Adaptive Histogram Equalization in Image Processing Using MATLAB


Histogram equalization is a method used in image processing to improve the dynamic range of the histogram. This mathematical technique is widely used for enhancing the contrast of an image in digital image processing. This technique provides a wider and balanced distribution of pixel values in the image. Histogram equalization technique basically works by enhancing the range of brightness values in the image which makes it more visually attractive.

Introduction to Adaptive Histogram Equalization (AHE)

In digital image processing, the adaptive histogram equalization (AHE) is a method used for enhancing the contrast of an image. The adaptive histogram equalization technique is different from the traditional histogram equalization, as it first divides the image into smaller sub-regions and then enhances the contrast in the image by applying histogram equalization technique to each sub-region separately.

Therefore, the adaptive histogram equalization technique provides local contrast enhancement in the image. Hence, this becomes a more effective technique in the case of images having varying illumination conditions.

Benefits of Adaptive Histogram Equalization

Adaptive histogram equalization offers various advantages in digital image processing. A few of them are listed here:

  • Adaptive histogram equalization enhances the contrast of the images by improving the brightness levels across a wider range.

  • Adaptive histogram equalization provides local contrast enhancement in the image, which is very useful in images with varying brightness levels.

  • Adaptive histogram equalization can improve overall visibility of the images captured in environments with low-light conditions, varying brightness levels, etc.

MATLAB Function used for Adaptive Histogram Equalization

The following MATLAB functions are used to write a MATLAB code to enhance the contrast of an image by using the adaptive histogram equalization:

  • imread(): This is a built-in MATLAB function used to read an image.

  • size(): This is a MATLAB function used to determine the size of the image.

  • rgb2gray(): This is also a built-in MATLAB function used to convert an RGB image into a grayscale image.

  • adapthisteq(): This is a built-in function in MATLAB to perform adaptive histogram equalization on image.

  • imshow(): This is a MATLAB function used to display image.

MATLAB Program Example

The following is a MATLAB program example to illustrate how to perform adaptive histogram equalization in image processing:
%MATLAB Code to perform adaptive histogram equalization in image processing
% Call imread() function to read the image that has to be enhanced
img = imread('https://www.tutorialspoint.com/assets/questions/media/14304-1687425236.jpg');
% Call size() and rgb2gray() functions to get size and convert the image to grayscale if necessary
if size(img, 3) == 3
   img = rgb2gray(img);
end
% Call adapthisteq() function to perform Adaptive Histogram Equalization
enhanced_img = adapthisteq(img);
% Call imshow() function to display the original and enhanced images
figure;
subplot(1, 2, 1); imshow(img); title('Original Image');
subplot(1, 2, 2); imshow(enhanced_img); title('Enhanced Image');

Output

Conclusion

In this MATLAB program, we start by calling the “imread()” function to read the input image. Then, we call “size() and rgb2gray()” functions to get the size and convert the color image to grayscale. After that we call “adapthisteq()” function to perform adaptive histogram equalization on the image. This function automatically divides the entire image into smaller regions and then apply histogram equalization to each region separately. Finally, we call “imshow()” function to display the original and enhanced images.

Updated on: 18-Jul-2023

159 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements