opencv
2.2.0
|
#include <core.hpp>
Public Member Functions | |
Mat | backProject (const Mat &vec) const |
reconstructs the original vector from the projection | |
void | backProject (const Mat &vec, CV_OUT Mat &result) const |
reconstructs the original vector from the projection | |
PCA & | operator() (const Mat &data, const Mat &mean, int flags, int maxComponents=0) |
operator that performs PCA. The previously stored data, if any, is released | |
PCA () | |
default constructor | |
PCA (const Mat &data, const Mat &mean, int flags, int maxComponents=0) | |
the constructor that performs PCA | |
Mat | project (const Mat &vec) const |
projects vector from the original space to the principal components subspace | |
void | project (const Mat &vec, CV_OUT Mat &result) const |
projects vector from the original space to the principal components subspace | |
Public Attributes | |
Mat | eigenvalues |
eigenvalues of the covariation matrix | |
Mat | eigenvectors |
eigenvectors of the covariation matrix | |
Mat | mean |
mean value subtracted before the projection and added after the back projection | |
Principal Component Analysis
The class PCA is used to compute the special basis for a set of vectors. The basis will consist of eigenvectors of the covariance matrix computed from the input set of vectors. After PCA is performed, vectors can be transformed from the original high-dimensional space to the subspace formed by a few most prominent eigenvectors (called the principal components), corresponding to the largest eigenvalues of the covariation matrix. Thus the dimensionality of the vector and the correlation between the coordinates is reduced.
The following sample is the function that takes two matrices. The first one stores the set of vectors (a row per vector) that is used to compute PCA, the second one stores another "test" set of vectors (a row per vector) that are first compressed with PCA, then reconstructed back and then the reconstruction error norm is computed and printed for each vector.
cv::PCA::PCA | ( | ) |
default constructor
the constructor that performs PCA
reconstructs the original vector from the projection
reconstructs the original vector from the projection
operator that performs PCA. The previously stored data, if any, is released
projects vector from the original space to the principal components subspace
projects vector from the original space to the principal components subspace
Mat cv::PCA::eigenvalues |
eigenvalues of the covariation matrix
Mat cv::PCA::eigenvectors |
eigenvectors of the covariation matrix
Mat cv::PCA::mean |
mean value subtracted before the projection and added after the back projection