# Non-rigid mesh registration of lung contour meshes

**URL:** https://discourse.vtk.org/t/non-rigid-mesh-registration-of-lung-contour-meshes/9472
**Category:** Support
**Created:** [September 27, 2022, 4:20pm UTC](https://discourse.vtk.org/t/non-rigid-mesh-registration-of-lung-contour-meshes/9472 "2022-09-27T16:20:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![qod\_rec](https://discourse.vtk.org/user_avatar/discourse.vtk.org/qod_rec/32/5845_2.png) [@qod\_rec](https://discourse.vtk.org/u/qod_rec)
#### Post date: [September 27, 2022, 4:20pm UTC](https://discourse.vtk.org/t/non-rigid-mesh-registration-of-lung-contour-meshes/9472/1 "2022-09-27T16:20:37Z")

</div>

Hello!  
I have some chest CTs with lung contours labeled. I have generated the contour meshes in 3D slicer and these meshes are in STL format.  
I use a mesh simplification algorithm in meshlab to simplify one mesh from these meshes and want this simplified mesh to be a template.  
The template mesh has 1000 vertices and generated contour meshes have around 170000 - 200000 vertices.  
I want to non-rigid register the template mesh to these meshes with a large number of vertices.  
Can VTK do this job in python?

---

<div class="post-metadata">

### Author: ![marcomusy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcomusy/32/95_2.png) [@marcomusy](https://discourse.vtk.org/u/marcomusy)
#### Post date: [September 27, 2022, 4:50pm UTC](https://discourse.vtk.org/t/non-rigid-mesh-registration-of-lung-contour-meshes/9472/2 "2022-09-27T16:50:39Z")

</div>

You can do it with `vtkThinPlateSplineTransform`, check out:

[https://discourse.vtk.org/t/very-long-time-to-deform-fe-mesh-with-thin-plate-spline-transformation/](https://discourse.vtk.org/t/very-long-time-to-deform-fe-mesh-with-thin-plate-spline-transformation/)

```python
from vedo import *
msh = Mesh('liver.stl')
source = msh.clone().subsample(0.1)
target = source.clone().scale([1.4,0.7,1.4]).shift(0.2,0.1,0.3)
arrows = Arrows(source, target, s=0.3, c='k')
warped = msh.clone().warp(source, target).alpha(0.2)
show(msh, arrows, warped, axes=7)
#print(type(warped.transform))

```

[liver.stl](https://discourse.vtk.org/uploads/short-url/kL6tjKhNrLSWhhVCwLELa1hqXcl.stl) (550.9 KB)

 ![Screenshot from 2022-09-27 18-41-19](https://discourse.vtk.org/uploads/default/original/2X/3/39286a3d7aefbe2540b913e738fa8126a9847532.png)
