LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

collapse an array

Is there a simple tool for "collapsing" an array through addition?

Specifically, I have a 3-d array which consists of a series of 2-d pictures taken with a webcam. I'd like to reduce it to a single picture by adding the pixel values from each 'exposure.' (The number of exposures is non-determinisitic and set by the user at runtime.)

Seems like there should be a pretty simple vi for this kind of operation but I haven't found it yet.

Thanks
Eric Coppock
Ball Aerospace & Technology Corp
0 Kudos
Message 1 of 4
(2,657 Views)
You should be able to use a simple FOR loop that indexes through all your 2D images and adds them sequentially to a shift register. Another possibility would be to feed it through 2 autoindexing FOR loops, containing a SUM operator.

The exact procedure heavily depends on the order in which your 3D array is indexed. It might be easier to slice it using "array index" with some indices unwired.

Do you have a small example array with a few layers? How many bits do you have per pixel and what is the data type? You might need to watch out for overflow.
0 Kudos
Message 2 of 4
(2,651 Views)
Dense newbie says "huh?"

Anytime I work with something inside a FOR loop, when I bring it out of the FOR loop it becomes an array of N of whatever it was I was working with inside the loop. That's the problem I'm trying to solve ... I'm not seeing how using another FOR loop is going to fix it.

Sorry I'm being slow. Maybe a picture would help?

Thanks
EC
0 Kudos
Message 3 of 4
(2,636 Views)
Awww jeez, I just discovered the "disable indexing" option on the tunnel exiting the for loop.

Thanks for your help! 🙂

EC
0 Kudos
Message 4 of 4
(2,634 Views)