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

Home » Public Forums » archive » Re: how to create a loop?
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: how to create a loop? [message #38480] Thu, 11 March 2004 07:34
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
"Thomas Nehls" <thomas.nehls@tu-berlin.de> wrote in message news:c2pveg$p24$1@mamenchi.zrz.TU-Berlin.DE...
> Hi,
>
> I want to create a loop, in which an array is filled pixel by pixel.
> Like this a(n) = a(n-1) + C*d
>
> I tried this
>
> new = indgen(3,400,400)
> runner= indgen(3,400,400)
>
> FOR g= 0,255 DO BEGIN
> grey = imageA[2,*,*] eq g ; so grey is my mask, containing the greylevel
>
> FOR j=0,2 DO BEGIN
> new[j,*,*] = runner[j,*,*] + imageB[j,*,*]*grey ; Image B contains
> the colors I want to employ
> new = runner
> ENDFOR
> ENDFOR
>
> My questions: (i)is the runner appropriate to do what I want or are
> there better ways to do this?
> (ii) is the "+" the right way to fill the array pixel by pixel?
>
> The results were not very exciting, I got a grey diagonal striped image...
> Thank you very much
> Tom
>

Hi Tom,
your line of new = runner is merely erasing any results,
and the equivalent of what you are doing in the lines above
can be written much shorter as follows:

runner= indgen(3,400,400)

So yes, you get a diagonal striped image in runner.
Other than that I'm not sure what you are trying to do.

To fill an array "Like this a(n) = a(n-1) + C*d"

; fist allocate "a" of size "npoints"
a = fltarr(npoints)
a[0] = c*d ; guessing a starting point
for i =1,npoints-1 do begin
a[i] = a[i-1] + c*d
endfor

This could (should!) be vectorized which would be
much quicker, but perhaps that is a later lesson.

Cheers,
bob
[Message index]
 
Read Message
Previous Topic: Re: UTM WGS-84 projection with IDL?
Next Topic: Output log / 'bring to front'

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

Current Time: Wed Oct 08 19:39:36 PDT 2025

Total time taken to generate the page: 0.00409 seconds