在SimpleITK中,各术语对应如下:
Width: 宽度,X轴,矢状面
Height: 高度,Y轴,冠状面
Depth: 深度, Z轴,横断面
GetArrayFromImage()可用于将SimpleITK对象转换为ndarray
import SimpleITK as sitk
# 实验用的图片大小为320*250*80,
# 即矢状面(x轴方向)切片数为320,冠状面(y轴方向)切片数为250,
# 横断面(z轴方向)片数为80
# 如上图所示
path = 'E:\COVID-19CTimageAnal\label\00018.dcm'
image = sitk.ReadImage(path)# convert to ndarry
data = sitk.GetArrayFromImage(image)
shape_data = data.shape
print(f'shape of data: {shape_data}')
输出:
shape of data: (80, 250, 320)
原始SimpleITK数据的存储形式为(Width, Height, Depth)即(X,Y,Z),
使用GetArrayFromImage()方法后,X轴与Z轴发生了对调,输出形状为:(Depth, Height, Width)即(Z,Y,X)。