原文: http://blog.163.com/ld081055@126/blog/static/11818691520105144852433/
还有这个文章也实现了:http://blog.csdn.net/lxdfigo/article/details/8279919
几个开源项目:
https://github.com/urgv/pthreads-fft2d
https://github.com/BenedictHiddleston/fft2d
https://github.com/ecordon/FFT2
这个缺少函数:trace
前面编过2D-FFT的程序,现在把2D-IFFT的程序整合到一起,便于后面做图像变换反变换使用。
FFT与IFFT有如下关系:
相应的2D-FFT与2D-IFFT的关系如下:
所以可以利用一个FFT核心函数实现2D-FFT与2D-IFFT。代码如下:
#include
#include
#include
#define intsize sizeof(int)
#define complexsize sizeof(complex)
#define PI 3.1415926
int *a,*b;
int nLen,init_nLen,mLen,init_mLen,N,M;
FILE *dataFile;
typedef struct{
float real;
float image;
}complex;
complex *A,*A_In,*W;
complex Add(complex, complex);
complex Sub(complex, complex);
complex Mul(complex, complex);
int calculate_M(int);
void reverse(int,int);
void readData();
void fft(int,int);
void Ifft();
void printResult_fft();
void printResult_Ifft();
int main()
{
int i,j;
readData();
A = (complex *)malloc(complexsize*nLen);
reverse(nLen,N);
for(i=0; i
{
for(j=0; j
{
A[j].real = A_In[i*nLen+b[j]].real;
A[j].image = A_In[i*nLen+b[j]].image;
}
fft(nLen,N);
for(j=0; j
{
A_In[i*nLen+j].real = A[j].real;
A_In[i*nLen+j].image = A[j].image;
}
}
free(a);
free(b);
free(A);
A = (complex *)malloc(complexsi