Top Banner
Quadtrees Raster and vector
22

Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Dec 18, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

QuadtreesRaster and vector

Page 2: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Quadtrees

• Finkel and Bentley, 1974• Raster structure: divides space, not objects• Form of block coding: compact storage of a

large 2-dimensional array• Vector versions exist too

Page 3: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Quadtrees, the idea

NW NE SW SE

NW NE

SW SE

1, 4, 16, 64, 256nodes

Page 4: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Quadtrees, the idea

NW NE SW SE

NW NE

SW SE

Choropleth raster map

Page 5: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Quadtrees

• Grid with 2k times 2k pixels• Depth is k +1• Internal nodes always have 4 children• Internal nodes represent a non-homogeneous

region• Leaves represent a homogeneous region and

store the common value (or name)

Page 6: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Quadtree complexity theorem

• A subdivision with boundary length r pixels in a grid of 2k times 2k gives a quadtree with O(k r) nodes.

• Idea: two adjacent, different pixels “cost” at most 2 paths in the quadtree.

Page 7: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Overlay with quadtrees

Water Acid rain withPH below 4.5

Page 8: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Overlay with quadtrees

Page 9: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Result of overlay

Page 10: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Overlay algorithm

• If color Q1 is specified, and Q2 is a leaf,then return a leaf for Q3 with as color the combination of those of Q1 and Q2

• If color Q2 is specified, and Q1 is a leaf,then return a leaf for Q3 with as color the combination of those of Q1 and Q2

• If Q1 and Q2 are both a leaf,then return a leaf for Q3 with as color the combination of those of Q1 and Q2

Page 11: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Overlay algorithm

• If color Q1 is specified or Q1 is a leaf, and Q2 is an internal nodethen recurse in the four subtrees of Q2 (with the color of Q1 as specified)

• If color Q2 is specified or Q2 is a leaf, and Q1 is an internal nodethen recurse in the four subtrees of Q1 (with the color of Q2 as specified)

• If Q1 and Q2 are both internal nodesthen recurse in the four corresponding subtrees of Q1 and Q2

Page 12: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Overlay, efficiency

• Result is quadtree Q3 that represents overlay

• Assume n nodes in Q1 and m nodes in Q2: O(n+m) time

• If Q3 need only contain the overlay where Q1 has a particular theme, then it can be done more efficiently by pruning

Page 13: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Quadtree construction from raster, I

• Construct complete quadtree on all pixels• Merge bottom-up groups of four with same

attribute

• Disadvantage: Temporarily a lot of storage needed (quadtree on all pixels), and not efficient in time

Page 14: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Quadtree construction from raster, II

• Construct quadtree top-down and recursively • Merge four subtrees immediately (when

returning from recursion) into a leaf if they are four leaves with the same attribute

Page 15: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Various queries

• Point location: trivial• Windowing: descend into subtree(s) that

intersect query window • Traversal boundary polygon: up and down in

the quadtree

Page 16: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Vector quadtree

• PM quadtree in naming of Samet• Divide each square if there are:

- 2 or more vertices inside- a vertex and an edge inside that are not incident- 2 (or more) edges inside, unless these edges are all incident to the same vertex and this vertex is also in the square

Page 17: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Leaf in vector quadtree

• Empty (inside a region; pointer to cell)• One edge (pointer to edge in leaf)• One vertex with incident edges (pointer to

vertex in leaf)

Page 18: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Example vector quadtree

Page 19: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Point location in vector quadtree

• Go down quadtree to leaf that contains the query point

• At the leaf, resolve the query

f v

e

O(1) time O(degree(v)) timeO(1) time

Page 20: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Complexity vector quadtree

• Cannot be expressed in the number of stored objects only

• Depends on inter-distance of vertices compared to region size

• Depends on “accidental” distance of a vertex to a side of a square

Page 21: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Alleviating the problem

• Allow a small number (e.g. 3 or 4) of points or independent edges in a square

• Do not split squares beyond a certain size

Page 22: Quadtrees Raster and vector. Quadtrees Finkel and Bentley, 1974 Raster structure: divides space, not objects Form of block coding: compact storage of.

Summary

• Raster quadtree: simple structure, simple map overlay, simple queries

• Vector quadtree: possibly useful for efficient access, no performance guarantees