1
votes

How can I plot phase and magnitude of Fourier transform of a 2D image in MATLAB? I am using angle and abs and then use imshow, but I get a black image.
what is the use of fftshift in this plotting?

2
try imagesc(abs(fftshift(fft2(I))));lennon310
I tried this but it only display a black image with a white point in the center.amanda

2 Answers

1
votes
F = fft2(I); where I is the input
F = fftshift(F); % Center FFT

F = abs(F); % Get the magnitude
F = log(F+1); % Use log, for perceptual scaling, and +1 since log(0) is undefined
F = mat2gray(F); % Use mat2gray to scale the image between 0 and 1

imshow(F,[]); % Display the result

Try this. Code taken from:How to plot a 2D FFT in Matlab?

1
votes

From your comment, you need to remove the DC offset. Something like:

imagesc(abs(fftshift(fft2(I - mean(I(:))))));