Top Banner
5C-L1 Shape from shading CS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys
34

CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

May 24, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

5C-L1 Shape from shading

CS4495/6495 Introduction to Computer Vision

Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys

Page 2: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Shape from shading

Shading as a cue for shape reconstruction

Page 3: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Shape from shading/lighting

What is the relation between intensity and shape?

โ€ข Need to look at the reflectance function

โ€ข Reflectance Map

Page 4: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Surface normals: A bit of math

โ€ข Letโ€™s assume we have a surface ๐‘ง(๐‘ฅ, ๐‘ฆ)

โ€ขWe can define the following:

โˆ’๐œ•๐‘ง

๐œ•๐‘ฅ= ๐‘ โˆ’

๐œ•๐‘ง

๐œ•๐‘ฆ= ๐‘ž

Page 5: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Surface Normal: A bit more math surface normal

๐‘ฅ ๐‘ฆ

z

๐ Suppose we have a point on the surface. We can define two tangents: ๐‘ก๐‘ฅ = 1,0,โˆ’๐‘ ๐‘‡and ๐‘ก๐‘ฆ = 0,1,โˆ’๐‘ž ๐‘‡

2 2

| | |

1, ,1

| 1

x y

x y

Tt tN

Np q

p qt t

n

Page 6: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Surface Normal: Gaussian sphere surface normal

๐‘ฅ ๐‘ฆ

z

๐

Page 7: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Surface Normal: Gradient space projection surface normal

๐‘ฅ ๐‘ฆ

z

๐

Page 8: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Surface Normal: Gradient space projection surface normal

๐‘ฅ ๐‘ฆ

z

๐

p

q (๐’‘๐ŸŽ, ๐’’๐ŸŽ)

๐‘ง = 1 plane is called Gradient Space (๐‘๐‘ž plane)

Page 9: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Gradient Space of Source and Normal z

๐‘ฅ ๐‘ฆ

๐‘

๐‘ž

1

๐‘ง = 1

๐’ ๐

๐ง ๐ฌ

Unit normal vector:

๐ง =๐

|๐|=

๐‘, ๐‘ž, 1

๐‘2 + ๐‘ž2 + 1

Unit source vector:

๐ฌ =๐’

|๐’|=

๐‘๐‘†, ๐‘ž๐‘†, 1

๐‘๐‘†2 + ๐‘ž๐‘†

2 + 1

Normal vector

Unit normal vector

Source vector

Unit source vector

Page 10: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Gradient Space of Source and Normal z

๐‘ฅ ๐‘ฆ

๐œƒ๐‘– ๐‘

๐‘ž

1

๐‘ง = 1

๐’ ๐

๐ง ๐ฌ

Unit normal vector:

๐ง =๐

|๐|=

๐‘, ๐‘ž, 1

๐‘2 + ๐‘ž2 + 1

Unit source vector:

๐ฌ =๐’

|๐’|=

๐‘๐‘†, ๐‘ž๐‘†, 1

๐‘๐‘†2 + ๐‘ž๐‘†

2 + 1

cos๐œƒ๐‘– = ๐ง โ‹… ๐ฌ =๐‘๐‘๐‘† + ๐‘ž๐‘ž๐‘† + 1

๐‘2 + ๐‘ž2 + 1 ๐‘๐‘†2 + ๐‘ž๐‘†

2 + 1

Page 11: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Shape from shading: Problem definition

๐ผ(๐‘ฅ, ๐‘ฆ) ๐‘(๐‘ฅ, ๐‘ฆ)

Output: 3D shape of object Input: 1 or more images

Page 12: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Reflectance Map

Relates image brightness ๐ผ(๐‘ฅ, ๐‘ฆ) to surface orientation (๐‘, ๐‘ž) for given source direction and surface reflectance

Page 13: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Reflectance Map: Lambertian case

Terms: ๐‘˜: source brightness ๐œŒ: surface albedo (reflectance)

Image brightness:

๐ผ = ๐œŒ โ‹… ๐‘˜ โ‹… cos๐œƒ๐‘– = ๐œŒ โ‹… ๐‘˜ (๐ง โ‹… ๐ฌ)

Let ๐œŒ โ‹… ๐‘˜ = 1 then ๐ผ = cos๐œƒ๐‘– = ๐ง โ‹… ๐ฌ

๐ผ(๐‘ฅ, ๐‘ฆ)

๐œƒ๐‘– ๐ฌ

๐ง

๐ฏ

Page 14: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Reflectance Map: Lambertian case

cone of constant ๐œƒ๐‘–

Iso-brightness contour in pq space

๐ผ = cos๐œƒ๐‘– = ๐ง โ‹… ๐ฌ =๐‘๐‘๐‘  + ๐‘ž๐‘ž๐‘  + 1

๐‘2 + ๐‘ž2 + 1 ๐‘๐‘†2 + ๐‘ž๐‘†

2 + 1

= ๐‘… ๐‘, ๐‘ž

Reflectance Map (Lambertian)

Page 15: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Note: ๐‘… ๐‘, ๐‘ž is maximum when ๐‘, ๐‘ž = ๐‘๐‘†, ๐‘ž๐‘†

๐œƒ๐‘– = 90โˆ˜ ๐‘๐‘๐‘† + ๐‘ž๐‘ž๐‘† + 1 = 0

0.0

0.3

๐‘

๐‘… ๐‘, ๐‘ž = 0.7

0.8

0.9

1.0

