title: How to assign 2d images to planes of a 3d OpenCV Mat, then extract 2D Mats along a different axis?
body: <p>I want to make a 3D Mat out of stacked 2D Mats and then pull out 2D Mats along a different axis of the 3D Mat.  I know I can build this up manually accessing every row or col of every image but is there a better to do it like the following?</p>
  
  <pre><code>vector&lt;cv::Mat&gt; images;
  </code></pre>
  
  <p>... populate vector with images</p>
  
  <pre><code>int sz[] = {images[0].rows, images[0].cols, images.size()}
  cv::Mat cube(3, sz, images[0].type() );
  cube = Scalar(0);
  
  for (int i = 0; i &lt; images.size(); i++) {
  </code></pre>
  
  <p>... place images into 3d mat</p>
  
  <pre><code>}
  
  vector&lt;cv::Mat&gt; image_rows;
  
  for (int i = 0; i &lt; images[0].rows(); i++) {
  </code></pre>
  
  <p>... push image planes into image_rows along width and depth of 3D cube matrix</p>
  
  <pre><code>}
  </code></pre>