diff options
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/affine')
21 files changed, 775 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/README b/SD-VBS/common/toolbox/toolbox_basic/affine/README new file mode 100755 index 0000000..e578a74 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/README | |||
@@ -0,0 +1,5 @@ | |||
1 | Top level program is "compute_AD.m". Use "compute_AD_disp.m" if one | ||
2 | wants to display results as program runs. | ||
3 | |||
4 | The testing programs are called "simulation.m" for synthetic images, | ||
5 | and "test_affine.m" for real images. | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/carve_it.m b/SD-VBS/common/toolbox/toolbox_basic/affine/carve_it.m new file mode 100755 index 0000000..1a44f89 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/carve_it.m | |||
@@ -0,0 +1,25 @@ | |||
1 | function img = carve_it(I,center,window_size_h) | ||
2 | |||
3 | [size_y,size_x]= size(I); | ||
4 | min_x = round(center(1)-window_size_h(1)); | ||
5 | max_x = round(center(1)+window_size_h(1)); | ||
6 | min_y = round(center(2)-window_size_h(2)); | ||
7 | max_y = round(center(2)+window_size_h(2)); | ||
8 | window_size = window_size_h*2 +1; | ||
9 | |||
10 | if (min_x <1)|(max_x > size_x)|(min_y<1)|(max_y>size_y), | ||
11 | disp('window too big'); | ||
12 | center | ||
13 | window_size_h | ||
14 | img = zeros(window_size(2),window_size(1)); | ||
15 | n_min_x = max(1,round(min_x)); | ||
16 | n_min_y = max(1,round(min_y)); | ||
17 | n_max_x = min(size_x,round(max_x)); | ||
18 | n_max_y = min(size_y,round(max_y)); | ||
19 | img(1+(n_min_y-min_y):window_size(2)-(max_y-n_max_y),1+(n_min_x-min_x):window_size(1)-(max_x-n_max_x))=I(n_min_y:n_max_y,n_min_x:n_max_x); | ||
20 | else | ||
21 | img = I(center(2)-window_size_h(2):center(2)+window_size_h(2),... | ||
22 | center(1)-window_size_h(1):center(1)+window_size_h(1)); | ||
23 | end | ||
24 | |||
25 | |||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/compute_AD.m b/SD-VBS/common/toolbox/toolbox_basic/affine/compute_AD.m new file mode 100755 index 0000000..a39acd6 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/compute_AD.m | |||
@@ -0,0 +1,90 @@ | |||
1 | function [A,D,mask] =... | ||
2 | compute_AD(img_i,img_j,center_i,center_j,window_size_h,num_iter,w,num_trans,Dest,mask) | ||
3 | % | ||
4 | % function [A,D,mask] = ... | ||
5 | % compute_AD(img_i,img_j,center_i,center_j,window_size_h,num_iter,w, | ||
6 | % mask,num_trans) | ||
7 | % | ||
8 | % A: Affine motion; | ||
9 | % D: Displacement; | ||
10 | % | ||
11 | % img_i, img_j: the two image(in full size); | ||
12 | % center_i, center_j: the centers of the feature in two images; | ||
13 | % window_size_h: half size of the feature window; | ||
14 | % num_iter: number of iterations; | ||
15 | % w: parameter used in "grad.m" for computing gaussians used for | ||
16 | % gradient estimation; | ||
17 | % | ||
18 | % num_trans: OPTIONAL, number of translation iteration; default = 3; | ||
19 | % mask: OPTIONAL, if some area of the square shaped feature window should | ||
20 | % be weighted less; | ||
21 | % | ||
22 | |||
23 | % | ||
24 | % Jianbo Shi | ||
25 | % | ||
26 | |||
27 | if ~exist('Dest'), | ||
28 | Dest = [0,0]; | ||
29 | end | ||
30 | |||
31 | if ~exist('mask'), | ||
32 | mask = ones(2*window_size_h+1)'; | ||
33 | end | ||
34 | |||
35 | % set the default num_trans | ||
36 | if ~exist('num_trans'), | ||
37 | num_trans= 3; | ||
38 | end | ||
39 | |||
40 | % normalize image intensity to the range of 0.0-1.0 | ||
41 | img_i = norm_inten(img_i); | ||
42 | img_j = norm_inten(img_j); | ||
43 | |||
44 | window_size = 2*window_size_h + 1; | ||
45 | I = carve_it(img_i,center_i,window_size_h); | ||
46 | J = carve_it(img_j,center_j,window_size_h); | ||
47 | |||
48 | % init. step | ||
49 | J_computed = I; | ||
50 | D_computed = Dest; | ||
51 | A_computed = eye(2); | ||
52 | J_computed = compute_J(A_computed,D_computed,img_i,center_i,window_size_h); | ||
53 | |||
54 | %% level of noise | ||
55 | sig = 0.1; | ||
56 | |||
57 | records = zeros(num_iter,6); | ||
58 | errs = zeros(1,num_iter); | ||
59 | |||
60 | k = 1; | ||
61 | % iteration | ||
62 | while k <= num_iter, | ||
63 | [A,D] = iter_AD(J_computed,J,mask,w,k,num_trans); | ||
64 | |||
65 | A_computed = A*A_computed; | ||
66 | D_computed = (A*D_computed')' + D; | ||
67 | |||
68 | % compute the warped image | ||
69 | J_computed = compute_J(A_computed,D_computed,img_i,center_i,window_size_h); | ||
70 | |||
71 | % compute the SSD error | ||
72 | errs(k) = sqrt(sum(sum((mask.*(J_computed-J)).^2)))/prod(size(J)); | ||
73 | |||
74 | % update the mask, discounting possible occlusion region | ||
75 | if (k>num_trans), | ||
76 | mask = exp(-abs(J_computed-J)/sig); | ||
77 | end | ||
78 | |||
79 | % record the A and D | ||
80 | records(k,:) = [reshape(A_computed,1,4),reshape(D_computed,1,2)]; | ||
81 | |||
82 | k = k+1; | ||
83 | end | ||
84 | |||
85 | [tmp,id] = min(errs); | ||
86 | A = reshape(records(id,1:4),2,2); | ||
87 | D = reshape(records(id,5:6),1,2); | ||
88 | |||
89 | J_computed = compute_J(A,D,img_i,center_i,window_size_h); | ||
90 | mask = exp(-abs(J_computed-J)/sig); | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/compute_AD_disp.m b/SD-VBS/common/toolbox/toolbox_basic/affine/compute_AD_disp.m new file mode 100755 index 0000000..f2e6c62 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/compute_AD_disp.m | |||
@@ -0,0 +1,103 @@ | |||
1 | function [A,D,mask] =... | ||
2 | compute_AD_disp(img_i,img_j,center_i,center_j,window_size_h,num_iter,w,fig_disp,num_trans,Dest,mask) | ||
3 | % | ||
4 | % function [A,D,mask] = ... | ||
5 | % compute_AD_disp(img_i,img_j,center_i,center_j,window_size_h,num_iter,w, | ||
6 | % fig_disp,mask,num_trans) | ||
7 | % | ||
8 | % Computing affine transform for matching to image patches. Display results | ||
9 | % as program runs. | ||
10 | % | ||
11 | % A: Affine motion; | ||
12 | % D: Displacement; | ||
13 | % | ||
14 | % | ||
15 | % img_i, img_j: the two image(in full size); | ||
16 | % center_i, center_j: the centers of the feature in two images; | ||
17 | % window_size_h: half size of the feature window; | ||
18 | % num_iter: number of iterations; | ||
19 | % w: parameter used in "grad.m" for computing gaussians used for | ||
20 | % gradient estimation; | ||
21 | % fig_disp: figure for display; | ||
22 | % | ||
23 | % num_trans: OPTIONAL, number of translation iteration; | ||
24 | % mask: OPTIONAL, if some area of the square shaped feature window should | ||
25 | % be weighted less; | ||
26 | % | ||
27 | |||
28 | |||
29 | % | ||
30 | % Jianbo Shi | ||
31 | % | ||
32 | |||
33 | if ~exist('mask'), | ||
34 | mask = ones(2*window_size_h+1)'; | ||
35 | end | ||
36 | |||
37 | if ~exist('Dest'), | ||
38 | Dest = [0,0]; | ||
39 | end | ||
40 | |||
41 | % set the default num_trans | ||
42 | if ~exist('num_trans'), | ||
43 | num_trans= 3; | ||
44 | end | ||
45 | |||
46 | % normalize image intensity to the range of 0.0-1.0 | ||
47 | img_i = norm_inten(img_i); | ||
48 | img_j = norm_inten(img_j); | ||
49 | |||
50 | window_size = 2*window_size_h + 1; | ||
51 | I = carve_it(img_i,center_i,window_size_h); | ||
52 | J = carve_it(img_j,center_j,window_size_h); | ||
53 | |||
54 | % init. step | ||
55 | D_computed = Dest; | ||
56 | A_computed = eye(2); | ||
57 | J_computed = compute_J(A_computed,D_computed,img_i,center_i,window_size_h); | ||
58 | |||
59 | |||
60 | |||
61 | figure(fig_disp);subplot(1,3,1);imagesc(I);colormap(gray);axis('image'); | ||
62 | subplot(1,3,3);imagesc(J);axis('image'); | ||
63 | drawnow; | ||
64 | |||
65 | sig = 0.1; | ||
66 | |||
67 | records = zeros(num_iter,6); | ||
68 | errs = zeros(1,num_iter); | ||
69 | |||
70 | k = 1; | ||
71 | % iteration | ||
72 | while k <= num_iter, | ||
73 | [A,D] = iter_AD(J_computed,J,mask,w,k,num_trans); | ||
74 | |||
75 | A_computed = A*A_computed; | ||
76 | D_computed = (A*D_computed')' + D; | ||
77 | |||
78 | % compute the warped image | ||
79 | J_computed = compute_J(A_computed,D_computed,img_i,center_i,window_size_h); | ||
80 | |||
81 | % compute the SSD error | ||
82 | errs(k) = sqrt(sum(sum((mask.*(J_computed-J)).^2)))/prod(size(J)) | ||
83 | |||
84 | % update the mask, discounting possible occlusion region | ||
85 | if (k>num_trans+1), | ||
86 | mask = exp(-abs(J_computed-J)/sig); | ||
87 | end | ||
88 | |||
89 | % record the A and D | ||
90 | records(k,:) = [reshape(A_computed,1,4),reshape(D_computed,1,2)]; | ||
91 | |||
92 | figure(fig_disp);subplot(1,3,2);imagesc(J_computed);axis('image'); | ||
93 | title(sprintf('iter:%d: dx=%3.3f, dy = %3.3f',k,D_computed(1),D_computed(2)));drawnow; | ||
94 | |||
95 | k = k+1; | ||
96 | end | ||
97 | |||
98 | [tmp,id] = min(errs); | ||
99 | A = reshape(records(id,1:4),2,2); | ||
100 | D = reshape(records(id,5:6),1,2); | ||
101 | |||
102 | J_computed = compute_J(A,D,img_i,center_i,window_size_h); | ||
103 | mask = exp(-abs(J_computed-J)/sig); | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/compute_J.m b/SD-VBS/common/toolbox/toolbox_basic/affine/compute_J.m new file mode 100755 index 0000000..80db273 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/compute_J.m | |||
@@ -0,0 +1,31 @@ | |||
1 | function [JJ,mask] = compute_J(A,D,I,center,window_size_h) | ||
2 | %% function J = compute_J(A,D,I,center,window_size_h) | ||
3 | % | ||
4 | |||
5 | [size_y,size_x] = size(I); | ||
6 | |||
7 | center_x = center(1); | ||
8 | center_y = center(2); | ||
9 | |||
10 | [XX,YY] = meshgrid(1:size_x,1:size_y); | ||
11 | x = reshape(XX,size_x*size_y,1); | ||
12 | y = reshape(YY,size_x*size_y,1); | ||
13 | index(:,1) = x-center_x; | ||
14 | index(:,2) = y-center_y; | ||
15 | |||
16 | position_new = A*index'+ [D(1),0;0,D(2)]*ones(2,size_x*size_y); | ||
17 | position_new(1,:) = position_new(1,:)+center_x; | ||
18 | position_new(2,:) = position_new(2,:)+center_y; | ||
19 | |||
20 | position_new_x = reshape(position_new(1,:),size_y,size_x); | ||
21 | position_new_y = reshape(position_new(2,:),size_y,size_x); | ||
22 | |||
23 | [J,mask]= m_interp4(I,position_new_x,position_new_y); | ||
24 | |||
25 | JJ = J(center(2)-window_size_h(2):center(2)+window_size_h(2),... | ||
26 | center(1)-window_size_h(1):center(1)+window_size_h(1)); | ||
27 | mask = mask(center(2)-window_size_h(2):center(2)+window_size_h(2),... | ||
28 | center(1)-window_size_h(1):center(1)+window_size_h(1)); | ||
29 | |||
30 | |||
31 | |||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/find_AD.m b/SD-VBS/common/toolbox/toolbox_basic/affine/find_AD.m new file mode 100755 index 0000000..3cccefb --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/find_AD.m | |||
@@ -0,0 +1,82 @@ | |||
1 | function [A,D] = find_AD(I,J,mask,w) | ||
2 | % | ||
3 | % [A,D] = find_AD(I,J,mask,w) | ||
4 | % | ||
5 | % find the matrix affine transform A and displacement D, | ||
6 | % such that SSD difference of I(Ax-d)-J(x) is minimized, | ||
7 | % | ||
8 | |||
9 | % | ||
10 | % Jianbo Shi | ||
11 | % | ||
12 | |||
13 | |||
14 | [gy1,gx1] = grad(I,w); | ||
15 | [gy2,gx2] = grad(J,w); | ||
16 | |||
17 | gx = 0.5*(gx1+gx2); | ||
18 | gy = 0.5*(gy1+gy2); | ||
19 | |||
20 | [size_y,size_x] = size(I); | ||
21 | [center_y,center_x] = find_center(size_y,size_x); | ||
22 | mask = mask(w+1:size_y-w,w+1:size_x-w); | ||
23 | |||
24 | [x,y] = meshgrid(1:size_x,1:size_y); | ||
25 | x = x- center_x; | ||
26 | y = y-center_y; | ||
27 | |||
28 | x = x(w+1:size_y-w,w+1:size_x-w); | ||
29 | y = y(w+1:size_y-w,w+1:size_x-w); | ||
30 | |||
31 | gx_sqr = gx.*mask.*gx; | ||
32 | gx_gy = gx.*mask.*gy; | ||
33 | gy_sqr = gy.*mask.*gy; | ||
34 | |||
35 | x_sqr = x.*x; | ||
36 | x_y = x.*y; | ||
37 | y_sqr = y.*y; | ||
38 | |||
39 | T= zeros(6,6); | ||
40 | T(1,1) = 0.5*trapz(trapz(gx_sqr.*x_sqr)); | ||
41 | T(2,1) = trapz(trapz(gx_gy.*x_y)); | ||
42 | T(3,1) = trapz(trapz(gx_sqr.*x_y)); | ||
43 | T(4,1) = trapz(trapz(gx_gy.*x_sqr)); | ||
44 | T(5,1) = trapz(trapz(gx_sqr.*x)); | ||
45 | T(6,1) = trapz(trapz(gx_gy.*x)); | ||
46 | T(2,2) = 0.5*trapz(trapz(gy_sqr.*y_sqr)); | ||
47 | T(3,2) = trapz(trapz(gx_gy.*y_sqr)); | ||
48 | T(4,2) = trapz(trapz(gy_sqr.*x_y)); | ||
49 | T(5,2) = trapz(trapz(gx_gy.*y)); | ||
50 | T(6,2) = trapz(trapz(gy_sqr.*y)); | ||
51 | T(3,3) = 0.5*trapz(trapz(gx_sqr.*y_sqr)); | ||
52 | T(4,3) = trapz(trapz(gx_gy.*x_y)); | ||
53 | T(5,3) = trapz(trapz(gx_sqr.*y)); | ||
54 | T(6,3) = trapz(trapz(gx_gy.*y)); | ||
55 | T(4,4) = 0.5*trapz(trapz(gy_sqr.*x_sqr)); | ||
56 | T(5,4) = trapz(trapz(gx_gy.*x)); | ||
57 | T(6,4) = trapz(trapz(gy_sqr.*x)); | ||
58 | T(5,5) = 0.5*trapz(trapz(gx_sqr)); | ||
59 | T(6,5) = trapz(trapz(gx_gy)); | ||
60 | T(6,6) = 0.5*trapz(trapz(gy_sqr)); | ||
61 | |||
62 | T = T+T'; | ||
63 | |||
64 | J = J(w+1:size_y-w,w+1:size_x-w); | ||
65 | I = I(w+1:size_y-w,w+1:size_x-w); | ||
66 | |||
67 | |||
68 | diff = (J-I).*mask; | ||
69 | b(1) = trapz(trapz(diff.*gx.*x)); | ||
70 | b(2) = trapz(trapz(diff.*gy.*y)); | ||
71 | b(3) = trapz(trapz(diff.*gx.*y)); | ||
72 | b(4) = trapz(trapz(diff.*gy.*x)); | ||
73 | b(5) = trapz(trapz(diff.*gx)); | ||
74 | b(6) = trapz(trapz(diff.*gy)); | ||
75 | |||
76 | a = inv(T)*b'; | ||
77 | |||
78 | A = [1+a(1), a(3); | ||
79 | a(4),1+a(2)]; | ||
80 | |||
81 | D= [a(5),a(6)]; | ||
82 | |||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/find_D.m b/SD-VBS/common/toolbox/toolbox_basic/affine/find_D.m new file mode 100755 index 0000000..1e42cb2 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/find_D.m | |||
@@ -0,0 +1,65 @@ | |||
1 | function D = find_D(I,J,mask,w) | ||
2 | % | ||
3 | % function D = find_D(I,J,mask,w) | ||
4 | % | ||
5 | % find the vector D such that it minimizes then | ||
6 | % difference between I(Ax-d)-J(x). | ||
7 | % | ||
8 | % mask: the weight matrix, | ||
9 | % w: window size for estimating gradiant, use a large value | ||
10 | % when A,D are large. | ||
11 | % | ||
12 | |||
13 | % | ||
14 | % NOTE: Because gradient values on the boarder regions of | ||
15 | % I and J can not be computed accuately when using | ||
16 | % a gaussian of large support, those boarder regions | ||
17 | % of width w are not used in computing D. | ||
18 | % | ||
19 | |||
20 | % | ||
21 | % Jianbo Shi | ||
22 | % | ||
23 | |||
24 | [gy1,gx1] = grad(I,w); | ||
25 | [gy2,gx2] = grad(J,w); | ||
26 | |||
27 | gx = 0.5*(gx1+gx2); | ||
28 | gy = 0.5*(gy1+gy2); | ||
29 | |||
30 | [size_y,size_x] = size(I); | ||
31 | [center_y,center_x] = find_center(size_y,size_x); | ||
32 | mask = mask(w+1:size_y-w,w+1:size_x-w); | ||
33 | |||
34 | [x,y] = meshgrid(1:size_x,1:size_y); | ||
35 | x = x- center_x; | ||
36 | y = y-center_y; | ||
37 | |||
38 | x = x(w+1:size_y-w,w+1:size_x-w); | ||
39 | y = y(w+1:size_y-w,w+1:size_x-w); | ||
40 | |||
41 | gx_sqr = gx.*mask.*gx; | ||
42 | gx_gy = gx.*mask.*gy; | ||
43 | gy_sqr = gy.*mask.*gy; | ||
44 | |||
45 | |||
46 | T= zeros(2,2); | ||
47 | |||
48 | T(1,1) = 0.5*trapz(trapz(gx_sqr)); | ||
49 | T(2,1) = trapz(trapz(gx_gy)); | ||
50 | T(2,2) = 0.5*trapz(trapz(gy_sqr)); | ||
51 | |||
52 | T = T+T'; | ||
53 | |||
54 | J = J(w+1:size_y-w,w+1:size_x-w); | ||
55 | I = I(w+1:size_y-w,w+1:size_x-w); | ||
56 | |||
57 | |||
58 | diff = (J-I).*mask; | ||
59 | b(1) = trapz(trapz(diff.*gx)); | ||
60 | b(2) = trapz(trapz(diff.*gy)); | ||
61 | |||
62 | a = inv(T)*b'; | ||
63 | |||
64 | D= [a(1),a(2)]; | ||
65 | |||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/find_center.m b/SD-VBS/common/toolbox/toolbox_basic/affine/find_center.m new file mode 100755 index 0000000..b12ac7b --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/find_center.m | |||
@@ -0,0 +1,4 @@ | |||
1 | function [center_x,center_y] = find_center(size_x,size_y) | ||
2 | |||
3 | center_x = 0.5*(size_x +1); | ||
4 | center_y = 0.5*(size_y +1); | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/gen_feature_s.m b/SD-VBS/common/toolbox/toolbox_basic/affine/gen_feature_s.m new file mode 100755 index 0000000..3c113e9 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/gen_feature_s.m | |||
@@ -0,0 +1,17 @@ | |||
1 | function I = gen_feature_s(size_of_feature) | ||
2 | % function I = gen_feature(size_of_feature) | ||
3 | % generates a spherical features with size | ||
4 | % of "size_of_feature" | ||
5 | % | ||
6 | |||
7 | ss = round(0.4*size_of_feature); | ||
8 | [X,Y,II] = hemisphere_s(ss); | ||
9 | |||
10 | II = abs(II); | ||
11 | II = 1/max(max(II))*II; | ||
12 | |||
13 | I = zeros(size_of_feature,size_of_feature); | ||
14 | |||
15 | t = round((size_of_feature-ss)/2); | ||
16 | |||
17 | I(1+t:1+t+ss,1+t:1+t+ss) = II; | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/grad.m b/SD-VBS/common/toolbox/toolbox_basic/affine/grad.m new file mode 100755 index 0000000..53bab55 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/grad.m | |||
@@ -0,0 +1,24 @@ | |||
1 | % gradient of an image | ||
2 | % coordinates (r, c) follow matrix convention; | ||
3 | % the gaussian is truncated at x = +- tail, and there are samples samples | ||
4 | % inbetween, where samples = hsamples * 2 + 1 | ||
5 | |||
6 | function[gr,gc] = gradient(image, hsamples) | ||
7 | |||
8 | tail=4; | ||
9 | samples = hsamples * 2 + 1; | ||
10 | |||
11 | x = linspace(-tail, tail, samples); | ||
12 | gauss = exp(-x.^2); | ||
13 | n = gauss * ones(samples,1); | ||
14 | gauss = gauss/n; | ||
15 | |||
16 | gaussderiv = -x.*gauss; | ||
17 | n = -gaussderiv*linspace(1,samples,samples)'; | ||
18 | gaussderiv = gaussderiv/n; | ||
19 | |||
20 | gr = conv2(conv2(image, gaussderiv','valid'), gauss,'valid'); | ||
21 | gc = conv2(conv2(image, gaussderiv,'valid'), gauss','valid'); | ||
22 | |||
23 | %gr = conv2(conv2(image, gaussderiv','same'), gauss,'same'); | ||
24 | %gc = conv2(conv2(image, gaussderiv,'same'), gauss','same'); | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/hemisphere_s.m b/SD-VBS/common/toolbox/toolbox_basic/affine/hemisphere_s.m new file mode 100755 index 0000000..5300183 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/hemisphere_s.m | |||
@@ -0,0 +1,27 @@ | |||
1 | function [x,y,z] = hemisphere(r) | ||
2 | %HEMISPHERE Generate sphere and transform from spherical coordinates. | ||
3 | % | ||
4 | % [X,Y,Z] = HEMISPHERE(N) generates three (n+1)-by-(n+1) | ||
5 | % matrices so that SURF(X,Y,Z) produces a sphere. | ||
6 | % | ||
7 | % [X,Y,Z] = HEMISPHERE(R,N) generates three (n+1)-by-(n+1) | ||
8 | % matrices so that SURF(X,Y,Z,R) produces a sphere colored by R | ||
9 | % | ||
10 | % [X,Y,Z] = HEMISPHERE(R,THETA,PHI) converts from spherical coordinates | ||
11 | % to cartesian coordinates. | ||
12 | |||
13 | % Modified from | ||
14 | % Clay M. Thompson 4-24-91 | ||
15 | % Copyright (c) 1991-92 by the MathWorks, Inc. | ||
16 | % by Carlo Tomasi | ||
17 | |||
18 | error(nargchk(1,3,nargin)); | ||
19 | |||
20 | n = r; | ||
21 | % 0 <= theta <= 2*pi and 0 <= phi <= pi/2 | ||
22 | [theta,phi] = meshgrid((pi/n/2)*[-n:2:n],(pi/2/n)*[-n:2:n]); | ||
23 | r = ones(n+1,n+1); | ||
24 | |||
25 | x = r .* cos(phi) .* sin(theta); | ||
26 | y = r .* sin(phi); | ||
27 | z = r .* cos(phi) .* cos(theta).*phi.*theta; | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/im.m b/SD-VBS/common/toolbox/toolbox_basic/affine/im.m new file mode 100755 index 0000000..6450120 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/im.m | |||
@@ -0,0 +1,3 @@ | |||
1 | function im(I) | ||
2 | |||
3 | imagesc(I);axis('image');drawnow; \ No newline at end of file | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/iter_AD.m b/SD-VBS/common/toolbox/toolbox_basic/affine/iter_AD.m new file mode 100755 index 0000000..50bdae1 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/iter_AD.m | |||
@@ -0,0 +1,26 @@ | |||
1 | function [A,D] = iter_AD(I,J,mask,w,k,num_trans) | ||
2 | % | ||
3 | % function [A,D] = iter_AD(I,J,mask,w,k,num_trans) | ||
4 | % | ||
5 | % find the affine motion A, and displacement D, | ||
6 | % such that difference between I(Ax-D) and J(x) is minimized. | ||
7 | % If k <= num_trans, only translation is computed. This is useful | ||
8 | % in practice, when translation is relative large. | ||
9 | % | ||
10 | % mask: the weight matrix, | ||
11 | % w: window size for estimating gradiant, use a large value | ||
12 | % when A,D are large. | ||
13 | % | ||
14 | |||
15 | % | ||
16 | % Jianbo Shi | ||
17 | % | ||
18 | |||
19 | |||
20 | if k <= num_trans, | ||
21 | D = find_D(I,J,mask,w); | ||
22 | A = eye(2); | ||
23 | else | ||
24 | [A,D] = find_AD(I,J,mask,w); | ||
25 | end | ||
26 | |||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/m_interp4.m b/SD-VBS/common/toolbox/toolbox_basic/affine/m_interp4.m new file mode 100755 index 0000000..314f140 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/m_interp4.m | |||
@@ -0,0 +1,49 @@ | |||
1 | function [F,mask] = m_interp4(z,s,t) | ||
2 | %INTERP4 2-D bilinear data interpolation. | ||
3 | % ZI = INTERP4(Z,XI,YI) assumes X = 1:N and Y = 1:M, where | ||
4 | % [M,N] = SIZE(Z). | ||
5 | % | ||
6 | % Copyright (c) 1984-93 by The MathWorks, Inc. | ||
7 | % Clay M. Thompson 4-26-91, revised 7-3-91, 3-22-93 by CMT. | ||
8 | % | ||
9 | % modified to | ||
10 | |||
11 | |||
12 | [nrows,ncols] = size(z); | ||
13 | |||
14 | |||
15 | if any(size(z)<[3 3]), error('Z must be at least 3-by-3.'); end | ||
16 | if size(s)~=size(t), error('XI and YI must be the same size.'); end | ||
17 | |||
18 | % Check for out of range values of s and set to 1 | ||
19 | sout = find((s<1)|(s>ncols)); | ||
20 | if length(sout)>0, s(sout) = ones(size(sout)); end | ||
21 | |||
22 | % Check for out of range values of t and set to 1 | ||
23 | tout = find((t<1)|(t>nrows)); | ||
24 | if length(tout)>0, t(tout) = ones(size(tout)); end | ||
25 | |||
26 | % Matrix element indexing | ||
27 | ndx = floor(t)+floor(s-1)*nrows; | ||
28 | |||
29 | % Compute intepolation parameters, check for boundary value. | ||
30 | d = find(s==ncols); | ||
31 | s(:) = (s - floor(s)); | ||
32 | if length(d)>0, s(d) = s(d)+1; ndx(d) = ndx(d)-nrows; end | ||
33 | |||
34 | % Compute intepolation parameters, check for boundary value. | ||
35 | d = find(t==nrows); | ||
36 | t(:) = (t - floor(t)); | ||
37 | if length(d)>0, t(d) = t(d)+1; ndx(d) = ndx(d)-1; end | ||
38 | d = []; | ||
39 | |||
40 | % Now interpolate, reuse u and v to save memory. | ||
41 | F = ( z(ndx).*(1-t) + z(ndx+1).*t ).*(1-s) + ... | ||
42 | ( z(ndx+nrows).*(1-t) + z(ndx+(nrows+1)).*t ).*s; | ||
43 | |||
44 | mask = ones(size(z)); | ||
45 | |||
46 | % Now set out of range values to zeros. | ||
47 | if length(sout)>0, F(sout) = zeros(size(sout));mask(sout)=zeros(size(sout));end | ||
48 | if length(tout)>0, F(tout) = zeros(size(tout));mask(tout)=zeros(size(tout));end | ||
49 | |||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/norm_inten.m b/SD-VBS/common/toolbox/toolbox_basic/affine/norm_inten.m new file mode 100755 index 0000000..8e8865b --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/norm_inten.m | |||
@@ -0,0 +1,11 @@ | |||
1 | function I = norm_inten(J) | ||
2 | % | ||
3 | % I = norm_inten(J) | ||
4 | % | ||
5 | % normalize image intensity to the range of 0.0-1.0 | ||
6 | % | ||
7 | |||
8 | max_J = max(max(J)); | ||
9 | min_J = min(min(J)); | ||
10 | |||
11 | I = (J-min_J)/(max_J-min_J); | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/pan.0.pgm b/SD-VBS/common/toolbox/toolbox_basic/affine/pan.0.pgm new file mode 100755 index 0000000..2e7b5f6 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/pan.0.pgm | |||
@@ -0,0 +1,53 @@ | |||
1 | P5 | ||
2 | # CREATOR: XV Version 3.10a Rev: 12/29/94 | ||
3 | 128 96 | ||
4 | 255 | ||
5 | qquvvvvwzyz{}~qrrsvxwxyzzz{{|~~tuwuruzzyzz{}}}tvwxyxwwz{{z|{|}tvwwyz{ywz}}mzuuvvvurvuwxz{{{}BUwxz}~}~{{GcZW}}~}~Geoxae~~ηFakswveyӺùIbjnpu|x_nbb_eq¿漭㖽>q}̶Gbjkloqw|pnrcbbehq.ٻfbf0^xF_VYqH^ehkoopqyf|x;33>AVyi5!qcMi<2<3WWB=XFoZMqeHNtMdfVwNiv\uat}c*dHY]ZtG]aced`C233++%)(*59:@7B>F>FEA=<\g^gb\^Ya][\PD83.2<Fgua?>X_=Hj?42)Wh3%GkgpD8xb`vJQjFktVR|LvtTytLU{OdoU}N]sSwZl[+eIVYRqI[^___W?519+&'112>;9G<@;E8BG<:5V[FYYLPIHHMA4=A83:PMd{m@BdmUOi?$ByC!'Q_pS$l|hSrJMqG^ugpOs~Rq|QRN\wM}SYyQuPeX#_NQ_RpFX\]^YK512:)&(032>?9B=E:G7AJ@B;W\GRWHOHEJIB5>C@:4NQ^xp<5[njFlJ, %pIQk]L*&Xw{qReNBnIGeԨYjKayPRXQQuXQOtUb^%[QPcRoGUY]YNC445=)%+.01?98EAG=E6>H@B<S\KPY?LFKOKG9GA8>7BFRwvN\r>itK2WRJmRZ9(AepvPZ[BpVCfΨU]N[zSKgUPjbJQpX\d%UVPhNmFUYYTG>26;?*'+247><;HCM@I7<LCE:T[JKWAJJMVJMAGB394<GLny]#HpGYY:!Eh-(ek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}}~s@;kbNp~}{zxwwwttrrppmmihhfdb`_][VIKMLI5 | ||
10 | |||
11 | |||
12 | |||
13 | |||
14 | |||
15 | |||
16 | |||
17 | |||
18 | 5H]vbW* #$$&&%'&%$&'%$##&$$$#$$$##$$#!##$"IIIHG=* | ||
19 | |||
20 | (KUf~v1GCVvN$!-01* ! ! ! ILLJLE2 | ||
21 | |||
22 | |||
23 | |||
24 | |||
25 | |||
26 | |||
27 | ;R]qvHE`sF'&0/!=?B' JJLJGB8(3>2,94>BB.7AB11<'' | ||
28 | "5$EXg~p|W5((..!!%GHN) <YT:EBMXS\jcIM\kfKJJJIE?)5B42@;FKH3@IG9;D | ||
29 | |||
30 | #nf$!" | ||
31 | ;Xfx|yr:T47A3,MSQ* $2 TigRMHYc]]ieMLbonIKLLIGB4DR;;HAVXY9M]^CN^' | ||
32 | "^Z%!"<iTI<hG:W7YcmZ<).+1Lt{=FCyo6s' Bk*B]RSKSr|qWSRhxqnvq\etLKJJKGE:VeCK\TkokBcruL[q/ | ||
33 | |||
34 | *m`%06$?hRJBnEQ0W`adwotp5Rt9^X7ʇj1@1;QOQP`|`d`xJLMLIHG;YoJUg]t}pEn}~L^o(*n[,PdC M?qDT́!EY\bYQZ^hy}|wcql3Tu.5ρ_ը׀/C5LPTXNiqpoIKMKKIG<\rGZg^zmDpz~Mcn% | ||
35 | /td0g|K O<xBY{?UXWL<4C_v{yyixo1\w.;zXȽz>5*U{`<Sqs{JLMNNKG>_uH\h_xfDt|~Ngk! /t_$$&T={@^z @U\iuxxzxs3Zs-AyjvO@2RRIQMxxst~KNNNOO_WesG_jbxfHw}Nnj | ||
36 | 5|]$##Z??bpQdPY`inr}|u}e7Vu%Ovlˁz8HwgMeZxvrrLNNNVgjYgvKegcygJx}~Qsi !#3_O#>EL\cOONWWRT]kqkozd:1><"2LTSqgM=FNHFIUqrqpOPRRdmkXfuQjhg~jLzPxf | ||
37 | |||
38 | |||
39 | #&!]mOKIOY_badin\G:6$<WZ_y¿ԵH^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%&&'(),*,/2FGFGEB?2 [ԯ❝9-))('%'''&&((+---.022GHHGFB?7& oϦۻʙn+++(()'&%&'*+--.04333FFFGFB?9*~קַ§.-+*((')()+,-./013444FGJIGDA;0 "ݵS5/++,+++-/./10362251DGGGEB@<4& BҰʴ⡶)-.,,+*,.00122244444FFEEDA@=8- _ླྀ±źћ60,,-.../0334555553/BBDDCB?;6." y̹ܵǹđn-.-/../112333335421EDDEB@?<80%6ѕIJ6.,/121134464543244ADECAA?<93'NⲫĹ̬Z20012/233121132122@?B@A?A=:4+!dͷȵžæ/44314442034532441BABBCB@><82& љĬ}Q84443444222333121>@CDDCB?<93(Dú݊bnt88432421255422122=>@AABA@<94+"nݱ캙vkwwyyWpvpU973222122233220252@AABCB@><97.#(rH 9ltvpmb\ZZrT !&nks2.BS@78423322312311221/11>@ABABA=<;72'(0&;_ggea\SQU]iSflV7@CDK<3443223322334443233110=>CCBBAB@<94)! ""!!"""##%"#&'!(AW^_``\XY^XWbP%xmZ8:>FNI:899:7878557677766777554>?@BABB@?<95. !!"""##$%%##$%%&((''(-5@LSWYXVTRKDI^`hz`5*, /uaX=;=DOYI889:9::999879::999:98886 \ No newline at end of file | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/pan.1.pgm b/SD-VBS/common/toolbox/toolbox_basic/affine/pan.1.pgm new file mode 100755 index 0000000..9d57f70 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/pan.1.pgm | |||
@@ -0,0 +1,59 @@ | |||
1 | P5 | ||
2 | # CREATOR: XV Version 3.10a Rev: 12/29/94 | ||
3 | 128 96 | ||
4 | 255 | ||
5 | prsrxxwxz{{||||}~~ſ¿prsttuyxyyz{|{{|~tuuuwwvwyxzz{|}tuwwxxzyy{{{{||}~uvuwyyz{~{z~~~_`k{x{{zzywzyz{{{}~~8:E[{|}57@_WYĿ:9D`ny_iδ8:B^kryxc}ѷ¸8;C[gorv}wbned_gxߍ0mt9;D^iloquz~nqxifdefq1ͺx^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<)51Uz}`qN&QuTpwaaoYm]tr`fie~EAqWEEGIHEG0! | ||
9 | #"6FEHQKTEQDERKMDEae^UR^^d\V[P`^KI3</.GNmB/LMEMTcu{zvzJ53/By\aY Dw[e]faVd`ch_jcyJ<|tXEFGIIIG3+(%+O`H'(2:>IIFOLU@NIHTKKDCe_ZTMkg\UXcW^^JH6:6+DGb<@es~|I0*3.2y}s|zaueeae_h`khr]:z}YFEFIIJI323()UkO*(.9AIDBKGOCNJKRCNHA^UT[Jg`WVbdZV[JNA5<0>I\.Ehpx}yxz{I'!,$#g~znlgt[qchYufwiii;oYEGIKLIPI;:GM[c^X[]acgklmmqpoqswuvwt{zy}zBKSG<69G[ZI@EUlwT(IFEFILMYgiikoprvwy}}Y-UM2)-88{}B/'8Xsi4(Imnnmnmlhhigeccecb__`a^^\^]\\\]^]]][\^^``bbceebFGGJLLZYOMNOOQRTTSUVYYYZ[[\\^^___^^^`abbcegffffgijiknnnonooqY(2`TGCA=KK9>V_xwHPoHIJMMN^lqopqrsuwzz}n4Ajymei`_vM@FGHJKKZghgilnoruwwz|}~~M;awWj~}|{yxwvtrpomlkhffebaaa_\[YWTKMMLNMK8" | ||
10 | |||
11 | |||
12 | |||
13 | |||
14 | |||
15 | |||
16 | |||
17 | |||
18 | |||
19 | |||
20 | ,?QttaA!!"$&%$&'''&(&'&'(&%%#%$"$$%#!"##"HKKJJKI?+ | ||
21 | |||
22 | |||
23 | |||
24 | ASd|>AGRve5"++!$" .12,!! "! ! JJLMLLKD5 | ||
25 | |||
26 | |||
27 | |||
28 | 3P\m|E?Wwz*11''1/ =AB) KKNMKKID;%->5-:3:@C.5AC52= (+3 !?Wf{~o{~(00&%-. #$EDN+ 8WX=GCMZTZfdIL]IJLJKKKJA+1D3,@8FKL.9GG64F kj(#$4S`u£|x3qq;S69G6*MQQ( + | ||
29 | NeeRMDRd^]feGG[JJKLONMKE2>S@9LAVXY9H[]CG_) | ||
30 | |||
31 | |||
32 | \[%"$<hSF=jF:|\bm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>.Do[6^trPMMPRVjokIBiln~]xad | ||
51 | %'!?渲7<3La^CVlǨMNOQRYlpmK>rclx^v[o | ||
52 | ')`QEMTQFHBs~ѳNMPOOYmpkN8|~`kvat^z' | ||
53 | '&:Y[[UTG@ʎwzϴLMNPPYnrlO6z]tpcn`z- | ||
54 | ))˵٠aǍz|DZ¼uNPQPQ]qtlN+o`{}tmgmw7& | ||
55 | ! !/MOHnlZFZ}Q¾ƪÿmNNMNQ]qtlP$a^]rvbxv9 !!xkD\P|]p~álLNPRR_wytgYbs]XpYk~UF{ees,$!!6RazrViƬxļnKLMPS`rssvy|LZ?HKDG:rknyƳ½wKLNPRZH9:99<=<>=@=::<;;==?@BGLORUY_ciosx~оLKMOP^lnlllmnopsuuuwwvutsqpopnmmjhgeeb`__]\_x{}}~JLMKN\nrsru{}Յ{zvvtrrqpprqpoommmmkkihgheLKJNOK: | ||
56 | |||
57 | $',048:>CHNTX^chdLMLLMNH* }ոo{LJJLJJG4 | ||
58 | E(%!KKLLIIH>%ټ{&#!! !!!!" !#LLKLKIE?- ϭ2&$#""!!! !!""!!"!#""$MKLMJFGB5 4֥`+$#$$!$$""#! ######%'&KIJJIGEB:( Nζɻ#)'%$"###""#####!#%%&%&)KHHJIIFC?/ lɪᰡ<+($$$'&&$#$$%$#$%&&&),+KIHJJHGD?4# ⫗s(*(&'&&&&&&&&&'('&)*,..IHHIJFECA9(-ฤڬ7-,)(''&'''')(&'*-./123IIIHEFECA<0 =뾬ֽЫ\0-*)(''''('')*+,--0123HHGHHIGEC>4%Uó(,*+)))*+***+,-/223365GEHIFFDDB?7)k¶찯D0,**((*+++++./0344223GGHGGFIFCA</"ѻɾͿۡz-,-.-)+,,-./131343343EDDFEEEDC@<2&3ƟЙ6.,---,,..0/023332222CCDFGHGEA><6-!Fةk0/-/.,-./01212342243DDDEGGECB@<7."`Īɼλ1.-.--.-0/0223310110CBDDECDB??<80$,{wټʶǼZ111/./0110111310110BABDEEFC@?=;4) 7ƺy0200010011331110121D?ACEDEECA>;7,#lͺqyqwnȽM5331121/1220100220?=@BDDDDB@=97.%!̯jrut~Uhj͟`9431121212111100/00@=AAEHGDC@>:62&RA*\qsrmaYWUkT#jj;=UG7322243122112100110-.?=>@CDEDCA><83* ,0$,Rfgeb_URU]hS | ||
59 | |bX5?BIL;2222201232332111221011/?<=>BDDA@BA>;4+! !" !""!$$%$'&(6Q\\_b]ZXZXR^yY(܊o|Z:;AJOE7355356866544565565553311>=??BBCDCA@>950! "!!#"!""$$%#$$%%&*29GQUWYUTTLDEVWZeX9180>ךryM==AJTS<6799788768987677886676765 \ No newline at end of file | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/readpgm.m b/SD-VBS/common/toolbox/toolbox_basic/affine/readpgm.m new file mode 100755 index 0000000..a5fd7f2 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/readpgm.m | |||
@@ -0,0 +1,26 @@ | |||
1 | function img = pgmread(filename) | ||
2 | % function img = pgmread(filename) | ||
3 | % this is my version of pgmread for the pgm file created by XV. | ||
4 | % | ||
5 | % this program also corrects for the shifts in the image from pm file. | ||
6 | |||
7 | |||
8 | fid = fopen(filename,'r'); | ||
9 | fscanf(fid, 'P5\n'); | ||
10 | cmt = '#'; | ||
11 | while findstr(cmt, '#'), | ||
12 | cmt = fgets(fid); | ||
13 | if length(findstr(cmt, '#')) ~= 1, | ||
14 | YX = sscanf(cmt, '%d %d'); | ||
15 | y = YX(1); x = YX(2); | ||
16 | end | ||
17 | end | ||
18 | |||
19 | fgets(fid); | ||
20 | |||
21 | %img = fscanf(fid,'%d',size); | ||
22 | %img = img'; | ||
23 | |||
24 | img = fread(fid,[y,x],'uint8'); | ||
25 | img = img'; | ||
26 | fclose(fid); | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/simulation.m b/SD-VBS/common/toolbox/toolbox_basic/affine/simulation.m new file mode 100755 index 0000000..2186a6d --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/simulation.m | |||
@@ -0,0 +1,42 @@ | |||
1 | clear | ||
2 | |||
3 | figure(1);colormap(gray); | ||
4 | |||
5 | %------------ Parameters -------------------------- | ||
6 | window_size_h = 40; | ||
7 | window_size = 2*window_size_h+1; | ||
8 | noise_level = 40/256; | ||
9 | |||
10 | % define A and D | ||
11 | x_ext = -0.423; | ||
12 | ext = 1.232; | ||
13 | A = [ext+x_ext, 0.2534; 0.3423,ext]; | ||
14 | |||
15 | D = [3,1]; | ||
16 | |||
17 | %------------- compute image I and J --------------- | ||
18 | disp('generating I') | ||
19 | I_init = gen_feature_s(window_size); | ||
20 | [size_y,size_x] = size(I_init); | ||
21 | |||
22 | %define image center | ||
23 | [center_x,center_y] = find_center(size_x,size_y); | ||
24 | |||
25 | % adding noise to image I | ||
26 | I = I_init+noise_level*rand(size_y,size_x); | ||
27 | % make sure all intensities are positive | ||
28 | I = I.*(I>0); | ||
29 | |||
30 | disp('computing J') | ||
31 | J_init = compute_J(A,D,I_init,[center_x,center_y],[window_size_h,window_size_h]); | ||
32 | J = J_init+noise_level*rand(size_y,size_x); | ||
33 | J = J.*(J>0); | ||
34 | |||
35 | |||
36 | %------------- compute A and residue ---------------- | ||
37 | c = [center_x,center_y]; | ||
38 | num_iter = 8; w = 9;win_h = [window_size_h,window_size_h]; | ||
39 | |||
40 | fig_disp = 1; | ||
41 | [Ac,Dc,mask] = compute_AD_disp(I,J,c,c,win_h,num_iter,w,fig_disp); | ||
42 | |||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/sports1_11_28.jpeg b/SD-VBS/common/toolbox/toolbox_basic/affine/sports1_11_28.jpeg new file mode 100755 index 0000000..39ebed5 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/sports1_11_28.jpeg | |||
Binary files differ | |||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/test_affine.m b/SD-VBS/common/toolbox/toolbox_basic/affine/test_affine.m new file mode 100755 index 0000000..41b48b9 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/test_affine.m | |||
@@ -0,0 +1,33 @@ | |||
1 | %%% This is a test program for Affine tracker %%%% | ||
2 | |||
3 | disp(sprintf('This is a test program of Affine tracker')); | ||
4 | |||
5 | %% read in images | ||
6 | |||
7 | disp(sprintf('read in images')); | ||
8 | I = readpgm('pan.0.pgm'); | ||
9 | J = readpgm('pan.1.pgm'); | ||
10 | |||
11 | figure(1); im(I); colormap(gray); | ||
12 | figure(2); im(J); colormap(gray); | ||
13 | |||
14 | |||
15 | figure(1);disp(sprintf('click on the center of a image window')); | ||
16 | c = round(ginput(1)); | ||
17 | |||
18 | %% compute the displacement of that image window | ||
19 | disp(sprintf('computing...')); | ||
20 | |||
21 | win_hsize_temp = [8,8]; | ||
22 | w = 3; | ||
23 | num_iter = 6; | ||
24 | |||
25 | disp_flag = 1; | ||
26 | |||
27 | win_h = win_hsize_temp + [w,w]; | ||
28 | if disp_flag == 1, | ||
29 | figure_id = 3; | ||
30 | [A,D,mask] = compute_AD_disp(I,J,c,c,win_h,num_iter,w,figure_id); | ||
31 | else | ||
32 | [A,D,mask] = compute_AD(I,J,c,c,win_h,num_iter,w); | ||
33 | end | ||