0% found this document useful (0 votes)
32 views1 page

Histogram Equalization

This function takes an image name as input, reads the image into a matrix, calculates the image histogram, cumulative distribution function (CDF) and normalized CDF. It then maps the pixel values of the original image to the normalized CDF to perform histogram equalization. Finally, it displays the equalized image and overlays the equalized image histogram.

Uploaded by

Rohan Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views1 page

Histogram Equalization

This function takes an image name as input, reads the image into a matrix, calculates the image histogram, cumulative distribution function (CDF) and normalized CDF. It then maps the pixel values of the original image to the normalized CDF to perform histogram equalization. Finally, it displays the equalized image and overlays the equalized image histogram.

Uploaded by

Rohan Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

function [a] = hist_equal( name )

a = imread(name);
hist = histo(name);
cdf = zeros(1,256);
mincdf = 0;
for i=1:256
if(i==1)cdf(1) = hist(1);
else cdf(i) = cdf(i-1) + hist(i);
end
mincdf = min(mincdf,cdf(i));
end
cdf_sc = zeros(1,256);
for i = 1:256
cdf_sc(i) = round(((cdf(i) - mincdf)*(255))/(262144 - mincdf));
end
for i = 1:512
for j = 1:512
a(i,j) = cdf_sc(a(i,j) + 1);
end
end

histogram = zeros(1,256);
for i = 1:512
for j = 1:512
val = a(i,j) + 1;
histogram(val) = histogram(val) + 1;
end
end
x = 0:255;
imshow(a);
plot(x,histogram);

end

Published with MATLAB 7.14

You might also like