| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# CIEXYZ color space specific code for Illuminant D65 and Observer 2° |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Graphics::Toolkit::Color::Space::Instance::CIEXYZ; |
|
5
|
15
|
|
|
15
|
|
292882
|
use v5.12; |
|
|
15
|
|
|
|
|
58
|
|
|
6
|
15
|
|
|
15
|
|
98
|
use warnings; |
|
|
15
|
|
|
|
|
27
|
|
|
|
15
|
|
|
|
|
1058
|
|
|
7
|
15
|
|
|
15
|
|
734
|
use Graphics::Toolkit::Color::Space qw/mult_matrix_vector_3/; |
|
|
15
|
|
|
|
|
26
|
|
|
|
15
|
|
|
|
|
7617
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my @D65 = (0.95047, 1, 1.088830); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# change normalized RGB values to and from standard observer 2° |
|
12
|
69
|
100
|
|
69
|
0
|
308
|
sub apply_observer { $_[0] > 0.04045 ? ((($_[0] + 0.055) / 1.055 ) ** 2.4) : ($_[0] / 12.92) } |
|
13
|
54
|
100
|
|
54
|
0
|
249
|
sub remove_observer { $_[0] > 0.003131 ? ((($_[0]**(1/2.4)) * 1.055) - 0.055) : ($_[0] * 12.92) } |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub from_rgb { |
|
16
|
23
|
|
|
23
|
0
|
62
|
my ($rgb) = shift; |
|
17
|
23
|
|
|
|
|
73
|
my @rgb = map {apply_observer( $_ )} @$rgb; |
|
|
69
|
|
|
|
|
142
|
|
|
18
|
23
|
|
|
|
|
164
|
return [ mult_matrix_vector_3([[0.433949941, 0.37620977, 0.18984029], # conversion + normalisation |
|
19
|
|
|
|
|
|
|
[0.2126729, 0.7151522, 0.0721750], |
|
20
|
|
|
|
|
|
|
[0.017756583, 0.109467961, 0.872775456]], @rgb) ]; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
sub to_rgb { |
|
23
|
18
|
|
|
18
|
0
|
48
|
my ($xyz) = shift; |
|
24
|
18
|
|
|
|
|
164
|
my @rgb = mult_matrix_vector_3([[ 3.07996, -1.53714 , -0.542816 ], |
|
25
|
|
|
|
|
|
|
[ -0.921259 , 1.87601 , 0.0452475], |
|
26
|
|
|
|
|
|
|
[ 0.0528874, -0.204026, 1.15114 ]], @$xyz); |
|
27
|
18
|
|
|
|
|
103
|
return [ map { remove_observer($_) } @rgb ]; |
|
|
54
|
|
|
|
|
121
|
|
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Graphics::Toolkit::Color::Space->new( |
|
31
|
|
|
|
|
|
|
alias => 'CIEXYZ', |
|
32
|
|
|
|
|
|
|
axis => [qw/X Y Z/], |
|
33
|
|
|
|
|
|
|
range => [map {$D65[$_] * 100} 0 .. 2], |
|
34
|
|
|
|
|
|
|
precision => 3, |
|
35
|
|
|
|
|
|
|
convert => {RGB => [\&to_rgb, \&from_rgb]}, |
|
36
|
|
|
|
|
|
|
); |