如何执行FFT2D(快速傅里叶变换2D)R,G,B颜色分量

时间:2011-11-21 08:17:15

标签: c++ visual-c++ fft kissfft ifft

我是快速傅里叶变换(FFT)的新手,并没有太多的想法,如何用C ++等编程语言进行计算。这是FFT2D的方法

void FFT2D(Complex<double> *f, Complex<double> *F, int width, int height);
It takes an input image f of size width * height and output the transformed 
coefficients into F.

提示:图像像素存储为三个单独的图像颜色(R,G,B)平面,每个平面由一维复数数组表示。假设图像的大小宽度为W且高度为H,则图像位置(m,n)处的像素的颜色分量值(R,G和B)可以为R [m + n * W],G( m + n * W)和B [m + n * W],其中R,G,B是三个复数数组。 变换系数的1D数组也以相同的方式表示。

我只需要实现一个颜色组件的处理,编程模板将根据实现的功能分别处理R,G,B。模板还将使用零填充图像,以便每个输入图像的大小为2m * 2n。

If I called from another class, I have to pass R, G, B separately
Suppose: 
Complex<double> *R = new Complex<double>[width * height];
Let, width = 4096 and height 4096
FFT2D(R, output F, width, height) for compute “R” color component;
FFT2D(G, output F, width, height) for compute “G” color component;
FFT2D(B, output F, width, height) for compute “B” color component;

We have template of calculated FFT1D function:
void FFT1D(Complex<double> *fx, Complex<double> *Fu, int twoK, int stride)
Hint: it outputs the frequency coefficients in the array Fu.

FFT1D从FFT2D函数内部调用 。我在C,C ++和Java以及FFT #D的C#中找到了几种不同类型的代码。他们中的大多数已经使用2D阵列结构实现;它们在行和列的循环中将实部和虚部分配给2D数组结构。但是,在我的情况下是颜色分量的一维数组结构。

让我们做一些代码,这是在FFT2D函数中:

Complex<double> *outPutMap = new Complex<double>[width * height];
 for (int i = 0; i < height; i++){
 #  for(int j = 0; j < width; j++){
 #     outPutMap[i + j * width] = f[i + j * width];
 #      I don’t understand how to implement in here for color component and how 
 #      it assign a value for real and imaginary part
 #   }
  }

在调用FFTID之前,它还需要计算一个值为2K,如书中所示,M = 2K

如果您有任何想法或任何参考,请告诉我。

谢谢

此致 一郎

1 个答案:

答案 0 :(得分:-2)

我建议你掌握一本像[数字食谱] [1]这样的书。

http://www.amazon.com/Numerical-Recipes-Art-Scientific-Computing/dp/0521750334

FFT,Simpsons Rule,Fouriers算法都应该存在。我从一位名叫Rajaram的作者那里读到了......那是在C。