Polygon Filling Algorithms

Slides:



Advertisements
Similar presentations
6.5 Graphing Linear Inequalities
Advertisements

6.5 Graphing Linear Inequalities
Polygon Scan Conversion – 11b
Computer Graphics- SCC 342
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 30, D Clipping 1/14 Clipping (pages , )
Objectives Define Clipping Various clipping methods. Line clipping methods.
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Course Website: Computer Graphics 4: Viewing In 2D.
Computer Graphics : Clipping
Viewing & Clipping In 2D. 2 of 44 Contents Windowing Concepts Clipping –Introduction –Brute Force –Cohen-Sutherland Clipping Algorithm Area Clipping –Sutherland-Hodgman.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
Different types of Polygons Simple Convex Simple Concave Non-simple : self-intersecting With holes ConvexConcaveSelf-intersecting.
CSCE 441: Computer Graphics Scan Conversion of Polygons
Implementation III Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Graphics Programming: Polygon Filling
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
CS 454 Computer graphics Polygon Filling
CS 4731: Computer Graphics Lecture 22: Raster Graphics Part 3 Emmanuel Agu.
Rasterization Foley, Ch: 3. Pixels are represented as disjoint circles centered on uniform grid Each (x,y) of the grid has a pixel Y X (1,1) (1,2) (0,0)
University College Dublin1 Clipping u Clipping is the removal of all objects or part of objects in a modelled scene that are outside the real-world window.
TOPIC 4 PART III FILL AREA PRIMITIVES POLYGON FILL AREAS CGMB214: Introduction to Computer Graphics.
IT- 601: Computer Graphics Lecture-04 Scan Conversion Jesmin Akhter Lecturer,IIT Jahangirnagar University, Savar, Dhaka,Bangladesh 9/3/2015.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
2-Dimension Viewing and Clipping
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
1/24/20061 Fill-Area Algorithms and Functions. 1/24/20062 Learning Objectives OpenGL state variables Color and gray scale Color functions Point attributes.
Polygon Scan Conversion and Z-Buffering
Informationsteknologi Monday, November 26, 2007Computer Graphics - Class 121 Today’s class Drawing lines Bresenham’s algorithm Compositing Polygon filling.
Triangle Scan Conversion. 2 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rasterization Rasterization (scan conversion) –Determine which.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
Introduction to Computer Graphics with WebGL
CS 480/680 Computer Graphics Implementation III Dr. Frederick C Harris, Jr. Fall 2011.
Quadratic Surfaces. SPLINE REPRESENTATIONS a spline is a flexible strip used to produce a smooth curve through a designated set of points. We.
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CAP4730: Computational Structures in Computer Graphics
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
EEL Introduction to Computer Graphics
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.
Computer Graphics Lecture 20 Fasih ur Rehman. Last Class Clipping – What is clipping – Why we do clipping – How clipping is done.
Lecture 15: Raster Graphics and Scan Conversion
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
Introduction to Meshes Lecture 22 Mon, Oct 20, 2003.
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 I, Fall 2010 Scan conversion algorithms.
CS552: Computer Graphics Lecture 16: Polygon Filling.
Computer Graphics Filling.
Introduction to Polygons
Computer Graphics CC416 Week 13 Clipping.
Polygons.
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
University of New Mexico
Implementation III.
Fill Area Algorithms Jan
Introduction to Computer Graphics with WebGL
Agenda Polygon Terminology Types of polygons Inside Test
Computer Graphics, KKU. Lecture 7
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
Prepared by Narendra V G CSE MIT
Agenda Polygon Terminology Types of polygons Inside Test
Computer Graphics Implementation III
Primitive Drawing Algorithm
Rasterizing Polygons Lecture 29 Wed, Dec 7, 2005.
Primitive Drawing Algorithm
Type to enter a caption. Computer Graphics Week 6 Lecture 1.
Implementation III Ed Angel Professor Emeritus of Computer Science
Polygons.
Presentation transcript:

Polygon Filling Algorithms Highlight all the pixels inside the polygon .2 approaches can be used 1. Scan Fill 2. Seed Fill (Boundary Fill, Flood Fill )

Start with max y and move to min y or vice versa Scan Fill Start with max y and move to min y or vice versa For each scan line: 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 For scan line number 8 the sorted list of x-coordinates is (2, 4, 9, 13) Therefore draw line b/w (2,4) & (9,13)

Assume that we are taking scan line from max y and moving towards min y   We know that for every scan line we have to calculate x intersection with every polygon side. We can determine the next x intersection value as xi+1=xi - 1/m where m is the slope of edge

It is very easy to identify which polygon sides should be tested for x-intersection, if we sort edges in order of maximum y and find active edge list (Active edge list for scan line contains all the edges crossed by that scan line ). Two pointers are used to indicate the beginning and ending of active edge list. As the scan line move down the picture the beginning and end pointers also moved down to eliminate the edges which end above the current scan line and include the new edges which now start on or above the current scan line .

Boundary Fill Algorithm This algorithm picks a point inside the polygon and starts to fill until it hits the boundary of the object. Assumption: In this algorithm, we assume that color of the boundary is same for the entire object.

Boundary Fill Algorithm (Code)

Flood Fill Algorithm Sometimes we want to fill in 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 (Code)

Boundary Fill Algorithm /Flood Fill algorithm The boundary fill algorithm/ flood fill algorithm can be implemented by 4-connected pixels or 8-connected pixels.

4-connected (Example) Start Position

3 2 1 1 2 3

4 2 1 1 4 2

2 1 1 2

5 1 5 1

1 1

Some region remains unfilled

8-connected (Example) Start Position

5 4 3 2 1 4 1 5 2 3

6 4 3 2 1 6 4 1 2 3

8 7 4 3 2 1 7 8 4 1 2 3

12 11 10 9 7 4 3 2 1 11 9 12 7 10 4 1 2 3

11 10 9 7 4 3 2 1 11 9 7 10 4 1 2 3

10 9 7 4 3 2 1 9 7 10 4 1 2 3

9 7 4 3 2 1 9 7 4 1 2 3

7 4 3 2 1 7 4 1 2 3

4 3 2 1 4 1 2 3

3 2 1 1 2 3

2 1 1 2

1 1