Table of Contents

Enum ChromaSiting

Namespace
Egami.Pixels
Assembly
Egami.dll

Where each chroma sample of a subsampled picture (4:2:0, 4:2:2, 4:1:1 or 4:1:0) sits against the luma samples it covers. Conversions filter chroma to match, so colors line up with edges. Ignored for 4:4:4 and 4:0:0.

public enum ChromaSiting

Fields

Center = 0

Centered between the luma samples it covers, both ways: JPEG, VP8 and lossy WebP.

Left = 1

On the left luma column of the columns it covers and centered vertically: BT.601 and BT.709 video, MPEG-2 and later, and AV1's "vertical" position.

TopLeft = 2

On the top-left luma sample of the block it covers: BT.2020 and AV1's "colocated" position.

Examples

// How samples turn into RGB is always stated: a preset, or the codes a video container carries (ITU-T H.273).
YuvColor jpeg = YuvColor.Jpeg;                                         // BT.601, full range, chroma centered
YuvColor custom = new(YuvMatrix.Bt709, YuvRange.Full, ChromaSiting.Left);
if (YuvColor.TryFromH273(matrixCoefficients: 9, fullRange: false, ChromaSiting.TopLeft, out YuvColor fromStream))
{
    Console.WriteLine($"{fromStream.Matrix}, {fromStream.Range}; back to code {fromStream.ToH273()}");
}

// Or straight from the code points an AVIF or PNG cICP box carries.
Egami.Colors.ColorCodePoints hdr10 = new(Primaries: 9, TransferCharacteristics: 16, MatrixCoefficients: 9, FullRange: false);
hdr10.TryGetYuvColor(ChromaSiting.TopLeft, out YuvColor fromBox);