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.