Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)

Slides:



Advertisements
Similar presentations
Graphics Primitives: line
Advertisements

CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
2006 by Jim X. Chen: 1.1. Review –Graphics commands specify straight lines or other geometric primitives that are scan-converted.
Basic Raster Graphics Algorithms for Drawing 2D Primitives
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.
Advanced Manufacturing Laboratory Department of Industrial Engineering Sharif University of Technology Session # 6.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Output Primitives Computer Graphics.
Buffers Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Java ThreadsGraphics Programming Graphics Programming: Graphics Devices.
Graphics Device Principles B.Sc. (Hons) Multimedia ComputingMedia Technologies.
Sep 21, Fall 2005ITCS4010/ Computer Graphics Overview Color Displays Drawing Pipeline.
Sep 21, Fall 2006IAT 4101 Computer Graphics Overview Color Displays Drawing Pipeline.
IAT 3551 Computer Graphics Overview Color Displays Drawing Pipeline.
Graphics Device Principles B.Sc. (Hons) Multimedia ComputingMedia Technologies.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Scan Conversion CS123 1 of 44Scan Conversion - 10/14/2014.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
Ch 1 Intro to Graphics page 1CS 367 First Day Agenda Best course you have ever had (survey) Info Cards Name, , Nickname C / C++ experience, EOS experience.
CS 4731: Computer Graphics Lecture 21: Raster Graphics Part 2 Emmanuel Agu.
Computer Graphics Hardware and Software Lecture Notes, CEng 477.
Raghu Machiraju Slides: Courtesy - Prof. Huamin Wang, CSE, OSU
1. 2  A computer is a device capable of storing data  in a format suited to the computer,  which is then processed by mathematical manipulation and.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 46 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 46 Computer Graphics Introduction II.
COMPUTER GRAPHICS Prepared by S.MAHALAKSHMI Asst. Prof(Sr) / SCSE VIT University.
Basics of a Computer Graphics System Introduction to Computer Graphics CSE 470/598 Arizona State University Dianne Hansford.
Dr. S.M. Malaek Assistant: M. Younesi
BY Kamran Yousaf Computer Graphics & Animation. BY Kamran Yousaf Contents Introduction Usage, Application & Advantages Video Display Devices Output Devices.
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.
Raster-scan system In addition to the central processing unit a special purpose processor called the video controller or display controller is used to.
Objectives Differentiate between raster scan display and random scan display.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
Institute for Visualization and Perception Research 1 © Copyright 2000 Haim Levkowitz Introduction (Foley & Van Dam Ch 1) Uses of computer graphics … Some.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 2D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
INT 840E Computer graphics Introduction & Graphic’s Architecture.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Week One Raster & Vector Formats. 2 Computer Graphics Vector Graphics Pictures are produced via a series of ‘draw commands’ These commands will draw short.
 Video Display Devices Video Display Devices  Cathode-ray tube (CRT) Monitors Cathode-ray tube (CRT) Monitors  Display Technologies Display Technologies.
Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic Light Source.
Overview of Graphics System
Introduction and Graphics Pipeline Advanced Multimedia Technology: Computer Graphics Yung-Yu Chuang 2005/12/07 with slides by Brian Curless, Zoran Popovic,
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
CS-321 Dr. Mark L. Hornick 1 Graphics Displays Video graphics adapter Monitor.
Institute for Visualization and Perception Research 1 © Copyright 2000 Haim Levkowitz Raster graphics alg’s for drawing 2D primitives Points of view Application.
Scan Conversion.
Lecture 13: Raster Graphics and Scan Conversion
Chapter 1 Graphics Systems and Models Models and Architectures.
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 CC416 Lecture 02: Overview of Graphics Systems: Raster & Random Displays – Chapter 2 Dr. Manal Helal – Fall 2014.
Computer Graphics Inf4/MSc Computer Graphics Lecture 4 Line & Circle Drawing.
Chapter 7 Introduction to High-Level Language Programming.
Graphics Graphics Korea University cgvr.korea.ac.kr Introduction to Computer Graphics 고려대학교 컴퓨터 그래픽스 연구실.
CSCE 441 Lecture 2: Scan Conversion of Lines
Computer Graphics Lecture 3 Computer Graphics Hardware
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
CSCE 441 Lecture 2: Scan Conversion of Lines
Introduction to Computer Graphics
Rasterization and Antialiasing
Computer Graphics Implementation III
Rasterization and Antialiasing
Chapter 2 Overview of Graphics Systems
Basic Raster Graphics Algorithms for Drawing 2D Primitives
CS297 Graphics with Java and OpenGL
Implementation III Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)

Basic Raster Graphics Algorithms for Drawing 2D Primitives  Architecture of a Raster Display  Scan Converting Lines  Filling Rectangles  Filling Polygons  Clipping Lines  Clipping Polygons  Antialiasing  Image Processing

