Table of Contents

Class PCA

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

Principal Component Analysis

public class PCA : CvObject, IDisposable
Inheritance
PCA
Implements
Inherited Members

Constructors

PCA()

default constructor.

The default constructor initializes an empty PCA structure. The other constructors initialize the structure and call PCA::operator()().

PCA(InputArray, InputArray, Flags, double)

Constructor

PCA(InputArray, InputArray, Flags, int)

Constructor

Properties

Eigenvalues

eigenvalues of the covariation matrix

Eigenvectors

eigenvalues of the covariation matrix

Mean

mean value subtracted before the projection and added after the back projection

Methods

BackProject(InputArray)

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.

BackProject(InputArray, OutputArray)

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.

Compute(InputArray, InputArray, Flags, int)

Performs PCA.

The operator performs %PCA of the supplied dataset. It is safe to reuse the same PCA structure for multiple datasets. That is, if the structure has been previously used with another dataset, the existing internal data is reclaimed and the new @ref eigenvalues, @ref eigenvectors and @ref mean are allocated and computed.

The computed @ref eigenvalues are sorted from the largest to the smallest and the corresponding @ref eigenvectors are stored as eigenvectors rows.

ComputeVar(InputArray, InputArray, Flags, double)

Performs PCA.

The operator performs %PCA of the supplied dataset. It is safe to reuse the same PCA structure for multiple datasets. That is, if the structure has been previously used with another dataset, the existing internal data is reclaimed and the new @ref eigenvalues, @ref eigenvectors and @ref mean are allocated and computed.

The computed @ref eigenvalues are sorted from the largest to the smallest and the corresponding @ref eigenvectors are stored as eigenvectors rows.

Project(InputArray)

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.

Project(InputArray, OutputArray)

Projects vector(s) to the principal component subspace.

Read(FileNode)

Load PCA objects. Loads @ref eigenvalues @ref eigenvectors and @ref mean from specified FileNode

Write(FileStorage)

Write PCA objects. Writes @ref eigenvalues @ref eigenvectors and @ref mean to specified FileStorage