Direct Graphical Models
v.1.7.0
|
Extended Pairwise Layered graph class. More...
#include <GraphLayeredExt.h>
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 >) |
Adds a block of new feature vectors. More... | |
void | addFeatureVecs (CTrainEdge &edgeTrainer, const vec_mat_t &featureVectors, const Mat >) |
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... | |
IGraphPairwise & | getGraph (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 CGraphExt & | operator= (const CGraphExt &)=delete |
Private Attributes | |
IGraphPairwise & | m_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... | |
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.
Definition at line 33 of file GraphLayeredExt.h.
|
inline |
Constructor.
graph | The graph |
nLayers | The number of layers |
gType | The graph type. (Ref. graphEdgesType) |
Definition at line 42 of file GraphLayeredExt.h.
|
virtualdefault |
|
overridevirtual |
Adds default data-independet edge model.
val | Value, specifying the smoothness strength |
weight | The weighting parameter |
Implements DirectGraphicalModels::CGraphExt.
Definition at line 67 of file GraphLayeredExt.cpp.
|
overridevirtual |
Adds default contrast-sensitive edge model.
featureVectors | Multi-channel matrix, each element of which is a multi-dimensinal point: Mat(type: CV_8UC<nFeatures>) |
val | Value, specifying the smoothness strength |
weight | The weighting parameter |
Implements DirectGraphicalModels::CGraphExt.
Definition at line 75 of file GraphLayeredExt.cpp.
|
overridevirtual |
Adds default contrast-sensitive edge model.
featureVectors | Vector of size nFeatures, each element of which is a single feature - image: Mat(type: CV_8UC1) |
val | Value, specifying the smoothness strength |
weight | The weighting parameter |
Implements DirectGraphicalModels::CGraphExt.
Definition at line 84 of file GraphLayeredExt.cpp.
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
edgeTrainer | A pointer to the edge trainer |
featureVectors | Multi-channel matrix, each element of which is a multi-dimensinal point: Mat(type: CV_8UC<nFeatures>) |
gt | Matrix, each element of which is a ground-truth state (class) |
Definition at line 151 of file GraphLayeredExt.cpp.
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
edgeTrainer | A pointer to the edge trainer |
featureVectors | Vector of size nFeatures, each element of which is a single feature - image: Mat(type: CV_8UC1) |
gt | Matrix, each element of which is a ground-truth state (class) |
Definition at line 200 of file GraphLayeredExt.cpp.
|
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.
graphSize | The size of the graph (image resolution) |
Implements DirectGraphicalModels::CGraphExt.
Definition at line 13 of file GraphLayeredExt.cpp.
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.
A | Constant line parameter |
B | Constant line parameter |
C | Constant line parameter |
group | New group ID |
Definition at line 410 of file GraphLayeredExt.cpp.
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
edgeTrainer | A pointer to the edge trainer |
linkTrainer | A pointer to tht link (inter-layer edge) trainer |
featureVectors | Multi-channel matrix, each element of which is a multi-dimensinal point: Mat(type: CV_8UC<nFeatures>) |
vParams | Array of control parameters. Please refer to the concrete model implementation of the CTrainEdge::calculateEdgePotentials() function for more details |
edgeWeight | The weighting parameter for (within-layer) edges |
linkWeight | The weighting parameter for (inter-layer) edges, i.e. links |
Definition at line 253 of file GraphLayeredExt.cpp.
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
edgeTrainer | A pointer to the edge trainer |
linkTrainer | A pointer to tht link (inter-layer edge) trainer |
featureVectors | Vector of size nFeatures, each element of which is a single feature - image: Mat(type: CV_8UC1) |
vParams | Array of control parameters. Please refer to the concrete model implementation of the CTrainEdge::calculateEdgePotentials() function for more details |
edgeWeight | The weighting parameter for (within-layer) edges |
linkWeight | The weighting parameter for (inter-layer) edges, i.e. links |
Definition at line 328 of file GraphLayeredExt.cpp.
|
inline |
Returns the reference to the graph.
Definition at line 158 of file GraphLayeredExt.h.
|
inlineoverridevirtual |
Returns the size of the graph.
Implements DirectGraphicalModels::CGraphExt.
Definition at line 74 of file GraphLayeredExt.h.
|
inline |
Returns the type of the graph.
Definition at line 153 of file GraphLayeredExt.h.
void DirectGraphicalModels::CGraphLayeredExt::setEdges | ( | std::optional< byte > | group, |
const Mat & | pot | ||
) |
Sets potential pot to all edges in the group group.
pot | Edge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1) |
group | The edge group ID |
Definition at line 460 of file GraphLayeredExt.cpp.
|
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
pots | A 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.
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
This function supports PPL
potBase | A block of potentials for the base layer: Mat(type: CV_32FC(nStatesBase)) |
potOccl | A block of potentials for the occlusion layer: Mat(type: CV_32FC(nStatesOccl)) |
Definition at line 93 of file GraphLayeredExt.cpp.
|
private |
The graph.
Definition at line 162 of file GraphLayeredExt.h.
|
private |
Graph type (Ref. graphEdgesType)
Definition at line 164 of file GraphLayeredExt.h.
|
private |
Number of layers.
Definition at line 163 of file GraphLayeredExt.h.
|
private |
Size of the graph.
Definition at line 165 of file GraphLayeredExt.h.