Course Website: Computer Graphics 5: Line Drawing Algorithms.

Slides:



Advertisements
Similar presentations
Line Drawing Algorithms
Advertisements

Contents In today’s lecture we’ll have a look at:
Graphics Primitives: line
5.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 5 – Drawing A Line.
Computer Graphics- SCC 342
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.
Line Drawing Algorithms. Rasterization-Process of determining which pixels give the best approximation to a desired line on the screen. Scan Conversion-Digitizing.
30/9/2008Lecture 21 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
OUTPUT PRIMITIVES Screen vs. World coordinate systems ● Objects positions are specified in a Cartesian coordinate system called World Coordinate.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Computer Graphics Viewing.
Raster conversion algorithms for line and circle
Output Primitives Computer Graphics.
Course Website: Computer Graphics 9: Clipping In 3D.
Computer Graphics Hardware and Software Lecture Notes, CEng 477.
1.Introduction to Computer Graphics GMR lab. What is computer garphics? The generation of graphical output using a computer Refers to creation, Storage.
The Monitors Name of Teacher :Rasha My Name: Diana Anbar ID: University of Palestine Collage of Engineer Computer Skills.
Dr. Scott Schaefer Scan Conversion of Lines. 2/78 Displays – Cathode Ray Tube.
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 Graphics Korea University cgvr.korea.ac.kr Raster Graphics 고려대학교 컴퓨터 그래픽스 연구실.
Graphics Primitives: line. Pixel Position
Scan Conversion Line and Circle
Raster-scan system In addition to the central processing unit a special purpose processor called the video controller or display controller is used to.
Informationsteknologi Monday, November 26, 2007Computer Graphics - Class 121 Today’s class Drawing lines Bresenham’s algorithm Compositing Polygon filling.
CS-321 Dr. Mark L. Hornick 1 Graphics Display Hardware Display technologies CRT LCD Storage tube Drawing methods Vector Raster Architecture.
Computer Graphics Hardware
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 Computer Graphics & Its application Types of computer graphics Graphic display : random Scan & Raster Scan display Frame buffer and video.
Plasma Screens ‘How it works?’. Cathode Ray Tubes Output devices Cathode Ray Tubes Television screens used to use a technology called, cathode ray tubes.
CGMB214: Introduction to Computer Graphics
Hardware used in Multimedia Systems. Hardware demands on multimedia systems Multimedia puts huge demands on a computer system, so designers and users.
 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.
