Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 8: Dynamic Range and Trichromacy Li Zhang Spring 2008

Similar presentations


Presentation on theme: "Lecture 8: Dynamic Range and Trichromacy Li Zhang Spring 2008"— Presentation transcript:

1 Lecture 8: Dynamic Range and Trichromacy Li Zhang Spring 2008
CS559: Computer Graphics Lecture 8: Dynamic Range and Trichromacy Li Zhang Spring 2008 Most Slides from Stephen Chenney

2 Today Finish image morphing
Dynamic Range: Is 8 bits per channel enough? Trichromacy: Is RGB 3 bands enough? Start on 3D graphics Reading: Shirley ch Shirley ch Shirley ch 6, except 6.2.2 Last time, we talked how to sample a continuous light pattern into a discrete iamge. How to resample an discrete at different resolution or sampling rate. This lecture, we’ll look at what operation we can do on a discrete image. We’ll start with convolution

3 Dynamic Range The dynamic range is the ratio between the maximum and minimum values of a physical measurement. Its definition depends on what the dynamic range refers to. For a Scene: ratio between the brightest and darkest parts of the scene. For a Display: ratio between the maximum and minimum intensities emitted from the screen. For circuits, it means for voltage For physics, temperature. In our class, we mean the brightness of light. If you look at this room, the brightest region is the ceiling light and the darkest is the blackboard.

4 Dynamic Range Dynamic range is a ratio and as such a dimensionless quantity. In photography and imaging, the dynamic range represents the ratio of two luminance values, with the luminance expressed in candelas per square meter. A scene showing the interior of a room with a sunlit view outside the window, for instance, will have a dynamic range of approximately 100,000:1. The human eye can accommodate a dynamic range of approximately 10,000:1 in a single view. If you look at this room, the brightest region is the ceiling light and the darkest is the blackboard.

5 Dynamic Range Dynamic range is a ratio and as such a dimensionless quantity. In photography and imaging, the dynamic range represents the ratio of two luminance values, with the luminance expressed in candelas per square meter. A scene showing the interior of a room with a sunlit view outside the window, for instance, will have a dynamic range of approximately 100,000:1. The human eye can accommodate a dynamic range of approximately 10,000:1 in a single view. Beyond that, use adaptation to adjust If you look at this room, the brightest region is the ceiling light and the darkest is the blackboard.

6 Dynamic Range Image depth refers to the number of bits available.
We can use those bits to represent a large range at low resolution, or a small range at high resolution Long exposure time, use 8 bit to represent a small range of brightness, higher resolution Short exposure time, use 8 bits to represent a large range of brightness, lower resolution

7 High dynamic imaging High Dynamic Range Image Floating point pixel
Tone mapped image 8 bits, for standard monitors

8 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

9 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

10 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

11 Color Vision We have seen that humans have three sensors for color vision What’s the implications for digital color representation…

12 Qualitative Response Sensitivity,  E 400 500 600 700 400 500 600 700
Multiply 400 500 600 700 400 500 600 700 Area under curve? #photons, E Red Big response! 400 500 600 700

13 Qualitative Response Sensitivity,  E 400 500 600 700 400 500 600 700
Multiply 400 500 600 700 400 500 600 700 Area under curve? #photons, E Blue Tiny response! 400 500 600 700

14 People think these two spectra look the same
Trichromacy means… Spectrum Representing color: If you want people to “see” the continuous spectrum, you can just show the three primaries Color Matching: People think these two spectra look the same 400 500 600 700 3 Primaries Now you see the implication. No matter how complex the source spectrum is, you can always represent it using 3 colors to our vision. 400 500 600 700

15 Trichromacy 400 500 600 700 Spectrum 400 500 600 700 3 primaries 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.

16 Trichromacy 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

17 Primaries are Spectra Too
A primary can be a spectrum Single wavelengths are just a special case 3 Primaries 3 Primaries or 400 500 600 700 400 500 600 700

18 Color Matching Given a spectrum, how do we determine how much each of R, G and B to use to match it? Procedure: 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

