Restoration.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 #ifndef __TERRALIB_RP_INTERNAL_RESTORATION_H
22 #define __TERRALIB_RP_INTERNAL_RESTORATION_H
23 
24 #include "Algorithm.h"
25 
26 #include "../raster/Raster.h"
27 
28 #include <vector>
29 #include <string>
30 #include <map>
31 
32 namespace te
33 {
34  namespace rp
35  {
36  /*!
37  \class Restoration
38  \brief This class implements the combining interpolation and restoration operation.
39  \note The restoration operation compensates the degradation due
40  the optics, detector and electronic filtering in the interpolation process.
41  The image to be processed must be in the original resolution. For example
42  Spot-X ( 20 m ), Spot-Pan ( 10 m ) and TM ( 30 m ).
43  Filters and Resamples the input image in disk using a filter
44  in the vertical and horizontal directions.
45  \ingroup rp_enh
46  */
48  {
49  public:
50 
51  /*!
52  \class InputParameters
53  \brief Restoration input parameters
54  */
56  {
57  public:
58 
59  /*! \enum The sensor type.*/
61  {
65  TM,
82  MODIS_500
83  };
84 
85  /*! \enum The available sampling factors.*/
87  {
95  SAMPLING_FACTOR_3_BY_4
96  };
97 
98 
99  SensorType m_sensorType; //!< The sensor type.
100 
101  std::vector< unsigned int > m_sensorBandDesignations; //!< Sensor band designations (starting from 1).
102 
103  te::rst::Raster const* m_inRasterPtr; //!< Input raster.
104 
105  std::vector< unsigned int > m_inRasterBands; //!< Bands to be used from the input raster (starting from zero).
106 
107  SamplingFactorType m_samplingFactor; //!< The samnpling factor.
108 
109  bool m_enableProgress; //!< Enable/Disable the progress interface (default:false).
110 
111  bool m_enableRasterCache; //!< Enable/Disable the use of a raster data cache (default:true).
112 
114 
116 
118 
119  //overload
120  void reset() _NOEXCEPT_OP(false);
121 
122  //overload
123  const InputParameters& operator=( const InputParameters& params );
124 
125  //overload
126  AbstractParameters* clone() const;
127 
128  //overload
129  bool serialize ( AlgorithmParametersSerializer& serializer ) const;
130 
131  /*!
132  \brief Returns all supported sensor types.
133  \param infos All supported sensor types.
134  */
135  static void getSupportedSensorTypes(
136  std::map< SensorType, std::string >& infos );
137 
138  /*!
139  \brief Returns all supported sampling factor types.
140  \param infos All supported sampling factor types.
141  */
142  static void getSupportedSamplingFactorsTypes(
143  std::map< SamplingFactorType, std::string >& infos );
144 
145  /*!
146  \brief Get Resolution sampling factor given the type.
147  \param sFactortype Sampling factor type.
148  \param resSamplingFactor Resolution sampling factor type.
149  \note Output_resolution = input_resolution * resSamplingFactor.
150  */
151  static void getResolutionSamplingFactor(
152  const InputParameters::SamplingFactorType& sFactortype,
153  double& resSamplingFactor );
154  };
155 
156  /*!
157  \class OutputParameters
158  \brief Restoration output parameters
159  */
161  {
162  public:
163 
164  std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
165 
166  std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the raster (as described in te::raster::RasterFactory).
167 
168  std::unique_ptr< te::rst::Raster > m_outputRasterPtr; //!< A pointer the ge generated output raster (label image).
169 
171 
173 
175 
176  //overload
177  void reset() _NOEXCEPT_OP(false);
178 
179  //overload
180  const OutputParameters& operator=( const OutputParameters& params );
181 
182  //overload
183  AbstractParameters* clone() const;
184  };
185 
187 
189 
190  //overload
191  bool execute( AlgorithmOutputParameters& outputParams ) _NOEXCEPT_OP(false);
192 
193  //overload
194  void reset() _NOEXCEPT_OP(false);
195 
196  //overload
197  bool initialize( const AlgorithmInputParameters& inputParams ) _NOEXCEPT_OP(false);
198 
199  //overload
200  bool isInitialized() const;
201 
202  protected:
203 
204  bool m_isInitialized; //!< Is this instance already initialized?
205 
206  Restoration::InputParameters m_inputParameters; //!< Input parameters.
207 
208  /*!
209  \brief Calculate the weights of the restoration filter in the vertical and horizontal directions.
210  \param bandDesignation Sensor band designation (starting from 1).
211  \param XCoefs X coeficients.
212  \param YCoefs Y coeficients.
213  \return true if OK, false on erros.
214  */
215  bool getFilterCoefs(
216  const unsigned int bandDesignation,
217  std::vector< double >& XCoefs,
218  std::vector< double >& YCoefs ) const;
219 
220  /*!
221  \brief Apply the restorafion filter on the input rasters.
222  \param bandsXCoefs X coeficients.
223  \param bandsYCoefs Y coeficients.
224  \param inputRaster Input raster.
225  \param outputRaster PrĂ©-initialized Output raster.
226  \return true if OK, false on erros.
227  */
228  bool applyFilterCoefs(
229  const std::vector< std::vector< double > >& bandsXCoefs,
230  const std::vector< std::vector< double > >& bandsYCoefs,
231  const te::rst::Raster& inputRaster,
232  te::rst::Raster& outputRaster );
233 
234  /*!
235  \brief Decompose sampling factor.
236  \param sFactortype Sampling factor type.
237  \param upperValue Upper value.
238  \param lowerValue Lower value.
239  \note SamplingFactor = ( upperValue / lowerValue ).
240  */
241  static void getDecomposedSamplingFactor(
242  const InputParameters::SamplingFactorType& sFactortype,
243  unsigned int& upperValue,
244  unsigned int& lowerValue );
245 
246  /*!
247  \brief Return the target filter size following the current sensor.
248  \return Return the target filter size following the current sensor.
249  */
250  unsigned int getFilterSize() const;
251 
252  };
253 
254  } // end namespace rp
255 } // end namespace te
256 
257 #endif // __TERRALIB_RP_INTERNAL_RESTORATION_H
258 
#define _NOEXCEPT_OP(x)
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
Restoration input parameters.
Definition: Restoration.h:56
void reset() _NOEXCEPT_OP(false)
Clear all internal allocated resources and reset the parameters instance to its initial state.
std::vector< unsigned int > m_inRasterBands
Bands to be used from the input raster (starting from zero).
Definition: Restoration.h:105
SensorType m_sensorType
The sensor type.
Definition: Restoration.h:99
SamplingFactorType m_samplingFactor
The samnpling factor.
Definition: Restoration.h:107
bool m_enableRasterCache
Enable/Disable the use of a raster data cache (default:true).
Definition: Restoration.h:111
std::vector< unsigned int > m_sensorBandDesignations
Sensor band designations (starting from 1).
Definition: Restoration.h:101
te::rst::Raster const * m_inRasterPtr
Input raster.
Definition: Restoration.h:103
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: Restoration.h:109
InputParameters(const InputParameters &)
Restoration output parameters.
Definition: Restoration.h:161
void reset() _NOEXCEPT_OP(false)
Clear all internal allocated resources and reset the parameters instance to its initial state.
std::map< std::string, std::string > m_rInfo
The necessary information to create the raster (as described in te::raster::RasterFactory).
Definition: Restoration.h:166
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: Restoration.h:164
OutputParameters(const OutputParameters &)
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
A pointer the ge generated output raster (label image).
Definition: Restoration.h:168
This class implements the combining interpolation and restoration operation.
Definition: Restoration.h:48
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
Abstract algorithm.