![]() |
Direct Graphical Models
v.1.7.0
|
Contrast-Sensitive Potts training class. More...
#include <TrainEdgePottsCS.h>
Public Member Functions | |
CTrainEdgePottsCS (byte nStates, word nFeatures, ePotPenalApproach penApproach=eP_APP_PEN_EXP) | |
Constructor. More... | |
virtual | ~CTrainEdgePottsCS (void) |
![]() | |
CTrainEdgePotts (byte nStates, word nFeatures) | |
Constructor. More... | |
virtual | ~CTrainEdgePotts (void) |
virtual void | reset (void) |
Resets class variables. More... | |
virtual void | addFeatureVecs (const Mat &featureVector1, byte gt1, const Mat &featureVector2, byte gt2) |
Adds a pair of feature vectors. More... | |
![]() | |
CTrainEdge (byte nStates, word nFeatures) | |
Constructor. More... | |
virtual | ~CTrainEdge (void)=default |
virtual void | train (bool doClean=false) |
Random model training. More... | |
Mat | getEdgePotentials (const Mat &featureVector1, const Mat &featureVector2, const vec_float_t &vParams, float weight=1.0f) const |
Returns the edge potential, based on the feature vectors. More... | |
![]() | |
ITrain (byte nStates, word nFeatures) | |
Constructor. More... | |
virtual | ~ITrain (void)=default |
word | getNumFeatures (void) const |
Returns number of features. More... | |
![]() | |
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 Mat | calculateEdgePotentials (const Mat &featureVector1, const Mat &featureVector2, const vec_float_t &vParams) const |
Returns the contrast-sensitive edge potentials. More... | |
![]() | |
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... | |
![]() | |
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... | |
Private Attributes | |
ePotPenalApproach | m_penApproach |
Additional Inherited Members | |
![]() | |
static std::shared_ptr< CTrainEdge > | create (byte edgeRandomModel, byte nStates, word nFeatures) |
Factory method returning edge trainer object. More... | |
static Mat | getDefaultEdgePotentials (float val, byte nStates) |
Returns the data-independent edge potentials. More... | |
static Mat | getDefaultEdgePotentials (const vec_float_t &values) |
Returns the data-independent edge potentials. More... | |
![]() | |
byte | m_nStates |
The number of states (classes) More... | |
Contrast-Sensitive Potts training class.
This class improves the CTrainEdgePotts class by considering the contrast in test-data between edge's nodes. In other respects this class is still training-data-independent, and thus may be applied without edge training procedure, i.e. functions reset(), save(), load(), addFeatureVecs() are unnecessary here.
This class may be used in case when the training-data for edges is not available.
Definition at line 35 of file TrainEdgePottsCS.h.
|
inline |
Constructor.
nStates | Number of states (classes) |
nFeatures | Number of features |
penApproach | Flag specifying the penalization approach for the edge potential matrix (Ref. ePotPenalApproach) |
Definition at line 44 of file TrainEdgePottsCS.h.
|
inlinevirtual |
Definition at line 49 of file TrainEdgePottsCS.h.
|
protectedvirtual |
Returns the contrast-sensitive edge potentials.
This function returns matrix with diagonal elements equal to parameter \(\vec{\theta}\) provided through argument params and penalized with a penalization function \(\mathcal{P}\), which depends on the difference between arguments featureVector1 and featureVector2; all the other elements are 1's:
\[edgePot[nStates][nStates] = \begin{bmatrix} \theta_1\mathcal{P} & 1 & \cdots & 1 \\ 1 & \theta_2\mathcal{P} & \cdots & 1 \\ \vdots & \vdots & \ddots & \vdots \\ 1 & 1 & \cdots & \theta_{nStates}\mathcal{P} \end{bmatrix}, \]
where \(\mathcal{P}\equiv\mathcal{P}(d;\,\lambda)\) is the penalization function, where \(d = ||\textbf{f}_1 - \textbf{f}_2||_2\) is the Euclidean distance between feature vectors,
and \(\lambda\) is a parameter provided through argument params. For more details on penalization fuction, please refere to ePotPenalApproach.
featureVector1 | Multi-dimensinal point \(\textbf{f}_1\): Mat(size: nFeatures x 1; type: CV_{XX}C1), corresponding to the first node of the edge |
featureVector2 | Multi-dimensinal point \(\textbf{f}_2\): Mat(size: nFeatures x 1; type: CV_{XX}C1), corresponding to the second node of the edge |
vParams | Array of control parameters \(\{\vec{\theta},\lambda\} \). \(\vec{\theta}\) may consist either from one parameter (in this case all the diagonal elemets will be the same), or from nStates parameters, specifying smoothness strength for each state (class) individually; \(\lambda\) consists from one parameter. |
If featureVector1 or featureVector2 is empty, the function returns the test-data-independent Potts potential: CTrainEdgePotts::calculateEdgePotentials()
Reimplemented from DirectGraphicalModels::CTrainEdgePotts.
Reimplemented in DirectGraphicalModels::CTrainEdgePrior.
Definition at line 52 of file TrainEdgePottsCS.cpp.
|
private |
Definition at line 72 of file TrainEdgePottsCS.h.