CS 130. Scan Conversion. Raster Graphics

Similar documents
CPSC / Scan Conversion

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

Rasterization: Geometric Primitives

Rendering. A simple X program to illustrate rendering

Scan Converting Lines

Rendering. A simple X program to illustrate rendering

Digital Differential Analyzer Bresenhams Line Drawing Algorithm

Output Primitives. Dr. S.M. Malaek. Assistant: M. Younesi

From Ver(ces to Fragments: Rasteriza(on

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

Line Drawing Week 6, Lecture 9

Scan Conversion. Lines and Circles

CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE

Graphics System. Processor. Output Display. Input Devices. Frame Buffer. Memory. Array of pixels. Resolution: # of pixels Depth: # of bits/pixel

Rasterization, or What is glbegin(gl_lines) really doing?

Line Drawing. Foundations of Computer Graphics Torsten Möller

Section 1.1 The Distance and Midpoint Formulas

Output Primitives Lecture: 4. Lecture 4

Scan Conversion. Drawing Lines Drawing Circles

Chapter 8: Implementation- Clipping and Rasterization

Math 21a Tangent Lines and Planes Fall, What do we know about the gradient f? Tangent Lines to Curves in the Plane.

Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática. Chap. 2 Rasterization.

Realtime 3D Computer Graphics Virtual Reality

Computer Graphics. - Rasterization - Philipp Slusallek

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

CS488 2D Graphics. Luc RENAMBOT

Direction Fields; Euler s Method

Scan Conversion. CMP 477 Computer Graphics S. A. Arekete

Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling

Computer Graphics D Graphics Algorithms

Computer Graphics. Lecture 2. Doç. Dr. Mehmet Gokturk

Graphs of Equations. MATH 160, Precalculus. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Graphs of Equations

MODULE - 4. e-pg Pathshala

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6. ) is graphed below:

Each point P in the xy-plane corresponds to an ordered pair (x, y) of real numbers called the coordinates of P.

Scan Converting Circles

GRAPHICS OUTPUT PRIMITIVES

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics

WHAT YOU SHOULD LEARN

(Refer Slide Time: 00:03:51)

Topic #1: Rasterization (Scan Conversion)

Lesson 19: The Graph of a Linear Equation in Two Variables is a Line

CSCI 4620/8626. Coordinate Reference Frames

True/False. MATH 1C: SAMPLE EXAM 1 c Jeffrey A. Anderson ANSWER KEY

Computer Graphics D Graphics Algorithms

1 Introduction to Graphics

Rendering approaches. 1.image-oriented. 2.object-oriented. foreach pixel... 3D rendering pipeline. foreach object...

Rasterization. COMP 575/770 Spring 2013

Section 1.1 The Distance and Midpoint Formulas; Graphing Utilities; Introduction to Graphing Equations

Points and lines. x x 1 + y 1. y = mx + b

Test Name: Chapter 3 Review

Section Graphs and Lines

0. Introduction: What is Computer Graphics? 1. Basics of scan conversion (line drawing) 2. Representing 2D curves

The Rectangular Coordinate System and Equations of Lines. College Algebra

UNIT 3B CREATING AND GRAPHING EQUATIONS Lesson 4: Solving Systems of Equations Instruction

Efficient Plotting Algorithm

Math Analysis Chapter 1 Notes: Functions and Graphs

CS 130 Exam I. Fall 2015

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Computer Graphics

(Refer Slide Time: 9:36)

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6

Output Primitives Lecture: 3. Lecture 3. Output Primitives. Assuming we have a raster display, a picture is completely specified by:

In today s lecture we ll have a look at: A simple technique The mid-point circle algorithm

Rendering. Basic Math Review. Rasterizing Lines and Polygons Hidden Surface Remove Multi-pass Rendering with Accumulation Buffers.

Section 18-1: Graphical Representation of Linear Equations and Functions

Polar (BC Only) They are necessary to find the derivative of a polar curve in x- and y-coordinates. The derivative

EF432. Introduction to spagetti and meatballs

Math 231E, Lecture 34. Polar Coordinates and Polar Parametric Equations

Math-2. Lesson 3-1. Equations of Lines

Department of Computer Sciences Graphics Fall 2003 (Lecture 2) Pixels

Rasterization. CS4620/5620: Lecture 12. Announcements. Turn in HW 1. PPA 1 out. Friday lecture. History of graphics PPA 1 in 4621.

CMSC 435/634: Introduction to Graphics

CS-321 Thursday 12 September 2002 Quiz (3 pts.) What is the purpose of a control grid in a cathode ray tube (CRT)?

OUTPUT PRIMITIVES. CEng 477 Introduction to Computer Graphics METU, 2007

CS Rasterization. Junqiao Zhao 赵君峤

UNIT -8 IMPLEMENTATION

Sketching graphs of polynomials

Computer Graphics (CS 543) Lecture 10: Rasterization and Antialiasing

Introduction to Computer Graphics (CS602) Lecture 05 Line Drawing Techniques

Computer Graphics - Week 6

MATH 19520/51 Class 6

Math Analysis Chapter 1 Notes: Functions and Graphs

Functions. Copyright Cengage Learning. All rights reserved.

CS-184: Computer Graphics. Today

Overview of Computer Graphics

Objectives. Materials

Algebra 1 Semester 2 Final Review

CS 543: Computer Graphics. Rasterization

CS 450: COMPUTER GRAPHICS RASTERIZING LINES SPRING 2016 DR. MICHAEL J. REALE

a. Plot the point (x, y, z) and understand it as a vertex of a rectangular prism. c. Recognize and understand equations of planes and spheres.

6.7. POLAR COORDINATES

Line Drawing Algorithms

Objectives. Materials

Math 113 Calculus III Final Exam Practice Problems Spring 2003

Polynomial Functions Graphing Investigation Unit 3 Part B Day 1. Graph 1: y = (x 1) Graph 2: y = (x 1)(x + 2) Graph 3: y =(x 1)(x + 2)(x 3)

11.9 Three dimensional Coordinates

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Computer Graphics: 6-Rasterization

Transcription:

CS 130 Scan Conversion Raster Graphics 2 1

Image Formation Computer graphics forms images, generally two dimensional, using processes analogous to physical imaging systems like: - Cameras - Human visual system Images are generated and shown with specialized software and hardware 3 Introduction Synthetic images can be created like those taken by a camera For this class, we will draw directly on the image plane 4 2

Scan conversion Image Plane is a N x M grid of pixels This grid is similar to a coordinate system only it is discrete. 5 Scan conversion Scan conversion is taking the graphic from the continuous (thin) line to turning on pixels 6 3

Scan conversion Scan conversion algorithms compute integer coordinates for pixels near the line or circle Algorithms are invoked many, many times and so must be efficient Result should be visually pleasing, for example, they should have constant density Obviously, they should be able to draw the gamet of possible lines/circles and remain defined 7 2D math for lines Math Review How do we determine the equation of the line? (X2, Y2) (X1, Y1) 8 4

Math Review 2D math for lines Slope-Intercept formula for a line (X2, Y2) Slope = (Y2 Y1)/(X2 X1) ( Y - Y1)/(X - X1) Solving For Y (X1, Y1) (X, Y) Y = [(Y2 Y1)/(X2 X1)]X + [-(Y2 Y1)/(X2 - X1)]X1 + Y1 or Y = m X + b 9 Explicit (functional) representation y = f(x) Math Review y is the dependent, x independent variable Find value of y from value of x Example, for a line: for a circle: y = mx + b x 2 + y 2 = r 2 10 5

Math Review Implicit representation f(x,y) = 0 Called a membership function, test value of (x,y) to see if it belongs to the curve x,y treated the same, axis invariant Example, for a line: for a circle: ax + by + c = 0 x 2 + y 2 r 2 = 0 ax + by + c < 0? 11 Math Review Parametric Representation x = x(u), y = y(u) where new parameter u (or often t) determines the value of x and y (and possibly z) for each point x,y treated the same, axis invariant 12 6

Math Review Parametric formula for a line (X2, Y2) X = X1 + t(x2 X1) Y = Y1 + t(y2 Y1) for parameter t from 0 to 1 (X1, Y1) (X, Y) Therefore, when t = 0 we get (X1,Y1) t = 1 we get (X2,Y2) Varying t gives the points along the line segment 13 Math Review 2D math for circles Circle centered at origin X 2 + Y 2 = R 2 where R is the radius We can plot this as: R Y = +/- R 2 -X 2 14 7

Math Review 2D math for circles Y = R 2 -X 2 includes a fair amount of computation May want to parametric form: x = R cos y = R sin R With theta going from 0 to 360, Then use with a look-up sin/cos 15 Scan conversion Scan conversion is taking the graphic from the continuous (thin) line to turning on pixels 16 8

Scan conversion for lines 0 < M < 1 M > 1 17 DDA algorithm for lines Parametric Lines: the DDA algorithm for 0 < M < 1 (digital differential analyzer) Y i+1 = m x i+1 + B = m(x i + x) + B x = (x i+1 -x i ) = y i + m( x) <- must round to find int We increment by 1 pixel in X We turn on [xi, Round(yi)] - or same for Y if m > 1 18 9

Scan conversion for lines 19 Fast scan conversion for lines DDA includes Round( ); and this is fairly slow For Fast Lines, we want to do only integer math +,- We do this using the Midpoint Algorithm To do this, lets look at lines with y-intercept B and with slope between 0 and 1: y = (dy/dx)x + B ==> f(x,y) = (dy)x - (dx)y + B(dx) = 0 Removes the division => slope treated as 2 integers 20 10

Midpoint Algorithm For lines in the first octant, the next pixel is to the right or to the right and up one By looking at the difference between the line and the midpoint, e, we only need to look at the sign i.e.) no Round( ) needed midpoint e 21 Midpoint: Decision Variable Rewrite such that f(x,y) = ax + by + c (from f(x,y) = (dy)x - (dx)y + B(dx) =0) Then, f(x + 1, y + 1/2) is the next column's midpoint = a(x + 1) + b(y + 1/2) + c = d (this d is called the decision variable) if (d = 0) then the line passes on the midpoint if (d > 0) then the line passes above if (d < 0) then the line passes below 22 11

