如何可视化标签图像



我想分割一个图像。我使用了简单的阈值方法。为此,我读取图像并将其转换为数组,然后转换 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 &'

您已经转换了 SimpleITK sitk。图像对象,"标头"(此变量名称表示对什么 sitk 的缺失理解。ReadImage 返回 (,到 numpy nd.array。SimpleITK 过滤器、函数和重载运算符仅适用于 sitk。图像类型。

最新更新