From: <dkg5@us...>  20090710 07:44:40

Revision: 1005 http://panotools.svn.sourceforge.net/panotools/?rev=1005&view=rev Author: dkg5 Date: 20090710 07:44:34 +0000 (Fri, 10 Jul 2009) Log Message:  new try at slant/tilt functions Added Paths:  branches/libpano_gsoc2009_mosaic/matlab/mosaic_v17.m branches/libpano_gsoc2009_mosaic/matlab/projectDepthTilt2.m Added: branches/libpano_gsoc2009_mosaic/matlab/mosaic_v17.m ===================================================================  branches/libpano_gsoc2009_mosaic/matlab/mosaic_v17.m (rev 0) +++ branches/libpano_gsoc2009_mosaic/matlab/mosaic_v17.m 20090710 07:44:34 UTC (rev 1005) @@ 0,0 +1,68 @@ +% Script for slanting and tilting points and images + +clear all, +clc + +ang = 47; +FOV = 50; +% Create five points forming square and its center. Transform and Recover. +% 1. Apply slant or tilt (transformed square) +% 2. Apply negative of slant or tilt (recovered square) +% 3. Plot input (blue stars), transformed square (green circles), +% and recovered (red squares) + +% Create corners of square as projective points in the form [x y 1] +% pts = [1 1 1;... +% 1 1 1;... +% 1 1 1;... +% 1 1 1;... +% 0 0 1] + +% pts = [1.8 1.8 1;... +% 1.8 1.8 1;... +% 1.8 1.8 1;... +% 1.8 1.8 1;... +% 0 0 1] + +pts = [ 8 8;... + 8 8;... + 3 3;... + 3 3;... + 0 0]; + +% Change points to column vectors +pts = pts' + + +ymax = abs(max(pts(2,:))) +% FOV is full angle FOV so z0 is calculated using half of FOV +z0 = ymax/tand(FOV/2) + + +adjpts = projectDepthTilt2(pts,ang,z0) + + +% Make slant/tilt matrix +M = tilt2(ang) + +% Create rotated projective points by multiplying slant matrix with +% projective points +outpts = M * adjpts + +% Convert outpts (in projective coordinates) to +% outcart (in cartesian coordinates) by dividing by zcoordinate +outcart = [outpts(1,:)./outpts(3,:); outpts(2,:)./outpts(3,:)] +%outcart = [outpts(1,:); outpts(2,:)] + + + +% plot corners of square and slanted corners of square +figure(1), + +plot(pts(1,:), pts(2,:), '*', outcart(1,:), outcart(2,:), 'o'), +%plot(outcart(1,:), outcart(2,:), 'o'), + +axis image +legend('Original Points', 'Tilted/Slanted Points') + + Added: branches/libpano_gsoc2009_mosaic/matlab/projectDepthTilt2.m ===================================================================  branches/libpano_gsoc2009_mosaic/matlab/projectDepthTilt2.m (rev 0) +++ branches/libpano_gsoc2009_mosaic/matlab/projectDepthTilt2.m 20090710 07:44:34 UTC (rev 1005) @@ 0,0 +1,46 @@ +function out = projectDepthTilt2(M, phi, z0) + +% should be passed N Cartesian coordinates as column vectors +% if M is 2xN assume z0 = 1, then convert to get adjusted projective +% coordinate +% otherwise M should be 3xN and z0 is given for each coordinate + +% returns: + +%if size(M,1) == 2 +% M = [M; ones(1,size(M,2))]; +%end + + +%%%%%%%%%%%%%% +% Gets Nx2 matrix of N (x1, y1) pairs +% Returns Nx3 matrix of N (x1, y1, z1) points + +% This function calculates z1 based on y1 and phi + +x1 = M(1,:); +y1 = M(2,:); + +%z0 = 1 +%z1 = zeros(size(y1)); + + +z1 = z0  y1*tand(phi); + + +% for i = 1:length(y1) +% if y1(i) >= 0 +% z1(i) = z0  y1(i)*tand(phi); +% end +% if y1(i) < 0 +% z1(i) = y1(i)*tand(phi)  z0; +% end +% end + + + +% z1 = (z0  y1*tand(phi)) .* (y1>=0) +... +% (y1*tand(phi)  z0) .* (y1<0); + + +out = [x1; y1; z1]; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. 