# Thin Plate Spline & Lanczos Interpolation

**URL:** <https://forum.opencv.org/t/thin-plate-spline-lanczos-interpolation/18912>\
**Category:** Python\
**Tags:** thinplatespline\
**Created:** [October 7, 2024, 9:02pm UTC](https://forum.opencv.org/t/thin-plate-spline-lanczos-interpolation/18912 "2024-10-07T21:02:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_van](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/jason_van/32/11192_2.png) [@Jason\_van](https://forum.opencv.org/u/Jason_van)\
**Post date:** [October 7, 2024, 9:02pm UTC](https://forum.opencv.org/t/thin-plate-spline-lanczos-interpolation/18912/1 "2024-10-07T21:02:05Z")

</div>

Hello all! Apologies for past twice in the past couple of weeks.

I’ve been struggling a bit on my project regarding aligning astronomical images nonlinearly. I have a question converting from Scikit-Image to OpenCV:

- I’ve been trying to do this using OpenCV instead, but have been struggling to getting results as the above. The images look very twisted and incorrect. Here is the code that I thought would be the equivalent in OpenCV:

```auto
# Scikit-image
tps = ThinPlateSplineTransform()

tps.estimate(dst_pts, src_pts)

warped_img = warp(src_img, tps, order=5)

```

```auto
# OpenCV
tps_transformer = cv2.createThinPlateSplineShapeTransformer()

matches = [cv2.DMatch(i, i, 0) for i in range(len(src_pts))]

tps_transformer.estimateTransformation(src_pts.reshape(1, -1, 2), dst_pts.reshape(1, -1, 2), matches)

warped_img_opencv = tps_transformer.warpImage(src_img, flags=cv2.INTER_LANCZOS4)

```
