简体   繁体   中英

How to specify and keep only a proportion of the Fourier Transforms of largest magnitude from an image

I want to write a short MATLAB program that enables me to specify and keep only a proportion of the Fourier Transforms of largest magnitude from an image representation.

Here is my code so far, where 'image123' is a 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,[]) 

If I increase my value of 1 in 'F = log(F + 1)' will this increase the magnitude of the Fourier transform?

You'll want to use a binary mask to set all values below a given threshold to zero and then use ifft2 to create an image from this modified Fourier data

% 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')

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM