Computational Movement Analysis Lecture 3: Curve simplification Joachim Gudmundsson

118
Computational Movement Analysis Lecture 3: Curve simplification Joachim Gudmundsson

description

Computational Movement Analysis Lecture 3: Curve simplification Joachim Gudmundsson. Problem. Many algorithms handling movement data are slow, e.g. - similarity O(nm log nm) - approximate clustering O(n 2 +nml) - … Observation: - PowerPoint PPT Presentation

Transcript of Computational Movement Analysis Lecture 3: Curve simplification Joachim Gudmundsson

Page 1: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Computational Movement Analysis

Lecture 3: Curve simplification

Joachim Gudmundsson

Page 2: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Problem

Many algorithms handling movement data are slow, e.g. - similarity O(nm log nm)- approximate clustering O(n2+nml)- …

Observation:Many trajectories can be simplified without losing much information.

Page 3: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Problem

Many algorithms handling movement data are slow, e.g. - - similarity O(nm log nm)- approximate clustering O(n2+nml)- …

Observation:Many trajectories can be simplified without losing much information.

Example:

Page 4: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Problem

Many algorithms handling movement data are slow, e.g.

- similarity O(nm log nm)- approximate clustering O(n2+nml)- …

Observation:Many trajectories can be simplified without losing much information. Example:

Page 5: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Problem

Many algorithms handling movement data are slow, e.g. - similarity O(nm log nm)

- approximate clustering O(n2+nml)- …

Observation:Many trajectories can be simplified without losing much information.

Example:

Page 6: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Problem

Many algorithms handling movement data are slow, e.g. - similarity O(nm log nm)- approximate clustering O(n2+nml)- …

Observation:Many trajectories can be simplified without losing much information.

Example:

Page 7: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Problem

Many algorithms handling movement data are slow, e.g. - similarity O(nm log nm)

- approximate clustering O(n2+nml)- …

Observation:Many trajectories can be simplified without losing much information.

Example:

Page 8: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Problem

Many algorithms handling movement data are slow, e.g. - similarity O(nm log nm)- approximate clustering O(n2+nml)- …

Observation:Many trajectories can be simplified without losing much information.

Example:

Page 9: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Problem

Many algorithms handling movement data are slow, e.g. - similarity O(nm log nm)

- approximate clustering O(n2+nml)- …

Observation:Many trajectories can be simplified without losing much information.

Example:

Page 10: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Problem

Many algorithms handling movement data are slow, e.g. - similarity O(nm log nm)- approximate clustering O(n2+nml)- …

Observation:Many trajectories can be simplified without losing much information.

Example:

Page 11: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Example

Generated trajectory:

Universe: 400x400Number of points: 10KError: 5 units 278 points

10 units   174 points Time: ~15ms

Car trajectory:

Universe: ~20km 20kmNumber of points: 85KError: 5 meter 2601 points

10 meter   1728 points Time: ~200ms

Page 12: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Outline

Simplifying polygonal curves

• Ramer–Douglas–Peucker 1973

• Driemel, Har-Peled and Wenk, 2010

• Imai-Iri 1988

• Agarwal, Har-Peled, Mustafa and Wang, 2005

• Take time into consideration

Page 13: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Ramer-Douglas-Peucker

1972 by Urs Ramer and 1973 by David Douglas and Thomas Peucker

The most successful simplification algorithm. Used in GIS, geography, computer vision, pattern recognition…

Very easy to implement and works well in practice.p

Page 14: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

pjpi

Ramer-Douglas-Peucker

Input polygonal path P = p1,…,pn and threshold

Initially i=1 and j=n

Algorithm DP(P,i,j) Find the vertex vf between pi and pj farthest from pipj. dist := the distance between vf and pipj.

if dist > thenDP(P, vi , vf)DP(P, vf , vj)

elseOutput(vivj)

Page 15: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

pjpi

Ramer-Douglas-Peucker

Input polygonal path P = p1,…,pn and threshold

Initially i=1 and j=n

Algorithm DP(P,i,j) Find the vertex vf between pi and pj farthest from pipj. dist := the distance between vf and pipj.

if dist > thenDP(P, vi , vf)DP(P, vf , vj)

elseOutput(vivj)

dist

Page 16: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

>

>

Ramer-Douglas-Peucker

>

>

>

>

p

q

Page 17: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Ramer-Douglas-Peucker

p

q

Page 18: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Ramer-Douglas-Peucker

Time complexity?

Testing a shortcut between pi and pj takes O(j-i) time.

Worst-case recursion?Algorithm DP(P,i,j) Find the vertex vf farthest from pipj. dist := the distance between vf and pipj.

if dist > thenDP(P, vi , vf)DP(P, vf , vj)

elseOutput(vivj)

DP(P, vi , vi+1)DP(P, vi+1 , vj)

Time complexity T(n) = O(n) + T(n-1) = O(n2)

Page 19: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Summary: Ramer-Douglas-Peucker

Worst-case time complexity: O(n2)

In most realistic cases: T(n) = T(n1) +  T(n2) + O(n) = O(n log n), where n1 and n2 are smaller than n/c for some constant c.

If the curve is in 2D and it does not self-intersect then the algorithm can be implemented in O(n log* n) time.

[Hershberger & Snoeiynk’98]

Does not give any bound on the complexity of the simplification!

Page 20: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Simple simplification(P = p1,…,pn, ) P’:= p1i:=1while i<n do q := pi

pi := first vertex pi in q,…,pn s.t. |q-pi|> if no such vertex then set i:=nadd pi to P’

endreturn P’

Page 21: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Simple simplification(P = p1,…,pn, ) P’:= p1i:=1while i<n do q := pi

pi := first vertex pi in q,…,pn s.t. |q-pi|> if no such vertex then set i:=nadd pi to P’

endreturn P’

Page 22: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Simple simplification(P = p1,…,pn, ) P’:= p1i:=1while i<n do q := pi

pi := first vertex pi in q,…,pn s.t. |q-pi|> if no such vertex then set i:=nadd pi to P’

endreturn P’

Page 23: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Simple simplification(P = p1,…,pn, ) P’:= p1i:=1while i<n do q := pi

pi := first vertex pi in q,…,pn s.t. |q-pi|> if no such vertex then set i:=nadd pi to P’

endreturn P’

Page 24: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Simple simplification(P = p1,…,pn, ) P’:= p1i:=1while i<n do q := pi

pi := first vertex pi in q,…,pn s.t. |q-pi|> if no such vertex then set i:=nadd pi to P’

endreturn P’

Page 25: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Simple simplification(P = p1,…,pn, ) P’:= p1i:=1while i<n do q := pi

pi := first vertex pi in q,…,pn s.t. |q-pi|> if no such vertex then set i:=nadd pi to P’

endreturn P’

Page 26: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Simple simplification(P = p1,…,pn, ) P’:= p1i:=1while i<n do q := pi

pi := first vertex pi in q,…,pn s.t. |q-pi|> if no such vertex then set i:=nadd pi to P’

endreturn P’

Page 27: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Simple simplification(P = p1,…,pn, ) P’:= p1i:=1while i<n do q := pi

pi := first vertex pi in q,…,pn s.t. |q-pi|> if no such vertex then set i:=nadd pi to P’

endreturn P’

Page 28: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Simple simplification(P = p1,…,pn, ) P’:= p1i:=1while i<n do q := pi

pi := first vertex pi in q,…,pn s.t. |q-pi|> if no such vertex then set i:=nadd pi to P’

endreturn P’

Page 29: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Simple simplification(P = p1,…,pn, ) Property 1: All edges (except the last one) have length at least .

Property 2: F(P,P’)

Page 30: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Simple simplification(P = p1,…,pn, ) Property 1: All edges (except the last one) have length at least .

Property 2: F(P,P’)

Definition: A curve P is c-packed, if has finite length, and for any ball b(p,r) it holds |P b(p,r)| < cr.

Property 3: If P is c-packed then P’ is 6c-packed.

Page 31: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Aim: Prove Property 3 If P is c-packed then P’ is 6c-packed.

We need the following observation:Let P be a curve and let P’ be an -simplification of P |P B(p,r+ )| |P’ B(p,r)| for any ball B(p,r)

Proof:

B(p,r)

Page 32: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Pu

Driemel et al.

Observation:Let P be a curve and let P’ be an -simplification of P |P B(p,r+)| |P’ B(p,r)| for any ball B(p,r)

Proof:

B(p,r)

u

Page 33: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Observation:Let P be a curve and let P’ be an -simplification of P |P B(p,r+)| |P’ B(p,r)| for any ball B(p,r)

Proof:

B(p,r)

uPu

Hu

Pu must lie inside Hu

