asgn1_
DESCRIPTION
image processingTRANSCRIPT
1
Table of ContentsImage 1 ............................................................................................................................ 1Histogram of the original image ............................................................................................ 1Histogram of modified image ............................................................................................... 2Previous v/s new image ....................................................................................................... 2Old image ......................................................................................................................... 2New Image ........................................................................................................................ 3Image 2 ............................................................................................................................ 4Histogram of the original image ............................................................................................ 4Histogram of modified image ............................................................................................... 5Previous v/s new image ....................................................................................................... 6Old image ......................................................................................................................... 6New Image ........................................................................................................................ 7
Image 1name = 'Sat_512_512.jpg';
Histogram of the original imagehisto(name);
2
Histogram of modified imagenew = hist_equal(name);
Previous v/s new imageold = imread(name);
Old imageimshow(old);
1
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; endend
x = 0:255;plot(x,hist);
end
Published with MATLAB® 7.14
Function to calculate histogram of the image
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); endend
histogram = zeros(1,256);
for i = 1:512 for j = 1:512 val = a(i,j) + 1; histogram(val) = histogram(val) + 1; endend
x = 0:255;
imshow(a);plot(x,histogram);
end
Published with MATLAB® 7.14
Function for calculating histogram equalization
1
Histogram Maching
Table of ContentsFirst Image ........................................................................................................................ 1Histogram of matched image ................................................................................................ 1Matched image .................................................................................................................. 2Second Image .................................................................................................................... 3Histogram of matched image ................................................................................................ 3Matched image .................................................................................................................. 4
First Imagea = 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)); endend
Histogram of matched imagehi = histo(a);x = 0:255;plot(x,hi);
Histogram Maching
3
Second Imagea = 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)); endend
Histogram of matched imagehi = histo(a);x = 0:255;plot(x,hi);
1
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 endend
imshow(oimg);
Published with MATLAB® 7.14
Performing local histogram equalization with a 3 x 3 mask