1 | initial version |
Ok, taking into account the fact that normal inpaint()
cannot handle borders, @berak 's suggestion and the solution from @Micka at SO here a workaround could be the following:
copyMakeBorder()
inpaint()
, your borders will still have problem thoughcode:
// add 1pixel border
copyMakeBorder(img, img, 1, 1, 1, 1, BORDER_REPLICATE);
const unsigned char noDepth = 0; // change to 255, if values no depth uses max value or use mask image
// apply inpainting
cv::inpaint(img, (img == noDepth), img, 5.0, INPAINT_TELEA);
// extract the original area without border:
cv::Mat new_img = img(cv::Rect(1, 1, img.cols-1, img.rows-1));
output:
However, this does not answer if the initial behavior of inpaint()
is expected or it is based on a bug.