# Export segmentation contour from cine-mri images (one single time frame)

**URL:** <https://discourse.slicer.org/t/export-segmentation-contour-from-cine-mri-images-one-single-time-frame/22411>\
**Category:** Support\
**Tags:** segmentation, python\
**Created:** [March 9, 2022, 2:50pm UTC](https://discourse.slicer.org/t/export-segmentation-contour-from-cine-mri-images-one-single-time-frame/22411 "2022-03-09T14:50:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MSensale](https://avatars.discourse-cdn.com/v4/letter/m/db5fbb/32.png) [@MSensale](https://discourse.slicer.org/u/MSensale)\
**Post date:** [March 9, 2022, 2:50pm UTC](https://discourse.slicer.org/t/export-segmentation-contour-from-cine-mri-images-one-single-time-frame/22411/1 "2022-03-09T14:50:30Z")

</div>

Hi 3D Slicer Community !

My name is Marco and I am a PhD student passionated about medical images based modelling.

I would like to ask support about exporting the segmentation contour of a mask.

I am working with cine-mri images of the human aorta. With this kind of imaging technique, you can get the in-plane motion of the aorta over the time. In this case, the time resolution is about 25 frames for cardiac cycle. My aim is to estimate the motion of the aorta from cine-mri images.

I segmented manually each frame (therefore one single slice for each frame). An example of segmentation for one frame is reported below:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/e/1e52e9d3345919ba670dcfb0ea645e7516f273cb.jpeg)

If I untick the Slice Fill option, I get the contour of the segmetation as shown in the image below:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/3/0335846632f161a5966820f3e44cd29c46e08365.jpeg)

In that image, the contour of the segmentation is represented by a broken line. The broken line is made up by joining several points. These points are corners of pixels in the slice and are associated with some x, y and z coordinates.

I am looking for a method to store those coordinates.

I have seen similar topics at:  
[Extract contours only from a segmentation - Support - 3D Slicer Community](https://discourse.slicer.org/t/extract-contours-only-from-a-segmentation/1853)

And found that the vtkImageLabelOutline should be the right filter for this task. However it does not seem to be available in Python API.

It would be great if someone would like to share his/her ideas.

Thanks,

Marco

---

<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 10, 2022, 12:11am UTC](https://discourse.slicer.org/t/export-segmentation-contour-from-cine-mri-images-one-single-time-frame/22411/2 "2022-03-10T00:11:37Z")

</div>

I guess this is a sequence of 2D frames? If so you might try this class:

[https://vtk.org/doc/nightly/html/classvtkFlyingEdges2D.html#details](https://vtk.org/doc/nightly/html/classvtkFlyingEdges2D.html#details)

Otherwise if it’s 3D you could just export to a surface model and get the vertices.

---

<div class="post-metadata">

**Author:** ![MSensale](https://avatars.discourse-cdn.com/v4/letter/m/db5fbb/32.png) [@MSensale](https://discourse.slicer.org/u/MSensale)\
**Post date:** [March 10, 2022, 4:53pm UTC](https://discourse.slicer.org/t/export-segmentation-contour-from-cine-mri-images-one-single-time-frame/22411/3 "2022-03-10T16:53:36Z")

</div>

Hi Steve,

Many thanks for your answer.

Indeed, it is a sequence of 2D frames and the class you suggested seems to do exactly what I am looking for. I will try it and let you know.

Thanks

Marco

---

<div class="post-metadata">

**Author:** ![MSensale](https://avatars.discourse-cdn.com/v4/letter/m/db5fbb/32.png) [@MSensale](https://discourse.slicer.org/u/MSensale)\
**Post date:** [March 14, 2022, 2:22pm UTC](https://discourse.slicer.org/t/export-segmentation-contour-from-cine-mri-images-one-single-time-frame/22411/4 "2022-03-14T14:22:40Z")

</div>

Hi Steve,  
Thanks again for your suggestion.  
In the description of the vtkFlyingEdges2D filter it is written: “If you are interested in extracting segmented regions from a label mask, consider using [vtkDiscreteFlyingEdges2D](https://vtk.org/doc/nightly/html/classvtkDiscreteFlyingEdges2D.html).”

I implemented this filter in my code and it does perfectly what I asked in the post.

Thanks,

Marco
