LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Slice a 3D array in multiple direction?

Solved!
Go to solution
Hello. First of all I am not sure if this problem has been asked before, since I could not find any keywords that lead me to anyone who has the similar problem with me. 
 
Basically we can slice a 3D array into 2D array by using the index array function in the x, y and z direction. However I still have not figured out how to slice a 3D array in any direction I want. For example, I want to slice it in the x direction with a small angle to the right or left, as illustrated in the image. 
 
Could anyone suggest me any idea of what I should do? Thank you very much.
0 Kudos
Message 1 of 5
(2,502 Views)
Solution
Accepted by topic author hyeon_do

You'll need to identify the indices of the elements that lie along your array, then specifically index those elements, I would think.

You might find this easier to do if you first Reshape your array to be 1D, then you can pass the array into a For loop (not autoindexing) and use Index Array with an array of calculated indices (with this input to the For loop autoindexing), and autoindex the output.

 

A 2D example is below:

Index diagonallyIndex diagonally


GCentral
0 Kudos
Message 2 of 5
(2,456 Views)

@hyeon_do wrote:
Basically we can slice a 3D array into 2D array by using the index array function in the x, y and z direction. However I still have not figured out how to slice a 3D array in any direction I want. For example, I want to slice it in the x direction with a small angle to the right or left, as illustrated in the image. 
 

 

In order to slice at an arbitrary angle, you typically have non-integer indices and probably want to do some trilinear interpolation.  Start reading here. If One of the planes remains aligned with integer indices (as the Z in your picture), you could do a bilinear interpolation for each z plane.

 

Quote from the above link:

"These functions are useful to e.g. extract a profile along an arbitrary line in 2D (example) or 3D, or an arbitrary cutting plane in 3D."

 

Can you attach some simple VI with data?

 

(only if the values change little for adjacent elements, a "nearest" might be sufficient)

Message 3 of 5
(2,445 Views)

Thank you very much for your reply. I guess I already got some points to starts from your basic example. 

0 Kudos
Message 4 of 5
(2,414 Views)

@hyeon_do wrote:

Thank you very much for your reply. I guess I already got some points to starts from your basic example. 


Glad it was helpful. Although I'm grateful for the solution mark, I would for the sake of fairness point out that Altenbach's point about interpolating values is probably much more valuable - in my example I assumed that you could happily round to nearest integer index and just take that value for the sake of a simple example - his linked posts provide a typically much more useful approach (there are some situations where linear interpolation is inappropriate, but few where it is worse than nearest-neighbour).

 

Since you can probably combine the two posts to get a better result, perhaps you should mark them both as answers 😉 (or just his, but I'm happy to keep mine too 😛 )


GCentral
0 Kudos
Message 5 of 5
(2,407 Views)