Line Drawing Algorithms. Rasterization-Process of determining which pixels give the best approximation to a desired line on the screen. Scan Conversion-Digitizing.

Slides:



Advertisements
Similar presentations
Line Drawing Algorithms
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.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Drawing Elementary Figures Dr. Eng. Farag Elnagahy.
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.
Scan Conversion Algorithms
Scan conversion of Line , circle & ellipse
Computer Graphics Lecture 3 Line & Circle Drawing.
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
The lines of this object appear continuous However, they are made of pixels 2April 13, 2015.
OUTPUT PRIMITIVES Screen vs. World coordinate systems ● Objects positions are specified in a Cartesian coordinate system called World Coordinate.
In the name of God Computer Graphics Bastanfard.
Raster conversion algorithms for line and circle
Output Primitives Computer Graphics.
Line Drawing by Algorithm. Line Drawing Algorithms Line drawn as pixels Graphics system –Projects the endpoints to their pixel locations in the frame.
CS 450: COMPUTER GRAPHICS DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
Circle Drawing algo..
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.
Objectives Differentiate between raster scan display and random scan display.
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
 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.
Image Synthesis Rabie A. Ramadan, PhD 7. 2 Image Rasterization.
1 CSCE 441 Lecture 2: Scan Conversion of Lines Jinxiang Chai.
GEOMETRY AND LINE GENERATION Geometry and Line Generation Chapter 2.
In the name of God Computer Graphics. Today Introduction Sampling Graphic Output Primitives 1.Line 2.Circle 3.Curve 4.polygon.
Rendering.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
Bresenham’s Line Algorithm
OUTPUT PRIMITIVES A.Aruna/Faculty of Information technology/SNSCE13/19/2016.
Lecture 2: 19/4/1435 Graphical algorithms Lecturer/ Kawther Abas CS- 375 Graphics and Human Computer Interaction.
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 Inf4/MSc Computer Graphics Lecture 4 Line & Circle Drawing.
10/10/2006TCSS458A Isabelle Bichindaritz1 Line and Circle Drawing Algorithms.
Rasterization CENG 477 Introduction to Computer Graphics Slides from Steve Marschner, CS4620, 2008 Cornell University.
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 : output primitives.. 2 of 32 T1 – pp. 103–123, 137–145, 147–150, 164–171 Points and LinesPoints Line Drawing AlgorithmsLine Mid–Point.
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.
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
CSCE 441 Lecture 2: Scan Conversion of Lines
Raster Graphics.
Lecture 9 Line Drawing Algorithms (Bresenham’s Line Algorithm)
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Lecture 8 Shear and Line Drawing Algorithms
University of New Mexico
Implementation III.
Chapter Three Part I Output Primitives CS 380.
Introduction to Computer Graphics with WebGL
CSCE 441 Lecture 2: Scan Conversion of Lines
Rasterization and Antialiasing
Computer Graphics Implementation III
Rasterization and Antialiasing
Chapter 3 Graphics Output Primitives
Primitive Drawing Algorithm
Primitive Drawing Algorithm
Presentation transcript:

Line Drawing Algorithms

Rasterization-Process of determining which pixels give the best approximation to a desired line on the screen. Scan Conversion-Digitizing a picture definition given in an application program into a set of pixel intensity values for storage in the frame buffer.

Output primitives -Basic geometric structures. A scene is described in such a way that the graphics programming packages provide functions to describe a scene in terms of basic geometric structures called output primitives and to group sets of o/p primitives into more complex structures Each output primitive is specified with the input coordinate data and other information about the way that object is to be displayed.

Points- Point plotting is accomplished by converting a single coordinate position in an application program into appropriate operations for the output device in use. Line- Line drawing is accomplished by calculating intermediate positions along the line path between 2 specified end point positions. The output device is directed to fill these positions between the end points.

Scan Line number Pixel Column number

x1 x2 y1 y2 Straight line segment with 5 sampling positions along the x axis and y axis

The Cartesian slope intercept eqn for straight line is y = m x + b (x1,y1) & (x2,y2) be the two endpoints of the line, then m=(y2-y1)/(x2-x1)‏ b= y1- mx1 i.e y1 = mx1 + b y2 = mx2 + b (3) –(2)‏ ( y2-y1) = m (x2 – x1)‏ m=(y2-y1)/(x2-x1) ie ∆y/ ∆x (2)‏ (3)‏ (1)‏

For any given x interval ∆x along a line, compute the corresponding y interval ∆y as ∆y = m ∆x Similarly the x interval is obtained as ∆x = ∆y /m The above eqns form the basis for determining deflection voltages.

Lines with slope magnitude |m| <1, ∆x is set proportional to a small horizontal deflection voltage and the corresponding vertical deflection voltage ∆y is ∆y = m ∆x ∆x> ∆y Lines with slope magnitude |m| >1, ∆y is set proportional to a small vertical deflection voltage and the corresponding horizontal deflection voltage is ∆x = ∆y /m ∆y> ∆x P1 P2 P1 P2

Digital Differential Algorithm(DDA)‏ Scan conversion algorithm based on calculating either ∆x or ∆y. Sample the line at unit intervals in one coordinate and determine the corresponding integer values nearest the line path for the other coordinate. Case 1 Line with positive slope less than or equal to 1, we sample at unit x intervals (∆x =1) and determine the successive y value as Y k+1 = Yk + m ∆y=m ∆x Yk+1- Yk =m ∆x Yk+1- Yk =m (∆x =1)‏

k takes integer values starting from 1 and increases by 1 until the final point is reached. m can be any number between 0 and 1. Calculated y values must be rounded off to the nearest integer. For lines with positive slope greater than 1, sample at unit y intervals (∆y = 1) and calculate each successive x value as x k+1 = x k + 1/m The above eqns are based on the assumption that lines are processed from left to right. If the processing is reversed then ∆x = -1 & y k+1 = y k – m Slope <1 ∆y = -1 & x k+1 = x k -1/m Slope >1

Steps P1 ( xa,ya) and P2 (xb,yb) are the two end points. 2. Horizontal and vertical differences between the endpoint positions are computed & assigned to two parameters namely dx and dy. 3. The difference with greater magnitude determines the ‘value’ of increments to be done. That means the number of times sampling has to be done. This value is assigned to a parameter called ‘steps’.

4. Starting from the 1 st pixel,we determine the offset needed at each step to generate the next pixel position along the line path. Call the offset value as x increment and y increment. The starting points are xa and ya. Assign x =xa and y=ya x= x+ x incr & y= y+ y incr 5. Loop through the process steps times, till the last point xb, yb is reached. P1 (xa,ya)‏ P2 (xb,yb)‏

Step 1: Accept as input the 2 end point pixel position. P1(xa,ya)P2 (xb, yb)‏ Step 2: Horizontal and vertical differences between the endpoint positions are computed & assigned to two parameters namely dx and dy. dx= xb – xady = yb - ya Steps for DDA Algorithm

Step 3: If abs(dx) >abs(dy) steps =abs( dx)‏ else steps =abs( dy)‏ Step 4: x incr = dx/steps (if steps = abs(dx), xincr = 1)‏ y incr =dy/steps (ie dy/dx = m)‏ Assign x= xa and y=ya x= x+ x incr & y= y+ y incr Step 5: Loop through the process steps times.

Advantages DDA algorithm is a faster method for calculating the pixel positions than the direct use of line equation. It eliminates multiplication by making use of raster characteristics. Disadvantages DDA algorithm runs slowly because it requires real arithmetic (floating point operations) and rounding operations.