【发布时间】:2015-01-17 06:25:09
【问题描述】:
从一堆图像I 中演变出一种平均颜色C_m。现在我想获得一个距离图像,使用马氏距离,其中计算每个像素到C_m 的马氏距离。我无法让 OpenCV 的 Mahalanobis() 函数工作。
我用I 的所有像素颜色计算 calcCovarMatrix,将其反转并将其传递给Mahalanobis()。接下来,我将循环遍历新图像以计算每个像素的距离:
Mat covar, incovar, mean;
calcCovarMatrix(...);
invert(covar,incovar,DECOMP_SVD);
for (int row = 0; row < image.rows; ++row) {
for (int col = 0; col < image.cols; ++col) {
Scalar color = image.at<Vec3b>(row, col);
double m_dist = Mahalanobis(color, mean, incovar);
}
}
导致:
OpenCV Error: Assertion failed (type == v2.type() && type == icovar.type() && sz == v2.size() && len == icovar.rows && len == icovar.cols) in Mahalanobis, file /tmp/opencv-8GA996/opencv-2.4.9/modules/core/src/matmul.cpp,
我的错误是什么?提前致谢!
【问题讨论】: