Transfer from CPUImage to GPUImage

I need transfer from CPUImage to GPUImage in python. And I find this discourse by use itk.cuda_image_to_image_filter() to complete the conversion.
But the error prompt seems that the fuction only support input type as GPUImage:

itk.support.extras.TemplateTypeError: itk.CudaImageToImageFilter is not wrapped for input type `itk.Image[itk.F,3], itk.CudaImage[itk.F,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.CudaImageToImageFilter.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.CudaImageToImageFilter[itk.CudaImage[itk.F,2], itk.CudaImage[itk.F,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`.
Supported input types:
itk.CudaImage[itk.F,2]
itk.CudaImage[itk.F,3]
itk.CudaImage[itk.F,4]
itk.CudaImage[itk.Vector[itk.F,2],2]
itk.CudaImage[itk.Vector[itk.F,2],3]
itk.CudaImage[itk.Vector[itk.F,2],4]
itk.CudaImage[itk.Vector[itk.F,3],2]
itk.CudaImage[itk.Vector[itk.F,3],3]
itk.CudaImage[itk.Vector[itk.F,3],4]
itk.CudaImage[itk.Vector[itk.F,4],2]
itk.CudaImage[itk.Vector[itk.F,4],3]
itk.CudaImage[itk.Vector[itk.F,4],4]
itk.CudaImage[itk.Vector[itk.F,5],2]
itk.CudaImage[itk.Vector[itk.F,5],3]
itk.CudaImage[itk.Vector[itk.F,5],4]
itk.CudaImage[itk.F,3]
itk.CudaImage[itk.F,3]
itk.CudaImage[itk.F,2]
itk.CudaImage[itk.F,3]
itk.CudaImage[itk.F,4]
itk.CudaImage[itk.Vector[itk.F,2],2]
itk.CudaImage[itk.Vector[itk.F,2],3]
itk.CudaImage[itk.Vector[itk.F,2],4]
itk.CudaImage[itk.Vector[itk.F,3],2]
itk.CudaImage[itk.Vector[itk.F,3],3]
itk.CudaImage[itk.Vector[itk.F,3],4]
itk.CudaImage[itk.Vector[itk.F,4],2]
itk.CudaImage[itk.Vector[itk.F,4],3]
itk.CudaImage[itk.Vector[itk.F,4],4]
itk.CudaImage[itk.Vector[itk.F,5],2]
itk.CudaImage[itk.Vector[itk.F,5],3]
itk.CudaImage[itk.Vector[itk.F,5],4]
itk.CudaImage[itk.F,3]
itk.CudaImage[itk.F,3]
itk.CudaImage[itk.Vector[itk.F,2],3]
itk.CudaImage[itk.Vector[itk.F,3],3]
itk.CudaImage[itk.Vector[itk.F,4],3]
itk.CudaImage[itk.Vector[itk.F,5],3]
itk.CudaImage[itk.F,3]
itk.CudaImage[itk.F,3]
itk.CudaImage[itk.Vector[itk.F,2],3]
itk.CudaImage[itk.Vector[itk.F,3],3]
itk.CudaImage[itk.Vector[itk.F,4],3]
itk.CudaImage[itk.Vector[itk.F,5],3]
itk.CudaImage[itk.F,3]
itk.CudaImage[itk.F,3]
itk.CudaImage[itk.F,3]
itk.CudaImage[itk.F,4]

How can I handle conversion from CPU to GPU images in Python? Any help would be appreciated.

The answer could be find on this topic topic by SetPIxelContainer method complete the conversion.
I tested cast filter but error happened.

1 Like

Perhaps @simon.rit can help?

I could have but I think @zhangm solved the problem with my answer in this topic, right?

2 Likes