CS6640 - Project 2

Sujin Philip (sujin@cs.utah.edu)
Back to Index

Basic Histogram Equalization:

Basic histogram equalization is quite straight forward. The ideas is to map the input image's intensities in such a way that the output image's intensities cover the entire range of intensities. This is achieved by using the Cumulative Distribution Function of the input image as the mapping function. This algorithm is implemented in the program histeq.cpp by the function "histeq". Following is the general algorithm of this function:
  1. Calculate the cdf of the input image.
  2. For each pixel in the input image, the corresponding output pixel intensity is calculated by using the cdf as a look-up function.
  3. The value found by the last step is then remaped to a range [min:max) and put in the output image.
The command line parameters for this program is:
$ ./histeq inImage bins min max
where bins is the number of "bins" to be used for the cdf and min and max  give the output image's intensity range.

Bellow are some examples of the output generated by this program:
Input
Output






In the original image the light behind the hut is saturated and the people standing at the window are not clearly visible due to poor contrast. Histogram equalization doesn't help much here because of the large white sunlight region. Histogram equalization in this case has created a sharp contrast region between the sky and the sunlight which makes the image look very unreal. On the other hand it has not enhanced the contrast in the window region enough to make the third person from the left clearly visible. From the histogram of both the images it can be seen that the histogram of the output is spread out relative to the input histogram, but the presence of the large saturated region of light is preventing effective contrast enhancement of the whole image. The plot of the cdf of the output image shows how the equalization has made it linear with a somewhat constant slope.

This next image is an image of a car. What's noteworthy about this image is that it has poor contrast but is virtually noiseless. Global histogram equalization should work very well for this image:






As expected, histogram equalization works really well for this image. The histogram of the output looks similar in shape to the input histogram but it is now spread out to cover the entire intensity range. As expected the output cdf has a relatively constant slope.







This image of the capitol building contains its dome in the foreground and the sky in the background. The contrast of this image is very poor. Contrast enhancement of this image does spread out its histogram but the output image is not as desired. Due to contrast enhancement noise in the sky region is now more clearly visible. The dome itself has become darker and there is not enough contrast there to make out the details. This is the kind of image for which AHE should work better than global histogram equalization.







As can be seen from the histogram of this image, the range of intensities is very small and has low values, due to which the image is very dark and has poor contrast. After applying histogram equalization the shape of the histogram is similar to the original but now the intensities cover the entire range. Its easier to make out the details in the equalized image but the noise has also been enhanced.







This image is similar to the previous image, but in this case the image is lighter at the bottom left corner compared to the rest of the image. Histogram equalization spreads out the histogram of this image which improve the contrast of the darker regions of the image but the bottom left corner of the image has now become too bright. This is another example where AHE would perform better.







In this medical image, the region of interest is in the white area but due to poor contrast the details within this area are difficult to make out. Histogram equalization enhances the contrast and the details are now more clearly visible. Small variations in tone in the dark background at top right region is also enhanced.







This looks like a photograph taken at dusk without a flash, resulting in a dark low contrast image, but the background sky is slightly illuminated at the top right corner. Histogram equalization of this image works similar to the example of the crowd image in that here too, global contrast enhancement has caused the region at the top-right to become brighter than the rest of the image and the contrast at the left of the image has not been enhanced very much.

The above examples show that global histogram equalization works best for images that have less noise and don't contain regions of relative brightness or darkness. Comparing the histograms of the input and output images its seen that histogram equalization spreads out the histogram to cover the entire range of intensities in such a way so as to make the cdf of the image to have a somewhat constant slope. Ideally histogram equalization should make the histogram of the image flat and the cdf perfectly linear, but since we are working with discrete samples the resulting histograms are not flat and the cdf has a stair-step appearance.

Back to Index