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)
但问题是,我想利用 SimpleITK.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)
上面的代码块看起来很紧凑,但是array_view
fromGetArrayViewFromImage
是只读的。因此,有没有办法做到这一点?