home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_02 / 1102073a < prev    next >
Text File  |  1992-12-13  |  2KB  |  48 lines

  1.    /**************************************************
  2.    *
  3.    *   manual_threshold_segmentation(...
  4.    *
  5.    *   This function segments an image using thresholding
  6.    *   given the hi and low values of the threshold
  7.    *   by the calling routine.  It reads in an image
  8.    *   and writes the result to the output image.
  9.    *
  10.    *   If the segment parameter is 0, you only
  11.    *   threshold the array - you do not segment.
  12.    *
  13.    ***************************************************/
  14.  
  15. manual_threshold_segmentation(in_name, out_name,
  16.                               the_image, out_image,
  17.                               il, ie, ll, le,
  18.                               hi, low, value, segment)
  19.    char   in_name[], out_name[];
  20.    int    il, ie, ll, le, segment;
  21.    short  hi, low, the_image[ROWS][COLS],
  22.           out_image[ROWS][COLS], value;
  23. {
  24.    int    length, width;
  25.    struct tiff_header_struct image_header;
  26.  
  27.    if(does_not_exist(out_name)){
  28.       printf("\n\nMTS> output file does not exist %s",
  29.               out_name);
  30.       read_tiff_header(in_name, &image_header);
  31.       round_off_image_size(&image_header,
  32.                            &length, &width);
  33.       image_header.image_length = length*ROWS;
  34.       image_header.image_width  = width*COLS;
  35.       create_allocate_tiff_file(out_name, &image_header,
  36.                                 out_image);
  37.    }  /* ends if does_not_exist */
  38.  
  39.    read_tiff_image(in_name, the_image, il, ie, ll, le);
  40.    threshold_image_array(the_image, out_image,
  41.             hi, low, value);
  42.    if(segment == 1)
  43.       grow(out_image, value);
  44.    write_array_into_tiff_image(out_name, out_image,
  45.                                il, ie, ll, le);
  46. }  /* ends manual_threshold_segmentation */
  47.  
  48.