source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/BlueCCal/MultiCamValidation/CoreFunctions/findinl.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.0 KB
Line 
1% FindInl    find inliers in joint image matrix
2%                        by pairwise epipolar geometry
3%
4% function IdMatIn = findinl(Ws,IdMat,tol)
5% Ws ... 3MxN joint image matrix
6% IdMat ... MxN ... 0 -> no point detected
7%                   1 -> point detected
8% tol ... [pixels] tolerance for the epipolar geometry
9%         the point are accpted as outliers only if they
10%         are closer to the epipolar line than tol
11
12% $Author: svoboda $
13% $Revision: 2.0 $
14% $Id: findinl.m,v 2.0 2003/06/19 12:07:09 svoboda Exp $
15% $State: Exp $
16
17function IdMatIn = findinl(Ws,IdMat,tol)
18
19NoCams = size(IdMat,1);
20
21% fill the array of structures not_used denoted as 0
22% allocate the array of structures for used
23for i=1:NoCams,
24  not_used(i).pts = sum(IdMat(i,:));
25  used(i).pts     = -1;
26end
27
28% allocate IdMat for outliers
29IdMatIn = zeros(size(IdMat));
30
31while (sum([not_used.pts])>1-NoCams),
32  [buff, id.cam_max]  = max([not_used.pts]);
33  used     = add(used, id.cam_max, not_used(id.cam_max).pts);
34  not_used = remove(not_used, id.cam_max);
35  Mask     = repmat(IdMat(id.cam_max,:),NoCams,1);
36  Corresp  = Mask & IdMat;
37  Corresp(id.cam_max,:) = 0;
38  [buff, id.cam_to_pair] = max(sum(Corresp')); % find the camera with most correspondences
39  idx.corr_to_pair = find(sum(IdMat([id.cam_max,id.cam_to_pair],:))==2);
40  % used           = add(used, id.cam_to_pair, not_used(id.cam_to_pair).pts);
41  % not_used = remove(not_used, id.cam_to_pair);
42  if size(idx.corr_to_pair,2)<8,
43        error('Not enough points to compute epipolar geometry in RANSAC validation')
44  end
45  Wspair   = [];
46  Wspair   = Ws(id.cam_max*3-2:id.cam_max*3, idx.corr_to_pair);
47  Wspair   = [Wspair; Ws(id.cam_to_pair*3-2:id.cam_to_pair*3, idx.corr_to_pair)];
48  % id
49  [F, inls] = rEG(Wspair,tol,tol,0.99);
50  IdMatIn(id.cam_max, idx.corr_to_pair(inls)) = 1;
51  IdMat(id.cam_max, :)                                            = 0;
52  IdMat(id.cam_max, idx.corr_to_pair(inls))       = 1;
53end
54
55function list = add(list, id, value)
56list(id).pts = value;
57return
58
59function list = remove(list, id)
60list(id).pts = -1;
61return
Note: See TracBrowser for help on using the repository browser.