Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
BIAS::ContourDetectorSimple< StorageType > Class Template Reference

a class for calculating the contour of a segmented region More...

#include <FeatureDetector/ContourDetectorSimple.hh>

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

Public Member Functions

 ContourDetectorSimple ()
 
void CreateDistanceImage (BIAS::Image< StorageType > &dist_img, const BIASContour &contour)
 returns a Borgefor distance transformed image (returned in 'dist_img') of the pixel set given by the contour pixels in 'contour' More...
 
int CreateDistanceImageByContour (BIAS::Image< StorageType > &dist_img, BIAS::Image< StorageType > &img)
 returns a Borgefor distance transformed image of the contour pixel set of the first blob found in the image 'img'. More...
 
int Detect (Image< StorageType > &image, std::vector< BIAS::BIASContour > &contour)
 detect function of ContourDetectorSimple More...
 
bool GetContourImage (BIAS::Image< unsigned char > &image, const std::vector< BIASContour > &contour)
 draws the contour in the given image as white line More...
 
std::vector< int > & GetFreemanCode ()
 instead of contour pixels a start point and a list of difference vector (created during surrounding the blob clock wise) is given More...
 
void SetBackground (StorageType backgroundColor)
 Set the background color if it is different from 0. More...
 
void SetGap (int gap=5)
 Set the maximum gap which is bridged in search for contour. More...
 
 ~ContourDetectorSimple ()
 

Protected Member Functions

bool CreateContourBase_ (BIAS::BIASContour &contour, BIAS::Image< StorageType > &img)
 creates the contour of the first blob found in the image; a pixel is assumed as foreground pixel, if the pixel value is != 0; this function works even if the blob is located at the image frame More...
 
bool FindFirst_ (int &pos_x, int &pos_y)
 Finds first foreground pixel. More...
 
void Init_ (BIAS::Image< StorageType > &img)
 
void InitDistanceImage_ (BIAS::Image< StorageType > &img, const BIASContour &contour)
 Initializes the distance image. More...
 
bool IsFg_ (int x, int y)
 determines of a pixel is foreground or not More...
 
bool IsFg_ (int x, int y, int direction)
 returns IsFg_ of the next pixel in the direction of param direction More...
 
void MakeDistanceImage_ (BIAS::Image< StorageType > &img)
 converts the given image to an distance transformed image (the Borgefor distance is used, that means one step in diagonal direction has a distance of 4 other steps have distances of 3); the underlying pixel set has to be marked as zero valued pixels – all other pixels have to be set to a high value (MAX_USHORT) More...
 

Protected Attributes

StorageType background_
 
StorageType ** data_
 
std::vector< int > directionList_
 
int gap_
 
int img_h
 
int img_w
 

Private Member Functions

void AddDebugLevel (const long int lv)
 
void AddDebugLevel (const std::string &name)
 
long ConsumeNextFreeDebuglevel_ ()
 returns the next available debuglevel More...
 
bool DebugLevelIsSet (const long int lv) const
 
bool DebugLevelIsSet (const std::string &name) const
 
int GetDebugLevel () const
 
std::ostream & GetDebugStream () const
 
void GetDebugStream (std::ostream &os) const
 
int GetMaxNumContours ()
 return maximum number of contours 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
 
void RemoveDebugLevel (const long int lv)
 
void RemoveDebugLevel (const std::string &name)
 
void SetDebugLevel (const long int lv)
 
void SetDebugLevel (const std::string &name)
 
void SetDebugStream (const std::ostream &os)
 
void SetMaxNumContours (const int maxnum)
 
void ShowDebugLevel (std::ostream &os=std::cout) const
 prints all internally known debuglevels More...
 

Static Private Member Functions

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

Private Attributes

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< BIAS::BIASContourdetectedContours_
 
int dMaxNumContours_
 maximum number of corners to return More...
 

Static Private Attributes

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

Detailed Description

template<class StorageType>
class BIAS::ContourDetectorSimple< StorageType >

a class for calculating the contour of a segmented region

Author
Dennis Herzog, Jan. 2005 ischiller 08/08
Examples:
ExampleContourDetectorSimple.cpp, and ExampleRefineContour.cpp.

Definition at line 45 of file ContourDetectorSimple.hh.

Constructor & Destructor Documentation

template<class StorageType >
ContourDetectorSimple::ContourDetectorSimple ( )

Definition at line 76 of file ContourDetectorSimple.cpp.

template<class StorageType >
ContourDetectorSimple::~ContourDetectorSimple ( )

Definition at line 83 of file ContourDetectorSimple.cpp.

Member Function Documentation

template<class StorageType >
bool ContourDetectorSimple::CreateContourBase_ ( BIAS::BIASContour contour,
BIAS::Image< StorageType > &  img 
)
protected

creates the contour of the first blob found in the image; a pixel is assumed as foreground pixel, if the pixel value is != 0; this function works even if the blob is located at the image frame

Author
herzog
Parameters
contour
Returns
true=ok, false=no contour detected

Definition at line 206 of file ContourDetectorSimple.cpp.

References BIAS::BIASContour::contourPixel, and BIAS::BIASContour::length.

template<class StorageType >
void ContourDetectorSimple::CreateDistanceImage ( BIAS::Image< StorageType > &  dist_img,
const BIASContour contour 
)

returns a Borgefor distance transformed image (returned in 'dist_img') of the pixel set given by the contour pixels in 'contour'

Author
herzog
Parameters
dist_im(output) the Borgefor distance image
contour(input) the already detected contour by a call to Detect(...)

Definition at line 176 of file ContourDetectorSimple.cpp.

template<class StorageType >
int ContourDetectorSimple::CreateDistanceImageByContour ( BIAS::Image< StorageType > &  dist_img,
BIAS::Image< StorageType > &  img 
)

