===== RP → Mosaic =====
This module implements algorithms to create a mosaic from a set of rasters.
Image mosaic refer to that multi images, which are shot in
the same or different shooting condition and have overlapped
regions, are stitched and combined to a image to enlarge the
field of vision that a image can cover.
==== Geo Mosaic ====
Create a mosaic from a set of geo-referenced rasters.
{{:wiki:designimplementation:rp:geomosaic.jpg?400|}}
== Example of use ==
// Openning 3 input RGB images
te::rst::Raster inputRaster1;
...
te::rst::Raster inputRaster2;
...
te::rst::Raster inputRaster3;
...
// Creating the algorithm parameters
te::rp::GeoMosaic::InputParameters algoInputParams;
std::vector< const te::rst::Raster* > rasters;
rasters.push_back( &inputRaster1 );
rasters.push_back( &inputRaster2 );
rasters.push_back( &inputRaster3 );
te::rp::FeederConstRasterVector feeder( rasters );
algoInputParams.m_feederRasterPtr = &feeder;
// Input raster 1 bands to mosaic
std::vector< unsigned int > bands1;
bands1.push_back( 0 );
bands1.push_back( 1 );
bands1.push_back( 2 );
algoInputParams.m_inputRastersBands.push_back( bands1 );
// Input raster 2 bands to mosaic
std::vector< unsigned int > bands2;
bands2.push_back( 0 );
bands2.push_back( 1 );
bands2.push_back( 2 );
algoInputParams.m_inputRastersBands.push_back( bands2 );
// Input raster 3 bands to mosaic
std::vector< unsigned int > bands3;
bands3.push_back( 0 );
bands3.push_back( 1 );
bands3.push_back( 2 );
algoInputParams.m_inputRastersBands.push_back( bands3 );
te::rp::GeoMosaic::OutputParameters algoOutputParams;
// The output raster info
algoOutputParams.m_rInfo["URI"] = "Mosaic.tif";
algoOutputParams.m_rType = "GDAL";
// Executing the algorithm
te::rp::GeoMosaic algorithmInstance;
algorithmInstance.initialize( algoInputParams );
algorithmInstance.execute( algoOutputParams );
==== Tie Points Mosaic ====
Create a mosaic from a set of rasters using tie-points over each adjacent rasters pair.
{{:wiki:designimplementation:rp:mosaictiepoints.jpg?400|}}
{{:wiki:designimplementation:rp:mosaictiepoints2.jpg?400|}}
== Example of use ==
// Openning 2 input RGB images
te::rst::Raster inputRaster1;
...
te::rst::Raster inputRaster2;
...
// Creating the algorithm parameters
te::rp::TiePointsMosaic::InputParameters algoInputParams;
std::vector< const te::rst::Raster* > rasters;
rasters.push_back( &inputRaster1 );
rasters.push_back( &inputRaster2 );
te::rp::FeederConstRasterVector feeder( rasters );
algoInputParams.m_feederRasterPtr = &feeder;
std::vector< unsigned int > bands1;
bands1.push_back( 0 );
bands1.push_back( 1 );
bands1.push_back( 2 );
algoInputParams.m_inputRastersBands.push_back( bands1 );
std::vector< unsigned int > bands2;
bands2.push_back( 0 );
bands2.push_back( 1 );
bands2.push_back( 2 );
algoInputParams.m_inputRastersBands.push_back( bands2 );
// Defining 3 1 tiePoints
std::vector< te::gm::GTParameters::TiePoint > r0ToR1tiePoints( 3 );
r0ToR1tiePoints[ 0 ].first.x = 40;
r0ToR1tiePoints[ 0 ].first.y = 38;
r0ToR1tiePoints[ 0 ].second.x = 334;
r0ToR1tiePoints[ 0 ].second.y = 575;
r0ToR1tiePoints[ 1 ].first.x = 465;
r0ToR1tiePoints[ 1 ].first.y = 71;
r0ToR1tiePoints[ 1 ].second.x = 759;
r0ToR1tiePoints[ 1 ].second.y = 608;
r0ToR1tiePoints[ 2 ].first.x = 496;
r0ToR1tiePoints[ 2 ].first.y = 429;
r0ToR1tiePoints[ 2 ].second.x = 789;
r0ToR1tiePoints[ 2 ].second.y = 964;
algoInputParams.m_tiePoints.push_back( r0ToR1tiePoints );
te::rp::TiePointsMosaic::OutputParameters algoOutputParams;
algoOutputParams.m_rInfo["URI"] = "Mosaic.tif";
algoOutputParams.m_rType = "GDAL";
// Executing the algorithm
te::rp::TiePointsMosaic algorithmInstance;
algorithmInstance.initialize( algoInputParams );
algorithmInstance.execute( algoOutputParams );
==== Sequence Mosaic ====
Create mosaics from a sequence of overlapped rasters using an automatic tie-points detection method.
{{:wiki:designimplementation:rp:sequencemosaic.jpg?400|}}
== Example of use ==
// Openning 2 input RGB images
te::rst::Raster inputRaster1;
...
te::rst::Raster inputRaster2;
...
// Creating the algorithm parameters
te::rp::SequenceMosaic::InputParameters algoInputParams;
std::vector< const te::rst::Raster* > rasters;
rasters.push_back( &inputRaster1 );
rasters.push_back( &inputRaster2 );
te::rp::FeederConstRasterVector feeder( rasters );
algoInputParams.m_feederRasterPtr = &feeder;
std::vector< unsigned int > bands1;
bands1.push_back( 0 );
bands1.push_back( 1 );
bands1.push_back( 2 );
algoInputParams.m_inputRastersBands.push_back( bands1 );
std::vector< unsigned int > bands2;
bands2.push_back( 0 );
bands2.push_back( 1 );
bands2.push_back( 2 );
algoInputParams.m_inputRastersBands.push_back( bands2 );
algoInputParams.m_outDataSetsNamePrefix = "Mosaic_Sequence_";
algoInputParams.m_outDataSetsNameSufix = ".tif";
te::rp::SequenceMosaic::OutputParameters algoOutputParams;
// Tells the algorithm to generate the output images into the current directory "."
std::map connInfoRaster;
connInfoRaster["SOURCE"] = ".";
std::auto_ptr< te::da::DataSource > dsPtr( te::da::DataSourceFactory::make("GDAL") );
CPPUNIT_ASSERT( dsPtr.get() );
dsPtr->setConnectionInfo( connInfoRaster );
dsPtr->open();
CPPUNIT_ASSERT( dsPtr->isOpened() );
algoOutputParams.m_outputDSPtr = dsPtr.get();
// Executing the algorithm
te::rp::SequenceMosaic algorithmInstance;
algorithmInstance.initialize( algoInputParams );
algorithmInstance.execute( algoOutputParams );
==== References ====
Yuanhang Cheng and Dingyu Xue, A Fast Mosaic Approach for Remote Sensing Images