Quadtrees and Octrees - PowerPoint PPT Presentation

1 / 66
About This Presentation
Title:

Quadtrees and Octrees

Description:

The decomposition of the region into four(4) can be resprensented as a ... Computer-aided design. Computer graphics. Databases. Geographic Information Systems ... – PowerPoint PPT presentation

Number of Views:1369
Avg rating:3.0/5.0
Slides: 67
Provided by: facultyK4
Category:

less

Transcript and Presenter's Notes

Title: Quadtrees and Octrees


1
Quadtrees and Octrees
  • Dr. Randy M. Kaplan

2
Introduction
  • Quadtrees
  • Hierarchical
  • Spacial
  • Based on -
  • Recursive decomposition of space

3
Quadtree
  • Representation of 2-dimensional space
  • Space is decomposed using separators
  • Parallel to the coordinate axis
  • Split a region into four(4) regions
  • Southwest
  • Northwest
  • Southeast
  • Northeast

4
Quadtree
  • A node corresponds to the region
  • The decomposition of the region into four(4) can
    be resprensented as a subtree whose -
  • parent is the original region
  • one(1) child for each decomposed region

5
Quadtree
Region of 2D Space
Region of 2D Space
Region of 2D Space
Region of 2D Space
Region of 2D Space
6
Octree
  • 3D Analog to Quadtree
  • Region is split into eight(8) sub-regions
  • using planes parallel to the coordinate axis
  • A region node will have 8 children

7
Octree
8
Octree
9
Octree
10
More Than 3 Dimensions
  • In the case where more than 3 dimensions need to
    be represented the term for the data structure is
  • HYPEROCTREE

11
Quadtree/Octree
  • Allow space to be represented at various levels
    of granularity
  • Allows quick focusing on regions of interest
  • Example
  • Find all points in a dataset that lie within a
    given distance from a query point

12
Quadtree/Octree
  • Find all points in a dataset that lie within a
    given distance from a query point
  • AKA Spherical Region Query

13
Spherical Region Query
  • In the absence of any data structure
  • all points in the dataset will need to be
    analyzed
  • If a quadtree is available, large regions of
    points can be eliminated from the search

14
Quadtree Construction
  • Start with a square, cubic, or hypercubic region
    (depending on dimensionality of the dataset)
  • Decompose the initial region according to one of
    two strategies

15
Quadtree Construction
  • Guide decomposition by input data
  • Guide decomposition by principal of equal
    subdivision

16
Quadtree Construction
  • Guide decomposition by input data
  • Resulting tree size will be proportional to input
  • If all data is available a priori it is possible
    to make the tree height balanced

17
Quadtree Construction
  • Guide decomposition by input data
  • Although the resulting tree has desirable
    properties, it also has some disadvantage, i.e.,
  • Difficult to make the data structure dynamic
  • Deletion of data is difficult

18
Quadtree Construction
  • Decomposition based on equal subdivision
  • Distribution of spacial data determines the
    characteristics of the resulting tree

19
Quadtree Construction
  • Decomposition based on equal subdivision
  • Tree will be height balanced and size will be
    linear when the spatial data is distributed
    uniformly

20
Quadtree Construction
  • Decomposition based on equal subdivision
  • Height and size properties deteriorate as the
    distribution becomes non-uniform

21
Termination Criteria
  • In the subdivision process, when is it time to
    stop subdividing?
  • Two criteria can be used in an OR or AND
    configuration
  • Resolution Requirement
  • Condition on Region Requirement

22
Ubiquity
  • The quadtree is a ubiquitous data structure much
    as the binary tree is also a ubiquitous data
    structure
  • It can be found applied to many different areas
    of spatial computing

23
Ubiquity
  • Computational Geometry
  • Computer-aided design
  • Computer graphics
  • Databases
  • Geographic Information Systems
  • Image processing
  • Pattern recognition

24
Quadtrees for Point Data
  • Set of n points in d dimensional space
  • Principle application
  • Organize multidimensional data
  • Facilitate queries requiring spatial information

25
Quadtrees for Point Data
  • Kinds of queries
  • Range query
  • Spherical region query
  • All nearest neighbors query

26
Range Query
  • Given a range of values for each dimension,
  • find all points that lie within the range
  • Equivalent to finding all points lying within a
    hyper-rectangular region

27
Spherical Region Query
  • Given, point p, radius r
  • Find all the points that lie within a distance r
    from p

28
Nearest Neighbor Query
  • Given n points,
  • find the nearest neighbor of each point within
    the set

29
Point Quadtrees
  • Point quadtree is a natural generalization of the
    binary search tree
  • We will consider the 2-dimensional case
  • Begin with a square region containing all of the
    input points

30
Point Quadtrees
31
Point Quadtrees
  • How to Make a Quadtree
  • Choose an arbitrary point

32
Point Quadtrees
  • The point becomes the root of the tree

33
Point Quadtrees
  • Use lines that are parallel to the coordinate
    axis
  • Draw these lines to intersect with the chosen
    point to divide the region

34
Point Quadtrees
  • Each of the subregions are recursively divided in
    a similar way
  • In this way the point quadtree is produced

35
Point Quadtrees
  • When a point is on a boundary it is necessary to
    adopt some conventions to specify to which region
    the point belongs
  • Points lying on the left and bottom edges of a
    region are considered included in the region

