Translating from Matlab to C a function -
i translating funciton matlab c. have problem lines fourier transform. code, commented lines in matlab , that's need translate.
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 rpad return rpad; }
or if want code fft yourslef, matlabs's fft code , translate line line.
Comments
Post a Comment