Anonymous user
Zhang-Suen thinning algorithm: Difference between revisions
→{{header|Perl 6}}: use gather/take rather than push, saves initializing to ()
(→{{header|Perl 6}}: add entry) |
(→{{header|Perl 6}}: use gather/take rather than push, saves initializing to ()) |
||
Line 350:
repeat while my @goners1 or my @goners2 {
sub cycles (@neighbors) { [+] @neighbors Z< @neighbors[].rotate }
sub blacks (@neighbors) { [+] @neighbors }
@goners1 = gather for @has8 -> \p {
next unless @black[p];
my \n = @black[p8 X+ p];
Line 361 ⟶ 359:
next unless 2 <= blacks(n) <= 6;
next if all n[0,2,4] or all n[2,4,6];
}
@black[@goners1] = 0 xx *;
say "Ping: {[+] @black} remaining after removing ", @goners1 if $DEBUG;
@goners2 = gather for @has8 -> \p {
next unless @black[p];
my \n = @black[p8 X+ p];
Line 372 ⟶ 370:
next unless 2 <= blacks(n) <= 6;
next if all n[0,2,6] or all n[0,4,6];
}
@black[@goners2] = 0 xx *;
Line 396 ⟶ 394:
.........#.........####.........
................................</pre>
=={{header|Python}}==
Several input images are converted.
|