latest version v1.9 - last update 10 Apr 2010 |
This class stores a 2d histogram containing all chrominances which have been seen on a specific object. More...
#include <ltiChrominanceModelEstimator.h>
Classes | |
class | parameters |
The parameters for the class chrominanceModelEstimator. More... | |
Public Member Functions | |
chrominanceModelEstimator () | |
chrominanceModelEstimator (const parameters &par) | |
chrominanceModelEstimator (const chrominanceModelEstimator &other) | |
virtual | ~chrominanceModelEstimator () |
virtual const char * | getTypeName () const |
chrominanceModelEstimator & | copy (const chrominanceModelEstimator &other) |
chrominanceModelEstimator & | operator= (const chrominanceModelEstimator &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
bool | setParameters (const parameters &theParams) |
bool | setChrominanceModels (const std::vector< histogram2D > &theModels) |
const std::vector< histogram2D > & | getChrominanceModels () const |
bool | writeChrominanceModels (const std::string &prefix, const std::vector< std::string > &fileNames) const |
bool | readChrominanceModels (const std::string &prefix, const std::vector< std::string > &fileNames) |
virtual bool | consider (const channel8 &uChan, const channel8 &vChan, const channel8 &mask) |
virtual bool | consider (const channel8 &uChan, const channel8 &vChan, const channel8 &mask, const ivector &count) |
virtual bool | consider (const channel8 &uChan, const channel8 &vChan, const bool trainForeground) |
virtual bool | consider (const channel8 &uChan, const channel8 &vChan, const bool trainForeground, const ivector &count) |
virtual bool | consider (const channel8 &uChan, const channel8 &vChan, const int index) |
virtual bool | consider (const channel8 &uChan, const channel8 &vChan, const int index, const ivector &count) |
Protected Member Functions | |
parameters & | getWritableParameters () |
bool | checkHistograms (const std::vector< histogram2D > &theHistos) |
bool | scaleValues (histogram2D &theHisto) |
bool | rescale (histogram2D &theHisto, const int cellsInDimension) |
bool | rescale (const histogram2D &theHisto, histogram2D &destHisto, const int cellsInDimension) |
bool | upsample (const histogram2D &theHisto, histogram2D &destHisto, const int factor) |
bool | downsample (const histogram2D &theHisto, histogram2D &destHisto, const int factor) |
bool | increaseCount (const ivector &count) |
Protected Attributes | |
std::vector< histogram2D > | m_chromHistos |
ivector | m_count |
int | m_maxEntries |
int | m_numEntries |
bool | m_constructModel |
This class stores a 2d histogram containing all chrominances which have been seen on a specific object.
The class administers histograms for >=1 objects. The histograms may be processed by other classes to create probability maps or a look up table containing the most likely object for each chrominance.
The class supports a time out of the histogram entries. For robustness and run-time efficiency a maximal chrominance set may be specified for each object including the background. E.g. if an object is known to be red it is advantageous to store only red chrominances inside it's histogram. This way no false chrominances are stored if the segmentation is errornous. Furthermore, if only red objects are processed all other chrominances may be excluded from processing for run time efficiency. We do not need to store these non-object chrominances in the background histogram neither.
If using fully automatic re-calibration it is possible to carve out chrominances that are well known to belong to an object from the background. These chrominances will always be segmented and the object cannot dissappear due to time-out and wrong maxima.
If you change the maximal chrominance sets online you should implement a method that deletes all histogram entries outside the region defined by the maximal chrominance sets. This is not done yet.
lti::chrominanceModelEstimator::chrominanceModelEstimator | ( | ) |
Default constructor.
lti::chrominanceModelEstimator::chrominanceModelEstimator | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
lti::chrominanceModelEstimator::chrominanceModelEstimator | ( | const chrominanceModelEstimator & | other | ) |
Copy constructor.
other | the object to be copied |
virtual lti::chrominanceModelEstimator::~chrominanceModelEstimator | ( | ) | [virtual] |
Destructor.
bool lti::chrominanceModelEstimator::checkHistograms | ( | const std::vector< histogram2D > & | theHistos | ) | [protected] |
Check if the histograms are valid, i.e.
have the correct size and accord to the number of models
theHistos | the chrominance models. |
virtual functor* lti::chrominanceModelEstimator::clone | ( | ) | const [virtual] |
Returns a pointer to a clone of this functor.
Reimplemented from lti::statisticsFunctor.
Reimplemented in lti::chrominanceMapEstimator.
virtual bool lti::chrominanceModelEstimator::consider | ( | const channel8 & | uChan, | |
const channel8 & | vChan, | |||
const int | index, | |||
const ivector & | count | |||
) | [virtual] |
Consider the chrominances in the supplied channel8.
All histograms are incremented.
uChan | refers to the columns of the histogram. | |
vChan | refers to the rows of the histogram. | |
count | specifies how the counters will be incremented. The counter determine if a histogram is decayed prior to considering the new values. | |
index | train chrominance model associated with index i. Index 0 refers to the background. |
virtual bool lti::chrominanceModelEstimator::consider | ( | const channel8 & | uChan, | |
const channel8 & | vChan, | |||
const int | index | |||
) | [virtual] |
Consider the chrominances in the supplied channel8.
All histograms are incremented. All histograms will be considered as updated, no matter whether they really did change.
uChan | refers to the columns of the histogram. | |
vChan | refers to the rows of the histogram. | |
index | train chrominance model associated with index i. Index 0 refers to the background. |
virtual bool lti::chrominanceModelEstimator::consider | ( | const channel8 & | uChan, | |
const channel8 & | vChan, | |||
const bool | trainForeground, | |||
const ivector & | count | |||
) | [virtual] |
Consider the chrominances in the supplied channel8.
All histograms are incremented.
uChan | refers to the columns of the histogram. | |
vChan | refers to the rows of the histogram. | |
count | specifies how the counters will be incremented. The counter determine if a histogram is decayed prior to considering the new values. | |
trainForeground | if true all histogram apart the background are trained. If false the background is trained. If you train more than two models please use the objectTable to distinguish the objects' colors. E.g. the object table provides the rough segmentation, which this class refines. Of course, this method only works for non-overlapping object colors. |
virtual bool lti::chrominanceModelEstimator::consider | ( | const channel8 & | uChan, | |
const channel8 & | vChan, | |||
const bool | trainForeground | |||
) | [virtual] |
Consider the chrominances in the supplied channel8.
All histograms are incremented. All histograms will be considered as updated, no matter whether they really did change.
uChan | refers to the columns of the histogram. | |
vChan | refers to the rows of the histogram. | |
trainForeground | if true all histogram apart the background are trained. If false the background is trained. If you train more than two models please use the objectTable to distinguish the objects' colors. E.g. the object table provides the rough segmentation, which this class refines. Of course, this method only works for non-overlapping object colors. |
virtual bool lti::chrominanceModelEstimator::consider | ( | const channel8 & | uChan, | |
const channel8 & | vChan, | |||
const channel8 & | mask, | |||
const ivector & | count | |||
) | [virtual] |
Consider the chrominances in the supplied channel8.
The mask specifies which histogram is incremented. Usually the background has the index 0. Any pixels that shall not be considered must have a value above or equal to the number of models.
uChan | refers to the columns of the histogram. | |
vChan | refers to the rows of the histogram. | |
mask | specifies which models will be updated. | |
count | specifies how the counters will be incremented. The counter determine if a histogram is decayed prior to considering the new values. |
virtual bool lti::chrominanceModelEstimator::consider | ( | const channel8 & | uChan, | |
const channel8 & | vChan, | |||
const channel8 & | mask | |||
) | [virtual] |
Consider the chrominances in the supplied channel8.
The mask specifies which histogram is incremented. Usually the background has the index 0. Any pixels that shall not be considered must have a value above or equal to the number of models. All histograms will be considered as updated, no matter whether they really did change.
uChan | refers to the columns of the histogram. | |
vChan | refers to the rows of the histogram. | |
mask | specifies which models will be updated. Tip: If drawing the mask from object shape keep in mind that drawing rectangles is faster than drawing polygons. |
chrominanceModelEstimator& lti::chrominanceModelEstimator::copy | ( | const chrominanceModelEstimator & | other | ) |
Copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::statisticsFunctor.
Reimplemented in lti::chrominanceMapEstimator.
bool lti::chrominanceModelEstimator::downsample | ( | const histogram2D & | theHisto, | |
histogram2D & | destHisto, | |||
const int | factor | |||
) | [protected] |
Downsample a histogram.
theHisto | a chrominance model. | |
destHisto | scaled chrominance model. | |
factor | the downsampling factor. |
const std::vector<histogram2D>& lti::chrominanceModelEstimator::getChrominanceModels | ( | ) | const |
Get the histograms that are build up by this class.
const parameters& lti::chrominanceModelEstimator::getParameters | ( | ) | const |
Returns used parameters.
Reimplemented from lti::statisticsFunctor.
Reimplemented in lti::chrominanceMapEstimator.
virtual const char* lti::chrominanceModelEstimator::getTypeName | ( | ) | const [virtual] |
Returns the name of this type ("chrominanceModelEstimator").
Reimplemented from lti::statisticsFunctor.
Reimplemented in lti::chrominanceMapEstimator.
parameters& lti::chrominanceModelEstimator::getWritableParameters | ( | ) | [protected] |
Returns used parameters.
Reimplemented in lti::chrominanceMapEstimator.
bool lti::chrominanceModelEstimator::increaseCount | ( | const ivector & | count | ) | [protected] |
Increase the count and check decay.
count | specifies how the counters will be incremented. The counter determine if a histogram is decayed prior to considering the new values. |
chrominanceModelEstimator& lti::chrominanceModelEstimator::operator= | ( | const chrominanceModelEstimator & | other | ) |
Alias for copy member.
other | the functor to be copied |
Reimplemented from lti::functor.
Reimplemented in lti::chrominanceMapEstimator.
bool lti::chrominanceModelEstimator::readChrominanceModels | ( | const std::string & | prefix, | |
const std::vector< std::string > & | fileNames | |||
) |
Initialize the chrominance models from disk.
prefix | a string containing the path or prefix to the files. If you specify a directory, please do not forget the /. It is not added automatically. | |
fileNames | a vector with the filename for each histogram. |
bool lti::chrominanceModelEstimator::rescale | ( | const histogram2D & | theHisto, | |
histogram2D & | destHisto, | |||
const int | cellsInDimension | |||
) | [protected] |
Rescale a histogram.
theHisto | a chrominance model. | |
destHisto | scaled chrominance model. | |
cellsInDimension | the new number of cells. |
bool lti::chrominanceModelEstimator::rescale | ( | histogram2D & | theHisto, | |
const int | cellsInDimension | |||
) | [protected] |
Rescale a histogram, i.e.
change it's quantization.
theHisto | a chrominance model. The result is left here, too. | |
cellsInDimension | the new number of cells. |
bool lti::chrominanceModelEstimator::scaleValues | ( | histogram2D & | theHisto | ) | [protected] |
Decrease the histogram's entries.
theHisto | a chrominance model. |
bool lti::chrominanceModelEstimator::setChrominanceModels | ( | const std::vector< histogram2D > & | theModels | ) |
Initialize the chrominance models.
theModels | the histograms to be copied inside the internal state of the class. |
bool lti::chrominanceModelEstimator::setParameters | ( | const parameters & | theParams | ) | [virtual] |
Set the parameters and ensure validity.
Reimplemented from lti::functor.
Reimplemented in lti::chrominanceMapEstimator.
bool lti::chrominanceModelEstimator::upsample | ( | const histogram2D & | theHisto, | |
histogram2D & | destHisto, | |||
const int | factor | |||
) | [protected] |
Upsample a histogram.
theHisto | a chrominance model. | |
destHisto | scaled chrominance model. | |
factor | the upsampling factor. |
bool lti::chrominanceModelEstimator::writeChrominanceModels | ( | const std::string & | prefix, | |
const std::vector< std::string > & | fileNames | |||
) | const |
Store all chrominance models to disk.
prefix | a string containing the path or prefix to the files. If you specify a directory, please do not forget the /. It is not added automatically. | |
fileNames | a vector with the filename for each histogram. |
std::vector<histogram2D> lti::chrominanceModelEstimator::m_chromHistos [protected] |
the 2D histograms of the chrominances
bool lti::chrominanceModelEstimator::m_constructModel [protected] |
Special care with setParameters during construction.
Historic and complicated code, but it works.
ivector lti::chrominanceModelEstimator::m_count [protected] |
counts calls of consider
int lti::chrominanceModelEstimator::m_maxEntries [protected] |
maximum number of entries in the histograms that make sense (max.
ubyte)
int lti::chrominanceModelEstimator::m_numEntries [protected] |
the scaled number of entries