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



On 28 Dec 2006 06:14:23 -0800, Eadmund@xxxxxxxxxxxxx wrote:

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__








--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
.



Relevant Pages

  • Re: matching password problem
    ... and turn on warnings. ... You don't need to store the usernames and passwords in arrays in your code, because you only need to look at ONE username and ONE password at a time. ... And if you DID want to store them, you should use a hash, not an array. ... use strict; use warnings; ...
    (perl.beginners)
  • Re: read consecutive lines
    ... use strict; ... use warnings; ... Not clear to me what you want in this for loop: ... There is no array @l that could be accessed with $l. ...
    (perl.beginners)
  • Re: Remove an element from middle of array
    ... use strict; ... use warnings; ... use diagnostics; ... array and then using the array to assign to hash. ...
    (perl.beginners)
  • Re: Module questions (perhaps a module creation mini-tutorial)
    ... > use warnings; ... > use strict; ... You shouldn't be using this array. ... > package I am calling. ...
    (perl.beginners)
  • Re: K&R2 section 2.7 type conversions (exercise)
    ... warnings), ... we are asked to write a function "htoi(an array)" that accomplishes ... value of type char. ... int main{ ...
    (comp.lang.c)