Skip to main content

RGB and YPbPr

Red, Green, Blue ⇄ Luma and Sync, Blue/Luma Variance, Red/Luma Variance

Kb and Kr constants defined from target color space. This module does not currently have reference values for these.

Kg=1KbKrKg = 1 - Kb - Kr

RGB to YPbPr

Y=KrR+KgG+KbBPb=0.5BY1KbPr=0.5RY1Kr\begin{align*} Y &= Kr \cdot R + Kg \cdot G + Kb \cdot B\\ Pb &= 0.5 \cdot \frac{B - Y}{1 - Kb}\\ Pr &= 0.5 \cdot \frac{R - Y}{1 - Kr}\\ \end{align*}

YPbPr to RGB

Pb0=(KbKg(22Kb))PbPr0=(KrKg(22Kr))PrR=Y+(22Kr)PrG=Y+Pb0+Pr0B=Y+(22Kb)Pb\begin{align*} Pb_{0} &= (-\frac{Kb}{Kg} \cdot (2 - 2Kb)) \cdot Pb \\ Pr_{0} &= (-\frac{Kr}{Kg} \cdot (2 - 2Kr)) \cdot Pr \\ \:\\ R &= Y + (2 - 2Kr) \cdot Pr \\ G &= Y + Pb_{0} + Pr_{0} \\ B &= Y + (2 - 2Kb) \cdot Pb \end{align*}