Example Code

Manipulating pixels in a 3D array composed of stacked 2D arrays.

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview:  This VI simply adds together all pixel values and places them in a single resultant 2D array.


Description:

The first array is a 3d array of values. The second array is a resultant 2D array of values after performing an operation on all values in the z-direction for each element. Such an array might be a collection of 2D arrays stacked on top of each other such as a collection of images. Thus, x and y are the values in an individual image while z corresponds to the image number - literally a stack of images. If the user wanted to perform some sort of analysis on each pixel, they need a way to hold the pixel value constant (x, y) and step through the stack of images in the z-direction. Finally, the result is placed in a final array after all the elements have been analyzed. This VI simply adds together all pixel values and places them in a single resultant 2D array.


Requirements: LabVIEW 2012 (or compatible). Hardware: none.


Steps to Implement or Execute Code: Run the VI.


Additional Information or References: 

 

 

Manipulating pixels in a 3D array composed of stacked 2D arrays FP.png

 

Manipulating pixels in a 3D array composed of stacked 2D arrays sn.png 

For demonstrational purposes, I simply chose to add together all the z-values for each pixel (x,y location). The loop containing this manipulation can be replaced with any other type of array operation or analysis.


 **This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Todd S.
NI Employee (retired)
on

Thanks for posting!  When you have a chance, please rename your attachment to include the LabVIEW version.  "_lvXX.VI" is fine.

Todd S.
LabVIEW Community Manager
National Instruments