clear;
S1=imread('0525a.jpg');
figure(1);
image(S1);
G=0.299*S1(:,:,1)+0.587*S1(:,:,2)+0.114*S1(:,:,3);
figure(2);
colormap(gray(256));
image(G);
for i=1:320;
for j=1:240;
if G(j,i) >=127
B(j,i)=uint8(1);
else
B(j,i)=uint8(0);
end
end
end
figure(3);
colormap(gray(2));
image(B);