Automatic Exposure Blending with Enfuse (HDR-ish)

I say HDR-ish because there is not a true HDRi being created, but rather a final output image is being blended together from multiple exposures (using a fancy algorithm and what I suspect is some magical kung-fu).

First, though, a quick recap. I talked about creating HDRi's in my previous post about doing it entirely with F/OSS tools. The intention there was to create a single HDRi scene that contained more luminance data than could be captured with any camera in a single shot. The problem was, you had no means of visualizing this high range of data.


So to squeeze the large range of light values into something you can see, we have to rely on Tone Mapping Operators (TMO's) to compress the range of values down to something we can see. There are quite a few different methods for doing this, which led to all the results in my previous post:


My results from using all the different TMO's in +Luminance HDR 

In each of these cases, the first step was to create an HDRi, then to feed that through a TMO to produce the result (and tweak as necessary).

Remember - the goal was to produce an image that could represent a large dynamic range of information into a smaller range that we can see.

In that article, I neglected to mention another method for achieving the same result - exposure blending.

At its simplest, an exposure-blended image could just be two exposures. For instance, one to capture the dark areas nicely exposed, with another exposed for light areas. The basic idea is to bring both of those images into GIMP, then use layer masks to blend them together where you can choose the best exposed parts for the final output manually.

This is actually a great method for total control of your final result. I personally have used this method often to great results. Of course, I take advantage of things like luminosity masks to help me quickly/easily mask areas of an image.

The problem is that it gets unwieldy very fast as the number of exposures goes up. (Image trying to manually blend the exposures from 7 different images - yikes!).

So I just go ahead and cheat a little by using Enfuse (included as part of Hugin) to automatically blend the different exposures together for me! (Some of you may remember Enfuse from my previous post about using it to focus-stack a series of macro images to increase depth-of-field). For reference, I'm re-using the images from my earlier HDR tutorial. Here are those images:


The base exposure, 1160 s, 0EV


180 second, +1EV (left), 140 second, +2EV (right)


1320, -1EV (left), 1640, -2EV (right)

Enough talk. Get all your JPG's in a directory, open a command prompt there, and:

enfuse *.jpg
Impressive, right? Wait a bit, and when it's done you'll have a file a.tif in that directory. Here's my output from the above images:


Compared to all of the previous results from the different TMO's in LuminanceHDR, this is a fantastic result, I think! No weird halos or colors, and I can get detail just about everywhere in the resulting image. This would make a great base image to start with if I wanted to do any further processing. As a bonus, it was fast (wayyyy faster than creating an HDRi and then tonemapping it).

There's another neat trick you can use as well. If you wanted to tweak the results you can have enfuse also save the masks it used to generate the results:

enfuse --save-masks=%f-softmask.png *.jpg
This will generate the mask used (named FILE-softmask.png) for each of the input files. Now you can load up your original images in GIMP, and add layer masks with these masks for further tweaking and adjustment. Couldn't be simpler!

I would highly recommend you keep this in mind as part of your toolset for blending images with high dynamic ranges. It usually produces very realistic and well-blended images much faster and easier than going through all of the steps for creating an HDRi.

5 comments:

  1. Great tip. I have played with Luminance a few times and all the options are dizzying. Your article on that product was good too. Enfuse seems to do a pretty good job with minimal fuss. Since I usually just want to have a uniformly well exposed image, it sounds like just the ticket for the majority of my needs.

    ReplyDelete
  2. I've been devouring your articles, thanks so much for the help. I do most of my processing in darktable and I exported a few images as .jpg but when I run the enfuse command I get the following:

    enfuse: info: input image "DSC_0023.jpg" does not have an alpha channel;
    enfuse: info: assuming all pixels should contribute to the final image
    enfuse: info: input image "DSC_0024.jpg" does not have an alpha channel;
    enfuse: info: assuming all pixels should contribute to the final image

    enfuse: input image "DSC_0024.jpg"
    enfuse: has ICC profile "sRGB - Darktable sRGB", but previous images have ICC profile "sRGB - Darktable sRGB"
    enfuse: warning: blending images with different color spaces
    enfuse: warning: may have unexpected results
    enfuse: info: input image "DSC_0026.jpg" does not have an alpha channel;
    enfuse: info: assuming all pixels should contribute to the final image

    I'm not sure what I'm doing wrong. The images are unedited so I'm basically using darktable to convert to .jpg.

    ReplyDelete
    Replies
    1. You're welcome!

      Are you getting any output at all? It looks like enfuse is just printing warning/info messages - not sure it should cause it to fail. If it is failing, is there any way to get a copy of your .jpg output to use as a test?

      Delete
    2. David, I didn't publish your last comment in case you didn't want everyone to have access to your files. I did take a look at them, and the results seem to be ok (relatively).

      First, you can ignore the warnings and info on colorspace and alpha that you see, those are just informational.

      The result wasn't so bad. A little dark, but that may be due to the fact that the treeline in all of your images were silhouettes for the most exposures, with only a single exposure having any detail there at all. If it were me, I might consider outputting the masks with the files and doing further manipulations in GIMP to emphasize the details in those shadows.

      Delete
  3. Thanks. It's as I expected. Thankfully, I know a place on the web that has some great tutorials on getting around in GIMP.
    Initially I wondered if the mediocre outcome was related to warnings so I tried a different batch and got the same result. I'm willing to accept the the originals were the cause as they were the first time I tried a sunset. I've only been at this since March.
    Again, thanks for everything you've done here and on G+.

    ReplyDelete