Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BIAS::Label Class Reference

does a connected component analysis and labels all connected regions More...

#include <Filter/Label.hh>

+ Inheritance diagram for BIAS::Label:
+ Collaboration diagram for BIAS::Label:

Public Types

enum  TBorderHandling
 enum for border calculation, same meanings as in matlab: More...
 

Public Member Functions

void AddDebugLevel (const long int lv)
 
void AddDebugLevel (const std::string &name)
 
void CopyNonROIFromSource (const Image< unsigned char > &src, Image< unsigned char > &dst) const
 run over all pixel which do not belong to the roi and set them to the value in the source image regardless of the roi of the source. More...
 
bool DebugLevelIsSet (const long int lv) const
 
bool DebugLevelIsSet (const std::string &name) const
 
virtual int Filter (const Image< unsigned char > &src, Image< unsigned char > &dst)
 prototyp for filter computation function More...
 
std::vector< int > GetBlobCounts ()
 returns a list with the size of each blob, largest first, if no blobs are found a list with a single 0 is returned More...
 
std::map< unsigned char, int > GetBlobMap ()
 Returns a map that hold the blob size for each label. More...
 
void GetBlobSizes (std::vector< int > &sizes) const
 
int GetBorderHandling () const
 
void GetBorders (int &border_x, int &border_y) const
 
int GetBoundingBoxes (std::vector< BIAS::Vector2< int > > &topLefts, std::vector< BIAS::Vector2< int > > &botRights)
 returns two lists,one with the topLeft coordinates of the bounding boxes of each region and one with the botrights, sorted by size of regions (in pixel) More...
 
void GetCenters (std::vector< BIAS::Vector2< double > > &centers) const
 returns the centers of the blobs More...
 
int GetDebugLevel () const
 
std::ostream & GetDebugStream () const
 
void GetDebugStream (std::ostream &os) const
 
void GetLabelImage (Image< LABEL_CALC_TYPE > &li)
 returns in li the image where each region has a different grey value, value zero is the background region More...
 
void GetMedianCenters (std::vector< BIAS::Vector2< double > > &cts) const
 returns the median centers of the blobs More...
 
 Label ()
 
int Label4Neighbour (const BIAS::Image< unsigned char > &Image, BIAS::Image< unsigned char > &DestinationImage)
 labels an unsigned short int using an 4er neighbourhood and returns it in DestinationImage if DestinationImage is allocated it is not reallocated untested More...
 
int Label4Neighbour (const BIAS::Image< LABEL_CALC_TYPE > &Image, BIAS::Image< LABEL_CALC_TYPE > &DestinationImage)
 labels an unsigned short int using an 4er neighbourhood and returns it in DestinationImage if DestinationImage is allocated it is not reallocated More...
 
long int Name2DebugLevel (const std::string &name) const
 looks up a debuglevel in the internal map, returns 0 if not found More...
 
long int NewDebugLevel (const std::string &name)
 creates a new debuglevel More...
 
void PrintDebugLevel (std::ostream &os=std::cout) const
 
int Process (const Image< unsigned char > &im)
 call this if you don't need the output image, is faster than Filter More...
 
void RemoveDebugLevel (const long int lv)
 
void RemoveDebugLevel (const std::string &name)
 
void SetBorderHandling (const int bh)
 
void SetDebugLevel (const long int lv)
 
void SetDebugLevel (const std::string &name)
 
void SetDebugStream (const std::ostream &os)
 
void SetNonROIToValue (Image< unsigned char > &dst, const std::vector< unsigned char > &t) const
 run over all pixel which do not belong to the roi and set them to some value (typically black) More...
 
void ShowDebugLevel (std::ostream &os=std::cout) const
 prints all internally known debuglevels More...
 
 ~Label ()
 

Static Public Member Functions

static long int GetGlobalDebugLevel ()
 
static void SetGlobalDebugLevel (long int lev)
 

Protected Member Functions

