MATLAB下实现巴特沃斯低通滤波器并对图像滤波

clear;
I1=imread('Fig3.35(a).jpg');

n4=2;w4=80;%ER阶巴特沃斯(Butterworth)低通滤波器,截止频率为80

f=im2double(I1);
g=fft2(f);%傅立叶变换
g=fftshift(g);%转换数据矩阵
[M,N]=size(g);
m=fix(M/2);
n=fix(N/2);
for i=1:M
   for j=1:N
        d=sqrt((i-m)^2+(j-n)^2);
        h1=1/(1+0.414*(d/w1)^(2*n1));%计算低通滤波器传递函数
        s1(i,j)=h1*g(i,j);
        T1(i, j) = h1;

  end
end


y1=im2uint8(real(ifft2(ifftshift(s1))));

figure,subplot(1,2,1),mesh(T3),title('滤波器透视图');
subplot(1,2,2),imshow(T3),title('滤波器示意图');

figure,subplot(3,2,1),imshow(I1),title('原图');
subplot(3,2,2),imshow(y1),title('半径为5的BLPF滤波器');

你可能感兴趣的:(MATLAB)