function smoothing
A=imread('cameraman.tif');
%m=[0 -1 0;-1 4 -1;0 -1 0];
%m=[1/16 1/8 1/16;1/8 1/4 1/16 ;1/16 1/8 1/16]
m=[1/10 1/10 1/10;1/10 1/5 1/10;1/10 1/10 1/10];
%m=[-1 -1 -1;-1 9 -1;-1 -1 -1];
A=double(A);
d=A;
[baris kolom]=size(A);
for i=2:baris-1;
for j=2:kolom-1;
d(i,j)=A(i-1,j-1)*m(1,1)+A(i-1,j)*m(1,2)+A(i-1,j+1)*m(1,3)+A(i,j-1)*m(2,1)+A(i,j)*m(2,2)+A(i,j+1)*m(2,3)+A(i+1,j-1)*m(3,1)+A(i+1,j)*m(3,2)+A(i+1,j+1)*m(3,3);
if d(i,j)>255
d(i,j)=255;
else if d(i,j)
d(i,j)=0;
end
end
end
end
C=uint8(A);
subplot (2,2,1), imshow(C);
subplot (2,2,2), imhist(C);
D=uint8(d)
subplot (2,2,3), imshow(D);
subplot (2,2,4), imhist(D);
1 comments:
Click here for commentsNo more live link in this comments field
ConversionConversion EmoticonEmoticon