segmentation
All Data Structures Namespaces Files Functions Variables Modules Pages
msImageProcessor.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  Mean Shift Image Processor Class:
13  ================================
14 
15  The following class inherits from the mean shift library
16  in order to perform the specialized tasks of image
17  segmentation and filtering.
18 
19  The prototype of the Mean Shift Image Processor Class
20  is provided below. Its definition is provided in
21  'msImageProcessor.cc'.
22 
23 The theory is described in the papers:
24 
25  D. Comaniciu, P. Meer: Mean Shift: A robust approach toward feature
26  space analysis.
27 
28  C. Christoudias, B. Georgescu, P. Meer: Synergism in low level vision.
29 
30 and they are is available at:
31  http://www.caip.rutgers.edu/riul/research/papers/
32 
33 Implemented by Chris M. Christoudias, Bogdan Georgescu
34 ********************************************************/
35 
36 #ifndef msImageProcessor_H
37 #define msImageProcessor_H
38 
39 //include mean shift library
40 #include "ms.h"
41 
42 //include prototypes of additional strucuters
43 //used for image segmentation...
44 
45 //include region list used to store boundary pixel
46 //indeces for each region
47 #include "rlist.h"
48 
49 //include region adjacency list class used for
50 //region pruning and transitive closure
51 #include "RAList.h"
52 
53 //define constants
54 
55  //image pruning
56 #define TOTAL_ITERATIONS 14
57 #define BIG_NUM 0xffffffff //BIG_NUM = 2^32-1
58 #define NODE_MULTIPLE 10
59 
60  //data space conversion...
61 const double Xn = 0.95050;
62 const double Yn = 1.00000;
63 const double Zn = 1.08870;
64 //const double Un_prime = 0.19780;
65 //const double Vn_prime = 0.46830;
66 const double Un_prime = 0.19784977571475;
67 const double Vn_prime = 0.46834507665248;
68 const double Lt = 0.008856;
69 
70  //RGB to LUV conversion
71 const double XYZ[3][3] = { { 0.4125, 0.3576, 0.1804 },
72  { 0.2125, 0.7154, 0.0721 },
73  { 0.0193, 0.1192, 0.9502 } };
74 
75  //LUV to RGB conversion
76 const double RGB[3][3] = { { 3.2405, -1.5371, -0.4985 },
77  { -0.9693, 1.8760, 0.0416 },
78  { 0.0556, -0.2040, 1.0573 } };
79 
80 //define data types
81 typedef unsigned char byte;
82 
83 //define enumerations
84 enum imageType {GRAYSCALE, COLOR};
85 
86 //define prototype
87 class msImageProcessor: public MeanShift {
88 
89 public:
90 
91  /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
92  /* Class Constructor and Destructor */
93  /*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
94 
95  msImageProcessor( void ); //Default Constructor
96  ~msImageProcessor( void ); //Class Destructor
97 
98  /*/\/\/\/\/\/\/\/\/\/\/\/\/\*/
99  /* Input Image Declaration */
100  /*\/\/\/\/\/\/\/\/\/\/\/\/\/*/
101 
102  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
103  //<--------------------------------------------------->|//
104  //| |//
105  //| Method Name: |//
106  //| ============ |//
107  //| * Define Image * |//
108  //| |//
109  //<--------------------------------------------------->|//
110  //| |//
111  //| Description: |//
112  //| ============ |//
113  //| |//
114  //| Uploads an image to be segmented by the image |//
115  //| segmenter class. |//
116  //| |//
117  //| An image is defined by specifying the folloing: |//
118  //| |//
119  //| <* data *> |//
120  //| A one dimensional unsigned char array of RGB |//
121  //| vectors. |//
122  //| |//
123  //| <* type *> |//
124  //| Specifies the image type: COLOR or GREYSCALE. |//
125  //| |//
126  //| <* height *> |//
127  //| The image height. |//
128  //| |//
129  //| <* width *> |//
130  //| The image width. |//
131  //| |//
132  //| This method uploads the image and converts its |//
133  //| data into the LUV space. If another conversion |//
134  //| is desired data may be uploaded into this class |//
135  //| via the procedure MeanShift::UploadInput(). |//
136  //| |//
137  //<--------------------------------------------------->|//
138  //| |//
139  //| Usage: |//
140  //| ====== |//
141  //| DefineImage(data, type, height, width) |//
142  //| |//
143  //<--------------------------------------------------->|//
144  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
145 
146  void DefineImage(byte*,imageType, int, int);
147  void DefineBgImage(byte*, imageType , int , int );
148 
149 
150  /*/\/\/\/\/\/\*/
151  /* Weight Map */
152  /*\/\/\/\/\/\/*/
153 
154  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
155  //<--------------------------------------------------->|//
156  //| |//
157  //| Method Name: |//
158  //| ============ |//
159  //| * Set Weight Map * |//
160  //| |//
161  //<--------------------------------------------------->|//
162  //| |//
163  //| Description: |//
164  //| ============ |//
165  //| |//
166  //| Uploads weight map specifying for each pixel |//
167  //| in the image a value between 0 and 1 - 1 indica- |//
168  //| ting the presence of an edge and 0 the absense |//
169  //| of an edge. |//
170  //| |//
171  //| The arguments to this method are: |//
172  //| |//
173  //| <* weightMap *> |//
174  //| A floating point array of size (height x width) |//
175  //| specifying at location (i,j) the edge strength |//
176  //| of pixel (i,j). (e.g. pixel (i,j) has an edge |//
177  //| strength of weightMap[j*width+i]). |//
178  //| |//
179  //| <* epsilon *> |//
180  //| A floating point number specifying the threshold |//
181  //| used to fuse regions during transitive closure. |//
182  //| |//
183  //| Note: DefineImage must be called prior to call- |//
184  //| ing this method. DefineImage is used to |//
185  //| define the dimensions of the image. |//
186  //| |//
187  //<--------------------------------------------------->|//
188  //| |//
189  //| Usage: |//
190  //| ====== |//
191  //| SetWeightMap(weightMap, epsilon) |//
192  //| |//
193  //<--------------------------------------------------->|//
194  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
195 
196  void SetWeightMap(float*, float);
197 
198  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
199  //<--------------------------------------------------->|//
200  //| |//
201  //| Method Name: |//
202  //| ============ |//
203  //| * Remove Weight Map * |//
204  //| |//
205  //<--------------------------------------------------->|//
206  //| |//
207  //| Description: |//
208  //| ============ |//
209  //| |//
210  //| Removes weight map. An error is NOT flagged |//
211  //| if a weight map was not defined prior to calling |//
212  //| this method. |//
213  //| |//
214  //<--------------------------------------------------->|//
215  //| |//
216  //| Usage: |//
217  //| ====== |//
218  //| RemoveWeightMap(void) |//
219  //| |//
220  //<--------------------------------------------------->|//
221  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
222 
223  void RemoveWeightMap(void);
224 
225  /*/\/\/\/\/\/\/\/\/\*/
226  /* Image Filtering */
227  /*\/\/\/\/\/\/\/\/\/*/
228 
229  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
230  //<--------------------------------------------------->|//
231  //| |//
232  //| Method Name: |//
233  //| ============ |//
234  //| * Filter * |//
235  //| |//
236  //<--------------------------------------------------->|//
237  //| |//
238  //| Description: |//
239  //| ============ |//
240  //| |//
241  //| Apply mean shift filter to the defined image, |//
242  //| defined either via MeanShift::DefineLInput or |//
243  //| msImageProcessor::DefineImage. The resulting |//
244  //| segmented image is stored in the private data |//
245  //| members of the image segmenter class which can |//
246  //| be obtained by calling image msImageProcessor:: |//
247  //| GetResults(). |//
248  //| |//
249  //| The arguments to this method are: |//
250  //| |//
251  //| <* sigmaS *> |//
252  //| The spatial radius of the mean shift window. |//
253  //| |//
254  //| <* sigmaR *> |//
255  //| The range radius of the mean shift window. |//
256  //| |//
257  //| <* speedUpLevel *> |//
258  //| Determines if a speed up optimization should be |//
259  //| used to perform image filtering. A value of |//
260  //| NO_SPEEDUP turns this optimization off and a |//
261  //| value of SPEEDUP turns this optimization on. |//
262  //| |//
263  //<--------------------------------------------------->|//
264  //| |//
265  //| Usage: |//
266  //| ====== |//
267  //| Filter(sigmaS, sigmaR, speedUpLevel) |//
268  //| |//
269  //<--------------------------------------------------->|//
270  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
271 
272  void Filter(int, float, SpeedUpLevel);
273 
274  /*/\/\/\/\/\/\/\/\/\/\/\*/
275  /* Image Region Fusing */
276  /*\/\/\/\/\/\/\/\/\/\/\/*/
277 
278  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
279  //<--------------------------------------------------->|//
280  //| |//
281  //| Method Name: |//
282  //| ============ |//
283  //| * Fuse Regions * |//
284  //| |//
285  //<--------------------------------------------------->|//
286  //| |//
287  //| Description: |//
288  //| ============ |//
289  //| |//
290  //| Fuses the regions of a filtered image, |//
291  //| defined either via MeanShift::DefineLInput or |//
292  //| msImageProcessor::DefineImage. The resulting |//
293  //| segmented image is stored in the private data |//
294  //| members of the image segmenter class which can |//
295  //| be obtained by calling image msImageProcessor:: |//
296  //| GetResults(). |//
297  //| |//
298  //| The arguments to this method are: |//
299  //| |//
300  //| <* sigmaR *> |//
301  //| The range radius that defines similar color |//
302  //| amongst image regions. |//
303  //| |//
304  //| <* minRegion *> |//
305  //| The minimum density a region may have in the |//
306  //| resulting segmented image. All regions have |//
307  //| point density < minRegion are pruned from the |//
308  //| image. |//
309  //| |//
310  //<--------------------------------------------------->|//
311  //| |//
312  //| Usage: |//
313  //| ====== |//
314  //| FuseRegions(sigmaR, minRegion) |//
315  //| |//
316  //<--------------------------------------------------->|//
317  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
318 
319  void FuseRegions(float, int);
320 
321  /*/\/\/\/\/\/\/\/\/\/\*/
322  /* Image Segmentation */
323  /*\/\/\/\/\/\/\/\/\/\/*/
324 
325  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
326  //<--------------------------------------------------->|//
327  //| |//
328  //| Method Name: |//
329  //| ============ |//
330  //| * Segment * |//
331  //| |//
332  //<--------------------------------------------------->|//
333  //| |//
334  //| Description: |//
335  //| ============ |//
336  //| |//
337  //| Segments the defined image, defined either via |//
338  //| MeanShift::DefineLInput or msImageProcessor::De- |//
339  //| fineImage. The resulting segmented image is |//
340  //| stored in the private data members of the image |//
341  //| processor class which can be obtained by calling |//
342  //| ImageSegmenter::GetResults(). |//
343  //| |//
344  //| The arguments to this method are: |//
345  //| |//
346  //| <* sigmaS *> |//
347  //| The spatial radius of the mean shift window. |//
348  //| |//
349  //| <* sigmaR *> |//
350  //| The range radius of the mean shift window. |//
351  //| |//
352  //| <* minRegion *> |//
353  //| The minimum density a region may have in the |//
354  //| resulting segmented image. All regions have |//
355  //| point density < minRegion are pruned from the |//
356  //| image. |//
357  //| |//
358  //| <* speedUpLevel *> |//
359  //| Determines if a speed up optimization should be |//
360  //| used to perform image filtering. A value of |//
361  //| NO_SPEEDUP turns this optimization off and a |//
362  //| value of SPEEDUP turns this optimization on. |//
363  //| |//
364  //<--------------------------------------------------->|//
365  //| |//
366  //| Usage: |//
367  //| ====== |//
368  //| Segment(sigmaS, sigmaR, minRegion, |//
369  //| speedUpLevel) |//
370  //| |//
371  //<--------------------------------------------------->|//
372  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
373 
374  void Segment(int, float, int, SpeedUpLevel);
375 
376  /*/\/\/\/\/\/\/\/\/\/\/\/\*/
377  /* Data Space Conversion */
378  /*\/\/\/\/\/\/\/\/\/\/\/\/*/
379 
380  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
381  //<--------------------------------------------------->|//
382  //| |//
383  //| Method Name: |//
384  //| ============ |//
385  //| * RGB To LUV * |//
386  //| |//
387  //<--------------------------------------------------->|//
388  //| |//
389  //| Description: |//
390  //| ============ |//
391  //| |//
392  //| Converts an RGB vector to LUV. |//
393  //| |//
394  //| The arguments to this method are: |//
395  //| |//
396  //| <* rgbVal *> |//
397  //| An unsigned char array containing the RGB |//
398  //| vector. |//
399  //| |//
400  //| <* luvVal *> |//
401  //| A floating point array containing the LUV |//
402  //| vector. |//
403  //| |//
404  //<--------------------------------------------------->|//
405  //| |//
406  //| Usage: |//
407  //| ====== |//
408  //| RGBtoLUV(rgbVal, luvVal) |//
409  //| |//
410  //<--------------------------------------------------->|//
411  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
412 
413  void RGBtoLUV(byte*, float*);
414 
415  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
416  //<--------------------------------------------------->|//
417  //| |//
418  //| Method Name: |//
419  //| ============ |//
420  //| * LUV To RGB * |//
421  //| |//
422  //<--------------------------------------------------->|//
423  //| |//
424  //| Description: |//
425  //| ============ |//
426  //| |//
427  //| Converts an LUV vector to RGB. |//
428  //| |//
429  //| The arguments to this method are: |//
430  //| |//
431  //| <* luvVal *> |//
432  //| A floating point array containing the LUV |//
433  //| vector. |//
434  //| |//
435  //| <* rgbVal *> |//
436  //| An unsigned char array containing the RGB |//
437  //| vector. |//
438  //| |//
439  //<--------------------------------------------------->|//
440  //| |//
441  //| Usage: |//
442  //| ====== |//
443  //| LUVtoRGB(luvVal, rgbVal) |//
444  //| |//
445  //<--------------------------------------------------->|//
446  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
447 
448  void LUVtoRGB(float*, byte*);
449 
450  /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
451  /* Filtered and Segmented Image Output */
452  /*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
453 
454  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
455  //<--------------------------------------------------->|//
456  //| |//
457  //| Method Name: |//
458  //| ============ |//
459  //| * Get Raw Data * |//
460  //| |//
461  //<--------------------------------------------------->|//
462  //| |//
463  //| Description: |//
464  //| ============ |//
465  //| |//
466  //| Returns the resulting filtered or segmented im- |//
467  //| age data after calling Filter() or Segment(). |//
468  //| |//
469  //| The arguments to this method are: |//
470  //| |//
471  //| <* outputImageData *> |//
472  //| A floating point array containing the vector |//
473  //| data of the filtered or segmented image. |//
474  //| |//
475  //| NOTE: If DefineImage was used to specify the |//
476  //| the input to this class, outputImageData |//
477  //| is in the LUV data space. |//
478  //| |//
479  //<--------------------------------------------------->|//
480  //| |//
481  //| Usage: |//
482  //| ====== |//
483  //| GetResults(outputImageData) |//
484  //| |//
485  //<--------------------------------------------------->|//
486  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
487 
488  void GetRawData(float*);
489 
490  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
491  //<--------------------------------------------------->|//
492  //| |//
493  //| Method Name: |//
494  //| ============ |//
495  //| * Get Results * |//
496  //| |//
497  //<--------------------------------------------------->|//
498  //| |//
499  //| Description: |//
500  //| ============ |//
501  //| |//
502  //| Returns the resulting filtered or segmented im- |//
503  //| age after calling Filter() or Segment(). |//
504  //| |//
505  //| The arguments to this method are: |//
506  //| |//
507  //| <* outputImage *> |//
508  //| An unsigned char array containing the RGB |//
509  //| vector data of the output image. |//
510  //| |//
511  //| To obtain the un-converted (LUV) data space |//
512  //| output one may use |//
513  //| msImageProcessor::GetRawData(). |//
514  //<--------------------------------------------------->|//
515  //| |//
516  //| Usage: |//
517  //| ====== |//
518  //| GetResults(outputImage) |//
519  //| |//
520  //<--------------------------------------------------->|//
521  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
522 
523  void GetResults(byte*);
524 
525  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
526  //<--------------------------------------------------->|//
527  //| |//
528  //| Method Name: |//
529  //| ============ |//
530  //| * Get Boundaries * |//
531  //| |//
532  //<--------------------------------------------------->|//
533  //| |//
534  //| Description: |//
535  //| ============ |//
536  //| |//
537  //| Returns the boundaries of each region of the |//
538  //| segmented image using a region list object, |//
539  //| available after filtering or segmenting the |//
540  //| defined image. |//
541  //| |//
542  //<--------------------------------------------------->|//
543  //| |//
544  //| Usage: |//
545  //| ====== |//
546  //| regionList = GetBoundaries() |//
547  //| |//
548  //<--------------------------------------------------->|//
549  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
550 
551  RegionList *GetBoundaries( void );
552 
553  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
554  //<--------------------------------------------------->|//
555  //| |//
556  //| Method Name: |//
557  //| ============ |//
558  //| * Get Regions * |//
559  //| |//
560  //<--------------------------------------------------->|//
561  //| |//
562  //| Description: |//
563  //| ============ |//
564  //| |//
565  //| Returns the regions of the processed image. |//
566  //| Each region in the image is uniquely character- |//
567  //| ized by its location and color (e.g. RGB). |//
568  //| GetRegions() therefore returns the following |//
569  //| information about the regions of the processed |//
570  //| image: |//
571  //| |//
572  //| <* regionCount *> |//
573  //| An integer that specifies the number of regions |//
574  //| contained in the processed image. |//
575  //| |//
576  //| <* modes *> |//
577  //| A floating point array of length regionCount*N |//
578  //| containing the feature space component of each |//
579  //| region (e.g. LUV), and indexed by region label. |//
580  //| |//
581  //| <* labels *> |//
582  //| An integer array of length (height*width) which |//
583  //| contains at every pixel location (x,y) a label |//
584  //| relating that pixel to a region whose mode is |//
585  //| specified by modes and whose area is specified |//
586  //| by modePointCounts. |//
587  //| |//
588  //| <* modePointCounts *> |//
589  //| An integer array of length regionCount and ind- |//
590  //| exed by region label, that specifies the region |//
591  //| area (in pixels) for each segmented image reg- |//
592  //| ion. (e.g. Area of region having label specif- |//
593  //| ified by l, has area modePointCounts[l] (pix- |//
594  //| els).) |//
595  //| |//
596  //| NOTE: Memory for the above integer and floating |//
597  //| point arrays is allocated inside this |//
598  //| method. |//
599  //| |//
600  //| Also modes stored by the modes array are |//
601  //| not in the RGB space. Instead if the |//
602  //| method DefineImage was used, these data |//
603  //| points are in the LUV space, and if the |//
604  //| method DefineLInput was used these data |//
605  //| points are in whatever space you specified |//
606  //| them to be in when calling DefineLInput. |//
607  //| |//
608  //<--------------------------------------------------->|//
609  //| |//
610  //| Usage: |//
611  //| ====== |//
612  //| regionCount = GetRegions(labels, modes |//
613  //| modePointCounts) |//
614  //| |//
615  //<--------------------------------------------------->|//
616  //--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//--\\||//
617 
618  int GetRegions(int**, float**, int**);
619 
620 
621  void SetSpeedThreshold(float);
622 private:
623 
624  //========================
625  // *** Private Methods ***
626  //========================
627 
628  /*/\/\/\/\/\/\/\/\/\*/
629  /* Image Filtering */
630  /*\/\/\/\/\/\/\/\/\/*/
631 
632  void NonOptimizedFilter(float, float); // filters the image applying mean shift to each point
633  // Advantage : most accurate
634  // Disadvantage : time expensive
635  void NewNonOptimizedFilter(float, float);
636 
637  void OptimizedFilter1(float, float); // filters the image using previous mode information
638  // to avoid re-applying mean shift to some data points
639  // Advantage : maintains high level of accuracy,
640  // large speed up compared to non-optimized
641  // version
642  // Disadvantage : POSSIBLY not as accurate as non-optimized
643  // version
644  void NewOptimizedFilter1(float, float);
645 
646 
647  void OptimizedFilter2(float, float); //filter the image using previous mode information
648  //and window traversals to avoid re-applying mean shift to
649  //some data points
650  // Advantage : huge speed up - maintains accuracy good enough
651  // for segmentation
652  // Disadvantage : not as accurate as previous filters
653  void NewOptimizedFilter2(float, float);
654 
655 
656  /*/\/\/\/\/\/\/\/\/\/\/\*/
657  /* Image Classification */
658  /*\/\/\/\/\/\/\/\/\/\/\/*/
659 
660  void Connect( void ); // classifies mean shift filtered image regions using
661  // private classification structure of this class
662 
663  void Fill(int, int); // used by Connect to perform label each region in the
664  // mean shift filtered image using an eight-connected
665  // fill
666 
667  /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
668  /* Transitive Closure and Image Pruning */
669  /*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
670 
671  void BuildRAM( void ); // build a region adjacency matrix using the region list
672  // object
673 
674  void DestroyRAM( void ); // destroy the region adjacency matrix: de-allocate its memory
675  // initialize it for re-use
676 
677  void TransitiveClosure( void ); // use the RAM to apply transitive closure to the image modes
678 
679  void ComputeEdgeStrengths( void ); // computes the weights of the weighted graph using the weight
680  // map
681 
682  //Usage: Prune(minRegion)
683  void Prune(int); // use the RAM to prune the image of spurious regions (regions
684  // whose area is less than minRegion pixels, where minRegion is
685  // an argument of this method)
686 
687  /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
688  /* Region Boundary Detection */
689  /*\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
690 
691  void DefineBoundaries( void ); // defines the boundaries of each region using the classified segmented
692  // image storing the resulting boundary locations for each region using
693  // a region list object
694 
695  /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
696  /* Image Data Searching/Distance Calculation */
697  /*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
698 
699  //Usage: InWindow(modeIndex1, modeIndex2)
700  bool InWindow(int, int); //returns true if the range data of the specified data points
701  //are within the defined search window (defined by kernel
702  //bandwidth h[1])
703 
704  float SqDistance(int, int); // computes the normalized square distance between two modes
705 
706  /*/\/\/\/\/\/\/\/\/\/\*/
707  /* Memory Management */
708  /*\/\/\/\/\/\/\/\/\/\/*/
709 
710  void InitializeOutput( void ); //Allocates memory needed by this class to perform image
711  //filtering and segmentation
712 
713  void DestroyOutput( void ); //De-allocates memory needed by this class to perform image
714  //filtering and segmentation
715 
716  //=============================
717  // *** Private Data Members ***
718  //=============================
719 
720  //##########################################
721  //####### IMAGE CLASSIFICATION ########
722  //##########################################
723 
725  RegionList *regionList; // stores the boundary locations for each region
726 
728  int regionCount; // stores the number of connected regions contained by the
729  // image
730 
732  int neigh[8];
733 
735  int *indexTable; //used during fill algorithm
736 
738  //int *LUV_data; //stores modes in integer format on lattice
739  float *LUV_data; //stores modes in float format on lattice
740  float LUV_treshold; //in float mode this determines what "close" means between modes
741 
742 
743  //##########################################
744  //####### OUTPUT DATA STORAGE ########
745  //##########################################
746 
748  float *msRawData; // Raw data output of mean shift algorithm
749  // to the location of the data point on the lattice
750 
752  int *labels; // assigns a label to each data point associating it to
753  // a mode in modes (e.g. a data point having label l has
754  // mode modes[l])
755 
756  float *modes; // stores the mode data of the input data set, indexed by labels
757 
758  int *modePointCounts; // stores for each mode the number of point mapped to that mode,
759  // indexed by labels
760 
761  //##########################################
762  //####### REGION ADJACENCY MATRIX ########
763  //##########################################
764 
766  RAList *raList; // an array of RAList objects containing an entry for each
767  // region of the image
768 
770  RAList *freeRAList; // a pointer to the head of a region adjacency list object
771  // free list
772 
773  RAList *raPool; // a pool of RAList objects used in the construction of the
774  // RAM
775 
776  //##############################################
777  //####### COMPUTATION OF EDGE STRENGTHS #######
778  //##############################################
779 
781  float epsilon; //Epsilon used for transitive closure
782 
784  unsigned char *visitTable; //Table used to keep track of which pixels have been
785  //already visited upon computing the boundary edge strengths
786 
787  //##########################################
788  //####### IMAGE PRUNING ########
789  //##########################################
790 
792  float rR2; //defines square range radius used when clustering pixels
793  //together, thus defining image regions
794 
795  float speedThreshold; // the % of window radius used in new optimized filter 2.
796 };
797 
798 #endif