我尝试用Python和Python-VTK处理MHD图像文件。该文件位于Google Drive中:MHD。
我想将其转换为numpy数组,然后根据给定值(例如“500”)将它们分割。然后计算摘要信息。我按照这篇文章的说明操作:
如何将3D vtkDataSet转换为numpy数组?
但是对于我的情况不起作用。
import vtk
imageReader = vtk.vtkMetaImageReader()
imageReader.SetFileName(testfile1)
imageReader.Update()
# from vtk.util.numpy_support import numpy_to_vtk, vtk_to_numpy does not work for the data type issue
image = imageReader.GetOutput()
# List the dimensions of the image, for example
print image.GetDimensions()
pixelspace = imageReader.GetPixelSpacing()
这里出现了一个错误:
AttributeError: GetPixelSpacing
我该如何实现转换?
当我完成数据分割后,我该如何将它们保存回mhd文件(或者原始数据更好?)
mhd
文件,它对我也起作用了... - Saullo G. P. Castro