All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
70  Parameters();
71 
72  ~Parameters();
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 
88  ~ClassifierKMeansStrategy();
89 
90  //overload
91  bool initialize(StrategyParameters const* const strategyParams) throw(te::rp::Exception);
92 
93  //overload
94  bool execute(const te::rst::Raster& inputRaster, const std::vector<unsigned int>& inputRasterBands,
95  const std::vector<te::gm::Polygon*>& inputPolygons, te::rst::Raster& outputRaster,
96  const unsigned int outputRasterBand, const bool enableProgressInterface) throw(te::rp::Exception);
97 
98  protected:
99 
100  bool m_isInitialized; //!< True if this instance is initialized.
101  ClassifierKMeansStrategy::Parameters m_parameters; //!< Internal execution parameters.
102 
103  };
104 
105  /*!
106  \class ClassifierKMeansStrategyFactory
107 
108  \brief Raster KMeans Classifier strategy factory.
109 
110  \note Factory key: RegionGrowing
111  */
113  {
114  public:
115 
117 
119 
120  //overload
122  };
123 
124  } // end namespace rp
125 } // end namespace te
126 
127 #endif // __TERRALIB_RP_INTERNAL_CLASSIFIERKMEANSSTRATEGY_H
128 
Raster KMeans Classifier strategy factory.
unsigned int m_maxInputPoints
The maximum number of points used to estimate the clusters (default = 1000).
Raster classifier strategy factory base class.
unsigned int m_K
The number of clusters (means) to detect in image.
Raster strategy parameters base class.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:141
double m_epsilon
The stop criteria. When the clusters change in a value smaller then epsilon, the convergence is achie...
Raster classifier strategy factory base class.
Configuration flags for the Raster Processing module of TerraLib.
Raster classifier strategy base class.
unsigned int m_maxIterations
The maximum of iterations to perform if convergence is not achieved.
Raster classifier strategy base class.
KMeans strategy for image classification. Step-by-step: