mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-02 01:37:54 +08:00
7042d778e6
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.
34 lines
1017 B
Python
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
|