returns a Borgefor distance transformed image of the contour pixel set of the first blob found in the image 'img'.

Author
herzog
Parameters
img(input) source image, from which the contour comes
dist_img(output) returns the distance transformed image of the contour
Returns
<0=error, > 0 length of contour in pixel

Definition at line 185 of file ContourDetectorSimple.cpp.

References BIAS::BIASContour::length.

template<class StorageType >
int ContourDetectorSimple::Detect ( Image< StorageType > &  image,
std::vector< BIAS::BIASContour > &  contour 
)
virtual

detect function of ContourDetectorSimple

Parameters
image(input) an image with a constant background and an object of which the contour is to be calculated
contour(output) the contours of the detected objects, currently only one contour is searched
Returns
<0=error, >0 length of contour in pixel
Author
ischiller
Date
12/09

Implements BIAS::ContourDetectorBase< StorageType >.

Definition at line 158 of file ContourDetectorSimple.cpp.

template<class StorageType >
bool ContourDetectorSimple::FindFirst_ ( int &  pos_x,
int &  pos_y 
)
protected

Finds first foreground pixel.

Parameters
pos_x(output) x position of pixel
pos_y(output) y position of pixel
Returns
true=found, false=not found

Definition at line 118 of file ContourDetectorSimple.cpp.

template<class StorageType >
bool ContourDetectorSimple::GetContourImage ( BIAS::Image< unsigned char > &  image,
const std::vector< BIASContour > &  contour 
)

draws the contour in the given image as white line

Author
ischiller
Parameters
image(input) image in which to draw the contour. Has to be initialized with the correct size
Returns
false=no contour available, true=drawing successful

Definition at line 89 of file ContourDetectorSimple.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), and BIAS::ImageBase::GetWidth().

template<class StorageType>
std::vector<int>& BIAS::ContourDetectorSimple< StorageType >::GetFreemanCode ( )
inline

instead of contour pixels a start point and a list of difference vector (created during surrounding the blob clock wise) is given

Author
herzog
Returns
directionList difference vectors coded in FreeManCode (that means: ( 0 = step right – 1 = step right & step down – 2 = step down – 3 = step left & step down – 4 = step left – 5 = step left & up 6 = step up – 7 = step right & step up))

Definition at line 107 of file ContourDetectorSimple.hh.

template<class StorageType >
void ContourDetectorSimple::Init_ ( BIAS::Image< StorageType > &  img)
protected
template<class StorageType >
void ContourDetectorSimple::InitDistanceImage_ ( BIAS::Image< StorageType > &  img,
const BIASContour contour 
)
protected
template<class StorageType>
bool BIAS::ContourDetectorSimple< StorageType >::IsFg_ ( int  x,
int  y 
)
inlineprotected

determines of a pixel is foreground or not

Parameters
x(input) x position of pixel
y(input) y position of pixel
Returns
true=is foreground, false=not foreground

Definition at line 156 of file ContourDetectorSimple.hh.

template<class StorageType>
bool BIAS::ContourDetectorSimple< StorageType >::IsFg_ ( int  x,
int  y,
int  direction 
)
inlineprotected

returns IsFg_ of the next pixel in the direction of param direction

Parameters
x(input) x position of pixel
y(input) y position of pixel
direction(input) direction of next pixel (freeman code)
Returns
true=is foreground, false=not foreground

Definition at line 168 of file ContourDetectorSimple.hh.

template<class StorageType >
void ContourDetectorSimple::MakeDistanceImage_ ( BIAS::Image< StorageType > &  img)
protected

converts the given image to an distance transformed image (the Borgefor distance is used, that means one step in diagonal direction has a distance of 4 other steps have distances of 3); the underlying pixel set has to be marked as zero valued pixels – all other pixels have to be set to a high value (MAX_USHORT)

Author
herzog
Parameters
imginput and output image

Definition at line 278 of file ContourDetectorSimple.cpp.

References BIAS::DistImgMatAcc< StorageType >::Get(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetWidth(), and BIAS::DistImgMatAcc< StorageType >::Set().

template<class StorageType>
void BIAS::ContourDetectorSimple< StorageType >::SetBackground ( StorageType  backgroundColor)
inline

Set the background color if it is different from 0.

Parameters
backgroundColor(input) the new background color

Definition at line 113 of file ContourDetectorSimple.hh.

template<class StorageType>
void BIAS::ContourDetectorSimple< StorageType >::SetGap ( int  gap = 5)
inline

Set the maximum gap which is bridged in search for contour.

Parameters
gap(input) the new max gap (default 5)

Definition at line 120 of file ContourDetectorSimple.hh.

Member Data Documentation

template<class StorageType>
StorageType BIAS::ContourDetectorSimple< StorageType >::background_
protected

Definition at line 195 of file ContourDetectorSimple.hh.

template<class StorageType>
StorageType** BIAS::ContourDetectorSimple< StorageType >::data_
protected

Definition at line 197 of file ContourDetectorSimple.hh.

template<class StorageType>
std::vector<int> BIAS::ContourDetectorSimple< StorageType >::directionList_
protected

Definition at line 196 of file ContourDetectorSimple.hh.

template<class StorageType>
int BIAS::ContourDetectorSimple< StorageType >::gap_
protected

Definition at line 198 of file ContourDetectorSimple.hh.

template<class StorageType>
int BIAS::ContourDetectorSimple< StorageType >::img_h
protected

Definition at line 194 of file ContourDetectorSimple.hh.

template<class StorageType>
int BIAS::ContourDetectorSimple< StorageType >::img_w
protected

Definition at line 193 of file ContourDetectorSimple.hh.


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