Shading, Shadows, Lights, and shape from...

49
CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005 Shading, Shadows, Lights, and shape from shading

Transcript of Shading, Shadows, Lights, and shape from...

Page 1: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

Shading, Shadows, Lights, and shapefrom shading

Page 2: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

n̂θ

δA

δI

αzf

Surface Radiance and Image Irradiance

α

22 )cos/(cos

)cos/(cos

ααδ

αθδ

fI

zA

=2

coscos

=

fz

IA

θα

δδ

Same solid angle

PinholeCameraModel

Page 3: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

n̂δA

δI

αzf

d

Surface Radiance and Image Irradiance

α

απ

ααπ 3

2

2

2

cos4)cos/(

cos4

==Ωzd

zd

Solid angle subtended by the lens, as seen by the patch δA

θαπ

δθδδ coscos4

cos 32

=Ω=zdALALP

Power from patch δA through the lens

Ω

απ

θαπ

δδ

δδ 4

23

2

cos4

coscos4

=

==fdL

zd

IAL

IPE

Thus, we conclude

Page 4: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

n̂δA

δI

αzf

d

Surface Radiance and Image Irradiance

αΩ

απ

θαπ

δδ

δδ 4

23

2

cos4

coscos4

=

==fdL

zd

IAL

IPE

E ∝Le Image intensity isproportional to ExidentRadiance

Page 5: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Radiance emitted by point sources• small, distant sphere

radius ε and uniformradiance E, which is faraway and subtends asolid angle of about

Ω = πεd

2

Le = ρd x( ) Li x,ω( )cosθidωΩ

∫= ρd x( ) Lidω cosθi

Ω

≈ ρd x( ) εr(x)

2

E cosθi

= kρd x( )cosθi

r x( )2

Page 6: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Standard nearby point source model• N is the surface normal

• rho is diffuse albedo

• S is source vector - a vectorfrom x to the source, whoselength is the intensity term– works because a dot-product

is basically a cosine

ρd x( ) N x( ) •S x( )r x( )2

Page 7: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Standard distant point source model• Issue: nearby point source

gets bigger if one gets closer– the sun doesn’t for any

reasonable binding of closer

• Assume that all points in themodel are close to eachother with respect to thedistance to the source.Then the source vectordoesn’t vary much, and thedistance doesn’t vary mucheither, and we can roll theconstants together to get:

ρd x( ) N x( )• Sd x( )( )

Page 8: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Line sources

radiosity due to line source varies with inverse distance, if the source is long enough.

For a finite line source centeredon the plane, there is spatialvariation across the surface

Page 9: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Area sources• Examples: diffuser boxes,

white walls.

• The radiosity at a point dueto an area source isobtained by adding up thecontribution over the sectionof view hemispheresubtended by the source– change variables and add up

over the source

Page 10: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Area Source Shadows

Page 11: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Shading models• Local shading model

– Surface has radiosity dueonly to sources visible ateach point

– Advantages:• often easy to manipulate,

expressions easy

• supports quite simple theoriesof how shape information canbe extracted from shading

• Global shading model– surface radiosity is due to

radiance reflected from othersurfaces as well as fromsurfaces

– Advantages:• usually very accurate

– Disadvantage:• extremely difficult to infer

anything from shading values

Page 12: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Photometric stereo

• Assume:– a local shading model

– a set of point sources that are infinitely distant

– a set of pictures of an object, obtained in exactly the samecamera/object configuration but using different sources

– A Lambertian object (or the specular component has beenidentified and removed)

Page 13: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Projection model for surface recovery - usually calleda Monge patch

z = f (x, y)

r n =∂z /∂x∂z /∂y

1

ˆ n = r n / r n €

ˆ n

Page 14: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Image model• For each point source, we

know the source vector (byassumption). We assumewe know the scalingconstant of the linearcamera. Fold the normaland the reflectance into onevector g, and the scalingconstant and source vectorinto another Vj

• Out of shadow:

• In shadow:

I j(x,y) = 0

I j (x, y) = kB(x, y)

= kρ(x, y) N(x, y) •S j( )= g(x, y)•Vj

Page 15: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA
Page 16: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

Surface normals

Page 17: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

l1 =

− 200

l2 =

200

Surface NormalLight directionsDefined relative to local surface patch

Page 18: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Basic Equation

ValuesOf images atPixel (x,y)

Matrix stackOf light sourcesFor each of the nimages

Unknown

Problem- Nonlinear due to shadowing

n x 3n x 1

I1(x,y)I2(x,y)

L

In (x,y)

= max

V1T

V1T

L

VnT

g(x,y),r 0

. .

etc

I1(x,y)

I2(x,y)

In (x,y)

.

Page 19: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Dealing with shadows

I12(x, y)I22(x, y)..

In2(x, y)

=

I1(x, y) 0 .. 00 I2(x, y) .. .... .. .. 00 .. 0 In(x, y)

V1T

V2T

..Vn

T

g(x, y)

Known Known Known Unknown

r b = Ar x General form:

n x 3n x 1

For each x,y point

Page 20: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Recovering normal and reflectance• Given sufficient sources, we can solve the previous

equation (most likely need a least squares solution) for g(x, y) = ρ(x,y) N(x, y)• Recall that N(x, y) is the unit normal• This means that ρ(x,y) is the magnitude of g(x, y)• This yields a check

– If the magnitude of g(x, y) is greater than 1, there’s aproblem

• And N(x, y) = g(x, y) / ρ(x,y)

Page 21: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Example figures

Page 22: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Recovered reflectance

Page 23: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Recovered normal field

Page 24: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Recovering a surface from normals - 1• Recall the surface is written

as

• This means the normal hasthe form:

• If we write the known vectorg as

• Then we obtain values forthe partial derivatives of thesurface:

(x, y, f (x, y))

g(x, y) =

g1(x, y)g2 (x, y)g3(x, y)

fx (x, y) = g1(x, y) g3(x, y)( )

fy(x, y) = g2(x, y) g3(x, y)( )

N(x, y) =1

fx2 + fy

2 +1

− fx− fy1

Page 25: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Recovering a surface from normals - 2• Recall that mixed second partials

are equal --- this gives us acheck. We must have:

(or they should be similar, at least)

• We can now recover thesurface height at any pointby integration along somepath, e.g.

∂ g1(x, y) g3(x, y)( )∂y

=

∂ g2(x, y) g3(x, y)( )∂x

f (x, y) = fx (s, y)ds0

x

∫ +

fy (x, t)dt0

y

∫ + c

Page 26: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Surface recovered by integration

Page 27: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Shape from Shading with ambiguity

What to do if light source unknown?

Only one image?

Ans: Use prior knowledge in the form of constraints(e.g. regularization methods, Bayesian methods), takeadvantage of the habits (regularities) of images.

Page 28: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Horn’s approach

• Want to estimate scene parameters (surface slopes fx(x,y) and fy(x,y) atevery image position, (x,y).

• Have a rendering function that takes you from some given set of sceneparameters to observation data (e.g. r(x,y) n(x,y) gives image intensity for any(x,y)).

• Could try to find the parameters fx(x,y) & fy(x,y) that minimize thedifference from the observations I(x,y).

• But the problem is “ill-posed”, or underspecified from that constraint alone.So add-in additional requirements that the scene parameters must satisfy (thesurface slopes fx(x,y) & fy(x,y) must be smooth at every point).

Page 29: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

RegularizationFor each normal, compute the distance fromthe normal to its neighbors:

Prior/regularizer

s(i, j) =r n i + k, j + l( ) −

r n (i, j)( )2

k={−1,1}∑l={−1,1}∑

Intensity Error

r(i, j) = I i, j( ) − Ipred (i, j)( )2

Err = r(i, j) + λs(i, j)i, j∑

Page 30: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

Shape from Shading Ambiguity

Page 31: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

CSCI 5561: Computer Vision, Prof. Paul Schrater, Spring 2005

Page 32: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Curious Experimental Fact

• Prepare two rooms, one with white walls and whiteobjects, one with black walls and black objects

• Illuminate the black room with bright light, the whiteroom with dim light

• People can tell which is which (due to Gilchrist)

• Why? (a local shading model predicts they can’t).

Page 33: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Figure from “Mutual Illumination,” by D.A. Forsyth and A.P. Zisserman, Proc. CVPR, 1989, copyright 1989 IEEE

A view of awhite room,under dim light.Below, we see across-section ofthe imageintensitycorresponding tothe line drawnon the image.

Page 34: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Figure from “Mutual Illumination,” by D.A. Forsyth and A.P. Zisserman, Proc. CVPR, 1989, copyright 1989 IEEE

A view of a blackroom, underbright light.Below, we see across-section ofthe imageintensitycorresponding tothe line drawnon the image.

Page 35: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

What’s going on here?

• local shading model is a poor description of physicalprocesses that give rise to images– because surfaces reflect light onto one another

• This is a major nuisance; the distribution of light (inprinciple) depends on the configuration of everyradiator; big distant ones are as important as smallnearby ones (solid angle)

• The effects are easy to model

• It appears to be hard to extract information from thesemodels

Page 36: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Interreflections - a global shading model• Other surfaces are now area sources - this yields:

• Vis(x, u) is 1 if they can see each other, 0 if they can’t

Radiosity at surface = Exitance + Radiosity due to other surfaces

B x( ) = E x( ) + ρd x( ) B u( )cosθi cosθsπr(x,u)2 Vis x,u( )dAu

all othersurfaces

Page 37: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

What do we do about this?

• Attempt to build approximations– Ambient illumination

• Study qualitative effects– reflexes

– decreased dynamic range

– smoothing

• Try to use other information to control errors

Page 38: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Shadows cast by a point source• A point that can’t see the

source is in shadow

• For point sources, thegeometry is simple

Page 39: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Ambient Illumination• Two forms

– Add a constant to the radiosity at every point in the scene toaccount for brighter shadows than predicted by point sourcemodel

• Advantages: simple, easily managed (e.g. how would you changephotometric stereo?)

• Disadvantages: poor approximation (compare black and whiterooms

– Add a term at each point that depends on the size of theclear viewing hemisphere at each point (see next slide)

• Advantages: appears to be quite a good approximation, but jury isout

• Disadvantages: difficult to work with

Page 40: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

At a point inside a cube or room, the surface sees light in alldirections, so add a large term. At a point on the base of a groove,the surface sees relatively little light, so add a smaller term.

Page 41: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Reflexes

• A characteristic feature of interreflections is little brightpatches in concave regions– Examples in following slides

– Perhaps one should detect and reason about reflexes?

– Known that artists reproduce reflexes, but often too big andin the wrong place

Page 42: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Figure from “Mutual Illumination,” by D.A. Forsyth and A.P. Zisserman, Proc. CVPR, 1989, copyright 1989 IEEE

At the top, geometry of asemi-circular bump on aplane; below, predictedradiosity solutions, scaledto lie on top of each other,for different albedos ofthe geometry. Whenalbedo is close to zero,shading follows a localmodel; when it is close toone, there are substantialreflexes.

Page 43: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Radiosity observed in animage of this geometry;note the reflexes, whichare circled.

Figure from “Mutual Illumination,” by D.A. Forsyth and A.P. Zisserman, Proc. CVPR, 1989, copyright 1989 IEEE

Page 44: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Figure from “Mutual Illumination,” by D.A. Forsyth and A.P. Zisserman, Proc. CVPR, 1989, copyright 1989 IEEE

At the top, geometry of agutter with triangularcross-section; below,predicted radiositysolutions, scaled to lie ontop of each other, fordifferent albedos of thegeometry. When albedois close to zero, shadingfollows a local model;when it is close to one,there are substantialreflexes.

Page 45: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Radiosity observed in animage of this geometry;above, for a black gutterand below for a white one

Figure from “Mutual Illumination,” by D.A. Forsyth and A.P. Zisserman, Proc. CVPR, 1989, copyright 1989 IEEE

Page 46: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Figure from “Mutual Illumination,” by D.A. Forsyth and A.P. Zisserman, Proc. CVPR, 1989, copyright 1989 IEEE

At the top, geometry of agutter with triangularcross-section; below,predicted radiositysolutions, scaled to lie ontop of each other, fordifferent albedos of thegeometry. When albedois close to zero, shadingfollows a local model;when it is close to one,there are substantialreflexes.

Page 47: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Radiosity observed in animage of this geometryfor a white gutter.

Figure from “Mutual Illumination,” by D.A. Forsyth and A.P. Zisserman, Proc. CVPR, 1989, copyright 1989 IEEE

Page 48: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Smoothing

• Interreflections smooth detail– E.g. you can’t see the pattern of a stained glass window by

looking at the floor at the base of the window; at best, you’llsee coloured blobs.

– This is because, as I move from point to point on a surface,the pattern that I see in my incoming hemisphere doesn’tchange all that much

– Implies that fast changes in the radiosity are localphenomena.

Page 49: Shading, Shadows, Lights, and shape from shadingvision.psych.umn.edu/users/schrater/schrater_lab/courses/CompVis0… · Shading, Shadows, Lights, and shape from shading. n ˆ θ δA

Fix a small patch near alarge radiator carrying aperiodic radiosity signal;the radiosity on the surfaceis periodic, and its amplitudefalls very fast with thefrequency of the signal. Thegeometry is illustratedabove. Below, we show agraph of amplitude as afunction of spatialfrequency, for differentinclinations of the smallpatch. This means that ifyou observe a highfrequency signal, it didn’tcome from a distant source.