0% found this document useful (0 votes)
31 views

Image 1 Histogram of The Original Image: 'Sat - 512 - 512.jpg'

The document discusses histogram equalization techniques applied to images. It contains code to calculate histograms and equalize histograms of images, as well as apply local histogram equalization using a 3x3 mask.

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)
31 views

Image 1 Histogram of The Original Image: 'Sat - 512 - 512.jpg'

The document discusses histogram equalization techniques applied to images. It contains code to calculate histograms and equalize histograms of images, as well as apply local histogram equalization using a 3x3 mask.

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/ 18

Table of Contents

Image 1 ............................................................................................................................
Histogram of the original image ............................................................................................
Histogram of modified image ...............................................................................................
Previous v/s new image .......................................................................................................
Old image .........................................................................................................................
New Image ........................................................................................................................
Image 2 ............................................................................................................................
Histogram of the original image ............................................................................................
Histogram of modified image ...............................................................................................
Previous v/s new image .......................................................................................................
Old image .........................................................................................................................
New Image ........................................................................................................................

Image 1
name = 'Sat_512_512.jpg';

Histogram of the original image


histo(name);

1
1
2
2
2
3
4
4
5
6
6
7

Histogram of modified image


new = hist_equal(name);

Previous v/s new image


old = imread(name);

Old image
imshow(old);

New Image
imshow(new);

Image 2
name = 'Sat2_512_512.jpg';

Histogram of the original image


histo(name);

Histogram of modified image


new = hist_equal(name);

Previous v/s new image


old = imread(name);

Old image
imshow(old);

New Image
imshow(new);

Published with MATLAB 7.14

Function to calculate histogram of the image


function [hist] = histo( name )
%plots histogram of an image
a = imread(name);
hist = zeros(1,256);
for i = 1:512
for j = 1:512
val = a(i,j) + 1;
hist(val) = hist(val) + 1;
end
end
x = 0:255;
plot(x,hist);
end
Published with MATLAB 7.14

Function for calculating histogram equalization


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

Histogram Maching
Table of Contents
First Image ........................................................................................................................
Histogram of matched image ................................................................................................
Matched image ..................................................................................................................
Second Image ....................................................................................................................
Histogram of matched image ................................................................................................
Matched image ..................................................................................................................

First Image
a = imread('Sat_512_512.jpg');
hist_a = histo(a);
cdf_sc = hist_equal(a,hist_a);
for i = 1:512
for j = 1:512
a(i,j) = (norminv((cdf_sc(a(i,j)+1)/255),122,30));
end
end

Histogram of matched image


hi = histo(a);
x = 0:255;
plot(x,hi);

1
1
2
3
3
4

Histogram Maching

Matched image
imshow(a);

Histogram Maching

Second Image
a = imread('Sat2_512_512.jpg');
hist_a = histo(a);
cdf_sc = hist_equal(a,hist_a);
for i = 1:512
for j = 1:512
a(i,j) = (norminv((cdf_sc(a(i,j)+1)/255),122,30));
end
end

Histogram of matched image


hi = histo(a);
x = 0:255;
plot(x,hi);

Histogram Maching

Matched image
imshow(a);

Histogram Maching

Published with MATLAB 7.14

Performing local histogram equalization with a 3 x 3 mask

name = 'Sat2_512_512.jpg';
img = imread(name);
oimg = img;
for i = 1:510
for j = 1:510
a = zeros(3,3);
for m = 1:3
for n = 1:3
a(m,n) = img(m + i - 1,n + j -1);
end
end
%a
hist = histo(a);
out = hist_equal(a, hist);
%out
for m = 1:3
for n = 1:3
oimg(m + i - 1,n + j -1) = out(m,n);
end
end
end
end
imshow(oimg);
Published with MATLAB 7.14

You might also like