Loading...
Searching...
No Matches
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"
34#include "../raster/BandProperty.h"
35
36#include <map>
37
38namespace te
39{
40 namespace rst
41 {
42 class Raster;
43 class Band;
44 }
45
46 namespace gm
47 {
48 class Polygon;
49 }
50
51 namespace rp
52 {
53 class AlgorithmParametersSerializer;
54
55 /*!
56 \class Classifier
57
58 \brief Raster classification.
59
60 \details Raster classification following the choosed strategy.
61
62 \note The created label image will be written to the raster instance
63 pointed by m_outRasterPtr (in this case the output band must also be
64 passed by m_outRasterBand).
65
66 \ingroup rp_class
67 */
69 {
70 public:
71
72 /*!
73 \class InputParameters
74
75 \brief Classifier input parameters
76 */
77
79 {
80 public:
81
82 /*! \brief Default constructor. */
84
85 /*!
86 \brief Copy constructor.
87
88 \param rhs The right-hand side Raster.
89 */
91
93
94 /*!
95 \brief Set specific classifier strategy parameters.
96
97 \param p The specific classifier strategy parameters.
98 */
100
101 /*!
102 \brief Returns a pointer to the internal specific classifier strategy parameters, or null if no parameters are present.
103 */
105
106 //overload
107 void reset() ;
108
109 //overload
111
112 //overload
114
115 //overload
116 bool serialize ( AlgorithmParametersSerializer& serializer ) const;
117
118 public:
119
120 te::rst::Raster const* m_inputRasterPtr; //!< Input raster.
121 bool m_enableProgressInterface; //!< Enable (true) or disable (false) the use of a progress interface (default: disabled).
122 bool m_createRasterPalette; //!< Enable (true) or disable (false) the creation of a paletted output raster (default:true).
123 bool m_enableRasterCache; //!< Enable (true) or disable (false) the use of memory raster data cache (default:true).
124 bool m_enableMultiThread; //!< Enable (true) or disable (false) the use multiple threads (default:true).
125 std::vector<unsigned int> m_inputRasterBands; //!< Bands to be processed from the input raster.
126 std::vector<te::gm::Polygon*> m_inputPolygons; //!< The polygons to be classified when using object-based image analysis (OBIA).
127 std::string m_strategyName; //!< The classifier strategy name see each te::rp::ClassifierStrategyFactory inherited classes documentation for reference.
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 private:
131
132 ClassifierStrategyParameters* m_classifierStrategyParamsPtr; //!< Internal specific classifier strategy parameters.
133 };
134
135 /*!
136 \class OutputParameters
137
138 \brief Classifier output parameters
139 */
140
142 {
143 public:
144
145 /*! \brief Default constructor. */
147
148 /*!
149 \brief Copy constructor.
150
151 \param rhs The right-hand side Raster.
152 */
154
156
157 //overload
158 void reset() ;
159
160 //overload
162
163 //overload
165
166 /*!
167 \brief Set specific classifier strategy output parameters.
168
169 \param p The specific classifier strategy output parameters.
170 */
172
173 /*!
174 \brief Returns a pointer to the internal specific classifier strategy output parameters, or null if no parameters are present.
175 */
177
178 public:
179
180 std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
181 std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the raster (as described in te::raster::RasterFactory).
182 mutable std::unique_ptr<te::rst::Raster> m_outputRasterPtr; //!< A pointer to the generated output raster (label image).
183 std::map< std::string, std::string > m_metadata; //!< Extra strategy-dependent generated metadata.
184
185 private:
186
187 ClassifierStrategyOutParameters* m_classifierStrategyOutParamsPtr; //!< Internal specific classifier strategy output parameters.
188 };
189
191
193
194 //overload
195 bool execute(AlgorithmOutputParameters& outputParams) ;
196
197 //overload
198 void reset() ;
199
200 //overload
201 bool initialize(const AlgorithmInputParameters& inputParams) ;
202
203 bool isInitialized() const;
204
205 protected :
206
207 bool m_instanceInitialized; //!< Is this instance already initialized?
208 Classifier::InputParameters m_inputParameters; //!< Classifier execution parameters.
209 };
210
211 } // end namespace rp
212} // end namespace te
213
214#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 Strategy Output Parameters.
Classifier input parameters.
Definition: Classifier.h:79
te::rst::Raster const * m_inputRasterPtr
Input raster.
Definition: Classifier.h:120
bool m_enableMultiThread
Enable (true) or disable (false) the use multiple threads (default:true).
Definition: Classifier.h:124
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.
ClassifierStrategyParameters const * getClassifierStrategyParams() const
Returns a pointer to the internal specific classifier strategy parameters, or null if no parameters a...
std::vector< te::gm::Polygon * > m_inputPolygons
The polygons to be classified when using object-based image analysis (OBIA).
Definition: Classifier.h:126
std::vector< unsigned int > m_inputRasterBands
Bands to be processed from the input raster.
Definition: Classifier.h:125
te::common::AbstractParameters * clone() const
Create a clone copy of this instance.
bool m_enableProgressInterface
Enable (true) or disable (false) the use of a progress interface (default: disabled).
Definition: Classifier.h:121
const Classifier::InputParameters & operator=(const Classifier::InputParameters &params)
ClassifierStrategyParameters * m_classifierStrategyParamsPtr
Internal specific classifier strategy parameters.
Definition: Classifier.h:132
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:123
std::string m_strategyName
The classifier strategy name see each te::rp::ClassifierStrategyFactory inherited classes documentati...
Definition: Classifier.h:127
bool m_createRasterPalette
Enable (true) or disable (false) the creation of a paletted output raster (default:true).
Definition: Classifier.h:122
Classifier output parameters.
Definition: Classifier.h:142
OutputParameters()
Default constructor.
ClassifierStrategyOutParameters * m_classifierStrategyOutParamsPtr
Internal specific classifier strategy output parameters.
Definition: Classifier.h:187
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: Classifier.h:180
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:183
te::common::AbstractParameters * clone() const
Create a clone copy of this instance.
ClassifierStrategyOutParameters const * getClassifierStrategyOutParams() const
Returns a pointer to the internal specific classifier strategy output parameters, or null if no param...
void setClassifierStrategyOutParams(const ClassifierStrategyOutParameters &p)
Set specific classifier strategy output parameters.
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:182
const Classifier::OutputParameters & operator=(const Classifier::OutputParameters &params)
std::map< std::string, std::string > m_rInfo
The necessary information to create the raster (as described in te::raster::RasterFactory).
Definition: Classifier.h:181
Raster classification.
Definition: Classifier.h:69
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
Classifier::InputParameters m_inputParameters
Classifier execution parameters.
Definition: Classifier.h:208
bool m_instanceInitialized
Is this instance already initialized?
Definition: Classifier.h:207
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.