LocalFeatureColorWeijer.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /**
  2. * @file LocalFeatureColorWeijer.cpp
  3. * @brief implementation of the color features mentioned in van de Weijer, J. & Schmid, C. Applying Color Names to Image Description (2007)
  4. * @author Björn Fröhlich
  5. * @date 01/28/2010
  6. */
  7. #ifndef LFColorWeijerINCLUDE
  8. #define LFColorWeijerINCLUDE
  9. // nice-core includes
  10. #include <core/basics/Config.h>
  11. //
  12. #include <core/image/ImageT.h>
  13. #include <core/image/MultiChannelImageT.h>
  14. #include <core/imagedisplay/ImageDisplay.h>
  15. //
  16. #include <core/vector/VectorT.h>
  17. #include <core/vector/MatrixT.h>
  18. // nice-vislearning includes
  19. #include "LocalFeature.h"
  20. namespace OBJREC {
  21. /** interface to ColorSande implementation */
  22. class LocalFeatureColorWeijer : public LocalFeature
  23. {
  24. protected:
  25. //! enum for 11 main colors
  26. enum
  27. {
  28. BLACK = 0,
  29. BLUE,
  30. BROWN,
  31. GREY,
  32. GREEN,
  33. ORANGE,
  34. PINK,
  35. PURPLE,
  36. RED,
  37. WHITE,
  38. YELLOW,
  39. LASTCOLOR
  40. };
  41. //! lookup table
  42. double hist[32][32][32][11];
  43. //! destination of the precomputed lookuptable
  44. std::string tfile;
  45. //! configuration file
  46. const NICE::Config *conf;
  47. public:
  48. /** simple constructor */
  49. LocalFeatureColorWeijer ( const NICE::Config *c );
  50. /** simple destructor */
  51. virtual ~LocalFeatureColorWeijer();
  52. /**
  53. * get the size of the descriptor
  54. * @return size of descriptor
  55. */
  56. int getDescSize () const;
  57. /**
  58. * get the colorWeijer features
  59. * @param img grayvalue input image
  60. * @param features features (output)
  61. * @param positions position of the features
  62. * @return
  63. */
  64. int getDescriptors ( const NICE::Image & img, NICE::VVector & positions, NICE::VVector & features ) const;
  65. /**
  66. * get the colorWeijer features
  67. * @param img color input image
  68. * @param features features (output)
  69. * @param positions given positions of the features
  70. * @return
  71. */
  72. int getDescriptors ( const NICE::ColorImage & img, NICE::VVector & positions, NICE::VVector & features ) const;
  73. /**
  74. * visualize the features
  75. * @param mark
  76. * @param positions
  77. * @param color
  78. */
  79. void visualizeFeatures ( NICE::Image & mark, const NICE::VVector & positions, size_t color ) const;
  80. /**
  81. * visualize the features
  82. * @param mark
  83. * @param positions
  84. * @param color
  85. */
  86. void visualizeFeatures ( NICE::ColorImage & mark, const NICE::VVector & features, const NICE::VVector & position ) const;
  87. /**
  88. * visualize the features
  89. * @param cimg
  90. */
  91. void visualizeFeatures ( const NICE::ColorImage & cimg ) const;
  92. /**
  93. * visualize the features
  94. * @param cimg
  95. * @param out
  96. */
  97. void visualizeFeatures ( const NICE::ColorImage & cimg, NICE::ColorImage & out ) const;
  98. /**
  99. * load parameters
  100. */
  101. void restore();
  102. /**
  103. * finds a colorname in a given string
  104. * @param fn input string
  105. * @return number of the color
  106. */
  107. int findColor ( std::string &fn );
  108. /**
  109. * transform each pixel of an image
  110. * @param img input image
  111. * @param feats feature vector for each pixel
  112. */
  113. void getFeats ( const NICE::ColorImage &img, NICE::MultiChannelImageT<double> &feats );
  114. };
  115. } // namespace
  116. #endif