1 CPE 333 : Computer Graphics มหาวิทยาลัยเทคโนโลยีพระจอม เกล้าธนบุรี Dr. Natasha Dejdumrong.

Slides:



Advertisements
Similar presentations
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
Advertisements

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.
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.
30/9/2008Lecture 21 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
Advanced Manufacturing Laboratory Department of Industrial Engineering Sharif University of Technology Session # 6.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Output Primitives Computer Graphics.
CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics May 3, 2007.
SWE 423: Multimedia Systems Chapter 4: Graphics and Images.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Scan Conversion CS123 1 of 44Scan Conversion - 10/14/2014.
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)
2.01 Understand Digital Raster Graphics
Image Representation CS105. Data Representation Text representation – ASCII character set – Unicode – Data compression Images!
Introduction to Computer Graphics
MULTIMEDIA TECHNOLOGY SMM 3001 MEDIA - GRAPHICS. In this chapter how the computer creates, stores, and displays graphic images how the computer creates,
Vector Graphics Making custom images. Raster vs. Vector Graphics In computer graphics, a raster graphics image, or bitmap, is a dot matrix data structure.
Lecture 3. Fundamentals of Computer Graphics. Computer Graphics, a very broad term Fields Related to Computer Graphics Bitmap/Vector graphics, 2D/3D graphics,
Computer Systems Nat 4.5 Computing Science Data Representation Lesson 4: Storing Graphics EXTENSION.
COMP Bitmapped and Vector Graphics Pages Using Qwizdom.
1/1/20001 Topic >>>> Scan Conversion CSE Computer Graphics.
IT- 601: Computer Graphics Lecture-03 Scan Conversion
Dr. S.M. Malaek Assistant: M. Younesi
Jehee Lee Seoul National University
Scan Conversion Line and Circle
Objective Understand concepts used to create digital graphics. Course Weight : 15% Part Three : Concepts of Digital Graphics.
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.
Digital Terminology. Bitmap A representation consisting of rows and columns of dots of a graphic image stored in computer memory. To display a bitmap.
INT 840E Computer graphics Introduction & Graphic’s Architecture.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Digital Media Dr. Jim Rowan ITEC So far… We have compared bitmapped graphics and vector graphics We have discussed bitmapped images, some file formats.
Lecture 7: Intro to Computer Graphics. Remember…… DIGITAL - Digital means discrete. DIGITAL - Digital means discrete. Digital representation is comprised.
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.
CS 325 Introduction to Computer Graphics 02 / 03 / 2010 Instructor: Michael Eckmann.
In the name of God Computer Graphics. Today Introduction Sampling Graphic Output Primitives 1.Line 2.Circle 3.Curve 4.polygon.
Handle By, S.JENILA AP/IT
CISC 110 Day 3 Introduction to Computer Graphics.
Digital Media Dr. Jim Rowan ITEC 2110 Chapter 3. Roll call.
Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan.
Scan Conversion.
HOW SCANNERS WORK A scanner is a device that uses a light source to electronically convert an image into binary data (0s and 1s). This binary data can.
1 Module U08181: Computer Graphics graphics primitives part 1: scan conversion and filling.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
Lecture 2: 19/4/1435 Graphical algorithms Lecturer/ Kawther Abas CS- 375 Graphics and Human Computer Interaction.
Mohammed AM Dwikat CIS Department Digital Image.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
AUTUMN Asst. Prof. Dr. Gazi Erkan BOSTANCI Slides by Robert Thomson, Süleyman Tosun and Kurtuluş Küllü.
IS502:M ULTIMEDIA D ESIGN FOR I NFORMATION S YSTEM D IGITAL S TILL I MAGES Presenter Name: Mahmood A.Moneim Supervised By: Prof. Hesham A.Hefny Winter.
Graphics Basic Concepts 1.  A graphic is an image or visual representation of an object.  A visual representation such as a photo, illustration or diagram.
Computer Graphic. Raster graphics In computer graphics, a raster graphics image, digital image, or bitmap, is a data structure representing a generally.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Unit 2.6 Data Representation Lesson 3 ‒ Images
Scan Conversion or Rasterization
CSCE 441 Lecture 2: Scan Conversion of Lines
2.01 Understand Digital Raster Graphics
2.01 Understand Digital Raster Graphics
Bitmap Image Vectorization using Potrace Algorithm
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Scan Conversion or Rasterization
Rasterizing Lines 1 Lecture 32 Mon, Nov 12, 2007.
2.01 Understand Digital Raster Graphics
Introduction to Computer Graphics
Introduction to Computer Graphics with WebGL
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
2.01 Understand Digital Raster Graphics
Web Programming– UFCFB Lecture 7
Computer Systems Nat 4.5 Computing Science Data Representation
Visuals are analog signals...
2.01 Understand Digital Raster Graphics
Presentation transcript:

1 CPE 333 : Computer Graphics มหาวิทยาลัยเทคโนโลยีพระจอม เกล้าธนบุรี Dr. Natasha Dejdumrong

