Classifier.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  \file terralib/rp/Classifier.h
21 
22  \brief Raster classification.
23  */
24 
25 #ifndef __TERRALIB_RP_INTERNAL_CLASSIFIER_H
26 #define __TERRALIB_RP_INTERNAL_CLASSIFIER_H
27 
28 // TerraLib
29 #include "Algorithm.h"
30 #include "Config.h"
31 #include "Matrix.h"
33 #include "../raster/BandProperty.h"
34 
35 #include <map>
36 
37 namespace te
38 {
39  namespace rst
40  {
41  class Raster;
42  class Band;
43  }
44 
45  namespace gm
46  {
47  class Polygon;
48  }
49 
50  namespace rp
51  {
52  /*!
53  \class Classifier
54 
55  \brief Raster classification.
56 
57  \details Raster classification following the choosed strategy.
58 
59  \note The created label image will be written to the raster instance
60  pointed by m_outRasterPtr (in this case the output band must also be
61  passed by m_outRasterBand).
62 
63  \ingroup rp_class
64  */
66  {
67  public:
68 
69  /*!
70  \class InputParameters
71 
72  \brief Classifier input parameters
73  */
74 
76  {
77  public:
78 
79  /*! \brief Default constructor. */
81 
82  /*!
83  \brief Copy constructor.
84 
85  \param rhs The right-hand side Raster.
86  */
88 
90 
91  /*!
92  \brief Set specific classifier strategy parameters.
93 
94  \param p The specific classifier strategy parameters.
95  */
97 
98  /*!
99  \brief Returns a pointer to the internal specific classifier strategy parameters, or null if no parameters are present.
100  */
102 
103  //overload
104  void reset() throw(te::rp::Exception);
105 
106  //overload
107  const Classifier::InputParameters& operator=(const Classifier::InputParameters& params);
108 
109  //overload
110  te::common::AbstractParameters* clone() const;
111 
112  public:
113 
114  te::rst::Raster const* m_inputRasterPtr; //!< Input raster.
115  bool m_enableProgressInterface; //!< Enable (true) or disable (false) the use of a progress interface (default: disabled).
116  bool m_createRasterPalette; //!< Enable (true) or disable (false) the creation of a paletted output raster (default:true).
117  bool m_enableRasterCache; //!< Enable (true) or disable (false) the use of memory raster data cache (default:true).
118  bool m_enableMultiThread; //!< Enable (true) or disable (false) the use multiple threads (default:true).
119  std::vector<unsigned int> m_inputRasterBands; //!< Bands to be processed from the input raster.
120  std::vector<te::gm::Polygon*> m_inputPolygons; //!< The polygons to be classified when using object-based image analysis (OBIA).
121  std::string m_strategyName; //!< The classifier strategy name see each te::rp::ClassifierStrategyFactory inherited classes documentation for reference.
122  ClassifierStrategyParameters* m_classifierStrategyParamsPtr; //!< Internal specific classifier strategy parameters.
123  std::vector< te::rst::BandProperty::ColorEntry > m_userOutputPalette; //!< User output raster palette (it must be large enough to accomodate all classifyier generated classes or an empty vector to automatically generate an random palette.
124 
125  };
126 
127  /*!
128  \class OutputParameters
129 
130  \brief Classifier output parameters
131  */
132 
134  {
135  public:
136 
137  /*! \brief Default constructor. */
139 
140  /*!
141  \brief Copy constructor.
142 
143  \param rhs The right-hand side Raster.
144  */
146 
148 
149  //overload
150  void reset() throw(te::rp::Exception);
151 
152  //overload
153  const Classifier::OutputParameters& operator=(const Classifier::OutputParameters& params);
154 
155  //overload
156  te::common::AbstractParameters* clone() const;
157 
158  public:
159 
160  std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
161  std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the raster (as described in te::raster::RasterFactory).
162  mutable std::unique_ptr<te::rst::Raster> m_outputRasterPtr; //!< A pointer to the generated output raster (label image).
163  std::map< std::string, std::string > m_metadata; //!< Extra strategy-dependent generated metadata.
164  };
165 
167 
169 
170  //overload
171  bool execute(AlgorithmOutputParameters& outputParams) throw(te::rp::Exception);
172 
173  //overload
174  void reset() throw(te::rp::Exception);
175 
176  //overload
177  bool initialize(const AlgorithmInputParameters& inputParams) throw(te::rp::Exception);
178 
179  bool isInitialized() const;
180 
181  protected :
182 
183  bool m_instanceInitialized; //!< Is this instance already initialized?
184  Classifier::InputParameters m_inputParameters; //!< Classifier execution parameters.
185  };
186 
187  } // end namespace rp
188 } // end namespace te
189 
190 #endif
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rp::AlgorithmOutputParameters
Raster Processing algorithm output parameters base interface.
Definition: AlgorithmOutputParameters.h:40
te::rp::Classifier::OutputParameters::OutputParameters
OutputParameters()
Default constructor.
te::rp::AlgorithmInputParameters
Raster Processing algorithm input parameters base interface.
Definition: AlgorithmInputParameters.h:40
te::rp::ClassifierStrategyParameters
Classifier Strategy Parameters.
Definition: ClassifierStrategyParameters.h:42
Matrix.h
Generic template matrix.
te::rp::Classifier::InputParameters
Classifier input parameters.
Definition: Classifier.h:76
te::rp::Classifier::OutputParameters::~OutputParameters
~OutputParameters()
te::rp::Algorithm
Raster Processing algorithm base interface.
Definition: Algorithm.h:42
te::rp::Classifier::InputParameters::~InputParameters
~InputParameters()
te::rp::Classifier::OutputParameters::reset
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::rp::Classifier
Raster classification.
Definition: Classifier.h:66
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::Classifier::OutputParameters
Classifier output parameters.
Definition: Classifier.h:134
Algorithm.h
Abstract algorithm.
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::rp::Classifier::InputParameters::setClassifierStrategyParams
void setClassifierStrategyParams(const ClassifierStrategyParameters &p)
Set specific classifier strategy parameters.
te::rp::Classifier::InputParameters::InputParameters
InputParameters(const InputParameters &rhs)
Copy constructor.
ClassifierStrategyParameters.h
Raster classifier strategy parameters base class.
te::rp::Classifier::InputParameters::reset
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::rp::Classifier::InputParameters::InputParameters
InputParameters()
Default constructor.
te::rp::Classifier::InputParameters::getClassifierStrategyParams
ClassifierStrategyParameters const * getClassifierStrategyParams() const
Returns a pointer to the internal specific classifier strategy parameters, or null if no parameters a...
te::rp::Classifier::OutputParameters::OutputParameters
OutputParameters(const OutputParameters &rhs)
Copy constructor.