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::BlobDetectorCCA< StorageType > Class Template Reference

Does a Connected Component Analyis and gives information about regions in an image, like centroid and bounding boxes. More...

#include <FeatureDetector/BlobDetectorCCA.hh>

+ Inheritance diagram for BIAS::BlobDetectorCCA< StorageType >:
+ Collaboration diagram for BIAS::BlobDetectorCCA< StorageType >:

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)
 
 BlobDetectorCCA ()
 
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
 
int Detect (Image< StorageType > &image, std::vector< BIAS::BIASBlob > &blobs)
 Does a Connected Component Analyis (4-neighborhood) and deletes all regions, whose sizes are smaller than p percent of the image. More...
 
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 GetCentroids (std::vector< BIAS::Vector2< double > > &centroids)
 call this afer Process() to get the centroids of all regions. 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...
 
int GetMaxNumBlobs ()
 return maximum number of blobs More...
 
void GetMedianCenters (std::vector< BIAS::Vector2< double > > &cts) const
 returns the median centers of the blobs More...
 
int GetMedians (std::vector< BIAS::Vector2< unsigned int > > &medians)
 call this afer Process() to get the medians of all regions. More...
 
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 SetMaxNumBlobs (const int maxnum)
 
void SetNeighborhoud4 (bool neighborhoud4)
 If neighborHood4, then a max of 255 regions is possible, if there are more it results in undefined behaviour (probably a segfault). More...
 
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 SetPercent (float percent)
 
void ShowDebugLevel (std::ostream &os=std::cout) const
 prints all internally known debuglevels More...
 
virtual ~BlobDetectorCCA ()
 

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
 
void Init_ (const BIAS::Image< StorageType > &img)
 init is called before processing the first image More...
 
int Label4Neighbour_ ()
 
void LabelInit_ (const ImageBase &Image)
 
void LabelRelease_ ()
 
int Process8_ (BIAS::Image< StorageType > &img, float percent)
 
int Process_ (BIAS::Image< StorageType > &img, float percent, bool neighborHood4=true)
 

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< std::vector
< BIAS::Vector2< int > > > 
allBlobs_
 
bool bIsInited_
 
std::vector< int > BlobCount_
 
bool bNeighborHood4_
 
std::vector< BIAS::Vector2< int > > BotRights_
 
std::vector< BIAS::Vector2
< double > > 
Centers_
 
int dMaxNumBlobs_
 maximum number of corners to return More...
 
float fPercent_
 
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

template<class StorageType>
class BIAS::BlobDetectorCCA< StorageType >

Does a Connected Component Analyis and gives information about regions in an image, like centroid and bounding boxes.

Geometry useful after morphological operators like Erosion or Dilation The input image has to be segmented in only a few grey values, best is black or white.

neighborhood 8 so far not implemented

Author
grest, Aug. 2004, ischiller 08/08
Examples:
ExampleBlobDetectorCCA.cpp.

Definition at line 24 of file BlobDetectorCCA.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

template<class StorageType >
BlobDetectorCCA::BlobDetectorCCA ( )

Definition at line 43 of file BlobDetectorCCA.cpp.

template<class StorageType >
BlobDetectorCCA::~BlobDetectorCCA ( )
virtual

Definition at line 51 of file BlobDetectorCCA.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.

template<class StorageType >
int BlobDetectorCCA::Detect ( Image< StorageType > &  image,
std::vector< BIAS::BIASBlob > &  blobs 
)
virtual

Does a Connected Component Analyis (4-neighborhood) and deletes all regions, whose sizes are smaller than p percent of the image.


Use SetPercent and SetNeighborhoud4 before If percent is negative, only the two largest regions are not deleted. While there is no difference between fore- and background (see BIAS::Label), so the largest region is usually the background. One channel images only !

Author
Daniel Grest, Aug. 2004

Implements BIAS::BlobDetectorBase< StorageType >.

Definition at line 57 of file BlobDetectorCCA.cpp.

References BIAS::BIASBlob::centerofmass, BIAS::BIASBlob::LR, BIAS::BIASBlob::UL, and BIAS::BIASBlob::weight.

Referenced by BIAS::CheckerboardDetectorCrossFilter::GetCCACenter().

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

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 ( )
inlineinherited

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
inlineinherited

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
protectedvirtualinherited

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 
)
inlineinherited

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
inlineinherited

returns the centers of the blobs

