What is Histogram Equalization and how it works?

  1. Introduction
  2. Histogram equalization
  3. Steps Involved 
  4. Algorithm
  5. Example
  6. CLAHE (Contrast Limited Adaptive Histogram Equalization)

Contributed by: Sreekanth

Introduction to Histogram Equalization

Image pre-processing is the term for operations on the images at the lowest level of abstraction. These operations do not increase image information content, but they decrease it if entropy is an information measure. The aim of pre-processing is an improvement of the image data that suppresses undesired distortions or enhances some image features relevant for further processing and analysis tasks.  

There are four different types of Image Pre-Processing techniques, and they are listed below.

  1. Pixel brightness transformations/ Brightness corrections
  2. Geometric Transformations
  3. Image Filtering and Segmentation 
  4. Fourier transform and Image restoration

Histogram equalization is one of the Pixel brightness transformations techniques. It is a well-known contrast enhancement technique due to its performance on almost all types of image. 

Also Read: What is Image Recognition and how is it used?

Histogram equalization

A histogram is a representation of frequency distribution. It is the basis for numerous spatial domain processing techniques. Histogram manipulation can be used for image enhancement. 

Contrast is defined as the difference in intensity between two objects in an image. If the contrast is too low, it is impossible to distinguish between two objects, and they are seen as a single object. 

Histogram equalization is a widely used contrast-enhancement technique in image processing because of its high efficiency and simplicity. It is one of the sophisticated methods for modifying the dynamic range and contrast of an image by altering that image such that its intensity histogram has the desired shape. It can be classified into two branches as per the transformation function is used.

  • Global histogram equalization (GHE)

GHE is very simple and fast, but its contrast enhancement power is low. Here the histogram of the whole input image is used to compute the histogram transformation function. As a result, the dynamic range of the image histogram is flattened and stretched. The overall contrast is improved.

  • Local histogram equalization (LHE)

LHE can enhance the overall contrast more effectively.

One of the drawbacks of histogram equalization is that it can change the mean brightness of an image significantly as a consequence of histogram flattening and sometimes this is not a desirable property when preserving the original mean brightness of a given image is necessary. Bi-Histogram Equalization was proposed to overcome this problem.

Check out these interesting Machine Learning Free Courses

Steps Involved 

  1. Get the input image
  2. Generate the histogram for the image
  3. Find the local minima of the image
  4. Divide the histogram based on the local minima
  5. Have the specific gray levels for each partition of the histogram
  6. Apply the histogram equalization on each partition


  • Compute the histogram of pixel values of the input image. The histogram places the value of each pixel 𝑓[𝑥,𝑦] into one of L uniformly-spaced buckets ℎ[𝑖]

Where 𝐿=2^8 and the image dimension is 𝑀×𝑁

  • Calculate the cumulative distribution function
  • Scale the input image using the cumulative distribution function to produce the output image.

Where CDFmin is the smallest non-zero value of the cumulative distribution function

CLAHE (Contrast Limited Adaptive Histogram Equalization)

The above histogram equalization considers the global contrast of the image, and in many cases, it is not a good idea. The human pic in the original diagram is not shown correctly in the histogram equalization output. Even though the contrast of the image had been improved, we lost some of the information due to over brightness. The reason is that the histogram is not confined to the local region.

Adaptive Histogram Equalization helps to solve this issue. In this method, the image is divided into small blocks, and each of these blocks is histogram equalized. 

The same image has been converted, and below is the output of Adaptive Histogram Equalization.

This brings us to the end of the blog about Histogram Equalization. We hope you found this helpful. If you wish to learn more about such concepts, head over to Great Learning Academy and join our free online courses today.

Source : https://www.mygreatlearning.com/blog/artificial-intelligence/