Expand description
Convert colors from one reference white point to another
Chromatic adaptation is the ability to adjust the appearance of colors to changes in illumination. This happens naturally in our body’s visual system, and can be emulated with a “chromatic adaptation transform” (CAT).
This library implements a one-step adaptation transform, known as the von
Kries method. It’s provided as AdaptFromUnclamped or
AdaptIntoUnclamped for convenience, or adaptation_matrix for control
and reusability. All of them can be customized with different LMS matrices.
The provided LMS matrices are:
Bradford- A “spectrally sharpened” matrix, which may improve chromatic adaptation. This is the default forAdaptFromUnclampedandAdaptIntoUnclamped.VonKries- Produces cone-describing LMS values, as opposed to many other matrices, but may perform worse than other matrices.UnitMatrix- Included for completeness, but generally considered a bad option. Also called “XYZ scaling” or “wrong von Kries”.
use palette::{
Xyz, white_point::{A, C},
chromatic_adaptation::AdaptIntoUnclamped,
};
use approx::assert_relative_eq;
let input = Xyz::<A, f32>::new(0.315756, 0.162732, 0.015905);
//Will convert Xyz<A, f32> to Xyz<C, f32> using Bradford chromatic adaptation;
let output: Xyz<C, f32> = input.adapt_into_unclamped();
let expected = Xyz::new(0.257963, 0.139776, 0.058825);
assert_relative_eq!(output, expected, epsilon = 0.0001);Structs§
- Cone
Response Matrices Deprecated - Holds the matrix coefficients for the chromatic adaptation methods
Enums§
- Method
Deprecated - Chromatic adaptation methods implemented in the library
Traits§
- Adapt
From Deprecated - Trait to convert color from one reference white point to another
- Adapt
From Unclamped - A trait for unchecked conversion of one color from another via chromatic adaptation.
- Adapt
Into Deprecated - Trait to convert color with one reference white point into another
- Adapt
Into Unclamped - A trait for unchecked conversion of one color into another via chromatic adaptation.
- Transform
Matrix Deprecated - Generates a conversion matrix to convert the Xyz tristimulus values from
one illuminant to another (
source_wptodestination_wp)
Functions§
- adaptation_
matrix - Construct a one-step chromatic adaptation matrix.
- diagonal_
matrix - Construct a diagonal matrix for full adaptation of
Lmscolors.