Migration guide OTBv4

From OTBWiki
Revision as of 12:03, 13 March 2014 by Manuel.grizonnet (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page lists all the API changes that happened during OTBv3->OTBv4 migration, and explains how to change your code to fit to the new API.

General overview

Moving from OTBv3 to OTBv4 actually involves 3 migrations for which both ITK and OTB communities maintain migration guides:

Evolution of OTB cmake configuration

The support of ITK4.x into OTB have generated some modifications into the configuration step.

FFTW

Move USE_FFTW* to ITK_USE_FFTW*

The access to FFTW in OTB 4 is only made through ITK (internal or external). There are two options in ITK (which are reported in OTB cmake configuration when using the internal ITK) : ITK_USE_FFTWD and ITK_USE_FFTWF

Previous OTB versions use two variables USE_FFTWD and USE_FFTWF.

API changes in ITK

The move of OTB to ITK v4 API sums up as 2 sets of changes:

  • Using the ITK new statistics framework, which was already available in ITK v3, but wasn't used in OTB. This change is necessary since the old statistics framework has been removed from ITKv4. The new statistics framework aims at rationalizing the design of the classes of the itk::Statistics namespace, by transforming some classes to real ITK filters/DataObjects. The ITK community wrote a migration guide for the new statistics framework, which is available here.
  • Using the ITK 4 API, which includes yet another set of changes. To support the code migration to ITK v4 API, ITK is maintaining a migration guide here, which should be your first entry point when encountering an API change.

This page provides information complementary to the ITK Migration Guide, and will be completed incrementally to cover all the API changes of OTB.


Generic ITK modifications

  • itk::OStringStream oss;, replaced by std::ostringstream oss;
(ITK Migration Guide: OStringStream removed)
  • typedef itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType;
 RandomGeneratorType::Pointer randomGenerator = RandomGeneratorType::New();
 replaced by
 RandomGeneratorType::Pointer randomGenerator = RandomGeneratorType::GetInstance();

ThreadedGenerateData signature

From ITKv4 migration guide: The method signature of itk::ImageSource::ThreadedGenerateData changed: The thread id is now of type unsigned int instead of int. Use the new ThreadIdType typedef to correctly overload the virtual ThreadedGenerateData method.

If you experience runtime errors such as:

MultiThreader(0x42cc0e0): Exception occurred during SingleMethodExecute
/home/OTB-4.0-rc1/Utilities/ITK/Modules/Core/Common/include/itkImageSource.hxx:267:
itk::ERROR: VectorImageFilterW2(0x458c110): Subclass should override this method!!!
The signature of ThreadedGenerateData() has been changed in ITK v4 to use the new ThreadIdType.
VectorImageFilterW2::ThreadedGenerateData() might need to be updated to used it.

Apply the following prototype change to your filter overloading the ThreadedGenerateData method:

virtual void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, int threadId);
replaced by
virtual void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId);

API changes in OTB

In the OTB code the API changes due to the migration to ITK v4 sums up as 2 sets of changes:

  • API changes directly linked to ITK API changes (see API changes in ITK section below)
  • API changes in OTB

This section especially focuses on the 2nd category.


Compilation macros

If your code depends on FFTW, or behave differently whether FFTW is present or not, or depends on the FFTW flavor available (float or double), then you probably use the macro USE_FFTWD. This macro is not available anymore in OTB v4.

  • #if defined(USE_FFTWF), replaced by #if defined(ITK_USE_FFTWF)
  • #if defined(USE_FFTWD), replaced by #if defined(ITK_USE_FFTWD)

Removed OTB class files and methods

Replace some methods in Code/Common/otbSystem by equivalent ones in itksys/SystemTools with identical API's

