March 20101 Shape Drawing Algorithms Shmuel Wimer Bar Ilan Univ., Engineering Faculty.

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

Computer Graphics- SCC 342
Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
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.
CMPE 466 COMPUTER GRAPHICS
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Graphics Pipeline.
In the name of God Computer Graphics Bastanfard.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
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
CS 376 Introduction to Computer Graphics 02 / 05 / 2007 Instructor: Michael Eckmann.
Output Primitives Computer Graphics.
CMPE 466 COMPUTER GRAPHICS
CS 454 Computer graphics Polygon Filling
Graphics Output Primitives Pixel Addressing and Fill Area Dr. M. Al-Mulhem Feb. 1, 2008.
Aliasing and Anti-Aliasing Copyright Zachary Wartell, University of North Carolina at Charlotte, All Rights Reserved Revision: 10/24/2007 3:38:00 AM ©Zachary.
Circle Drawing algo..
TOPIC 4 PART III FILL AREA PRIMITIVES POLYGON FILL AREAS CGMB214: Introduction to Computer Graphics.
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
Polygon Scan Conversion and Z-Buffering
Geometric Objects Computer Graphics Lab. Sun-Jeong Kim.
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
CGMB214: Introduction to Computer Graphics
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.
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:
Graphics Graphics Korea University cgvr.korea.ac.kr Raster Graphics 고려대학교 컴퓨터 그래픽스 연구실.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
1Computer Graphics Implementation III Lecture 17 John Shearer Culture Lab – space 2
10/26/04© University of Wisconsin, CS559 Fall 2004 Last Time Drawing lines Polygon fill rules Midterm Oct 28.
1 Introduction Line attribute Color and gray scale Area filled attribute Anti-aliasing.
Graphics Output Primitives
Hidden Surface Removal 1.  Suppose that we have the polyhedron which has 3 totally visible surfaces, 4 totally invisible/hidden surfaces, and 1 partially.
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.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
MIDPOINT CIRCLE & ELLIPSE GENERARTING ALGORITHMS
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.
Attributes of Graphics Primitives Hearn & Baker Chapter 4 Some slides are taken from Robert Thomsons notes.
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
Scan Conversion.
Lecture 13: Raster Graphics and Scan Conversion
CS552: Computer Graphics Lecture 17: Scan Conversion (Special Cases)
OUTPUT PRIMITIVES A.Aruna/Faculty of Information technology/SNSCE13/19/2016.
Computer Graphics CC416 Week 14 Filling Algorithms.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
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.
10/10/2006TCSS458A Isabelle Bichindaritz1 Line and Circle Drawing Algorithms.
Computer Graphics I, Fall 2010 Scan conversion algorithms.
OUTPUT PRIMITIVES CEng 477 Computer Graphics METU, 2004.
Attributes of Graphics Primitives Hearn & Baker Chapter 4
Computer Graphics Filling.
Introduction to Polygons
Chapter Three Part I Output Primitives CS 380.
Mean Shift Segmentation
Lecture 13 Clipping & Scan Conversion
Chapter 3 Graphics Output Primitives
Primitive Drawing Algorithm
Primitive Drawing Algorithm
Polygons.
Presentation transcript:

March Shape Drawing Algorithms Shmuel Wimer Bar Ilan Univ., Engineering Faculty

March Display Window World –coordinate limits Screen –coordinates (4,2) pixel coordinate

March We’d like to display straight line on the screen. On raster systems, lines are plotted with pixels which have vertical and horizontal finite resolution. The outcome is a jaggy line. In analog displays, such as vector-scan, a smooth line can be displayed, as line equation is translated into deflection voltages. Line Drawing Algorithms

March In raster systems lines are plotted with pixels and step sizes in the horizontal and vertical directions must be sampled at nearest pixel positions.

March 20105

6

7

8

9

10 Circle Drawing Algorithms We could use above equation to step along the x axis from x c - r to x c + r and calculate y positions of pixels.

March This requires considerable amount of computation (square root) The drawing appearance is poor since the vertical spacing between drawn pixels is uneven. Appearance can be improved by changing the role of x and y whenever the absolute value of the slope of circle is crossing 1. But this requires more computation. Polar coordinates can be used with uniform stepping of θ. This spaces pixels evenly along circumference. Time consuming due to trigonometric computations.

March We can use large angular steps and connect the points by straight lines. For smoother boundary we can use angular steps of 1/r which plots pixels approximately one pixel apart of each other (r∙1/r =1). Any of the methods can use symmetry for efficiency. All methods involve expensive computations.

March

