bcdi.algorithms
: Image and PSF deconvolution using Richardson-Lucy algorithm¶
algorithms_utils¶
This module includes routines using Richardson-Lucy deconvolution algorithm and blind deconvolution, that can be applied to a 3D dataset.
API Reference¶
Functions related to image deconvolution.
Richardson-Lucy algorithm, blind deconvolution…
- bcdi.algorithms.algorithms_utils.blind_deconvolution_rl(blurred_object, perfect_object, psf, nb_cycles=10, sub_iterations=10, update_psf_first=True, debugging=False, **kwargs)¶
Blind deconvolution using Richardson-Lucy algorithm.
Estimates of the perfect object and the psf have to be provided. See Figure 1 and equations (4) & (5) in D. A. Fish et al. J. Opt. Soc. Am. A, 12, 58 (1995).
- Parameters:
blurred_object – ndarray, measured object with partial coherent illumination
perfect_object – ndarray, estimate of the object measured by a fully coherent illumination, same shape as blurred_object
psf – ndarray, estimate of the psf, same shape as blurred_object
nb_cycles – number of blind deconvolution interations
sub_iterations – number of iterations of the Richardson-Lucy algorithm during a single blind iteration
update_psf_first – bool, if True the psf estimate is updated first and then the perfect object estimate
debugging – True to see plots
kwargs –
‘scale’: tuple, scale for the plots, ‘linear’ or ‘log’
’reciprocal_space’: bool, True if the data is in reciprocal space, False otherwise.
’is_orthogonal’: bool, True is the frame is orthogonal, False otherwise (detector frame) Used for plot labels.
’vmin’ = tuple of two floats (np.nan to use default), lower boundary for the colorbars
’vmax’ = tuple of two floats (np.nan to use default), higher boundary for the colorbars
- Returns:
the psf
- bcdi.algorithms.algorithms_utils.deconvolution_rl(image, psf=None, psf_shape=(10, 10, 10), iterations=20, debugging=False)¶
Image deconvolution using Richardson-Lucy algorithm.
The algorithm is based on a PSF (Point Spread Function), where PSF is described as the impulse response of the optical system.
- Parameters:
image – image to be deconvoluted
psf – ndarray, psf if known. Leave None to use a Gaussian kernel of shape psf_shape.
psf_shape – shape of the kernel used for deconvolution
iterations – number of iterations for the Richardson-Lucy algorithm
debugging – True to see plots
- Returns:
the deconvoluted image
- bcdi.algorithms.algorithms_utils.partial_coherence_rl(measured_intensity, coherent_intensity, iterations=20, debugging=False, **kwargs)¶
Partial coherence deconvolution using Richardson-Lucy algorithm.
See J.N. Clark et al., Nat. Comm. 3, 993 (2012).
- Parameters:
measured_intensity – measured object with partial coherent illumination
coherent_intensity – estimate of the object measured by a fully coherent illumination
iterations – number of iterations for the Richardson-Lucy algorithm
debugging – True to see plots
kwargs –
‘scale’: scale for the plot, ‘linear’ or ‘log’
’reciprocal_space’: True if the data is in reciprocal space, False otherwise.
’is_orthogonal’: set to True is the frame is orthogonal, False otherwise (detector frame) Used for plot labels.
’vmin’ = lower boundary for the colorbar. Float or tuple of 3 floats
’vmax’ = [higher boundary for the colorbar. Float or tuple of 3 floats
’guess’: ndarray, initial guess for the psf, of the same shape as measured_intensity
- Returns:
the retrieved psf (ndarray), the error metric (1D ndarray of len=iterations)
- bcdi.algorithms.algorithms_utils.richardson_lucy(image, psf, iterations=50, clip=True, guess=None)¶
Richardson-Lucy algorithm.
The algorithm is as implemented in scikit-image.restoration.deconvolution with an additional parameter for the initial guess of the psf.
- Parameters:
image – ndarray, input degraded image (can be N dimensional).
psf – ndarray, the point spread function.
iterations – int, number of iterations. This parameter plays the role of regularisation.
clip – boolean. If true, pixel values of the result above 1 or under -1 are thresholded for skimage pipeline compatibility.
guess – ndarray, the initial guess for the deconvoluted image. Leave None to use the default (flat array of 0.5)
- Returns:
the deconvolved image (ndarray) and the error metric (1D ndarray, len = iterations). The error is given by np.linalg.norm(previous_deconv-new_deconv) / np.linalg.norm(previous_deconv)