ThinPlateSplines¶
-
class
menpo.transform.
ThinPlateSplines
(source, target, kernel=None)[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. If None is supplied, the
R2LogR2
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 (
BasisFunction
, optional) –The kernel to apply.
Default:
R2LogR2
Raises: ValueError
– TPS is only with on 2-dimensional 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, **kwargs)¶ Applies this transform to
x
.If
x
isTransformable
,x
will be handed this transform object to transform itself non-destructively (a transformed copy of the object will be returned).If not,
x
is assumed to be an ndarray. The transformation will be non-destructive, 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. - kwargs (dict) – Passed through to
_apply()
.
Returns: transformed (
type(x)
) – The transformed object or array- x (
-
apply_inplace
(x, **kwargs)¶ Applies this transform to a
Transformable
x
destructively.Any
kwargs
will be passed to the specific transform_apply()
method.Parameters: - x (
Transformable
) – TheTransformable
object to be transformed. - kwargs (dict) – Passed through to
_apply()
.
Returns: transformed (
type(x)
) – The transformed object- x (
-
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 (
TransformChain
) – Transform to be applied before self - Returns –
- -------- –
- transform – The resulting transform chain.
- transform (
-
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 (
TransformChain
) – Transform to be applied after self - Returns –
- -------- –
- transform – The resulting transform chain.
- transform (
-
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
-
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.
-
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