#[non_exhaustive]
pub enum ColorChannelModel {
    Rgb,
    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.

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.