# Unable to show the result from filter - SimpleITK

**URL:** https://discourse.slicer.org/t/unable-to-show-the-result-from-filter-simpleitk/10601
**Category:** Support
**Created:** [March 9, 2020, 3:59pm UTC](https://discourse.slicer.org/t/unable-to-show-the-result-from-filter-simpleitk/10601 "2020-03-09T15:59:26Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![siaeleni](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@siaeleni](https://discourse.slicer.org/u/siaeleni)
#### Post date: [March 9, 2020, 3:59pm UTC](https://discourse.slicer.org/t/unable-to-show-the-result-from-filter-simpleitk/10601/1 "2020-03-09T15:59:26Z")

</div>

Hello,  
What I am trying to achieve is to apply BinaryMorphologicalOpeningImageFilter to a vtkMRMLModelNode.

These are the steps that I follow:

1. Add the stl model as Segmentation into Slicer
2. Convert Segmentation into vtkMRMLLabelMapVolumeNode and then into vtkMRMLScalarVolumeNode
3. Apply the filter to the Volume

> import SimpleITK as sitk  
> import sitkUtils as su
> 
> seg = 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

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [March 9, 2020, 6:51pm UTC](https://discourse.slicer.org/t/unable-to-show-the-result-from-filter-simpleitk/10601/2 "2020-03-09T18:51:55Z")

</div>

Hi @siaeleni -

It looks like you missing the conversion of the slicer volume to a simpleitk image - this code should help:

[https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Running\_an\_ITK\_filter\_in\_Python\_using\_SimpleITK](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Running_an_ITK_filter_in_Python_using_SimpleITK)

```auto
# Run processing
inputImage = sitkUtils.PullVolumeFromSlicer(inputVolumeNode)
filter = sitk.SignedMaurerDistanceMapImageFilter()
outputImage = filter.Execute(inputImage)
sitkUtils.PushVolumeToSlicer(outputImage, outputVolumeNode)

```
