College of Computer and Information Science, Northeastern UniversityOctober 17, 20151 CS 4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture 5.

Slides:



Advertisements
Similar presentations
Pixels and Digital Images Yrd. Doc. Dr. Ahmet Sayar Kocaeli Universitesi Bilgisayar Muhendisligi Ileri Bilgisayar Grafikleri.
Advertisements

Images Images are a key component of any multimedia presentation.
Lecture 2 Concepts, Terms and Definitions. Display Devices They are divided into a lot of small squares called pixels (“PICture ELements”). Each pixel.
CS 450: COMPUTER GRAPHICS LINEAR ALGEBRA REVIEW SPRING 2015 DR. MICHAEL J. REALE.
Image Data Representations and Standards
Prof. Harriet Fell Fall 2012 Lecture 7 – September 19, 2012
Output Primitives Computer Graphics.
Course Website: Computer Graphics 5: Line Drawing Algorithms.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphicsIntroduction Dr. Eng. Farag Elnagahy
Images: Pixels and Resolution Monica A. Stoica, Boston University Books used: “The Essential Guide to Computing” by E. Garrison Walters.
Introduction to Computer Graphics
Vector vs. Bitmap SciVis V
How Images are Represented Bitmap images (Dots used to draw the image) Monochrome images 8 bit grey scale images 24 bit colour Colour lookup tables Vector.
Raster vs Vector and Image Resolution By Josh Gallagan.
IE433 CAD/CAM Computer Aided Design and Computer Aided Manufacturing Part-2 CAD Systems Industrial Engineering Department King Saud University.
CS 1308 Computer Literacy and the Internet. Creating Digital Pictures  A traditional photograph is an analog representation of an image.  Digitizing.
COMP Bitmapped and Vector Graphics Pages Using Qwizdom.
CGMB214: Introduction to Computer Graphics
1/1/20001 Topic >>>> Scan Conversion CSE Computer Graphics.
College of Computer and Information Science, Northeastern UniversitySeptember 12, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture.
1 CPE 333 : Computer Graphics มหาวิทยาลัยเทคโนโลยีพระจอม เกล้าธนบุรี Dr. Natasha Dejdumrong.
WHERE TO DRAW A LINE?? Line drawing is accomplished by calculating intermediate positions along the line path between specified end points. Precise definition.
CSCI-235 Micro-Computers in Science Hardware Part II.
Lecture No. 3.  Screen resolution  Color  Blank space between the pixels  Intentional image degradation  Brightness  Contrast  Refresh rate  Sensitivity.
Vector vs. Bitmap
Chapter 2 Getting Started: Drawing Figures. The Framebuffer Lecture 2 Fri, Aug 29, 2003.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 14 Introduction to Computer Graphics.
Bitmap Vs. Vector Graphics. To create effective artwork, you need to understand some basic concepts about vector graphics versus bitmap images, resolution,
Computer Graphics Raster Devices Transformations Areg Sarkissian.
Objectives Differentiate between raster scan display and random scan display.
College of Computer and Information Science, Northeastern UniversityOctober 12, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2006.
Chapter 2 : Imaging and Image Representation Computer Vision Lab. Chonbuk National University.
Character Generation.
CGMB214: Introduction to Computer Graphics
INT 840E Computer graphics Introduction & Graphic’s Architecture.
CS- 375 Graphics and Human Computer Interaction Lecture 1: 12/4/1435 Fundamental Techniques in Graphics Lecturer: Kawther Abas.
College of Computer and Information Science, Northeastern UniversityOctober 31, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2009.
Introduction to Graphical Hardware Display Technologies
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
 Video Display Devices Video Display Devices  Cathode-ray tube (CRT) Monitors Cathode-ray tube (CRT) Monitors  Display Technologies Display Technologies.
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.
Data Representation The storage of Text Numbers Graphics.
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.
Computer Graphics, KKU. Lecture 41 The Computer Programming Laws Any given program, when running, is obsolete. Any given program costs more and.
Data Representation. What is data? Data is information that has been translated into a form that is more convenient to process As information take different.
CS 325 Introduction to Computer Graphics 02 / 03 / 2010 Instructor: Michael Eckmann.
GEOMETRY AND LINE GENERATION Geometry and Line Generation Chapter 2.
1. Cathode Ray Tubes (CRTs) TVs, RGB monitors, o-scopes Flat-Panel Displays PDAs, laptops, calculators, digital watches 2.
Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan.
©College of Computer and Information Science, Northeastern UniversityFebruary 21, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture.
Graphics and Image Data Representations 1. Q1 How images are represented in a computer system? 2.
OUTPUT PRIMITIVES A.Aruna/Faculty of Information technology/SNSCE13/19/2016.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
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.
Rasterization, or “What is glBegin(GL_LINES) really doing?” Course web page: February 23, 2012  Lecture 4.
Objectives Understand Bresenhams line drawing algorithm. Apply the algorithm to plot a line with the end points specified.
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.
Line Drawing Algorithms
Computer Graphics Lecture 3 Computer Graphics Hardware
Binary Notation and Intro to Computer Graphics
CS G140 Graduate Computer Graphics
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Prof. Harriet Fell Spring 2007 Lecture 5 – January 17, 2006
Microprocessor and Assembly Language
Computer Graphics 5: Line Drawing Algorithms
Computer Graphics 5: Line Drawing Algorithms
Computer Graphics 5: Line Drawing Algorithms
Multimedia System Image
Presentation transcript:

