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

Home » Public Forums » archive » Re: a newbie question on code efficiency
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: a newbie question on code efficiency [message #26298 is a reply to message #26297] Fri, 17 August 2001 20:47 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
GB Smith (gogosgogos@usa.net) writes:

> i have a little challenge for you which i stumbled into..
> i tried to write a program which takes a 3d array,
> sets a cutoff at a certain level and then creates a mask
> of all values above that level. the mask has to be 1 and 0.
> i came up with this code, but could never get rid of the loop.
>
> any suggestions on how to get rid of the loop?
> i would prefer array operators for speed :)
>
> ;----------------------------------------------------------- ------
>
> PRO MAKE_MASK
>
> a = dialog_pickfile()
> b = READ_BINARY(a, DATA_TYPE=1, DATA_DIMS=[160,256,256])
>
> b_dims = size(b)
> x_dim = b_dims[1]
> y_dim = b_dims[2]
> z_dim = b_dims[3]
>
> cutoff = 180
>
>
> e = b
>
> for i = 0, (x_dim-1) do begin
> for j = 0, (y_dim-1) do begin
> for k = 0, (z_dim-1) do begin
>
> if e[i,j,k] lt cutoff then e[i,j,k]=0
> if e[i,j,k] ge cutoff then e[i,j,k]=1
>
> endfor
> endfor
> endfor
>
> ; and so on to use the mask further in the program
>
>
> END

My goodness, an array operator question even I
can handle! :-)

e = b GE cutoff

Cheers,

David
--

---
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: object graphic / direct graphic
Next Topic: call_method

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

Current Time: Fri Oct 10 15:00:22 PDT 2025

Total time taken to generate the page: 1.59686 seconds