๐‘๐‘ , ๐‘ž๐‘ 

๐‘ž

Iso-brightness contours

Page 16: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Shape from a single image?

Given ๐‘…(๐‘, ๐‘ž) ((๐‘๐‘†, ๐‘ž๐‘†) and surface reflectance) can we determine (๐‘, ๐‘ž) uniquely for each image point?

NO ๐‘

๐‘ž

Page 17: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Shape from Shading

Need more information:

โ€ขAdd more constraints: Shape-from-shading

โ€ข Take more images: Photometric stereo

Page 18: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Given a single image of an object with known surface reflectance taken under a known light source, can we recover its shape?

Shape from shading

Page 19: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Given ๐‘…(๐‘, ๐‘ž) ((๐‘๐‘†, ๐‘ž๐‘†) and surface reflectance) can we determine (๐‘, ๐‘ž) uniquely for each image point?

โ€ข Assume shape along the occluding boundary is known

โ€ข Constraints on neighboring normals โ€” integrability

โ€ข Smoothness

Shape from shading

Yes, a slightly ugly optimization

Page 20: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Synthetic results

Page 21: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Shape from Shading: โ€œRealโ€ Results

โ€ข These single image methods work poorly in practice

โ€ข Why? The assumptions are quite restrictive

Page 22: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Shape from Shading

Need more information:

โ€ขAdd more constraints: Shape-from-shading

โ€ข Take more images: Photometric stereo

Page 23: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Photometric stereo Output:

โ€ข 3D shape of object

โ€ข Albedo at (๐‘ฅ, ๐‘ฆ)

Input: Several images

โ€ข Same object

โ€ข Different lightings

โ€ข Same pose

Page 24: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Photometric stereo Image brightness:

๐ง

๐ฌ๐Ÿ

๐ฌ๐Ÿ‘

๐ฏ

๐ฌ๐Ÿ

๐ผ1 = ๐œŒ๐ง โˆ™ ๐ฌ๐Ÿ

๐ผ2 = ๐œŒ๐ง โˆ™ ๐ฌ๐Ÿ

๐ผ3 = ๐œŒ๐ง โˆ™ ๐ฌ๐Ÿ‘

๐ผ = ๐œŒ โ‹… ๐‘˜ โ‹… cos๐œƒ๐‘– = ๐œŒ๐ง โ‹… ๐ฌ where k = 1

Write this as a matrix equation:

๐ผ1๐ผ2๐ผ3

= ๐œŒ๐ฌ๐Ÿ

๐‘‡

๐ฌ๐Ÿ ๐‘‡

๐ฌ๐Ÿ‘ ๐‘‡

๐ง

Page 25: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Solving the equations: Linear

๐ผ1๐ผ2๐ผ3

=๐ฌ๐Ÿ

๐‘‡

๐ฌ๐Ÿ ๐‘‡

๐ฌ๐Ÿ‘ ๐‘‡

๐œŒ๐ง

๐ˆ ๐’ ๐ง 3 ร— 1 3 ร— 3 3 ร— 1

๐ง = ๐’โˆ’1๐ˆ

๐œŒ = ๐ง

๐ง =๐ง

๐ง =๐ง

๐œŒ

๐ˆ and ๐’ are known

inverse

Page 26: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Adding more light sources

Get better results by using more (๐‘€) lights:

๐ผ1โ‹ฎ๐ผ๐‘€

=๐ฌ๐Ÿ

๐‘‡

โ‹ฎ๐ฌ๐‘€

๐‘‡

๐œŒ๐ง

Least squares solution:

๐ˆ = ๐’๐ง ๐’๐‘‡๐ˆ = ๐’๐‘‡๐’๐ง ๐ง = ๐’๐‘‡๐’ โˆ’๐Ÿ๐’๐‘‡๐ˆ

Solve for๐œŒ, ๐ง as before

๐‘€ ร— 1 = ๐‘€ ร— 3 3 ร— 1

Moore-Penrose pseudo inverse min ๐ˆ โˆ’ ๐’๐ง 2

2

Page 27: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Photometric stereo: pq space

๐‘

๐‘ž

๐‘๐‘ 1, ๐‘ž๐‘ 

1

๐‘๐‘ 2, ๐‘ž๐‘ 

2

๐‘๐‘ 3, ๐‘ž๐‘ 

3

Page 28: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Results: Lambertian sphere

Input Images

Estimated Albedo Estimated Surface Normals

Needles are projections of surface normal on image plane

Page 29: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Photometric stereo: Lambertian toy

Input Images

Estimated Surface Normals Estimated Albedo

Surface Normals

Albedo

Page 30: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

And from GT: www.trimensional.com

Page 31: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Photometric stereo: Limitations

Big problems โ€ข Doesnโ€™t work for shiny things, semi-translucent things โ€ข Shadows, inter-reflections Smaller problems โ€ข Camera and lights have to be distant โ€ข Calibration requirements

โ€“ Measure light source directions, intensities โ€“ Camera response function

Page 32: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

A real application that works

Page 33: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

A real application that works

Page 34: CS4495/6495 Introduction to Computer VisionCS4495/6495 Introduction to Computer Vision Thanks to Srinivasa Narasimhan, Shree Nayar, David Kreigman, Marc Pollefeys Shape from shading

Human shape from shading

Thomas R et al. J Vis 2010; 10:6

Also check Ramachandranโ€™s work on Shape from Shading by Humans http://psy.ucsd.edu/chip/ramabio.html