Image Processing Reference
In-Depth Information
X
2
=
W
X
2
·
R
+
−
W
X
2
·
W
G
1
·
G
+
−
W
X
2
·
W
B
1
·
B
(F.9)
−
W
R
−
W
R
Inserting we get the following conversion from RGB to YUV:
⎡
⎤
⎡
⎤
⎡
⎤
Y
U
V
0
.
299
0
.
587
0
.
114
R
G
B
Y
∈[
0
,
255
]
⎣
⎦
=
⎣
⎦
·
⎣
⎦
−
0
.
147
−
0
.
289
0
.
436
U
∈[−
111
,
111
]
−
−
∈[−
]
0
.
615
0
.
515
0
.
100
V
157
,
157
(F.10)
The conversion from YUV to RGB is found by rearranging Eqs.
F.1
,
F.2
, and
F.3
and inserting the weight factors as above. The equations for R and B follow trivially
by rearranging Eqs.
F.2
and
F.3
, respectively:
−
1
W
R
W
X
2
R
=
Y
+
X
2
·
(F.11)
1
W
B
W
X
1
−
B
=
Y
+
X
1
·
(F.12)
The equation for G is derived by inserting Eqs.
F.11
and
F.12
into
F.1
and rearrang-
ing:
Y
Y
1
W
R
W
X
2
−
1
W
B
W
X
1
−
Y
=
W
R
·
+
X
2
·
+
W
G
·
G
+
W
B
·
+
X
1
·
⇔
1
−
W
B
W
X
1
1
W
R
W
X
2
−
X
1
·
W
B
·
X
2
·
W
R
·
Y
·
(
1
−
W
R
−
W
B
)
G
=
−
−
⇔
W
G
W
G
W
G
W
B
·
(
1
−
W
B
)
W
X
1
·
W
G
W
R
·
(
1
−
W
R
)
W
X
2
·
W
G
G
=
Y
−
X
1
·
−
X
2
·
(F.13)
Inserting the weights for YUV yields the following conversion from YUV to RGB:
⎡
⎤
⎡
⎤
⎡
⎤
R
G
B
1
.
000
0
.
000
1
.
140
Y
U
V
R
∈[
0
,
255
]
⎣
⎦
=
⎣
⎦
·
⎣
⎦
1
.
000
−
0
.
395
−
0
.
581
G
∈[
0
,
255
]
(F.14)
1
.
000
2
.
032
0
.
000
B
∈[
0
,
255
]
F.4
YC
b
C
r
The conversion from RGB to YC
b
C
r
is found by inserting the following weights
into Eqs.
F.1
,
F.8
, and
F.9
:
W
R
=
0
.
299,
W
G
=
0
.
587,
W
B
=
0
.
114,
W
X
1
=
0
.
5, and
W
X
2
=
0
.
5
⎡
⎤
⎡
⎤
⎡
⎤
⎡
⎤
Y
C
b
C
r
0
.
299
0
.
587
0
.
114
R
G
B
0
128
128
Y
∈[
0
,
255
]
⎣
⎦
=
⎣
⎦
·
⎣
⎦
+
⎣
⎦
−
0
.
169
−
0
.
331
0
.
500
C
b
∈[
0
,
255
]
0
.
500
−
0
.
419
−
0
.
081
C
r
∈[
0
,
255
]
(F.15)