%高斯低通滤波器RGB = imread(’132。jpg'); I0 = rgb2gray(RGB); subplot(2,3,1),imshow(I0);title('原图');I1 = imnoise(I0,'gaussian’); %对原图像加噪声subplot(2,3,2),imshow(I1);title(’加入噪声后’)%将灰度图像的二维不连续 Fourier 变换的零频率成分移到频谱的中心s=fftshift(fft2(I1));subplot(2,3,3),imshow(log(1+abs(s)),[]);title(’fftshift’);[M,N]=size(s); %分别返回 s 的行数到 M 中,列数到N 中%GLPF 滤波 d0=50; %初始化 d0n1=floor(M/2); %对 M/2 进行取整n2=floor(N/2); %对 N/2 进行取整for i=1:M for j=1:N d=sqrt((i—n1)^2+(j—n2)^2); %点(i,j)到傅立叶变换中心的距离 h(i,j)=1*exp(-1/2*(d^2/d0^2)); %GLPF 滤波函数 s(i,j)=h(i,j)*s(i,j); %GLPF 滤波后的频域表示 endends=ifftshift(s); %对 s 进行反 FFT 移动%对 s 进行二维反离散的 Fourier 变换后,取复数的实部转化为无符号 8 位整数s=uint8(real(ifft2(s))); subplot(2,3,4),imshow(h);title(’传递函数’); %显示 GHPF 滤波器的传递函数subplot(2,3,5),imshow(s);title('GLPF 滤波(d0=50)’); %显示 GLPF 滤波处理后的图像