Splitting a 3D image into a 4D image then saving (C++)

For a few years we switched to representing segmentations using such 4D volumes but we reverted to using 3D volumes (except for storing overlapping segments) because of increased memory requirement and incompatibility with processing algorithms. So, I would not recommend to switch to this representation just to improve segmentation quality. Instead, you can keep a 3D labelmap and increase its resolution as needed.

If you just temporarily want to split the segmentation to separate volumes then it is very easy to do, for example using threshold filter.

Nearest neighbor interpolation is not optimal, especially when the target resolution is higher. You can use these readily available approaches for labelmap interpolation or you can port your slow Python code to C++ and add Python wrapping for it (for example, make an ITK filter from it and add it as an ITK remote module).

4 Likes