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  };
119 
120  /*!
121  \class OutputParameters
122 
123  \brief MixtureModel output parameters
124  */
125 
127  {
128  public:
129 
130  /*! \brief Default constructor. */
132 
133  /*!
134  \brief Copy constructor.
135 
136  \param rhs The right-hand side Raster.
137  */
139 
140  ~OutputParameters();
141 
142  /*!\brief Reset all variables*/
143  void reset() throw(te::rp::Exception);
144 
145  /*!\brief assigment operator*/
146  const MixtureModel::OutputParameters& operator=(const MixtureModel::OutputParameters& params);
147 
148  /*!\brief Copy paramters*/
149  te::common::AbstractParameters* clone() const;
150 
151  public:
152 
153  std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
154  std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the raster (as described in te::raster::RasterFactory).
155  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).
156  bool m_createErrorRaster; //!< A flag to indicate that output raster will include the error bands.
157  std::vector<double> m_min; //!< Minimun value calculeted in output raster
158  std::vector<double> m_max; //!< Maximum value calculeted in output raster
159 
160  };
161 
162  MixtureModel();
163 
164  ~MixtureModel();
165 
166  /*!\brief Executes the mixing model using the parameters defined in inputParams and outputParams */
167  bool execute(AlgorithmOutputParameters& outputParams) throw(te::rp::Exception);
168 
169  /*!\brief Resets all variables */
170  void reset() throw(te::rp::Exception);
171 
172  /*!\brief Initializes model with paramters defined in inputParams*/
173  bool initialize(const AlgorithmInputParameters& inputParams) throw(te::rp::Exception);
174 
175  /*!\brief Model already initialized?*/
176  bool isInitialized() const;
177 
178  /*!\brief Sets Transform Matrix, read from a file or pre-calculated*/
179  bool setTransformMatrix(boost::numeric::ublas::matrix<double>& matrix);
180 
181  /*!\brief Generates a Transform Matrix*/
182  bool generateTransformMatrix(boost::numeric::ublas::matrix<double>& matrix);
183 
184  protected :
185 
186  bool m_instanceInitialized; //!< Is this instance already initialized?
187  MixtureModel::InputParameters m_inputParameters; //!< Mixture model execution parameters.
188  };
189 
190  } // end namespace rp
191 } // end namespace te
192 
193 #endif
std::vector< double > m_min
Minimun value calculeted in output raster.
Definition: MixtureModel.h:157
Raster decomposition using mixture model.
Definition: MixtureModel.h:62
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: MixtureModel.h:153
Base exception class for plugin module.
Definition: Exception.h:42
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
std::map< std::string, std::string > m_rInfo
The necessary information to create the raster (as described in te::raster::RasterFactory).
Definition: MixtureModel.h:154
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:158
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
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:126
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:155
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:156
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