# MATLAB图像处理学习笔记（一）：频域滤波

### MATLAB图像处理学习笔记（一）：频域滤波

img = imread('1.jpg');

figure;
imshow(img);
title('原图');

f=rgb2gray(img);
F=fft2(f);          	%傅里叶变换
F1=log(abs(F)+1);
Fs=fftshift(F);      	%将频谱图中零频率移动到图像中心
S=log(abs(Fs)+1);

figure;
imshow(S,[]);title('频谱');


S=log(abs(Fs)+1);

filter_low = zeros(400, 600);
r = 50;
for i=(400/2-r+1):(400/2+r)
for j=(600/2-r+1):(600/2+r)
filter_low(i,j)=1;
end
end
figure;
imshow(filter_low,[]);
title('低通滤波窗口');


dst = filter_low.* Fs;

figure;
S2=log(abs(dst)+1);    %取模并进行缩放
imshow(S2,[]);
title('经过滤波后的频谱图');


fr=real(ifft2(ifftshift(dst)));  %频率域反变换到空间域，并取实部
ret=im2uint8(mat2gray(fr));    %更改图像类型

figure;
imshow(ret);
title('低通滤波结果');


img = imread('1.jpg');

figure;
imshow(img);
title('原图');

f=img;
F=fft2(f);
F1=log(abs(F)+1);
%subplot(2,2,2);imshow(F1,[]);title('傅里叶变换频谱图');
Fs=fftshift(F);
S=log(abs(Fs)+1);

figure;
imshow(S,[]);
title('频谱');

filter_low = zeros(400, 600);
r = 50;
for i=(400/2-r+1):(400/2+r)
for j=(600/2-r+1):(600/2+r)
filter_low(i,j)=1;
end
end
figure;
imshow(filter_low,[]);
title('低通滤波窗口');

dst = filter_low.* Fs;

figure;
S2=log(abs(dst)+1);
imshow(S2,[]);
title('经过滤波后的频谱图');

fr=real(ifft2(ifftshift(dst)));
ret=im2uint8(mat2gray(fr));

figure;
imshow(ret);
title('低通滤波结果');


©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客