Skip to main content

Module tonemap

Module tonemap 

Source
Expand description

Tone mapping and sRGB encoding.

Implements a tone reproduction pipeline for RAW image export:

  1. Apply BaselineExposure as a linear gain in scene-linear space.
  2. Apply the Hable/Uncharted2 filmic tone curve, with its white point set to the post-gain maximum so that sensor white always maps to display white. For negative BaselineExposure (extra highlight headroom), values above the “intended white” get smooth shoulder rolloff instead of hard clipping.
  3. Encode to sRGB (IEC 61966-2-1) with the piecewise gamma transfer function.

Output is comparable to dcraw/libraw defaults and correctly handles both negative BaselineExposure (e.g. iPhone ProRAW at -0.83 EV) and positive values.

Functions§

apply_tone_reproduction
Apply tone reproduction to an RGB image.
apply_tonemap
Apply the full tone reproduction pipeline to an RGB image.