36
Point Quadtrees
  • Points lying on the left and bottom edges of a
    region are considered included in the region
  • Points lying on the right and top edges of a
    region are considered not to be part of the region

37
Point Quadtrees
  • When all of the points are known in advance, it
    is possible to construct a balanced tree

38
Point Quadtrees
  • A simple way to accomplish this is to sort the
    points with one of the coordinates as the primary
    key
  • Call this primary key x
  • The other coordinate, y, is the secondary tree
  • This key is also used to sort the data

39
Point Quadtrees
  • The first subdivision point is the median of the
    sorted data
  • This insures that none of the children of the
    root node receives more than half the points

40
Point Quadtrees
  • O(n) time will be used to sort the data contained
    in each of the four subregions
  • The total work at every level of the tree is
    bounded by O(n)
  • At most there will be O(log n) levels in the tree
  • A height balanced quadtree can be built in
    O(nlogn) time

40
41
Point Quadtrees
  • Search
  • To search for a point, compare the point at the
    root with the point to find
  • If the points are different, then the point to
    search for is used to determine where to go next

42
Point Quadtrees
  • Search
  • The search continues by recursively calling the
    search procedure with the subregions root as the
    root of the new tree to search
  • The search stops if the point is found or if a
    leaf node is reached

43
Point Quadtrees
  • Search
  • The algorithm for search is O(h) where h is the
    height of the tree

44
Point Quadtrees
  • Insertion
  • Insertion is accomplished by search for the point
    in the tree
  • The search will end at a leaf
  • The leaf node now is a region that contains two
    points

45
Point Quadtrees
  • Insertion
  • The leaf node now is a region that contains two
    points
  • One point is chosen of the two to subdivide the
    region
  • The point becomes the child of the node
    representing the region where the point belongs

46
Point Quadtrees
  • The run time for insertion is bounded by O(h)
  • In d dimensions the run time is bounded by O(dh)

47
Point Quadtrees
  • Deletion
  • The node is located by search
  • To delete the node it is necessary to locate
    another point that will take its place
  • This is where the complexity of the algorithm for
    deletion lies

48
Region Quadtrees
  • A region quadtree for n points in d dimensions is
    defined as follows
  • Consider that we have a hypercube large enough to
    enclose all of the points
  • The region is represented by the root of the
    d-dimensional quadtree

49
Region Quadtrees
  • The region is subdivided into 2d subregions of
    equal size
  • A subregion is subdivided by bisecting along each
    dimension
  • Each of these regions containing at least one
    point is represented as a child of the root node

50
Region Quadtrees
  • Each of the regions that contain at least one
    point is represented as the child of the root
    node
  • The same procedure is recursively applied to each
    child of the root node
  • The process is terminated when a region contains
    only a single point

51
Region Quadtrees
  • This data structure is known as the
  • point region quadtree or
  • PR-quadtree

52
Region Quadtrees
53
2-D Polygonal Objects
  • Suppose we restrict ourselves to 2-D polygonal
    objects
  • If we recursively divide the tree nodes yields
    minimum size nodes all along the edges of the
    polygon
  • The resulting tree is large and the number of
    non-divisible cells is proportional to the
    polygons perimeter

54
Algorithm
  • The algorithm for building the tree from boundary
    information is simple
  • Recognition of boundaries from the quadtree is
    complex
  • The algorithm must infer straight edges from
    staircaselike contours

55
A Different Quadtree
  • In this quadtree, EDGE nodes are considered,
    including -
  • WHITE nodes
  • BLACK nodes
  • GRAY nodes

56
EDGE Nodes
  • Partly inside and partly outside the object
  • The piece of the object boundary that is
    contained in the node is a simple straight segment

57
Features of Quadtrees
  • (1) The resulting trees are more compact and
    shorter than the usual quadtree
  • (2) The recomputation of the boundary model is
    easy and exact

58
Quadtree Representation
  • The quadtree representation has two data
    structures
  • First - a tree structure in which data is stored
    linearly by a depth method
  • The second is a sequential list storing the edges
    that define the polygonal object boundary

59
An Example
60
Compact Representation
  • We will be using a compact representation for the
    tree - a so-called list representation
  • The primitive elements of the list will be X, W,
    G, B

61
Compact Representation
  • W
  • WHITE is used if the quadrant is entirely outside
    the object the node represents

62
Compact Representation
  • B
  • BLACK if the quadrant is entirely inside the
    object boundary

63
Compact Representation
  • X
  • EDGE if and only if one boundary edge and only
    one edge crosses the quadrant
  • EDGE nodes have a second field storing a pointer
    to the edge crossing the quadrant

64
Compact Representation
  • G
  • A node is GRAY when more than one boundary edge
    crosses the quadrant
  • Represent either terminal or non-terminal nodes

65
Compact Representation
((X(X(WWGW)XX)((WWWG)XWX)B)XX ((B(XXBG)BX)W(XXX(GW
WW))W))
66
Compact Representation
The coding of quadrants is done in this order.
((X(X(WWGW)XX)((WWWG)XWX)B)XX ((B(XXBG)BX)W(XXX(GW
WW))W))
Write a Comment
User Comments (0)
About PowerShow.com