In the name of God Computer Graphics. Today Introduction Sampling Graphic Output Primitives 1.Line 2.Circle 3.Curve 4.polygon.

Slides:



Advertisements
Similar presentations
Graphics Primitives: line
Advertisements

Computer Graphics- SCC 342
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
Section 3-1 to 3-2, 3-5 Drawing Lines Some of the material in these slides may have been adapted from university of Virginia, MIT, and Åbo Akademi University.
Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Drawing Elementary Figures Dr. Eng. Farag Elnagahy.
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
+ 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.
In the name of God Computer Graphics Bastanfard.
Raster conversion algorithms for line and circle
Output Primitives Computer Graphics.
Line Drawing by Algorithm. Line Drawing Algorithms Line drawn as pixels Graphics system –Projects the endpoints to their pixel locations in the frame.
CS 450: COMPUTER GRAPHICS DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
Circle Drawing algo..
CGMB214: Introduction to Computer Graphics
1/1/20001 Topic >>>> Scan Conversion CSE Computer Graphics.
Dr. S.M. Malaek Assistant: M. Younesi
Jehee Lee Seoul National University
Graphics Primitives: line. Pixel Position
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.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
Introduction to Computer Graphics with WebGL
CS 480/680 Computer Graphics Implementation III Dr. Frederick C Harris, Jr. Fall 2011.
Introduction Computer Graphics & Its application Types of computer graphics Graphic display : random Scan & Raster Scan display Frame buffer and video.
Graphics Output Primitives
CGMB214: Introduction to Computer Graphics
 A line segment in a scene is defined by the coordinate positions of the line end-points x y (2, 2) (7, 5)
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.
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.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
1 CSCE 441 Lecture 2: Scan Conversion of Lines Jinxiang Chai.
GEOMETRY AND LINE GENERATION Geometry and Line Generation Chapter 2.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Lecture 15: Raster Graphics and Scan Conversion
Lecture 13: Raster Graphics and Scan Conversion
Bresenham’s Line Algorithm
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.
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.
10/10/2006TCSS458A Isabelle Bichindaritz1 Line and Circle Drawing Algorithms.
Computer Graphics Lecture 06 Circle Drawing Techniques Taqdees A. Siddiqi
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.
Line Drawing Algorithms 1. A line in Computer graphics is a portion of straight line that extends indefinitely in opposite direction. 2. It is defined.
OUTPUT PRIMITIVES CEng 477 Computer Graphics METU, 2004.
Objectives Understand Bresenhams line drawing algorithm. Apply the algorithm to plot a line with the end points specified.
Primitive graphic objects
CSCE 441 Lecture 2: Scan Conversion of Lines
Lecture 9 Line Drawing Algorithms (Bresenham’s Line Algorithm)
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Implementation III.
Chapter Three Part I Output Primitives CS 380.
CSCE 441 Lecture 2: Scan Conversion of Lines
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Introduction to Computer Graphics
Rasterization and Antialiasing
Rasterization and Antialiasing
Chapter 3 Graphics Output Primitives
Primitive Drawing Algorithm
Primitive Drawing Algorithm
Presentation transcript:

In the name of God Computer Graphics

Today Introduction Sampling Graphic Output Primitives 1.Line 2.Circle 3.Curve 4.polygon

A scene from the wolfman video. The animated figure of this primitive lycanthrope is modeled with 61 bones and eight layers of fur. Each frame of the computer animation contains 100,000 surface polygons. (Courtesy of the NVIDIA Corporation.)

Preface On raster systems, lines are plotted with pixels, and step sizes in the horizontal and vertical directions are constrained by pixel separations. That is, we must “sample” a line at discrete positions and determine the nearest pixel to the line at each sampled position. The DDA algorithm is a faster method for calculating pixel positions than one that directly implements line equation. And in the next section, we consider a more general scan-line approach that can be applied to both lines and curves (Bresenham).

Sampling

