Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 21 Today’s class Graphics programming Color.

Slides:



Advertisements
Similar presentations
2IV60 Computer graphics Graphics primitives and attributes Jack van Wijk TU/e.
Advertisements

Light Light is fundamental for color vision Unless there is a source of light, there is nothing to see! What do we see? We do not see objects, but the.
W14D1. Multimedia Representation of colour (photos, videos) Representation of sound. Comp.Sci. questions: what is colour? how can computers capture &
School of Computing Science Simon Fraser University
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
© 2002 by Yu Hen Hu 1 ECE533 Digital Image Processing Color Imaging.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
Color.
1 Lecture 6 Attributes of graphical primitives Colors Colors in OpenGL Algorithms for scan-conversion.
Display Issues Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
OpenGL and WebGL Drawing Functions CSCI 440 Day Five.
CSC 461: Lecture 6 1 CSC461 Lecture 6: 2D Programming in OpenGL Objectives:  Fundamental OpenGL primitives  Attributes  Viewport.
1 CSCE441: Computer Graphics: Color Models Jinxiang Chai.
Color Models AM Radio FM Radio + TV Microwave Infrared Ultraviolet Visible.
Colour Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 6 This presentation © 2004, MacAvon Media Productions Colour.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
CS 376 Introduction to Computer Graphics 01 / 26 / 2007 Instructor: Michael Eckmann.
2001 by Jim X. Chen: 1 The purpose of a color model is to allow convenient specification of colors within some color gamut.
Image Processing Lecture 2 - Gaurav Gupta - Shobhit Niranjan.
Computer Graphics I, Fall 2008 Image Formation.
1 Image Formation. 2 Objectives Fundamental imaging notions Physical basis for image formation ­Light ­Color ­Perception Synthetic camera model Other.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
Color Theory What is color? How do we describe and match colors? Color spaces.
Chapter 6: Color Image Processing Digital Image Processing.
Human Eye and Color Rays of light enter the pupil and strike the back of the eye (retina) – signals go to the optic nerve and eventually to the brain Retina.
COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS Light and Color Graphics Systems / Computer.
I-1 Steps of Image Generation –Create a model of the objects –Create a model for the illumination of the objects –Create an image (render) the result I.
Topic 5 - Imaging Mapping - II DIGITAL IMAGE PROCESSING Course 3624 Department of Physics and Astronomy Professor Bob Warwick.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
Color. Contents Light and color The visible light spectrum Primary and secondary colors Color spaces –RGB, CMY, YIQ, HLS, CIE –CIE XYZ, CIE xyY and CIE.
Week 6 Colour. 2 Overview By the end of this lecture you will be familiar with: –Human visual system –Foundations of light and colour –HSV and user-oriented.
Color Theory ‣ What is color? ‣ How do we perceive it? ‣ How do we describe and match colors? ‣ Color spaces.
1. OpenGL/GLU/GLUT  OpenGL v4.0 (latest) is the “core” library that is platform independent  GLUT v3.7 is an auxiliary library that handles window creation,
INT 840E Computer graphics Introduction & Graphic’s Architecture.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Computer Graphics Bing-Yu Chen National Taiwan University.
Lecture 2: Some definitions of terms 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Graphics Lecture 4: Slide 1 Interactive Computer Graphics Lecture 4: Colour.
A color model is a specification of a 3D color co-ordinate system and a visible subset in the co-ordinate System within all colors in a particular color.
DIGITAL IMAGE. Basic Image Concepts An image is a spatial representation of an object An image can be thought of as a function with resulting values of.
CS654: Digital Image Analysis Lecture 29: Color Image Processing.
1 CSCE441: Computer Graphics: Color Models Jinxiang Chai.
Introduction to Computer Graphics
Color Models. Color models,cont’d Different meanings of color: painting wavelength of visible light human eye perception.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 CSCE441: Computer Graphics: Color Models Jinxiang Chai.
Color and Color for the Web First, discuss idea of color (some overlap with lecture on HVS) First, discuss idea of color (some overlap with lecture on.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Chapter 4 -- Color1 Color Open GL Chapter 4. Chapter 4 -- Color2 n The goal of almost all OpenGL applications is to draw color pictures in a window on.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 4: Color and Attributes Isaac Gang University.
Image credit: Wikipedia (Fovea) Human Eye Some interesting facts – Rod cells: requires only low light b/w vision blur, all over retina EXCEPT fovea – Cone.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
Computer Graphics: Achromatic and Coloured Light.
1 of 32 Computer Graphics Color. 2 of 32 Basics Of Color elements of color:
CSC Graphics Programming
Programming with OpenGL Part 2: Complete Programs
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Computer Vision Lecture 4: Color
Programming with OpenGL Part 4: Color and Attributes
Slides taken from Scott Schaefer
Programming with OpenGL Part 2: Complete Programs
Color Models l Ultraviolet Infrared 10 Microwave 10
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 4: Color and Attributes
Primitive Drawing Algorithm
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 21 Today’s class Graphics programming Color

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 22 testline.c Example program testline.c shows the general structure of an OpenGL program Note the use of a callback function for the display

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 23 Overview of image generation Scene – collection of objects in space Viewer – forms image from objects Light – illuminates the objects and helps visualize their textures All of these need to be modeled to generate an appropriate image

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 24 Coordinate systems World coordinates - the application’s coordinate system Device coordinates - the graphics device coordinate system, usually first quadrant Normalized device coordinates - (0, 0)  (x, y)  (1, 1)

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 25 Output primitives The basic building blocks of graphics images:  points  lines  polygons  circles  character strings

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 26 Attributes Properties of output primitives:  intensity  color  line style  text style  area-filling patterns

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 27 OpenGL geometry Specified by edges and vertices Vertices  a sequence or array of coordinates  specified with 2, 3, or 4 (homogeneous) coordinates in short, int, float, or double types  routines are glVertex{234}{sifd}[v]() Edges are determined by the order the vertices are entered

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 28 OpenGL geometry (cont.) Vertices are specified between glBegin() and glEnd() Parameter to glBegin() describes type of geometry:  GL_POINTS - a disconnected set of points  GL_LINES - n/2 line segments  GL_LINE_STRIP - n-1 line segments connected end to end  GL_LINE_LOOP - n line segments connected end to end and last to first

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 29 OpenGL geometry (cont.) More parameters to glBegin() :  GL_TRIANGLES - n/3 triangles  GL_TRIANGLE_STRIP - n-2 triangles  for even i (0, 2, 4, …) vertices i, i+1, i+2 define the triangle  for odd i (1, 3, 5, …) vertices i+1, i, i+2 define the triangle  GL_TRIANGLE_FAN - n-2 triangles  vertices 0, i+1, i+2 define the triangles

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 210 OpenGL geometry (cont.) More parameters to glBegin() :  GL_QUADS - n/4 quadrilaterals  GL_QUAD_STRIP - n/2-1 quadrilaterals  vertices 2i, 2i+1, 2i+3, 2i+2 define the quadrilateral  GL_POLYGON - a single convex polygon

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 211 Example program Program brownian.c is an example of OpenGL and GLUT

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 212 In class exercise The picture below shows the first step in generating the Koch curve, a famous fractal Write an OpenGL code fragment to draw the image on the right

Color

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 214 Color characterization Colors are combinations of wavelengths of light Characterized by a function, C( ), which represents the strength of each wavelength of visible light present in the color To accurately produce a color on the CRT would require representation of each wavelength present in the color Impossible to do, and really does not represent how our eyes perceive color

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 215 Cones Color receptors in our eyes are called cones Come in three types Each type has its own sensitivity curve, which represents how sensitive it is to the different wavelengths of light

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 216 Tristimulus values When cone i is exposed to a color distribution C( ) it sends the brain a “number” which represents the total response of that cone to the color: Thus, there are 3 numbers (one for each cone) that are sent to the brain to represent a color These are known as the tristimulus values The brain sums these numbers

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 217 CRT color model Applying the tristimulus approach to a CRT we have 3 color guns (R, G, B) Each gun’s intensity is weighted by the appropriate tristimulus value to produce an overall color Note that this is an additive system

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 218 RGB color model Most common Defined on a unit cube Black at (0, 0, 0), white at (1, 1, 1) Diagonally opposite colors are complementary (two colors added together give white; e.g. yellow (1,1,0) + blue (0,0,1)) (R,G,B) = (1,1,1) - (C,M,Y)

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 219 Color in OpenGL Two models  RGBA  A indicates opacity a value of 1.0 indicates an opaque color a value of 0.0 indicates a transparent color  RGB is the same as RGBA with A set to 1.0  This is the internal form used in OpenGL’s state  Color index  An index into a table of RGB values  Requires interaction with the windowing system

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 220 Color on paper For printing on paper, a complementary approach is needed since you start with white paper (the presence of all color) A subtractive system is needed, such that when you place all 3 primary colors down you get black The standard subtractive system is CMY (cyan, magenta, yellow)

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 221 HLS A distortion of the RGB cube A double cone Hue is location of the dominant wavelength in the color (measured as angle from 0° (red) Lightness is measured from 0 to 1 vertically Saturation is the radial distance from the lightness axis, also 0 to 1

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 222 Color angles Red = 0° Yellow = 60° Green = 120° Cyan = 180° Blue = 240° Magenta = 300°

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 223 HSV A single cone Hue and saturation the same as HLS Value is captured in the vertical axis, also on a 0 to 1 scale

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 224 HSV to RGB conversion If H = 360 then H = 0 H = H / 60 I = floor (H) F = H - I P1 = V * (1 - S) P2 = V * (1 - S * F) P3 = V * (1 - (S * (1 - F))) Case I of  0: R = V; G = P3; B = P1  1: R = P2; G = V; B = P1  2: R = P1; G = V; B = P3  3: R = P1; G = P2; B = V  4: R = P3; G = P1; B = V  5: R = V; G = P1; B = P2

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 225 Programming the color lookup table In OpenGL a float is used for the red, green, and blue components One approach is to equally space the colors at some fixed L and S on the HLS model Another approach is to determine the range of red, green, and blue in the image and quantize on three axes

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 226 Index color mode GLUT_INDEX is used for the display mode glutSetColor(index, r, g, b) enters a color map entry glIndexi(index) chooses a color map entry for the current color glClearIndex(index) sets the clear color for a window in index mode

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 227 Default colors 0 = black 1 = red 2 = green 3 = yellow 4 = blue 5 = magenta 6 = cyan 7 = white

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 228 Color index mode on PCs 8 bit planes 256 entries in color index Need to be in 256-color mode Avoid setting colors 0-7

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 229 Unix machines SGI machines  12 bit planes  avoid setting colors Sun workstations  8 bit planes  no default colors

Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 230 Example program Program colorMap.cpp shows using the color map and indexed color A large list of colors and their RGB values has been posted on the Example Programs page of the course website