我有关于用户手指的红度的数据,这是目前相当嘈杂的,所以我想通过FFT来减少噪音。这幅图像左侧的数据与我目前的数据相似。我已经熟悉了有关vDSP的苹果文档,但对于如何使用苹果的vDSP和加速框架实现快速傅里叶变换,我似乎没有明确或简明的指南。我该怎么做?
我已经提到了https://stackoverflow.com/questions/3398753/using-the-apple-fft-and-accelerate-framework,它涉及一个类似的主题,但已经明显过时了,而且不涉及vDSP。
发布于 2017-04-08 14:16:43
使用vDSP进行快速傅立叶变换计算非常容易。我假设你在输入上有实际值。唯一需要记住的是,您需要将真正的值数组转换为vDSP内部使用的打包的复杂数组。
您可以在文档中看到一个很好的概述:
Guide/UsingFourierTransforms/UsingFourierTransforms.html
下面是计算实值FFT的最小示例:
const int n = 1024;
const int log2n = 10; // 2^10 = 1024
DSPSplitComplex a;
a.realp = new float[n/2];
a.imagp = new float[n/2];
// prepare the fft algo (you want to reuse the setup across fft calculations)
FFTSetup setup = vDSP_create_fftsetup(log2n, kFFTRadix2);
// copy the input to the packed complex array that the fft algo uses
vDSP_ctoz((DSPComplex *) input, 2, &a, 1, n/2);
// calculate the fft
vDSP_fft_zrip(setup, &a, 1, log2n, FFT_FORWARD);
// do something with the complex spectrum
for (size_t i = 0; i < n/2; ++i) {
a.realp[i];
a.imagp[i];
}一个技巧是,a.realp[0]是直流偏移量,而a.imagp[0]是奈奎斯特频率上的真实值幅度。
https://stackoverflow.com/questions/43289265
复制相似问题