Hello,
What I am trying to achieve is to apply BinaryMorphologicalOpeningImageFilter to a vtkMRMLModelNode.
These are the steps that I follow:
- Add the stl model as Segmentation into Slicer
- Convert Segmentation into vtkMRMLLabelMapVolumeNode and then into vtkMRMLScalarVolumeNode
- Apply the filter to the Volume
import SimpleITK as sitk
import sitkUtils as suseg = slicer.util.getNode(‘segm’)
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass(‘vtkMRMLLabelMapVolumeNode’,‘LabelMap’)
outputvolumenode = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLScalarVolumeNode”, ‘OutputVolume’)
slicer.modules.segmentations.logic().ExportAllSegmentsToLabelmapNode(seg, labelmapVolumeNode)
sef = slicer.modules.volumes.logic().CreateScalarVolumeFromVolume(slicer.mrmlScene,outputvolumenode, labelmapVolumeNode)filter = sitk.BinaryMorphologicalOpeningImageFilter()
filter.SetKernelRadius((1,1,1))
su.PullVolumeFromSlicer(outputvolumenode)
result = filter.Execute(im)
But I am not sure how should I display the result into a vtkMRMLModelNode to Slicer and verify that the filter is working.
Thanks