Keywords

1 Introduction

We consider the general problem of aligning multidimensional curves as 3D objects. The curve alignment and registration problems are well studied for scalar curves (1D) under functional data analysis framework [7, 10]. The richness of the registration problem comes from the variety of the criterion for comparing and measuring the similarity between the curves, which may also depend on the context. Nevertheless, in practice, good registration techniques aim to align significant features of the curves, called landmarks, such as peaks and valleys, and more generally geometric patterns of the curves. Many statistical approaches have been developed to automate this process, without the need of manually identifying the landmarks. As the geometric information is contained in the derivatives, it is often better to align the curves based on the derivatives. A related problem is to identify the sources of variations, in particular, decoupling amplitude and phase variations has been the main framework to study the variations of 1D curves [6].

While the notion of amplitude is univocally defined for scalar curves, the generalisation to curves in Euclidean space \(\mathbb {R}^{d}\) can be done in multiple ways [5]. Among possible approaches, the use of geometric features is shown to be effective for registering curves. This idea is formalised within the framework of elastic shape analysis [9], by considering significant landmarks and looking for invariant properties through group actions such as isometries or invariance by re-parametrisation. The basis of shape analysis is provided by the definition of proper spaces for representing objects, and the definition of an adapted distance. One of the successful applications of shape analysis for curves in general Euclidean spaces or more exotic ones is found with the use of the square root velocity transform (SRVT, [9]). The geometric feature is embedded in the first order derivative of the curves, the tangent of the curves.

In this article, we generalise the methodology based on the SRVT for the registration of two curves. Instead of using only the tangent information, we use an exhaustive description of the geometry of curves given by the so-called Frenet frame, which corresponds to the higher order information. This moving frame gives an explicit link to the complete geometric characterisation of a curve (curvature and torsion) through the Frenet-Serret formula. We propose a new distance between the curves based on the Frenet frame and demonstrates that the registration of the curves based on the Frenet frames is equivalent to stretching the curvatures and torsions. We show how to find an optimal solution using dynamic programming.

The article is organised as follows. In Sect. 2, we introduce the Frenet framework and review the square root velocity framework. Section 3 present our proposed methodology of curve alignment under the Frenet framework. Section 4 develops a computational algorithm.

2 Preliminaries

2.1 Frenet-Serret Framework

We consider regular curves x, i.e, functions such that the derivatives \(x^{(k)}(\cdot ),\,k=0,\dots 3\) exist, are continuous, and for all t in \(\left[ 0,T\right] \), we have \(\dot{x}(t)=x^{(1)}(t)\ne 0\) and \(\det \left( x^{(1)}(t),x^{(2)}(t),x^{(3)}(t)\right) \ne 0\). Consequently, we can write \(x(t)=X\left( s(t)\right) \) where \(s\mapsto X(s)\) is the arclength parametrised curve and \(t\mapsto s(t)\) is the curvilinear speed \(\dot{s}(t)=\left\| \dot{x}(t)\right\| \) and \(s(t)=\int _{0}^{t}\left\| \dot{x}(u)\right\| du\). The length of the curve is \(L=s(T)\). For clarity, we write \(\frac{d}{dt}x=\dot{x}(t)\) for differentiation with respect to time and \(\frac{d}{ds}X=X^{\prime }(s)\) for differentiation with respect to the curvilinear abscissa s. We denote the space of warping functions as

$$\begin{aligned} \mathcal {W}_{T,L}^+=\left\{ h:[0,T] \rightarrow [0,L]\, \vert \, h,h^{-1} \in C^1, \dot{h}>0 \right\} \end{aligned}$$

which corresponds to the space of increasing diffeormorphisms.

The parametrised curve \(\left\{ s\mapsto X(s),\,s\in \left[ 0,L\right] \right\} \) is the geometric curve associated with x. For each \(s\in \left[ 0,L\right] \), the tangent vector \(\mathbf T (s)=X^{\prime }(s)\) is normalised, and we can define additional normalised vectors \(\mathbf N \) and \(\mathbf B \) such that \(\mathbf N (s)\propto \mathbf T ^{\prime }(s)\) and \(\mathbf B (s)\propto \mathbf T (s)\times \mathbf N (s)\). Then, the matrix \(\mathbf Q (s)=\left[ \mathbf T (s)\vert \mathbf N (s)\vert \mathbf B (s)\right] \) is an orthonormal frame, which can be obtained by Gram-Schmidt orthonormalisation of the frame \(\left[ X^{\prime }(s)\vert X^{\prime \prime }(s)\vert X^{\prime \prime \prime }(s)\right] \). Quite remarkably, the Frenet frames are shown to be the solution of the following ODE:

$$\begin{aligned} \left\{ \begin{array}{ll} \mathbf T '(s)= &{} \kappa (s)\mathbf N (s) \,,\\ \mathbf N '(s)= &{} -\kappa (s)\mathbf T (s)+\tau (s)\mathbf B (s)\,,\\ \mathbf B '(s)= &{} -\tau (s)\mathbf N (s)\,, \end{array}\right. \end{aligned}$$
(1)

where the functions \(s\mapsto \kappa (s),\tau (s)\) are respectively the curvature and torsion (with a positivity condition for the curvature \(\kappa \)). In the rest of the paper, we will denote \(\varvec{\theta } : s\mapsto \left( \kappa (s),\tau (s)\right) \) the corresponding \(\mathbb {R}^2\)-valued function, and \(\varvec{\theta }\) will be called the generalised curvature. An alternative interpretation of this Frenet-Serret formula is that it defines an ODE in the Lie group SO(3) as:

$$\begin{aligned} \dot{\mathbf{Q }}(s)= & {} \mathbf Q (s)A_{\varvec{\theta }}(s) \end{aligned}$$
(2)

where the matrix

$$\begin{aligned} A_{\varvec{\theta }}(s) \triangleq \left[ \begin{array}{ccc} 0 &{} -\kappa (s) &{} 0\\ \kappa (s) &{} 0 &{} -\tau (s)\\ 0 &{} \tau (s) &{} 0 \end{array}\right] \,, \end{aligned}$$
(3)

is in the Lie algebra of skew-symmetric matrices, with the generalised curvature \(\varvec{\theta }\) and the initial condition \(\mathbf Q (0)=Q_{0}\).

The fundamental theorem of Differential Geometry of curves [2] is based on the Frenet-Serret Eq. (2) and claims that two curves \(x_{0},x_{1}\) with the same generalised curvature \(\varvec{\theta }\) (hence \(L_{0}=L_{1}\)) differ only by a rigid (Euclidean) transformation and a re-parametrisation: there exists a unique \((a,O) \in \mathbb {R}^3\times SO(3)\) and \(h\in \mathcal {W}_{T,L}^+\) such that

$$ x_{1}(t)=a+Ox_{0}\circ h(t)\,. $$

Obviously this means that the Frenet frames \(\mathbf Q _{0}\) and \(\mathbf Q _{1}\) satisfy \(\mathbf Q _{1}(s)=O \mathbf Q _{0}(\gamma (s))\) for all \(s\in \left[ 0,L\right] \), and an appropriate diffeomorphism \(\gamma \). It is clear then that \(\mathbf Q _{i}\) or \(\varvec{\theta }_{i}\) represent the shape of the curves \(x_i\), for \(i=0,1\).

2.2 Elastic Shape Analysis

The shapes \(X_0,X_1\) are what is left invariant under the actions of the rigid group and the group of re-parametrisations. We now focus on the development of an elastic shape analysis framework for the comparison of two different shapes through the action of specific groups of local (and nonlinear) deformations. This is motivated by finding the most appropriate warping \( h:\left[ 0,T\right] \longrightarrow \left[ 0,T\right] \in \mathcal {W}_{T,T}^+\) such that the two curves \(x_{1}\left( h(t)\right) =X_{1}\left( s_{1}\left( h(t)\right) \right) \) and \(x_{0}(t)=X_{0}\left( s_{0}(t)\right) \) looks similar. This is the standard alignment or registration problem, which has been studied in various ways, in particular based on geometric features through the geodesic distance between curves, [1, 4, 7, 11]. We focus here on the geometric features of the curves described by Frenet frames that can be seen as an extension of the Square Root Velocity Transform (SRVT) [9]. For each curve x, the square root velocity function is defined as

$$ q_{x}(t)=\frac{\dot{x}(t)}{\sqrt{\left\| \dot{x}(t)\right\| }}=\sqrt{\dot{s}(t)}\mathbf T \left( s(t)\right) \,, $$

which can be viewed as a representation of the shape of the curve. The distance between two curves is then defined as the \(L^2\) distance between \(q_x\) and is parametrisation-independent.

The SRVF transformation \(F:x\mapsto \dot{x}(t)/\sqrt{\left\| \dot{x}(t)\right\| }\) helps defining a pre-shape space that is used for characterising the underlying shape of a given function. In order to align the curves \(x_0, x_1\) with SRVF, we solve the following minimisation problem that defines at the same time a geodesic distance:

$$\begin{aligned} d_{srvf}(x_{0},x_{1})=\inf _{O\in SO(3), h\in \mathcal {W}_{T,T}^+} \int _{0}^{T}\left\| q_{0}(t)- O\sqrt{\dot{h}(t)}q_{1}(h(t)) \right\| ^{2}dt. \end{aligned}$$
(4)

As the distance \(d_{srvf}\) is invariant under re-parametrisation (and translation and rotation), it can be conveniently re-written by using the increasing diffeomorphisms \(\gamma :[0,L_0] \rightarrow [0,L_1] \in \mathcal {W}_{L_0,L_1}^+\) such that \(s_{1}\circ h=\gamma \circ s_{0}\) and by defining the discrepancy

$$\begin{aligned} \mathcal {R}(O,\gamma )=\int _{0}^{L_{0}}\left\| \mathbf T _{0}(s)-\sqrt{\dot{\gamma }(s)}O\mathbf T _{1}(\gamma (s))\right\| _{2}^{2}ds \,. \end{aligned}$$
(5)

The distance \(d_{srvf}\) and the corresponding optimal registration is obtained by solving the following program \((O^{*},\gamma ^{*})=\min _{\gamma , O}\mathcal {R}(O,\gamma )\) for \(\gamma \in \mathcal {W}_{L_0,L_1}^+\). The optimal registration \(h^* \in \mathcal {W}_{T,T}^+\) is then decomposed as \(h^*=s_1^{-1}\circ \gamma ^* \circ s_0\). While the warping functions \(s_i,i=0,1\) are related to curvilinear speeds along the shapes \(X_i,i=0,1\), the diffeomorphism \(\gamma ^*\) is a non-linear curve stretching that induces a deformation of the shape \(X_1\) towards the shape \(X_0\). We elaborate on this analysis for defining a distance and the corresponding alignment problem that fully exploit the geometry of the curve.

3 Elastic Shape Analysis and Curvature Stretching

3.1 Geometry Stretching

The previous section shows the alignment of \(x_0,x_1\) is not done by changing the curvilinear speed but by changing the geometry of the curves. Indeed, the elastic distance induces a specific family of transformations on the geometry of the curves. We have seen that the warping \(\gamma ^{*}\) permits to transform a curve of length \(L_{0}\) to a curve of length \(L_{1}\) by a non-linear (diffeomorphic) stretching. The two Frenet paths \(\mathbf Q _{0}\,:\,\left[ 0,L_{0}\right] \longrightarrow SO(3)\) and \(\mathbf Q _{1}\,:\,\left[ 0,L_{1}\right] \longrightarrow SO(3)\) are stretched with \(\gamma \in \mathcal {W}_{L_0,L_1}^+\). From Sect. 2.1, we know that the Frenet path \(s\mapsto \tilde{\mathbf{Q }}_{1}(s)=\mathbf Q _{1}(\gamma (s))\) is the solution to a new Frenet-Serret ODE:

$$\begin{aligned} \frac{d}{ds}\tilde{\mathbf{Q }}_{1}(s)= & {} \mathbf Q _{1}'(\gamma (s))\gamma '(s) \,,\\= & {} \mathbf Q _{1}\left( \gamma (s)\right) A_{\varvec{\theta }}(\gamma (s))\gamma '(s)\,,\\= & {} \tilde{\mathbf{Q }}_{1}(s)A_{\tilde{\varvec{\theta }}}(s) \,, \end{aligned}$$

This means that the shape \(X_1\) is stretched to a new shape \(\tilde{X}_1\) that possesses a generalised curvature \(\tilde{\varvec{\theta }}(s)\triangleq \varvec{\theta }(\gamma (s))\gamma '(s)\). In the case of equal length curves (\(L_0=L_1=L\)), the standard group of non-linear stretching \(\mathcal {W}_{L,L}^+\) defines a family of deformations that corresponds to a group action on the set of generalised curvatures \(\mathbf {\Theta }=\left\{ \varvec{\theta }=(\kappa ,\tau ), \kappa >0 \right\} \): for any \(\gamma \in \mathcal {W}_{L,L}^+\), we have \(\varvec{\theta } \mapsto \gamma \cdot \varvec{\theta } = \gamma ^{\prime }\varvec{\theta }\circ \gamma \). Indeed, we can check that for \(\gamma _{1},\gamma _{2} \in \mathcal {W}_{L,L}^+\), we have

$$ \left( \gamma _{2}\circ \gamma _{1}\right) \cdot \varvec{\theta }=\gamma _{2}\cdot \left( \gamma _{1}\cdot \varvec{\theta }\right) \,. $$

In general, the problem of finding a proper stretching \(\gamma \) between \(\varvec{\theta }_{0}\) and \(\varvec{\theta }_{1}\) can be expressed as solving the boundary value problem of finding \(\gamma \) such that \(\varvec{\theta }_{1}(\gamma (s))\gamma '(s)=\varvec{\theta }_{0}(s)\) for all \(s\in \left[ 0,L_0\right] \) with the constraint \(\gamma (0)=0\), \(\gamma (L_{0})=L_{1}\) and \(\gamma ^{\prime }>0\). Nevertheless, it is easy to see that there is no solution in general for stretching any geometry into another: if \(\varvec{\theta }_{0}\) and \(\varvec{\theta }_{1}\) are two generalised curvatures such that the torsions are \(\tau _{0}>0\) and \(\tau _{1}<0\), then we cannot find \(\gamma \) such that \(\gamma ^{\prime }\tau _{1}(\gamma )=\tau _{0}\).

A relaxation of that problem can be turned into the standard registration problem considered by SRVF, where we introduce a distance d defined on SO(3) and we aim at solving the problem of calculus of variations

$$ \left\{ \begin{array}{l} \min \nolimits _{\gamma }\int _{0}^{L_{0}}d\left( \mathbf Q _{0}(s),\mathbf Q _{1}(\gamma (s))\right) \sqrt{\gamma '(s)}ds \\ \gamma (0)=0,\,\gamma (L_0)=L_1\\ \gamma ^{\prime }>0 \end{array}\right. \,, $$

This problem might be solved with the corresponding Euler-Lagrange equation, but we will focus instead on a dynamic programming algorithm that solves efficiently a discretised version of the problem, adapted to sampled curves.

3.2 Registration with Frenet-Serret Frames

We define in this section precisely our Frenet-Serret framework for the registration of two curves. We aim at finding a warping \(h:\left[ 0,T\right] \longrightarrow \left[ 0,T\right] \) that minimises the discrepancy between the moving frames \(\mathbf Q _{1}\left( s_{1}\left( h(t)\right) \right) \) to \(\mathbf Q _{0}\left( s_{0}(t)\right) \). Similarly to the elastic distance, we propose the following distance between the curves

$$\begin{aligned} D(x_{0},x_{1})=\int _{0}^{T}d\left( \mathbf Q _{0}\left( s_{0}(t)\right) ,\mathbf Q _{1}\left( s_{1}(t)\right) \right) \sqrt{\dot{s}_{0}(t)\dot{s}_{1}(t)}dt \,, \end{aligned}$$
(6)

where \(d(\mathbf Q _{0},\mathbf Q _{1})\) is a distance between the frames in SO(3). Standard choices are the Frobenius distance \(\left\| \mathbf Q _{0}-\mathbf Q _{1}\right\| _{F}^{2}\) or the geodesic distance \(\left\| \log \mathbf Q _{1}^{\top }\mathbf Q _{0}\right\| _{F}^{2}\), where \(\log \) is the matrix logarithm. More generally, we can consider a distance based on the weighted norms such as \(\left\| \mathbf Q \right\| _{W,F}^{2}=Trace(\mathbf Q ^{\top }W\mathbf Q )\), indicating preferred directions in the frame.

If we introduce the non-linear stretching diffeomorphism \(s_{1}\circ s_{0}^{-1}=\gamma \in \mathcal {W}_{L_0,L_1}^+\), this leads to

$$ D(x_{0},x_{1}) = \int _{0}^{L_{0}}d\left( \mathbf Q _{0}\left( s\right) ,\mathbf Q _{1}\left( \gamma \left( s\right) \right) \right) \sqrt{\gamma ^{\prime }(s)}ds \,. $$

The distance between curves can be seen as a weighted distance between the Frenet path \(\mathcal {D}\left( \mathbf Q _{0},\mathbf Q _{1};\gamma \right) =\int _{0}^{L_{0}}d\left( \mathbf Q _{0}\left( s\right) ,\mathbf Q _{1}\left( \gamma \left( s\right) \right) \right) \sqrt{\gamma ^{\prime }(s)}ds\). A direct extension of the distance \(d_{srvf}\) is then the elastic Frenet-Serret distance

$$\begin{aligned} D_{FS}\left( x_{0},x_{1}\right)&=\min _{h\in \mathcal {W}_{T,T}^+,O\in SO(3)}D(x_{0},Ox_{1}\circ h). \end{aligned}$$
(7)

We can also consider a distance that does not respect rotation invariance, but only reparametrisation, defined by

$$\begin{aligned} D_{FS}^{0}\left( x_{0},x_{1}\right)&=\min _{h\in \mathcal {W}_{T,T}^+}D(x_{0},x_{1}\circ h). \end{aligned}$$
(8)

As with elastic distance based on the SRVF, the registration problem is the computation of the distance function:

$$\begin{aligned} \gamma ^{*}=\arg \min _{\gamma \in \mathcal {W}_{L_0,L_1}^+}\int _{0}^{L_{0}}d\left( \mathbf Q _{0}\left( s\right) ,\mathbf Q _{1}\left( \gamma \left( s\right) \right) \right) \sqrt{\gamma ^{\prime }(s)}ds \,. \end{aligned}$$
(9)

The optimal warping \(h\in \mathcal {W}_{T,T}^+\) for aligning \(x_{1}\left( h(t)\right) \) to \(x_{0}(t)\) is given by \(h^{*}=s_{1}^{-1}\circ \gamma ^{*}\circ s_{0}\), where \(\gamma ^{*}\) is the optimal non-linear stretching. Similarly, we can find the best reparametrisation and rotation \(\left( \gamma ^{*},O^{*}\right) \) that solves the optimisation problem (7), and the curve \(O^{*}x_{1}\left( h^{*}(t)\right) \) is aligned to \(x_{0}(t)\) with \(h^{*}=s_{1}^{-1}\circ \gamma ^{*}\circ s_{0}\).

Remark 1

\(D_{FS}^{0}\) is a direct generalisation of the standard elastic distance. If \(d\left( \mathbf Q _{0},\mathbf Q _{1}\right) =\left\| \mathbf Q _{0}-\mathbf Q _{1}\right\| _{F}^{2}=\left( \left\| \mathbf Q _{0}\right\| _{F}^{2}+\left\| \mathbf Q _{1}\right\| _{F}^{2}-2\text {Trace}\left( \mathbf Q _{0}^{\top }\mathbf Q _{1}\right) \right) \), the minimisation of \(\int _{0}^{L_{0}}d\left( \mathbf Q _{0}\left( s\right) ,\mathbf Q _{1}\left( \gamma \left( s\right) \right) \right) \sqrt{\gamma ^{\prime }(s)}ds\) is then equivalent to the maximisation of \(\int _{0}^{L_{0}}\text {Trace}\left( \mathbf Q _{0}^{\top }(s)\mathbf Q _{1}\left( \gamma \left( s\right) \right) \right) \sqrt{\gamma ^{\prime }(s)}ds\). In the same way, the minimisation of \(\int _{0}^{L_{0}}\left\| T_{0}(s)-\sqrt{\gamma ^{\prime }(s)}OT_{1}(\gamma (s))\right\| _{2}^{2}ds\) is equivalent to the maximisation of \(\int _{0}^{L_{0}}T_{0}^{\top }(s)OT_{1}\left( \gamma \left( s\right) \right) \sqrt{\gamma ^{\prime }(s)}ds\). This demonstrates that warping Frenet-Serret frames requires a higher degree of agreement between the geometries of \(x_{0}\) and \(x_{1}\).

Remark 2

We put emphasis on the fact that registering two curves \(x_{0}\) and \(x_{1}\) with an elastic distance (based on SRVF or Frenet-Serret) is not equivalent to aligning the curvatures and torsions.

4 Algorithm for Pairwise Alignment

Our objective is to obtain an algorithm that computes the optimal stretching and rotation by minimising \(\int _{0}^{L_{0}}d\left( \mathbf Q _{0}\left( s\right) ,O\mathbf Q _{1}\left( \gamma \left( s\right) \right) \right) \sqrt{\gamma ^{\prime }(s)}ds \) in \(O,\gamma \). We derive an iterative algorithm that works with discretely sampled data from \(\mathbf Q _0\) and \(\mathbf Q _1\). It starts by finding the best rotation \(O^{\left[ 0\right] }\) that minimises the distance between the normalised Frenet paths \(\int _{0}^{L_{0}}d\left( \mathbf Q _{0}\left( s\right) ,O\mathbf Q _{1}\left( s\right) \right) ds \) (with same length \(L_0\)). Then it implements an alternate optimisation based on a discretised criterion denoted by \(\mathcal {D}_{N_0}\left( \mathbf Q _{0},O\mathbf Q _{1};\gamma \right) \): Repeat steps 1 and 2 until convergence for \(m\ge 0\)

  1. 1.

    \(\gamma ^{\left[ m\right] }=\arg \min _{\gamma }\mathcal {D}_{N_0}\left( \mathbf Q _{0},O^{\left[ m\right] }\mathbf Q _{1};\gamma \right) \) computed by dynamic programming.

  2. 2.

    \(O^{\left[ m+1\right] }=\arg \min _{O}\mathcal {D}_{N_0}\left( \mathbf Q _{0},O\mathbf Q _{1};\gamma ^{[m]}\right) \) computed by weighted averaging of rotations.

4.1 Discretisation and Dynamic Programming

We consider two regular grids \(G_i,\, i=0,1\) defined on \([0,L_i], i=0,1\), with stepsize \(h_i=\frac{L_i}{N_i}, i=0,1\) and \(N_0,N_1\) are the number of points used. The points of the grid \(G_0\) are denoted \(s_k=k h_0, k\le N_0 \), and the point of the grid \(G_1\) are denoted \(x_j= j h_1, j\le N_1\). We use a quadrature formula for approximating the integrals \(\int _{s_k}^{s_{k+1}} d\left( \mathbf Q _{0}(s),\mathbf Q _{1}\left( \gamma (s)\right) \right) \sqrt{\gamma '(s)}ds\) and we use a piece-wise linear approximation of the function \(\gamma \) on the same grid \(G_0\), with values in \(G_1\). The function values are denoted \(x_k=\gamma (s_k)\), and the derivatives are piece-wise constant on \(]s_k,s_{k+1}[\) and are denoted \(u_k=\gamma ^\prime (s_k)\). Consequently, we have \(x_{k+1}=x_k + h_0 u_k\), for \(k=0,\dots ,N_0-1\), and we must have \(x_{N_0}=\gamma (s_{N_0})=L_1\). As the boundary conditions are fixed and known, the computation of \(\gamma \) is equivalent to optimising with respect to \(\varvec{u}=\left( u_k\right) _{k=0,\dots ,N_0-1}\). Moreover, the state dynamics is \(x_{k+1}=x_{k}+h_0 u_{k}\), which means that there exists \(i_k \in 1,\dots ,N_1\), such that \(i_k h_1 = u_k h_0\), i.e. the possible values of the derivatives \(u_k\) are multiple of \(h_1/h_0\).

On each segment \([s_k,s_{k+1}]\), our approximation of the integral is \(g_{k}(x_{k},u_{k})\) and is obtained by using the trapezoidal rule

$$ g_{k}(x_{k},u_{k})=h_0\frac{d\left( \mathbf Q _{0}(s_{k}),\mathbf Q _{1}\left( x_{k}\right) \right) + d\left( \mathbf Q _{0}(s_{k+1}),\mathbf Q _{1}\left( x_{k+1}\right) \right) }{2} \times \sqrt{u_{k}}. $$

where we have made use of the fact that \(\gamma '=u_k\) is constant on the segment. Finally, our approximation of the integral criterion is the following sum

$$ \mathcal {D}_{N_0}\left( \mathbf Q _{0},\mathbf Q _{1};\gamma \right) \triangleq \mathcal {D}_{N_0}\left[ \varvec{u}\right] = \sum _{k=0}^{N_0-1}g_{k}(x_{k},u_{k})+g_{N_0}(x_{N_0}). $$

The terminal cost \(g_{N}(x_{N})\) is such that \(g_{N_0}(x_{N_0})= +\infty \) if \(x_{N_0} \ne L_1\) and \(g_{N_0}(x_{N_0})=0\) if \(x_{N_0}=L_1\). We need to solve the following program with constraints on the state and the control variables:

$$ \left\{ \begin{array}{ll} \min \nolimits _{\varvec{u}} &{} \sum _{k=0}^{N_{0}-1}g_{k}(x_{k},u_{k})+g_{N_{0}}(x_{N_{0}})\\ s.t. &{} x_{k+1}=x_{k}+h_{0}u_{k}\\ &{} x_{0}=0,x_{N_{0}}=L_{1},0<x_{k}<L_{1}, \forall k \in [1,\ldots , N_{0}-1]\\ &{} \forall k\le N_0-1,u_{k}>0 \end{array}\right. $$

We use Dynamic Programming for computing the criterion and optimising in \(\varvec{u}\). This is based on the backward computation of the value function \(J_k(x)\) (\(k=0,\dots ,N_0\)) defined on the state space, i.e the grid \(G_1\). For every initial state x, the optimal cost is given by

$$ \left\{ \begin{array}{l} J_{N_0}(x)=g_{N_0}(x), \forall x \in G_1\\ J_{k}(x_{k})=\min \nolimits _{u\in U_{k}(x_{k})}g_{k}(x_{k},u)+J_{k+1}\left( x_{k}+h_0u\right) ,\,k=0,1,\dots ,N_0-1 \,, \end{array}\right. $$

where \(U_k(x_k)\) is the set of admissible control at time k and state \(x_k\). For computation speed, we may impose a more stringent constraint on the control such as \(h_0 u_{k}\le \varDelta _{Max}\). The optimal control found at each time k is denoted by \(u_k^*\), and is computed during the forward pass. The optimal alignment function \(\gamma ^*\) is sampled on the grid \(G_0\), such that \(x_{k}^{*}=\gamma ^{*}(s_{k})\) is obtained by starting at \(x^*_{0}=0\) and by using the optimal decision \(u^*_k, k=0,\dots ,N_0-1\).

Remark 3

In practice we use this Dynamic Programming algorithm for computing warping functions defined on [0, 1]. A straightforward change of variable gives

$$\begin{aligned} \mathcal {D}\left( \mathbf Q _{0},\mathbf Q _{1};\gamma \right)= & {} \int _{0}^{1}d\left( \tilde{\mathbf{Q }}_{0}(u),\tilde{\mathbf{Q }}_{1}\left( \tilde{\gamma }(s)\right) \right) \sqrt{\tilde{\gamma }'(s)} \sqrt{L_0 L_1} ds \end{aligned}$$
(10)

where \(\tilde{\gamma }\,:\,[0,1] \longrightarrow [0,1]\) is the warping function defined for all \(u \in [0,1]\) such as \(\tilde{\gamma }(u)= L_1 \gamma (u L_0)\). The Frenet path \(\tilde{Q}_{0},\tilde{Q}_{1}\) have been defined by normalizing the paths by their length, i.e \(\tilde{\mathbf{Q }}_{i}(u)=\mathbf Q _{i}(uL_i),\,i=0,1\).

Remark 4

We deal with two grids defined on [0, 1]: \(G_0=\{i\frac{1}{N_0},\, i=0,\dots ,N_0\}\) and \(G_1=\{j\frac{1}{N_1},\, j=0,\dots ,N_1\}\). It is important to resample the data and to interpolate the data of the Frenet Path \(\tilde{Q}_1\) such that \(N_1=2\times N_0\). This is needed because the warping function is piece-wise linear, and we control only the slope \(u_k\) on the interval \([s_k, s_{k+1}]\). We impose \(u_k>0\), but the slope is quantified and is proportional to \(\frac{h_1}{h_0}\), consequently if we want a good approximation of the exact warping function \(\gamma \) we need a fine grid \(G_1\). In practice, doubling and interpolating the number of points in \(\tilde{\mathbf{Q }}_1\) is sufficient. On the other side, the trapezoid approximation might be significantly biased, hence refining the grid \(G_0\) by interpolating the data \(\tilde{\mathbf{Q }}_0(s_k)\) is sometimes needed.

Remark 5

We use linear interpolation in the Lie Algebra: let \(A,B \in SO(3)\), we define the smooth path \(\varphi : [0,1] \longrightarrow SO(3)\) such that \(\varphi (0)=A\) and \(\varphi (1)=B\), by \(\varphi (s)=\exp \big ( s \log (BA^\top ) \big ) A\).

Fig. 1.
figure 1

Alignement of two shapes \(X_0\) and \(X_1\), when \(\varvec{\theta _1}=w^* \cdot \varvec{\theta _0}\) and estimation of the warping function \(\gamma ^*\).

First Row: No rotation. Top Left: The two curves \(X_0\) (in blue) and \(X_1\) (in red). Top Right: the estimates of \(\gamma ^*\): the truth \(\gamma ^*\) (dark blue), \(\hat{\gamma }_{fs}\) (red), and \(\hat{\gamma }_{srvf}\) (magenta). The red and magenta are superimposed.

2nd Row: With a random rotation. Bottom Left: The two curves \(X_0\) (in blue) and \(X_1\) (in red). \(X_1\) is a stretched and rotated version of \(X_0\). Bottom Right: the estimates of \(\gamma ^*\): the truth \(\gamma ^*\) (dark blue), \(\hat{\gamma }_{fs}\) (red), and \(\hat{\gamma }_{srvf}\) (magenta). The estimate \(\hat{\gamma }_{fs}\) is closer to the truth blue line than \(\hat{\gamma }_{srvf}\). The rotations are both estimated by SRVF and FS, and we obtain also more precise results with Frenet-Serret, which might be natural because we use more information. Finally, we should notice that the convergence is much faster for the Frenet-Serret version than for the SRVF (less than 5 iterations against more than 50 iterations) (color figure online).

4.2 Optimal Rotation

The computation of the minimum depends on the type of the distance function used. For the standard Frobenius distance, the solution is found by solving

$$\begin{aligned} \min _{O}\sum _{k=0}^{N_0-1} \frac{h_0\sqrt{u_{k}^{*}}}{2}\text {Trace} \big ( \left( \mathbf Q _{1}(x_{k_1}^{*})\mathbf Q _{0}^{\top }(s_{k+1}) + \mathbf Q _{1}(x_{k}^{*})\mathbf Q _{0}^{\top }(s_{k}) \right) O \big ) \,. \end{aligned}$$
(11)

The solution is the polar part of the weighted mean \(\sum _{k=0}^{N_0-1} \frac{h_0\sqrt{u_{k}^{*}}}{2} \mathbf Q _{1}(x_{k_1}^{*})\)\(\mathbf Q _{0}^{\top }(s_{k+1}) + \mathbf Q _{1}(x_{k}^{*})\mathbf Q _{0}^{\top }(s_{k})\). If we use the geodesic distance, the problem is equivalent to computing a weighted geodesic, which can be computed by gradient descent in SO(3), see [3, 8].

5 Examples and Simulations

We show that our DP algorithm can estimate properly the warping function. In our simulations, we define a reference generalised curvature \(\varvec{\theta _0}\) and the associated Frenet path \(\mathbf Q _0\) and curve \(X_0\) of length \(L_0\). The curve \(X_1\) is obtained from \(X_0\) by applying the elastic deformation given by \(w^*\), i.e \(\varvec{\theta _1}=w^* \cdot \varvec{\theta _0}\), and the Frenet paths are such that \(\forall s\in [0,L_1], \mathbf Q _1(s) = \mathbf Q _0\big (w^*(s)\big )\). Our objective is then to estimate \(w^{*(-1)} = \gamma ^*\) by minimizing our criteria \(\mathcal {D}_{N_0}\left( \mathbf Q _{0},\mathbf Q _{1};\gamma \right) \). We denote \(\hat{\gamma }_{fs}\) the estimate obtained by Frenet-Serret frames and \(\hat{\gamma }_{srvf}\) obtained by standard SRVF. We consider a warping functions defined in [0, 1] (see remark 3) \(w(s)=\frac{\log (s+1)}{log(2)}\) with \(\gamma (s)=\exp \big ( \log (2)s \big )-1\). We consider that we observe directly the Frenet paths \(\mathbf Q _0, \mathbf Q _1\) on grids \(G_0,G_1\), with \(L_0=2, N_0=100\) and \(L_1=3, N_0=150\). The curves have a shape defined by a curvature \(\kappa _0(s)=\exp (\theta \sin (s))\) and a torsion \(\tau _0(s)=\eta s - 0.5\). We consider a simple registration case without any rotation O, and we consider also the case of a additional random rotation i.e \(\mathbf Q _1=O \mathbf Q _0 \circ w^*\). The results are available in Fig. 1.