Add the #include "itksys/SystemTools.hxx" instruction.

  • otb::System::GetPathName, replaced by itksys::SystemTools::GetFilenamePath
  • otb::System::GetShortFileName , replaced by itksys::SystemTools::GetFilenameName
  • otb::System::GetExtension , replaced by itksys::SystemTools::GetFilenameLastExtension, /!\The extensions extracted with GetFilenameLastExtension include the dot "."
  • otb::System::SetToLower, replaced by itksys::SystemTools::LowerCase
  • otb::System::SetToUpper, replaced by itksys::SystemTools::UpperCase
  • otb::System::IsADirName, replaced by itksys::SystemTools::FileIsDirectory
  • otb::System::IsAFileName, replaced by itksys::SystemTools::FileExists, with a 2nd argument equal to "true"
Miscellaneous
  • otbInverseDeformationFieldImageFilter.h, replaced by itkInverseDisplacementFieldImageFilter.h
  • otbPolarimetricSynthesisFilter.h, replaced by otbMultiChannelsPolarimetricSynthesisFilter.h
#include "otbPolarimetricSynthesisFilter.h
replaced by
#include "otbMultiChannelsPolarimetricSynthesisFilter.h"
const unsigned int Dimension = 2;
typedef std::complex<double> InputPixelType;
typedef double OutputPixelType;
typedef otb::Image<InputPixelType, Dimension> InputImageType;
replaced by
typedef otb::VectorImage<InputPixelType, Dimension> InputVectorImageType;
typedef otb::Image<OutputPixelType, Dimension> OutputImageType;
typedef otb::PolarimetricSynthesisFilter<InputImageType, InputImageType, InputImageType, InputImageType, OutputImageType> FilterType;
replaced by
typedef otb::MultiChannelsPolarimetricSynthesisFilter<InputVectorImageType, OutputImageType> FilterType;
FilterType::Pointer polarimetricSynthesis = FilterType::New();
InputImageType::Pointer imageHH = InputImageType::New();
InputImageType::Pointer imageHV = InputImageType::New();
InputImageType::Pointer imageVH = InputImageType::New();
InputImageType::Pointer imageVV = InputImageType::New();
polarimetricSynthesis->SetInputHH(imageHH);
polarimetricSynthesis->SetInputHV(imageHV);
polarimetricSynthesis->SetInputVH(imageVH);
polarimetricSynthesis->SetInputVV(imageVV);
replaced by
InputVectorImageType::Pointer vectorImageWithChannels_HH_HV_VH_VV = InputVectorImageType::New();
polarimetricSynthesis->SetInput(vectorImageWithChannels_HH_HV_VH_VV);
where the channels of vectorImageWithChannels_HH_HV_VH_VV are respectively HH, HV, VH and VV.


  • otbMaskedScalarImageToGreyLevelCoocurenceMatrixGenerator.h, replaced by itkHistogramToTextureFeaturesFilter.h
