How to pass output memory to a filter (avoid a copy to external memory)?

emmenlau
Thu, 14 Oct 2021 13:32:31 +0000
Engineering

We use ITK together with a lot of older code that has its own memory management. It was quite easy to wrap our memory containers into an itk::Image using itk::ImportImageFilter. It was also very straightforward to apply filters and other processing to the wrapped memory. Awesome!

Now I fail to see if we can do the same for the output (result) image. Instead of getting a new memory block from GetOutput(), we would prefer to pass a wrapped itk::Image (i.e. again from itk::ImportImageFilter) to the last step of the pipeline.

I could not see something like SetOutput(). Does that exist, and if not, are there hints how to implement it?

Note that our goal is to avoid the second memory copy, mostly to save RAM, but also for performance reasons. So I’m not looking for a convenient way to copy the memory. Rather, I want to avoid the second copy alltogether, and have the last filter step write directly to our memory.

11 posts - 3 participants