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('高斯低通滤波后的图像')
本文介绍了一种基于MATLAB实现的高斯低通滤波器,并使用该滤波器对特定图像进行处理,以减少高频噪声,同时保持图像的基本特征不变。
1492

被折叠的 条评论
为什么被折叠?



