How can I convert a vector of Mat files into a Mat file? I have got a vector with size N. Every mat file is of size 1xM. I want to create a new Mat file of size 1xNM? How can I do so in Opencv? Or better to create a new vector with size MN which will contain the pixels of every Mat file. Is there a reshape function in Opencv?
Mat flat; // output
for (size_t i=0; i<patch_image.size(); i++)
{
// you said, those would be 1xM, but let's make sure.
flat.push_back( patch_image[i].reshape(1,1) );
}
flat = flat.reshape(1,1);
int temp;
for(int i=0; i<flat.rows; i++){
for(int j=0; j<flat.cols; j++){
temp = (int)flat.at<uchar>(i,j);
cout << temp << "\t";
}
cout << endl;
}
However that assignment to int temp it seems to work.
cout << flat << endl;
(print the whole Mat in 1 go) – berak