66 DllExport
void train(
const Mat &X, word nWords, dword batch = 2000,
unsigned int nIt = 1000,
float lRate =
SC_LRATE_D,
const std::string &fileName = std::string());
71 DllExport
void save(
const std::string &fileName)
const;
76 DllExport
void load(
const std::string &fileName);
82 DllExport
bool empty(
void)
const {
return m_D.empty(); }
110 #ifdef DEBUG_MODE // --- Debugging --- 130 DllExport Mat TEST_decode(
const Mat &X, cv::Size imgSize)
const;
131 #endif // --- --------- --- 145 DllExport
static Mat
img2data(
const Mat &img,
int blockSize,
float varianceThreshold = 0.0f);
158 DllExport
static Mat
data2img(
const Mat &X, cv::Size imgSize);
174 DllExport
static void calculate_W(
const Mat &X,
const Mat& D, Mat &W,
float lambda,
float epsilon,
unsigned int nIt = 800,
float lRate =
SC_LRATE_W);
186 DllExport
static void calculate_D(
const Mat &X, Mat &D,
const Mat &W,
float gamma,
unsigned int nIt = 800,
float lRate =
SC_LRATE_D);
211 static Mat
calculateGradient(
grad_type gType,
const Mat &X,
const Mat &D,
const Mat &W,
float lambda,
float epsilon,
float gamma);
222 static float calculateCost(
const Mat &X,
const Mat &D,
const Mat &W,
float lambda,
float epsilon,
float gamma);
static void calculate_W(const Mat &X, const Mat &D, Mat &W, float lambda, float epsilon, unsigned int nIt=800, float lRate=SC_LRATE_W)
Evaluates weighting coefficients matrix .
const float SC_LRATE_W
Learning rate (speed) for weights .
Sparse Dictionary Learning class.
const float SC_EPSILON
: L1-regularisation epsilon
static Mat calculateGradient(grad_type gType, const Mat &X, const Mat &D, const Mat &W, float lambda, float epsilon, float gamma)
Calculates the gradient matrices and .
static float calculateCost(const Mat &X, const Mat &D, const Mat &W, float lambda, float epsilon, float gamma)
Calculates the value of function.
static Mat data2img(const Mat &X, cv::Size imgSize)
Converts data into an image.
void save(const std::string &fileName) const
Saves dictionary into a binary file.
void load(const std::string &fileName)
Loads dictionary from the file.
virtual ~CSparseDictionary(void)
static void calculate_D(const Mat &X, Mat &D, const Mat &W, float gamma, unsigned int nIt=800, float lRate=SC_LRATE_D)
Evaluates dictionary .
const float SC_GAMMA
: L2-regularisation parameter (on dictionary words)
word getNumWords(void) const
Returns the number words in dictionary .
static Mat img2data(const Mat &img, int blockSize, float varianceThreshold=0.0f)
Converts image into data .
Mat m_D
The dictionary : Mat(size: nWords x sampleLen; type: CV_32FC1);.
void train(const Mat &X, word nWords, dword batch=2000, unsigned int nIt=1000, float lRate=SC_LRATE_D, const std::string &fileName=std::string())
Trains dictionary .
const float SC_LAMBDA
: L1-regularisation parameter (on features)
bool empty(void) const
Checks whether the dictionary has been trained or loaded.
const float SC_LRATE_D
Learning rate (speed) for dictionary .
static Mat getDictionary(const std::string &fileName)
Returns dictionary from file.
Mat getDictionary(void) const
Returns dictionary .
int getBlockSize(void) const
Returns size of the block, i.e. .