Direct Graphical Models  v.1.5.2
DirectGraphicalModels Namespace Reference

Namespaces

 fex
 
 mathop
 Mathematical operations.
 
 parallel
 
 random
 Random number generation.
 
 Serialize
 OpenCV Mat Serialization class.
 
 Timer
 Timer
 
 vis
 

Classes

class  CBaseRandomModel
 Base abstract class for random model training. More...
 
class  CCMat
 Confusion matrix class. More...
 
class  CDecode
 Base abstract class for random model decoding. More...
 
class  CDecodeExact
 Exact decoding class. More...
 
class  CDiffFeaturesConcatenator
 Difference features concatenator class. More...
 
class  CFeaturesConcatenator
 Features concatenator base abstract class. More...
 
class  CGraph
 Pairwise graph class. More...
 
class  CGraph3
 Triple graph class. More...
 
class  CGraphBoost
 
class  CGraphExt
 Extended Pairwise graph class. More...
 
class  CGraphLayered
 Extended Pairwise Layered graph class. More...
 
class  CGraphWeiss
 Pairwise graph class. More...
 
class  CInfer
 Base abstract class for random model inference. More...
 
class  CInferChain
 Inference for chain graphs. More...
 
class  CInferExact
 Exact inference class. More...
 
class  CInferLBP
 Sum product Loopy Belief Propagation inference class. More...
 
class  CInferTree
 Inference for tree graphs (undirected graphs without loops) More...
 
class  CInferTRW
 Tree-reweighted inference class. More...
 
class  CInferViterbi
 Max product Viterbi inference class. More...
 
class  CKDNode
 k-D Node class for the k-D Tree data structure More...
 
class  CKDTree
 Class implementing k-D Tree data structure. More...
 
class  CMessagePassing
 Abstract base class for message passing inference algorithmes. More...
 
class  CNDGauss
 Multi - dimensional Gauss function class. More...
 
class  CPDFGaussian
 Gaissian-based PDF class. More...
 
class  CPDFHistogram
 Histogram-based PDF class (1D) More...
 
class  CPDFHistogram2D
 Histogram-based PDF class (2D) More...
 
class  CPowell
 The Powell search method class. More...
 
class  CPrior
 Base abstract class for prior probability estimation. More...
 
class  CPriorEdge
 Edge prior probability estimation class. More...
 
class  CPriorNode
 Node prior probability estimation class More...
 
class  CPriorTriplet
 Triplet prior probability estimation class. More...
 
class  CRForest
 Random Forest class. More...
 
class  CSamplesAccumulator
 Samples accumulator abstract class. More...
 
class  CSimpleFeaturesConcatenator
 Simple features concatenator class. More...
 
class  CTrainEdge
 Base abstract class for edge potentials training. More...
 
class  CTrainEdgeConcat
 Concatenated edge training class. More...
 
class  CTrainEdgePotts
 Potts edge training class. More...
 
class  CTrainEdgePottsCS
 Contrast-Sensitive Potts training class. More...
 
class  CTrainEdgePrior
 Contrast-Sensitive Potts training with edge prior probability class. More...
 
class  CTrainLink
 Base abstract class for link (inter-layer edge) potentials training. More...
 
class  CTrainLinkNested
 Nested link (inter-layer edge) training class. More...
 
class  CTrainNode
 Base abstract class for node potentials training. More...
 
class  CTrainNodeCvGM
 OpenCV Gaussian Model training class. More...
 
class  CTrainNodeCvGMM
 OpenCV Gaussian Mixture Model training class. More...
 
class  CTrainNodeCvRF
 OpenCV Random Forest training class. More...
 
class  CTrainNodeGM
 Gaussian Model training class. More...
 
class  CTrainNodeGMM
 Gaussian Mixture Model training class. More...
 
class  CTrainNodeKNN
 Nearest Neighbor training class. More...
 
class  CTrainNodeMsRF
 Microsoft Sherwood Random Forest training class. More...
 
class  CTrainNodeNaiveBayes
 Bayes training class. More...
 
class  CTrainTriplet
 Base abstract class for triplet potential training. More...
 
struct  Edge
 Edge structure More...
 
class  IGraph
 Interface class for graphical models. More...
 