long ConsumeNextFreeDebuglevel_ ()
 returns the next available debuglevel More...
 
virtual void GetBordersValid_ (int &border_x, int &border_y) const
 
int Label4Neighbour_ ()
 
void LabelInit_ (const ImageBase &Image)
 
void LabelRelease_ ()
 

Protected Attributes

int _FilterBorderHandling
 
long int _liDebugLevel
 
long int _liNextDebugLevel
 new concept, debuglevel are managed here in the debug class More...
 
std::map< std::string, long int > _String2Debuglevel
 
std::vector< int > BlobCount_
 
std::vector< BIAS::Vector2< int > > BotRights_
 
std::vector< BIAS::Vector2
< double > > 
Centers_
 
bool LabelInitialized_
 
Image< LABEL_CALC_TYPE > LabelResultImage_
 
Image< LABEL_CALC_TYPE > LabelSumImage_
 
std::vector< BIAS::Vector2
< double > > 
MedianCenters_
 
std::vector< int > Num_
 
std::vector< BIAS::CCAStructSortVec_
 
std::vector< BIAS::Vector2< int > > TopLefts_
 

Static Protected Attributes

static std::ostream _zDebugStream
 
static long int GlobalDebugLevel = 0
 

Detailed Description

does a connected component analysis and labels all connected regions

there is no difference between fore and background. Each region that has a different color than all its neighbouring pixels is its own region. Each pixel is assigned to one region.

There are utility functions to get Blobcounts and bounding boxes. So far only 4neighborhoud and grey value images only. Important: When using Filter(), the resulting image is only valid if there are less than 255 regions!!

Author
woelk

Definition at line 84 of file Label.hh.

Member Enumeration Documentation

enum for border calculation, same meanings as in matlab:

  • TBH_valid: returns only the pixels whose values can be computed without using zero padding of the input image. The resulting output image is smaller than the input image. The ROI of the output image is set accordingly.
  • TBH_same: returns the set of pixels that can be computed by applying the filter to all pixels that are actually part of the input image. Border pixels are computed using zero padding, but the center pixel of the computational kernel is applied only to pixels in the image. This results in an output image that is the same size as the input image.
  • TBH_full: returns the full convolution. This means conv2 returns all pixels for which any of the pixels in the computational molecule overlap pixels in the image, even when the center pixel is outside the input image. The resulting output image is larger than the input image. This is not implemented at the moment.

Definition at line 98 of file FilterBase.hh.

Constructor & Destructor Documentation

Label::Label ( )

Definition at line 55 of file Label.cpp.

Label::~Label ( )

Definition at line 62 of file Label.cpp.

Member Function Documentation

void BIAS::Debug::AddDebugLevel ( const long int  lv)
inlineinherited
void BIAS::Debug::AddDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 362 of file Debug.hh.

long BIAS::Debug::ConsumeNextFreeDebuglevel_ ( )
inlineprotectedinherited

returns the next available debuglevel

Author
woelk 09/2006

Definition at line 521 of file Debug.hh.

void BIAS::FilterBase< unsigned char , unsigned char >::CopyNonROIFromSource ( const Image< unsigned char > &  src,
Image< unsigned char > &  dst 
) const
inherited

run over all pixel which do not belong to the roi and set them to the value in the source image regardless of the roi of the source.

Both images must have same size.

Author
koeser 12/2008
bool BIAS::Debug::DebugLevelIsSet ( const long int  lv) const
inlineinherited
bool BIAS::Debug::DebugLevelIsSet ( const std::string &  name) const
inlineinherited

Definition at line 350 of file Debug.hh.

int Label::Filter ( const Image< unsigned char > &  src,
Image< unsigned char > &  dst 
)
virtual
std::vector<int> BIAS::Label::GetBlobCounts ( )
inline

returns a list with the size of each blob, largest first, if no blobs are found a list with a single 0 is returned

Author
Daniel Grest, Aug. 2004

