123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /**
- * @file FeatureLearningClusterBased.h
- * @brief compute new histogram entries by clustering new features and take centers of clusters which are relevant and novel
- * @author Alexander Freytag
- * @date 16-04-2013 (dd-mm-yyyy)
- */
- #ifndef _INCLUDEFEATURELEARNINGCLUSTERBASED
- #define _INCLUDEFEATURELEARNINGCLUSTERBASED
- #include "FeatureLearningGeneric.h"
- #include <string>
- #include <core/vector/Distance.h>
- #include <core/vector/VVector.h>
- #include <vislearning/cbaselib/MultiDataset.h>
- #include <vislearning/features/localfeatures/GenericLocalFeatureSelection.h>
- #include <vislearning/math/cluster/ClusterAlgorithm.h>
- namespace OBJREC
- {
- /** abstract interface for feature learning algorithms */
- class FeatureLearningClusterBased : public FeatureLearningGeneric
- {
- protected:
-
- bool showTrainingImages;
-
- //! define the initial number of clusters our codebook shall contain
- int initialNumberOfClusters;
- //! define the number of clusters we want to compute for an unseen image
- int numberOfClustersForNewImage;
-
- OBJREC::ClusterAlgorithm * clusterAlgo;
- NICE::VectorDistance<double> * distFunction;
- LocalFeatureRepresentation * featureExtractor;
-
- NICE::VVector prototypes;
-
- bool showResults;
- std::string resultdir;
-
- int newImageCounter;
- //just needed for visualisation
- double oldMaxDist;
- //TODO stupid!!!
- double maxValForVisualization;
-
- /************************
- *
- * protected methods
- *
- **************************/
-
- void setClusterAlgo( const std::string & _clusterAlgoString, const bool & _setForInitialTraining);
-
- void extractFeaturesFromTrainingImages( const OBJREC::MultiDataset *_md, NICE::VVector & examplesTraining );
-
- void train ( const OBJREC::MultiDataset *_md );
-
- virtual bool loadInitialCodebook ( );
- virtual bool writeInitialCodebook ( );
-
-
- public:
- /** constructor
- * @param conf needs a configfile
- * @param md and a MultiDataset (contains images and other things)
- */
- FeatureLearningClusterBased ( const NICE::Config *_conf, const OBJREC::MultiDataset *_md , const std::string & _section = "featureLearning");
- /** simple destructor */
- virtual ~FeatureLearningClusterBased();
-
- /** this function has to be overloaded by all subclasses
- @param imgWithNovelContent
- */
- virtual void learnNewFeatures ( const std::string & filename ) ;
-
- virtual NICE::FloatImage evaluateCurrentCodebook ( const std::string & filename , const bool & beforeComputingNewFeatures = true );
-
- };
- } // namespace
- #endif
|