clc;
close all;
clear all;
%读取图像
I = imread(‘Fig0206(a)(rose-original).tif’);
figure(1);
imshow(I);
title(‘原图’);
% 显示图像
F1 = fft2(double(I));%离散傅里叶变换
F2 = fftshift(F1); %将直流分量移到频谱中心
figure(2);
imshow(log(abs(F2)+1),[]);
title(‘d = 100中心化频谱’);
[row,col]=size(F2);
a0 = round(row/2);
b0 = round(col/2);
d = 100;
%理想低通滤波器
ILP = ones(row,col);
for i=1:row
for j=1:col
distance = sqrt((i-a0)2+(j-b0)2);
if distance<=d
h=1;
else
h=0;
end
ILP(i,j) = h;
end
end
%理想低通
s1=F2.ILP;
s1=uint8(real(ifft2(ifftshift(s1))));
%理想高通
n1=F2.(1-ILP);
n1=uint8(real(ifft2(ifftshift(n1))));
figure(3);
subplot(1,2,1), imshow(s1), title(‘d = 100理想低通滤波所得图像’);
subplot(1