MixtureModel.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 /*!
21  \file terralib/rp/MixtureModel.h
22 
23  \brief Raster decomposition using mixture model.
24  */
25 
26 #ifndef __TERRALIB_RP_INTERNAL_MIXTUREMODEL_H
27 #define __TERRALIB_RP_INTERNAL_MIXTUREMODEL_H
28 
29 // TerraLib
30 #include "Algorithm.h"
31 #include "Config.h"
32 #include "Matrix.h"
34 
35 // Boost
36 #include <boost/numeric/ublas/matrix.hpp>
37 
38 namespace te
39 {
40  namespace rst
41  {
42  class Raster;
43  class Band;
44  }
45 
46  namespace rp
47  {
48  /*!
49  \class MixtureModel
50 
51  \brief Raster decomposition using mixture model.
52 
53  \details Raster decomposition following the choosed mixture model strategy.
54 
55  \note The created output image will be written to the raster instance
56  pointed by m_outRasterPtr (in this case the output band must also be
57  passed by m_outRasterBand).
58 
59  \ingroup rp_class
60  */
61 
63  {
64  public:
65 
66  /*!
67  \class InputParameters
68 
69  \brief MixtureModel input parameters
70  */
71 
73  {
74  public:
75 
76  /*! \brief Default constructor. */
78 
79  /*!
80  \brief Copy constructor.
81 
82  \param rhs The right-hand side Raster.
83  */
85 
87 
88  /*!
89  \brief Set specific mixture model strategy parameters.
90 
91  \param p The specific mixture model strategy parameters.
92  */
94 
95  /*!
96  \brief Returns a pointer to the internal specific mixture model strategy parameters, or null if no parameters are present.
97  */
99 
100  //overload
101  void reset() ;
102 
103  //overload
105 
106  //overload
108 
109  //overload
110  bool serialize ( AlgorithmParametersSerializer& serializer ) const;
111 
112  public:
113 
114  te::rst::Raster const* m_inputRasterPtr; //!< Input raster.
115  std::vector<unsigned int> m_inputRasterBands; //!< Bands to be processed from the input raster.
116  std::vector<std::string> m_inputSensorBands; //!< The names of the sensor/bands.
117  std::map<std::string, std::vector<double> > m_components; //!< A set of endmembers and its radiances.
118  std::string m_strategyName; //!< The mixture model strategy name see each te::rp::MixtureModelStrategyFactory inherited classes documentation for reference.
119  MixtureModelStrategyParameters* m_mixtureModelStrategyParamsPtr; //!< Internal specific mixture model strategy parameters.
120  boost::numeric::ublas::matrix<double> m_transfMatrix; //!< Used transformation matrix (when applicable).
121  std::vector< std::complex< double > > m_inputRasterNoDataValues; //!< A vector of values to be used as input raster no-data values or an empty vector indicating to use the default values from the input raster..
122  };
123 
124  /*!
125  \class OutputParameters
126 
127  \brief MixtureModel output parameters
128  */
129 
131  {
132  public:
133 
134  /*! \brief Default constructor. */
136 
137  /*!
138  \brief Copy constructor.
139 
140  \param rhs The right-hand side Raster.
141  */
143 
145 
146  /*!\brief Reset all variables*/
147  void reset() ;
148 
149  /*!\brief assigment operator*/
151 
152  /*!\brief Copy paramters*/
154 
155  public:
156 
157  std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
158  std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the output raster (as described in te::raster::RasterFactory).
159  mutable std::unique_ptr<te::rst::Raster> m_outputRasterPtr; //!< A pointer to the generated output raster, one band per component plus one error band per component (when parameter m_createErrorRaster is true).
160  mutable std::unique_ptr<te::rst::Raster> m_errorRasterPtr; //!< A pointer to the generated output error raster, one band per component plus one error band per component (when parameter m_createErrorRaster is true).
161  std::map< std::string, std::string > m_rInfoError; //!< The necessary information to create the error raster (as described in te::raster::RasterFactory).
162  bool m_normalizeOutput; //!< A flag to indicate that output raster will be normalized , default [0, 1].
163  double m_normalMin; //!< Lower limit to normalized
164  double m_normalMax; //!< Upper limit to normalized
165  bool m_createErrorRaster; //!< A flag to indicate that output raster will include the error bands.
166  std::vector<double> m_min; //!< Minimun value calculeted in output raster
167  std::vector<double> m_max; //!< Maximum value calculeted in output raster
168  std::vector<double> m_minerror; //!< Minimun value calculeted in output raster
169  std::vector<double> m_maxerror; //!< Maximum value calculeted in output raster
170 
171  };
172 
174 
176 
177  /*!\brief Executes the mixing model using the parameters defined in inputParams and outputParams */
178  bool execute(AlgorithmOutputParameters& outputParams) ;
179 
180  /*!\brief Resets all variables */
181  void reset() ;
182 
183  /*!\brief Initializes model with paramters defined in inputParams*/
184  bool initialize(const AlgorithmInputParameters& inputParams) ;
185 
186  /*!\brief Model already initialized?*/
187  bool isInitialized() const;
188 
189  /*!\brief Sets Transform Matrix, read from a file or pre-calculated*/
190  bool setTransformMatrix(boost::numeric::ublas::matrix<double>& matrix);
191 
192  /*!\brief Generates a Transform Matrix*/
193  bool generateTransformMatrix(boost::numeric::ublas::matrix<double>& matrix);
194 
195  protected :
196 
197  bool m_instanceInitialized; //!< Is this instance already initialized?
198  MixtureModel::InputParameters m_inputParameters; //!< Mixture model execution parameters.
199  };
200 
201  } // end namespace rp
202 } // end namespace te
203 
204 #endif
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
Mixture model strategy parameters base class.
MixtureModel input parameters.
Definition: MixtureModel.h:73
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
void setMixtureModelStrategyParams(const MixtureModelStrategyParameters &p)
Set specific mixture model strategy parameters.
InputParameters()
Default constructor.
StrategyParameters const * getMixtureModelStrategyParams() const
Returns a pointer to the internal specific mixture model strategy parameters, or null if no parameter...
te::common::AbstractParameters * clone() const
Create a clone copy of this instance.
te::rst::Raster const * m_inputRasterPtr
Input raster.
Definition: MixtureModel.h:114
std::string m_strategyName
The mixture model strategy name see each te::rp::MixtureModelStrategyFactory inherited classes docume...
Definition: MixtureModel.h:118
MixtureModelStrategyParameters * m_mixtureModelStrategyParamsPtr
Internal specific mixture model strategy parameters.
Definition: MixtureModel.h:119
boost::numeric::ublas::matrix< double > m_transfMatrix
Used transformation matrix (when applicable).
Definition: MixtureModel.h:120
InputParameters(const InputParameters &rhs)
Copy constructor.
std::vector< unsigned int > m_inputRasterBands
Bands to be processed from the input raster.
Definition: MixtureModel.h:115
std::vector< std::string > m_inputSensorBands
The names of the sensor/bands.
Definition: MixtureModel.h:116
std::vector< std::complex< double > > m_inputRasterNoDataValues
A vector of values to be used as input raster no-data values or an empty vector indicating to use the...
Definition: MixtureModel.h:121
const MixtureModel::InputParameters & operator=(const MixtureModel::InputParameters &params)
std::map< std::string, std::vector< double > > m_components
A set of endmembers and its radiances.
Definition: MixtureModel.h:117
bool serialize(AlgorithmParametersSerializer &serializer) const
Returns a parameter serialization object.
MixtureModel output parameters.
Definition: MixtureModel.h:131
double m_normalMin
Lower limit to normalized.
Definition: MixtureModel.h:163
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
A pointer to the generated output raster, one band per component plus one error band per component (w...
Definition: MixtureModel.h:159
const MixtureModel::OutputParameters & operator=(const MixtureModel::OutputParameters &params)
assigment operator
te::common::AbstractParameters * clone() const
Copy paramters.
void reset()
Reset all variables.
OutputParameters(const OutputParameters &rhs)
Copy constructor.
double m_normalMax
Upper limit to normalized.
Definition: MixtureModel.h:164
bool m_createErrorRaster
A flag to indicate that output raster will include the error bands.
Definition: MixtureModel.h:165
std::vector< double > m_minerror
Minimun value calculeted in output raster.
Definition: MixtureModel.h:168
std::vector< double > m_maxerror
Maximum value calculeted in output raster.
Definition: MixtureModel.h:169
std::unique_ptr< te::rst::Raster > m_errorRasterPtr
A pointer to the generated output error raster, one band per component plus one error band per compon...
Definition: MixtureModel.h:160
std::map< std::string, std::string > m_rInfo
The necessary information to create the output raster (as described in te::raster::RasterFactory).
Definition: MixtureModel.h:158
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: MixtureModel.h:157
std::vector< double > m_min
Minimun value calculeted in output raster.
Definition: MixtureModel.h:166
OutputParameters()
Default constructor.
bool m_normalizeOutput
A flag to indicate that output raster will be normalized , default [0, 1].
Definition: MixtureModel.h:162
std::map< std::string, std::string > m_rInfoError
The necessary information to create the error raster (as described in te::raster::RasterFactory).
Definition: MixtureModel.h:161
std::vector< double > m_max
Maximum value calculeted in output raster.
Definition: MixtureModel.h:167
Raster decomposition using mixture model.
Definition: MixtureModel.h:63
bool execute(AlgorithmOutputParameters &outputParams)
Executes the mixing model using the parameters defined in inputParams and outputParams.
bool setTransformMatrix(boost::numeric::ublas::matrix< double > &matrix)
Sets Transform Matrix, read from a file or pre-calculated.
bool generateTransformMatrix(boost::numeric::ublas::matrix< double > &matrix)
Generates a Transform Matrix.
MixtureModel::InputParameters m_inputParameters
Mixture model execution parameters.
Definition: MixtureModel.h:198
bool initialize(const AlgorithmInputParameters &inputParams)
Initializes model with paramters defined in inputParams.
void reset()
Resets all variables.
bool isInitialized() const
Model already initialized?
bool m_instanceInitialized
Is this instance already initialized?
Definition: MixtureModel.h:197
Raster strategy parameters base class.
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.