pydicom-seg icon indicating copy to clipboard operation
pydicom-seg copied to clipboard

Support reading into ITK images (and not just SimpleITK images)

Open aylward opened this issue 3 years ago • 0 comments

ITK now directly supports python wrapping. The wrapping provided directly by ITK is arguably more Pythonic, and it expose the entire ITK library and all optional modules, whereas SimpleITK does not.

To install ITK Python: pip install itk

It would be great if this library also provided a segment_itk_image() function that returned an ITK image and that let you specify the target pixel type. The function would be nearly identical to segment_image()

def segment_itk_image(self, number: int, ttype):
     result = itk.GetImageFromArray(self._segment_data[number].astype(ttype))
     result.SetOrigin(self.origin)
     result.SetSpacing(self.spacing)
     result.SetDirection(self.direction.ravel())
     return result

aylward avatar Sep 02 '21 14:09 aylward