how to cout 4 dimensional cv::Mat code example
Example: how to cout 4 dimensional cv::Mat
cv::Mat sliceMat(cv::Mat L,int dim,std::vector _sz)
{
cv::Mat M(L.dims - 1, std::vector(_sz.begin() + 1, _sz.end()).data(), CV_8UC1, L.data + L.step[0] * 0);
return M;
}
std::cout << "3 dimensions" << std::endl;
std::vector sz = { 3,3,3 };
cv::Mat L;
L.create(3, sz.data(), CV_8UC1);
L = cv::Scalar(255);
std::cout<< sliceMat(L, 1, sz);
std::cout << std::endl;
std::cout <<"4 dimensions"<< std::endl;
sz = { 5,4,3,5 };
L.create(4, sz.data(), CV_8UC1);
L = cv::Scalar(255);
std::cout << sliceMat(sliceMat(L, 1, sz),2, std::vector(sz.begin() + 1, sz.end()));