Reputation: 17944
I'm trying to get a sense of the spatial frequencies present in a series of images I want to analyze. I decided to do this with the numpy.fft.fft2
function, but apparetly the output can't be plotted - can you help me figure out what's wrong?
Apparently this is happening because the output contains values like 0.+0.j
which` matplotlib can't deal with. But I don't know how to change them to something it can deal with either.
Here's a minimal example with my issue.
Upvotes: 0
Views: 1260
Reputation: 20226
Matplotlib can only handle real values. Your options are to take the real or imaginary parts of the results, or magnitude and maybe even phase. These can be done with numpy.real
or numpy.imag
, or numpy.abs
and numpy.angle
.
Ultimately, I guess it just depends on what you want to know about your FFT. People are usually most interested in the magnitude of FFT data, which suggests abs
. This gives you an idea of the "power" in the various frequencies.
Upvotes: 5