curfil  ..
 All Classes Functions Variables Typedefs Friends Groups Pages
Public Member Functions | List of all members
curfil::RandomForestImage Class Reference

A random forest for RGB-D images. More...

#include <random_forest_image.h>

Public Member Functions

 RandomForestImage (const std::vector< std::string > &treeFiles, const std::vector< int > &deviceIds=std::vector< int >(1, 0), const AccelerationMode accelerationMode=GPU_ONLY, const double histogramBias=0.0)
 Load the random forest from disk.
 RandomForestImage (unsigned int treeCount, const TrainingConfiguration &configuration)
 Prepare a random forest with the given number of trees and the configuration.
 RandomForestImage (const std::vector< boost::shared_ptr< RandomTreeImage > > &ensemble, const TrainingConfiguration &configuration)
 Construct a random forest from the given list of existing trees.
void train (const std::vector< LabeledRGBDImage > &trainLabelImages, size_t numLabels=0, bool trainTreesSequentially=false)
 Starts the training process of the random forest.
LabelImage predict (const RGBDImage &image, cuv::ndarray< float, cuv::host_memory_space > *prediction=0, const bool onGPU=true, bool useDepthImages=true) const
LabelImage improveHistograms (const RGBDImage &trainingImage, const LabelImage &labelImage, const bool onGPU=true, bool useDepthImages=true) const
 classifies all images at the end of training - used to improve leaf distributions
void updateTreesHistograms ()
 uses the allPixelsHistograms to update the trees leaves histograms - used to improve leaf distributions
std::map< std::string, size_t > countFeatures () const
LabelType getNumClasses () const
const boost::shared_ptr
< RandomTreeImage
getTree (size_t treeNr) const
const std::vector
< boost::shared_ptr
< RandomTreeImage > > & 
getTrees () const
const TrainingConfigurationgetConfiguration () const
bool shouldIgnoreLabel (const LabelType &label) const
std::map< LabelType, RGBColorgetLabelColorMap () const
void normalizeHistograms (const double histogramBias)
 goes over all trees and normalizes the histograms

Detailed Description

A random forest for RGB-D images.

Definition at line 17 of file random_forest_image.h.

Constructor & Destructor Documentation

curfil::RandomForestImage::RandomForestImage ( const std::vector< std::string > &  treeFiles,
const std::vector< int > &  deviceIds = std::vector< int >(1, 0),
const AccelerationMode  accelerationMode = GPU_ONLY,
const double  histogramBias = 0.0 
)
explicit

Load the random forest from disk.

Parameters
treeFilespaths of JSON tree files
deviceIdsthe GPU device IDs to use for prediction
accelerationModethe acceleration mode to use for prediction. CPU or GPU.
histogramBiasif larger than 0.0, apply a histogram bias (see the Wiki) after loading the forest.
curfil::RandomForestImage::RandomForestImage ( unsigned int  treeCount,
const TrainingConfiguration configuration 
)
explicit

Prepare a random forest with the given number of trees and the configuration.

Parameters
treeCountthe number of trees in the forest
configurationthe configuration to use for training
curfil::RandomForestImage::RandomForestImage ( const std::vector< boost::shared_ptr< RandomTreeImage > > &  ensemble,
const TrainingConfiguration configuration 
)
explicit

Construct a random forest from the given list of existing trees.

Parameters
ensemblelist of trees that should be used to construct the random forest from
configurationthe configuration the trees were trained with

Member Function Documentation

std::map<std::string, size_t> curfil::RandomForestImage::countFeatures ( ) const
Returns
a recursive sum of per-feature type count
const TrainingConfiguration& curfil::RandomForestImage::getConfiguration ( ) const
inline
Returns
the configuration the random forest was trained with

Definition at line 113 of file random_forest_image.h.

std::map<LabelType, RGBColor> curfil::RandomForestImage::getLabelColorMap ( ) const
Returns
a map where keys are the labels and the values are the colors associated with them
LabelType curfil::RandomForestImage::getNumClasses ( ) const
Returns
the number of classes (labels) that random forest was trained from
const boost::shared_ptr<RandomTreeImage> curfil::RandomForestImage::getTree ( size_t  treeNr) const
inline
Returns
the n-th tree in the forest where 0 ≤ treeNr < numTrees

Definition at line 95 of file random_forest_image.h.

const std::vector<boost::shared_ptr<RandomTreeImage> >& curfil::RandomForestImage::getTrees ( ) const
inline
Returns
the list of trees in the forest

Definition at line 106 of file random_forest_image.h.

LabelImage curfil::RandomForestImage::predict ( const RGBDImage image,
cuv::ndarray< float, cuv::host_memory_space > *  prediction = 0,
const bool  onGPU = true,
bool  useDepthImages = true 
) const
Parameters
imagethe image which should be classified
predictionif not null, probabilities per class in a C×H×W matrix for C classes and an image of size W×H
onGPUwhether prediction is done using GPUs
useDepthImageswhether depth images are used when classifying images
Returns
prediction image which has the same size as 'image'
bool curfil::RandomForestImage::shouldIgnoreLabel ( const LabelType &  label) const
Returns
whether the passed label is one of those specified by the user to be ignored
void curfil::RandomForestImage::train ( const std::vector< LabeledRGBDImage > &  trainLabelImages,
size_t  numLabels = 0,
bool  trainTreesSequentially = false 
)

Starts the training process of the random forest.

Parameters
trainLabelImagesthe list of labeled images to train the random forest from
trainTreesSequentiallywhether to train the trees in the random forest in parallel or sequentially.
numLabelsnumber of classes in the images

The documentation for this class was generated from the following file: