If the lenses in a camera are not set correctly, the intended subject will be "out of focus" in the resulting image. There seems to be no loss of information here. The photons are just steered to the wrong CCD element. If we knew the exact specification and configuration of the lenses, would it be possible to apply a tranform on the image to see the subject in focus?

Sharpening filters are often used to improve "out of focus" images, but I suspect a much better result could be possible if the physics of the optics were considered.

  • 1
    $\begingroup$ Google Deconvolution. For example, see olympusmicro.com/primer/digitalimaging/deconvolution/…. Deconvolution can correct focus errors and other defects. $\endgroup$
    – mmesser314
    Jun 2, 2015 at 5:00
  • 8
    $\begingroup$ Starting to read up on deconvolution. That is a deep rabbit hole. $\endgroup$ Jun 2, 2015 at 5:29
  • 2
    $\begingroup$ You might want to look in to the Hubble space telescope mirror, which was incorrectly grounded but could initially be corrected with software (and eventually with a second correcting mirror) $\endgroup$
    – Sanchises
    Jun 2, 2015 at 10:43
  • 2
    $\begingroup$ possible duplicate of On unfocused images, their information content and possible restoration $\endgroup$
    – Adam Davis
    Jun 2, 2015 at 14:48
  • 3
    $\begingroup$ While standing behind someone else using your computer, just say "Enhance!" $\endgroup$
    – Roger
    Jun 2, 2015 at 23:19

3 Answers 3


Unfortunately there is a loss of information for physical images i.e. images with finite signal to noise ratio per pixel. An out of focus lens acts like a linear transformation, i.e. a matrix between the focused ideal image and the actual image. To reverse that transformation we have to calculate the inverse of the matrix. Depending on the severity of the blurring that inverse may not exist or it may, if it exists, amplify noise and sampling errors in the resulting image very strongly. Imagine the worst case blurring matrix of a two pixel image:


This matrix is singular and can not be inverted at all.

Take a less severe case (20% blurring), now the matrix is


and the inverse of that is:


There are two problems with this one: because of negative coefficients in the inverse you may end up with negative pixel values in the reconstructed image, which is unphysical. Secondly the diagonal elements are larger than one, which amplifies noise.

Having said that, one can achieve remarkable results if the resulting image has a very high signal to noise ratio and if the inverse transformation can be reconstructed with high precision.

If you are interested in this area I would urge you to do your own experiments with a few matrices to get a feel for what's going on. Ideally image blurring is a local phenomenon, i.e. we can restrict ourselves to areas of an image that are only a few (maybe 2-5) pixels wide. This reduces the problem to small matrices. Wolfram Alpha can do the matrix inversion for you, so you don't have to set up any math package (although numpy is easy to use, if you know Python).

As for the experimental side of it, the proper way to calibrate a lens requires to produce a series of high contrast test images of either pinholes (delta functions) to retrieve the blurring matrix directly or, even better, to use high frequency stripe patterns to measure the blurring in the Fourier domain.

  • 2
    $\begingroup$ Comprehensive answer! I will take your suggestion and try out some matrix operations with my friend Python. $\endgroup$ Jun 2, 2015 at 5:34
  • 1
    $\begingroup$ Nice answer - though strictly speaking, shouldn't you have a Tensor acting on the matrix of pixels? (Which one could of course re-shape into a matrix acting on the row-aligned pixels) $\endgroup$ Jun 2, 2015 at 9:32
  • 1
    $\begingroup$ I'm not that familiar with optics, spread point functions, etc. but have worked with optical engineers who have explained the inverse focusing problem in a similar way. I agree - good explanation and examples. But also something clicked in my head. Is there an analogous behavior in quantum mechanical (inverting Heisenberg matrices) systems that connects to uncertainty? $\endgroup$
    – docscience
    Jun 2, 2015 at 12:54
  • 1
    $\begingroup$ I should have added - we were working on an adaptive optics problem to improve image quality. We used a laser to measure an atmospheric transfer function, and applied its inverse to a segmented mirror. Not perfectly refocused, however improved. $\endgroup$
    – docscience
    Jun 2, 2015 at 12:57
  • 3
    $\begingroup$ @DnaielSank: Even in mathematics it depends on the linear transformation. A singular matrix loses information even in the ideal case. I pointed that out in my post. I did, however, reformulate the first sentence. If you still don't like it, you are free to make a concrete suggestion to make the post better? $\endgroup$
    – CuriousOne
    Jun 2, 2015 at 17:20

Unfocussing is convolving the image with a low-pass filter (that's what the optical system does to the source signal here). If high-frequencies are distroyed, you can't expect to recover them by simple algebra, since it would mean dividing by zero in the spectral domain. (filter high freqs are zero in real world, because the gaussian or the Bessel tails would be to low to make 1 bit of grey level).

Still, nowadays there are solutions to that, how unintuitive they can be. They consist in using purposely made "bad lenses" so that the Fourier transform of the "bluring filter" contains the high frequencies - and indeed, be dense in the Fourier domain - , so that you can invert them (i.e. process a "unconvolving"). Keyword is "coded aperture", and applies to many similar cases (depth of field, motion blur, etc). Several papers of the MIT graphics group developped this.

Appart from this: Note also than under some regularising hypothesis, you can sometime also recover the high frequencies if you have multiple images (with varying view angles). This is basically how tomography works.


This should help: http://yuzhikov.com/articles/BlurredImagesRestoration1.htm

He is able to calculate/approximate the kernel and there is code to implement it as well which could be translated into Python.

A more precise deconvolution, 'blind deconvolution' is achieved using an iteratively tuned method with a Wiener filter that is used to take into account the randomness of noise in the image.

  • 6
    $\begingroup$ Welcome to Physics! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. $\endgroup$
    – Kyle Kanos
    Jun 2, 2015 at 15:46
  • $\begingroup$ Be extremely careful with this link/program. As pointed out by @fabrice-neyret above, once you loose the high frequency detail, there no way to regain, unless using some artificial guess method (AI). The presented images scare me and his github page is unreachable. $\endgroup$
    – jaromrax
    Aug 13, 2023 at 15:46

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .