Enum ColorChannelModel

Source
#[non_exhaustive]
pub enum ColorChannelModel { Rgb, Luma, Yuv, Lab, Lch, Cmyk, Hsv, Hsl, }
Expand description

How to interpret channels as physical quantities.

Each color model consists of a set of color channels, each of which may occur or be omitted in buffers using that model. Each model defines one canonical channel order. This is the order they appear in within ‘shader units’ when pixels are decoded from texels.

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.
§

Rgb

An additive model consisting of a redish, greenish, blueish channel.

Not all models have truly red, green, or blue channels. More specifically we refer to any color representation that uses three observer functions (weight functions on the visible portion of the spectrum of light) and represents color as the simplex defined from mixing them.

The most common, or nearly universal in computer imagery, choice is a linear combination of the three CIE XYZ standard observers at 2° center of vision.

Example: sRGB, CIE XYZ.

§

Luma

A lightness model without any color representations.

This is a one-dimensional color where all representable colors fall on the line segment between full darkness and the whitepoint. Any Rgb and Yuv can be reduced to this.

§

Yuv

A lightness, and two color difference components.

Also sometimes called YUV but that is easily confused is the specific color model called ‘YUV’, a common analog encoding for several PAL systems (now outdated). Don’t confuse with CIE Yuv (1960) or CIE Luv* which is different thing entirely. Yes, confusing.

Based on an Rgb color spaces, with a linear transform to express the color in terms of a total luminance and the difference of blue, red luminance relative to the total one. The linear transform is most often applied to non-linear (aka. gamma pre-corrected, or electric) R’G’B’ values but sometimes (Rec.709) such correct is applied after transformation. Coefficients differ between systems.

As can be read from the terms, the intensity is given as a photometric definition in terms of luminance and not as a perceptual ‘lightness’ which differentiates it from Lab/Lch as defined below.

§

Lab

A lightness, and two chroma components.

Differs from xyY spaces by a non-linear transform, commonly with the goal of generating perceptually uniform values. Example: CIE Lab.

The uniformity permits a perceptual distance metric as Euclidean distance, although this proves imprecise under in-depth investigation. Good for a decent estimate though.

§

Lch

A lightness and two chroma components as polar coordinates.

Polar transform of a Lab model. Example: Oklab

§

Cmyk

A subtractive model consisting of fours inks defining absorbed colors.

Example: ISO 2846 (Euroskala)

§

Hsv

HSV (Hue, saturation, value).

On closer inspection, a model that is neither physical nor perceptual nor based on correctness merits and its use should be strongly reconsidered in favor of a proper Lab-like color model. Please stop, please. https://en.wikipedia.org/wiki/HSL_and_HSV#Disadvantages

§

Hsl

HSL (Hue, saturation, lightness).

Careful, lightness means neither luminance nor perceptual lightness and is a mere arithmetic mean of color values. Some recommend using Luma (based on primary weights) instead but neglect to mention a specific standard. Really research what definition was used when the pixel color was computed. Good luck.

On closer inspection, a model that is neither physical nor perceptual nor based on correctness merits and its use should be strongly reconsidered in favor of a proper Lab-like color model. Please stop, please. https://en.wikipedia.org/wiki/HSL_and_HSV#Disadvantages

Implementations§

Source§

impl ColorChannelModel

Source

pub const fn contains(self, channel: ColorChannel) -> bool

Trait Implementations§

Source§

impl Clone for ColorChannelModel

Source§

fn clone(&self) -> ColorChannelModel

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ColorChannelModel

Source§

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

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

impl Hash for ColorChannelModel

Source§

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

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 ColorChannelModel

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const 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 Copy for ColorChannelModel

Source§

impl Eq for ColorChannelModel

Source§

impl StructuralPartialEq for ColorChannelModel

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<P, L> PlaneOf<&L> for P
where P: PlaneOf<L>,

Source§

type Plane = <P as PlaneOf<L>>::Plane

Source§

fn get_plane(self, layout: &&L) -> Option<<P as PlaneOf<&L>>::Plane>

Get the layout describing the plane.
Source§

impl<P, L> PlaneOf<&mut L> for P
where P: PlaneOf<L>,

Source§

type Plane = <P as PlaneOf<L>>::Plane

Source§

fn get_plane(self, layout: &&mut L) -> Option<<P as PlaneOf<&mut L>>::Plane>

Get the layout describing the plane.
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.