Direct Graphical Models  v.1.7.0
DirectGraphicalModels::CGraphPairwiseExt Class Reference

Extended Pairwise graph class for 2D image classifaction. More...

#include <GraphPairwiseExt.h>

Inheritance diagram for DirectGraphicalModels::CGraphPairwiseExt:
Collaboration diagram for DirectGraphicalModels::CGraphPairwiseExt:

Public Member Functions

 CGraphPairwiseExt (IGraphPairwise &graph, byte gType=GRAPH_EDGES_GRID)
 Constructor. More...
 
virtual ~CGraphPairwiseExt (void)=default
 
void buildGraph (Size graphSize) override
 Builds a 2D graph of size corresponding to the image resolution. More...
 
void setGraph (const Mat &pots) override
 Fills an existing 2D graph with potentials or builds a new 2D graph of size corresponding to pots.size() with potentials. More...
 
void addDefaultEdgesModel (float val, float weight=1.0f) override
 Adds default data-independet edge model. More...
 
void addDefaultEdgesModel (const Mat &featureVectors, float val, float weight=1.0f) override
 Adds default contrast-sensitive edge model. More...
 
void addDefaultEdgesModel (const vec_mat_t &featureVectors, float val, float weight=1.0f) override
 Adds default contrast-sensitive edge model. More...
 
Size getSize () const override
 Returns the size of the graph. More...
 
void addFeatureVecs (CTrainEdge &edgeTrainer, const Mat &featureVectors, const Mat &gt)
 Adds a block of new feature vectors. More...
 
void addFeatureVecs (CTrainEdge &edgeTrainer, const vec_mat_t &featureVectors, const Mat &gt)
 Adds a block of new feature vectors. More...
 
void fillEdges (const CTrainEdge &edgeTrainer, const Mat &featureVectors, const vec_float_t &vParams, float weight=1.0f)
 Fills the graph edges with potentials. More...
 
void fillEdges (const CTrainEdge &edgeTrainer, const vec_mat_t &featureVectors, const vec_float_t &vParams, float weight=1.0f)
 Fills the graph edges with potentials. More...
 
void defineEdgeGroup (float A, float B, float C, byte group)
 Assign the edges, which cross the given line to the grop group. More...
 
void setEdges (std::optional< byte > group, const Mat &pot)
 Sets potential pot to all edges in the group group. More...
 
byte getType (void) const
 Returns the type of the graph. More...
 
- Public Member Functions inherited from DirectGraphicalModels::CGraphExt
 CGraphExt (void)=default
 
 CGraphExt (const CGraphExt &)=delete
 
virtual ~CGraphExt (void)=default
 
const CGraphExtoperator= (const CGraphExt &)=delete
 

Private Attributes

std::unique_ptr< CGraphLayeredExtm_pGraphLayeredExt
 

Detailed Description

Extended Pairwise graph class for 2D image classifaction.

This graph class provides simplified interface and additional functionality, when the graph is used for 2D image classification

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 19 of file GraphPairwiseExt.h.

Constructor & Destructor Documentation

◆ CGraphPairwiseExt()

DirectGraphicalModels::CGraphPairwiseExt::CGraphPairwiseExt ( IGraphPairwise graph,
byte  gType = GRAPH_EDGES_GRID 
)
inline

Constructor.

Parameters
graphThe graph
gTypeThe graph type. (Ref. graphEdgesType)

Definition at line 27 of file GraphPairwiseExt.h.

◆ ~CGraphPairwiseExt()

virtual DirectGraphicalModels::CGraphPairwiseExt::~CGraphPairwiseExt ( void  )
virtualdefault

Member Function Documentation

◆ addDefaultEdgesModel() [1/3]

void DirectGraphicalModels::CGraphPairwiseExt::addDefaultEdgesModel ( float  val,
float  weight = 1.0f 
)
overridevirtual

Adds default data-independet edge model.

Parameters
valValue, specifying the smoothness strength
weightThe weighting parameter

Implements DirectGraphicalModels::CGraphExt.

Definition at line 9 of file GraphPairwiseExt.cpp.

Here is the call graph for this function:

◆ addDefaultEdgesModel() [2/3]

void DirectGraphicalModels::CGraphPairwiseExt::addDefaultEdgesModel ( const Mat &  featureVectors,
float  val,
float  weight = 1.0f 
)
overridevirtual

Adds default contrast-sensitive edge model.

Parameters
featureVectorsMulti-channel matrix, each element of which is a multi-dimensinal point: Mat(type: CV_8UC<nFeatures>)
valValue, specifying the smoothness strength
weightThe weighting parameter

Implements DirectGraphicalModels::CGraphExt.

Definition at line 16 of file GraphPairwiseExt.cpp.

Here is the call graph for this function:

◆ addDefaultEdgesModel() [3/3]

void DirectGraphicalModels::CGraphPairwiseExt::addDefaultEdgesModel ( const vec_mat_t &  featureVectors,
float  val,
float  weight = 1.0f 
)
overridevirtual

Adds default contrast-sensitive edge model.

Parameters
featureVectorsVector of size nFeatures, each element of which is a single feature - image: Mat(type: CV_8UC1)
valValue, specifying the smoothness strength
weightThe weighting parameter

Implements DirectGraphicalModels::CGraphExt.

Definition at line 24 of file GraphPairwiseExt.cpp.

Here is the call graph for this function:

◆ addFeatureVecs() [1/2]

void DirectGraphicalModels::CGraphPairwiseExt::addFeatureVecs ( CTrainEdge edgeTrainer,
const Mat &  featureVectors,
const Mat &  gt 
)
inline

Adds a block of new feature vectors.