class  IPDF
 Interface class for Probability Density Function (PDF) More...
 
class  ITrain
 Interface class for random model training. More...
 
struct  Node
 Node structure More...
 
struct  TrainNodeCvGMMParams
 OpenCV Random Forest parameters. More...
 
struct  TrainNodeCvRFParams
 OpenCV Random Forest parameters. More...
 
struct  TrainNodeGMMParams
 Gaussian Mixture Model parameters. More...
 
struct  TrainNodeKNNParams
 k-Nearest Neighbors parameters More...
 
struct  TrainNodeMsRFParams
 Microsoft Research Random Forest parameters. More...
 
struct  Triplet
 Triplet structure More...
 

Typedefs

using ptr_node_t = std::unique_ptr< Node >
 
using vec_node_t = std::vector< ptr_node_t >
 
using ptr_edge_t = std::unique_ptr< Edge >
 
using vec_edge_t = std::vector< ptr_edge_t >
 
using vec_triplet_t = std::vector< Triplet >
 
typedef struct DirectGraphicalModels::TrainNodeCvGMMParams TrainNodeCvGMMParams
 OpenCV Random Forest parameters. More...
 
typedef struct DirectGraphicalModels::TrainNodeCvRFParams TrainNodeCvRFParams
 OpenCV Random Forest parameters. More...
 
typedef struct DirectGraphicalModels::TrainNodeGMMParams TrainNodeGMMParams
 Gaussian Mixture Model parameters. More...
 
typedef struct DirectGraphicalModels::TrainNodeKNNParams TrainNodeKNNParams
 k-Nearest Neighbors parameters More...
 
typedef struct DirectGraphicalModels::TrainNodeMsRFParams TrainNodeMsRFParams
 Microsoft Research Random Forest parameters. More...
 
using vec_NDGauss_t = std::vector< CNDGauss >
 
using vec_nColor_t = std::vector< std::pair< Scalar, std::string > >
 

Enumerations

enum  RandomModelType { RM_UNARY = 1, RM_PAIRWISE, RM_TRIPLET }
 Random model types. More...
 
enum  graphType { GRAPH_EDGES_NONE = 0, GRAPH_EDGES_GRID = 1, GRAPH_EDGES_DIAG = 2, GRAPH_EDGES_LINK = 4 }
 Graph types. More...
 
enum  ePotNormApproach { eP_APP_NORM_STANDARD, eP_APP_NORM_SYMMETRIC, eP_APP_NORM_ASYMMETRIC }
 Normalization approach flag. More...
 
enum  ePotPenalApproach { eP_APP_PEN_CHAR, eP_APP_PEN_PM, eP_APP_PEN_EXP }
 Penalization approach flag. More...
 

Functions

float getAveragePrecision (const vec_byte_t &predictions, const vec_float_t &potentials, const vec_byte_t &gt, byte state)
 Returns Average Precision for the selected state (class) state. More...
 
float calculateContrast (const Mat &featureVector1, const Mat &featureVector2)
 
float penalizerChar (float x, float l)
 
float penalizerPM (float x, float l)
 
float penalizerExp (float x, float l)
 
double fastPow (double a, double b)
 
template<typename T , void(T::*)(byte b) SomeMethod>
void DGM_ELEMENTWISE1 (T &self, const Mat &m)
 
template<typename T , void(T::*)(byte b1, byte b2) SomeMethod>
void DGM_ELEMENTWISE2 (T &self, const Mat &m1, const Mat &m2)
 
template<typename T , void(T::*)(byte b1, byte b2) SomeMethod>
void DGM_ELEMENTWISE2 (T &self, const Mat &m1, const Mat &m2, const Mat &mask)
 
template<typename T , void(T::*)(const Mat &vec, byte b) SomeMethod>
void DGM_VECTORWISE1 (T &self, const Mat &m1, const Mat &m2)
 
template<typename T , void(T::*)(const Mat &vec, byte b) SomeMethod>
void DGM_VECTORWISE1 (T &self, const vec_mat_t &m1, const Mat &m2)
 
template<typename T , void(T::*)(const Mat &vec, byte b1, byte b2) SomeMethod>
void DGM_VECTORWISE2 (T &self, const Mat &m1, const Mat &m2, const Mat &m3)
 
