05-24-2016 05:42 AM - edited 05-24-2016 05:44 AM
Dear Community,
I have not worked out how to start this puzzle yet and I can't find an existing solution so I am sorry I do not have any code to attach.
I have Initialized a 3 dimensional array of size 500x500x200 with zeros which defines my DISPLAY volume from which I will then Index out the chosen axis planes to display in a Picture control.
My DATA array is also a 3 dimensional array containing the voxel values but is not necessarily 500x500x200. What I want to do is take whatever volume the DATA volume is and Overwrite/Replace/Superimpose it onto the DISPLAY volume at the {0,0,0} corner outwards, so that the resulting array is full of the DATA and then padded out to 500x500x200 with zeros.
I feel this should be a basic function but the only function I can find is the Replace Array Subset which will only substitute in 2D arrays. I don't want to have to index out every element and rebuild as this would be insanely slow and memory heavy. I also dont really want to manually 'pad' out the DATA array to 500x500x200 as this feels very clumsy and the for loops would again be slow.
I feel the In Place Element Strucuture might hold the key but can't work it out. Any help would be greatly appreciated.
Sincerely,
RG
ps. I am running LV 2015
Solved! Go to Solution.
05-24-2016 05:58 AM
Replace array subset should work, but the type it accepts on the bottom input changes depending on the number of index input you wire into it. If you want to replace a 3D array inside a 3D array, you will need to wire 0 to all 3 index inputs.
Note that you might still have performance issues. Your array has 50M elements, which could translates to hundred of MB of RAM, depending on the type and the number of copies you create, which is an issue, because arrays need to be contiguous in memory.
Also, the picture control isn't very efficient with raster images, so you might have some issues there too.
05-24-2016 06:03 AM
05-24-2016 06:49 AM
Thankyou, wiring 0 to the 3 index inputs allowed me to wire the 3D array. For some reason I thought that 0 was default on all three already.
05-24-2016 06:53 AM
Thankyou. As far as I understand it the Replace Array Subset is already an inherent "In Place" function that doesnt duplicate the memory space? I will see what the performance is like and consider how to implement the In Place structure if I need it.
05-24-2016 09:31 AM
Dear Community,
In thanks for your support I pay back with the code I finally came up with. Working with 3D arrays, the code takes an input volume and scales the values by a chosen magnification factor outputing them enclosed within an output volume of fixed size (padded if necessary).
By adding the conditional terminals (versions with and without conditionals in the zip file) I managed to gain some efficiency by not processing unnecessary elements outside the Output volume, but I am still indexing through each element which is intensive....
I have tried an "Expanding" method (also in the zip file) which works more efficiently for 2D arrays but I can't work out how to adapt it for 3D arrays.
Thanks again,
RG