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 >
Wrap
Text File
|
1992-12-13
|
990b
|
32 lines
/**************************************************
*
* 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 */