Basic Raster Graphics Algorithms for Drawing 2D Primitives

Slides:



Advertisements
Similar presentations
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 7 Scanline algorithm and polygon clipping Taku Komura.
Advertisements

Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity();
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
Basic Raster Graphics Algorithms for Drawing 2D Primitives
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 30, D Clipping 1/14 Clipping (pages , )
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.
Group Teaching and Learning 3 extra points. Lecture 11  Group A: Line drawing – DDA algorithm – Midpoint algorithm – Bresenham’s line algorithm  Group.
Line clipping: Line clipping algorithm is method of eliminate lines of outside area of the object,so outside of object viewing is Removed. Typically, any.
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();
Polygon Rasterization
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
Implementation Dr. Amy Zhang. Reading 2  Hill, Chapters  Hill, Chapter 10.
Implementation III Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Scan Conversion CS123 1 of 44Scan Conversion - 10/14/2014.
Graphics Primitives: line. Pixel Position
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.
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Introduction and Graphics Pipeline Advanced Multimedia Technology: Computer Graphics Yung-Yu Chuang 2005/12/07 with slides by Brian Curless, Zoran Popovic,
Scan Conversion.
Lecture 13: Raster Graphics and Scan Conversion
CS552: Computer Graphics Lecture 17: Scan Conversion (Special Cases)
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.
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 I, Fall 2010 Scan conversion algorithms.
Computer Graphics Drawing Line.
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphic 2 D Viewing.
Computer Graphics Filling.
Transformations contd.
Computer Graphics Shading in OpenGL
Concepts, Algorithms for line clipping
Basic Raster Graphics Algorithms for Drawing 2D Primitives
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
University of New Mexico
Implementation III.
Concepts, algorithms for clipping
Zhen Jiang West Chester University
Implementation I Ed Angel
Graphics Pipeline Clipping
Introduction to Computer Graphics with WebGL
WINDOWING AND CLIPPING
Computer Graphics : Viewing In 2D
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
Introduction to Computer Graphics
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Rasterization and Antialiasing
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Two Dimensional Viewing and Clipping.
Computer Graphics Implementation III
Rasterization and Antialiasing
Segment Clipping Simple algorithm. For each segment compute the intersection with the four sides of the rectangle, and then determine which sub-segment.
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
From Vertices To Fragments
Clipping Clipping Sutherland-Hodgman Clipping
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Where We Stand At this point we know how to: Next thing:
Implementation I Ed Angel Professor Emeritus of Computer Science
Implementation III Ed Angel Professor Emeritus of Computer Science
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Presentation transcript:

Basic Raster Graphics Algorithms for Drawing 2D Primitives Prof. Lizhuang Ma Shanghai Jiao Tong University

Contents Architecture of a Raster Display Scan Converting Lines Filling Rectangles Filling Polygons Clipping Lines Clipping Polygons Antialiasing

Architecture of a Raster Display Video

Definitions Pixel: a screen consists of N x M pixels Bilevel = monochrome, 1 bit / pixel Color: RGB/CYK/LUV… Bitmap / pixmap Frame buffer: an array of data in memory mapped to screen

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

The Basic Incremental Algorithm A scan-converted line showing intensified pixels as black circles

The Basic Incremental Algorithm void Line (intx0, inty0, intx1, inty1, value) { Int x; Float dy, dx, y, m; dy=y1-y0; dx=x1-x0; m=dy/dx; y=y0; for(x=x0; x<=x1; x++) { WritePixel(x, (int)floor(y+0.5), value); y+=m; }

Midpoint Line Algorithm

Midpoint Line Algorithm

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

Filling Rectangles for(y from ymin to ymax of the rectangle) { for(x from xmin to xmax) { WritePixel(x, y, value); }

Filling Polygons

Filling Polygons

Filling Polygons Find the intersections of the scan line with all edges of the polygon Sort the intersections by increasing x coordinate Fill in all pixels between pairs of intersections that lie interior to the polygon

Special Cases Slivers Horizontal Edges

Clipping Lines

The Cohen-Sutherland Algorithm

The Cohen-Sutherland Algorithm

Clipping Polygons

The Sutherland-Hodgman Polygon-Clipping Algorithm

Liang-Barsky Algorithm Starting point is parametric form Compute four intersections with extended clipping rectangle Will see that this can be avoided

Ordering of intersection Ordering of intersection points Order the intersection points • Figure (a): 1 > a4 > a3 > a2 > a1 > 0 • Figure (b): 1 > a4 > a2 > a3 > a1 > 0

Ordering of intersection Li Liang-Barsky Efficiency Improvements – Compute intersections one by one – Often can reject before all four are computed • Efficiency improvement 2: – Equations for a3, a2 – Compare a3, a2 without floating-point division

Antialiasing