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

Extended Pairwise Layered graph class. More...

#include <GraphLayeredExt.h>

Inheritance diagram for DirectGraphicalModels::CGraphLayeredExt:
Collaboration diagram for DirectGraphicalModels::CGraphLayeredExt:

Public Member Functions

 CGraphLayeredExt (IGraphPairwise &graph, word nLayers, byte gType=GRAPH_EDGES_GRID)
 Constructor. More...
 
virtual ~CGraphLayeredExt (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 setGraph (const Mat &potBase, const Mat &potOccl)
 Fills the graph nodes with potentials. 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 CTrainLink *linkTrainer, const Mat &featureVectors, const vec_float_t &vParams, float edgeWeight=1.0f, float linkWeight=1.0f)
 Fills the graph edges with potentials. More...
 
void fillEdges (const CTrainEdge &edgeTrainer, const CTrainLink *linkTrainer, const vec_mat_t &featureVectors, const vec_float_t &vParams, float edgeWeight=1.0f, float linkWeight=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...
 
IGraphPairwisegetGraph (void) const
 Returns the reference to 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

IGraphPairwisem_graph
 The graph. More...
 
const word m_nLayers
 Number of layers. More...
 
const byte m_gType
 Graph type (Ref. graphEdgesType) More...
 
Size m_size
 Size of the graph. More...
 

Detailed Description

Extended Pairwise Layered graph class.

This graph class provides additional functionality, when the multi-layer graph is used for 2D image classification. The implementation is based on Labeling of Partially Occluded Regions via the Multi-Layer CRF paper.

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

Definition at line 33 of file GraphLayeredExt.h.

Constructor & Destructor Documentation

◆ CGraphLayeredExt()

DirectGraphicalModels::CGraphLayeredExt::CGraphLayeredExt ( IGraphPairwise graph,
word  nLayers,
byte  gType = GRAPH_EDGES_GRID 
)
inline

Constructor.

Parameters
graphThe graph
nLayersThe number of layers
gTypeThe graph type. (Ref. graphEdgesType)

Definition at line 42 of file GraphLayeredExt.h.

◆ ~CGraphLayeredExt()

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

Member Function Documentation

◆ addDefaultEdgesModel() [1/3]

void DirectGraphicalModels::CGraphLayeredExt::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 67 of file GraphLayeredExt.cpp.

Here is the call graph for this function:

◆ addDefaultEdgesModel() [2/3]

void DirectGraphicalModels::CGraphLayeredExt::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 75 of file GraphLayeredExt.cpp.

Here is the call graph for this function:

◆ addDefaultEdgesModel() [3/3]

void DirectGraphicalModels::CGraphLayeredExt::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 84 of file GraphLayeredExt.cpp.

Here is the call graph for this function:

◆ addFeatureVecs() [1/2]

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

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 during the class construction via gType argument

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 151 of file GraphLayeredExt.cpp.

Here is the call graph for this function:

◆ addFeatureVecs() [2/2]

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

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 during the class construction via gType argument

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 200 of file GraphLayeredExt.cpp.

Here is the call graph for this function:

◆ buildGraph()

void DirectGraphicalModels::CGraphLayeredExt::buildGraph ( Size  graphSize)
overridevirtual

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

All edges in graph will have group id 0 except the edges connecting different layers (links), which will have group id 1. When called multiple times, previouse graph structure is always replaced.

Parameters
graphSizeThe size of the graph (image resolution)

Implements DirectGraphicalModels::CGraphExt.

Definition at line 13 of file GraphLayeredExt.cpp.

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

◆ defineEdgeGroup()

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

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 410 of file GraphLayeredExt.cpp.

◆ fillEdges() [1/2]

void DirectGraphicalModels::CGraphLayeredExt::fillEdges ( const CTrainEdge edgeTrainer,
const CTrainLink linkTrainer,
const Mat &  featureVectors,
const vec_float_t &  vParams,
float  edgeWeight = 1.0f,
float  linkWeight = 1.0f 
)

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
linkTrainerA pointer to tht link (inter-layer 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
edgeWeightThe weighting parameter for (within-layer) edges
linkWeightThe weighting parameter for (inter-layer) edges, i.e. links

Definition at line 253 of file GraphLayeredExt.cpp.

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

◆ fillEdges() [2/2]

void DirectGraphicalModels::CGraphLayeredExt::fillEdges ( const CTrainEdge edgeTrainer,
const CTrainLink linkTrainer,
const vec_mat_t &  featureVectors,
const vec_float_t &  vParams,
float  edgeWeight = 1.0f,
float  linkWeight = 1.0f 
)

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
linkTrainerA pointer to tht link (inter-layer 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
edgeWeightThe weighting parameter for (within-layer) edges
linkWeightThe weighting parameter for (inter-layer) edges, i.e. links

Definition at line 328 of file GraphLayeredExt.cpp.

Here is the call graph for this function:

◆ getGraph()

IGraphPairwise& DirectGraphicalModels::CGraphLayeredExt::getGraph ( void  ) const
inline

Returns the reference to the graph.

Returns
The reference to the graph

Definition at line 158 of file GraphLayeredExt.h.

◆ getSize()

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

Returns the size of the graph.

Returns
The size of the Graph

Implements DirectGraphicalModels::CGraphExt.

Definition at line 74 of file GraphLayeredExt.h.

◆ getType()

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

Returns the type of the graph.

Returns
The type of the graph (Ref. graphEdgesType)

Definition at line 153 of file GraphLayeredExt.h.

◆ setEdges()

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

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 460 of file GraphLayeredExt.cpp.

◆ setGraph() [1/2]

void DirectGraphicalModels::CGraphLayeredExt::setGraph ( const Mat &  pots)
overridevirtual

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 61 of file GraphLayeredExt.cpp.

◆ setGraph() [2/2]

void DirectGraphicalModels::CGraphLayeredExt::setGraph ( const Mat &  potBase,
const Mat &  potOccl 
)

Fills the graph nodes with potentials.

If the graph was not build beforehand, this function calls first

buildGraph(potBase.size())

This function supports PPL

Parameters
potBaseA block of potentials for the base layer: Mat(type: CV_32FC(nStatesBase))
potOcclA block of potentials for the occlusion layer: Mat(type: CV_32FC(nStatesOccl))

Definition at line 93 of file GraphLayeredExt.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ m_graph

IGraphPairwise& DirectGraphicalModels::CGraphLayeredExt::m_graph
private

The graph.

Definition at line 162 of file GraphLayeredExt.h.

◆ m_gType

const byte DirectGraphicalModels::CGraphLayeredExt::m_gType
private

Graph type (Ref. graphEdgesType)

Definition at line 164 of file GraphLayeredExt.h.

◆ m_nLayers

const word DirectGraphicalModels::CGraphLayeredExt::m_nLayers
private

Number of layers.

Definition at line 163 of file GraphLayeredExt.h.

◆ m_size

Size DirectGraphicalModels::CGraphLayeredExt::m_size
private

Size of the graph.

Definition at line 165 of file GraphLayeredExt.h.


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