In this activity, we are asked to give an estimation of the shape of a surface or its elevation z by capturing multiple images of it at different locations. Using loadmatfile in scilab, the these four images of the synthetic spherical surfaces which are illuminated by a far away point source located at points V1-4 were loaded:
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}
A matrix I was created with the source as the rows, and the x,y,z components of the source as the columns. With N=4 as the number of surface images, matrix I was expressed as:
I1(x , y) = V11 g1+V12 g2+V13 g3
I2(x , y) = V21 g1+V22 g2+V23 g3
IN(x , y) = VN1 g1+VN2 g2+VN3 g3
or I = Vg
The surface normals (nx,ny,nz) were computed by photometric stereo using the equations:
g = ((V '*V)^-1)*V'*I ; where V'= transpose of V
n = g/l; where the normal vector n is determined by normalizing g by its length l
These surface normals are related to a function f by :
Therefore since the elevation z= f(x,y), the surface elevation at point(u,v) is given by f(u,v), and can be calculated using the integral:
The resulting 3D plot of the object shape is shown below:
The code used is:
chdir('C:\Documents and Settings\Plasma\My Documents\julie\186\activity13');
loadmatfile('Photos.mat');
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];
VN = [V1;V2;V3;V4];
I1= I1(: )';
I2= I2(: )';
I3= I3(: )';
I4= I4(: )';
const = 1e-6;
g = inv(VN'*VN)*VN'*I;
l = sqrt((g(1,:).*g(1,:))+(g(2,:).*g(2,:))+(g(3,:).*g(3,:)));
l = l+const;
for i = 1:3
n(i,:) = g(i,:)./l;
end
dfx = -n(1,: )./(nz+const);
dfy = -n(2,: )./(nz+const);
f1 = cumsum(matrix(dfx,128,128),2);
f2 = cumsum(matrix(dfy,128,128),1);
z = int1+int2;
object = plot3d(1:128, 1:128, z);
rating - 10 because the surface normals were computed and the resulting 3D plot was shown Acknowledgement - Jeric for helping me with the some parts of the code.
Tuesday, August 12, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment