Nilpotent Approximations of Sub-Riemannian Distances for Fast Perceptual Grouping of Blood Vessels in 2D and 3D

We propose an efficient approach for the grouping of local orientations (points on vessels) via nilpotent approximations of sub-Riemannian distances in the 2D and 3D roto-translation groups SE(2) and SE(3). In our distance approximations we consider homogeneous norms on nilpotent groups that locally approximate SE(n), and which are obtained via the exponential and logarithmic map on SE(n). In a qualitative validation we show that the norms provide accurate approximations of the true sub-Riemannian distances, and we discuss their relations to the fundamental solution of the sub-Laplacian on SE(n). The quantitative experiments further confirm the accuracy of the approximations. Quantitative results are obtained by evaluating perceptual grouping performance of retinal blood vessels in 2D images and curves in challenging 3D synthetic volumes. The results show that (1) sub-Riemannian geometry is essential in achieving top performance and (2) grouping via the fast analytic approximations performs almost equally, or better, than data-adaptive fast marching approaches on \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathbb {R}^n$$\end{document}Rn and SE(n).


Nilpotent Approximation
The sub-Riemannian distances on SE(n) are approximated via norms on the vectors obtained from the logarithmic map (from group elements to the Lie algebra). This approach is motivated by problems from sub-Riemannian geometry in nilpotent Lie groups, in which such homogenous norms provide exact fundamental solutions to sub-Laplacians.
The vectors obtained by the logarithmic map, expressed in a left-invariant basis, are the so-called exponential coordinates of the first kind. For a nilpotent group of step two, like the Heisenberg group, these coordinates define [together with a group product defined via the Baker-Campbell-Hausdorf (BCH) formula] a global isomorphism to the group. In our SE(n) setting we have to truncate the commutator series in the BCH formula due to non-vanishing (higher-order) commutators, yielding a corresponding Heisenberg type approximation which we denote with (SE(n)) 0 . The obtained Taylor development of the group product and associated leftinvariant vector fields gives rise to a local approximation of the (sub-Riemannian) flows on SE (2) in the sense of Rothschild and Stein [50].
We then define a norm on (SE(n)) 0 based on the Folland-Kaplan-Korányi gauge, which is known for its relation Fig. 1 The red and green arrows have equal spatial and angular distance to the origin (black arrow). In a flat geometry on R 2 × S 1 the distance between the red and green arrow and the source would be equal, and the geodesics straight lines (see dashed lines). In sub-Riemannian geometry on SE(2) the green arrow has a shorter distance to the source. The left image shows 2D projections of the sub-Riemannian geodesics in solid black, and the right image shows their paths in SE(2) (Color figure online) to the fundamental solution of the sub-Laplacian on the Heisenberg group [29,33,35]. We reason that the Folland-Kaplan-Korányi provides an accurate approximation to the fundamental solution on SE(n) as well, as it provides the exact fundamental solution on the Heisenberg type approximation (SE(n)) 0 . As such, we provide an approach to approximating the heat kernel and fundamental solution of the sub-Laplacian on SE(n), as an alternative to the works [12,22,47].
The distance associated with the Folland-Kaplan-Korányi-type norm on (SE(n)) 0 is locally equivalent to the sub-Riemannian distance on SE (2), as was formally proved in full generality in the seminal work by Nagel et al. [43]. In this paper we show by qualitative and quantitative comparison that the norm on (SE(n)) 0 indeed provides a sharp local approximation of the sub-Riemannian distances on SE(n).

Perceptual Grouping
The motivation for perceptual grouping of local orientations comes from problems in medical image analysis in which the topologically correct reconstruction of vessel (and pul-monary) trees is of great importance in biomarker research and surgery planning. Knowing the correct connectivity in tree structures not only allows for local biomarker analysis (e.g., studies on bifurcation and crossing properties [37]), but also allows for higher level biomarker research via statistics on tree structures [28]. Topological knowledge of vessel trees is also essential in determining artery/vein classification problems [15,25,26]. Finally, in many medical applications involving vessel analysis, including topological tree reconstruction, distances between local orientations play a crucial role [1,16,27,39,55,57]. The approximate sub-Riemannian distance in this paper is analytic, fast and easy to implement, and as such may be a useful tool for algorithms that rely on local orientation analysis.
Sub-Riemannian models are shown to be effective in both image processing and in neuropsychological models for line perception in the primary visual cortex [3,7,12,20,27,40,45,48,51,53]. In this paper we indeed observe by quantitative validation of automatic connectivity analysis that sub-Riemannian distances are preferred over their (full) Riemannian counter parts.
The approach taken in this paper for doing connectivity analysis is based on the perceptual grouping algorithm proposed by Cohen [13]. This algorithm turns a set of key points into a graph by iteratively adding edges between nodes based on their geodesic distances while putting constraints on the number of connections per node. The input set of key points may be obtained via key point tracking algorithms [5,10,34], as is done also in this paper; see Fig. 2.
In [13] an isotropic metric was used to define the geodesic distances. Later, the perceptual grouping algorithm was adapted for use with anisotropic Riemannian metrics by Bougleux et al. [8]. In recent work [11] it was further extended for the grouping of n closed contours for an a priori n. There, a (sub-)Finsler metric on position orientation space was used, similar to the sub-Riemannian metric used in this paper. As in [8] and [11] we use the main algorithm of [13] as a backbone, but we change the metric used for perceptual Fig. 2 The pipeline for grouping vessel segments consists of 2 steps. First, key points are generated (from a single source point) using minimal path tracking with key points [5]. Second, the automatically generated key points, with estimated orientations, are grouped based on an adaption of the perceptual grouping algorithm [13] with the use of sub-Riemannian distances on SE (2). The result on the right is obtained with the nilpotent approximations of the sub-Riemannian distances in SE (2) grouping and we impose an additional constraint to avoid closed loops (which are physically not realistic in the vessel networks of interest).
With quantitative experiments we show that perceptual grouping with sub-Riemannian distances on SE(n) is preferred over the use of (full) Riemannian distances on SE(n), which is in turn preferred over grouping with distances on R n . Furthermore, the analytic approximations allow for fast perceptual grouping with competitive performance compared to data-adaptive sub-Riemannian distances computed via fast marching.

