https://github.com/raphaelreme/tps
Implementation of ThinPlateSpline
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.5%) to scientific vocabulary
Repository
Implementation of ThinPlateSpline
Basic Info
Statistics
- Stars: 29
- Watchers: 1
- Forks: 4
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Thin Plate Spline (TPS)
Python (NumPy & SciPy) implementation of the generalized Polyharmonic Spline interpolation (also known as Thin Plate Spline in 2D). It learns a smooth elastic mapping between two Euclidean spaces with support for:
- Arbitrary input and output dimensions
- Arbitrary spline order
k - Optional regularization
Useful for interpolation, deformation fields, and smooth non-linear regression.
For a faster implementation in PyTorch, see torch-tps.
🚀 Install
Pip
bash
$ pip install thin-plate-spline
Getting started
```python import numpy as np from tps import ThinPlateSpline
Control points
Xtrain = np.random.normal(0, 1, (800, 3)) # 800 points in R^3 Ytrain = np.random.normal(0, 1, (800, 2)) # Values for each point (800 values in R^2)
New source points to interpolate
X_test = np.random.normal(0, 1, (300 0, 3))
Initialize spline model (Regularization is controled with alpha parameter)
tps = ThinPlateSpline(alpha=0.5)
Fit spline from control points
tps.fit(Xtrain, Ytrain)
Interpolate new points
Ytest = tps.transform(Xtest) ```
Examples
See the example/ folder for scripts showing:
- Interpolation in 1D, 2D, 3D
- Arbitrary input and output dimensions
- Image warping with elastic deformation
Image Warping
Example of increasing/decreasing/randomly deforming a dog's face using sparse control points.

Code: example/image_warping.py
🧠 Theory Summary
The model solves the regularized interpolation problem:
$$ minf \sum{i=1}^n (yi - f(xi))^2 + \int |\nabla^{\text{order}} f|_2^2 dx $$
With solution:
$$ f(x) = P(x) + \sum{i=1}^n wi G(|x - xi|2) $$
Where:
- $G(r)$: radial basis function (RBF) (depends on
orderand the input dimensiond) - $P(x)$: a polynomial of degree
order - 1
Default kernel (TPS): - $G(r) = r^2 \log(r)$
General kernel: - $G(r) = r^{(2 \text{order} - d)} \text{ if d is odd}$ - $G(r) = r^{(2\text{order} - d)} \log(r) \text{ otherwise}$
🔧 API
ThinPlateSpline(alpha=0.0, order=2, enforce_tps_kernel=False)
Creates a general polyharmonic spline interpolator (Default to TPS in 2D and natural cubic splines in 1D).
- alpha (float): Regularization strength (default 0.0)
- order (int): Spline order (default is 2 for TPS)
- enforcetpskernel (bool): Force TPS kernel r^2 log r, even when mathematically suboptimal
.fit(X, Y)
Fits the model to control point pairs.
- X:
(n, d)input coordinates - Y:
(n, v)target coordinates
Returns: self
.transform(X)
Applies the learned mapping to new input points.
- X:
(n', d)points
Returns: (n', v) interpolated values
Development
bash
git clone https://github.com/raphaelreme/tps.git
cd tps
pip install -e .
License
MIT License
Owner
- Login: raphaelreme
- Kind: user
- Repositories: 8
- Profile: https://github.com/raphaelreme
GitHub Events
Total
- Watch event: 8
- Push event: 8
- Create event: 1
Last Year
- Watch event: 8
- Push event: 8
- Create event: 1
Committers
Last synced: almost 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Raphael Reme | r****e@p****m | 12 |
| Raphael Reme | r****e@t****r | 3 |
| Dženan Zukić | d****c@k****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 4
- Total pull requests: 1
- Average time to close issues: 2 months
- Average time to close pull requests: about 4 hours
- Total issue authors: 3
- Total pull request authors: 1
- Average comments per issue: 4.5
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 0
- Average time to close issues: 25 days
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 6.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- frehburg (2)
- JoSchmaltz (1)
- Koushouu (1)
Pull Request Authors
- dzenanz (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 647 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 7
- Total maintainers: 1
pypi.org: thin-plate-spline
Thin Plate Spline and Polyharmonic Spline implementation with numpy/scipy
- Homepage: https://github.com/raphaelreme/tps
- Documentation: https://thin-plate-spline.readthedocs.io/
- License: MIT
-
Latest release: 1.2.0
published about 1 year ago
Rankings
Maintainers (1)
Dependencies
- black * development
- build * development
- matplotlib * development
- mypy * development
- pylint * development
- tqdm * development
- twine * development
- actions/checkout v3 composite
- actions/setup-python v4 composite
- pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite