Inpainting is the task of reconstructing missing regions in an image. OpenCV implements two methods that work well to rebuild small portions of an image. For large pieces or very textured areas, these algorithms show some limitations. The first figure shows that using the built-in inpainting from OpenCV is not satisfactory compared to the patch-based texture inpainting in the case of significant gaps and with a very textured background.
The algorithm used for the patch inpainting is described in . This algorithm uses image quilting to generate texture and KDTree to find the similarities between adjacent cells and fill missing image parts.
One difficulty can arise in the case of huge images because dividing the image into cells can take much memory. To circumvent this problem, the patch-based-inpainting library provides several parameters to reduce memory intake. One way is to select a sub-area to perform the training in the image. Another way is not to perform mirror operations and rotations on the cells. At last, we can change the step used to divide the image into cells.
Finally, the user provides the image to inpaint, several parameters like the cell and overlap size, and a binary mask where all the areas that are not zero will be inpainted.