vtk连点成面, 并求该截面的面积
缘起
试图通过求椎管最大横径确定穿刺轴线,由于椎管的截面的变异等原因导致截取的椎管不规则所以失败了…(见vtk的截面多边形裁切和质心的探索实验之三:求当前截面椎管的质心)
开始尝试直接求椎弓根截面面积…
探索过程
1. 连点成面
def CreatePolygon(self, points):
"Create a 3D plane from Nx3 numpy array"
self.verts = vtk.vtkPoints()
polygon = vtk.vtkPolygon()
polygon_pid = polygon.GetPointIds()
for i, p in enumerate(points):
self.verts.InsertNextPoint(*tuple(p))
polygon_pid.InsertNextId(i)
polygon_cell = vtk.vtkCellArray()
polygon_cell.InsertNextCell(polygon)
self.pd = vtk.vtkPolyData()
self.pd.SetPoints(self.verts)
self.pd.SetPolys(polygon_cell)
self.mapper = vtk.vtkPolyDataMapper()
self.mapper.SetInputData(self.pd)
self.actor = vtk.vtkActor()
self.actor.SetMapper(self.mapper)
From: det3d
求截面积
一下这个代码是常用的方法:
crossSectionProperties = vtk.vtkMassProperties()
crossSectionProperties.SetInputData(crossSectionPolyData)
currentSurfaceArea = crossSectionProperties.GetSurfaceArea()
可是得到的结果似乎不对:
如上图:17*7=119
❓?为啥呢???♀️??♀️??♀️
回归Slicer
PerkLab/SlicerSandbox/blob/90320348677225ae86bb54d0dea563af55c5bcae/SegmentCrossSectionArea/SegmentCrossSectionArea.py#L494-L496 2
logic = SegmentCrossSectionAreaLogic()
logic.run(segmentationNode, masterVolumeNode, "slice", tableNode, plotChartNode)
logic.showChart(plotChartNode)
If you run the code from a different file then of course you need to import the module or the classes that you use from them. For example, you can import the logic class by calling:
from SegmentCrossSectionArea import SegmentCrossSectionAreaLogic
logic = SegmentCrossSectionAreaLogic(),
Clipped from Compute surface area in segment based on Hounsfield units (CT-images) - Support - 3D Slicer Community at 2022-08-03.
<未完待续>
本文含有隐藏内容,请 开通VIP 后查看