-
Notifications
You must be signed in to change notification settings - Fork 12
/
multiSample_APAP.m
35 lines (30 loc) · 1.06 KB
/
multiSample_APAP.m
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
function [matches_1, matches_2] = multiSample_APAP(pts1, pts2)
global fitfn resfn degenfn psize numpar
fitfn = 'homography_fit';
resfn = 'homography_res';
degenfn = 'homography_degen';
psize = 4;
numpar = 9;
% normalise point distribution.
data_orig = [ pts1(1:2,:) ; ones(1,size(pts1,2)) ; pts2(1:2,:) ; ones(1,size(pts2,2)) ];
[data_norm_img1, ~] = normalise2dpts(data_orig(1:3,:));
[data_norm_img2, ~] = normalise2dpts(data_orig(4:6,:));
data_norm = [data_norm_img1; data_norm_img2];
%outlier removal - Multi-GS (RANSAC).
rng(0);
[ ~,res,~,~,~ ] = multigsSampling(100, data_norm, 500, 10);
con = sum(res<=0.05);
[ ~, maxinx ] = max(con);
inliers = find(res(:,maxinx)<=0.05);
matches_1 = pts1(:, inliers);
matches_2 = pts2(:, inliers);
% delete duplicate feature match
[h1, indh1] = sortrows(matches_1');
[~, indk1] = unique(h1,'rows');
matches_1 = matches_1(:, indh1(indk1));
matches_2 = matches_2(:, indh1(indk1));
[h2, indh2] = sortrows(matches_2');
[~, indk2] = unique(h2, 'rows');
matches_1 = matches_1(:, indh2(indk2));
matches_2 = matches_2(:, indh2(indk2));
end