Exposure Adjustment
Apply exposure adjustment to HDR luminance values.
Before tone mapping, it's common to adjust the overall brightness using exposure compensation. This is specified in "stops" or EV (exposure value), where each stop doubles or halves the brightness.
Ladjusted=L⋅2exposure
Examples:
- exposure = +1: doubles brightness (1 stop brighter)
- exposure = -1: halves brightness (1 stop darker)
- exposure = 0: no change
This simulates opening/closing the camera aperture or changing shutter speed, allowing you to set the overall brightness level before compressing with a tone mapper.
Example:
adjust_exposure(1.0, 1.0)
2.0
For L = 1.0 and exposure = +1 stop:
- Compute multiplier: 2^1 = 2.0
- Apply to luminance: 1.0 × 2.0 = 2.0
- Result: brightness doubled (1 stop brighter)
Constraints:
- L is HDR luminance value (non-negative)
- exposure is adjustment in stops (can be negative, zero, or positive)
- Return adjusted luminance rounded to 4 decimal places
More from CV: Computational Photography
To solve this problem, you only need to apply a simple mathematical operation to each luminance value, but it helps to understand the photographic meaning behind it.
1. Background Knowledge
In HDR imaging, each pixel often stores a luminance value L in a physically meaningful or wide dynamic-range space (often floating point). These values can span many orders of magnitude (from dark shadows to bright highlights), so we adjust them before compressing them with a tone-mapping operator.
Exposure value (EV) or “stops” comes from photography: changing exposure by +1 stop doubles the amount of light reaching the sensor; -1 stop halves it. Mathematically, this corresponds to multiplying luminance by a power of 2:
Ladjusted=L⋅2exposureThis simulates changing shutter speed, aperture, or ISO in a virtual camera before tone mapping.
2. Algorithm / General Approach
The pattern here is:
- Treat exposure compensation as a global scale factor applied uniformly to all luminance values.
- Compute this scale factor as s = 2^{\text{exposure}}.
- Multiply every HDR luminance value by s.
This is just an element-wise transformation over an array (or image) of luminance values.
3. Step-by-Step Strategy
- Input parsing
- Read the HDR luminance values (likely as a 2D array or 1D list of floats).
- Read the exposure value (a float, can be positive, negative, or zero).
- Compute the scaling factor
- Compute:
scale = 2 ** exposure
or, in many languages, pow(2.0, exposure).
- Apply exposure adjustment
- For each luminance value L[i]:
L_adjusted[i] = L[i] * scale
- Do this for all pixels.
- Return / store result
- Output the adjusted luminance values in the same shape/format as the input.
Example (Python-style pseudocode):
def adjust_exposure(luminance, exposure):
scale = 2.0 ** exposure
return [L * scale for L in luminance]
For an image, the same idea applies but over a 2D array.
4. Common Pitfalls
- Using the wrong base: The formula uses base 2, not base 10. It must be 2^{\text{exposure}}, not 10^{\text{exposure}}.
- Integer arithmetic: Make sure you are using floating-point for luminance and exposure; integer math will break fractional exposures and precise scaling.
- Overflow/underflow: Extreme exposure values on very large/small luminance values can overflow or underflow; not usually a concern in an easy problem, but good to be aware of.
- Modifying in place incorrectly: If the platform expects you to return a new array, don’t overwrite the input unless allowed.
5. Time & Space Complexity
Let N be the number of luminance values (pixels):
- Time complexity: O(N) — you do a constant amount of work per pixel (one multiply).
- Space complexity:
- O(N) if you create a new array for the adjusted luminance.
- O(1) extra space if you modify the array in place.