These arrays are way too big to be stored on the stack, but allocating them on the heap should be no problem. The easiest way is to let STL containers or VTK or ITK objects manage the memory for you. Most CLI modules use ITK, so you can find lots of examples how to do it.
Thank you for your response @lassoan. I have seen several examples but most of the examples are manipulating image. Like taking input as an image , apply itk filter and return an image.
I need to work on these 3 dimensional large arrays. Is there any basic example in in ITK to work on these which can return a 3 dimensional array as well.
Maybe a simple example to parse these higher dimensional arrays from scripting module and return as well.
Thank you so much for all your guidance throughout this development process
Thank you for your response. I have some higher dimensional arrays and I want to perform some numerical manipulation on them. Doing this in python is very time consuming, so I am planning to parse my arrays to CLI module in C++ and perform these computationally expensive tasks in CLI module thn return the output array.
I mostly have to use simple operations like dot product and vector additions …
You cannot iterate through each voxel of an image in Python, but there are hundreds of Python packages that implement efficient processing operations on higher-dimensional arrays. See numpy, scipy, SimpleITK, VTK, scikitimage, OpenCV, etc.
In C++ you can implement pixel-by-pixel processing, but nowadays this is rarely needed, since most common low-level operations are already have nice, robust, performance-optimized implementations.
You certainly don’t need to implement such basic operations from scratch, in C++. You can add two n-dimensional numpy arrays like this: c = a + b.