Monday, August 11, 2008

Activity 13: Photometric Stereo

Using Photometric stereo technique, we reconstruct the shape of a 3D object by capturing the image of the object at different positions of the light source.

We have to compute for the matrix of reflectance g using the equation


where V is the matrix of the light source positions and I is the image matrix.
Plotting the value of the elevations given by equations



the result is a hemisphere.


Rating: I'll give myself 10. since the reconstructed shape is similar to the original object.


The 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);

No comments: