当我应用阈值时,出现错误:
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 调试:关闭对象名称:观察者:无源:(无)源输出名称:(无)发布数据:关闭数据发布:假全局发布数据:关闭 PipelineMTime:1278 UpdateMTime:1288 RealTimeStamp:0 秒 LargestPossibleRegion:维度:2 索引:[0, 0] 大小:[305, 305] BufferedRegion:维度:2 索引:[0, 0] 大小:[305, 305 ] RequestedRegion: 维度: 2 索引: [0, 0] 大小: [305, 305] 间距: [1, 1] 原点: [0, 0] 方向: 1 0 0 1
索引到点矩阵:1 0 0 1
点到索引矩阵:1 0 0 1
反向:1 0 0 1
VectorLength:4 PixelContainer:ImportImageContainer (0x24ba950) RTTI typeinfo:itk::ImportImageContainer 参考计数:1 修改时间:1285 调试:关闭对象名称:观察者:无指针:0x30bb390 容器管理内存:true 大小:372100 容量:372100
</p>