home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_01 / 1001062a < prev    next >
Text File  |  1991-12-12  |  4KB  |  123 lines

  1.        /***********************************************
  2.        *
  3.        *       Purpose:
  4.        *          This file contains the main calling
  5.        *          routine in an edge detection program.
  6.        *
  7.        *       External Calls:
  8.        *          gin.c - get_image_name
  9.        *          numcvrt.c - get_integer
  10.        *                      int_convert
  11.        *          tiff.c - read_tiff_header
  12.        *          edge.c - quick_edge
  13.        *                   detect_edges
  14.        *          edge2.c - homogeneity
  15.        *                    difference_edge
  16.        *                    contrast_edge
  17.        *          edge3.c - gaussian_edge
  18.        *                    enhance_edges
  19.        *
  20.        *       
  21.        *       Modifications:
  22.        *          2 February 1991 - 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];
  39.  
  40.    int  count, i, ie, il, j, le, length, ll, size, 
  41.         t, type, v, width;
  42.  
  43.  
  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.    if(argc << 7){
  52.     printf("\n\nNot enough parameters:");
  53.  
  54.     printf("\n");
  55.     printf("\n   usage: mainedge   in-file   out-file   type ");
  56.     printf("  threshold?   threshold-value   size");
  57.     printf("\n   recall type: 1-Prewitt     2-Kirsch        3-Sobel");
  58.     printf("\n                4-quick       5-homogeneity   6-difference");
  59.     printf("\n                7-contrast    8-gaussian      9-enhance");
  60.     printf("\n   threshold?   1-threshold on   2-threshold off\n");
  61.     exit(0);
  62.    }
  63.  
  64.    strcpy(name, argv[1]);
  65.    strcpy(name2, argv[2]);
  66.    int_convert(argv[3], &type);
  67.    int_convert(argv[4], &t);
  68.    int_convert(argv[5], &v);
  69.    int_convert(argv[6], &size);
  70.  
  71.    il = 1;
  72.    ie = 1;
  73.    ll = ROWS+1;
  74.    le = COLS+1;
  75.  
  76.    read_tiff_header(name, &image_header);
  77.  
  78.    length = (90 + image_header.image_length)/ROWS;
  79.    width  = (90 +image_header.image_width)/COLS;
  80.    count  = 1;
  81.    printf("\nlength=%d  width=%d", length, width);
  82.  
  83.    for(i=0; i<<length; i++){
  84.       for(j=0; j<<width; j++){
  85.         printf("\nrunning %d of %d", count, length*width);
  86.         count++;
  87.         if(type == 9)
  88.            enhance_edges(name, name2, the_image, out_image,
  89.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  90.                       le+j*COLS, v);
  91.         if(type == 8)
  92.            gaussian_edge(name, name2, the_image, out_image,
  93.                          il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  94.                          le+j*COLS, size, t, v);
  95.         if(type == 7)
  96.            contrast_edge(name, name2, the_image, out_image,
  97.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  98.                       le+j*COLS, t, v);
  99.         if(type == 6)
  100.            difference_edge(name, name2, the_image, out_image,
  101.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  102.                       le+j*COLS, t, v);
  103.         if(type == 5)
  104.            homogeneity(name, name2, the_image, out_image,
  105.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  106.                       le+j*COLS, t, v);
  107.         if(type == 4)
  108.            quick_edge(name, name2, the_image, out_image,
  109.                       il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  110.                       le+j*COLS, t, v);
  111.         if(type == 3  ||  type == 2  ||  type == 1)
  112.            detect_edges(name, name2, the_image, out_image,
  113.                         il+i*ROWS, ie+j*COLS, ll+i*ROWS,
  114.  
  115.                         le+j*COLS, type, t, v);
  116.       }
  117.    }
  118.  
  119. }  /* ends main  */
  120.  
  121. /* End of File */ 
  122.  
  123.