IHSFusion.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/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  \note This algorithm expects both images to be aligned over the same geographic region. No reprojection or crop operations are performed.
49 
50  \note 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.
51 
52  \note 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.
53 
54  \ingroup rp_fus
55  */
57  {
58  public:
59 
60  /*!
61  \class InputParameters
62  \brief IHSFusion input parameters
63  */
65  {
66  public:
67 
68  te::rst::Raster const* m_lowResRasterPtr; //!< Input low-resolution multi-band raster.
69 
70  unsigned int m_lowResRasterRedBandIndex; //!< The low-resolution raster red band index (default:0).
71 
72  unsigned int m_lowResRasterGreenBandIndex; //!< The low-resolution raster green band index (default:1).
73 
74  unsigned int m_lowResRasterBlueBandIndex; //!< The low-resolution raster blue band index (default:2).
75 
76  te::rst::Raster const* m_highResRasterPtr; //!< Input high-resolution raster.
77 
78  unsigned int m_highResRasterBand; //!< Band to process from the high-resolution raster.
79 
80  bool m_enableProgress; //!< Enable/Disable the progress interface (default:false).
81 
82  te::rst::Interpolator::Method m_interpMethod; //!< The raster interpolator method (default:NearestNeighbor).
83 
84  double m_RGBMin; //!< The used RGB minimum value (default:0 - leave zero for automatic detection based on the input images).
85 
86  double m_RGBMax; //!< The used RGB maximum value (default:0 - leave zero for automatic detection based on the input images).
87 
89 
91 
92  ~InputParameters();
93 
94  //overload
95  void reset() throw( te::rp::Exception );
96 
97  //overload
98  const InputParameters& operator=( const InputParameters& params );
99 
100  //overload
101  AbstractParameters* clone() const;
102  };
103 
104  /*!
105  \class OutputParameters
106  \brief IHSFusion output parameters
107  */
109  {
110  public:
111 
112  std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
113 
114  std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the output rasters (as described in te::raster::RasterFactory).
115 
116  std::auto_ptr< te::rst::Raster > m_outputRasterPtr; //!< The generated output fused raster.
117 
119 
121 
122  ~OutputParameters();
123 
124  //overload
125  void reset() throw( te::rp::Exception );
126 
127  //overload
128  const OutputParameters& operator=( const OutputParameters& params );
129 
130  //overload
131  AbstractParameters* clone() const;
132  };
133 
134  IHSFusion();
135 
136  ~IHSFusion();
137 
138  //overload
139  bool execute( AlgorithmOutputParameters& outputParams ) throw( te::rp::Exception );
140 
141  //overload
142  void reset() throw( te::rp::Exception );
143 
144  //overload
145  bool initialize( const AlgorithmInputParameters& inputParams ) throw( te::rp::Exception );
146 
147  //overload
148  bool isInitialized() const;
149 
150  protected:
151 
152  InputParameters m_inputParameters; //!< Input execution parameters.
153 
154  bool m_isInitialized; //!< Tells if this instance is initialized.
155 
156  /*!
157  \brief Get the minimum and maximum values from the RGB input image.
158  \param rgbMin RGB minimum value.
159  \param rgbMax RGB maximum value.
160  \return true if ok, false on errors.
161  */
162  bool getRGBRange( double& rgbMin, double& rgbMax ) const;
163 
164  /*!
165  \brief Get statistics from the given matrix.
166  \param matrix Input matrix.
167  \param mean Mean value.
168  \param variance Variance value.
169  \return true if ok, false on errors.
170  */
171  bool getStatistics( const te::rp::Matrix< float >& matrix, float& mean,
172  float& variance ) const;
173 
174  /*!
175  \brief Load resampled IHS data from the input image.
176  \param rgbMin RGB minimum value.
177  \param rgbMax RGB maximum value.
178  \param intensityData Intensity channel data.
179  \param hueData Hue channel data.
180  \param saturationData Saturation channel data.
181  \return true if ok, false on errors.
182  \note IHS data with the following channels ranges: I:[0,1] H:[0,2pi] (radians) S:[0,1].
183  */
184  bool loadIHSData( const double& rgbMin, const double rgbMax, te::rp::Matrix< float >& intensityData,
185  te::rp::Matrix< float >& hueData, te::rp::Matrix< float >& saturationData ) const;
186 
187  /*!
188  \brief Swap the intensity data by the high resolution image data.
189  \param intensityData Intensity channel data.
190  \return true if ok, false on errors.
191  */
192  bool swapIntensity( te::rp::Matrix< float >& intensityData );
193 
194  /*!
195  \brief Save resampled IHS data as RGB data to the output image.
196  \param rgbMin RGB minimum value.
197  \param rgbMax RGB maximum value.
198  \param intensityData Intensity channel data.
199  \param hueData Hue channel data.
200  \param saturationData Saturation channel data.
201  \return true if ok, false on errors.
202  */
203  bool saveIHSData( const double& rgbMin, const double rgbMax, const te::rp::Matrix< float >& intensityData,
204  const te::rp::Matrix< float >& hueData, const te::rp::Matrix< float >& saturationData,
205  const std::string& rType, const std::map< std::string, std::string >& rInfo,
206  std::auto_ptr< te::rst::Raster >& outputRasterPtr ) const;
207  };
208 
209  } // end namespace rp
210 } // end namespace te
211 
212 #endif
213 
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:114
double m_RGBMin
The used RGB minimum 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:112
Fusion of a low-resolution multi-band image with a high resolution image using the IHS method...
Definition: IHSFusion.h:56
std::auto_ptr< te::rst::Raster > m_outputRasterPtr
The generated output fused raster.
Definition: IHSFusion.h:116
Base exception class for plugin module.
Definition: Exception.h:42
IHSFusion output parameters.
Definition: IHSFusion.h:108
IHSFusion input parameters.
Definition: IHSFusion.h:64
Raster Processing algorithm output parameters base interface.
unsigned int m_lowResRasterRedBandIndex
The low-resolution raster red band index (default:0).
Definition: IHSFusion.h:70
Raster Processing algorithm base interface class.
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:92
unsigned int m_highResRasterBand
Band to process from the high-resolution raster.
Definition: IHSFusion.h:78
Raster Processing algorithm base interface.
Definition: Algorithm.h:41
double m_RGBMax
The used RGB maximum value (default:0 - leave zero for automatic detection based on the input images)...
Definition: IHSFusion.h:86
An abstract class for raster data strucutures.
Definition: Raster.h:71
URI C++ Library.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
unsigned int m_lowResRasterBlueBandIndex
The low-resolution raster blue band index (default:2).
Definition: IHSFusion.h:74
Generic template matrix.
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: IHSFusion.h:80
A generic template matrix.
Definition: Matrix.h:51
Raster Processing algorithm input parameters base interface.
te::rst::Raster const * m_highResRasterPtr
Input high-resolution raster.
Definition: IHSFusion.h:76
te::rst::Raster const * m_lowResRasterPtr
Input low-resolution multi-band raster.
Definition: IHSFusion.h:68
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: IHSFusion.h:82
unsigned int m_lowResRasterGreenBandIndex
The low-resolution raster green band index (default:1).
Definition: IHSFusion.h:72