The “Flood Fill” Algorithm A recursive graphics algorithm used to fill in irregular-shaped regions with a solid color.

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick Recursion rA recursive function must have at least two parts l A part that solves a simple case of the.
Advertisements

Image Processing … computing with and about data, … where "data" includes the values and relative locations of the colors that make up an image.
Linear Interpolation Applying “weighted averages” to some graphics problems: animations and curve-drawing.
CHAPTER 3 2D GRAPHICS ALGORITHMS
Recursion October 5, Reading Read pp in the text.
1 CS1110 Lec Oct 2010 More on Recursion We develop recursive functions and look at execution of recursive functions Study Sect 15.1, p Watch.
CSCE 441: Computer Graphics Scan Conversion of Polygons
Graphics Programming: Polygon Filling
Scan Conversion II Revision 1.4 2/13/07 Copyright 2006, Dr. Zachary Wartell, UNCC, All Rights Reserved.
Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi Most material.
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
A code-walkthrough Commentary on our ‘model3d.cpp’ demo-program – an initial ‘prototype’ for 3D wire-frame animations.
CS 454 Computer graphics Polygon Filling
Computer Graphics (Fall 2008) COMS 4160, Lectures 8,9: Curves Problems
CS 4731: Computer Graphics Lecture 22: Raster Graphics Part 3 Emmanuel Agu.
Modelling: Curves Week 11, Wed Mar 23
Computer Graphics (Fall 2005) COMS 4160, Lecture 7: Curves 2
Algorithm for Approximating Piecewise Smooth Curves.
19-Aug-15 Simple Recursive Algorithms. 2 A short list of categories Algorithm types we will consider include: Simple recursive algorithms Backtracking.
Splines III – Bézier Curves
Curve Modeling Bézier Curves
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.
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.
19/13/ :20 UML Graphics II Parametric Curves and Surfaces Session 3.
Planar Graphs: Euler's Formula and Coloring Graphs & Algorithms Lecture 7 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
Curves.
Recursion. Hanoi Tower Legend: Inside a Vietnamese temple there are three rods (labeled as r 1, r 2, and r 3 ), surrounded by n golden disks of different.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Copyright © Curt Hill Visualization of 3D Worlds How are these images described?
Subdivision Schemes Basic idea: Start with something coarse, and refine it into smaller pieces for rendering –We have seen how subdivision may be used.
1 CS 430/536 Computer Graphics I Curve Drawing Algorithms Week 4, Lecture 8 David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing.
1 Bezier Curves and Surfaces © Jeff Parker, Nov 2009.
Volumes By Cylindrical Shells Objective: To develop another method to find volume without known cross-sections.
1 Subdivision. 2 Subdivision for game Why? Large model require many memory for storage Need to dynamically tessellated during game play Make surface modeling.
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.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
Rendering Bezier Curves (1) Evaluate the curve at a fixed set of parameter values and join the points with straight lines Advantage: Very simple Disadvantages:
Curves University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
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.
Properties of water paper PowerPoint presentation
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.
CSE 167 [Win 17], Lecture 10: Curves 2 Ravi Ramamoorthi
Bell Work.
Computer Graphics CC416 Week 13 Clipping.
Polygons.
Computer Vision Lecture 13: Image Segmentation III
Daniil Rodin for CAGD course, 2016
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
Fill Area Algorithms Jan
Polygon Filling Algorithms
What is the difference between Big Ideas and Enduring Understandings?
Craig Schroeder October 26, 2004
Agenda Polygon Terminology Types of polygons Inside Test
Computer Graphics, KKU. Lecture 7
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
Agenda Polygon Terminology Types of polygons Inside Test
Diffusion Curves Dr. Scott Schaefer.
ویژگیهای مبناهای گرافیکی
Project 1 Guidelines.
Lecture 21: B Spline Curve
Drawing Graphs The straight line Example
Polygons.
Presentation transcript:

The “Flood Fill” Algorithm A recursive graphics algorithm used to fill in irregular-shaped regions with a solid color

Region Boundaries We often want to “color” regions which are defined by an irregular-shaped boundary Our earlier “scanline-fill” algorithm worked well for regions with boundaries defined by straight line-segments, or by circular arcs But more complicated regions could lead to programming difficulties if the scanline approach is taken

An irregular region

Alternative: simple recursion A “recursive” approach may be simpler It works by successively reducing a very complicated problem to one that is just a little bit easier to solve We apply that idea to a graphics problem: coloring the interior of an irregular region

A flood-fill algorithm void fill( int x, int y, int interiorcolor, int newcolor ) { if ( get_pixel( x, y ) == interiorcolor ) { put_pixel( x, y, newcolor ); fill( x -1, y, interiorcolor, newcolor ); fill( x+1, y, interiorcolor, newcolor ); fill( x, y -1, interiorcolor, newcolor ); fill( x, y+1, interiorcolor, newcolor ); }

Demonstration setup We need a way to create irregular regions We will do it by using “bezier curves” We subdivide the viewpoint into quadrants We form a bezier curve in each quadrant These bezier curves will connect together First and last control-points are mid-axes Other control-points are randomly chosen

Four bezier curves viewport

Demo-program Our ‘flood.cpp’ demo implements this idea You can find it on our course website It does all of its drawing on page 0 But you might want to draw to page 1, and then afterward copy from page 1 to page 0 That avoids your user seeing the effects of a “slow” drawing operation in-progress