Skip to content
Related Articles

Related Articles

Adaptive Histogram Equalization in Image Processing Using MATLAB

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Hard
  • Last Updated : 22 Nov, 2021

Histogram Equalization is a mathematical technique to widen the dynamic range of the histogram. Sometimes the histogram is spanned over a short range, by equalization the span of the histogram is widened. In digital image processing, the contrast of an image is enhanced using this very technique. 

Adaptive Histogram Equalization: Adaptive histogram equalization is a digital image processing technique used to enhance the contrast of images. It differs from normal histogram equalization in the respect that the adaptive method enhances the contrast locally. It divides the image into distinct blocks and computes histogram equalization for each section. Thus, AHE computes many histograms, each corresponding to a distinct section of the image. It enhances the local contrast and definitions of edges in all distinct regions of the image.


  • It computes the HE of distinct sections of the image.
  • It preserves the edges in distinct regions of the image.
  • It enhances the contrast locally.


AHE overamplifies the noise in relatively homogeneous regions of an image. To prevent this a variant of adaptive histogram equalization called contrast limited adaptive histogram equalization (CLAHE) is used.

Function Used:

  • imread( ) is in-built function used to read the image.
  • size( ) is in-built function used to get the size of image.
  • rgb2gray( ) is in-built function used to convert RGB image into grayscale image.
  • zeros(row, col) is in-built function used to create row*col matrix of zeros.
  • unit8( ) is in-built function used to convert double value into integer format.
  • blockproc( ) is in-built function used to apply HE function to distinct sections of the image.
  • length( ) is in-built function used to find the size of list.
  • imtool( ) is in-built function used to display image.
  • pause( ) is in-built function used to pause the system to execute next statements.


% MATLAB code for Histogram equalisation
% function to return resultant
% image: Apply on single channel only.
function res_img=myhistEq(img)
% Convert into grayscale if 
% image is coloured.
% Calculate frequency of each
% intensity value.
for i=1:x
    for j=1:y
% Calculate PDF for each intensity value.
for i=1:256
% Calculate the CDF for each intensity value.
for i=2:256
% Multiply by Maximum intensity value
% and round off the result.
for i=1:256
% Compute the new image.
for i=1:x
    for j=1:y
%%%%% UTILITY CODE %%%%%%%%
%blockproc() is block processing function.
%it applies normal HE on distinct block of
%defines sizes [m n]
for i=1:length(list)
    AHEq=blockproc(img,[100 100], fun);
    %AHEq=blockproc(img,[200 200], fun);
    %AHEq=blockproc(img,[250 200], fun);
    imtool close all;



AHE is better than ordinary HE when the image has extremely dark or bright spots. But AHE tends to overamplify the contrast in near-constant regions of the image since the histogram in such regions is highly concentrated. As a result, AHE may cause noise to be amplified in the near-constant region.


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!