Activity 13: Photometric Stereo
We consider a point light source from infinity located at
. The intensity
as captured by the camera at image location (x,y) is proportional to the brightness
. Thus we have
![]()
then
![]()
where
![]()
We can approximate the shape of an object by varying the light source and taking the picture of the image at various locations. The (x,y,z) of the light sources are stored in the matrix V.
Thus, we have

which are the the (x,y,z) locations of the N sources. The intensity for each point in the image is given by

or in matrix form
![]()
Since we know I and V, we can solve for g using
![]()
We get the normalize vectors using
![]()
After some manipulations we can compute the elevation z=f(x,y) using at any given (x,y) using
![]()
![]()
code:
loadmatfile(‘Photos.mat’);
V(1,: ) = [0.085832 0.17365 0.98106];
V(2,: ) = [0.085832 -0.17365 0.98106];
V(3,: ) = [0.17365 0 0.98481];
V(4,: ) = [0.16318 -0.34202 0.92542];
I(1, : ) = I1(: )’;
I(2, : ) = I2(: )’;
I(3, : ) = I3(: )’;
I(4, : ) = I4(: )’;
g = inv(V’*V)*V’*I;
g = g;
ag = sqrt((g(1,:).*g(1,: ))+(g(2,:).*g(2,: ))+(g(3,: ).*g(3,: )))+1e-6;
for i = 1:3
n(i,: ) = g(i,: )./(ag);
end
//get derivatives
dfx = -n(1,: )./(nz+1e-6);
dfy = -n(2,: )./(nz+1e-6);
//get estimate of line integrals
int1 = cumsum(matrix(dfx,128,128),2);
int2 = cumsum(matrix(dfy,128,128),1);
z = int1+int2;
plot3d(1:128, 1:128, z);
I give my self 10 points for this activity because there is high similarity in the shape of the actual object and photometric stereo.
Collaborators: Cole, Benj, Mark

