# Non-zero 3D image surface

**URL:** https://discourse.vtk.org/t/non-zero-3d-image-surface/7715
**Category:** Support
**Created:** [January 25, 2022, 7:01pm UTC](https://discourse.vtk.org/t/non-zero-3d-image-surface/7715 "2022-01-25T19:01:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![osemmler](https://discourse.vtk.org/user_avatar/discourse.vtk.org/osemmler/32/4599_2.png) [@osemmler](https://discourse.vtk.org/u/osemmler)
#### Post date: [January 25, 2022, 7:01pm UTC](https://discourse.vtk.org/t/non-zero-3d-image-surface/7715/1 "2022-01-25T19:01:22Z")

</div>

Hello,  
I’d like to ask your advice.

**INPUT**

- 3D image.
  - -1 = background
  - 0…X = object

**OUTPUT**

- triangular surface
  - containing values equal to the value of the edge voxels of the object

Can you please advise me what combination of filters I should choose?  
Thank you in advance for any advice…

---

<div class="post-metadata">

### Author: ![Christos\_Tsolakis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/christos_tsolakis/32/2076_2.png) [@Christos\_Tsolakis](https://discourse.vtk.org/u/Christos_Tsolakis)
#### Post date: [January 25, 2022, 8:09pm UTC](https://discourse.vtk.org/t/non-zero-3d-image-surface/7715/2 "2022-01-25T20:09:06Z")

</div>

> - triangular surface

Check [vtkMarchingCubes](https://vtk.org/doc/nightly/html/classvtkMarchingCubes.html) & [vtkFlyingEdges3D](https://vtk.org/doc/nightly/html/classvtkFlyingEdges3D.html)  
and the examples therein.

> containing values equal to the value of the edge voxels of the object

not sure what you mean here. But both filters should produce scalar values for each point based on the isosurface they belong to.

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [January 26, 2022, 4:52pm UTC](https://discourse.vtk.org/t/non-zero-3d-image-surface/7715/3 "2022-01-26T16:52:10Z")

</div>

It’s possible that [vtkDiscreteMarchingCubes](https://vtk.org/doc/nightly/html/classvtkDiscreteMarchingCubes.html) will give you the desired result, and I think that’s the best place to start. However, it will create inner surfaces between each value in addition to the outer surface. It assumes the values are categorical (e.g. label values) rather than continuous.

A very general (but not very efficient) solution is to apply vtkThreshold to remove all cells with a negative value, followed by vtkGeometryFilter to get the outer surface.

---

<div class="post-metadata">

### Author: ![osemmler](https://discourse.vtk.org/user_avatar/discourse.vtk.org/osemmler/32/4599_2.png) [@osemmler](https://discourse.vtk.org/u/osemmler)
#### Post date: [January 27, 2022, 7:25pm UTC](https://discourse.vtk.org/t/non-zero-3d-image-surface/7715/4 "2022-01-27T19:25:06Z")

</div>

Thank you for your answers. I’ll try your suggested solutions 👍
