12-12-2018 10:29 AM
Hi,
Here's what I'm trying to do. I have a big 3D array. From that 3D array, I want to extract certain rows and columns at a periodic interval. For example, I want to make a new array with the 1st, 3rd, 5th, 7th... column and the 1st, 4th, 7th, 10th... rows. That mean, if I start with a 10x100x99 array, I'll have a 10x50x33 array after this. I'm trying to make this process as fast as possible.
The way I found to do it is with this example: https://forums.ni.com/t5/LabVIEW/Indexing-an-Array-at-multiple-indexes/td-p/3082685
However, I found it counter-intuitive to use a for loop to dismantle and rebuild the whole array one element at the time and I was wonderingif there as a better way of doing it.
Thank you for the help.
RMT
Solved! Go to Solution.
12-12-2018 10:42 AM - edited 12-12-2018 10:45 AM
@RaphaelMT wrote:
However, I found it counter-intuitive to use a for loop to dismantle and rebuild the whole array one element at the time and I was wondering if there as a better way of doing it.
What is your definition of "big"? A FOR loop is perfectly fine and will be very efficient.. There is no microprocessor that could do these operations in parallel, so even if you had a primitive to do what you want, it would loop internally one way or another.
What does the 3D array data represent? do you have a choice in what order to arrange the dimensions?
Can you attach a simplified example with small arrays and typical default data to show what you expect?
... and NO, a FOR loop does not "dismantle" anything it exactly knows the final array size and will allocate that before the loop runs, then build the new array there.
12-12-2018 12:00 PM
-A typical size of data would be 10x1000x1000. By big, I just meant I can't select them all manually by adding a select index for each column.
-No, I'd like to keep the same arrangement for the dimension. They represent a series of images I'm analyzing.
-For an example, I actually failed at making one that works. Instead, I link an image of a simple matrix and what I would like in the end.
Thanks.
12-12-2018 12:22 PM - edited 12-12-2018 12:23 PM
These images are completely useless because we cannot see the third dimension, [container size != array size] and you seem to resize in at least two dimensions.
Does that mean you have 10 images at 1000x1000 each?
Do you want fewer images or do you want to crop all images?
12-12-2018 04:39 PM
I didn't show the 3rd dimension since it's the only dimension I don't want to crop.
I want the same amount of images but crop. Let's say I want one row in each 3 and one column in each 10 that means my end result will be 10 images at 334x100.
12-13-2018 11:12 AM
All you need is an autoindexing FOR loop. Inside the loop, do your decimation using a little pyramid of FOR loops . Autoindex at the output tunnels and you are all set. You can even parallelize the outer loop.
Example (there are many ways to do this):
12-13-2018 11:59 AM
Please verify correct operation. The index for the middle "index array" might not be wired to the correct terminal. This is just a rough outline.