##################################
########### Ready to go
##################################
use Time::HiRes 'time';
my $t = time;
$image = t_lab-> apply(( !t_srgb )-> apply( $image ));
$palette = t_lab-> apply(( !t_srgb )-> apply( $palette ));
my $indexed = delta_e_2000(
$palette, $image-> dummy( 1, $plt_size )
)-> minimum_ind;
print time - $t, "\n";
print @pixels[ @$_ ], "\n" for @{ $indexed-> unpdl };
####
##################################
########### Ready to go
##################################
use Time::HiRes 'time';
my $t = time;
my ( undef, $w, $h ) = $image-> dims;
my $fat_rgb = $image-> clump( 1, 2 );
my $perm_2_sort = $fat_rgb-> qsortveci;
my $sorted = $fat_rgb-> dice_axis( 1, $perm_2_sort );
my $enumerated = $sorted-> enumvecg;
my $selector = $enumerated-> uniqind;
my $slim_rgb = $sorted-> dice_axis( 1, $selector );
$slim_rgb = t_lab-> apply(( !t_srgb )-> apply( $slim_rgb ));
$palette = t_lab-> apply(( !t_srgb )-> apply( $palette ));
my $slim_indexed = delta_e_2000(
$palette, $slim_rgb-> dummy( 1, $plt_size )
)-> minimum_ind;
my $indexed = $slim_indexed
-> index( $enumerated ) # fatten
-> index( $perm_2_sort-> qsorti ) # permute to original
-> reshape( $w, $h ); # reshape :)
print time - $t, "\n";
print @pixels[ @$_ ], "\n" for @{ $indexed-> unpdl };
##
##
$fat_rgb-> sever-> inplace-> and2( 0b1111_1110 );
##
##
pdl> $x = zeroes 3,2,2; $y = $x-> clump( 1,2 )
pdl> $x .= 3
pdl> p $x, $y, $y-> uniqvec
[
[
[3 3 3]
[3 3 3]
]
[
[3 3 3]
[3 3 3]
]
]
[
[3 3 3]
[3 3 3]
[3 3 3]
[3 3 3]
]
[
[3 3 3]
]
pdl> $x = zeroes 3,2,2; $y = $x-> clump( 1,2 )
pdl> $y .= 3
pdl> p $x, $y, $y-> uniqvec
[
[
[3 3 3]
[3 3 3]
]
[
[3 3 3]
[3 3 3]
]
]
[
[3 3 3]
[3 3 3]
[3 3 3]
[3 3 3]
]
[
[0 0 0]
]
##
##
pdl> $x = zeroes 3,2,2; $y = $x-> clump( 1,2 )
pdl> p $y
[
[0 0 0]
[0 0 0]
[0 0 0]
[0 0 0]
]
pdl> $x .= 3
pdl> p $x, $y, $y-> uniqvec
[
[
[3 3 3]
[3 3 3]
]
[
[3 3 3]
[3 3 3]
]
]
[
[0 0 0]
[0 0 0]
[0 0 0]
[0 0 0]
]
[
[0 0 0]
]