College of Computer and Information Science, Northeastern UniversityMay 27, 20161 CS 4300 Computer Graphics Prof. Harriet Fell Fall 2012 Lecture 9 – September.

Slides:



Advertisements
Similar presentations
Polygon Scan Conversion – 11b
Advertisements

SI23 Introduction to Computer Graphics
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 7 Scanline algorithm and polygon clipping Taku Komura.
Computer Graphics- SCC 342
CMPE 466 COMPUTER GRAPHICS
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Polygon Rasterization
Computer Graphics Scan Conversion Polygon Faculty of Physical and Basic Education Computer Science Dep Lecturer: Azhee W. MD.
College of Computer and Information Science, Northeastern UniversityApril 17, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 9.
Convex Hull obstacle start end Convex Hull Convex Hull
I. The Problem of Molding Does a given object have a mold from which it can be removed? object not removable mold 1 object removable Assumptions The object.
I. The Problem of Molding Does a given object have a mold from which it can be removed? object not removable mold 1 object removable Assumptions The object.
Classes of Polygons Planar polygons Non-planar polygons Simple
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
5/17/2015 1:32 AMConvex Hull1 obstacle start end.
Different types of Polygons Simple Convex Simple Concave Non-simple : self-intersecting With holes ConvexConcaveSelf-intersecting.
CPCS 391 Computer Graphics 1 Lecture 5: Polygon Filling
Graphics Programming: Polygon Filling
College of Computer and Information Science, Northeastern UniversityJune 21, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 21.
Computational Geometry
CSE53111 Computational Geometry TOPICS q Preliminaries q Point in a Polygon q Polygon Construction q Convex Hulls Further Reading.
TOPIC 4 PART III FILL AREA PRIMITIVES POLYGON FILL AREAS CGMB214: Introduction to Computer Graphics.
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
Polygon Scan Conversion and Z-Buffering
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
College of Computer and Information Science, Northeastern UniversitySeptember 12, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture.
3/4/04© University of Wisconsin, CS559 Spring 2004 Last Time Clipping Lines –Cohen-Sutherland: The use of outcodes and early reject/accept tests –Liang-Barsky:
Informationsteknologi Monday, November 26, 2007Computer Graphics - Class 121 Today’s class Drawing lines Bresenham’s algorithm Compositing Polygon filling.
College of Computer and Information Science, Northeastern UniversityOctober 12, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2006.
1 Filling Graphical Shapes. 2 We know how to draw outlines Can we just fill the “inside”? …but how do we know the difference between the inside and outside?
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
Scan Conversion. Last step in the graphics pipeline Efficiency is a central issue Common primitives – Lines (done last class) – Polygons (fill polygons,
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
College of Computer and Information Science, Northeastern UniversityOctober 31, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2009.
1 Dr. Scott Schaefer Intersecting Simple Surfaces.
Computer Graphics Filling. Filling Polygons So we can figure out how to draw lines and circles How do we go about drawing polygons? We use an incremental.
CS6234 Advanced Algorithms - Convex hull. Terminologies – ◦ Convex hull of a set Q of points is the smallest convex polygon P for which each point in.
Lecture 15: Raster Graphics and Scan Conversion
Special Angle Pairs. Definitions Adjacent Angles: Angles that have a common ray or side and a common vertex, but points inside either one of the angles.
Rasterization Overview Raster Display Device. Scan Conversion / Rasterization: converting vector graphics into raster graphics (determining pixels in.
Computer Graphics CC416 Week 14 Filling Algorithms.
Computer Graphics Lecture 08 Taqdees A. Siddiqi Computer Graphics Filled Area Primitives I Lecture 08 Taqdees A. Siddiqi
Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition Chapter 14.
CS552: Computer Graphics Lecture 16: Polygon Filling.
Computer Graphics Filling.
Introduction to Polygons
Computer Graphics CC416 Week 13 Clipping.
CS G140 Graduate Computer Graphics
Polygons.
(c) 2002 University of Wisconsin, CS559
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
Midterm Review Computer Graphics Hardware Point and Line Drawing
Zhen Jiang West Chester University
Prof. Harriet Fell Spring 2007 Lecture 9 – January 29, 2007
© University of Wisconsin, CS559 Fall 2004
Convex Hull obstacle start end 11/21/2018 4:05 AM Convex Hull
Agenda Polygon Terminology Types of polygons Inside Test
Prepared by Narendra V G CSE MIT
Agenda Polygon Terminology Types of polygons Inside Test
I. The Problem of Molding
Prof. Harriet Fell Fall 2011 Lecture 9 – September 26, 2011
(c) 2002 University of Wisconsin, CS559
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
NOTE.
Convex Hull obstacle start end 4/30/2019 5:21 PM Convex Hull
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Where We Stand At this point we know how to: Next thing:
Type to enter a caption. Computer Graphics Week 6 Lecture 1.
Computational Geometry
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Presentation transcript:

College of Computer and Information Science, Northeastern UniversityMay 27, CS 4300 Computer Graphics Prof. Harriet Fell Fall 2012 Lecture 9 – September 24, 2012

College of Computer and Information Science, Northeastern UniversityMay 27, Today’s Topics Fill: Flood Boundary Fill vs. Polygon Fill  See Photoshop for Flood Fill 2D Polygon Fill

College of Computer and Information Science, Northeastern University Simple 2D Polygon an ordered sequence of line segments such that  each edge g i = ( s i, e i ) is the segment from a start vertex s i to an end vertex e i  e i-1 = s i for 0 < i ≤ n-1 and e n-1 = s 0  non-adjacent edges do not intersect  the only intersection of adjacent edges is at their shared vertex 5/27/20163

College of Computer and Information Science, Northeastern UniversityMay 27, Scan Line Polygon Fill

College of Computer and Information Science, Northeastern UniversityMay 27, Parity Check Draw a horizontal half-line from P to the right. Count the number of times the half-line crosses an edge. 1in 4out 7in

College of Computer and Information Science, Northeastern UniversityMay 27, Polygon Data Structure edges xminymax1/m  168/4  (1, 2) (9, 6) xmin = x value at lowest y ymax = highest y Why 1/m? If y = mx + b, x = (y-b)/m. x at y+1 = (y+1-b)/m = (y-b)/m + 1/m.

Polygon Data Structure Edge Table (ET) has a list of edges for each scan line. e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e  e  e4  e5 6  e3  e7  e  e2  e1  e11 0  e10  e9

College of Computer and Information Science, Northeastern UniversityMay 27, Preprocessing the edges count twice, once for each edge chop lowest pixel to only count once delete horizontal edges For a closed polygon, there should be an even number of crossings at each scan line. We fill between each successive pair.

 e  e4  e5 6  e3  e7  e  e2  e1  e11 0  e10  e9 e11 7  e3  e4  e5 6  e7  e8 11  e6 10 Polygon Data Structure after preprocessing Edge Table (ET) has a list of edges for each scan line. e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e

College of Computer and Information Science, Northeastern UniversityMay 27, The Algorithm 1.Start with smallest nonempty y value in ET. 2.Initialize SLB (Scan Line Bucket) to nil. 3.While current y ≤ top y value: a.Merge y bucket from ET into SLB; sort on xmin. b.Fill pixels between rounded pairs of x values in SLB. c.Remove edges from SLB whose ytop = current y. d.Increment xmin by 1/m for edges in SLB. e.Increment y by 1.

Running the Algorithm e2 e3 e4 e5 e6 e7 e8 e9 e10 e ET  e  e3  e4  e5 6  e7ve  e2  e11 0  e10  e9 xminymax1/m e226-2/5 e31/3 121/3 e4412-2/5 e54130 e66 2/313-4/3 e /2 e81082 e91183/8 e /4 e11642/

May 27, Running the Algorithm e2 e3 e4 e5 e6 e7 e8 e9 e10 e y=0 SCB  114-3/4  1183/8  e9 e /4 11 3/8

May 27, Running the Algorithm e2 e3 e4 e5 e6 e7 e8 e9 e10 e y=1 SLB  26-2/5  642/3  e11 e2 1 3/5 10 1/44-3/4  11 3/8 83/8  e9 e10 6 2/3 9 1/2 11 6/8

May 27, Running the Algorithm e2 e3 e4 e5 e6 e7 e8 e9 e10 e y=2 SLB  1 3/56-2/5  6 2/342/3  e11 e2 9 1/24-3/4  11 6/883/8  e9 e /8 8 3/4 7 1/3 1 1/5

May 27, Running the Algorithm e3 e4 e5 e6 e7 e8 e9 e y=3 SLB  1 1/56-2/5  7 1/342/3  e11 e2 8 3/44-3/4  12 1/883/8  e9 e / /5 e11e2

May 27, Running the Algorithm e3 e4 e5 e6 e7 e8 e y=4 SLB  4/56-2/5  842/3  e11 e2 84-3/4  12 4/883/8  e9 e10 e11e2 e9 Remove these edges.

May 27, Running the Algorithm e3 e4 e5 e6 e7 e y=4 SLB  4/56-2/5  e2 12 4/883/8  e9 12 7/8 2/5 e2e11 e10 e9 e11 and e10 are removed.

May 27, Running the Algorithm e3 e4 e5 e6 e7 e y=5 SLB  2/56-2/5  e2 12 7/883/8  e9 13 2/8 0 e2e11 e10 e9

May 27, Running the Algorithm e3 e4 e5 e6 e7 e y=6 SLB  06-2/5  e /2  e7 e2e11 e10 e9 Remove this edge  e8 13 2/883/8  e9 9 1/ /8

Running the Algorithm e3 e4 e5 e6 e7 e y=7 SLB  4130  e5 9 1/210-1/2  e7 e2e11 e10 e  e8 13 5/883/8  e9 Add these edges /5  e4 1/3121/3  e3

College of Computer and Information Science, Northeastern University Non-Simple Polygons 5/27/201621

College of Computer and Information Science, Northeastern University Even-odd Rule construct a ray r in an arbitrary direction from the test point p count number of intersections of r with the polygon. p is defined to be inside the poly if the intersection count is odd. 5/27/201622

College of Computer and Information Science, Northeastern University Reasoning each time an edge is crossed, either switch from inside to outside or outside to inside but since poly is closed, know that ray r must end up outside this is the method we just applied 5/27/201623

College of Computer and Information Science, Northeastern University Nonzero Rule construct a ray r as before compute all intersections of r with the poly edges g i, but this time keep track of whether the edge crossed from left to right (i.e. s i on left side of r and e i on right side of r ) or right to left count +1 for left-to-right and –1 for right-to-left p is defined to be inside the poly if and only if (iff) final count is nonzero 5/27/201624

College of Computer and Information Science, Northeastern University Reasoning consider sweeping a point q along the perimeter of the poly take the integral of the orientation angle of the line segment from p to q turns out that, for one complete sweep of the polygon, the integrated winding angle will be an integer multiple of cover it) 5/27/201625

College of Computer and Information Science, Northeastern University Intuition intuition: reasonable definition of inside- ness is to check if the poly “circled around” p in CCW direction different number times than in CW direction nonzero intersection test turns out to be a shortcut to compute (proof is a little subtle and we will not cover it) 5/27/201626

College of Computer and Information Science, Northeastern University The Results Can be Different 5/27/201627