Histogram equalization
Once the image histogram is calculated, it can be modelled so that the image is modified and the histogram has a different shape. This is useful to change the low-contrast levels of images with narrow histograms, since this will spread out the gray levels and thus enhance the contrast. Histogram modeling, also known as histogram transfer, is a powerful technique for image enhancement. In histogram equalization, the goal is to obtain a uniform histogram for the output image. That is, a flat histogram where each pixel value has the same probability. In OpenCV, histogram equalization is performed with the function void equalizeHist(InputArray src, OutputArray dst)
. The first parameter is the input image and the second one is the output image with the histogram equalized.
The following EqualizeHist_Demo
example shows how to calculate and display the histogram equalized and the effect on the two-dimensional image:
#include "opencv2/highgui/highgui.hpp" #include...