Page 34: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Observation:Let P be a curve and let P’ be an -simplification of P |P B(p,r+)| |P’ B(p,r)| for any ball B(p,r)

Proof:

B(p,r)

uPu

Hu

v

lv rv

Pu must intersect lv and rv |PuHv| |v|

|B(p,r) u| = |v|

Page 35: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Observation:Let P be a curve and let P’ be an -simplification of P |P B(p,r+)| v |P’ B(p,r)| for any ball B(p,r)

Proof:

B(p,r)

uPu

Hu

v

lv rv

v B(p,r)

|B(p,r) u| = |v|

Page 36: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Hv

Driemel et al.

Observation:Let P be a curve and let P’ be an -simplification of P |P B(p,r+)| |P’ B(p,r)| for any ball B(p,r)

Proof:

B(p,r)

uPu

Hu

v

lv rv

v B(p,r)

B(p,r+)

|B(p,r) u| = |v|

Page 37: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Hv

Driemel et al.

Observation:Let P be a curve and let P’ be an -simplification of P |P B(p,r+)| |P’ B(p,r)| for any ball B(p,r)

Proof:

B(p,r)

uPu

Hu

v

lv rv

B(p,r+)

v B(p,r) Hv B(p,r+)

|B(p,r) u| = |v|

Page 38: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Hv

Driemel et al.

Observation:Let P be a curve and let P’ be an -simplification of P |P B(p,r+)| |P’ B(p,r)| for any ball B(p,r)

Proof:

B(p,r)

uPu

Hu

v

lv rv

B(p,r+)

v B(p,r) Hv B(p,r+) Pu Hv B(p,r+)

|B(p,r) u| = |v|

Page 39: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Hv

Driemel et al.

Observation:Let P be a curve and let P’ be an -simplification of P |P B(p,r+)| |P’ B(p,r)| for any ball B(p,r)

Proof:

B(p,r)

uPu

Hu

v

lv rv

B(p,r+)

v B(p,r) Hv B(p,r+) Pu Hv B(p,r+) |Pu B(p,r+)| |v|

|B(p,r) u| = |v|

Page 40: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Theorem: If P is c-packed then P’ is 6c-packed.

Observation:Let P be a curve and let P’ be an -simplification of P |P B(p,r+ )| |P’ B(p,r)| for any ball B(p,r)

Page 41: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Theorem: If P is c-packed then P’ is 6c-packed.

Proof: Proof by contradiction.Assume |P’B(p,r)|>6cr for some B(p,r)

Two cases: r or r<

Case r : |P B(p,2r)|

Page 42: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Theorem: If P is c-packed then P’ is 6c-packed.

Proof: Proof by contradiction.Assume |P’B(p,r)|>6cr for some B(p,r)

Two cases: r or r<

Case r : |P B(p,2r)| |P B(p,r+)|

Page 43: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Theorem: If P is c-packed then P’ is 6c-packed.

Proof: Proof by contradiction.Assume |P’B(p,r)|>6cr for some B(p,r)

Two cases: r or r<

Case r : |P B(p,2r)| |P B(p,r+)| |P’ B(p,r)|

According to observation

Page 44: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Theorem: If P is c-packed then P’ is 6c-packed.

Proof: Proof by contradiction.Assume |P’B(p,r)|>6cr for some B(p,r)

Two cases: r or r<

Case r : |P B(p,2r)| |P B(p,r+)| |P’ B(p,r)| > 6cr

According to observation

Page 45: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Theorem: If P is c-packed then P’ is 6c-packed.

Proof: Proof by contradiction.Assume |P’B(p,r)|>6cr for some B(p,r)

Two cases: r or r<

Case r : |P B(p,2r)| |P B(p,r+)| |P’ B(p,r)| > 6cr

|P B(p,2r)| > 6cr

|P B(p,r’)| > 3cr’ which contradicts that P is c-packed

According to observation

Page 46: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Driemel et al.

Theorem: If P is c-packed then P’ is 6c-packed.

Proof: Proof by contradiction.Assume |P’B(p,r)|>6cr for some B(p,r)

Two cases: r or r<

Case r : |P B(p,2r)| |P B(p,r+)| |P’ B(p,r)| > 6cr

|P B(p,2r)| > 6cr

|P B(p,r’)| > 3cr’ which contradicts that P is c-packed

Case r < : Proof is similar.

According to observation

Page 47: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Summary: Driemel et al.

