Generating a spectrogram for a sequence of 2D movie frames Generating a spectrogram for a sequence of 2D movie frames numpy numpy

Generating a spectrogram for a sequence of 2D movie frames


I believe that the approach you describe is in general the best way to do this analysis.

However, i did spot an error in your code. as:

np.abs(f2*f2)

is not the PSD of complex array f2, you need to multiply f2 by it's complex conjugate instead of itself (|f2^2| is not the same as |f2|^2).

Instead you should do something like

(f2*np.conjugate(f2)).astype(float)

Or, more cleanly:

np.abs(f2)**2.

The oscillations in the 2D power-spectrum are a tell-tale sign of this kind of error (I've done this before myself!)