OUTPUT PRIMITIVES CEng 477 Computer Graphics METU, 2004.

Slides:



Advertisements
Similar presentations
Polygon Scan Conversion – 11b
Advertisements

Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
+ CPCS 391 Computer Graphics 1 Instructor: Dr. Sahar Shabanah Lecture 3.
Scan conversion of Line , circle & ellipse
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 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Different types of Polygons Simple Convex Simple Concave Non-simple : self-intersecting With holes ConvexConcaveSelf-intersecting.
CPCS 391 Computer Graphics 1 Lecture 5: Polygon Filling
Raster conversion algorithms for line and circle
Output Primitives Computer Graphics.
CSCE 441: Computer Graphics Scan Conversion of Polygons
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.
Rasterization Foley, Ch: 3. Pixels are represented as disjoint circles centered on uniform grid Each (x,y) of the grid has a pixel Y X (1,1) (1,2) (0,0)
Circle Drawing algo..
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
March Shape Drawing Algorithms Shmuel Wimer Bar Ilan Univ., Engineering Faculty.
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
1/24/20061 Fill-Area Algorithms and Functions. 1/24/20062 Learning Objectives OpenGL state variables Color and gray scale Color functions Point attributes.
Polygon Scan Conversion and Z-Buffering
Dr. S.M. Malaek Assistant: M. Younesi
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
Informationsteknologi Monday, November 26, 2007Computer Graphics - Class 121 Today’s class Drawing lines Bresenham’s algorithm Compositing Polygon filling.
Graphics Graphics Korea University cgvr.korea.ac.kr Raster Graphics 고려대학교 컴퓨터 그래픽스 연구실.
Graphics Output Primitives
CGMB214: Introduction to Computer Graphics
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
MIDPOINT CIRCLE & ELLIPSE GENERARTING ALGORITHMS
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.
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.
Computer Graphics Filling. Filling Polygons So we can figure out how to draw lines and circles How do we go about drawing polygons? We use an incremental.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Lecture 15: Raster Graphics and Scan Conversion
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
Lecture 2: 19/4/1435 Graphical algorithms Lecturer/ Kawther Abas CS- 375 Graphics and Human Computer Interaction.
Computer Graphics CC416 Week 14 Filling Algorithms.
Computer Graphics Lecture 08 Taqdees A. Siddiqi Computer Graphics Filled Area Primitives I Lecture 08 Taqdees A. Siddiqi
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Write Bresenham’s algorithm for generation of line also indicate which raster locations would be chosen by Bresenham’s algorithm when scan converting.
Computer Graphics Inf4/MSc Computer Graphics Lecture 4 Line & Circle Drawing.
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 I, Fall 2010 Scan conversion algorithms.
Objectives Understand Bresenhams line drawing algorithm. Apply the algorithm to plot a line with the end points specified.
CS552: Computer Graphics Lecture 16: Polygon Filling.
Primitive graphic objects
CSCE 441 Lecture 2: Scan Conversion of Lines
Computer Graphics Filling.
Introduction to Polygons
(c) 2002 University of Wisconsin, CS559
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
University of New Mexico
Implementation III.
Chapter Three Part I Output Primitives CS 380.
Introduction to Computer Graphics with WebGL
CSCE 441 Lecture 2: Scan Conversion of Lines
Agenda Polygon Terminology Types of polygons Inside Test
Agenda Polygon Terminology Types of polygons Inside Test
Computer Graphics Implementation III
عَلَّمَهُ الْبَيَانَ He has taught him speech (and intelligence).
Scan Conversion (From geometry to pixels)
Chapter 3 Graphics Output Primitives
Where We Stand At this point we know how to: Next thing:
Implementation III Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

OUTPUT PRIMITIVES CEng 477 Computer Graphics METU, 2004

Output Primitives ● Graphic SW and HW provide subroutines to describe a scene in terms of basic geometric structures called output primitives. ● Output primitives are combined to form complex structures ● Simplest primitives – Point (pixel) – Line segment

Scan Conversion ● Converting output primitives into frame buffer updates. Choose which pixels contain which intensity value. ● Constraints – Straight lines should appear as a straight line – primitives should start and end accurately – Primitives should have a consistent brightness along their length – They should be drawn rapidly

Line Drawing ● Simple approach: sample a line at discrete positions at one coordinate from start point to end point, calculate the other coordinate value from line equation. If m>1, increment y and find x If m ≤1, increment x and find y

Digital Differential Analyzer ● Simple approach: too many floating point operations and repeated calculations ● Calculate from for a value

Bresenham's Line Algorithm ● DDA: Still floating point operations x k+1 xkxk ykyk yk+1yk+1 y d2d2 d1d1

● Algorithm:

Circle Generation ● Computationally complex ● Non uniform spacing ● Polar coordinates:

● Fixed angular step size to have equally spaced points

