My goal is to obtain a plot with the spatial frequencies of an image - kind of like doing a fourier transformation on it. I don't care about the position on the image of features with the frequency f (for instance); I'd just like to have a graphic which tells me how much of every frequency I have (the amplitude for a frequency band could be represented by the sum of contrasts with that frequency).

I am trying to do this via the numpy.fft.fft2 function.

Here is a link to a minimal example portraying my use case.

As it turns out I only get distinctly larger values for frequencies[:30,:30], and of these the absolute highest value is frequencies[0,0]. How can I interpret this?

  • What exactly does the amplitude of each value stand for?
  • What does it mean that my highest value is in frequency[0,0] What is a 0 Hz frequency?
  • Can I bin the values somehow so that my frequency spectrum is orientation agnostic?

1 Answer 1


You actually did a two dimensional Fourier transform there. The 0 Hz frequency is the ,,DC offset'' of your signal, that is, its average value. In computers, it's no wonder that there's a high average value, because signals are often defined using positive numbers.

In a 2D Fourier transform, the coefficients of the transformed correspond to products of 1D Fourier basis elements, that is, signals with a period equal to the length of the signal. You could call these overtones.

2D Products of two such signals are not ,,orientation agnostic''. In fact, they have obvious orientation along the edges of the signal. It is not entirely clear what you are asking for here.

  • $\begingroup$ I don't care much about the orientation of the spatial frequency components, I would just like to compute how strongly each spatial frequency is represented in my image (for this I need a 1d array with frequency bands for 1/1px, 1/2px, etc.). Also, what spatial frequency does the coefficient at freq[0,1] for instance correspond to? $\endgroup$
    – TheChymera
    Jan 26, 2014 at 15:20
  • $\begingroup$ To a wave with a single wavelength, parallel to one of the edges. Just take the inverse to see it. $\endgroup$
    – user7358
    Jan 26, 2014 at 15:38
  • $\begingroup$ how do I take the inverse? and which wavelength is that "single wavelength" ? $\endgroup$
    – TheChymera
    Jan 26, 2014 at 15:43
  • $\begingroup$ I was referring to the inverse fourier transform. In numpy, it is conveniently named "ifft2" for the two-dimensional case. With "a single wavelength" I meant a wave as long as the signal, with just one period occuring inside the signal. $\endgroup$
    – user7358
    Jan 26, 2014 at 15:51
  • $\begingroup$ so practically the frequency a coefficient at freq[0,x] corresponds to is len(freq[0,:])/x and the same for y? what about coefficients outside freq[0,x] and freq[y,0]? I understand these are for "diagonal waves" - but how does np.fft.fft2 decide if a spatial wave is diagonal or if it's just a horizontal and vertical wave co-occurring? $\endgroup$
    – TheChymera
    Jan 26, 2014 at 15:56

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.