Quad Trees - Advanced Data Structures - Lecture Slides, Slides of Computer Science

These are the Lecture Slides of Advanced Data Structures which includes Split Algorithm, Unbalanced Binary Search Trees, Forward Pass, Forward Pass Example, Backward Cleanup Pass, Retrace Path, Current Nodes, Roots of Respective Tries, Branch Nodes etc. Key important points are: Quad Trees, Network Firewalls, Destination Prefix, Binary Images, Example Binary Image, Image Operations, Pixels of Same Intensity, Scaling, Shrinking Example, Union and Intersection

Typology: Slides

2012/2013

Uploaded on 03/19/2013

dharmakeerti
dharmakeerti 🇮🇳

4.2

(27)

89 documents

1 / 17

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Quad Trees
Region data vs. point data.
Roads and rivers in a country/state.
Which rivers flow through Florida?
Which roads cross a river?
Network firewalls.
(source prefix, destination prefix, action)
(01*, 110*, drop packet)
source
dest 815
24
27
Quad Trees
Binary images.
Image region is divided into cells called pixels.
Each pixel is either black (0, background) or white
(1).
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Quad Trees - Advanced Data Structures - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Quad Trees

  • Region data vs. point data.
  • Roads and rivers in a country/state. ƒ Which rivers flow through Florida? ƒ Which roads cross a river?
  • Network firewalls.

ƒ (source prefix, destination prefix, action) ƒ (01, 110, drop packet)

source

dest 8 15

24

27

Quad Trees

  • Binary images.

ƒ Image region is divided into cells called pixels. ƒ Each pixel is either black ( 0 , background) or white ( 1 ).

Example Binary Image

1 1 1 1 1 1 1 1 1 1 1

1 1

Remaining entries are 0.

Image Operations

  • Rotation.

Rotate 90 degrees clockwise.

Union & Intersection

  • Image1 = roads.
  • Image2 = rivers.
  • Union(Image1, Image2) = roads and rivers.
  • Intersection(Image1,Image2) = places where a road crosses a river => bridge or tunnel.

Image Representation

  • n x n matrix.

ƒ Θ(n^2 ) space. ƒ Θ(n^2 ) time for rotation, scaling, union, intersection, and so on.

  • Quad tree. ƒ O(n^2 ) space. ƒ O(n^2 ) time for rotation, scaling, union, intersection, and so on. ƒ For some images, the space and time could be as little as O(1) (e.g., all white or all black images).

Quad Tree

  • Degree 4 tree (each node has up to 4 children).
  • Each node represents a portion of the image.
  • Root node represents entire 2 k^ x 2k^ image.
  • The children of a node that represents a 2 q^ x 2q region represent its 4 2q-1^ x 2q-1^ subregions.

Quad Tree

  • Each node has one of the colors white, black, gray. ƒ White (black) => all pixels in node’s region are white (black). ƒ Gray => at least one black and at least one white.
  • White and black nodes have no children.
  • Gray nodes have 4 children each.

Quad Tree Example

NW

SW SE

NE

Quad Tree Example

NW

SW SE

NE

Oct Tree

  • Extension of quad tree to the representation of 3 -d images.
  • Degree 8 tree (each node has up to 8 children).
  • The children of a node that represents a 2 q^ x 2q^ x 2q region represent its 8 2q-1^ x 2q-1^ x 2q-1^ subregions.

From Matrix To Quad Tree

  • 2 k^ x 2k^ binary matrix.
  • If k = 0, return a single-node quad tree. ƒ Root is white if pixel is 1. ƒ Root is black if pixel is 0.

Complexity

  • Let t(k) be the time to construct the quad tree of a 2 k^ x 2k^ binary image (matrix).
  • t(0) = c, where c is some constant.
  • t(k) = 4t(k–1) + d, where d is some constant and k > 1.
  • t(k) = Θ(4k) = Θ(#pixels in matrix).

From Quad Tree To Matrix

  • Run divide-and-conquer algorithm for matrix to quad tree transformation backwards.
  • t(k) = Θ(4k) = Θ(#pixels in matrix).

Clockwise Rotation By 90 Degrees

NW NE

SW NW

Clockwise Rotation By 90 Degrees

NW NE

SW NW

Shrinking

  • k = 1.
  • = 2 white pixels in 21 x 2^1 window => white pixel. NW

SW SE

NE

Shrinking

  • k = 1.
  • = 2 white pixels in 21 x 2^1 window => white pixel. NW

SW SE

NE

Shrinking

  • k = 1.
  • = 2 white pixels in 21 x 2^1 window => white pixel. NW

SW SE

NE

Shrinking

  • k = 1.
  • = 2 white pixels in 21 x 2^1 window =>

    white pixel. NW

SW SE

NE

Recursive Union(A,B)

  • root(A) (root(B)) is white => return A (B).
  • root(A) (root(B)) is black => return B (A).
  • Both have a gray root. ƒ Pairwise union the subtrees of A and B. ƒ If all four of the returned subtrees have a white root, return a single node tree with a white root. ƒ Otherwise return a tree with a gray root and the four returned subtrees as its subtrees.
  • Complexity is O(|A| + |B|).

A B

Intersection

  • Rules. ƒ Do a pairwise intersection of corresponding pixels in the two images. ƒ Intersection is white iff both pixels of the pair are white.

Recursive Intersection(A,B)

  • root(A) (root(B)) is black => return A (B).
  • root(A) (root(B)) is white => return B (A).
  • Both have a gray root. ƒ Pairwise intersect the subtrees of A and B. ƒ If all four of the returned subtrees have a black root, return a single node tree with a black root. ƒ Otherwise return a tree with a gray root and the four returned subtrees as its subtrees.
  • Complexity is O(|A| + |B|).

A B