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  */
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() 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 
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 
171 
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
te::rp::MixtureModel::InputParameters::getMixtureModelStrategyParams
StrategyParameters const * getMixtureModelStrategyParams() const
Returns a pointer to the internal specific mixture model strategy parameters, or null if no parameter...
te::rp::MixtureModel::InputParameters::setMixtureModelStrategyParams
void setMixtureModelStrategyParams(const StrategyParameters &p)
Set specific mixture model strategy parameters.
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rp::MixtureModel::InputParameters::~InputParameters
~InputParameters()
te::rp::AlgorithmOutputParameters
Raster Processing algorithm output parameters base interface.
Definition: AlgorithmOutputParameters.h:40
te::rp::AlgorithmInputParameters
Raster Processing algorithm input parameters base interface.
Definition: AlgorithmInputParameters.h:40
Matrix.h
Generic template matrix.
boost
Definition: Translator.h:43
te::rp::MixtureModel
Raster decomposition using mixture model.
Definition: MixtureModel.h:63
te::rp::MixtureModel::OutputParameters
MixtureModel output parameters.
Definition: MixtureModel.h:128
te::rp::Algorithm
Raster Processing algorithm base interface.
Definition: Algorithm.h:42
te::rp::MixtureModel::InputParameters::reset
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::rp::MixtureModel::OutputParameters::reset
void reset()
Reset all variables.
te::rp::MixtureModel::OutputParameters::OutputParameters
OutputParameters()
Default constructor.
te::Exception
Base exception class for plugin module.
Definition: Exception.h:42
TERPEXPORT
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
te::rp::StrategyParameters
Raster strategy parameters base class.
Definition: StrategyParameters.h:43
te::rp::MixtureModel::InputParameters::InputParameters
InputParameters(const InputParameters &rhs)
Copy constructor.
te::rp::MixtureModel::OutputParameters::~OutputParameters
~OutputParameters()
Algorithm.h
Abstract algorithm.
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
StrategyParameters.h
Raster strategy parameters base class.
te::rp::MixtureModel::InputParameters
MixtureModel input parameters.
Definition: MixtureModel.h:73
te::rp::MixtureModel::OutputParameters::OutputParameters
OutputParameters(const OutputParameters &rhs)
Copy constructor.
te::rp::MixtureModel::InputParameters::InputParameters
InputParameters()
Default constructor.