Extended Reinhard with White Point
Apply extended Reinhard tone mapping with white point control.
The basic Reinhard operator never reaches pure white (1.0) because it asymptotically approaches 1. The extended version allows control over which luminance value maps to white:
Ldβ=1+LLβ (1+Lwhite2βLβ)β
where Lwhiteβ is the luminance value that should map to pure white (1.0).
Properties:
- When L=Lwhiteβ: Ldβ=1.0 (reaches pure white)
- When LβͺLwhiteβ: behaves like basic Reinhard
- Allows intentional "burning out" of very bright highlights
This gives photographers control similar to choosing paper white in traditional printing.
Example:
reinhard_extended(1.0, 2.0)
0.625
For L = 1.0 and L_white = 2.0:
- Compute L/L_whiteΒ²: 1.0 / (2.0)Β² = 1.0 / 4.0 = 0.25
- Compute numerator: 1.0 Γ (1 + 0.25) = 1.0 Γ 1.25 = 1.25
- Compute denominator: 1 + 1.0 = 2.0
- Final result: 1.25 / 2.0 = 0.625
Constraints:
- L is HDR luminance value (non-negative)
- L_white is the white point luminance (positive)
- Return tone-mapped value rounded to 4 decimal places
- When L = L_white, output should be 1.0
More from CV: Computational Photography
Youβre implementing a global tone-mapping operator that takes HDR luminance values and compresses them into displayable range [0,1] using the extended Reinhard formula with a white point parameter.
1. Background Knowledge
-
HDR vs LDR and Tone Mapping HDR images can contain luminance values spanning many orders of magnitude (e.g., from dark shadows to bright sunlight). Standard displays (LDR) can only show a limited range, so we apply a tone-mapping operator (TMO) to compress the dynamic range while preserving important detail and contrast.
-
Reinhard Tone Mapping The original Reinhard global operator maps a luminance L to display luminance Ldβ using a simple curve that:
-
Is monotonic (brighter stays brighter),
-
Compresses large values,
-
Asymptotically approaches 1 but never reaches it. The extended version introduces a white point Lwhiteβ so that a specific luminance is forced to map to pure white (1.0), giving artistic control over how quickly highlights βburn out.β
-
White Point Control In the extended operator
choosing a smaller Lwhiteβ causes highlights to clip earlier; choosing a larger Lwhiteβ preserves more highlight detail but may look flatter.
2. Algorithm / General Approach
The pattern for this type of global tone-mapping problem is:
- Work in luminance space, not directly on RGB.
- Apply a per-pixel mapping function f(L) to compress luminance values into [0,1].
- Reconstruct RGB using the ratio of new luminance to old luminance (so colors are preserved).
- Clamp and gamma-correct as needed for the target display.
For this specific problem, the core is implementing the given scalar function for each luminance value using the provided formula and chosen Lwhiteβ.
3. Step-by-Step Strategy
Assume each pixel has RGB values R,G,B in some linear HDR range.
- Compute luminance per pixel Use a standard linear luminance formula, e.g.
float L = 0.2126f * R + 0.7152f * G + 0.0722f * B;
(Weights may differ depending on the assignment, but the idea is the same.)
- Choose or receive Lwhiteβ
- Often given as a parameter in the problem.
- If not, a typical strategy in practice is to pick something like a high percentile of luminance (e.g., 95th percentile), but in a coding exercise itβs usually provided.
Continue the full explanation
You're reading the free preview. Unlock the complete walkthrough, the code editor, test runner and reference solution with Premium.
Editor locked
The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.