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

Home » Public Forums » archive » 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
a newbie question on code efficiency [message #26299] Fri, 17 August 2001 19:54
gogosgogos is currently offline  gogosgogos
Messages: 15
Registered: July 2001
Junior Member
Dear group members,

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
[Message index]
 
Read Message
Previous Topic: Re: 2 questions
Next Topic: Re: on-screen slider

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

Current Time: Fri Oct 10 10:30:25 PDT 2025

Total time taken to generate the page: 0.56477 seconds