Counting Convex k -gons in an Arrangement of Line Segments Martin - - PowerPoint PPT Presentation

counting convex k gons in an arrangement of line segments
SMART_READER_LITE
LIVE PREVIEW

Counting Convex k -gons in an Arrangement of Line Segments Martin - - PowerPoint PPT Presentation

Counting Convex k -gons in an Arrangement of Line Segments Martin Fink, Neeraj Kumar and Subhash Suri University of California, Santa Barbara Motivation Consider the following problem from computer vision: Motivation Consider the following


slide-1
SLIDE 1

Counting Convex k-gons in an Arrangement of Line Segments

Martin Fink, Neeraj Kumar and Subhash Suri

University of California, Santa Barbara

slide-2
SLIDE 2

Motivation

Consider the following problem from computer vision:

slide-3
SLIDE 3

Motivation

Consider the following problem from computer vision: Given a camera image I representing object boundaries, estimate the number of rectangular objects in the scene.

slide-4
SLIDE 4

Motivation

Consider the following problem from computer vision: Given a camera image I representing object boundaries, estimate the number of rectangular objects in the scene.

◮ Camera image I ⇒ Arrangement A of line segments

slide-5
SLIDE 5

Motivation

Consider the following problem from computer vision: Given a camera image I representing object boundaries, estimate the number of rectangular objects in the scene.

◮ Camera image I ⇒ Arrangement A of line segments ◮ Perspective transformation:

Rectangles in scene ⇒ quadilaterals in image

slide-6
SLIDE 6

Motivation

Consider the following problem from computer vision: Given a camera image I representing object boundaries, estimate the number of rectangular objects in the scene.

◮ Camera image I ⇒ Arrangement A of line segments ◮ Perspective transformation:

Rectangles in scene ⇒ quadilaterals in image

◮ Count all convex quadilaterals (4-gon) in an arrangement

slide-7
SLIDE 7

Motivation

Consider the following problem from computer vision: Given a camera image I representing object boundaries, estimate the number of rectangular objects in the scene.

◮ Camera image I ⇒ Arrangement A of line segments ◮ Perspective transformation:

Rectangles in scene ⇒ quadilaterals in image

◮ Count all convex quadilaterals (4-gon) in an arrangement

Natural generalization to convex k-gons

slide-8
SLIDE 8

Problem Definition

Given: An arrangement A(S) of line segments S in 2-D

a b c d e

slide-9
SLIDE 9

Problem Definition

Given: An arrangement A(S) of line segments S in 2-D

a b c d e

A convex k-gon of A(S) is a convex polygon with k sides if:

slide-10
SLIDE 10

Problem Definition

Given: An arrangement A(S) of line segments S in 2-D

1 2 3 4 5 6 7 a b c d e

A convex k-gon of A(S) is a convex polygon with k sides if:

◮ vertices are a subset of arrangement vertices.

slide-11
SLIDE 11

Problem Definition

Given: An arrangement A(S) of line segments S in 2-D

1 2 3 4 5 6 7 a b c d e

A convex k-gon of A(S) is a convex polygon with k sides if:

◮ vertices are a subset of arrangement vertices. ◮ sides are part of input segments.

slide-12
SLIDE 12

Problem Definition

Given: An arrangement A(S) of line segments S in 2-D

1 2 3 4 5 6 7 a b c d e k = 4

A convex k-gon of A(S) is a convex polygon with k sides if:

◮ vertices are a subset of arrangement vertices. ◮ sides are part of input segments.

slide-13
SLIDE 13

Problem Definition

Given: An arrangement A(S) of line segments S in 2-D

1 2 3 4 5 6 7 a b c d e k = 4

A convex k-gon of A(S) is a convex polygon with k sides if:

◮ vertices are a subset of arrangement vertices. ◮ sides are part of input segments.

Goal: count and report all such k-gons.

slide-14
SLIDE 14

Our Results

◮ Count all k-gons in O(n log n + mn) time and O(n2) space

(for constant k)

slide-15
SLIDE 15

Our Results

◮ Count all k-gons in O(n log n + mn) time and O(n2) space

(for constant k)

