Ask Your Question

ffolch's profile - activity

2021-04-07 10:06:51 -0600 received badge  Enthusiast
2020-08-04 03:42:29 -0600 asked a question TermCriteria in LogisticRegression

TermCriteria in LogisticRegression TermCriteria is not stored in the model file But, when using miniBatch, its member ma

2020-08-04 03:42:27 -0600 asked a question TermCriteria in LogisticRegression

TermCriteria in LogisticRegression TermCriteria is not stored in the model file But, when using miniBatch, its member ma

2020-06-25 09:18:47 -0600 marked best answer Mahalanobis function returns squared mahalanobis distance?

According to documentation, Mahalanobis distance returns the weighted distance between 2 vectors sqrt(sum_of_weighted_squared_diferences_with_mean) But, in the code, it doesn't seem to calculate the sqrt. It seems to return the square of the Mahalanobis distance. Is is possible?

double MahalanobisImpl(const Mat& v1, const Mat& v2, const Mat& icovar, double diff_buffer /[len]/, int len /=v1.total()*/)
{
CV_INSTRUMENT_REGION();

Size sz = v1.size();
double result = 0;

sz.width *= v1.channels();
if (v1.isContinuous() && v2.isContinuous())
{
    sz.width *= sz.height;
    sz.height = 1;
}

{
    const T* src1 = v1.ptr<T>();
    const T* src2 = v2.ptr<T>();
    size_t step1 = v1.step/sizeof(src1[0]);
    size_t step2 = v2.step/sizeof(src2[0]);
    double* diff = diff_buffer;
    const T* mat = icovar.ptr<T>();
    size_t matstep = icovar.step/sizeof(mat[0]);

    for (; sz.height--; src1 += step1, src2 += step2, diff += sz.width)
    {
        for (int i = 0; i < sz.width; i++)
            diff[i] = src1[i] - src2[i];
    }

    diff = diff_buffer;
    for (int i = 0; i < len; i++, mat += matstep)
    {
        double row_sum = 0;
        int j = 0;
#if CV_ENABLE_UNROLLED
for(; j <= len - 4; j += 4 )
row_sum += diff[j]*mat[j] + diff[j+1]*mat[j+1] +
diff[j+2]*mat[j+2] + diff[j+3]*mat[j+3];
#endif
for (; j < len; j++)
row_sum += diff[j]*mat[j];
result += row_sum * diff[i];
}
}
return result;
}
2020-06-25 04:51:37 -0600 received badge  Student (source)
2020-06-25 04:26:11 -0600 asked a question Mahalanobis function returns squared mahalanobis distance?

Mahalanobis function returns squared mahalanobis distance? According to documentation, Mahalanobis distance returns the