← Back to Writing

Can you recover a blurred image?

What reverse convolution can recover — and the information it still needs.

  • julia
  • imaging
  • convolution
  • linear-algebra
Ler em português

An edited republication of my original Medium article, published in 2020.

Can a blurred image be recovered? Usually, blur discards useful information. But when the blur operation, boundary treatment and output dimensions are all known, convolution can be written as a linear system and, in a controlled case, inverted.

An animation showing convolution as a filter moving over an image

Convolution illustration by vdumoulin/conv_arithmetic, as credited in the original article.

Convolution as a linear system

For an image x, kernel k and output y, convolution can be represented as A · x = y. A is determined by the kernel and padding rule. If convolution makes the output smaller than the input, the system is underdetermined and there is no unique original image.

With suitable padding, an odd-sized kernel and a same-size output, A can be square. When it is invertible, the original can be calculated from x = A⁻¹ · y.

The same-size convolution system represented as a square matrix

The Julia experiment

I implemented this in Julia and Pluto using a Gaussian blur with replicate padding. Knowing the exact kernel and padding, I built A and recovered the original from the blurred result alone. In that controlled setup, the reconstruction is exact.

Original image and Gaussian-blurred image

Original and blurred image.

Blurred image and exact reconstruction

Blurred image and reconstruction using the known kernel and padding.

This is not a general-purpose deblurring technique. A slightly different kernel leaves blur and artefacts; the wrong padding can make the result unusable. The matrix also grows rapidly with image size. It is a useful experiment in convolutions, linear algebra and image processing, rather than a way to recover arbitrary blurred photographs.

Reconstruction with an incorrect kernel

Using an incorrect kernel leaves blur and artefacts.

The reverse-convolution repository contains the notebook. The original article includes the worked visual examples and fuller derivation.