Files
scikit-image/skimage/deconvolution/test/test_deconvolution.py
T
François Orieux 33aedfd9aa Add deconvolution module to skimage.
This module add three function to skimage. The `wiener` function is a
simple wiener deconvolution. The `unsupervised_wiener` is a more
sophisticated wiener deconvolution with automatic estimation of
regularisation parameters. The third function is a literal traduction
in python of the rychardson lucy deconvolution of wikipedia.
2013-12-10 22:45:07 +01:00

39 lines
1.0 KiB
Python

import warnings
import numpy as np
import numpy.testing.assert_array_almost_equal
from scipy.signal import convolve2d as conv2
from skimage import data, deconvolution
# Test deconvolution
# ===========================
test_img = data.camera().astype(np.float)
def test_wiener():
psf = np.ones((5, 5))
data = conv2(test_img, psf, 'same')
np.random.seed(0)
data += 0.1 * data.std() * np.random.standard_normal(data.shape)
deconvolued = deconvolution.wiener(data, psf, 25)
numpy.testing.assert_array_almost_equal(deconvolued,
np.load("./camera_wiener.npy"))
def test_unsupervised_wiener():
psf = np.ones((5, 5))
data = conv2(test_img, psf, 'same')
np.random.seed(0)
data += 0.1 * data.std() * np.random.standard_normal(data.shape)
deconvolued, _ = deconvolution.unsupervised_wiener(data, psf)
numpy.testing.assert_array_almost_equal(deconvolued,
np.load("./camera_unsup.npy"))
def test_rychardson_lucy():
return True