#include "otbMaskedScalarImageToGreyLevelCoocurenceMatrixGenerator.h
replaced by
#include "itkHistogramToTextureFeaturesFilter.h
typedef otb::MaskedScalarImageToGreyLevelCooccurrenceMatrixGenerator<InputImageType> CoocurrenceMatrixGeneratorType;
replaced by
typedef itk::Statistics::ScalarImageToCooccurrenceMatrixFilter<InputImageType> CoocurrenceMatrixGeneratorType;
//Index of the processed pixel
const IndexType& index;
InputImagePointerType inputPtr = const_cast<InputImageType *> (this->GetInputImage());
// Compute the region on which co-occurence will be estimated
typename InputRegionType::IndexType inputIndex;
typename InputRegionType::IndexType inputIndexWithTwiceOffset;
typename InputRegionType::SizeType inputSize;
typename InputRegionType::SizeType inputSizeWithTwiceOffset;
for(unsigned int dim = 0; dim<InputImageType::ImageDimension; ++dim)
  {
  inputIndex[dim] = std::min(
                             (index[dim] - m_NeighborhoodRadius),
                             (index[dim] - m_NeighborhoodRadius + m_Offset[dim])
                            );
  inputSize[dim] = 2 * m_NeighborhoodRadius + 1;
  replaced by
  
  inputSize[dim] = 2 * m_NeighborhoodRadius + 1 + std::abs(m_Offset[dim]);
  inputIndexWithTwiceOffset[dim] = index[dim] - m_NeighborhoodRadius - std::abs(m_Offset[dim]);
  inputSizeWithTwiceOffset[dim] = inputSize[dim] + std::abs(m_Offset[dim]);
  
  }
 // Build the input region
 InputRegionType inputRegion;
 inputRegion.SetIndex(inputIndex);
 inputRegion.SetSize(inputSize);
 inputRegion.Crop(inputPtr->GetRequestedRegion());
 
 
 // Build the input region With Twice Offset size  
 InputRegionType inputRegionWithTwiceOffset;
 inputRegionWithTwiceOffset.SetIndex(inputIndexWithTwiceOffset);
 inputRegionWithTwiceOffset.SetSize(inputSizeWithTwiceOffset);
 inputRegionWithTwiceOffset.Crop(inputPtr->GetRequestedRegion());
 
 
 /*********************************************************************************/
 //Local copy of the input image around the processed pixel index
 InputImagePointerType localInputImage = InputImageType::New();
 localInputImage->SetRegions(inputRegionWithTwiceOffset);
 localInputImage->Allocate();
 typedef itk::ImageRegionIteratorWithIndex<InputImageType> ImageRegionIteratorType;
 ImageRegionIteratorType itInputPtr(inputPtr, inputRegionWithTwiceOffset);
 ImageRegionIteratorType itLocalInputImage(localInputImage, inputRegionWithTwiceOffset);
 for (itInputPtr.GoToBegin(), itLocalInputImage.GoToBegin(); !itInputPtr.IsAtEnd(); ++itInputPtr, ++itLocalInputImage)
   {
   itLocalInputImage.Set(itInputPtr.Get());
   }
 /*********************************************************************************/
 
 
 // Build the maskImage corresponding to inputRegion included in inputRegionWithTwiceOffset
 InputImagePointerType maskImage = InputImageType::New();
 maskImage->SetRegions(inputRegionWithTwiceOffset);
 maskImage->Allocate();
 maskImage->FillBuffer(0);
 ImageRegionIteratorType itMask(maskImage, inputRegion);
 for (itMask.GoToBegin(); !itMask.IsAtEnd(); ++itMask)
   {
   itMask.Set(1);
   }
 
 // Build the co-occurence matrix generator
 CoocurrenceMatrixGeneratorPointerType coOccurenceMatrixGenerator = CoocurrenceMatrixGeneratorType::New();
 coOccurenceMatrixGenerator->SetInput(this->GetInputImage());
 coOccurenceMatrixGenerator->SetOffset(m_Offset);
 coOccurenceMatrixGenerator->SetNumberOfBinsPerAxis(m_NumberOfBinsPerAxis);
 coOccurenceMatrixGenerator->SetPixelValueMinMax(m_InputImageMinimum, m_InputImageMaximum);
 coOccurenceMatrixGenerator->SetRegion(inputRegion);
 replaced by
 coOccurenceMatrixGenerator->SetMaskImage(maskImage);
 coOccurenceMatrixGenerator->SetInsidePixelValue(1);
 coOccurenceMatrixGenerator->Update();
  • otbBinaryFunctorNeighborhoodJoinHistogramImageFilter methods removed
    • SetHistogramSize
    • GetHistogramSize


  • Classes related to pqxx library

Classes which use pqxx have been removed in OTB4. They are still present of course in OTB 3.X Media:http://hg.orfeo-toolbox.org/OTB/rev/92170f90f137

We decided to remove it as . Moreover access to PostGIS database (read/write) can be access to gdal in OTB.

Don't hesitate to report if you've got issues regarding this modification.


  • Classes related to liblas library

