Tuesday, August 19, 2008
Activity 13: Photometric Stereo
Continuing how image processing can be applied to our lives, we move on to photometric stereo. When we say "stereo" we usually associate the word to "music" but stereo also means having two or more images be placed together to form a 3D image, which is what we are going to do. Photometric because we use "light sources" to do this.

Essentially, photometric stereo can be used to estimate the shape of the object from different locations of light sources. Processing the data from the images using the code below: (The math is included in the code, and the explanations are in the lecture notes)

chdir('G:\poy\poy backup\physics\186\paper 13');
// To load the Matlab images
loadmatfile('Photos.mat');
// These are the values of the light sources
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];
V = [V1;V2;V3;V4];
// To produce a matrix I for intensity
I1 = I1(:)';
I2 = I2(:)';
I3 = I3(:)';
I4 = I4(:)';
I = [I1;I2;I3;I4];

a = 1e-6; // This is the additive factor
//g is the matrix that represents the relationship of V to I:
g = inv(V'*V)*V'*I;
mod = sqrt((g(1,:).*g(1,:))+(g(2,:).*g(2,:))+(g(3,:).*g(3,:)));
mod = mod+a;

for i = 1:3
n(i,:) = g(i,:)./mod; // To calculate for the normal vectors
end

nz = n(3,:)+a;
dfx = -n(1,:)./nz; //Performing partial differentiation
dfy = -n(2,:)./nz;
z1 = matrix(dfx,128,128); // Reshaping the matrix to 128x128
z2 = matrix(dfy,128,128);
int1 = cumsum(z1,2); //We use the cumsum function to perform our integration
int2 = cumsum(z2,1);
z = int1+int2;
scf(0);
plot3d(1:128, 1:128, z); // This shows the reconstruction




Acknowledgments

I believe I performed this activity fairly well. Thanks to Cole for helping me with the code. I think its ok to give me 10/10 neutrinos? Hehehe.

posted by poy @ 1:03 AM  
0 Comments:
Post a Comment
<< Home
 
 
About Me

Name: poy
Home: Quezon City, NCR, Philippines
About Me:
See my complete profile
Previous Post
Archives
Template by
Blogger templates