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=1−Kb−KrKg = 1 - Kb - Kr

RGB to YPbPr​

Y=Kr⋅R+Kg⋅G+Kb⋅BPb=0.5⋅B−Y1−KbPr=0.5⋅R−Y1−Kr\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⋅(2−2Kb))⋅PbPr0=(−KrKg⋅(2−2Kr))⋅Pr R=Y+(2−2Kr)⋅PrG=Y+Pb0+Pr0B=Y+(2−2Kb)⋅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*}