Question

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?

Was it helpful?

Solution

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?

OTHER TIPS

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

imagesc(abs(fftshift(fft2(I - mean(I(:))))));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top