SpectralCluster.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * @file SpectralCluster.h
  3. * @brief spectral clustering by kmeans-clustering of eigenvectors
  4. * @author Erik Rodner, Alexander Freytag
  5. * @date 11/13/2007
  6. */
  7. #ifndef SPECTRALCLUSTERINCLUDE
  8. #define SPECTRALCLUSTERINCLUDE
  9. #include <core/vector/VectorT.h>
  10. #include <core/vector/MatrixT.h>
  11. #include "ClusterAlgorithm.h"
  12. #include "KMeans.h"
  13. namespace OBJREC {
  14. /** spectral clustering by kmeans-clustering of eigenvectors */
  15. class SpectralCluster : public ClusterAlgorithm
  16. {
  17. protected:
  18. int noClusters;
  19. double alpha;
  20. KMeans kmeans;
  21. enum {
  22. L_UNNORMALIZED = 0,
  23. L_RW_NORMALIZED
  24. };
  25. virtual void computeLaplacian ( const NICE::VVector & features,
  26. NICE::Matrix & laplacian,
  27. int method, double alpha );
  28. virtual void getSimilarityMatrix ( const NICE::VVector & features,
  29. NICE::Matrix & laplacian, double alpha );
  30. public:
  31. ///////////////////// ///////////////////// /////////////////////
  32. // CONSTRUCTORS / DESTRUCTORS
  33. ///////////////////// ///////////////////// /////////////////////
  34. /**
  35. * @brief default constructor
  36. * @date 12-02-2014 (dd-mm-yyyy )
  37. * @author Alexander Freytag
  38. */
  39. SpectralCluster ( );
  40. /** simple constructor */
  41. SpectralCluster (int _noClusters, double alpha);
  42. /**
  43. * @brief standard constructor
  44. * @param conf config file specifying all relevant variable settings
  45. * @param _section name of the section within the configfile where the settings can be found (default: SpectralCluster)
  46. * @date 14-06-2013 (dd-mm-yyyy)
  47. * @author Alexander Freytag
  48. */
  49. SpectralCluster( const NICE::Config *conf, const std::string & _section = "SpectralCluster");
  50. /** simple destructor */
  51. virtual ~SpectralCluster();
  52. /**
  53. * @brief Jobs previously performed in the config-version of the constructor, read settings etc.
  54. * @author Alexander Freytag
  55. * @date 12-02-2014 ( dd-mm-yyyy )
  56. */
  57. void initFromConfig ( const NICE::Config * _conf, const std::string & _confSection = "SpectralCluster");
  58. ///////////////////// ///////////////////// /////////////////////
  59. // CLUSTERING STUFF
  60. ///////////////////// ///////////////////// //////////////////
  61. void cluster ( const NICE::VVector & features,
  62. NICE::VVector & prototypes,
  63. std::vector<double> & weights,
  64. std::vector<int> & assignment );
  65. ///////////////////// INTERFACE PERSISTENT /////////////////////
  66. // interface specific methods for store and restore
  67. ///////////////////// INTERFACE PERSISTENT /////////////////////
  68. /**
  69. * @brief Load object from external file (stream)
  70. * @author Alexander Freytag
  71. * @date 12-02-2014 ( dd-mm-yyyy )
  72. */
  73. void restore ( std::istream & is, int format = 0 );
  74. /**
  75. * @brief Save object to external file (stream)
  76. * @author Alexander Freytag
  77. * @date 12-02-2014 ( dd-mm-yyyy )
  78. */
  79. void store ( std::ostream & os, int format = 0 ) const;
  80. /**
  81. * @brief Clear object
  82. * @author Alexander Freytag
  83. * @date 12-02-2014 ( dd-mm-yyyy )
  84. */
  85. void clear ();
  86. };
  87. } // namespace
  88. #endif