4
$\begingroup$

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);

enter image description here

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

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

will result,

enter image description here

How do I 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 could there be negative frequencies?

$\endgroup$
2
  • 2
    $\begingroup$ Related (possible duplicate): dsp.stackexchange.com/q/1637/77 $\endgroup$ Sep 25, 2012 at 17:23
  • 1
    $\begingroup$ 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 $\endgroup$
    – endolith
    Sep 25, 2012 at 21:46

3 Answers 3

1
$\begingroup$

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.

$\endgroup$
1
  • 2
    $\begingroup$ 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. $\endgroup$
    – Jim Clay
    Sep 25, 2012 at 19:33
1
$\begingroup$

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).

$\endgroup$
1
$\begingroup$

You are missing the abs command.

Try the following:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.