Home > General-Functions > SUGR > Homography_2D > sugr_Homography_2D.m

sugr_Homography_2D

PURPOSE ^

% create 2D homography

SYNOPSIS ^

function Homography_2D = sugr_Homography_2D(a1,a2)

DESCRIPTION ^

% create 2D homography

 H = sugr_Homography_2D(a1,a2);

 input cases
 (1) 8-vector of Euclideanly normalized homography, CovM == 0
 (1) list of Euclidean points, Nx2 matrix of x,y-coordinates -> H = conditioning matrix
 (1) 3 x 3-matrix, CovM == 0
 (1) list of structs of points and lines -> generate conditioning matrix
 (2) 3 x 3-matrix with full covariance matrix
 (2) 8-vector Euclidean homography with full covariance matrix

 Homography = structure
 *             .H   = 3 x 3-Matrix, determinant normalized (det= +1)
 *             .Crr = covariance matrix of 8 parameters of differential left factor
 *             .type = 20

 Wolfgang Förstner
 wfoerstn@uni-bonn.de

 wf 1/2011

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% create 2D homography
0002 %
0003 % H = sugr_Homography_2D(a1,a2);
0004 %
0005 % input cases
0006 % (1) 8-vector of Euclideanly normalized homography, CovM == 0
0007 % (1) list of Euclidean points, Nx2 matrix of x,y-coordinates -> H = conditioning matrix
0008 % (1) 3 x 3-matrix, CovM == 0
0009 % (1) list of structs of points and lines -> generate conditioning matrix
0010 % (2) 3 x 3-matrix with full covariance matrix
0011 % (2) 8-vector Euclidean homography with full covariance matrix
0012 %
0013 % Homography = structure
0014 % *             .H   = 3 x 3-Matrix, determinant normalized (det= +1)
0015 % *             .Crr = covariance matrix of 8 parameters of differential left factor
0016 % *             .type = 20
0017 %
0018 % Wolfgang Förstner
0019 % wfoerstn@uni-bonn.de
0020 %
0021 % wf 1/2011
0022 
0023 function Homography_2D = sugr_Homography_2D(a1,a2)
0024 
0025 % default
0026 Chh  = zeros(9);
0027 %
0028 switch nargin
0029     case 1
0030         % 9-matrix or 8-vector
0031         switch isstruct(a1)
0032             case 0
0033                 [~,columns_a1] = size(a1);
0034                 switch columns_a1
0035                     case 1 % 8-vector of elements except H(3,3)
0036                         %% (1) 8-vector of Euclidean normalized homography, CovM == 0
0037                         H = reshape([a1;1],3,3);
0038                         Homography_2D = sugr_minimal_Homography_2D(H,Chh);
0039                     case 2 % list of Euclidean points
0040                         xy = a1;
0041                         max_xy=max(xy);
0042                         min_xy=min(xy);
0043                         
0044                         H = [1 ,0 ,-(min_xy(1)+max_xy(1))/2;...
0045                             0 ,1 ,-(min_xy(2)+max_xy(2))/2;...
0046                             0 ,0 ,max(max_xy(1)-min_xy(1),max_xy(2)-min_xy(2))];
0047                         Homography_2D = sugr_Homography_2D(H);
0048                     case 3
0049                         %% (1) 3 x 3-matrix, CovM == 0
0050                         Homography_2D = sugr_minimal_Homography_2D(a1,Chh);
0051                         
0052                         
0053                 end
0054             case 1
0055                 %% (1) generate conditioning matrix
0056                 % set of point structs and line structs -> H = conditioning matrix
0057                 X =a1;
0058                 N  = length(X);
0059                 xy = zeros(N,2);
0060                 % for list of structs
0061                 for i=1:N
0062                     if X(i).type == 1
0063                         [xe,~] = sugr_get_Euclidean_Point_2D(X(i));
0064                         xy(i,:) = xe';
0065                     end
0066                     
0067                     if X(i).type == 2
0068                         f = sugr_get_centroid_Line_2D(X(i));
0069                         [fe,~] = sugr_get_Euclidean_Point_2D(f);
0070                         xy(i,:) = fe';
0071                     end
0072                 end
0073                 
0074                 max_xy=max(xy);
0075                 min_xy=min(xy);
0076                 
0077                 H = [1 ,0 ,-(min_xy(1)+max_xy(1))/2;...
0078                     0 ,1 ,-(min_xy(2)+max_xy(2))/2;...
0079                     0 ,0 ,max(max_xy(1)-min_xy(1),max_xy(2)-min_xy(2))];
0080                 
0081                 Homography_2D = sugr_Homography_2D(H);
0082         end
0083     case 2 %
0084         %% 9-matrix or 8-vector with full covariance matrix
0085         size_a1 = size(a1,1);
0086         switch size_a1
0087             case 3
0088                 %% (2) 3 x 3-matrix
0089                 Homography_2D = sugr_minimal_Homography_2D(a1,a2);
0090                 
0091             case 8
0092                 %% (2) 8-vector Euclidean homography
0093                 H = reshape([a1;1],3,3);
0094                 Chh = [a2 zeros(8,1);zeros(1,9)];
0095                 Homography_2D = sugr_minimal_Homography_2D(H,Chh);
0096                 
0097         end
0098         
0099 end
0100 
0101 Homography_2D.type = 20;

Generated on Sat 21-Jul-2018 20:56:10 by m2html © 2005