CS559: Computer Graphics Lecture 5: Color and Edge Li Zhang Spring 2008 Most Slides from Stephen Chenney.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Color & Light, Digitalization, Storage. Vision Rods work at low light levels and do not see color –That is, their response depends only on how many photons,
Color Image Processing
Informationsteknologi Monday, October 29, 2007Computer Graphics - Class 21 Today’s class Graphics programming Color.
School of Computing Science Simon Fraser University
CS248 Midterm Review. CS248 Midterm Mon, November 4, 7-9 pm, Terman Aud Mostly “short answer” questions – Keep your answers short and sweet! Covers lectures.
CS248 Midterm Review. CS248 Midterm Mon, November 3, 7-9 pm, Gates B01 Mostly “short answer” questions – Keep your answers short and sweet! Covers lectures.
What is color for?.
Computer Graphics (Fall 2004) COMS 4160, Lecture 3: Transformations 1
CS248 Midterm Review. CS248 Midterm Mon, November 5, 7-9 pm, Terman Aud Mon, November 5, 3-5 pm, Gates 392 Mostly “short answer” questions Covers through.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
CS 450: Computer Graphics 2D TRANSFORMATIONS
1/22/04© University of Wisconsin, CS559 Spring 2004 Last Time Course introduction Image basics.
CS559-Computer Graphics Copyright Stephen Chenney Color Recap The physical description of color is as a spectrum: the intensity of light at each wavelength.
Why Care About Color? Accurate color reproduction is commercially valuable - e.g. Kodak yellow, painting a house Color reproduction problems increased.
10/5/04© University of Wisconsin, CS559 Fall 2004 Last Time Compositing Painterly Rendering Intro to 3D Graphics Homework 3 due Oct 12 in class.
9/14/04© University of Wisconsin, CS559 Spring 2004 Last Time Intensity perception – the importance of ratios Dynamic Range – what it means and some of.
Colour Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman
Digital Image Processing Colour Image Processing.
CS 376 Introduction to Computer Graphics 01 / 26 / 2007 Instructor: Michael Eckmann.
09/05/02© University of Wisconsin, CS559 Spring 2002 Last Time Course introduction Assignment 1 (not graded, but necessary) –View is part of Project 1.
10/13/200© NTUST Last Time Compositing Painterly Rendering Intro to 3D Graphics Homework 2, 3 due Oct 13 in class.
CS559-Computer Graphics Copyright Stephen Chenney 2001 The Human Eye Graphics is concerned with the visual transmission of information How do we see? –Light.
Any questions about the current assignment? (I’ll do my best to help!)
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
9/9/04© University of Wisconsin, CS559 Spring 2004 Last Time Course introduction Digital Images –The difference between an image and a display –Ways to.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
10/3/02 (c) 2002 University of Wisconsin, CS 559 Last Time 2D Coordinate systems and transformations.
CSC361/ Digital Media Burg/Wong
CHAPTER 8 Color and Texture Mapping © 2008 Cengage Learning EMEA.
CS559: Computer Graphics Lecture 8: 3D Transforms Li Zhang Spring 2008 Most Slides from Stephen Chenney.
Graphics Lecture 4: Slide 1 Interactive Computer Graphics Lecture 4: Colour.
CS559: Computer Graphics Lecture 8: Warping, Morphing, 3D Transformation Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
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.
2/17/04© University of Wisconsin, CS559 Spring 2004 Last Time Resampling –Ideal reconstruction –You can only ideally reconstruct band-limited functions.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
Introduction to Computer Graphics
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
In the name of God Computer Graphics.
2/19/04© University of Wisconsin, CS559 Spring 2004 Last Time Painterly rendering 2D Transformations –Transformations as coordinate system changes –Transformations.
CS559: Computer Graphics Lecture 8: Dynamic Range and Trichromacy Li Zhang Spring 2008 Most Slides from Stephen Chenney.
Computer Graphics Matrices
3D Coordinate Systems o3D computer graphics involves the additional dimension of depth, allowing more realistic representations of 3D objects in the real.
Intelligent Robotics Today: Vision & Time & Space Complexity.
David Luebke2/23/2016 CS 551 / 645: Introductory Computer Graphics Color Continued Clipping in 3D.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
09/10/02(c) University of Wisconsin, CS559 Fall 2002 Last Time Digital Images –Spatial and Color resolution Color –The physics of color.
1 of 32 Computer Graphics Color. 2 of 32 Basics Of Color elements of color:
CSE 185 Introduction to Computer Vision
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Half Toning Dithering RGB CMYK Models
Color Image Processing
Color Image Processing
(c) University of Wisconsin, CS559 Spring 2002
© University of Wisconsin, CS559 Spring 2002
Chapter 6: Color Image Processing
Color Image Processing
3D Transformations Source & Courtesy: University of Wisconsin,
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
© University of Wisconsin, CS559 Spring 2004
Lecture 8: Dynamic Range and Trichromacy Li Zhang Spring 2008
Computer Vision Lecture 4: Color
Color Image Processing
(c) 2002 University of Wisconsin, CS 559
(c) University of Wisconsin, CS559
Color Image Processing
Lecture 8: 3D Transforms Li Zhang Spring 2008
Presentation transcript:

