Direct Graphical Models
v.1.7.0
|
Sparse Coding feature extraction class. More...
#include <SparseCoding.h>
Public Member Functions | |
CSparseCoding (const Mat &img) | |
Constructor. More... | |
virtual | ~CSparseCoding (void) |
virtual Mat | get (void) const |
Extracts and returns the required feature. More... | |
Public Member Functions inherited from DirectGraphicalModels::fex::ILocalFeatureExtractor | |
ILocalFeatureExtractor (const Mat &img) | |
Constructor. More... | |
virtual | ~ILocalFeatureExtractor (void) |
Public Member Functions inherited from DirectGraphicalModels::fex::IFeatureExtractor | |
IFeatureExtractor (const Mat &img) | |
Constructor. More... | |
virtual | ~IFeatureExtractor (void) |
Public Member Functions inherited from DirectGraphicalModels::fex::CSparseDictionary | |
CSparseDictionary (void) | |
virtual | ~CSparseDictionary (void) |
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 \(D\). More... | |
void | save (const std::string &fileName) const |
Saves dictionary \(D\) into a binary file. More... | |
void | load (const std::string &fileName) |
Loads dictionary \(D\) from the file. More... | |
bool | empty (void) const |
Checks whether the dictionary has been trained or loaded. More... | |
Mat | getDictionary (void) const |
Returns dictionary \(D\). More... | |
int | getBlockSize (void) const |
Returns size of the block, i.e. \(\sqrt{sampleLen}\). More... | |
word | getNumWords (void) const |
Returns the number words in dictionary \(D\). More... | |
Static Public Member Functions | |
static Mat | get (const Mat &img, const Mat &D, SqNeighbourhood nbhd=sqNeighbourhood(3)) |
Extracts the sparse coding feature. More... | |
static vec_mat_t | get_v (const Mat &img, const Mat &D, SqNeighbourhood nbhd=sqNeighbourhood(3)) |
Extracts the sparse coding feature. More... | |
Static Public Member Functions inherited from DirectGraphicalModels::fex::CSparseDictionary | |
static Mat | getDictionary (const std::string &fileName) |
Returns dictionary \(D\) from file. More... | |
static Mat | img2data (const Mat &img, int blockSize, float varianceThreshold=0.0f) |
Converts image into data \(X\). More... | |
static Mat | data2img (const Mat &X, cv::Size imgSize) |
Converts data \(X\) into an image. More... | |
Additional Inherited Members | |
Protected Types inherited from DirectGraphicalModels::fex::CSparseDictionary | |
enum | grad_type { GRAD_D, GRAD_W } |
Static Protected Member Functions inherited from DirectGraphicalModels::fex::CSparseDictionary | |
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 \(W\). More... | |
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 \(D\). More... | |
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 \(\frac{\partial J(D, W)}{\partial D}\) and \(\frac{\partial J(D, W)}{\partial W}\). More... | |
static float | calculateCost (const Mat &X, const Mat &D, const Mat &W, float lambda, float epsilon, float gamma) |
Calculates the value of \(J(D, W)\) function. More... | |
Protected Attributes inherited from DirectGraphicalModels::fex::IFeatureExtractor | |
const Mat | m_img |
Container for the image, from which the features are to be extracted. More... | |
Sparse Coding feature extraction class.
Definition at line 17 of file SparseCoding.h.
|
inline |
Constructor.
img | Input image of type CV_8UC1. |
Definition at line 24 of file SparseCoding.h.
|
inlinevirtual |
Definition at line 25 of file SparseCoding.h.
|
inlinevirtual |
Extracts and returns the required feature.
Implements DirectGraphicalModels::fex::ILocalFeatureExtractor.
Definition at line 27 of file SparseCoding.h.
|
static |
Extracts the sparse coding feature.
This fuction supports dictionaries with nWords less or equal to 512 words. For larger dictionaries use CSparseCoding::get_v() function directly.
img | Input image of type CV_8UC1 or CV_8UC3. |
D | Sparse dictionary \(D\): Mat(size nWords x blockSize^2; type CV_32FC1).
|
nbhd | Neighborhood around the pixel, where the samples are estimated. (Ref. SqNeighbourhood). It shoul be a square with a side equal to blockSize. |
Definition at line 8 of file SparseCoding.cpp.
|
static |
Extracts the sparse coding feature.
This function is an alternative to get(), which can handle large amount of features (more then 512)
img | Input image of type CV_8UC1 or CV_8UC3. |
D | Sparse dictionary \(D\): Mat(size nWords x blockSize^2; type CV_32FC1).
|
nbhd | Neighborhood around the pixel, where the samples are estimated. (Ref. SqNeighbourhood). It shoul be a square with a side equal to blockSize. |
Definition at line 19 of file SparseCoding.cpp.