Python中有类似Matlab的deconvblind的函数吗?

Is there a function in Python similar to Matlab's deconvblind?

我正在研究盲解卷积。

在迭代L2norm reguralization的时候,我想同时更新PSF,查了一下,发现Matlab中有一个叫deconvblind的函数:

l[J,PSF] = deconvblind(I,INITPSF) deconvolves image I using the maximum likelihood algorithm, returning both the deblurred image, J, and a restored point-spread function, PSF. The input array, I, and your initial guess at the PSF, INITPSF, can be numeric arrays or cell arrays. (Use cell arrays when you want to be able to perform additional deconvolutions that start where your initial deconvolution finished. See Resuming Deconvolution for more information.) The restored PSF is a positive array that is the same size as INITPSF, normalized so its sum adds up to 1.

Python中是否有类似deconvblind的功能?

以下是如何使用 Richardson Lucy 算法在 python 中实现盲反卷积:

盲去模糊的迭代更新步骤(如2, 4中所提议),未知 PSF H,图像损坏X和复原图像S如下式所示:

下面的代码展示了我在1, mostly with frequency domain operations (as opposed to spatial domain implementation as in 3). It is similar to the non-blind implementation as in 3, only we need to estimate the unknown blur PSF at each iteration (starting with a random PSF), assumed to be known in 3中提出的迭代贝叶斯盲反卷积算法的实现。

import numpy as np
from scipy.signal import fftconvolve

def richardson_lucy_blind(image, psf, original, num_iter=50):    
    im_deconv = np.full(image.shape, 0.1, dtype='float')    # init output
    for i in range(num_iter):
        psf_mirror = np.flip(psf)
        conv = fftconvolve(im_deconv, psf, mode='same')
        relative_blur = image / conv
        im_deconv *= fftconvolve(relative_blur, psf_mirror, mode='same')
        im_deconv_mirror = np.flip(im_deconv)
        psf *= fftconvolve(relative_blur, im_deconv_mirror, mode='same')    
    return im_deconv

下一个动画分别展示了使用 RL 算法的非盲和盲版本的图像恢复。

参考文献:

  1. https://courses.cs.duke.edu/cps258/fall06/references/Nonnegative-iteration/Richardson-alg.pdf
  2. https://scikit-image.org/docs/dev/api/skimage.restoration.html#skimage.restoration.richardson_lucy
  3. https://arxiv.org/ftp/arxiv/papers/1206/1206.3594.pdf