CS559: Computer Graphics Lecture 5: Color and Edge Li Zhang Spring 2008 Most Slides from Stephen Chenney

Today Trichromacy: Is RGB 3 bands enough? Dynamic Range: Is 8 bits per channel enough? Reading:

9/9/04© University of Wisconsin, CS559 Spring 2004 Dynamic Range Image depth refers to the number of bits available, but not how those bits map onto intensities We can use those bits to represent a large range at low resolution, or a small range at high resolution Common display devices can only show a limited dynamic range, so typically we fix the range at that of the display device and choose high resolution All possible intensities Low range, high res High range, low res

More Dynamic Range Real scenes have very high and very low intensities Humans can see contrast at very low and very high light levels – Can’t see all levels all the time – use adaptation to adjust – Still, high range even at one adaptation level Film has low dynamic range ~ 100:1 Monitors are even worse Many ways to deal with the problem – Will discuss later if we have time

More Dynamic Range Tone mapping – using a small number of bits (8) to represent high dynamic range scene. Tone mapping Linear Mapping

Intensity Perception Humans are actually tuned to the ratio of intensities, not their absolute difference – So going from a 50 to 100 Watt light bulb looks the same as going from 100 to 200 – So, if we only have 4 intensities, between 0 and 1, we should choose to use 0, 0.25, 0.5 and 1 Ignoring this results in poorer perceptible intensity resolution at low light levels, and better resolution at high light levels – It would use 0, 0.33, 0.66, and 1

Display on a Monitor When images are created, a linear mapping between pixels and intensity is assumed – For example, if you double the pixel value, the displayed intensity should double Monitors, however, do not work that way – For analog monitors, the pixel value is converted to a voltage – The voltage is used to control the intensity of the monitor pixels – But the voltage to display intensity is not linear – Similar problem with other monitors, different causes The outcome: A linear intensity scale in memory does not look linear on a monitor Even worse, different monitors do different things

Gamma Control The mapping from voltage to display is usually an exponential function: To correct the problem, we pass the pixel values through a gamma function before converting them to the monitor This process is called gamma correction The parameter, , is controlled by the user – It should be matched to a particular monitor – Typical values are between 2.2 and 2.5 The mapping can be done in hardware or software

Color Vision Three kinds of cones:

Qualitative Response Sensitivity,  #photons, E Red Multiply EE Area under curve? Big response!

9/14/04© University of Wisconsin, CS559 Spring 2004 Qualitative Response 700 Multiply EE Area under curve? Tiny response! Sensitivity,  #photons, E Blue

