Digital Geometry: Volumetric Analysis§

author:David Coeurjolly

Distance Transformation/Voronoi Map§

Problem setting§

Distance transformation

Def.

At each point p of a shape X, we want the smallest distance to q\in\bar{X}

_images/homme.png _images/homme_edt_eq.png _images/homme_circ.png

\Rightarrow We need

Why the DT ?§

Very usefull

…for many applications

_images/spheretree-single.png _images/contour.png _images/contour_circ.png

Example: curvature from DT§

Idea

Shape \rightarrow Boundary \rightarrow Distance field \rightarrow Implicit representation f: (x,y)\rightarrow \mathbb{R}

f(x,y)&=0\\
\vec{g}(x,y)&=(I_x,I_y)^T\\
\vec{t}(x,y)&=\frac{(-I_x,I_y)^T}{\sqrt{I_x^2+I_y^2}}\\
k&=\frac{-t^THt}{\|\vec{g}\|}, \quad H=
\left [ \begin{array}{cc}
  I_{xx} & I_{xy}\\
  I_{yx} & I_{yy}
\end{array}\right ]

Application example 1: Snow Micro-structure Analysis§

Objectives

_images/echantillonSurface.png _images/M2DISCO8.png _images/Courb08iso_600_300_256p2_000.png

Application example 2: Metallic Foam Description§

Objectives

_images/mousse_surface.png _images/mousse_DT.png

Metric in Digital Space§

Def.

Metric (d,E,F) is a map d: E\times E \rightarrow F such that

  • \forall p,q\in E\,, d(p,q)\geq 0 (separation axiom)
  • \forall p,q\in E\,, d(p,q) =0 \Rightarrow p=q (coincidence axiom)
  • \forall p,q\in E\,, d(p,q) = d(q,p) (symmetry)
  • \forall p,q,r\in E\,, d(p,q) \leq d(p,r) + d(r,q) (triangular inequality)

Def.

(d,E,F) is a norm (metric induced by “normed” vector space) iff

  • \forall p,q,r\in E\,, d(p,q) = d(p+r,q+r)\geq 0 (translation invariant)
  • \forall p,q,\lambda\in E\,, d(\lambda p, \lambda q) = |\lambda|d(p,q)\geq 0 (homogeneity)

Examples§

E.g.

l_p metrics Illustration§

_images/metrics.png

Discrete Metrics§

Definition

Hence

Hints for last two results use p(2,3)\, q(-1,-1)\, r(0,0) and p(1,1)\, q(-1,-1)\, r(0,0)

Chamfer Mask§

Weigthed vector

M = (\vec{v},\omega)

Chamfer Mask

Set of weighted vector

\mathcal{M} = \{ M_i\in \mathbb{Z}^n\times \mathbb{N}^*\}_{1\leq i \leq m}

Usually, chamfer masks are G-symmetric, i.e. restricted to

\mathcal{M} = \{ M_i\in \mathcal{G}\times \mathbb{N}^*\}_{1\leq i \leq m}

with

\mathcal{G} = \{ (x_1,\ldots,x_n)\in\mathbb{Z}^n\,|\, x_n\geq \ldots \geq x_1\geq 0 \}

Chamfer Distances§

Chamfer path

k-Path based on vectors from a chamfer mask

\mathcal{P} =\{ \alpha_1\vec{v}_{i_1}, \ldots, \alpha_k \vec{v}_{i_k} \}

Length of a chamfer path

d_\mathcal{M}(\mathcal{P}) = \sum_k \alpha_k\omega_{i_k}

Chamfer distance

Minimal length of chamfer path between p and q

All chamfer distances induced distances, not necessarily norm

Simple examples§

Path based distance

_images/chamferVect.png

Matrix representation for masks

\mathcal{M}_{ab}=\{ (a,(0,1)^T) , (b,(1,1)^T) \}, \mathcal{M}_{abc}=\{ (a,(0,1)^T) , (b,(1,1)^T), (c,(2,1)^T)\}

_images/chamfer2.png

For example:

\mathcal{M}_{3,4} = \{ (3,(0,1)^T), (4,(1,1)^T) \}

(distances must be divided by 3 at the end)

Chamfer balls§

_images/cha2d-9boules.png

\Rightarrow We need constraints on \{\omega_i\} to induce norms

e.g.

0 < a \leq b \leq 2a

0 < 2a \leq c \leq a+b\quad\text{and}\quad 3b\leq 2c

