ClassifierKMeansStrategy.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib 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,
8  or (at your option) any later version.
9 
10  TerraLib 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 TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/rp/ClassifierKMeansStrategy.h
22 
23  \brief KMeans strategy for image classification.
24 */
25 
26 #ifndef __TERRALIB_RP_INTERNAL_CLASSIFIERKMEANSSTRATEGY_H
27 #define __TERRALIB_RP_INTERNAL_CLASSIFIERKMEANSSTRATEGY_H
28 
29 #include "ClassifierStrategy.h"
31 #include "Config.h"
32 
33 namespace te
34 {
35  namespace rp
36  {
37  /*!
38  \class ClassifierKMeansStrategy
39 
40  \brief KMeans strategy for image classification.
41  Step-by-step:
42  1. Define a random solution, creating K values of mean.
43  2. Classify each pixel according to the closest mean.
44  3. Calculate new means using the classified pixels.
45  4. Go back to step 2, or stop depending on the following checks:
46  5. Check if the new means are different from the previous iteration,
47  using the convergence threshold.
48  6. Check if maximum number of iterations has achieved.
49 
50  \ingroup rp_class
51  */
53  {
54  public:
55 
56  /*!
57  \class Parameters
58 
59  \brief Classifier Parameters
60  */
62  {
63  public:
64 
65  unsigned int m_K; //!< The number of clusters (means) to detect in image.
66  unsigned int m_maxIterations; //!< The maximum of iterations to perform if convergence is not achieved.
67  unsigned int m_maxInputPoints; //!< The maximum number of points used to estimate the clusters (default = 1000).
68  double m_epsilon; //!< The stop criteria. When the clusters change in a value smaller then epsilon, the convergence is achieved.
69 
71 
73 
74  //overload
75  const Parameters& operator=(const Parameters& params);
76 
77  //overload
78  void reset() throw( te::rp::Exception );
79 
80  //overload
81  AbstractParameters* clone() const;
82  };
83 
84  public:
85 
87 
89 
90  //overload
91  bool initialize(ClassifierStrategyParameters const* const strategyParams) throw(te::rp::Exception);
92 
93  //overload
94  bool execute() throw(te::rp::Exception);
95 
96  protected:
97 
98  bool m_isInitialized; //!< True if this instance is initialized.
99  ClassifierKMeansStrategy::Parameters m_parameters; //!< Internal execution parameters.
100 
101  };
102 
103  /*!
104  \class ClassifierKMeansStrategyFactory
105 
106  \brief Raster KMeans Classifier strategy factory.
107 
108  \note Factory key: RegionGrowing
109  */
111  {
112  public:
113 
115 
117 
118  //overload
120  };
121 
122  } // end namespace rp
123 } // end namespace te
124 
125 #endif // __TERRALIB_RP_INTERNAL_CLASSIFIERKMEANSSTRATEGY_H
126 
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rp::ClassifierKMeansStrategy::Parameters::operator=
const Parameters & operator=(const Parameters &params)
te::rp::ClassifierKMeansStrategyFactory::~ClassifierKMeansStrategyFactory
~ClassifierKMeansStrategyFactory()
te::rp::ClassifierKMeansStrategy::Parameters::m_maxIterations
unsigned int m_maxIterations
The maximum of iterations to perform if convergence is not achieved.
Definition: ClassifierKMeansStrategy.h:66
te::rp::ClassifierKMeansStrategyFactory
Raster KMeans Classifier strategy factory.
Definition: ClassifierKMeansStrategy.h:111
te::rp::ClassifierStrategyParameters
Classifier Strategy Parameters.
Definition: ClassifierStrategyParameters.h:42
te::rp::ClassifierKMeansStrategy::Parameters::m_maxInputPoints
unsigned int m_maxInputPoints
The maximum number of points used to estimate the clusters (default = 1000).
Definition: ClassifierKMeansStrategy.h:67
te::rp::ClassifierKMeansStrategy::Parameters::reset
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
ClassifierStrategy.h
Raster classifier strategy base class.
te::rp::ClassifierKMeansStrategy::Parameters::Parameters
Parameters()
te::rp::ClassifierKMeansStrategy::Parameters::m_K
unsigned int m_K
The number of clusters (means) to detect in image.
Definition: ClassifierKMeansStrategy.h:65
te::rp::ClassifierKMeansStrategy::Parameters::~Parameters
~Parameters()
te::rp::ClassifierKMeansStrategyFactory::ClassifierKMeansStrategyFactory
ClassifierKMeansStrategyFactory()
te::rp::ClassifierKMeansStrategyFactory::build
te::rp::ClassifierStrategy * build()
Concrete factories (derived from this one) must implement this method in order to create objects.
te::Exception
Base exception class for plugin module.
Definition: Exception.h:42
te::rp::ClassifierKMeansStrategy::Parameters::m_epsilon
double m_epsilon
The stop criteria. When the clusters change in a value smaller then epsilon, the convergence is achie...
Definition: ClassifierKMeansStrategy.h:68
TERPEXPORT
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
te::rp::ClassifierKMeansStrategy::Parameters
Classifier Parameters.
Definition: ClassifierKMeansStrategy.h:62
te::rp::ClassifierStrategyFactory
Raster classifier strategy factory base class.
Definition: ClassifierStrategyFactory.h:47
te::rp::ClassifierKMeansStrategy
KMeans strategy for image classification. Step-by-step:
Definition: ClassifierKMeansStrategy.h:53
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::rp::ClassifierStrategy
Raster classifier strategy base class.
Definition: ClassifierStrategy.h:49
ClassifierStrategyFactory.h
Raster classifier strategy factory base class.