Mahalanobis
import { Mahalanobis } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
ARGUMENTSv1, v2, icovar
FUNCTIONMahalanobis
RETURN TYPEnumber
Calculates the Mahalanobis distance between two vectors.
The function cv::Mahalanobis calculates and returns the weighted distance between two vectors:
d( \texttt{vec1} , \texttt{vec2} )= \sqrt{\sum_{i,j}{\texttt{icovar(i,j)}\cdot(\texttt{vec1}(I)-\texttt{vec2}(I))\cdot(\texttt{vec1(j)}-\texttt{vec2(j)})} }
The covariance matrix may be calculated using the #calcCovarMatrix function and then inverted using the invert function (preferably using the #DECOMP_SVD method, as the most accurate).
Mahalanobis(v1: Mat, v2: Mat, icovar: Mat): number;v1first 1D input vector.
v2second 1D input vector.
icovarinverse covariance matrix.
Returns
The number result.
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.