Dual Marching Squares: Implementation
Total Page:16
File Type:pdf, Size:1020Kb
DUAL MARCHING SQUARES: IMPLEMENTATION AND ANALYSIS USING VTK by MANU GARG A thesis submitted to the Graduate Faculty of the University of Colorado Colorado Springs in partial fulfillment of the requirements for the degree of Master of Science Department of Computer Science 2017 © 2017 MANU GARG ALL RIGHTS RESERVED As is a common practice in Computer Science, journal and conference articles are published based on the MS/Ph.D. thesis work, which means that wording, tables, figures, and sentence structure are sometimes identical in the dissertation document, and journal and conference articles co-authored by the student and their advisor. This thesis for the Master of Science degree by Manu Garg has been approved for the Department of Computer Science by Sudhanshu K. Semwal, Chair T. S. Kalkur Al. Glock Date October 3, 2017 ii Garg, Manu (M.S., Computer Science) Dual Marching Squares: Implementation and Analysis Using VTK Thesis directed by Professor Sudhanshu K. Semwal ABSTRACT In the past few decades’ volume rendering is perhaps one of the most visited research topics in the field of scientific visualization. Since volume datasets are large and require considerable computing power to process, the issue of supporting real time interaction has received much attention. Extracting a polygonal mesh from an existing scalar field identified in the volume data has been the focus since nineteen-eighties. Many algorithms, like Marching Cube, and Marching Square, have been developed to extract the polygonal mesh from the scalar interpretation of the volume data. However, only a few of these techniques claim to solve all known existing problems due to concave nature of the surfaces embedded inside the volume data. Some extract meshes with too many polygons. Many such polygons, with same orientation, could be combined. Sharp features or small detail in the underlying surface could be lost due to polygonal approximation. Other techniques suffer from topological inconsistencies, self- intersections, inter-cell dependencies, and other similar issues. Recently published Dual Marching Squares (DMS) produce smother results in comparison to the Marching Square algorithm. According to best of our knowledge, there has been no other implementations, except the original theoretical research paper on DMS which was published in Feb. 2016. In this thesis, we implement DMS using the VTK pipeline. A comparison of MS and DMS is provided. Keywords: Isosurface, Extraction, Implicit Surfaces, Scalar Field Polygonization, Meshing, Marching Cube, Marching Square, Dual Marching Cube, Dual Marching Square, Volume visualization, Volume Rendering, Computer Graphics. iii TABLE OF CONTENTS CHAPTER I. INTRODUCTION. ……………………..1 II. BACKGROUND. ……………………...6 III. TECHNICAL BACKGROUND. ………………......9 IV. ANALYSIS AND IMPLEMENTATION. ……………... .15 V. RESULTS AND DISCUSSION. …………………30 VI. CONCLUSION AND FUTURE WORK. …………….... ... 34 REFERENCES . ……………………..35 APPENDICES A. Steps to install VTK-Python on Mac…………………………………..38 B. Codes. ………………………...39 C. Code for getting attributes for DICOM file . .……………….. ....42 iv LIST OF TABLES TABLE 5.1 Time taken to run the algorithm to generate the 3D dataset……………..32 v LIST OF FIGURES FIGURE 3.1. A marching square. The points at the corners denote the sample points. In this example, red points are outside the isoline (or isoband) and yellow points inside the isoline. The dotted line, marks the isoline, and the blue color defining the 'inside (Drawn using draw.io)'………………………… 9 3.2 The 16 configurations of the Marching Squares algorithm (Drawn using draw.io…………………………………………………………………………. 10 3.3 The 4 unique configurations of the Marching Squares algorithm, which are necessary to reproduce all others (Drawn using draw.io). 11 ………………………………..…………………………………………… 3.4 The 15 configurations into which the 256 variations of straddling cubes, decompose, in the MC algorithm (Drawn using draw.io). …………………… 11 3.5 The curve achieved by Dual Marching Square (a) compared to Marching Square (b) (Drawn using draw.io). 14 ………………………………..…………………………………………… 4.1 Testing shape for the algorithm………………………………..……………… 15 4.2 First five quad tree level for test data “h” ………………………………..…… 17 4.3 Merging of cells to form larger leaf (green color) after ADFs.…………… 18 4.4 Quad tree created for test shape “h” after ADFs. Leaf cells (Green Color), Empty cells (Grey Color), and Full cells (Back Color). …………………… 19 4.5 Dual grid (Black color) over a primary quadtree (Grey color)…………….. 20 4.6 Vertices (Red color) of the test shape “h” for Dual Marching Square. Leaf cells (Green Color), Empty cells (Grey Color), and Full cells (Back 21 Color). ………………………………..……………………………………………………. 4.7 Left “h” generated using Marching Square. Right “h” generated using Dual Marching Square …………………………………………………………………….. 22 4.8 DICOM file attributes………………………………..…………………………………. 25 vi 5.1 Left Female head_Front Marching Square (duration 0:00:00.246355) Right Female head_Front Dual Marching Square (duration 30 0:00:00.247965) ………………………………..…………………………………… 5.2 Left Female Head_side Marching Square (duration 0:00:00.246355) Right Female Head_side Dual Marching Square (duration 30 0:00:00.247965) ………………………………..……………………………………… 5.3 Left Female Head_back Marching Square (duration 0:00:00.246355), Right Female Head_back Dual Marching Square (duration 31 0:00:00.247965)……………………………..…………………………………………… 5.4 Left Female Eye_ Front Marching Square (duration 0:00:00. 213779), Right Female Eye_Front Dual Marching Square (duration 0:00:00. 31 223355) ………………………………..…………………………………………… 5.5 Left Female Right_Eye_WireFrame Marching Square Square (duration 0:00:00. 213779), Right Female Right_Eye_WireFrame Dual Marching 31 Square (duration 0:00:00. 223355)………………………………..……………… 5.6 Left Female_Ear_Front Marching Square(duration 0:00:00.244979), Right Female_Ear_Front Dual Marching Square(duration 0:00:00. 31 253785) ………………………………..…………………………………………… 5.7 Left Female_Ear_Front Marching Square Wireframe (duration 0:00:00.244979), Right Female_Ear_Front Dual Marching Square WireFrame (duration 0:00:00. 253785) Does not include rendering time, only the mesh generation time is specified in the above table………………… 32 vii LIST OF ABBREVIATIONS • CAD Computer Aided Design • CT Computed Tomography • DC Dual Contouring • DICOM Digital Imaging in Communications and Medicine • DMC Dual Marching Cube • DMS Dual Marching Square • MC Marching Cubes • MRI Magnetic Resonance Imaging • MS Marching Squares • VTK Visualization Toolkit • CSG Constructive Solid Geometry viii CHAPTER I INTRODUCTION “Imagination or visualization, and in particular the use of diagrams, has a crucial part to play in scientific investigation.” - Rene Descartes, 1637. The term visualization, as Ware [1] describes, means the construction of a visual image in the mind (Oxford English Dictionary, 1973). But it has also come to mean something more tangible: the graphical representation of data or concepts in multi- participant virtual environments. Earliest visualizations can be found in Chinese cartography in the year 1137 [2]. For example, Volume 86 of the historical text Records of the Grand Historian (Shi Ji) dated 227 BC has earliest mention of a map. Visualization once was a manually intensive task, involving ink and paper. Sometimes, models were created using stick-and-balls in classrooms and texts. The advent of the computing era has brought in an ability to process, and subsequently visualize, large amounts of data. Real-time interaction provides an ability to concentrate on interpreting and understanding the data. Some believe that human beings will always have vital a role in visualization. This is because ultimately human beings are the one who can perceive the best way of visually representing the volumetric data. Computational Scientific Visualization process works as a tool to aid in this process. Computational Scientific visualization is a framework that enables scientists to computationally analyze, understand, and communicate the numerical data generated by scientific research. In recent years, volume data is being collected at a rate beyond what can be possibly studied and comprehended by a person. Scientific visualization uses computer graphics and Human Computer Interaction (HCI) techniques to process numerical data into two- and three-dimensional visual images. This visualization process includes gathering, processing, displaying, analyzing, and interpreting data. Volume visualization is a set of techniques used to extract meaningful 1 information from volumetric data using image processing and interactive graphics techniques. It helps with the representation of the volume data, modeling, manipulation, and rendering. Volume datasets can be collected by sampling, simulation, or modeling techniques. For example, Computed Tomography (CT) can be used to get a sequence of 2D slices or Magnetic Resonance Imaging (MRI) data set. MRI is a diagnostic tool which can be used to produce detailed 3D model of the inside of the human-body. This technology has also been used for non-destructive inspection of composite materials or mechanical parts. Likewise, the data obtained from confocal microscopes can be visualized to study the morphology of biological structures. Volume visualization can also be used in many computational fields, e.g. computational fluid dynamics (CFD), where results/outcome of simulation generated on a supercomputer can be used to analyze and verify the aspects of fluid flow, including compressible, non-isothermal, non-Newtonian, multiphase, and porous