Skip to content
Snippets Groups Projects
Commit 783513d2 authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

Ajout quelques tutoriaux

parent 05352e20
Branches
Tags
No related merge requests found
PROJECT(HelloWorld)
FIND_PACKAGE(OTB)
IF(OTB_FOUND)
INCLUDE(${OTB_USE_FILE})
ELSE(OTB_FOUND)
MESSAGE(FATAL_ERROR
"Cannot build OTB project without OTB. Please set OTB_DIR.")
ENDIF(OTB_FOUND)
ADD_EXECUTABLE(HelloWorldOTB HelloWorldOTB.cxx )
TARGET_LINK_LIBRARIES(HelloWorldOTB OTBCommon OTBIO)
ADD_EXECUTABLE(Pipeline Pipeline.cxx )
TARGET_LINK_LIBRARIES(Pipeline OTBCommon OTBIO)
ADD_EXECUTABLE(Filtering Filtering.cxx )
TARGET_LINK_LIBRARIES(Filtering OTBCommon OTBIO)
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
// Software Guide : BeginLatex
//
//
// We are going to use the \doxygen{itk}{GradientMagnitudeImageFilter}
// to compute the gradient of the image. The begining of the file is
// similar to the Pipeline.cxx.
//
// We include the required header, without forgetting to add the header
// for the \doxygen{itk}{GradientMagnitudeImageFilter}.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbStreamingImageFileWriter.h"
#include "itkGradientMagnitudeImageFilter.h"
int main(int argc, char ** argv)
{
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We declare the image type, the reader and the writer as
// before:
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::Image<unsigned char, 2> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader=ReaderType::New();
typedef otb::StreamingImageFileWriter<ImageType> WriterType;
WriterType::Pointer writer=WriterType::New();
reader->SetFileName(argv[1]);
writer->SetFileName(argv[2]);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Now we have to declare the filter. It is templated with the
// input image type and the output image type like many filters
// in OTB. Here we are using the same type for the input and the
// output images:
//
// Software Guide : EndLatex
typedef itk::GradientMagnitudeImageFilter
<ImageType,ImageType> FilterType;
FilterType::Pointer filter = FilterType::New();
// Software Guide : BeginLatex
//
// Let's plug the pipeline:
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
filter->SetInput(reader->GetOutput());
writer->SetInput(filter->GetOutput());
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// And finally, we trigger the pipeline execution calling the Update()
// method on the writer
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
writer->Update();
return 0;
}
// Software Guide : EndCodeSnippet
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
// Software Guide : BeginLatex
//
// The following code is an implementation of a small OTB
// program. It tests including header files and linking with OTB
// libraries.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
#include "otbImage.h"
#include <iostream>
int main()
{
typedef otb::Image< unsigned short, 2 > ImageType;
ImageType::Pointer image = ImageType::New();
std::cout << "OTB Hello World !" << std::endl;
return 0;
}
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// This code instantiates an image whose pixels are represented with
// type \code{unsigned short}. The image is then constructed and assigned to a
// \doxygen{itk}{SmartPointer}. Although later in the text we will discuss
// \code{SmartPointer}'s in detail, for now think of it as a handle on an
// instance of an object (see section \ref{sec:SmartPointers} for more
// information). The \doxygen{itk}{Image} class will be described in
// Section~\ref{sec:ImageSection}.
//
// Software Guide : EndLatex
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
// Software Guide : BeginLatex
//
// Start by including some necessary header and with the
// usual \code{main} declaration:
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbStreamingImageFileWriter.h"
int main(int argc, char ** argv)
{
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Declare the image as an \doxygen{otb}{Image}, the pixel type
// is declared as an unsigned char and the image is specified as
// having two dimensions.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::Image<unsigned char, 2> ImageType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// To read the image, we need an \doxygen{otb}{ImageFileReader}
// which is templated with the image type.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader=ReaderType::New();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Then, we need an \doxygen{otb}{StreamingImageFileWriter}
// also templated with the image type.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::StreamingImageFileWriter<ImageType> WriterType;
WriterType::Pointer writer=WriterType::New();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The filenames are passed as arguments to the program. We keep it
// simple and we don't check their validity.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
reader->SetFileName(argv[1]);
writer->SetFileName(argv[2]);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Now that we have all the elements, we connect the pipeline,
// pluging the output of the reader to the input of the writer.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
writer->SetInput(reader->GetOutput());
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// And finally, we trigger the pipeline execution calling the Update()
// method on the last element of the pipeline. The last element will make
// sure to update all previous elements in the pipeline.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
writer->Update();
return 0;
}
// Software Guide : EndCodeSnippet
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment