Home > General-Functions > SUGR > Line_2D > sugr_perturb_Lines_2D.m

sugr_perturb_Lines_2D

PURPOSE ^

% Perturbes given image lines through one point

SYNOPSIS ^

function lstruct = sugr_perturb_Lines_2D(x0,d,lines,resolution,sigma, rigorous) %#ok

DESCRIPTION ^

% Perturbes given image lines through one point

 lstruct = sugr_perturb_Lines_2D(x0,d,lines,resolution,sigma, rigorous)

 * xo = [x,y,phi] true line centroid, true direction of line
 * d   = length of line
 * lines = Nx4 [u0,v0,phi_0,lengthl] of N true lines
 * resolution = sampling distance for ploting
 * sigma [pel] = standard deviation of single pixels
      sigma_q = sigma_0/length   sigma of cross-position deviation
      sigma_phi^2 = sigma_0^2*length^3/12
 * rigorous = 0 approximate covariance matrix, = 1 rogorous covariance matrix

 lstruct = lstruct.h    =  N x 3 matrix of homogeneous coordinates
           lstruct.Crr  =  N x 2 x 2 matrix of reduced covariance matrices
           lstruct.type =  N x 1 vector of type = 2        

 Wolfgang Förstner 1/2011
 wfoerstn@uni-bonn.de
 
 See also sugr_Line_2D, sugr_generate_true_Lines_2D_one_Point

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Perturbes given image lines through one point
0002 %
0003 % lstruct = sugr_perturb_Lines_2D(x0,d,lines,resolution,sigma, rigorous)
0004 %
0005 % * xo = [x,y,phi] true line centroid, true direction of line
0006 % * d   = length of line
0007 % * lines = Nx4 [u0,v0,phi_0,lengthl] of N true lines
0008 % * resolution = sampling distance for ploting
0009 % * sigma [pel] = standard deviation of single pixels
0010 %      sigma_q = sigma_0/length   sigma of cross-position deviation
0011 %      sigma_phi^2 = sigma_0^2*length^3/12
0012 % * rigorous = 0 approximate covariance matrix, = 1 rogorous covariance matrix
0013 %
0014 % lstruct = lstruct.h    =  N x 3 matrix of homogeneous coordinates
0015 %           lstruct.Crr  =  N x 2 x 2 matrix of reduced covariance matrices
0016 %           lstruct.type =  N x 1 vector of type = 2
0017 %
0018 % Wolfgang Förstner 1/2011
0019 % wfoerstn@uni-bonn.de
0020 %
0021 % See also sugr_Line_2D, sugr_generate_true_Lines_2D_one_Point
0022 
0023 function lstruct = sugr_perturb_Lines_2D(x0,d,lines,resolution,sigma, rigorous) %#ok<INUSD>
0024 
0025 
0026 global plot_option
0027 global print_option
0028 
0029 %% Initiate
0030 
0031 [N,~] = size(lines);
0032 c = 1;
0033 
0034 if plot_option > 0
0035     van_1 = x0/norm(x0);
0036     van_1(3)=van_1(3)*c;
0037     %plot(2*d*[1,-1,-1,1,1]',2*d*[1,1,-1,-1,1]','-b');
0038     xlim([-2.1,2.1]);
0039     ylim([-2,2.7])
0040     if abs(van_1(3)) > sqrt(1/2)*d* norm(van_1(1:2))
0041         van_1_e=van_1(1:2)/van_1(3);
0042         plot(van_1_e(1),van_1_e(2),'or')
0043     end
0044 end
0045 
0046 %% prepare generation of lines
0047 
0048 lstruct.h    = zeros(N,3);
0049 lstruct.Crr  = zeros(N,2,2);
0050 lstruct.type = 2 * ones(N,1);
0051 
0052 ii = 0;
0053 
0054 Delta_x=d/resolution;
0055 sigma=sigma*Delta_x;
0056 
0057 % colors
0058 % col(0+1)='g';
0059 % col(1+1)='r';
0060 
0061 % maxl=0;
0062 % minl=10000;
0063 
0064 %% generate N lines
0065 for n = 1:N
0066     % generate line to point van_1
0067 
0068     % Generate noisy data
0069     % centre
0070     z0     = lines(n,1)+1i*lines(n,2);
0071     
0072     % true direction
0073     phi_0  = lines(n,3);
0074 
0075     % length
0076     lengthl= lines(n,4);
0077     
0078     N_points = round(lengthl);
0079 
0080     % std. deviation across line
0081     sigma_k = sigma/sqrt(N_points);
0082     
0083     % noisy centre
0084     z0_n = z0 + (randn(1)+1i*randn(1)) * sigma_k;
0085     
0086     % std. dev. direction
0087     sigma_phi= sigma/sqrt(N_points^3/12)/Delta_x;
0088     
0089     % noisy direction
0090     phi_n = phi_0 + randn(1)*sigma_phi;
0091 
0092     % start and end point
0093     dz_n = lengthl/2*exp(1i*phi_n)/resolution*d;
0094 
0095     zs_0 = z0_n - dz_n;
0096     ze_0 = z0_n + dz_n;
0097 
0098     % convert to 2D
0099     xs = real(zs_0) ;
0100     ys = imag(zs_0) ;
0101     xe = real(ze_0) ;
0102     ye = imag(ze_0) ;
0103 %     [xs,ys,xe,ye,phi_n];
0104     ii=ii+1;
0105     Line                = sugr_Line_2D((xs+xe)/2,(ys+ye)/2,phi_n-pi/2,sigma_phi,sigma_k);
0106     lstruct.h(ii,:)     = Line.h';
0107     lstruct.Crr(ii,:,:) = Line.Crr;
0108 end;
0109 
0110 % [maxl,minl];
0111 nii=ii;
0112 
0113 %% Check and Plot if plot_option fulfilled
0114 
0115 if print_option > 0
0116     Omega_d = 0;
0117     Omega_p = 0;
0118     for j=1:nii
0119         l       = sugr_select_Line_2D(lstruct,j);
0120         Clhh    = sugr_get_CovM_homogeneous_Vector(l);
0121         var_c   = van_1' * Clhh * van_1;
0122         c       = l.h' * van_1;
0123         Omega_d = Omega_d + c^2;
0124         Omega_p = Omega_p + c^2 / var_c;
0125     end;
0126     % check
0127 %     RMS_d=sqrt(Omega_d/nii)*resolution;
0128 %     sigma_0_est = sqrt(Omega_p/(nii-2));
0129 end
0130 
0131 if plot_option > 0
0132     for j=1:nii        
0133         l       = sugr_select_Line_2D(lstruct,j);
0134         sugr_plot_Line_2D(l,'-w','-k',2,100,[0,0]);
0135     end
0136     axis equal
0137 end
0138 
0139 
0140 
0141             
0142   
0143 
0144 
0145 
0146

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