SparseVectorFeature.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * @file SparseVectorFeature.h
  3. * @brief feature class to use in Examples stored sparse features
  4. * @author Björn Fröhlich
  5. * @date 05/25/2009
  6. */
  7. #ifndef SparseVectorFeatureINCLUDE
  8. #define SparseVectorFeatureINCLUDE
  9. #include "core/vector/VectorT.h"
  10. #include "core/vector/MatrixT.h"
  11. #include "core/image/ImageT.h"
  12. #include "core/imagedisplay/ImageDisplay.h"
  13. #include "core/basics/Config.h"
  14. #include "vislearning/cbaselib/Feature.h"
  15. #include "core/vector/SparseVectorT.h"
  16. namespace OBJREC {
  17. class SparseVectorFeature : public Feature
  18. {
  19. protected:
  20. //! feature dimension
  21. int dimension;
  22. //! index of the feature
  23. int feature_index;
  24. public:
  25. /**
  26. * internally used by SparseVectorFeature::explode
  27. * @param _dimension new dimension
  28. * @param _feature_index new featureindex
  29. */
  30. SparseVectorFeature ( int _dimension, int _feature_index = 0 ) { dimension = _dimension; feature_index = _feature_index; };
  31. /**
  32. * simple destructor
  33. */
  34. virtual ~SparseVectorFeature();
  35. /**
  36. * returns the value of the sparse feature stored in example
  37. * @param example input example
  38. * @return feature value
  39. */
  40. double val( const Example *example ) const;
  41. /**
  42. * creates for each feature a own SparseVectorFeature in featurepool
  43. * @param featurePool the feature pool
  44. * @param variableWindow
  45. */
  46. void explode ( FeaturePool & featurePool, bool variableWindow = true ) const;
  47. Feature *clone() const;
  48. Feature *generateFirstParameter () const;
  49. /**
  50. * store the data
  51. * @param is input stream
  52. * @param format
  53. */
  54. void restore (std::istream & is, int format = 0);
  55. /**
  56. * read the data
  57. * @param os
  58. * @param format
  59. */
  60. void store (std::ostream & os, int format = 0) const;
  61. /**
  62. * does nothing
  63. */
  64. void clear ();
  65. /**
  66. * returns the feature index and the dimension
  67. * @param feature_index
  68. * @param dimension
  69. */
  70. void getStump ( int & feature_index, int & dimension ) const;
  71. };
  72. } // namespace
  73. #endif