| 1 | |||
| 2 | # YUV color space specific code as in BT.601 | ||
| 3 | |||
| 4 | package Graphics::Toolkit::Color::Space::Instance::YPbPr; | ||
| 5 | 16 | ▶ | use v5.12; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 16 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 16 | ▶ | use Graphics::Toolkit::Color::Space qw/mult_matrix_vector_3/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 9 | ▶ | sub from_ypp { |
|
Subroutine
from_ypp: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 10 | 9 | my ($ypp) = shift; | |
| 11 | 9 | $ypp->[1] -= 0.5; | |
| 12 | 9 | $ypp->[2] -= 0.5; | |
| 13 | 9 | my (@rgb) = mult_matrix_vector_3([[ 1, 0 , 1.402 ], | |
| 14 | [ 1, -0.344136, -0.714136], | ||
| 15 | [ 1, 1.772 , 0 ]], @$ypp); | ||
| 16 | 9 | return \@rgb; | |
| 17 | } | ||
| 18 | 5 | ▶ | sub to_ypp { |
|
Subroutine
to_ypp: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 19 | 5 | my ($rgb) = shift; | |
| 20 | 5 | 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 | $ypp[1] += 0.5; | |
| 24 | 5 | $ypp[2] += 0.5; | |
| 25 | 5 | return \@ypp; | |
| 26 | } | ||
| 27 | 16 | 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 | ); | ||