Resample a vector image with transform

I understand how to resample a single channel image, but am having trouble figuring out how to to do it with a rgb image.

I am creating and image from a numpy array, reading it in like:

f_sitk = sitk.GetImageFromArray(np_image, isVector=vector)
f_sitk.SetSpacing(spacing)
f_sitk.SetOrigin(origin)

This method does not work with the image using this approach :

 moving_resampled = sitk.Resample(t_sitk, f_sitk,  transform, sitk.sitkLinear, 0.0, t_sitk.GetPixelID())

I think this would use something like the following:

Dimension = 2
PixelType = itk.RGBPixel[itk.UC]
ImageType = itk.Image[PixelType, Dimension]

the problem I think is that I want to do this in simpleITK, because otherwise I am mixing things together in a convoluted way, and having tried the above I get a type error.

either I need an equivalent SimpleITK version for RGB, or a way to convert a composite sitk transform to itk transform…

I have discovered this :

# Extract first three channels of joined image (assuming RGB)
select = sitk.VectorIndexSelectionCastImageFilter()
channel1_image = select.Execute(joined_image, 0, sitk.sitkUInt8)
channel2_image = select.Execute(joined_image, 1, sitk.sitkUInt8)
channel3_image = select.Execute(joined_image, 2, sitk.sitkUInt8)

I found that I can resample each component individually.

However from @blowekamp:

So I must be missing something.

Please elaborate on “does not work”. Do you get an error message?

I’m going to get that t_sitk.GetPixelID(), the output pixel type is a scalar and not a vector image. Setting the output pixel type to the same as the input.

@blowekamp it returns an error, I will have to find it. it was something about types not being the same.

I think it was vector of unit8 is not allowed. or something like that,

what’s even more weird is that the above code works on the computer I am using at present, but it gave me the error on my home computer last night. I wonder if there is a difference between which types are wrapped with sitk?

@blowekamp
I must have gotten confused, I think maybe I was calling Resample without passing the PixelID in and user defined function…

I will have to try again at home to see if the issue is between the seat and keyboard…