Paper Outline
In Sects. 2 and 3 we derive approximations for sub-Riemannian distances in, respectively, SE(2) and SE(3). There, for each Lie group we first provide the preliminaries, then define the sub-Riemannian distance and then describe the proposed approximations. In Sect. 4 the algorithms (perceptual grouping, fast marching and key point tracking) are described, including an overview of the different distances used in this paper. In Sect. 5 we then compare the performance of the perceptual grouping algorithm using different distances, first on R 2 and SE(2) in Sect. 5.1, and then on R 3 and SE(3) in Sect. 5.2. General conclusions are provided in Sect. 6.

Sub-Riemannian Distance and its
Approximation in SE(2)

SE(2)
In order to measure distances between local orientations we will consider the Lie group SE(2) as our base manifold. The group SE(2) = R 2 SO(2) is the semi-direct product of the group of planar translations R 2 and rotations SO(2), and its group product and inverse are, respectively, defined via: with group elements g, g ∈ SE(2). The group acts on the (coupled) space of positions and orientations R 2 S 1 via Since (x, R θ ) · (0, 0) = (x, θ), we can uniquely identify the roto-translation group SE(2) with the space of positions and orientations R 2 S 1 .

The Lie Algebra, Exponential Map and Commutators
The Lie algebra associated with SE(2) is the real vector space se(2) = span{A 1 , A 2 , A 3 } together with a bilinear operator [·, ·] : se(2) × se(2) → se(2) called the Lie bracket (which we define in Eq. (4)). The generators of the Lie algebra are given by the differential frame {∂ θ , ∂ x , ∂ y } (0,0,0) at the origin which define corresponding left-invariant vector fields via the push forward of left multiplication, denoted by (L g ) * , and with g = (x, y, θ) ∈ SE(2). The exponential map Exp : se(2) → SE(2) defines a mapping from a vector X ∈ se(2) in the tangent space at g = (0, 0, 0) to an element in the group SE(2) by following an integral curve along the left-invariant vector field (L g ) * X . The logarithmic map Log : S E(2) → se(2) defines the mapping from group element to tangent vector at g = (0, 0, 0).
The Lie bracket for vector fields is defined as follows That is, it describes the infinitesimal displacement by following a path moving forth and back in X and Y directions. The Lie bracket of two vectors defines a new vector (the commutator) and the Lie bracket of two vector fields defines a new vector field. The nonzero commutators of se (2) are

Sub-Riemannian Geometry in SE(2)
We consider a sub-Riemannian geometry on SE(2) by measuring distances between two points in SE(2) via the lengths of shortest horizontal paths. A horizontal path is a curve γ : where Δ denotes the sub-bundle of the full tangent bundle T (SE(2)) := span{A 1 , A 2 , A 3 }. Lengths of horizontal curves withγ (t) = u 1 (t) A 1 | γ (t) + u 2 (t) A 2 | γ (t) are measured by the sub-Riemannian metric in which C : SE(2) → R + is an external cost which penalizes the curves to move through certain regions in SE(2), ξ is a parameter which balances the penalty of motion in the angular and spatial directions and has dimensions [1/length], and u 1 and u 2 are the control parameters of the curve γ . The sub-Riemannian distances between two points g 1 , g 2 ∈ SE(2) is then given by where the infimum is taken over by Lipschitz continuous Note that due to the inclusion of an external cost function C the distance d is not strictly left-invariant; however, when substituting C by C g := C(g −1 h) in (7) we do have left invariance (i.e., then d(g · g 1 , g · g 2 ) = d(g 1 , g 2 )).