Classes which use liblas have been removed in OTB4. They are still present of course in OTB 3.X Media:http://hg.orfeo-toolbox.org/OTB/rev/9812525eeb31

We decided to remove it as. You can take a look to the PDAL and PCL projects to deal with this type of data.

Don't hesitate to report if you've got issues regarding this modification.

ITK class files removed from OTB/Utilities/InsightJournal

itkAttributeKeepNObjectsLabelMapFilter.h
itkAttributeKeepNObjectsLabelMapFilter.txx
itkAttributeLabelObject.h
itkAttributeOpeningLabelMapFilter.h
itkAttributeOpeningLabelMapFilter.txx
itkAttributeRelabelImageFilter.h
itkAttributeRelabelImageFilter.txx
itkAttributeRelabelLabelMapFilter.h
itkAttributeRelabelLabelMapFilter.txx
itkAttributeSelectionLabelMapFilter.h
itkAttributeSelectionLabelMapFilter.txx
itkBinaryAttributeKeepNObjectsImageFilter.h
itkBinaryAttributeKeepNObjectsImageFilter.txx
itkBinaryAttributeOpeningImageFilter.h
itkBinaryAttributeOpeningImageFilter.txx
itkBinaryClosingByReconstructionImageFilter.h
itkBinaryClosingByReconstructionImageFilter.txx
itkBinaryFillholeImageFilter.h
itkBinaryFillholeImageFilter.txx
itkBinaryGrindPeakImageFilter.h
itkBinaryGrindPeakImageFilter.txx
itkBinaryNotImageFilter.h
itkBinaryOpeningByReconstructionImageFilter.h
itkBinaryOpeningByReconstructionImageFilter.txx
itkBinaryReconstructionByDilationImageFilter.h
itkBinaryReconstructionByDilationImageFilter.txx
itkBinaryReconstructionByErosionImageFilter.h
itkBinaryReconstructionByErosionImageFilter.txx
itkBinaryReconstructionLabelMapFilter.h
itkBinaryReconstructionLabelMapFilter.txx
itkBinaryShapeKeepNObjectsImageFilter.h
itkBinaryShapeKeepNObjectsImageFilter.txx
itkBinaryShapeOpeningImageFilter.h
itkBinaryShapeOpeningImageFilter.txx
itkBinaryStatisticsKeepNObjectsImageFilter.h
itkBinaryStatisticsKeepNObjectsImageFilter.txx
itkBinaryStatisticsOpeningImageFilter.h
itkBinaryStatisticsOpeningImageFilter.txx
itkConnectedComponentAlgorithm.h
itkGreyLevelRunLengthMatrixTextureCoefficientsCalculator.h
itkGreyLevelRunLengthMatrixTextureCoefficientsCalculator.txx
itkLabelAttributeKeepNObjectsImageFilter.h
itkLabelAttributeKeepNObjectsImageFilter.txx
itkLabelAttributeOpeningImageFilter.h
itkLabelAttributeOpeningImageFilter.txx
itkLabelMapMaskImageFilter.h
itkLabelMapMaskImageFilter.txx
itkLabelMapOverlayImageFilter.h
itkLabelMapOverlayImageFilter.txx
itkLabelMapToAttributeImageFilter.h
itkLabelMapToAttributeImageFilter.txx
itkLabelMapToRGBImageFilter.h
itkLabelMapToRGBImageFilter.txx
itkLabelObjectUtils.h
itkLabelReconstructionByDilationImageFilter.h
itkLabelReconstructionByDilationImageFilter.txx
itkLabelReconstructionLabelMapFilter.h
itkLabelReconstructionLabelMapFilter.txx
itkLabelSelectionLabelMapFilter.h
itkScalarImageToGreyLevelRunLengthMatrixGenerator.h
itkScalarImageToGreyLevelRunLengthMatrixGenerator.txx
N.B: The following Insight Journal class files are still present in OTB/Utilities/InsightJournal:
itkScaleInvariantFeatureImageFilter.h
itkScaleInvariantFeatureImageFilter.txx


