fluidimage.calcul.interpolate.thin_plate_spline#
Thin plate spline#
Translated and adapted from UVmat code (Joel Sommeria, LEGI, CNRS).
This interpolation/smoothing (Duchon, 1976; NguyenDuc and Sommeria, 1988) minimises a linear combination of the squared curvature and squared difference from the initial data.
We first need to compute tps coefficients U_tps
(function
compute_tps_weights
). Interpolated data can then be obtained as the
matrix product dot(U_tps, EM)
where the matrix EM
is obtained
by the function compute_tps_matrix
. The spatial derivatives are
obtained as dot(U_tps, EMDX)
and dot(U_tps, EMDY)
, where
EMDX
and EMDY
are obtained from the function
compute_tps_matrix_dxy
. A helper class is also provided.
- fluidimage.calcul.interpolate.thin_plate_spline.compute_tps_weights(centers, values, smoothing_coef)[source]#
Calculate the thin plate spline (tps) coefficients
- Parameters:
- centersnp.array
[nb_dim, N]
array representing the positions of the N centers, sources of the TPS (nb_dim = space dimension).- valuesnp.array
[N]
array representing the values of the considered scalar measured at the centrescenters
.- smoothing_coeffloat
Smoothing parameter. The result is smoother for larger smoothing_coef.
- Returns:
- smoothed_valuesnp.array
Values of the quantity U at the N centres after smoothing.
- tps_weightsnp.array
TPS weights of the centres and columns of the linear.
- class fluidimage.calcul.interpolate.thin_plate_spline.ThinPlateSpline(new_positions, centers)[source]#
Bases:
object
Helper class for thin plate interpolation.
- fluidimage.calcul.interpolate.thin_plate_spline.compute_tps_matrix_numpy(new_pos: float64[][], centers: float64[][])[source]#
calculate the thin plate spline (tps) interpolation at a set of points
- Parameters:
- new_pos: np.array
[nb_dim, M]
array representing the postions of the M ‘observation’ sites, with nb_dim the space dimension.- centers: np.array
[nb_dim, N]
array representing the postions of the N centers, sources of the tps.
- Returns:
- EMnp.array
[(N+nb_dim), M]
matrix representing the contributions at the M sites.From unit sources located at each of the N centers, + (nb_dim+1) columns representing the contribution of the linear gradient part.
Notes
>>> U_interp = np.dot(U_tps, EM)
- fluidimage.calcul.interpolate.thin_plate_spline.compute_tps_matrices_dxy(dsites, centers)[source]#
Calculate the derivatives of thin plate spline (tps) interpolation at a set of points (limited to the 2D case)
- Parameters:
- dsitesnp.array
[nb_dim, M]
array of interpolation site coordinates (nb_dim = space dimension = 2, here).- centersnp.array
[nb_dim, N]
array of centre coordinates (initial data).
- Returns:
- DMXnp.array
[(N+3), M]
array representing the contributions to the X derivatives at the M sites from unit sources located at each of the N centers, + 3 columns representing the contribution of the linear gradient part.- DMYnp.array
idem for Y derivatives.
Functions
|
Calculate the derivatives of thin plate spline (tps) interpolation at a set of points (limited to the 2D case) |
|
calculate the thin plate spline (tps) interpolation at a set of points |
|
calculate the thin plate spline (tps) interpolation at a set of points |
|
calculate the thin plate spline (tps) interpolation at a set of points |
|
Calculate the thin plate spline (tps) coefficients |
Classes
|
Helper class for thin plate interpolation. |
|