March Successive decision parameters are obtained by incremental calculations.

March

March kpkpk (x k+1,y k+1 )2x k+1 2y k (1,10) (2,10) (3,10)620 36(4,9) (5,9) (6,8) (7,7)14

March Ellipse Drawing Algorithms

March Unlike circles, symmetry exists only in quadrants. Midpoint Ellipse Algorithm is working similar to circle with a few adaptations.

March

March

March Polygon Fill Areas Convex polygons are easy to fill Concave polygons are more difficult to fill Some graphics packages support convex polygon filling only. How should polygon split into convex components? We’d like to avoid any trigonometric or division operations. We’ll use vector product a x b for convex / concave test.

March Polygon vertices are counterclockwise oriented. The cross product of successive edges is a perpendicular vector. Z component is positive for convex angle and negative for concave. Only multiplications are involved.

March

March The problem turns to filling of triangles Found concave followed by convex Tear off triangle

March Inside-Outside Tests ? Odd-even rule: Draw “infinite” ray and count the number of crossings. Odd is inside, even outside. Avoid passing through vertices. ? Nonzero winding-number rule: Draw “infinite” directed ray. Traverse edges and check for crossing direction (e.g. by cross product). Add ±1 accordingly. If it sums to zero point is outside, otherwise it is inside.

March Polygon Tables Objects are described by sets of polygon surface facets.

March In hardware implementation these tables translate into physical RW memories. For hardware implementations triangles are preferred, since it makes SURFACE-FACET MEMORY homogeneous. Data in memories needs to be organized to maximize pipeline processing of facets: –Vertices are stored such that vertex progression in VERTEX MEMORY completes new triangle for every vertex. –Vertex indices are their memory addresses. It is the SW application responsibility to triangulate objects and load HW memories in the right order.

March Plane Equations Graphics system processes input data through several steps: –Transformation of modeling through viewing pipeline. –Identification of visible surfaces. –Rendering of surface facets. Information about the spatial orientation of surfaces is needed –Plane equations are in order. –How to calculate those efficiently w/o divisions?

March

March Front and Back Polygon Faces Polygon surfaces enclose objects. –Need to know the outward an inward sides of polygon. Need to find the side of a polygon visible by an observer.

March Scan-Line Polygon-Fill Algorithms This is most time consuming operation in computer graphics. –Use only integer arithmetic with minimum operations Polygons are filled with scan-line –The sweep is vertical –A scan-line is the pixels of same y coordinates Pixels between odd-even intersections with border are inside. x 1234

March Scan-line y 2 11 Scan-line y’ A problem may occur at vertices. Scan-line y’ is okay, but y is not. The remedy is to traverse edges prior to filling and detect the values of three consecutive of two successive edges. If they are monotonic then one of the edges is shortened by one pixel at corner

March Polygon filling takes advantage of y increments by one unit. How to calculate efficiently the intersection of an edge with scan line? How to avoid division?

March

March

March Antialiasing Graphics primitives generated by raster algorithms have jagged (stair-step) appearance, called aliasing. –This is due to under sampling. –Antialiasing compensates for this. Sampling rate could increase by higher raster resolution. –Expensive, increase of frame buffer (memory). –More processing (time, hardware). –Jagging phenomena is not canceled, but only improved. Raster systems capable of gradual intensity of pixels can support antialiasing by modifying pixel intensity near boundary of primitives.

March Antialiasing by Supersampling Treat the screen as if it has finer grid than actual. Modify real pixel intensity according to the number of covered sub-pixels There are 4 possible intensities, depending on the count of covered pixels at every 3x3 superpixel (1,1) is covered by 3 subpixels (2,2) and ((3,2) are covered by 2 subpixels (2,1) and ((3,3) are covered by 1 subpixels

March Line was treated as zero width. In case of finite width we count the number of subpixels inside the polygon representing the line. Useful also for mixing foreground and background colors in a pixel. For instance, if foreground is red and background is blue:

March Central pixel is most important and has a weight of 1/4. Others has a weight of 1/8 and 1/16. Antialiasing by subpixel Weighting Masks Antialiasing compensates for line-intensity differences Diagonal lines are less instance than horizontal and vertical ones. Supersampling with higher weights for subpixels close to diagonal will intensify diagonal lines

March Antialiasing Area Boundaries Pixel intensities are adjusted along the boundary of area. Subdivide area of pixels and double scan- line. Count how many subpixels are inside. Scan-line 1 Scan-line 2 75% pixel intensity

March Percentage of pixel area within fill area by midpoint method (Pitteway & Watkinson).

March boundary line overlap area