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

…衆ロ難τιáo~ 提交于 2019-12-06 04:23:37

问题


I am new in fast fourier transform (FFT) and does not have much idea, how it calculate in programming language such as C++. Here is method of 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. 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. 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. The template will also pad the image with zeros so that each input image is of size 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. I found several different type of code in C, C++, and Java and C #of FFT2D. Most of them have implemented using 2D array structure; they assign real and imaginary part to 2D array structure in loop of rows and columns. However, in my case is 1D array structure of color component.

Let's, do some code and this is inside FFT2D function:

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

If you have any idea or any reference please let me know.

Thank you

Regards Ichiro


回答1:


I would suggest you get hold of a book such as [Numerical Recipes][1] .

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

FFT, Simpsons Rule, Fouriers Algorith should all be there. I had read from an author named Rajaram .. it was in C.



来源:https://stackoverflow.com/questions/8208974/how-to-perform-fft2d-fast-fourier-transform-2d-r-g-b-color-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!