Hi all,
In discussion on the ITKStrain remote module we recently encountered a question of handling vector-valued image data in the ITK Python wrapping. I’ve worked with itk.VectorImage
and itk.Image[itk.Vector[t,d],d]
types separately, but I’m hoping someone can clarify the best way to convert between the two.
In my experience so far it seems that the Python wrapping favors importing vector-valued data from outside sources into itk.VectorImage
objects given their ability to accommodate itk.VariableLengthVector
s of arbitrary length, as opposed to greatly increasing the wrapping coverage for itk.Vector
. However, wrappings for ITK filter classes typically favor itk.Image
s with fixed-length itk.Vector
pixel types, such as in the case of the itk.StrainImageFilter
under discussion in the original thread. The ITK Software Guide also favors the itk.Image
type with little discussion of itk.VectorImage
s. The itk.VectorImage
documentation emphasizes that the formats differ in their memory organization, so they are not directly interchangeable. As expected, attempting to cast directly between an itk.Image
and itk.VectorImage
fails.
The brute force solution this problem is to allocate and iteratively fill a new object, but that seems poorly optimized. Is there a recommended method for moving vector data between an itk.Image
and itk.VectorImage
of the same size and vector length, both in c++ and Python?
Thank you!