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?
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?
From your comment, you need to remove the DC offset. Something like:
imagesc(abs(fftshift(fft2(I - mean(I(:))))));
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.