CS 5600 CS 5600 Class mailing list: Introduction to Computer - - PDF document

cs 5600 cs 5600
SMART_READER_LITE
LIVE PREVIEW

CS 5600 CS 5600 Class mailing list: Introduction to Computer - - PDF document

Utah School of Computing Spring 2013 CS 5600 CS 5600 Class mailing list: Introduction to Computer Graphics cs5600@list.eng.utah.edu http://www.eng.utah.edu/~cs5600/ Sign up: Prof: Chuck Hansen


slide-1
SLIDE 1

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 1

CS 5600

Introduction to Computer Graphics Prof: Chuck Hansen Goal: have fun and learn graphics!

http://www.eng.utah.edu/~cs5600/

Spring 2013 Utah School of Computing 2

CS 5600

  • Class mailing list:

cs5600@list.eng.utah.edu

  • Sign up:

https://sympa.eng.utah.edu/sympa/info/cs5600

  • Text: OpenGL Programming Guide

“Red Book” supplemental reading material

» DDA – Line Drawing » Ray Tracing

Spring 2013 Utah School of Computing 3

CS 5600

  • Grading:

70% homework 25% exams 5% class participation (ask questions, respond to questions)

  • Cheating: DON'T share code! DON'T

grab code off the web!

  • Late penalty: -20%/day but 4 one-day

grace periods.

Spring 2013 Utah School of Computing 4

CS 5600

  • What will we do?

– Color – DDA algorithms (equ. into algs) – Scan conversion – Transformations – Projections – Polygon rendering – Texture mapping – Ray tracing

Spring 2013 Utah School of Computing 5

Prereqs:

  • Normalized Vector?
  • Matrix multiply?
  • Vector multiply?
  • Dot-product? (what is it?)

Spring 2013 Utah School of Computing 6

Prereqs:

  • Normalized Vector?
  • Matrix multiply?
  • Vector multiply?
  • Dot-product? (what is it?)
slide-2
SLIDE 2

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 7

Prereqs:

  • Cross Product?

– Properties?

Spring 2013 Utah School of Computing 8

Prereqs:

  • Cross Product?

– Properties? – Compute?

Spring 2013 Utah School of Computing 9

Cross Product

V1 = [3, -1, 0] V2 = [4, -3, 1] x y z 3

  • 1 0

4

  • 3 1

Det:

Spring 2013 Utah School of Computing 10

Cross Product

V1 = [3, -1, 0] V2 = [4, -3, 1] x y z 3

  • 1 0

4

  • 3 1

Det: -1 - 0 ,

Spring 2013 Utah School of Computing 11

Cross Product

V1 = [3, -1, 0] V2 = [4, -3, 1] x y z 3

  • 1 0

4

  • 3 1

Det: -1 , 3 - 0 ,

X WRONG!

Spring 2013 Utah School of Computing 12

Cross Product

V1 = [3, -1, 0] V2 = [4, -3, 1] x y z 3

  • 1 0

4

  • 3 1

Det: -1 , 0 - 3 ,

slide-3
SLIDE 3

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 13

Cross Product

V1 = [3, -1, 0] V2 = [4, -3, 1] x y z 3

  • 1 0

4

  • 3 1

Det: -1, -3,

  • 9 - (-4)

Spring 2013 Utah School of Computing 14

Cross Product

V1 = [3, -1, 0] V2 = [4, -3, 1] x y z 3

  • 1 0

4

  • 3 1

Det: -1, -3, -5

Spring 2013 Utah School of Computing 15

Cross Product Sarrus' scheme

V1 = [3, -1, 0] V2 = [4, -3, 1] x y z x y z 3 -1 0 3 -1 0 4 -3 1 4 -3 1 Det:

Spring 2013 Utah School of Computing 16

Cross Product Sarrus' scheme

V1 = [3, -1, 0] V2 = [4, -3, 1] x y z x y z 3 -1 0 3 -1 0 4 -3 1 4 -3 1 Det: -1 - 0 ,

Spring 2013 Utah School of Computing 17

Cross Product Sarrus' scheme

V1 = [3, -1, 0] V2 = [4, -3, 1] x y z x y z 3 -1 0 3 -1 0 4 -3 1 4 -3 1 Det: -1, 0 - 3 ,

