Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading...

44
1 Color • Reading: – Chapter 6, Forsyth & Ponce Optional reading: – Chapter 4 of Wandell, Foundations of Vision, Sinauer, 1995 has a good treatment of this. Oct. 1, 2002 MIT 6.801/6.866 Profs. Freeman and Darrell

Transcript of Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading...

Page 1: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

1

Color

• Reading: – Chapter 6, Forsyth & Ponce

• Optional reading:– Chapter 4 of Wandell, Foundations of Vision,

Sinauer, 1995 has a good treatment of this.

Oct. 1, 2002MIT 6.801/6.866Profs. Freeman and Darrell

Page 2: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

2

Shape-from-shading

• Reading: – Chapter 11 (esp. 11.1, 11.7), Horn

Oct. 1, 2002MIT 6.801/6.866Profs. Freeman and Darrell

Page 3: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

3

linear filters (Thursday & next Tuesday)

• Reading: – Chapter 7, F&P

• Recommended Reading: – Chapter 7, 8 Horn

Oct. 1, 2002MIT 6.801/6.866Profs. Freeman and Darrell

Page 4: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

4

Color matching experiment

Foundations of Vision, by Brian Wandell, Sinauer Assoc., 1995

Page 5: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

5

Color matching functions for a particular set of monochromatic primaries

p1 = 645.2 nmp2 = 525.3 nmp3 = 444.4 nm

Foundations of Vision, by Brian Wandell, Sinauer Assoc., 1995

Page 6: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

6

Using the color matching functions to predict the primary match for a new spectral signal

=

)()()()()()(

313

212

111

N

N

N

cccccc

Cλλλλλλ

L

L

L

Store the color matching functions in the rows of the matrix, C

=

)(

)( 1

Nt

tt

λ

λM

r

Let the new spectral signal to be characterized be the vector t.

Then the amounts of each primary needed to match t are:

tCr

Page 7: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

7

CIE XYZ: Color matching functions are positive everywhere, but primaries are imaginary. Usually draw x, y, where x=X/(X+Y+Z)

y=Y/(X+Y+Z)

Foundations of Vision, by Brian Wandell, Sinauer Assoc., 1995

Page 8: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

8

Page 9: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

9

Color metamerism

Two spectra, t and s, perceptually match when

where C are the color matching functions for some set of primaries.

sCtC r=

r

C

tr

Csr=

Graphically,

Page 10: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

10

Metameric lights

Foundations of Vision, by Brian Wandell, Sinauer Assoc., 1995

Page 11: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

11

Metamerism applications

The word “VOID” wasn’t visible on the check, when viewed by eye, only after xerox copying did it appear.

Page 12: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

12

Color appearance

• Or, color matching outside of the controlled experimental setup.

Page 13: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

13

Spatial effects on color appearance

Page 14: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

14Forsyth & Ponce

Page 15: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

15Forsyth & Ponce

Page 16: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

16

demos

lightnesscolor

Page 17: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

17

Outline

• Color physics.• Color perception and color matching.• Inference about the world from color

observations.

Page 18: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

18

What does a color reaching your eye tell you about the world?

=.*

Foundations of Vision, by Brian Wandell, Sinauer Assoc., 1995

Page 19: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

19

General strategies

• (a) Determine what image would look like under white light, or (b) surface reflectances

• Assume – that we are dealing with flat

frontal surfaces– We’ve identified and

removed specularities– no variation in illumination

• We need some form of reference– brightest patch is white– spatial average is

known– gamut is known– specularities– prior probabilities for

lights and surfaces

Forsyth & Ponce

Page 20: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

20

Low-dimensional models for color spectra

=

3

2

1

321 )()()()(ωωω

λλλλM

M

M

M

M

M

M

M

EEEe

Page 21: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

21

Basis functions for Macbeth color checker

Foundations of Vision, by Brian Wandell, Sinauer Assoc., 1995

Page 22: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

22

Low-dimensional models for color spectra

Foundations of Vision, by Brian Wandell, Sinauer Assoc., 1995

Page 23: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

23

The rendering model (using linear combinations of spectral basis functions to

represent both surfaces and lights)

skp

Spectral response of sensors

.*

∑ ∑∑

=

λ

λψλφλi

iij

jsjk

sk ercp )()()(

sjr

)(λφ j

ie)(λψ i

)(λkc

Surface spectral basis functions

Surface basis coefficients

Illuminant spectral basis

functions

illuminant basis

coefficients

=Response of kth

sensor to the jth

surface patch

Page 24: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

24

Count unknowns and equations

• Suppose you use a 3-dimensional linear model for both the illuminant and surfaces (two different linear models of the same dimensionality). Suppose have N surfaces.

• 3 + 3N unknowns• 3N measurements

Page 25: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

25

A possible assumption: know the mean surface value

∑ ∑∑

=

λ

λψλφλi

iij

jsjk

sk ercp )()()(

Sum over and j to writeλ

∑ ∑∑

=

λ

λψλφλi

iij

jsjk

sk ercp )()()(

Sensor responses, as function of surfaces and lights, from before:

Average over all the N surfaces:

Aep =In general, A will be invertible and the estimated illuminant, e, under the “gray world” assumption, is:

epA-1 =

Page 26: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

26

Shape from shading

Page 27: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

27

Horn, 1986

),(),(),,,(ii

eeeeii E

LfBRDFφθφθφθφθ ==

Page 28: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

28

Generic reflectance map

Horn, 1986

Page 29: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

29

Remember, this model doesn’t handle properly:

• Occluding edges• Albedo changes• Perspective effects (small)• Interreflections• Material changes across surfaces in the

image

Page 30: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

30Freeman, 1994

Page 31: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

31Freeman, 1994

Page 32: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

32

Linear shading map

Horn, 1986

Page 33: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

33

Linear shading: 1st order terms of Lambertian shading

2222 111),(

ss

ss

qpqpqqppkqpR

++++

++=

Lambertian point source

qqqpRp

pqpRk

qpqp 0,00,02

),(),( ==== ∂

∂+

∂∂

+≈

1st order Taylor series about p=q=0

)1( 2 qqppk ss ++=

See Pentland, IJCV vol. 1 no. 4, 1990.

Page 34: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

34

Linear shading approximation

range image Lambertian shading

quadratic terms higher-order termslinear shading

Pentland 1990, Adelson&Freeman, 1991

Page 35: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

35

Simplified lighting assumption

• For simplicity, and without loss of generality, let’s consider light source from the left.

• Then rendered image is proportional to the derivative of the range image along a row

Page 36: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

36

Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N)

