Hi,
Does anyone know how to convert an array of x-y coordinates, plotting a
shape, in to a image (BMP, GIFF etc) in Perl? I have Image magic etc.
Regards
Eadmund
PDL does this. You just need to get the dimensions of your array
data into a properly formed piddle, then use the various IO modules
to write the image in your desired format. The wim (write image )
function is probably the easiest.
PDL will want your data in a form something like [3,x,y], where the
3 represents the RGB data. Sometimes its [x,y,3] or even [x,y]
You can use PDL's IO methods to read in your raw data, and convert
it to the desired format. That is usually the trickiest part.
The PDL maillist can be very helpful, but you need to provide a sample
of what your input data looks like.
Here are 3 simple examples:
#!/usr/bin/perl
use warnings;
use strict;
use PDL::LiteF;
use PDL::IO::GD;
# a random color image using GD IO
my $pdl = random( 100, 100, 3 ) * 65525;
write_true_png_ex( $pdl, "$0.png", 9 );
__END__
####################################
#!/usr/bin/perl
use warnings;
use strict;
use PDL::LiteF;
use PDL::IO:
ic;
# random black and white using wpic
my $pdl = random( 100,100 ) * 65525;
$pdl->wpic("$0.jpg")
__END__
###################################
#!/usr/bin/perl
use warnings;
use strict;
use PDL::LiteF;
use PDL::IO:
ic;
# random color using wpic
my $pdl = random(3,100,100 ) * 65525;
$pdl->wpic("$0.jpg")
__END__