Architecture of a Raster Display Video controller Display controller (DC) Interface with host computer (Display commands)(Interaction data) Refresh buffer Keyboard Mouse

Definitions  Pixel a screen consists of N x M pixels  Bilevel = monochrome, 1 bit / pixel  Color: RGB model 8 bits / pixel  256 colors, color map, indexing 16bits / pixel  R, G, B each 5 bits, 1 bit overlay 24(32)bits / pixel  R, G, B(, A) each 8 bits

Definitions  Bitmap / pixmap bitmap  1-bit-per-pixel bilevel systems pixmap  multiple-bit-per-pixel systems  Frame buffer an array of data in memory mapped to screen

Scan Converting Lines  A scan-converted line showing intensified pixels as black circles

The Basic Incremental Algorithm (x i,Round(y i )) (xi,yi)(xi,yi) (x i +1,y i +m) (x i +1,Round(y i +m)) Desired line

The Basic Incremental Algorithm void Line(int x0, int y0, int x1, int y1, value) { float dx = x1-x0, dy = y1-y0; float m = dy/dx; float y = y0; for (int x = x0; x <= x1; ++x) { WritePixel(x, round(y), value); y += m; }

Midpoint Line Algorithm NE M E Q P=(x P,y P )

Midpoint Line Algorithm NE E P=(x P,y P ) oldnew

Midpoint Line Algorithm void MidpointLine(int x0, int y0, int x1, int y1, value){ int dx = x1-x0, dy = y1-y0; int incrE = dy*2, incrNE = (dy-dx)*2; int d = dy*2 - dx; int x = x0, y = y0; WritePixel(x, y, value); while (x < x1) { if (d <= 0) { d += incrE; ++x; } else { d += incrNE; ++x; ++y; } WritePixel(x, y, value); } NE E

Faster Line Algorithms?  Recall the basic incremental algorithm float m = dy/dx; float y = y0; for (int x = x0; x <= x1; ++x) { WritePixel(x, round(y), value); y += m; }  Performance issues: floating point operations round()

Extremely Fast Line algorithm  Idea: Use large integer instead of floating point round(x) = int(x+0.5) void FastLine(int x0, int y0, int x1, int y1, value) { int dy = y1-y0, dx = x1-x0; int m = (dx<<16) / dy; for (int x = x0, y = 0x8000+(y0<<16); x <= x1; ++x) { WritePixel (x, (y>>16), value); y += m; } Copyright (c) 2005, By Po-Han Lin,

Filling Rectangles for (int y = ymin; y <= ymax; y++) { for (int x from xmin to xmax) { WritePixel(x, y, value); }

Filling Polygons A B C D E F a d b c Scan line

Filling Polygons Span extrema Other pixels in the span

Filling Polygons 1.find the intersections of the scan line with all edges of the polygon 2.sort the intersections by increasing x coordinate 3.fill in all pixels between pairs of intersections that lie interior to the polygon

Some Issues Horizontal lines Shared points Silvers

Clipping Lines E F A B G C D H I J Clip rectangle G’G’ D’D’ H’H’ I’I’ J’J’ A B C G’G’ D’D’ H’H’

The Cohen-Sutherland Line-Clipping Algorithm Clip rectangle X min X max Y min Y max

The Cohen-Sutherland Line-Clipping Algorithm E F A B G C D H I Clip rectangle X min X max Y min Y max

Clipping Polygons Clip rectangle

The Sutherland-Hodgman Polygon-Clipping Algorithm Clip rectangle Right clip boundary Bottom clip boundary Left clip boundary Top clip boundary

Antialiasing

Jagged Edges

Unweighted Area Sampling

Unweighted Area Sampling

Xiaolin Wu's line algorithm rfpart fpart Idea: intensity is based on rfpart and fpart

Xiaolin Wu's line algorithm ipart(x): integer part of x fpart(x): fraction part of x rfpart(x): 1 – fpart(x) void WuLine(float x0, float y0, float x1, float y1, value) { /* handle both endpoints here */ /* and determine the xbegin and xend */ float dx = x1-x0, dy = y1-y0; float m = dy/dx; float intery = y1 + m(xbegin-x); for (int x = xbegin; x <= xend; ++x) { WritePixel(x, ipart(intery), value*rfpart(intery)); WritePixel(x, ipart(intery)+1, value*fpart(intery)); intery += m; } Xiaolin Wu, An efficient antialiasing technique, SIGGRAPH 1991.

Subpixel rendering

Aliasing

Nyquist–Shannon sampling theorem If a function x(t) contains no frequencies higher than B hertz, it is completely determined by giving its ordinates at a series of points spaced 1/(2B) seconds apart.

Full-Screen Anti-Aliasing (FSAA)  Ordered Grid Multi-Sampling (OGMS)  Rotate Grid Multi-Sampling (OGMS)  Ordered Grid Super Sampling (OGSS)  Rotate Grid Super Sampling (RGSS) 1.Super sampling 2.Low-pass filter 3.Down-sampling