10-24-2006 03:29 PM
10-24-2006 07:44 PM
Not sure I'm entirely clear on what you're dealing with.
I'm going to suppose that your X,Y, and Z are just integer indices into a 3D matrix, and the value found at (X,Y,Z) is your measurement. For conversation's sake, I'll imagine this as a cubic grid of temperature probes in a fluid of interest.
If I'm on the right track, then each value of index Z represents a different X-Y plane. It sounds like you want to average over Z, i.e., find an average X-Y plane.
If so, then at least half the battle is making sure you build your 3D matrix properly, so a single auto-indexed For loop will index on the Z dimension, extracting each of the XY planes. You can then easily use a Shift Register to sum up your X-Y planes and then divide by count after the loop for an average.
Then again, maybe that's not even close to what you're after. If not, can you post again with more detail?
-Kevin P.
10-25-2006 04:10 AM
10-25-2006 07:54 AM
Wiebe@CARYA wrote:
Another tactic might be to flatten the 3d array to one 1d array. If you do this correct (depending on how the 3d array is build up)...
It might be faster, but the only way to find out is to try it out.I *think* that the 3d build-up that makes Wiebe's idea work would be different than the one that makes auto-indexing work. A speed trial (including any gyrations required to perform each type of build-up) would be a good idea. That said, I expect his other ideas might well prove to be faster yet. Here they are again for emphasis:
Have you thought about avoiding the 3d array?
Or averaging the data each time you add a sample (by keeping the last average and the number of samples, you can add a new sample to the average without averaging all the data)?-Kevin P.
10-25-2006 08:14 AM
10-25-2006 09:50 AM
Are you sure that there isn't a different driver call that would just give you each 2D snapshot one at a time rather than all at once as a 3D matrix? This would let you build up a cumulative average with each successive frame. Dunno your device, but it "feels like" an option that ought to be available. Perhaps you can't get the frame rate you need that way, but don't discount it too fast. You don't have to snap--calc--snap--calc in series. You can have parallel loops with a queue for the 2D pic. One loop does snap--enqueue--snap--enqueue... while the other loop does dequeue--calc--dequeue--calc.
But if you're really really stuck with 3D data, you're at the mercy of the arrangement used by the driver. It certainly seems logical that it'd be arranged such that Wiebe's idea to reshape into 1D and operate on subsets could work. One frame probably occupies one contiguous chunk of memory, and each successive frame probably appends additional contiguous chunks.
(Note to purists: Yeah, I know, if the imaging code is C-like, individual frames wouldn't need to be laid out in consecutive memory. But the part of the driver that's going to return a by-value LV-compatible 3D array still would.)
-Kevin P.
10-25-2006 10:23 AM
10-25-2006 12:13 PM
Ok, I hope to show an example later but first need to know how the data is arranged in the 3D matrix. If you were to index a value out of the 3D matrix using "Index Array", you'll have 3 index terminals to wire. Going from top to bottom, which is X, which is Y, and which is Z?
Also, since speed is a concern, what are your standard sizes for the X and Y dimensions? What is a reasonable range to expect for Z, the # of frames to average? From the time you receive the 3D matrix, how soon must you have an averaged result?
-Kevin P.
10-25-2006 12:30 PM
10-25-2006 12:38 PM