Lecture 13: Raster Graphics and Scan Conversion

Slides:



Advertisements
Similar presentations
Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity();
Advertisements

CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
Basic Raster Graphics Algorithms for Drawing 2D Primitives
Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
Scan Conversion A. Samal. Scan Conversion Last step in the graphics pipeline Efficiency is a central issue Common primitives – Lines – Polygons – Circles.
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.
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.
Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)
Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity();
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
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.
Implementation III Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
CS 4731: Computer Graphics Lecture 22: Raster Graphics Part 3 Emmanuel Agu.
Course Website: Computer Graphics 5: Line Drawing Algorithms.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Scan Conversion CS123 1 of 44Scan Conversion - 10/14/2014.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
Computer Graphics Panos Trahanias ΗΥ358 Spring 2009.
Dr. S.M. Malaek Assistant: M. Younesi
Jehee Lee Seoul National University
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
Computing & Information Sciences Kansas State University CIS 536/636 Introduction to Computer Graphics Lecture 6 of 41 William H. Hsu Department of Computing.
Tools for Raster Displays CVGLab Goals of the Chapter To describe pixmaps and useful operations on them. To develop tools for copying, scaling, and rotating.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
3/4/04© University of Wisconsin, CS559 Spring 2004 Last Time Clipping Lines –Cohen-Sutherland: The use of outcodes and early reject/accept tests –Liang-Barsky:
Triangle Scan Conversion. 2 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rasterization Rasterization (scan conversion) –Determine which.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 Going-through.
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.
Line Drawing and Generalization. Outline  overview  line drawing  circle drawing  curve drawing.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 2D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
CGMB214: Introduction to Computer Graphics
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Image Synthesis Rabie A. Ramadan, PhD 7. 2 Image Rasterization.
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.
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
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.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner Rasterization.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
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.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
Lecture 15: Raster Graphics and Scan Conversion
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.
Rasterization Overview Raster Display Device. Scan Conversion / Rasterization: converting vector graphics into raster graphics (determining pixels in.
Computer Graphics Inf4/MSc Computer Graphics Lecture 4 Line & Circle Drawing.
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.
Computer Graphics I, Fall 2010 Scan conversion algorithms.
Computer Graphics Drawing Line.
Basic Raster Graphics Algorithms for Drawing 2D Primitives
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
University of New Mexico
Implementation III.
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics
Rasterization and Antialiasing
Lecture 13 Clipping & Scan Conversion
Computer Graphics Implementation III
Rasterization and Antialiasing
Basic Raster Graphics Algorithms for Drawing 2D Primitives
SUBJECT : COMPUTER GRAPHICS
Implementation III Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Lecture 13: Raster Graphics and Scan Conversion CS552: Computer Graphics Lecture 13: Raster Graphics and Scan Conversion

Recap Viewing pipeline Model coordinate World coordinate View coordinate Normalized coordinate Device coordinate Transformation 2D 3D Homogeneous Cliping

Objective After completing this lecture students will be able to Derive mathematical expression for drawing lines between two points Write programs to implement line drawing algorithm

2D Graphics Pipeline Simple 2D Drawing Pipeline Clipping window to Object World Coordinates Applying world window Clipping Object subset window to viewport mapping Object Screen coordinates Simple 2D Drawing Pipeline Display Rasterization

Rasterization (Scan Conversion) Convert high-level geometry description to pixel colors in the frame buffer Example: given vertex 𝑥,𝑦 coordinates determine pixel colors to draw line Two ways to create an image: Scan existing photograph Procedurally compute values (rendering) Viewport Transformation Rasterization

Rasterization A fundamental computer graphics function Determine the pixels’ colors, illuminations, textures, etc. Implemented by graphics hardware Rasterization algorithms Lines Circles Triangles Polygons

Rasterization Operations Drawing lines on the screen Manipulating pixel maps (pixmaps): copying, scaling, rotating, etc Compositing images, defining and modifying regions Drawing and filling polygons Aliasing and antialiasing methods

Line drawing algorithm Programmer specifies (x,y) values of end pixels Need algorithm to figure out which intermediate pixels are on line path Pixel (x,y) values constrained to integer values Actual computed intermediate line values may be floats Rounding may be required. E.g. computed point (10.48, 20.51) rounded to (10, 21) Rounded pixel value is off actual line path (jaggy)

Line Drawing Algorithm 0 1 2 3 4 5 6 7 8 9 10 11 12 8 7 6 5 4 3 2 1 Line: (3,2) -> (9,6) ? Which intermediate pixels to turn on?

DDA Line Drawing Algorithm (Case a: m < 1) x = x0 y = y0 Illuminate pixel (x, round(y)) (x1,y1) x = x0 + 1 y = y0 + 1 * m (x0, y0) Illuminate pixel (x, round(y)) x = x + 1 y = y + 1 * m Illuminate pixel (x, round(y)) … Until x == x1

DDA Line Drawing Algorithm (Case b: m > 1) x = x0 y = y0 (x1,y1) Illuminate pixel (round(x), y) y = y0 + 1 x = x0 + 1 * 1/m Illuminate pixel (round(x), y) y = y + 1 x = x + 1 /m Illuminate pixel (round(x), y) … (x0,y0) Until y == y1

DDA Line Drawing Algorithm Pseudocode compute m; if m < 1: { float y = y0; // initial value for(int x = x0;x <= x1; x++, y += m) setPixel(x, round(y)); } else // m > 1 float x = x0; // initial value for(int y = y0;y <= y1; y++, x += 1/m) setPixel(round(x), y); Note: setPixel(x, y) writes current color into pixel in column x and row y in frame buffer

Line Drawing Algorithm Drawbacks DDA is the simplest line drawing algorithm Not very efficient (time consuming) Round operation is expensive Optimized algorithms typically used. Integer DDA E.g. Bresenham algorithm Bresenham algorithm Incremental algorithm: current value uses previous value Integers only: avoid floating point arithmetic midpoint version of algorithm

Bresenham’s Line-Drawing Algorithm Problem: Given endpoints ( 𝑥 0 , 𝑦 0 ) and ( 𝑥 1 , 𝑦 1 ) of a line Task is to to determine best sequence of intervening pixels First make two simplifying assumptions (remove later): (0 < m < 1)

Additional Issues Endpoint order A line from 𝑃 0 to 𝑃 1 contains the same set of points as the line from 𝑃 1 to 𝑃 0 . Appearance of the line is independent of the order of the end point specification Choice of points when 𝑑=0 West or South West

Additional Issues Different slope ? Starting at the edge of a clip rectangle Different slope ? x = 𝒙 𝒎𝒊𝒏 ( 𝒙 𝒎𝒊𝒏 ,𝑹𝒐𝒖𝒏𝒅(𝒎 𝒙 𝒎 +𝑩) ( 𝑥 𝑚𝑖𝑛 ,(𝑚 𝑥 𝑚 +𝐵) y = 𝒚 𝒎𝒊𝒏

Additional Issues Different slope ? Starting at the edge of a clip rectangle Different slope ? x = 𝒙 𝒎𝒊𝒏 𝐲= 𝒚 𝒎𝒊𝒏 − 𝟏 𝟐 y = 𝒚 𝒎𝒊𝒏 𝐲= 𝒚 𝒎𝒊𝒏 −1

Additional Issues Antialiasing Line style Varying the intensity as a function of slope Antialiasing Line style

Thank you Next Lecture: Scan converting Circle