CSC Computer Graphics

Similar documents
Scalar Visualization

Indirect Volume Rendering

Scalar Visualization

Scalar Algorithms: Contouring

Isosurface Rendering. CSC 7443: Scientific Information Visualization

Volume Illumination, Contouring

Scientific Visualization. CSC 7443: Scientific Information Visualization

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Contouring and Isosurfaces. Ronald Peikert SciVis Contouring 2-1

Lecture overview. Visualisatie BMT. Fundamental algorithms. Visualization pipeline. Structural classification - 1. Structural classification - 2

Graphics (Output) Primitives. Chapters 3 & 4

Volume visualization. Volume visualization. Volume visualization methods. Sources of volume visualization. Sources of volume visualization

In today s lecture we ll have a look at: A simple technique The mid-point circle algorithm

Visualization. Images are used to aid in understanding of data. Height Fields and Contours Scalar Fields Volume Rendering Vector Fields [chapter 26]

Chapter 3. Sukhwinder Singh

11/1/13. Visualization. Scientific Visualization. Types of Data. Height Field. Contour Curves. Meshes

Visualization. CSCI 420 Computer Graphics Lecture 26

Agenda. Polygon Terminology Types of polygons Inside Test Polygon Filling Algorithms. Scan-Line Polygon Fill Algorithm Flood-Fill Algorithm

Scientific Visualization Example exam questions with commented answers

coding of various parts showing different features, the possibility of rotation or of hiding covering parts of the object's surface to gain an insight

SURFACE CONSTRUCTION USING TRICOLOR MARCHING CUBES

MARCHING CUBES AND VARIANTS

Contours & Implicit Modelling 4

POLYGON FILLING ALGORITHM

Marching Cubes Robert Hunt CS 525. Introduction

Data Visualization (DSC 530/CIS )

Data Visualization (DSC 530/CIS )

Visualization Computer Graphics I Lecture 20

Height Fields and Contours Scalar Fields Volume Rendering Vector Fields [Angel Ch. 12] April 23, 2002 Frank Pfenning Carnegie Mellon University

Scalar Field Visualization. Some slices used by Prof. Mike Bailey

COMP371 COMPUTER GRAPHICS

Decimation of 2D Scalar Data with Error Control

Geometric Representations. Stelian Coros

Contours & Implicit Modelling 1

Reconstruction of complete 3D object model from multi-view range images.

Scalar Data. Visualization Torsten Möller. Weiskopf/Machiraju/Möller

CIS 467/602-01: Data Visualization

CIS 4930/ SCIENTIFICVISUALIZATION

Marching Squares Algorithm. Can you summarize the marching squares algorithm based on what we just discussed?

Volume Illumination and Segmentation

2D Graphics Primitives II. Additional issues in scan converting lines. 1)Endpoint order. Want algorithms to draw the same pixels for each line

Einführung in Visual Computing

Iso-surface cell search. Iso-surface Cells. Efficient Searching. Efficient search methods. Efficient iso-surface cell search. Problem statement:

4.5 VISIBLE SURFACE DETECTION METHODES

Chapter 8: Implementation- Clipping and Rasterization

Visualization Computer Graphics I Lecture 20

UNIT 2 GRAPHIC PRIMITIVES

9. Three Dimensional Object Representations

Level Set Extraction from Gridded 2D and 3D Data

SE Mock Online Test 1-CG

Unit 2 Output Primitives and their Attributes

3D Surface Reconstruction of the Brain based on Level Set Method

Scan Conversion of Polygons. Dr. Scott Schaefer

Multi-View Matching & Mesh Generation. Qixing Huang Feb. 13 th 2017

Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling

Special Topics in Visualization

Identify parallel lines, skew lines and perpendicular lines.

CS 543: Computer Graphics. Rasterization

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics

Scalar Algorithms -- surfaces

Data Visualization (CIS/DSC 468)

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

Fundamental Algorithms and Advanced Data Representations

Course Title: Computer Graphics Course no: CSC209

CSCI 4620/8626. Coordinate Reference Frames

LAPLACIAN MESH SMOOTHING FOR TETRAHEDRA BASED VOLUME VISUALIZATION 1. INTRODUCTION

Computer Graphics Lecture Notes

Lecture notes: Object modeling

