ClassifierEMStrategy.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/ClassifierEMStrategy.h
22 
23  \brief EM (Expectation-Maximization) strategy for pixel-based classification.
24 */
25 
26 #ifndef __TERRALIB_RP_INTERNAL_CLASSIFIEREMSTRATEGY_H
27 #define __TERRALIB_RP_INTERNAL_CLASSIFIEREMSTRATEGY_H
28 
29 // TerraLib
30 #include "ClassifierStrategy.h"
32 #include "Config.h"
33 
34 // STL
35 #include <vector>
36 
37 // Boost
38 #include <boost/numeric/ublas/matrix.hpp>
39 
40 namespace te
41 {
42  namespace rp
43  {
44  /*!
45  \class ClassifierEMStrategy
46 
47  \brief EM strategy for pixel-based classification. This is an unsupervised
48  and pixel-based classification algorithm. Expectation-Maximization (EM) works
49  iteratively by applying two steps: the E-step (Expectation) and the M-step
50  (Maximization). The method aims to approximate the parameter estimates to
51  real data distribution, along the iterations:
52  1. The E-step calculates the conditional expectation of the complete a
53  posteriori probability function.
54  2. The M-step updates the parameter estimation.
55 
56  \ingroup rp_class
57  */
59  {
60  public:
61 
62  /*!
63  \class Parameters
64 
65  \brief Classifier Parameters
66  */
68  {
69  public:
70 
71  unsigned int m_numberOfClusters; //!< The number of clusters (classes) to estimate in the image.
72  unsigned int m_maxIterations; //!< The maximum of iterations (E/M steps) to perform if convergence is not achieved.
73  unsigned int m_maxInputPoints; //!< The maximum number of points used to estimate the clusters (default = 1000).
74  double m_epsilon; //!< The stop criteria. When the clusters change in a value smaller then epsilon, the convergence is achieved.
75  std::vector<std::vector<double> > m_clustersMeans; //!< The previously estimated means of the clusters (optional).
76 
77  Parameters();
78 
79  ~Parameters();
80 
81  //overload
82  const Parameters& operator=(const Parameters& params);
83 
84  //overload
85  void reset() throw( te::rp::Exception );
86 
87  //overload
88  AbstractParameters* clone() const;
89  };
90 
91  public:
92 
94 
95  ~ClassifierEMStrategy();
96 
97  //overload
98  bool initialize(ClassifierStrategyParameters const* const strategyParams) throw(te::rp::Exception);
99 
100  //overload
101  bool execute(const te::rst::Raster& inputRaster, const std::vector<unsigned int>& inputRasterBands,
102  const std::vector<te::gm::Polygon*>& inputPolygons, te::rst::Raster& outputRaster,
103  const unsigned int outputRasterBand, const bool enableProgressInterface) throw(te::rp::Exception);
104 
105  // overload
106  std::vector< int > getOutputDataTypes() const;
107 
108  protected:
109 
110  bool m_isInitialized; //!< True if this instance is initialized.
111  ClassifierEMStrategy::Parameters m_parameters; //!< Internal execution parameters.
112 
113  };
114 
115  /*!
116  \class ClassifierEMStrategyFactory
117 
118  \brief Raster EM Classifier strategy factory.
119  */
121  {
122  public:
123 
125 
127 
128  //overload
130  };
131 
132  } // end namespace rp
133 } // end namespace te
134 
135 #endif // __TERRALIB_RP_INTERNAL_CLASSIFIEREMSTRATEGY_H
unsigned int m_numberOfClusters
The number of clusters (classes) to estimate in the image.
Base exception class for plugin module.
Definition: Exception.h:42
Raster classifier strategy factory base class.
Raster EM Classifier strategy factory.
EM strategy for pixel-based classification. This is an unsupervised and pixel-based classification al...
URI C++ Library.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
unsigned int m_maxInputPoints
The maximum number of points used to estimate the clusters (default = 1000).
Raster classifier strategy factory base class.
Configuration flags for the Raster Processing module of TerraLib.
unsigned int m_maxIterations
The maximum of iterations (E/M steps) to perform if convergence is not achieved.
Raster classifier strategy base class.
Raster classifier strategy base class.
std::vector< std::vector< double > > m_clustersMeans
The previously estimated means of the clusters (optional).
double m_epsilon
The stop criteria. When the clusters change in a value smaller then epsilon, the convergence is achie...