Wednesday, August 13, 2008

Activity 13: Photometric Stereo

By capturing multiple images of a surface with light sources at different locations. In this activity, the images used are the following below.



To do this, N sources in 3D space are defined in matrix form

Since I = Vg, we can solve for the surface normal. I is the intensity matrix and V is matrix form for the sources. To get surface normal, we use the equations




With the surface normals determined, the elevation is the computed and plotted in 3D space.


loadmatfile ('C:\Users\nez\Documents\tresloco\ap186_2\activity13\Photos');
browsevar();
I(1,:) = (I1(:))';
I(2,:) = (I2(:))';
I(3,:) = (I3(:))';
I(4,:) = (I4(:))';
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];
g = (inv(V'*V)*(V'))*I;
N = size(g);gmag = [];
for i = 1:N(2)
gmag(i) = sqrt(g(1,i)**2 + g(2,i)**2 + g(3,i)**3)+0.0000000001;
end

n(1,:) = g(1,:)./gmag(1,:);
n(2,:) = g(2,:)./gmag(1,:);
n(3,:) = g(3,:)./gmag(1,:);
dfx = -n(1,:)./(n(3,:)+0.0000000001);
dfy = -n(2,:)./(n(3,:)+0.0000000001);

F = cumsum(dfx,1)+cumsum(dfy,2);
new = matrix(F,[128,128]);
plot3d(1:128,1:128,new)
Using this code, a 3D plot of the suface was created.

Grade: 8/10 - I have done the activity well.

No comments: