title: Copy Mat in opencv
body: <p>I try to copy a image to other image using opencv, but I got a problem. Two image is not the same, like this:</p>
  
  <p><img src="https://i.stack.imgur.com/Kq8uX.jpg" alt="enter image description here"></p>
  
  <p>This is the code I used:</p>
  
  <pre><code>#include &lt;opencv2\opencv.hpp&gt;
  
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  #include &lt;opencv2/imgproc/imgproc.hpp&gt;
  #include &lt;cmath&gt;
  #include &lt;iostream&gt;
  #include &lt;opencv2\opencv.hpp&gt;
  int main()
  {
      cv::Mat inImg =    cv::imread("C:\\Users\\DUY\\Desktop\\basic_shapes.png");  
      //Data point copy  
      unsigned char * pData = inImg.data;  
  
      int width = inImg.rows;  
      int height = inImg.cols;  
  
      cv::Mat outImg(width, height, CV_8UC1);  
      //data copy using memcpy function  
      memcpy(outImg.data, pData, sizeof(unsigned char)*width*height);  
  
     //processing and copy check  
     cv::namedWindow("Test");  
     imshow("Test", inImg);  
  
     cv::namedWindow("Test2");  
     imshow("Test2", outImg);  
  
     cvWaitKey(0);  
  }
  </code></pre>