All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IHSFusion.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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/IHSFusion.h
22  \brief Creation of skeleton imagems.
23  */
24 
25 #ifndef __TERRALIB_RP_INTERNAL_IHSFUSION_H
26 #define __TERRALIB_RP_INTERNAL_IHSFUSION_H
27 
28 #include "Algorithm.h"
29 #include "Matrix.h"
30 #include "../raster/Raster.h"
31 #include "../raster/Interpolator.h"
32 
33 #include <vector>
34 #include <string>
35 #include <map>
36 
37 namespace te
38 {
39  namespace rp
40  {
41  /*!
42  \class IHSFusion
43 
44  \brief Fusion of a low-resolution multi-band image with a high resolution image using the IHS method.
45 
46  \details The IHS is one of the widespread image fusion methods in the remote sensing community and has been employed as a standard procedure in many commercial packages; IHS is the intrinsic method when the intensity channel is replaced by the high-resolution Pan image.
47 
48  \reference Te-Ming Tu, Shun-Chi Su, Hsuen-Chyun Shyu, Ping S. Huang, A new look at IHS-like image fusion methods, Information Fusion, Volume 2, Issue 3, September 2001, Pages 177-186, ISSN 1566-2535.
49 
50  \reference W.J. Carper, T.M. Lillesand, R.W. Kiefer, The use of intensity-hue-saturation transformations for merging SPOT panchromatic and multispectral image data Photogramm. Eng. Remote Sensing, 56 (1990), pp. 459–467.
51 
52  \ingroup rp
53  */
55  {
56  public:
57 
58  /*!
59  \class InputParameters
60  \brief IHSFusion input parameters
61  */
63  {
64  public:
65 
66  te::rst::Raster const* m_lowResRasterPtr; //!< Input low-resolution multi-band raster.
67 
68  unsigned int m_lowResRasterRedBandIndex; //!< The low-resolution raster red band index (default:0).
69 
70  unsigned int m_lowResRasterGreenBandIndex; //!< The low-resolution raster green band index (default:1).
71 
72  unsigned int m_lowResRasterBlueBandIndex; //!< The low-resolution raster blue band index (default:2).
73 
74  te::rst::Raster const* m_highResRasterPtr; //!< Input high-resolution raster.
75 
76  unsigned int m_highResRasterBand; //!< Band to process from the high-resolution raster.
77 
78  bool m_enableProgress; //!< Enable/Disable the progress interface (default:false).
79 
80  te::rst::Interpolator::Method m_interpMethod; //!< The raster interpolator method (default:NearestNeighbor).
81 
82  double m_RGBMin; //!< The used RGB minimum value (default:0 - leave zero for automatic detection based on the input images).
83 
84  double m_RGBMax; //!< The used RGB maximum value (default:0 - leave zero for automatic detection based on the input images).
85 
87 
89 
90  ~InputParameters();
91 
92  //overload
93  void reset() throw( te::rp::Exception );
94 
95  //overload
96  const InputParameters& operator=( const InputParameters& params );
97 
98  //overload
99  AbstractParameters* clone() const;
100  };
101 
102  /*!
103  \class OutputParameters
104  \brief IHSFusion output parameters
105  */
107  {
108  public:
109 
110  std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
111 
112  std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the output rasters (as described in te::raster::RasterFactory).
113 
114  std::auto_ptr< te::rst::Raster > m_outputRasterPtr; //!< The generated output fused raster.
115 
117 
119 
120  ~OutputParameters();
121 
122  //overload
123  void reset() throw( te::rp::Exception );
124 
125  //overload
126  const OutputParameters& operator=( const OutputParameters& params );
127 
128  //overload
129  AbstractParameters* clone() const;
130  };
131 
132  IHSFusion();
133 
134  ~IHSFusion();
135 
136  //overload
137  bool execute( AlgorithmOutputParameters& outputParams ) throw( te::rp::Exception );
138 
139  //overload
140  void reset() throw( te::rp::Exception );
141 
142  //overload
143  bool initialize( const AlgorithmInputParameters& inputParams ) throw( te::rp::Exception );
144 
145  //overload
146  bool isInitialized() const;
147 
148  protected:
149 
150  InputParameters m_inputParameters; //!< Input execution parameters.
151 
152  bool m_isInitialized; //!< Tells if this instance is initialized.
153 
154  /*!
155  \brief Get the minimum and maximum values from the RGB input image.
156  \param rgbMin RGB minimum value.
157  \param rgbMax RGB maximum value.
158  \return true if ok, false on errors.
159  */
160  bool getRGBRange( double& rgbMin, double& rgbMax ) const;
161 
162  /*!
163  \brief Get statistics from the given matrix.
164  \param matrix Input matrix.
165  \param mean Mean value.
166  \param variance Variance value.
167  \return true if ok, false on errors.
168  */
169  bool getStatistics( const te::rp::Matrix< float >& matrix, float& mean,
170  float& variance ) const;
171 
172  /*!
173  \brief Load resampled IHS data from the input image.
174  \param rgbMin RGB minimum value.
175  \param rgbMax RGB maximum value.
176  \param intensityData Intensity channel data.
177  \param hueData Hue channel data.
178  \param saturationData Saturation channel data.
179  \return true if ok, false on errors.
180  \note IHS data with the following channels ranges: I:[0,1] H:[0,2pi] (radians) S:[0,1].
181  */
182  bool loadIHSData( const double& rgbMin, const double rgbMax, te::rp::Matrix< float >& intensityData,
183  te::rp::Matrix< float >& hueData, te::rp::Matrix< float >& saturationData ) const;
184 
185  /*!
186  \brief Swap the intensity data by the high resolution image data.
187  \param intensityData Intensity channel data.
188  \return true if ok, false on errors.
189  */
190  bool swapIntensity( te::rp::Matrix< float >& intensityData );
191 
192  /*!
193  \brief Save resampled IHS data as RGB data to the output image.
194  \param rgbMin RGB minimum value.
195  \param rgbMax RGB maximum value.
196  \param intensityData Intensity channel data.
197  \param hueData Hue channel data.
198  \param saturationData Saturation channel data.
199  \return true if ok, false on errors.
200  */
201  bool saveIHSData( const double& rgbMin, const double rgbMax, const te::rp::Matrix< float >& intensityData,
202  const te::rp::Matrix< float >& hueData, const te::rp::Matrix< float >& saturationData,
203  const std::string& rType, const std::map< std::string, std::string >& rInfo,
204  std::auto_ptr< te::rst::Raster >& outputRasterPtr ) const;
205  };
206 
207  } // end namespace rp
208 } // end namespace te
209 
210 #endif
211 
Generic template matrix.
Raster Processing algorithm base interface class.
unsigned int m_lowResRasterRedBandIndex
The low-resolution raster red band index (default:0).
Definition: IHSFusion.h:68
Raster Processing algorithm base interface.
Definition: Algorithm.h:42
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: IHSFusion.h:78
Fusion of a low-resolution multi-band image with a high resolution image using the IHS method...
Definition: IHSFusion.h:54
Method
Allowed interpolation methods.
Definition: Interpolator.h:58
std::auto_ptr< te::rst::Raster > m_outputRasterPtr
The generated output fused raster.
Definition: IHSFusion.h:114
double m_RGBMax
The used RGB maximum value (default:0 - leave zero for automatic detection based on the input images)...
Definition: IHSFusion.h:84
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: IHSFusion.h:110
te::rst::Raster const * m_lowResRasterPtr
Input low-resolution multi-band raster.
Definition: IHSFusion.h:66
IHSFusion input parameters.
Definition: IHSFusion.h:62
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
Definition: IHSFusion.h:112
A generic template matrix.
Definition: Matrix.h:50
unsigned int m_lowResRasterGreenBandIndex
The low-resolution raster green band index (default:1).
Definition: IHSFusion.h:70
Raster Processing algorithm output parameters base interface.
unsigned int m_highResRasterBand
Band to process from the high-resolution raster.
Definition: IHSFusion.h:76
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: IHSFusion.h:80
An abstract class for raster data strucutures.
Definition: Raster.h:70
te::rst::Raster const * m_highResRasterPtr
Input high-resolution raster.
Definition: IHSFusion.h:74
IHSFusion output parameters.
Definition: IHSFusion.h:106
double m_RGBMin
The used RGB minimum value (default:0 - leave zero for automatic detection based on the input images)...
Definition: IHSFusion.h:82
unsigned int m_lowResRasterBlueBandIndex
The low-resolution raster blue band index (default:2).
Definition: IHSFusion.h:72
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:91
Raster Processing algorithm input parameters base interface.