Skip to main content

Module math

Module math 

Source
Expand description

Small colour-science helpers: 3×3 matrices, CIE XYZ ↔ Lab*, chromatic adaptation.

All formulas are from public standards: CIE 15 (Lab*), ICC.1:2010 Annex A (PCS, D50), and the Bradford cone response matrix published by Lam (1985).

Constants§

D50
The ICC profile connection space illuminant (D50), as encoded in s15Fixed16 in every ICC header: X = 0.9642, Y = 1.0, Z = 0.8249.
D65_XY
CIE D65 white point as XYZ (Y = 1), from the chromaticity (0.3127, 0.3290) used by sRGB, Display P3 and Adobe RGB-compatible spaces.
IDENTITY

Functions§

apply
bradford
Bradford chromatic adaptation matrix from white src to white dst (both XYZ).
d50_quantized
The D50 illuminant exactly as an ICC header stores it (s15Fixed16).
delta_e76
CIE 1976 colour difference.
det
invert
Inverse, or None when (nearly) singular.
lab_to_xyz
CIE Lab* → XYZ relative to white.
lab_to_xyz_f32
mul
rgb_to_xyz_matrix
RGB → XYZ matrix (relative to white, Y = 1) for primaries given as chromaticities, or None when the primaries are not independent.
s15f16_round
Quantizes to ICC s15Fixed16Number and back (what a profile can actually store).
xy_to_xyz
XYZ (Y = 1) of a chromaticity (x, y).
xyz_to_lab
CIE XYZ → Lab* relative to white (CIE 15).
xyz_to_lab_f32
f32 versions for the hot paths (D50 PCS only).

Type Aliases§

Mat3
Row-major 3×3 matrix.