line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Imager::LineTrace; |
2
|
1
|
|
|
1
|
|
920
|
use 5.008001; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
39
|
|
3
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
17
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw(Imager); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17318
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
96735
|
use Imager::LineTrace::Algorithm; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
9
|
1
|
|
|
1
|
|
557
|
use Imager::LineTrace::Figure; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
395
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = "0.06"; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub line_trace { |
14
|
7
|
|
|
7
|
0
|
24688
|
my $self = shift; |
15
|
7
|
|
|
|
|
19
|
my %args = @_; |
16
|
|
|
|
|
|
|
|
17
|
7
|
|
|
|
|
17
|
my $channels = [ 0, 1, 2 ]; |
18
|
7
|
100
|
|
|
|
27
|
if ( exists $args{channels} ) { |
19
|
4
|
|
|
|
|
10
|
$channels = $args{channels}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
7
|
|
|
|
|
14
|
my $number_of_channels = scalar( @{$channels} ); |
|
7
|
|
|
|
|
13
|
|
23
|
7
|
|
|
|
|
32
|
my $ymax = $self->getheight() - 1; |
24
|
13
|
|
|
|
|
20
|
my @pixels = map { |
25
|
7
|
|
|
|
|
131
|
my $iy = $_; |
26
|
|
|
|
|
|
|
|
27
|
13
|
|
|
|
|
45
|
my $ary_ref = $self->getsamples( y => $iy, channels => $channels ); |
28
|
13
|
|
|
|
|
484
|
my @wk = (); |
29
|
13
|
100
|
|
|
|
19
|
if ( @{$channels} == 3 ) { |
|
13
|
50
|
|
|
|
36
|
|
|
4
|
|
|
|
|
10
|
|
30
|
9
|
|
|
|
|
43
|
my @tmp = unpack( "C*", $ary_ref ); |
31
|
9
|
|
|
|
|
24
|
while ( @tmp ) { |
32
|
27
|
|
|
|
|
40
|
my $val = shift @tmp; |
33
|
27
|
|
|
|
|
34
|
$val = ($val << 8) + shift @tmp; |
34
|
27
|
|
|
|
|
36
|
$val = ($val << 8) + shift @tmp; |
35
|
27
|
|
|
|
|
71
|
push @wk, $val; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
elsif ( @{$channels} == 2 ) { |
39
|
0
|
|
|
|
|
0
|
@wk = unpack( "S*", $ary_ref ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
4
|
|
|
|
|
18
|
@wk = unpack( "C*", $ary_ref ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
13
|
|
|
|
|
47
|
\@wk; |
46
|
|
|
|
|
|
|
} 0..$ymax; |
47
|
|
|
|
|
|
|
|
48
|
7
|
100
|
|
|
|
23
|
if ( not exists $args{ignore} ) { |
49
|
6
|
100
|
|
|
|
10
|
if ( @{$channels} == 3 ) { |
|
6
|
50
|
|
|
|
16
|
|
|
4
|
|
|
|
|
9
|
|
50
|
2
|
|
|
|
|
8
|
$args{ignore} = 0xFFFFFF; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
elsif ( @{$channels} == 2 ) { |
53
|
0
|
|
|
|
|
0
|
$args{ignore} = 0xFFFF; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
4
|
|
|
|
|
8
|
$args{ignore} = 0xFF; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
7
|
|
|
|
|
34
|
my $results = Imager::LineTrace::Algorithm::search( \@pixels, \%args ); |
61
|
7
|
|
|
|
|
37
|
my @figures = map { |
62
|
7
|
|
|
|
|
14
|
Imager::LineTrace::Figure->new( $_ ); |
63
|
7
|
|
|
|
|
11
|
} @{$results}; |
64
|
|
|
|
|
|
|
|
65
|
7
|
|
|
|
|
44
|
return \@figures; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |