LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::coilBackgroundSegmentation Class Reference

The coilBackgroundSegmentation functor tries to detect which pixels belong to the background and which not. More...

#include <ltiCoilBackgroundSegmentation.h>

Inheritance diagram for lti::coilBackgroundSegmentation:
Inheritance graph
[legend]
Collaboration diagram for lti::coilBackgroundSegmentation:
Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 the parameters for the class coilBackgroundSegmentation More...
struct  TmeanProbability
 type combining the region with its mean color, probability and relation to background and object More...

Public Member Functions

 coilBackgroundSegmentation ()
 coilBackgroundSegmentation (const coilBackgroundSegmentation &other)
virtual ~coilBackgroundSegmentation ()
virtual const char * getTypeName () const
bool apply (const image &src, channel8 &result)
coilBackgroundSegmentationcopy (const coilBackgroundSegmentation &other)
coilBackgroundSegmentationoperator= (const coilBackgroundSegmentation &other)
virtual functorclone () const
const parametersgetParameters () const

Protected Member Functions

void deleteWeakLinks (channel8 &ch8) const
bool getInvertedCovarMatrixForMask (const image &img, channel8 &mask, trgbPixel< double > &mean, dmatrix &covarMatrix) const
bool checkColorReasonable (const trgbPixel< double > &mean, const dmatrix &covarMatrix, const rgbPixel &xMinusM) const
bool growOutsideObject (const image &img, channel8 &ch8MaskChannel, sparseMatrix< int > &intSparseMat, std::vector< TmeanProbability > &meanProbabilityList, matrix< int > &newLabelsMatrix, bool &converged) const
bool growInsideObject (const image &img, channel8 &ch8MaskChannel, sparseMatrix< int > &intSparseMat, std::vector< TmeanProbability > &meanProbabilityList, matrix< int > &newLabelsMatrix, bool &converged) const

Detailed Description

The coilBackgroundSegmentation functor tries to detect which pixels belong to the background and which not.

It is quite slow, so it should be used mainly for static applications where the mask has to be generated only once and without any matter of time.

For proper functionality there are some assumtions/requirements:

The algorithm works as follows:

At first the colors are quantized into regions using the k-means algorithm. Then two masks are generated, one representing the object, the other one the background. These masks serve as a basis for a probability estimation which region belongs to object or background. After that the masks grow considering these results, neighbourhoods and covariance matrices. This iteration is repeated "iteration"-times and finally generates a channel containing 0 for background and 255 for the object.

At last some after-treatment is done: Pixels constituting weak links are deleted and if there is more than one object estimated, only the largest one is kept. In order to improve results, the whole algorithm is reiterated up to "maxNumberBestOfN"-times, erasing pixels in the final mask which are not estimated as object every time. In the best case these shrinking lasts until the final mask doesn´t change any more.

See the lti::coilBackgroundSegmentation::parameters for more information.


Constructor & Destructor Documentation

lti::coilBackgroundSegmentation::coilBackgroundSegmentation (  ) 

default constructor

lti::coilBackgroundSegmentation::coilBackgroundSegmentation ( const coilBackgroundSegmentation other  ) 

copy constructor

Parameters:
other the object to be copied
virtual lti::coilBackgroundSegmentation::~coilBackgroundSegmentation (  )  [virtual]

destructor


Member Function Documentation

bool lti::coilBackgroundSegmentation::apply ( const image src,
channel8 result 
)

generates a mask with the value 255 where the object is estimated and 0 for the background.

Parameters:
src image with the source data
result the resulting mask
Returns:
true if apply successful or false otherwise
bool lti::coilBackgroundSegmentation::checkColorReasonable ( const trgbPixel< double > &  mean,
const dmatrix covarMatrix,
const rgbPixel xMinusM 
) const [protected]

checking if a given color is close enough to the covariance matrix

Parameters:
mean the center of the covarianve matrix is considered here
covarMatrix the covariance matrix to be considered
xMinusM pixel with the color to be checked
Returns:
true if succesfull
virtual functor* lti::coilBackgroundSegmentation::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Reimplemented from lti::segmentation.

coilBackgroundSegmentation& lti::coilBackgroundSegmentation::copy ( const coilBackgroundSegmentation other  ) 

copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::segmentation.

void lti::coilBackgroundSegmentation::deleteWeakLinks ( channel8 ch8  )  const [protected]

delete such positions in the mask

    ** **        *****
    ** **        *****
    **x**          x
    ** **        *****
    ** **        *****
Parameters:
ch8 the channel8 to be optimized
bool lti::coilBackgroundSegmentation::getInvertedCovarMatrixForMask ( const image img,
channel8 mask,
trgbPixel< double > &  mean,
dmatrix covarMatrix 
) const [protected]

calculating the inverted covariance matrix under consideration of the object/background mask

Parameters:
img the image to be considered
mask the mask which pixels from img should be used
mean the meanvalue (center) of the covarianve matrix is returned here
covarMatrix the resulting matrix is returned here
Returns:
true if succesfull
const parameters& lti::coilBackgroundSegmentation::getParameters (  )  const

returns used parameters

Reimplemented from lti::functor.

virtual const char* lti::coilBackgroundSegmentation::getTypeName (  )  const [virtual]

returns the name of this type ("coilBackgroundSegmentation")

Reimplemented from lti::segmentation.

bool lti::coilBackgroundSegmentation::growInsideObject ( const image img,
channel8 ch8MaskChannel,
sparseMatrix< int > &  intSparseMat,
std::vector< TmeanProbability > &  meanProbabilityList,
matrix< int > &  newLabelsMatrix,
bool &  converged 
) const [protected]

building the object mask under consideration of neighbourhoods, covariance matrix and probabilities

Parameters:
img the image to be considered
ch8MaskChannel the mask estimating the object
intSparseMat matix containing which labels are related
meanProbabilityList a list containing mean probability, color and relation towards background and object for each region
newLabelsMatrix matrix containing the labelnumber for each pixel
converged true if no change took place
Returns:
true if succesfull
bool lti::coilBackgroundSegmentation::growOutsideObject ( const image img,
channel8 ch8MaskChannel,
sparseMatrix< int > &  intSparseMat,
std::vector< TmeanProbability > &  meanProbabilityList,
matrix< int > &  newLabelsMatrix,
bool &  converged 
) const [protected]

building the background mask under consideration of neighbourhoods, covariance matrix and probabilities

Parameters:
img the image to be considered
ch8MaskChannel the mask estimating the background
intSparseMat matix containing which regions are neighbours
meanProbabilityList a list containing mean probability, color and relation towards background and object for each region
newLabelsMatrix matrix containing the labelnumber for each pixel
converged true if no change took place
Returns:
true if succesfull
coilBackgroundSegmentation& lti::coilBackgroundSegmentation::operator= ( const coilBackgroundSegmentation other  ) 

alias for copy member

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::functor.


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

Generated on Sat Apr 10 15:27:07 2010 for LTI-Lib by Doxygen 1.6.1