Quantization.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /**
  2. * @file Quantization.h
  3. * @brief Quantization of one-dimensional signals with a standard range of [0,1] (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 one-dimensional signals with a standard range of [0,1]
  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 size() const;
  54. virtual uint getNumberOfBins() const;
  55. /**
  56. * @brief get specific word or prototype element of the quantization
  57. *
  58. * @param bin the index of the bin
  59. *
  60. * @return value of the prototype
  61. */
  62. virtual double getPrototype (uint _bin) const = 0;
  63. /**
  64. * @brief Determine for a given signal value the bin in the vocabulary. This is not the corresponding prototype, which
  65. * has to be requested with getPrototype afterwards
  66. *
  67. * @param value signal function value
  68. *
  69. * @return index of the bin entry corresponding to the given signal value
  70. */
  71. virtual uint quantize ( double _value,
  72. const uint & _dim
  73. ) const = 0;
  74. ///////////////////// INTERFACE PERSISTENT /////////////////////
  75. // interface specific methods for store and restore
  76. ///////////////////// INTERFACE PERSISTENT /////////////////////
  77. virtual void restore ( std::istream & _is,
  78. int _format = 0
  79. );
  80. virtual void store ( std::ostream & _os,
  81. int _format = 0
  82. ) const;
  83. virtual void clear () {};
  84. };
  85. }
  86. #endif