TsBlender.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/blender/TsBlender.cpp
22 
23  \brief A test suit for the Blender interface.
24 */
25 
26 // TerraLib
27 #include "../Config.h"
28 #include <terralib/rp.h>
29 #include <terralib/raster.h>
30 #include <terralib/geometry.h>
31 #include <terralib/common.h>
32 
33 // STL
34 #include <memory>
35 
36 // Boost
37 #define BOOST_TEST_NO_MAIN
38 #include <boost/test/unit_test.hpp>
39 #include <boost/scoped_array.hpp>
40 
41 BOOST_AUTO_TEST_SUITE (blender_tests)
42 
43 BOOST_AUTO_TEST_CASE(pixelByPixelNoBlend_test)
44 {
45  /* Openning input rasters */
46 
47  std::map<std::string, std::string> auxRasterInfo;
48 
49  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop2.tif";
50  std::unique_ptr< te::rst::Raster > inputRaster1Pointer ( te::rst::RasterFactory::open(
51  auxRasterInfo ) );
52  BOOST_CHECK( inputRaster1Pointer.get() );
53 
54  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop1.tif";
55  std::unique_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
56  auxRasterInfo ) );
57  BOOST_CHECK( inputRaster2Pointer.get() );
58 
59  /* Creating blender parameters */
60 
61  std::vector< unsigned int > raster1Bands;
62  raster1Bands.push_back( 0 );
63  raster1Bands.push_back( 1 );
64  raster1Bands.push_back( 2 );
65 
66  std::vector< unsigned int > raster2Bands;
67  raster2Bands.push_back( 1 );
68  raster2Bands.push_back( 2 );
69  raster2Bands.push_back( 0 );
70 
71  const std::vector< double > pixelOffsets( 3, 0.0 );
72  const std::vector< double > pixelScales( 3, 1.0 );
73 
74  te::gm::GTParameters transParams;
75  transParams.m_tiePoints.push_back( te::gm::GTParameters::TiePoint(
76  te::gm::Coord2D( 292, 538 ), te::gm::Coord2D( 0, 0 ) ) );
77  transParams.m_tiePoints.push_back(
80  transParams.m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
81  transParams.m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
82  ),
84  inputRaster2Pointer->getNumberOfColumns() - 1,
85  inputRaster2Pointer->getNumberOfRows() - 1 )
86  )
87  );
88  std::unique_ptr< te::gm::GeometricTransformation > transPtr(
89  te::gm::GTFactory::make( "RST" ) );
90  BOOST_CHECK( transPtr->initialize( transParams ) );
91 
92  /* Initiating the blender instance */
93 
94  te::rp::Blender blender;
95 
96  BOOST_CHECK( blender.initialize(
97  *inputRaster1Pointer,
98  raster1Bands,
99  *inputRaster2Pointer,
100  raster2Bands,
104  0.0,
105  false,
106  false,
107  pixelOffsets,
108  pixelScales,
109  pixelOffsets,
110  pixelScales,
111  0,
112  0,
113  *transPtr,
114  1,
115  false ) );
116 
117  /* Creating the output image */
118 
119  std::map<std::string, std::string> outputRasterInfo;
120  outputRasterInfo["URI"] = "terralib_unittest_rp_Blender_PixelByPixelNoBlendTest_Test.tif";
121 
122  std::vector< te::rst::BandProperty* > bandsProperties;
123  for( unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
124  raster1Bands.size() ; ++inRasterBandsIdx )
125  {
126  bandsProperties.push_back( new te::rst::BandProperty(
127  *( inputRaster1Pointer->getBand( raster1Bands[ inRasterBandsIdx ] )->getProperty() ) ) );
128  }
129 
130  te::rst::Grid* gridPtr = new te::rst::Grid( *( inputRaster1Pointer->getGrid() ) );
131  gridPtr->setNumberOfColumns( gridPtr->getNumberOfColumns() * 2 );
132  gridPtr->setNumberOfRows( gridPtr->getNumberOfRows() * 2 );
133 
134  std::unique_ptr< te::rst::Raster > outRasterPtr( te::rst::RasterFactory::make(
135  "GDAL",
136  gridPtr,
137  bandsProperties,
138  outputRasterInfo,
139  0,
140  0 ) );
141 
142  BOOST_CHECK( outRasterPtr.get() );
143 
144  boost::scoped_array< double > values( new double[ outRasterPtr->getNumberOfBands() ] );
145  for( unsigned int row = 0 ; row < outRasterPtr->getNumberOfRows() ; ++row )
146  {
147  for( unsigned int col = 0 ; col < outRasterPtr->getNumberOfColumns() ; ++col )
148  {
149  blender.getBlendedValues( row, col, values.get() );
150 
151  for( unsigned int band = 0 ; band < outRasterPtr->getNumberOfBands() ; ++band )
152  {
153  outRasterPtr->setValue( col, row, values[ band ], band );
154  }
155  }
156  }
157 }
158 
159 BOOST_AUTO_TEST_CASE(equalization_test)
160 {
161  /* Openning input rasters */
162 
163  std::map<std::string, std::string> auxRasterInfo;
164 
165  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop2.tif";
166  std::unique_ptr< te::rst::Raster > inputRaster1Pointer ( te::rst::RasterFactory::open(
167  auxRasterInfo ) );
168  BOOST_CHECK( inputRaster1Pointer.get() );
169 
170  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop1.tif";
171  std::unique_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
172  auxRasterInfo ) );
173  BOOST_CHECK( inputRaster2Pointer.get() );
174 
175  /* Creating blender parameters */
176 
177  std::vector< unsigned int > raster1Bands;
178  raster1Bands.push_back( 0 );
179  raster1Bands.push_back( 1 );
180  raster1Bands.push_back( 2 );
181 
182  std::vector< unsigned int > raster2Bands;
183  raster2Bands.push_back( 1 );
184  raster2Bands.push_back( 2 );
185  raster2Bands.push_back( 0 );
186 
187  std::vector< double > pixelOffsets1( raster1Bands.size(), 0.0 );
188  std::vector< double > pixelScales1( raster1Bands.size(), 1.0 );
189  std::vector< double > pixelOffsets2( raster1Bands.size(), 0.0 );
190  std::vector< double > pixelScales2( raster1Bands.size(), 1.0 );
191  std::vector< double > means1( raster1Bands.size() );
192  std::vector< double > stddevs1( raster1Bands.size() );
193  std::vector< double > means2( raster1Bands.size() );
194  std::vector< double > stddevs2( raster1Bands.size() );
195 
196  for( unsigned int raster1BandsIdx = 0 ; raster1BandsIdx < raster1Bands.size() ;
197  ++raster1BandsIdx )
198  {
199  unsigned int band1Idx = raster1Bands[ raster1BandsIdx ];
200  unsigned int band2Idx = raster2Bands[ raster1BandsIdx ];
201 
202  te::rp::GetMeanValue( *inputRaster1Pointer->getBand( band1Idx ), 4,
203  means1[ raster1BandsIdx ] );
204  te::rp::GetStdDevValue( *inputRaster1Pointer->getBand( band1Idx ), 4,
205  &means1[ raster1BandsIdx ], stddevs1[ raster1BandsIdx ] );
206 
207  te::rp::GetMeanValue( *inputRaster2Pointer->getBand( band2Idx ), 4,
208  means2[ raster1BandsIdx ] );
209  te::rp::GetStdDevValue( *inputRaster2Pointer->getBand( band2Idx ), 4,
210  &means2[ raster1BandsIdx ], stddevs2[ raster1BandsIdx ] );
211 
212  pixelScales2[ raster1BandsIdx ] = stddevs1[ raster1BandsIdx ] /
213  stddevs2[ raster1BandsIdx ];
214  pixelOffsets2[ raster1BandsIdx ] = means1[ raster1BandsIdx ] -
215  ( pixelScales2[ raster1BandsIdx ] * means2[ raster1BandsIdx ] );
216  }
217 
218  te::gm::GTParameters transParams;
219  transParams.m_tiePoints.push_back( te::gm::GTParameters::TiePoint(
220  te::gm::Coord2D( 292, 538 ), te::gm::Coord2D( 0, 0 ) ) );
221  transParams.m_tiePoints.push_back(
224  transParams.m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
225  transParams.m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
226  ),
228  inputRaster2Pointer->getNumberOfColumns() - 1,
229  inputRaster2Pointer->getNumberOfRows() - 1 )
230  )
231  );
232  std::unique_ptr< te::gm::GeometricTransformation > transPtr(
233  te::gm::GTFactory::make( "RST" ) );
234  BOOST_CHECK( transPtr->initialize( transParams ) );
235 
236  /* Initiating the blender instance */
237 
238  te::rp::Blender blender;
239 
240  BOOST_CHECK( blender.initialize(
241  *inputRaster1Pointer,
242  raster1Bands,
243  *inputRaster2Pointer,
244  raster2Bands,
248  0.0,
249  false,
250  false,
251  pixelOffsets1,
252  pixelScales1,
253  pixelOffsets2,
254  pixelScales2,
255  0,
256  0,
257  *transPtr,
258  1,
259  false ) );
260 
261  /* Creating the output image */
262 
263  std::map<std::string, std::string> outputRasterInfo;
264  outputRasterInfo["URI"] = "terralib_unittest_rp_Blender_EqualizationTest_Test.tif";
265 
266  std::vector< te::rst::BandProperty* > bandsProperties;
267  for( unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
268  raster1Bands.size() ; ++inRasterBandsIdx )
269  {
270  bandsProperties.push_back( new te::rst::BandProperty(
271  *( inputRaster1Pointer->getBand( raster1Bands[ inRasterBandsIdx ] )->getProperty() ) ) );
272  }
273 
274  te::rst::Grid* gridPtr = new te::rst::Grid( *( inputRaster1Pointer->getGrid() ) );
275  gridPtr->setNumberOfColumns( gridPtr->getNumberOfColumns() * 2 );
276  gridPtr->setNumberOfRows( gridPtr->getNumberOfRows() * 2 );
277 
278  std::unique_ptr< te::rst::Raster > outRasterPtr( te::rst::RasterFactory::make(
279  "GDAL",
280  gridPtr,
281  bandsProperties,
282  outputRasterInfo,
283  0,
284  0 ) );
285 
286  BOOST_CHECK( outRasterPtr.get() );
287 
288  boost::scoped_array< double > values( new double[ outRasterPtr->getNumberOfBands() ] );
289  for( unsigned int row = 0 ; row < outRasterPtr->getNumberOfRows() ; ++row )
290  {
291  for( unsigned int col = 0 ; col < outRasterPtr->getNumberOfColumns() ; ++col )
292  {
293  blender.getBlendedValues( row, col, values.get() );
294 
295  for( unsigned int band = 0 ; band < outRasterPtr->getNumberOfBands() ; ++band )
296  {
297  outRasterPtr->setValue( col, row, values[ band ], band );
298  }
299  }
300  }
301 }
302 
303 BOOST_AUTO_TEST_CASE(pixelByPixelEucBlend_test)
304 {
305  /* Openning input rasters */
306 
307  std::map<std::string, std::string> auxRasterInfo;
308 
309  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop2.tif";
310  std::unique_ptr< te::rst::Raster > inputRaster1Pointer ( te::rst::RasterFactory::open(
311  auxRasterInfo ) );
312  BOOST_CHECK( inputRaster1Pointer.get() );
313 
314  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop1.tif";
315  std::unique_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
316  auxRasterInfo ) );
317  BOOST_CHECK( inputRaster2Pointer.get() );
318 
319  /* Creating blender parameters */
320 
321  std::vector< unsigned int > raster1Bands;
322  raster1Bands.push_back( 0 );
323  raster1Bands.push_back( 1 );
324  raster1Bands.push_back( 2 );
325 
326  std::vector< unsigned int > raster2Bands;
327  raster2Bands.push_back( 1 );
328  raster2Bands.push_back( 2 );
329  raster2Bands.push_back( 0 );
330 
331  const std::vector< double > pixelOffsets( 3, 0.0 );
332  const std::vector< double > pixelScales( 3, 1.0 );
333 
334  te::gm::GTParameters transParams;
335  transParams.m_tiePoints.push_back( te::gm::GTParameters::TiePoint(
336  te::gm::Coord2D( 292, 538 ), te::gm::Coord2D( 0, 0 ) ) );
337  transParams.m_tiePoints.push_back(
340  transParams.m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
341  transParams.m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
342  ),
344  inputRaster2Pointer->getNumberOfColumns() - 1,
345  inputRaster2Pointer->getNumberOfRows() - 1 )
346  )
347  );
348  std::unique_ptr< te::gm::GeometricTransformation > transPtr(
349  te::gm::GTFactory::make( "RST" ) );
350  BOOST_CHECK( transPtr->initialize( transParams ) );
351 
352  /* Initiating the blender instance */
353 
354  te::rp::Blender blender;
355 
356  BOOST_CHECK( blender.initialize(
357  *inputRaster1Pointer,
358  raster1Bands,
359  *inputRaster2Pointer,
360  raster2Bands,
364  0.0,
365  false,
366  false,
367  pixelOffsets,
368  pixelScales,
369  pixelOffsets,
370  pixelScales,
371  0,
372  0,
373  *transPtr,
374  1,
375  false ) );
376 
377  /* Creating the output image */
378 
379  std::map<std::string, std::string> outputRasterInfo;
380  outputRasterInfo["URI"] = "terralib_unittest_rp_Blender_PixelByPixelEucBlendTest_Test.tif";
381 
382  std::vector< te::rst::BandProperty* > bandsProperties;
383  for( unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
384  raster1Bands.size() ; ++inRasterBandsIdx )
385  {
386  bandsProperties.push_back( new te::rst::BandProperty(
387  *( inputRaster1Pointer->getBand( raster1Bands[ inRasterBandsIdx ] )->getProperty() ) ) );
388  }
389 
390  te::rst::Grid* gridPtr = new te::rst::Grid( *( inputRaster1Pointer->getGrid() ) );
391  gridPtr->setNumberOfColumns( gridPtr->getNumberOfColumns() * 2 );
392  gridPtr->setNumberOfRows( gridPtr->getNumberOfRows() * 2 );
393 
394  std::unique_ptr< te::rst::Raster > outRasterPtr( te::rst::RasterFactory::make(
395  "GDAL",
396  gridPtr,
397  bandsProperties,
398  outputRasterInfo,
399  0,
400  0 ) );
401 
402  BOOST_CHECK( outRasterPtr.get() );
403 
404  boost::scoped_array< double > values( new double[ outRasterPtr->getNumberOfBands() ] );
405  for( unsigned int row = 0 ; row < outRasterPtr->getNumberOfRows() ; ++row )
406  {
407  for( unsigned int col = 0 ; col < outRasterPtr->getNumberOfColumns() ; ++col )
408  {
409  blender.getBlendedValues( row, col, values.get() );
410 
411  for( unsigned int band = 0 ; band < outRasterPtr->getNumberOfBands() ; ++band )
412  {
413  outRasterPtr->setValue( col, row, values[ band ], band );
414  }
415  }
416  }
417 }
418 
419 BOOST_AUTO_TEST_CASE(pixelByPixelSumBlend_test)
420 {
421  /* Openning input rasters */
422 
423  std::map<std::string, std::string> auxRasterInfo;
424 
425  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop2.tif";
426  std::unique_ptr< te::rst::Raster > inputRaster1Pointer ( te::rst::RasterFactory::open(
427  auxRasterInfo ) );
428  BOOST_CHECK( inputRaster1Pointer.get() );
429 
430  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop1.tif";
431  std::unique_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
432  auxRasterInfo ) );
433  BOOST_CHECK( inputRaster2Pointer.get() );
434 
435  /* Creating blender parameters */
436 
437  std::vector< unsigned int > raster1Bands;
438  raster1Bands.push_back( 0 );
439  raster1Bands.push_back( 1 );
440  raster1Bands.push_back( 2 );
441 
442  std::vector< unsigned int > raster2Bands;
443  raster2Bands.push_back( 1 );
444  raster2Bands.push_back( 2 );
445  raster2Bands.push_back( 0 );
446 
447  const std::vector< double > pixelOffsets( 3, 0.0 );
448  const std::vector< double > pixelScales( 3, 0.5 );
449 
450  te::gm::GTParameters transParams;
451  transParams.m_tiePoints.push_back( te::gm::GTParameters::TiePoint(
452  te::gm::Coord2D( 292, 538 ), te::gm::Coord2D( 0, 0 ) ) );
453  transParams.m_tiePoints.push_back(
456  transParams.m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
457  transParams.m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
458  ),
460  inputRaster2Pointer->getNumberOfColumns() - 1,
461  inputRaster2Pointer->getNumberOfRows() - 1 )
462  )
463  );
464  std::unique_ptr< te::gm::GeometricTransformation > transPtr(
465  te::gm::GTFactory::make( "RST" ) );
466  BOOST_CHECK( transPtr->initialize( transParams ) );
467 
468  /* Initiating the blender instance */
469 
470  te::rp::Blender blender;
471 
472  BOOST_CHECK( blender.initialize(
473  *inputRaster1Pointer,
474  raster1Bands,
475  *inputRaster2Pointer,
476  raster2Bands,
480  0.0,
481  false,
482  false,
483  pixelOffsets,
484  pixelScales,
485  pixelOffsets,
486  pixelScales,
487  0,
488  0,
489  *transPtr,
490  1,
491  false ) );
492 
493  /* Creating the output image */
494 
495  std::map<std::string, std::string> outputRasterInfo;
496  outputRasterInfo["URI"] = "terralib_unittest_rp_Blender_PixelByPixelSumBlendTest_Test.tif";
497 
498  std::vector< te::rst::BandProperty* > bandsProperties;
499  for( unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
500  raster1Bands.size() ; ++inRasterBandsIdx )
501  {
502  bandsProperties.push_back( new te::rst::BandProperty(
503  *( inputRaster1Pointer->getBand( raster1Bands[ inRasterBandsIdx ] )->getProperty() ) ) );
504  }
505 
506  te::rst::Grid* gridPtr = new te::rst::Grid( *( inputRaster1Pointer->getGrid() ) );
507  gridPtr->setNumberOfColumns( gridPtr->getNumberOfColumns() * 2 );
508  gridPtr->setNumberOfRows( gridPtr->getNumberOfRows() * 2 );
509 
510  std::unique_ptr< te::rst::Raster > outRasterPtr( te::rst::RasterFactory::make(
511  "GDAL",
512  gridPtr,
513  bandsProperties,
514  outputRasterInfo,
515  0,
516  0 ) );
517 
518  BOOST_CHECK( outRasterPtr.get() );
519 
520  boost::scoped_array< double > values( new double[ outRasterPtr->getNumberOfBands() ] );
521  for( unsigned int row = 0 ; row < outRasterPtr->getNumberOfRows() ; ++row )
522  {
523  for( unsigned int col = 0 ; col < outRasterPtr->getNumberOfColumns() ; ++col )
524  {
525  blender.getBlendedValues( row, col, values.get() );
526 
527  for( unsigned int band = 0 ; band < outRasterPtr->getNumberOfBands() ; ++band )
528  {
529  outRasterPtr->setValue( col, row, values[ band ], band );
530  }
531  }
532  }
533 }
534 
535 BOOST_AUTO_TEST_CASE(fullRasterBlend_test)
536 {
537  /* Progress interface */
538 
539  te::common::ConsoleProgressViewer progressViewerInstance;
540 
541  /* Openning input rasters */
542 
543  std::map<std::string, std::string> auxRasterInfo;
544 
545  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop2.tif";
546  std::unique_ptr< te::rst::Raster > inputRaster1Pointer ( te::rst::RasterFactory::open(
547  auxRasterInfo ) );
548  BOOST_CHECK( inputRaster1Pointer.get() );
549 
550  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop1.tif";
551  std::unique_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
552  auxRasterInfo ) );
553  BOOST_CHECK( inputRaster2Pointer.get() );
554 
555  /* Creating the valid area delimiters */
556 
557  std::unique_ptr< te::gm::MultiPolygon > r1ValidDataDelimiterPtr(
559  inputRaster1Pointer->getSRID(), 0 ) );
560  {
561  const double& LLX = inputRaster1Pointer->getGrid()->getExtent()->m_llx;
562  const double& LLY = inputRaster1Pointer->getGrid()->getExtent()->m_lly;
563  const double& URX = inputRaster1Pointer->getGrid()->getExtent()->m_urx;
564  const double& URY = inputRaster1Pointer->getGrid()->getExtent()->m_ury;
565  const int& SRID = inputRaster1Pointer->getSRID();
566 
567  te::gm::LinearRing* ringPtr = new te::gm::LinearRing( 5,
568  te::gm::LineStringType, SRID, 0 );
569  ringPtr = new te::gm::LinearRing(5, te::gm::LineStringType, SRID);
570  ringPtr->setPoint( 0, LLX, URY );
571  ringPtr->setPoint( 1, URX, URY );
572  ringPtr->setPoint( 2, URX, LLY );
573  ringPtr->setPoint( 3, LLX, LLY );
574  ringPtr->setPoint( 4, LLX, URY );
575 
576  te::gm::Polygon* polPtr = new te::gm::Polygon( 0, te::gm::PolygonType, SRID, 0 );
577  polPtr->add( ringPtr );
578 
579  r1ValidDataDelimiterPtr->add( polPtr );
580  }
581 
582  std::unique_ptr< te::gm::MultiPolygon > r2ValidDataDelimiterPtr(
584  inputRaster2Pointer->getSRID(), 0 ) );
585  {
586  const double& LLX = inputRaster2Pointer->getGrid()->getExtent()->m_llx;
587  const double& LLY = inputRaster2Pointer->getGrid()->getExtent()->m_lly;
588  const double& URX = inputRaster2Pointer->getGrid()->getExtent()->m_urx;
589  const double& URY = inputRaster2Pointer->getGrid()->getExtent()->m_ury;
590  const int& SRID = inputRaster2Pointer->getSRID();
591 
592  te::gm::LinearRing* ringPtr = new te::gm::LinearRing( 5,
593  te::gm::LineStringType, SRID, 0 );
594  ringPtr = new te::gm::LinearRing(5, te::gm::LineStringType, SRID);
595  ringPtr->setPoint( 0, LLX, URY );
596  ringPtr->setPoint( 1, URX, URY );
597  ringPtr->setPoint( 2, URX, LLY );
598  ringPtr->setPoint( 3, LLX, LLY );
599  ringPtr->setPoint( 4, LLX, URY );
600 
601  te::gm::Polygon* polPtr = new te::gm::Polygon( 0, te::gm::PolygonType, SRID, 0 );
602  polPtr->add( ringPtr );
603 
604  r2ValidDataDelimiterPtr->add( polPtr );
605  }
606 
607  /* Creating the output image */
608 
609  std::unique_ptr< te::rst::Raster > outRasterPtr;
610 
611  {
612  std::map<std::string, std::string> outputRasterInfo;
613  outputRasterInfo["URI"] = "terralib_unittest_rp_Blender_FullRasterBlendTest_Test.tif";
614 
615  te::rst::Grid* gridPtr = new te::rst::Grid(
616  *( inputRaster1Pointer->getGrid() ) );
617  gridPtr->setNumberOfColumns( inputRaster1Pointer->getGrid()->getNumberOfColumns() * 2 );
618  gridPtr->setNumberOfRows( inputRaster1Pointer->getGrid()->getNumberOfRows() * 2 );
619 
620  std::vector< te::rst::BandProperty* > bandsProperties;
621  for( unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
622  inputRaster1Pointer->getNumberOfBands() ; ++inRasterBandsIdx )
623  {
624  bandsProperties.push_back( new te::rst::BandProperty(
625  *( inputRaster1Pointer->getBand( 0 )->getProperty() ) ) );
626  bandsProperties[ inRasterBandsIdx ]->m_blkh = 1;
627  bandsProperties[ inRasterBandsIdx ]->m_blkw = gridPtr->getNumberOfColumns();
628  bandsProperties[ inRasterBandsIdx ]->m_nblocksx = 1;
629  bandsProperties[ inRasterBandsIdx ]->m_nblocksy = gridPtr->getNumberOfRows();
630  bandsProperties[ inRasterBandsIdx ]->m_noDataValue = 0.0;
631  }
632 
633  outRasterPtr.reset( te::rst::RasterFactory::make(
634  "GDAL",
635  gridPtr,
636  bandsProperties,
637  outputRasterInfo,
638  0,
639  0 ) );
640  BOOST_CHECK( outRasterPtr.get() );
641 
642  double uLX = 0;
643  double uLY = 0;
644  inputRaster1Pointer->getGrid()->gridToGeo( 0, 0, uLX, uLY );
645 
646  double outULCol = 0;
647  double outULRow = 0;
648  outRasterPtr->getGrid()->geoToGrid( uLX, uLY, outULCol, outULRow );
649 
650  const unsigned int inputNRows = inputRaster1Pointer->getNumberOfRows();
651  const unsigned int inputNCols = inputRaster1Pointer->getNumberOfColumns();
652  const unsigned int outputNRows = outRasterPtr->getNumberOfRows();
653  const unsigned int outputNCols = outRasterPtr->getNumberOfColumns();
654  unsigned int row = 0;
655  unsigned int col = 0;
656  double value = 0;
657  double outNoDataValue = 0;
658 
659  for( unsigned int band = 0; band < inputRaster1Pointer->getNumberOfBands();
660  ++band )
661  {
662  outNoDataValue = outRasterPtr->getBand( band )->getProperty()->m_noDataValue;
663 
664  for( row = 0 ; row < outputNRows ; ++row )
665  {
666  for( col = 0; col < outputNCols ; ++col )
667  {
668  outRasterPtr->setValue( col, row, outNoDataValue, band );
669  }
670  }
671 
672  for( row = 0 ; row < inputNRows ; ++row )
673  {
674  for( col = 0; col < inputNCols ; ++col )
675  {
676  inputRaster1Pointer->getValue( col, row, value, band );
677  outRasterPtr->setValue((unsigned int)(col + outULCol), (unsigned int)(row + outULRow), value, band );
678  }
679  }
680  }
681  }
682 
683  /* Creating blender parameters */
684 
685  std::vector< unsigned int > raster1Bands;
686  raster1Bands.push_back( 0 );
687  raster1Bands.push_back( 1 );
688  raster1Bands.push_back( 2 );
689 
690  std::vector< unsigned int > raster2Bands;
691  raster2Bands.push_back( 1 );
692  raster2Bands.push_back( 2 );
693  raster2Bands.push_back( 0 );
694 
695  const std::vector< double > pixelOffsets( 3, 0.0 );
696  const std::vector< double > pixelScales( 3, 1.0 );
697 
698  te::gm::GTParameters transParams;
699  transParams.m_tiePoints.push_back( te::gm::GTParameters::TiePoint(
700  te::gm::Coord2D( 292, 538 ), te::gm::Coord2D( 0, 0 ) ) );
701  transParams.m_tiePoints.push_back(
704  transParams.m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
705  transParams.m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
706  ),
708  inputRaster2Pointer->getNumberOfColumns() - 1,
709  inputRaster2Pointer->getNumberOfRows() - 1 )
710  )
711  );
712  std::unique_ptr< te::gm::GeometricTransformation > transPtr(
713  te::gm::GTFactory::make( "RST" ) );
714  BOOST_CHECK( transPtr->initialize( transParams ) );
715 
716  /* Initiating the blender instance */
717 
718  te::rp::Blender blender;
719 
720  BOOST_CHECK( blender.initialize(
721  *outRasterPtr,
722  raster1Bands,
723  *inputRaster2Pointer,
724  raster2Bands,
728  0.0,
729  false,
730  false,
731  pixelOffsets,
732  pixelScales,
733  pixelOffsets,
734  pixelScales,
735  r1ValidDataDelimiterPtr.get(),
736  r2ValidDataDelimiterPtr.get(),
737  *transPtr,
738  1,
739  true ) );
740 
741  BOOST_CHECK( blender.blendIntoRaster1() );
742 }
743 
744 BOOST_AUTO_TEST_CASE(threadedFullRasterBlend_test)
745 {
746  /* Progress interface */
747 
748  te::common::ConsoleProgressViewer progressViewerInstance;
749 
750  /* Openning input rasters */
751 
752  std::map<std::string, std::string> auxRasterInfo;
753 
754  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop2.tif";
755  std::unique_ptr< te::rst::Raster > inputRaster1Pointer ( te::rst::RasterFactory::open(
756  auxRasterInfo ) );
757  BOOST_CHECK( inputRaster1Pointer.get() );
758 
759  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop1.tif";
760  std::unique_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
761  auxRasterInfo ) );
762  BOOST_CHECK( inputRaster2Pointer.get() );
763 
764  /* Creating the valid area delimiters */
765 
766  std::unique_ptr< te::gm::MultiPolygon > r1ValidDataDelimiterPtr(
768  inputRaster1Pointer->getSRID(), 0 ) );
769  {
770  const double& LLX = inputRaster1Pointer->getGrid()->getExtent()->m_llx;
771  const double& LLY = inputRaster1Pointer->getGrid()->getExtent()->m_lly;
772  const double& URX = inputRaster1Pointer->getGrid()->getExtent()->m_urx;
773  const double& URY = inputRaster1Pointer->getGrid()->getExtent()->m_ury;
774  const int& SRID = inputRaster1Pointer->getSRID();
775 
776  te::gm::LinearRing* ringPtr = new te::gm::LinearRing( 5,
777  te::gm::LineStringType, SRID, 0 );
778  ringPtr = new te::gm::LinearRing(5, te::gm::LineStringType, SRID);
779  ringPtr->setPoint( 0, LLX, URY );
780  ringPtr->setPoint( 1, URX, URY );
781  ringPtr->setPoint( 2, URX, LLY );
782  ringPtr->setPoint( 3, LLX, LLY );
783  ringPtr->setPoint( 4, LLX, URY );
784 
785  te::gm::Polygon* polPtr = new te::gm::Polygon( 0, te::gm::PolygonType, SRID, 0 );
786  polPtr->add( ringPtr );
787 
788  r1ValidDataDelimiterPtr->add( polPtr );
789  }
790 
791  std::unique_ptr< te::gm::MultiPolygon > r2ValidDataDelimiterPtr(
793  inputRaster2Pointer->getSRID(), 0 ) );
794  {
795  const double& LLX = inputRaster2Pointer->getGrid()->getExtent()->m_llx;
796  const double& LLY = inputRaster2Pointer->getGrid()->getExtent()->m_lly;
797  const double& URX = inputRaster2Pointer->getGrid()->getExtent()->m_urx;
798  const double& URY = inputRaster2Pointer->getGrid()->getExtent()->m_ury;
799  const int& SRID = inputRaster2Pointer->getSRID();
800 
801  te::gm::LinearRing* ringPtr = new te::gm::LinearRing( 5,
802  te::gm::LineStringType, SRID, 0 );
803  ringPtr = new te::gm::LinearRing(5, te::gm::LineStringType, SRID);
804  ringPtr->setPoint( 0, LLX, URY );
805  ringPtr->setPoint( 1, URX, URY );
806  ringPtr->setPoint( 2, URX, LLY );
807  ringPtr->setPoint( 3, LLX, LLY );
808  ringPtr->setPoint( 4, LLX, URY );
809 
810  te::gm::Polygon* polPtr = new te::gm::Polygon( 0, te::gm::PolygonType, SRID, 0 );
811  polPtr->add( ringPtr );
812 
813  r2ValidDataDelimiterPtr->add( polPtr );
814  }
815 
816  /* Creating the output image */
817 
818  std::unique_ptr< te::rst::Raster > outRasterPtr;
819 
820  {
821  std::map<std::string, std::string> outputRasterInfo;
822  outputRasterInfo["URI"] = "terralib_unittest_rp_Blender_ThreadedFullRasterBlendTest_Test.tif";
823 
824  te::rst::Grid* gridPtr = new te::rst::Grid( *( inputRaster1Pointer->getGrid() ) );
825  gridPtr->setNumberOfColumns( inputRaster1Pointer->getGrid()->getNumberOfColumns() * 2 );
826  gridPtr->setNumberOfRows( inputRaster1Pointer->getGrid()->getNumberOfRows() * 2 );
827 
828  std::vector< te::rst::BandProperty* > bandsProperties;
829  for( unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
830  inputRaster1Pointer->getNumberOfBands() ; ++inRasterBandsIdx )
831  {
832  bandsProperties.push_back( new te::rst::BandProperty(
833  *( inputRaster1Pointer->getBand( 0 )->getProperty() ) ) );
834  bandsProperties[ inRasterBandsIdx ]->m_blkh = 1;
835  bandsProperties[ inRasterBandsIdx ]->m_blkw = gridPtr->getNumberOfColumns();
836  bandsProperties[ inRasterBandsIdx ]->m_nblocksx = 1;
837  bandsProperties[ inRasterBandsIdx ]->m_nblocksy = gridPtr->getNumberOfRows();
838  bandsProperties[ inRasterBandsIdx ]->m_noDataValue = 0.0;
839  }
840 
841  outRasterPtr.reset( te::rst::RasterFactory::make(
842  "GDAL",
843  gridPtr,
844  bandsProperties,
845  outputRasterInfo,
846  0,
847  0 ) );
848  BOOST_CHECK( outRasterPtr.get() );
849 
850  double uLX = 0;
851  double uLY = 0;
852  inputRaster1Pointer->getGrid()->gridToGeo( 0, 0, uLX, uLY );
853 
854  double outULCol = 0;
855  double outULRow = 0;
856  outRasterPtr->getGrid()->geoToGrid( uLX, uLY, outULCol, outULRow );
857 
858  const unsigned int inputNRows = inputRaster1Pointer->getNumberOfRows();
859  const unsigned int inputNCols = inputRaster1Pointer->getNumberOfColumns();
860  const unsigned int outputNRows = outRasterPtr->getNumberOfRows();
861  const unsigned int outputNCols = outRasterPtr->getNumberOfColumns();
862  unsigned int row = 0;
863  unsigned int col = 0;
864  double value = 0;
865  double outNoDataValue = 0;
866 
867  for( unsigned int band = 0; band < inputRaster1Pointer->getNumberOfBands();
868  ++band )
869  {
870  outNoDataValue = outRasterPtr->getBand( band )->getProperty()->m_noDataValue;
871 
872  for( row = 0 ; row < outputNRows ; ++row )
873  {
874  for( col = 0; col < outputNCols ; ++col )
875  {
876  outRasterPtr->setValue( col, row, outNoDataValue, band );
877  }
878  }
879 
880  for( row = 0 ; row < inputNRows ; ++row )
881  {
882  for( col = 0; col < inputNCols ; ++col )
883  {
884  inputRaster1Pointer->getValue( col, row, value, band );
885  outRasterPtr->setValue( (unsigned int)(col + outULCol), (unsigned int)(row + outULRow), value, band );
886  }
887  }
888  }
889  }
890 
891  /* Creating blender parameters */
892 
893  std::vector< unsigned int > raster1Bands;
894  raster1Bands.push_back( 0 );
895  raster1Bands.push_back( 1 );
896  raster1Bands.push_back( 2 );
897 
898  std::vector< unsigned int > raster2Bands;
899  raster2Bands.push_back( 1 );
900  raster2Bands.push_back( 2 );
901  raster2Bands.push_back( 0 );
902 
903  const std::vector< double > pixelOffsets( 3, 0.0 );
904  const std::vector< double > pixelScales( 3, 1.0 );
905 
906  te::gm::GTParameters transParams;
907  transParams.m_tiePoints.push_back( te::gm::GTParameters::TiePoint(
908  te::gm::Coord2D( 292, 538 ), te::gm::Coord2D( 0, 0 ) ) );
909  transParams.m_tiePoints.push_back(
912  transParams.m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
913  transParams.m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
914  ),
916  inputRaster2Pointer->getNumberOfColumns() - 1,
917  inputRaster2Pointer->getNumberOfRows() - 1 )
918  )
919  );
920  std::unique_ptr< te::gm::GeometricTransformation > transPtr(
921  te::gm::GTFactory::make( "RST" ) );
922  BOOST_CHECK( transPtr->initialize( transParams ) );
923 
924  /* Initiating the blender instance */
925 
926  te::rp::Blender blender;
927 
928  BOOST_CHECK( blender.initialize(
929  *outRasterPtr,
930  raster1Bands,
931  *inputRaster2Pointer,
932  raster2Bands,
936  0.0,
937  false,
938  false,
939  pixelOffsets,
940  pixelScales,
941  pixelOffsets,
942  pixelScales,
943  r1ValidDataDelimiterPtr.get(),
944  r2ValidDataDelimiterPtr.get(),
945  *transPtr,
946  0,
947  true ) );
948 
949  BOOST_CHECK( blender.blendIntoRaster1() );
950 }
951 
952 BOOST_AUTO_TEST_CASE(pixelByPixelMaxBlend_test)
953 {
954  /* Openning input rasters */
955 
956  std::map<std::string, std::string> auxRasterInfo;
957 
958  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop2.tif";
959  std::unique_ptr< te::rst::Raster > inputRaster1Pointer ( te::rst::RasterFactory::open(
960  auxRasterInfo ) );
961  BOOST_CHECK( inputRaster1Pointer.get() );
962 
963  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop1.tif";
964  std::unique_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
965  auxRasterInfo ) );
966  BOOST_CHECK( inputRaster2Pointer.get() );
967 
968  /* Creating blender parameters */
969 
970  std::vector< unsigned int > raster1Bands;
971  raster1Bands.push_back( 0 );
972  raster1Bands.push_back( 1 );
973  raster1Bands.push_back( 2 );
974 
975  std::vector< unsigned int > raster2Bands;
976  raster2Bands.push_back( 1 );
977  raster2Bands.push_back( 2 );
978  raster2Bands.push_back( 0 );
979 
980  const std::vector< double > pixelOffsets( 3, 0.0 );
981  const std::vector< double > pixelScales( 3, 0.5 );
982 
983  te::gm::GTParameters transParams;
984  transParams.m_tiePoints.push_back( te::gm::GTParameters::TiePoint(
985  te::gm::Coord2D( 292, 538 ), te::gm::Coord2D( 0, 0 ) ) );
986  transParams.m_tiePoints.push_back(
989  transParams.m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
990  transParams.m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
991  ),
993  inputRaster2Pointer->getNumberOfColumns() - 1,
994  inputRaster2Pointer->getNumberOfRows() - 1 )
995  )
996  );
997  std::unique_ptr< te::gm::GeometricTransformation > transPtr(
998  te::gm::GTFactory::make( "RST" ) );
999  BOOST_CHECK( transPtr->initialize( transParams ) );
1000 
1001  /* Initiating the blender instance */
1002 
1003  te::rp::Blender blender;
1004 
1005  BOOST_CHECK( blender.initialize(
1006  *inputRaster1Pointer,
1007  raster1Bands,
1008  *inputRaster2Pointer,
1009  raster2Bands,
1013  0.0,
1014  false,
1015  false,
1016  pixelOffsets,
1017  pixelScales,
1018  pixelOffsets,
1019  pixelScales,
1020  0,
1021  0,
1022  *transPtr,
1023  1,
1024  false ) );
1025 
1026  /* Creating the output image */
1027 
1028  std::map<std::string, std::string> outputRasterInfo;
1029  outputRasterInfo["URI"] = "terralib_unittest_rp_Blender_PixelByPixelMaxBlendTest_Test.tif";
1030 
1031  std::vector< te::rst::BandProperty* > bandsProperties;
1032  for( unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
1033  raster1Bands.size() ; ++inRasterBandsIdx )
1034  {
1035  bandsProperties.push_back( new te::rst::BandProperty(
1036  *( inputRaster1Pointer->getBand( raster1Bands[ inRasterBandsIdx ] )->getProperty() ) ) );
1037  }
1038 
1039  te::rst::Grid* gridPtr = new te::rst::Grid( *( inputRaster1Pointer->getGrid() ) );
1040  gridPtr->setNumberOfColumns( gridPtr->getNumberOfColumns() * 2 );
1041  gridPtr->setNumberOfRows( gridPtr->getNumberOfRows() * 2 );
1042 
1043  std::unique_ptr< te::rst::Raster > outRasterPtr( te::rst::RasterFactory::make(
1044  "GDAL",
1045  gridPtr,
1046  bandsProperties,
1047  outputRasterInfo,
1048  0,
1049  0 ) );
1050 
1051  BOOST_CHECK( outRasterPtr.get() );
1052 
1053  boost::scoped_array< double > values( new double[ outRasterPtr->getNumberOfBands() ] );
1054  for( unsigned int row = 0 ; row < outRasterPtr->getNumberOfRows() ; ++row )
1055  {
1056  for( unsigned int col = 0 ; col < outRasterPtr->getNumberOfColumns() ; ++col )
1057  {
1058  blender.getBlendedValues( row, col, values.get() );
1059 
1060  for( unsigned int band = 0 ; band < outRasterPtr->getNumberOfBands() ; ++band )
1061  {
1062  outRasterPtr->setValue( col, row, values[ band ], band );
1063  }
1064  }
1065  }
1066 }
1067 
1068 BOOST_AUTO_TEST_CASE(pixelByPixelMinBlend_test)
1069 {
1070  /* Openning input rasters */
1071 
1072  std::map<std::string, std::string> auxRasterInfo;
1073 
1074  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop2.tif";
1075  std::unique_ptr< te::rst::Raster > inputRaster1Pointer ( te::rst::RasterFactory::open(
1076  auxRasterInfo ) );
1077  BOOST_CHECK( inputRaster1Pointer.get() );
1078 
1079  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/cbers_rgb342_crop1.tif";
1080  std::unique_ptr< te::rst::Raster > inputRaster2Pointer ( te::rst::RasterFactory::open(
1081  auxRasterInfo ) );
1082  BOOST_CHECK( inputRaster2Pointer.get() );
1083 
1084  /* Creating blender parameters */
1085 
1086  std::vector< unsigned int > raster1Bands;
1087  raster1Bands.push_back( 0 );
1088  raster1Bands.push_back( 1 );
1089  raster1Bands.push_back( 2 );
1090 
1091  std::vector< unsigned int > raster2Bands;
1092  raster2Bands.push_back( 1 );
1093  raster2Bands.push_back( 2 );
1094  raster2Bands.push_back( 0 );
1095 
1096  const std::vector< double > pixelOffsets( 3, 0.0 );
1097  const std::vector< double > pixelScales( 3, 0.5 );
1098 
1099  te::gm::GTParameters transParams;
1100  transParams.m_tiePoints.push_back( te::gm::GTParameters::TiePoint(
1101  te::gm::Coord2D( 292, 538 ), te::gm::Coord2D( 0, 0 ) ) );
1102  transParams.m_tiePoints.push_back(
1104  te::gm::Coord2D(
1105  transParams.m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
1106  transParams.m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
1107  ),
1108  te::gm::Coord2D(
1109  inputRaster2Pointer->getNumberOfColumns() - 1,
1110  inputRaster2Pointer->getNumberOfRows() - 1 )
1111  )
1112  );
1113  std::unique_ptr< te::gm::GeometricTransformation > transPtr(
1114  te::gm::GTFactory::make( "RST" ) );
1115  BOOST_CHECK( transPtr->initialize( transParams ) );
1116 
1117  /* Initiating the blender instance */
1118 
1119  te::rp::Blender blender;
1120 
1121  BOOST_CHECK( blender.initialize(
1122  *inputRaster1Pointer,
1123  raster1Bands,
1124  *inputRaster2Pointer,
1125  raster2Bands,
1129  0.0,
1130  false,
1131  false,
1132  pixelOffsets,
1133  pixelScales,
1134  pixelOffsets,
1135  pixelScales,
1136  0,
1137  0,
1138  *transPtr,
1139  1,
1140  false ) );
1141 
1142  /* Creating the output image */
1143 
1144  std::map<std::string, std::string> outputRasterInfo;
1145  outputRasterInfo["URI"] = "terralib_unittest_rp_Blender_PixelByPixelMinBlendTest_Test.tif";
1146 
1147  std::vector< te::rst::BandProperty* > bandsProperties;
1148  for( unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
1149  raster1Bands.size() ; ++inRasterBandsIdx )
1150  {
1151  bandsProperties.push_back( new te::rst::BandProperty(
1152  *( inputRaster1Pointer->getBand( raster1Bands[ inRasterBandsIdx ] )->getProperty() ) ) );
1153  }
1154 
1155  te::rst::Grid* gridPtr = new te::rst::Grid( *( inputRaster1Pointer->getGrid() ) );
1156  gridPtr->setNumberOfColumns( gridPtr->getNumberOfColumns() * 2 );
1157  gridPtr->setNumberOfRows( gridPtr->getNumberOfRows() * 2 );
1158 
1159  std::unique_ptr< te::rst::Raster > outRasterPtr( te::rst::RasterFactory::make(
1160  "GDAL",
1161  gridPtr,
1162  bandsProperties,
1163  outputRasterInfo,
1164  0,
1165  0 ) );
1166 
1167  BOOST_CHECK( outRasterPtr.get() );
1168 
1169  boost::scoped_array< double > values( new double[ outRasterPtr->getNumberOfBands() ] );
1170  for( unsigned int row = 0 ; row < outRasterPtr->getNumberOfRows() ; ++row )
1171  {
1172  for( unsigned int col = 0 ; col < outRasterPtr->getNumberOfColumns() ; ++col )
1173  {
1174  blender.getBlendedValues( row, col, values.get() );
1175 
1176  for( unsigned int band = 0 ; band < outRasterPtr->getNumberOfBands() ; ++band )
1177  {
1178  outRasterPtr->setValue( col, row, values[ band ], band );
1179  }
1180  }
1181  }
1182 }
1183 
1184 BOOST_AUTO_TEST_SUITE_END()
bool GetMeanValue(const te::rst::Band &band, const unsigned int maxThreads, double &meanValue)
Get the mean of band pixel values.
unsigned int getNumberOfRows() const
Returns the grid number of rows.
void add(Curve *ring)
It adds the ring to the curve polygon.
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
unsigned int band
Near neighborhood interpolation method.
Keep the maximum value of two overlapping pixels.
Definition: Blender.h:69
std::vector< TiePoint > m_tiePoints
Tie points.
Definition: GTParameters.h:95
BOOST_AUTO_TEST_SUITE(blender_tests) BOOST_AUTO_TEST_CASE(pixelByPixelNoBlend_test)
Definition: TsBlender.cpp:41
A raster band description.
Definition: BandProperty.h:61
Blended pixel value calculation for two overlaped rasters.
Definition: Blender.h:58
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
No blending performed.
Definition: Blender.h:66
std::pair< Coord2D, Coord2D > TiePoint
Tie point type definition.
Definition: GTParameters.h:59
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
Pixels will be summed inside the raster overlapped area.
Definition: Blender.h:68
Keep the minimum value of two overlapping pixels.
Definition: Blender.h:70
unsigned int getNumberOfColumns() const
Returns the grid number of columns.
This file contains include headers for the TerraLib Raster Processing module.
void setNumberOfRows(unsigned int nRows)
Sets the grid number of rows.
static GeometricTransformation * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
void setNumberOfColumns(unsigned int nCols)
Sets the grid number of columns.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
static Raster * make()
It creates and returns an empty raster with default raster driver.
Euclidean distance method.
Definition: Blender.h:67
2D Geometric transformation parameters.
Definition: GTParameters.h:50
This file contains include headers for the TerraLib Common Runtime module.
This file contains include headers for the Vector Geometry model of TerraLib.
A rectified grid is the spatial support for raster data.
Definition: raster/Grid.h:68
BOOST_AUTO_TEST_CASE(equalization_test)
Definition: TsBlender.cpp:159
unsigned int col
bool GetStdDevValue(const te::rst::Band &band, const unsigned int maxThreads, double const *const meanValuePtr, double &stdDevValue)
Get the standard deviation of band pixel values.
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.