【发布时间】:2018-06-28 22:54:03
【问题描述】:
当我应用阈值时出现错误:
import SimpleITK as sitk
img = sitk.ReadImage("Sub1.png")
img=img>20
错误是:
RuntimeError Traceback (most recent call last)
<ipython-input-48-a1d4494dca15> in <module>()
1 #img = sitk.Image(img.GetSize(), sitk.sitkUInt8)
----> 2 img=img>20
~/sitkpy/lib/python3.5/site-packages/SimpleITK/SimpleITK.py in __gt__(self, other)
4424 return Greater( self, other )
4425 try:
-> 4426 return Greater( self, float(other) )
4427 except (ValueError, TypeError):
4428 return NotImplemented
~/sitkpy/lib/python3.5/site-packages/SimpleITK/SimpleITK.py in Greater(*args)
34345
34346 """
> 34347 return _SimpleITK.Greater(*args)
34348 class GridImageSource(ImageFilter_0):
34349 """
RuntimeError: Exception thrown in SimpleITK Greater: /tmp/SimpleITK/Code/Common/include/sitkMemberFunctionFactory.hxx:209:
sitk::ERROR: Pixel type: vector of 8-bit unsigned integer is not supported in 2D byN3itk6simple18GreaterImageFilterE
我申请了img = sitk.Image(img.GetSize(), sitk.sitkUInt8),但得到的是黑色图像。
在 Python 中有没有像 double(img) 或 im2bw 这样的选项?会正常工作吗?
print(img) 给出以下内容
VectorImage (0x2f57af0) RTTI 类型信息:itk::VectorImage 引用计数:1 修改时间:1289 调试:关闭对象名称:观察者: 无源:(无)源输出名称:(无)发布数据:关闭数据发布:False 全局发布数据:关闭 PipelineMTime:1278 UpdateMTime:1288 RealTimeStamp:0 秒 LargestPossibleRegion: 尺寸:2 索引:[0, 0] 大小:[305, 305] 缓冲区域: 尺寸:2 索引:[0, 0] 大小:[305, 305] 请求区域: 尺寸:2 索引:[0, 0] 大小:[305, 305] 间距:[1, 1] 原点:[0, 0] 方向:1 0 0 1
IndexToPointMatrix: 1 0 0 1
PointToIndexMatrix: 1 0 0 1
反向:1 0 0 1
向量长度:4 像素容器: ImportImageContainer (0x24ba950) RTTI 类型信息:itk::ImportImageContainer 参考数:1 修改时间:1285 调试:关闭 对象名称: 观察员: 没有任何 指针:0x30bb390 容器管理内存:true 尺寸:372100 容量:372100
【问题讨论】:
标签: python image-processing simpleitk image-thresholding