Listing 2 Function for image thresholding

   /*********************************************
   *
   *   threshold_image_array(...
   *
   *   This function thresholds an input image array
   *   and produces a binary output image array.
   *   If the pixel in the input array is between
   *   the hi and low values, then it is set to value.
   *   Otherwise, it is set to 0.
   *
   *********************************************/

threshold_image_array(in_image, out_image, hi, low, value)
   short hi, low, in image[ROWS][COLS],
         out_image[ROWS][COLS], value;
{
   int counter = 0, i, j;
   for(i=0; i<ROWS; i++){
      for(j=0; j<COLS; j++){
         if(in_image[i][j] >= low &&
            in_image[i][j] <= hi){
            out_image[i][j] = value;
            counter++;
         }
         else
            out_image[i][j] = 0;
      }  /* ends loop over j */
   )  /* ends loop over i */
   printf("\n\tTIA> set %d points", counter);
}  /* ends threshold_image_array */
/* End of File */