# matlab三大低通滤波器的简单使用

F=fftshift(F);%将变换的原点移到频率矩形的中心

[M,N]=size(f);

%截至半径30理想低通滤波
h1=zeros(M,N);
for i=1:M
for j=i:N
if(sqrt(((i-M/2)^2+(j-N/2)^2))<30)
h1(i,j)=1;

end
end
end
G1=F.*h1;
G1=ifftshift(G1);
g1=real(ifft2(G1)); %截至半径90理想低通滤波
h2=zeros(M,N);
for i=1:M
for j=i:N
if(sqrt(((i-M/2)^2+(j-N/2)^2))<90)
h2(i,j)=1;

end
end
end
G2=F.*h2;
G2=ifftshift(G2);
g2=real(ifft2(G2)); %截至半径160理想低通滤波
h3=zeros(M,N);
for i=1:M
for j=i:N
if(sqrt(((i-M/2)^2+(j-N/2)^2))<160)
h3(i,j)=1;

end
end
end
G3=F.*h3;
G3=ifftshift(G3);
g3=real(ifft2(G3)); subplot(2,2,1);imshow(m);title('原图');
subplot(2,2,2);imshow(g1);title('理想低通滤波截至半径30');
subplot(2,2,3);imshow(g2);title('理想低通滤波截至半径90');

subplot(2,2,4);imshow(g3);title('理想低通滤波截至半径160');

f=double(m);
g=fft2(f);%傅里叶变换
g=fftshift(g);
[M,N]=size(g);
n1=fix(M/2);
n2= fix(N/2);
for i=1:M
for j=1:N
d=sqrt((i-n1)^2+(j-n2)^2);
h1=1/(1+(d/30)^(2*2));
h2=1/(1+(d/90)^(2*2));
h3=1/(1+(d/160)^(2*2));
result1(i,j)=h1*g(i,j);
result2(i,j)=h2*g(i,j);
result3(i,j)=h3*g(i,j);
end
end
r1=ifftshift(result1);
r2=ifftshift(result2);
r3=ifftshift(result3);
X1=ifft2(r1);
x1=uint8(real(X1));

X2=ifft2(r2);
x2=uint8(real(X2));

X3=ifft2(r3);
x3=uint8(real(X3));
subplot(2,2,1);imshow(m);title('加噪原图');
subplot(2,2,2);imshow(x1);title('Butterworth低通滤波截至半径30');
subplot(2,2,3);imshow(x2);title('Butterworth低通滤波截至半径90');
subplot(2,2,4);imshow(x3);title('Butterworth低通滤波截至半径160');

f=double(m);
f=fft2(f);
f=fftshift(f);
[m,n]=size(f);
m1=fix(m/2);
n1=fix(n/2);
for i=1:m
for j=1:n
d=sqrt((i-m1)^2+(j-n1)^2);
h1(i,j)=exp(-d^2/2/30^2);
h2(i,j)=exp(-d^2/2/90^2);
h3(i,j)=exp(-d^2/2/160^2);
end
end
g=f.*h1;
g=ifftshift(g);
g=ifft2(g);
g=mat2gray(real(g));

g2=f.*h2;
g2=ifftshift(g2);
g2=ifft2(g2);
g2=mat2gray(real(g2));

g3=f.*h3;
g3=ifftshift(g3);
g3=ifft2(g3);
g3=mat2gray(real(g3));

subplot(2,2,1);imshow(g1);title('加噪原图');
subplot(2,2,2);imshow(g);title('高斯低通滤波截至半径30');
subplot(2,2,3);imshow(g2);title('高斯低通滤波截至半径90');
subplot(2,2,4);imshow(g3);title('高斯低通滤波截至半径160');

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120