Adaptive Histogram Equalization in Image Processing Using MATLAB Last Updated : 22 Nov, 2021 Comments Improve Suggest changes Like Article Like Report 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. Advantages: 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.Disadvantage: 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 % MATLAB code for Histogram equalisation % function to return resultant % image: Apply on single channel only. function res_img=myhistEq(img) Freq=zeros(1,256); [x,y,z]=size(img); % Convert into grayscale if % image is coloured. if(z==3) img=rgb2gray(img); end % Calculate frequency of each % intensity value. for i=1:x for j=1:y Freq(img(i,j)+1)=Freq(img(i,j)+1)+1; end end % Calculate PDF for each intensity value. PDF=zeros(1,256); Total=x*y; for i=1:256 PDF(i)=Freq(i)/Total; end % Calculate the CDF for each intensity value. CDF=zeros(1,256); CDF(1)=PDF(1); for i=2:256 CDF(i)=CDF(i-1)+PDF(i); end % Multiply by Maximum intensity value % and round off the result. Result=zeros(1,256); for i=1:256 Result(i)=uint8(CDF(i)*(255)); end % Compute the new image. new_img=zeros(size(img)); for i=1:x for j=1:y new_img(i,j)=Result(img(i,j)+1); end end res_img=new_img; end %%%%% UTILITY CODE %%%%%%%% fun=@(block_struct)myhisteq(block_struct.data); %blockproc() is block processing function. %it applies normal HE on distinct block of %defines sizes [m n] list=["hat_lady.jfif"]; for i=1:length(list) img=imread(list(i)); AHEq=blockproc(img,[100 100], fun); %AHEq=blockproc(img,[200 200], fun); %AHEq=blockproc(img,[250 200], fun); %HEq=myhisteq(img); %imtool(HEq,[]); imtool(AHEq,[]); imtool(img,[]); pause(10); imtool close all; Output: 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. Comment More infoAdvertise with us Next Article Adaptive Histogram Equalization in Image Processing Using MATLAB pintusaini Follow Improve Article Tags : Software Engineering MATLAB image-processing Similar Reads Histogram Equalization in Digital Image Processing A digital image is a two-dimensional matrix of two spatial coordinates, with each cell specifying the intensity level of the image at that point. So, we have an N x N matrix with integer values ranging from a minimum intensity level of 0 to a maximum level of L-1, where L denotes the number of inten 5 min read How to Perform Contrast Enhancement Using Histogram Equalization in MATLAB? Image enhancement is a manner to enhance the appearance of photographs/images to human viewers or to image processing device performance. Image Enhancement strategies may be categorized into classes as spatial area and frequency area. There are 5 image enhancement algorithms in the spatial domain th 3 min read Digital Image Processing Algorithms using MATLAB Like it is said, "One picture is worth more than ten thousand words "A digital image is composed of thousands and thousands of pixels. An image could also be defined as a two-dimensional function, f(x, y), where x and y are spatial (plane) coordinates and therefore the amplitude of f at any pair of 8 min read What Color Histogram Equalization in MATLAB? A Histogram is a graph-based representation technique between a number of pixels and intensity values. it is a plot of the frequency of occurrence of an event. So in this article, we will understand how we generate the and Equalize Histogram of a color image. Histogram EqualizationHistogram Equaliz 5 min read Histogram Equalization Without Using histeq() Function in MATLAB Histogram Equalization is the most famous contrast management technique for digital image processing with different image data intensity level values. or we can say it's a Pixels brightness transformations technique. The histogram is basically a graph-based representation method that clarifies the 4 min read Binarization of Digital Images Using Otsu Method in MATLAB Binarization is important in digital image processing, mainly in computer vision applications. Thresholding is an efficient technique in binarization. The choice of thresholding technique is crucial in binarization. There are various thresholding algorithms have been proposed to define the optimal t 4 min read Image Sharpening Using Laplacian Filter and High Boost Filtering in MATLAB Image sharpening is an effect applied to digital images to give them a sharper appearance. Sharpening enhances the definition of edges in an image. The dull images are those which are poor at the edges. There is not much difference in background and edges. On the contrary, the sharpened image is tha 4 min read Edge detection using first derivative operator in MATLAB An edge in an image is a significant local change in image intensity, usually associated with a discontinuity in image intensity or the first derivative of image intensity. The discontinuities in the intensity of the image can be stepped discontinuities, in which the intensity of the image changes f 3 min read MATLAB - Image Edge Detection using Sobel Operator from Scratch Sobel Operator: It is a discrete differentiation gradient-based operator. It computes the gradient approximation of image intensity function for image edge detection. At the pixels of an image, the Sobel operator produces either the normal to a vector or the corresponding gradient vector. It uses tw 3 min read Image Processing in MATLAB | Fundamental Operations 1. Reading Images Images are read into the MATLAB Environment using imread() function which takes filename with applicable extension as the argument For Example: >> I=imread('nature.jpg'); This will read JPEG image 'nature' into the image array. Note: The semicolon(;) at the end of command lin 3 min read Like