skimage2.restoration.wiener#
- skimage2.restoration.wiener(image, psf, balance, reg=None, is_real=True, clip=True)[source]#
Restore image using WienerâHunt deconvolution.
WienerâHunt deconvolution is a restoration method which follows a Bayesian approach [1].
- Parameters:
- image(N1, N2, âĶ, ND) ndarray
Degraded image.
- psfndarray
Point spread function (PSF). Assumed to be the impulse response (input image space) if the data type is real, or the transfer function (Fourier or frequency space) if the data type is complex. There is no constraint on the shape of the impulse response. The transfer function though must be of shape
(N1, N2, ..., ND)ifis_real is True,(N1, N2, ..., ND // 2 + 1)otherwise (seenumpy.fft.rfftn()).- balancefloat
Regularization parameter. Denoted by \(\lambda\): in the Notes section below, its value lets you balance data adequacy (improving frequency restoration) with respect to prior adequacy (reducing frequency restoration and avoiding noise artifacts). A larger value for this parameter favors the regularization/prior.
- regndarray, optional
Regularization operator. Laplacian by default. It can be an impulse response or a transfer function, as for the PSF. Shape constraints are the same as for
psf.- is_realbool, optional
True by default. Specify if
psfandregare provided over just half the frequency space (thanks to the redundancy of the Fourier transform for real signals). Applies only ifpsfand/orregare provided as transfer functions. Seeuftmodule andnp.fft.rfftn().- clipbool, optional
True by default. If True, pixel values of the deconvolved image (which is the return value) above 1 (resp. below -1) are clipped to 1 (resp. to -1). Be careful to set
clip=Falseif you do not want this clipping and/or if your data range is not [0, 1] or [-1,1].
- Returns:
- im_deconv(N1, N2, âĶ, ND) ndarray
The deconvolved image.
Notes
This function applies the Wiener filter to a noisy (degraded) image by an impulse response (or PSF). If the data model is
\[y = Hx + n\]where \(n\) is noise, \(H\) the PSF, and \(x\) the unknown original image, the Wiener filter is
\[\hat x = F^\dagger \left( |\Lambda_H|^2 + \lambda |\Lambda_D|^2 \right)^{-1} \Lambda_H^\dagger F y\]where \(F\) and \(F^\dagger\) are the Fourier and inverse Fourier transforms respectively, \(\Lambda_H\) the transfer function (or the Fourier transform of the PSF, see [2]), and \(\Lambda_D\) the regularization operator, which is a filter penalizing the restored image frequencies (Laplacian by default, that is, penalization of high frequencies). The parameter \(\lambda\) tunes the balance between data (which tends to increase high frequencies, even those coming from noise) and regularization/prior (which tends to avoid noise artifacts).
These methods are then specific to a prior model. Consequently, the application or the true image nature must correspond to the prior model. By default, the prior model (Laplacian) introduces image smoothness or pixel correlation. It can also be interpreted as high-frequency penalization to compensate for the instability of the solution with respect to the data (sometimes called noise amplification or âexplosiveâ solution).
Finally, the use of Fourier space implies a circulant property of \(H\), see [2].
References
[1]François Orieux, Jean-François Giovannelli, and Thomas Rodet, âBayesian estimation of regularization and point spread function parameters for WienerâHunt deconvolutionâ, J. Opt. Soc. Am. A 27, 1593â1607 (2010) https://www.osapublishing.org/josaa/abstract.cfm?URI=josaa-27-7-1593 https://hal.archives-ouvertes.fr/hal-00674508
Examples
>>> import _skimage2 as ski2 >>> import scipy as sp >>> img = ski2.color.rgb2gray(ski2.data.astronaut()) >>> psf = np.ones((5, 5)) / 25 >>> img = sp.signal.convolve2d(img, psf, 'same') >>> rng = np.random.default_rng() >>> img += 0.1 * img.std() * rng.standard_normal(img.shape) >>> deconvolved_img = ski2.restoration.wiener(img, psf, 0.1)