Computer Graphics, KKU. Lecture 7

Slides:



Advertisements
Similar presentations
CHAPTER 3 2D GRAPHICS ALGORITHMS
Advertisements

Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)
Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.
Some Basic Morphological Algorithm
Different types of Polygons Simple Convex Simple Concave Non-simple : self-intersecting With holes ConvexConcaveSelf-intersecting.
The “Flood Fill” Algorithm A recursive graphics algorithm used to fill in irregular-shaped regions with a solid color.
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.
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
Now Playing: Big Bird Eddie Floyd from The Complete Stax-Volt Singles Volume 1 ( ) Released April 30, 1991.
CS 454 Computer graphics Polygon Filling
CS 4731: Computer Graphics Lecture 22: Raster Graphics Part 3 Emmanuel Agu.
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.
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.
Lecture 5CSE Intro to Cognitive Science1 Algorithmic Thinking III.
CS 450: Computer Graphics PIXEL AdDRESSING AND OBJECT GEOMETRY
October 14, 2014Computer Vision Lecture 11: Image Segmentation I 1Contours How should we represent contours? A good contour representation should meet.
Introduction to Computer Graphics with WebGL
CS 480/680 Computer Graphics Implementation III Dr. Frederick C Harris, Jr. Fall 2011.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Institute for Visualization and Perception Research 1 © Copyright 2000 Haim Levkowitz Primitives Points … Lines … Circles, ellipses, conics, curves, disks.
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.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 50 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 50 Computer Graphics Implementation II.
Lecture 15: Raster Graphics and Scan Conversion
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
Lecture 13: Raster Graphics and Scan Conversion
Winter 2005CS-2851 Dr. Mark L. Hornick 1 Recursion.
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.
Computer Graphics I, Fall 2010 Scan conversion algorithms.
OUTPUT PRIMITIVES CEng 477 Computer Graphics METU, 2004.
Chapter- 3 & Unit-2 Graphics PRIMITIVES 1. Objectives Introduction to Primitives Points & Lines Line Drawing Algorithms Digital Differential Analyzer.
CS552: Computer Graphics Lecture 16: Polygon Filling.
Scan Conversion or Rasterization
Graphics PRIMITIVES Chapter- 3 & Unit-2.
Flood fill algorithm Also called seed fill, is an algorithm that determines the area connected to a given node in a multi-dimensional array, When applied.
Computer Graphics Filling.
Scan Conversion of Polygons
CSE 554 Lecture 1: Binary Pictures
Introduction to Polygons
Computer Graphics CC416 Week 13 Clipping.
Polygons.
Scan Conversion or Rasterization
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
University of New Mexico
Implementation III.
Fill Area Algorithms Jan
Polygon Filling Algorithms
Concepts, algorithms for clipping
Anti Aliasing.
Introduction to Computer Graphics with WebGL
Computer Vision Lecture 5: Binary Image Processing
Agenda Polygon Terminology Types of polygons Inside Test
SSEA Computer Science: Track A
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
Prepared by Narendra V G CSE MIT
Agenda Polygon Terminology Types of polygons Inside Test
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Computer Graphics Implementation III
عَلَّمَهُ الْبَيَانَ He has taught him speech (and intelligence).
ECE 692 – Advanced Topics in Computer Vision
Type to enter a caption. Computer Graphics Week 2 Lecture 1.
Introduction to OpenGL
Implementation III Ed Angel Professor Emeritus of Computer Science
Polygons.
Computer Graphics, KKU. Lecture 11
Presentation transcript:

168 471 Computer Graphics, KKU. Lecture 7 Region Filling Region Filling is the process of “coloring in” a definite image area or region. Seed Fill Approaches 2 algorithms: Boundary Fill and Flood Fill works at the pixel level suitable for interactive painting applications 168 471 Computer Graphics, KKU. Lecture 7

Seed Fill Algorithms: Connectedness 4-connected region: From a given pixel, the region that you can get to by a series of 4 way moves (N, S, E and W) 8-connected region: From a given pixel, the region that you can get to by a series of 8 way moves (N, S, E, W, NE, NW, SE, and SW) 4-connected 8-connected 168 471 Computer Graphics, KKU. Lecture 7

Boundary Fill Algorithm Start at a point inside a region Paint the interior outward to the edge The edge must be specified in a single color Fill the 4-connected or 8-connected region 4-connected fill is faster, but can have problems: 168 471 Computer Graphics, KKU. Lecture 7

Boundary Fill Algorithm (cont.) void BoundaryFill4(int x, int y, int fill, int Boundary) { int current; current = ReadPixel(x, y); if(current != Boundary && current != fill) BoundaryFill4(x+1, y,fill, Boundary); BoundaryFill4(x-1, y,fill, Boundary); BoundaryFill4(x, y+1,fill , Boundary); BoundaryFill4(x, y-1, fill, Boundary); } 168 471 Computer Graphics, KKU. Lecture 7

168 471 Computer Graphics, KKU. Lecture 7 Recursive Boundary fill algorithms may not fill regions correctly if some interior pixels are already displayed in the fill color. This occurs because the algorithms checks next pixels both for boundary color and fill color. Encountering a pixel with the fill color can cause a recursive branch to terminate, leaving other interior pixels unfilled. To avoid this we can first change the color of any interior pixels that are initially set to fill color before applying boundary fill procedure. 168 471 Computer Graphics, KKU. Lecture 7

168 471 Computer Graphics, KKU. Lecture 7 Flood Fill Algorithm Used when an area defined with multiple color boundaries Start at a point inside a region Replace a specified interior color (old color) with fill color Fill the 4-connected or 8-connected region until all interior points being replaced 168 471 Computer Graphics, KKU. Lecture 7

Flood Fill Algorithm (cont.) void FloodFill4(int x, int y, int fillcolor, int oldColor) { if(ReadPixel(x, y) == oldColor) FloodFill4(x+1, y, fillcolor, oldColor); FloodFill4(x-1, y, fillcolor, oldColor); FloodFill4(x, y+1, fillcolor, oldColor); FloodFill4(x, y-1, fillcolor, oldColor); } 168 471 Computer Graphics, KKU. Lecture 7

168 471 Computer Graphics, KKU. Lecture 7 { setcolor(RED); rectangle(100,100,200,200); circle(300,300,50); setfillstyle(1,YELLOW); floodfill(101,101,RED); floodfill(301,301,RED); } 168 471 Computer Graphics, KKU. Lecture 7

168 471 Computer Graphics, KKU. Lecture 7 Setfillstyle Purpose: setfillstyle is used to set the color and style to be filled in the object using the flood fill method. Syntax: stefillstyle(STYLE, COLOR); Example: setfillstyle(1,RED) Floodfill Purpose: floodfill function is used to fill the color in the object, object may be circle, rectangle or any other closed image. Syntax: floodfill(x,y,boundary color); Example: floodfill(100,100,BLUE); 168 471 Computer Graphics, KKU. Lecture 7