Graphics Reference
In-Depth Information
R
0.45
R
′
R
G
0.45
G
S
G
′
5
B
0.45
B
B
′
X
R
X
R
′
Y
R
′
Y
S
G
5
M
1
Y
G
′
C
B
5
M
2
G
′
S
Z
B
Z
B
′
C
R
B
′
Subsample
Y
′
C
B
C
R
Y
′
C
B
C
R
XYZ
RGB
R
′
G
′
B
′
Figure 28.25: Converting from XYZ values to Y
C
B
C
R
values. XYZ is converted to RGB by
multiplication by a matrix
M
1
; the RGB values are then nonlinearly encoded by a
0.45
power function; the resultant values are then transformed by another matrix,
M
2
, and
shifted slightly, to form Y
,
C
B
,
and C
R
,whereY
approximately represents intensity and
the other two encode chrominance information. Finally, the resultant values are digitized
by a step called the subsampling filter. Conversion to analog component video is similar,
except that the subsampling filter is replaced by band-limiting.
⎡
⎣
⎤
⎦
=
M
1
⎡
⎣
⎤
⎦
=
⎡
⎣
⎤
⎦
⎡
⎣
⎤
⎦
.
−
−
R
709
G
709
B
709
X
Y
Z
3.24
1.54
0.5
X
Y
Z
−
0.97
1.88
0.04
(28.46)
0.06
−
0.20
1.06
The conversion to
R
,
G
,
B
is very simple:
⎡
⎤
⎡
⎤
R
709
G
709
B
709
R
0.45
709
G
0.45
709
B
0.45
709
⎣
⎦
⎣
⎦
=
.
(28.47)
A second matrix operation converts the primed values into a luminance value and
two chrominance values, while adding an offset to make the chrominance values
lie in the range of 8-bit positive integers.
⎡
⎤
⎡
⎤
⎡
⎤
⎡
⎤
⎡
⎤
Y
C
B
C
R
R
709
G
709
B
709
R
709
G
709
B
709
16
128
128
65.481
128.553
24.9965
⎣
⎦
=
vM
2
⎣
⎦
=
⎣
⎦
+
⎣
⎦
⎣
⎦
−
37.797
−
74.203
112
112
−
93.786.20
−
18.214
(28.48)
As
R
,
G
, and
B
range from 0 to 1, the value
Y
ranges from 16 to 255, while
C
B
and
C
R
go from 128
112
=
14 to 128
+
112
=
240.
If you happen to have
R
,
G
, and
B
ranging from 0 to 255 (as you might in
some computer representations of images), you'll need to first scale them appro-
priately (dividing by 255) before converting using Equation 28.48.
There is another standard for video—studio video—that requires a different
transformation (albeit similar in form). Before converting to or from video, you
must know which video format is in use.
−
The RGB cube is not ideal as a color-selection tool. For one thing, with its limited
range (0 to 1 in R, G, and B) it's best suited to selecting
reflectances
in three wave-
length bands, that is, it's well suited to “material colors” but not “colored lights,”
where the intensity can be arbitrarily large. Even for selecting reflectance colors,