latest version v1.9 - last update 10 Apr 2010 |
This functor is used to create three-dimensional histograms for the colors of images. More...
#include <ltiColorModelEstimator.h>
Classes | |
class | parameters |
The parameters for the class colorModelEstimator. More... | |
Public Member Functions | |
colorModelEstimator () | |
colorModelEstimator (const colorModelEstimator &other) | |
virtual | ~colorModelEstimator () |
virtual const char * | getTypeName () const |
bool | reset () |
bool | consider (const rgbPixel &pix, const int times=1) |
bool | smoothConsider (const rgbPixel &pix, const int times=1) |
bool | consider (const float &c1, const float &c2, const float &c3, const int times=1) |
bool | consider (const palette &pal) |
bool | consider (const image &img) |
bool | consider (const channel &c1, const channel &c2, const channel &c3) |
bool | consider (const image &img, const channel8 &mask) |
bool | consider (const image &img, const imatrix &mask) |
bool | consider (const channel &c1, const channel &c2, const channel &c3, const channel8 &mask) |
bool | consider (const channel &c1, const channel &c2, const channel &c3, const imatrix &mask) |
bool | consider (const image &img, const channel8 &mask, const ubyte label) |
bool | consider (const image &img, const imatrix &mask, const int label) |
bool | consider (const std::list< image > &imgs) |
bool | consider (const std::list< image > &imgs, const std::list< channel8 > &masks) |
const thistogram< double > & | getColorModel () |
bool | apply (thistogram< double > &model) const |
bool | apply (trgbPixel< double > &mean, dmatrix &covar) const |
colorModelEstimator & | copy (const colorModelEstimator &other) |
colorModelEstimator & | operator= (const colorModelEstimator &other) |
virtual functor * | clone () const |
virtual bool | updateParameters () |
const parameters & | getParameters () const |
Protected Member Functions | |
void | outer (const trgbPixel< double > &a, const trgbPixel< double > &b, dmatrix &mat) const |
Protected Attributes | |
thistogram< double > | theModel |
trgbPixel< double > | sum |
dmatrix | sumOuter |
int | n |
This functor is used to create three-dimensional histograms for the colors of images.
The histograms are used as color models in functors like lti::colorModelSelector and lti::probabilityMap.
It is possible to provide whole images (usefull to create histograms of backgrounds, if they can be captured as a whole image), or images with corresponding masks, that allow to consider only those pixels with a mask value different than zero.
It is also possible to provide directly a list of images.
This functor generates also simple statistics for a multivariate gaussian model for the color (mean color and covariance matrix)
lti::colorModelEstimator::colorModelEstimator | ( | ) |
Default constructor.
lti::colorModelEstimator::colorModelEstimator | ( | const colorModelEstimator & | other | ) |
Copy constructor.
other | the object to be copied |
virtual lti::colorModelEstimator::~colorModelEstimator | ( | ) | [virtual] |
Destructor.
bool lti::colorModelEstimator::apply | ( | thistogram< double > & | model | ) | const |
Get a copy of the internal model in the given parameter.
model | the color model (as 3D histogram) computed until now |
virtual functor* lti::colorModelEstimator::clone | ( | ) | const [virtual] |
Returns a pointer to a clone of this functor.
Reimplemented from lti::statisticsFunctor.
bool lti::colorModelEstimator::consider | ( | const std::list< image > & | imgs, | |
const std::list< channel8 > & | masks | |||
) |
Consider all the images in the given list.
The mask list must have the same size, and the corresponding images must also have the same size.
imgs | list of images to be considered. | |
masks | list of all masks. |
bool lti::colorModelEstimator::consider | ( | const std::list< image > & | imgs | ) |
Consider all the images in the given list.
imgs | list of images to be considered |
bool lti::colorModelEstimator::consider | ( | const image & | img, | |
const imatrix & | mask, | |||
const int | label | |||
) |
Consider the pixels in the image, for which the corresponding pixel in the mask contains the value given by label.
The mask and the image must have the same size.
This is seldom used. See lti::computePalette, maybe that is what you are looking for!
img | image with colors to be considered | |
mask | imatrix with the mask. | |
label | only those pixel whose value in the mask are equal to this parameters will be considered. |
bool lti::colorModelEstimator::consider | ( | const image & | img, | |
const channel8 & | mask, | |||
const ubyte | label | |||
) |
Consider the pixels in the image, for which the corresponding pixel in the mask contains the value given by label.
The mask and the image must have the same size.
This is seldom used. See lti::computePalette, maybe that is what you are looking for!
img | image with colors to be considered | |
mask | channel8 with the mask. | |
label | only those pixel whose value in the mask are equal to this parameters will be considered. |
bool lti::colorModelEstimator::consider | ( | const channel & | c1, | |
const channel & | c2, | |||
const channel & | c3, | |||
const imatrix & | mask | |||
) |
Consider the pixels in the image, for which the corresponding pixel in the mask is not zero.
The mask and the image must have the same size.
c1 | first channel. | |
c2 | second channel. | |
c3 | third channel. | |
mask | imatrix with the mask. A value of zero means, that the corresponding pixel in the image must be ignored. |
bool lti::colorModelEstimator::consider | ( | const channel & | c1, | |
const channel & | c2, | |||
const channel & | c3, | |||
const channel8 & | mask | |||
) |
Consider the pixels in the image, for which the corresponding pixel in the mask is not zero.
The mask and the image must have the same size.
c1 | first channel. | |
c2 | second channel. | |
c3 | third channel. | |
mask | channel8 with the mask. A value of zero means, that the corresponding pixel in the image must be ignored. |
Consider the pixels in the image, for which the corresponding pixel in the mask is not zero.
The mask and the image must have the same size.
img | image with colors to be considered | |
mask | imatrix with the mask. A value of zero means, that the corresponding pixel in the image must be ignored. |
Consider the pixels in the image, for which the corresponding pixel in the mask is not zero.
The mask and the image must have the same size.
img | image with colors to be considered | |
mask | channel8 with the mask. A value of zero means, that the corresponding pixel in the image must be ignored. |
bool lti::colorModelEstimator::consider | ( | const image & | img | ) |
bool lti::colorModelEstimator::consider | ( | const palette & | pal | ) |
Consider a pixel for the model.
pal | the color palette to be considered |
bool lti::colorModelEstimator::consider | ( | const float & | c1, | |
const float & | c2, | |||
const float & | c3, | |||
const int | times = 1 | |||
) |
Consider a three dimensional pixel value given its three components.
It is assumed that the value range of all channels lies between 0.0 and 1.0.
c1 | first color component. | |
c2 | second color component. | |
c3 | third color component. | |
times | number of times the given color point must be consider. |
bool lti::colorModelEstimator::consider | ( | const rgbPixel & | pix, | |
const int | times = 1 | |||
) |
Consider a pixel for the model.
pix | pixel to be considered | |
times | how many times should the pixel be considered |
colorModelEstimator& lti::colorModelEstimator::copy | ( | const colorModelEstimator & | other | ) |
Copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::statisticsFunctor.
const thistogram<double>& lti::colorModelEstimator::getColorModel | ( | ) |
Get a constant reference to the internal model.
const parameters& lti::colorModelEstimator::getParameters | ( | ) | const |
Returns used parameters.
Reimplemented from lti::statisticsFunctor.
virtual const char* lti::colorModelEstimator::getTypeName | ( | ) | const [virtual] |
Returns the name of this type ("colorModelEstimator").
Reimplemented from lti::statisticsFunctor.
colorModelEstimator& lti::colorModelEstimator::operator= | ( | const colorModelEstimator & | other | ) |
void lti::colorModelEstimator::outer | ( | const trgbPixel< double > & | a, | |
const trgbPixel< double > & | b, | |||
dmatrix & | mat | |||
) | const [protected] |
Outer product of two colors.
The matrix MUST be 3x3 before calling this method.
bool lti::colorModelEstimator::reset | ( | ) |
Reset the internal histogram to consider new elements.
The internal model will be empty, but with the correct size.
bool lti::colorModelEstimator::smoothConsider | ( | const rgbPixel & | pix, | |
const int | times = 1 | |||
) |
Consider a pixel for the model.
This more time consuming consider method will not only add 1 to the "winner" bin, but will also distribute the "1" vote using tri-linear interpolation among the seven neighbors.
pix | pixel to be considered | |
times | how many times should the pixel be considered |
virtual bool lti::colorModelEstimator::updateParameters | ( | ) | [virtual] |
Set functor's parameters.
This member makes a copy of theParam: the functor will keep its own copy of the parameters!
This overloading will initialize the size of the internal color model
Reimplemented from lti::functor.
int lti::colorModelEstimator::n [protected] |
Number of pixels considered until now.
trgbPixel<double> lti::colorModelEstimator::sum [protected] |
Sum of colors until now.
dmatrix lti::colorModelEstimator::sumOuter [protected] |
Sum of outer-product of the colors until now (required for the computation of the covariance matrix.
thistogram<double> lti::colorModelEstimator::theModel [protected] |
The color model used.
If empty, it is assumed to be uninitialized.