
37
Converting RGB to YCRCB
The following pseudo code illustrates how to convert RGB image information into YCRCB
image information.
GREEN
,
BLUE
, Yvalue, Cvalue, and Avalue are 8 bit unsigned values,
Yhi, Ylo, Chi, Clo, Ahi, and Alo are 8 bit unsigned values,
R0, G0, B0, A0, R1, G1, B1, and A1 are floating point values,
AVGR, AVGG, and AVGB are floating point values,
Y0, Y1, CR, and CB are floating point values,
Yarray, Carray, and Aarray are arrays of 16 bit unsigned values.
for L = 0 to (Y size - 1)
for P = 0 to (Xsize - 1) step 2
get
RED
,
GREEN
,
BLUE
. and alpha value for line L, pixel P
R0 =
RED
/ 255
(floating point value between 0 and 1)
G0 =
GREEN
/ 255
(floating point value between 0 and 1)
B0 =
BLUE
/ 255
(floating point value between 0 and 1)
if (X size is odd) and (P = (Xsize - 1)) then
R1 = R0
(if image width is odd then make the
G1 = G0
image width even by adding a
B1 = B0
transparent pixel at the end of each line)
A1 = 0
else
get RED, GREEN, BLUE. and alpha value for line L, pixel P+1
R1 = RED / 255
(floating point value between 0 and 1)
G1 = GREEN / 255
(floating point value between 0 and 1)
B1 = BLUE / 255
(floating point value between 0 and 1)
end if
AVGR = (R0 + R1) / 2
(compute average color of pixel pair)
AVGG = (G0 + G1) / 2
AVGB = (B0 + B1) / 2
Y0 = 0.299 R0 + 0.587 G0 + 0.114 B0
Y1 = 0.299 R1 + 0.587 G1 + 0.114 B1
CR = 2 * (0.500 AVGR - 0.419 AVGG - 0.081 AVGB)
CB = 2 * (0.500 AVGB - 0.169 AVGR - 0.331 AVGG)
5. Files
Summary of Contents for DV2000
Page 4: ...4 ULTECH DV2000 User s Manual...
Page 8: ...8 ULTECH DV2000 User s Manual...
Page 10: ...10 ULTECH DV2000 User s Manual...
Page 16: ...16 ULTECH DV2000 User s Manual...
Page 26: ...26 ULTECH DV2000 User s Manual...