For this activity, we would reconstruct a 3D image using 2D images taken at different locations of point sources. The images used are shown below.
To get the elevation of the image, we used the following equation
where V is the matrix containing the locations of the sources, and I is the matrix containing the images. After this operation, we get a 3 row matrix corresponding to the xyz locations. To get a normal vector, we just need to divide each element in a column with the magnitude of that column. After this, a linear integral was used to obtain the z values. Plotting z with a 128x128 plane yields:
For this activity I give myself a grade of 10 since the reconstruction was quite accurate.
Collaborator: Raf Jaculbia
//Scilab code
chdir("C:\Documents and Settings\AP186user17\Desktop\ap18657activity13"); 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};
I(1, :) = I1(:)';
I(2, :) = I2(:)';
I(3, :) = I3(:)';
I(4, :) = I4(:)';
V = cat(1, V1, V2, V3, V4);
g = (inv(V'*V))*V'*I;
len = size(g);
len = len(2);
n = [];
mag = [];
for i = 1:len
mag(i) = sqrt(g(1, i)**2 + g(2, i)**2 + g(3, i)**2);
end
mag = mag';
n(1, :) = g(1, :)./(mag + 0.00000000000001);
n(2, :) = g(2, :)./(mag + 0.00000000000001);
n(3, :) = (g(3, :)./(mag + 0.00000000000001)) + 0.00000000000001;
dfdx = -(n(1, :))./n(3, :);
dfdy = -(n(2, :))./n(3, :);
dfdx = matrix(dfdx, [128, 128]);
dfdy = matrix(dfdy, [128, 128]);
lintfx = cumsum(dfdx, 2);
lintfy = cumsum(dfdy, 1);
z = lintfx + lintfy;
plot3d(1:128, 1:128, z)
//end of code
Subscribe to:
Post Comments (Atom)
1 comment:
sorry what is the matrix function
Post a Comment