# visualization of fitted thin plate spline from vtkThinPlateSplineTransform

**URL:** https://discourse.vtk.org/t/visualization-of-fitted-thin-plate-spline-from-vtkthinplatesplinetransform/5460
**Category:** Support
**Created:** [March 29, 2021, 1:35pm UTC](https://discourse.vtk.org/t/visualization-of-fitted-thin-plate-spline-from-vtkthinplatesplinetransform/5460 "2021-03-29T13:35:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Bjorn\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/bjorn_hansen/32/3189_2.png) [@Bjorn\_Hansen](https://discourse.vtk.org/u/Bjorn_Hansen)
#### Post date: [March 29, 2021, 1:35pm UTC](https://discourse.vtk.org/t/visualization-of-fitted-thin-plate-spline-from-vtkthinplatesplinetransform/5460/1 "2021-03-29T13:35:51Z")

</div>

Hello, I’m currently using the vtkThinPlateSplineTransform to do data augmentation on a mesh of a heart in Python. I would like to visualize the Thin Plate Spline i have fitted to a set of source and target points such that i can view the applied distortion as a plotted function in 3D.  
The code i have is currently is:

```
transform = vtk.vtkThinPlateSplineTransform()
transform.SetSourceLandmarks(p1)
transform.SetTargetLandmarks(p2)
transform.SetBasisToR2LogR()
transform.Update()
transform_filter = vtk.vtkTransformPolyDataFilter()
transform_filter.SetTransform(transform)
transform_filter.SetInputData(pd)
transform_filter.Update()

```

where p1 is the source points and p2 are the target points.

Is there any way i can exctract the fitted functions from the **transform** variable? Can i visualize the function with any VTK render functions or can i perhaps do it with matplotlib?  
I’m a mere novice with this amazing software so doing simple things like this is not that easy.

Thanks,  
Bjørn Hansen

---

<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: [March 29, 2021, 2:28pm UTC](https://discourse.vtk.org/t/visualization-of-fitted-thin-plate-spline-from-vtkthinplatesplinetransform/5460/2 "2021-03-29T14:28:01Z")

</div>

One way to visualize a deformable transform is to draw a grid of vectors, with each vector showing the direction and magnitude of the deformation at a point on the grid.

A transform can be sampled to create a vector grid with [vtkTransformToGrid](https://vtk.org/doc/nightly/html/classvtkTransformToGrid.html). The vector grid can be visualized with e.g. [vtkGlyph3DMapper](https://vtk.org/doc/nightly/html/classvtkGlyph3DMapper.html). There are a couple missing steps that you would have to figure out (and don’t make the mistake of thinking it’s simple, because it definitely isn’t).

---

<div class="post-metadata">

### Author: ![pieper](https://discourse.vtk.org/user_avatar/discourse.vtk.org/pieper/32/17_2.png) [@pieper](https://discourse.vtk.org/u/pieper)
#### Post date: [March 29, 2021, 2:52pm UTC](https://discourse.vtk.org/t/visualization-of-fitted-thin-plate-spline-from-vtkthinplatesplinetransform/5460/3 "2021-03-29T14:52:22Z")

</div>

A lot of the visualization modes are implemented with a user interface in Slicer if you want to avoid writing the code yourself.

[https://slicer.readthedocs.io/en/latest/user\_guide/modules/transforms.html?highlight=transform#visualization-modes](https://slicer.readthedocs.io/en/latest/user_guide/modules/transforms.html?highlight=transform#visualization-modes)
