Shape from Shading Formula
Explain in detail and extract all the formulas (if any) with derivation and a solved example foe each
formula.
Here's a detailed explanation and extraction of all the key formulas, their derivations (where possible),
and a solved example for each, based on the lecture notes titled "Shape from Shading" and "Scan Line
Algorithm" by Dr. M.K. Bhuyan.
📌 1. Lambertian Reflectance Model
Formula:
The radiance L observed from a Lambertian surface is given by:
L = ρ ⋅ (n ⋅ s)
Where:
ρ = albedo (diffuse reflectance, between 0 and 1),
n = unit surface normal vector,
s = unit light source direction vector,
n ⋅ s = cosine of the angle between surface normal and light direction.
Derivation:
This is derived from Lambert’s cosine law: brightness observed is proportional to cos(θ), where θ is the
angle between the normal and the light source.
Example:
Let’s say:
ρ = 0.8,
n = (0, 0, 1),
1
s= 2
(1, 0, 1) ⇒ ∥s∥ = 1
n ⋅ s = (0)(1/ 2) + (0)(0) + (1)(1/ 2) = 1/ 2
1
L = 0.8 ⋅ ≈ 0.8 ⋅ 0.707 = 0.566
2
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/4
📌 2. Image Irradiance Equation
E(x, y) = R(p, q)
Where:
E(x, y): image irradiance at a pixel,
R(p, q): reflectance map,
∂z ∂z
p= ∂x , q
= ∂y represent surface orientation.
Reflectance Map (Lambertian):
ρ(n ⋅ s)
R(p, q) =
1 + p2 + q 2
(−p,−q,1)
For normalized surface normal n =
1+p2 +q 2
Example:
Assume:
ρ = 1,
1
s= 3
(1, 1, 1),
p = 1, q = 1
(−1,−1,1)
Then n = , so:
3
(−1)(1) + (−1)(1) + (1)(1) −1
n⋅s= =
3 3
−1 −1
R(p, q) = = ≈ −0.577
1+1+1 3
(Note: Negative value implies surface is facing away from the light.)
📌 3. Photometric Stereo Equation
For n light sources, at each pixel location:
I=C ⋅g
Where:
I: vector of observed intensities from different light sources.
C : matrix of known light source directions.
g = ρn: combined albedo-normal vector.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/4
Solve using least squares:
g = (C T C)−1 C T I
Example:
Let:
1 0 1
C= 0 1 1 ,
1 1 1
0.7
I = 0.6
0.9
Then calculate g, and:
g
ρ = ∥g∥, n=
📌 4. Albedo and Surface Normal Recovery
Given g = ρn, we extract:
g
ρ = ∥g∥, n=
∥g∥
📌 5. Depth Recovery
From normals, recover gradients:
nx ny
p=− , q=−
nz nz
Then integrate p, q to get surface height z(x, y).
✅ Summary of Concepts Covered:
Concept Formula Output
Lambertian reflectance L = ρ(n ⋅ s) Image brightness
n⋅s
Reflectance map R(p, q) = ρ ⋅ Irradiance map
1+p2 +q 2
Photometric stereo I = C ⋅ g, g = ρn Normals and albedo
g
Normal recovery n= ∥g∥
Unit normals
Albedo recovery ρ = ∥g∥ Reflectance
n
Depth from normals p = − nnxz , q = − nyz , integrate to get z(x, y) 3D shape
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/4
Would you like me to generate Python code to simulate one of these examples, or a visual plot of the
reflectance map?
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/4