A Local Approximation via the Baker-Campbell-Hausdorff Formula
Consider the exponential map from Lie algebra se(2) to the group SE(2) the basis vectors of se(2) given in (2), and with (c 1 , c 2 , c 3 ) the canonical coordinates of the first kind given by For two left-invariant vector fields X = 3 i=1 x i A i and Y = 3 i=1 y i A i the Baker-Campbell-Hausdorff (BCH) formula (see, e.g., [49]) gives: by omitting the Lie brackets of order 2 (once nested brackets) and higher, as if our Lie algebra se (2) The new group product (12), where the elements are expressed in coordinates of the first kind [cf. Eq. (8)], gives rise to a nilpotent Heisenberg group. It is a local 3 approximation of the true group product (1). We denote this group by (SE(2)) 0 = H (3), with H (3) the three-dimensional (nilpotent) Heisenberg group. Note that if (x 1 , x 2 , x 3 ) and (y 1 , y 2 , y 3 ) were coordinates of the first kind for a group with a step 2 nilpotent algebra, then this new group would be globally isomorphic to that group. The new group (SE(2)) 0 defines a homogeneous Carnot group with respect to the dilations

Homogeneous Norms on (SE(2)) 0 and the Fundamental Solution of the Sub-Laplacian
In our approximation of the sub-Riemannian distance d 0 of Eq. (7) we make use of the following homogenous norm on (SE(2)) 0 : with constant ζ > 0 a relative penalty for the non-horizontal part. For ζ = 16 this norm coincides with the well-known Folland-Kaplan-Korányi gauge, which is a widely studied norm on Carnot groups due to its relation to fundamental solutions of sub-Laplacians [6]: Folland found that c 2−Q 16 , with homogeneous dimensions Q, is (a constant multiple of) the fundamental solution of the canonical sub-Laplacian on the Heisenberg group [29]; Kaplan showed that this relation more generally holds for H-type (Carnot) groups [33]; Korányi derived many more of its properties in relation to harmonic analysis and potential theory [35].
In relation to sub-Riemannian geometry on SE(2) and its sub-Laplacian L := A 2 1 + A 2 2 , we find that the fundamental solution Γ of L can be approximated by the (explicit) fundamental solution of the canonical sub-Laplacian L 0 := X 2 1 + X 2 2 , with Jacobian basis (2)) 0 . This solution in fact coincides with one of the approximations of Γ found by Duits and Franken [22]. There, the fundamental solution of L was first approximated by relying on a contraction of SE(2) to a three-dimensional Heisenberg group (via dilations on the group SE(2)) and then derived the Gaussian estimates based on the homogeneous norm · 1 , i.e., ζ = 1, with exponential coordinates derived from the contraction.
In our study on the sub-Riemannian distance approximations we found that even sharper estimates could be obtained by relying on the explicit formula for the fundamental solution of the (Kohn) sub-Laplacian on H (3) (which is up to a constant given by c −2 16 ). In this context we thus obtain an estimate of the fundamental solution of L by estimating it with c −2 16 , which is proportional to the exact fundamental solution of L 0 on our approximated group (SE(2)) 0 .

Approximation of the Sub-Riemannian Distance
Finally we arrive at the sub-Riemannian distance approximations. By the Ball-Box theorem (see, e.g., [4]) and equivalence of homogeneous norms, there exists a constant c such that with Log(g) defined by Eq. (9). The logarithmic norm is locally equivalent to the sub-Riemannian distance, which was proved in full generality in [43,Thm. 2 and 4]. Via a scaling of the generatorsÃ 2 withc 2 = ξ c 2 andc 3 = ξ c 3 , and the c i given in (9). The norm · ξ,ζ closely approximates the sub-Riemannian distance d 0 (e, ·) for C = 1 (no data adaptivity) via (16) with c the coordinates of the first kind obtained via (9). In view of the Folland-Kaplan-Korányi gauge setting ζ = 16 in · ξ,ζ would be a sensible choice. We do observe, however, that ζ = 44 gives an even sharper approximation; see Fig. 3 for a visual comparison to the sub-Riemannian distance d 0 and "Appendix A" for a quantitative comparison. The setting ζ = 44 is used in all experiments on SE(2).

Sub-Riemannian Distance and Its Approximation in SE(3)
In this section we extend the concepts of the previous section to the group SE(3) of 3D translations and rotations. In the end we again obtain an approximation for the sub-Riemannian distance, which allows us to do perceptual grouping in 3D images as well.

SE(3)
The Lie group SE(3) = R 3 SO (3) is the semi-direct product of the group of 3D translations R 3 and the group of 3D rotations SO(3). The group product and inverse for elements In the 3D case, we define the space of coupled positions and orientations as a Lie group quotient of SE (3): (2)).

