【问题标题】:How to find Fourier transform magnitude of a function in python?如何在python中找到函数的傅里叶变换幅度?
【发布时间】:2021-08-07 08:00:21
【问题描述】:

我正在计算视频中所有帧的能量(像素值)。

cap= cv2.VideoCapture('video.mp4')
x = []
y = []
def imageEnergy(img):
 img = img / 255  
 return np.sum(np.square(img))
success, image = cap.read()
count = 0
while success: 
 En = imageEnergy(image)
 EnP = En / np.prod(image.shape) 
 print(f"Count: {count} Energy: {EnP}")
 success, image = cap.read()
 x.append(count)
 y.append(EnP)
 count += 1

我想找到我的能量函数的傅立叶变换幅度,即 Enp。我试过在 y 上使用 fft 但它不起作用。

transform = fft(y)
print (transform)

有人可以指导我吗?

【问题讨论】:

    标签: python signal-processing


    【解决方案1】:

    Pythonn 没有内置的 fft。有多个库提供 FFT 实现,我认为使用最广泛的是 numpy。

    import numpy as np;
    transform = abs(np.fft.fft(y))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多