title: Reshaping OpenCV Mat fails
body: <p>I am unable to reshape my <code>cv::Mat</code>.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>#include "opencv2/core/core.hpp"
  #include "opencv2/contrib/contrib.hpp"
  #include "opencv2/highgui/highgui.hpp"
  #include "opencv2/imgproc/imgproc.hpp"
  #include "opencv2/objdetect/objdetect.hpp"
  #include &lt;boost/algorithm/string.hpp&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  #include &lt;assert.h&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;iterator&gt;
  #include &lt;sstream&gt;
  
  
  
  int main(int argc, const char* argv[])
  {
      std::cout &lt;&lt; "Start\n";
      cv::Mat eigenvectors = (cv::Mat_&lt;float&gt;(2,2) &lt;&lt; 4, 3, 2, 1);
      std::cout &lt;&lt; "eigenvectors shape " &lt;&lt; eigenvectors.size() &lt;&lt; std::endl;
      cv::Mat reshaped = eigenvectors.reshape(4, 1);
      std::cout &lt;&lt; reshaped.size() &lt;&lt; std::endl;
      std::cout &lt;&lt; reshaped &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>Here is the result.</p>
  
  <pre><code>Start
  eigenvectors shape [2 x 2]
  [1 x 1]
  [4, 3, 2, 1]
  </code></pre>
  
  <p>Why is my program claiming to have a 1x1 matrix, but holding the values for a 4x1 matrix? It is only doing this for this dimension.</p>
  
  <p>When I expand my code to include these tests.</p>
  
  <pre><code>reshaped = eigenvectors.reshape(1, 4);
  std::cout &lt;&lt; reshaped.size() &lt;&lt; std::endl;
  std::cout &lt;&lt; reshaped &lt;&lt; std::endl;
  reshaped = eigenvectors.reshape(2, 2);
  std::cout &lt;&lt; reshaped.size() &lt;&lt; std::
  </code></pre>
  
  <p>I get normal results.</p>
  
  <pre><code>[1 x 4]
  [4; 3; 2; 1]
  [1 x 2]
  [4, 3; 2, 1]
  </code></pre>
  
  <p>Is this a bug or am I doing something wrong?</p>
  
  <p>EDIT:</p>
  
  <p>To improve the Google relevance of this result, another symptom I was having is that as a result of my "reshaping", I was also losing the type of my <code>Mat</code>.</p>