Skip to main content

LumaCoefficients

Enum LumaCoefficients 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

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

Source§

fn clone(&self) -> LumaCoefficients

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LumaCoefficients

Source§

impl Debug for LumaCoefficients

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for LumaCoefficients

Source§

impl Hash for LumaCoefficients

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for LumaCoefficients

Source§

fn eq(&self, other: &LumaCoefficients) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for LumaCoefficients

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.