Replace *DeformationField* by *DisplacementField* in so-called OTB classes and methods

New names of OTB classes
  • otbBSplinesInterpolateDeformationFieldGenerator.h, replaced by otbBSplinesInterpolateDisplacementFieldGenerator.h
 Example of implementation: 
#include "otbBSplinesInterpolateDeformationFieldGenerator.h"
replaced by
#include "otbBSplinesInterpolateDisplacementFieldGenerator.h"
typedef otb::BSplinesInterpolateDeformationFieldGenerator<PointSetType, ImageType> FilterType;
replaced by
typedef otb::BSplinesInterpolateDisplacementFieldGenerator<PointSetType, ImageType> FilterType;

The following OTB classes are modified in a similar way:

  • otbBSplinesInterpolateTransformDeformationFieldGenerator.h, replaced by otbBSplinesInterpolateTransformDisplacementFieldGenerator.h
  • otbNearestPointDeformationFieldGenerator.h, replaced by otbNearestPointDisplacementFieldGenerator.h
  • otbNearestTransformDeformationFieldGenerator.h, replaced by otbNearestTransformDisplacementFieldGenerator.h
  • otbNNearestPointsLinearInterpolateDeformationFieldGenerator.h, replaced by otbNNearestPointsLinearInterpolateDisplacementFieldGenerator.h
  • otbNNearestTransformsLinearInterpolateDeformationFieldGenerator.h, replaced by otbNNearestTransformsLinearInterpolateDisplacementFieldGenerator.h
  • otbPointSetToDeformationFieldGenerator.h, replaced by otbPointSetToDisplacementFieldGenerator.h
  • otbPointSetWithTransformToDeformationFieldGenerator.h, replaced by otbPointSetWithTransformToDisplacementFieldGenerator.h
  • otbStereorectificationDeformationFieldSource.h, replaced by otbStereorectificationDisplacementFieldSource.h
  • otbInverseDeformationFieldImageFilter.h, replaced by itkInverseDisplacementFieldImageFilter.h


New names of OTB class methods
  • In otb::StreamingResampleImageFilter<ImageType, ImageType>
typedef otb::StreamingResampleImageFilter<ImageType, ImageType> ImageResamplerType;
ImageResamplerType::Pointer resampler = ImageResamplerType::New();
resampler->SetDeformationFieldSpacing(5.);
replaced by
resampler->SetDisplacementFieldSpacing(5.);
SpacingType dFSpacing = resampler->GetDeformationFieldSpacing();
replaced by
SpacingType dFSpacing = resampler->GetDisplacementFieldSpacing();
resampler->SetDeformationFilterNumberOfThreads(15);
replaced by
resampler->SetDisplacementFilterNumberOfThreads(15);

  • In otb::GenericRSResampleImageFilter<ImageType, ImageType>
typedef otb::GenericRSResampleImageFilter<ImageType, ImageType> ImageResamplerType;
ImageResamplerType::Pointer resampler = ImageResamplerType::New();
resampler->SetDeformationFieldSpacing(gridSpacing);
replaced by
resampler->SetDisplacementFieldSpacing(gridSpacing);


  • In otb::OrthoRectificationFilter<ImageType, ImageType, UtmMapProjectionType>
typedef otb::OrthoRectificationFilter<ImageType, ImageType, UtmMapProjectionType> OrthoRectifFilterType;
OrthoRectifFilterType::Pointer orthoRectifFilter = OrthoRectifFilterType::New();
orthoRectifFilter->SetDeformationFieldSpacing(gridSpacing);
replaced by
orthoRectifFilter->SetDisplacementFieldSpacing(gridSpacing);


  • In otb::FineRegistrationImageFilter<ImageType, ImageType, FieldImageType>