Why Sampling? Once image is defined in terms of colors at (x, y) locations on grid, can change image easily by altering location or color values E.g., if we reverse our mapping above and make 10 = white and 0 = black, the image would look like this:

Why Sampling? Pixel information from one image can be copied and pasted into another, replacing or combining with previously stored pixels

Disadvantage? WYSIAYG (What You See Is All You Get): No additional information – no depth information – can’t examine scene from a different point of view – at most can play with the individual pixels or groups of pixels to change colors, enhance contrast, find edges, etc. But recently, strong interest in image-based rendering to fake 3D scenes and arbitrary camera positions. New images constructed by interpolation, composition, warping and other operations. Capture of Hair Geometry from Multiple Images, Siggraph 2004

Digital Images Computers work with discrete pieces of information How do we digitize a continuous image? –Break the continuous space into small areas, pixels –Use a single value for each pixel - the pixel value (no color, yet) –No longer continuous in space or intensity we shall see Continuous Discrete Pixels: Picture Elements

Point To specify the geometry of a point, we simply give a coordinate position in the world reference frame. Then this coordinate position, along with other geometric descriptions we may have in our scene, is passed to the viewing routines. Unless we specify other attribute values, OpenGL primitives are displayed with a default size and color. The default color for primitives is white and the default point size is equal to the size of one screen pixel.

Line Drawing Algorithm Graphics packages typically provide a function for specifying one or more straight-line segments, where each line segment is defined by two endpoint coordinate positions.

Line Drawing Algorithm A straight-line segment in a scene is defined by the coordinate positions for the endpoints of the segment. Example, A computed line position of (10.48, 20.51), for example, is converted to pixel position (10, 21). This rounding of coordinate values to integers causes all but horizontal and vertical lines to be displayed with a stair-step appearance (“the jaggies”) Improvement high-resolution systems. adjusting pixel intensities along the line path.

Display the line on a Raster Monitor This process digitizes the line into a set of discrete integer positions that, in general, only approximates the actual line path. graphics system project the endpoints to integer screen coordinates and determine the nearest pixel positions along the line path between the two endpoints. Reading from the frame buffer, the video controller plots the screen pixels. This process digitizes the line into a set of discrete integer positions. The line color is loaded into the frame buffer at the corresponding pixel coordinates.

Graphic Hardware Display Vector (random-scan) – still used in some plotters Raster (TV, bitmap), used in displays and laser printers Outline primitives Filed primitives

2D Raster Architecture Raster display stores bitmap in refresh buffer, also known as bitmap, frame buffer; can be in separate hardware (VRAM) or in CPU’s main memory (DRAM) Video controller draws all scan-lines at consistent > 60 Hz; separates update rate of the frame buffer and refresh rate of the CRT

2D Hardware/Algorithm Outline Display Hardware: Raster scan vs. random scan Drawing primitives by scan conversion – lines, polygons, circles and ellipses, characters, attributes (color, line style, fill pattern…) Clipping to clip rectangle: three methods – analytically compute intersections and draw clipped primitives – test each pixel and write only if inside – compute spans inside the primitive and fill entire span Color Table – indirect specification of (pseudo) color – color correction, simple types of animation Bit/RasterOp for operating on blocks of pixels

Line Equations(1) Determine pixel positions along a straight-line path from the geometric properties of the line. The Cartesian slope-intercept equation for a straight line is Y intercept X,Y interval slope

Line Equation(2) Voltage deflection in analog display system X,Y interval

Voltage deflection in analog display like vector-scan system For lines whose slopes have magnitudes | m | > 1, be set proportional to a small vertical deflection voltage with the corresponding horizontal deflection voltage set proportional to, calculated from Eq For lines with m = 1, = and the horizontal and vertical deflections voltages are equal. In each case, a smooth line with slope m is generated between the specified end points. X,Y interval

DDA Algorithm The digital differential analyzer (DDA) is a scan- conversion line algorithm based on calculating A line is sampled at unit intervals in one coordinate and the corresponding integer values nearest the line path are determined for the other coordinate. We consider first a line with positive slope.

