a= imread('test.jpg');
c=rgb2gray(a);
b= size(c);
t=b(1);
s=b(2);
tem=uint8(zeros(t,s));
re=zeros(1,256);
for n=1:t
for m=1:s
re(c(n,m)+1)=re(c(n,m)+1)+1
end
end
tmp=re;
x=re/(t*s);
y=x*255;
%%%%%%%%%%%%%%%%%%%%%
cu(1)=y(1);
for s1=2:256
cu(s1)=y(s1)+cu(s1-1);
end
rou=round(cu);
%temp=[0 1 2 3 4 5 6 7;re];
%temp=[rou;re];
for o=1:t
for l=1:s
for w=1:256
if c(o,l)==w-1
tem(o,l)=rou(w);
end
end
end
end
figure;
histeq(c)
figure;
imshow(tem);
figure;
imshow(c);
c=rgb2gray(a);
b= size(c);
t=b(1);
s=b(2);
tem=uint8(zeros(t,s));
re=zeros(1,256);
for n=1:t
for m=1:s
re(c(n,m)+1)=re(c(n,m)+1)+1
end
end
tmp=re;
x=re/(t*s);
y=x*255;
%%%%%%%%%%%%%%%%%%%%%
cu(1)=y(1);
for s1=2:256
cu(s1)=y(s1)+cu(s1-1);
end
rou=round(cu);
%temp=[0 1 2 3 4 5 6 7;re];
%temp=[rou;re];
for o=1:t
for l=1:s
for w=1:256
if c(o,l)==w-1
tem(o,l)=rou(w);
end
end
end
end
figure;
histeq(c)
figure;
imshow(tem);
figure;
imshow(c);
No comments:
Post a Comment