home

blur

31/10/2022

A few weeks ago a friend of mine asked me how much we could remove blur on an image. I didn't really know what to respond at the time so I will try to give a few examples and results to answer this question.

Types of Blur

This initial question isn't as easy as it may seem because there exists quite a few different types of blur. For instance, if you try to take a picture of a car going fast, you might only be able to capture the blurry outlines of the car, but the perfectly clear landscape behind. This setting will be very different than if you shook your hand before taking the picture for example.

Dealing with Blurry Pictures

There is no Magic Formula to deal with any bluriness, but rather at least as many as there are blur types (16 at least in Photoshop [1] ). Therefore, the person analyzing the picture will have to determine what kind of deformation the image has and apply an appropriate algorithm, on either a portion or the whole picture. If we go back to our example of the car going too fast on the highway, the picture obtained by the police will probably be quite blurry. They could try and improve the whole image, or just the important part - the numberplate. Taking only a portion of the image will generally yield better results because the blur type will be closer of being uniform than if taking the whole car.

Landweber's Algorithm

In this section we consider a simple gaussian blur model, without any noise (A).

Blurry picture (A)

To deal with such a distortion, we use here a Landweber Iteration Algorithm [2] , but I won't bore you with the details. The only important part is that this algorithm works better the longer it runs. Here is a demonstration of it running for 200 iterations on image (A) that had a little blur (5x5 Uniform PSF).

Incremental deblurring of the image (B) - GIF

As you can see that even though this method leaves behind a few artifacts (the weird outline around the man), it yields pretty good results. Let us try with a higher blur (11x11 Uniform PSF) on image (C).

Blurrier picture (C)

And below is an attempt to deblur it, with 300 iterations.

Incremental deblurring of the image (D) - GIF

As you can see, the more important the blur, the more artifacts we generate and consequently the more information we lose (this is not necessarily true for all blur types).

Bonus

Here are a few nice images I obtained while my program had bugs.

Cursed waves (E)
Cursed animated waves (F) - GIF

Remember kids, it is a good idea to initialize your matrices after allocating memory in C 🤡.