Scan Conversion. Also known as rasterization In our programs objects are represented symbolically –3D coordinates representing an object’s position –Attributes.

Slides:



Advertisements
Similar presentations
Contents In today’s lecture we’ll have a look at:
Advertisements

Graphics Primitives Part II: Bresenhams line and circle.
Graphics Primitives: line
5.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 5 – Drawing A Line.
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
Section 3-1 to 3-2, 3-5 Drawing Lines Some of the material in these slides may have been adapted from university of Virginia, MIT, and Åbo Akademi University.
Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Drawing Elementary Figures Dr. Eng. Farag Elnagahy.
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
Scan conversion of Line , circle & ellipse
Line Drawing Algorithms. Rasterization-Process of determining which pixels give the best approximation to a desired line on the screen. Scan Conversion-Digitizing.
Larry F. Hodges (modified by Amos Johnson) 1 Design of Line, Circle & Ellipse Algorithms.
30/9/2008Lecture 21 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
Lecture 17 Fun with Graphics Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
OUTPUT PRIMITIVES Screen vs. World coordinate systems ● Objects positions are specified in a Cartesian coordinate system called World Coordinate.
Lecture 16 Fun with graphics
Raster conversion algorithms for line and circle
Implementation III Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Course Website: Computer Graphics 5: Line Drawing Algorithms.
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)
CS 450: COMPUTER GRAPHICS DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
Circle Drawing algo..
1/1/20001 Topic >>>> Scan Conversion CSE Computer Graphics.
College of Computer and Information Science, Northeastern UniversitySeptember 12, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture.
Dr. S.M. Malaek Assistant: M. Younesi
Jehee Lee Seoul National University
WHERE TO DRAW A LINE?? Line drawing is accomplished by calculating intermediate positions along the line path between specified end points. Precise definition.
Scan Conversion Line and Circle
Triangle Scan Conversion. 2 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rasterization Rasterization (scan conversion) –Determine which.
CS 325 Introduction to Computer Graphics 02 / 01 / 2010 Instructor: Michael Eckmann.
CSC505 Advanced Computer Graphics Dr. Craig Reinhart.
1Computer Graphics Implementation III Lecture 17 John Shearer Culture Lab – space 2
Introduction to Computer Graphics with WebGL
CS 480/680 Computer Graphics Implementation III Dr. Frederick C Harris, Jr. Fall 2011.
Does this point lie on this line? The Point-Slope format (y – y 1 ) = m(x – x 1 )
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
Curves. First of all… You may ask yourselves “What did those papers have to do with computer graphics?” –Valid question Answer: I thought they were cool,
Introduction Computer Graphics & Its application Types of computer graphics Graphic display : random Scan & Raster Scan display Frame buffer and video.
Graphics Output Primitives
CGMB214: Introduction to Computer Graphics
 A line segment in a scene is defined by the coordinate positions of the line end-points x y (2, 2) (7, 5)
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
10/15/02 (c) 2002 University of Wisconsin, CS559 Who Am I? Prof Stephen Chenney These notes will be online after the lecture – in fact they’re online already.
Midpoint Circle Algorithm
CS 325 Introduction to Computer Graphics 02 / 03 / 2010 Instructor: Michael Eckmann.
GEOMETRY AND LINE GENERATION Geometry and Line Generation Chapter 2.
CS 551 / 645: Introductory Computer Graphics
Lecture 13: Raster Graphics and Scan Conversion
Lecture 2: 19/4/1435 Graphical algorithms Lecturer/ Kawther Abas CS- 375 Graphics and Human Computer Interaction.
Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Computer Graphics Lecture 06 Circle Drawing Techniques Taqdees A. Siddiqi
Rasterization CENG 477 Introduction to Computer Graphics Slides from Steve Marschner, CS4620, 2008 Cornell University.
Scan Conversion of Line Segments. What is Scan conversion? Final step of rasterization (the process of taking geometric shapes and converting them into.
Computer Graphics I, Fall 2010 Scan conversion algorithms.
Rasterization, or “What is glBegin(GL_LINES) really doing?” Course web page: February 23, 2012  Lecture 4.
Line Drawing Algorithms 1. A line in Computer graphics is a portion of straight line that extends indefinitely in opposite direction. 2. It is defined.
Primitive graphic objects
(c) 2002 University of Wisconsin, CS559
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
University of New Mexico
Implementation III.
Prof. Harriet Fell Spring 2007 Lecture 5 – January 17, 2006
Chapter Three Part I Output Primitives CS 380.
Introduction to Computer Graphics with WebGL
Rasterizing Lines 1 Lecture 32 Mon, Nov 12, 2007.
Rasterization and Antialiasing
Computer Graphics Implementation III
Rasterization and Antialiasing
Implementation III Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Scan Conversion

Also known as rasterization In our programs objects are represented symbolically –3D coordinates representing an object’s position –Attributes representing color, motion, etc. But, the display device is a 2D array of pixels (unless you’re doing holographic displays) Scan Conversion is the process in which an object’s 2D symbolic representation is converted to pixels

Consider a straight line in 2D –Our program will [most likely] represent it as two end points of a line segment which is not compatible with what the display expects –We need a way to perform the conversion Scan Conversion (X 0, Y 0 ) (X 1, Y 1 ) Program Space (X 0, Y 0 ) (X 1, Y 1 ) (X n, Y n ) Display Space

Drawing Lines Equations of a line –Point-Slope Form: y = mx + b (also Ax + By + C = 0) ∆y ∆x m = ∆y ∆x b Y X As it turns out, this is not very convenient for scan converting a line

Drawing Lines Equations of a line –Two Point Form: –Directly related to the point-slope form but now it allows us to represent a line by two points – which is what most graphics systems use

Drawing Lines Equations of a line –Parametric Form: –By varying t from 0 to 1we can compute all of the points between the end points of the line segment – which is really what we want

Issues With Line Drawing Line drawing is such a fundamental algorithm that it must be done fast –Use of floating point calculations does not facilitate speed Furthermore, lines must be drawn without gaps –Gaps look bad –If you try to fill a polygon made of lines with gaps the fill will leak out into other portions of the display –Eliminating gaps through direct implementation of any of the standard line equations is difficult Finally, we don’t want to draw individual points more than once –That’s wasting valuable time

Bresenham’s Line Drawing Algorithm Jack Bresenham addressed these issues with the Bresenham Line Scan Convert algorithm –This was back in 1965 in the days of pen-plotters All simple integer calculations –Addition, subtraction, multiplication by 2 (shifts) Guarantees connected (gap-less) lines where each point is drawn exactly 1 time Also known as the midpoint line algorithm

Bresenham’s Line Algorithm Consider the two point-slope forms: algebraic manipulation yields: where: yielding:

Bresenham’s Line Algorithm Assume that the slope of the line segment is 0 ≤ m ≤ 1 Also, we know that our selection of points is restricted to the grid of display pixels The problem is now reduced to a decision of which grid point to draw at each step along the line –We have to determine how to make our steps Which point should we choose next?

Bresenham’s Line Algorithm What it comes down to is computing how close the midpoint (between the two grid points) is to the actual line (x p, y p ) (x p +1, y p +½)

Bresenham’s Line Algorithm Define F(m) = d as the discriminant –(derive from the equation of a line Ax + By + C) if (d m > 0) choose the upper point, otherwise choose the lower point

Bresenham’s Line Algorithm But this is yet another relatively complicated computation for every point Bresenham’s “trick” is to compute the discriminant incrementally rather than from scratch for every point

Bresenham’s Line Algorithm Looking one point ahead we have: (x p, y p ) m m2m2 m1m1

Bresenham’s Line Algorithm If d > 0 then discriminant is: If d < 0 then the next discriminant is: These can now be computed incrementally given the proper starting value

Bresenham’s Line Algorithm Initial point is (x 0, y 0 ) and we know that it is on the line so F(x 0, y 0 ) = 0! Initial midpoint is (x 0 +1, y 0 +½) Initial discriminant is F (x 0 +1, y 0 +½) = A(x 0 +1) + B(y 0 +½) + C = Ax 0 +By 0 + C + A + B/2 = F(x 0, y 0 ) + A + B/2 And we know that F(x 0, y 0 ) = 0 so

Bresenham’s Line Algorithm Finally, to do this incrementally we need to know the differences between the current discriminant (d m ) and the two possible next discriminants (d m1 and d m2 )

Bresenham’s Line Algorithm We know: We need (if we choose m1): or (if we choose m2):

Bresenham’s Line Algorithm Notice that ΔE and ΔNE both contain only constant, known values! Thus, we can use them incrementally – we need only add one of them to our current discriminant to get the next discriminant!

Bresenham’s Line Algorithm The algorithm then loops through x values in the range of x 0 ≤ x ≤ x 1 computing a y for each x – then plotting the point (x, y) Update step –If the discriminant is less than/equal to 0 then increment x, leaving y alone, and increment the discriminant by ΔE –If the discriminant is greater than 0 then increment x, increment y, and increment the discriminant by ΔNE This is for slopes less than 1 If the slope is greater than 1 then loop on y and reverse the increments of x’s and y’s Sometimes you’ll see implementations that the discriminant, ΔE, and ΔNE by 2 (to get rid of the initial divide by 2) And that is Bresenham’s algorithm

Summary Why did we go through all this? Because it’s an extremely important algorithm Because the problem demonstrates the “need for speed” in computer graphics Because it relates mathematics to computer graphics (and the math is simple algebraic manipulations) Because it presents a nice programming assignment…

Assignment Implement Bresenham's approach –You can search the web for this code – it’s out there –But, be careful because much of the code only does the slope < 1 case so you’ll have to add the additional code – it’s a copy/paste/edit job In your previous assignment, replace your calls to g2d.drawLine with calls to this new method