python---之sitk中的Getspacing,origin,direction


itk_img = sitk.ReadImage(img_file) 
img_array = sitk.GetArrayFromImage(itk_img) # indexes are z,y,x (notice the ordering)
center = np.array([node_x,node_y,node_z])   # nodule center
origin = np.array(itk_img.GetOrigin())      # x,y,z  Origin in world coordinates (mm)
spacing = np.array(itk_img.GetSpacing())    # spacing of voxels in world coor. (mm)
v_center =np.rint((center-origin)/spacing)  # nodule center in voxel space (still x,y,z ordering)

其中 origin是,原始图像中心点在相机坐标系的位置

spacing是两个像素之间的间隔

direction是方向:这个没太搞懂

 

python---之sitk中的Getspacing,origin,direction_第1张图片

左边图是世界坐标(不懂自行百度),右边是图像坐标,

 

 

你可能感兴趣的:(python学习笔记)