• Image, one row: I(n) =[17 14 12 4 4 9 25 …]

• Shape, same row: S(n) =[0 17 31 43 47 51 60 85…]

or S(n) =[-17 0 14 26 30 34 41 66…]or etc.

Page 37: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

37

Illustrates a general problem

• Each row can have a different constant of integration.

• Typical of shape-from-shading problems: extra knowledge has to be put in, or extra assumptions have to be made:– Boundary conditions– Regularization terms

Page 38: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

38

Shape-from-shading as prototypical vision computation

Want to estimate scene parameters (surface slopes p and q at every image position, i, j).

Have a rendering function that takes you from some given set of scene parameters to observation data (reflectance map R(p,q) gives image intensity for any p, q).

Want to find the parameters (pi,j, qi,j) that minimize the difference from the observations (Ei,j).

But the problem is “ill-posed”, or underspecified from that constraint alone. So add-in additional requirements that the scene parameters must satisfy (the surface slopes p and q must be smooth at every point).

Page 39: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

39

Shape-from-shading as prototypical vision computation

( ) ( ) ( ) ( )( )2,1,

2,,1

2,1,

2,,1, 4

1jijijijijijijijiji qqqqpppps −+−+−+−= ++++

smoothness at i,j [Bayesian: prior]

( )( )2, ijijsijij qpREr −=error in image irradiance at i,j [Bayesian: likelihood]

Page 40: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

40

Shape-from-shading as prototypical vision computation( ) ( ) ( ) ( )( )2

,1,2

,,12

,1,2

,,1, 41

jijijijijijijijiji qqqqpppps −+−+−+−= ++++

( )( )2, ijijsijij qpREr −=

( )∑∑ +=i j

ijij rse λMinimize regularized function [Bayesian: maximize posterior]

This approach is used in many different vision problems. See poggio nature paper, horn work, szeliski paper, etc. Relation to Bayesian methods will be discussed later.

Page 41: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

41

Look for stationary points( ) ( ) ( ) ( )( )2

,1,2

,,12

,1,2

,,1, 41

jijijijijijijijiji qqqqpppps −+−+−+−= ++++

( )( )2, ijijsijij qpREr −=

( )∑∑ +=i j

ijij rse λ

( ) ( )( )

( ) ( )( )qRqpREqq

qe

pRqpREpp

pe

sklklsklklkl

kl

sklklsklklkl

kl

∂∂

−−−=∂∂

∂∂

−−−=∂∂

,22

,22

λ

λ

Differentiate error term w.r.t. shape parameters

( )

( )1,,11,,1

1,,11,,1

4141

−−++

−−++

+++=

+++=

jijijijikl

jijijijikl

qqqqq

pppppwhere

Page 42: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

42

Set derivatives = 0( ) ( ) ( ) ( )( )2

,1,2

,,12

,1,2

,,1, 41

jijijijijijijijiji qqqqpppps −+−+−+−= ++++

( )( )2, ijijsijij qpREr −=( )∑∑ +=

i jijij rse λ

( ) ( )( )

( ) ( )( )qRqpREqq

qe

pRqpREpp

pe

sklklsklklkl

kl

sklklsklklkl

kl

∂∂

−−−=∂∂

∂∂

−−−=∂∂

,22

,22

λ

λ

( )( )

( )( )qRqpREqq

pRqpREpp

sklklsklklkl

sklklsklklkl

∂∂

−+=

∂∂

−+=

,

,

λ

λ

Rearranging terms, find a necessary condition for local max of function to be optimized, e:

Page 43: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

43

Set derivatives = 0

( )( )

( )( )qRqpREqq

pRqpREpp

sklklsklklkl

sklklsklklkl

∂∂

−+=

∂∂

−+=

,

,

λ

λ

This suggests an iterative algorithm (keep insisting that the condition be met, until it is): ( )( )

( )( )qRqpREqq

pRqpREpp

snkl

nklskl

nkl

nkl

snkl

nklskl

nkl

nkl

∂∂

−+=

∂∂

−+=

+

+

,

,

1

1

λ

λ

( ) ( ) ( ) ( )( )2,1,

2,,1

2,1,

2,,1, 4

1jijijijijijijijiji qqqqpppps −+−+−+−= ++++

( )( )2, ijijsijij qpREr −=( )∑∑ +=

i jijij rse λ

( ) ( )( )

( ) ( )( )qRqpREqq

qe

pRqpREpp

pe

sklklsklklkl

kl

sklklsklklkl

kl

∂∂

−−−=∂∂

∂∂

−−−=∂∂

,22

,22

λ

λ

Page 44: Shape-from-shading - MIT CSAIL · 2002. 10. 4. · Simplified linear shape from shading computation, for I(n) = S(n+1)-S(N) • Image, one row: I(n) =[17 14 12 4 4 9 25 …] • Shape,

44

• Show fig. 11-10, 11-11.

Horn, 1986

Results using this approach