Spring 2013 Utah School of Computing 18

Cross Product Sarrus' scheme

V1 = [3, -1, 0] V2 = [4, -3, 1] x y z x y z 3 -1 0 3 -1 0 4 -3 1 4 -3 1 Det: -1, -3, -9 - (-4) ,

slide-4
SLIDE 4

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 19

Cross Product Sarrus' scheme

V1 = [3, -1, 0] V2 = [4, -3, 1] x y z x y z 3 -1 0 3 -1 0 4 -3 1 4 -3 1 Det: -1, -3, -5

Spring 2013 Utah School of Computing 20

Line Equations

  • Explicit form:

y = mx + b

  • Implicit form:

f(x,y) = Ax + By + C = 0

  • Parametric form:

P(x,y) = P0 + t D

Spring 2013 Utah School of Computing 21

Line Equations

Show: y = mx + b equivalent to P(x,y) = P0 + t D For P1P2 (assume b=0) :

y – y1 = ((y2 – y1)/(x2 – x1)) ( x – x1) x = ((x2 – x1)/(y2 – y1)) ( y – y1) + x1)

Spring 2013 Utah School of Computing 22

Line Equations

P(x,y) = P0 + t D For P1P2:

x = x1 + t (x2 – x1) y = y1 + t (y2 – y1) t = (x – x1) / (x2 – x1) y = y1 + [(x – x1) / (x2 – x1)] (y2 – y1) y – y1 = (x – x1) [(y2 – y1) / (x2 – x1)] x = ((x2 – x1)/(y2 – y1)) ( y – y1) + x1)

Spring 2013 Utah School of Computing 23

CS5600 Computer Graphics

Modified from Rich Riesenfeld

Spring 2013 Lecture Set 1

Spring 2013 Utah School of Computing 24

  • Color is complicated!

–Highly nonlinear –No single model to explain all

  • Many simplistic models,

explanations

  • Many myths
  • Much new knowledge
slide-5
SLIDE 5

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 25

Wavelength Spectrum

infrared light ultraviolet light

Wavelength (nm)

700 600 500 400

  • Seen in physics, physical phenomena

(rainbows, prisms, etc)

  • 1 Dimensional color space

Spring 2013 Utah School of Computing 26

Wavelength Spectrum

Spring 2013 Utah School of Computing 27

Color Space

  • “Navigating,” moving around in a

color space, is tricky

  • Many color representations (spaces)
  • Can you get to a nearby color?
  • Can you predictably adjust a color?

Spring 2013 Utah School of Computing 28

Color Spaces

  • Device-derived

–convenient for describing display device levels –RGB, CMY

  • Intuitive (transformations)

–based in familiar color description terms –HSV, HSI

  • Perceptually based

–device independent, perceptually uniform –CIELUV, CIELAB, Munsell

Spring 2013 Utah School of Computing 29

R-G-B Color Space

  • Convenient colors (screen phosphors)
  • Decent coverage of the human color
  • Not a particularly good basis for human

interaction –Non-intuitive –Non-orthogonal (perceptually)

Spring 2013 Utah School of Computing 30

slide-6
SLIDE 6

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 31

Color Cube: (r,g,b) is RHS

gra y (0,0,1 ) (0,0,1 ) blue blue blue (1,0,1) (1,0,1) magenta magenta magenta (0,1,1) (0,1,1) cyan cyan cyan (0,1,0) (0,1,0) green green green (1,1,0) (1,1,0) yellow yellow yellow (1,0,0) (1,0,0) red red red white white white (1,1,1) (1,1,1) (0,0,0) (0,0,0) black black black

Spring 2013 Utah School of Computing 32

Color Cube

(0,0,1 ) (0,0,1 ) blue blue blue (1,0,1) (1,0,1) magenta magenta magenta (0,1,1) (0,1,1) cyan cyan cyan (0,1,0) (0,1,0) green green green (1,1,0) (1,1,0) yellow yellow yellow (1,0,0) (1,0,0) red red red (1,1,1) (1,1,1) white white white

Spring 2013 Utah School of Computing 33

