Moreover, the output image seems to have some noise.
It looks like the original image has a higher dynamic range than supported by the unsigned char pixel type used to read the image, so we are seeing more variations over this small range and wrap-around when the values exceed the 0-255 range. One option is to read in the image with a different pixel type with a larger range, like short, or to rescale the intensity to 0-255 with an itk.RescaleIntensityImageFilter.
However, I am unable to customize the color of the masks
The itk.LabelMapOverlayImageFilter does not support custom colors, but we may be able to add them with other classes. Can you share your input images to create an example?
The regular LabelOverlayImageFilter does support custom color maps. This is a similar filter that works with labeled images and not LabelMaps of LabelObjects.
@matt.mccormick I tried to read the image with imread but I can’t get it to work : overlayFilter.SetFeatureImage(reader.GetOutput()) AttributeError: 'itkImageSS3' object has no attribute 'GetOutput'
I also tried modifying the pixel type from unsigned char to short, but I got another error
Traceback (most recent call last):
File "/home/dre/anaconda3/lib/python3.6/site-packages/itkTemplate.py", line 266, in __getitem__
return(self.__template__[tuple(cleanParameters)])
KeyError: (<class 'itkImagePython.itkImageSS3'>, <class 'ITKLabelMapBasePython.itkLabelMap3'>)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dre/anaconda3/lib/python3.6/site-packages/itkTemplate.py", line 270, in __getitem__
return(self.__template__[tuple(cleanParameters)])
KeyError: (<class 'itkImagePython.itkImageSS3'>, <class 'ITKLabelMapBasePython.itkLabelMap3'>)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dre/Stage/LongitudinalTumorTracking/Python_Backend/segFilterv1.py", line 63, in <module>
converter = itk.LabelImageToLabelMapFilter[ImageType, LabelMapType].New()
File "/home/dre/anaconda3/lib/python3.6/site-packages/itkTemplate.py", line 274, in __getitem__
(str(parameters), self.__name__))
KeyError: "itkTemplate : No template (<class 'itkImagePython.itkImageSS3'>, <class 'ITKLabelMapBasePython.itkLabelMap3'>) for the itk::LabelImageToLabelMapFilter class"