Histograms - 2: Histogram Equalization
- We will learn the concepts of histogram equalization and use it to improve the contrast of our images.
Theory
Consider an image whose pixel values are confined to some specific range of values only. For eg, brighter image will have all pixels confined to high values. But a good image will have pixels from all regions of the image. So you need to stretch this histogram to either ends (as given in below image, from wikipedia) and that is what Histogram Equalization does (in simple words). This normally improves the contrast of the image.
I would recommend you to read the wikipedia page on Histogram Equalization for more details about it. It has a very good explanation with worked out examples, so that you would understand almost everything after reading that.
Histograms Equalization in OpenCV
We use the function: cv.equalizeHist (src, dst)