Sub topic 15
Separating Brightness from Colour with YCbCr
Assume you understand RGB arrays, 8-bit channel values, and the difference between an image’s stored values and the colours displayed on screen. YCbCr is a colour representation commonly used for video, JPEG images, and image-processing pipelines.
The three components
YCbCr separates a pixel into:
- Y′, called luma, which represents perceived brightness.
- Cb, the blue-difference chroma component.
- Cr, the red-difference chroma component.
The prime symbol in Y′ matters. Luma is calculated from gamma-encoded RGB values such as sRGB values. It is not the same as physical luminance, which is based on linear-light values.
For 8-bit full-range BT.601-style conversion, one common formula is:
Y′ = 0.299R′ + 0.587G′ + 0.114B′
Cb = 128 - 0.168736R′ - 0.331264G′ + 0.500000B′
Cr = 128 + 0.500000R′ - 0.418688G′ - 0.081312B′The Cb and Cr values are centred around 128. A neutral grey has approximately Cb = 128 and Cr = 128. Values farther from 128 indicate stronger blue or red differences.
import numpy as np
rgb = np.array([[[255, 0, 0],
[0, 255, 0],
[0, 0, 255],
[128, 128, 128]]], dtype=np.float64)
r, g, b = rgb[..., 0], rgb[..., 1], rgb[..., 2]
y = 0.299 * r + 0.587 * g + 0.114 * b
cb = 128 - 0.168736 * r - 0.331264 * g + 0.5 * b
cr = 128 + 0.5 * r - 0.418688 * g - 0.081312 * b
ycbcr = np.stack([y, cb, cr], axis=-1).round().astype(np.uint8)
print(ycbcr)Why separate luma and chroma?
Human vision usually notices fine brightness detail more readily than fine colour detail. Image and video formats can therefore keep Y′ at full resolution while storing Cb and Cr at lower resolution. This is called chroma subsampling.
| Format | Y′ samples | Cb and Cr samples | Typical use |
|---|---|---|---|
| 4:4:4 | Full | Full | Editing and high-quality graphics |
| 4:2:2 | Full | Half horizontally | Professional video |
| 4:2:0 | Full | Half horizontally and vertically | Consumer video and streaming |
In 4:2:0, a block of four neighbouring luma samples may share one Cb sample and one Cr sample. Edges in brightness remain relatively sharp, while colour edges can become softer.
Common mistakes
- Treating Y′ as linear brightness. It is normally computed from gamma-encoded RGB.
- Confusing YCbCr with YUV. They are related representations, but their formulas and historical uses differ.
- Converting limited-range video as if it were full-range. This causes washed-out blacks or clipped highlights.
- Ignoring chroma placement when resizing or reconstructing 4:2:0 data.
Exercise
Why can 4:2:0 reduce file size while preserving much of the apparent image detail?
Show answer
It stores fewer Cb and Cr samples, while keeping the full-resolution Y′ component that carries most visible brightness detail.