Ask Your Question

Revision history [back]

Answer is no. To get intersection a mask must be used. Then you can use (example) copyTo. but it is written :

Operation mask of the same size as *this. Its non-zero elements indicate which matrix elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels.

You have copy your mask is an image with a size equal to original image example :

Mat img;
Mat mask(img.size(),CV_8UC1,Scalar(0));
Mat smallerMask;

smallerMask.copyTo(mask(rect(Point(10,10),smallerMask.size()));

PS code is not tested

Answer is no. To get intersection a mask must be used. Then you can use (example) copyTo. but it is written :

Operation mask of the same size as *this. Its non-zero elements indicate which matrix elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels.

You have must copy your mask is an image with a size equal to original image example :

Mat img;
Mat mask(img.size(),CV_8UC1,Scalar(0));
Mat smallerMask;
 ....
smallerMask.copyTo(mask(rect(Point(10,10),smallerMask.size()));

PS code is not tested

Answer is no. To get intersection a mask must be used. Then you can use (example) copyTo. but it is written :

Operation mask of the same size as *this. Its non-zero elements indicate which matrix elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels.

You must copy mask is an image with a size equal to original image example :

Mat img;
Mat mask(img.size(),CV_8UC1,Scalar(0));
Mat smallerMask;
....
smallerMask.copyTo(mask(rect(Point(10,10),smallerMask.size()));
Point p(10,10);
smallerMask.copyTo(mask(rect(p,smallerMask.size()));

You must choose P location and check is rect(p,smallerMask.size()) is not outside of img image

PS code is not tested