This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Graphics & Multimedia

Blending photos with Enfuse

By Nathan Willis on February 20, 2008 (7:00:00 PM)

Share    Print    Comments   

Combining multiple photographs taken at different exposures lets you create a single image with good highlight and shadow detail. Tone-mapping applications like Qtpfsgui are the traditional way to do this, but tone-mapping is slow, difficult to use, and can produce strange visual artifacts. A new tool on the scene is easier, faster, and produces nicer results: Enfuse.

Enfuse is recent project from the developers of the panorama apps Hugin and Enblend. It is part of the Enblend package, but has not yet made it into the stable release for Linux. You can download precompiled betas of Enblend for Windows and Mac OS X from panospace.wordpress.com; Linux users can follow the directions linked at that same page to compile the software. Compilation does not take too much time, and as long as you install the listed dependencies first isn't tricky either.

What you get after the make install step is a binary called enfuse. The syntax for using it is simple: type enfuse -o outputfilename.jpg inputfile_1.jpg inputfile_2.jpg inputfile_3.jpg ..., listing all of the input images (you can use wildcards if you want). By default Enfuse prints out verbose status messages as it goes along, which can help give you a feel for how the algorithm works. At the end, though, you will have to open up the resulting image in an image viewer yourself.

To provide an example, I took a series of bracketed shots aimed at the corner of my desk. Part of a computer monitor is visible in frame, as is an LED light aimed directly at the camera, a number of reflective surfaces, and a number of shadow areas both in the foreground and in the background.

Running Enfuse -- with no manual tweaking of the command-line switches and no adjustments made to any of the input images -- I got the resulting fused image in less than four seconds. By comparison, Qtpfsgui took more than 20 seconds to generate each of its tone-mapped output images, and subjectively I found even the best of them inferior, even when I tweaked the algorithm's settings.

How it works

Enfuse blends its input images using a process called exposure fusion, in which the algorithm examines the input images and grades each pixel on contrast, saturation, and "well-exposedness." The images get added together, with each input image weighted differently at each pixel, depending on its score.

The reason it works is that overexposure and underexposure score poorly on all three of the criteria. Overexposed areas are washed-out, all white -- meaning no contrast and no saturation. Underexposed regions are all black -- again, no contrast and no saturation. "Well-exposedness" as the algorithm defines it just means values not close to zero or one (i.e., pure black and pure white).

The algorithm makes several improvements on this basic idea, accounting for things like multiple color channels and avoiding trouble at sharp edges. The original paper on the subject is interesting and is a quick read; it is available at the Enfuse page on the panotools.org wiki.

If you read carefully, you might have noticed that my description of the algorithm did not refer to the original scene at all. That distinction is what makes Enfuse so fast. High dynamic range (HDR) based tone-mapping apps always start by combining the input images into a reconstruction of the original scene, usually using the exposure information in the EXIF tags to properly arrange the input stack darkest to lightest. Only then can the HDR image be tone-mapped down into a regular TIFF or JPEG.

With exposure fusion, none of that is necessary. Each pixel of each image is graded on its individual merits alone.

Advanced usage

Naturally there are some instances where Enfuse's default weighting scheme does not give you a pleasant-looking result. An image without much saturation, or with objects that you want to look near-black or near-white, might not score well. For those circumstances, you can adjust the weighting scheme on the command line.

The --w switch allows you to specify the relative importance of each of the scoring factors on a scale from 0 to 1. You specify values for contract, saturation, and "well exposedness" separately with --wContrast=x --wSaturation=y --wExposure=z. It takes some trial-and-error to determine what values work, but the fusion process is fast.

The Enfuse man page details several other switches, with which you can adjust the number of levels used for blending, contrast analysis, output scaling, and memory usage.

You can even use Enfuse to blend images with different depths of field, and thus create output images with both foreground and background objects in focus. That capability is useful for situations where lighting dictates setting a shallow depth of field in-camera. Be prepared for more manual tweaking of the --w switch variables, though, as this process puts a different spin on what makes a particular pixel worth weighting heavily.

I frequently see comments about HDR tone-mapping that express interest in the final product, but disappointment with the results. To be sure, you can do a lot of creative things with tone-mapping, especially if you are willing to put in the time to experiment with the various algorithms and their settings. But if you just want a good, normal-looking image that covers a wide dynamic range, Enfuse is the better option.

Share    Print    Comments   

Comments

on Blending photos with Enfuse

Note: Comments are owned by the poster. We are not responsible for their content.

Blending photos with Enfuse

Posted by: Ian Mackenzie on February 20, 2008 10:42 PM
Wow - this is excellent. I also tried for a long time to get Qtpfsgui to generate a nice result, and even with all sorts of tweaking different algorithms I could never get anything I was happy with...I ran Enfuse with no options and the resulting image is perfect. So many more indoor photo-taking opportunities now...