DDA Algorithm(2) If the slope is less than or equal to 1 sample at unit x intervals ( ) and compute successive y values as Since m can be any real number between 0.0 and 1.0, each calculated y value must be rounded to the nearest integer corresponding to a screen pixel position in the x column we are processing. Subscript k takes integer values starting from 0, for the first point, and increases by 1 until the final endpoint is reached. For lines with a positive slope greater than 1.0,we reverse the roles of x and y.

Bresenham Algorithm? negative slope line segment is to be plotted, we need to determine at the next sample position whether to plot the pixel at position at pixel position (50, 50). next pixel position as (51, 50) or as (51, 49)?

Bresenham Algorithm Scan conversion for lines with 0<m<1. (xk, yk) is to be displayed. Now choose the pixel to plot in column xk+1= 1+ xk from (xk+1,yk+1) & (xk+1,yk)

Bresenham Algorithm(1) Accurate & efficient raster line-generating algorithm uses integer calculations-adapted to other curves scan line positions (Y axis) pixel columns (X axis) Sampling at unit x intervals, choose the closer of the 2 possible pixel positions to the line path at each sample step depending on sign of slope

Bresenham Algorithm(2) we first consider the scan-conversion process for lines with positive slope less than 1.0. Pixel positions along a line path are then determined by sampling at unit x intervals. Starting from the left endpoint ( x 0, y 0 ) of a given line, we step to each successive column ( x position) and plot the pixel whose scan-line y value is closest to the line path.

Bresenham Algorithm(2) Assuming the pixel at ( x k, y k ) is to be displayed, we need to decide which pixel to plot in column Our choices are the pixels at positions ( x k + 1, y k ) and ( x k + 1, y k + 1). At sampling position x k + 1, label vertical pixel separations from the mathematical line path as d lower and d upper. The y coordinate on the mathematical line at pixel column position x k + 1 is calculated as: y = m ( x k + 1 ) + b Then d lower = y - y k = m ( x k + 1 ) + b - y k d upper = ( y k + 1 ) - y = y k m ( x k + 1 ) - b

Bresenham Algorithm(3) which of the two pixels is closest to the line path, efficient test that is difference between the two pixel separations: d lower - d upper = 2 m ( x k + 1 ) - 2 y k + 2 b - 1 A decision parameter p k for the k th step in the line algorithm can be obtained by rearranging so that it involves only integer calculations.

Bresenham Algorithm(4) the vertical and horizontal separations of the endpoint positions, and defining the decision parameter as p k = ( d lower - d upper ) The sign of p k is the same as the sign of d lower - d upper, since > 0for our example. Parameter c is constant and has the value,which is independent of the pixel position and will be eliminated in the recursive calculations for p k.

Bresenham Algorithm(5) If the pixel at y k is “closer” to the line path than the pixel at y k + 1 (that is, d lower < d upper ), then decision parameter p k is negative. In that case, we plot the lower pixel; otherwise we plot the upper pixel. Coordinate changes along the line occur in unit steps in either the x or y directions. Therefore, we can obtain the values of successive decision parameters using incremental integer calculations. At step k + 1, the decision parameter is evaluated from Eq as

Bresenham Algorithm(6) Subtracting Eq from the preceding equation, we have But, so that where the term y k y k is either 0 or 1, depending on the sign of parameter p k. The first parameter, p 0, is evaluated from Eq at the starting pixel position ( x 0, y 0 ) and with m evaluated as

Bresenham Algorithm Bresenham’s Line-Drawing Algorithm for | m | < 1. 0

Example(1) To illustrate the algorithm, we digitize the line with endpoints (20, 10) and (30, 18). This line has a slope of 0.8, with We plot the initial point ( x 0, y 0 ) = (20, 10), and determine successive pixel positions along the line path from the decision parameter as:

Example(2)