Table of Contents

Enum YuvMatrix

Namespace
Egami.Pixels
Assembly
Egami.dll

The matrix between RGB and luma-chroma (Y'CbCr) values, as ITU-T H.273 names them. Shared by YCbCrColor and planar YUV images, so their coefficients never disagree.

public enum YuvMatrix

Fields

Bt2020Ncl = 2

ITU-R BT.2020, non-constant luminance: Kr 0.2627, Kb 0.0593. UHD and HDR video.

Bt601 = 0

ITU-R BT.601: Kr 0.299, Kb 0.114. JPEG, and standard-definition video.

Bt709 = 1

ITU-R BT.709: Kr 0.2126, Kb 0.0722. High-definition video.

Identity = 3

No matrix: Y is green, Cb blue and Cr red, as AV1 stores lossless RGB.

Examples

// Color values in the models apps ask for, from and to pixels, and between each other.
Rgba8 orange = new(240, 128, 32, 255);
HslColor hsl = HslColor.From(orange);                          // hue 28°, saturation 0.87, lightness 0.53
LabColor lab = ColorConvert.Convert<HslColor, LabColor>(hsl);  // through XYZ
OklchColor oklch = OklchColor.From(orange);
YCbCrColor jpeg = YCbCrColor.From(orange);                     // BT.601 full range, as JPEG
YCbCrColor video = YCbCrColor.From(orange, YuvMatrix.Bt709, YuvRange.Limited);

// Color difference: CIEDE2000 on Lab, distance on Oklab.
double deltaE = lab.DeltaE2000(LabColor.From(new Rgba8(235, 130, 40, 255)));

// Whole rows at once, from any pixel type and encoding.
Rgba8[] pixels = [orange, new(10, 20, 30, 255)];
OklabColor[] row = new OklabColor[pixels.Length];
ColorConvert.FromPixels<Rgba8, OklabColor>(pixels, row);
ColorConvert.FromPixels<Rgba8, OklabColor>(pixels, row, ColorProfile.DisplayP3);   // the same pixels read as Display P3