Drago Adaptive Log Mapping
Implement Drago's adaptive logarithmic tone mapping, a technique used in tone mapping to preserve details in high dynamic range images. This method extends traditional logarithmic tone mapping by adapting the base of the logarithm based on local luminance.
The goal is to map high dynamic range images to lower dynamic ranges while preserving details, which is crucial in computational photography. The logarithmic tone mapping approach is based on the idea that human perception of light is logarithmic, and can be represented by the equation , where is the luminance and is the adaptive base.
Here are the key steps:
- Compute the luminance from the input image.
- Determine the maximum luminance .
- Calculate the adaptive base based on local luminance.
- Apply the logarithmic tone mapping using the calculated .
Specification
- hdr is an RGB image of shape with positive float values; values below are raised to .
- Luminance: .
- Adaptive base: , so runs from at the darkest pixel to at the brightest.
- Colour: multiply every channel of a pixel by , then clip the result to .
- Return a float array of the same shape with values in (not 8-bit integers in ).
This technique is widely used in high dynamic range imaging applications.
Example
HDR image
Tone mapped LDR
- Input:
hdris an RGB radiance image of unbounded positive values;biassets how fast the log base grows with brightness. Take gray pixels and . - Luminance: the weights sum to 1, so gray pixels have and , giving , .
- Adaptive base: the darkest pixel gets ; the brightest gets .
- Mapping: bright pixel ; dark pixel .
- Output: scaling channels by gives and , so the Tone mapped LDR image has pixels and : same shape, floats in .
- Notice: each pixel's base appears top and bottom, so by change of base . The brightest pixel always maps to 1; a radiance gap shrinks to .
Constraints
- Input image: 2D numpy array (grayscale or RGB) with shape (height, width) and dtype float32, representing the high dynamic range image
- Luminance values: in range [0, 1e6], assuming a maximum possible luminance of 1 million
- Adaptive base calculation: b in range [2, 10], with a minimum and maximum base value to prevent division by zero and ensure meaningful tone mapping
- Output: return the tone mapped image as a 2D numpy array (grayscale or RGB) with the same shape as the input, and dtype uint8, representing the low dynamic range image
- Special conditions: assume the input image has at least one pixel with a non-zero luminance value to avoid division by zero in the logarithmic tone mapping equation