use strict; use warnings; use PDL; use PDL::GSL::RNG qw(ran_bivariate_gaussian_pdf); my @insert = sample_data(); my ($XSIZE, $YSIZE) = (300, 300); my ($xcoord, $ycoord, $weight) = pdl(\@insert) # xyw nweights ->slice(",*$XSIZE,*$YSIZE,") # xyw nx ny nweights ->using(0..2); # nx ny nweights my $xbase = xvals($XSIZE)->slice(",*$YSIZE"); # nx ny my $ybase = xvals($YSIZE)->slice("*$XSIZE,"); # nx ny $| = 1; print "Generating GIF frame "; # replace Imager::Heatmap::insert_datas my @hms = map { my $h = ( $weight * ran_bivariate_gaussian_pdf( $xcoord-$xbase, $ycoord-$ybase, $_, $_, 0 ) # nx ny nweights )->mv(-1,0)->sumover; # nx ny print "."; $h; } 1..90; my $all_vals = pdl(\@hms); # dims: nx ny frame # broadcasting version of Imager::Heatmap::draw use PDL::Graphics::ColorSpace; my $frame_max = $all_vals->clump(0,1)->maxover; # dims: nxy frame, then frame $all_vals /= $frame_max->slice("*1,*1,"); # nx ny frame my $hue = (1 - $all_vals)*240; my $d = cat($hue, pdl(1), pdl(1))->mv(-1,0); # hsv nx ny frame my $all_hms = (hsv_to_rgb($d) * 255)->byte; # rgb nx ny frame # Imager::write_multi unlink($_), $all_hms->wmpeg($_) for 'heatmapb.gif'; print "\n"; sub sample_data { my @insert = (); while () { chomp; push @insert, [ split /\s+/ ] } return @insert } __DATA__ ...