/*************************************************************************** * Func: histogram_equalize * * * * Desc: histogram equalize an input image and write it out * * * * Params: buffer - pointer to image in memory * * number_of_pixels - total number of pixels in image * ***************************************************************************/ void histogram_equalize(image_ptr buffer, unsigned long number_of_pixels) { unsigned long histogram[256]; /* image histogram */ unsigned long sum_hist[256]; /* sum of histogram elements */ float scale_factor; /* normalized scale factor */ unsigned long i; /* index variable */ unsigned long sum; /* variable used to increment sum of hist */ /* clear histogram to 0 */ for(i=0; i<256; i++) histogram[i]=0; /* calculate histogram */ for(i=0; i