vtk imagedata拆分和重新切片

问题描述

我正在使用VTK制作医疗应用。 我有一系列DICOM图像,**需要从已有的法线和原点分开两个平面,然后在剪切后渲染此图像数据,并重新切割3维图像。

到目前为止,我使用volume-> addClippingPlane。减少体积 但不知道切后要切片。

该怎么做?

int main(int argc,char *argv[])
{
  auto reader = vtkSmartPointer<vtkDICOMImageReader>::New();
  reader->SetDirectoryName("DIR");
  reader->Update();
  int imageDims[3];
  reader->GetOutput()->GetDimensions(imageDims); //need include <vtkimagedata.h>
  cout << "dimension[] :" << imageDims[0] << " " << imageDims[1] << " " << imageDims[2] << endl;

  auto voloumeMapper = vtkSmartPointer<vtkSmartVolumeMapper>::New();
  voloumeMapper->SetInputData(reader->GetOutput());
  voloumeMapper->SetSampleDistance(voloumeMapper->GetSampleDistance() * 3);
  
  auto clipLowerPlane = vtkSmartPointer<vtkPlane>::New();
  clipLowerPlane->SetNormal(normal[0],normal[1],normal[2]);
  clipLowerPlane->SetOrigin(origin[0],origin[1],origin[2]);
  auto clipUpperPlane = vtkSmartPointer<vtkPlane>::New();
  clipUpperPlane->SetNormal(normal1[0],normal1[1],normal1[2]);
  clipUpperPlane->SetOrigin(origin1[0],origin1[1],origin1[2]);


  voloumeMapper->AddClippingPlane(clipLowerPlane);
  voloumeMapper->AddClippingPlane(clipUpperPlane);
  voloumeMapper->Update();
  vtkSmartPointer<vtkVolumeProperty> volumeProperty = 
  vtkSmartPointer<vtkVolumeProperty>::New();
  volumeProperty->ShadeOn();
  volumeProperty->SetAmbient(0.4);
  volumeProperty->SetDiffuse(0.6);
  volumeProperty->SetSpecular(0.2);

  vtkSmartPointer<vtkPiecewiseFunction> compositeOpacity = 
  vtkSmartPointer<vtkPiecewiseFunction>::New();
  //Defines a piecewise function mapping.
  compositeOpacity->AddPoint(150,0.00);
  compositeOpacity->AddPoint(200,0.80);
  compositeOpacity->AddPoint(250,1);

  volumeProperty->SetScalarOpacity(compositeOpacity);


  vtkSmartPointer<vtkPiecewiseFunction> volumeGradientOpacity =
      vtkSmartPointer<vtkPiecewiseFunction>::New();
  volumeGradientOpacity->AddPoint(10,0.0);
  volumeGradientOpacity->AddPoint(90,0.5);
  volumeGradientOpacity->AddPoint(100,1.0);
  volumeProperty->SetGradientOpacity(volumeGradientOpacity); 

  vtkSmartPointer<vtkColorTransferFunction> color =
      vtkSmartPointer<vtkColorTransferFunction>::New();
  color->AddRGBPoint(220.000,1.00,1.00);
  color->AddRGBPoint(190.00,0.80,0.8,0.80);
  color->AddRGBPoint(64.0,0.50,0.50);
  color->AddRGBPoint(0.0,0.20,0.20);
  volumeProperty->SetColor(color);
  auto volumeActor = vtkSmartPointer<vtkVolume>::New();
  volumeActor->SetMapper(voloumeMapper);
  volumeActor->SetProperty(volumeProperty);
  vtkSmartPointer<vtkRenderWindow> renWin = 
  vtkSmartPointer<vtkRenderWindow>::New();
  renWin->SetSize(800,800);
  vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
  renderer->SetBackground(0,0);
  vtkSmartPointer<vtkRenderWindowInteractor> interactor = 
  vtkSmartPointer<vtkRenderWindowInteractor>::New();
  renWin->AddRenderer(renderer);
  interactor->SetRenderWindow(renWin);
  renderer->AddVolume(volumeActor);
  renderer->ResetCamera();
  interactor->Initialize();
  interactor->Start();
  return EXIT_SUCCESS;
  ;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...