Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt The Rasterization Problem: Idealized Primitives Map to Discrete Display Space Edited from.

Slides:



Advertisements
Similar presentations
Graphics Primitives: line
Advertisements

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.
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
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.
Scan Conversion Algorithms
Scan conversion of Line , circle & ellipse
CS 376 Introduction to Computer Graphics 01 / 29 / 2007 Instructor: Michael Eckmann.
Lecture 16 Fun with graphics
Komputer Grafik 2 (AK045206) Scan Conversion 1/31 Scan Conversion.
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.
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 / 45 Computer Graphics Implementation I.
University of Missouri at Columbia 2D Scan-line Conversion University of Missouri at Columbia.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Scan Conversion CS123 1 of 44Scan Conversion - 10/14/2014.
CS 450: COMPUTER GRAPHICS DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
Dr. Scott Schaefer Scan Conversion of Lines. 2/78 Displays – Cathode Ray Tube.
1/1/20001 Topic >>>> Scan Conversion CSE Computer Graphics.
Dr. S.M. Malaek Assistant: M. Younesi
Graphics Primitives: line. Pixel Position
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
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.
CS 325 Introduction to Computer Graphics 02 / 01 / 2010 Instructor: Michael Eckmann.
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.
Graphics Graphics & Graphical Programming Lecture 14 - Lines & Circles.
Introduction Computer Graphics & Its application Types of computer graphics Graphic display : random Scan & Raster Scan display Frame buffer and video.
Line Drawing and Generalization. Outline  overview  line drawing  circle drawing  curve drawing.
 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.
Computer Graphics Drawing Line. Lines and Polylines Convex: For every pair of points in the polygon, the line between them is fully contained in the polygon.
CS-321 Dr. Mark L. Hornick 1 Line Drawing Algorithms.
1 CSCE 441 Lecture 2: Scan Conversion of Lines Jinxiang Chai.
GEOMETRY AND LINE GENERATION Geometry and Line Generation Chapter 2.
Scan Conversion.
Bresenham’s Line Algorithm
Example: (7,9) (12,0) Example 2: Point1 V:(7,9 ) C:( 0,255,0) Point2 V:(12,0) C:(0,255,0) (0,0) (18,0) (0,9) What are the problems with this method? Slope>1.
Lecture 2: 19/4/1435 Graphical algorithms Lecturer/ Kawther Abas CS- 375 Graphics and Human Computer Interaction.
Rasterization Overview Raster Display Device. Scan Conversion / Rasterization: converting vector graphics into raster graphics (determining pixels in.
Computer Graphics Inf4/MSc Computer Graphics Lecture 4 Line & Circle Drawing.
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.
Pattern filling in scan-conversion Antialiasing
Scan Conversion or Rasterization
Computer Graphics Drawing Line.
CSCE 441 Lecture 2: Scan Conversion of Lines
Computer graphics 2D graphics.
CENG 477 Introduction to Computer Graphics
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Scan Conversion or Rasterization
University of New Mexico
Implementation III.
Computer Graphics Implementation I.
Chapter Three Part I Output Primitives CS 380.
Introduction to Computer Graphics with WebGL
CSCE 441 Lecture 2: Scan Conversion of Lines
2D Scan-line Conversion
Introduction to Computer Graphics
Rasterization and Antialiasing
Computer Graphics Implementation III
Rasterization and Antialiasing
Chapter 3 Graphics Output Primitives
Implementation III Ed Angel Professor Emeritus of Computer Science
Line Drawing Algorithms
OUTPUT PRIMITIVES / DISPLAY TECHNIQUES
Presentation transcript:

Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt The Rasterization Problem: Idealized Primitives Map to Discrete Display Space Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt 更新时间2019年2月19日星期二5时35分45秒

Solution Involves Selection of Discrete Representation Values Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Scan Converting Lines: Characterizing the Problem ideal line i.e. for each x, choose y i.e. for each y, choose x Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Scan Converting Lines: The Strategy Pick pixels closest to endpoints Select in between pixels “closest” to ideal line Objective: To minimize the required calculations. Pixels can be displayed in multiple shapes and sizes. In OpenGL, the centers of pixels are located at values halfway between intergers. Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Scan Converting Lines: DDA (Digital Differential Analyzer) Algorithm Calculate ideal line equation Starting at leftmost point: for each xi Calculate Select pixel at Selected Not Selected Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Scan Converting Lines: DDA Algorithm, Incremental Form Therefore, rather than recomputing y in each step, simply add m. The Algorithm: void Line(int x0, int y0, int xn, int yn) { int x; float dy, dx, y, m; dy = yn - y0; dx = xn - x0; m = dy/dx; y = y0; for (x = x0; x<=xn,x++){ WritePixel(x, round(y)); y += m; } Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt We assume m ≤1 in the above. For larger slope, the separation between pixels can be large, generating an unacceptable rendering of the line segment. We swap the roles of x and y for line segments with larger slopes. Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Bresenham’s Algorithm: Allowable Pixel Selections DDA requires a floating-point addition. Bresenham derived an algorithm that avoids all floating-point claculations. Option NE Option E Not Allowed Last Selection 0 <= Slope <= 1 Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Bresenham’s Algorithm: Iterating 0 <= Slope <= 1 Select NE Select E Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Bresenham’s Algorithm Decision Function: (implicit equation of the line) Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Bresenham’s Algorithm: Calculating the Decision Function Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Bresenham’s Algorithm: Incremental Calculation of di Option NE Option E Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Bresenham’s Algorithm: The Code void BresenhamLine(int x0, int y0, int xn, int yn) { int dx,dy,incrE,incrNE,d,x,y; dx=xn-x0; dy=yn-y0; d=2*dy-dx; /* initial value of d */ incrE=2*dy; /* decision funct incr for E */ incrNE=2*dy-2*dx; /* decision funct incr for NE */ x=x0; y=y0; DrawPixel(x,y) /* draw the first pixel */ while (x<xn){ if (d<=0){ /* choose E */ d+=incrE; x++; /* move E */ }else{ /* choose NE */ d+=incrNE; x++; y++; /* move NE */ } DrawPixel (x,y); Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Bresenham’s Algorithm An example 12 11 10 9 8 7 4 5 6 7 8 9 Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Bresenham’s Algorithm An example 12 11 10 9 8 7 4 5 6 7 8 9 Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Bresenham’s Algorithm An example 12 11 10 9 8 7 4 5 6 7 8 9 Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt

Another derivation: comparing d1 and d2 Allowed Option NE 0 <= Slope <= 1 d1 d2 Last Selection Option E Ref. [HA], Section 3.2.2 Edited from http://www.comp.hkbu.edu.hk/~sci3750/lect8-04.ppt