我想将nifti文件转换为.vtk,我使用了此python代码
import itk
import vtk
input_filename = ‘/home/nour/Bureau/244seg_pve_2.nii.gz’
PixelType = itk.ctype(‘float’)
Dimension = 3
ImageType = itk.Image[PixelType, Dimension]
reader = itk.ImageFileReader[ImageType].New()
reader.SetFileName(input_filename)
reader.Update()
thresholdFilter = itk.ThresholdImageFilter[ImageType].New()
thresholdFilter.SetInput(reader.GetOutput())
thresholdFilter.ThresholdBelow(0)
thresholdFilter.SetOutsideValue(0)
thresholdFilter.Update()
itkToVtkFilter = itk.ImageToVTKImageFilter[ImageType].New()
itkToVtkFilter.SetInput(thresholdFilter.GetOutput())
myvtkImageData = itkToVtkFilter.GetOutput()
itkToVtkFilter.Update()
contour=vtk.vtkMarchingCubes()
contour.SetInputData(itkToVtkFilter.GetOutput())
contour.ComputeNormalsOn()
#contour.Update()
当我使用itkToVtkFilter.Update()运行它时:分割错误(核心已转储) 但是当我在没有itkToVtkFilter.Update()的情况下运行它时:vtkMarchingCubes(0x4d03f80):必须定义轮廓标量