# Calculating distance using Maurer distance map

**URL:** <https://discourse.slicer.org/t/calculating-distance-using-maurer-distance-map/1848>\
**Category:** Support\
**Created:** [January 15, 2018, 6:43pm UTC](https://discourse.slicer.org/t/calculating-distance-using-maurer-distance-map/1848 "2018-01-15T18:43:46Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [January 16, 2018, 6:30pm UTC](https://discourse.slicer.org/t/calculating-distance-using-maurer-distance-map/1848/14 "2018-01-16T18:30:40Z")

</div>

Here you go:

```
import vtkSlicerSegmentComparisonModuleLogicPython
polHist = vtkSlicerSegmentComparisonModuleLogicPython.vtkPolyDataDistanceHistogramFilter()
segNode = slicer.util.getNode('vtkMRMLSegmentationNode1')
poly1 = segNode.GetSegmentation().GetSegment('Segment_1').GetRepresentation(slicer.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())
poly2 = segNode.GetSegmentation().GetSegment('Segment_2').GetRepresentation(slicer.vtkSegmentationConverter.GetSegmentationClosedSurfaceRepresentationName())
polHist.SetInputReferencePolyData(poly1)
polHist.SetInputComparePolyData(poly2)
polHist.Update()
histTable = polHist.GetOutputHistogram()
tableNode = slicer.vtkMRMLTableNode()
tableNode.SetAndObserveTable(histTable)
slicer.mrmlScene.AddNode(tableNode)

```

Then you can save the table to csv with Save data dialog, or oyu can make a plot with it from Tables module.

Oh, and you need to install the SlicerRT extension first to have the Segment Comparison module if you haven’t.

---

_[View the full topic](https://discourse.slicer.org/t/calculating-distance-using-maurer-distance-map/1848)._