#

Blending photos with Enfuse

Posted by: Anonymous [ip: 139.80.32.130] on February 20, 2008 10:49 PM
So how long until there are digital camera's that support this mode of photography? Push the button, hold the camera still (i.e. on a tripod), wait for it to iterate over various exposure settings. Would be cool.

#

Re: Blending photos with Enfuse

Posted by: Anonymous [ip: 72.25.192.4] on February 21, 2008 06:44 PM
Many of the higher end DSLRs already support this, and have for a while now.

#

Darn...

Posted by: Anonymous [ip: 199.164.56.5] on February 21, 2008 12:55 AM
That's great when you can take 20 shots of the same subject from a tripod, but as an underwater photographer, where everything is in motion all the time, I'm feeling left out. Underwater, getting even 2 shots the same is difficult. Anyone know of a program that can do this from a single image?

#

Blending photos with Enfuse

Posted by: Anonymous [ip: 70.55.115.165] on February 21, 2008 03:47 AM
don't feel left out, diver! You don't need 20 shots - two or three are enough, especially under water where the dynamic range is not as extreme. Set your camera on auto-bracketing mode. Target the slowest bracket to be where you would normally expose your single shot. On most popular cameras, that's -2 EV. No need for a tripod either. Using hugin's align_image_stack, hand held pictures are easily pre-aligned for the fusion process. http://panospace.wordpress.com/2008/02/07/take-enfuse-on-a-test-flight/ is the story of an amazing shot which needed alignment. The result is stunning!

#

Blending photos with Enfuse

Posted by: Anonymous [ip: 192.33.238.6] on February 21, 2008 11:00 AM
@Darn
If the dynamic range of the scene you are trying to photograph exceeds the dynamic range of your camera's sensor, there is nothing you can do with a single take: it will be always either underexposed or overexposed (or both of them at the same time). However, if that is not the case, you can still use a local tone-mapping algorithm to enhance a single image; this process makes bright zones darker and vice-versa.

#

Single shot HDR

Posted by: Anonymous [ip: 69.109.58.171] on February 21, 2008 08:56 PM
This is some really neat work - and so easy.

For single shot (moving subjects, no tripod, etc.) raw photo processing can effectively give you similar results to these HDR methods with just one exposure. It's takes some experience and manual adjustment generally, but it can be pretty quick and has a lot of other benefits. I especially like LightZone which is not FOSS but has had some Linux releases. Lightzone also allows you to select areas.

And, no offense, but your results shot looks flat and lacking contrast. I think maybe your bright exposures are too bright. It would be interesting to try and just eliminate the 4-5 brightest and re-process.

The recently announced Pentax K20D, for one, offers an in-camera HDR blend function of multiple bracketed exposures.

#

Re: Single shot HDR

Posted by: Nathan Willis on February 22, 2008 06:04 PM
I don't think you're getting how these techniques work. With exposure fusion, there is no such thing as "bright exposures are too bright" -- with any set of bracketed exposures, the most exposed frames will have overexposed regions and the least exposed frames will have underexposed regions -- obviously; the algorithm recognizes which frames are overexposed and which are underexposed, and eliminates them from the composite image. That's the whole point. And the example image is not intended to produce an "eye pleasing" result, but to demonstrate that the exposure fusion technique in Enfuse can correctly identify the regions of each frame to use so that the composite image has both highlight detail (text in the LCD screen), and shadow detail (shelf items in the back wall, and beneath the monitor). Regardless of any one person's opinion on the subjective pleasantness of any particular exposure, the technique allows you to combine a set of multiple exposures that collectively cover far more dynamic range than you can capture in a single shot. RAW processing is about correctly bringing out the detail in each exposure; it doesn't change the dynamic range captured in the exposure and cannot bring out more data than is actually there. Combining multiple exposures can. -- Nate

#

Blending photos with Enfuse

Posted by: Anonymous [ip: 80.248.105.241] on February 24, 2008 03:10 PM
HDR images has done many many years, since B/W photos was easy to develope on home 'wet-workflow'. You could do this kind things but it was skillfull job to get frames to be exact on same position. Diafilm has so much greater dynamic on colors/light so it's easy to get from one slide great picture, but the picture taking itself is much harder (correct exposure is needed).

Now with DSRL time, we have RAW format what allows us to recover +/- 2-3 F-stops from one image and it's bretty easy to get nice HDR image. It's even better if you just braket 3-6 frame and combine them.
And if you are taking long exposure shots (over 1s), take one black frame with same settings (cover your lens and take picture) so you can remove image noise from it before you make HDR image :-)

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya