c语言数字图像处理(六):二维离散傅里叶变换

 

基础知识

复数表示

C = R + jI

极坐标:C = |C|(cosθ + jsinθ)

欧拉公式:C = |C|e

有关更多的时域与复频域的知识可以学习复变函数与积分变换,本篇文章只给出DFT公式,性质,以及实现方法

二维离散傅里叶变换(DFT)

其中f(x,y)为原图像,F(u,v)为傅里叶变换以后的结果,根据欧拉公式可得,每个F(u,v)值都为复数,由实部和虚部组成

代码示例

 

复制代码
 1 void dft(short** in_array, double** re_array, double** im_array, long height, long width)  2 {  3     double re, im, temp;  4  5     for (int i = 0; i < height; i++){  6         for (int j = 0; j < width; j++){  7             re = 0;  8             im = 0;  9 10             for (int x = 0; x < height; x++){ 11                 for (int y = 0; y < width; y++){ 12                     temp = (double)i * x / (double)height + 13                            (double)j * y / (double)width; 14                     re += in_array[x][y] * cos(-2 * pi * temp); 15                     im += in_array[x][y] * sin(-2 * pi * temp); 16                 } 17             } 18             19             re_array[i][j] = re; 20             im_array[i][j] = im; 21         } 22     } 23     printf("dft done\n"); 24 }
复制代码

 

关键字:

50000+
5万行代码练就真实本领
17年
创办于2008年老牌培训机构
1000+
合作企业
98%
就业率

联系我们

电话咨询

0532-85025005

扫码添加微信