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

sugr_generate_true_Lines_2D_one_Point

PURPOSE ^

sugr_generate_true_2d_lines_one_point: generates image lines through one point

SYNOPSIS ^

function lines = sugr_generate_true_Lines_2D_one_Point(x0,d,N,lengthq,resolution)

DESCRIPTION ^

 sugr_generate_true_2d_lines_one_point: generates image lines through one point

 lines = sugr_generate_true_2d_lines_one_point(x0,d,N,lengthq,resolution)

 * x0 true intersection point, homogeneous vector, direction from projection centre
 * d = image size d*[-1,1] x  d*[-1,1] ---- assuming c=1
 * N  = total number of lines to be generated
 * lengthq [pel] = average length of lines in pixels

 *     lines have length lengthq*f, log(f) in [-1,3],
 *     thus f in[1/e, e^3] appr. [0.3,25]

 * resolution [pel] = number of pixels (square image)
 
 lines = N x 4 array with [u0,v0,phi_0,lengthl]    

 Wolfgang Förstner 2/2011
 wfoerstn@uni-bonn.de
 
 see also sugr_Line_2D, sugr_perturb_Lines_2D

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % sugr_generate_true_2d_lines_one_point: generates image lines through one point
0002 %
0003 % lines = sugr_generate_true_2d_lines_one_point(x0,d,N,lengthq,resolution)
0004 %
0005 % * x0 true intersection point, homogeneous vector, direction from projection centre
0006 % * d = image size d*[-1,1] x  d*[-1,1] ---- assuming c=1
0007 % * N  = total number of lines to be generated
0008 % * lengthq [pel] = average length of lines in pixels
0009 %
0010 % *     lines have length lengthq*f, log(f) in [-1,3],
0011 % *     thus f in[1/e, e^3] appr. [0.3,25]
0012 %
0013 % * resolution [pel] = number of pixels (square image)
0014 %
0015 % lines = N x 4 array with [u0,v0,phi_0,lengthl]
0016 %
0017 % Wolfgang Förstner 2/2011
0018 % wfoerstn@uni-bonn.de
0019 %
0020 % see also sugr_Line_2D, sugr_perturb_Lines_2D
0021 
0022 function lines = sugr_generate_true_Lines_2D_one_Point(x0,d,N,lengthq,resolution)
0023 
0024 
0025 %% Initiate
0026 %
0027 % determine given point
0028 
0029 c=1; % nur zum Test auf Sensitivität gegen Änderungen von c
0030 
0031 van_1 = x0/norm(x0);
0032 van_1(3) = van_1(3)*c;
0033 
0034 %% prepare generation of lines
0035 
0036 lines        = zeros(N,4);
0037 
0038 ii = 0;
0039 
0040 % Delta_x=d/resolution;
0041 
0042 maxl = 0;
0043 minl = 10000;
0044 
0045 %% generate N lines
0046 for n = 1:N
0047     % generate line to point van_1
0048 
0049     % Generate true data
0050     
0051     % centre, randomly distributed in image
0052     z0     = (rand(1)*2-1+1i*(rand(1)*2-1))*d;
0053 
0054     % true line
0055     e_line = cross([real(z0),imag(z0),1],van_1);
0056     if rand(1) < 0.5 e_line=-e_line; end;
0057 
0058     % true direction of line
0059     phi_0 = atan2(e_line(2),e_line(1))+pi/2;
0060 
0061     % length
0062     log_f=(rand(1)*4-1)/2;
0063     f=exp(log_f);
0064     lengthl= lengthq*f;
0065     minl=min(minl,lengthl);
0066     maxl=max(maxl,lengthl);
0067     ii=ii+1;
0068     lines(ii,:)=[real(z0),imag(z0),phi_0,lengthl];
0069 end;
0070 
0071 % minlength_maxlength_of_segments=[minl,maxl];
0072 disp(['Minimum and maximum length of segments : [', num2str(minl),',',num2str(maxl),']']);
0073 
0074 
0075             
0076   
0077 
0078 
0079 
0080

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