latest version v1.9 - last update 10 Apr 2010 |
Considering 2d sets, which may overlap, one might ask in which sets a particular 2d point is contained. More...
#include <ltiOverlappingSets2D.h>
Classes | |
class | parameters |
The parameters for the class overlappingSets2D. More... | |
Public Member Functions | |
overlappingSets2D () | |
overlappingSets2D (const parameters &par) | |
overlappingSets2D (const overlappingSets2D &other) | |
virtual | ~overlappingSets2D () |
virtual const char * | getTypeName () const |
overlappingSets2D & | copy (const overlappingSets2D &other) |
overlappingSets2D & | operator= (const overlappingSets2D &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
bool | setParameters (const parameters &theParams) |
bool | readObjectTable (const std::string &prefix, const std::vector< std::string > &names) |
bool | setObjectTable (const std::vector< channel8 > &src) |
bool | setObjectTable (const std::vector< image > &src) |
const imatrix & | getObjectTable () const |
bool | isContained (int label, int u, int v) const |
bool | doDiscard (int u, int v) const |
bool | isInitialized () const |
bool | apply (int label, int u, int v, bool &isContained) const |
bool | apply (int u, int v, bool &doDiscard) const |
Protected Member Functions | |
bool | initObjectTable (const std::vector< channel8 > &src) |
bool | scale (const channel8 &src, channel8 &dest) const |
bool | scale (channel8 &src) const |
bool | resize () |
Protected Attributes | |
imatrix | m_objectTable |
std::vector< int > | m_id |
int | m_discardThreshold |
Considering 2d sets, which may overlap, one might ask in which sets a particular 2d point is contained.
This class creates a single 2d look up table (LUT), which stores the ids of all sets that cover a particular position. This is useful to exclude any other set from further processing. For example an image contains several objects and each object has certain 2d features, which are known a priori. If a specific feature is extracted, an application would only process the objects which contain the feature. The classes for estimating chrominance models use this framework for robustness and run time efficiency. If it is known that an object is red then only red chrominances are processed.
The LUT entry is coded in an additive manner. E.g. for a total of three sets the LUT will contain values from 0 to 7. If a position is covered by no set, the LUT contains a 0. If a position is contained in all sets the LUT's entry is 7. If a position is contained in the first and third set the LUT returns 3. If a position is contained in the third set only the LUT contains 4.
The maximum number of sets is limited by the capacity of the data type int. Caution, this class is only efficient if a few sets overlap.
lti::overlappingSets2D::overlappingSets2D | ( | ) |
Default constructor.
lti::overlappingSets2D::overlappingSets2D | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
lti::overlappingSets2D::overlappingSets2D | ( | const overlappingSets2D & | other | ) |
Copy constructor.
other | the object to be copied |
virtual lti::overlappingSets2D::~overlappingSets2D | ( | ) | [virtual] |
Destructor.
bool lti::overlappingSets2D::apply | ( | int | u, | |
int | v, | |||
bool & | doDiscard | |||
) | const |
Checks if position (u,v) is not contained in any set, whose internal id is above the discard threshold.
u | the column of the LUT. | |
v | the row of the LUT. | |
doDiscard | true if (u,v) is not contained in any set and false otherwise. |
bool lti::overlappingSets2D::apply | ( | int | label, | |
int | u, | |||
int | v, | |||
bool & | isContained | |||
) | const |
Checks if position (u,v) is contained in the set associated with the provided label.
label | the label of the set, which starts from 0. Please note that the label and the internal id are not identical. | |
u | the column of the LUT. | |
v | the row of the LUT. | |
isContained | true if (u,v) is contained in the set and false otherwise. |
virtual functor* lti::overlappingSets2D::clone | ( | ) | const [virtual] |
Returns a pointer to a clone of this functor.
Implements lti::functor.
overlappingSets2D& lti::overlappingSets2D::copy | ( | const overlappingSets2D & | other | ) |
Copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::functor.
bool lti::overlappingSets2D::doDiscard | ( | int | u, | |
int | v | |||
) | const [inline] |
Returns true if position (u,v) is not contained in any set, whose internal id is above the discard threshold.
Fast access which does not check if the LUT is initialized.
u | the column of the LUT. | |
v | the row of the LUT. |
References lti::genericMatrix< T >::at(), m_discardThreshold, and m_objectTable.
const imatrix& lti::overlappingSets2D::getObjectTable | ( | ) | const |
Returns the LUT with the overlapping sets.
const parameters& lti::overlappingSets2D::getParameters | ( | ) | const |
Returns used parameters.
Reimplemented from lti::functor.
virtual const char* lti::overlappingSets2D::getTypeName | ( | ) | const [virtual] |
Returns the name of this type ("overlappingSets2D").
Reimplemented from lti::functor.
bool lti::overlappingSets2D::initObjectTable | ( | const std::vector< channel8 > & | src | ) | [protected] |
Initialize the LUT with overlapping sets coded as channel8.
Regions that are contained in a set must have values above 0.
src | a vector containing one channel8 for each set. The internal set ids correspond with the order of this vector, but start from 1. |
bool lti::overlappingSets2D::isContained | ( | int | label, | |
int | u, | |||
int | v | |||
) | const [inline] |
Returns true if position (u,v) is contained in the set associated with the provided label.
Fast access which does not check if the LUT is initialized.
label | the label of the set, which starts from 0. Please note that the label and the internal id are not identical. | |
u | the column of the LUT. | |
v | the row of the LUT. |
References lti::genericMatrix< T >::at(), m_id, and m_objectTable.
bool lti::overlappingSets2D::isInitialized | ( | ) | const |
Checks if the LUT for the overlapping sets is initialized.
overlappingSets2D& lti::overlappingSets2D::operator= | ( | const overlappingSets2D & | other | ) |
bool lti::overlappingSets2D::readObjectTable | ( | const std::string & | prefix, | |
const std::vector< std::string > & | names | |||
) |
Initialize the LUT with the overlapping sets from disk.
Each set is interpreted as an image and loaded accordingly. Regions that are contained in a set must have intensities above 0.
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. | |
names | a vector with the filename of each image or set. The internal set ids correspond with the order of this vector, but start from 1. |
bool lti::overlappingSets2D::resize | ( | ) | [protected] |
Adjust the size of the internal LUT to fit the parameters.
The LUT will be scaled using nearest neighbor interpolation.
bool lti::overlappingSets2D::scale | ( | channel8 & | src | ) | const [protected] |
Scale a channel8 to match the LUT size specified in the parameters.
src | channel8 to be scaled. The result is left here too. |
Scale a channel8 to match the LUT size specified in the parameters.
bool lti::overlappingSets2D::setObjectTable | ( | const std::vector< image > & | src | ) |
Initialize the LUT with overlapping sets coded as channel8.
Regions that are contained in a set must have intensities above 0.
src | a vector containing one image for each set. The internal set ids correspond with the order of this vector, but start from 1. |
bool lti::overlappingSets2D::setObjectTable | ( | const std::vector< channel8 > & | src | ) |
Initialize the LUT with overlapping sets coded as channel8.
Regions that are contained in a set must have values above 0.
src | a vector containing one channel8 for each set. The internal set ids correspond with the order of this vector, but start from 1. |
bool lti::overlappingSets2D::setParameters | ( | const parameters & | theParams | ) | [virtual] |
Set used parameters.
Reimplemented from lti::functor.
int lti::overlappingSets2D::m_discardThreshold [protected] |
A copy of the discardThreshold in the parameters.
This is here for efficiency.
Referenced by doDiscard().
std::vector<int> lti::overlappingSets2D::m_id [protected] |
A table which stores the id which is associated with each label, defined by id = 2 power label.
Referenced by isContained().
imatrix lti::overlappingSets2D::m_objectTable [protected] |
The LUT with the overlapping sets.
Referenced by doDiscard(), and isContained().