TsTiePointsLocator.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/tie_points_locator/TsTiePointsLocator.cpp
22 
23  \brief A test suit for TiePointsLocator 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 #include <boost/shared_ptr.hpp>
35 
36 BOOST_AUTO_TEST_SUITE (tiePointsLocator_tests)
37 
38 void saveImagesAndTiePoints(
39 
40  const te::rst::Raster& raster1,
41  const unsigned int band1,
42  const te::rst::Raster& raster2,
43  const unsigned int band2,
44  const std::vector< te::gm::GTParameters::TiePoint >& tiePoints,
45  const std::string& tifFileNameBeginning )
46 {
47  std::map<std::string, std::string> rInfo1;
48  rInfo1["URI"] = tifFileNameBeginning + "_raster1.tif";
49 
50  std::vector<te::rst::BandProperty*> bandsProperties1;
51  bandsProperties1.push_back(new te::rst::BandProperty( 0, te::dt::UCHAR_TYPE, "" ));
52  bandsProperties1[0]->m_colorInterp = te::rst::RedCInt;
53  bandsProperties1[0]->m_noDataValue = 0;
54  bandsProperties1.push_back(new te::rst::BandProperty( *bandsProperties1[0] ));
55  bandsProperties1[1]->m_colorInterp = te::rst::GreenCInt;
56  bandsProperties1.push_back(new te::rst::BandProperty( *bandsProperties1[0] ));
57  bandsProperties1[2]->m_colorInterp = te::rst::BlueCInt;
58 
59  te::rst::Grid* newgrid1 = new te::rst::Grid( *raster1.getGrid() );
60 
61  std::unique_ptr< te::rst::Raster > outputRaster1Ptr(
62  te::rst::RasterFactory::make( "GDAL", newgrid1, bandsProperties1, rInfo1, 0, 0));
63  BOOST_CHECK( outputRaster1Ptr.get() );
64 
65  unsigned int line = 0;
66  unsigned int col = 0;
67  double value = 0;
68 
69  for( line = 0 ; line < raster1.getNumberOfRows() ; ++line )
70  for( col = 0 ; col < raster1.getNumberOfColumns() ; ++col )
71  {
72  raster1.getValue( col, line, value, band1 );
73  outputRaster1Ptr->setValue( col, line, value, 0 );
74  outputRaster1Ptr->setValue( col, line, value, 1 );
75  outputRaster1Ptr->setValue( col, line, value, 2 );
76  }
77 
78  std::map<std::string, std::string> rInfo2;
79  rInfo2["URI"] = tifFileNameBeginning + "_raster2.tif";
80 
81  std::vector<te::rst::BandProperty*> bandsProperties2;
82  bandsProperties2.push_back(new te::rst::BandProperty( 0, te::dt::UCHAR_TYPE, "" ));
83  bandsProperties2[0]->m_colorInterp = te::rst::RedCInt;
84  bandsProperties2[0]->m_noDataValue = 0;
85  bandsProperties2.push_back(new te::rst::BandProperty( *bandsProperties2[0] ));
86  bandsProperties2[1]->m_colorInterp = te::rst::GreenCInt;
87  bandsProperties2.push_back(new te::rst::BandProperty( *bandsProperties2[0] ));
88  bandsProperties2[2]->m_colorInterp = te::rst::BlueCInt;
89 
90  te::rst::Grid* newgrid2 = new te::rst::Grid( *raster2.getGrid() );
91 
92  std::unique_ptr< te::rst::Raster > outputRaster2Ptr(
93  te::rst::RasterFactory::make( "GDAL", newgrid2, bandsProperties2, rInfo2, 0, 0));
94  BOOST_CHECK( outputRaster2Ptr.get() );
95 
96  for( line = 0 ; line < raster2.getNumberOfRows() ; ++line )
97  for( col = 0 ; col < raster2.getNumberOfColumns() ; ++col )
98  {
99  raster2.getValue( col, line, value, band2 );
100  outputRaster2Ptr->setValue( col, line, value, 0 );
101  outputRaster2Ptr->setValue( col, line, value, 1 );
102  outputRaster2Ptr->setValue( col, line, value, 2 );
103  }
104 
105  std::vector< te::gm::GTParameters::TiePoint >::const_iterator itB = tiePoints.begin();
106  const std::vector< te::gm::GTParameters::TiePoint >::const_iterator itE =
107  tiePoints.end();
108 
109  while( itB != itE )
110  {
111  BOOST_CHECK( ((unsigned int)(itB->first.x)) < outputRaster1Ptr->getNumberOfColumns() );
112  BOOST_CHECK( ((unsigned int)(itB->first.y)) < outputRaster1Ptr->getNumberOfRows() );
113  outputRaster1Ptr->setValue( (unsigned int)(itB->first.x), (unsigned int)(itB->first.y), 255, 1 );
114 
115  BOOST_CHECK( ((unsigned int)(itB->second.x)) < outputRaster2Ptr->getNumberOfColumns() );
116  BOOST_CHECK( ((unsigned int)(itB->second.y)) < outputRaster2Ptr->getNumberOfRows() );
117  outputRaster2Ptr->setValue( (unsigned int)(itB->second.x), (unsigned int)(itB->second.y), 255, 1 );
118 
119  ++itB;
120  }
121 }
122 
123 BOOST_AUTO_TEST_CASE(moravecStrategySameImage_test)
124 {
125  /* Openning input raster */
126 
127  std::map<std::string, std::string> inputRasterInfo;
128  inputRasterInfo["URI"] = TERRALIB_DATA_DIR
129  "/geotiff/cbers_b2_crop.tif";
130 
131  boost::shared_ptr< te::rst::Raster > inputRasterPointer ( te::rst::RasterFactory::open(
132  inputRasterInfo ) );
133  BOOST_CHECK( inputRasterPointer.get() );
134 
135  /* Creating the algorithm parameters */
136 
138 
140  algoInputParams.m_interesPointsLocationStrategyName = "Moravec";
141  algoInputParams.m_inRaster1Ptr = inputRasterPointer.get();
142  algoInputParams.m_inRaster1Bands.push_back( 0 );
143  algoInputParams.m_inRaster2Ptr = inputRasterPointer.get();
144  algoInputParams.m_inRaster2Bands.push_back( 0 );
145  algoInputParams.m_enableMultiThread = false;
146  algoInputParams.m_maxTiePoints = 1000;
147  algoInputParams.m_geomTransfName = "RST";
148  algoInputParams.setSpecStrategyParams( specPars );
149 
151 
152  /* Executing the algorithm */
153 
154  te::rp::TiePointsLocator algorithmInstance;
155 
156  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
157  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
158 
159  /* Saving images and tie-points */
160 
161  saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
162  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_MoravecStrategySameImage" );
163 
164  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)866 );
165 }
166 
167 BOOST_AUTO_TEST_CASE(moravecStrategyUpsampledImage_test)
168 {
169  /* Openning input raster */
170 
171  std::map<std::string, std::string> inputRasterInfo;
172  inputRasterInfo["URI"] = TERRALIB_DATA_DIR
173  "/geotiff/cbers_b2_crop.tif";
174 
175  boost::shared_ptr< te::rst::Raster > inputRasterPointer ( te::rst::RasterFactory::open(
176  inputRasterInfo ) );
177  BOOST_CHECK( inputRasterPointer.get() );
178 
179  std::map<std::string, std::string> inputRaster2Info;
180  inputRaster2Info["URI"] = TERRALIB_DATA_DIR
181  "/geotiff/cbers_b2_crop_upsampled.tif";
182 
183  boost::shared_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
184  inputRaster2Info ) );
185  BOOST_CHECK( inputRaster2Pointer.get() );
186 
187  /* Creating the algorithm parameters */
188 
190 
192  algoInputParams.m_interesPointsLocationStrategyName = "Moravec";
193  algoInputParams.m_inRaster1Ptr = inputRasterPointer.get();
194  algoInputParams.m_inRaster1Bands.push_back( 0 );
195  algoInputParams.m_inRaster2Ptr = inputRaster2Pointer.get();
196  algoInputParams.m_inRaster2Bands.push_back( 0 );
197  algoInputParams.m_enableMultiThread = false;
198  algoInputParams.m_maxTiePoints = 1000;
199  algoInputParams.m_pixelSizeXRelation = inputRasterPointer->getResolutionX() /
200  inputRaster2Pointer->getResolutionX();
201  algoInputParams.m_pixelSizeYRelation = inputRasterPointer->getResolutionY() /
202  inputRaster2Pointer->getResolutionY();
203  algoInputParams.m_geomTransfName = "RST";
204  algoInputParams.setSpecStrategyParams( specPars );
205 
207 
208  /* Executing the algorithm */
209 
210  te::rp::TiePointsLocator algorithmInstance;
211 
212  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
213  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
214 
215  /* Saving images and tie-points */
216 
217  saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRaster2Pointer, 0,
218  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_MoravecStrategyUpsampledImage" );
219 
220  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)866 );
221 }
222 
223 BOOST_AUTO_TEST_CASE(moravecStrategy90ClkWRotationImage_test)
224 {
225  /* Openning input raster */
226 
227  std::map<std::string, std::string> inputRasterInfo;
228  inputRasterInfo["URI"] = TERRALIB_DATA_DIR
229  "/geotiff/cbers_b2_crop.tif";
230 
231  boost::shared_ptr< te::rst::Raster > inputRasterPointer ( te::rst::RasterFactory::open(
232  inputRasterInfo ) );
233  BOOST_CHECK( inputRasterPointer.get() );
234 
235  std::map<std::string, std::string> inputRaster2Info;
236  inputRaster2Info["URI"] = TERRALIB_DATA_DIR
237  "/geotiff/cbers_b2_crop_90clockw_rotation.tif";
238 
239  boost::shared_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
240  inputRaster2Info ) );
241  BOOST_CHECK( inputRaster2Pointer.get() );
242 
243  /* Creating the algorithm parameters */
244 
246 
248  algoInputParams.m_interesPointsLocationStrategyName = "Moravec";
249  algoInputParams.m_inRaster1Ptr = inputRasterPointer.get();
250  algoInputParams.m_inRaster1Bands.push_back( 0 );
251  algoInputParams.m_inRaster2Ptr = inputRaster2Pointer.get();
252  algoInputParams.m_inRaster2Bands.push_back( 0 );
253  algoInputParams.m_enableMultiThread = false;
254  algoInputParams.m_maxTiePoints = 1000;
255  algoInputParams.m_geomTransfName = "RST";
256  algoInputParams.setSpecStrategyParams( specPars );
257 
259 
260  /* Executing the algorithm */
261 
262  te::rp::TiePointsLocator algorithmInstance;
263 
264  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
265  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
266 
267  /* Saving images and tie-points */
268 
269  saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRaster2Pointer, 0,
270  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_MoravecStrategy90ClkWRotationImage" );
271 
272  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)854 );
273 }
274 
275 BOOST_AUTO_TEST_CASE(moravecStrategyHalfRotated90Image_test)
276 {
277  /* Openning input rasters */
278 
279  std::map<std::string, std::string> inputRaster1Info;
280  inputRaster1Info["URI"] = TERRALIB_DATA_DIR
281  "/geotiff/cbers_b2_crop.tif";
282 
283  boost::shared_ptr< te::rst::Raster > inputRaster1Pointer ( te::rst::RasterFactory::open(
284  inputRaster1Info ) );
285  BOOST_CHECK( inputRaster1Pointer.get() );
286 
287  std::map<std::string, std::string> inputRaster2Info;
288  inputRaster2Info["URI"] = TERRALIB_DATA_DIR
289  "/geotiff/cbers_b2_crop_contrast_halfsampled_90rotation.tif";
290 
291  boost::shared_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
292  inputRaster2Info ) );
293  BOOST_CHECK( inputRaster2Pointer.get() );
294 
295  /* Creating the algorithm parameters */
296 
298 
300  algoInputParams.m_interesPointsLocationStrategyName = "Moravec";
301  algoInputParams.m_inRaster1Ptr = inputRaster1Pointer.get();
302  algoInputParams.m_inRaster1Bands.push_back( 0 );
303  algoInputParams.m_inRaster2Ptr = inputRaster2Pointer.get();
304  algoInputParams.m_inRaster2Bands.push_back( 0 );
305  algoInputParams.m_enableMultiThread = false;
306  algoInputParams.m_pixelSizeXRelation = 20.0 / 40.0;
307  algoInputParams.m_pixelSizeYRelation = 20.0 / 40.0;
308  algoInputParams.m_maxTiePoints = 1000;
309  algoInputParams.m_geomTransfName = "RST";
310  algoInputParams.setSpecStrategyParams( specPars );
311 
313 
314  /* Executing the algorithm */
315 
316  te::rp::TiePointsLocator algorithmInstance;
317 
318  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
319  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
320 
321  /* Saving images and tie-points */
322 
323  saveImagesAndTiePoints( *inputRaster1Pointer, 0, *inputRaster2Pointer, 0,
324  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_MoravecStrategyHalfRotated90Image" );
325 
326  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)200 );
327 }
328 
329 BOOST_AUTO_TEST_CASE(moravecStrategySameImageDifBoxes_test)
330 {
331  /* Openning input raster */
332 
333  std::map<std::string, std::string> inputRasterInfo;
334  inputRasterInfo["URI"] = TERRALIB_DATA_DIR
335  "/geotiff/cbers_b2_crop.tif";
336 
337  boost::shared_ptr< te::rst::Raster > inputRasterPointer ( te::rst::RasterFactory::open(
338  inputRasterInfo ) );
339  BOOST_CHECK( inputRasterPointer.get() );
340 
341  /* Creating the algorithm parameters */
342 
344 
346  algoInputParams.m_interesPointsLocationStrategyName = "Moravec";
347  algoInputParams.m_inRaster1Ptr = inputRasterPointer.get();
348  algoInputParams.m_inRaster1Bands.push_back( 0 );
349  algoInputParams.m_inRaster2Ptr = inputRasterPointer.get();
350  algoInputParams.m_inRaster2Bands.push_back( 0 );
351  algoInputParams.m_enableMultiThread = false;
352  algoInputParams.m_raster1TargetAreaColStart = 200;
353  algoInputParams.m_raster1TargetAreaLineStart = 200;
354  algoInputParams.m_raster1TargetAreaWidth = 500;
355  algoInputParams.m_raster1TargetAreaHeight = 500;
356  algoInputParams.m_raster2TargetAreaColStart = 300;
357  algoInputParams.m_raster2TargetAreaLineStart = 300;
358  algoInputParams.m_raster2TargetAreaWidth = 400;
359  algoInputParams.m_raster2TargetAreaHeight = 400;
360  algoInputParams.m_maxTiePoints = 1000;
361  algoInputParams.m_geomTransfName = "RST";
362  algoInputParams.setSpecStrategyParams( specPars );
363 
365 
366  /* Executing the algorithm */
367 
368  te::rp::TiePointsLocator algorithmInstance;
369 
370  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
371  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
372 
373  /* Saving images and tie-points */
374 
375  saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
376  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_MoravecStrategySameImageDifBoxes" );
377 
378  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)189 );
379 }
380 
381 BOOST_AUTO_TEST_CASE(moravecStrategyMultipleThreads_test)
382 {
383  /* Openning input raster */
384 
385  std::map<std::string, std::string> inputRasterInfo;
386  inputRasterInfo["URI"] = TERRALIB_DATA_DIR
387  "/geotiff/cbers_b2_crop.tif";
388 
389  boost::shared_ptr< te::rst::Raster > inputRasterPointer ( te::rst::RasterFactory::open(
390  inputRasterInfo ) );
391  BOOST_CHECK( inputRasterPointer.get() );
392 
393  /* Creating the algorithm parameters */
394 
396 
398  algoInputParams.m_interesPointsLocationStrategyName = "Moravec";
399  algoInputParams.m_inRaster1Ptr = inputRasterPointer.get();
400  algoInputParams.m_inRaster1Bands.push_back( 0 );
401  algoInputParams.m_inRaster2Ptr = inputRasterPointer.get();
402  algoInputParams.m_inRaster2Bands.push_back( 0 );
403  algoInputParams.m_enableMultiThread = true;
404  algoInputParams.m_maxTiePoints = 1000;
405  algoInputParams.m_geomTransfName = "RST";
406  algoInputParams.setSpecStrategyParams( specPars );
407 
409 
410  /* Executing the algorithm */
411 
412  te::rp::TiePointsLocator algorithmInstance;
413 
414  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
415  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
416 
417  /* Saving images and tie-points */
418 
419  saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
420  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_MoravecStrategyMultipleThreads" );
421 
422  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)700 );
423 }
424 
425 BOOST_AUTO_TEST_CASE(moravecStrategyRescaleFactor_test)
426 {
427  /* Openning input raster */
428 
429  std::map<std::string, std::string> inputRasterInfo;
430  inputRasterInfo["URI"] = TERRALIB_DATA_DIR
431  "/geotiff/cbers2b_hrc_crop.tif";
432 
433  boost::shared_ptr< te::rst::Raster > inputRasterPointer ( te::rst::RasterFactory::open(
434  inputRasterInfo ) );
435  BOOST_CHECK( inputRasterPointer.get() );
436 
437  /* Creating the algorithm parameters */
438 
440 
442  algoInputParams.m_interesPointsLocationStrategyName = "Moravec";
443  algoInputParams.m_inRaster1Ptr = inputRasterPointer.get();
444  algoInputParams.m_inRaster1Bands.push_back( 0 );
445  algoInputParams.m_inRaster2Ptr = inputRasterPointer.get();
446  algoInputParams.m_inRaster2Bands.push_back( 0 );
447  algoInputParams.m_enableMultiThread = false;
448  algoInputParams.m_maxTiePoints = 1000;
449  algoInputParams.m_subSampleOptimizationRescaleFactor = 0.5;
450  algoInputParams.m_geomTransfName = "RST";
451  algoInputParams.setSpecStrategyParams( specPars );
452 
454 
455  /* Executing the algorithm */
456 
457  te::rp::TiePointsLocator algorithmInstance;
458 
459  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
460  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
461 
462  /* Saving images and tie-points */
463 
464  saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
465  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_MoravecStrategyRescaleFactor" );
466 
467  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)992 );
468 }
469 
470 BOOST_AUTO_TEST_CASE(surfStrategySameImage_test)
471 {
472  /* Openning input raster */
473 
474  std::map<std::string, std::string> inputRasterInfo;
475  inputRasterInfo["URI"] = TERRALIB_DATA_DIR
476  "/geotiff/cbers_b2_crop.tif";
477 
478  boost::shared_ptr< te::rst::Raster > inputRasterPointer ( te::rst::RasterFactory::open(
479  inputRasterInfo ) );
480  BOOST_CHECK( inputRasterPointer.get() );
481 
482  /* Creating the algorithm parameters */
483 
485 
487  algoInputParams.m_interesPointsLocationStrategyName = "SURF";
488  algoInputParams.m_inRaster1Ptr = inputRasterPointer.get();
489  algoInputParams.m_inRaster1Bands.push_back( 0 );
490  algoInputParams.m_inRaster2Ptr = inputRasterPointer.get();
491  algoInputParams.m_inRaster2Bands.push_back( 0 );
492  algoInputParams.m_enableMultiThread = false;
493  algoInputParams.m_maxTiePoints = 2000;
494  algoInputParams.m_geomTransfName = "RST";
495  algoInputParams.setSpecStrategyParams( specPars );
496 
498 
499  /* Executing the algorithm */
500 
501  te::rp::TiePointsLocator algorithmInstance;
502 
503  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
504  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
505 
506  /* Saving images and tie-points */
507 
508  saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
509  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_SurfStrategySameImage" );
510 
511  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)1500 );
512 }
513 
514 BOOST_AUTO_TEST_CASE(surfStrategyUpsampledImage_test)
515 {
516  /* Openning input raster */
517 
518  std::map<std::string, std::string> inputRasterInfo;
519  inputRasterInfo["URI"] = TERRALIB_DATA_DIR
520  "/geotiff/cbers_b2_crop.tif";
521 
522  boost::shared_ptr< te::rst::Raster > inputRasterPointer ( te::rst::RasterFactory::open(
523  inputRasterInfo ) );
524  BOOST_CHECK( inputRasterPointer.get() );
525 
526  std::map<std::string, std::string> inputRaster2Info;
527  inputRaster2Info["URI"] = TERRALIB_DATA_DIR
528  "/geotiff/cbers_b2_crop_upsampled.tif";
529 
530  boost::shared_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
531  inputRaster2Info ) );
532  BOOST_CHECK( inputRaster2Pointer.get() );
533 
534  /* Creating the algorithm parameters */
535 
537 
539  algoInputParams.m_interesPointsLocationStrategyName = "SURF";
540  algoInputParams.m_inRaster1Ptr = inputRasterPointer.get();
541  algoInputParams.m_inRaster1Bands.push_back( 0 );
542  algoInputParams.m_inRaster2Ptr = inputRaster2Pointer.get();
543  algoInputParams.m_inRaster2Bands.push_back( 0 );
544  algoInputParams.m_enableMultiThread = false;
545  algoInputParams.m_maxTiePoints = 2000;
546  algoInputParams.m_geomTransfName = "RST";
547  algoInputParams.m_pixelSizeXRelation = inputRasterPointer->getResolutionX() /
548  inputRaster2Pointer->getResolutionX();
549  algoInputParams.m_pixelSizeYRelation = inputRasterPointer->getResolutionY() /
550  inputRaster2Pointer->getResolutionY();
551  algoInputParams.setSpecStrategyParams( specPars );
552 
554 
555  /* Executing the algorithm */
556 
557  te::rp::TiePointsLocator algorithmInstance;
558 
559  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
560  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
561 
562  /* Saving images and tie-points */
563 
564  saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRaster2Pointer, 0,
565  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_SurfStrategyUpsampledImage" );
566 
567  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)1700 );
568 }
569 
570 BOOST_AUTO_TEST_CASE(surfStrategy90ClkWRotationImage_test)
571 {
572  /* Openning input raster */
573 
574  std::map<std::string, std::string> inputRasterInfo;
575  inputRasterInfo["URI"] = TERRALIB_DATA_DIR
576  "/geotiff/cbers_b2_crop.tif";
577 
578  boost::shared_ptr< te::rst::Raster > inputRasterPointer ( te::rst::RasterFactory::open(
579  inputRasterInfo ) );
580  BOOST_CHECK( inputRasterPointer.get() );
581 
582  std::map<std::string, std::string> inputRaster2Info;
583  inputRaster2Info["URI"] = TERRALIB_DATA_DIR
584  "/geotiff/cbers_b2_crop_90clockw_rotation.tif";
585 
586  boost::shared_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
587  inputRaster2Info ) );
588  BOOST_CHECK( inputRaster2Pointer.get() );
589 
590  /* Creating the algorithm parameters */
591 
593 
595  algoInputParams.m_interesPointsLocationStrategyName = "SURF";
596  algoInputParams.m_inRaster1Ptr = inputRasterPointer.get();
597  algoInputParams.m_inRaster1Bands.push_back( 0 );
598  algoInputParams.m_inRaster2Ptr = inputRaster2Pointer.get();
599  algoInputParams.m_inRaster2Bands.push_back( 0 );
600  algoInputParams.m_enableMultiThread = false;
601  algoInputParams.m_maxTiePoints = 2000;
602  algoInputParams.m_geomTransfName = "RST";
603  algoInputParams.setSpecStrategyParams( specPars );
604 
606 
607  /* Executing the algorithm */
608 
609  te::rp::TiePointsLocator algorithmInstance;
610 
611  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
612  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
613 
614  /* Saving images and tie-points */
615 
616  saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRaster2Pointer, 0,
617  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_SurfStrategy90ClkWRotationImage" );
618 
619  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)1268 );
620 }
621 
622 BOOST_AUTO_TEST_CASE(surfStrategySameImageDifBoxes_test)
623 {
624  /* Openning input raster */
625 
626  std::map<std::string, std::string> inputRasterInfo;
627  inputRasterInfo["URI"] = TERRALIB_DATA_DIR
628  "/geotiff/cbers_b2_crop.tif";
629 
630  boost::shared_ptr< te::rst::Raster > inputRasterPointer ( te::rst::RasterFactory::open(
631  inputRasterInfo ) );
632  BOOST_CHECK( inputRasterPointer.get() );
633 
634  /* Creating the algorithm parameters */
635 
637 
639  algoInputParams.m_interesPointsLocationStrategyName = "SURF";
640  algoInputParams.m_inRaster1Ptr = inputRasterPointer.get();
641  algoInputParams.m_inRaster1Bands.push_back( 0 );
642  algoInputParams.m_inRaster2Ptr = inputRasterPointer.get();
643  algoInputParams.m_inRaster2Bands.push_back( 0 );
644  algoInputParams.m_enableMultiThread = false;
645  algoInputParams.m_raster1TargetAreaColStart = 0;
646  algoInputParams.m_raster1TargetAreaLineStart = 0;
647  algoInputParams.m_raster1TargetAreaWidth = 700;
648  algoInputParams.m_raster1TargetAreaHeight = 600;
649  algoInputParams.m_raster2TargetAreaColStart = 20;
650  algoInputParams.m_raster2TargetAreaLineStart = 30;
651  algoInputParams.m_raster2TargetAreaWidth = 600;
652  algoInputParams.m_raster2TargetAreaHeight = 700;
653  algoInputParams.m_maxTiePoints = 2000;
654  algoInputParams.m_geomTransfName = "RST";
655  algoInputParams.setSpecStrategyParams( specPars );
656 
658 
659  /* Executing the algorithm */
660 
661  te::rp::TiePointsLocator algorithmInstance;
662 
663  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
664  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
665 
666  /* Saving images and tie-points */
667 
668  saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
669  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_SurfStrategySameImageDifBoxes" );
670 
671  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)1081 );
672 }
673 
674 BOOST_AUTO_TEST_CASE(surfStrategyHalfRotated90Image_test)
675 {
676  /* Openning input rasters */
677 
678  std::map<std::string, std::string> inputRaster1Info;
679  inputRaster1Info["URI"] = TERRALIB_DATA_DIR
680  "/geotiff/cbers_b2_crop.tif";
681 
682  boost::shared_ptr< te::rst::Raster > inputRaster1Pointer ( te::rst::RasterFactory::open(
683  inputRaster1Info ) );
684  BOOST_CHECK( inputRaster1Pointer.get() );
685 
686  std::map<std::string, std::string> inputRaster2Info;
687  inputRaster2Info["URI"] = TERRALIB_DATA_DIR
688  "/geotiff/cbers_b2_crop_contrast_halfsampled_90rotation.tif";
689 
690  boost::shared_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
691  inputRaster2Info ) );
692  BOOST_CHECK( inputRaster2Pointer.get() );
693 
694  /* Creating the algorithm parameters */
695 
697 
699  algoInputParams.m_interesPointsLocationStrategyName = "SURF";
700  algoInputParams.m_inRaster1Ptr = inputRaster1Pointer.get();
701  algoInputParams.m_inRaster1Bands.push_back( 0 );
702  algoInputParams.m_inRaster2Ptr = inputRaster2Pointer.get();
703  algoInputParams.m_inRaster2Bands.push_back( 0 );
704  algoInputParams.m_enableMultiThread = false;
705  algoInputParams.m_maxTiePoints = 3000;
706  algoInputParams.m_geomTransfName = "RST";
707  algoInputParams.m_pixelSizeXRelation = 20.0 / 40.0;
708  algoInputParams.m_pixelSizeYRelation = 20.0 / 40.0;
709  algoInputParams.setSpecStrategyParams( specPars );
710 
712 
713  /* Executing the algorithm */
714 
715  te::rp::TiePointsLocator algorithmInstance;
716 
717  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
718  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
719 
720  /* Saving images and tie-points */
721 
722  saveImagesAndTiePoints( *inputRaster1Pointer, 0, *inputRaster2Pointer, 0,
723  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_SurfStrategyHalfRotated90Image" );
724 
725  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)882 );
726 }
727 
728 BOOST_AUTO_TEST_CASE(surfStrategyMultipleThreads_test)
729 {
730  /* Openning input raster */
731 
732  std::map<std::string, std::string> inputRasterInfo;
733  inputRasterInfo["URI"] = TERRALIB_DATA_DIR
734  "/geotiff/cbers_b2_crop.tif";
735 
736  boost::shared_ptr< te::rst::Raster > inputRasterPointer ( te::rst::RasterFactory::open(
737  inputRasterInfo ) );
738  BOOST_CHECK( inputRasterPointer.get() );
739 
740  /* Creating the algorithm parameters */
741 
743 
745  algoInputParams.m_interesPointsLocationStrategyName = "SURF";
746  algoInputParams.m_inRaster1Ptr = inputRasterPointer.get();
747  algoInputParams.m_inRaster1Bands.push_back( 0 );
748  algoInputParams.m_inRaster2Ptr = inputRasterPointer.get();
749  algoInputParams.m_inRaster2Bands.push_back( 0 );
750  algoInputParams.m_enableMultiThread = true;
751  algoInputParams.m_maxTiePoints = 2000;
752  algoInputParams.m_geomTransfName = "RST";
753  algoInputParams.setSpecStrategyParams( specPars );
754 
756 
757  /* Executing the algorithm */
758 
759  te::rp::TiePointsLocator algorithmInstance;
760 
761  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
762  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
763 
764  /* Saving images and tie-points */
765 
766  saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
767  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_SurfStrategyMultipleThreads" );
768 
769  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)400 );
770 }
771 
772 BOOST_AUTO_TEST_CASE(surfStrategyRescaleFactor_test)
773 {
774  /* Openning input raster */
775 
776  std::map<std::string, std::string> inputRasterInfo;
777  inputRasterInfo["URI"] = TERRALIB_DATA_DIR
778  "/geotiff/cbers2b_hrc_crop.tif";
779 
780  boost::shared_ptr< te::rst::Raster > inputRasterPointer ( te::rst::RasterFactory::open(
781  inputRasterInfo ) );
782  BOOST_CHECK( inputRasterPointer.get() );
783 
784  /* Creating the algorithm parameters */
785 
787 
789  algoInputParams.m_interesPointsLocationStrategyName = "SURF";
790  algoInputParams.m_inRaster1Ptr = inputRasterPointer.get();
791  algoInputParams.m_inRaster1Bands.push_back( 0 );
792  algoInputParams.m_inRaster2Ptr = inputRasterPointer.get();
793  algoInputParams.m_inRaster2Bands.push_back( 0 );
794  algoInputParams.m_enableMultiThread = false;
795  algoInputParams.m_maxTiePoints = 2000;
796  algoInputParams.m_subSampleOptimizationRescaleFactor = 0.5;
797  algoInputParams.m_geomTransfName = "RST";
798  algoInputParams.setSpecStrategyParams( specPars );
799 
801 
802  /* Executing the algorithm */
803 
804  te::rp::TiePointsLocator algorithmInstance;
805 
806  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
807  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
808 
809  /* Saving images and tie-points */
810 
811  saveImagesAndTiePoints( *inputRasterPointer, 0, *inputRasterPointer, 0,
812  algoOutputParams.m_tiePoints, "terralib_rp_tiepointslocator_test_SurfStrategyRescaleFactor" );
813 
814  BOOST_CHECK( algoOutputParams.m_tiePoints.size() >= (size_t)1540 );
815 }
816  BOOST_AUTO_TEST_SUITE_END()
std::vector< te::gm::GTParameters::TiePoint > m_tiePoints
The generated tie-points (te::gm::GTParameters::TiePoint::first are raster 1 line/column indexes...
std::vector< unsigned int > m_inRaster2Bands
Bands to be used from the input raster 2.
unsigned int m_raster2TargetAreaLineStart
The first line of the raster 2 target area to process (default:0 - The entire raster will be consider...
A raster band description.
Definition: BandProperty.h:61
double m_subSampleOptimizationRescaleFactor
Sub-sampled optimization tie-points search rescale factor (Tie-ponts will be searched into a subsabmp...
te::rst::Raster const * m_inRaster2Ptr
Input raster 2.
Red channel color interpretation.
TiePointsLocator SURF strategy parameters.
std::string m_interesPointsLocationStrategyName
The strategy used to locate interest points (default:Moravec).
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
void setSpecStrategyParams(const TiePointsLocatorStrategyParameters &specStratParams)
Set specific tie-points locator strategy parameters.
unsigned int m_maxTiePoints
The maximum number of tie-points to generate (0:Automatically calculated, default:2500).
unsigned int line
unsigned int m_raster1TargetAreaHeight
The raster 1 target area height (default:0 - The entire raster will be considered).
double m_pixelSizeXRelation
The pixel resolution relation m_pixelSizeXRelation = raster1_pixel_res_x / raster2_pixel_res_x (defau...
std::vector< unsigned int > m_inRaster1Bands
Bands to be used from the input raster 1.
URI C++ Library.
Definition: Attributes.h:37
TiePointsLocator Moravec strategy parameters.
This file contains include headers for the TerraLib Raster Processing module.
BOOST_AUTO_TEST_CASE(moravecStrategySameImage_test)
TiePointsLocator output parameters.
BOOST_AUTO_TEST_SUITE(tiePointsLocator_tests) void saveImagesAndTiePoints(const te
te::rst::Raster const * m_inRaster1Ptr
Input raster 1.
Tie points locator.
unsigned int m_raster1TargetAreaWidth
The raster 1 target area width (default:0 - The entire raster will be considered).
double m_pixelSizeYRelation
The pixel resolution relation m_pixelSizeYRelation = raster1_pixel_res_y / raster2_pixel_res_y (defau...
unsigned int m_raster1TargetAreaLineStart
The first line of the raster 1 target area to process (default:0 - The entire raster will be consider...
unsigned int m_raster2TargetAreaColStart
The first column of the raster 2 target area to process (default:0 - The entire raster will be consid...
unsigned int m_raster2TargetAreaHeight
The raster 2 target area height (default:0 - The entire raster will be considered).
bool m_enableMultiThread
Enable/Disable the use of multi-threads (default:true).
static Raster * make()
It creates and returns an empty raster with default raster driver.
std::string m_geomTransfName
The name of the geometric transformation used to ensure tie-points consistency (see each te::gm::GTFa...
Blue channel color interpretation.
A rectified grid is the spatial support for raster data.
Definition: raster/Grid.h:68
Green channel color interpretation.
unsigned int m_raster1TargetAreaColStart
The first column of the raster 2 target area to process (default:0 - The entire raster will be consid...
unsigned int m_raster2TargetAreaWidth
The raster 2 target area width (default:0 - The entire raster will be considered).
unsigned int col
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.