二维fft c语言,c语言 2D-FFT(fft2)及IFFT

本文介绍了一个C语言实现2D快速傅里叶变换(FFT)和逆FFT(IFFT)的程序,包括读取数据、计算、打印结果等步骤。程序涉及复数运算和位反转,适用于图像处理等领域。
摘要由CSDN通过智能技术生成

原文: 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有如下关系:

0818b9ca8b590ca3270a3433284dd417.png

相应的2D-FFT与2D-IFFT的关系如下:

0818b9ca8b590ca3270a3433284dd417.png

所以可以利用一个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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值