typedef otb::FineRegistrationImageFilter<ImageType, ImageType, FieldImageType> RegistrationFilterType;
RegistrationFilterType::Pointer registration = RegistrationFilterType::New();
registration->GetOutputDeformationField();
replaced by
registration->GetOutputDisplacementField();


  • In otb::StereorectificationDeformationFieldSource<ImageType,DeformationFieldType> otb::StereorectificationDisplacementFieldSource<ImageType,DisplacementFieldType>
typedef otb::StereorectificationDeformationFieldSource<ImageType,DeformationFieldType> DeformationFieldSourceType;
replaced by
typedef otb::StereorectificationDisplacementFieldSource<ImageType,DisplacementFieldType> DisplacementFieldSourceType;
DeformationFieldSourceType::Pointer dfSource = DeformationFieldSourceType::New();
replaced by
DisplacementFieldSourceType::Pointer dfSource = DisplacementFieldSourceType::New();
dfSource->GetLeftDeformationFieldOutput();
replaced by
dfSource->GetLeftDisplacementFieldOutput();
dfSource->GetRightDeformationFieldOutput();
replaced by
dfSource->GetRightDisplacementFieldOutput();


  • In otb::WarpImageFilter<ImageType, ImageType, DisplacementFieldType>
typedef otb::WarpImageFilter<ImageType, ImageType, DisplacementFieldType> ImageWarperType;
ImageWarperType::Pointer warper = ImageWarperType::New();
warper->SetDeformationField(deformationReader->GetOutput());
replaced by
warper->SetDisplacementField(displacementReader->GetOutput());
DisplacementFieldType dField = warper->GetDeformationField();
replaced by
DisplacementFieldType dField = warper->GetDisplacementField();


  • In otb::StreamingWarpImageFilter<ImageType, ImageType, DisplacementFieldType>
typedef otb::StreamingWarpImageFilter<ImageType, ImageType, DisplacementFieldType> ImageWarperType;
ImageWarperType::Pointer warper = ImageWarperType::New();
warper->SetMaximumDeformation(maxDeformation);
replaced by
warper->SetMaximumDisplacement(maxDisplacement);
warper->SetDeformationField(deformationReader->GetOutput());
replaced by
warper->SetDisplacementField(displacementReader->GetOutput());
DisplacementFieldType dField = warper->GetDeformationField();
replaced by
DisplacementFieldType dField = warper->GetDisplacementField();


Replace *EuclideanDistance* by *EuclideanDistanceMetric* in so-called OTB classes and methods

New names of OTB classes
  • otbEuclideanDistanceWithMissingValuePow2.h, replaced by otbEuclideanDistanceMetricWithMissingValuePow2.h
 Example of implementation: 
#include "otbEuclideanDistanceWithMissingValuePow2.h"
replaced by
#include "otbEuclideanDistanceMetricWithMissingValuePow2.h"
otb::Statistics::EuclideanDistanceWithMissingValuePow2<PixelType> FilterType;
replaced by
otb::Statistics::EuclideanDistanceMetricWithMissingValuePow2<PixelType> FilterType;


  • otbEuclideanDistanceWithMissingValue.h, replaced by otbEuclideanDistanceMetricWithMissingValue.h
 Example of implementation: 
#include "otbEuclideanDistanceWithMissingValue.h"
replaced by
#include "otbEuclideanDistanceMetricWithMissingValue.h"
otb::Statistics::EuclideanDistanceWithMissingValue<PixelType> FilterType;
replaced by
otb::Statistics::EuclideanDistanceMetricWithMissingValue<PixelType> FilterType;



New names of OTB class methods
  • In otb::DataNode<TPrecision, VDimension, TValuePrecision>
