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

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

其中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 }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpfgzw.html