# Surface questions

**URL:** <https://discourse.slicer.org/t/surface-questions/2078>\
**Category:** Development\
**Created:** [February 13, 2018, 1:53pm UTC](https://discourse.slicer.org/t/surface-questions/2078 "2018-02-13T13:53:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [February 13, 2018, 1:53pm UTC](https://discourse.slicer.org/t/surface-questions/2078/1 "2018-02-13T13:53:06Z")

</div>

Dear All  
I have a model (solid) and I would like to do following:

- Generate a surface from the model. I tried Sobel edges, modifying the model properties, somes extensions but the result are not the same as I get with Blender.
- Display the triangulation Mesh as wireframe, where I can only see the edges and vertices.
- Is it possible to produce all the triangles in the same size? if yes, how?

Thanks!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 13, 2018, 2:17pm UTC](https://discourse.slicer.org/t/surface-questions/2078/2 "2018-02-13T14:17:38Z")

</div>

> [@brhoom](#):
>
> I have a model (solid)

Is it a polydata or an unstructured grid mesh?

> [@brhoom](#):
>
> Sobel edges

Sobel operator is for image processing. It is not applicable to meshes.

> [@brhoom](#):
>
> Display the triangulation Mesh, where I can only see the edges and vertices

You can adjust model display options, including wireframe-style display in Models module Display section.

> [@brhoom](#):
>
> Is it possible to produce all the triangles in the same size? if yes, how?

If you generate model from image and disable decimation then size of triangles in your mesh should be very similar.

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [February 13, 2018, 2:34pm UTC](https://discourse.slicer.org/t/surface-questions/2078/3 "2018-02-13T14:34:11Z")

</div>

> Is it a polydata or an unstructured grid mesh?  
> Sobel operator is for image processing. It is not applicable to meshes.

I generated the model from a label-map and saved it as stl file I guess it is polydata). I used Sobel Edges on the label map image (sorry for not explaining).

> You can adjust model display options, including wireframe-style display in Models module Display section.

Thanks for the info. I can display wire-frame now.

> If you generate model from image and disable decimation then size of triangles in your mesh should be very similar.

I used the default options, so i guess zero means disable:  
compute surface normals =1  
decimation factor = 0  
smoothing factor =1

I also tried different number but I keep getting some triangles that are very large comparing to the others.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 13, 2018, 3:15pm UTC](https://discourse.slicer.org/t/surface-questions/2078/4 "2018-02-13T15:15:04Z")

</div>

Yes, decimation = 0 disables decimation. You may also try disabling or decreasing smoothing factor. If you still not get what you need then post a screenshot so that we can have a look.

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [February 13, 2018, 10:09pm UTC](https://discourse.slicer.org/t/surface-questions/2078/5 "2018-02-13T22:09:12Z")

</div>

> [@lassoan](#):
>
> decreasing

Thanks for your concern. I did as you said, here as a sample

 ![Sample](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/7/97170c64986c2d43415f5577d112dcbea9314e34.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 13, 2018, 11:30pm UTC](https://discourse.slicer.org/t/surface-questions/2078/6 "2018-02-13T23:30:33Z")

</div>

This seems to be a very nicely triangulated surface. To make triangles less elongated, you can resample your input volume to have cubic shaped voxels, by checking `Isotropic spacing` checkbox in `Crop volume module` when you crop/resample your original volume to prepare it for segmentation.

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [February 14, 2018, 7:27am UTC](https://discourse.slicer.org/t/surface-questions/2078/7 "2018-02-14T07:27:03Z")

</div>

Thanks for the feedback. I will try the resampling idea.

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [February 15, 2018, 9:02pm UTC](https://discourse.slicer.org/t/surface-questions/2078/8 "2018-02-15T21:02:41Z")

</div>

Resampling was a helpful idea, thanks a lot. . I have two more questions:

- Is it possible to control the number of these equal triangles?
- Is the triangulation applied only on the surface or it produces tetrahedrons as well?

I found out these tools and they are very useful:

- [https://github.com/wjakob/instant-meshes](https://github.com/wjakob/instant-meshes)
- [https://github.com/gaoxifeng/robust\_hex\_dominant\_meshing](https://github.com/gaoxifeng/robust_hex_dominant_meshing)

If you think they are better than the one in slicer, it would be a good idea to integrate this work in slicer. I am planning to integrate them as a slicer extension in the upcoming weeks (if someone is not done this before).  
Best!  
Ibraheem

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 15, 2018, 9:17pm UTC](https://discourse.slicer.org/t/surface-questions/2078/9 "2018-02-15T21:17:26Z")

</div>

> [@brhoom](#):
>
> Is it possible to control the number of these equal triangles?

Triangle size is determined by the input volume’s resolution. You can decrease the number of triangles in flat regions by replacing them by larger ones by using decimation option (you specify the fraction of points that should be removed, so decimation factor of 0.9 means that you remove 90% of the triangles).

> [@brhoom](#):
>
> Is the triangulation applied only on the surface or it produces tetrahedrons as well?

Segmentation generates a surface mesh. To generate volumetric mesh, you can use [SegmentMesher extension](https://github.com/lassoan/SlicerSegmentMesher). SegmentMesher uses Cleaver2 or Tetgen meshers internally, which are well-established algorithms.

instant-meshes and robust\_hex\_dominant\_meshing methods seem to be for remeshing of existing surface mesh to improve mesh quality. I don’t think they are relevant for us, as from images we can always generate high-quality meshes that contains triangles with equal size with a nice aspect ratio.

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [February 15, 2018, 9:46pm UTC](https://discourse.slicer.org/t/surface-questions/2078/10 "2018-02-15T21:46:54Z")

</div>

Thanks for the feedback. I will try your suggestions.