Mask Construction§

We construct the mask to approximate the Euclidean Metric

Drawbacks

Distance Transformation algorithm with Chamfer Masks§

Propagation using Dijkstra’s algorithm

\Rightarrow Computation cost in O(mn\log n) for n grid points and |\mathcal{M}|=m

_images/chamferGraphDom.png _images/chamferMask.png _images/chamferGraph.png

Raster Scan Algorithm§

Split the mask into two sub-masks and perform forward/backward scans with “min” operations.

_images/chanfDT.png
Init

DT(p) = 0 \quad \text{if} \quad p\not\in X\\
DT(p) = +\infty \quad \text{if} \quad p\in X

Then

DT(p) = min( DT(p), min_{(\omega_i,\vec{v}_i) \text{ in sub-mask}} ( DT(p+\vec{v}_i) + \omega_i ))

\Rightarrow Computational cost in O(nm)

Other path-based distances§

Neighborhood sequence

Example

“Octogonal” distance with infinite sequence \{ d_1, d_\infty, d_1,\ldots, \}

Sometimes, explicit forms exist

d_{oct}(p,q)=\max \left \{ \left \lfloor\frac{2}{3} d_1(p,q) + 1\right\rfloor, d_\infty(p,q)  \right\}

Euclidean metric§

Idea

Still consider (d,\mathbb{Z}^n, \mathbb{R}) distances but with integer based representations and algorithmic

E.g.

Nice but are there fast algorithms for such exact metrics ?

Separable Approach For Squared Euclidean Distance Transform§

We want to compute (for all p\in X)

DT_2(p) = \min_{q\in\bar{X}} \{ d_2(p,q)\} =\sqrt{ \min_{q\in\bar{X}} \{ (p_1 - q_1)^2 + (p_2 - q_2)^2\}}

DT_2(p) = \sqrt { \min_{q\in\bar{X}} SEDT(p) }

Separable approach with intermediate map

g( i,j) =  \min_{x} \{ (x-i)^2\}

SEDT( p(i,j) ) =  \min_{y} \{  (y-j)^2 + g(i,y)\}

in dimension 3, we would have

g(i,j,k) = \min_x \{(x-i)^2 \},   h(i,j,k) = \min_y \{(y-j)^2 + g(i,y,k) \}\\
SEDT( p(i,j,k) ) =  \min_{z} \{  (z-k)^2 + h(i,j,z)\}

First Step§

Simple two-scan propagation

_images/saitoX.png

\Rightarrow O(N^2) in 2D for NxN image

\Rightarrow O(N^d) in d-D for N^d image

Second Step§

g( i,j) =  \min_{x} \{ (x-i)^2\} and SEDT( p(i,j) ) =  \min_{y} \{  (y-j)^2 + g(i,y)\}

_images/edt_saito.png

Key-point Lower envelope computation of a set of parabolas

Lower Envelope Computation§

Consider the set of parabolas \{  (x-k)^2 + g_k \}_{k=1\ldots N}

_images/edt_para.png

\Rightarrow Lower envelope computation in O(N) using stack based approach ;)

Overall SEDT Algorithm§

Given a N^d image

Algorithm

\Rightarrow\quad O(d\cdot N^d) algorithm for error free Euclidean metric DT

_images/neigeDT_508_p.png _images/AlCaponeDistanceMap.png

Generalizations§

Thanks to separability

Optimal multi-thread implementation

_images/edt_multithread.png

Generalization to toric domains

_images/edt_tore.png

Useful to characterize periodic structures in arbitrary dimensions

Generalization to other metrics§

Principle

Def.

We consider p(x,y), q(x',y') with x<x'

r( x'',O) be a point on the x-axis such that d(p,r) = d(q,r)

Let s(u,0) be another point on the x-axis A metric d is monotonic if

u < x'' \implies d(p,s) \leq d(q,s)

u > x'' \implies d(p,s) \geq d(q,s)

Result

\Rightarrow Let’s use the separable approach for other metrics !

Voronoi Diagram§

Definition

Given a set of sites S=\{ s_i\in \mathbb{R}^d\}, the Voronoi Diagram is a decomposition of the space into closed cells {c_i} such that

Voro_{S}(s_i) = \{ x\in\mathbb{R}^d,\, d(x,s_i) \leq d(x,s_j),\, \forall s_j\in S\}

