comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Array Subscripting Puzzle
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Array Subscripting Puzzle [message #30892 is a reply to message #30790] Thu, 23 May 2002 06:07 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
JD Smith wrote:
>
> On Fri, 17 May 2002 10:53:08 -0700, David Fanning wrote:
>
>> Folks,
>>
>> I have a 24-bit image. You can interleave it anyway you like that will
>> make the problem described below trackable. At the moment it is 800 by
>> 600 by 3.
>>
>> I have the indices of something I want to draw on the image. Say they
>> are the indices of the outlines of some continents. For example, like
>> this:
>>
>> window, xsize=800, ysize=600
>> map_set, /Cylindrical, position=[0,0,1,1] map_continents, /fill a =
>> tvrd()
>> indices = where(a GT 0)
>>
>> I want to make all the outline pixels yellow. I *could* do this:
>>
>> r = Reform((image[*,*,0]))
>> g = Reform((image[*,*,1]))
>> b = Reform((image[*,*,2]))
>> r[indices] = 255
>> g[indices] = 255
>> b[indices] = 0
>> image[*,*,0] = r
>> image[*,*,1] = g
>> image[*,*,2] = b
>>
>> That seems wasteful and inelegant. There must be a way to do this in one
>> go. I'm sure it uses REBIN and REFORM, but I'm not sure in which order.
>> :-(
>>
>> Can anyone help?
>
> An excellent exercise for the reader of the rebin/reform tutorial ;)
>
> Here's what I used:
>
> inds=where(a GT 0,n) & s=size(a,/DIMENSIONS)
> image[rebin(inds,n,3)+rebin(1#(s[0]*s[1]*lindgen(3)),n,3)]= $
> rebin(1#[255,255,0],n,3)

Holy cow!

For my (relatively pokey) PC:

DF's method execution time: 0.65045297seconds
JD's method execution time: 0.28429806seconds


For my (_extremely_ pokey) sultana:

DF's method understanding time: oh, about 5-10seconds or so
JD's method understanding time: uh... still working on it.


And now, for some more syntactical gymnastics, I'm off to comp.lang.c..... :o)

paulv

--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP/EMC purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Problems importing IDL postscript from TV output into Adobe Illustrator
Next Topic: Re: Object programming with data...

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Nov 28 17:00:18 PST 2025

Total time taken to generate the page: 0.01597 seconds