Ask Your Question

Revision history [back]

you can create a canvas ( Mat ) and use rois to show the image and selections

see the code below ( just to show the idea)

cv::Mat img = cv::imread("messi5.jpg");
cv::Mat canvas(img.rows+130, img.cols+20, CV_8UC3, cv::Scalar(127, 127, 127));

cv::Rect r(10, 10, img.cols, img.rows);
img.copyTo(canvas(r));

cv::Rect selection1(10, 10, 100, 100);
cv::Rect selection2(200, 200, 100, 100);
cv::Rect selection3(300, 240, 100, 100);

cv::Rect showSelection1(10, img.rows + 20, 100, 100);
cv::Rect showSelection2(120, img.rows + 20, 100, 100);
cv::Rect showSelection3(230, img.rows + 20, 100, 100);

img(selection1).copyTo(canvas(showSelection1));
img(selection2).copyTo(canvas(showSelection2));
img(selection3).copyTo(canvas(showSelection3));

cv::imshow("Canvas", canvas);
cv::waitKey();

image description