title: OpenCV 2.4.2 Byte array to Mat produces a strange image pattern
body: <p>Good afternoon,</p>
  
  <p>I am trying to run <code>OpenCV</code> through a <code>DLL</code> and use it in a <code>LabVIEW</code> application.</p>
  
  <p>I have correctly acquired an image in <code>LV</code> and passed the byte array to the <code>DLL</code>.</p>
  
  <p>I can loop and print out in a text file the values for every pixel and match them to the output in LV, so I know that all my pixels are in the right position, for the exception that LV adds 2 columns at the beginning, with the first 2 values reserved for height and width and the rest are arbitrary numbers. But all this should do is produce a streak on the left side of the image. </p>
  
  <p>Next, I am using the following lines to convert and display the image.</p>
  
  <p><code>a[0]</code>, <code>a[1]</code>... etc. are channels.</p>
  
  <p>The output image comes out as a very horizontally stretched out image with pixels spaced equally 15-20 pixels apart and surrounded by black pixels. I attached a screenshot</p>
  
  <pre><code>_declspec (dllexport)  double  imageProcess(int **a, int &amp;x, int &amp;y, int &amp;cor,int &amp;cog,int &amp;cob,int &amp;cow, int th, int hth)
  {
  
      y = a[0][0];
      x = a[0][1];
  
  
      Mat image(y, x, CV_8U, a[0]);
  
  
      namedWindow( "Display window", CV_WINDOW_NORMAL );  // Create a window for display.
      imshow( "Display window", image );                 // Show our image inside it.
  
      return (0);
  }
  </code></pre>
  
  <p>Additionally I tried using this code with the same effect:</p>
  
  <pre><code>IplImage* cv_image = cvCreateImageHeader(cvSize(x,y), IPL_DEPTH_8U, 1);
  cvSetData(cv_image, a[0], cv_image-&gt;widthStep);
  Mat image = Mat(cv_image, false);
  </code></pre>
  
  <p>Can anyone please help me explain why this is happening during my image creation?</p>
  
  <p>Note, Unfortunately, I cannot provide the original image/capture from LV, but I can say that it doesn't look anything like that and I am working with everything in grayscale.</p>
  
  <p>Output Image:</p>
  
  <p><img src="https://i.stack.imgur.com/KOKGE.jpg" alt="Output"></p>