Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "COMPUTER GRAPHICS CS 482 – FALL 2014 NOVEMBER 5, 2014 DATA STRUCTURES QUAD TREES OCTREES K-D TREES BINARY SPACE PARTITIONING."— Presentation transcript:

1

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

3 QUAD TREES CS 482 – FALL D PARTITIONING NOVEMBER 5, 2014: DATA STRUCTURESPAGE 257 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.

4 OCTREES CS 482 – FALL D PARTITIONING NOVEMBER 5, 2014: DATA STRUCTURESPAGE 258 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.

5 OCTREES CS 482 – FALL 2014 COLOR QUANTIZATION NOVEMBER 5, 2014: DATA STRUCTURESPAGE 259 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. 1.FOR EACH COLOR IN THE SCENE, SEPARATE THE COLOR INTO 8-BIT RGB COMPONENTS. RGB=(100, 117, 214) R: G: B: 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         2 3.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. 4.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.

6 K-D TREES CS 482 – FALL 2014 BALANCED PARTITIONING NOVEMBER 5, 2014: DATA STRUCTURESPAGE 260 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.

7 K-D TREES CS 482 – FALL 2014 NEAREST NEIGHBOR ALGORITHM NOVEMBER 5, 2014: DATA STRUCTURESPAGE 261 K-D TREES MAY BE USED TO DETERMINE WHICH OF THE ORIGINAL OBJECTS IN THE SCENE ARE CLOSEST TO A PARTICULAR LOCATION. THIS ALGORITHM MAY BE USED TO SPEED UP RAY TRACING (BY DETERMINING THAT A RAY DOESN’T INTERSECT PARTICULAR PORTIONED SECTORS). 1.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. 2.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. 3.ONCE THE BACKTRACKING REACHES THE ROOT OF THE TREE, THE CURRENT CANDIDATE OBJECT IS THE ACTUAL CLOSEST OBJECT TO THE SPECIFIED LOCATION.

8 BINARY SPACE PARTITIONING CS 482 – FALL 2014 BSP TREES NOVEMBER 5, 2014: DATA STRUCTURESPAGE 262 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) A B C D2 E F D1 BB A,D2,E,FA,D2,E,FC,D1C,D1 FRONTBACK CONTINU E THIS PROCESS A B C D2 E F D1 BB FFC,D1C,D1 FRONTBACK AA D2,ED2,E FRONTBACK A B C D2 E F D1 BB FFCC FRONTBACK AA D2,ED2,E FRONT BACK FRONT D1D1 A B C D2 E F D1 BB FFCC FRONTBACK AAD2D2 FRONT BACK FRONT D1D1 EE BACK THE PROCESS ENDS WHEN EACH TREE NODE CONTAINS ONE OBJECT (OR SUB-OBJECT)

9 BINARY SPACE PARTITIONING CS 482 – FALL 2014 PAINTER’S ALGORITHM IMPLEMENTATION NOVEMBER 5, 2014: DATA STRUCTURESPAGE 263 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. A B C D2 E F D1 EXAMPLE 1 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 A B C D2 E F D1 EXAMPLE 2 VIEWPOINT 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 BB FFCC FRONTBACK AAD2D2 FRONT BACK FRONT D1D1 EE BACK


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

Similar presentations


Ads by Google