Quantization.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. namespace NICE {
  18. /**
  19. * @class Quantization
  20. * @brief Quantization of signals
  21. * @author Erik Rodner, Alexander Freytag
  22. */
  23. class Quantization : public NICE::Persistent
  24. {
  25. /** TODO
  26. * The current implementation only provides uniform quantization. We could extend this
  27. * by giving a ParameterizedFunction object to the constructor, which would allow us to inverse transform function values
  28. * before performing the binning.
  29. */
  30. protected:
  31. uint ui_numBins;
  32. // NOTE: we do not need lower bounds,
  33. // since our features are required to be non-negative
  34. // (for applying the HIK as kernel function)
  35. NICE::Vector v_upperBounds;
  36. public:
  37. /**
  38. * @brief default constructor
  39. * @author Alexander Freytag
  40. * @date 06-02-2014
  41. */
  42. Quantization( );
  43. /**
  44. * @brief simple constructor
  45. * @author Erik Rodner
  46. * @date
  47. */
  48. Quantization( uint _numBins,
  49. NICE::Vector * v_upperBounds = NULL
  50. );
  51. /** simple destructor */
  52. virtual ~Quantization();
  53. /**
  54. * @brief get the size of the vocabulary, i.e. the number of bins
  55. */
  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. virtual void computeParametersFromData ( const NICE::GMHIKernelRaw * _gm ) = 0;
  81. ///////////////////// INTERFACE PERSISTENT /////////////////////
  82. // interface specific methods for store and restore
  83. ///////////////////// INTERFACE PERSISTENT /////////////////////
  84. virtual void restore ( std::istream & _is,
  85. int _format = 0
  86. );
  87. virtual void store ( std::ostream & _os,
  88. int _format = 0
  89. ) const;
  90. virtual void clear () {};
  91. };
  92. }
  93. #endif