ThinPlateSplines¶

class
menpo.transform.
ThinPlateSplines
(source, target, kernel=None, min_singular_val=0.0001)[source]¶ Bases:
Alignment
,Transform
,Invertible
The thin plate splines (TPS) alignment between 2D source and target landmarks.
kernel
can be used to specify an alternative kernel function. IfNone
is supplied, theR2LogR2RBF
kernel will be used.Parameters:  source (
(N, 2)
ndarray) – The source points to apply the tps from  target (
(N, 2)
ndarray) – The target points to apply the tps to  kernel (
RadialBasisFunction
, optional) – The kernel to apply.  min_singular_val (float, optional) – If the target has points that are nearly coincident, the coefficients matrix is rank deficient, and therefore not invertible. Therefore, we only take the inverse on the fullrank matrix and drop any singular values that are less than this value (close to zero).
Raises: ValueError
– TPS is only with on 2dimensional data
aligned_source
()¶ The result of applying
self
tosource
Type: PointCloud

alignment_error
()¶ The Frobenius Norm of the difference between the target and the aligned source.
Type: float

apply
(x, batch_size=None, **kwargs)¶ Applies this transform to
x
.If
x
isTransformable
,x
will be handed this transform object to transform itself nondestructively (a transformed copy of the object will be returned).If not,
x
is assumed to be an ndarray. The transformation will be nondestructive, returning the transformed version.Any
kwargs
will be passed to the specific transform_apply()
method.Parameters:  x (
Transformable
or(n_points, n_dims)
ndarray) – The array or object to be transformed.  batch_size (int, optional) – If not
None
, this determines how many items from the numpy array will be passed through the transform at a time. This is useful for operations that require large intermediate matrices to be computed.  kwargs (dict) – Passed through to
_apply()
.
Returns: transformed (
type(x)
) – The transformed object or array x (

apply_inplace
(*args, **kwargs)¶ Deprecated as public supported API, use the nonmutating apply() instead.
For internal performancespecific uses, see _apply_inplace().

compose_after
(transform)¶ Returns a
TransformChain
that represents this transform composed after the given transform:c = a.compose_after(b) c.apply(p) == a.apply(b.apply(p))
a
andb
are left unchanged.This corresponds to the usual mathematical formalism for the compose operator, o.
Parameters: transform ( Transform
) – Transform to be applied before selfReturns: transform ( TransformChain
) – The resulting transform chain.

compose_before
(transform)¶ Returns a
TransformChain
that represents this transform composed before the given transform:c = a.compose_before(b) c.apply(p) == b.apply(a.apply(p))
a
andb
are left unchanged.Parameters: transform ( Transform
) – Transform to be applied after selfReturns: transform ( TransformChain
) – The resulting transform chain.

copy
()¶ Generate an efficient copy of this object.
Note that Numpy arrays and other
Copyable
objects onself
will be deeply copied. Dictionaries and sets will be shallow copied, and everything else will be assigned (no copy will be made).Classes that store state other than numpy arrays and immutable types should overwrite this method to ensure all state is copied.
Returns: type(self)
– A copy of this object

pseudoinverse
()[source]¶ The pseudoinverse of the transform  that is, the transform that results from swapping source and target, or more formally, negating the transforms parameters. If the transform has a true inverse this is returned instead.
Type: type(self)

set_target
(new_target)¶ Update this object so that it attempts to recreate the
new_target
.Parameters: new_target ( PointCloud
) – The new target that this object should try and regenerate.

has_true_inverse
¶ type –
False

n_dims_output
¶ The output of the data from the transform.
None
if the output of the transform is not dimension specific.Type: int or None

source
¶ The source
PointCloud
that is used in the alignment.The source is not mutable.
Type: PointCloud

target
¶ The current
PointCloud
that this object produces.To change the target, use
set_target()
.Type: PointCloud
 source (