The Lie Algebra, Exponential Map and Commutators
Analogously as in the SE(2) case, we associate with the group SE(3) the Lie algebra se(3) using the exponential and logarithmic maps. This is most easily done using an isomorphism with the corresponding matrix group: A basis for the corresponding matrix Lie algebra is given by and their equivalents A i in the tangent space of SE(3) span the Lie algebra se(3). Since it will be clear from the context if we are in the SE(2) or SE(3) case, we use the same notation for the generators of the Lie algebra as previously. Now the left-invariant vector fields are again obtained using the push forward of the left multiplication (L g ) * , but they depend on the choice of coordinates. In this paper we mostly rely on ZYZ Euler angles in the parameterization of SO (3), i.e., with R n,α a rotation with angle α around n. Then, the leftinvariant vector fields are given by for β = 0, π.
Remark 1 A second coordinate chart is needed to cover the entire SO (3), for which, for example, ZYX angles can be used, as is done in, e.g., [23], where also the expressions for the vector fields in this alternative coordinate chart are given. In fact, the basis elements A i of the Lie algebra correspond to partial derivatives with respect to the ZYX angles, similar to the SE(2)-case.
We can express each element se (3) we obtain a rotation using the exponential map of matrices, i.e., R = exp( ). The relation between the spatial coefficients c (1) and (x, R) is given by where q = ||c (2) || and such that R = exp( ). Now using the relations above.

Sub-Riemannian Geometry in SE(3)
In the SE(3) case, a horizontal path is a curve γ : In this case we have one spatial control u 3 and two "angular" controls u 4 and u 5 , so that the sub-Riemannian metric tensor becomes: The sub-Riemannian distance between two elements g 1 , g 2 ∈ SE(3) is still defined as in (7), but now the infimum is taken over Lipschitz continuous curves γ ∈

A Nilpotent Approximation (SE(3)) 0 of SE(3) and the Approximated Sub-Riemannian Distance
It is important to realize that the logarithmic map is only well defined on the group SE (3) and not on the quotient R 3 S 2 , i.e., different choices for α in the rotational part result in different values for the coefficients c i . Here, we choose the approach of [46] and set α = −γ such that expected symmetries are preserved. With that choice the logarithm (23) gives for each (x, n) ∈ R S 2 a unique vector c, on which we can put a norm: where c = c(g) according to (23). Also here, the Folland-Kaplan-Korányi-type norm can be used to approximate the fundamental solutions of the sub-Laplacian on SE(3). The norm ||c|| ξ,ζ with ζ = 1 was, for example, used in [23] approximations of the heat kernel and the fundamental solution on SE (3), of which only recently exact solutions were found in [47]. In the context of this paper we can approximate the exact solutions of the sub-Laplacian on SE(3) by c 2−Q 1,16 , with homogeneous dimensions Q = 9, as the exact solution of the sub-Laplacian on the approximation group (SE(3)) 0 . The group (SE(3)) 0 that locally approximates SE(3) is again obtained via a nilpotent step 2 approximation of the BCH formula and is defined by the group product with x i , y i coordinates of the first kind given by the logarithmic map (22). This new group is a free-nilpotent group of rank 3 and step 2.
We approximate the sub-Riemannian distance d 0 on SE(3) via the norm (25). That is,  Table 1 for an overview of the different distances and as such again obtain an approximation of the distance in the sense of Rothschild and Stein [50]. Based on the quantitative comparison to the sub-Riemannian distances d 0 in "Appendix A" and the visualizations in Fig. 4 of the level sets we conclude that the approximated sub-Riemannian distance of (27) quite accurately approximates the true sub-Riemannian distance on SE(3). In our analysis we found that the logarithmic norm with ζ = 100 gave the best approximation, and as such we used this norm in the perceptual grouping experiments of Sec. 5.2.

Remark 2
The glyph at each grid point y in Fig. 4 is given by the surface {y + νU (y, n)n|n ∈ S 2 }, for a specific choice ν > 0, and with density U : R 3 × S 2 → R + . The color of each orientation n = (n 1 , n 2 , n 3 ) ∈ S 2 on the glyph is defined by the RGB color (n 1 , n 2 , n 3 ).

Perceptual Grouping, Fast Marching and Key Point Tracking
In this section the algorithms used in this paper are explained. Our main application of interest is that of grouping/clustering of points on blood vessels via the perceptual grouping algorithm, which is explained in Sect. 4

The Perceptual Grouping Algorithm
The perceptual grouping algorithm presented in this paper is a modification of the original algorithm proposed by Cohen [13], and which was later adapted for perceptual grouping based on anisotropic distances [8]. In recent work [11], the perceptual grouping algorithm was extended for the grouping of n closed contours for an a priori specified n. Like in [8] and [11], we use the main algorithm of [13] as a backbone, but we change the metric used for perceptual grouping and we impose an additional constraint to avoid closed loops (which are physically not realistic in the vessel networks of interest). Our adapted perceptual grouping algorithm is given in pseudo-code in Algorithm 1.
input : S: a set of key points; d(g i , g j ): distances between g i , g j ∈ S; s max : max spatial length of geodesics; variables:D S : set of possible edges; δ i : node degree of x i ; output : D S : final set of edges;

Initialization:
Compute the distances d(g i , g j ) (and corresponding geodesics) between all key points g i , g j ∈ S.
InitializeD S with the set of all edges between each g i , g j ∈ S whose connecting geodesic has spatial arc length smaller then s max , and set D S = Ø.
Main algorithm: whileD S = Ø do 1. Select edge and remove it fromD S :

