My friend came back from holidays, where he took lots of pictures. Unfortunately, the camera was set on manual focus and most pictures are blurry. It got me thinking that mathematica showed how to deblur the images ImageDeconvolve[] documentation and remembered how the original image can be reconstructed. In principle we only need to find the kernel for the lens.

So the challenge: can we find kernel guessing method that produces sharpest images? I am providing 3 images to play with.

1) Perfect image with GaussianMatrix[] blur (I'm not telling you the parameters) (high resolution link)

Gaussian matrix convolution

2) Perfect image with unknown kernel blur (high resolution link)

secret kernel blur

3) An actual picture from my friend's holidays (high resolution link, raw)

real image with lens blur

Also there was an old discussion on this thread that did not get anywhere.

  • 2
    $\begingroup$ You will be better off, and get it done more easily, using software that is designed for this purpose (e.g. smartdeblur) - some are (or have earlier versions) free/open source. Don't expect miracles whatever the means - were it that simple, they'd never have needed to fit the Hubble with contacts.... $\endgroup$
    – ciao
    Sep 21, 2015 at 21:51
  • 5
    $\begingroup$ Also previously: How to enhance a fuzzy image $\endgroup$
    – user484
    Sep 21, 2015 at 21:54
  • 1
    $\begingroup$ You can "improve" the blurred Lena image — call it lenablurred — with something as simple as Manipulate[Sharpen[lenablurred, r], {r, Range[1, 20], ControlType -> Slider}]. $\endgroup$ Sep 21, 2015 at 22:56
  • 3
    $\begingroup$ This problem is called "blind deconvolution", and there is an entire literature about it, which I recommend you read. It is too much to expect an answer in this forum to conclusively solve a problem to which extensive research effort has been dedicated over many years. $\endgroup$ Sep 21, 2015 at 23:27
  • 1
    $\begingroup$ Note the Wolfram Blog post on astronomy deconvolution, which does a little bit of kernel estimation. $\endgroup$ Sep 22, 2015 at 7:56

1 Answer 1


As mentioned in a comment by ciao, blind deconvolution is no easy task.

However, here are some pointers for estimating the kernel parameters. These can equally be applied to denoising an image rather than deblurring.

I am assuming that the form of the kernel is known here, rather than blind deconvolution (Wikipedia) methods such as Maximum A Posteriori (MAP). For that scenario, here's a neat paper on the use of blind deconvolution in astronomy for further interest.

Anyway, in order to estimate the best deconvolution parameters, you need to have a metric that defines how close the result is to the original. A common choice is to minimize the mean-squared error (MSE),

$$\underset{\theta}{\min} \enspace \frac{1}{N}\left \| X - f_{\theta }\left ( X \right ) \right \|_{2}^{2}$$

where $X$ is your original image and $f_{\theta }\left ( X \right )$ is your deconvolution function with parameter(s) $\theta$.

The MSE is useful because you can replace it with an estimator such as Stein's unbiased risk estimate (SURE), which means you no longer need to know the original image in order to estimate the convolution parameters.

I'll leave the implementation of SURE as an exercise for now as I'm rather busy, but a very good starting point is this paper on deconvolution in 3D fluorescence microscopy, which uses Tikhonov regularization.

Now as an example using ImageDeconvolve[] in Mathematica, apply a Gaussian blur and see how the MSE between the original and the deconvolved image changes with the deconvolution parameter, in this case simply the width of the Gaussian kernel.

image = ImageAdjust@ImageResize[ExampleData[{"TestImage", "Man"}], 256];
blurredImage = ImageConvolve[image, GaussianMatrix[5]];

imageBlurMSE[im1_, im2_, ker_] := ImageDistance[
      ImageAdjust@ImageDeconvolve[im2, ker, Method -> "RichardsonLucy"], 
      DistanceFunction -> "MeanSquaredEuclideanDistance"]

ListLogPlot@Table[{i, imageBlurMSE[image, blurredImage, GaussianMatrix[i]]}, {i, 1, 10, 0.1}]

enter image description here

This puts the minima somewhere around 4.5 (compared to the original value of 5), which isn't bad. But what does the resulting image look like?

enter image description here

Oh dear...although the parameter estimate wasn't bad, the result doesn't look great! Herein lie the perils of deconvolution algorithms. It also perhaps highlights the difference between using MSE as a metric for image similarity compared to actual human perception.

Incidentally, here is the MSE result when the image is convolved/deconvolved with a kernel of DiskMatrix[5] rather than a Gaussian kernel as above. Again the parameter estimation is decent, giving an estimate of 4.9 compared to the original value of 5, but the end image doesn't look any good.

enter image description here


Not the answer you're looking for? Browse other questions tagged or ask your own question.