Computer Fundamentals MSCH 233 Lecture 5. The Monitor A Monitor is a video screen that looks like a TV. It displays both the input data and instructions,
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.
Raster graphics & Line Drawing Algorithms Kaushik.S VIT
Hardware Components Display. 1.Display (Monitor) The screen is made up of thousands of picture elements or pixels Displays can be either CRT (Cathode.
Institute for Visualization and Perception Research 1 © Copyright 2000 Haim Levkowitz Raster graphics alg’s for drawing 2D primitives Points of view Application.
Lecture 13: Raster Graphics and Scan Conversion
OUTPUT PRIMITIVES A.Aruna/Faculty of Information technology/SNSCE13/19/2016.
1.  The primary output device in a graphics system is a video monitor. These monitors are based on Cathode Ray Tube (CRT) design.  CRT is a vacuum tube/electron.
Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing
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.
Rasterization, or “What is glBegin(GL_LINES) really doing?” Course web page: February 23, 2012  Lecture 4.
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.
Computer Graphics Lecture 4 Computer Graphics Hardware
Line Drawing Algorithms
CSCE 441 Lecture 2: Scan Conversion of Lines
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Chapter Three Part I Output Primitives CS 380.
Overview of Graphics Systems
Computer Graphics 5: Line Drawing Algorithms
Computer Graphics 5: Line Drawing Algorithms
CSCE 441 Lecture 2: Scan Conversion of Lines
Rasterization and Antialiasing
Computer Graphics 5: Line Drawing Algorithms
Rasterization and Antialiasing
Chapter 2 Overview of Graphics Systems
Chapter 3 Graphics Output Primitives
Presentation transcript:

Course Website: Computer Graphics 5: Line Drawing Algorithms

2 of 32 Contents Graphics hardware The problem of scan conversion Considerations Line equations Scan converting algorithms –A very simple solution –The DDA algorithm Conclusion

3 of 32 Graphics Hardware It’s worth taking a little look at how graphics hardware works before we go any further How do things end up on the screen? Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

4 of 32 Architecture Of A Graphics System System Bus CPU Display Processor System Memory Display Processor Memory Frame Buffer Video Controller Monitor

5 of 32 Output Devices There are a range of output devices currently available: –Printers/plotters –Cathode ray tube displays –Plasma displays –LCD displays –3 dimensional viewers –Virtual/augmented reality headsets We will look briefly at some of the more common display devices

6 of 32 Basic Cathode Ray Tube (CRT) Fire an electron beam at a phosphor coated screen Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

7 of 32 Raster Scan Systems Draw one line at a time Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

8 of 32 Colour CRT An electron gun for each colour – red, green and blue Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

9 of 32 Applying voltages to crossing pairs of conductors causes the gas (usually a mixture including neon) to break down into a glowing plasma of electrons and ions Plasma-Panel Displays Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

10 of 32 Liquid Crystal Displays Light passing through the liquid crystal is twisted so it gets through the polarizer A voltage is applied using the crisscrossing conductors to stop the twisting and turn pixels off Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

11 of 32 The Problem Of Scan Conversion A line segment in a scene is defined by the coordinate positions of the line end-points x y (2, 2) (7, 5)

12 of 32 The Problem (cont…) But what happens when we try to draw this on a pixel based display? How do we choose which pixels to turn on?

13 of 32 Considerations Considerations to keep in mind: –The line has to look good Avoid jaggies –It has to be lightening fast! How many lines need to be drawn in a typical scene? This is going to come back to bite us again and again

14 of 32 Line Equations Let’s quickly review the equations involved in drawing lines x y y0y0 y end x end x0x0 Slope-intercept line equation: where:

15 of 32 Lines & Slopes The slope of a line ( m ) is defined by its start and end coordinates The diagram below shows some examples of lines and their slopes m = 0 m = - 1 / 3 m = - 1 / 2 m = -1 m = -2 m = -4 m = ∞ m = 1 / 3 m = 1 / 2 m = 1 m = 2 m = 4 m = 0

16 of 32 A Very Simple Solution We could simply work out the corresponding y coordinate for each unit x coordinate Let’s consider the following example: x y (2, 2) (7, 5)

17 of 32 A Very Simple Solution (cont…)

18 of 32 A Very Simple Solution (cont…) x y (2, 2) (7, 5) First work out m and b : Now for each x value work out the y value:

19 of 32 A Very Simple Solution (cont…) Now just round off the results and turn on these pixels to draw our line

20 of 32 A Very Simple Solution (cont…) However, this approach is just way too slow In particular look out for: –The equation y = mx + b requires the multiplication of m by x –Rounding off the resulting y coordinates We need a faster solution

21 of 32 A Quick Note About Slopes In the previous example we chose to solve the parametric line equation to give us the y coordinate for each unit x coordinate What if we had done it the other way around? So this gives us: where: and

22 of 32 A Quick Note About Slopes (cont…) Leaving out the details this gives us: We can see easily that this line doesn’t look very good! We choose which way to work out the line pixels based on the slope of the line

23 of 32 A Quick Note About Slopes (cont…) If the slope of a line is between -1 and 1 then we work out the y coordinates for a line based on it’s unit x coordinates Otherwise we do the opposite – x coordinates are computed based on unit y coordinates m = 0 m = - 1 / 3 m = - 1 / 2 m = -1 m = -2 m = -4 m = ∞ m = 1 / 3 m = 1 / 2 m = 1 m = 2 m = 4 m = 0

24 of 32 A Quick Note About Slopes (cont…)

25 of 32 The DDA Algorithm The digital differential analyzer (DDA) algorithm takes an incremental approach in order to speed up scan conversion Simply calculate y k+1 based on y k The original differential analyzer was a physical machine developed by Vannevar Bush at MIT in the 1930’s in order to solve ordinary differential equations. More information here.here

26 of 32 The DDA Algorithm (cont…) Consider the list of points that we determined for the line in our previous example: (2, 2), (3, 2 3 / 5 ), (4, 3 1 / 5 ), (5, 3 4 / 5 ), (6, 4 2 / 5 ), (7, 5) Notice that as the x coordinates go up by one, the y coordinates simply go up by the slope of the line This is the key insight in the DDA algorithm

27 of 32 The DDA Algorithm (cont…) When the slope of the line is between -1 and 1 begin at the first point in the line and, by incrementing the x coordinate by 1, calculate the corresponding y coordinates as follows: When the slope is outside these limits, increment the y coordinate by 1 and calculate the corresponding x coordinates as follows:

28 of 32 The DDA Algorithm (cont…) Again the values calculated by the equations used by the DDA algorithm must be rounded to match pixel values (x k, y k ) (x k +1, y k +m) (x k, round(y k )) (x k +1, round(y k +m)) (x k, y k ) (x k + 1 / m, y k +1) (round(x k ), y k ) (round(x k + 1 / m ), y k +1)

29 of 32 DDA Algorithm Example Let’s try out the following examples: x y (2, 2) (7, 5) x y (2, 7) (3, 2)

30 of 32 DDA Algorithm Example (cont…)

31 of 32 The DDA Algorithm Summary The DDA algorithm is much faster than our previous attempt –In particular, there are no longer any multiplications involved However, there are still two big issues: –Accumulation of round-off errors can make the pixelated line drift away from what was intended –The rounding operations and floating point arithmetic involved are time consuming

32 of 32 Conclusion In this lecture we took a very brief look at how graphics hardware works Drawing lines to pixel based displays is time consuming so we need good ways to do it The DDA algorithm is pretty good – but we can do better Next time we’ll like at the Bresenham line algorithm and how to draw circles, fill polygons and anti-aliasing