| 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::YPbPr; |
|
5
|
16
|
|
|
16
|
|
270335
|
use v5.12; |
|
|
16
|
|
|
|
|
48
|
|
|
6
|
16
|
|
|
16
|
|
70
|
use warnings; |
|
|
16
|
|
|
|
|
17
|
|
|
|
16
|
|
|
|
|
754
|
|
|
7
|
16
|
|
|
16
|
|
421
|
use Graphics::Toolkit::Color::Space qw/mult_matrix_vector_3/; |
|
|
16
|
|
|
|
|
17
|
|
|
|
16
|
|
|
|
|
4265
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub from_ypp { |
|
10
|
9
|
|
|
9
|
0
|
13
|
my ($ypp) = shift; |
|
11
|
9
|
|
|
|
|
16
|
$ypp->[1] -= 0.5; |
|
12
|
9
|
|
|
|
|
10
|
$ypp->[2] -= 0.5; |
|
13
|
9
|
|
|
|
|
67
|
my (@rgb) = mult_matrix_vector_3([[ 1, 0 , 1.402 ], |
|
14
|
|
|
|
|
|
|
[ 1, -0.344136, -0.714136], |
|
15
|
|
|
|
|
|
|
[ 1, 1.772 , 0 ]], @$ypp); |
|
16
|
9
|
|
|
|
|
29
|
return \@rgb; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
sub to_ypp { |
|
19
|
5
|
|
|
5
|
0
|
6
|
my ($rgb) = shift; |
|
20
|
5
|
|
|
|
|
16
|
my (@ypp) = mult_matrix_vector_3([[ 0.299 , 0.587, 0.114 ], |
|
21
|
|
|
|
|
|
|
[-0.168736, -0.331264, 0.5 ], |
|
22
|
|
|
|
|
|
|
[ 0.5 , -0.418688, -0.081312 ]], @$rgb); |
|
23
|
5
|
|
|
|
|
10
|
$ypp[1] += 0.5; |
|
24
|
5
|
|
|
|
|
6
|
$ypp[2] += 0.5; |
|
25
|
5
|
|
|
|
|
11
|
return \@ypp; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
Graphics::Toolkit::Color::Space->new( |
|
28
|
|
|
|
|
|
|
name => 'YPbPr', |
|
29
|
|
|
|
|
|
|
alias_name => 'YUV', |
|
30
|
|
|
|
|
|
|
family => 'LAB', |
|
31
|
|
|
|
|
|
|
axis => [qw/luma Pb Pr/], # luma, cyan-orange balance, magenta-green balance |
|
32
|
|
|
|
|
|
|
short => [qw/y u v/], |
|
33
|
|
|
|
|
|
|
role => [qw/l a b/], |
|
34
|
|
|
|
|
|
|
range => [1, [-.5, .5], [-.5, .5],], |
|
35
|
|
|
|
|
|
|
convert => {RGB => [\&from_ypp, \&to_ypp]}, |
|
36
|
|
|
|
|
|
|
); |