HDR Exposure Fusion
Operator: Abdulla Al Fahad. How tools are built and checked
Three exposures of one scene hold different parts of it: the dark frame keeps the window, the bright frame keeps the shadows, and the middle one has neither fully. On a synthetic scene with a dim half and a bright half, the three inputs (0.35x, 1x and 3x) have texture contrast, the standard deviation of the green channel, of 6.1, 9.8 and 16.1 in the dim half and 9.4, 5.9 and 0.0 in the bright half, where the brightest frame is clipped to white. The fused picture scores 17.4 and 11.9, better than any single input in each half.
This is exposure fusion (Mertens, Kautz and Van Reeth, 2007): the photos are blended directly, with no HDR file and no tone-mapping step, so the output is an ordinary 8-bit picture.
Order and exposure values do not matter, because fusion weighs pixels by how they look, not by shutter speed; no EXIF data is read.
Key features
- 2 to 7 photos, in any order
- Contrast, saturation and well-exposedness weights from 0 to 2, plus an exposure bell width from 0.10 to 0.40
- Optional alignment of whole-pixel shifts by median threshold bitmaps, reporting what it moved
- Laplacian pyramid blending with up to 8 levels, in a background worker with cancel
Weights, pyramid levels and alignment
Each bracket photo can be a PNG, JPG, WEBP, GIF (first frame) or BMP of up to 25 MB, scaled to 2048 px on the long side. The first photo sets the frame. A later photo whose width-to-height ratio differs from it by more than 3 percent is rejected, because it cannot be a bracket of the same view, and one within 3 percent is stretched to fit. EXIF rotation is applied before the comparison, so a portrait and a landscape shot of the same scene are rejected too.
The output has the size of the first photo and is saved as PNG or JPG at quality 95. The result panel compares the middle exposure, by mean brightness, with the fused picture on a slider.
Seven photos at the 2048 px cap take about 78 MB as pixel bytes and the same again as weight maps while the worker runs, before the pyramids; if the browser stops it, the page suggests using fewer photos.
How it works
Each pixel of each photo gets a weight: contrast x saturation x well-exposedness, each raised to its exponent (an exponent of 0 switches that measure off). Contrast is the absolute response of a 4-neighbour Laplacian on brightness; saturation is the standard deviation of red, green and blue; well-exposedness is a Gaussian around mid-grey, applied to each channel and multiplied together.
The weights of all photos are normalised to sum to 1 at every pixel. Blending them directly would show seams where the best photo changes, so each photo is instead decomposed into a Laplacian pyramid (the picture minus its blurred, reduced version, level by level), each weight map into a Gaussian pyramid, and the weighted levels are summed. Coarse levels, which carry overall brightness, mix over wide areas; fine levels, which carry texture, switch more sharply.
The levels are collapsed back into one picture. The number of levels is the whole part of log2 of the shorter side, minus 2, kept between 2 and 8: 8 for a 2048 x 1365 frame.
Alignment takes the photo with the median mean brightness as the reference. For every other photo it builds a pyramid of median threshold bitmaps, which mark the pixels brighter than that photo's own median and so look the same at any exposure, and at each level tries the nine shifts around the current guess, counting XOR mismatches outside a 4-level band around the median. Up to six levels give a reach of 127 px at full size, and a moved photo repeats its edge pixels. A shift is only used when it is clearly better than no shift: its mismatch rate must be at most 80 percent of the rate at zero shift (50 percent when it sits at the limit of the search), and at least 5 percent of the pixels must have usable texture. Otherwise the photo is left where it is and the result panel says why.
Common use cases
- A hand-held three-shot bracket of a church interior scaled to 2048 x 1365: with Align on, the note lists each photo's shift, for example 'IMG_2 by -4, 2 px', and the stained glass comes mostly from the dark frame while the pews come from the bright one.
- Five frames of a sunset over water in which the sun is white in all but the darkest frame: raise the saturation weight to 1.5 so the coloured sky wins over the grey foreground wherever the exposures overlap.
How to use this tool
- Add 2 to 7 photos of the same scene, taken from one spot at different exposures.
- Leave the three weights at 1 and Align on for a first run.
- Press Fuse photos and watch the progress; Cancel stops the worker.
- Compare with the middle exposure on the slider and read the alignment note.
- Adjust a weight if needed, fuse again and download.
Example
Three photos of a scene whose left half is dim and right half bright, shot at 0.35x, 1x and 3x the light
Texture contrast (standard deviation of green) in the dim half and the bright half:
photo at 0.35x: 6.1 and 9.4
photo at 1x: 9.8 and 5.9
photo at 3x: 16.1 and 0.0 (bright half clipped to white)Fused picture, measured the same way
dim half 17.4, bright half 11.9
So each half keeps more texture than in any single photo.Common pitfalls
Moving subjects ghost. Fusion has no deghosting step, so a person who walked through the frame appears partly in each position, weighted by how well exposed each copy is.
Alignment moves whole pixels only. It does not correct rotation, zoom or perspective, so a camera twist between frames still leaves soft or doubled edges. On a scene with almost no texture, such as a plain gradient, it declines to move anything and says so.
Fusion lifts shadows and holds highlights but does not extend dynamic range the way a calibrated HDR merge does. The output is 8-bit, and a scene with little contrast can come out flat; raise the contrast weight or lower the exposure bell width.
Weights above 1.5 for contrast or saturation can pick noisy pixels from a dark frame, because noise has a high local contrast and a high colour spread.
- Shoot the bracket changing only shutter speed. A different aperture changes depth of field between frames, and alignment can correct a shift of position but not a change in blur.
Best practices
- Start with three frames two stops apart. Every extra frame costs another pyramid pass, and three frames already cover most interiors with one bright window.
Choosing the weights
The three weights multiply, so raising one exponent makes that measure dominate the other two. With all at 1 the fusion favours textured, colourful, mid-tone pixels. Setting contrast to 0 removes the preference for texture and gives a smoother blend that suits low-detail skies; setting well-exposedness to 0 stops each frame being trusted only for its mid-tones, which tends to give a darker, more saturated look.
The bell width is the sigma of the well-exposedness curve on a 0 to 1 scale. At the default 0.20 a channel at 0.3 gets a weight of 0.61, one at 0.1 gets 0.14 and one at 0.0 gets 0.04. At 0.10 the same channels get 0.14, 0.0003 and effectively zero, so only the middle tones count.
Frequently asked questions
Do all the photos need the same pixel size?
No, but they need the same shape. Photos of different sizes are scaled to the first one's size if their width-to-height ratio is within 3 percent of it, and anything further off is rejected with a message naming the file.
Is this the same as an HDR merge?
No. A calibrated HDR merge estimates scene brightness from the exposure times and then tone-maps it down for display. Fusion skips both steps and blends the best-exposed parts of the photos directly, which is why no exposure data is needed.
Why is my result flatter than the middle photo?
Fusion gives up contrast to keep detail in both the shadows and the highlights. Raise the contrast weight, or lower the bell width to favour the middle tones of each frame, and fuse again.