TsFusion.cpp
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/unittest/rp/fusion/TsFusion.cpp
22 
23  \brief A test suit for the Fusion interface.
24 */
25 
26 // TerraLib
27 #include "../Config.h"
28 #include <terralib/rp.h>
29 #include <terralib/raster.h>
30 
31 // Boost
32 #define BOOST_TEST_NO_MAIN
33 #include <boost/test/unit_test.hpp>
34 
35 BOOST_AUTO_TEST_SUITE (fusion_tests)
36 
37 BOOST_AUTO_TEST_CASE(ihs_test)
38 {
39  /* Openning input raster */
40 
41  std::map<std::string, std::string> auxRasterInfo;
42 
43  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers2b_rgb342_crop.tif";
44  boost::shared_ptr< te::rst::Raster > lowResRasterPtr( te::rst::RasterFactory::open(
45  auxRasterInfo ) );
46  BOOST_CHECK( lowResRasterPtr.get() );
47 
48  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers2b_hrc_crop.tif";
49  boost::shared_ptr< te::rst::Raster > highResRasterPtr( te::rst::RasterFactory::open(
50  auxRasterInfo ) );
51  BOOST_CHECK( highResRasterPtr.get() );
52 
53  /* Creating the algorithm parameters */
54 
55  te::rp::IHSFusion::InputParameters algoInputParams;
56 
57  algoInputParams.m_lowResRasterPtr = lowResRasterPtr.get();
58  algoInputParams.m_lowResRasterRedBandIndex = 0;
59  algoInputParams.m_lowResRasterGreenBandIndex = 1;
60  algoInputParams.m_lowResRasterBlueBandIndex = 2;
61  algoInputParams.m_highResRasterPtr = highResRasterPtr.get();
62  algoInputParams.m_highResRasterBand = 0;
63  algoInputParams.m_enableProgress = false;
64  algoInputParams.m_interpMethod = te::rst::NearestNeighbor;
65  algoInputParams.m_RGBMin = 0;
66  algoInputParams.m_RGBMax = 0;
67 
68  te::rp::IHSFusion::OutputParameters algoOutputParams;
69 
70  algoOutputParams.m_rInfo["URI"] =
71  "terralib_unittest_rp_fusion_ihs.tif";
72  algoOutputParams.m_rType = "GDAL";
73 
74  /* Executing the algorithm */
75 
76  te::rp::IHSFusion algorithmInstance;
77 
78  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
79  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
80 }
81 
83 {
84  /* Opening input raster */
85 
86  std::map<std::string, std::string> auxRasterInfo;
87 
88  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers2b_rgb342_crop.tif";
89  boost::shared_ptr< te::rst::Raster > lowResRasterPtr( te::rst::RasterFactory::open(
90  auxRasterInfo ) );
91  BOOST_CHECK( lowResRasterPtr.get() );
92 
93  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers2b_hrc_crop.tif";
94  boost::shared_ptr< te::rst::Raster > highResRasterPtr( te::rst::RasterFactory::open(
95  auxRasterInfo ) );
96  BOOST_CHECK( highResRasterPtr.get() );
97 
98  /* Creating the algorithm parameters */
99 
100  te::rp::PCAFusion::InputParameters algoInputParams;
101 
102  algoInputParams.m_lowResRasterPtr = lowResRasterPtr.get();
103  algoInputParams.m_lowResRasterBands.push_back( 0 );
104  algoInputParams.m_lowResRasterBands.push_back( 1 );
105  algoInputParams.m_lowResRasterBands.push_back( 2 );
106  algoInputParams.m_highResRasterPtr = highResRasterPtr.get();
107  algoInputParams.m_highResRasterBand = 0;
108  algoInputParams.m_enableProgress = true;
109  algoInputParams.m_enableThreadedProcessing = false;
110  algoInputParams.m_interpMethod = te::rst::NearestNeighbor;
111 
112  te::rp::PCAFusion::OutputParameters algoOutputParams;
113 
114  algoOutputParams.m_rInfo["URI"] =
115  "terralib_unittest_rp_fusion_pca.tif";
116  algoOutputParams.m_rType = "GDAL";
117 
118  /* Executing the algorithm */
119 
120  te::rp::PCAFusion algorithmInstance;
121 
122  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
123  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
124 }
125 
127 {
128  /* Opening input raster */
129 
130  std::map<std::string, std::string> auxRasterInfo;
131 
132  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers2b_rgb342_crop.tif";
133  boost::shared_ptr< te::rst::Raster > lowResRasterPtr( te::rst::RasterFactory::open(
134  auxRasterInfo ) );
135  BOOST_CHECK( lowResRasterPtr.get() );
136 
137  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers2b_hrc_crop.tif";
138  boost::shared_ptr< te::rst::Raster > highResRasterPtr( te::rst::RasterFactory::open(
139  auxRasterInfo ) );
140  BOOST_CHECK( highResRasterPtr.get() );
141 
142  /* Creating the algorithm parameters */
143 
145 
146  algoInputParams.m_lowResRasterPtr = lowResRasterPtr.get();
147  algoInputParams.m_lowResRasterBands.push_back( 0 );
148  algoInputParams.m_lowResRasterBands.push_back( 1 );
149  algoInputParams.m_lowResRasterBands.push_back( 2 );
150  algoInputParams.m_lowResRasterBandSensors.push_back( te::rp::srf::CBERS2BCCDB3Sensor );
151  algoInputParams.m_lowResRasterBandSensors.push_back( te::rp::srf::CBERS2BCCDB4Sensor );
152  algoInputParams.m_lowResRasterBandSensors.push_back( te::rp::srf::CBERS2BCCDB2Sensor );
153  algoInputParams.m_highResRasterPtr = highResRasterPtr.get();
154  algoInputParams.m_highResRasterBand = 0;
155  algoInputParams.m_hiResRasterBandSensor = te::rp::srf::CBERS2BCCDB5PANSensor;
156  algoInputParams.m_hiResRasterWaveletLevels = 0;
157  algoInputParams.m_enableProgress = true;
158  algoInputParams.m_interpMethod = te::rst::NearestNeighbor;
159  algoInputParams.m_waveletFilterType = te::rp::TriangleWAFilter;
160 
162 
163  algoOutputParams.m_rInfo["URI"] =
164  "terralib_unittest_rp_fusion_wisper.tif";
165  algoOutputParams.m_rType = "GDAL";
166 
167  /* Executing the algorithm */
168 
169  te::rp::WisperFusion algorithmInstance;
170 
171  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
172  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
173 }
174 
175 BOOST_AUTO_TEST_SUITE_END()
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
Definition: PCAFusion.cpp:139
Near neighborhood interpolation method.
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
te::rst::Raster const * m_lowResRasterPtr
Input low-resolution multi-band raster.
Definition: WisperFusion.h:69
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 WiSpeR method...
Definition: WisperFusion.h:57
Fusion of a low-resolution multi-band image with a high resolution image using the IHS method...
Definition: IHSFusion.h:56
IHSFusion output parameters.
Definition: IHSFusion.h:108
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: PCAFusion.h:100
IHSFusion input parameters.
Definition: IHSFusion.h:64
BOOST_AUTO_TEST_SUITE(fusion_tests) BOOST_AUTO_TEST_CASE(ihs_test)
Definition: TsFusion.cpp:35
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
PCAFusion output parameters.
Definition: PCAFusion.h:96
Fusion of a low-resolution multi-band image with a high resolution image using the PCA (Principal com...
Definition: PCAFusion.h:50
te::rst::Raster const * m_lowResRasterPtr
Input low-resolution multi-band raster.
Definition: PCAFusion.h:62
WisperFusion output parameters.
Definition: WisperFusion.h:117
BOOST_AUTO_TEST_CASE(pca_test)
Definition: TsFusion.cpp:82
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
WisperFusion input parameters.
Definition: WisperFusion.h:65
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
Definition: PCAFusion.cpp:288
This file contains include headers for the TerraLib Raster Processing module.
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
Definition: WisperFusion.h:123
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:102
PCAFusion input parameters.
Definition: PCAFusion.h:58
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: WisperFusion.h:121
te::rst::Raster const * m_lowResRasterPtr
Input low-resolution multi-band raster.
Definition: IHSFusion.h:68
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
static Raster * open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
It opens a raster with the given parameters and default raster driver.