home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_02
/
1102066a
< prev
next >
Wrap
Text File
|
1992-12-13
|
1KB
|
37 lines
/********************************************
*
* smooth_histogram(...
*
* This function smoothes the input histogram
* and returns it. It uses a simple averaging
* scheme where each point in the histogram
* is replaced by the average of itself and
* the two points on either side of it.
*
*********************************************/
smooth_histogram(histogram)
unsigned long histogram[];
{
int i;
unsigned long new_hist[GRAY_LEVELS+1];
zero_histogram(new_hist);
new_hist[0] = (histogram[0] + histogram[1])/2;
new_hist[GRAY_LEVELS] =
(histogram[GRAY_LEVELS] +
histogram[GRAY_LEVELS-1])/2;
for(i=1; i<GRAY_LEVELS; i++){
new_hist[i] = (histogram[i-1] +
histogram[i] +
histogram[i+1])/3;
}
for(i=0; i<=GRAY_LEVELS; i++)
histogram[i] = new_hist[i];
} /* ends smooth_histogram */