Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Image Processing


May 1991/New Products/Listing 1

Listing 1

/*************************************************
*
*  file d:\cips\cips.c
*
*  Functions: This file contains
*
*      main
*      clear_text_screen
*      show_menu
*      show_image
*
*  External Calls:
*    numcvrt.c - get_integer
*    gin.c - get_image_name
*    rtiff.c - read_tiff_image
*    tiff.c - read_tiff_header
*    rstring.c - read_string
*    display.c - display_image
*           display_menu_for_display_image
*    pi.c - print_image
*
*  Modifications:
*     26 June 1990 - created
*
************************************************/

#include "d:\cips\cips.h"


short the_image[ROWS] [COLS];
short out_image[ROWS] [COLS];

main()
{

 char   color_transform [80],
       monitor_type [80],
       name[80],
       name2[80],
       rep[80];

 int    color,
       display_colors,
       file_d,
       first_element,
       first_line,
       i,
       ie,
       il,
       image_colors,
       invert,
       j,
       le,
       ll,
       not_finished,
       response;

 long   mean_of_pixels;
 struct tiff_header_struct image_header;

 clear_text_screen();

 not_finished =  1;
 response   = 99;

 il    = 1;
 ie    = 1;
 ll         = ROWS+1;
 le         = COLS+1;

 display_colors = 16;
 image_colors   = 16;
 invert         =  0;
 strcpy(color_transform, "Straight mode");
 strcpy(monitor_type, "VGA" );
 strcpy(name, "d:/pix/adam256.tif");

while(not_finished){
   show_menu();

   get_integer(&response);

   switch (response){

   case 1:/* display image header */
      get_image_name(name);
      read_tiff_header(name, &image_header);
      printf("\n\nCIPS> The image header is:");
      printf("\n\t\twidth=%ld length=%ld start=%ld bits=%ld",
         image_header.image_width,
         image_header.image_length,
         image_header.strip_offset,
         image_header.bits_per_pixel);
      printf("\nCIPS> Hit Enter to continue");
      read-string( rep);
      break;

   case 2:/* display image numbers */
      get_image_name(name);
      get_parameters(&il, &ie, &ll, &le);
      read-tiff_image(name, the_image, il, ie; ll, le);
      show_image(the_image, il, ie);
      break;

   case 3:   /* print image numbers */
      get_image_name(name);
      get_parameters(&il, &ie, &ll, &le);
      read_tiff_image(name, the_image, il, ie, ll, le);
      print_image(the_image, name, 1, 1, 1, 100, 18,
             il, ie);
      break;

   case 4:   /* display image */
      get_image_name(name);
      read_tiff_header(name, &image_header);
      get_parameters(&il, &ie, &ll, &le);
      display_menu_for_display_image(&image_colors,
           &display_colors, &invert,
           color_transform, monitor_type);
      display_image(name, the_image, il, ie,
           ll, le, &image_header, monitor_type,
           color_transform, invert,
           image_colors, display_colors);
      break;

   case 20: /* exit system */
      not_finished = 0;
      break;

   default:
      printf("\nCould not understand response, try again");
      break;

     }              /* ends switch response          */
  }               /* ends while not finished */
}               /* ends main                  */
/******************************************************
*   clear_text_screen()
*
*   This calls Microsoft C functions to clear the text
*   screen and set a blue background with gray text.
*******************************************************/

clear_text_screen()
{
   _setvideomode(_TEXTC80);     /* MSC 6.0 statements */
   _setbkcolor(1);
   _settextcolor(7);
   _clearscreen(_GCLEARSCREEN );
}  /* ends clear_text_screen */

/******************************************************
*   show_image(...
*
*   This function displays the image numbers on the
*   screen as text. It displays 20 rows with 18
*   columns each.
*******************************************************/

show_image(image, il,  ie)
   int il, ie;
   short image[ROWS][COLS];
{
   int i, j;
   printf("\n ");
   for(i=0; i<18; i++)
printf("-%3d", i+ie);

   for(i=0; i<20; i++){
printf("\n%2d>", i+il);
for(j=0; j<18; j++)
   printf("-%3d", image[i] [j] );
   }

   printf("\nPress enter to continue");
   get_integer(&i);

}   /* ends show_image */

/******************************************************
*   show_menu(..
*   This function displays the CIPS main menu.
******************************************************/

show_menu()
{

  printf("\n\n\nWelcome to CIPS");
  printf("\nThe C Image Processing System");
  printf("\nThese are you choices:\n");
  printf("\n\t1.  Display image header");
  printf("\n\t2.  Show image numbers");
  printf("\n\t3.  Print image numbers");
  printf("\n\t4.  DispLay image");
  printf("\n\t20. Exit system");
  printf("\n\nEnter choice _\b");
}    /* ends show_menu */


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.