# Fit splines to center of irregular 3d tube

**URL:** https://discourse.vtk.org/t/fit-splines-to-center-of-irregular-3d-tube/9972
**Category:** Support
**Created:** [November 28, 2022, 6:49am UTC](https://discourse.vtk.org/t/fit-splines-to-center-of-irregular-3d-tube/9972 "2022-11-28T06:49:50Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![s195t](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@s195t](https://discourse.vtk.org/u/s195t)
#### Post date: [November 28, 2022, 6:49am UTC](https://discourse.vtk.org/t/fit-splines-to-center-of-irregular-3d-tube/9972/1 "2022-11-28T06:49:50Z")

</div>

Dear everyone,

I have a dataset with multiple structures which are shaped like irregular 3d tubes, I was wondering if it is possible to fit a spline through the approximate center of such structures (I have both isosurfaces and volume data) … Here is an example:

 ![](https://discourse.vtk.org/uploads/default/original/2X/8/82be7a3f9d43164f04f8c6f25dbcb7df75bb33b0.gif)  
Like transforming the isosurfaces to solids and then calculate the centerline based on an the middle point for each coordinate

Is there any way to do so or any example that can be reutilized?

Thanks in advance

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 4, 2022, 3:06pm UTC](https://discourse.vtk.org/t/fit-splines-to-center-of-irregular-3d-tube/9972/2 "2022-12-04T15:06:11Z")

</div>

Hi,

The operation you need is called skeletonization. I don’t believe VTK has a mesh skeletonizer or even a raster skeletonizer. Still, you can do it with its sister library, ITK, and you have, as you already guessed, to raster your mesh into a 3D volume: [https://vtk.org/pipermail/vtkusers/2018-January/100722.html](https://vtk.org/pipermail/vtkusers/2018-January/100722.html) .

Alternatively, you can try CGAL for direct-from-mesh skeletonization: [https://doc.cgal.org/latest/Surface\_mesh\_skeletonization/index.html](https://doc.cgal.org/latest/Surface_mesh_skeletonization/index.html) .

take care,

Paulo
