4

我是快速傅立叶变换 (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 是三个复数数组。变换系数的一维数组也以相同的方式表示。

我只需要实现一种颜色分量的处理,编程模板将根据实现的功能分别处理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 和 C#of FFT2D 中发现了几种不同类型的代码。他们中的大多数都使用二维数组结构来实现;他们将实部和虚部分配给行和列循环中的二维数组结构。但是,在我的例子中是颜色分量的一维数组结构。

让我们做一些代码,这是在 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,还需要计算一个 twoK 的值,如书中的,M = 2K

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

谢谢

问候一郎

4

1 回答 1

-2

我建议你找一本书,比如 [Numerical Recipes][1] 。

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

FFT、辛普森法则、傅里叶算法都应该在那里。我从一位名叫 Rajaram 的作者那里读过 .. 它是用 C 语言编写的。

于 2011-11-21T08:28:07.373 回答