简体   繁体   English

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

[英]How to perform FFT2D (Fast Fourier Transform 2D) R, G, B color component

I am new in fast fourier transform (FFT) and does not have much idea, how it calculate in programming language such as C++. 我是快速傅立叶变换(FFT)的新手,对如何使用C ++等编程语言进行计算并没有太多的想法。 Here is method of FFT2D 这是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.

Hints: Image pixels are stored as three separate image color (R, G, B) planes, with each of them being represented by a 1D array of complex numbers. 提示:图像像素存储为三个单独的图像颜色(R,G,B)平面,每个平面由一维复数数组表示。 Suppose an image is of size width W and height H, then the color component values (R, G and B) of the pixels at image location (m, n) can be found as R[m + n * W], G(m + n * W) and B[m + n * W], where R, G, B are the three arrays of complex numbers. 假设图像的大小为宽度W和高度H,则可以找到图像位置(m,n)上像素的颜色分量值(R,G和B)为R [m + n * W],G( m + n * W)和B [m + n * W],其中R,G,B是复数的三个数组。 The 1D array for the transformed coefficients is also represents in the same manner. 变换后的系数的一维数组也以相同的方式表示。

What I need to implement the processing for one color component only and the programming template will process the R, G, B separately based on implemented functions. 我只需要为一个颜色分量实现处理,编程模板将根据实现的功能分别处理R,G,B。 The template will also pad the image with zeros so that each input image is of size 2m * 2n. 该模板还将用零填充图像,以便每个输入图像的大小为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 is calling from inside a function of FFT2D . FFT1D从FFT2D函数内部调用 I found several different type of code in C, C++, and Java and C #of FFT2D. 我在C,C ++,Java和FFT2D的C#中发现了几种不同类型的代码。 Most of them have implemented using 2D array structure; 他们中的大多数已经使用2D阵列结构实现了。 they assign real and imaginary part to 2D array structure in loop of rows and columns. 他们在行和列的循环中为2D数组结构分配实部和虚部。 However, in my case is 1D array structure of color component. 但是,在我的情况下是颜色分量的一维阵列结构。

Let's, do some code and this is inside FFT2D function: 让我们做一些代码,这是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
 #   }
  }

Before, calling a FFTID, it also required calculate a value of twoK as in book, M = 2K 在调用FFTID之前,还需要像书中那样计算2K的值,M = 2K

If you have any idea or any reference please let me know. 如果您有任何想法或参考,请告诉我。

Thank you 谢谢

Regards Ichiro 问候一郎

I would suggest you get hold of a book such as [Numerical Recipes][1] . 我建议您拿一本书,例如[数字食谱] [1]。

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

FFT, Simpsons Rule, Fouriers Algorith should all be there. FFT,Simpsons规则,Fouriers Algorith应该都在那里。 I had read from an author named Rajaram .. it was in C. 我读过一位名叫拉贾兰(Rajaram)的作家的文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM