mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-02 13:03:48 +08:00
Add test for Richardson Lucy.
This commit is contained in:
@@ -48,9 +48,9 @@ ax[0].imshow(lena)
|
||||
ax[0].axis('off')
|
||||
ax[0].set_title('Data')
|
||||
|
||||
ax[1].imshow(deconvolued)
|
||||
ax[1].imshow(deconvolued, vmax=lena.max())
|
||||
ax[1].axis('off')
|
||||
ax[1].set_title('Deconvolution')
|
||||
ax[1].set_title('Self tuned deconvolution')
|
||||
|
||||
fig.subplots_adjust(wspace=0.02, hspace=0.2,
|
||||
top=0.9, bottom=0.05, left=0, right=1)
|
||||
|
||||
@@ -30,4 +30,11 @@ def test_unsupervised_wiener():
|
||||
|
||||
|
||||
def test_richardson_lucy():
|
||||
return True
|
||||
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.richardson_lucy(data, psf, 5)
|
||||
|
||||
path = pjoin(dirname(abspath(__file__)), 'camera_rl.npy')
|
||||
np.testing.assert_allclose(deconvolved, np.load(path))
|
||||
|
||||
@@ -28,7 +28,7 @@ from __future__ import division
|
||||
|
||||
import numpy as np
|
||||
import numpy.random as npr
|
||||
from scipy.signal import convolve2d as conv2
|
||||
from scipy.signal import convolve2d
|
||||
|
||||
import uft
|
||||
|
||||
@@ -330,13 +330,24 @@ def richardson_lucy(data, psf, iterations=50):
|
||||
The point spread function
|
||||
|
||||
iterations : int
|
||||
Number of iterations
|
||||
Number of iterations. This parameter play to role of regularisation.
|
||||
|
||||
Returns
|
||||
-------
|
||||
im_deconv : ndarray
|
||||
The deconvolved image
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> import numpy as np
|
||||
>>> from skimage import color, data, deconvolution
|
||||
>>> camera = color.rgb2gray(data.camera())
|
||||
>>> from scipy.signal import convolve2d
|
||||
>>> psf = np.ones((5, 5)) / 25
|
||||
>>> camera = convolve2d(camera, psf, 'same')
|
||||
>>> camera += 0.1 * camera.std() * np.random.standard_normal(camera.shape)
|
||||
>>> deconvolved = deconvolution.richardson_lucy(camera, psf, 5)
|
||||
|
||||
References
|
||||
----------
|
||||
.. [2] http://en.wikipedia.org/wiki/Richardson%E2%80%93Lucy_deconvolution
|
||||
@@ -347,7 +358,7 @@ def richardson_lucy(data, psf, iterations=50):
|
||||
im_deconv = 0.5 * np.ones(data.shape)
|
||||
psf_mirror = psf[::-1, ::-1]
|
||||
for _ in range(iterations):
|
||||
relative_blur = data / conv2(im_deconv, psf, 'same')
|
||||
im_deconv *= conv2(relative_blur, psf_mirror, 'same')
|
||||
relative_blur = data / convolve2d(im_deconv, psf, 'same')
|
||||
im_deconv *= convolve2d(relative_blur, psf_mirror, 'same')
|
||||
|
||||
return im_deconv
|
||||
|
||||
Reference in New Issue
Block a user