Letting the matrix V be the three dimensional position of the point source for different positions given and matrix I be the resulting image depending on the position of the light source. For each image with size (NxN), the images are then reshaped to (N^2 x 1) to form a column matrix. All of the reshaped images are then combined to form a single matrix I.
Matrix g contains all the information about the original shape about object and can be solved using Equation 1:
Equation 1
Getting then normal vector of the g matrix, I used the Equation 2:
To know the shape of the object, we get the function f first by partial differentiation of normal vectors (x and y) with respect to z using Equation 3:Equation 3
Finally, function f can be obtained using Equation 4:
The result of the shape of the image is shown below:
Figure 1
For this activity, I will give myself a grade of 10 because all of the objectives of the activity were met.
Appendix (Source code in Scilab):
loadmatfile ('C:\Documents and Settings\AP186user15\Desktop\ap18657activity13\Photos.mat');
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,:)+0.0000000001;
Fx = -n(1,:)./n(3,:);
Fy = -n(2,:)./n(3,:);
f = cumsum(Fx,1)+cumsum(Fy,2);
newf = matrix(f,[128,128]);
plot3d(1:128,1:128,newf)
Appendix (Source code in Scilab):
loadmatfile ('C:\Documents and Settings\AP186user15\Desktop\ap18657activity13\Photos.mat');
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,:)+0.0000000001;
Fx = -n(1,:)./n(3,:);
Fy = -n(2,:)./n(3,:);
f = cumsum(Fx,1)+cumsum(Fy,2);
newf = matrix(f,[128,128]);
plot3d(1:128,1:128,newf)