19 The RGB Color Matching Functions

20 Computing the Matching
Given a spectrum E(), 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 R, G, B seem like a basis vector in a 3D space. r,g,b, are coordinates of this space. If we change r, g, b, we are changing the percieved color

21 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 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

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

23 Problems with RGB 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)

24 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 Alvy intronduced the concept of alpha channel.

25 RGB to HSV http://alvyray.com/Papers/hsv2rgb.htm
#define RETURN_HSV(h, s, v) {HSV.H = h; HSV.S = s; HSV.V = v; return HSV;} #define RETURN_RGB(r, g, b) {RGB.R = r; RGB.G = g; RGB.B = b; return RGB;} #define UNDEFINED -1 // Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms. Pure // red always maps to 6 in this implementation. Therefore UNDEFINED can be // defined as 0 in situations where only unsigned numbers are desired. typedef struct {float R, G, B;} RGBType; typedef struct {float H, S, V;} HSVType; HSVType RGB_to_HSV( RGBType RGB ) { // RGB are each on [0, 1]. S and V are returned on [0, 1] and H is // returned on [0, 6]. Exception: H is returned UNDEFINED if S==0. float R = RGB.R, G = RGB.G, B = RGB.B, v, x, f; int i; HSVType HSV; x = min(R, G, B); v = max(R, G, B); if(v == x) RETURN_HSV(UNDEFINED, 0, v); f = (R == x) ? G - B : ((G == x) ? B - R : R - G); i = (R == x) ? 3 : ((G == x) ? 5 : 1); RETURN_HSV(i - f /(v - x), (v - x)/v, v); }

26 HSV to RGB http://alvyray.com/Papers/hsv2rgb.htm
RGBType HSV_to_RGB( HSVType HSV ) { // H is given on [0, 6] or UNDEFINED. S and V are given on [0, 1]. // RGB are each returned on [0, 1]. float h = HSV.H, s = HSV.S, v = HSV.V, m, n, f; int i; RGBType RGB; if (h == UNDEFINED) RETURN_RGB(v, v, v); i = floor(h); f = h - i; if ( !(i&1) ) f = 1 - f; // if i is even m = v * (1 - s); n = v * (1 - s * f); switch (i) { case 6: case 0: RETURN_RGB(v, n, m); case 1: RETURN_RGB(n, v, m); case 2: RETURN_RGB(m, v, n) case 3: RETURN_RGB(m, n, v); case 4: RETURN_RGB(n, m, v); case 5: RETURN_RGB(v, m, n); }

27 L-A-B 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)

28 Spatial resolution and color
G In the next few slides, I’ll change these individual channels to you will see how the modification will change the final look of the color image. B original

29 Blurring the G component
original processed

30 Blurring the R component
original processed

31 Blurring the B component
processed original

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

33 Bluring L L a b processed original

34 Bluring a L a b processed original

35 Bluring b L a b processed original

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

37 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

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

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

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

41 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 y x x

42 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

43 Rotating About An Arbitrary Point
x x y y x x

44 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 xf=x”+a, yf=y”+b

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

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

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

48 Basic Transformations
Translation: Rotation: Scaling:

49 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

50 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) Direction is translation invariant

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

52 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

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

54 3D Translation

55 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

56 3D Rotation Why so? Consider r1, r2, r3 as reseult of unit vectors
This implies how many degree of freedom does a rotation matrix have?

57 Problems with Rotation Matrices
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

58 Alternative Representations
Euler angles: Specify how much to rotate about X, then how much about Y, then how much about Z Any three axes will do e.g. X,Y,X Hard to think about, and hard to compose

59 Alternative Representations
Specify the axis and the angle (OpenGL method) Hard to compose multiple rotations A rotation by an angle around axis specified by the unit vector is given by

60 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

61 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

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

63 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

64 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

65 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 Coordinate Space World Coordinate Space View Space Canonical View Volume Display Space


Download ppt "Lecture 8: Dynamic Range and Trichromacy Li Zhang Spring 2008"

Similar presentations


Ads by Google