Loading...
Searching...
No Matches
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#include "../raster/RasterSynchronizer.h"
33
34#include <boost/numeric/ublas/matrix.hpp>
35
36#include <vector>
37#include <string>
38#include <map>
39#include <memory>
40
41namespace te
42{
43 namespace rp
44 {
45 /*!
46 \class PCAFusion
47 \brief Fusion of a low-resolution multi-band image with a high resolution image using the PCA (Principal components analysis) method.
48 \details The PCA performs image fusion where the first principal component of the multi-spectral image is replaced by the histogram matched panchromatic imagery.
49 \note Reference: Tania Stathaki, "Image Fusion: Algorithms and Applications", Elsevier, First edition 2008.
50 \note This algorithm expects both images to be aligned over the same geographic region. No reprojection or crop operations are performed.
51 \ingroup rp_fus
52 */
54 {
55 public:
56
57 /*!
58 \class InputParameters
59 \brief PCAFusion input parameters
60 */
62 {
63 public:
64
65 /*!
66 \enum HRHistoFitMethod High resolution image histogram fitting method.
67 */
69 {
70 NoHistoFitMethod = 0, //!< No fitting performed method.
71 MeanStdDevHistoFitMethod = 1, //!< Fitting by using mean and Standard deviation.
72 MinMaxHistoFitMethod = 2, //!< Fitting by using the mininum and maximum values.
73 MeanStdDevHistoFitAndClipMethod = 3, //!< Fitting by using mean and Standard deviation and clipping to minimum and maximum values.
74 };
75
76 te::rst::Raster const* m_lowResRasterPtr; //!< Input low-resolution multi-band raster.
77
78 std::vector< unsigned int > m_lowResRasterBands; //!< The low-resolution raster band indexes.
79
80 te::rst::Raster const* m_highResRasterPtr; //!< Input high-resolution raster.
81
82 unsigned int m_highResRasterBand; //!< Band to process from the high-resolution raster.
83
84 bool m_enableProgress; //!< Enable/Disable the progress interface (default:false).
85
86 bool m_enableThreadedProcessing; //!< If true, threaded processing will be performed (best with multi-core or multi-processor systems (default:true).
87
88 te::rst::Interpolator::Method m_interpMethod; //!< The raster interpolator method (default:NearestNeighbor).
89
90 bool m_autoAlignRasters; //!< If true, the HR image will be clipped and reprojected to mach the LR image area.
91
92 HRHistoFitMethod m_hrHistoFitMethod; //!< High resolution image histogram fitting method (default: MeanStdDevHistoFitMethod).
93
94 boost::numeric::ublas::matrix< double > m_directPCAMatrix; //!< A valid direct transformation PCA matrix or an empty matrix (will be automcaticall calculated).
95
96 std::vector< double > m_outputNoDataValues; //!< A vector of output raster band no-data values or an empty vector to use low-resolution raster no-data values.
97
99
101
103
104 //overload
105 void reset() ;
106
107 //overload
109
110 //overload
111 AbstractParameters* clone() const;
112
113 //overload
114 bool serialize ( AlgorithmParametersSerializer& serializer ) const;
115 };
116
117 /*!
118 \class OutputParameters
119 \brief PCAFusion output parameters
120 */
122 {
123 public:
124
125 std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
126
127 std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the output rasters (as described in te::raster::RasterFactory).
128
129 std::unique_ptr< te::rst::Raster > m_outputRasterPtr; //!< The generated output fused raster.
130
131 boost::numeric::ublas::matrix< double > m_directPCAMatrix; //!< The calculated direct PCA transformation matrix.
132
134
136
138
139 //overload
140 void reset() ;
141
142 //overload
144
145 //overload
146 AbstractParameters* clone() const;
147 };
148
150
152
153 //overload
154 bool execute( AlgorithmOutputParameters& outputParams ) ;
155
156 //overload
157 void reset() ;
158
159 //overload
160 bool initialize( const AlgorithmInputParameters& inputParams ) ;
161
162 //overload
163 bool isInitialized() const;
164
165 protected:
166
168 {
173
174 // std::get< 0 > == processed = true / not processed = false
175 // std::get< 1 > == output block X
176 // std::get< 2 > == output block Y
177 std::vector< std::tuple< bool, unsigned int, unsigned int > >*
179
181 std::mutex* m_mutexPtr;
184 double m_gain;
187 };
188
189 InputParameters m_inputParameters; //!< Input execution parameters.
190
191 bool m_isInitialized; //!< Tells if this instance is initialized.
192
193 /*!
194 \brief Swap the band values by the normalized high resolution raster data.
195 \param highResRaster High resolution raster.
196 \param highResRaster High resolution raster.
197 \param pcaRaster The PCA raster.
198 \param pcaRasterBandIdx The band index where the values will be swapped.
199 \return true if ok, false on errors.
200 */
201 bool swapBandByHighResRaster( const te::rst::Raster& highResRaster,
202 const unsigned int highResRasterBand,
203 te::rst::Raster& pcaRaster, const unsigned int pcaRasterBandIdx );
204
206
207 };
208
209 } // end namespace rp
210} // end namespace te
211
212#endif
213
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
PCAFusion input parameters.
Definition PCAFusion.h:62
AbstractParameters * clone() const
Create a clone copy of this instance.
bool m_enableThreadedProcessing
If true, threaded processing will be performed (best with multi-core or multi-processor systems (defa...
Definition PCAFusion.h:86
bool m_autoAlignRasters
If true, the HR image will be clipped and reprojected to mach the LR image area.
Definition PCAFusion.h:90
std::vector< double > m_outputNoDataValues
A vector of output raster band no-data values or an empty vector to use low-resolution raster no-data...
Definition PCAFusion.h:96
const InputParameters & operator=(const InputParameters &params)
boost::numeric::ublas::matrix< double > m_directPCAMatrix
A valid direct transformation PCA matrix or an empty matrix (will be automcaticall calculated).
Definition PCAFusion.h:94
unsigned int m_highResRasterBand
Band to process from the high-resolution raster.
Definition PCAFusion.h:82
std::vector< unsigned int > m_lowResRasterBands
The low-resolution raster band indexes.
Definition PCAFusion.h:78
InputParameters(const InputParameters &)
bool serialize(AlgorithmParametersSerializer &serializer) const
Returns a parameter serialization object.
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition PCAFusion.h:84
HRHistoFitMethod m_hrHistoFitMethod
High resolution image histogram fitting method (default: MeanStdDevHistoFitMethod).
Definition PCAFusion.h:92
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition PCAFusion.h:88
te::rst::Raster const * m_lowResRasterPtr
Input low-resolution multi-band raster.
Definition PCAFusion.h:76
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::rst::Raster const * m_highResRasterPtr
Input high-resolution raster.
Definition PCAFusion.h:80
PCAFusion output parameters.
Definition PCAFusion.h:122
OutputParameters(const OutputParameters &)
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:127
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
The generated output fused raster.
Definition PCAFusion.h:129
const OutputParameters & operator=(const OutputParameters &params)
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition PCAFusion.h:125
AbstractParameters * clone() const
Create a clone copy of this instance.
boost::numeric::ublas::matrix< double > m_directPCAMatrix
The calculated direct PCA transformation matrix.
Definition PCAFusion.h:131
Fusion of a low-resolution multi-band image with a high resolution image using the PCA (Principal com...
Definition PCAFusion.h:54
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
bool m_isInitialized
Tells if this instance is initialized.
Definition PCAFusion.h:191
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
static void swapBandByHighResRasterThreadEntry(SwapBandByHighResRasterThreadParameters *paramsPtr)
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
bool swapBandByHighResRaster(const te::rst::Raster &highResRaster, const unsigned int highResRasterBand, te::rst::Raster &pcaRaster, const unsigned int pcaRasterBandIdx)
Swap the band values by the normalized high resolution raster data.
InputParameters m_inputParameters
Input execution parameters.
Definition PCAFusion.h:189
bool isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
An access synchronizer to be used in SynchronizedRaster raster instances.
An abstract class for raster data strucutures.
Definition Raster.h:72
InterpolationMethod
Allowed interpolation methods.
Definition Enums.h:93
TerraLib.
std::vector< std::tuple< bool, unsigned int, unsigned int > > * m_rasterBlocksStatusPtr
Definition PCAFusion.h:178
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition Config.h:139
Abstract algorithm.