10 vec_byte_t res(nNodes);
12 bool ifLossMat = !lossMatrix.empty();
15 for (
size_t n = 0; n < nNodes; n++) {
17 if (ifLossMat) gemm(lossMatrix, pot, 1.0, Mat(), 0.0, pot);
20 if (ifLossMat) minMaxLoc(pot, NULL, NULL, &extremumLoc, NULL);
21 else minMaxLoc(pot, NULL, NULL, NULL, &extremumLoc);
22 res[n] =
static_cast<byte
>(extremumLoc.y);
30 Mat res(nStates, nStates, CV_32FC1, Scalar(1.0f));
31 for (byte i = 0; i < nStates; i++) res.at<
float>(i,i) = 0.0f;
virtual vec_byte_t decode(Mat &lossMatrix=EmptyMat) const
Approximate decoding.
virtual size_t getNumNodes(void) const =0
Returns the number of nodes in the graph.
virtual void getNode(size_t node, Mat &pot) const =0
Returns the node potential.
Interface class for graphical models.
static Mat getDefaultLossMatrix(byte nStates)
Returns a default loss matrix .