Trait opencv::core::PCATraitConst
source · pub trait PCATraitConst {
// Required method
fn as_raw_PCA(&self) -> *const c_void;
// Provided methods
fn eigenvectors(&self) -> Mat { ... }
fn eigenvalues(&self) -> Mat { ... }
fn mean(&self) -> Mat { ... }
fn project(&self, vec: &impl ToInputArray) -> Result<Mat> { ... }
fn project_to(
&self,
vec: &impl ToInputArray,
result: &mut impl ToOutputArray
) -> Result<()> { ... }
fn back_project(&self, vec: &impl ToInputArray) -> Result<Mat> { ... }
fn back_project_to(
&self,
vec: &impl ToInputArray,
result: &mut impl ToOutputArray
) -> Result<()> { ... }
fn write(&self, fs: &mut impl FileStorageTrait) -> Result<()> { ... }
}
Expand description
Constant methods for core::PCA
Required Methods§
fn as_raw_PCA(&self) -> *const c_void
Provided Methods§
sourcefn eigenvectors(&self) -> Mat
fn eigenvectors(&self) -> Mat
eigenvectors of the covariation matrix
sourcefn eigenvalues(&self) -> Mat
fn eigenvalues(&self) -> Mat
eigenvalues of the covariation matrix
sourcefn mean(&self) -> Mat
fn mean(&self) -> Mat
mean value subtracted before the projection and added after the back projection
sourcefn project(&self, vec: &impl ToInputArray) -> Result<Mat>
fn project(&self, vec: &impl ToInputArray) -> Result<Mat>
Projects vector(s) to the principal component subspace.
The methods project one or more vectors to the principal component subspace, where each vector projection is represented by coefficients in the principal component basis. The first form of the method returns the matrix that the second form writes to the result. So the first form can be used as a part of expression while the second form can be more efficient in a processing loop.
§Parameters
- vec: input vector(s); must have the same dimensionality and the
same layout as the input data used at %PCA phase, that is, if
DATA_AS_ROW are specified, then
vec.cols==data.cols
(vector dimensionality) andvec.rows
is the number of vectors to project, and the same is true for the PCA::DATA_AS_COL case.
sourcefn project_to(
&self,
vec: &impl ToInputArray,
result: &mut impl ToOutputArray
) -> Result<()>
fn project_to( &self, vec: &impl ToInputArray, result: &mut impl ToOutputArray ) -> Result<()>
Projects vector(s) to the principal component subspace.
The methods project one or more vectors to the principal component subspace, where each vector projection is represented by coefficients in the principal component basis. The first form of the method returns the matrix that the second form writes to the result. So the first form can be used as a part of expression while the second form can be more efficient in a processing loop.
§Parameters
- vec: input vector(s); must have the same dimensionality and the
same layout as the input data used at %PCA phase, that is, if
DATA_AS_ROW are specified, then
vec.cols==data.cols
(vector dimensionality) andvec.rows
is the number of vectors to project, and the same is true for the PCA::DATA_AS_COL case.
§Overloaded parameters
- vec: input vector(s); must have the same dimensionality and the
same layout as the input data used at PCA phase, that is, if
DATA_AS_ROW are specified, then
vec.cols==data.cols
(vector dimensionality) andvec.rows
is the number of vectors to project, and the same is true for the PCA::DATA_AS_COL case. - result: output vectors; in case of PCA::DATA_AS_COL, the
output matrix has as many columns as the number of input vectors, this
means that
result.cols==vec.cols
and the number of rows match the number of principal components (for example,maxComponents
parameter passed to the constructor).
sourcefn back_project(&self, vec: &impl ToInputArray) -> Result<Mat>
fn back_project(&self, vec: &impl ToInputArray) -> Result<Mat>
Reconstructs vectors from their PC projections.
The methods are inverse operations to PCA::project. They take PC coordinates of projected vectors and reconstruct the original vectors. Unless all the principal components have been retained, the reconstructed vectors are different from the originals. But typically, the difference is small if the number of components is large enough (but still much smaller than the original vector dimensionality). As a result, PCA is used.
§Parameters
- vec: coordinates of the vectors in the principal component subspace, the layout and size are the same as of PCA::project output vectors.
sourcefn back_project_to(
&self,
vec: &impl ToInputArray,
result: &mut impl ToOutputArray
) -> Result<()>
fn back_project_to( &self, vec: &impl ToInputArray, result: &mut impl ToOutputArray ) -> Result<()>
Reconstructs vectors from their PC projections.
The methods are inverse operations to PCA::project. They take PC coordinates of projected vectors and reconstruct the original vectors. Unless all the principal components have been retained, the reconstructed vectors are different from the originals. But typically, the difference is small if the number of components is large enough (but still much smaller than the original vector dimensionality). As a result, PCA is used.
§Parameters
- vec: coordinates of the vectors in the principal component subspace, the layout and size are the same as of PCA::project output vectors.
§Overloaded parameters
- vec: coordinates of the vectors in the principal component subspace, the layout and size are the same as of PCA::project output vectors.
- result: reconstructed vectors; the layout and size are the same as of PCA::project input vectors.