template<typename T , void(T::*)(const Mat &vec, byte b1, byte b2) SomeMethod>
void DGM_VECTORWISE2 (T &self, const vec_mat_t &m1, const Mat &m2, const Mat &m3)
 

Variables

const TrainNodeCvGMMParams TRAIN_NODE_CV_GMM_PARAMS_DEFAULT
 
const TrainNodeCvRFParams TRAIN_NODE_CV_RF_PARAMS_DEFAULT
 
const TrainNodeGMMParams TRAIN_NODE_GMM_PARAMS_DEFAULT
 
const TrainNodeKNNParams TRAIN_NODE_KNN_PARAMS_DEFAULT
 
const TrainNodeMsRFParams TRAIN_NODE_MS_RF_PARAMS_DEFAULT
 
const size_t STR_LEN = 256
 

Typedef Documentation

◆ ptr_edge_t

using DirectGraphicalModels::ptr_edge_t = typedef std::unique_ptr<Edge>

Definition at line 63 of file Graph.h.

◆ ptr_node_t

using DirectGraphicalModels::ptr_node_t = typedef std::unique_ptr<Node>

Definition at line 29 of file Graph.h.

◆ TrainNodeCvGMMParams

◆ TrainNodeCvRFParams

◆ TrainNodeGMMParams

◆ TrainNodeKNNParams

◆ TrainNodeMsRFParams

Microsoft Research Random Forest parameters.

◆ vec_edge_t

using DirectGraphicalModels::vec_edge_t = typedef std::vector<ptr_edge_t>

Definition at line 64 of file Graph.h.

◆ vec_nColor_t

using DirectGraphicalModels::vec_nColor_t = typedef std::vector<std::pair<Scalar, std::string> >

Definition at line 61 of file types.h.

◆ vec_NDGauss_t

using DirectGraphicalModels::vec_NDGauss_t = typedef std::vector<CNDGauss>

Definition at line 60 of file types.h.

◆ vec_node_t

using DirectGraphicalModels::vec_node_t = typedef std::vector<ptr_node_t>

Definition at line 30 of file Graph.h.

◆ vec_triplet_t

using DirectGraphicalModels::vec_triplet_t = typedef std::vector<Triplet>

Definition at line 23 of file Graph3.h.

Enumeration Type Documentation

◆ ePotNormApproach

Normalization approach flag.

These flags specify the approach for normalization of the edge potential matrix. The difference between symmetric and asymmetric approaches:

  • Standard approach performs a per-element multiplication of the histogram matrix with the calar value \(1/sum\), where \(sum\) - is the sum of all matrix elements.
  • Let \(A,B\in\mathbb{S}\) - are any two different states (classes) and \(N_{AA}\) (and, consequently \(N_{BB}\)) - are number of within class transitions in training data, i.e. the doubled number of neighboring sites with the same state (class). And \(N_{AB}\equiv N_{BA}\) - are the number of transitions between classes \(A\) and \(B\), i.e. the number of neighboring sites with states (classes) \(A\) and \(B\).
  • Symmetric approach after the normalization guaranties that resulting ePot matrix is symmetric, i.e. \(M_{AB} = M_{BA}\) and \(M_{AA} = M_{BB} = 1\). In case of \(N_{AA}, N_{BB} > N_{AB}\equiv N_{BA}\), the largest number in ePot matrix will be \(1\equiv M_{AA}\equiv M_{BB}\) (ones on the diagonal); and in case of \(N_{AB}\cdot N_{AB}\geq N_{AA}\cdot N_{BB}\), it is possible to have values larger than \(M_{AB} > 1\). This case is possible to model for academic purpose, but it is almost improbable in real life applications.
  • Asymmetric approach takes into account the difference in number of occurrences of states (classes) in the training data (i.e. prior probabilities \(p(A)\) and \(p(B)\)). After the normalization it guaranties that the largest value in ePot matrix does not exceed \(1\). The case, when the diagonal values of the matrix are not the largest is usually probable (e.g. \(1 = AB > AA\) after the normalization). This may lead to erosion of areas with small occurrence rate.
  • The result of asymmetric approach could be approximated from the result of symmetric approach, by multiplying the columns of the ePot matrix with the corresponding to the base columns state (class) the prior state (class) probability.
