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  class AlgorithmParametersSerializer;
53 
54  /*!
55  \class Classifier
56 
57  \brief Raster classification.
58 
59  \details Raster classification following the choosed strategy.
60 
61  \note The created label image will be written to the raster instance
62  pointed by m_outRasterPtr (in this case the output band must also be
63  passed by m_outRasterBand).
64 
65  \ingroup rp_class
66  */
68  {
69  public:
70 
71  /*!
72  \class InputParameters
73 
74  \brief Classifier input parameters
75  */
76 
78  {
79  public:
80 
81  /*! \brief Default constructor. */
83 
84  /*!
85  \brief Copy constructor.
86 
87  \param rhs The right-hand side Raster.
88  */
90 
92 
93  /*!
94  \brief Set specific classifier strategy parameters.
95 
96  \param p The specific classifier strategy parameters.
97  */
99 
100  /*!
101  \brief Returns a pointer to the internal specific classifier strategy parameters, or null if no parameters are present.
102  */
104 
105  //overload
106  void reset() ;
107 
108  //overload
110 
111  //overload
113 
114  //overload
115  bool serialize ( AlgorithmParametersSerializer& serializer ) const;
116 
117  public:
118 
119  te::rst::Raster const* m_inputRasterPtr; //!< Input raster.
120  bool m_enableProgressInterface; //!< Enable (true) or disable (false) the use of a progress interface (default: disabled).
121  bool m_createRasterPalette; //!< Enable (true) or disable (false) the creation of a paletted output raster (default:true).
122  bool m_enableRasterCache; //!< Enable (true) or disable (false) the use of memory raster data cache (default:true).
123  bool m_enableMultiThread; //!< Enable (true) or disable (false) the use multiple threads (default:true).
124  std::vector<unsigned int> m_inputRasterBands; //!< Bands to be processed from the input raster.
125  std::vector<te::gm::Polygon*> m_inputPolygons; //!< The polygons to be classified when using object-based image analysis (OBIA).
126  std::string m_strategyName; //!< The classifier strategy name see each te::rp::ClassifierStrategyFactory inherited classes documentation for reference.
127  ClassifierStrategyParameters* m_classifierStrategyParamsPtr; //!< Internal specific classifier strategy parameters.
128  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.
129 
130  };
131 
132  /*!
133  \class OutputParameters
134 
135  \brief Classifier output parameters
136  */
137 
139  {
140  public:
141 
142  /*! \brief Default constructor. */
144 
145  /*!
146  \brief Copy constructor.
147 
148  \param rhs The right-hand side Raster.
149  */
151 
153 
154  //overload
155  void reset() ;
156 
157  //overload
159 
160  //overload
162 
163  public:
164 
165  std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
166  std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the raster (as described in te::raster::RasterFactory).
167  mutable std::unique_ptr<te::rst::Raster> m_outputRasterPtr; //!< A pointer to the generated output raster (label image).
168  std::map< std::string, std::string > m_metadata; //!< Extra strategy-dependent generated metadata.
169  };
170 
172 
174 
175  //overload
176  bool execute(AlgorithmOutputParameters& outputParams) ;
177 
178  //overload
179  void reset() ;
180 
181  //overload
182  bool initialize(const AlgorithmInputParameters& inputParams) ;
183 
184  bool isInitialized() const;
185 
186  protected :
187 
188  bool m_instanceInitialized; //!< Is this instance already initialized?
189  Classifier::InputParameters m_inputParameters; //!< Classifier execution parameters.
190  };
191 
192  } // end namespace rp
193 } // end namespace te
194 
195 #endif
Raster classifier strategy parameters base class.
Generic template matrix.
Abstract parameters base interface.
Raster Processing algorithm input parameters base interface.
Raster Processing algorithm output parameters base interface.
A class to standardize algorithm parameters serialization.
Raster Processing algorithm base interface.
Definition: Algorithm.h:42
Classifier input parameters.
Definition: Classifier.h:78
te::rst::Raster const * m_inputRasterPtr
Input raster.
Definition: Classifier.h:119
bool m_enableMultiThread
Enable (true) or disable (false) the use multiple threads (default:true).
Definition: Classifier.h:123
void setClassifierStrategyParams(const ClassifierStrategyParameters &p)
Set specific classifier strategy parameters.
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
std::vector< te::gm::Polygon * > m_inputPolygons
The polygons to be classified when using object-based image analysis (OBIA).
Definition: Classifier.h:125
ClassifierStrategyParameters const * getClassifierStrategyParams() const
Returns a pointer to the internal specific classifier strategy parameters, or null if no parameters a...
std::vector< unsigned int > m_inputRasterBands
Bands to be processed from the input raster.
Definition: Classifier.h:124
bool m_enableProgressInterface
Enable (true) or disable (false) the use of a progress interface (default: disabled).
Definition: Classifier.h:120
te::common::AbstractParameters * clone() const
Create a clone copy of this instance.
ClassifierStrategyParameters * m_classifierStrategyParamsPtr
Internal specific classifier strategy parameters.
Definition: Classifier.h:127
InputParameters()
Default constructor.
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:128
InputParameters(const InputParameters &rhs)
Copy constructor.
bool serialize(AlgorithmParametersSerializer &serializer) const
Returns a parameter serialization object.
bool m_enableRasterCache
Enable (true) or disable (false) the use of memory raster data cache (default:true).
Definition: Classifier.h:122
std::string m_strategyName
The classifier strategy name see each te::rp::ClassifierStrategyFactory inherited classes documentati...
Definition: Classifier.h:126
bool m_createRasterPalette
Enable (true) or disable (false) the creation of a paletted output raster (default:true).
Definition: Classifier.h:121
const Classifier::InputParameters & operator=(const Classifier::InputParameters &params)
Classifier output parameters.
Definition: Classifier.h:139
OutputParameters()
Default constructor.
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: Classifier.h:165
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
std::map< std::string, std::string > m_metadata
Extra strategy-dependent generated metadata.
Definition: Classifier.h:168
const Classifier::OutputParameters & operator=(const Classifier::OutputParameters &params)
te::common::AbstractParameters * clone() const
Create a clone copy of this instance.
OutputParameters(const OutputParameters &rhs)
Copy constructor.
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
A pointer to the generated output raster (label image).
Definition: Classifier.h:167
std::map< std::string, std::string > m_rInfo
The necessary information to create the raster (as described in te::raster::RasterFactory).
Definition: Classifier.h:166
Raster classification.
Definition: Classifier.h:68
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
Classifier::InputParameters m_inputParameters
Classifier execution parameters.
Definition: Classifier.h:189
bool m_instanceInitialized
Is this instance already initialized?
Definition: Classifier.h:188
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
bool isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
An abstract class for raster data strucutures.
Definition: Raster.h:72
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).
Abstract algorithm.