Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

1 Binary Space Partition Trees ©Anthony Steed, Yiorgos Chrysanthou
Collisions and Intersections When objects move, test for collision. When projecting surfaces, check for intersections. (Many slides adapted from Amitabh.
Nearest Neighbor Search

Searching on Multi-Dimensional Data
03/12/02 (c) 2002 University of Wisconsin, CS559 Last Time Some Visibility (Hidden Surface Removal) algorithms –Painter’s Draw in some order Things drawn.
CSE 381 – Advanced Game Programming Scene Management
Clustering & image segmentation Goal::Identify groups of pixels that go together Segmentation.
Korea Univ. Graphics Lab. 3D Game Engine Design Chapter 12. Spatial Sorting Chung Ji Hye
Computer Graphics1 Quadtrees & Octrees. Computer Graphics2 Quadtrees n A hierarchical data structure often used for image representation. n Quadtrees.
CS447/ Realistic Rendering -- Solids Modeling -- Introduction to 2D and 3D Computer Graphics.
1 Dr. Scott Schaefer Hidden Surfaces. 2/62 Hidden Surfaces.
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.
Introduction General Data Structures - Arrays, Linked Lists - Stacks & Queues - Hash Tables & Binary Search Trees - Graphs Spatial Data Structures -Why.
A lion in the desert How do you find a lion in the desert? How about when you have a predicate that tells you if the lion is in front or behind a separating.
Hidden Surface Elimination Wen-Chieh (Steve) Lin Institute of Multimedia Engineering I-Chen Lin’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals.
1 CSCE 441: Computer Graphics Hidden Surface Removal (Cont.) Jinxiang Chai.
Introduction General Data Structures - Arrays, Linked Lists - Stacks & Queues - Hash Tables & Binary Search Trees - Graphs Spatial Data Structures -Why.
1 Clipping and Hidden Surfaces CS-184: Computer Graphics Prof. James O’Brien.
A lion in the desert How do you find a lion in the desert? How about when you have a predicate that tells you if the lion is in front or behind a separating.
Estruturas de Dados Espaciais MC-930 MO-603. Speeding Up Ray Tracing.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
10/02/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Octrees.
Hidden Surface Removal
BSP Trees, Quadtrees & Octrees Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, January 28, 2004.
Data Structures for Computer Graphics Point Based Representations and Data Structures Lectured by Vlastimil Havran.
10/29/02 (c) 2002 University of Wisconsin, CS559 Today Hidden Surface Removal Exact Visibility.
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
CS 450: COMPUTER GRAPHICS VISIBLE SURFACE DETECTION SPRING 2015 DR. MICHAEL J. REALE.
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
The BSP-tree from Prof. Seth MIT.. Motivation for BSP Trees: The Visibility Problem We have a set of objects (either 2d or 3d) in space. We have.
Visible-Surface Detection Jehee Lee Seoul National University.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
Chapter 10, Part II Edge Linking and Boundary Detection The methods discussed in the previous section yield pixels lying only on edges. This section.
Using BSP for CD Ref: BSP in deBerg et al ’ s book (url)url.
Vector Quantization CAP5015 Fall 2005.
Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.
Maths & Technologies for Games Spatial Partitioning 2
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
01/28/09Dinesh Manocha, COMP770 Visibility Computations Visible Surface Determination Visibility Culling.
BSP Tree Supplement Jyun-Ming Chen. Fall Kd-Tree and BSP tree kd-tree is a special kind of bsp tree.
3D Object Representations 2009, Fall. Introduction What is CG?  Imaging : Representing 2D images  Modeling : Representing 3D objects  Rendering : Constructing.
Visibility Determination – List Priority Methods Chapter 11.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Hierarchical Data Structure in Game Programming Yanci Zhang Game Programming Practice.
CS552: Computer Graphics Lecture 28: Solid Modeling.
School of Computing Clemson University Fall, 2012
Constructive Solid Geometry CSG (Geometri Padat Konstruktif)
Scene Manager Creates and places movable objects like lights and cameras so as to access them efficiently, e.g. for rendering. Loads and assembles world.
Bounding Volume Hierarchies and Spatial Partitioning
Distance Computation “Efficient Distance Computation Between Non-Convex Objects” Sean Quinlan Stanford, 1994 Presentation by Julie Letchner.
BSP Trees Binary space partitioning trees.
Bounding Volume Hierarchies and Spatial Partitioning
© University of Wisconsin, CS559 Fall 2004
Hidden Surfaces Dr. Scott Schaefer.
Modeliranje kompleksnih modelov
3D Object Representations
Mean Shift Segmentation
KD Tree A binary search tree where every node is a
CSCE 441: Computer Graphics Hidden Surface Removal
Quadtrees 1.
Lecture 32: Visible Surface Detection
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
CS679 - Fall Copyright Univ. of Wisconsin
Hidden Surface Removal
Modeliranje kompleksnih modelov
Visible-Surface Determination
Presentation transcript:

COMPUTER GRAPHICS CHAPTER 37 CS 482 – Fall 2017 DATA STRUCTURES QUAD TREES OCTREES K-D TREES BINARY SPACE PARTITIONING

CHAPTER 37: DATA STRUCTURES QUAD TREES 2D PARTITIONING Quad trees are used to partition two-dimensional space by recursively subdividing it into quadrants until each quadrant contains all or part of a single shape or reaches some minimum size (usually a pixel). Quad trees are effectively utilized in applications such as image representation, efficient 2D collision detection, and fractal image analysis. CS 482 – Fall 2017 CHAPTER 37: DATA STRUCTURES PAGE 293

QUAD TREES RECURSIVE SUBDIVISION OF TOPOGRAPHICAL SURFACES In the application, a topographical map is recursively subdivided until each region is reasonably flat (i.e., the center and four corners are within ten meters of each other in elevation). Pink regions aren’t flat enough Yellow-green regions became flat enough on this iteration Tan regions don’t require further subdivision Final subdivision squares Circle drawn in center of each square Circles colored with a gradient CS 482 – Fall 2017 CHAPTER 37: DATA STRUCTURES PAGE 294

CHAPTER 37: DATA STRUCTURES OCTREES 3D PARTITIONING Octrees extend the notion of Quad trees into three dimensions by recursively subdividing 3D space into octants until each contains all or part of a single shape or reaches some minimum size (usually a voxel). Commonly used for view 3D image representation, frustum culling, and 3D collision detection, octrees have also proven effective in reducing a scene’s color palette. CS 482 – Fall 2017 CHAPTER 37: DATA STRUCTURES PAGE 295

CHAPTER 37: DATA STRUCTURES OCTREES COLOR QUANTIZATION To restrict an image’s color palette to a particular size, the following octree algorithm starts by creating an octree whose leaf nodes constitute a count of how many pixels in the image possess a particular color. For each color in the scene, separate the color into 8-bit RGB components. RGB=(100, 117, 214) R: 01100100 G: 01110101 B: 11010110 Starting with the most significant bit for each primary color, use the eight 3-bit sequences to generate indices between 0 and 7 by adding R+2G+4B. 0014 1117 1103 0116 0000 1117 0014 0102 Traverse the octree structure, using the computed indices to determine which offspring to visit, adding one to the count of the color in question in the leaf node. After finishing all pixels, if the number of leaf nodes exceeds the desired palette size, start merging leaf nodes with low counts into their parent. CS 482 – Fall 2017 CHAPTER 37: DATA STRUCTURES PAGE 296

OCTREES COLOR QUANTIZATION Full Color Image 16-Color Octree Quantization CS 482 – Fall 2017 CHAPTER 37: DATA STRUCTURES PAGE 297

K-D TREES BALANCED PARTITIONING K-D TREES PARTITION SPACE IN A BALANCED MANNER BY ALTERNATING BETWEEN VERTICAL AND HORIZONTAL SPLITTING OF REGIONS INTO TWO PARTS, EACH CONTAINING HALF OF THE REGION’S OBJECTS. CS 482 – Fall 2017 CHAPTER 37: DATA STRUCTURES PAGE 298

K-D TREES NEAREST NEIGHBOR ALGORITHM K-D TREES MAY BE USED TO DETERMINE WHICH OF THE ORIGINAL OBJECTS IN THE SCENE ARE CLOSEST TO A PARTICULAR LOCATION. Recursively traverse the tree until you determine which sector the new location belongs in. The object in this sector is the initial candidate for being closest. Backtrack up the tree from the leaf node to the root, determining whether the subtree on the other side of each partition contains an object that’s closer to the location in question, which would make it the new candidate for closest. This algorithm may be used to speed up ray tracing (by determining that a ray doesn’t intersect particular portioned sectors). Once the backtracking reaches the root of the tree, the current candidate object is the actual closest object to the specified location. CS 482 – Fall 2017 CHAPTER 37: DATA STRUCTURES PAGE 299

K-D TREES a b g c f h i d e DETAILED EXAMPLE: K-D TREE CONSTRUCTION x=s1 y=s2 y=s6 x=s3 y=s4 y=s7 y=s8 a b x=s5 g c f h i d e CS 482 – Fall 2017 CHAPTER 37: DATA STRUCTURES PAGE 300

K-D TREES a b g c f h i d e g g f f h h e e DETAILED EXAMPLE: K-D TREE CONSTRUCTION x=s1 y=s2 x=s3 y=s4 y=s6 y=s7 y=s8 a b x=s5 g c f h i d e g g f f h h e e CS 482 – Fall 2017 CHAPTER 37: DATA STRUCTURES PAGE 301

BINARY SPACE PARTITIONING BSP TREES Using a binary tree structure, object space can be partitioned into numerous half-spaces, and the viewpoint’s position in these half-spaces can be used to determine the order in which they should be rendered in the Painter’s Algorithm. A B C D2 E F D1 Pick a polygon and split the space into the part in front of the polygon and the part in back of it (splitting all intersected polygons) B A,D2,E,F C,D1 front back A B C D2 E F D1 A B C D2 E F D1 A B C D2 E F D1 B F C front back A D2 D1 E Continue this process B F C,D1 front back A D2,E B F C front back A D2,E D1 The process ends when each tree node contains one object (or sub-object) CS 482 – Fall 2017 CHAPTER 37: DATA STRUCTURES PAGE 302

BINARY SPACE PARTITIONING PAINTER’S ALGORITHM IMPLEMENTATION B F C front back A D2 D1 E When determining the order in which the objects should be displayed (e.g., in a painter’s algorithm) for a particular viewpoint, merely traverse the BSP tree recursively: If the viewpoint is in front of the root, traverse Back-Root-Front; otherwise, traverse Front-Root-Back. Example 1 Example 2 A B C D2 E F D1 A B C D2 E F D1 Viewpoint Viewpoint B-subtree: in front  C-subtree, B, F-subtree C-subtree: in front  C, D1 F-subtree: in front  A, F, D2-subtree D2-subtree: in back  D2, E Complete Traversal: C, D1, B, A, F, D2, E B-subtree: in back  F-subtree, B, C-subtree F-subtree: in front  A, F, D2-subtree D2-subtree: in front  E, D2 C-subtree: in front  C, D1 Complete Traversal: A, F, E, D2, B, C, D1 CS 482 – Fall 2017 CHAPTER 37: DATA STRUCTURES PAGE 303