Check topology and update network:
if δ i < 2 and δ j < 2 and g i , g i are not already in the same subgraph in D S then D S = D S + (g i , g j ); δ i = δ i + 1; end Algorithm 1: Perceptual grouping.
The goal of the perceptual grouping algorithm is to construct a graph out of a set S of points of interest in which the edges D S are true connections (represented by geodesics) between points. Following the terminology of [5,10,17] we will refer to the points of interest as key points. Each key point is only linked to at most 2 other key points (i.e., node degree δ i is 2 at most). The final graph thus only contains sets of non-bifurcating vessel segments. The graph is build up by inserting one by one the edges which have the shortest geodesic distance (if the node degree allows). As such, only the strongest connections (shortest geodesics) appear in the final graph network. Since the original algorithm in [13] (and also [8]) does not include a mechanism to avoid closed loops we include an additional check in the main algorithm to prevent this. Finally, in order to avoid connecting key points which are too far apart from each other we only consider edges of which the spatial arc length of the connecting geodesic does not exceed a certain a priori threshold s max .
In summary our changes relative to the works [8,11,13] are that we -keep the choice for distance d(x i , x j ) open. In our experiments the distances d will be mainly based on sub-Riemannian geometry in SE(n). -explicitly avoid making long distance connections by filtering out such possible connections in an initialization step. -avoid closed loops by not making connections between nodes that belong to the same subgraph. -group crossing lines without pre-specifying the number of groups.
In particular, it is the use of a sub-Riemannian metric on SE(n) that allows for the grouping of crossing lines. A first (successful) feasibility study on the possibility of perceptual grouping of crossing lines was performed by Chen et al. [11] using a (sub-)Finsler metric (based on the Euler elastica model) on position orientation space. There it was successfully demonstrated on phantom images that their algorithm is able to deal with crossing closed contours; however, it required specification of the number of contours (which is not always a priori known). Furthermore, their metric relies on a notion of directionality (instead of just orientations) which is useful in grouping closed contours, but may be disadvantages for grouping non-closed contours. Here, we focus on the grouping of non-closed crossing contours without specifying the number of contours. Furthermore, we quantify the performance of perceptual grouping of crossing lines on a large set of both retinal images in 2D, and phantom images in 3D.

Fast Marching
Most of the distances (except for the fast analytic approximations) and the geodesics used in this paper are computed via the fast marching algorithm, which is an efficient numerical solver of the eikonal equation and which can be used to obtain globally optimal geodesics [14]. Let g 0 be an arbitrary source point in a domain M of interest, let G| g : T g (M) × T g (M) → R + be a metric tensor defined on the tangent space T g (M) at g ∈ M, and let its associated distance map, where the infimum is taken over the set S(g 0 , g) of Lipschitz continuous curves with γ (0) = g 0 , γ (1) = g, and withγ (t) ∈ T γ (t) (M). Then the distance map U is the unique viscosity solution of the eikonal equation with ∇ G := G −1 dU the intrinsic gradient with inverse metric G −1 and dU the differential of U , and · G the norm with respect to the metric tensor. In the standard (data-adaptive) Euclidean case with M = R 2 , g 0 = 0, The fast marching algorithm efficiently solves the eikonal equation in a one pass algorithm. It computes the values of U in increasing order [starting with U (g 0 ) = 0] based on the Bellman principle of optimality, in a manner very similar to the Dijkstra algorithm for shortest paths on graphs [18]. The minimal geodesic connecting g 0 with g is then obtained via a gradient descent on U from g back to the origin g 0 , i.e., solving the ODE For details on the fast marching algorithm on isotropic manifolds we refer to [54,56], to [32,41] for anisotropic fast marching, and to [52] and [24] for fast marching in sub-Riemannian manifolds in SE(2) and SE(3), respectively.

Generating Key Points
The key point method is based on keeping track of a spatial arc length map U l (in which the spatial lengths of the minimizing geodesics γ defining U are stored) and stops as soon as a certain distance threshold is passed [17]. The rationale behind this algorithm is that among all points with equal geodesic distance values U , the points reached by geodesics γ that best follow the data (paths along which C is low) have maximum spatial distance l(γ ). Such a point maximizing spatial distance in a given level set in U is called a key point. The fast marching algorithm is highly suited for keeping track of a spatial arc length map U l , in addition to U , due to the local updating approach (wavefront propagation). Moreover, the algorithm can stop early if one is only interested in finding the first key point with length larger than l max [17].
In summary a key point is detected as follows. The spatial arc length map is defined as with γ g 0 ,g = argmin γ ∈S(g 0 ,g) 1 0

