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

  1.    /**************************************************
  2.    *
  3.    *   threshold_image_array(...
  4.    *
  5.    *   This function thresholds an input image array
  6.    *   and produces a binary output image array.
  7.    *   If the pixel in the input array is between
  8.    *   the hi and low values, then it is set to value.
  9.    *   Otherwise, it is set to 0.
  10.    *
  11.    ***************************************************/
  12.  
  13. threshold_image_array(in_image, out_image, hi, low, value)
  14.    short hi, low, in_image[ROWS][COLS],
  15.          out_image[ROWS][COLS], value;
  16. {
  17.    int   counter = 0, i, j;
  18.    for(i=0; i<ROWS; i++){
  19.       for(j=0; j<COLS; j++){
  20.          if(in_image[i][j] >= low  &&
  21.             in_image[i][j] <= hi){
  22.             out_image[i][j] = value;
  23.             counter++;
  24.          }
  25.          else
  26.             out_image[i][j] = 0;
  27.       }  /* ends loop over j */
  28.    }  /* ends loop over i */
  29.    printf("\n\tTIA> set %d points", counter);
  30. }  /* ends threshold_image_array */
  31.  
  32.