# Segmentation to text file

**URL:** <https://discourse.itk.org/t/segmentation-to-text-file/5377>\
**Category:** Algorithms\
**Created:** [September 29, 2022, 6:25pm UTC](https://discourse.itk.org/t/segmentation-to-text-file/5377 "2022-09-29T18:25:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_Hatton](https://discourse.itk.org/user_avatar/discourse.itk.org/sean_hatton/32/2957_2.png) [@Sean\_Hatton](https://discourse.itk.org/u/Sean_Hatton)\
**Post date:** [September 29, 2022, 6:25pm UTC](https://discourse.itk.org/t/segmentation-to-text-file/5377/1 "2022-09-29T18:25:01Z")

</div>

Hi all,

I would like to export my segmentations to a text file (i.e. list of contour pixels) to create IMOD model files (with point2model). Two questions:

1. I expect I would push the segmentation through the LabelContourImageFilter to get the edges, but is there an sitk.Cast to text? Would this use ImageFileWriter or just a txt dump?
2. Would this text dump encode the origin and dimensions of the segmentation cf. reference image?

Cheers,

Sean Hatton  
UCSD

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [September 29, 2022, 7:02pm UTC](https://discourse.itk.org/t/segmentation-to-text-file/5377/2 "2022-09-29T19:02:42Z")

</div>

`LabelContourImageFilter` does not produce a mesh, but another image. There is no standard way to convert that into text.

[Marching cubes](https://itk.org/Doxygen/html/classitk_1_1BinaryMask3DMeshSource.html), and newer and higher quality [Cuberille](https://github.com/InsightSoftwareConsortium/ITKCuberille) produce a mesh. Meshes are usually in physical space, so they don’t carry image grid information.
