1.18k likes | 1.34k Views
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:
E N D
Computational Movement AnalysisLecture 3: Curve simplificationJoachim 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.
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:
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:
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:
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:
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:
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:
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:
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:
Example Generated trajectory: Universe: 400x400 Number of points: 10K Error: 5 units 278 points 10 units 174 points Time: ~15ms Car trajectory: Universe: ~20km 20km Number of points: 85K Error: 5 meter 2601 points 10 meter 1728 points Time: ~200ms
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
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
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 vfand pipj. • if dist > then • DP(P,vi ,vf) • DP(P, vf, vj) • else • Output(vivj) pj pi
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 pjfarthest from pipj. • dist := the distance between vfand pipj. • if dist > then • DP(P,vi ,vf) • DP(P, vf, vj) • else • Output(vivj) pj pi dist
>e >e >e >e >e >e Ramer-Douglas-Peucker q p
Ramer-Douglas-Peucker Time complexity? Testing a shortcut between pi and pj takes O(j-i) time. Algorithm DP(P,i,j) • Find the vertex vf farthest from pipj. • dist := the distance between vfand pipj. • if dist > then • DP(P,vi ,vf) • DP(P, vf, vj) • else • Output(vivj) Worst-case recursion? DP(P, vi , vi+1) DP(P, vi+1, vj) Time complexity T(n) = O(n) + T(n-1) = O(n2)
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!
Driemel et al. Simple simplification(P = p1,…,pn, ) P’:= p1 i:=1 while i<n do q := pi pi := first vertex pi in q,…,pns.t. |q-pi|> if no such vertex then set i:=n add pito P’ end return P’
Driemel et al. Simple simplification(P = p1,…,pn, ) P’:= p1 i:=1 while i<n do q := pi pi := first vertex pi in q,…,pns.t. |q-pi|> if no such vertex then set i:=n add pito P’ end return P’
Driemel et al. Simple simplification(P = p1,…,pn, ) P’:= p1 i:=1 while i<n do q := pi pi := first vertex pi in q,…,pns.t. |q-pi|> if no such vertex then set i:=n add pito P’ end return P’
Driemel et al. Simple simplification(P = p1,…,pn, ) P’:= p1 i:=1 while i<n do q := pi pi := first vertex pi in q,…,pns.t. |q-pi|> if no such vertex then set i:=n add pito P’ end return P’
Driemel et al. Simple simplification(P = p1,…,pn, ) P’:= p1 i:=1 while i<n do q := pi pi := first vertex pi in q,…,pns.t. |q-pi|> if no such vertex then set i:=n add pito P’ end return P’
Driemel et al. Simple simplification(P = p1,…,pn, ) P’:= p1 i:=1 while i<n do q := pi pi := first vertex pi in q,…,pns.t. |q-pi|> if no such vertex then set i:=n add pito P’ end return P’
Driemel et al. Simple simplification(P = p1,…,pn, ) P’:= p1 i:=1 while i<n do q := pi pi := first vertex pi in q,…,pns.t. |q-pi|> if no such vertex then set i:=n add pito P’ end return P’
Driemel et al. Simple simplification(P = p1,…,pn, ) P’:= p1 i:=1 while i<n do q := pi pi := first vertex pi in q,…,pns.t. |q-pi|> if no such vertex then set i:=n add pito P’ end return P’
Driemel et al. Simple simplification(P = p1,…,pn, ) P’:= p1 i:=1 while i<n do q := pi pi := first vertex pi in q,…,pns.t. |q-pi|> if no such vertex then set i:=n add pito P’ end return P’
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’)
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.
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)
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: Pu u B(p,r)
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: Hu Pu u B(p,r) Pu must lie inside Hu
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| =|v| lv rv Hu Pu u v B(p,r) Pu must intersect lv and rv |PuHv| |v|
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) u| =|v| lv rv Hu Pu u v B(p,r) v B(p,r)
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| =|v| lv rv Hu Hv Pu u v B(p,r+) B(p,r) v B(p,r)
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| =|v| lv rv Hu Hv Pu u v B(p,r+) B(p,r) v B(p,r) Hv B(p,r+)
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| =|v| lv rv Hu Hv Pu u v B(p,r+) B(p,r) v B(p,r) Hv B(p,r+) Pu Hv B(p,r+)
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| =|v| lv rv Hu Hv Pu u v B(p,r+) B(p,r) v B(p,r) Hv B(p,r+) Pu Hv B(p,r+) |Pu B(p,r+)| |v|
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)
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)|
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+)|
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
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
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
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
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.
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.
Imai-Iri Input polygonal path P = p1,…,pn and threshold Build a graph G containing all valid shortcuts. Find a minimum link path from p1 to pn in G
Imai-Iri Input polygonal path P = p1,…,pn and threshold Build a graph G containing all valid shortcuts. Find a minimum link path from p1 to pn in G