9/14/04© University of Wisconsin, CS559 Spring 2004 Recall We’re working toward a representation for digital color We have seen that humans have three sensors for color vision Now, the implications …

9/14/04© University of Wisconsin, CS559 Spring 2004 Trichromacy means… Spectrum 3 Primaries Color Matching: People think these two spectra look the same (monomers) Representing color: If you want people to “see” the continuous spectrum, you can just show the three primaries

Trichromacy For almost any given E_target(λ), we can solve for [r,g,b] so that the displayed color looks indistinguishable from the target color to our eyes Spectrum primaries

9/14/04© University of Wisconsin, CS559 Spring 2004 The Math of Trichromacy Write primaries as R, G and B – We won’t precisely define them yet Many colors can be represented as a mixture of R, G, B: M=rR + gG + bB (Additive matching) Gives a color description system - two people who agree on R, G, B need only supply (r, g, b) to describe a color Some colors can’t be matched like this, instead, write: M+rR=gG+bB (Subtractive matching) – Interpret this as (-r, g, b) – Problem for reproducing colors – you can’t subtract light using a monitor, or add it using ink

9/14/04© University of Wisconsin, CS559 Spring 2004 Primaries are Spectra Too A primary can be a spectrum – Single wavelengths are just a special case Primaries Primaries or

9/14/04© University of Wisconsin, CS559 Spring 2004 Color Matching Given a spectrum, how do we determine how much each of R, G and B to use to match it? First step: – For a light of unit intensity at each wavelength, ask people to match it using some combination of R, G and B primaries – Gives you, r( ), g( ) and b( ), the amount of each primary used for wavelength – Defined for all visible wavelengths, r( ), g( ) and b( ) are the RGB color matching functions

9/14/04© University of Wisconsin, CS559 Spring 2004 The RGB Color Matching Functions

9/14/04© University of Wisconsin, CS559 Spring 2004 Computing the Matching Given a spectrum, how do we determine how much each of R, G and B to use to match it? The spectrum function that we are trying to match, E( ), gives the amount of energy at each wavelength The RGB matching functions describe how much of each primary is needed to give one energy unit’s worth of response at each wavelength

9/14/04© University of Wisconsin, CS559 Spring 2004 Color Spaces The principle of trichromacy means that the colors displayable are all the linear combination of primaries Taking linear combinations of R, G and B defines the RGB color space – the range of perceptible colors generated by adding some part each of R, G and B If R, G and B correspond to a monitor’s phosphors (monitor RGB), then the space is the range of colors displayable on the monitor

RGB Cube Black (0,0,0) Red (1,0,0) Green(0,1,0) Blue (0,0,1) Magenta (0,1,1) White(1,1,1) Yellow (1,1,0) Cyan (0,1,1) Demo

9/14/04© University of Wisconsin, CS559 Spring 2004 Problems with RGB Can only a small range of all the colors humans are capable of perceiving (particularly for monitor RGB) – Have you ever seen magenta on a monitor? It isn’t easy for humans to say how much of RGB to use to make a given color – How much R, G and B is there in “brown”? (Answer:.64,.16,.16) Perceptually non-linear – Two points a certain distance apart in one part of the space may be perceptually different – Two other points, the same distance apart in another part of the space, may be perceptually the same

9/14/04© University of Wisconsin, CS559 Spring 2004 HSV Color Space (Alvy Ray Smith, 1978) Hue: the color family: red, yellow, blue… Saturation: The purity of a color: white is totally unsaturated Value: The intensity of a color: white is intense, black isn’t Space looks like a cone – Parts of the cone can be mapped to RGB space Not a linear space, so no linear transform to take RGB to HSV – But there is an algorithmic transform

Other Color Space Hue-Saturation-Value (HSV) [Alvy Smith, 1978] – Hue: dominant color component – Saturation: color purity – Value: lightness or brightness HSV-RGB transformation

