I am currently trying to get the interpolated vector at a subpixel location using the itk.LinearInterpolateImageFunction in python. It was my understanding that this function is supposed to support both vector and scalar images (as it seems itk.VectorLinearInterpolateImageFunction doesnt exist in the python wrapper?)
However, when I use this function, it returns a scalar, when I expect that it would return an interpolated vector at the given location.
Trying to instantiate this: interpolator = itk.LinearInterpolateImageFunction[ImageType].New(im) results in a traceback with a useful error message:
Traceback (most recent call last):
File "C:\Dev\ITK-py11\Wrapping\Generators\Python\itk\support\template_class.py", line 525, in __getitem__
this_item = self.__template__[key]
~~~~~~~~~~~~~~~~~^^^^^
KeyError: (<class 'itk.itkImagePython.itkImageVF33'>,)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Dev\ITK-py11\Wrapping\Generators\Python\itk\support\template_class.py", line 529, in __getitem__
raise itk.TemplateTypeError(self, key)
itk.support.extras.TemplateTypeError: itk.LinearInterpolateImageFunction is not wrapped for input type `itk.Image[itk.Vector[itk.F,3],3]`.
To limit the size of the package, only a limited number of
types are available in ITK Python. To print the supported
types, run the following command in your python environment:
itk.LinearInterpolateImageFunction.GetTypes()
Possible solutions:
* If you are an application user:
** Convert your input image into a supported format (see below).
** Contact developer to report the issue.
* If you are an application developer, force input images to be
loaded in a supported pixel type.
e.g.: instance = itk.LinearInterpolateImageFunction[itk.Image[itk.SS,2], itk.D].New(my_input)
* (Advanced) If you are an application developer, build ITK Python yourself and
turned to `ON` the corresponding CMake option to wrap the pixel type or image
dimension you need. When configuring ITK with CMake, you can set
`ITK_WRAP_${type}` (replace ${type} with appropriate pixel type such as
`double`). If you need to support images with 4 or 5 dimensions, you can add
these dimensions to the list of dimensions in the CMake variable
`ITK_WRAP_IMAGE_DIMS`.
Supported input types:
itk.Image[itk.SS,2]
itk.Image[itk.UC,2]
itk.Image[itk.F,2]
itk.Image[itk.Vector[itk.F,2],2]
itk.Image[itk.CovariantVector[itk.F,2],2]
itk.Image[itk.RGBPixel[itk.UC],2]
itk.Image[itk.RGBAPixel[itk.UC],2]
itk.Image[itk.SS,3]
itk.Image[itk.UC,3]
itk.Image[itk.F,3]
itk.Image[itk.Vector[itk.F,3],3]
itk.Image[itk.CovariantVector[itk.F,3],3]
itk.Image[itk.RGBPixel[itk.UC],3]
itk.Image[itk.RGBAPixel[itk.UC],3]
itk.PhasedArray3DSpecialCoordinatesImage[itk.F]
itk.PhasedArray3DSpecialCoordinatesImage[itk.UC]
>>> print(ImageType)
<class 'itk.itkImagePython.itkImageVF33'>
So try to construct ImageType as one of the types wrapped by LinearInterpolateImageFunction.