How can I permute dimensions in cv::Mat from CxWxH to WxHxC?
13:23 02 Sep 2017

How can I permute dimensions in cv::Mat from CxWxH to WxHxC (Width x Height x Channels)?

I.e. how can I convert Mat:

  • from cv::Mat frame (1000, 1000, CV_8UC3) = cv::imread("image.jpg", -1);

    with dimesions: channels, width, height

  • to Mat with dimesions: width, height, channels int sizes_inputs[] = { 3, 1000, 1000 }; cv::Mat out_image(3, sizes_inputs, CV_8UC);

Is there in OpenCV a ready-made fast function for such a conversion? Or should I implement this algorithm myself?

c++ opencv image-processing multidimensional-array