libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRNSpectralClustering.h
Go to the documentation of this file.
1 /* Copyright 2012-2014 INSA Lyon, CoReNum
2  *
3  * This file is part of libcrn.
4  *
5  * libcrn is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libcrn is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libcrn. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: CRNSpectralClustering.h
19  * \author Yann LEYDIER
20  */
21 
22 #ifndef CRNSpectralClustering_HEADER
23 #define CRNSpectralClustering_HEADER
24 
25 #include <CRN.h>
27 #include <vector>
28 #include <map>
29 #include <limits>
30 
31 namespace crn
32 {
33  class SpectralClustering;
34  CRN_ALIAS_SMART_PTR(SpectralClustering)
35 }
36 namespace crn
37 {
38  class SquareMatrixDouble;
39  /****************************************************************************/
50  {
51  public:
52  SpectralClustering(const SpectralClustering&) = delete;
56 
58  static SpectralClustering CreateLocalScaleFromNN(const SquareMatrixDouble &distance_matrix, size_t sigma_neighborhood = 7, double epsilon = std::numeric_limits<double>::max());
60  static SpectralClustering CreateGlobalScaleFromDimension(const SquareMatrixDouble &distance_matrix, size_t dimension, double epsilon = std::numeric_limits<double>::max());
62  static SpectralClustering CreateGlobalScaleFromNN(const SquareMatrixDouble &distance_matrix, size_t sigma_neighborhood = 1, double epsilon = std::numeric_limits<double>::max());
64  static SpectralClustering CreateFixedScale(const SquareMatrixDouble &distance_matrix, double sigma, double epsilon = std::numeric_limits<double>::max());
65 
67  const std::multimap<double, MatrixDouble>& GetEigenpairs() const noexcept { return eigenpairs; }
69  std::vector<double> GetEigenvalues() const;
71  size_t EstimateClusterNumber(double limit = 1.0) const;
73  std::vector<std::vector<double>> ProjectData(size_t ncoordinates, bool normalize) const;
74 
75  private:
78 
79  std::multimap<double, MatrixDouble> eigenpairs;
80  };
81 }
82 
83 #endif
SpectralClustering & operator=(const SpectralClustering &)=delete
std::vector< std::vector< double > > ProjectData(size_t ncoordinates, bool normalize) const
Projects the data on the first coordinates.
static SpectralClustering CreateGlobalScaleFromDimension(const SquareMatrixDouble &distance_matrix, size_t dimension, double epsilon=std::numeric_limits< double >::max())
Clustering with global automatic scale.
static SpectralClustering CreateLocalScaleFromNN(const SquareMatrixDouble &distance_matrix, size_t sigma_neighborhood=7, double epsilon=std::numeric_limits< double >::max())
Clustering with local automatic scale.
std::vector< double > GetEigenvalues() const
Returns the eigenvalues (sorted from highest to lowest)
size_t EstimateClusterNumber(double limit=1.0) const
Estimates the number of clusters.
static SpectralClustering CreateGlobalScaleFromNN(const SquareMatrixDouble &distance_matrix, size_t sigma_neighborhood=1, double epsilon=std::numeric_limits< double >::max())
Clustering with global automatic scale.
Spectral clustering.
static SpectralClustering CreateFixedScale(const SquareMatrixDouble &distance_matrix, double sigma, double epsilon=std::numeric_limits< double >::max())
Clustering with global fixed scale.
const std::multimap< double, MatrixDouble > & GetEigenpairs() const noexcept
Gets the data projected on each coordinates (higher eigenvalues are associated the to most significan...
Square double matrix class.
CRN_ALIAS_SMART_PTR(ImageBW)
SpectralClustering(const SpectralClustering &)=delete