Hi Mark:  You can manage PDLs as images like this:

pdl> $im = zeroes(3,100,100)
pdl> $im->slice(":,50,:") .= 255;
pdl> wpic $im, 'im.jpg'

This writes a JPEG image which is black with a vertical white stripe down the middle.

(wim seems to do the same thing).

The trick here is to understand that images are just 3 x Xdim x Ydim byte matrices, with the 3 dim being red, green and blue bytes.

So, you could take your 2D PDL of ones and zeroes and convert it to a 3D PDL with all 3 of the RGB dimension being 255 for white and 0 for black.

Hope this helps,

  Doug Hunt


[email protected]
Software Engineer
UCAR - COSMIC, Tel. (303) 497-2611

On Thu, 15 Sep 2011, MARK BAKER wrote:


___________________________________________________________________________________________________________________________________________
From: MARK BAKER <[email protected]>
To: Matthew Kenworthy <[email protected]>
Sent: Thursday, September 15, 2011 2:37 PM
Subject: Re: [Perldl] Can any one help me on this ???

Hey Matt

I want to be able to take a large matrix of "ones" and "zeros" (about 150000)
and make a 2D  black and white picture ...

for example if i had the matrix

[0 1 0 1 0 1 0]
[0 1 1 1 1 1 1]
[1 1 1 1 1 1 0]

I want to make a Black and white picture like 

 ?  ? ?
 ??????
??????


now if you can see that it is some black squares
and the lack of black squares , and I want to use
use PDL::Image2D  and     imagrgb  to do it
im just lacking the the way to go about it properly
so im doing some reading, I wonder tho if you could
help me !

Thanks

Mark R Baker













___________________________________________________________________________________________________________________________________________
From: Matthew Kenworthy <[email protected]>
To: MARK BAKER <[email protected]>
Sent: Thursday, September 15, 2011 2:01 PM
Subject: Re: [Perldl] Can any one help me on this ???

Mark,

I'm not sure what you're trying to do - do you want to display a 2D
image on a display?

Matt

On Thu, Sep 15, 2011 at 10:01 PM, MARK BAKER <[email protected]> wrote:
> ________________
> I have been trying to get a binary 2D picture where the zeros are black and
> the ones are white
> but im having trouble trying to figure out how to put
>
> [0 1 0 0 1 1 1 0 1 0 1 0]
> [0 1 0 1 1 0 1 1 1 0 1 0]
> [0 1 1 0 1 0 1 0 1 1 1 0]
>
> something like this in a black and white picture
>
> can any one help me with this ...
>
> my attempt at rewriting the lucy demo to it
> is but I feel really lost here...
>
> use PDL; use PDL::Image2D; use PDL::Graphics::TriD;nokeeptwiddling3d;
>
>
> for $x (0..1,1,1,0) {
> for $y (reverse 0..1,0,0,1) {
> for $z (reverse 1..999) {
>  $z = 0.001*$z;
>  $d=byte(random(zeroes(1000,100))>$z);
>  $k=byte [[$x,$y,$x,$y],[$y,$y,$x,$y],[$y,$x,$x,$x]];
> do{ imagrgb [$d];
>  $s=conv2d($d,$k);
>  $d&=($s<5);
>  $d&=($s>1);
>  $d|=($s==3);
> } while (!twiddle3d);
> }
> } }
>
> Thanks
>
> Mark R Baker
>
> ______________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>
>
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>
>



--
Matthew Kenworthy / Assistant Professor / Leiden Observatory
Niels Bohrweg 2 (#463) / P.O. Box 9513 / 2300 RA Leiden / NL





_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to