Definition at line 119 of file Label.hh.

std::map<unsigned char, int> BIAS::Label::GetBlobMap ( )
inline

Returns a map that hold the blob size for each label.

Definition at line 123 of file Label.hh.

void BIAS::Label::GetBlobSizes ( std::vector< int > &  sizes) const
inline

Definition at line 153 of file Label.hh.

int BIAS::FilterBase< unsigned char , unsigned char >::GetBorderHandling ( ) const
inlineinherited

Definition at line 129 of file FilterBase.hh.

void BIAS::FilterBase< unsigned char , unsigned char >::GetBorders ( int &  border_x,
int &  border_y 
) const
inherited
void Label::GetBordersValid_ ( int &  border_x,
int &  border_y 
) const
protectedvirtual

Implements BIAS::FilterBase< unsigned char, unsigned char >.

Definition at line 493 of file Label.cpp.

int BIAS::Label::GetBoundingBoxes ( std::vector< BIAS::Vector2< int > > &  topLefts,
std::vector< BIAS::Vector2< int > > &  botRights 
)
inline

returns two lists,one with the topLeft coordinates of the bounding boxes of each region and one with the botrights, sorted by size of regions (in pixel)

Returns
0, in case of no error
Author
woelk

Definition at line 139 of file Label.hh.

void BIAS::Label::GetCenters ( std::vector< BIAS::Vector2< double > > &  centers) const
inline

returns the centers of the blobs

Author
woelk 03/2006

Definition at line 145 of file Label.hh.

int BIAS::Debug::GetDebugLevel ( ) const
inlineinherited
std::ostream& BIAS::Debug::GetDebugStream ( ) const
inlineinherited

Definition at line 405 of file Debug.hh.

void BIAS::Debug::GetDebugStream ( std::ostream &  os) const
inlineinherited

Definition at line 414 of file Debug.hh.

static long int BIAS::Debug::GetGlobalDebugLevel ( )
inlinestaticinherited

Definition at line 431 of file Debug.hh.

void BIAS::Label::GetLabelImage ( Image< LABEL_CALC_TYPE > &  li)
inline

returns in li the image where each region has a different grey value, value zero is the background region

Definition at line 129 of file Label.hh.

void BIAS::Label::GetMedianCenters ( std::vector< BIAS::Vector2< double > > &  cts) const
inline

returns the median centers of the blobs

Author
woelk 03/2006

Definition at line 150 of file Label.hh.

int Label::Label4Neighbour ( const BIAS::Image< unsigned char > &  Image,
BIAS::Image< unsigned char > &  DestinationImage 
)

labels an unsigned short int using an 4er neighbourhood and returns it in DestinationImage if DestinationImage is allocated it is not reallocated untested

Author
Felix Woelk

Definition at line 308 of file Label.cpp.

References BIAS::ImageConvert::ConvertST(), BIAS::ImageBase::GetCopyOfROI(), BIAS::ImageBase::Paste2ROI(), and BIAS::ImageBase::SamePixelAndChannelCount().

int Label::Label4Neighbour ( const BIAS::Image< LABEL_CALC_TYPE > &  Image,
BIAS::Image< LABEL_CALC_TYPE > &  DestinationImage 
)

labels an unsigned short int using an 4er neighbourhood and returns it in DestinationImage if DestinationImage is allocated it is not reallocated

Definition at line 286 of file Label.cpp.

References BIAS::ImageBase::GetCopyOfROI(), BIAS::ImageBase::Paste2ROI(), and BIAS::ImageBase::SamePixelAndChannelCount().

int Label::Label4Neighbour_ ( )
protected

Definition at line 110 of file Label.cpp.

void Label::LabelInit_ ( const ImageBase Image)
protected
void Label::LabelRelease_ ( )
protected

Definition at line 100 of file Label.cpp.

long int BIAS::Debug::Name2DebugLevel ( const std::string &  name) const
inlineinherited

