Files
scikit-image/skimage/deconvolution/tests/test_deconvolution.py
T
François Orieux 7042d778e6 Fix the bad results of unsupervised deconvolution.
The initial implementation was simplified to reduce the number of
local variable. Consequently the parameter data.size was wrong. It was
the size of the fourier spectrum, with hermitian property, instead of
the real space size. This should work.

In addition the PSF is now normalized.
2013-12-10 22:45:10 +01:00

34 lines
1017 B
Python

from os.path import abspath, dirname, join as pjoin
import numpy as np
from scipy.signal import convolve2d
from skimage.data import camera
from skimage import deconvolution
test_img = camera().astype(np.float)
def test_wiener():
psf = np.ones((5, 5)) / 25
data = convolve2d(test_img, psf, 'same')
np.random.seed(0)
data += 0.1 * data.std() * np.random.standard_normal(data.shape)
deconvolved = deconvolution.wiener(data, psf, 25)
path = pjoin(dirname(abspath(__file__)), 'camera_wiener.npy')
np.testing.assert_allclose(deconvolved, np.load(path))
def test_unsupervised_wiener():
psf = np.ones((5, 5)) / 25
data = convolve2d(test_img, psf, 'same')
np.random.seed(0)
data += 0.1 * data.std() * np.random.standard_normal(data.shape)
deconvolved, _ = deconvolution.unsupervised_wiener(data, psf)
path = pjoin(dirname(abspath(__file__)), 'camera_unsup.npy')
np.testing.assert_allclose(deconvolved, np.load(path))
def test_richardson_lucy():
return True