diff options
Diffstat (limited to 'SD-VBS/benchmarks/sift/src')
52 files changed, 5480 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/sift/src/c/diffss.c b/SD-VBS/benchmarks/sift/src/c/diffss.c new file mode 100644 index 0000000..683cbe7 --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/diffss.c | |||
@@ -0,0 +1,53 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include "sift.h" | ||
6 | |||
7 | /** | ||
8 | DIFFSS Difference of scale space | ||
9 | Returns a scale space DSS obtained by subtracting | ||
10 | consecutive levels of the scale space SS. | ||
11 | |||
12 | In SIFT, this function is used to compute the difference of | ||
13 | Gaussian scale space from the Gaussian scale space of an image. | ||
14 | **/ | ||
15 | |||
16 | F2D** diffss(F2D** ss, int num, int intervals) | ||
17 | { | ||
18 | F2D** dss; | ||
19 | int o, sizeM, sizeN, s, i, j; | ||
20 | F2D *current, *in1, *in2; | ||
21 | |||
22 | dss = malloc(num*intervals*sizeof(F2D*)); | ||
23 | |||
24 | for(o=0; o<num; o++) | ||
25 | { | ||
26 | for(s=0; s<(intervals-1); s++) | ||
27 | { | ||
28 | sizeM = ss[o*intervals+s]->height; | ||
29 | sizeN = ss[o*intervals+s]->width; | ||
30 | |||
31 | dss[o*intervals+s] = fMallocHandle(sizeM, sizeN); | ||
32 | |||
33 | current = dss[o*intervals+s]; | ||
34 | in1 = ss[o*intervals+s+1]; | ||
35 | in2 = ss[o*intervals+s]; | ||
36 | |||
37 | for(i=0; i<sizeM; i++) | ||
38 | { | ||
39 | for(j=0; j<sizeN; j++) | ||
40 | { | ||
41 | subsref(current,i,j) = subsref(in1,i,j) - subsref(in2,i,j); | ||
42 | } | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | |||
47 | return dss; | ||
48 | |||
49 | } | ||
50 | |||
51 | |||
52 | |||
53 | |||
diff --git a/SD-VBS/benchmarks/sift/src/c/doubleSize.c b/SD-VBS/benchmarks/sift/src/c/doubleSize.c new file mode 100644 index 0000000..dd17f77 --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/doubleSize.c | |||
@@ -0,0 +1,55 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include "sift.h" | ||
6 | |||
7 | F2D* doubleSize(F2D* I) | ||
8 | { | ||
9 | F2D *J; | ||
10 | int M, N, i, j; | ||
11 | |||
12 | M = I->height; | ||
13 | N = I->width; | ||
14 | J = fSetArray(2*M, 2*N, 0); | ||
15 | |||
16 | for(i=0; i<M; i++) | ||
17 | { | ||
18 | for(j=0; j<N; j++) | ||
19 | { | ||
20 | subsref(J,2*i,j*2) = subsref(I,i,j); | ||
21 | } | ||
22 | } | ||
23 | |||
24 | for(i=0; i<M-1; i++) | ||
25 | { | ||
26 | for(j=0; j<N-1; j++) | ||
27 | { | ||
28 | subsref(J,i*2+1,j*2+1) = (0.25 * (subsref(I,i,j) + subsref(I,i+1,j) + subsref(I,i,j+1) + subsref(I,(i+1),j+1))); | ||
29 | } | ||
30 | } | ||
31 | |||
32 | for(i=0; i<M-1; i++) | ||
33 | { | ||
34 | for(j=0; j<N; j++) | ||
35 | { | ||
36 | subsref(J,i*2+1,j*2) = (0.5 * (subsref(I,i,j) + subsref(I,i+1,j))); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | for(i=0; i<M; i++) | ||
41 | { | ||
42 | for(j=0; j<N-1; j++) | ||
43 | { | ||
44 | subsref(J,i*2,j*2+1) = (0.5 * (subsref(I,i,j) + subsref(I,i,j+1))); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | return J; | ||
49 | } | ||
50 | |||
51 | |||
52 | |||
53 | |||
54 | |||
55 | |||
diff --git a/SD-VBS/benchmarks/sift/src/c/filterBoundaryPoints.c b/SD-VBS/benchmarks/sift/src/c/filterBoundaryPoints.c new file mode 100644 index 0000000..c68e717 --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/filterBoundaryPoints.c | |||
@@ -0,0 +1,61 @@ | |||
1 | #include "sift.h" | ||
2 | |||
3 | /** | ||
4 | Filter out points on the boundaries. | ||
5 | The function returns oframes, which | ||
6 | contains the row, col and the interval number | ||
7 | **/ | ||
8 | |||
9 | F2D* filterBoundaryPoints(int M, int N, F2D* oframes) | ||
10 | { | ||
11 | int i, k=0, m=0; | ||
12 | int cnt; | ||
13 | I2D* sel; | ||
14 | F2D *ret; | ||
15 | |||
16 | cnt = 0; | ||
17 | for(i=0; i<oframes->width; i++) | ||
18 | { | ||
19 | if(asubsref(oframes,i)>3 && asubsref(oframes,i)<(N-3) && | ||
20 | subsref(oframes,1,i)>3 && subsref(oframes,1,i)<(M-3)) | ||
21 | { | ||
22 | cnt++; | ||
23 | } | ||
24 | } | ||
25 | |||
26 | sel = iSetArray(cnt, 1, 0); | ||
27 | for(i=0; i<oframes->width; i++) | ||
28 | { | ||
29 | if(asubsref(oframes,i)>3 && asubsref(oframes,i)<(N-3) && | ||
30 | subsref(oframes,1,i)>3 && subsref(oframes,1,i)<(M-3)) | ||
31 | { | ||
32 | asubsref(sel,k) = i; | ||
33 | k++; | ||
34 | } | ||
35 | m++; | ||
36 | } | ||
37 | |||
38 | if( sel->height > 0) | ||
39 | { | ||
40 | ret = fSetArray(oframes->height, sel->height, 0); | ||
41 | { | ||
42 | for(i=0; i<sel->height; i++) | ||
43 | { | ||
44 | subsref(ret,0,i) = subsref(oframes,0,asubsref(sel,i)); | ||
45 | subsref(ret,1,i) = subsref(oframes,1,asubsref(sel,i)); | ||
46 | subsref(ret,2,i) = subsref(oframes,2,asubsref(sel,i)); | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | else | ||
51 | ret = fSetArray(1,1,0); | ||
52 | |||
53 | iFreeHandle(sel); | ||
54 | return ret; | ||
55 | } | ||
56 | |||
57 | |||
58 | |||
59 | |||
60 | |||
61 | |||
diff --git a/SD-VBS/benchmarks/sift/src/c/gaussianss.c b/SD-VBS/benchmarks/sift/src/c/gaussianss.c new file mode 100644 index 0000000..52dd95b --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/gaussianss.c | |||
@@ -0,0 +1,185 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include "sift.h" | ||
6 | |||
7 | F2D* resizeArray(F2D* array, int omin) | ||
8 | { | ||
9 | F2D* prev = NULL; | ||
10 | F2D* current = array; | ||
11 | int o; | ||
12 | if(omin<0) | ||
13 | { | ||
14 | for(o=1; o>=-omin; o--) | ||
15 | { | ||
16 | prev = current; | ||
17 | current = doubleSize(current); | ||
18 | fFreeHandle(prev); | ||
19 | } | ||
20 | } | ||
21 | if(omin>0) | ||
22 | { | ||
23 | for(o=1; o<= omin; o++) | ||
24 | { | ||
25 | prev = current; | ||
26 | current = halveSize(current); | ||
27 | fFreeHandle(prev); | ||
28 | } | ||
29 | } | ||
30 | return current; | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | Returns the Gaussian scale space of image I. Image I is assumed to be | ||
35 | pre-smoothed at level SIGMAN. O,S,OMIN,SMIN,SMAX,SIGMA0 are the | ||
36 | parameters of the scale space. | ||
37 | **/ | ||
38 | |||
39 | F2D** gaussianss(F2D* array, float sigman, int O, int S, int omin, int smin, int smax, float sigma0) | ||
40 | { | ||
41 | /* We compute the following items in the function | ||
42 | 1. Smooth input image per octave | ||
43 | 2. Smooth each octave for different intervals | ||
44 | 3. Subtract each "interval-1" smooth image from "interval" image per octave. So, per octave, we have "interval" * DOG images. | ||
45 | 4. So, octave * intervals * image | ||
46 | 5. Note: At each octave, the image is scaled down in both x and y directions | ||
47 | */ | ||
48 | |||
49 | float k, dsigma0, dsigma; | ||
50 | int s, i, j, o, so, M, N, sbest; | ||
51 | int intervals = smax-smin+1; | ||
52 | float temp, target_sigma, prev_sigma; | ||
53 | F2D *TMP, **gss; | ||
54 | F2D* I = array; | ||
55 | |||
56 | // Scale multiplicative step | ||
57 | k = pow(2, (1.0/S)); | ||
58 | dsigma0 = sigma0 * sqrt(1-(1.0/pow(k,2))); // Scale step factor | ||
59 | |||
60 | // If omin < 0, multiply the size of the image. | ||
61 | I = resizeArray(I, omin); | ||
62 | M = I->height; | ||
63 | N = I->width; | ||
64 | so = -smin+1; // Index offset | ||
65 | |||
66 | gss = malloc(O*intervals*sizeof(F2D*)); | ||
67 | if(gss == NULL) | ||
68 | { | ||
69 | printf("Could not allocate memory\n"); | ||
70 | return NULL; | ||
71 | } | ||
72 | |||
73 | /** | ||
74 | First octave | ||
75 | -------------------------------------------------------------------- | ||
76 | |||
77 | The first level of the first octave has scale index (o,s) = | ||
78 | (omin,smin) and scale coordinate | ||
79 | |||
80 | sigma(omin,smin) = sigma0 2^omin k^smin | ||
81 | |||
82 | The input image I is at nominal scale sigman. Thus in order to get | ||
83 | the first level of the pyramid we need to apply a smoothing of | ||
84 | |||
85 | sqrt( (sigma0 2^omin k^smin)^2 - sigman^2 ). | ||
86 | |||
87 | As we have pre-scaled the image omin octaves (up or down, | ||
88 | depending on the sign of omin), we need to correct this value | ||
89 | by dividing by 2^omin, getting | ||
90 | |||
91 | sqrt( (sigma0 k^smin)^2 - (sigman/2^omin)^2 ) | ||
92 | |||
93 | **/ | ||
94 | |||
95 | temp = sqrt(pow((sigma0*pow(k,smin)),2) - pow((sigman/pow(2,omin)),2)); | ||
96 | |||
97 | { | ||
98 | gss[0] = fSetArray(I->height, I->width, 0); | ||
99 | imsmooth(I, temp, gss[0] ); | ||
100 | } | ||
101 | |||
102 | for(s=smin; s<smax; s++) | ||
103 | { | ||
104 | |||
105 | /** | ||
106 | Here we go from (omin,s-1) to (omin,s). The extra smoothing | ||
107 | standard deviation is | ||
108 | |||
109 | (sigma0 2^omin 2^(s/S) )^2 - (simga0 2^omin 2^(s/S-1/S) )^2 | ||
110 | |||
111 | After dividing by 2^omin (to take into account the fact | ||
112 | that the image has been pre-scaled omin octaves), the | ||
113 | standard deviation of the smoothing kernel is | ||
114 | |||
115 | dsigma = sigma0 k^s sqrt(1-1/k^2) | ||
116 | **/ | ||
117 | |||
118 | dsigma = pow(k,s+1) * dsigma0; | ||
119 | gss[s+so] = fSetArray(gss[s+so-1]->height, gss[s+so-1]->width, 0); | ||
120 | imsmooth( gss[(s+so-1)] , dsigma, gss[(s+so)] ); | ||
121 | } | ||
122 | |||
123 | /** Other octaves **/ | ||
124 | |||
125 | for(o=1; o<O; o++) | ||
126 | { | ||
127 | /** | ||
128 | We need to initialize the first level of octave (o,smin) from | ||
129 | the closest possible level of the previous octave. A level (o,s) | ||
130 | in this octave corrsponds to the level (o-1,s+S) in the previous | ||
131 | octave. In particular, the level (o,smin) correspnds to | ||
132 | (o-1,smin+S). However (o-1,smin+S) might not be among the levels | ||
133 | (o-1,smin), ..., (o-1,smax) that we have previously computed. | ||
134 | The closest pick is | ||
135 | |||
136 | / smin+S if smin+S <= smax | ||
137 | (o-1,sbest) , sbest = | | ||
138 | \ smax if smin+S > smax | ||
139 | |||
140 | The amount of extra smoothing we need to apply is then given by | ||
141 | |||
142 | ( sigma0 2^o 2^(smin/S) )^2 - ( sigma0 2^o 2^(sbest/S - 1) )^2 | ||
143 | |||
144 | As usual, we divide by 2^o to cancel out the effect of the | ||
145 | downsampling and we get | ||
146 | |||
147 | ( sigma 0 k^smin )^2 - ( sigma0 2^o k^(sbest - S) )^2 | ||
148 | **/ | ||
149 | |||
150 | sbest = MIN(smin+S-1, smax-1); | ||
151 | TMP = halveSize( gss[(o-1)*intervals+sbest+so]); | ||
152 | target_sigma = sigma0 * pow(k,smin); | ||
153 | prev_sigma = sigma0 * pow(k, (sbest+1)-S); | ||
154 | |||
155 | temp = sqrt(pow(target_sigma,2) - pow(prev_sigma, 2)); | ||
156 | if(target_sigma > prev_sigma) | ||
157 | { | ||
158 | gss[o*intervals] = fSetArray(TMP->height, TMP->width, 0); | ||
159 | imsmooth(TMP, temp, gss[o*intervals] ); | ||
160 | } | ||
161 | else | ||
162 | { | ||
163 | int i; | ||
164 | gss[o*intervals] = fSetArray(TMP->height, TMP->width, 0); | ||
165 | for(i=0; i<(TMP->height*TMP->width); i++) | ||
166 | asubsref(gss[o*intervals],i) = asubsref(TMP,i); | ||
167 | } | ||
168 | |||
169 | M = TMP->height; | ||
170 | N = TMP->width; | ||
171 | |||
172 | fFreeHandle(TMP); | ||
173 | |||
174 | for(s=smin; s<smax; s++) | ||
175 | { | ||
176 | // The other levels are determined as above for the first octave. | ||
177 | dsigma = pow(k,s+1) * dsigma0; | ||
178 | gss[o*intervals+s+so] = fSetArray(gss[o*intervals+s-1+so]->height, gss[o*intervals+s-1+so]->width, 0); | ||
179 | imsmooth( gss[o*intervals+s-1+so] , dsigma, gss[o*intervals+s+so]); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | fFreeHandle(I); | ||
184 | return gss; | ||
185 | } | ||
diff --git a/SD-VBS/benchmarks/sift/src/c/halveSize.c b/SD-VBS/benchmarks/sift/src/c/halveSize.c new file mode 100644 index 0000000..fe1e536 --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/halveSize.c | |||
@@ -0,0 +1,35 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <stdlib.h> | ||
7 | #include "sift.h" | ||
8 | |||
9 | F2D* halveSize(F2D* I) | ||
10 | { | ||
11 | F2D *J; | ||
12 | int i, j, k; | ||
13 | int hM, hN; | ||
14 | int M, N; | ||
15 | |||
16 | M = I->height; | ||
17 | N = I->width; | ||
18 | |||
19 | hM = (M+1)/2; | ||
20 | hN = (N+1)/2; | ||
21 | |||
22 | J = fSetArray(hM, hN, 0.0); | ||
23 | |||
24 | k = 0; | ||
25 | for(i=0; i<M; i+=2) | ||
26 | { | ||
27 | for(j=0; j<N; j+=2) | ||
28 | { | ||
29 | asubsref(J,k++) = subsref(I,i,j); | ||
30 | } | ||
31 | } | ||
32 | |||
33 | return J; | ||
34 | } | ||
35 | |||
diff --git a/SD-VBS/benchmarks/sift/src/c/imsmooth.c b/SD-VBS/benchmarks/sift/src/c/imsmooth.c new file mode 100644 index 0000000..d901418 --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/imsmooth.c | |||
@@ -0,0 +1,104 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include "sift.h" | ||
6 | #include <math.h> | ||
7 | #include <assert.h> | ||
8 | const double win_factor = 1.5 ; | ||
9 | const int nbins = 36 ; | ||
10 | const float threshold = 0.01; | ||
11 | |||
12 | /** | ||
13 | This function is similar to imageBlur in common/c folder. | ||
14 | Here, we can specify the sigma value for the gaussian filter | ||
15 | function. | ||
16 | **/ | ||
17 | |||
18 | void imsmooth(F2D* array, float dsigma, F2D* out) | ||
19 | { | ||
20 | int M,N ; | ||
21 | int i,j,k; | ||
22 | float s ; | ||
23 | |||
24 | /* ------------------------------------------------------------------ | ||
25 | ** Check the arguments | ||
26 | ** --------------------------------------------------------------- */ | ||
27 | |||
28 | M = array->height; | ||
29 | N = array->width; | ||
30 | s = dsigma; | ||
31 | |||
32 | /* ------------------------------------------------------------------ | ||
33 | ** Do the job | ||
34 | ** --------------------------------------------------------------- */ | ||
35 | if(s > threshold) | ||
36 | { | ||
37 | int W = (int) ceil(4*s) ; | ||
38 | float temp[2*W+1]; | ||
39 | F2D* buffer; | ||
40 | float acc = 0.0; | ||
41 | |||
42 | buffer = fSetArray(M,N,0); | ||
43 | |||
44 | for(j = 0 ; j < (2*W+1) ; ++j) | ||
45 | { | ||
46 | temp[j] = (float)(expf(-0.5 * (j - W)*(j - W)/(s*s))) ; | ||
47 | acc += temp[j]; | ||
48 | } | ||
49 | |||
50 | for(j = 0 ; j < (2*W+1) ; ++j) | ||
51 | { | ||
52 | temp[j] /= acc ; | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | ** Convolve along the columns | ||
57 | **/ | ||
58 | |||
59 | for(j = 0 ; j < M ; ++j) | ||
60 | { | ||
61 | for(i = 0 ; i < N ; ++i) | ||
62 | { | ||
63 | int startCol = MAX(i-W,0); | ||
64 | int endCol = MIN(i+W, N-1); | ||
65 | int filterStart = MAX(0, W-i); | ||
66 | |||
67 | assert(j < array->height); | ||
68 | assert(j < buffer->height); | ||
69 | assert(i < buffer->width); | ||
70 | for(k=startCol; k<=endCol; k++) { | ||
71 | assert(k < array->width); | ||
72 | assert(filterStart < 2*W+1); | ||
73 | subsref(buffer,j,i) += subsref(array, j, k) * temp[filterStart++]; | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | |||
78 | /* | ||
79 | ** Convolve along the rows | ||
80 | **/ | ||
81 | for(j = 0 ; j < M ; ++j) | ||
82 | { | ||
83 | for(i = 0 ; i < N ; ++i) | ||
84 | { | ||
85 | int startRow = MAX(j-W,0); | ||
86 | int endRow = MIN(j+W, M-1); | ||
87 | int filterStart = MAX(0, W-j); | ||
88 | for(k=startRow; k<=endRow; k++) | ||
89 | subsref(out,j,i) += subsref(buffer,k,i) * temp[filterStart++]; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | fFreeHandle(buffer); | ||
94 | |||
95 | } | ||
96 | else | ||
97 | { | ||
98 | for(i=0;i<M*N;i++) | ||
99 | asubsref(out, i) = asubsref(array, i); | ||
100 | } | ||
101 | |||
102 | |||
103 | return; | ||
104 | } | ||
diff --git a/SD-VBS/benchmarks/sift/src/c/script_sift.c b/SD-VBS/benchmarks/sift/src/c/script_sift.c new file mode 100644 index 0000000..0b2f106 --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/script_sift.c | |||
@@ -0,0 +1,83 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <stdlib.h> | ||
7 | #include "sift.h" | ||
8 | #include <malloc.h> | ||
9 | #include "extra.h" | ||
10 | #define SIFT_MEM 1<<29 | ||
11 | void normalizeImage(F2D* image) | ||
12 | { | ||
13 | int i; | ||
14 | int rows; | ||
15 | int cols; | ||
16 | |||
17 | int tempMin = 10000, tempMax = -1; | ||
18 | rows = image->height; | ||
19 | cols = image->width; | ||
20 | |||
21 | for(i=0; i<(rows*cols); i++) | ||
22 | if(tempMin > asubsref(image,i)) | ||
23 | tempMin = asubsref(image,i); | ||
24 | |||
25 | for(i=0; i<(rows*cols); i++) | ||
26 | asubsref(image,i) = asubsref(image,i) - tempMin; | ||
27 | |||
28 | for(i=0; i<(rows*cols); i++) | ||
29 | if(tempMax < asubsref(image,i)) | ||
30 | tempMax = asubsref(image,i); | ||
31 | |||
32 | for(i=0; i<(rows*cols); i++) | ||
33 | asubsref(image,i) = ( asubsref(image,i) / (tempMax+0.0) ); | ||
34 | } | ||
35 | |||
36 | int main(int argc, char* argv[]) | ||
37 | { | ||
38 | SET_UP | ||
39 | mallopt(M_TOP_PAD, SIFT_MEM); | ||
40 | mallopt(M_MMAP_MAX, 0); | ||
41 | I2D* im; | ||
42 | F2D *image; | ||
43 | int rows, cols, i, j; | ||
44 | F2D* frames; | ||
45 | unsigned int* startTime, *endTime, *elapsed; | ||
46 | |||
47 | char imSrc[100]; | ||
48 | printf("Input image: "); | ||
49 | scanf("%s", imSrc); | ||
50 | im = readImage(imSrc); | ||
51 | image = fiDeepCopy(im); | ||
52 | rows = image->height; | ||
53 | cols = image->width; | ||
54 | |||
55 | |||
56 | printf("start\n"); | ||
57 | for_each_job{ | ||
58 | image = fiDeepCopy(im); | ||
59 | normalizeImage(image); | ||
60 | /** Extract sift features for the normalized image **/ | ||
61 | frames = sift(image); | ||
62 | } | ||
63 | printf("end..\n"); | ||
64 | |||
65 | #ifdef CHECK | ||
66 | { | ||
67 | int ret=0; | ||
68 | float tol = 0.2; | ||
69 | #ifdef GENERATE_OUTPUT | ||
70 | fWriteMatrix(frames, argv[1]); | ||
71 | #endif | ||
72 | ret = fSelfCheck(frames, "expected_C.txt", tol); | ||
73 | if (ret == -1) | ||
74 | printf("Error in SIFT\n"); | ||
75 | } | ||
76 | #endif | ||
77 | |||
78 | iFreeHandle(im); | ||
79 | fFreeHandle(frames); | ||
80 | WRITE_TO_FILE | ||
81 | return 0; | ||
82 | } | ||
83 | |||
diff --git a/SD-VBS/benchmarks/sift/src/c/sift.c b/SD-VBS/benchmarks/sift/src/c/sift.c new file mode 100644 index 0000000..ea0d308 --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/sift.c | |||
@@ -0,0 +1,314 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include <math.h> | ||
6 | #include "sift.h" | ||
7 | |||
8 | /** SIFT- Scale Invariant Feature Transform. This algorithm is based on | ||
9 | David Lowe's implementation of sift. So, we will use the parameter | ||
10 | values from Lowe's implementation. | ||
11 | See: http://www.cs.ubc.ca/~lowe/keypoints/ | ||
12 | |||
13 | SIFT extracts from an image a collection of frames or keypoints. These | ||
14 | are oriented disks attacked to blob-like structures of the image. As | ||
15 | the image translates, rotates and scales, the frames track these blobs | ||
16 | and the deformation. | ||
17 | |||
18 | 'BoundaryPoint' [bool] | ||
19 | If set to 1, frames too close to the image boundaries are discarded. | ||
20 | |||
21 | 'Sigma0' [pixels] | ||
22 | Smoothing of the level 0 of octave 0 of the scale space. | ||
23 | (Note that Lowe's 1.6 value refers to the level -1 of octave 0.) | ||
24 | |||
25 | 'SigmaN' [pixels] | ||
26 | Nominal smoothing of the input image. Typically set to 0.5. | ||
27 | |||
28 | 'Threshold' | ||
29 | Threshold used to eliminate weak keypoints. Typical values for | ||
30 | intensity images in the range [0,1] are around 0.01. Smaller | ||
31 | values mean more keypoints. | ||
32 | |||
33 | **/ | ||
34 | |||
35 | F2D* sift(F2D* I) | ||
36 | { | ||
37 | int rows, cols, K; | ||
38 | int subLevels, omin, Octaves, r, NBP, NBO, smin, smax, intervals, o; | ||
39 | float sigma, sigman, sigma0, thresh, magnif; | ||
40 | int discardBoundaryPoints; | ||
41 | F2D *descriptors; | ||
42 | F2D **gss, *tfr; | ||
43 | F2D **dogss; | ||
44 | I2D* i_, *j_, *s_; | ||
45 | F2D *oframes, *frames; | ||
46 | int i, j, k, m, startRow, startCol, endRow, endCol, firstIn=1; | ||
47 | float minVal; | ||
48 | I2D* tx1, *ty1, *ts1; | ||
49 | I2D* x1, *y1, *s1, *txys; | ||
50 | |||
51 | rows = I->height; | ||
52 | cols = I->width; | ||
53 | |||
54 | /** | ||
55 | Lowe's choices | ||
56 | Octaves - octave | ||
57 | subLevels - sub-level for image | ||
58 | sigma - sigma value for gaussian kernel, for smoothing the image | ||
59 | At each successive octave, the data is spatially downsampled by half | ||
60 | **/ | ||
61 | |||
62 | subLevels = 3; | ||
63 | omin = -1; | ||
64 | minVal = log2f(MIN(rows,cols)); | ||
65 | Octaves = (int)(floor(minVal))-omin-4; /* Upto 16x16 images */ | ||
66 | sigma0 = 1.6 * pow(2, (1.0/subLevels)); | ||
67 | sigman = 0.5; | ||
68 | thresh = (0.04/subLevels)/2; | ||
69 | r = 10; | ||
70 | |||
71 | #ifdef test | ||
72 | subLevels = 1; | ||
73 | Octaves = 1; | ||
74 | sigma0 = pow(0.6 * 2, 1); | ||
75 | sigman = 1.0; | ||
76 | thresh = (1/subLevels)/2; | ||
77 | r = 1; | ||
78 | #endif | ||
79 | |||
80 | NBP = 4; | ||
81 | NBO = 8 ; | ||
82 | magnif = 3.0 ; | ||
83 | discardBoundaryPoints = 1 ; | ||
84 | |||
85 | smin = -1; | ||
86 | smax = subLevels+1; | ||
87 | intervals = smax - smin + 1; | ||
88 | |||
89 | /** | ||
90 | We build gaussian pyramid for the input image. Given image I, | ||
91 | we sub-sample the image into octave 'Octaves' number of levels. At | ||
92 | each level, we smooth the image with varying sigman values. | ||
93 | |||
94 | Gaussiam pyramid can be assumed as a 2-D matrix, where each | ||
95 | element is an image. Number of rows corresponds to the number | ||
96 | of scales of the pyramid (octaves, "Octaves"). Row 0 (scale 0) is the | ||
97 | size of the actual image, Row 1 (scale 1) is half the actual | ||
98 | size and so on. | ||
99 | |||
100 | At each scale, the image is smoothened with different sigma values. | ||
101 | So, each row has "intervals" number of smoothened images, starting | ||
102 | with least blurred. | ||
103 | |||
104 | gss holds the entire gaussian pyramid. | ||
105 | **/ | ||
106 | |||
107 | gss = gaussianss(I, sigman, Octaves, subLevels, omin, -1, subLevels+1, sigma0); | ||
108 | |||
109 | /** | ||
110 | Once we build the gaussian pyramid, we compute DOG, the | ||
111 | Difference of Gaussians. At every scale, we do: | ||
112 | |||
113 | dogss[fixedScale][0] = gss[fixedScale][1] - gss[fixedScale][0] | ||
114 | |||
115 | Difference of gaussian gives us edge information, at each scale. | ||
116 | In order to detect keypoints on the intervals per octave, we | ||
117 | inspect DOG images at highest and lowest scales of the octave, for | ||
118 | extrema detection. | ||
119 | **/ | ||
120 | |||
121 | dogss = diffss(gss, Octaves, intervals); | ||
122 | |||
123 | /** The extraction of keypoints is carried one octave per time **/ | ||
124 | for(o=0; o<Octaves; o++) | ||
125 | { | ||
126 | F2D *temp; | ||
127 | F2D *t; | ||
128 | F2D *negate; | ||
129 | F2D *idxf, *idxft; | ||
130 | I2D *idx; | ||
131 | int i1, j1; | ||
132 | I2D *s, *i, *j, *x, *y; | ||
133 | int sizeRows = dogss[o*intervals]->height; | ||
134 | int sizeCols = dogss[o*intervals]->width; | ||
135 | |||
136 | { | ||
137 | int i,j,k=0; | ||
138 | temp = fMallocHandle(intervals-1, sizeRows*sizeCols); | ||
139 | negate = fMallocHandle(intervals-1, sizeRows*sizeCols); | ||
140 | |||
141 | /** | ||
142 | Keypoints are detected as points of local extrema of the | ||
143 | DOG pyramid, at a given octave. In softlocalmax function, the | ||
144 | keypoints are extracted by looking at 9x9x9 neighborhood samples. | ||
145 | |||
146 | We populate temp and negate arrays with the values of the DOG | ||
147 | pyramid for a given octave, o. Since we are interested in both | ||
148 | local maxima and minima, we compute negate matrix, which is the | ||
149 | negated values of the DOG pyramid. | ||
150 | |||
151 | **/ | ||
152 | |||
153 | for(i1=0; i1<(intervals-1); i1++) | ||
154 | { | ||
155 | for(j=0; j<sizeCols; j++) | ||
156 | { | ||
157 | for(i=0; i<sizeRows; i++) | ||
158 | { | ||
159 | asubsref(temp,k) = subsref(dogss[o*intervals+i1],i,j); | ||
160 | asubsref(negate,k++) = -subsref(dogss[o*intervals+i1],i,j); | ||
161 | } | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | |||
166 | /** | ||
167 | siftlocalmax returns indices k, that correspond to local maxima and | ||
168 | minima. | ||
169 | The 80% tricks discards early very weak points before refinement. | ||
170 | **/ | ||
171 | idxf = siftlocalmax( temp, 0.8*thresh, intervals, sizeRows, sizeCols); | ||
172 | t = siftlocalmax( negate, 0.8*thresh, intervals, sizeRows, sizeCols); | ||
173 | |||
174 | idxft = fHorzcat(idxf, t); | ||
175 | |||
176 | /** | ||
177 | Since indices is the 1-D index of the temp/negate arrays, we compute | ||
178 | the x,y and intervals(s) co-ordinates corresponding to each index. | ||
179 | **/ | ||
180 | |||
181 | idx = ifDeepCopy(idxft); | ||
182 | |||
183 | x = iSetArray(idx->height,idx->width,0); | ||
184 | y = iSetArray(idx->height,idx->width,0); | ||
185 | s_ = iSetArray(idx->height,idx->width,0); | ||
186 | |||
187 | { | ||
188 | int i, j; | ||
189 | for(i=0; i<idx->height; i++) | ||
190 | { | ||
191 | for(j=0; j<idx->width; j++) | ||
192 | { | ||
193 | int v, u, w, z; | ||
194 | w = subsref(idx,i,j); | ||
195 | v = ceil((w/(sizeRows*sizeCols)) + 0.5); | ||
196 | u = floor(w/(sizeRows*sizeCols)); | ||
197 | z = w - (sizeRows*sizeCols*u); | ||
198 | |||
199 | /** v is the interval number, s **/ | ||
200 | subsref(s_,i,j) = v; | ||
201 | /** row number of the index **/ | ||
202 | subsref(y,i,j) = ceil((z / sizeRows)+0.5); | ||
203 | /** col number of the index **/ | ||
204 | subsref(x,i,j) = z - (sizeCols * floor(z / sizeRows)); | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | |||
209 | { | ||
210 | |||
211 | tx1 = isMinus(x, 1); | ||
212 | x1 = iReshape(tx1, 1, (tx1->height*tx1->width)); | ||
213 | |||
214 | ty1 = isMinus(y, 1); | ||
215 | y1 = iReshape(ty1, 1, (ty1->height*ty1->width)); | ||
216 | |||
217 | ts1 = isPlus(s_, (smin-1)); | ||
218 | s1 = iReshape(ts1, 1, (ts1->height*ts1->width)); | ||
219 | |||
220 | txys = iVertcat(y1, x1); | ||
221 | i_ = iVertcat(txys, s1); | ||
222 | } | ||
223 | |||
224 | /** | ||
225 | Stack all x,y,s into oframes. | ||
226 | Row 0 of oframes = x | ||
227 | Row 1 of oframes = y | ||
228 | Row 2 of oframes = s | ||
229 | **/ | ||
230 | oframes = fiDeepCopy(i_); | ||
231 | |||
232 | { | ||
233 | int i,j; | ||
234 | F2D* temp; | ||
235 | temp = oframes; | ||
236 | |||
237 | /** | ||
238 | Remove points too close to the boundary | ||
239 | **/ | ||
240 | |||
241 | if(discardBoundaryPoints) | ||
242 | oframes = filterBoundaryPoints(sizeRows, sizeCols, temp); | ||
243 | fFreeHandle(temp); | ||
244 | } | ||
245 | |||
246 | /** | ||
247 | Refine the location, threshold strength and remove points on edges | ||
248 | **/ | ||
249 | if( asubsref(oframes,0) != 0) | ||
250 | { | ||
251 | F2D* temp_; | ||
252 | temp_ = fTranspose(oframes); | ||
253 | fFreeHandle(oframes); | ||
254 | oframes = siftrefinemx(temp_, temp, smin, thresh, r, sizeRows, sizeCols, intervals-1); | ||
255 | fFreeHandle(temp_); | ||
256 | |||
257 | if( firstIn == 0) | ||
258 | { | ||
259 | tfr = fDeepCopy(frames); | ||
260 | fFreeHandle(frames); | ||
261 | frames = fHorzcat(tfr, oframes); | ||
262 | fFreeHandle(tfr); | ||
263 | } | ||
264 | else | ||
265 | frames = fDeepCopy(oframes); | ||
266 | firstIn = 0; | ||
267 | } | ||
268 | else if(Octaves == 1) | ||
269 | frames = fDeepCopy(oframes); | ||
270 | |||
271 | fFreeHandle(oframes); | ||
272 | iFreeHandle(y); | ||
273 | iFreeHandle(x); | ||
274 | iFreeHandle(s_); | ||
275 | iFreeHandle(y1); | ||
276 | iFreeHandle(x1); | ||
277 | iFreeHandle(s1); | ||
278 | iFreeHandle(ty1); | ||
279 | iFreeHandle(tx1); | ||
280 | iFreeHandle(ts1); | ||
281 | iFreeHandle(txys); | ||
282 | iFreeHandle(i_); | ||
283 | iFreeHandle(idx); | ||
284 | fFreeHandle(idxf); | ||
285 | fFreeHandle(idxft); | ||
286 | fFreeHandle(temp); | ||
287 | fFreeHandle(t); | ||
288 | fFreeHandle(negate); | ||
289 | } | ||
290 | |||
291 | { int s; | ||
292 | for(o=0; o<Octaves; o++) | ||
293 | { | ||
294 | for(s=0; s<(intervals-1); s++) | ||
295 | { | ||
296 | fFreeHandle(dogss[o*intervals+s]); | ||
297 | } | ||
298 | } | ||
299 | for(o=0; o<Octaves; o++) | ||
300 | { | ||
301 | for(s=0; s<(intervals); s++) | ||
302 | { | ||
303 | fFreeHandle(gss[o*intervals+s]); | ||
304 | } | ||
305 | } | ||
306 | } | ||
307 | free(gss); | ||
308 | free(dogss); | ||
309 | |||
310 | return frames; | ||
311 | } | ||
312 | |||
313 | |||
314 | |||
diff --git a/SD-VBS/benchmarks/sift/src/c/sift.h b/SD-VBS/benchmarks/sift/src/c/sift.h new file mode 100644 index 0000000..e8a4ee0 --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/sift.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #ifndef _SIFT_ | ||
6 | #define _SIFT_ | ||
7 | |||
8 | #include "sdvbs_common.h" | ||
9 | #include <assert.h> | ||
10 | |||
11 | #define GREATER(a,b) ((a) > (b)) | ||
12 | #define MAX(a,b) (((a)>(b))?(a):(b)) | ||
13 | #define MIN(a,b) (((a)<(b))?(a):(b)) | ||
14 | |||
15 | F2D* sift(F2D* I); | ||
16 | F2D* halveSize(F2D* I); | ||
17 | F2D** gaussianss(F2D* I, float sigman, int O, int S, int omin, int smin, int smax, float sigma0); | ||
18 | F2D** diffss(F2D** ss, int O, int intervals); | ||
19 | F2D* doubleSize(F2D* I); | ||
20 | void imsmooth(F2D* I_pt, float dsigma, F2D* out); | ||
21 | F2D* siftlocalmax(F2D* in, float thresh, int intervals, int M, int N); | ||
22 | F2D* filterBoundaryPoints(int M, int N, F2D* oframes); | ||
23 | F2D* siftrefinemx(F2D* oframes, F2D* dogss, int smin, float thresh, int rin, int M, int N, int intervals); | ||
24 | |||
25 | #endif | ||
26 | |||
27 | |||
diff --git a/SD-VBS/benchmarks/sift/src/c/siftlocalmax.c b/SD-VBS/benchmarks/sift/src/c/siftlocalmax.c new file mode 100644 index 0000000..d75bcbd --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/siftlocalmax.c | |||
@@ -0,0 +1,247 @@ | |||
1 | #include "sift.h" | ||
2 | |||
3 | /** | ||
4 | SIFTLOCALMAX Find local maximizers | ||
5 | Returns the indexes of the local maximizers of | ||
6 | the 3-dimensional array F. | ||
7 | |||
8 | Say, we have a Q-dimensional array F. | ||
9 | A local maximizer is an element whose value is greater than the | ||
10 | value of all its neighbors. The neighbors of an element i1...iQ | ||
11 | are the subscripts j1...jQ such that iq-1 <= jq <= iq (excluding | ||
12 | i1...iQ itself). For example, if Q=1 the neighbors of an element | ||
13 | are its predecessor and successor in the linear order; if Q=2, its | ||
14 | neighbors are the elements immediately to its north, south, west, | ||
15 | est, north-west, north-est, south-west and south-est | ||
16 | (8-neighborhood). | ||
17 | |||
18 | Points on the boundary of F are ignored (and never selected as | ||
19 | local maximizers). | ||
20 | |||
21 | SEL=SIFTLOCALMAX(F,THRESH) accepts an element as a mazimizer only | ||
22 | if it is at least THRES greater than all its neighbors. | ||
23 | |||
24 | SEL=SIFTLOCALMAX(F,THRESH,P) look for neighbors only in the first | ||
25 | P dimensions of the Q-dimensional array F. This is useful to | ||
26 | process F in ``slices''. | ||
27 | |||
28 | REMARK. Matrices (2-array) with a singleton dimension are | ||
29 | interpreted as vectors (1-array). So for example SIFTLOCALMAX([0 1 | ||
30 | 0]) and SIFTLOCALMAX([0 1 0]') both return 2 as an aswer. However, | ||
31 | if [0 1 0] is to be interpreted as a 1x2 matrix, then the correct | ||
32 | answer is the empty set, as all elements are on the boundary. | ||
33 | Unfortunately MATLAB does not distinguish between vectors and | ||
34 | 2-matrices with a singleton dimension. To forece the | ||
35 | interpretation of all matrices as 2-arrays, use | ||
36 | SIFTLOCALMAX(F,TRESH,2) (but note that in this case the result is | ||
37 | always empty!). | ||
38 | **/ | ||
39 | |||
40 | #define NDIMS 3 | ||
41 | |||
42 | F2D* siftlocalmax(F2D* in, float thresh, int intervals, int M, int N) | ||
43 | { | ||
44 | int ndims, ptoffset=0, maxIter = 0; | ||
45 | int offsets[NDIMS]; | ||
46 | int midx[NDIMS]; | ||
47 | int dims[NDIMS]; | ||
48 | I2D* neighbors ; | ||
49 | int nneighbors ; | ||
50 | F2D* out; | ||
51 | |||
52 | /** | ||
53 | We pass dogss[o], which has >1 intervals | ||
54 | If >1 intervals, then the dimensions of in[F] will be 1 x intervals | ||
55 | If =1 interval, then the dimensions of in[F] will be the size of the dogss[o] image | ||
56 | We will check for this condition. | ||
57 | **/ | ||
58 | |||
59 | ndims = NDIMS; /* Since we have intervals number of images of size M x N */ | ||
60 | dims[0] = M; | ||
61 | dims[1] = N; | ||
62 | dims[2] = intervals-1; | ||
63 | |||
64 | /* | ||
65 | If there are only two dimensions and if one is singleton, then | ||
66 | assume that a vector has been provided as input (and treat this | ||
67 | as a COLUMN matrix with p=1). We do this because Matlab does not | ||
68 | distinguish between vectors and 1xN or Mx1 matrices and because | ||
69 | the cases 1xN and Mx1 are trivial (the result is alway empty). | ||
70 | */ | ||
71 | |||
72 | |||
73 | |||
74 | /* ------------------------------------------------------------------ | ||
75 | * Do the job | ||
76 | * --------------------------------------------------------------- */ | ||
77 | int maxima_size = M*N ; | ||
78 | |||
79 | I2D* maxima_start = iMallocHandle(1, maxima_size); | ||
80 | int* maxima_iterator = maxima_start->data ; | ||
81 | int* maxima_end = maxima_start->data + maxima_size ; | ||
82 | |||
83 | int i,h,o,j; | ||
84 | F2D* pt; | ||
85 | |||
86 | pt = in; | ||
87 | |||
88 | /* Compute the offsets between dimensions. */ | ||
89 | offsets[0] = 1 ; | ||
90 | for(i = 1 ; i < ndims ; ++i) | ||
91 | { | ||
92 | offsets[i] = offsets[i-1]*dims[i-1] ; | ||
93 | } | ||
94 | |||
95 | /* Multi-index. */ | ||
96 | for(i = 0 ; i < ndims ; ++i) | ||
97 | midx[i] = 1 ; | ||
98 | |||
99 | /* Neighbors. */ | ||
100 | nneighbors = 1 ; | ||
101 | o=0 ; | ||
102 | for(i = 0 ; i < ndims ; ++i) | ||
103 | { | ||
104 | nneighbors *= 3 ; | ||
105 | midx[i] = -1 ; | ||
106 | o -= offsets[i] ; | ||
107 | } | ||
108 | nneighbors -= 1 ; | ||
109 | neighbors = iMallocHandle(1,nneighbors); | ||
110 | |||
111 | /* Precompute offsets from offset(-1,...,-1,0,...0) to | ||
112 | * offset(+1,...,+1,0,...,0). */ | ||
113 | i = 0 ; | ||
114 | |||
115 | while(1) | ||
116 | { | ||
117 | if(o != 0) | ||
118 | { | ||
119 | asubsref(neighbors, i) = o ; | ||
120 | i++; | ||
121 | } | ||
122 | h = 0 ; | ||
123 | while( o += offsets[h], (++midx[h]) > 1 ) | ||
124 | { | ||
125 | o -= 3*offsets[h] ; | ||
126 | midx[h] = -1 ; | ||
127 | if(++h >= ndims) | ||
128 | goto stop ; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | stop: ; | ||
133 | |||
134 | /* Starts at the corner (1,1,...,1,0,0,...0) */ | ||
135 | for(h = 0 ; h < ndims ; ++h) | ||
136 | { | ||
137 | midx[h] = 1 ; | ||
138 | ptoffset += offsets[h] ; | ||
139 | } | ||
140 | |||
141 | |||
142 | /* --------------------------------------------------------------- | ||
143 | * Loop | ||
144 | * ------------------------------------------------------------ */ | ||
145 | |||
146 | /* | ||
147 | If any dimension in the first P is less than 3 elements wide | ||
148 | then just return the empty matrix (if we proceed without doing | ||
149 | anything we break the carry reporting algorithm below). | ||
150 | */ | ||
151 | |||
152 | for(h=0 ; h < ndims ; ++h) | ||
153 | if(dims[h] < 3) | ||
154 | goto end ; | ||
155 | |||
156 | while(1) | ||
157 | { | ||
158 | /* Propagate carry along multi index midx */ | ||
159 | |||
160 | h = 0 ; | ||
161 | while(midx[h] >= dims[h] - 1) | ||
162 | { | ||
163 | midx[h] = 1 ; | ||
164 | if(++h >= ndims) | ||
165 | goto next_layer ; | ||
166 | ++midx[h] ; | ||
167 | } | ||
168 | |||
169 | /* Scan neighbors */ | ||
170 | { | ||
171 | float v = asubsref(pt, ptoffset); //*pt ; | ||
172 | int is_greater = (v>=thresh) ? 1 : 0; | ||
173 | |||
174 | assert(ptoffset < pt->width*pt->height); | ||
175 | |||
176 | i = 0 ; | ||
177 | while(is_greater && i < nneighbors) | ||
178 | { | ||
179 | if(v > asubsref(pt, ptoffset + asubsref(neighbors,i))) | ||
180 | is_greater *= 1; | ||
181 | else | ||
182 | is_greater *= 0; | ||
183 | i = i+1; | ||
184 | } | ||
185 | |||
186 | /* Add the local maximum */ | ||
187 | if(is_greater) | ||
188 | { | ||
189 | /* Need more space? */ | ||
190 | if( &(maxima_iterator[maxIter]) == maxima_end) | ||
191 | { | ||
192 | int *temp, i, j; | ||
193 | maxima_size += M*N ; | ||
194 | |||
195 | free(maxima_start); | ||
196 | maxima_start = iMallocHandle(1, maxima_size); | ||
197 | |||
198 | maxima_end = maxima_start->data + maxima_size ; | ||
199 | maxima_iterator = maxima_end - M*N ; | ||
200 | maxIter = 0; | ||
201 | } | ||
202 | |||
203 | maxima_iterator[maxIter] = ptoffset + 1; | ||
204 | maxIter++; | ||
205 | } | ||
206 | |||
207 | /* Go to next element */ | ||
208 | ptoffset += 1 ; | ||
209 | ++midx[0] ; | ||
210 | continue ; | ||
211 | |||
212 | next_layer: ; | ||
213 | if( h >= ndims ) | ||
214 | goto end ; | ||
215 | |||
216 | while((++midx[h]) >= dims[h]) | ||
217 | { | ||
218 | midx[h] = 0 ; | ||
219 | if(++h >= ndims) | ||
220 | goto end ; | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | |||
225 | end:; | ||
226 | /* Return. */ | ||
227 | { | ||
228 | int i=0; | ||
229 | out = fMallocHandle(1, maxIter); | ||
230 | |||
231 | for(i=0; i<maxIter; i++) | ||
232 | asubsref(out,i) = maxima_iterator[i] ; | ||
233 | } | ||
234 | |||
235 | /* Release space. */ | ||
236 | free(neighbors) ; | ||
237 | free(maxima_start); | ||
238 | |||
239 | return out; | ||
240 | } | ||
241 | |||
242 | |||
243 | |||
244 | |||
245 | |||
246 | |||
247 | |||
diff --git a/SD-VBS/benchmarks/sift/src/c/siftrefinemx.c b/SD-VBS/benchmarks/sift/src/c/siftrefinemx.c new file mode 100644 index 0000000..2b10e9d --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/c/siftrefinemx.c | |||
@@ -0,0 +1,196 @@ | |||
1 | #include "sift.h" | ||
2 | |||
3 | const int max_iter = 5 ; | ||
4 | |||
5 | /** | ||
6 | |||
7 | SIFTREFINEMX Subpixel localization, thresholding and on-edge test | ||
8 | Q = SIFTREFINEMX(P, OCTAVE, SMIN) refines, thresholds and performs | ||
9 | the on-edge test for the SIFT frames P extracted from the DOG | ||
10 | octave OCTAVE with parameter SMIN (see GAUSSIANSS()). | ||
11 | |||
12 | Q = SIFTREFINEMX(P, OCTAVE, SMIN, THRESH, R) specifies custom | ||
13 | values for the local maximum strength threshold THRESH and the | ||
14 | local maximum peakedeness threshold R. | ||
15 | |||
16 | OCTAVE is an octave of the Difference Of Gaussian scale space. P | ||
17 | is a 3xK matrix specifying the indexes (X,Y,S) of the points of | ||
18 | extremum of the octave OCTAVE. The spatial indexes X,Y are integer | ||
19 | with base zero. The scale index S is integer with base SMIN and | ||
20 | represents a scale sublevel in the specified octave. | ||
21 | |||
22 | The function returns a matrix Q containing the refined keypoints. | ||
23 | The matrix has the same format as P, except that the indexes are | ||
24 | now fractional. The function drops the points that do not satisfy | ||
25 | the strength and peakedness tests. | ||
26 | |||
27 | **/ | ||
28 | |||
29 | F2D* siftrefinemx(F2D* oframes, F2D* dogss, int smin, float thresh, int r, int M, int N, int intervals) | ||
30 | { | ||
31 | int S,K ; | ||
32 | F2D* out; | ||
33 | |||
34 | /* ----------------------------------------------------------------- | ||
35 | ** Check the arguments | ||
36 | ** -------------------------------------------------------------- */ | ||
37 | |||
38 | S = intervals; | ||
39 | K = oframes->height; | ||
40 | |||
41 | /* If the input array is empty, then output an empty array as well. */ | ||
42 | if( K == 0) { | ||
43 | out = fDeepCopy(oframes); | ||
44 | return out; | ||
45 | } | ||
46 | |||
47 | /* ----------------------------------------------------------------- | ||
48 | * Do the job | ||
49 | * -------------------------------------------------------------- */ | ||
50 | { | ||
51 | F2D* buffer = fMallocHandle(K,3); | ||
52 | int p ; | ||
53 | const int yo = 1 ; | ||
54 | const int xo = M ; | ||
55 | const int so = M*N; | ||
56 | int buffCounter = 0; | ||
57 | int pptcount = 0; | ||
58 | |||
59 | for(p = 0 ; p < K ; ++p) | ||
60 | { | ||
61 | float tx, ty, ts; | ||
62 | int x,y,s; | ||
63 | int iter ; | ||
64 | float b[3] ; | ||
65 | |||
66 | tx = asubsref(oframes, pptcount++); | ||
67 | ty = asubsref(oframes, pptcount++); | ||
68 | ts = asubsref(oframes, pptcount++); | ||
69 | |||
70 | x = ceil(tx); | ||
71 | y = ceil(ty); | ||
72 | s = ceil(ts) - smin; | ||
73 | |||
74 | |||
75 | /* Local maxima extracted from the DOG | ||
76 | * have coorrinates 1<=x<=N-2, 1<=y<=M-2 | ||
77 | * and 1<=s-mins<=S-2. This is also the range of the points | ||
78 | * that we can refine. | ||
79 | */ | ||
80 | |||
81 | if(x < 1 || x > N-2 || | ||
82 | y < 1 || y > M-2 || | ||
83 | s < 1 || s > S-2) { | ||
84 | continue ; | ||
85 | } | ||
86 | |||
87 | #define at(dx,dy,ds) asubsref(dogss, (dx)*xo + (dy)*yo + (ds)*so) | ||
88 | |||
89 | { | ||
90 | float Dx=0,Dy=0,Ds=0,Dxx=0,Dyy=0,Dss=0,Dxy=0,Dxs=0,Dys=0 ; | ||
91 | int dx = 0 ; | ||
92 | int dy = 0 ; | ||
93 | |||
94 | for(iter = 0 ; iter < max_iter ; ++iter) | ||
95 | { | ||
96 | |||
97 | float A[3*3] ; | ||
98 | |||
99 | #define Aat(i,j) (A[(i)+(j)*3]) | ||
100 | |||
101 | x += dx ; | ||
102 | y += dy ; | ||
103 | |||
104 | /* Compute the gradient. */ | ||
105 | Dx = 0.5 * (at(x+1,y+0,s+0) - at(x-1,y+0,s+0)) ; | ||
106 | Dy = 0.5 * (at(x+0,y+1,s+0) - at(x+0,y-1,s+0)); | ||
107 | Ds = 0.5 * (at(x+0,y+0,s+1) - at(x+0,y+0,s-1)) ; | ||
108 | |||
109 | /* Compute the Hessian. */ | ||
110 | Dxx = (at(x+1,y,s) + at(x-1,y,s) - 2.0 * at(x,y,s)) ; | ||
111 | Dyy = (at(x,y+1,s) + at(x,y-1,s) - 2.0 * at(x,y,s)) ; | ||
112 | Dss = (at(x,y,s+1) + at(x,y,s-1) - 2.0 * at(x,y,s)) ; | ||
113 | |||
114 | Dxy = 0.25 * ( at(x+1,y+1,s) + at(x-1,y-1,s) - at(x-1,y+1,s) - at(x+1,y-1,s) ) ; | ||
115 | Dxs = 0.25 * ( at(x+1,y,s+1) + at(x-1,y,s-1) - at(x-1,y,s+1) - at(x+1,y,s-1) ) ; | ||
116 | Dys = 0.25 * ( at(x,y+1,s+1) + at(x,y-1,s-1) - at(x,y-1,s+1) - at(x,y+1,s-1) ) ; | ||
117 | |||
118 | /* Solve linear system. */ | ||
119 | Aat(0,0) = Dxx ; | ||
120 | Aat(1,1) = Dyy ; | ||
121 | Aat(2,2) = Dss ; | ||
122 | Aat(0,1) = Aat(1,0) = Dxy ; | ||
123 | Aat(0,2) = Aat(2,0) = Dxs ; | ||
124 | Aat(1,2) = Aat(2,1) = Dys ; | ||
125 | |||
126 | b[0] = - Dx ; | ||
127 | b[1] = - Dy ; | ||
128 | b[2] = - Ds ; | ||
129 | |||
130 | /* If the translation of the keypoint is big, move the keypoint | ||
131 | * and re-iterate the computation. Otherwise we are all set. | ||
132 | */ | ||
133 | dx= ((b[0] > 0.6 && x < N-2) ? 1 : 0 ) | ||
134 | + ((b[0] < -0.6 && x > 1 ) ? -1 : 0 ) ; | ||
135 | |||
136 | dy= ((b[1] > 0.6 && y < M-2) ? 1 : 0 ) | ||
137 | + ((b[1] < -0.6 && y > 1 ) ? -1 : 0 ) ; | ||
138 | |||
139 | if( dx == 0 && dy == 0 ) | ||
140 | break ; | ||
141 | |||
142 | } | ||
143 | |||
144 | { | ||
145 | float val = at(x,y,s) + 0.5 * (Dx * b[0] + Dy * b[1] + Ds * b[2]) ; | ||
146 | float score = (Dxx+Dyy)*(Dxx+Dyy) / (Dxx*Dyy - Dxy*Dxy) ; | ||
147 | float xn = x + b[0] ; | ||
148 | float yn = y + b[1] ; | ||
149 | float sn = s + b[2] ; | ||
150 | |||
151 | if(fabs(val) > thresh && | ||
152 | score < (r+1)*(r+1)/r && | ||
153 | score >= 0 && | ||
154 | fabs(b[0]) < 1.5 && | ||
155 | fabs(b[1]) < 1.5 && | ||
156 | fabs(b[2]) < 1.5 && | ||
157 | xn >= 0 && | ||
158 | xn <= N-1 && | ||
159 | yn >= 0 && | ||
160 | yn <= M-1 && | ||
161 | sn >= 0 && | ||
162 | sn <= S-1) | ||
163 | { | ||
164 | asubsref(buffer,buffCounter++) = xn ; | ||
165 | asubsref(buffer,buffCounter++) = yn ; | ||
166 | asubsref(buffer,buffCounter++) = sn+smin ; | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | } | ||
171 | |||
172 | /* Copy the result into an array. */ | ||
173 | { | ||
174 | int i, j, k=0; | ||
175 | int NL = buffCounter/3; | ||
176 | out = fMallocHandle(3, NL); | ||
177 | |||
178 | for(i=0; i<NL; i++) | ||
179 | { | ||
180 | for(j=0; j<3; j++) | ||
181 | { | ||
182 | subsref(out,j,i) = asubsref(buffer,k); | ||
183 | k++; | ||
184 | } | ||
185 | } | ||
186 | } | ||
187 | free(buffer) ; | ||
188 | } | ||
189 | |||
190 | return out; | ||
191 | } | ||
192 | |||
193 | |||
194 | |||
195 | |||
196 | |||
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 @@ | |||
1 | function 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 | |||
50 | dss.smin = ss.smin ; | ||
51 | dss.smax = ss.smax-1 ; | ||
52 | dss.omin = ss.omin ; | ||
53 | dss.O = ss.O ; | ||
54 | dss.S = ss.S ; | ||
55 | dss.sigma0 = ss.sigma0 ; | ||
56 | |||
57 | for 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 | ||
66 | end | ||
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 @@ | |||
1 | function 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 | ||
60 | k = 2^(1/S) ; | ||
61 | |||
62 | dsigma0 = sigma0 * sqrt(1 - 1/k^2) ; % Scale step factor | ||
63 | sigman = 0.5 ; % Nominal smoothing of the image | ||
64 | |||
65 | % Scale space structure | ||
66 | SS.O = O ; | ||
67 | SS.S = S ; | ||
68 | SS.sigma0 = sigma0 ; | ||
69 | SS.omin = omin ; | ||
70 | SS.smin = smin ; | ||
71 | SS.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 | |||
77 | if omin < 0 | ||
78 | for o=1:-omin | ||
79 | I = doubleSize(I) ; | ||
80 | end | ||
81 | elseif omin > 0 | ||
82 | for o=1:omin | ||
83 | I = halveSize(I) ; | ||
84 | end | ||
85 | end | ||
86 | |||
87 | [M,N] = size(I) ; | ||
88 | |||
89 | % Index offset | ||
90 | so = -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 | |||
113 | SS.octave{1} = zeros(M,N,smax-smin+1) ; | ||
114 | SS.octave{1}(:,:,1) = imsmooth(I, ... | ||
115 | sqrt((sigma0*k^smin)^2 - (sigman/2^omin)^2)) ; | ||
116 | |||
117 | temp = sqrt((sigma0*k^smin)^2 - (sigman/2^omin)^2) ; | ||
118 | |||
119 | for 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 ) ; | ||
136 | end | ||
137 | |||
138 | % -------------------------------------------------------------------- | ||
139 | % Other octaves | ||
140 | % -------------------------------------------------------------------- | ||
141 | |||
142 | for 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 | |||
189 | end | ||
190 | |||
191 | % ------------------------------------------------------------------------- | ||
192 | % Auxiliary functions | ||
193 | % ------------------------------------------------------------------------- | ||
194 | function J = doubleSize(I) | ||
195 | [M,N]=size(I) ; | ||
196 | J = zeros(2*M,2*N) ; | ||
197 | J(1:2:end,1:2:end) = I ; | ||
198 | J(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) ; | ||
203 | J(2:2:end-1,1:2:end) = ... | ||
204 | 0.5*I(1:end-1,:) + ... | ||
205 | 0.5*I(2:end,:) ; | ||
206 | J(1:2:end,2:2:end-1) = ... | ||
207 | 0.5*I(:,1:end-1) + ... | ||
208 | 0.5*I(:,2:end) ; | ||
209 | |||
210 | function J = halveSize(I) | ||
211 | J=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 @@ | |||
1 | function 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 | |||
46 | I=im2double(imread(file)) ; | ||
47 | |||
48 | if(size(I,3) > 1) | ||
49 | I = rgb2gray( I ) ; | ||
50 | end | ||
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 | |||
16 | const double win_factor = 1.5 ; | ||
17 | const int nbins = 36 ; | ||
18 | |||
19 | void | ||
20 | mexFunction(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 | |||
10 | const double win_factor = 1.5 ; | ||
11 | const int nbins = 36 ; | ||
12 | |||
13 | float* 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 | **/ | ||
16 | int | ||
17 | uIsRealScalar(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 | **/ | ||
38 | int | ||
39 | uIsRealMatrix(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 | **/ | ||
59 | int | ||
60 | uIsRealVector(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 | **/ | ||
83 | int | ||
84 | uIsString(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 @@ | |||
1 | function 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 | |||
70 | stack='h' ; | ||
71 | |||
72 | for k=1:2:length(varargin) | ||
73 | switch varargin{k} | ||
74 | case 'Stacking' | ||
75 | stack=varargin{k+1} ; | ||
76 | end | ||
77 | end | ||
78 | |||
79 | % -------------------------------------------------------------------- | ||
80 | % Do the job | ||
81 | % -------------------------------------------------------------------- | ||
82 | |||
83 | [M1,N1,K1]=size(I1) ; | ||
84 | [M2,N2,K2]=size(I2) ; | ||
85 | |||
86 | switch 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; | ||
107 | end | ||
108 | |||
109 | I=zeros(M3,N3,K1) ; | ||
110 | I(1:M1,1:N1,:) = I1 ; | ||
111 | I(oi+(1:M2),oj+(1:N2),:) = I2 ; | ||
112 | |||
113 | axes('Position', [0 0 1 1]) ; | ||
114 | imagesc(I) ; colormap gray ; hold on ; axis image ; axis off ; | ||
115 | drawnow ; | ||
116 | |||
117 | K = size(matches, 2) ; | ||
118 | nans = NaN * ones(1,K) ; | ||
119 | |||
120 | x = [ P1(1,matches(1,:)) ; P2(1,matches(2,:))+oj ; nans ] ; | ||
121 | y = [ P1(2,matches(1,:)) ; P2(2,matches(2,:))+oi ; nans ] ; | ||
122 | |||
123 | h = line(x(:)', y(:)') ; | ||
124 | set(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 @@ | |||
1 | function 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 | |||
57 | lowe_compatible = 1 ; | ||
58 | |||
59 | % -------------------------------------------------------------------- | ||
60 | % Check the arguments | ||
61 | % -------------------------------------------------------------------- | ||
62 | |||
63 | if(size(d,1) ~= 128) | ||
64 | error('D should be a 128xK matrix (only standard descriptors accepted)') ; | ||
65 | end | ||
66 | |||
67 | if 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 | ||
75 | end | ||
76 | |||
77 | % Descriptors are often non-double numeric arrays | ||
78 | d = double(d) ; | ||
79 | K = size(d,2) ; | ||
80 | if nargin < 2 | ||
81 | f = repmat([0;0;1;0],1,K) ; | ||
82 | end | ||
83 | |||
84 | maginf = 3.0 ; | ||
85 | NBP=4 ; | ||
86 | NBO=8 ; | ||
87 | |||
88 | % -------------------------------------------------------------------- | ||
89 | % Do the job | ||
90 | % -------------------------------------------------------------------- | ||
91 | |||
92 | xall=[] ; | ||
93 | yall=[] ; | ||
94 | |||
95 | for 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)] ; | ||
104 | end | ||
105 | |||
106 | h=line(xall,yall) ; | ||
107 | |||
108 | % -------------------------------------------------------------------- | ||
109 | % Helper functions | ||
110 | % -------------------------------------------------------------------- | ||
111 | |||
112 | % Renders a single descriptor | ||
113 | function [x,y] = render_descr( d ) | ||
114 | |||
115 | lowe_compatible=1; | ||
116 | NBP=4 ; | ||
117 | NBO=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 | ||
122 | d = 0.4 * d / max(d(:)) ; | ||
123 | |||
124 | % We have NBP*NBP bins to plot. Here are the centers: | ||
125 | xc = x(1:end-1,1:end-1) + 0.5 ; | ||
126 | yc = 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.) | ||
130 | xc = xc' ; | ||
131 | yc = yc' ; | ||
132 | |||
133 | % Each bin contains a star with eight tips | ||
134 | xc = repmat(xc(:)',NBO,1) ; | ||
135 | yc = repmat(yc(:)',NBO,1) ; | ||
136 | |||
137 | % Do the stars | ||
138 | th=linspace(0,2*pi,NBO+1) ; | ||
139 | th=th(1:end-1) ; | ||
140 | if lowe_compatible | ||
141 | xd = repmat(cos(-th), 1, NBP*NBP ) ; | ||
142 | yd = repmat(sin(-th), 1, NBP*NBP ) ; | ||
143 | else | ||
144 | xd = repmat(cos(th), 1, NBP*NBP ) ; | ||
145 | yd = repmat(sin(th), 1, NBP*NBP ) ; | ||
146 | end | ||
147 | xd = xd .* d(:)' ; | ||
148 | yd = yd .* d(:)' ; | ||
149 | |||
150 | % Re-arrange in sequential order the lines to draw | ||
151 | nans = NaN * ones(1,NBP^2*NBO) ; | ||
152 | x1 = xc(:)' ; | ||
153 | y1 = yc(:)' ; | ||
154 | x2 = x1 + xd ; | ||
155 | y2 = y1 + yd ; | ||
156 | xstars = [x1;x2;nans] ; | ||
157 | ystars = [y1;y2;nans] ; | ||
158 | |||
159 | % Horizontal lines of the grid | ||
160 | nans = NaN * ones(1,NBP+1); | ||
161 | xh = [x(:,1)' ; x(:,end)' ; nans] ; | ||
162 | yh = [y(:,1)' ; y(:,end)' ; nans] ; | ||
163 | |||
164 | % Verical lines of the grid | ||
165 | xv = [x(1,:) ; x(end,:) ; nans] ; | ||
166 | yv = [y(1,:) ; y(end,:) ; nans] ; | ||
167 | |||
168 | x=[xstars(:)' xh(:)' xv(:)'] ; | ||
169 | y=[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 @@ | |||
1 | function 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 | |||
68 | if size(frames,1) ~= 4 | ||
69 | error('FRAMES should be a 4xK matrix') ; | ||
70 | end | ||
71 | |||
72 | K = size(frames,2) ; | ||
73 | |||
74 | if nargin > 1 | ||
75 | putlabels = 1 ; | ||
76 | end | ||
77 | |||
78 | % -------------------------------------------------------------------- | ||
79 | % Do the work | ||
80 | % -------------------------------------------------------------------- | ||
81 | |||
82 | hold on ; | ||
83 | K=size(frames,2) ; | ||
84 | thr=linspace(0,2*pi,40) ; | ||
85 | |||
86 | allx = nan*ones(1, 40*K+(K-1)) ; | ||
87 | ally = nan*ones(1, 40*K+(K-1)) ; | ||
88 | |||
89 | allxf = nan*ones(1, 3*K) ; | ||
90 | allyf = nan*ones(1, 3*K) ; | ||
91 | |||
92 | putlabel=0 ; | ||
93 | |||
94 | for 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 | |||
117 | end | ||
118 | |||
119 | h=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 @@ | |||
1 | function 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 | |||
46 | if nargin > 2 | ||
47 | error('Too many arguments.') ; | ||
48 | end | ||
49 | |||
50 | omin = ss.omin ; | ||
51 | smin = ss.smin ; | ||
52 | nlevels = ss.smax-ss.smin+1 ; | ||
53 | |||
54 | for 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 | ||
66 | end | ||
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 @@ | |||
1 | function script_run_profile(dataDir, resultDir, type, common, tooldir) | ||
2 | |||
3 | path(path,common); | ||
4 | sift_compile; | ||
5 | |||
6 | I1=readImage([dataDir, '/1.bmp']) ; | ||
7 | |||
8 | rows = size(I1,1); | ||
9 | cols = size(I1,2); | ||
10 | fprintf(1,'Input size\t\t- (%dx%d)\n', rows, cols); | ||
11 | |||
12 | I1=I1-min(I1(:)) ; | ||
13 | I1=I1/max(I1(:)) ; | ||
14 | |||
15 | %% Timing | ||
16 | start = photonStartTiming; | ||
17 | frames1 = sift( I1) ; | ||
18 | stop = photonEndTiming; | ||
19 | elapsed = photonReportTiming(start, stop); | ||
20 | photonPrintTiming(elapsed); | ||
21 | |||
22 | fWriteMatrix(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 | |||
15 | function [frames]=sift(I) | ||
16 | |||
17 | [M,N,C] = size(I) ; | ||
18 | |||
19 | % Lowe's choices | ||
20 | S=3 ; | ||
21 | omin=-1 ; | ||
22 | O=floor(log2(min(M,N)))-omin-4 ; % Up to 16x16 images | ||
23 | sigma0=1.6*2^(1/S) ; | ||
24 | sigman=0.5 ; | ||
25 | thresh = 0.04 / S / 2 ; | ||
26 | r = 10 ; | ||
27 | |||
28 | NBP = 4 ; | ||
29 | NBO = 8 ; | ||
30 | magnif = 3.0 ; | ||
31 | |||
32 | % Parese input | ||
33 | compute_descriptor = 0 ; | ||
34 | discard_boundary_points = 1 ; | ||
35 | verb = 0 ; | ||
36 | |||
37 | smin = -1; | ||
38 | smax = S+1; | ||
39 | intervals = smax - smin + 1; | ||
40 | |||
41 | |||
42 | % -------------------------------------------------------------------- | ||
43 | % Parameters | ||
44 | % -------------------------------------------------------------------- | ||
45 | |||
46 | oframes = [] ; | ||
47 | frames = [] ; | ||
48 | descriptors = [] ; | ||
49 | |||
50 | % -------------------------------------------------------------------- | ||
51 | % SIFT Detector and Descriptor | ||
52 | % -------------------------------------------------------------------- | ||
53 | |||
54 | % Compute scale spaces | ||
55 | %if verb > 0, fprintf('SIFT: computing scale space...') ; end | ||
56 | |||
57 | gss = gaussianss(I,sigman,O,S,omin,-1,S+1,sigma0) ; | ||
58 | dogss = diffss(gss) ; | ||
59 | frames = []; | ||
60 | |||
61 | %% To maintain consistency with C code. Once C code is ready, this will be uncommented. | ||
62 | for 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 | |||
95 | end | ||
96 | end | ||
97 | |||
98 | %% -------------------------------------------------------------------- | ||
99 | %% Helpers | ||
100 | %% -------------------------------------------------------------------- | ||
101 | function oframes=filter_boundary_points(sz, oframes) | ||
102 | |||
103 | sel=find(... | ||
104 | oframes(1,:) > 3 & ... | ||
105 | oframes(1,:) < sz(2)-3 & ... | ||
106 | oframes(2,:) > 3 & ... | ||
107 | oframes(2,:) < sz(1)-3 ) ; | ||
108 | |||
109 | oframes=oframes(:,sel) ; | ||
110 | end | ||
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 @@ | |||
1 | function 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 | |||
7 | siftroot = fileparts(which('siftcompile')) ; | ||
8 | opts = { '-O', '-I.' } ; | ||
9 | %opts = { opts{:}, '-v' } ; | ||
10 | |||
11 | if nargin < 1 | ||
12 | type = 'visualc' ; | ||
13 | end | ||
14 | |||
15 | switch 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.']) ; | ||
49 | end | ||
50 | |||
51 | mex('imsmooth.c',opts{:}) ; | ||
52 | mex('siftlocalmax.c',opts{:}) ; | ||
53 | mex('siftrefinemx.c',opts{:}) ; | ||
54 | mex('siftormx.c',opts{:}) ; | ||
55 | mex('siftdescriptor.c',opts{:}) ; | ||
56 | mex('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 @@ | |||
1 | cd % 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 | |||
45 | I1=imreadbw('data/landscape-a.jpg') ; % I1=I1(1:2:end,:) ; | ||
46 | I2=imreadbw('data/landscape-b.jpg') ; % I2=I2(1:2:end,:) ; | ||
47 | I1c=double(imread('data/landscape-a.jpg'))/255.0 ; | ||
48 | I2c=double(imread('data/landscape-b.jpg'))/255.0 ; | ||
49 | |||
50 | I1=imsmooth(I1,.1) ; | ||
51 | I2=imsmooth(I2,.1) ; | ||
52 | |||
53 | I1=I1-min(I1(:)) ; | ||
54 | I1=I1/max(I1(:)) ; | ||
55 | I2=I2-min(I2(:)) ; | ||
56 | I2=I2/max(I2(:)) ; | ||
57 | |||
58 | S=3 ; | ||
59 | |||
60 | fprintf('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 | |||
66 | figure(11) ; clf ; plotss(dogss1) ; colormap gray ; | ||
67 | figure(12) ; clf ; plotss(dogss2) ; colormap gray ; | ||
68 | drawnow ; | ||
69 | |||
70 | figure(2) ; clf ; | ||
71 | tightsubplot(1,2,1) ; imagesc(I1) ; colormap gray ; axis image ; | ||
72 | hold on ; | ||
73 | h=plotsiftframe( frames1 ) ; set(h,'LineWidth',2,'Color','g') ; | ||
74 | h=plotsiftframe( frames1 ) ; set(h,'LineWidth',1,'Color','k') ; | ||
75 | |||
76 | tightsubplot(1,2,2) ; imagesc(I2) ; colormap gray ; axis image ; | ||
77 | hold on ; | ||
78 | h=plotsiftframe( frames2 ) ; set(h,'LineWidth',2,'Color','g') ; | ||
79 | h=plotsiftframe( frames2 ) ; set(h,'LineWidth',1,'Color','k') ; | ||
80 | |||
81 | fprintf('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) | ||
85 | descr1=uint8(512*descr1) ; | ||
86 | descr2=uint8(512*descr2) ; | ||
87 | tic ; | ||
88 | matches=siftmatch( descr1, descr2, 3 ) ; | ||
89 | fprintf('Matched in %.3f s\n', toc) ; | ||
90 | |||
91 | figure(3) ; clf ; | ||
92 | plotmatches(I1c,I2c,frames1(1:2,:),frames2(1:2,:),matches,... | ||
93 | 'Stacking','v') ; | ||
94 | drawnow ; | ||
95 | |||
96 | % Movie | ||
97 | figure(4) ; set(gcf,'Position',[10 10 1024 512]) ; | ||
98 | figure(4) ; clf ; | ||
99 | tightsubplot(1,1); | ||
100 | imagesc(I1) ; colormap gray ; axis image ; hold on ; | ||
101 | h=plotsiftframe( frames1 ) ; set(h,'LineWidth',1,'Color','g') ; | ||
102 | h=plot(frames1(1,:),frames1(2,:),'r.') ; | ||
103 | MOV(1)=getframe ; | ||
104 | |||
105 | figure(4) ; clf ; | ||
106 | tightsubplot(1,1); | ||
107 | imagesc(I2) ; colormap gray ; axis image ; hold on ; | ||
108 | h=plotsiftframe( frames2 ) ; set(h,'LineWidth',1,'Color','g') ; | ||
109 | h=plot(frames2(1,:),frames2(2,:),'r.') ; | ||
110 | MOV(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 | |||
8 | h1 | ||
9 | { | ||
10 | color: #3a3a3a ; | ||
11 | } | ||
12 | |||
13 | pre | ||
14 | { | ||
15 | font-family: monaco, courier, monospace ; | ||
16 | font-size: 14px ; | ||
17 | color: #3a3a3a ; | ||
18 | } | ||
19 | |||
20 | body | ||
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 | |||
35 | div.module | ||
36 | { | ||
37 | margin-bottom: 1em ; | ||
38 | //background-color: #ffffff ; | ||
39 | } | ||
40 | |||
41 | div.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 | |||
50 | div.module pre | ||
51 | { | ||
52 | padding-left: 1em ; | ||
53 | } | ||
54 | |||
55 | div.module div.footer | ||
56 | { | ||
57 | clear: both ; | ||
58 | } | ||
59 | |||
60 | div.module div.footer :link | ||
61 | { | ||
62 | color: white ; | ||
63 | text-decoration: none ; | ||
64 | } | ||
65 | |||
66 | /* ------------------------------------------------------------------ | ||
67 | * Module index | ||
68 | * --------------------------------------------------------------- */ | ||
69 | |||
70 | div.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 | |||
81 | div.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 | |||
91 | div.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 | |||
101 | div.module div.index ul li | ||
102 | { | ||
103 | margin-bottom: 0.1em ; | ||
104 | } | ||
105 | |||
106 | |||
107 | /* ------------------------------------------------------------------ | ||
108 | * Mfile | ||
109 | * --------------------------------------------------------------- */ | ||
110 | |||
111 | div.mfile | ||
112 | { | ||
113 | background-color: white ; | ||
114 | margin-bottom: 1em ; | ||
115 | border: 1px #aaaaaa solid ; | ||
116 | } | ||
117 | |||
118 | div.mfile h1 | ||
119 | { | ||
120 | margin: 0 ; | ||
121 | padding: 0 ; | ||
122 | padding-left: 10px ; | ||
123 | font-size: 1.3em ; | ||
124 | background-color: #f0f0ff ; | ||
125 | } | ||
126 | |||
127 | div.mfile h1 span.name | ||
128 | { | ||
129 | font-family: monaco, courier, fixed ; | ||
130 | } | ||
131 | |||
132 | div.mfile h1 span.brief | ||
133 | { | ||
134 | padding-left: 10px ; | ||
135 | font-size: 0.9em ; | ||
136 | font-weight: normal ; | ||
137 | } | ||
138 | |||
139 | div.mfile pre | ||
140 | { | ||
141 | padding-left: 1em ; | ||
142 | } | ||
143 | |||
144 | div.mfile div.footer | ||
145 | { | ||
146 | font-size: 0.8em ; | ||
147 | padding: 0.3em ; | ||
148 | } | ||
149 | |||
150 | div.mfile div.footer a | ||
151 | { | ||
152 | text-decoration: none ; | ||
153 | color: #777777 ; | ||
154 | } | ||
155 | |||
156 | div.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 @@ | |||
1 | function 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 | |||
45 | rootdir = fileparts(which('siftgendoc')) ; | ||
46 | d=pwd; | ||
47 | cd([rootdir]) ; | ||
48 | res = perl([rootdir '/siftgendoc.pl'],[rootdir '/dom/index.html']) ; | ||
49 | cd(d) ; | ||
50 | fprintf(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 | ||
62 | if ($#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 | |||
73 | while ($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 | |||
154 | print FOUT <<EOF; | ||
155 | <html> | ||
156 | <head> | ||
157 | <link href="default.css" rel="stylesheet" type="text/css"/> | ||
158 | </head> | ||
159 | <body> | ||
160 | EOF | ||
161 | |||
162 | # sort modules by path | ||
163 | sub criterion { $modules{$a}->{'path'} cmp $modules{$b}->{'path'} ; } | ||
164 | |||
165 | MODULE: | ||
166 | foreach $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> | ||
178 | EOF | ||
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> | ||
192 | EOF | ||
193 | } | ||
194 | |||
195 | foreach $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> | ||
214 | EOF | ||
215 | } | ||
216 | |||
217 | print FOUT "</body></html>" ; | ||
218 | |||
219 | # Close file | ||
220 | close FOUT ; | ||
221 | |||
222 | |||
223 | # ------------------------------------------------------------------------- | ||
224 | sub 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 | # ------------------------------------------------------------------------- | ||
250 | sub 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 | # ------------------------------------------------------------------------- | ||
259 | sub 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 | # ------------------------------------------------------------------------- | ||
286 | sub 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 | ||
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 | |||
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> | ||
78 | typedef 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 | |||
90 | enum {SCALESPACE, NOSCALESPACE} ; | ||
91 | |||
92 | enum {PROP_MAGNIF=0, | ||
93 | PROP_NBP, | ||
94 | PROP_NBO, | ||
95 | PROP_UNKNOWN} ; | ||
96 | |||
97 | char const * properties [4] = | ||
98 | { "Magnif", | ||
99 | "NumSpatialBins", | ||
100 | "NumOrientBins", | ||
101 | 0L | ||
102 | } ; | ||
103 | |||
104 | /** Fast fmodf for 2*PI | ||
105 | **/ | ||
106 | /*inline*/ | ||
107 | float 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*/ | ||
117 | int fast_floor(float x) | ||
118 | { | ||
119 | return (int)( x - ((x>=0)?0:1) ) ; | ||
120 | } | ||
121 | |||
122 | /** Normalizes in norm L_2 a descriptor. | ||
123 | **/ | ||
124 | void | ||
125 | normalize_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 | **/ | ||
142 | void | ||
143 | mexFunction(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 | ||
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 | |||
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 | |||
54 | void | ||
55 | mexFunction(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 | |||
84 | if(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 | ||
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 | |||
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 | |||
71 | typedef 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 | |||
139 | void | ||
140 | mexFunction(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 | ||
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 | |||
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 | |||
57 | const double win_factor = 1.5 ; | ||
58 | #define NBINS 36 | ||
59 | |||
60 | void | ||
61 | mexFunction(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 @@ | |||
1 | function [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 | |||
54 | verbosity=0 ; | ||
55 | |||
56 | g = fopen(file, 'r'); | ||
57 | if g == -1 | ||
58 | error(['Could not open file ''', file, '''.']) ; | ||
59 | end | ||
60 | [header, count] = fscanf(g, '%d', [1 2]) ; | ||
61 | if count ~= 2 | ||
62 | error('Invalid keypoint file header.'); | ||
63 | end | ||
64 | K = header(1) ; | ||
65 | DL = header(2) ; | ||
66 | |||
67 | if(verbosity > 0) | ||
68 | fprintf('%d keypoints, %d descriptor length.\n', K, DL) ; | ||
69 | end | ||
70 | |||
71 | %creates two output matrices | ||
72 | P = zeros(4,K) ; | ||
73 | L = zeros(DL,K) ; | ||
74 | |||
75 | %parse tmp.key | ||
76 | for 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 | |||
94 | end | ||
95 | fclose(g) ; | ||
96 | |||
97 | L=double(L) ; | ||
98 | P(1:2,:)=flipud(P(1:2,:)) ; % i,j -> x,y | ||
99 | |||
100 | frames=[ P(1:2,:) ; P(3,:) ; -P(4,:) ] ; | ||
101 | descriptors = 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 | |||
3 | Benchmark - sift | ||
4 | Data 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 | |||
15 | Warning: 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 | ||
18 | Warning: You are using gcc version "4.1.1". The earliest gcc version supported | ||
19 | with mex is "3.4.0". The latest version tested for use with mex is "3.4.5". | ||
20 | To download a different version of gcc, visit http://gcc.gnu.org | ||
21 | Warning: You are using gcc version "4.1.1". The earliest gcc version supported | ||
22 | with mex is "3.4.0". The latest version tested for use with mex is "3.4.5". | ||
23 | To download a different version of gcc, visit http://gcc.gnu.org | ||
24 | Warning: You are using gcc version "4.1.1". The earliest gcc version supported | ||
25 | with mex is "3.4.0". The latest version tested for use with mex is "3.4.5". | ||
26 | To download a different version of gcc, visit http://gcc.gnu.org | ||
27 | Warning: You are using gcc version "4.1.1". The earliest gcc version supported | ||
28 | with mex is "3.4.0". The latest version tested for use with mex is "3.4.5". | ||
29 | To download a different version of gcc, visit http://gcc.gnu.org | ||
30 | Warning: You are using gcc version "4.1.1". The earliest gcc version supported | ||
31 | with mex is "3.4.0". The latest version tested for use with mex is "3.4.5". | ||
32 | To download a different version of gcc, visit http://gcc.gnu.org | ||
33 | Warning: You are using gcc version "4.1.1". The earliest gcc version supported | ||
34 | with mex is "3.4.0". The latest version tested for use with mex is "3.4.5". | ||
35 | To download a different version of gcc, visit http://gcc.gnu.org | ||
36 | Input size - (96x96) | ||
37 | ** author: Andrea Vedaldi | ||
38 | ** description: Subpixel localization, thresholding and off-edge test. | ||
39 | **/ | ||
40 | |||
41 | /* AUTORIGHTS | ||
42 | Copyright (c) 2006 The Regents of the University of California. | ||
43 | All Rights Reserved. | ||
44 | |||
45 | Created by Andrea Vedaldi | ||
46 | UCLA Vision Lab - Department of Computer Science | ||
47 | |||
48 | Permission to use, copy, modify, and distribute this software and its | ||
49 | documentation for educational, research and non-profit purposes, | ||
50 | without fee, and without a written agreement is hereby granted, | ||
51 | provided that the above copyright notice, this paragraph and the | ||
52 | following three paragraphs appear in all copies. | ||
53 | |||
54 | This software program and documentation are copyrighted by The Regents | ||
55 | of the University of California. The software program and | ||
56 | documentation are supplied "as is", without any accompanying services | ||
57 | from The Regents. The Regents does not warrant that the operation of | ||
58 | the program will be uninterrupted or error-free. The end-user | ||
59 | understands that the program was developed for research purposes and | ||
60 | is advised not to rely exclusively on the program for any reason. | ||
61 | |||
62 | This software embodies a method for which the following patent has | ||
63 | been issued: "Method and apparatus for identifying scale invariant | ||
64 | features in an image and use of same for locating an object in an | ||
65 | image," David G. Lowe, US Patent 6,711,293 (March 23, | ||
66 | 2004). Provisional application filed March 8, 1999. Asignee: The | ||
67 | University of British Columbia. | ||
68 | |||
69 | IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY | ||
70 | FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, | ||
71 | INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND | ||
72 | ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN | ||
73 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF | ||
74 | CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT | ||
75 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
76 | A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" | ||
77 | BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE | ||
78 | MAINTENANCE, 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__ | ||
99 | extern "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 | ||
111 | extern 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 | |||
119 | const int max_iter = 5 ; | ||
120 | |||
121 | void | ||
122 | mexFunction(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 @@ | |||
1 | function 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 | |||
69 | sp=0.0 ; | ||
70 | use_outer=0 ; | ||
71 | |||
72 | % -------------------------------------------------------------------- | ||
73 | % Parse arguments | ||
74 | % -------------------------------------------------------------------- | ||
75 | K=varargin{1} ; | ||
76 | p=varargin{2} ; | ||
77 | N = ceil(sqrt(K)) ; | ||
78 | M = ceil(K/N) ; | ||
79 | |||
80 | a=3 ; | ||
81 | NA = length(varargin) ; | ||
82 | if 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 | ||
92 | end | ||
93 | |||
94 | for 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 | ||
114 | end | ||
115 | |||
116 | % -------------------------------------------------------------------- | ||
117 | % Check the arguments | ||
118 | % -------------------------------------------------------------------- | ||
119 | |||
120 | [j,i]=ind2sub([N M],p) ; | ||
121 | i=i-1 ; | ||
122 | j=j-1 ; | ||
123 | |||
124 | dt = sp/2 ; | ||
125 | db = sp/2 ; | ||
126 | dl = sp/2 ; | ||
127 | dr = sp/2 ; | ||
128 | |||
129 | pos = [ j*1/N+dl,... | ||
130 | 1-i*1/M-1/M-db,... | ||
131 | 1/N-dl-dr,... | ||
132 | 1/M-dt-db] ; | ||
133 | |||
134 | switch 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 | ||
151 | end | ||