G| γ (t) (γ (t),γ (t))dt the mini-
mizing geodesic in (28), and with the spatial arc length of γ , withẋ(t) = P R nγ (t) ∈ R n the spatial components of the tangentsγ (t). 4 The fast marching algorithm stops as soon as there is a g for which U l (g) ≥ l max , and g will be called a key point.
With the above criteria one can iteratively detect new key points based on geodesic distances to previously found key points, a method known as minimal path tracking with key point detection [5]. One can make several choice on when to stop the key point tracking algorithm [5,10,34]. In this work we rely on the approach by Chen et al. [10], where we only add key points on locations which lie in a masked region (we use a binary vessel centerline mask m : M → {0, 1}), i.e., we only add a key point when both U l (g) ≥ l max and m(g) = 1. The algorithm is stopped as soon U l (g) ≥ 3 l max . Table 1 gives an overview of the different distances discussed in this paper and used in the experiments. The isotropic Euclidean metrics are used the generate key points in R 2 and R 3 using the algorithm of Subsec. 4.3. The isotropic Euclidean distances are also used in comparison to the other distances on SE(n) in the perceptual grouping experiments. The sub-Riemannian distances on SE(2) and SE(3) are explained, respectively, in Sects. 2.2 and 3.2. In the Riemannian distances the full tangent bundle on SE(n) is considered. This means that now also non-horizontal curves in SE(n) are considered, i.e., points on the curves γ are allowed to move sideways by the non-horizontal controls u 3 (t) in the SE(n) case, and u 1 (t), u 2 (t) in the SE(3) case. Recall that in this case the blue and red oriented particles in Fig. 1

The Cost C
The cost functions C are constructed from functions U f : R n × S n−1 → R on the orientation-lifted space. These func-  tions U f are obtained via an orientation score transform [21,31] of image f : R n → R by correlating the image with a set of anisotropic wavelets ψ : R n → R: with ( f , g) L 2 (R n ) = R n f (x)g(x)dx the standard inner product on L 2 (R n ), with the overline denoting complex conjugation, and where U g denotes the left regular representation of the Lie group on images f . For the group SE(2) acting on images f ∈ L 2 (R 2 ) it is defined as (2) (3) acting on images f ∈ L 2 (R 3 ) it is defined as The wavelets used in the orientation score transform [21,31] are designed in such a way that all rotated version together cover the full Fourier spectrum. With this design no data are lost in the transformation and a stable invertible transform (from orientation score) back to image exists. For details on this wavelet-type transform for lifting 2D images to functions on SE(2) we refer to [21], and for lifting 3D images to 3D orientation scores we refer to [31]. In all experiments we define the cost in the following form with V a vessel (or centerline) enhancement obtained by processing of the orientation score U f , and which is normalized between 0 and 1. Parameters λ and p then control, respectively, the influence of the cost (data adaptivity) and p the contrast. Good choices for V for tracking of vessels in 2D position orientation space may be via the vessel enhancements of [58] or [30], similar to the SE(2) tracking experiments in [3]. For tracking in 3D orientation scores V may be obtained via the crossing preserving vessel enhancements of [19]. In related tracking problems in lifted spaces the lifts are obtained via tubularity measures [11,36,38], or by correlating the image with a set of rotated templates [44].

Projective Line Bundle
Finally, we remark that when dealing with geodesic distances in SE(n) we have to take into account that these are defined for positions and orientations on the full sphere S n−1 . The distances discussed in this paper thus make a distinc- 99.75% (9) 99.83% (6) 99.72% (10) tion between forward and backward arrival directions, i.e., d(e, (x, θ)) = d (e, (x, θ + π)). In practice, and in particular in our perceptual grouping problem, we often do not know the direction of the vessel, but we only have orientations. As such, we would actually want to compute distances on the projective line bundle R n ×P n−1 , with P n−1 := S n−1 / ∼ with identification of antipodal points n 1 ∼ n 2 ↔ n 1 = ±n 2 . We define the distancesd on the projective line bundle by distances d on SE(n) viã d (g, (x, n) with n ∈ S n−1 , and g, (x, ±n) ∈ SE(n). Note that in the SE(2) case we have with n(θ ) = (cos θ, sin θ) ↔ θ and −n(θ ) = n(θ + π). For a more detailed analysis on dataadaptive sub-Riemannian geodesics on the 2D projective line bundle we refer [2].

Experiments
In the experiments we aim to quantify the performance of perceptual grouping with different distances. For a fair comparison we therefore generate automatically the most reasonable key points by using a vessel centerline mask m : R n → [0, 1] (see Sect. 4.3) based on the ground-truth data. Moreover, this guarantees that the key points are always located on the ground-truth centerlines, which allows us to quantify performance using the ground-truth data. In both the 2D and 3D case the key points are then generated using the isotropic Euclidean metric tensor, and with V(x) = m(x) (see Sect. 4.4.1). In all experiments we set p = 1, λ = 100 to compute the cost [cf. Eq. (33)].
In the perceptual grouping experiments the cost functions are constructed from orientation score transforms U f of the mask m on R n . The costs on SE(n) are then constructed via the modulus of the score: For equal comparison the costs on R n are then constructed via V (x) = max x, n), i.e., via a maximum intensity projection over orientations n.

