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


clc; 
fid=fopen('d:/img/fing_128.img','r'); 
f=fread(fid,[128,128],'uchar'); 
subplot(2,2,1); 
imshow(f,[0,255]); 
for x=1:128 
    for y=1:128 
        if x==y 
            f(x,y)=255; 
        elseif x+y==100 
            f(x,y)=0; 
        end 
    end 
end 
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]);