Deconvolve - how to specify the kernel

Hi, I’d like to remove motion blur. For that I need to specify a kernel which amounts to a Dirac distribution with support on a 1-D interval (in 2-D). How can this be done?

Many thanks for a hint,
Helmut

1 Like

Hello Helmut,

There is a (still experimental) command to deconvolve an image with a PSF given as an argument.
Command -deconvolve_goldmeinel should do the trick for you :

  $ gmic -h deconvolve_goldmeinel
    gmic: GREYC's Magic for Image Computing. 

    Version 1.7.0 (pre-release #021916), Copyright (c) 2008-2016, David Tschumperle. 
    (http://gmic.eu)

-deconvolve_goldmeinel:
                    filter,nb_iter>=1,acceleration>=0

    Deblur and zoom selected images using Gold-Meinel algorithm
    
    Default values: 'nb_iter=8', 'acceleration=1' and 'kernel_type=1'.
    
    Example: image.jpg 100%,100% -gaussian[-1] 5,1,45 \
               --convolve_fft[0] [1] --deconvolve_goldmeinel[-1] [2],5

Now, here is a simple example that takes an image, convolve it with an oriented gaussian kernel, and deconvolve it afterwards, using the -deconvolve_goldmeinel command :

$ gmic -testimage2d 512 100%,100% -gaussian. 5,0.7,20 -convolve_fft[0] [1] --deconvolve_goldmeinel[0] [1],30

That is what I get on the output (left image is the blurred one, middle image is the kernel and right image is the deconvolved one) :

It seems that the kernel must have the same size as the input image to make it work correctly right now. This is maybe something we can fix in the future.
Note also that this command is only available if you updated your command list from internet :

$ gmic -update

The command has been coded by Jérome Boulanger and thus is in his own repository.
Let us know if you succeed in doing something with it !

Many thanks, David.

Since I don’t have any experience with stand-alone G’MIC, I have two questions:

1.) What’s the syntax of the -gaussian option and is there a dot after -gaussian option?
2.) A mathematical question:
A motion blurred image can be describe by a convolution integral where the kernel is concentrated on a 1-d interval with a given direction (which can be estimated with Gimp’s measure tool) and a given length (= speed of movement times the shutter speed). The corresponding Dirac-like kernel could be approximated by a very anisotropic Gaussian kernel. What approximation would you suggest?

Many thanks for you help,
Helmut

Hello,
I found this conversation with you, @David_Tschumperl, from 5 years ago. I also have the need to do deconvolution with an original blurred image and a PSF extracted from that image. I have some questions:

  1. Is deconvolve_goldmeinel in command line GMIC the same as Details > Sharpen (Gold-Meinel) in the GIMP plug-in?
  2. If I have to use the command line GMIC , I don’t understand how to pass the parameters to it, it always gives me an error. Also, I only see an image in the commnad, I need to pass two images: blurred and PSF.
    Could you help me?
    Thanks

Hi @fjcaba

I will try to answer, but I’m not the expert on this function:

  1. No - I think that’s a straight deconvolve with a gaussian kernel
  2. It works well for me with version 3.0.1 like this:
gmic image.png kernel.png resize. [0],[0],100%,100%,0,0,0.5,0.5 deconvolve_goldmeinel.. .,30

The resize is to ensure the kernel is the same size as the image. I hope that helps!

Thanks for your answer @garagecoder. I tried your statement and didn’t get a good image. What is the meaning of each parameter?

Another problem could be the PSF itself: my PSFs are synthetic; starting from an astrophoto, and taking as reference numerous small stars that are supposed to be luminous points distorted by the lenses and the atmosphere, I calculate fmhwx, fmhwy and angle (first software). With these data I build a synthetic PSF with a second software assuming that it is a circular and Gaussian deformation.

It’s probably going to take some careful tweaking to get the best from it. Sadly, I’m not able to help with that or any deeper understanding of the algorithm.

You can get the parameters of any stdlib command (and some others) with the help, e.g. gmic h deconvolve_goldmeinel. My guess is the kernel is most important, but you’ll need to change the number of iterations as well.