SimpleITK读取和保存nii图像
注意SimpleITK读取的图像,顺序为(z,y,x)
import SimpleITK as sitk
itk_img = sitk.ReadImage('./***.nii.gz')
img = sitk.GetArrayFromImage(itk_img)
print("img shape:",img.shape)
## save
out = sitk.GetImageFromArray(img)
# # out.SetSpacing(itk_img.GetSpacing())
# # out.SetOrigin(itk_img.GetOrigin())
sitk.WriteImage(out,'***.nii.gz')
nibabel读取nii图像
image_data=nib.load(path).get_data()
网友评论