Each cell can be further decomposed into sub-dimensional i-facets taking into account cases where d(x,s_i)= d(x,s_j)

_images/voronoi_diagramme.png

Voronoi Diagram \equiv Distance Transformation

DT(p)  = d(p,q)\, \text{ with } q\in\bar{X}\text{ such that }p\in Voro_{\bar{X}}(q)

\Rightarrow Getting the distance value is equivalent to localizing a point in a Voronoi diagram

Separable Voronoi Map§

Input set: X\subset\mathbb{Z}^2, we construct Voro_{\bar{X}}\cap\mathbb{Z}^2

_images/Voromap-random-orig.svg

Separable Voronoi Map§

_images/Voromap-random-diag.svg _images/Voromap-random.svg _images/Voromap-random-hue.svg
_images/Voromap-random-diag-complete.svg _images/Voromap-random-complete.svg _images/Voromap-random-hue-complete.svg

Generic Algorithm§

Main Result

For any monotonic metric and an image [1\ldots n]^d\rightarrow \{0,1\}, the Voronoi Map (and the distance transformation) can be obtained by the separable algorithm in O( d\cdot n^d\cdot (C + H) ) _images/closest.png _images/hiddenBy.png
Metric C H Total
l_2 O(1) O(1) \Theta(d\cdot n^d)
l_1 O(1) O(1) \Theta(d\cdot n^d)
l_\infty O(1) O(1) \Theta(d\cdot n^d)
Exact l_p O(log(p)) O(log(p).log(n)) O(d\cdot n^d\log(p)\cdot\log(n))
Chamfer Norms O(log(m)) O(log^2(m)) O(d\cdot n^d\cdot\log^2(m))
Neigh. Seq. Norms O(1) O(\log(n)) O(d\cdot n^d\cdot\log(n))

Examples§

_images/Voromap-huesimple.svg _images/Voromap-hue-l6-simple.svg
l_2 l_6

Path based Metrics§

Better expected bounds for path based norms

Metric C H Total
Chamfer with adapter O(m) O(m\cdot log(m)) O(d\cdot m\cdot n^d\cdot\log(n))
Chamfer Norms O(\log(m)) O(\log^2(m)) O(d\cdot n^d\cdot\log^2(m))

Similar expected results for neighborhood sequences

Examples§

_images/Voromap-huesimple.svg _images/Voromap-hue-l6-simple.svg
l_2 l_6

Subquadratic Algorithm for path based distances§

Path Based Metric and Rational balls§

Notations

\mathcal{M}_{7,8,11,14}

Distance Evaluation§

[Normand et al.]

d(O,p) = \max_i \{ \mathcal{F}_i\cdot \vec{Op}\}

\Rightarrow O(m)

Can be generalized to other path based distances to get similar expression

d(O,p) = \max_i \{ f_i(\mathcal{F}_i\cdot \vec{Op}) \}

for some function f_i (based Lambek-Moser inverse sequences)

_images/seqDT.png

Optimized Distance Evaluation§

Computational Geometry setting

Fast Distance computation

Separable Predicates for Chamfer Masks§

Goal

Main Result

h = O(\log^2m)

==> First sub-quadratic DT algorithm for Chamfer metrics

Dimension 2§

Key point

Warm up: Localizing a point§

Question Find the cone at p containing a point r

==> Dichotomic/Binary search (thanks to convexity of the metric)

==> O(\log m)

_images/searchPoint.png

Algorithm Overview§

Idea

If we have localized the Voronoi edge point, we are done (find the exact position given by linear system with one unknown)

_images/algoEnd.png

Step 1: Shrinking \mathcal{M}_p§

ShrinkMp( Mp, Mq )

   if |Mp| == 1
     return the cone in Mp
   else
     Split cones Mp -> { Mp, cone, M-} with |M+|~|M-|
     {v1,v2} = cone
     dp1 = distance d_M(p, v1 intersection l)   //O(1)
     dp2 = distance d_M(p, v1 intersection l)   //O(1)
     dq1 = localize and get the distance of d_M(q, v1 intersection l) //O(log(m))
     dq2 = localize and get the distance of d_M(q, v2 intersection l) //O(log(m))

     c1  = closest point between p and q at v1
     c2  = closest point between p and q at v2

     if (c1 == c2 == GREEN)
      return ShrinkMp(M+)

     if (c1 == c2 == BLUE)
      return ShrinkMp(M-)

      return cone

Correctness

