Monday, September 7, 2009

Activity 17 - Photometric Stereo

Photometric stereo is a method that gets information from shadow to reconstruct a shape. Images of an object under different illumination sources is taken, and from these images which contain shadow information, the shape can be retrieved. We were given the file Photos.mat which contains four images of a hemisphere (shown below), with illumination coming from different directions. The x,y,z components of each of the four light sources stored as a vector are given below:

V1 = [0.085832, 0.17365, 0.98106];

V2 = [0.085832, -0.17365, 0.98106];

V3 = [0.17365, 0, 0.98481];

V4 = [0.16318, -0.34202, 0.92542];





Above are the images of a hemisphere illuminated from different directions. The directions stored in an array shown below, where V1 and V2 are the directions for the top row image, respectively, and V3 and V4 are the directions for the bottom row, respectively. The light source matrix is defined as



where each row is a light source and each column is x,y,z component of the source [1]. The image is represented in matrix form as I=Vg. I here is the matrix of the values of each pixel in each image, given by:


Since we know I and V, we can solve for g using:



The normal vector is given by:


The surface elevation f(u,v) at a point (u,v) is given by:

where



The line integral above was implemented by first computing all partial derivatives for each pixel such that we have two 2D matrices (with the same size as the images) containing the partial derivatives. The first term is computed by summing the uth row from columns 1 to v, and the second term is computed by summing the vth column from rows 1 to u. The code is shown below:

for u=1:x
for v=1:y
t1 = dfdx(u,1:v);
t2 = dfdy(1:u,v);
f(u,v) = sum(t1)+sum(t2);
end
end

Plotting f(u,v) in 3D gives us:



I give myself 10 points for this activity. The hemisphere is successfully reconstructed. However, I cannot explain the visible grooves in the reconstruction, which seems to form a cross in the middle.

Thanks to Martin for clarifying the integral limits.

0 comments:

Post a Comment