Experiment # 6: Objective: Resource Required
Experiment # 6: Objective: Resource Required
Objective:
in MATLAB.
Resource Required:
Exercise:
%EXPERIMENT 6
%histogram equalization
function [count] =myhist(b)
b=imread('image.jpg');
x=rgb2gray(b);
xmin=(min(min(x)));
xmax=max(max(x));
count=(zeros(1,256));
for i= xmin:xmax
count(i+1)=sum(sum(x==i));
end
figure(1);
subplot(1,2,1);
bar(0:255,count)
title('histogram by function')
subplot(1,2,2);
imhist(x)
title('histogram by command')
OUTPUT:
%histogram equalization
[count]=myhist(x)
[row col] = size(x);
N=length(x(:));
xmin=min(min(x));
xmax=max(max(x));
%cdf
c=cumsum(count);
M=min(c);
%equalization
y=zeros(size(x));
for j=1:256
%find(x1==j)
for i=1:row
for m= 1:col
if x(i,m)==j
y(i,m)=ceil(((c(j)-M)/(N-M))*255);
end
end
end
end
figure(1);
subplot(1,2,1);
imshow(uint8(y))
title ('equalized image');
subplot(1,2,2);
imshow(x)
title('original image');
figure (2);
subplot(1,2,1);
imhist(uint8(y));
title('equalized histogram');
subplot(1,2,2);
imhist(x)
title('original histogram');
OUTPUT:
Learning Outcome: