Thursday, August 7, 2008

A13 – Photometric Stereo

We can estimate the shape of the surface by capturing multiple images of the surface with the sources at different locations. The information about the surface will be coded in the shadings obtained from the images.

Let there be N sources in 3-d space. We can define a matrix
where each row is a source, each column is the x,y,z component of the source.

Procedure:
1. Load the matlab file photos.mat which contains 4 images I1, I2, I3,
and I4. The images are synthetic spherical surfaces illuminated by a far
away point source located respectively at
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}
Use loadmatfile in Scilab.

Sperical surfaces
2. Compute the surface normals using Equation 10 and 11.

Equation 10
To get the normal vector we simplify normalize g by its length
Equation 11

3. From the surface normals compute the elevation z=f(u,v) and display a 3D plot of the object shape.
Once the surface normals (nx, ny, nz) are estimated using photometric stereo, they are related to the partial derivative of f as
The surface elevation z at point (u,v) is given by f(u,v) and is evaluated by a line integral

This is the resulting image.
--
codes
loadmatfile('Photos.mat',['I1','I2','I3', 'I4']);
scf(1)
subplot(141);imshow(I1,[]);
subplot(142);imshow(I2,[]);
subplot(143);imshow(I3,[]);
subplot(144);imshow(I4,[]);

V = [0.085832 0.17365 0.98106; 0.085832 -0.17365 0.98106; 0.17365 0 0.98481; 0.16318 -0.34202 0.92542];
I = [I1(:)';I2(:)';I3(:)';I4(:)'];

g = inv(V'*V)*V'*I;
[A,B] = size(g);
for i=1:A;
for j=1:B;
c(j)=sqrt((g(1,j)**2)+(g(2,j)**2)+(g(3,j)**2));
c = c+ 0.000000001;
end
end

n(1,:) = g(1,:)./c';
n(2,:) = g(2,:)./c';
n(3,:) = g(3,:)./c';


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

imx = matrix(dfx,128,128);
imy = matrix(dfy,128,128);

fx =cumsum(imx,2);
fy =cumsum(imy,1);

Image = fx+fy;

mesh(Image)

Acknowledgements:
April, Lei, Mark Leo and Aiyin
- for helping me

Grade
10/10
-since I was able to find the correct 3D plot.

0 comments:

 
template by suckmylolly.com