2011-11-21 40 views
3

我在快速傅立葉新變換(FFT),並沒有太多的想法,它的編程語言如C++如何計算。下面是FFT2D如何執行FFT2D(快速傅立葉變換2D)R,G,B顏色分量

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和FFT2D的C#中發現了幾種不同類型的代碼。他們中的大多數都使用二維數組結構實現;他們將實部和虛部分配給行和列循環中的二維數組結構。但是,在我的情況下是一維顏色分量的數組結構。

讓我們,做一些代碼,這是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

如果您有任何想法或任何參考請讓我知道。

謝謝

問候 一郎

+0

使用[FFTW](http://www.fftw.org)庫。 –

回答

-2

我會建議你得到一本書的保持,如[數字食譜] [1]。

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

FFT,辛普森規則,Fouriers Algorith都應該有。我讀過一位名爲Rajaram的作者..它在C中。

+1

這並沒有真正回答這個問題,並在數字食譜的FFT程序不是特別有用。 –

+0

Sujay,這不是一個答案,我在找什麼。 – user553710

+1

-1數字食譜(2007)描述了譜方法包括FFT大約1976年的事情,因爲再有很大的變化。請參閱FFTW文件瞭解更多最新信息。 –