# TriangleMeshToBinaryImageFilter In Python

**URL:** <https://discourse.itk.org/t/trianglemeshtobinaryimagefilter-in-python/1604>\
**Category:** Beginner Questions\
**Tags:** itkv5, python\
**Created:** [February 15, 2019, 9:01pm UTC](https://discourse.itk.org/t/trianglemeshtobinaryimagefilter-in-python/1604 "2019-02-15T21:01:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [February 17, 2019, 1:33pm UTC](https://discourse.itk.org/t/trianglemeshtobinaryimagefilter-in-python/1604/2 "2019-02-17T13:33:59Z")

</div>

Hi Roger,

This patch adds Python wrapping for `TriangleMeshToBinaryImageFilter`:

[https://github.com/InsightSoftwareConsortium/ITK/pull/516](https://github.com/InsightSoftwareConsortium/ITK/pull/516)

Since you are interested in STL files, it is worth noting that Python packages for [ITKIOMeshSTL](https://github.com/InsightSoftwareConsortium/ITKIOMeshSTL) were recently released. Install with:

```auto
python -m pip install itk-iomeshstl

```

Then, read a mesh file, e.g.:

```auto
import itk
MeshType = itk.Mesh[itk.F, 3]
reader = itk.MeshFileReader[MeshType].New()
meshIO = itk.STLMeshIO.New()
reader.SetMeshIO(meshIO)
reader.SetFileName("/path/to/mymesh.stl")
reader.Update()
mesh = reader.GetOutput()

```

---

_[View the full topic](https://discourse.itk.org/t/trianglemeshtobinaryimagefilter-in-python/1604)._
