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  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 
147  ~OutputParameters();
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 
166  Classifier();
167 
168  ~Classifier();
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
std::vector< te::gm::Polygon * > m_inputPolygons
The polygons to be classified when using object-based image analysis (OBIA).
Definition: Classifier.h:120
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:121
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:162
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:123
Raster Processing algorithm base interface class.
Classifier output parameters.
Definition: Classifier.h:133
Raster classifier strategy parameters base class.
Raster Processing algorithm base interface.
Definition: Algorithm.h:41
bool m_enableRasterCache
Enable (true) or disable (false) the use of memory raster data cache (default:true).
Definition: Classifier.h:117
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:119
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:161
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: Classifier.h:160
ClassifierStrategyParameters * m_classifierStrategyParamsPtr
Internal specific classifier strategy parameters.
Definition: Classifier.h:122
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:163
bool m_enableMultiThread
Enable (true) or disable (false) the use multiple threads (default:true).
Definition: Classifier.h:118