Experimental Setup
The data for the 2D retinal vessel grouping experiments consist of 52 retinal image patches in which the vessels have complicated topologies (each patch contains at least 1 crossing, and at least 1 bifurcation). For each retina patch the centerlines were semiautomatically traced, after which the connectivity (bifurcation relations) between the vessel segments were manually determined. The set of images contained in total 313 separate vessel segments. A connection between two nodes was determined to be a true positive if both nodes lie on the same vessel tree. The minimum distance between key points in the retina experiments (with patch sizes of ≈ 400 × 400 pixels) was set to l max = 30 pixels. The maximum geodesic arc length distance in the perceptual grouping algorithm was set to s max = 80 pixels. The orientations θ at each key point x was estimated by the orientation that gave maximum response in the orientation score, i.e., θ = argmax x, θ). The circle S 1 was sampled with N θ = 32. All distances were computing via the fast marching algorithm of [41,42] except for the sub-Riemannian approximations, which were computed directly using (9) and (15). The position orientation balancing parameter was set to ξ = 0.01. Table 2 gives a quantitative overview of the results, and Figs. 5 and 6 show the results on two of the 52 retina patches. From Table 2 we make the following observations and conclusions:

Results
1. Perceptual grouping is preferred in the lifted domain SE(2) instead of in the based domain R 2 . This suggest that taking orientation into account in the grouping is essential. 2. A sub-Riemannian geometry on SE(2) is preferred over a (ξ -isotropic) Riemannian geometry. This suggests that a sub-Riemannian geometry is necessary to deal with the complex geometry at crossings and parallel tracks (cf. Figs. 5 and 6). 3. The results obtained with the sub-Riemannian distances on SE(2) for C = 1 are almost equal. This suggests that the approximations are quite accurate, and that for C = 1 the analytic approximations may be preferred due to speed and algorithm complexity considerations. 4. Overall, results for C = 1 are better than for C = 1. Note, however, that the sub-Riemannian distances on SE(2) for C = 1 are still better then the Euclidean distance on R 2 and Riemannian distance on SE(2) for C = 1, and only slightly under performs relative to the sub-Riemannian C = 1 case. This again shows that sub-Riemannian geometry is preferred, whether data are included in the metric tensors or not.
We conclude that in perceptual grouping of 2D vessels a sub-Riemannian geometry in SE(2) is preferred over a Euclidean geometry in R 2 , or a Riemannian geometry in SE (2). When accurate vesselness maps are available, it is preferable to use these in the distances. Furthermore, if one aims to design a easy to implement and efficient perceptual grouping pipeline, approximate sub-Riemannian distances should be used. With only a 2D key point tracking algorithm, a method for estimating orientations and the analytic approximate distances (15) one obtains very accurate grouping results.

Experimental Setup
To quantify and study the influence of different distances in perceptual grouping algorithms for 3D vessels we make use of synthetic 3D images. For these experiments 10 volumes were generated, each with 6 random paths. Each path was generated with a Monte Carlo simulation of a random walk in SE(3) (see, e.g., [59,Ch. 3.5]). Due to the random con-   struction it might occur that 2 paths cross each other. This is physiologically unrealistic (vessels in 3D might bifurcate or touch, but never grow through each other), but it does make the experiments more challenging. For each volume a binary centerline mask was constructed using the generated ground-truth paths. The volumes were of size 51×51×51 voxels. The distance between key points was set to l max = 5 voxels. The maximum geodesic arc length distance in the perceptual grouping algorithm was set to s max = 15 voxels. The orientation at each key point was again estimated as the orientation that gave maximum response in V SE(n) [Eq. (35)]. The sphere S 2 was sampled with 200 orientations using Euler angles with n(β, γ ) = R γ,β,α .e z , with . . , 2π − π N β }, with N β = 10, and with R γ,β,α given by (19). In the lifted metric tensor we set ξ = 1. Table 3 gives a quantitative overview of the results, and Fig. 7 shows the results on one of the ten synthetic volumes. From Table 3 we can draw the same conclusions as for the SE(2) case (using a sub-Riemannian geometry and including data adaptivity improves results). Here, however, we make two additional observations 1. Data-adaptive fast marching seems less sensitive to the choice of metric, but tracking in the lifted domain SE(3) still improves results. This can be explained by the fact that the volume is relatively sparse, and by the fact that the cost function C is constructed from ground-truth data (the best possible cost). If the cost function dominates the metric, then the intrinsic energy/geometry has a smaller influence. 2. Out of all C = 1 distances (no data adaptivity) the grouping via the nilpotent distance approximations on SE (3) give best performance, even better then for the true sub-Riemannian distance. This can be explained by the fact that for long distances from the origin, the approximation gradually looses their sub-Riemannian nature and allows more non-horizontal behavior, as in the Riemannian case. It could be that, due to the discrete sampling of the sphere, not all orientations are accurately estimated. The grouping based on the sub-Riemannian distance approximations seems less sensitive to such errors.

