title: Converting Numpy Array to OpenCV Array
body: <p>I'm trying to convert a 2D Numpy array, representing a black-and-white image, into a 3-channel OpenCV array (i.e. an RGB image).</p>
  
  <p>Based on <a href="https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/python2/find_obj.py" rel="noreferrer">code samples</a> and <a href="http://opencv.willowgarage.com/documentation/cpp/miscellaneous_image_transformations.html#cv-cvtcolor" rel="noreferrer">the docs</a> I'm attempting to do this via Python like:</p>
  
  <pre><code>import numpy as np, cv
  vis = np.zeros((384, 836), np.uint32)
  h,w = vis.shape
  vis2 = cv.CreateMat(h, w, cv.CV_32FC3)
  cv.CvtColor(vis, vis2, cv.CV_GRAY2BGR)
  </code></pre>
  
  <p>However, the call to CvtColor() is throwing the following cpp-level Exception:</p>
  
  <pre><code>OpenCV Error: Image step is wrong () in cvSetData, file /build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp, line 902
  terminate called after throwing an instance of 'cv::Exception'
    what():  /build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp:902: error: (-13)  in function cvSetData
  
  Aborted
  </code></pre>
  
  <p>What am I doing wrong?</p>