天天看点

(六)图像的频域处理_低通滤波和高通滤波

一,实验原理

设置低通滤波截止频率为Dl0=50,即:

(六)图像的频域处理_低通滤波和高通滤波

高通滤波器截止频率为Dh0=30,即:

(六)图像的频域处理_低通滤波和高通滤波

二,实验过程和结果

clc;
clear;
close all;

I=imread('test5.gif','gif');            %自己设置路径
subplot(2,2,1);
imshow(I);
title('test5原图');
f=double(I);     % chage into double as MATLAB doesn’t suppor calculation
  % of image in unsigned int type
  subplot(2,2,2);
  G=fft2(f);
imshow(log(abs(G)),[]);
title('test5幅度谱图');
g=fft2(f);       % fourier transform
g=fftshift(g);  % zero-frequency area centralized
[M,N]=size(g);
dl0=50;            %cutoff frequency
m=fix(M/2); n=fix(N/2);
for i=1:M
       for j=1:N
           d=sqrt((i-m)^2+(j-n)^2);
           if(d<=dl0)
           h=1;
           else h=0;
                  end
           result(i,j)=h*g(i,j);
    end
end
result=ifftshift(result);
Gl1=ifft2(result);
Gl2=uint8(real(Gl1));
subplot(2,2,3);
imshow(Gl2) ;
title('test5低通滤波图');

dh0=30;
for i=1:M
       for j=1:N
           d=sqrt((i-m)^2+(j-n)^2);
           if(d>=dh0)
           h=1;
           else h=0;
                  end
           result(i,j)=h*g(i,j);
    end
end
result=ifftshift(result);
Gh1=ifft2(result);
Gh2=uint8(real(Gh1));
subplot(2,2,4);
imshow(Gh2) ;
title('test5高通滤波图');
           
(六)图像的频域处理_低通滤波和高通滤波

三,实验总结

低通滤波器由于滤掉了高频成分,高频成分含有大量边缘信息,所以造成了一定程度的图像模糊。高通滤波器滤掉了低频成分,保留了高频成分,即保留了边界信息,所以显示出原图像的边界。