Expand description
P7.2 — Gamut / object-colour solid + closest-point gamut mapping. P7.2 — Gamut / object-colour solid as a convex polytope + closest-point gamut mapping.
The sRGB gamut is the convex hull of the primary colours (red, green, blue) and their combinations in XYZ space. An out-of-gamut colour is mapped to the closest point on the gamut boundary.
§Algorithm
- The sRGB gamut is the set of all
(R,G,B)with0 ≤ R,G,B ≤ 1, mapped through the sRGB→XYZ matrix. - In-gamut check: convert XYZ to linear sRGB; if all channels are in
[0,1], the colour is in-gamut. - Out-of-gamut mapping: clamp each sRGB channel to
[0,1]and convert back to XYZ. This is a simple (non-optimal) closest-point mapping.
§Determinism
All operations are deterministic: the XYZ→sRGB matrix is a constant, and clamping is a pure function.
Enums§
- Gamut
Error - Gamut mapping error.
Functions§
- gamut_
map_ clamp - Map an out-of-gamut colour to the closest in-gamut colour.
- gamut_
map_ idempotent - Interior idempotence: an in-gamut colour maps to itself.
- is_
in_ gamut - Check if a colour is in the sRGB gamut (all linear sRGB channels in [0,1]).
- linear_
rgb_ is_ in_ gamut - Check if a linear sRGB colour is in gamut.
- linear_
srgb_ to_ xyz - Convert linear sRGB to CIE XYZ (inverse of
xyz_to_linear_srgb).