Download Tu 28 February 2006

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Binary search tree wikipedia , lookup

Quadtree wikipedia , lookup

Interval tree wikipedia , lookup

Transcript
Geometric methods in shape and pattern recognition
Lecture 5: 28-02-2006 15:15-17:00
Prof. dr. H. Alt
Volkan Çardak
0246816
Voronoi diagram of a set of line segments (continuation 1.3.5)
There are two cases for finding the shortest distance d from a line segment e to a point p :
 Look at the slab, whose boundaries are formed by lines which go perpendicular from the
endpoints of e. If p lies in this slab, then d is the length of the line segment which is
perpendicular from e to p.
 If p is not present in this stroke, than d is the distance to the closest endpoint.
For visualization see figure 1 below:
figure 1.
Algorithms which compute the Voronoi diagram of points are well known and there are many
attempts how to make implementations consistent and effective. A newer problem is to deal
with generator sets containing points and line-segments. This yields to much more complex
bisectors and distance calculations.
The Voronoi diagram of a set of line segments consists of / segments of
bisectors between : - two points ( straight )
- two lines ( straight )
- point and line (parabolic)
For visualization see figure 2 below:
figure 2.
Facts:
- The size (# edges, vertices, facets) of the Voronoi Diagram of n line segments is O( n ).
- it can be computed in O( n log n ) time, similar to the one for points.
1.3.6 Searching planar subdivisions
A planar subdivision is a straight line embedding of a planar graph (possibly with points “at
infinity”).
Fact: Given a planar subdivision a data structure can be constructed such that for any query
with some point q Є R² it can be determined in time O( log n ) which face contains q.
Example in 1D
How can we say which point is in which facet of the subdivision?
- First sort the data in an array in O (n log n) time.
– Then we can use the binary search algorithm for searching in a data set in O( log n ) time.
- So the actual location of a point can be done in O( log n ) .
Application : “Post office problem”
Given a set S of points in the plane, create a data structure such that for any query point q
the closest point in S can be determined efficiently!
Computing the distance of q to all points in S it would take O ( n ) time.
Solution :
1. Construct a Voronoi diagram of S, it forms a planar subdivision.
2. Construct a search structure for this planar subdivision.
3. Find the facet containing the query point and, thus, the closest point.
Steps 1 and 2 are the pre-processing steps which both take O (n log n ) time.
Step 3, the query time can be done in O( log n ).
1.4 Line sweep (for an applet see: http://www.lupinho.de/gishur/html/Sweeps.html)
a paradigm to construct/design geometric algorithms in order to solve geometric problems
(e.g. intersection points of a set of n line segments.)
-
Imagine a vertical line (not necessarily a vertical line) that moves from far left to far
right across the input scene.
-
Maintain a data structure about the current situation on the line. This is called the
“sweep line status” (SLS).
-
Maintain a second data structure with all the x-coordinates (=position of the
sweepline where the SLS changes). This is called the “event point schedule” (EPS).
This method is faster than calculating each intersection possibility of 2 line segments. This
would be O( n² ) .
Let’s have a deeper look at the components of the line sweep paradigm:
SLS = sequence of line segments intersecting the sweep line in sorted order. The
search,insert,delete operations have to be done at the SLS data structure. So now we
need an efficient data structure where we can perform these operations relatively
cheap. To do this we can use a balanced binary search tree (e.g AVL-tree).
Initialization of this data structure would be the empty tree. With this data structure
we can support insert/delete/search in O( log n ) time.
EPS = Initialization are the right and left endpoints of line segments. Here are detected
intersection points inserted in the data structure. The points that are processed are
deleted. The possible data structures would be the heap or again the balanced binary
search tree.
We always want to find the next event point (insertion at right place, deletion of
minimum).
For overview a pseudo code of Line Sweep:
Events:

adding a new segment:
- insert into SLS
- determine it’s neighbours
- if there are intersection points with the neighbours:
report them & enter these into EPS

deleting a new segment:
- delete from SLS
- for new neighbourhoods neighbours:
if there are intersection points with the neighbours:
report them & enter these into EPS

processing intersection point: -swap two segments in SLS
- for the new neighbourhoods:
if there are intersection points with the neighbours:
report them & enter them into EPS
Analysis. The construction of the initial event schedule requires sorting all endpoints by
their x-coordinates and constructing a search tree for this sorted order. This takes
O (n log n) time. The runtime per event is O (log n). If there are k intersection points the
total number of events is k+2n, one for each endpoint and each intersection point. Hence,
the running time of the algorithm is O (( k + n ) log n). A drawback of this algorithm is
that if k is large than this algorithm is not efficient. Then it would be more efficient to use
the brute force algorithm. If k is significantly smaller than n²/ log n this paradigm is more
efficient.