Whether by wind, vibration, or shaky hand, we have all taken blurry photos. But in the digital era, there is no need to despair -- you can remove shake and blur from your pictures after the fact. Several Linux-friendly utilities can help you.
Deconvolution is the general process that helps remove the effects of camera shake and blur. If you want to understand the math behind the process, start with the articles referenced at Wikipedia and you can find as much detail as you want. In a nutshell, it involves taking the Fast Fourier Transform of the image (which makes it easier to see the tell-tale signs of blurring), smoothing out the artifacts, then transforming the image back into its original form. It is a CPU-intensive process, but for a shaky image there is no better use of your MHz.
The most straightforward way to get started is with Mark Cahill's Unshake, a small Java app with a lot of options that performs some helpful guesswork to speed things up. The latest release is 1.5, which requires Java 2 or greater. Unshake is closed source, and the license prevents use for commercial purposes.
You can unpack the distribution anywhere on your system and launch the app by running ./unlaunch.sh. The interface has controls at the top, a status window beneath them, and a clickable file selection widget at the very bottom. When you open a photo, you start by resizing the photo window to show just the portion of the image that you are most concerned about. This is a critical step, and one that the interface does not explain to you. If you choose the wrong portion of the image, Unshake could misidentify portions of it as blur and overdo the correction.
When the window is properly set, click on the Estimate button and Unshake will give its best guess as to how long the process will take. You can adjust the blur severity and correction quality parameters and get new estimates. To see the results, just click the DeBlur button. Unshake will perform the image correction and open the result in a new window, which you can then save.
Unshake attempts to determine on its own how much correction to apply. The actual processing time can vary greatly depending on what it decides. The Time control allows you to allot more or less time to Unshake's process. By default it is set to "x1" meaning that Unshake will perform its transformations within the Estimate time. You can turn the Time parameter all the way to "x100" if you want the algorithm to perform more detailed analysis.
At the default settings, 40 to 50 seconds is a reasonable estimate time for a 1.3 megapixel image. Cahill notes on the Unshake site that he has never seen the algorithm come close to the "x100" time allotment -- he just put it in as an upper bound to make sure the program exits.
The GIMP has two third-party plugins that do the same kind of correction as Unshake. Both are open source, although neither of them seems to be undergoing active development.
The first is Refocus, which is officially at version 0.9.0. That release is from 2003, though, and several other developers have released their own patches to bring Refocus compatibility up to modern versions of the GIMP. Richard Lemieux and Peter Heckert each maintain a page for their respective patched versions. Debian and Ubuntu include Lemieux's version as 0.9.1 in their package managers.
You start Refocus from within the GIMP, in Filters -> Enhance menu. The tool has five parameters and a preview window. It is not easy to explain the parameters without delving into deconvolution math, but you can play around with the settings. Roughly speaking, the Radius and Matrix Size controls determine how small a blur the algorithm will detect, and the Gauss, Correlation, and Noise controls affect the degree of smoothness and pixelization artifacts to allow.
In my tests, Refocus was drastically faster than Unshake, taking less than five seconds than to deblur an image that required 30 or 40 in the latter program. Of course, one of Unshake's selling points is that it performs its own automatic tweaking, thus producing higher-quality output.
The other helpful GIMP plugin is named Iterative Refocus (or refocus-it). Its last release was 2.0.0, in 2004, but unlike Refocus no one that I am aware of is putting effort into making sure it remains compatible with newer versions of the GIMP.
Fedora provides the plugin as the gimp-refocus-it package, but users of other distros will probably need to compile from source. Fortunately, this is simple. Make sure that you have the GIMP development libraries installed, then execute the old ./configure; make; make install three-step. On Ubuntu 7.10, I found that I needed to create the directories /usr/local/share/help/C and /usr/local/share/help/images. You could also attempt to alter the Makefile to correct for this problem, but creating the directories is faster.
Once installed, Iterative Refocus also shows up in the Filters -> Enhance menu. Iterative Refocus has more options than Refocus, including the ability to specify the direction and size of the motion blur in the image. Knowing this allows you to better correct for the blur's ill effects -- but of course it is rarely simple. The worst kind of motion blur is not in a straight line, it is multi-directional or circular. Still, if you can zoom in on the image and determine which direction and how far it stretches, you are that much closer to eliminating it.
As its name implies, this plugin makes multiple iterations, correcting a little bit more on each pass. As with the other settings, it is often subjective how many iterations improve the image, but you can get a good feel for the quality of the output using the Preview button on a few.
No silver bullet
If you watch the movies, you have probably seen the impossibly accurate "computer enhancement" hand-waving that turns a blurry mess into a crystal clear mug shot or license plate for the hero to chase. Real-world image enhancement is not that good, but you may still be surprised at the level of quality a good Fast Fourier Transform and deconvolution can produce.
All three of these applications produce admirable results. Refocus is the fastest, and subjectively Unshake produces the cleanest results. It is unfortunate that among the three alternatives, one is not free software and the other two lack active maintainership. But since the math is well understood, maybe someone will pick up where the other programmers left off, and bring even better refocusing technology to the image editors of tomorrow.