DNGMonochrome: deblurring filter          
    Turning Leica DNGs...          
   ... into monochrome DNGs !          
    DEBLURRING FILTER          
 

Deblurring through Wiener filtering is a well known method. The challenge on a technical level was combining it with Fast Fourier Transform: keeping it fast enough and keeping the memory demands within acceptable levels.

But to be honest, I have my doubts about the usefulness of this new filter. It was interesting from a development perspective - adding some new knowledge for my own benefit - but I do doubt the practicality of it, seeing that on larger blur the result is still kinda frustrating. Yes, you may achieve a less blury photo, but the artifacts that come along with it may not be worth your trouble.

The artifacts arrise from the fact that Wiener filtering is far from perfect. It's notorious for the amplification of noise and edge ringing. But let me first explain the proper steps and what can be done about the distortions.


Getting there

After processing a color DNG, click the 'Noise reduction and deblurring' button under the 'Tools' heading. Then click the 'Deblur' button under the main image.


The grid

You'll be presented with an emtpy grid. Under the grid you'll see several buttons, and to the right of the grid three sliders. The grid is used to create a so called 'kernel', which is basically an image that will function as the actual filter (after transformation of photo and image through Fast Fourier Transform). You can create this image by clicking in the grid, turning on or off the squares. Click once to turn a square on (it will color green), click on it again to turn it off. Observe what's happening to your photo after turning on a square. This free clicking to create an image can only be done if the grid is in the 'Free grid' mode (see next paragraph about the buttons).


The buttons

The buttons under the grid enable you to select two types of deblurring: motion deblur and focus deblur.

For motion deblur you can use the first two buttons: 'free grid' and 'line'. In the 'free grid' mode you can click anywhere in the grid to turn squares on or off. Through the second button (the line mode), you can create a kernel with one single line by clicking in the grid (except by clicking in the middle of the grid, indicated by the dark blue square).

For focus deblur, you click on the third button. The grid will show you a small cross in a light blue color. This is in fact the beginning of a cilinder circle, you can extend with the slider next to the focus deblur button. Slide to the right to increase the radius of the circle. You can also click in the grid to place the circle off center. Click on the 'pin' button to center the circle again.

Then there are two buttons to zoom in and out on the grid, since the initital visible portion of the grid is actually only a small part of a much larger grid.

The row ends with two buttons to reset the sliders and empty the grid (or set it back to the initial focus circle when in focus deblurring mode).


Fighting distortions

To battle the noise and the distortion this type of filtering can create, the kernel (the image you make by clicking in the grid) is combined with a low pass filter, basically cutting off the highest frequencies. That's the first slider under 'reduce artifacts'. It's a rather crude but effective way of eliminating a lot of the nastier effects when trying to deblur. However, it also leads to a more fuzzy image. You can think of this slider as a very strong form of noise reduction.

The second slider is the Masking slider. This is quite a powerful tool to eliminate distortions, since it will focus the attention of the deblurring to the edges of the subject. However, in the darker / shadow parts of the photo you might lose the deblurring benefit.

The Localization option will also reduce some of the artifacts, but is mainly useful if the blur is just a few pixels wide. It will look at the original image and try to keep the pixel under consideration within the limits of a locally bound area around the original pixel. In a way it's also a form of masking. As a consequence, on more extensive blur, this option will counter-act your deblurring attempts, since that local area might be too much part of the blur you are trying to correct.


Some other remarks

Technically this method is applied to the DNG in overlapping tiles. It's the only way to keep it as fast as possible and within RAM memory, without having to resort to memory mapped files on hard disk (which work, but are a big slow down). This tiling works in most cases without problems. However, when you leave in too much distortion (not correcting through the sliders), you might start to see the edges of the tiles. At the same time, when that happens, your photo will look absolutly horrendous anyway, so I didn't bother with this problem.

Deblurring this way is not a one-click method and it will take some time per photo for the best results. It works best if the blur isn't too extensive (within a few pixels) and you'll have to experiment per photo on what the best kernel is for the specific photo.

Also first try if you can get acceptable results - but a lot quicker - by sharpening. The effects are not the same, but with small blur and turning the DNG into a smaller JPG, sharpening might be enough.

Keep in mind that deblurring software is usually run on the JPG end product, on a smaller image, covering up a lot of the distortions you might see when this is done on a full scale DNG. When turning the deblurred DNG into a smaller JPG, some of the distortions will drop away. And some of them can still be tackled in your RAW converter (e.g. through noise reduction or a clarity slider).

Time wise on an Intel i5 processor:

- deblurring a Canon 40D DNG (10mp): 35 seconds.
- deblurring an M9 DNG (18mp): 50 seconds.
- deblurring a Canon 5D Mark III DNG (24mp): 75 seconds.
- deblurring an M (Typ 240) DNG (24mp): 75 seconds.
- deblurring a Nikon D800 DNG (36mp): 115 seconds.



Click here to go back to the main page.

See also the blog