27 #include "../Config.h" 37 #define BOOST_TEST_NO_MAIN 38 #include <boost/test/unit_test.hpp> 39 #include <boost/scoped_array.hpp> 47 std::map<std::string, std::string> auxRasterInfo;
49 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop2.tif";
52 BOOST_CHECK( inputRaster1Pointer.get() );
54 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop1.tif";
57 BOOST_CHECK( inputRaster2Pointer.get() );
61 std::vector< unsigned int > raster1Bands;
62 raster1Bands.push_back( 0 );
63 raster1Bands.push_back( 1 );
64 raster1Bands.push_back( 2 );
66 std::vector< unsigned int > raster2Bands;
67 raster2Bands.push_back( 1 );
68 raster2Bands.push_back( 2 );
69 raster2Bands.push_back( 0 );
71 const std::vector< double > pixelOffsets( 3, 0.0 );
72 const std::vector< double > pixelScales( 3, 1.0 );
80 transParams.
m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
81 transParams.
m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
84 inputRaster2Pointer->getNumberOfColumns() - 1,
85 inputRaster2Pointer->getNumberOfRows() - 1 )
88 std::unique_ptr< te::gm::GeometricTransformation > transPtr(
90 BOOST_CHECK( transPtr->initialize( transParams ) );
96 BOOST_CHECK( blender.initialize(
119 std::map<std::string, std::string> outputRasterInfo;
120 outputRasterInfo[
"URI"] =
"terralib_unittest_rp_Blender_PixelByPixelNoBlendTest_Test.tif";
122 std::vector< te::rst::BandProperty* > bandsProperties;
123 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
124 raster1Bands.size() ; ++inRasterBandsIdx )
127 *( inputRaster1Pointer->getBand( raster1Bands[ inRasterBandsIdx ] )->getProperty() ) ) );
142 BOOST_CHECK( outRasterPtr.get() );
144 boost::scoped_array< double > values(
new double[ outRasterPtr->getNumberOfBands() ] );
145 for(
unsigned int row = 0 ; row < outRasterPtr->getNumberOfRows() ; ++row )
147 for(
unsigned int col = 0 ;
col < outRasterPtr->getNumberOfColumns() ; ++
col )
149 blender.getBlendedValues( row,
col, values.get() );
151 for(
unsigned int band = 0 ;
band < outRasterPtr->getNumberOfBands() ; ++
band )
153 outRasterPtr->setValue(
col, row, values[
band ], band );
163 std::map<std::string, std::string> auxRasterInfo;
165 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop2.tif";
168 BOOST_CHECK( inputRaster1Pointer.get() );
170 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop1.tif";
173 BOOST_CHECK( inputRaster2Pointer.get() );
177 std::vector< unsigned int > raster1Bands;
178 raster1Bands.push_back( 0 );
179 raster1Bands.push_back( 1 );
180 raster1Bands.push_back( 2 );
182 std::vector< unsigned int > raster2Bands;
183 raster2Bands.push_back( 1 );
184 raster2Bands.push_back( 2 );
185 raster2Bands.push_back( 0 );
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() );
196 for(
unsigned int raster1BandsIdx = 0 ; raster1BandsIdx < raster1Bands.size() ;
199 unsigned int band1Idx = raster1Bands[ raster1BandsIdx ];
200 unsigned int band2Idx = raster2Bands[ raster1BandsIdx ];
203 means1[ raster1BandsIdx ] );
205 &means1[ raster1BandsIdx ], stddevs1[ raster1BandsIdx ] );
208 means2[ raster1BandsIdx ] );
210 &means2[ raster1BandsIdx ], stddevs2[ raster1BandsIdx ] );
212 pixelScales2[ raster1BandsIdx ] = stddevs1[ raster1BandsIdx ] /
213 stddevs2[ raster1BandsIdx ];
214 pixelOffsets2[ raster1BandsIdx ] = means1[ raster1BandsIdx ] -
215 ( pixelScales2[ raster1BandsIdx ] * means2[ raster1BandsIdx ] );
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
228 inputRaster2Pointer->getNumberOfColumns() - 1,
229 inputRaster2Pointer->getNumberOfRows() - 1 )
232 std::unique_ptr< te::gm::GeometricTransformation > transPtr(
234 BOOST_CHECK( transPtr->initialize( transParams ) );
240 BOOST_CHECK( blender.initialize(
241 *inputRaster1Pointer,
243 *inputRaster2Pointer,
263 std::map<std::string, std::string> outputRasterInfo;
264 outputRasterInfo[
"URI"] =
"terralib_unittest_rp_Blender_EqualizationTest_Test.tif";
266 std::vector< te::rst::BandProperty* > bandsProperties;
267 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
268 raster1Bands.size() ; ++inRasterBandsIdx )
271 *( inputRaster1Pointer->getBand( raster1Bands[ inRasterBandsIdx ] )->getProperty() ) ) );
286 BOOST_CHECK( outRasterPtr.get() );
288 boost::scoped_array< double > values(
new double[ outRasterPtr->getNumberOfBands() ] );
289 for(
unsigned int row = 0 ; row < outRasterPtr->getNumberOfRows() ; ++row )
291 for(
unsigned int col = 0 ;
col < outRasterPtr->getNumberOfColumns() ; ++
col )
293 blender.getBlendedValues( row,
col, values.get() );
295 for(
unsigned int band = 0 ;
band < outRasterPtr->getNumberOfBands() ; ++
band )
297 outRasterPtr->setValue(
col, row, values[
band ], band );
307 std::map<std::string, std::string> auxRasterInfo;
309 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop2.tif";
312 BOOST_CHECK( inputRaster1Pointer.get() );
314 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop1.tif";
317 BOOST_CHECK( inputRaster2Pointer.get() );
321 std::vector< unsigned int > raster1Bands;
322 raster1Bands.push_back( 0 );
323 raster1Bands.push_back( 1 );
324 raster1Bands.push_back( 2 );
326 std::vector< unsigned int > raster2Bands;
327 raster2Bands.push_back( 1 );
328 raster2Bands.push_back( 2 );
329 raster2Bands.push_back( 0 );
331 const std::vector< double > pixelOffsets( 3, 0.0 );
332 const std::vector< double > pixelScales( 3, 1.0 );
340 transParams.
m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
341 transParams.
m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
344 inputRaster2Pointer->getNumberOfColumns() - 1,
345 inputRaster2Pointer->getNumberOfRows() - 1 )
348 std::unique_ptr< te::gm::GeometricTransformation > transPtr(
350 BOOST_CHECK( transPtr->initialize( transParams ) );
356 BOOST_CHECK( blender.initialize(
357 *inputRaster1Pointer,
359 *inputRaster2Pointer,
379 std::map<std::string, std::string> outputRasterInfo;
380 outputRasterInfo[
"URI"] =
"terralib_unittest_rp_Blender_PixelByPixelEucBlendTest_Test.tif";
382 std::vector< te::rst::BandProperty* > bandsProperties;
383 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
384 raster1Bands.size() ; ++inRasterBandsIdx )
387 *( inputRaster1Pointer->getBand( raster1Bands[ inRasterBandsIdx ] )->getProperty() ) ) );
402 BOOST_CHECK( outRasterPtr.get() );
404 boost::scoped_array< double > values(
new double[ outRasterPtr->getNumberOfBands() ] );
405 for(
unsigned int row = 0 ; row < outRasterPtr->getNumberOfRows() ; ++row )
407 for(
unsigned int col = 0 ;
col < outRasterPtr->getNumberOfColumns() ; ++
col )
409 blender.getBlendedValues( row,
col, values.get() );
411 for(
unsigned int band = 0 ;
band < outRasterPtr->getNumberOfBands() ; ++
band )
413 outRasterPtr->setValue(
col, row, values[
band ], band );
423 std::map<std::string, std::string> auxRasterInfo;
425 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop2.tif";
428 BOOST_CHECK( inputRaster1Pointer.get() );
430 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop1.tif";
433 BOOST_CHECK( inputRaster2Pointer.get() );
437 std::vector< unsigned int > raster1Bands;
438 raster1Bands.push_back( 0 );
439 raster1Bands.push_back( 1 );
440 raster1Bands.push_back( 2 );
442 std::vector< unsigned int > raster2Bands;
443 raster2Bands.push_back( 1 );
444 raster2Bands.push_back( 2 );
445 raster2Bands.push_back( 0 );
447 const std::vector< double > pixelOffsets( 3, 0.0 );
448 const std::vector< double > pixelScales( 3, 0.5 );
456 transParams.
m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
457 transParams.
m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
460 inputRaster2Pointer->getNumberOfColumns() - 1,
461 inputRaster2Pointer->getNumberOfRows() - 1 )
464 std::unique_ptr< te::gm::GeometricTransformation > transPtr(
466 BOOST_CHECK( transPtr->initialize( transParams ) );
472 BOOST_CHECK( blender.initialize(
473 *inputRaster1Pointer,
475 *inputRaster2Pointer,
495 std::map<std::string, std::string> outputRasterInfo;
496 outputRasterInfo[
"URI"] =
"terralib_unittest_rp_Blender_PixelByPixelSumBlendTest_Test.tif";
498 std::vector< te::rst::BandProperty* > bandsProperties;
499 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
500 raster1Bands.size() ; ++inRasterBandsIdx )
503 *( inputRaster1Pointer->getBand( raster1Bands[ inRasterBandsIdx ] )->getProperty() ) ) );
518 BOOST_CHECK( outRasterPtr.get() );
520 boost::scoped_array< double > values(
new double[ outRasterPtr->getNumberOfBands() ] );
521 for(
unsigned int row = 0 ; row < outRasterPtr->getNumberOfRows() ; ++row )
523 for(
unsigned int col = 0 ;
col < outRasterPtr->getNumberOfColumns() ; ++
col )
525 blender.getBlendedValues( row,
col, values.get() );
527 for(
unsigned int band = 0 ;
band < outRasterPtr->getNumberOfBands() ; ++
band )
529 outRasterPtr->setValue(
col, row, values[
band ], band );
543 std::map<std::string, std::string> auxRasterInfo;
545 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop2.tif";
548 BOOST_CHECK( inputRaster1Pointer.get() );
550 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop1.tif";
553 BOOST_CHECK( inputRaster2Pointer.get() );
557 std::unique_ptr< te::gm::MultiPolygon > r1ValidDataDelimiterPtr(
559 inputRaster1Pointer->getSRID(), 0 ) );
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();
577 polPtr->
add( ringPtr );
579 r1ValidDataDelimiterPtr->add( polPtr );
582 std::unique_ptr< te::gm::MultiPolygon > r2ValidDataDelimiterPtr(
584 inputRaster2Pointer->getSRID(), 0 ) );
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();
602 polPtr->
add( ringPtr );
604 r2ValidDataDelimiterPtr->add( polPtr );
609 std::unique_ptr< te::rst::Raster > outRasterPtr;
612 std::map<std::string, std::string> outputRasterInfo;
613 outputRasterInfo[
"URI"] =
"terralib_unittest_rp_Blender_FullRasterBlendTest_Test.tif";
616 *( inputRaster1Pointer->getGrid() ) );
617 gridPtr->
setNumberOfColumns( inputRaster1Pointer->getGrid()->getNumberOfColumns() * 2 );
618 gridPtr->
setNumberOfRows( inputRaster1Pointer->getGrid()->getNumberOfRows() * 2 );
620 std::vector< te::rst::BandProperty* > bandsProperties;
621 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
622 inputRaster1Pointer->getNumberOfBands() ; ++inRasterBandsIdx )
625 *( inputRaster1Pointer->getBand( 0 )->getProperty() ) ) );
626 bandsProperties[ inRasterBandsIdx ]->m_blkh = 1;
628 bandsProperties[ inRasterBandsIdx ]->m_nblocksx = 1;
629 bandsProperties[ inRasterBandsIdx ]->m_nblocksy = gridPtr->
getNumberOfRows();
630 bandsProperties[ inRasterBandsIdx ]->m_noDataValue = 0.0;
640 BOOST_CHECK( outRasterPtr.get() );
644 inputRaster1Pointer->getGrid()->gridToGeo( 0, 0, uLX, uLY );
648 outRasterPtr->getGrid()->geoToGrid( uLX, uLY, outULCol, outULRow );
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;
657 double outNoDataValue = 0;
659 for(
unsigned int band = 0;
band < inputRaster1Pointer->getNumberOfBands();
662 outNoDataValue = outRasterPtr->getBand(
band )->getProperty()->m_noDataValue;
664 for( row = 0 ; row < outputNRows ; ++row )
666 for( col = 0; col < outputNCols ; ++
col )
668 outRasterPtr->setValue( col, row, outNoDataValue,
band );
672 for( row = 0 ; row < inputNRows ; ++row )
674 for( col = 0; col < inputNCols ; ++
col )
676 inputRaster1Pointer->getValue( col, row, value,
band );
677 outRasterPtr->setValue((
unsigned int)(col + outULCol), (
unsigned int)(row + outULRow), value,
band );
685 std::vector< unsigned int > raster1Bands;
686 raster1Bands.push_back( 0 );
687 raster1Bands.push_back( 1 );
688 raster1Bands.push_back( 2 );
690 std::vector< unsigned int > raster2Bands;
691 raster2Bands.push_back( 1 );
692 raster2Bands.push_back( 2 );
693 raster2Bands.push_back( 0 );
695 const std::vector< double > pixelOffsets( 3, 0.0 );
696 const std::vector< double > pixelScales( 3, 1.0 );
704 transParams.
m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
705 transParams.
m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
708 inputRaster2Pointer->getNumberOfColumns() - 1,
709 inputRaster2Pointer->getNumberOfRows() - 1 )
712 std::unique_ptr< te::gm::GeometricTransformation > transPtr(
714 BOOST_CHECK( transPtr->initialize( transParams ) );
720 BOOST_CHECK( blender.initialize(
723 *inputRaster2Pointer,
735 r1ValidDataDelimiterPtr.get(),
736 r2ValidDataDelimiterPtr.get(),
741 BOOST_CHECK( blender.blendIntoRaster1() );
752 std::map<std::string, std::string> auxRasterInfo;
754 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop2.tif";
757 BOOST_CHECK( inputRaster1Pointer.get() );
759 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop1.tif";
762 BOOST_CHECK( inputRaster2Pointer.get() );
766 std::unique_ptr< te::gm::MultiPolygon > r1ValidDataDelimiterPtr(
768 inputRaster1Pointer->getSRID(), 0 ) );
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();
786 polPtr->
add( ringPtr );
788 r1ValidDataDelimiterPtr->add( polPtr );
791 std::unique_ptr< te::gm::MultiPolygon > r2ValidDataDelimiterPtr(
793 inputRaster2Pointer->getSRID(), 0 ) );
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();
811 polPtr->
add( ringPtr );
813 r2ValidDataDelimiterPtr->add( polPtr );
818 std::unique_ptr< te::rst::Raster > outRasterPtr;
821 std::map<std::string, std::string> outputRasterInfo;
822 outputRasterInfo[
"URI"] =
"terralib_unittest_rp_Blender_ThreadedFullRasterBlendTest_Test.tif";
825 gridPtr->
setNumberOfColumns( inputRaster1Pointer->getGrid()->getNumberOfColumns() * 2 );
826 gridPtr->
setNumberOfRows( inputRaster1Pointer->getGrid()->getNumberOfRows() * 2 );
828 std::vector< te::rst::BandProperty* > bandsProperties;
829 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
830 inputRaster1Pointer->getNumberOfBands() ; ++inRasterBandsIdx )
833 *( inputRaster1Pointer->getBand( 0 )->getProperty() ) ) );
834 bandsProperties[ inRasterBandsIdx ]->m_blkh = 1;
836 bandsProperties[ inRasterBandsIdx ]->m_nblocksx = 1;
837 bandsProperties[ inRasterBandsIdx ]->m_nblocksy = gridPtr->
getNumberOfRows();
838 bandsProperties[ inRasterBandsIdx ]->m_noDataValue = 0.0;
848 BOOST_CHECK( outRasterPtr.get() );
852 inputRaster1Pointer->getGrid()->gridToGeo( 0, 0, uLX, uLY );
856 outRasterPtr->getGrid()->geoToGrid( uLX, uLY, outULCol, outULRow );
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;
865 double outNoDataValue = 0;
867 for(
unsigned int band = 0;
band < inputRaster1Pointer->getNumberOfBands();
870 outNoDataValue = outRasterPtr->getBand(
band )->getProperty()->m_noDataValue;
872 for( row = 0 ; row < outputNRows ; ++row )
874 for( col = 0; col < outputNCols ; ++
col )
876 outRasterPtr->setValue( col, row, outNoDataValue,
band );
880 for( row = 0 ; row < inputNRows ; ++row )
882 for( col = 0; col < inputNCols ; ++
col )
884 inputRaster1Pointer->getValue( col, row, value,
band );
885 outRasterPtr->setValue( (
unsigned int)(col + outULCol), (
unsigned int)(row + outULRow), value,
band );
893 std::vector< unsigned int > raster1Bands;
894 raster1Bands.push_back( 0 );
895 raster1Bands.push_back( 1 );
896 raster1Bands.push_back( 2 );
898 std::vector< unsigned int > raster2Bands;
899 raster2Bands.push_back( 1 );
900 raster2Bands.push_back( 2 );
901 raster2Bands.push_back( 0 );
903 const std::vector< double > pixelOffsets( 3, 0.0 );
904 const std::vector< double > pixelScales( 3, 1.0 );
912 transParams.
m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
913 transParams.
m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
916 inputRaster2Pointer->getNumberOfColumns() - 1,
917 inputRaster2Pointer->getNumberOfRows() - 1 )
920 std::unique_ptr< te::gm::GeometricTransformation > transPtr(
922 BOOST_CHECK( transPtr->initialize( transParams ) );
928 BOOST_CHECK( blender.initialize(
931 *inputRaster2Pointer,
943 r1ValidDataDelimiterPtr.get(),
944 r2ValidDataDelimiterPtr.get(),
949 BOOST_CHECK( blender.blendIntoRaster1() );
956 std::map<std::string, std::string> auxRasterInfo;
958 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop2.tif";
961 BOOST_CHECK( inputRaster1Pointer.get() );
963 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop1.tif";
966 BOOST_CHECK( inputRaster2Pointer.get() );
970 std::vector< unsigned int > raster1Bands;
971 raster1Bands.push_back( 0 );
972 raster1Bands.push_back( 1 );
973 raster1Bands.push_back( 2 );
975 std::vector< unsigned int > raster2Bands;
976 raster2Bands.push_back( 1 );
977 raster2Bands.push_back( 2 );
978 raster2Bands.push_back( 0 );
980 const std::vector< double > pixelOffsets( 3, 0.0 );
981 const std::vector< double > pixelScales( 3, 0.5 );
989 transParams.
m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
990 transParams.
m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
993 inputRaster2Pointer->getNumberOfColumns() - 1,
994 inputRaster2Pointer->getNumberOfRows() - 1 )
997 std::unique_ptr< te::gm::GeometricTransformation > transPtr(
999 BOOST_CHECK( transPtr->initialize( transParams ) );
1005 BOOST_CHECK( blender.initialize(
1006 *inputRaster1Pointer,
1008 *inputRaster2Pointer,
1028 std::map<std::string, std::string> outputRasterInfo;
1029 outputRasterInfo[
"URI"] =
"terralib_unittest_rp_Blender_PixelByPixelMaxBlendTest_Test.tif";
1031 std::vector< te::rst::BandProperty* > bandsProperties;
1032 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
1033 raster1Bands.size() ; ++inRasterBandsIdx )
1036 *( inputRaster1Pointer->getBand( raster1Bands[ inRasterBandsIdx ] )->getProperty() ) ) );
1051 BOOST_CHECK( outRasterPtr.get() );
1053 boost::scoped_array< double > values(
new double[ outRasterPtr->getNumberOfBands() ] );
1054 for(
unsigned int row = 0 ; row < outRasterPtr->getNumberOfRows() ; ++row )
1056 for(
unsigned int col = 0 ;
col < outRasterPtr->getNumberOfColumns() ; ++
col )
1058 blender.getBlendedValues( row,
col, values.get() );
1060 for(
unsigned int band = 0 ;
band < outRasterPtr->getNumberOfBands() ; ++
band )
1062 outRasterPtr->setValue(
col, row, values[
band ], band );
1072 std::map<std::string, std::string> auxRasterInfo;
1074 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop2.tif";
1077 BOOST_CHECK( inputRaster1Pointer.get() );
1079 auxRasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers_rgb342_crop1.tif";
1082 BOOST_CHECK( inputRaster2Pointer.get() );
1086 std::vector< unsigned int > raster1Bands;
1087 raster1Bands.push_back( 0 );
1088 raster1Bands.push_back( 1 );
1089 raster1Bands.push_back( 2 );
1091 std::vector< unsigned int > raster2Bands;
1092 raster2Bands.push_back( 1 );
1093 raster2Bands.push_back( 2 );
1094 raster2Bands.push_back( 0 );
1096 const std::vector< double > pixelOffsets( 3, 0.0 );
1097 const std::vector< double > pixelScales( 3, 0.5 );
1105 transParams.
m_tiePoints[ 0 ].first.x + inputRaster2Pointer->getNumberOfColumns() - 1,
1106 transParams.
m_tiePoints[ 0 ].first.y + inputRaster2Pointer->getNumberOfRows() - 1
1109 inputRaster2Pointer->getNumberOfColumns() - 1,
1110 inputRaster2Pointer->getNumberOfRows() - 1 )
1113 std::unique_ptr< te::gm::GeometricTransformation > transPtr(
1115 BOOST_CHECK( transPtr->initialize( transParams ) );
1121 BOOST_CHECK( blender.initialize(
1122 *inputRaster1Pointer,
1124 *inputRaster2Pointer,
1144 std::map<std::string, std::string> outputRasterInfo;
1145 outputRasterInfo[
"URI"] =
"terralib_unittest_rp_Blender_PixelByPixelMinBlendTest_Test.tif";
1147 std::vector< te::rst::BandProperty* > bandsProperties;
1148 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
1149 raster1Bands.size() ; ++inRasterBandsIdx )
1152 *( inputRaster1Pointer->getBand( raster1Bands[ inRasterBandsIdx ] )->getProperty() ) ) );
1167 BOOST_CHECK( outRasterPtr.get() );
1169 boost::scoped_array< double > values(
new double[ outRasterPtr->getNumberOfBands() ] );
1170 for(
unsigned int row = 0 ; row < outRasterPtr->getNumberOfRows() ; ++row )
1172 for(
unsigned int col = 0 ;
col < outRasterPtr->getNumberOfColumns() ; ++
col )
1174 blender.getBlendedValues( row,
col, values.get() );
1176 for(
unsigned int band = 0 ;
band < outRasterPtr->getNumberOfBands() ; ++
band )
1178 outRasterPtr->setValue(
col, row, values[
band ], band );
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.
Near neighborhood interpolation method.
Keep the maximum value of two overlapping pixels.
std::vector< TiePoint > m_tiePoints
Tie points.
BOOST_AUTO_TEST_SUITE(blender_tests) BOOST_AUTO_TEST_CASE(pixelByPixelNoBlend_test)
A raster band description.
Blended pixel value calculation for two overlaped rasters.
An utility struct for representing 2D coordinates.
std::pair< Coord2D, Coord2D > TiePoint
Tie point type definition.
A LinearRing is a LineString that is both closed and simple.
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.
Keep the minimum value of two overlapping pixels.
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.
static Raster * make()
It creates and returns an empty raster with default raster driver.
Euclidean distance method.
2D Geometric transformation parameters.
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.
BOOST_AUTO_TEST_CASE(equalization_test)
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.