0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 function Homography_2D = sugr_Homography_2D(a1,a2)
0024
0025
0026 Chh = zeros(9);
0027
0028 switch nargin
0029 case 1
0030
0031 switch isstruct(a1)
0032 case 0
0033 [~,columns_a1] = size(a1);
0034 switch columns_a1
0035 case 1
0036
0037 H = reshape([a1;1],3,3);
0038 Homography_2D = sugr_minimal_Homography_2D(H,Chh);
0039 case 2
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
0050 Homography_2D = sugr_minimal_Homography_2D(a1,Chh);
0051
0052
0053 end
0054 case 1
0055
0056
0057 X =a1;
0058 N = length(X);
0059 xy = zeros(N,2);
0060
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
0085 size_a1 = size(a1,1);
0086 switch size_a1
0087 case 3
0088
0089 Homography_2D = sugr_minimal_Homography_2D(a1,a2);
0090
0091 case 8
0092
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;