Labeling.h
Go to the documentation of this file.
1 /* Labeling.h
2  *
3  * Copyright (c) 2010, IMURA Masataka.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
17  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __LABELING_H__
30 #define __LABELING_H__
31 
32 #include <iostream>
33 
34 #include <algorithm>
35 #include <list>
36 #include <queue>
37 
38 #define CLEAR_DST_BUFFER 1
39 #define CLEAR_ALL_DST_BUFFER 0
40 #define CALC_CENTER_OF_GRAVITY 1
41 
42 template<class SrcT, class DstT>
43 class Labeling {
44 public:
45 
46  // raster segment /////////////////////////////////////////////////////////
47 
48  class RasterSegment {
49  private:
50  int left_x;
51  int right_x;
52  int y;
54  public:
55  RasterSegment( const int n_left_x, const int n_right_x,
56  const int n_y, const SrcT n_source_value )
57  : left_x( n_left_x ), right_x( n_right_x ), y( n_y ),
58  source_value( n_source_value )
59  {
60  }
61 
63  {
64  }
65 
66  // get
67 
68  inline int
69  GetLeftX( void ) const
70  {
71  return left_x;
72  }
73 
74  inline int
75  GetRightX( void ) const
76  {
77  return right_x;
78  }
79 
80  inline int
81  GetY( void ) const
82  {
83  return y;
84  }
85 
86  inline SrcT
87  GetSourceValue( void ) const
88  {
89  return source_value;
90  }
91 
92  // get (short version)
93 
94  inline int
95  LeftX( void ) const
96  {
97  return left_x;
98  }
99 
100  inline int
101  RightX( void ) const
102  {
103  return right_x;
104  }
105 
106  inline int
107  Y( void ) const
108  {
109  return y;
110  }
111 
112  inline SrcT
113  SourceValue( void ) const
114  {
115  return source_value;
116  }
117 
118  friend std::ostream&
119  operator<<( std::ostream& s, RasterSegment& rs )
120  {
121  s << rs.LeftX() << " "
122  << rs.RightX() << " "
123  << rs.Y() << " "
124  << rs.SourceValue() << std::endl;
125 
126  return s;
127  }
128  };
129 
130  typedef std::list<RasterSegment *> RSPList;
131  typedef typename std::list<RasterSegment *>::iterator RSPIterator;
132 
133  typedef std::queue<RasterSegment *> RSPQueue;
134 
135  // information about region ///////////////////////////////////////////////
136 
137  class RegionInfo {
138 
139  private:
141  float center_x, center_y;
142  int size_x, size_y;
143  int min_x, min_y;
144  int max_x, max_y;
146  DstT result;
148 #if CALC_CENTER_OF_GRAVITY
149  float gravity_x, gravity_y;
150 #endif
151  public:
152  // constructor and destructor
153 
155  {
156  raster_segment_list.clear();
157  }
158 
160  {
161  RSPIterator rspi;
162  for ( rspi = raster_segment_list.begin();
163  rspi != raster_segment_list.end(); rspi++ ) {
164  RasterSegment *rs = *rspi;
165  delete rs;
166  }
167  raster_segment_list.erase( raster_segment_list.begin(),
168  raster_segment_list.end());
169  }
170 
171  // a default copy constucter and an assignment operator
172  // are suitable for this class.
173 
174  // declaration of functions
175 
176  // inline functions
177 
178  // set
179 
180  inline void
181  SetNumOfPixels( const int n_num_of_pixels )
182  {
183  num_of_pixels = n_num_of_pixels;
184  }
185 
186  inline void
187  SetCenter( const float x, const float y )
188  {
189  center_x = x;
190  center_y = y;
191  }
192 
193  inline void
194  SetSize( const int x, const int y )
195  {
196  size_x = x;
197  size_y = y;
198  }
199 
200  inline void
201  SetMin( const int x, const int y )
202  {
203  min_x = x;
204  min_y = y;
205  }
206 
207  inline void
208  SetMax( const int x, const int y )
209  {
210  max_x = x;
211  max_y = y;
212  }
213 
214  inline void
215  SetMinMax( const int n_min_x, const int n_min_y,
216  const int n_max_x, const int n_max_y )
217  {
218  SetMin( n_min_x, n_min_y );
219  SetMax( n_max_x, n_max_y );
220  SetCenter(( n_min_x + n_max_x ) / 2.0f,
221  ( n_min_y + n_max_y ) / 2.0f );
222  SetSize( n_max_x - n_min_x + 1, n_max_y - n_min_y + 1 );
223  }
224 
225  inline void
226  SetCenterOfGravity( const float x, const float y )
227  {
228  gravity_x = x;
229  gravity_y = y;
230  }
231 
232  inline void
233  SetSourceValue( const SrcT n_source_value )
234  {
235  source_value = n_source_value;
236  }
237 
238  inline void
239  SetResult( const DstT n_result )
240  {
241  result = n_result;
242  }
243 
244  // get
245 
246  inline int
247  GetNumOfPixels( void ) const
248  {
249  return num_of_pixels;
250  }
251 
252  inline void
253  GetCenter( float& x, float& y ) const
254  {
255  x = center_x;
256  y = center_y;
257  }
258 
259  inline void
260  GetSize( int& x, int& y ) const
261  {
262  x = size_x;
263  y = size_y;
264  }
265 
266  inline void
267  GetMin( int& x, int& y ) const
268  {
269  x = min_x;
270  y = min_y;
271  }
272 
273  inline void
274  GetMax( int& x, int& y ) const
275  {
276  x = max_x;
277  y = max_y;
278  }
279 
280  inline void
281  GetCenterOfGravity( float& x, float& y ) const
282  {
283  x = gravity_x;
284  y = gravity_y;
285  }
286 
287  inline SrcT
288  GetSourceValue( void ) const
289  {
290  return source_value;
291  }
292 
293  inline DstT
294  GetResult( void ) const
295  {
296  return result;
297  }
298 
299  // list
300 
301  inline RSPList&
303  {
304  return raster_segment_list;
305  }
306 
307  inline void
309  {
310  raster_segment_list.push_front( rs );
311  }
312 
313  inline void
314  Pop( RasterSegment * & rs )
315  {
316  RSPIterator rspi = raster_segment_list.begin();
317  rs = *rspi;
318  raster_segment_list.erase( rspi );
319  }
320 
321  inline int
323  {
324  return raster_segment_list.size();
325  }
326 
327  // operators
328 
329  friend bool
330  operator<( const RegionInfo& l, const RegionInfo& r )
331  {
332  bool b = ( l.GetNumOfPixels() < r.GetNumOfPixels());
333  return b;
334  }
335 
336  friend std::ostream&
337  operator<<( std::ostream& s, RegionInfo& ri )
338  {
339  int x, y;
340  float cx, cy;
341 
342  s << "num_of_pixels: " << ri.GetNumOfPixels() << std::endl;
343 
344  ri.GetCenter( cx, cy );
345  s << "center: " << cx << "," << cy << std::endl;
346 
347  ri.GetSize( x, y );
348  s << "size: " << x << "," << y << std::endl;
349 
350  ri.GetMin( x, y );
351  s << "min: " << x << "," << y << std::endl;
352 
353  ri.GetMax( x, y );
354  s << "max: " << x << "," << y << std::endl;
355 
356 #if CALC_CENTER_OF_GRAVITY
357  ri.GetCenterOfGravity( cx, cy );
358  s << "center_of_graivty: " << cx << "," << cy << std::endl;
359 #endif
360 
361  s << "source_value: "
362  << static_cast<int>( ri.GetSourceValue()) << std::endl
363  << "result: "
364  << static_cast<int>( ri.GetResult()) << std::endl;
365 
366  return s;
367  }
368  };
369 
370  typedef std::list<RegionInfo *> RIPList;
371  typedef typename std::list<RegionInfo *>::iterator RIPIterator;
372 
373  typedef std::vector<RegionInfo *> RIPVector;
374 
375 private:
376  static const int DEFAULT_REGION_SIZE_MIN = 10;
377 
378  SrcT *src_frame;
379  DstT *dst_frame;
380  int width;
381  int height;
383 
386 
387  RSPQueue seed_queue;
388 
391 
394 
395  // private functions
396 
397  void
398  RegisterSegment( const int lx, const int rx,
399  const int y, const SrcT src_value )
400  {
401  RasterSegment *rs = new RasterSegment( lx, rx, y, src_value );
402 
403  raster_segment_list[ y ].push_back( rs );
404  num_of_raster_segments++;
405  }
406 
407  void
408  SearchNeighboringSegment( RasterSegment *rs_seed, const int dy )
409  {
410  RSPList *rspl_p = &raster_segment_list[ rs_seed->Y() + dy ];
411  RSPIterator rspi;
412 
413  int rs_seed_lx = rs_seed->LeftX();
414  int rs_seed_rx = rs_seed->RightX();
415  int rs_seed_source_value = rs_seed->SourceValue();
416 
417  rspi = rspl_p->begin();
418 
419 #if 1
420  if ( rspi == rspl_p->end()) {
421  return;
422  }
423 
424  while (( *rspi )->RightX() < rs_seed_lx ) {
425  rspi++;
426  if ( rspi == rspl_p->end()) {
427  return;
428  }
429  }
430  RasterSegment *rs;
431  while (( rs = *rspi )->LeftX() <= rs_seed_rx ) {
432  if ( rs_seed_source_value == rs->SourceValue()) {
433  rspi = rspl_p->erase( rspi );
434  seed_queue.push( rs );
435  } else {
436  rspi++;
437  }
438  if ( rspi == rspl_p->end()) {
439  return;
440  }
441  }
442 
443  return;
444 #endif
445 #if 0
446  while ( rspi != rspl_p->end()) {
447  RasterSegment *rs = *rspi;
448  if ( rs_seed_source_value == rs->SourceValue()
449  && rs_seed_lx <= rs->RightX()
450  && rs_seed_rx >= rs->LeftX()) {
451  rspi = rspl_p->erase( rspi );
452  seed_queue.push( rs );
453  } else {
454  rspi++;
455  }
456  }
457 #endif
458  }
459 
460  RegionInfo *
462  const DstT region_num )
463  {
464  RegionInfo *ri = new RegionInfo;
465 
466  int num_of_pixels = 0;
467  int min_x, min_y;
468  int max_x, max_y;
469  SrcT source_value;
470 
471  min_x = rs_seed->LeftX();
472  max_x = rs_seed->RightX();
473  min_y = max_y = rs_seed->Y();
474  source_value = rs_seed->SourceValue();
475 
476 #if CALC_CENTER_OF_GRAVITY
477  int sum_x = 0;
478  int sum_y = 0;
479 #endif
480 
481  seed_queue.push( rs_seed );
482 
483  while ( seed_queue.size() > 0 ) {
484  RasterSegment *rs = seed_queue.front();
485  seed_queue.pop();
486  ri->Push( rs );
487 
488  int n = rs->RightX() - rs->LeftX() + 1;
489  num_of_pixels += n;
490  if ( rs->LeftX() < min_x ) {
491  min_x = rs->LeftX();
492  }
493  if ( rs->RightX() > max_x ) {
494  max_x = rs->RightX();
495  }
496  if ( rs->Y() < min_y ) {
497  min_y = rs->Y();
498  } else if ( rs->Y() > max_y ) {
499  max_y = rs->Y();
500  }
501 #if CALC_CENTER_OF_GRAVITY
502  sum_x += ( rs->LeftX() + rs->RightX()) * n;
503  sum_y += rs->Y() * n;
504 #endif
505 
506  if ( rs->Y() > 0 ) {
507  SearchNeighboringSegment( rs, -1 );
508  }
509  if ( rs->Y() < height - 1 ) {
510  SearchNeighboringSegment( rs, 1 );
511  }
512  }
513 
514  ri->SetNumOfPixels( num_of_pixels );
515  ri->SetMinMax( min_x, min_y, max_x, max_y );
516  ri->SetSourceValue( source_value );
517  ri->SetResult( region_num );
518 #if CALC_CENTER_OF_GRAVITY
519  float gx = static_cast<float>( sum_x ) / ( 2 * num_of_pixels );
520  float gy = static_cast<float>( sum_y ) / num_of_pixels;
521  ri->SetCenterOfGravity( gx, gy );
522 #endif
523  return ri;
524  }
525 
526  static bool
528  const RegionInfo * const &r )
529  {
530  bool b = ( l->GetNumOfPixels() > r->GetNumOfPixels());
531  if ( l->GetNumOfPixels() == r->GetNumOfPixels()) {
532  int lx, ly, rx, ry;
533  l->GetMin( lx, ly );
534  r->GetMin( rx, ry );
535  b = ( ly > ry );
536  }
537  return b;
538  }
539 
540  void
541  FillFrame( RegionInfo *ri, const DstT fill_value )
542  {
543 #if 0
544  while ( ri->GetNumOfRasterSegments() > 0 ) {
545  RasterSegment *rs;
546  ri->Pop( rs );
547  DstT *sp = dst_frame + rs->LeftX() + rs->Y() * width;
548  for ( int i = 0; i < rs->RightX() - rs->LeftX() + 1; i++ ) {
549  *sp++ = fill_value;
550  }
551  }
552 #endif
553  RSPList rspl = ri->GetRasterSegmentList();
554  for ( RSPIterator rspi = rspl.begin(); rspi != rspl.end(); rspi++ ) {
555  RasterSegment *rs = *rspi;
556  int lx = rs->LeftX();
557  int rx = rs->RightX();
558  int y = rs->Y();
559  DstT *sp = dst_frame + lx + y * width;
560  for ( int i = 0; i < ( rx - lx + 1 ); i++ ) {
561  *sp++ = fill_value;
562  }
563  }
564  }
565 
566 public:
567 
568  inline int
569  GetNumOfRegions( void ) const
570  {
571  return num_of_regions;
572  }
573 
574  inline int
575  GetNumOfResultRegions( void ) const
576  {
577  return num_of_result_regions;
578  }
579 
580  inline RegionInfo *
581  GetResultRegionInfo( const int num ) const
582  {
583  return result_region_info[ num ];
584  }
585 
587  {
588  raster_segment_list = 0;
589  region_info_list.clear();
590  result_region_info.clear();
591  }
592 
593  virtual ~Labeling()
594  {
595  for ( RIPIterator ripi = region_info_list.begin();
596  ripi != region_info_list.end(); ripi++ ) {
597  RegionInfo *ri = *ripi;
598  delete ri;
599  }
600  region_info_list.erase( region_info_list.begin(),
601  region_info_list.end());
602  result_region_info.clear();
603  }
604 
605 #define CHECK_FOR_PHASE1 0
606 #define CHECK_FOR_PHASE2 0
607 
608  int
609  Exec( SrcT *target, DstT *result,
610  int target_width, int target_height,
611  const bool is_sort_region,
612  const int region_size_min )
613  {
614  src_frame = target;
615  dst_frame = result;
616 
617  width = target_width;
618  height = target_height;
619  total_num = width * height;
620 
621  // phase pre1
622 
623  for ( RIPIterator ripi = region_info_list.begin();
624  ripi != region_info_list.end(); ripi++ ) {
625  RegionInfo *ri = *ripi;
626  delete ri;
627  }
628  region_info_list.erase( region_info_list.begin(),
629  region_info_list.end());
630  result_region_info.clear();
631 
632  raster_segment_list = new RSPList[ height ];
633  num_of_raster_segments = 0;
634 
635  // phase 1
636 
637  SrcT *p = src_frame;
638 
639 #if ( CLEAR_DST_BUFFER || CLEAR_ALL_DST_BUFFER )
640  DstT *q = dst_frame;
641 #endif
642  if ( src_frame != reinterpret_cast<SrcT *>( dst_frame )) {
643 #if CLEAR_ALL_DST_BUFFER
644  for ( int i = 0; i < width * height; i++ ) {
645  *q++ = 0;
646  }
647 #endif
648  for ( int y = 0; y < height; y++ ) {
649  int lx = 0;
650  int current_src_value = 0;
651  for ( int x = 0; x < width; x++ ) {
652  if ( *p != current_src_value ) {
653  if ( current_src_value != 0 ) { // raster segment
654  RegisterSegment( lx, x - 1, y, current_src_value );
655  }
656  current_src_value = *p;
657  lx = x;
658  }
659 #if ( CLEAR_DST_BUFFER && !CLEAR_ALL_DST_BUFFER )
660  if ( *p == 0 ) { // if src = 0
661  *q = 0; // clear destination buffer
662  }
663  q++;
664 #endif
665  p++;
666  }
667  if ( current_src_value != 0 ) {
668  RegisterSegment( lx, width - 1, y, current_src_value );
669  }
670  }
671  } else { // no need to clear dst_frame if src_frame = dst_frame
672  for ( int y = 0; y < height; y++ ) {
673  int lx = 0;
674  int current_src_value = 0;
675  for ( int x = 0; x < width; x++ ) {
676  if ( *p != current_src_value ) {
677  if ( current_src_value != 0 ) { // raster segment
678  RegisterSegment( lx, x - 1, y, current_src_value );
679  }
680  current_src_value = *p;
681  lx = x;
682  }
683  p++;
684  }
685  if ( current_src_value != 0 ) {
686  RegisterSegment( lx, width - 1, y, current_src_value );
687  }
688  }
689  }
690 
691 #if CHECK_FOR_PHASE1
692  for ( int y = 0; y < height; y++ ) {
693  cout << y << ":" << raster_segment_list[ y ].size() << endl;
694  RSPList *rspl_p = &raster_segment_list[ y ];
695  RSPIterator i;
696  for ( i = rspl_p->begin(); i != rspl_p->end(); i++ ) {
697  RasterSegment *rs = *i;
698  cout << *rs;
699  }
700  }
701  cout << "num_of_raster_segments: " << num_of_raster_segments << endl;
702 #endif
703 
704  // phase pre2
705 
706  region_info_list.clear();
707  num_of_regions = 0;
708 
709  // phase 2: connect
710 
711  for ( int y = 0; y < height; y++ ) {
712  RSPList *rspl_p = &raster_segment_list[ y ];
713  while ( rspl_p->size() > 0 ) {
714  RSPIterator rspi = rspl_p->begin();
715  RasterSegment *rs = *rspi; // get 1 raster segment
716  rspl_p->erase( rspi ); // remove from list
717 
718  RegionInfo *rip = ConnectRasterSegment( rs,
719  num_of_regions + 1 );
720  region_info_list.push_back( rip );
721  num_of_regions++;
722  }
723  }
724 
725 #if CHECK_FOR_PHASE2
726  for ( int y = 0; y < height; y++ ) {
727  if ( !raster_segment_list[ y ].empty()) {
728  cout << "mmmm" << y << endl;
729  }
730  }
731 
732  int n_p = 0;
733  for ( RIPIterator ripi = region_info_list.begin();
734  ripi != region_info_list.end(); ripi++ ) {
735  RegionInfo *ri = *ripi;
736  n_p += ri->GetNumOfPixels();
737  while ( ri->GetNumOfRasterSegments() > 0 ) {
738  RasterSegment *rs;
739  ri->Pop( rs );
740  cout << *rs;
741  }
742  }
743  cout << "num_of_pixels: " << n_p << endl;
744  cout << "num_of_regions: " << num_of_regions << endl;
745 #endif
746 
747  // phase 3
748  // reorder by size
749 
750  result_region_info.resize( num_of_regions );
751  int n = 0;
752  for ( RIPIterator ripi = region_info_list.begin();
753  ripi != region_info_list.end(); ripi++ ) {
754  result_region_info[ n ] = *ripi;
755  n++;
756  }
757 
758  if ( is_sort_region ) {
759  // sort result_region_info by size
760 
761  sort( result_region_info.begin(), result_region_info.end(),
763  }
764 
765  // renumber IDs of RegionInfo
766 
767  if ( is_sort_region && region_size_min > 0 ) {
768  int n = 0;
769  while ( n < num_of_regions
770  && result_region_info[ n ]->GetNumOfPixels()
771  >= region_size_min ) {
772  result_region_info[ n ]->SetResult( n + 1 );
773  n++;
774  }
775  num_of_result_regions = n;
776  for ( int i = n; i < num_of_regions; i++ ) {
777  result_region_info[ i ]->SetResult( 0 );
778  }
779  } else {
780  for ( int i = 0; i < num_of_regions; i++ ) {
781  result_region_info[ i ]->SetResult( i + 1 );
782  }
783  num_of_result_regions = num_of_regions;
784  }
785 
786  // phase 4
787  // put label number for pixels
788 
789  for ( int i = 0; i < num_of_regions; i++ ) {
790  RegionInfo *ri = result_region_info[ i ];
791  FillFrame( ri, ri->GetResult());
792  }
793 
794  // clear
795 
796  delete [] raster_segment_list;
797 
798  return 0;
799  }
800 };
801 
806 
807 #endif // __LABELING_H__
f
int GetNumOfResultRegions(void) const
Definition: Labeling.h:575
void GetSize(int &x, int &y) const
Definition: Labeling.h:260
SrcT GetSourceValue(void) const
Definition: Labeling.h:87
DstT * dst_frame
Definition: Labeling.h:379
RIPVector result_region_info
Definition: Labeling.h:392
RSPList raster_segment_list
Definition: Labeling.h:147
void SetResult(const DstT n_result)
Definition: Labeling.h:239
int Exec(SrcT *target, DstT *result, int target_width, int target_height, const bool is_sort_region, const int region_size_min)
Definition: Labeling.h:609
std::list< RasterSegment * > RSPList
Definition: Labeling.h:130
virtual ~Labeling()
Definition: Labeling.h:593
GLfloat n[6][3]
DstT GetResult(void) const
Definition: Labeling.h:294
int Y(void) const
Definition: Labeling.h:107
RSPQueue seed_queue
Definition: Labeling.h:387
Labeling< unsigned char, short > LabelingBS
Definition: Labeling.h:802
Labeling< unsigned char, short >::RegionInfo RegionInfoBS
Definition: Labeling.h:804
void Pop(RasterSegment *&rs)
Definition: Labeling.h:314
RasterSegment(const int n_left_x, const int n_right_x, const int n_y, const SrcT n_source_value)
Definition: Labeling.h:55
int num_of_result_regions
Definition: Labeling.h:393
int GetRightX(void) const
Definition: Labeling.h:75
void GetCenter(float &x, float &y) const
Definition: Labeling.h:253
void SetMinMax(const int n_min_x, const int n_min_y, const int n_max_x, const int n_max_y)
Definition: Labeling.h:215
void SetSize(const int x, const int y)
Definition: Labeling.h:194
RSPList & GetRasterSegmentList(void)
Definition: Labeling.h:302
q
int GetNumOfPixels(void) const
Definition: Labeling.h:247
int height
Definition: Labeling.h:381
void RegisterSegment(const int lx, const int rx, const int y, const SrcT src_value)
Definition: Labeling.h:398
static bool RevCompRegionInfoPointer(const RegionInfo *const &l, const RegionInfo *const &r)
Definition: Labeling.h:527
int num_of_raster_segments
Definition: Labeling.h:385
RegionInfo * GetResultRegionInfo(const int num) const
Definition: Labeling.h:581
std::queue< RasterSegment * > RSPQueue
Definition: Labeling.h:133
void SetCenterOfGravity(const float x, const float y)
Definition: Labeling.h:226
int LeftX(void) const
Definition: Labeling.h:95
friend std::ostream & operator<<(std::ostream &s, RasterSegment &rs)
Definition: Labeling.h:119
x
void SetNumOfPixels(const int n_num_of_pixels)
Definition: Labeling.h:181
void SetCenter(const float x, const float y)
Definition: Labeling.h:187
std::list< RegionInfo * >::iterator RIPIterator
Definition: Labeling.h:371
void SetMax(const int x, const int y)
Definition: Labeling.h:208
int GetY(void) const
Definition: Labeling.h:81
RegionInfo * ConnectRasterSegment(RasterSegment *rs_seed, const DstT region_num)
Definition: Labeling.h:461
int RightX(void) const
Definition: Labeling.h:101
std::list< RegionInfo * > RIPList
Definition: Labeling.h:370
Labeling< short, short >::RegionInfo RegionInfoSS
Definition: Labeling.h:805
RSPList * raster_segment_list
Definition: Labeling.h:384
void Push(RasterSegment *rs)
Definition: Labeling.h:308
std::vector< RegionInfo * > RIPVector
Definition: Labeling.h:373
void SetSourceValue(const SrcT n_source_value)
Definition: Labeling.h:233
static const int DEFAULT_REGION_SIZE_MIN
Definition: Labeling.h:376
int num_of_regions
Definition: Labeling.h:390
void SearchNeighboringSegment(RasterSegment *rs_seed, const int dy)
Definition: Labeling.h:408
std::list< RasterSegment * >::iterator RSPIterator
Definition: Labeling.h:131
int GetNumOfRasterSegments(void)
Definition: Labeling.h:322
void FillFrame(RegionInfo *ri, const DstT fill_value)
Definition: Labeling.h:541
void GetCenterOfGravity(float &x, float &y) const
Definition: Labeling.h:281
RIPList region_info_list
Definition: Labeling.h:389
int total_num
Definition: Labeling.h:382
int width
Definition: Labeling.h:380
void GetMax(int &x, int &y) const
Definition: Labeling.h:274
SrcT SourceValue(void) const
Definition: Labeling.h:113
int GetNumOfRegions(void) const
Definition: Labeling.h:569
int GetLeftX(void) const
Definition: Labeling.h:69
SrcT GetSourceValue(void) const
Definition: Labeling.h:288
Labeling< short, short > LabelingSS
Definition: Labeling.h:803
void SetMin(const int x, const int y)
Definition: Labeling.h:201
void GetMin(int &x, int &y) const
Definition: Labeling.h:267
SrcT * src_frame
Definition: Labeling.h:378
Labeling()
Definition: Labeling.h:586


jsk_perception
Author(s): Manabu Saito, Ryohei Ueda
autogenerated on Mon May 3 2021 03:03:27