使用vtk绘制体

vtkPCANormalEstimation
vtkPCANormalEstimation使用PCA(principal component analysis)生成点法线。
基本上,这是通过考虑围绕p的点的较小邻域并将平面拟合到邻域(通过PCA)来估计每个采样点p周围的局部切平面.
有三种解决法线一致性的方法:1)使法线保持计算状态; 2)调整法线的+/-符号,以使法线都指向指定点; 3)遍历点云;以及 翻转相邻法线,使它们相互一致。
vtkSignedDistance
vtkSignedDistance是一个过滤器,用于计算从输入点云到整个卷的有符号距离

读取dcm文件(不可压缩)
    vtkSmartPointer<vtkDICOMImageReader> reader =
      vtkSmartPointer<vtkDICOMImageReader>::New();
    reader->SetDirectoryName("E:/workspace/DICOM/133ceng");
    reader->Update();
读取mhd文件
    vtkSmartPointer<vtkMetaImageReader> metaread =
        vtkSmartPointer<vtkMetaImageReader>::New();
    metaread->SetFileName("./volume/25723.mhd");
    metaread->Update();
Marchingcubes面提取
    vtkSmartPointer<vtkMarchingCubes> march =
        vtkSmartPointer<vtkMarchingCubes>::New();
    march->SetInputData(metaread->GetOutput());
    march->SetValue(0,0.5);
    march->Update();
绘制体

    vtkSmartPointer<vtkDICOMImageReader> reader =
      vtkSmartPointer<vtkDICOMImageReader>::New();
    reader->SetDirectoryName("E:/workspace/DICOM/133ceng");
    reader->Update();

    vtkSmartPointer<vtkOpenGLGPUVolumeRayCastMapper> volumeMapper =
      vtkSmartPointer<vtkOpenGLGPUVolumeRayCastMapper>::New();
    volumeMapper->SetInputConnection(reader->GetOutputPort());

  // Create transfer mapping scalar value to opacity
    vtkSmartPointer<vtkPiecewiseFunction> opacityTransferFunction =
      vtkSmartPointer<vtkPiecewiseFunction>::New();
  // Create transfer mapping scalar value to color
    vtkSmartPointer<vtkColorTransferFunction> colorTransferFunction =
      vtkSmartPointer<vtkColorTransferFunction>::New();
    colorTransferFunction->AddRGBPoint( -3024, 0, 0, 0, 0.5, 0.0 );
    colorTransferFunction->AddRGBPoint( -16, 0.73, 0.25, 0.30, 0.49, .61 );
    colorTransferFunction->AddRGBPoint( 641, .90, .82, .56, .5, 0.0 );
    colorTransferFunction->AddRGBPoint( 3071, 1, 1, 1, .5, 0.0 );
    opacityTransferFunction->AddPoint(-3024, 0, 0.5, 0.0 );
    opacityTransferFunction->AddPoint(-16, 0, .49, .61 );
    opacityTransferFunction->AddPoint(641, .72, .5, 0.0 );
    opacityTransferFunction->AddPoint(3071, .71, 0.5, 0.0);
  // The property describes how the data will look
    vtkSmartPointer<vtkVolumeProperty> volumeProperty =
      vtkSmartPointer<vtkVolumeProperty>::New();
    volumeProperty->SetColor(colorTransferFunction);
    volumeProperty->SetScalarOpacity(opacityTransferFunction);
    volumeProperty->ShadeOn();
    volumeProperty->SetInterpolationTypeToLinear();


  // The volume holds the mapper and the property and
  // can be used to position/orient the volume
    vtkSmartPointer<vtkVolume> volume =
      vtkSmartPointer<vtkVolume>::New();
    volume->SetMapper(volumeMapper);
    volume->SetProperty(volumeProperty);

    vtkSmartPointer<vtkRenderer> ren1 =
      vtkSmartPointer<vtkRenderer>::New();
    ren1->AddVolume(volume);
    ren1->ResetCamera();
    vtkSmartPointer<vtkRenderWindow> renderWindow =
      vtkSmartPointer<vtkRenderWindow>::New();
    renderWindow->AddRenderer(ren1);
    vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
      vtkSmartPointer<vtkRenderWindowInteractor>::New();
    renderWindowInteractor->SetRenderWindow(renderWindow);
    vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
      vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
    renderWindowInteractor->SetInteractorStyle(style);
    renderWindow->Render();
    renderWindowInteractor->Start();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

努力减肥的小胖子5

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值