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];
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:
0 comments:
Post a Comment