#include <core.hpp>
Public Member Functions | |
PCA () | |
default constructor More... | |
PCA (InputArray data, InputArray mean, int flags, int maxComponents=0) | |
the constructor that performs PCA More... | |
PCA (InputArray data, InputArray mean, int flags, double retainedVariance) | |
PCA & | operator() (InputArray data, InputArray mean, int flags, int maxComponents=0) |
operator that performs PCA. The previously stored data, if any, is released More... | |
PCA & | computeVar (InputArray data, InputArray mean, int flags, double retainedVariance) |
Mat | project (InputArray vec) const |
projects vector from the original space to the principal components subspace More... | |
void | project (InputArray vec, OutputArray result) const |
projects vector from the original space to the principal components subspace More... | |
Mat | backProject (InputArray vec) const |
reconstructs the original vector from the projection More... | |
void | backProject (InputArray vec, OutputArray result) const |
reconstructs the original vector from the projection More... | |
Public Attributes | |
Mat | eigenvectors |
eigenvectors of the covariation matrix More... | |
Mat | eigenvalues |
eigenvalues of the covariation matrix More... | |
Mat | mean |
mean value subtracted before the projection and added after the back projection More... | |
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
cv::PCA::PCA | ( | InputArray | data, |
InputArray | mean, | ||
int | flags, | ||
int | maxComponents = 0 |
||
) |
the constructor that performs PCA
cv::PCA::PCA | ( | InputArray | data, |
InputArray | mean, | ||
int | flags, | ||
double | retainedVariance | ||
) |
Mat cv::PCA::backProject | ( | InputArray | vec | ) | const |
reconstructs the original vector from the projection
void cv::PCA::backProject | ( | InputArray | vec, |
OutputArray | result | ||
) | const |
reconstructs the original vector from the projection
PCA& cv::PCA::computeVar | ( | InputArray | data, |
InputArray | mean, | ||
int | flags, | ||
double | retainedVariance | ||
) |
PCA& cv::PCA::operator() | ( | InputArray | data, |
InputArray | mean, | ||
int | flags, | ||
int | maxComponents = 0 |
||
) |
operator that performs PCA. The previously stored data, if any, is released
Mat cv::PCA::project | ( | InputArray | vec | ) | const |
projects vector from the original space to the principal components subspace
void cv::PCA::project | ( | InputArray | vec, |
OutputArray | result | ||
) | const |
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