Feature.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * @file Feature.cpp
  3. * @brief abstraction of a feature
  4. * @author Erik Rodner
  5. * @date 04/21/2008
  6. */
  7. #include "core/image/ImageT.h"
  8. #include "core/vector/VectorT.h"
  9. #include "core/vector/MatrixT.h"
  10. #include <iostream>
  11. #include "Feature.h"
  12. #include "FeaturePool.h"
  13. using namespace OBJREC;
  14. using namespace std;
  15. // refactor-nice.pl: check this substitution
  16. // old: using namespace ice;
  17. using namespace NICE;
  18. Feature::Feature()
  19. {
  20. }
  21. Feature::~Feature()
  22. {
  23. }
  24. void Feature::calcFeatureValues ( const Examples & examples,
  25. vector<int> & examples_selection,
  26. FeatureValues & values ) const
  27. {
  28. for ( vector<int>::const_iterator si = examples_selection.begin();
  29. si != examples_selection.end();
  30. si++ )
  31. {
  32. int index = *si;
  33. const pair<int, Example> & p = examples[index];
  34. int classno = p.first;
  35. const Example & ce = p.second;
  36. double value = val ( &ce );
  37. values.insert ( quadruplet<double, int, int,double> ( value, classno, index, ce.weight ) );
  38. }
  39. }
  40. void Feature::calcFeatureValues ( const Examples & examples,
  41. vector<int> & examples_selection,
  42. FeatureValuesUnsorted & values ) const
  43. {
  44. for ( vector<int>::const_iterator si = examples_selection.begin();
  45. si != examples_selection.end();
  46. si++ )
  47. {
  48. int index = *si;
  49. const pair<int, Example> & p = examples[index];
  50. int classno = p.first;
  51. const Example & ce = p.second;
  52. double value = val ( &ce );
  53. values.push_back ( quadruplet<double, int, int, double> ( value, classno, index, ce.weight ) );
  54. }
  55. }