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

Home » Public Forums » archive » Re: 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 #30788 is a reply to message #30785] Fri, 17 May 2002 11:30 Go to previous messageGo to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
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?

Here's a shorcut with no array rearrangment.
Note that the 24-bit image must be in [NCOL, NROW, 3] format:

dims = size(image, /dimensions)
ncol = dims[0]
nrow = dims[1]
chan = 0 ; red channel
image[indices + (chan * ncol * nrow)] = 255
chan = 1 ; green channel
image[indices + (chan * ncol * nrow)] = 255
chan = 2 ; blue channel
image[indices + (chan * ncol * nrow)] = 0

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ActiveX
Next Topic: sec : U Re: Carriage Return / LineFeed in Text Widget

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

Current Time: Fri Oct 10 01:45:22 PDT 2025

Total time taken to generate the page: 0.71868 seconds