looks up a debuglevel in the internal map, returns 0 if not found

Author
woelk 09/2006

Definition at line 454 of file Debug.hh.

long int BIAS::Debug::NewDebugLevel ( const std::string &  name)
inlineinherited
void BIAS::Debug::PrintDebugLevel ( std::ostream &  os = std::cout) const
inlineinherited

Definition at line 383 of file Debug.hh.

int Label::Process ( const Image< unsigned char > &  im)
void BIAS::Debug::RemoveDebugLevel ( const long int  lv)
inlineinherited

Definition at line 369 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 376 of file Debug.hh.

void BIAS::FilterBase< unsigned char , unsigned char >::SetBorderHandling ( const int  bh)
inlineinherited

Definition at line 127 of file FilterBase.hh.

void BIAS::Debug::SetDebugLevel ( const long int  lv)
inlineinherited
void BIAS::Debug::SetDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 325 of file Debug.hh.

void BIAS::Debug::SetDebugStream ( const std::ostream &  os)
inlineinherited

Definition at line 398 of file Debug.hh.

static void BIAS::Debug::SetGlobalDebugLevel ( long int  lev)
inlinestaticinherited

Definition at line 424 of file Debug.hh.

void BIAS::FilterBase< unsigned char , unsigned char >::SetNonROIToValue ( Image< unsigned char > &  dst,
const std::vector< unsigned char > &  t 
) const
inherited

run over all pixel which do not belong to the roi and set them to some value (typically black)

Author
koeser 12/2008
void BIAS::Debug::ShowDebugLevel ( std::ostream &  os = std::cout) const
inlineinherited

prints all internally known debuglevels

Author
woelk 09/2006

Definition at line 496 of file Debug.hh.

Member Data Documentation

int BIAS::FilterBase< unsigned char , unsigned char >::_FilterBorderHandling
protectedinherited

Definition at line 132 of file FilterBase.hh.

long int BIAS::Debug::_liDebugLevel
protectedinherited

Definition at line 510 of file Debug.hh.

Referenced by BIAS::Debug::operator=(), and BIAS::ImageBase::operator=().

long int BIAS::Debug::_liNextDebugLevel
protectedinherited

new concept, debuglevel are managed here in the debug class

Definition at line 516 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

std::map<std::string, long int> BIAS::Debug::_String2Debuglevel
protectedinherited

Definition at line 517 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

std::ostream BIAS::Debug::_zDebugStream
staticprotectedinherited

Definition at line 511 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

std::vector<int> BIAS::Label::BlobCount_
protected

Definition at line 170 of file Label.hh.

std::vector<BIAS::Vector2<int> > BIAS::Label::BotRights_
protected

Definition at line 171 of file Label.hh.

std::vector<BIAS::Vector2<double> > BIAS::Label::Centers_
protected

Definition at line 172 of file Label.hh.

long int BIAS::Debug::GlobalDebugLevel = 0
staticprotectedinherited

Definition at line 513 of file Debug.hh.

bool BIAS::Label::LabelInitialized_
protected

Definition at line 159 of file Label.hh.

Image<LABEL_CALC_TYPE> BIAS::Label::LabelResultImage_
protected

Definition at line 161 of file Label.hh.

Image<LABEL_CALC_TYPE> BIAS::Label::LabelSumImage_
protected

Definition at line 160 of file Label.hh.

std::vector<BIAS::Vector2<double> > BIAS::Label::MedianCenters_
protected

Definition at line 173 of file Label.hh.

std::vector<int> BIAS::Label::Num_
protected

Definition at line 167 of file Label.hh.

std::vector<BIAS::CCAStruct> BIAS::Label::SortVec_
protected

Definition at line 168 of file Label.hh.

std::vector<BIAS::Vector2<int> > BIAS::Label::TopLefts_
protected

Definition at line 171 of file Label.hh.


The documentation for this class was generated from the following files: