College of Computer and Information Science, Northeastern UniversitySeptember 12, 20151 CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture.

Slides:



Advertisements
Similar presentations
Circle Drawing Asst. Prof. Dr. Ahmet Sayar Kocaeli University
Advertisements

Graphics Primitives Part II: Bresenhams line and circle.
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
CS 376 Introduction to Computer Graphics 02 / 02 / 2007 Instructor: Michael Eckmann.
Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
+ CPCS 391 Computer Graphics 1 Instructor: Dr. Sahar Shabanah Lecture 3.
Lecture 5 Rendering lines 1.Steps of line rendering 2.Scan-conversion for line segments 3.A1 tutorial CP411 Computer Graphics Fall 2007 Wilfrid Laurier.
Computer Graphics Lecture 3 Line & Circle Drawing.
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 2 Line & Circle Drawing
CS 376 Introduction to Computer Graphics 01 / 29 / 2007 Instructor: Michael Eckmann.
College of Computer and Information Science, Northeastern UniversityApril 17, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 9.
3/2/04© University of Wisconsin, CS559 Spring 2004 Last Time General Perspective –Methods for specifying the view volume As a set of clip planes As a field.
Raster conversion algorithms for line and circle
Bresenham’s Midpoint Algorithm CS5600 Computer Graphics Rich Riesenfeld Spring 2006 Lecture Set 1.
CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics May 3, 2007.
Implementation III Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
CS 450: COMPUTER GRAPHICS DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
©College of Computer and Information Science, Northeastern UniversitySeptember 9, CS 4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture.
Dr. Scott Schaefer Scan Conversion of Lines. 2/78 Displays – Cathode Ray Tube.
1/1/20001 Topic >>>> Scan Conversion CSE Computer Graphics.
Scan Conversion. Also known as rasterization In our programs objects are represented symbolically –3D coordinates representing an object’s position –Attributes.
IT- 601: Computer Graphics Lecture-03 Scan Conversion
1 CS 430/536 Computer Graphics I Circle Drawing and Clipping Week 3, Lecture 6 David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent.
WHERE TO DRAW A LINE?? Line drawing is accomplished by calculating intermediate positions along the line path between specified end points. Precise definition.
Computing & Information Sciences Kansas State University CIS 536/636 Introduction to Computer Graphics Lecture 6 of 41 William H. Hsu Department of Computing.
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING ELLIPSES AND OTHER CURVES SPRING 2015 DR. MICHAEL J. REALE.
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.
Larry F. Hodges 1 Design of Line and Circle Algorithms.
College of Computer and Information Science, Northeastern UniversityOctober 12, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2006.
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.
College of Computer and Information Science, Northeastern UniversityOctober 17, CS 4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture 5.
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
Line Drawing and Generalization. Outline  overview  line drawing  circle drawing  curve drawing.
College of Computer and Information Science, Northeastern UniversityOctober 31, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2009.
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.
Lecture 13: Raster Graphics and Scan Conversion
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Write Bresenham’s algorithm for generation of line also indicate which raster locations would be chosen by Bresenham’s algorithm when scan converting.
Computer Graphics Lecture 06 Circle Drawing Techniques Taqdees A. Siddiqi
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.
Objectives Understand Bresenhams line drawing algorithm. Apply the algorithm to plot a line with the end points specified.
Primitive graphic objects
Scan Conversion or Rasterization
CS G140 Graduate Computer Graphics
(c) 2002 University of Wisconsin, CS559
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Scan Conversion or Rasterization
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
Prof. Harriet Fell Spring 2007 Lecture 9 – January 29, 2007
Scan Conversion of Circles
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:

College of Computer and Information Science, Northeastern UniversitySeptember 12, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 5 – January 14, 2009

College of Computer and Information Science, Northeastern UniversitySeptember 12, Today’s Topics Raster Algorithms  Lines - Section 3.5 in Shirley et al.  Antialiasing Line Attributes

College of Computer and Information Science, Northeastern UniversitySeptember 12, (3,1) (0,3) (0,0) Pixel Coordinates y x x = -0.5 y = -0.5 y = 3.5 x = 4.5

College of Computer and Information Science, Northeastern UniversitySeptember 12, (3,2) (0,0) (0,3) Pixel Coordinates y x x = -0.5 y = 3.5 y = -.5 x = 4.5

College of Computer and Information Science, Northeastern UniversitySeptember 12, What Makes a Good Line? Not too jaggy Uniform thickness along a line Uniform thickness of lines at different angles Symmetry, Line(P,Q) = Line(Q,P) A good line algorithm should be fast.

College of Computer and Information Science, Northeastern UniversitySeptember 12, Line Drawing

College of Computer and Information Science, Northeastern UniversitySeptember 12, Line Drawing

