VtkImageData --> Numpy.array
代码如下:(vtkimage是VtkImageData类型数据)
# 获取图像大小
cols, rows, levels = vtkimage.GetDimensions()
# 获取vtkDataArray类型变量
sc = vtkimage.GetPointData().GetScalars()
# 转为ndarray类型一维向量
imageArr = vtk.util.numpy_support.vtk_to_numpy(sc)
# 转维三维数据
image3D = imageArr.reshape(levels, rows, cols)
# 取第0层,得到二维
image2D = image3D[0,:,:]