<p>Here is how you can implement blind deconvolution in python with the <strong>Richardson Lucy</strong> algorithm:</p>
<p>Iterative updation steps for <strong>Blind Deblurring</strong> (as proposed in <a href="https://i.stack.imgur.com/a6I9t.png" rel="nofollow noreferrer">2</a>, <a href="https://arxiv.org/ftp/arxiv/papers/1206/1206.3594.pdf" rel="nofollow noreferrer">4</a>), with <strong>unknown</strong> PSF H, corrupted image <strong>X</strong> and restored image <strong>S</strong> are shown in the below equation:</p>
<p><a href="https://i.stack.imgur.com/a6I9t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a6I9t.png" alt="enter image description here" /></a></p>
<p>The following code shows my implementation of the iterative Bayesian blind deconvolution algorithm proposed in <a href="https://i.stack.imgur.com/h2SuP.gif" rel="nofollow noreferrer">1</a>, mostly with frequency domain operations (as opposed to spatial domain implementation as in <a href="https://scikit-image.org/docs/dev/api/skimage.restoration.html#skimage.restoration.richardson_lucy" rel="nofollow noreferrer">3</a>). It is similar to the non-blind implementation as in <a href="https://scikit-image.org/docs/dev/api/skimage.restoration.html#skimage.restoration.richardson_lucy" rel="nofollow noreferrer">3</a>, only we need to estimate the unknown blur PSF at each iteration (starting with a random PSF), assumed to be known in <a href="https://scikit-image.org/docs/dev/api/skimage.restoration.html#skimage.restoration.richardson_lucy" rel="nofollow noreferrer">3</a>.</p>
<pre><code>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
</code></pre>
<p>The next animation shows image restoration with non-blind and blind versions of the RL algorithm, respectively.</p>
<p><a href="https://i.stack.imgur.com/h2SuP.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h2SuP.gif" alt="enter image description here" /></a>
<strong>References:</strong></p>
<ol>
<li><a href="https://courses.cs.duke.edu/cps258/fall06/references/Nonnegative-iteration/Richardson-alg.pdf" rel="nofollow noreferrer">https://courses.cs.duke.edu/cps258/fall06/references/Nonnegative-iteration/Richardson-alg.pdf</a></li>
<li><a href="https://scikit-image.org/docs/dev/api/skimage.restoration.html#skimage.restoration.richardson_lucy" rel="nofollow noreferrer">https://scikit-image.org/docs/dev/api/skimage.restoration.html#skimage.restoration.richardson_lucy</a></li>
<li><a href="https://arxiv.org/ftp/arxiv/papers/1206/1206.3594.pdf" rel="nofollow noreferrer">https://arxiv.org/ftp/arxiv/papers/1206/1206.3594.pdf</a></li>
</ol>
Is there a function in Python similar to Matlab's deconvblind?
<p>I'm working on blind deconvoltuion.</p>
<p>In iterating L2norm reguralization, I want to update the PSF at the same time, and when I looked it up, I found a function called <a href="https://www.mathworks.com/help/images/ref/deconvblind.html" rel="nofollow noreferrer"><code>deconvblind</code></a> in Matlab:</p>
<blockquote>
<p>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.</p>
</blockquote>
<p>Is there a function similar to <code>deconvblind</code> in Python?</p>