1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
|
#define TEAGN_ENABLE_STDOUT_LOG
#include <TePDIExamplesBase.hpp>
#include <TePDIBlender.hpp>
#include <TePDIParameters.hpp>
#include <TeAgnostic.h>
#include <TePDIUtils.hpp>
#include <TePDIGeoMosaic.hpp>
#include <TePDIBatchGeoMosaic.hpp>
#include <TePDITPMosaic.hpp>
#include <TeInitRasterDecoders.h>
#include <TeProgress.h>
#include <TeStdIOProgress.h>
#include <vector>
void TPMosaic_test1()
{
// Initiating images
TePDITypes::TePDIRasterPtrType input_raster1( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop_C.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster1->init(),
"Unable to init input_raster1" );
TePDITypes::TePDIRasterPtrType input_raster2( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop_B_contraste.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster2->init(),
"Unable to init input_raster2" );
TePDITypes::TePDIRasterPtrType output_raster;
TEAGN_TRUE_OR_THROW( TePDIUtils::TeAllocRAMRaster( output_raster,
1, 1, 1, false, TeUNSIGNEDCHAR, 0 ), "output_raster Alloc error" );
// The geometric transformation parameters telling how the input rasters are
// overlapped
TeGTParams trans_params;
trans_params.transformation_name_ = "affine";
trans_params.out_rem_strat_ = TeGTParams::NoOutRemotion;
TeCoordPair auxPair;
auxPair.pt1.setXY( 36,234 ); // point over input image 1
auxPair.pt2.setXY( 245,21 ); // the corresponding point over input image 2
trans_params.tiepoints_.push_back( auxPair );
auxPair.pt1.setXY( 319,252 );
auxPair.pt2.setXY( 528,39 );
trans_params.tiepoints_.push_back( auxPair );
auxPair.pt1.setXY( 136,416 );
auxPair.pt2.setXY( 345,203 );
trans_params.tiepoints_.push_back( auxPair );
// Other parameters
std::vector< unsigned int > channels1;
channels1.push_back( 0 );
std::vector< unsigned int > channels2;
channels2.push_back( 0 );
// Creating algorithm parameters
TePDIParameters params;
params.SetParameter( "input_raster1" , input_raster1 );
params.SetParameter( "input_raster2" , input_raster2 );
params.SetParameter( "channels1" , channels1 );
params.SetParameter( "channels2" , channels2 );
params.SetParameter( "output_raster" , output_raster );
params.SetParameter( "trans_params" , trans_params );
params.SetParameter( "blend_method", TePDIBlender::EuclideanBlendMethod );
params.SetParameter( "interp_method", TePDIInterpolator::NNMethod );
params.SetParameter( "dummy_value" , (double)0.0 );
params.SetParameter( "auto_equalize" , (int)1 );
TePDITPMosaic mos;
TEAGN_TRUE_OR_THROW( mos.Apply( params ), "Apply error" );
TEAGN_TRUE_OR_THROW( TePDIUtils::TeRaster2Geotiff( output_raster,
TEPDIEXAMPLESBINPATH "TePDITPMosaic_test1.tif" ), "GeoTIF generation error" );
}
// non-overlapped images test (simulated)
void TPMosaic_test2()
{
// Initiating images
TePDITypes::TePDIRasterPtrType input_raster1( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster1->init(),
"Unable to init input_raster1" );
TePDITypes::TePDIRasterPtrType input_raster2( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop2.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster2->init(),
"Unable to init input_raster2" );
// pre-initializing the output raster
TeRasterParams outputRasterParams;
outputRasterParams.setDataType( TeUNSIGNEDCHAR, 1 );
outputRasterParams.setNLinesNColumns( 1, 1 );
outputRasterParams.nBands( 3 );
outputRasterParams.setPhotometric( TeRasterParams::TeRGB, -1 );
TePDITypes::TePDIRasterPtrType output_raster;
TEAGN_TRUE_OR_THROW( TePDIUtils::TeAllocRAMRaster( outputRasterParams,
output_raster ), "outputRaster creation error" );
// The geometric transformation parameters telling how the input rasters are
// overlapped
TeGTParams trans_params;
trans_params.transformation_name_ = "affine";
trans_params.out_rem_strat_ = TeGTParams::NoOutRemotion;
TeCoordPair auxPair;
auxPair.pt1.setXY( 885,0 ); // point over input image 1
auxPair.pt2.setXY( 0,0 ); // TopLeft - image 2
trans_params.tiepoints_.push_back( auxPair );
auxPair.pt1.setXY( 885 + 838,0 );
auxPair.pt2.setXY( 837,0 ); // TopRight - image 2
trans_params.tiepoints_.push_back( auxPair );
auxPair.pt1.setXY( 885,1009 );
auxPair.pt2.setXY( 0,1008 ); // LowerLeft - image 2
trans_params.tiepoints_.push_back( auxPair );
auxPair.pt1.setXY( 885 + 838,1009 );
auxPair.pt2.setXY( 837,1008 ); // LowerRight - image 2
trans_params.tiepoints_.push_back( auxPair );
// Other parameters
std::vector< unsigned int > channels1;
channels1.push_back( 0 );
channels1.push_back( 1 );
channels1.push_back( 2 );
std::vector< unsigned int > channels2;
channels2.push_back( 0 );
channels2.push_back( 1 );
channels2.push_back( 2 );
// Creating algorithm parameters
TePDIParameters params;
params.SetParameter( "input_raster1" , input_raster1 );
params.SetParameter( "input_raster2" , input_raster2 );
params.SetParameter( "channels1" , channels1 );
params.SetParameter( "channels2" , channels2 );
params.SetParameter( "output_raster" , output_raster );
params.SetParameter( "trans_params" , trans_params );
params.SetParameter( "blend_method", TePDIBlender::EuclideanBlendMethod );
params.SetParameter( "interp_method", TePDIInterpolator::NNMethod );
params.SetParameter( "dummy_value" , (double)0.0 );
params.SetParameter( "auto_equalize" , (int)1 );
TePDITPMosaic mos;
TEAGN_TRUE_OR_THROW( mos.Apply( params ), "Apply error" );
TEAGN_TRUE_OR_THROW( TePDIUtils::TeRaster2Geotiff( output_raster,
TEPDIEXAMPLESBINPATH "TePDITPMosaic_test2.tif" ), "GeoTIF generation error" );
}
void GeoMosaic_test1()
{
// Initiating images
TePDITypes::TePDIRasterPtrType input_raster1( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop_A.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster1->init(),
"Unable to init input_raster1" );
TePDITypes::TePDIRasterPtrType input_raster2( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop_B_contraste.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster2->init(),
"Unable to init input_raster2" );
TePDITypes::TePDIRasterPtrType output_raster;
TEAGN_TRUE_OR_THROW( TePDIUtils::TeAllocRAMRaster( output_raster,
1, 1, 1, false, TeUNSIGNEDCHAR, 0 ), "output_raster Alloc error" );
// Creating algorithm parameters
TePDIParameters params;
params.SetParameter( "blend_method", TePDIBlender::EuclideanBlendMethod );
params.SetParameter( "input_raster1" , input_raster1 );
params.SetParameter( "input_raster2" , input_raster2 );
params.SetParameter( "output_raster" , output_raster );
std::vector< unsigned int > channels1;
channels1.push_back( 0 );
params.SetParameter( "channels1" , channels1 );
std::vector< unsigned int > channels2;
channels2.push_back( 0 );
params.SetParameter( "channels2" , channels2 );
params.SetParameter( "interp_method", TePDIInterpolator::BilinearMethod );
params.SetParameter( "dummy_value" , (double)0. );
params.SetParameter( "auto_equalize" , (int)1 );
TePDIGeoMosaic mos;
TEAGN_TRUE_OR_THROW( mos.Apply( params ), "Apply error" );
TEAGN_TRUE_OR_THROW( TePDIUtils::TeRaster2Geotiff( output_raster,
TEPDIEXAMPLESBINPATH "TePDIGeoMosaic_test1.tif" ), "GeoTIF generation error" );
}
void GeoMosaic_test2()
{
// Initiating images
TePDITypes::TePDIRasterPtrType input_raster1( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop_C.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster1->init(),
"Unable to init input_raster1" );
TePDITypes::TePDIRasterPtrType input_raster2( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop_B_contraste.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster2->init(),
"Unable to init input_raster2" );
TePDITypes::TePDIRasterPtrType output_raster;
TEAGN_TRUE_OR_THROW( TePDIUtils::TeAllocRAMRaster( output_raster,
1, 1, 1, false, TeUNSIGNEDCHAR, 0 ), "output_raster Alloc error" );
// Creating algorithm parameters
TePDIParameters params;
params.SetParameter( "blend_method", TePDIBlender::EuclideanBlendMethod );
params.SetParameter( "input_raster1" , input_raster1 );
params.SetParameter( "input_raster2" , input_raster2 );
params.SetParameter( "output_raster" , output_raster );
std::vector< unsigned int > channels1;
channels1.push_back( 0 );
params.SetParameter( "channels1" , channels1 );
std::vector< unsigned int > channels2;
channels2.push_back( 0 );
params.SetParameter( "channels2" , channels2 );
params.SetParameter( "interp_method", TePDIInterpolator::BilinearMethod );
params.SetParameter( "dummy_value" , (double)0. );
params.SetParameter( "auto_equalize" , (int)1 );
TePDIGeoMosaic mos;
TEAGN_TRUE_OR_THROW( mos.Apply( params ), "Apply error" );
TEAGN_TRUE_OR_THROW( TePDIUtils::TeRaster2Geotiff( output_raster,
TEPDIEXAMPLESBINPATH "TePDIGeoMosaic_test2.tif" ), "GeoTIF generation error" );
}
// Non-overlapped images test
void GeoMosaic_test3()
{
// Initiating images
TePDITypes::TePDIRasterPtrType input_raster1( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip0_0.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster1->init(),
"Unable to init input_raster1" );
TePDITypes::TePDIRasterPtrType input_raster2( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip500_500.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster2->init(),
"Unable to init input_raster2" );
// pre-initializing the output raster
TeRasterParams outputRasterParams;
outputRasterParams.setDataType( TeUNSIGNEDCHAR, 1 );
outputRasterParams.setNLinesNColumns( 1, 1 );
outputRasterParams.nBands( 3 );
outputRasterParams.setPhotometric( TeRasterParams::TeRGB, -1 );
TePDITypes::TePDIRasterPtrType output_raster;
TEAGN_TRUE_OR_THROW( TePDIUtils::TeAllocRAMRaster( outputRasterParams,
output_raster ), "outputRaster creation error" );
// Creating algorithm parameters
TePDIParameters params;
params.SetParameter( "blend_method", TePDIBlender::EuclideanBlendMethod );
params.SetParameter( "input_raster1" , input_raster1 );
params.SetParameter( "input_raster2" , input_raster2 );
params.SetParameter( "output_raster" , output_raster );
std::vector< unsigned int > channels1;
channels1.push_back( 0 );
channels1.push_back( 1 );
channels1.push_back( 2 );
params.SetParameter( "channels1" , channels1 );
std::vector< unsigned int > channels2;
channels2.push_back( 0 );
channels2.push_back( 1 );
channels2.push_back( 2 );
params.SetParameter( "channels2" , channels2 );
params.SetParameter( "interp_method", TePDIInterpolator::BilinearMethod );
params.SetParameter( "dummy_value" , (double)0. );
//params.SetParameter( "auto_equalize" , (int)1 );
TePDIGeoMosaic mos;
TEAGN_TRUE_OR_THROW( mos.Apply( params ), "Apply error" );
TEAGN_TRUE_OR_THROW( TePDIUtils::TeRaster2Geotiff( output_raster,
TEPDIEXAMPLESBINPATH "TePDIGeoMosaic_test3.tif" ), "GeoTIF generation error" );
}
// Testing images with different resolutions
void GeoMosaic_test4()
{
// Initiating images
TePDITypes::TePDIRasterPtrType input_raster1( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_halfsampled_cropB.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster1->init(),
"Unable to init input_raster1" );
TePDITypes::TePDIRasterPtrType input_raster2( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_cropA.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster2->init(),
"Unable to init input_raster2" );
TePDITypes::TePDIRasterPtrType output_raster;
TEAGN_TRUE_OR_THROW( TePDIUtils::TeAllocRAMRaster( output_raster,
1, 1, 1, false, TeUNSIGNEDCHAR, 0 ), "output_raster Alloc error" );
// Creating algorithm parameters
TePDIParameters params;
params.SetParameter( "blend_method", TePDIBlender::EuclideanBlendMethod );
params.SetParameter( "input_raster1" , input_raster1 );
params.SetParameter( "input_raster2" , input_raster2 );
params.SetParameter( "output_raster" , output_raster );
std::vector< unsigned int > channels1;
channels1.push_back( 2 );
params.SetParameter( "channels1" , channels1 );
std::vector< unsigned int > channels2;
channels2.push_back( 0 );
params.SetParameter( "channels2" , channels2 );
params.SetParameter( "interp_method", TePDIInterpolator::NNMethod );
params.SetParameter( "dummy_value" , (double)0. );
//params.SetParameter( "auto_equalize" , (int)1 );
TePDIGeoMosaic mos;
TEAGN_TRUE_OR_THROW( mos.Apply( params ), "Apply error" );
TEAGN_TRUE_OR_THROW( TePDIUtils::TeRaster2Geotiff( output_raster,
TEPDIEXAMPLESBINPATH "TePDIGeoMosaic_test4.tif" ), "GeoTIF generation error" );
}
void BatchGeoMosaic_test1()
{
TePDIParameters params1;
/* Building rasters */
TePDITypes::TePDIRasterPtrType input_raster1( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop_A.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster1->init(),
"Unable to init input_raster1" );
TePDITypes::TePDIRasterPtrType input_raster2( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop_B_contraste.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster2->init(),
"Unable to init input_raster2" );
TePDITypes::TePDIRasterPtrType input_raster3( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_b2_crop_C.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster3->init(),
"Unable to init input_raster2" );
std::vector< unsigned int > bands;
bands.push_back( 0 ); // from raster 1
bands.push_back( 0 ); // from raster 2
bands.push_back( 0 ); // from raster 3
TePDITypes::TePDIRasterPtrType output_raster;
TEAGN_TRUE_OR_THROW( TePDIUtils::TeAllocRAMRaster( output_raster,
1, 1, 1, false, TeDOUBLE, 0 ), "output_raster Alloc error" );
TePDITypes::TePDIRasterVectorType input_rasters;
input_rasters.push_back( input_raster1 );
input_rasters.push_back( input_raster2 );
input_rasters.push_back( input_raster3 );
// Building algorithm parameters
TePDIParameters params;
params.SetParameter( "input_rasters" , input_rasters );
params.SetParameter( "bands" , bands );
params.SetParameter( "output_raster" , output_raster );
params.SetParameter( "blend_method", TePDIBlender::EuclideanBlendMethod );
params.SetParameter( "interp_method", TePDIInterpolator::BilinearMethod );
params.SetParameter( "dummy_value" , (double)0. );
params.SetParameter( "auto_equalize" , (int)1 );
TePDIBatchGeoMosaic mos;
TEAGN_TRUE_OR_THROW( mos.Apply( params ), "Apply error" );
TEAGN_TRUE_OR_THROW( TePDIUtils::TeRaster2Geotiff( output_raster,
TEPDIEXAMPLESBINPATH "TePDIBatchGeoMosaic_test1.tif" ),
"GeoTIF generation error" );
}
// Non-overlapped images test
void BatchGeoMosaic_test2()
{
TePDIParameters params1;
/* Initializing input rasters */
TePDITypes::TePDIRasterPtrType input_raster1( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip0_0.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster1->init(),
"Unable to init input raster" );
TePDITypes::TePDIRasterPtrType input_raster2( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip0_250.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster2->init(),
"Unable to init input raster" );
TePDITypes::TePDIRasterPtrType input_raster3( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip0_500.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster3->init(),
"Unable to init input raster" );
TePDITypes::TePDIRasterPtrType input_raster4( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip0_750.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster4->init(),
"Unable to init input raster" );
TePDITypes::TePDIRasterPtrType input_raster5( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip250_0.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster5->init(),
"Unable to init input raster" );
TePDITypes::TePDIRasterPtrType input_raster6( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip250_250.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster6->init(),
"Unable to init input raster" );
TePDITypes::TePDIRasterPtrType input_raster7( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip250_500.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster7->init(),
"Unable to init input raster" );
TePDITypes::TePDIRasterPtrType input_raster8( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip250_750.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster8->init(),
"Unable to init input raster" );
TePDITypes::TePDIRasterPtrType input_raster9( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip500_0.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster9->init(),
"Unable to init input raster" );
TePDITypes::TePDIRasterPtrType input_raster10( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip500_250.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster10->init(),
"Unable to init input raster" );
TePDITypes::TePDIRasterPtrType input_raster11( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip500_500.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster11->init(),
"Unable to init input raster" );
TePDITypes::TePDIRasterPtrType input_raster12( new TeRaster(
std::string( TEPDIEXAMPLESRESPATH "cbers_rgb342_crop1_chip500_750.tif" ), 'r' ) );
TEAGN_TRUE_OR_THROW( input_raster12->init(),
"Unable to init input raster" );
// Input bands from each raster
std::vector< unsigned int > bands;
bands.push_back( 0 ); // from raster 0
bands.push_back( 1 ); // from raster 0
bands.push_back( 2 ); // from raster 0
bands.push_back( 0 ); // from raster 1
bands.push_back( 1 ); // from raster 1
bands.push_back( 2 ); // from raster 1
bands.push_back( 0 ); // from raster 2
bands.push_back( 1 ); // from raster 2
bands.push_back( 2 ); // from raster 2
bands.push_back( 0 );
bands.push_back( 1 );
bands.push_back( 2 );
bands.push_back( 0 );
bands.push_back( 1 );
bands.push_back( 2 );
bands.push_back( 0 );
bands.push_back( 1 );
bands.push_back( 2 );
bands.push_back( 0 );
bands.push_back( 1 );
bands.push_back( 2 );
bands.push_back( 0 );
bands.push_back( 1 );
bands.push_back( 2 );
bands.push_back( 0 );
bands.push_back( 1 );
bands.push_back( 2 );
bands.push_back( 0 );
bands.push_back( 1 );
bands.push_back( 2 );
bands.push_back( 0 );
bands.push_back( 1 );
bands.push_back( 2 );
bands.push_back( 0 );
bands.push_back( 1 );
bands.push_back( 2 );
// pre-initializing the output raster
TeRasterParams outputRasterParams;
outputRasterParams.setDataType( TeUNSIGNEDCHAR, 1 );
outputRasterParams.setNLinesNColumns( 1, 1 );
outputRasterParams.nBands( 3 );
outputRasterParams.setPhotometric( TeRasterParams::TeRGB, -1 );
TePDITypes::TePDIRasterPtrType output_raster;
TEAGN_TRUE_OR_THROW( TePDIUtils::TeAllocRAMRaster( outputRasterParams,
output_raster ), "outputRaster creation error" );
// Creating the input rasters pointers vector
TePDITypes::TePDIRasterVectorType input_rasters;
input_rasters.push_back( input_raster1 );
input_rasters.push_back( input_raster2 );
input_rasters.push_back( input_raster3 );
input_rasters.push_back( input_raster4 );
input_rasters.push_back( input_raster5 );
input_rasters.push_back( input_raster6 );
input_rasters.push_back( input_raster7 );
input_rasters.push_back( input_raster8 );
input_rasters.push_back( input_raster9 );
input_rasters.push_back( input_raster10 );
input_rasters.push_back( input_raster11 );
input_rasters.push_back( input_raster12 );
// Building algorithm parameters
TePDIParameters params;
params.SetParameter( "input_rasters" , input_rasters );
params.SetParameter( "bands" , bands );
params.SetParameter( "output_raster" , output_raster );
params.SetParameter( "blend_method", TePDIBlender::NoBlendMethod );
//params.SetParameter( "blend_method", TePDIBlender::MeanBlendMethod );
//params.SetParameter( "blend_method", TePDIBlender::EuclideanBlendMethod );
//params.SetParameter( "interp_method", TePDIInterpolator::NNMethod );
//params.SetParameter( "interp_method", TePDIInterpolator::BilinearMethod );
params.SetParameter( "interp_method", TePDIInterpolator::BicubicMethod );
params.SetParameter( "dummy_value" , (double)0. );
params.SetParameter( "auto_equalize" , (int)1 );
TePDIBatchGeoMosaic mos;
TEAGN_TRUE_OR_THROW( mos.Apply( params ), "Apply error" );
TEAGN_TRUE_OR_THROW( TePDIUtils::TeRaster2Geotiff( output_raster,
TEPDIEXAMPLESBINPATH "TePDIBatchGeoMosaic_test2.tif" ),
"GeoTIF generation error" );
}
int main()
{
TEAGN_LOGMSG( "Test started." );
TeStdIOProgress pi;
TeProgress::setProgressInterf( dynamic_cast< TeProgressBase* >( &pi ) );
GeoMosaic_test4();
BatchGeoMosaic_test2();
GeoMosaic_test3();
TPMosaic_test2();
TPMosaic_test1();
GeoMosaic_test1();
GeoMosaic_test2();
BatchGeoMosaic_test1();
TEAGN_LOGMSG( "Test OK." );
return EXIT_SUCCESS;
}
|