PROJECT 04-03

PROJECT 04-03

Lowpass Filtering

(a) Implement the Gaussian lowpass filter in Eq. (4.3-7).  You must be able to specify the size, Mx N,of the resulting 2D function.  Inaddition, you must be able to specify the location of the center of theGaussian function.

(b) Download Fig. 4.11(a) [this image is the same as Fig. 4.18(a)] fromthe book web site and lowpass filter it to duplicate the results in Fig.4.18(c).

实验代码:

f=imread('Fig4.11(a).jpg');
f=mat2gray(f);
figure;imshow(f);title('原图像')
[M,N]=size(f);
P=2*M;Q=2*N;
%生成实的对称的滤波函数,中心在(P/2,Q/2)
 alf=100;
 for i=1:P
 for j=1:Q
H(i,j) =exp(-((i-P/2)^2+(j-Q/2)^2)/(2*alf^2));
 end
 end
%H=im2double(H);
figure;imshow(H);title('滤波函数')
 
[M,N]=size(f);
P=2*M;Q=2*N;
%图像填充
fp=zeros(P,Q);
fp(1:M,1:N)=f(1:M,1:N);
%用(-1)^(x+y)乘以输入图像,来实现中心化变换
[Y,X]=meshgrid(1:Q,1:P);
ones=(-1).^(X+Y);
 
f=ones.*fp;
F=fft2(f);
 
%(-1)^(x+y)*f(x,y)的傅里叶变换等于fftshift(fft2(f,P,Q));
%以上可用F=fftshift(fft2(f,P,Q));  
G=H.*F;%频率域相乘
g=real(ifft2(G));%反变换并取结果的实部
g=ones.*g;
g=g(1:M,1:N);%在g(x,y)左上象限提取M*N
figure;imshow(g);title('高斯低通滤波后的图像')


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值