From Ver(ces to Fragments: Rasteriza(on

Scalar Field Visualization I

Topology Preserving Tetrahedral Decomposition of Trilinear Cell

3D Modeling: Surfaces

Geometric Modeling in Graphics

Computer Graphics 1. Chapter 2 (May 19th, 2011, 2-4pm): 3D Modeling. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2011

Computer Graphics (CS 543) Lecture 10: Rasterization and Antialiasing

3D Volume Mesh Generation of Human Organs Using Surface Geometries Created from the Visible Human Data Set

Graphics Output Primitives

CS 248 Assignment 2 Polygon Scan Converter. CS248 Presented by Abe Davis Stanford University October 17, 2008

Solid Modeling. Michael Kazhdan ( /657) HB , FvDFH 12.1, 12.2, 12.6, 12.7 Marching Cubes, Lorensen et al.

Polygonization of Implicit Surfaces

CHAPTER 1 Graphics Systems and Models 3

CS 248 Assignment 2 Polygon Scan Conversion. CS248 Presented by Michael Green Stanford University October 20, 2004

Chapter 24. Creating Surfaces for Displaying and Reporting Data

Fairing Scalar Fields by Variational Modeling of Contours

Surface Construction Analysis using Marching Cubes

The Traditional Graphics Pipeline

EF432. Introduction to spagetti and meatballs

Human Heart Coronary Arteries Segmentation

CS3621 Midterm Solution (Fall 2005) 150 points

Parameterization. Michael S. Floater. November 10, 2011

Practical Linear Algebra: A Geometry Toolbox

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Computer Graphics

03 - Reconstruction. Acknowledgements: Olga Sorkine-Hornung. CSCI-GA Geometric Modeling - Spring 17 - Daniele Panozzo

Computer Graphics 7 - Rasterisation

The Traditional Graphics Pipeline

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Cs602-computer graphics MCQS MIDTERM EXAMINATION SOLVED BY ~ LIBRIANSMINE ~

Scalar Field Visualization I

5. Volume Visualization

Computer Graphics. Chapter 4 Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Transcription:

// CSC. Computer Graphics Lecture Kasun@dscs.sjp.ac.lk Department of Computer Science University of Sri Jayewardanepura Polygon Filling Scan-Line Polygon Fill Algorithm Span Flood-Fill Algorithm Inside-outside Test Odd-Even Rule onzero Winding umber Rule Marching Cubes // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP So we can figure out how to draw lines and circles How do we go about drawing polygons? We use an incremental algorithm known as the scan-line algorithm // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Scan Line // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP 5

// ymax xmin slope Edge Table (ET) Entry The Scan-Line Polygon Fill Algorithm (Example) Polygon = {A, B, C, D, E, F, G} Polygon = {(, ), (, ), (,5), (, ), (, 5), (, ), (5, 5)} F D EF DE -5/ / E C 5 CD FA A B AB BC -5/ 5 / Scan Line The Scan-Line Polygon Fill Algorithm (Example) The Scan-Line Polygon Fill Algorithm Dealing with vertices

// The basic scan-line algorithm is as follows: Find the intersections of the scan line with all edges of the polygon Sort the intersections by increasing x coordinate Fill in all pixels between pairs of intersections that lie interior to the polygon // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Over the last couple of lectures we have looked at the idea of scan converting lines The key thing to remember is this has to be FAST For lines we have either DDA or Bresenham For circles the mid-point algorithm // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP 5 // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP 5 5 // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP

// // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Another approach to area filling is to start at a point inside a region and paint the interior outward toward the boundary. If the boundary is specified in a single color, the fill algorithm processed outward pixel by pixel until the boundary color is encountered. A boundary-fill procedure accepts as input the coordinate of the interior point (x, y), a fill color, and a boundary color. // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP The recursive boundary-fill algorithm:. Start from an interior point.. If the current pixel is not already filled and if it is not an edge point, then set the pixel with the fill color, and store its neighboring pixels ( or -connected) in the stack for processing. Store only neighboring pixel that is not already filled and is not an edge point.. Select the next pixel from the stack, and continue with step. The order of pixels that should be added to stack using -connected is above, below, left, and right. For -connected is above, below, left, right, above-left, aboveright, below-left, and below-right.

// -connected (Example) -connected (Example) Start Position 5 -connected (Example) -connected (Example) -connected (Example) -connected (Example) 5 5 5

// -connected (Example) Start Position 5 5 5

//

// Since the previous procedure requires considerable stacking of neighboring pixels, more efficient methods are generally employed. These methods (Span Flood-Fill) fill horizontal pixel spans across scan lines, instead of proceeding to -connected or -connected neighboring pixels. Then we need only stack a beginning position for each horizontal pixel spans, instead of stacking all unprocessed neighboring positions around the current position. 5 Span Flood-Fill Algorithm The algorithm is summarized as follows: Starting from the initial interior pixel, then fill in the contiguous span of pixels on this starting scan line. Then locate and stack starting positions for spans on the adjacent scan lines, where spans are defined as the contiguous horizontal string of positions bounded by pixels displayed in the area border color. At each subsequent step, unstack the next start position and repeat the process. 5 S 5

// 5 S 5 S 5 5 5 5 5 5 S 5 5 S 5 5 5 5 5 5 5 5 S 5 5 S 5 5 5 5

// 5 5 5 S 5 S 5 5 55 5 5 5 5 S 5 S 5 5 5 5 5 5 5 S 5 S 5 5 5

// 5 5 S 5 Flood Fill Algorithm Sometimes we want to fill in (recolor) an area that is not defined within a single color boundary. We paint such areas by replacing a specified interior color instead of searching for a boundary color value. This approach is called a flood-fill algorithm. Flood Fill Algorithm We start from a specified interior pixel (x, y) and reassign all pixel values that are currently set to a given interior color with the desired fill color. If the area has more than one interior color, we can first reassign pixel values so that all interior pixels have the same color. Counting umber Methods Odd-Even Rule onzero winding number rule Using either -connected or -connected approach, we then step through pixel positions until all interior pixels have been repainted. // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Count the edge crossing along the line from any point (x,y) to infinity. If the number of interactions is odd, then the point (x,y) is an interior point; Else, it is an exterior point. Give directions to all the edges of the polygon. to all upward edges and - for others. Check the sum of scan line. If it is non-zero, then it is an interior point, otherwise it is an exterior point. // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP 5 // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP

// Vertices and Edges Surface in Euclidean space defined by a parametric equation with two parameters A set of weighted control points determine the location of individual surface points The come in several flavors including Bezier, B-Spline, URBS

// Marching Cubes (Geometric) BOO - branch-on-need octree (Geometric) ISSUE - Isosurfacing in Span Space with Utmost Efficiency (Span Space) Interval Tree (Span Space) Contour line (isoline): the same scalar value, or isovalue A contour C is defined as all points p, in a dataset D, that have the same scalar value x: s(p) = x. For D dataset: contour line (isoline); For D dataset: contour surface (iso-surface) Fig 5.. Relationship between color banding and contouring // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP 5 // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Contour properties: Closed curve or open curves ever stop inside the dataset itself ever intersects itself o intersect of an isoline with another scalar value Contours are perpendicular to the gradient of the contoured function (Fig 5.) Fig 5.. The gradient of a scalar field is perpendicular to the field's contours Fig 5.. Isoline properties // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP

// Given a discrete, sampled dataset, compute contours Contouring need At least piecewise linear, C dataset The complexity of computing contours The most popular method D: Marching Squares ( 5..) D: Marching Cubes ( 5..) Fig 5.. Constructing the isoline for the scalar value v =.. The figure indicates scalar values at the grid vertices. // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Fig5.. Topological states of a quad cell (marching squares algorithm). Red indicates "inside" vertices. Bold indices mark ambiguous cases. // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Listing 5.. Marching squares pseudocode // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Similar to Marching Squares but D versus D = 5 different topological cases; Reduced to only 5 by symmetry considerations topological states (Fig 5.) William E. Lorensen, Harvey E. Cline: Marching Cubes: A high resolution D surface construction algorithm. In: Computer Graphics, Vol., r., July International Conference on Computer Graphics and Interactive Techniques (ACM/SIGGRAPH ) Computes polygons where the isosurface passes through eight nearest neighbors Gradient of scalar value at each grid point used for surface normal Other algorithms are always compared to Marching Cubes // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP

// Marching Cubes is an algorithm which creates triangle models of constant density surfaces from D medical data. Computed Tomography (CT) Magnetic Resonance (MRI) Single-Photon Emission Computed Tomography (SPECT) Each scanning process results in two dimensional slices of data. // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP 5 // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Construction/Reconstruction of scanned surfaces or objects. Problem of interpreting/interpolating D data into D visuals. Marching Cubes provides a new method of creating D surfaces. High resolution surface construction algorithm. Extracts surfaces from adjacent pairs of data slices using cubes. Cubes march through the pair of slices until the entire surface of both slices has been examined. // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Load slices. Create a cube from pixels on adjacent slices. Find vertices on the surfaces. Determine the intersection edges. Interpolate the edge intersections. Calculate vertex normals. Output triangles and normals. Uses identical squares of four pixels connected between adjacent slices. Each cube vertex is examined to see if it lies on or off of the surface. // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP 5

// There are =5 ways the surface may intersect the cube Triangulate each case using the symmetries reduces those 5 cases to 5 patterns // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP 5 Unique cube configurations that can be rotated and reflected to 5 configurations // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Fig 5.. Topological states of a hex cell (marching cubes algorithm). Red indicates "inside" vertices. Bold indices mark ambiguous cases. Fig 5.. Ambiguous cases for marching cubes. Each case has two contouring variants. // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP 5 // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP

// Pixels on the slice surfaces determine D surfaces. 5 surface permutations, but only unique patterns. A normal is calculated for each triangle vertex for rendering. // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Pros: Simple rendering and manipulation High resolution Cons: Possible holes in the model Model complexity Determine triangles contained by a cube. Determine which cube edges are intersected. Interpolate intersection point using pixel density. Calculate unit normals for each triangle vertex using the gradient vector. // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Utilizes pixel, line and slice coherency to minimize the number of calculations. Can provide solid modeling. Can use conventional rendering techniques and hardware. o user interaction is necessary. Enables selective displays. Can be used with other density values. Variations can increase/decrease surface density. // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP

// MRI scan data wavy pattern: Caused by subsampling Fig 5.5. Ringing artifacts on isosurface. (a) Overview. (b) Detail mesh. General rule: most isosurface details that are under or around the size of the resolution of the iso-surfaced dataset can be either actual data or artifact should be interpreted with great care Can draw more than a single iso-surface of the same dataset in one visualization (Fig 5.) // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP Fig 5.. Two nested isosurfaces of a tooth scan dataset Isosurfaces and isolines are strongly related Fig 5.. Isosurfaces, isolines, and slicing // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP 5 // Kasun@dscs.sjp.ac.lk - Faculty of Applied Sciences of USJP