mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-01 21:15:07 +08:00
33aedfd9aa
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.
39 lines
1.0 KiB
Python
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
|