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"
30 #include "Config.h"
31 #include "../classification/MAP.h"
32 #include "../classification/Adaptors.h"
33 
34 #include <boost/shared_ptr.hpp>
35 
36 #include <map>
37 #include <vector>
38 
39 namespace te
40 {
41  namespace rp
42  {
43  class AlgorithmParametersSerializer;
44 
45  /*!
46  \class ClassifierMAPStrategy
47 
48  \brief Maximum a posteriori probability strategy.
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  typedef unsigned int ClassIDT; //!< Class ID type definition (zero means invalid ID).
66 
67  typedef std::vector< double > ClassSampleT; //!< Class sample type definition.
68 
69  typedef std::vector< ClassSampleT > ClassSamplesContainerT; //!< Class samples container type definition.
70 
71  typedef std::map< ClassIDT, ClassSamplesContainerT > MClassesSamplesCT; //!< Multi-classes samples container type definition.
72 
73  typedef boost::shared_ptr<MClassesSamplesCT> MClassesSamplesCTPtr; //!< A shared pointer to a multi classes samples container type definition.
74 
75  MClassesSamplesCTPtr m_trainSamplesPtr; //!< A shared pointer to a always-valid structure where trainning samples are stored.
76 
77  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).
78 
79  unsigned int m_prioriCalcSampleStep; //!< A positive non-zero sample step used when calculating piori probabilities (default:5 - 1/5 of samples will be used);
80 
82 
84 
85  //overload
86  const Parameters& operator=(const Parameters& params);
87 
88  //overload
89  void reset() ;
90 
91  //overload
92  AbstractParameters* clone() const;
93 
94  //overload
95  bool serialize ( AlgorithmParametersSerializer& serializer ) const;
96  };
97 
99 
101 
102  //overload
103  bool initialize(ClassifierStrategyParameters const* const strategyParams) ;
104 
105  //overload
106  bool execute() ;
107 
108  unsigned int getOutputNumberBands(void);
109 
110  protected :
111 
112  bool m_isInitialized; //!< Is this instance initialized?
113 
114  Parameters::ClassIDT m_highestTrainClassID; //!< The highest train sample lable.
115 
116  ClassifierMAPStrategy::Parameters m_initParams; //!< Initialization parameters.
117 
118  te::cl::MAP m_genClassInstance; //!< A generir classifier instance.
119 
120  };
121 
122  /*!
123  \class ClassifierMAPStrategyFactory
124 
125  \brief Maximum a posteriori probability strategy factory.
126 
127  \note Factory key: RegionGrowing
128  */
130  {
131  public:
132 
134 
136 
137  //overload
139  };
140 
141  } // end namespace rp
142 } // end namespace te
143 
144 #endif // __TERRALIB_RP_INTERNAL_CLASSIFIERMAPSTRATEGY_H
145 
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.
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.
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.
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.
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).