I've created an itk image from a numpy array (float32) of size (r, c, 3)
itk_img = itk.image_view_from_array(arr, is_vector=True)
But I can't instanciate an interpolator with the image type:
image_type = type(itk_img) # itk.itkVectorImagePython.itkVectorImageF2
interpolator = itk.LinearInterpolateImageFunction[image_type, itk.D].New()
Supported input types:
itk.Image[itk.SS,2]
itk.Image[itk.UC,2]
itk.Image[itk.US,2]
itk.Image[itk.F,2]
itk.Image[itk.D,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.US,3]
itk.Image[itk.F,3]
itk.Image[itk.D,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.Image[itk.SS,4]
itk.Image[itk.UC,4]
itk.Image[itk.US,4]
itk.Image[itk.F,4]
itk.Image[itk.D,4]
itk.Image[itk.Vector[itk.F,4],4]
itk.Image[itk.CovariantVector[itk.F,4],4]
itk.Image[itk.RGBPixel[itk.UC],4]
itk.Image[itk.RGBAPixel[itk.UC],4]
Creating the resampler with image_type works fine.
I just can't find a working combination of types... Is 3 float vector not supported in python ? Thanks for any help!
CodePudding user response:
If your pixel type were UC instead of F, your image would be itk.Image[itk.RGBPixel[itk.UC],2]
(based on the relevant code), which is a supported pixel type. So either cast to UC (itk_img = itk_img.astype(itk.UC)
) or use RescaleIntensity.
CodePudding user response:
Compile ITK from source, and enable the extra type wrapping to suit your needs.
Way 1: build ITK with ITK_WRAP_PYTHON=ON and other relevant options, then copy the WrapITK.pth
build tree file to your virtual environment or conda environment site-packages, see release docs.
Way 2: follow the instructions for creating a custom wheel.