Conclusion
In this paper we have proposed an efficient approach for perceptual grouping of local orientations via nilpotent approximations of sub-Riemannian distances in the roto-translation group SE(n). The quantitative experiments on grouping of retinal blood vessels in 2D images, and perceptual grouping in challenging 3D synthetic volumes, showed that (1) sub-Riemannian geometry is essential in achieving top performance and (2) that the grouping approach via the fast analytic approximations performs almost equally, or better, than the data-adaptive fast marching approaches. The sub-Riemannian distances on SE(2) and SE(3) were approximated via norms on exponential coordinates of the first kind (obtained via the logarithmic map). In both quantitative and visual comparison it was found that the approximations accurately follow the true sub-Riemannian distances, a conclusion which was further supported by the equal performance in quantitative perceptual grouping experiments. We also numerically showed that the weighted logarithmic norms used in this paper provide a more accurate approach for approximating the heat kernel and fundamental solution of the sub-Laplacian on SE(n), compared to previous approaches [12,22,47].
Since the sub-Riemannian distance approximations are analytic, they are easy to implement and fast to compute. An interesting line of further research would be to embed the sub-Riemannian distances in other algorithms that rely on the quantification of the distance between local orientations. The results of this paper could be further improved by augmenting the sub-Riemannian distances with additional features (like cross-sectional profile descriptors) and use a global graph optimization approach as in [26,57]. The potential of using sub-Riemannian distances in such problems is demonstrated by the experiments of this paper. their influence on the manuscript: Remco Duits at Eindhoven University of Technology for suggestions on logarithmic approximations of the heat kernel and the fundamental solution on SE(2), SE(3) and the Heisenberg group; Laurent Cohen at University Paris Dauphine for fruitful discussions on geodesic methods and perceptual grouping; Jean-Marie Mirebeau at Laboratoire de mathématiques dOrsay, Université Paris-Saclay, for providing efficient and generic fast marching code.

A Optimization of the Folland-Kaplan-Korányi Gauge Parameter ζ
In Figs. 3 and 4 we visually compared the nilpotent approximations of the sub-Riemannian distance on SE(2) and SE(3), respectively. In this appendix we support by means of a quantitative comparison our choices for ζ = 44 and ζ = 100 which appear in the logarithmic approximations (Folland-Kaplan-Korányi gauge) of | Log(g −1 h)| ξ,ζ as defined in (16) and (27) on, respectively, SE(2) and SE(3).

A.1 Optimization of ζ for the SE(2) Approximations
In the quantitative comparison on SE(2) we computed the L 2 error between d 0 (g, h) and the approximation | Log(g −1 h)| ξ,ζ with ξ = 1 on a grid with a varying spatial domain size (from x, y ∈ [−0.5, 0.5] to x, y ∈ [−4, 4]), and with varying choices of ζ . The results are shown in Fig. 8 and are computed as follows.
The reference sub-Riemannian distance d 0 on SE(2) was computed once via an anisotropic fast marching algorithm [41,42] on a grid which sampled x, y ∈ [−4, 4] at a sub-pixel resolution of 0.01 with 128 orientations. The numerically computed sub-Riemannian distance volume was thus of dimensions 801 × 801 × 128.
In each experiment (with fixed spatial range and ζ ) the squared error between d 0 and its approximation was sampled on a regular grid that covered the specified domain with 41 × 41 × 128 points. The averaged errors are plotted in Fig. 8.
Here we see that the approximation becomes more accurate toward the origin (x, y ∈ [−0.5, 0.5]) and that parameter ζ has to be chosen larger in order to keep the anisotropy for longer distances from the origin. The choice ζ = 44 generally gave the best approximations and we rely on this setting in the experiments on SE(2).

A.2 Optimization of ζ for the SE(3) Approximations
In the quantitative comparison on SE(3) we computed the L 2 error between d 0 (g, h) and the approximation | Log(g −1 h)| ξ,ζ with ξ = 1 on a grid with a varying spatial domain size (from x, y, z ∈ [−0.5, 0.5] to x, y, z ∈ [−4, 4]), and with varying choices of ζ . The results are shown in Fig. 9 and are computed as follows.
In each experiment (with fixed spatial range and ζ ) the squared error between d 0 and its approximation was sampled on a regular grid that covered the specified domain with 21 × 21 × 21 × 31 × 62 points. The averaged errors are plotted in Fig. 9.
Here we see that the approximation becomes more accurate toward the origin (x, y, z ∈ [−0.5, 0.5]). However, compared to the SE(2) experiments we do see a less stable localization of the optimal parameter ζ with varying spatial resolutions. This behavior can be explaind by (1) the sub-Riemannian distances are numerically computed via a fast marching algorithm using Euler angles (which do not uniformly sample the sphere) and (2) the spatial resolution of the computed reference sub-Riemannian distance volume was only 0.1 (due to computer memory constraints). Although very accurate from an application point of view, the sub-Riemannian distances on SE(3) are not exact, and the numerical errors induced by the algorithm may explain the variation in optimal ζ (in particular for the region close to the origin). Overall, the choice ζ = 100 seems to be reasonable in all ranges, and this was confirmed by visual comparison of the distance maps in Fig. 4.