You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

eulerian.py 597B

11 months ago
123456789101112131415161718
  1. import numpy as np
  2. import scipy.fftpack as fftpack
  3. # Temporal bandpass filter with Fast-Fourier Transform
  4. def fft_filter(video, freq_min, freq_max, fps):
  5. fft = fftpack.fft(video, axis=0)
  6. frequencies = fftpack.fftfreq(video.shape[0], d=1.0 / fps)
  7. bound_low = (np.abs(frequencies - freq_min)).argmin()
  8. bound_high = (np.abs(frequencies - freq_max)).argmin()
  9. fft[:bound_low] = 0
  10. fft[bound_high:-bound_high] = 0
  11. fft[-bound_low:] = 0
  12. iff = fftpack.ifft(fft, axis=0)
  13. result = np.abs(iff)
  14. result *= 100 # Amplification factor
  15. return result, fft, frequencies