#[non_exhaustive]pub enum LumaCoefficients {
Bt709,
Bt601,
Bt2020,
DisplayP3,
}Expand description
Luma coefficients for RGB→Gray conversion.
Use coefficients() to get the concrete [f32; 3]
weights for each variant.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bt709
BT.709: 0.2126R + 0.7152G + 0.0722B (HDTV, sRGB).
Bt601
BT.601: 0.299R + 0.587G + 0.114B (SDTV, JPEG).
Bt2020
BT.2020 / BT.2100: 0.2627R + 0.6780G + 0.0593B (UHDTV, wide gamut).
BT.2100 (HDR) uses the same primaries as BT.2020, so this is the variant to use for both SDR BT.2020 and HDR BT.2100 content.
DisplayP3
Display P3 (DCI-P3 primaries + D65): 0.2289746R + 0.6917385G + 0.0792869B
(Apple wide-gamut consumer displays).
Unlike BT.709 and BT.2020, no ITU recommendation prescribes these weights — they are derived as the middle (Y) row of the DisplayP3→XYZ matrix from the P3 primaries and D65 white point, and match what libultrahdr and other HDR tooling use in practice for RGB→luma on DisplayP3 content.
Implementations§
Source§impl LumaCoefficients
impl LumaCoefficients
Sourcepub const fn coefficients(self) -> [f32; 3]
pub const fn coefficients(self) -> [f32; 3]
Return the [R, G, B] weights for this luma recipe.
Bt709:[0.2126, 0.7152, 0.0722]Bt601:[0.299, 0.587, 0.114]Bt2020:[0.2627, 0.6780, 0.0593](same as BT.2100)DisplayP3:[0.2289746, 0.6917385, 0.0792869]
The three weights always sum to exactly 1.0 in IEEE 754 double
precision, but may sum to 1.0 ± 1 ULP in f32. Callers that need
the weights to sum to exactly 1.0 in f32 should use double-precision
accumulation in their inner loop.
Trait Implementations§
Source§impl Clone for LumaCoefficients
impl Clone for LumaCoefficients
Source§fn clone(&self) -> LumaCoefficients
fn clone(&self) -> LumaCoefficients
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for LumaCoefficients
Source§impl Debug for LumaCoefficients
impl Debug for LumaCoefficients
impl Eq for LumaCoefficients
Source§impl Hash for LumaCoefficients
impl Hash for LumaCoefficients
Source§impl PartialEq for LumaCoefficients
impl PartialEq for LumaCoefficients
Source§fn eq(&self, other: &LumaCoefficients) -> bool
fn eq(&self, other: &LumaCoefficients) -> bool
self and other values to be equal, and is used by ==.