The question is how do we determine the value of d for a given line? For example to start, f(xo + 1, yo + 1/2) = d d = a(xo + 1) + b(yo + 1/2) + c = a(xo) + b(yo) + c + a + b/2 = f(xo,yo) + a + b/2 but f(xo,yo) = 0 = a + b/2 Midpoint: Decision Variable What about d after this first case? 23 Scan Converting Circles What problems arise when we think about scan conversion for circles (ie. when we increment one pixel in x, say) R 24 12

Scan Converting Circles What problems arise when we think about scan conversion for circles (ie. when we increment one pixel in x, say) 25 Scan Converting Circles Better approach takes into account the 8 way symmetry of each octant in a circle (Lets call this function circle_points ) 26 13

Fast Circles Only consider the first octant of the circle of radius r centered at origin Start from (r,0) and go until x < y (at 45 degrees) The decision is at each step to go up, or go over to the left and up 27 Fast Circles - via the midpoint f(x,y) = x 2 + y 2 -r 2 = 0 (x -1,y +1) midpoint e (x,y +1) Then for next decision (midpoint decides row) f(x-1/2, y +1) = d = (x - 1/2) 2 + (y + 1) 2 -r 2 Starting at y = 0, x = r this becomes = (r - 1/2) 2 + (0 + 1) 2 -r 2 = 5/4 - r (x,y) 28 14

Fast Circles - via the midpoint All thats left is to find the new d for the next step If (go up and over) d* = f(x - 1-1/2, (y + 1) + 1) = (x -3/2) 2 + (y + 2) 2 -r 2... = d - 2(x -1) + 2 (y + 1) + 1 = d + 2(y - x) + 5 Else (just go up) d* = f(x -1/2, (y + 1) + 1)... = d + 2(y) + 3 29 15