◮ Report set of all k-gons K in O(|K|) additional time and

O(mn) additional space

slide-16
SLIDE 16

Our Results

◮ Count all k-gons in O(n log n + mn) time and O(n2) space

(for constant k)

◮ Report set of all k-gons K in O(|K|) additional time and

O(mn) additional space Count in time much faster than the number of k-gons :

slide-17
SLIDE 17

Our Results

◮ Count all k-gons in O(n log n + mn) time and O(n2) space

(for constant k)

◮ Report set of all k-gons K in O(|K|) additional time and

O(mn) additional space Count in time much faster than the number of k-gons : Θ(nk)

⌊ n

k ⌋

slide-18
SLIDE 18

Our Results

◮ Count all k-gons in O(n log n + mn) time and O(n2) space

(for constant k)

◮ Report set of all k-gons K in O(|K|) additional time and

O(mn) additional space Count in time much faster than the number of k-gons : Θ(nk)

⌊ n

k ⌋

◮ Counting k-gons is as hard as the 3SUM problem, for k = 3, 4

slide-19
SLIDE 19

Counting k-gons

A vertical line L intersects at most two sides of a k-gon P.

L span(P, L) = (a, b)

slide-20
SLIDE 20

Counting k-gons

A vertical line L intersects at most two sides of a k-gon P.

a b L P span(P, L) = (a, b)

slide-21
SLIDE 21

Counting k-gons

A vertical line L intersects at most two sides of a k-gon P.

a b L span(P, L) = (a, b) P

slide-22
SLIDE 22

Counting k-gons

A vertical line L intersects at most two sides of a k-gon P.

a b L span(P, L) = (a, b) P

◮ O(n2) distinct spans (w.r.t. L) among all k-gons

slide-23
SLIDE 23

Counting k-gons

A vertical line L intersects at most two sides of a k-gon P.

a b L span(P, L) = (a, b) P

◮ O(n2) distinct spans (w.r.t. L) among all k-gons ◮ Suggests a plane sweep based algorithm, key idea:

slide-24
SLIDE 24

Counting k-gons

A vertical line L intersects at most two sides of a k-gon P.

a b L span(P, L) = (a, b) P

◮ O(n2) distinct spans (w.r.t. L) among all k-gons ◮ Suggests a plane sweep based algorithm, key idea:

◮ Assign a k-gon intersecting L to its span

slide-25
SLIDE 25

Counting k-gons

A vertical line L intersects at most two sides of a k-gon P.

a b L span(P, L) = (a, b) P

◮ O(n2) distinct spans (w.r.t. L) among all k-gons ◮ Suggests a plane sweep based algorithm, key idea:

◮ Assign a k-gon intersecting L to its span ◮ Update count as we sweep L across the plane

slide-26
SLIDE 26

Notation

L a b

◮ Open j-gons: All j ≤ k sides start left of L

slide-27
SLIDE 27

Notation

L a b

◮ Open j-gons: All j ≤ k sides start left of L

slide-28
SLIDE 28

Notation

L a b

◮ Open j-gons: All j ≤ k sides start left of L

◮ σ(a, b, j) : Number of open j-gons with span (a, b)

slide-29
SLIDE 29

Notation

L a b σ(a, b, 5) = 2

◮ Open j-gons: All j ≤ k sides start left of L

◮ σ(a, b, j) : Number of open j-gons with span (a, b)

slide-30
SLIDE 30

Notation

L a b

◮ Open j-gons: All j ≤ k sides start left of L

◮ σ(a, b, j) : Number of open j-gons with span (a, b)

◮ Closed k-gons: All k sides end left of L

slide-31
SLIDE 31

Notation

L a b count = 2

◮ Open j-gons: All j ≤ k sides start left of L

◮ σ(a, b, j) : Number of open j-gons with span (a, b)

◮ Closed k-gons: All k sides end left of L

◮ count: number of k-gons left of L

slide-32
SLIDE 32

Algorithm Steps

◮ Set count = 0 and σ(a, b, j) = 0, for all a, b, j

slide-33
SLIDE 33

Algorithm Steps

