YCbCr Is a 3×3 Matrix That Halves Your Photo Size Without You Noticing
YCbCr is the invisible substrate under every compressed image and video stream a developer encounters. Knowing it as a 3×3 matrix plus an offset — rather than a black-box library call — explains why brightness adjustments clip in RGB, why chroma subsampling artifacts appear at keying edges, and when to demand 4:4:4 assets for post-production pipelines.
RGB encodes every pixel as three numbers that all carry brightness, so adjusting exposure or compressing color inevitably distorts the image. YCbCr replaces that with one luminance channel (Y) and two color-difference channels (Cb, Cr) via a fixed 3×3 matrix defined by BT.601. The Y channel is exactly the grayscale image from Section 1 of this series; the chroma channels are just scaled versions of B−Y and R−Y, offset by 128 to fit into a u8.
Once separated, the engineering payoff is immediate. Setting Cb and Cr to 128 produces a perfect grayscale image. Averaging chroma across 2×2 blocks — 4:2:0 subsampling — cuts total data in half with no visible difference, which is why every JPEG and video codec defaults to it. Adjusting only Y brightens an image without the color shift that RGB multiplication causes when channels clip at 255. And measuring Euclidean distance on the Cb-Cr plane, ignoring Y entirely, gives a green-screen keyer that handles shadows and wrinkles with a single threshold.
The inverse transform needs no memorized constants: `try_inverse()` on the forward matrix produces the textbook coefficients 1.402 and 1.772. PCA from the previous chapter also finds a grayscale axis, but YCbCr won because its axes are fixed — zero per-image overhead, universally recognized by every codec.
YCbCr and PCA both find a grayscale axis, but YCbCr won because its fixed, human-chosen constants eliminate per-image overhead and guarantee universal decoder compatibility.
The ±128 offset on Cb and Cr is a mechanical detail that causes catastrophic fluorescent output when missed, yet it's purely a storage convention to fit signed values into unsigned bytes.
Real JPEG stores subsampled chroma as a physically smaller image and interpolates on decode; the visual result is identical to the block-average-then-spread-back approach shown here, but the memory savings are real only in the former.
Chroma subsampling is lossy compression that exploits human physiology, not math — the eye's poor color spatial resolution is the only reason 4:2:0 works.