Quantization.h 3.0 KB

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