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.

Slides:



Advertisements
Similar presentations
Nearest Neighbor Search
Advertisements

INTERVAL TREE & SEGMENTATION TREE

Spatial Data Structures Hanan Samet Computer Science Department
S. Sudarshan Based partly on material from Fawzi Emad & Chau-Wen Tseng
Tree Data Structures &Binary Search Tree 1. Trees Data Structures Tree  Nodes  Each node can have 0 or more children  A node can have at most one parent.
CS144: Spatial Index. Example Dataset Grid File (2 points per bucket)
Searching on Multi-Dimensional Data
Do Now:.
Clustering & image segmentation Goal::Identify groups of pixels that go together Segmentation.
Computer Graphics1 Quadtrees & Octrees. Computer Graphics2 Quadtrees n A hierarchical data structure often used for image representation. n Quadtrees.
Quadtrees Raster and vector.
Multiple-key indexes Index on one attribute provides pointer to an index on the other. If V is a value of the first attribute, then the index we reach.
1Ellen L. Walker Segmentation Separating “content” from background Separating image into parts corresponding to “real” objects Complete segmentation Each.
Spatial Information Systems (SIS) COMP Raster-based structures (2) Data conversion.
1 Red-Black Trees. 2 Black-Height of the tree = 4.
Spatial Information Systems (SIS) COMP Raster-based structures (1)
Spatial Indexing I Point Access Methods.
Binomial Heaps. Min Binomial Heap Collection of min trees
CSC 212 Lecture 19: Splay Trees, (2,4) Trees, and Red-Black Trees.
B-trees (Balanced Trees) A B-tree is a special kind of tree, similar to a binary tree. However, It is not a binary search tree. It is not a binary tree.
Chapter 9.  Mathematical morphology: ◦ A useful tool for extracting image components in the representation of region shape.  Boundaries, skeletons,
Data Structures CSCI 2720 Spring 2007 Balanced Trees.
Data Structures Balanced Trees 1CSCI Outline  Balanced Search Trees 2-3 Trees Trees Red-Black Trees 2CSCI 3110.
Lossless Compression CIS 465 Multimedia. Compression Compression: the process of coding that will effectively reduce the total number of bits needed to.
2-3 Tree. Slide 2 Outline  Balanced Search Trees 2-3 Trees Trees.
Fall 2006 CSC311: Data Structures 1 Chapter 10: Search Trees Objectives: Binary Search Trees: Search, update, and implementation AVL Trees: Properties.
Spatial Indexing Techniques Introduction to Spatial Computing CSE 5ISC Some slides adapted from Spatial Databases: A Tour by Shashi Shekhar Prentice Hall.
Trees. 2 Root leaf CHAPTER 5 3 Definition of Tree n A tree is a finite set of one or more nodes such that: n There is a specially designated node called.
Red Black Trees Top-Down Deletion. Recall the rules for BST deletion 1.If vertex to be deleted is a leaf, just delete it. 2.If vertex to be deleted has.
The Present. Outline Index structures for in-memory Quad trees kd trees Index structures for databases kdB trees Grid files II. Index Structure.
Machine Vision ENT 273 Regions and Segmentation in Images Hema C.R. Lecture 4.
1 Binary Search Trees   . 2 Ordered Dictionaries Keys are assumed to come from a total order. New operations: closestKeyBefore(k) closestElemBefore(k)
Red-Black Trees Bottom-Up Deletion. Recall “ordinary” BST Delete 1.If vertex to be deleted is a leaf, just delete it. 2.If vertex to be deleted has just.
Morphological Image Processing (Chapter 9) CSC 446 Lecturer: Nada ALZaben.
UNC Chapel Hill M. C. Lin Geometric Data Structures Reading: Chapter 10 of the Textbook Driving Applications –Windowing Queries Related Application –Query.
1 Red-Black Trees. 2 A Red-Black Tree with NULLs shown Black-Height of the tree = 4.
Machine Vision ENT 273 Lecture 4 Hema C.R.

