All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ClassifierKMeansStrategy.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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  */
51  {
52  public:
53 
54  /*!
55  \class Parameters
56 
57  \brief Classifier Parameters
58  */
60  {
61  public:
62 
63  unsigned int m_K; //!< The number of clusters (means) to detect in image.
64  unsigned int m_maxIterations; //!< The maximum of iterations to perform if convergence is not achieved.
65  unsigned int m_maxInputPoints; //!< The maximum number of points used to estimate the clusters (default = 1000).
66  double m_epsilon; //!< The stop criteria. When the clusters change in a value smaller then epsilon, the convergence is achieved.
67 
68  Parameters();
69 
70  ~Parameters();
71 
72  //overload
73  const Parameters& operator=(const Parameters& params);
74 
75  //overload
76  void reset() throw( te::rp::Exception );
77 
78  //overload
79  AbstractParameters* clone() const;
80  };
81 
82  public:
83 
85 
86  ~ClassifierKMeansStrategy();
87 
88  //overload
89  bool initialize(StrategyParameters const* const strategyParams) throw(te::rp::Exception);
90 
91  //overload
92  bool execute(const te::rst::Raster& inputRaster, const std::vector<unsigned int>& inputRasterBands,
93  const std::vector<te::gm::Polygon*>& inputPolygons, te::rst::Raster& outputRaster,
94  const unsigned int outputRasterBand, const bool enableProgressInterface) 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 
unsigned int m_maxInputPoints
The maximum number of points used to estimate the clusters (default = 1000).
double m_epsilon
The stop criteria. When the clusters change in a value smaller then epsilon, the convergence is achie...
Raster KMeans Classifier strategy factory.
Raster strategy parameters base class.
KMeans strategy for image classification. Step-by-step:
unsigned int m_maxIterations
The maximum of iterations to perform if convergence is not achieved.
unsigned int m_K
The number of clusters (means) to detect in image.
Raster classifier strategy base class.
Raster classifier strategy factory base class.
Configuration flags for the Raster Processing module of TerraLib.
Raster classifier strategy base class.
Raster classifier strategy factory base class.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:91