LocalFeatureCentrist.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**
  2. * @file LocalFeatureCentrist.h
  3. * @brief Implementation of the LocalFeatureCentrist feature published in "CENTRIST: A Visual Descriptor for Scene Categorization" (PAMI 2011)
  4. * @author Alexander Freytag
  5. * @date 12/06/2011
  6. * @NOTE NEEDS PROPER UNIT TEST!
  7. */
  8. #ifndef CENTRISTINCLUDE
  9. #define CENTRISTINCLUDE
  10. // nice-core includes
  11. #include <core/basics/Config.h>
  12. //
  13. #include <core/image/ImageT.h>
  14. //
  15. #include <core/vector/MatrixT.h>
  16. #include <core/vector/VectorT.h>
  17. #include <core/vector/VVector.h>
  18. // nice-vislearning includes
  19. #include "LocalFeature.h"
  20. namespace OBJREC {
  21. /** interface to CENTRIST implementation*/
  22. class LocalFeatureCentrist : public LocalFeature
  23. {
  24. protected:
  25. /////////////////////////
  26. /////////////////////////
  27. // PROTECTED VARIABLES //
  28. /////////////////////////
  29. /////////////////////////
  30. int i_sizeNeighborhood;
  31. /////////////////////////
  32. /////////////////////////
  33. // PROTECTED METHODS //
  34. /////////////////////////
  35. /////////////////////////
  36. int CensusTransform(const NICE::Image & img, const int & x, const int & y) const;
  37. int CensusTransform(const NICE::ColorImage & img, const int & x, const int & y, const int & channel) const;
  38. void GenerateHistForOneRect(const NICE::Image & img, const int & xi, const int & xa, const int & yi, const int & ya, NICE::Vector & feature) const;
  39. void GenerateHistForOneRect(const NICE::ColorImage & img, const int & xi, const int & xa, const int & yi, const int & ya, NICE::Vector & feature) const;
  40. void computeDesc( const NICE::Image & img, NICE::VVector & positions, NICE::VVector & descriptors ) const;
  41. void computeDesc( const NICE::ColorImage & img, NICE::VVector & positions, NICE::VVector & descriptors ) const;
  42. public:
  43. ///////////////////// ///////////////////// /////////////////////
  44. // CONSTRUCTORS / DESTRUCTORS
  45. ///////////////////// ///////////////////// /////////////////////
  46. /**
  47. * @brief default constructor
  48. * @date 09-02-2014 (dd-mm-yyyy )
  49. * @author Alexander Freytag
  50. */
  51. LocalFeatureCentrist ( );
  52. /**
  53. * @brief recommended constructor, calls initFromConfig
  54. * @date 09-02-2014 (dd-mm-yyyy )
  55. * @author Alexander Freytag
  56. */
  57. LocalFeatureCentrist ( const NICE::Config * _conf );
  58. /**
  59. * @brief simple destructor
  60. */
  61. virtual ~LocalFeatureCentrist();
  62. /**
  63. * @brief Jobs previously performed in the config-version of the constructor, read settings etc.
  64. * @author Alexander Freytag
  65. * @date 09-02-2014 ( dd-mm-yyyy )
  66. */
  67. virtual void initFromConfig ( const NICE::Config * _conf, const std::string & _confSection = "CENTRIST");
  68. ///////////////////// ///////////////////// /////////////////////
  69. // FEATURE STUFF
  70. ///////////////////// ///////////////////// //////////////////
  71. /** Beware: multiply this number by the number of channels you use in your color image*/
  72. virtual int getDescSize() const;
  73. virtual int getDescriptors ( const NICE::Image & img, NICE::VVector & positions, NICE::VVector & descriptors) const;
  74. virtual int getDescriptors ( const NICE::ColorImage & img, NICE::VVector & positions, NICE::VVector & descriptors) const;
  75. virtual void visualizeFeatures ( NICE::Image & mark,
  76. const NICE::VVector & positions,
  77. size_t color ) const;
  78. ///////////////////// INTERFACE PERSISTENT /////////////////////
  79. // interface specific methods for store and restore
  80. ///////////////////// INTERFACE PERSISTENT /////////////////////
  81. /**
  82. * @brief Load object from external file (stream)
  83. * @author Alexander Freytag
  84. * @date 09-02-2014 ( dd-mmyyyy)
  85. */
  86. virtual void restore ( std::istream & is, int format = 0 );
  87. /**
  88. * @brief Save object to external file (stream)
  89. * @author Alexander Freytag
  90. * @date 09-02-2014 ( dd-mmyyyy)
  91. */
  92. virtual void store( std::ostream & os, int format = 0 ) const;
  93. /**
  94. * @brief Clear object
  95. * @author Alexander Freytag
  96. * @date 09-02-2014 ( dd-mmyyyy)
  97. */
  98. virtual void clear ();
  99. };
  100. } // namespace
  101. #endif