colr_types/observer.rs
1//! Standard colorimetric observers.
2//!
3//! A standard observer is an empirical model of human color vision expressed
4//! as three spectral sensitivity functions x-bar(lambda), y-bar(lambda),
5//! z-bar(lambda), collectively the color matching functions (CMFs). Integrating
6//! a spectral power distribution against these functions yields CIE XYZ
7//! tristimulus values. Because the functions differ between observers, the
8//! XYZ values for the same spectrum differ between observers and the two
9//! spaces are not interchangeable.
10//!
11//! | Type | Field | Specification |
12//! |-------------|--------|---------------|
13//! | [`Cie1931`] | 2-deg | CIE 015:2018 |
14//! | [`Cie1964`] | 10-deg | CIE 015:2018 |
15//!
16//! # Which observer to use
17//!
18//! Every standard RGB color space (sRGB, Rec. 709, Rec. 2020, Display P3,
19//! ACES, ProPhoto) is defined relative to [`Cie1931`]. The ICC profile
20//! connection space is [`Cie1931`]. Use [`Cie1931`] for display and imaging
21//! pipelines.
22//!
23//! [`Cie1964`] is recommended by CIE 015:2018 for surface color evaluation
24//! of object colors subtending more than roughly 4 degrees of visual field:
25//! textiles, paints, plastics, printed matter viewed at close range.
26//! Industrial spectrophotometers routinely report results under both observers.
27//! ISO 105-J01 (textile color fastness) mandates [`Cie1964`].
28//!
29//! # Converting between observers
30//!
31//! There is no general lossless conversion between observer spaces at the
32//! tristimulus level. The only correct path is to return to the original
33//! spectral data and integrate against the target observer's CMFs. Once a
34//! spectrum has been collapsed to XYZ, the information needed to reconstruct
35//! it is gone. Observer adaptation transforms (approximate 3x3 matrices)
36//! appear in some literature but they do not preserve metamerism and are not
37//! standardized. This crate does not provide them.
38
39/// Marker for a CIE standard colorimetric observer.
40///
41/// Implemented by [`Cie1931`] and [`Cie1964`]. Participates in the types of
42/// [`Xyz`], [`Illuminant`], and [`WavelengthGrid`] to prevent mixing values
43/// from different XYZ spaces at compile time.
44///
45/// [`Xyz`]: crate::model::Xyz
46/// [`Illuminant`]: crate::illuminant::Illuminant
47/// [`WavelengthGrid`]: crate::model::WavelengthGrid
48pub trait StandardObserver: 'static {}
49
50/// CIE 1931 2-degree standard observer (CIE 015:2018).
51///
52/// Derived from color matching experiments over a 2-degree bipartite field,
53/// covering the fovea. The basis of all standard RGB color spaces and the
54/// ICC profile connection space.
55#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
56pub struct Cie1931;
57
58/// CIE 1964 10-degree supplementary standard observer (CIE 015:2018).
59///
60/// Derived from color matching experiments over a 10-degree bipartite field,
61/// including the parafovea. More representative of large-area viewing.
62/// Recommended for surface color evaluation of textiles, paints, and plastics,
63/// and required by ISO 105-J01 for textile color fastness testing.
64#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
65pub struct Cie1964;
66
67impl StandardObserver for Cie1931 {}
68impl StandardObserver for Cie1964 {}