Top Banner
Quadtrees II Algorithms for GIS Laura Toma Bowdoin College
42

Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

May 05, 2018

Download

Documents

dodiep
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 II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

QuadtreesII

Algorithms for GIS

Laura Toma

Bowdoin College

Page 2: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

Applications of quadtrees

Page 3: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

Applications of quadtrees

• Hundreds of papers • Specialized quadtrees

• customized for specific types of data (images, edges, polygons) • customized for specific applications • customized for large data

• Used to answer queries on spatial data such as: • point location • nearest neighbor (NN) • k-NNs • range searching • find all segments intersecting a given segment • meshing • …

Page 4: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 5: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=?

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 6: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 7: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=?

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 8: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=?

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 9: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=?

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 10: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 11: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

neighbor of the parent

Page 12: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=?

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 13: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=NULL

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 14: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=?

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 15: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 16: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=?

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 17: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=?

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

Page 18: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NORTH_Neighbor=?

Example: Neighbor finding

Given a node v and a direction (N, S, E, W) find a node v’ such that region(v’) is adjacent to region(v) in the given direction.

• two regions (squares) are adjacent iff they share an edge

• try to find a node v’ at the same depth as v

• if not possible, find the deepest

Page 19: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

• try to find a node v’ at the same depth as v • if not possible, find the deepest

NW SW NE SE

…..NORTH_Neighbor=?

Visualizing it on the tree..

Page 20: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

• try to find a node v’ at the same depth as v • if not possible, find the deepest

NW SW NE SE

…..NORTH_Neighbor=?

Visualizing it on the tree..

Page 21: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

• try to find a node v’ at the same depth as v • if not possible, find the deepest

NW SW NE SE

…..NORTH_Neighbor=?

Visualizing it on the tree..

Page 22: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

• try to find a node v’ at the same depth as v • if not possible, find the deepest

NW SW NE SE

…..NORTH_Neighbor=?

Visualizing it on the tree..

Page 23: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

• try to find a node v’ at the same depth as v • if not possible, find the deepest

NW SW NE SE

…..NORTH_Neighbor=?

Visualizing it on the tree..

Page 24: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

• try to find a node v’ at the same depth as v • if not possible, find the deepest

NW SW NE SE

…..NORTH_Neighbor=?

Visualizing it on the tree..

Page 25: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

• try to find a node v’ at the same depth as v • if not possible, find the deepest

NW SW NE SE

…..NORTH_Neighbor=?

Visualizing it on the tree..

Is the North_neighbor always a sibling or an uncle?

Page 26: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NW SW NE SE

….. …..

Visualizing it on the tree..

• try to find a node v’ at the same depth as v • if not possible, find the deepest Could be a nephew/niece, but we prefer the sibling..

Page 27: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

• try to find a node v’ at the same depth as v • if not possible, find the deepest

NW SW NE SE

…..NORTH_Neighbor=?

Visualizing it on the tree..

Come up with an example where the search for a North_neighbor is a great-uncle

Page 28: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

Come up with an example where the North_neighbor is a

• great-uncle.

• great-great-uncle • …

Example: Neighbor finding

Page 29: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NW SW NE SE

Page 30: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NW SW NE SE

Page 31: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NW SW NE SE

Page 32: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

//input: a node v in a quadtree

//output: the deepest node v’ whose depth is at most the depth of v such that region(v’) is a north-neighbor of region(v), and NULL if there is no such node

North_Neighbor(v) • if v==root: … • if v==SW-child of parent(v):… • if v==SE-child of parent(v): …

//if we reached here, v must be NW or NE child • x <—- North_Neighbor(parent(v))

• if x is NULL or a leaf: • .…

• else: • …..

Example: Neighbor finding

Page 33: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

//input: a node v in a quadtree

//output: the deepest node v’ whose depth is at most the depth of v such that region(v’) is a north-neighbor of region(v), and NULL if there is no such node

North_Neighbor(v) • if v==root: return NULL • if v==SW-child of parent(v): return NW-child of parent(v) • if v==SE-child of parent(v): return NE-child of parent(v)

//if we reached here, v must be NW or NE child • x <—- North_Neighbor(parent(v))

• if x is NULL or a leaf: return x • else:

• if v ==NW-child of parent(v): return SW-child(x) • else: return SE-child(x)

Example: Neighbor finding

Page 34: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

//input: a node v in a quadtree

//output: the deepest node v’ whose depth is at most the depth of v such that region(v’) is a north-neighbor of region(v), and NULL if there is no such node

North_Neighbor(v) • if v==root: return NULL • if v==SW-child of parent(v): return NW-child of parent(v) • if v==SE-child of parent(v): return NE-child of parent(v)

//if we reached here, v must be NW or NE child • x <—- North_Neighbor(parent(v))

• if x is NULL or a leaf: return x • else:

• if v ==NW-child of parent(v): return SW-child(x) • else: return SE-child(x)

Example: Neighbor finding

give an example that would trigger several recursive calls

Page 35: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

More applications

• Used to answer queries on spatial data such as: • point location • nearest neighbor (NN) • k-NNs • range searching • find all segments intersecting a given segment • meshing • …

How would you do these?

Page 36: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NN=?

Page 37: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

NN=?

Page 38: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

find all points in this range

Page 39: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

find all points in this range

Page 40: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

Applications

• Image analysis/compression

Page 41: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific

Applications

• Used for fast rendering (LOD) • Store data at various levels of detail, using a quadtree

• Bottom level has full resolution, level above it has lower resolution, and so on • This can be done so that the total amount of data stored is still O(n) (that is, no blowup due to storing multiple levels)

• Render scene at a resolution dependent on its distance from the viewpoint • when rendering an object, select the appropriate level based on its distance from viewpoint

Page 42: Quadtrees II - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_q… · Applications of quadtrees • Hundreds of papers • Specialized quadtrees • customized for specific