Introduction Computer Graphics & Its application Types of computer graphics Graphic display : random Scan & Raster Scan display Frame buffer and video.

Slides:



Advertisements
Similar presentations
Contents In today’s lecture we’ll have a look at:
Advertisements

Graphics Primitives Part II: Bresenhams line and circle.
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.
CS 376 Introduction to Computer Graphics 02 / 02 / 2007 Instructor: Michael Eckmann.
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.
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.
Lecture 16 Fun with graphics
Raster conversion algorithms for line and circle
CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics May 3, 2007.
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.
CS 450: COMPUTER GRAPHICS DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
Circle Drawing algo..
Computer Graphics- SCC 342
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.
CS 325 Introduction to Computer Graphics 02 / 01 / 2010 Instructor: Michael Eckmann.
Graphics Graphics & Graphical Programming Lecture 14 - Lines & Circles.
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)
Chapter 3 Scan Conversion Lecture-02. Bresenham’s Line Algorithm Bresenham’s line algorithm – is a highly efficient incremental method for scan- converting.
Image Synthesis Rabie A. Ramadan, PhD 7. 2 Image Rasterization.
MIDPOINT CIRCLE & ELLIPSE GENERARTING ALGORITHMS
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.
Graphics Output Primitives Hearn & Baker Chapter 3
CS 325 Introduction to Computer Graphics 02 / 03 / 2010 Instructor: Michael Eckmann.
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.
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.
Instructor: Dr. Shereen Aly Taie If (P>0)
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.
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.
Computer Graphics Lecture 07 Ellipse and Other Curves Taqdees A. Siddiqi
Computer Graphics Lecture 06 Circle Drawing Techniques Taqdees A. Siddiqi
Rasterization CENG 477 Introduction to Computer Graphics Slides from Steve Marschner, CS4620, 2008 Cornell University.
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.
Computer Graphics Lecture 05 Line Drawing Techniques Taqdees A. Siddiqi
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.
Objectives Understand Bresenhams line drawing algorithm. Apply the algorithm to plot a line with the end points specified.
Primitive graphic objects
Computer Graphics Drawing Line.
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
Chapter Three Part I Output Primitives CS 380.
2D Scan-line Conversion
Rasterization and Antialiasing
Rasterization and Antialiasing
Chapter 3 Graphics Output Primitives
Type to enter a caption. Computer Graphics Week 1 Lecture 2.
Line Drawing Algorithms
Presentation transcript:

Introduction Computer Graphics & Its application Types of computer graphics Graphic display : random Scan & Raster Scan display Frame buffer and video Controller Points & Lines, line Drawing Algorithm Circle Generation algorithm Mid point circle generation algorithm Parallel version of these algorithm Point & Line Generation

Line Based on slope-intercept algorithm from algebra: y = mx + b Simple approach: increment x, solve for y Floating point arithmetic required

DDA algorithm DDA = Digital Differential Analyser –finite differences Treat line as parametric equation in t : Start point - End point -

DDA Algorithm Start at t = 0 At each step, increment t by dt Choose appropriate value for dt Ensure no pixels are missed: –Implies: and Set dt to maximum of dx and dy

DDA algorithm line(int x1, int y1, int x2, int y2) { float x,y; int dx = x2-x1, dy = y2-y1; int n = max(abs(dx),abs(dy)); float dt = n, dxdt = dx/dt, dydt = dy/dt; x = x1; y = y1; while( n-- ) { point(round(x),round(y)); x += dxdt; y += dydt; }

DDA algo. Start. Declare variables x,y,x1,y1,x2,y2,k,dx,dy,s,xi,yi and also declare gdriver=DETECT,gmode. Initialise the graphic mode with the path location in TC folder. Input the two line end-points and store the left end-points in (x1,y1). Load (x1,y1) into the frame buffer;that is,plot the first point.put x=x1,y=y1. Calculate dx=x2-x1 and dy=y2-y1. If abs(dx) > abs(dy), do s=abs(dx). Otherwise s= abs(dy). Then xi=dx/s and yi=dy/s. Start from k=0 and continuing till k<s,the points will be x=x+xi. y=y+yi. Place pixels using putpixel at points (x,y) in specified colour. Close Graph. Stop.

Bresenham’s line drawing algorithm –Line drawing algorithm comparisons –Circle drawing algorithms A simple technique The mid-point circle algorithm Jack Bresenham

Concept Move across the x axis in unit intervals and at each step choose between two different y coordinates For example, from position (2, 3) we have to choose between (3, 3) and (3, 4) We would like the point that is closer to the original line (x k, y k ) (x k +1, y k ) (x k +1, y k +1)

The y coordinate on the mathematical line at x k +1 is: Concept: The Bresenham Line Algorithm At sample position x k +1 the vertical separations from the mathematical line are labelled d upper and d lower y ykyk y k+1 xk+1xk+1 d lower d upp er

So, d upper and d lower are given as follows: and: We can use these to make a simple decision about which pixel is closer to the mathematical line Deriving The Bresenham Line Algorithm (cont…)

This simple decision is based on the difference between the two pixel positions: Let’s substitute m with ∆ y /∆ x where ∆ x and ∆ y are the differences between the end-points: Deriving The Bresenham Line Algorithm (cont…)

So, a decision parameter p k for the k th step along a line is given by: The sign of the decision parameter p k is the same as that of d lower – d upper If p k is negative, then we choose the lower pixel, otherwise we choose the upper pixel Deriving Algorithm (cont…)

Remember coordinate changes occur along the x axis in unit steps so we can do everything with integer calculations At step k +1 the decision parameter is given as: Subtracting p k from this we get: Deriving The Bresenham Line Algorithm (cont…)

But, x k+1 is the same as x k +1 so: where y k+1 - y k is either 0 or 1 depending on the sign of p k The first decision parameter p0 is evaluated at (x0, y0) is given as: Deriving The Bresenham Line Algorithm (cont…)

The Bresenham Line Algorithm BRESENHAM’S LINE DRAWING ALGORITHM (for | m | < 1.0) 1.Input the two line end-points, storing the left end-point in ( x 0, y 0 ) 2.Plot the point ( x 0, y 0 ) 3.Calculate the constants Δx, Δy, 2Δy, and ( 2Δy - 2Δx ) and get the first value for the decision parameter as: 4.At each x k along the line, starting at k = 0, perform the following test. If p k < 0, the next point to plot is (x k +1, y k ) and:

The Bresenham Line Algorithm (cont…) The algorithm and derivation above assumes slopes are less than 1. for other slopes we need to adjust the algorithm slightly Otherwise, the next point to plot is ( x k +1, y k +1 ) and: 5.Repeat step 4 ( Δx – 1) times

Example Let’s have a go at this Let’s plot the line from (20, 10) to (30, 18) First off calculate all of the constants: –Δx : 10 –Δy : 8 –2Δy : 16 –2Δy - 2Δx : -4 Calculate the initial decision parameter p 0 : –p0 = 2Δy – Δx = 6

Bresenham Example (cont…) kpkpk (x k+1,y k+1 )