College of Computer and Information Science, Northeastern UniversityOctober 17, CS 4300 Computer Graphics Prof. Harriet Fell Fall 2011 Lecture 5 – September 15, 2011

College of Computer and Information Science, Northeastern UniversityOctober 17, Today’s Topics Vectors – review Shirley et al. 2.4 Rasters Shirley et al Rasterizing Lines Shirley et al Implicit 2D lines pp Parametric Lines p. 41  Antialiasing  Line Attributes

College of Computer and Information Science, Northeastern UniversityOctober 17, Vectors A vector describes a length and a direction. a b a = b a zero length vector 1 a unit vector

College of Computer and Information Science, Northeastern UniversityOctober 17, Vector Operations a a b b b+a -d c-d Vector Sum a -a c Vector Difference d

College of Computer and Information Science, Northeastern UniversityOctober 17, Cartesian Coordinates Any two non-zero, non-parallel 2D vectors form a 2D basis. Any 2D vector can be written uniquely as a linear combination of two 2D basis vectors. x and y (or i and j) denote unit vectors parallel to the x-axis and y-axis. x and y form an orthonormal 2D basis. a = x a x + y a y a =( x a, y a ) or x, y and z form an orthonormal 3D basis. or a =(a x,a y )

College of Computer and Information Science, Northeastern UniversityOctober 17, Vector Length Vector a =( x a, y a ) yaya xaxa ||a|| a

College of Computer and Information Science, Northeastern UniversityOctober 17, Dot Product a =( x a, y a ) b =( x b, y b ) a  b = x a x b + y a y b a  b = || a ||  || b || cos(φ) a b φ θ x a = ||a||cos(θ+φ) x b = ||b||cos(θ) y a = ||a||sin(θ+φ) y b = ||b||sin(θ)

College of Computer and Information Science, Northeastern UniversityOctober 17, Projection a =( x a, y a ) b =( x b, y b ) a  b = ||a||  ||b||cos(φ) The length of the projection of a onto b is given by a b φ abab

College of Computer and Information Science, Northeastern University Output Devices a raster is a rectangular array of pixels (picture elements) common raster output devices include CRT and LCD monitors, ink jet and laser printers typically considered as top-to-bottom array of left-to-right rows, because that is how CRTs are (were) typically scanned for this reason, device (e.g. on-screen) coordinate frame typically has origin in upper left, axis aims to right, and axis aims down 10/17/20159

College of Computer and Information Science, Northeastern University Device Resolution (native) resolution of the device is the dimensions (note this is reverse of typical way we write matrix dimensions) of its raster output hardware typical resolutions for monitors are 640x480 (VGA, the archaic but celebrated Video Graphics Array), 800x600, 1024x768, 1280x1024, 1600x1200, etc higher resolution is generally “better” because finer detail can be represented  more computation required for more pixels though, and more pixels makes the display hardware more expensive  however monitors usually can display lower or higher (within some limits) resolution images than their native resolution by scaling (we will study how to scale images later in the course) 10/17/201510

College of Computer and Information Science, Northeastern University Sub-pixel Display 10/17/201511

College of Computer and Information Science, Northeastern University How are Rasters Represented? for a monochrome image, each pixel corresponds to one bit (also called a binary image) typically in graphics we use at least greyscale images, where bits are used to represent the intensity at each pixel. The number of gray levels at each pixel is usually a multiple of 8. for a color image, compose multiple greyscale images, where each corresponds to a different color component. Three images corresponding to red, green, and blue color components are one typical arrangement. The images can be stored as independent planes or they may be interleaved. 10/17/201512

College of Computer and Information Science, Northeastern University in-memory representation of a raster monochrome image is typically a linear array of r x c x B bytes, where r and c are the number of rows and columns in the raster, and B is the number of bytes per pixel value of pixel at location (i, j) is thus stored in the B bytes at memory location (ic + j)B relative to the beginning of the array  the order of bytes within the pixel value is determined by the byte order of the computer, which may be little-endian (least significant byte first) or big-endian (most significant byte first).  Nowadays, little-endian is more common (e.g. Intel x86). Big- endian may still be encountered on e.g. PowerPC architectures (which is what Apple used in Mac computers up to around 2006). 10/17/201513

College of Computer and Information Science, Northeastern University Color Image Representation for color images, either store as (typically three) separate monochrome rasters (planes), or interleave by packing all color components for a pixel into a contiguous block of memory (interleaved is more common now) the order of the color components, as well as the number of bits per component, is called the pixel format 10/17/201514

College of Computer and Information Science, Northeastern University Common Pixel Formats common pixel formats today include  24-bit RGB (b r = b g = b b = 8) (“over 16 million colors!”)  32-bit RGB (like 24 bit but with one byte of padding)  16-bit 5:6:5 RGB (b r = 5, b g =6, b b = 5) (human eye is most sensitive to green; common for lower-quality video because it looks ok for images of real-world scenes and uses 2 bytes per pixel, reducing file size) (ic + j)B works with  B = {(b r + b g + b b +padding)}/8 byte ordering (little- vs big-endian) only matters within each color component and if some b r > 8 10/17/201515

College of Computer and Information Science, Northeastern University Frame Buffer In-memory raster is called a frame buffer when hardware is set up so that changes to memory contents drive pixel colors on the display itself. Most modern display hardware has a such a frame buffer.  in fact, generally more than one, and can switch among them  a common way to produce a smooth-looking animation is to use two buffers: the front buffer is rendered to the screen, and the back buffer is not  this is called double buffering  Each new frame of the animation is drawn onto the back buffer. Because it can take some time (hopefully not too long) to draw, this avoids seeing a “partial frame”.  once the drawing is complete, the buffers are swapped 10/17/201516

College of Computer and Information Science, Northeastern University Rasterization how to render images of geometry, say line segments or triangles, onto a raster display? need to figure out what pixels to “light up” to draw the shape this is the process of rasterization will study line segment rasterization now and triangles later in the course 10/17/201517

College of Computer and Information Science, Northeastern University Vector Output historically, vector displays were developed first a CRT is made to scan line segments by steering an electron beam from start to end of each segment (can generalize to curves) potentially more efficient because only need to scan along the actual line segments vs always scanning a raster across the whole screen but hard to draw images of real-world scenes, and how to deal with color? nowadays, vector output is sometimes still encountered on a pen plotter, but even these are mostly antiques 10/17/201518

College of Computer and Information Science, Northeastern University Vector Representation some software systems represent graphics in a vector form. PostScript, PDF (portable document format), and SVG (scalable vector graphics) in a vector format, a picture is stored not as an array of pixels, but as a list of instructions about how to draw it  vector format is “better” for some kinds of images, particularly line drawings and images (e.g. cartoons or computer art) since the actual geometry, vs a sampling of it, is stored, vector images can generally be scaled to larger or smaller sizes without any loss of quality  vector images may also require less memory to store, and may be more compressible 10/17/201519

College of Computer and Information Science, Northeastern UniversityOctober 17, (3,1) (0,3) (0,0) Pixel Coordinates y x x = -0.5 y = -0.5 y = 3.5 x = 4.5

College of Computer and Information Science, Northeastern UniversityOctober 17, (3,2) (0,0) (0,3) Pixel Coordinates y x x = -0.5 y = 3.5 y = -.5 x = 4.5

College of Computer and Information Science, Northeastern UniversityOctober 17, What Makes a Good Line? Not too jaggy Uniform thickness along a line Uniform thickness of lines at different angles Symmetry, Line(P,Q) = Line(Q,P) A good line algorithm should be fast.

College of Computer and Information Science, Northeastern UniversityOctober 17, Line Drawing

College of Computer and Information Science, Northeastern UniversityOctober 17, Line Drawing

College of Computer and Information Science, Northeastern UniversityOctober 17, Which Pixels Should We Color? Given P 0 = (x 0, y 0 ), P 1 = (x 1, y 1 ) We could use the equation of the line:  y = mx + b  m = (y 1 – y 0 )/(x 1 – x 0 )  b = y 1 - mx 1 And a loop for x = x 0 to x 1 y = mx + b draw (x, y) This calls for real multiplication for each pixel This only works if x 0 <= x 1 and |m| <= 1.

