OpenCV set pixels outside ROI as the nearest pixel value inside the ROI
I have an image with a non-rectangular ROI, defined by a binary mask image.
In OpenCV, how can I set the pixels OUTSIDE my ROI as the nearest pixel value INSIDE the ROI? Something similar to what is in cv::BORDER_REPLICATE
, or something similar to what is done in cv::warp
You can make use of cv::inpaint()
by restoring the selected region region in an image using the region neighborhood.
In your case, that will be something like:
cv::inpaint(mat_input, 255 - roi, mat_output, inpaint_radius, cv::INPAINT_NS);
链接地址: http://www.djcxy.com/p/89728.html