我可以在SimpleITK
中这样做
img = sitk.ReadImage(file_path)
array = sitk.GetArrayFromImage(img)
array[array > 10] = 10
array[array < 0] = 0
或者我可以这样做
img = sitk.ReadImage(file_path)
binthresh = sitk.BinaryThresholdFilter()
... # set up params for binthresh
img = binthresh.Execute(img)
但问题是,我想利用SimpleTk.ResampleImageFilter重新采样`所以我不得不像这样使用它
img = sitk.ReadImage(file_path)
binthresh = sitk.BinaryThresholdFilter()
... # set up params for binthresh
img = binthresh.Execute(img)
resample = sitk.ResampleImageFilter()
... # set up params for resample
img = resample.Execute(img)
事实上,我希望有这样的方法
img = sitk.ReadImage(file_path)
array_view = sitk.GetArrayViewFromImage(img)
array_view[array_view > 10] = 10
array_view[array_view < 0] = 0
resample = sitk.ResampleImageFilter()
... # set up params for resample
img = resample.Execute(img)
上面的代码块似乎非常紧凑,但是来自GetArrayViewFromImage
的array_view
是只读的。因此,有没有办法做到等价呢?你知道吗
在simpletik当前的
GetArrayViewFromImage
实现中,防止别名(浅拷贝)是最安全的,这样可以避免潜在的无效内存访问。因此,没有实现可写访问方法。然而,当前的开发正在致力于开发一种安全的引用计数访问方法,该方法将支持写入。你知道吗但是,SimpleTk中有一个等效的图像过滤器来执行与ClampImageFilter相同的操作。速度也更快:
相关问题 更多 >
编程相关推荐