Simple simplification: can be computed in O(n) time Property 1: All edges (except the last one) have length at least .

Property 2: F(P,P’)

Definition: A curve P is c-packed, if has finite length, and for any ball b(p,r) it holds |P b(p,r)| < cr.

Property 3: If P is c-packed then P’ is 6c-packed.

Page 48: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Both previous algorithms are simple and fast but do not give a bound on the complexity of the simplification!

Imai-Iri 1988 gave an algorithm that produces a -simplification with the minimum number of links.

Page 49: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Input polygonal path P = p1,…,pn and threshold

1. Build a graph G containing all valid shortcuts.2. Find a minimum link path from p1 to pn in G

Page 50: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Input polygonal path P = p1,…,pn and threshold

1. Build a graph G containing all valid shortcuts.2. Find a minimum link path from p1 to pn in G

Page 51: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

Page 52: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

>

Page 53: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

<<

Page 54: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

>

Page 55: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

>

Page 56: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

>

Page 57: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

>

Page 58: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

>

Page 59: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

>

Page 60: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

Page 61: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

Page 62: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

Page 63: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

Page 64: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

Page 65: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Find all possible valid shortcuts

Page 66: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

All possible shortcuts!

Page 67: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

1. Build a directed graph of valid shortcuts.2. Compute a shortest path from p1 to pn using breadth-first search.

Page 68: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

1. Build a directed graph of valid shortcuts.2. Compute a shortest path from p1 to pn using breadth-first search.

Page 69: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Imai-Iri

Brute force running time: ? #possible shortcuts ?

Page 70: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Summary: Imai-Iri

Running time: O(n3) O(n2) possible shortcuts

O(n) per shortcut O(n3) to build graphO(n2) BFS in the graph

Output: A path with minimum number of edges

Improvements: Chan and Chin’92: O(n2)

Page 71: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Results so far

RDP: O(n2) time (simple and fast in practice) Output: A path with no bound on the size of the path

SS: O(n) time (simple and fast in practice)Output: A path with no bound on the size of the path

Imai-Iri: O(n2) time by Chan and Chin (complicated)Output: A path with minimum number of edges

RDP and II use the Hausdorff error measure, SS use Fréchet

Can we get something that is simple, fast and has a worst-case bound using the Fréchet error measure?

Page 72: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Agarwal et al.

Agarwal, Har-Peled, Mustafa and Wang, 2002

Time: Running time O(n log n)

Measure: Fréchet distance

Output: Path has at most the same complexity as a minimum link (/2)-simplification

Page 73: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Notation: Let (pipj) denote the Fréchet distance between (pi,pj) and the subpath (pi,pj) of P between pi and pj.

Let P = p1, p2, ... , pn be a polygonal curve pi

pm

pj

pl

Page 74: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Algorithm - Agarwal et al.

Algorithm(P = p1,…,pn, )