◮ Set count = 0 and σ(a, b, j) = 0, for all a, b, j ◮ Compute all intersections (Event points)

slide-34
SLIDE 34

Algorithm Steps

◮ Set count = 0 and σ(a, b, j) = 0, for all a, b, j ◮ Compute all intersections (Event points) ◮ For each event from left to right: Perform Updates

slide-35
SLIDE 35

Algorithm Steps

◮ Set count = 0 and σ(a, b, j) = 0, for all a, b, j ◮ Compute all intersections (Event points) ◮ For each event from left to right: Perform Updates ◮ Return count

slide-36
SLIDE 36

Updates at intersection (a, b)

a b pi L c d

slide-37
SLIDE 37

Updates at intersection (a, b)

a b pi L c d

◮ Some k-gons complete

slide-38
SLIDE 38

Updates at intersection (a, b)

a b pi L c d

◮ Some k-gons complete

◮ count += σ(a, b, k)

slide-39
SLIDE 39

Updates at intersection (a, b)

a b pi L c d

◮ Some k-gons complete

◮ count += σ(a, b, k)

◮ A 2-gon begins

slide-40
SLIDE 40

Updates at intersection (a, b)

a b pi L c d

◮ Some k-gons complete

◮ count += σ(a, b, k)

◮ A 2-gon begins

◮ σ(b, a, 2) = 1

slide-41
SLIDE 41

Updates at intersection (a, b)

a b pi c d L

◮ Some k-gons complete

◮ count += σ(a, b, k)

◮ A 2-gon begins

◮ σ(b, a, 2) = 1

◮ Some j-gons grow into j + 1-gons

slide-42
SLIDE 42

Updates at intersection (a, b)

a b pi c L d

◮ Some k-gons complete

◮ count += σ(a, b, k)

◮ A 2-gon begins

◮ σ(b, a, 2) = 1

◮ Some j-gons grow into j + 1-gons

◮ For all segments c above a

slide-43
SLIDE 43

Updates at intersection (a, b)

a b pi c L d

◮ Some k-gons complete

◮ count += σ(a, b, k)

◮ A 2-gon begins

◮ σ(b, a, 2) = 1

◮ Some j-gons grow into j + 1-gons

◮ For all segments c above a

slide-44
SLIDE 44

Updates at intersection (a, b)

a b pi c L d

◮ Some k-gons complete

◮ count += σ(a, b, k)

◮ A 2-gon begins

◮ σ(b, a, 2) = 1

◮ Some j-gons grow into j + 1-gons

◮ For all segments c above a

σ(c, b, j + 1) += σ(c, a, j)

slide-45
SLIDE 45

Updates at intersection (a, b)

a b pi d L c

◮ Some k-gons complete

◮ count += σ(a, b, k)

◮ A 2-gon begins

◮ σ(b, a, 2) = 1

◮ Some j-gons grow into j + 1-gons

◮ For all segments c above a

σ(c, b, j + 1) += σ(c, a, j)

◮ For all segments d below b

slide-46
SLIDE 46

Updates at intersection (a, b)

a b pi c d L

◮ Some k-gons complete

◮ count += σ(a, b, k)

◮ A 2-gon begins

◮ σ(b, a, 2) = 1

◮ Some j-gons grow into j + 1-gons

◮ For all segments c above a

σ(c, b, j + 1) += σ(c, a, j)

◮ For all segments d below b

slide-47
SLIDE 47

Updates at intersection (a, b)

a b pi d L c

◮ Some k-gons complete

◮ count += σ(a, b, k)

◮ A 2-gon begins

◮ σ(b, a, 2) = 1

◮ Some j-gons grow into j + 1-gons

◮ For all segments c above a

σ(c, b, j + 1) += σ(c, a, j)

◮ For all segments d below b

σ(a, d, j + 1) += σ(b, d, j)

slide-48
SLIDE 48

Updates at intersection (a, b)

a b pi c d L

◮ Some k-gons complete

◮ count += σ(a, b, k)

◮ A 2-gon begins

◮ σ(b, a, 2) = 1

◮ Some j-gons grow into j + 1-gons

◮ For all segments c above a

