Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot a 2D FFT in Matlab?

I am using fft2 to compute the Fourier Transform of a grayscale image in MATLAB.

What is the common way to plot the magnitude of the result?

like image 503
Yoav Avatar asked Nov 25 '12 07:11

Yoav


1 Answers

Assuming that I is your input image and F is its Fourier Transform (i.e. F = fft2(I))

You can use this code:

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 
like image 87
Yoav Avatar answered Sep 21 '22 04:09

Yoav