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_useRandomSamples; //!< If true, random samples will be used instead of regular spaced samples.
72  unsigned int m_numberOfClusters; //!< The number of clusters (classes) to estimate in the image.
73  unsigned int m_maxIterations; //!< The maximum of iterations (E/M steps) to perform if convergence is not achieved.
74  unsigned int m_maxInputPoints; //!< The maximum number of points used to estimate the clusters (default = 1000).
75  double m_epsilon; //!< The stop criteria. When the clusters change in a value smaller then epsilon, the convergence is achieved.
76  std::vector<std::vector<double> > m_clustersMeans; //!< The previously estimated means of the clusters (optional).
77 
79 
81 
82  //overload
83  const Parameters& operator=(const Parameters& params);
84 
85  //overload
86  void reset() throw( te::rp::Exception );
87 
88  //overload
89  AbstractParameters* clone() const;
90  };
91 
92  public:
93 
95 
97 
98  //overload
99  bool initialize(ClassifierStrategyParameters const* const strategyParams) throw(te::rp::Exception);
100 
101  //overload
102  bool execute() throw(te::rp::Exception);
103 
104  protected:
105 
106  bool m_isInitialized; //!< True if this instance is initialized.
107  ClassifierEMStrategy::Parameters m_parameters; //!< Internal execution parameters.
108 
109  };
110 
111  /*!
112  \class ClassifierEMStrategyFactory
113 
114  \brief Raster EM Classifier strategy factory.
115  */
117  {
118  public:
119 
121 
123 
124  //overload
126  };
127 
128  } // end namespace rp
129 } // end namespace te
130 
131 #endif // __TERRALIB_RP_INTERNAL_CLASSIFIEREMSTRATEGY_H
te::rp::ClassifierEMStrategy::Parameters
Classifier Parameters.
Definition: ClassifierEMStrategy.h:68
te::rp::ClassifierEMStrategyFactory::ClassifierEMStrategyFactory
ClassifierEMStrategyFactory()
te::rp::ClassifierEMStrategy
EM strategy for pixel-based classification. This is an unsupervised and pixel-based classification al...
Definition: ClassifierEMStrategy.h:59
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rp::ClassifierEMStrategy::Parameters::m_clustersMeans
std::vector< std::vector< double > > m_clustersMeans
The previously estimated means of the clusters (optional).
Definition: ClassifierEMStrategy.h:76
te::rp::ClassifierEMStrategyFactory::~ClassifierEMStrategyFactory
~ClassifierEMStrategyFactory()
te::rp::ClassifierStrategyParameters
Classifier Strategy Parameters.
Definition: ClassifierStrategyParameters.h:42
te::rp::ClassifierEMStrategy::Parameters::m_epsilon
double m_epsilon
The stop criteria. When the clusters change in a value smaller then epsilon, the convergence is achie...
Definition: ClassifierEMStrategy.h:75
ClassifierStrategy.h
Raster classifier strategy base class.
te::rp::ClassifierEMStrategy::Parameters::m_maxInputPoints
unsigned int m_maxInputPoints
The maximum number of points used to estimate the clusters (default = 1000).
Definition: ClassifierEMStrategy.h:74
te::rp::ClassifierEMStrategy::Parameters::m_useRandomSamples
unsigned int m_useRandomSamples
If true, random samples will be used instead of regular spaced samples.
Definition: ClassifierEMStrategy.h:71
te::rp::ClassifierEMStrategyFactory
Raster EM Classifier strategy factory.
Definition: ClassifierEMStrategy.h:117
te::rp::ClassifierEMStrategy::Parameters::m_numberOfClusters
unsigned int m_numberOfClusters
The number of clusters (classes) to estimate in the image.
Definition: ClassifierEMStrategy.h:72
te::rp::ClassifierEMStrategy::Parameters::reset
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::rp::ClassifierEMStrategy::Parameters::Parameters
Parameters()
te::Exception
Base exception class for plugin module.
Definition: Exception.h:42
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::ClassifierEMStrategy::Parameters::operator=
const Parameters & operator=(const Parameters &params)
te::rp::ClassifierEMStrategy::Parameters::~Parameters
~Parameters()
te::rp::ClassifierStrategyFactory
Raster classifier strategy factory base class.
Definition: ClassifierStrategyFactory.h:47
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::rp::ClassifierStrategy
Raster classifier strategy base class.
Definition: ClassifierStrategy.h:49
te::rp::ClassifierEMStrategyFactory::build
te::rp::ClassifierStrategy * build()
Concrete factories (derived from this one) must implement this method in order to create objects.
ClassifierStrategyFactory.h
Raster classifier strategy factory base class.
te::rp::ClassifierEMStrategy::Parameters::m_maxIterations
unsigned int m_maxIterations
The maximum of iterations (E/M steps) to perform if convergence is not achieved.
Definition: ClassifierEMStrategy.h:73