summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/sift/src/matlab
diff options
context:
space:
mode:
authorleochanj105 <leochanj@live.unc.edu>2020-10-19 23:09:30 -0400
committerleochanj105 <leochanj@live.unc.edu>2020-10-20 02:40:39 -0400
commitf618466c25d43f3bae9e40920273bf77de1e1149 (patch)
tree460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/benchmarks/sift/src/matlab
parent47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff)
initial sd-vbs
initial sd-vbs add sd-vbs sd-vbs
Diffstat (limited to 'SD-VBS/benchmarks/sift/src/matlab')
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/diffss.m72
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/gaussianss.m216
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/imreadbw.m52
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/imsmooth.c115
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/imsmooth.mexa64bin0 -> 9570 bytes
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/imsmooth.mexglxbin0 -> 7450 bytes
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/imsmooth_.c103
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/mexutils.c98
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/plotmatches.m124
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/plotsiftdescriptor.m169
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/plotsiftframe.m119
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/plotss.m68
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/script_run_profile.m23
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/sift.m110
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/sift_compile.m60
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/sift_demo2.m110
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/sift_gendoc.css159
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/sift_gendoc.m50
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/sift_gendoc.pl296
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/sift_overview.m33
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.c524
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.m79
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/siftdescriptor.mexa64bin0 -> 15700 bytes
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/siftdescriptor.mexglxbin0 -> 13332 bytes
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.c291
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.m33
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/siftlocalmax.mexa64bin0 -> 10836 bytes
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/siftlocalmax.mexglxbin0 -> 8518 bytes
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/siftmatch.c250
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/siftmatch.m60
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/siftmatch.mexa64bin0 -> 11877 bytes
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/siftmatch.mexglxbin0 -> 9607 bytes
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/siftormx.c251
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/siftormx.mexa64bin0 -> 12860 bytes
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/siftormx.mexglxbin0 -> 10524 bytes
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/siftread.m101
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.c342
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.m61
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/siftrefinemx.mexa64bin0 -> 12392 bytes
-rwxr-xr-xSD-VBS/benchmarks/sift/src/matlab/siftrefinemx.mexglxbin0 -> 9007 bytes
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/tightsubplot.m151
41 files changed, 4120 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/sift/src/matlab/diffss.m b/SD-VBS/benchmarks/sift/src/matlab/diffss.m
new file mode 100644
index 0000000..1e65390
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/diffss.m
@@ -0,0 +1,72 @@
1function dss = diffss(ss)
2% DIFFSS Difference of scale space
3% DSS=DIFFSS(SS) returns a scale space DSS obtained by subtracting
4% consecutive levels of the scale space SS.
5%
6% In SIFT, this function is used to compute the difference of
7% Gaussian scale space from the Gaussian scale space of an image.
8%
9% See also GAUSSIANSS(), PDF:SIFT.USER.SS.
10
11% AUTORIGHTS
12% Copyright (c) 2006 The Regents of the University of California.
13% All Rights Reserved.
14%
15% Created by Andrea Vedaldi
16% UCLA Vision Lab - Department of Computer Science
17%
18% Permission to use, copy, modify, and distribute this software and its
19% documentation for educational, research and non-profit purposes,
20% without fee, and without a written agreement is hereby granted,
21% provided that the above copyright notice, this paragraph and the
22% following three paragraphs appear in all copies.
23%
24% This software program and documentation are copyrighted by The Regents
25% of the University of California. The software program and
26% documentation are supplied "as is", without any accompanying services
27% from The Regents. The Regents does not warrant that the operation of
28% the program will be uninterrupted or error-free. The end-user
29% understands that the program was developed for research purposes and
30% is advised not to rely exclusively on the program for any reason.
31%
32% This software embodies a method for which the following patent has
33% been issued: "Method and apparatus for identifying scale invariant
34% features in an image and use of same for locating an object in an
35% image," David G. Lowe, US Patent 6,711,293 (March 23,
36% 2004). Provisional application filed March 8, 1999. Asignee: The
37% University of British Columbia.
38%
39% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
40% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
41% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
42% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
43% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
44% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
45% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
47% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
48% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
49
50dss.smin = ss.smin ;
51dss.smax = ss.smax-1 ;
52dss.omin = ss.omin ;
53dss.O = ss.O ;
54dss.S = ss.S ;
55dss.sigma0 = ss.sigma0 ;
56
57for o=1:dss.O
58 % Can be done at once, but it turns out to be faster
59 % this way
60 [M,N,S] = size(ss.octave{o}) ;
61 dss.octave{o} = zeros(M,N,S-1) ;
62 for s=1:S-1
63 dss.octave{o}(:,:,s) = ...
64 ss.octave{o}(:,:,s+1) - ss.octave{o}(:,:,s) ;
65 end
66end
67
68% for i=1:32
69% for j=1:32
70% fprintf(1, '%f\n', dss.octave{1}(i,j,1));
71% end
72% end
diff --git a/SD-VBS/benchmarks/sift/src/matlab/gaussianss.m b/SD-VBS/benchmarks/sift/src/matlab/gaussianss.m
new file mode 100644
index 0000000..c92383c
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/gaussianss.m
@@ -0,0 +1,216 @@
1function SS = gaussianss(I,sigman,O,S,omin,smin,smax,sigma0)
2% GAUSSIANSS
3% SS = GAUSSIANSS(I,SIGMAN,O,S,OMIN,SMIN,SMAX,SIGMA0) returns the
4% Gaussian scale space of image I. Image I is assumed to be
5% pre-smoothed at level SIGMAN. O,S,OMIN,SMIN,SMAX,SIGMA0 are the
6% parameters of the scale space as explained in PDF:SIFT.USER.SS.
7%
8% See also DIFFSS(), PDF:SIFT.USER.SS.
9
10% History
11% 4-15-2006 Fixed some comments
12
13% AUTORIGHTS
14% Copyright (c) 2006 The Regents of the University of California.
15% All Rights Reserved.
16%
17% Created by Andrea Vedaldi
18% UCLA Vision Lab - Department of Computer Science
19%
20% Permission to use, copy, modify, and distribute this software and its
21% documentation for educational, research and non-profit purposes,
22% without fee, and without a written agreement is hereby granted,
23% provided that the above copyright notice, this paragraph and the
24% following three paragraphs appear in all copies.
25%
26% This software program and documentation are copyrighted by The Regents
27% of the University of California. The software program and
28% documentation are supplied "as is", without any accompanying services
29% from The Regents. The Regents does not warrant that the operation of
30% the program will be uninterrupted or error-free. The end-user
31% understands that the program was developed for research purposes and
32% is advised not to rely exclusively on the program for any reason.
33%
34% This software embodies a method for which the following patent has
35% been issued: "Method and apparatus for identifying scale invariant
36% features in an image and use of same for locating an object in an
37% image," David G. Lowe, US Patent 6,711,293 (March 23,
38% 2004). Provisional application filed March 8, 1999. Asignee: The
39% University of British Columbia.
40%
41% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
42% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
43% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
44% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
45% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
46% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
47% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
48% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
49% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
50% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
51
52% --------------------------------------------------------------------
53% Check the arguments
54% --------------------------------------------------------------------
55% --------------------------------------------------------------------
56% Do the job
57% --------------------------------------------------------------------
58
59% Scale multiplicative step
60k = 2^(1/S) ;
61
62dsigma0 = sigma0 * sqrt(1 - 1/k^2) ; % Scale step factor
63sigman = 0.5 ; % Nominal smoothing of the image
64
65% Scale space structure
66SS.O = O ;
67SS.S = S ;
68SS.sigma0 = sigma0 ;
69SS.omin = omin ;
70SS.smin = smin ;
71SS.smax = smax ;
72
73% If mino < 0, multiply the size of the image.
74% (The rest of the code is consistent with this.)
75
76
77if omin < 0
78 for o=1:-omin
79 I = doubleSize(I) ;
80 end
81elseif omin > 0
82 for o=1:omin
83 I = halveSize(I) ;
84 end
85end
86
87[M,N] = size(I) ;
88
89% Index offset
90so = -smin+1 ;
91
92% --------------------------------------------------------------------
93% First octave
94% --------------------------------------------------------------------
95%
96% The first level of the first octave has scale index (o,s) =
97% (omin,smin) and scale coordinate
98%
99% sigma(omin,smin) = sigma0 2^omin k^smin
100%
101% The input image I is at nominal scale sigman. Thus in order to get
102% the first level of the pyramid we need to apply a smoothing of
103%
104% sqrt( (sigma0 2^omin k^smin)^2 - sigman^2 ).
105%
106% As we have pre-scaled the image omin octaves (up or down,
107% depending on the sign of omin), we need to correct this value
108% by dividing by 2^omin, getting
109%e
110% sqrt( (sigma0 k^smin)^2 - (sigman/2^omin)^2 )
111%
112
113SS.octave{1} = zeros(M,N,smax-smin+1) ;
114SS.octave{1}(:,:,1) = imsmooth(I, ...
115 sqrt((sigma0*k^smin)^2 - (sigman/2^omin)^2)) ;
116
117temp = sqrt((sigma0*k^smin)^2 - (sigman/2^omin)^2) ;
118
119for s=smin+1:smax
120 % Here we go from (omin,s-1) to (omin,s). The extra smoothing
121 % standard deviation is
122 %
123 % (sigma0 2^omin 2^(s/S) )^2 - (simga0 2^omin 2^(s/S-1/S) )^2
124 %
125 % Aftred dividing by 2^omin (to take into account the fact
126 % that the image has been pre-scaled omin octaves), the
127 % standard deviation of the smoothing kernel is
128 %
129 % dsigma = sigma0 k^s sqrt(1-1/k^2)
130 %
131 dsigma = k^s * dsigma0 ;
132 SS.octave{1}(:,:,s +so) = ...
133 imsmooth(squeeze(...
134 SS.octave{1}(:,:,s-1 +so)...
135 ), dsigma ) ;
136end
137
138% --------------------------------------------------------------------
139% Other octaves
140% --------------------------------------------------------------------
141
142for o=2:O
143 % We need to initialize the first level of octave (o,smin) from
144 % the closest possible level of the previous octave. A level (o,s)
145 % in this octave corrsponds to the level (o-1,s+S) in the previous
146 % octave. In particular, the level (o,smin) correspnds to
147 % (o-1,smin+S). However (o-1,smin+S) might not be among the levels
148 % (o-1,smin), ..., (o-1,smax) that we have previously computed.
149 % The closest pick is
150 %
151 % / smin+S if smin+S <= smax
152 % (o-1,sbest) , sbest = |
153 % \ smax if smin+S > smax
154 %
155 % The amount of extra smoothing we need to apply is then given by
156 %
157 % ( sigma0 2^o 2^(smin/S) )^2 - ( sigma0 2^o 2^(sbest/S - 1) )^2
158 %
159 % As usual, we divide by 2^o to cancel out the effect of the
160 % downsampling and we get
161 %
162 % ( sigma 0 k^smin )^2 - ( sigma0 2^o k^(sbest - S) )^2
163 %
164 sbest = min(smin + S, smax) ;
165 TMP = halveSize(squeeze(SS.octave{o-1}(:,:,sbest+so))) ;
166
167 target_sigma = sigma0 * k^smin ;
168 prev_sigma = sigma0 * k^(sbest - S) ;
169
170 if(target_sigma > prev_sigma)
171 temp = sqrt(target_sigma^2 - prev_sigma^2);
172 TMP = imsmooth(TMP, temp ) ;
173 end
174 [M,N] = size(TMP) ;
175
176 SS.octave{o} = zeros(M,N,smax-smin+1) ;
177 SS.octave{o}(:,:,1) = TMP ;
178
179 for s=smin+1:smax
180 % The other levels are determined as above for the first octave.
181 dsigma = k^s * dsigma0 ;
182 SS.octave{o}(:,:,s +so) = ...
183 imsmooth(squeeze(...
184 SS.octave{o}(:,:,s-1 +so)...
185 ), dsigma) ;
186 end
187
188
189end
190
191% -------------------------------------------------------------------------
192% Auxiliary functions
193% -------------------------------------------------------------------------
194function J = doubleSize(I)
195[M,N]=size(I) ;
196J = zeros(2*M,2*N) ;
197J(1:2:end,1:2:end) = I ;
198J(2:2:end-1,2:2:end-1) = ...
199 0.25*I(1:end-1,1:end-1) + ...
200 0.25*I(2:end,1:end-1) + ...
201 0.25*I(1:end-1,2:end) + ...
202 0.25*I(2:end,2:end) ;
203J(2:2:end-1,1:2:end) = ...
204 0.5*I(1:end-1,:) + ...
205 0.5*I(2:end,:) ;
206J(1:2:end,2:2:end-1) = ...
207 0.5*I(:,1:end-1) + ...
208 0.5*I(:,2:end) ;
209
210function J = halveSize(I)
211J=I(1:2:end,1:2:end) ;
212%[M,N] = size(I) ;
213%m=floor((M+1)/2) ;
214%n=floor((N+1)/2) ;
215%J = I(:,1:2:2*n) + I(:,2:2:2*n+1) ;
216%J = 0.25*(J(1:2:2*m,:)+J(2:2:2*m+1,:)) ;
diff --git a/SD-VBS/benchmarks/sift/src/matlab/imreadbw.m b/SD-VBS/benchmarks/sift/src/matlab/imreadbw.m
new file mode 100644
index 0000000..55cb708
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/imreadbw.m
@@ -0,0 +1,52 @@
1function I = imreadbw(file)
2% IMREADBW Reads an image as gray-scale
3% I=IMREADBW(FILE) reads the image FILE and converts the result to a
4% gray scale image (with DOUBLE storage class anr range normalized
5% in [0,1]).
6
7% AUTORIGHTS
8% Copyright (c) 2006 The Regents of the University of California.
9% All Rights Reserved.
10%
11% Created by Andrea Vedaldi
12% UCLA Vision Lab - Department of Computer Science
13%
14% Permission to use, copy, modify, and distribute this software and its
15% documentation for educational, research and non-profit purposes,
16% without fee, and without a written agreement is hereby granted,
17% provided that the above copyright notice, this paragraph and the
18% following three paragraphs appear in all copies.
19%
20% This software program and documentation are copyrighted by The Regents
21% of the University of California. The software program and
22% documentation are supplied "as is", without any accompanying services
23% from The Regents. The Regents does not warrant that the operation of
24% the program will be uninterrupted or error-free. The end-user
25% understands that the program was developed for research purposes and
26% is advised not to rely exclusively on the program for any reason.
27%
28% This software embodies a method for which the following patent has
29% been issued: "Method and apparatus for identifying scale invariant
30% features in an image and use of same for locating an object in an
31% image," David G. Lowe, US Patent 6,711,293 (March 23,
32% 2004). Provisional application filed March 8, 1999. Asignee: The
33% University of British Columbia.
34%
35% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
36% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
37% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
38% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
39% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
40% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
41% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
42% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
43% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
44% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
45
46I=im2double(imread(file)) ;
47
48if(size(I,3) > 1)
49 I = rgb2gray( I ) ;
50end
51
52
diff --git a/SD-VBS/benchmarks/sift/src/matlab/imsmooth.c b/SD-VBS/benchmarks/sift/src/matlab/imsmooth.c
new file mode 100644
index 0000000..5d6a660
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/imsmooth.c
@@ -0,0 +1,115 @@
1/** file: imsmooth.c
2 ** author: Andrea Vedaldi
3 ** description: Smooth an image.
4 **/
5
6#include"mex.h"
7#include<stdlib.h>
8#include<string.h>
9#include<math.h>
10#include<assert.h>
11
12#define greater(a,b) ((a) > (b))
13#define min(a,b) (((a)<(b))?(a):(b))
14#define max(a,b) (((a)>(b))?(a):(b))
15
16const double win_factor = 1.5 ;
17const int nbins = 36 ;
18
19void
20mexFunction(int nout, mxArray *out[],
21 int nin, const mxArray *in[])
22{
23 int M,N ;
24 double* I_pt ;
25 double* J_pt ;
26 double s ;
27 enum {I=0,S} ;
28 enum {J=0} ;
29
30 /* ------------------------------------------------------------------
31 ** Check the arguments
32 ** --------------------------------------------------------------- */
33 if (nin != 2) {
34 mexErrMsgTxt("Exactly two input arguments required.");
35 } else if (nout > 1) {
36 mexErrMsgTxt("Too many output arguments.");
37 }
38
39 if (!mxIsDouble(in[I]) ||
40 !mxIsDouble(in[S]) ) {
41 mexErrMsgTxt("All arguments must be real.") ;
42 }
43
44 if(mxGetNumberOfDimensions(in[I]) > 2||
45 mxGetNumberOfDimensions(in[S]) > 2) {
46 mexErrMsgTxt("I must be a two dimensional array and S a scalar.") ;
47 }
48
49 if(max(mxGetM(in[S]),mxGetN(in[S])) > 1) {
50 mexErrMsgTxt("S must be a scalar.\n") ;
51 }
52
53 M = mxGetM(in[I]) ;
54 N = mxGetN(in[I]) ;
55
56 out[J] = mxCreateDoubleMatrix(M, N, mxREAL) ;
57
58 I_pt = mxGetPr(in[I]) ;
59 J_pt = mxGetPr(out[J]) ;
60 s = *mxGetPr(in[S]) ;
61
62 /* ------------------------------------------------------------------
63 ** Do the job
64 ** --------------------------------------------------------------- */
65 if(s > 0.01) {
66
67 int W = (int) ceil(4*s) ;
68 int i ;
69 int j ;
70 double* g0 = (double*) mxMalloc( (2*W+1)*sizeof(double) ) ;
71 double* buffer = (double*) mxMalloc( M*N*sizeof(double) ) ;
72 double acc=0.0 ;
73
74 for(j = 0 ; j < 2*W+1 ; ++j) {
75 g0[j] = exp(-0.5 * (j - W)*(j - W)/(s*s)) ;
76 acc += g0[j] ;
77 }
78 for(j = 0 ; j < 2*W+1 ; ++j) {
79 g0[j] /= acc ;
80 }
81
82 /*
83 ** Convolve along the columns
84 **/
85 for(j = 0 ; j < N ; ++j) {
86 for(i = 0 ; i < M ; ++i) {
87 double* start = I_pt + max(i-W,0) + j*M ;
88 double* stop = I_pt + min(i+W,M-1) + j*M + 1 ;
89 double* g = g0 + max(0, W-i) ;
90 acc = 0.0 ;
91 while(stop != start) acc += (*g++) * (*start++) ;
92 *buffer++ = acc ;
93 }
94 }
95 buffer -= M*N ;
96
97 /*
98 ** Convolve along the rows
99 **/
100 for(j = 0 ; j < N ; ++j) {
101 for(i = 0 ; i < M ; ++i) {
102 double* start = buffer + i + max(j-W,0)*M ;
103 double* stop = buffer + i + min(j+W,N-1)*M + M ;
104 double* g = g0 + max(0, W-j) ;
105 acc = 0.0 ;
106 while(stop != start) { acc += (*g++) * (*start) ; start+=M ;}
107 *J_pt++ = acc ;
108 }
109 }
110 mxFree(buffer) ;
111 mxFree(g0) ;
112 } else {
113 memcpy(J_pt, I_pt, sizeof(double)*M*N) ;
114 }
115}
diff --git a/SD-VBS/benchmarks/sift/src/matlab/imsmooth.mexa64 b/SD-VBS/benchmarks/sift/src/matlab/imsmooth.mexa64
new file mode 100755
index 0000000..0997262
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/imsmooth.mexa64
Binary files differ
diff --git a/SD-VBS/benchmarks/sift/src/matlab/imsmooth.mexglx b/SD-VBS/benchmarks/sift/src/matlab/imsmooth.mexglx
new file mode 100755
index 0000000..a4a7a20
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/imsmooth.mexglx
Binary files differ
diff --git a/SD-VBS/benchmarks/sift/src/matlab/imsmooth_.c b/SD-VBS/benchmarks/sift/src/matlab/imsmooth_.c
new file mode 100644
index 0000000..e0adeff
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/imsmooth_.c
@@ -0,0 +1,103 @@
1#include<stdlib.h>
2#include<string.h>
3#include<math.h>
4#include "imsmooth.h"
5
6#define greater(a,b) ((a) > (b))
7#define min(a,b) (((a)<(b))?(a):(b))
8#define max(a,b) (((a)>(b))?(a):(b))
9
10const double win_factor = 1.5 ;
11const int nbins = 36 ;
12
13float* imsmooth(float* I_pt_, float dsigma)
14{
15 int M,N ;
16 float *I_pt ;
17 float* J_pt_, *J_pt ;
18 float* out_, *out;
19 float s ;
20 enum {I=0,S} ;
21 enum {J=0} ;
22
23 /* ------------------------------------------------------------------
24 ** Check the arguments
25 ** --------------------------------------------------------------- */
26
27 M = (int)in_[0];
28 N = (int)in_[1];
29
30 out_ = fMallocHandle(M, N);
31 J_pt_ = &(out_[0]);
32 J_pt = &(J_pt_[4]);
33 s = dsigma;
34
35
36 /* ------------------------------------------------------------------
37 ** Do the job
38 ** --------------------------------------------------------------- */
39 if(s > 0.01)
40 {
41
42 int W = (int) ceil(4*s) ;
43 int i ;
44 int j ;
45 float* g0_, *g0, *buffer_, *buffer, acc;
46 g0_ = fMallocHandle(1, 2*W+1);
47 g0 = &(g0_[4]);
48 buffer_ = fMallocHandle(M, N);
49 acc=0.0 ;
50
51 for(j = 0 ; j < 2*W+1 ; ++j)
52 {
53 g0[j] = exp(-0.5 * (j - W)*(j - W)/(s*s)) ;
54 acc += g0[j] ;
55 }
56
57 for(j = 0 ; j < 2*W+1 ; ++j)
58 {
59 g0[j] /= acc ;
60 }
61
62 /*
63 ** Convolve along the columns
64 **/
65
66 for(j = 0 ; j < N ; ++j)
67 {
68 for(i = 0 ; i < M ; ++i)
69 {
70 float* start = I_pt + max(i-W,0) + j*M ;
71 float* stop = I_pt + min(i+W,M-1) + j*M + 1 ;
72 float* g = g0 + max(0, W-i) ;
73 acc = 0.0 ;
74 while(stop != start) acc += (*g++) * (*start++) ;
75 *buffer++ = acc ;
76 }
77 }
78 buffer -= M*N ;
79
80 /*
81 ** Convolve along the rows
82 **/
83 for(j = 0 ; j < N ; ++j)
84 {
85 for(i = 0 ; i < M ; ++i)
86 {
87 float* start = buffer + i + max(j-W,0)*M ;
88 float* stop = buffer + i + min(j+W,N-1)*M + M ;
89 float* g = g0 + max(0, W-j) ;
90 acc = 0.0 ;
91 while(stop != start) { acc += (*g++) * (*start) ; start+=M ;}
92 *J_pt++ = acc ;
93 }
94 }
95 free(buffer) ;
96 free(g0) ;
97 }
98 else
99 {
100 memcpy(J_pt, I_pt, sizeof(double)*M*N) ;
101 }
102 return J_pt_;
103}
diff --git a/SD-VBS/benchmarks/sift/src/matlab/mexutils.c b/SD-VBS/benchmarks/sift/src/matlab/mexutils.c
new file mode 100644
index 0000000..45843cf
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/mexutils.c
@@ -0,0 +1,98 @@
1/* file: mexutils.c
2** author: Andrea Vedaldi
3** description: Utility functions to write MEX files.
4**/
5
6#include"mex.h"
7#include<math.h>
8
9#undef M_PI
10#define M_PI 3.14159265358979
11
12/** @biref Is real scalar?
13 **
14 ** @return @c true if the array @a A is a real scalar.
15 **/
16int
17uIsRealScalar(const mxArray* A)
18{
19 return
20 mxIsDouble(A) &&
21 !mxIsComplex(A) &&
22 mxGetNumberOfDimensions(A) == 2 &&
23 mxGetM(A) == 1 &&
24 mxGetN(A) == 1 ;
25}
26
27/** @brief Is real matrix?
28 **
29 ** The function checks wether the argument @a A is a real matrix. In
30 ** addition, if @a M >= 0, it checks wether the number of rows is
31 ** equal to @a M and, if @a N >= 0, if the number of columns is equal
32 ** to @a N.
33 **
34 ** @param M number of rows.
35 ** @param N number of columns.
36 ** @return @c true if the array is a real matrix with the specified format.
37 **/
38int
39uIsRealMatrix(const mxArray* A, int M, int N)
40{
41 return
42 mxIsDouble(A) &&
43 !mxIsComplex(A) &&
44 mxGetNumberOfDimensions(A) == 2 &&
45 ((M>=0)?(mxGetM(A) == M):1) &&
46 ((N>=0)?(mxGetN(A) == N):1) ;
47}
48
49/** @brief Is real vector?
50 **
51 ** The function checks wether the argument @a V is a real vector. By
52 ** definiton, a matrix is a vector if one of its dimension is one.
53 ** In addition, if @a D >= 0, it checks wether the dimension of the
54 ** vecotr is equal to @a D.
55 **
56 ** @param D lenght of the vector.
57 ** @return @c true if the array is a real vector of the specified dimension.
58 **/
59int
60uIsRealVector(const mxArray* V, int D)
61{
62 int M = mxGetM(V) ;
63 int N = mxGetN(V) ;
64 int is_vector = (N == 1) || (M == 1) ;
65
66 return
67 mxIsDouble(V) &&
68 !mxIsComplex(V) &&
69 mxGetNumberOfDimensions(V) == 2 &&
70 is_vector &&
71 ( D < 0 || N == D || M == D) ;
72}
73
74
75/** @brief Is a string?
76 **
77 ** The function checks wether the array @a S is a string. If
78 ** @a L is non-negative, it also check wether the strign has
79 ** length @a L.
80 **
81 ** @return @a c true if S is a string of the specified length.
82 **/
83int
84uIsString(const mxArray* S, int L)
85{
86 int M = mxGetM(S) ;
87 int N = mxGetN(S) ;
88
89 return
90 mxIsChar(S) &&
91 M == 1 &&
92 (L < 0 || N == L) ;
93}
94
95/**
96 **
97 **/
98
diff --git a/SD-VBS/benchmarks/sift/src/matlab/plotmatches.m b/SD-VBS/benchmarks/sift/src/matlab/plotmatches.m
new file mode 100644
index 0000000..b6324e9
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/plotmatches.m
@@ -0,0 +1,124 @@
1function h=plotmatches(I1,I2,P1,P2,matches,varargin)
2% PLOTMATCHES Plot keypoint matches
3% PLOTMATCHES(I1,I2,P1,P2,MATCHES) plots the two images I1 and I2
4% and lines connecting the frames (keypoints) P1 and P2 as specified
5% by MATCHES.
6%
7% P1 and P2 specify two sets of frames, one per column. The first
8% two elements of each column specify the X,Y coordinates of the
9% corresponding frame. Any other element is ignored.
10%
11% MATCHES specifies a set of matches, one per column. The two
12% elementes of each column are two indexes in the sets P1 and P2
13% respectively.
14%
15% The images I1 and I2 might be either both grayscale or both color
16% and must have DOUBLE storage class. If they are color the range
17% must be normalized in [0,1].
18%
19% The function accepts the following option-value pairs:
20%
21% 'Stacking' ['h']
22% Stacking of images: horizontal [h], vertical [v], diagonal
23% [h], overlap ['o']
24%
25% See also PLOTSIFTDESCRIPTOR(), PLOTSIFTFRAME(), PLOTSS().
26
27% AUTORIGHTS
28% Copyright (c) 2006 The Regents of the University of California.
29% All Rights Reserved.
30%
31% Created by Andrea Vedaldi
32% UCLA Vision Lab - Department of Computer Science
33%
34% Permission to use, copy, modify, and distribute this software and its
35% documentation for educational, research and non-profit purposes,
36% without fee, and without a written agreement is hereby granted,
37% provided that the above copyright notice, this paragraph and the
38% following three paragraphs appear in all copies.
39%
40% This software program and documentation are copyrighted by The Regents
41% of the University of California. The software program and
42% documentation are supplied "as is", without any accompanying services
43% from The Regents. The Regents does not warrant that the operation of
44% the program will be uninterrupted or error-free. The end-user
45% understands that the program was developed for research purposes and
46% is advised not to rely exclusively on the program for any reason.
47%
48% This software embodies a method for which the following patent has
49% been issued: "Method and apparatus for identifying scale invariant
50% features in an image and use of same for locating an object in an
51% image," David G. Lowe, US Patent 6,711,293 (March 23,
52% 2004). Provisional application filed March 8, 1999. Asignee: The
53% University of British Columbia.
54%
55% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
56% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
57% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
58% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
59% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
60% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
61% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
62% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
63% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
64% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
65
66% --------------------------------------------------------------------
67% Check the arguments
68% --------------------------------------------------------------------
69
70stack='h' ;
71
72for k=1:2:length(varargin)
73 switch varargin{k}
74 case 'Stacking'
75 stack=varargin{k+1} ;
76 end
77end
78
79% --------------------------------------------------------------------
80% Do the job
81% --------------------------------------------------------------------
82
83[M1,N1,K1]=size(I1) ;
84[M2,N2,K2]=size(I2) ;
85
86switch stack
87 case 'h'
88 N3=N1+N2 ;
89 M3=max(M1,M2) ;
90 oj=N1 ;
91 oi=0 ;
92 case 'v'
93 M3=M1+M2 ;
94 N3=max(N1,N2) ;
95 oj=0 ;
96 oi=M1 ;
97 case 'd'
98 M3=M1+M2 ;
99 N3=N1+N2 ;
100 oj=N1 ;
101 oi=M1 ;
102 case 'o'
103 M3=max(M1,M2) ;
104 N3=max(N1,N2) ;
105 oj=0;
106 oi=0;
107end
108
109I=zeros(M3,N3,K1) ;
110I(1:M1,1:N1,:) = I1 ;
111I(oi+(1:M2),oj+(1:N2),:) = I2 ;
112
113axes('Position', [0 0 1 1]) ;
114imagesc(I) ; colormap gray ; hold on ; axis image ; axis off ;
115drawnow ;
116
117K = size(matches, 2) ;
118nans = NaN * ones(1,K) ;
119
120x = [ P1(1,matches(1,:)) ; P2(1,matches(2,:))+oj ; nans ] ;
121y = [ P1(2,matches(1,:)) ; P2(2,matches(2,:))+oi ; nans ] ;
122
123h = line(x(:)', y(:)') ;
124set(h,'Marker','.','Color','g') ;
diff --git a/SD-VBS/benchmarks/sift/src/matlab/plotsiftdescriptor.m b/SD-VBS/benchmarks/sift/src/matlab/plotsiftdescriptor.m
new file mode 100644
index 0000000..2f4af50
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/plotsiftdescriptor.m
@@ -0,0 +1,169 @@
1function h=plotsiftdescriptor(d,f)
2% PLOTSIFTDESCRIPTOR Plot SIFT descriptor
3% PLOTSIFTDESCRIPTOR(D) plots the SIFT descriptors D, stored as
4% columns of the matrix D. D has the same format used by SIFT().
5%
6% PLOTSIFTDESCRIPTOR(D,F) plots the SIFT descriptors warped to the
7% SIFT frames F, specified as columns of the matrix F. F has
8% the same format used by SIFT().
9%
10% H=PLOTSIFTDESCRIPTOR(...) returns the handle H to the line drawing
11% representing the descriptors.
12%
13% REMARK. Currently the function supports only descriptors with 4x4
14% spatial bins and 8 orientation bins (Lowe's default.)
15%
16% See also PLOTSIFTFRAME(), PLOTMATCHES(), PLOTSS().
17
18% AUTORIGHTS
19% Copyright (c) 2006 The Regents of the University of California.
20% All Rights Reserved.
21%
22% Created by Andrea Vedaldi
23% UCLA Vision Lab - Department of Computer Science
24%
25% Permission to use, copy, modify, and distribute this software and its
26% documentation for educational, research and non-profit purposes,
27% without fee, and without a written agreement is hereby granted,
28% provided that the above copyright notice, this paragraph and the
29% following three paragraphs appear in all copies.
30%
31% This software program and documentation are copyrighted by The Regents
32% of the University of California. The software program and
33% documentation are supplied "as is", without any accompanying services
34% from The Regents. The Regents does not warrant that the operation of
35% the program will be uninterrupted or error-free. The end-user
36% understands that the program was developed for research purposes and
37% is advised not to rely exclusively on the program for any reason.
38%
39% This software embodies a method for which the following patent has
40% been issued: "Method and apparatus for identifying scale invariant
41% features in an image and use of same for locating an object in an
42% image," David G. Lowe, US Patent 6,711,293 (March 23,
43% 2004). Provisional application filed March 8, 1999. Asignee: The
44% University of British Columbia.
45%
46% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
47% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
48% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
49% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
50% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
51% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
52% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
54% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
55% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
56
57lowe_compatible = 1 ;
58
59% --------------------------------------------------------------------
60% Check the arguments
61% --------------------------------------------------------------------
62
63if(size(d,1) ~= 128)
64 error('D should be a 128xK matrix (only standard descriptors accepted)') ;
65end
66
67if nargin > 1
68 if(size(f,1) ~= 4)
69 error('F should be a 4xK matrix');
70 end
71
72 if(size(f,2) ~= size(f,2))
73 error('D and F must have the same number of columns') ;
74 end
75end
76
77% Descriptors are often non-double numeric arrays
78d = double(d) ;
79K = size(d,2) ;
80if nargin < 2
81 f = repmat([0;0;1;0],1,K) ;
82end
83
84maginf = 3.0 ;
85NBP=4 ;
86NBO=8 ;
87
88% --------------------------------------------------------------------
89% Do the job
90% --------------------------------------------------------------------
91
92xall=[] ;
93yall=[] ;
94
95for k=1:K
96 SBP = maginf * f(3,k) ;
97 th=f(4,k) ;
98 c=cos(th) ;
99 s=sin(th) ;
100
101 [x,y] = render_descr(d(:,k)) ;
102 xall = [xall SBP*(c*x-s*y)+f(1,k)] ;
103 yall = [yall SBP*(s*x+c*y)+f(2,k)] ;
104end
105
106h=line(xall,yall) ;
107
108% --------------------------------------------------------------------
109% Helper functions
110% --------------------------------------------------------------------
111
112% Renders a single descriptor
113function [x,y] = render_descr( d )
114
115lowe_compatible=1;
116NBP=4 ;
117NBO=8 ;
118
119[x,y] = meshgrid(-NBP/2:NBP/2,-NBP/2:NBP/2) ;
120
121% Rescale d so that the biggest peak fits inside the bin diagram
122d = 0.4 * d / max(d(:)) ;
123
124% We have NBP*NBP bins to plot. Here are the centers:
125xc = x(1:end-1,1:end-1) + 0.5 ;
126yc = y(1:end-1,1:end-1) + 0.5 ;
127
128% We swap the order of the bin diagrams because they are stored row
129% major into the descriptor (Lowe's convention that we follow.)
130xc = xc' ;
131yc = yc' ;
132
133% Each bin contains a star with eight tips
134xc = repmat(xc(:)',NBO,1) ;
135yc = repmat(yc(:)',NBO,1) ;
136
137% Do the stars
138th=linspace(0,2*pi,NBO+1) ;
139th=th(1:end-1) ;
140if lowe_compatible
141 xd = repmat(cos(-th), 1, NBP*NBP ) ;
142 yd = repmat(sin(-th), 1, NBP*NBP ) ;
143else
144 xd = repmat(cos(th), 1, NBP*NBP ) ;
145 yd = repmat(sin(th), 1, NBP*NBP ) ;
146end
147xd = xd .* d(:)' ;
148yd = yd .* d(:)' ;
149
150% Re-arrange in sequential order the lines to draw
151nans = NaN * ones(1,NBP^2*NBO) ;
152x1 = xc(:)' ;
153y1 = yc(:)' ;
154x2 = x1 + xd ;
155y2 = y1 + yd ;
156xstars = [x1;x2;nans] ;
157ystars = [y1;y2;nans] ;
158
159% Horizontal lines of the grid
160nans = NaN * ones(1,NBP+1);
161xh = [x(:,1)' ; x(:,end)' ; nans] ;
162yh = [y(:,1)' ; y(:,end)' ; nans] ;
163
164% Verical lines of the grid
165xv = [x(1,:) ; x(end,:) ; nans] ;
166yv = [y(1,:) ; y(end,:) ; nans] ;
167
168x=[xstars(:)' xh(:)' xv(:)'] ;
169y=[ystars(:)' yh(:)' yv(:)'] ;
diff --git a/SD-VBS/benchmarks/sift/src/matlab/plotsiftframe.m b/SD-VBS/benchmarks/sift/src/matlab/plotsiftframe.m
new file mode 100644
index 0000000..984dfc9
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/plotsiftframe.m
@@ -0,0 +1,119 @@
1function h=plotsiftframe(frames,labels)
2% PLOTSIFTFRAME Plot SIFT frame
3% H=PLOTSIFTFRAME(FRAMES) plots the SIFT frames FRAMES and returns
4% and handle H to the resulting line set. FRAMES has the same format
5% used by SIFT().
6%
7% PLOTSIFTFRAME(FRAMES, LABELS) displays nearby the frame centers
8% the indexes specified by the vector LABELS. This operation is slow
9% for large sets of frames.
10%
11% A SIFT frame is denoted by a circle, representing its support, and
12% one of its radii, representing its orientation. The support is a
13% disk with radius equal to six times the scale SIGMA of the
14% frame. If the standard parameters are used for the detector, this
15% corresponds to four times the standard deviation of the Gaussian
16% window that has been uses to estimate the orientation, which is in
17% fact equal to 1.5 times the scale SIGMA.
18%
19% This function is considerably more efficient if called once on a
20% whole set of frames as opposed to multiple times, one for each
21% frame.
22%
23% See also PLOTMATCHES(), PLOTSIFTDESCRIPTOR(), PLOTSS().
24
25% AUTORIGHTS
26% Copyright (c) 2006 The Regents of the University of California.
27% All Rights Reserved.
28%
29% Created by Andrea Vedaldi
30% UCLA Vision Lab - Department of Computer Science
31%
32% Permission to use, copy, modify, and distribute this software and its
33% documentation for educational, research and non-profit purposes,
34% without fee, and without a written agreement is hereby granted,
35% provided that the above copyright notice, this paragraph and the
36% following three paragraphs appear in all copies.
37%
38% This software program and documentation are copyrighted by The Regents
39% of the University of California. The software program and
40% documentation are supplied "as is", without any accompanying services
41% from The Regents. The Regents does not warrant that the operation of
42% the program will be uninterrupted or error-free. The end-user
43% understands that the program was developed for research purposes and
44% is advised not to rely exclusively on the program for any reason.
45%
46% This software embodies a method for which the following patent has
47% been issued: "Method and apparatus for identifying scale invariant
48% features in an image and use of same for locating an object in an
49% image," David G. Lowe, US Patent 6,711,293 (March 23,
50% 2004). Provisional application filed March 8, 1999. Asignee: The
51% University of British Columbia.
52%
53% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
54% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
55% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
56% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
57% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
58% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
59% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
60% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
61% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
62% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
63
64% --------------------------------------------------------------------
65% Check the arguments
66% --------------------------------------------------------------------
67
68if size(frames,1) ~= 4
69 error('FRAMES should be a 4xK matrix') ;
70end
71
72K = size(frames,2) ;
73
74if nargin > 1
75 putlabels = 1 ;
76end
77
78% --------------------------------------------------------------------
79% Do the work
80% --------------------------------------------------------------------
81
82hold on ;
83K=size(frames,2) ;
84thr=linspace(0,2*pi,40) ;
85
86allx = nan*ones(1, 40*K+(K-1)) ;
87ally = nan*ones(1, 40*K+(K-1)) ;
88
89allxf = nan*ones(1, 3*K) ;
90allyf = nan*ones(1, 3*K) ;
91
92putlabel=0 ;
93
94for k=1:K
95 xc=frames(1,k) ;
96 yc=frames(2,k) ;
97 r=1.5*4*frames(3,k) ;
98 th=frames(4,k) ;
99
100 x = r*cos(thr) + xc ;
101 y = r*sin(thr) + yc ;
102
103 allx((k-1)*(41) + (1:40)) = x ;
104 ally((k-1)*(41) + (1:40)) = y ;
105
106 allxf((k-1)*3 + (1:2)) = [xc xc+r*cos(th)] ;
107 allyf((k-1)*3 + (1:2)) = [yc yc+r*sin(th)] ;
108
109 if putlabel
110 x=xc+r ;
111 y=yc ;
112 h=text(x+2,y,sprintf('%d',labels(k))) ;
113 set(h,'Color',[1 0 0]) ;
114 plot(x,y,'r.') ;
115 end
116
117end
118
119h=line([allx nan allxf], [ally nan allyf], 'Color','g','LineWidth',3) ;
diff --git a/SD-VBS/benchmarks/sift/src/matlab/plotss.m b/SD-VBS/benchmarks/sift/src/matlab/plotss.m
new file mode 100644
index 0000000..17868b6
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/plotss.m
@@ -0,0 +1,68 @@
1function plotss(ss,field)
2% PLOTSS Plot scale space
3% PLOTSS(SS) plots all octaves of the scale space SS.
4%
5% See also GAUSSIANSS(), DIFFSS().
6
7% AUTORIGHTS
8% Copyright (c) 2006 The Regents of the University of California.
9% All Rights Reserved.
10%
11% Created by Andrea Vedaldi
12% UCLA Vision Lab - Department of Computer Science
13%
14% Permission to use, copy, modify, and distribute this software and its
15% documentation for educational, research and non-profit purposes,
16% without fee, and without a written agreement is hereby granted,
17% provided that the above copyright notice, this paragraph and the
18% following three paragraphs appear in all copies.
19%
20% This software program and documentation are copyrighted by The Regents
21% of the University of California. The software program and
22% documentation are supplied "as is", without any accompanying services
23% from The Regents. The Regents does not warrant that the operation of
24% the program will be uninterrupted or error-free. The end-user
25% understands that the program was developed for research purposes and
26% is advised not to rely exclusively on the program for any reason.
27%
28% This software embodies a method for which the following patent has
29% been issued: "Method and apparatus for identifying scale invariant
30% features in an image and use of same for locating an object in an
31% image," David G. Lowe, US Patent 6,711,293 (March 23,
32% 2004). Provisional application filed March 8, 1999. Asignee: The
33% University of British Columbia.
34%
35% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
36% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
37% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
38% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
39% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
40% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
41% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
42% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
43% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
44% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
45
46if nargin > 2
47 error('Too many arguments.') ;
48end
49
50omin = ss.omin ;
51smin = ss.smin ;
52nlevels = ss.smax-ss.smin+1 ;
53
54for oi=1:ss.O
55 for si=1:nlevels
56 tightsubplot(nlevels, ss.O, nlevels*(oi-1)+si) ;
57 s = si-1 + smin ;
58 o = oi-1 + omin ;
59 sigma = ss.sigma0 * 2^(s/ss.S + o) ;
60 F=squeeze(ss.octave{oi}(:,:,si)) ;
61 [M,N]=size(F) ;
62 imagesc(squeeze(ss.octave{oi}(:,:,si))) ; axis image ; axis off ;
63 h=text(M/10,N/20,sprintf('(o,s)=(%d,%d), sigma=%f',o,s,sigma)) ;
64 set(h,'BackgroundColor','w','Color','k') ;
65 end
66end
67
68
diff --git a/SD-VBS/benchmarks/sift/src/matlab/script_run_profile.m b/SD-VBS/benchmarks/sift/src/matlab/script_run_profile.m
new file mode 100644
index 0000000..c157507
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/script_run_profile.m
@@ -0,0 +1,23 @@
1function script_run_profile(dataDir, resultDir, type, common, tooldir)
2
3path(path,common);
4sift_compile;
5
6I1=readImage([dataDir, '/1.bmp']) ;
7
8rows = size(I1,1);
9cols = size(I1,2);
10fprintf(1,'Input size\t\t- (%dx%d)\n', rows, cols);
11
12I1=I1-min(I1(:)) ;
13I1=I1/max(I1(:)) ;
14
15%% Timing
16start = photonStartTiming;
17frames1 = sift( I1) ;
18stop = photonEndTiming;
19elapsed = photonReportTiming(start, stop);
20photonPrintTiming(elapsed);
21
22fWriteMatrix(frames1, dataDir);
23
diff --git a/SD-VBS/benchmarks/sift/src/matlab/sift.m b/SD-VBS/benchmarks/sift/src/matlab/sift.m
new file mode 100644
index 0000000..ee79371
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/sift.m
@@ -0,0 +1,110 @@
1% Input:
2% I the input image, with pixel values normalize to lie betwen [0,1].
3%
4% Output:
5% features a structure which contains the following fields:
6% pos an n*2 matrix containing the (x,y) coordinates of the keypoints
7% stored in rows.
8% scale an n*3 matrix with rows describing the scale of each keypoint
9% (i.e., first column specifies the octave, second column specifies the interval, and
10% third column specifies sigma).
11% orient a n*1 vector containing the orientations of the keypoints [-pi,pi).
12% desc an n*128 matrix with rows containing the feature descriptors
13% corresponding to the keypoints.
14
15function [frames]=sift(I)
16
17[M,N,C] = size(I) ;
18
19% Lowe's choices
20S=3 ;
21omin=-1 ;
22O=floor(log2(min(M,N)))-omin-4 ; % Up to 16x16 images
23sigma0=1.6*2^(1/S) ;
24sigman=0.5 ;
25thresh = 0.04 / S / 2 ;
26r = 10 ;
27
28NBP = 4 ;
29NBO = 8 ;
30magnif = 3.0 ;
31
32% Parese input
33compute_descriptor = 0 ;
34discard_boundary_points = 1 ;
35verb = 0 ;
36
37smin = -1;
38smax = S+1;
39intervals = smax - smin + 1;
40
41
42% --------------------------------------------------------------------
43% Parameters
44% --------------------------------------------------------------------
45
46oframes = [] ;
47frames = [] ;
48descriptors = [] ;
49
50% --------------------------------------------------------------------
51% SIFT Detector and Descriptor
52% --------------------------------------------------------------------
53
54% Compute scale spaces
55%if verb > 0, fprintf('SIFT: computing scale space...') ; end
56
57gss = gaussianss(I,sigman,O,S,omin,-1,S+1,sigma0) ;
58dogss = diffss(gss) ;
59frames = [];
60
61%% To maintain consistency with C code. Once C code is ready, this will be uncommented.
62for o=1:O %for o=1:O
63
64 % Local maxima of the DOG octave
65 % The 80% tricks discards early very weak points before refinement.
66
67 idx = siftlocalmax( dogss.octave{o}, 0.8*thresh ) ;
68 idx = [idx , siftlocalmax( - dogss.octave{o}, 0.8*thresh)] ;
69
70 K=length(idx) ;
71 [i,j,s] = ind2sub( size( dogss.octave{o} ), idx ) ;
72
73 y=i-1 ;
74 x=j-1 ;
75 s=s-1+dogss.smin ;
76 oframes = [x(:)';y(:)';s(:)'] ;
77
78% fWriteMatrix(oframes, '../data/sim');
79
80 % Remove points too close to the boundary
81 if discard_boundary_points
82 oframes = filter_boundary_points(size(dogss.octave{o}), oframes ) ;
83 end
84
85 % Refine the location, threshold strength and remove points on edges
86 oframes = siftrefinemx(...
87 oframes, ...
88 dogss.octave{o}, ...
89 dogss.smin, ...
90 thresh, ...
91 r) ;
92
93 frames = [frames, oframes];
94
95end
96end
97
98%% --------------------------------------------------------------------
99%% Helpers
100%% --------------------------------------------------------------------
101function oframes=filter_boundary_points(sz, oframes)
102
103sel=find(...
104 oframes(1,:) > 3 & ...
105 oframes(1,:) < sz(2)-3 & ...
106 oframes(2,:) > 3 & ...
107 oframes(2,:) < sz(1)-3 ) ;
108
109oframes=oframes(:,sel) ;
110end
diff --git a/SD-VBS/benchmarks/sift/src/matlab/sift_compile.m b/SD-VBS/benchmarks/sift/src/matlab/sift_compile.m
new file mode 100644
index 0000000..78c0034
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/sift_compile.m
@@ -0,0 +1,60 @@
1function sift_compile(type)
2% SIFT_COMPILE Compile MEX files
3% Compiling under Windows requires at least Visual C 6 or LCC. You
4% might try other compilers, but most likely you will need to edit
5% this file.
6
7siftroot = fileparts(which('siftcompile')) ;
8opts = { '-O', '-I.' } ;
9%opts = { opts{:}, '-v' } ;
10
11if nargin < 1
12 type = 'visualc' ;
13end
14
15switch computer
16 case 'PCWIN'
17 warning('NOTE: compiling has been tested only with Visual C 6-7 and LCC') ;
18 switch type
19 case 'visualc'
20 lib{1}=[matlabroot '\extern\lib\win32\microsoft\libmwlapack.lib'] ;
21 lib{2}=[matlabroot '\extern\lib\win32\microsoft\msvc60\libmwlapack.lib'];
22 lib{3}=[matlabroot '\extern\lib\win32\microsoft\msvc71\libmwlapack.lib'];
23 case 'lcc'
24 lib{1}=[matlabroot '\extern\lib\win32\lcc\libmwlapack.lib'] ;
25 end
26 found=0;
27 for k=1:length(lib)
28 fprintf('Trying LAPACK lib ''%s''\n',lib{k}) ;
29 found=exist(lib{k}) ;
30 if found ~= 0
31 break ;
32 end
33 end
34 if found == 0
35 error('Could not find LAPACK library. Please edit this M-file to fix the issue.');
36 end
37 opts = {opts{:}, '-DWINDOWS'} ;
38 opts = {opts{:}, lib{k}} ;
39
40 case 'MAC'
41 opts = {opts{:}, '-DMACOSX'} ;
42 opts = {opts{:}, 'CFLAGS=\$CFLAGS -faltivec'} ;
43
44 case 'GLNX86'
45 opts = {opts{:}, '-DLINUX' } ;
46
47 otherwise
48 error(['Unsupported architecture ', computer, '. Please edit this M-mfile to fix the issue.']) ;
49end
50
51mex('imsmooth.c',opts{:}) ;
52mex('siftlocalmax.c',opts{:}) ;
53mex('siftrefinemx.c',opts{:}) ;
54mex('siftormx.c',opts{:}) ;
55mex('siftdescriptor.c',opts{:}) ;
56mex('siftmatch.c',opts{:}) ;
57
58
59
60
diff --git a/SD-VBS/benchmarks/sift/src/matlab/sift_demo2.m b/SD-VBS/benchmarks/sift/src/matlab/sift_demo2.m
new file mode 100644
index 0000000..a6f0c66
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/sift_demo2.m
@@ -0,0 +1,110 @@
1cd % SIFT_DEMO2 Demonstrate SIFT code (2)
2% This is similar to SIFT_DEMO().
3%
4% See also SIFT_DEMO().
5
6% AUTORIGHTS
7% Copyright (c) 2006 The Regents of the University of California.
8% All Rights Reserved.
9%
10% Created by Andrea Vedaldi
11% UCLA Vision Lab - Department of Computer Science
12%
13% Permission to use, copy, modify, and distribute this software and its
14% documentation for educational, research and non-profit purposes,
15% without fee, and without a written agreement is hereby granted,
16% provided that the above copyright notice, this paragraph and the
17% following three paragraphs appear in all copies.
18%
19% This software program and documentation are copyrighted by The Regents
20% of the University of California. The software program and
21% documentation are supplied "as is", without any accompanying services
22% from The Regents. The Regents does not warrant that the operation of
23% the program will be uninterrupted or error-free. The end-user
24% understands that the program was developed for research purposes and
25% is advised not to rely exclusively on the program for any reason.
26%
27% This software embodies a method for which the following patent has
28% been issued: "Method and apparatus for identifying scale invariant
29% features in an image and use of same for locating an object in an
30% image," David G. Lowe, US Patent 6,711,293 (March 23,
31% 2004). Provisional application filed March 8, 1999. Asignee: The
32% University of British Columbia.
33%
34% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
35% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
36% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
37% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
38% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
39% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
40% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
41% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
42% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
43% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
44
45I1=imreadbw('data/landscape-a.jpg') ; % I1=I1(1:2:end,:) ;
46I2=imreadbw('data/landscape-b.jpg') ; % I2=I2(1:2:end,:) ;
47I1c=double(imread('data/landscape-a.jpg'))/255.0 ;
48I2c=double(imread('data/landscape-b.jpg'))/255.0 ;
49
50I1=imsmooth(I1,.1) ;
51I2=imsmooth(I2,.1) ;
52
53I1=I1-min(I1(:)) ;
54I1=I1/max(I1(:)) ;
55I2=I2-min(I2(:)) ;
56I2=I2/max(I2(:)) ;
57
58S=3 ;
59
60fprintf('Computing frames and descriptors.\n') ;
61[frames1,descr1,gss1,dogss1] = sift( I1, 'Verbosity', 1, 'Threshold', ...
62 0.005, 'NumLevels', S ) ;
63[frames2,descr2,gss2,dogss2] = sift( I2, 'Verbosity', 1, 'Threshold', ...
64 0.005, 'NumLevels', S ) ;
65
66figure(11) ; clf ; plotss(dogss1) ; colormap gray ;
67figure(12) ; clf ; plotss(dogss2) ; colormap gray ;
68drawnow ;
69
70figure(2) ; clf ;
71tightsubplot(1,2,1) ; imagesc(I1) ; colormap gray ; axis image ;
72hold on ;
73h=plotsiftframe( frames1 ) ; set(h,'LineWidth',2,'Color','g') ;
74h=plotsiftframe( frames1 ) ; set(h,'LineWidth',1,'Color','k') ;
75
76tightsubplot(1,2,2) ; imagesc(I2) ; colormap gray ; axis image ;
77hold on ;
78h=plotsiftframe( frames2 ) ; set(h,'LineWidth',2,'Color','g') ;
79h=plotsiftframe( frames2 ) ; set(h,'LineWidth',1,'Color','k') ;
80
81fprintf('Computing matches.\n') ;
82% By passing to integers we greatly enhance the matching speed (we use
83% the scale factor 512 as Lowe's, but it could be greater without
84% overflow)
85descr1=uint8(512*descr1) ;
86descr2=uint8(512*descr2) ;
87tic ;
88matches=siftmatch( descr1, descr2, 3 ) ;
89fprintf('Matched in %.3f s\n', toc) ;
90
91figure(3) ; clf ;
92plotmatches(I1c,I2c,frames1(1:2,:),frames2(1:2,:),matches,...
93 'Stacking','v') ;
94drawnow ;
95
96% Movie
97figure(4) ; set(gcf,'Position',[10 10 1024 512]) ;
98figure(4) ; clf ;
99tightsubplot(1,1);
100imagesc(I1) ; colormap gray ; axis image ; hold on ;
101h=plotsiftframe( frames1 ) ; set(h,'LineWidth',1,'Color','g') ;
102h=plot(frames1(1,:),frames1(2,:),'r.') ;
103MOV(1)=getframe ;
104
105figure(4) ; clf ;
106tightsubplot(1,1);
107imagesc(I2) ; colormap gray ; axis image ; hold on ;
108h=plotsiftframe( frames2 ) ; set(h,'LineWidth',1,'Color','g') ;
109h=plot(frames2(1,:),frames2(2,:),'r.') ;
110MOV(2)=getframe ;
diff --git a/SD-VBS/benchmarks/sift/src/matlab/sift_gendoc.css b/SD-VBS/benchmarks/sift/src/matlab/sift_gendoc.css
new file mode 100644
index 0000000..b9bd8e3
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/sift_gendoc.css
@@ -0,0 +1,159 @@
1/** file: default.css
2 ** author: Andrea Vedaldi
3 ** description: Default CSS sylesheet for SIFT_GENDOC.PL
4 **/
5
6/* AUTORIGHTS */
7
8h1
9{
10 color: #3a3a3a ;
11}
12
13pre
14{
15 font-family: monaco, courier, monospace ;
16 font-size: 14px ;
17 color: #3a3a3a ;
18}
19
20body
21{
22 margin: 10px ;
23 padding: 1em ;
24 right: 0px ;
25 font-family: arial, sans-serif ;
26
27 color: black ;
28 background-color: #fffffa ;
29}
30
31/* ------------------------------------------------------------------
32 * Module
33 * --------------------------------------------------------------- */
34
35div.module
36{
37 margin-bottom: 1em ;
38 //background-color: #ffffff ;
39}
40
41div.module h1
42{
43 margin: 0px ;
44 margin-bottom: 0.5em ;
45 padding: 0px ;
46 font-size: 1.5em ;
47 border-bottom: 2px #3a3a3a solid ;
48}
49
50div.module pre
51{
52 padding-left: 1em ;
53}
54
55div.module div.footer
56{
57 clear: both ;
58}
59
60div.module div.footer :link
61{
62 color: white ;
63 text-decoration: none ;
64}
65
66/* ------------------------------------------------------------------
67 * Module index
68 * --------------------------------------------------------------- */
69
70div.module div.index
71{
72 font-family: sans-serif ;
73 font-size: 0.8em ;
74
75 width: 15em ;
76 float: right ;
77 border: 1px #ccc0c0 solid ;
78 background-color: #fcf0f0 ;
79}
80
81div.module div.index h1
82{
83 font-size: 1em ;
84 font-weight: bold ;
85 text-align: center ;
86 border: none ;
87 padding: 0 ;
88 margin: 0 ;
89}
90
91div.module div.index ul
92{
93 list-style-type: square ;
94 list-style-position: inside ;
95 color: #3a3a3a ;
96 padding: 0 ;
97 margin: 0 ;
98 padding: 0.3em ;
99}
100
101div.module div.index ul li
102{
103 margin-bottom: 0.1em ;
104}
105
106
107/* ------------------------------------------------------------------
108 * Mfile
109 * --------------------------------------------------------------- */
110
111div.mfile
112{
113 background-color: white ;
114 margin-bottom: 1em ;
115 border: 1px #aaaaaa solid ;
116}
117
118div.mfile h1
119{
120 margin: 0 ;
121 padding: 0 ;
122 padding-left: 10px ;
123 font-size: 1.3em ;
124 background-color: #f0f0ff ;
125}
126
127div.mfile h1 span.name
128{
129 font-family: monaco, courier, fixed ;
130}
131
132div.mfile h1 span.brief
133{
134 padding-left: 10px ;
135 font-size: 0.9em ;
136 font-weight: normal ;
137}
138
139div.mfile pre
140{
141 padding-left: 1em ;
142}
143
144div.mfile div.footer
145{
146 font-size: 0.8em ;
147 padding: 0.3em ;
148}
149
150div.mfile div.footer a
151{
152 text-decoration: none ;
153 color: #777777 ;
154}
155
156div.mfile div.footer a:hover
157{
158 text-decoration: underline ;
159}
diff --git a/SD-VBS/benchmarks/sift/src/matlab/sift_gendoc.m b/SD-VBS/benchmarks/sift/src/matlab/sift_gendoc.m
new file mode 100644
index 0000000..417f9c5
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/sift_gendoc.m
@@ -0,0 +1,50 @@
1function sift_gendoc
2% SIFT_GENDOC Generate documentation
3% This function extracts the documentation from the MEX files and
4% creates an HTML manual.
5
6% AUTORIGHTS
7% Copyright (c) 2006 The Regents of the University of California.
8% All Rights Reserved.
9%
10% Created by Andrea Vedaldi
11% UCLA Vision Lab - Department of Computer Science
12%
13% Permission to use, copy, modify, and distribute this software and its
14% documentation for educational, research and non-profit purposes,
15% without fee, and without a written agreement is hereby granted,
16% provided that the above copyright notice, this paragraph and the
17% following three paragraphs appear in all copies.
18%
19% This software program and documentation are copyrighted by The Regents
20% of the University of California. The software program and
21% documentation are supplied "as is", without any accompanying services
22% from The Regents. The Regents does not warrant that the operation of
23% the program will be uninterrupted or error-free. The end-user
24% understands that the program was developed for research purposes and
25% is advised not to rely exclusively on the program for any reason.
26%
27% This software embodies a method for which the following patent has
28% been issued: "Method and apparatus for identifying scale invariant
29% features in an image and use of same for locating an object in an
30% image," David G. Lowe, US Patent 6,711,293 (March 23,
31% 2004). Provisional application filed March 8, 1999. Asignee: The
32% University of British Columbia.
33%
34% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
35% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
36% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
37% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
38% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
39% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
40% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
41% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
42% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
43% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
44
45rootdir = fileparts(which('siftgendoc')) ;
46d=pwd;
47cd([rootdir]) ;
48res = perl([rootdir '/siftgendoc.pl'],[rootdir '/dom/index.html']) ;
49cd(d) ;
50fprintf(res) ;
diff --git a/SD-VBS/benchmarks/sift/src/matlab/sift_gendoc.pl b/SD-VBS/benchmarks/sift/src/matlab/sift_gendoc.pl
new file mode 100755
index 0000000..6bc0b5e
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/sift_gendoc.pl
@@ -0,0 +1,296 @@
1#!/usr/bin/perl -w
2## file: sift_gendoc.pl
3## author: Andrea Vedaldi
4## description: Summarize MATLAB M-Files docs
5
6# AUTORIGHTS
7# Copyright (c) 2006 The Regents of the University of California.
8# All Rights Reserved.
9#
10# Created by Andrea Vedaldi
11# UCLA Vision Lab - Department of Computer Science
12#
13# Permission to use, copy, modify, and distribute this software and its
14# documentation for educational, research and non-profit purposes,
15# without fee, and without a written agreement is hereby granted,
16# provided that the above copyright notice, this paragraph and the
17# following three paragraphs appear in all copies.
18#
19# This software program and documentation are copyrighted by The Regents
20# of the University of California. The software program and
21# documentation are supplied "as is", without any accompanying services
22# from The Regents. The Regents does not warrant that the operation of
23# the program will be uninterrupted or error-free. The end-user
24# understands that the program was developed for research purposes and
25# is advised not to rely exclusively on the program for any reason.
26#
27# This software embodies a method for which the following patent has
28# been issued: "Method and apparatus for identifying scale invariant
29# features in an image and use of same for locating an object in an
30# image," David G. Lowe, US Patent 6,711,293 (March 23,
31# 2004). Provisional application filed March 8, 1999. Asignee: The
32# University of British Columbia.
33#
34# IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
35# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
36# INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
37# ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
38# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
39# CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
40# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
41# A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
42# BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
43# MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
44
45# Debugging level
46$verb = 0 ;
47
48# PDF document location
49$pdfdoc = 'sift.pdf' ;
50
51# This is the queue of directories to process.
52# It gets filled recursively.
53@dir_fifo = ('.') ;
54
55# This will hold an entry for each m-file found
56%mfiles = () ;
57
58# This will hold an entry for each module found
59%modules = () ;
60
61# #ARGV is the index of the last element, which is 0
62if ($#ARGV == 0) {
63 open(FOUT,">$ARGV[0]") ;
64 print STDERR "Writing to file '$ARGV[0]'.\n" if $verb ;
65} else {
66 *FOUT= *STDOUT;
67 print STDERR "Using standard output.\n" if $verb ;
68}
69
70# Each module is a subdirectory. The subdirectory is used
71# as the module ID.
72
73while ($module_path = shift(@dir_fifo)) {
74 print STDERR "=> '$module_path'\n" if $verb ;
75
76 # get a first version of the module name
77 $module_path =~ m/.*\/([^\\]+)$/ ;
78 $module_name = $1 ;
79
80 # start a new module
81 $module = {
82 'id' => $module_path,
83 'path' => $module_path,
84 'name' => $module_name,
85 'mfiles' => [],
86 'description' => ""
87 } ;
88
89 # .................................................................
90 opendir(DIRHANDLE, $module->{'path'}) ;
91 FILE: foreach (sort readdir(DIRHANDLE)) {
92 $name = $_ ;
93 $path = $module->{'path'} . "/" . $_ ;
94
95 # push if a directory
96 $_ = $path ;
97 if (-d) {
98 next FILE if /(\.$|\.\.$)/ ;
99 push( @dir_fifo, "$_" ) ;
100 next FILE ;
101 }
102
103 # parse if .m and not test_
104 next FILE unless (/.+\.m$/) ;
105 next FILE if (/test_.x*/) ;
106 $name =~ m/(.*).m/ ;
107 $name = $1 ;
108 print STDERR " . m-file '$name'\n" if $verb ;
109 my ($brief,$description) = get_comment($path) ;
110
111 # topic description?
112 if (/overview/) {
113 print STDERR " * module description\n" if $verb ;
114 $module->{'id'} = $name ;
115 $module->{'name'} = $brief ;
116 $module->{'description'} = $description ;
117 next FILE ;
118 }
119
120 # use names as IDs
121 $id = $name ;
122 $id =~ tr/A-Z/a-z/ ;
123
124 # create a new mfile object
125 $mfile = {
126 'id' => $id,
127 'path' => $path,
128 'name' => $name,
129 'brief' => $brief,
130 'module' => $module,
131 'description' => $description
132 } ;
133
134 # add a reference to this mfile
135 # object to the global mfile list
136 $mfiles{$id} = $mfile ;
137
138 # add a reference to this mfile
139 # object to the current module
140 push( @{$module->{'mfiles'}}, $mfile) ;
141 }
142 closedir(DIRHANDLE) ;
143 # ................................................................
144
145 # add a reference to the current module to the global
146 # module list
147 $modules{$module->{'id'}} = $module ;
148}
149
150# ....................................................................
151# write documentation
152# ....................................................................
153
154print FOUT <<EOF;
155<html>
156 <head>
157 <link href="default.css" rel="stylesheet" type="text/css"/>
158 </head>
159 <body>
160EOF
161
162# sort modules by path
163sub criterion { $modules{$a}->{'path'} cmp $modules{$b}->{'path'} ; }
164
165MODULE:
166foreach $id ( sort criterion keys %modules ) {
167 my $module = $modules{$id} ;
168 my $rich_description = make_rich($module->{'description'}) ;
169
170 next MODULE if $#{$module->{'mfiles'}} < 0 and length($rich_description) == 0;
171
172 print FOUT <<EOF;
173 <div class='module' id='$module->{"id"}'>
174 <h1>$module->{'name'}</h1>
175 <div class='index'>
176 <h1>Module contents</h1>
177 <ul>
178EOF
179 foreach( @{$module->{'mfiles'}} ) {
180 print FOUT " <li><a href='#$_->{'id'}'>"
181 . "$_->{'name'}</a></li>\n" ;
182 }
183 print FOUT <<EOF;
184 </ul>
185 </div>
186 <pre>
187 $rich_description
188 </pre>
189 <div class="footer">
190 </div>
191 </div>
192EOF
193}
194
195foreach $id (sort keys %mfiles) {
196 my $mfile = $mfiles{$id} ;
197 my $rich_description = make_rich($mfile->{'description'}) ;
198
199 print FOUT <<EOF;
200 <div class="mfile" id='$mfile->{"id"}'>
201 <h1>
202 <span class="name">$mfile->{"name"}</span>
203 <span class="brief">$mfile->{"brief"}</span>
204 </h1>
205 <pre>
206$rich_description
207 </pre>
208 <div class="footer">
209 <a href="#$mfile->{'module'}->{'id'}">
210 $mfile->{'module'}->{'name'}
211 </a>
212 </div>
213 </div>
214EOF
215}
216
217print FOUT "</body></html>" ;
218
219# Close file
220close FOUT ;
221
222
223# -------------------------------------------------------------------------
224sub get_comment {
225# -------------------------------------------------------------------------
226 local $_ ;
227 my $full_name = $_[0] ;
228 my @comment = () ;
229
230 open IN,$full_name ;
231 SCAN:
232 while( <IN> ) {
233 next if /^function/ ;
234 last SCAN unless ( /^%/ ) ;
235 push(@comment, substr("$_",1)) ;
236 }
237 close IN ;
238
239 my $brief = "" ;
240 if( $#comment >= 0 && $comment[0] =~ m/^\s*\w+\s+(.*)$/ ) {
241 $brief = $1 ;
242 splice (@comment, 0, 1) ;
243 }
244
245 # from the first line
246 return ($brief, join("",@comment)) ;
247}
248
249# -------------------------------------------------------------------------
250sub make_rich {
251# -------------------------------------------------------------------------
252 local $_ = $_[0] ;
253 s/([A-Z]+[A-Z0-9_]*)\(([^\)]*)\)/${\make_link($1,$2)}/g ;
254 s/PDF:([A-Z0-9_\-:.]+[A-Z0-9])/${\make_pdf_link($1)}/g ;
255 return $_ ;
256}
257
258# -------------------------------------------------------------------------
259sub make_link {
260# -------------------------------------------------------------------------
261 local $_ ;
262 my $name = $_[0] ;
263 my $arg = $_[1] ;
264 my $id = $name ;
265
266 # convert name to lower case and put into $_
267 $id =~ tr/A-Z/a-z/ ;
268
269 # get mfile
270 my $mfile = $mfiles{$id} ;
271 my $module = $modules{$id} ;
272
273 # return as appropriate
274 if($mfile) {
275 return "<a href='#$id'>" . $name . "</a>" . "(" . $arg . ")" ;
276 } elsif($module) {
277 return "<a class='module' href='#$id'>" . $name .
278 "</a>" . "(" . $arg . ")" ;
279 } else {
280 return $name . "(" . $arg .")" ;
281 }
282}
283
284
285# -------------------------------------------------------------------------
286sub make_pdf_link {
287# -------------------------------------------------------------------------
288 local $_ ;
289 my $name = $_[0] ;
290 my $id = $name ;
291
292 # convert name to lower case and put into $_
293 $id =~ tr/A-Z/a-z/ ;
294
295 return "<a href='${pdfdoc}#$id'>PDF:$1</a>" ;
296}
diff --git a/SD-VBS/benchmarks/sift/src/matlab/sift_overview.m b/SD-VBS/benchmarks/sift/src/matlab/sift_overview.m
new file mode 100644
index 0000000..71557e4
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/sift_overview.m
@@ -0,0 +1,33 @@
1% SIFT_OVERVIEW Scale-Invariant Feature Transfrom
2%
3% This is a MATLAB/C implementation of SIFT detector and descriptor
4% [1]. You can:
5%
6% * Use SIFT() to detect the SIFT frames (keypoints) of a given image
7% and compute their descriptors. Then you can use SIFTMATCH() to
8% match the descriptors.
9%
10% * Use PLOTSS(), PLOTSIFTDESCRIPTOR(), PLOTSIFTFRAME(),
11% PLOTMATCHES() to visualize the results.
12%
13% As SIFT is implemented by several reusable M and MEX files, you can
14% also run portions of the algorithm, or change them. Specifically,
15% you can:
16%
17% * Use SIFTDESCRIPTOR() to compute the SIFT descriptor from a list
18% of frames and a scale space or plain image.
19%
20% * Use GAUSSIANSS() and DIFFSS() to compute the Gaussian and DOG
21% scale spaces.
22%
23% * Use SIFTLOCALMAX(), SIFTREFINEMX(), SIFTORMX() to manually
24% extract the SIFT frames from the DOG scale space. More in
25% general, you can use SIFTLOCALMAX() to find maximizers of any
26% multi-dimensional arrays.
27%
28% REFERENCES
29% [1] D. G. Lowe, "Distinctive image features from scale-invariant
30% keypoints," IJCV, vol. 2, no. 60, pp. 91 110, 2004.
31%
32% See also PDF:SIFT.INTRODUCTION.
33
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.c b/SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.c
new file mode 100644
index 0000000..63f4830
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.c
@@ -0,0 +1,524 @@
1/* file: siftdescriptor
2** author: Andrea Vedaldi
3** description: Compute SIFT descriptors
4**/
5
6/* AUTORIGHTS
7Copyright (c) 2006 The Regents of the University of California.
8All Rights Reserved.
9
10Created by Andrea Vedaldi
11UCLA Vision Lab - Department of Computer Science
12
13Permission to use, copy, modify, and distribute this software and its
14documentation for educational, research and non-profit purposes,
15without fee, and without a written agreement is hereby granted,
16provided that the above copyright notice, this paragraph and the
17following three paragraphs appear in all copies.
18
19This software program and documentation are copyrighted by The Regents
20of the University of California. The software program and
21documentation are supplied "as is", without any accompanying services
22from The Regents. The Regents does not warrant that the operation of
23the program will be uninterrupted or error-free. The end-user
24understands that the program was developed for research purposes and
25is advised not to rely exclusively on the program for any reason.
26
27This software embodies a method for which the following patent has
28been issued: "Method and apparatus for identifying scale invariant
29features in an image and use of same for locating an object in an
30image," David G. Lowe, US Patent 6,711,293 (March 23,
312004). Provisional application filed March 8, 1999. Asignee: The
32University of British Columbia.
33
34IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
35FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
36INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
37ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
38ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
39CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
40LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
41A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
42BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
43MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
44*/
45
46/*
47 REMARKS. The use of strcasecmp makes the function POSIX but not ANSI
48 compliant. When compling with Altivec, GCC Altivec extensions are
49 supported.
50*/
51
52#define LOWE_COMPATIBLE
53
54#include"mexutils.c"
55#include<stdlib.h>
56#include<math.h>
57
58#ifdef WINDOWS
59#include<string.h>
60#ifndef __cplusplus
61#define sqrtf(x) ((float)sqrt((double)(x)))
62#define powf(x,y) ((float)pow((double)(x),(double)(y)))
63#define fabsf(x) ((float)fabs((double)(x)))
64#define sinf(x) ((float)sin((double)(x)))
65#define cosf(x) ((float)cos((double)(x)))
66#define expf(x) ((float)exp((double)(x)))
67#define atan2f(x,y) ((float)atan2((double)(x),(double)(y)))
68#endif
69#else
70#include<strings.h>
71#endif
72
73/* Altivec and Accelerate support.
74 * Very crude at this time.
75 */
76#if defined( MACOSX ) && defined( __ALTIVEC__ )
77#include<Accelerate/Accelerate.h>
78typedef union
79{
80 float x[4] ;
81 vFloat vec ;
82} float4 ;
83#endif
84
85#define greater(a,b) a > b
86#define min(a,b) (((a)<(b))?(a):(b))
87#define max(a,b) (((a)>(b))?(a):(b))
88
89
90enum {SCALESPACE, NOSCALESPACE} ;
91
92enum {PROP_MAGNIF=0,
93 PROP_NBP,
94 PROP_NBO,
95 PROP_UNKNOWN} ;
96
97char const * properties [4] =
98 { "Magnif",
99 "NumSpatialBins",
100 "NumOrientBins",
101 0L
102 } ;
103
104/** Fast fmodf for 2*PI
105 **/
106/*inline*/
107float fast_mod(float th)
108{
109 while(th < 0) th += 2*M_PI ;
110 while(th > 2*M_PI) th -= 2*M_PI ;
111 return th ;
112}
113
114/** Fast floor. Equivalent to (int) floor(x)
115 **/
116/*inline*/
117int fast_floor(float x)
118{
119 return (int)( x - ((x>=0)?0:1) ) ;
120}
121
122/** Normalizes in norm L_2 a descriptor.
123 **/
124void
125normalize_histogram(float* L_begin, float* L_end)
126{
127 float* L_iter ;
128 float norm=0.0 ;
129
130 for(L_iter = L_begin; L_iter != L_end ; ++L_iter)
131 norm += (*L_iter) * (*L_iter) ;
132
133 norm = sqrtf(norm) ;
134 /* mexPrintf("%f\n",norm) ;*/
135
136 for(L_iter = L_begin; L_iter != L_end ; ++L_iter)
137 *L_iter /= norm ;
138}
139
140/** @brief MATLAB Driver.
141 **/
142void
143mexFunction(int nout, mxArray *out[],
144 int nin, const mxArray *in[])
145{
146 int M,N,S=0,smin=0,K,num_levels=0 ;
147 const int* dimensions ;
148 const double* P_pt ;
149 const double* G_pt ;
150 float* descr_pt ;
151 float* buffer_pt ;
152 float sigma0 ;
153 float magnif = 3.0f ; /* Spatial bin extension factor. */
154 int NBP = 4 ; /* Number of bins for one spatial direction (even). */
155 int NBO = 8 ; /* Number of bins for the ortientation. */
156 int mode = NOSCALESPACE ;
157 int buffer_size=0;
158
159 enum {IN_G=0,IN_P,IN_SIGMA0,IN_S,IN_SMIN} ;
160 enum {OUT_L=0} ;
161
162 /* ------------------------------------------------------------------
163 ** Check the arguments
164 ** --------------------------------------------------------------- */
165
166 if (nin < 3) {
167 mexErrMsgTxt("At least three arguments are required") ;
168 } else if (nout > 1) {
169 mexErrMsgTxt("Too many output arguments.");
170 }
171
172 if( !uIsRealScalar(in[IN_SIGMA0]) ) {
173 mexErrMsgTxt("SIGMA0 should be a real scalar") ;
174 }
175
176 if(!mxIsDouble(in[IN_G]) ||
177 mxGetNumberOfDimensions(in[IN_G]) > 3) {
178 mexErrMsgTxt("G should be a real matrix or 3-D array") ;
179 }
180
181 sigma0 = (float) *mxGetPr(in[IN_SIGMA0]) ;
182
183 dimensions = mxGetDimensions(in[IN_G]) ;
184 M = dimensions[0] ;
185 N = dimensions[1] ;
186 G_pt = mxGetPr(in[IN_G]) ;
187
188 P_pt = mxGetPr(in[IN_P]) ;
189 K = mxGetN(in[IN_P]) ;
190
191 if( !uIsRealMatrix(in[IN_P],-1,-1)) {
192 mexErrMsgTxt("P should be a real matrix") ;
193 }
194
195 if ( mxGetM(in[IN_P]) == 4) {
196 /* Standard (scale space) mode */
197 mode = SCALESPACE ;
198 num_levels = dimensions[2] ;
199
200 if(nin < 5) {
201 mexErrMsgTxt("Five arguments are required in standard mode") ;
202 }
203
204 if( !uIsRealScalar(in[IN_S]) ) {
205 mexErrMsgTxt("S should be a real scalar") ;
206 }
207
208 if( !uIsRealScalar(in[IN_SMIN]) ) {
209 mexErrMsgTxt("SMIN should be a real scalar") ;
210 }
211
212 if( !uIsRealMatrix(in[IN_P],4,-1)) {
213 mexErrMsgTxt("When the e mode P should be a 4xK matrix.") ;
214 }
215
216 S = (int)(*mxGetPr(in[IN_S])) ;
217 smin = (int)(*mxGetPr(in[IN_SMIN])) ;
218
219 } else if ( mxGetM(in[IN_P]) == 3 ) {
220 mode = NOSCALESPACE ;
221 num_levels = 1 ;
222 S = 1 ;
223 smin = 0 ;
224 } else {
225 mexErrMsgTxt("P should be either a 3xK or a 4xK matrix.") ;
226 }
227
228 /* Parse the property-value pairs */
229 {
230 char str [80] ;
231 int arg = (mode == SCALESPACE) ? IN_SMIN + 1 : IN_SIGMA0 + 1 ;
232
233 while(arg < nin) {
234 int k ;
235
236 if( !uIsString(in[arg],-1) ) {
237 mexErrMsgTxt("The first argument in a property-value pair"
238 " should be a string") ;
239 }
240 mxGetString(in[arg], str, 80) ;
241
242#ifdef WINDOWS
243 for(k = 0 ; properties[k] && strcmpi(str, properties[k]) ; ++k) ;
244#else
245 for(k = 0 ; properties[k] && strcasecmp(str, properties[k]) ; ++k) ;
246#endif
247
248 switch (k) {
249 case PROP_NBP:
250 if( !uIsRealScalar(in[arg+1]) ) {
251 mexErrMsgTxt("'NumSpatialBins' should be real scalar") ;
252 }
253 NBP = (int) *mxGetPr(in[arg+1]) ;
254 if( NBP <= 0 || (NBP & 0x1) ) {
255 mexErrMsgTxt("'NumSpatialBins' must be positive and even") ;
256 }
257 break ;
258
259 case PROP_NBO:
260 if( !uIsRealScalar(in[arg+1]) ) {
261 mexErrMsgTxt("'NumOrientBins' should be a real scalar") ;
262 }
263 NBO = (int) *mxGetPr(in[arg+1]) ;
264 if( NBO <= 0 ) {
265 mexErrMsgTxt("'NumOrientlBins' must be positive") ;
266 }
267 break ;
268
269 case PROP_MAGNIF:
270 if( !uIsRealScalar(in[arg+1]) ) {
271 mexErrMsgTxt("'Magnif' should be a real scalar") ;
272 }
273 magnif = (float) *mxGetPr(in[arg+1]) ;
274 if( magnif <= 0 ) {
275 mexErrMsgTxt("'Magnif' must be positive") ;
276 }
277 break ;
278
279 case PROP_UNKNOWN:
280 mexErrMsgTxt("Property unknown.") ;
281 break ;
282 }
283 arg += 2 ;
284 }
285 }
286
287 /* -----------------------------------------------------------------
288 * Pre-compute gradient and angles
289 * -------------------------------------------------------------- */
290 /* Alloc two buffers and make sure their size is multiple of 128 for
291 * better alignment (used also by the Altivec code below.)
292 */
293 buffer_size = (M*N*num_levels + 0x7f) & (~ 0x7f) ;
294 buffer_pt = (float*) mxMalloc( sizeof(float) * 2 * buffer_size ) ;
295 descr_pt = (float*) mxCalloc( NBP*NBP*NBO*K, sizeof(float) ) ;
296
297 {
298 /* Offsets to move in the scale space. */
299 const int yo = 1 ;
300 const int xo = M ;
301 const int so = M*N ;
302 int x,y,s ;
303
304#define at(x,y) (*(pt + (x)*xo + (y)*yo))
305
306 /* Compute the gradient */
307 for(s = 0 ; s < num_levels ; ++s) {
308 const double* pt = G_pt + s*so ;
309 for(x = 1 ; x < N-1 ; ++x) {
310 for(y = 1 ; y < M-1 ; ++y) {
311 float Dx = 0.5 * ( at(x+1,y) - at(x-1,y) ) ;
312 float Dy = 0.5 * ( at(x,y+1) - at(x,y-1) ) ;
313 buffer_pt[(x*xo+y*yo+s*so) + 0 ] = Dx ;
314 buffer_pt[(x*xo+y*yo+s*so) + buffer_size] = Dy ;
315 }
316 }
317 }
318
319 /* Compute angles and modules */
320 {
321 float* pt = buffer_pt ;
322 int j = 0 ;
323 while (j < N*M*num_levels) {
324
325#if defined( MACOSX ) && defined( __ALTIVEC__ )
326 if( ((unsigned int)pt & 0x7) == 0 && j+3 < N*M*num_levels ) {
327 /* If aligned to 128 bit and there are at least 4 pixels left */
328 float4 a, b, c, d ;
329 a.vec = vec_ld(0,(vector float*)(pt )) ;
330 b.vec = vec_ld(0,(vector float*)(pt + buffer_size)) ;
331 c.vec = vatan2f(b.vec,a.vec) ;
332 a.x[0] = a.x[0]*a.x[0]+b.x[0]*b.x[0] ;
333 a.x[1] = a.x[1]*a.x[1]+b.x[1]*b.x[1] ;
334 a.x[2] = a.x[2]*a.x[2]+b.x[2]*b.x[2] ;
335 a.x[3] = a.x[3]*a.x[3]+b.x[3]*b.x[3] ;
336 d.vec = vsqrtf(a.vec) ;
337 vec_st(c.vec,0,(vector float*)(pt + buffer_size)) ;
338 vec_st(d.vec,0,(vector float*)(pt )) ;
339 j += 4 ;
340 pt += 4 ;
341 } else {
342#endif
343 float Dx = *(pt ) ;
344 float Dy = *(pt + buffer_size) ;
345 *(pt ) = sqrtf(Dx*Dx + Dy*Dy) ;
346 *(pt + buffer_size) = atan2f(Dy, Dx) ;
347 j += 1 ;
348 pt += 1 ;
349#if defined( MACOSX ) && defined( __ALTIVEC__ )
350 }
351#endif
352
353 }
354 }
355 }
356
357 /* -----------------------------------------------------------------
358 * Do the job
359 * -------------------------------------------------------------- */
360 if(K > 0) {
361 int p ;
362
363 /* Offsets to move in the buffer */
364 const int yo = 1 ;
365 const int xo = M ;
366 const int so = M*N ;
367
368 /* Offsets to move in the descriptor. */
369 /* Use Lowe's convention. */
370 const int binto = 1 ;
371 const int binyo = NBO * NBP ;
372 const int binxo = NBO ;
373 const int bino = NBO * NBP * NBP ;
374
375 for(p = 0 ; p < K ; ++p, descr_pt += bino) {
376 /* The SIFT descriptor is a three dimensional histogram of the position
377 * and orientation of the gradient. There are NBP bins for each spatial
378 * dimesions and NBO bins for the orientation dimesion, for a total of
379 * NBP x NBP x NBO bins.
380 *
381 * The support of each spatial bin has an extension of SBP = 3sigma
382 * pixels, where sigma is the scale of the keypoint. Thus all the bins
383 * together have a support SBP x NBP pixels wide . Since weighting and
384 * interpolation of pixel is used, another half bin is needed at both
385 * ends of the extension. Therefore, we need a square window of SBP x
386 * (NBP + 1) pixels. Finally, since the patch can be arbitrarly rotated,
387 * we need to consider a window 2W += sqrt(2) x SBP x (NBP + 1) pixels
388 * wide.
389 */
390 const float x = (float) *P_pt++ ;
391 const float y = (float) *P_pt++ ;
392 const float s = (float) (mode == SCALESPACE) ? (*P_pt++) : 0.0 ;
393 const float theta0 = (float) *P_pt++ ;
394
395 const float st0 = sinf(theta0) ;
396 const float ct0 = cosf(theta0) ;
397 const int xi = (int) floor(x+0.5) ; /* Round-off */
398 const int yi = (int) floor(y+0.5) ;
399 const int si = (int) floor(s+0.5) - smin ;
400 const float sigma = sigma0 * powf(2, s / S) ;
401 const float SBP = magnif * sigma ;
402 const int W = (int) floor( sqrt(2.0) * SBP * (NBP + 1) / 2.0 + 0.5) ;
403 int bin ;
404 int dxi ;
405 int dyi ;
406 const float* pt ;
407 float* dpt ;
408
409 /* Check that keypoints are within bounds . */
410
411 if(xi < 0 ||
412 xi > N-1 ||
413 yi < 0 ||
414 yi > M-1 ||
415 ((mode==SCALESPACE) &&
416 (si < 0 ||
417 si > dimensions[2]-1) ) )
418 continue ;
419
420 /* Center the scale space and the descriptor on the current keypoint.
421 * Note that dpt is pointing to the bin of center (SBP/2,SBP/2,0).
422 */
423 pt = buffer_pt + xi*xo + yi*yo + si*so ;
424 dpt = descr_pt + (NBP/2) * binyo + (NBP/2) * binxo ;
425
426#define atd(dbinx,dbiny,dbint) (*(dpt + (dbint)*binto + (dbiny)*binyo + (dbinx)*binxo))
427
428 /*
429 * Process each pixel in the window and in the (1,1)-(M-1,N-1)
430 * rectangle.
431 */
432 for(dxi = max(-W, 1-xi) ; dxi <= min(+W, N-2-xi) ; ++dxi) {
433 for(dyi = max(-W, 1-yi) ; dyi <= min(+W, M-2-yi) ; ++dyi) {
434
435 /* Compute the gradient. */
436 float mod = *(pt + dxi*xo + dyi*yo + 0 ) ;
437 float angle = *(pt + dxi*xo + dyi*yo + buffer_size ) ;
438#ifdef LOWE_COMPATIBLE
439 float theta = fast_mod(-angle + theta0) ;
440#else
441 float theta = fast_mod(angle - theta0) ;
442#endif
443 /* Get the fractional displacement. */
444 float dx = ((float)(xi+dxi)) - x;
445 float dy = ((float)(yi+dyi)) - y;
446
447 /* Get the displacement normalized w.r.t. the keypoint orientation
448 * and extension. */
449 float nx = ( ct0 * dx + st0 * dy) / SBP ;
450 float ny = (-st0 * dx + ct0 * dy) / SBP ;
451 float nt = NBO * theta / (2*M_PI) ;
452
453 /* Get the gaussian weight of the sample. The gaussian window
454 * has a standard deviation of NBP/2. Note that dx and dy are in
455 * the normalized frame, so that -NBP/2 <= dx <= NBP/2. */
456 const float wsigma = NBP/2 ;
457 float win = expf(-(nx*nx + ny*ny)/(2.0 * wsigma * wsigma)) ;
458
459 /* The sample will be distributed in 8 adijacient bins.
460 * Now we get the ``lower-left'' bin. */
461 int binx = fast_floor( nx - 0.5 ) ;
462 int biny = fast_floor( ny - 0.5 ) ;
463 int bint = fast_floor( nt ) ;
464 float rbinx = nx - (binx+0.5) ;
465 float rbiny = ny - (biny+0.5) ;
466 float rbint = nt - bint ;
467 int dbinx ;
468 int dbiny ;
469 int dbint ;
470
471 /* Distribute the current sample into the 8 adijacient bins. */
472 for(dbinx = 0 ; dbinx < 2 ; ++dbinx) {
473 for(dbiny = 0 ; dbiny < 2 ; ++dbiny) {
474 for(dbint = 0 ; dbint < 2 ; ++dbint) {
475
476 if( binx+dbinx >= -(NBP/2) &&
477 binx+dbinx < (NBP/2) &&
478 biny+dbiny >= -(NBP/2) &&
479 biny+dbiny < (NBP/2) ) {
480 float weight = win
481 * mod
482 * fabsf(1 - dbinx - rbinx)
483 * fabsf(1 - dbiny - rbiny)
484 * fabsf(1 - dbint - rbint) ;
485
486 atd(binx+dbinx, biny+dbiny, (bint+dbint) % NBO) += weight ;
487 }
488 }
489 }
490 }
491 }
492 }
493
494 {
495 /* Normalize the histogram to L2 unit length. */
496 normalize_histogram(descr_pt, descr_pt + NBO*NBP*NBP) ;
497
498 /* Truncate at 0.2. */
499 for(bin = 0; bin < NBO*NBP*NBP ; ++bin) {
500 if (descr_pt[bin] > 0.2) descr_pt[bin] = 0.2;
501 }
502
503 /* Normalize again. */
504 normalize_histogram(descr_pt, descr_pt + NBO*NBP*NBP) ;
505 }
506 }
507 }
508
509 /* Restore pointer to the beginning of the descriptors. */
510 descr_pt -= NBO*NBP*NBP*K ;
511
512 {
513 int k ;
514 double* L_pt ;
515 out[OUT_L] = mxCreateDoubleMatrix(NBP*NBP*NBO, K, mxREAL) ;
516 L_pt = mxGetPr(out[OUT_L]) ;
517 for(k = 0 ; k < NBP*NBP*NBO*K ; ++k) {
518 L_pt[k] = descr_pt[k] ;
519 }
520 }
521
522 mxFree(descr_pt) ;
523 mxFree(buffer_pt) ;
524}
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.m b/SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.m
new file mode 100644
index 0000000..7764897
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.m
@@ -0,0 +1,79 @@
1% SIFTDESCRIPTOR Compute SIFT descriptors
2% DESCR = SIFTDESCRIPTOR(G, P, SIGMA0, S, MINS) computes the SIFT
3% descriptors DESCR of the SIFT frames P defined on the octave G of
4% a Gaussian scale space. SIGMA0, S and MINS are the the parameter
5% of the scale space as explained in PDF:SIFT.USER.SS. P has one
6% column per frame, specifiying the center X1,X2, the scal index s
7% and the orientation THETA of the frame.
8%
9% As the function operates on a single octave, in order to process
10% features spanning several octaves, one must group them and call
11% SIFTDESCRIPTOR() once per each octave.
12%
13% DESCR = SIFTDESCRIPTOR(I, P, SIGMA0) operates on a plain image
14% I. The image I is assumed to be pre-smoothed at scale SIGMA0 and P
15% is a matrix with a column per frame, specifying the center X1,X2
16% and the orientation THETA (but NOT the scale).
17%
18% REMARK. The scale parameter s in P is the scale index, NOT the
19% scale coordinate (see the PDF doc. for a discussion).
20%
21% Other parameters can be specfied as option-value paris. These
22% are
23%
24% 'Magnif' [3.0]
25% Frame magnification factor. Each spatial bin of the SIFT
26% histogram has an exentsion equal to magnif * sigma, where
27% magnif is the frame magnification factor and sigma is the scale
28% of the frame.
29%
30% 'NumSpatialBins' [4]
31% This parameter specifies the number of spatial bins in each
32% spatial direction x1 and x2. It must be a positive and even
33% number.
34%
35% 'NumOrientBins' [8]
36% This parameter specifies the number of orietnation bins. It
37% must be a positive number.
38%
39% See also SIFT(), GAUSSIANSS(), DIFFSS(), SIFTLOCALMAX(),
40% PDF:SIFT.USER.DESCRIPTOR.
41
42% AUTORIGHTS
43% Copyright (c) 2006 The Regents of the University of California.
44% All Rights Reserved.
45%
46% Created by Andrea Vedaldi
47% UCLA Vision Lab - Department of Computer Science
48%
49% Permission to use, copy, modify, and distribute this software and its
50% documentation for educational, research and non-profit purposes,
51% without fee, and without a written agreement is hereby granted,
52% provided that the above copyright notice, this paragraph and the
53% following three paragraphs appear in all copies.
54%
55% This software program and documentation are copyrighted by The Regents
56% of the University of California. The software program and
57% documentation are supplied "as is", without any accompanying services
58% from The Regents. The Regents does not warrant that the operation of
59% the program will be uninterrupted or error-free. The end-user
60% understands that the program was developed for research purposes and
61% is advised not to rely exclusively on the program for any reason.
62%
63% This software embodies a method for which the following patent has
64% been issued: "Method and apparatus for identifying scale invariant
65% features in an image and use of same for locating an object in an
66% image," David G. Lowe, US Patent 6,711,293 (March 23,
67% 2004). Provisional application filed March 8, 1999. Asignee: The
68% University of British Columbia.
69%
70% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
71% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
72% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
73% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
74% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
75% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
76% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
77% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
78% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
79% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.mexa64 b/SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.mexa64
new file mode 100755
index 0000000..f094f56
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.mexa64
Binary files differ
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.mexglx b/SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.mexglx
new file mode 100755
index 0000000..4eb94d8
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftdescriptor.mexglx
Binary files differ
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.c b/SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.c
new file mode 100644
index 0000000..3646692
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.c
@@ -0,0 +1,291 @@
1/* file: siftlocalmax.c
2** author: Andrea Vedaldi
3** description: Find local maximizer of multi-dimensional array.
4**/
5
6/* AUTORIGHTS
7Copyright (c) 2006 The Regents of the University of California.
8All Rights Reserved.
9
10Created by Andrea Vedaldi
11UCLA Vision Lab - Department of Computer Science
12
13Permission to use, copy, modify, and distribute this software and its
14documentation for educational, research and non-profit purposes,
15without fee, and without a written agreement is hereby granted,
16provided that the above copyright notice, this paragraph and the
17following three paragraphs appear in all copies.
18
19This software program and documentation are copyrighted by The Regents
20of the University of California. The software program and
21documentation are supplied "as is", without any accompanying services
22from The Regents. The Regents does not warrant that the operation of
23the program will be uninterrupted or error-free. The end-user
24understands that the program was developed for research purposes and
25is advised not to rely exclusively on the program for any reason.
26
27This software embodies a method for which the following patent has
28been issued: "Method and apparatus for identifying scale invariant
29features in an image and use of same for locating an object in an
30image," David G. Lowe, US Patent 6,711,293 (March 23,
312004). Provisional application filed March 8, 1999. Asignee: The
32University of British Columbia.
33
34IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
35FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
36INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
37ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
38ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
39CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
40LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
41A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
42BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
43MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
44*/
45
46#include"mex.h"
47#include<mexutils.c>
48#include<stdlib.h>
49
50/** Matlab driver.
51 **/
52#define greater(a,b) ((a) > (b)+threshold)
53
54void
55mexFunction(int nout, mxArray *out[],
56 int nin, const mxArray *in[])
57{
58 int M, N ;
59 const double* F_pt ;
60 int ndims ;
61 int pdims = -1 ;
62 int* offsets ;
63 int* midx ;
64 int* neighbors ;
65 int nneighbors ;
66 int* dims ;
67 enum {F=0,THRESHOLD,P} ;
68 enum {MAXIMA=0} ;
69 double threshold = - mxGetInf() ;
70
71
72 /* ------------------------------------------------------------------
73 * Check the arguments
74 * --------------------------------------------------------------- */
75 if(nin > 1) {
76 if(!uIsRealScalar(in[THRESHOLD])) {
77 mexErrMsgTxt("THRESHOLD must be a real scalar.") ;
78 }
79 threshold = *mxGetPr(in[THRESHOLD]) ;
80 }
81
82 ndims = mxGetNumberOfDimensions(in[F]) ;
83
84if(ndims !=3)
85 printf("Error Error: NDIMS not equal to 3. Not handled by C version\n");
86
87 {
88 /* We need to make a copy because in one special case (see below)
89 we need to adjust dims[].
90 */
91 int d ;
92 const int* const_dims = (int*) mxGetDimensions(in[F]) ;
93 dims = mxMalloc(sizeof(int)*ndims) ;
94 for(d=0 ; d < ndims ; ++d)
95 {
96/* printf("Const Dimensions = %d\n", const_dims[d]);
97*/
98 dims[d] = const_dims[d] ;
99 }
100 }
101 M = dims[0] ;
102 N = dims[1] ;
103 F_pt = mxGetPr(in[F]) ;
104
105 /*
106 If there are only two dimensions and if one is singleton, then
107 assume that a vector has been provided as input (and treat this
108 as a COLUMN matrix with p=1). We do this because Matlab does not
109 distinguish between vectors and 1xN or Mx1 matrices and because
110 the cases 1xN and Mx1 are trivial (the result is alway empty).
111 */
112 if((ndims == 2) && (pdims < 0) && (M == 1 || N == 1)) {
113
114 printf("ERROR ERROR: Entered a different loop here. Not handled by C version");
115
116 pdims = 1 ;
117 M = (M>N)?M:N ;
118 N = 1 ;
119 dims[0]=M ;
120 dims[1]=N ;
121 }
122
123 /* search the local maxima along the first p dimensions only */
124 if(pdims < 0)
125 {
126 pdims = ndims ;
127 }
128
129 if(pdims > ndims) {
130 mxFree(dims) ;
131 mexErrMsgTxt("P must not be greater than the number of dimensions") ;
132 }
133
134 /* ------------------------------------------------------------------
135 * Do the job
136 * --------------------------------------------------------------- */
137 {
138 int maxima_size = M*N ;
139 int* maxima_start = (int*) mxMalloc(sizeof(int) * maxima_size) ;
140 int* maxima_iterator = maxima_start ;
141 int* maxima_end = maxima_start + maxima_size ;
142 int i,j,h,o ;
143 const double* pt = F_pt ;
144
145 /* Compute the offsets between dimensions. */
146 offsets = (int*) mxMalloc(sizeof(int) * ndims) ;
147 offsets[0] = 1 ;
148
149 for(h = 1 ; h < ndims ; ++h)
150 {
151 offsets[h] = offsets[h-1]*dims[h-1] ;
152/* printf("%d:%d\t%d\n", h, offsets[h], dims[h-1]);
153*/
154 }
155
156 /* Multi-index. */
157 midx = (int*) mxMalloc(sizeof(int) * ndims) ;
158 for(h = 0 ; h < ndims ; ++h)
159 midx[h] = 1 ;
160
161 /* Neighbors. */
162 nneighbors = 1 ;
163 o=0 ;
164 for(h = 0 ; h < pdims ; ++h) {
165 nneighbors *= 3 ;
166 midx[h] = -1 ;
167 o -= offsets[h] ;
168 }
169 nneighbors -= 1 ;
170 neighbors = (int*) mxMalloc(sizeof(int) * nneighbors) ;
171
172 /* Precompute offsets from offset(-1,...,-1,0,...0) to
173 * offset(+1,...,+1,0,...,0). */
174 i = 0 ;
175
176 while(true) {
177 if(o != 0)
178 neighbors[i++] = o ;
179 h = 0 ;
180 while( o += offsets[h], (++midx[h]) > 1 ) {
181 o -= 3*offsets[h] ;
182 midx[h] = -1 ;
183 if(++h >= pdims)
184 goto stop ;
185 }
186 }
187 stop: ;
188
189 /* Starts at the corner (1,1,...,1,0,0,...0) */
190 for(h = 0 ; h < pdims ; ++h) {
191 midx[h] = 1 ;
192 pt += offsets[h] ;
193/* printf("%d:%x\t%d\n", h, pt, offsets[h]);
194*/
195 }
196
197 for(h = pdims ; h < ndims ; ++h) {
198 midx[h] = 0 ;
199 }
200
201 /* ---------------------------------------------------------------
202 * Loop
203 * ------------------------------------------------------------ */
204
205 /*
206 If any dimension in the first P is less than 3 elements wide
207 then just return the empty matrix (if we proceed without doing
208 anything we break the carry reporting algorithm below).
209 */
210 for(h=0 ; h < pdims ; ++h)
211 if(dims[h] < 3) goto end ;
212
213 while(true) {
214
215 /* Propagate carry along multi index midx */
216 h = 0 ;
217 while((midx[h]) >= dims[h] - 1) {
218/* pt += 2*offsets[h] ; skip first and last el. */
219 midx[h] = 1 ;
220 if(++h >= pdims)
221 goto next_layer ;
222 ++midx[h] ;
223 }
224
225 /* Scan neighbors */
226 {
227 double v = *pt ;
228 bool is_greater = (v >= threshold) ;
229 /* printf("%f\n", v);
230 */
231 i = 0 ;
232 while(is_greater && i < nneighbors)
233 {
234 is_greater &= v > *(pt + neighbors[i++]) ;
235 }
236
237 /* Add the local maximum */
238 if(is_greater) {
239 /* Need more space? */
240 if(maxima_iterator == maxima_end) {
241 maxima_size += M*N ;
242 maxima_start = (int*) mxRealloc(maxima_start,
243 maxima_size*sizeof(int)) ;
244 maxima_end = maxima_start + maxima_size ;
245 maxima_iterator = maxima_end - M*N ;
246 }
247
248 *maxima_iterator++ = pt - F_pt + 1 ;
249 }
250
251 /* Go to next element */
252 pt += 1 ;
253 ++midx[0] ;
254 continue ;
255
256 next_layer: ;
257 if( h >= ndims )
258 goto end ;
259
260 while((++midx[h]) >= dims[h]) {
261 midx[h] = 0 ;
262 if(++h >= ndims)
263 goto end ;
264 }
265 }
266 }
267 end:;
268 /* Return. */
269 {
270 double* M_pt ;
271/* printf("%x\t%x\t%d\n", maxima_iterator, maxima_start, maxima_iterator-maxima_start);
272*/
273 out[MAXIMA] = mxCreateDoubleMatrix
274 (1, maxima_iterator-maxima_start, mxREAL) ;
275 maxima_end = maxima_iterator ;
276 maxima_iterator = maxima_start ;
277 M_pt = mxGetPr(out[MAXIMA]) ;
278 while(maxima_iterator != maxima_end)
279 {
280 *M_pt++ = *maxima_iterator++ ;
281 }
282 }
283
284 /* Release space. */
285 mxFree(offsets) ;
286 mxFree(neighbors) ;
287 mxFree(midx) ;
288 mxFree(maxima_start) ;
289 }
290 mxFree(dims) ;
291}
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.m b/SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.m
new file mode 100644
index 0000000..cee30ce
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.m
@@ -0,0 +1,33 @@
1% SIFTLOCALMAX Find local maximizers
2% SEL=SIFTLOCALMAX(F) returns the indexes of the local maximizers of
3% the Q-dimensional array F.
4%
5% A local maximizer is an element whose value is greater than the
6% value of all its neighbors. The neighbors of an element i1...iQ
7% are the subscripts j1...jQ such that iq-1 <= jq <= iq (excluding
8% i1...iQ itself). For example, if Q=1 the neighbors of an element
9% are its predecessor and successor in the linear order; if Q=2, its
10% neighbors are the elements immediately to its north, south, west,
11% est, north-west, north-est, south-west and south-est
12% (8-neighborhood).
13%
14% Points on the boundary of F are ignored (and never selected as
15% local maximizers).
16%
17% SEL=SIFTLOCALMAX(F,THRESH) accepts an element as a mazimizer only
18% if it is at least THRES greater than all its neighbors.
19%
20% SEL=SIFTLOCALMAX(F,THRESH,P) look for neighbors only in the first
21% P dimensions of the Q-dimensional array F. This is useful to
22% process F in ``slices''.
23%
24% REMARK. Matrices (2-array) with a singleton dimension are
25% interpreted as vectors (1-array). So for example SIFTLOCALMAX([0 1
26% 0]) and SIFTLOCALMAX([0 1 0]') both return 2 as an aswer. However,
27% if [0 1 0] is to be interpreted as a 1x2 matrix, then the correct
28% answer is the empty set, as all elements are on the boundary.
29% Unfortunately MATLAB does not distinguish between vectors and
30% 2-matrices with a singleton dimension. To forece the
31% interpretation of all matrices as 2-arrays, use
32% SIFTLOCALMAX(F,TRESH,2) (but note that in this case the result is
33% always empty!).
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.mexa64 b/SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.mexa64
new file mode 100755
index 0000000..2b8e264
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.mexa64
Binary files differ
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.mexglx b/SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.mexglx
new file mode 100755
index 0000000..613a74e
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftlocalmax.mexglx
Binary files differ
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftmatch.c b/SD-VBS/benchmarks/sift/src/matlab/siftmatch.c
new file mode 100644
index 0000000..1150176
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftmatch.c
@@ -0,0 +1,250 @@
1/* file: siftmatch.c
2** author: Andrea Vedaldi
3** description: SIFT descriptor matching.
4**/
5
6/* AUTORIGHTS
7Copyright (c) 2006 The Regents of the University of California.
8All Rights Reserved.
9
10Created by Andrea Vedaldi
11UCLA Vision Lab - Department of Computer Science
12
13Permission to use, copy, modify, and distribute this software and its
14documentation for educational, research and non-profit purposes,
15without fee, and without a written agreement is hereby granted,
16provided that the above copyright notice, this paragraph and the
17following three paragraphs appear in all copies.
18
19This software program and documentation are copyrighted by The Regents
20of the University of California. The software program and
21documentation are supplied "as is", without any accompanying services
22from The Regents. The Regents does not warrant that the operation of
23the program will be uninterrupted or error-free. The end-user
24understands that the program was developed for research purposes and
25is advised not to rely exclusively on the program for any reason.
26
27This software embodies a method for which the following patent has
28been issued: "Method and apparatus for identifying scale invariant
29features in an image and use of same for locating an object in an
30image," David G. Lowe, US Patent 6,711,293 (March 23,
312004). Provisional application filed March 8, 1999. Asignee: The
32University of British Columbia.
33
34IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
35FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
36INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
37ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
38ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
39CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
40LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
41A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
42BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
43MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
44*/
45
46#include"mexutils.c"
47
48#include<stdlib.h>
49#include<string.h>
50#include<math.h>
51
52#define greater(a,b) ((a) > (b))
53#define min(a,b) (((a)<(b))?(a):(b))
54#define max(a,b) (((a)>(b))?(a):(b))
55
56#define TYPEOF_mxDOUBLE_CLASS double
57#define TYPEOF_mxSINGLE_CLASS float
58#define TYPEOF_mxINT8_CLASS char
59#define TYPEOF_mxUINT8_CLASS unsigned char
60
61#define PROMOTE_mxDOUBLE_CLASS double
62#define PROMOTE_mxSINGLE_CLASS float
63#define PROMOTE_mxINT8_CLASS int
64#define PROMOTE_mxUINT8_CLASS int
65
66#define MAXVAL_mxDOUBLE_CLASS mxGetInf()
67#define MAXVAL_mxSINGLE_CLASS ((float)mxGetInf())
68#define MAXVAL_mxINT8_CLASS 0x7fffffff
69#define MAXVAL_mxUINT8_CLASS 0x7fffffff
70
71typedef struct
72{
73 int k1 ;
74 int k2 ;
75 double score ;
76} Pair ;
77
78/*
79 * This macro defines the matching function for abstract type; that
80 * is, it is a sort of C++ template. This is also a good illustration
81 * of why C++ is preferable for templates :-)
82 */
83#define _COMPARE_TEMPLATE(MXC) \
84 Pair* compare_##MXC (Pair* pairs_iterator, \
85 const TYPEOF_##MXC * L1_pt, \
86 const TYPEOF_##MXC * L2_pt, \
87 int K1, int K2, int ND, float thresh) \
88 { \
89 int k1, k2 ; \
90 const PROMOTE_##MXC maxval = MAXVAL_##MXC ; \
91 for(k1 = 0 ; k1 < K1 ; ++k1, L1_pt += ND ) { \
92 \
93 PROMOTE_##MXC best = maxval ; \
94 PROMOTE_##MXC second_best = maxval ; \
95 int bestk = -1 ; \
96 \
97 /* For each point P2[k2] in the second image... */ \
98 for(k2 = 0 ; k2 < K2 ; ++k2, L2_pt += ND) { \
99 \
100 int bin ; \
101 PROMOTE_##MXC acc = 0 ; \
102 for(bin = 0 ; bin < ND ; ++bin) { \
103 PROMOTE_##MXC delta = \
104 ((PROMOTE_##MXC) L1_pt[bin]) - \
105 ((PROMOTE_##MXC) L2_pt[bin]) ; \
106 acc += delta*delta ; \
107 } \
108 \
109 /* Filter the best and second best matching point. */ \
110 if(acc < best) { \
111 second_best = best ; \
112 best = acc ; \
113 bestk = k2 ; \
114 } else if(acc < second_best) { \
115 second_best = acc ; \
116 } \
117 } \
118 \
119 L2_pt -= ND*K2 ; \
120 \
121 /* Lowe's method: accept the match only if unique. */ \
122 if(thresh * (float) best <= (float) second_best && \
123 bestk != -1) { \
124 pairs_iterator->k1 = k1 ; \
125 pairs_iterator->k2 = bestk ; \
126 pairs_iterator->score = best ; \
127 pairs_iterator++ ; \
128 } \
129 } \
130 \
131 return pairs_iterator ; \
132 } \
133
134_COMPARE_TEMPLATE( mxDOUBLE_CLASS )
135_COMPARE_TEMPLATE( mxSINGLE_CLASS )
136_COMPARE_TEMPLATE( mxINT8_CLASS )
137_COMPARE_TEMPLATE( mxUINT8_CLASS )
138
139void
140mexFunction(int nout, mxArray *out[],
141 int nin, const mxArray *in[])
142{
143 int K1, K2, ND ;
144 void* L1_pt ;
145 void* L2_pt ;
146 double thresh = 1.5 ;
147 mxClassID data_class ;
148 enum {L1=0,L2,THRESH} ;
149 enum {MATCHES=0,D} ;
150
151 /* ------------------------------------------------------------------
152 ** Check the arguments
153 ** --------------------------------------------------------------- */
154 if (nin < 2) {
155 mexErrMsgTxt("At least two input arguments required");
156 } else if (nout > 2) {
157 mexErrMsgTxt("Too many output arguments");
158 }
159
160 if(!mxIsNumeric(in[L1]) ||
161 !mxIsNumeric(in[L2]) ||
162 mxGetNumberOfDimensions(in[L1]) > 2 ||
163 mxGetNumberOfDimensions(in[L2]) > 2) {
164 mexErrMsgTxt("L1 and L2 must be two dimensional numeric arrays") ;
165 }
166
167 K1 = mxGetN(in[L1]) ;
168 K2 = mxGetN(in[L2]) ;
169 ND = mxGetM(in[L1]) ;
170
171 if(mxGetM(in[L2]) != ND) {
172 mexErrMsgTxt("L1 and L2 must have the same number of rows") ;
173 }
174
175 data_class = mxGetClassID(in[L1]) ;
176 if(mxGetClassID(in[L2]) != data_class) {
177 mexErrMsgTxt("L1 and L2 must be of the same class") ;
178 }
179
180 L1_pt = mxGetData(in[L1]) ;
181 L2_pt = mxGetData(in[L2]) ;
182
183 if(nin == 3) {
184 if(!uIsRealScalar(in[THRESH])) {
185 mexErrMsgTxt("THRESH should be a real scalar") ;
186 }
187 thresh = *mxGetPr(in[THRESH]) ;
188 } else if(nin > 3) {
189 mexErrMsgTxt("At most three arguments are allowed") ;
190 }
191
192 /* ------------------------------------------------------------------
193 ** Do the job
194 ** --------------------------------------------------------------- */
195 {
196 Pair* pairs_begin = (Pair*) mxMalloc(sizeof(Pair) * (K1+K2)) ;
197 Pair* pairs_iterator = pairs_begin ;
198
199
200#define _DISPATCH_COMPARE( MXC ) \
201 case MXC : \
202 pairs_iterator = compare_##MXC(pairs_iterator, \
203 (const TYPEOF_##MXC*) L1_pt, \
204 (const TYPEOF_##MXC*) L2_pt, \
205 K1,K2,ND,thresh) ; \
206 break ; \
207
208 switch (data_class) {
209 _DISPATCH_COMPARE( mxDOUBLE_CLASS ) ;
210 _DISPATCH_COMPARE( mxSINGLE_CLASS ) ;
211 _DISPATCH_COMPARE( mxINT8_CLASS ) ;
212 _DISPATCH_COMPARE( mxUINT8_CLASS ) ;
213 default :
214 mexErrMsgTxt("Unsupported numeric class") ;
215 break ;
216 }
217
218 /* ---------------------------------------------------------------
219 * Finalize
220 * ------------------------------------------------------------ */
221 {
222 Pair* pairs_end = pairs_iterator ;
223 double* M_pt ;
224 double* D_pt = NULL ;
225
226 out[MATCHES] = mxCreateDoubleMatrix
227 (2, pairs_end-pairs_begin, mxREAL) ;
228
229 M_pt = mxGetPr(out[MATCHES]) ;
230
231 if(nout > 1) {
232 out[D] = mxCreateDoubleMatrix(1,
233 pairs_end-pairs_begin,
234 mxREAL) ;
235 D_pt = mxGetPr(out[D]) ;
236 }
237
238 for(pairs_iterator = pairs_begin ;
239 pairs_iterator < pairs_end ;
240 ++pairs_iterator) {
241 *M_pt++ = pairs_iterator->k1 + 1 ;
242 *M_pt++ = pairs_iterator->k2 + 1 ;
243 if(nout > 1) {
244 *D_pt++ = pairs_iterator->score ;
245 }
246 }
247 }
248 mxFree(pairs_begin) ;
249 }
250}
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftmatch.m b/SD-VBS/benchmarks/sift/src/matlab/siftmatch.m
new file mode 100644
index 0000000..d4398c1
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftmatch.m
@@ -0,0 +1,60 @@
1% SIFTMATCH Match SIFT features
2% MATCHES=SIFTMATCH(DESCR1, DESCR2) matches the two sets of SIFT
3% descriptors DESCR1 and DESCR2.
4%
5% The function uses the same algorithm suggested by D. Lowe [1] to
6% reject matches that are too ambiguous.
7%
8% SIFTMATCH(DESCR1, DESCR2, THRESH) uses [1] with the specified
9% threshold THRESH. A descriptor D1 is matched to a descriptor D2
10% only if the distance d(D1,D2) multiplied by THRESH is not greather
11% than the distance of D1 to all other descriptors. The default
12% value of THRESH is 1.5.
13%
14% The storage class of the descriptors can be either DOUBLE, FLOAT,
15% INT8 or UINT8. Usually interger classes are faster.
16%
17% [1] D. G. Lowe,
18% `Distinctive image features from scale-invariant keypoints,'
19% IJCV, vol. 2, no. 60, pp. 91–110, 2004.
20%
21% See also SIFT(), SIFTDESCRIPTOR().
22
23% AUTORIGHTS
24% Copyright (c) 2006 The Regents of the University of California.
25% All Rights Reserved.
26%
27% Created by Andrea Vedaldi
28% UCLA Vision Lab - Department of Computer Science
29%
30% Permission to use, copy, modify, and distribute this software and its
31% documentation for educational, research and non-profit purposes,
32% without fee, and without a written agreement is hereby granted,
33% provided that the above copyright notice, this paragraph and the
34% following three paragraphs appear in all copies.
35%
36% This software program and documentation are copyrighted by The Regents
37% of the University of California. The software program and
38% documentation are supplied "as is", without any accompanying services
39% from The Regents. The Regents does not warrant that the operation of
40% the program will be uninterrupted or error-free. The end-user
41% understands that the program was developed for research purposes and
42% is advised not to rely exclusively on the program for any reason.
43%
44% This software embodies a method for which the following patent has
45% been issued: "Method and apparatus for identifying scale invariant
46% features in an image and use of same for locating an object in an
47% image," David G. Lowe, US Patent 6,711,293 (March 23,
48% 2004). Provisional application filed March 8, 1999. Asignee: The
49% University of British Columbia.
50%
51% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
52% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
53% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
54% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
55% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
56% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
57% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
58% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
59% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
60% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftmatch.mexa64 b/SD-VBS/benchmarks/sift/src/matlab/siftmatch.mexa64
new file mode 100755
index 0000000..e58eaf5
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftmatch.mexa64
Binary files differ
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftmatch.mexglx b/SD-VBS/benchmarks/sift/src/matlab/siftmatch.mexglx
new file mode 100755
index 0000000..d5e32f7
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftmatch.mexglx
Binary files differ
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftormx.c b/SD-VBS/benchmarks/sift/src/matlab/siftormx.c
new file mode 100644
index 0000000..40380a2
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftormx.c
@@ -0,0 +1,251 @@
1/* file: siftormx.c
2** author: Andrea Vedaldi
3** description: Computes peaks of orientation histogram.
4**/
5
6/* AUTORIGHTS
7Copyright (c) 2006 The Regents of the University of California.
8All Rights Reserved.
9
10Created by Andrea Vedaldi
11UCLA Vision Lab - Department of Computer Science
12
13Permission to use, copy, modify, and distribute this software and its
14documentation for educational, research and non-profit purposes,
15without fee, and without a written agreement is hereby granted,
16provided that the above copyright notice, this paragraph and the
17following three paragraphs appear in all copies.
18
19This software program and documentation are copyrighted by The Regents
20of the University of California. The software program and
21documentation are supplied "as is", without any accompanying services
22from The Regents. The Regents does not warrant that the operation of
23the program will be uninterrupted or error-free. The end-user
24understands that the program was developed for research purposes and
25is advised not to rely exclusively on the program for any reason.
26
27This software embodies a method for which the following patent has
28been issued: "Method and apparatus for identifying scale invariant
29features in an image and use of same for locating an object in an
30image," David G. Lowe, US Patent 6,711,293 (March 23,
312004). Provisional application filed March 8, 1999. Asignee: The
32University of British Columbia.
33
34IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
35FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
36INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
37ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
38ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
39CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
40LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
41A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
42BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
43MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
44*/
45
46#include"mex.h"
47#include<stdlib.h>
48#include<string.h>
49#include<math.h>
50
51#include<mexutils.c>
52
53#define greater(a,b) a > b
54#define min(a,b) (((a)<(b))?(a):(b))
55#define max(a,b) (((a)>(b))?(a):(b))
56
57const double win_factor = 1.5 ;
58#define NBINS 36
59
60void
61mexFunction(int nout, mxArray *out[],
62 int nin, const mxArray *in[])
63{
64 int M,N,S,smin,K ;
65 const int* dimensions ;
66 const double* P_pt ;
67 const double* G_pt ;
68 double* TH_pt ;
69 double sigma0 ;
70 double H_pt [ NBINS ] ;
71
72 enum {IN_P=0,IN_G,IN_S,IN_SMIN,IN_SIGMA0} ;
73 enum {OUT_Q=0} ;
74
75 /* -----------------------------------------------------------------
76 ** Check the arguments
77 ** -------------------------------------------------------------- */
78 if (nin != 5) {
79 mexErrMsgTxt("Exactly five input arguments required.");
80 } else if (nout > 1) {
81 mexErrMsgTxt("Too many output arguments.");
82 }
83
84 if( !uIsRealScalar(in[IN_S]) ) {
85 mexErrMsgTxt("S should be a real scalar") ;
86 }
87
88 if( !uIsRealScalar(in[IN_SMIN]) ) {
89 mexErrMsgTxt("SMIN should be a real scalar") ;
90 }
91
92 if( !uIsRealScalar(in[IN_SIGMA0]) ) {
93 mexErrMsgTxt("SIGMA0 should be a real scalar") ;
94 }
95
96 if( !uIsRealMatrix(in[IN_P],3,-1)) {
97 mexErrMsgTxt("P should be a 3xK real matrix") ;
98 }
99
100 if(mxGetNumberOfDimensions(in[IN_G]) != 3) {
101 mexErrMsgTxt("SSO must be a three dimensional array") ;
102 }
103
104 dimensions = mxGetDimensions(in[IN_G]) ;
105 M = dimensions[0] ;
106 N = dimensions[1] ;
107 S = (int)(*mxGetPr(in[IN_S])) ;
108 smin = (int)(*mxGetPr(in[IN_SMIN])) ;
109 sigma0 = *mxGetPr(in[IN_SIGMA0]) ;
110
111 K = mxGetN(in[IN_P]) ;
112 P_pt = mxGetPr(in[IN_P]) ;
113 G_pt = mxGetPr(in[IN_G]) ;
114
115
116 /* If the input array is empty, then output an empty array as well. */
117 if(K == 0) {
118 out[OUT_Q] = mxCreateDoubleMatrix(4,0,mxREAL) ;
119 return ;
120 }
121
122 /* ------------------------------------------------------------------
123 * Do the job
124 * --------------------------------------------------------------- */
125 {
126 int p ;
127 const int yo = 1 ;
128 const int xo = M ;
129 const int so = M*N ;
130
131 int buffer_size = K*4 ;
132 double* buffer_start = (double*) mxMalloc( buffer_size *sizeof(double)) ;
133 double* buffer_iterator = buffer_start ;
134 double* buffer_end = buffer_start + buffer_size ;
135
136 for(p = 0 ; p < K ; ++p, TH_pt += 2) {
137 const double x = *P_pt++ ;
138 const double y = *P_pt++ ;
139 const double s = *P_pt++ ;
140 int xi = ((int) (x+0.5)) ; /* Round them off. */
141 int yi = ((int) (y+0.5)) ;
142 int si = ((int) (s+0.5)) - smin ;
143 int xs ;
144 int ys ;
145 double sigmaw = win_factor * sigma0 * pow(2, ((double)s) / S) ;
146 int W = (int) ceil(3.0 * sigmaw) ;
147 int bin ;
148 const double* pt ;
149
150 /* Make sure that the rounded off keypoint index is within bound.
151 */
152 if(xi < 0 ||
153 xi > N-1 ||
154 yi < 0 ||
155 yi > M-1 ||
156 si < 0 ||
157 si > dimensions[2]-1 ) {
158 mexPrintf("Dropping %d: W %d x %d y %d si [%d,%d,%d,%d]\n",p,W,xi,yi,si,M,N,dimensions[2]) ;
159 continue ;
160 }
161
162 /* Clear histogram buffer. */
163 {
164 int i ;
165 for(i = 0 ; i < NBINS ; ++i)
166 H_pt[i] = 0 ;
167 }
168
169 pt = G_pt + xi*xo + yi*yo + si*so ;
170
171#define at(dx,dy) (*(pt + (dx)*xo + (dy)*yo))
172
173 for(xs = max(-W, 1-xi) ; xs <= min(+W, N -2 -xi) ; ++xs) {
174 for(ys = max(-W, 1-yi) ; ys <= min(+W, M -2 -yi) ; ++ys) {
175 double Dx = 0.5 * ( at(xs+1,ys) - at(xs-1,ys) ) ;
176 double Dy = 0.5 * ( at(xs,ys+1) - at(xs,ys-1) ) ;
177 double dx = ((double)(xi+xs)) - x;
178 double dy = ((double)(yi+ys)) - y;
179
180 if(dx*dx + dy*dy > W*W+0.5) continue ;
181
182 {
183 double win = exp( - (dx*dx + dy*dy)/(2*sigmaw*sigmaw) ) ;
184 double mod = sqrt(Dx*Dx + Dy*Dy) ;
185 double theta = fmod(atan2(Dy, Dx) + 2*M_PI, 2*M_PI) ;
186 bin = (int) floor( NBINS * theta / (2*M_PI) ) ;
187 H_pt[bin] += mod*win ;
188 }
189 }
190 }
191
192 /* Smooth histogram */
193 {
194 int iter, i ;
195 for (iter = 0; iter < 6; iter++) {
196 double prev;
197 prev = H_pt[NBINS-1];
198 for (i = 0; i < NBINS; i++) {
199 float newh = (prev + H_pt[i] + H_pt[(i+1) % NBINS]) / 3.0;
200 prev = H_pt[i] ;
201 H_pt[i] = newh ;
202 }
203 }
204 }
205
206 /* Find most strong peaks. */
207 {
208 int i ;
209 double maxh = H_pt[0] ;
210 for(i = 1 ; i < NBINS ; ++i)
211 maxh = max(maxh, H_pt[i]) ;
212
213 for(i = 0 ; i < NBINS ; ++i) {
214 double h0 = H_pt[i] ;
215 double hm = H_pt[(i-1+NBINS) % NBINS] ;
216 double hp = H_pt[(i+1+NBINS) % NBINS] ;
217
218 if( h0 > 0.8*maxh && h0 > hm && h0 > hp ) {
219
220 double di = -0.5 * (hp-hm) / (hp+hm-2*h0) ; /*di=0;*/
221 double th = 2*M_PI*(i+di+0.5)/NBINS ;
222
223 if( buffer_iterator == buffer_end ) {
224 int offset = buffer_iterator - buffer_start ;
225 buffer_size += 4*max(1, K/16) ;
226 buffer_start = (double*) mxRealloc(buffer_start,
227 buffer_size*sizeof(double)) ;
228 buffer_end = buffer_start + buffer_size ;
229 buffer_iterator = buffer_start + offset ;
230 }
231
232 *buffer_iterator++ = x ;
233 *buffer_iterator++ = y ;
234 *buffer_iterator++ = s ;
235 *buffer_iterator++ = th ;
236 }
237 } /* Scan histogram */
238 } /* Find peaks */
239 }
240
241 /* Save back the result. */
242 {
243 double* result ;
244 int NL = (buffer_iterator - buffer_start)/4 ;
245 out[OUT_Q] = mxCreateDoubleMatrix(4, NL, mxREAL) ;
246 result = mxGetPr(out[OUT_Q]);
247 memcpy(result, buffer_start, sizeof(double) * 4 * NL) ;
248 }
249 mxFree(buffer_start) ;
250 }
251}
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftormx.mexa64 b/SD-VBS/benchmarks/sift/src/matlab/siftormx.mexa64
new file mode 100755
index 0000000..ae1f787
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftormx.mexa64
Binary files differ
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftormx.mexglx b/SD-VBS/benchmarks/sift/src/matlab/siftormx.mexglx
new file mode 100755
index 0000000..de90e4b
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftormx.mexglx
Binary files differ
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftread.m b/SD-VBS/benchmarks/sift/src/matlab/siftread.m
new file mode 100644
index 0000000..76945c8
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftread.m
@@ -0,0 +1,101 @@
1function [frames,descriptors] = siftread(file)
2% SIFTREAD Read Lowe's SIFT implementation data files
3% [FRAMES, DESCRIPTORS] = READSIFT(FILE) reads the frames and the
4% descriptors from the specified file. The function reads files
5% produced by Lowe's SIFT implementation.
6%
7% FRAMES and DESCRIPTORS have the same format used by SIFT().
8%
9% REMARK. Lowe's and our implementations use a silightly different
10% convention to store the orientation of the frame. When the file
11% is read, the orientation is changed to match our convention.
12%
13% See also SIFT().
14
15% AUTORIGHTS
16% Copyright (c) 2006 The Regents of the University of California.
17% All Rights Reserved.
18%
19% Created by Andrea Vedaldi
20% UCLA Vision Lab - Department of Computer Science
21%
22% Permission to use, copy, modify, and distribute this software and its
23% documentation for educational, research and non-profit purposes,
24% without fee, and without a written agreement is hereby granted,
25% provided that the above copyright notice, this paragraph and the
26% following three paragraphs appear in all copies.
27%
28% This software program and documentation are copyrighted by The Regents
29% of the University of California. The software program and
30% documentation are supplied "as is", without any accompanying services
31% from The Regents. The Regents does not warrant that the operation of
32% the program will be uninterrupted or error-free. The end-user
33% understands that the program was developed for research purposes and
34% is advised not to rely exclusively on the program for any reason.
35%
36% This software embodies a method for which the following patent has
37% been issued: "Method and apparatus for identifying scale invariant
38% features in an image and use of same for locating an object in an
39% image," David G. Lowe, US Patent 6,711,293 (March 23,
40% 2004). Provisional application filed March 8, 1999. Asignee: The
41% University of British Columbia.
42%
43% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
44% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
45% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
46% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
47% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
48% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
49% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
50% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
51% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
52% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
53
54verbosity=0 ;
55
56g = fopen(file, 'r');
57if g == -1
58 error(['Could not open file ''', file, '''.']) ;
59end
60[header, count] = fscanf(g, '%d', [1 2]) ;
61if count ~= 2
62 error('Invalid keypoint file header.');
63end
64K = header(1) ;
65DL = header(2) ;
66
67if(verbosity > 0)
68 fprintf('%d keypoints, %d descriptor length.\n', K, DL) ;
69end
70
71%creates two output matrices
72P = zeros(4,K) ;
73L = zeros(DL,K) ;
74
75%parse tmp.key
76for k = 1:K
77
78 % Record format: i,j,s,th
79 [record, count] = fscanf(g, '%f', [1 4]) ;
80 if count ~= 4
81 error(...
82 sprintf('Invalid keypoint file (parsing keypoint %d)',k) );
83 end
84 P(:,k) = record(:) ;
85
86 % Record format: descriptor
87 [record, count] = fscanf(g, '%d', [1 DL]) ;
88 if count ~= DL
89 error(...
90 sprintf('Invalid keypoint file (parsing keypoint %d)',k) );
91 end
92 L(:,k) = record(:) ;
93
94end
95fclose(g) ;
96
97L=double(L) ;
98P(1:2,:)=flipud(P(1:2,:)) ; % i,j -> x,y
99
100frames=[ P(1:2,:) ; P(3,:) ; -P(4,:) ] ;
101descriptors = L ;
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.c b/SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.c
new file mode 100644
index 0000000..a1ef8c7
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.c
@@ -0,0 +1,342 @@
1/* file: siftrefinemx.c
2
3Benchmark - sift
4Data set - sqcif
5
6 < M A T L A B >
7 Copyright 1984-2006 The MathWorks, Inc.
8 Version 7.3.0.298 (R2006b)
9 August 03, 2006
10
11
12 To get started, type one of these: helpwin, helpdesk, or demo.
13 For product information, visit www.mathworks.com.
14
15Warning: Function /h/g2/kvs/checkParallel/sdvbs-svn/common/matlab/randn.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.
16> In path at 113
17 In script_run_profile at 3
18Warning: You are using gcc version "4.1.1". The earliest gcc version supported
19with mex is "3.4.0". The latest version tested for use with mex is "3.4.5".
20To download a different version of gcc, visit http://gcc.gnu.org
21Warning: You are using gcc version "4.1.1". The earliest gcc version supported
22with mex is "3.4.0". The latest version tested for use with mex is "3.4.5".
23To download a different version of gcc, visit http://gcc.gnu.org
24Warning: You are using gcc version "4.1.1". The earliest gcc version supported
25with mex is "3.4.0". The latest version tested for use with mex is "3.4.5".
26To download a different version of gcc, visit http://gcc.gnu.org
27Warning: You are using gcc version "4.1.1". The earliest gcc version supported
28with mex is "3.4.0". The latest version tested for use with mex is "3.4.5".
29To download a different version of gcc, visit http://gcc.gnu.org
30Warning: You are using gcc version "4.1.1". The earliest gcc version supported
31with mex is "3.4.0". The latest version tested for use with mex is "3.4.5".
32To download a different version of gcc, visit http://gcc.gnu.org
33Warning: You are using gcc version "4.1.1". The earliest gcc version supported
34with mex is "3.4.0". The latest version tested for use with mex is "3.4.5".
35To download a different version of gcc, visit http://gcc.gnu.org
36Input size - (96x96)
37** author: Andrea Vedaldi
38** description: Subpixel localization, thresholding and off-edge test.
39**/
40
41/* AUTORIGHTS
42Copyright (c) 2006 The Regents of the University of California.
43All Rights Reserved.
44
45Created by Andrea Vedaldi
46UCLA Vision Lab - Department of Computer Science
47
48Permission to use, copy, modify, and distribute this software and its
49documentation for educational, research and non-profit purposes,
50without fee, and without a written agreement is hereby granted,
51provided that the above copyright notice, this paragraph and the
52following three paragraphs appear in all copies.
53
54This software program and documentation are copyrighted by The Regents
55of the University of California. The software program and
56documentation are supplied "as is", without any accompanying services
57from The Regents. The Regents does not warrant that the operation of
58the program will be uninterrupted or error-free. The end-user
59understands that the program was developed for research purposes and
60is advised not to rely exclusively on the program for any reason.
61
62This software embodies a method for which the following patent has
63been issued: "Method and apparatus for identifying scale invariant
64features in an image and use of same for locating an object in an
65image," David G. Lowe, US Patent 6,711,293 (March 23,
662004). Provisional application filed March 8, 1999. Asignee: The
67University of British Columbia.
68
69IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
70FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
71INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
72ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
73ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
74CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
75LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
76A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
77BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
78MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
79*/
80
81#include"mex.h"
82
83#include<mexutils.c>
84
85#include<stdlib.h>
86#include<string.h>
87
88/* Prototype of DGESV LAPACK function for the solution of a linear system. */
89#ifdef WINDOWS
90#define DGESV dgesv
91#undef min
92#undef max
93#else
94#define DGESV dgesv_
95#endif
96
97#ifdef WINDOWS
98#ifdef __cplusplus__
99extern "C" {
100 extern int DGESV(int *n, int *nrhs, double *a, int *lda,
101 int *ipiv, double *b, int *ldb, int *info) ;
102}
103#else
104 extern int DGESV(int *n, int *nrhs, double *a, int *lda,
105 int *ipiv, double *b, int *ldb, int *info) ;
106#define sqrtf(x) ((float)sqrt((double)x)
107#define powf(x) ((float)pow((double)x)
108#define fabsf(x) ((float)fabs((double)x)
109#endif
110#else
111extern int DGESV(int *n, int *nrhs, double *a, int *lda,
112 int *ipiv, double *b, int *ldb, int *info) ;
113#endif
114
115#define greater(a,b) ((a) > (b))
116#define min(a,b) (((a)<(b))?(a):(b))
117#define max(a,b) (((a)>(b))?(a):(b))
118
119const int max_iter = 5 ;
120
121void
122mexFunction(int nout, mxArray *out[],
123 int nin, const mxArray *in[])
124{
125 int M,N,S,smin,K ;
126 const int* dimensions ;
127 const double* P_pt ;
128 const double* D_pt ;
129 double threshold = 0.01 ; /*0.02 ;*/
130 double r = 10.0 ;
131 double* result ;
132 enum {IN_P=0,IN_D,IN_SMIN,IN_THRESHOLD,IN_R} ;
133 enum {OUT_Q=0} ;
134
135 /* -----------------------------------------------------------------
136 ** Check the arguments
137 ** -------------------------------------------------------------- */
138 if (nin < 3) {
139 mexErrMsgTxt("At least three input arguments required.");
140 } else if (nout > 1) {
141 mexErrMsgTxt("Too many output arguments.");
142 }
143
144 if( !uIsRealMatrix(in[IN_P],3,-1) ) {
145 mexErrMsgTxt("P must be a 3xK real matrix") ;
146 }
147
148 if( !mxIsDouble(in[IN_D]) || mxGetNumberOfDimensions(in[IN_D]) != 3) {
149 mexErrMsgTxt("G must be a three dimensional real array.") ;
150 }
151
152 if( !uIsRealScalar(in[IN_SMIN]) ) {
153 mexErrMsgTxt("SMIN must be a real scalar.") ;
154 }
155
156 if(nin >= 4) {
157 if(!uIsRealScalar(in[IN_THRESHOLD])) {
158 mexErrMsgTxt("THRESHOLD must be a real scalar.") ;
159 }
160 threshold = *mxGetPr(in[IN_THRESHOLD]) ;
161 }
162
163 if(nin >= 5) {
164 if(!uIsRealScalar(in[IN_R])) {
165 mexErrMsgTxt("R must be a real scalar.") ;
166 }
167 r = *mxGetPr(in[IN_R]) ;
168 }
169
170 dimensions = mxGetDimensions(in[IN_D]) ;
171 M = dimensions[0] ;
172 N = dimensions[1] ;
173 S = dimensions[2] ;
174 smin = (int)(*mxGetPr(in[IN_SMIN])) ;
175
176 if(S < 3 || M < 3 || N < 3) {
177 mexErrMsgTxt("All dimensions of DOG must be not less than 3.") ;
178 }
179
180 K = mxGetN(in[IN_P]) ;
181 P_pt = mxGetPr(in[IN_P]) ;
182 D_pt = mxGetPr(in[IN_D]) ;
183
184 /* If the input array is empty, then output an empty array as well. */
185 if( K == 0) {
186 out[OUT_Q] = mxDuplicateArray(in[IN_P]) ;
187 return ;
188 }
189
190 /* -----------------------------------------------------------------
191 * Do the job
192 * -------------------------------------------------------------- */
193 {
194 double* buffer = (double*) mxMalloc(K*3*sizeof(double)) ;
195 double* buffer_iterator = buffer ;
196 int p ;
197 const int yo = 1 ;
198 const int xo = M ;
199 const int so = M*N ;
200
201/* printf("Actual values = %d\n\n", K);
202*/
203 for(p = 0 ; p < K ; ++p) {
204 int x = ((int)*P_pt++) ;
205 int y = ((int)*P_pt++) ;
206/* printf("%d\t%d\n", ((int)*P_pt), smin);
207*/
208 int s = ((int)*P_pt++) - smin ;
209 int iter ;
210 double b[3] ;
211
212 /* Local maxima extracted from the DOG
213 * have coorrinates 1<=x<=N-2, 1<=y<=M-2
214 * and 1<=s-mins<=S-2. This is also the range of the points
215 * that we can refine.
216 */
217/* printf("%d\t%d\t%d\t%d\t%d\t%d\n", x, N-2,y,M-2, s, S-2);
218*/
219 if(x < 1 || x > N-2 ||
220 y < 1 || y > M-2 ||
221 s < 1 || s > S-2) {
222 continue ;
223 }
224
225#define at(dx,dy,ds) (*(pt + (dx)*xo + (dy)*yo + (ds)*so))
226
227 {
228 const double* pt = D_pt + y*yo + x*xo + s*so ;
229
230 double Dx=0,Dy=0,Ds=0,Dxx=0,Dyy=0,Dss=0,Dxy=0,Dxs=0,Dys=0 ;
231 int dx = 0 ;
232 int dy = 0 ;
233/* printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%f\t%f\n",S, y, yo, x, xo, s, so, *D_pt, *pt);
234*/
235 for(iter = 0 ; iter < max_iter ; ++iter) {
236
237 double A[3*3] ;
238 int ipiv[3] ;
239 int n = 3 ;
240 int one = 1 ;
241 int info = 0 ;
242
243#define Aat(i,j) (A[(i)+(j)*3])
244
245 x += dx ;
246 y += dy ;
247 pt = D_pt + y*yo + x*xo + s*so ;
248
249 /* Compute the gradient. */
250 Dx = 0.5 * (at(+1,0,0) - at(-1,0,0)) ;
251 Dy = 0.5 * (at(0,+1,0) - at(0,-1,0));
252 Ds = 0.5 * (at(0,0,+1) - at(0,0,-1)) ;
253
254 /* Compute the Hessian. */
255 Dxx = (at(+1,0,0) + at(-1,0,0) - 2.0 * at(0,0,0)) ;
256 Dyy = (at(0,+1,0) + at(0,-1,0) - 2.0 * at(0,0,0)) ;
257 Dss = (at(0,0,+1) + at(0,0,-1) - 2.0 * at(0,0,0)) ;
258
259 Dxy = 0.25 * ( at(+1,+1,0) + at(-1,-1,0) - at(-1,+1,0) - at(+1,-1,0) ) ;
260 Dxs = 0.25 * ( at(+1,0,+1) + at(-1,0,-1) - at(-1,0,+1) - at(+1,0,-1) ) ;
261 Dys = 0.25 * ( at(0,+1,+1) + at(0,-1,-1) - at(0,-1,+1) - at(0,+1,-1) ) ;
262
263 /* Solve linear system. */
264 Aat(0,0) = Dxx ;
265 Aat(1,1) = Dyy ;
266 Aat(2,2) = Dss ;
267 Aat(0,1) = Aat(1,0) = Dxy ;
268 Aat(0,2) = Aat(2,0) = Dxs ;
269 Aat(1,2) = Aat(2,1) = Dys ;
270
271 b[0] = - Dx ;
272 b[1] = - Dy ;
273 b[2] = - Ds ;
274
275 /* DGESV (&n, &one, A, &n, ipiv, b, &n, &info) ;
276 */
277 /* If the translation of the keypoint is big, move the keypoint
278 * and re-iterate the computation. Otherwise we are all set.
279 */
280 dx= ((b[0] > 0.6 && x < N-2) ? 1 : 0 )
281 + ((b[0] < -0.6 && x > 1 ) ? -1 : 0 ) ;
282
283 dy= ((b[1] > 0.6 && y < M-2) ? 1 : 0 )
284 + ((b[1] < -0.6 && y > 1 ) ? -1 : 0 ) ;
285
286 if( dx == 0 && dy == 0 ) break ;
287
288 }
289
290 {
291 double val = at(0,0,0) + 0.5 * (Dx * b[0] + Dy * b[1] + Ds * b[2]) ;
292 double score = (Dxx+Dyy)*(Dxx+Dyy) / (Dxx*Dyy - Dxy*Dxy) ;
293 double xn = x + b[0] ;
294 double yn = y + b[1] ;
295 double sn = s + b[2] ;
296
297/* printf("%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n", fabs(val),threshold,score,(r+1)*(r+1)/r,fabs(b[0]), fabs(b[1]), fabs(b[2]),xn,yn,sn,r);
298*/
299 if(fabs(val) > threshold &&
300 score < (r+1)*(r+1)/r &&
301 score >= 0 &&
302 fabs(b[0]) < 1.5 &&
303 fabs(b[1]) < 1.5 &&
304 fabs(b[2]) < 1.5 &&
305 xn >= 0 &&
306 xn <= N-1 &&
307 yn >= 0 &&
308 yn <= M-1 &&
309 sn >= 0 &&
310 sn <= S-1) {
311 *buffer_iterator++ = xn ;
312 *buffer_iterator++ = yn ;
313 *buffer_iterator++ = sn+smin ;
314 }
315 }
316 }
317 }
318
319 /* Copy the result into an array. */
320 {
321 int i;
322 int NL = (buffer_iterator - buffer)/3 ;
323/* printf("%NL VALUE = %d\t%d\t%d\n", NL, buffer_iterator, buffer);
324*/
325 out[OUT_Q] = mxCreateDoubleMatrix(3, NL, mxREAL) ;
326 result = mxGetPr(out[OUT_Q]);
327 for(i=0; i<(3*NL); i++)
328 {
329 result[i] = buffer[i];
330/* printf("%f\t", buffer[i]);
331*/
332 }
333/* printf("\n");
334 memcpy(result, buffer, sizeof(double) * 3 * NL) ;
335*/
336 }
337 mxFree(buffer) ;
338 }
339
340}
341
342
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.m b/SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.m
new file mode 100644
index 0000000..222d610
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.m
@@ -0,0 +1,61 @@
1% SIFTREFINEMX Subpixel localization, thresholding and on-edge test
2% Q = SIFTREFINEMX(P, OCTAVE, SMIN) refines, thresholds and performs
3% the on-edge test for the SIFT frames P extracted from the DOG
4% octave OCTAVE with parameter SMIN (see GAUSSIANSS()).
5%
6% Q = SIFTREFINEMX(P, OCTAVE, SMIN, THRESH, R) specifies custom
7% values for the local maximum strength threshold THRESH and the
8% local maximum peakedeness threshold R.
9%
10% OCTAVE is an octave of the Difference Of Gaussian scale space. P
11% is a 3xK matrix specifying the indexes (X,Y,S) of the points of
12% extremum of the octave OCTAVE. The spatial indexes X,Y are integer
13% with base zero. The scale index S is integer with base SMIN and
14% represents a scale sublevel in the specified octave.
15%
16% The function returns a matrix Q containing the refined keypoints.
17% The matrix has the same format as P, except that the indexes are
18% now fractional. The function drops the points that do not satisfy
19% the strength and peakedness tests.
20%
21% See also SIFT().
22
23% AUTORIGHTS
24% Copyright (c) 2006 The Regents of the University of California.
25% All Rights Reserved.
26%
27% Created by Andrea Vedaldi
28% UCLA Vision Lab - Department of Computer Science
29%
30% Permission to use, copy, modify, and distribute this software and its
31% documentation for educational, research and non-profit purposes,
32% without fee, and without a written agreement is hereby granted,
33% provided that the above copyright notice, this paragraph and the
34% following three paragraphs appear in all copies.
35%
36% This software program and documentation are copyrighted by The Regents
37% of the University of California. The software program and
38% documentation are supplied "as is", without any accompanying services
39% from The Regents. The Regents does not warrant that the operation of
40% the program will be uninterrupted or error-free. The end-user
41% understands that the program was developed for research purposes and
42% is advised not to rely exclusively on the program for any reason.
43%
44% This software embodies a method for which the following patent has
45% been issued: "Method and apparatus for identifying scale invariant
46% features in an image and use of same for locating an object in an
47% image," David G. Lowe, US Patent 6,711,293 (March 23,
48% 2004). Provisional application filed March 8, 1999. Asignee: The
49% University of British Columbia.
50%
51% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
52% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
53% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
54% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
55% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
56% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
57% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
58% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
59% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
60% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
61
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.mexa64 b/SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.mexa64
new file mode 100755
index 0000000..c91556b
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.mexa64
Binary files differ
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.mexglx b/SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.mexglx
new file mode 100755
index 0000000..74b312c
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/siftrefinemx.mexglx
Binary files differ
diff --git a/SD-VBS/benchmarks/sift/src/matlab/tightsubplot.m b/SD-VBS/benchmarks/sift/src/matlab/tightsubplot.m
new file mode 100644
index 0000000..b790ef0
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/tightsubplot.m
@@ -0,0 +1,151 @@
1function H = tightsubplot(varargin)
2% TIGHTSUBPLOT Tiles axes without wasting space
3% H = TIGHTSUBPLOT(K,P) returns an handle to the P-th axis in a
4% regular grid of K axes. The K axes are numbered from left to right
5% and from top to bottom. The function operates similarly to
6% SUBPLOT(), but by default it does not put any margin between axes.
7%
8% H = TIGHTSUBPLOT(M,N,P) retursn an handle to the P-th axes in a
9% regular subdivision with M rows and N columns.
10%
11% The function accepts the following option-value pairs:
12%
13% 'Spacing' [0]
14% Set extra spacing between axes. The space is added between the
15% inner or outer boxes, depending on the setting below.
16%
17% 'Box' ['inner'] (** ONLY >R14 **)
18% If set to 'outer', the function displaces the axes by their
19% outer box, thus protecting title and labels. Unfortunately
20% MATLAB typically picks unnecessarily large insets, so that a bit
21% of space is wasted in this case. If set to 'inner', the
22% function uses the inner box. This causes the instets of nearby
23% axes to overlap, but it is very space conservative.
24%
25% REMARK. While SUBPLOT kills any pre-existing axes that overalps a
26% new one, this function does not.
27%
28% See also SUBPLOT().
29
30% AUTORIGHTS
31% Copyright (c) 2006 The Regents of the University of California.
32% All Rights Reserved.
33%
34% Created by Andrea Vedaldi
35% UCLA Vision Lab - Department of Computer Science
36%
37% Permission to use, copy, modify, and distribute this software and its
38% documentation for educational, research and non-profit purposes,
39% without fee, and without a written agreement is hereby granted,
40% provided that the above copyright notice, this paragraph and the
41% following three paragraphs appear in all copies.
42%
43% This software program and documentation are copyrighted by The Regents
44% of the University of California. The software program and
45% documentation are supplied "as is", without any accompanying services
46% from The Regents. The Regents does not warrant that the operation of
47% the program will be uninterrupted or error-free. The end-user
48% understands that the program was developed for research purposes and
49% is advised not to rely exclusively on the program for any reason.
50%
51% This software embodies a method for which the following patent has
52% been issued: "Method and apparatus for identifying scale invariant
53% features in an image and use of same for locating an object in an
54% image," David G. Lowe, US Patent 6,711,293 (March 23,
55% 2004). Provisional application filed March 8, 1999. Asignee: The
56% University of British Columbia.
57%
58% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
59% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
60% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
61% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
62% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
63% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
64% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
65% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
66% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
67% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
68
69sp=0.0 ;
70use_outer=0 ;
71
72% --------------------------------------------------------------------
73% Parse arguments
74% --------------------------------------------------------------------
75K=varargin{1} ;
76p=varargin{2} ;
77N = ceil(sqrt(K)) ;
78M = ceil(K/N) ;
79
80a=3 ;
81NA = length(varargin) ;
82if NA > 2
83 if isa(varargin{3},'char')
84 % Called with K and p
85 else
86 % Called with M,N and p
87 a = 4 ;
88 M = K ;
89 N = p ;
90 p = varargin{3} ;
91 end
92end
93
94for a=a:2:NA
95 switch varargin{a}
96 case 'Spacing'
97 sp=varargin{a+1} ;
98 case 'Box'
99 switch varargin{a+1}
100 case 'inner'
101 use_outer = 0 ;
102 case 'outer'
103 if ~strcmp(version('-release'), '14')
104 %warning(['Box option supported only on MATALB 14']) ;
105 continue;
106 end
107 use_outer = 1 ;
108 otherwise
109 error(['Box is either ''inner'' or ''outer''']) ;
110 end
111 otherwise
112 error(['Uknown parameter ''', varargin{a}, '''.']) ;
113 end
114end
115
116% --------------------------------------------------------------------
117% Check the arguments
118% --------------------------------------------------------------------
119
120[j,i]=ind2sub([N M],p) ;
121i=i-1 ;
122j=j-1 ;
123
124dt = sp/2 ;
125db = sp/2 ;
126dl = sp/2 ;
127dr = sp/2 ;
128
129pos = [ j*1/N+dl,...
130 1-i*1/M-1/M-db,...
131 1/N-dl-dr,...
132 1/M-dt-db] ;
133
134switch use_outer
135 case 0
136 H = findobj(gcf, 'Type', 'axes', 'Position', pos) ;
137 if(isempty(H))
138 H = axes('Position', pos) ;
139 else
140 axes(H) ;
141 end
142
143 case 1
144 H = findobj(gcf, 'Type', 'axes', 'OuterPosition', pos) ;
145 if(isempty(H))
146 H = axes('ActivePositionProperty', 'outerposition',...
147 'OuterPosition', pos) ;
148 else
149 axes(H) ;
150 end
151end