Other Color Space L-A-B – L: luminance – A: position between magenta and green (negative values indicate green while positive values indicate magenta) – B: position between yellow and blue (negative values indicate blue and positive values indicate yellow)

Spatial resolution and color R G B original

Blurring the G component R G B original processed

Blurring the R component original processed R G B

Blurring the B component original R G B processed

L a b A rotation of the color coordinates into directions that are more perceptually meaningful: L: luminance, a: magenta-green, b: blue-yellow Lab Color Component

L a b original processed Bluring L

original L a b processed Bluring a

original L a b processed Bluring b

Application to image compression (compression is about hiding differences from the true image where you can’t see them).

9/30/04© University of Wisconsin, CS559 Fall 2004 Where to now… We are now done with images We will spend several weeks on the mechanics of 3D graphics – Coordinate systems and Viewing – Clipping – Drawing lines and polygons – Lighting and shading We will finish the semester with modeling and some additional topics

Recall: All 2D Linear Transformations Linear transformations are combinations of … – Scale, – Rotation, – Shear, and – Mirror

2D Rotation Rotate counter-clockwise about the origin by an angle  x y x y 

Rotating About An Arbitrary Point What happens when you apply a rotation transformation to an object that is not at the origin? x y ?

Rotating About An Arbitrary Point What happens when you apply a rotation transformation to an object that is not at the origin? – It translates as well x y x

10/5/04© University of Wisconsin, CS559 Fall 2004 How Do We Fix it? How do we rotate an about an arbitrary point? – Hint: we know how to rotate about the origin of a coordinate system

10/5/04© University of Wisconsin, CS559 Fall 2004 Rotating About An Arbitrary Point x y x y x y x y

10/5/04© University of Wisconsin, CS559 Fall 2004 Rotate About Arbitrary Point Say you wish to rotate about the point (a,b) You know how to rotate about (0,0) Translate so that (a,b) is at (0,0) – x’=x–a, y’=y–b Rotate – x”=(x-a)cos  -(y-b)sin , y”=(x-a)sin  +(y-b)cos  Translate back again – x f =x”+a, y f =y”+b

10/5/04© University of Wisconsin, CS559 Fall 2004 Scaling an Object not at the Origin What happens if you apply the scaling transformation to an object not at the origin? Based on the rotating about a point composition, what should you do to resize an object about its own center?

10/5/04© University of Wisconsin, CS559 Fall 2004 Back to Rotation About a Pt Say R is the rotation matrix to apply, and p is the point about which to rotate Translation to Origin: Rotation: Translate back: The translation component of the composite transformation involves the rotation matrix. What a mess!

10/5/04© University of Wisconsin, CS559 Fall 2004 Homogeneous Coordinates Use three numbers to represent a point (x,y)=(wx,wy,w) for any constant w  0 – Typically, (x,y) becomes (x,y,1) – To go backwards, divide by w Translation can now be done with matrix multiplication!

10/5/04© University of Wisconsin, CS559 Fall 2004 Basic Transformations Translation: Rotation: Scaling:

10/5/04© University of Wisconsin, CS559 Fall 2004 Homogeneous Transform Advantages Unified view of transformation as matrix multiplication – Easier in hardware and software To compose transformations, simply multiply matrices – Order matters: AB is generally not the same as BA Allows for non-affine transformations: – Perspective projections! – Bends, tapers, many others

10/5/04© University of Wisconsin, CS559 Fall 2004 Directions vs. Points We have been talking about transforming points Directions are also important in graphics – Viewing directions – Normal vectors – Ray directions Directions are represented by vectors, like points, and can be transformed, but not like points (1,1) (-2,-1)

10/5/04© University of Wisconsin, CS559 Fall 2004 Transforming Directions Say I define a direction as the difference of two points: d=a–b – This represents the direction of the line between two points Now I translate the points by the same amount: a’=a+t, b’=b+t How should I transform d?

