Enhancing the image contrast
Now that you understand what a histogram is and how to calculate it, it is time to look at one of the most widely used image enhancing techniques: the histogram equalization. The histogram equalization technique is used to enhance the image contrast, that is, the difference between the minimum and maximum intensity values in order to strengthen image details that could be washed out.
Understanding histogram equalization
From an abstract point of view, what the histogram equalization does is it finds a function that takes the image's original histogram and transforms it to a stretched histogram with a uniform distribution of the image intensity values, thus enhancing the image contrast.
In practice, histogram equalization doesn't produce a perfectly equalized output histogram; however, it forms a good approximation of the needed transformation that spreads the intensity values more evenly over the defined equalization range of the image: