天天看點

(六)圖像的頻域處理_低通濾波和高通濾波

一,實驗原理

設定低通濾波截止頻率為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高通濾波圖');
           
(六)圖像的頻域處理_低通濾波和高通濾波

三,實驗總結

低通濾波器由于濾掉了高頻成分,高頻成分含有大量邊緣資訊,是以造成了一定程度的圖像模糊。高通濾波器濾掉了低頻成分,保留了高頻成分,即保留了邊界資訊,是以顯示出原圖像的邊界。