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:
- Calculate the cdf of the input image.
- For each pixel in the input image, the corresponding output pixel
intensity is calculated by using the cdf as a look-up function.
- 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:
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
global histogram equalization.