Expand description
P7.0 — Spectral-space kernel: SPD/CMF POD types + CIE linear-projection. P7.0 — Spectral-space kernel: SPD/CMF POD types + the CIE linear-projection contract.
This module defines the foundational spectral types and the linear projection from a Spectral Power Distribution (SPD) to CIE 1931 XYZ tristimulus values via tabulated Colour Matching Functions (CMFs).
§EMF → Colour pipeline
The Qualia 10D tensor’s spectral axes [α, μ, σ] represent the EMF
(electromagnetic field) payload:
- α (amplitude): total radiant power scaling
- μ (modulation): spectral bandwidth / phase modulation
- σ (signature): peak wavelength selector (400–700 nm)
The pipeline is:
EMF [α, μ, σ] → SPD(λ) → CIE XYZ → linear sRGB → display sRGBemf_to_spd(α, μ, σ)constructs an SPD from the EMF payload.spd_to_xyz(spd)projects through the tabulated CIE 1931 CMFs.xyz_to_linear_srgb(xyz)applies the standard XYZ→sRGB matrix.
§CIE 1931 2-degree observer
The CMFs are tabulated at 10 nm intervals from 380–780 nm (41 samples).
This replaces the Gaussian approximation in render/spectral.rs with
the authoritative tabulated data. The ΔE between the two is documented.
§Determinism
All operations are deterministic: identical input → bit-identical output. The CMF tables are compile-time constants.
Structs§
- Linear
Rgb - Linear sRGB (no gamma encoding). POD, f32.
- Spd
- Spectral Power Distribution: radiant power at 41 wavelength samples (380–780 nm, 10 nm steps). POD, zero-heap, stack-allocated.
- Xyz
- CIE XYZ tristimulus values. POD, f32.
Constants§
- CIE_
1931_ CMF_ X - CIE 1931 2-degree observer colour matching functions, tabulated at 10 nm intervals from 380–780 nm.
- CIE_
1931_ CMF_ Y - CIE_
1931_ CMF_ Z - CIE_
D65_ X - CIE D65 illuminant white point (normalised, Y=1).
- CIE_
D65_ Y - CIE_
D65_ Z - LAMBDA_
MAX - Ending wavelength (nm).
- LAMBDA_
MIN - Starting wavelength (nm).
- LAMBDA_
STEP - Wavelength step (nm).
- SPD_
SAMPLES - Number of spectral samples (380–780 nm at 10 nm intervals).
Functions§
- delta_
e_ 76 - CIE76 ΔE colour difference between two XYZ values (in Lab space).
- emf_
to_ linear_ rgb - Full EMF → linear sRGB pipeline.
- emf_
to_ spd - Convert an EMF payload
[α, μ, σ]to a Spectral Power Distribution. - flat_
spd_ to_ xyz - Project a flat (equal-energy) SPD to verify the D65 white point.
- gaussian_
vs_ tabulated_ delta_ e - Compute the ΔE between the tabulated CMF projection and the existing
Gaussian approximation in
render::spectral.rs. - linear_
rgb_ to_ display - Convert linear sRGB to 8-bit display sRGB (gamma-encoded, normalised).
- linear_
to_ srgb_ channel - Apply sRGB gamma encoding to a single linear channel.
- spd_
to_ xyz - Project an SPD through the CIE 1931 2-degree CMFs to obtain XYZ tristimulus values.
- xyz_
to_ lab - Convert XYZ to CIELAB (D65 reference white).
- xyz_
to_ linear_ srgb - Convert CIE XYZ to linear sRGB using the standard sRGB matrix.