σ(c, b, j + 1) += σ(c, a, j)

◮ For all segments d below b

σ(a, d, j + 1) += σ(b, d, j)

Total O(n) time per intersection

slide-49
SLIDE 49

Updates at intersection (a, b)

a b pi c d L

◮ Some k-gons complete

◮ count += σ(a, b, k)

◮ A 2-gon begins

◮ σ(b, a, 2) = 1

◮ Some j-gons grow into j + 1-gons

◮ For all segments c above a

σ(c, b, j + 1) += σ(c, a, j)

◮ For all segments d below b

σ(a, d, j + 1) += σ(b, d, j)

Total O(n) time per intersection Handles degenerate cases: apply pairwise updates collectively

slide-50
SLIDE 50

Reporting Problem

Goal: Report all k-gons of the output set K.

slide-51
SLIDE 51

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e

slide-52
SLIDE 52

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e (c, a, 2)

Create a vertex for the new open 2-gon

slide-53
SLIDE 53

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e (c, a, 2) (b, a, 3)

2

Add an edge for a j-gon growing into j + 1-gon

slide-54
SLIDE 54

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e (c, a, 2) (b, a, 3) (b, d, 4)

2 3

Add an edge for a j-gon growing into j + 1-gon

slide-55
SLIDE 55

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e (c, a, 2) (b, a, 3) (b, d, 4) (d, a, 2) (e, a, 4)

2 3 4

Add an edge for a j-gon growing into j + 1-gon

slide-56
SLIDE 56

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e (c, a, 2) (b, a, 3) (b, d, 4) (d, a, 2) (e, a, 4) Q = { }

2 3 4

Append vertices for completed k-gons to Q

slide-57
SLIDE 57

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e (c, a, 2) (b, a, 3) (b, d, 4) (d, a, 2) (e, a, 4) Q = { }

2 3 7 4

Append vertices for completed k-gons to Q

slide-58
SLIDE 58

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e (c, a, 2) (d, a, 2) (b, a, 3) (e, a, 4) (b, d, 4)

2 7 4

Q = { }

3

Recursively enumerate all k-gons

slide-59
SLIDE 59

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e (c, a, 2) (d, a, 2) (b, a, 3) (e, a, 4) (b, d, 4)

2 7 4

Q = { }

3

Recursively enumerate all k-gons

slide-60
SLIDE 60

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e (c, a, 2) (d, a, 2) (b, a, 3) (e, a, 4) (b, d, 4)

2 7 4 3

Q = { }

Recursively enumerate all k-gons

slide-61
SLIDE 61

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e (c, a, 2) (d, a, 2) (b, a, 3) (e, a, 4) (b, d, 4)

2 7 4 3

Q = { }

Recursively enumerate all k-gons

slide-62
SLIDE 62

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e (c, a, 2) (d, a, 2) (b, a, 3) (e, a, 4) (b, d, 4)

2 7 4 3

Q = { } ×

Only time respecting paths are valid k-gons

slide-63
SLIDE 63

Reporting Problem

Goal: Report all k-gons of the output set K. Keep track of updates using acyclic digraph G = (V , E, L)

1 2 3 4 5 6 7 a b c d e K = {(1, 2, 4, 6), (1, 2, 3, 7)}

Report all k-gons in O(|K|) additional time

slide-64
SLIDE 64

3SUM Hardness

Reduction from Point-on-3-lines problem

slide-65
SLIDE 65

3SUM Hardness

Reduction from Point-on-3-lines problem Given a set of lines L in plane, is there a point that lies on 3 lines?

slide-66
SLIDE 66

3SUM Hardness

Reduction from Point-on-3-lines problem Given a set of lines L in plane, is there a point that lies on 3 lines? 3SUM − → 3-Points-on-line

dual

− − − − → Point-on-3-lines

slide-67
SLIDE 67

3SUM Hardness

Reduction from Point-on-3-lines problem Given a set of lines L in plane, is there a point that lies on 3 lines? 3SUM − → 3-Points-on-line

dual

− − − − → Point-on-3-lines

◮ Reduction ensures that no two lines in L are parallel

slide-68
SLIDE 68