typedef otb::DataNode<double, 2>  DataNodeType;
DataNodeType::Pointer dataNode1 = DataNodeType::New();
DataNodeType::Pointer dataNode2 = DataNodeType::New();
double euclideanDist = dataNode1->EuclideanDistance(dataNode2);
replaced by
double euclideanDist = dataNode1->EuclideanDistanceMetric(dataNode2);


  • In otb::DBOverlapDataNodeFeatureFunction<TCoordRep, TPrecision>
VertexType q1, q2, p;
typedef otb::DBOverlapDataNodeFeatureFunction<double, double> DataNodeFunctionType;
DataNodeFunctionType::Pointer function = DataNodeFunctionType::New();
function->SetInputVectorData(vectorDataDBReader->GetOutput());
double euclideanDist = function->ComputeEuclideanDistanceToSegment(q1, q2, p);
replaced by
double euclideanDist = function->ComputeEuclideanDistanceMetricToSegment(q1, q2, p);


  • In otb::LabeledSampleLocalizationGenerator<TVectorData>
typedef otb::LabeledSampleLocalizationGenerator<TVectorData> FilterType;
typename typedef FilterType::EuclideanDistanceType EuclideanDistanceType;
replaced by
typename typedef FilterType::EuclideanDistanceMetricType EuclideanDistanceMetricType;


  • In otb::Rectangle<TValue>
VertexType q1, q2, p;
typedef otb::Rectangle<double> RectangleType;
RectangleType::Pointer rectangle = RectangleType::New();
double euclideanDist = rectangle->ComputeEuclideanDistanceToSegment(q1, q2, p);
replaced by
double euclideanDist = rectangle->ComputeEuclideanDistanceMetricToSegment(q1, q2, p);


  • In otb::otbPointSetToDisplacementFieldGenerator<TPointSet, TDisplacementField>
  • In otb::otbNNearestTransformsLinearInterpolateDisplacementFieldGenerator<TPointSet, TDisplacementField>
  • In otb::otbNNearestPointsLinearInterpolateDisplacementFieldGenerator<TPointSet, TDisplacementField>
double euclideanDist = this->EuclideanDistance(index, point);
replaced by
double euclideanDist = this->EuclideanDistanceMetric(index, point);


New use of OTB class methods

  • In otb::ChangeLabelImageFilter<InputImageType, OutputImageType>
const unsigned int ImageDimension = 2;
typedef unsigned short PixelType;
typedef otb::Image<PixelType, ImageDimension> InputImageType;
typedef otb::VectorImage<PixelType, ImageDimension> OutputImageType;
typedef InputImageType::PixelType InputPixelType;
typedef OutputImageType::PixelType OutputPixelType;
typedef otb::ChangeLabelImageFilter<InputImageType, OutputImageType> FilterType;

OutputPixelType background;
background.SetSize(filter->GetNumberOfComponentsPerPixel());
background[0] = itk::NumericTraits<PixelType>::max();
background[1] = itk::NumericTraits<PixelType>::max();
background[2] = 0;

FilterType::Pointer filter = FilterType::New();
filter->SetChange(0, 0);
replaced by
OutputPixelType zero = itk::NumericTraits<OutputPixelType>::ZeroValue(background);
filter->SetChange(0, zero);

New names of OTB class methods

  • In otb::SVMClassifier<SampleType, LabelPixelType>
typedef otb::SVMClassifier<SampleType, LabelPixelType> ClassifierType;
ClassifierType::Pointer classifier = ClassifierType::New();
classifier->SetSample(sample.GetPointer());
replaced by
classifier->SetInput(sample.GetPointer());

/!\ otb::SVMClassifier<SampleType, LabelPixelType> was already deprecated in OTB 3.20 /!\



  • In otb::Statistics::ConcatenateSampleListFilter<DoubleSampleListType>
typedef otb::Statistics::ConcatenateSampleListFilter<DoubleSampleListType> ConcatenateFilterType;
ConcatenateFilterType::Pointer filter = ConcatenateFilterType::New();
filter->GetOutputSampleList();
replaced by
filter->GetOutput();


  • In otb::Statistics::GaussianAdditiveNoiseSampleListFilter <FloatSampleListType, DoubleSampleListType>
