v9.1.1
Menu

Exposure Merge Weights

mediumFREEHDR ImagingHDRCV: Computational Photography

Compute pixel weights for HDR merging based on exposure quality.

In HDR imaging, we combine multiple exposures to capture scenes with high dynamic range. However, not all pixels from each exposure are equally reliable:

  • Under-exposed pixels (dark, near 0) contain noise
  • Over-exposed pixels (bright, near 255) are saturated/clipped
  • Well-exposed pixels (mid-gray, near 128) are most reliable

We use a Gaussian weighting function centered at mid-gray:

w(z)=exp⁡(−(z−128)22σ2)w(z) = \exp\left(-\frac{(z - 128)^2}{2\sigma^2}\right)

where:

  • zz is the pixel value in range [0, 255]
  • σ\sigma controls the width of the acceptable exposure range
  • The weight peaks at 1.0 for z = 128 and falls off for extreme values

This ensures that HDR merging prioritizes well-exposed samples while downweighting unreliable saturated or noisy regions.

Example

Input
exposure_weight(128, 50)
Output
1.0
Reasoning
  • Inputs: pixel_value =128= 128 is an 8-bit intensity (0 is black, 255 is white), and sigma =50= 50 sets how quickly trust drops as a pixel moves away from mid-gray.
  • Deviation: the distance from the ideal exposure is z−128=128−128=0z - 128 = 128 - 128 = 0.
  • Exponent: the Gaussian exponent is −022⋅502=−05000=0-\frac{0^2}{2 \cdot 50^2} = -\frac{0}{5000} = 0.
  • Weight: e0=1e^{0} = 1, so after rounding to 4 decimal places the output is 1.0, the largest weight any pixel can receive.
  • Notice: the weight depends only on the squared distance, so it is symmetric. A pixel one σ\sigma away on either side (z=178z = 178 or z=78z = 78) gets e−1/2≈0.6065e^{-1/2} \approx 0.6065, while pure black (z=0z = 0, deviation 128128) gives e−16384/5000=e−3.2768≈0.0377e^{-16384/5000} = e^{-3.2768} \approx 0.0377.
  • A larger σ\sigma widens the bell, so extreme pixels keep more weight; a smaller σ\sigma trusts only values close to 128.

Constraints

  • pixel_value is an integer in range [0, 255]
  • sigma is the Gaussian width parameter (positive float, default 50)
  • Return weight rounded to 4 decimal places
  • Weight should be in range [0, 1]

Learn this in

More from CV: Computational Photography

solution.py

Test results

Sign in to run your code against the test cases.