/** * @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 > > > 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 > > &tab); /** * creates a new and empty table * @return table of the size bin[0]xbin[1]xbin[2] */ std::vector > > 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 > > &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 > > &dest, std::vector > > &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 &feats); }; } // namespace #endif