Ask Your Question

Revision history [back]

click to hide/show revision 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:

  1. replicate border pixels using copyMakeBorder()
  2. apply inpaint(), your borders will still have problem though
  3. extract the original area without border, borders information having aritfacts is excluded

code:

// 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:

image description

However, this does not answer if the initial behavior of inpaint() is expected or it is based on a bug.