0

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?

Tanozar
  • 49
  • 1
  • 1
  • 4
  • Check my answer here https://stackoverflow.com/questions/59347349/access-elements-of-multidimentional-cvmat-array/59349683?noredirect=1#comment104975506_59349683 just instead of 5 channels use 3 – Ziri Dec 19 '19 at 10:52
  • what are you trying to achieve? it'll be much more easy to store your images in a `std::vector>`... – Miki Dec 19 '19 at 11:50

0 Answers0