Complementary Colors Add to Gray

(0,0,1 ) (0,0,1 ) (0,0,1 ) blue blue blue magenta magenta magenta (0,1,1) (0,1,1) cyan cyan cyan (1,1,1) (1,1,1) white white white (1,0,1) (1,0,1) (0,1,0) (0,1,0) (0,1,0) green green green

( (1,1,0

1,1,0)

) yellow yellow yellow

(1,0,0) (1,0,0) red red red

Spring 2013 Utah School of Computing 34

Complementary Colors

Looking at color cube along major diagonal

Spring 2013 Utah School of Computing 35

Additive Primary Colors Additive Primary Colors

(1,0,1) (1,0,1) (0,0,1 ) (0,0,1 ) (0,1,0) (0,1,0) (0,1,1) (0,1,1) (1,0,0) (1,0,0) (1,1,0) (1,1,0) magenta magenta magenta blue blue blue cyan cyan cyan green green green red red red yellow yellow yellow white white white (1,1,1) (1,1,1)

Spring 2013 Utah School of Computing 36

Additive Primary Colors Additive Primary Colors

(0,1,0) (0,1,0) (1,0,0) (1,0,0) (1,1,0) (1,1,0) green green green red red red yellow yellow yellow

slide-7
SLIDE 7

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 37

Additive Primary Colors Additive Primary Colors

(1,0,1) (1,0,1) (0,0,1 ) (0,0,1 ) (1,0,0) (1,0,0) magenta magenta magenta blue blue blue red red red

Spring 2013 Utah School of Computing 38

Additive Primary Colors Additive Primary Colors

(0,1,0) (0,1,0) green green green (0,1,1) (0,1,1) cyan cyan cyan (0,0,1 ) (0,0,1 ) blue blue blue

Spring 2013 Utah School of Computing 39

Subtractive Primary Colors Subtractive Primary Colors

(1,1,0) (1,1,0) yellow yellow yellow (0,1,0) (0,1,0) green green green (0,1,1) (0,1,1) cyan cyan cyan (0,0,1 ) (0,0,1 ) blue blue blue (1,0,1) (1,0,1) magenta magenta magenta (1,0,0) (1,0,0) red red red black black black (0,0,0) (0,0,0)

Spring 2013 Utah School of Computing 40

Subtractive Primary Colors Subtractive Primary Colors

(1,1,0) (1,1,0) (1,1,0) yellow yellow yellow (1,0,1) (1,0,1) (1,0,1) magenta magenta magenta (1,0,0) (1,0,0) (1,0,0) red red red

Spring 2013 Utah School of Computing 41

Subtractive Primary Colors Subtractive Primary Colors

(1,1,0) (1,1,0) yellow yellow yellow (0,1,0) (0,1,0) green green green (0,1,1) (0,1,1) cyan cyan cyan

Spring 2013 Utah School of Computing 42

Subtractive Primary Colors Subtractive Primary Colors

(1,0,1) (1,0,1) magenta magenta magenta (0,0,1 ) (0,0,1 ) blue blue blue (0,1,1) (0,1,1) cyan cyan cyan

slide-8
SLIDE 8

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 43

(H, S, V ) Color Space

  • Introduced by Albet Munsell, late 1800s

– He was an artist and scientist

  • Hue: Color
  • Saturation/Chroma: Strength of a color

– Neutral gray has 0 saturation

  • Brightness/Value: Intensity of light

emanating from image

Spring 2013 Utah School of Computing 44

HSV/HSL

Spring 2013 Utah School of Computing 45

HSI/HSV

  • Value/Luminance – total amount of

energy

  • Saturation – degree to which color

is one wavelength

  • Hue – dominant wavelength

Spring 2013 Utah School of Computing 46

Saturation

Spring 2013 Utah School of Computing 47

HSV

  • Max = max(R, G, B)
  • Min = min(R, G, B)
  • S = (Max – Min)/Max
  • If R==Max -> h = (G-B)/(Max-Min)
  • If G==Max -> h = 2+(B-R)/(Max-Min)
  • If B==Max -> h = 4 + (R-G)/(Max-Min)
  • If h<0 -> H = h/6 + 1
  • If h>0 -> H = h/6

