Be Sociable, Share!

Tutorial 1:

Write a matlab code that inptuts a grayscale image and then create its Histogram.

 

Code:

a=imread(‘cameraman.tif’);
[r c]=size(a);
prob=zeros(1,255)
for h=1:1:255
for i=1:1:r
for j=1:1:c
if(a(i,j)==h)
prob(h)=prob(h)+1;
end
end
end
end
subplot(1,2,1)
imshow(a);
title(‘Orignal Image’);
subplot(1,2,2)
stem(prob);
title(‘Histogram’);

 

Program Output :

histogram

Tutorial # 2:

Matlab code that inputs a gray scale image and then equalizes its Histogram and also  its Histogram after histogram equalization and then compare your result.

Code:

a=imread(‘cameraman.tif’);

subplot(2,2,1)

imshow(a);

title(‘Orignal Image’);

c=histeq(a);

subplot(2,2,2)

imshow(c);

title(‘Equalized Image’);

b=imhist(a);

subplot(2,2,3)

stem(b);

title(‘Orignal Histogram’);

d=imhist(c);

subplot(2,2,4)

stem(d);

title(‘Equalized Histogram’);

 

Output :

Histogram tutorial

For More Matlab Tutorials Visit Algorithm for implementing High Pass

Be Sociable, Share!