Python - Write A Three Dimensional Image From 3D Array
I'm trying to obtain an image from 3D array and convert it to TIF 3D. I'm using simple ITK but it doesn't work. I obtain this error message : 'in method 'WriteImage', argument 1 of
Solution 1:
It looks like your sitk::Image pixel type is not supported by the TIFF ImageIO. You need to cast to one of the pixel types listed, i.e. sitk.UInt8, sitk.UInt16, sitk.Float32.
You can inspect what your current pixel type is with something like:
print("pixel id: {0} ({2})".format(test2.GetPixelID(), test2.GetPixelIDTypeAsString())
Then you can convert the pixel type of your image:
test2 = sitk.Cast(test2, sitk.Float32)
or
test2 = sitk.Cast(test2, sitk.UInt16)
etc...
Post a Comment for "Python - Write A Three Dimensional Image From 3D Array"