# Understanding FFT of an Image

I am having trouble identifying the frequency components of an image,

Here i simply generated, 256x256 binary-image.

a = [zeros(256,128) ones(256,128)];
imshow(a);


Taking the image FFT and shifting the Zero-frequency to the center,

f = fft2(a)
shft = fftshift(f);
imshow(log(shft)) %stretching


will result,

How do identify how many frequency components are there and what are those frequencies ?

Also if i calculate FFT of any 1-D sequence and plot that sequence there are certain values on negative , what does that mean ? how there could be negative frequencies ?

• Related (possible duplicate): dsp.stackexchange.com/q/1637/77 – Lorem Ipsum Sep 25 '12 at 17:23
• One of the best ways to understand what a transform does is to experiment with the inverse transform. Draw a dot and then inverse transform it to see the waves that it produces. Then try a dot in a different place, then a line, etc. As for negative frequencies, see dsp.stackexchange.com/q/431/29 – endolith Sep 25 '12 at 21:46

how there could be negative frequencies ?

The FFT coefficients are not frequencies, but complex amplitudes. The modulus of the coefficient indicates the amplitude, the argument of the coefficient indicates the phase.

Note that you should be getting a warning or error message from Matlab for computing log(shft), since shft is a complex matrix, the result is not a real and cannot be plotted as an image.

• Everything you say is true, but it is also side-stepping the question. Half of the coefficients can be interpreted to correspond to negative frequencies. – Jim Clay Sep 25 '12 at 19:33

My first suggestion is that you understand FFT in 1 dimension before trying to interpret results in 2D.

The Discrete Fourier Transform (FFT is an implementation of DFT) is a complex transform: it transforms between 2 vectors complex vectors of size N.

So in the 1D case, you will get not only negative values, but complex values in general.

The same applies in 2D. The imshow function is probably taking the real part of the complex matrix (it is not clear in the imshow documentation).

You are missing the abs command.

Try the following:

f = fft2(a)
shft = fftshift(abs(f));
imshow(log(shft)) %stretching