College of Computer and Information Science, Northeastern UniversitySeptember 12, Which Pixels Should We Color? Given P 0 = (x 0, y 0 ), P 1 = (x 1, y 1 ) We could use the equation of the line:  y = mx + b  m = (y 1 – y 0 )/(x 1 – x 0 )  b = y 1 - mx 1 And a loop for x = x 0 to x 1 y = mx + b draw (x, y) This calls for real multiplication for each pixel This only works if x 0  x 1 and |m|  1.

College of Computer and Information Science, Northeastern UniversitySeptember 12, Midpoint Algorithm Pitteway 1967 Van Aiken abd Nowak 1985 Draws the same pixels as Bresenham Algorithm Uses integer arithmetic and incremental computation. Uses a decision function to decide on the next point Draws the thinnest possible line from (x 0, y 0 ) to (x 1, y 1 ) that has no gaps. A diagonal connection between pixels is not a gap.

College of Computer and Information Science, Northeastern UniversitySeptember 12, Implicit Equation of a Line (x 0, y 0 ) (x 1, y 1 )f(x,y) = (y 0 – y 1 )x +(x 1 - x 0 )y + x 0 y 1 - x 1 y 0 We will assume x 0  x 1 and that m = (y 1 – y 0 )/(x 1 - x 0 ) is in [0, 1]. f(x,y) = 0 f(x,y) > 0 f(x,y) < 0

College of Computer and Information Science, Northeastern UniversitySeptember 12, Basic Form of the Algotithm y = y 0 for x = x 0 to x 1 do draw (x, y) if (some condition) then y = y + 1 Since m  [0, 1], as we move from x to x+1, the y value stays the same or goes up by 1. We want to compute this condition efficiently.

College of Computer and Information Science, Northeastern UniversitySeptember 12, Above or Below the Midpoint?

College of Computer and Information Science, Northeastern UniversitySeptember 12, Finding the Next Pixel Assume we just drew (x, y). For the next pixel, we must decide between (x+1, y) and (x+1, y+1). The midpoint between the choices is (x+1, y+0.5). If the line passes below (x+1, y+0.5), we draw the bottom pixel. Otherwise, we draw the upper pixel.

College of Computer and Information Science, Northeastern UniversitySeptember 12, The Decision Function if f(x+1, y+0.5) < 0 // midpoint below line y = y + 1 f(x,y) = (y 0 – y 1 )x +(x 1 - x 0 )y + x 0 y 1 - x 1 y 0 How do we compute f(x+1, y+0.5) incrementally? using only integer arithmetic?

College of Computer and Information Science, Northeastern UniversitySeptember 12, Incremental Computation f(x,y) = (y 0 – y 1 )x +(x 1 - x 0 )y + x 0 y 1 - x 1 y 0 f(x + 1, y) = f(x, y) + (y 0 – y 1 ) f(x + 1, y + 1) = f(x, y) + (y 0 – y 1 ) + (x 1 - x 0 ) y = y 0 d = f(x 0 + 1, y + 0.5) for x = x 0 to x 1 do draw (x, y) if d < 0 then y = y + 1 d = d + (y 0 – y 1 ) + (x 1 - x 0 ) else d = d + + (y 0 – y 1 )

College of Computer and Information Science, Northeastern UniversitySeptember 12, Integer Decision Function f(x,y) = (y 0 – y 1 )x +(x 1 - x 0 )y + x 0 y 1 - x 1 y 0 f(x 0 + 1, y + 0.5) = (y 0 – y 1 )(x 0 + 1) +(x 1 - x 0 )(y + 0.5) + x 0 y 1 - x 1 y 0 2f(x 0 + 1, y + 0.5) = 2(y 0 – y 1 )(x 0 + 1) +(x 1 - x 0 )(2y + 1) + 2x 0 y 1 - 2x 1 y 0 2f(x, y)= 0 if (x, y) is on the line. < 0 if (x, y) is below the line. > 0 if (x, y) is above the line.

College of Computer and Information Science, Northeastern UniversitySeptember 12, Midpoint Line Algorithm y = y 0 d = 2(y 0 – y 1 )(x 0 + 1) +(x 1 - x 0 )(2y 0 + 1) + 2x 0 y 1 - 2x 1 y 0 for x = x 0 to x 1 do draw (x, y) if d < 0 then y = y + 1 d = d + 2(y 0 – y 1 ) + 2(x 1 - x 0 ) else d = d + 2(y 0 – y 1 ) These are constants and can be computed before the loop.

College of Computer and Information Science, Northeastern UniversitySeptember 12, Some Lines

College of Computer and Information Science, Northeastern UniversitySeptember 12, Some Lines Magnified

College of Computer and Information Science, Northeastern UniversitySeptember 12, Antialiasing by Downsampling

College of Computer and Information Science, Northeastern UniversitySeptember 12, Antialiasing by Downsampling

College of Computer and Information Science, Northeastern UniversitySeptember 12, Antialiasing by Downsampling