How to get a ROI with arbitrary shape?
Hello, the code is here
cv::Mat src = cv::imread("1.bmp", CV_LOAD_IMAGE_UNCHANGED);
cv::Mat mask = cv::Mat::ones(src.size(), CV_8UC1);
mask.row(10).setTo(255);
mask.col(20).setTo(255); // arbitary shape
cv::Mat roi;
src.copyTo(roi, mask); // get the roi
This is 1.bmp
This is mask
This is roi
If I excute roi = roi + 10
, the black parts of roi will also add 10, it's not what I want.
How to get a roi without the black parts?
Thanks!
you could use the same mask with add
Thanks for reply. Adding with a mask has solved this problem, but what about other operation? For example, roi.setTo(255), matching roi to another picture... Can all the operation just influence the roi region? thanks :)