Attributes of Graphics Primitives Chapter 4

Slides:



Advertisements
Similar presentations
Polygon Scan Conversion – 11b
Advertisements

Computer Graphics- SCC 342
CHAPTER 3 2D GRAPHICS ALGORITHMS
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Polygon Rasterization
CP411 polygon Lecture 6 1. Scan conversion algorithm for circle 2. Draw polygons 3. Antialiasing.
CS 551 / CS 645 Antialiasing. What is a pixel? A pixel is not… –A box –A disk –A teeny tiny little light A pixel is a point –It has no dimension –It occupies.
© 2001 By Default! A Free sample background from Slide 1 Attributes of Output Primitives Definition Parameter that affects.
CMPE 466 COMPUTER GRAPHICS Chapter 5 Attributes of Graphics Primitives Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth.
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
Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 21 Today’s class Graphics programming Color.
CS 376 Introduction to Computer Graphics 02 / 05 / 2007 Instructor: Michael Eckmann.
Output Primitives Computer Graphics.
Implementation Dr. Amy Zhang. Reading 2  Hill, Chapters  Hill, Chapter 10.
CMPE 466 COMPUTER GRAPHICS
CSCE 441: Computer Graphics Scan Conversion of Polygons
Graphics Programming: Polygon Filling
CST 494/598 Computer Graphics Anshuman Razdan i3dea.asu.edu/razdan.
CS 454 Computer graphics Polygon Filling
Graphics Output Primitives Pixel Addressing and Fill Area Dr. M. Al-Mulhem Feb. 1, 2008.
CS 4731: Computer Graphics Lecture 22: Raster Graphics Part 3 Emmanuel Agu.
Computer Graphics, KKU. Lecture 9
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
March Shape Drawing Algorithms Shmuel Wimer Bar Ilan Univ., Engineering Faculty.
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
Geometric Objects Computer Graphics Lab. Sun-Jeong Kim.
CGMB214: Introduction to Computer Graphics
IT- 601: Computer Graphics Lecture-03 Scan Conversion
Dr. S.M. Malaek Assistant: M. Younesi
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:
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 고려대학교 컴퓨터 그래픽스 연구실.
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.
Ch 2 Graphics Programming page 1 CSC 367 Coordinate Systems (2.1.2) Device coordinates, or screen coordinates (pixels) put limitations on programmers and.
CGMB214: Introduction to Computer Graphics
INT 840E Computer graphics Introduction & Graphic’s Architecture.
Scan Conversion. Last step in the graphics pipeline Efficiency is a central issue Common primitives – Lines (done last class) – Polygons (fill polygons,
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Attributes of Graphics Primitives Hearn & Baker Chapter 4 Some slides are taken from Robert Thomsons notes.
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.
CS552: Computer Graphics Lecture 17: Scan Conversion (Special Cases)
Rasterization Overview Raster Display Device. Scan Conversion / Rasterization: converting vector graphics into raster graphics (determining pixels in.
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.
ATTRIBUTE OF OUTPUT PRIMITIVES. Attribute of Output Primitives 30/9/2008 A.Aruna/Assistant professor/IT/SNSCE 2 Definition Line Attribute Curve Attribute.
OUTPUT PRIMITIVES CEng 477 Computer Graphics METU, 2004.
Pattern filling in scan-conversion Antialiasing
CSC Graphics Programming
Attributes of Graphics Primitives Hearn & Baker Chapter 4
Computer Graphics Filling.
Introduction to Polygons
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
Agenda Polygon Terminology Types of polygons Inside Test
o عَلَّمَهُ الْبَيَانَ
Prepared by Narendra V G CSE MIT
Agenda Polygon Terminology Types of polygons Inside Test
Primitive Drawing Algorithm
NOTE.
Primitive Drawing Algorithm
Polygons.
Presentation transcript:

Attributes of Graphics Primitives Chapter 4

Atrributes of Output Primitves In general, any parameter that affects the way a primitive displayed is an attribute parameter. Ex: Line attributes type (solid, dashed, dotted), width, cap (butt, round, projecting square caps), join (miter, round, etc.), color, grayscale

Point Attributes -OpenGL glPointSize(GLfloat size); Example : glColor3f ( 1.0, 0.0, 0.0); glBegin(GL_POINTS); glVertex2i(50,100); glPointSize(2.0); glColor3f ( 0.0, 1.0, 0.0); glVertex2i(75,150); glPointSize(3.0); glColor3f ( 0.0, 0.0, 1.0); glVertex2i(100,200); glEnd ( );

3 Line Attributes- OpenGL Line Color – glcolor( ); Line Width - glLineWidth(GLfloat width); Line Style - glLineStipple(repeatFactor, pattern); Pattern – 16-bit integer ( 0xFFFF with each bit position 1 ) default is a solid line Repeat factor specifies how many times each bit in the pattern is repeated before the next bit in the pattern is applied.- Default value is 1 Example: glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0x00FF); // Plot dashed double width line glLineWidth(2.0); lineplot( ) ; // plot the line glLineStipple(1, 0x0101); \\Plot dotted triple width line glLineWidth(3.0); lineplot( ); glDisable(GL_LINE_STIPPLE);

Polygons Filling Polygons Scan-line fill algorithm Inside-Outside tests Boundary fill algorithm 11 1 2 3 4 5 6 7 8 9 10 5 6 7 8 9 4 3 1 2

SCAN-CONVERTING POLYGONS Find the intersections of the scan-line with all edges of the polygon. Sort the intersections by increasing the x coordinate. Fill in all pixels between pairs of intersections that lie interior to the polygon, using the odd-parity rule to determine that a point is inside a region. 6 .6.

Scan-Line Polygon Fill Topological Difference between 2 Scan lines y : intersection edges are opposite sides y’ : intersection edges are same side y 1 2 2 y’ 1 1

Scan-Line Polygon Fill (cont.) Edge Sorted Table B yC yB xC 1/mCB C C’ E yD yC’ xD 1/mDC yE xD 1/mDE D yA yE xA 1/mAE yB xA 1/mAB A 1 Scan-Line Number

Procedure Set y to the smallest y that has an entry in the ET(Edge Table – all edges sorted by smaller y cord Initialize the AET(Active ET corresponds to current scan line) to be empty. Repeat until the AET and ET are empty: Move from ET bucket y to AET those edges whose ymin = y. Sort the AET on x. Fill-in desired pixel values on scan-line y by using pairs of x coord. from the AET. Increment y by 1. Remove from the AET those entries that y=ymax. For each non-vertical edge remaining in the AET, update x for the new y: x = x + 1/m.

Example

Inside-Outside Tests Self-Intersections – scan line polygon Fill Algorithm Odd (Interior)-Even(Exterior) rule exterior interior

Boundary-Fill Algorithm Proceed to Neighboring Pixels 4-Connected 8-Connected

OpenGL Implementation A convex polygon means that all the angles inside the polygon formed by the edges are smaller than 180 degrees. If a polygon is not convex, it is concave. Convex polygons can be scan-converted faster than concave polygons. OpenGL draws a convex polygon with the following commands: glBegin(GL_POLYGON); // a list of vertices glEnd();

Effects of Scan conversion Aliasing : The distortion that result from scan conversion. Staircase Effect ( jagged appearance) Unequal Brightness( slanted line appears dimmer than a horizontal/vertical) Picket Fence Problem(object is not aligned to the pixel grid) Hence we go for Anti Aliasing

Antialiasing Aliasing Undersampling: Low-frequency sampling Nyquist sampling frequency: Nyquist sampling interval: original sample reconstruct

Antialiasing Supersampling (Postfiltering) Increase the sampling rate by Sampling object charactersitics at a high resolution and display the results in low resolution is called Area Sampling (Prefiltering) Pixel Phasing Shift the display location of pixel areas

SPECIFYING A COLOR -OpenGL glColor3f(0.0, 0.0, 0.0); draw_object(A); draw_object(B); glColor3f(1.0, 0.0, 0.0); draw_object(C); glColor3f(0.0, 0.0, 0.0); black glColor3f(1.0, 0.0, 0.0); red glColor3f(0.0, 1.0, 0.0); green glColor3f(1.0, 1.0, 0.0); yellow glColor3f(0.0, 0.0, 1.0); blue glColor3f(1.0, 0.0, 1.0); magenta glColor3f(0.0, 1.0, 1.0); cyan glColor3f(1.0, 1.0, 1.0); white

Supersampling (postfiltering) Increase sampling rate, each pixel area is covered by a finer grid We can then use multiple sample points in a pixel that is within a line to determine an appropriate intensity level for the pixel. Supersampling algorithms often choose more weight to subpixels near the center of a pixel area: pixel- wighting masks

Area sampling (prefiltering) Determine pixel intensity by calculating the areas of overlap of each pixel with the objects to be displayed Unweighted Area Sampling determines the pixel intensity by the overlap area only Weighted Area Sampling an area closer to the pixel’s center has greater influence on the pixel’s intensity than an equal area further away from the pixel’s center.

Supersampling Subpixels Increase resolution 22 (10, 20): Maximum Intensity (11, 21): Next Highest Intensity (11, 20): Lowest Intensity 21 20 10 11 12

Supersampling Subpixels (10, 20): Maximum Intensity –Level3 (11, 21), (12,21): Next Highest Intensity-2 (11, 20),(12,22): Lowest Intensity-1 Subpixels Increase resolution 22 21 20 10 11 12

Pixel-Weighting Masks Give More Weight to Subpixels Near the Center of a Pixel Area Sum of the weights in the filter =1 Low pass Filtering 1 2 4 1/16 1/8 1/4

Area Sampling Set Each Pixel Intensity Proportional to the Area of Overlap of Pixel 2 adjacent vertical (or horizontal) screen grid lines  trapezoid 22 (10, 20): 90% (10, 21): 15% 21 20 10 11 12

Filtering Techniques Filter Functions (Weighting Surface) Box Filter Cone Filter Gaussian Filter

Character Generation Bitmapped Fonts:   Bitmapped Fonts:  .Characters represented as a rectangular grid or bits. .Simple and quick to draw because character is mapped onto pixel positions in the frame buffer. .However, it needs a lot of space. Each variation in size and style needs to be stored separately in a font cache. .Can still generate different size and styles from a single bitmap but the results are poor quality because bitmap descriptions do not scale well.

Character Generation   . Overall design or style for set of characters is called type-face. .Ex: Courier, Arial, Times New Roman. .Type-face are serif and san-serif (optima). .Font is originally referred to size and format.