Inpainting
Inpainting works provided the damaged area is not too “thick” and enough of the original texture and color
remains around the boundaries of the damage.
Figure 6-27 shows what happens when the damaged area is too large.
Figure 6-26: Inpainting: an image damaged by overwritten text (left) is restored by inpainting (right)
The prototype for cv::inpaint() is
void cv::inpaint(
cv::InputArray src, // Input Image: 8-bit, 1 or 3 channels
cv::InputArray inpaintMask, // 8-bit, 1 channel. Inpaint non-zeros
cv::OutputArray dst, // Result image
double inpaintRadius, // Range to consider around pixel
int flags // Select NS or TELEA
);
Figure 6-27: Inpainting cannot magically restore textures that are completely removed: the navel of the
orange has been completely blotted out (left); inpainting fills it back in with mostly orangelike texture
(right)