www.pudn.com > digitalimageprocessprograms.rar > pinhua.m


clc; 
fid=fopen('d:/img/fing_128.img','r'); 
fg=fread(fid,[128,128],'uchar'); 
subplot(2,2,1); 
imshow(fg,[0,255]); 
a=randn(128,128); 
f=a.*20+fg; 
subplot(2,2,2); 
imshow(f,[0,255]); 
 
 
f0=f; 
for x=2:127 
    for y=2:127 
        f0(x,y)=(f((x-1),y)+f((x+1),y)+f(x,(y-1))+f(x,(y+1)))./4; 
    end 
end 
subplot(2,2,3); 
imshow(f0,[0,255]); 
 
t=fft2(f); 
T=t(1,1)/128; 
f1=f; 
for x=2:127 
    for y=2:127 
        h=(f((x-1),y)+f((x+1),y)+f(x,(y-1))+f(x,(y+1)))./4; 
        if abs(f(x,y)-h)>T 
            f1(x,y)=h; 
        else 
            f1(x,y)=f(x,y); 
        end 
    end 
end 
subplot(2,2,4); 
imshow(f1,[0,255]);