Home > General-Functions > SUGR > Point_Pair_2D > sugr_perturb_2D_point_pairs.m

sugr_perturb_2D_point_pairs

PURPOSE ^

% Perturb sampled 2D points pairs

SYNOPSIS ^

function PP = sugr_perturb_2D_point_pairs(PP_true,sigma_x,sigma_y,rho,fp)

DESCRIPTION ^

% Perturb sampled 2D points pairs

 PP = sugr_perturb_2D_point_pairs(PP_true,sigma_x,sigma_y,rho,fp);

 PP_true = struct, sugr point pairs 2D, true point pairs
              .h(N,6)  homogeneous coordinates of N point pairs stored in each row [x1_n', x2_n']
              .Crr(N,4,4) according reduced CovM
 sigma_x   = standard deviation for perturbation of x's: CovM = sigma_x^2 I_2
 sigma_y   = standard deviation for perturbation of y's: CovM = sigma_x^2 I_2
 rho       = correlation coefficient
 fp        = magnification factor for plot

 PP perturbed point pairs

 Wolfgang Förstner 2/2011
 wfoerstn@uni-bonn.de

 See also sugr_perturb_2D_point_pairs_spherical, sugr_perturb_3D_2D_point_pairs,
 sugr_perturb_Lines_2D

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Perturb sampled 2D points pairs
0002 %
0003 % PP = sugr_perturb_2D_point_pairs(PP_true,sigma_x,sigma_y,rho,fp);
0004 %
0005 % PP_true = struct, sugr point pairs 2D, true point pairs
0006 %              .h(N,6)  homogeneous coordinates of N point pairs stored in each row [x1_n', x2_n']
0007 %              .Crr(N,4,4) according reduced CovM
0008 % sigma_x   = standard deviation for perturbation of x's: CovM = sigma_x^2 I_2
0009 % sigma_y   = standard deviation for perturbation of y's: CovM = sigma_x^2 I_2
0010 % rho       = correlation coefficient
0011 % fp        = magnification factor for plot
0012 %
0013 % PP perturbed point pairs
0014 %
0015 % Wolfgang Förstner 2/2011
0016 % wfoerstn@uni-bonn.de
0017 %
0018 % See also sugr_perturb_2D_point_pairs_spherical, sugr_perturb_3D_2D_point_pairs,
0019 % sugr_perturb_Lines_2D
0020 
0021 function PP = sugr_perturb_2D_point_pairs(PP_true,sigma_x,sigma_y,rho,fp)
0022 
0023 global plot_option
0024 
0025 Pth   = PP_true.h;
0026 
0027 N = size(Pth,1);
0028 
0029 Cppe     = [sigma_x^2*eye(2) sigma_x*sigma_y*rho*eye(2);...
0030     sigma_x*sigma_y*rho*eye(2) sigma_y^2*eye(2)];
0031 for n=1:N
0032     % true Euclidean coordinates
0033     x_true_e = Pth(n,1:2)'/Pth(n,3);
0034     y_true_e = Pth(n,4:5)'/Pth(n,6);
0035     p_true_e = [x_true_e;y_true_e];
0036     % perturbed point pair
0037     pe       = sugr_rand_gauss(p_true_e,Cppe, 1);
0038     %pp       = sugr_Point_Pair_2D(pe,Cppe);
0039     %     PP.h(n,:)     = pp.h';
0040     %     PP.Crr(n,:,:) = pp.Crr;
0041     %     PP.type(n)    = 8;
0042     %
0043     % homogeneous coordinates
0044     x1h = [pe(1:2);1];
0045     n1  = norm(x1h);
0046     x2h = [pe(3:4);1];
0047     n2  = norm(x2h);
0048     ph   = [x1h/n1;x2h/n2];
0049     % covariance matrix
0050     Chh  = [Cppe(1:2,1:2) zeros(2,1) Cppe(1:2,3:4) zeros(2,1);...
0051         zeros(1,6);...
0052         Cppe(3:4,1:2) zeros(2,1) Cppe(3:4,3:4) zeros(2,1);...
0053         zeros(1,6)];
0054     J    = [null(x1h')/n1, zeros(3,2); ...
0055         zeros(3,2), null(x2h')/n2];
0056     Crr    = J' * Chh * J;               % CovM of reduced vector
0057     %
0058     PP.h(n,:)     = ph';
0059     PP.Crr(n,:,:) = Crr;
0060     
0061 end
0062 
0063 
0064 for n=1:N
0065     xh = PP.h(n,1:3)';
0066     yh = PP.h(n,4:6)';
0067     Cxx = null(xh') * squeeze(PP.Crr(n,1:2,1:2)) * null(xh')';
0068     Cyy = null(yh') * squeeze(PP.Crr(n,3:4,3:4)) * null(yh')';
0069     x = sugr_Point_2D(xh,Cxx);
0070     y = sugr_Point_2D(yh,Cyy);
0071     if plot_option > 0
0072         sugr_plot_Point_2D(x,'.k','-r',2,fp);
0073         sugr_plot_Point_2D(y,'.k','-b',2,fp);
0074         l = sugr_construct_join_Line_2D(x,y);
0075         sugr_plot_Line_2D(l,'-k','-w',1,5,[0,0]);
0076     end
0077     
0078 end
0079 
0080

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