Reputation: 321
I have read various resources that define constants for use in converting from RGB to YUV and these constants are redefined in different standards with slightly different values.
From the wiki on YCbCr
ITU-R BT.601 conversion The form of Y′CbCr that was defined for standard-definition television use in the ITU-R BT.601 (formerly CCIR 601) standard for use with digital component video is derived from the corresponding RGB space as follows:
Kr=0.299
Kg=0.587
Kb=0.114
What is the reason for this choice of these constant values? and why do they vary in other standards? as can be seen here
Upvotes: 3
Views: 675
Reputation: 51
They are calculated from RGB and Standard Illuminant xy coordinates in CIE xy chromaticity diagram.
According to Rec.601 625 - CIE xy chromaticity values are:
Wx = 0.3127; Wy = 0.3290; // White Point D65
Rx = 0.640; Ry = 0.330; // Red primary
Gx = 0.290; Gy = 0.600; // Green primary
Bx = 0.150; By = 0.060; // Blue primary
There are definitions of Yxy and XYZ colorspaces:
Y = 1.0; // maximum luminance
x + y + z = 1;
Xw = Wx / Wy; // from X = Y * x / y
Zw = Wz / Wy; // from Z = Y * z / y
Mixing of RGB primaries on xy diagram will produce some central point. RGB space requires that central point is white point. So we have to calculate RGB scaling coefficients (Ra, Rg, Rb) using below (also RGB -> XYZ transformation matrix):
Ra * Rx + Ga * Gx + Ba * Bx = Xw = Wx / Wy
Ra * Ry + Ga * Gy + Ba * By = Yw = 1
Ra * Rz + Ga * Gz + Ba * Bz = Zw = Wz / Wy
When we solve the above equations we get:
Ra = 0.9059594488629998
Ga = 0.8259453663844839
Ba = 1.4326521467778324
Which we can use to produce to RGB (Rec.601 625) -> XYZ conversion matrix:
[ Ra * Rx, Ga * Gx, Ba * Bx ]
[ Ra * Ry, Ga * Gy, Ba * By ]
[ Ra * Rz, Ga * Gz, Ba * Bz ]
And central row will contain [Kr, Kg, Kb] Y coefficients:
[ 0.2123763607050675, 0.7010598569257229, 0.08656378236920959 ]
Which are completely different from wiki on YCbCr's Kr, Kg, Kb. Because coefficients on that wiki are for SMPTE C colorspace which has:
Wx = 0.3127; Wy = 0.3290; // White Point D65
Rx = 0.630; Ry = 0.340; // Red primary
Gx = 0.310; Gy = 0.595; // Green primary
Bx = 0.155; By = 0.070; // Blue primary
And if we repeat above we get SMPTE-C's [Kr, Kg, Kb] Y coefficients:
[ 0.29896661812479, 0.5864212101329835, 0.1146121717422266 ]
Which are ones from wiki.
Upvotes: 5