I'd like to create a 3D matrix made of several images. So, first of all I define the Mat object as follow:
string folder = argv[1]; // DARK folder
vector<String> fn; // read all file in main folder
glob(folder, fn, false); //
int cont = fn.size(); //
cvFits dark1(fn[0]); //load 1st images in order to retrieve images size
int col = dark1.cols;
int row = dark1.rows;
int Dark_size[3] = {row, col, cont}; //size of Dark matrix
Mat Dark_3D(cont, Dark_size, CV_16UC1); //define dark matrix
After that, I try to fill it with all images in the folder
for(int z = 0; z < cont; z++)
{
cvFits dark(fn[z]);
for(int i = 0; i < row; i++)
{
for(int j = 0; j < col; j++)
{
Dark_3D.at<Vec3w>(i,j)[z] = dark.at<ushort>(i,j);
}
}
}
But the code return with error "Segmentation fault (core dumped)". What is the problem?