/*************************************************************************** * Func: histogram_specification * * * * Desc: perform histogram specification on an input image * * * * Params: buffer - pointer to input image * * number_of_pixel - total number of pixels in image * * desired_histogram - desired histogram of output image * ***************************************************************************/ void histogram_specification(image_ptr buffer, unsigned long number_of_pixels, unsigned long *desired_histogram) { float histogram[256]; /* image histogram */ float sum_hist[256]; /* normalized sum of histogram elements */ float scale_factor; /* scaling factor used to normalize hist */ float difference; /* used to determine inverse transform */ unsigned long i; /* loop variable */ unsigned long sum; /* sum used to determine sum of hist */ unsigned char inv_hist[256]; /* inverse histogram indices */ int j; /* loop variable */ int min; /* min difference computing inverse trans */ /* clear histogram to 0 */ for(i=0; i<256; i++) histogram[i]=0; /* calculate histogram */ for(i=0; i