Step 2: Shrinking \mathcal{M}_q and final computation§

Shrinking \mathcal{M}_q

Final step

Fast computations in higher dimensions§

Basic Idea for \mathcal{M} in \mathbb{R}^d

Conclusion

Reverse Distance Transformation§

Reverse Transformation§

Problem setting

Def.

Given a metric (d,E,G) and a set of balls \mathcal{B}=\{ B_i=(p_i,r_i)\in E\times G\}_{i=1\ldots N}, reconstruct the binary shape X

X = \bigcup_{i=1\ldots N} B_i

Why?

Bruteforce approach

For n\times m image

O(Nnm)

Separable Approach for l_2§

W.l.o.g. we consider d=2

Let us denote p_k=(x_k,y_k) for k=1\ldots N, then

X = \left \{ (i,j)\,|\, \exists k\in[1,N] \, (i - x_k)^2 + (j-y_k)^2 \leq r_k^2\right \}

Which can be rewritten

X =\left \{ (i,j)\,|\, \max_{k=1\ldots N}\{ r_k^2 -(i - x_k)^2 - (j-y_k)^2\} >0\right \}

\Rightarrow Separable decomposition

Start from a map f: \mathbb{Z}^2\rightarrow \mathbb{Z} with f(x,y) = r_k^2 if ((x,y),r_k)\in\mathcal{B} (f(x,y) = 0 otherwise)

g(i,j) =  \max_{x} \{ f(x,j) - (x-i)^2\}

REDT(i,j) =  \max_{y} \{g(i,y) -  (y-j)^2 \}

Illustration§

Similar algorithm

_images/redt-example.png _images/redt_para.png

\Rightarrow O(d\cdot n^d) separable algorithm for REDT

Associated Structure from Computational Geometry§

Voronoi map –> Power map

Def.

Given a set of weighted sites S=\{ (s_i,w_i)\in \mathbb{R}^d\times\mathbb{R}\}, the Power Diagram is a decomposition of the space into closed cells {c_i} such that

Power_{S}((s_i,w_i)) = \{ x\in\mathbb{R}^d,\, \pi(x,(s_i,w_i)) \leq \pi(x,(s_j,w_j)),\, \forall (s_j,w_j)\in S\}

Each cell can be further decomposed into sub-dimensional i-facets taking into account cases where d(x,s_i)= d(x,s_j)

_images/Power_diagram.png _images/Radical_axis_intersecting_circles.png

Power Map§

Idea

Results

Medial Axis Extraction§

Problem Description§

Alternative Definitions

_images/grass.png _images/am-cercles.png

Contact Points based Geometrical Definition§

Voronoi Based Approximation

Shape \Rightarrow Point set approximation \Rightarrow Voronoi Diagram \Rightarrow Medial Axis approximation _images/approxma.png

Convergence results exists for various classes of Voronoi based medial axis

Maximal Ball based Definition§

Def.

A maximal ball is a ball contained in the shape not entirely covered by another ball contained in the shape

Def.

The medial axis of a shape is the set of maximal ball centers contained in the shape.

Digital Setting

Reversible Encoding of X

X = \bigcup_{B_i\in MA(X)} B_i

DT and Digital Medial Axis§

DT as preliminary step

Given p\in X and r\in\mathbb{R} such that Euclidean ball with B(p,r)\cap X\in X, we have

B(p,r) \subseteq B(p, DT(p))

(defined for l_2 but trivial generalizations to other metrics)

_images/2spheres_edt_surf.png _images/carre_edt_surf.png _images/homme_edt_surf.png

\Rightarrow Set of candidate balls O(|X|)

Digital Ball vs. Euclidean Balls§

Covering Test

Let us consider a IsCoveredBy(B,B’) a predicate returning true if B\subseteq B'

but

B\subset B' \not\Leftarrow (B\cap\mathbb{Z}^2)\subset (B'\cap\mathbb{Z}^2)

\Rightarrow Bruteforce Digital Medial Axis Extraction O(|X|^2r^2_{max}) (with r_{max} the maximal DT value)

Implementing IsCoveredBy()§

Goal

Design a IsCoveredBy() predicate with cost as a function of m

Elementary Chamfer Masks \mathcal{M}\in\{d_1, d_\infty\}

(p,DT(p)) \in MA \Leftrightarrow DT(p+\vec{v}) < DT(p) + \omega,\, \forall (\vec{v},\omega)\in\mathcal{M}

