CS452/552; EE465/505 Color Display Issues 4-16 15
2
Outline! Color Display Issues Color Systems Dithering and Halftoning! Splines Hermite Splines Bezier Splines Catmull-Rom Splines Read: Angel, Chapter 8, section 8.13 Display Considerations Chapter 11, Curves and Surfaces Chapter 12, section 12.1-12.7 Advanced Rendering: Ray-Tracing Lab#5 posted, due: April 22nd simple scene: platform & object; 1 light; shadow map; camera controls Project#2 posted due: April 23rd
Light mapping
Recursive Ray Tracer (Simple version) // starting point p, direction d, max # of steps; returns a color c (single light source) trace(p, d, step) { color local, reflected, transmitted; point q; normal n; if(step > max) return(background_color); q = intersect(p, d, status); if(status==light_source) return(light_source_color); if(status==no_intersection) return(background_color); n = normal(q); r = reflect(q, n); t = transmit(q,n); local = phong(q, n, r); reflected = trace(q, r, step+1); // recursive call transmitted = trace(q, t, step+1); // recursive call return(local + reflected + transmitted); }
Ray Tracing: Summary! Efficiency replace the recursion with iteration use bounding boxes to simplify the math used to compute intersections! Aliasing errors, due to sampling use a stochastic sampling method in which the decision on where to cast the next ray is based on the rays cast so far (used in Renderman)! Ray tracing is an inherently parallel process! There are many free ray tracers available
Next Topic: Displays & Color! Consider perceptual issues related to displays! Introduce chromaticity space Color systems Color transformations! Standard Color Systems Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015
Displays & Color! Problems that affect the quality of a display two different displays may have the same resolution, but display pixels at different sizes the colors displayed on two different monitors may differ map software-defined colors onto the display map brightness values onto the display RGB values are independent of display properties, but do not account for the full range of the human visual system! The range of displayable colors for a device is called its color gamut
Luminance and Color Images! Luminance Image Monochromatic Values are gray levels Analogous to working with black and white film or television! Color Image Has perceptional attributes of hue, saturation, and lightness Do we have to match every frequency in visible spectrum? No! E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Perception Review! Light is the part of the electromagnetic spectrum between ~350-750 nm! A color C(λ) is a distribution of energies within this range! Human visual system has two types of sensors Rods: monochromatic, night vision Cones: color sensitive Three types of cones! Consequently, only three values, the tristimulus values, are perceived by the brain E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Color vision deficiency! red-green difficulty distinguishing between shades of red + green affects ~8% of males and ~0.5% of females in populations of North European ancestry! blue-yellow difficulty differentiating shades of blue and yellow affects males & females equally, < 1/10,000! achromatopsia cannot perceive any colors rare, < 1/30,000 for most populations
Tristimulus Values! The human visual center has three cones with sensitivity curves S 1 (λ), S 2 (λ), and S 3 (λ)! For a color C(λ), the cones output the tristimulus values T = S λ) C( λ) dλ 1 1 ( C(λ) T = S λ) C( λ) dλ 2 2 ( T = S λ) C( λ) dλ 3 3 ( cones optic nerve T 1, T 2, T 3 E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Three Color Theory! Any two colors with the same tristimulus values are perceived to be identical! Thus a display (CRT, LCD, film) must only produce the correct tristimulus values to match a color! Is this possible? Not always Different primaries (different sensitivity curves) in different systems E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
The Problem! The sensitivity curves of the human are not the same as those of physical devices! Human: curves centered in blue, green, and green-yellow! CRT: RGB! Print media: CMY or CMYK! Which colors can we match and, if we cannot match, how close can we come? E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Representing Colors! Consider a color C(λ)! It generates tristimulus values T 1, T 2, T 3 Write C = (T 1, T 2, T 3 ) Conventionally,we assume 1 T 1, T 2, T 3 0 because there is a maximum brightness we can produce and energy is nonnegative 1 C is a point in color solid C 1 T 3 T 2 T 1 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Producing Colors! Consider a device such as a CRT with RGB primaries and sensitivity curves! Tristimulus values T = R( λ) C( λ) dλ T = G( λ) C( λ) dλ T = B( λ) C( λ) dλ 1 2 3 E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Matching! This T 1, T 2, T 3 is dependent on the particular device! If we use another device, we will get different values and these values will not match those of the human cone curves! Need a way of matching and a way of normalizing E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Color Systems! Various color systems are used Based on real primaries: RGB UVW CMYK HLS (aka HSB) NTSC YIQ (National Television System Committee) Theoretical XYZ! Prefer to separate brightness (luminance) from color (chromatic) information Reduce to two dimensions E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Tristimulus Coordinates! For any set of primaries, define t = T T T 1 1 + + 1 2 Note: T t 3 = T T T t 3 3 + + 1 2 = T T T 2 2 + + 1 2 T 3 T + + 1,, 0 t t t 2 3 1 = 1 t t 2 t 1 3 3 E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Maxwell Triangle 1 T 1 + T 2 +T 3 =1 1 1 color solid Project onto 2D: chromaticity space 1 t 1 + t 2 =1 t 1 possible colors t 2 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
NTSC RGB 1 r+g+b=1 g r+g=1 r 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Producing Other Colors! However colors producible on one system (its color gamut) is not necessarily producible on any other! Note that if we produce all the pure spectral colors in the 350-750 nm range, we can produce all others by adding spectral colors! With real systems (CRT, film), we cannot produce the pure spectral colors! We can project the color solid of each system into chromaticity space (of some system) to see how close we can get E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Color Gamuts 600 nm spectral colors CRT colors printer colors producible color on CRT but not on printer unproducible color 350 nm producible color on both CRT and printer 750 nm E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
XYZ! Reference system in which all visible pure spectral colors can be produced! Theoretical systems, as there are no corresponding physical primaries! Standard reference system E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Color Systems! Most correspond to real primaries National Television Systems Committee (NTSC) RGB matches phosphors in CRTs! Film both additive (RGB) and subtractive (CMY) for positive and negative film! Print industry CMYK (K = black) K used to produce sharp crisp blacks Example: ink jet printers E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Color Transformations! Each additive color system is a linear transformation of another G G C = (T 1, T 2, T 3 ) = (T 1, T 2, T 3 ) B B R in R G B system R in RGB system E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Additive and Subtractive Color! Additive color Form a color by adding amounts of three primaries CRTs, projection systems, positive film Primaries are Red (R), Green (G), Blue (B)! Subtractive color Form a color by filtering white light with cyan (C), Magenta (M), and Yellow (Y) filters Light-material interactions Printing Negative film E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
RGB: Red, Green, Blue! Primary colors: red, green, blue! Secondary colors: yellow = red+green cyan = green+blue magenta = blue+red! All colors white = red+green+blue black = no color C = T 1 R + T 2 G + T 3 B Color Cube
CMYK: Cyan, Magenta, Yellow, Black! Primary colors: cyan, magenta, yellow! Secondary colors: blue = cyan+magenta red = magenta+yellow green = yellow+cyan! All colors white = no color black = cyan+magenta+yellow for true black, add in black (+black) Also known as process color (used to print full-color images)
RGB, CMY, CMYK! Assuming 1 is max of a primary C = 1 R M = 1 G Y = 1 B! Convert CMY to CMYK by K = min(c, M, Y) C = C K M = M K Y = Y - K E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Color Matrix! Exists a 3 x 3 matrix to convert from representation in one system to representation in another # &! $! = M$! $ " %! Example: XYZ to NTSC RGB find in colorimetry references & $ $ $ % T' T' T' 1 2 3 T T T! Can take a color in XYZ and find out if it is producible by transforming and then checking if resulting tristimulus values lie in (0,1) 1 2 3 #!!! " E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
YIQ! NTSC Transmission Colors! Here Y is the luminance arose from the need to separate brightness from chromatic information in TV broadcasting & Y# $! $ I! $ % Q! " = & 0.299 $ $ 0.596 $ % 0.212 0.587-0.275-0.523 0.114 #& R# - 0.321! $!! $ G! 0.311!" $ % B! "! Note luminance shows high green sensitivity E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Other Color Systems! UVW: equal numerical errors are closer to equal perceptual errors! HLS: perceptual color (hue, saturation, lightness) Polar representation of color space Single and double cone versions E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
HSB: Hue, Saturation, Brightness! Hue is the actual color. It is measured in angular degrees counter-clockwise around the cone starting and ending at red=0 or 360 (yellow = 60, green = 120, etc.).! Saturation is the purity of the color, measured in percent from the center of the cone (0) to the surface (100).! Brightness is measured in percent from black (0%) to white (100%). grayscale axis from 0% (white) to 100% (black)
Gamma Correction! Intensity vs CRT voltage is nonlinear I = cv γ! Gamma correction (encoding) can code/decode luminance or tristimulus values! Can use a lookup table to correct! Human brightness response is logarithmic Equal steps in gray levels are not perceived equally Can use lookup table! CRTs cannot produce a full black Limits contrast ratio E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012
Dithering (digital halftoning)
Black/White Dithering
Color Dithering
Halftoning
Modeling Complex Shapes
What do we need from curves in Computer Graphics?! Local control of shape so that it is easy to build and modify! Stability! Smoothness and continuity! Ability to evaluate derivatives! Ease of rendering
Utah Teapot! Most famous data set in computer graphics! Widely available as a list of 306 3D vertices and the indices that define 32 Bezier patches
Curve Representations
Parameterization of a Curve
Polynomial Interpolation
Splines: Piecewise Polynomials
Piecewise Polynomials
Splines
Cubic Curves in 3D
Cubic Hermite Splines
Deriving Hermite Splines
Deriving Hermite Splines
Deriving Hermite Splines
The Cubic Hermite Spline Equation
Four Basis Functions for Hermite Splines
Piecing together Hermite Splines
Hermite Splines in Adobe Illustrator
Bezier s Idea! In graphics and CAD, we do not usually have derivative data! Bezier suggested using the same 4 data points as with the cubic interpolating curve to approximate the derivatives in the Hermite form
Bezier Splines
Approximating Derivatives p 1 located at u=1/3 p 1 p 2 p 2 located at u=2/3 p p0 p'(0) 1/ 3 1 p p2 p'(1) 1/ 3 3 slope p (0) slope p (1) p 0 u p 3
The Bezier Spline Matrix
Bezier Blending Functions
DeCasteljau Construction
Bezier Patches Using same data array P=[p ij ] as with interpolating form p( u, v) 3 3 = i= 0 j= 0 bi( u) b j ( v) p ij = u T M B P M T B v Patch lies in convex hull
Analysis! Although the Bezier form is much better than the interpolating form, we have the derivatives are not continuous at join points! Can we do better? Go to higher order Bezier More work Derivative continuity still only approximate Supported by OpenGL Apply different conditions Tricky without letting order increase
Catmull-Rom Splines
Constructing the Catmull-Rom Spline
Catmull-Rom Spline Matrix
Splines with More Continuity?
Comparison of Basic Cubic Splines
Natural Cubic Splines
B-Splines
B-Splines! Basis splines: use the data at p=[p i-2 p i-1 p i p i-1 ] T to define curve only between p i-1 and p i! Allows us to apply more continuity conditions to each segment! For cubics, we can have continuity of function, first and second derivatives at join points! Cost is 3 times as much work for curves Add one new point each time rather than three! For surfaces, we do 9 times as much work
B-Spline Basis
Other Common Types of Splines
Generalizing Splines! We can extend to splines of any degree! Data and conditions to not have to given at equally spaced values (the knots) Nonuniform and uniform splines Can have repeated knots Can force spline to interpolate points! Cox-deBoor recursion gives method of evaluation
NURBS! Nonuniform Rational B-Spline curves and surfaces add a fourth variable w to x,y,z Can interpret as weight to give more importance to some control data Can also interpret as moving to homogeneous coordinate! Requires a perspective division NURBS act correctly for perspective viewing! Quadrics are a special case of NURBS
How to Draw Spline Curves
Drawing Splines, continued
Summary
Project: Roller Coaster! use Catmull-Rom splines along with lighting and texture mapping to create a roller coaster simulation! runs in a first-person view, allowing the user to ride the coaster in an immersive environment
Animation