typedef otb::Statistics::GaussianAdditiveNoiseSampleListFilter<FloatSampleListType, DoubleSampleListType> GaussianFilterType;
GaussianFilterType::Pointer filter = GaussianFilterType::New();
filter->GetOutputSampleList();
replaced by
filter->GetOutput();


  • In otb::Statistics::ShiftScaleSampleListFilter<FloatSampleListType, DoubleSampleListType>
typedef otb::Statistics::ShiftScaleSampleListFilter<FloatSampleListType, DoubleSampleListType> ShiftScaleFilterType;
ShiftScaleFilterType::Pointer filter = ShiftScaleFilterType::New();
filter->GetOutputSampleList();
replaced by
filter->GetOutput();


  • In otb::Statistics::ListSampleToBalancedListSampleFilter<FloatSampleListType, IntegerSampleListType, DoubleSampleListType>
typedef otb::Statistics::ListSampleToBalancedListSampleFilter<FloatSampleListType, IntegerSampleListType, DoubleSampleListType> BalancingFilterType;
BalancingFilterType::Pointer filter = BalancingFilterType::New();
filter->GetOutputSampleList();
replaced by
filter->GetOutput();
filter->GetOutputLabelSampleList();
replaced by
filter->GetOutputLabel();



  • In otb::PathListToHistogramGenerator<PathType, FunctionType>
typedef itk::PolyLineParametricPath<Dimension> PathType;
typedef otb::OrientationPathFunction<PathType> FunctionType;
typedef otb::PathListToHistogramGenerator<PathType, FunctionType> HistogramGeneratorType;
HistogramGeneratorType::Pointer histogramGenerator = HistogramGeneratorType::New()
histogramGenerator->Compute();
replaced by
histogramGenerator->Update();


  • In otb::LabelMapWithClassLabelToLabeledSampleListFilter<LabelMapType, ListSampleType, TrainingListSampleType>
typedef otb::LabelMapWithClassLabelToLabeledSampleListFilter<LabelMapType, ListSampleType, TrainingListSampleType> ListSampleFilterType;
ListSampleFilterType::Pointer filter = ListSampleFilterType::New();
filter->Compute();
replaced by
filter->Update();


  • In otb::LabelMapToSampleListFilter<LabelMapType, ListSampleType>
typedef otb::LabelMapToSampleListFilter<LabelMapType, ListSampleType> LabelMap2ListSampleFilterType;
LabelMap2ListSampleFilterType::Pointer filter = LabelMap2ListSampleFilterType::New();
filter->Compute();
replaced by
filter->Update();

Migration of FLTK visualization framework from OTB to Monteverdi 1.x

In order to rationalize the OTB visualization framework, we decide to move the FLTK visualization framework into Monteverdi 1 project. Therefore the Visu, GUI and Visualization source code and related tests move into Monteverdi. It was renamed respectively OTBVisuLegacyFLTK, OTBGuiFLTK, OTBVisuFLTK into Monteverdi project. We have also remove FLTK source from OTB and decide to set FLTK as an external dependences for Montevedi project. You need to use your FLTK system package or build you own FLTK by yourself. We recommend you to use FLTK 1.3 which is mainly supported by the major distribution. A osgeo4W package will be available as soon as possible.

If you have external project based on this Visualization framework based on FLTK you should migrate you application as following.

Into the CMakeList.txt of you external project replace:

  • find_package(OTB) by find_package(Monteverdi REQUIRED)
  • in your include_directories command, you should add the variable ${Monteverdi_INCLUDE_DIRS} to get the headers from Monteverdi
  • in your target_link_libraries command, you should add the variable ${Monteverdi_LIBRARIES} to link with the visualization libraries: OTBGuiFLTK and OTBVisuFLTK