Image Contrast Enhancement | Cumulative Histogram Equalization

A histogram is a graph which shows frequency of anything. The bars that represent frequency of occurring of data in the whole data set.

The histogram of an image normally refers to a histogram of the pixel intensity values. histogram is a graph showing the number of pixels in an image at each different intensity value found in that image. The histogram plots the number of pixels in the image at vertical axis and with a particular brightness value or gray level intensities at horizontal axis.

Histogram Equalization

Histogram equalization is used to enhance contrast. It is a process for increasing the contrast in an image by spreading the histogram. The idea of histogram equalization is the distributed pixels in uniformly over the whole intensity range, so the Original Image is transformed to the output image which has a flat histogram. The increase of dynamic range produces an increase in contrast.

For cumulative histogram equalization, the algorithmic steps are as follows.

  1. Create the histogram for the image.
  2. Calculate the cumulative distribution function histogram.
  3. Calculate the new values through the general histogram equalization formula.
  4. Assign new values for each gray value in the image.
Algorithm of matlab code given below
  1. Load image
  2. Get image size
  3. Get image histogram
  4. Get cumulative distribution function
  5. Calculate new values via general histogram equalization formula
  6. Build new image by replacing original gray values with the new gray values
  7. Show output image & its histogram as result.

    Download code histogram-equalization.zip(8 downloads)

 Input Image :                    Output Image:

input-histogram-imageoutput-histogram-eq-image

 

 

Following figure shows the input , output images with its respective histograms.

Matlab-output-image-histogram-eq

histeq is matlab built in function which return the grayscale transformation T that maps gray levels in the image I to gray levels in K.

Output Image

output-matlab-code-histogram-equalization

Download code histogram-equalization.zip(8 downloads)