Spring 2013 Utah School of Computing 48

HSV User Interaction

slide-9
SLIDE 9

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 49

HLS

  • S = sqrt( ((R-G)2 + (R-B)2 + (G-B) 2)/2 )
  • I = (R + G + B)/3
  • H = (a – arctan((R–I)b/(G-B)))/(2) --- angle
  • a =

–/2 if G>B –3*/2 if G<B –H = 1 if G=B

  • a=sqrt(3)

Spring 2013 Utah School of Computing 50

The hue of an object may be blue, but the terms light and dark distinguish the brightness of one

  • bject from another.

(Hue, Saturation, Value/Intensity)

(H, S, V ) Color Space

Spring 2013 Utah School of Computing 51

HSV Color Space (Cone)

120˚ 0˚

V S H

1.0 0.0

240˚

yellow yellow yellow green green green cyan cyan cyan red red red magenta magenta magenta blue blue blue black black black

Spring 2013 Utah School of Computing 52

V S H

120˚ 0˚

1.0

240˚

HSV Color Space (Cone) HSV Color Space (Cone)

Spring 2013 Utah School of Computing 53

HLS Color Space (double cone)

0.0 1.0

S L

53

0.0

H white white white black black black red red red

Spring 2013 Utah School of Computing 54

OpenGL Color

void glColor3f (GLfloat red , GLfloat green , GLfloat blue ); void glColor4f (GLfloat red , GLfloat green , GLfloat blue , GLfloat alpha );

Color is OpenGL State (once set, it doesn’t change) Typical usage: glBegin(GL_POINTS) glColor3f ( 1.0, 0.0, 0.0); glVertex2i ( 64, 64); glVertex2i (128, 128); glColor3f ( 0.0, 1.0, 0.0); glVertex2i ( 256, 256);

slide-10
SLIDE 10

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 55

Tristimulus Color Theory

  • Any color can be matched by a mixture
  • f three fixed base colors (primaries)
  • Eye has three kinds of color receptors

called cones

  • Eye also has rods (low light receptors)

Spring 2013 Utah School of Computing 56

Color Receptors in Eye

  • Red,

Green, Blue

  • Long,

Medium, Short

  • Red

Red, Green Green, Blue Blue

  • Long

Long, Medium Medium, Short Short

Fraction of light absorbed by each type of cone Wavelength λ (nm)

0.20 0 .18 0 .16 0 .14 0 .12 0 .10 0 .08 0 .06 0 .04 0 .02 0 .00 600 560 440 520 640 400 680 480

Spring 2013 Utah School of Computing 57

Color Receptors in Eye

600 550 450 500 650 400 700

Wavelength λ (nm)

Relative sensitivity

0.0 1.0

Spring 2013 Utah School of Computing 58

CIE* Color Space

( X, Y, Z ) represents an imaginary basis that

does not correspond to what we see Define the normalized coordinates:

x = X / ( X + Y + Z ) y = Y / ( X + Y + Z ) z = Z / ( X + Y + Z ) * Commission Internationale de l'Êclairage

Spring 2013 Utah School of Computing 59

CIE Color Space of Visible Colors

x + y + z = 1 x = X / ( X + Y + Z ) y = Y / ( X + Y + Z ) z = Z / ( X + Y + Z ) z y x The projection of the plane of the triangle onto the (X,Y) plane forms the chromaticity diagram that follows.

Spring 2013 Utah School of Computing 60

Color Gamuts: CIE Color Chart

ideal red ideal red ideal red ideal blue ideal blue ideal blue Ideal green Ideal green Ideal green red red blue blue green green cyan cyan yellow yellow white white white

400 nm 490 nm 500 nm 510 nm 540 nm 560 nm 580 nm 700 nm 600 nm 520 nm

slide-11
SLIDE 11

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 61

Color Gamuts: CIE Color Chart Color Gamuts: CIE Color Chart

www.cs.rit.edu/~ncs/color/a_chroma.html

40 0 490 50 0 510 520 60 0 70 0 580 560 54 0 Spring 2013 Utah School of Computing 62

Color Gamuts: CIE Color Chart Color Gamuts: CIE Color Chart

