IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
KernelKMeansClustering.h
1 // KernelKMeansClustering.h:
3 // -------------------------
4 //
22 
23 #ifndef __IPSDKMATH_KERNELKMEANSCLUSTERING_H__
24 #define __IPSDKMATH_KERNELKMEANSCLUSTERING_H__
25 
26 // suppression warnings
27 // warning C4251: 'ipsdk::math::clustering::KernelKMeansClustering<KernelType>::_inputDataColl': class 'std::vector<ipsdk::math::Vector,std::allocator<_Ty>>' needs to have dll-interface to be used by clients of class 'ipsdk::math::clustering::KernelKMeansClustering<KernelType>'
28 // warning C4275: interface non dll class 'boost::noncopyable_::noncopyable' utilisée comme base d'une interface dll class 'ipsdk::math::clustering::KernelKMeansClustering<ipsdk::math::clustering::LinearKernel>'
29 #pragma warning (push)
30 #pragma warning (disable : 4275 4251)
31 
34 #include <IPSDKMath/Clustering/KernelKMeansClusteringConfig.h>
35 #include <IPSDKMath/Clustering/KernelKMeansCentroid.h>
36 #include <boost/noncopyable.hpp>
37 
38 namespace ipsdk {
39 namespace math {
40 namespace clustering {
41 
44 
45 template <typename KernelType>
46 class IPSDKMATH_API KernelKMeansClustering : public boost::noncopyable
47 {
48 // predefined public types
49 public:
52 
55 
57  typedef std::vector<CentroidType> CentroidsColl;
58 
59 public:
62  KernelKMeansClustering(const KernelType& kernel);
65 
66 // methods
67 public:
69  const KernelType& getKernel() const;
70 
73  const AlgorithmConfig& getConfig() const;
74  void setConfig(const AlgorithmConfig& config);
76 
77  // ----------------------------
80  // ----------------------------
81 
83  bool isClusteringDone() const;
84 
108  bool compute(const ipUInt32 nbClusters,
109  const VectorColl& inputDataColl);
111 
112  // ------------------------
115  // ------------------------
116 
120  ipUInt32 getNbClusters() const;
121 
125  ipUInt32 getDataSize() const;
126 
130  ipUInt32 getNbInputData() const;
131 
135  const VectorColl& getInputDataColl() const;
136 
140  ipUInt32 getNbFailedAttempts() const;
141 
147  ipReal64 getSeparation() const;
148 
153  ipUInt32 getNbIteration() const;
154 
158  ipUInt32 getClusterPopulation(const ipUInt32 clusterIdx) const;
159 
163  const CentroidsColl& getClustersCentroids() const;
164 
168  const CentroidType& getCentroid(const ipUInt32 clusterIdx) const;
169 
173  const UInt32Vector& getAssignments() const;
174 
180  ipUInt32 computeAssignment(const Vector& data) const;
182 
184  void clear();
185 
186 // attributes
187 protected:
189  KernelType _kernel;
190 
193 
196 
199 
202 
205 
208 
211 };
212 
215 
216 } // end of namespace clustering
217 } // end of namespace math
218 } // end of namespace ipsdk
219 
220 #pragma warning (pop)
221 
222 #endif // __IPSDKMATH_KERNELKMEANSCLUSTERING_H__
KernelType _kernel
kernel associated to clustering operation
Definition: KernelKMeansClustering.h:189
Definition of import/export macro for library.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
AlgorithmConfig _config
configuration associated to clustering algorithm
Definition: KernelKMeansClustering.h:192
std::vector< ipUInt32 > UInt32Vector
stl vector collections
Definition: BaseCollections.h:33
std::vector< CentroidType > CentroidsColl
collection of centroids
Definition: KernelKMeansClustering.h:57
KernelKMeansClusteringConfig AlgorithmConfig
algorithm configuration
Definition: KernelKMeansClustering.h:51
Definition: ClusteringUtils.h:27
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
Definition: KernelKMeansClusteringConfig.h:29
CentroidsColl _clustersCentroids
cluster centroids associated to processing
Definition: KernelKMeansClustering.h:207
ipReal64 _separation
separation associated to processing
Definition: KernelKMeansClustering.h:204
boost::numeric::ublas::vector< ipReal64 > Vector
vector type associated to library
Definition: LinearAlgebraTypes.h:36
UInt32Vector _assignments
cluster index associated to each input data
Definition: KernelKMeansClustering.h:210
std::vector< Vector > VectorColl
collection of vectors
Definition: ClusteringTypes.h:31
#define IPSDKMATH_API
Import/Export macro for library IPSDKMath.
Definition: IPSDKMathExports.h:27
ipUInt32 _nbFailedAttempts
number of failed attempts
Definition: KernelKMeansClustering.h:198
VectorColl _inputDataColl
input data collection
Definition: KernelKMeansClustering.h:195
ipUInt32 _nbIteration
number of iterations associated to selected clustering solution
Definition: KernelKMeansClustering.h:201
IPSDKMATH_API ipUInt32 computeAssignment(const VectorColl &clustersCentersColl, const Vector &data)
function allowing to compute cluster assignment using an euclidian distance to clusters centers ...
Predefined types for clustering algorithm.
KernelKMeansCentroid< KernelType > CentroidType
centroid type associated to object
Definition: KernelKMeansClustering.h:54
Definition: ClusteringTypes.h:29
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53