function lab8()
	im1 = imread('d:\comp vision\images\stereo1.jpg' );
	im2 = imread('d:\comp vision\images\stereo2.jpg' );
       
	C1 = [0.6596   -0.7391   -0.0615  363.4235;
         -0.1851   -0.1387   -0.9437  342.7417;
          0.0005    0.0003   -0.0003    1.0000];     
	C2 = [0.9234   -0.2221   -0.0257  347.7796;
         -0.0741   -0.2278   -0.9168  339.8960;
          0.0002    0.0004   -0.0002    1.0000];
	
	pt3D = stereo(im1, im2, C1, C2)
	
	figure(3)
	cube(pt3D(1:7,:));
	tetrahedron(pt3D(8:11,:));
	cube(pt3D(12:18,:));
	
    % label coordinate axes
	text(100,0,0,'x');
	text(0,100,0,'y');
	text(0,0,100,'z');
  
	% draw in a set of coordinate axes
	axislength = 100*eye(3);
	for i=1:3
	    line([0, axislength(i,1)], [0, axislength(i,2)], [0, axislength(i,3)]);
	end
    axis equal; box on; rotate3D on; grid on;
end
  
function cube(cubepts3D)
    % determine hidden vertex
    cubepts3D(8,:) = - cubepts3D(4,:) + cubepts3D(6,:) + cubepts3D(2,:);
    % define faces from standard numbering
    cubefaces = [4 1 2 3
                 4 3 7 6
                 4 6 5 1
                 8 5 1 2
                 8 2 3 7
                 8 7 6 5];
    % draw 'patcheds' from vertice and face matrix
    patch('Faces',cubefaces,'Vertices',cubepts3D, 'FaceColor', 'none')
    fprintf(1, 'Length matrix of face sides\n');
    [slengths, nface] = sidelengths(cubepts3D, cubefaces)
end

function tetrahedron(tetrahedronpts3D)
    % define faces from standard numbering
    tetrahedronfaces = [1 2 3
                        1 2 4
                        1 3 4
                        2 3 4];
    % draw 'patcheds' from vertice and face matrix
    patch('Faces',tetrahedronfaces,'Vertices',tetrahedronpts3D, 'FaceColor', 'none')
    fprintf(1, 'Length matrix of face sides\n');
    [slengths, nface] = sidelengths(tetrahedronpts3D, tetrahedronfaces)
end

function [slengths, nface] = sidelengths(pt3D, face)
    [rows, cols] = size(face);
    nface = [face face(:,1)];
    for i=1:cols
        for j=1:rows
            slengths(j,i) = norm(pt3D(nface(j,i),:)-pt3D(nface(j,i+1),:));
        end
    end
end