Using multiple exposures of a raw photo to get more detail

One of my main photographic interests is trains, and I like to be able to retrieve a lot of detail - the running gear beneath the body is often very dark. By using raw photos I can use a "correct" exposure, an overexposure to provide the dark parts, and a corresponding underexposure to provide the highlights and (mostly) balance things out. But I think this approach can also be useful for general views.

My aim is to simplify my preparation - I still have to sort out lens distortion, and rotation or perspective distortion when the camera is not held straight, but the process is now a little easier.

The following example pictures are end results, resized to 400 pixels tall. Each one links to a set of images at 900 pixels tall showing the camera's own jpeg, various raw exposures, the result of the plugin, and various corrective measures after that. These are not necessarily the best way to process each of these pictures, but the process seems to work reliably on my subjects as well as on general views.

If you are not aware, gimp-2.8 is the stable series, 2.9 is for development versions where things can change.

Revision details since I first uploaded this for gimp-2.8 :

  1. I discovered that my ufraw setup was wrong - I had copied it to a different machine to work in gimp-2.8 whilst I experimented with gimp-2.9 on the original machine, and along the way I had managed to pick up an old curve in ufraw, instead of the default straight line from bottom left to top right. That boosted some darker tones, and in some cases I used different exposures because of that.
  2. I only had this working for gimp-2.8. Now it is working in 2.9 and to prove that I've used 2.9 for some of these examples (Alpacas, Banyuls, Train Jaune).
  3. On the original I used G'Mic Tone Mapping in the mistaken belief it was like the old Advanced Tone Mapping plugin : it is more like a sharpener. Now I've gone back to the old Advanced Tone Mapping plugin except for the Banyuls pics where I forgot (and since doing those I've updated to a newer version of gimp-2.9) : in current 2.9 this plugin will produce some messages, but for the moment they are harmless.
  4. In my latest testing I used a gimp-2.9 version from 2017-08-14 for the Le Train Jaune pics. (gimp-2.9.6 has now been released, some brief testing on other pictures shows my plugin still works.) To my chagrin, ufraw's plugin is no longer recognised as a valid way of opening my RAW photos (fair enough, I suppose, it is no longer maintained, and I haven't yet looked at why gimp will no-longer use it). As an alternative I compiled RawTherapee and used it for these examples - but I'm not comfortable with it and I'm not sure if I've managed to "neutralise" all its default settings. I'll need to find the time to experiment with Photoflow and darktable.

More details are below the set of pictures.

Examples

Alpacas Banyuls
Alpacas near Eynsham Banyuls harbour
Alpacas Banyuls
Palü Glacier A street in Waidhofen an der Ybbs
Palü Glacier Waidhofen/Ybbs
RhB coach A1275 at Poschiavo Peldon at the Amberley Museum
Alpacas Banyuls
Taliesin at Minfordd Le Train Jaune

Summary of the process

This is for raw photos except those from foveon sensors (which create 'x3f' files, used in Sigma cameras) - for those, Kalpanika/x3f appears to be the only way to use such images on linux or BSD. I've no idea if that can be used with the gimp.

  1. Using a suitable tool (for 2.8 I use ufraw, for current 2.9 see my comments in item 4 of the revision details above), select a "base" exposure which you think is "correct", an overexposure to get shadow detail (typically +2EV, but +1EV if not much contrast, or +3EV in a few awkward photos), and a corresponding underexposure for the highlights. Save each of these as an xcf file (or, from ufraw batch, an 8-bit png file). The non-batch viewer in ufraw can indicate overexposure, and I set it to restore in HSV space for sharp details on negative EV, and to soft film-like clipping for positive EV.
  2. Open the base exposure, then use 'Filters -> Three Exposures' and specify the files for the shadow and highlight images. The shadow image is added as a second layer, duplicated, desaturated and inverted to form a mask (i.e. the darker something is in the shadow layer, the more it wil be used). The highlight image is added above this and similarly processed, except the mask is not inverted (so whatever is bright in the highlight layer will be used). Then the layers are merged.
  3. Often, the result can be hard to view (loss of contrast). I now use the G'MIC plugins (G'MIC-GTK in v2) and from that I use Local contrast enhancement. Previously I used to use Gimp's contrast tool.
  4. At this point I make corrections (lens distortion, rotation, perspective, clipping) to make the best of a bad job (sigh! ALL modern digital cameras seem to give barrel distortion on wide-angle lenses, and bridge cameras may give pincushion distortion at longer focal lengths).
  5. I now apply the Advanced Tone Mapping plugin : In gimp-2.9 this currently produces a number of messages about deprecated functions, but for the moment it still works. This plugin adds an extra layer, which you will need to merge down. In the previous version of this page I had wrongly used the G'MIC Tone Mapping, or occasionally Tone Enhancement, filters, but what those actually do is apply some sharpening. The Advanced Tone Mapping filter tends to lighten some parts of the image, but mostly it is benign and overall it doesn't do a lot at the default settings.
  6. The picture is probably still slightly lacking contrast. If I'm going to put it online, I usually want to add some more contrast, at the expense of a little of the recovered shadow detail. For that I use the Curves tool: click on points at 25% and 75% of the way along the line, pull the 25% point down (parallel to the line) and the 75% point up. Undo then redo to see the effect, then probably undo again and have another go - the curve does not usually need to deviate far from the central line.
  7. Finally, sharpen it. I mostly use the Unsharp Mask. For this, zooming in to full-size to check the results is essential. In G'MIC there are a lot of other sharpening filters. Historically I have tended to over-sharpen, I'm now trying to get away from that, but no promises.

When used with gimp-2.8, I usually get a small rectangle appearing at the top left of the image after using three-exposures. This is not actually in the iamge, saving or undo/redo will refresh the display. With gimp-2.9 the display does not update after running three-exposures: again, either save or undo/redo to force it to update. I think I've see a similar issue with Advanced Tone Mapping in 2.9.

Limitations

  1. It reduces contrast, so you then have to take steps to restore that.
  2. Colours will not be accurate - see the pictures of Peldon which is a dark green diesel locomotive, but tends to become lighter.
  3. The process will not recover all of the shadow detail, and highlights might still be a bit blown.
  4. Using significant underexposure for the highlights may produce image noise - see the sky in the Alpaca pictures (iso400 ±3 stops on a bridge camera). However, photos using ±3 stops taken on my Olympus, even some at iso400, seem OK.

The plugin

A lot of the gimp's internals have changed in 2.9, so use the correct version of the plugin (last tested with 2.8.22 and 2.9.6).

The 2.8 plugin is here: 2.8 plugin.

And the 2.9 plugin is here: 2.9 plugin.

Ken Moffat, 2017-09-02. E&OE