This function may be used only for basic graphical models, built with the CGraphExt::build() method. It extracts pairs of feature vectors with corresponding ground-truth values from blocks featureVectors and gt, according to the graph structure, provided via pGraph

Parameters
edgeTrainerA pointer to the edge trainer
featureVectorsMulti-channel matrix, each element of which is a multi-dimensinal point: Mat(type: CV_8UC<nFeatures>)
gtMatrix, each element of which is a ground-truth state (class)

Definition at line 75 of file GraphPairwiseExt.h.

◆ addFeatureVecs() [2/2]

void DirectGraphicalModels::CGraphPairwiseExt::addFeatureVecs ( CTrainEdge edgeTrainer,
const vec_mat_t &  featureVectors,
const Mat &  gt 
)
inline

Adds a block of new feature vectors.

This function may be used only for basic graphical models, built with the CGraphExt::build() method. It extracts pairs of feature vectors with corresponding ground-truth values from blocks featureVectors and gt, according to the graph structure, provided via pGraph

Parameters
edgeTrainerA pointer to the edge trainer
featureVectorsVector of size nFeatures, each element of which is a single feature - image: Mat(type: CV_8UC1)
gtMatrix, each element of which is a ground-truth state (class)

Definition at line 88 of file GraphPairwiseExt.h.

◆ buildGraph()

void DirectGraphicalModels::CGraphPairwiseExt::buildGraph ( Size  graphSize)
inlineoverridevirtual

Builds a 2D graph of size corresponding to the image resolution.

When called multiple times, previouse graph structure is always replaced

Parameters
graphSizeThe size of the graph (image resolution)

Implements DirectGraphicalModels::CGraphExt.

Definition at line 33 of file GraphPairwiseExt.h.

◆ defineEdgeGroup()

void DirectGraphicalModels::CGraphPairwiseExt::defineEdgeGroup ( float  A,
float  B,
float  C,
byte  group 
)
inline

Assign the edges, which cross the given line to the grop group.

The line is given by the equation: Ax + By + C = 0. A and B are not both equal to zero.

Parameters
AConstant line parameter
BConstant line parameter
CConstant line parameter
groupNew group ID

Definition at line 128 of file GraphPairwiseExt.h.

◆ fillEdges() [1/2]

void DirectGraphicalModels::CGraphPairwiseExt::fillEdges ( const CTrainEdge edgeTrainer,
const Mat &  featureVectors,
const vec_float_t &  vParams,
float  weight = 1.0f 
)
inline

Fills the graph edges with potentials.

This function uses edgeTrainer class in oerder to achieve edge potentials from feature vectors, stored in featureVectors and fills with them the graph edges

This function supports PPL

Parameters
edgeTrainerA pointer to the edge trainer
featureVectorsMulti-channel matrix, each element of which is a multi-dimensinal point: Mat(type: CV_8UC<nFeatures>)
vParamsArray of control parameters. Please refer to the concrete model implementation of the CTrainEdge::calculateEdgePotentials() function for more details
weightThe weighting parameter

Definition at line 102 of file GraphPairwiseExt.h.

Here is the caller graph for this function:

◆ fillEdges() [2/2]

void DirectGraphicalModels::CGraphPairwiseExt::fillEdges ( const CTrainEdge edgeTrainer,
const vec_mat_t &  featureVectors,
const vec_float_t &  vParams,
float  weight = 1.0f 
)
inline

Fills the graph edges with potentials.

This function uses edgeTrainer class in oerder to achieve edge potentials from feature vectors, stored in featureVectors and fills with them the graph edges

This function supports PPL

Parameters
edgeTrainerA pointer to the edge trainer
featureVectorsVector of size nFeatures, each element of which is a single feature - image: Mat(type: CV_8UC1)
vParamsArray of control parameters. Please refer to the concrete model implementation of the CTrainEdge::calculateEdgePotentials() function for more details
weightThe weighting parameter

Definition at line 116 of file GraphPairwiseExt.h.

◆ getSize()

Size DirectGraphicalModels::CGraphPairwiseExt::getSize ( ) const
inlineoverridevirtual

Returns the size of the graph.

Returns
The size of the Graph

Implements DirectGraphicalModels::CGraphExt.

Definition at line 61 of file GraphPairwiseExt.h.

◆ getType()

byte DirectGraphicalModels::CGraphPairwiseExt::getType ( void  ) const
inline

Returns the type of the graph.

Returns
The type of the graph (Ref. graphEdgesType)

Definition at line 145 of file GraphPairwiseExt.h.

◆ setEdges()

void DirectGraphicalModels::CGraphPairwiseExt::setEdges ( std::optional< byte >  group,
const Mat &  pot 
)
inline

Sets potential pot to all edges in the group group.

Parameters
potEdge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1)
groupThe edge group ID

Definition at line 137 of file GraphPairwiseExt.h.

◆ setGraph()

void DirectGraphicalModels::CGraphPairwiseExt::setGraph ( const Mat &  pots)
inlineoverridevirtual

Fills an existing 2D graph with potentials or builds a new 2D graph of size corresponding to pots.size() with potentials.

If the graph was not build beforehand, or the size of existing graph does not correspond to pots.size() this function calls first

buildGraph(pots.size())
Parameters
potsA block of node potentials: Mat(size: image width x image height; type: CV_32FC(nStates)). It may be obtained by:

Implements DirectGraphicalModels::CGraphExt.

Definition at line 37 of file GraphPairwiseExt.h.

Member Data Documentation

◆ m_pGraphLayeredExt

std::unique_ptr<CGraphLayeredExt> DirectGraphicalModels::CGraphPairwiseExt::m_pGraphLayeredExt
private

Definition at line 152 of file GraphPairwiseExt.h.


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