12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- /**
- * @file GenericClusterAlgorithmSelection.h
- * @brief This class provides a generic chooser function for different clustering techniques
- * @date 14-06-2013 (dd-mm-yyyy)
- * @author Alexander Freytag
- */
- #ifndef _NICE_GENERICCLUSTERALGORITHMSELECTION_INCLUDE
- #define _NICE_GENERICCLUSTERALGORITHMSELECTION_INCLUDE
- #include <iostream>
- //abstract base class
- #include "vislearning/math/cluster/ClusterAlgorithm.h"
- //derived specializations
- #include "vislearning/math/cluster/GMM.h"
- #include "vislearning/math/cluster/KMeans.h"
- #include "vislearning/math/cluster/KMeansHeuristic.h"
- #include "vislearning/math/cluster/KMeansMatlab.h"
- #include "vislearning/math/cluster/KMedian.h"
- #include "vislearning/math/cluster/RandomClustering.h"
- #include "vislearning/math/cluster/SpectralCluster.h"
- namespace OBJREC {
- /** @class GenericClusterAlgorithmSelection
- * @brief This class provides a generic chooser function for different clustering techniques
- * The abstract base class is ClusterAlgorithm
- * @date 14-06-2013 (dd-mm-yyyy)
- * @author Alexander Freytag
- */
- class GenericClusterAlgorithmSelection
- {
- public:
- /**
- * @brief This methode switches between the different clustering techniques.
- * @param[in] conf - A pointer to the given configfile, which should contain "section" - "clusterTechnique"
- * @param[in] section - This string defines the value for "section" in the configfile.
- * @return ClusterAlgorithm* - The ClusterAlgorithm to cluster samples according to the selected clustering technique.
- * @date 14-06-2013 (dd-mm-yyyy)
- * @author Alexander Freytag
- */
- static
- OBJREC::ClusterAlgorithm *selectClusterAlgo ( const NICE::Config *conf, std::string section = "clustering" )
- {
- // return value
- OBJREC::ClusterAlgorithm *clusterAlgo = NULL;
-
- // string which defines the clustering technique
- std::string clusterTechnique = conf->gS(section, "clusterTechnique", "");
-
- if ( clusterTechnique == "kmeans" )
- {
- clusterAlgo = new OBJREC::KMeans ( conf );
- }
- else if ( clusterTechnique == "kmeansHeuristic" )
- {
- clusterAlgo = new OBJREC::KMeansHeuristic ( conf );
- }
- else if ( clusterTechnique == "kmeansMatlab" )
- {
- clusterAlgo = new OBJREC::KMeansMatlab ( conf );
- }
- else if ( clusterTechnique == "kmedian" )
- {
- clusterAlgo = new OBJREC::KMedian ( conf );
- }
- else if ( clusterTechnique == "GMM" )
- {
- clusterAlgo = new OBJREC::GMM ( conf );
- }
- else if ( clusterTechnique == "spectral" )
- {
- clusterAlgo = new OBJREC::SpectralCluster ( conf );
- }
- else if ( clusterTechnique == "RandomClustering" )
- {
- clusterAlgo = new OBJREC::RandomClustering ( conf );
- }
- else
- {
- //default: random clustering - it is easy, fast, does not need extra memory, and is still better than a NULL pointer
- std::cerr << "Unknown cluster algorithm selected, use random clustering instead" << std::endl;
- clusterAlgo = new OBJREC::RandomClustering ( conf );
- }
-
- return clusterAlgo;
- }
- };
- }
- #endif
|