www.cs.rit.edu/~ncs/color/a_chroma.html

700 nm 510 nm 400 nm 500 nm 490 nm 600 nm 520 nm 540 nm 560 nm 580 nm

Spring 2013 Utah School of Computing 63

Color Gamuts: CIE Color Chart Color Gamuts: CIE Color Chart

www.cs.rit.edu/~ncs/color/a_chroma.html

40 0 490 50 0 510 520 60 0 70 0 580 560 54 0

C2 C3 C1

The additive colors C1and C2 combine to form C3 on the line connecting C1 and C2.

Spring 2013 Utah School of Computing 64

Color Gamuts: CIE Color Chart

y

x

1.0 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1

1.0 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

cyan cyan magenta magenta red red blue blue green green yellow yellow

400 490 500 510 520 600 700 580 560 540

white white white

Spring 2013 Utah School of Computing 65

Color Gamuts: CIE Color Chart Color Gamuts: CIE Color Chart

www.cs.rit.edu/~ncs/color/a_chroma.html

40 0 490 50 0 510 520 60 0 70 0 580 560 54 0

R B G

The Color Gamuts of different displays and printers are not likely to match. Printers usually have smaller gamuts.

Spring 2013 Utah School of Computing 66

Gamuts

slide-12
SLIDE 12

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 67

CIE L*a*b* Color Space

green green green

  • b

* b * L*=0 L*=1

lightness

r e d r e d r e d b l u e b l u e b l u e

+a* + +a a* *

  • a*
  • a*

a*

yellow yellow yellow

+b* +b* +b*

Equal distances represent approximately equal color difference.

white white white black black black

Spring 2013 Utah School of Computing 68

Trichromatic Theory Shortcomings

  • Color blindness

–R-G, B-Y, All

  • Yellow seems primary
  • Color constancy

Spring 2013 Utah School of Computing 69

Color Blindness

Normal Protan (L-cone) Deutan (M-cone) Tritan (S-cone)

Spring 2013 Utah School of Computing 70

Mondrian Color Patches

  • Colors look different

depending on their neighbors

  • Adjacency/black lines
  • Color edges are critical to

color perception

  • Can determine color in

non-white lighting conditions

Spring 2013 Utah School of Computing 71 Spring 2013 Utah School of Computing 72

slide-13
SLIDE 13

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 73

Opponent Color Theory

  • Humans encode colors by differences
  • E.g R-G, and B-Y Differences

–Color blindness

Long (R) Medium (G) Short (B)

+

  • R - G

Y-B Achromatic Yellow Spring 2013 Utah School of Computing 74

Perceptual Distortions

  • Color-deficiency
  • Interactions between color components

– brightness - hue (Bezold-Brucke Phenomenon) – saturation - brightness (Helmholtz-Kohlraush effect)

  • Simultaneous contrast

– brightness – hue

  • Small field achrominance
  • Effects of color on perceived size

Spring 2013 Utah School of Computing 75

Bezold-Brucke Phenomenon

  • Hurvich ‘81, pg. 73.

Spring 2013 Utah School of Computing 76

Bezold-Brucke Phenomenon

  • Hurvich ‘81, pg. 73.

Spring 2013 Utah School of Computing 77

Helmholtz-Kohlrausch effect

Spring 2013 Utah School of Computing 78

Simultaneous Contrast

slide-14
SLIDE 14

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 79

Simultaneous Contrast

Spring 2013 Utah School of Computing 80

Simultaneous Contrast

Spring 2013 Utah School of Computing 81

Mach Banding

Spring 2013 Utah School of Computing 82 Spring 2013 Utah School of Computing 83

Chromatic Adaptation

Spring 2013 Utah School of Computing 84

slide-15
SLIDE 15

Utah School of Computing Spring 2013 Computer Graphics CS5600

Spring 2013 Utah School of Computing 85 Spring 2013 Utah School of Computing 86

Color Applets

www.cs.brown.edu/exploratories/freeSoftware/repository/ edu/brown/cs/exploratories/applets/combinedColorMixing /combined_color_mixing_java_browser.html

Spring 2013 Utah School of Computing 87

Lecture Set 1