Direct Graphical Models
v.1.7.0
|
Base abstract class for prior probability estimation. More...
#include <Prior.h>
Public Member Functions | |
CPrior (byte nStates, RandomModelType type) | |
Constructor. More... | |
~CPrior (void) | |
void | reset (void) |
Resets class variables. More... | |
Mat | getPrior (float weight=1.0f) const |
Returns the prior probabilies. More... | |
Public Member Functions inherited from DirectGraphicalModels::CBaseRandomModel | |
CBaseRandomModel (byte nStates) | |
Constructor. More... | |
virtual | ~CBaseRandomModel (void) |
virtual void | save (const std::string &path, const std::string &name=std::string(), short idx=-1) const |
Saves the training data. More... | |
virtual void | load (const std::string &path, const std::string &name=std::string(), short idx=-1) |
Loads the training data. More... | |
byte | getNumStates (void) const |
Returns number of states (classes) More... | |
Protected Member Functions | |
virtual void | saveFile (FILE *pFile) const |
Saves the random model into the file. More... | |
virtual void | loadFile (FILE *pFile) |
Loads the random model from the file. More... | |
virtual Mat | calculatePrior (void) const =0 |
Calculates the prior probabilies. More... | |
Protected Member Functions inherited from DirectGraphicalModels::CBaseRandomModel | |
std::string | generateFileName (const std::string &path, const std::string &name, short idx) const |
Generates name of the data file for storing random model parameters. More... | |
Protected Attributes | |
Mat | m_histogramPrior |
The class cooccurance histogram. More... | |
Protected Attributes inherited from DirectGraphicalModels::CBaseRandomModel | |
byte | m_nStates |
The number of states (classes) More... | |
Private Attributes | |
RandomModelType | m_type |
Type of the random model (RandomModelType) More... | |
Base abstract class for prior probability estimation.
This class implements serialization interface and defines basic interface for calculation prior probabilities.
DirectGraphicalModels::CPrior::CPrior | ( | byte | nStates, |
RandomModelType | type | ||
) |
Constructor.
nStates | Number of states (classes). |
type | Type of the random model (Ref. RandomModelType) |
|
protectedpure virtual |
Calculates the prior probabilies.
This function returns the normalized class co-occurance histogram, which ought to be build during the training phase with help of the "addGroundTruth()" functionality, implemented in derived classes.
Implemented in DirectGraphicalModels::CPriorEdge, DirectGraphicalModels::CPriorNode, and DirectGraphicalModels::CPriorTriplet.
Mat DirectGraphicalModels::CPrior::getPrior | ( | float | weight = 1.0f | ) | const |
Returns the prior probabilies.
This function calls calculatePrior() function, which should be implemented in derived classes. It returns the normalized class co-occurance histogram, multiplied with the parameter weight. If the prior probabilities were not estimated, this functions returns a uniform distribution "all ones".
weight | The weighting parameter |
Definition at line 24 of file Prior.cpp.
|
protectedvirtual |
Loads the random model from the file.
Allows to re-use the class.
pFile | Pointer to the file, opened for reading. |
Implements DirectGraphicalModels::CBaseRandomModel.
Reimplemented in DirectGraphicalModels::CTrainNodeBayes, DirectGraphicalModels::CTrainTriplet, and DirectGraphicalModels::CTrainEdgePrior.
Definition at line 55 of file Prior.cpp.
|
virtual |
Resets class variables.
Allows to re-use the class.
Implements DirectGraphicalModels::CBaseRandomModel.
Reimplemented in DirectGraphicalModels::CTrainNodeBayes, DirectGraphicalModels::CTrainEdgePrior, and DirectGraphicalModels::CTrainTriplet.
Definition at line 19 of file Prior.cpp.
|
protectedvirtual |
Saves the random model into the file.
Allows to re-use the class.
pFile | Pointer to the file, opened for writing. |
Implements DirectGraphicalModels::CBaseRandomModel.
Reimplemented in DirectGraphicalModels::CTrainNodeBayes, DirectGraphicalModels::CTrainEdgePrior, and DirectGraphicalModels::CTrainTriplet.
Definition at line 34 of file Prior.cpp.
|
protected |
|
private |
Type of the random model (RandomModelType)