Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I am not really sure what you are saying, it is a little bit confusing, but if I had understand write, this should help: Normally, the Mat roiMat = image(roi); is the same as the roi of the image, so if you process it, then you actually process the image(roi). (If you do not want this, then you should do a copyTo or clone.)

As an example to better explanation, just do:

cv::Mat image = cv::imread("../img.jpg");
cv::Rect roi(15, 15, 40, 40);
cv::Rect rct(15, 15, 15, 15);
cv::Mat roiMat = image(roi); // you can do image(roi).clone() if you do not want this
cv::rectangle(roiMat, rct, CV_RGB(0, 255, 0), 2);
cv::imshow("image", image);

It will draw the rectangle in the read image, relative to the roi. I hope that this will answer your question.