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"
33 #include "StrategyParameters.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  */
84  InputParameters(const InputParameters& rhs);
85 
86  ~InputParameters();
87 
88  /*!
89  \brief Set specific mixture model strategy parameters.
90 
91  \param p The specific mixture model strategy parameters.
92  */
93  void setMixtureModelStrategyParams(const StrategyParameters& p);
94 
95  /*!
96  \brief Returns a pointer to the internal specific mixture model strategy parameters, or null if no parameters are present.
97  */
98  StrategyParameters const* getMixtureModelStrategyParams() const;
99 
100  //overload
101  void reset() throw(te::rp::Exception);
102 
103  //overload
104  const MixtureModel::InputParameters& operator=(const MixtureModel::InputParameters& params);
105 
106  //overload
107  te::common::AbstractParameters* clone() const;
108 
109  public:
110 
111  te::rst::Raster const* m_inputRasterPtr; //!< Input raster.
112  std::vector<unsigned int> m_inputRasterBands; //!< Bands to be processed from the input raster.
113  std::vector<std::string> m_inputSensorBands; //!< The names of the sensor/bands.
114  std::map<std::string, std::vector<double> > m_components; //!< A set of endmembers and its radiances.
115  std::string m_strategyName; //!< The mixture model strategy name see each te::rp::MixtureModelStrategyFactory inherited classes documentation for reference.
116  StrategyParameters* m_mixtureModelStrategyParamsPtr; //!< Internal specific mixture model strategy parameters.
117  boost::numeric::ublas::matrix<double> m_transfMatrix; //!< Used transformation matrix (when applicable).
118  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..
119  };
120 
121  /*!
122  \class OutputParameters
123 
124  \brief MixtureModel output parameters
125  */
126 
128  {
129  public:
130 
131  /*! \brief Default constructor. */
133 
134  /*!
135  \brief Copy constructor.
136 
137  \param rhs The right-hand side Raster.
138  */
140 
141  ~OutputParameters();
142 
143  /*!\brief Reset all variables*/
144  void reset() throw(te::rp::Exception);
145 
146  /*!\brief assigment operator*/
147  const MixtureModel::OutputParameters& operator=(const MixtureModel::OutputParameters& params);
148 
149  /*!\brief Copy paramters*/
150  te::common::AbstractParameters* clone() const;
151 
152  public:
153 
154  std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
155  std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the output raster (as described in te::raster::RasterFactory).
156  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).
157  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).
158  std::map< std::string, std::string > m_rInfoError; //!< The necessary information to create the error raster (as described in te::raster::RasterFactory).
159  bool m_normalizeOutput; //!< A flag to indicate that output raster will be normalized , default [0, 1].
160  double m_normalMin; //!< Lower limit to normalized
161  double m_normalMax; //!< Upper limit to normalized
162  bool m_createErrorRaster; //!< A flag to indicate that output raster will include the error bands.
163  std::vector<double> m_min; //!< Minimun value calculeted in output raster
164  std::vector<double> m_max; //!< Maximum value calculeted in output raster
165  std::vector<double> m_minerror; //!< Minimun value calculeted in output raster
166  std::vector<double> m_maxerror; //!< Maximum value calculeted in output raster
167 
168  };
169 
170  MixtureModel();
171 
172  ~MixtureModel();
173 
174  /*!\brief Executes the mixing model using the parameters defined in inputParams and outputParams */
175  bool execute(AlgorithmOutputParameters& outputParams) throw(te::rp::Exception);
176 
177  /*!\brief Resets all variables */
178  void reset() throw(te::rp::Exception);
179 
180  /*!\brief Initializes model with paramters defined in inputParams*/
181  bool initialize(const AlgorithmInputParameters& inputParams) throw(te::rp::Exception);
182 
183  /*!\brief Model already initialized?*/
184  bool isInitialized() const;
185 
186  /*!\brief Sets Transform Matrix, read from a file or pre-calculated*/
187  bool setTransformMatrix(boost::numeric::ublas::matrix<double>& matrix);
188 
189  /*!\brief Generates a Transform Matrix*/
190  bool generateTransformMatrix(boost::numeric::ublas::matrix<double>& matrix);
191 
192  protected :
193 
194  bool m_instanceInitialized; //!< Is this instance already initialized?
195  MixtureModel::InputParameters m_inputParameters; //!< Mixture model execution parameters.
196  };
197 
198  } // end namespace rp
199 } // end namespace te
200 
201 #endif
std::vector< double > m_min
Minimun value calculeted in output raster.
Definition: MixtureModel.h:163
Raster decomposition using mixture model.
Definition: MixtureModel.h:62
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:158
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: MixtureModel.h:154
Base exception class for plugin module.
Definition: Exception.h:42
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:157
Raster Processing algorithm output parameters base interface.
std::vector< std::string > m_inputSensorBands
The names of the sensor/bands.
Definition: MixtureModel.h:113
Raster Processing algorithm base interface class.
std::string m_strategyName
The mixture model strategy name see each te::rp::MixtureModelStrategyFactory inherited classes docume...
Definition: MixtureModel.h:115
double m_normalMax
Upper limit to normalized.
Definition: MixtureModel.h:161
double m_normalMin
Lower limit to normalized.
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:155
MixtureModel input parameters.
Definition: MixtureModel.h:72
Raster Processing algorithm base interface.
Definition: Algorithm.h:41
std::vector< double > m_max
Maximum value calculeted in output raster.
Definition: MixtureModel.h:164
bool m_normalizeOutput
A flag to indicate that output raster will be normalized , default [0, 1].
Definition: MixtureModel.h:159
std::vector< double > m_minerror
Minimun value calculeted in output raster.
Definition: MixtureModel.h:165
An abstract class for raster data strucutures.
Definition: Raster.h:71
URI C++ Library.
Raster strategy parameters base class.
Raster strategy parameters base class.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
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:118
std::vector< double > m_maxerror
Maximum value calculeted in output raster.
Definition: MixtureModel.h:166
Generic template matrix.
Abstract parameters base interface.
std::map< std::string, std::vector< double > > m_components
A set of endmembers and its radiances.
Definition: MixtureModel.h:114
MixtureModel output parameters.
Definition: MixtureModel.h:127
Configuration flags for the Raster Processing module of TerraLib.
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:156
Raster Processing algorithm input parameters base interface.
boost::numeric::ublas::matrix< double > m_transfMatrix
Used transformation matrix (when applicable).
Definition: MixtureModel.h:117
te::rst::Raster const * m_inputRasterPtr
Input raster.
Definition: MixtureModel.h:111
bool m_createErrorRaster
A flag to indicate that output raster will include the error bands.
Definition: MixtureModel.h:162
StrategyParameters * m_mixtureModelStrategyParamsPtr
Internal specific mixture model strategy parameters.
Definition: MixtureModel.h:116
std::vector< unsigned int > m_inputRasterBands
Bands to be processed from the input raster.
Definition: MixtureModel.h:112