SequenceMosaic.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/SequenceMosaic.h
22  \brief Create mosaics from a sequence of overlapped rasters using an automatic tie-points detection method.
23  */
24 
25 #ifndef __TERRALIB_RP_INTERNAL_SEQUENCEMOSAIC_H
26 #define __TERRALIB_RP_INTERNAL_SEQUENCEMOSAIC_H
27 
28 #include "Algorithm.h"
29 #include "FeedersRaster.h"
30 #include "Blender.h"
31 #include "TiePointsLocator.h"
32 #include "../raster/Interpolator.h"
33 #include "../dataaccess/datasource/DataSource.h"
34 #include "../geometry/GTParameters.h"
35 
36 #include <vector>
37 #include <string>
38 
39 namespace te
40 {
41  namespace rp
42  {
43  /*!
44  \class SequenceMosaic
45  \brief Create mosaics from a sequence of overlapped rasters using an automatic tie-points detection method.
46  \note When the tie-points detection fails, a new mosaic sequence is generated.
47  \note Each mosaic sequence takes the first raster (of each sequence) as reference for resolution, SRS and equalization parameters.
48  \ingroup rp_mos
49  */
51  {
52  public:
53 
54  /*!
55  \class InputParameters
56  \brief Mosaic input parameters
57  */
59  {
60  public:
61 
62  FeederConstRaster* m_feederRasterPtr; //!< Input rasters feeder.
63 
64  std::vector< std::vector< unsigned int > > m_inputRastersBands; //!< Bands to process for each input raster.
65 
66  std::string m_geomTransfName; //!< The name of the geometric transformation used if tie-points are supplied (see each te::gm::GTFactory inherited classes to find each factory key/name, default:Affine).
67 
68  te::rst::Interpolator::Method m_interpMethod; //!< The raster interpolator method (default:NearestNeighbor).
69 
70  double m_noDataValue; //!< The pixel value used where no raster data is avaliable (defaul:0).
71 
72  bool m_forceInputNoDataValue; //!< If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
73 
74  te::rp::Blender::BlendMethod m_blendMethod; //!< The pixel blending method (default: NoBlendMethod).
75 
76  bool m_autoEqualize; //!< Auto equalization will be performed using the overlaped image areas (default:true).
77 
78  bool m_useRasterCache; //!< Enable(true) or disable the use of raster caching (default:true).
79 
80  bool m_enableMultiThread; //!< Enable/Disable the use of multi-threads (default:true).
81 
82  bool m_enableProgress; //!< Enable/Disable the progress interface (default:false).
83 
84  unsigned int m_tiePointsLocationBandIndex; //!< The band used to locate tie-points, this is the index inside each vector of m_inputRastersBands (defaul:0).
85 
86  std::string m_outDataSetsNamePrefix; //!< The raster output data sets names prefix.
87 
88  std::string m_outDataSetsNameSufix; //!< The raster output data sets names sufix.
89 
90  double m_minRequiredTiePointsCoveredAreaPercent; //!< The mininumum required tie-points covered area percent of each raster area - valid range [0,100] (default:25).
91 
92  te::rp::TiePointsLocator::InputParameters m_locatorParams; //!< The parameters used by the tie-points locator when processing each rasters pair (leave untouched to use the default).
93 
94  bool m_enableAutoValidAreaDetect; //!< Enable/disable the auto-detection of raster valid area pixels (this option allows better mosaic result for rasters with no-data pixels on borders. Default:true).
95 
97 
99 
101 
102  //overload
103  void reset() ;
104 
105  //overload
106  const InputParameters& operator=( const InputParameters& params );
107 
108  //overload
109  AbstractParameters* clone() const;
110 
111  //overload
112  bool serialize ( AlgorithmParametersSerializer& serializer ) const;
113  };
114 
115  /*!
116  \class MosaicSequenceInfo
117  \brief Mosaic sequence info.
118  */
120  {
121  public:
122 
123  std::string m_dataSetName; //!< The generated data set name for this mosaic sequence.
124 
125  std::vector< unsigned int > m_rasterFeederIndexes; //!< The indexes (inside the input rasters feeder) of the rasters written to this mosaic sequence.
126 
127  std::vector< std::vector< te::gm::GTParameters::TiePoint > > m_tiePoints; //!< The generated tie-pionts (te::gm::GTParameters::TiePoint::first are mosaic coods, te::gm::GTParameters::TiePoint::second are the used input raster line/column indexes).
128 
129  void clear(); //!< Clear the internal allocated resources.
130 
132 
134  };
135 
136  /*!
137  \class OutputParameters
138  \brief Mosaic output parameters
139  */
141  {
142  public:
143 
144  std::vector< MosaicSequenceInfo > m_sequencesInfo; //! The mosaic sequences info.
145 
146  te::da::DataSource* m_outputDSPtr; //!< The output data source where the mosaic rasters will be created.
147 
149 
151 
153 
154  //overload
155  void reset() ;
156 
157  //overload
158  const OutputParameters& operator=( const OutputParameters& params );
159 
160  //overload
161  AbstractParameters* clone() const;
162  };
163 
165 
167 
168  //overload
169  bool execute( AlgorithmOutputParameters& outputParams ) ;
170 
171  //overload
172  void reset() ;
173 
174  //overload
175  bool initialize( const AlgorithmInputParameters& inputParams ) ;
176 
177  bool isInitialized() const;
178 
179  protected:
180 
181  SequenceMosaic::InputParameters m_inputParameters; //!< Input execution parameters.
182 
183  bool m_isInitialized; //!< Tells if this instance is initialized.
184 
185  /*!
186  \brief Raster band statistics calcule.
187  \param raster Input raster
188  \param bandIndex Input raster band index.
189  \param forceNoDataValue Force the noDataValue to be used as the band no-data value.
190  \param noDataValue The no-data value to use.
191  \param mean Pixels mean.
192  \param variance Pixels variance.
193  \return true if ok, false on errors.
194  */
195  bool calcBandStatistics( const te::rst::Raster& raster,
196  const unsigned int bandIndex,
197  const bool& forceNoDataValue,
198  const double& noDataValue,
199  double& mean,
200  double& variance );
201 
202  /*!
203  \brief Create a raster data set from the given raster.
204 
205  \param dataSetName The data set name.
206 
207  \param sourceRaster The source raster.
208 
209  \param dataSourcePtr The output data source pointer.
210 
211  \return true if OK, false on errors.
212  */
213  bool createRasterDataSet( const std::string& dataSetName,
214  const te::rst::Raster& sourceRaster, te::da::DataSource* dataSourcePtr ) const;
215 
216  /*!
217  \brief Create copy of the given raster into a disk file.
218 
219  \param fileName The disk file name.
220 
221  \param sourceRaster The source raster.
222 
223  \return true if OK, false on errors.
224  */
225  bool createDiskRasterCopy( const std::string& fileName,
226  const te::rst::Raster& sourceRaster );
227 
228  };
229 
230  } // end namespace rp
231 } // end namespace te
232 
233 #endif
234 
Blended pixel value calculation for two overlaped rasters.
Raster objects feeders.
An abstract class for data providers like a DBMS, Web Services or a regular file.
Definition: DataSource.h:120
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
Feeder from a input rasters.
Definition: FeedersRaster.h:47
bool m_enableAutoValidAreaDetect
Enable/disable the auto-detection of raster valid area pixels (this option allows better mosaic resul...
bool m_enableMultiThread
Enable/Disable the use of multi-threads (default:true).
double m_minRequiredTiePointsCoveredAreaPercent
The mininumum required tie-points covered area percent of each raster area - valid range [0,...
unsigned int m_tiePointsLocationBandIndex
The band used to locate tie-points, this is the index inside each vector of m_inputRastersBands (defa...
bool m_autoEqualize
Auto equalization will be performed using the overlaped image areas (default:true).
FeederConstRaster * m_feederRasterPtr
Input rasters feeder.
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
const InputParameters & operator=(const InputParameters &params)
bool m_useRasterCache
Enable(true) or disable the use of raster caching (default:true).
double m_noDataValue
The pixel value used where no raster data is avaliable (defaul:0).
std::vector< std::vector< unsigned int > > m_inputRastersBands
Bands to process for each input raster.
bool m_enableProgress
Enable/Disable the progress interface (default:false).
InputParameters(const InputParameters &)
std::string m_outDataSetsNameSufix
The raster output data sets names sufix.
std::string m_geomTransfName
The name of the geometric transformation used if tie-points are supplied (see each te::gm::GTFactory ...
std::string m_outDataSetsNamePrefix
The raster output data sets names prefix.
bool m_forceInputNoDataValue
If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
te::rp::Blender::BlendMethod m_blendMethod
The pixel blending method (default: NoBlendMethod).
te::rp::TiePointsLocator::InputParameters m_locatorParams
The parameters used by the tie-points locator when processing each rasters pair (leave untouched to u...
bool serialize(AlgorithmParametersSerializer &serializer) const
Returns a parameter serialization object.
AbstractParameters * clone() const
Create a clone copy of this instance.
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
void clear()
Clear the internal allocated resources.
std::string m_dataSetName
The generated data set name for this mosaic sequence.
std::vector< unsigned int > m_rasterFeederIndexes
The indexes (inside the input rasters feeder) of the rasters written to this mosaic sequence.
std::vector< std::vector< te::gm::GTParameters::TiePoint > > m_tiePoints
The generated tie-pionts (te::gm::GTParameters::TiePoint::first are mosaic coods, te::gm::GTParameter...
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
OutputParameters(const OutputParameters &)
const OutputParameters & operator=(const OutputParameters &params)
te::da::DataSource * m_outputDSPtr
The mosaic sequences info.
std::vector< MosaicSequenceInfo > m_sequencesInfo
AbstractParameters * clone() const
Create a clone copy of this instance.
Create mosaics from a sequence of overlapped rasters using an automatic tie-points detection method.
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
bool isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
bool calcBandStatistics(const te::rst::Raster &raster, const unsigned int bandIndex, const bool &forceNoDataValue, const double &noDataValue, double &mean, double &variance)
Raster band statistics calcule.
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
SequenceMosaic::InputParameters m_inputParameters
Input execution parameters.
bool createRasterDataSet(const std::string &dataSetName, const te::rst::Raster &sourceRaster, te::da::DataSource *dataSourcePtr) const
Create a raster data set from the given raster.
bool createDiskRasterCopy(const std::string &fileName, const te::rst::Raster &sourceRaster)
Create copy of the given raster into a disk file.
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
bool m_isInitialized
Tells if this instance is initialized.
An abstract class for raster data strucutures.
Definition: Raster.h:72
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:93
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.