17.3 Merging exposures⧉
Calibration puts the exposures into common units. The next decision is how much to trust each estimate at each location. We start with a simple method based on thresholds. But we then observe that long exposures can supply precise shadows and clipped highlights at the same time, so a more advanced merge must combine both measurement values and their reliability.
17.3.1 The weighted merge⧉
We work with registered, black-level-corrected linear values $I_i$ and calibrated exposure factors $k_i$. We divide by $k_i$ to put the observations in common relative-radiance units, then combine the valid estimates. For encoded inputs, we first invert the appropriate response.
Validity masks reject saturated, defective or unregistered samples. Noise weights reduce the influence of uncertain measurements. We choose clipping margins in the input's calibrated units; thresholds such as 0.99 or 0.002 are not universal. Very dark samples can still provide information when their noise is modeled. We avoid selecting on noisy intensity more aggressively than necessary, since this can bias the merge.
We let $w_i$ include both validity and reliability. The linear-light merge is
In words, the estimated radiance is the reliability-weighted mean of the rescaled observations. In code this is one pass per pixel over the bracket: divide out each exposure factor, accumulate by reliability, normalize:
for each pixel p: num, den = 0, 0 for each exposure i: if valid(i, p): q = linear_value(i, p) / exposure_factor[i] w = radiance_weight(i, p) num += w * q den += w if den > 0: L[p], measured[p] = num / den, True else: L[p], measured[p] = flagged_fallback(p), False
For a calibrated nonlinear response, Debevec–Malik Debevec & Malik 1997 instead combines log-radiance estimates:
Exponentiation produces a weighted geometric mean, not the preceding arithmetic mean. The error model and weighting should match the domain. Multiple independent, equally precise observations reduce standard deviation by $1/\sqrt N$; unequal weights, correlations and data-dependent selection require the more general variance calculation (Chapter 13.2, Denoising by averaging).
17.3.2 When every exposure is bad at a pixel⧉
If every exposure clips, the shortest exposure supplies the strongest lower bound on radiance. If all are too noisy, the longest usable exposure is usually the best fallback at fixed gain, provided motion and defects do not invalidate it. We keep an uncertainty or validity flag, since neither case supplies a reliable point estimate. With variable gain, we select by calibrated radiance-domain uncertainty rather than by exposure duration alone.
Chapter 18.4, Exposure fusion directly blends rendered inputs using appearance weights. It is useful when a finished picture is the objective; its output is not a calibrated radiance measurement.
17.3.3 What comes out is not a picture⧉
The radiance estimate still needs an exposure and rendering choice. A target display may require contrast compression; local tone mapping can compress a coarse base while retaining detail. Edge-aware bases can reduce some halos, but do not guarantee artifact-free output (Chapter 18.3, Two-scale and bilateral tone mapping).
17.3.4 Optimizing the capture and merge⧉
A binary validity mask can retain several exposures at once. Among the valid estimates, inverse-variance weights account for unequal precision instead of treating all samples equally.
For two independent unbiased estimates $x,y$ with variances $\sigma_x^2,\sigma_y^2$, we write $\hat L=\beta x+(1-\beta)y$. Minimizing $\beta^2\sigma_x^2+(1-\beta)^2\sigma_y^2$ gives:
Under independence and known positive variances, the minimum-variance linear unbiased estimate weights each observation by inverse variance. Here $\sigma_i^2$ must denote variance after exposure normalization, in radiance units:
The preceding result applies to independent estimates with fixed known variances. Saturation and uncertain calibration need separate treatment.
To make those weights concrete, we plug in the camera's noise model. The per-pixel variance is dominated by two terms: photon (shot) noise, whose variance is proportional to the signal and so dominates in the highlights, and read noise, whose variance is constant and so dominates in the shadows:
where $a$ and $\sigma_\text{read}$ depend on the camera and the ISO. We can calibrate it by shooting repeated frames and measuring the variance across the stack, or derive it on paper. Either way, the merge weights are no longer a hand-drawn hat; they come from the physics of the sensor.
If linear signal $I_i$ has conditional variance $a_i k_iL+b_i$, then the normalized estimate has
At common gain with shot noise alone, the relative weights are proportional to $k_i$ for each valid frame. With read noise, the weights generally also depend on scene intensity. We handle that dependence with a pilot radiance estimate or an appropriate likelihood. For correlated measurements, the covariance matrix replaces independent inverse variances. Clipping and data-dependent weights also limit the unbiased-estimator interpretation.
We can measure what each choice of weights does to the noise of the merge on a simulated bracket (Figure 17.3.4). Weights proportional to $k_i$ match the hat almost everywhere and do much better just below the level where a frame clips, where the hat discounts the best sample. In the shadows, where read noise dominates, they trust a short frame too much, and the hat does slightly better there. Only the inverse variance is never worse than the others, and weighting by $1/k_i$, which favors the short frames, is clearly worse than all of them.

Hasinoff, Durand and Freeman optimize the shutter/ISO sequence for worst-case SNR over a specified brightness range and time budget, using a calibrated camera noise model (Hasinoff et al. 2010). Higher gain can reduce the contribution of downstream read noise on some sensors, at the cost of saturation headroom. The optimum is camera- and scene-dependent; it does not imply a general preference for short, high-ISO exposures. Granados and colleagues develop related noise-aware merging (Granados et al. 2010).
The fixed-time capture question also matters for bursts: additional frames incur readout and alignment costs. Chapter 17.6, HDR+ and burst imaging on phones uses a different capture design, retaining short exposures for highlights and motion while combining them for noise reduction.
Calibrated HDR scenes for tone-mapping evaluation; Google's RAW burst set behind HDR+ Hasinoff et al. 2016. <http://markfairchild.org/HDR.html> · <https://hdrplusdata.org>. See the Chapter 45.16, Datasets appendix.
The units of the weight are easiest to see with two exposure times. A long exposure records more photons, but its raw variance is also larger in the shot-noise regime. Dividing each measurement by its exposure time puts both on a radiance scale. The long exposure then has smaller variance on that common scale, because the exposure normalization divides its variance by the square of the time. Weighting raw values by their unnormalized variance would answer the wrong question.
With shot noise alone, the precision of an unclipped radiance estimate grows in proportion to exposure time. Read noise adds a term whose radiance variance decreases with the square of exposure time, making long captures especially useful where that term matters. Clipping removes their usefulness at bright pixels. This is how one frame can be valuable in the shadows and unusable in the highlights without changing the weighting principle.
The capture optimization asks a different question from choosing merge weights. Suppose the total capture time is fixed. Spending most of it on a long exposure gives dark regions more photons, but can leave bright regions clipped in that frame. Dividing it among short exposures provides repeated highlight measurements but incurs read noise repeatedly. Changing gain can alter the contribution of downstream electronics as well as the available headroom. For each candidate sequence, we predict the merged SNR as a function of scene brightness; the objective used by Hasinoff, Durand and Freeman improves the worst part of that curve over a specified range Hasinoff et al. 2010. The figure's comparison should be read as a result for its camera model and budget, rather than as a universal ISO prescription.
The published capture example makes the role of gain concrete. Under a budget of at most three photographs and 0.25 seconds of exposure, the paper's Canon 1D Mark III model compares an ISO-100 bracket of $1/100$, $1/25$ and $1/6$ second with an optimized ISO-3200 sequence of $1/3200$, $1/125$ and $1/5$ second. Its plotted worst-case SNR improves by about 12 dB (project poster). The longest optimized exposure is actually longer than the longest bracket exposure. The result comes from allocating the whole sequence under the sensor's noise and saturation model, not from a rule that increasing ISO and shortening every exposure improves photographs.