This is a fairly simple program that has been coded with the aim of performing image inpainting on damaged images and it works with both RGB and gray-scale images. Two different techniques have been used:
- Interpolation
- Explicit solution of a linear PDE
The following image, used for this case study, has pixels which have worn off over time. Those damaged regions are the ones we wish to inpaint and reconstruct. (In this repo you can find more example pictures which can be used to test the algorithm).
The damaged regions are highlighted by the following mask:
Those pixels of the input image, which show no sign of wear, have been modeled as scattered data and they have been used in order to define the interpolant. Two interpolants were defined: one for the linear interpolation and the other for the Nearest Neighbour interpolation. The output image obtained as a result of the algorithm is the following:
The second inpainting technique involves the solution of the following linear PDE using the explicit method.
where
Such PDE is similar to the heat equation and permits the inpainting of the image through an isotropic diffusion. A more in depth mathematical analysis of the problem can be found Here . (Please note that the doc is currently n Italian, the math part should be pretty straight forward though 😆)
The result of the algorithm is the following:
This PDE has two problems:
- It doesn't take into account damaged pixels which might be part of the borders.
- The PDE performs an isotropic inpainting, hence the edges aren't taken into account.
The first issue has been addressed and solved by implementing the Neumann boundary condition.
As an example have a look at how an image would look without and with such boundary condition:
- Higher order non linear anisotropic PDE in order to have a weighted, edge preserving diffusion along the edges.
Distributed under the MIT License. See LICENSE.txt for more information.