Scan Conversion.

Slides:



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

Graphics Primitives: 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.
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 Algorithms
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Komputer Grafik 2 (AK045206) Scan Conversion 1/31 Scan Conversion.
2D Output Primitives Graphics packages provide basic operations (called primitive operations) to describe a scene in terms of geometric structures. The.
Raster conversion algorithms for line and circle
Output Primitives Computer Graphics.
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.
Line Drawing by Algorithm. Line Drawing Algorithms Line drawn as pixels Graphics system –Projects the endpoints to their pixel locations in the frame.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Scan Conversion CS123 1 of 44Scan Conversion - 10/14/2014.
CSI 421: Computer Graphics
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.
Dr. Scott Schaefer Scan Conversion of Lines. 2/78 Displays – Cathode Ray Tube.
1/1/20001 Topic >>>> Scan Conversion CSE Computer Graphics.
IT- 601: Computer Graphics Lecture-03 Scan Conversion
Dr. S.M. Malaek Assistant: M. Younesi
Jehee Lee Seoul National University
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.
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.
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.
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
Graphics Graphics & Graphical Programming Lecture 14 - Lines & Circles.
Line Drawing and Generalization. Outline  overview  line drawing  circle drawing  curve drawing.
Chapter 3 Scan Conversion Lecture-02. Bresenham’s Line Algorithm Bresenham’s line algorithm – is a highly efficient incremental method for scan- converting.
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.
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
1 CSCE 441 Lecture 2: Scan Conversion of Lines Jinxiang Chai.
GEOMETRY AND LINE GENERATION Geometry and Line Generation Chapter 2.
Rasterization Overview Raster Display Device. Scan Conversion / Rasterization: converting vector graphics into raster graphics (determining pixels in.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Computer Graphics Inf4/MSc Computer Graphics Lecture 4 Line & Circle Drawing.
10/10/2006TCSS458A Isabelle Bichindaritz1 Line and Circle Drawing Algorithms.
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.
Primitive graphic objects
Scan Conversion or Rasterization
Computer Graphics Drawing Line.
CSCE 441 Lecture 2: Scan Conversion of Lines
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Scan Conversion or Rasterization
IT- 601: Computer Graphics Lecture-03 Scan Conversion
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
Rasterization and Antialiasing
Computer Graphics Implementation III
Rasterization and Antialiasing
Edited from The Rasterization Problem: Idealized Primitives Map to Discrete Display Space Edited from.
Chapter 3 Graphics Output Primitives
Implementation III Ed Angel Professor Emeritus of Computer Science
OUTPUT PRIMITIVES / DISPLAY TECHNIQUES
Presentation transcript:

Scan Conversion

Rasterization Final step in pipeline: rasterization (scan conv.) From screen coordinates (float) to pixels (int) Writing pixels into frame buffer Separate z-buffer, display, shading, blending Concentrate on primitives: Lines Polygons Uses Incremental Function Evaluation f(xi+1) = f(xi) + fxi Fast but cumulative Error Need to find f(x0)

DDA Algorithm DDA (“Digital Differential Analyzer”) Assume 0  m  1 else flip about y= x line. (xi,yi) (xi,Round(yi)) (xi,Round(yi+m)) (xi,yi +m) Desired Line void Line(int x0, int y0, int x1, int y1, int value) { double y = y0; double m = (y1 – y0) / (x0 – x1); // 0 <= m <= 1 for (int x = x0; x <= x1; x++) { WritePixel(x, Round(y), value); y += m; } } Require to eliminate floating point operations & variables

Midpoint Line Algorithm Assume 0  m  1 [ else flip about y= x line. ] (x0, y0) and (x1, y1) are integer values At each iteration we determine if the line intersects the next pixel above or below its midpoint y value. if above then NE  ynew = yp+1 otherwise E  ynew = yp d=F(M) > 0  NE P=(xp, yp) M E NE xp+1 xp yp+1 yp P=(xp, yp) M E NE xp xp+1 d=F(M) < 0  E yp+1 yp

Midpoint Line Algorithm P=(xp, yp) is pixel chosen by the algorithm in previous step To calculate d incrementally we require dnew If d > 0 then choose NE Yp+2 MNE NE Yp+1 M yp E P=(xp, yp) xp xp+1 xp+2 Next Previous Current

Midpoint Line Algorithm If d < 0 then choose E P=(xp, yp) M E NE xp+1 xp xp+2 Previous Current Next yp Yp+1 Yp+2 ME

Midpoint Line Algorithm To find Initial value of d NE M E P=(x0, y0) x0 x0+1 Only fractional value Start Initial do Multiply by 2 to avoid fractions. Redefine d0, E, NE

Midpoint Line Algorithm (xi,yi) P=(xp, yp) M E NE xp+1 xp xp+2 Previous Current Next void MidpointLine(int x0, int y0, int x1, int y1, int color) { int dx = x1 – x0, dy = y1 – y0; int d = 2*dy – dx; int dE = 2*dy, dNE = 2*(dy – dx); int x = x0, y = y0; WritePixel(x, y, color); while (x < x1) { if (d <= 0) { // Current d d += dE; // Next d at E x++; } else { d += dNE; // Next d at NE y++ } WritePixel(x, y, color); } (xi,yi) P=(xp, yp) M E NE xp+1 xp xp+2 Previous Current Next

Midpoint Circle Algorithm Implicit of equation of circle is: x2 + y2 - R2 = 0 Eight way symmetry  require to calculate one octant Define decision variable d as: P=(xp, yp) M E xp+1 xp xp+2 Previous Current Next ME yp yp – 1 yp – 2 SE MSE

Midpoint Circle Algorithm If d <= 0 then midpoint m is inside circle we choose E Increment x y remains unchanged P=(xp, yp) M E xp+1 xp xp+2 Previous Current Next ME yp yp – 1 yp – 2 d < 0

Midpoint Circle Algorithm If d > 0 then midpoint m is outside circle we choose E Increment x Decrement y P=(xp, yp) M SE xp+1 xp xp+2 Current Next MSE yp yp – 1 yp – 2 d > 0 Previous

Midpoint Circle Algorithm Initial condition Starting pixel (0, R) Next Midpoint lies at (1, R – ½) d0 = F(1, R – ½) = 1 + (R2 – R + ¼) – R2 = 5/4 – R To remove the fractional value 5/4 : Consider a new decision variable h as, h = d – ¼ Substituting d for h + ¼, d0=5/4 – R  h = 1 – R d < 0  h < – ¼  h < 0 Since h starts out with an integer value and is incremented by integer value (E or SE), e can change the comparison to just h < 0

Midpoint Circle Algorithm void MidpointCircle(int radius, int value) { int x = 0; int y = radius ; int d = 1 – radius ; CirclePoints(x, y, value); while (y > x) { if (d < 0) { /* Select E */ d += 2 * x + 3; } else { /* Select SE */ d += 2 * ( x – y ) + 5; y – –; } x++;

Midpoint Circle Algorithm Second-order differences can be used to enhance performance. E M SE MSE E is chosen SE is chosen

Midpoint Circle Algorithm void MidpointCircle(int radius, int value) { int x = 0; int y = radius ; int d = 1 – radius ; int dE = 3; int dSE = -2*radius +5; CirclePoints(x, y, value); while (y > x) { if (d < 0) { /* Select E */ d += dE; dE += 2; dSE += 2; } else { /* Select SE */ d += dSE; dSE += 4; y – –; } x++;

Midpoint Ellipse Algorithm Implicit equation is: F(x,y) = b2x2 + a2y2 – a2b2 = 0 We have only 4-way symmetry There exists two regions In Region 1 dx > dy Increase x at each step y may decrease In Region 2 dx < dy Decrease y at each step x may increase At region boundary: (x1,y1) (-x1,y1) (x1,-y1) (-x1,-y1) (-x2,y2) (-x2,-y2) (x2,y2) (x2,-y2) Region 1 Region 2 S SE E Gradient Vector Tangent Slope = -1

Midpoint Ellipse Algorithm In region 1 P=(xp, yp) M E xp+1 xp xp+2 Previous Current Next ME yp yp – 1 yp – 2 SE MSE

Midpoint Ellipse Algorithm In region 2 P=(xp, yp) M S xp+1 xp xp+2 Previous Current Next MS yp yp – 1 yp – 2 SE MSE

Self Study Pseudo code for midpoint ellipse algorithm Derive 2nd order difference equations for midpoint ellipse algorithm.

Side Effects of Scan Conversion The most common side effects when working with raster devices are: Aliasing Unequal intensity Overstrike

1. Aliasing jagged appearance of curves or diagonal lines on a display screen, which is caused by low screen resolution. Refers to the plotting of a point in a location other than its true location in order to fit the point into the raster. Consider equation y = mx + b For m = 0.5, b = 1 and x = 3 : y = 2.5 So the point (3,2.5) is plotted at alias location (3,3) Remedy Apply anti-aliasing algorithms. Most of these algorithms introduce extra pixels and pixels are intensified proportional to the area of that pixel covered by the object. [dithering.]

2. Unequal Intensity Human perception of light is dependent on 1.44 1 Human perception of light is dependent on Density and Intensity of light source. Thus, on a raster display with perfect squareness, a diagonal line of pixels will appear dimmer that a horizontal or vertical line. Remedy If speed of scan conversion main then ignore By increasing the number of pixels in diagonal lines By increasing the number of pixels on diagonal lines.

3. Overstrike The same pixel is written more than once. This results in intensified pixels in case of photographic media, such as slide or transparency Remedy Check each pixel to see whether it has already been written to prior to writing a new point.