ClassifierMAPStrategy.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/ClassifierMAPStrategy.h
22  \brief Maximum a posteriori probability strategy.
23  */
24 
25 #ifndef __TERRALIB_RP_INTERNAL_CLASSIFIERMAPSTRATEGY_H
26 #define __TERRALIB_RP_INTERNAL_CLASSIFIERMAPSTRATEGY_H
27 
28 #include "ClassifierStrategy.h"
31 #include "Config.h"
32 #include "../classification/MAP.h"
33 #include "../classification/Adaptors.h"
34 
35 #include <boost/shared_ptr.hpp>
36 
37 #include <map>
38 #include <vector>
39 
40 namespace te
41 {
42  namespace rp
43  {
44  class AlgorithmParametersSerializer;
45 
46  /*!
47  \class ClassifierMAPStrategy
48 
49  \brief Maximum a posteriori probability strategy.
50 
51  \ingroup rp_class
52  */
54  {
55  public:
56 
57  /*!
58  \class Parameters
59 
60  \brief Classifier Parameters
61  */
63  {
64  public:
65 
66  typedef unsigned int ClassIDT; //!< Class ID type definition (zero means invalid ID).
67 
68  typedef std::vector< double > ClassSampleT; //!< Class sample type definition.
69 
70  typedef std::vector< ClassSampleT > ClassSamplesContainerT; //!< Class samples container type definition.
71 
72  typedef std::map< ClassIDT, ClassSamplesContainerT > MClassesSamplesCT; //!< Multi-classes samples container type definition.
73 
74  typedef boost::shared_ptr<MClassesSamplesCT> MClassesSamplesCTPtr; //!< A shared pointer to a multi classes samples container type definition.
75 
76  MClassesSamplesCTPtr m_trainSamplesPtr; //!< A shared pointer to a always-valid structure where trainning samples are stored.
77 
78  std::vector< double > m_prioriProbs; //!< Priori probabilities, one for each class. Values from 0 to 1 (use an empty vector to allow internal calcule of priori probabilities).
79 
80  unsigned int m_prioriCalcSampleStep; //!< A positive non-zero sample step used when calculating piori probabilities (default:5 - 1/5 of samples will be used);
81 
82  te::cl::MAP::ModelParameters m_MAPModelParams; //!< Optional model parameters (further training not required).
83 
85 
87 
88  //overload
89  const Parameters& operator=(const Parameters& params);
90 
91  //overload
92  void reset() ;
93 
94  //overload
95  AbstractParameters* clone() const;
96 
97  //overload
98  bool serialize ( AlgorithmParametersSerializer& serializer ) const;
99  };
100 
101  /*!
102  \class Output Parameters
103 
104  \brief MAP Classifier output parameters
105  */
107  {
108  public:
109 
110  te::cl::MAP::ModelParameters m_MAPModelParams; //!< The calculated model parameters.
111 
113 
115 
116  //overload
118 
119  //overload
120  void reset() ;
121 
122  //overload
123  AbstractParameters* clone() const;
124 
125  //overload
126  bool serialize ( AlgorithmParametersSerializer& serializer ) const;
127  };
128 
130 
132 
133  //overload
134  bool initialize(ClassifierStrategyParameters const* const strategyParams) ;
135 
136  //overload
137  bool execute() ;
138 
139  unsigned int getOutputNumberBands(void);
140 
141  //overload
143 
144  protected :
145 
146  bool m_isInitialized; //!< Is this instance initialized?
147 
148  Parameters::ClassIDT m_highestTrainClassID; //!< The highest train sample lable.
149 
150  ClassifierMAPStrategy::Parameters m_initParams; //!< Initialization parameters.
151 
152  te::cl::MAP m_genClassInstance; //!< A generir classifier instance.
153 
154  OutputParameters m_outParams; //!< Output execution parameters.
155 
156  };
157 
158  /*!
159  \class ClassifierMAPStrategyFactory
160 
161  \brief Maximum a posteriori probability strategy factory.
162 
163  \note Factory key: RegionGrowing
164  */
166  {
167  public:
168 
170 
172 
173  //overload
175  };
176 
177  } // end namespace rp
178 } // end namespace te
179 
180 #endif // __TERRALIB_RP_INTERNAL_CLASSIFIERMAPSTRATEGY_H
181 
Raster classifier strategy factory base class.
Raster classifier strategy base class.
MAP strategy for classification.
Definition: MAP.h:55
A class to standardize algorithm parameters serialization.
Maximum a posteriori probability strategy factory.
te::rp::ClassifierStrategy * build()
Concrete factories (derived from this one) must implement this method in order to create objects.
const OutputParameters & operator=(const OutputParameters &params)
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::cl::MAP::ModelParameters m_MAPModelParams
The calculated model parameters.
bool serialize(AlgorithmParametersSerializer &serializer) const
Returns a parameter serialization object.
AbstractParameters * clone() const
Create a clone copy of this instance.
std::vector< ClassSampleT > ClassSamplesContainerT
Class samples container type definition.
unsigned int m_prioriCalcSampleStep
A positive non-zero sample step used when calculating piori probabilities (default:5 - 1/5 of samples...
std::map< ClassIDT, ClassSamplesContainerT > MClassesSamplesCT
Multi-classes samples container type definition.
const Parameters & operator=(const Parameters &params)
unsigned int ClassIDT
Class ID type definition (zero means invalid ID).
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::cl::MAP::ModelParameters m_MAPModelParams
Optional model parameters (further training not required).
std::vector< double > m_prioriProbs
Priori probabilities, one for each class. Values from 0 to 1 (use an empty vector to allow internal c...
MClassesSamplesCTPtr m_trainSamplesPtr
A shared pointer to a always-valid structure where trainning samples are stored.
boost::shared_ptr< MClassesSamplesCT > MClassesSamplesCTPtr
A shared pointer to a multi classes samples container type definition.
AbstractParameters * clone() const
Create a clone copy of this instance.
std::vector< double > ClassSampleT
Class sample type definition.
bool serialize(AlgorithmParametersSerializer &serializer) const
Returns a parameter serialization object.
Maximum a posteriori probability strategy.
OutputParameters m_outParams
Output execution parameters.
ClassifierStrategyOutParameters const * getOutputParameters() const
Returns a pointer to the strategy output execution parameters or a null pointer if there are none.
bool execute()
Executes the classification strategy.
unsigned int getOutputNumberBands(void)
te::cl::MAP m_genClassInstance
A generir classifier instance.
bool initialize(ClassifierStrategyParameters const *const strategyParams)
Initialize the classification strategy.
bool m_isInitialized
Is this instance initialized?
ClassifierMAPStrategy::Parameters m_initParams
Initialization parameters.
Parameters::ClassIDT m_highestTrainClassID
The highest train sample lable.
Raster classifier strategy factory base class.
Classifier Strategy Output Parameters.
Raster classifier strategy base class.
TerraLib.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
Proxy configuration file for TerraView (see terraview_config.h).