1

我想编写一个简短的 MATLAB 程序,使我能够从图像表示中指定并仅保留最大数量级的傅里叶变换的一部分。

到目前为止,这是我的代码,其中“image123”是 256x256 uint8:

I= image123;
F = fft2(I); 
F = fftshift(F); 
F = abs(F); % Get the magnitude
F = log(F + 1); 
F = mat2gray(F); 
figure, imshow(F,[]) 

如果我在“F = log(F + 1)”中增加我的值 1,这会增加傅里叶变换的幅度吗?

4

1 回答 1

3

您需要使用二进制掩码将低于给定阈值的所有值设置为零,然后使用ifft2此修改后的傅立叶数据创建图像

% Load in some sample data
tmp = load('mri');
I = tmp.D(:,:,12);

% Take the 2D Fourier Transform
F = fft2(I);

% Set this to whatever you want
threshold = 2000;

% Force all values less than this cutoff to be zero
F(abs(F) < threshold) = 0;

% Take the inverse Fourier transform to get your image back
I2 = ifft2(F);

% Plot them
figure;
subplot(1,2,1);    
imshow(I, []);
title('Original')

subplot(1,2,2);
imshow(I2, []);
title('Filtered')

在此处输入图像描述

于 2017-03-29T14:25:08.460 回答