imagematlabplotfftphase

Plotting phase and magnitude image Fourier


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?


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?