Data Structures Balanced Trees CSCI 2720 Spring 2007.
Red-Black Trees v z Red-Black Trees Red-Black Trees
Red-Black Trees 5/17/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Red-Black Trees 5/22/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
IP Routers – internal view
CISC220 Fall 2009 James Atlas Lecture 13: Binary Trees.
Lecture 17 Red-Black Trees
Red-Black Trees v z Red-Black Trees 1 Red-Black Trees
CHAPTER 4 Trees.
Red-Black Trees Bottom-Up Deletion.
Red-Black Trees Bottom-Up Deletion.
The Quad tree The index is represented as a quaternary tree
Mean Shift Segmentation
Data Structures Balanced Trees CSCI
Red-Black Trees Bottom-Up Deletion.
TCSS 342, Winter 2006 Lecture Notes
Wednesday, April 18, 2018 Announcements… For Today…
Red-Black Trees v z Red-Black Trees 1 Red-Black Trees
Red-Black Trees v z Red-Black Trees Red-Black Trees
Segment Trees Basic data structure in computational geometry.
Red-Black Trees Bottom-Up Deletion.
Quadtrees 1.
Red-Black Trees.
Red Black Trees Top-Down Deletion.
Red-Black Trees Bottom-Up Deletion.
Red-Black Trees Bottom-Up Deletion.
(2,4) Trees /6/ :26 AM (2,4) Trees (2,4) Trees
Multidimensional Search Structures
Red Black Trees Top-Down Deletion.
Binary Search Trees < > = Dictionaries
Presentation transcript:

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

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 Remaining entries are 0.

Image Operations Rotation. Rotate 90 degrees clockwise.

Scaling Expansion.  Each pixel is replaced by a 2 k x 2 k window of pixels of the same intensity. Shrinking.  Each 2 k x 2 k window is replaced by a pixel whose intensity is some function of that of the window pixel intensities.

Shrinking Example k = 1. >= 2 white pixels in 2 1 x 2 1 window => white pixel.

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 2 k image. The children of a node that represents a 2 q x 2 q region represent its 4 2 q-1 x 2 q-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 NWSW NW SWSE NE SE

Quad Tree Example NW SWSE NE

Quad Tree Example NW SWSE NE

Quad Tree Example NW SWSE 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 2 q x 2 q region represent its 8 2 q-1 x 2 q-1 x 2 q-1 subregions.

From Matrix To Quad Tree 2 k x 2 k 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.

From Matrix To Quad Tree If k > 0, recursively construct quad trees for the four quadrants. NW SWSE NE

From Matrix To Quad Tree If the 4 quad tree roots are all black (white), return a single node quad tree with a black (white) root. Otherwise, return a quad tree with a gray root whose subtrees are the quadrant quad trees. NW SWSE NE

Complexity Let t(k) be the time to construct the quad tree of a 2 k x 2 k 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) =  (4 k ) =  (#pixels in matrix).

From Quad Tree To Matrix Run divide-and-conquer algorithm for matrix to quad tree transformation backwards. t(k) =  (4 k ) =  (#pixels in matrix).

Clockwise Rotation By 90 Degrees NENW SW

Clockwise Rotation By 90 Degrees NENW SW

Recursive Algorithm If root is a leaf, return. Rotate the children of the root.  (NW, NE, SE, SW)  (SW, NW, NE, SE) Recursively perform the rotation in the subtrees of the root. Complexity is  (size of quad tree).  Quad tree size = # nodes. Quad tree size is usually substantially less than matrix size.

Other Rotations Clockwise rotations by 180 and 270 degrees are similar. Counterclockwise rotations by 90, 180, and 270 degrees are similar. Rotation by 360 degrees is null.

Shrinking k = 1. >= 2 white pixels in 2 1 x 2 1 window => white pixel.

Shrinking k = 1. >= 2 white pixels in 2 1 x 2 1 window => white pixel.

Shrinking k = 1. >= 2 white pixels in 2 1 x 2 1 window => white pixel.

Shrinking k = 1. >= 2 white pixels in 2 1 x 2 1 window => white pixel. NW SWSE NE

Algorithm To Shrink (k = 1) Root represents a 1 x 1 region => return. Root represents a 2 x 2 region.  Root is a leaf => return.  Color the root white if it has >= 2 white children.  Otherwise color the root black.  Make root a leaf and return. Root represents a 2 k x 2 k, k > 1, region.  Shrink subtrees (if any) of root.  Recolor root if all subtrees now have same color. Complexity is  (size of quad tree).

Union Rules.  Do a pairwise union of corresponding pixels in the two images.  Union is white iff at least one pixel of the pair is white.

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(min{|A|, |B|}). AB

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(min{|A|, |B|}). AB