我想分割图像。我使用了简单的阈值方法。为此,我读取图像并将其转换为数组,然后转换 img
import SimpleITK as sitk
import numpy as np
header = sitk.ReadImage("Sub1.png")
img = sitk.GetArrayFromImage(header)
a=img
img = ((img > 20) * 255).astype(np.uint8)
# To visualize the labels image in RGB with needs a image with 0-255 range
img_T1_255 = sitk.Cast(sitk.RescaleIntensity(a), sitk.sitkUInt8)
myshow(sitk.LabelOverlay(img_T1_255, img), "Basic Thresholding")
错误是:
TypeError Traceback (most recent call last)
<ipython-input-70-c44b80227919> in <module>()
8 img = ((img > 20) * 255).astype(np.uint8)
9 # To visualize the labels image in RGB with needs a image with 0-255 range
---> 10 img_T1_255 = sitk.Cast(sitk.RescaleIntensity(a), sitk.sitkUInt8)
~/sitkpy/lib/python3.5/site-packages/SimpleITK/SimpleITK.py in RescaleIntensity(image1, outputMinimum, outputMaximum)
58734
58735 """
> 58736 return _SimpleITK.RescaleIntensity(image1, outputMinimum, outputMaximum)
58737 class RichardsonLucyDeconvolutionImageFilter(ImageFilter_2):
58738 """
TypeError: in method 'RescaleIntensity', argument 1 of type 'itk::simple::Image const &'