1 #include "TrainNodeNaiveBayes.h" 2 #include "PDFHistogram.h" 3 #include "PDFHistogram2D.h" 4 #include "PDFGaussian.h" 66 DGM_ASSERT_MSG(gt <
m_nStates,
"The groundtruth value %d is out of range %d", gt,
m_nStates);
67 DGM_ASSERT_MSG(featureVector.type() == CV_8UC1,
"The feature vector has incorrect type");
73 byte feature = featureVector.at<byte>(f, 0);
78 byte x = featureVector.at<byte>(0, 0);
79 byte y = featureVector.at<byte>(1, 0);
94 dynamic_cast<CPDFHistogram *>(
m_pPDF[s][f])->smooth(nIt);
97 dynamic_cast<CPDFHistogram2D *>(
m_pPDF2D[s])->smooth(nIt);
129 float * pPot = potential.ptr<
float>(s);
130 byte * pMask = mask.ptr<byte>(s);
132 byte feature = featureVector.ptr<byte>(f)[0];
133 if (
m_pPDF[s][f]->isEstimated())
134 pPot[0] *= static_cast<float>(
m_pPDF[s][f]->getDensity(feature));
void smooth(int nIt=1)
Smothes the underlying Probability Density Functions (PDFs)
virtual void loadFile(FILE *pFile)
Loads the random model from the file.
IPDF *** m_pPDF
The 1D PDF for node potentials [state][feature].
virtual void train(bool doClean=false)
Random model training.
virtual void addPoint(Scalar point)=0
Adds a sample point for PDF estimation.
Histogram-based PDF class (2D)
word getNumFeatures(void) const
Returns number of features.
void addNodeGroundTruth(const Mat >)
Adds ground truth values to the co-occurance histogram vector.
virtual void reset(void)
Resets class variables.
Mat m_prior
The class prior probability vector.
virtual void saveFile(FILE *pFile) const
Saves the random model into the file.
virtual void addFeatureVec(const Mat &featureVector, byte gt)
Adds new feature vector.
CTrainNodeBayes(byte nStates, word nFeatures)
Constructor.
Base abstract class for random model training.
Histogram-based PDF class (1D)
void reset(void)
Resets class variables.
virtual void loadFile(FILE *pFile)
Loads the random model from the file.
Node prior probability estimation class
Interface class for Probability Density Function (PDF)
virtual void saveFile(FILE *pFile) const
Saves the random model into the file.
Mat getPrior(float weight=1.0f) const
Returns the prior probabilies.
virtual ~CTrainNodeBayes(void)
IPDF ** m_pPDF2D
The 2D data histogram for node potentials and 2 features[state].
Base abstract class for node potentials training.
void calculateNodePotentials(const Mat &featureVector, Mat &potential, Mat &mask) const
Calculates the node potential, based on the feature vector.
byte m_nStates
The number of states (classes)