Quantization.h 3.1 KB

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