Direct Graphical Models  v.1.7.0
DirectGraphicalModels::CPrior Class Referenceabstract

Base abstract class for prior probability estimation. More...

#include <Prior.h>

Inheritance diagram for DirectGraphicalModels::CPrior:
Collaboration diagram for DirectGraphicalModels::CPrior:

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...
 

Detailed Description

Base abstract class for prior probability estimation.

This class implements serialization interface and defines basic interface for calculation prior probabilities.

Author
Sergey G. Kosov, serge.nosp@m.y.ko.nosp@m.sov@p.nosp@m.roje.nosp@m.ct-10.nosp@m..de

Definition at line 15 of file Prior.h.

Constructor & Destructor Documentation

◆ CPrior()

DirectGraphicalModels::CPrior::CPrior ( byte  nStates,
RandomModelType  type 
)

Constructor.

Parameters
nStatesNumber of states (classes).
typeType of the random model (Ref. RandomModelType)

Definition at line 6 of file Prior.cpp.

◆ ~CPrior()

DirectGraphicalModels::CPrior::~CPrior ( void  )

Definition at line 14 of file Prior.cpp.

Member Function Documentation

◆ calculatePrior()

virtual Mat DirectGraphicalModels::CPrior::calculatePrior ( void  ) const
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.

Returns
1D (nStates) for node, 2D (nStates x nStates) for edge or 3D (nStates x nStates x nStates) for triplet Mat of type CV_32FC1 with prior probabilies.

Implemented in DirectGraphicalModels::CPriorEdge, DirectGraphicalModels::CPriorNode, and DirectGraphicalModels::CPriorTriplet.

Here is the caller graph for this function:

◆ getPrior()

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".

Parameters
weightThe weighting parameter
Returns
1D (nStates) for node, 2D (nStates x nStates) for edge or 3D (nStates x nStates x nStates) for triplet Mat of type CV_32FC1 with prior probabilies.

Definition at line 24 of file Prior.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFile()

void DirectGraphicalModels::CPrior::loadFile ( FILE *  pFile)
protectedvirtual

Loads the random model from the file.

Allows to re-use the class.

Parameters
pFilePointer 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.

Here is the caller graph for this function:

◆ reset()

void DirectGraphicalModels::CPrior::reset ( void  )
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.

Here is the caller graph for this function:

◆ saveFile()

void DirectGraphicalModels::CPrior::saveFile ( FILE *  pFile) const
protectedvirtual

Saves the random model into the file.

Allows to re-use the class.

Parameters
pFilePointer 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.

Here is the caller graph for this function:

Member Data Documentation

◆ m_histogramPrior

Mat DirectGraphicalModels::CPrior::m_histogramPrior
protected

The class cooccurance histogram.

Definition at line 51 of file Prior.h.

◆ m_type

RandomModelType DirectGraphicalModels::CPrior::m_type
private

Type of the random model (RandomModelType)

Definition at line 55 of file Prior.h.


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