Quantization.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 getNumberOfBins() const;
  56. /**
  57. * @brief get specific word or prototype element of the quantization
  58. *
  59. * @param bin the index of the bin
  60. *
  61. * @return value of the prototype
  62. */
  63. virtual double getPrototype ( uint _bin,
  64. const uint & _dim = 0
  65. ) const = 0;
  66. /**
  67. * @brief Determine for a given signal value the bin in the vocabulary. This is not the corresponding prototype, which
  68. * has to be requested with getPrototype afterwards
  69. *
  70. * @param value signal function value
  71. *
  72. * @return index of the bin entry corresponding to the given signal value
  73. */
  74. virtual uint quantize ( double _value,
  75. const uint & _dim = 0
  76. ) const = 0;
  77. //FIXME should the argument _fm be templated?
  78. virtual void computeParametersFromData ( const NICE::FeatureMatrix * _fm ) = 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