Re: Newbie question (w/colorful points)... [message #23283] |
Wed, 17 January 2001 23:47 |
randystack
Messages: 5 Registered: January 2001
|
Junior Member |
|
|
> mat0=mat[*,*,0]
> mat0[ xy[*,0], xy[*,1]]=hls[*,0]
> mat1=mat[*,*,1]
> mat1[ xy[*,0], xy[*,1]]=hls[*,1]
> mat2=mat[*,*,2]
> mat2[ xy[*,0], xy[*,1]]=hls[*,2]
> mat=[[[mat0]],[[mat1]],[[mat3]]]
Marc~
Thanks so much for a great solution!
~Randy
P.S. Hmmm...looks like I'll have to start thinking like I did back in my APL
days! :)
|
|
|
|
Re: Newbie question (w/colorful points)... [message #23287 is a reply to message #23286] |
Wed, 17 January 2001 20:08  |
marc schellens[1]
Messages: 183 Registered: January 2000
|
Senior Member |
|
|
RandyStack wrote:
> << As to the fastest way to create the array, I'm
> not sure I can decipher how a 8192 vector
> relates to a 512x512 array. >>
>
> The 8192-element vector just contains the coordinates that I need to plot.
> Basically...
>
> xy(n,0)=x coordinate for point n (values 0-511)
> xy(n,1)=y coordinate for point n (values 0-511)
> hls(n,0)=hue for point n
> hls(n,1)=luminance for point n
> hls(n,2)=saturation for point n
>
> Without IDL, I'd normally go something like...
>
> declare mat(512,512,3)
> loop n from 0 to 8191
> mat(xy(n,0),xy(n,1),0)=hls(n,0)
> mat(xy(n,0),xy(n,1),1)=hls(n,1)
> mat(xy(n,0),xy(n,1),2)=hls(n,2)
> end loop
>
> ...then convert the resulting 512x512 HLS matrix mat() to RGB for display. Was
> just looking for a more expedient way to handle this in IDL rather than
> looping.
>
> Thanks,
> ~Randy
Hi Randy,
you can speed the thing up using matrix operations:
mat0=mat[*,*,0]
mat0[ xy[*,0], xy[*,1]]=hls[*,0]
mat1=mat[*,*,1]
mat1[ xy[*,0], xy[*,1]]=hls[*,1]
mat2=mat[*,*,2]
mat2[ xy[*,0], xy[*,1]]=hls[*,2]
mat[*,*,0]=mat0
mat[*,*,1]=mat1
mat[*,*,2]=mat2
In IDL the expression:
a[v1,v2,...vn] with a=n dim array, v1,v2,...vn=1 dim arrays
is a n dimensional array if the size of v1, v2, .. vn differ and one dimesional
is the size of v1,v2,...vn are the same.
cheers,
:-) marc
|
|
|
Re: Newbie question (w/colorful points)... [message #23299 is a reply to message #23287] |
Wed, 17 January 2001 14:13  |
randystack
Messages: 5 Registered: January 2001
|
Junior Member |
|
|
<< As to the fastest way to create the array, I'm
not sure I can decipher how a 8192 vector
relates to a 512x512 array. >>
The 8192-element vector just contains the coordinates that I need to plot.
Basically...
xy(n,0)=x coordinate for point n (values 0-511)
xy(n,1)=y coordinate for point n (values 0-511)
hls(n,0)=hue for point n
hls(n,1)=luminance for point n
hls(n,2)=saturation for point n
Without IDL, I'd normally go something like...
declare mat(512,512,3)
loop n from 0 to 8191
mat(xy(n,0),xy(n,1),0)=hls(n,0)
mat(xy(n,0),xy(n,1),1)=hls(n,1)
mat(xy(n,0),xy(n,1),2)=hls(n,2)
end loop
...then convert the resulting 512x512 HLS matrix mat() to RGB for display. Was
just looking for a more expedient way to handle this in IDL rather than
looping.
Thanks,
~Randy
|
|
|
Re: Newbie question (w/colorful points)... [message #23318 is a reply to message #23299] |
Wed, 17 January 2001 06:12  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
RandyStack (randystack@aol.com) writes:
> I've got a a set of 8192-element 1d arrays that I need to plot. Each point has
> an X & Y value as well as a color (the unique color for each of the 8192 points
> is specified with hue, luminance and saturation values). My question is this:
> What's the best and/or fastest and/or easiest way to plot these values over a
> 512x512 2d grid with 24-bit color? Again, each point has a unique color (and,
> if necessary, I can convert the HLS array into RGB)...I just need to end up
> with a 512x512 3-plane (RGB) matrix for further processing. Just started using
> IDL, so thanks for any assistance and direction y'all can provide...
I'd convert the color HLS array to RGB, for sure.
As to the fastest way to create the array, I'm
not sure I can decipher how a 8192 vector
relates to a 512x512 array. (Except to note
that 8192/512 = 16.) If you can reform the
vector into a 61x512 array, then some kind of
array sub-scripting of the larger 512x512 array
will surely work.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|