| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# YUV color space specific code as in BT.601 |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Graphics::Toolkit::Color::Space::Instance::YUV; |
|
5
|
15
|
|
|
15
|
|
287030
|
use v5.12; |
|
|
15
|
|
|
|
|
62
|
|
|
6
|
15
|
|
|
15
|
|
155
|
use warnings; |
|
|
15
|
|
|
|
|
138
|
|
|
|
15
|
|
|
|
|
1058
|
|
|
7
|
15
|
|
|
15
|
|
840
|
use Graphics::Toolkit::Color::Space qw/mult_matrix_vector_3/; |
|
|
15
|
|
|
|
|
26
|
|
|
|
15
|
|
|
|
|
5271
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub from_rgb { |
|
10
|
5
|
|
|
5
|
0
|
10
|
my ($rgb) = shift; |
|
11
|
5
|
|
|
|
|
29
|
my (@yuv) = mult_matrix_vector_3([[ 0.299 , 0.587, 0.114 ], |
|
12
|
|
|
|
|
|
|
[-0.168736, -0.331264, 0.5 ], |
|
13
|
|
|
|
|
|
|
[ 0.5 , -0.418688, -0.081312 ]], @$rgb); |
|
14
|
5
|
|
|
|
|
16
|
$yuv[1] += 0.5; |
|
15
|
5
|
|
|
|
|
9
|
$yuv[2] += 0.5; |
|
16
|
5
|
|
|
|
|
18
|
return \@yuv; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
sub to_rgb { |
|
19
|
9
|
|
|
9
|
0
|
23
|
my ($yuv) = shift; |
|
20
|
9
|
|
|
|
|
49
|
$yuv->[1] -= 0.5; |
|
21
|
9
|
|
|
|
|
19
|
$yuv->[2] -= 0.5; |
|
22
|
9
|
|
|
|
|
66
|
my (@rgb) = mult_matrix_vector_3([[ 1, 0 , 1.402 ], |
|
23
|
|
|
|
|
|
|
[ 1, -0.344136, -0.714136], |
|
24
|
|
|
|
|
|
|
[ 1, 1.772 , 0 ]], @$yuv); |
|
25
|
9
|
|
|
|
|
52
|
return \@rgb; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Graphics::Toolkit::Color::Space->new( |
|
29
|
|
|
|
|
|
|
alias => 'YPbPr', |
|
30
|
|
|
|
|
|
|
axis => [qw/luma Pb Pr/], # luma, cyan-orange balance, magenta-green balance |
|
31
|
|
|
|
|
|
|
short => [qw/Y U V/], |
|
32
|
|
|
|
|
|
|
range => [1, [-.5, .5], [-.5, .5],], |
|
33
|
|
|
|
|
|
|
convert => {RGB => [\&to_rgb, \&from_rgb]}, |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|