Expand description
Types for the CIE CAM16 color appearance model.
CIE CAM16 is a color appearance model that tries to predict the appearance
of a color under certain viewing conditions, as specified via the
Parameters
type. The Cam16
type has descriptions for the CAM16
attributes. The Color appearance model page on Wikipedia
has some history and background as well.
§Converting Between XYZ and CAM16
The CIE CAM16 implementation in Palette has the Cam16
type and its
partial variants on one side of the boundary, and Xyz
on the
other. Going between Xyz
and Cam16
requires the viewing conditions to be
specified as Parameters
.
use palette::{
Srgb, FromColor, IntoColor,
cam16::{Cam16, Parameters},
};
// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);
// CAM16 from sRGB, or most other color spaces:
let rgb = Srgb::new(0.3f32, 0.8, 0.1);
let cam16_from_rgb = Cam16::from_xyz(rgb.into_color(), example_parameters);
// sRGB from CAM16, using lightness, chroma and hue by default:
let rgb_from_cam16 = Srgb::from_color(cam16_from_rgb.into_xyz(example_parameters));
For more control over the attributes to use when converting from CAM16, one of the partial CAM16 types can be used:
Cam16Jch
: lightness and chroma.Cam16Jmh
: lightness and colorfulness.Cam16Jsh
: lightness and saturation.Cam16Qch
: brightness and chroma.Cam16Qmh
: brightness and colorfulness.Cam16Qsh
: brightness and saturation.
Generic traits and functions can make use of the IntoCam16Unclamped
,
FromCam16Unclamped
, Cam16IntoUnclamped
, and Cam16FromUnclamped
traits. They are similar to the traits from the convert
module and help abstracting away most of the implementation details.
§The CAM16-UCS Color Space
CIE CAM16 specifies a visually uniform color space that can be used for
color manipulation. It’s represented by the Cam16UcsJmh
and
Cam16UcsJab
types, similar to Lch
and
Lab
.
use palette::{
Srgb, FromColor, IntoColor,
cam16::{Cam16Jmh, Parameters, Cam16UcsJmh},
};
// Customize these according to the viewing conditions:
let mut example_parameters = Parameters::default_static_wp(40.0);
// CAM16-UCS from sRGB, or most other color spaces:
let rgb = Srgb::new(0.3f32, 0.8, 0.1);
let cam16 = Cam16Jmh::from_xyz(rgb.into_color(), example_parameters);
let mut ucs_from_rgb = Cam16UcsJmh::from_color(cam16);
// Shift the hue by 120 degrees in CAM16-UCS:
ucs_from_rgb.hue += 120.0;
// Convert back to sRGB under the same viewing conditions:
let rgb = Srgb::from_color(Cam16Jmh::from_color(ucs_from_rgb).into_xyz(example_parameters));
Modules§
- cam16_
jch - Partial CIE CAM16, with lightness and chroma, and helper types.
- cam16_
jmh - Partial CIE CAM16, with lightness and colorfulness, and helper types.
- cam16_
jsh - Partial CIE CAM16, with lightness and saturation, and helper types.
- cam16_
qch - Partial CIE CAM16, with brightness and chroma, and helper types.
- cam16_
qmh - Partial CIE CAM16, with brightness and colorfulness, and helper types.
- cam16_
qsh - Partial CIE CAM16, with brightness and saturation, and helper types.
Structs§
- Baked
Parameters - Pre-calculated variables for CAM16, that only depend on the viewing conditions.
- Cam16
- The CIE CAM16 color appearance model.
- Cam16
Jch - Partial CIE CAM16, with lightness and chroma.
- Cam16
Jmh - Partial CIE CAM16, with lightness and colorfulness.
- Cam16
Jsh - Partial CIE CAM16, with lightness and saturation.
- Cam16
Qch - Partial CIE CAM16, with brightness and chroma.
- Cam16
Qmh - Partial CIE CAM16, with brightness and colorfulness.
- Cam16
Qsh - Partial CIE CAM16, with brightness and saturation.
- Cam16
UcsJab - The Cartesian form of CAM16-UCS, or J’ a’ b’.
- Cam16
UcsJab Iter - An iterator for
Cam16UcsJab
values. - Cam16
UcsJmh - The polar form of CAM16-UCS, or J’M’h’.
- Cam16
UcsJmh Iter - An iterator for
Cam16UcsJmh
values. - Parameters
- Parameters for CAM16 that describe the viewing conditions.
- Static
Wp - Represents a static white point in
Parameters
, as opposed to a dynamicXyz
value.
Enums§
- Discounting
- The degree of discounting of (or adaptation to) the illuminant.
- Surround
- A description of the peripheral area.
Traits§
- Cam16
From Unclamped - A trait for converting into a CAM16 color type from
C
without clamping. - Cam16
Into Unclamped - A trait for converting from a CAM16 color type into
C
without clamping. - From
Cam16 Unclamped - A trait for converting from a CAM16 color type
C
without clamping. - Into
Cam16 Unclamped - A trait for converting into a CAM16 color type
C
without clamping. - White
Point Parameter - A trait for types that can be used as white point parameters in
Parameters
.
Type Aliases§
- Cam16
Jcha - Partial CIE CAM16 with lightness, chroma, and an alpha component.
- Cam16
Jmha - Partial CIE CAM16 with lightness, colorfulness, and an alpha component.
- Cam16
Jsha - Partial CIE CAM16 with lightness, saturation, and an alpha component.
- Cam16
Qcha - Partial CIE CAM16 with brightness, chroma, and an alpha component.
- Cam16
Qmha - Partial CIE CAM16 with brightness, colorfulness, and an alpha component.
- Cam16
Qsha - Partial CIE CAM16 with brightness, saturation, and an alpha component.
- Cam16
UcsJaba - Cartesian CAM16-UCS with an alpha component.
- Cam16
UcsJmha - Polar CAM16-UCS with an alpha component.
- Cam16a
- CIE CAM16 with an alpha component.