So you want to denoise some images, or maybe shrink inside a projected gradient algorithm?
This Python package provides an interface for the BM3D denoising strategy which is based on enhanced sparse representations in the transform-domain. The enhancement of the sparsity is achieved by grouping similar 2D image fragments (e.g. blocks) into 3D data arrays. Visit the offical BM3D website for a detailed explanation, benchmark results and other related works.
The core C implementation of BM3D is based on the work of Marc Lebrun.
PyBM3D is supported for Linux and OSX and Python 2.7 and 3.6. Please follow the installation instructions:
- FFTW3:
- Linux:
sudo apt-get install libfftw3-dev
- OSX:
brew update && brew install fftw
- Linux:
pip install pybm3d
Denoising a RGB color image |
import numpy as np
import skimage.data
from skimage.measure import compare_psnr
import pybm3d
noise_std_dev = 40
img = skimage.data.astronaut()
noise = np.random.normal(scale=noise_std_dev,
size=img.shape).astype(img.dtype)
noisy_img = img + noise
out = pybm3d.bm3d.bm3d(noisy_img, noise_std_dev)
noise_psnr = compare_psnr(img, noisy_img)
out_psnr = compare_psnr(img, out)
print("PSNR of noisy image: ", noise_psnr)
print("PSNR of reconstructed image: ", out_psnr) |
This project is released under the terms of the GPL3 license.