latest version v1.9 - last update 10 Apr 2010 |
This functor selects one color model from a set, which elements were given by addColorModel. More...
#include <ltiColorModelSelector.h>
Classes | |
class | namedModel |
Internal data type to facilitate the administration of named color models. More... | |
class | parameters |
the parameters for the class colorModelSelector More... | |
Public Member Functions | |
colorModelSelector () | |
colorModelSelector (const colorModelSelector &other) | |
virtual | ~colorModelSelector () |
virtual const char * | getTypeName () const |
bool | apply (const image &img, probabilityMap &colorMap, principalComponents< float > &pca) |
bool | apply (const image &img, const probabilityMap *&pColorMap, const principalComponents< float > *&pPca) |
bool | apply (const image &img, const rectangle &window, probabilityMap &colorMap, principalComponents< float > &pca) |
bool | apply (const image &img, const rectangle &window, const probabilityMap *&pColorMap, const principalComponents< float > *&pPca) |
bool | apply (const image &img, probabilityMap &colorMap) const |
bool | apply (const image &img, const probabilityMap *&pColorMap) const |
bool | apply (const image &img, const probabilityMap *&pColorMap, std::string &modelName) const |
bool | apply (const image &img, const rectangle &window, const probabilityMap *&pColorMap, const principalComponents< float > *&pPca, std::string &modelName) |
bool | apply (const image &img, const rectangle &window, probabilityMap &colorMap) const |
bool | apply (const image &img, const rectangle &window, const probabilityMap *&pColorMap) const |
bool | apply (const image &img, const rectangle &window, const probabilityMap *&pColorMap, std::string &modelName) const |
bool | addColorModel (const std::string &name, const std::string &colorHistFileName, const std::string &nonColorHistFileName) |
bool | addColorModel (const std::string &name, const thistogram< double > &colorHist, const thistogram< double > &nonColorHist) |
bool | addColorModel (const std::string &name, const probabilityMap &colorMap) |
bool | updateModels (const probabilityMap::parameters &newAttribs) |
bool | initPCA () |
bool | clearColorModels () |
bool | removeColorModel (const std::string &name) |
colorModelSelector & | copy (const colorModelSelector &other) |
colorModelSelector & | operator= (const colorModelSelector &other) |
bool | read (ioHandler &handler, const bool complete=true) |
bool | write (ioHandler &handler, const bool complete=true) const |
virtual functor * | clone () const |
const parameters & | getParameters () const |
Protected Attributes | |
std::list< namedModel > | modelList |
This functor selects one color model from a set, which elements were given by addColorModel.
The selected model (a lti::probabilityMap functor) will be the one which maximizes the likelihood in the given image window, i.e. the model which achieves the maximal average probability in the given window.
The window size and position can be defined once in the parameters, or can be be given directly to the required apply methods.
It is also possible to get the lti::principalComponents object that will zoom into the model colors. This is mainly used to zoom into skin colors, to allow the segmentation between skin-similar and skin colors. The computation of the PCA will be delayed until the first apply requires it, or when the user explicitelly calls initPCA. This is done this way to avoid waiting times in those cases where the color zoom is not required.
lti::colorModelSelector::colorModelSelector | ( | ) |
default constructor
lti::colorModelSelector::colorModelSelector | ( | const colorModelSelector & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::colorModelSelector::~colorModelSelector | ( | ) | [virtual] |
destructor
bool lti::colorModelSelector::addColorModel | ( | const std::string & | name, | |
const probabilityMap & | colorMap | |||
) |
add a further color model to a intern list
name | the name for this model | |
colorMap | a probabilityMap functor with the color and non-color models. |
bool lti::colorModelSelector::addColorModel | ( | const std::string & | name, | |
const thistogram< double > & | colorHist, | |||
const thistogram< double > & | nonColorHist | |||
) |
add a further color model to a intern list
name | the name for this model | |
colorHist | thistogram<double> with the color model | |
nonColorHist | thistogram<double> with the non-color model. |
bool lti::colorModelSelector::addColorModel | ( | const std::string & | name, | |
const std::string & | colorHistFileName, | |||
const std::string & | nonColorHistFileName | |||
) |
add a further color model to a intern list.
The model is assumed to be stored in a file of a thistogram<double> written with a lispStreamHandler.
If you want to write the histograms by yourself do something like:
thistogram<double> myHist; // the histogram to be stored in a file std::ofstream out("myFile.hist"); // the file stream lti::lispStreamHandler lsh(out); // the lisp stream handler myHist.write(lsh); // write to the lisp stream handler out.close();
Please note that you can also add all histogram models directly, and at the end you can write this functor with all its models (and pca) to be readed later. This can save lots of time, specially, because the pca do not need to be computed again.
name | the name for this model | |
colorHistFileName | complete file name (path+filename) for the thistogram<double> file with the color model | |
nonColorHistFileName | complete file name (path+filename) for the thistogram<double> file with the non-color model. |
bool lti::colorModelSelector::apply | ( | const image & | img, | |
const rectangle & | window, | |||
const probabilityMap *& | pColorMap, | |||
std::string & | modelName | |||
) | const |
get a pointer to the internal stored color model functor that maximizes the likelihood for the image window specified in the parameters object.
Note that if this object is destroyed, the pointers returned will be invalid.
img | image with the source data. | |
window | the region of the image to be considered. | |
pColorMap | pointer to the internal model which maximizes the color probability for the given image window. | |
modelName | name of the model used |
bool lti::colorModelSelector::apply | ( | const image & | img, | |
const rectangle & | window, | |||
const probabilityMap *& | pColorMap | |||
) | const |
get a pointer to the internal stored color model functor that maximizes the likelihood for the image window specified in the parameters object.
Note that if this object is destroyed, the pointers returned will be invalid.
img | image with the source data. | |
window | the region of the image to be considered. | |
pColorMap | pointer to the internal model which maximizes the color probability for the given image window. |
bool lti::colorModelSelector::apply | ( | const image & | img, | |
const rectangle & | window, | |||
probabilityMap & | colorMap | |||
) | const |
Copy into colorMap the internal functor for the color model that maximizes the likelihood for the image window specified in the parameters object.
img | image with the source data. | |
window | the region of the image to be considered. | |
colorMap | the internal model which maximizes the color probability for the given image window will be copied here. |
Note that this member will copy the color model functor, and this takes some time. If you can ensure that this object will exist while using the model functor, you better get just a pointer to the internal objects.
bool lti::colorModelSelector::apply | ( | const image & | img, | |
const rectangle & | window, | |||
const probabilityMap *& | pColorMap, | |||
const principalComponents< float > *& | pPca, | |||
std::string & | modelName | |||
) |
Get a pointer to the internal stored model and transformation functors that maximize the likelihood for the image window specified in the arguments.
Note that if this object is destroyed, the pointers returned will be invalid.
img | image with the source data. | |
window | the region of the image to be considered. | |
pColorMap | pointer to the internal model which maximizes the color probability for the given image window. | |
pPca | pointer to the internal PCA functor (whitening transform) computed from the colorMap to be used in color zooming. | |
modelName | the name of the model used |
bool lti::colorModelSelector::apply | ( | const image & | img, | |
const probabilityMap *& | pColorMap, | |||
std::string & | modelName | |||
) | const |
get a pointer to the internal stored color model functor that maximizes the likelihood for the image window specified in the parameters object.
Note that if this object is destroyed, the pointers returned will be invalid.
img | image with the source data. | |
pColorMap | pointer to the internal model which maximizes the color probability for the given image window. | |
modelName | the name of the model used |
bool lti::colorModelSelector::apply | ( | const image & | img, | |
const probabilityMap *& | pColorMap | |||
) | const |
get a pointer to the internal stored color model functor that maximizes the likelihood for the image window specified in the parameters object.
Note that if this object is destroyed, the pointers returned will be invalid.
img | image with the source data. | |
pColorMap | pointer to the internal model which maximizes the color probability for the given image window. |
bool lti::colorModelSelector::apply | ( | const image & | img, | |
probabilityMap & | colorMap | |||
) | const |
copy into colorMap the internal functor for the color model that maximizes the likelihood for the image window specified in the parameters object.
img | image with the source data. | |
colorMap | the internal model which maximizes the color probability for the given image window will be copied here. |
Note that this member will copy the color model functor, and this takes some time. If you can ensure that this object will exist while using the model functor, you better get just a pointer to the internal objects.
bool lti::colorModelSelector::apply | ( | const image & | img, | |
const rectangle & | window, | |||
const probabilityMap *& | pColorMap, | |||
const principalComponents< float > *& | pPca | |||
) |
get a pointer to the internal stored model and transformation functors that maximize the likelihood for the image window specified in the parameters.
Note that if this object is destroyed, the pointers returned will be invalid.
img | image with the source data. | |
window | the region of the image to be considered. | |
pColorMap | pointer to the internal model which maximizes the color probability for the given image window. | |
pPca | pointer to the internal PCA functor (whitening transform) computed from the colorMap to be used in color zooming. |
bool lti::colorModelSelector::apply | ( | const image & | img, | |
const rectangle & | window, | |||
probabilityMap & | colorMap, | |||
principalComponents< float > & | pca | |||
) |
copy into colorMap and pca the internal functors for the color models that maximize the likelihood for the image window specified in the parameters.
img | image with the source data. | |
window | the region of the image to be considered. | |
colorMap | the internal model which maximizes the color probability for the given image window will be copied here. | |
pca | functor with the whitening transform used to zoom the color model into the whole RGB color space. |
Note that this member will copy the models and pca transformation functors, and this takes some time. If you can ensure that this object will exist while using the models and pca functors, you better get just a pointer to the internal objects.
bool lti::colorModelSelector::apply | ( | const image & | img, | |
const probabilityMap *& | pColorMap, | |||
const principalComponents< float > *& | pPca | |||
) |
get a pointer into the internal stored model and transformation functors that maximize the likelihood for the image window specified in the parameters object.
Note that if this object is destroyed, the pointers returned will be invalid.
img | image with the source data. | |
pColorMap | pointer to the internal model which maximizes the color probability for the given image window. | |
pPca | pointer to the internal PCA functor (whitening transform) computed from the colorMap to be used in color zooming. |
bool lti::colorModelSelector::apply | ( | const image & | img, | |
probabilityMap & | colorMap, | |||
principalComponents< float > & | pca | |||
) |
copy into colorMap and pca the internal functors for the color models that maximize the likelihood for the image window specified in the parameters object.
img | image with the source data. | |
colorMap | the internal model which maximizes the color probability for the given image window will be copied here. | |
pca | functor with the whitening transform used to zoom the color model into the whole RGB color space. |
Note that this member will copy the models and pca transformation functors, and this takes some time. If you can ensure that this object will exist while using the models and pca functors, you better get just a pointer to the internal objects.
bool lti::colorModelSelector::clearColorModels | ( | ) |
remove all color models
virtual functor* lti::colorModelSelector::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Implements lti::functor.
colorModelSelector& lti::colorModelSelector::copy | ( | const colorModelSelector & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::functor.
const parameters& lti::colorModelSelector::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::transform.
virtual const char* lti::colorModelSelector::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("colorModelSelector")
Reimplemented from lti::transform.
bool lti::colorModelSelector::initPCA | ( | ) |
call if you want to precompute the PCA (Whitening Transformation) for the color models, before calling the corresponding apply methods.
Otherwise, the pca will be initialized on-the-fly (when required).
colorModelSelector& lti::colorModelSelector::operator= | ( | const colorModelSelector & | other | ) |
bool lti::colorModelSelector::read | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | [virtual] |
read the colorModelSelector from the given ioHandler
handler | the ioHandler to be used | |
complete | if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written. |
Reimplemented from lti::functor.
bool lti::colorModelSelector::removeColorModel | ( | const std::string & | name | ) |
remove only the color models with the given name.
bool lti::colorModelSelector::updateModels | ( | const probabilityMap::parameters & | newAttribs | ) |
Update parameters for all models.
The color models are considered here as state, and not as part of the probabilityMap::parameters. I.e. all attributes except the histograms themselves will be updated in each of the availabe functors.
bool lti::colorModelSelector::write | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | const [virtual] |
write the colorModelSelector in the given ioHandler
handler | the ioHandler to be used | |
complete | if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written. |
Reimplemented from lti::functor.
std::list<namedModel> lti::colorModelSelector::modelList [protected] |
list with all color models