Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CS559: Computer Graphics Lecture 5: Color and Edge Li Zhang Spring 2008 Most Slides from Stephen Chenney."— Presentation transcript:

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

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

3 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

4 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

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

6 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

7 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

8 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

9 Color Vision Three kinds of cones:

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

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

12 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 …

13 9/14/04© University of Wisconsin, CS559 Spring 2004 Trichromacy means… 400500600700 400500600700 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

14 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. 400500600700 Spectrum 400500600700 3 primaries

15 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

16 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 400500600700 3 Primaries 400500600 700 3 Primaries or

17 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

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

19 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

20 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

21 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

22 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

23 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

24 Other Color Space Hue-Saturation-Value (HSV) [Alvy Smith, 1978] – Hue: dominant color component – Saturation: color purity – Value: lightness or brightness HSV-RGB transformation http://alvyray.com/Papers/hsv2rgb.htm http://www.mandelbrot-dazibao.com/HSV/HSV.htm

25 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) http://en.wikipedia.org/wiki/Lab_color_space http://en.wikipedia.org/wiki/CIE_1931_color_space

26 Spatial resolution and color R G B original

27 Blurring the G component R G B original processed

28 Blurring the R component original processed R G B

29 Blurring the B component original R G B processed

30 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

31 L a b original processed Bluring L

32 original L a b processed Bluring a

33 original L a b processed Bluring b

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

35 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

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

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

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

39 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

40 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

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

42 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

43 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?

44 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!

45 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!

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

47 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

48 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)

49 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?

50 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

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

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

53 10/5/04© University of Wisconsin, CS559 Fall 2004 3D 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

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

55 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

56 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

57 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

58 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

59 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

60 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)

61 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

62 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

63 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


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

Similar presentations


Ads by Google