FeatureLearningClusterBased.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * @file FeatureLearningClusterBased.h
  3. * @brief compute new histogram entries by clustering new features and take centers of clusters which are relevant and novel
  4. * @author Alexander Freytag
  5. * @date 16-04-2013 (dd-mm-yyyy)
  6. */
  7. #ifndef _INCLUDEFEATURELEARNINGCLUSTERBASED
  8. #define _INCLUDEFEATURELEARNINGCLUSTERBASED
  9. #include "FeatureLearningGeneric.h"
  10. #include <string>
  11. #include <core/vector/Distance.h>
  12. #include <core/vector/VVector.h>
  13. #include <vislearning/cbaselib/MultiDataset.h>
  14. #include <vislearning/features/localfeatures/GenericLocalFeatureSelection.h>
  15. #include <vislearning/math/cluster/ClusterAlgorithm.h>
  16. namespace OBJREC
  17. {
  18. /** abstract interface for feature learning algorithms */
  19. class FeatureLearningClusterBased : public FeatureLearningGeneric
  20. {
  21. protected:
  22. std::string section;
  23. bool showTrainingImages;
  24. //! define the initial number of clusters our codebook shall contain
  25. int initialNumberOfClusters;
  26. OBJREC::ClusterAlgorithm * clusterAlgo;
  27. NICE::VectorDistance<double> * distFunction;
  28. LocalFeatureRepresentation * featureExtractor;
  29. NICE::VVector prototypes;
  30. /************************
  31. *
  32. * protected methods
  33. *
  34. **************************/
  35. void extractFeaturesFromTrainingImages( const OBJREC::MultiDataset *_md, NICE::VVector & examplesTraining );
  36. void train ( const OBJREC::MultiDataset *_md );
  37. public:
  38. /** constructor
  39. * @param conf needs a configfile
  40. * @param md and a MultiDataset (contains images and other things)
  41. */
  42. FeatureLearningClusterBased ( const NICE::Config *_conf, const OBJREC::MultiDataset *_md , const std::string & _section = "featureLearning");
  43. /** simple destructor */
  44. virtual ~FeatureLearningClusterBased();
  45. /** this function has to be overloaded by all subclasses
  46. @param imgWithNovelContent
  47. */
  48. virtual void learnNewFeatures ( OBJREC::CachedExample *_ce ) ;
  49. virtual void evaluateCurrentCodebook ( const std::string & filename );
  50. };
  51. } // namespace
  52. #endif