Quantization.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. * @file Quantization.h
  3. * @brief Quantization of signals (Interface)
  4. * @author Erik Rodner, Alexander Freytag
  5. * @date 01/09/2012
  6. */
  7. #ifndef _NICE_QUANTIZATIONINCLUDE
  8. #define _NICE_QUANTIZATIONINCLUDE
  9. // NICE-core includes
  10. #include <core/basics/types.h>
  11. #include <core/basics/Persistent.h>
  12. //
  13. #include <core/vector/VectorT.h>
  14. // gp-hik-core includes
  15. #include "gp-hik-core/FeatureMatrixT.h"
  16. namespace NICE {
  17. /**
  18. * @class Quantization
  19. * @brief Quantization of signals
  20. * @author Erik Rodner, Alexander Freytag
  21. */
  22. class Quantization : public NICE::Persistent
  23. {
  24. /** TODO
  25. * The current implementation only provides uniform quantization. We could extend this
  26. * by giving a ParameterizedFunction object to the constructor, which would allow us to inverse transform function values
  27. * before performing the binning.
  28. */
  29. protected:
  30. uint ui_numBins;
  31. // NOTE: we do not need lower bounds,
  32. // since our features are required to be non-negative
  33. // (for applying the HIK as kernel function)
  34. NICE::Vector v_upperBounds;
  35. public:
  36. /**
  37. * @brief default constructor
  38. * @author Alexander Freytag
  39. * @date 06-02-2014
  40. */
  41. Quantization( );
  42. /**
  43. * @brief simple constructor
  44. * @author Erik Rodner
  45. * @date
  46. */
  47. Quantization( uint _numBins,
  48. NICE::Vector * v_upperBounds = NULL
  49. );
  50. /** simple destructor */
  51. virtual ~Quantization();
  52. /**
  53. * @brief get the size of the vocabulary, i.e. the number of bins
  54. */
  55. virtual uint size() const;
  56. virtual uint getNumberOfBins() const;
  57. /**
  58. * @brief get specific word or prototype element of the quantization
  59. *
  60. * @param bin the index of the bin
  61. *
  62. * @return value of the prototype
  63. */
  64. virtual double getPrototype ( uint _bin,
  65. const uint & _dim = 0
  66. ) const = 0;
  67. /**
  68. * @brief Determine for a given signal value the bin in the vocabulary. This is not the corresponding prototype, which
  69. * has to be requested with getPrototype afterwards
  70. *
  71. * @param value signal function value
  72. *
  73. * @return index of the bin entry corresponding to the given signal value
  74. */
  75. virtual uint quantize ( double _value,
  76. const uint & _dim = 0
  77. ) const = 0;
  78. //FIXME should the argument _fm be templated?
  79. virtual void computeParametersFromData ( const NICE::FeatureMatrix * _fm ) = 0;
  80. ///////////////////// INTERFACE PERSISTENT /////////////////////
  81. // interface specific methods for store and restore
  82. ///////////////////// INTERFACE PERSISTENT /////////////////////
  83. virtual void restore ( std::istream & _is,
  84. int _format = 0
  85. );
  86. virtual void store ( std::ostream & _os,
  87. int _format = 0
  88. ) const;
  89. virtual void clear () {};
  90. };
  91. }
  92. #endif