PIXELBANKv9.1.0
Menu

Exposure Merge Weights

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:

For pixel_value = 128 (mid-gray):

  1. Compute deviation from mid-gray: diff = 128 - 128 = 0
  2. Apply Gaussian formula: w = exp(-(0)² / (2 × 50²)) = exp(0) = 1.0
  3. The weight is maximum because mid-gray is perfectly exposed.

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]
solution.py

Test Results

0/0
Run code to see test results.
Exposure Merge Weights - Medium | PixelBank