1 / 8

COMPUTER GRAPHICS

COMPUTER GRAPHICS. CS 482 – FALL 2014. NOVEMBER 5, 2014. DATA STRUCTURES. QUAD TREES OCTREES K-D TREES BINARY SPACE PARTITIONING. QUAD TREES. 2D PARTITIONING.

siran
Télécharger la présentation

COMPUTER GRAPHICS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COMPUTER GRAPHICS CS 482 – FALL 2014 NOVEMBER 5, 2014 DATA STRUCTURES • QUAD TREES • OCTREES • K-D TREES • BINARY SPACE PARTITIONING

  2. 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 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 257

  3. 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 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 258

  4. 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 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 259

  5. 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 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 260

  6. 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 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 261

  7. BINARY SPACE PARTITIONING B C front back B A D1 F C B C D2 F E front front B front back back A D1 D2 A D1 A,D2,E,F C,D1 F D2 back E E B C C B front back B B A D1 A D1 F C,D1 front back F D2 F D2 E E front back F C D2,E A front front back D2,E A D1 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. 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) Continue this process The process ends when each tree node contains one object (or sub-object) CS 482 – FALL 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 262

  8. BINARY SPACE PARTITIONING B front back F C front front back D2 A D1 back E C C B B A A D1 D1 F F D2 D2 E E Viewpoint Viewpoint PAINTER’S ALGORITHM IMPLEMENTATION 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 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 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 263

More Related