Enumerator
eP_APP_NORM_STANDARD 

Standard approach.

eP_APP_NORM_SYMMETRIC 

Symmetric approach.

eP_APP_NORM_ASYMMETRIC 

Asymmetric approach.

Definition at line 27 of file PriorEdge.h.

◆ ePotPenalApproach

Penalization approach flag.

These flags specify which penalization function \(\mathcal{P}(d;\,\lambda)\) for penalizing the diagonal elements of the edge potential matrix will be used. Argument \(d\) usually represent the Euclidean distance between two feature vectors, which correspond to the both nodes of an edge, and thus, is a measure of similarity (or contrast) between them. Parameter \(\lambda\) defines the penalization strength. The penaliztion functions are given as follows:

  • Charbonnier penalization approach: \(\mathcal{P}(d;\,\lambda) = \frac{\lambda}{\sqrt{\lambda^2 + d^2}}\)
  • Perrona-Malik penalization approach: \(\mathcal{P}(d;\,\lambda) = \frac{\lambda^2}{\lambda^2 + d^2}\)
  • Exponential penalization approach: \(\mathcal{P}(d;\,\lambda) = e^{-\lambda d^2}\)
Enumerator
eP_APP_PEN_CHAR 

Charbonnier penalization approach.

eP_APP_PEN_PM 

Perrona-Malik penalization approach.

eP_APP_PEN_EXP 

Exponential penalization approach.

Definition at line 18 of file TrainEdgePottsCS.h.

◆ graphType

Graph types.

Define the grid of edges, connecting nodes of the graph

Enumerator
GRAPH_EDGES_NONE 

No edges.

GRAPH_EDGES_GRID 

Vertical and horizontal edges.

GRAPH_EDGES_DIAG 

Diagonal edges.

GRAPH_EDGES_LINK 

Links (inter-layer edges)

Definition at line 17 of file GraphLayered.h.

◆ RandomModelType

Random model types.

Define the maximal number of nodes in the cliques

Enumerator
RM_UNARY 

Unary random model: no iteraction between nodes.

RM_PAIRWISE 

Pairwise random model: maximum two nodes in the cliques.

RM_TRIPLET 

Triplet random model: maximum tree nodes in the cliques.

Definition at line 13 of file BaseRandomModel.h.

Function Documentation

◆ calculateContrast()

float DirectGraphicalModels::calculateContrast ( const Mat &  featureVector1,
const Mat &  featureVector2 
)

Definition at line 7 of file TrainEdgePottsCS.cpp.

Here is the caller graph for this function:

◆ DGM_ELEMENTWISE1()

template<typename T , void(T::*)(byte b) SomeMethod>
void DirectGraphicalModels::DGM_ELEMENTWISE1 ( T &  self,
const Mat &  m 
)
inline

Definition at line 57 of file macroses.h.

◆ DGM_ELEMENTWISE2() [1/2]

template<typename T , void(T::*)(byte b1, byte b2) SomeMethod>
void DirectGraphicalModels::DGM_ELEMENTWISE2 ( T &  self,
const Mat &  m1,
const Mat &  m2 
)
inline

Definition at line 71 of file macroses.h.

◆ DGM_ELEMENTWISE2() [2/2]

template<typename T , void(T::*)(byte b1, byte b2) SomeMethod>
void DirectGraphicalModels::DGM_ELEMENTWISE2 ( T &  self,
const Mat &  m1,
const Mat &  m2,
const Mat &  mask 
)
inline

Definition at line 87 of file macroses.h.

◆ DGM_VECTORWISE1() [1/2]

template<typename T , void(T::*)(const Mat &vec, byte b) SomeMethod>
void DirectGraphicalModels::DGM_VECTORWISE1 ( T &  self,
const Mat &  m1,
const Mat &  m2 
)
inline

Definition at line 105 of file macroses.h.

◆ DGM_VECTORWISE1() [2/2]

template<typename T , void(T::*)(const Mat &vec, byte b) SomeMethod>
void DirectGraphicalModels::DGM_VECTORWISE1 ( T &  self,
const vec_mat_t &  m1,
const Mat &  m2 
)
inline