College of Computer and Information Science, Northeastern UniversityOctober 17, Midpoint Algorithm Pitteway 1967 Van Aiken abd Nowak 1985 Draws the same pixels as Bresenham Algorithm Uses integer arithmetic and incremental computation. Uses a decision function to decide on the next point Draws the thinnest possible line from (x 0, y 0 ) to (x 1, y 1 ) that has no gaps. A diagonal connection between pixels is not a gap.

College of Computer and Information Science, Northeastern UniversityOctober 17, Implicit Equation of a Line (x 0, y 0 ) (x 1, y 1 )f(x,y) = (y 0 – y 1 )x +(x 1 - x 0 )y + x 0 y 1 - x 1 y 0 We will assume x 0 <= x 1 and that m = (y 1 – y 0 )/(x 1 - x 0 ) is in [0, 1]. f(x,y) = 0 f(x,y) > 0 f(x,y) < 0

College of Computer and Information Science, Northeastern UniversityOctober 17, Basic Form of the Algotithm y = y 0 for x = x 0 to x 1 do draw (x, y) if (some condition) then y = y + 1 Since m is in [0, 1], as we move from x to x+1, the y value stays the same or goes up by 1. We want to compute this condition efficiently.

College of Computer and Information Science, Northeastern UniversityOctober 17, Above or Below the Midpoint?

College of Computer and Information Science, Northeastern UniversityOctober 17, Finding the Next Pixel Assume we just drew (x, y). For the next pixel, we must decide between (x+1, y) and (x+1, y+1). The midpoint between the choices is (x+1, y+0.5). If the line passes below (x+1, y+0.5), we draw the bottom pixel. Otherwise, we draw the upper pixel.

College of Computer and Information Science, Northeastern UniversityOctober 17, The Decision Function if f(x+1, y+0.5) < 0 // midpoint below line y = y + 1 f(x,y) = (y 0 – y 1 )x +(x 1 - x 0 )y + x 0 y 1 - x 1 y 0 How do we compute f(x+1, y+0.5) incrementally? using only integer arithmetic?

College of Computer and Information Science, Northeastern UniversityOctober 17, Incremental Computation f(x,y) = (y 0 – y 1 )x +(x 1 - x 0 )y + x 0 y 1 - x 1 y 0 f(x + 1, y) = f(x, y) + (y 0 – y 1 ) f(x + 1, y + 1) = f(x, y) + (y 0 – y 1 ) + (x 1 - x 0 ) y = y 0 d = f(x 0 + 1, y + 0.5) for x = x 0 to x 1 do draw (x, y) if d < 0 then y = y + 1 d = d + (y 0 – y 1 ) + (x 1 - x 0 ) else d = d + (y 0 – y 1 )

College of Computer and Information Science, Northeastern UniversityOctober 17, Integer Decision Function f(x,y) = (y 0 – y 1 )x +(x 1 - x 0 )y + x 0 y 1 - x 1 y 0 f(x 0 + 1, y + 0.5) = (y 0 – y 1 )(x 0 + 1) +(x 1 - x 0 )(y + 0.5) + x 0 y 1 - x 1 y 0 2f(x 0 + 1, y + 0.5) = 2(y 0 – y 1 )(x 0 + 1) +(x 1 - x 0 )(2y + 1) + 2x 0 y 1 - 2x 1 y 0 2f(x, y)= 0 if (x, y) is on the line. < 0 if (x, y) is below the line. > 0 if (x, y) is above the line.

College of Computer and Information Science, Northeastern UniversityOctober 17, Midpoint Line Algorithm y = y 0 d = 2(y 0 – y 1 )(x 0 + 1) +(x 1 - x 0 )(2y 0 + 1) + 2x 0 y 1 - 2x 1 y 0 for x = x 0 to x 1 do draw (x, y) if d < 0 then y = y + 1 d = d + 2(y 0 – y 1 ) + 2(x 1 - x 0 ) else d = d + 2(y 0 – y 1 ) These are constants and can be computed before the loop.

College of Computer and Information Science, Northeastern University Line Attributes line width dash patterns end caps: butt, round, square 10/17/201535

College of Computer and Information Science, Northeastern University Joins: round, bevel, miter 10/17/201536

College of Computer and Information Science, Northeastern UniversityOctober 17, Some Lines

College of Computer and Information Science, Northeastern UniversityOctober 17, Some Lines Magnified

College of Computer and Information Science, Northeastern UniversityOctober 17, Antialiasing by Downsampling

College of Computer and Information Science, Northeastern UniversityOctober 17, Antialiasing by Downsampling

College of Computer and Information Science, Northeastern UniversityOctober 17, Antialiasing by Downsampling