university of british columbia cpsc 314 computer graphics jan-apr 2005 tamara munzner cs314/vjan2005...

52
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner http://www.ugrad.cs.ubc.ca/~cs314 /Vjan2005 Color Week 5, Fri Feb 4

Post on 18-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

University of British ColumbiaCPSC 314 Computer Graphics

Jan-Apr 2005

Tamara Munzner

http://www.ugrad.cs.ubc.ca/~cs314/Vjan2005

Color

Week 5, Fri Feb 4

Page 2: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

2

Review: Shading Models

flat shading compute Phong lighting once for entire

polygon Gouraud shading

compute Phong lighting at the vertices and interpolate lighting values across polygon

Phong shading compute averaged vertex normals interpolate normals across polygon and

perform Phong lighting across polygon

Page 3: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

3

Correction: Phong Shading

linearly interpolating surface normal across the facet, applying Phong lighting model at every pixel same input as Gouraud shading pro: much smoother results con: considerably more expensive

not the same as Phong lighting common confusion Phong lighting: empirical model to calculate

illumination at a point on a surface

Page 4: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

4

Review/Correction: Non-Photorealism

draw silhouettes and creases cool-to-warm shading

http://www.cs.utah.edu/~gooch/SIG98/paper/drawing.html

(n0 ⋅n1 ) ≤ threshold

Page 5: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

5

Computing Normals per-vertex normals by interpolating per-facet

normals OpenGL supports both

computing normal for a polygon

c

b

a

Page 6: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

6

Computing Normals per-vertex normals by interpolating per-facet

normals OpenGL supports both

computing normal for a polygon three points form two vectors

c

b

a

b-c

a-b

Page 7: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

7

Computing Normals per-vertex normals by interpolating per-facet

normals OpenGL supports both

computing normal for a polygon three points form two vectors cross: normal of plane

c

b

a

b-c

a-b

(a-b) x (b-c)

Page 8: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

8

Computing Normals per-vertex normals by interpolating per-facet

normals OpenGL supports both

computing normal for a polygon three points form two vectors cross: normal of plane

which side of plane is up? counterclockwise

point order convention

c

b

a

b-c

a-b

(a-b) x (b-c)

Page 9: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

University of British ColumbiaCPSC 314 Computer Graphics

Jan-Apr 2005

Tamara Munzner

Color

Page 10: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

10

Basics Of Color

elements of color:

Page 11: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

11

Basics of Color

Physics: Illumination

Electromagnetic spectra Reflection

Material properties Surface geometry and microgeometry (i.e.,

polished versus matte versus brushed) Perception

Physiology and neurophysiology Perceptual psychology

Page 12: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

12

Electromagnetic Spectrum

Page 13: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

13

White Light

Sun or light bulbs emit all frequencies within the visible range to produce what we perceive as the "white light"

Page 14: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

14

Sunlight Spectrum

Page 15: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

15

White Light and Color

when white light is incident upon an object, some frequencies are reflected and some are absorbed by the object

combination of frequencies present in the reflected light that determinses what we perceive as the color of the object

Page 16: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

16

Hue

hue (or simply, "color") is dominant wavelength

integration of energy for all visible wavelengths is proportional to intensity of color

Page 17: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

17

Saturation or Purity of Light

how washed out or how pure the color of the light appears contribution of dominant light vs. other

frequencies producing white light

Page 18: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

18

Intensity vs. Brightness

intensity : radiant energy emitted per unit of time, per unit solid angle, and per unit projected area of the source (related to the luminance of the source)

brightness : perceived intensity of light

Page 19: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

19

Humans and Light when we view a source of light, our eyes respond

respond to hue: the color we see (red, green, purple)

dominant frequency saturation: how far is color from grey

(pink is less saturated than red, sky blue is less saturated than royal blue)

brightness: how bright is the color how close is the color to white or black how bright are the lights illuminating the object?

 

Page 20: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

20

Physiology of Vision

the eye: the retina

rods cones

color!

Page 21: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

21

Physiology of Vision

center of retina is densely packed region called the fovea. cones much denser here than the periphery

Page 22: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

22

Trichromacy three types of cones

L or R, most sensitive to red light (610 nm) M or G, most sensitive to green light (560 nm) S or B, most sensitive to blue light (430 nm)

color blindness results from missing cone type(s)

Page 23: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

23

Metamers a given perceptual sensation of color derives from the stimulus of all three cone types

identical perceptions of color can thus be caused by very different spectra

Page 24: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

24

