# Alternatives to TriangleMeshToBinaryImageFilter

**URL:** https://discourse.itk.org/t/alternatives-to-trianglemeshtobinaryimagefilter/6386
**Category:** Algorithms
**Tags:** itk
**Created:** [January 10, 2024, 2:39pm UTC](https://discourse.itk.org/t/alternatives-to-trianglemeshtobinaryimagefilter/6386 "2024-01-10T14:39:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![CrownMella](https://discourse.itk.org/user_avatar/discourse.itk.org/crownmella/32/3612_2.png) [@CrownMella](https://discourse.itk.org/u/CrownMella)
#### Post date: [January 10, 2024, 2:39pm UTC](https://discourse.itk.org/t/alternatives-to-trianglemeshtobinaryimagefilter/6386/1 "2024-01-10T14:39:51Z")

</div>

Hi all,

As title suggests, are there any other ways to convert a mesh to an image? the current filter causes these barcode artefacts to appear and this ruins the image. I’ve tried using VTK and the barcodes don’t appear but the lack of ‘direction’ makes the image ‘inaccurate’ to what is expected in ITK.

 ![image](https://discourse.itk.org/uploads/default/original/2X/b/b0c5c241f734795ff46047d3bf904575614970fa.jpeg)

---

<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: [January 10, 2024, 3:16pm UTC](https://discourse.itk.org/t/alternatives-to-trianglemeshtobinaryimagefilter/6386/2 "2024-01-10T15:16:23Z")

</div>

Hi @CrownMella ,

One approach is to use the [anti-alias binary image filter](https://examples.itk.org/src/filtering/antialias/smoothbinaryimagebeforesurfaceextraction/documentation) followed by surface extraction with the [cuberille filter](https://github.com/InsightSoftwareConsortium/ITKCuberille).

---

<div class="post-metadata">

### Author: ![CrownMella](https://discourse.itk.org/user_avatar/discourse.itk.org/crownmella/32/3612_2.png) [@CrownMella](https://discourse.itk.org/u/CrownMella)
#### Post date: [January 10, 2024, 3:43pm UTC](https://discourse.itk.org/t/alternatives-to-trianglemeshtobinaryimagefilter/6386/3 "2024-01-10T15:43:17Z")

</div>

Hi Matt,

thanks for your reply, I was hoping for the other way around? I have the stl/mesh, i want it to be a binary image. My current pipeline involves using vtk moving to itk then resampling + filter but I’m concerned of all the jumping that might affect the final image. Currently, it looks fine to me but maybe there’s a purely ITK way?

---

<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: [January 11, 2024, 5:31pm UTC](https://discourse.itk.org/t/alternatives-to-trianglemeshtobinaryimagefilter/6386/4 "2024-01-11T17:31:41Z")

</div>

Oh – another idea, then, is `SpatialObjectToImageFilter` with a `MeshSpatialObject`. Here is an example:

> <https://github.com/InsightSoftwareConsortium/ITK/blob/master/Examples/SpatialObjects/MeshSpatialObject.cxx>
