OpenCV  3.4.19
Open Source Computer Vision
Histogram Equalization

Prev Tutorial: Affine Transformations

Next Tutorial: Histogram Calculation

Goal

In this tutorial you will learn:

Theory

What is an Image Histogram?

Histogram_Equalization_Theory_0.jpg

What is Histogram Equalization?

Histogram_Equalization_Theory_1.jpg

How does it work?

Code

Explanation

As it can be easily seen, the only arguments are the original image and the output (equalized) image.

Results

  1. To appreciate better the results of equalization, let's introduce an image with not much contrast, such as:

    Histogram_Equalization_Original_Image.jpg

    which, by the way, has this histogram:

    Histogram_Equalization_Original_Histogram.jpg

    notice that the pixels are clustered around the center of the histogram.

  2. After applying the equalization with our program, we get this result:

    Histogram_Equalization_Equalized_Image.jpg

    this image has certainly more contrast. Check out its new histogram like this:

    Histogram_Equalization_Equalized_Histogram.jpg

    Notice how the number of pixels is more distributed through the intensity range.

Note
Are you wondering how did we draw the Histogram figures shown above? Check out the following tutorial!