Metamer Demo http://www.cs.brown.edu/exploratories/freeSoftware/catalogs/color_theory.html

Page 25: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

25

Adaptation, Surrounding Color

color perception is also affected by adaptation (move from sunlight to dark room) surrounding color/intensity:

simultaneous contrast effect

Page 26: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

26

Bezold Effect

impact of outlines

Page 27: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

27

Color Constancy

Page 28: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

28

Color Constancy

Page 29: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

29

Color Constancy

Page 30: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

30

Color Constancy

Page 31: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

31

Color Constancy

Page 32: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

32

Color Constancy

Page 33: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

33

Color Constancy

automatic “white balance” from change in illumination

vast amount of processing behind the scenes!

colorimetry vs. perception

Page 34: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

34

Color Spaces

three types of cones suggests color is a 3D quantity. how to define 3D color space?

idea: perceptually based measurement shine given wavelength () on a screen user must control three pure lights producing

three other wavelengths (say R=700nm, G=546nm, and B=436nm)

adjust intensity of RGB until colors are identical this works because of metamers!

Page 35: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

35

Negative Lobes

exact target match with phosphors not possible

some red had to be added to target color to permit exact match using “knobs” on RGB intensity output of CRT

equivalently (theoretically), some red could have been removed from CRT output

figure shows that red phosphor must remove some cyan for perfect match

CRT phosphors cannot remove cyan, so 500 nm cannot be generated

Page 36: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

36

Negative Lobes

can’t generate all other wavelenths with any set of three positive monochromatic lights!

solution: convert to new synthetic coordinate system to make the job easy

Page 37: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

37

CIE Color Space

CIE defined three “imaginary” lights X, Y, and Z, any wavelength can be matched perceptually by positive combinations

Note that:X ~ RY ~ GZ ~ B

Page 38: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

38

Measured vs. CIE Color Spaces

measured basis monochromatic lights physical observations negative lobes

transformed basis “imaginary” lights all positive, unit area Y is luminance

Page 39: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

39

CIE Color Space Gamut

the gamut of all colors perceivable is thus a three-dimensional shape in X,Y,Z

color = X’X + Y’Y + Z’Z

Page 40: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

40

RGB Color Space (Color Cube) define colors with (r, g, b)

amounts of red, green, and blue used by OpenGL

RGB color cube sits within CIE color space something like this subset of perceivable colors

Page 41: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

41

CIE Chromaticity Diagram (1931)

For simplicity, we often project to the 2D plane X’+Y’+Z’=1

X’ = X’ / (X’+Y’+Z’)Y’ = Y’ / (X’+Y’+Z’)Z’ = 1 – X’ – Y’

Page 42: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

42

Device Color Gamuts

use CIE chromaticity diagram to compare the gamuts of various devices

Page 43: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

43

Device Color Gamuts

Since X, Y, and Z are hypothetical light sources, no real device can produce the entire gamut of perceivable color

Example: CRT monitor

Page 44: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

44

Gamut Mapping

Page 45: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

45

YIQ Color Space

YIQ is the color model used for color TV in America. Y is brightness, I & Q are color note: Y is the same as CIE’s Y result: use the Y alone and backwards

compatibility with B/W TV!

Page 46: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

46

Converting Color Spaces

converting between color models can also be expressed as a matrix transform

note the relative unimportance of blue in computing the Y

⎥⎥⎥

⎢⎢⎢

⎥⎥⎥

⎢⎢⎢

−−−=

⎥⎥⎥

⎢⎢⎢

B

G

R

Q

I

Y

31.052.021.0

32.028.060.0

11.059.030.0

Page 47: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

47

HSV Color Space

a more intuitive color space H = Hue S = Saturation V = Value (or brightness)

ValueSaturation

Hue

Page 48: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

48

Simple Model of Color

based on RGB triples surface interactions also simplified

Page 49: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

49

Page 50: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

50

The Gamma Problem

device gamma

monitor: I= A(k1D+k2V)

typical monitor =2.5 LCD: nearly linear

OS gamma defined by operating system

inverse gamma curve I1/

“gamma correction”

Page 51: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

51

Display System Gamma

product of device and OS curves divide device by OS gammaDS D OS

display system gamma varies different devices, different OS nonlinear

viewing conditions also affect perception of “gamma”

PC Mac SGI

1.0 1.4 1.7

Default OS Gamma

PC Mac SGI

2.2 1.6 1.3

Default DS Gamma

Page 52: University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner cs314/Vjan2005 Color Week 5, Fri Feb

52

Intensity Mapping