Multiclass LocalBinaryPatterns Class. More...
#include <Features/LocalBinaryPatterns.H>
Public Types | |
typedef std::map< int, std::vector< std::vector < float > > > | MapModelVector |
Public Member Functions | |
LocalBinaryPatterns (int LBPRadii=1, int LBPPixels=8, int varBins=128, bool useColor=false, bool normalize=true) | |
Constructor. | |
~LocalBinaryPatterns () | |
Destructor. | |
void | addModel (const Image< PixRGB< byte > > &texture, const int id) |
Add histograms using color texture. | |
void | addModel (const std::vector< float > &lbp, const std::vector< float > &col, const std::vector< float > &var, const int id) |
Add a LBP and VAR histogram explicitly as a model to the system. | |
std::vector< float > | createHistogram (const Image< PixRGB< byte > > &texture) |
Return the final histogram. | |
void | createRawHistogram (const Image< PixRGB< byte > > &colTexture, std::vector< float > &lbps, std::vector< float > &col, std::vector< float > &vars) |
Determine the LBP histogram and variance values. | |
void | colorSum (Image< PixRGB< byte > >img, Rectangle rec, float &rg, float &by) |
Sum the colors within the rectangle. | |
std::vector< float > | convertVariance (const std::vector< float > &vars) |
Convert list of variances to a variance histogram. | |
void | setModels (const MapModelVector &models) |
Set the map of built models. | |
MapModelVector | getModels () |
Return a map of the built models. | |
void | getLabeledData (const MapModelVector &models, std::vector< std::vector< float > > &data, std::vector< float > &labels) |
Return a separate data vector and label vector from the MapModelVector. | |
std::vector< float > | merge (const std::vector< float > &left, const std::vector< float > &right) |
Merge two ordered vectors. | |
void | setIncompleteModels (const MapModelVector &incompleteModels) |
Load the incomplete models from a combined format. | |
std::vector< float > | getVarThresholds () |
void | setVarThresholds (std::vector< float > thresholds) |
void | combineModels (const std::vector< MapModelVector > &allModels, MapModelVector &combined) |
void | appendMap (MapModelVector &dst, const MapModelVector &src) |
MapModelVector | getIncompleteModels () |
Return the incomplete models in a combined format. | |
void | buildModels () |
After all model exemplars have been given, build final model histograms and set up variance bins. | |
void | convertIncompleteModels () |
Convert incomplete models to complete models. | |
int | predict (const Image< float > &texture) |
Predict using classifier. | |
uint | getTotalModelExemplars (MapModelVector models) |
Get total number of model exemplars. | |
MapModelVector | readModelsFile (std::string modelsFile) |
Read file of models into system. | |
void | writeModelsFile (std::string modelsFile, MapModelVector models) |
Write file of models out. | |
std::vector< float > | readThresholdsFile (std::string thresholdsFile) |
void | writeThresholdsFile (std::string thresholdsFile, std::vector< float > thresholds) |
Protected Member Functions | |
template<class T > | |
int | getVarIndex (const T &thresh, float var, int binHint=-1) |
Protected Attributes | |
float | itsLBPRadius |
int | itsLBPPixels |
int | itsVarBins |
bool | itsUseColor |
bool | itsNormalize |
int | itsColorBins |
std::vector< float > | itsVarBinThresholds |
MapModelVector | itsModels |
Store each model. | |
MapModelVector | itsTempLBP |
Temporary LBP models (multiple per class). | |
MapModelVector | itsTempVariance |
List of actual variances, kept until training is complete so that a full histogram can be built. | |
MapModelVector | itsTempColor |
List of color histogram models. |
Multiclass LocalBinaryPatterns Class.
Definition at line 48 of file LocalBinaryPatterns.H.
LocalBinaryPatterns::LocalBinaryPatterns | ( | int | LBPRadii = 1 , |
|
int | LBPPixels = 8 , |
|||
int | varBins = 128 , |
|||
bool | useColor = false , |
|||
bool | normalize = true | |||
) |
Constructor.
Definition at line 64 of file LocalBinaryPatterns.C.
LocalBinaryPatterns::~LocalBinaryPatterns | ( | ) |
Destructor.
Definition at line 78 of file LocalBinaryPatterns.C.
void LocalBinaryPatterns::addModel | ( | const std::vector< float > & | lbp, | |
const std::vector< float > & | col, | |||
const std::vector< float > & | var, | |||
const int | id | |||
) |
Add a LBP and VAR histogram explicitly as a model to the system.
Definition at line 94 of file LocalBinaryPatterns.C.
References itsTempColor, itsTempLBP, and itsTempVariance.
Add histograms using color texture.
Add model to.
Definition at line 86 of file LocalBinaryPatterns.C.
References createRawHistogram().
Referenced by setIncompleteModels().
void LocalBinaryPatterns::buildModels | ( | ) |
After all model exemplars have been given, build final model histograms and set up variance bins.
Definition at line 394 of file LocalBinaryPatterns.C.
References convertIncompleteModels(), itsModels, itsTempVariance, and merge().
void LocalBinaryPatterns::colorSum | ( | Image< PixRGB< byte > > | img, | |
Rectangle | rec, | |||
float & | rg, | |||
float & | by | |||
) |
Sum the colors within the rectangle.
Definition at line 217 of file LocalBinaryPatterns.C.
References ASSERT, getLAB(), Image< T >::getVal(), Dims::h(), and Dims::w().
Referenced by createRawHistogram().
void LocalBinaryPatterns::convertIncompleteModels | ( | ) |
Convert incomplete models to complete models.
Definition at line 422 of file LocalBinaryPatterns.C.
References convertVariance(), itsModels, itsTempColor, itsTempLBP, and itsTempVariance.
Referenced by buildModels().
std::vector< float > LocalBinaryPatterns::convertVariance | ( | const std::vector< float > & | vars | ) |
Convert list of variances to a variance histogram.
Definition at line 239 of file LocalBinaryPatterns.C.
Referenced by convertIncompleteModels(), and createHistogram().
std::vector< float > LocalBinaryPatterns::createHistogram | ( | const Image< PixRGB< byte > > & | texture | ) |
Return the final histogram.
Definition at line 107 of file LocalBinaryPatterns.C.
References convertVariance(), and createRawHistogram().
void LocalBinaryPatterns::createRawHistogram | ( | const Image< PixRGB< byte > > & | colTexture, | |
std::vector< float > & | lbps, | |||
std::vector< float > & | col, | |||
std::vector< float > & | vars | |||
) |
Determine the LBP histogram and variance values.
Definition at line 119 of file LocalBinaryPatterns.C.
References abs(), ASSERT, colorSum(), Image< T >::getHeight(), Image< T >::getValInterp(), Image< T >::getWidth(), and min().
Referenced by addModel(), and createHistogram().
LocalBinaryPatterns::MapModelVector LocalBinaryPatterns::getIncompleteModels | ( | ) |
Return the incomplete models in a combined format.
Definition at line 306 of file LocalBinaryPatterns.C.
References itsTempColor, itsTempLBP, and itsTempVariance.
void LocalBinaryPatterns::getLabeledData | ( | const MapModelVector & | models, | |
std::vector< std::vector< float > > & | data, | |||
std::vector< float > & | labels | |||
) |
Return a separate data vector and label vector from the MapModelVector.
Definition at line 197 of file LocalBinaryPatterns.C.
LocalBinaryPatterns::MapModelVector LocalBinaryPatterns::getModels | ( | ) |
Return a map of the built models.
Definition at line 263 of file LocalBinaryPatterns.C.
References itsModels.
uint LocalBinaryPatterns::getTotalModelExemplars | ( | MapModelVector | models | ) |
Get total number of model exemplars.
Get number of models.
Definition at line 511 of file LocalBinaryPatterns.C.
std::vector< float > LocalBinaryPatterns::merge | ( | const std::vector< float > & | left, | |
const std::vector< float > & | right | |||
) |
Merge two ordered vectors.
Definition at line 356 of file LocalBinaryPatterns.C.
Referenced by buildModels().
int LocalBinaryPatterns::predict | ( | const Image< float > & | texture | ) |
Predict using classifier.
LocalBinaryPatterns::MapModelVector LocalBinaryPatterns::readModelsFile | ( | std::string | modelsFile | ) |
Read file of models into system.
Definition at line 523 of file LocalBinaryPatterns.C.
void LocalBinaryPatterns::setIncompleteModels | ( | const MapModelVector & | incompleteModels | ) |
Load the incomplete models from a combined format.
Definition at line 285 of file LocalBinaryPatterns.C.
References addModel().
void LocalBinaryPatterns::setModels | ( | const MapModelVector & | models | ) |
Set the map of built models.
Definition at line 268 of file LocalBinaryPatterns.C.
References itsModels.
void LocalBinaryPatterns::writeModelsFile | ( | std::string | modelsFile, | |
MapModelVector | models | |||
) |
Write file of models out.
Definition at line 561 of file LocalBinaryPatterns.C.
MapModelVector LocalBinaryPatterns::itsModels [protected] |
Store each model.
Definition at line 141 of file LocalBinaryPatterns.H.
Referenced by buildModels(), convertIncompleteModels(), getModels(), and setModels().
MapModelVector LocalBinaryPatterns::itsTempColor [protected] |
List of color histogram models.
Definition at line 147 of file LocalBinaryPatterns.H.
Referenced by addModel(), convertIncompleteModels(), and getIncompleteModels().
MapModelVector LocalBinaryPatterns::itsTempLBP [protected] |
Temporary LBP models (multiple per class).
Definition at line 143 of file LocalBinaryPatterns.H.
Referenced by addModel(), convertIncompleteModels(), and getIncompleteModels().
MapModelVector LocalBinaryPatterns::itsTempVariance [protected] |
List of actual variances, kept until training is complete so that a full histogram can be built.
Definition at line 145 of file LocalBinaryPatterns.H.
Referenced by addModel(), buildModels(), convertIncompleteModels(), and getIncompleteModels().