close all
clear all
A=imread('4.bmp');
[m,n]=size(A);
h=zeros(256);
p=zeros(256);
s=zeros(256);
B=uint8(zeros(m,n));
for i=1:m
for j=1:n
h(A(i,j)+1)=h(A(i,j)+1)+1;
end
end
for x=1:256
p(x)=h(x)/(m*n);
end
plot(p);
figure;
imhist(A);
for x = 1:256
p0=0;
for y = 1:x
p0= p0+p(y);
end
p0=p0*256;
s(x)=p0;
end
figure;
plot(s);
for i=1:m
for j=1:n
B(i,j)=s(A(i,j));
end
end
figure;
imshow(uint8(A));
figure;
imshow(uint8(B));
No comments:
Post a Comment