I'm trying to create a collage image. The following code writes correctly to the left part of collage image (green), but not to the right.
Size collageSize(img1.width + img2.width, std::max(img1.height, img2.height));
Mat collageImg = Mat(collageSize, CV_8UC3, Scalar::all(0));
Mat img1ROI(collageImg, cv::Range(0, img1.rows), cv::Range(0, img1.cols));
rectangle(img1ROI, Rect(0, 0, img1.cols, img1.rows), CV_RGB(0, 255, 0), -1);
Mat img2ROI(collageImg, cv::Range(0, img2.rows), cv::Range(img1.cols, img2.cols));
rectangle(img2ROI, Rect(0, 0, img2.cols, img2.rows), CV_RGB(255, 0, 0), -1);
If I create img2ROI
as following:
Mat img2ROI(collageImg, Rect(img1.cols, 0, img2.cols, img2.rows));
Then I get the correct collage image:
Why it doesn't work with Range
for the right image?