2 Course Description Line Drawing Circle Drawing [ Ellipse Drawing ] 2D and 3D Transformations Line and Polygon Clipping techniques 3D Viewing Geometric Modeling: Representation of Curves and Surfaces, Solid Modeling Hidden Surface Removal Algorithms Illumination and Shading models Ray tracing

3 Text Book and Supplements Textbook – Hearn Baker, Computer Graphics with OpenGL, 3rd Ed., Pearson International Edition, Lecture Note Powerpoints

4 Schedule Classroom: CB40805 Lecture Time:Monday 13:30 – 15:20 [AB] Tuesday 14:30 – 16:20 [CD] Lab Time:Monday 14:30 – 16:20 [AB] Tuesday 16:30 – 17:20 [CD]

5 Active Learning Lecture: 2 Hours Laboratory: 2 Hours Teaching Assistant: Pitchaya Jamjun

6 Marking Midterm Examination 20% Final Examination 30% Assignments 40% Class + Lab Attendance 10% Total100%

7 Grading Policy 80 or aboveA 75-79B B 65-69C C 55-59D D under 50F

8 Chapter 2 Scan Conversion

9 Overview Point Line Circle Ellipse

10 Raster Graphics A raster graphics image, digital image, or bitmap, is a data file or structure representing a generally rectangular grid of pixels, or points of color, on a computer monitor, paper, or other display device.

11 Vector Graphics Vector graphics (also called Geometric Modeling or Object-Oriented Graphics) is the use of geometrical primitives such as points, lines, curves, and polygons, which are all based upon mathematical equations to represent images in computer graphics. It is used by contrast to the term raster graphics, which is the representation of images as a collection of pixels (dots). Raster graphics are distinguished from vector graphics in that vector graphics represent an image through the use of geometric objects such as curves and polygons.

12 Raster vs Vector Graphics Raster graphics cannot be scaled to a higher resolution without loss of apparent quality. This is in contrast to vector graphics, which easily scale to the quality of the device on which they are rendered.vector graphics Raster graphics are more practical than vector graphics for photographs and photo-realistic images, while vector graphics are often more practical for typesetting or graphic design.

13 RGB The color of each pixel is individually defined; images in the RGB color space, for instance, often consist of colored pixels defined by three bytes—one byte each for red, green and blue. Less colorful images require less information per pixel; an image with only black and white pixels requires only a single bit for each pixel. A colored raster image (or pixmap) will usually have pixels with between one and eight bits for each of the red, green, and blue components.

14 Resolution The quality of a raster image is determined by the total number of pixels ( resolution ), and the amount of information in each pixel (often called color depth ). color depth For example, an image that stores 24 bits of color information per pixel can represent smoother degrees of shading than one that only stores 16 bits per pixel, but not as smooth as one that stores 48 bits. Likewise, an image sampled at 640 x 480 pixels (therefore containing 307,200 pixels) will look rough and blocky compared to one sampled at 1280 x 1024 (1,310,720 pixels). Because it takes a large amount of data to store a high- quality image.

15 Point Real World A point has no dimension. Practical Representation A point has size. Analytic Geometry A point P = (x, y) [For 2 Dimension] A point P = (x, y, z) [For 3 Dimension]

16 Raster Graphics Pixels Example Point(4.3, 5.3) = Pixel(4, 5) Point(3.8, 4.8) = Pixel(4, 5)

Straight Line (x 2,y 2 ) (x 1,y 1 ) y = m x +b y x b

18 Equation : y = m x + b b : y-interceptm : dy/dx F(x, y) : Ax + By +C = 0 F(x, y) : dy x - dx y + b dx = 0 Therefore, A = dy, B = -dx, C = b dx Straight Line

Bresenham’s Line Algorithm

Midpoint Line Algorithm

Suppose that point (x i, y i ) has been plotted. We move x i to x i + 1. The problem is how to select between two pixels, U (x i + 1, y i + 1) and D (x i + 1, y i ). For this purpose, we consider the middle pixel M (x i + 1, y i + 1/2). d = F(M) = a (x i + 1) + b( y i + 1/2) + c IFd > 0,choose U d < 0,choose D d = 0,choose either U or D, so choose U.

When D is chosen, M is incremented one step in the x direction. So d new =F (x i +2, y i + 1/2) =a (x i + 2) + b (y i + 1/2) + c while d old =F (x i + 1, y i + 1/2) = a (x i + 1) + b (y i + 1/2) + c So the increment in d (denoted d D ) is d D =d new - d old = a = dy

When U (x i + 1, y i + 1) is chosen, M is incremented one step in both directions: d new =F (x i +2, y i + 3/2) =a (x i + 2) + b( y i + 3/2) + c =d old + a + b So the increment in d (denoted d U ) is d U = a + b = dy - dx

First, we have the point (x 1, y 1 ). So M (x 1 + 1, y 1 + 1/2) and F(M) =a (x 1 + 1) + b (y 1 + 1/2) + c =F (x 1, y 1 ) + a + b/2 Since F (x 1, y 1 ) = 0, we have d = d 1 = dy - dx/2

In order to avoid a division by 2, we use 2d 1 instead. Afterward, 2d is used. So, with d used in place of 2d, we have First set d 1 = 2dy - dx IF d i >= 0 THEN x i+1 = x i + 1, y i+1 = y i + 1 and d i+1 = d i + 2 (dy-dx) IF d i < 0 THEN x i+1 = x i + 1, y i+1 = y i and d i+1 = d i + 2dy

26 Midpoint Line Algorithm [Scan-convert the line between (x 1, y 1 ) and (x 2, y 2 )] dx = x 2 - x 1 ; dy = y 2 - y 1 ; d = 2 * dy - dx;/* initial value of d */ dD = 2 * dy;/* increment used to move D */ dU = 2 * (dy-dx);/* increment used to move U */ x = x 1 ; y = y 1 ; Plot(x,y);/* the first pixel */ While (x < x 2 ) if d < 0 then d = d + dD;/ * choose D */ x = x + 1; else d = d + dU;/* choose U */ x = x + 1; y = y + 1; endif Plot(x,y);/* the selected pixel closest to the line */ EndWhile Midpoint Line Algorithm

Since for the points, x < y, consequently the algorithm can apply. Here dy = = 3, dx = 9-5 = 4 First d 1 = 2dy - dx = = 2 > 0Select U So the new point is (6, 9) and d 2 = d (dy - dx) = 2 + 2(-1) = 0Select U The chosen pixel is (7, 10) and d 3 = d (dy - dx) = 0 +2(-1) = -2 < 0 Select D The chosen pixel is (8, 10) then d 4 = d 3 + 2dy = = 5 > 0Select U The chosen pixel is (9, 11). Example. Scan-convert the line between (5, 8) and (9, 11). Example

28 Bresenham’s Line Algorithm can work only with the line segment with slope m from 0 to 1. (45 o ) y x Remarks

29 Bresenham’s Line Algorithm can work only with the line segment with slope m from 0 to 1. (45 o ) Remarks

30 Bresenham’s Line Algorithm can work only with the line segment with slope m from 0 to 1. (45 o ) Remarks

31 x 2 + y 2 = r 2 F ( x,y ) = x 2 + y 2 - r 2 F ( x,y ) = (x - x c ) 2 + (y - y c ) 2 - r 2 x = r cos(theta) y = r sin(theta) Circle

32 F ( x,y ) = (x - x c ) 2 + (y - y c ) 2 - r 2 IF F ( x,y ) = 0 : Point ( x,y ) is on the circle. IF F ( x,y ) < 0 : Point ( x,y ) is inside the circle. IF F ( x,y ) > 0 : Point ( x,y ) is outside the circle. F ( x,y ) < 0 F ( x,y ) > 0 Circle

33 Midpoint Circle Algorithm

34 P 1 = ( x, y ) P 5 = (- y, -x ) P 2 = ( y, x ) P 6 = (- y, -x ) P 3 = (- y, x ) P 7 = ( y, -x ) P 4 = (- x, y ) P 8 = ( x, - y ) Eight-Way Symmetry

35 d = F(M) = F(x i, y i ) = x i 2 + y i 2 - r 2 IFd < 0,choose U d > 0,choose D d = 0,choose either U or D, so choose U. Midpoint Algorithm

Let d old = F(x i +1, y i - 1/2) = (x i + 1) 2 + (y i - 1/2) 2 - r 2 If d old < 0, then U (x i+1, y i ) is chosen and the next midpoint will be one increment over x. Thus d new = F(x i +2, y i - 1/2) = d old + 2x i + 3 The increment in d is d U = d new - d old = 2x i + 3

IF d old >= 0, M is outside the circle and D is chosen. The new midpoint will be one increment over x and one increment down in y: d new = F (x i + 2, y i - 3/2) = d old + 2x i - 2y i + 5 The increment in d is therefore d D = d new - d old = 2(x i - y i ) + 5

Initial point : (0, r). The next midpoint lies at (1, r- 1/2) and so F (1, r- 1/2) = 1 + (r- 1/2) 2 - r 2 = 5/4 - r To avoid the fractional initialization of d, we take h = d - 1/4. So the initials value of h is 1-r and the comparison d < 0 becomes h < -1/4. However, since h starts out with an integer value and is incremented with integer values ( d U and d D ), we can change the comparison to h < 0.

39 h = 1-r; /* initialization */ x = 0; y = r; Plot(x,y); While y > x if h < 0 then/* Select U */ dU = 2*x + 3; h = h + dU; x = x + 1; else/* Select D */ dD = 2*(x-y) + 5; h = h + dD; x = x + 1; y = y - 1; endif Plot(x,y); EndWhile Midpoint Circle Algorithm