最近写了一个计算图像二维傅里叶变换的程序, c++, 采用索引表的方法计算。
程序如下
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
#include <stdlib.h>
#include <stdio.h>
#define PI 3.14159265359
float *trigalesin;
float *trigalecos;
void calculate(int col, int row)
{
trigalesin = new float[col*row];
trigalecos = new float[col*row];
for (int y = 0; y< row; y++)
{
for(int x = 0; x< col; x++)
{
float tmp = -2*PI*(1.0*x/col+1.0*y/row);
trigalesin[y*col+x] = sin(tmp);
trigalecos[y*col+x] = cos(tmp);
}
}
}
void getDFT(int *a, int arows, int acols, float **b, float **c)
{
*b = new float [arows*acols];
*c = new float [arows*acols];
for (int v = 0; v< arows; v++)
{
if (v*100%arows == 0)
{