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

Home » Public Forums » archive » Re: Faster than looping?
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: Faster than looping? [message #16973] Thu, 26 August 1999 00:00
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Richard Tyc wrote:
> Is there a faster way of doing the following for-loop code (it basically
> looks for yellow in an RGB image and turns it white with intensity 254 .
>
> img = bytarr(3,512,512)
>
> for j=0,511 do begin
> for k=0,511 do begin
> if (img[0,j,k] eq 255 and img[1,j,k] eq 255 and img[2,j,k] eq 0)
> then begin
> img[0,j,k] = 254
> img[1,j,k] = 254
> img[2,j,k] = 254
> endif
> endfor
> endfor

c0 = img[0, *, *]
c1 = img[1, *, *]
c2 = img[2, *, *]
index = where(c0 eq 255 and c1 eq 255 and c2 eq 0, count)
if count gt 0 then begin
c0[index] = 254
c1[index] = 254
c2[index] = 254
img[0, *, *] = temporary(c0)
img[1, *, *] = temporary(c1)
img[2, *, *] = temporary(c2)
endif

Cheers,
Liam.

--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
[Message index]
 
Read Message
Previous Topic: Re: Resetting data in IDLgrVolume object
Next Topic: Faster than looping?

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

Current Time: Sun Oct 12 04:17:59 PDT 2025

Total time taken to generate the page: 1.27952 seconds