DSP

【DSP C++】2D_FFT

2019-07-13 15:03发布

#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;//init_nLen,init_mLen:原始图像的大小、N,M:dft变换应该是2的几次方、nLen,mLen:dft的点数 FILE *dataFile; typedef struct{ float real; float image; }complex; complex *A,*A_In,*W;//A_In:dft的原矩阵,不够的补0 complex Add(complex, complex); complex Sub(complex, complex); complex Mul(complex, complex); int calculate_M(int);//计算dft的点数应为2的N次方、 void reverse(int,int); void readData(); //读入原矩阵数据,并补零转化为可以计算dft的矩阵、 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