This package provides an implementation of the loopy belief propagation (LBP) algorithm in denoising and inpainting greyscale images.
This package contains 2 modules:
image_damager
: Add Gaussian noise to an image and destroy a portion of it.
denoising_inpainting
: Denoise and inpaint an image using the LBP
algorithm. The current implementation can take many hours for a high number of
iterations or high-resolution images.
The algorithm is based on the following paper:
The following libraries need to be installed:
- NumPy
- OpenCV
- Matplotlib
Install the package from the repository with the following commands:
git clone https://github.com/NickGeramanis/denoising-inpainting-lbp
cd denoising-inpainting-lbp
pip3 install -e .
To damage an image, execute the function damage_image()
of the image_damager
module with the following parameters:
image_path, noise_mean_value, noise_variance
For example:
from denoising_inpainting_lbp import image_damager
image_damager.damage_image('path/to/image.png', 0, 0.1)
Note that a mask image will also be produced that indicates which pixels have been damaged.
To perform denoising and inpainting on an image using the LBP algorithm,
execute the function denoise_inpaint()
of the denoising_inpainting
module
with the following parameters:
image_path, mask_image_path, n_iterations, lambda, energy_lower_bound, max_smoothness_penalty
If the smoothness cost function is not truncated do not provide max_smoothness_penalty.
If energy_lower_bound is not known provide 1.
For example:
from denoising_inpainting_lbp import denoising_inpainting
denoising_inpainting.denoise_inpaint('path/to/image.png', 'path/to/mask.png', 1, 5, 37580519.6)
Furthermore, some unit tests have been implemented in the folder tests
to verify
the proper functioning of the code.
Under maintenance.
Distributed under the GPL-3.0 License. See LICENSE
for more information.