Color & Display
RGB to Y′CbCr Matrix & Code-Value Calculator
Apply a selected non-constant-luminance luma/chroma matrix and quantize full- or limited-range code values.
How the calculation works
kr = 0.299 if matrix == "601" else (0.2126 if matrix == "709" else 0.2627). kb = 0.114 if matrix == "601" else (0.0722 if matrix == "709" else 0.0593). yy = green/255+kr*(red-green)/255+kb*(blue-green)/255. cb = (blue/255-yy)/(2*(1-kb)). cr = (red/255-yy)/(2*(1-kr)). scale = 2**(bits-8). maximum = 2**bits-1. Normalized luma Y′ = yy . Normalized blue-difference Cb = cb . Normalized red-difference Cr = cr . Quantized Y′ code = floor(((16+219*yy)*scale if signal_range == "limited" else yy*maximum)+0.5) code. Quantized Cb code = floor(((128+224*cb)*scale if signal_range == "limited" else (cb+0.5)*maximum)+0.5) code. Quantized Cr code = floor(((128+224*cr)*scale if signal_range == "limited" else (cr+0.5)*maximum)+0.5) code.
Worked example
Example inputs — Encoded R′ channel, 8-bit scale: 255; Encoded G′ channel, 8-bit scale: 0; Encoded B′ channel, 8-bit scale: 0; Output bit depth: 8; Matrix coefficients: 709; Output code range: limited. Expected results — Normalized luma Y′: 0.2126; Normalized blue-difference Cb: -0.1145721061; Normalized red-difference Cr: 0.5; Quantized Y′ code: 63 code; Quantized Cb code: 102 code; Quantized Cr code: 240 code.
Assumptions and limits
Mathematical color model with stated reference conventions; device calibration, viewing conditions and color-management profiles affect practical appearance. Inputs are already nonlinear R′G′B′ in the selected signal convention. Choosing matrix coefficients does not convert RGB primaries, transfer curves or reference whites. BT.2020 here is non-constant luminance only. No chroma subsampling, dithering, headroom excursions or HDR transfer decoding. Nearest-integer quantization; full-range chroma uses midpoint maximum/2 before rounding.
Reference and further reading
Read the underlying subject reference. Calculith is an independent implementation; the reference does not endorse or certify this tool.
Related calculators
- Opaque Hex Color, HSL, HSV, XYZ & Lab Converter
- WCAG Contrast Ratio & Text Threshold Calculator
- Color Mix & Alpha Composite Calculator
- CIELAB ΔE76 & CIEDE2000 Color Difference Calculator
- xyY White Coordinates, CCT & Mired Shift Calculator
Example values are editable. Results are estimates where assumptions apply. Calculations run in your browser. Updated 2026-11-16.