-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.m
More file actions
87 lines (57 loc) · 2.55 KB
/
run.m
File metadata and controls
87 lines (57 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
% Image Stitching Algorithm
% Author: Bicheng Zhang
% Support stich multiple images
% Parameters can be tuned for best performance
%
% Author:
% Bicheng Zhang
% Department of Computer Engineering
% University of Illinois Urbana Champaign
% viczhang1990@gmail.com
%
% March 2014
%% Please specify image folder and image names
img_folder = 'pair_pitching_data/';
img_name_list = char('uttower_1','uttower_2');
%% General paremeters
SHOW_DETAILS = 0; % Show inliers in plots, ransac algorithm info
%% Putative matches parameters
neighbor_size = 10; % Neihbor size used in putative matches
putative_matches_limit = 50; % Number of putative matches selected
%% Harris code parameters
harris_coe.threshold = 5000; % Feature point threshold
harris_coe.sigma = 2.1; % Sigma
harris_coe.radius = 2; % Feature point radius
harris_coe.display_result = 0; % Display features points
%% RANSAC parameters
ransac_coef.minPtNum = 4; % Ransac number of putative matches selected in each iteration
ransac_coef.iterNum = 10000; % Number of total iteration
ransac_coef.thDist = 1; % Ransac inlier distance
total_number_img = size(img_name_list,1);
img_pool = cell(total_number_img);
for i=1:total_number_img
img_pool{i} = imread(sprintf('%s%s', img_folder, img_name_list(i,:)),'jpg');
end
fprintf('Total number of image to stich:%d\n', total_number_img);
for total_unstitched=total_number_img:-1:2
shuffler = fliplr(fullfact([total_unstitched total_unstitched]));
shuffler(~diff(shuffler')',:) = [];
shuffler(shuffler(:,1)>shuffler(:,2),:) = [];
total_iteration = size(shuffler, 1);
fprintf('Total iterations:%d\n', total_iteration);
stich_rank = zeros(total_iteration, 2);
stiched_img_pool = cell(total_iteration);
for i=1:total_iteration
left_img_rgb = img_pool{shuffler(i,1)};
right_img_rgb = img_pool{shuffler(i,2)};
[stiched_img_pool{i}, inliers, residual] = stiching(left_img_rgb, right_img_rgb, harris_coe, ransac_coef, neighbor_size,putative_matches_limit,SHOW_DETAILS);
stich_rank(i, :) = [residual, i];
end
stich_rank = sortrows(stich_rank, 1);
fprintf('Images [%d] [%d] will be stiched with residual:%d\n',shuffler(stich_rank(1,2),1), shuffler(stich_rank(1,2),2),stich_rank(1));
img_pool{shuffler(stich_rank(1,2), 1)} = stiched_img_pool{stich_rank(1,2)};
idx = [1:shuffler(stich_rank(1,2), 2)-1 shuffler(stich_rank(1,2), 2)+1:total_iteration];
img_pool = img_pool(idx);
fprintf('%d images left in img_pool\n', size(img_pool, 2));
end
figure, imshow(img_pool{1});