0
votes

I'm new in programming with Python and I need to translate code from c++ to python using the itk library, but I'm encountering many difficulties. I show you an example, in the c++ code I have :

typedef itk::PasteImageFilter <Image3D, Image3D, Image3D> PasteImageFilterType;

with:

typedef itk::Image <unsigned char, 3> BinaryImageType3D

I translate it in Python in this way:

PasteImageFilterType = itk.PasteImageFilter[itk.Image[itk.UC, 3], itk.Image[itk.UC, 3], itk.Image[itk.UC, 3]]

But I obtain the following error:

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.PasteImageFilter.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.PasteImageFilter[itk.Image[itk.SS,2]].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.

Can someone explain how I can deal with this problem? Consider that it's not only for this function that I have this problem, but for many others; I don't find any documentation of itk for python; and I haven't understood very well the solution proposed by python. In your opinion which is the best strategy to deal with this error.

Thank you very much for the help