gpt4 book ai didi

opencv - opencv2协方差矩阵奇怪的结果

转载 作者:行者123 更新时间:2023-12-02 17:48:07 26 4
gpt4 key购买 nike

以下代码给出了不一致的协方差矩阵大小。

cv::Mat A = (cv::Mat_<float>(3,2) << -1, 1, -2, 3, 4, 0);
cv::Mat covar1, covar2, covar3, covar4, mean;
calcCovarMatrix(A, covar1, mean, CV_COVAR_NORMAL | CV_COVAR_ROWS);
calcCovarMatrix(A, covar2, mean, CV_COVAR_SCRAMBLED | CV_COVAR_ROWS);
calcCovarMatrix(A, covar3, mean, CV_COVAR_NORMAL | CV_COVAR_COLS);
calcCovarMatrix(A, covar4, mean, CV_COVAR_SCRAMBLED | CV_COVAR_COLS);

std::cout << "size: " << covar1.size() << "\n";
std::cout << "size: " << covar2.size() << "\n";
std::cout << "size: " << covar3.size() << "\n";
std::cout << "size: " << covar4.size() << "\n";
covar1covar2应该具有相同的大小,因为它们都描述了行的协方差,而 covar3covar4应该具有相同的大小,因为它们都描述了列的协方差。但是,输出为:
size: [2 x 2]
size: [3 x 3]
size: [3 x 3]
size: [2 x 2]

最佳答案

calcCovarMatrix() docs,具体说,当使用CV_COVAR_SCRAMBLED时,“协方差矩阵将为nsamples x nsamples。”

关于opencv - opencv2协方差矩阵奇怪的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30316507/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com