Chapter 3 Graphics Output Primitives

Slides:



Advertisements
Similar presentations
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
Advertisements

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.
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.
OUTPUT PRIMITIVES Screen vs. World coordinate systems ● Objects positions are specified in a Cartesian coordinate system called World Coordinate.
Raster conversion algorithms for line and circle
Output Primitives Computer Graphics.
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.
Graphics Output Primitives Pixel Addressing and Fill Area Dr. M. Al-Mulhem Feb. 1, 2008.
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..
CGMB214: Introduction to Computer Graphics
1/1/20001 Topic >>>> Scan Conversion CSE Computer Graphics.
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
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING ELLIPSES AND OTHER CURVES SPRING 2015 DR. MICHAEL J. REALE.
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.
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
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Image Synthesis Rabie A. Ramadan, PhD 7. 2 Image Rasterization.
Midpoint Circle Algorithm
1 CSCE 441 Lecture 2: Scan Conversion of Lines Jinxiang Chai.
In the name of God Computer Graphics. Today Introduction Sampling Graphic Output Primitives 1.Line 2.Circle 3.Curve 4.polygon.
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.
10/10/2006TCSS458A Isabelle Bichindaritz1 Line and Circle Drawing Algorithms.
Computer Graphics Lecture 07 Ellipse and Other Curves Taqdees A. Siddiqi
Computer Graphics Lecture 06 Circle Drawing Techniques Taqdees A. Siddiqi
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.
OUTPUT PRIMITIVES CEng 477 Computer Graphics METU, 2004.
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
CSCE 441 Lecture 2: Scan Conversion of Lines
Raster Graphics.
MID-POINT CIRCLE ALGORITHM
Chapter 10 Conic Sections
Lecture 9 Line Drawing Algorithms (Bresenham’s Line Algorithm)
(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.
Lecture 05: Mid-point Ellipse algorithm Dr. Manal Helal – Fall 2014
Chapter Three Part I Output Primitives CS 380.
Introduction to Computer Graphics with WebGL
Scan Conversion of Circles
Rasterization and Antialiasing
Computer Graphics Implementation III
Rasterization and Antialiasing
Scan Conversion (From geometry to pixels)
Primitive Drawing Algorithm
Primitive Drawing Algorithm
Implementation III Ed Angel Professor Emeritus of Computer Science
OUTPUT PRIMITIVES / DISPLAY TECHNIQUES
Presentation transcript:

Chapter 3 Graphics Output Primitives Computer Graphics Chapter 3 Graphics Output Primitives

Display screen과 Frame Buffer Frame buffer Display screen 2019-04-16 Computer Vision & Pattern Recognition Lab.

Computer Vision & Pattern Recognition Lab. 1. Point Point plotting : converting a single coordinate position setPixel(x,y) getPixel(x,y,color) addr(x,y) = addr(0,0) + y(xmax+1) +x addr(x+1,y) = addr(x,y) + 1 addr(x, y+1) = addr(x,y) + (xmax+1) 2019-04-16 Computer Vision & Pattern Recognition Lab.

Computer Vision & Pattern Recognition Lab. 2. Line Line drawing Calculating intermediate positions along the line path between two specified endpoint positions Output device is directed to fill in these positions between the endpoints Digital devices - Plotting discrete points between the two endpoints ⇒ jaggies - Calculate from the equation of the line 2019-04-16 Computer Vision & Pattern Recognition Lab.

3. Line-Drawing Algorithms Problem: Given start and end points,      -. Find sequence of pixels (integer coor.) as close to ideal line as possible (Given point drawing software)      -. Issues: Correctness(accuracy) and Effectiveness(Speed) Slope-intercept equation For each x, compute y (if m<1). or For each y, compute x (if m>1). => Floating point multiplication, addition, and rounding 2019-04-16 Computer Vision & Pattern Recognition Lab.

3. Line-Drawing Algorithms DDA Algorithm Digital Differential Analyzer Scan-conversion line algorithm Calculate either ∆x or ∆y Left endpoint → right endpoint ⇒ slope ≤ 1 ; yk+1 = yk + m (∆x=1) ⇒ slope > 1 ; xk+1 = xk + 1/m(∆y=1) Right endpoint → left endpoint ⇒ slope ≤ 1 ; yk+1 = yk - m (∆x=-1) ⇒ slope > 1 ; xk+1 = xk - 1/m(∆y=-1) Floating point addition & rounding 2019-04-16 Computer Vision & Pattern Recognition Lab.

3. Line-Drawing Algorithms Midpoint algorithm (Bresenham’s line algorithm) An accurate and efficient raster line-generating algorithm Use only incremental integer calculations that can be adapted to display circles and curves 2019-04-16 Computer Vision & Pattern Recognition Lab.

3. Line-Drawing Algorithms Assume : 0 < m < 1 Given (xk, yk), choose NE or E  ⇒  Is M below the line ? Let 2019-04-16 Computer Vision & Pattern Recognition Lab.

3. Line-Drawing Algorithms Let decision variable Approach:            (1) test the sign of pk            (2) select E or NE            (3) update pk+1 using pk 2019-04-16 Computer Vision & Pattern Recognition Lab.

3. Line-Drawing Algorithms 2019-04-16 Computer Vision & Pattern Recognition Lab.

3. Line-Drawing Algorithms To avoid , let only integer addition 2019-04-16 Computer Vision & Pattern Recognition Lab.

3. Line-Drawing Algorithms 2019-04-16 Computer Vision & Pattern Recognition Lab.

3. Line-Drawing Algorithms Note: -. Generalization -. Special case can be handled separately Horizontal lines (Δy = 0) Vertical lines (Δx = 0) Diagonal lines with |Δx| = |Δy| -. H/W dependent address generation ⇒ fast -. Additional Issues Use of symmetry ⇒ faster       Independence of endpoint order        Anti-aliasing Parallel algorithm 2019-04-16 Computer Vision & Pattern Recognition Lab.

4. Circle generating algorithms Problem: Given center & radius, generate a circle. Integer coordinates Accuracy and Efficiency Properties of circles Center : (xc, yc), distance : r (x - xc)2 + (y - yc)2 = r2 y = yc ± √ r2 – (x - xc)2 Multiplication, square root Problem At each step, considerable computation Unequally spacing Another way to eliminate the unequal spacing 2019-04-16 Computer Vision & Pattern Recognition Lab.

4. Circle generating algorithms Parametric polar form x = xc + r·cosθ y = yc + r·sinθ Multiplication, trigonometric calculation For a continuous boundary, set the angular step size at 1/r Considering the symmetry of circles Quadrant Octants Position (x, y) on a one-eighth circle sector is mapped into the seven circle points in the other octants of the xy plane 2019-04-16 Computer Vision & Pattern Recognition Lab.

4. Circle generating algorithms Midpoint circle algorithm Problem: Given center & radius, generate a circle. Assume: center at the origin Consider only 2nd octant and use 8-way symmetry. Given (xk, yk), choose E (xk+1, yk) or SE (xk+1, yk-1) ⇒  Is Midpoint inside the circle? fcirc(x, y) = x2 + y2 – r2 fcirc(x, y) = 0, if (x, y) is on the circle boundary < 0, if (x, y) is inside the circle boundary > 0, if (x, y) is outside the circle boundary 2019-04-16 Computer Vision & Pattern Recognition Lab.

4. Circle generating algorithms Decision function : pk = fcirc(xk+1, yk-1/2) Approach : (1) test the sign of pk        (2) select E or SE        (3) update pk+1 using pk pk = fcirc (xk+1, yk-1/2) = (xk+1)2 + (yk-1/2)2 – r2 If pk<0, select E (xk+1= xk +1, yk +1 = yk ) pk+1 = fcirc (xk +2, yk-1/2) = (xk+2)2 + (yk-1/2)2 – r2 = pk+ 2xk + 3 <= (xk = xk+1 -1) = pk+ 2xk +1 + 1 Otherwise, select SE (xk+1= xk +1, yk +1 = yk -1) pk+1 = fcirc (xk+2, yk-3/2) = (xk+2)2 + (yk-3/2)2 – r2 = xk2 + 4xk + 4 + yk2 – 3yk + 9/4 – r2 = pk+ 2xk – 2yk + 5 <= (xk = xk+1–1, yk = yk+1+1) = pk+ 2(xk +1 – yk +1 ) + 1 2019-04-16 Computer Vision & Pattern Recognition Lab.

4. Circle generating algorithms Initial decision function : p0 = fcirc(1, r-1/2) = 1 + (r -1/2)2 – r2 = 5/4 – r If r is specified as an integer, p0 = 1- r 2019-04-16 Computer Vision & Pattern Recognition Lab.

Computer Vision & Pattern Recognition Lab. 2019-04-16 Computer Vision & Pattern Recognition Lab.

5. Ellipse generating algorithms 2019-04-16 Computer Vision & Pattern Recognition Lab.

Computer Vision & Pattern Recognition Lab. 6. Other Curves Conic section Ax2 + By2 + Cxy + Dx + Ey + F = 0 B – 4AC < 0 : generates an ellipse = 0 : generates a parabola > 0 : generates s hyperbola Polynomials and spline curves Polynomial function of n-th degree in x y = ∑akxk Useful in a number of graphics applications 2019-04-16 Computer Vision & Pattern Recognition Lab.

7. Pixel addressing & object geometry Maintaining geometric properties of displayed objects Pixel area : referenced by the integer coordinates of its lower left corner Adjust the length of the displayed line by omitting one of the endpoint pixel 2019-04-16 Computer Vision & Pattern Recognition Lab.

7. Pixel addressing & object geometry 2019-04-16 Computer Vision & Pattern Recognition Lab.

8. Filled-Area Primitives Inside-outside tests Odd-even rule If # of crossings is odd, interior. If # of crossings is even, exterior.         (Make sure there is no crossing at vertex) Nonzero winding number rule Step 1: Count directional crossing of PP' to each polygon edge               (Use vector product.)   If right to left, increment winding #.   If left to right, decrement winding #. Step 2: If winding # is nonzero, interior (more versatile than the odd-even rule) 2019-04-16 Computer Vision & Pattern Recognition Lab.