123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- /**
- * @file HistIntersectDistance.cpp
- * @brief $\chi^2$ distance measure
- * @author Erik Rodner
- * @date 02/19/2008
- */
- #include <iostream>
- #include <assert.h>
- #include "vislearning/math/distances/HistIntersectDistance.h"
- using namespace OBJREC;
- using namespace std;
- // refactor-nice.pl: check this substitution
- // old: using namespace ice;
- using namespace NICE;
- HistIntersectDistance::HistIntersectDistance()
- {
- }
- HistIntersectDistance::~HistIntersectDistance()
- {
- }
- double HistIntersectDistance::doCalculate (const NICE::Vector & x, const NICE::Vector & y) const
- {
- /*************************************************
- calculate (x,x) is only in seldom cases
- zero. A idea for normalization would be
- \sum_i \max{x_i,y_i} - \min{x_i,y_i}
- which is exactly the L_1 distance
- **************************************************/
- double dist = 0.0;
- for ( int i = 0 ; i < (int)x.size() ; i++ )
- {
- double u = x[i];
- double v = y[i];
-
- assert ( u >= 0 );
- assert ( v >= 0 );
- if ( u < v ) dist += u;
- else dist += v;
- }
- return - dist;
- }
|