Homogeneous Directions Translation does not affect directions! Homogeneous coordinates give us a very clean way of handling this The direction (x,y) becomes the homogeneous direction (x,y,0) The correct thing happens for rotation and scaling also – Scaling changes the length of the vector, but not the direction – Normal vectors are slightly different – we’ll see more later

3D Transformations Homogeneous coordinates: (x,y,z)=(wx,wy,wz,w) Transformations are now represented as 4x4 matrices

10/5/04© University of Wisconsin, CS559 Fall D Translation

10/5/04© University of Wisconsin, CS559 Fall D Rotation Rotation in 3D is about an axis in 3D space passing through the origin Using a matrix representation, any matrix with an orthonormal top-left 3x3 sub-matrix is a rotation – Rows are mutually orthogonal (0 dot product) – Determinant is 1 – Implies columns are also orthogonal, and that the transpose is equal to the inverse

10/5/04© University of Wisconsin, CS559 Fall D Rotation

10/5/04© University of Wisconsin, CS559 Fall 2004 Problems with Rotation Matrices Specifying a rotation really only requires 3 numbers – Axis is a unit vector, so requires 2 numbers – Angle to rotate is third number Rotation matrix has a large amount of redundancy – Orthonormal constraints reduce degrees of freedom back down to 3 – Keeping a matrix orthonormal is difficult when transformations are combined Rotations are a very complex subject, and a detailed discussion is way beyond the scope of this course

10/5/04© University of Wisconsin, CS559 Fall 2004 Alternative Representations Specify the axis and the angle (OpenGL method) – Hard to compose multiple rotations Euler angles: Specify how much to rotate about X, then how much about Y, then how much about Z – Hard to think about, and hard to compose – Any three axes will do e.g. X,Y,X Specify the axis, scaled by the angle – Only 3 numbers, called the exponential map Quaternions

4-vector related to axis and angle, unit magnitude – Rotation about axis (n x,n y,n z ) by angle  : Reasonably easy to compose Reasonably easy to go to/from rotation matrix Only normalized quaternions represent rotations, but you can normalize them just like vectors, so it isn’t a problem Easy to perform spherical interpolation

10/5/04© University of Wisconsin, CS559 Fall 2004 Other Rotation Issues Rotation is about an axis at the origin – For rotation about an arbitrary axis, use the same trick as in 2D: Translate the axis to the origin, rotate, and translate back again Rotation is not commutative – Rotation order matters – Experiment to convince yourself of this

10/5/04© University of Wisconsin, CS559 Fall 2004 Transformation Leftovers Scale, shear etc extend naturally from 2D to 3D Rotation and Translation are the rigid-body transformations: – Do not change lengths or angles, so a body does not deform when transformed

10/5/04© University of Wisconsin, CS559 Fall 2004 Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded by line segments – Any face can be triangulated (broken into triangles)

10/5/04© University of Wisconsin, CS559 Fall 2004 Modeling and OpenGL In OpenGL, all geometry is specified by stating which type of object and then giving the vertices that define it glBegin(…) …glEnd() glVertex[34][fdv] – Three or four components (regular or homogeneous) – Float, double or vector (eg float[3]) Chapter 2 of the red book

10/5/04© University of Wisconsin, CS559 Fall 2004 Rendering Generate an image showing the contents of some region of space – The region is called the view volume, and it is defined by the user Determine where each object should go in the image – Viewing, Projection Determine which pixels should be filled – Rasterization Determine which object is in front at each pixel – Hidden surface elimination, Hidden surface removal, Visibility Determine what color it is – Lighting, Shading

10/5/04© University of Wisconsin, CS559 Fall 2004 Graphics Pipeline Graphics hardware employs a sequence of coordinate systems – The location of the geometry is expressed in each coordinate system in turn, and modified along the way – The movement of geometry through these spaces is considered a pipeline Local Coordinat e Space World Coordinate Space View Space Canonica l View Volume Displa y Space