diff options
Diffstat (limited to 'SD-VBS/benchmarks/mser/src/matlab/old')
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/Makefile | 123 | ||||
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/TIMESTAMP | 2 | ||||
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/erfill.m | 13 | ||||
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/erfill.mex.c | 223 | ||||
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/erfill.mexa64 | bin | 18714 -> 0 bytes | |||
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/mexutils.c | 111 | ||||
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/mser.mex.c | 809 | ||||
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/mser.mexa64 | bin | 28582 -> 0 bytes | |||
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/mser_compile.m | 7 | ||||
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/mser_demo2.m | 62 | ||||
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m | 117 | ||||
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/overview_mser.m | 8 | ||||
-rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/script_run_profile.m | 137 |
13 files changed, 0 insertions, 1612 deletions
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/Makefile b/SD-VBS/benchmarks/mser/src/matlab/old/Makefile deleted file mode 100755 index 29c0982..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/Makefile +++ /dev/null | |||
@@ -1,123 +0,0 @@ | |||
1 | # file: Makefile | ||
2 | # author: Andrea Vedaldi | ||
3 | # description: Build mex files | ||
4 | |||
5 | # -------------------------------------------------------------------- | ||
6 | # | ||
7 | # -------------------------------------------------------------------- | ||
8 | |||
9 | # Determine on the flight the system we are running on | ||
10 | Darwin_ARCH := mac | ||
11 | Linux_ARCH := glx | ||
12 | ARCH := $($(shell uname)_ARCH) | ||
13 | |||
14 | mac_CFLAGS := -I. -pedantic -Wall -Wno-long-long | ||
15 | mac_MEX_CFLAGS := -g -O CFLAGS='$$CFLAGS $(mac_CFLAGS)' | ||
16 | mac_MEX_SUFFIX := mexmac | ||
17 | |||
18 | glx_CFLAGS := -I. -pedantic -Wall -Wno-long-long | ||
19 | glx_MEX_CFLAGS := -g -O CFLAGS='$$CFLAGS $(glx_CFLAGS)' | ||
20 | glx_MEX_SUFFIX := mexglx | ||
21 | |||
22 | MEX_SUFFIX := $($(ARCH)_MEX_SUFFIX) | ||
23 | MEX_CFLAGS := $($(ARCH)_MEX_CFLAGS) | ||
24 | |||
25 | VER := 0.4 | ||
26 | DIST := mser-$(VER) | ||
27 | BINDIST := $(DIST)-$(ARCH) | ||
28 | |||
29 | # -------------------------------------------------------------------- | ||
30 | # | ||
31 | # -------------------------------------------------------------------- | ||
32 | |||
33 | vpath %.mex.c . | ||
34 | |||
35 | src := $(wildcard *.mex.c) | ||
36 | msrc := $(wildcard *.m) | ||
37 | stem := $(notdir $(basename $(basename $(src)))) | ||
38 | tgt := $(addprefix ./, $(addsuffix .$(MEX_SUFFIX),$(stem))) | ||
39 | |||
40 | %.$(MEX_SUFFIX) : %.mex.c | ||
41 | mex -I. $(MEX_CFLAGS) $< -output $* | ||
42 | |||
43 | .PHONY: all | ||
44 | all: $(tgt) | ||
45 | |||
46 | .PHONY: info | ||
47 | info : | ||
48 | @echo src = $(src) | ||
49 | @echo stem = $(stem) | ||
50 | @echo tgt = $(tgt) | ||
51 | |||
52 | # PDF documentation | ||
53 | .PHONY: doc | ||
54 | doc: mser.html doc/mser.pdf | ||
55 | |||
56 | mser.html : $(msrc) | ||
57 | mdoc --output=mser.html . \ | ||
58 | --exclude='.*(_demo|_compile).*.m' | ||
59 | |||
60 | .PHONY: clean | ||
61 | clean: | ||
62 | rm -f $(tgt) | ||
63 | find . -name '.DS_Store' -exec rm -f \{\} \; | ||
64 | find . -name '.gdb_history' -exec rm -f \{\} \; | ||
65 | find . -name '*~' -exec rm -f \{\} \; | ||
66 | find . -name '*.bak' -exec rm -f \{\} \; | ||
67 | make -C doc/figures clean | ||
68 | |||
69 | .PHONY: distclean | ||
70 | distclean: clean | ||
71 | rm -f *.mexmac *.mexglx | ||
72 | rm -f mser.html | ||
73 | rm -f mser-*.tar.gz | ||
74 | rm -f doc/*.log | ||
75 | rm -f doc/*.aux | ||
76 | rm -f doc/*.toc | ||
77 | rm -f doc/*.bbl | ||
78 | rm -f doc/*.blg | ||
79 | rm -f doc/*.out | ||
80 | rm -f $(DIST).tar.gz | ||
81 | rm -f $(BINDIST).tar.gz | ||
82 | rm -rf $(BINDIST) | ||
83 | |||
84 | .PHONY: dist | ||
85 | dist: distclean | ||
86 | echo Version $(VER) >TIMESTAMP | ||
87 | echo Archive created on `date` >>TIMESTAMP | ||
88 | d=$(notdir $(CURDIR)) ; \ | ||
89 | tar chzvf $(DIST).tar.gz \ | ||
90 | --exclude mser_demo4.m \ | ||
91 | --exclude data/seq.avi \ | ||
92 | --exclude results \ | ||
93 | ../$${d} | ||
94 | |||
95 | .PHONY: bindist | ||
96 | bindist: all | ||
97 | test -e $(BINDIST) || mkdir $(BINDIST) | ||
98 | cp *.$(MEX_SUFFIX) $(BINDIST) | ||
99 | cd $(BINDIST) ; strip -S *.$(MEX_SUFFIX) | ||
100 | tar chzvf $(BINDIST).tar.gz $(BINDIST) | ||
101 | |||
102 | .PHONY: autorights | ||
103 | autorights: | ||
104 | autorights . \ | ||
105 | --verbose \ | ||
106 | --recursive \ | ||
107 | --template cal \ | ||
108 | --years 2006 \ | ||
109 | --authors "Andrea Vedaldi (UCLA VisionLab)" \ | ||
110 | --program "Video Extremal Regions" | ||
111 | |||
112 | doc/mser.pdf : doc/*.tex doc/*.bib doc/figures/*.fig | ||
113 | make -C doc/figures all | ||
114 | cd doc ; \ | ||
115 | for k in 1 2 3 ; \ | ||
116 | do \ | ||
117 | pdflatex -file-line-error-style -interaction batchmode \ | ||
118 | mser.tex ; \ | ||
119 | if test "$$k" = '1' ; \ | ||
120 | then \ | ||
121 | bibtex mser.aux ; \ | ||
122 | fi ; \ | ||
123 | done | ||
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/TIMESTAMP b/SD-VBS/benchmarks/mser/src/matlab/old/TIMESTAMP deleted file mode 100755 index 1de1720..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/TIMESTAMP +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | Version 0.4 | ||
2 | Archive created on Wed Feb 7 11:08:47 PST 2007 | ||
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/erfill.m b/SD-VBS/benchmarks/mser/src/matlab/old/erfill.m deleted file mode 100755 index 6e11fc6..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/erfill.m +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | % ERFILL Fill extremal region | ||
2 | % MEMBERS=ERFILL(I,ER) returns the list MEMBERS of the pixels which | ||
3 | % belongs to the extremal region represented by the pixel ER. | ||
4 | % | ||
5 | % The selected region is the one that contains pixel ER and of | ||
6 | % inensity I(ER). | ||
7 | % | ||
8 | % I must be of class UINT8 and ER must be a (scalar) index of the | ||
9 | % region representative point. | ||
10 | % | ||
11 | % See also MSER(). | ||
12 | |||
13 | |||
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/erfill.mex.c b/SD-VBS/benchmarks/mser/src/matlab/old/erfill.mex.c deleted file mode 100755 index 893d346..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/erfill.mex.c +++ /dev/null | |||
@@ -1,223 +0,0 @@ | |||
1 | /* file: erfill.mex.c | ||
2 | ** description: Extremal Regions filling | ||
3 | ** author: Andrea Vedaldi | ||
4 | **/ | ||
5 | |||
6 | /* AUTORIGHTS | ||
7 | Copyright (C) 2006 Regents of the University of California | ||
8 | All rights reserved | ||
9 | |||
10 | Written by Andrea Vedaldi (UCLA VisionLab). | ||
11 | |||
12 | Redistribution and use in source and binary forms, with or without | ||
13 | modification, are permitted provided that the following conditions are met | ||
14 | |||
15 | * Redistributions of source code must retain the above copyright | ||
16 | notice, this list of conditions and the following disclaimer. | ||
17 | * Redistributions in binary form must reproduce the above copyright | ||
18 | notice, this list of conditions and the following disclaimer in the | ||
19 | documentation and/or other materials provided with the distribution. | ||
20 | * Neither the name of the University of California, Berkeley nor the | ||
21 | names of its contributors may be used to endorse or promote products | ||
22 | derived from this software without specific prior written permission. | ||
23 | |||
24 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY | ||
25 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
27 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY | ||
28 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
31 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
34 | */ | ||
35 | |||
36 | /** @file | ||
37 | ** @brief Maximally Stable Extremal Regions - MEX implementation | ||
38 | **/ | ||
39 | |||
40 | #include<mexutils.c> | ||
41 | #include<stdio.h> | ||
42 | #include<stdlib.h> | ||
43 | #include<math.h> | ||
44 | #include<string.h> | ||
45 | #include<assert.h> | ||
46 | |||
47 | #define MIN(x,y) (((x)<(y))?(x):(y)) | ||
48 | #define MAX(x,y) (((x)>(y))?(x):(y)) | ||
49 | |||
50 | typedef char unsigned val_t ; | ||
51 | typedef int unsigned idx_t ; | ||
52 | typedef long long int unsigned acc_t ; | ||
53 | |||
54 | /* advance N-dimensional subscript */ | ||
55 | void | ||
56 | adv(int const* dims, int ndims, int* subs_pt) | ||
57 | { | ||
58 | int d = 0 ; | ||
59 | while(d < ndims) { | ||
60 | if( ++subs_pt[d] < dims[d] ) return ; | ||
61 | subs_pt[d++] = 0 ; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | /* driver */ | ||
66 | void | ||
67 | mexFunction(int nout, mxArray *out[], | ||
68 | int nin, const mxArray *in[]) | ||
69 | { | ||
70 | |||
71 | enum {IN_I=0, IN_ER} ; | ||
72 | enum {OUT_MEMBERS} ; | ||
73 | |||
74 | idx_t i ; | ||
75 | int k, nel, ndims ; | ||
76 | int const * dims ; | ||
77 | val_t const * I_pt ; | ||
78 | int last = 0 ; | ||
79 | int last_expanded = 0 ; | ||
80 | val_t value = 0 ; | ||
81 | |||
82 | double const * er_pt ; | ||
83 | |||
84 | int* subs_pt ; /* N-dimensional subscript */ | ||
85 | int* nsubs_pt ; /* diff-subscript to point to neigh. */ | ||
86 | idx_t* strides_pt ; /* strides to move in image array */ | ||
87 | val_t* visited_pt ; /* flag */ | ||
88 | idx_t* members_pt ; /* region members */ | ||
89 | |||
90 | /** ----------------------------------------------------------------- | ||
91 | ** Check the arguments | ||
92 | ** -------------------------------------------------------------- */ | ||
93 | if (nin != 2) { | ||
94 | mexErrMsgTxt("Two arguments required.") ; | ||
95 | } else if (nout > 4) { | ||
96 | mexErrMsgTxt("Too many output arguments."); | ||
97 | } | ||
98 | |||
99 | if(mxGetClassID(in[IN_I]) != mxUINT8_CLASS) { | ||
100 | mexErrMsgTxt("I must be of class UINT8.") ; | ||
101 | } | ||
102 | |||
103 | if(!uIsRealScalar(in[IN_ER])) { | ||
104 | mexErrMsgTxt("ER must be a DOUBLE scalar.") ; | ||
105 | } | ||
106 | |||
107 | /* get dimensions */ | ||
108 | nel = mxGetNumberOfElements(in[IN_I]) ; | ||
109 | ndims = mxGetNumberOfDimensions(in[IN_I]) ; | ||
110 | dims = mxGetDimensions(in[IN_I]) ; | ||
111 | I_pt = mxGetData(in[IN_I]) ; | ||
112 | |||
113 | /* allocate stuff */ | ||
114 | subs_pt = mxMalloc( sizeof(int) * ndims ) ; | ||
115 | nsubs_pt = mxMalloc( sizeof(int) * ndims ) ; | ||
116 | strides_pt = mxMalloc( sizeof(idx_t) * ndims ) ; | ||
117 | visited_pt = mxMalloc( sizeof(val_t) * nel ) ; | ||
118 | members_pt = mxMalloc( sizeof(idx_t) * nel ) ; | ||
119 | |||
120 | er_pt = mxGetPr(in[IN_ER]) ; | ||
121 | |||
122 | /* compute strides to move into the N-dimensional image array */ | ||
123 | strides_pt [0] = 1 ; | ||
124 | for(k = 1 ; k < ndims ; ++k) { | ||
125 | strides_pt [k] = strides_pt [k-1] * dims [k-1] ; | ||
126 | } | ||
127 | |||
128 | /* load first pixel */ | ||
129 | memset(visited_pt, 0, sizeof(val_t) * nel) ; | ||
130 | { | ||
131 | idx_t idx = (idx_t) *er_pt ; | ||
132 | if( idx < 1 || idx > nel ) { | ||
133 | char buff[80] ; | ||
134 | snprintf(buff,80,"ER=%d out of range [1,%d]",idx,nel) ; | ||
135 | mexErrMsgTxt(buff) ; | ||
136 | } | ||
137 | members_pt [last++] = idx - 1 ; | ||
138 | } | ||
139 | value = I_pt[ members_pt[0] ] ; | ||
140 | |||
141 | /* ----------------------------------------------------------------- | ||
142 | * Fill region | ||
143 | * -------------------------------------------------------------- */ | ||
144 | while(last_expanded < last) { | ||
145 | |||
146 | /* pop next node xi */ | ||
147 | idx_t index = members_pt[last_expanded++] ; | ||
148 | |||
149 | /* convert index into a subscript sub; also initialize nsubs | ||
150 | to (-1,-1,...,-1) */ | ||
151 | { | ||
152 | idx_t temp = index ; | ||
153 | for(k = ndims-1 ; k >=0 ; --k) { | ||
154 | nsubs_pt [k] = -1 ; | ||
155 | subs_pt [k] = temp / strides_pt [k] ; | ||
156 | temp = temp % strides_pt [k] ; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | /* process neighbors of xi */ | ||
161 | while( true ) { | ||
162 | int good = true ; | ||
163 | idx_t nindex = 0 ; | ||
164 | |||
165 | /* compute NSUBS+SUB, the correspoinding neighbor index NINDEX | ||
166 | and check that the pixel is within image boundaries. */ | ||
167 | for(k = 0 ; k < ndims && good ; ++k) { | ||
168 | int temp = nsubs_pt [k] + subs_pt [k] ; | ||
169 | good &= 0 <= temp && temp < dims[k] ; | ||
170 | nindex += temp * strides_pt [k] ; | ||
171 | } | ||
172 | |||
173 | /* process neighbor | ||
174 | 1 - the pixel is within image boundaries; | ||
175 | 2 - the pixel is indeed different from the current node | ||
176 | (this happens when nsub=(0,0,...,0)); | ||
177 | 3 - the pixel has value not greather than val | ||
178 | is a pixel older than xi | ||
179 | 4 - the pixel has not been visited yet | ||
180 | */ | ||
181 | if(good | ||
182 | && nindex != index | ||
183 | && I_pt [nindex] <= value | ||
184 | && ! visited_pt [nindex] ) { | ||
185 | |||
186 | /* mark as visited */ | ||
187 | visited_pt [nindex] = 1 ; | ||
188 | |||
189 | /* add to list */ | ||
190 | members_pt [last++] = nindex ; | ||
191 | } | ||
192 | |||
193 | /* move to next neighbor */ | ||
194 | k = 0 ; | ||
195 | while(++ nsubs_pt [k] > 1) { | ||
196 | nsubs_pt [k++] = -1 ; | ||
197 | if(k == ndims) goto done_all_neighbors ; | ||
198 | } | ||
199 | } /* next neighbor */ | ||
200 | done_all_neighbors : ; | ||
201 | } /* goto pop next member */ | ||
202 | |||
203 | /* | ||
204 | * Save results | ||
205 | */ | ||
206 | { | ||
207 | int dims[2] ; | ||
208 | int unsigned * pt ; | ||
209 | dims[0] = last ; | ||
210 | out[OUT_MEMBERS] = mxCreateNumericArray(1,dims,mxUINT32_CLASS,mxREAL); | ||
211 | pt = mxGetData(out[OUT_MEMBERS]) ; | ||
212 | for (i = 0 ; i < last ; ++i) { | ||
213 | *pt++ = members_pt[i] + 1 ; | ||
214 | } | ||
215 | } | ||
216 | |||
217 | /* free stuff */ | ||
218 | mxFree( members_pt ) ; | ||
219 | mxFree( visited_pt ) ; | ||
220 | mxFree( strides_pt ) ; | ||
221 | mxFree( nsubs_pt ) ; | ||
222 | mxFree( subs_pt ) ; | ||
223 | } | ||
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/erfill.mexa64 b/SD-VBS/benchmarks/mser/src/matlab/old/erfill.mexa64 deleted file mode 100755 index 679e972..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/erfill.mexa64 +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/mexutils.c b/SD-VBS/benchmarks/mser/src/matlab/old/mexutils.c deleted file mode 100755 index 0fc664b..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/mexutils.c +++ /dev/null | |||
@@ -1,111 +0,0 @@ | |||
1 | /* file: mexutils.c | ||
2 | ** author: Andrea Vedaldi | ||
3 | ** description: Utility functions to write MEX files. | ||
4 | **/ | ||
5 | |||
6 | #include"mex.h" | ||
7 | |||
8 | #undef M_PI | ||
9 | #define M_PI 3.14159265358979 | ||
10 | |||
11 | /** @brief Is scalar? | ||
12 | ** | ||
13 | ** @return @c true if the array @a A is a scalar. | ||
14 | **/ | ||
15 | int | ||
16 | uIsScalar(const mxArray* A) | ||
17 | { | ||
18 | return | ||
19 | !mxIsComplex(A) && | ||
20 | mxGetNumberOfDimensions(A) == 2 && | ||
21 | mxGetM(A) == 1 && | ||
22 | mxGetN(A) == 1 ; | ||
23 | } | ||
24 | |||
25 | /** @brief Is real scalar? | ||
26 | ** | ||
27 | ** @return @c true if the array @a A is a real scalar. | ||
28 | **/ | ||
29 | int | ||
30 | uIsRealScalar(const mxArray* A) | ||
31 | { | ||
32 | return | ||
33 | mxIsDouble(A) && | ||
34 | !mxIsComplex(A) && | ||
35 | mxGetNumberOfDimensions(A) == 2 && | ||
36 | mxGetM(A) == 1 && | ||
37 | mxGetN(A) == 1 ; | ||
38 | } | ||
39 | |||
40 | /** @brief Is real matrix? | ||
41 | ** | ||
42 | ** The function checks wether the argument @a A is a real matrix. In | ||
43 | ** addition, if @a M >= 0, it checks wether the number of rows is | ||
44 | ** equal to @a M and, if @a N >= 0, if the number of columns is equal | ||
45 | ** to @a N. | ||
46 | ** | ||
47 | ** @param M number of rows. | ||
48 | ** @param N number of columns. | ||
49 | ** @return @c true if the array is a real matrix with the specified format. | ||
50 | **/ | ||
51 | int | ||
52 | uIsRealMatrix(const mxArray* A, int M, int N) | ||
53 | { | ||
54 | return | ||
55 | mxIsDouble(A) && | ||
56 | !mxIsComplex(A) && | ||
57 | mxGetNumberOfDimensions(A) == 2 && | ||
58 | ((M>=0)?(mxGetM(A) == M):1) && | ||
59 | ((N>=0)?(mxGetN(A) == N):1) ; | ||
60 | } | ||
61 | |||
62 | /** @brief Is real vector? | ||
63 | ** | ||
64 | ** The function checks wether the argument @a V is a real vector. By | ||
65 | ** definiton, a matrix is a vector if one of its dimension is one. | ||
66 | ** In addition, if @a D >= 0, it checks wether the dimension of the | ||
67 | ** vecotr is equal to @a D. | ||
68 | ** | ||
69 | ** @param D lenght of the vector. | ||
70 | ** @return @c true if the array is a real vector of the specified dimension. | ||
71 | **/ | ||
72 | int | ||
73 | uIsRealVector(const mxArray* V, int D) | ||
74 | { | ||
75 | int M = mxGetM(V) ; | ||
76 | int N = mxGetN(V) ; | ||
77 | int is_vector = (N == 1) || (M == 1) ; | ||
78 | |||
79 | return | ||
80 | mxIsDouble(V) && | ||
81 | !mxIsComplex(V) && | ||
82 | mxGetNumberOfDimensions(V) == 2 && | ||
83 | is_vector && | ||
84 | ( D < 0 || N == D || M == D) ; | ||
85 | } | ||
86 | |||
87 | |||
88 | /** @brief Is a string? | ||
89 | ** | ||
90 | ** The function checks wether the array @a S is a string. If | ||
91 | ** @a L is non-negative, it also check wether the strign has | ||
92 | ** length @a L. | ||
93 | ** | ||
94 | ** @return @a c true if S is a string of the specified length. | ||
95 | **/ | ||
96 | int | ||
97 | uIsString(const mxArray* S, int L) | ||
98 | { | ||
99 | int M = mxGetM(S) ; | ||
100 | int N = mxGetN(S) ; | ||
101 | |||
102 | return | ||
103 | mxIsChar(S) && | ||
104 | M == 1 && | ||
105 | (L < 0 || N == L) ; | ||
106 | } | ||
107 | |||
108 | /** | ||
109 | ** | ||
110 | **/ | ||
111 | |||
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/mser.mex.c b/SD-VBS/benchmarks/mser/src/matlab/old/mser.mex.c deleted file mode 100755 index 48c788e..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/mser.mex.c +++ /dev/null | |||
@@ -1,809 +0,0 @@ | |||
1 | /* file: mser.mex.c | ||
2 | ** description: Maximally Stable Extremal Regions | ||
3 | ** author: Andrea Vedaldi | ||
4 | **/ | ||
5 | |||
6 | /* AUTORIGHTS | ||
7 | Copyright (C) 2006 Regents of the University of California | ||
8 | All rights reserved | ||
9 | |||
10 | Written by Andrea Vedaldi (UCLA VisionLab). | ||
11 | |||
12 | Redistribution and use in source and binary forms, with or without | ||
13 | modification, are permitted provided that the following conditions are met | ||
14 | |||
15 | * Redistributions of source code must retain the above copyright | ||
16 | notice, this list of conditions and the following disclaimer. | ||
17 | * Redistributions in binary form must reproduce the above copyright | ||
18 | notice, this list of conditions and the following disclaimer in the | ||
19 | documentation and/or other materials provided with the distribution. | ||
20 | * Neither the name of the University of California, Berkeley nor the | ||
21 | names of its contributors may be used to endorse or promote products | ||
22 | derived from this software without specific prior written permission. | ||
23 | |||
24 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY | ||
25 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
27 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY | ||
28 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
31 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
34 | */ | ||
35 | |||
36 | /** @file | ||
37 | ** @brief Maximally Stable Extremal Regions - MEX implementation | ||
38 | **/ | ||
39 | |||
40 | #include<mexutils.c> | ||
41 | #include<stdio.h> | ||
42 | #include<stdlib.h> | ||
43 | #include<math.h> | ||
44 | #include<string.h> | ||
45 | #include<assert.h> | ||
46 | |||
47 | #define MIN(x,y) (((x)<(y))?(x):(y)) | ||
48 | #define MAX(x,y) (((x)>(y))?(x):(y)) | ||
49 | |||
50 | #define USE_BUCKET_SORT | ||
51 | /*#define USE_RANK_UNION | ||
52 | */ | ||
53 | |||
54 | typedef char unsigned val_t ; | ||
55 | typedef int unsigned idx_t ; | ||
56 | typedef long long int unsigned acc_t ; | ||
57 | |||
58 | /* pairs are used to sort the pixels */ | ||
59 | typedef struct | ||
60 | { | ||
61 | val_t value ; | ||
62 | idx_t index ; | ||
63 | } pair_t ; | ||
64 | |||
65 | /* forest node */ | ||
66 | typedef struct | ||
67 | { | ||
68 | idx_t parent ; /**< parent pixel */ | ||
69 | idx_t shortcut ; /**< shortcut to the root */ | ||
70 | idx_t region ; /**< index of the region */ | ||
71 | int area ; /**< area of the region */ | ||
72 | #ifdef USE_RANK_UNION | ||
73 | int height ; /**< node height */ | ||
74 | #endif | ||
75 | } node_t ; | ||
76 | |||
77 | /* extremal regions */ | ||
78 | typedef struct | ||
79 | { | ||
80 | idx_t parent ; /**< parent region */ | ||
81 | idx_t index ; /**< index of root pixel */ | ||
82 | val_t value ; /**< value of root pixel */ | ||
83 | int area ; /**< area of the region */ | ||
84 | int area_top ; /**< area of the region DELTA levels above */ | ||
85 | int area_bot ; /**< area of the region DELTA levels below */ | ||
86 | float variation ; /**< variation */ | ||
87 | int maxstable ; /**< max stable number (=0 if not maxstable) */ | ||
88 | } region_t ; | ||
89 | |||
90 | /* predicate used to sort pixels by increasing intensity */ | ||
91 | int | ||
92 | cmp_pair(void const* a, void const* b) | ||
93 | { | ||
94 | pair_t* pa = (pair_t*) a; | ||
95 | pair_t* pb = (pair_t*) b; | ||
96 | return pa->value - pb->value ; | ||
97 | } | ||
98 | |||
99 | /* advance N-dimensional subscript */ | ||
100 | void | ||
101 | adv(int const* dims, int ndims, int* subs_pt) | ||
102 | { | ||
103 | int d = 0 ; | ||
104 | while(d < ndims) { | ||
105 | if( ++subs_pt[d] < dims[d] ) return ; | ||
106 | subs_pt[d++] = 0 ; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | /* driver */ | ||
111 | void | ||
112 | mexFunction(int nout, mxArray *out[], | ||
113 | int nin, const mxArray *in[]) | ||
114 | { | ||
115 | enum {IN_I=0, IN_DELTA} ; | ||
116 | enum {OUT_REGIONS=0, OUT_ELL, OUT_PARENTS, OUT_AREA} ; | ||
117 | |||
118 | idx_t i ; | ||
119 | idx_t rindex = 0 ; | ||
120 | int k ; | ||
121 | |||
122 | /* configuration */ | ||
123 | int verbose = 1 ; /* be verbose */ | ||
124 | int small_cleanup= 1 ; /* remove very small regions */ | ||
125 | int big_cleanup = 1 ; /* remove very big regions */ | ||
126 | int bad_cleanup = 0 ; /* remove very bad regions */ | ||
127 | int dup_cleanup = 1 ; /* remove duplicates */ | ||
128 | val_t delta ; /* stability delta */ | ||
129 | |||
130 | /* node value denoting a void node */ | ||
131 | idx_t const node_is_void = 0xffffffff ; | ||
132 | |||
133 | int* subs_pt ; /* N-dimensional subscript */ | ||
134 | int* nsubs_pt ; /* diff-subscript to point to neigh. */ | ||
135 | idx_t* strides_pt ; /* strides to move in image array */ | ||
136 | idx_t* visited_pt ; /* flag */ | ||
137 | |||
138 | int nel ; /* number of image elements (pixels) */ | ||
139 | int ner = 0 ; /* number of extremal regions */ | ||
140 | int nmer = 0 ; /* number of maximally stable */ | ||
141 | int ndims ; /* number of dimensions */ | ||
142 | int const* dims ; /* dimensions */ | ||
143 | int njoins = 0 ; /* number of join ops */ | ||
144 | |||
145 | val_t const* I_pt ; /* source image */ | ||
146 | pair_t* pairs_pt ; /* scratch buffer to sort pixels */ | ||
147 | node_t* forest_pt ; /* the extremal regions forest */ | ||
148 | region_t* regions_pt ; /* list of extremal regions found */ | ||
149 | |||
150 | /* ellipses fitting */ | ||
151 | acc_t* acc_pt ; /* accumulator to integrate region moments */ | ||
152 | acc_t* ell_pt ; /* ellipses parameters */ | ||
153 | int gdl ; /* number of parameters of an ellipse */ | ||
154 | idx_t* joins_pt ; /* sequence of joins */ | ||
155 | |||
156 | /** ----------------------------------------------------------------- | ||
157 | ** Check the arguments | ||
158 | ** -------------------------------------------------------------- */ | ||
159 | if (nin != 2) { | ||
160 | mexErrMsgTxt("Two arguments required.") ; | ||
161 | } else if (nout > 4) { | ||
162 | mexErrMsgTxt("Too many output arguments."); | ||
163 | } | ||
164 | |||
165 | if(mxGetClassID(in[IN_I]) != mxUINT8_CLASS) { | ||
166 | mexErrMsgTxt("I must be of class UINT8") ; | ||
167 | } | ||
168 | |||
169 | if(!uIsScalar(in[IN_DELTA])) { | ||
170 | mexErrMsgTxt("DELTA must be scalar") ; | ||
171 | } | ||
172 | |||
173 | delta = 0 ; | ||
174 | switch(mxGetClassID(in[IN_DELTA])) { | ||
175 | case mxUINT8_CLASS : | ||
176 | delta = * (val_t*) mxGetData(in[IN_DELTA]) ; | ||
177 | break ; | ||
178 | |||
179 | case mxDOUBLE_CLASS : | ||
180 | { | ||
181 | double x = *mxGetPr(in[IN_DELTA]) ; | ||
182 | if(x < 0.0) { | ||
183 | mexErrMsgTxt("DELTA must be non-negative") ; | ||
184 | } | ||
185 | delta = (val_t) x ; | ||
186 | } | ||
187 | break ; | ||
188 | |||
189 | default : | ||
190 | mexErrMsgTxt("DELTA must be of class DOUBLE or UINT8") ; | ||
191 | } | ||
192 | |||
193 | /* get dimensions */ | ||
194 | nel = mxGetNumberOfElements(in[IN_I]) ; | ||
195 | ndims = mxGetNumberOfDimensions(in[IN_I]) ; | ||
196 | dims = mxGetDimensions(in[IN_I]) ; | ||
197 | I_pt = mxGetData(in[IN_I]) ; | ||
198 | |||
199 | /* allocate stuff */ | ||
200 | subs_pt = mxMalloc( sizeof(int) * ndims ) ; | ||
201 | nsubs_pt = mxMalloc( sizeof(int) * ndims ) ; | ||
202 | strides_pt = mxMalloc( sizeof(idx_t) * ndims ) ; | ||
203 | visited_pt = mxMalloc( sizeof(idx_t) * nel ) ; | ||
204 | regions_pt = mxMalloc( sizeof(region_t) * nel ) ; | ||
205 | pairs_pt = mxMalloc( sizeof(pair_t) * nel ) ; | ||
206 | forest_pt = mxMalloc( sizeof(node_t) * nel ) ; | ||
207 | joins_pt = mxMalloc( sizeof(idx_t) * nel ) ; | ||
208 | |||
209 | /* compute strides to move into the N-dimensional image array */ | ||
210 | strides_pt [0] = 1 ; | ||
211 | for(k = 1 ; k < ndims ; ++k) { | ||
212 | strides_pt [k] = strides_pt [k-1] * dims [k-1] ; | ||
213 | } | ||
214 | |||
215 | /* sort pixels by increasing intensity*/ | ||
216 | verbose && mexPrintf("Sorting pixels ... ") ; | ||
217 | |||
218 | #ifndef USE_BUCKETSORT | ||
219 | for(i = 0 ; i < nel ; ++i) { | ||
220 | pairs_pt [i].value = I_pt [i] ; | ||
221 | pairs_pt [i].index = i ; | ||
222 | } | ||
223 | qsort(pairs_pt, nel, sizeof(pair_t), cmp_pair) ; | ||
224 | #else | ||
225 | { | ||
226 | int unsigned buckets [256] ; | ||
227 | memset(buckets, 0, sizeof(int unsigned)*256) ; | ||
228 | for(i = 0 ; i < nel ; ++i) { | ||
229 | val_t v = I_pt [i] ; | ||
230 | ++ buckets[v] ; | ||
231 | } | ||
232 | for(i = 1 ; i < 256 ; ++i) { | ||
233 | buckets[i] += buckets[i-1] ; | ||
234 | } | ||
235 | for(i = nel ; i >= 1 ; ) { | ||
236 | val_t v = I_pt [--i] ; | ||
237 | idx_t j = -- buckets [v] ; | ||
238 | pairs_pt [j].value = v ; | ||
239 | pairs_pt [j].index = i ; | ||
240 | } | ||
241 | } | ||
242 | #endif | ||
243 | verbose && mexPrintf("done\n") ; | ||
244 | |||
245 | /* initialize the forest with all void nodes */ | ||
246 | for(i = 0 ; i < nel ; ++i) { | ||
247 | forest_pt [i].parent = node_is_void ; | ||
248 | } | ||
249 | |||
250 | /* number of ellipse free parameters */ | ||
251 | gdl = ndims*(ndims+1)/2 + ndims ; | ||
252 | |||
253 | /* ----------------------------------------------------------------- | ||
254 | * Compute extremal regions tree | ||
255 | * -------------------------------------------------------------- */ | ||
256 | verbose && mexPrintf("Computing extremal regions ... ") ; | ||
257 | for(i = 0 ; i < nel ; ++i) { | ||
258 | |||
259 | /* pop next node xi */ | ||
260 | idx_t index = pairs_pt [i].index ; | ||
261 | val_t value = pairs_pt [i].value ; | ||
262 | |||
263 | /* this will be needed later */ | ||
264 | rindex = index ; | ||
265 | |||
266 | /* push it into the tree */ | ||
267 | forest_pt [index] .parent = index ; | ||
268 | forest_pt [index] .shortcut = index ; | ||
269 | forest_pt [index] .area = 1 ; | ||
270 | #ifdef USE_RANK_UNION | ||
271 | forest_pt [index] .height = 1 ; | ||
272 | #endif | ||
273 | |||
274 | /* convert index into a subscript sub; also initialize nsubs | ||
275 | to (-1,-1,...,-1) */ | ||
276 | { | ||
277 | idx_t temp = index ; | ||
278 | for(k = ndims-1 ; k >=0 ; --k) { | ||
279 | nsubs_pt [k] = -1 ; | ||
280 | subs_pt [k] = temp / strides_pt [k] ; | ||
281 | temp = temp % strides_pt [k] ; | ||
282 | } | ||
283 | } | ||
284 | |||
285 | /* process neighbors of xi */ | ||
286 | while( true ) { | ||
287 | int good = true ; | ||
288 | idx_t nindex = 0 ; | ||
289 | |||
290 | /* compute NSUBS+SUB, the correspoinding neighbor index NINDEX | ||
291 | and check that the pixel is within image boundaries. */ | ||
292 | for(k = 0 ; k < ndims && good ; ++k) { | ||
293 | int temp = nsubs_pt [k] + subs_pt [k] ; | ||
294 | good &= 0 <= temp && temp < dims[k] ; | ||
295 | nindex += temp * strides_pt [k] ; | ||
296 | } | ||
297 | |||
298 | /* keep going only if | ||
299 | 1 - the neighbor is within image boundaries; | ||
300 | 2 - the neighbor is indeed different from the current node | ||
301 | (this happens when nsub=(0,0,...,0)); | ||
302 | 3 - the nieghbor is already in the tree, meaning that | ||
303 | is a pixel older than xi. | ||
304 | */ | ||
305 | if(good && | ||
306 | nindex != index && | ||
307 | forest_pt[nindex].parent != node_is_void ) { | ||
308 | |||
309 | idx_t nrindex = 0, nvisited ; | ||
310 | val_t nrvalue = 0 ; | ||
311 | |||
312 | #ifdef USE_RANK_UNION | ||
313 | int height = forest_pt [ rindex] .height ; | ||
314 | int nheight = forest_pt [nrindex] .height ; | ||
315 | #endif | ||
316 | |||
317 | /* RINDEX = ROOT(INDEX) might change as we merge trees, so we | ||
318 | need to update it after each merge */ | ||
319 | |||
320 | /* find the root of the current node */ | ||
321 | /* also update the shortcuts */ | ||
322 | nvisited = 0 ; | ||
323 | while( forest_pt[rindex].shortcut != rindex ) { | ||
324 | visited_pt[ nvisited++ ] = rindex ; | ||
325 | rindex = forest_pt[rindex].shortcut ; | ||
326 | } | ||
327 | while( nvisited-- ) { | ||
328 | forest_pt [ visited_pt[nvisited] ] .shortcut = rindex ; | ||
329 | } | ||
330 | |||
331 | /* find the root of the neighbor */ | ||
332 | nrindex = nindex ; | ||
333 | nvisited = 0 ; | ||
334 | while( forest_pt[nrindex].shortcut != nrindex ) { | ||
335 | visited_pt[ nvisited++ ] = nrindex ; | ||
336 | nrindex = forest_pt[nrindex].shortcut ; | ||
337 | } | ||
338 | while( nvisited-- ) { | ||
339 | forest_pt [ visited_pt[nvisited] ] .shortcut = nrindex ; | ||
340 | } | ||
341 | |||
342 | /* | ||
343 | Now we join the two subtrees rooted at | ||
344 | |||
345 | RINDEX = ROOT(INDEX) and NRINDEX = ROOT(NINDEX). | ||
346 | |||
347 | Only three things can happen: | ||
348 | |||
349 | a - ROOT(INDEX) == ROOT(NRINDEX). In this case the two trees | ||
350 | have already been joined and we do not do anything. | ||
351 | |||
352 | b - I(ROOT(INDEX)) == I(ROOT(NRINDEX)). In this case index | ||
353 | is extending an extremal region with the same | ||
354 | value. Since ROOT(NRINDEX) will NOT be an extremal | ||
355 | region of the full image, ROOT(INDEX) can be safely | ||
356 | addedd as children of ROOT(NRINDEX) if this reduces | ||
357 | the height according to union rank. | ||
358 | |||
359 | c - I(ROOT(INDEX)) > I(ROOT(NRINDEX)) as index is extending | ||
360 | an extremal region, but increasing its level. In this | ||
361 | case ROOT(NRINDEX) WILL be an extremal region of the | ||
362 | final image and the only possibility is to add | ||
363 | ROOT(NRINDEX) as children of ROOT(INDEX). | ||
364 | */ | ||
365 | |||
366 | if( rindex != nrindex ) { | ||
367 | /* this is a genuine join */ | ||
368 | |||
369 | nrvalue = I_pt [nrindex] ; | ||
370 | if( nrvalue == value | ||
371 | #ifdef USE_RANK_UNION | ||
372 | && height < nheight | ||
373 | #endif | ||
374 | ) { | ||
375 | /* ROOT(INDEX) becomes the child */ | ||
376 | forest_pt[rindex] .parent = nrindex ; | ||
377 | forest_pt[rindex] .shortcut = nrindex ; | ||
378 | forest_pt[nrindex].area += forest_pt[rindex].area ; | ||
379 | |||
380 | #ifdef USE_RANK_UNION | ||
381 | forest_pt[nrindex].height = MAX(nheight, height+1) ; | ||
382 | #endif | ||
383 | |||
384 | joins_pt[njoins++] = rindex ; | ||
385 | |||
386 | } else { | ||
387 | /* ROOT(index) becomes parent */ | ||
388 | forest_pt[nrindex] .parent = rindex ; | ||
389 | forest_pt[nrindex] .shortcut = rindex ; | ||
390 | forest_pt[rindex] .area += forest_pt[nrindex].area ; | ||
391 | |||
392 | #ifdef USE_RANK_UNION | ||
393 | forest_pt[rindex].height = MAX(height, nheight+1) ; | ||
394 | #endif | ||
395 | if( nrvalue != value ) { | ||
396 | /* nrindex is extremal region: save for later */ | ||
397 | forest_pt[nrindex].region = ner ; | ||
398 | regions_pt [ner] .index = nrindex ; | ||
399 | regions_pt [ner] .parent = ner ; | ||
400 | regions_pt [ner] .value = nrvalue ; | ||
401 | regions_pt [ner] .area = forest_pt [nrindex].area ; | ||
402 | regions_pt [ner] .area_top = nel ; | ||
403 | regions_pt [ner] .area_bot = 0 ; | ||
404 | ++ner ; | ||
405 | /* printf("ner = %d\n", ner);*/ | ||
406 | } | ||
407 | |||
408 | /* annote join operation for post-processing */ | ||
409 | joins_pt[njoins++] = nrindex ; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | } /* neighbor done */ | ||
414 | |||
415 | /* move to next neighbor */ | ||
416 | k = 0 ; | ||
417 | while(++ nsubs_pt [k] > 1) { | ||
418 | nsubs_pt [k++] = -1 ; | ||
419 | if(k == ndims) goto done_all_neighbors ; | ||
420 | } | ||
421 | } /* next neighbor */ | ||
422 | done_all_neighbors : ; | ||
423 | } /* next pixel */ | ||
424 | |||
425 | /* the root of the last processed pixel must be a region */ | ||
426 | forest_pt [rindex].region = ner ; | ||
427 | regions_pt [ner] .index = rindex ; | ||
428 | regions_pt [ner] .parent = ner ; | ||
429 | regions_pt [ner] .value = I_pt [rindex] ; | ||
430 | regions_pt [ner] .area = forest_pt [rindex] .area ; | ||
431 | regions_pt [ner] .area_top = nel ; | ||
432 | regions_pt [ner] .area_bot = 0 ; | ||
433 | ++ner ; | ||
434 | |||
435 | verbose && mexPrintf("done\nExtremal regions: %d\n", ner) ; | ||
436 | |||
437 | /* ----------------------------------------------------------------- | ||
438 | * Compute region parents | ||
439 | * -------------------------------------------------------------- */ | ||
440 | for( i = 0 ; i < ner ; ++i) { | ||
441 | idx_t index = regions_pt [i].index ; | ||
442 | val_t value = regions_pt [i].value ; | ||
443 | idx_t j = i ; | ||
444 | |||
445 | while(j == i) { | ||
446 | idx_t pindex = forest_pt [index].parent ; | ||
447 | val_t pvalue = I_pt [pindex] ; | ||
448 | |||
449 | /* top of the tree */ | ||
450 | if(index == pindex) { | ||
451 | j = forest_pt[index].region ; | ||
452 | break ; | ||
453 | } | ||
454 | |||
455 | /* if index is the root of a region, either this is still | ||
456 | i, or it is the parent region we are looking for. */ | ||
457 | if(value < pvalue) { | ||
458 | j = forest_pt[index].region ; | ||
459 | } | ||
460 | |||
461 | index = pindex ; | ||
462 | value = pvalue ; | ||
463 | } | ||
464 | regions_pt[i]. parent = j ; | ||
465 | } | ||
466 | |||
467 | /* ----------------------------------------------------------------- | ||
468 | * Compute areas of tops and bottoms | ||
469 | * -------------------------------------------------------------- */ | ||
470 | |||
471 | /* We scan the list of regions from the bottom. Let x0 be the current | ||
472 | region and be x1 = PARENT(x0), x2 = PARENT(x1) and so on. | ||
473 | |||
474 | Here we do two things: | ||
475 | |||
476 | 1) Look for regions x for which x0 is the BOTTOM. This requires | ||
477 | VAL(x0) <= VAL(x) - DELTA < VAL(x1). | ||
478 | We update AREA_BOT(x) for each of such x found. | ||
479 | |||
480 | 2) Look for the region y which is the TOP of x0. This requires | ||
481 | VAL(y) <= VAL(x0) + DELTA < VAL(y+1) | ||
482 | We update AREA_TOP(x0) as soon as we find such y. | ||
483 | |||
484 | */ | ||
485 | |||
486 | for( i = 0 ; i < ner ; ++i) { | ||
487 | /* fix xi as the region, then xj are the parents */ | ||
488 | idx_t parent = regions_pt [i].parent ; | ||
489 | int val0 = regions_pt [i].value ; | ||
490 | int val1 = regions_pt [parent].value ; | ||
491 | int val = val0 ; | ||
492 | idx_t j = i ; | ||
493 | |||
494 | while(true) { | ||
495 | int valp = regions_pt [parent].value ; | ||
496 | |||
497 | /* i is the bottom of j */ | ||
498 | if(val0 <= val - delta && val - delta < val1) { | ||
499 | regions_pt [j].area_bot = | ||
500 | MAX(regions_pt [j].area_bot, regions_pt [i].area) ; | ||
501 | } | ||
502 | |||
503 | /* j is the top of i */ | ||
504 | if(val <= val0 + delta && val0 + delta < valp) { | ||
505 | regions_pt [i].area_top = regions_pt [j].area ; | ||
506 | } | ||
507 | |||
508 | /* stop if going on is useless */ | ||
509 | if(val1 <= val - delta && val0 + delta < val) | ||
510 | break ; | ||
511 | |||
512 | /* stop also if j is the root */ | ||
513 | if(j == parent) | ||
514 | break ; | ||
515 | |||
516 | /* next region upward */ | ||
517 | j = parent ; | ||
518 | parent = regions_pt [j].parent ; | ||
519 | val = valp ; | ||
520 | } | ||
521 | } | ||
522 | |||
523 | /* ----------------------------------------------------------------- | ||
524 | * Compute variation | ||
525 | * -------------------------------------------------------------- */ | ||
526 | for(i = 0 ; i < ner ; ++i) { | ||
527 | int area = regions_pt [i].area ; | ||
528 | int area_top = regions_pt [i].area_top ; | ||
529 | int area_bot = regions_pt [i].area_bot ; | ||
530 | regions_pt [i].variation = | ||
531 | (float)(area_top - area_bot) / (float)area ; | ||
532 | |||
533 | /* initialize .mastable to 1 for all nodes */ | ||
534 | regions_pt [i].maxstable = 1 ; | ||
535 | } | ||
536 | |||
537 | /* ----------------------------------------------------------------- | ||
538 | * Remove regions which are NOT maximally stable | ||
539 | * -------------------------------------------------------------- */ | ||
540 | nmer = ner ; | ||
541 | for(i = 0 ; i < ner ; ++i) { | ||
542 | idx_t parent = regions_pt [i] .parent ; | ||
543 | float var = regions_pt [i] .variation ; | ||
544 | float pvar = regions_pt [parent] .variation ; | ||
545 | idx_t loser ; | ||
546 | |||
547 | /* decide which one to keep and put that in loser */ | ||
548 | if(var < pvar) loser = parent ; else loser = i ; | ||
549 | |||
550 | /* make loser NON maximally stable */ | ||
551 | if(regions_pt [loser].maxstable) --nmer ; | ||
552 | regions_pt [loser].maxstable = 0 ; | ||
553 | } | ||
554 | |||
555 | verbose && mexPrintf("Maximally stable regions: %d (%.1f%%)\n", | ||
556 | nmer, 100.0 * (double) nmer / ner) ; | ||
557 | |||
558 | /* ----------------------------------------------------------------- | ||
559 | * Remove more regions | ||
560 | * -------------------------------------------------------------- */ | ||
561 | |||
562 | /* it is critical for correct duplicate detection to remove regions | ||
563 | from the bottom (smallest one first) */ | ||
564 | |||
565 | if( big_cleanup || small_cleanup || bad_cleanup || dup_cleanup ) { | ||
566 | int nbig = 0 ; | ||
567 | int nsmall = 0 ; | ||
568 | int nbad = 0 ; | ||
569 | int ndup = 0 ; | ||
570 | |||
571 | /* scann all extremal regions */ | ||
572 | for(i = 0 ; i < ner ; ++i) { | ||
573 | |||
574 | /* process only maximally stable extremal regions */ | ||
575 | if(! regions_pt [i].maxstable) continue ; | ||
576 | |||
577 | if( bad_cleanup && regions_pt[i].variation >= 1.0f ) { | ||
578 | ++nbad ; | ||
579 | goto remove_this_region ; | ||
580 | } | ||
581 | |||
582 | if( big_cleanup && regions_pt[i].area > nel/2 ) { | ||
583 | ++nbig ; | ||
584 | goto remove_this_region ; | ||
585 | } | ||
586 | |||
587 | if( small_cleanup && regions_pt[i].area < 25 ) { | ||
588 | ++nsmall ; | ||
589 | goto remove_this_region ; | ||
590 | } | ||
591 | |||
592 | /* | ||
593 | * Remove duplicates | ||
594 | */ | ||
595 | if( dup_cleanup ) { | ||
596 | idx_t parent = regions_pt [i].parent ; | ||
597 | int area, parea ; | ||
598 | float change ; | ||
599 | |||
600 | /* the search does not apply to root regions */ | ||
601 | if(parent != i) { | ||
602 | |||
603 | /* search for the maximally stable parent region */ | ||
604 | while(! regions_pt[parent].maxstable) { | ||
605 | idx_t next = regions_pt[parent].parent ; | ||
606 | if(next == parent) break ; | ||
607 | parent = next ; | ||
608 | } | ||
609 | |||
610 | /* compare with the parent region; if the current and parent | ||
611 | regions are too similar, keep only the parent */ | ||
612 | area = regions_pt [i].area ; | ||
613 | parea = regions_pt [parent].area ; | ||
614 | change = (float)(parea - area)/area ; | ||
615 | |||
616 | if(change < 0.5) { | ||
617 | ++ndup ; | ||
618 | goto remove_this_region ; | ||
619 | } | ||
620 | |||
621 | } /* drop duplicates */ | ||
622 | } | ||
623 | continue ; | ||
624 | remove_this_region : | ||
625 | regions_pt[i].maxstable = false ; | ||
626 | --nmer ; | ||
627 | } /* next region to cleanup */ | ||
628 | |||
629 | if(verbose) { | ||
630 | mexPrintf(" Bad regions: %d\n", nbad ) ; | ||
631 | mexPrintf(" Small regions: %d\n", nsmall ) ; | ||
632 | mexPrintf(" Big regions: %d\n", nbig ) ; | ||
633 | mexPrintf(" Duplicated regions: %d\n", ndup ) ; | ||
634 | } | ||
635 | } | ||
636 | |||
637 | verbose && mexPrintf("Cleaned-up regions: %d (%.1f%%)\n", | ||
638 | nmer, 100.0 * (double) nmer / ner) ; | ||
639 | |||
640 | /* ----------------------------------------------------------------- | ||
641 | * Fit ellipses | ||
642 | * -------------------------------------------------------------- */ | ||
643 | ell_pt = 0 ; | ||
644 | if (nout >= 1) { | ||
645 | int midx = 1 ; | ||
646 | int d, index, j ; | ||
647 | |||
648 | verbose && mexPrintf("Fitting ellipses...\n") ; | ||
649 | |||
650 | /* enumerate maxstable regions */ | ||
651 | for(i = 0 ; i < ner ; ++i) { | ||
652 | if(! regions_pt [i].maxstable) continue ; | ||
653 | regions_pt [i].maxstable = midx++ ; | ||
654 | } | ||
655 | |||
656 | /* allocate space */ | ||
657 | acc_pt = mxMalloc(sizeof(acc_t) * nel) ; | ||
658 | ell_pt = mxMalloc(sizeof(acc_t) * gdl * nmer) ; | ||
659 | |||
660 | /* clear accumulators */ | ||
661 | memset(ell_pt, 0, sizeof(int) * gdl * nmer) ; | ||
662 | |||
663 | /* for each gdl */ | ||
664 | for(d = 0 ; d < gdl ; ++d) { | ||
665 | /* initalize parameter */ | ||
666 | memset(subs_pt, 0, sizeof(int) * ndims) ; | ||
667 | |||
668 | if(d < ndims) { | ||
669 | verbose && mexPrintf(" mean %d\n",d) ; | ||
670 | for(index = 0 ; index < nel ; ++ index) { | ||
671 | acc_pt[index] = subs_pt[d] ; | ||
672 | adv(dims, ndims, subs_pt) ; | ||
673 | } | ||
674 | |||
675 | } else { | ||
676 | |||
677 | /* decode d-ndims into a (i,j) pair */ | ||
678 | i = d-ndims ; | ||
679 | j = 0 ; | ||
680 | while(i > j) { | ||
681 | i -= j + 1 ; | ||
682 | j ++ ; | ||
683 | } | ||
684 | |||
685 | verbose && mexPrintf(" corr (%d,%d)\n",i,j) ; | ||
686 | |||
687 | /* add x_i * x_j */ | ||
688 | for(index = 0 ; index < nel ; ++ index){ | ||
689 | acc_pt[index] = subs_pt[i]*subs_pt[j] ; | ||
690 | adv(dims, ndims, subs_pt) ; | ||
691 | } | ||
692 | } | ||
693 | |||
694 | /* integrate parameter */ | ||
695 | for(i = 0 ; i < njoins ; ++i) { | ||
696 | idx_t index = joins_pt[i] ; | ||
697 | idx_t parent = forest_pt [ index ].parent ; | ||
698 | acc_pt[parent] += acc_pt[index] ; | ||
699 | } | ||
700 | |||
701 | /* save back to ellpises */ | ||
702 | for(i = 0 ; i < ner ; ++i) { | ||
703 | idx_t region = regions_pt [i].maxstable ; | ||
704 | |||
705 | /* skip if not extremal region */ | ||
706 | if(region-- == 0) continue ; | ||
707 | ell_pt [d + gdl*region] = acc_pt [ regions_pt[i].index ] ; | ||
708 | } | ||
709 | |||
710 | /* next gdl */ | ||
711 | } | ||
712 | mxFree(acc_pt) ; | ||
713 | } | ||
714 | |||
715 | /* ----------------------------------------------------------------- | ||
716 | * Save back and exit | ||
717 | * -------------------------------------------------------------- */ | ||
718 | |||
719 | /* | ||
720 | * Save extremal regions | ||
721 | */ | ||
722 | { | ||
723 | int dims[2] ; | ||
724 | int unsigned * pt ; | ||
725 | dims[0] = nmer ; | ||
726 | out[OUT_REGIONS] = mxCreateNumericArray(1,dims,mxUINT32_CLASS,mxREAL); | ||
727 | pt = mxGetData(out[OUT_REGIONS]) ; | ||
728 | for (i = 0 ; i < ner ; ++i) { | ||
729 | if( regions_pt[i].maxstable ) { | ||
730 | /* adjust for MATLAB index compatibility */ | ||
731 | *pt++ = regions_pt[i].index + 1 ; | ||
732 | } | ||
733 | } | ||
734 | } | ||
735 | |||
736 | /* | ||
737 | * Save fitted ellipses | ||
738 | */ | ||
739 | if(nout >= 2) { | ||
740 | int dims[2], d, j, index ; | ||
741 | double * pt ; | ||
742 | dims[0] = gdl ; | ||
743 | dims[1] = nmer ; | ||
744 | |||
745 | out[OUT_ELL] = mxCreateNumericArray(2,dims,mxDOUBLE_CLASS,mxREAL) ; | ||
746 | pt = mxGetData(out[OUT_ELL]) ; | ||
747 | |||
748 | for(index = 0 ; index < nel ; ++index) { | ||
749 | |||
750 | idx_t region = regions_pt [index] .maxstable ; | ||
751 | int N = regions_pt [index] .area ; | ||
752 | |||
753 | if(region-- == 0) continue ; | ||
754 | |||
755 | for(d = 0 ; d < gdl ; ++d) { | ||
756 | |||
757 | pt[d] = (double) ell_pt[gdl*region + d] / N ; | ||
758 | |||
759 | if(d < ndims) { | ||
760 | /* adjust for MATLAB coordinate frame convention */ | ||
761 | pt[d] += 1 ; | ||
762 | } else { | ||
763 | /* remove squared mean from moment to get variance */ | ||
764 | i = d - ndims ; | ||
765 | j = 0 ; | ||
766 | while(i > j) { | ||
767 | i -= j + 1 ; | ||
768 | j ++ ; | ||
769 | } | ||
770 | pt[d] -= (pt[i]-1)*(pt[j]-1) ; | ||
771 | } | ||
772 | } | ||
773 | pt += gdl ; | ||
774 | } | ||
775 | mxFree(ell_pt) ; | ||
776 | } | ||
777 | |||
778 | if(nout >= 3) { | ||
779 | int unsigned * pt ; | ||
780 | out[OUT_PARENTS] = mxCreateNumericArray(ndims,dims,mxUINT32_CLASS,mxREAL) ; | ||
781 | pt = mxGetData(out[OUT_PARENTS]) ; | ||
782 | for(i = 0 ; i < nel ; ++i) { | ||
783 | *pt++ = forest_pt[i].parent ; | ||
784 | } | ||
785 | } | ||
786 | |||
787 | if(nout >= 4) { | ||
788 | int dims[2] ; | ||
789 | int unsigned * pt ; | ||
790 | dims[0] = 3 ; | ||
791 | dims[1]= ner ; | ||
792 | out[OUT_AREA] = mxCreateNumericArray(2,dims,mxUINT32_CLASS,mxREAL); | ||
793 | pt = mxGetData(out[OUT_AREA]) ; | ||
794 | for( i = 0 ; i < ner ; ++i ) { | ||
795 | *pt++ = regions_pt [i]. area_bot ; | ||
796 | *pt++ = regions_pt [i]. area ; | ||
797 | *pt++ = regions_pt [i]. area_top ; | ||
798 | } | ||
799 | } | ||
800 | |||
801 | /* free stuff */ | ||
802 | mxFree( forest_pt ) ; | ||
803 | mxFree( pairs_pt ) ; | ||
804 | mxFree( regions_pt ) ; | ||
805 | mxFree( visited_pt ) ; | ||
806 | mxFree( strides_pt ) ; | ||
807 | mxFree( nsubs_pt ) ; | ||
808 | mxFree( subs_pt ) ; | ||
809 | } | ||
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/mser.mexa64 b/SD-VBS/benchmarks/mser/src/matlab/old/mser.mexa64 deleted file mode 100755 index fb9fb0b..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/mser.mexa64 +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/mser_compile.m b/SD-VBS/benchmarks/mser/src/matlab/old/mser_compile.m deleted file mode 100755 index 5e3562b..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/mser_compile.m +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | function mser_compile(type) | ||
2 | % MSER_COMPILE Compile MEX files | ||
3 | |||
4 | opts = { '-O', '-I.' } ; | ||
5 | |||
6 | mex('mser.mex.c','-output', 'mser',opts{:}) ; | ||
7 | mex('erfill.mex.c','-output', 'erfill',opts{:}) ; | ||
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/mser_demo2.m b/SD-VBS/benchmarks/mser/src/matlab/old/mser_demo2.m deleted file mode 100755 index 37a4ed1..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/mser_demo2.m +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | % MSER_DEMO2 Demonstrate MSER code | ||
2 | |||
3 | % AUTORIGHTS | ||
4 | % Copyright (C) 2006 Regents of the University of California | ||
5 | % All rights reserved | ||
6 | % | ||
7 | % Written by Andrea Vedaldi (UCLA VisionLab). | ||
8 | % | ||
9 | % Redistribution and use in source and binary forms, with or without | ||
10 | % modification, are permitted provided that the following conditions are met | ||
11 | % | ||
12 | % * Redistributions of source code must retain the above copyright | ||
13 | % notice, this list of conditions and the following disclaimer. | ||
14 | % * Redistributions in binary form must reproduce the above copyright | ||
15 | % notice, this list of conditions and the following disclaimer in the | ||
16 | % documentation and/or other materials provided with the distribution. | ||
17 | % * Neither the name of the University of California, Berkeley nor the | ||
18 | % names of its contributors may be used to endorse or promote products | ||
19 | % derived from this software without specific prior written permission. | ||
20 | % | ||
21 | % THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY | ||
22 | % EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
23 | % WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
24 | % DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY | ||
25 | % DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
26 | % (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
27 | % LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
28 | % ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
29 | % (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
30 | % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
31 | |||
32 | I = load('clown') ; I = uint8(I.X) ; | ||
33 | figure(1) ; imagesc(I) ; colormap gray; hold on ; | ||
34 | |||
35 | [M,N] = size(I) ; | ||
36 | i = double(i) ; | ||
37 | j = double(j) ; | ||
38 | |||
39 | [r,ell] = mser(I,5) ; | ||
40 | |||
41 | r=double(r) ; | ||
42 | |||
43 | [i,j]=ind2sub(size(I),r) ; | ||
44 | plot(j,i,'r*') ; | ||
45 | |||
46 | ell = ell([2 1 5 4 3],:) ; | ||
47 | plotframe(ell); | ||
48 | |||
49 | figure(2) ; | ||
50 | |||
51 | clear MOV ; | ||
52 | K = size(ell,2) ; | ||
53 | for k=1:K | ||
54 | clf ; | ||
55 | sel = erfill(I,r(k)) ; | ||
56 | mask = zeros(M,N) ; mask(sel) =1 ; | ||
57 | imagesc(cat(3,I,255*uint8(mask),I)) ; colormap gray ; hold on ; | ||
58 | set(gca,'position',[0 0 1 1]) ; axis off ; axis equal ; | ||
59 | plot(j(k),i(k),'r*') ; | ||
60 | plotframe(ell(:,k),'color','r') ; | ||
61 | MOV(k) = getframe(gca) ; | ||
62 | end | ||
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m b/SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m deleted file mode 100755 index 4669437..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m +++ /dev/null | |||
@@ -1,117 +0,0 @@ | |||
1 | % MSER_DEMO3 Demonstrates MSER on a volumetric image | ||
2 | |||
3 | % AUTORIGHTS | ||
4 | % Copyright (C) 2006 Regents of the University of California | ||
5 | % All rights reserved | ||
6 | % | ||
7 | % Written by Andrea Vedaldi (UCLA VisionLab). | ||
8 | % | ||
9 | % Redistribution and use in source and binary forms, with or without | ||
10 | % modification, are permitted provided that the following conditions are met | ||
11 | % | ||
12 | % * Redistributions of source code must retain the above copyright | ||
13 | % notice, this list of conditions and the following disclaimer. | ||
14 | % * Redistributions in binary form must reproduce the above copyright | ||
15 | % notice, this list of conditions and the following disclaimer in the | ||
16 | % documentation and/or other materials provided with the distribution. | ||
17 | % * Neither the name of the University of California, Berkeley nor the | ||
18 | % names of its contributors may be used to endorse or promote products | ||
19 | % derived from this software without specific prior written permission. | ||
20 | % | ||
21 | % THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY | ||
22 | % EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
23 | % WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
24 | % DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY | ||
25 | % DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
26 | % (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
27 | % LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
28 | % ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
29 | % (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
30 | % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
31 | |||
32 | % -------------------------------------------------------------------- | ||
33 | % Create data | ||
34 | % -------------------------------------------------------------------- | ||
35 | |||
36 | % volumetric coordinate (x,y,z) | ||
37 | x = linspace(-1,1,50) ; | ||
38 | [x,y,z] = meshgrid(x,x,x) ; | ||
39 | |||
40 | % create funny volumetric image | ||
41 | I = sin(4*x).*cos(4*y).*sin(z) ; | ||
42 | I = I-min(I(:)) ; | ||
43 | I = I/max(I(:)) ; | ||
44 | |||
45 | % quantize the image in 10 levels | ||
46 | lev = 10 ; | ||
47 | I = lev*I ; | ||
48 | Ir = round(I) ; | ||
49 | |||
50 | % -------------------------------------------------------------------- | ||
51 | % Compute regions | ||
52 | % -------------------------------------------------------------------- | ||
53 | [idx,ell,p] = mser(uint8(Ir),1); | ||
54 | |||
55 | % -------------------------------------------------------------------- | ||
56 | % Plots | ||
57 | % -------------------------------------------------------------------- | ||
58 | |||
59 | % The image is quantized; store in LEV its range. | ||
60 | lev = unique(Ir(idx)) ; | ||
61 | |||
62 | figure(100); clf; | ||
63 | K=min(length(lev),4) ; | ||
64 | |||
65 | r=.99 ; | ||
66 | |||
67 | % one level per time | ||
68 | for k=1:K | ||
69 | tightsubplot(K,k) ; | ||
70 | [i,j,m] = ind2sub(size(I), idx(Ir(idx)==lev(k)) ) ; | ||
71 | |||
72 | % compute level set of level LEV(k) | ||
73 | Is = double(Ir<=lev(k)) ; | ||
74 | |||
75 | p1 = patch(isosurface(Is,r), ... | ||
76 | 'FaceColor','blue','EdgeColor','none') ; | ||
77 | p2 = patch(isocaps(Is,r),... | ||
78 | 'FaceColor','interp','EdgeColor','none') ; | ||
79 | isonormals(I,p1) | ||
80 | hold on ; | ||
81 | |||
82 | view(3); axis vis3d tight | ||
83 | camlight; lighting phong ; | ||
84 | |||
85 | % find regions that have this level | ||
86 | sel = find( Ir(idx) == lev(k) ) ; | ||
87 | |||
88 | % plot fitted ellipsoid | ||
89 | for r=sel' | ||
90 | E = ell(:,r) ; | ||
91 | c = E(1:3) ; | ||
92 | A = zeros(3) ; | ||
93 | A(1,1) = E(4) ; | ||
94 | A(1,2) = E(5) ; | ||
95 | A(2,2) = E(6) ; | ||
96 | A(1,3) = E(7) ; | ||
97 | A(2,3) = E(8) ; | ||
98 | A(3,3) = E(9) ; | ||
99 | |||
100 | A = A + A' - diag(diag(A)) ; | ||
101 | |||
102 | % correct var. order | ||
103 | perm = [0 1 0 ; 1 0 0 ; 0 0 1] ; | ||
104 | A = perm*A*perm ; | ||
105 | |||
106 | [V,D] = eig(A) ; | ||
107 | A = 2.5*V*sqrt(D) ; | ||
108 | |||
109 | [x,y,z]=sphere ; | ||
110 | [P,Q]=size(x) ; | ||
111 | X=A*[x(:)';y(:)';z(:)'] ; | ||
112 | x=reshape(X(1,:),P,Q)+c(2) ; | ||
113 | y=reshape(X(2,:),P,Q)+c(1) ; | ||
114 | z=reshape(X(3,:),P,Q)+c(3) ; | ||
115 | surf(x,y,z,'FaceAlpha',.5) ; | ||
116 | end | ||
117 | end | ||
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/overview_mser.m b/SD-VBS/benchmarks/mser/src/matlab/old/overview_mser.m deleted file mode 100755 index b7fcf2b..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/overview_mser.m +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | % OVERVIEW_MSER Maximally Stable Extremal Regions | ||
2 | % This is a MATLAB/MEX implementation of Maximally Stable Extremal | ||
3 | % Regions (MSER). You can: | ||
4 | % | ||
5 | % * Use MSER() to extract the maximally stable extremal regions from | ||
6 | % a given image. | ||
7 | % | ||
8 | % For practical coding example, see MSER_DEMO() and MSER_DEMO3(). | ||
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/script_run_profile.m b/SD-VBS/benchmarks/mser/src/matlab/old/script_run_profile.m deleted file mode 100755 index bdb2c04..0000000 --- a/SD-VBS/benchmarks/mser/src/matlab/old/script_run_profile.m +++ /dev/null | |||
@@ -1,137 +0,0 @@ | |||
1 | function script_run_profile(dataDir, resultDir, type, common,toolDir) | ||
2 | |||
3 | path(path, common); | ||
4 | |||
5 | % MSER_DEMO Demonstrates MSER | ||
6 | |||
7 | % AUTORIGHTS | ||
8 | % Copyright (C) 2006 Regents of the University of California | ||
9 | % All rights reserved | ||
10 | % | ||
11 | % Written by Andrea Vedaldi (UCLA VisionLab). | ||
12 | % | ||
13 | % Redistribution and use in source and binary forms, with or without | ||
14 | % modification, are permitted provided that the following conditions are met | ||
15 | % | ||
16 | % * Redistributions of source code must retain the above copyright | ||
17 | % notice, this list of conditions and the following disclaimer. | ||
18 | % * Redistributions in binary form must reproduce the above copyright | ||
19 | % notice, this list of conditions and the following disclaimer in the | ||
20 | % documentation and/or other materials provided with the distribution. | ||
21 | % * Neither the name of the University of California, Berkeley nor the | ||
22 | % names of its contributors may be used to endorse or promote products | ||
23 | % derived from this software without specific prior written permission. | ||
24 | % | ||
25 | % THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY | ||
26 | % EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
27 | % WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
28 | % DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY | ||
29 | % DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
30 | % (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
31 | % LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
32 | % ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
33 | % (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
34 | % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
35 | |||
36 | which_image = 3 ; | ||
37 | |||
38 | % -------------------------------------------------------------------- | ||
39 | % Create data | ||
40 | % -------------------------------------------------------------------- | ||
41 | switch which_image | ||
42 | case 1 | ||
43 | I = rand(200,200) ; | ||
44 | I = imsmooth(I,10) ; | ||
45 | I = I-min(I(:)) ; | ||
46 | I = I/max(I(:)) ; | ||
47 | lev = 10 ; | ||
48 | I = uint8(round(I*lev)) ; | ||
49 | |||
50 | case 2 | ||
51 | I = zeros(200,200) ; | ||
52 | I(50:150,50:150)=5 ; | ||
53 | I = imsmooth(I,10) ; | ||
54 | I = uint8(round(I)) ; | ||
55 | |||
56 | case 3 | ||
57 | Files = dir([dataDir,'/1.bmp']); | ||
58 | I=readImage(fullfile(dataDir,Files(1).name)); | ||
59 | |||
60 | % if(ndims(Image) > 2) | ||
61 | % | ||
62 | % for i=1:size(Image,1) | ||
63 | % for j=1:size(Image,2) | ||
64 | % I(i,j) = (Image(i,j,1) + Image(i,j,2)*6 + Image(i,j,3)*3)/10; | ||
65 | % end | ||
66 | % end | ||
67 | % | ||
68 | % else | ||
69 | % I = Image; | ||
70 | % end | ||
71 | disp(size(I)); | ||
72 | end | ||
73 | |||
74 | % -------------------------------------------------------------------- | ||
75 | % Compute MSERs | ||
76 | % -------------------------------------------------------------------- | ||
77 | |||
78 | %% Self check params | ||
79 | tol = 0.1; | ||
80 | elapsed = zeros(1,2); | ||
81 | |||
82 | %% Timing | ||
83 | start = photonStartTiming; | ||
84 | |||
85 | [idx,ell,p,a] = mser(uint8(I), 2) ; | ||
86 | |||
87 | %% Timing | ||
88 | stop = photonEndTiming; | ||
89 | |||
90 | temp = photonReportTiming(start, stop); | ||
91 | elapsed(1) = elapsed(1) + temp(1); | ||
92 | elapsed(2) = elapsed(2) + temp(2); | ||
93 | |||
94 | %% Self checking | ||
95 | writeMatrix(idx, dataDir); | ||
96 | ret = selfCheck(idx, dataDir, tol); | ||
97 | if(ret == -1) | ||
98 | disp('Error in MSER'); | ||
99 | end | ||
100 | |||
101 | %% Timing | ||
102 | photonPrintTiming(elapsed); | ||
103 | |||
104 | %% -------------------------------------------------------------------- | ||
105 | %% Plots | ||
106 | %% -------------------------------------------------------------------- | ||
107 | %[i,j] = ind2sub(size(I),idx) ; | ||
108 | % | ||
109 | %figure(100) ; clf ; imagesc(I) ; hold on ; | ||
110 | %set(gca,'Position',[0 0 1 1]) ; | ||
111 | %plot(j,i,'g*') ; colormap gray ; | ||
112 | % | ||
113 | %% swap x with y | ||
114 | %ell = ell([2 1 5 4 3],:) ; | ||
115 | % | ||
116 | %for k=1:size(ell,2) | ||
117 | % E = ell(:,k) ; | ||
118 | % c = E(1:2) ; | ||
119 | % A = zeros(2) ; | ||
120 | % A(1,1) = E(3) ; | ||
121 | % A(1,2) = E(4) ; | ||
122 | % A(2,2) = E(5) ; | ||
123 | % A = A + A' - diag(diag(A)) ; | ||
124 | % | ||
125 | % [V,D] = eig(A) ; | ||
126 | % A = 2.5*V*sqrt(D) ; | ||
127 | % | ||
128 | % X = A*[cos(linspace(0,2*pi,30)) ; sin(linspace(0,2*pi,30)) ;] ; | ||
129 | % X(1,:) = X(1,:) + c(1) ; | ||
130 | % X(2,:) = X(2,:) + c(2) ; | ||
131 | % | ||
132 | % plot(X(1,:),X(2,:),'r-','LineWidth',2) ; | ||
133 | % plot(c(1),c(2),'r.') ; | ||
134 | % plot(j(k),i(k),'g*') ; | ||
135 | %end | ||
136 | % | ||
137 | %line([j'; ell(1,:)],[i'; ell(2,:)],'color','b') ; | ||