Commit fc0becc1 authored by Julien Malik's avatar Julien Malik

ITK4: Change OTB API and implementation to support ITK 4.4.2

parent 583033f1

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -22,7 +22,7 @@
#include "itkMersenneTwisterRandomVariateGenerator.h"
#include "otbVectorImage.h"
#include "otbImage.h"
#include "itkEuclideanDistance.h"
#include "itkEuclideanDistanceMetric.h"
#include "otbStreamingTraits.h"
#include "itkImageRegionConstIterator.h"
#include "itkListSample.h"
......@@ -99,7 +99,7 @@ public:
private:
typedef std::map<TLabel, TSample> CentroidMapType;
typedef itk::Statistics::EuclideanDistance<TSample> DistanceType;
typedef itk::Statistics::EuclideanDistanceMetric<TSample> DistanceType;
CentroidMapType m_CentroidsMap;
typename DistanceType::Pointer m_Distance;
......@@ -292,6 +292,7 @@ private:
// Training sample lists
ListSampleType::Pointer sampleList = ListSampleType::New();
sampleList->SetMeasurementVectorSize(m_InImage->GetNumberOfComponentsPerPixel());
//unsigned int init_means_index = 0;
......
......@@ -21,7 +21,7 @@
#include "otbSOMMap.h"
#include "otbSOM.h"
#include "otbSOMImageClassificationFilter.h"
#include "itkEuclideanDistance.h"
#include "itkEuclideanDistanceMetric.h"
#include "itkImageRegionSplitter.h"
#include "otbStreamingTraits.h"
#include "itkImageRegionConstIterator.h"
......@@ -50,7 +50,7 @@ public:
typedef UInt16ImageType LabeledImageType;
typedef itk::VariableLengthVector<double> SampleType;
typedef itk::Statistics::EuclideanDistance<SampleType> DistanceType;
typedef itk::Statistics::EuclideanDistanceMetric<SampleType> DistanceType;
typedef otb::SOMMap<SampleType, DistanceType, 2> SOMMapType;
typedef itk::Statistics::ListSample<SampleType> ListSampleType;
typedef otb::SOM<ListSampleType, SOMMapType> EstimatorType;
......@@ -181,7 +181,7 @@ private:
{
// initiating random number generation
itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer
randomGen = itk::Statistics::MersenneTwisterRandomVariateGenerator::New();
randomGen = itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance();
FloatVectorImageType::Pointer input = GetParameterImage("in");
LabeledImageType::Pointer mask;
......@@ -228,6 +228,8 @@ private:
// Training sample lists
ListSampleType::Pointer sampleList = ListSampleType::New();
sampleList->SetMeasurementVectorSize(input->GetNumberOfComponentsPerPixel());
const double trainingProb = static_cast<double>(GetParameterFloat("tp"));
unsigned int nbsamples;
if (HasValue("ts"))
......
......@@ -304,12 +304,12 @@ void TrainImagesClassifier::DoExecute()
concatenateValidationSamples->Update();
concatenateValidationLabels->Update();
if (concatenateTrainingSamples->GetOutputSampleList()->Size() == 0)
if (concatenateTrainingSamples->GetOutput()->Size() == 0)
{
otbAppLogFATAL("No training samples, cannot perform SVM training.");
}
if (concatenateValidationSamples->GetOutputSampleList()->Size() == 0)
if (concatenateValidationSamples->GetOutput()->Size() == 0)
{
otbAppLogWARNING("No validation samples.");
}
......@@ -339,14 +339,14 @@ void TrainImagesClassifier::DoExecute()
ListSampleType::Pointer validationListSample=ListSampleType::New();
//Test if the validation test is empty
if ( concatenateValidationSamples->GetOutput()->Get()->Size() != 0 )
if ( concatenateValidationSamples->GetOutput()->Size() != 0 )
{
ShiftScaleFilterType::Pointer validationShiftScaleFilter = ShiftScaleFilterType::New();
validationShiftScaleFilter->SetInput(concatenateValidationSamples->GetOutput());
validationShiftScaleFilter->SetShifts(meanMeasurementVector);
validationShiftScaleFilter->SetScales(stddevMeasurementVector);
validationShiftScaleFilter->Update();
validationListSample = validationShiftScaleFilter->GetOutputSampleList();
validationListSample = validationShiftScaleFilter->GetOutput();
}
ListSampleType::Pointer listSample;
......@@ -356,29 +356,29 @@ void TrainImagesClassifier::DoExecute()
// if (IsParameterEnabled("sample.b"))
// {
// // Balance the list sample.
// otbAppLogINFO("Number of training samples before balancing: " << concatenateTrainingSamples->GetOutputSampleList()->Size())
// otbAppLogINFO("Number of training samples before balancing: " << concatenateTrainingSamples->GetOutput()->Size())
// BalancingListSampleFilterType::Pointer balancingFilter = BalancingListSampleFilterType::New();
// balancingFilter->SetInput(trainingShiftScaleFilter->GetOutput()/*GetOutputSampleList()*/);
// balancingFilter->SetInputLabel(concatenateTrainingLabels->GetOutput()/*GetOutputSampleList()*/);
// balancingFilter->SetInput(trainingShiftScaleFilter->GetOutput());
// balancingFilter->SetInputLabel(concatenateTrainingLabels->GetOutput());
// balancingFilter->SetBalancingFactor(GetParameterInt("sample.b"));
// balancingFilter->Update();
// listSample = balancingFilter->GetOutputSampleList();
// listSample = balancingFilter->GetOutput();
// labelListSample = balancingFilter->GetOutputLabelSampleList();
// otbAppLogINFO("Number of samples after balancing: " << balancingFilter->GetOutputSampleList()->Size());
// otbAppLogINFO("Number of samples after balancing: " << balancingFilter->GetOutput()->Size());
// }
// else
// {
listSample = trainingShiftScaleFilter->GetOutputSampleList();
labelListSample = concatenateTrainingLabels->GetOutputSampleList();
otbAppLogINFO("Number of training samples: " << concatenateTrainingSamples->GetOutputSampleList()->Size());
listSample = trainingShiftScaleFilter->GetOutput();
labelListSample = concatenateTrainingLabels->GetOutput();
otbAppLogINFO("Number of training samples: " << concatenateTrainingSamples->GetOutput()->Size());
// }
//--------------------------
// Split the data set into training/validation set
ListSampleType::Pointer trainingListSample = listSample;
LabelListSampleType::Pointer trainingLabeledListSample = labelListSample;
LabelListSampleType::Pointer validationLabeledListSample = concatenateValidationLabels->GetOutputSampleList();
LabelListSampleType::Pointer validationLabeledListSample = concatenateValidationLabels->GetOutput();
otbAppLogINFO("Size of training set: " << trainingListSample->Size());
otbAppLogINFO("Size of validation set: " << validationListSample->Size());
otbAppLogINFO("Size of labeled training set: " << trainingLabeledListSample->Size());
......
......@@ -73,13 +73,13 @@ public:
static const unsigned int Dimension = 2;
typedef double PixelType;
typedef itk::FixedArray<PixelType, Dimension> DeformationValueType;
typedef itk::FixedArray<PixelType, Dimension> DisplacementValueType;
typedef otb::Image< PixelType, Dimension > ScalarImageType;
typedef otb::VectorImage<PixelType, Dimension> VectorImageType;
typedef otb::ImageList<ScalarImageType> ImageListType;
typedef otb::ImageListToVectorImageFilter
<ImageListType, VectorImageType> IL2VIFilterType;
typedef otb::Image<DeformationValueType, Dimension> FieldImageType;
typedef otb::Image<DisplacementValueType, Dimension> FieldImageType;
typedef otb::FineRegistrationImageFilter
<ScalarImageType, ScalarImageType, FieldImageType> RegistrationFilterType;
typedef itk::DiscreteGaussianImageFilter
......@@ -362,11 +362,11 @@ private:
}
m_XExtractor = VectorImageToImageFilterType::New();
m_XExtractor->SetInput(m_Registration->GetOutputDeformationField());
m_XExtractor->SetInput(m_Registration->GetOutputDisplacementField());
m_XExtractor->SetIndex(0);
m_YExtractor = VectorImageToImageFilterType::New();
m_YExtractor->SetInput(m_Registration->GetOutputDeformationField());
m_YExtractor->SetInput(m_Registration->GetOutputDisplacementField());
m_YExtractor->SetIndex(1);
m_ImgList = ImageListType::New();
......@@ -443,7 +443,7 @@ private:
FloatVectorImageType::Pointer imageToWarp = GetParameterImage("w");
m_Warp = WarpFilterType::New();
m_Warp->SetDeformationField(m_Cast->GetOutput());
m_Warp->SetDisplacementField(m_Cast->GetOutput());
m_Warp->SetInput(imageToWarp);
m_Warp->SetOutputParametersFromImage(refImage);
......
......@@ -32,7 +32,7 @@
#include "otbKeyPointSetsMatchingFilter.h"
#include "itkPointSet.h"
#include "itkEuclideanDistance.h"
#include "itkEuclideanDistanceMetric.h"
#include "otbGenericRSTransform.h"
#include "otbOGRDataSourceWrapper.h"
#include "ogrsf_frmts.h"
......@@ -64,7 +64,7 @@ public:
typedef ImageToSURFKeyPointSetFilter<FloatImageType,PointSetType> SurfFilterType;
typedef itk::Statistics::EuclideanDistance<RealVectorType> DistanceType;
typedef itk::Statistics::EuclideanDistanceMetric<RealVectorType> DistanceType;
typedef otb::KeyPointSetsMatchingFilter<PointSetType,
DistanceType> MatchingFilterType;
......
......@@ -30,7 +30,6 @@
#include "otbLmvmPanSharpeningFusionImageFilter.h"
#include "itkPixelBuilder.h"
#include "itkFixedArray.h"
// Elevation handler
......
......@@ -22,7 +22,6 @@
#include "otbGenericRSResampleImageFilter.h"
#include "otbBCOInterpolateImageFunction.h"
#include "otbSimpleRcsPanSharpeningFusionImageFilter.h"
#include "itkPixelBuilder.h"
#include "itkFixedArray.h"
// Elevation handler
......@@ -144,20 +143,19 @@ private:
defSpacing[0] = defScalarSpacing;
defSpacing[1] = defScalarSpacing;
resampler->SetDeformationFieldSpacing(defSpacing);
resampler->SetDisplacementFieldSpacing(defSpacing);
}
else
{
FloatVectorImageType::SpacingType defSpacing;
defSpacing[0]=10*spacing[0];