Skip to content
Snippets Groups Projects
Commit 99b8eca1 authored by Julien Michel's avatar Julien Michel
Browse files

Exemples de la formation

parents
No related branches found
No related tags found
No related merge requests found
#include <iostream>
#include "otbImage.h"
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbObjectList.h"
#include "otbImageList.h"
#include "otbImageListToVectorImageFilter.h"
#include "otbStreamingImageFileWriter.h"
#include "otbCommandLineArgumentParser.h"
int main(int argc, char** argv)
{
// Parse command line parameters
typedef otb::CommandLineArgumentParser ParserType;
ParserType::Pointer parser = ParserType::New();
parser->AddOutputImage();
parser->AddOption("--InputImagesList","Images list to concatenate","-il",argc-4,true);
typedef otb::CommandLineArgumentParseResult ParserResultType;
ParserResultType::Pointer parseResult = ParserResultType::New();
try
{
parser->ParseCommandLine(argc,argv,parseResult);
}
catch( itk::ExceptionObject & err )
{
return EXIT_SUCCESS;
}
const unsigned int NbImages = argc-4;
std::cout << "Concat of " << NbImages << " images into a multi-band image " <<
std::endl;
typedef unsigned short int PixelType;
const unsigned int Dimension = 2;
typedef otb::Image< PixelType, Dimension > InputImageType;
typedef otb::ImageFileReader< InputImageType > ImageReaderType;
typedef otb::ObjectList< ImageReaderType > ReaderListType;
ReaderListType::Pointer readerList = ReaderListType::New();
typedef otb::ImageList< InputImageType > ImageListType;
ImageListType::Pointer imageList = ImageListType::New();
for(unsigned int i = 0; i<NbImages; i++)
{
ImageReaderType::Pointer imageReader = ImageReaderType::New();
imageReader->SetFileName(parseResult->GetParameterString("--InputImagesList",i).c_str() );
std::cout << "Adding image " <<parseResult->GetParameterString("--InputImagesList",i).c_str() << std::endl;
imageReader->UpdateOutputInformation();
imageList->PushBack( imageReader->GetOutput() );
readerList->PushBack( imageReader );
}
typedef otb::VectorImage< PixelType, Dimension > VectorImageType;
typedef otb::ImageListToVectorImageFilter< ImageListType, VectorImageType >
ImageListToVectorImageFilterType;
ImageListToVectorImageFilterType::Pointer iL2VI =
ImageListToVectorImageFilterType::New();
iL2VI->SetInput( imageList );
typedef otb::StreamingImageFileWriter< VectorImageType > ImageWriterType;
ImageWriterType::Pointer imageWriter = ImageWriterType::New();
imageWriter->SetFileName(parseResult->GetOutputImage().c_str());
unsigned long size = (10000 * 10000 * sizeof(PixelType)) / NbImages;
std::cout<<"Streaming size: "<<size<<std::endl;
imageWriter->SetBufferMemorySize(size);
imageWriter->SetInput( iL2VI->GetOutput() );
imageWriter->Update();
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment