Go to the documentation of this file.
   29 #ifndef __LABELING_H__ 
   30 #define __LABELING_H__ 
   38 #define CLEAR_DST_BUFFER                1 
   39 #define CLEAR_ALL_DST_BUFFER    0 
   40 #define CALC_CENTER_OF_GRAVITY  1 
   42 template<
class SrcT, 
class DstT>
 
   56                                            const int n_y, 
const SrcT n_source_value )
 
  131         typedef typename std::list<RasterSegment *>::iterator   
RSPIterator;
 
  148 #if CALC_CENTER_OF_GRAVITY 
  216                                    const int n_max_x, 
const int n_max_y )
 
  218                         SetMin( n_min_x, n_min_y );
 
  219                         SetMax( n_max_x, n_max_y );
 
  221                                           ( n_min_y + n_max_y ) / 2.0
f );
 
  222                         SetSize( n_max_x - n_min_x + 1, n_max_y - n_min_y + 1 );
 
  332                         bool    b = ( 
l.GetNumOfPixels() < 
r.GetNumOfPixels());
 
  345                         s << 
"center: "        << cx << 
"," << cy << std::endl;
 
  348                         s << 
"size:   "        << 
x << 
"," << y << std::endl;
 
  351                         s << 
"min:    "        << 
x << 
"," << y << std::endl;
 
  354                         s << 
"max:    "        << 
x << 
"," << y << std::endl;
 
  356 #if CALC_CENTER_OF_GRAVITY 
  358                         s << 
"center_of_graivty: " << cx << 
"," << cy << std::endl;
 
  361                         s << 
"source_value: "   
  364                           << 
static_cast<int>( ri.
GetResult())      << std::endl;
 
  399                                          const int y, 
const SrcT src_value )
 
  413                 int     rs_seed_lx = rs_seed->
LeftX();
 
  414                 int     rs_seed_rx = rs_seed->
RightX();
 
  417                 rspi = rspl_p->begin();
 
  420                 if ( rspi == rspl_p->end()) {
 
  424                 while (( *rspi )->RightX() < rs_seed_lx ) {
 
  426                         if ( rspi == rspl_p->end()) {
 
  431                 while (( rs = *rspi )->LeftX() <= rs_seed_rx ) {
 
  433                                 rspi = rspl_p->erase( rspi );
 
  438                         if ( rspi == rspl_p->end()) {
 
  446                 while ( rspi != rspl_p->end()) {
 
  449                                  && rs_seed_lx <= rs->RightX()
 
  450                                  && rs_seed_rx >= rs->
LeftX()) {
 
  451                                 rspi = rspl_p->erase( rspi );
 
  462                                                   const DstT region_num )
 
  466                 int     num_of_pixels = 0;
 
  471                 min_x = rs_seed->
LeftX();
 
  472                 max_x = rs_seed->
RightX();
 
  473                 min_y = max_y = rs_seed->
Y();
 
  476 #if CALC_CENTER_OF_GRAVITY 
  490                         if ( rs->
LeftX() < min_x ) {
 
  493                         if ( rs->
RightX() > max_x ) {
 
  496                         if ( rs->
Y() < min_y ) {
 
  498                         } 
else if ( rs->
Y() > max_y ) {
 
  501 #if CALC_CENTER_OF_GRAVITY 
  503                         sum_y += rs->
Y() * 
n;
 
  515                 ri->
SetMinMax( min_x, min_y, max_x, max_y );
 
  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;
 
  530                 bool    b = ( 
l->GetNumOfPixels() > 
r->GetNumOfPixels());
 
  531                 if ( 
l->GetNumOfPixels() == 
r->GetNumOfPixels()) {
 
  554                 for ( 
RSPIterator rspi = rspl.begin(); rspi != rspl.end(); rspi++ ) {
 
  556                         int     lx = rs->
LeftX();
 
  560                         for ( 
int i = 0; 
i < ( rx - lx + 1 ); 
i++ ) {
 
  605 #define CHECK_FOR_PHASE1        0 
  606 #define CHECK_FOR_PHASE2        0 
  610                   int target_width, 
int target_height,
 
  611                   const bool is_sort_region,
 
  612                   const int region_size_min )
 
  617                 width     = target_width;
 
  639 #if ( CLEAR_DST_BUFFER || CLEAR_ALL_DST_BUFFER ) 
  643 #if CLEAR_ALL_DST_BUFFER 
  648                         for ( 
int y = 0; y < 
height; y++ ) {
 
  650                                 int     current_src_value = 0;
 
  652                                         if ( *
p != current_src_value ) {
 
  653                                                 if ( current_src_value != 0 ) { 
 
  656                                                 current_src_value = *
p;
 
  659 #if ( CLEAR_DST_BUFFER && !CLEAR_ALL_DST_BUFFER ) 
  667                                 if ( current_src_value != 0 ) {
 
  672                         for ( 
int y = 0; y < 
height; y++ ) {
 
  674                                 int     current_src_value = 0;
 
  676                                         if ( *
p != current_src_value ) {
 
  677                                                 if ( current_src_value != 0 ) { 
 
  680                                                 current_src_value = *
p;
 
  685                                 if ( current_src_value != 0 ) {
 
  692                 for ( 
int y = 0; y < 
height; y++ ) {
 
  696                         for ( 
i = rspl_p->begin(); 
i != rspl_p->end(); 
i++ ) {
 
  711                 for ( 
int y = 0; y < 
height; y++ ) {
 
  713                         while ( rspl_p->size() > 0 ) {
 
  716                                 rspl_p->erase( rspi );                  
 
  726                 for ( 
int y = 0; y < 
height; y++ ) {
 
  728                                 cout << 
"mmmm" << y << endl;
 
  743                 cout << 
"num_of_pixels: " << n_p << endl;
 
  758                 if ( is_sort_region ) {
 
  767                 if ( is_sort_region && region_size_min > 0 ) {
 
  771                                         >= region_size_min ) {
 
  807 #endif  // __LABELING_H__ 
  
void Push(RasterSegment *rs)
static const int DEFAULT_REGION_SIZE_MIN
Labeling< short, short >::RegionInfo RegionInfoSS
std::list< RasterSegment * >::iterator RSPIterator
void SetMinMax(const int n_min_x, const int n_min_y, const int n_max_x, const int n_max_y)
RIPVector result_region_info
void GetMax(int &x, int &y) const
void SetSourceValue(const SrcT n_source_value)
int num_of_result_regions
int GetNumOfResultRegions(void) const
friend std::ostream & operator<<(std::ostream &s, RasterSegment &rs)
Labeling< short, short > LabelingSS
void SetResult(const DstT n_result)
void SetMax(const int x, const int y)
friend bool operator<(const RegionInfo &l, const RegionInfo &r)
void SetCenter(const float x, const float y)
int num_of_raster_segments
int Exec(SrcT *target, DstT *result, int target_width, int target_height, const bool is_sort_region, const int region_size_min)
void SetSize(const int x, const int y)
int GetRightX(void) const
RegionInfo * GetResultRegionInfo(const int num) const
Labeling< unsigned char, short >::RegionInfo RegionInfoBS
int GetNumOfPixels(void) const
RegionInfo * ConnectRasterSegment(RasterSegment *rs_seed, const DstT region_num)
void RegisterSegment(const int lx, const int rx, const int y, const SrcT src_value)
static bool RevCompRegionInfoPointer(const RegionInfo *const &l, const RegionInfo *const &r)
friend std::ostream & operator<<(std::ostream &s, RegionInfo &ri)
std::queue< RasterSegment * > RSPQueue
int GetNumOfRegions(void) const
RasterSegment(const int n_left_x, const int n_right_x, const int n_y, const SrcT n_source_value)
SrcT GetSourceValue(void) const
void FillFrame(RegionInfo *ri, const DstT fill_value)
std::list< RegionInfo * > RIPList
RSPList * raster_segment_list
void GetMin(int &x, int &y) const
Labeling< unsigned char, short > LabelingBS
void SetMin(const int x, const int y)
std::list< RegionInfo * >::iterator RIPIterator
void SearchNeighboringSegment(RasterSegment *rs_seed, const int dy)
void GetSize(int &x, int &y) const
int GetNumOfRasterSegments(void)
RSPList & GetRasterSegmentList(void)
RSPList raster_segment_list
void SetCenterOfGravity(const float x, const float y)
SrcT GetSourceValue(void) const
void SetNumOfPixels(const int n_num_of_pixels)
DstT GetResult(void) const
void Pop(RasterSegment *&rs)
std::vector< RegionInfo * > RIPVector
void GetCenter(float &x, float &y) const
std::list< RasterSegment * > RSPList
void GetCenterOfGravity(float &x, float &y) const
SrcT SourceValue(void) const
jsk_perception
Author(s): Manabu Saito, Ryohei Ueda 
autogenerated on Fri May 16 2025 03:11:17