LFColorWeijer.h 3.1 KB

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