1 | %
|
---|
2 | % %designed for the good of the world by Philip Torr based on ideas contained in
|
---|
3 | % copyright Philip Torr and Microsoft Corp 2002
|
---|
4 | %
|
---|
5 | % @inproceedings{Torr93b,
|
---|
6 | % author = "Torr, P. H. S. and Murray, D. W.",
|
---|
7 | % title = "Outlier Detection and Motion Segmentation",
|
---|
8 | % booktitle = "Sensor Fusion VI",
|
---|
9 | % editor = "Schenker, P. S.",
|
---|
10 | % publisher = "SPIE volume 2059",
|
---|
11 | % note = "Boston",
|
---|
12 | % pages = {432-443},
|
---|
13 | % year = 1993 }
|
---|
14 | %
|
---|
15 | %
|
---|
16 | % @phdthesis{Torr:thesis,
|
---|
17 | % author="Torr, P. H. S.",
|
---|
18 | % title="Outlier Detection and Motion Segmentation",
|
---|
19 | % school=" Dept. of Engineering Science, University of Oxford",
|
---|
20 | % year=1995}
|
---|
21 | %
|
---|
22 | % @inproceedings{Beardsley96a,
|
---|
23 | % author="Beardsley, P. and Torr, P. H. S. and Zisserman, A.",
|
---|
24 | % title="{3D} Model Aquisition from Extended Image Sequences",
|
---|
25 | % booktitle=eccv4.2,
|
---|
26 | % editor = "Buxton, B. and Cipolla R.",
|
---|
27 | % publisher = "Springer--Verlag",
|
---|
28 | % pages={683--695},
|
---|
29 | % year=1996}
|
---|
30 |
|
---|
31 |
|
---|
32 | %
|
---|
33 | % \pai
|
---|
34 | % \bi
|
---|
35 | % \item {\tt im1, im2} the two input images, arrays of doubles as described in
|
---|
36 | % Section~\ref{det_cor:sec}.
|
---|
37 | % \item {\tt clist1, clist2} two $nc \times 2$ arrays of corner positions
|
---|
38 | % as described in
|
---|
39 | % Section~\ref{det_cor:sec}, $nc$ is the number of corners.
|
---|
40 | % \item {\tt max\_disparity} the size of the search window (square) in the next image.
|
---|
41 | % \item {\tt half\_size} the half size of the correlation window.
|
---|
42 | % \ei
|
---|
43 | %
|
---|
44 | % \pao
|
---|
45 | % \bi
|
---|
46 | % \item {\tt matches12} matches in an $n \times 4$ array of matches $(x,y,x'y')$, in this
|
---|
47 | % case $n$ is the number of matches.
|
---|
48 | % \item {\tt minc} is the minimum value of $C$ for each corner.
|
---|
49 | % \item {\tt mat12} is defined such that {\tt mat(i) = j} means corner $i$ matches to
|
---|
50 | % corner $j$.
|
---|
51 | % \ei
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 | function [matches12,minc,mat12] = torr_corn_matcher(im1, im2, clist1, clist2, max_disparity,half_size)
|
---|
56 |
|
---|
57 | maxc = 10000000000;
|
---|
58 | mat12 = zeros(length(clist1),1);
|
---|
59 |
|
---|
60 | %holds the value of the minimum correlation for each corner
|
---|
61 | minc = ones(length(clist1),1)* maxc;
|
---|
62 |
|
---|
63 | for i = 1:length(clist1)
|
---|
64 | for j = 1:length(clist2)
|
---|
65 | if sum(abs(clist1(i,:) - clist2(j,:))) < max_disparity
|
---|
66 | A = patch_match(im1,im2,clist1(i,2),clist1(i,1),clist2(j,2),clist2(j,1),half_size,minc(i));
|
---|
67 | %non mex correlation code
|
---|
68 | % for xi = -3:3
|
---|
69 | % for yi = -3:3
|
---|
70 | % %maybe add Birchfield and Tomasi here?
|
---|
71 | % A(i,j) = A(i,j) + abs(im1(clist1(i,2)+xi,clist1(i,1)+yi) -im2(clist2(j,2)+xi,clist2(j,1)+yi));
|
---|
72 | % %A(i,j) = sum(abs(im1(i,:)- im2(j,:)));
|
---|
73 | % %A(i,j) = sum(abs(clist1(i,:) - clist2(j,:)));
|
---|
74 | % %jump out
|
---|
75 | % if A(i,j) > minc(i)
|
---|
76 | % xi = 3;
|
---|
77 | % yi = 3;
|
---|
78 | % end
|
---|
79 | % end
|
---|
80 | % end
|
---|
81 | if A < minc(i);
|
---|
82 | minc(i) = A;
|
---|
83 | mat12(i) = j;
|
---|
84 | end
|
---|
85 | end
|
---|
86 | end
|
---|
87 | end
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 | n_matches = 0;
|
---|
92 | for i = 1:length(mat12)
|
---|
93 | if mat12(i) ~= 0
|
---|
94 | n_matches = n_matches +1;
|
---|
95 | matches12(n_matches,:) = [clist1(i,:) clist2(mat12(i),:)];
|
---|
96 | end
|
---|
97 | end
|
---|