Definition at line 124 of file macroses.h.

◆ DGM_VECTORWISE2() [1/2]

template<typename T , void(T::*)(const Mat &vec, byte b1, byte b2) SomeMethod>
void DirectGraphicalModels::DGM_VECTORWISE2 ( T &  self,
const Mat &  m1,
const Mat &  m2,
const Mat &  m3 
)
inline

Definition at line 146 of file macroses.h.

◆ DGM_VECTORWISE2() [2/2]

template<typename T , void(T::*)(const Mat &vec, byte b1, byte b2) SomeMethod>
void DirectGraphicalModels::DGM_VECTORWISE2 ( T &  self,
const vec_mat_t &  m1,
const Mat &  m2,
const Mat &  m3 
)
inline

Definition at line 168 of file macroses.h.

◆ fastPow()

double DirectGraphicalModels::fastPow ( double  a,
double  b 
)
inline

Definition at line 41 of file macroses.h.

Here is the caller graph for this function:

◆ penalizerChar()

float DirectGraphicalModels::penalizerChar ( float  x,
float  l 
)

Definition at line 31 of file TrainEdgePottsCS.cpp.

Here is the caller graph for this function:

◆ penalizerExp()

float DirectGraphicalModels::penalizerExp ( float  x,
float  l 
)

Definition at line 45 of file TrainEdgePottsCS.cpp.

Here is the caller graph for this function:

◆ penalizerPM()

float DirectGraphicalModels::penalizerPM ( float  x,
float  l 
)

Definition at line 38 of file TrainEdgePottsCS.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ STR_LEN

const size_t DirectGraphicalModels::STR_LEN = 256

Definition at line 62 of file types.h.

◆ TRAIN_NODE_CV_GMM_PARAMS_DEFAULT

const TrainNodeCvGMMParams DirectGraphicalModels::TRAIN_NODE_CV_GMM_PARAMS_DEFAULT
Initial value:
16,
ml::EM::COV_MAT_DIAGONAL,
100,
0.01,
TermCriteria::MAX_ITER | TermCriteria::EPS,
0
)
struct DirectGraphicalModels::TrainNodeCvGMMParams TrainNodeCvGMMParams
OpenCV Random Forest parameters.

Definition at line 24 of file TrainNodeCvGMM.h.

◆ TRAIN_NODE_CV_RF_PARAMS_DEFAULT

const TrainNodeCvRFParams DirectGraphicalModels::TRAIN_NODE_CV_RF_PARAMS_DEFAULT
Initial value:
25,
5,
0,
false,
15,
false,
4,
100,
0.01,
TermCriteria::MAX_ITER | TermCriteria::EPS,
0
)
struct DirectGraphicalModels::TrainNodeCvRFParams TrainNodeCvRFParams
OpenCV Random Forest parameters.

Definition at line 30 of file TrainNodeCvRF.h.

◆ TRAIN_NODE_GMM_PARAMS_DEFAULT

const TrainNodeGMMParams DirectGraphicalModels::TRAIN_NODE_GMM_PARAMS_DEFAULT
Initial value:
64,
64,
64,
-16,
-16
)
struct DirectGraphicalModels::TrainNodeGMMParams TrainNodeGMMParams
Gaussian Mixture Model parameters.

Definition at line 21 of file TrainNodeGMM.h.

◆ TRAIN_NODE_KNN_PARAMS_DEFAULT

const TrainNodeKNNParams DirectGraphicalModels::TRAIN_NODE_KNN_PARAMS_DEFAULT
Initial value:
0.1f,
100,
0
)
struct DirectGraphicalModels::TrainNodeKNNParams TrainNodeKNNParams
k-Nearest Neighbors parameters

Definition at line 22 of file TrainNodeKNN.h.

◆ TRAIN_NODE_MS_RF_PARAMS_DEFAULT

const TrainNodeMsRFParams DirectGraphicalModels::TRAIN_NODE_MS_RF_PARAMS_DEFAULT
Initial value:
10,
10,
10,
10,
false,
0
)
struct DirectGraphicalModels::TrainNodeMsRFParams TrainNodeMsRFParams
Microsoft Research Random Forest parameters.

Definition at line 36 of file TrainNodeMsRF.h.