bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / restoration / deconvolution / wiener
function
skimage.restoration.deconvolution:wiener
source: /dev/scikit-image/src/skimage/restoration/deconvolution.py :10
Signature
def wiener ( image , psf , balance , reg = None , is_real = True , clip = True ) Summary
Restore image using Wiener–Hunt deconvolution.
Extended Summary
Wiener–Hunt deconvolution is a restoration method which follows a Bayesian approach [1].
Parameters
image: (N1, N2, ..., ND) ndarrayDegraded image.
psf: ndarrayPoint 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 (see numpy.fft.rfftn).balance: floatRegularization parameter. Denoted by : 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.
reg: ndarray, optionalRegularization 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_real: bool, optionalTrue 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.clip: bool, optionalTrue 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) ndarrayThe 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
where is noise, the PSF, and the unknown original image, the Wiener filter is
where and are the Fourier and inverse Fourier transforms respectively, the transfer function (or the Fourier transform of the PSF, see [2]), and the regularization operator, which is a filter penalizing the restored image frequencies (Laplacian by default, that is, penalization of high frequencies). The parameter 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 , see [2].
Examples
import skimage as ski import scipy as sp img = ski.color.rgb2gray(ski.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 = ski.restoration.wiener(img, psf, 0.1)✓
Aliases
-
skimage.restoration.wiener