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

Home » Public Forums » archive » simple vectorizing problem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
simple vectorizing problem [message #62465] Mon, 08 September 2008 18:47
dpm314 is currently offline  dpm314
Messages: 3
Registered: September 2008
Junior Member
Hey - here is a vectorizing question from an experienced programmer
'newish' to IDL.

I have a stack of images dimensions (nx,ny, num_images) , a LOT of
data sometimes, on which I need to preform a whole mathematical
operation on. For example, one thing I need to do is create an array
of the mean of each image.

I've done this successfully with something like
averages = fltarr(num_images)
for k = 0, NUM_OF_CLICKS-1 do averages[k] = mean(image(*,*,k)

which makes perfect sense to a c/c++/Fortran programmer. But, this
really hangs up for the size images I am working with (512*512*70000
or more). Is there a way to vectorize? I've tried several things
like:

averages = fltarr(num_images)
a = indgen(num_images)
averages(a) = mean(image(*,*,a))

I've also tried reforming the image to by 2D, with dimensions [nx*ny,
num_images] and doing a similar thing, but no luck. That included
making an array of integers, call it b, where b = 0, nx*ny*1 - 1,
nx*ny*2 - 1, nx*ny*3 - 1 ... and doing something like
averages(a) = mean(image(b[a]:b[a+1], a)
(I know this probably will run out of bounds, I can't remember right
now what I did, but it still didn't work and I had the series worked
out right...)

It seems that in a language like IDL there should be a way to do
something like this without writing a for-loop.

Thanks,

David M.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: inverse the axis
Next Topic: Weiler Atherton Clipping Algorithm

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

Current Time: Wed Oct 08 15:22:15 PDT 2025

Total time taken to generate the page: 0.00475 seconds