Re: array operations [message #55814 is a reply to message #55813] |
Wed, 12 September 2007 03:18   |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
payon@gmx.de writes:
> Hello,
> I have a small question to an array operation.
>
> I have a 3-dimensional array. 10x10x100 ... the first 2 dimensions
> 10x10 are spatial dimensions (so one image with 10 width with and 10
> pix height). The third dimension is the time dimension. So every
> images was acquired 100 times.
>
> What I wanted to do is now to compute the the mean of every pixel in
> time dimension.
>
> So for one special pixel (e.g. [3,3]) i would write
>
> meanpixel = mean(myarray[3,3,*])
>
> but how is it, if i would like to do this operation for every pixel in
> the spatial dimensions? I just saw a possibility with a for loop.
>
If you are just computing the mean value, then using TOTAL is the
fastest. You can sum over any axis you wish, and then divide by the
number of pixels in the sum.
For example,
mean_image = total(myarray,3) / 100
would give the mean image. The "3" tells TOTAL to sum over the third
dimension.
Good luck,
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|