我正在尝试读取一系列 DICOM 文件并将其渲染为 3D 模型。我已经做到了这一点。但是,我也希望能够在渲染之前删除某些切片。这就是我迷路的地方。我无法找到一种方法来访问每个加载的文件并删除我想要的文件。我读过我可以将数据集转换为 numpy 数组。但是,我不确定如何做到这一点。
reader = vtkDICOMImageReader()
reader.SetDirectoryName('loads a directory of DICOM files')
reader.Update()
imageDataGeometryFilter = vtkImageDataGeometryFilter()
imageDataGeometryFilter.SetInputConnection(reader.GetOutputPort())
imageDataGeometryFilter.Update()
mapper = vtkPolyDataMapper()
mapper.SetInputConnection(imageDataGeometryFilter.GetOutputPort())
'''Here is where I want to take my vtkDataSet and convert it into a numpy array.
Once in array form I can remove data that I do not want (ie DICOM slices).
Then I want to convert it back into a vtkDataSet to continue program.
'''
actor = vtkActor()
actor.SetMapper(mapper)
ren = vtkRenderer()
ren.AddActor(actor)
ren.SetBackground(0.1,0.3,0.1)
renWin = vtkRenderWindow()
renWin.AddRenderer(ren)
interactor = vtkRenderWindowInteractor()
interactor.SetRenderWindow(renWin)
renWin.Start()
interactor.Initialize()
interactor.Start()