A Status on the Gimp plugin "refocus"
Richard Lemieux

Ernst Lippe is the author of "refocus". Here is an excerpt from the author's description.

Refocus is a plug-in for the Gimp (the GNU Image Manipulation Program). This plug-in attempts to "refocus" the image, using a technique called FIR Wiener filtering. The traditional technique for sharpening images is to use unsharp masking. Refocus generally produces better results than unsharp masking.

Ernst Lippe [refocus.sourceforge.net]

I saw in log files that a number people attempted to publish patches on the sourceforge site, but for some reason the patch code does not appear to be available from sourceforge. There was a message that mentioned the problem I am providing a patch for, but I couldn't find the patch code.

Peter Heckert has adapted the plugin to work with gimp-2.2, and it also works with gimp-2.4. Peter's version of refocus is available from hphsite.de/refocus.

As I started using the "refocus" plugin on raw files from the Powershot A620, the plugin crashed. I figured out that the plugin crashed only for pictures of some peculiar sizes and not for picture of more typical sizes. I found the error in the source code and I publish here a patch to be applied to Peter Heckert's source.

I didn't find a way yet to update either the sourceforge site or the gimp plugin site so I resort to publish my path here.

Installation of "refocus" with my patch

  1. Download file refocus-0.9.0-gimp-2.2.tar.gz.
  2. Download the patch file refocus-0.9.0-gimp-2.2_rlx.diff.
  3. Extract the code and apply the patch as follows,
  4.     tar xvzf refocus-0.9.0-gimp-2.2.tar.gz
        cd   refocus-0.9.0-gimp-2.2/;
        patch -Np1 < ../refocus-0.9.0-gimp-2.2_rlx.diff
        gimptool --install-bin src/refocus 
        # That's it.


I renamed the refocus code with my patches applied as "refocus-0.9.1", and I uploaded the tar file to the Gimp plugin registry.


Martin Egger is the author of SmartSharpen and he agreed to modify his script to use "refocus" as well as "unsharp mask". Martin's script can be downloaded from Plug-In: Smart Sharpen (Redux). Use the following command to install Martin's script. Then to use the script, open menu "Script-Fu/Eg".

    gimptool --install-script Eg-SmartSharpen-refocus.scm

Typical use

I typically use the plugin with the default parameters. I would increase the noise factor if I find that the plugin amplifies the noise too much. Otherwise, if I am working on a raw picture and the finished picture won't be scaled down, I might increase the radius to 1.3 or 1.5 to account for the alternance of colored pixels on the raw data (the real pixels are larger than implied).

If I am working with a raw picture that I want to downsize, I will apply the refocus plugin once on the raw picture (after any rotation) and before downsizing. Then I would apply the refocus plugin a second time just before saving the result.

I know that it is difficult to justify applying refocus before downsizing if refocus is to be applied later anyway, but I feel that the result is sharper when I do it that way than when I use refocus just once at the end.