24.colorIssues - Clarkson University › class › cs452 › slides › 24.colorIssues.pdfuse...

Post on 25-Jun-2020

3 views 0 download

transcript

CS452/552; EE465/505

Color Display Issues

4-16–15

2

! 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

Outline

Light mapping

// 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); }

Recursive Ray Tracer (Simple version)

! 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

Ray Tracing: Summary

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

! 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

Displays & Color

E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

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

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

! achromatopsia ✦ cannot perceive any

colors ✦ rare, < 1/30,000 for

most populations

! blue-yellow

✦ difficulty differentiating shades of blue and yellow

✦ affects males & females equally, < 1/10,000

E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Tristimulus Values! The human visual center has three cones with

sensitivity curves S1(λ), S2(λ), and S3(λ) ! For a color C(λ), the cones output the tristimulus

values

λλλ dCST )()(11 ∫=

λλλ dCST )()(22 ∫=

λλλ dCST )()(33 ∫=

C(λ)

T1, T2, T3cones

optic nerve

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 T1, T2, T3

✦Write C = (T1, T2, T3 ) ✦Conventionally,we assume 1≥ T1, T2, T3 ≥ 0 because there is a maximum brightness we can produce and energy is nonnegative

✦C is a point in color solid C1

11T1

T2

T3

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λλλ dCRT )()(1 ∫= λλλ dCGT )()(2 ∫= λλλ dCBT )()(3 ∫=

E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Matching ! This T1, T2, T3 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

TTTTt

321

11 ++=

TTTTt

321

22 ++=

! For any set of primaries, define

TTTTt

321

33 ++=

1ttt 321 =++ 0,,1 ttt 321 ≥≥✦Note:

E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Maxwell Triangle

Project onto 2D: chromaticity space

1

1T1 + T2+T3 =1

1

color solid

t1

t2

1

1t1 +

t2 =1possible colors

E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

NTSC RGB

1

1

r

g

r+g+b=1

r+g=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

spectral colors printer colors

CRT colors

350 nm

750 nm

600 nm

producible color on CRT but not on printer

producible color on both CRT and printer

unproducible color

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

R

R’

GG’

BB’

C = (T1, T2, T3) = (T’1, T’2, T’3)

in RGB system

in R’G’B’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

! 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

RGB: Red, Green, Blue

C = T1R + T2G + T3B

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

Also known as process color (used to print full-color images)

(+black)

E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

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

! Example: XYZ to NTSC RGB ✦ find in colorimetry references

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

!!!

"

#

$$$

%

&

=!!!

"

#

$$$

%

&

TTT

T'T'T'

3

2

1

3

2

1

M

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

! Note luminance shows high green sensitivity

!!!

"

#

$$$

%

&

!!!

"

#

$$$

%

&

=

!!!

"

#

$$$

%

&

BGR

0.3110.523-0.2120.321-0.275-0.5960.1140.5870.299

QIY

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

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)

E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

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

Dithering (digital halftoning)

Black/White Dithering

Color Dithering

Halftoning

Modeling Complex Shapes

! Local control of shape ■ so that it is easy to build and modify

! Stability ! Smoothness and continuity ! Ability to evaluate derivatives ! Ease of rendering

What do we need from curves in Computer Graphics?

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

p0

p1p2

p3

p1 located at u=1/3 p2 located at u=2/3

3/1pp)0('p 01−≈

3/1pp)1('p 23−≈

slope p’(0) slope p’(1)

u

The Bezier Spline Matrix

Bezier Blending Functions

DeCasteljau Construction

Bezier Patches

Using same data array P=[pij] as with interpolating form

vupvbubvup TBB

Tijj

i ji MPM==∑∑

= =

)()(),(3

0

3

0

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=[pi-2 pi-1 pi pi-1]T

to define curve only between pi-1 and pi

! 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

! 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

Project: Roller Coaster

Animation