Also true for \mathcal{M}_{3,4} with the following rewriting rules of the DT map:

Other path-based distances: Look-up table approach

\mathcal{V} is the neighborhood test.

Bottlenecks Efficient computation of Lut, bounds on |\mathcal{V}|, bounds on |Lut|, …

Global approach using Power Map§

Idea

Get the Medial Axis as a by-product of the Power map

Lemma

Let S\subset \mathbb{R}^d\times\mathbb{R} and X=\bigcup_{B_i\in S} B_i

B\subset B' \implies    Power_{S}(B) \cap X = \emptyset

Non-empty power map cells are related to maximal balls

[Skipping details…]

\implies Separable algorithm to extract the medial axis

\implies O( d\cdot n^d\cdot (C + H) ) computational cost for a large class of metrics

One algorithm to rule them all§

_images/Al-orig.png _images/Al-DT.png _images/Al-RDMA.png
_images/neige_254.png _images/neige_254_DT.png _images/neige_254_RDMA.png

Toward Minimal Medial Axis§

Question

Is the set of maximal balls a minimal representation of X as union of balls ?

Answer No

Toward minimal MA

Thm.

If we allow k-ary predicates IsCoveredBy(B, S_k) with |S_k|=k the minimal medial axis problem becomes NP-complete

Heuristics§

_images/amOptHeuristics.png

Topological Skeleton§

Introduction§

Digital Medial Axis is defined as a set of balls without any topological information

We are thus looking for

\Rightarrow Iterative thinning via Simple Point Removal

Simple Point§

Def.

A point p\in X is simple for X if X and X\setminus\{p\} are in the same homotopy equivalence class

Topological Transformations§

From Simple Point Definition

Let \phi by any sequence of insertions/removals of simple points, then X and \phi(X) are in the same homotopy equivalence class

_images/mug-torus.png

How to characterize simple points ?

\alpha-simple points§

Definition

Def.

A point p\in X is (\kappa,\lambda)-simple for X if

  • X and X\setminus\{p\} have the same number of \kappa-components
  • \overline{X} and \overline{X\setminus\{p\}} have the same number of \lambda-components

Example

_images/pointsimple.png

(which are resp. (0,1)- and (1,0)-simple ?)

Local characterization§

Main Results

Thm.

In dimension 2 and 3, (\kappa,\lambda)-simplicity of p\in
X can be decided locally at p

(3\times 3 neighborhood in 2D, 3\times 3\times 3)

E.g. 2D

In dimension 3, T_\kappa(p,X) definition is a bit more complex but still local

Illustration§

All configurations in 2D

_images/table8_4.png _images/table4_8.png
(0,1) (1,0)

Homotopic thinning§

Idea

Iterate until stability over sequential simple points removal \Rightarrow ultimate homotopic thinning

_images/chrom_simples.png _images/chrom_sk1.png
_images/chrom_sk2.png _images/chrom_sk3.png

In Dimension 3§

_images/a_skel_ult.png

Algorithm§

P = { p in X | p is simple for X }
while ( P != empty )
   Q = emptyset
   for all points p in P
     if (p is simple for X)
       X = X \ {p}
       for all q in N(p)
          Q = Q + {q}

   P = emptyset
   for all points p in Q
     if (p is simple for X)
       P = P+ {p}
_images/chrom_ambi.png

Homotopic thinning with anchor points§

Idea

Based on an Oracle, we decide to block some simple points during the thinning

Generic algorithm

Breadth first thinning if P is implemented as a queue

P = { p in X | p is simple for X }
while ( P != empty )
   Q = emptyset
   for all points p in P
     if (p is simple for X) and (p is not anchor point)
       X = X \ {p}
       for all q in N(p)
          Q = Q + {q}

   P = emptyset
   for all points p in Q
     if (p is simple for X)
       P = P+ {p}

E.g.

p is anchor point if it has only one neighbor in X

Illustration§

_images/a_skel_cur.png _images/a_skel_end.png

Curve or Surface based Skeleton§

Idea

Anchor points can be specified to generate surface based skeleton

_images/torus_skelsur2.png _images/torus_skelsur3.png

Misc.§

Guided Thinning

Instead of using a queue for P, we consider a priority list with distance transformation values

\Rightarrow Better geometry (central axis) of the skeleton

Parallel thinning

\Rightarrow usually, parallel thinning algorithms are more efficient and provide centered skeletons

Active works