Tuesday, August 19, 2008

Activity 13: Photometric Stereo


The task: to use photometric stereo concepts to build a 3d image solely from shadow cues.

The the surface shape can be determined by taking many images of the same object from different angles and distances.

This results in a v matrix similar to the following,
...where each row is a source and each column corresponds to the x,y,z component of the source's location in space. If you take N images of the surface using each of these N sources, then for each point (x,y) on the surface we have,

...g may now be solved for.

Then calculating for the normal vectors...we can the use these to calculate for the object's shape.

**The provided matlab file, photos.mat held 4 images to be used in this particular activity. Also given were the elements of the v matrix, the points in space where the light source is located.








Then, using the following code:
loadmatfile('Photos.mat');

v= [0.085832 0.17365 0.98106;0.085832 -0.17365 0.98106;0.17365 0 0.98481;0.16318 -0.34202 0.92542];
is1=I1(:)';
is2=I2(:)';
is3=I3(:)';
is4=I4(:)';
i=[is1; is2; is3; is4];

vt=v';

g = inv(vt*v)*vt*i;

new = sqrt((g(1,:).*g(1,:))+(g(2,:).*g(2,:))+(g(3,:).*g(3,:)));

for j = 1:3

n(j,:) = g(j,:)./new;

end

nz = n(3,:)+a;

dfx = -n(1,:)./nz;

dfy = -n(2,:)./nz;

z1 = matrix(dfx,128,128);

z2 = matrix(dfy,128,128);

int1 = cumsum(z1,2);

int2 = cumsum(z2,1);

z = int1+int2;

plot3d(1:128, 1:128, z);

The object seems to be a hemisphere with a + shaped indention on the surface.

**i give myself a grade of 9 for this activity because i successfully reconstructed the object into a shape that coincides with the apparent shape inferred from the images in photos.mat.

*thank you to cole.

***i'm having a lot of problems with my posts lately, with uploading the images and somehow my drafts got resetted. (i think they got wiped out when my virus-riddled laptop restarted and firefox restored my 10-13 pages and autosave kicked in with the blank page? unlikely, but it's the only explanation i can think of right now. i'm still working on trying to recover them but it seems like a lost cause.) i'm currently redoing this and the last two activities.

No comments: