| 1 | package ICC::Profile::cvst; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | our $VERSION = 0.31; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | # revised 2018-03-27 | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # Copyright © 2004-2018 by William B. Birkett | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | # add development directory | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use lib 'lib'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | # inherit from Shared | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 7 | ▶ | use parent qw(ICC::Shared); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | # support modules | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 7 | ▶ | use File::Glob; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 7 | ▶ | use POSIX (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 7 | ▶ | use Template; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 7 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | # create new cvst object | ||||||||||||||||||||||||||||||||||||||||||
| 25 | # array contains curve objects for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 26 | # objects must have 'transform' and 'derivative' methods | ||||||||||||||||||||||||||||||||||||||||||
| 27 | # parameters: ([ref_to_array]) | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # returns: (ref_to_object) | ||||||||||||||||||||||||||||||||||||||||||
| 29 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | # get object class | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 11 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | # create empty cvst object | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 11 | my $self = [ | |||||||||||||||||||||||||||||||||||||||||
| 36 | {}, # object header | ||||||||||||||||||||||||||||||||||||||||||
| 37 | [], # curve object array | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | # if there are parameters | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 11 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | # if one parameter, a hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 4 | ▶ | if (@_ == 1 && ref($_[0]) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and ref $_[0] eq "ARRAY"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1
ref $_[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | # make new cvst object from array | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 4 | _new_from_array($self, shift()); | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | # error | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | croak('\'cvst\' parameter must be an array reference'); | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | # bless object | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 11 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | # return object reference | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 11 | return($self); | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | # create inverse 'cvst' object | ||||||||||||||||||||||||||||||||||||||||||
| 67 | # returns: (ref_to_object) | ||||||||||||||||||||||||||||||||||||||||||
| 68 | sub inv { | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | # get object | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inv: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my ($array); | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | # for each curve object | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | # verify curve object has 'inv' method | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | ($self->[1][$i]->can('inv')) || croak('curve element lacks \'inv\' method'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | # make inverse curve object | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $array->[$i] = $self->[1][$i]->inv(); | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | return(ICC::Profile::cvst->new($array)); | |||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | # get/set reference to header hash | ||||||||||||||||||||||||||||||||||||||||||
| 93 | # parameters: ([ref_to_new_hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 94 | # returns: (ref_to_hash) | ||||||||||||||||||||||||||||||||||||||||||
| 95 | sub header { | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | # if there are parameters | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | # if one parameter, a hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if (@_ == 1 && ref($_[0]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | # set header to new hash | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $self->[0] = {%{shift()}}; | |||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | # error | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | croak('parameter must be a hash reference'); | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | # return reference | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | return($self->[0]); | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | # get/set array reference | ||||||||||||||||||||||||||||||||||||||||||
| 124 | # parameters: ([ref_to_new_array]) | ||||||||||||||||||||||||||||||||||||||||||
| 125 | # returns: (ref_to_array) | ||||||||||||||||||||||||||||||||||||||||||
| 126 | sub array { | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 65 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
array: called CC=7 SCAR=33.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | # if one parameter supplied | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 65 | ▶ | if (@_ == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | # verify array reference | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | (ref($_[0]) eq 'ARRAY') || croak('not an array reference'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | # get array reference | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $array = shift(); | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | # for each curve element | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | for my $i (0 .. $#{$array}) { | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | # verify object has processing methods | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | ($array->[$i]->can('transform') && $array->[$i]->can('derivative')) || croak('curve element lacks \'transform\' or \'derivative\' method'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$array->[$i]->can("transform") and $array->[$i]->can("derivative")
MC/DC0%0/2
$array->[$i]->can("transform") and $array->[$i]->can("derivative")
$array->[$i]->can("transform")
$array->[$i]->can("derivative")
Truth table0%0/3
A and B
A= $array->[$i]->can("transform")B= $array->[$i]->can("derivative")
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | # add curve element | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $self->[1][$i] = $array->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | } elsif (@_) { | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | # error | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | croak("too many parameters\n"); | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | # return array reference | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 65 | return($self->[1]); | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | # create cvst object from ICC profile | ||||||||||||||||||||||||||||||||||||||||||
| 164 | # assumes file handle is positoned at start of cvst data | ||||||||||||||||||||||||||||||||||||||||||
| 165 | # header information must be read separately by the calling function | ||||||||||||||||||||||||||||||||||||||||||
| 166 | # parameters: (ref_to_parent_object, file_handle, input_channels, output_channels) | ||||||||||||||||||||||||||||||||||||||||||
| 167 | # returns: (ref_to_object) | ||||||||||||||||||||||||||||||||||||||||||
| 168 | sub new_fh { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | # get object class | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | my $class = shift(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_fh: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | # create empty cvst object | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $self = [ | |||||||||||||||||||||||||||||||||||||||||
| 175 | {}, # object header | ||||||||||||||||||||||||||||||||||||||||||
| 176 | [], # curve object array | ||||||||||||||||||||||||||||||||||||||||||
| 177 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | # verify 3 parameters | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | (@_ == 3) || croak('wrong number of parameters'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | # read cvst data from profile | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | _readICCcvst($self, @_); | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | # bless object | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | # return object reference | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | # writes cvst tag object to ICC profile | ||||||||||||||||||||||||||||||||||||||||||
| 194 | # parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry) | ||||||||||||||||||||||||||||||||||||||||||
| 195 | sub write_fh { | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_fh: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | # verify 3 parameters | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | (@_ == 3) || croak('wrong number of parameters'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | # write cvst data to profile | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | _writeICCcvst($self, @_); | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | # get cvst size (for writing to profile) | ||||||||||||||||||||||||||||||||||||||||||
| 209 | # returns: (cvst_size) | ||||||||||||||||||||||||||||||||||||||||||
| 210 | sub size { | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | # get parameter | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | # get size of header and table | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $size = 12 + 8 * @{$self->[1]}; | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | # for each curve object | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | for my $crv (@{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | # add size | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $size += $crv->size(); | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | # adjust to 4-byte boundary | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $size += -$size % 4; | |||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | # return size | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | return($size); | |||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | # get number of input channels | ||||||||||||||||||||||||||||||||||||||||||
| 235 | # returns: (number) | ||||||||||||||||||||||||||||||||||||||||||
| 236 | sub cin { | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 22 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 22 | return(scalar(@{$self->[1]})); | |||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | # get number of output channels | ||||||||||||||||||||||||||||||||||||||||||
| 247 | # returns: (number) | ||||||||||||||||||||||||||||||||||||||||||
| 248 | sub cout { | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 10 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cout: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 10 | return(scalar(@{$self->[1]})); | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | # transform data | ||||||||||||||||||||||||||||||||||||||||||
| 259 | # supported input types: | ||||||||||||||||||||||||||||||||||||||||||
| 260 | # parameters: (list, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 261 | # parameters: (vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 262 | # parameters: (matrix, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # parameters: (Math::Matrix_object, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 264 | # parameters: (structure, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 265 | # returns: (same_type_as_input) | ||||||||||||||||||||||||||||||||||||||||||
| 266 | sub transform { | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | # set hash value (0 or 1) | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | my $h = ref($_[-1]) eq 'HASH' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transform: not called CC=12 SCAR=50.5
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | # if input a 'Math::Matrix' object | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if (@_ == $h + 2 && UNIVERSAL::isa($_[1], 'Math::Matrix')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
@_ == $h + 2 and UNIVERSAL::isa($_[1], "Math::Matrix")
MC/DC0%0/2
@_ == $h + 2 and UNIVERSAL::isa($_[1], "Math::Matrix")
@_ == $h + 2
UNIVERSAL::isa($_[1], "Math::Matrix")
Truth table0%0/3
A and B
A= @_ == $h + 2B= UNIVERSAL::isa($_[1], "Math::Matrix")
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | # call matrix transform | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | &_trans2; | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | # if input an array reference | ||||||||||||||||||||||||||||||||||||||||||
| 278 | ▶ | } elsif (@_ == $h + 2 && ref($_[1]) eq 'ARRAY') { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
@_ == $h + 2 and ref $_[1] eq "ARRAY"
MC/DC0%0/2
@_ == $h + 2 and ref $_[1] eq "ARRAY"
@_ == $h + 2
ref $_[1] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == $h + 2B= ref $_[1] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | # if array contains numbers (vector) | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | if (! ref($_[1][0]) && @{$_[1]} == grep {Scalar::Util::looks_like_number($_)} @{$_[1]}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not ref $_[1][0] and @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
MC/DC0%0/2
not ref $_[1][0] and @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
not ref $_[1][0]
@{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
Truth table0%0/3
not(A) and B
A= not ref $_[1][0]B= @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | # call vector transform | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | &_trans1; | |||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | # if array contains vectors (2-D array) | ||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | } elsif (ref($_[1][0]) eq 'ARRAY' && @{$_[1]} == grep {ref($_) eq 'ARRAY' && Scalar::Util::looks_like_number($_->[0])} @{$_[1]}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $_[1][0] eq "ARRAY" and @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
MC/DC0%0/2
ref $_[1][0] eq "ARRAY" and @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
ref $_[1][0] eq "ARRAY"
@{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
Truth table0%0/3
A and B
A= ref $_[1][0] eq "ARRAY"B= @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | # call matrix transform | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | &_trans2; | |||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | # call structure transform | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | &_trans3; | |||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | # if input a list (of numbers) | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | } elsif (@_ == $h + 1 + grep {Scalar::Util::looks_like_number($_)} @_) { | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | # call list transform | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | &_trans0; | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | # error | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | croak('invalid transform input'); | |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | # invert data | ||||||||||||||||||||||||||||||||||||||||||
| 315 | # supported input types: | ||||||||||||||||||||||||||||||||||||||||||
| 316 | # parameters: (list, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 317 | # parameters: (vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 318 | # parameters: (matrix, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 319 | # parameters: (Math::Matrix_object, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 320 | # parameters: (structure, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 321 | # returns: (same_type_as_input) | ||||||||||||||||||||||||||||||||||||||||||
| 322 | sub inverse { | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | # set hash value (0 or 1) | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | my $h = ref($_[-1]) eq 'HASH' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inverse: not called CC=12 SCAR=50.5
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | # if input a 'Math::Matrix' object | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | if (@_ == $h + 2 && UNIVERSAL::isa($_[1], 'Math::Matrix')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
@_ == $h + 2 and UNIVERSAL::isa($_[1], "Math::Matrix")
MC/DC0%0/2
@_ == $h + 2 and UNIVERSAL::isa($_[1], "Math::Matrix")
@_ == $h + 2
UNIVERSAL::isa($_[1], "Math::Matrix")
Truth table0%0/3
A and B
A= @_ == $h + 2B= UNIVERSAL::isa($_[1], "Math::Matrix")
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | # call matrix transform | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | &_inv2; | |||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | # if input an array reference | ||||||||||||||||||||||||||||||||||||||||||
| 334 | ▶ | } elsif (@_ == $h + 2 && ref($_[1]) eq 'ARRAY') { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
@_ == $h + 2 and ref $_[1] eq "ARRAY"
MC/DC0%0/2
@_ == $h + 2 and ref $_[1] eq "ARRAY"
@_ == $h + 2
ref $_[1] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == $h + 2B= ref $_[1] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | # if array contains numbers (vector) | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if (! ref($_[1][0]) && @{$_[1]} == grep {Scalar::Util::looks_like_number($_)} @{$_[1]}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not ref $_[1][0] and @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
MC/DC0%0/2
not ref $_[1][0] and @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
not ref $_[1][0]
@{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
Truth table0%0/3
not(A) and B
A= not ref $_[1][0]B= @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | # call vector transform | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | &_inv1; | |||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | # if array contains vectors (2-D array) | ||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | } elsif (ref($_[1][0]) eq 'ARRAY' && @{$_[1]} == grep {ref($_) eq 'ARRAY' && Scalar::Util::looks_like_number($_->[0])} @{$_[1]}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $_[1][0] eq "ARRAY" and @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
MC/DC0%0/2
ref $_[1][0] eq "ARRAY" and @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
ref $_[1][0] eq "ARRAY"
@{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
Truth table0%0/3
A and B
A= ref $_[1][0] eq "ARRAY"B= @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | # call matrix transform | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | &_inv2; | |||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | # call structure transform | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | &_inv3; | |||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | # if input a list (of numbers) | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | } elsif (@_ == $h + 1 + grep {Scalar::Util::looks_like_number($_)} @_) { | |||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | # call list transform | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | &_inv0; | |||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | # error | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | croak('invalid transform input'); | |||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | # compute Jacobian matrix | ||||||||||||||||||||||||||||||||||||||||||
| 371 | # hash key 'diag' for diagonal vector | ||||||||||||||||||||||||||||||||||||||||||
| 372 | # parameters: (input_vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 373 | # returns: (Jacobian_matrix, [output_vector]) | ||||||||||||||||||||||||||||||||||||||||||
| 374 | sub jacobian { | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jacobian: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my (@drv, $out, $jac); | |||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | # compute derivative | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $drv[$i] = $self->[1][$i]->derivative($in->[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | # compute transform | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | $out->[$i] = $self->[1][$i]->transform($in->[$i]) if wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | # if 'diag' enabled | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if ($hash->{'diag'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | # make diagonal vector | ||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $jac = [@drv]; | |||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | # make diagonal matrix | ||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $jac = Math::Matrix->diagonal(@drv); | |||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | # if output values wanted | ||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | # return Jacobian matrix and output vector | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | return($jac, $out); | |||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | # return Jacobian matrix only | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | return($jac); | |||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | # compute parametric Jacobian matrix | ||||||||||||||||||||||||||||||||||||||||||
| 422 | # note: parameters are selected by the 'slice' array | ||||||||||||||||||||||||||||||||||||||||||
| 423 | # parameters: (input_vector) | ||||||||||||||||||||||||||||||||||||||||||
| 424 | # returns: (parametric_jacobian_matrix) | ||||||||||||||||||||||||||||||||||||||||||
| 425 | sub parajac { | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | my ($self, $in) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parajac: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my ($jac, $s, @pj); | |||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | # verify curve object has '_parametric' method | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | ($self->[1][0]->can('_parametric')) || croak('parajac method not supported'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | # get slice array ref (if any) | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $s = $self->[0]{'slice'}; | |||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | # get parametric partial derivatives | ||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | @pj = $self->[1][$i]->_parametric(0, $in->[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | for my $j (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | # if current channel | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | if ($j == $i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | # if slice defined | ||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | if ($s) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | # push slice parameters on matrix row | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | push(@{$jac->[$j]}, @pj[@{$s}]); | |||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | # push all parameters on matrix row | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | push(@{$jac->[$j]}, @pj); | |||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | # if slice defined | ||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | if ($s) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | # push zeros on matrix row | ||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | push(@{$jac->[$j]}, (0) x @{$s}); | |||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | # push zeros on matrix row | ||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | push(@{$jac->[$j]}, (0) x @pj); | |||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | # return Jacobian matrix | ||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | return(bless($jac, 'Math::Matrix')); | |||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | # find min/max values | ||||||||||||||||||||||||||||||||||||||||||
| 491 | # calls the 'roots' method of any 'bern' objects | ||||||||||||||||||||||||||||||||||||||||||
| 492 | # should be called after modifying Bernstein parameters | ||||||||||||||||||||||||||||||||||||||||||
| 493 | sub roots { | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | # get parameter | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
roots: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | # call 'roots' method if a 'bern' object | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | $self->[1][$i]->roots if (UNIVERSAL::isa($_[1], 'ICC::Support::bern')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | # get 'para' or 'parf' curve parameters | ||||||||||||||||||||||||||||||||||||||||||
| 509 | # returns: (ref_to_array) | ||||||||||||||||||||||||||||||||||||||||||
| 510 | sub pars { | ||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | my $self = shift(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pars: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | my ($pars); | |||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | # for each curve | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | # verify curve is a 'para' or 'parf' object | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | (UNIVERSAL::isa($self->[1][$i], 'ICC::Profile::para') || UNIVERSAL::isa($self->[1][$i], 'ICC::Profile::parf')) || croak('curve is not a \'para\' or \'parf\' object'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
UNIVERSAL::isa($self->[1][$i], "ICC::Profile::para") or UNIVERSAL::isa($self->[1][$i], "ICC::Profile::parf")
MC/DC0%0/2
UNIVERSAL::isa($self->[1][$i], "ICC::Profile::para") or UNIVERSAL::isa($self->[1][$i], "ICC::Profile::parf")
UNIVERSAL::isa($self->[1][$i], "ICC::Profile::para")
UNIVERSAL::isa($self->[1][$i], "ICC::Profile::parf")
Truth table0%0/3
A or B
A= UNIVERSAL::isa($self->[1][$i], "ICC::Profile::para")B= UNIVERSAL::isa($self->[1][$i], "ICC::Profile::parf")
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | # copy parameters | ||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | $pars->[$i] = [@{$self->[1][$i]->array}]; | |||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | # return parameter array | ||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | return($pars); | |||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | # make new 'cvst' object containing 'curv' objects | ||||||||||||||||||||||||||||||||||||||||||
| 535 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 536 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 537 | # parameters: (number_of_table_entries, [direction]) | ||||||||||||||||||||||||||||||||||||||||||
| 538 | # returns: (cvst_object) | ||||||||||||||||||||||||||||||||||||||||||
| 539 | sub curv { | ||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | my ($self, $n, $dir) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
curv: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | my ($curv); | |||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | # create table array | ||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | $curv->[$i] = $self->[1][$i]->curv($n, $dir); | |||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | # return 'cvst' object | ||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | return(ICC::Profile::cvst->new($curv)); | |||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | # write Agfa Apogee tone curve file | ||||||||||||||||||||||||||||||||||||||||||
| 561 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 562 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 563 | # hash keys: 'dir', 'steps' | ||||||||||||||||||||||||||||||||||||||||||
| 564 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 565 | # parameters: (file_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 566 | sub apogee { | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apogee: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my ($dir, @STdot, %ink, @files); | |||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | my ($dom, $root, @obj); | |||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my ($i, @out); | |||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | # if steps are defined | ||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | if (defined($opts->{'steps'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | # set input %-dot values | ||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | @STdot = @{$opts->{'steps'}}; | |||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | # set standard 'Stimuli' %-dot values used by Apogee RIP (31-step) | ||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | @STdot = (0 .. 6, (map {5 * $_} (2 .. 18)), 94 .. 100); | |||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||
| 592 | # set ink hash | ||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | %ink = ('Cyan', 0, 'Magenta', 1, 'Yellow', 2, 'Black', 3); | |||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | # resolve file list from path | ||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | (@files = File::Glob::bsd_glob($path)) || croak('invalid file path'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | # verify file path is unique | ||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | (@files == 1) || carp('file path not unique'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | # open curve set template | ||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | eval {$dom = XML::LibXML->load_xml('location' => ICC::Shared::getICCPath('Templates/Apogee_template.xml'))} || croak('can\'t load Apogee curve template'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||
| 604 | # get the root element | ||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | $root = $dom->documentElement(); | |||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | # get the 'Curve' nodes | ||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | @obj = $root->findnodes('Curve'); | |||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | # for each 'Curve' node | ||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | for my $n (@obj) { | |||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | # look-up the color index (0 - 3) | ||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | $i = $ink{$n->getAttribute('Name')}; | |||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | # set the 'Stimuli' values | ||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | $n->setAttribute('Stimuli', join(' ', @STdot)); | |||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | # set the 'Measured' values | ||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | $n->setAttribute('Measured', join(' ', @STdot)); | |||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | # compute and set the 'Wanted' values | ||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $n->setAttribute('Wanted', join(' ', map {sprintf("%f", 100 * ($self->[1][$i]->_transform($dir, $_/100)))} @STdot)); | |||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | # compute and set the 'TransferCurve' values | ||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | $n->setAttribute('TransferCurve', join(' ', map {sprintf("%f", 100 * ($self->[1][$i]->_transform($dir, $_/255)))} (0 .. 255))); | |||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | # add namespace attribute | ||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | $root->setAttribute('xmlns', 'file:///procres'); | |||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||
| 633 | # write XML file | ||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | $dom->toFile($files[0], 1); | |||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | # write tone curves as a device link profile | ||||||||||||||||||||||||||||||||||||||||||
| 639 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 640 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 641 | # hash key: 'dir' | ||||||||||||||||||||||||||||||||||||||||||
| 642 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 643 | # parameters: (file_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 644 | sub device_link { | ||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||
| 646 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
device_link: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my ($dir, $n, @files, $sig, $clrt, $profile, $b); | |||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||
| 655 | # get number of channels | ||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | $n = @{$self->[1]}; | |||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||
| 658 | # resolve file list from path | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | (@files = File::Glob::bsd_glob($path)) || croak('invalid file path'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||
| 661 | # verify file path is unique | ||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | (@files == 1) || carp('file path not unique'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | # if grayscale | ||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | if ($n == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | # make signature | ||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | $sig = 'GRAY'; | |||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | } elsif ($n == 3) { | ||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | # make signature | ||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | $sig = 'RGB '; | |||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||
| 675 | } elsif ($n == 4) { | ||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | # make signature | ||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | $sig = 'CMYK'; | |||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||
| 680 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | # make signature | ||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | $sig = sprintf("%XCLR", $n); | |||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | # make colorant tag (could be developed further) | ||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | $clrt = ICC::Profile::clrt->new(); | |||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | } | ||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | # make device link profile object | ||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | $profile = ICC::Profile->new({'class' => 'link', 'data' => $sig, 'PCS' => $sig, 'version' => '04200000'}); | |||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | # add copyright tag | ||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | $profile->tag({'cprt' => ICC::Profile::mluc->new('en', 'US', 'Copyright (c) 2004-2018 by William B. Birkett')}); | |||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | # add description tag | ||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $profile->tag({'desc' => ICC::Profile::mluc->new('en', 'US', 'tone curves')}); | |||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | # add profile sequence tag | ||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | $profile->tag({'pseq' => ICC::Profile::pseq->new()}); | |||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | # for each curve | ||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||
| 705 | # if direction is forward and curve is an ICC::Profile object | ||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | if ($dir == 0 && (UNIVERSAL::isa($self->[1][$i], 'ICC::Profile::curv') || UNIVERSAL::isa($self->[1][$i], 'ICC::Profile::para'))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$dir == 0 and UNIVERSAL::isa($self->[1][$i], "ICC::Profile::curv") || UNIVERSAL::isa($self->[1][$i], "ICC::Profile::para")
UNIVERSAL::isa($self->[1][$i], "ICC::Profile::curv") or UNIVERSAL::isa($self->[1][$i], "ICC::Profile::para")
MC/DC0%0/3
$dir == 0 and UNIVERSAL::isa($self->[1][$i], "ICC::Profile::curv") || UNIVERSAL::isa($self->[1][$i], "ICC::Profile::para")
$dir == 0
UNIVERSAL::isa($self->[1][$i], "ICC::Profile::curv")
UNIVERSAL::isa($self->[1][$i], "ICC::Profile::para")
Truth table0%0/4
A and B or C
A= $dir == 0B= UNIVERSAL::isa($self->[1][$i], "ICC::Profile::curv")C= UNIVERSAL::isa($self->[1][$i], "ICC::Profile::para")
| |||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | # use curve object as-is | ||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | $b->[$i] = $self->[1][$i]; | |||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | # use ICC::Profile::curv equivalent | ||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | $b->[$i] = $self->[1][$i]->curv(1285, $dir); | |||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||
| 720 | # add A2B0 tag (B-curves only) | ||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | $profile->tag({'A2B0' => ICC::Profile::mAB_->new({'b_curves' => ICC::Profile::cvst->new($b)})}); | |||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||
| 723 | # add colorant tags, if nCLR | ||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | $profile->tag({'clrt' => $clrt, 'clot' => $clrt}) if (defined($clrt)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | # write profile | ||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | $profile->write($files[0]); | |||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | # write Fuji XMF tone curve file | ||||||||||||||||||||||||||||||||||||||||||
| 732 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 733 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 734 | # hash key: 'dir' | ||||||||||||||||||||||||||||||||||||||||||
| 735 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 736 | # parameters: (file_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 737 | sub fuji_xmf { | ||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fuji_xmf: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||
| 742 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | my ($dir, @XTRdot, @files, $fh, $rs, @colors, @Tdot); | |||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | # set tone curve %-dot values used by XMF RIP | ||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | @XTRdot = (0, 1, 2, 3, 4, 5, 10, 20, 25, 30, 40, 50, 60, 70, 75, 80, 90, 95, 96, 97, 98, 99, 100); | |||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | # resolve file list from path | ||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | (@files = File::Glob::bsd_glob($path)) || croak('invalid file path'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | # verify file path is unique | ||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | (@files == 1) || carp('file path not unique'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||
| 757 | # open the file | ||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | open($fh, '>', $files[0]) or croak("can't open $files[0]: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | # set output record separator (Windows CR-LF) | ||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $rs = "\015\012"; | |||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | # set color list | ||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | @colors = qw(Cyan Magenta Yellow Black); | |||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||
| 766 | # print colors | ||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | print $fh join(';', @colors), $rs; | |||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | # for each step | ||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | for my $j (0 .. 100) { | |||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||
| 772 | # if a valid dot value | ||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | ▶ | if (grep {$j == $_} @XTRdot) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||
| 775 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | for my $i (0 .. 3) { | |||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||
| 778 | # compute transformed dot value | ||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | $Tdot[$i] = sprintf("%.2f", 100 * ($self->[1][$i]->_transform($dir, $j/100))); | |||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||
| 783 | # print transformed values | ||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | print $fh join(';', @Tdot), $rs; | |||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||
| 786 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | # print empty line | ||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | print $fh '‐;‐;‐;‐', $rs; | |||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | # close the file | ||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||
| 800 | # write Harlequin tone curve file | ||||||||||||||||||||||||||||||||||||||||||
| 801 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 802 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 803 | # hash key: 'dir' | ||||||||||||||||||||||||||||||||||||||||||
| 804 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 805 | # note: values must be entered manually in Harlequin RIP | ||||||||||||||||||||||||||||||||||||||||||
| 806 | # parameters: (file_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 807 | sub harlequin { | ||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
harlequin: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||
| 812 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | my ($dir, @HQNdot, @files, $fh, $rs, @colors); | |||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||
| 815 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||
| 818 | # set tone curve %-dot values used by Harlequin RIP (they are reversed for input with Calibration Manager) | ||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | @HQNdot = (100, 95, 90, 85, 80, 70, 60, 50, 40, 30, 20, 15, 10, 8, 6, 4, 2, 0); | |||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | # resolve file list from path | ||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | ▶ | (@files = File::Glob::bsd_glob($path)) || croak('invalid file path'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||
| 824 | # verify file path is unique | ||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | (@files == 1) || carp('file path not unique'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||
| 827 | # open the file | ||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | ▶ | open($fh, '>', $files[0]) or croak("can't open $files[0]: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||
| 830 | # set output record separator (Windows CR-LF) | ||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | $rs = "\015\012"; | |||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||
| 833 | # set color list | ||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | @colors = qw(Cyan Magenta Yellow Black); | |||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||
| 836 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | for my $i (0 .. 3) { | |||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||
| 839 | # print color | ||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | print $fh "$colors[$i]$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | # for each step | ||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | for my $j (0 .. $#HQNdot) { | |||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||
| 845 | # print input and transformed values | ||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | printf $fh "%7.2f %7.2f$rs", $HQNdot[$j], 100 * ($self->[1][$i]->_transform($dir, $HQNdot[$j]/100)); | |||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | # print space | ||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | print $fh "$rs$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||
| 855 | # close the file | ||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||
| 860 | # write HP Indigo tone curve file set | ||||||||||||||||||||||||||||||||||||||||||
| 861 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 862 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 863 | # hash key: 'dir' | ||||||||||||||||||||||||||||||||||||||||||
| 864 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 865 | # parameters: (folder_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 866 | sub indigo { | ||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||
| 868 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
indigo: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||
| 871 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | my ($dir, $rs, @files, $fh, @segs, $file); | |||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | my (@CMYK, @HPdot, $steps); | |||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | my ($dotr, $dotp); | |||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||
| 876 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | # set record separator (CR-LF) | ||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | $rs = "\015\012"; | |||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||
| 882 | # resolve file list from path | ||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | ▶ | (@files = File::Glob::bsd_glob($path)) || croak('invalid file path'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||
| 885 | # verify file path is unique | ||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | ▶ | (@files == 1) || carp('file path not unique'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||
| 888 | # split the path | ||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | @segs = split(/\//, $files[0]); | |||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||
| 891 | # make the folder | ||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | mkdir($files[0]); | |||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | # ink color array (for building file names) | ||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | @CMYK = qw(Cyan Magenta Yellow Black); | |||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||
| 897 | # set tone curve device values | ||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | @HPdot = map {$_/10} (0 .. 10); | |||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||
| 900 | # get upper index | ||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | $steps = $#HPdot; | |||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||
| 903 | # for each color | ||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | for my $i (0 .. 3) { | |||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||
| 906 | # build the file path | ||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | $file = "$files[0]/tone_curve-$CMYK[$i].lut"; | |||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||
| 909 | # create the file | ||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | ▶ | open($fh, '>', $file) or croak("can't open $file: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||
| 912 | # for each step | ||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | for my $j (0 .. $steps) { | |||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | # get reference device value | ||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | $dotr = $HPdot[$j]; | |||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | # get press device value | ||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | $dotp = $self->[1][$i]->_transform($dir, $dotr); | |||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | # limit %-dot (0 - 100) | ||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | ▶ | $dotr = ($dotr < 0) ? 0 : $dotr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | ▶ | $dotp = ($dotp < 0) ? 0 : $dotp; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | ▶ | $dotr = ($dotr > 1) ? 1 : $dotr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | ▶ | $dotp = ($dotp > 1) ? 1 : $dotp; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||
| 927 | # print step info | ||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | printf $fh "%3.1f\t%6.4f$rs", $dotr, $dotp; | |||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||
| 932 | # close file | ||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||
| 935 | } | ||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||
| 939 | # write ISO 18620 tone curve file | ||||||||||||||||||||||||||||||||||||||||||
| 940 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 941 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 942 | # hash keys: 'dir', 'steps' | ||||||||||||||||||||||||||||||||||||||||||
| 943 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 944 | # parameters: (file_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 945 | sub iso_18620 { | ||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||
| 947 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iso_18620: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||
| 950 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | my ($dir, @STdot, %ink, @files); | |||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | my ($dom, $root, @obj); | |||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | my ($i, @out); | |||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||
| 955 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||
| 958 | # if steps are defined | ||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | ▶ | if (defined($opts->{'steps'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||
| 961 | # set input %-dot values | ||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | @STdot = @{$opts->{'steps'}}; | |||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||
| 964 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||
| 966 | # set default input %dot values | ||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | @STdot = (0, 1, 2, 5, (map {10 * $_} (1 .. 9)), 95, 100); | |||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||
| 971 | # set ink hash | ||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | %ink = ('Cyan', 0, 'Magenta', 1, 'Yellow', 2, 'Black', 3); | |||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||
| 974 | # resolve file list from path | ||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | ▶ | (@files = File::Glob::bsd_glob($path)) || croak('invalid file path'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||
| 977 | # verify file path is unique | ||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | ▶ | (@files == 1) || carp('file path not unique'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||
| 980 | # open curve set template | ||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | ▶ | eval {$dom = XML::LibXML->load_xml('location' => ICC::Shared::getICCPath('Templates/ISO_18620_template.xml'))} || croak('can\'t load ISO 18620 curve template'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||
| 983 | # get the root element | ||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | $root = $dom->documentElement(); | |||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||
| 986 | # get the 'TransferCurve' nodes | ||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | @obj = $root->findnodes('TransferCurve'); | |||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||
| 989 | # for each 'TransferCurve' node | ||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | for my $n (@obj) { | |||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||
| 992 | # look-up the color index (0 - 3) | ||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | $i = $ink{$n->getAttribute('Separation')}; | |||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||
| 995 | # compute and set the 'Curve' values | ||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | $n->setAttribute('Curve', join(' ', map {sprintf("%f %f", $_/100, $self->[1][$i]->_transform($dir, $_/100))} @STdot)); | |||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||
| 998 | } | ||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||
| 1000 | # add namespace attribute | ||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | $root->setAttribute('xmlns', 'http://www.npes.org/schema/ISO18620/'); | |||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||
| 1003 | # write XML file | ||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | $dom->toFile($files[0], 1); | |||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | # write Photoshop tone curve file | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | # hash keys: 'dir', 'steps' | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | # note: Photoshop curves must have between 2 and 16 points | ||||||||||||||||||||||||||||||||||||||||||
| 1014 | # parameters: (file_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | sub photoshop { | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||
| 1017 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
photoshop: not called CC=22 SCAR=62.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||
| 1020 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | my ($dir, $xval, $n, @files, $fh, $x, $y, $xmin, $xmax, $xp, @yx); | |||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||
| 1023 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||
| 1026 | # if 'steps' array supplied | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | ▶ | if (defined($opts->{'steps'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||
| 1029 | # copy step values | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | $xval = [map {$_/100} @{$opts->{'steps'}}]; | |||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||
| 1032 | # verify maximum number of curve points | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | ▶ | ($#{$xval} < 16) || croak('photoshop curve steps array has more than 16 points'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||
| 1035 | # verify minimum number of curve points | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | ($#{$xval} > 0) || croak('photoshop curve steps array has less than 2 points'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||
| 1038 | # if 'bern' curve objects | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | } elsif (UNIVERSAL::isa($self->[1][0], 'ICC::Support::bern')) { | ||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||
| 1041 | # compute array upper index | ||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | ▶ | $n = ($#{$self->[1][0][1][0]} > $#{$self->[1][0][1][1]}) ? $#{$self->[1][0][1][0]} : $#{$self->[1][0][1][1]}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||
| 1044 | # make x-value array | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | $xval = [map {$_/$n} (0 .. $n)]; | |||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||
| 1047 | # if 'akima' curve objects | ||||||||||||||||||||||||||||||||||||||||||
| 1048 | } elsif (UNIVERSAL::isa($self->[1][0], 'ICC::Support::akima')) { | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||
| 1050 | # compute upper index | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | ▶ | $n = $#{$self->[1][0][1]} < 16 ? $#{$self->[1][0][1]} : 15; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||
| 1053 | # make x-value array | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | $xval = [map {$_/$n} (0 .. $n)]; | |||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||
| 1056 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||
| 1058 | # use default array (5 points) | ||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | $xval = [map {$_/4} (0 .. 4)]; | |||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||
| 1061 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||
| 1063 | # sort the x-values from low to high | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | @{$xval} = sort {$a <=> $b} @{$xval}; | |||||||||||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||||||||||||
| 1066 | # resolve file list from path | ||||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | ▶ | (@files = File::Glob::bsd_glob($path)) || croak('invalid file path'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||
| 1069 | # verify file path is unique | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | ▶ | (@files == 1) || carp('file path not unique'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||
| 1072 | # open the file | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | ▶ | open($fh, '>', $files[0]) or croak("can't open $files[0]: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||||||||||
| 1075 | # set binary mode | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | 0 | binmode($fh); | |||||||||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||||||||||
| 1078 | # print the version and number of curves (including master curve) | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | 0 | print $fh pack('n2', 4, scalar(@{$self->[1]}) + 1); | |||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||
| 1081 | # print null master curve | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | 0 | print $fh pack('n5', 2, 0, 0, 255, 255); | |||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||
| 1084 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||
| 1087 | # compute min and max x-values (correspond to y-values of 0 and 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | $xmin = $self->[1][$i]->_transform((1 - $dir), 0); | |||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | $xmax = $self->[1][$i]->_transform((1 - $dir), 1); | |||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||
| 1091 | # swap min and max if negative curve | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | ▶ | ($xmax, $xmin) = ($xmin, $xmax) if ($xmin > $xmax); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||
| 1094 | # initialize point array | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | @yx = (); | |||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||
| 1097 | # initialize previous x-value | ||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | $xp = -1; | |||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||
| 1100 | # for each point | ||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | for my $j (0 .. $#{$xval}) { | |||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||
| 1103 | # get x-value | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | $x = $xval->[$j]; | |||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||
| 1106 | # limit x-value (previously limited domain 0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | ▶ | $x = $x > $xmax ? $xmax : ($x < $xmin ? $xmin : $x); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||
| 1109 | # skip if x-value same as previous | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | ▶ | next if ($x == $xp); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||
| 1112 | # set previous x-value | ||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | $xp = $x; | |||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||
| 1115 | # get y-value | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | 0 | $y = $self->[1][$i]->_transform($dir, $x); | |||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||
| 1118 | # limit y-value | ||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | ▶ | $y = $y > 1 ? 1 : ($y < 0 ? 0 : $y); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||||||||
| 1121 | # push y-x pair on array (Photoshop curve points are [output, input]) | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | push(@yx, [$y, $x]); | |||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||
| 1124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||
| 1126 | # print number of points | ||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | print $fh pack('n', scalar(@yx)); | |||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||
| 1129 | # if 3 channels (RGB) | ||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | ▶ | if (@{$self->[1]} == 3) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||
| 1132 | # for each point | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | for (@yx) { | |||||||||||||||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||||||||||||||||
| 1135 | # print point value (y, x), normal for RGB | ||||||||||||||||||||||||||||||||||||||||||
| 1136 | 0 | print $fh pack('n2', map {255 * $_ + 0.5} @{$_}); | |||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||
| 1138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||
| 1140 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||
| 1142 | # for each point (in reverse order) | ||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | for (reverse(@yx)) { | |||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||
| 1145 | # print point value (y, x), complemented for Grayscale, CMYK, Multichannel | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | print $fh pack('n2', map {255 * (1 - $_) + 0.5} @{$_}); | |||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||
| 1148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||
| 1150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||
| 1152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||
| 1154 | # close the file | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 1156 | |||||||||||||||||||||||||||||||||||||||||||
| 1157 | # set file creator and type (OS X only) | ||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | ICC::Shared::setFile($files[0], '8BIM', '8BSC'); | |||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||
| 1160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||
| 1162 | # write Prinergy (Harmony) tone curve file | ||||||||||||||||||||||||||||||||||||||||||
| 1163 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1164 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 1165 | # hash keys: 'dir', 'Comments', 'CurveSet', 'DefaultFrequency', 'DefaultMedium', | ||||||||||||||||||||||||||||||||||||||||||
| 1166 | # 'DefaultResolution', 'DefaultSpotFunction', 'Enabled', 'FirstName', 'FreqFrom', | ||||||||||||||||||||||||||||||||||||||||||
| 1167 | # 'FreqTo', 'FrequencyUsed', 'ID', 'Medium', 'MediumUsed', 'Resolution', | ||||||||||||||||||||||||||||||||||||||||||
| 1168 | # 'ResolutionUsed', 'ScreeningType', 'ScreeningTypeUsed', 'SpotFunction', | ||||||||||||||||||||||||||||||||||||||||||
| 1169 | # 'SpotFunctionMode', 'SpotFunctionUsed' | ||||||||||||||||||||||||||||||||||||||||||
| 1170 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 1171 | # parameters: (file_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | sub prinergy { | ||||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||
| 1174 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prinergy: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||
| 1177 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | 0 | my ($dir, $prinergy, $key); | |||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | my (@files, $fh, @time, $time, @month, $datetime); | |||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | my ($rs, @colors, @map, $up); | |||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||
| 1182 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 1183 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||
| 1185 | # read prinergy hash template | ||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | $prinergy = YAML::Tiny->read(ICC::Shared::getICCPath('Preferences/Prinergy.yml'))->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||
| 1188 | # for each hash key | ||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | for my $key (keys(%{$prinergy})) { | |||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||
| 1191 | # set to options value, if defined | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | 0 | ▶ | $prinergy->{$key} = $opts->{$key} if (defined($opts->{$key})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||
| 1194 | # set undefined values to null string | ||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | ▶ | $prinergy->{$key} = '' if (! defined($prinergy->{$key})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||
| 1199 | # resolve file list from path | ||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | ▶ | (@files = File::Glob::bsd_glob($path)) || croak('invalid file path'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||
| 1202 | # verify file path is unique | ||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | ▶ | (@files == 1) || carp('file path not unique'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||
| 1205 | # open the file | ||||||||||||||||||||||||||||||||||||||||||
| 1206 | 0 | ▶ | open($fh, '>', $files[0]) or croak("can't open $files[0]: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||
| 1208 | # set file creator and type (Windows NT SFM values) | ||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | ICC::Shared::setFile($files[0], 'LMAN', 'TEXT'); | |||||||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||||||||
| 1211 | # get the time | ||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | @time = localtime(time); | |||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||
| 1214 | # print time as string | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | $time = sprintf "%d/%d/%d %2.2d:%2.2d:%2.2d", $time[4]+1, $time[3], $time[5]+1900, $time[2], $time[1], $time[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||
| 1217 | # make array of months | ||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | @month = qw(January February March April May June July August September October November December); | |||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||
| 1220 | # print datetime as string | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | $datetime = sprintf "%2.2d %s %d %2.2d:%2.2d:%2.2d", $time[3], $month[$time[4]], $time[5]+1900, $time[2], $time[1], $time[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||
| 1223 | # Windows record separator (CR-LF) | ||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | $rs = "\015\012"; | |||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||
| 1226 | # print Prinergy header | ||||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | print $fh ";Creo Harmony Database File$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | print $fh ";1.07$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | print $fh ";$time$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | print $fh ";Next Calibration ID = 0001$rs$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||
| 1232 | # print 'transfer' table info | ||||||||||||||||||||||||||||||||||||||||||
| 1233 | printf $fh "[ E %s, %s %s %s %s %s ]$rs", $prinergy->{'FirstName'}, $prinergy->{'DefaultMedium'}, 'CMYK', | ||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | $prinergy->{'DefaultSpotFunction'}, $prinergy->{'DefaultFrequency'}, $prinergy->{'DefaultResolution'}; | |||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | print $fh "FirstName = $prinergy->{'FirstName'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | print $fh "ID = $prinergy->{'ID'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1237 | 0 | print $fh "Enabled = $prinergy->{'Enabled'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1238 | 0 | print $fh "CurveSet = $prinergy->{'CurveSet'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | print $fh "DateTime = $datetime$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1240 | 0 | printf $fh "Time = %d$rs", time; | |||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | print $fh "MediumUsed = $prinergy->{'MediumUsed'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | print $fh "Medium = $prinergy->{'Medium'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | print $fh "ScreeningTypeUsed = $prinergy->{'ScreeningTypeUsed'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | print $fh "ScreeningType = $prinergy->{'ScreeningType'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | print $fh "ResolutionUsed = $prinergy->{'ResolutionUsed'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | print $fh "Resolution = $prinergy->{'Resolution'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | print $fh "FrequencyUsed = $prinergy->{'FrequencyUsed'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | print $fh "FreqFrom = $prinergy->{'FreqFrom'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | print $fh "FreqTo = $prinergy->{'FreqTo'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | print $fh "SpotFunctionUsed = $prinergy->{'SpotFunctionUsed'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | print $fh "SpotFunction = $prinergy->{'SpotFunction'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | print $fh "SpotFunctionMode = $prinergy->{'SpotFunctionMode'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | print $fh "DefaultMedium = $prinergy->{'DefaultMedium'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | print $fh "DefaultResolution = $prinergy->{'DefaultResolution'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | print $fh "DefaultFrequency = $prinergy->{'DefaultFrequency'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | print $fh "DefaultSpotFunction = $prinergy->{'DefaultSpotFunction'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||||||||||||||||
| 1258 | # set color names | ||||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | @colors = qw(Cyan Magenta Yellow Black); | |||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||
| 1261 | # set color map (KCMY) | ||||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | @map = (3, 0, 1, 2); | |||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||
| 1264 | # set upper index (number of curve points - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | $up = 100; | |||||||||||||||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||||||||||||||||
| 1267 | # for each curve | ||||||||||||||||||||||||||||||||||||||||||
| 1268 | 0 | for my $i (0 .. 3) { | |||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||
| 1270 | # print curve dropoff | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | printf $fh "Curve%d DropOff = %d$rs", $i + 1, 0; | |||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||
| 1273 | # print curve color | ||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | printf $fh "Curve%d Color = %s$rs", $i + 1, $colors[$map[$i]]; | |||||||||||||||||||||||||||||||||||||||||
| 1275 | |||||||||||||||||||||||||||||||||||||||||||
| 1276 | # print curve start | ||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | printf $fh "Curve%d = ", $i + 1; | |||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||
| 1279 | # print curve points | ||||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | for my $j (0 .. $up) { | |||||||||||||||||||||||||||||||||||||||||
| 1281 | |||||||||||||||||||||||||||||||||||||||||||
| 1282 | # print curve values | ||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | printf $fh "%d %d ", 1E7 * $j/$up + 0.5, 1E7 * $self->[1][$map[$i]]->_transform($dir, $j/$up) + 0.5; | |||||||||||||||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||||||||||||||||
| 1285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||
| 1287 | # print curve end | ||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | print $fh "$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1289 | |||||||||||||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||
| 1292 | # print trailing comments | ||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | print $fh "Comments = $prinergy->{'Comments'}$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1294 | 0 | print $fh "$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||
| 1296 | # close the file | ||||||||||||||||||||||||||||||||||||||||||
| 1297 | 0 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||
| 1299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||
| 1301 | # write Rampage tone curve file set | ||||||||||||||||||||||||||||||||||||||||||
| 1302 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1303 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 1304 | # hash key: 'dir' | ||||||||||||||||||||||||||||||||||||||||||
| 1305 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 1306 | # parameters: (folder_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 1307 | sub rampage { | ||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||
| 1309 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1310 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rampage: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||||||||||||||||
| 1312 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | my ($dir, $rs, @files, $fh0, $fh1, @segs, $folder, $file); | |||||||||||||||||||||||||||||||||||||||||
| 1314 | 0 | my (@CMYK, @RAMdot, $steps); | |||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | my ($dotr, $dotp); | |||||||||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||||||||||
| 1317 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 1318 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||||||||||||||||
| 1320 | # set record separator (CR-LF) | ||||||||||||||||||||||||||||||||||||||||||
| 1321 | 0 | $rs = "\015\012"; | |||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||
| 1323 | # resolve file list from path | ||||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | ▶ | (@files = File::Glob::bsd_glob($path)) || croak('invalid file path'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||
| 1326 | # verify file path is unique | ||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | ▶ | (@files == 1) || carp('file path not unique'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||
| 1329 | # split the path | ||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | @segs = split(/\//, $files[0]); | |||||||||||||||||||||||||||||||||||||||||
| 1331 | |||||||||||||||||||||||||||||||||||||||||||
| 1332 | # get the folder name | ||||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | $folder = $segs[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||
| 1335 | # make the folder | ||||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | mkdir($files[0]); | |||||||||||||||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||||||||||||||||
| 1338 | # ink color array (for building file names) | ||||||||||||||||||||||||||||||||||||||||||
| 1339 | 0 | @CMYK = qw(C M Y K); | |||||||||||||||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||||||||||||||||
| 1341 | # set tone curve %-dot values | ||||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | @RAMdot = (0, 1, 3, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 97, 99, 100); | |||||||||||||||||||||||||||||||||||||||||
| 1343 | |||||||||||||||||||||||||||||||||||||||||||
| 1344 | # get upper index | ||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | $steps = $#RAMdot; | |||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||
| 1347 | # for each color | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | for my $i (0 .. 3) { | |||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||
| 1350 | # build the DESIRED file path | ||||||||||||||||||||||||||||||||||||||||||
| 1351 | 0 | $file = $files[0] . '/' . $folder . '_DESIRED_' . $CMYK[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||
| 1353 | # create the DESIRED file | ||||||||||||||||||||||||||||||||||||||||||
| 1354 | 0 | ▶ | open($fh0, '>', $file) or croak("can't open $file: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||
| 1356 | # set file creator and type | ||||||||||||||||||||||||||||||||||||||||||
| 1357 | 0 | ICC::Shared::setFile($file, 'RamC', 'Clst'); | |||||||||||||||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||||||||||||||||
| 1359 | # build the ACT file path | ||||||||||||||||||||||||||||||||||||||||||
| 1360 | 0 | $file = $files[0] . '/' . $folder . '_ACT_' . $CMYK[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||
| 1362 | # create the ACT file | ||||||||||||||||||||||||||||||||||||||||||
| 1363 | 0 | ▶ | open($fh1, '>', $file) or croak("can't open $file: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||||||||||||||||
| 1365 | # set file creator and type | ||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | ICC::Shared::setFile($file, 'RamC', 'Clst'); | |||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||
| 1368 | # print DESIRED header | ||||||||||||||||||||||||||||||||||||||||||
| 1369 | 0 | print $fh0 "2$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | print $fh0 "0.0000000000$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1371 | 0 | print $fh0 "0.0000000000$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1372 | 0 | printf $fh0 "%2d$rs", $steps + 1; | |||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||
| 1374 | # print ACT header | ||||||||||||||||||||||||||||||||||||||||||
| 1375 | 0 | print $fh1 "2$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1376 | 0 | print $fh1 "0.0000000000$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1377 | 0 | print $fh1 "0.0000000000$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | printf $fh1 "%2d$rs", $steps + 1; | |||||||||||||||||||||||||||||||||||||||||
| 1379 | |||||||||||||||||||||||||||||||||||||||||||
| 1380 | # for each step | ||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | for my $j (0 .. $steps) { | |||||||||||||||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||||||||||||||||
| 1383 | # get reference %-dot | ||||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | $dotr = $RAMdot[$j]; | |||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||
| 1386 | # get press %-dot | ||||||||||||||||||||||||||||||||||||||||||
| 1387 | 0 | $dotp = 100 * $self->[1][$i]->_transform($dir, $dotr/100); | |||||||||||||||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||||||||||||||||
| 1389 | # limit %-dot (0 - 100) | ||||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | ▶ | $dotr = ($dotr < 0) ? 0 : $dotr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1391 | 0 | ▶ | $dotp = ($dotp < 0) ? 0 : $dotp; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | ▶ | $dotr = ($dotr > 100) ? 100 : $dotr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | ▶ | $dotp = ($dotp > 100) ? 100 : $dotp; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||
| 1395 | # print DESIRED step info | ||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | printf $fh0 "%3.1f %3.1f$rs", $dotr, $dotp; | |||||||||||||||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||||||||||||||||
| 1398 | # print ACT step info | ||||||||||||||||||||||||||||||||||||||||||
| 1399 | 0 | printf $fh1 "%3.1f %3.1f$rs", $dotr, $dotr; | |||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||
| 1401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||||||||||||||||
| 1403 | # print DESIRED footer | ||||||||||||||||||||||||||||||||||||||||||
| 1404 | 0 | print $fh0 "Version: 2.0$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||||||||||||||||
| 1406 | # print ACT footer | ||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | print $fh1 "Version: 2.0$rs"; | |||||||||||||||||||||||||||||||||||||||||
| 1408 | |||||||||||||||||||||||||||||||||||||||||||
| 1409 | # close the DESIRED file | ||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | close($fh0); | |||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||
| 1412 | # close the ACT file | ||||||||||||||||||||||||||||||||||||||||||
| 1413 | 0 | close($fh1); | |||||||||||||||||||||||||||||||||||||||||
| 1414 | |||||||||||||||||||||||||||||||||||||||||||
| 1415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||
| 1417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||||||||||||||||
| 1419 | # write Trueflow tone curve file | ||||||||||||||||||||||||||||||||||||||||||
| 1420 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1421 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 1422 | # hash key: 'dir' | ||||||||||||||||||||||||||||||||||||||||||
| 1423 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 1424 | # parameters: (file_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 1425 | sub trueflow { | ||||||||||||||||||||||||||||||||||||||||||
| 1426 | |||||||||||||||||||||||||||||||||||||||||||
| 1427 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1428 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trueflow: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||
| 1430 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | my ($dir, @names, @colors, @map, @TFdot); | |||||||||||||||||||||||||||||||||||||||||
| 1432 | 0 | my (@files, $fh, $in, $out, $dg, @lut, $float); | |||||||||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||||||||||
| 1434 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||
| 1437 | # set curve names | ||||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | @names = qw(Y M C K); | |||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||
| 1440 | # set curve display colors (YMCK) | ||||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | @colors = (0x00ffff, 0xff00ff, 0xffff00, 0x000000); | |||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||
| 1443 | # set color map (YMCK) | ||||||||||||||||||||||||||||||||||||||||||
| 1444 | 0 | @map = (2, 1, 0, 3); | |||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||
| 1446 | # set tone curve %-dot values | ||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | @TFdot = (0, 2, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 98, 100); | |||||||||||||||||||||||||||||||||||||||||
| 1448 | |||||||||||||||||||||||||||||||||||||||||||
| 1449 | # resolve file list from path | ||||||||||||||||||||||||||||||||||||||||||
| 1450 | 0 | ▶ | (@files = File::Glob::bsd_glob($path)) || croak('invalid file path'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||
| 1452 | # verify file path is unique | ||||||||||||||||||||||||||||||||||||||||||
| 1453 | 0 | ▶ | (@files == 1) || carp('file path not unique'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||||||||||||
| 1455 | # open the file | ||||||||||||||||||||||||||||||||||||||||||
| 1456 | 0 | ▶ | open($fh, '>', $files[0]) or croak("can't open $files[0]: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||
| 1458 | # set binary mode | ||||||||||||||||||||||||||||||||||||||||||
| 1459 | 0 | binmode($fh); | |||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||
| 1461 | # print the header | ||||||||||||||||||||||||||||||||||||||||||
| 1462 | 0 | print $fh pack('C4a4', 4, 3, 2, 1, 'DGT'); # file signature | |||||||||||||||||||||||||||||||||||||||||
| 1463 | 0 | print $fh pack('V', 256); # offset to first curve | |||||||||||||||||||||||||||||||||||||||||
| 1464 | 0 | print $fh pack('V', 100); # | |||||||||||||||||||||||||||||||||||||||||
| 1465 | 0 | print $fh pack('V', 4); # number of curves | |||||||||||||||||||||||||||||||||||||||||
| 1466 | 0 | print $fh pack('V4', 640, 640, 640, 640); # curve block sizes | |||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||
| 1468 | # seek start of first curve | ||||||||||||||||||||||||||||||||||||||||||
| 1469 | 0 | seek($fh, 256, 0); | |||||||||||||||||||||||||||||||||||||||||
| 1470 | |||||||||||||||||||||||||||||||||||||||||||
| 1471 | # loop thru colors (0-3) (YMCK) | ||||||||||||||||||||||||||||||||||||||||||
| 1472 | 0 | for my $i (0 .. 3) { | |||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||
| 1474 | # print curve name | ||||||||||||||||||||||||||||||||||||||||||
| 1475 | 0 | print $fh pack('a128', $names[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 1476 | |||||||||||||||||||||||||||||||||||||||||||
| 1477 | # print display color | ||||||||||||||||||||||||||||||||||||||||||
| 1478 | 0 | print $fh pack('V', $colors[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||||||||||
| 1480 | # print curve parameters (LUT_size, dot_gain_steps, dot_gain_table_size) | ||||||||||||||||||||||||||||||||||||||||||
| 1481 | 0 | print $fh pack('V3', 256, 15, 240); | |||||||||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||||||||||
| 1483 | # print binary LUT | ||||||||||||||||||||||||||||||||||||||||||
| 1484 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1485 | # for each step | ||||||||||||||||||||||||||||||||||||||||||
| 1486 | 0 | for my $j (0 .. 255) { | |||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||
| 1488 | # compute output value | ||||||||||||||||||||||||||||||||||||||||||
| 1489 | 0 | $out = $self->[1][$map[$i]]->_transform($dir, $j/255); | |||||||||||||||||||||||||||||||||||||||||
| 1490 | |||||||||||||||||||||||||||||||||||||||||||
| 1491 | # print LUT value (limited and rounded) | ||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | ▶ | print $fh pack('C', 255 * ($out < 0 ? 0 : ($out > 1 ? 1 : $out)) + 0.5); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||||||||||||||||
| 1494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||||||||||||
| 1496 | # print dot gain table | ||||||||||||||||||||||||||||||||||||||||||
| 1497 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1498 | # for each tone curve step | ||||||||||||||||||||||||||||||||||||||||||
| 1499 | 0 | for my $j (0 .. $#TFdot) { | |||||||||||||||||||||||||||||||||||||||||
| 1500 | |||||||||||||||||||||||||||||||||||||||||||
| 1501 | # compute input value | ||||||||||||||||||||||||||||||||||||||||||
| 1502 | 0 | $in = $TFdot[$j]/100; | |||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||
| 1504 | # compute output value | ||||||||||||||||||||||||||||||||||||||||||
| 1505 | 0 | $out = $self->[1][$map[$i]]->_transform($dir, $in); | |||||||||||||||||||||||||||||||||||||||||
| 1506 | |||||||||||||||||||||||||||||||||||||||||||
| 1507 | # compute dot gain (rounded to 0.1%) | ||||||||||||||||||||||||||||||||||||||||||
| 1508 | 0 | $dg = POSIX::floor(1000 * ($out - $in) + 0.5)/10; | |||||||||||||||||||||||||||||||||||||||||
| 1509 | |||||||||||||||||||||||||||||||||||||||||||
| 1510 | # print dot gain value (little-endian double) | ||||||||||||||||||||||||||||||||||||||||||
| 1511 | 0 | print $fh pack('C2 x6 d<', $TFdot[$j], 1, $dg); | |||||||||||||||||||||||||||||||||||||||||
| 1512 | |||||||||||||||||||||||||||||||||||||||||||
| 1513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||
| 1515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||
| 1517 | # close the file | ||||||||||||||||||||||||||||||||||||||||||
| 1518 | 0 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 1519 | |||||||||||||||||||||||||||||||||||||||||||
| 1520 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1521 | |||||||||||||||||||||||||||||||||||||||||||
| 1522 | # write Xitron Sierra tone curve file | ||||||||||||||||||||||||||||||||||||||||||
| 1523 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1524 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 1525 | # hash key: 'dir' | ||||||||||||||||||||||||||||||||||||||||||
| 1526 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 1527 | # parameters: (file_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 1528 | sub xitron { | ||||||||||||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||||||||||||
| 1530 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1531 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xitron: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1532 | |||||||||||||||||||||||||||||||||||||||||||
| 1533 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 1534 | 0 | my ($dir, @XTRdot, @files, $fh, $rs, @colors, @Tdot); | |||||||||||||||||||||||||||||||||||||||||
| 1535 | |||||||||||||||||||||||||||||||||||||||||||
| 1536 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 1537 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 1538 | |||||||||||||||||||||||||||||||||||||||||||
| 1539 | # set tone curve %-dot values used by Xitron RIP | ||||||||||||||||||||||||||||||||||||||||||
| 1540 | 0 | @XTRdot = (0, 1, 2, 3, 4, 5, 10, 20, 25, 30, 40, 50, 60, 70, 75, 80, 90, 95, 96, 97, 98, 99, 100); | |||||||||||||||||||||||||||||||||||||||||
| 1541 | |||||||||||||||||||||||||||||||||||||||||||
| 1542 | # resolve file list from path | ||||||||||||||||||||||||||||||||||||||||||
| 1543 | 0 | ▶ | (@files = File::Glob::bsd_glob($path)) || croak('invalid file path'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||||||||||||||||
| 1545 | # verify file path is unique | ||||||||||||||||||||||||||||||||||||||||||
| 1546 | 0 | ▶ | (@files == 1) || carp('file path not unique'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||||||||||||||||
| 1548 | # open the file | ||||||||||||||||||||||||||||||||||||||||||
| 1549 | 0 | ▶ | open($fh, '>', $files[0]) or croak("can't open $files[0]: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||
| 1551 | # set output record separator (Windows CR-LF) | ||||||||||||||||||||||||||||||||||||||||||
| 1552 | 0 | $rs = "\015\012"; | |||||||||||||||||||||||||||||||||||||||||
| 1553 | |||||||||||||||||||||||||||||||||||||||||||
| 1554 | # set color list | ||||||||||||||||||||||||||||||||||||||||||
| 1555 | 0 | @colors = qw(Cyan Magenta Yellow Black); | |||||||||||||||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||||||||||||||||
| 1557 | # print colors | ||||||||||||||||||||||||||||||||||||||||||
| 1558 | 0 | print $fh join(';', @colors), $rs; | |||||||||||||||||||||||||||||||||||||||||
| 1559 | |||||||||||||||||||||||||||||||||||||||||||
| 1560 | # for each step | ||||||||||||||||||||||||||||||||||||||||||
| 1561 | 0 | for my $j (0 .. $#XTRdot) { | |||||||||||||||||||||||||||||||||||||||||
| 1562 | |||||||||||||||||||||||||||||||||||||||||||
| 1563 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 1564 | 0 | for my $i (0 .. 3) { | |||||||||||||||||||||||||||||||||||||||||
| 1565 | |||||||||||||||||||||||||||||||||||||||||||
| 1566 | # compute transformed dot value | ||||||||||||||||||||||||||||||||||||||||||
| 1567 | 0 | $Tdot[$i] = sprintf("%.4f", 100 * ($self->[1][$i]->_transform($dir, $XTRdot[$j]/100))); | |||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||
| 1569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||||||||||||||||
| 1571 | # print transformed values | ||||||||||||||||||||||||||||||||||||||||||
| 1572 | 0 | print $fh join(';', @Tdot), $rs; | |||||||||||||||||||||||||||||||||||||||||
| 1573 | |||||||||||||||||||||||||||||||||||||||||||
| 1574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||||||||||||||||
| 1576 | # close the file | ||||||||||||||||||||||||||||||||||||||||||
| 1577 | 0 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 1578 | |||||||||||||||||||||||||||||||||||||||||||
| 1579 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||||||||||||||||
| 1581 | # write tab delimited text tone curve file | ||||||||||||||||||||||||||||||||||||||||||
| 1582 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1583 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 1584 | # hash keys: 'dir', 'steps' | ||||||||||||||||||||||||||||||||||||||||||
| 1585 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 1586 | # parameters: (file_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 1587 | sub text { | ||||||||||||||||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||||||||||||||||
| 1589 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1590 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
text: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1591 | |||||||||||||||||||||||||||||||||||||||||||
| 1592 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 1593 | 0 | my ($dir, @XTRdot, $fp, @files, $fh, $rs, @Tdot); | |||||||||||||||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||||||||||||||||
| 1595 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 1596 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||||||||||||||||
| 1598 | # if 'steps' are defined | ||||||||||||||||||||||||||||||||||||||||||
| 1599 | 0 | ▶ | if (defined($opts->{'steps'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1600 | |||||||||||||||||||||||||||||||||||||||||||
| 1601 | # copy step values | ||||||||||||||||||||||||||||||||||||||||||
| 1602 | 0 | @XTRdot = @{$opts->{'steps'}}; | |||||||||||||||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||||||||||||||||
| 1604 | # check for non-integer values | ||||||||||||||||||||||||||||||||||||||||||
| 1605 | 0 | $fp = grep {int($_) != $_} @XTRdot; | |||||||||||||||||||||||||||||||||||||||||
| 1606 | |||||||||||||||||||||||||||||||||||||||||||
| 1607 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1608 | |||||||||||||||||||||||||||||||||||||||||||
| 1609 | # set default input %-dot values | ||||||||||||||||||||||||||||||||||||||||||
| 1610 | 0 | @XTRdot = map {$_ * 5} (0 .. 20); | |||||||||||||||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||||||||||||||||
| 1612 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1613 | |||||||||||||||||||||||||||||||||||||||||||
| 1614 | # resolve file list from path | ||||||||||||||||||||||||||||||||||||||||||
| 1615 | 0 | ▶ | (@files = File::Glob::bsd_glob($path)) || croak('invalid file path'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1616 | |||||||||||||||||||||||||||||||||||||||||||
| 1617 | # verify file path is unique | ||||||||||||||||||||||||||||||||||||||||||
| 1618 | 0 | ▶ | (@files == 1) || carp('file path not unique'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1619 | |||||||||||||||||||||||||||||||||||||||||||
| 1620 | # open the file | ||||||||||||||||||||||||||||||||||||||||||
| 1621 | 0 | ▶ | open($fh, '>', $files[0]) or croak("can't open $files[0]: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||
| 1623 | # set output record separator (Windows CR-LF) | ||||||||||||||||||||||||||||||||||||||||||
| 1624 | 0 | $rs = "\015\012"; | |||||||||||||||||||||||||||||||||||||||||
| 1625 | |||||||||||||||||||||||||||||||||||||||||||
| 1626 | # for each step | ||||||||||||||||||||||||||||||||||||||||||
| 1627 | 0 | for my $j (@XTRdot) { | |||||||||||||||||||||||||||||||||||||||||
| 1628 | |||||||||||||||||||||||||||||||||||||||||||
| 1629 | # format input value | ||||||||||||||||||||||||||||||||||||||||||
| 1630 | 0 | ▶ | $Tdot[0] = $fp ? sprintf("%.2f", $j) : $j; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||||||||||
| 1632 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 1633 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||||||||||
| 1635 | # compute transformed dot value | ||||||||||||||||||||||||||||||||||||||||||
| 1636 | 0 | $Tdot[$i + 1] = sprintf("%.2f", 100 * ($self->[1][$i]->_transform($dir, $j/100))); | |||||||||||||||||||||||||||||||||||||||||
| 1637 | |||||||||||||||||||||||||||||||||||||||||||
| 1638 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1639 | |||||||||||||||||||||||||||||||||||||||||||
| 1640 | # print step values | ||||||||||||||||||||||||||||||||||||||||||
| 1641 | 0 | print $fh join("\t", @Tdot), $rs; | |||||||||||||||||||||||||||||||||||||||||
| 1642 | |||||||||||||||||||||||||||||||||||||||||||
| 1643 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||
| 1645 | # close the file | ||||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 1647 | |||||||||||||||||||||||||||||||||||||||||||
| 1648 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1649 | |||||||||||||||||||||||||||||||||||||||||||
| 1650 | # graph tone curves | ||||||||||||||||||||||||||||||||||||||||||
| 1651 | # assumes curve domain/range is (0 - 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1652 | # options parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 1653 | # hash keys: 'dir', 'composite' | ||||||||||||||||||||||||||||||||||||||||||
| 1654 | # direction: 0 - normal, 1 - inverse | ||||||||||||||||||||||||||||||||||||||||||
| 1655 | # parameters: (folder_path, [options]) | ||||||||||||||||||||||||||||||||||||||||||
| 1656 | sub graph { | ||||||||||||||||||||||||||||||||||||||||||
| 1657 | |||||||||||||||||||||||||||||||||||||||||||
| 1658 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | ▶ | my ($self, $path, $opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
graph: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||||||||||||||||
| 1661 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 1662 | 0 | my ($dir, $include, $folder, $tt, $vars, @colors, @inks, $s, $lib); | |||||||||||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||||||||||||
| 1664 | # process options | ||||||||||||||||||||||||||||||||||||||||||
| 1665 | 0 | $dir = _options($opts); | |||||||||||||||||||||||||||||||||||||||||
| 1666 | |||||||||||||||||||||||||||||||||||||||||||
| 1667 | # if ICC::Templates folder is found in @INC (may be relative) | ||||||||||||||||||||||||||||||||||||||||||
| 1668 | 0 | ▶ | if (($include) = grep {-d} map {File::Spec->catdir($_, 'ICC', 'Templates')} @INC) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1669 | |||||||||||||||||||||||||||||||||||||||||||
| 1670 | # purify folder path | ||||||||||||||||||||||||||||||||||||||||||
| 1671 | 0 | $folder = File::Glob::bsd_glob($path); | |||||||||||||||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||||||||||||||||
| 1673 | # make a template processing object | ||||||||||||||||||||||||||||||||||||||||||
| 1674 | 0 | $tt = Template->new({ | |||||||||||||||||||||||||||||||||||||||||
| 1675 | 'INCLUDE_PATH' => $include, | ||||||||||||||||||||||||||||||||||||||||||
| 1676 | 'OUTPUT_PATH' => $folder, | ||||||||||||||||||||||||||||||||||||||||||
| 1677 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||||||||||||||||
| 1679 | # if gray scale curve | ||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | ▶ | if ($#{$self->[1]} == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1681 | |||||||||||||||||||||||||||||||||||||||||||
| 1682 | # set colors | ||||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | @colors = qw(black); | |||||||||||||||||||||||||||||||||||||||||
| 1684 | 0 | @inks = qw(grayscale); | |||||||||||||||||||||||||||||||||||||||||
| 1685 | |||||||||||||||||||||||||||||||||||||||||||
| 1686 | # if RGB curves | ||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | } elsif ($#{$self->[1]} == 2) { | |||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||
| 1689 | # set colors | ||||||||||||||||||||||||||||||||||||||||||
| 1690 | 0 | @colors = @inks = qw(red green blue); | |||||||||||||||||||||||||||||||||||||||||
| 1691 | |||||||||||||||||||||||||||||||||||||||||||
| 1692 | # if CMYK+ curves | ||||||||||||||||||||||||||||||||||||||||||
| 1693 | 0 | } elsif ($#{$self->[1]} > 2) { | |||||||||||||||||||||||||||||||||||||||||
| 1694 | |||||||||||||||||||||||||||||||||||||||||||
| 1695 | # set colors | ||||||||||||||||||||||||||||||||||||||||||
| 1696 | 0 | @colors = qw(cyan magenta yellow black orange green blue); | |||||||||||||||||||||||||||||||||||||||||
| 1697 | 0 | $colors[2] = '#cc0'; # dark yellow | |||||||||||||||||||||||||||||||||||||||||
| 1698 | 0 | $colors[4] = '#f80'; # orange | |||||||||||||||||||||||||||||||||||||||||
| 1699 | 0 | @inks = qw(cyan magenta yellow black ink5 ink6 ink7); | |||||||||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||||||||||
| 1701 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||||||||||||||||
| 1703 | # if 'composite' curve | ||||||||||||||||||||||||||||||||||||||||||
| 1704 | 0 | ▶ | if ($opts->{'composite'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1705 | |||||||||||||||||||||||||||||||||||||||||||
| 1706 | # for each curve | ||||||||||||||||||||||||||||||||||||||||||
| 1707 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 1708 | |||||||||||||||||||||||||||||||||||||||||||
| 1709 | # compute curve data | ||||||||||||||||||||||||||||||||||||||||||
| 1710 | 0 | $s->[$i] = '[' . join(', ', map {sprintf("%.3f", $self->[1][$i]->_transform($dir, $_/100))} (0 .. 100)) . ']'; | |||||||||||||||||||||||||||||||||||||||||
| 1711 | |||||||||||||||||||||||||||||||||||||||||||
| 1712 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1713 | |||||||||||||||||||||||||||||||||||||||||||
| 1714 | # make composite javascript string of curve data | ||||||||||||||||||||||||||||||||||||||||||
| 1715 | 0 | $vars->{'data'} = '[' . join(', ', @{$s}) . ']'; | |||||||||||||||||||||||||||||||||||||||||
| 1716 | |||||||||||||||||||||||||||||||||||||||||||
| 1717 | # set graph title | ||||||||||||||||||||||||||||||||||||||||||
| 1718 | 0 | $vars->{'title'} = "composite tone curves"; | |||||||||||||||||||||||||||||||||||||||||
| 1719 | |||||||||||||||||||||||||||||||||||||||||||
| 1720 | # set graph colors | ||||||||||||||||||||||||||||||||||||||||||
| 1721 | 0 | $vars->{'colors'} = '[' . join(', ', map {"'$_'"} @colors) . ']'; | |||||||||||||||||||||||||||||||||||||||||
| 1722 | |||||||||||||||||||||||||||||||||||||||||||
| 1723 | # process the template | ||||||||||||||||||||||||||||||||||||||||||
| 1724 | 0 | ▶ | $tt->process('rgraph_cvst_svg.tt2', $vars, "composite.html") || CORE::die $tt->error(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||||||||||||||||
| 1726 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||||||||||||||||
| 1728 | # for each curve | ||||||||||||||||||||||||||||||||||||||||||
| 1729 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 1730 | |||||||||||||||||||||||||||||||||||||||||||
| 1731 | # make javascript string of curve data | ||||||||||||||||||||||||||||||||||||||||||
| 1732 | 0 | $vars->{'data'} = '[[' . join(', ', map {sprintf("%.3f", $self->[1][$i]->_transform($dir, $_/100))} (0 .. 100)) . ']]'; | |||||||||||||||||||||||||||||||||||||||||
| 1733 | |||||||||||||||||||||||||||||||||||||||||||
| 1734 | # set graph title | ||||||||||||||||||||||||||||||||||||||||||
| 1735 | 0 | $vars->{'title'} = "$inks[$i] tone curve"; | |||||||||||||||||||||||||||||||||||||||||
| 1736 | |||||||||||||||||||||||||||||||||||||||||||
| 1737 | # set graph color | ||||||||||||||||||||||||||||||||||||||||||
| 1738 | 0 | $vars->{'colors'} = "['$colors[$i]']"; | |||||||||||||||||||||||||||||||||||||||||
| 1739 | |||||||||||||||||||||||||||||||||||||||||||
| 1740 | # process the template | ||||||||||||||||||||||||||||||||||||||||||
| 1741 | 0 | ▶ | $tt->process('rgraph_cvst_svg.tt2', $vars, "$inks[$i].html") || CORE::die $tt->error(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||||||||||||||||
| 1743 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1744 | |||||||||||||||||||||||||||||||||||||||||||
| 1745 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1746 | |||||||||||||||||||||||||||||||||||||||||||
| 1747 | # make path to 'lib' folder | ||||||||||||||||||||||||||||||||||||||||||
| 1748 | 0 | $lib = "$folder/lib"; | |||||||||||||||||||||||||||||||||||||||||
| 1749 | |||||||||||||||||||||||||||||||||||||||||||
| 1750 | # make 'lib' folder, if none | ||||||||||||||||||||||||||||||||||||||||||
| 1751 | 0 | ▶ | mkdir($lib) if ! -d $lib; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1752 | |||||||||||||||||||||||||||||||||||||||||||
| 1753 | # match 'ICC' folder path | ||||||||||||||||||||||||||||||||||||||||||
| 1754 | 0 | $include =~ m/^(.*)Templates$/; | |||||||||||||||||||||||||||||||||||||||||
| 1755 | |||||||||||||||||||||||||||||||||||||||||||
| 1756 | # copy Rgraph Javascripts to 'lib' folder | ||||||||||||||||||||||||||||||||||||||||||
| 1757 | 0 | qx(cp -n "$1/Javascripts/rgraph/RGraph.svg.common.core.js" $lib); | |||||||||||||||||||||||||||||||||||||||||
| 1758 | 0 | qx(cp -n "$1/Javascripts/rgraph/RGraph.svg.line.js" $lib); | |||||||||||||||||||||||||||||||||||||||||
| 1759 | |||||||||||||||||||||||||||||||||||||||||||
| 1760 | # if 'composite' curve | ||||||||||||||||||||||||||||||||||||||||||
| 1761 | 0 | ▶ | if ($opts->{'composite'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1762 | |||||||||||||||||||||||||||||||||||||||||||
| 1763 | # open graph file in browser | ||||||||||||||||||||||||||||||||||||||||||
| 1764 | 0 | qx(open "$folder/composite.html"); | |||||||||||||||||||||||||||||||||||||||||
| 1765 | |||||||||||||||||||||||||||||||||||||||||||
| 1766 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1767 | |||||||||||||||||||||||||||||||||||||||||||
| 1768 | # for each curve | ||||||||||||||||||||||||||||||||||||||||||
| 1769 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 1770 | |||||||||||||||||||||||||||||||||||||||||||
| 1771 | # open graph file in browser | ||||||||||||||||||||||||||||||||||||||||||
| 1772 | 0 | qx(open "$folder/$inks[$i].html"); | |||||||||||||||||||||||||||||||||||||||||
| 1773 | |||||||||||||||||||||||||||||||||||||||||||
| 1774 | # pause for first file (Firefox) | ||||||||||||||||||||||||||||||||||||||||||
| 1775 | 0 | ▶ | sleep(1) if ($i == 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||
| 1777 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1778 | |||||||||||||||||||||||||||||||||||||||||||
| 1779 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1780 | |||||||||||||||||||||||||||||||||||||||||||
| 1781 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||
| 1783 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1784 | |||||||||||||||||||||||||||||||||||||||||||
| 1785 | # print object contents to string | ||||||||||||||||||||||||||||||||||||||||||
| 1786 | # format is an array structure | ||||||||||||||||||||||||||||||||||||||||||
| 1787 | # parameter: ([format]) | ||||||||||||||||||||||||||||||||||||||||||
| 1788 | # returns: (string) | ||||||||||||||||||||||||||||||||||||||||||
| 1789 | sub sdump { | ||||||||||||||||||||||||||||||||||||||||||
| 1790 | |||||||||||||||||||||||||||||||||||||||||||
| 1791 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1792 | 0 | ▶ | my ($self, $p) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sdump: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1793 | |||||||||||||||||||||||||||||||||||||||||||
| 1794 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 1795 | 0 | my ($element, $fmt, $s, $pt, $st); | |||||||||||||||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||||||||||||||||
| 1797 | # resolve parameter to an array reference | ||||||||||||||||||||||||||||||||||||||||||
| 1798 | 0 | ▶ | $p = defined($p) ? ref($p) eq 'ARRAY' ? $p : [$p] : []; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1799 | |||||||||||||||||||||||||||||||||||||||||||
| 1800 | # get format string | ||||||||||||||||||||||||||||||||||||||||||
| 1801 | 0 | ▶ | $fmt = defined($p->[0]) && ! ref($p->[0]) ? $p->[0] : 's'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $p->[0] and not ref $p->[0]
MC/DC0%0/2
defined $p->[0] and not ref $p->[0]
defined $p->[0]
not ref $p->[0]
Truth table0%0/3
A and not(B)
A= defined $p->[0]B= not ref $p->[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 1802 | |||||||||||||||||||||||||||||||||||||||||||
| 1803 | # set string to object ID | ||||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | $s = sprintf("'%s' object, (0x%x)\n", ref($self), $self); | |||||||||||||||||||||||||||||||||||||||||
| 1805 | |||||||||||||||||||||||||||||||||||||||||||
| 1806 | # if format contains 'o' | ||||||||||||||||||||||||||||||||||||||||||
| 1807 | 0 | ▶ | if ($fmt =~ m/s/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1808 | |||||||||||||||||||||||||||||||||||||||||||
| 1809 | # get default parameter | ||||||||||||||||||||||||||||||||||||||||||
| 1810 | 0 | $pt = $p->[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 1811 | |||||||||||||||||||||||||||||||||||||||||||
| 1812 | # for each processing element | ||||||||||||||||||||||||||||||||||||||||||
| 1813 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||||||||||||||||
| 1815 | # get element reference | ||||||||||||||||||||||||||||||||||||||||||
| 1816 | 0 | $element = $self->[1][$i]; | |||||||||||||||||||||||||||||||||||||||||
| 1817 | |||||||||||||||||||||||||||||||||||||||||||
| 1818 | # if processing element is undefined | ||||||||||||||||||||||||||||||||||||||||||
| 1819 | 0 | ▶ | if (! defined($element)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1820 | |||||||||||||||||||||||||||||||||||||||||||
| 1821 | # append message | ||||||||||||||||||||||||||||||||||||||||||
| 1822 | 0 | $s .= "\tprocessing element is undefined\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1823 | |||||||||||||||||||||||||||||||||||||||||||
| 1824 | # if processing element is not a blessed object | ||||||||||||||||||||||||||||||||||||||||||
| 1825 | } elsif (! Scalar::Util::blessed($element)) { | ||||||||||||||||||||||||||||||||||||||||||
| 1826 | |||||||||||||||||||||||||||||||||||||||||||
| 1827 | # append message | ||||||||||||||||||||||||||||||||||||||||||
| 1828 | 0 | $s .= "\tprocessing element is not a blessed object\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||||||||||||||||
| 1830 | # if processing element has an 'sdump' method | ||||||||||||||||||||||||||||||||||||||||||
| 1831 | } elsif ($element->can('sdump')) { | ||||||||||||||||||||||||||||||||||||||||||
| 1832 | |||||||||||||||||||||||||||||||||||||||||||
| 1833 | # get 'sdump' string | ||||||||||||||||||||||||||||||||||||||||||
| 1834 | 0 | ▶ | $st = $element->sdump(defined($p->[$i + 1]) ? $p->[$i + 1] : $pt); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||||||||||||||||
| 1836 | # prepend tabs to each line | ||||||||||||||||||||||||||||||||||||||||||
| 1837 | 0 | $st =~ s/^/\t/mg; | |||||||||||||||||||||||||||||||||||||||||
| 1838 | |||||||||||||||||||||||||||||||||||||||||||
| 1839 | # append 'sdump' string | ||||||||||||||||||||||||||||||||||||||||||
| 1840 | 0 | $s .= $st; | |||||||||||||||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||||||||||||||||
| 1842 | # processing element is object without an 'sdump' method | ||||||||||||||||||||||||||||||||||||||||||
| 1843 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1844 | |||||||||||||||||||||||||||||||||||||||||||
| 1845 | # append object info | ||||||||||||||||||||||||||||||||||||||||||
| 1846 | 0 | $s .= sprintf("\t'%s' object, (0x%x)\n", ref($element), $element); | |||||||||||||||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||||||||||||||||
| 1848 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||||||||||||||||
| 1850 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||||||||||||||||
| 1852 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1853 | |||||||||||||||||||||||||||||||||||||||||||
| 1854 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 1855 | 0 | return($s); | |||||||||||||||||||||||||||||||||||||||||
| 1856 | |||||||||||||||||||||||||||||||||||||||||||
| 1857 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1858 | |||||||||||||||||||||||||||||||||||||||||||
| 1859 | # transform list | ||||||||||||||||||||||||||||||||||||||||||
| 1860 | # parameters: (object_reference, list, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 1861 | # returns: (list) | ||||||||||||||||||||||||||||||||||||||||||
| 1862 | sub _trans0 { | ||||||||||||||||||||||||||||||||||||||||||
| 1863 | |||||||||||||||||||||||||||||||||||||||||||
| 1864 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 1865 | 0 | ▶ | my ($self, @out, $hash); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trans0: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1866 | |||||||||||||||||||||||||||||||||||||||||||
| 1867 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||
| 1868 | 0 | $self = shift(); | |||||||||||||||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||||||||||||||||
| 1870 | # get optional hash | ||||||||||||||||||||||||||||||||||||||||||
| 1871 | 0 | ▶ | $hash = pop() if (ref($_[-1]) eq 'HASH'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1872 | |||||||||||||||||||||||||||||||||||||||||||
| 1873 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 1874 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 1875 | |||||||||||||||||||||||||||||||||||||||||||
| 1876 | # compute transform | ||||||||||||||||||||||||||||||||||||||||||
| 1877 | 0 | $out[$i] = $self->[1][$i]->transform($_[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 1878 | |||||||||||||||||||||||||||||||||||||||||||
| 1879 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1880 | |||||||||||||||||||||||||||||||||||||||||||
| 1881 | # return output array | ||||||||||||||||||||||||||||||||||||||||||
| 1882 | 0 | return(@out); | |||||||||||||||||||||||||||||||||||||||||
| 1883 | |||||||||||||||||||||||||||||||||||||||||||
| 1884 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1885 | |||||||||||||||||||||||||||||||||||||||||||
| 1886 | # transform vector | ||||||||||||||||||||||||||||||||||||||||||
| 1887 | # parameters: (object_reference, vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 1888 | # returns: (vector) | ||||||||||||||||||||||||||||||||||||||||||
| 1889 | sub _trans1 { | ||||||||||||||||||||||||||||||||||||||||||
| 1890 | |||||||||||||||||||||||||||||||||||||||||||
| 1891 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1892 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trans1: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||||||||||||||||
| 1894 | # local variable | ||||||||||||||||||||||||||||||||||||||||||
| 1895 | 0 | my ($out); | |||||||||||||||||||||||||||||||||||||||||
| 1896 | |||||||||||||||||||||||||||||||||||||||||||
| 1897 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 1898 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 1899 | |||||||||||||||||||||||||||||||||||||||||||
| 1900 | # compute transform | ||||||||||||||||||||||||||||||||||||||||||
| 1901 | 0 | $out->[$i] = $self->[1][$i]->transform($in->[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 1902 | |||||||||||||||||||||||||||||||||||||||||||
| 1903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1904 | |||||||||||||||||||||||||||||||||||||||||||
| 1905 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 1906 | 0 | return($out); | |||||||||||||||||||||||||||||||||||||||||
| 1907 | |||||||||||||||||||||||||||||||||||||||||||
| 1908 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1909 | |||||||||||||||||||||||||||||||||||||||||||
| 1910 | # transform matrix (2-D array -or- Math::Matrix object) | ||||||||||||||||||||||||||||||||||||||||||
| 1911 | # parameters: (object_reference, matrix, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 1912 | # returns: (matrix) | ||||||||||||||||||||||||||||||||||||||||||
| 1913 | sub _trans2 { | ||||||||||||||||||||||||||||||||||||||||||
| 1914 | |||||||||||||||||||||||||||||||||||||||||||
| 1915 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1916 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trans2: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1917 | |||||||||||||||||||||||||||||||||||||||||||
| 1918 | # local variable | ||||||||||||||||||||||||||||||||||||||||||
| 1919 | 0 | my ($out); | |||||||||||||||||||||||||||||||||||||||||
| 1920 | |||||||||||||||||||||||||||||||||||||||||||
| 1921 | # for each input vector | ||||||||||||||||||||||||||||||||||||||||||
| 1922 | 0 | for my $i (0 .. $#{$in}) { | |||||||||||||||||||||||||||||||||||||||||
| 1923 | |||||||||||||||||||||||||||||||||||||||||||
| 1924 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 1925 | 0 | for my $j (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 1926 | |||||||||||||||||||||||||||||||||||||||||||
| 1927 | # compute transform | ||||||||||||||||||||||||||||||||||||||||||
| 1928 | 0 | $out->[$i][$j] = $self->[1][$j]->transform($in->[$i][$j]); | |||||||||||||||||||||||||||||||||||||||||
| 1929 | |||||||||||||||||||||||||||||||||||||||||||
| 1930 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1931 | |||||||||||||||||||||||||||||||||||||||||||
| 1932 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1933 | |||||||||||||||||||||||||||||||||||||||||||
| 1934 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 1935 | 0 | return($out); | |||||||||||||||||||||||||||||||||||||||||
| 1936 | |||||||||||||||||||||||||||||||||||||||||||
| 1937 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1938 | |||||||||||||||||||||||||||||||||||||||||||
| 1939 | # transform structure | ||||||||||||||||||||||||||||||||||||||||||
| 1940 | # parameters: (object_reference, structure, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 1941 | # returns: (structure) | ||||||||||||||||||||||||||||||||||||||||||
| 1942 | sub _trans3 { | ||||||||||||||||||||||||||||||||||||||||||
| 1943 | |||||||||||||||||||||||||||||||||||||||||||
| 1944 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1945 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trans3: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1946 | |||||||||||||||||||||||||||||||||||||||||||
| 1947 | # transform the array structure | ||||||||||||||||||||||||||||||||||||||||||
| 1948 | 0 | _crawl($self, $in, my $out = [], $hash); | |||||||||||||||||||||||||||||||||||||||||
| 1949 | |||||||||||||||||||||||||||||||||||||||||||
| 1950 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 1951 | 0 | return($out); | |||||||||||||||||||||||||||||||||||||||||
| 1952 | |||||||||||||||||||||||||||||||||||||||||||
| 1953 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1954 | |||||||||||||||||||||||||||||||||||||||||||
| 1955 | # recursive transform | ||||||||||||||||||||||||||||||||||||||||||
| 1956 | # array structure is traversed until scalar arrays are found and transformed | ||||||||||||||||||||||||||||||||||||||||||
| 1957 | # parameters: (ref_to_object, input_array_reference, output_array_reference, hash) | ||||||||||||||||||||||||||||||||||||||||||
| 1958 | sub _crawl { | ||||||||||||||||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||||||||||||||||
| 1960 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1961 | 0 | ▶ | my ($self, $in, $out, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_crawl: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1962 | |||||||||||||||||||||||||||||||||||||||||||
| 1963 | # if input is a vector (reference to a scalar array) | ||||||||||||||||||||||||||||||||||||||||||
| 1964 | 0 | ▶ | if (@{$in} == grep {! ref()} @{$in}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1965 | |||||||||||||||||||||||||||||||||||||||||||
| 1966 | # transform input vector and copy to output | ||||||||||||||||||||||||||||||||||||||||||
| 1967 | 0 | @{$out} = @{_trans1($self, $in, $hash)}; | |||||||||||||||||||||||||||||||||||||||||
| 1968 | |||||||||||||||||||||||||||||||||||||||||||
| 1969 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1970 | |||||||||||||||||||||||||||||||||||||||||||
| 1971 | # for each input element | ||||||||||||||||||||||||||||||||||||||||||
| 1972 | 0 | for my $i (0 .. $#{$in}) { | |||||||||||||||||||||||||||||||||||||||||
| 1973 | |||||||||||||||||||||||||||||||||||||||||||
| 1974 | # if an array reference | ||||||||||||||||||||||||||||||||||||||||||
| 1975 | 0 | ▶ | if (ref($in->[$i]) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1976 | |||||||||||||||||||||||||||||||||||||||||||
| 1977 | # transform next level | ||||||||||||||||||||||||||||||||||||||||||
| 1978 | 0 | _crawl($self, $in->[$i], $out->[$i] = [], $hash); | |||||||||||||||||||||||||||||||||||||||||
| 1979 | |||||||||||||||||||||||||||||||||||||||||||
| 1980 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1981 | |||||||||||||||||||||||||||||||||||||||||||
| 1982 | # error | ||||||||||||||||||||||||||||||||||||||||||
| 1983 | 0 | croak('invalid transform input'); | |||||||||||||||||||||||||||||||||||||||||
| 1984 | |||||||||||||||||||||||||||||||||||||||||||
| 1985 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1986 | |||||||||||||||||||||||||||||||||||||||||||
| 1987 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1988 | |||||||||||||||||||||||||||||||||||||||||||
| 1989 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1990 | |||||||||||||||||||||||||||||||||||||||||||
| 1991 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1992 | |||||||||||||||||||||||||||||||||||||||||||
| 1993 | # invert list | ||||||||||||||||||||||||||||||||||||||||||
| 1994 | # parameters: (object_reference, list, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 1995 | # returns: (list) | ||||||||||||||||||||||||||||||||||||||||||
| 1996 | sub _inv0 { | ||||||||||||||||||||||||||||||||||||||||||
| 1997 | |||||||||||||||||||||||||||||||||||||||||||
| 1998 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 1999 | 0 | ▶ | my ($self, $hash, @out); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inv0: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 2000 | |||||||||||||||||||||||||||||||||||||||||||
| 2001 | # get object reference | ||||||||||||||||||||||||||||||||||||||||||
| 2002 | 0 | $self = shift(); | |||||||||||||||||||||||||||||||||||||||||
| 2003 | |||||||||||||||||||||||||||||||||||||||||||
| 2004 | # get optional hash | ||||||||||||||||||||||||||||||||||||||||||
| 2005 | 0 | ▶ | $hash = pop() if (ref($_[-1]) eq 'HASH'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2006 | |||||||||||||||||||||||||||||||||||||||||||
| 2007 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 2008 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 2009 | |||||||||||||||||||||||||||||||||||||||||||
| 2010 | # compute invert | ||||||||||||||||||||||||||||||||||||||||||
| 2011 | 0 | $out[$i] = $self->[1][$i]->inverse($_[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 2012 | |||||||||||||||||||||||||||||||||||||||||||
| 2013 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2014 | |||||||||||||||||||||||||||||||||||||||||||
| 2015 | # return output array | ||||||||||||||||||||||||||||||||||||||||||
| 2016 | 0 | return(@out); | |||||||||||||||||||||||||||||||||||||||||
| 2017 | |||||||||||||||||||||||||||||||||||||||||||
| 2018 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2019 | |||||||||||||||||||||||||||||||||||||||||||
| 2020 | # invert vector | ||||||||||||||||||||||||||||||||||||||||||
| 2021 | # parameters: (object_reference, vector, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 2022 | # returns: (vector) | ||||||||||||||||||||||||||||||||||||||||||
| 2023 | sub _inv1 { | ||||||||||||||||||||||||||||||||||||||||||
| 2024 | |||||||||||||||||||||||||||||||||||||||||||
| 2025 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 2026 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inv1: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2027 | |||||||||||||||||||||||||||||||||||||||||||
| 2028 | # local variable | ||||||||||||||||||||||||||||||||||||||||||
| 2029 | 0 | my ($out); | |||||||||||||||||||||||||||||||||||||||||
| 2030 | |||||||||||||||||||||||||||||||||||||||||||
| 2031 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 2032 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 2033 | |||||||||||||||||||||||||||||||||||||||||||
| 2034 | # compute invert | ||||||||||||||||||||||||||||||||||||||||||
| 2035 | 0 | $out->[$i] = $self->[1][$i]->inverse($in->[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 2036 | |||||||||||||||||||||||||||||||||||||||||||
| 2037 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2038 | |||||||||||||||||||||||||||||||||||||||||||
| 2039 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 2040 | 0 | return($out); | |||||||||||||||||||||||||||||||||||||||||
| 2041 | |||||||||||||||||||||||||||||||||||||||||||
| 2042 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2043 | |||||||||||||||||||||||||||||||||||||||||||
| 2044 | # invert matrix (2-D array -or- Math::Matrix object) | ||||||||||||||||||||||||||||||||||||||||||
| 2045 | # parameters: (object_reference, matrix, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 2046 | # returns: (matrix) | ||||||||||||||||||||||||||||||||||||||||||
| 2047 | sub _inv2 { | ||||||||||||||||||||||||||||||||||||||||||
| 2048 | |||||||||||||||||||||||||||||||||||||||||||
| 2049 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 2050 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inv2: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 2051 | |||||||||||||||||||||||||||||||||||||||||||
| 2052 | # local variable | ||||||||||||||||||||||||||||||||||||||||||
| 2053 | 0 | my ($out); | |||||||||||||||||||||||||||||||||||||||||
| 2054 | |||||||||||||||||||||||||||||||||||||||||||
| 2055 | # for each input vector | ||||||||||||||||||||||||||||||||||||||||||
| 2056 | 0 | for my $i (0 .. $#{$in}) { | |||||||||||||||||||||||||||||||||||||||||
| 2057 | |||||||||||||||||||||||||||||||||||||||||||
| 2058 | # for each channel | ||||||||||||||||||||||||||||||||||||||||||
| 2059 | 0 | for my $j (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 2060 | |||||||||||||||||||||||||||||||||||||||||||
| 2061 | # compute invert | ||||||||||||||||||||||||||||||||||||||||||
| 2062 | 0 | $out->[$i][$j] = $self->[1][$j]->inverse($in->[$i][$j]); | |||||||||||||||||||||||||||||||||||||||||
| 2063 | |||||||||||||||||||||||||||||||||||||||||||
| 2064 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2065 | |||||||||||||||||||||||||||||||||||||||||||
| 2066 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2067 | |||||||||||||||||||||||||||||||||||||||||||
| 2068 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 2069 | 0 | return($out); | |||||||||||||||||||||||||||||||||||||||||
| 2070 | |||||||||||||||||||||||||||||||||||||||||||
| 2071 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2072 | |||||||||||||||||||||||||||||||||||||||||||
| 2073 | # invert structure | ||||||||||||||||||||||||||||||||||||||||||
| 2074 | # parameters: (object_reference, structure, [hash]) | ||||||||||||||||||||||||||||||||||||||||||
| 2075 | # returns: (structure) | ||||||||||||||||||||||||||||||||||||||||||
| 2076 | sub _inv3 { | ||||||||||||||||||||||||||||||||||||||||||
| 2077 | |||||||||||||||||||||||||||||||||||||||||||
| 2078 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 2079 | 0 | ▶ | my ($self, $in, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inv3: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2080 | |||||||||||||||||||||||||||||||||||||||||||
| 2081 | # recursive inverse | ||||||||||||||||||||||||||||||||||||||||||
| 2082 | 0 | _crawl2($self, $in, my $out = []); | |||||||||||||||||||||||||||||||||||||||||
| 2083 | |||||||||||||||||||||||||||||||||||||||||||
| 2084 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 2085 | 0 | return($out); | |||||||||||||||||||||||||||||||||||||||||
| 2086 | |||||||||||||||||||||||||||||||||||||||||||
| 2087 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2088 | |||||||||||||||||||||||||||||||||||||||||||
| 2089 | # recursive inverse | ||||||||||||||||||||||||||||||||||||||||||
| 2090 | # array structure is traversed until scalar arrays are found and inverted | ||||||||||||||||||||||||||||||||||||||||||
| 2091 | # parameters: (object_reference, input_array_reference, output_array_reference, hash) | ||||||||||||||||||||||||||||||||||||||||||
| 2092 | sub _crawl2 { | ||||||||||||||||||||||||||||||||||||||||||
| 2093 | |||||||||||||||||||||||||||||||||||||||||||
| 2094 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 2095 | 0 | ▶ | my ($self, $in, $out, $hash) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_crawl2: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2096 | |||||||||||||||||||||||||||||||||||||||||||
| 2097 | # if input is a vector (reference to a scalar array) | ||||||||||||||||||||||||||||||||||||||||||
| 2098 | 0 | ▶ | if (@{$in} == grep {! ref()} @{$in}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2099 | |||||||||||||||||||||||||||||||||||||||||||
| 2100 | # invert input vector and copy to output | ||||||||||||||||||||||||||||||||||||||||||
| 2101 | 0 | @{$out} = @{_inv1($self, $in, $hash)}; | |||||||||||||||||||||||||||||||||||||||||
| 2102 | |||||||||||||||||||||||||||||||||||||||||||
| 2103 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2104 | |||||||||||||||||||||||||||||||||||||||||||
| 2105 | # for each input element | ||||||||||||||||||||||||||||||||||||||||||
| 2106 | 0 | for my $i (0 .. $#{$in}) { | |||||||||||||||||||||||||||||||||||||||||
| 2107 | |||||||||||||||||||||||||||||||||||||||||||
| 2108 | # if an array reference | ||||||||||||||||||||||||||||||||||||||||||
| 2109 | 0 | ▶ | if (ref($in->[$i]) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2110 | |||||||||||||||||||||||||||||||||||||||||||
| 2111 | # invert next level | ||||||||||||||||||||||||||||||||||||||||||
| 2112 | 0 | _crawl2($self, $in->[$i], $out->[$i] = []); | |||||||||||||||||||||||||||||||||||||||||
| 2113 | |||||||||||||||||||||||||||||||||||||||||||
| 2114 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2115 | |||||||||||||||||||||||||||||||||||||||||||
| 2116 | # error | ||||||||||||||||||||||||||||||||||||||||||
| 2117 | 0 | croak('invalid inverse input'); | |||||||||||||||||||||||||||||||||||||||||
| 2118 | |||||||||||||||||||||||||||||||||||||||||||
| 2119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2120 | |||||||||||||||||||||||||||||||||||||||||||
| 2121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2122 | |||||||||||||||||||||||||||||||||||||||||||
| 2123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2124 | |||||||||||||||||||||||||||||||||||||||||||
| 2125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2126 | |||||||||||||||||||||||||||||||||||||||||||
| 2127 | # process the options parameter | ||||||||||||||||||||||||||||||||||||||||||
| 2128 | # the parameter may be a scalar or hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 2129 | # parameter: (options_parameter) | ||||||||||||||||||||||||||||||||||||||||||
| 2130 | # returns: (direction_flag) | ||||||||||||||||||||||||||||||||||||||||||
| 2131 | sub _options { | ||||||||||||||||||||||||||||||||||||||||||
| 2132 | |||||||||||||||||||||||||||||||||||||||||||
| 2133 | # local variable | ||||||||||||||||||||||||||||||||||||||||||
| 2134 | 0 | ▶ | my ($dir, $steps, $n); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_options: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||
| 2135 | |||||||||||||||||||||||||||||||||||||||||||
| 2136 | # if parameter is defined | ||||||||||||||||||||||||||||||||||||||||||
| 2137 | 0 | ▶ | if (defined($_[0])) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||||||||||||||||
| 2139 | # if parameter is a hash reference | ||||||||||||||||||||||||||||||||||||||||||
| 2140 | 0 | ▶ | if (ref($_[0]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2141 | |||||||||||||||||||||||||||||||||||||||||||
| 2142 | # use 'dir' hash value | ||||||||||||||||||||||||||||||||||||||||||
| 2143 | 0 | $dir = $_[0]->{'dir'}; | |||||||||||||||||||||||||||||||||||||||||
| 2144 | |||||||||||||||||||||||||||||||||||||||||||
| 2145 | # if the 'steps' key is defined | ||||||||||||||||||||||||||||||||||||||||||
| 2146 | 0 | ▶ | if (defined($steps = $_[0]->{'steps'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2147 | |||||||||||||||||||||||||||||||||||||||||||
| 2148 | # if steps value is an array reference | ||||||||||||||||||||||||||||||||||||||||||
| 2149 | 0 | ▶ | if (ref($steps) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 2150 | |||||||||||||||||||||||||||||||||||||||||||
| 2151 | # if step values are valid | ||||||||||||||||||||||||||||||||||||||||||
| 2152 | 0 | ▶ | if (@{$steps} == grep {Scalar::Util::looks_like_number($_) && $_ >= 0 && $_ <= 100} @{$steps}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
&Scalar::Util::looks_like_number($_) and $_ >= 0
MC/DC0%0/2
&Scalar::Util::looks_like_number($_) and $_ >= 0
&Scalar::Util::looks_like_number($_)
$_ >= 0
Truth table0%0/3
A and B
A= &Scalar::Util::looks_like_number($_)B= $_ >= 0
| |||||||||||||||||||||||||||||||||||||||||||
| 2153 | |||||||||||||||||||||||||||||||||||||||||||
| 2154 | # sort step values | ||||||||||||||||||||||||||||||||||||||||||
| 2155 | 0 | @{$steps} = sort {$a <=> $b} @{$steps}; | |||||||||||||||||||||||||||||||||||||||||
| 2156 | |||||||||||||||||||||||||||||||||||||||||||
| 2157 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2158 | |||||||||||||||||||||||||||||||||||||||||||
| 2159 | # print warning | ||||||||||||||||||||||||||||||||||||||||||
| 2160 | 0 | carp("invalid 'step' value(s)\n"); | |||||||||||||||||||||||||||||||||||||||||
| 2161 | |||||||||||||||||||||||||||||||||||||||||||
| 2162 | # delete hash entry | ||||||||||||||||||||||||||||||||||||||||||
| 2163 | 0 | delete($_[0]->{'steps'}); | |||||||||||||||||||||||||||||||||||||||||
| 2164 | |||||||||||||||||||||||||||||||||||||||||||
| 2165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2166 | |||||||||||||||||||||||||||||||||||||||||||
| 2167 | # if steps value is a scalar | ||||||||||||||||||||||||||||||||||||||||||
| 2168 | } elsif (! ref($steps)) { | ||||||||||||||||||||||||||||||||||||||||||
| 2169 | |||||||||||||||||||||||||||||||||||||||||||
| 2170 | # if steps value is a positive integer > 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2171 | 0 | ▶ | if (Scalar::Util::looks_like_number($steps) && int($steps) == $steps && $steps > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
&Scalar::Util::looks_like_number($steps) and int $steps == $steps and $steps > 1
&Scalar::Util::looks_like_number($steps) and int $steps == $steps
MC/DC0%0/3
&Scalar::Util::looks_like_number($steps) and int $steps == $steps and $steps > 1
&Scalar::Util::looks_like_number($steps)
int $steps == $steps
$steps > 1
Truth table0%0/4
A and B and C
A= &Scalar::Util::looks_like_number($steps)B= int $steps == $stepsC= $steps > 1
| |||||||||||||||||||||||||||||||||||||||||||
| 2172 | |||||||||||||||||||||||||||||||||||||||||||
| 2173 | # set upper index | ||||||||||||||||||||||||||||||||||||||||||
| 2174 | 0 | $n = $steps - 1; | |||||||||||||||||||||||||||||||||||||||||
| 2175 | |||||||||||||||||||||||||||||||||||||||||||
| 2176 | # make steps an array | ||||||||||||||||||||||||||||||||||||||||||
| 2177 | 0 | $_[0]->{'steps'} = [map {100 * $_/$n} (0 .. $n)]; | |||||||||||||||||||||||||||||||||||||||||
| 2178 | |||||||||||||||||||||||||||||||||||||||||||
| 2179 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2180 | |||||||||||||||||||||||||||||||||||||||||||
| 2181 | # print warning | ||||||||||||||||||||||||||||||||||||||||||
| 2182 | 0 | carp("'steps' value must be an integer > 1\n"); | |||||||||||||||||||||||||||||||||||||||||
| 2183 | |||||||||||||||||||||||||||||||||||||||||||
| 2184 | # delete hash entry | ||||||||||||||||||||||||||||||||||||||||||
| 2185 | 0 | delete($_[0]->{'steps'}); | |||||||||||||||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||||||||||||||||
| 2187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2188 | |||||||||||||||||||||||||||||||||||||||||||
| 2189 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2190 | |||||||||||||||||||||||||||||||||||||||||||
| 2191 | # print warning | ||||||||||||||||||||||||||||||||||||||||||
| 2192 | 0 | carp("'steps' value must be a scalar or array reference\n"); | |||||||||||||||||||||||||||||||||||||||||
| 2193 | |||||||||||||||||||||||||||||||||||||||||||
| 2194 | # delete hash entry | ||||||||||||||||||||||||||||||||||||||||||
| 2195 | 0 | delete($_[0]->{'steps'}); | |||||||||||||||||||||||||||||||||||||||||
| 2196 | |||||||||||||||||||||||||||||||||||||||||||
| 2197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2198 | |||||||||||||||||||||||||||||||||||||||||||
| 2199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2200 | |||||||||||||||||||||||||||||||||||||||||||
| 2201 | # if parameter is a scalar | ||||||||||||||||||||||||||||||||||||||||||
| 2202 | } elsif (! ref($_[0])) { | ||||||||||||||||||||||||||||||||||||||||||
| 2203 | |||||||||||||||||||||||||||||||||||||||||||
| 2204 | # use scalar value | ||||||||||||||||||||||||||||||||||||||||||
| 2205 | 0 | $dir = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 2206 | |||||||||||||||||||||||||||||||||||||||||||
| 2207 | # undefine parameter | ||||||||||||||||||||||||||||||||||||||||||
| 2208 | 0 | undef($_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 2209 | |||||||||||||||||||||||||||||||||||||||||||
| 2210 | # any other type | ||||||||||||||||||||||||||||||||||||||||||
| 2211 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2212 | |||||||||||||||||||||||||||||||||||||||||||
| 2213 | # print warning | ||||||||||||||||||||||||||||||||||||||||||
| 2214 | 0 | carp("options parameter must be a scalar or hash reference\n"); | |||||||||||||||||||||||||||||||||||||||||
| 2215 | |||||||||||||||||||||||||||||||||||||||||||
| 2216 | # undefine parameter | ||||||||||||||||||||||||||||||||||||||||||
| 2217 | 0 | undef($_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 2218 | |||||||||||||||||||||||||||||||||||||||||||
| 2219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2220 | |||||||||||||||||||||||||||||||||||||||||||
| 2221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2222 | |||||||||||||||||||||||||||||||||||||||||||
| 2223 | # return purified flag | ||||||||||||||||||||||||||||||||||||||||||
| 2224 | 0 | ▶ | return($dir ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2225 | |||||||||||||||||||||||||||||||||||||||||||
| 2226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2227 | |||||||||||||||||||||||||||||||||||||||||||
| 2228 | # make new cvst object from array | ||||||||||||||||||||||||||||||||||||||||||
| 2229 | # parameters: (ref_to_object, ref_to_array) | ||||||||||||||||||||||||||||||||||||||||||
| 2230 | sub _new_from_array { | ||||||||||||||||||||||||||||||||||||||||||
| 2231 | |||||||||||||||||||||||||||||||||||||||||||
| 2232 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 2233 | 4 | ▶ | my ($self, $array) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_from_array: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2234 | |||||||||||||||||||||||||||||||||||||||||||
| 2235 | # for each curve element | ||||||||||||||||||||||||||||||||||||||||||
| 2236 | 4 | for my $i (0 .. $#{$array}) { | |||||||||||||||||||||||||||||||||||||||||
| 2237 | |||||||||||||||||||||||||||||||||||||||||||
| 2238 | # verify object has processing methods | ||||||||||||||||||||||||||||||||||||||||||
| 2239 | 11 | ▶ | ($array->[$i]->can('transform') && $array->[$i]->can('derivative')) || croak('curve element lacks \'transform\' or \'derivative\' method'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$array->[$i]->can("transform") and $array->[$i]->can("derivative")
MC/DC0%0/2
$array->[$i]->can("transform") and $array->[$i]->can("derivative")
$array->[$i]->can("transform")
$array->[$i]->can("derivative")
Truth table33%1/3
A and B
A= $array->[$i]->can("transform")B= $array->[$i]->can("derivative")
| |||||||||||||||||||||||||||||||||||||||||||
| 2240 | |||||||||||||||||||||||||||||||||||||||||||
| 2241 | # add curve element | ||||||||||||||||||||||||||||||||||||||||||
| 2242 | 11 | $self->[1][$i] = $array->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 2243 | |||||||||||||||||||||||||||||||||||||||||||
| 2244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2245 | |||||||||||||||||||||||||||||||||||||||||||
| 2246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2247 | |||||||||||||||||||||||||||||||||||||||||||
| 2248 | # read cvst tag from ICC profile | ||||||||||||||||||||||||||||||||||||||||||
| 2249 | # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry) | ||||||||||||||||||||||||||||||||||||||||||
| 2250 | sub _readICCcvst { | ||||||||||||||||||||||||||||||||||||||||||
| 2251 | |||||||||||||||||||||||||||||||||||||||||||
| 2252 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 2253 | 0 | ▶ | my ($self, $parent, $fh, $tag) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readICCcvst: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 2254 | |||||||||||||||||||||||||||||||||||||||||||
| 2255 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 2256 | 0 | my ($buf, @mft, $table, $tag2, $type, $class, %hash); | |||||||||||||||||||||||||||||||||||||||||
| 2257 | |||||||||||||||||||||||||||||||||||||||||||
| 2258 | # set tag signature | ||||||||||||||||||||||||||||||||||||||||||
| 2259 | 0 | $self->[0]{'signature'} = $tag->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 2260 | |||||||||||||||||||||||||||||||||||||||||||
| 2261 | # seek start of tag | ||||||||||||||||||||||||||||||||||||||||||
| 2262 | 0 | seek($fh, $tag->[1], 0); | |||||||||||||||||||||||||||||||||||||||||
| 2263 | |||||||||||||||||||||||||||||||||||||||||||
| 2264 | # read tag header | ||||||||||||||||||||||||||||||||||||||||||
| 2265 | 0 | read($fh, $buf, 12); | |||||||||||||||||||||||||||||||||||||||||
| 2266 | |||||||||||||||||||||||||||||||||||||||||||
| 2267 | # unpack header | ||||||||||||||||||||||||||||||||||||||||||
| 2268 | 0 | @mft = unpack('a4 x4 n2', $buf); | |||||||||||||||||||||||||||||||||||||||||
| 2269 | |||||||||||||||||||||||||||||||||||||||||||
| 2270 | # verify tag signature | ||||||||||||||||||||||||||||||||||||||||||
| 2271 | 0 | ▶ | ($mft[0] eq 'cvst') or croak('wrong tag type'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2272 | |||||||||||||||||||||||||||||||||||||||||||
| 2273 | # for each curve set element | ||||||||||||||||||||||||||||||||||||||||||
| 2274 | 0 | for my $i (0 .. $mft[1] - 1) { | |||||||||||||||||||||||||||||||||||||||||
| 2275 | |||||||||||||||||||||||||||||||||||||||||||
| 2276 | # read positionNumber | ||||||||||||||||||||||||||||||||||||||||||
| 2277 | 0 | read($fh, $buf, 8); | |||||||||||||||||||||||||||||||||||||||||
| 2278 | |||||||||||||||||||||||||||||||||||||||||||
| 2279 | # unpack to processing element tag table | ||||||||||||||||||||||||||||||||||||||||||
| 2280 | 0 | $table->[$i] = ['cvst', unpack('N2', $buf)]; | |||||||||||||||||||||||||||||||||||||||||
| 2281 | |||||||||||||||||||||||||||||||||||||||||||
| 2282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2283 | |||||||||||||||||||||||||||||||||||||||||||
| 2284 | # for each curve set element | ||||||||||||||||||||||||||||||||||||||||||
| 2285 | 0 | for my $i (0 .. $mft[1] - 1) { | |||||||||||||||||||||||||||||||||||||||||
| 2286 | |||||||||||||||||||||||||||||||||||||||||||
| 2287 | # get tag table entry | ||||||||||||||||||||||||||||||||||||||||||
| 2288 | 0 | $tag2 = $table->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 2289 | |||||||||||||||||||||||||||||||||||||||||||
| 2290 | # make offset absolute | ||||||||||||||||||||||||||||||||||||||||||
| 2291 | 0 | $tag2->[1] += $tag->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 2292 | |||||||||||||||||||||||||||||||||||||||||||
| 2293 | # if a duplicate tag | ||||||||||||||||||||||||||||||||||||||||||
| 2294 | 0 | ▶ | if (exists($hash{$tag2->[1]})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2295 | |||||||||||||||||||||||||||||||||||||||||||
| 2296 | # use original tag object | ||||||||||||||||||||||||||||||||||||||||||
| 2297 | 0 | $self->[1][$i] = $hash{$tag2->[1]}; | |||||||||||||||||||||||||||||||||||||||||
| 2298 | |||||||||||||||||||||||||||||||||||||||||||
| 2299 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2300 | |||||||||||||||||||||||||||||||||||||||||||
| 2301 | # seek to start of tag | ||||||||||||||||||||||||||||||||||||||||||
| 2302 | 0 | seek($fh, $tag2->[1], 0); | |||||||||||||||||||||||||||||||||||||||||
| 2303 | |||||||||||||||||||||||||||||||||||||||||||
| 2304 | # read tag type signature | ||||||||||||||||||||||||||||||||||||||||||
| 2305 | 0 | read($fh, $type, 4); | |||||||||||||||||||||||||||||||||||||||||
| 2306 | |||||||||||||||||||||||||||||||||||||||||||
| 2307 | # convert non-word characters to underscores | ||||||||||||||||||||||||||||||||||||||||||
| 2308 | 0 | $type =~ s|\W|_|g; | |||||||||||||||||||||||||||||||||||||||||
| 2309 | |||||||||||||||||||||||||||||||||||||||||||
| 2310 | # form class specifier | ||||||||||||||||||||||||||||||||||||||||||
| 2311 | 0 | $class = "ICC::Profile::$type"; | |||||||||||||||||||||||||||||||||||||||||
| 2312 | |||||||||||||||||||||||||||||||||||||||||||
| 2313 | # if 'class->new_fh' method exists | ||||||||||||||||||||||||||||||||||||||||||
| 2314 | 0 | ▶ | if ($class->can('new_fh')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2315 | |||||||||||||||||||||||||||||||||||||||||||
| 2316 | # create specific tag object | ||||||||||||||||||||||||||||||||||||||||||
| 2317 | 0 | $self->[1][$i] = $class->new_fh($self, $fh, $tag2); | |||||||||||||||||||||||||||||||||||||||||
| 2318 | |||||||||||||||||||||||||||||||||||||||||||
| 2319 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2320 | |||||||||||||||||||||||||||||||||||||||||||
| 2321 | # create generic tag object | ||||||||||||||||||||||||||||||||||||||||||
| 2322 | 0 | $self->[1][$i] = ICC::Profile::Generic->new_fh($self, $fh, $tag2); | |||||||||||||||||||||||||||||||||||||||||
| 2323 | |||||||||||||||||||||||||||||||||||||||||||
| 2324 | # print warning | ||||||||||||||||||||||||||||||||||||||||||
| 2325 | 0 | print "curve set element $type opened as generic\n"; | |||||||||||||||||||||||||||||||||||||||||
| 2326 | |||||||||||||||||||||||||||||||||||||||||||
| 2327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2328 | |||||||||||||||||||||||||||||||||||||||||||
| 2329 | # save tag object in hash | ||||||||||||||||||||||||||||||||||||||||||
| 2330 | 0 | $hash{$tag2->[1]} = $self->[1][$i]; | |||||||||||||||||||||||||||||||||||||||||
| 2331 | |||||||||||||||||||||||||||||||||||||||||||
| 2332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2333 | |||||||||||||||||||||||||||||||||||||||||||
| 2334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2335 | |||||||||||||||||||||||||||||||||||||||||||
| 2336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2337 | |||||||||||||||||||||||||||||||||||||||||||
| 2338 | # write cvst tag to ICC profile | ||||||||||||||||||||||||||||||||||||||||||
| 2339 | # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry) | ||||||||||||||||||||||||||||||||||||||||||
| 2340 | sub _writeICCcvst { | ||||||||||||||||||||||||||||||||||||||||||
| 2341 | |||||||||||||||||||||||||||||||||||||||||||
| 2342 | # get parameters | ||||||||||||||||||||||||||||||||||||||||||
| 2343 | 0 | ▶ | my ($self, $parent, $fh, $tag) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_writeICCcvst: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 2344 | |||||||||||||||||||||||||||||||||||||||||||
| 2345 | # local variables | ||||||||||||||||||||||||||||||||||||||||||
| 2346 | 0 | my ($n, $offset, $size, @cept, %hash); | |||||||||||||||||||||||||||||||||||||||||
| 2347 | |||||||||||||||||||||||||||||||||||||||||||
| 2348 | # get number of curve elements | ||||||||||||||||||||||||||||||||||||||||||
| 2349 | 0 | $n = @{$self->[1]}; | |||||||||||||||||||||||||||||||||||||||||
| 2350 | |||||||||||||||||||||||||||||||||||||||||||
| 2351 | # verify number of channels (1 to 15) | ||||||||||||||||||||||||||||||||||||||||||
| 2352 | 0 | ▶ | ($n > 0 && $n < 16) || croak('unsupported number of channels'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$n > 0 and $n < 16
MC/DC0%0/2
$n > 0 and $n < 16
$n > 0
$n < 16
Truth table0%0/3
A and B
A= $n > 0B= $n < 16
| |||||||||||||||||||||||||||||||||||||||||||
| 2353 | |||||||||||||||||||||||||||||||||||||||||||
| 2354 | # seek start of tag | ||||||||||||||||||||||||||||||||||||||||||
| 2355 | 0 | seek($fh, $tag->[1], 0); | |||||||||||||||||||||||||||||||||||||||||
| 2356 | |||||||||||||||||||||||||||||||||||||||||||
| 2357 | # write tag type signature and number channels | ||||||||||||||||||||||||||||||||||||||||||
| 2358 | 0 | print $fh pack('a4 x4 n2', 'cvst', $n, $n); | |||||||||||||||||||||||||||||||||||||||||
| 2359 | |||||||||||||||||||||||||||||||||||||||||||
| 2360 | # initialize tag offset | ||||||||||||||||||||||||||||||||||||||||||
| 2361 | 0 | $offset = 12 + 8 * $n; | |||||||||||||||||||||||||||||||||||||||||
| 2362 | |||||||||||||||||||||||||||||||||||||||||||
| 2363 | # for each curve element | ||||||||||||||||||||||||||||||||||||||||||
| 2364 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 2365 | |||||||||||||||||||||||||||||||||||||||||||
| 2366 | # verify curve element is 'curf' object | ||||||||||||||||||||||||||||||||||||||||||
| 2367 | 0 | ▶ | (UNIVERSAL::isa($self->[1][$i], 'ICC::Profile::curf')) || croak('curve element must a \'curf\' object'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2368 | |||||||||||||||||||||||||||||||||||||||||||
| 2369 | # if tag not in hash | ||||||||||||||||||||||||||||||||||||||||||
| 2370 | 0 | ▶ | if (! exists($hash{$self->[1][$i]})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2371 | |||||||||||||||||||||||||||||||||||||||||||
| 2372 | # get size | ||||||||||||||||||||||||||||||||||||||||||
| 2373 | 0 | $size = $self->[1][$i]->size(); | |||||||||||||||||||||||||||||||||||||||||
| 2374 | |||||||||||||||||||||||||||||||||||||||||||
| 2375 | # set table entry and add to hash | ||||||||||||||||||||||||||||||||||||||||||
| 2376 | 0 | $cept[$i] = $hash{$self->[1][$i]} = [$offset, $size]; | |||||||||||||||||||||||||||||||||||||||||
| 2377 | |||||||||||||||||||||||||||||||||||||||||||
| 2378 | # update offset | ||||||||||||||||||||||||||||||||||||||||||
| 2379 | 0 | $offset += $size; | |||||||||||||||||||||||||||||||||||||||||
| 2380 | |||||||||||||||||||||||||||||||||||||||||||
| 2381 | # adjust to 4-byte boundary | ||||||||||||||||||||||||||||||||||||||||||
| 2382 | 0 | $offset += -$offset % 4; | |||||||||||||||||||||||||||||||||||||||||
| 2383 | |||||||||||||||||||||||||||||||||||||||||||
| 2384 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 2385 | |||||||||||||||||||||||||||||||||||||||||||
| 2386 | # set table entry | ||||||||||||||||||||||||||||||||||||||||||
| 2387 | 0 | $cept[$i] = $hash{$self->[1][$i]}; | |||||||||||||||||||||||||||||||||||||||||
| 2388 | |||||||||||||||||||||||||||||||||||||||||||
| 2389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2390 | |||||||||||||||||||||||||||||||||||||||||||
| 2391 | # write curve element position entry | ||||||||||||||||||||||||||||||||||||||||||
| 2392 | 0 | print $fh pack('N2', @{$cept[$i]}); | |||||||||||||||||||||||||||||||||||||||||
| 2393 | |||||||||||||||||||||||||||||||||||||||||||
| 2394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2395 | |||||||||||||||||||||||||||||||||||||||||||
| 2396 | # initialize hash | ||||||||||||||||||||||||||||||||||||||||||
| 2397 | 0 | %hash = (); | |||||||||||||||||||||||||||||||||||||||||
| 2398 | |||||||||||||||||||||||||||||||||||||||||||
| 2399 | # for each curve element | ||||||||||||||||||||||||||||||||||||||||||
| 2400 | 0 | for my $i (0 .. $#{$self->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 2401 | |||||||||||||||||||||||||||||||||||||||||||
| 2402 | # if tag not in hash | ||||||||||||||||||||||||||||||||||||||||||
| 2403 | 0 | ▶ | if (! exists($hash{$self->[1][$i]})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2404 | |||||||||||||||||||||||||||||||||||||||||||
| 2405 | # make offset absolute | ||||||||||||||||||||||||||||||||||||||||||
| 2406 | 0 | $cept[$i][0] += $tag->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 2407 | |||||||||||||||||||||||||||||||||||||||||||
| 2408 | # write tag | ||||||||||||||||||||||||||||||||||||||||||
| 2409 | 0 | $self->[1][$i]->write_fh($self, $fh, ['cvst', $cept[$i][0], $cept[$i][1]]); | |||||||||||||||||||||||||||||||||||||||||
| 2410 | |||||||||||||||||||||||||||||||||||||||||||
| 2411 | # add key to hash | ||||||||||||||||||||||||||||||||||||||||||
| 2412 | 0 | $hash{$self->[1][$i]}++; | |||||||||||||||||||||||||||||||||||||||||
| 2413 | |||||||||||||||||||||||||||||||||||||||||||
| 2414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2415 | |||||||||||||||||||||||||||||||||||||||||||
| 2416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2417 | |||||||||||||||||||||||||||||||||||||||||||
| 2418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2419 | |||||||||||||||||||||||||||||||||||||||||||
| 2420 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||