● Computation can be reduced by considering symmetry of circles: ● Still too complex, multiplications, trigonometric calculations ● Bresenham's circle generation algorithm involves simple integer operations ● Midpoint Circle Algorithm generates the same pixels (x,y) (x,-y) (-x,-y) (-x,y) (-y,-x)(y,-x) (y,x)(-y,x)

Midpoint Circle Algorithm ● Consider the second octant. Increment x, decide on y ● Assume that select which of 2 pixels are closer to the circle by evaluating the function at E and SE. x y E SE M MEME M SE previous pixel choices for current pixel choices for the next pixel

● Algorithm:

Ellipse Generation ● Similar to circle generation with mid-point. Inside test. ● Different formula for points up to the tangent y=-x, slope<1. (0,b) to tangent: increment x find y tangent to (a,0) : decrement y find x ● Mid-point algorithm is applicable to other polynomial equations: – Parabola, Hyperbola y=-x a b

Filled Area Primitives ● Two basic approaches to area filling on raster systems: – Determine the overlap intervals for scan lines that cross the area (scan-line) – Start from an interior position and point outward from this point until the boundary condition reached (fill method) ● Scan-line: simple objects, polygons, circles,.. ● Fill-method: complex objects, interactive fill.

Scan-line Polygon Fill ● For each scan-line: – Locate the intersection of the scan-line with the edges ( y=y s ) – Sort the intersection points from left to right. – Draw the interiors intersection points pairwise. (a-b), (c-d) ● Problem with corners. Same point counted twice or not? a bc d

● a,b,c and d are intersected by 2 line segments each. ● Count b,d twice but a and d once. Why? a b c d a b c d ● Solution: Make a clockwise or counter- clockwise traversal on edges. Check if y is monotonically increasing or decreasing. If direction changes, double intersection, otherwise single intersection.

Scan-line Polygon Filling (coherence) ● Coherence: Properties of one part of a scene are related with the other in a way that can it be used to reduce processing of the other. ● Scan-lines adjacent to each other. Intersection of scan-lines are close to each other (like scan conversion of a line) ● Intersection points with scan lines:

● Instead of floating point operations, use integer operations: ● Example: m = 8/5 scanlinecounter x

Efficient Polygon Fill ● Make a (counter)clockwise traversal and shorten the single intersection vertices. ● Generate a sorted edge table on the scan-line axis. Each edge has an entry in smaller y valued corner point. ● Each entry keeps a linked list of all connected edges: – x value of the point – y value of the end-point – Slope of the edge

A B D C E E' F F' y F' xAxA 1/m AF' yByB xAxA 1/m AB y E' xFxF 1/m FE' yDyD xCxC 1/m CD yByB xCxC 1/m CB yDyD xExE 1/m ED Scan line 0 1

● Start with the smallest scan-line ● Keep an active edge list: – Update the current x value of the edge based on m value – Add the lists in the current table entry based on their x value – Remove the completed edges – Draw the intermediate points of pairwise elements of the list.

● Example: A,B,C,D,E,F,A Polygon: (30,10),(24,32),(20,22),(16,34) (8,26),(12,16),(30,10) E'=(20,25), F'=(12,15) Edge Table: Y E1 E2 10[15,30,-3][32,30,-3/11] 16[25,12,-2/5] 22[34,20,-1/3][32,20,2/5] 26[34,8,1]

Boundary Fill Algorithm ● Start at a point inside a continuous arbitrary shaped region and paint the interior outward toward the boundary. Assumption: boundary color is a single color ● (x,y): start point; b:boundary color, fill: fill color void boundaryFill4(x,y,fill,b) { cur = getpixel(x,y) if (cur != b) AND (cur != fill) { setpixel(x,y,fill); boundaryFill4(x+1,y,fill,b); boundaryFill4(x-1,y,fill,b); boundaryFill4(x,y+1,fill,b); boundaryFill4(x,y-1,fill,b); } }

● 4 neighbors vs 8 neighbors: depends on definition of continuity. 8 neighbor: diagonal boundaries will not stop ● Recursive, so slow. For large regions with millions of pixels, millions of function calls. ● Stack based improvement: keep neighbors in stack ● Number of elements in the stack can be reduced by filling the area as pixel spans and pushing only the pixels with pixel transitions.

● Check the neighbor pixels as filling the area line by line ● If pixel changes from null to boundary or null when scan-line finishes, push the pixel information on stack. ● After a scan-line finishes, pop a value from stack and continue processing Stack after scan line

Flood-Fill ● Similar to boundary fill. Algorithm continues while the neighbor pixels have the same color. ● void FloodFill4(x,y,fill,oldcolor) { cur = getpixel(x,y) if (cur == oldcolor) { setpixel(x,y,fill); FloodFill4(x+1,y,fill,oldcolor); FloodFill4(x-1,y,fill,oldcolor); FloodFill4(x,y+1,fill,oldcolor); FloodFill4(x,y-1,fill,oldcolor); } }

Character Generation ● Typesetting fonts: – Bitmap fonts: simple, not scalable. – Outline fonts: scalable, flexible, more complex process ● Pixelwise on/of information Points and tangents of the boundary