Author
woelk 03/2006

Definition at line 145 of file Label.hh.

template<class StorageType >
int BlobDetectorCCA::GetCentroids ( std::vector< BIAS::Vector2< double > > &  centroids)

call this afer Process() to get the centroids of all regions.

Calculates the centroids of each region, sorted by size of the region, largest region first. returns 0, in case of no error

Author
Daniel Grest, June. 2003

Definition at line 193 of file BlobDetectorCCA.cpp.

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)
inlineinherited

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.

template<class StorageType>
int BIAS::BlobDetectorBase< StorageType >::GetMaxNumBlobs ( )
inlineinherited

return maximum number of blobs

Author
ischiller

Definition at line 82 of file BlobDetectorBase.hh.

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

returns the median centers of the blobs

Author
woelk 03/2006

Definition at line 150 of file Label.hh.

template<class StorageType >
int BlobDetectorCCA::GetMedians ( std::vector< BIAS::Vector2< unsigned int > > &  medians)

call this afer Process() to get the medians of all regions.

Calculates the medians of each region, sorted by size of the region, largest region first. returns 0, in case of no error

Author
Daniel Grest, June. 2003

Definition at line 214 of file BlobDetectorCCA.cpp.

template<class StorageType >
void BlobDetectorCCA::Init_ ( const BIAS::Image< StorageType > &  img)
protected

init is called before processing the first image

Definition at line 81 of file BlobDetectorCCA.cpp.

References BIAS::Label::LabelInit_().

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

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 
)
inherited

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_ ( )
protectedinherited

Definition at line 110 of file Label.cpp.

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

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)
inherited
template<class StorageType >
int BlobDetectorCCA::Process8_ ( BIAS::Image< StorageType > &  img,
float  percent 
)
protected

Definition at line 182 of file BlobDetectorCCA.cpp.

template<class StorageType >
int BlobDetectorCCA::Process_ ( BIAS::Image< StorageType > &  img,
float  percent,
bool  neighborHood4 = true 
)
protected
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.

template<class StorageType>
void BIAS::BlobDetectorBase< StorageType >::SetMaxNumBlobs ( const int  maxnum)
inlineinherited

Definition at line 74 of file BlobDetectorBase.hh.

template<class StorageType>
void BIAS::BlobDetectorCCA< StorageType >::SetNeighborhoud4 ( bool  neighborhoud4)
inline

If neighborHood4, then a max of 255 regions is possible, if there are more it results in undefined behaviour (probably a segfault).

Best is to delete small regions before, e.g. with Erosion3Fast or DeleteSingles() from BIAS::Morphology

Definition at line 76 of file BlobDetectorCCA.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
template<class StorageType>
void BIAS::BlobDetectorCCA< StorageType >::SetPercent ( float  percent)
inline

Definition at line 66 of file BlobDetectorCCA.hh.

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=().

template<class StorageType>
std::vector<std::vector<BIAS::Vector2<int> > > BIAS::BlobDetectorCCA< StorageType >::allBlobs_
protected

Definition at line 94 of file BlobDetectorCCA.hh.

template<class StorageType>
bool BIAS::BlobDetectorCCA< StorageType >::bIsInited_
protected

Definition at line 89 of file BlobDetectorCCA.hh.

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

Definition at line 170 of file Label.hh.

template<class StorageType>
bool BIAS::BlobDetectorCCA< StorageType >::bNeighborHood4_
protected

Definition at line 91 of file BlobDetectorCCA.hh.

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

Definition at line 171 of file Label.hh.

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

Definition at line 172 of file Label.hh.

template<class StorageType>
int BIAS::BlobDetectorBase< StorageType >::dMaxNumBlobs_
protectedinherited

maximum number of corners to return

Definition at line 89 of file BlobDetectorBase.hh.

template<class StorageType>
float BIAS::BlobDetectorCCA< StorageType >::fPercent_
protected

Definition at line 90 of file BlobDetectorCCA.hh.

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

Definition at line 513 of file Debug.hh.

bool BIAS::Label::LabelInitialized_
protectedinherited

Definition at line 159 of file Label.hh.

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

Definition at line 161 of file Label.hh.

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

Definition at line 160 of file Label.hh.

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

Definition at line 173 of file Label.hh.

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

Definition at line 167 of file Label.hh.

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

Definition at line 168 of file Label.hh.

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

Definition at line 171 of file Label.hh.


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