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  /*!
129  \brief Returns all supported sensor types.
130  \param infos All supported sensor types.
131  */
132  static void getSupportedSensorTypes(
133  std::map< SensorType, std::string >& infos );
134 
135  /*!
136  \brief Returns all supported sampling factor types.
137  \param infos All supported sampling factor types.
138  */
139  static void getSupportedSamplingFactorsTypes(
140  std::map< SamplingFactorType, std::string >& infos );
141 
142  /*!
143  \brief Get Resolution sampling factor given the type.
144  \param sFactortype Sampling factor type.
145  \param resSamplingFactor Resolution sampling factor type.
146  \note Output_resolution = input_resolution * resSamplingFactor.
147  */
148  static void getResolutionSamplingFactor(
149  const InputParameters::SamplingFactorType& sFactortype,
150  double& resSamplingFactor );
151  };
152 
153  /*!
154  \class OutputParameters
155  \brief Restoration output parameters
156  */
158  {
159  public:
160 
161  std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
162 
163  std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the raster (as described in te::raster::RasterFactory).
164 
165  std::unique_ptr< te::rst::Raster > m_outputRasterPtr; //!< A pointer the ge generated output raster (label image).
166 
168 
170 
172 
173  //overload
174  void reset() _NOEXCEPT_OP(false);
175 
176  //overload
177  const OutputParameters& operator=( const OutputParameters& params );
178 
179  //overload
180  AbstractParameters* clone() const;
181  };
182 
184 
186 
187  //overload
188  bool execute( AlgorithmOutputParameters& outputParams ) _NOEXCEPT_OP(false);
189 
190  //overload
191  void reset() _NOEXCEPT_OP(false);
192 
193  //overload
194  bool initialize( const AlgorithmInputParameters& inputParams ) _NOEXCEPT_OP(false);
195 
196  //overload
197  bool isInitialized() const;
198 
199  protected:
200 
201  bool m_isInitialized; //!< Is this instance already initialized?
202 
203  Restoration::InputParameters m_inputParameters; //!< Input parameters.
204 
205  /*!
206  \brief Calculate the weights of the restoration filter in the vertical and horizontal directions.
207  \param bandDesignation Sensor band designation (starting from 1).
208  \param XCoefs X coeficients.
209  \param YCoefs Y coeficients.
210  \return true if OK, false on erros.
211  */
212  bool getFilterCoefs(
213  const unsigned int bandDesignation,
214  std::vector< double >& XCoefs,
215  std::vector< double >& YCoefs ) const;
216 
217  /*!
218  \brief Apply the restorafion filter on the input rasters.
219  \param bandsXCoefs X coeficients.
220  \param bandsYCoefs Y coeficients.
221  \param inputRaster Input raster.
222  \param outputRaster PrĂ©-initialized Output raster.
223  \return true if OK, false on erros.
224  */
225  bool applyFilterCoefs(
226  const std::vector< std::vector< double > >& bandsXCoefs,
227  const std::vector< std::vector< double > >& bandsYCoefs,
228  const te::rst::Raster& inputRaster,
229  te::rst::Raster& outputRaster );
230 
231  /*!
232  \brief Decompose sampling factor.
233  \param sFactortype Sampling factor type.
234  \param upperValue Upper value.
235  \param lowerValue Lower value.
236  \note SamplingFactor = ( upperValue / lowerValue ).
237  */
238  static void getDecomposedSamplingFactor(
239  const InputParameters::SamplingFactorType& sFactortype,
240  unsigned int& upperValue,
241  unsigned int& lowerValue );
242 
243  /*!
244  \brief Return the target filter size following the current sensor.
245  \return Return the target filter size following the current sensor.
246  */
247  unsigned int getFilterSize() const;
248 
249  };
250 
251  } // end namespace rp
252 } // end namespace te
253 
254 #endif // __TERRALIB_RP_INTERNAL_RESTORATION_H
255 
te::rp::Restoration::InputParameters::SAMPLING_FACTOR_1_BY_3
@ SAMPLING_FACTOR_1_BY_3
Definition: Restoration.h:90
te::rp::Restoration::InputParameters::MODIS_250
@ MODIS_250
Definition: Restoration.h:81
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rp::AlgorithmOutputParameters
Raster Processing algorithm output parameters base interface.
Definition: AlgorithmOutputParameters.h:40
te::rp::Restoration::InputParameters::SPOTX
@ SPOTX
Definition: Restoration.h:64
te::rp::Restoration::InputParameters::INVALID_RESTORATION_TYPE
@ INVALID_RESTORATION_TYPE
Definition: Restoration.h:62
te::rp::Restoration::InputParameters::CBERS_CCD
@ CBERS_CCD
Definition: Restoration.h:69
te::rp::Restoration::InputParameters::ETMX
@ ETMX
Definition: Restoration.h:66
te::rp::Restoration::OutputParameters
Restoration output parameters.
Definition: Restoration.h:158
te::rst::Raster
An abstract class for raster data strucutures.
Definition: Raster.h:72
te::rp::Restoration::InputParameters::InputParameters
InputParameters()
te::rp::Restoration::OutputParameters::OutputParameters
OutputParameters(const OutputParameters &)
te::rp::Restoration::InputParameters::TM
@ TM
Definition: Restoration.h:65
te::rp::AlgorithmInputParameters
Raster Processing algorithm input parameters base interface.
Definition: AlgorithmInputParameters.h:40
te::rp::Restoration::InputParameters::CBERS_4_WFI
@ CBERS_4_WFI
Definition: Restoration.h:77
te::rp::Restoration::InputParameters::ETMP
@ ETMP
Definition: Restoration.h:67
te::rp::Restoration::InputParameters::SAMPLING_FACTOR_2_BY_3
@ SAMPLING_FACTOR_2_BY_3
Definition: Restoration.h:94
te::rp::Restoration::InputParameters::QUICKBIRD
@ QUICKBIRD
Definition: Restoration.h:79
te::rp::Restoration::InputParameters::CBERS2_CCD
@ CBERS2_CCD
Definition: Restoration.h:71
_NOEXCEPT_OP
#define _NOEXCEPT_OP(x)
Definition: NoExceptDefinition.h:36
te::rp::Restoration::InputParameters::m_enableProgress
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: Restoration.h:109
te::rp::Restoration::OutputParameters::~OutputParameters
~OutputParameters()
te::rp::Restoration::InputParameters::m_enableRasterCache
bool m_enableRasterCache
Enable/Disable the use of a raster data cache (default:true).
Definition: Restoration.h:111
te::rp::Restoration
This class implements the combining interpolation and restoration operation.
Definition: Restoration.h:48
te::rp::Restoration::InputParameters::LANDSAT_8
@ LANDSAT_8
Definition: Restoration.h:68
te::rp::Restoration::InputParameters::CBERS_CCRX
@ CBERS_CCRX
Definition: Restoration.h:70
te::rp::Restoration::InputParameters::m_samplingFactor
SamplingFactorType m_samplingFactor
The samnpling factor.
Definition: Restoration.h:107
te::rp::Algorithm
Raster Processing algorithm base interface.
Definition: Algorithm.h:42
te::rp::Restoration::InputParameters::reset
void reset() _NOEXCEPT_OP(false)
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::rp::Restoration::InputParameters::CBERS_4_PAN5
@ CBERS_4_PAN5
Definition: Restoration.h:76
te::rp::Restoration::InputParameters::CBERS_4_PAN10
@ CBERS_4_PAN10
Definition: Restoration.h:75
te::rp::Restoration::InputParameters::SAMPLING_FACTOR_1_BY_2
@ SAMPLING_FACTOR_1_BY_2
Definition: Restoration.h:89
te::rp::Restoration::InputParameters::CBERS2B_CCD
@ CBERS2B_CCD
Definition: Restoration.h:72
te::rp::Restoration::InputParameters::SAMPLING_FACTOR_1_BY_6
@ SAMPLING_FACTOR_1_BY_6
Definition: Restoration.h:93
te::rp::Restoration::InputParameters::CBERS2B_HRC
@ CBERS2B_HRC
Definition: Restoration.h:73
te::rp::Restoration::InputParameters::SamplingFactorType
SamplingFactorType
Definition: Restoration.h:87
te::rp::Restoration::InputParameters::RAPIDEYE
@ RAPIDEYE
Definition: Restoration.h:78
te::rp::Restoration::InputParameters::WORLDVIEW2
@ WORLDVIEW2
Definition: Restoration.h:80
te::rp::Restoration::OutputParameters::m_outputRasterPtr
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
A pointer the ge generated output raster (label image).
Definition: Restoration.h:165
te::rp::Restoration::OutputParameters::reset
void reset() _NOEXCEPT_OP(false)
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::rp::Restoration::InputParameters::m_inRasterBands
std::vector< unsigned int > m_inRasterBands
Bands to be used from the input raster (starting from zero).
Definition: Restoration.h:105
te::rp::Restoration::OutputParameters::m_rType
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: Restoration.h:161
te::rp::Restoration::InputParameters::INVALID_SAMPLING_FACTOR_TYPE
@ INVALID_SAMPLING_FACTOR_TYPE
Definition: Restoration.h:88
te::rp::Restoration::InputParameters::SAMPLING_FACTOR_1_BY_5
@ SAMPLING_FACTOR_1_BY_5
Definition: Restoration.h:92
te::rp::Restoration::InputParameters
Restoration input parameters.
Definition: Restoration.h:56
te::rp::Restoration::InputParameters::m_sensorType
SensorType m_sensorType
The sensor type.
Definition: Restoration.h:99
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::Restoration::InputParameters::SAMPLING_FACTOR_1_BY_4
@ SAMPLING_FACTOR_1_BY_4
Definition: Restoration.h:91
te::rp::Restoration::InputParameters::CBERS_4_MUX
@ CBERS_4_MUX
Definition: Restoration.h:74
te::rp::Restoration::OutputParameters::OutputParameters
OutputParameters()
te::rp::Restoration::InputParameters::SPOTP
@ SPOTP
Definition: Restoration.h:63
te::rp::Restoration::InputParameters::~InputParameters
~InputParameters()
Algorithm.h
Abstract algorithm.
te::rp::Restoration::InputParameters::InputParameters
InputParameters(const InputParameters &)
te::rp::Restoration::InputParameters::SensorType
SensorType
Definition: Restoration.h:61
te::rp::Restoration::InputParameters::m_inRasterPtr
te::rst::Raster const * m_inRasterPtr
Input raster.
Definition: Restoration.h:103
te::rp::Restoration::InputParameters::m_sensorBandDesignations
std::vector< unsigned int > m_sensorBandDesignations
Sensor band designations (starting from 1).
Definition: Restoration.h:101
te::rp::Restoration::OutputParameters::m_rInfo
std::map< std::string, std::string > m_rInfo
The necessary information to create the raster (as described in te::raster::RasterFactory).
Definition: Restoration.h:163