3SUM Hardness

Reduction from Point-on-3-lines problem Given a set of lines L in plane, is there a point that lies on 3 lines? 3SUM − → 3-Points-on-line

dual

− − − − → Point-on-3-lines

◮ Reduction ensures that no two lines in L are parallel ◮ Compute bounding box B of the arrangement

slide-69
SLIDE 69

3SUM Hardness

Reduction from Point-on-3-lines problem Given a set of lines L in plane, is there a point that lies on 3 lines? 3SUM − → 3-Points-on-line

dual

− − − − → Point-on-3-lines

◮ Reduction ensures that no two lines in L are parallel ◮ Compute bounding box B of the arrangement ◮ Clip the lines around B to obtain an arrangement of segments

slide-70
SLIDE 70

3SUM Hardness

Reduction from Point-on-3-lines problem Given a set of lines L in plane, is there a point that lies on 3 lines? 3SUM − → 3-Points-on-line

dual

− − − − → Point-on-3-lines

◮ Reduction ensures that no two lines in L are parallel ◮ Compute bounding box B of the arrangement ◮ Clip the lines around B to obtain an arrangement of segments

n

3

  • triangles ⇔ no Point-on-3-lines
slide-71
SLIDE 71

3SUM Hardness

Reduction from Point-on-3-lines problem Given a set of lines L in plane, is there a point that lies on 3 lines? 3SUM − → 3-Points-on-line

dual

− − − − → Point-on-3-lines

◮ Reduction ensures that no two lines in L are parallel ◮ Compute bounding box B of the arrangement ◮ Clip the lines around B to obtain an arrangement of segments

n

3

  • triangles ⇔ no Point-on-3-lines
slide-72
SLIDE 72

3SUM Hardness

Reduction from Point-on-3-lines problem Given a set of lines L in plane, is there a point that lies on 3 lines? 3SUM − → 3-Points-on-line

dual

− − − − → Point-on-3-lines

◮ Reduction ensures that no two lines in L are parallel ◮ Compute bounding box B of the arrangement ◮ Clip the lines around B to obtain an arrangement of segments

n

3

  • triangles ⇔ no Point-on-3-lines

n

4

  • quadilaterals ⇔ no Point-on-3-lines
slide-73
SLIDE 73

3SUM Hardness

Reduction from Point-on-3-lines problem Given a set of lines L in plane, is there a point that lies on 3 lines? 3SUM − → 3-Points-on-line

dual

− − − − → Point-on-3-lines

◮ Reduction ensures that no two lines in L are parallel ◮ Compute bounding box B of the arrangement ◮ Clip the lines around B to obtain an arrangement of segments

n

3

  • triangles ⇔ no Point-on-3-lines

n

4

  • quadilaterals ⇔ no Point-on-3-lines

Does not extend to k ≥ 5

slide-74
SLIDE 74

Concluding Remarks

slide-75
SLIDE 75

Concluding Remarks

◮ Introduced the k-gon counting problem

slide-76
SLIDE 76

Concluding Remarks

◮ Introduced the k-gon counting problem ◮ Algorithm for k-gon counting in O(mn) ∈ O(n3) time

slide-77
SLIDE 77

Concluding Remarks

◮ Introduced the k-gon counting problem ◮ Algorithm for k-gon counting in O(mn) ∈ O(n3) time ◮ Reporting in additional O(|K|) time

slide-78
SLIDE 78

Concluding Remarks

◮ Introduced the k-gon counting problem ◮ Algorithm for k-gon counting in O(mn) ∈ O(n3) time ◮ Reporting in additional O(|K|) time ◮ 3SUM hardness for k = 3, 4 ⇒ Significantly better than

O(n2) unlikely

slide-79
SLIDE 79

Concluding Remarks

◮ Introduced the k-gon counting problem ◮ Algorithm for k-gon counting in O(mn) ∈ O(n3) time ◮ Reporting in additional O(|K|) time ◮ 3SUM hardness for k = 3, 4 ⇒ Significantly better than

O(n2) unlikely

◮ Open question: faster algorithms?

slide-80
SLIDE 80

Thanks!