我可以使用带有以下代码的 vtkNIFTIImageReader 显示切片图像:https ://github.com/dgobbi/vtk-dicom/blob/master/Examples/TestNIFTIDisplay.cxx
但是,当我尝试将 NIFTI 文件渲染为 3D 对象时,它总是出现空。如何在 VTK 中显示 NIFTI 对象
vtkSmartPointer<vtkNIFTIImageReader> reader =
vtkSmartPointer<vtkNIFTIImageReader>::New();
reader->SetFileName (filename);
reader->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(reader->GetOutputPort());
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
renderer->AddActor(actor);
renderWindow->Render();
renderWindowInteractor->Start();