LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Overwrite/Merge/Replace/Superimpose 3D array

Solved!
Go to solution

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

0 Kudos
Message 1 of 6
(3,145 Views)
Solution
Accepted by topic author rg8766

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.


___________________
Try to take over the world!
Message 2 of 6
(3,136 Views)
You will need to individually process each 2D "slice" of your cubic dataset, but you don't have to worry about padding if you start each time with an empty 500x500x200 array.

Performance should be good because you are dealing with arrays of fixed size elements (numbers) so the modifications can be done in-place. The only thing is that I'm not sure if LabVIEW will automatically do it in-place or if you will need to tell it to with an in-place structure.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 6
(3,131 Views)

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.

0 Kudos
Message 4 of 6
(3,119 Views)

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.

0 Kudos
Message 5 of 6
(3,115 Views)

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

0 Kudos
Message 6 of 6
(3,091 Views)