PCACompute function
(Mat, Mat, Mat)
PCACompute(
- InputArray data,
- InputOutputArray mean, {
- OutputArray? eigenvectors,
- OutputArray? eigenvalues,
- int maxComponents = 0,
PCACompute performs PCA.
The computed eigenvalues are sorted from the largest to the smallest and the corresponding eigenvectors are stored as eigenvectors rows.
Note: Calling with maxComponents == 0 (opencv default) will cause all components to be retained.
For further details, please see: https://docs.opencv.org/4.x/d2/de8/group__core__array.html#ga27a565b31d820b05dcbcd47112176b6e
Implementation
(Mat mean, Mat eigenvalues, Mat eigenvectors) PCACompute(
InputArray data,
InputOutputArray mean, {
OutputArray? eigenvectors,
OutputArray? eigenvalues,
int maxComponents = 0,
}) {
eigenvalues ??= Mat.empty();
eigenvectors ??= Mat.empty();
cvRun(
() => ccore.cv_PCACompute(
data.ref,
mean.ref,
eigenvectors!.ref,
eigenvalues!.ref,
maxComponents,
ffi.nullptr,
),
);
return (mean, eigenvalues, eigenvectors);
}