Shape spaces
Shape spaces are spaces of $k$ points in $ℝ^n$ up to simultaneous action of a group on all points. The most commonly encountered are Kendall's pre-shape and shape spaces. In the case of the Kendall's pre-shape spaces the action is translation and scaling. In the case of the Kendall's shape spaces the action is translation, scaling and rotation.
using Manifolds, PlotsM = KendallsShapeSpace(2, 3)# two random point on the shape spacep = [ 0.4385117672460505 -0.6877826444042382 0.24927087715818771 -0.3830259932279294 0.35347460720654283 0.029551386021386548]q = [ -0.42693314765896473 -0.3268567431952937 0.7537898908542584 0.3054740561061169 -0.18962848284149897 -0.11584557326461796]# let's plot them as triples of points on a planefig = scatter(p[1,:], p[2,:], label="p", aspect_ratio=:equal)scatter!(fig, q[1,:], q[2,:], label="q")A more extensive usage example is available in the hand gesture analysis tutorial.
Manifolds.KendallsPreShapeSpace — Type
KendallsPreShapeSpace{T} <: AbstractSphere{ℝ}Kendall's pre-shape space of $k$ landmarks in $ℝ^n$ represented by n×k matrices. In each row the sum of elements of a matrix is equal to 0. The Frobenius norm of the matrix is equal to 1 [Ken84][Ken89].
The space can be interpreted as tuples of $k$ points in $ℝ^n$ up to simultaneous translation and scaling of all points, so this can be thought of as a quotient manifold.
Constructor
KendallsPreShapeSpace(n::Int, k::Int; parameter::Symbol=:type)See also
KendallsShapeSpace, esp. for the references
Manifolds.KendallsShapeSpace — Type
KendallsShapeSpace{T} <: AbstractDecoratorManifold{ℝ}Kendall's shape space, defined as quotient of a KendallsPreShapeSpace (represented by n×k matrices) modulo column wise application of a single rotation.
The space can be interpreted as tuples of $k$ points in $ℝ^n$ up to simultaneous translation and scaling and rotation of all points [Ken84][Ken89].
Constructor
KendallsShapeSpace(n::Int, k::Int; parameter::Symbol=:type)References
Provided functions
Manifolds.helmert_submatrix — Method
helmert_submatrix(::Type{T}, k::Int)Return the (k-1)×k matrix below the first row of the Helmert matrix of order k, whose j-th row is $(h_j, …, h_j, -jh_j, 0, …, 0)$ with $h_j = (j(j+1))^{-1/2}$. With the first row $(1/\sqrt{k}, …, 1/\sqrt{k})$ the Helmert matrix is orthogonal, see Eq. (8.87) in [Gen17, Section 8.8.1].
ManifoldsBase.check_point — Method
check_point(M::KendallsPreShapeSpace, p; atol=sqrt(eps(float(eltype(p)))), kwargs...)Check whether p is a valid point on KendallsPreShapeSpace, i.e. whether each row has zero mean. Other conditions are checked via embedding in ArraySphere.
ManifoldsBase.check_vector — Method
check_vector(M::KendallsPreShapeSpace, p, X; atol=sqrt(eps(float(eltype(X)))), kwargs...)Check whether X is a valid tangent vector on KendallsPreShapeSpace, i.e. whether each row has zero mean. Other conditions are checked via embedding in ArraySphere.
ManifoldsBase.get_coordinates — Method
get_coordinates(M::KendallsPreShapeSpace, p, X, ::DefaultOrthonormalBasis)Compute the coordinates of the tangent vector X at p on the KendallsPreShapeSpace M in an orthonormal basis. With the helmert_submatrix $H$, $p ↦ pH^{\mathrm{T}}$ maps M isometrically onto the ArraySphere(n, k-1), see [Ken89, Section 2], and the coordinates are those of $XH^{\mathrm{T}}$ at $pH^{\mathrm{T}}$ on that sphere.
ManifoldsBase.get_embedding — Method
get_embedding(M::KendallsPreShapeSpace)Return the space KendallsPreShapeSpace M is embedded in, i.e. ArraySphere of matrices of the same shape.
ManifoldsBase.get_vector — Method
get_vector(M::KendallsPreShapeSpace, p, c, ::DefaultOrthonormalBasis)Compute the tangent vector at p on the KendallsPreShapeSpace M with the coordinates c in an orthonormal basis. It is $YH$, where $H$ is the helmert_submatrix and $Y$ is the tangent vector with the coordinates c at $pH^{\mathrm{T}}$ on the ArraySphere(n, k-1), see [Ken89, Section 2].
ManifoldsBase.manifold_dimension — Method
manifold_dimension(M::KendallsPreShapeSpace)Return the dimension of the KendallsPreShapeSpace manifold M. The dimension is given by $n(k - 1) - 1$.
ManifoldsBase.project — Method
project(M::KendallsPreShapeSpace, p, X)Project tangent vector X at point p from the embedding to KendallsPreShapeSpace by selecting the right element from the tangent space to orthogonal section representing the quotient manifold M. See Section 3.7 of [SK16] for details.
ManifoldsBase.project — Method
project(M::KendallsPreShapeSpace, p)Project point p from the embedding to KendallsPreShapeSpace by selecting the right element from the orthogonal section representing the quotient manifold M. See Section 3.7 of [SK16] for details.
The method computes the mean of the landmarks and moves them to make their mean zero; afterwards the Frobenius norm of the landmarks (as a matrix) is normalised to fix the scaling.
Base.exp — Method
exp(M::KendallsShapeSpace, p, X)Compute the exponential map on KendallsShapeSpace M. See [GMTP21] for discussion about its computation.
Base.isapprox — Method
isapprox(M::KendallsShapeSpace, p, X, Y; kwargs...)Test whether two tangent vectors X, Y at p on the KendallsShapeSpace M are (approximately) the same, that is whether $\lVert X - Y \rVert_p \approx 0$ with the classical isapprox. The kwargs... are passed on to this; atol defaults to sqrt(max_eps(X, Y)).
Base.isapprox — Method
isapprox(M::KendallsShapeSpace, p, q; kwargs...)Test whether two points p, q on the KendallsShapeSpace M are (approximately) the same. Since this is a quotient manifold, the test is performed by checking their distance if they are not equal, that is $d_{\mathcal M}(p,q) \approx 0$ with the classical isapprox. The kwargs... are passed on to this; atol defaults to sqrt(max_eps(p, q)).
Base.log — Method
log(M::KendallsShapeSpace, p, q)Compute the logarithmic map on KendallsShapeSpace M. See the exponential map for more details.
Base.rand — Method
rand(::KendallsShapeSpace; vector_at=nothing)When vector_at is nothing, return a random point x on the KendallsShapeSpace manifold M by generating a random point in the embedding.
When vector_at is not nothing, return a random vector from the tangent space with mean zero and standard deviation σ.
ManifoldsBase.get_embedding — Method
get_embedding(M::KendallsShapeSpace)Get the manifold in which KendallsShapeSpace M is embedded, i.e. KendallsPreShapeSpace of matrices of the same shape.
ManifoldsBase.get_total_space — Method
get_total_space(::KendallsShapeSpace)Return the total space of the KendallsShapeSpace manifold, which is the KendallsPreShapeSpace manifold.
ManifoldsBase.horizontal_component — Method
horizontal_component(::KendallsShapeSpace, p, X)Compute the horizontal component of tangent vector X at p on KendallsShapeSpace M. See [GMTP21], Section 2.3 for details.
ManifoldsBase.is_flat — Method
is_flat(::KendallsShapeSpace)Return false. KendallsShapeSpace is not a flat manifold.
ManifoldsBase.manifold_dimension — Method
manifold_dimension(M::KendallsShapeSpace)Return the dimension of the KendallsShapeSpace manifold M. The dimension is given by $n(k - 1) - 1 - n(n - 1)/2$ in the typical case where $k \geq n+1$, and $(k + 1)(k - 2) / 2$ otherwise. See [Ken84] for a discussion of the over-dimensioned case.
Literature
- [Gen17]
- J. E. Gentle. Matrix Algebra: Theory, Computations and Applications in Statistics. 2 Edition, Springer Texts in Statistics (Springer Cham, 2017).
- [GMTP21]
- N. Guigui, E. Maignant, A. Trouvé and X. Pennec. Parallel Transport on Kendall Shape Spaces. In: Geometric Science of Information (SPringer Cham, 2021); pp. 103–110.
- [Ken84]
- D. G. Kendall. Shape Manifolds, Procrustean Metrics, and Complex Projective Spaces. Bulletin of the London Mathematical Society 16, 81–121 (1984).
- [Ken89]
- D. G. Kendall. A Survey of the Statistical Theory of Shape. Statistical Science 4, 87–99 (1989).
- [SK16]
- A. Srivastava and E. P. Klassen. Functional and Shape Data Analysis (Springer New York, 2016).