PCAFusion.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/PCAFusion.h
22  \brief Creation of skeleton imagems.
23  */
24 
25 #ifndef __TERRALIB_RP_INTERNAL_PCAFUSION_H
26 #define __TERRALIB_RP_INTERNAL_PCAFUSION_H
27 
28 #include "Algorithm.h"
29 #include "../raster/Raster.h"
30 #include "../raster/Band.h"
31 #include "../raster/Interpolator.h"
32 
33 #include <vector>
34 #include <string>
35 #include <map>
36 #include <memory>
37 
38 namespace te
39 {
40  namespace rp
41  {
42  /*!
43  \class PCAFusion
44  \brief Fusion of a low-resolution multi-band image with a high resolution image using the PCA (Principal components analysis) method.
45  \details The PCA performs image fusion where the first principal component of the multi-spectral image is replaced by the histogram matched panchromatic imagery.
46  \note Reference: Tania Stathaki, "Image Fusion: Algorithms and Applications", Elsevier, First edition 2008.
47  \note This algorithm expects both images to be aligned over the same geographic region. No reprojection or crop operations are performed.
48  \ingroup rp_fus
49  */
51  {
52  public:
53 
54  /*!
55  \class InputParameters
56  \brief PCAFusion input parameters
57  */
59  {
60  public:
61 
62  te::rst::Raster const* m_lowResRasterPtr; //!< Input low-resolution multi-band raster.
63 
64  std::vector< unsigned int > m_lowResRasterBands; //!< The low-resolution raster band indexes.
65 
66  te::rst::Raster const* m_highResRasterPtr; //!< Input high-resolution raster.
67 
68  unsigned int m_highResRasterBand; //!< Band to process from the high-resolution raster.
69 
70  bool m_enableProgress; //!< Enable/Disable the progress interface (default:false).
71 
72  bool m_enableThreadedProcessing; //!< If true, threaded processing will be performed (best with multi-core or multi-processor systems (default:true).
73 
74  te::rst::Interpolator::Method m_interpMethod; //!< The raster interpolator method (default:NearestNeighbor).
75 
76  bool m_autoAlignRasters; //!< If true, the HR image will be clipped and reprojected to mach the LR image area.
77 
79 
81 
83 
84  //overload
85  void reset() throw( te::rp::Exception );
86 
87  //overload
88  const InputParameters& operator=( const InputParameters& params );
89 
90  //overload
91  AbstractParameters* clone() const;
92  };
93 
94  /*!
95  \class OutputParameters
96  \brief PCAFusion output parameters
97  */
99  {
100  public:
101 
102  std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
103 
104  std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the output rasters (as described in te::raster::RasterFactory).
105 
106  std::unique_ptr< te::rst::Raster > m_outputRasterPtr; //!< The generated output fused raster.
107 
109 
111 
113 
114  //overload
115  void reset() throw( te::rp::Exception );
116 
117  //overload
118  const OutputParameters& operator=( const OutputParameters& params );
119 
120  //overload
121  AbstractParameters* clone() const;
122  };
123 
125 
127 
128  //overload
129  bool execute( AlgorithmOutputParameters& outputParams ) throw( te::rp::Exception );
130 
131  //overload
132  void reset() throw( te::rp::Exception );
133 
134  //overload
135  bool initialize( const AlgorithmInputParameters& inputParams ) throw( te::rp::Exception );
136 
137  //overload
138  bool isInitialized() const;
139 
140  protected:
141 
142  InputParameters m_inputParameters; //!< Input execution parameters.
143 
144  bool m_isInitialized; //!< Tells if this instance is initialized.
145 
146  /*!
147  \brief Load resampled data from the input image.
148  \param highResRaster High resolution raster.
149  \param ressampledRasterPtr The loaded and ressampled raster data.
150  \return true if ok, false on errors.
151  */
152  bool loadRessampledRaster( const te::rst::Raster& highResRaster,
153  std::unique_ptr< te::rst::Raster >& ressampledRasterPtr ) const;
154 
155  /*!
156  \brief Swap the band values by the normalized high resolution raster data.
157  \param highResRaster High resolution raster.
158  \param pcaRaster The PCA raster.
159  \param pcaRasterBandIdx The band index where the values will be swapped.
160  \return true if ok, false on errors.
161  */
162  bool swapBandByHighResRaster( const te::rst::Raster& highResRaster,
163  te::rst::Raster& pcaRaster, const unsigned int pcaRasterBandIdx );
164 
165  };
166 
167  } // end namespace rp
168 } // end namespace te
169 
170 #endif
171 
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rp::AlgorithmOutputParameters
Raster Processing algorithm output parameters base interface.
Definition: AlgorithmOutputParameters.h:40
te::rp::PCAFusion::InputParameters
PCAFusion input parameters.
Definition: PCAFusion.h:59
te::rp::PCAFusion::OutputParameters::reset
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::rp::PCAFusion::OutputParameters::m_rType
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: PCAFusion.h:102
te::rst::Raster
An abstract class for raster data strucutures.
Definition: Raster.h:72
te::rp::AlgorithmInputParameters
Raster Processing algorithm input parameters base interface.
Definition: AlgorithmInputParameters.h:40
te::rp::PCAFusion::OutputParameters
PCAFusion output parameters.
Definition: PCAFusion.h:99
te::rp::PCAFusion::InputParameters::m_lowResRasterPtr
te::rst::Raster const * m_lowResRasterPtr
Input low-resolution multi-band raster.
Definition: PCAFusion.h:62
te::rp::PCAFusion::OutputParameters::m_outputRasterPtr
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
The generated output fused raster.
Definition: PCAFusion.h:106
te::rp::PCAFusion
Fusion of a low-resolution multi-band image with a high resolution image using the PCA (Principal com...
Definition: PCAFusion.h:51
te::rp::PCAFusion::OutputParameters::~OutputParameters
~OutputParameters()
te::rp::PCAFusion::InputParameters::m_highResRasterPtr
te::rst::Raster const * m_highResRasterPtr
Input high-resolution raster.
Definition: PCAFusion.h:66
te::rp::PCAFusion::InputParameters::~InputParameters
~InputParameters()
te::rp::Algorithm
Raster Processing algorithm base interface.
Definition: Algorithm.h:42
te::rp::PCAFusion::InputParameters::m_interpMethod
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: PCAFusion.h:74
te::rst::InterpolationMethod
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:93
te::rp::PCAFusion::OutputParameters::OutputParameters
OutputParameters()
te::Exception
Base exception class for plugin module.
Definition: Exception.h:42
te::rp::PCAFusion::InputParameters::reset
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
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::PCAFusion::InputParameters::InputParameters
InputParameters()
te::rp::PCAFusion::InputParameters::InputParameters
InputParameters(const InputParameters &)
te::rp::PCAFusion::OutputParameters::OutputParameters
OutputParameters(const OutputParameters &)
te::rp::PCAFusion::OutputParameters::m_rInfo
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
Definition: PCAFusion.h:104
te::rp::PCAFusion::InputParameters::m_lowResRasterBands
std::vector< unsigned int > m_lowResRasterBands
The low-resolution raster band indexes.
Definition: PCAFusion.h:64
Algorithm.h
Abstract algorithm.
te::rp::PCAFusion::InputParameters::m_highResRasterBand
unsigned int m_highResRasterBand
Band to process from the high-resolution raster.
Definition: PCAFusion.h:68
te::rp::PCAFusion::InputParameters::m_enableProgress
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: PCAFusion.h:70
te::rp::PCAFusion::InputParameters::m_enableThreadedProcessing
bool m_enableThreadedProcessing
If true, threaded processing will be performed (best with multi-core or multi-processor systems (defa...
Definition: PCAFusion.h:72
te::rp::PCAFusion::InputParameters::m_autoAlignRasters
bool m_autoAlignRasters
If true, the HR image will be clipped and reprojected to mach the LR image area.
Definition: PCAFusion.h:76