Skip to content
/ tps Public
forked from raphaelreme/tps

Implementation of ThinPlateSpline (originally created by @raphaelreme)

License

Notifications You must be signed in to change notification settings

Koushouu/tps

 
 

Repository files navigation

tps

Lint and Test

Implementation of Thin Plate Spline. (For a faster implementation in torch, look at torch-tps)

Install

Pip

$ pip install thin-plate-spline

Conda

Not yet available

Getting started

import numpy 
from tps import ThinPlateSpline

# Some data
X_c = np.random.normal(0, 1, (800, 3))
X_t = np.random.normal(0, 2, (800, 2))
X = np.random.normal(0, 1, (300, 3))

# Create the tps object
tps = ThinPlateSpline(alpha=0.0)  # 0 Regularization

# Fit the control and target points
tps.fit(X_c, X_t)

# Transform new points
Y = tps.transform(X)

Examples

We provide different examples in the example folder. (From interpolation, to multidimensional cases and image warping).

Image warping

The elastic deformation of TPS can be used for image warping. Here is an example of tps to increase/decrease the size of the center of the image or using random control points:

Input ImageIncreased ImageDecreased ImageWarped Image

Have a look at example/image_warping.py.

Build and Deploy

$ python -m build
$ python -m twine upload dist/*

About

Implementation of ThinPlateSpline (originally created by @raphaelreme)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%