话不多说,直接上图
需要把图片中灰度值大于12000的值全部置0
采用for循环遍历所以的像素点,在Simpleitk中,访问像素点采用的命令是GetPixel
name0= 'H:\\CT-image\\touce\\0004.mhd'
a0=sitk.ReadImage(name0, sitk.sitkFloat32)
nda = sitk.GetArrayViewFromImage(a0)
maxvoxel = np.max(nda)
print('maxvoxel',maxvoxel)
for i in range(nda.shape[1]):
for j in range(nda.shape[0]):
if a0.GetPixel(i, j)>12000:
a0[i,j]=0
maxvoxel = np.max(nda)
print('maxvoxel',maxvoxel)