% Generate 2D point pairs from homography, i.e., for given H generate N point pairs PP = sugr_generate_true_2D_point_pairs_homography(H,N,boolean_r); H = 3x3 matrix N = number of points (in square [-1,1]^2 boolean_r = boolean: points should sit random else: points sit in a square (N should be square) PP = point pairs PP.h = N x 6 matrix of pairs of homogeneous point coordinates PP.Crr = N x 4 x 4 sith 4 x4 CovM of point pairs PP.type = 8 * ones(N,1) Wolfgang Förstner wfoerstn@uni-bonn.de wf 02/2011
0001 %% Generate 2D point pairs from homography, 0002 % i.e., for given H generate N point pairs 0003 % 0004 % PP = sugr_generate_true_2D_point_pairs_homography(H,N,boolean_r); 0005 % 0006 % H = 3x3 matrix 0007 % N = number of points (in square [-1,1]^2 0008 % boolean_r = boolean: points should sit random 0009 % else: points sit in a square (N should be square) 0010 % 0011 % PP = point pairs 0012 % PP.h = N x 6 matrix of pairs of homogeneous point coordinates 0013 % PP.Crr = N x 4 x 4 sith 4 x4 CovM of point pairs 0014 % PP.type = 8 * ones(N,1) 0015 % 0016 % Wolfgang Förstner 0017 % wfoerstn@uni-bonn.de 0018 % 0019 % wf 02/2011 0020 0021 function PP = sugr_generate_true_2D_point_pairs_homography(H,N,br) 0022 0023 if br 0024 for n=1:N 0025 x = [rand(2,1)*2-1;1]; 0026 y = H * x; 0027 PP.h(n,:) = [x',y']; 0028 PP.Crr(n,:,:) = zeros(4); 0029 PP.type(n) = 8; 0030 end 0031 else 0032 M = ceil(sqrt(N)); 0033 n=0; 0034 for m=1:M 0035 for k=1:M 0036 n = n+1; 0037 if n <= N 0038 x = [-(M-1)/2+2*(m-1)/(M-1);-(M-1)/2+2*(k-1)/(M-1);1]; 0039 y = H * x; 0040 PP.h(n,:) = [x',y']; 0041 PP.Crr(n,:,:) = zeros(4); 0042 PP.type(n) = 8; 0043 end 0044 end 0045 end 0046 end