cv::SVD::compute
static void cv::SVD::compute | ( | InputArray | src, |
---|---|---|---|
OutputArray | w, | ||
OutputArray | u, | ||
OutputArray | vt, | ||
int | flags = 0 |
||
) |
參數:
//A=u*w*vt
src decomposed matrix
w calculated singular values
u calculated left singular vectors
vt transposed matrix of right singular values
flags operation flags
flags可以選的參數:
Enumerator | flag | |
SVD::MODIFY_A | 1 | allow the algorithm to modify the decomposed matrix; it can save space and speed up processing. currently ignored. |
SVD::NO_UV | 2 | indicates that only a vector of singular values w is to be processed, while u and vt will be set to empty matrices |
SVD::FULL_UV | 4 | when the matrix is not square, by default the algorithm produces u and vt matrices of sufficiently large size for the further A reconstruction; if, however, FULL_UV flag is specified, u and vt will be full-size square orthogonal matrices. |
//使用方法
Mat A, w, u, vt;
cv::SVD::compute(A, w, u, vt,SVD::FULL_UV);
cv::SVDecomp(A,w,u,vt,cv::SVD::MODIFY_A | cv::SVD::FULL_UV);
cv::SVDecomp
也是調用的上面函數
void cv::SVDecomp(InputArray src, OutputArray w, OutputArray u, OutputArray vt, int flags)
{
CV_INSTRUMENT_REGION()
SVD::compute(src, w, u, vt, flags);
}
SVD計算方法
奇異值分解定義:
有一個m×n的實數矩陣A,我們想要把它分解成如下的形式:
其中U和V均爲單位正交陣
具體計算可以參考:https://byjiang.com/2017/11/18/SVD/
或者:奇異值分解與應用
主要利用如下性質:
參考
https://docs.opencv.org/3.1.0/d2/de8/group__core__array.html#gab477b5b7b39b370bb03e75b19d2d5109