segmentation
All Data Structures Namespaces Files Functions Variables Modules Pages
rlist.h
1 /*******************************************************
2 
3  Mean Shift Analysis Library
4  =============================================
5 
6 
7  The mean shift library is a collection of routines
8  that use the mean shift algorithm. Using this algorithm,
9  the necessary output will be generated needed
10  to analyze a given input set of data.
11 
12  Region List Class:
13  =================
14 
15  During segmentation, data regions are defined. The
16  RegionList class provides a mechanism for doing so, as
17  well as defines some basic operations, such as region
18  growing or small region pruning, on the defined regions.
19  The prototype for the RegionList class is provided below. It
20  is defined in "region.cc".
21 
22 The theory is described in the papers:
23 
24  D. Comaniciu, P. Meer: Mean Shift: A robust approach toward feature
25  space analysis.
26 
27  C. Christoudias, B. Georgescu, P. Meer: Synergism in low level vision.
28 
29 and they are is available at:
30  http://www.caip.rutgers.edu/riul/research/papers/
31 
32 Implemented by Chris M. Christoudias, Bogdan Georgescu
33 ********************************************************/
34 
35 #ifndef RLIST_H
36 #define RLIST_H
37 
38 //include global type definitions
39 #include "tdef.h"
40 
41 //define region structure
42 struct REGION {
43  int label;
44  int pointCount;
45  int region;
46 
47 };
48 
49 //region class prototype...
50 class RegionList {
51 
52 public:
53 
54  /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
55  /* Class Constructor and Destructor */
56  /*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
57 
58  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
59  //<--------------------------------------------------->|//
60  //| |//
61  //| Method Name: |//
62  //| ============ |//
63  //| * Class Constructor * |//
64  //| |//
65  //<--------------------------------------------------->|//
66  //| |//
67  //| Description: |//
68  //| ============ |//
69  //| |//
70  //| Constructs a region list object. |//
71  //| |//
72  //| Its arguments are: |//
73  //| |//
74  //| <* maxRegions *> |//
75  //| The maximum amount of regions that can be class- |//
76  //| ified by the region list. |//
77  //| |//
78  //| <* L *> |//
79  //| The length of the input data set being class- |//
80  //| ified by the region list object. |//
81  //| |//
82  //| <* N *> |//
83  //| The dimension of the input data set being class- |//
84  //| ified by the region list object. |//
85  //| |//
86  //<--------------------------------------------------->|//
87  //| |//
88  //| Usage: |//
89  //| ====== |//
90  //| RegionList(maxRegions, L, N) |//
91  //| |//
92  //<--------------------------------------------------->|//
93  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
94 
95  RegionList(int, int, int);
96 
97  // Class Destructor
98  ~RegionList( void );
99 
100  /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
101  /* Region List Manipulation */
102  /*\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
103 
104  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
105  //<--------------------------------------------------->|//
106  //| |//
107  //| Method Name: |//
108  //| ============ |//
109  //| * Add Region * |//
110  //| |//
111  //<--------------------------------------------------->|//
112  //| |//
113  //| Description: |//
114  //| ============ |//
115  //| |//
116  //| Adds a region to the region list. |//
117  //| |//
118  //| Its arguments are: |//
119  //| |//
120  //| <* label *> |//
121  //| |//
122  //| A positive integer used to uniquely identify |//
123  //| a region. |//
124  //| |//
125  //| <* pointCount *> |//
126  //| A positive integer that specifies the number of |//
127  //| N-dimensional data points that exist in the re- |//
128  //| gion being classified. |//
129  //| |//
130  //| <* indeces *> |//
131  //| An integer array that specifies the set of ind- |//
132  //| eces of the data points that are contianed with- |//
133  //| in this region. |//
134  //| |//
135  //<--------------------------------------------------->|//
136  //| |//
137  //| Usage: |//
138  //| ====== |//
139  //| AddRegion(label, pointCount, indeces) |//
140  //| |//
141  //<--------------------------------------------------->|//
142  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
143 
144  void AddRegion(int, int, int*);
145 
146  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
147  //<--------------------------------------------------->|//
148  //| |//
149  //| Method Name: |//
150  //| ============ |//
151  //| * Reset * |//
152  //| |//
153  //<--------------------------------------------------->|//
154  //| |//
155  //| Description: |//
156  //| ============ |//
157  //| |//
158  //| Resets the region list for re-use (for new |//
159  //| classification). |//
160  //| |//
161  //<--------------------------------------------------->|//
162  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
163 
164  void Reset( void );
165 
166  /*/\/\/\/\/\/\/\/\/\/\*/
167  /* Query Region List */
168  /*\/\/\/\/\/\/\/\/\/\/*/
169 
170  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
171  //<--------------------------------------------------->|//
172  //| |//
173  //| Method Name: |//
174  //| ============ |//
175  //| * Get Number of Regions * |//
176  //| |//
177  //<--------------------------------------------------->|//
178  //| |//
179  //| Description: |//
180  //| ============ |//
181  //| |//
182  //| Returns the number of regions stored by the |//
183  //| region list. |//
184  //| |//
185  //<--------------------------------------------------->|//
186  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
187 
188  int GetNumRegions ( void );
189 
190  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
191  //<--------------------------------------------------->|//
192  //| |//
193  //| Method Name: |//
194  //| ============ |//
195  //| * Get Label * |//
196  //| |//
197  //<--------------------------------------------------->|//
198  //| |//
199  //| Description: |//
200  //| ============ |//
201  //| |//
202  //| Returns the label of a specified region. |//
203  //| |//
204  //| Its arguments are: |//
205  //| |//
206  //| <* regionNumber *> |//
207  //| The index of the region in the region list |//
208  //| array. |//
209  //| |//
210  //<--------------------------------------------------->|//
211  //| |//
212  //| Usage: |//
213  //| ====== |//
214  //| label = GetLabel(regionNumber) |//
215  //| |//
216  //<--------------------------------------------------->|//
217  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
218 
219  int GetLabel(int);
220 
221  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
222  //<--------------------------------------------------->|//
223  //| |//
224  //| Method Name: |//
225  //| ============ |//
226  //| * Get Region Count * |//
227  //| |//
228  //<--------------------------------------------------->|//
229  //| |//
230  //| Description: |//
231  //| ============ |//
232  //| |//
233  //| Returns number of data points contained by a sp- |//
234  //| ecified region. |//
235  //| |//
236  //| Its arguments are: |//
237  //| |//
238  //| <* regionNumber *> |//
239  //| The index of the region in the region list |//
240  //| array. |//
241  //| |//
242  //<--------------------------------------------------->|//
243  //| |//
244  //| Usage: |//
245  //| ====== |//
246  //| pointCount = GetRegionCount(regionNumber) |//
247  //| |//
248  //<--------------------------------------------------->|//
249  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
250 
251  int GetRegionCount(int);
252 
253  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
254  //<--------------------------------------------------->|//
255  //| |//
256  //| Method Name: |//
257  //| ============ |//
258  //| * Get Region Indeces * |//
259  //| |//
260  //<--------------------------------------------------->|//
261  //| |//
262  //| Description: |//
263  //| ============ |//
264  //| |//
265  //| Returns a pointer to a set of grid location ind- |//
266  //| eces specifying the data points belonging to a |//
267  //| specified region. |//
268  //| |//
269  //| Its arguments are: |//
270  //| |//
271  //| <* regionNumber *> |//
272  //| The index of the region in the region list |//
273  //| array. |//
274  //| |//
275  //<--------------------------------------------------->|//
276  //| |//
277  //| Usage: |//
278  //| ====== |//
279  //| indeces = GetRegionIndeces(regionNumber) |//
280  //| |//
281  //<--------------------------------------------------->|//
282  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
283 
284  int*GetRegionIndeces(int);
285 
286 private:
287 
288  /*/\/\/\/\/\/\/\/\/\/\/\*/
289  /* Class Error Handler */
290  /*\/\/\/\/\/\/\/\/\/\/\/*/
291 
292  void ErrorHandler(const char*, const char*, ErrorType);
293 
294  //=============================
295  // *** Private Data Members ***
296  //=============================
297 
298  //#####################################
299  //### REGION LIST PARTITIONED ARRAY ###
300  //#####################################
301 
302  REGION *regionList; //array of maxRegions regions
303  int minRegion;
304 
305  int maxRegions; //defines the number maximum number of regions
306  //allowed (determined by user during class construction)
307  int numRegions; //the number of regions currently stored by the
308  //region list
309  int freeRegion; //an index into the regionList pointing to the next
310  //available region in the regionList
311 
312  //#####################################
313  //### INDEX TABLE ###
314  //#####################################
315 
316  int *indexTable; //an array of indexes that point into an external structure
317  //specifying which points belong to a region
318  int freeBlockLoc; //points to the next free block of memory in the indexTable
319 
320  //#####################################
321  //### INPUT DATA PARAMETERS ###
322  //#####################################
323 
324  //Dimension of data set
325  int N; //dimension of data set being classified by region list
326  //class
327 
328  //Length of the data set
329  int L; //number of points contained by the data set being classified by
330  //region list class
331 
332 };
333 
334 #endif
335 
336 
337