![]() |
latest version v1.9 - last update 10 Apr 2010 |
![]() |
The coilBackgroundSegmentation functor tries to detect which pixels belong to the background and which not. More...
#include <ltiCoilBackgroundSegmentation.h>
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) |
coilBackgroundSegmentation & | copy (const coilBackgroundSegmentation &other) |
coilBackgroundSegmentation & | operator= (const coilBackgroundSegmentation &other) |
virtual functor * | clone () const |
const parameters & | getParameters () 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 |
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.
lti::coilBackgroundSegmentation::coilBackgroundSegmentation | ( | ) |
default constructor
lti::coilBackgroundSegmentation::coilBackgroundSegmentation | ( | const coilBackgroundSegmentation & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::coilBackgroundSegmentation::~coilBackgroundSegmentation | ( | ) | [virtual] |
destructor
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.
other | the functor to be copied |
Reimplemented from lti::segmentation.
void lti::coilBackgroundSegmentation::deleteWeakLinks | ( | channel8 & | ch8 | ) | const [protected] |
delete such positions in the mask
** ** ***** ** ** ***** **x** x ** ** ***** ** ** *****
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
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 |
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
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 |
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
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 |
coilBackgroundSegmentation& lti::coilBackgroundSegmentation::operator= | ( | const coilBackgroundSegmentation & | other | ) |