1 numerical geometry of non-rigid shapes shortest path problems shortest path problems alexander...
Post on 22-Dec-2015
231 views
TRANSCRIPT
1Numerical geometry of non-rigid shapes Shortest Path Problems
Shortest Path Problems
Alexander Bronstein, Michael Bronstein© 2008 All rights reserved. Web: tosca.cs.technion.ac.il
As regards obstacles, the shortest distance between two points can
be a curve.
B. Brecht
2Numerical geometry of non-rigid shapes Shortest Path Problems
How to compute the intrinsic metric?
So far, we represented itself.
Our model of rigid shapes as metric spaces involves
the intrinsic metric
Sampling procedure requires as well.
We need a tool to compute geodesic distances on .
3Numerical geometry of non-rigid shapes Shortest Path Problems
Shortest path problem
Paris
Brussels
BernMunich
Prague
Vienna346
183 566
194285
504407
271
943
1146
1542902
4Numerical geometry of non-rigid shapes Shortest Path Problems
Shapes as graphs
Sample the shape at vertices .
Represent shape as an undirected graph
set of edges
representing adjacent vertices.
Define length function
measuring local distances as
Euclidean ones,
5Numerical geometry of non-rigid shapes Shortest Path Problems
Shapes as graphs
Path between is an ordered set of connected edges
where and .
Path length = sum of edge lengths
6Numerical geometry of non-rigid shapes Shortest Path Problems
Geodesic distance
Shortest path between
Length metric in graph
Approximates the geodesic distance on the shape.
Shortest path problem: compute and
between any .
Alternatively: given a source point , compute the
distance map .
7Numerical geometry of non-rigid shapes Shortest Path Problems
Bellman’s principle of optimality
Let be shortest path between
and a point on the path.
Then, and are
shortest sub-paths between , and .
Suppose there exists a shorter path .
Contradiction to being shortest path.
Richard Bellman(1920-1984)
8Numerical geometry of non-rigid shapes Shortest Path Problems
Dynamic programming
How to compute the shortest path between source and on ?
Bellman principle: there exists such that
has to minimize path length
Recursive dynamic programming equation.
9Numerical geometry of non-rigid shapes Shortest Path Problems
Edsger Wybe Dijkstra (1930–2002)
[‘ɛtsxər ‘wibə ‘dɛɪkstra]
10Numerical geometry of non-rigid shapes Shortest Path Problems
Dijkstra’s algorithm
Initialize and for the rest of the graph;
Initialize queue of unprocessed vertices .
While
Find vertex with smallest value of ,
For each unprocessed adjacent vertex ,
Remove from .
Return distance map .
11Numerical geometry of non-rigid shapes Shortest Path Problems
Dijkstra’s algorithm
Paris
Brussels
Bern
Munich
Prague
Vienna
346
183 566
194
285
504407
271
0
0
183
346
183
346
0
679
749
679
749
183183
617
346346346
617617 904904617
749749
904904904
12Numerical geometry of non-rigid shapes Shortest Path Problems
Dijkstra’s algorithm – complexity
While there are still unprocessed vertices
Find and remove minimum
For each unprocessed adjacent vertex
Perform update
Every vertex is processed exactly once: outer iterations.
Minimum extraction straightforward complexity:
Can be reduced to using binary or Fibonacci heap.
Updating adjacent vertices is in general .
In our case, graph is sparsely connected, update in .
Total complexity: .
13Numerical geometry of non-rigid shapes Shortest Path Problems
Troubles with the metric
Grid with 4-neighbor connectivity.
True Euclidean distance
Shortest path in graph (not unique)
Increasing sampling density does
not help.
14Numerical geometry of non-rigid shapes Shortest Path Problems
Metrication error
4-neighbor topology
Manhattan distance
Continuous
Euclidean distance
8-neighbor topology
Graph representation induces an inconsistent metric.
Increasing sampling size does not make it consistent.
Neither does increasing connectivity.
15Numerical geometry of non-rigid shapes Shortest Path Problems
Metrication error
How to approximate the metric consistently?
Solution 1
Stick to graph representation.
Change connectivity and sampling.
Under certain conditions consistency is
guaranteed.
Solution 2
Stick to given sampling (and connectivity).
Compute distance map on a surface in some
representation (e.g., mesh).
Requires a new algorithm.
16Numerical geometry of non-rigid shapes Shortest Path Problems
Fast marching algorithms
Imagine a forest fire…
17Numerical geometry of non-rigid shapes Shortest Path Problems
Forest fire
Fire starts at a source at
.
Propagates with constant velocity
Arrives at time to a point
.
Fermat’s (least action) principle:
The fire chooses the quickest path
to travel.
Governs refraction laws in optics
(Snell’s law) and acoustics.
Fire arrival time =
distance map from source.
18Numerical geometry of non-rigid shapes Shortest Path Problems
Distance maps on surfaces
Distance map on surface
Mapped locally to the tangent space
A small step in the direction changes the distance by
is directional derivative in the direction .
19Numerical geometry of non-rigid shapes Shortest Path Problems
Intrinsic gradient
For some direction ,
The perpendicular direction is the direction of steepest
change of the distance map.
is referred to as the intrinsic gradient.
Formally, the intrinsic gradient of
function at a point
is a map
satisfying for any
20Numerical geometry of non-rigid shapes Shortest Path Problems
Extrinsic gradient
Consider the distance map as a function .
The extrinsic gradient of at a point is a map
satisfying for any direction
In the standard Euclidean basis
Usually called “the gradient” of .
What is the connection between intrinsic and extrinsic gradients?
21Numerical geometry of non-rigid shapes Shortest Path Problems
Intrinsic gradient = projection of
extrinsic gradient on tangent plane
In coordinates of a parametrization
,
is the Jacobian matrix
whose columns span .
Intrinsic and extrinsic gradients
22Numerical geometry of non-rigid shapes Shortest Path Problems
Eikonal equation
Let be a minimal geodesic between and .
The derivative
is the fire front propagation direction.
In arclength parametrization .
Fermat’s principle:
Propagation direction = direction of steepest increase of .
Geodesic is perpendicular to the level sets of on .
23Numerical geometry of non-rigid shapes Shortest Path Problems
Eikonal equation
Eikonal equation (from Greek εικων)
Hyperbolic PDE with boundary
condition
Minimal geodesics are
characteristics.
Describes propagation of waves
in medium.
24Numerical geometry of non-rigid shapes Shortest Path Problems
Eikonal equation
Let be a minimal geodesic between and .
The derivative
is the fire front propagation direction.
In arclength parametrization .
Fermat’s principle:
Propagation direction = direction of steepest increase of .
Geodesic is perpendicular to the level sets of on .
25Numerical geometry of non-rigid shapes Shortest Path Problems
Uniqueness of solution
In classic PDE theory, a solution
is a continuous differentiable
function satisfying
PDE theory guarantees existence
and uniqueness of solution.
Distance map is not everywhere
differentiable.
Solution is not unique!
1D example
26Numerical geometry of non-rigid shapes Shortest Path Problems
We need assistance of a super-creature…
27Numerical geometry of non-rigid shapes Shortest Path Problems
Sub- and super-derivatives (1D case)
Superderivative: the set of all slopes above the graph
Subderivative: the set of all slopes below the graph
where is differentiable.
28Numerical geometry of non-rigid shapes Shortest Path Problems
Viscosity solution
is a viscosity solution of the
1D eikonal equation if
Monotonicity: viscosity solution
does not have local maxima.
The largest among all
Existence and uniqueness
guaranteed.
Not a viscosity solution
Viscosity solution
29Numerical geometry of non-rigid shapes Shortest Path Problems
Fast marching methods (FMM)
A family of numerical methods for
solving eikonal equation.
Finds the viscosity solution =
distance map.
Simulates wavefront propagation
from a source set.
A continuous variant of Dijkstra’s
algorithm.
Consistently approximate the
intrinsic metric on the surface.
30Numerical geometry of non-rigid shapes Shortest Path Problems
Fast marching algorithm
Initialize and mark it as black.
Initialize for other vertices and mark them as green.
Initialize queue of red vertices .
Repeat
Mark green neighbors of black vertices as red (add to )
For each red vertex
For each triangle sharing the vertex
Update from the triangle.
Mark with minimum value of as black (remove from )
Until there are no more green vertices.
Return distance map .
31Numerical geometry of non-rigid shapes Shortest Path Problems
Update step
Dijkstra’s update
Vertex updated from
adjacent vertex
Distance computed
from
Path restricted to graph edges
Fast marching update
Vertex updated from
triangle
Distance computed
from and
Path can pass on mesh faces
32Numerical geometry of non-rigid shapes Shortest Path Problems
Fast marching update step
Update from triangle
Compute from
and
Model wave front propagating from
planar source
unit propagation direction
source offset
Front hits at time
Hits at time
When does the front arrive to ?
Planar source
33Numerical geometry of non-rigid shapes Shortest Path Problems
Fast marching update step
Assume w.l.o.g. and .
is given by the point-to-plane distance
Solve for parameters and using the point-to-plane distance
In vector notation
where , , and .
In a non-degenerate triangle matrix is full-rank
34Numerical geometry of non-rigid shapes Shortest Path Problems
Fast marching update step
Apparently, we have two equations with three variables.
However, is a unit vector, hence .
where .
Substitute and obtain a quadratic equation
35Numerical geometry of non-rigid shapes Shortest Path Problems
Causality condition
Quadratic equation is satisfied by both
and .
Two solutions for
Causality: front can propagate only
forward in time.
Causality condition
36Numerical geometry of non-rigid shapes Shortest Path Problems
Causality condition
Causality condition
In other words
has to form obtuse angles with both
triangle edges .
Causality is required to obtain
consistent
approximation of the distance map.
Smallest solution for is inconsistent
and is discarded.
If largest solution is consistent, live the
largest solution!
37Numerical geometry of non-rigid shapes Shortest Path Problems
Monotonicity condition
Viscosity solution has to be a monotonically increasing function.
Monotonicity condition: increase when or increase.
In other words:
Differentiate
w.r.t obtaining
38Numerical geometry of non-rigid shapes Shortest Path Problems
Monotonicity condition
Substitute
Monotonicity satisfied when both coordinates of
have the same sign.
is positive definite
Causality condition:
Monotonicity condition:
At least one coordinate
of is negative
39Numerical geometry of non-rigid shapes Shortest Path Problems
Since we have
Rows of are orthogonal to triangle edges
Monotonicity condition:
Geometric interpretation:
must form obtuse angles with normals
to triangle edges.
Said differently:
must come from within the triangle.
Monotonicity condition
40Numerical geometry of non-rigid shapes Shortest Path Problems
Monotonicity condition: update direction
must come from within the triangle.
If it does not, project inside the triangle.
will coincide with one of the edges.
Update will reduce to Dijkstra’s update
One-sided update
or
41Numerical geometry of non-rigid shapes Shortest Path Problems
Solve for the quadratic equation
Compute propagation direction
If monotonicity condition is violated,
Set
Fast marching update
42Numerical geometry of non-rigid shapes Shortest Path Problems
Acute triangle
All directions in the triangle
satisfy consistency and
monotonicity conditions.
Consistency and monotonicity encore
Monotonicity
Consistency
Consi
sten
cy
Obtuse triangle
Some directions in the triangle
violate consistency condition!
43Numerical geometry of non-rigid shapes Shortest Path Problems
Fast marching on obtuse meshes
Inconsistent solution if the mesh contains obtuse triangles
Remeshing is costly
Solution: split obtuse triangles by adding virtual connections to
non-adjacent vertices
Done as a pre-processing step in
44Numerical geometry of non-rigid shapes Shortest Path Problems
Fast marching
MATLAB® intermezzo
45Numerical geometry of non-rigid shapes Shortest Path Problems
46Numerical geometry of non-rigid shapes Shortest Path Problems
Parametrization of over .
Compute distance map ,
from source .
Chain rule
Extrinsic gradient in parametrization coordinates
Intrinsic gradient in parametrization coordinates
Eikonal equation on parametric surfaces
47Numerical geometry of non-rigid shapes Shortest Path Problems
Eikonal equation on parametric surfaces
Eikonal equation in parametrization coordinates
48Numerical geometry of non-rigid shapes Shortest Path Problems
Solve eikonal equation in parametrization domain
March on discretized parametrization domain.
We need to express update step in parametrization coordinates.
Fast marching on parametric surfaces
49Numerical geometry of non-rigid shapes Shortest Path Problems
Cartesian sampling of with unit step.
Some connectivity (e.g. 4- or 8-neighbor).
Vertex updated from triangle
Assuming w.l.o.g.
or in matrix form
Fast marching on parametric surfaces
50Numerical geometry of non-rigid shapes Shortest Path Problems
Inner product matrix
Describes triangle geometry.
lengths of the edges.
cosine of the angle.
Substitute into the update quadratic equation
Only first fundamental form coefficients and grid connectivity are
required for update.
Can measure distances when only surface gradients are known.
Fast marching on parametric surfaces
51Numerical geometry of non-rigid shapes Shortest Path Problems
Heap-based grid update
Fast marching and Dijkstra’s algorithm use heap-based grid update.
Next vertex to be updated is decided by extracting the smallest .
Update order is unknown and data-dependent.
Inefficient use of memory system and cache.
Inherently sequential algorithm – next update depends on previous
one.
Can we do better?
Regular access to memory (known in advance).
Vectorizable (parallelizable) algorithm.
52Numerical geometry of non-rigid shapes Shortest Path Problems
Marching even faster
Danielsson’s algorithm: update the grid in a raster scan order
In Euclidean case, parametrization is trivial.
Geodesics are straight lines in parametrization domain.
Each raster scan covers ¼ of the possible directions of the geodesics.
Euclidean distance map computed by four alternating raster scans.
53Numerical geometry of non-rigid shapes Shortest Path Problems
Raster scan fast marching
Generally, geodesics are curved in
parametrization domain.
Raster scans have to be repeated to
produce a convergent solution.
Iterative algorithm.
Number of iterations depends on
geometry and parametrization.
Practically, few iterations are
required.
1 iteration
2 iterations
3 iterations
4 iterations
5 iterations
6 iterations
54Numerical geometry of non-rigid shapes Shortest Path Problems
Raster scan fast marching
What we lost:
No more a one-pass algorithm.
Computational complexity is data-dependent.
What we found:
Coherent memory access, efficient use of cache.
No heap, each iteration is .
Raster scans can be parallelized.
BBK, "Parallel algorithms for approximation of distance maps on parametric surfaces”, 2007
55Numerical geometry of non-rigid shapes Shortest Path Problems
Parallellization
Rotate scan directions by 450.
All updates performed along a row or column can be parallelized.
Constant CPU load – suitable for SIMD architecture and GPUs.
56Numerical geometry of non-rigid shapes Shortest Path Problems
Parallel marching
Rotate scan directions by 450.
All updates performed along a row or column can be parallelized.
Constant CPU load.
Suitable for SIMD architecture and GPUs.
GPU implementation computes geodesic on grid with 10,000,000
vertices in less than 50 msec.
About 200 million distances per second!
57Numerical geometry of non-rigid shapes Shortest Path Problems
Minimal geodesics
We have a numerical tool to compute geodesic distance.
Sometimes, the shortest path itself is needed.
Minimal geodesics are characteristics of the eikonal equation.
In other words:
Along geodesic, eikonal equation becomes an ODE
with initial condition .
Solve the ODE for .
58Numerical geometry of non-rigid shapes Shortest Path Problems
Minimal geodesics
To find a minimal geodesic between two points
Compute distance map from to all other points.
Starting at , follow the direction of until is reached.
Steepest descent on the distance map.
In the parametrization coordinates
Let be the preimage of in
59Numerical geometry of non-rigid shapes Shortest Path Problems
Minimal geodesics
Substitute into characteristic equation
Steepest descent on surface = scaled steepest descent in
parametrization domain.
60Numerical geometry of non-rigid shapes Shortest Path Problems
Uses of fast marching
Geodesic distances
Minimal geodesics
Voronoi tessellation &
sampling
Offset curves