PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
algo3.m
Go to the documentation of this file.
1 % Algorithm 3
2 % Rate-Linearization of Position and Orientation
3 %
4 % Created: Dec 1, 2000
5 % Modified: Mar 4, 2002
6 % Sangyoon Lee
7 
8 clear all
9 flops(0)
10 
11 % Loading data files
12 %slice = 4 % Image slice number
13 p = load('Kel_p9.dat'); % Position vectors of rods
14 v = load('Kel_v9.dat'); % Direction vectors of rods
15 %y = load('CRW_trs_y43_9.dat'); % Coordinates of fiducials on image plane
16 y = load('syn_y4_9.dat'); % Coordinates of fiducials on image plane
17 R0 = [0.9848 0.0000 -0.1736; 0.0000 1.0000 0.0000; 0.1736 0.0000 0.9848];
18 b0 = [19.3969 -20.0000 5.4202]';
19 N = size(p,2) % # of rods
20 
21 
22 % Initializations
23 R = eye(3); % Initial rotation matrix
24 %R = [-1 0 0; 0 0 1; 0 1 0]; % Initial rotation matrix
25 b = [5 5 5]'; % Initial translation vector
26 alpha = 1; % Positive constant for (deldot) = -(alpha)*(del)
27 delt = 0.1; % Time increment
28 limit = 100; % # of iterations
29 iter = 1:1:limit';
30 error1 = zeros(limit, 1); % To store error at each iteration
31 error2 = zeros(limit, 2); % To store error at each iteration
32 
33 % Calculation by iteration (velocity vector is calculated)
34 cnt = 1;
35 while cnt <= limit
36  mat1 = zeros(3*N, 3*N); % Main equation is
37  mat2 = zeros(3*N, 6); % (mat1)*(mat2)*(l_vect) = (r_vect)
38  l_vect = zeros(6,1); % 6*1 velocity vector
39  r_vect = zeros(3*N, 1);
40  for i = 1:N
41  tmp1 = eye(3) - v(:,i) * v(:,i)'; % 3*3 block
42  mat1((3*i-2):(3*i), (3*i-2):(3*i)) = tmp1;
43  tmp2 = R * y(:,i);
44  % Skew symmetric matrix corresponding to tmp2
45  mat2((3*i-2):(3*i), 1:3) = [0 -tmp2(3) tmp2(2); ...
46  tmp2(3) 0 -tmp2(1); -tmp2(2) tmp2(1) 0];
47  mat2((3*i-2):(3*i), 4:6) = -eye(3);
48  del = tmp1 * (p(:,i) - (tmp2 + b));
49  r_vect((3*i-2):(3*i)) = -alpha * del;
50  end
51  mat3 = mat1 * mat2;
52  l_vect = inv(mat3' * mat3) * (mat3' * r_vect);
53  ang_vel = l_vect(1:3); % Angular vecocity
54  bdot = l_vect(4:6);
55 
56  % Error
57  for i = 1:N
58  tmp_e(:,i) = (eye(3) - v(:,i) * v(:,i)') * ...
59  (p(:,i) - (R * y(:,i) + b));
60  error1(cnt) = error1(cnt) + norm(tmp_e(:,i));
61  end
62  error1(cnt) = error1(cnt) / N;
63  error2(cnt, :) = [sqrt(6 - 2 * trace(R0' * R)) norm(b0 - b)]; % NOTE
64 
65  % Update
66  R = rot_up2_2(R, ang_vel);
67  b = b + delt * bdot;
68  cnt = cnt + 1;
69 end
70 flops_is = flops
71 norm_del = error1(limit)
72 dist_se3 = error2(limit, :)
73 R_b = [R b]
74 
75 
76 
77 
78 zzz
79 
80 
81 
82 % Plot
83 figure(1) % error vs # of iterations
84 plot(iter, error, 'k-')
85 xlabel('Number of iterations')
86 ylabel('Error')
87 %logerror = log(error);
88 %plot(iter, logerror, 'k-')
89 %plot(iter, logerror, 'k:')
90 %xlabel('Number of iterations')
91 %ylabel('log(Error)')
92 %tit = sprintf('Algorithm 2 for 6*1 approach, slice %d', slice);
93 %title(tit)
94 %legend('solid: synthetic data', 'dotted: real data')
95 grid on
const uint32_t * data
Definition: phidget22.h:3971
To store error at each iteration Calculation by iteration cnt
Definition: algo4.m:31
ang_vel(3) 0 -ang_vel(1)
Positive constant for(deldot)
Initial rotation matrix R
Definition: algo3.m:24
for i
Initial rotation matrix b
Definition: algo3.m:25
b0
Definition: algo3.m:18
Image slice number p
Definition: algo4.m:14
iter
Definition: algo3.m:29
error1
Definition: algo3.m:30
Algorithm Minimization over Position
Definition: algo4.m:2
Algorithm Minimization over Orientation
Definition: algo4.m:2
Coordinates of fiducials on image plane R0
Definition: algo3.m:17
Initial translation vector alpha
Definition: algo3.m:26
Algorithm Minimization over and Arc lengths Sangyoon Lee clear all flops(0) % Loading data files %slice
To store error at each iteration error2
Definition: algo3.m:31
Direction vectors of rods y
Definition: algo3.m:15
Time increment limit
Definition: algo3.m:28
N
Definition: algo3.m:19
Position vectors of rods v
Definition: algo3.m:14