How do I convert an array of x-y coordiates in to a image?

E

Eadmund

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
 
T

* Tong *

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.

gnuplot, no programming necessary.
 
Z

zentara

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::pic;

# 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::pic;

# random color using wpic
my $pdl = random(3,100,100 ) * 65525;
$pdl->wpic("$0.jpg")

__END__
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top