title: How to merge two images in opencv?
body: <p>I have calculated homography ,taken out perspective transform .I am able two display two images in one window but unable to merge them.Here are my example images->
  <img src="https://i.stack.imgur.com/JN0d8.jpg" alt="image1"></p>
  
  <p><img src="https://i.stack.imgur.com/byA4W.jpg" alt="image2"></p>
  
  <p>The code I am using thiscode -></p>
  
  <pre><code>cv::warpPerspective(image2,warpresult2,homography,cv::Size(2*image2.cols,image2.rows));
  
  
  Mat imgResult(image1.rows,2*image1.cols,image1.type());
  
  Mat roiImgResult_Left = imgResult(Rect(0,0,image1.cols,image1.rows)); 
  Mat roiImgResult_Right = imgResult(Rect(image1.cols,0,image2.cols,image2.rows)); 
  
  Mat roiImg1 = image1(Rect(0,0,image1.cols,image1.rows));
  Mat roiImg2 = warpresult2(Rect(0,0,image2.cols,image2.rows));
  
  roiImg1.copyTo(roiImgResult_Left); //Img1 will be on the left of imgResult
  roiImg2.copyTo(roiImgResult_Right); //Img2 will be on the right of imgResult
  
  imshow("Finalimg",imgResult);
  imwrite("C:\\OpenCv_Projects\\outputimage.jpg",imgResult);
  cvWaitKey(0);
  </code></pre>
  
  <p>I think the problem is in the coordinates that i am giving roiImgResult_right.</p>
  
  <p>And the Output Image is ->
  <img src="https://i.stack.imgur.com/Qcafd.jpg" alt="Output images">
  As you can see the images are not properly merge and there is black area on the right side.how to remove that also?</p>