我正在将一个函数从 Matlab 转换为 C。我对傅里叶变换的一些行有疑问。这是代码,注释行在 Matlab 中,这就是我需要翻译的内容。
Mat logGabor(Mat imfft,int *sz2filt_r,int *sz2filt_c,double r_o, double theta_o,double sigma_theta,double **radius,double **theta,int cols,int rows,double sigma_r,int *padSize);
Mat rpad;
int k=*padSize;
int rs=*sz2filt_r;
int cs=*sz2filt_c;
double x[rs-(2*k)],y[cs-(2*k)],sintheta[rows][cols],costheta[rows][cols];
double ds[rows][cols],dc[rows][cols],divis[rows][cols],divis2[rows][cols];
double filter[rows][cols],dalpha[rows][cols],spread[rows][cols];
double div=(PI)/180.0;
for(int a=0; a<rows; a++){
for(int b=0; b<cols; b++){
theta[a][b]=theta[a][b]*div;
sintheta[a][b]=sin(theta[a][b]);
costheta[a][b]=cos(theta[a][b]);
ds[a][b] = (sintheta[a][b] * cos(theta_o) - costheta[a][b] * sin(theta_o))*div;
dc[a][b] = (costheta[a][b] * cos(theta_o) + sintheta[a][b] * sin(theta_o))*div;
dalpha[a][b] = abs(atan2(ds[a][b],dc[a][b]));
divis[a][b] = -(dalpha[a][b]*dalpha[a][b])/(2*(sigma_theta*sigma_theta));
spread[a][b]= exp(divis[a][b]);
divis2[a][b]= -(log((radius[a][b]/r_o) * (radius[a][b]/r_o))/(2*log(sigma_r*sigma_r)));
filter[a][b]= exp(divis2[a][b]);
filter[a][b]=filter[a][b]*spread[a][b];
// filter = fftshift(filter);
// rpad = ifft2(imfft.*filter);
}
}
for(int i=1+k;i<=rs-k;i++)
x[i]= i;
for(int i=1+k;i<=cs-k;i++)
y[i]= i;
// rpad=rpad(x,y); delete x & y from rpad
return rpad;
}