C# VTK Dicom数据——三维体素网格模型

该代码片段展示了如何使用VTK库读取并处理Dicom数据,通过设置阈值和几何过滤器,将体素数据转换成三维网格模型,最终返回一个vtkPolyData对象。
摘要由CSDN通过智能技术生成

读入Dicom 数据,然后将Dicom体素网格化,生成体素网格模型,一个体素就是一个立方体。

 public vtkPolyData GenrateImageGridModel(vtkImageData imageData)
 {
     int[] extent = imageData.GetExtent();

     vtkImageWrapPad pad = new vtkImageWrapPad();
     pad.SetInputData(imageData);
     pad.SetOutputWholeExtent(extent[0], extent[1] + 1, extent[2], extent[3] + 1, extent[4], extent[5] + 1);
     pad.Update();
     pad.GetOutput().GetCellData().SetScalars(imageData.GetPointData().GetScalars());

     vtkThreshold threshold = new vtkThreshold();
     threshold.SetInputArrayToProcess(0, 0, 0, (int)vtkDataObject.FieldAssociations.FIELD_ASSOCIATION_CELLS, (int)vtkDataSetAttributes.AttributeTypes.SCALARS);
     threshold.SetInputConnection(pad.GetOutputPort());
     threshold.SetLowerThreshold(0);
     threshold.SetUpperThreshold(255);
     threshold.Update();

     vtkGeometryFilter geometryFilter = new vtkGeometryFilter();
     geometryFilter.SetInputData(threshold.GetOutput());
     geometryFilter.Update();

     vtkPolyData polydata = new vtkPolyData();
     polydata.DeepCopy(geometryFilter.GetOutput());

     return polydata;
 }

  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值