Ciao ho un problema traducendo una linea di codice da Matlab a C/C++:
radius(floor(rows/2+1),floor(cols/2+1)) = 1;
% Get rid of the 0 radius value at the 0
% frequency point (now at top-left corner)
% so that taking the log of the radius will
% not cause trouble.
Io ho fatto:
radius[rows/2][cols/2]=1;
Si trova nella funzione:
void pre_filter_Computations(matriz radius,matriz theta,int cols,int rows){
double X[rows][cols],Y[rows][cols];
double x[cols],y[rows];
double epsilon = 0.0001;
for(int i=0;i<cols;i++){
x[i]=((double)(i-cols)/2)/((double)cols/2);
}
for(int z=0;z<rows;z++){
y[z]=-(((double)(z-rows)/2)/((double)rows/2));
}
for(int m=0;m<cols;m++){
for(int n=0;n<rows;n++){
X[m][n]=x[m];
Y[m][n]=y[n];
}
}
for(int a=0;a<rows;a++){
for(int b=0;b<cols;b++){
X[a][b] = pow(X[a][b],2);
Y[a][b] = pow(Y[a][b],2);
X[a][b] = X[a][b] + Y[a][b];
radius[a][b] = sqrt(X[a][b]);
}
}
printf("Hello\n"); //STAMPA
radius[rows/2][cols/2]=1;
printf("Hello\n"); //NON STAMPA
for(int a=0;a<rows;a++){
for(int b=0;b<cols;b++){
radius [a][b]= radius[a][b] + epsilon;
theta[a][b] = atan2(Y[a][b],X[a][b])*180/PI;
}
}
}
Il tipo matriz:
typedef double**matriz;
matriz radius,theta;
[/code]
La funzione che crea la matrice:
double **createmat(int rows,int cols){
double **m;
m=new double*[rows];
for(int i=0;i<rows;i++)
m[i]=new double[cols];
return m;
}