home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_11 / 1011107a < prev    next >
Text File  |  1992-09-02  |  4KB  |  132 lines

  1.        /***********************************************
  2.        *
  3.        *       file d:\cips\mainas.c
  4.        *
  5.        *       Functions: This file contains
  6.        *          main
  7.        *
  8.        *       Purpose:
  9.        *          This file contains the main calling
  10.        *          routine in an image addition and subtraction
  11.        *          program.
  12.        *
  13.        *       External Calls:
  14.        *          gin.c - get_image_name
  15.        *          numcvrt.c - get_integer
  16.        *                      int_convert
  17.        *          tiff.c - read_tiff_header
  18.        *          addsub.c - add_image
  19.        *                     subtract_image
  20.        *
  21.        *       Modifications:
  22.        *          1 April 1992 - created
  23.        *
  24.        *************************************************/
  25.  
  26. #include "d:\cips\cips.h"
  27.  
  28.  
  29.  
  30. short the_image[ROWS][COLS];
  31. short out_image[ROWS][COLS];
  32.  
  33. main(argc, argv)
  34.    int argc;
  35.    char *argv[];
  36. {
  37.  
  38.    char     name[80], name2[80], name3[80];
  39.    int      count, i, j, length, lw,
  40.             type, width,
  41.             il1, ie1, ll1, le1,
  42.             il2, ie2, ll2, le2,
  43.             il3, ie3, ll3, le3;
  44.    struct   tiff_header_struct image_header;
  45.  
  46.    _setvideomode(_TEXTC80); /* MSC 6.0 statements */
  47.    _setbkcolor(1);
  48.    _settextcolor(7);
  49.    _clearscreen(_GCLEARSCREEN);
  50.  
  51.        /***********************************************
  52.        *
  53.        *       Interpret the command line parameters.
  54.        *
  55.        ************************************************/
  56.  
  57.    if(argc < 5 || argc > 5){
  58.     printf(
  59.      "\n"
  60.      "\n usage: mainas in1-file in2-file out_file add-subtract"
  61.      "\n"
  62.      "\n   recall add-subtract a=add s=subtract\n");
  63.     exit(0);
  64.    }
  65.  
  66.    strcpy(name, argv[1]);
  67.    strcpy(name2, argv[2]);
  68.    strcpy(name3, argv[3]);
  69.  
  70.    il1 = 1;
  71.    ie1 = 1;
  72.    ll1 = ROWS+1;
  73.    le1 = COLS+1;
  74.  
  75.    il2 = 1;
  76.    ie2 = 1;
  77.    ll2 = ROWS+1;
  78.    le2 = COLS+1;
  79.  
  80.    il3 = 1;
  81.    ie3 = 1;
  82.    ll3 = ROWS+1;
  83.    le3 = COLS+1;
  84.  
  85.        /***********************************************
  86.        *
  87.        *       Read the input image header and setup
  88.        *       the looping counters.
  89.        *
  90.        *       If high or low pass filtering, setup
  91.        *       the filter mask array.
  92.        *
  93.        ************************************************/
  94.  
  95.    read_tiff_header(name, &image_header);
  96.  
  97.    length = (90 + image_header.image_length)/ROWS;
  98.    width  = (90 + image_header.image_width)/COLS;
  99.    count  = 1;
  100.    lw     = length*width;
  101.    printf("\nlength=%d  width=%d", length, width);
  102.  
  103.        /***********************************************
  104.        *
  105.        *       Loop over the input images and either
  106.        *       add or subtract them.
  107.        *
  108.        ************************************************/
  109.  
  110.    for(i=0; i<length; i++){
  111.       for(j=0; j<width; j++){
  112.          printf("\nrunning %d of %d", count, lw);
  113.          count++;
  114.  
  115.          if(argv[4][0] == 'a' || argv[4][0] == 'A')
  116.             add_image(name, name2, name3, 
  117.                the_image, out_image,
  118.                 il1+i*ROWS, ie1+j*COLS, ll1+i*ROWS, le1+j*COLS,
  119.                 il2+i*ROWS, ie2+j*COLS, ll2+i*ROWS, le2+j*COLS,
  120.                 il3+i*ROWS, ie3+j*COLS, ll3+i*ROWS, le3+j*COLS);
  121.  
  122.          if(argv[4][0] == 's' || argv[4][0] == 'S')
  123.             subtract_image(name, name2, name3, 
  124.                the_image, out_image,
  125.                 il1+i*ROWS, ie1+j*COLS, ll1+i*ROWS, le1+j*COLS,
  126.                 il2+i*ROWS, ie2+j*COLS, ll2+i*ROWS, le2+j*COLS,
  127.                 il3+i*ROWS, ie3+j*COLS, ll3+i*ROWS, le3+j*COLS);
  128.  
  129.       }  /* ends loop over j */
  130.    }  /* ends loop over i */
  131. }  /* ends main  */
  132.