I created a 3D float matrix in opencv, c++ by the help of brunocodutra in his answer. My matrix is 1024*1024*N (N is not a constant number, it might change)
When I say const int N = some_number;
I can say
typedef Vec<float,N> VecNf;
After this type definition, I can play with the matrix. However, I don't want N to be constant, thus I'm stuck there. I believe, there should be some easy solution for this but I couldn't find any yet.
EDIT: I added code for saving a Matrix. Assume I properly created 3D Mat noise
having 100 channels.
typedef Vec<float,100> Vec100f;
void writeNoise_ND(string filename,Mat noise) throw(){
int chans = noise.channels();
int sz = noise.rows;
FILE* fp = fopen(filename.c_str(),"wb");
if (!fp){
perror("out directory is not found\n");
}
float *buffer = new float[sz];
for(int c = 0; c < chans; c++){
for(int i=0;i<sz;++i){
for(int j=0;j<sz;++j)
buffer[j]=noise.at<Vec100f>(i,j)[c];
fwrite(buffer,sizeof(Vec100f),sz,fp);
}
}
fclose(fp);
free(buffer);
}
Could somebody direct me? If it is already asked question, sorry about it.
Thanks in advance,