Scan conversion of Line , circle & ellipse

Slides:



Advertisements
Similar presentations
Graphics Primitives: line
Advertisements

5.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 5 – Drawing A 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.
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
Line Drawing Algorithms. Rasterization-Process of determining which pixels give the best approximation to a desired line on the screen. Scan Conversion-Digitizing.
Computer Graphics Lecture 3 Line & Circle Drawing.
Larry F. Hodges (modified by Amos Johnson) 1 Design of Line, Circle & Ellipse Algorithms.
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
Advanced Manufacturing Laboratory Department of Industrial Engineering Sharif University of Technology Session # 6.
The lines of this object appear continuous However, they are made of pixels 2April 13, 2015.
CS 376 Introduction to Computer Graphics 01 / 29 / 2007 Instructor: Michael Eckmann.
OUTPUT PRIMITIVES Screen vs. World coordinate systems ● Objects positions are specified in a Cartesian coordinate system called World Coordinate.
Lecture 16 Fun with graphics
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.
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.
Scan Conversion. Also known as rasterization In our programs objects are represented symbolically –3D coordinates representing an object’s position –Attributes.
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
CS 325 Introduction to Computer Graphics 02 / 01 / 2010 Instructor: Michael Eckmann.
Larry F. Hodges 1 Design of Line and Circle Algorithms.
1 Circle Drawing Algorithms Pictures snagged from
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)
Image Synthesis Rabie A. Ramadan, PhD 7. 2 Image Rasterization.
CS-321 Dr. Mark L. Hornick 1 Line Drawing Algorithms.
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.
Lecture 13: Raster Graphics and 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.
Computer Graphics Inf4/MSc Computer Graphics Lecture 4 Line & Circle Drawing.
10/10/2006TCSS458A Isabelle Bichindaritz1 Line and Circle Drawing Algorithms.
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.
Scan Conversion of Line Segments. What is Scan conversion? Final step of rasterization (the process of taking geometric shapes and converting them into.
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
Scan Conversion or Rasterization
CSCE 441 Lecture 2: Scan Conversion of Lines
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Scan Conversion or Rasterization
Lecture 8 Shear and Line Drawing Algorithms
Chapter Three Part I Output Primitives CS 380.
CSCE 441 Lecture 2: Scan Conversion of Lines
2D Scan-line Conversion
Edited from The Rasterization Problem: Idealized Primitives Map to Discrete Display Space Edited from.
Chapter 3 Graphics Output Primitives
S.JOSEPHINE THERESA, DEPT OF CS, SJC, TRICHY-2
OUTPUT PRIMITIVES / DISPLAY TECHNIQUES
Presentation transcript:

Scan conversion of Line , circle & ellipse Computer graphics Scan conversion of Line , circle & ellipse

Scan conversion is the process of converting basic, low level objects in to their corresponding pixel map representations. This is often an approximation to the object, since the frame buffer is a discrete grid.

Line Drawing algorithms Direct or floating or simple algorithm Digital Differential Analyzer algorithm (DDA) Bresenham's algorithm or midpoint algorithm General Bresenham's algorithm Description: Given the specification for a straight line (parameters). find the collection of addressable pixels which most closely approximates this line (mathematical equations) . Draw the scan conversion of lines (frame buffer map). Goals Straight lines should appear straight. Lines should start and end accurately. Lines should be drawn as rapidly as possible. matching endpoints with connecting lines. Lines should have constant brightness.

Direct method Description: 1. A straight line may be defined by two endpoints and an equation If the two endpoints used to specify a line are (X1,Y1) and (X2,Y2) ,then the equation of the line is used to describe the X , Y coordinates of all the pointes that lie between these two endpoints. x1 y1 x2 Y2 2. The line equation depend on octant which contain line Dx = x2 - x1 Octant covering in 2D space Dy = y2 - y1 dy > dx negative VIII dy < dx VII positive VI V IV III II I ratio Slope (m) Octant

x go from x1 to x2 with values (+1) or (-1) 3. The equation of straight line in octants Dx > Dy Y= M * X + B Where: M is the slope of the line. B is the Y intercept. B= Y – M * X Note : The slope between any point (X1,Y1) on the line and (X2,Y2) M = DY/ DX x go from x1 to x2 with values (+1) or (-1) EX1:- draw line between(0,1) and ( 5,4) Sol:- M= 4 -1 / 5-0 = 3/5 = 0.6 , B=1 , y= (0.6)*X+1 x go from x1 to x2 with integer values (+1) in each step 0 1 2 3 4 5 0 1 2 3 4 x 1 2 3 4 5 y 1.6 2.2 2.8 3.4 draw (0,1) (1,2) (2,2) (3,3) (4,3) (5,4)

y go from y1 to y2 with values (+1) or (-1) 4. The equation of straight line in octants Dy > Dx X= Y – B / M y go from y1 to y2 with values (+1) or (-1) Ex: draw line between(1,2) and ( 3,6) sol:- m= 2 , B= 0 1 2 3 4 5 1 2 3 4 5 6 X Y draw 1 2 (1,2) 1.5 3 (2.3) 4 (2,4) 2.5 5 (3,4) 6 (3,6)

Ex: draw line between(2,-2) and ( 6,-6) Sol:- m= -4 / 4 = -1 , B= -2 – (-1*2) = 0 X Y draw 2 -2 (2,-2) 3 -3 (3,-3) 4 -4 (4,-4) 5 -5 (5,-5) 6 -6 (6,-6) 2 3 4 5 6 -2 -3 -4 -5 -6

features: The algorithm performs a floating-point multiplication for every step in x. This method therefore requires an enormous number of floating-point multiplications, and is therefore expensive. Round functions are needed not general for all octants Can get gaps in the line. example: y = 10.x + 2 x=1, y=12; x=2, y=22.

Algorithm for octant with x1<x2 Dim img As New Bitmap(1, 1) img.SetPixel(0, 0, Color.Blue) dx = x2 - x1 dy = y2 - y1 m = dy / dx b = y1 - m * x1 For x = x1 To x2 e.Graphics.DrawImage(img, x, Int(y)) y = m * x + b Next HW: develop direct method to draw lines in octants(( Dx >Dy), slope( positive , negative))

length=max( Abs(y2-y1) , Abs(x2-x1) Digital Differential Analyzer (DDA) Description: 1. We calculate the length of the line in the X direction ( number of pointes) by the equation Abs(x2-x1) 2. calculate the length of the line in the Y direction ( number of pointes) by the Equation Abs(y2-y1) Where ABS is a function takes the positive of the arguments. 3. The Length estimates is equal to the larger of the above two equations. length=max( Abs(y2-y1) , Abs(x2-x1)

4. The increment steps ( dX and dY ) are used to increment the X and Y coordinates for the next pointes to be plotted. Dx= (x2-x1) / length Dy= (y2-y1) / length 5. each point will calculate as equation x = x + Dx y = y + Dy 6. Integer function works as follow( round down) Ex. Integer (8.5) = 8 Integer (-8.5) = -9 7. first point we add 0.5 x = x1 + 0.5 y = y1 + 0.5

Ex1: Consider the line from (-8,-4) to (0,0)Use DDA to scan conversion of line. Sol 1 : X1=-8 ; Y1=-4 ; X2=0 ; Y2=0 ; Length= 8 dX= 1; dY=0.5 ; X=-7.5 ; Y=-3.5 I X Y draw -7.5 -3.5 (-8,-4) 1 -6.5 -3 (-7,-3) 2 -5.5 -2.5 (-6,-3) 3 -4.5 -2 (-5,-2) 4 -1.5 (-4,-2) 5 -1 (-3,-1) 6 -0.5 (-2,-1) 7 (-1,0) 8 0.5 (0,0) -8 -7 -6 -5 -4 -3 -2 -1 0 -4 -3 -2 -1 0

Algorithm DDA Start Length=ABS (X2-X1) If length < ABS (Y2-Y1) Then Length=ABS (Y2-Y1) dX = (X2 - X1) / Length dY = (Y2 - Y1) / Length X=X1 + 0.5 Y=Y1 + 0.5 Plot (Integer (X) , Integer (Y)) For I=1 to Length Begin X=X + dX Y=Y + dY End Finish

Features of DDA 1- The algorithm is orientation dependent 2- The end point accuracy deteriorates 3- The algorithm suffer from the fact that it must be performed using floating point arithmetic HW1: Consider the line from (0,0) to (-8,-4) evaluate the DDA algorithm