www.pudn.com > digitalimageprocessprograms.rar > ruihua.m
clc;
fid=fopen('d:/img/lena.img','r');
f=fread(fid,[256,256],'uchar');
subplot(3,1,1);
imshow(f,[0,255]);
g1=f;g2=f;
a=1;
for x=2:255
for y=2:255
g1(x,y)=f(x,y)-(f((x-1),y)+f((x+1),y)+f(x,(y-1))+f(x,(y+1))-f(x,y).*4).*a;
g2(x,y)=f(x,y).*4*a-(f((x-1),y)+f((x+1),y)+f(x,(y-1))+f(x,(y+1))).*a;
end
end
subplot(3,1,2);
imshow(g1,[0,255]);
subplot(3,1,3);
imshow(g2,[0,255]);