i := 1 P’= p1 while i < n do find any j>i such that ((pi,pj) and ((pi,pj+1) > ) or

((pi,pj) and j=n) P’= concat(P,pj) i := j end return P’

Page 75: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Algorithm - Agarwal et al.

p1

pj

Pj+

1

Algorithm(P = p1,…,pn, )

i := 1 P’= p1 while i < n do find any j>i such that ((pi,pj) and ((pi,pj+1) > ) or

((pi,pj) and j=n) P’= concat(P,pj) i := j end return P’

Page 76: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Algorithm - Agarwal et al.

p1

pj

Pj+

1

Algorithm(P = p1,…,pn, )

i := 1 P’= p1 while i < n do find any j>i such that ((pi,pj) and ((pi,pj+1) > ) or

((pi,pj) and j=n) P’= concat(P,pj) i := j end return P’

Page 77: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Algorithm - Agarwal et al.

Efficient algorithm?

Recall: Computing the Fréchet distance between (pi,pj) and (pi,pj) can be done in O(j-i) time (Lecture 1).

pi

pj

Pj+1

Page 78: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Algorithm - Agarwal et al.

Efficient algorithm?

Recall: Computing the Fréchet distance between (pi,pj) and (pi,pj) can be done in O(j-i) time (Lecture 1).

Finding the first j such that (pi,pj) and (pi,pj+1) > takes O(n2) time.

pi

pj

Pj+1

Page 79: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Algorithm - Agarwal et al.

How can we speed up the search for pj?

Note that it is enough to find any vertex pj such that

(pi,pj) and (pi,pj+1) >

Idea: Search for pj using exponential search followed by binary search!

Page 80: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Algorithm - Agarwal et al.

Exponential search:Test pi+1, pi+2, pi+4, pi+8… until found pi+2k, such that (pi,pi+2k) > .Binary search:Search for pj between pi+2k-1 and pi+2k s.t.

(pi,pj) and (pi,pj+1) > .

i+2k-1 i+2k

>

Page 81: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Algorithm - Agarwal et al.

> if then

search right

Binary search:Search for pj between pi+2k-1 and pi+2k s.t.

(pi,pj) and (pi,pj+1) > .

Exponential search:Test pi+1, pi+2, pi+4, pi+8… until found pi+2k, such that (pi,pi+2k) > .

i+2k-1 i+2k

Page 82: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Algorithm - Agarwal et al.

>

Binary search:Search for pj between pi+2k-1 and pi+2k s.t.

(pi,pj) and (pi,pj+1) > .

Exponential search:Test pi+1, pi+2, pi+4, pi+8… until found pi+2k, such that (pi,pi+2k) > .

i+2k-1 i+2k

if > thensearch left

Page 83: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Algorithm - Agarwal et al.

>

Binary search:Search for pj between pi+2k-1 and pi+2k s.t.

(pi,pj) and (pi,pj+1) > .

Exponential search:Test pi+1, pi+2, pi+4, pi+8… until found pi+2k, such that (pi,pi+2k) > .

i+2k-1 i+2kpj pj+1

>

Page 84: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Algorithm - Agarwal et al.

Binary search:Search for pj between pi+2k-1 and pi+2k s.t.

(pi,pj) and (pi,pj+1) > . Iterations: O(log n)

Total time: O(n log n)

Exponential search:Test pi+1, pi+2, pi+4, pi+8… until found pi+2k, such that (pi,pi+2k) > . Iterations: O(log n)

Page 85: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Lemma 1: Let P = p1, p2, ... , pn be a polygonal curve. For l ≤ i ≤ j ≤ m, (pipj) ≤ 2·(plpm).

pi

pm

pj

pl

Page 86: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Lemma 1: Let P = p1, p2, ... , pn be a polygonal curve. For l ≤ i ≤ j ≤ m, (pipj) ≤ 2·(plpm).

Proof:Fix matching that realises (plpm).Set = (plpm).

pi

pm

pj

pl

qj

qi

Page 87: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Lemma 1: Let P = p1, p2, ... , pn be a polygonal curve. For l ≤ i ≤ j ≤ m, (pipj) ≤ 2·(plpm).

Proof:Fix matching that realises (plpm).Set = (plpm).

1. ((pipj),(qiqj)) ≤

pi

pm

pj

pl

qj

qi

Page 88: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Lemma 1: Let P = p1, p2, ... , pn be a polygonal curve. For l ≤ i ≤ j ≤ m, (pipj) ≤ 2·(plpm).

Proof:Fix matching that realises (plpm).Set = (plpm).

1. ((pipj),(qiqj)) ≤

pi

pj

qj

qi

(pipj)

Page 89: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Lemma 1: Let P = p1, p2, ... , pn be a polygonal curve. For l ≤ i ≤ j ≤ m, (pipj) ≤ 2·(plpm).

Proof:Fix matching that realises (plpm).Set = (plpm).

1. ((pipj),(qiqj)) ≤

2. ((qiqj),(pipj)) ≤

pi

pm

pj

pl

qj

qi

Page 90: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Lemma 1: Let P = p1, p2, ... , pn be a polygonal curve. For l ≤ i ≤ j ≤ m, (pipj) ≤ 2·(plpm).

Proof:Fix matching that realises (plpm).Set = (plpm).

1. ((pipj),(qiqj)) ≤

2. ((qiqj),(pipj)) ≤

pi

pj

qj

qi

Page 91: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Lemma 1: Let P = p1, p2, ... , pn be a polygonal curve. For l ≤ i ≤ j ≤ m, (pipj) ≤ 2·(plpm).

Proof:Fix matching that realises (plpm).Set = (plpm).

1. ((pipj),(qiqj)) ≤

2. ((qiqj),(pipj)) ≤

((pipj),pipj) ≤ ≤ ((pipj),(qiqj)) + ((qiqj),(pipj)) ≤ 2

pi

pm

pj

pl

qj

qi

(pipj)

Page 92: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Theorem: (P,P’) and |P’| Popt(/2)

Proof: (P,P’) follows by construction.

Page 93: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Theorem: |P’| Popt(/2)

Proof: Q = p1= pj1

,…, pjl=pn - optimal (/2)-

simplificationP’ = p1= pi1

,…, pik=pn

Prove (by induction) that im jm , m 1.

pim-1

pjm

pim

Page 94: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Theorem: |P’| Popt(/2)

Proof: Q = p1= pj1

,…, pjl=pn - optimal (/2)-

simplificationP’ = p1= pi1

,…, pik=pn

Prove (by induction) that im jm , m 1.

Assume im-1 jm-1 and let i’ = im+1.

pim-1

pjm

pimpi’

pjm-1

Page 95: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Theorem: |P’| Popt(/2)

Proof: Q = p1= pj1

,…, pjl=pn - optimal (/2)-

simplificationP’ = p1= pi1

,…, pik=pn

Prove (by induction) that im jm , m 1.

Assume im-1 jm-1 and let i’ = im+1. By construction we have: (pim-1

pi’) > and (pim-1pi’-1)

pim-1

pjm

pimpi’

pjm-1

If i’ > jm then we are done!

>

Page 96: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Theorem: |P’| Popt(/2)

Proof: Q = p1= pj1

,…, pjl=pn - optimal (/2)-

simplificationP’ = p1= pi1

,…, pik=pn

(pim-1pi’) > and (pim-1

pi’-1)

Assume the opposite i.e. i’ jm

pim-1

pjm

pim

pi’

pjm-1

Page 97: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Theorem: |P’| Popt(/2)

Proof: Q = p1= pj1

,…, pjl=pn - optimal (/2)-

simplificationP’ = p1= pi1

,…, pik=pn

(pim-1pi’) > and (pim-1

pi’-1)

Assume the opposite i.e. i’ jm

Q is an (/2)-simplification (pjm-1pjm

) /2

pim-1

pjm

pim

pi’

pjm-1

Page 98: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Theorem: |P’| Popt(/2)

Proof: Q = p1= pj1

,…, pjl=pn - optimal (/2)-

simplificationP’ = p1= pi1

,…, pik=pn

(pim-1pi’) > and (pim-1

pi’-1)

Assume the opposite i.e. i’ jm

Q is an (/2)-simplification (pjm-1pjm

) /2

According to Lemma 1: (pim-1

pi’) 2 (pjm-1pjm

)

pim-1

pjm

pim

pi’

pjm-1

Page 99: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Analysis - Agarwal et al.

Theorem: |P’| Popt(/2)

Proof: Q = p1= pj1

,…, pjl=pn - optimal (/2)-

simplificationP’ = p1= pi1

,…, pik=pn

According to Lemma 1: (pim-1

pi’) 2 (pjm-1pjm

)

This is a contradiction since (pjm-1pjm

) > by construction.

i’ > jm and we are done!

pim-1

pjm

pimpi’

pjm-1

Page 100: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Summary - Agarwal et al.

Theorem: Given a polygonal curve P in Rd and a parameter 0, an -simplification of P of size at most Popt(/2) can be constructed in O(n log n) time and O(n) space.

Page 101: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Summary

• Ramer–Douglas–Peucker 1973Used very often in practice. Easy to implement and

fast in practice. Hausdorff error

• Simple Simplification O(n) time - simple and fastSeveral nice properties. Fréchet error

• Imai-Iri 1988Gives an optimal solution but slow. Hausdorff error

• Agarwal, Har-Peled, Mustafa and Wang 2005Fast and easy to implement. Gives a worst-case

performance guarantee. Fréchet error

Page 102: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Handle time?

Compress trajectories s.t. standard database queries are “sound” after compression.

The five standard database operations on a trajectory T are:

• where-at(T,t): location of e at time t.

• when-at(T,(x,y),L): time at which e is within distance L of (x,y)

• intersect: • nearest-neighbour: • spatial-join:

Page 103: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

• where-at(T,t): location of e at time t.

time t

point (x,y)

• when-at(T,(x,y),L): time at which e is within distance L of (x,y).

Handle time?

Page 104: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Soundness

Define distance between simplification and original trajectory.

Definition: A distance function is sound for a query q, if for each >0 there exists a >0, s.t. for every trajectory T and its -simplification T’ we have

||q(T)-q(T’)||< .

[Cao, Wolfson & Trajcevski’06]

Page 105: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Path simplification

1

45

32

7

6

1

2

7

1

2

7

6

6?

Input path Traditional path simplification

Aim

Page 106: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Soundness

Trajectory = Polygonal path in 3D (x,y,time)

Transform time units into space units (x,y,z), where z = time and is the maximum speed along the trajectory.

Use the Euclidean distance function.

Theorem: Where-at, spatial-join, NN, intersect are sound When-at is NOT sound

Where-at(T,t): Spatial error = |pq|

= |pr|/sin(rqp) 2

pq

rt

Page 107: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Soundness

Theorem: Where-at, spatial-join, NN, intersect are sound When-at is approximately sound

Apx-When-at(T,(x,y),L): When within distance L from (x,y)?

Set-Apx-when-at(T,(x,y),L) Set of time points when T is within distance L from (x, y)

Given a query point q=(x, y), let t1 be the time reported by apx-when-at(T’,(x, y), L+). There exists a time point t2 in set-apx-when-at (T, (x, y), L+2) such that |t1 − t2| / and |T(t1) − T’(t2)| .

Page 108: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Summary

Simplifying polygonal curves• Ramer–Douglas–Peucker 1973

• Driemel, Har-Peled and Wenk 2010

• Imai-Iri 1988

• Agarwal, Har-Peled, Mustafa and Wang 2005

• Take time into consideration

Other interesting simplification algorithms• Abam, de Berg, Hachenberger, Zarei 2007

Page 109: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Constraint FSD

Recall the free space diagram (fsd)Consider the fsd of two curves P and Q with respect to a distance r. (qQ,pP) in the fsd is in the free space iff dist(q,p) r.

(q1,p1)

(qm,pn)

P

Q

Can we use it for other measures?

qp

Page 110: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Constraint FSD

Example: (qQ,pP) in the fsd is in the free space iff p can “see” q.

q

p

Can the owner and the dog walk along P and Q such that they always see each other?

Page 111: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Constraint FSD

Example: (qQ,pP) in the fsd is in the free space iff p can “see” q.

q

p

Can the owner and the dog walk along P and Q such that they always see each other? Yes!

Page 112: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Constraint FSD

Example: The entities must walk with similar speed (similar ~ within a factor of 2?).

Can the entities walk along P and Q with similar speed while keeping a distance of at most r?

P

Q

Page 113: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Constraint FSD

Example: The entities must walk with similar speed (similar ~ within a factor of 2?).

Can the entities walk along P and Q with similar speed while keeping a distance of at most r?

P

Q

Page 114: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Constraint FSD

Example: The entities must walk with similar speed (similar ~ within a factor of 2?).

Can the entities walk along P and Q with similar speed while keeping a distance of at most r?

P

Q

Page 115: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Constraint FSD

Example: The entities must walk with similar speed (similar ~ within a factor of 2?).

Can the entities walk along P and Q with similar speed while keeping a distance of at most r?

P

Q

Page 116: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Constraint FSD

Example: The entities must walk with similar speed (similar ~ within a factor of 2?).

Can the entities walk along P and Q with similar speed while keeping a distance of at most r? No!

P

Q

Page 117: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

Open Problem

1. Can we find a subquadtratic algorithm that computed a simplification with a minimal number of edges, or within a constant factor?

Page 118: Computational Movement Analysis Lecture 3:  Curve simplification Joachim  Gudmundsson

References

• A. Driemel, S. Har-Peled and C. Wenk. Approximating the Fréchet Distance for Realistic Curves in Near Linear Time. Discrete & Computational Geometry , 2012.

• H. Cao, O. Wolfson, and G. Trajcevski. Spatio-temporal data reduction with deterministic error bounds. The VLDB Journal, 2006.

• W. S. Chan and F. Chin. Approximation of polygonal curves with minimum number of line segments. In Proceedings of the 3rd International Symposium on Algorithms and Computation, 1992.

• D. H. Douglas and T. K. Peucker. Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. The Canadian Cartographer, 1973.

• J. Gudmundsson, J. Katajainen, D. Merrick, C. Ong and T. Wolle. Compressing spatio-temporal trajectories. Computational Geometry - Theory and Applications, 2009.

• P. K. Agarwal, S. Har-Peled, N. Mustafa, and Y. Wang. Near-linear time approximation algorithms for curve simplication in two and three dimensions. Algorithmica, 2005.