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  */
87  InputParameters(const InputParameters& rhs);
88 
89  ~InputParameters();
90 
91  /*!
92  \brief Set specific classifier strategy parameters.
93 
94  \param p The specific classifier strategy parameters.
95  */
96  void setClassifierStrategyParams(const ClassifierStrategyParameters& p);
97 
98  /*!
99  \brief Returns a pointer to the internal specific classifier strategy parameters, or null if no parameters are present.
100  */
101  ClassifierStrategyParameters const* getClassifierStrategyParams() const;
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  std::vector<unsigned int> m_inputRasterBands; //!< Bands to be processed from the input raster.
118  std::vector<te::gm::Polygon*> m_inputPolygons; //!< The polygons to be classified when using object-based image analysis (OBIA).
119  std::string m_strategyName; //!< The classifier strategy name see each te::rp::ClassifierStrategyFactory inherited classes documentation for reference.
120  ClassifierStrategyParameters* m_classifierStrategyParamsPtr; //!< Internal specific classifier strategy parameters.
121  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.
122 
123  };
124 
125  /*!
126  \class OutputParameters
127 
128  \brief Classifier output parameters
129  */
130 
132  {
133  public:
134 
135  /*! \brief Default constructor. */
137 
138  /*!
139  \brief Copy constructor.
140 
141  \param rhs The right-hand side Raster.
142  */
144 
145  ~OutputParameters();
146 
147  //overload
148  void reset() throw(te::rp::Exception);
149 
150  //overload
151  const Classifier::OutputParameters& operator=(const Classifier::OutputParameters& params);
152 
153  //overload
154  te::common::AbstractParameters* clone() const;
155 
156  public:
157 
158  std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
159  std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the raster (as described in te::raster::RasterFactory).
160  mutable std::unique_ptr<te::rst::Raster> m_outputRasterPtr; //!< A pointer to the generated output raster (label image).
161  std::map< std::string, std::string > m_metadata; //!< Extra strategy-dependent generated metadata.
162  };
163 
164  Classifier();
165 
166  ~Classifier();
167 
168  //overload
169  bool execute(AlgorithmOutputParameters& outputParams) throw(te::rp::Exception);
170 
171  //overload
172  void reset() throw(te::rp::Exception);
173 
174  //overload
175  bool initialize(const AlgorithmInputParameters& inputParams) throw(te::rp::Exception);
176 
177  bool isInitialized() const;
178 
179  protected :
180 
181  bool m_instanceInitialized; //!< Is this instance already initialized?
182  Classifier::InputParameters m_inputParameters; //!< Classifier execution parameters.
183  };
184 
185  } // end namespace rp
186 } // end namespace te
187 
188 #endif
std::vector< te::gm::Polygon * > m_inputPolygons
The polygons to be classified when using object-based image analysis (OBIA).
Definition: Classifier.h:118
Raster classification.
Definition: Classifier.h:65
te::rst::Raster const * m_inputRasterPtr
Input raster.
Definition: Classifier.h:114
bool m_enableProgressInterface
Enable (true) or disable (false) the use of a progress interface (default: disabled).
Definition: Classifier.h:115
std::string m_strategyName
The classifier strategy name see each te::rp::ClassifierStrategyFactory inherited classes documentati...
Definition: Classifier.h:119
Base exception class for plugin module.
Definition: Exception.h:42
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
A pointer to the generated output raster (label image).
Definition: Classifier.h:160
Raster Processing algorithm output parameters base interface.
std::vector< te::rst::BandProperty::ColorEntry > m_userOutputPalette
User output raster palette (it must be large enough to accomodate all classifyier generated classes o...
Definition: Classifier.h:121
Raster Processing algorithm base interface class.
Classifier output parameters.
Definition: Classifier.h:131
Raster classifier strategy parameters base class.
Raster Processing algorithm base interface.
Definition: Algorithm.h:41
An abstract class for raster data strucutures.
Definition: Raster.h:71
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
std::vector< unsigned int > m_inputRasterBands
Bands to be processed from the input raster.
Definition: Classifier.h:117
Generic template matrix.
Abstract parameters base interface.
Configuration flags for the Raster Processing module of TerraLib.
Raster Processing algorithm input parameters base interface.
std::map< std::string, std::string > m_rInfo
The necessary information to create the raster (as described in te::raster::RasterFactory).
Definition: Classifier.h:159
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: Classifier.h:158
ClassifierStrategyParameters * m_classifierStrategyParamsPtr
Internal specific classifier strategy parameters.
Definition: Classifier.h:120
bool m_createRasterPalette
Enable (true) or disable (false) the creation of a paletted output raster (default:true).
Definition: Classifier.h:116
Classifier input parameters.
Definition: Classifier.h:75
std::map< std::string, std::string > m_metadata
Extra strategy-dependent generated metadata.
Definition: Classifier.h:161