c++ - How to create rotated rectangular or polygonal ROI/mask? -
let's have following image:
and region of interest looks this:
and want have following result:
how can achieve knowing roi denoted 4 points:
point pt1(129,9); point pt2(284,108); point pt3(223,205); point pt4(67,106);
the idea use fillpoly()
fill pixels inside rotated-rectangle/polygon 0, 255 otherwise:
mat mask = cv::mat(img.size(), cv_8uc1, scalar(255)); // suppose img image mat vector<vector<point>> pts = { { pt1, pt2, pt3, pt4 } }; fillpoly(mask, pts, scalar(0)); // <- here
Comments
Post a Comment