Photometric stereo is a technique for 3D modeling which estimates the surface contour with the cues given by the shadows of the object, taken at one viewpoint under different illumination directions. Technically, method computes for the surface normals of the object and from there develops the height variations of the object.
In this activity, synthetic photometric stereo images are used as shown below.
Using these images, we can calculate for the surface information as encoded in the shadings defined by some matrix:
with each column corresponding to x,y,z component of the source. Having multiple images allow us to compute for g given by:
After that, we take the normal vector by dividing g by its length and relating the surface normal to height variations give us:The V's are given as:
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];
Doing all the rigorous mathematical derivations and implementing algorithm gives us a 3D reconstruction of the synthetic object.
Note that the reconstruction is not a perfectly hemispherical surface. This is maybe due to the black and white boundary between quadrants of the hemisphere.
I give myself 10 pts for understanding and doing the activity correctly.
Reference
A17 - Photometric Stereo handout. M. Soriano, 2008.
Code
chdir('E:\Documents and Settings\vergara\My Documents\acads\1st sem 09-10\186\act17');
loadmatfile('Photos.mat')
//who // list of variables
//scf(), imshow(I1, [])
//scf(), imshow(I2, [])
//scf(), imshow(I3, [])
//scf(), imshow(I4, [])
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];
I = [I1(:)'; I2(:)'; I3(:)'; I4(:)'];
g = inv(V'*V)*V'*I;
lg = sqrt(g(1,:).^2 + g(2,:).^2 + g(3,:).^2);
for i = 1:size(g, 1), n(i,:) = g(i,:)./(lg + 1E-9), end
dx = -n(1,:) ./ (n(3,:) + 1E-9);
dy = -n(2,:) ./ (n(3,:) + 1E-9);
sx = size(I1,1); sy = size(I1,2);
z = cumsum(matrix(dx,sx,sy),2) + cumsum(matrix(dy,sx,sy),1);
scf(), plot3d(1:sx,1:sy,z)
Subscribe to:
Post Comments (Atom)











Hi, Thanks for your codes But I can not run .
ReplyDeletean error like below
Error using ==> mtimes
Integers can only be combined with integers of the same class, or scalar doubles.
There is not matrix function here ??
ReplyDeleteThe 'mtimes' error occurred because of the missing data I guess ('Photos.mat'). There is a 'matrix' function in Scilab 4.1.2(0) that I am using and it is working. :)
ReplyDelete