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 a0 Hz
frequency? - Can I bin the values somehow so that my frequency spectrum is orientation agnostic?
freq
has a few very large values, and lots of small values. You can see that by plotting(See below.) So, when you use
Matplotlib uses
freq.min()
as the lowest value in the color range (which is by default colored blue), andfreq.max()
as the highest value in the color range (which is by default colored red). Since almost all the values infreq
are near the blue end, the plot as a whole looks blue.You can get a more informative plot by rescaling the values in
freq
so that the low values are more widely distributed on the color range.For example, you can get a better distribution of values by taking the
log
offreq
. (You probably don't want to throw away the highest values, since they correspond to frequencies with the highest power.)From the docs:
Thus,
freq[0,0]
is the "zero frequency" term. In other words, it is the constant term in the discrete Fourier Transform.