123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- /**
- * @file LFColorWeijer.cpp
- * @brief implementation of the color features mentioned in van de Weijer, J. & Schmid, C. Applying Color Names to Image Description (2007)
- * @author Björn Fröhlich
- * @date 01/28/2010
- */
- #ifndef LFColorWeijerINCLUDE
- #define LFColorWeijerINCLUDE
- #include "core/vector/VectorT.h"
- #include "core/vector/MatrixT.h"
- #include "core/image/ImageT.h"
- #include "core/imagedisplay/ImageDisplay.h"
- #include "core/image/MultiChannelImageT.h"
- #include "LocalFeature.h"
- #include "core/basics/Config.h"
- namespace OBJREC {
- /** interface to ColorSande implementation */
- class LFColorWeijer : public LocalFeature
- {
- protected:
- //! enum for 11 main colors
- enum
- {
- BLACK = 0,
- BLUE,
- BROWN,
- GREY,
- GREEN,
- ORANGE,
- PINK,
- PURPLE,
- RED,
- WHITE,
- YELLOW,
- LASTCOLOR
- };
-
- //! bins for L*, a* and b* chanel of L*a*b*
- int bin[3];
- //! upper limits for L*, a* and b* chanel of L*a*b*
- double maxv[3];
-
- //! lower limits for L*, a* and b* chanel of L*a*b*
- double minv[3];
-
- //! quantization interval for L*, a* and b* chanel of L*a*b* depending on bin, maxv and minv
- double interval[3];
-
- //! destination of the computed lookuptable
- std::string tfile;
-
- //! lookuptable for the probabilities (4d: colors, L-channel, a-channel, b-channel)
- std::vector<std::vector<std::vector<std::vector<double> > > > hist;
-
- //! configuration file
- const NICE::Config *conf;
-
- public:
-
- /** simple constructor */
- LFColorWeijer( const NICE::Config *c);
-
- /** simple destructor */
- virtual ~LFColorWeijer();
-
- /**
- * get the size of the descriptor
- * @return size of descriptor
- */
- int getDescSize () const;
-
- /**
- * get the colorWeijer features
- * @param img grayvalue input image
- * @param features features (output)
- * @param positions position of the features
- * @return
- */
- int getDescriptors ( const NICE::Image & img, NICE::VVector & positions, NICE::VVector & features ) const;
-
- /**
- * get the colorWeijer features
- * @param img color input image
- * @param features features (output)
- * @param positions given positions of the features
- * @return
- */
- int getDescriptors ( const NICE::ColorImage & img, NICE::VVector & positions, NICE::VVector & features ) const;
-
- /**
- * visualize the features
- * @param mark
- * @param positions
- * @param color
- */
- void visualizeFeatures ( NICE::Image & mark, const NICE::VVector & positions, size_t color ) const;
-
- /**
- * visualize the features
- * @param mark
- * @param positions
- * @param color
- */
- void visualizeFeatures ( NICE::ColorImage & mark, const NICE::VVector & features, const NICE::VVector & position ) const;
-
- /**
- * visualize the features
- * @param cimg
- */
- void visualizeFeatures ( const NICE::ColorImage & cimg) const;
-
- /**
- * visualize the features
- * @param cimg
- * @param out
- */
- void visualizeFeatures ( const NICE::ColorImage & cimg, NICE::ColorImage & out) const;
-
- /**
- * save parameters
- */
- void store();
-
-
- /**
- * load parameters
- */
- void restore();
-
- /**
- * smooths the look up table
- */
- void smooth();
-
- /**
- * normalizes the sum of a 3d histogram to 1
- * @param tab 3d histogram
- */
- void normalize(std::vector<std::vector<std::vector<double> > > &tab);
-
- /**
- * creates a new and empty table
- * @return table of the size bin[0]xbin[1]xbin[2]
- */
- std::vector<std::vector<std::vector<double > > > createTable();
-
- /**
- * finds a colorname in a given string
- * @param fn input string
- * @return number of the color
- */
- int findColor(std::string &fn);
-
- /**
- * creates a new Histogram for input image depending on the image mask
- * @param cimg input image
- * @param hist histogram
- * @param mask which pixel should be consider
- */
- void createHist(const NICE::ColorImage &cimg, std::vector<std::vector<std::vector<double> > > &hist, NICE::Image &mask);
-
- /**
- * train the lookuptable
- */
- void train();
-
-
- /**
- * add a 3d table to a 3d table elementwise
- * @param dest destination table
- * @param src source table
- */
- void add(std::vector<std::vector<std::vector<double> > > &dest, std::vector<std::vector<std::vector<double> > > &src);
-
- /**
- * transform each pixel of an image
- * @param img input image
- * @param feats feature vector for each pixel
- */
- void getFeats(const NICE::ColorImage &img, NICE::MultiChannelImageT<double> &feats);
- };
- } // namespace
- #endif
|