From 60e51aba214f7751fcfb46e4b9cb667206b303a9 Mon Sep 17 00:00:00 2001 From: Traizet Cedric <cedric.traizet@cesbio.cnes.fr> Date: Tue, 25 Apr 2017 11:07:16 +0200 Subject: [PATCH 001/567] Empty app creation --- CMakeLists.txt | 5 ++++ app/CMakeLists.txt | 4 ++++ app/cbDimensionalityReductionTrainer.cxx | 29 ++++++++++++++++++++++++ otb-module.cmake | 9 ++++++++ 4 files changed, 47 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 app/CMakeLists.txt create mode 100644 app/cbDimensionalityReductionTrainer.cxx create mode 100644 otb-module.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..d44bf84f11 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.9) + +project(CbDimensionalityReduction) +#set(CbDimensionalityReduction_LIBRARIES CbDimensionalityReduction) +otb_module_impl() diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt new file mode 100644 index 0000000000..cdb4d73fb7 --- /dev/null +++ b/app/CMakeLists.txt @@ -0,0 +1,4 @@ +OTB_CREATE_APPLICATION(NAME CbDimensionalityReductionTrainer +SOURCES cbDimensionalityReductionTrainer.cxx +LINK_LIBRARIES ${${otb-module}_LIBRARIES} +) diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx new file mode 100644 index 0000000000..daa5d6766d --- /dev/null +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -0,0 +1,29 @@ +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + +class CbDimensionalityReductionTrainer : public otb::Wrapper::Application +{ +public: + typedef CbDimensionalityReductionTrainer Self; + typedef itk::SmartPointer<Self> Pointer; + itkNewMacro(Self); + itkTypeMacro(CbDimensionalityReductionTrainer, otb::Wrapper::Application); +private: + void DoInit() + { + SetName("CbDimensionalityReductionTrainer"); + SetDescription("Trainer for the dimensionality reduction algorithms used in the cbDimensionalityReduction application."); + } + + void DoUpdateParameters() + { + } + + void DoExecute() + { + int ThisDoesNothing = 0; + } + +}; + +OTB_APPLICATION_EXPORT(CbDimensionalityReductionTrainer) diff --git a/otb-module.cmake b/otb-module.cmake new file mode 100644 index 0000000000..c2861a847f --- /dev/null +++ b/otb-module.cmake @@ -0,0 +1,9 @@ +set(DOCUMENTATION "Dimensionality reduction application") +otb_module(CbDimensionalityReduction + DEPENDS + OTBCommon + OTBApplicationEngine + + DESCRIPTION + "${DOCUMENTATION}" +) -- GitLab From a800be90d23af97a76617b5b24339ac47a0beaea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 25 Apr 2017 11:40:56 +0200 Subject: [PATCH 002/567] README added --- README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000..e69de29bb2 -- GitLab From f3c26934f88d4f6ece51b65a42a2bf628b693346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 27 Apr 2017 16:42:02 +0200 Subject: [PATCH 003/567] Dimensionality reduction app created (dummy), encode filter .h and .txx added --- app/cbDimensionalityReduction.cxx | 31 ++++++ include/encode_filter.h | 53 ++++++++++ include/encode_filter.txx | 160 ++++++++++++++++++++++++++++++ 3 files changed, 244 insertions(+) create mode 100644 app/cbDimensionalityReduction.cxx create mode 100644 include/encode_filter.h create mode 100644 include/encode_filter.txx diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx new file mode 100644 index 0000000000..5986fd3a74 --- /dev/null +++ b/app/cbDimensionalityReduction.cxx @@ -0,0 +1,31 @@ +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + +class CbDimensionalityReduction : public otb::Wrapper::Application +{ +public: + typedef CbDimensionalityReduction Self; + typedef itk::SmartPointer<Self> Pointer; + itkNewMacro(Self); + itkTypeMacro(CbDimensionalityReduction, otb::Wrapper::Application); +private: + void DoInit() + { + SetName("CbDimensionalityReduction"); + SetDescription("Perform dimensionality reduction on the input image"); + AddRAMParameter(); + } + + void DoUpdateParameters() + { + } + + void DoExecute() + { + std::cout << "Appli !" << std::endl; + int ThisDoesNothing = 0; + } + +}; + +OTB_APPLICATION_EXPORT(CbDimensionalityReduction) diff --git a/include/encode_filter.h b/include/encode_filter.h new file mode 100644 index 0000000000..9a6b70c117 --- /dev/null +++ b/include/encode_filter.h @@ -0,0 +1,53 @@ +#ifndef __encode_Filter_h +#define __encode_Filter_h + +#include "itkImageToImageFilter.h" +#include "itkMacro.h" + + +template< class TImage, class AutoencoderModel, class NormalizerModel> +class ITK_EXPORT EncodeFilter:public itk::ImageToImageFilter< TImage, TImage > +{ + public: + /** Standard class typedefs. */ + typedef EncodeFilter Self; + typedef itk::ImageToImageFilter< TImage, TImage > Superclass; + typedef itk::SmartPointer< Self > Pointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(EncodeFilter, ImageToImageFilter); + + //void SetInputImage(const TImage* image); + void SetAutoencoderModel(const std::string encoderPath); + void SetNormalizerModel(const std::string NormalizerPath); + void SetModels( const AutoencoderModel net, const NormalizerModel normalizer); + + protected: + EncodeFilter(); + ~EncodeFilter(){} + + typename TImage::ConstPointer GetInputImage(); + AutoencoderModel GetAutoencoderModel(); + NormalizerModel GetNormalizerModel(); + + /** Does the real work. */ + + virtual void BeforeThreadedGenerateData(); + void ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) ITK_OVERRIDE; + + private: + EncodeFilter(const Self &); //purposely not implemented + void operator=(const Self &); //purposely not implemented + AutoencoderModel m_net; + NormalizerModel m_normalizer; +}; + +#ifndef ITK_MANUAL_INSTANTIATION +#include "encode_filter.txx" +#endif + + +#endif // __encode_Filter_h diff --git a/include/encode_filter.txx b/include/encode_filter.txx new file mode 100644 index 0000000000..adb071854f --- /dev/null +++ b/include/encode_filter.txx @@ -0,0 +1,160 @@ +#ifndef __encode_filter_txx +#define __encode_filter_txx + +#include "encode_filter.h" +#include <fstream> + + +#include "itkObjectFactory.h" +#include "itkImageRegionIterator.h" +#include "itkImageRegionConstIterator.h" +#include "otbVectorImage.h" + + +#include <shark/Data/Csv.h> +#include <shark/Data/Pgm.h> //for exporting the learned filters +#include <shark/Data/SparseData.h>//for reading in the images as sparseData/Libsvm format +#include <shark/Models/Autoencoder.h>//normal autoencoder model +#include <shark/Models/TiedAutoencoder.h>//autoencoder with tied weights +#include <shark/Models/Normalizer.h> +#include <shark/Algorithms/Trainers/NormalizeComponentsUnitVariance.h> + + +//using namespace shark; + +template< class TImage, class AutoencoderModel, class NormalizerModel> +EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::EncodeFilter() +{ + this->SetNumberOfRequiredInputs(1); +} + + +template< class TImage, class AutoencoderModel, class NormalizerModel> +void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::SetAutoencoderModel(const std::string encoderPath) +{ + //m_net = net; + std::ifstream ifs(encoderPath); + boost::archive::polymorphic_text_iarchive ia(ifs); + m_net.read(ia); + ifs.close(); +} + + +template< class TImage, class AutoencoderModel, class NormalizerModel> +void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::SetNormalizerModel(const std::string NormalizerPath) +{ + //m_normalizer = normalizer; + std::ifstream ifs(NormalizerPath); + boost::archive::polymorphic_text_iarchive ia(ifs); + m_normalizer.read(ia); + ifs.close(); +} + + +template< class TImage, class AutoencoderModel, class NormalizerModel> +void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::SetModels(const AutoencoderModel net, const NormalizerModel normalizer) +{ + m_net = net; + m_normalizer = normalizer; +} + + +template< class TImage, class AutoencoderModel, class NormalizerModel> +typename TImage::ConstPointer EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GetInputImage() +{ + return static_cast< const TImage * > + ( this->itk::ProcessObject::GetInput(0) ); +} + + + +template< class TImage, class AutoencoderModel, class NormalizerModel> +AutoencoderModel EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GetAutoencoderModel() +{ + return m_net; +} + + +template< class TImage, class AutoencoderModel, class NormalizerModel> +NormalizerModel EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GetNormalizerModel() +{ + return m_normalizer; +} + + + +struct Data_with_info { + shark::Data<shark::RealVector> data; // This file format can be used to do Machine Learning with the Shark ML library + otb::VectorImage<double, 2>::RegionType region; + otb::VectorImage<double, 2>::PointType origin; + otb::VectorImage<double, 2>::SpacingType spacing; +}; + + +template< class TImage, class AutoencoderModel, class NormalizerModel> +void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::BeforeThreadedGenerateData() +{ +#ifdef _OPENMP +// OpenMP will take care of threading +this->SetNumberOfThreads(1); +#endif +} + + +/*template< class TImage, class AutoencoderModel, class NormalizerModel> +void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GenerateData()*/ +template< class TImage, class AutoencoderModel, class NormalizerModel> +void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) +{ + //Data_with_info info; + typename TImage::ConstPointer input = this->GetInput(); + typename TImage::Pointer output = this->GetOutput(); + + // Image to vector + const unsigned int img_bands = input->GetNumberOfComponentsPerPixel(); + + itk::ImageRegionConstIterator<TImage> inputIterator(input,outputRegionForThread); + + std::vector<shark::RealVector> image_vect; + + typename TImage::PixelType pixelValue; + while(!inputIterator.IsAtEnd()){ + shark::RealVector vect; + pixelValue = inputIterator.Get(); + for(unsigned int a = 0; a < img_bands; ++a){ + vect.push_back(pixelValue[a]); + } + image_vect.push_back(vect); + ++inputIterator; + } + shark::Data<shark::RealVector> data = shark::createDataFromRange(image_vect); + image_vect.clear(); + + /** Normalize the data */ + + data= transform(data, m_normalizer); + /** Encode the data */ + + data = m_net.encode(data); + + /** vector to image */ + + std::size_t numHidden = data.element(1).size(); + output->SetVectorLength(numHidden); + itk::ImageRegionIterator<TImage> imageIteratorOut(output,outputRegionForThread); + auto vect_it = data.elements().begin(); + while(!imageIteratorOut.IsAtEnd() && vect_it!=data.elements().end()){ + pixelValue.SetSize(numHidden); + shark::RealVector vect_out=(*vect_it); + for(unsigned int a = 0; a < numHidden; ++a){ + pixelValue[a]=vect_out[a]; + } + + imageIteratorOut.Set(pixelValue); + ++imageIteratorOut; + ++vect_it; + } +} + + +#endif -- GitLab From 3c3eddd1581e9d9711b8415c99c881e08ebf974f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Fri, 28 Apr 2017 11:26:17 +0200 Subject: [PATCH 004/567] app added --- CMakeLists.txt | 1 + app/CMakeLists.txt | 9 +++- app/cbDimensionalityReduction.cxx | 66 ++++++++++++++++++++++-- app/cbDimensionalityReductionTrainer.cxx | 4 +- otb-module.cmake | 4 +- 5 files changed, 78 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d44bf84f11..b1d9bfe596 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,3 +3,4 @@ cmake_minimum_required(VERSION 2.8.9) project(CbDimensionalityReduction) #set(CbDimensionalityReduction_LIBRARIES CbDimensionalityReduction) otb_module_impl() + diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index cdb4d73fb7..5dc561a085 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,4 +1,11 @@ -OTB_CREATE_APPLICATION(NAME CbDimensionalityReductionTrainer +OTB_CREATE_APPLICATION( +NAME CbDimensionalityReductionTrainer SOURCES cbDimensionalityReductionTrainer.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES} ) + +OTB_CREATE_APPLICATION( +NAME CbDimensionalityReduction +SOURCES cbDimensionalityReduction.cxx +LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBITK_LIBRARIES} ${OTBBoost_LIBRARIES} ${OTBShark_LIBRARIES} +) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index 5986fd3a74..a6362a4b4f 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -1,5 +1,26 @@ #include "otbWrapperApplication.h" #include "otbWrapperApplicationFactory.h" +#include "otbWrapperChoiceParameter.h" + +#include <iostream> + +#include "otbImage.h" +//#include "otbVectorImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" + + +#include <shark/Models/Autoencoder.h>//normal autoencoder model + +#include <shark/Models/TiedAutoencoder.h>//autoencoder with tied weights +#include <shark/Models/Normalizer.h> + +#include "encode_filter.h" + +namespace otb +{ +namespace Wrapper +{ class CbDimensionalityReduction : public otb::Wrapper::Application { @@ -13,6 +34,19 @@ private: { SetName("CbDimensionalityReduction"); SetDescription("Perform dimensionality reduction on the input image"); + + AddParameter(ParameterType_InputImage, "in", "Input Image"); + SetParameterDescription( "in", "The input image to perform dimensionality reduction on."); + + AddParameter(ParameterType_InputFilename, "model", "Model file"); + SetParameterDescription("model", "A model file (produced by the cbDimensionalityReductionTrainer application)."); + + AddParameter(ParameterType_InputFilename, "normalizer", "Normalizer model file"); + SetParameterDescription("normalizer", "A normalizer model file (produced by the cbDimensionalityReductionTrainer application)."); + + AddParameter(ParameterType_OutputImage, "out", "Output Image"); + SetParameterDescription("out", "Output image"); + AddRAMParameter(); } @@ -22,10 +56,36 @@ private: void DoExecute() { + typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; + + using image_type = otb::VectorImage<double, 2>; + using FilterType = EncodeFilter<image_type, AutoencoderType, shark::Normalizer<shark::RealVector>> ; + std::cout << "Appli !" << std::endl; - int ThisDoesNothing = 0; + FloatVectorImageType::Pointer inImage = GetParameterImage("in"); + std::string encoderPath = GetParameterString("model"); + std::string normalizerPath = GetParameterString("normalizer"); + + //inImage->UpdateOutputInformation(); + + using ReaderType = otb::ImageFileReader<image_type>; + + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName("/mnt/data/home/vincenta/features_2014/SL_MultiTempGapF_Brightness_NDVI_NDWI__.tif"); + + FilterType::Pointer filter = FilterType::New(); + filter->SetAutoencoderModel(encoderPath); + filter->SetNormalizerModel(normalizerPath); + filter->SetInput(reader->GetOutput()); + //filter->SetInput(inImage); + + filter->UpdateOutputInformation(); + + SetParameterOutputImage("out", filter->GetOutput()); + } }; - -OTB_APPLICATION_EXPORT(CbDimensionalityReduction) +} +} +OTB_APPLICATION_EXPORT(otb::Wrapper::CbDimensionalityReduction) diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index daa5d6766d..cd18d7e5c4 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -13,6 +13,7 @@ private: { SetName("CbDimensionalityReductionTrainer"); SetDescription("Trainer for the dimensionality reduction algorithms used in the cbDimensionalityReduction application."); + AddRAMParameter(); } void DoUpdateParameters() @@ -20,7 +21,8 @@ private: } void DoExecute() - { + { + std::cout << "Appli !" << std::endl; int ThisDoesNothing = 0; } diff --git a/otb-module.cmake b/otb-module.cmake index c2861a847f..5797e5c7cb 100644 --- a/otb-module.cmake +++ b/otb-module.cmake @@ -3,7 +3,9 @@ otb_module(CbDimensionalityReduction DEPENDS OTBCommon OTBApplicationEngine - + OTBITK + OTBShark + OTBBoost DESCRIPTION "${DOCUMENTATION}" ) -- GitLab From 8426dd2a572846a523df0979b2292cd29433f412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Fri, 28 Apr 2017 15:52:09 +0200 Subject: [PATCH 005/567] autoencoder dim reduc added to the dim reduc app, dummy filter added (to delete later) --- include/dummy_filter.h | 47 ++++++++++++++++++++++++ include/dummy_filter.txx | 79 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 include/dummy_filter.h create mode 100644 include/dummy_filter.txx diff --git a/include/dummy_filter.h b/include/dummy_filter.h new file mode 100644 index 0000000000..ea6dd8d21a --- /dev/null +++ b/include/dummy_filter.h @@ -0,0 +1,47 @@ +#ifndef __dummy_Filter_h +#define __dummy_Filter_h + +#include "itkImageToImageFilter.h" +#include "itkMacro.h" + + +template< class TImage> +class ITK_EXPORT DummyFilter:public itk::ImageToImageFilter< TImage, TImage > +{ + public: + /** Standard class typedefs. */ + typedef DummyFilter Self; + typedef itk::ImageToImageFilter< TImage, TImage > Superclass; + typedef itk::SmartPointer< Self > Pointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(DummyFilter, ImageToImageFilter); + + //void SetInputImage(const TImage* image); + + + protected: + DummyFilter(); + ~DummyFilter(){} + + typename TImage::ConstPointer GetInputImage(); + + /** Does the real work. */ + + virtual void BeforeThreadedGenerateData(); + void ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) ITK_OVERRIDE; + + private: + DummyFilter(const Self &); //purposely not implemented + void operator=(const Self &); //purposely not implemented +}; + +#ifndef ITK_MANUAL_INSTANTIATION +#include "dummy_filter.txx" +#endif + + +#endif // __dummy_Filter_h diff --git a/include/dummy_filter.txx b/include/dummy_filter.txx new file mode 100644 index 0000000000..2ec1ced9e8 --- /dev/null +++ b/include/dummy_filter.txx @@ -0,0 +1,79 @@ +#ifndef __dummy_filter_txx +#define __dummy_filter_txx + +#include "dummy_filter.h" +#include <fstream> + + +#include "itkObjectFactory.h" +#include "itkImageRegionIterator.h" +#include "itkImageRegionConstIterator.h" +#include "otbVectorImage.h" + +/* +#include <shark/Data/Csv.h> +#include <shark/Data/Pgm.h> //for exporting the learned filters +#include <shark/Data/SparseData.h>//for reading in the images as sparseData/Libsvm format +#include <shark/Models/Autoencoder.h>//normal autoencoder model +#include <shark/Models/TiedAutoencoder.h>//autoencoder with tied weights +#include <shark/Models/Normalizer.h> +#include <shark/Algorithms/Trainers/NormalizeComponentsUnitVariance.h> +*/ + +//using namespace shark; + +template< class TImage> +DummyFilter<TImage>::DummyFilter() +{ + this->SetNumberOfRequiredInputs(1); +} + + + +template< class TImage> +typename TImage::ConstPointer DummyFilter<TImage>::GetInputImage() +{ + return static_cast< const TImage * > + ( this->itk::ProcessObject::GetInput(0) ); +} + + + + + +template< class TImage> +void DummyFilter<TImage>::BeforeThreadedGenerateData() +{ +#ifdef _OPENMP +// OpenMP will take care of threading +this->SetNumberOfThreads(1); +#endif +} + + +/*template< class TImage, class AutoencoderModel, class NormalizerModel> +void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GenerateData()*/ +template< class TImage> +void DummyFilter<TImage>::ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) +{ + //Data_with_info info; + typename TImage::ConstPointer input = this->GetInput(); + typename TImage::Pointer output = this->GetOutput(); + + // Image to vector + const unsigned int img_bands = input->GetNumberOfComponentsPerPixel(); + + itk::ImageRegionConstIterator<TImage> inputIterator(input,outputRegionForThread); + itk::ImageRegionIterator<TImage> imageIteratorOut(output,outputRegionForThread); + + typename TImage::PixelType pixelValue; + while(!inputIterator.IsAtEnd()){ + imageIteratorOut.Set(inputIterator.Get()); + ++inputIterator; + ++imageIteratorOut; + } + +} + + +#endif -- GitLab From 9e6b26abe32b44a4592def3632dfd3a899fdcdd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 2 May 2017 10:16:44 +0200 Subject: [PATCH 006/567] app cxx added --- app/cbDimensionalityReduction.cxx | 47 ++++++++++++++---------- app/cbDimensionalityReductionTrainer.cxx | 30 ++++++++++++++- 2 files changed, 55 insertions(+), 22 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index a6362a4b4f..a8b0e06e83 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -5,9 +5,7 @@ #include <iostream> #include "otbImage.h" -//#include "otbVectorImage.h" -#include "otbImageFileReader.h" -#include "otbImageFileWriter.h" +#include "otbVectorImage.h" #include <shark/Models/Autoencoder.h>//normal autoencoder model @@ -16,6 +14,7 @@ #include <shark/Models/Normalizer.h> #include "encode_filter.h" +//#include "dummy_filter.h" namespace otb { @@ -25,11 +24,18 @@ namespace Wrapper class CbDimensionalityReduction : public otb::Wrapper::Application { public: - typedef CbDimensionalityReduction Self; + /** Standard class typedefs. */ + typedef CbDimensionalityReduction Self; + typedef Application Superclass; typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + + /** Standard macro */ itkNewMacro(Self); - itkTypeMacro(CbDimensionalityReduction, otb::Wrapper::Application); + itkTypeMacro(CbDimensionalityReduction, otb::Application); private: + void DoInit() { SetName("CbDimensionalityReduction"); @@ -56,33 +62,34 @@ private: void DoExecute() { - typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - - using image_type = otb::VectorImage<double, 2>; + typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; + using image_type = FloatVectorImageType; using FilterType = EncodeFilter<image_type, AutoencoderType, shark::Normalizer<shark::RealVector>> ; + using DummyFilterType = DummyFilter<image_type> ; std::cout << "Appli !" << std::endl; FloatVectorImageType::Pointer inImage = GetParameterImage("in"); std::string encoderPath = GetParameterString("model"); std::string normalizerPath = GetParameterString("normalizer"); - //inImage->UpdateOutputInformation(); - - using ReaderType = otb::ImageFileReader<image_type>; - - ReaderType::Pointer reader = ReaderType::New(); - reader->SetFileName("/mnt/data/home/vincenta/features_2014/SL_MultiTempGapF_Brightness_NDVI_NDWI__.tif"); - FilterType::Pointer filter = FilterType::New(); filter->SetAutoencoderModel(encoderPath); filter->SetNormalizerModel(normalizerPath); - filter->SetInput(reader->GetOutput()); - //filter->SetInput(inImage); - - filter->UpdateOutputInformation(); - + filter->SetInput(inImage); + filter->Update(); SetParameterOutputImage("out", filter->GetOutput()); +/* + DummyFilterType::Pointer dummy_filter = DummyFilterType::New(); // this filter simply copies the input image (do not need shark library) + dummy_filter->SetInput(GetParameterFloatVectorImage("in")); + dummy_filter->Update(); + dummy_filter->UpdateOutputInformation(); + SetParameterOutputImage("out", dummy_filter->GetOutput()); + +*/ + + //SetParameterOutputImage("out", inImage); // copy input image + } }; diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index cd18d7e5c4..92e23672e5 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -1,6 +1,14 @@ #include "otbWrapperApplication.h" #include "otbWrapperApplicationFactory.h" +#include "otbWrapperChoiceParameter.h" +#include "otbOGRDataSourceWrapper.h" +#include "otbOGRFeatureWrapper.h" + +namespace otb +{ +namespace Wrapper +{ class CbDimensionalityReductionTrainer : public otb::Wrapper::Application { public: @@ -13,6 +21,14 @@ private: { SetName("CbDimensionalityReductionTrainer"); SetDescription("Trainer for the dimensionality reduction algorithms used in the cbDimensionalityReduction application."); + + + AddParameter(ParameterType_InputVectorData, "train", "Name of the input training vector data"); + SetParameterDescription("train","The vector data used for training."); +/* + AddParameter(ParameterType_InputVectorData, "val", "Name of the input validation vector data"); + SetParameterDescription("val","The vector data used for validation."); +*/ AddRAMParameter(); } @@ -23,9 +39,19 @@ private: void DoExecute() { std::cout << "Appli !" << std::endl; - int ThisDoesNothing = 0; + std::string shapefile = GetParameterString("train"); + otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); + otb::ogr::Layer layer = source->GetLayer(0); + //ListSampleType::Pointer input = ListSampleType::New(); + //const int nbFeatures = GetSelectedItems("feat").size(); + //input->SetMeasurementVectorSize(nbFeatures); + } }; -OTB_APPLICATION_EXPORT(CbDimensionalityReductionTrainer) + +} +} + +OTB_APPLICATION_EXPORT(otb::Wrapper::CbDimensionalityReductionTrainer) -- GitLab From 25e4c6a21856f940a4dcc8da5d34caba5bc7ac9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 3 May 2017 10:44:29 +0200 Subject: [PATCH 007/567] dimreduc model added (not used at the moment), trainer app working for autoencoder --- include/AutoencoderModel.h | 44 +++++++++++++++++++++++ include/AutoencoderModel.txx | 20 +++++++++++ include/DimensionalityReductionModel.h | 48 ++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 include/AutoencoderModel.h create mode 100644 include/AutoencoderModel.txx create mode 100644 include/DimensionalityReductionModel.h diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h new file mode 100644 index 0000000000..f545a72284 --- /dev/null +++ b/include/AutoencoderModel.h @@ -0,0 +1,44 @@ +#ifndef AutoencoderModel_h +#define AutoencoderModel_h + +#include "DimensionalityReductionModel.h" + + +namespace otb +{ +template <class TInputValue, class AutoencoderType> +class AutoencoderModel: public DimensionalityReductionModel<TInputValue> +{ + +public: + + typedef AutoencoderModel Self; + typedef DimensionalityReductionModel<TInputValue> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef TInputValue InputValueType; + typedef itk::VariableLengthVector<InputValueType> InputSampleType; + typedef itk::Statistics::ListSample<InputSampleType> InputListSampleType; + + + + void Save(const std::string & filename, const std::string & name="") {}; + void Load(const std::string & filename, const std::string & name="") {}; + + void Train(); + void Dimensionality_reduction() {}; + +protected: + AutoencoderModel(){}; + +}; +} // end namespace otb + + +#ifndef OTB_MANUAL_INSTANTIATION +#include "AutoencoderModel.txx" +#endif + + +#endif diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx new file mode 100644 index 0000000000..9a51269360 --- /dev/null +++ b/include/AutoencoderModel.txx @@ -0,0 +1,20 @@ +#ifndef AutoencoderModel_txx +#define AutoencoderModel_txx + + +#include "AutoencoderModel.h" +namespace otb +{ + +template <class TInputValue, class AutoencoderType> +void AutoencoderModel<TInputValue,AutoencoderType>::Train() +{ + +} + + + + + +} // namespace otb +#endif diff --git a/include/DimensionalityReductionModel.h b/include/DimensionalityReductionModel.h new file mode 100644 index 0000000000..05066e976b --- /dev/null +++ b/include/DimensionalityReductionModel.h @@ -0,0 +1,48 @@ +#ifndef DimensionalityReductionModel_h +#define DimensionalityReductionModel_h +#include "itkObject.h" +#include "itkListSample.h" +namespace otb +{ +template <class TInputValue> +class DimensionalityReductionModel: public itk::Object +{ + +public: + + typedef DimensionalityReductionModel Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef TInputValue InputValueType; + typedef itk::VariableLengthVector<InputValueType> InputSampleType; + typedef itk::Statistics::ListSample<InputSampleType> InputListSampleType; + + + + itkSetObjectMacro(InputListSample,InputListSampleType); + itkGetObjectMacro(InputListSample,InputListSampleType); + itkGetConstObjectMacro(InputListSample,InputListSampleType); + + virtual void Save(const std::string & filename, const std::string & name="") = 0; + virtual void Load(const std::string & filename, const std::string & name="") = 0; + + virtual void Train() = 0; + virtual void Dimensionality_reduction() = 0; + +protected: + DimensionalityReductionModel(){}; + typename InputListSampleType::Pointer m_InputListSample; + + +}; +} // end namespace otb + + +//#ifndef OTB_MANUAL_INSTANTIATION +//#include "DimensionalityReductionModel.txx" +//#endif + + +#endif -- GitLab From 7187352c7348dd42173b6d6505bf3c34d6c68e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 3 May 2017 10:49:00 +0200 Subject: [PATCH 008/567] missing file in the last commit added --- app/CMakeLists.txt | 2 +- app/cbDimensionalityReduction.cxx | 29 +++-- app/cbDimensionalityReductionTrainer.cxx | 135 +++++++++++++++++++++-- otb-module.cmake | 1 + 4 files changed, 144 insertions(+), 23 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 5dc561a085..720a15197b 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,7 +1,7 @@ OTB_CREATE_APPLICATION( NAME CbDimensionalityReductionTrainer SOURCES cbDimensionalityReductionTrainer.cxx -LINK_LIBRARIES ${${otb-module}_LIBRARIES} +LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBITK_LIBRARIES} ${OTBBoost_LIBRARIES} ${OTBShark_LIBRARIES} ) OTB_CREATE_APPLICATION( diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index a8b0e06e83..d2b6666079 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -1,20 +1,17 @@ #include "otbWrapperApplication.h" #include "otbWrapperApplicationFactory.h" -#include "otbWrapperChoiceParameter.h" #include <iostream> #include "otbImage.h" #include "otbVectorImage.h" - #include <shark/Models/Autoencoder.h>//normal autoencoder model - #include <shark/Models/TiedAutoencoder.h>//autoencoder with tied weights #include <shark/Models/Normalizer.h> - #include "encode_filter.h" -//#include "dummy_filter.h" + +#include "dummy_filter.h" namespace otb { @@ -31,6 +28,11 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; + using image_type = FloatVectorImageType; + + typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; + using FilterType = EncodeFilter<image_type, AutoencoderType, shark::Normalizer<shark::RealVector>> ; + /** Standard macro */ itkNewMacro(Self); itkTypeMacro(CbDimensionalityReduction, otb::Application); @@ -62,36 +64,33 @@ private: void DoExecute() { - typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - using image_type = FloatVectorImageType; - using FilterType = EncodeFilter<image_type, AutoencoderType, shark::Normalizer<shark::RealVector>> ; - using DummyFilterType = DummyFilter<image_type> ; - std::cout << "Appli !" << std::endl; + std::cout << "Appli" << std::endl; FloatVectorImageType::Pointer inImage = GetParameterImage("in"); std::string encoderPath = GetParameterString("model"); std::string normalizerPath = GetParameterString("normalizer"); - FilterType::Pointer filter = FilterType::New(); + filter = FilterType::New(); filter->SetAutoencoderModel(encoderPath); filter->SetNormalizerModel(normalizerPath); filter->SetInput(inImage); - filter->Update(); + //filter->Update(); SetParameterOutputImage("out", filter->GetOutput()); - /* + + using DummyFilterType = DummyFilter<image_type> ; DummyFilterType::Pointer dummy_filter = DummyFilterType::New(); // this filter simply copies the input image (do not need shark library) dummy_filter->SetInput(GetParameterFloatVectorImage("in")); dummy_filter->Update(); - dummy_filter->UpdateOutputInformation(); SetParameterOutputImage("out", dummy_filter->GetOutput()); - */ + //SetParameterOutputImage("out", inImage); // copy input image } + FilterType::Pointer filter; }; } } diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index 92e23672e5..7250e35ddd 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -1,10 +1,74 @@ #include "otbWrapperApplication.h" #include "otbWrapperApplicationFactory.h" -#include "otbWrapperChoiceParameter.h" #include "otbOGRDataSourceWrapper.h" #include "otbOGRFeatureWrapper.h" +#include "itkVariableLengthVector.h" + +#include "AutoencoderModel.h" + +#include "otbSharkUtils.h" + +//include train function +#include <shark/ObjectiveFunctions/ErrorFunction.h> +#include <shark/Algorithms/GradientDescent/Rprop.h>// the RProp optimization algorithm +#include <shark/ObjectiveFunctions/Loss/SquaredLoss.h> // squared loss used for regression +#include <shark/ObjectiveFunctions/Regularizer.h> //L2 regulariziation + +#include <fstream> // write the model file + + +#include <shark/Models/Autoencoder.h>//normal autoencoder model +#include <shark/Models/TiedAutoencoder.h>//autoencoder with tied weights +#include <shark/Models/Normalizer.h> + +#include <shark/Algorithms/Trainers/NormalizeComponentsUnitVariance.h> + + +template<class AutoencoderModel> +AutoencoderModel trainAutoencoderModel( + shark::UnlabeledData<shark::RealVector> const& data,//the data to train with + std::size_t numHidden,//number of features in the autoencoder + std::size_t iterations, //number of iterations to optimize + double regularisation//strength of the regularisation +){ + //create the model + std::size_t inputs = dataDimension(data); + AutoencoderModel model; + model.setStructure(inputs, numHidden); + initRandomUniform(model,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + //create the objective function + + shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(data,data);//labels identical to inputs + shark::SquaredLoss<shark::RealVector> loss; + shark::ErrorFunction error(trainSet, &model, &loss); + shark::TwoNormRegularizer regularizer(error.numberOfVariables()); + error.setRegularizer(regularisation,®ularizer); + + shark::IRpropPlusFull optimizer; + error.init(); + optimizer.init(error); + std::cout<<"Optimizing model: "+model.name()<<std::endl; + for(std::size_t i = 0; i != iterations; ++i){ + optimizer.step(error); + std::cout<<i<<" "<<optimizer.solution().value<<std::endl; + } + //std::cout<<optimizer.solution().value<<std::endl; + model.setParameterVector(optimizer.solution().point); + return model; +} + +shark::Normalizer<shark::RealVector> trainNormalizer(const shark::UnlabeledData<shark::RealVector>& data) +{ + bool removeMean = true; + shark::Normalizer<shark::RealVector> normalizer; + shark::NormalizeComponentsUnitVariance<shark::RealVector> normalizingTrainer(removeMean); + normalizingTrainer.train(normalizer, data); + return normalizer; +} + + namespace otb { namespace Wrapper @@ -15,16 +79,27 @@ public: typedef CbDimensionalityReductionTrainer Self; typedef itk::SmartPointer<Self> Pointer; itkNewMacro(Self); - itkTypeMacro(CbDimensionalityReductionTrainer, otb::Wrapper::Application); + itkTypeMacro(CbDimensionalityReductionTrainer, otb::Application); + + + typedef double ValueType; + typedef itk::VariableLengthVector<ValueType> InputSampleType; + typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; + + typedef itk::VariableLengthVector<ValueType> MeasurementType; + + private: void DoInit() { SetName("CbDimensionalityReductionTrainer"); SetDescription("Trainer for the dimensionality reduction algorithms used in the cbDimensionalityReduction application."); - - AddParameter(ParameterType_InputVectorData, "train", "Name of the input training vector data"); SetParameterDescription("train","The vector data used for training."); + + AddParameter(ParameterType_StringList, "feat", "Field names to be calculated."); // + SetParameterDescription("feat","List of field names in the input vector data used as features for training."); // + /* AddParameter(ParameterType_InputVectorData, "val", "Name of the input validation vector data"); SetParameterDescription("val","The vector data used for validation."); @@ -38,14 +113,60 @@ private: void DoExecute() { + std::cout << "Appli !" << std::endl; + std::string shapefile = GetParameterString("train"); + otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); otb::ogr::Layer layer = source->GetLayer(0); - //ListSampleType::Pointer input = ListSampleType::New(); - //const int nbFeatures = GetSelectedItems("feat").size(); - //input->SetMeasurementVectorSize(nbFeatures); + ListSampleType::Pointer input = ListSampleType::New(); + const int nbFeatures = GetParameterStringList("feat").size(); + input->SetMeasurementVectorSize(nbFeatures); + otb::ogr::Layer::const_iterator it = layer.cbegin(); + otb::ogr::Layer::const_iterator itEnd = layer.cend(); + for( ; it!=itEnd ; ++it) + { + MeasurementType mv; + mv.SetSize(nbFeatures); + for(int idx=0; idx < nbFeatures; ++idx) + { + mv[idx] = (*it)[GetParameterStringList("feat")[idx]].GetValue<double>(); + } + input->PushBack(mv); + } + std::cout << input << std::endl; + std::vector<shark::RealVector> features; + otb::Shark::ListSampleToSharkVector<ListSampleType>( input, features); + shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); + + std::size_t numHidden= 5; // stoi convert string to int + std::size_t iterations = 10; + double regularisation = 0; // stod convert string to double + + + shark::Normalizer<shark::RealVector> normalizer = trainNormalizer(inputSamples); + inputSamples = normalizer(inputSamples); + + std::cout << "normalizer trained and training set normalized" << std::endl; + + typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; + AutoencoderType net = trainAutoencoderModel<AutoencoderType>(inputSamples,numHidden,iterations,regularisation); + std::cout << "autoencoder trained !!" << std::endl; + + // save the model to the file "net.model" + std::ofstream ofs("net.model"); + boost::archive::polymorphic_text_oarchive oa(ofs); + net.write(oa); + ofs.close(); + + // save the model to the file "net.model" + std::ofstream norm_ofs("normalizer.model"); + boost::archive::polymorphic_text_oarchive onorm(norm_ofs); + normalizer.write(onorm); + norm_ofs.close(); + } }; diff --git a/otb-module.cmake b/otb-module.cmake index 5797e5c7cb..d1bd695426 100644 --- a/otb-module.cmake +++ b/otb-module.cmake @@ -6,6 +6,7 @@ otb_module(CbDimensionalityReduction OTBITK OTBShark OTBBoost + OTBSupervised DESCRIPTION "${DOCUMENTATION}" ) -- GitLab From dfc3280ce20b3f551c8eae763d06a8e93041f872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 4 May 2017 14:47:26 +0200 Subject: [PATCH 009/567] trainer and dimreduc app working for simple autoencoders --- app/cbDimensionalityReduction.cxx | 44 +++++++++++++----------- app/cbDimensionalityReductionTrainer.cxx | 17 +++++++-- include/encode_filter.h | 9 ++--- include/encode_filter.txx | 8 ++--- 4 files changed, 47 insertions(+), 31 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index d2b6666079..a539b66c13 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -12,6 +12,7 @@ #include "encode_filter.h" #include "dummy_filter.h" +#include "otbMultiChannelExtractROI.h" namespace otb { @@ -32,7 +33,7 @@ public: typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; using FilterType = EncodeFilter<image_type, AutoencoderType, shark::Normalizer<shark::RealVector>> ; - + typedef otb::MultiChannelExtractROI<FloatVectorImageType::InternalPixelType, FloatVectorImageType::InternalPixelType> ExtractROIFilterType; /** Standard macro */ itkNewMacro(Self); itkTypeMacro(CbDimensionalityReduction, otb::Application); @@ -51,7 +52,7 @@ private: AddParameter(ParameterType_InputFilename, "normalizer", "Normalizer model file"); SetParameterDescription("normalizer", "A normalizer model file (produced by the cbDimensionalityReductionTrainer application)."); - + AddParameter(ParameterType_OutputImage, "out", "Output Image"); SetParameterDescription("out", "Output image"); @@ -61,36 +62,39 @@ private: void DoUpdateParameters() { } - + void DoExecute() { - std::cout << "Appli" << std::endl; - FloatVectorImageType::Pointer inImage = GetParameterImage("in"); + image_type::Pointer inImage = GetParameterImage("in"); std::string encoderPath = GetParameterString("model"); std::string normalizerPath = GetParameterString("normalizer"); - filter = FilterType::New(); - filter->SetAutoencoderModel(encoderPath); - filter->SetNormalizerModel(normalizerPath); - filter->SetInput(inImage); - //filter->Update(); - SetParameterOutputImage("out", filter->GetOutput()); -/* - - using DummyFilterType = DummyFilter<image_type> ; - DummyFilterType::Pointer dummy_filter = DummyFilterType::New(); // this filter simply copies the input image (do not need shark library) - dummy_filter->SetInput(GetParameterFloatVectorImage("in")); - dummy_filter->Update(); - SetParameterOutputImage("out", dummy_filter->GetOutput()); -*/ + + filter_dim_reduc = FilterType::New(); + filter_dim_reduc->SetAutoencoderModel(encoderPath); + filter_dim_reduc->SetNormalizerModel(normalizerPath); + filter_dim_reduc->SetInput(inImage); + //SetParameterOutputImage("out", filter_dim_reduc->GetOutput()); + + m_ExtractROIFilter = ExtractROIFilterType::New(); + m_ExtractROIFilter->SetInput(filter_dim_reduc->GetOutput()); + for (unsigned int idx = 1; idx <= filter_dim_reduc->GetDimension(); ++idx) + { + m_ExtractROIFilter->SetChannel(idx ); + } + + SetParameterOutputImage("out", m_ExtractROIFilter->GetOutput()); + //SetParameterOutputImage("out", inImage); // copy input image } - FilterType::Pointer filter; + FilterType::Pointer filter_dim_reduc; + ExtractROIFilterType::Pointer m_ExtractROIFilter; + }; } } diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index 7250e35ddd..2ceb73d902 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -99,7 +99,18 @@ private: AddParameter(ParameterType_StringList, "feat", "Field names to be calculated."); // SetParameterDescription("feat","List of field names in the input vector data used as features for training."); // + + AddParameter(ParameterType_Int, "k","target dimension"); + SetParameterDescription("k", "Dimension of the output feature vectors"); + + /* + AddParameter(ParameterType_InputFilename, "model", "Dimensionality Reduction model file"); + SetParameterDescription("model", "A model file (produced by cbDimensionalityReduction application."); + AddParameter(ParameterType_InputFilename, "normalizer", "normalizer model file"); + SetParameterDescription("normalizer", "A model file (produced by cbDimensionalityReduction application."); +*/ + /* AddParameter(ParameterType_InputVectorData, "val", "Name of the input validation vector data"); SetParameterDescription("val","The vector data used for validation."); @@ -141,9 +152,9 @@ private: otb::Shark::ListSampleToSharkVector<ListSampleType>( input, features); shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - std::size_t numHidden= 5; // stoi convert string to int - std::size_t iterations = 10; - double regularisation = 0; // stod convert string to double + std::size_t numHidden= GetParameterInt("k"); + std::size_t iterations = 100; + double regularisation = 0; shark::Normalizer<shark::RealVector> normalizer = trainNormalizer(inputSamples); diff --git a/include/encode_filter.h b/include/encode_filter.h index 9a6b70c117..6b5e361fb3 100644 --- a/include/encode_filter.h +++ b/include/encode_filter.h @@ -24,15 +24,15 @@ class ITK_EXPORT EncodeFilter:public itk::ImageToImageFilter< TImage, TImage > void SetAutoencoderModel(const std::string encoderPath); void SetNormalizerModel(const std::string NormalizerPath); void SetModels( const AutoencoderModel net, const NormalizerModel normalizer); - + std::size_t GetDimension(){return m_hidden_neuron;}; protected: EncodeFilter(); ~EncodeFilter(){} - + typename TImage::ConstPointer GetInputImage(); AutoencoderModel GetAutoencoderModel(); NormalizerModel GetNormalizerModel(); - + /** Does the real work. */ virtual void BeforeThreadedGenerateData(); @@ -42,7 +42,8 @@ class ITK_EXPORT EncodeFilter:public itk::ImageToImageFilter< TImage, TImage > EncodeFilter(const Self &); //purposely not implemented void operator=(const Self &); //purposely not implemented AutoencoderModel m_net; - NormalizerModel m_normalizer; + NormalizerModel m_normalizer; + std::size_t m_hidden_neuron; }; #ifndef ITK_MANUAL_INSTANTIATION diff --git a/include/encode_filter.txx b/include/encode_filter.txx index adb071854f..8e7b334a9a 100644 --- a/include/encode_filter.txx +++ b/include/encode_filter.txx @@ -37,6 +37,7 @@ void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::SetAutoencoderMode boost::archive::polymorphic_text_iarchive ia(ifs); m_net.read(ia); ifs.close(); + m_hidden_neuron = m_net.numberOfHiddenNeurons(); } @@ -101,15 +102,13 @@ this->SetNumberOfThreads(1); } -/*template< class TImage, class AutoencoderModel, class NormalizerModel> -void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GenerateData()*/ + template< class TImage, class AutoencoderModel, class NormalizerModel> void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) { //Data_with_info info; typename TImage::ConstPointer input = this->GetInput(); typename TImage::Pointer output = this->GetOutput(); - // Image to vector const unsigned int img_bands = input->GetNumberOfComponentsPerPixel(); @@ -149,11 +148,12 @@ void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::ThreadedGenerateDa for(unsigned int a = 0; a < numHidden; ++a){ pixelValue[a]=vect_out[a]; } - + imageIteratorOut.Set(pixelValue); ++imageIteratorOut; ++vect_it; } + } -- GitLab From 2f6c48cdf8d36fcff9295c51910d176d737c356d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 9 May 2017 17:09:45 +0200 Subject: [PATCH 010/567] app training working for autoencoder and tied autoencoder using the autoencodermodel class --- app/cbDimensionalityReduction.cxx | 7 +- app/cbDimensionalityReductionTrainer.cxx | 66 +++++++++-- include/AutoencoderModel.h | 52 ++++++-- include/AutoencoderModel.h.gch | Bin 0 -> 8399 bytes include/AutoencoderModel.txx | 83 ++++++++++++- include/AutoencoderModelFactory.h | 50 ++++++++ include/AutoencoderModelFactory.txx | 64 ++++++++++ include/cbLearningApplicationBaseDR.h | 144 +++++++++++++++++++++++ include/cbLearningApplicationBaseDR.txx | 122 +++++++++++++++++++ include/cbTrainAutoencoder.txx | 65 ++++++++++ include/encode_filter.h | 2 +- include/encode_filter.txx | 9 +- otb-module.cmake | 1 + 13 files changed, 635 insertions(+), 30 deletions(-) create mode 100644 include/AutoencoderModel.h.gch create mode 100644 include/AutoencoderModelFactory.h create mode 100644 include/AutoencoderModelFactory.txx create mode 100644 include/cbLearningApplicationBaseDR.h create mode 100644 include/cbLearningApplicationBaseDR.txx create mode 100644 include/cbTrainAutoencoder.txx diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index a539b66c13..b195d053ba 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -11,7 +11,6 @@ #include <shark/Models/Normalizer.h> #include "encode_filter.h" -#include "dummy_filter.h" #include "otbMultiChannelExtractROI.h" namespace otb @@ -77,8 +76,8 @@ private: filter_dim_reduc->SetNormalizerModel(normalizerPath); filter_dim_reduc->SetInput(inImage); - //SetParameterOutputImage("out", filter_dim_reduc->GetOutput()); - + SetParameterOutputImage("out", filter_dim_reduc->GetOutput()); +/* m_ExtractROIFilter = ExtractROIFilterType::New(); m_ExtractROIFilter->SetInput(filter_dim_reduc->GetOutput()); for (unsigned int idx = 1; idx <= filter_dim_reduc->GetDimension(); ++idx) @@ -87,7 +86,7 @@ private: } SetParameterOutputImage("out", m_ExtractROIFilter->GetOutput()); - +*/ //SetParameterOutputImage("out", inImage); // copy input image } diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index 2ceb73d902..9c7cc45142 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -6,10 +6,10 @@ #include "itkVariableLengthVector.h" -#include "AutoencoderModel.h" +//#include "AutoencoderModel.h" #include "otbSharkUtils.h" - +#include "otbMachineLearningModel.h" //include train function #include <shark/ObjectiveFunctions/ErrorFunction.h> #include <shark/Algorithms/GradientDescent/Rprop.h>// the RProp optimization algorithm @@ -25,6 +25,9 @@ #include <shark/Algorithms/Trainers/NormalizeComponentsUnitVariance.h> +#include "otbMachineLearningModelFactory.h" + +#include "cbLearningApplicationBaseDR.h" template<class AutoencoderModel> AutoencoderModel trainAutoencoderModel( @@ -73,27 +76,36 @@ namespace otb { namespace Wrapper { -class CbDimensionalityReductionTrainer : public otb::Wrapper::Application +class CbDimensionalityReductionTrainer : public cbLearningApplicationBaseDR<float,float> { public: typedef CbDimensionalityReductionTrainer Self; + typedef cbLearningApplicationBaseDR<float, float> Superclass; typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + itkNewMacro(Self); itkTypeMacro(CbDimensionalityReductionTrainer, otb::Application); - typedef double ValueType; + typedef float ValueType; typedef itk::VariableLengthVector<ValueType> InputSampleType; typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; typedef itk::VariableLengthVector<ValueType> MeasurementType; - + + typedef otb::MachineLearningModelFactory<ValueType, ValueType> ModelFactoryType; + + typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; + typedef AutoencoderModel<ValueType,AutoencoderType> AutoencoderModelType; +typedef RandomForestsMachineLearningModel<ValueType,int> rfModelType; private: void DoInit() { SetName("CbDimensionalityReductionTrainer"); SetDescription("Trainer for the dimensionality reduction algorithms used in the cbDimensionalityReduction application."); + /* AddParameter(ParameterType_InputVectorData, "train", "Name of the input training vector data"); SetParameterDescription("train","The vector data used for training."); @@ -102,6 +114,22 @@ private: AddParameter(ParameterType_Int, "k","target dimension"); SetParameterDescription("k", "Dimension of the output feature vectors"); +*/ + AddParameter(ParameterType_Group, "io", "Input and output data"); + SetParameterDescription("io", "This group of parameters allows setting input and output data."); + + AddParameter(ParameterType_InputVectorData, "io.vd", "Input Vector Data"); + SetParameterDescription("io.vd", "Input geometries used for training (note : all geometries from the layer will be used)"); + + AddParameter(ParameterType_OutputFilename, "io.out", "Output model"); + SetParameterDescription("io.out", "Output file containing the model estimated (.txt format)."); + + + AddParameter(ParameterType_StringList, "feat", "Field names to be calculated."); // + SetParameterDescription("feat","List of field names in the input vector data used as features for training."); // + + Superclass::DoInit(); + /* AddParameter(ParameterType_InputFilename, "model", "Dimensionality Reduction model file"); @@ -127,7 +155,7 @@ private: std::cout << "Appli !" << std::endl; - std::string shapefile = GetParameterString("train"); + std::string shapefile = GetParameterString("io.vd"); otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); otb::ogr::Layer layer = source->GetLayer(0); @@ -147,6 +175,7 @@ private: } input->PushBack(mv); } + /* std::cout << input << std::endl; std::vector<shark::RealVector> features; otb::Shark::ListSampleToSharkVector<ListSampleType>( input, features); @@ -162,13 +191,12 @@ private: std::cout << "normalizer trained and training set normalized" << std::endl; - typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; AutoencoderType net = trainAutoencoderModel<AutoencoderType>(inputSamples,numHidden,iterations,regularisation); - std::cout << "autoencoder trained !!" << std::endl; + std::cout << "autoencoder trained !!!!" << std::endl; // save the model to the file "net.model" std::ofstream ofs("net.model"); - boost::archive::polymorphic_text_oarchive oa(ofs); + shark::TextOutArchive oa(ofs); net.write(oa); ofs.close(); @@ -177,9 +205,27 @@ private: boost::archive::polymorphic_text_oarchive onorm(norm_ofs); normalizer.write(onorm); norm_ofs.close(); - + */ + + std::cout << "Using a Machine learning model" << std::endl; + /* + AutoencoderModelType::Pointer dimredTrainer = AutoencoderModelType::New(); + dimredTrainer->SetNumberOfHiddenNeurons(5); + dimredTrainer->SetNumberOfIterations(50); + dimredTrainer->SetRegularization(0.1); + dimredTrainer->SetInputListSample(input); + dimredTrainer->Train(); + dimredTrainer->Save("net.model"); + std::cout << "ok" << std::endl; + */ + this->Train(input,GetParameterString("io.out")); + } + + + + }; diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index f545a72284..603f0dc4d2 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -1,37 +1,64 @@ #ifndef AutoencoderModel_h #define AutoencoderModel_h -#include "DimensionalityReductionModel.h" +#include "otbMachineLearningModel.h" namespace otb { template <class TInputValue, class AutoencoderType> -class AutoencoderModel: public DimensionalityReductionModel<TInputValue> +class ITK_EXPORT AutoencoderModel: public MachineLearningModel<TInputValue,TInputValue> { public: typedef AutoencoderModel Self; - typedef DimensionalityReductionModel<TInputValue> Superclass; + typedef MachineLearningModel<TInputValue,TInputValue> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - typedef TInputValue InputValueType; - typedef itk::VariableLengthVector<InputValueType> InputSampleType; - typedef itk::Statistics::ListSample<InputSampleType> InputListSampleType; + typedef typename Superclass::InputValueType InputValueType; + typedef typename Superclass::InputSampleType InputSampleType; + typedef typename Superclass::InputListSampleType InputListSampleType; + typedef typename Superclass::TargetValueType TargetValueType; + typedef typename Superclass::TargetSampleType TargetSampleType; + typedef typename Superclass::TargetListSampleType TargetListSampleType; + typedef typename Superclass::ConfidenceValueType ConfidenceValueType; + typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; + typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; + itkNewMacro(Self); + itkTypeMacro(AutoencoderModel, MachineLearningModel); - - void Save(const std::string & filename, const std::string & name="") {}; - void Load(const std::string & filename, const std::string & name="") {}; - void Train(); - void Dimensionality_reduction() {}; + itkGetMacro(NumberOfHiddenNeurons,unsigned int); + itkSetMacro(NumberOfHiddenNeurons,unsigned int); + + itkGetMacro(NumberOfIterations,unsigned int); + itkSetMacro(NumberOfIterations,unsigned int); + + itkGetMacro(Regularization,double); + itkSetMacro(Regularization,double); + + bool CanReadFile(const std::string & filename); + bool CanWriteFile(const std::string & filename); + + void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + + void Train() ITK_OVERRIDE; + //void Dimensionality_reduction() {}; // Dimensionality reduction is done by DoPredict + protected: AutoencoderModel(){}; - +private: + virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + + AutoencoderType m_net; + unsigned int m_NumberOfHiddenNeurons; + unsigned int m_NumberOfIterations; + double m_Regularization; }; } // end namespace otb @@ -42,3 +69,4 @@ protected: #endif + diff --git a/include/AutoencoderModel.h.gch b/include/AutoencoderModel.h.gch new file mode 100644 index 0000000000000000000000000000000000000000..298f5cae3a31fa80eb0653035130a574619c25e6 GIT binary patch literal 8399 zcmb7J$#Uez5!J}Myf5;;z>*iXM(jWp3fmEEph<+#iyGjN<4eVu!x&A7;wWYb>*62r zS>NEB|G_7p9N}MazRCisfNpAGOgD#Jg{rK~moHydKl%9T;`!5;*Pnj6zW*Qb;Gh5c z$LsI?{l9-pU%U63`T6&o|Ks2MC%t3fo*i}n8HO?8lPoz-)bJ5c{tEu?pPT&mbu(sG zc2nq2{x^9Lf7&0j+`X^&f0;k~vC;2)Pp)sTpFh1KtHzUlM$^7eFRjayMz89%t}eG) z2S>*ulw$Tv8v2PDKCjoEZmOc~M50&4CCy3VIEsHnqdzb+if*&27rI!ye_rpZK>nFN z{k9odHl0~o2VySLSmi2;!%Rw<rE!?%>Gg4xE#IQ4)2%YyJ=|8b)vMbVPoLagKMt-w zc=Q~z-Y^T3O)zC~bTtdEg16ren(xu)-!Ws0vtp-D>W-eyen_8u*L;d&WY&He$3GvY zU*LRvE+uo7C#lTi^Iy|AT%`48S5`aS)Lqw9x>}cYv8I)UjMUr18g2cT%B~?YrIJ*s zFpbhMk7JRD_`Jb(Y{!K$kN1;8r7DXOmHvUo;Rmfx7Ylt>Jg9X0aJ|rr&1zfhDqXBg z-Ch)1Edud{=gKcJR|O)a{Sj0~L|LsjyOoXJ<7cn_dUJiG=D7-!I8kw?gj7kalt>Xo zshZgrHY*FnZ)lre4ac?kF^*|Ai}&<$R}qZfqzOMZlK`XYK|wIBy0cA5?hk)Y1HU`8 zLL@c8)vfZ*u!;fll5m`;&x{qq&il6YskX*hI6l37`3o9$ZbIUSaLAn~OlLnGCJZ}z zz{9D4O7e2Gu$FM<MOh4peA5gXv@*Q!(+AW1_?#oaK2C=AY}cbZl4+8{9X!&Qyf^tw z$(iM8Bvej$oyth0NgT@S`znuQ<J{qxz&p>uP@ZfyjUNO+o4EpO0Q}aUH_vXLxEv?% zev4*)gI-$SJiUGONg$9pgTE-a)wZphjY+}kI4PHK7kE(XSGP}TK8Ookpf$Fl2li4M ztj8|k)Tam%pw7Wq*xl}o9Cz%|dRZ%Eit~)p*{pGNthJxs$AOpuNW3apLs9b>E1;p@ z(u;H6;%vL2dEgs|;5(sCd_00WfCqTd(OWE0oK%h8?y6-C(#Bz!@Y}8=j@h(bg;W}Q z7{KysL6pfEyvcM9#FUg1^iT{S@p2|RT~y{Gmtih5;=VA=gp5P_xjs&pj-gL4FZD%L zyoZIRfHa<r=20R=NQjJtpw*~qBr>@^Hh=_iu=6Q{h5+aD-27BIfx^+Pj{!%wZ_pB) zX8;Y%@VrA@zFATL);MV9%A9dqT`hDR=XeB2V<O;@c0){%sD#F3D9HK-{=rs^MG6;3 z9}ltX=m7PKc#WMZ1wQ4YJ-L0w8GxMtBL0|;GgM)d&p0XKuC>YMv!c~hg{w}lxlFl} zp03Xqw3q_)*(iiz*L8IuT-L2tz={Ch@YxVutZM54je!7pOO(CdRpsXVgbE~$C$Nce zcv7F9R&A$?raoP-Dk`)XcPaZ}h7UrT?*PX6YAcSIlS)YPNJJ`2h?wFu%tU;BKMJ#E z2A#o1l3O&G-JwCsC`x4*C0VS}G|s}bfz8aLz%kBLub1_@?jFJjm(sM@K(G0Mb+9Fq znLYoq*%UaL0#*84<!4f^X0D(Ov2tDw2J0Nn4#$}Y6RuAEp+N&ImJFK`iDH}`diC+m zs~30$BF|GH8W4_q+{n6N7ndKfbd+KyD@Apj$EBCYWku|=D2PWGF&5O&lSJ`c)ksY$ zmnj5zA+s@wM^R}qg*R;53Y^`YAt*?74w<FLGlJNzg4tCdA`zw%vV-^CcDu4(E-m37 zikyS_qmLdZBzas!ObV|zx;xudMcHC=CxN}qdyxwXoQ#qSY@q;2Mu6cD^TvQaWKV-g z@N^3$BP5M--5WB+%D@aj=BJRs#YwFnRJ*p`tSOa3iBWb)uf7LiFXI_JiUjtAW_eNU zmQpX4wJzFKAl#{_ozZX;#IOU6l~5DRO_JCE#wM|xOR54X>6?sx5jRFz6y_uwk;IN^ ztPA=INZjizX||M-6cc0^Q%j%2BervF*fZ-%UFszXS(Biq)Ui0QKtzVpvZN%a)RYa3 z;e+m~)0zt8&eczhIbkudu<3=|A$qf1V#9gvxx<Z(<9&i)y>9BYVNwTAGIyeYWj?Ii zpT%goz7BFVJosMGVO43s$2?|$QV@sQI;7^bHWP?N7CGrHHP7ZTN*juC6ddiSD?5Ai zGBBSXtJzyHmn#b>Y$SHh8|-A<U^0z(qpX(tjIo7G8>t{ro2P)@rE$1eYo^)@>d9<h zrh_{=G^`0YXg#XiXsDXX)Hql(NHZcqF3w1ffy3zxBfTl&vcv>7hC9P;xpi$}M19d7 z+xcaHTrX$)`9#}K^67}SVWhiy;F$i!2hX0r90_M=;IGn)RWMp3%cp2f{k4aVnhM1q zX_~|4Q1uS?usHajLIxar?YX1Zs#zkfa89NotHrGyz6lQcK;f<^jaZeaQ|x7f1$+Hq zpXbw){Qw3-*i=+6R`W1Zk}fh*sWK9xN<}IZ*T*6^GJvrSqd?A1lb<&(<&0k1o%Q90 z&ZBxCYyF{ZVp)E8eIk>+tE2&0xF_<tNf<%giIbiNZ8bB+08ZkT#hlY>@XSd$W@`BS zPc#)QY5GfoReOGdMjp+x;ks}RJs#Rx{tnG#!ZRovX{f^}K!uy)l7Mp;!W?1uLUKgd zSjp*3IB#gCqYRCYJvGGm-F4JC&*(W^#gKm3tQ#o1u%u;}2`o|G;S%GQ!*4@@@OHAg z*w>KoJ%e`erc2qqRu{=Ph^!&^_V~MsGF6t4r<_XYMBS?UMBpm?c2}IP3IZ@uEh<WN z*{zEe2`6N-tLNjpJ=0aVu#n4)X+v=k2|E5sYEA$^nF)t8vrv*v&82Y=)Wn2ClrmHe zZPNm5K$(dB2bQ)1mSs+!!gwCTWI(#VuAt5xcXoqaq!>Q~Rk()u8olgA#D2Fy$GRJn z*o47bT`sC^NAj#?mCUx8L|(a~o2Yl`iG4mXNsF6>J(9uog2Ut0v&Yx^BYL~hFFty7 za|13ocsFB(>2S>kSMs(LYvalx)+wUMs3TXxTYj2T6dfu7_-UAZn#T_8cT0ZUvCtYw z8r}nIxRBgUKWuFuT$ecqdNqU_G%`{booPvNqe^{pw>!txVjz%;To=GpOtHy<jGkcK zKO~~TOTf5kDF77?(3`A6en2*`A6SkJ4V28Ll7rf6CplCk%>@D1LFi8pRdECzF-f$~ z^cc=CVx?XolV~qXXd52oc4Tr%Zy_<Q4^G|q-a;7JXq(&Z*@iAF>Gs443F-y`WH`X9 z^S+=GNtB5hyv|zAbar?K2XRO-B<Jw}M*S6Cze?+Q^x|j-eJd?%Za3JWHif;Kh5IRY zEZa6xzgk>UiyTI@Cr21ja$?16lSrr}p~|UUqAQOu3$vIsOVZ4GF4Aa(0s$EDagj5b zRWQib2{Aj*Q)pbK+f(&Aga{Q$;<9jpPCsghEg#<qq;1hHs40IyH;p=oN9+px-_4H@ zMJ_zd(!IQM-}pHBV4OX@v_TZv7<iQU%ezezscRpXm+cP0LppN`o;>WT&ubyzFW1kI zD?On&AIvvw;eS~o<|H*`o~eXVQ)MCz>5CvqmzVJph~uJQ!p7dAs&s&6T;%qIgOk<J z0&b!oCR8iOX1q~EhRKY+xJn4)vCOhKr~6sDOv{$eRp$PMT!q*SY~}W_M8!4C!f3eq z%SQDAn@;Kl!pT9mQVesrZc}5l|CQo`ism^K3mnJR7}OB~Y!J|FTs*KEAN6qYaFoC_ z>18e@o1i_s#2$SC7R~8PFS<gDBavm2zO_q28ArH~j)nQ^k+YGaN=1-i;<*&}?c`F& zV*ORs#65e|(N^#4McV~23N6!BUnKoU{lJGb6K?LmU-~?;OVZXbyO&CQN9R?MNI_J3 zz5xLbLj4HW^1^&gz}N<9_cwT0mO06S#odch_&@?c^Qb&GQ-$IvhjY!(^8B5_GI++w zy+M~9MuA(-V2R$mD;FS`5o)UN_?%HXJ7_T%F7LtuY|8E$j2hJK5G;J7J%|oi(QeLn V3j+Hd4CvAkZD^qOM*6$Z=>J&7Iwb%A literal 0 HcmV?d00001 diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 9a51269360..50fc9940f9 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -1,20 +1,101 @@ + #ifndef AutoencoderModel_txx #define AutoencoderModel_txx +#include <fstream> +#include <shark/Data/Dataset.h> +#include "otbSharkUtils.h" +//include train function +#include <shark/ObjectiveFunctions/ErrorFunction.h> +#include <shark/Algorithms/GradientDescent/Rprop.h>// the RProp optimization algorithm +#include <shark/ObjectiveFunctions/Loss/SquaredLoss.h> // squared loss used for regression +#include <shark/ObjectiveFunctions/Regularizer.h> //L2 regulariziation -#include "AutoencoderModel.h" namespace otb { template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Train() { + + std::vector<shark::RealVector> features; + + Shark::ListSampleToSharkVector(this->GetInputListSample(), features); + + shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); + + std::size_t inputs = dataDimension(inputSamples); + m_net.setStructure(inputs, m_NumberOfHiddenNeurons); + initRandomUniform(m_net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + + shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(inputSamples,inputSamples);//labels identical to inputs + shark::SquaredLoss<shark::RealVector> loss; + shark::ErrorFunction error(trainSet, &m_net, &loss); + shark::TwoNormRegularizer regularizer(error.numberOfVariables()); + error.setRegularizer(m_Regularization,®ularizer); + + shark::IRpropPlusFull optimizer; + error.init(); + optimizer.init(error); + std::cout<<"Optimizing model: "+m_net.name()<<std::endl; + for(std::size_t i = 0; i != m_NumberOfIterations; ++i){ + optimizer.step(error); + std::cout<<i<<" "<<optimizer.solution().value<<std::endl; + } + //std::cout<<optimizer.solution().value<<std::endl; + m_net.setParameterVector(optimizer.solution().point); +} + + +template <class TInputValue, class AutoencoderType> +bool AutoencoderModel<TInputValue,AutoencoderType>::CanReadFile(const std::string & filename) +{ + try + { + this->Load(filename); + m_net.name(); + } + catch(...) + { + return false; + } + return true; +} + +template <class TInputValue, class AutoencoderType> +bool AutoencoderModel<TInputValue,AutoencoderType>::CanWriteFile(const std::string & filename) +{ + return true; } +template <class TInputValue, class AutoencoderType> +void AutoencoderModel<TInputValue,AutoencoderType>::Save(const std::string & filename, const std::string & name) +{ + std::ofstream ofs(filename); + boost::archive::polymorphic_text_oarchive oa(ofs); + m_net.write(oa); + ofs.close(); +} +template <class TInputValue, class AutoencoderType> +void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & filename, const std::string & name) +{ + std::ifstream ifs(filename); + boost::archive::polymorphic_text_iarchive ia(ifs); + m_net.read(ia); + ifs.close(); + m_NumberOfHiddenNeurons = m_net.numberOfHiddenNeurons(); +} +template <class TInputValue, class AutoencoderType> +typename AutoencoderModel<TInputValue,AutoencoderType>::TargetSampleType +AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value, ConfidenceValueType *quality) const +{ + TargetSampleType target; + return target; +} } // namespace otb #endif diff --git a/include/AutoencoderModelFactory.h b/include/AutoencoderModelFactory.h new file mode 100644 index 0000000000..5bead33b9b --- /dev/null +++ b/include/AutoencoderModelFactory.h @@ -0,0 +1,50 @@ +#ifndef AutoencoderModelFactory_h +#define AutoencoderModelFactory_h + + +#include "itkObjectFactoryBase.h" + +namespace otb +{ + +template <class TInputValue, class TTargetValue> +class ITK_EXPORT AutoencoderModelFactory : public itk::ObjectFactoryBase +{ +public: + /** Standard class typedefs. */ + typedef AutoencoderModelFactory Self; + typedef itk::ObjectFactoryBase Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Class methods used to interface with the registered factories. */ + const char* GetITKSourceVersion(void) const ITK_OVERRIDE; + const char* GetDescription(void) const ITK_OVERRIDE; + + /** Method for class instantiation. */ + itkFactorylessNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(AutoencoderModelFactory, itk::ObjectFactoryBase); + + /** Register one factory of this type */ + static void RegisterOneFactory(void) + { + Pointer RFFactory = AutoencoderModelFactory::New(); + itk::ObjectFactoryBase::RegisterFactory(RFFactory); + } + +protected: + AutoencoderModelFactory(); + ~AutoencoderModelFactory() ITK_OVERRIDE; + +private: + AutoencoderModelFactory(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + +}; +} //namespace otb + +#endif + + diff --git a/include/AutoencoderModelFactory.txx b/include/AutoencoderModelFactory.txx new file mode 100644 index 0000000000..272e29bc10 --- /dev/null +++ b/include/AutoencoderModelFactory.txx @@ -0,0 +1,64 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#ifndef AutoencoderModelFactory_txx +#define AutoencoderModelFactory_txx + + +#include "AutoencoderModelFactory.h" + +#include "itkCreateObjectFunction.h" +#include "AutoencoderModel.h" +#include "itkVersion.h" + +namespace otb +{ +template <class TInputValue, class TOutputValue> +AutoencoderModelFactory<TInputValue,TOutputValue>::AutoencoderModelFactory() +{ + + std::string classOverride = std::string("otbMachineLearningModel"); + std::string subclass = std::string("AutoencoderModel"); + + this->RegisterOverride(classOverride.c_str(), + subclass.c_str(), + "Shark RF ML Model", + 1, + // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); + itk::CreateObjectFunction<AutoencoderModel<TInputValue,shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> > >::New()); +} + +template <class TInputValue, class TOutputValue> +AutoencoderModelFactory<TInputValue,TOutputValue>::~AutoencoderModelFactory() +{ +} + +template <class TInputValue, class TOutputValue> +const char* AutoencoderModelFactory<TInputValue,TOutputValue>::GetITKSourceVersion(void) const +{ + return ITK_SOURCE_VERSION; +} + +template <class TInputValue, class TOutputValue> +const char* AutoencoderModelFactory<TInputValue,TOutputValue>::GetDescription() const +{ + return "Autoencoder model factory"; +} + +} // end namespace otb + +#endif diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h new file mode 100644 index 0000000000..fe42e2d875 --- /dev/null +++ b/include/cbLearningApplicationBaseDR.h @@ -0,0 +1,144 @@ +#ifndef cbLearningApplicationBaseDR_h +#define cbLearningApplicationBaseDR_h + +#include "otbConfigure.h" + +#include "otbWrapperApplication.h" + +#include <iostream> + +// ListSample +#include "itkListSample.h" +#include "itkVariableLengthVector.h" + +//Estimator +#include "otbMachineLearningModelFactory.h" + +#ifdef OTB_USE_SHARK +#include "AutoencoderModel.h" +#endif + +namespace otb +{ +namespace Wrapper +{ + +/** \class LearningApplicationBase + * \brief LearningApplicationBase is the base class for application that + * use machine learning model. + * + * This base class offers a DoInit() method to initialize all the parameters + * related to machine learning models. They will all be in the choice parameter + * named "classifier". The class also offers generic Train() and Classify() + * methods. The classes derived from LearningApplicationBase only need these + * 3 methods to handle the machine learning model. + * + * There are multiple machine learning models in OTB, some imported + * from OpenCV and one imported from LibSVM. They all have + * different parameters. The purpose of this class is to handle the + * creation of all parameters related to machine learning models (in + * DoInit() ), and to dispatch the calls to specific train functions + * in function Train(). + * + * This class is templated over scalar types for input and output values. + * Typically, the input value type will be either float of double. The choice + * of an output value type depends on the learning mode. This base class + * supports both classification and regression modes. For classification + * (enabled by default), the output value type corresponds to a class + * identifier so integer types suit well. For regression, the output value + * should not be an integer type, but rather a floating point type. In addition, + * an application deriving this base class for regression should initialize + * the m_RegressionFlag to true in their constructor. + * + * \sa TrainImagesClassifier + * \sa TrainRegression + * + * \ingroup OTBAppClassification + */ +template <class TInputValue, class TOutputValue> +class cbLearningApplicationBaseDR: public Application +{ +public: + /** Standard class typedefs. */ + typedef cbLearningApplicationBaseDR Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Standard macro */ + itkTypeMacro(cbLearningApplicationBaseDR, otb::Application) + + typedef TInputValue InputValueType; + typedef TOutputValue OutputValueType; + + typedef otb::VectorImage<InputValueType> SampleImageType; + typedef typename SampleImageType::PixelType PixelType; + + // Machine Learning models + typedef otb::MachineLearningModelFactory< + InputValueType, OutputValueType> ModelFactoryType; + typedef typename ModelFactoryType::MachineLearningModelTypePointer ModelPointerType; + typedef typename ModelFactoryType::MachineLearningModelType ModelType; + + typedef typename ModelType::InputSampleType SampleType; + typedef typename ModelType::InputListSampleType ListSampleType; + + +#ifdef OTB_USE_SHARK + typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; + typedef otb::AutoencoderModel<InputValueType, AutoencoderType> AutoencoderModelType; + + typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; + typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType; +#endif + +protected: + cbLearningApplicationBaseDR(); + + ~cbLearningApplicationBaseDR() ITK_OVERRIDE; + + /** Generic method to train and save the machine learning model. This method + * uses specific train methods depending on the chosen model.*/ + void Train(typename ListSampleType::Pointer trainingListSample, + std::string modelPath); + + /** Generic method to load a model file and use it to classify a sample list*/ + void Reduce(typename ListSampleType::Pointer validationListSample, + std::string modelPath); + + /** Init method that creates all the parameters for machine learning models */ + void DoInit(); + +private: + + /** Specific Init and Train methods for each machine learning model */ + //@{ + +#ifdef OTB_USE_SHARK + void InitAutoencoderParams(); + template <class autoencoderchoice> + void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath){ + // typename AutoencoderModelType::Pointer dimredTrainer = AutoencoderModelType::New(); + typename autoencoderchoice::Pointer dimredTrainer = autoencoderchoice::New(); + dimredTrainer->SetNumberOfHiddenNeurons(GetParameterInt("model.autoencoder.nbneuron")); + dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); + dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.normalizer")); + dimredTrainer->SetInputListSample(trainingListSample); + dimredTrainer->Train(); + dimredTrainer->Save(modelPath); +}; // !!!!!!!!!!!!!!!!! How to declare this method body in the .txx ? (double template...) +#endif + //@} +}; + +} +} + +#ifndef OTB_MANUAL_INSTANTIATION +#include "cbLearningApplicationBaseDR.txx" +#ifdef OTB_USE_SHARK +#include "cbTrainAutoencoder.txx" +#endif +#endif + +#endif diff --git a/include/cbLearningApplicationBaseDR.txx b/include/cbLearningApplicationBaseDR.txx new file mode 100644 index 0000000000..344b6eccfc --- /dev/null +++ b/include/cbLearningApplicationBaseDR.txx @@ -0,0 +1,122 @@ +/*========================================================================= + 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. + + =========================================================================*/ +#ifndef cbLearningApplicationBaseDR_txx +#define cbLearningApplicationBaseDR_txx + +#include "cbLearningApplicationBaseDR.h" + +namespace otb +{ +namespace Wrapper +{ + +template <class TInputValue, class TOutputValue> +cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::cbLearningApplicationBaseDR() +{ +} + +template <class TInputValue, class TOutputValue> +cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::~cbLearningApplicationBaseDR() +{ + ModelFactoryType::CleanFactories(); +} + +template <class TInputValue, class TOutputValue> +void +cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::DoInit() +{ + AddDocTag(Tags::Learning); + + // main choice parameter that will contain all machine learning options + AddParameter(ParameterType_Choice, "model", "moddel to use for the training"); + SetParameterDescription("model", "Choice of the dimensionality reduction model to use for the training."); + + +#ifdef OTB_USE_SHARK + InitAutoencoderParams(); +#endif + +} + +template <class TInputValue, class TOutputValue> +void +cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::Reduce(typename ListSampleType::Pointer validationListSample,std::string modelPath) +{/* + // Setup fake reporter + RGBAPixelConverter<int,int>::Pointer dummyFilter = + RGBAPixelConverter<int,int>::New(); + dummyFilter->SetProgress(0.0f); + this->AddProcess(dummyFilter,"Classify..."); + dummyFilter->InvokeEvent(itk::StartEvent()); + + // load a machine learning model from file and predict the input sample list + ModelPointerType model = ModelFactoryType::CreateMachineLearningModel(modelPath, + ModelFactoryType::ReadMode); + + if (model.IsNull()) + { + otbAppLogFATAL(<< "Error when loading model " << modelPath); + } + + model->Load(modelPath); + model->SetRegressionMode(this->m_RegressionFlag); + model->SetInputListSample(validationListSample); + model->SetTargetListSample(predictedList); + model->PredictAll(); + + // update reporter + dummyFilter->UpdateProgress(1.0f); + dummyFilter->InvokeEvent(itk::EndEvent());*/ +} + +template <class TInputValue, class TOutputValue> +void +cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::Train(typename ListSampleType::Pointer trainingListSample, + std::string modelPath) +{ + + // get the name of the chosen machine learning model + const std::string modelName = GetParameterString("model"); + // call specific train function + + if(modelName == "autoencoder") + { + #ifdef OTB_USE_SHARK + TrainAutoencoder<AutoencoderModelType>(trainingListSample,modelPath); + #else + otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); + #endif + } + if(modelName == "tiedautoencoder") + { + #ifdef OTB_USE_SHARK + TrainAutoencoder<TiedAutoencoderModelType>(trainingListSample,modelPath); + #else + otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); + #endif + } +} + +} +} + +#endif diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx new file mode 100644 index 0000000000..f28bad3297 --- /dev/null +++ b/include/cbTrainAutoencoder.txx @@ -0,0 +1,65 @@ + +#ifndef cbTrainAutoencoder_txx +#define cbTrainAutoencoder_txx + +#include "cbLearningApplicationBaseDR.h" + +namespace otb +{ +namespace Wrapper +{ + +template <class TInputValue, class TOutputValue> +void +cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::InitAutoencoderParams() +{ + + + AddChoice("model.tiedautoencoder", "Shark Tied Autoencoder"); + AddChoice("model.autoencoder", "Shark Autoencoder"); + SetParameterDescription("model.autoencoder", + "This group of parameters allows setting Shark autoencoder parameters. " + ); + //Number Of Iterations + AddParameter(ParameterType_Int, "model.autoencoder.nbiter", + "Maximum number of iterations during training"); + SetParameterInt("model.autoencoder.nbiter",100, false); + SetParameterDescription( + "model.autoencoder.nbiter", + "The maximum number of iterations used during training."); + + + //Number Of Hidden Neurons + AddParameter(ParameterType_Int, "model.autoencoder.nbneuron", + "Number of neurons in the hidden layer"); + SetParameterInt("model.autoencoder.nbneuron",10, false); + SetParameterDescription( + "model.autoencoder.nbneuron", + "The number of neurons in the hidden layer."); + + //normalization + AddParameter(ParameterType_Float, "model.autoencoder.normalizer", "Strength of the normalization"); + SetParameterFloat("model.autoencoder.normalizer",0, false); + SetParameterDescription("model.autoencoder.normalizer", + "Strength of the L2 normalization used during training"); +} +/* +template <class TInputValue, class TOutputValue> +void cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::template < autoencoderchoice> TrainAutoencoder(typename ListSampleType::Pointer trainingListSample,std::string modelPath) +{ + // typename AutoencoderModelType::Pointer dimredTrainer = AutoencoderModelType::New(); + autoencoderchoice::Pointer dimredTrainer = autoencoderchoice::New(); + dimredTrainer->SetNumberOfHiddenNeurons(GetParameterInt("model.autoencoder.nbneuron")); + dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); + dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.normalizer")); + dimredTrainer->SetInputListSample(trainingListSample); + dimredTrainer->Train(); + dimredTrainer->Save(modelPath); +} +*/ +} //end namespace wrapper +} //end namespace otb + +#endif diff --git a/include/encode_filter.h b/include/encode_filter.h index 6b5e361fb3..cd8f523505 100644 --- a/include/encode_filter.h +++ b/include/encode_filter.h @@ -34,7 +34,7 @@ class ITK_EXPORT EncodeFilter:public itk::ImageToImageFilter< TImage, TImage > NormalizerModel GetNormalizerModel(); /** Does the real work. */ - + virtual void GenerateOutputInformation(); virtual void BeforeThreadedGenerateData(); void ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) ITK_OVERRIDE; diff --git a/include/encode_filter.txx b/include/encode_filter.txx index 8e7b334a9a..a96b048f33 100644 --- a/include/encode_filter.txx +++ b/include/encode_filter.txx @@ -101,7 +101,12 @@ this->SetNumberOfThreads(1); #endif } - +template< class TImage, class AutoencoderModel, class NormalizerModel> +void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GenerateOutputInformation() +{ + Superclass::GenerateOutputInformation(); + this->GetOutput()->SetNumberOfComponentsPerPixel( m_hidden_neuron ); +} template< class TImage, class AutoencoderModel, class NormalizerModel> void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) @@ -153,7 +158,7 @@ void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::ThreadedGenerateDa ++imageIteratorOut; ++vect_it; } - + } diff --git a/otb-module.cmake b/otb-module.cmake index d1bd695426..8b1eb2c05c 100644 --- a/otb-module.cmake +++ b/otb-module.cmake @@ -7,6 +7,7 @@ otb_module(CbDimensionalityReduction OTBShark OTBBoost OTBSupervised + OTBAppClassification DESCRIPTION "${DOCUMENTATION}" ) -- GitLab From 64af665b6b1244a10b668bdfcadf6f3a75a6e4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 10 May 2017 11:40:15 +0200 Subject: [PATCH 011/567] bug can't find appli --- app/cbDimensionalityReduction.cxx | 2 +- app/cbDimensionalityReductionTrainer.cxx | 141 +++++++++-------------- include/AutoencoderModel.h | 10 +- include/AutoencoderModel.txx | 9 ++ include/DimensionalityReductionModel.h | 48 -------- include/cbLearningApplicationBaseDR.h | 4 +- include/cbTrainAutoencoder.txx | 10 +- include/encode_filter.h | 8 +- 8 files changed, 80 insertions(+), 152 deletions(-) delete mode 100644 include/DimensionalityReductionModel.h diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index b195d053ba..9dfa3d6810 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -93,7 +93,7 @@ private: FilterType::Pointer filter_dim_reduc; ExtractROIFilterType::Pointer m_ExtractROIFilter; - + //d }; } } diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index 9c7cc45142..98b88417f1 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -6,6 +6,9 @@ #include "itkVariableLengthVector.h" +#include "otbShiftScaleSampleListFilter.h" +#include "otbStatisticsXMLFileReader.h" + //#include "AutoencoderModel.h" #include "otbSharkUtils.h" @@ -29,39 +32,6 @@ #include "cbLearningApplicationBaseDR.h" -template<class AutoencoderModel> -AutoencoderModel trainAutoencoderModel( - shark::UnlabeledData<shark::RealVector> const& data,//the data to train with - std::size_t numHidden,//number of features in the autoencoder - std::size_t iterations, //number of iterations to optimize - double regularisation//strength of the regularisation -){ - //create the model - std::size_t inputs = dataDimension(data); - AutoencoderModel model; - model.setStructure(inputs, numHidden); - initRandomUniform(model,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); - //create the objective function - - shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(data,data);//labels identical to inputs - shark::SquaredLoss<shark::RealVector> loss; - shark::ErrorFunction error(trainSet, &model, &loss); - shark::TwoNormRegularizer regularizer(error.numberOfVariables()); - error.setRegularizer(regularisation,®ularizer); - - shark::IRpropPlusFull optimizer; - error.init(); - optimizer.init(error); - std::cout<<"Optimizing model: "+model.name()<<std::endl; - for(std::size_t i = 0; i != iterations; ++i){ - optimizer.step(error); - std::cout<<i<<" "<<optimizer.solution().value<<std::endl; - } - //std::cout<<optimizer.solution().value<<std::endl; - model.setParameterVector(optimizer.solution().point); - return model; -} - shark::Normalizer<shark::RealVector> trainNormalizer(const shark::UnlabeledData<shark::RealVector>& data) { bool removeMean = true; @@ -88,11 +58,24 @@ public: itkTypeMacro(CbDimensionalityReductionTrainer, otb::Application); - typedef float ValueType; - typedef itk::VariableLengthVector<ValueType> InputSampleType; - typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; - + typedef Superclass::SampleType SampleType; + typedef Superclass::ListSampleType ListSampleType; + typedef Superclass::SampleImageType SampleImageType; + + typedef double ValueType; typedef itk::VariableLengthVector<ValueType> MeasurementType; + + typedef otb::StatisticsXMLFileReader<SampleType> StatisticsReader; + + typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; + + + + //typedef float ValueType; + //typedef itk::VariableLengthVector<ValueType> InputSampleType; + //typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; + + //typedef itk::VariableLengthVector<ValueType> MeasurementType; typedef otb::MachineLearningModelFactory<ValueType, ValueType> ModelFactoryType; @@ -105,16 +88,7 @@ private: { SetName("CbDimensionalityReductionTrainer"); SetDescription("Trainer for the dimensionality reduction algorithms used in the cbDimensionalityReduction application."); - /* - AddParameter(ParameterType_InputVectorData, "train", "Name of the input training vector data"); - SetParameterDescription("train","The vector data used for training."); - AddParameter(ParameterType_StringList, "feat", "Field names to be calculated."); // - SetParameterDescription("feat","List of field names in the input vector data used as features for training."); // - - AddParameter(ParameterType_Int, "k","target dimension"); - SetParameterDescription("k", "Dimension of the output feature vectors"); -*/ AddParameter(ParameterType_Group, "io", "Input and output data"); SetParameterDescription("io", "This group of parameters allows setting input and output data."); @@ -124,6 +98,9 @@ private: AddParameter(ParameterType_OutputFilename, "io.out", "Output model"); SetParameterDescription("io.out", "Output file containing the model estimated (.txt format)."); + AddParameter(ParameterType_InputFilename, "io.stats", "Input XML image statistics file"); + MandatoryOff("io.stats"); + SetParameterDescription("io.stats", "XML file containing mean and variance of each feature."); AddParameter(ParameterType_StringList, "feat", "Field names to be calculated."); // SetParameterDescription("feat","List of field names in the input vector data used as features for training."); // @@ -153,7 +130,7 @@ private: void DoExecute() { - std::cout << "Appli !" << std::endl; + std::cout << "Appli Training!" << std::endl; std::string shapefile = GetParameterString("io.vd"); @@ -175,51 +152,37 @@ private: } input->PushBack(mv); } - /* - std::cout << input << std::endl; - std::vector<shark::RealVector> features; - otb::Shark::ListSampleToSharkVector<ListSampleType>( input, features); - shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - std::size_t numHidden= GetParameterInt("k"); - std::size_t iterations = 100; - double regularisation = 0; - - - shark::Normalizer<shark::RealVector> normalizer = trainNormalizer(inputSamples); - inputSamples = normalizer(inputSamples); +// Statistics for shift/scale + MeasurementType meanMeasurementVector; + MeasurementType stddevMeasurementVector; + if (HasValue("io.stats") && IsParameterEnabled("io.stats")) + { + StatisticsReader::Pointer statisticsReader = StatisticsReader::New(); + std::string XMLfile = GetParameterString("io.stats"); + statisticsReader->SetFileName(XMLfile); + meanMeasurementVector = statisticsReader->GetStatisticVectorByName("mean"); + stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); + } + else + { + meanMeasurementVector.SetSize(nbFeatures); + meanMeasurementVector.Fill(0.); + stddevMeasurementVector.SetSize(nbFeatures); + stddevMeasurementVector.Fill(1.); + } + + ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); + trainingShiftScaleFilter->SetInput(input); + trainingShiftScaleFilter->SetShifts(meanMeasurementVector); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector); + trainingShiftScaleFilter->Update(); + + ListSampleType::Pointer trainingListSample= trainingShiftScaleFilter->GetOutput(); - std::cout << "normalizer trained and training set normalized" << std::endl; - - AutoencoderType net = trainAutoencoderModel<AutoencoderType>(inputSamples,numHidden,iterations,regularisation); - std::cout << "autoencoder trained !!!!" << std::endl; - - // save the model to the file "net.model" - std::ofstream ofs("net.model"); - shark::TextOutArchive oa(ofs); - net.write(oa); - ofs.close(); - // save the model to the file "net.model" - std::ofstream norm_ofs("normalizer.model"); - boost::archive::polymorphic_text_oarchive onorm(norm_ofs); - normalizer.write(onorm); - norm_ofs.close(); - */ - - std::cout << "Using a Machine learning model" << std::endl; - /* - AutoencoderModelType::Pointer dimredTrainer = AutoencoderModelType::New(); - dimredTrainer->SetNumberOfHiddenNeurons(5); - dimredTrainer->SetNumberOfIterations(50); - dimredTrainer->SetRegularization(0.1); - dimredTrainer->SetInputListSample(input); - dimredTrainer->Train(); - dimredTrainer->Save("net.model"); - std::cout << "ok" << std::endl; - */ - this->Train(input,GetParameterString("io.out")); - + this->Train(trainingListSample,GetParameterString("io.out")); + // d } diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 603f0dc4d2..e77e901ae1 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -51,10 +51,14 @@ public: protected: - AutoencoderModel(){}; -private: + AutoencoderModel(); + //~AutoencoderModel() ITK_OVERRIDE; + virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; - + virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const ITK_OVERRIDE; + +private: + AutoencoderType m_net; unsigned int m_NumberOfHiddenNeurons; unsigned int m_NumberOfIterations; diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 50fc9940f9..72f9e2ef8f 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -14,6 +14,15 @@ namespace otb { + +template <class TInputValue, class AutoencoderType> +AutoencoderModel<TInputValue,AutoencoderType>::AutoencoderModel() +{ + //this->m_IsRegressionSupported = true; +} + + + template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Train() { diff --git a/include/DimensionalityReductionModel.h b/include/DimensionalityReductionModel.h deleted file mode 100644 index 05066e976b..0000000000 --- a/include/DimensionalityReductionModel.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef DimensionalityReductionModel_h -#define DimensionalityReductionModel_h -#include "itkObject.h" -#include "itkListSample.h" -namespace otb -{ -template <class TInputValue> -class DimensionalityReductionModel: public itk::Object -{ - -public: - - typedef DimensionalityReductionModel Self; - typedef itk::Object Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - typedef TInputValue InputValueType; - typedef itk::VariableLengthVector<InputValueType> InputSampleType; - typedef itk::Statistics::ListSample<InputSampleType> InputListSampleType; - - - - itkSetObjectMacro(InputListSample,InputListSampleType); - itkGetObjectMacro(InputListSample,InputListSampleType); - itkGetConstObjectMacro(InputListSample,InputListSampleType); - - virtual void Save(const std::string & filename, const std::string & name="") = 0; - virtual void Load(const std::string & filename, const std::string & name="") = 0; - - virtual void Train() = 0; - virtual void Dimensionality_reduction() = 0; - -protected: - DimensionalityReductionModel(){}; - typename InputListSampleType::Pointer m_InputListSample; - - -}; -} // end namespace otb - - -//#ifndef OTB_MANUAL_INSTANTIATION -//#include "DimensionalityReductionModel.txx" -//#endif - - -#endif diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index fe42e2d875..ab359092d2 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -117,7 +117,7 @@ private: #ifdef OTB_USE_SHARK void InitAutoencoderParams(); template <class autoencoderchoice> - void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath){ + void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath);/*{ // typename AutoencoderModelType::Pointer dimredTrainer = AutoencoderModelType::New(); typename autoencoderchoice::Pointer dimredTrainer = autoencoderchoice::New(); dimredTrainer->SetNumberOfHiddenNeurons(GetParameterInt("model.autoencoder.nbneuron")); @@ -126,7 +126,7 @@ private: dimredTrainer->SetInputListSample(trainingListSample); dimredTrainer->Train(); dimredTrainer->Save(modelPath); -}; // !!!!!!!!!!!!!!!!! How to declare this method body in the .txx ? (double template...) +}; // !!!!!!!!!!!!!!!!! How to declare this method body in the .txx ? (double template...) */ #endif //@} }; diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index f28bad3297..feed6cf75e 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -44,13 +44,13 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> SetParameterDescription("model.autoencoder.normalizer", "Strength of the L2 normalization used during training"); } -/* + template <class TInputValue, class TOutputValue> +template <typename autoencoderchoice> void cbLearningApplicationBaseDR<TInputValue,TOutputValue> -::template < autoencoderchoice> TrainAutoencoder(typename ListSampleType::Pointer trainingListSample,std::string modelPath) +::TrainAutoencoder(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { - // typename AutoencoderModelType::Pointer dimredTrainer = AutoencoderModelType::New(); - autoencoderchoice::Pointer dimredTrainer = autoencoderchoice::New(); + typename autoencoderchoice::Pointer dimredTrainer = autoencoderchoice::New(); dimredTrainer->SetNumberOfHiddenNeurons(GetParameterInt("model.autoencoder.nbneuron")); dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.normalizer")); @@ -58,7 +58,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> dimredTrainer->Train(); dimredTrainer->Save(modelPath); } -*/ + } //end namespace wrapper } //end namespace otb diff --git a/include/encode_filter.h b/include/encode_filter.h index cd8f523505..903912be28 100644 --- a/include/encode_filter.h +++ b/include/encode_filter.h @@ -9,15 +9,15 @@ template< class TImage, class AutoencoderModel, class NormalizerModel> class ITK_EXPORT EncodeFilter:public itk::ImageToImageFilter< TImage, TImage > { public: - /** Standard class typedefs. */ + // Standard class typedefs. typedef EncodeFilter Self; typedef itk::ImageToImageFilter< TImage, TImage > Superclass; typedef itk::SmartPointer< Self > Pointer; - /** Method for creation through the object factory. */ + // Method for creation through the object factory. itkNewMacro(Self); - /** Run-time type information (and related methods). */ + // Run-time type information (and related methods). itkTypeMacro(EncodeFilter, ImageToImageFilter); //void SetInputImage(const TImage* image); @@ -33,7 +33,7 @@ class ITK_EXPORT EncodeFilter:public itk::ImageToImageFilter< TImage, TImage > AutoencoderModel GetAutoencoderModel(); NormalizerModel GetNormalizerModel(); - /** Does the real work. */ + // Does the real work. virtual void GenerateOutputInformation(); virtual void BeforeThreadedGenerateData(); void ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) ITK_OVERRIDE; -- GitLab From 794a23772f4e526b5727102e1d9c8591ba3d3c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 11 May 2017 12:18:10 +0200 Subject: [PATCH 012/567] application working (monoband...), commit before aefactory template creation --- app/cbDimensionalityReduction.cxx | 347 +++++++++++++++++------ app/cbDimensionalityReductionTrainer.cxx | 5 - include/AutoencoderModel.h | 2 +- include/AutoencoderModel.txx | 59 +++- include/AutoencoderModelFactory.h | 9 +- include/AutoencoderModelFactory.txx | 1 + include/cbLearningApplicationBaseDR.h | 11 +- 7 files changed, 332 insertions(+), 102 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index 9dfa3d6810..08769213b9 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -1,100 +1,283 @@ -#include "otbWrapperApplication.h" -#include "otbWrapperApplicationFactory.h" -#include <iostream> +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + -#include "otbImage.h" -#include "otbVectorImage.h" + 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. -#include <shark/Models/Autoencoder.h>//normal autoencoder model -#include <shark/Models/TiedAutoencoder.h>//autoencoder with tied weights -#include <shark/Models/Normalizer.h> -#include "encode_filter.h" +=========================================================================*/ +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" -#include "otbMultiChannelExtractROI.h" +#include "itkUnaryFunctorImageFilter.h" +#include "otbChangeLabelImageFilter.h" +#include "otbStandardWriterWatcher.h" +#include "otbStatisticsXMLFileReader.h" +#include "otbShiftScaleVectorImageFilter.h" +#include "otbImageClassificationFilter.h" +#include "otbMultiToMonoChannelExtractROI.h" +#include "otbImageToVectorImageCastFilter.h" +#include "otbMachineLearningModelFactory.h" namespace otb { +namespace Functor +{ +/** + * simple affine function : y = ax+b + */ +template<class TInput, class TOutput> +class AffineFunctor +{ +public: + typedef double InternalType; + + // constructor + AffineFunctor() : m_A(1.0),m_B(0.0) {} + + // destructor + virtual ~AffineFunctor() {} + + void SetA(InternalType a) + { + m_A = a; + } + + void SetB(InternalType b) + { + m_B = b; + } + + inline TOutput operator()(const TInput & x) const + { + return static_cast<TOutput>( static_cast<InternalType>(x)*m_A + m_B); + } +private: + InternalType m_A; + InternalType m_B; +}; + +} + namespace Wrapper { -class CbDimensionalityReduction : public otb::Wrapper::Application +class CbDimensionalityReduction : public Application { public: - /** Standard class typedefs. */ - typedef CbDimensionalityReduction Self; - typedef Application Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - - using image_type = FloatVectorImageType; - - typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - using FilterType = EncodeFilter<image_type, AutoencoderType, shark::Normalizer<shark::RealVector>> ; - typedef otb::MultiChannelExtractROI<FloatVectorImageType::InternalPixelType, FloatVectorImageType::InternalPixelType> ExtractROIFilterType; - /** Standard macro */ - itkNewMacro(Self); - itkTypeMacro(CbDimensionalityReduction, otb::Application); + /** Standard class typedefs. */ + typedef CbDimensionalityReduction Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(CbDimensionalityReduction, otb::Application); + + /** Filters typedef */ + typedef UInt8ImageType MaskImageType; + typedef itk::VariableLengthVector<FloatVectorImageType::InternalPixelType> MeasurementType; + typedef otb::StatisticsXMLFileReader<MeasurementType> StatisticsReader; + typedef otb::ShiftScaleVectorImageFilter<FloatVectorImageType, FloatVectorImageType> RescalerType; + typedef itk::UnaryFunctorImageFilter< + FloatImageType, + FloatImageType, + otb::Functor::AffineFunctor<float,float> > OutputRescalerType; + typedef otb::ImageClassificationFilter<FloatVectorImageType, FloatImageType, MaskImageType> ClassificationFilterType; + typedef ClassificationFilterType::Pointer ClassificationFilterPointerType; + typedef ClassificationFilterType::ModelType ModelType; + typedef ModelType::Pointer ModelPointerType; + typedef ClassificationFilterType::ValueType ValueType; + typedef ClassificationFilterType::LabelType LabelType; + typedef otb::MachineLearningModelFactory<ValueType, LabelType> MachineLearningModelFactoryType; + +protected: + + ~CbDimensionalityReduction() ITK_OVERRIDE + { + MachineLearningModelFactoryType::CleanFactories(); + } + private: + void DoInit() ITK_OVERRIDE + { + SetName("PredictRegression"); + SetDescription("Performs a prediction of the input image according to a regression model file."); + + // Documentation + SetDocName("Predict Regression"); + SetDocLongDescription("This application predict output values from an input" + " image, based on a regression model file produced by" + " the TrainRegression application. Pixels of the " + "output image will contain the predicted values from" + "the regression model (single band). The input pixels" + " can be optionally centered and reduced according " + "to the statistics file produced by the " + "ComputeImagesStatistics application. An optional " + "input mask can be provided, in which case only " + "input image pixels whose corresponding mask value " + "is greater than 0 will be processed. The remaining" + " of pixels will be given the value 0 in the output" + " image."); + + SetDocLimitations("The input image must contain the feature bands used for" + " the model training (without the predicted value). " + "If a statistics file was used during training by the " + "TrainRegression, it is mandatory to use the same " + "statistics file for prediction. If an input mask is " + "used, its size must match the input image size."); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso("TrainRegression, ComputeImagesStatistics"); + + AddDocTag(Tags::Learning); + + AddParameter(ParameterType_InputImage, "in", "Input Image"); + SetParameterDescription( "in", "The input image to predict."); + + // TODO : use CSV input/output ? + + AddParameter(ParameterType_InputImage, "mask", "Input Mask"); + SetParameterDescription( "mask", "The mask allow restricting " + "classification of the input image to the area where mask pixel values " + "are greater than 0."); + MandatoryOff("mask"); + + AddParameter(ParameterType_InputFilename, "model", "Model file"); + SetParameterDescription("model", "A regression model file (produced by " + "TrainRegression application)."); + + AddParameter(ParameterType_InputFilename, "imstat", "Statistics file"); + SetParameterDescription("imstat", "A XML file containing mean and standard" + " deviation to center and reduce samples before prediction " + "(produced by ComputeImagesStatistics application). If this file contains" + "one more band than the sample size, the last stat of last band will be" + "applied to expand the output predicted value"); + MandatoryOff("imstat"); + + AddParameter(ParameterType_OutputImage, "out", "Output Image"); + SetParameterDescription( "out", "Output image containing predicted values"); + + AddRAMParameter(); + + // Doc example parameter settings + SetDocExampleParameterValue("in", "QB_1_ortho.tif"); + SetDocExampleParameterValue("imstat", "EstimateImageStatisticsQB1.xml"); + SetDocExampleParameterValue("model", "clsvmModelQB1.svm"); + SetDocExampleParameterValue("out", "clLabeledImageQB1.tif"); + } + + void DoUpdateParameters() ITK_OVERRIDE + { + // Nothing to do here : all parameters are independent + } + + void DoExecute() ITK_OVERRIDE + { + // Load input image + FloatVectorImageType::Pointer inImage = GetParameterImage("in"); + inImage->UpdateOutputInformation(); + unsigned int nbFeatures = inImage->GetNumberOfComponentsPerPixel(); + + // Load svm model + otbAppLogINFO("Loading model"); + m_Model = MachineLearningModelFactoryType::CreateMachineLearningModel(GetParameterString("model"), + MachineLearningModelFactoryType::ReadMode); + otbAppLogINFO("yo"); + if (m_Model.IsNull()) + { + otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") << " : unsupported model type"); + } + + m_Model->Load(GetParameterString("model")); + m_Model->SetRegressionMode(true); + otbAppLogINFO("Model loaded"); + + // Classify + m_ClassificationFilter = ClassificationFilterType::New(); + m_ClassificationFilter->SetModel(m_Model); + + FloatImageType::Pointer outputImage = m_ClassificationFilter->GetOutput(); + + // Normalize input image if asked + if(IsParameterEnabled("imstat") ) + { + otbAppLogINFO("Input image normalization activated."); + // Normalize input image (optional) + StatisticsReader::Pointer statisticsReader = StatisticsReader::New(); + MeasurementType meanMeasurementVector; + MeasurementType stddevMeasurementVector; + m_Rescaler = RescalerType::New(); + // Load input image statistics + statisticsReader->SetFileName(GetParameterString("imstat")); + meanMeasurementVector = statisticsReader->GetStatisticVectorByName("mean"); + stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); + otbAppLogINFO( "mean used: " << meanMeasurementVector ); + otbAppLogINFO( "standard deviation used: " << stddevMeasurementVector ); + if (meanMeasurementVector.Size() == nbFeatures + 1) + { + double outMean = meanMeasurementVector[nbFeatures]; + double outStdDev = stddevMeasurementVector[nbFeatures]; + meanMeasurementVector.SetSize(nbFeatures,false); + stddevMeasurementVector.SetSize(nbFeatures,false); + m_OutRescaler = OutputRescalerType::New(); + m_OutRescaler->SetInput(m_ClassificationFilter->GetOutput()); + m_OutRescaler->GetFunctor().SetA(outStdDev); + m_OutRescaler->GetFunctor().SetB(outMean); + outputImage = m_OutRescaler->GetOutput(); + } + else if (meanMeasurementVector.Size() != nbFeatures) + { + otbAppLogFATAL("Wrong number of components in statistics file : "<<meanMeasurementVector.Size()); + } + + // Rescale vector image + m_Rescaler->SetScale(stddevMeasurementVector); + m_Rescaler->SetShift(meanMeasurementVector); + m_Rescaler->SetInput(inImage); + + m_ClassificationFilter->SetInput(m_Rescaler->GetOutput()); + } + else + { + otbAppLogINFO("Input image normalization deactivated."); + m_ClassificationFilter->SetInput(inImage); + } + + + if(IsParameterEnabled("mask")) + { + otbAppLogINFO("Using input mask"); + // Load mask image and cast into LabeledImageType + MaskImageType::Pointer inMask = GetParameterUInt8Image("mask"); + + m_ClassificationFilter->SetInputMask(inMask); + } + + SetParameterOutputImage<FloatImageType>("out", outputImage); + + } + + ClassificationFilterType::Pointer m_ClassificationFilter; + ModelPointerType m_Model; + RescalerType::Pointer m_Rescaler; + OutputRescalerType::Pointer m_OutRescaler; - void DoInit() - { - SetName("CbDimensionalityReduction"); - SetDescription("Perform dimensionality reduction on the input image"); - - AddParameter(ParameterType_InputImage, "in", "Input Image"); - SetParameterDescription( "in", "The input image to perform dimensionality reduction on."); - - AddParameter(ParameterType_InputFilename, "model", "Model file"); - SetParameterDescription("model", "A model file (produced by the cbDimensionalityReductionTrainer application)."); - - AddParameter(ParameterType_InputFilename, "normalizer", "Normalizer model file"); - SetParameterDescription("normalizer", "A normalizer model file (produced by the cbDimensionalityReductionTrainer application)."); - - AddParameter(ParameterType_OutputImage, "out", "Output Image"); - SetParameterDescription("out", "Output image"); - - AddRAMParameter(); - } - - void DoUpdateParameters() - { - } - - void DoExecute() - { - std::cout << "Appli" << std::endl; - image_type::Pointer inImage = GetParameterImage("in"); - std::string encoderPath = GetParameterString("model"); - std::string normalizerPath = GetParameterString("normalizer"); - - - - filter_dim_reduc = FilterType::New(); - filter_dim_reduc->SetAutoencoderModel(encoderPath); - filter_dim_reduc->SetNormalizerModel(normalizerPath); - filter_dim_reduc->SetInput(inImage); - - SetParameterOutputImage("out", filter_dim_reduc->GetOutput()); -/* - m_ExtractROIFilter = ExtractROIFilterType::New(); - m_ExtractROIFilter->SetInput(filter_dim_reduc->GetOutput()); - for (unsigned int idx = 1; idx <= filter_dim_reduc->GetDimension(); ++idx) - { - m_ExtractROIFilter->SetChannel(idx ); - } - - SetParameterOutputImage("out", m_ExtractROIFilter->GetOutput()); -*/ - //SetParameterOutputImage("out", inImage); // copy input image - - } - - FilterType::Pointer filter_dim_reduc; - ExtractROIFilterType::Pointer m_ExtractROIFilter; - //d }; + + } } + OTB_APPLICATION_EXPORT(otb::Wrapper::CbDimensionalityReduction) diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index 98b88417f1..f8496bd0f7 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -79,10 +79,6 @@ public: typedef otb::MachineLearningModelFactory<ValueType, ValueType> ModelFactoryType; - typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - typedef AutoencoderModel<ValueType,AutoencoderType> AutoencoderModelType; -typedef RandomForestsMachineLearningModel<ValueType,int> rfModelType; - private: void DoInit() { @@ -182,7 +178,6 @@ private: this->Train(trainingListSample,GetParameterString("io.out")); - // d } diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index e77e901ae1..5fdd4ba072 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -52,7 +52,7 @@ public: protected: AutoencoderModel(); - //~AutoencoderModel() ITK_OVERRIDE; + ~AutoencoderModel() ITK_OVERRIDE; virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const ITK_OVERRIDE; diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 72f9e2ef8f..60eff32025 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -4,6 +4,7 @@ #include <fstream> #include <shark/Data/Dataset.h> +#include "itkMacro.h" #include "otbSharkUtils.h" //include train function #include <shark/ObjectiveFunctions/ErrorFunction.h> @@ -18,10 +19,15 @@ namespace otb template <class TInputValue, class AutoencoderType> AutoencoderModel<TInputValue,AutoencoderType>::AutoencoderModel() { - //this->m_IsRegressionSupported = true; + this->m_IsRegressionSupported = true; } +template <class TInputValue, class AutoencoderType> +AutoencoderModel<TInputValue,AutoencoderType>::~AutoencoderModel() +{ +} + template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Train() @@ -53,6 +59,8 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() } //std::cout<<optimizer.solution().value<<std::endl; m_net.setParameterVector(optimizer.solution().point); + + } @@ -82,6 +90,7 @@ template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Save(const std::string & filename, const std::string & name) { std::ofstream ofs(filename); + ofs << m_net.name() << std::endl; //first line boost::archive::polymorphic_text_oarchive oa(ofs); m_net.write(oa); ofs.close(); @@ -91,6 +100,13 @@ template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & filename, const std::string & name) { std::ifstream ifs(filename); + char autoencoder[256]; + ifs.getline(autoencoder,256); + std::string autoencoderstr(autoencoder); + + if (autoencoderstr != m_net.name()){ + itkExceptionMacro(<< "Error opening " << filename.c_str() ); + } boost::archive::polymorphic_text_iarchive ia(ifs); m_net.read(ia); ifs.close(); @@ -101,10 +117,49 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & fil template <class TInputValue, class AutoencoderType> typename AutoencoderModel<TInputValue,AutoencoderType>::TargetSampleType AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value, ConfidenceValueType *quality) const +{ + shark::RealVector samples(value.Size()); + for(size_t i = 0; i < value.Size();i++) + { + samples.push_back(value[i]); + } + shark::Data<shark::RealVector> data; + data.element(0)=samples; + data = m_net.encode(data); + + TargetSampleType target; + + //target.SetSize(m_NumberOfHiddenNeurons); + for(unsigned int a = 0; a < m_NumberOfHiddenNeurons; ++a){ + //target[a]=data.element(0)[a]; + target=data.element(0)[a]; + } + return target; +} + + +template <class TInputValue, class AutoencoderType> +void AutoencoderModel<TInputValue,AutoencoderType> +::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const { + std::vector<shark::RealVector> features; + Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); + shark::Data<shark::RealVector> data = shark::createDataFromRange(features); TargetSampleType target; - return target; + data = m_net.encode(data); + unsigned int id = startIndex; + for(const auto& p : data.elements()){ + + for(unsigned int a = 0; a < m_NumberOfHiddenNeurons; ++a){ + //target[a]=p[a]; + target=p[a]; + } + //std::cout << p << std::endl; + targets->SetMeasurementVector(id,target); + ++id; + } } + } // namespace otb #endif diff --git a/include/AutoencoderModelFactory.h b/include/AutoencoderModelFactory.h index 5bead33b9b..51847dfebe 100644 --- a/include/AutoencoderModelFactory.h +++ b/include/AutoencoderModelFactory.h @@ -3,6 +3,7 @@ #include "itkObjectFactoryBase.h" +#include "itkImageIOBase.h" namespace otb { @@ -30,8 +31,8 @@ public: /** Register one factory of this type */ static void RegisterOneFactory(void) { - Pointer RFFactory = AutoencoderModelFactory::New(); - itk::ObjectFactoryBase::RegisterFactory(RFFactory); + Pointer AEFactory = AutoencoderModelFactory::New(); + itk::ObjectFactoryBase::RegisterFactory(AEFactory); } protected: @@ -45,6 +46,10 @@ private: }; } //namespace otb +#ifndef OTB_MANUAL_INSTANTIATION +#include "AutoencoderModelFactory.txx" +#endif + #endif diff --git a/include/AutoencoderModelFactory.txx b/include/AutoencoderModelFactory.txx index 272e29bc10..8b35be2881 100644 --- a/include/AutoencoderModelFactory.txx +++ b/include/AutoencoderModelFactory.txx @@ -25,6 +25,7 @@ #include "AutoencoderModel.h" #include "itkVersion.h" +#include <shark/Models/Autoencoder.h>//normal autoencoder model namespace otb { template <class TInputValue, class TOutputValue> diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index ab359092d2..49145ae3f1 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -117,16 +117,7 @@ private: #ifdef OTB_USE_SHARK void InitAutoencoderParams(); template <class autoencoderchoice> - void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath);/*{ - // typename AutoencoderModelType::Pointer dimredTrainer = AutoencoderModelType::New(); - typename autoencoderchoice::Pointer dimredTrainer = autoencoderchoice::New(); - dimredTrainer->SetNumberOfHiddenNeurons(GetParameterInt("model.autoencoder.nbneuron")); - dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); - dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.normalizer")); - dimredTrainer->SetInputListSample(trainingListSample); - dimredTrainer->Train(); - dimredTrainer->Save(modelPath); -}; // !!!!!!!!!!!!!!!!! How to declare this method body in the .txx ? (double template...) */ + void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); #endif //@} }; -- GitLab From fa0bf983e6347752545a1fbed3e6b1b99703d206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 11 May 2017 14:36:54 +0200 Subject: [PATCH 013/567] dr application working (monoband output) for autoencoders and tiedautoencoders --- app/cbDimensionalityReduction.cxx | 2 +- include/AutoencoderModelFactory.h | 31 +++++++++++++++++++++-------- include/AutoencoderModelFactory.txx | 19 +++++++++--------- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index 08769213b9..d1e4861be1 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -194,7 +194,7 @@ private: otbAppLogINFO("Loading model"); m_Model = MachineLearningModelFactoryType::CreateMachineLearningModel(GetParameterString("model"), MachineLearningModelFactoryType::ReadMode); - otbAppLogINFO("yo"); + if (m_Model.IsNull()) { otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") << " : unsupported model type"); diff --git a/include/AutoencoderModelFactory.h b/include/AutoencoderModelFactory.h index 51847dfebe..0b8f538272 100644 --- a/include/AutoencoderModelFactory.h +++ b/include/AutoencoderModelFactory.h @@ -2,18 +2,20 @@ #define AutoencoderModelFactory_h +#include <shark/Models/TiedAutoencoder.h> +#include <shark/Models/Autoencoder.h> #include "itkObjectFactoryBase.h" #include "itkImageIOBase.h" namespace otb { -template <class TInputValue, class TTargetValue> -class ITK_EXPORT AutoencoderModelFactory : public itk::ObjectFactoryBase +template <class TInputValue, class TTargetValue, class AutoencoderType> +class ITK_EXPORT AutoencoderModelFactoryBase : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ - typedef AutoencoderModelFactory Self; + typedef AutoencoderModelFactoryBase Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -26,26 +28,39 @@ public: itkFactorylessNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro(AutoencoderModelFactory, itk::ObjectFactoryBase); + itkTypeMacro(AutoencoderModelFactoryBase, itk::ObjectFactoryBase); /** Register one factory of this type */ static void RegisterOneFactory(void) { - Pointer AEFactory = AutoencoderModelFactory::New(); + Pointer AEFactory = AutoencoderModelFactoryBase::New(); itk::ObjectFactoryBase::RegisterFactory(AEFactory); } protected: - AutoencoderModelFactory(); - ~AutoencoderModelFactory() ITK_OVERRIDE; + AutoencoderModelFactoryBase(); + ~AutoencoderModelFactoryBase() ITK_OVERRIDE; private: - AutoencoderModelFactory(const Self &); //purposely not implemented + AutoencoderModelFactoryBase(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented }; + + + + +template <class TInputValue, class TTargetValue> +class ITK_EXPORT AutoencoderModelFactory : public AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron>> {}; + + +template <class TInputValue, class TTargetValue> +class ITK_EXPORT TiedAutoencoderModelFactory : public AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> {}; + + } //namespace otb + #ifndef OTB_MANUAL_INSTANTIATION #include "AutoencoderModelFactory.txx" #endif diff --git a/include/AutoencoderModelFactory.txx b/include/AutoencoderModelFactory.txx index 8b35be2881..22d6c5ba9a 100644 --- a/include/AutoencoderModelFactory.txx +++ b/include/AutoencoderModelFactory.txx @@ -25,11 +25,10 @@ #include "AutoencoderModel.h" #include "itkVersion.h" -#include <shark/Models/Autoencoder.h>//normal autoencoder model namespace otb { -template <class TInputValue, class TOutputValue> -AutoencoderModelFactory<TInputValue,TOutputValue>::AutoencoderModelFactory() +template <class TInputValue, class TOutputValue, class AutoencoderType> +AutoencoderModelFactoryBase<TInputValue,TOutputValue, AutoencoderType>::AutoencoderModelFactoryBase() { std::string classOverride = std::string("otbMachineLearningModel"); @@ -40,22 +39,22 @@ AutoencoderModelFactory<TInputValue,TOutputValue>::AutoencoderModelFactory() "Shark RF ML Model", 1, // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); - itk::CreateObjectFunction<AutoencoderModel<TInputValue,shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> > >::New()); + itk::CreateObjectFunction<AutoencoderModel<TInputValue,AutoencoderType > >::New()); } -template <class TInputValue, class TOutputValue> -AutoencoderModelFactory<TInputValue,TOutputValue>::~AutoencoderModelFactory() +template <class TInputValue, class TOutputValue, class AutoencoderType> +AutoencoderModelFactoryBase<TInputValue,TOutputValue, AutoencoderType>::~AutoencoderModelFactoryBase() { } -template <class TInputValue, class TOutputValue> -const char* AutoencoderModelFactory<TInputValue,TOutputValue>::GetITKSourceVersion(void) const +template <class TInputValue, class TOutputValue, class AutoencoderType> +const char* AutoencoderModelFactoryBase<TInputValue,TOutputValue, AutoencoderType>::GetITKSourceVersion(void) const { return ITK_SOURCE_VERSION; } -template <class TInputValue, class TOutputValue> -const char* AutoencoderModelFactory<TInputValue,TOutputValue>::GetDescription() const +template <class TInputValue, class TOutputValue, class AutoencoderType> +const char* AutoencoderModelFactoryBase<TInputValue,TOutputValue, AutoencoderType>::GetDescription() const { return "Autoencoder model factory"; } -- GitLab From bc35458a617463ff8167e7d762c4d9f5b1ab05d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 11 May 2017 14:57:14 +0200 Subject: [PATCH 014/567] repository cleaned (precompiled header deleted) --- include/AutoencoderModel.h.gch | Bin 8399 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 include/AutoencoderModel.h.gch diff --git a/include/AutoencoderModel.h.gch b/include/AutoencoderModel.h.gch deleted file mode 100644 index 298f5cae3a31fa80eb0653035130a574619c25e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8399 zcmb7J$#Uez5!J}Myf5;;z>*iXM(jWp3fmEEph<+#iyGjN<4eVu!x&A7;wWYb>*62r zS>NEB|G_7p9N}MazRCisfNpAGOgD#Jg{rK~moHydKl%9T;`!5;*Pnj6zW*Qb;Gh5c z$LsI?{l9-pU%U63`T6&o|Ks2MC%t3fo*i}n8HO?8lPoz-)bJ5c{tEu?pPT&mbu(sG zc2nq2{x^9Lf7&0j+`X^&f0;k~vC;2)Pp)sTpFh1KtHzUlM$^7eFRjayMz89%t}eG) z2S>*ulw$Tv8v2PDKCjoEZmOc~M50&4CCy3VIEsHnqdzb+if*&27rI!ye_rpZK>nFN z{k9odHl0~o2VySLSmi2;!%Rw<rE!?%>Gg4xE#IQ4)2%YyJ=|8b)vMbVPoLagKMt-w zc=Q~z-Y^T3O)zC~bTtdEg16ren(xu)-!Ws0vtp-D>W-eyen_8u*L;d&WY&He$3GvY zU*LRvE+uo7C#lTi^Iy|AT%`48S5`aS)Lqw9x>}cYv8I)UjMUr18g2cT%B~?YrIJ*s zFpbhMk7JRD_`Jb(Y{!K$kN1;8r7DXOmHvUo;Rmfx7Ylt>Jg9X0aJ|rr&1zfhDqXBg z-Ch)1Edud{=gKcJR|O)a{Sj0~L|LsjyOoXJ<7cn_dUJiG=D7-!I8kw?gj7kalt>Xo zshZgrHY*FnZ)lre4ac?kF^*|Ai}&<$R}qZfqzOMZlK`XYK|wIBy0cA5?hk)Y1HU`8 zLL@c8)vfZ*u!;fll5m`;&x{qq&il6YskX*hI6l37`3o9$ZbIUSaLAn~OlLnGCJZ}z zz{9D4O7e2Gu$FM<MOh4peA5gXv@*Q!(+AW1_?#oaK2C=AY}cbZl4+8{9X!&Qyf^tw z$(iM8Bvej$oyth0NgT@S`znuQ<J{qxz&p>uP@ZfyjUNO+o4EpO0Q}aUH_vXLxEv?% zev4*)gI-$SJiUGONg$9pgTE-a)wZphjY+}kI4PHK7kE(XSGP}TK8Ookpf$Fl2li4M ztj8|k)Tam%pw7Wq*xl}o9Cz%|dRZ%Eit~)p*{pGNthJxs$AOpuNW3apLs9b>E1;p@ z(u;H6;%vL2dEgs|;5(sCd_00WfCqTd(OWE0oK%h8?y6-C(#Bz!@Y}8=j@h(bg;W}Q z7{KysL6pfEyvcM9#FUg1^iT{S@p2|RT~y{Gmtih5;=VA=gp5P_xjs&pj-gL4FZD%L zyoZIRfHa<r=20R=NQjJtpw*~qBr>@^Hh=_iu=6Q{h5+aD-27BIfx^+Pj{!%wZ_pB) zX8;Y%@VrA@zFATL);MV9%A9dqT`hDR=XeB2V<O;@c0){%sD#F3D9HK-{=rs^MG6;3 z9}ltX=m7PKc#WMZ1wQ4YJ-L0w8GxMtBL0|;GgM)d&p0XKuC>YMv!c~hg{w}lxlFl} zp03Xqw3q_)*(iiz*L8IuT-L2tz={Ch@YxVutZM54je!7pOO(CdRpsXVgbE~$C$Nce zcv7F9R&A$?raoP-Dk`)XcPaZ}h7UrT?*PX6YAcSIlS)YPNJJ`2h?wFu%tU;BKMJ#E z2A#o1l3O&G-JwCsC`x4*C0VS}G|s}bfz8aLz%kBLub1_@?jFJjm(sM@K(G0Mb+9Fq znLYoq*%UaL0#*84<!4f^X0D(Ov2tDw2J0Nn4#$}Y6RuAEp+N&ImJFK`iDH}`diC+m zs~30$BF|GH8W4_q+{n6N7ndKfbd+KyD@Apj$EBCYWku|=D2PWGF&5O&lSJ`c)ksY$ zmnj5zA+s@wM^R}qg*R;53Y^`YAt*?74w<FLGlJNzg4tCdA`zw%vV-^CcDu4(E-m37 zikyS_qmLdZBzas!ObV|zx;xudMcHC=CxN}qdyxwXoQ#qSY@q;2Mu6cD^TvQaWKV-g z@N^3$BP5M--5WB+%D@aj=BJRs#YwFnRJ*p`tSOa3iBWb)uf7LiFXI_JiUjtAW_eNU zmQpX4wJzFKAl#{_ozZX;#IOU6l~5DRO_JCE#wM|xOR54X>6?sx5jRFz6y_uwk;IN^ ztPA=INZjizX||M-6cc0^Q%j%2BervF*fZ-%UFszXS(Biq)Ui0QKtzVpvZN%a)RYa3 z;e+m~)0zt8&eczhIbkudu<3=|A$qf1V#9gvxx<Z(<9&i)y>9BYVNwTAGIyeYWj?Ii zpT%goz7BFVJosMGVO43s$2?|$QV@sQI;7^bHWP?N7CGrHHP7ZTN*juC6ddiSD?5Ai zGBBSXtJzyHmn#b>Y$SHh8|-A<U^0z(qpX(tjIo7G8>t{ro2P)@rE$1eYo^)@>d9<h zrh_{=G^`0YXg#XiXsDXX)Hql(NHZcqF3w1ffy3zxBfTl&vcv>7hC9P;xpi$}M19d7 z+xcaHTrX$)`9#}K^67}SVWhiy;F$i!2hX0r90_M=;IGn)RWMp3%cp2f{k4aVnhM1q zX_~|4Q1uS?usHajLIxar?YX1Zs#zkfa89NotHrGyz6lQcK;f<^jaZeaQ|x7f1$+Hq zpXbw){Qw3-*i=+6R`W1Zk}fh*sWK9xN<}IZ*T*6^GJvrSqd?A1lb<&(<&0k1o%Q90 z&ZBxCYyF{ZVp)E8eIk>+tE2&0xF_<tNf<%giIbiNZ8bB+08ZkT#hlY>@XSd$W@`BS zPc#)QY5GfoReOGdMjp+x;ks}RJs#Rx{tnG#!ZRovX{f^}K!uy)l7Mp;!W?1uLUKgd zSjp*3IB#gCqYRCYJvGGm-F4JC&*(W^#gKm3tQ#o1u%u;}2`o|G;S%GQ!*4@@@OHAg z*w>KoJ%e`erc2qqRu{=Ph^!&^_V~MsGF6t4r<_XYMBS?UMBpm?c2}IP3IZ@uEh<WN z*{zEe2`6N-tLNjpJ=0aVu#n4)X+v=k2|E5sYEA$^nF)t8vrv*v&82Y=)Wn2ClrmHe zZPNm5K$(dB2bQ)1mSs+!!gwCTWI(#VuAt5xcXoqaq!>Q~Rk()u8olgA#D2Fy$GRJn z*o47bT`sC^NAj#?mCUx8L|(a~o2Yl`iG4mXNsF6>J(9uog2Ut0v&Yx^BYL~hFFty7 za|13ocsFB(>2S>kSMs(LYvalx)+wUMs3TXxTYj2T6dfu7_-UAZn#T_8cT0ZUvCtYw z8r}nIxRBgUKWuFuT$ecqdNqU_G%`{booPvNqe^{pw>!txVjz%;To=GpOtHy<jGkcK zKO~~TOTf5kDF77?(3`A6en2*`A6SkJ4V28Ll7rf6CplCk%>@D1LFi8pRdECzF-f$~ z^cc=CVx?XolV~qXXd52oc4Tr%Zy_<Q4^G|q-a;7JXq(&Z*@iAF>Gs443F-y`WH`X9 z^S+=GNtB5hyv|zAbar?K2XRO-B<Jw}M*S6Cze?+Q^x|j-eJd?%Za3JWHif;Kh5IRY zEZa6xzgk>UiyTI@Cr21ja$?16lSrr}p~|UUqAQOu3$vIsOVZ4GF4Aa(0s$EDagj5b zRWQib2{Aj*Q)pbK+f(&Aga{Q$;<9jpPCsghEg#<qq;1hHs40IyH;p=oN9+px-_4H@ zMJ_zd(!IQM-}pHBV4OX@v_TZv7<iQU%ezezscRpXm+cP0LppN`o;>WT&ubyzFW1kI zD?On&AIvvw;eS~o<|H*`o~eXVQ)MCz>5CvqmzVJph~uJQ!p7dAs&s&6T;%qIgOk<J z0&b!oCR8iOX1q~EhRKY+xJn4)vCOhKr~6sDOv{$eRp$PMT!q*SY~}W_M8!4C!f3eq z%SQDAn@;Kl!pT9mQVesrZc}5l|CQo`ism^K3mnJR7}OB~Y!J|FTs*KEAN6qYaFoC_ z>18e@o1i_s#2$SC7R~8PFS<gDBavm2zO_q28ArH~j)nQ^k+YGaN=1-i;<*&}?c`F& zV*ORs#65e|(N^#4McV~23N6!BUnKoU{lJGb6K?LmU-~?;OVZXbyO&CQN9R?MNI_J3 zz5xLbLj4HW^1^&gz}N<9_cwT0mO06S#odch_&@?c^Qb&GQ-$IvhjY!(^8B5_GI++w zy+M~9MuA(-V2R$mD;FS`5o)UN_?%HXJ7_T%F7LtuY|8E$j2hJK5G;J7J%|oi(QeLn V3j+Hd4CvAkZD^qOM*6$Z=>J&7Iwb%A -- GitLab From 4db350d36d7664f9954e445a29dc5553006cc793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 11 May 2017 15:18:40 +0200 Subject: [PATCH 015/567] Cleaning: some useless headers and old commented code have been removed --- app/cbDimensionalityReduction.cxx | 1 - app/cbDimensionalityReductionTrainer.cxx | 47 ------------------------ 2 files changed, 48 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index d1e4861be1..4275a3e8a0 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -1,4 +1,3 @@ - /*========================================================================= Program: ORFEO Toolbox diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index f8496bd0f7..03bfbb7b96 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -9,38 +9,13 @@ #include "otbShiftScaleSampleListFilter.h" #include "otbStatisticsXMLFileReader.h" -//#include "AutoencoderModel.h" - #include "otbSharkUtils.h" -#include "otbMachineLearningModel.h" -//include train function -#include <shark/ObjectiveFunctions/ErrorFunction.h> -#include <shark/Algorithms/GradientDescent/Rprop.h>// the RProp optimization algorithm -#include <shark/ObjectiveFunctions/Loss/SquaredLoss.h> // squared loss used for regression -#include <shark/ObjectiveFunctions/Regularizer.h> //L2 regulariziation #include <fstream> // write the model file - -#include <shark/Models/Autoencoder.h>//normal autoencoder model -#include <shark/Models/TiedAutoencoder.h>//autoencoder with tied weights -#include <shark/Models/Normalizer.h> - -#include <shark/Algorithms/Trainers/NormalizeComponentsUnitVariance.h> - #include "otbMachineLearningModelFactory.h" - #include "cbLearningApplicationBaseDR.h" -shark::Normalizer<shark::RealVector> trainNormalizer(const shark::UnlabeledData<shark::RealVector>& data) -{ - bool removeMean = true; - shark::Normalizer<shark::RealVector> normalizer; - shark::NormalizeComponentsUnitVariance<shark::RealVector> normalizingTrainer(removeMean); - normalizingTrainer.train(normalizer, data); - return normalizer; -} - namespace otb { @@ -68,15 +43,7 @@ public: typedef otb::StatisticsXMLFileReader<SampleType> StatisticsReader; typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; - - - - //typedef float ValueType; - //typedef itk::VariableLengthVector<ValueType> InputSampleType; - //typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; - //typedef itk::VariableLengthVector<ValueType> MeasurementType; - typedef otb::MachineLearningModelFactory<ValueType, ValueType> ModelFactoryType; private: @@ -103,19 +70,6 @@ private: Superclass::DoInit(); - - /* - AddParameter(ParameterType_InputFilename, "model", "Dimensionality Reduction model file"); - SetParameterDescription("model", "A model file (produced by cbDimensionalityReduction application."); - - AddParameter(ParameterType_InputFilename, "normalizer", "normalizer model file"); - SetParameterDescription("normalizer", "A model file (produced by cbDimensionalityReduction application."); -*/ - -/* - AddParameter(ParameterType_InputVectorData, "val", "Name of the input validation vector data"); - SetParameterDescription("val","The vector data used for validation."); -*/ AddRAMParameter(); } @@ -149,7 +103,6 @@ private: input->PushBack(mv); } -// Statistics for shift/scale MeasurementType meanMeasurementVector; MeasurementType stddevMeasurementVector; if (HasValue("io.stats") && IsParameterEnabled("io.stats")) -- GitLab From c9051b5447296495d798e718f39810351cc0851d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 11 May 2017 15:23:19 +0200 Subject: [PATCH 016/567] encode_filter and dummy_filter have been removed, as they are not used in the applications anymore. --- include/dummy_filter.h | 47 ----------- include/dummy_filter.txx | 79 ------------------ include/encode_filter.h | 54 ------------- include/encode_filter.txx | 165 -------------------------------------- 4 files changed, 345 deletions(-) delete mode 100644 include/dummy_filter.h delete mode 100644 include/dummy_filter.txx delete mode 100644 include/encode_filter.h delete mode 100644 include/encode_filter.txx diff --git a/include/dummy_filter.h b/include/dummy_filter.h deleted file mode 100644 index ea6dd8d21a..0000000000 --- a/include/dummy_filter.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __dummy_Filter_h -#define __dummy_Filter_h - -#include "itkImageToImageFilter.h" -#include "itkMacro.h" - - -template< class TImage> -class ITK_EXPORT DummyFilter:public itk::ImageToImageFilter< TImage, TImage > -{ - public: - /** Standard class typedefs. */ - typedef DummyFilter Self; - typedef itk::ImageToImageFilter< TImage, TImage > Superclass; - typedef itk::SmartPointer< Self > Pointer; - - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Run-time type information (and related methods). */ - itkTypeMacro(DummyFilter, ImageToImageFilter); - - //void SetInputImage(const TImage* image); - - - protected: - DummyFilter(); - ~DummyFilter(){} - - typename TImage::ConstPointer GetInputImage(); - - /** Does the real work. */ - - virtual void BeforeThreadedGenerateData(); - void ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) ITK_OVERRIDE; - - private: - DummyFilter(const Self &); //purposely not implemented - void operator=(const Self &); //purposely not implemented -}; - -#ifndef ITK_MANUAL_INSTANTIATION -#include "dummy_filter.txx" -#endif - - -#endif // __dummy_Filter_h diff --git a/include/dummy_filter.txx b/include/dummy_filter.txx deleted file mode 100644 index 2ec1ced9e8..0000000000 --- a/include/dummy_filter.txx +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef __dummy_filter_txx -#define __dummy_filter_txx - -#include "dummy_filter.h" -#include <fstream> - - -#include "itkObjectFactory.h" -#include "itkImageRegionIterator.h" -#include "itkImageRegionConstIterator.h" -#include "otbVectorImage.h" - -/* -#include <shark/Data/Csv.h> -#include <shark/Data/Pgm.h> //for exporting the learned filters -#include <shark/Data/SparseData.h>//for reading in the images as sparseData/Libsvm format -#include <shark/Models/Autoencoder.h>//normal autoencoder model -#include <shark/Models/TiedAutoencoder.h>//autoencoder with tied weights -#include <shark/Models/Normalizer.h> -#include <shark/Algorithms/Trainers/NormalizeComponentsUnitVariance.h> -*/ - -//using namespace shark; - -template< class TImage> -DummyFilter<TImage>::DummyFilter() -{ - this->SetNumberOfRequiredInputs(1); -} - - - -template< class TImage> -typename TImage::ConstPointer DummyFilter<TImage>::GetInputImage() -{ - return static_cast< const TImage * > - ( this->itk::ProcessObject::GetInput(0) ); -} - - - - - -template< class TImage> -void DummyFilter<TImage>::BeforeThreadedGenerateData() -{ -#ifdef _OPENMP -// OpenMP will take care of threading -this->SetNumberOfThreads(1); -#endif -} - - -/*template< class TImage, class AutoencoderModel, class NormalizerModel> -void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GenerateData()*/ -template< class TImage> -void DummyFilter<TImage>::ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) -{ - //Data_with_info info; - typename TImage::ConstPointer input = this->GetInput(); - typename TImage::Pointer output = this->GetOutput(); - - // Image to vector - const unsigned int img_bands = input->GetNumberOfComponentsPerPixel(); - - itk::ImageRegionConstIterator<TImage> inputIterator(input,outputRegionForThread); - itk::ImageRegionIterator<TImage> imageIteratorOut(output,outputRegionForThread); - - typename TImage::PixelType pixelValue; - while(!inputIterator.IsAtEnd()){ - imageIteratorOut.Set(inputIterator.Get()); - ++inputIterator; - ++imageIteratorOut; - } - -} - - -#endif diff --git a/include/encode_filter.h b/include/encode_filter.h deleted file mode 100644 index 903912be28..0000000000 --- a/include/encode_filter.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef __encode_Filter_h -#define __encode_Filter_h - -#include "itkImageToImageFilter.h" -#include "itkMacro.h" - - -template< class TImage, class AutoencoderModel, class NormalizerModel> -class ITK_EXPORT EncodeFilter:public itk::ImageToImageFilter< TImage, TImage > -{ - public: - // Standard class typedefs. - typedef EncodeFilter Self; - typedef itk::ImageToImageFilter< TImage, TImage > Superclass; - typedef itk::SmartPointer< Self > Pointer; - - // Method for creation through the object factory. - itkNewMacro(Self); - - // Run-time type information (and related methods). - itkTypeMacro(EncodeFilter, ImageToImageFilter); - - //void SetInputImage(const TImage* image); - void SetAutoencoderModel(const std::string encoderPath); - void SetNormalizerModel(const std::string NormalizerPath); - void SetModels( const AutoencoderModel net, const NormalizerModel normalizer); - std::size_t GetDimension(){return m_hidden_neuron;}; - protected: - EncodeFilter(); - ~EncodeFilter(){} - - typename TImage::ConstPointer GetInputImage(); - AutoencoderModel GetAutoencoderModel(); - NormalizerModel GetNormalizerModel(); - - // Does the real work. - virtual void GenerateOutputInformation(); - virtual void BeforeThreadedGenerateData(); - void ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) ITK_OVERRIDE; - - private: - EncodeFilter(const Self &); //purposely not implemented - void operator=(const Self &); //purposely not implemented - AutoencoderModel m_net; - NormalizerModel m_normalizer; - std::size_t m_hidden_neuron; -}; - -#ifndef ITK_MANUAL_INSTANTIATION -#include "encode_filter.txx" -#endif - - -#endif // __encode_Filter_h diff --git a/include/encode_filter.txx b/include/encode_filter.txx deleted file mode 100644 index a96b048f33..0000000000 --- a/include/encode_filter.txx +++ /dev/null @@ -1,165 +0,0 @@ -#ifndef __encode_filter_txx -#define __encode_filter_txx - -#include "encode_filter.h" -#include <fstream> - - -#include "itkObjectFactory.h" -#include "itkImageRegionIterator.h" -#include "itkImageRegionConstIterator.h" -#include "otbVectorImage.h" - - -#include <shark/Data/Csv.h> -#include <shark/Data/Pgm.h> //for exporting the learned filters -#include <shark/Data/SparseData.h>//for reading in the images as sparseData/Libsvm format -#include <shark/Models/Autoencoder.h>//normal autoencoder model -#include <shark/Models/TiedAutoencoder.h>//autoencoder with tied weights -#include <shark/Models/Normalizer.h> -#include <shark/Algorithms/Trainers/NormalizeComponentsUnitVariance.h> - - -//using namespace shark; - -template< class TImage, class AutoencoderModel, class NormalizerModel> -EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::EncodeFilter() -{ - this->SetNumberOfRequiredInputs(1); -} - - -template< class TImage, class AutoencoderModel, class NormalizerModel> -void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::SetAutoencoderModel(const std::string encoderPath) -{ - //m_net = net; - std::ifstream ifs(encoderPath); - boost::archive::polymorphic_text_iarchive ia(ifs); - m_net.read(ia); - ifs.close(); - m_hidden_neuron = m_net.numberOfHiddenNeurons(); -} - - -template< class TImage, class AutoencoderModel, class NormalizerModel> -void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::SetNormalizerModel(const std::string NormalizerPath) -{ - //m_normalizer = normalizer; - std::ifstream ifs(NormalizerPath); - boost::archive::polymorphic_text_iarchive ia(ifs); - m_normalizer.read(ia); - ifs.close(); -} - - -template< class TImage, class AutoencoderModel, class NormalizerModel> -void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::SetModels(const AutoencoderModel net, const NormalizerModel normalizer) -{ - m_net = net; - m_normalizer = normalizer; -} - - -template< class TImage, class AutoencoderModel, class NormalizerModel> -typename TImage::ConstPointer EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GetInputImage() -{ - return static_cast< const TImage * > - ( this->itk::ProcessObject::GetInput(0) ); -} - - - -template< class TImage, class AutoencoderModel, class NormalizerModel> -AutoencoderModel EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GetAutoencoderModel() -{ - return m_net; -} - - -template< class TImage, class AutoencoderModel, class NormalizerModel> -NormalizerModel EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GetNormalizerModel() -{ - return m_normalizer; -} - - - -struct Data_with_info { - shark::Data<shark::RealVector> data; // This file format can be used to do Machine Learning with the Shark ML library - otb::VectorImage<double, 2>::RegionType region; - otb::VectorImage<double, 2>::PointType origin; - otb::VectorImage<double, 2>::SpacingType spacing; -}; - - -template< class TImage, class AutoencoderModel, class NormalizerModel> -void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::BeforeThreadedGenerateData() -{ -#ifdef _OPENMP -// OpenMP will take care of threading -this->SetNumberOfThreads(1); -#endif -} - -template< class TImage, class AutoencoderModel, class NormalizerModel> -void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::GenerateOutputInformation() -{ - Superclass::GenerateOutputInformation(); - this->GetOutput()->SetNumberOfComponentsPerPixel( m_hidden_neuron ); -} - -template< class TImage, class AutoencoderModel, class NormalizerModel> -void EncodeFilter<TImage, AutoencoderModel, NormalizerModel>::ThreadedGenerateData(const typename TImage::RegionType &outputRegionForThread, unsigned int threadId) -{ - //Data_with_info info; - typename TImage::ConstPointer input = this->GetInput(); - typename TImage::Pointer output = this->GetOutput(); - // Image to vector - const unsigned int img_bands = input->GetNumberOfComponentsPerPixel(); - - itk::ImageRegionConstIterator<TImage> inputIterator(input,outputRegionForThread); - - std::vector<shark::RealVector> image_vect; - - typename TImage::PixelType pixelValue; - while(!inputIterator.IsAtEnd()){ - shark::RealVector vect; - pixelValue = inputIterator.Get(); - for(unsigned int a = 0; a < img_bands; ++a){ - vect.push_back(pixelValue[a]); - } - image_vect.push_back(vect); - ++inputIterator; - } - shark::Data<shark::RealVector> data = shark::createDataFromRange(image_vect); - image_vect.clear(); - - /** Normalize the data */ - - data= transform(data, m_normalizer); - /** Encode the data */ - - data = m_net.encode(data); - - /** vector to image */ - - std::size_t numHidden = data.element(1).size(); - output->SetVectorLength(numHidden); - itk::ImageRegionIterator<TImage> imageIteratorOut(output,outputRegionForThread); - auto vect_it = data.elements().begin(); - while(!imageIteratorOut.IsAtEnd() && vect_it!=data.elements().end()){ - pixelValue.SetSize(numHidden); - shark::RealVector vect_out=(*vect_it); - for(unsigned int a = 0; a < numHidden; ++a){ - pixelValue[a]=vect_out[a]; - } - - imageIteratorOut.Set(pixelValue); - ++imageIteratorOut; - ++vect_it; - } - -} - - -#endif -- GitLab From ae2ac84c1824ab51c01d7e6a336806ce1c5793c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 11 May 2017 17:47:05 +0200 Subject: [PATCH 017/567] creation of drmodel and drmodelfactory --- include/AutoencoderModel.h | 8 +- include/AutoencoderModelFactory.txx | 4 +- include/DimensionalityReductionModel.h | 240 ++++++++++++++++++ include/DimensionalityReductionModel.txx | 192 ++++++++++++++ include/DimensionalityReductionModelFactory.h | 81 ++++++ .../DimensionalityReductionModelFactory.txx | 148 +++++++++++ 6 files changed, 667 insertions(+), 6 deletions(-) create mode 100644 include/DimensionalityReductionModel.h create mode 100644 include/DimensionalityReductionModel.txx create mode 100644 include/DimensionalityReductionModelFactory.h create mode 100644 include/DimensionalityReductionModelFactory.txx diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 5fdd4ba072..2c59573449 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -1,19 +1,19 @@ #ifndef AutoencoderModel_h #define AutoencoderModel_h -#include "otbMachineLearningModel.h" +#include "DimensionalityReductionModel.h" namespace otb { template <class TInputValue, class AutoencoderType> -class ITK_EXPORT AutoencoderModel: public MachineLearningModel<TInputValue,TInputValue> +class ITK_EXPORT AutoencoderModel: public DimensionalityReductionModel<TInputValue,TInputValue> { public: typedef AutoencoderModel Self; - typedef MachineLearningModel<TInputValue,TInputValue> Superclass; + typedef DimensionalityReductionModel<TInputValue,TInputValue> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -28,7 +28,7 @@ public: typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; itkNewMacro(Self); - itkTypeMacro(AutoencoderModel, MachineLearningModel); + itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); itkGetMacro(NumberOfHiddenNeurons,unsigned int); diff --git a/include/AutoencoderModelFactory.txx b/include/AutoencoderModelFactory.txx index 22d6c5ba9a..5b0d0b754a 100644 --- a/include/AutoencoderModelFactory.txx +++ b/include/AutoencoderModelFactory.txx @@ -31,12 +31,12 @@ template <class TInputValue, class TOutputValue, class AutoencoderType> AutoencoderModelFactoryBase<TInputValue,TOutputValue, AutoencoderType>::AutoencoderModelFactoryBase() { - std::string classOverride = std::string("otbMachineLearningModel"); + std::string classOverride = std::string("DimensionalityReductionModel"); std::string subclass = std::string("AutoencoderModel"); this->RegisterOverride(classOverride.c_str(), subclass.c_str(), - "Shark RF ML Model", + "Shark AE ML Model", 1, // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); itk::CreateObjectFunction<AutoencoderModel<TInputValue,AutoencoderType > >::New()); diff --git a/include/DimensionalityReductionModel.h b/include/DimensionalityReductionModel.h new file mode 100644 index 0000000000..2045e9b21c --- /dev/null +++ b/include/DimensionalityReductionModel.h @@ -0,0 +1,240 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#ifndef DimensionalityReductionModel_h +#define DimensionalityReductionModel_h + +#include "itkObject.h" +#include "itkVariableLengthVector.h" +#include "itkListSample.h" + +namespace otb +{ + +/** \class MachineLearningModel + * \brief MachineLearningModel is the base class for all classifier objects (SVM, KNN, + * Random Forests, Artificial Neural Network, ...) implemented in the supervised classification framework of the OTB. + * + * MachineLearningModel is an abstract object that specifies behavior and + * interface of supervised classifiers (SVM, KNN, Random Forests, Artificial + * Neural Network, ...) in the generic supervised classification framework of the OTB. + * The main generic virtual methods specifically implemented in each classifier + * derived from the MachineLearningModel class are two learning-related methods: + * Train() and Save(), and three classification-related methods: Load(), + * DoPredict() and optionnaly DoPredictBatch(). + * + * Thus, each classifier derived from the MachineLearningModel class + * computes its corresponding model with Train() and exports it with + * the help of the Save() method. + * + * It is also possible to classify any input sample composed of several + * features (or any number of bands in the case of a pixel extracted + * from a multi-band image) with the help of the Predict() method which + * needs a previous loading of the classification model with the Load() method. + * + * \sa MachineLearningModelFactory + * \sa LibSVMMachineLearningModel + * \sa SVMMachineLearningModel + * \sa BoostMachineLearningModel + * \sa KNearestNeighborsMachineLearningModel + * \sa DecisionTreeMachineLearningModel + * \sa RandomForestsMachineLearningModel + * \sa GradientBoostedTreeMachineLearningModel + * \sa NormalBayesMachineLearningModel + * \sa NeuralNetworkMachineLearningModel + * \sa SharkRandomForestsMachineLearningModel + * \sa ImageClassificationFilter + * + * + * \ingroup OTBSupervised + */ +template <class TInputValue, class TTargetValue, class TConfidenceValue = double > +class ITK_EXPORT DimensionalityReductionModel + : public itk::Object +{ +public: + /**\name Standard ITK typedefs */ + //@{ + typedef DimensionalityReductionModel Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + //@} + + /**\name Input related typedefs */ + //@{ + typedef TInputValue InputValueType; + typedef itk::VariableLengthVector<InputValueType> InputSampleType; + typedef itk::Statistics::ListSample<InputSampleType> InputListSampleType; + //@} + + /**\name Target related typedefs */ + //@{ + typedef TTargetValue TargetValueType; + typedef itk::VariableLengthVector<TargetValueType> TargetSampleType; + typedef itk::Statistics::ListSample<TargetSampleType> TargetListSampleType; + //@} + + /**\name Confidence value typedef */ + typedef TConfidenceValue ConfidenceValueType; + typedef itk::FixedArray<ConfidenceValueType,1> ConfidenceSampleType; + typedef itk::Statistics::ListSample<ConfidenceSampleType> ConfidenceListSampleType; + + /**\name Standard macros */ + //@{ + /** Run-time type information (and related methods). */ + itkTypeMacro(DimensionalityReductionModel, itk::Object); + //@} + + /** Train the machine learning model */ + virtual void Train() =0; + + /** Predict a single sample + * \param input The sample + * \param quality A pointer to the quality variable were to store + * quality value, or NULL + * \return The predicted label + */ + TargetSampleType Predict(const InputSampleType& input, ConfidenceValueType *quality = ITK_NULLPTR) const; + + + + /** Predict a batch of samples (InputListSampleType) + * \param input The batch of sample to predict + * \param quality A pointer to the list were to store + * quality value, or NULL + * \return The predicted labels + * Note that this method will be multi-threaded if OTB is built + * with OpenMP. + */ + typename TargetListSampleType::Pointer PredictBatch(const InputListSampleType * input, ConfidenceListSampleType * quality = ITK_NULLPTR) const; + + /** THIS METHOD IS DEPRECATED AND SHOULD NOT BE USED. */ + void PredictAll(); + + /**\name Classification model file manipulation */ + //@{ + /** Save the model to file */ + virtual void Save(const std::string & filename, const std::string & name="") = 0; + + /** Load the model from file */ + virtual void Load(const std::string & filename, const std::string & name="") = 0; + //@} + + /**\name Classification model file compatibility tests */ + //@{ + /** Is the input model file readable and compatible with the corresponding classifier ? */ + virtual bool CanReadFile(const std::string &) = 0; + + /** Is the input model file writable and compatible with the corresponding classifier ? */ + virtual bool CanWriteFile(const std::string &) = 0; + //@} + + /** Query capacity to produce a confidence index */ + bool HasConfidenceIndex() const {return m_ConfidenceIndex;} + + /**\name Input list of samples accessors */ + //@{ + itkSetObjectMacro(InputListSample,InputListSampleType); + itkGetObjectMacro(InputListSample,InputListSampleType); + itkGetConstObjectMacro(InputListSample,InputListSampleType); + //@} + + /**\name Classification output accessors */ + //@{ + /** Set the target labels (to be used before training) */ + itkSetObjectMacro(TargetListSample,TargetListSampleType); + /** Get the target labels (to be used after PredictAll) */ + itkGetObjectMacro(TargetListSample,TargetListSampleType); + //@} + + itkGetObjectMacro(ConfidenceListSample,ConfidenceListSampleType); + + /**\name Use model in regression mode */ + //@{ + itkGetMacro(RegressionMode,bool); + void SetRegressionMode(bool flag); + //@} + +protected: + /** Constructor */ + DimensionalityReductionModel(); + + /** Destructor */ + ~DimensionalityReductionModel() ITK_OVERRIDE; + + /** PrintSelf method */ + void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + + /** Input list sample */ + typename InputListSampleType::Pointer m_InputListSample; + + /** Target list sample */ + typename TargetListSampleType::Pointer m_TargetListSample; + + typename ConfidenceListSampleType::Pointer m_ConfidenceListSample; + + /** flag to choose between classification and regression modes */ + bool m_RegressionMode; + + /** flag that indicates if the model supports regression, child + * classes should modify it in their constructor if they support + * regression mode */ + bool m_IsRegressionSupported; + + /** flag that tells if the model support confidence index output */ + bool m_ConfidenceIndex; + + /** Is DoPredictBatch multi-threaded ? */ + bool m_IsDoPredictBatchMultiThreaded; + +private: + /** Actual implementation of BatchPredicition + * Default implementation will call DoPredict iteratively + * \param input The input batch + * \param startIndex Index of the first sample to predict + * \param size Number of samples to predict + * \param target Pointer to the list of produced labels + * \param quality Pointer to the list of produced confidence + * values, or NULL + * + * Override me if internal implementation allows for batch + * prediction. + * + * Also set m_IsDoPredictBatchMultiThreaded to true if internal + * implementation allows for parallel batch prediction. + */ + virtual void DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * target, ConfidenceListSampleType * quality = ITK_NULLPTR) const; + + /** Actual implementation of single sample prediction + * \param input sample to predict + * \param quality Pointer to a variable to store confidence value, + * or NULL + * \return The predicted label + */ + virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType * quality= ITK_NULLPTR) const = 0; + + DimensionalityReductionModel(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented +}; +} // end namespace otb + +#ifndef OTB_MANUAL_INSTANTIATION +#include "DimensionalityReductionModel.txx" +#endif + +#endif diff --git a/include/DimensionalityReductionModel.txx b/include/DimensionalityReductionModel.txx new file mode 100644 index 0000000000..68db8019a3 --- /dev/null +++ b/include/DimensionalityReductionModel.txx @@ -0,0 +1,192 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#ifndef DimensionalityReductionModel_txx +#define DimensionalityReductionModel_txx + +#ifdef _OPENMP + # include <omp.h> +#endif + +#include "DimensionalityReductionModel.h" + +#include "itkMultiThreader.h" + +namespace otb +{ + +template <class TInputValue, class TOutputValue, class TConfidenceValue> +DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +::DimensionalityReductionModel() : + m_RegressionMode(false), + m_IsRegressionSupported(false), + m_ConfidenceIndex(false), + m_IsDoPredictBatchMultiThreaded(false) +{} + + +template <class TInputValue, class TOutputValue, class TConfidenceValue> +DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +::~DimensionalityReductionModel() +{} + +template <class TInputValue, class TOutputValue, class TConfidenceValue> +void +DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +::SetRegressionMode(bool flag) +{ + if (flag && !m_IsRegressionSupported) + { + itkGenericExceptionMacro(<< "Regression mode not implemented."); + } + if (m_RegressionMode != flag) + { + m_RegressionMode = flag; + this->Modified(); + } +} + +template <class TInputValue, class TOutputValue, class TConfidenceValue> +void +DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +::PredictAll() +{ + itkWarningMacro("DimensionalityReductionModel::PredictAll() has been DEPRECATED. Use DimensionalityReductionModel::PredictBatch() instead."); + + typename TargetListSampleType::Pointer targets = this->GetTargetListSample(); + targets->Clear(); + + typename TargetListSampleType::Pointer tmpTargets = this->PredictBatch(this->GetInputListSample()); + + targets->Graft(tmpTargets); +} + +template <class TInputValue, class TOutputValue, class TConfidenceValue> +typename DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +::TargetSampleType +DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +::Predict(const InputSampleType& input, ConfidenceValueType *quality) const +{ + // Call protected specialization entry point + return this->DoPredict(input,quality); +} + + +template <class TInputValue, class TOutputValue, class TConfidenceValue> +typename DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +::TargetListSampleType::Pointer +DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +::PredictBatch(const InputListSampleType * input, ConfidenceListSampleType * quality) const +{ + typename TargetListSampleType::Pointer targets = TargetListSampleType::New(); + targets->Resize(input->Size()); + + if(quality!=ITK_NULLPTR) + { + quality->Clear(); + quality->Resize(input->Size()); + } + + if(m_IsDoPredictBatchMultiThreaded) + { + // Simply calls DoPredictBatch + this->DoPredictBatch(input,0,input->Size(),targets,quality); + return targets; + } + else + { + + #ifdef _OPENMP + // OpenMP threading here + unsigned int nb_threads(0), threadId(0), nb_batches(0); + + #pragma omp parallel shared(nb_threads,nb_batches) private(threadId) + { + // Get number of threads configured with ITK + omp_set_num_threads(itk::MultiThreader::GetGlobalDefaultNumberOfThreads()); + nb_threads = omp_get_num_threads(); + threadId = omp_get_thread_num(); + nb_batches = std::min(nb_threads,(unsigned int)input->Size()); + // Ensure that we do not spawn unncessary threads + if(threadId<nb_batches) + { + unsigned int batch_size = ((unsigned int)input->Size()/nb_batches); + unsigned int batch_start = threadId*batch_size; + if(threadId == nb_threads-1) + { + batch_size+=input->Size()%nb_batches; + } + + this->DoPredictBatch(input,batch_start,batch_size,targets,quality); + } + } + #else + this->DoPredictBatch(input,0,input->Size(),targets,quality); + #endif + return targets; + } +} + + + +template <class TInputValue, class TOutputValue, class TConfidenceValue> +void +DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +::DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const +{ + assert(input != ITK_NULLPTR); + assert(targets != ITK_NULLPTR); + + assert(input->Size()==targets->Size()&&"Input sample list and target label list do not have the same size."); + assert(((quality==ITK_NULLPTR)||(quality->Size()==input->Size()))&&"Quality samples list is not null and does not have the same size as input samples list"); + + if(startIndex+size>input->Size()) + { + itkExceptionMacro(<<"requested range ["<<startIndex<<", "<<startIndex+size<<"[ partially outside input sample list range.[0,"<<input->Size()<<"["); + } + + if(quality != ITK_NULLPTR) + { + for(unsigned int id = startIndex;id<startIndex+size;++id) + { + ConfidenceValueType confidence = 0; + const TargetSampleType target = this->DoPredict(input->GetMeasurementVector(id),&confidence); + quality->SetMeasurementVector(id,confidence); + targets->SetMeasurementVector(id,target); + } + } + else + { + for(unsigned int id = startIndex;id<startIndex+size;++id) + { + const TargetSampleType target = this->DoPredict(input->GetMeasurementVector(id)); + targets->SetMeasurementVector(id,target); + } + } +} + +template <class TInputValue, class TOutputValue, class TConfidenceValue> +void +DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + // Call superclass implementation + Superclass::PrintSelf(os,indent); +} +} + +#endif diff --git a/include/DimensionalityReductionModelFactory.h b/include/DimensionalityReductionModelFactory.h new file mode 100644 index 0000000000..eebade611d --- /dev/null +++ b/include/DimensionalityReductionModelFactory.h @@ -0,0 +1,81 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#ifndef DimensionalityReductionModelFactory_h +#define DimensionalityReductionModelFactory_h + +#include "DimensionalityReductionModel.h" +#include "otbMachineLearningModelFactoryBase.h" + +namespace otb +{ +/** \class MachineLearningModelFactory + * \brief Creation of object instance using object factory. + * + * \ingroup OTBSupervised + */ +template <class TInputValue, class TOutputValue> +class DimensionalityReductionModelFactory : public MachineLearningModelFactoryBase +{ +public: + /** Standard class typedefs. */ + typedef DimensionalityReductionModelFactory Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Class Methods used to interface with the registered factories */ + + /** Run-time type information (and related methods). */ + itkTypeMacro(DimensionalityReductionModelFactory, itk::Object); + + /** Convenient typedefs. */ + typedef otb::DimensionalityReductionModel<TInputValue,TOutputValue> DimensionalityReductionModelType; + typedef typename DimensionalityReductionModelType::Pointer DimensionalityReductionModelTypePointer; + + /** Mode in which the files is intended to be used */ + typedef enum { ReadMode, WriteMode } FileModeType; + + /** Create the appropriate MachineLearningModel depending on the particulars of the file. */ + static DimensionalityReductionModelTypePointer CreateDimensionalityReductionModel(const std::string& path, FileModeType mode); + + static void CleanFactories(); + +protected: + DimensionalityReductionModelFactory(); + ~DimensionalityReductionModelFactory() ITK_OVERRIDE; + +private: + DimensionalityReductionModelFactory(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + + /** Register Built-in factories */ + static void RegisterBuiltInFactories(); + + /** Register a single factory, ensuring it has not been registered + * twice */ + static void RegisterFactory(itk::ObjectFactoryBase * factory); + +}; + +} // end namespace otb + +#ifndef OTB_MANUAL_INSTANTIATION +#include "DimensionalityReductionModelFactory.txx" +#endif + +#endif diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx new file mode 100644 index 0000000000..4cd8751994 --- /dev/null +++ b/include/DimensionalityReductionModelFactory.txx @@ -0,0 +1,148 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#ifndef DimensionalityReductionModelFactory_txx +#define DimensionalityReductionFactory_txx + +#include "DimensionalityReductionModelFactory.h" +#include "otbConfigure.h" + + +#ifdef OTB_USE_SHARK +#include "AutoencoderModelFactory.h" +#endif + +#include "itkMutexLockHolder.h" + + +namespace otb +{ +template <class TInputValue, class TOutputValue> +typename DimensionalityReductionModel<TInputValue,TOutputValue>::Pointer +DimensionalityReductionModelFactory<TInputValue,TOutputValue> +::CreateDimensionalityReductionModel(const std::string& path, FileModeType mode) +{ + RegisterBuiltInFactories(); + + std::list<DimensionalityReductionModelTypePointer> possibleDimensionalityReductionModel; + std::list<LightObject::Pointer> allobjects = + itk::ObjectFactoryBase::CreateAllInstance("DimensionalityReductionModel"); + for(std::list<LightObject::Pointer>::iterator i = allobjects.begin(); + i != allobjects.end(); ++i) + { + DimensionalityReductionModel<TInputValue,TOutputValue> * io = dynamic_cast<DimensionalityReductionModel<TInputValue,TOutputValue>*>(i->GetPointer()); + if(io) + { + possibleDimensionalityReductionModel.push_back(io); + } + else + { + std::cerr << "Error DimensionalityReductionModel Factory did not return an DimensionalityReductionModel: " + << (*i)->GetNameOfClass() + << std::endl; + } + } +for(typename std::list<DimensionalityReductionModelTypePointer>::iterator k = possibleDimensionalityReductionModel.begin(); + k != possibleDimensionalityReductionModel.end(); ++k) + { + if( mode == ReadMode ) + { + if((*k)->CanReadFile(path)) + { + return *k; + } + } + else if( mode == WriteMode ) + { + if((*k)->CanWriteFile(path)) + { + return *k; + } + + } + } + return ITK_NULLPTR; +} + +template <class TInputValue, class TOutputValue> +void +DimensionalityReductionModelFactory<TInputValue,TOutputValue> +::RegisterBuiltInFactories() +{ + itk::MutexLockHolder<itk::SimpleMutexLock> lockHolder(mutex); + + +#ifdef OTB_USE_SHARK + RegisterFactory(AutoencoderModelFactory<TInputValue,TOutputValue>::New()); + RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); +#endif + +} + +template <class TInputValue, class TOutputValue> +void +DimensionalityReductionModelFactory<TInputValue,TOutputValue> +::RegisterFactory(itk::ObjectFactoryBase * factory) +{ + // Unregister any previously registered factory of the same class + // Might be more intensive but static bool is not an option due to + // ld error. + itk::ObjectFactoryBase::UnRegisterFactory(factory); + itk::ObjectFactoryBase::RegisterFactory(factory); +} + +template <class TInputValue, class TOutputValue> +void +DimensionalityReductionModelFactory<TInputValue,TOutputValue> +::CleanFactories() +{ + itk::MutexLockHolder<itk::SimpleMutexLock> lockHolder(mutex); + + std::list<itk::ObjectFactoryBase*> factories = itk::ObjectFactoryBase::GetRegisteredFactories(); + std::list<itk::ObjectFactoryBase*>::iterator itFac; + + for (itFac = factories.begin(); itFac != factories.end() ; ++itFac) + { + + +#ifdef OTB_USE_SHARK + + // Autoencoder + AutoencoderModelFactory<TInputValue,TOutputValue> *aeFactory = + dynamic_cast<AutoencoderModelFactory<TInputValue,TOutputValue> *>(*itFac); + if (aeFactory) + { + itk::ObjectFactoryBase::UnRegisterFactory(aeFactory); + continue; + } + + TiedAutoencoderModelFactory<TInputValue,TOutputValue> *taeFactory = + dynamic_cast<TiedAutoencoderModelFactory<TInputValue,TOutputValue> *>(*itFac); + if (taeFactory) + { + itk::ObjectFactoryBase::UnRegisterFactory(taeFactory); + continue; + } +#endif + + } + +} + +} // end namespace otb + +#endif -- GitLab From abac2ee1c919653efe7b9a356c71ae7dd1ba41af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 11 May 2017 17:53:33 +0200 Subject: [PATCH 018/567] master working again --- app/cbDimensionalityReduction.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index 4275a3e8a0..5ec146218a 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -28,6 +28,9 @@ #include "otbImageToVectorImageCastFilter.h" #include "otbMachineLearningModelFactory.h" + +//#include "DimensionalityReductionModelFactory.h" // new branch + namespace otb { namespace Functor @@ -202,7 +205,7 @@ private: m_Model->Load(GetParameterString("model")); m_Model->SetRegressionMode(true); otbAppLogINFO("Model loaded"); - + // Classify m_ClassificationFilter = ClassificationFilterType::New(); m_ClassificationFilter->SetModel(m_Model); @@ -265,7 +268,7 @@ private: } SetParameterOutputImage<FloatImageType>("out", outputImage); - + } ClassificationFilterType::Pointer m_ClassificationFilter; -- GitLab From 1fd2ba4d288b6b42459ad9904d6154372e33b70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Fri, 12 May 2017 11:13:31 +0200 Subject: [PATCH 019/567] added image dr filter --- app/cbDimensionalityReduction.cxx | 34 +- app/cbDimensionalityReductionTrainer.cxx | 4 +- include/AutoencoderModel.txx | 3 +- include/DimensionalityReductionModel.h | 8 +- include/ImageDimensionalityReductionFilter.h | 141 ++++++++ .../ImageDimensionalityReductionFilter.txx | 327 ++++++++++++++++++ include/cbLearningApplicationBaseDR.h | 8 +- 7 files changed, 500 insertions(+), 25 deletions(-) create mode 100644 include/ImageDimensionalityReductionFilter.h create mode 100644 include/ImageDimensionalityReductionFilter.txx diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index 4275a3e8a0..c689f71108 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -23,10 +23,10 @@ #include "otbStandardWriterWatcher.h" #include "otbStatisticsXMLFileReader.h" #include "otbShiftScaleVectorImageFilter.h" -#include "otbImageClassificationFilter.h" +#include "ImageDimensionalityReductionFilter.h" #include "otbMultiToMonoChannelExtractROI.h" #include "otbImageToVectorImageCastFilter.h" -#include "otbMachineLearningModelFactory.h" +#include "DimensionalityReductionModelFactory.h" namespace otb { @@ -94,19 +94,19 @@ public: FloatImageType, FloatImageType, otb::Functor::AffineFunctor<float,float> > OutputRescalerType; - typedef otb::ImageClassificationFilter<FloatVectorImageType, FloatImageType, MaskImageType> ClassificationFilterType; - typedef ClassificationFilterType::Pointer ClassificationFilterPointerType; - typedef ClassificationFilterType::ModelType ModelType; + typedef otb::ImageDimensionalityReductionFilter<FloatVectorImageType, FloatVectorImageType, MaskImageType> DimensionalityReductionFilterType; + typedef DimensionalityReductionFilterType::Pointer DimensionalityReductionFilterPointerType; + typedef DimensionalityReductionFilterType::ModelType ModelType; typedef ModelType::Pointer ModelPointerType; - typedef ClassificationFilterType::ValueType ValueType; - typedef ClassificationFilterType::LabelType LabelType; - typedef otb::MachineLearningModelFactory<ValueType, LabelType> MachineLearningModelFactoryType; + typedef DimensionalityReductionFilterType::ValueType ValueType; + typedef DimensionalityReductionFilterType::LabelType LabelType; + typedef otb::DimensionalityReductionModelFactory<ValueType, LabelType> DimensionalityReductionModelFactoryType; protected: ~CbDimensionalityReduction() ITK_OVERRIDE { - MachineLearningModelFactoryType::CleanFactories(); + DimensionalityReductionModelFactoryType::CleanFactories(); } private: @@ -191,8 +191,8 @@ private: // Load svm model otbAppLogINFO("Loading model"); - m_Model = MachineLearningModelFactoryType::CreateMachineLearningModel(GetParameterString("model"), - MachineLearningModelFactoryType::ReadMode); + m_Model = DimensionalityReductionModelFactoryType::CreateDimensionalityReductionModel(GetParameterString("model"), + DimensionalityReductionModelFactoryType::ReadMode); if (m_Model.IsNull()) { @@ -204,10 +204,10 @@ private: otbAppLogINFO("Model loaded"); // Classify - m_ClassificationFilter = ClassificationFilterType::New(); + m_ClassificationFilter = DimensionalityReductionFilterType::New(); m_ClassificationFilter->SetModel(m_Model); - FloatImageType::Pointer outputImage = m_ClassificationFilter->GetOutput(); + FloatVectorImageType::Pointer outputImage = m_ClassificationFilter->GetOutput(); // Normalize input image if asked if(IsParameterEnabled("imstat") ) @@ -224,7 +224,7 @@ private: stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); otbAppLogINFO( "mean used: " << meanMeasurementVector ); otbAppLogINFO( "standard deviation used: " << stddevMeasurementVector ); - if (meanMeasurementVector.Size() == nbFeatures + 1) + /*if (meanMeasurementVector.Size() == nbFeatures + 1) { double outMean = meanMeasurementVector[nbFeatures]; double outStdDev = stddevMeasurementVector[nbFeatures]; @@ -236,7 +236,7 @@ private: m_OutRescaler->GetFunctor().SetB(outMean); outputImage = m_OutRescaler->GetOutput(); } - else if (meanMeasurementVector.Size() != nbFeatures) + else*/ if (meanMeasurementVector.Size() != nbFeatures) { otbAppLogFATAL("Wrong number of components in statistics file : "<<meanMeasurementVector.Size()); } @@ -264,11 +264,11 @@ private: m_ClassificationFilter->SetInputMask(inMask); } - SetParameterOutputImage<FloatImageType>("out", outputImage); + SetParameterOutputImage<FloatVectorImageType>("out", outputImage); } - ClassificationFilterType::Pointer m_ClassificationFilter; + DimensionalityReductionFilterType::Pointer m_ClassificationFilter; ModelPointerType m_Model; RescalerType::Pointer m_Rescaler; OutputRescalerType::Pointer m_OutRescaler; diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index 03bfbb7b96..dd245a44e5 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -13,7 +13,7 @@ #include <fstream> // write the model file -#include "otbMachineLearningModelFactory.h" +#include "DimensionalityReductionModelFactory.h" #include "cbLearningApplicationBaseDR.h" @@ -44,7 +44,7 @@ public: typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; - typedef otb::MachineLearningModelFactory<ValueType, ValueType> ModelFactoryType; + typedef otb::DimensionalityReductionModelFactory<ValueType, ValueType> ModelFactoryType; private: void DoInit() diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 60eff32025..964af74226 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -111,6 +111,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & fil m_net.read(ia); ifs.close(); m_NumberOfHiddenNeurons = m_net.numberOfHiddenNeurons(); + //this->m_Size = m_NumberOfHiddenNeurons; } @@ -154,7 +155,7 @@ void AutoencoderModel<TInputValue,AutoencoderType> //target[a]=p[a]; target=p[a]; } - //std::cout << p << std::endl; + std::cout << p << std::endl; targets->SetMeasurementVector(id,target); ++id; } diff --git a/include/DimensionalityReductionModel.h b/include/DimensionalityReductionModel.h index 2045e9b21c..df67e2b3bf 100644 --- a/include/DimensionalityReductionModel.h +++ b/include/DimensionalityReductionModel.h @@ -201,7 +201,13 @@ protected: /** Is DoPredictBatch multi-threaded ? */ bool m_IsDoPredictBatchMultiThreaded; - + + + /** Size of the output after dimensionality reduction */ + //unsigned int m_Size; + + + private: /** Actual implementation of BatchPredicition * Default implementation will call DoPredict iteratively diff --git a/include/ImageDimensionalityReductionFilter.h b/include/ImageDimensionalityReductionFilter.h new file mode 100644 index 0000000000..d6eb3deb3e --- /dev/null +++ b/include/ImageDimensionalityReductionFilter.h @@ -0,0 +1,141 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#ifndef ImageDimensionalityReduction_h +#define ImageDimensionalityReduction_h + +#include "itkImageToImageFilter.h" +#include "DimensionalityReductionModel.h" +#include "otbImage.h" + +namespace otb +{ +/** \class ImageClassificationFilter + * \brief This filter performs the classification of a VectorImage using a Model. + * + * This filter is streamed and threaded, allowing to classify huge images + * while fully using several core. + * + * \sa Classifier + * \ingroup Streamed + * \ingroup Threaded + * + * \ingroup OTBSupervised + */ +template <class TInputImage, class TOutputImage, class TMaskImage = TOutputImage> +class ITK_EXPORT ImageDimensionalityReductionFilter + : public itk::ImageToImageFilter<TInputImage, TOutputImage> +{ +public: + /** Standard typedefs */ + typedef ImageDimensionalityReductionFilter Self; + typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Type macro */ + itkNewMacro(Self); + + /** Creation through object factory macro */ + itkTypeMacro(ImageDimensionalityReductionFilter, ImageToImageFilter); + + typedef TInputImage InputImageType; + typedef typename InputImageType::ConstPointer InputImageConstPointerType; + typedef typename InputImageType::InternalPixelType ValueType; + + typedef TMaskImage MaskImageType; + typedef typename MaskImageType::ConstPointer MaskImageConstPointerType; + typedef typename MaskImageType::Pointer MaskImagePointerType; + + typedef TOutputImage OutputImageType; + typedef typename OutputImageType::Pointer OutputImagePointerType; + typedef typename OutputImageType::RegionType OutputImageRegionType; + typedef typename OutputImageType::InternalPixelType LabelType; + + typedef DimensionalityReductionModel<ValueType, LabelType> ModelType; + typedef typename ModelType::Pointer ModelPointerType; + + typedef otb::Image<double> ConfidenceImageType; + typedef typename ConfidenceImageType::Pointer ConfidenceImagePointerType; + + /** Set/Get the model */ + itkSetObjectMacro(Model, ModelType); + itkGetObjectMacro(Model, ModelType); + + /** Set/Get the default label */ + itkSetMacro(DefaultLabel, LabelType); + itkGetMacro(DefaultLabel, LabelType); + + /** Set/Get the confidence map flag */ + itkSetMacro(UseConfidenceMap, bool); + itkGetMacro(UseConfidenceMap, bool); + + itkSetMacro(BatchMode, bool); + itkGetMacro(BatchMode, bool); + itkBooleanMacro(BatchMode); + + /** + * If set, only pixels within the mask will be classified. + * All pixels with a value greater than 0 in the mask, will be classified. + * \param mask The input mask. + */ + void SetInputMask(const MaskImageType * mask); + + /** + * Get the input mask. + * \return The mask. + */ + const MaskImageType * GetInputMask(void); + + /** + * Get the output confidence map + */ + ConfidenceImageType * GetOutputConfidence(void); + +protected: + /** Constructor */ + ImageDimensionalityReductionFilter(); + /** Destructor */ + ~ImageDimensionalityReductionFilter() ITK_OVERRIDE {} + + /** Threaded generate data */ + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ClassicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId); + void BatchThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId); + /** Before threaded generate data */ + void BeforeThreadedGenerateData() ITK_OVERRIDE; + /**PrintSelf method */ + void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + +private: + ImageDimensionalityReductionFilter(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + + /** The model used for classification */ + ModelPointerType m_Model; + /** Default label for invalid pixels (when using a mask) */ + LabelType m_DefaultLabel; + /** Flag to produce the confidence map (if the model supports it) */ + bool m_UseConfidenceMap; + bool m_BatchMode; +}; +} // End namespace otb +#ifndef OTB_MANUAL_INSTANTIATION +#include "ImageDimensionalityReductionFilter.txx" +#endif + +#endif diff --git a/include/ImageDimensionalityReductionFilter.txx b/include/ImageDimensionalityReductionFilter.txx new file mode 100644 index 0000000000..73e2cce1ca --- /dev/null +++ b/include/ImageDimensionalityReductionFilter.txx @@ -0,0 +1,327 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#ifndef otbImageClassificationFilter_txx +#define otbImageClassificationFilter_txx + +#include "ImageDimensionalityReductionFilter.h" +#include "itkImageRegionIterator.h" +#include "itkProgressReporter.h" + +namespace otb +{ +/** + * Constructor + */ +template <class TInputImage, class TOutputImage, class TMaskImage> +ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> +::ImageDimensionalityReductionFilter() +{ + this->SetNumberOfIndexedInputs(2); + this->SetNumberOfRequiredInputs(1); + LabelType empty_vect; + empty_vect.SetSize(1); + m_DefaultLabel = itk::NumericTraits<LabelType>::ZeroValue(empty_vect); + + this->SetNumberOfRequiredOutputs(2); + this->SetNthOutput(0,TOutputImage::New()); + this->SetNthOutput(1,ConfidenceImageType::New()); + m_UseConfidenceMap = false; + m_BatchMode = true; +} + +template <class TInputImage, class TOutputImage, class TMaskImage> +void +ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> +::SetInputMask(const MaskImageType * mask) +{ + this->itk::ProcessObject::SetNthInput(1, const_cast<MaskImageType *>(mask)); +} + +template <class TInputImage, class TOutputImage, class TMaskImage> +const typename ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> +::MaskImageType * +ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> +::GetInputMask() +{ + if (this->GetNumberOfInputs() < 2) + { + return ITK_NULLPTR; + } + return static_cast<const MaskImageType *>(this->itk::ProcessObject::GetInput(1)); +} + +template <class TInputImage, class TOutputImage, class TMaskImage> +typename ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> +::ConfidenceImageType * +ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> +::GetOutputConfidence() +{ + if (this->GetNumberOfOutputs() < 2) + { + return ITK_NULLPTR; + } + return static_cast<ConfidenceImageType *>(this->itk::ProcessObject::GetOutput(1)); +} + +template <class TInputImage, class TOutputImage, class TMaskImage> +void +ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> +::BeforeThreadedGenerateData() +{ + if (!m_Model) + { + itkGenericExceptionMacro(<< "No model for classification"); + } + if(m_BatchMode) + { + #ifdef _OPENMP + // OpenMP will take care of threading + this->SetNumberOfThreads(1); + #endif + } +} + +template <class TInputImage, class TOutputImage, class TMaskImage> +void +ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> +::ClassicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) +{ + // Get the input pointers + InputImageConstPointerType inputPtr = this->GetInput(); + MaskImageConstPointerType inputMaskPtr = this->GetInputMask(); + OutputImagePointerType outputPtr = this->GetOutput(); + ConfidenceImagePointerType confidencePtr = this->GetOutputConfidence(); + + // Progress reporting + itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); + + // Define iterators + typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType; + typedef itk::ImageRegionConstIterator<MaskImageType> MaskIteratorType; + typedef itk::ImageRegionIterator<InputImageType> OutputIteratorType; + typedef itk::ImageRegionIterator<ConfidenceImageType> ConfidenceMapIteratorType; + + InputIteratorType inIt(inputPtr, outputRegionForThread); + OutputIteratorType outIt(outputPtr, outputRegionForThread); + + // Eventually iterate on masks + MaskIteratorType maskIt; + if (inputMaskPtr) + { + maskIt = MaskIteratorType(inputMaskPtr, outputRegionForThread); + maskIt.GoToBegin(); + } + + // setup iterator for confidence map + bool computeConfidenceMap(m_UseConfidenceMap && m_Model->HasConfidenceIndex() && !m_Model->GetRegressionMode()); + ConfidenceMapIteratorType confidenceIt; + if (computeConfidenceMap) + { + confidenceIt = ConfidenceMapIteratorType(confidencePtr,outputRegionForThread); + confidenceIt.GoToBegin(); + } + + bool validPoint = true; + double confidenceIndex = 0.0; + + // Walk the part of the image + for (inIt.GoToBegin(), outIt.GoToBegin(); !inIt.IsAtEnd() && !outIt.IsAtEnd(); ++inIt, ++outIt) + { + // Check pixel validity + if (inputMaskPtr) + { + validPoint = maskIt.Get() > 0; + ++maskIt; + } + // If point is valid + if (validPoint) + { + // Classifify + if (computeConfidenceMap) + { + outIt.Set(m_Model->Predict(inIt.Get(),&confidenceIndex)[0]); + } + else + { + outIt.Set(m_Model->Predict(inIt.Get())[0]); + } + } + else + { + // else, set default value + outIt.Set(m_DefaultLabel); + confidenceIndex = 0.0; + } + if (computeConfidenceMap) + { + confidenceIt.Set(confidenceIndex); + ++confidenceIt; + } + progress.CompletedPixel(); + } + +} + +template <class TInputImage, class TOutputImage, class TMaskImage> +void +ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> +::BatchThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) +{ + bool computeConfidenceMap(m_UseConfidenceMap && m_Model->HasConfidenceIndex() + && !m_Model->GetRegressionMode()); + // Get the input pointers + InputImageConstPointerType inputPtr = this->GetInput(); + MaskImageConstPointerType inputMaskPtr = this->GetInputMask(); + OutputImagePointerType outputPtr = this->GetOutput(); + ConfidenceImagePointerType confidencePtr = this->GetOutputConfidence(); + + // Progress reporting + itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); + + // Define iterators + typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType; + typedef itk::ImageRegionConstIterator<MaskImageType> MaskIteratorType; + typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType; + typedef itk::ImageRegionIterator<ConfidenceImageType> ConfidenceMapIteratorType; + + InputIteratorType inIt(inputPtr, outputRegionForThread); + OutputIteratorType outIt(outputPtr, outputRegionForThread); + + MaskIteratorType maskIt; + if (inputMaskPtr) + { + maskIt = MaskIteratorType(inputMaskPtr, outputRegionForThread); + maskIt.GoToBegin(); + } + + // typedef typename ModelType::InputValueType InputValueType; + typedef typename ModelType::InputSampleType InputSampleType; + typedef typename ModelType::InputListSampleType InputListSampleType; + typedef typename ModelType::TargetValueType TargetValueType; + // typedef typename ModelType::TargetSampleType TargetSampleType; + typedef typename ModelType::TargetListSampleType TargetListSampleType; + // typedef typename ModelType::ConfidenceValueType ConfidenceValueType; + // typedef typename ModelType::ConfidenceSampleType ConfidenceSampleType; + typedef typename ModelType::ConfidenceListSampleType ConfidenceListSampleType; + + typename InputListSampleType::Pointer samples = InputListSampleType::New(); + unsigned int num_features = inputPtr->GetNumberOfComponentsPerPixel(); + samples->SetMeasurementVectorSize(num_features); + InputSampleType sample(num_features); + // Fill the samples + bool validPoint = true; + for (inIt.GoToBegin(); !inIt.IsAtEnd(); ++inIt) + { + // Check pixel validity + if (inputMaskPtr) + { + validPoint = maskIt.Get() > 0; + ++maskIt; + } + if(validPoint) + { + typename InputImageType::PixelType pix = inIt.Get(); + for(size_t feat=0; feat<num_features; ++feat) + { + sample[feat]=pix[feat]; + } + samples->PushBack(sample); + } + } + //Make the batch prediction + typename TargetListSampleType::Pointer labels; + typename ConfidenceListSampleType::Pointer confidences; + if(computeConfidenceMap) + confidences = ConfidenceListSampleType::New(); + + // This call is threadsafe + labels = m_Model->PredictBatch(samples,confidences); + + // Set the output values + ConfidenceMapIteratorType confidenceIt; + if (computeConfidenceMap) + { + confidenceIt = ConfidenceMapIteratorType(confidencePtr,outputRegionForThread); + confidenceIt.GoToBegin(); + } + + typename TargetListSampleType::ConstIterator labIt = labels->Begin(); + maskIt.GoToBegin(); + for (outIt.GoToBegin(); !outIt.IsAtEnd(); ++outIt) + { + double confidenceIndex = 0.0; + TargetValueType labelValue(m_DefaultLabel); + if (inputMaskPtr) + { + validPoint = maskIt.Get() > 0; + ++maskIt; + } + if (validPoint && labIt!=labels->End()) + { + labelValue = labIt.GetMeasurementVector()[0]; + + if(computeConfidenceMap) + { + confidenceIndex = confidences->GetMeasurementVector(labIt.GetInstanceIdentifier())[0]; + } + + ++labIt; + } + else + { + labelValue = m_DefaultLabel; + } + + outIt.Set(labelValue); + + if(computeConfidenceMap) + { + confidenceIt.Set(confidenceIndex); + ++confidenceIt; + } + + progress.CompletedPixel(); + } +} +template <class TInputImage, class TOutputImage, class TMaskImage> +void +ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> +::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) +{ + if(m_BatchMode) + { + this->BatchThreadedGenerateData(outputRegionForThread, threadId); + } + else + { + this->ClassicThreadedGenerateData(outputRegionForThread, threadId); + } + +} +/** + * PrintSelf Method + */ +template <class TInputImage, class TOutputImage, class TMaskImage> +void +ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} +} // End namespace otb +#endif diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 49145ae3f1..da6311c263 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -12,7 +12,7 @@ #include "itkVariableLengthVector.h" //Estimator -#include "otbMachineLearningModelFactory.h" +#include "DimensionalityReductionModelFactory.h" #ifdef OTB_USE_SHARK #include "AutoencoderModel.h" @@ -75,10 +75,10 @@ public: typedef typename SampleImageType::PixelType PixelType; // Machine Learning models - typedef otb::MachineLearningModelFactory< + typedef otb::DimensionalityReductionModelFactory< InputValueType, OutputValueType> ModelFactoryType; - typedef typename ModelFactoryType::MachineLearningModelTypePointer ModelPointerType; - typedef typename ModelFactoryType::MachineLearningModelType ModelType; + typedef typename ModelFactoryType::DimensionalityReductionModelTypePointer ModelPointerType; + typedef typename ModelFactoryType::DimensionalityReductionModelType ModelType; typedef typename ModelType::InputSampleType SampleType; typedef typename ModelType::InputListSampleType ListSampleType; -- GitLab From ab7142d8a8c06ce9aa2c1cdc5fef4b313f699520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Fri, 12 May 2017 14:19:26 +0200 Subject: [PATCH 020/567] app dim reduc working for autoencoders, using the dimensionalityReductionModel as a base class --- include/AutoencoderModel.h | 2 +- include/AutoencoderModel.txx | 13 ++- include/DimensionalityReductionModel.h | 5 +- include/ImageDimensionalityReductionFilter.h | 5 +- .../ImageDimensionalityReductionFilter.txx | 86 ++++++++----------- 5 files changed, 53 insertions(+), 58 deletions(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 2c59573449..7ebb95de6f 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -30,7 +30,7 @@ public: itkNewMacro(Self); itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); - + unsigned int GetDimension() {return m_NumberOfHiddenNeurons;}; itkGetMacro(NumberOfHiddenNeurons,unsigned int); itkSetMacro(NumberOfHiddenNeurons,unsigned int); diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 964af74226..8ae6e58b9d 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -143,22 +143,29 @@ template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType> ::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const { + std::vector<shark::RealVector> features; Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); shark::Data<shark::RealVector> data = shark::createDataFromRange(features); TargetSampleType target; data = m_net.encode(data); unsigned int id = startIndex; + target.SetSize(m_NumberOfHiddenNeurons); for(const auto& p : data.elements()){ for(unsigned int a = 0; a < m_NumberOfHiddenNeurons; ++a){ - //target[a]=p[a]; - target=p[a]; + target[a]=p[a]; + + //target.SetElement(a,p[a]); + + } - std::cout << p << std::endl; + //std::cout << p << std::endl; targets->SetMeasurementVector(id,target); ++id; + } + } diff --git a/include/DimensionalityReductionModel.h b/include/DimensionalityReductionModel.h index df67e2b3bf..ba9888b1fb 100644 --- a/include/DimensionalityReductionModel.h +++ b/include/DimensionalityReductionModel.h @@ -126,6 +126,9 @@ public: /** THIS METHOD IS DEPRECATED AND SHOULD NOT BE USED. */ void PredictAll(); + /** Get the size of the output after dimensionality reduction */ + virtual unsigned int GetDimension() = 0; + /**\name Classification model file manipulation */ //@{ /** Save the model to file */ @@ -203,8 +206,6 @@ protected: bool m_IsDoPredictBatchMultiThreaded; - /** Size of the output after dimensionality reduction */ - //unsigned int m_Size; diff --git a/include/ImageDimensionalityReductionFilter.h b/include/ImageDimensionalityReductionFilter.h index d6eb3deb3e..e550b1944d 100644 --- a/include/ImageDimensionalityReductionFilter.h +++ b/include/ImageDimensionalityReductionFilter.h @@ -112,7 +112,10 @@ protected: /** Destructor */ ~ImageDimensionalityReductionFilter() ITK_OVERRIDE {} - /** Threaded generate data */ + /** Generate output information */ + virtual void GenerateOutputInformation(); + + /** Threaded generate data */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; void ClassicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId); void BatchThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId); diff --git a/include/ImageDimensionalityReductionFilter.txx b/include/ImageDimensionalityReductionFilter.txx index 73e2cce1ca..9d6f8d7085 100644 --- a/include/ImageDimensionalityReductionFilter.txx +++ b/include/ImageDimensionalityReductionFilter.txx @@ -33,9 +33,8 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> { this->SetNumberOfIndexedInputs(2); this->SetNumberOfRequiredInputs(1); - LabelType empty_vect; - empty_vect.SetSize(1); - m_DefaultLabel = itk::NumericTraits<LabelType>::ZeroValue(empty_vect); + + //m_DefaultLabel = itk::NumericTraits<LabelType>::ZeroValue(); this->SetNumberOfRequiredOutputs(2); this->SetNthOutput(0,TOutputImage::New()); @@ -100,7 +99,7 @@ template <class TInputImage, class TOutputImage, class TMaskImage> void ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> ::ClassicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) -{ +{/* // Get the input pointers InputImageConstPointerType inputPtr = this->GetInput(); MaskImageConstPointerType inputMaskPtr = this->GetInputMask(); @@ -113,7 +112,7 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> // Define iterators typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType; typedef itk::ImageRegionConstIterator<MaskImageType> MaskIteratorType; - typedef itk::ImageRegionIterator<InputImageType> OutputIteratorType; + typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType; typedef itk::ImageRegionIterator<ConfidenceImageType> ConfidenceMapIteratorType; InputIteratorType inIt(inputPtr, outputRegionForThread); @@ -173,15 +172,25 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> ++confidenceIt; } progress.CompletedPixel(); - } + }*/ } +template <class TInputImage, class TOutputImage, class TMaskImage> +void ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage>::GenerateOutputInformation() +{ + Superclass::GenerateOutputInformation(); + this->GetOutput()->SetNumberOfComponentsPerPixel( m_Model->GetDimension() ); +} + + + template <class TInputImage, class TOutputImage, class TMaskImage> void ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> ::BatchThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) { + bool computeConfidenceMap(m_UseConfidenceMap && m_Model->HasConfidenceIndex() && !m_Model->GetRegressionMode()); // Get the input pointers @@ -189,7 +198,7 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> MaskImageConstPointerType inputMaskPtr = this->GetInputMask(); OutputImagePointerType outputPtr = this->GetOutput(); ConfidenceImagePointerType confidencePtr = this->GetOutputConfidence(); - + // Progress reporting itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); @@ -202,13 +211,6 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> InputIteratorType inIt(inputPtr, outputRegionForThread); OutputIteratorType outIt(outputPtr, outputRegionForThread); - MaskIteratorType maskIt; - if (inputMaskPtr) - { - maskIt = MaskIteratorType(inputMaskPtr, outputRegionForThread); - maskIt.GoToBegin(); - } - // typedef typename ModelType::InputValueType InputValueType; typedef typename ModelType::InputSampleType InputSampleType; typedef typename ModelType::InputListSampleType InputListSampleType; @@ -224,24 +226,17 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> samples->SetMeasurementVectorSize(num_features); InputSampleType sample(num_features); // Fill the samples - bool validPoint = true; + for (inIt.GoToBegin(); !inIt.IsAtEnd(); ++inIt) { - // Check pixel validity - if (inputMaskPtr) - { - validPoint = maskIt.Get() > 0; - ++maskIt; - } - if(validPoint) - { - typename InputImageType::PixelType pix = inIt.Get(); - for(size_t feat=0; feat<num_features; ++feat) + + typename InputImageType::PixelType pix = inIt.Get(); + for(size_t feat=0; feat<num_features; ++feat) { sample[feat]=pix[feat]; } samples->PushBack(sample); - } + } //Make the batch prediction typename TargetListSampleType::Pointer labels; @@ -250,8 +245,8 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> confidences = ConfidenceListSampleType::New(); // This call is threadsafe - labels = m_Model->PredictBatch(samples,confidences); - + //labels = m_Model->PredictBatch(samples,confidences); + labels = m_Model->PredictBatch(samples); // Set the output values ConfidenceMapIteratorType confidenceIt; if (computeConfidenceMap) @@ -259,36 +254,25 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> confidenceIt = ConfidenceMapIteratorType(confidencePtr,outputRegionForThread); confidenceIt.GoToBegin(); } - + typename TargetListSampleType::ConstIterator labIt = labels->Begin(); - maskIt.GoToBegin(); + for (outIt.GoToBegin(); !outIt.IsAtEnd(); ++outIt) { double confidenceIndex = 0.0; - TargetValueType labelValue(m_DefaultLabel); - if (inputMaskPtr) - { - validPoint = maskIt.Get() > 0; - ++maskIt; - } - if (validPoint && labIt!=labels->End()) - { - labelValue = labIt.GetMeasurementVector()[0]; + + itk::VariableLengthVector<TargetValueType> labelValue; + + labelValue = labIt.GetMeasurementVector(); - if(computeConfidenceMap) - { - confidenceIndex = confidences->GetMeasurementVector(labIt.GetInstanceIdentifier())[0]; - } + if(computeConfidenceMap) + { + confidenceIndex = confidences->GetMeasurementVector(labIt.GetInstanceIdentifier())[0]; + } - ++labIt; - } - else - { - labelValue = m_DefaultLabel; - } - + ++labIt; + outIt.Set(labelValue); - if(computeConfidenceMap) { confidenceIt.Set(confidenceIndex); -- GitLab From ae3191a243821275b1615146e51bd8b7e10e9ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Fri, 12 May 2017 16:10:47 +0200 Subject: [PATCH 021/567] pca added (work in progress) --- include/PCAModel.h | 69 +++++++++++++++++++ include/PCAModel.txx | 155 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 224 insertions(+) create mode 100644 include/PCAModel.h create mode 100644 include/PCAModel.txx diff --git a/include/PCAModel.h b/include/PCAModel.h new file mode 100644 index 0000000000..e7cdafa21b --- /dev/null +++ b/include/PCAModel.h @@ -0,0 +1,69 @@ +#ifndef PCAModel_h +#define PCAModel_h + +#include "DimensionalityReductionModel.h" +#include <shark/Algorithms/Trainers/PCA.h> + +namespace otb +{ +template <class TInputValue> +class ITK_EXPORT PCAModel: public DimensionalityReductionModel<TInputValue,TInputValue> +{ + +public: + + typedef PCAModel Self; + typedef DimensionalityReductionModel<TInputValue,TInputValue> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef typename Superclass::InputValueType InputValueType; + typedef typename Superclass::InputSampleType InputSampleType; + typedef typename Superclass::InputListSampleType InputListSampleType; + typedef typename Superclass::TargetValueType TargetValueType; + typedef typename Superclass::TargetSampleType TargetSampleType; + typedef typename Superclass::TargetListSampleType TargetListSampleType; + typedef typename Superclass::ConfidenceValueType ConfidenceValueType; + typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; + typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; + + itkNewMacro(Self); + itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); + + unsigned int GetDimension() {return m_Dimension;}; + itkGetMacro(Dimension,unsigned int); + + bool CanReadFile(const std::string & filename); + bool CanWriteFile(const std::string & filename); + + void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + + void Train() ITK_OVERRIDE; + //void Dimensionality_reduction() {}; // Dimensionality reduction is done by DoPredict + + +protected: + PCAModel(); + ~PCAModel() ITK_OVERRIDE; + + virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const ITK_OVERRIDE; + +private: + LinearModel<> m_encoder + LinearModel<> m_decoder + PCA m_pca; + unsigned int m_Dimension; + +}; +} // end namespace otb + + +#ifndef OTB_MANUAL_INSTANTIATION +#include "PCAModel.txx" +#endif + + +#endif + diff --git a/include/PCAModel.txx b/include/PCAModel.txx new file mode 100644 index 0000000000..f0c2c010f9 --- /dev/null +++ b/include/PCAModel.txx @@ -0,0 +1,155 @@ + +#ifndef AutoencoderModel_txx +#define AutoencoderModel_txx + +#include <fstream> +#include <shark/Data/Dataset.h> +#include "itkMacro.h" +#include "otbSharkUtils.h" +//include train function +#include <shark/ObjectiveFunctions/ErrorFunction.h> +#include <shark/Algorithms/GradientDescent/Rprop.h>// the RProp optimization algorithm +#include <shark/ObjectiveFunctions/Loss/SquaredLoss.h> // squared loss used for regression +#include <shark/ObjectiveFunctions/Regularizer.h> //L2 regulariziation + +namespace otb +{ + + +template <class TInputValue> +PCAModel<TInputValue>::PCAModel() +{ + this->m_IsRegressionSupported = true; +} + + +template <class TInputValue> +PCAModel<TInputValue,AutoencoderType>::~PCAModel() +{ +} + + +template <class TInputValue> +void PCAModel<TInputValue>::Train() +{ + + std::vector<shark::RealVector> features; + + Shark::ListSampleToSharkVector(this->GetInputListSample(), features); + + shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); + + m_pca(inputSamples); + pca.encoder(m_encoder, m_Dimension); + pca.decoder(m_decoder, m_Dimension); + +} + + +template <class TInputValue> +bool PCAModel<TInputValue>::CanReadFile(const std::string & filename) +{ + try + { + this->Load(filename); + m_net.name(); + } + catch(...) + { + return false; + } + return true; +} + + +template <class TInputValue> +bool PCAModel<TInputValue>::CanWriteFile(const std::string & filename) +{ + return true; +} + +template <class TInputValue> +void PCAModel<TInputValue>::Save(const std::string & filename, const std::string & name) +{ + std::ofstream ofs(filename); + ofs << m_net.name() << std::endl; //first line + boost::archive::polymorphic_text_oarchive oa(ofs); + m_net.write(oa); + ofs.close(); +} + +template <class TInputValue> +void PCAModel<TInputValue>::Load(const std::string & filename, const std::string & name) +{ + std::ifstream ifs(filename); + char autoencoder[256]; + ifs.getline(autoencoder,256); + std::string autoencoderstr(autoencoder); + + if (autoencoderstr != m_net.name()){ + itkExceptionMacro(<< "Error opening " << filename.c_str() ); + } + boost::archive::polymorphic_text_iarchive ia(ifs); + m_net.read(ia); + ifs.close(); + m_NumberOfHiddenNeurons = m_net.numberOfHiddenNeurons(); + //this->m_Size = m_NumberOfHiddenNeurons; +} + + +template <class TInputValue> +typename PCAModel<TInputValue>::TargetSampleType +PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueType *quality) const +{ + shark::RealVector samples(value.Size()); + for(size_t i = 0; i < value.Size();i++) + { + samples.push_back(value[i]); + } + shark::Data<shark::RealVector> data; + data.element(0)=samples; + data = m_net.encode(data); + + TargetSampleType target; + + //target.SetSize(m_NumberOfHiddenNeurons); + for(unsigned int a = 0; a < m_NumberOfHiddenNeurons; ++a){ + //target[a]=data.element(0)[a]; + target=data.element(0)[a]; + } + return target; +} + + +template <class TInputValue> +void PCAModel<TInputValue> +::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const +{ + + std::vector<shark::RealVector> features; + Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); + shark::Data<shark::RealVector> data = shark::createDataFromRange(features); + TargetSampleType target; + data = m_net.encode(data); + unsigned int id = startIndex; + target.SetSize(m_NumberOfHiddenNeurons); + for(const auto& p : data.elements()){ + + for(unsigned int a = 0; a < m_NumberOfHiddenNeurons; ++a){ + target[a]=p[a]; + + //target.SetElement(a,p[a]); + + + } + //std::cout << p << std::endl; + targets->SetMeasurementVector(id,target); + ++id; + + } + +} + + +} // namespace otb +#endif -- GitLab From f624445fff9614063501548e275dbc4be16ee7db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Fri, 12 May 2017 17:16:45 +0200 Subject: [PATCH 022/567] pca factory done --- app/cbDimensionalityReduction.cxx | 2 + .../DimensionalityReductionModelFactory.txx | 10 +++ include/PCAModel.h | 8 +-- include/PCAModel.txx | 28 ++++---- include/PCAModelFactory.h | 59 +++++++++++++++++ include/PCAModelFactory.txx | 65 +++++++++++++++++++ include/cbLearningApplicationBaseDR.h | 1 + 7 files changed, 157 insertions(+), 16 deletions(-) create mode 100644 include/PCAModelFactory.h create mode 100644 include/PCAModelFactory.txx diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index c689f71108..abe3875264 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -28,6 +28,8 @@ #include "otbImageToVectorImageCastFilter.h" #include "DimensionalityReductionModelFactory.h" +#include "PCAModel.h" + namespace otb { namespace Functor diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 4cd8751994..5106424403 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -24,6 +24,7 @@ #ifdef OTB_USE_SHARK #include "AutoencoderModelFactory.h" +#include "PCAModelFactory.h" #endif #include "itkMutexLockHolder.h" @@ -87,6 +88,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> #ifdef OTB_USE_SHARK + RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(AutoencoderModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); #endif @@ -137,6 +139,14 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> itk::ObjectFactoryBase::UnRegisterFactory(taeFactory); continue; } + + PCAModelFactory<TInputValue,TOutputValue> *pcaFactory = + dynamic_cast<PCAModelFactory<TInputValue,TOutputValue> *>(*itFac); + if (pcaFactory) + { + itk::ObjectFactoryBase::UnRegisterFactory(pcaFactory); + continue; + } #endif } diff --git a/include/PCAModel.h b/include/PCAModel.h index e7cdafa21b..529d2fa9bb 100644 --- a/include/PCAModel.h +++ b/include/PCAModel.h @@ -31,7 +31,7 @@ public: itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); unsigned int GetDimension() {return m_Dimension;}; - itkGetMacro(Dimension,unsigned int); + //itkGetMacro(Dimension,unsigned int); bool CanReadFile(const std::string & filename); bool CanWriteFile(const std::string & filename); @@ -51,9 +51,9 @@ protected: virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const ITK_OVERRIDE; private: - LinearModel<> m_encoder - LinearModel<> m_decoder - PCA m_pca; + shark::LinearModel<> m_encoder; + shark::LinearModel<> m_decoder; + shark::PCA m_pca; unsigned int m_Dimension; }; diff --git a/include/PCAModel.txx b/include/PCAModel.txx index f0c2c010f9..329b2558cf 100644 --- a/include/PCAModel.txx +++ b/include/PCAModel.txx @@ -52,7 +52,7 @@ bool PCAModel<TInputValue>::CanReadFile(const std::string & filename) try { this->Load(filename); - m_net.name(); + m_encoder.name(); } catch(...) { @@ -72,9 +72,9 @@ template <class TInputValue> void PCAModel<TInputValue>::Save(const std::string & filename, const std::string & name) { std::ofstream ofs(filename); - ofs << m_net.name() << std::endl; //first line + ofs << m_encoder.name() << std::endl; //first line boost::archive::polymorphic_text_oarchive oa(ofs); - m_net.write(oa); + m_encoder.write(oa); ofs.close(); } @@ -82,17 +82,17 @@ template <class TInputValue> void PCAModel<TInputValue>::Load(const std::string & filename, const std::string & name) { std::ifstream ifs(filename); - char autoencoder[256]; - ifs.getline(autoencoder,256); - std::string autoencoderstr(autoencoder); + char encoder[256]; + ifs.getline(encoder,256); + std::string encoderstr(encoder); - if (autoencoderstr != m_net.name()){ + if (autoencoderstr != m_encoder.name()){ itkExceptionMacro(<< "Error opening " << filename.c_str() ); } boost::archive::polymorphic_text_iarchive ia(ifs); m_net.read(ia); ifs.close(); - m_NumberOfHiddenNeurons = m_net.numberOfHiddenNeurons(); + m_Dimension = m_encoder.outputSize(); //this->m_Size = m_NumberOfHiddenNeurons; } @@ -108,14 +108,18 @@ PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueT } shark::Data<shark::RealVector> data; data.element(0)=samples; - data = m_net.encode(data); + data = m_encoder(data); TargetSampleType target; //target.SetSize(m_NumberOfHiddenNeurons); + for(unsigned int a = 0; a < m_NumberOfHiddenNeurons; ++a){ - //target[a]=data.element(0)[a]; - target=data.element(0)[a]; + target[a]=p[a]; + + //target.SetElement(a,p[a]); + + } return target; } @@ -130,7 +134,7 @@ void PCAModel<TInputValue> Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); shark::Data<shark::RealVector> data = shark::createDataFromRange(features); TargetSampleType target; - data = m_net.encode(data); + data = m_encoder(data); unsigned int id = startIndex; target.SetSize(m_NumberOfHiddenNeurons); for(const auto& p : data.elements()){ diff --git a/include/PCAModelFactory.h b/include/PCAModelFactory.h new file mode 100644 index 0000000000..56c0b88c6c --- /dev/null +++ b/include/PCAModelFactory.h @@ -0,0 +1,59 @@ +#ifndef PCAModelFactory_h +#define PCAModelFactory_h + + +#include "itkObjectFactoryBase.h" +#include "itkImageIOBase.h" + +namespace otb +{ + +template <class TInputValue, class TTargetValue> +class ITK_EXPORT PCAModelFactory : public itk::ObjectFactoryBase +{ +public: + /** Standard class typedefs. */ + typedef PCAModelFactory Self; + typedef itk::ObjectFactoryBase Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Class methods used to interface with the registered factories. */ + const char* GetITKSourceVersion(void) const ITK_OVERRIDE; + const char* GetDescription(void) const ITK_OVERRIDE; + + /** Method for class instantiation. */ + itkFactorylessNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(PCAModelFactory, itk::ObjectFactoryBase); + + /** Register one factory of this type */ + static void RegisterOneFactory(void) + { + Pointer PCAFactory = PCAModelFactory::New(); + itk::ObjectFactoryBase::RegisterFactory(PCAFactory); + } + +protected: + PCAModelFactory(); + ~PCAModelFactory() ITK_OVERRIDE; + +private: + PCAModelFactory(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + +}; + + + +} //namespace otb + + +#ifndef OTB_MANUAL_INSTANTIATION +#include "PCAModelFactory.txx" +#endif + +#endif + + diff --git a/include/PCAModelFactory.txx b/include/PCAModelFactory.txx new file mode 100644 index 0000000000..2a0ff98b44 --- /dev/null +++ b/include/PCAModelFactory.txx @@ -0,0 +1,65 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#ifndef AutoencoderModelFactory_txx +#define AutoencoderModelFactory_txx + + +#include "AutoencoderModelFactory.h" + +#include "itkCreateObjectFunction.h" +#include "AutoencoderModel.h" +#include <shark/Algorithms/Trainers/PCA.h> +#include "itkVersion.h" + +namespace otb +{ +template <class TInputValue, class TOutputValue> +PCAModelFactory<TInputValue,TOutputValue>::PCAModelFactory() +{ + + std::string classOverride = std::string("DimensionalityReductionModel"); + std::string subclass = std::string("PCAModel"); + + this->RegisterOverride(classOverride.c_str(), + subclass.c_str(), + "Shark PCA ML Model", + 1, + // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); + itk::CreateObjectFunction<PCAModel<TInputValue,shark::LinearModel<> > >::New()); +} + +template <class TInputValue, class TOutputValue> +PCAModelFactory<TInputValue,TOutputValue>::~PCAModelFactory() +{ +} + +template <class TInputValue, class TOutputValue> +const char* PCAModelFactory<TInputValue,TOutputValue>::GetITKSourceVersion(void) const +{ + return ITK_SOURCE_VERSION; +} + +template <class TInputValue, class TOutputValue> +const char* PCAModelFactory<TInputValue,TOutputValue>::GetDescription() const +{ + return "PCA model factory"; +} + +} // end namespace otb + +#endif diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index da6311c263..abd8cfc55f 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -16,6 +16,7 @@ #ifdef OTB_USE_SHARK #include "AutoencoderModel.h" +#include "PCAModel.h" #endif namespace otb -- GitLab From 600d61b94335de6b580c7791eb143887da1915fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 16 May 2017 08:59:01 +0200 Subject: [PATCH 023/567] Shark pca and autoencoders DoPredict's method (ie without using batches) is now working, it shouldn't be used thought, as using batches is more efficient with Shark --- app/cbDimensionalityReduction.cxx | 1 - include/AutoencoderModel.txx | 20 ++++--- .../ImageDimensionalityReductionFilter.txx | 59 ++----------------- include/PCAModel.h | 2 +- include/PCAModel.txx | 49 +++++++-------- include/PCAModelFactory.txx | 12 ++-- include/cbLearningApplicationBaseDR.h | 5 ++ include/cbLearningApplicationBaseDR.txx | 10 ++++ include/cbTrainPCA.txx | 50 ++++++++++++++++ otb-module.cmake | 1 + 10 files changed, 115 insertions(+), 94 deletions(-) create mode 100644 include/cbTrainPCA.txx diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index abe3875264..5a019b3989 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -28,7 +28,6 @@ #include "otbImageToVectorImageCastFilter.h" #include "DimensionalityReductionModelFactory.h" -#include "PCAModel.h" namespace otb { diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 8ae6e58b9d..b0e206532f 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -122,18 +122,20 @@ AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) { - samples.push_back(value[i]); + samples[i]=value[i]; } - shark::Data<shark::RealVector> data; - data.element(0)=samples; - data = m_net.encode(data); + std::vector<shark::RealVector> features; + features.push_back(samples); + + shark::Data<shark::RealVector> data = shark::createDataFromRange(features); + + data = m_net.encode(data); TargetSampleType target; - - //target.SetSize(m_NumberOfHiddenNeurons); + target.SetSize(m_NumberOfHiddenNeurons); + for(unsigned int a = 0; a < m_NumberOfHiddenNeurons; ++a){ - //target[a]=data.element(0)[a]; - target=data.element(0)[a]; + target[a]=data.element(0)[a]; } return target; } @@ -143,7 +145,7 @@ template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType> ::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const { - + std::cout << "BATCH" << std::endl; std::vector<shark::RealVector> features; Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); shark::Data<shark::RealVector> data = shark::createDataFromRange(features); diff --git a/include/ImageDimensionalityReductionFilter.txx b/include/ImageDimensionalityReductionFilter.txx index 9d6f8d7085..9f5b34cab2 100644 --- a/include/ImageDimensionalityReductionFilter.txx +++ b/include/ImageDimensionalityReductionFilter.txx @@ -40,7 +40,7 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> this->SetNthOutput(0,TOutputImage::New()); this->SetNthOutput(1,ConfidenceImageType::New()); m_UseConfidenceMap = false; - m_BatchMode = true; + m_BatchMode = false; } template <class TInputImage, class TOutputImage, class TMaskImage> @@ -99,7 +99,7 @@ template <class TInputImage, class TOutputImage, class TMaskImage> void ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> ::ClassicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) -{/* +{ // Get the input pointers InputImageConstPointerType inputPtr = this->GetInput(); MaskImageConstPointerType inputMaskPtr = this->GetInputMask(); @@ -118,61 +118,14 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> InputIteratorType inIt(inputPtr, outputRegionForThread); OutputIteratorType outIt(outputPtr, outputRegionForThread); - // Eventually iterate on masks - MaskIteratorType maskIt; - if (inputMaskPtr) - { - maskIt = MaskIteratorType(inputMaskPtr, outputRegionForThread); - maskIt.GoToBegin(); - } - - // setup iterator for confidence map - bool computeConfidenceMap(m_UseConfidenceMap && m_Model->HasConfidenceIndex() && !m_Model->GetRegressionMode()); - ConfidenceMapIteratorType confidenceIt; - if (computeConfidenceMap) - { - confidenceIt = ConfidenceMapIteratorType(confidencePtr,outputRegionForThread); - confidenceIt.GoToBegin(); - } - - bool validPoint = true; - double confidenceIndex = 0.0; - // Walk the part of the image for (inIt.GoToBegin(), outIt.GoToBegin(); !inIt.IsAtEnd() && !outIt.IsAtEnd(); ++inIt, ++outIt) { - // Check pixel validity - if (inputMaskPtr) - { - validPoint = maskIt.Get() > 0; - ++maskIt; - } - // If point is valid - if (validPoint) - { - // Classifify - if (computeConfidenceMap) - { - outIt.Set(m_Model->Predict(inIt.Get(),&confidenceIndex)[0]); - } - else - { - outIt.Set(m_Model->Predict(inIt.Get())[0]); - } - } - else - { - // else, set default value - outIt.Set(m_DefaultLabel); - confidenceIndex = 0.0; - } - if (computeConfidenceMap) - { - confidenceIt.Set(confidenceIndex); - ++confidenceIt; - } + // Classifify + + outIt.Set(m_Model->Predict(inIt.Get())); progress.CompletedPixel(); - }*/ + } } diff --git a/include/PCAModel.h b/include/PCAModel.h index 529d2fa9bb..96d0e235c0 100644 --- a/include/PCAModel.h +++ b/include/PCAModel.h @@ -31,7 +31,7 @@ public: itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); unsigned int GetDimension() {return m_Dimension;}; - //itkGetMacro(Dimension,unsigned int); + itkSetMacro(Dimension,unsigned int); bool CanReadFile(const std::string & filename); bool CanWriteFile(const std::string & filename); diff --git a/include/PCAModel.txx b/include/PCAModel.txx index 329b2558cf..c7625e661e 100644 --- a/include/PCAModel.txx +++ b/include/PCAModel.txx @@ -1,6 +1,6 @@ -#ifndef AutoencoderModel_txx -#define AutoencoderModel_txx +#ifndef PCAModel_txx +#define PCAModel_txx #include <fstream> #include <shark/Data/Dataset.h> @@ -24,7 +24,7 @@ PCAModel<TInputValue>::PCAModel() template <class TInputValue> -PCAModel<TInputValue,AutoencoderType>::~PCAModel() +PCAModel<TInputValue>::~PCAModel() { } @@ -38,10 +38,10 @@ void PCAModel<TInputValue>::Train() Shark::ListSampleToSharkVector(this->GetInputListSample(), features); shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - - m_pca(inputSamples); - pca.encoder(m_encoder, m_Dimension); - pca.decoder(m_decoder, m_Dimension); + //m_pca.train(m_encoder,inputSamples); + m_pca.setData(inputSamples); + m_pca.encoder(m_encoder, m_Dimension); + m_pca.decoder(m_decoder, m_Dimension); } @@ -72,7 +72,8 @@ template <class TInputValue> void PCAModel<TInputValue>::Save(const std::string & filename, const std::string & name) { std::ofstream ofs(filename); - ofs << m_encoder.name() << std::endl; //first line + //ofs << m_encoder.name() << std::endl; //first line + ofs << "pca" << std::endl; //first line boost::archive::polymorphic_text_oarchive oa(ofs); m_encoder.write(oa); ofs.close(); @@ -86,11 +87,12 @@ void PCAModel<TInputValue>::Load(const std::string & filename, const std::string ifs.getline(encoder,256); std::string encoderstr(encoder); - if (autoencoderstr != m_encoder.name()){ + //if (encoderstr != m_encoder.name()){ + if (encoderstr != "pca"){ itkExceptionMacro(<< "Error opening " << filename.c_str() ); } boost::archive::polymorphic_text_iarchive ia(ifs); - m_net.read(ia); + m_encoder.read(ia); ifs.close(); m_Dimension = m_encoder.outputSize(); //this->m_Size = m_NumberOfHiddenNeurons; @@ -104,22 +106,20 @@ PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueT shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) { - samples.push_back(value[i]); + samples[i]=value[i]; } - shark::Data<shark::RealVector> data; - data.element(0)=samples; - data = m_encoder(data); + std::vector<shark::RealVector> features; + features.push_back(samples); + + shark::Data<shark::RealVector> data = shark::createDataFromRange(features); + + data = m_encoder(data); TargetSampleType target; - - //target.SetSize(m_NumberOfHiddenNeurons); + target.SetSize(m_Dimension); - for(unsigned int a = 0; a < m_NumberOfHiddenNeurons; ++a){ - target[a]=p[a]; - - //target.SetElement(a,p[a]); - - + for(unsigned int a = 0; a < m_Dimension; ++a){ + target[a]=data.element(0)[a]; } return target; } @@ -136,11 +136,12 @@ void PCAModel<TInputValue> TargetSampleType target; data = m_encoder(data); unsigned int id = startIndex; - target.SetSize(m_NumberOfHiddenNeurons); + target.SetSize(m_Dimension); for(const auto& p : data.elements()){ - for(unsigned int a = 0; a < m_NumberOfHiddenNeurons; ++a){ + for(unsigned int a = 0; a < m_Dimension; ++a){ target[a]=p[a]; + //target[a]=1; //target.SetElement(a,p[a]); diff --git a/include/PCAModelFactory.txx b/include/PCAModelFactory.txx index 2a0ff98b44..bfaa4f6f62 100644 --- a/include/PCAModelFactory.txx +++ b/include/PCAModelFactory.txx @@ -15,15 +15,15 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef AutoencoderModelFactory_txx -#define AutoencoderModelFactory_txx +#ifndef PCAFactory_txx +#define PCAFactory_txx -#include "AutoencoderModelFactory.h" +#include "PCAModelFactory.h" #include "itkCreateObjectFunction.h" -#include "AutoencoderModel.h" -#include <shark/Algorithms/Trainers/PCA.h> +#include "PCAModel.h" +//#include <shark/Algorithms/Trainers/PCA.h> #include "itkVersion.h" namespace otb @@ -40,7 +40,7 @@ PCAModelFactory<TInputValue,TOutputValue>::PCAModelFactory() "Shark PCA ML Model", 1, // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); - itk::CreateObjectFunction<PCAModel<TInputValue,shark::LinearModel<> > >::New()); + itk::CreateObjectFunction<PCAModel<TInputValue>>::New()); } template <class TInputValue, class TOutputValue> diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index abd8cfc55f..7a467e242e 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -91,6 +91,8 @@ public: typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType; + + typedef otb::PCAModel<InputValueType> PCAModelType; #endif protected: @@ -117,8 +119,10 @@ private: #ifdef OTB_USE_SHARK void InitAutoencoderParams(); + void InitPCAParams(); template <class autoencoderchoice> void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); #endif //@} }; @@ -130,6 +134,7 @@ private: #include "cbLearningApplicationBaseDR.txx" #ifdef OTB_USE_SHARK #include "cbTrainAutoencoder.txx" +#include "cbTrainPCA.txx" #endif #endif diff --git a/include/cbLearningApplicationBaseDR.txx b/include/cbLearningApplicationBaseDR.txx index 344b6eccfc..562b5e395b 100644 --- a/include/cbLearningApplicationBaseDR.txx +++ b/include/cbLearningApplicationBaseDR.txx @@ -51,6 +51,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> #ifdef OTB_USE_SHARK InitAutoencoderParams(); + InitPCAParams(); #endif } @@ -114,6 +115,15 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); #endif } + + if(modelName == "pca") + { + #ifdef OTB_USE_SHARK + TrainPCA(trainingListSample,modelPath); + #else + otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); + #endif + } } } diff --git a/include/cbTrainPCA.txx b/include/cbTrainPCA.txx new file mode 100644 index 0000000000..9c02c566cd --- /dev/null +++ b/include/cbTrainPCA.txx @@ -0,0 +1,50 @@ + +#ifndef cbTrainPCA_txx +#define cbTrainPCA_txx + +#include "cbLearningApplicationBaseDR.h" + +namespace otb +{ +namespace Wrapper +{ + +template <class TInputValue, class TOutputValue> +void +cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::InitPCAParams() +{ + + + AddChoice("model.pca", "Shark PCA"); + SetParameterDescription("model.pca", + "This group of parameters allows setting Shark PCA parameters. " + ); + + + //Output Dimension + AddParameter(ParameterType_Int, "model.pca.dim", + "Dimension of the output of the pca transformation"); + SetParameterInt("model.pca.dim",10, false); + SetParameterDescription( + "model.pca.dim", + "Dimension of the output of the pca transformation."); + + +} + +template <class TInputValue, class TOutputValue> +void cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::TrainPCA(typename ListSampleType::Pointer trainingListSample,std::string modelPath) +{ + typename PCAModelType::Pointer dimredTrainer = PCAModelType::New(); + dimredTrainer->SetDimension(GetParameterInt("model.pca.dim")); + dimredTrainer->SetInputListSample(trainingListSample); + dimredTrainer->Train(); + dimredTrainer->Save(modelPath); +} + +} //end namespace wrapper +} //end namespace otb + +#endif diff --git a/otb-module.cmake b/otb-module.cmake index 8b1eb2c05c..f4a7c8f8ca 100644 --- a/otb-module.cmake +++ b/otb-module.cmake @@ -8,6 +8,7 @@ otb_module(CbDimensionalityReduction OTBBoost OTBSupervised OTBAppClassification + OTBSOM DESCRIPTION "${DOCUMENTATION}" ) -- GitLab From ef393f138ac7ec3d7b84bde2a1f4a5ec2950ba18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 16 May 2017 15:33:53 +0200 Subject: [PATCH 024/567] Training app for SOM working, empty som factory header created --- app/cbDimensionalityReduction.cxx | 2 - include/AutoencoderModelFactory.h | 8 +- include/DimensionalityReductionModelFactory.h | 1 + .../DimensionalityReductionModelFactory.txx | 16 +++ include/PCAModel.h | 2 +- include/PCAModel.txx | 1 - include/SOMModel.h | 132 ++++++++++++++++++ include/SOMModel.txx | 101 ++++++++++++++ include/SOMModelFactory.h | 59 ++++++++ include/SOMModelFactory.txx | 65 +++++++++ include/cbLearningApplicationBaseDR.h | 11 +- include/cbLearningApplicationBaseDR.txx | 8 +- include/cbTrainSOM.txx | 95 +++++++++++++ 13 files changed, 490 insertions(+), 11 deletions(-) create mode 100644 include/SOMModel.h create mode 100644 include/SOMModel.txx create mode 100644 include/SOMModelFactory.h create mode 100644 include/SOMModelFactory.txx create mode 100644 include/cbTrainSOM.txx diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index 5a019b3989..7b1063147b 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -28,7 +28,6 @@ #include "otbImageToVectorImageCastFilter.h" #include "DimensionalityReductionModelFactory.h" - namespace otb { namespace Functor @@ -273,7 +272,6 @@ private: ModelPointerType m_Model; RescalerType::Pointer m_Rescaler; OutputRescalerType::Pointer m_OutRescaler; - }; diff --git a/include/AutoencoderModelFactory.h b/include/AutoencoderModelFactory.h index 0b8f538272..73d841e9a8 100644 --- a/include/AutoencoderModelFactory.h +++ b/include/AutoencoderModelFactory.h @@ -49,14 +49,14 @@ private: - +/* template <class TInputValue, class TTargetValue> -class ITK_EXPORT AutoencoderModelFactory : public AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron>> {}; +using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; template <class TInputValue, class TTargetValue> -class ITK_EXPORT TiedAutoencoderModelFactory : public AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> {}; - +using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; +*/ } //namespace otb diff --git a/include/DimensionalityReductionModelFactory.h b/include/DimensionalityReductionModelFactory.h index eebade611d..e7a913cc07 100644 --- a/include/DimensionalityReductionModelFactory.h +++ b/include/DimensionalityReductionModelFactory.h @@ -50,6 +50,7 @@ public: /** Mode in which the files is intended to be used */ typedef enum { ReadMode, WriteMode } FileModeType; + /** Create the appropriate MachineLearningModel depending on the particulars of the file. */ static DimensionalityReductionModelTypePointer CreateDimensionalityReductionModel(const std::string& path, FileModeType mode); diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 5106424403..0c05937d39 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -32,6 +32,15 @@ namespace otb { + +template <class TInputValue, class TTargetValue> +using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; + + +template <class TInputValue, class TTargetValue> +using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; + + template <class TInputValue, class TOutputValue> typename DimensionalityReductionModel<TInputValue,TOutputValue>::Pointer DimensionalityReductionModelFactory<TInputValue,TOutputValue> @@ -88,6 +97,13 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> #ifdef OTB_USE_SHARK + + + // using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron>> {}; + + + //using TiedAutoencoderModelFactory = public AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> {}; + RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(AutoencoderModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); diff --git a/include/PCAModel.h b/include/PCAModel.h index 96d0e235c0..4ea1370a9f 100644 --- a/include/PCAModel.h +++ b/include/PCAModel.h @@ -28,7 +28,7 @@ public: typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; itkNewMacro(Self); - itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); + itkTypeMacro(PCAModel, DimensionalityReductionModel); unsigned int GetDimension() {return m_Dimension;}; itkSetMacro(Dimension,unsigned int); diff --git a/include/PCAModel.txx b/include/PCAModel.txx index c7625e661e..92fdc3ee4c 100644 --- a/include/PCAModel.txx +++ b/include/PCAModel.txx @@ -38,7 +38,6 @@ void PCAModel<TInputValue>::Train() Shark::ListSampleToSharkVector(this->GetInputListSample(), features); shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - //m_pca.train(m_encoder,inputSamples); m_pca.setData(inputSamples); m_pca.encoder(m_encoder, m_Dimension); m_pca.decoder(m_decoder, m_Dimension); diff --git a/include/SOMModel.h b/include/SOMModel.h new file mode 100644 index 0000000000..1a469e4436 --- /dev/null +++ b/include/SOMModel.h @@ -0,0 +1,132 @@ +#ifndef SOMModel_h +#define SOMModel_h + +#include "DimensionalityReductionModel.h" +#include "otbSOMMap.h" + +#include "otbSOM.h" + +#include "itkEuclideanDistanceMetric.h" // the distance function + +#include "otbCzihoSOMLearningBehaviorFunctor.h" +#include "otbCzihoSOMNeighborhoodBehaviorFunctor.h" + + + +namespace otb +{ +template <class TInputValue> +class ITK_EXPORT SOMModel: public DimensionalityReductionModel<TInputValue,TInputValue> +{ + +public: + + typedef SOMModel Self; + typedef DimensionalityReductionModel<TInputValue,TInputValue> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef typename Superclass::InputValueType InputValueType; + typedef typename Superclass::InputSampleType InputSampleType; + typedef typename Superclass::InputListSampleType InputListSampleType; + typedef typename InputListSampleType::Pointer ListSamplePointerType; + typedef typename Superclass::TargetValueType TargetValueType; + typedef typename Superclass::TargetSampleType TargetSampleType; + typedef typename Superclass::TargetListSampleType TargetListSampleType; + typedef typename Superclass::ConfidenceValueType ConfidenceValueType; + typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; + typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; + + typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> MapType; + typedef typename MapType::SizeType SizeType; + + typedef otb::SOM<InputListSampleType, MapType> EstimatorType; + + + typedef Functor::CzihoSOMLearningBehaviorFunctor SOMLearningBehaviorFunctorType; + typedef Functor::CzihoSOMNeighborhoodBehaviorFunctor SOMNeighborhoodBehaviorFunctorType; + + itkNewMacro(Self); + itkTypeMacro(SOMModel, DimensionalityReductionModel); + + /** Accessors */ + itkSetMacro(NumberOfIterations, unsigned int); + itkGetMacro(NumberOfIterations, unsigned int); + itkSetMacro(BetaInit, double); + itkGetMacro(BetaInit, double); + itkSetMacro(BetaEnd, double); + itkGetMacro(BetaEnd, double); + itkSetMacro(MinWeight, InputValueType); + itkGetMacro(MinWeight, InputValueType); + itkSetMacro(MaxWeight, InputValueType); + itkGetMacro(MaxWeight, InputValueType); + itkSetMacro(MapSize, SizeType); + itkGetMacro(MapSize, SizeType); + itkSetMacro(NeighborhoodSizeInit, SizeType); + itkGetMacro(NeighborhoodSizeInit, SizeType); + itkSetMacro(RandomInit, bool); + itkGetMacro(RandomInit, bool); + itkSetMacro(Seed, unsigned int); + itkGetMacro(Seed, unsigned int); + itkGetObjectMacro(ListSample, InputListSampleType); + itkSetObjectMacro(ListSample, InputListSampleType); + + bool CanReadFile(const std::string & filename); + bool CanWriteFile(const std::string & filename); + + void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + + void Train() ITK_OVERRIDE; + //void Dimensionality_reduction() {}; // Dimensionality reduction is done by DoPredict + + unsigned int GetDimension() { return MapType::ImageDimension;}; +protected: + SOMModel(); + ~SOMModel() ITK_OVERRIDE; + + virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + +private: + typename MapType::Pointer m_SOMMap; + + + /** Map Parameters used for training */ + + SizeType m_MapSize; + /** Number of iterations */ + unsigned int m_NumberOfIterations; + /** Initial learning coefficient */ + double m_BetaInit; + /** Final learning coefficient */ + double m_BetaEnd; + /** Initial neighborhood size */ + SizeType m_NeighborhoodSizeInit; + /** Minimum initial neuron weights */ + InputValueType m_MinWeight; + /** Maximum initial neuron weights */ + InputValueType m_MaxWeight; + /** Random initialization bool */ + bool m_RandomInit; + /** Seed for random initialization */ + unsigned int m_Seed; + /** The input list sample */ + ListSamplePointerType m_ListSample; + /** Behavior of the Learning weightening (link to the beta coefficient) */ + SOMLearningBehaviorFunctorType m_BetaFunctor; + /** Behavior of the Neighborhood extent */ + SOMNeighborhoodBehaviorFunctorType m_NeighborhoodSizeFunctor; + +}; + + +} // end namespace otb + + +#ifndef OTB_MANUAL_INSTANTIATION +#include "SOMModel.txx" +#endif + + +#endif + diff --git a/include/SOMModel.txx b/include/SOMModel.txx new file mode 100644 index 0000000000..78df8415c8 --- /dev/null +++ b/include/SOMModel.txx @@ -0,0 +1,101 @@ + +#ifndef SOMModel_txx +#define SOMModel_txx + +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" + +#include "itkMacro.h" + +namespace otb +{ + + +template <class TInputValue> +SOMModel<TInputValue>::SOMModel() +{ +} + + +template <class TInputValue> +SOMModel<TInputValue>::~SOMModel() +{ +} + + +template <class TInputValue> +void SOMModel<TInputValue>::Train() +{ + + typename EstimatorType::Pointer estimator = EstimatorType::New(); + + estimator->SetListSample(m_ListSample); + estimator->SetMapSize(m_MapSize); + estimator->SetNeighborhoodSizeInit(m_NeighborhoodSizeInit); + estimator->SetNumberOfIterations(m_NumberOfIterations); + estimator->SetBetaInit(m_BetaInit); + estimator->SetBetaEnd(m_BetaEnd); + estimator->SetMaxWeight(m_MaxWeight); + //AddProcess(estimator,"Learning"); + std::cout << "list = " << m_ListSample << std::endl; + std::cout << "size = " << m_MapSize << std::endl; + std::cout << "neigsize = " << m_NeighborhoodSizeInit << std::endl; + std::cout << "n iter = " << m_NumberOfIterations << std::endl; + std::cout << "bi = " << m_BetaInit << std::endl; + std::cout << "be = " << m_BetaEnd << std::endl; + std::cout << "mw = " << m_MaxWeight << std::endl; + + estimator->Update(); + + m_SOMMap = estimator->GetOutput(); +} + + +template <class TInputValue> +bool SOMModel<TInputValue>::CanReadFile(const std::string & filename) +{ + return true; +} + + +template <class TInputValue> +bool SOMModel<TInputValue>::CanWriteFile(const std::string & filename) +{ + return true; +} + +template <class TInputValue> +void SOMModel<TInputValue>::Save(const std::string & filename, const std::string & name) +{ + std::cout << m_SOMMap->GetNumberOfComponentsPerPixel() << std::endl; + +//Ecriture + auto kwl = m_SOMMap->GetImageKeywordlist(); + //kwl.AddKey("MachineLearningModelType", "SOM"); + //m_SOMMap->SetImageKeywordList(kwl); + auto writer = otb::ImageFileWriter<MapType>::New(); + writer->SetInput(m_SOMMap); + writer->SetFileName(filename); + writer->Update(); + +} + +template <class TInputValue> +void SOMModel<TInputValue>::Load(const std::string & filename, const std::string & name) +{ + auto reader = otb::ImageFileReader<MapType>::New(); + reader->SetFileName(filename); + reader->Update(); + std::cout << reader->GetOutput()->GetImageKeywordlist().GetMetadataByKey("MachineLearningModelType") << '\n'; + m_SOMMap = reader->GetOutput(); +} + + +template <class TInputValue> +typename SOMModel<TInputValue>::TargetSampleType +SOMModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueType *quality) const +{ +} + +} // namespace otb +#endif diff --git a/include/SOMModelFactory.h b/include/SOMModelFactory.h new file mode 100644 index 0000000000..56c0b88c6c --- /dev/null +++ b/include/SOMModelFactory.h @@ -0,0 +1,59 @@ +#ifndef PCAModelFactory_h +#define PCAModelFactory_h + + +#include "itkObjectFactoryBase.h" +#include "itkImageIOBase.h" + +namespace otb +{ + +template <class TInputValue, class TTargetValue> +class ITK_EXPORT PCAModelFactory : public itk::ObjectFactoryBase +{ +public: + /** Standard class typedefs. */ + typedef PCAModelFactory Self; + typedef itk::ObjectFactoryBase Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Class methods used to interface with the registered factories. */ + const char* GetITKSourceVersion(void) const ITK_OVERRIDE; + const char* GetDescription(void) const ITK_OVERRIDE; + + /** Method for class instantiation. */ + itkFactorylessNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(PCAModelFactory, itk::ObjectFactoryBase); + + /** Register one factory of this type */ + static void RegisterOneFactory(void) + { + Pointer PCAFactory = PCAModelFactory::New(); + itk::ObjectFactoryBase::RegisterFactory(PCAFactory); + } + +protected: + PCAModelFactory(); + ~PCAModelFactory() ITK_OVERRIDE; + +private: + PCAModelFactory(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + +}; + + + +} //namespace otb + + +#ifndef OTB_MANUAL_INSTANTIATION +#include "PCAModelFactory.txx" +#endif + +#endif + + diff --git a/include/SOMModelFactory.txx b/include/SOMModelFactory.txx new file mode 100644 index 0000000000..bfaa4f6f62 --- /dev/null +++ b/include/SOMModelFactory.txx @@ -0,0 +1,65 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#ifndef PCAFactory_txx +#define PCAFactory_txx + + +#include "PCAModelFactory.h" + +#include "itkCreateObjectFunction.h" +#include "PCAModel.h" +//#include <shark/Algorithms/Trainers/PCA.h> +#include "itkVersion.h" + +namespace otb +{ +template <class TInputValue, class TOutputValue> +PCAModelFactory<TInputValue,TOutputValue>::PCAModelFactory() +{ + + std::string classOverride = std::string("DimensionalityReductionModel"); + std::string subclass = std::string("PCAModel"); + + this->RegisterOverride(classOverride.c_str(), + subclass.c_str(), + "Shark PCA ML Model", + 1, + // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); + itk::CreateObjectFunction<PCAModel<TInputValue>>::New()); +} + +template <class TInputValue, class TOutputValue> +PCAModelFactory<TInputValue,TOutputValue>::~PCAModelFactory() +{ +} + +template <class TInputValue, class TOutputValue> +const char* PCAModelFactory<TInputValue,TOutputValue>::GetITKSourceVersion(void) const +{ + return ITK_SOURCE_VERSION; +} + +template <class TInputValue, class TOutputValue> +const char* PCAModelFactory<TInputValue,TOutputValue>::GetDescription() const +{ + return "PCA model factory"; +} + +} // end namespace otb + +#endif diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 7a467e242e..9ef37ef948 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -14,6 +14,8 @@ //Estimator #include "DimensionalityReductionModelFactory.h" +#include "SOMModel.h" + #ifdef OTB_USE_SHARK #include "AutoencoderModel.h" #include "PCAModel.h" @@ -75,7 +77,6 @@ public: typedef otb::VectorImage<InputValueType> SampleImageType; typedef typename SampleImageType::PixelType PixelType; - // Machine Learning models typedef otb::DimensionalityReductionModelFactory< InputValueType, OutputValueType> ModelFactoryType; typedef typename ModelFactoryType::DimensionalityReductionModelTypePointer ModelPointerType; @@ -84,6 +85,11 @@ public: typedef typename ModelType::InputSampleType SampleType; typedef typename ModelType::InputListSampleType ListSampleType; + // Dimensionality reduction models + + typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> MapType; + typedef otb::SOM<ListSampleType, MapType> EstimatorType; + typedef otb::SOMModel<InputValueType> SOMModelType; #ifdef OTB_USE_SHARK typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; @@ -120,9 +126,11 @@ private: #ifdef OTB_USE_SHARK void InitAutoencoderParams(); void InitPCAParams(); + void InitSOMParams(); template <class autoencoderchoice> void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); #endif //@} }; @@ -132,6 +140,7 @@ private: #ifndef OTB_MANUAL_INSTANTIATION #include "cbLearningApplicationBaseDR.txx" +#include "cbTrainSOM.txx" #ifdef OTB_USE_SHARK #include "cbTrainAutoencoder.txx" #include "cbTrainPCA.txx" diff --git a/include/cbLearningApplicationBaseDR.txx b/include/cbLearningApplicationBaseDR.txx index 562b5e395b..885484638c 100644 --- a/include/cbLearningApplicationBaseDR.txx +++ b/include/cbLearningApplicationBaseDR.txx @@ -48,7 +48,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> AddParameter(ParameterType_Choice, "model", "moddel to use for the training"); SetParameterDescription("model", "Choice of the dimensionality reduction model to use for the training."); - + InitSOMParams(); #ifdef OTB_USE_SHARK InitAutoencoderParams(); InitPCAParams(); @@ -98,7 +98,11 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> // get the name of the chosen machine learning model const std::string modelName = GetParameterString("model"); // call specific train function - + + if(modelName == "som") + { + TrainSOM(trainingListSample,modelPath); + } if(modelName == "autoencoder") { #ifdef OTB_USE_SHARK diff --git a/include/cbTrainSOM.txx b/include/cbTrainSOM.txx new file mode 100644 index 0000000000..9e2b620dc5 --- /dev/null +++ b/include/cbTrainSOM.txx @@ -0,0 +1,95 @@ + +#ifndef cbTrainSOM_txx +#define cbTrainSOM_txx +#include "cbLearningApplicationBaseDR.h" + +namespace otb +{ +namespace Wrapper +{ + +template <class TInputValue, class TOutputValue> +void +cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::InitSOMParams() +{ + + + AddChoice("model.som", "OTB SOM"); + SetParameterDescription("model.som", + "This group of parameters allows setting SOM parameters. " + ); + + + AddParameter(ParameterType_Int, "model.som.sx", "SizeX"); + SetParameterDescription("model.som.sx", "X size of the SOM map"); + MandatoryOff("model.som.sx"); + + AddParameter(ParameterType_Int, "model.som.sy", "SizeY"); + SetParameterDescription("model.som.sy", "Y size of the SOM map"); + MandatoryOff("model.som.sy"); + + AddParameter(ParameterType_Int, "model.som.nx", "NeighborhoodX"); + SetParameterDescription("model.som.nx", "X size of the initial neighborhood in the SOM map"); + MandatoryOff("model.som.nx"); + + AddParameter(ParameterType_Int, "model.som.ny", "NeighborhoodY"); + SetParameterDescription("model.som.ny", "Y size of the initial neighborhood in the SOM map"); + MandatoryOff("model.som.nx"); + + AddParameter(ParameterType_Int, "model.som.ni", "NumberIteration"); + SetParameterDescription("model.som.ni", "Number of iterations for SOM learning"); + MandatoryOff("model.som.ni"); + + AddParameter(ParameterType_Float, "model.som.bi", "BetaInit"); + SetParameterDescription("model.som.bi", "Initial learning coefficient"); + MandatoryOff("model.som.bi"); + + AddParameter(ParameterType_Float, "model.som.bf", "BetaFinal"); + SetParameterDescription("model.som.bf", "Final learning coefficient"); + MandatoryOff("model.som.bf"); + + AddParameter(ParameterType_Float, "model.som.iv", "InitialValue"); + SetParameterDescription("model.som.iv", "Maximum initial neuron weight"); + MandatoryOff("model.som.iv"); + + SetDefaultParameterInt("model.som.sx", 32); + SetDefaultParameterInt("model.som.sy", 32); + SetDefaultParameterInt("model.som.nx", 10); + SetDefaultParameterInt("model.som.ny", 10); + SetDefaultParameterInt("model.som.ni", 5); + SetDefaultParameterFloat("model.som.bi", 1.0); + SetDefaultParameterFloat("model.som.bf", 0.1); + SetDefaultParameterFloat("model.som.iv", 10.0); + + +} + +template <class TInputValue, class TOutputValue> +void cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::TrainSOM(typename ListSampleType::Pointer trainingListSample,std::string modelPath) +{ + + typename SOMModelType::Pointer dimredTrainer = SOMModelType::New(); + dimredTrainer->SetNumberOfIterations(GetParameterInt("model.som.ni")); + dimredTrainer->SetBetaInit(GetParameterFloat("model.som.bi")); + dimredTrainer->SetBetaEnd(GetParameterFloat("model.som.bf")); + dimredTrainer->SetMaxWeight(GetParameterFloat("model.som.iv")); + typename EstimatorType::SizeType size; + size[0]=GetParameterInt("model.som.sx"); + size[1]=GetParameterInt("model.som.sy"); + dimredTrainer->SetMapSize(size); + typename EstimatorType::SizeType radius; + radius[0] = GetParameterInt("model.som.nx"); + radius[1] = GetParameterInt("model.som.ny"); + dimredTrainer->SetNeighborhoodSizeInit(radius); + std::cout << trainingListSample << std::endl; + dimredTrainer->SetListSample(trainingListSample); + dimredTrainer->Train(); + dimredTrainer->Save(modelPath); +} + +} //end namespace wrapper +} //end namespace otb + +#endif -- GitLab From f9580ea514d2c2ec9bc24a09b60b2628f31d59ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 16 May 2017 18:00:22 +0200 Subject: [PATCH 025/567] dr som almsot working (third band empty ...) --- .../DimensionalityReductionModelFactory.txx | 22 ++++++++----- include/SOMModel.h | 2 +- include/SOMModel.txx | 32 +++++++++++++------ include/SOMModelFactory.h | 22 ++++++------- include/SOMModelFactory.txx | 24 +++++++------- include/cbLearningApplicationBaseDR.h | 2 +- include/cbTrainSOM.txx | 29 +++++++++++++---- 7 files changed, 84 insertions(+), 49 deletions(-) diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 0c05937d39..585af208aa 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -21,6 +21,7 @@ #include "DimensionalityReductionModelFactory.h" #include "otbConfigure.h" +#include "SOMModelFactory.h" #ifdef OTB_USE_SHARK #include "AutoencoderModelFactory.h" @@ -95,15 +96,12 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> { itk::MutexLockHolder<itk::SimpleMutexLock> lockHolder(mutex); + -#ifdef OTB_USE_SHARK + RegisterFactory(SOMModelFactory<TInputValue,TOutputValue>::New()); - // using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron>> {}; - - - //using TiedAutoencoderModelFactory = public AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> {}; - +#ifdef OTB_USE_SHARK RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(AutoencoderModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); @@ -136,7 +134,14 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> for (itFac = factories.begin(); itFac != factories.end() ; ++itFac) { - + // SOM + SOMModelFactory<TInputValue,TOutputValue> *somFactory = + dynamic_cast<SOMModelFactory<TInputValue,TOutputValue> *>(*itFac); + if (somFactory) + { + itk::ObjectFactoryBase::UnRegisterFactory(somFactory); + continue; + } #ifdef OTB_USE_SHARK // Autoencoder @@ -155,7 +160,8 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> itk::ObjectFactoryBase::UnRegisterFactory(taeFactory); continue; } - + + // PCA PCAModelFactory<TInputValue,TOutputValue> *pcaFactory = dynamic_cast<PCAModelFactory<TInputValue,TOutputValue> *>(*itFac); if (pcaFactory) diff --git a/include/SOMModel.h b/include/SOMModel.h index 1a469e4436..b7adddd663 100644 --- a/include/SOMModel.h +++ b/include/SOMModel.h @@ -37,7 +37,7 @@ public: typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; - typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> MapType; + typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> MapType; typedef typename MapType::SizeType SizeType; typedef otb::SOM<InputListSampleType, MapType> EstimatorType; diff --git a/include/SOMModel.txx b/include/SOMModel.txx index 78df8415c8..5c6be685ba 100644 --- a/include/SOMModel.txx +++ b/include/SOMModel.txx @@ -14,6 +14,7 @@ namespace otb template <class TInputValue> SOMModel<TInputValue>::SOMModel() { + this->m_IsRegressionSupported = true; } @@ -37,13 +38,6 @@ void SOMModel<TInputValue>::Train() estimator->SetBetaEnd(m_BetaEnd); estimator->SetMaxWeight(m_MaxWeight); //AddProcess(estimator,"Learning"); - std::cout << "list = " << m_ListSample << std::endl; - std::cout << "size = " << m_MapSize << std::endl; - std::cout << "neigsize = " << m_NeighborhoodSizeInit << std::endl; - std::cout << "n iter = " << m_NumberOfIterations << std::endl; - std::cout << "bi = " << m_BetaInit << std::endl; - std::cout << "be = " << m_BetaEnd << std::endl; - std::cout << "mw = " << m_MaxWeight << std::endl; estimator->Update(); @@ -54,6 +48,14 @@ void SOMModel<TInputValue>::Train() template <class TInputValue> bool SOMModel<TInputValue>::CanReadFile(const std::string & filename) { + try + { + this->Load(filename); + } + catch(...) + { + return false; + } return true; } @@ -86,7 +88,7 @@ void SOMModel<TInputValue>::Load(const std::string & filename, const std::string auto reader = otb::ImageFileReader<MapType>::New(); reader->SetFileName(filename); reader->Update(); - std::cout << reader->GetOutput()->GetImageKeywordlist().GetMetadataByKey("MachineLearningModelType") << '\n'; + //std::cout << reader->GetOutput()->GetImageKeywordlist().GetMetadataByKey("MachineLearningModelType") << '\n'; m_SOMMap = reader->GetOutput(); } @@ -94,7 +96,19 @@ void SOMModel<TInputValue>::Load(const std::string & filename, const std::string template <class TInputValue> typename SOMModel<TInputValue>::TargetSampleType SOMModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueType *quality) const -{ +{ + unsigned int dimension =MapType::ImageDimension; + TargetSampleType target; + target.SetSize(dimension); + + auto winner =m_SOMMap->GetWinner(value); + + + for (int i=0; i< dimension ;i++) { + target[i] = winner.GetElement(i); + } + + return target; } } // namespace otb diff --git a/include/SOMModelFactory.h b/include/SOMModelFactory.h index 56c0b88c6c..0a3a9dd7a3 100644 --- a/include/SOMModelFactory.h +++ b/include/SOMModelFactory.h @@ -1,5 +1,5 @@ -#ifndef PCAModelFactory_h -#define PCAModelFactory_h +#ifndef SOMModelFactory_h +#define SOMModelFactory_h #include "itkObjectFactoryBase.h" @@ -9,11 +9,11 @@ namespace otb { template <class TInputValue, class TTargetValue> -class ITK_EXPORT PCAModelFactory : public itk::ObjectFactoryBase +class ITK_EXPORT SOMModelFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ - typedef PCAModelFactory Self; + typedef SOMModelFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -26,21 +26,21 @@ public: itkFactorylessNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro(PCAModelFactory, itk::ObjectFactoryBase); + itkTypeMacro(SOMModelFactory, itk::ObjectFactoryBase); /** Register one factory of this type */ static void RegisterOneFactory(void) { - Pointer PCAFactory = PCAModelFactory::New(); - itk::ObjectFactoryBase::RegisterFactory(PCAFactory); + Pointer SOMFactory = SOMModelFactory::New(); + itk::ObjectFactoryBase::RegisterFactory(SOMFactory); } protected: - PCAModelFactory(); - ~PCAModelFactory() ITK_OVERRIDE; + SOMModelFactory(); + ~SOMModelFactory() ITK_OVERRIDE; private: - PCAModelFactory(const Self &); //purposely not implemented + SOMModelFactory(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented }; @@ -51,7 +51,7 @@ private: #ifndef OTB_MANUAL_INSTANTIATION -#include "PCAModelFactory.txx" +#include "SOMModelFactory.txx" #endif #endif diff --git a/include/SOMModelFactory.txx b/include/SOMModelFactory.txx index bfaa4f6f62..0df39c43c4 100644 --- a/include/SOMModelFactory.txx +++ b/include/SOMModelFactory.txx @@ -15,49 +15,49 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef PCAFactory_txx -#define PCAFactory_txx +#ifndef SOMFactory_txx +#define SOMFactory_txx -#include "PCAModelFactory.h" +#include "SOMModelFactory.h" #include "itkCreateObjectFunction.h" -#include "PCAModel.h" +#include "SOMModel.h" //#include <shark/Algorithms/Trainers/PCA.h> #include "itkVersion.h" namespace otb { template <class TInputValue, class TOutputValue> -PCAModelFactory<TInputValue,TOutputValue>::PCAModelFactory() +SOMModelFactory<TInputValue,TOutputValue>::SOMModelFactory() { std::string classOverride = std::string("DimensionalityReductionModel"); - std::string subclass = std::string("PCAModel"); + std::string subclass = std::string("SOMModel"); this->RegisterOverride(classOverride.c_str(), subclass.c_str(), - "Shark PCA ML Model", + "SOM DR Model", 1, // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); - itk::CreateObjectFunction<PCAModel<TInputValue>>::New()); + itk::CreateObjectFunction<SOMModel<TInputValue>>::New()); } template <class TInputValue, class TOutputValue> -PCAModelFactory<TInputValue,TOutputValue>::~PCAModelFactory() +SOMModelFactory<TInputValue,TOutputValue>::~SOMModelFactory() { } template <class TInputValue, class TOutputValue> -const char* PCAModelFactory<TInputValue,TOutputValue>::GetITKSourceVersion(void) const +const char* SOMModelFactory<TInputValue,TOutputValue>::GetITKSourceVersion(void) const { return ITK_SOURCE_VERSION; } template <class TInputValue, class TOutputValue> -const char* PCAModelFactory<TInputValue,TOutputValue>::GetDescription() const +const char* SOMModelFactory<TInputValue,TOutputValue>::GetDescription() const { - return "PCA model factory"; + return "SOM model factory"; } } // end namespace otb diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 9ef37ef948..5ff2e90442 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -87,7 +87,7 @@ public: // Dimensionality reduction models - typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> MapType; + typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> MapType; typedef otb::SOM<ListSampleType, MapType> EstimatorType; typedef otb::SOMModel<InputValueType> SOMModelType; diff --git a/include/cbTrainSOM.txx b/include/cbTrainSOM.txx index 9e2b620dc5..4951b17725 100644 --- a/include/cbTrainSOM.txx +++ b/include/cbTrainSOM.txx @@ -20,7 +20,14 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> "This group of parameters allows setting SOM parameters. " ); - + AddParameter(ParameterType_StringList , "model.som.s", "Size"); + SetParameterDescription("model.som.s", "Size of the SOM map"); + MandatoryOff("model.som.s"); + + AddParameter(ParameterType_StringList , "model.som.n", "Size Neighborhood"); + SetParameterDescription("model.som.n", "Size of the initial neighborhood in the SOM map"); + MandatoryOff("model.som.n"); + AddParameter(ParameterType_Int, "model.som.sx", "SizeX"); SetParameterDescription("model.som.sx", "X size of the SOM map"); MandatoryOff("model.som.sx"); @@ -52,7 +59,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> AddParameter(ParameterType_Float, "model.som.iv", "InitialValue"); SetParameterDescription("model.som.iv", "Maximum initial neuron weight"); MandatoryOff("model.som.iv"); - + ; SetDefaultParameterInt("model.som.sx", 32); SetDefaultParameterInt("model.som.sy", 32); SetDefaultParameterInt("model.som.nx", 10); @@ -70,20 +77,28 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> ::TrainSOM(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { + //std::cout << std::stoi(s[0]) << std::endl; typename SOMModelType::Pointer dimredTrainer = SOMModelType::New(); dimredTrainer->SetNumberOfIterations(GetParameterInt("model.som.ni")); dimredTrainer->SetBetaInit(GetParameterFloat("model.som.bi")); dimredTrainer->SetBetaEnd(GetParameterFloat("model.som.bf")); dimredTrainer->SetMaxWeight(GetParameterFloat("model.som.iv")); + std::cout << "0" << std::endl; typename EstimatorType::SizeType size; - size[0]=GetParameterInt("model.som.sx"); - size[1]=GetParameterInt("model.som.sy"); + std::vector<std::basic_string<char>> s= GetParameterStringList("model.som.s"); + for (int i=0; i<3; i++){ // This will be templated later (the 3) + size[i]=std::stoi(s[i]); + } + dimredTrainer->SetMapSize(size); + std::cout << "1" << std::endl; typename EstimatorType::SizeType radius; - radius[0] = GetParameterInt("model.som.nx"); - radius[1] = GetParameterInt("model.som.ny"); + std::vector<std::basic_string<char>> n= GetParameterStringList("model.som.n"); + for (int i=0; i<3; i++){ // This will be templated later (the 3) + radius[i]=std::stoi(n[i]); + } + std::cout << "2" << std::endl; dimredTrainer->SetNeighborhoodSizeInit(radius); - std::cout << trainingListSample << std::endl; dimredTrainer->SetListSample(trainingListSample); dimredTrainer->Train(); dimredTrainer->Save(modelPath); -- GitLab From b187c9a635b3fae949efe8176e9eec44c3bf04ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 17 May 2017 13:57:26 +0200 Subject: [PATCH 026/567] confidence map removed --- app/cbDimensionalityReduction.cxx | 18 +--- include/AutoencoderModel.h | 9 +- include/AutoencoderModel.txx | 6 +- include/DimensionalityReductionModel.h | 39 ++------ include/DimensionalityReductionModel.txx | 95 ++++++------------- .../DimensionalityReductionModelFactory.txx | 9 +- .../ImageDimensionalityReductionFilter.txx | 35 +------ include/PCAModel.h | 9 +- include/PCAModel.txx | 6 +- include/SOMModel.h | 7 +- include/SOMModel.txx | 6 +- 11 files changed, 66 insertions(+), 173 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index 7b1063147b..6d5366e9eb 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -145,8 +145,6 @@ private: AddParameter(ParameterType_InputImage, "in", "Input Image"); SetParameterDescription( "in", "The input image to predict."); - // TODO : use CSV input/output ? - AddParameter(ParameterType_InputImage, "mask", "Input Mask"); SetParameterDescription( "mask", "The mask allow restricting " "classification of the input image to the area where mask pixel values " @@ -200,7 +198,6 @@ private: } m_Model->Load(GetParameterString("model")); - m_Model->SetRegressionMode(true); otbAppLogINFO("Model loaded"); // Classify @@ -218,25 +215,14 @@ private: MeasurementType meanMeasurementVector; MeasurementType stddevMeasurementVector; m_Rescaler = RescalerType::New(); + // Load input image statistics statisticsReader->SetFileName(GetParameterString("imstat")); meanMeasurementVector = statisticsReader->GetStatisticVectorByName("mean"); stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); otbAppLogINFO( "mean used: " << meanMeasurementVector ); otbAppLogINFO( "standard deviation used: " << stddevMeasurementVector ); - /*if (meanMeasurementVector.Size() == nbFeatures + 1) - { - double outMean = meanMeasurementVector[nbFeatures]; - double outStdDev = stddevMeasurementVector[nbFeatures]; - meanMeasurementVector.SetSize(nbFeatures,false); - stddevMeasurementVector.SetSize(nbFeatures,false); - m_OutRescaler = OutputRescalerType::New(); - m_OutRescaler->SetInput(m_ClassificationFilter->GetOutput()); - m_OutRescaler->GetFunctor().SetA(outStdDev); - m_OutRescaler->GetFunctor().SetB(outMean); - outputImage = m_OutRescaler->GetOutput(); - } - else*/ if (meanMeasurementVector.Size() != nbFeatures) + if (meanMeasurementVector.Size() != nbFeatures) { otbAppLogFATAL("Wrong number of components in statistics file : "<<meanMeasurementVector.Size()); } diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 7ebb95de6f..eb65fdb1df 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -23,10 +23,7 @@ public: typedef typename Superclass::TargetValueType TargetValueType; typedef typename Superclass::TargetSampleType TargetSampleType; typedef typename Superclass::TargetListSampleType TargetListSampleType; - typedef typename Superclass::ConfidenceValueType ConfidenceValueType; - typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; - typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; - + itkNewMacro(Self); itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); @@ -54,8 +51,8 @@ protected: AutoencoderModel(); ~AutoencoderModel() ITK_OVERRIDE; - virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; - virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const ITK_OVERRIDE; + virtual TargetSampleType DoPredict(const InputSampleType& input) const ITK_OVERRIDE; + virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *) const ITK_OVERRIDE; private: diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index b0e206532f..7f2b451647 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -19,7 +19,7 @@ namespace otb template <class TInputValue, class AutoencoderType> AutoencoderModel<TInputValue,AutoencoderType>::AutoencoderModel() { - this->m_IsRegressionSupported = true; + this->m_IsDoPredictBatchMultiThreaded = true; } @@ -117,7 +117,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & fil template <class TInputValue, class AutoencoderType> typename AutoencoderModel<TInputValue,AutoencoderType>::TargetSampleType -AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value, ConfidenceValueType *quality) const +AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value) const { shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) @@ -143,7 +143,7 @@ AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType> -::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const +::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets) const { std::cout << "BATCH" << std::endl; std::vector<shark::RealVector> features; diff --git a/include/DimensionalityReductionModel.h b/include/DimensionalityReductionModel.h index ba9888b1fb..4f12b1e2ef 100644 --- a/include/DimensionalityReductionModel.h +++ b/include/DimensionalityReductionModel.h @@ -62,7 +62,7 @@ namespace otb * * \ingroup OTBSupervised */ -template <class TInputValue, class TTargetValue, class TConfidenceValue = double > +template <class TInputValue, class TTargetValue> class ITK_EXPORT DimensionalityReductionModel : public itk::Object { @@ -89,11 +89,6 @@ public: typedef itk::Statistics::ListSample<TargetSampleType> TargetListSampleType; //@} - /**\name Confidence value typedef */ - typedef TConfidenceValue ConfidenceValueType; - typedef itk::FixedArray<ConfidenceValueType,1> ConfidenceSampleType; - typedef itk::Statistics::ListSample<ConfidenceSampleType> ConfidenceListSampleType; - /**\name Standard macros */ //@{ /** Run-time type information (and related methods). */ @@ -109,7 +104,7 @@ public: * quality value, or NULL * \return The predicted label */ - TargetSampleType Predict(const InputSampleType& input, ConfidenceValueType *quality = ITK_NULLPTR) const; + TargetSampleType Predict(const InputSampleType& input) const; @@ -121,7 +116,7 @@ public: * Note that this method will be multi-threaded if OTB is built * with OpenMP. */ - typename TargetListSampleType::Pointer PredictBatch(const InputListSampleType * input, ConfidenceListSampleType * quality = ITK_NULLPTR) const; + typename TargetListSampleType::Pointer PredictBatch(const InputListSampleType * input) const; /** THIS METHOD IS DEPRECATED AND SHOULD NOT BE USED. */ void PredictAll(); @@ -147,9 +142,6 @@ public: virtual bool CanWriteFile(const std::string &) = 0; //@} - /** Query capacity to produce a confidence index */ - bool HasConfidenceIndex() const {return m_ConfidenceIndex;} - /**\name Input list of samples accessors */ //@{ itkSetObjectMacro(InputListSample,InputListSampleType); @@ -165,13 +157,7 @@ public: itkGetObjectMacro(TargetListSample,TargetListSampleType); //@} - itkGetObjectMacro(ConfidenceListSample,ConfidenceListSampleType); - - /**\name Use model in regression mode */ - //@{ - itkGetMacro(RegressionMode,bool); - void SetRegressionMode(bool flag); - //@} + protected: /** Constructor */ @@ -189,19 +175,6 @@ protected: /** Target list sample */ typename TargetListSampleType::Pointer m_TargetListSample; - typename ConfidenceListSampleType::Pointer m_ConfidenceListSample; - - /** flag to choose between classification and regression modes */ - bool m_RegressionMode; - - /** flag that indicates if the model supports regression, child - * classes should modify it in their constructor if they support - * regression mode */ - bool m_IsRegressionSupported; - - /** flag that tells if the model support confidence index output */ - bool m_ConfidenceIndex; - /** Is DoPredictBatch multi-threaded ? */ bool m_IsDoPredictBatchMultiThreaded; @@ -225,7 +198,7 @@ private: * Also set m_IsDoPredictBatchMultiThreaded to true if internal * implementation allows for parallel batch prediction. */ - virtual void DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * target, ConfidenceListSampleType * quality = ITK_NULLPTR) const; + virtual void DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * target) const; /** Actual implementation of single sample prediction * \param input sample to predict @@ -233,7 +206,7 @@ private: * or NULL * \return The predicted label */ - virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType * quality= ITK_NULLPTR) const = 0; + virtual TargetSampleType DoPredict(const InputSampleType& input) const = 0; DimensionalityReductionModel(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented diff --git a/include/DimensionalityReductionModel.txx b/include/DimensionalityReductionModel.txx index 68db8019a3..ba20ee8e28 100644 --- a/include/DimensionalityReductionModel.txx +++ b/include/DimensionalityReductionModel.txx @@ -29,40 +29,21 @@ namespace otb { -template <class TInputValue, class TOutputValue, class TConfidenceValue> -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> -::DimensionalityReductionModel() : - m_RegressionMode(false), - m_IsRegressionSupported(false), - m_ConfidenceIndex(false), - m_IsDoPredictBatchMultiThreaded(false) -{} +template <class TInputValue, class TOutputValue> +DimensionalityReductionModel<TInputValue,TOutputValue> +::DimensionalityReductionModel() +{ this->m_IsDoPredictBatchMultiThreaded=false;} -template <class TInputValue, class TOutputValue, class TConfidenceValue> -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +template <class TInputValue, class TOutputValue> +DimensionalityReductionModel<TInputValue,TOutputValue> ::~DimensionalityReductionModel() {} -template <class TInputValue, class TOutputValue, class TConfidenceValue> -void -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> -::SetRegressionMode(bool flag) -{ - if (flag && !m_IsRegressionSupported) - { - itkGenericExceptionMacro(<< "Regression mode not implemented."); - } - if (m_RegressionMode != flag) - { - m_RegressionMode = flag; - this->Modified(); - } -} -template <class TInputValue, class TOutputValue, class TConfidenceValue> +template <class TInputValue, class TOutputValue> void -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +DimensionalityReductionModel<TInputValue,TOutputValue> ::PredictAll() { itkWarningMacro("DimensionalityReductionModel::PredictAll() has been DEPRECATED. Use DimensionalityReductionModel::PredictBatch() instead."); @@ -75,36 +56,31 @@ DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> targets->Graft(tmpTargets); } -template <class TInputValue, class TOutputValue, class TConfidenceValue> -typename DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +template <class TInputValue, class TOutputValue> +typename DimensionalityReductionModel<TInputValue,TOutputValue> ::TargetSampleType -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> -::Predict(const InputSampleType& input, ConfidenceValueType *quality) const +DimensionalityReductionModel<TInputValue,TOutputValue> +::Predict(const InputSampleType& input) const { // Call protected specialization entry point - return this->DoPredict(input,quality); + return this->DoPredict(input); } -template <class TInputValue, class TOutputValue, class TConfidenceValue> -typename DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +template <class TInputValue, class TOutputValue> +typename DimensionalityReductionModel<TInputValue,TOutputValue> ::TargetListSampleType::Pointer -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> -::PredictBatch(const InputListSampleType * input, ConfidenceListSampleType * quality) const +DimensionalityReductionModel<TInputValue,TOutputValue> +::PredictBatch(const InputListSampleType * input) const { typename TargetListSampleType::Pointer targets = TargetListSampleType::New(); targets->Resize(input->Size()); - if(quality!=ITK_NULLPTR) - { - quality->Clear(); - quality->Resize(input->Size()); - } if(m_IsDoPredictBatchMultiThreaded) { // Simply calls DoPredictBatch - this->DoPredictBatch(input,0,input->Size(),targets,quality); + this->DoPredictBatch(input,0,input->Size(),targets); return targets; } else @@ -131,11 +107,11 @@ DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> batch_size+=input->Size()%nb_batches; } - this->DoPredictBatch(input,batch_start,batch_size,targets,quality); + this->DoPredictBatch(input,batch_start,batch_size,targets); } } #else - this->DoPredictBatch(input,0,input->Size(),targets,quality); + this->DoPredictBatch(input,0,input->Size(),targets); #endif return targets; } @@ -143,10 +119,10 @@ DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> -template <class TInputValue, class TOutputValue, class TConfidenceValue> +template <class TInputValue, class TOutputValue> void -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> -::DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const +DimensionalityReductionModel<TInputValue,TOutputValue> +::DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets) const { assert(input != ITK_NULLPTR); assert(targets != ITK_NULLPTR); @@ -159,29 +135,18 @@ DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> itkExceptionMacro(<<"requested range ["<<startIndex<<", "<<startIndex+size<<"[ partially outside input sample list range.[0,"<<input->Size()<<"["); } - if(quality != ITK_NULLPTR) - { - for(unsigned int id = startIndex;id<startIndex+size;++id) - { - ConfidenceValueType confidence = 0; - const TargetSampleType target = this->DoPredict(input->GetMeasurementVector(id),&confidence); - quality->SetMeasurementVector(id,confidence); - targets->SetMeasurementVector(id,target); - } - } - else + + for(unsigned int id = startIndex;id<startIndex+size;++id) { - for(unsigned int id = startIndex;id<startIndex+size;++id) - { - const TargetSampleType target = this->DoPredict(input->GetMeasurementVector(id)); - targets->SetMeasurementVector(id,target); - } + const TargetSampleType target = this->DoPredict(input->GetMeasurementVector(id)); + targets->SetMeasurementVector(id,target); } + } -template <class TInputValue, class TOutputValue, class TConfidenceValue> +template <class TInputValue, class TOutputValue> void -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +DimensionalityReductionModel<TInputValue,TOutputValue> ::PrintSelf(std::ostream& os, itk::Indent indent) const { // Call superclass implementation diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 585af208aa..5fba93346e 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -42,6 +42,9 @@ template <class TInputValue, class TTargetValue> using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; +template <class TInputValue, class TTargetValue> +using SOM3DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 2> ; + template <class TInputValue, class TOutputValue> typename DimensionalityReductionModel<TInputValue,TOutputValue>::Pointer DimensionalityReductionModelFactory<TInputValue,TOutputValue> @@ -99,7 +102,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> - RegisterFactory(SOMModelFactory<TInputValue,TOutputValue>::New()); + RegisterFactory(SOM3DModelFactory<TInputValue,TOutputValue>::New()); #ifdef OTB_USE_SHARK RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); @@ -135,8 +138,8 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> { // SOM - SOMModelFactory<TInputValue,TOutputValue> *somFactory = - dynamic_cast<SOMModelFactory<TInputValue,TOutputValue> *>(*itFac); + SOM3DModelFactory<TInputValue,TOutputValue> *somFactory = + dynamic_cast<SOM3DModelFactory<TInputValue,TOutputValue> *>(*itFac); if (somFactory) { itk::ObjectFactoryBase::UnRegisterFactory(somFactory); diff --git a/include/ImageDimensionalityReductionFilter.txx b/include/ImageDimensionalityReductionFilter.txx index 9f5b34cab2..9060270636 100644 --- a/include/ImageDimensionalityReductionFilter.txx +++ b/include/ImageDimensionalityReductionFilter.txx @@ -144,8 +144,6 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> ::BatchThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) { - bool computeConfidenceMap(m_UseConfidenceMap && m_Model->HasConfidenceIndex() - && !m_Model->GetRegressionMode()); // Get the input pointers InputImageConstPointerType inputPtr = this->GetInput(); MaskImageConstPointerType inputMaskPtr = this->GetInputMask(); @@ -172,8 +170,7 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> typedef typename ModelType::TargetListSampleType TargetListSampleType; // typedef typename ModelType::ConfidenceValueType ConfidenceValueType; // typedef typename ModelType::ConfidenceSampleType ConfidenceSampleType; - typedef typename ModelType::ConfidenceListSampleType ConfidenceListSampleType; - + typename InputListSampleType::Pointer samples = InputListSampleType::New(); unsigned int num_features = inputPtr->GetNumberOfComponentsPerPixel(); samples->SetMeasurementVectorSize(num_features); @@ -193,45 +190,23 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> } //Make the batch prediction typename TargetListSampleType::Pointer labels; - typename ConfidenceListSampleType::Pointer confidences; - if(computeConfidenceMap) - confidences = ConfidenceListSampleType::New(); - + // This call is threadsafe //labels = m_Model->PredictBatch(samples,confidences); labels = m_Model->PredictBatch(samples); // Set the output values - ConfidenceMapIteratorType confidenceIt; - if (computeConfidenceMap) - { - confidenceIt = ConfidenceMapIteratorType(confidencePtr,outputRegionForThread); - confidenceIt.GoToBegin(); - } + typename TargetListSampleType::ConstIterator labIt = labels->Begin(); for (outIt.GoToBegin(); !outIt.IsAtEnd(); ++outIt) { - double confidenceIndex = 0.0; - + itk::VariableLengthVector<TargetValueType> labelValue; - + labelValue = labIt.GetMeasurementVector(); - - if(computeConfidenceMap) - { - confidenceIndex = confidences->GetMeasurementVector(labIt.GetInstanceIdentifier())[0]; - } - ++labIt; - outIt.Set(labelValue); - if(computeConfidenceMap) - { - confidenceIt.Set(confidenceIndex); - ++confidenceIt; - } - progress.CompletedPixel(); } } diff --git a/include/PCAModel.h b/include/PCAModel.h index 4ea1370a9f..45693dfc8a 100644 --- a/include/PCAModel.h +++ b/include/PCAModel.h @@ -23,10 +23,7 @@ public: typedef typename Superclass::TargetValueType TargetValueType; typedef typename Superclass::TargetSampleType TargetSampleType; typedef typename Superclass::TargetListSampleType TargetListSampleType; - typedef typename Superclass::ConfidenceValueType ConfidenceValueType; - typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; - typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; - + itkNewMacro(Self); itkTypeMacro(PCAModel, DimensionalityReductionModel); @@ -47,8 +44,8 @@ protected: PCAModel(); ~PCAModel() ITK_OVERRIDE; - virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; - virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const ITK_OVERRIDE; + virtual TargetSampleType DoPredict(const InputSampleType& input) const ITK_OVERRIDE; + virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *) const ITK_OVERRIDE; private: shark::LinearModel<> m_encoder; diff --git a/include/PCAModel.txx b/include/PCAModel.txx index 92fdc3ee4c..8f48040388 100644 --- a/include/PCAModel.txx +++ b/include/PCAModel.txx @@ -19,7 +19,7 @@ namespace otb template <class TInputValue> PCAModel<TInputValue>::PCAModel() { - this->m_IsRegressionSupported = true; + this->m_IsDoPredictBatchMultiThreaded = true; } @@ -100,7 +100,7 @@ void PCAModel<TInputValue>::Load(const std::string & filename, const std::string template <class TInputValue> typename PCAModel<TInputValue>::TargetSampleType -PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueType *quality) const +PCAModel<TInputValue>::DoPredict(const InputSampleType & value) const { shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) @@ -126,7 +126,7 @@ PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueT template <class TInputValue> void PCAModel<TInputValue> -::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const +::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets) const { std::vector<shark::RealVector> features; diff --git a/include/SOMModel.h b/include/SOMModel.h index b7adddd663..bec029b9a4 100644 --- a/include/SOMModel.h +++ b/include/SOMModel.h @@ -15,7 +15,7 @@ namespace otb { -template <class TInputValue> +template <class TInputValue, unsigned int MapDimension>> class ITK_EXPORT SOMModel: public DimensionalityReductionModel<TInputValue,TInputValue> { @@ -33,9 +33,6 @@ public: typedef typename Superclass::TargetValueType TargetValueType; typedef typename Superclass::TargetSampleType TargetSampleType; typedef typename Superclass::TargetListSampleType TargetListSampleType; - typedef typename Superclass::ConfidenceValueType ConfidenceValueType; - typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; - typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> MapType; typedef typename MapType::SizeType SizeType; @@ -85,7 +82,7 @@ protected: SOMModel(); ~SOMModel() ITK_OVERRIDE; - virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + virtual TargetSampleType DoPredict(const InputSampleType& input) const ITK_OVERRIDE; private: typename MapType::Pointer m_SOMMap; diff --git a/include/SOMModel.txx b/include/SOMModel.txx index 5c6be685ba..872cd34c02 100644 --- a/include/SOMModel.txx +++ b/include/SOMModel.txx @@ -14,7 +14,6 @@ namespace otb template <class TInputValue> SOMModel<TInputValue>::SOMModel() { - this->m_IsRegressionSupported = true; } @@ -42,6 +41,7 @@ void SOMModel<TInputValue>::Train() estimator->Update(); m_SOMMap = estimator->GetOutput(); + std::cout << "dr of the first sample : " << m_SOMMap->GetWinner(m_ListSample->GetMeasurementVector(0)) << std::endl; } @@ -95,14 +95,14 @@ void SOMModel<TInputValue>::Load(const std::string & filename, const std::string template <class TInputValue> typename SOMModel<TInputValue>::TargetSampleType -SOMModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueType *quality) const +SOMModel<TInputValue>::DoPredict(const InputSampleType & value) const { unsigned int dimension =MapType::ImageDimension; TargetSampleType target; target.SetSize(dimension); auto winner =m_SOMMap->GetWinner(value); - + // std::cout << winner << std::endl; for (int i=0; i< dimension ;i++) { target[i] = winner.GetElement(i); -- GitLab From 02e37fb06b2c01631155293c9ee3e0fdea385981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 18 May 2017 14:04:47 +0200 Subject: [PATCH 027/567] added code for saving a SOM as txt file, + some code cleaning --- include/DimensionalityReductionModel.h | 13 --- include/DimensionalityReductionModel.txx | 14 --- .../DimensionalityReductionModelFactory.txx | 20 +++- .../ImageDimensionalityReductionFilter.txx | 1 + include/SOMModel.h | 4 +- include/SOMModel.txx | 95 +++++++++++++++---- include/SOMModelFactory.h | 2 +- include/SOMModelFactory.txx | 18 ++-- include/cbLearningApplicationBaseDR.h | 9 +- include/cbLearningApplicationBaseDR.txx | 10 +- include/cbTrainSOM.txx | 24 ++--- 11 files changed, 131 insertions(+), 79 deletions(-) diff --git a/include/DimensionalityReductionModel.h b/include/DimensionalityReductionModel.h index 4f12b1e2ef..23ffad38bf 100644 --- a/include/DimensionalityReductionModel.h +++ b/include/DimensionalityReductionModel.h @@ -118,9 +118,6 @@ public: */ typename TargetListSampleType::Pointer PredictBatch(const InputListSampleType * input) const; - /** THIS METHOD IS DEPRECATED AND SHOULD NOT BE USED. */ - void PredictAll(); - /** Get the size of the output after dimensionality reduction */ virtual unsigned int GetDimension() = 0; @@ -149,13 +146,6 @@ public: itkGetConstObjectMacro(InputListSample,InputListSampleType); //@} - /**\name Classification output accessors */ - //@{ - /** Set the target labels (to be used before training) */ - itkSetObjectMacro(TargetListSample,TargetListSampleType); - /** Get the target labels (to be used after PredictAll) */ - itkGetObjectMacro(TargetListSample,TargetListSampleType); - //@} @@ -172,9 +162,6 @@ protected: /** Input list sample */ typename InputListSampleType::Pointer m_InputListSample; - /** Target list sample */ - typename TargetListSampleType::Pointer m_TargetListSample; - /** Is DoPredictBatch multi-threaded ? */ bool m_IsDoPredictBatchMultiThreaded; diff --git a/include/DimensionalityReductionModel.txx b/include/DimensionalityReductionModel.txx index ba20ee8e28..5f49754f8c 100644 --- a/include/DimensionalityReductionModel.txx +++ b/include/DimensionalityReductionModel.txx @@ -41,20 +41,6 @@ DimensionalityReductionModel<TInputValue,TOutputValue> {} -template <class TInputValue, class TOutputValue> -void -DimensionalityReductionModel<TInputValue,TOutputValue> -::PredictAll() -{ - itkWarningMacro("DimensionalityReductionModel::PredictAll() has been DEPRECATED. Use DimensionalityReductionModel::PredictBatch() instead."); - - typename TargetListSampleType::Pointer targets = this->GetTargetListSample(); - targets->Clear(); - - typename TargetListSampleType::Pointer tmpTargets = this->PredictBatch(this->GetInputListSample()); - - targets->Graft(tmpTargets); -} template <class TInputValue, class TOutputValue> typename DimensionalityReductionModel<TInputValue,TOutputValue> diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 5fba93346e..240d68ad71 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -43,7 +43,10 @@ using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTa template <class TInputValue, class TTargetValue> -using SOM3DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 2> ; +using SOM2DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 2> ; + +template <class TInputValue, class TTargetValue> +using SOM3DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 3> ; template <class TInputValue, class TOutputValue> typename DimensionalityReductionModel<TInputValue,TOutputValue>::Pointer @@ -103,6 +106,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> RegisterFactory(SOM3DModelFactory<TInputValue,TOutputValue>::New()); + RegisterFactory(SOM2DModelFactory<TInputValue,TOutputValue>::New()); #ifdef OTB_USE_SHARK RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); @@ -138,11 +142,19 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> { // SOM - SOM3DModelFactory<TInputValue,TOutputValue> *somFactory = + SOM3DModelFactory<TInputValue,TOutputValue> *som3dFactory = dynamic_cast<SOM3DModelFactory<TInputValue,TOutputValue> *>(*itFac); - if (somFactory) + if (som3dFactory) + { + itk::ObjectFactoryBase::UnRegisterFactory(som3dFactory); + continue; + } + + SOM2DModelFactory<TInputValue,TOutputValue> *som2dFactory = + dynamic_cast<SOM2DModelFactory<TInputValue,TOutputValue> *>(*itFac); + if (som2dFactory) { - itk::ObjectFactoryBase::UnRegisterFactory(somFactory); + itk::ObjectFactoryBase::UnRegisterFactory(som2dFactory); continue; } #ifdef OTB_USE_SHARK diff --git a/include/ImageDimensionalityReductionFilter.txx b/include/ImageDimensionalityReductionFilter.txx index 9060270636..a072b48fce 100644 --- a/include/ImageDimensionalityReductionFilter.txx +++ b/include/ImageDimensionalityReductionFilter.txx @@ -134,6 +134,7 @@ void ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage>:: { Superclass::GenerateOutputInformation(); this->GetOutput()->SetNumberOfComponentsPerPixel( m_Model->GetDimension() ); + std::cout << m_Model->GetDimension() << std::endl; } diff --git a/include/SOMModel.h b/include/SOMModel.h index bec029b9a4..b7970a2970 100644 --- a/include/SOMModel.h +++ b/include/SOMModel.h @@ -15,7 +15,7 @@ namespace otb { -template <class TInputValue, unsigned int MapDimension>> +template <class TInputValue, unsigned int MapDimension> class ITK_EXPORT SOMModel: public DimensionalityReductionModel<TInputValue,TInputValue> { @@ -34,7 +34,7 @@ public: typedef typename Superclass::TargetSampleType TargetSampleType; typedef typename Superclass::TargetListSampleType TargetListSampleType; - typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> MapType; + typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, MapDimension> MapType; typedef typename MapType::SizeType SizeType; typedef otb::SOM<InputListSampleType, MapType> EstimatorType; diff --git a/include/SOMModel.txx b/include/SOMModel.txx index 872cd34c02..9940f12d16 100644 --- a/include/SOMModel.txx +++ b/include/SOMModel.txx @@ -7,24 +7,30 @@ #include "itkMacro.h" + +// test text file +#include "itkImageRegionIterator.h" +#include "itkImageRegionConstIterator.h" +#include <fstream> + namespace otb { -template <class TInputValue> -SOMModel<TInputValue>::SOMModel() +template <class TInputValue, unsigned int MapDimension> +SOMModel<TInputValue, MapDimension>::SOMModel() { } -template <class TInputValue> -SOMModel<TInputValue>::~SOMModel() +template <class TInputValue, unsigned int MapDimension> +SOMModel<TInputValue, MapDimension>::~SOMModel() { } -template <class TInputValue> -void SOMModel<TInputValue>::Train() +template <class TInputValue, unsigned int MapDimension> +void SOMModel<TInputValue, MapDimension>::Train() { typename EstimatorType::Pointer estimator = EstimatorType::New(); @@ -45,8 +51,8 @@ void SOMModel<TInputValue>::Train() } -template <class TInputValue> -bool SOMModel<TInputValue>::CanReadFile(const std::string & filename) +template <class TInputValue, unsigned int MapDimension> +bool SOMModel<TInputValue, MapDimension>::CanReadFile(const std::string & filename) { try { @@ -60,42 +66,91 @@ bool SOMModel<TInputValue>::CanReadFile(const std::string & filename) } -template <class TInputValue> -bool SOMModel<TInputValue>::CanWriteFile(const std::string & filename) +template <class TInputValue, unsigned int MapDimension> +bool SOMModel<TInputValue, MapDimension>::CanWriteFile(const std::string & filename) { return true; } -template <class TInputValue> -void SOMModel<TInputValue>::Save(const std::string & filename, const std::string & name) +template <class TInputValue, unsigned int MapDimension> +void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, const std::string & name) { std::cout << m_SOMMap->GetNumberOfComponentsPerPixel() << std::endl; //Ecriture auto kwl = m_SOMMap->GetImageKeywordlist(); - //kwl.AddKey("MachineLearningModelType", "SOM"); - //m_SOMMap->SetImageKeywordList(kwl); + kwl.AddKey("MachineLearningModelType", "SOM"+std::to_string(MapDimension)); + m_SOMMap->SetImageKeywordList(kwl); auto writer = otb::ImageFileWriter<MapType>::New(); writer->SetInput(m_SOMMap); writer->SetFileName(filename); writer->Update(); + + // test text + itk::ImageRegionConstIterator<MapType> inputIterator(m_SOMMap,m_SOMMap->GetLargestPossibleRegion()); + std::ofstream ofs(filename+"2"); + ofs << "SOM" << std::endl; + ofs << MapDimension << std::endl; + ofs << m_SOMMap->GetLargestPossibleRegion().GetSize() << std::endl; + ofs << inputIterator.Get().GetNumberOfElements() << std::endl;; + while(!inputIterator.IsAtEnd()){ + InputSampleType vect = inputIterator.Get(); + for (size_t i=0;i<vect.GetNumberOfElements();i++){ + ofs << vect[i] << " " ; + } + ofs << std::endl; + + ++inputIterator; + } + ofs.close(); + } -template <class TInputValue> -void SOMModel<TInputValue>::Load(const std::string & filename, const std::string & name) +template <class TInputValue, unsigned int MapDimension> +void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, const std::string & name) { auto reader = otb::ImageFileReader<MapType>::New(); reader->SetFileName(filename); reader->Update(); - //std::cout << reader->GetOutput()->GetImageKeywordlist().GetMetadataByKey("MachineLearningModelType") << '\n'; + if (reader->GetOutput()->GetImageKeywordlist().GetMetadataByKey("MachineLearningModelType") != "SOM"+std::to_string(MapDimension)){ + itkExceptionMacro(<< "Error opening " << filename.c_str() ); + } m_SOMMap = reader->GetOutput(); + + // test text + std::ifstream ifs(filename+"2"); + std::string model_type_str; + std::string dimension_str; + std::string size_str; + std::string number_of_elements_str; + SizeType size; + + std::getline(ifs,model_type_str); + std::getline(ifs,dimension_str); + std::getline(ifs,size_str); + std::getline(ifs,number_of_elements_str); + + for (int i=0 ; i<MapDimension; i++) + { + + } + + while (!ifs.eof()) + { + std::string line; + std::getline(ifs, line); + } + ifs.close(); + std::cout << "model type " << model_type_str << std::endl; + std::cout << "dimension " << dimension_str << std::endl; + std::cout << "size " << size_str << std::endl; } -template <class TInputValue> -typename SOMModel<TInputValue>::TargetSampleType -SOMModel<TInputValue>::DoPredict(const InputSampleType & value) const +template <class TInputValue, unsigned int MapDimension> +typename SOMModel<TInputValue, MapDimension>::TargetSampleType +SOMModel<TInputValue, MapDimension>::DoPredict(const InputSampleType & value) const { unsigned int dimension =MapType::ImageDimension; TargetSampleType target; diff --git a/include/SOMModelFactory.h b/include/SOMModelFactory.h index 0a3a9dd7a3..c078b07106 100644 --- a/include/SOMModelFactory.h +++ b/include/SOMModelFactory.h @@ -8,7 +8,7 @@ namespace otb { -template <class TInputValue, class TTargetValue> +template <class TInputValue, class TTargetValue, unsigned int MapDimension> class ITK_EXPORT SOMModelFactory : public itk::ObjectFactoryBase { public: diff --git a/include/SOMModelFactory.txx b/include/SOMModelFactory.txx index 0df39c43c4..396a5f0ac9 100644 --- a/include/SOMModelFactory.txx +++ b/include/SOMModelFactory.txx @@ -28,8 +28,8 @@ namespace otb { -template <class TInputValue, class TOutputValue> -SOMModelFactory<TInputValue,TOutputValue>::SOMModelFactory() +template <class TInputValue, class TOutputValue, unsigned int MapDimension> +SOMModelFactory<TInputValue,TOutputValue,MapDimension>::SOMModelFactory() { std::string classOverride = std::string("DimensionalityReductionModel"); @@ -40,22 +40,22 @@ SOMModelFactory<TInputValue,TOutputValue>::SOMModelFactory() "SOM DR Model", 1, // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); - itk::CreateObjectFunction<SOMModel<TInputValue>>::New()); + itk::CreateObjectFunction<SOMModel<TInputValue, MapDimension>>::New()); } -template <class TInputValue, class TOutputValue> -SOMModelFactory<TInputValue,TOutputValue>::~SOMModelFactory() +template <class TInputValue, class TOutputValue, unsigned int MapDimension> +SOMModelFactory<TInputValue,TOutputValue,MapDimension>::~SOMModelFactory() { } -template <class TInputValue, class TOutputValue> -const char* SOMModelFactory<TInputValue,TOutputValue>::GetITKSourceVersion(void) const +template <class TInputValue, class TOutputValue, unsigned int MapDimension> +const char* SOMModelFactory<TInputValue,TOutputValue,MapDimension>::GetITKSourceVersion(void) const { return ITK_SOURCE_VERSION; } -template <class TInputValue, class TOutputValue> -const char* SOMModelFactory<TInputValue,TOutputValue>::GetDescription() const +template <class TInputValue, class TOutputValue, unsigned int MapDimension> +const char* SOMModelFactory<TInputValue,TOutputValue,MapDimension>::GetDescription() const { return "SOM model factory"; } diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 5ff2e90442..f78dc01e27 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -87,9 +87,11 @@ public: // Dimensionality reduction models - typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> MapType; - typedef otb::SOM<ListSampleType, MapType> EstimatorType; - typedef otb::SOMModel<InputValueType> SOMModelType; + typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType; + typedef otb::SOMModel<InputValueType, 3> SOM3DModelType; + + typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType; + typedef otb::SOMModel<InputValueType, 2> SOM2DModelType; #ifdef OTB_USE_SHARK typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; @@ -130,6 +132,7 @@ private: template <class autoencoderchoice> void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + template <class somchoice> void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); #endif //@} diff --git a/include/cbLearningApplicationBaseDR.txx b/include/cbLearningApplicationBaseDR.txx index 885484638c..12f8d69d9c 100644 --- a/include/cbLearningApplicationBaseDR.txx +++ b/include/cbLearningApplicationBaseDR.txx @@ -101,9 +101,15 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> if(modelName == "som") { - TrainSOM(trainingListSample,modelPath); + TrainSOM<SOM2DModelType >(trainingListSample,modelPath); } - if(modelName == "autoencoder") + + if(modelName == "som3d") + { + TrainSOM<SOM3DModelType >(trainingListSample,modelPath); + } + + if(modelName == "autoencoder") { #ifdef OTB_USE_SHARK TrainAutoencoder<AutoencoderModelType>(trainingListSample,modelPath); diff --git a/include/cbTrainSOM.txx b/include/cbTrainSOM.txx index 4951b17725..10d62fb80b 100644 --- a/include/cbTrainSOM.txx +++ b/include/cbTrainSOM.txx @@ -14,12 +14,16 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> ::InitSOMParams() { - AddChoice("model.som", "OTB SOM"); SetParameterDescription("model.som", "This group of parameters allows setting SOM parameters. " ); + AddChoice("model.som3d", "OTB SOM"); + SetParameterDescription("model.som3d", + "This group of parameters allows setting SOM parameters. " + ); + AddParameter(ParameterType_StringList , "model.som.s", "Size"); SetParameterDescription("model.som.s", "Size of the SOM map"); MandatoryOff("model.som.s"); @@ -73,31 +77,29 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> } template <class TInputValue, class TOutputValue> +template <typename somchoice> void cbLearningApplicationBaseDR<TInputValue,TOutputValue> ::TrainSOM(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { - - //std::cout << std::stoi(s[0]) << std::endl; - typename SOMModelType::Pointer dimredTrainer = SOMModelType::New(); + using TemplateEstimatorType = typename somchoice::EstimatorType; + typename somchoice::Pointer dimredTrainer = somchoice::New(); + unsigned int dim = dimredTrainer->GetDimension(); dimredTrainer->SetNumberOfIterations(GetParameterInt("model.som.ni")); dimredTrainer->SetBetaInit(GetParameterFloat("model.som.bi")); dimredTrainer->SetBetaEnd(GetParameterFloat("model.som.bf")); dimredTrainer->SetMaxWeight(GetParameterFloat("model.som.iv")); - std::cout << "0" << std::endl; - typename EstimatorType::SizeType size; + typename TemplateEstimatorType::SizeType size; std::vector<std::basic_string<char>> s= GetParameterStringList("model.som.s"); - for (int i=0; i<3; i++){ // This will be templated later (the 3) + for (int i=0; i<dim; i++){ // This will be templated later (the 3) size[i]=std::stoi(s[i]); } dimredTrainer->SetMapSize(size); - std::cout << "1" << std::endl; - typename EstimatorType::SizeType radius; + typename TemplateEstimatorType::SizeType radius; std::vector<std::basic_string<char>> n= GetParameterStringList("model.som.n"); - for (int i=0; i<3; i++){ // This will be templated later (the 3) + for (int i=0; i<dim; i++){ // This will be templated later (the 3) radius[i]=std::stoi(n[i]); } - std::cout << "2" << std::endl; dimredTrainer->SetNeighborhoodSizeInit(radius); dimredTrainer->SetListSample(trainingListSample); dimredTrainer->Train(); -- GitLab From de38d4309f9c6156193228e869e3994c9b036add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 23 May 2017 10:23:13 +0200 Subject: [PATCH 028/567] serialization work in progress --- include/SOMModel.h | 1 + include/SOMModel.txx | 103 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 92 insertions(+), 12 deletions(-) diff --git a/include/SOMModel.h b/include/SOMModel.h index b7970a2970..290ee45c60 100644 --- a/include/SOMModel.h +++ b/include/SOMModel.h @@ -36,6 +36,7 @@ public: typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, MapDimension> MapType; typedef typename MapType::SizeType SizeType; + typedef typename MapType::SpacingType SpacingType; typedef otb::SOM<InputListSampleType, MapType> EstimatorType; diff --git a/include/SOMModel.txx b/include/SOMModel.txx index 9940f12d16..983e5f62a6 100644 --- a/include/SOMModel.txx +++ b/include/SOMModel.txx @@ -13,6 +13,9 @@ #include "itkImageRegionConstIterator.h" #include <fstream> + +#include "itkImage.h" + namespace otb { @@ -92,14 +95,18 @@ void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, con std::ofstream ofs(filename+"2"); ofs << "SOM" << std::endl; ofs << MapDimension << std::endl; - ofs << m_SOMMap->GetLargestPossibleRegion().GetSize() << std::endl; + SizeType size = m_SOMMap->GetLargestPossibleRegion().GetSize() ; + //ofs << m_SOMMap->GetLargestPossibleRegion().GetSize() << std::endl; + for (size_t i=0;i<MapDimension;i++){ + ofs << size[i] << " " ; + } + ofs << std::endl; ofs << inputIterator.Get().GetNumberOfElements() << std::endl;; while(!inputIterator.IsAtEnd()){ InputSampleType vect = inputIterator.Get(); for (size_t i=0;i<vect.GetNumberOfElements();i++){ ofs << vect[i] << " " ; } - ofs << std::endl; ++inputIterator; } @@ -110,6 +117,7 @@ void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, con template <class TInputValue, unsigned int MapDimension> void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, const std::string & name) { + /* auto reader = otb::ImageFileReader<MapType>::New(); reader->SetFileName(filename); reader->Update(); @@ -117,30 +125,101 @@ void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, con itkExceptionMacro(<< "Error opening " << filename.c_str() ); } m_SOMMap = reader->GetOutput(); - + */ // test text + + + + + + std::ifstream ifs(filename+"2"); std::string model_type_str; std::string dimension_str; std::string size_str; std::string number_of_elements_str; - SizeType size; std::getline(ifs,model_type_str); std::getline(ifs,dimension_str); - std::getline(ifs,size_str); - std::getline(ifs,number_of_elements_str); - + if (model_type_str+dimension_str != "SOM"+std::to_string(MapDimension)){ + itkExceptionMacro(<< "Error opening " << filename.c_str() ); + } + + std::cout << "bug-1?" << std::endl; + SizeType size; + itk::Point<double, MapDimension> origin; + SpacingType spacing; + itk::Index< MapDimension > index; for (int i=0 ; i<MapDimension; i++) { - + std::getline(ifs,size_str , ' '); + size[i] = stof(size_str); + origin[i] = 0; + spacing[i]=0; + index[i]=0; } - while (!ifs.eof()) - { - std::string line; - std::getline(ifs, line); + + std::getline(ifs,number_of_elements_str); + std::getline(ifs,number_of_elements_str); + std::cout << "bug0?" << number_of_elements_str << std::endl; + auto number_of_elements = stof(number_of_elements_str); + + //typedef itk::Image< unsigned char, 3 > ImageType; + //typename MapType::Pointer image = MapType::New(); + m_SOMMap = MapType::New(); + typename MapType::RegionType region; + region.SetSize( size ); + m_SOMMap->SetNumberOfComponentsPerPixel(number_of_elements); + region.SetIndex( index ); + m_SOMMap->SetRegions( region ); + m_SOMMap->Allocate(); + + std::cout << m_SOMMap << std::endl; +/* + + std::cout << "bug1?" << number_of_elements << std::endl; + itk::ImageRegion<MapDimension> outputRegion; + + + std::cout << "bugoriggin?" << origin << std::endl; + m_SOMMap->SetNumberOfComponentsPerPixel(number_of_elements); + outputRegion.SetIndex(index); + std::cout << "setindex?" << index << std::endl; + outputRegion.SetSize(size); + std::cout << origin << size << std::endl; + m_SOMMap->SetLargestPossibleRegion(outputRegion); + std::cout << "setRegion" << origin << std::endl; + + m_SOMMap->Allocate(); + std::cout << "bug2?" << std::endl; + + */ + itk::ImageRegionIterator<MapType> outputIterator(m_SOMMap,region); + + std::string value; + size_t j=0; + while(!outputIterator.IsAtEnd()){ + std::cout << j << std::endl; + std::getline(ifs,value, ' '); + itk::VariableLengthVector<float> vect(number_of_elements); + for (int i=0 ; i<number_of_elements; i++) + { + std::getline(ifs,value , ' '); + //std::cout << value << " "; + std::cout << stof(value) << " "; + vect[i]=std::stof(value); + } + std::cout << vect << std::endl; + outputIterator.Set(vect); + ++outputIterator; + j++; + std::cout << j << "end" << std::endl; + //std::cout << value << std::endl; + //std::string line; + //std::getline(ifs, line); } + std::cout << j << std::endl; ifs.close(); std::cout << "model type " << model_type_str << std::endl; std::cout << "dimension " << dimension_str << std::endl; -- GitLab From 039141fc2d5f4fe2274f00a64d46c640cc2f26d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 24 May 2017 15:35:31 +0200 Subject: [PATCH 029/567] serialization of som models done, added som maps of dimension 4 and 5 --- .../DimensionalityReductionModelFactory.txx | 28 +++- include/SOMModel.txx | 135 ++++++------------ include/cbLearningApplicationBaseDR.h | 12 +- include/cbLearningApplicationBaseDR.txx | 49 ++----- include/cbTrainSOM.txx | 51 ++++++- 5 files changed, 143 insertions(+), 132 deletions(-) diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 240d68ad71..5195605a89 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -48,6 +48,12 @@ using SOM2DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 2> ; template <class TInputValue, class TTargetValue> using SOM3DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 3> ; +template <class TInputValue, class TTargetValue> +using SOM4DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 4> ; + +template <class TInputValue, class TTargetValue> +using SOM5DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 5> ; + template <class TInputValue, class TOutputValue> typename DimensionalityReductionModel<TInputValue,TOutputValue>::Pointer DimensionalityReductionModelFactory<TInputValue,TOutputValue> @@ -104,9 +110,10 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> - - RegisterFactory(SOM3DModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(SOM2DModelFactory<TInputValue,TOutputValue>::New()); + RegisterFactory(SOM3DModelFactory<TInputValue,TOutputValue>::New()); + RegisterFactory(SOM4DModelFactory<TInputValue,TOutputValue>::New()); + RegisterFactory(SOM5DModelFactory<TInputValue,TOutputValue>::New()); #ifdef OTB_USE_SHARK RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); @@ -142,6 +149,23 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> { // SOM + + SOM5DModelFactory<TInputValue,TOutputValue> *som5dFactory = + dynamic_cast<SOM5DModelFactory<TInputValue,TOutputValue> *>(*itFac); + if (som5dFactory) + { + itk::ObjectFactoryBase::UnRegisterFactory(som5dFactory); + continue; + } + + SOM4DModelFactory<TInputValue,TOutputValue> *som4dFactory = + dynamic_cast<SOM4DModelFactory<TInputValue,TOutputValue> *>(*itFac); + if (som4dFactory) + { + itk::ObjectFactoryBase::UnRegisterFactory(som4dFactory); + continue; + } + SOM3DModelFactory<TInputValue,TOutputValue> *som3dFactory = dynamic_cast<SOM3DModelFactory<TInputValue,TOutputValue> *>(*itFac); if (som3dFactory) diff --git a/include/SOMModel.txx b/include/SOMModel.txx index 983e5f62a6..d6c9f02c45 100644 --- a/include/SOMModel.txx +++ b/include/SOMModel.txx @@ -54,6 +54,7 @@ void SOMModel<TInputValue, MapDimension>::Train() } + template <class TInputValue, unsigned int MapDimension> bool SOMModel<TInputValue, MapDimension>::CanReadFile(const std::string & filename) { @@ -75,11 +76,27 @@ bool SOMModel<TInputValue, MapDimension>::CanWriteFile(const std::string & filen return true; } +template<typename T> +std::ostream& binary_write(std::ostream& stream, const T& value){ + return stream.write(reinterpret_cast<const char*>(&value), sizeof(T)); +} + + +std::ostream& binary_write_string(std::ofstream& stream, const std::string& value){ + return stream.write(value.c_str(), value.length()); +} + +template<typename T> +std::istream & binary_read(std::istream& stream, T& value){ + return stream.read(reinterpret_cast<char*>(&value), sizeof(T)); +} + + + template <class TInputValue, unsigned int MapDimension> void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, const std::string & name) { - std::cout << m_SOMMap->GetNumberOfComponentsPerPixel() << std::endl; - + //Ecriture auto kwl = m_SOMMap->GetImageKeywordlist(); kwl.AddKey("MachineLearningModelType", "SOM"+std::to_string(MapDimension)); @@ -92,22 +109,21 @@ void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, con // test text itk::ImageRegionConstIterator<MapType> inputIterator(m_SOMMap,m_SOMMap->GetLargestPossibleRegion()); - std::ofstream ofs(filename+"2"); - ofs << "SOM" << std::endl; - ofs << MapDimension << std::endl; + inputIterator.GoToBegin(); + std::ofstream ofs(filename+"2", std::ios::binary); + binary_write_string(ofs,"som"); + binary_write(ofs,static_cast<int>(MapDimension)); SizeType size = m_SOMMap->GetLargestPossibleRegion().GetSize() ; - //ofs << m_SOMMap->GetLargestPossibleRegion().GetSize() << std::endl; for (size_t i=0;i<MapDimension;i++){ - ofs << size[i] << " " ; + binary_write(ofs,size[i]); } - ofs << std::endl; - ofs << inputIterator.Get().GetNumberOfElements() << std::endl;; + + binary_write(ofs,inputIterator.Get().GetNumberOfElements()); while(!inputIterator.IsAtEnd()){ InputSampleType vect = inputIterator.Get(); for (size_t i=0;i<vect.GetNumberOfElements();i++){ - ofs << vect[i] << " " ; + binary_write(ofs,vect[i]); } - ++inputIterator; } ofs.close(); @@ -117,113 +133,58 @@ void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, con template <class TInputValue, unsigned int MapDimension> void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, const std::string & name) { - /* - auto reader = otb::ImageFileReader<MapType>::New(); - reader->SetFileName(filename); - reader->Update(); - if (reader->GetOutput()->GetImageKeywordlist().GetMetadataByKey("MachineLearningModelType") != "SOM"+std::to_string(MapDimension)){ - itkExceptionMacro(<< "Error opening " << filename.c_str() ); - } - m_SOMMap = reader->GetOutput(); - */ - // test text - - + std::ifstream ifs(filename+"2", std::ios::binary); + /** Read the model key (should be som) */ + char s[]=" "; + for (int i=0; i<3; i++){ + binary_read(ifs,s[i]); + } + std::string modelType(s); + /** Read the dimension of the map (should be equal to MapDimension) */ - std::ifstream ifs(filename+"2"); - std::string model_type_str; - std::string dimension_str; - std::string size_str; - std::string number_of_elements_str; + int dimension; + binary_read(ifs,dimension); - std::getline(ifs,model_type_str); - std::getline(ifs,dimension_str); - if (model_type_str+dimension_str != "SOM"+std::to_string(MapDimension)){ + if (modelType != "som" || dimension != MapDimension){ itkExceptionMacro(<< "Error opening " << filename.c_str() ); } - std::cout << "bug-1?" << std::endl; SizeType size; - itk::Point<double, MapDimension> origin; - SpacingType spacing; itk::Index< MapDimension > index; for (int i=0 ; i<MapDimension; i++) { - std::getline(ifs,size_str , ' '); - size[i] = stof(size_str); - origin[i] = 0; - spacing[i]=0; + binary_read(ifs,size[i]); index[i]=0; } + unsigned int numberOfElements; + binary_read(ifs,numberOfElements); - std::getline(ifs,number_of_elements_str); - std::getline(ifs,number_of_elements_str); - std::cout << "bug0?" << number_of_elements_str << std::endl; - auto number_of_elements = stof(number_of_elements_str); - - //typedef itk::Image< unsigned char, 3 > ImageType; - //typename MapType::Pointer image = MapType::New(); m_SOMMap = MapType::New(); typename MapType::RegionType region; region.SetSize( size ); - m_SOMMap->SetNumberOfComponentsPerPixel(number_of_elements); + m_SOMMap->SetNumberOfComponentsPerPixel(numberOfElements); region.SetIndex( index ); m_SOMMap->SetRegions( region ); m_SOMMap->Allocate(); - std::cout << m_SOMMap << std::endl; -/* - - std::cout << "bug1?" << number_of_elements << std::endl; - itk::ImageRegion<MapDimension> outputRegion; - - - std::cout << "bugoriggin?" << origin << std::endl; - m_SOMMap->SetNumberOfComponentsPerPixel(number_of_elements); - outputRegion.SetIndex(index); - std::cout << "setindex?" << index << std::endl; - outputRegion.SetSize(size); - std::cout << origin << size << std::endl; - m_SOMMap->SetLargestPossibleRegion(outputRegion); - std::cout << "setRegion" << origin << std::endl; - - m_SOMMap->Allocate(); - std::cout << "bug2?" << std::endl; - - */ itk::ImageRegionIterator<MapType> outputIterator(m_SOMMap,region); - + outputIterator.GoToBegin(); std::string value; - size_t j=0; while(!outputIterator.IsAtEnd()){ - std::cout << j << std::endl; - std::getline(ifs,value, ' '); - itk::VariableLengthVector<float> vect(number_of_elements); - for (int i=0 ; i<number_of_elements; i++) + InputSampleType vect(numberOfElements); + for (int i=0 ; i<numberOfElements; i++) { - std::getline(ifs,value , ' '); - //std::cout << value << " "; - std::cout << stof(value) << " "; - vect[i]=std::stof(value); + binary_read(ifs,vect[i]); } - std::cout << vect << std::endl; outputIterator.Set(vect); ++outputIterator; - j++; - std::cout << j << "end" << std::endl; - //std::cout << value << std::endl; - //std::string line; - //std::getline(ifs, line); } - std::cout << j << std::endl; + ifs.close(); - std::cout << "model type " << model_type_str << std::endl; - std::cout << "dimension " << dimension_str << std::endl; - std::cout << "size " << size_str << std::endl; } @@ -236,8 +197,6 @@ SOMModel<TInputValue, MapDimension>::DoPredict(const InputSampleType & value) co target.SetSize(dimension); auto winner =m_SOMMap->GetWinner(value); - // std::cout << winner << std::endl; - for (int i=0; i< dimension ;i++) { target[i] = winner.GetElement(i); } diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index f78dc01e27..328373b24f 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -86,12 +86,19 @@ public: typedef typename ModelType::InputListSampleType ListSampleType; // Dimensionality reduction models + + typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType; + typedef otb::SOMModel<InputValueType, 2> SOM2DModelType; typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType; typedef otb::SOMModel<InputValueType, 3> SOM3DModelType; - typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType; - typedef otb::SOMModel<InputValueType, 2> SOM2DModelType; + typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType; + typedef otb::SOMModel<InputValueType, 4> SOM4DModelType; + + typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; + typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; + #ifdef OTB_USE_SHARK typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; @@ -134,6 +141,7 @@ private: void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); template <class somchoice> void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); #endif //@} }; diff --git a/include/cbLearningApplicationBaseDR.txx b/include/cbLearningApplicationBaseDR.txx index 12f8d69d9c..916d7d6f82 100644 --- a/include/cbLearningApplicationBaseDR.txx +++ b/include/cbLearningApplicationBaseDR.txx @@ -44,9 +44,10 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> { AddDocTag(Tags::Learning); - // main choice parameter that will contain all machine learning options + // main choice parameter that will contain all dimensionality reduction options AddParameter(ParameterType_Choice, "model", "moddel to use for the training"); SetParameterDescription("model", "Choice of the dimensionality reduction model to use for the training."); + InitSOMParams(); #ifdef OTB_USE_SHARK @@ -60,32 +61,7 @@ template <class TInputValue, class TOutputValue> void cbLearningApplicationBaseDR<TInputValue,TOutputValue> ::Reduce(typename ListSampleType::Pointer validationListSample,std::string modelPath) -{/* - // Setup fake reporter - RGBAPixelConverter<int,int>::Pointer dummyFilter = - RGBAPixelConverter<int,int>::New(); - dummyFilter->SetProgress(0.0f); - this->AddProcess(dummyFilter,"Classify..."); - dummyFilter->InvokeEvent(itk::StartEvent()); - - // load a machine learning model from file and predict the input sample list - ModelPointerType model = ModelFactoryType::CreateMachineLearningModel(modelPath, - ModelFactoryType::ReadMode); - - if (model.IsNull()) - { - otbAppLogFATAL(<< "Error when loading model " << modelPath); - } - - model->Load(modelPath); - model->SetRegressionMode(this->m_RegressionFlag); - model->SetInputListSample(validationListSample); - model->SetTargetListSample(predictedList); - model->PredictAll(); - - // update reporter - dummyFilter->UpdateProgress(1.0f); - dummyFilter->InvokeEvent(itk::EndEvent());*/ +{ } template <class TInputValue, class TOutputValue> @@ -95,20 +71,15 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> std::string modelPath) { - // get the name of the chosen machine learning model - const std::string modelName = GetParameterString("model"); - // call specific train function + // get the name of the chosen machine learning model + const std::string modelName = GetParameterString("model"); + // call specific train function if(modelName == "som") - { - TrainSOM<SOM2DModelType >(trainingListSample,modelPath); - } - - if(modelName == "som3d") - { - TrainSOM<SOM3DModelType >(trainingListSample,modelPath); - } - + { + BeforeTrainSOM(trainingListSample,modelPath); + } + if(modelName == "autoencoder") { #ifdef OTB_USE_SHARK diff --git a/include/cbTrainSOM.txx b/include/cbTrainSOM.txx index 10d62fb80b..539504b92b 100644 --- a/include/cbTrainSOM.txx +++ b/include/cbTrainSOM.txx @@ -24,6 +24,20 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> "This group of parameters allows setting SOM parameters. " ); + AddChoice("model.som4d", "OTB SOM"); + SetParameterDescription("model.som4d", + "This group of parameters allows setting SOM parameters. " + ); + + AddChoice("model.som5d", "OTB SOM"); + SetParameterDescription("model.som5d", + "This group of parameters allows setting SOM parameters. " + ); + + + AddParameter(ParameterType_Int, "model.som.dim","Dimension of the map"); + SetParameterDescription("model.som.dim","Dimension of the SOM map."); + AddParameter(ParameterType_StringList , "model.som.s", "Size"); SetParameterDescription("model.som.s", "Size of the SOM map"); MandatoryOff("model.som.s"); @@ -63,7 +77,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> AddParameter(ParameterType_Float, "model.som.iv", "InitialValue"); SetParameterDescription("model.som.iv", "Maximum initial neuron weight"); MandatoryOff("model.som.iv"); - ; + SetDefaultParameterInt("model.som.sx", 32); SetDefaultParameterInt("model.som.sy", 32); SetDefaultParameterInt("model.som.nx", 10); @@ -76,6 +90,41 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> } +template <class TInputValue, class TOutputValue> +void +cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, + std::string modelPath) +{ + int SomDim = GetParameterInt("model.som.dim"); + std::cout << SomDim << std::endl; + + if(SomDim == 2) + { + TrainSOM<SOM2DModelType >(trainingListSample,modelPath); + } + + if(SomDim == 3) + { + TrainSOM<SOM3DModelType >(trainingListSample,modelPath); + } + + if(SomDim == 4) + { + TrainSOM<SOM4DModelType >(trainingListSample,modelPath); + } + + if(SomDim == 5) + { + TrainSOM<SOM5DModelType >(trainingListSample,modelPath); + } + if(SomDim > 5 || SomDim < 2) + { + std::cerr << "invalid dimension" << std::endl; + } +} + + template <class TInputValue, class TOutputValue> template <typename somchoice> void cbLearningApplicationBaseDR<TInputValue,TOutputValue> -- GitLab From 4442d2af09e146ae328c39294c7e153d1ec14d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 24 May 2017 16:54:29 +0200 Subject: [PATCH 030/567] added new parameter tied/untied for autoencoders --- include/AutoencoderModel.txx | 12 +--- .../ImageDimensionalityReductionFilter.txx | 2 +- include/SOMModel.txx | 47 ++++++---------- include/cbLearningApplicationBaseDR.h | 4 ++ include/cbLearningApplicationBaseDR.txx | 2 +- include/cbTrainAutoencoder.txx | 55 +++++++++++++++++-- include/cbTrainSOM.txx | 18 +----- 7 files changed, 75 insertions(+), 65 deletions(-) diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 7f2b451647..dad8324514 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -57,7 +57,6 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() optimizer.step(error); std::cout<<i<<" "<<optimizer.solution().value<<std::endl; } - //std::cout<<optimizer.solution().value<<std::endl; m_net.setParameterVector(optimizer.solution().point); @@ -111,7 +110,6 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & fil m_net.read(ia); ifs.close(); m_NumberOfHiddenNeurons = m_net.numberOfHiddenNeurons(); - //this->m_Size = m_NumberOfHiddenNeurons; } @@ -119,6 +117,7 @@ template <class TInputValue, class AutoencoderType> typename AutoencoderModel<TInputValue,AutoencoderType>::TargetSampleType AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value) const { + std::cout << "SINGLE PIXEL " ; shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) { @@ -157,17 +156,10 @@ void AutoencoderModel<TInputValue,AutoencoderType> for(unsigned int a = 0; a < m_NumberOfHiddenNeurons; ++a){ target[a]=p[a]; - - //target.SetElement(a,p[a]); - - } - //std::cout << p << std::endl; targets->SetMeasurementVector(id,target); - ++id; - + ++id; } - } diff --git a/include/ImageDimensionalityReductionFilter.txx b/include/ImageDimensionalityReductionFilter.txx index a072b48fce..3dbfd16bfe 100644 --- a/include/ImageDimensionalityReductionFilter.txx +++ b/include/ImageDimensionalityReductionFilter.txx @@ -40,7 +40,7 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> this->SetNthOutput(0,TOutputImage::New()); this->SetNthOutput(1,ConfidenceImageType::New()); m_UseConfidenceMap = false; - m_BatchMode = false; + m_BatchMode = true; } template <class TInputImage, class TOutputImage, class TMaskImage> diff --git a/include/SOMModel.txx b/include/SOMModel.txx index d6c9f02c45..13765ccbfb 100644 --- a/include/SOMModel.txx +++ b/include/SOMModel.txx @@ -96,45 +96,32 @@ std::istream & binary_read(std::istream& stream, T& value){ template <class TInputValue, unsigned int MapDimension> void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, const std::string & name) { - -//Ecriture - auto kwl = m_SOMMap->GetImageKeywordlist(); - kwl.AddKey("MachineLearningModelType", "SOM"+std::to_string(MapDimension)); - m_SOMMap->SetImageKeywordList(kwl); - auto writer = otb::ImageFileWriter<MapType>::New(); - writer->SetInput(m_SOMMap); - writer->SetFileName(filename); - writer->Update(); - - - // test text - itk::ImageRegionConstIterator<MapType> inputIterator(m_SOMMap,m_SOMMap->GetLargestPossibleRegion()); - inputIterator.GoToBegin(); - std::ofstream ofs(filename+"2", std::ios::binary); - binary_write_string(ofs,"som"); - binary_write(ofs,static_cast<int>(MapDimension)); - SizeType size = m_SOMMap->GetLargestPossibleRegion().GetSize() ; - for (size_t i=0;i<MapDimension;i++){ + itk::ImageRegionConstIterator<MapType> inputIterator(m_SOMMap,m_SOMMap->GetLargestPossibleRegion()); + inputIterator.GoToBegin(); + std::ofstream ofs(filename, std::ios::binary); + binary_write_string(ofs,"som"); + binary_write(ofs,static_cast<int>(MapDimension)); + SizeType size = m_SOMMap->GetLargestPossibleRegion().GetSize() ; + for (size_t i=0;i<MapDimension;i++){ binary_write(ofs,size[i]); - } - - binary_write(ofs,inputIterator.Get().GetNumberOfElements()); - while(!inputIterator.IsAtEnd()){ - InputSampleType vect = inputIterator.Get(); - for (size_t i=0;i<vect.GetNumberOfElements();i++){ - binary_write(ofs,vect[i]); } + + binary_write(ofs,inputIterator.Get().GetNumberOfElements()); + while(!inputIterator.IsAtEnd()){ + InputSampleType vect = inputIterator.Get(); + for (size_t i=0;i<vect.GetNumberOfElements();i++){ + binary_write(ofs,vect[i]); + } ++inputIterator; - } - ofs.close(); - + } + ofs.close(); } template <class TInputValue, unsigned int MapDimension> void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, const std::string & name) { - std::ifstream ifs(filename+"2", std::ios::binary); + std::ifstream ifs(filename, std::ios::binary); /** Read the model key (should be som) */ char s[]=" "; diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 328373b24f..a45024aa47 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -136,9 +136,13 @@ private: void InitAutoencoderParams(); void InitPCAParams(); void InitSOMParams(); + + void BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); template <class autoencoderchoice> void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + template <class somchoice> void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); diff --git a/include/cbLearningApplicationBaseDR.txx b/include/cbLearningApplicationBaseDR.txx index 916d7d6f82..5603cca4f6 100644 --- a/include/cbLearningApplicationBaseDR.txx +++ b/include/cbLearningApplicationBaseDR.txx @@ -83,7 +83,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> if(modelName == "autoencoder") { #ifdef OTB_USE_SHARK - TrainAutoencoder<AutoencoderModelType>(trainingListSample,modelPath); + BeforeTrainAutoencoder(trainingListSample,modelPath); #else otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); #endif diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index feed6cf75e..82e21d17b6 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -21,6 +21,21 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> SetParameterDescription("model.autoencoder", "This group of parameters allows setting Shark autoencoder parameters. " ); + + + //Tied Autoencoder + AddParameter(ParameterType_Choice, "model.autoencoder.istied", + "tied weighth <tied/untied>"); + SetParameterDescription( + "model.autoencoder.istied", + "Parameter that determine if the weights are tied or not <tied/untied>"); + + + AddChoice("model.autoencoder.istied.yes","Tied weigths"); + AddChoice("model.autoencoder.istied.no","Untied weights"); + + + //Number Of Iterations AddParameter(ParameterType_Int, "model.autoencoder.nbiter", "Maximum number of iterations during training"); @@ -38,13 +53,41 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> "model.autoencoder.nbneuron", "The number of neurons in the hidden layer."); - //normalization - AddParameter(ParameterType_Float, "model.autoencoder.normalizer", "Strength of the normalization"); - SetParameterFloat("model.autoencoder.normalizer",0, false); - SetParameterDescription("model.autoencoder.normalizer", - "Strength of the L2 normalization used during training"); + //Regularization + AddParameter(ParameterType_Float, "model.autoencoder.regularization", "Strength of the regularization"); + SetParameterFloat("model.autoencoder.regularization",0, false); + SetParameterDescription("model.autoencoder.regularization", + "Strength of the L2 regularization used during training"); +} + + +template <class TInputValue, class TOutputValue> +void +cbLearningApplicationBaseDR<TInputValue,TOutputValue> +::BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample, + std::string modelPath) +{ + std::string TiedWeigth = GetParameterString("model.autoencoder.istied"); + std::cout << TiedWeigth << std::endl; + + if(TiedWeigth == "no") + { + TrainAutoencoder<AutoencoderModelType>(trainingListSample,modelPath); + } + + if(TiedWeigth == "yes") + { + TrainAutoencoder<TiedAutoencoderModelType>(trainingListSample,modelPath); + } + + if(TiedWeigth != "yes" && TiedWeigth != "no") + { + std::cerr << "istied : invalid choice <yes/no>" << std::endl; + } } + + template <class TInputValue, class TOutputValue> template <typename autoencoderchoice> void cbLearningApplicationBaseDR<TInputValue,TOutputValue> @@ -53,7 +96,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> typename autoencoderchoice::Pointer dimredTrainer = autoencoderchoice::New(); dimredTrainer->SetNumberOfHiddenNeurons(GetParameterInt("model.autoencoder.nbneuron")); dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); - dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.normalizer")); + dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.regularization")); dimredTrainer->SetInputListSample(trainingListSample); dimredTrainer->Train(); dimredTrainer->Save(modelPath); diff --git a/include/cbTrainSOM.txx b/include/cbTrainSOM.txx index 539504b92b..9ac28dd906 100644 --- a/include/cbTrainSOM.txx +++ b/include/cbTrainSOM.txx @@ -18,22 +18,6 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> SetParameterDescription("model.som", "This group of parameters allows setting SOM parameters. " ); - - AddChoice("model.som3d", "OTB SOM"); - SetParameterDescription("model.som3d", - "This group of parameters allows setting SOM parameters. " - ); - - AddChoice("model.som4d", "OTB SOM"); - SetParameterDescription("model.som4d", - "This group of parameters allows setting SOM parameters. " - ); - - AddChoice("model.som5d", "OTB SOM"); - SetParameterDescription("model.som5d", - "This group of parameters allows setting SOM parameters. " - ); - AddParameter(ParameterType_Int, "model.som.dim","Dimension of the map"); SetParameterDescription("model.som.dim","Dimension of the SOM map."); @@ -120,7 +104,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> } if(SomDim > 5 || SomDim < 2) { - std::cerr << "invalid dimension" << std::endl; + std::cerr << "k : invalid dimension" << std::endl; } } -- GitLab From 0c0351e2110bad051825f161fdc301774306c2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 24 May 2017 17:07:10 +0200 Subject: [PATCH 031/567] added denoising autoencoder (noise strength is now a parameter of cbdimensionalityreductiontrainer --- include/AutoencoderModel.h | 4 ++++ include/AutoencoderModel.txx | 11 ++++++----- include/cbTrainAutoencoder.txx | 7 +++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index eb65fdb1df..81b55a5fbf 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -37,6 +37,9 @@ public: itkGetMacro(Regularization,double); itkSetMacro(Regularization,double); + itkGetMacro(Noise,double); + itkSetMacro(Noise,double); + bool CanReadFile(const std::string & filename); bool CanWriteFile(const std::string & filename); @@ -60,6 +63,7 @@ private: unsigned int m_NumberOfHiddenNeurons; unsigned int m_NumberOfIterations; double m_Regularization; + double m_Noise; }; } // end namespace otb diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index dad8324514..5c7bc5d97e 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -11,6 +11,8 @@ #include <shark/Algorithms/GradientDescent/Rprop.h>// the RProp optimization algorithm #include <shark/ObjectiveFunctions/Loss/SquaredLoss.h> // squared loss used for regression #include <shark/ObjectiveFunctions/Regularizer.h> //L2 regulariziation +#include <shark/Models/ImpulseNoiseModel.h>//noise source to corrupt the inputs +#include <shark/Models/ConcatenatedModel.h>//to concatenate the noise with the model namespace otb { @@ -32,7 +34,6 @@ AutoencoderModel<TInputValue,AutoencoderType>::~AutoencoderModel() template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Train() { - std::vector<shark::RealVector> features; Shark::ListSampleToSharkVector(this->GetInputListSample(), features); @@ -42,10 +43,12 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() std::size_t inputs = dataDimension(inputSamples); m_net.setStructure(inputs, m_NumberOfHiddenNeurons); initRandomUniform(m_net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); - + shark::ImpulseNoiseModel noise(m_Noise,0.0);//set an input pixel with probability p to 0 + shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> m_net; + shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(inputSamples,inputSamples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; - shark::ErrorFunction error(trainSet, &m_net, &loss); + shark::ErrorFunction error(trainSet, &model, &loss); shark::TwoNormRegularizer regularizer(error.numberOfVariables()); error.setRegularizer(m_Regularization,®ularizer); @@ -117,7 +120,6 @@ template <class TInputValue, class AutoencoderType> typename AutoencoderModel<TInputValue,AutoencoderType>::TargetSampleType AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value) const { - std::cout << "SINGLE PIXEL " ; shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) { @@ -144,7 +146,6 @@ template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType> ::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets) const { - std::cout << "BATCH" << std::endl; std::vector<shark::RealVector> features; Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); shark::Data<shark::RealVector> data = shark::createDataFromRange(features); diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index 82e21d17b6..e120ae5e9b 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -58,6 +58,12 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> SetParameterFloat("model.autoencoder.regularization",0, false); SetParameterDescription("model.autoencoder.regularization", "Strength of the L2 regularization used during training"); + + //Noise strength + AddParameter(ParameterType_Float, "model.autoencoder.noise", "Strength of the noise"); + SetParameterFloat("model.autoencoder.noise",0, false); + SetParameterDescription("model.autoencoder.noise", + "Strength of the noise"); } @@ -97,6 +103,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> dimredTrainer->SetNumberOfHiddenNeurons(GetParameterInt("model.autoencoder.nbneuron")); dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.regularization")); + dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.noise")); dimredTrainer->SetInputListSample(trainingListSample); dimredTrainer->Train(); dimredTrainer->Save(modelPath); -- GitLab From 82e47317d4465939c1c4f39a7aa283d4c174d703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Mon, 29 May 2017 10:53:26 +0200 Subject: [PATCH 032/567] some cmments and documentation added --- include/AutoencoderModel.h | 13 ++-- include/AutoencoderModel.txx | 8 +-- include/DimensionalityReductionModel.h | 64 +++++++------------ .../ImageDimensionalityReductionFilter.txx | 7 +- 4 files changed, 35 insertions(+), 57 deletions(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 81b55a5fbf..ec9b5cdb2b 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -27,7 +27,7 @@ public: itkNewMacro(Self); itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); - unsigned int GetDimension() {return m_NumberOfHiddenNeurons;}; + unsigned int GetDimension() {return m_NumberOfHiddenNeurons;}; // Override the Dimensionality Reduction model method, it is used in the dimensionality reduction filter to set the output image size itkGetMacro(NumberOfHiddenNeurons,unsigned int); itkSetMacro(NumberOfHiddenNeurons,unsigned int); @@ -47,9 +47,7 @@ public: void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; void Train() ITK_OVERRIDE; - //void Dimensionality_reduction() {}; // Dimensionality reduction is done by DoPredict - - + protected: AutoencoderModel(); ~AutoencoderModel() ITK_OVERRIDE; @@ -59,11 +57,14 @@ protected: private: + /** Network attributes */ AutoencoderType m_net; unsigned int m_NumberOfHiddenNeurons; + + /** Training parameters */ unsigned int m_NumberOfIterations; - double m_Regularization; - double m_Noise; + double m_Regularization; // L2 Regularization parameter + double m_Noise; // probability for an input to be set to 0 (denosing autoencoder) }; } // end namespace otb diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 5c7bc5d97e..4305f805b8 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -6,12 +6,13 @@ #include <shark/Data/Dataset.h> #include "itkMacro.h" #include "otbSharkUtils.h" + //include train function #include <shark/ObjectiveFunctions/ErrorFunction.h> #include <shark/Algorithms/GradientDescent/Rprop.h>// the RProp optimization algorithm #include <shark/ObjectiveFunctions/Loss/SquaredLoss.h> // squared loss used for regression #include <shark/ObjectiveFunctions/Regularizer.h> //L2 regulariziation -#include <shark/Models/ImpulseNoiseModel.h>//noise source to corrupt the inputs +#include <shark/Models/ImpulseNoiseModel.h> //noise source to corrupt the inputs #include <shark/Models/ConcatenatedModel.h>//to concatenate the noise with the model namespace otb @@ -43,7 +44,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() std::size_t inputs = dataDimension(inputSamples); m_net.setStructure(inputs, m_NumberOfHiddenNeurons); initRandomUniform(m_net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); - shark::ImpulseNoiseModel noise(m_Noise,0.0);//set an input pixel with probability p to 0 + shark::ImpulseNoiseModel noise(m_Noise,0.0); //set an input pixel with probability m_Noise to 0 shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> m_net; shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(inputSamples,inputSamples);//labels identical to inputs @@ -92,7 +93,7 @@ template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Save(const std::string & filename, const std::string & name) { std::ofstream ofs(filename); - ofs << m_net.name() << std::endl; //first line + ofs << m_net.name() << std::endl; // the first line of the model file contains a key boost::archive::polymorphic_text_oarchive oa(ofs); m_net.write(oa); ofs.close(); @@ -163,6 +164,5 @@ void AutoencoderModel<TInputValue,AutoencoderType> } } - } // namespace otb #endif diff --git a/include/DimensionalityReductionModel.h b/include/DimensionalityReductionModel.h index 23ffad38bf..c5026551ee 100644 --- a/include/DimensionalityReductionModel.h +++ b/include/DimensionalityReductionModel.h @@ -25,42 +25,32 @@ namespace otb { -/** \class MachineLearningModel - * \brief MachineLearningModel is the base class for all classifier objects (SVM, KNN, - * Random Forests, Artificial Neural Network, ...) implemented in the supervised classification framework of the OTB. +/** \class DimensionalityReductionModel + * \brief DimensionalityReductionModel is the base class for all dimensionality Reduction objects (PCA, autoencoders and SOM) implemented in the dimensionality Reduction framework of the OTB. * - * MachineLearningModel is an abstract object that specifies behavior and - * interface of supervised classifiers (SVM, KNN, Random Forests, Artificial - * Neural Network, ...) in the generic supervised classification framework of the OTB. - * The main generic virtual methods specifically implemented in each classifier - * derived from the MachineLearningModel class are two learning-related methods: - * Train() and Save(), and three classification-related methods: Load(), + * DimensionalityReductionModel is an abstract object that specifies behavior and + * interface of dimensionality reduction algorithms (PCA, autoencoders and SOM) in the generic dimensionality Reduction framework of the OTB. + * The main generic virtual methods specifically implemented in each model + * derived from the DimensionalityReductionModel class are two learning-related methods: + * Train() and Save(), and three dimensionality reduction related methods: Load(), * DoPredict() and optionnaly DoPredictBatch(). * * Thus, each classifier derived from the MachineLearningModel class * computes its corresponding model with Train() and exports it with * the help of the Save() method. * - * It is also possible to classify any input sample composed of several + * It is also possible to reduce the dimensionality of any input sample composed of several * features (or any number of bands in the case of a pixel extracted * from a multi-band image) with the help of the Predict() method which * needs a previous loading of the classification model with the Load() method. * - * \sa MachineLearningModelFactory - * \sa LibSVMMachineLearningModel - * \sa SVMMachineLearningModel - * \sa BoostMachineLearningModel - * \sa KNearestNeighborsMachineLearningModel - * \sa DecisionTreeMachineLearningModel - * \sa RandomForestsMachineLearningModel - * \sa GradientBoostedTreeMachineLearningModel - * \sa NormalBayesMachineLearningModel - * \sa NeuralNetworkMachineLearningModel - * \sa SharkRandomForestsMachineLearningModel - * \sa ImageClassificationFilter + * \sa DimensionalityReductionModelFactory + * \sa SOMModel + * \sa PCAModel + * \sa AutoencderModel + * \sa ImageDimensionalityReductionFilter * - * - * \ingroup OTBSupervised + * \ingroup cbDimensionalityReduction */ template <class TInputValue, class TTargetValue> class ITK_EXPORT DimensionalityReductionModel @@ -121,7 +111,7 @@ public: /** Get the size of the output after dimensionality reduction */ virtual unsigned int GetDimension() = 0; - /**\name Classification model file manipulation */ + /**\name Dimensionality Reduction model file manipulation */ //@{ /** Save the model to file */ virtual void Save(const std::string & filename, const std::string & name="") = 0; @@ -132,10 +122,10 @@ public: /**\name Classification model file compatibility tests */ //@{ - /** Is the input model file readable and compatible with the corresponding classifier ? */ + /** Is the input model file readable and compatible with the corresponding model ? */ virtual bool CanReadFile(const std::string &) = 0; - /** Is the input model file writable and compatible with the corresponding classifier ? */ + /** Is the input model file writable and compatible with the corresponding model ? */ virtual bool CanWriteFile(const std::string &) = 0; //@} @@ -165,19 +155,13 @@ protected: /** Is DoPredictBatch multi-threaded ? */ bool m_IsDoPredictBatchMultiThreaded; - - - - private: /** Actual implementation of BatchPredicition * Default implementation will call DoPredict iteratively * \param input The input batch - * \param startIndex Index of the first sample to predict - * \param size Number of samples to predict - * \param target Pointer to the list of produced labels - * \param quality Pointer to the list of produced confidence - * values, or NULL + * \param startIndex Index of the first sample to reduce + * \param size Number of samples to reduce + * \param target Pointer to the list of reduced samples * * Override me if internal implementation allows for batch * prediction. @@ -187,11 +171,9 @@ private: */ virtual void DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * target) const; - /** Actual implementation of single sample prediction - * \param input sample to predict - * \param quality Pointer to a variable to store confidence value, - * or NULL - * \return The predicted label + /** Actual implementation of single sample reduction + * \param input sample to reduce + * \return The reduced sample */ virtual TargetSampleType DoPredict(const InputSampleType& input) const = 0; diff --git a/include/ImageDimensionalityReductionFilter.txx b/include/ImageDimensionalityReductionFilter.txx index 3dbfd16bfe..4eee4d3c9f 100644 --- a/include/ImageDimensionalityReductionFilter.txx +++ b/include/ImageDimensionalityReductionFilter.txx @@ -163,14 +163,10 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> InputIteratorType inIt(inputPtr, outputRegionForThread); OutputIteratorType outIt(outputPtr, outputRegionForThread); - // typedef typename ModelType::InputValueType InputValueType; typedef typename ModelType::InputSampleType InputSampleType; typedef typename ModelType::InputListSampleType InputListSampleType; typedef typename ModelType::TargetValueType TargetValueType; - // typedef typename ModelType::TargetSampleType TargetSampleType; typedef typename ModelType::TargetListSampleType TargetListSampleType; - // typedef typename ModelType::ConfidenceValueType ConfidenceValueType; - // typedef typename ModelType::ConfidenceSampleType ConfidenceSampleType; typename InputListSampleType::Pointer samples = InputListSampleType::New(); unsigned int num_features = inputPtr->GetNumberOfComponentsPerPixel(); @@ -193,11 +189,10 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> typename TargetListSampleType::Pointer labels; // This call is threadsafe - //labels = m_Model->PredictBatch(samples,confidences); labels = m_Model->PredictBatch(samples); + // Set the output values - typename TargetListSampleType::ConstIterator labIt = labels->Begin(); for (outIt.GoToBegin(); !outIt.IsAtEnd(); ++outIt) -- GitLab From b2b0fc4edfa284ace4422ab59938a09a67ca10ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Mon, 29 May 2017 13:57:44 +0200 Subject: [PATCH 033/567] autoencodermodel's attribute "m_net" is now a vector (works for a vector of size 1) --- include/AutoencoderModel.h | 2 +- include/AutoencoderModel.txx | 36 ++++++++++--------- .../DimensionalityReductionModelFactory.txx | 2 +- include/cbTrainAutoencoder.txx | 2 ++ 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index ec9b5cdb2b..df5f03280a 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -58,7 +58,7 @@ protected: private: /** Network attributes */ - AutoencoderType m_net; + std::vector<AutoencoderType> m_net; unsigned int m_NumberOfHiddenNeurons; /** Training parameters */ diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 4305f805b8..d13105ef27 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -35,6 +35,7 @@ AutoencoderModel<TInputValue,AutoencoderType>::~AutoencoderModel() template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Train() { + AutoencoderType net; std::vector<shark::RealVector> features; Shark::ListSampleToSharkVector(this->GetInputListSample(), features); @@ -42,11 +43,10 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); std::size_t inputs = dataDimension(inputSamples); - m_net.setStructure(inputs, m_NumberOfHiddenNeurons); - initRandomUniform(m_net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + net.setStructure(inputs, m_NumberOfHiddenNeurons); + initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); shark::ImpulseNoiseModel noise(m_Noise,0.0); //set an input pixel with probability m_Noise to 0 - shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> m_net; - + shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(inputSamples,inputSamples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; shark::ErrorFunction error(trainSet, &model, &loss); @@ -56,13 +56,13 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() shark::IRpropPlusFull optimizer; error.init(); optimizer.init(error); - std::cout<<"Optimizing model: "+m_net.name()<<std::endl; + std::cout<<"Optimizing model: "+net.name()<<std::endl; for(std::size_t i = 0; i != m_NumberOfIterations; ++i){ optimizer.step(error); std::cout<<i<<" "<<optimizer.solution().value<<std::endl; } - m_net.setParameterVector(optimizer.solution().point); - + net.setParameterVector(optimizer.solution().point); + m_net.push_back(net); } @@ -73,7 +73,7 @@ bool AutoencoderModel<TInputValue,AutoencoderType>::CanReadFile(const std::strin try { this->Load(filename); - m_net.name(); + m_net[0].name(); } catch(...) { @@ -93,27 +93,31 @@ template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Save(const std::string & filename, const std::string & name) { std::ofstream ofs(filename); - ofs << m_net.name() << std::endl; // the first line of the model file contains a key + ofs << m_net[0].name() << std::endl; // the first line of the model file contains a key boost::archive::polymorphic_text_oarchive oa(ofs); - m_net.write(oa); + //m_net.write(oa); + oa << m_net; ofs.close(); } template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & filename, const std::string & name) { + AutoencoderType net; std::ifstream ifs(filename); char autoencoder[256]; ifs.getline(autoencoder,256); std::string autoencoderstr(autoencoder); - - if (autoencoderstr != m_net.name()){ + std::cout << "oy" << std::endl; + if (autoencoderstr != net.name()){ itkExceptionMacro(<< "Error opening " << filename.c_str() ); } + std::cout << "yo" << std::endl; boost::archive::polymorphic_text_iarchive ia(ifs); - m_net.read(ia); + //m_net.read(ia); + ia >> m_net; ifs.close(); - m_NumberOfHiddenNeurons = m_net.numberOfHiddenNeurons(); + m_NumberOfHiddenNeurons = m_net[0].numberOfHiddenNeurons(); } @@ -132,7 +136,7 @@ AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & shark::Data<shark::RealVector> data = shark::createDataFromRange(features); - data = m_net.encode(data); + data = m_net[0].encode(data); TargetSampleType target; target.SetSize(m_NumberOfHiddenNeurons); @@ -151,7 +155,7 @@ void AutoencoderModel<TInputValue,AutoencoderType> Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); shark::Data<shark::RealVector> data = shark::createDataFromRange(features); TargetSampleType target; - data = m_net.encode(data); + data = m_net[0].encode(data); unsigned int id = startIndex; target.SetSize(m_NumberOfHiddenNeurons); for(const auto& p : data.elements()){ diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 5195605a89..24ed35449c 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -35,7 +35,7 @@ namespace otb { template <class TInputValue, class TTargetValue> -using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; +using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ; template <class TInputValue, class TTargetValue> diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index e120ae5e9b..7cef519d14 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -105,7 +105,9 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.regularization")); dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.noise")); dimredTrainer->SetInputListSample(trainingListSample); + std::cout << "before train" << std::endl; dimredTrainer->Train(); + std::cout << "after train" << std::endl; dimredTrainer->Save(modelPath); } -- GitLab From bc8b732a0f69fe9994bdaa0a5a7b667651f1de5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 30 May 2017 09:16:25 +0200 Subject: [PATCH 034/567] multi layer autoencoders now working (app and reduction) --- include/AutoencoderModel.h | 10 +++--- include/AutoencoderModel.txx | 60 +++++++++++++++++++++++----------- include/cbTrainAutoencoder.txx | 20 +++++++++--- 3 files changed, 62 insertions(+), 28 deletions(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index df5f03280a..cde280d83a 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -27,9 +27,9 @@ public: itkNewMacro(Self); itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); - unsigned int GetDimension() {return m_NumberOfHiddenNeurons;}; // Override the Dimensionality Reduction model method, it is used in the dimensionality reduction filter to set the output image size - itkGetMacro(NumberOfHiddenNeurons,unsigned int); - itkSetMacro(NumberOfHiddenNeurons,unsigned int); + unsigned int GetDimension() {return m_NumberOfHiddenNeurons[m_net.size()-1];}; // Override the Dimensionality Reduction model method, it is used in the dimensionality reduction filter to set the output image size + itkGetMacro(NumberOfHiddenNeurons,itk::Array<unsigned int>); + itkSetMacro(NumberOfHiddenNeurons,itk::Array<unsigned int>); itkGetMacro(NumberOfIterations,unsigned int); itkSetMacro(NumberOfIterations,unsigned int); @@ -47,6 +47,7 @@ public: void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; void Train() ITK_OVERRIDE; + void TrainOneLayer(unsigned int, shark::Data<shark::RealVector> &); protected: AutoencoderModel(); @@ -59,8 +60,9 @@ private: /** Network attributes */ std::vector<AutoencoderType> m_net; - unsigned int m_NumberOfHiddenNeurons; + + itk::Array<unsigned int> m_NumberOfHiddenNeurons; /** Training parameters */ unsigned int m_NumberOfIterations; double m_Regularization; // L2 Regularization parameter diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index d13105ef27..ac94902981 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -31,23 +31,35 @@ AutoencoderModel<TInputValue,AutoencoderType>::~AutoencoderModel() { } - template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Train() { - AutoencoderType net; std::vector<shark::RealVector> features; + Shark::ListSampleToSharkVector(this->GetInputListSample(), features); + shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); + + for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + { + TrainOneLayer( m_NumberOfHiddenNeurons[i], inputSamples); + } +} + +template <class TInputValue, class AutoencoderType> +void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(unsigned int nbneuron, shark::Data<shark::RealVector> &samples) +{ + AutoencoderType net; + /*std::vector<shark::RealVector> features; Shark::ListSampleToSharkVector(this->GetInputListSample(), features); shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - - std::size_t inputs = dataDimension(inputSamples); - net.setStructure(inputs, m_NumberOfHiddenNeurons); + */ //in Train() now + std::size_t inputs = dataDimension(samples); + net.setStructure(inputs, nbneuron); initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); shark::ImpulseNoiseModel noise(m_Noise,0.0); //set an input pixel with probability m_Noise to 0 shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; - shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(inputSamples,inputSamples);//labels identical to inputs + shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; shark::ErrorFunction error(trainSet, &model, &loss); shark::TwoNormRegularizer regularizer(error.numberOfVariables()); @@ -63,7 +75,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() } net.setParameterVector(optimizer.solution().point); m_net.push_back(net); - + samples = net.encode(samples); } @@ -108,16 +120,19 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & fil char autoencoder[256]; ifs.getline(autoencoder,256); std::string autoencoderstr(autoencoder); - std::cout << "oy" << std::endl; if (autoencoderstr != net.name()){ itkExceptionMacro(<< "Error opening " << filename.c_str() ); } - std::cout << "yo" << std::endl; boost::archive::polymorphic_text_iarchive ia(ifs); //m_net.read(ia); ia >> m_net; ifs.close(); - m_NumberOfHiddenNeurons = m_net[0].numberOfHiddenNeurons(); + + m_NumberOfHiddenNeurons.SetSize(m_net.size()); + for (int i=0; i<m_net.size(); i++){ + m_NumberOfHiddenNeurons[i] = m_net[i].numberOfHiddenNeurons(); + } + } @@ -135,15 +150,18 @@ AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & features.push_back(samples); shark::Data<shark::RealVector> data = shark::createDataFromRange(features); - - data = m_net[0].encode(data); + + for (int i=0; i<m_net.size(); i++){ // loop over all autoencoders in m_net + data = m_net[i].encode(data); + } TargetSampleType target; - target.SetSize(m_NumberOfHiddenNeurons); + target.SetSize(m_NumberOfHiddenNeurons[m_net.size()-1]); - for(unsigned int a = 0; a < m_NumberOfHiddenNeurons; ++a){ + for(unsigned int a = 0; a < m_NumberOfHiddenNeurons[m_net.size()-1]; ++a){ target[a]=data.element(0)[a]; } return target; + } @@ -155,12 +173,16 @@ void AutoencoderModel<TInputValue,AutoencoderType> Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); shark::Data<shark::RealVector> data = shark::createDataFromRange(features); TargetSampleType target; - data = m_net[0].encode(data); + + for (auto net :m_net ){ // loop over all autoencoders in m_net + data = net.encode(data); + } + unsigned int id = startIndex; - target.SetSize(m_NumberOfHiddenNeurons); - for(const auto& p : data.elements()){ - - for(unsigned int a = 0; a < m_NumberOfHiddenNeurons; ++a){ + target.SetSize(m_NumberOfHiddenNeurons[m_net.size()-1]); + for(const auto& p : data.elements()) + { + for(unsigned int a = 0; a < m_NumberOfHiddenNeurons[m_net.size()-1]; ++a){ target[a]=p[a]; } targets->SetMeasurementVector(id,target); diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index 7cef519d14..62b66cf8a9 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -46,12 +46,13 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> //Number Of Hidden Neurons - AddParameter(ParameterType_Int, "model.autoencoder.nbneuron", + AddParameter(ParameterType_StringList , "model.autoencoder.nbneuron", "Size"); + /*AddParameter(ParameterType_Int, "model.autoencoder.nbneuron", "Number of neurons in the hidden layer"); - SetParameterInt("model.autoencoder.nbneuron",10, false); + SetParameterInt("model.autoencoder.nbneuron",10, false);*/ SetParameterDescription( "model.autoencoder.nbneuron", - "The number of neurons in the hidden layer."); + "The number of neurons in each hidden layer."); //Regularization AddParameter(ParameterType_Float, "model.autoencoder.regularization", "Strength of the regularization"); @@ -100,7 +101,14 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> ::TrainAutoencoder(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { typename autoencoderchoice::Pointer dimredTrainer = autoencoderchoice::New(); - dimredTrainer->SetNumberOfHiddenNeurons(GetParameterInt("model.autoencoder.nbneuron")); + itk::Array<unsigned int> nb_neuron; + std::vector<std::basic_string<char>> s= GetParameterStringList("model.autoencoder.nbneuron"); + nb_neuron.SetSize(s.size()); + for (int i=0; i<s.size(); i++){ // This will be templated later (the 3) + nb_neuron[i]=std::stoi(s[i]); + } + std::cout << nb_neuron << std::endl; + dimredTrainer->SetNumberOfHiddenNeurons(nb_neuron); dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.regularization")); dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.noise")); @@ -108,7 +116,9 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> std::cout << "before train" << std::endl; dimredTrainer->Train(); std::cout << "after train" << std::endl; - dimredTrainer->Save(modelPath); + dimredTrainer->Save(modelPath); + + } } //end namespace wrapper -- GitLab From 916ac4606003db378f78d477d08d9161601fe9eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Fri, 2 Jun 2017 12:10:39 +0200 Subject: [PATCH 035/567] New application for vector dimensionality reductio --- app/CMakeLists.txt | 6 + app/cbDimensionalityReductionVector.cxx | 322 ++++++++++++++++++++++++ 2 files changed, 328 insertions(+) create mode 100644 app/cbDimensionalityReductionVector.cxx diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 720a15197b..ff6d803bbc 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -9,3 +9,9 @@ NAME CbDimensionalityReduction SOURCES cbDimensionalityReduction.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBITK_LIBRARIES} ${OTBBoost_LIBRARIES} ${OTBShark_LIBRARIES} ) + +OTB_CREATE_APPLICATION( +NAME CbDimensionalityReductionVector +SOURCES cbDimensionalityReductionVector.cxx +LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBITK_LIBRARIES} ${OTBBoost_LIBRARIES} ${OTBShark_LIBRARIES} +) diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx new file mode 100644 index 0000000000..c4e7eccfd8 --- /dev/null +++ b/app/cbDimensionalityReductionVector.cxx @@ -0,0 +1,322 @@ +/* +* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +* +* This file is part of Orfeo Toolbox +* +* https://www.orfeo-toolbox.org/ +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" +#include "otbOGRDataSourceWrapper.h" +#include "otbOGRFeatureWrapper.h" +#include "itkVariableLengthVector.h" +#include "otbStatisticsXMLFileReader.h" +#include "itkListSample.h" +#include "otbShiftScaleSampleListFilter.h" +#include "DimensionalityReductionModelFactory.h" +#include "DimensionalityReductionModel.h" +#include <time.h> +namespace otb +{ +namespace Wrapper +{ + +/** Utility function to negate std::isalnum */ +/*bool IsNotAlphaNum(char c) +{ +return !std::isalnum(c); +}*/ +class CbDimensionalityReductionVector : public Application +{ + public: + + /** Standard class typedefs. */ + typedef CbDimensionalityReductionVector Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Standard macro */ + itkNewMacro(Self); + itkTypeMacro(Self, Application) + + /** Filters typedef */ + + typedef double ValueType; + typedef DimensionalityReductionModel<ValueType,ValueType> DimensionalityReductionModelType; + typedef DimensionalityReductionModelFactory<ValueType, ValueType> DimensionalityReductionModelFactoryType; + typedef DimensionalityReductionModelType::Pointer ModelPointerType; + + /** Statistics Filters typedef */ + typedef itk::VariableLengthVector<ValueType> MeasurementType; + typedef otb::StatisticsXMLFileReader<MeasurementType> StatisticsReader; + typedef itk::VariableLengthVector<ValueType> InputSampleType; + typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; + typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; + ~CbDimensionalityReductionVector() ITK_OVERRIDE + { + DimensionalityReductionModelFactoryType::CleanFactories(); + } + + private: + + void DoInit() ITK_OVERRIDE + { + SetName("VectorDimensionalityReduction"); + SetDescription("Performs dimensionality reduction of the input vector data according to a model file."); + SetDocName("Vector Dimensionality Reduction"); + SetDocAuthors("OTB-Team"); + SetDocLongDescription("This application performs a vector data dimensionality reduction based on a model file produced by the cbDimensionalityReductionTrainer application."); + SetDocSeeAlso("cbDimensionalityReductionTrainer"); + AddDocTag(Tags::Learning); + + AddParameter(ParameterType_InputVectorData, "in", "Name of the input vector data"); + SetParameterDescription("in","The input vector data to reduce."); + + AddParameter(ParameterType_InputFilename, "instat", "Statistics file"); + SetParameterDescription("instat", "A XML file containing mean and standard deviation to center" + "and reduce samples before dimensionality reduction (produced by ComputeImagesStatistics application)."); + MandatoryOff("instat"); + + AddParameter(ParameterType_InputFilename, "model", "Model file"); + SetParameterDescription("model", "A model file (produced by cbDimensionalityReduction application,"); + + AddParameter(ParameterType_ListView, "feat", "Field names to be calculated."); // + SetParameterDescription("feat","List of field names in the input vector data used as features for training."); // + + AddParameter(ParameterType_ListView, "feat_out", "Field names to be calculated."); // + SetParameterDescription("feat_out","List of field names in the input vector data used as features for training."); // + + AddParameter(ParameterType_OutputFilename, "out", "Output vector data file containing the reduced vector"); + SetParameterDescription("out","Output vector data file storing sample values (OGR format)." + "If not given, the input vector data file is updated."); + MandatoryOff("out"); + + // Doc example parameter settings + SetDocExampleParameterValue("in", "vectorData.shp"); + SetDocExampleParameterValue("instat", "meanVar.xml"); + SetDocExampleParameterValue("model", "model.txt"); + SetDocExampleParameterValue("out", "vectorDataOut.shp"); + SetDocExampleParameterValue("feat", "perimeter area width"); + SetDocExampleParameterValue("feat_out", "perimeter area width"); + //SetOfficialDocLink(); + } + + void DoUpdateParameters() ITK_OVERRIDE + { + /** I don't know what this does */ + /* + if ( HasValue("in") ) + { + std::string shapefile = GetParameterString("in"); + otb::ogr::DataSource::Pointer ogrDS; + OGRSpatialReference oSRS(""); + std::vector<std::string> options; + ogrDS = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); + otb::ogr::Layer layer = ogrDS->GetLayer(0); + OGRFeatureDefn &layerDefn = layer.GetLayerDefn(); + ClearChoices("feat"); + + for(int iField=0; iField< layerDefn.GetFieldCount(); iField++) + { + std::string item = layerDefn.GetFieldDefn(iField)->GetNameRef(); + std::string key(item); + key.erase( std::remove_if(key.begin(),key.end(),IsNotAlphaNum), key.end()); + std::transform(key.begin(), key.end(), key.begin(), tolower); + OGRFieldType fieldType = layerDefn.GetFieldDefn(iField)->GetType(); + + if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal) + { + std::string tmpKey="feat."+key; + AddChoice(tmpKey,item); + } + } + }*/ + } + + void DoExecute() ITK_OVERRIDE + { + clock_t tic = clock(); + + std::string shapefile = GetParameterString("in"); + otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); + otb::ogr::Layer layer = source->GetLayer(0); + ListSampleType::Pointer input = ListSampleType::New(); + const int nbFeatures = GetSelectedItems("feat").size(); + input->SetMeasurementVectorSize(nbFeatures); + otb::ogr::Layer::const_iterator it = layer.cbegin(); + otb::ogr::Layer::const_iterator itEnd = layer.cend(); + + for( ; it!=itEnd ; ++it) + { + MeasurementType mv; + mv.SetSize(nbFeatures); + for(int idx=0; idx < nbFeatures; ++idx) + { + mv[idx] = (*it)[GetSelectedItems("feat")[idx]].GetValue<double>(); + } + input->PushBack(mv); + } + + /** Statistics for shift/scale */ + + MeasurementType meanMeasurementVector; + MeasurementType stddevMeasurementVector; + + if (HasValue("instat") && IsParameterEnabled("instat")) + { + StatisticsReader::Pointer statisticsReader = StatisticsReader::New(); + std::string XMLfile = GetParameterString("instat"); + statisticsReader->SetFileName(XMLfile); + meanMeasurementVector = statisticsReader->GetStatisticVectorByName("mean"); + stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); + } + else + { + meanMeasurementVector.SetSize(nbFeatures); + meanMeasurementVector.Fill(0.); + stddevMeasurementVector.SetSize(nbFeatures); + stddevMeasurementVector.Fill(1.); + } + + ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); + trainingShiftScaleFilter->SetInput(input); + trainingShiftScaleFilter->SetShifts(meanMeasurementVector); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector); + trainingShiftScaleFilter->Update(); + otbAppLogINFO("mean used: " << meanMeasurementVector); + otbAppLogINFO("standard deviation used: " << stddevMeasurementVector); + otbAppLogINFO("Loading model"); + + + /** Read the model */ + + m_Model = DimensionalityReductionModelFactoryType::CreateDimensionalityReductionModel(GetParameterString("model"), + DimensionalityReductionModelFactoryType::ReadMode); + if (m_Model.IsNull()) + { + otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") << " : unsupported model type"); + } + m_Model->Load(GetParameterString("model")); + otbAppLogINFO("Model loaded"); + + /** Perform Dimensionality Reduction */ + + ListSampleType::Pointer listSample = trainingShiftScaleFilter->GetOutput(); + ListSampleType::Pointer target; + target = m_Model->PredictBatch(listSample); + + + /** Create/Update Output Shape file */ + + ogr::DataSource::Pointer output; + ogr::DataSource::Pointer buffer = ogr::DataSource::New(); + bool updateMode = false; + if (IsParameterEnabled("out") && HasValue("out")) + { + // Create new OGRDataSource + output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite); + otb::ogr::Layer newLayer = output->CreateLayer( + GetParameterString("out"), + const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), + layer.GetGeomType()); + // Copy existing fields + OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); + for (int k=0 ; k<inLayerDefn.GetFieldCount() ; k++) + { + OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); + newLayer.CreateField(fieldDefn); + } + } + else + { + // Update mode + updateMode = true; + otbAppLogINFO("Update input vector data."); + // fill temporary buffer for the transfer + otb::ogr::Layer inputLayer = layer; + layer = buffer->CopyLayer(inputLayer, std::string("Buffer")); + // close input data source + source->Clear(); + // Re-open input data source in update mode + output = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Update_LayerUpdate); + } + + otb::ogr::Layer outLayer = output->GetLayer(0); + OGRErr errStart = outLayer.ogr().StartTransaction(); + + if (errStart != OGRERR_NONE) + { + itkExceptionMacro(<< "Unable to start transaction for OGR layer " << outLayer.ogr().GetName() << "."); + } + + // Add the field of prediction in the output layer if field not exist + + OGRFeatureDefn &layerDefn = layer.GetLayerDefn(); + int idx = layerDefn.GetFieldIndex(GetParameterString("feat_out").c_str()); + + if (idx >= 0) + { + if (layerDefn.GetFieldDefn(idx)->GetType() != OFTInteger) + itkExceptionMacro("Field name "<< GetParameterString("feat_out") << " already exists with a different type!"); + } + else + { + OGRFieldDefn predictedField(GetParameterString("feat_out").c_str(), OFTInteger); + ogr::FieldDefn predictedFieldDef(predictedField); + outLayer.CreateField(predictedFieldDef); + } + + // Fill output layer + + unsigned int count=0; + std::string classfieldname = GetParameterString("feat_out"); + it = layer.cbegin(); + itEnd = layer.cend(); + for( ; it!=itEnd ; ++it, ++count) + { + ogr::Feature dstFeature(outLayer.GetLayerDefn()); + dstFeature.SetFrom( *it , TRUE); + dstFeature.SetFID(it->GetFID()); + dstFeature[classfieldname].SetValue<int>(target->GetMeasurementVector(count)[0]); + + if (updateMode) + { + outLayer.SetFeature(dstFeature); + } + else + { + outLayer.CreateFeature(dstFeature); + } + } + if(outLayer.ogr().TestCapability("Transactions")) + { + const OGRErr errCommitX = outLayer.ogr().CommitTransaction(); + if (errCommitX != OGRERR_NONE) + { + itkExceptionMacro(<< "Unable to commit transaction for OGR layer " << outLayer.ogr().GetName() << "."); + } + } + output->SyncToDisk(); + clock_t toc = clock(); + otbAppLogINFO( "Elapsed: "<< ((double)(toc - tic) / CLOCKS_PER_SEC)<<" seconds."); + } + + ModelPointerType m_Model; +}; +} +} +OTB_APPLICATION_EXPORT(otb::Wrapper::CbDimensionalityReductionVector) -- GitLab From 00fb23c7d453546b164c82e1a8cba6cec05b9d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 6 Jun 2017 15:04:30 +0200 Subject: [PATCH 036/567] vector app work in progress --- app/cbDimensionalityReductionVector.cxx | 104 ++++++++++-------- include/AutoencoderModel.h | 8 ++ include/AutoencoderModel.txx | 3 + .../DimensionalityReductionModelFactory.txx | 1 + include/cbTrainAutoencoder.txx | 2 +- 5 files changed, 72 insertions(+), 46 deletions(-) diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index c4e7eccfd8..b4a8999a02 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -35,10 +35,11 @@ namespace Wrapper { /** Utility function to negate std::isalnum */ -/*bool IsNotAlphaNum(char c) +bool IsNotAlphaNum(char c) { return !std::isalnum(c); -}*/ +} + class CbDimensionalityReductionVector : public Application { public: @@ -97,8 +98,8 @@ class CbDimensionalityReductionVector : public Application AddParameter(ParameterType_ListView, "feat", "Field names to be calculated."); // SetParameterDescription("feat","List of field names in the input vector data used as features for training."); // - AddParameter(ParameterType_ListView, "feat_out", "Field names to be calculated."); // - SetParameterDescription("feat_out","List of field names in the input vector data used as features for training."); // + AddParameter(ParameterType_StringList, "featout", "Field names to be calculated."); // + SetParameterDescription("featout","List of field names in the input vector data used as features for training."); // AddParameter(ParameterType_OutputFilename, "out", "Output vector data file containing the reduced vector"); SetParameterDescription("out","Output vector data file storing sample values (OGR format)." @@ -111,40 +112,46 @@ class CbDimensionalityReductionVector : public Application SetDocExampleParameterValue("model", "model.txt"); SetDocExampleParameterValue("out", "vectorDataOut.shp"); SetDocExampleParameterValue("feat", "perimeter area width"); - SetDocExampleParameterValue("feat_out", "perimeter area width"); + SetDocExampleParameterValue("featout", "perimeter area width"); //SetOfficialDocLink(); } void DoUpdateParameters() ITK_OVERRIDE { - /** I don't know what this does */ - /* - if ( HasValue("in") ) - { - std::string shapefile = GetParameterString("in"); - otb::ogr::DataSource::Pointer ogrDS; - OGRSpatialReference oSRS(""); - std::vector<std::string> options; - ogrDS = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); - otb::ogr::Layer layer = ogrDS->GetLayer(0); - OGRFeatureDefn &layerDefn = layer.GetLayerDefn(); - ClearChoices("feat"); - - for(int iField=0; iField< layerDefn.GetFieldCount(); iField++) - { - std::string item = layerDefn.GetFieldDefn(iField)->GetNameRef(); - std::string key(item); - key.erase( std::remove_if(key.begin(),key.end(),IsNotAlphaNum), key.end()); - std::transform(key.begin(), key.end(), key.begin(), tolower); - OGRFieldType fieldType = layerDefn.GetFieldDefn(iField)->GetType(); - - if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal) - { - std::string tmpKey="feat."+key; - AddChoice(tmpKey,item); - } - } - }*/ + + if ( HasValue("in") ) + { + std::string shapefile = GetParameterString("in"); + otb::ogr::DataSource::Pointer ogrDS; + OGRSpatialReference oSRS(""); + std::vector<std::string> options; + ogrDS = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); + otb::ogr::Layer layer = ogrDS->GetLayer(0); + OGRFeatureDefn &layerDefn = layer.GetLayerDefn(); + ClearChoices("feat"); + //ClearChoices("featout"); + + for(int iField=0; iField< layerDefn.GetFieldCount(); iField++) + { + std::string item = layerDefn.GetFieldDefn(iField)->GetNameRef(); + std::string key(item); + key.erase( std::remove_if(key.begin(),key.end(),IsNotAlphaNum), key.end()); + std::transform(key.begin(), key.end(), key.begin(), tolower); + OGRFieldType fieldType = layerDefn.GetFieldDefn(iField)->GetType(); + + if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal) + { + std::string tmpKey="feat."+key; + AddChoice(tmpKey,item); + } + /* + if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal) + { + std::string tmpKey="featout."+key; + AddChoice(tmpKey,item); + }*/ + } + } } void DoExecute() ITK_OVERRIDE @@ -222,25 +229,30 @@ class CbDimensionalityReductionVector : public Application /** Create/Update Output Shape file */ + std::cout << GetParameterStringList("featout").size() << std::endl; + ogr::DataSource::Pointer output; ogr::DataSource::Pointer buffer = ogr::DataSource::New(); bool updateMode = false; + + if (IsParameterEnabled("out") && HasValue("out")) { // Create new OGRDataSource output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite); - otb::ogr::Layer newLayer = output->CreateLayer( - GetParameterString("out"), - const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), - layer.GetGeomType()); + otb::ogr::Layer newLayer = output->CreateLayer(GetParameterString("out"), + const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), + layer.GetGeomType()); // Copy existing fields OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); - for (int k=0 ; k<inLayerDefn.GetFieldCount() ; k++) + for (int k=0 ; k<inLayerDefn.GetFieldCount()-nbFeatures ; k++) // we don't copy the original bands { OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); newLayer.CreateField(fieldDefn); } } + + /* else { // Update mode @@ -253,11 +265,13 @@ class CbDimensionalityReductionVector : public Application source->Clear(); // Re-open input data source in update mode output = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Update_LayerUpdate); - } + }*/ + + otb::ogr::Layer outLayer = output->GetLayer(0); OGRErr errStart = outLayer.ogr().StartTransaction(); - + /* if (errStart != OGRERR_NONE) { itkExceptionMacro(<< "Unable to start transaction for OGR layer " << outLayer.ogr().GetName() << "."); @@ -266,16 +280,16 @@ class CbDimensionalityReductionVector : public Application // Add the field of prediction in the output layer if field not exist OGRFeatureDefn &layerDefn = layer.GetLayerDefn(); - int idx = layerDefn.GetFieldIndex(GetParameterString("feat_out").c_str()); + int idx = layerDefn.GetFieldIndex(GetParameterStringList("featout").c_str()); if (idx >= 0) { if (layerDefn.GetFieldDefn(idx)->GetType() != OFTInteger) - itkExceptionMacro("Field name "<< GetParameterString("feat_out") << " already exists with a different type!"); + itkExceptionMacro("Field name "<< GetParameterStringList("featout") << " already exists with a different type!"); } else { - OGRFieldDefn predictedField(GetParameterString("feat_out").c_str(), OFTInteger); + OGRFieldDefn predictedField(GetParameterStringList("featout").c_str(), OFTInteger); ogr::FieldDefn predictedFieldDef(predictedField); outLayer.CreateField(predictedFieldDef); } @@ -283,7 +297,7 @@ class CbDimensionalityReductionVector : public Application // Fill output layer unsigned int count=0; - std::string classfieldname = GetParameterString("feat_out"); + std::string classfieldname = GetParameterStringList("featout"); it = layer.cbegin(); itEnd = layer.cend(); for( ; it!=itEnd ; ++it, ++count) @@ -312,7 +326,7 @@ class CbDimensionalityReductionVector : public Application } output->SyncToDisk(); clock_t toc = clock(); - otbAppLogINFO( "Elapsed: "<< ((double)(toc - tic) / CLOCKS_PER_SEC)<<" seconds."); + otbAppLogINFO( "Elapsed: "<< ((double)(toc - tic) / CLOCKS_PER_SEC)<<" seconds.");*/ } ModelPointerType m_Model; diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index cde280d83a..927e552b88 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -40,6 +40,12 @@ public: itkGetMacro(Noise,double); itkSetMacro(Noise,double); + itkGetMacro(rho,double); + itkSetMacro(rho,double); + + itkGetMacro(beta,double); + itkSetMacro(beta,double); + bool CanReadFile(const std::string & filename); bool CanWriteFile(const std::string & filename); @@ -67,6 +73,8 @@ private: unsigned int m_NumberOfIterations; double m_Regularization; // L2 Regularization parameter double m_Noise; // probability for an input to be set to 0 (denosing autoencoder) + double m_rho; // Sparsity parameter + double m_beta; // Sparsity regularization parameter }; } // end namespace otb diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index ac94902981..909356bb1c 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -9,6 +9,8 @@ //include train function #include <shark/ObjectiveFunctions/ErrorFunction.h> +#include <shark/ObjectiveFunctions/SparseAutoencoderError.h>//the error function performing the regularisation of the hidden neurons + #include <shark/Algorithms/GradientDescent/Rprop.h>// the RProp optimization algorithm #include <shark/ObjectiveFunctions/Loss/SquaredLoss.h> // squared loss used for regression #include <shark/ObjectiveFunctions/Regularizer.h> //L2 regulariziation @@ -62,6 +64,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(unsigned int n shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; shark::ErrorFunction error(trainSet, &model, &loss); + //shark::SparseAutoencoderError error(data,&model, &loss, m_rho, m_beta); shark::TwoNormRegularizer regularizer(error.numberOfVariables()); error.setRegularizer(m_Regularization,®ularizer); diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 24ed35449c..5ccf34a388 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -54,6 +54,7 @@ using SOM4DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 4> ; template <class TInputValue, class TTargetValue> using SOM5DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 5> ; + template <class TInputValue, class TOutputValue> typename DimensionalityReductionModel<TInputValue,TOutputValue>::Pointer DimensionalityReductionModelFactory<TInputValue,TOutputValue> diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index 62b66cf8a9..998fe3b947 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -111,7 +111,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> dimredTrainer->SetNumberOfHiddenNeurons(nb_neuron); dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.regularization")); - dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.noise")); + dimredTrainer->SetNoise(GetParameterFloat("model.autoencoder.noise")); dimredTrainer->SetInputListSample(trainingListSample); std::cout << "before train" << std::endl; dimredTrainer->Train(); -- GitLab From a79f0d47ca65cf0905615b7d9dbeea5b515062e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 13 Jun 2017 14:17:47 +0200 Subject: [PATCH 037/567] Sparse ae added, parameters can now be defined for each layers (noise, regularization, rho and beta) --- app/cbDimensionalityReductionVector.cxx | 42 +++++++++++-------- include/AutoencoderModel.h | 27 ++++++------ include/AutoencoderModel.txx | 55 +++++++++++++++++++------ include/cbTrainAutoencoder.txx | 46 ++++++++++++++++----- 4 files changed, 117 insertions(+), 53 deletions(-) diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index b4a8999a02..90927c56c4 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -29,6 +29,7 @@ #include "DimensionalityReductionModelFactory.h" #include "DimensionalityReductionModel.h" #include <time.h> + namespace otb { namespace Wrapper @@ -115,7 +116,7 @@ class CbDimensionalityReductionVector : public Application SetDocExampleParameterValue("featout", "perimeter area width"); //SetOfficialDocLink(); } - + // void DoUpdateParameters() ITK_OVERRIDE { @@ -271,7 +272,7 @@ class CbDimensionalityReductionVector : public Application otb::ogr::Layer outLayer = output->GetLayer(0); OGRErr errStart = outLayer.ogr().StartTransaction(); - /* + if (errStart != OGRERR_NONE) { itkExceptionMacro(<< "Unable to start transaction for OGR layer " << outLayer.ogr().GetName() << "."); @@ -279,25 +280,28 @@ class CbDimensionalityReductionVector : public Application // Add the field of prediction in the output layer if field not exist - OGRFeatureDefn &layerDefn = layer.GetLayerDefn(); - int idx = layerDefn.GetFieldIndex(GetParameterStringList("featout").c_str()); - - if (idx >= 0) + for (int i=0; i<GetParameterStringList("featout").size() ;i++) { - if (layerDefn.GetFieldDefn(idx)->GetType() != OFTInteger) - itkExceptionMacro("Field name "<< GetParameterStringList("featout") << " already exists with a different type!"); - } - else - { - OGRFieldDefn predictedField(GetParameterStringList("featout").c_str(), OFTInteger); - ogr::FieldDefn predictedFieldDef(predictedField); - outLayer.CreateField(predictedFieldDef); + OGRFeatureDefn &layerDefn = outLayer.GetLayerDefn(); + int idx = layerDefn.GetFieldIndex(GetParameterStringList("featout")[i].c_str()); + + if (idx >= 0) + { + if (layerDefn.GetFieldDefn(idx)->GetType() != OFTReal) + itkExceptionMacro("Field name "<< GetParameterStringList("featout")[i] << " already exists with a different type!"); + } + else + { + OGRFieldDefn predictedField(GetParameterStringList("featout")[i].c_str(), OFTReal); + ogr::FieldDefn predictedFieldDef(predictedField); + outLayer.CreateField(predictedFieldDef); + } } // Fill output layer unsigned int count=0; - std::string classfieldname = GetParameterStringList("featout"); + auto classfieldname = GetParameterStringList("featout"); it = layer.cbegin(); itEnd = layer.cend(); for( ; it!=itEnd ; ++it, ++count) @@ -305,8 +309,9 @@ class CbDimensionalityReductionVector : public Application ogr::Feature dstFeature(outLayer.GetLayerDefn()); dstFeature.SetFrom( *it , TRUE); dstFeature.SetFID(it->GetFID()); - dstFeature[classfieldname].SetValue<int>(target->GetMeasurementVector(count)[0]); - + for (std::size_t i=0; i<classfieldname.size(); ++i){ + dstFeature[classfieldname[i]].SetValue<ValueType>(target->GetMeasurementVector(count)[i]); + } if (updateMode) { outLayer.SetFeature(dstFeature); @@ -316,6 +321,7 @@ class CbDimensionalityReductionVector : public Application outLayer.CreateFeature(dstFeature); } } + if(outLayer.ogr().TestCapability("Transactions")) { const OGRErr errCommitX = outLayer.ogr().CommitTransaction(); @@ -326,7 +332,7 @@ class CbDimensionalityReductionVector : public Application } output->SyncToDisk(); clock_t toc = clock(); - otbAppLogINFO( "Elapsed: "<< ((double)(toc - tic) / CLOCKS_PER_SEC)<<" seconds.");*/ + otbAppLogINFO( "Elapsed: "<< ((double)(toc - tic) / CLOCKS_PER_SEC)<<" seconds."); } ModelPointerType m_Model; diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 927e552b88..0ca282afc0 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -34,17 +34,17 @@ public: itkGetMacro(NumberOfIterations,unsigned int); itkSetMacro(NumberOfIterations,unsigned int); - itkGetMacro(Regularization,double); - itkSetMacro(Regularization,double); + itkGetMacro(Regularization,itk::Array<double>); + itkSetMacro(Regularization,itk::Array<double>); - itkGetMacro(Noise,double); - itkSetMacro(Noise,double); + itkGetMacro(Noise,itk::Array<double>); + itkSetMacro(Noise,itk::Array<double>); - itkGetMacro(rho,double); - itkSetMacro(rho,double); + itkGetMacro(Rho,itk::Array<double>); + itkSetMacro(Rho,itk::Array<double>); - itkGetMacro(beta,double); - itkSetMacro(beta,double); + itkGetMacro(Beta,itk::Array<double>); + itkSetMacro(Beta,itk::Array<double>); bool CanReadFile(const std::string & filename); bool CanWriteFile(const std::string & filename); @@ -53,7 +53,8 @@ public: void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; void Train() ITK_OVERRIDE; - void TrainOneLayer(unsigned int, shark::Data<shark::RealVector> &); + void TrainOneLayer(unsigned int,double, double, shark::Data<shark::RealVector> &); + void TrainOneSparseLayer(unsigned int,double, double,double, shark::Data<shark::RealVector> &); protected: AutoencoderModel(); @@ -71,10 +72,10 @@ private: itk::Array<unsigned int> m_NumberOfHiddenNeurons; /** Training parameters */ unsigned int m_NumberOfIterations; - double m_Regularization; // L2 Regularization parameter - double m_Noise; // probability for an input to be set to 0 (denosing autoencoder) - double m_rho; // Sparsity parameter - double m_beta; // Sparsity regularization parameter + itk::Array<double> m_Regularization; // L2 Regularization parameter + itk::Array<double> m_Noise; // probability for an input to be set to 0 (denosing autoencoder) + itk::Array<double> m_Rho; // Sparsity parameter + itk::Array<double> m_Beta; // Sparsity regularization parameter }; } // end namespace otb diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 909356bb1c..b55b5da7d4 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -20,7 +20,6 @@ namespace otb { - template <class TInputValue, class AutoencoderType> AutoencoderModel<TInputValue,AutoencoderType>::AutoencoderModel() { @@ -42,31 +41,34 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) { - TrainOneLayer( m_NumberOfHiddenNeurons[i], inputSamples); + if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen + { + TrainOneLayer( m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples); + } + else + { + TrainOneSparseLayer( m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples); + } } } template <class TInputValue, class AutoencoderType> -void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(unsigned int nbneuron, shark::Data<shark::RealVector> &samples) +void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(unsigned int nbneuron,double noise_strength,double regularization, shark::Data<shark::RealVector> &samples) { AutoencoderType net; - /*std::vector<shark::RealVector> features; - - Shark::ListSampleToSharkVector(this->GetInputListSample(), features); - - shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - */ //in Train() now + std::size_t inputs = dataDimension(samples); net.setStructure(inputs, nbneuron); initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); - shark::ImpulseNoiseModel noise(m_Noise,0.0); //set an input pixel with probability m_Noise to 0 + shark::ImpulseNoiseModel noise(noise_strength,0.0); //set an input pixel with probability m_Noise to 0 shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; shark::ErrorFunction error(trainSet, &model, &loss); - //shark::SparseAutoencoderError error(data,&model, &loss, m_rho, m_beta); + //shark::SparseAutoencoderError error(trainSet,&model, &loss, m_Rho, m_Beta); + //shark::SparseAutoencoderError error(trainSet,&net, &loss, 0.1, 0.1); shark::TwoNormRegularizer regularizer(error.numberOfVariables()); - error.setRegularizer(m_Regularization,®ularizer); + error.setRegularizer(regularization,®ularizer); shark::IRpropPlusFull optimizer; error.init(); @@ -82,6 +84,35 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(unsigned int n } +template <class TInputValue, class AutoencoderType> +void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(unsigned int nbneuron,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples) +{ + AutoencoderType net; + + std::size_t inputs = dataDimension(samples); + net.setStructure(inputs, nbneuron); + initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + + shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs + shark::SquaredLoss<shark::RealVector> loss; + shark::SparseAutoencoderError error(trainSet,&net, &loss, rho, beta); + + shark::TwoNormRegularizer regularizer(error.numberOfVariables()); + error.setRegularizer(regularization,®ularizer); + + shark::IRpropPlusFull optimizer; + error.init(); + optimizer.init(error); + std::cout<<"Optimizing model: "+net.name()<<std::endl; + for(std::size_t i = 0; i != m_NumberOfIterations; ++i){ + optimizer.step(error); + std::cout<<i<<" "<<optimizer.solution().value<<std::endl; + } + net.setParameterVector(optimizer.solution().point); + m_net.push_back(net); + samples = net.encode(samples); +} + template <class TInputValue, class AutoencoderType> bool AutoencoderModel<TInputValue,AutoencoderType>::CanReadFile(const std::string & filename) { diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index 998fe3b947..dce0efbe70 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -55,16 +55,24 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> "The number of neurons in each hidden layer."); //Regularization - AddParameter(ParameterType_Float, "model.autoencoder.regularization", "Strength of the regularization"); - SetParameterFloat("model.autoencoder.regularization",0, false); + AddParameter(ParameterType_StringList, "model.autoencoder.regularization", "Strength of the regularization"); SetParameterDescription("model.autoencoder.regularization", "Strength of the L2 regularization used during training"); //Noise strength - AddParameter(ParameterType_Float, "model.autoencoder.noise", "Strength of the noise"); - SetParameterFloat("model.autoencoder.noise",0, false); + AddParameter(ParameterType_StringList, "model.autoencoder.noise", "Strength of the noise"); SetParameterDescription("model.autoencoder.noise", "Strength of the noise"); + + // Sparsity parameter + AddParameter(ParameterType_StringList, "model.autoencoder.rho", "Sparsity parameter"); + SetParameterDescription("model.autoencoder.rho", + "Sparsity parameter"); + + // Sparsity regularization strength + AddParameter(ParameterType_StringList, "model.autoencoder.beta", "Sparsity regularization strength"); + SetParameterDescription("model.autoencoder.beta", + "Sparsity regularization strength"); } @@ -102,16 +110,34 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> { typename autoencoderchoice::Pointer dimredTrainer = autoencoderchoice::New(); itk::Array<unsigned int> nb_neuron; - std::vector<std::basic_string<char>> s= GetParameterStringList("model.autoencoder.nbneuron"); - nb_neuron.SetSize(s.size()); - for (int i=0; i<s.size(); i++){ // This will be templated later (the 3) - nb_neuron[i]=std::stoi(s[i]); + itk::Array<float> noise; + itk::Array<float> regularization; + itk::Array<float> rho; + itk::Array<float> beta; + std::vector<std::basic_string<char>> s_nbneuron= GetParameterStringList("model.autoencoder.nbneuron"); + std::vector<std::basic_string<char>> s_noise= GetParameterStringList("model.autoencoder.noise"); + std::vector<std::basic_string<char>> s_regularization= GetParameterStringList("model.autoencoder.regularization"); + std::vector<std::basic_string<char>> s_rho= GetParameterStringList("model.autoencoder.rho"); + std::vector<std::basic_string<char>> s_beta= GetParameterStringList("model.autoencoder.beta"); + nb_neuron.SetSize(s_nbneuron.size()); + noise.SetSize(s_nbneuron.size()); + regularization.SetSize(s_nbneuron.size()); + rho.SetSize(s_nbneuron.size()); + beta.SetSize(s_nbneuron.size()); + for (int i=0; i<s_nbneuron.size(); i++){ + nb_neuron[i]=std::stoi(s_nbneuron[i]); + noise[i]=std::stof(s_noise[i]); + regularization[i]=std::stof(s_regularization[i]); + rho[i]=std::stof(s_rho[i]); + beta[i]=std::stof(s_beta[i]); } std::cout << nb_neuron << std::endl; dimredTrainer->SetNumberOfHiddenNeurons(nb_neuron); dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); - dimredTrainer->SetRegularization(GetParameterFloat("model.autoencoder.regularization")); - dimredTrainer->SetNoise(GetParameterFloat("model.autoencoder.noise")); + dimredTrainer->SetRegularization(regularization); + dimredTrainer->SetNoise(noise); + dimredTrainer->SetRho(rho); + dimredTrainer->SetBeta(beta); dimredTrainer->SetInputListSample(trainingListSample); std::cout << "before train" << std::endl; dimredTrainer->Train(); -- GitLab From b108c5b34f53fbda6715ae02a4f957e6097ef9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Mon, 19 Jun 2017 11:06:46 +0200 Subject: [PATCH 038/567] debug --- include/AutoencoderModel.h | 1 - include/AutoencoderModel.txx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 0ca282afc0..3fd4c44748 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -3,7 +3,6 @@ #include "DimensionalityReductionModel.h" - namespace otb { template <class TInputValue, class AutoencoderType> diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index b55b5da7d4..b415e3d1d0 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -26,7 +26,7 @@ AutoencoderModel<TInputValue,AutoencoderType>::AutoencoderModel() this->m_IsDoPredictBatchMultiThreaded = true; } - + template <class TInputValue, class AutoencoderType> AutoencoderModel<TInputValue,AutoencoderType>::~AutoencoderModel() { -- GitLab From a30fb6f27767731a488855658600a4772e853692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 20 Jun 2017 10:02:30 +0200 Subject: [PATCH 039/567] som is now a machine learning model, ae and pca have been deactiveted --- app/cbDimensionalityReductionTrainer.cxx | 2 +- include/AutoencoderModel.txx | 1 - include/DimensionalityReductionModelFactory.h | 2 +- .../DimensionalityReductionModelFactory.txx | 15 +++--- include/SOMModel.h | 52 +++++++++++-------- include/SOMModel.txx | 3 +- include/cbLearningApplicationBaseDR.h | 25 +++++---- include/cbLearningApplicationBaseDR.txx | 7 +-- otb-module.cmake | 2 +- 9 files changed, 59 insertions(+), 50 deletions(-) diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index dd245a44e5..0f085d4c49 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -9,7 +9,7 @@ #include "otbShiftScaleSampleListFilter.h" #include "otbStatisticsXMLFileReader.h" -#include "otbSharkUtils.h" +//#include "otbSharkUtils.h" #include <fstream> // write the model file diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index b415e3d1d0..a23adb9ba2 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -1,4 +1,3 @@ - #ifndef AutoencoderModel_txx #define AutoencoderModel_txx diff --git a/include/DimensionalityReductionModelFactory.h b/include/DimensionalityReductionModelFactory.h index e7a913cc07..791199b5e8 100644 --- a/include/DimensionalityReductionModelFactory.h +++ b/include/DimensionalityReductionModelFactory.h @@ -20,7 +20,7 @@ #include "DimensionalityReductionModel.h" #include "otbMachineLearningModelFactoryBase.h" - + namespace otb { /** \class MachineLearningModelFactory diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 5ccf34a388..a546978fb7 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -22,25 +22,25 @@ #include "otbConfigure.h" #include "SOMModelFactory.h" - +/* #ifdef OTB_USE_SHARK #include "AutoencoderModelFactory.h" #include "PCAModelFactory.h" #endif - +*/ #include "itkMutexLockHolder.h" namespace otb { - +/* template <class TInputValue, class TTargetValue> using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ; template <class TInputValue, class TTargetValue> using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; - +*/ template <class TInputValue, class TTargetValue> using SOM2DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 2> ; @@ -115,13 +115,13 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> RegisterFactory(SOM3DModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(SOM4DModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(SOM5DModelFactory<TInputValue,TOutputValue>::New()); - + /* #ifdef OTB_USE_SHARK RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(AutoencoderModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); #endif - + */ } template <class TInputValue, class TOutputValue> @@ -182,6 +182,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> itk::ObjectFactoryBase::UnRegisterFactory(som2dFactory); continue; } + /* #ifdef OTB_USE_SHARK // Autoencoder @@ -210,7 +211,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> continue; } #endif - +*/ } } diff --git a/include/SOMModel.h b/include/SOMModel.h index 290ee45c60..846b0f2a2e 100644 --- a/include/SOMModel.h +++ b/include/SOMModel.h @@ -1,7 +1,7 @@ #ifndef SOMModel_h #define SOMModel_h -#include "DimensionalityReductionModel.h" +//#include "DimensionalityReductionModel.h" #include "otbSOMMap.h" #include "otbSOM.h" @@ -11,38 +11,45 @@ #include "otbCzihoSOMLearningBehaviorFunctor.h" #include "otbCzihoSOMNeighborhoodBehaviorFunctor.h" - +#include "otbMachineLearningModelTraits.h" +#include "otbMachineLearningModel.h" namespace otb { template <class TInputValue, unsigned int MapDimension> -class ITK_EXPORT SOMModel: public DimensionalityReductionModel<TInputValue,TInputValue> +class ITK_EXPORT SOMModel: public MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> { public: typedef SOMModel Self; - typedef DimensionalityReductionModel<TInputValue,TInputValue> Superclass; + typedef MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - typedef typename Superclass::InputValueType InputValueType; - typedef typename Superclass::InputSampleType InputSampleType; - typedef typename Superclass::InputListSampleType InputListSampleType; - typedef typename InputListSampleType::Pointer ListSamplePointerType; - typedef typename Superclass::TargetValueType TargetValueType; - typedef typename Superclass::TargetSampleType TargetSampleType; - typedef typename Superclass::TargetListSampleType TargetListSampleType; + typedef typename Superclass::InputValueType InputValueType; + typedef typename Superclass::InputSampleType InputSampleType; + typedef typename Superclass::InputListSampleType InputListSampleType; + typedef typename InputListSampleType::Pointer ListSamplePointerType; + typedef typename Superclass::TargetValueType TargetValueType; + typedef typename Superclass::TargetSampleType TargetSampleType; + typedef typename Superclass::TargetListSampleType TargetListSampleType; - typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, MapDimension> MapType; - typedef typename MapType::SizeType SizeType; - typedef typename MapType::SpacingType SpacingType; + /// Confidence map related typedefs - typedef otb::SOM<InputListSampleType, MapType> EstimatorType; + typedef typename Superclass::ConfidenceValueType ConfidenceValueType; + typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; + typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; - - typedef Functor::CzihoSOMLearningBehaviorFunctor SOMLearningBehaviorFunctorType; - typedef Functor::CzihoSOMNeighborhoodBehaviorFunctor SOMNeighborhoodBehaviorFunctorType; + + + typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, MapDimension> MapType; + typedef typename MapType::SizeType SizeType; + typedef typename MapType::SpacingType SpacingType; + typedef otb::SOM<InputListSampleType, MapType> EstimatorType; + + typedef Functor::CzihoSOMLearningBehaviorFunctor SOMLearningBehaviorFunctorType; + typedef Functor::CzihoSOMNeighborhoodBehaviorFunctor SOMNeighborhoodBehaviorFunctorType; itkNewMacro(Self); itkTypeMacro(SOMModel, DimensionalityReductionModel); @@ -72,8 +79,8 @@ public: bool CanReadFile(const std::string & filename); bool CanWriteFile(const std::string & filename); - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string & filename, const std::string & name="") ; + void Load(const std::string & filename, const std::string & name="") ; void Train() ITK_OVERRIDE; //void Dimensionality_reduction() {}; // Dimensionality reduction is done by DoPredict @@ -83,11 +90,10 @@ protected: SOMModel(); ~SOMModel() ITK_OVERRIDE; - virtual TargetSampleType DoPredict(const InputSampleType& input) const ITK_OVERRIDE; - private: typename MapType::Pointer m_SOMMap; - + + virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType * quality = ITK_NULLPTR) const; /** Map Parameters used for training */ diff --git a/include/SOMModel.txx b/include/SOMModel.txx index 13765ccbfb..29e226f4da 100644 --- a/include/SOMModel.txx +++ b/include/SOMModel.txx @@ -1,4 +1,3 @@ - #ifndef SOMModel_txx #define SOMModel_txx @@ -177,7 +176,7 @@ void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, con template <class TInputValue, unsigned int MapDimension> typename SOMModel<TInputValue, MapDimension>::TargetSampleType -SOMModel<TInputValue, MapDimension>::DoPredict(const InputSampleType & value) const +SOMModel<TInputValue, MapDimension>::DoPredict(const InputSampleType & value, ConfidenceValueType * quality) const { unsigned int dimension =MapType::ImageDimension; TargetSampleType target; diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index a45024aa47..71c31f40fe 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -15,12 +15,12 @@ #include "DimensionalityReductionModelFactory.h" #include "SOMModel.h" - +/* #ifdef OTB_USE_SHARK #include "AutoencoderModel.h" #include "PCAModel.h" #endif - +*/ namespace otb { namespace Wrapper @@ -99,7 +99,7 @@ public: typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; - +/* #ifdef OTB_USE_SHARK typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; typedef otb::AutoencoderModel<InputValueType, AutoencoderType> AutoencoderModelType; @@ -109,7 +109,7 @@ public: typedef otb::PCAModel<InputValueType> PCAModelType; #endif - + */ protected: cbLearningApplicationBaseDR(); @@ -131,11 +131,15 @@ private: /** Specific Init and Train methods for each machine learning model */ //@{ - + + void InitSOMParams(); + template <class somchoice> + void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); +/* #ifdef OTB_USE_SHARK void InitAutoencoderParams(); void InitPCAParams(); - void InitSOMParams(); void BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); template <class autoencoderchoice> @@ -143,10 +147,8 @@ private: void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); - template <class somchoice> - void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); - void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); -#endif + +#endif */ //@} }; @@ -156,10 +158,11 @@ private: #ifndef OTB_MANUAL_INSTANTIATION #include "cbLearningApplicationBaseDR.txx" #include "cbTrainSOM.txx" +/* #ifdef OTB_USE_SHARK #include "cbTrainAutoencoder.txx" #include "cbTrainPCA.txx" -#endif +#endif*/ #endif #endif diff --git a/include/cbLearningApplicationBaseDR.txx b/include/cbLearningApplicationBaseDR.txx index 5603cca4f6..2befe3e396 100644 --- a/include/cbLearningApplicationBaseDR.txx +++ b/include/cbLearningApplicationBaseDR.txx @@ -50,11 +50,12 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> InitSOMParams(); + /* #ifdef OTB_USE_SHARK InitAutoencoderParams(); InitPCAParams(); #endif - + */ } template <class TInputValue, class TOutputValue> @@ -79,7 +80,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> { BeforeTrainSOM(trainingListSample,modelPath); } - + /* if(modelName == "autoencoder") { #ifdef OTB_USE_SHARK @@ -104,7 +105,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> #else otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); #endif - } + }*/ } } diff --git a/otb-module.cmake b/otb-module.cmake index f4a7c8f8ca..258fdf1c44 100644 --- a/otb-module.cmake +++ b/otb-module.cmake @@ -6,9 +6,9 @@ otb_module(CbDimensionalityReduction OTBITK OTBShark OTBBoost - OTBSupervised OTBAppClassification OTBSOM + OTBLearningBase DESCRIPTION "${DOCUMENTATION}" ) -- GitLab From ea53b86767b0084fbe08a3eef9590d3de74fad0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 21 Jun 2017 09:42:51 +0200 Subject: [PATCH 040/567] DR is now based on Machine Learning Models, it is now possible to reduce de dimension of the pca model (it has to be changed in PCAModel.txx for now --- app/cbDimensionalityReductionVector.cxx | 20 +++++------ include/AutoencoderModel.h | 29 ++++++++++------ include/AutoencoderModel.txx | 4 +-- include/DimensionalityReductionModelFactory.h | 6 ++-- .../DimensionalityReductionModelFactory.txx | 24 ++++++++------ include/ImageDimensionalityReductionFilter.h | 5 +-- include/PCAModel.h | 33 ++++++++++++------- include/PCAModel.txx | 9 +++-- include/cbLearningApplicationBaseDR.h | 16 ++++----- include/cbLearningApplicationBaseDR.txx | 8 ++--- 10 files changed, 93 insertions(+), 61 deletions(-) diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index 90927c56c4..25ac852bd4 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -27,7 +27,7 @@ #include "itkListSample.h" #include "otbShiftScaleSampleListFilter.h" #include "DimensionalityReductionModelFactory.h" -#include "DimensionalityReductionModel.h" +//#include "DimensionalityReductionModel.h" #include <time.h> namespace otb @@ -57,16 +57,16 @@ class CbDimensionalityReductionVector : public Application /** Filters typedef */ - typedef double ValueType; - typedef DimensionalityReductionModel<ValueType,ValueType> DimensionalityReductionModelType; - typedef DimensionalityReductionModelFactory<ValueType, ValueType> DimensionalityReductionModelFactoryType; - typedef DimensionalityReductionModelType::Pointer ModelPointerType; + typedef double ValueType; + typedef itk::VariableLengthVector<ValueType> InputSampleType; + typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; + typedef MachineLearningModel<itk::VariableLengthVector<ValueType>, itk::VariableLengthVector<ValueType>> DimensionalityReductionModelType; + typedef DimensionalityReductionModelFactory<ValueType,ValueType> DimensionalityReductionModelFactoryType; + typedef DimensionalityReductionModelType::Pointer ModelPointerType; /** Statistics Filters typedef */ - typedef itk::VariableLengthVector<ValueType> MeasurementType; - typedef otb::StatisticsXMLFileReader<MeasurementType> StatisticsReader; - typedef itk::VariableLengthVector<ValueType> InputSampleType; - typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; + typedef itk::VariableLengthVector<ValueType> MeasurementType; + typedef otb::StatisticsXMLFileReader<MeasurementType> StatisticsReader; typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; ~CbDimensionalityReductionVector() ITK_OVERRIDE { @@ -211,7 +211,7 @@ class CbDimensionalityReductionVector : public Application /** Read the model */ - + std::cout << "create the fact ?" << std::endl; m_Model = DimensionalityReductionModelFactoryType::CreateDimensionalityReductionModel(GetParameterString("model"), DimensionalityReductionModelFactoryType::ReadMode); if (m_Model.IsNull()) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 3fd4c44748..e9dd9d2b66 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -6,23 +6,31 @@ namespace otb { template <class TInputValue, class AutoencoderType> -class ITK_EXPORT AutoencoderModel: public DimensionalityReductionModel<TInputValue,TInputValue> +class ITK_EXPORT AutoencoderModel: public MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> { public: typedef AutoencoderModel Self; - typedef DimensionalityReductionModel<TInputValue,TInputValue> Superclass; + typedef MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - typedef typename Superclass::InputValueType InputValueType; - typedef typename Superclass::InputSampleType InputSampleType; - typedef typename Superclass::InputListSampleType InputListSampleType; - typedef typename Superclass::TargetValueType TargetValueType; - typedef typename Superclass::TargetSampleType TargetSampleType; - typedef typename Superclass::TargetListSampleType TargetListSampleType; + typedef typename Superclass::InputValueType InputValueType; + typedef typename Superclass::InputSampleType InputSampleType; + typedef typename Superclass::InputListSampleType InputListSampleType; + typedef typename InputListSampleType::Pointer ListSamplePointerType; + typedef typename Superclass::TargetValueType TargetValueType; + typedef typename Superclass::TargetSampleType TargetSampleType; + typedef typename Superclass::TargetListSampleType TargetListSampleType; + + /// Confidence map related typedefs + typedef typename Superclass::ConfidenceValueType ConfidenceValueType; + typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; + typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; + + itkNewMacro(Self); itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); @@ -59,8 +67,9 @@ protected: AutoencoderModel(); ~AutoencoderModel() ITK_OVERRIDE; - virtual TargetSampleType DoPredict(const InputSampleType& input) const ITK_OVERRIDE; - virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *) const ITK_OVERRIDE; + virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType * quality = ITK_NULLPTR) const; + + virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * quality = ITK_NULLPTR) const; private: diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index a23adb9ba2..3060d8fb30 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -171,7 +171,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & fil template <class TInputValue, class AutoencoderType> typename AutoencoderModel<TInputValue,AutoencoderType>::TargetSampleType -AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value) const +AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value, ConfidenceValueType * quality) const { shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) @@ -200,7 +200,7 @@ AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType> -::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets) const +::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const { std::vector<shark::RealVector> features; Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); diff --git a/include/DimensionalityReductionModelFactory.h b/include/DimensionalityReductionModelFactory.h index 791199b5e8..16fa0f416d 100644 --- a/include/DimensionalityReductionModelFactory.h +++ b/include/DimensionalityReductionModelFactory.h @@ -18,9 +18,11 @@ #ifndef DimensionalityReductionModelFactory_h #define DimensionalityReductionModelFactory_h -#include "DimensionalityReductionModel.h" +//#include "DimensionalityReductionModel.h" #include "otbMachineLearningModelFactoryBase.h" +#include "otbMachineLearningModel.h" + namespace otb { /** \class MachineLearningModelFactory @@ -44,7 +46,7 @@ public: itkTypeMacro(DimensionalityReductionModelFactory, itk::Object); /** Convenient typedefs. */ - typedef otb::DimensionalityReductionModel<TInputValue,TOutputValue> DimensionalityReductionModelType; + typedef otb::MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TOutputValue>> DimensionalityReductionModelType; typedef typename DimensionalityReductionModelType::Pointer DimensionalityReductionModelTypePointer; /** Mode in which the files is intended to be used */ diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index a546978fb7..ac8f40c680 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -22,25 +22,25 @@ #include "otbConfigure.h" #include "SOMModelFactory.h" -/* + #ifdef OTB_USE_SHARK #include "AutoencoderModelFactory.h" #include "PCAModelFactory.h" #endif -*/ + #include "itkMutexLockHolder.h" namespace otb { -/* + template <class TInputValue, class TTargetValue> using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ; template <class TInputValue, class TTargetValue> using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; -*/ + template <class TInputValue, class TTargetValue> using SOM2DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 2> ; @@ -56,7 +56,7 @@ using SOM5DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 5> ; template <class TInputValue, class TOutputValue> -typename DimensionalityReductionModel<TInputValue,TOutputValue>::Pointer +typename MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TOutputValue>>::Pointer DimensionalityReductionModelFactory<TInputValue,TOutputValue> ::CreateDimensionalityReductionModel(const std::string& path, FileModeType mode) { @@ -65,26 +65,30 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> std::list<DimensionalityReductionModelTypePointer> possibleDimensionalityReductionModel; std::list<LightObject::Pointer> allobjects = itk::ObjectFactoryBase::CreateAllInstance("DimensionalityReductionModel"); + for(std::list<LightObject::Pointer>::iterator i = allobjects.begin(); i != allobjects.end(); ++i) { - DimensionalityReductionModel<TInputValue,TOutputValue> * io = dynamic_cast<DimensionalityReductionModel<TInputValue,TOutputValue>*>(i->GetPointer()); + MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TOutputValue>> * io = dynamic_cast<MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TOutputValue>>*>(i->GetPointer()); if(io) { possibleDimensionalityReductionModel.push_back(io); } else { + std::cerr << "Error DimensionalityReductionModel Factory did not return an DimensionalityReductionModel: " << (*i)->GetNameOfClass() << std::endl; } } + for(typename std::list<DimensionalityReductionModelTypePointer>::iterator k = possibleDimensionalityReductionModel.begin(); k != possibleDimensionalityReductionModel.end(); ++k) { if( mode == ReadMode ) { + if((*k)->CanReadFile(path)) { return *k; @@ -115,13 +119,13 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> RegisterFactory(SOM3DModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(SOM4DModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(SOM5DModelFactory<TInputValue,TOutputValue>::New()); - /* + #ifdef OTB_USE_SHARK RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(AutoencoderModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); #endif - */ + } template <class TInputValue, class TOutputValue> @@ -182,7 +186,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> itk::ObjectFactoryBase::UnRegisterFactory(som2dFactory); continue; } - /* + #ifdef OTB_USE_SHARK // Autoencoder @@ -211,7 +215,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> continue; } #endif -*/ + } } diff --git a/include/ImageDimensionalityReductionFilter.h b/include/ImageDimensionalityReductionFilter.h index e550b1944d..008c57d2a4 100644 --- a/include/ImageDimensionalityReductionFilter.h +++ b/include/ImageDimensionalityReductionFilter.h @@ -19,7 +19,8 @@ #define ImageDimensionalityReduction_h #include "itkImageToImageFilter.h" -#include "DimensionalityReductionModel.h" +//#include "DimensionalityReductionModel.h" +#include "otbMachineLearningModel.h" #include "otbImage.h" namespace otb @@ -66,7 +67,7 @@ public: typedef typename OutputImageType::RegionType OutputImageRegionType; typedef typename OutputImageType::InternalPixelType LabelType; - typedef DimensionalityReductionModel<ValueType, LabelType> ModelType; + typedef MachineLearningModel<itk::VariableLengthVector<ValueType>, itk::VariableLengthVector<LabelType>> ModelType; typedef typename ModelType::Pointer ModelPointerType; typedef otb::Image<double> ConfidenceImageType; diff --git a/include/PCAModel.h b/include/PCAModel.h index 45693dfc8a..d5557eb169 100644 --- a/include/PCAModel.h +++ b/include/PCAModel.h @@ -7,29 +7,39 @@ namespace otb { template <class TInputValue> -class ITK_EXPORT PCAModel: public DimensionalityReductionModel<TInputValue,TInputValue> +class ITK_EXPORT PCAModel: public MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> { public: typedef PCAModel Self; - typedef DimensionalityReductionModel<TInputValue,TInputValue> Superclass; + typedef MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - typedef typename Superclass::InputValueType InputValueType; - typedef typename Superclass::InputSampleType InputSampleType; - typedef typename Superclass::InputListSampleType InputListSampleType; - typedef typename Superclass::TargetValueType TargetValueType; - typedef typename Superclass::TargetSampleType TargetSampleType; - typedef typename Superclass::TargetListSampleType TargetListSampleType; + typedef typename Superclass::InputValueType InputValueType; + typedef typename Superclass::InputSampleType InputSampleType; + typedef typename Superclass::InputListSampleType InputListSampleType; + typedef typename InputListSampleType::Pointer ListSamplePointerType; + typedef typename Superclass::TargetValueType TargetValueType; + typedef typename Superclass::TargetSampleType TargetSampleType; + typedef typename Superclass::TargetListSampleType TargetListSampleType; + + /// Confidence map related typedefs + typedef typename Superclass::ConfidenceValueType ConfidenceValueType; + typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; + typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; + + itkNewMacro(Self); itkTypeMacro(PCAModel, DimensionalityReductionModel); unsigned int GetDimension() {return m_Dimension;}; itkSetMacro(Dimension,unsigned int); + itkSetMacro(Do_resize_flag,bool); + bool CanReadFile(const std::string & filename); bool CanWriteFile(const std::string & filename); @@ -44,15 +54,16 @@ protected: PCAModel(); ~PCAModel() ITK_OVERRIDE; - virtual TargetSampleType DoPredict(const InputSampleType& input) const ITK_OVERRIDE; - virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *) const ITK_OVERRIDE; + virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType * quality = ITK_NULLPTR) const; + + virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * quality = ITK_NULLPTR) const ITK_OVERRIDE; private: shark::LinearModel<> m_encoder; shark::LinearModel<> m_decoder; shark::PCA m_pca; unsigned int m_Dimension; - + bool m_Do_resize_flag; }; } // end namespace otb diff --git a/include/PCAModel.txx b/include/PCAModel.txx index 8f48040388..9cda11ec90 100644 --- a/include/PCAModel.txx +++ b/include/PCAModel.txx @@ -40,6 +40,7 @@ void PCAModel<TInputValue>::Train() shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); m_pca.setData(inputSamples); m_pca.encoder(m_encoder, m_Dimension); + std::cout << m_encoder.matrix() << std::endl; m_pca.decoder(m_decoder, m_Dimension); } @@ -94,13 +95,17 @@ void PCAModel<TInputValue>::Load(const std::string & filename, const std::string m_encoder.read(ia); ifs.close(); m_Dimension = m_encoder.outputSize(); + auto eigenvectors = m_encoder.matrix(); + eigenvectors.resize(2,m_encoder.inputSize()); + m_encoder.setStructure(eigenvectors, m_encoder.offset() ); + std::cout << m_encoder.matrix() << std::endl; //this->m_Size = m_NumberOfHiddenNeurons; } template <class TInputValue> typename PCAModel<TInputValue>::TargetSampleType -PCAModel<TInputValue>::DoPredict(const InputSampleType & value) const +PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueType * quality) const { shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) @@ -126,7 +131,7 @@ PCAModel<TInputValue>::DoPredict(const InputSampleType & value) const template <class TInputValue> void PCAModel<TInputValue> -::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets) const +::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const { std::vector<shark::RealVector> features; diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 71c31f40fe..b3bf030786 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -15,12 +15,12 @@ #include "DimensionalityReductionModelFactory.h" #include "SOMModel.h" -/* + #ifdef OTB_USE_SHARK #include "AutoencoderModel.h" #include "PCAModel.h" #endif -*/ + namespace otb { namespace Wrapper @@ -99,7 +99,7 @@ public: typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; -/* + #ifdef OTB_USE_SHARK typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; typedef otb::AutoencoderModel<InputValueType, AutoencoderType> AutoencoderModelType; @@ -109,7 +109,7 @@ public: typedef otb::PCAModel<InputValueType> PCAModelType; #endif - */ + protected: cbLearningApplicationBaseDR(); @@ -136,7 +136,7 @@ private: template <class somchoice> void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); -/* + #ifdef OTB_USE_SHARK void InitAutoencoderParams(); void InitPCAParams(); @@ -148,7 +148,7 @@ private: void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); -#endif */ +#endif //@} }; @@ -158,11 +158,11 @@ private: #ifndef OTB_MANUAL_INSTANTIATION #include "cbLearningApplicationBaseDR.txx" #include "cbTrainSOM.txx" -/* + #ifdef OTB_USE_SHARK #include "cbTrainAutoencoder.txx" #include "cbTrainPCA.txx" -#endif*/ +#endif #endif #endif diff --git a/include/cbLearningApplicationBaseDR.txx b/include/cbLearningApplicationBaseDR.txx index 2befe3e396..a42ad73857 100644 --- a/include/cbLearningApplicationBaseDR.txx +++ b/include/cbLearningApplicationBaseDR.txx @@ -50,12 +50,12 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> InitSOMParams(); - /* + #ifdef OTB_USE_SHARK InitAutoencoderParams(); InitPCAParams(); #endif - */ + } template <class TInputValue, class TOutputValue> @@ -80,7 +80,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> { BeforeTrainSOM(trainingListSample,modelPath); } - /* + if(modelName == "autoencoder") { #ifdef OTB_USE_SHARK @@ -105,7 +105,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> #else otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); #endif - }*/ + } } } -- GitLab From 717f6f9320a64702914a3538e4eef61f45d5be57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 21 Jun 2017 10:31:45 +0200 Subject: [PATCH 041/567] DRmodel headers removed (MLmodels are used instead) --- include/AutoencoderModel.h | 3 +- include/DimensionalityReductionModel.h | 189 ----------------------- include/DimensionalityReductionModel.txx | 143 ----------------- include/PCAModel.h | 4 +- 4 files changed, 5 insertions(+), 334 deletions(-) delete mode 100644 include/DimensionalityReductionModel.h delete mode 100644 include/DimensionalityReductionModel.txx diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index e9dd9d2b66..939f592610 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -1,7 +1,8 @@ #ifndef AutoencoderModel_h #define AutoencoderModel_h -#include "DimensionalityReductionModel.h" +#include "otbMachineLearningModelTraits.h" +#include "otbMachineLearningModel.h" namespace otb { diff --git a/include/DimensionalityReductionModel.h b/include/DimensionalityReductionModel.h deleted file mode 100644 index c5026551ee..0000000000 --- a/include/DimensionalityReductionModel.h +++ /dev/null @@ -1,189 +0,0 @@ -/*========================================================================= - - 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. - -=========================================================================*/ -#ifndef DimensionalityReductionModel_h -#define DimensionalityReductionModel_h - -#include "itkObject.h" -#include "itkVariableLengthVector.h" -#include "itkListSample.h" - -namespace otb -{ - -/** \class DimensionalityReductionModel - * \brief DimensionalityReductionModel is the base class for all dimensionality Reduction objects (PCA, autoencoders and SOM) implemented in the dimensionality Reduction framework of the OTB. - * - * DimensionalityReductionModel is an abstract object that specifies behavior and - * interface of dimensionality reduction algorithms (PCA, autoencoders and SOM) in the generic dimensionality Reduction framework of the OTB. - * The main generic virtual methods specifically implemented in each model - * derived from the DimensionalityReductionModel class are two learning-related methods: - * Train() and Save(), and three dimensionality reduction related methods: Load(), - * DoPredict() and optionnaly DoPredictBatch(). - * - * Thus, each classifier derived from the MachineLearningModel class - * computes its corresponding model with Train() and exports it with - * the help of the Save() method. - * - * It is also possible to reduce the dimensionality of any input sample composed of several - * features (or any number of bands in the case of a pixel extracted - * from a multi-band image) with the help of the Predict() method which - * needs a previous loading of the classification model with the Load() method. - * - * \sa DimensionalityReductionModelFactory - * \sa SOMModel - * \sa PCAModel - * \sa AutoencderModel - * \sa ImageDimensionalityReductionFilter - * - * \ingroup cbDimensionalityReduction - */ -template <class TInputValue, class TTargetValue> -class ITK_EXPORT DimensionalityReductionModel - : public itk::Object -{ -public: - /**\name Standard ITK typedefs */ - //@{ - typedef DimensionalityReductionModel Self; - typedef itk::Object Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - //@} - - /**\name Input related typedefs */ - //@{ - typedef TInputValue InputValueType; - typedef itk::VariableLengthVector<InputValueType> InputSampleType; - typedef itk::Statistics::ListSample<InputSampleType> InputListSampleType; - //@} - - /**\name Target related typedefs */ - //@{ - typedef TTargetValue TargetValueType; - typedef itk::VariableLengthVector<TargetValueType> TargetSampleType; - typedef itk::Statistics::ListSample<TargetSampleType> TargetListSampleType; - //@} - - /**\name Standard macros */ - //@{ - /** Run-time type information (and related methods). */ - itkTypeMacro(DimensionalityReductionModel, itk::Object); - //@} - - /** Train the machine learning model */ - virtual void Train() =0; - - /** Predict a single sample - * \param input The sample - * \param quality A pointer to the quality variable were to store - * quality value, or NULL - * \return The predicted label - */ - TargetSampleType Predict(const InputSampleType& input) const; - - - - /** Predict a batch of samples (InputListSampleType) - * \param input The batch of sample to predict - * \param quality A pointer to the list were to store - * quality value, or NULL - * \return The predicted labels - * Note that this method will be multi-threaded if OTB is built - * with OpenMP. - */ - typename TargetListSampleType::Pointer PredictBatch(const InputListSampleType * input) const; - - /** Get the size of the output after dimensionality reduction */ - virtual unsigned int GetDimension() = 0; - - /**\name Dimensionality Reduction model file manipulation */ - //@{ - /** Save the model to file */ - virtual void Save(const std::string & filename, const std::string & name="") = 0; - - /** Load the model from file */ - virtual void Load(const std::string & filename, const std::string & name="") = 0; - //@} - - /**\name Classification model file compatibility tests */ - //@{ - /** Is the input model file readable and compatible with the corresponding model ? */ - virtual bool CanReadFile(const std::string &) = 0; - - /** Is the input model file writable and compatible with the corresponding model ? */ - virtual bool CanWriteFile(const std::string &) = 0; - //@} - - /**\name Input list of samples accessors */ - //@{ - itkSetObjectMacro(InputListSample,InputListSampleType); - itkGetObjectMacro(InputListSample,InputListSampleType); - itkGetConstObjectMacro(InputListSample,InputListSampleType); - //@} - - - - -protected: - /** Constructor */ - DimensionalityReductionModel(); - - /** Destructor */ - ~DimensionalityReductionModel() ITK_OVERRIDE; - - /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - - /** Input list sample */ - typename InputListSampleType::Pointer m_InputListSample; - - /** Is DoPredictBatch multi-threaded ? */ - bool m_IsDoPredictBatchMultiThreaded; - -private: - /** Actual implementation of BatchPredicition - * Default implementation will call DoPredict iteratively - * \param input The input batch - * \param startIndex Index of the first sample to reduce - * \param size Number of samples to reduce - * \param target Pointer to the list of reduced samples - * - * Override me if internal implementation allows for batch - * prediction. - * - * Also set m_IsDoPredictBatchMultiThreaded to true if internal - * implementation allows for parallel batch prediction. - */ - virtual void DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * target) const; - - /** Actual implementation of single sample reduction - * \param input sample to reduce - * \return The reduced sample - */ - virtual TargetSampleType DoPredict(const InputSampleType& input) const = 0; - - DimensionalityReductionModel(const Self &); //purposely not implemented - void operator =(const Self&); //purposely not implemented -}; -} // end namespace otb - -#ifndef OTB_MANUAL_INSTANTIATION -#include "DimensionalityReductionModel.txx" -#endif - -#endif diff --git a/include/DimensionalityReductionModel.txx b/include/DimensionalityReductionModel.txx deleted file mode 100644 index 5f49754f8c..0000000000 --- a/include/DimensionalityReductionModel.txx +++ /dev/null @@ -1,143 +0,0 @@ -/*========================================================================= - - 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. - -=========================================================================*/ -#ifndef DimensionalityReductionModel_txx -#define DimensionalityReductionModel_txx - -#ifdef _OPENMP - # include <omp.h> -#endif - -#include "DimensionalityReductionModel.h" - -#include "itkMultiThreader.h" - -namespace otb -{ - -template <class TInputValue, class TOutputValue> -DimensionalityReductionModel<TInputValue,TOutputValue> -::DimensionalityReductionModel() -{ this->m_IsDoPredictBatchMultiThreaded=false;} - - -template <class TInputValue, class TOutputValue> -DimensionalityReductionModel<TInputValue,TOutputValue> -::~DimensionalityReductionModel() -{} - - - -template <class TInputValue, class TOutputValue> -typename DimensionalityReductionModel<TInputValue,TOutputValue> -::TargetSampleType -DimensionalityReductionModel<TInputValue,TOutputValue> -::Predict(const InputSampleType& input) const -{ - // Call protected specialization entry point - return this->DoPredict(input); -} - - -template <class TInputValue, class TOutputValue> -typename DimensionalityReductionModel<TInputValue,TOutputValue> -::TargetListSampleType::Pointer -DimensionalityReductionModel<TInputValue,TOutputValue> -::PredictBatch(const InputListSampleType * input) const -{ - typename TargetListSampleType::Pointer targets = TargetListSampleType::New(); - targets->Resize(input->Size()); - - - if(m_IsDoPredictBatchMultiThreaded) - { - // Simply calls DoPredictBatch - this->DoPredictBatch(input,0,input->Size(),targets); - return targets; - } - else - { - - #ifdef _OPENMP - // OpenMP threading here - unsigned int nb_threads(0), threadId(0), nb_batches(0); - - #pragma omp parallel shared(nb_threads,nb_batches) private(threadId) - { - // Get number of threads configured with ITK - omp_set_num_threads(itk::MultiThreader::GetGlobalDefaultNumberOfThreads()); - nb_threads = omp_get_num_threads(); - threadId = omp_get_thread_num(); - nb_batches = std::min(nb_threads,(unsigned int)input->Size()); - // Ensure that we do not spawn unncessary threads - if(threadId<nb_batches) - { - unsigned int batch_size = ((unsigned int)input->Size()/nb_batches); - unsigned int batch_start = threadId*batch_size; - if(threadId == nb_threads-1) - { - batch_size+=input->Size()%nb_batches; - } - - this->DoPredictBatch(input,batch_start,batch_size,targets); - } - } - #else - this->DoPredictBatch(input,0,input->Size(),targets); - #endif - return targets; - } -} - - - -template <class TInputValue, class TOutputValue> -void -DimensionalityReductionModel<TInputValue,TOutputValue> -::DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets) const -{ - assert(input != ITK_NULLPTR); - assert(targets != ITK_NULLPTR); - - assert(input->Size()==targets->Size()&&"Input sample list and target label list do not have the same size."); - assert(((quality==ITK_NULLPTR)||(quality->Size()==input->Size()))&&"Quality samples list is not null and does not have the same size as input samples list"); - - if(startIndex+size>input->Size()) - { - itkExceptionMacro(<<"requested range ["<<startIndex<<", "<<startIndex+size<<"[ partially outside input sample list range.[0,"<<input->Size()<<"["); - } - - - for(unsigned int id = startIndex;id<startIndex+size;++id) - { - const TargetSampleType target = this->DoPredict(input->GetMeasurementVector(id)); - targets->SetMeasurementVector(id,target); - } - -} - -template <class TInputValue, class TOutputValue> -void -DimensionalityReductionModel<TInputValue,TOutputValue> -::PrintSelf(std::ostream& os, itk::Indent indent) const -{ - // Call superclass implementation - Superclass::PrintSelf(os,indent); -} -} - -#endif diff --git a/include/PCAModel.h b/include/PCAModel.h index d5557eb169..f26f2233a3 100644 --- a/include/PCAModel.h +++ b/include/PCAModel.h @@ -1,7 +1,9 @@ #ifndef PCAModel_h #define PCAModel_h -#include "DimensionalityReductionModel.h" +#include "otbMachineLearningModelTraits.h" +#include "otbMachineLearningModel.h" + #include <shark/Algorithms/Trainers/PCA.h> namespace otb -- GitLab From 7b717e3ab5f99fa1d74424df6e7567eb5138e1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Mon, 26 Jun 2017 11:39:09 +0200 Subject: [PATCH 042/567] Get Dimension method added, this method needs to be overrided in the DR models --- Modules/Learning/LearningBase/include/otbMachineLearningModel.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModel.h b/Modules/Learning/LearningBase/include/otbMachineLearningModel.h index 552880cb9a..1de069ab6d 100644 --- a/Modules/Learning/LearningBase/include/otbMachineLearningModel.h +++ b/Modules/Learning/LearningBase/include/otbMachineLearningModel.h @@ -117,6 +117,8 @@ public: TargetSampleType Predict(const InputSampleType& input, ConfidenceValueType *quality = ITK_NULLPTR) const; + virtual unsigned int GetDimension() {return 1;}; /// This method is used to determine the output vector size after dimensionality reduction, and should be overrided for all machine learning models used for dimensionality reduction. This method is not used for classification and regression + /** Predict a batch of samples (InputListSampleType) * \param input The batch of sample to predict -- GitLab From 649836a8497e9588a862a418c0dc181c8abebb4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 27 Jun 2017 11:46:34 +0200 Subject: [PATCH 043/567] m_Dimension is now an attribute of ML models, it is now possible to change the dim of a pca model --- app/cbDimensionalityReductionTrainer.cxx | 1 + app/cbDimensionalityReductionVector.cxx | 14 +++- include/AutoencoderModel.h | 18 ++++- include/AutoencoderModel.txx | 75 ++++++++++++++----- .../DimensionalityReductionModelFactory.txx | 4 +- include/PCAModel.h | 6 +- include/PCAModel.txx | 27 ++++--- include/SOMModel.h | 2 +- include/SOMModel.txx | 2 + include/cbLearningApplicationBaseDR.h | 4 +- include/cbTrainAutoencoder.txx | 8 ++ 11 files changed, 120 insertions(+), 41 deletions(-) diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index 0f085d4c49..e83231428d 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -105,6 +105,7 @@ private: MeasurementType meanMeasurementVector; MeasurementType stddevMeasurementVector; + if (HasValue("io.stats") && IsParameterEnabled("io.stats")) { StatisticsReader::Pointer statisticsReader = StatisticsReader::New(); diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index 25ac852bd4..f71f456090 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -107,6 +107,10 @@ class CbDimensionalityReductionVector : public Application "If not given, the input vector data file is updated."); MandatoryOff("out"); + AddParameter(ParameterType_Int, "pcadim", "Principal component"); // + SetParameterDescription("pcadim","This optional parameter can be set to reduce the number of eignevectors used in the PCA model file."); // + MandatoryOff("pcadim"); + // Doc example parameter settings SetDocExampleParameterValue("in", "vectorData.shp"); SetDocExampleParameterValue("instat", "meanVar.xml"); @@ -211,13 +215,21 @@ class CbDimensionalityReductionVector : public Application /** Read the model */ - std::cout << "create the fact ?" << std::endl; + m_Model = DimensionalityReductionModelFactoryType::CreateDimensionalityReductionModel(GetParameterString("model"), DimensionalityReductionModelFactoryType::ReadMode); if (m_Model.IsNull()) { otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") << " : unsupported model type"); } + if (HasValue("pcadim") && IsParameterEnabled("pcadim")) + { + int dimension = GetParameterInt("pcadim"); + m_Model->SetDimension(dimension ); + std::cout << "yo" << std::endl; + } + + m_Model->Load(GetParameterString("model")); otbAppLogINFO("Model loaded"); diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 939f592610..72dd370568 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -4,6 +4,8 @@ #include "otbMachineLearningModelTraits.h" #include "otbMachineLearningModel.h" +#include <shark/Algorithms/StoppingCriteria/AbstractStoppingCriterion.h> + namespace otb { template <class TInputValue, class AutoencoderType> @@ -35,12 +37,15 @@ public: itkNewMacro(Self); itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); - unsigned int GetDimension() {return m_NumberOfHiddenNeurons[m_net.size()-1];}; // Override the Dimensionality Reduction model method, it is used in the dimensionality reduction filter to set the output image size + //unsigned int GetDimension() {return m_NumberOfHiddenNeurons[m_net.size()-1];}; // Override the Dimensionality Reduction model method, it is used in the dimensionality reduction filter to set the output image size itkGetMacro(NumberOfHiddenNeurons,itk::Array<unsigned int>); itkSetMacro(NumberOfHiddenNeurons,itk::Array<unsigned int>); itkGetMacro(NumberOfIterations,unsigned int); itkSetMacro(NumberOfIterations,unsigned int); + + itkGetMacro(Epsilon,double); + itkSetMacro(Epsilon,double); itkGetMacro(Regularization,itk::Array<double>); itkSetMacro(Regularization,itk::Array<double>); @@ -61,8 +66,12 @@ public: void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; void Train() ITK_OVERRIDE; - void TrainOneLayer(unsigned int,double, double, shark::Data<shark::RealVector> &); - void TrainOneSparseLayer(unsigned int,double, double,double, shark::Data<shark::RealVector> &); + + template <class T> + void TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int,double, double, shark::Data<shark::RealVector> &); + + template <class T> + void TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int,double, double,double, shark::Data<shark::RealVector> &); protected: AutoencoderModel(); @@ -80,7 +89,8 @@ private: itk::Array<unsigned int> m_NumberOfHiddenNeurons; /** Training parameters */ - unsigned int m_NumberOfIterations; + unsigned int m_NumberOfIterations; // stop the training after a fixed number of iterations + double m_Epsilon; // Stops the training when the training error seems to converge itk::Array<double> m_Regularization; // L2 Regularization parameter itk::Array<double> m_Noise; // probability for an input to be set to 0 (denosing autoencoder) itk::Array<double> m_Rho; // Sparsity parameter diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 3060d8fb30..fd71a73452 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -16,6 +16,8 @@ #include <shark/Models/ImpulseNoiseModel.h> //noise source to corrupt the inputs #include <shark/Models/ConcatenatedModel.h>//to concatenate the noise with the model +#include <shark/Algorithms/StoppingCriteria/MaxIterations.h> //A simple stopping criterion that stops after a fixed number of iterations +#include <shark/Algorithms/StoppingCriteria/TrainingProgress.h> //Stops when the algorithm seems to converge, Tracks the progress of the training error over a period of time namespace otb { @@ -35,24 +37,52 @@ template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Train() { std::vector<shark::RealVector> features; + std::cout << "converting the input ListSample to Shark vector" << std::endl; Shark::ListSampleToSharkVector(this->GetInputListSample(), features); + std::cout << "creating the data vector" << std::endl; shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) - { - if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen + + if (m_Epsilon > 0){ + shark::TrainingProgress<> criterion(5,m_Epsilon); + + for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) { - TrainOneLayer( m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples); + if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen + { + TrainOneLayer(criterion, m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples); + } + else + { + TrainOneSparseLayer( criterion,m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples); + } + criterion.reset(); } - else + + } + + else { + shark::MaxIterations<> criterion(m_NumberOfIterations); + + for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) { - TrainOneSparseLayer( m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples); + if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen + { + TrainOneLayer(criterion, m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples); + } + else + { + TrainOneSparseLayer(criterion, m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples); + } + criterion.reset(); } + } } template <class TInputValue, class AutoencoderType> -void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(unsigned int nbneuron,double noise_strength,double regularization, shark::Data<shark::RealVector> &samples) +template <class T> +void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int nbneuron,double noise_strength,double regularization, shark::Data<shark::RealVector> &samples) { AutoencoderType net; @@ -64,19 +94,22 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(unsigned int n shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; shark::ErrorFunction error(trainSet, &model, &loss); - //shark::SparseAutoencoderError error(trainSet,&model, &loss, m_Rho, m_Beta); - //shark::SparseAutoencoderError error(trainSet,&net, &loss, 0.1, 0.1); + shark::TwoNormRegularizer regularizer(error.numberOfVariables()); error.setRegularizer(regularization,®ularizer); shark::IRpropPlusFull optimizer; error.init(); optimizer.init(error); - std::cout<<"Optimizing model: "+net.name()<<std::endl; - for(std::size_t i = 0; i != m_NumberOfIterations; ++i){ + + std::cout<<"error before training : " << optimizer.solution().value<<std::endl; + unsigned int i=0; + do{ + i++; optimizer.step(error); - std::cout<<i<<" "<<optimizer.solution().value<<std::endl; - } + } while( !criterion.stop( optimizer.solution() ) ); + std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; + net.setParameterVector(optimizer.solution().point); m_net.push_back(net); samples = net.encode(samples); @@ -84,7 +117,8 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(unsigned int n template <class TInputValue, class AutoencoderType> -void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(unsigned int nbneuron,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples) +template <class T> +void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int nbneuron,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples) { AutoencoderType net; @@ -102,11 +136,14 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(unsigned shark::IRpropPlusFull optimizer; error.init(); optimizer.init(error); - std::cout<<"Optimizing model: "+net.name()<<std::endl; - for(std::size_t i = 0; i != m_NumberOfIterations; ++i){ + std::cout<<"error before training : " << optimizer.solution().value<<std::endl; + unsigned int i=0; + do{ + i++; optimizer.step(error); - std::cout<<i<<" "<<optimizer.solution().value<<std::endl; - } + } while( !criterion.stop( optimizer.solution() ) ); + std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; + net.setParameterVector(optimizer.solution().point); m_net.push_back(net); samples = net.encode(samples); @@ -165,7 +202,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & fil for (int i=0; i<m_net.size(); i++){ m_NumberOfHiddenNeurons[i] = m_net[i].numberOfHiddenNeurons(); } - + this->m_Dimension = m_NumberOfHiddenNeurons[m_net.size()-1]; } diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index ac8f40c680..a4cb4b87ed 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -35,11 +35,11 @@ namespace otb { template <class TInputValue, class TTargetValue> -using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ; +using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::LogisticNeuron, shark::LogisticNeuron>> ; template <class TInputValue, class TTargetValue> -using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; +using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::LogisticNeuron, shark::LogisticNeuron>> ; template <class TInputValue, class TTargetValue> diff --git a/include/PCAModel.h b/include/PCAModel.h index f26f2233a3..bd51913803 100644 --- a/include/PCAModel.h +++ b/include/PCAModel.h @@ -36,10 +36,10 @@ public: itkNewMacro(Self); itkTypeMacro(PCAModel, DimensionalityReductionModel); - +/* unsigned int GetDimension() {return m_Dimension;}; itkSetMacro(Dimension,unsigned int); - + */ itkSetMacro(Do_resize_flag,bool); bool CanReadFile(const std::string & filename); @@ -64,7 +64,7 @@ private: shark::LinearModel<> m_encoder; shark::LinearModel<> m_decoder; shark::PCA m_pca; - unsigned int m_Dimension; + //unsigned int m_Dimension; bool m_Do_resize_flag; }; } // end namespace otb diff --git a/include/PCAModel.txx b/include/PCAModel.txx index 9cda11ec90..ec941e1f28 100644 --- a/include/PCAModel.txx +++ b/include/PCAModel.txx @@ -20,6 +20,7 @@ template <class TInputValue> PCAModel<TInputValue>::PCAModel() { this->m_IsDoPredictBatchMultiThreaded = true; + this->m_Dimension = 0; } @@ -39,9 +40,9 @@ void PCAModel<TInputValue>::Train() shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); m_pca.setData(inputSamples); - m_pca.encoder(m_encoder, m_Dimension); + m_pca.encoder(m_encoder, this->m_Dimension); std::cout << m_encoder.matrix() << std::endl; - m_pca.decoder(m_decoder, m_Dimension); + m_pca.decoder(m_decoder, this->m_Dimension); } @@ -94,11 +95,19 @@ void PCAModel<TInputValue>::Load(const std::string & filename, const std::string boost::archive::polymorphic_text_iarchive ia(ifs); m_encoder.read(ia); ifs.close(); - m_Dimension = m_encoder.outputSize(); + if (this->m_Dimension ==0) + { + this->m_Dimension = m_encoder.outputSize(); + } + else + { + std::cout << "yo" << std::endl; + } + auto eigenvectors = m_encoder.matrix(); - eigenvectors.resize(2,m_encoder.inputSize()); + eigenvectors.resize(this->m_Dimension,m_encoder.inputSize()); m_encoder.setStructure(eigenvectors, m_encoder.offset() ); - std::cout << m_encoder.matrix() << std::endl; + std::cout << m_encoder.matrix() << "end" << std::endl; //this->m_Size = m_NumberOfHiddenNeurons; } @@ -120,9 +129,9 @@ PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueT data = m_encoder(data); TargetSampleType target; - target.SetSize(m_Dimension); + target.SetSize(this->m_Dimension); - for(unsigned int a = 0; a < m_Dimension; ++a){ + for(unsigned int a = 0; a < this->m_Dimension; ++a){ target[a]=data.element(0)[a]; } return target; @@ -140,10 +149,10 @@ void PCAModel<TInputValue> TargetSampleType target; data = m_encoder(data); unsigned int id = startIndex; - target.SetSize(m_Dimension); + target.SetSize(this->m_Dimension); for(const auto& p : data.elements()){ - for(unsigned int a = 0; a < m_Dimension; ++a){ + for(unsigned int a = 0; a < this->m_Dimension; ++a){ target[a]=p[a]; //target[a]=1; diff --git a/include/SOMModel.h b/include/SOMModel.h index 846b0f2a2e..88209ed24e 100644 --- a/include/SOMModel.h +++ b/include/SOMModel.h @@ -85,7 +85,7 @@ public: void Train() ITK_OVERRIDE; //void Dimensionality_reduction() {}; // Dimensionality reduction is done by DoPredict - unsigned int GetDimension() { return MapType::ImageDimension;}; + //unsigned int GetDimension() { return MapType::ImageDimension;}; protected: SOMModel(); ~SOMModel() ITK_OVERRIDE; diff --git a/include/SOMModel.txx b/include/SOMModel.txx index 29e226f4da..7afbd6f501 100644 --- a/include/SOMModel.txx +++ b/include/SOMModel.txx @@ -22,6 +22,7 @@ namespace otb template <class TInputValue, unsigned int MapDimension> SOMModel<TInputValue, MapDimension>::SOMModel() { + //m_Dimension = typename MapType::ImageDimension; } @@ -171,6 +172,7 @@ void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, con } ifs.close(); + this->m_Dimension = MapType::ImageDimension; } diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index b3bf030786..9d0a6c6908 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -101,10 +101,10 @@ public: #ifdef OTB_USE_SHARK - typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; + typedef shark::Autoencoder< shark::LogisticNeuron, shark::LogisticNeuron> AutoencoderType; typedef otb::AutoencoderModel<InputValueType, AutoencoderType> AutoencoderModelType; - typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; + typedef shark::TiedAutoencoder< shark::LogisticNeuron, shark::LogisticNeuron> TiedAutoencoderType; typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType; typedef otb::PCAModel<InputValueType> PCAModelType; diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index dce0efbe70..4efad5dae5 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -44,6 +44,13 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> "model.autoencoder.nbiter", "The maximum number of iterations used during training."); + AddParameter(ParameterType_Float, "model.autoencoder.epsilon", + " "); + SetParameterFloat("model.autoencoder.epsilon",0, false); + SetParameterDescription( + "model.autoencoder.epsilon", + " "); + //Number Of Hidden Neurons AddParameter(ParameterType_StringList , "model.autoencoder.nbneuron", "Size"); @@ -134,6 +141,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> std::cout << nb_neuron << std::endl; dimredTrainer->SetNumberOfHiddenNeurons(nb_neuron); dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); + dimredTrainer->SetEpsilon(GetParameterFloat("model.autoencoder.epsilon")); dimredTrainer->SetRegularization(regularization); dimredTrainer->SetNoise(noise); dimredTrainer->SetRho(rho); -- GitLab From 2c525d9391ef076ec440b070bd8678f3b3f81808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 27 Jun 2017 14:50:39 +0200 Subject: [PATCH 044/567] Training an autoencoder now outputs a learning curve (txt file), work in progress --- include/AutoencoderModel.h | 10 ++++++---- include/AutoencoderModel.txx | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 72dd370568..c6038427d2 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -3,7 +3,7 @@ #include "otbMachineLearningModelTraits.h" #include "otbMachineLearningModel.h" - +#include <fstream> #include <shark/Algorithms/StoppingCriteria/AbstractStoppingCriterion.h> namespace otb @@ -68,10 +68,10 @@ public: void Train() ITK_OVERRIDE; template <class T> - void TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int,double, double, shark::Data<shark::RealVector> &); + void TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int,double, double, shark::Data<shark::RealVector> &, std::ostream&); template <class T> - void TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int,double, double,double, shark::Data<shark::RealVector> &); + void TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int,double, double,double, shark::Data<shark::RealVector> &, std::ostream&); protected: AutoencoderModel(); @@ -85,7 +85,9 @@ private: /** Network attributes */ std::vector<AutoencoderType> m_net; - + + typename InputListSampleType::Pointer m_ValidationListSample; // This list can optionnaly be used during training to prevent overfitting. + itk::Array<unsigned int> m_NumberOfHiddenNeurons; /** Training parameters */ diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index fd71a73452..ecd39a468f 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -43,6 +43,9 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); + std::ofstream ofs("/mnt/data/home/traizetc/computation/learning_curve.txt"); //learning curve + ofs << "learning curve" << std::endl; + if (m_Epsilon > 0){ shark::TrainingProgress<> criterion(5,m_Epsilon); @@ -50,11 +53,11 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() { if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen { - TrainOneLayer(criterion, m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples); + TrainOneLayer(criterion, m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples,ofs); } else { - TrainOneSparseLayer( criterion,m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples); + TrainOneSparseLayer( criterion,m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i],inputSamples, ofs); } criterion.reset(); } @@ -68,11 +71,11 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() { if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen { - TrainOneLayer(criterion, m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples); + TrainOneLayer(criterion, m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples, ofs); } else { - TrainOneSparseLayer(criterion, m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples); + TrainOneSparseLayer(criterion, m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples, ofs); } criterion.reset(); } @@ -82,7 +85,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() template <class TInputValue, class AutoencoderType> template <class T> -void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int nbneuron,double noise_strength,double regularization, shark::Data<shark::RealVector> &samples) +void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int nbneuron,double noise_strength,double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) { AutoencoderType net; @@ -103,10 +106,15 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(shark::Abstrac optimizer.init(error); std::cout<<"error before training : " << optimizer.solution().value<<std::endl; + + File << "end layer" << std::endl; + + unsigned int i=0; do{ i++; optimizer.step(error); + File << optimizer.solution().value << std::endl; } while( !criterion.stop( optimizer.solution() ) ); std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; @@ -118,7 +126,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(shark::Abstrac template <class TInputValue, class AutoencoderType> template <class T> -void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int nbneuron,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples) +void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int nbneuron,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) { AutoencoderType net; @@ -141,6 +149,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(shark::A do{ i++; optimizer.step(error); + File << optimizer.solution().value << std::endl; } while( !criterion.stop( optimizer.solution() ) ); std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; -- GitLab From 67b1912916495e374c0246d41f87a720ba1aadf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 27 Jun 2017 15:53:52 +0200 Subject: [PATCH 045/567] comments added/modified --- README.md | 25 ++++++++++++++++++++++++ app/cbDimensionalityReduction.cxx | 32 +++++++++++++------------------ 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index e69de29bb2..a46b8fbf8a 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,25 @@ +This module contains a new dimensionality reduction framework for the Orfeo Toolbox. + +The framework is based on Machine learning models and a dimensionality reduction algorithm +can be trained and used using the model class, in the same fashion as Machine Learning Models +for Classification (supervised or unspervised) and Regression. + +The algorithms featured in the module are (27/06/2017) : + - autoencoders and multi layer autoencoders, with several regularization options + - PCA + - SOM + + Autoencoders and PCA models are using Shark ML library, while SOM model is based on the SOM classes of the OTB. + + More specifically, the module contains : + + - Autoencoder models, PCA models and SOM models, with methods for training, serialization and prediction (i.e. reduction) + - A Dimensionality Reduction Model Factory and a factories for each model, which allow the user to create objects of the model classes + - A (OTB ImageToImage) filter that can be used to perform dimensionality reduction on an image. This filter supports threading and streaming + - An application for training the models according to a shapefile + - An application for using a trained model on a shapefile + - An application for using a trained model on an image (using the filter) + + /!\ Work In Progress /!\ + + diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index 6d5366e9eb..106f609d48 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -112,33 +112,27 @@ protected: private: void DoInit() ITK_OVERRIDE { - SetName("PredictRegression"); - SetDescription("Performs a prediction of the input image according to a regression model file."); + SetName("DimensionalityReduction"); + SetDescription("Performs dimensionality reduction of the input image according to a dimensionality reduction model file."); // Documentation - SetDocName("Predict Regression"); - SetDocLongDescription("This application predict output values from an input" - " image, based on a regression model file produced by" - " the TrainRegression application. Pixels of the " - "output image will contain the predicted values from" - "the regression model (single band). The input pixels" + SetDocName("DimensionalityReduction"); + SetDocLongDescription("This application reduces the dimension of an input" + " image, based on a dimensionality reduction model file produced by" + " the DimensionalityReductionTrainer application. Pixels of the " + "output image will contain the reduced values from" + "the model. The input pixels" " can be optionally centered and reduced according " "to the statistics file produced by the " - "ComputeImagesStatistics application. An optional " - "input mask can be provided, in which case only " - "input image pixels whose corresponding mask value " - "is greater than 0 will be processed. The remaining" - " of pixels will be given the value 0 in the output" - " image."); + "ComputeImagesStatistics application. "); SetDocLimitations("The input image must contain the feature bands used for" - " the model training (without the predicted value). " + " the model training. " "If a statistics file was used during training by the " "TrainRegression, it is mandatory to use the same " - "statistics file for prediction. If an input mask is " - "used, its size must match the input image size."); + "statistics file for prediction."); SetDocAuthors("OTB-Team"); - SetDocSeeAlso("TrainRegression, ComputeImagesStatistics"); + SetDocSeeAlso("DimensionalityReductionTrainer, ComputeImagesStatistics"); AddDocTag(Tags::Learning); @@ -187,7 +181,7 @@ private: inImage->UpdateOutputInformation(); unsigned int nbFeatures = inImage->GetNumberOfComponentsPerPixel(); - // Load svm model + // Load DR model using a factory otbAppLogINFO("Loading model"); m_Model = DimensionalityReductionModelFactoryType::CreateDimensionalityReductionModel(GetParameterString("model"), DimensionalityReductionModelFactoryType::ReadMode); -- GitLab From 94ab0bf1d40eaa9fb67fc81384ec6cd72282d514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 29 Jun 2017 08:53:35 +0200 Subject: [PATCH 046/567] learning curves added, field for points ID added in vector dr app output shapefile --- app/cbDimensionalityReductionVector.cxx | 25 +++++++++++++++++++++---- include/AutoencoderModel.h | 6 ++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index f71f456090..485f248b64 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -106,6 +106,11 @@ class CbDimensionalityReductionVector : public Application SetParameterDescription("out","Output vector data file storing sample values (OGR format)." "If not given, the input vector data file is updated."); MandatoryOff("out"); + + AddParameter(ParameterType_Int, "indim", "Dimension of the input vector"); + SetParameterDescription("indim","Dimension of the whole input vector, this value is required if only a part of the bands contained in the vector are used." + "If not given, the dimension is deduced from the length of the 'feat' parameter"); + MandatoryOff("indim"); AddParameter(ParameterType_Int, "pcadim", "Principal component"); // SetParameterDescription("pcadim","This optional parameter can be set to reduce the number of eignevectors used in the PCA model file."); // @@ -167,7 +172,8 @@ class CbDimensionalityReductionVector : public Application otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); otb::ogr::Layer layer = source->GetLayer(0); ListSampleType::Pointer input = ListSampleType::New(); - const int nbFeatures = GetSelectedItems("feat").size(); + int nbFeatures = GetSelectedItems("feat").size(); + input->SetMeasurementVectorSize(nbFeatures); otb::ogr::Layer::const_iterator it = layer.cbegin(); otb::ogr::Layer::const_iterator itEnd = layer.cend(); @@ -247,6 +253,10 @@ class CbDimensionalityReductionVector : public Application ogr::DataSource::Pointer output; ogr::DataSource::Pointer buffer = ogr::DataSource::New(); bool updateMode = false; + + int nbBands = nbFeatures; + if (HasValue("indim") && IsParameterEnabled("indim")) + {nbBands = GetParameterInt("indim");} if (IsParameterEnabled("out") && HasValue("out")) @@ -258,7 +268,7 @@ class CbDimensionalityReductionVector : public Application layer.GetGeomType()); // Copy existing fields OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); - for (int k=0 ; k<inLayerDefn.GetFieldCount()-nbFeatures ; k++) // we don't copy the original bands + for (int k=0 ; k<inLayerDefn.GetFieldCount()-nbBands ; k++) // we don't copy the original bands { OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); newLayer.CreateField(fieldDefn); @@ -279,8 +289,7 @@ class CbDimensionalityReductionVector : public Application // Re-open input data source in update mode output = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Update_LayerUpdate); }*/ - - + otb::ogr::Layer outLayer = output->GetLayer(0); OGRErr errStart = outLayer.ogr().StartTransaction(); @@ -310,12 +319,18 @@ class CbDimensionalityReductionVector : public Application } } + // Add an ID field. (The ID already contained in the layer refers to the polygon) + OGRFieldDefn IDField("ID_point", OFTInteger); + ogr::FieldDefn IDFieldDef(IDField); + outLayer.CreateField(IDFieldDef); + // Fill output layer unsigned int count=0; auto classfieldname = GetParameterStringList("featout"); it = layer.cbegin(); itEnd = layer.cend(); + int id=0; for( ; it!=itEnd ; ++it, ++count) { ogr::Feature dstFeature(outLayer.GetLayerDefn()); @@ -324,6 +339,7 @@ class CbDimensionalityReductionVector : public Application for (std::size_t i=0; i<classfieldname.size(); ++i){ dstFeature[classfieldname[i]].SetValue<ValueType>(target->GetMeasurementVector(count)[i]); } + dstFeature["ID_point"].SetValue<int>(id); if (updateMode) { outLayer.SetFeature(dstFeature); @@ -332,6 +348,7 @@ class CbDimensionalityReductionVector : public Application { outLayer.CreateFeature(dstFeature); } + id++; } if(outLayer.ogr().TestCapability("Transactions")) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index c6038427d2..edbe4ae052 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -86,8 +86,7 @@ private: /** Network attributes */ std::vector<AutoencoderType> m_net; - typename InputListSampleType::Pointer m_ValidationListSample; // This list can optionnaly be used during training to prevent overfitting. - + itk::Array<unsigned int> m_NumberOfHiddenNeurons; /** Training parameters */ @@ -97,6 +96,9 @@ private: itk::Array<double> m_Noise; // probability for an input to be set to 0 (denosing autoencoder) itk::Array<double> m_Rho; // Sparsity parameter itk::Array<double> m_Beta; // Sparsity regularization parameter + + bool m_WriteLearningCurve; // Flag for writting the learning curve into a txt file + }; } // end namespace otb -- GitLab From ef7227bd6785e931e25fe86358643ac90ddd2825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 29 Jun 2017 11:55:56 +0200 Subject: [PATCH 047/567] the learning curve file can now be set in the app --- include/AutoencoderModel.h | 7 +++++++ include/AutoencoderModel.txx | 29 ++++++++++++++++++++++++----- include/cbTrainAutoencoder.txx | 13 +++++++++++++ 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index edbe4ae052..739f13f6cb 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -59,6 +59,12 @@ public: itkGetMacro(Beta,itk::Array<double>); itkSetMacro(Beta,itk::Array<double>); + itkGetMacro(WriteLearningCurve,bool); + itkSetMacro(WriteLearningCurve,bool); + + itkGetMacro(LearningCurveFileName,std::string); + itkSetMacro(LearningCurveFileName,std::string); + bool CanReadFile(const std::string & filename); bool CanWriteFile(const std::string & filename); @@ -98,6 +104,7 @@ private: itk::Array<double> m_Beta; // Sparsity regularization parameter bool m_WriteLearningCurve; // Flag for writting the learning curve into a txt file + std::string m_LearningCurveFileName; // Name of the output learning curve printed after training }; } // end namespace otb diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index ecd39a468f..8788315b72 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -25,6 +25,7 @@ template <class TInputValue, class AutoencoderType> AutoencoderModel<TInputValue,AutoencoderType>::AutoencoderModel() { this->m_IsDoPredictBatchMultiThreaded = true; + this->m_WriteLearningCurve = false; } @@ -36,6 +37,7 @@ AutoencoderModel<TInputValue,AutoencoderType>::~AutoencoderModel() template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>::Train() { + std::cout << this->m_WriteLearningCurve << std::endl; std::vector<shark::RealVector> features; std::cout << "converting the input ListSample to Shark vector" << std::endl; Shark::ListSampleToSharkVector(this->GetInputListSample(), features); @@ -43,9 +45,16 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); + std::ofstream ofs; + if (this->m_WriteLearningCurve =true) + { + ofs.open(m_LearningCurveFileName); + ofs << "learning curve" << std::endl; + } + /* std::ofstream ofs("/mnt/data/home/traizetc/computation/learning_curve.txt"); //learning curve ofs << "learning curve" << std::endl; - + */ if (m_Epsilon > 0){ shark::TrainingProgress<> criterion(5,m_Epsilon); @@ -106,15 +115,19 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(shark::Abstrac optimizer.init(error); std::cout<<"error before training : " << optimizer.solution().value<<std::endl; - - File << "end layer" << std::endl; - + if (this->m_WriteLearningCurve =true) + { + File << "end layer" << std::endl; + } unsigned int i=0; do{ i++; optimizer.step(error); + if (this->m_WriteLearningCurve =true) + { File << optimizer.solution().value << std::endl; + } } while( !criterion.stop( optimizer.solution() ) ); std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; @@ -149,10 +162,16 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(shark::A do{ i++; optimizer.step(error); + if (this->m_WriteLearningCurve =true) + { File << optimizer.solution().value << std::endl; + } } while( !criterion.stop( optimizer.solution() ) ); std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; - + if (this->m_WriteLearningCurve =true) + { + File << "end layer" << std::endl; + } net.setParameterVector(optimizer.solution().point); m_net.push_back(net); samples = net.encode(samples); diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index 4efad5dae5..244441d918 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -80,6 +80,11 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> AddParameter(ParameterType_StringList, "model.autoencoder.beta", "Sparsity regularization strength"); SetParameterDescription("model.autoencoder.beta", "Sparsity regularization strength"); + + AddParameter(ParameterType_OutputFilename, "model.autoencoder.learningcurve", "Learning curve"); + SetParameterDescription("model.autoencoder.learningcurve", "Learning error values"); + MandatoryOff("model.autoencoder.learningcurve"); + } @@ -146,6 +151,14 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> dimredTrainer->SetNoise(noise); dimredTrainer->SetRho(rho); dimredTrainer->SetBeta(beta); + + if (HasValue("model.autoencoder.learningcurve") && IsParameterEnabled("model.autoencoder.learningcurve")) + { + std::cout << "yo" << std::endl; + dimredTrainer->SetWriteLearningCurve(true); + dimredTrainer->SetLearningCurveFileName(GetParameterString("model.autoencoder.learningcurve")); + } + dimredTrainer->SetInputListSample(trainingListSample); std::cout << "before train" << std::endl; dimredTrainer->Train(); -- GitLab From 47fc69c1c4c20c981b80769ca36dd23898360175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Fri, 30 Jun 2017 09:57:49 +0200 Subject: [PATCH 048/567] BUG : SOMModel now herits from MachineLearningModel<TInput,...> instead of MachineLearningModel<itk:variablelengthvector<TInput>,...> --- app/cbDimensionalityReductionTrainer.cxx | 3 ++- app/cbDimensionalityReductionVector.cxx | 19 +++++++++++++- include/cbLearningApplicationBaseDR.h | 8 +++--- include/cbLearningApplicationBaseDR.txx | 32 ++++++++++++------------ 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index e83231428d..aee6fb3ed9 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -60,7 +60,8 @@ private: AddParameter(ParameterType_OutputFilename, "io.out", "Output model"); SetParameterDescription("io.out", "Output file containing the model estimated (.txt format)."); - + + AddParameter(ParameterType_InputFilename, "io.stats", "Input XML image statistics file"); MandatoryOff("io.stats"); SetParameterDescription("io.stats", "XML file containing mean and variance of each feature."); diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index 485f248b64..dbfd87d39a 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -116,6 +116,11 @@ class CbDimensionalityReductionVector : public Application SetParameterDescription("pcadim","This optional parameter can be set to reduce the number of eignevectors used in the PCA model file."); // MandatoryOff("pcadim"); + AddParameter(ParameterType_String, "mode", "Writting mode"); // + SetParameterString("mode","overwrite", false); + SetParameterDescription("mode","This parameter determines if the output file is overwritten or updated [overwrite/update]"); // + + // Doc example parameter settings SetDocExampleParameterValue("in", "vectorData.shp"); SetDocExampleParameterValue("instat", "meanVar.xml"); @@ -262,7 +267,19 @@ class CbDimensionalityReductionVector : public Application if (IsParameterEnabled("out") && HasValue("out")) { // Create new OGRDataSource - output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite); + if (GetParameterString("mode")=="overwrite") + { + output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite); + } + else if (GetParameterString("mode")=="update") + { + output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Update_LayerCreateOnly ); + } + else + { + otbAppLogFATAL(<< "Error when creating the output file" << GetParameterString("mode") << " : unsupported writting mode type [update/overwrite]"); + } + otb::ogr::Layer newLayer = output->CreateLayer(GetParameterString("out"), const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), layer.GetGeomType()); diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 9d0a6c6908..94c62d1b43 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -87,16 +87,16 @@ public: // Dimensionality reduction models - typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType; + typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType; typedef otb::SOMModel<InputValueType, 2> SOM2DModelType; - typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType; + typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType; typedef otb::SOMModel<InputValueType, 3> SOM3DModelType; - typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType; + typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType; typedef otb::SOMModel<InputValueType, 4> SOM4DModelType; - typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; + typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; diff --git a/include/cbLearningApplicationBaseDR.txx b/include/cbLearningApplicationBaseDR.txx index a42ad73857..6e1635e24d 100644 --- a/include/cbLearningApplicationBaseDR.txx +++ b/include/cbLearningApplicationBaseDR.txx @@ -45,7 +45,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> AddDocTag(Tags::Learning); // main choice parameter that will contain all dimensionality reduction options - AddParameter(ParameterType_Choice, "model", "moddel to use for the training"); + AddParameter(ParameterType_Choice, "model", "model to use for the training"); SetParameterDescription("model", "Choice of the dimensionality reduction model to use for the training."); @@ -83,28 +83,28 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> if(modelName == "autoencoder") { - #ifdef OTB_USE_SHARK - BeforeTrainAutoencoder(trainingListSample,modelPath); - #else - otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); - #endif + #ifdef OTB_USE_SHARK + BeforeTrainAutoencoder(trainingListSample,modelPath); + #else + otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); + #endif } if(modelName == "tiedautoencoder") { - #ifdef OTB_USE_SHARK - TrainAutoencoder<TiedAutoencoderModelType>(trainingListSample,modelPath); - #else - otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); - #endif + #ifdef OTB_USE_SHARK + TrainAutoencoder<TiedAutoencoderModelType>(trainingListSample,modelPath); + #else + otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); + #endif } if(modelName == "pca") { - #ifdef OTB_USE_SHARK - TrainPCA(trainingListSample,modelPath); - #else - otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); - #endif + #ifdef OTB_USE_SHARK + TrainPCA(trainingListSample,modelPath); + #else + otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); + #endif } } -- GitLab From ad08b84f164660aef0d485b3e32b2ac0bae3ca43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Mon, 3 Jul 2017 14:37:02 +0200 Subject: [PATCH 049/567] BUG : Serialization of SOM models works again --- app/cbDimensionalityReductionVector.cxx | 56 +++++++++++++++++-------- include/SOMModel.h | 1 + include/SOMModel.txx | 28 +++++-------- include/cbLearningApplicationBaseDR.h | 8 ++-- include/cbTrainSOM.txx | 1 + 5 files changed, 56 insertions(+), 38 deletions(-) diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index dbfd87d39a..ce4e1fa1ca 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -237,7 +237,6 @@ class CbDimensionalityReductionVector : public Application { int dimension = GetParameterInt("pcadim"); m_Model->SetDimension(dimension ); - std::cout << "yo" << std::endl; } @@ -270,26 +269,41 @@ class CbDimensionalityReductionVector : public Application if (GetParameterString("mode")=="overwrite") { output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite); + otb::ogr::Layer newLayer = output->CreateLayer(GetParameterString("out"), + const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), + layer.GetGeomType()); + // Copy existing fields + OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); + for (int k=0 ; k<inLayerDefn.GetFieldCount()-nbBands ; k++) // we don't copy the original bands + { + OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); + newLayer.CreateField(fieldDefn); + } } else if (GetParameterString("mode")=="update") { - output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Update_LayerCreateOnly ); + //output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Update_LayerCreateOnly); + // Update mode + otb::ogr::DataSource::Pointer source_output = otb::ogr::DataSource::New(GetParameterString("out"), otb::ogr::DataSource::Modes::Read); + layer = source_output->GetLayer(0); + updateMode = true; + otbAppLogINFO("Update input vector data."); + + // fill temporary buffer for the transfer + otb::ogr::Layer inputLayer = layer; + layer = buffer->CopyLayer(inputLayer, std::string("Buffer")); + // close input data source + source_output->Clear(); + // Re-open input data source in update mode + output = otb::ogr::DataSource::New(GetParameterString("out"), otb::ogr::DataSource::Modes::Update_LayerUpdate); + } else { - otbAppLogFATAL(<< "Error when creating the output file" << GetParameterString("mode") << " : unsupported writting mode type [update/overwrite]"); + otbAppLogFATAL(<< "Error when creating the output file" << GetParameterString("mode") << " : unsupported writting mode type"); } - otb::ogr::Layer newLayer = output->CreateLayer(GetParameterString("out"), - const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), - layer.GetGeomType()); - // Copy existing fields - OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); - for (int k=0 ; k<inLayerDefn.GetFieldCount()-nbBands ; k++) // we don't copy the original bands - { - OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); - newLayer.CreateField(fieldDefn); - } + } /* @@ -309,6 +323,7 @@ class CbDimensionalityReductionVector : public Application otb::ogr::Layer outLayer = output->GetLayer(0); + OGRErr errStart = outLayer.ogr().StartTransaction(); if (errStart != OGRERR_NONE) @@ -337,10 +352,11 @@ class CbDimensionalityReductionVector : public Application } // Add an ID field. (The ID already contained in the layer refers to the polygon) + /* OGRFieldDefn IDField("ID_point", OFTInteger); ogr::FieldDefn IDFieldDef(IDField); outLayer.CreateField(IDFieldDef); - + */ // Fill output layer unsigned int count=0; @@ -351,12 +367,18 @@ class CbDimensionalityReductionVector : public Application for( ; it!=itEnd ; ++it, ++count) { ogr::Feature dstFeature(outLayer.GetLayerDefn()); - dstFeature.SetFrom( *it , TRUE); - dstFeature.SetFID(it->GetFID()); + /* + if (GetParameterString("mode")=="overwrite") + {*/ + dstFeature.SetFrom( *it , TRUE); + dstFeature.SetFID(it->GetFID()); + //} + + for (std::size_t i=0; i<classfieldname.size(); ++i){ dstFeature[classfieldname[i]].SetValue<ValueType>(target->GetMeasurementVector(count)[i]); } - dstFeature["ID_point"].SetValue<int>(id); + //dstFeature["ID_point"].SetValue<int>(id); if (updateMode) { outLayer.SetFeature(dstFeature); diff --git a/include/SOMModel.h b/include/SOMModel.h index 88209ed24e..a5752ac5c9 100644 --- a/include/SOMModel.h +++ b/include/SOMModel.h @@ -46,6 +46,7 @@ public: typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, MapDimension> MapType; typedef typename MapType::SizeType SizeType; typedef typename MapType::SpacingType SpacingType; + //typedef otb::SOM<InputListSampleType, MapType> EstimatorType; typedef otb::SOM<InputListSampleType, MapType> EstimatorType; typedef Functor::CzihoSOMLearningBehaviorFunctor SOMLearningBehaviorFunctorType; diff --git a/include/SOMModel.txx b/include/SOMModel.txx index 7afbd6f501..b0b2229ac7 100644 --- a/include/SOMModel.txx +++ b/include/SOMModel.txx @@ -22,7 +22,7 @@ namespace otb template <class TInputValue, unsigned int MapDimension> SOMModel<TInputValue, MapDimension>::SOMModel() { - //m_Dimension = typename MapType::ImageDimension; + this->m_Dimension = MapType::ImageDimension; } @@ -46,12 +46,9 @@ void SOMModel<TInputValue, MapDimension>::Train() estimator->SetBetaEnd(m_BetaEnd); estimator->SetMaxWeight(m_MaxWeight); //AddProcess(estimator,"Learning"); - estimator->Update(); - m_SOMMap = estimator->GetOutput(); - std::cout << "dr of the first sample : " << m_SOMMap->GetWinner(m_ListSample->GetMeasurementVector(0)) << std::endl; -} + } @@ -100,7 +97,7 @@ void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, con inputIterator.GoToBegin(); std::ofstream ofs(filename, std::ios::binary); binary_write_string(ofs,"som"); - binary_write(ofs,static_cast<int>(MapDimension)); + binary_write(ofs,static_cast<unsigned int>(MapDimension)); SizeType size = m_SOMMap->GetLargestPossibleRegion().GetSize() ; for (size_t i=0;i<MapDimension;i++){ binary_write(ofs,size[i]); @@ -129,12 +126,10 @@ void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, con binary_read(ifs,s[i]); } std::string modelType(s); - /** Read the dimension of the map (should be equal to MapDimension) */ - int dimension; + unsigned int dimension; binary_read(ifs,dimension); - if (modelType != "som" || dimension != MapDimension){ itkExceptionMacro(<< "Error opening " << filename.c_str() ); } @@ -146,10 +141,8 @@ void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, con binary_read(ifs,size[i]); index[i]=0; } - unsigned int numberOfElements; binary_read(ifs,numberOfElements); - m_SOMMap = MapType::New(); typename MapType::RegionType region; region.SetSize( size ); @@ -165,13 +158,15 @@ void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, con InputSampleType vect(numberOfElements); for (int i=0 ; i<numberOfElements; i++) { - binary_read(ifs,vect[i]); + float v; // InputValue type is not the same during training anddimredvector. + binary_read(ifs,v); + vect[i] = static_cast<double>(v); } outputIterator.Set(vect); ++outputIterator; } - ifs.close(); + this->m_Dimension = MapType::ImageDimension; } @@ -180,15 +175,14 @@ template <class TInputValue, unsigned int MapDimension> typename SOMModel<TInputValue, MapDimension>::TargetSampleType SOMModel<TInputValue, MapDimension>::DoPredict(const InputSampleType & value, ConfidenceValueType * quality) const { - unsigned int dimension =MapType::ImageDimension; TargetSampleType target; - target.SetSize(dimension); + target.SetSize(this->m_Dimension); auto winner =m_SOMMap->GetWinner(value); - for (int i=0; i< dimension ;i++) { + for (int i=0; i< this->m_Dimension ;i++) { target[i] = winner.GetElement(i); } - + return target; } diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 94c62d1b43..3d90432fa9 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -87,16 +87,16 @@ public: // Dimensionality reduction models - typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType; + //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType; typedef otb::SOMModel<InputValueType, 2> SOM2DModelType; - typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType; + //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType; typedef otb::SOMModel<InputValueType, 3> SOM3DModelType; - typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType; + //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType; typedef otb::SOMModel<InputValueType, 4> SOM4DModelType; - typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; + //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; diff --git a/include/cbTrainSOM.txx b/include/cbTrainSOM.txx index 9ac28dd906..538ccea03c 100644 --- a/include/cbTrainSOM.txx +++ b/include/cbTrainSOM.txx @@ -117,6 +117,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> using TemplateEstimatorType = typename somchoice::EstimatorType; typename somchoice::Pointer dimredTrainer = somchoice::New(); unsigned int dim = dimredTrainer->GetDimension(); + std::cout << dim << std::endl; dimredTrainer->SetNumberOfIterations(GetParameterInt("model.som.ni")); dimredTrainer->SetBetaInit(GetParameterFloat("model.som.bi")); dimredTrainer->SetBetaEnd(GetParameterFloat("model.som.bf")); -- GitLab From 9cb87753ef64283493a567b352268a7588b332e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 5 Jul 2017 10:05:25 +0200 Subject: [PATCH 050/567] SOM can now output the trained map in a txt file --- include/SOMModel.h | 5 ++++- include/SOMModel.txx | 18 ++++++++++++++++++ include/cbTrainSOM.txx | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/SOMModel.h b/include/SOMModel.h index a5752ac5c9..c9553cd9c3 100644 --- a/include/SOMModel.h +++ b/include/SOMModel.h @@ -60,6 +60,8 @@ public: itkGetMacro(NumberOfIterations, unsigned int); itkSetMacro(BetaInit, double); itkGetMacro(BetaInit, double); + itkSetMacro(WriteMap, bool); + itkGetMacro(WriteMap, bool); itkSetMacro(BetaEnd, double); itkGetMacro(BetaEnd, double); itkSetMacro(MinWeight, InputValueType); @@ -121,7 +123,8 @@ private: SOMLearningBehaviorFunctorType m_BetaFunctor; /** Behavior of the Neighborhood extent */ SOMNeighborhoodBehaviorFunctorType m_NeighborhoodSizeFunctor; - + /** Write the SOM Map vectors in a txt file */ + bool m_WriteMap; }; diff --git a/include/SOMModel.txx b/include/SOMModel.txx index b0b2229ac7..6195b9f961 100644 --- a/include/SOMModel.txx +++ b/include/SOMModel.txx @@ -112,6 +112,24 @@ void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, con ++inputIterator; } ofs.close(); + + if (this->m_WriteMap == true) // output the map vectors in a txt file + { + std::ofstream otxt(filename+".txt"); + inputIterator.GoToBegin(); + while(!inputIterator.IsAtEnd()) + { + InputSampleType vect = inputIterator.Get(); + for (size_t i=0;i<vect.GetNumberOfElements();i++) + { + + otxt << vect[i] << " "; + } + otxt << std::endl; + ++inputIterator; + } + otxt.close(); + } } template <class TInputValue, unsigned int MapDimension> diff --git a/include/cbTrainSOM.txx b/include/cbTrainSOM.txx index 538ccea03c..fa9137b309 100644 --- a/include/cbTrainSOM.txx +++ b/include/cbTrainSOM.txx @@ -120,6 +120,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> std::cout << dim << std::endl; dimredTrainer->SetNumberOfIterations(GetParameterInt("model.som.ni")); dimredTrainer->SetBetaInit(GetParameterFloat("model.som.bi")); + dimredTrainer->SetWriteMap(true); dimredTrainer->SetBetaEnd(GetParameterFloat("model.som.bf")); dimredTrainer->SetMaxWeight(GetParameterFloat("model.som.iv")); typename TemplateEstimatorType::SizeType size; -- GitLab From 1b8af99c4e59ff20e2be56f641bb62be1a279a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 5 Jul 2017 10:51:15 +0200 Subject: [PATCH 051/567] Autoencoder now outputs the encoder matrix and the hidden bias if asked --- include/AutoencoderModel.h | 5 ++++- include/AutoencoderModel.txx | 16 ++++++++++++++++ include/PCAModel.h | 4 ++++ include/cbTrainAutoencoder.txx | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 739f13f6cb..b957d5d311 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -61,6 +61,9 @@ public: itkGetMacro(WriteLearningCurve,bool); itkSetMacro(WriteLearningCurve,bool); + + itkSetMacro(WriteWeights, bool); + itkGetMacro(WriteWeights, bool); itkGetMacro(LearningCurveFileName,std::string); itkSetMacro(LearningCurveFileName,std::string); @@ -105,7 +108,7 @@ private: bool m_WriteLearningCurve; // Flag for writting the learning curve into a txt file std::string m_LearningCurveFileName; // Name of the output learning curve printed after training - + bool m_WriteWeights; }; } // end namespace otb diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 8788315b72..847c096b59 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -208,6 +208,22 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Save(const std::string & fil //m_net.write(oa); oa << m_net; ofs.close(); + + + if (this->m_WriteWeights == true) // output the map vectors in a txt file + { + std::ofstream otxt(filename+".txt"); + + for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + { + otxt << m_net[i].encoderMatrix() << std::endl; + otxt << m_net[i].hiddenBias() << std::endl; + } + otxt.close(); + } + + + } template <class TInputValue, class AutoencoderType> diff --git a/include/PCAModel.h b/include/PCAModel.h index bd51913803..82ea0f8443 100644 --- a/include/PCAModel.h +++ b/include/PCAModel.h @@ -42,6 +42,9 @@ public: */ itkSetMacro(Do_resize_flag,bool); + itkSetMacro(WriteEigenvectors, bool); + itkGetMacro(WriteEigenvectors, bool); + bool CanReadFile(const std::string & filename); bool CanWriteFile(const std::string & filename); @@ -66,6 +69,7 @@ private: shark::PCA m_pca; //unsigned int m_Dimension; bool m_Do_resize_flag; + bool m_WriteEigenvectors; }; } // end namespace otb diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index 244441d918..05c5ee0207 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -152,6 +152,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> dimredTrainer->SetRho(rho); dimredTrainer->SetBeta(beta); + dimredTrainer->SetWriteWeights(true); if (HasValue("model.autoencoder.learningcurve") && IsParameterEnabled("model.autoencoder.learningcurve")) { std::cout << "yo" << std::endl; -- GitLab From 0887295c5873343e7ea8a2c7614d7d809dc061fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 5 Jul 2017 11:11:09 +0200 Subject: [PATCH 052/567] PCA now outputs Eigenvectors and eigenvalues in a txt file --- include/PCAModel.txx | 12 ++++++++++++ include/cbTrainPCA.txx | 1 + 2 files changed, 13 insertions(+) diff --git a/include/PCAModel.txx b/include/PCAModel.txx index ec941e1f28..dab5b6483a 100644 --- a/include/PCAModel.txx +++ b/include/PCAModel.txx @@ -78,6 +78,16 @@ void PCAModel<TInputValue>::Save(const std::string & filename, const std::string boost::archive::polymorphic_text_oarchive oa(ofs); m_encoder.write(oa); ofs.close(); + + if (this->m_WriteEigenvectors == true) // output the map vectors in a txt file + { + std::ofstream otxt(filename+".txt"); + + otxt << m_pca.eigenvectors() << std::endl; + otxt << m_pca.eigenvalues() << std::endl; + + otxt.close(); + } } template <class TInputValue> @@ -109,6 +119,8 @@ void PCAModel<TInputValue>::Load(const std::string & filename, const std::string m_encoder.setStructure(eigenvectors, m_encoder.offset() ); std::cout << m_encoder.matrix() << "end" << std::endl; //this->m_Size = m_NumberOfHiddenNeurons; + + } diff --git a/include/cbTrainPCA.txx b/include/cbTrainPCA.txx index 9c02c566cd..d51926469b 100644 --- a/include/cbTrainPCA.txx +++ b/include/cbTrainPCA.txx @@ -40,6 +40,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> typename PCAModelType::Pointer dimredTrainer = PCAModelType::New(); dimredTrainer->SetDimension(GetParameterInt("model.pca.dim")); dimredTrainer->SetInputListSample(trainingListSample); + dimredTrainer->SetWriteEigenvectors(true); dimredTrainer->Train(); dimredTrainer->Save(modelPath); } -- GitLab From af9aeea9efcd3f08b3b91aedff373f47d119de59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 6 Jul 2017 11:37:53 +0200 Subject: [PATCH 053/567] some temporary cout added for testing purposes --- include/AutoencoderModel.txx | 33 +++++++++++++++++-- .../DimensionalityReductionModelFactory.txx | 6 ++-- .../ImageDimensionalityReductionFilter.txx | 1 - include/PCAModel.txx | 22 ++++++++----- include/cbLearningApplicationBaseDR.h | 7 ++-- 5 files changed, 53 insertions(+), 16 deletions(-) diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 847c096b59..7103ec98eb 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -100,7 +100,8 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(shark::Abstrac std::size_t inputs = dataDimension(samples); net.setStructure(inputs, nbneuron); - initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + //initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + initRandomUniform(net,-1,1); shark::ImpulseNoiseModel noise(noise_strength,0.0); //set an input pixel with probability m_Noise to 0 shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs @@ -145,8 +146,8 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(shark::A std::size_t inputs = dataDimension(samples); net.setStructure(inputs, nbneuron); - initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); - + //initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + initRandomUniform(net,-1,1); shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; shark::SparseAutoencoderError error(trainSet,&net, &loss, rho, beta); @@ -219,7 +220,33 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Save(const std::string & fil otxt << m_net[i].encoderMatrix() << std::endl; otxt << m_net[i].hiddenBias() << std::endl; } + + + std::vector<shark::RealVector> features; + + shark::SquaredLoss<shark::RealVector> loss; + Shark::ListSampleToSharkVector(this->GetInputListSample(), features); + shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); + shark::Data<shark::RealVector> outputSamples = inputSamples; + + for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + { + outputSamples = m_net[i].encode(outputSamples); + } + + for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + { + outputSamples = m_net[m_NumberOfHiddenNeurons.Size()-i-1].decode(outputSamples); // We decode the data starting from the smallest layer + } + otxt << "Reconstruction error : " << loss.eval(inputSamples,outputSamples) << std::endl; // the mean squared error is returned + std::cout << "Reconstruction error : " << loss.eval(inputSamples,outputSamples) << std::endl; // the mean squared error is returned + + std::cout << "in" << inputSamples.element(0) << std::endl; + std::cout << "out" << outputSamples.element(0) << std::endl; + otxt.close(); + + } diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index a4cb4b87ed..23fcadddde 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -35,11 +35,13 @@ namespace otb { template <class TInputValue, class TTargetValue> -using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::LogisticNeuron, shark::LogisticNeuron>> ; +// using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ; +using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::TanhNeuron>> ; template <class TInputValue, class TTargetValue> -using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::LogisticNeuron, shark::LogisticNeuron>> ; +// using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; +using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron>> ; template <class TInputValue, class TTargetValue> diff --git a/include/ImageDimensionalityReductionFilter.txx b/include/ImageDimensionalityReductionFilter.txx index 4eee4d3c9f..53a1739bd2 100644 --- a/include/ImageDimensionalityReductionFilter.txx +++ b/include/ImageDimensionalityReductionFilter.txx @@ -134,7 +134,6 @@ void ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage>:: { Superclass::GenerateOutputInformation(); this->GetOutput()->SetNumberOfComponentsPerPixel( m_Model->GetDimension() ); - std::cout << m_Model->GetDimension() << std::endl; } diff --git a/include/PCAModel.txx b/include/PCAModel.txx index dab5b6483a..e9ea1e2a2b 100644 --- a/include/PCAModel.txx +++ b/include/PCAModel.txx @@ -12,6 +12,8 @@ #include <shark/ObjectiveFunctions/Loss/SquaredLoss.h> // squared loss used for regression #include <shark/ObjectiveFunctions/Regularizer.h> //L2 regulariziation +#include <shark/ObjectiveFunctions/ErrorFunction.h> + namespace otb { @@ -83,9 +85,16 @@ void PCAModel<TInputValue>::Save(const std::string & filename, const std::string { std::ofstream otxt(filename+".txt"); - otxt << m_pca.eigenvectors() << std::endl; - otxt << m_pca.eigenvalues() << std::endl; + otxt << "Eigenvectors : " << m_pca.eigenvectors() << std::endl; + otxt << "Eigenvalues : " << m_pca.eigenvalues() << std::endl; + std::vector<shark::RealVector> features; + + shark::SquaredLoss<shark::RealVector> loss; + Shark::ListSampleToSharkVector(this->GetInputListSample(), features); + shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); + otxt << "Reconstruction error : " << loss.eval(inputSamples,m_decoder(m_encoder(inputSamples))) << std::endl; + std::cout << "Reconstruction error : " << loss.eval(inputSamples,m_decoder(m_encoder(inputSamples))) << std::endl; otxt.close(); } } @@ -109,16 +118,13 @@ void PCAModel<TInputValue>::Load(const std::string & filename, const std::string { this->m_Dimension = m_encoder.outputSize(); } - else - { - std::cout << "yo" << std::endl; - } + auto eigenvectors = m_encoder.matrix(); eigenvectors.resize(this->m_Dimension,m_encoder.inputSize()); + m_encoder.setStructure(eigenvectors, m_encoder.offset() ); - std::cout << m_encoder.matrix() << "end" << std::endl; - //this->m_Size = m_NumberOfHiddenNeurons; + } diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 3d90432fa9..6207527baa 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -101,10 +101,13 @@ public: #ifdef OTB_USE_SHARK - typedef shark::Autoencoder< shark::LogisticNeuron, shark::LogisticNeuron> AutoencoderType; + + // typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; + typedef shark::Autoencoder< shark::TanhNeuron, shark::TanhNeuron> AutoencoderType; typedef otb::AutoencoderModel<InputValueType, AutoencoderType> AutoencoderModelType; - typedef shark::TiedAutoencoder< shark::LogisticNeuron, shark::LogisticNeuron> TiedAutoencoderType; + // typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; + typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron> TiedAutoencoderType; typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType; typedef otb::PCAModel<InputValueType> PCAModelType; -- GitLab From b2fc854cfe8eb696dc7c2350bbe4d21be625cb2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 6 Jul 2017 15:50:09 +0200 Subject: [PATCH 054/567] Started refactoring of ae (paused) --- include/AutoencoderModel.h | 19 ++-- include/AutoencoderModel.txx | 93 ++++++++++--------- include/AutoencoderModelFactory.h | 2 +- include/AutoencoderModelFactory.txx | 18 ++-- .../DimensionalityReductionModelFactory.txx | 10 +- include/cbLearningApplicationBaseDR.h | 8 +- include/cbLearningApplicationBaseDR.txx | 3 +- include/cbTrainAutoencoder.txx | 4 +- 8 files changed, 89 insertions(+), 68 deletions(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index b957d5d311..cb3adeac6d 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -6,9 +6,11 @@ #include <fstream> #include <shark/Algorithms/StoppingCriteria/AbstractStoppingCriterion.h> +#include <shark/Models/FFNet.h> +#include <shark/Models/Autoencoder.h> namespace otb { -template <class TInputValue, class AutoencoderType> +template <class TInputValue, class NeuronType> class ITK_EXPORT AutoencoderModel: public MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> { @@ -33,7 +35,12 @@ public: typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; - + /// Neural network related typedefs + typedef shark::Autoencoder<NeuronType,shark::LinearNeuron> OutAutoencoderType; + typedef shark::Autoencoder<NeuronType,NeuronType> AutoencoderType; + typedef shark::FFNet<NeuronType,shark::LinearNeuron> NetworkType; + + itkNewMacro(Self); itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); @@ -77,10 +84,10 @@ public: void Train() ITK_OVERRIDE; template <class T> - void TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int,double, double, shark::Data<shark::RealVector> &, std::ostream&); + void TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion,unsigned int, unsigned int,double, double, shark::Data<shark::RealVector> &, std::ostream&); template <class T> - void TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int,double, double,double, shark::Data<shark::RealVector> &, std::ostream&); + void TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion,unsigned int, unsigned int,double, double,double, shark::Data<shark::RealVector> &, std::ostream&); protected: AutoencoderModel(); @@ -93,8 +100,8 @@ protected: private: /** Network attributes */ - std::vector<AutoencoderType> m_net; - + //std::vector<AutoencoderType> m_net; + NetworkType m_net; itk::Array<unsigned int> m_NumberOfHiddenNeurons; diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 7103ec98eb..95d8721ce5 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -21,40 +21,35 @@ namespace otb { -template <class TInputValue, class AutoencoderType> -AutoencoderModel<TInputValue,AutoencoderType>::AutoencoderModel() +template <class TInputValue, class NeuronType> +AutoencoderModel<TInputValue,NeuronType>::AutoencoderModel() { this->m_IsDoPredictBatchMultiThreaded = true; this->m_WriteLearningCurve = false; } -template <class TInputValue, class AutoencoderType> -AutoencoderModel<TInputValue,AutoencoderType>::~AutoencoderModel() +template <class TInputValue, class NeuronType> +AutoencoderModel<TInputValue,NeuronType>::~AutoencoderModel() { } -template <class TInputValue, class AutoencoderType> -void AutoencoderModel<TInputValue,AutoencoderType>::Train() +template <class TInputValue, class NeuronType> +void AutoencoderModel<TInputValue,NeuronType>::Train() { - std::cout << this->m_WriteLearningCurve << std::endl; std::vector<shark::RealVector> features; - std::cout << "converting the input ListSample to Shark vector" << std::endl; Shark::ListSampleToSharkVector(this->GetInputListSample(), features); - std::cout << "creating the data vector" << std::endl; shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - std::ofstream ofs; if (this->m_WriteLearningCurve =true) { ofs.open(m_LearningCurveFileName); ofs << "learning curve" << std::endl; } - /* - std::ofstream ofs("/mnt/data/home/traizetc/computation/learning_curve.txt"); //learning curve - ofs << "learning curve" << std::endl; - */ + + + if (m_Epsilon > 0){ shark::TrainingProgress<> criterion(5,m_Epsilon); @@ -62,11 +57,11 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() { if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen { - TrainOneLayer(criterion, m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples,ofs); + TrainOneLayer(criterion,i , m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples,ofs); } else { - TrainOneSparseLayer( criterion,m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i],inputSamples, ofs); + TrainOneSparseLayer( criterion,i , m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i],inputSamples, ofs); } criterion.reset(); } @@ -80,11 +75,11 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() { if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen { - TrainOneLayer(criterion, m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples, ofs); + TrainOneLayer(criterion,i, m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples, ofs); } else { - TrainOneSparseLayer(criterion, m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples, ofs); + TrainOneSparseLayer(criterion,i, m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples, ofs); } criterion.reset(); } @@ -92,9 +87,9 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() } } -template <class TInputValue, class AutoencoderType> +template <class TInputValue, class NeuronType> template <class T> -void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int nbneuron,double noise_strength,double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) +void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion,unsigned int layer_index, unsigned int nbneuron,double noise_strength,double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) { AutoencoderType net; @@ -133,14 +128,16 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(shark::Abstrac std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; net.setParameterVector(optimizer.solution().point); - m_net.push_back(net); + // m_net.push_back(net); + m_net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); + m_net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); samples = net.encode(samples); } -template <class TInputValue, class AutoencoderType> +template <class TInputValue, class NeuronType> template <class T> -void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion, unsigned int nbneuron,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) +void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion,unsigned int layer_index, unsigned int nbneuron,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) { AutoencoderType net; @@ -174,17 +171,19 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(shark::A File << "end layer" << std::endl; } net.setParameterVector(optimizer.solution().point); - m_net.push_back(net); + //m_net.push_back(net); + m_net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); + m_net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); samples = net.encode(samples); } -template <class TInputValue, class AutoencoderType> -bool AutoencoderModel<TInputValue,AutoencoderType>::CanReadFile(const std::string & filename) +template <class TInputValue, class NeuronType> +bool AutoencoderModel<TInputValue,NeuronType>::CanReadFile(const std::string & filename) { try { this->Load(filename); - m_net[0].name(); + m_net.name(); } catch(...) { @@ -194,27 +193,28 @@ bool AutoencoderModel<TInputValue,AutoencoderType>::CanReadFile(const std::strin } -template <class TInputValue, class AutoencoderType> -bool AutoencoderModel<TInputValue,AutoencoderType>::CanWriteFile(const std::string & filename) +template <class TInputValue, class NeuronType> +bool AutoencoderModel<TInputValue,NeuronType>::CanWriteFile(const std::string & filename) { return true; } -template <class TInputValue, class AutoencoderType> -void AutoencoderModel<TInputValue,AutoencoderType>::Save(const std::string & filename, const std::string & name) +template <class TInputValue, class NeuronType> +void AutoencoderModel<TInputValue,NeuronType>::Save(const std::string & filename, const std::string & name) { std::ofstream ofs(filename); - ofs << m_net[0].name() << std::endl; // the first line of the model file contains a key + ofs << m_net.name() << std::endl; // the first line of the model file contains a key boost::archive::polymorphic_text_oarchive oa(ofs); //m_net.write(oa); oa << m_net; ofs.close(); - + /* if (this->m_WriteWeights == true) // output the map vectors in a txt file { std::ofstream otxt(filename+".txt"); + for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) { otxt << m_net[i].encoderMatrix() << std::endl; @@ -248,19 +248,22 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Save(const std::string & fil } - + */ } -template <class TInputValue, class AutoencoderType> -void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & filename, const std::string & name) +template <class TInputValue, class NeuronType> +void AutoencoderModel<TInputValue,NeuronType>::Load(const std::string & filename, const std::string & name) { - AutoencoderType net; + + NetworkType net; std::ifstream ifs(filename); char autoencoder[256]; ifs.getline(autoencoder,256); std::string autoencoderstr(autoencoder); + + std::cout << autoencoderstr << std::endl; if (autoencoderstr != net.name()){ itkExceptionMacro(<< "Error opening " << filename.c_str() ); } @@ -274,13 +277,15 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & fil m_NumberOfHiddenNeurons[i] = m_net[i].numberOfHiddenNeurons(); } this->m_Dimension = m_NumberOfHiddenNeurons[m_net.size()-1]; + } -template <class TInputValue, class AutoencoderType> -typename AutoencoderModel<TInputValue,AutoencoderType>::TargetSampleType -AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value, ConfidenceValueType * quality) const +template <class TInputValue, class NeuronType> +typename AutoencoderModel<TInputValue,NeuronType>::TargetSampleType +AutoencoderModel<TInputValue,NeuronType>::DoPredict(const InputSampleType & value, ConfidenceValueType * quality) const { + /* shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) { @@ -302,14 +307,15 @@ AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & target[a]=data.element(0)[a]; } return target; - + */ } -template <class TInputValue, class AutoencoderType> -void AutoencoderModel<TInputValue,AutoencoderType> +template <class TInputValue, class NeuronType> +void AutoencoderModel<TInputValue,NeuronType> ::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const { + /* std::vector<shark::RealVector> features; Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); shark::Data<shark::RealVector> data = shark::createDataFromRange(features); @@ -329,6 +335,7 @@ void AutoencoderModel<TInputValue,AutoencoderType> targets->SetMeasurementVector(id,target); ++id; } + */ } } // namespace otb diff --git a/include/AutoencoderModelFactory.h b/include/AutoencoderModelFactory.h index 73d841e9a8..c9c993b57e 100644 --- a/include/AutoencoderModelFactory.h +++ b/include/AutoencoderModelFactory.h @@ -10,7 +10,7 @@ namespace otb { -template <class TInputValue, class TTargetValue, class AutoencoderType> +template <class TInputValue, class TTargetValue, class NeuronType> class ITK_EXPORT AutoencoderModelFactoryBase : public itk::ObjectFactoryBase { public: diff --git a/include/AutoencoderModelFactory.txx b/include/AutoencoderModelFactory.txx index 5b0d0b754a..47b4669ab4 100644 --- a/include/AutoencoderModelFactory.txx +++ b/include/AutoencoderModelFactory.txx @@ -27,8 +27,8 @@ namespace otb { -template <class TInputValue, class TOutputValue, class AutoencoderType> -AutoencoderModelFactoryBase<TInputValue,TOutputValue, AutoencoderType>::AutoencoderModelFactoryBase() +template <class TInputValue, class TOutputValue, class NeuronType> +AutoencoderModelFactoryBase<TInputValue,TOutputValue, NeuronType>::AutoencoderModelFactoryBase() { std::string classOverride = std::string("DimensionalityReductionModel"); @@ -39,22 +39,22 @@ AutoencoderModelFactoryBase<TInputValue,TOutputValue, AutoencoderType>::Autoenco "Shark AE ML Model", 1, // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); - itk::CreateObjectFunction<AutoencoderModel<TInputValue,AutoencoderType > >::New()); + itk::CreateObjectFunction<AutoencoderModel<TInputValue,NeuronType > >::New()); } -template <class TInputValue, class TOutputValue, class AutoencoderType> -AutoencoderModelFactoryBase<TInputValue,TOutputValue, AutoencoderType>::~AutoencoderModelFactoryBase() +template <class TInputValue, class TOutputValue, class NeuronType> +AutoencoderModelFactoryBase<TInputValue,TOutputValue, NeuronType>::~AutoencoderModelFactoryBase() { } -template <class TInputValue, class TOutputValue, class AutoencoderType> -const char* AutoencoderModelFactoryBase<TInputValue,TOutputValue, AutoencoderType>::GetITKSourceVersion(void) const +template <class TInputValue, class TOutputValue, class NeuronType> +const char* AutoencoderModelFactoryBase<TInputValue,TOutputValue, NeuronType>::GetITKSourceVersion(void) const { return ITK_SOURCE_VERSION; } -template <class TInputValue, class TOutputValue, class AutoencoderType> -const char* AutoencoderModelFactoryBase<TInputValue,TOutputValue, AutoencoderType>::GetDescription() const +template <class TInputValue, class TOutputValue, class NeuronType> +const char* AutoencoderModelFactoryBase<TInputValue,TOutputValue, NeuronType>::GetDescription() const { return "Autoencoder model factory"; } diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 23fcadddde..fb65be910e 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -34,6 +34,7 @@ namespace otb { +/* template <class TInputValue, class TTargetValue> // using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ; using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::TanhNeuron>> ; @@ -42,6 +43,10 @@ using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTarget template <class TInputValue, class TTargetValue> // using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron>> ; +*/ + +template <class TInputValue, class TTargetValue> +using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TanhNeuron> ; template <class TInputValue, class TTargetValue> @@ -125,7 +130,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> #ifdef OTB_USE_SHARK RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(AutoencoderModelFactory<TInputValue,TOutputValue>::New()); - RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); + // RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); #endif } @@ -200,6 +205,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> continue; } + /* TiedAutoencoderModelFactory<TInputValue,TOutputValue> *taeFactory = dynamic_cast<TiedAutoencoderModelFactory<TInputValue,TOutputValue> *>(*itFac); if (taeFactory) @@ -207,7 +213,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> itk::ObjectFactoryBase::UnRegisterFactory(taeFactory); continue; } - + */ // PCA PCAModelFactory<TInputValue,TOutputValue> *pcaFactory = dynamic_cast<PCAModelFactory<TInputValue,TOutputValue> *>(*itFac); diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 6207527baa..084db66a4c 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -103,13 +103,13 @@ public: #ifdef OTB_USE_SHARK // typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - typedef shark::Autoencoder< shark::TanhNeuron, shark::TanhNeuron> AutoencoderType; - typedef otb::AutoencoderModel<InputValueType, AutoencoderType> AutoencoderModelType; - + typedef shark::TanhNeuron NeuronType; + typedef otb::AutoencoderModel<InputValueType, NeuronType> AutoencoderModelType; + /* // typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron> TiedAutoencoderType; typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType; - + */ typedef otb::PCAModel<InputValueType> PCAModelType; #endif diff --git a/include/cbLearningApplicationBaseDR.txx b/include/cbLearningApplicationBaseDR.txx index 6e1635e24d..19b5e4e414 100644 --- a/include/cbLearningApplicationBaseDR.txx +++ b/include/cbLearningApplicationBaseDR.txx @@ -89,6 +89,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); #endif } + /* if(modelName == "tiedautoencoder") { #ifdef OTB_USE_SHARK @@ -97,7 +98,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); #endif } - + */ if(modelName == "pca") { #ifdef OTB_USE_SHARK diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index 05c5ee0207..b44f99461a 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -101,12 +101,12 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> { TrainAutoencoder<AutoencoderModelType>(trainingListSample,modelPath); } - + /* if(TiedWeigth == "yes") { TrainAutoencoder<TiedAutoencoderModelType>(trainingListSample,modelPath); } - + */ if(TiedWeigth != "yes" && TiedWeigth != "no") { std::cerr << "istied : invalid choice <yes/no>" << std::endl; -- GitLab From e7e3f0894d102a8f60278e3f5f9943110da746ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 12 Jul 2017 13:43:37 +0200 Subject: [PATCH 055/567] neuronType switched to tanh/Linear, some cout removed --- app/cbDimensionalityReduction.cxx | 2 +- app/cbDimensionalityReductionTrainer.cxx | 4 +- app/cbDimensionalityReductionVector.cxx | 54 +++++-------------- .../DimensionalityReductionModelFactory.txx | 4 +- include/PCAModel.txx | 3 -- include/cbLearningApplicationBaseDR.h | 4 +- 6 files changed, 20 insertions(+), 51 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index 106f609d48..6a8ed36866 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -222,7 +222,7 @@ private: } // Rescale vector image - m_Rescaler->SetScale(stddevMeasurementVector); + m_Rescaler->SetScale(stddevMeasurementVector*5); m_Rescaler->SetShift(meanMeasurementVector); m_Rescaler->SetInput(inImage); diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index aee6fb3ed9..1b273650c9 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -37,7 +37,7 @@ public: typedef Superclass::ListSampleType ListSampleType; typedef Superclass::SampleImageType SampleImageType; - typedef double ValueType; + typedef float ValueType; typedef itk::VariableLengthVector<ValueType> MeasurementType; typedef otb::StatisticsXMLFileReader<SampleType> StatisticsReader; @@ -126,7 +126,7 @@ private: ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); trainingShiftScaleFilter->SetInput(input); trainingShiftScaleFilter->SetShifts(meanMeasurementVector); - trainingShiftScaleFilter->SetScales(stddevMeasurementVector); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector*3); trainingShiftScaleFilter->Update(); ListSampleType::Pointer trainingListSample= trainingShiftScaleFilter->GetOutput(); diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index ce4e1fa1ca..b598a0310a 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -159,12 +159,7 @@ class CbDimensionalityReductionVector : public Application std::string tmpKey="feat."+key; AddChoice(tmpKey,item); } - /* - if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal) - { - std::string tmpKey="featout."+key; - AddChoice(tmpKey,item); - }*/ + } } } @@ -192,8 +187,8 @@ class CbDimensionalityReductionVector : public Application mv[idx] = (*it)[GetSelectedItems("feat")[idx]].GetValue<double>(); } input->PushBack(mv); + } - /** Statistics for shift/scale */ MeasurementType meanMeasurementVector; @@ -218,7 +213,7 @@ class CbDimensionalityReductionVector : public Application ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); trainingShiftScaleFilter->SetInput(input); trainingShiftScaleFilter->SetShifts(meanMeasurementVector); - trainingShiftScaleFilter->SetScales(stddevMeasurementVector); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector*3); trainingShiftScaleFilter->Update(); otbAppLogINFO("mean used: " << meanMeasurementVector); otbAppLogINFO("standard deviation used: " << stddevMeasurementVector); @@ -246,8 +241,7 @@ class CbDimensionalityReductionVector : public Application /** Perform Dimensionality Reduction */ ListSampleType::Pointer listSample = trainingShiftScaleFilter->GetOutput(); - ListSampleType::Pointer target; - target = m_Model->PredictBatch(listSample); + ListSampleType::Pointer target = m_Model->PredictBatch(listSample); /** Create/Update Output Shape file */ @@ -276,8 +270,8 @@ class CbDimensionalityReductionVector : public Application OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); for (int k=0 ; k<inLayerDefn.GetFieldCount()-nbBands ; k++) // we don't copy the original bands { - OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); - newLayer.CreateField(fieldDefn); + OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); + newLayer.CreateField(fieldDefn); } } else if (GetParameterString("mode")=="update") @@ -306,20 +300,7 @@ class CbDimensionalityReductionVector : public Application } - /* - else - { - // Update mode - updateMode = true; - otbAppLogINFO("Update input vector data."); - // fill temporary buffer for the transfer - otb::ogr::Layer inputLayer = layer; - layer = buffer->CopyLayer(inputLayer, std::string("Buffer")); - // close input data source - source->Clear(); - // Re-open input data source in update mode - output = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Update_LayerUpdate); - }*/ + otb::ogr::Layer outLayer = output->GetLayer(0); @@ -351,34 +332,26 @@ class CbDimensionalityReductionVector : public Application } } - // Add an ID field. (The ID already contained in the layer refers to the polygon) - /* - OGRFieldDefn IDField("ID_point", OFTInteger); - ogr::FieldDefn IDFieldDef(IDField); - outLayer.CreateField(IDFieldDef); - */ + // Fill output layer unsigned int count=0; auto classfieldname = GetParameterStringList("featout"); it = layer.cbegin(); itEnd = layer.cend(); - int id=0; + for( ; it!=itEnd ; ++it, ++count) { ogr::Feature dstFeature(outLayer.GetLayerDefn()); - /* - if (GetParameterString("mode")=="overwrite") - {*/ - dstFeature.SetFrom( *it , TRUE); - dstFeature.SetFID(it->GetFID()); - //} + + dstFeature.SetFrom( *it , TRUE); + dstFeature.SetFID(it->GetFID()); + for (std::size_t i=0; i<classfieldname.size(); ++i){ dstFeature[classfieldname[i]].SetValue<ValueType>(target->GetMeasurementVector(count)[i]); } - //dstFeature["ID_point"].SetValue<int>(id); if (updateMode) { outLayer.SetFeature(dstFeature); @@ -387,7 +360,6 @@ class CbDimensionalityReductionVector : public Application { outLayer.CreateFeature(dstFeature); } - id++; } if(outLayer.ogr().TestCapability("Transactions")) diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 23fcadddde..183156c3e5 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -36,12 +36,12 @@ namespace otb template <class TInputValue, class TTargetValue> // using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ; -using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::TanhNeuron>> ; +using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ; template <class TInputValue, class TTargetValue> // using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; -using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron>> ; +using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; template <class TInputValue, class TTargetValue> diff --git a/include/PCAModel.txx b/include/PCAModel.txx index e9ea1e2a2b..364dd8def3 100644 --- a/include/PCAModel.txx +++ b/include/PCAModel.txx @@ -43,7 +43,6 @@ void PCAModel<TInputValue>::Train() shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); m_pca.setData(inputSamples); m_pca.encoder(m_encoder, this->m_Dimension); - std::cout << m_encoder.matrix() << std::endl; m_pca.decoder(m_decoder, this->m_Dimension); } @@ -175,8 +174,6 @@ void PCAModel<TInputValue> //target[a]=1; //target.SetElement(a,p[a]); - - } //std::cout << p << std::endl; targets->SetMeasurementVector(id,target); diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 6207527baa..3b7557afbf 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -103,11 +103,11 @@ public: #ifdef OTB_USE_SHARK // typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - typedef shark::Autoencoder< shark::TanhNeuron, shark::TanhNeuron> AutoencoderType; + typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; typedef otb::AutoencoderModel<InputValueType, AutoencoderType> AutoencoderModelType; // typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; - typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron> TiedAutoencoderType; + typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType; typedef otb::PCAModel<InputValueType> PCAModelType; -- GitLab From 80f9d699f73591ac39229439c30462432d59051a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 13 Jul 2017 09:59:27 +0200 Subject: [PATCH 056/567] debugging the vector reduction app --- app/cbDimensionalityReduction.cxx | 2 +- app/cbDimensionalityReductionTrainer.cxx | 2 + app/cbDimensionalityReductionVector.cxx | 48 ++++++++++++++----- .../ImageDimensionalityReductionFilter.txx | 2 +- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index 6a8ed36866..bc9a5754fe 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -222,7 +222,7 @@ private: } // Rescale vector image - m_Rescaler->SetScale(stddevMeasurementVector*5); + m_Rescaler->SetScale(stddevMeasurementVector*3); m_Rescaler->SetShift(meanMeasurementVector); m_Rescaler->SetInput(inImage); diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index 1b273650c9..cde3bfd6d7 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -103,6 +103,8 @@ private: } input->PushBack(mv); } + std::cout << GetParameterStringList("feat")[0] << std::endl; + std::cout << input->GetMeasurementVector(0) << std::endl; MeasurementType meanMeasurementVector; MeasurementType stddevMeasurementVector; diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index b598a0310a..ec11ba8adc 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -57,7 +57,7 @@ class CbDimensionalityReductionVector : public Application /** Filters typedef */ - typedef double ValueType; + typedef float ValueType; typedef itk::VariableLengthVector<ValueType> InputSampleType; typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; typedef MachineLearningModel<itk::VariableLengthVector<ValueType>, itk::VariableLengthVector<ValueType>> DimensionalityReductionModelType; @@ -136,6 +136,7 @@ class CbDimensionalityReductionVector : public Application if ( HasValue("in") ) { + std::string shapefile = GetParameterString("in"); otb::ogr::DataSource::Pointer ogrDS; OGRSpatialReference oSRS(""); @@ -153,21 +154,32 @@ class CbDimensionalityReductionVector : public Application key.erase( std::remove_if(key.begin(),key.end(),IsNotAlphaNum), key.end()); std::transform(key.begin(), key.end(), key.begin(), tolower); OGRFieldType fieldType = layerDefn.GetFieldDefn(iField)->GetType(); - - if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal) - { + /*if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal) + {*/ std::string tmpKey="feat."+key; AddChoice(tmpKey,item); - } - + //} } + } + } void DoExecute() ITK_OVERRIDE { clock_t tic = clock(); + + std::cout << GetChoiceKeys("feat")[0] << std::endl; + std::cout << GetChoiceKeys("feat")[1] << std::endl; + std::cout << GetChoiceKeys("feat")[2] << std::endl; + std::cout << GetChoiceKeys("feat")[3] << std::endl; + std::cout << GetChoiceKeys("feat")[4] << std::endl; + std::cout << GetChoiceKeys("feat")[5] << std::endl; + std::cout << GetChoiceKeys("feat")[6] << std::endl; + std::cout << GetChoiceKeys("feat")[7] << std::endl; + std::cout << GetChoiceKeys("feat")[8] << std::endl; + std::string shapefile = GetParameterString("in"); otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); otb::ogr::Layer layer = source->GetLayer(0); @@ -177,18 +189,31 @@ class CbDimensionalityReductionVector : public Application input->SetMeasurementVectorSize(nbFeatures); otb::ogr::Layer::const_iterator it = layer.cbegin(); otb::ogr::Layer::const_iterator itEnd = layer.cend(); - + std::cout << (*it)[GetSelectedItems("feat")[0]].GetValue<double>() << std::endl; for( ; it!=itEnd ; ++it) { MeasurementType mv; mv.SetSize(nbFeatures); + for(int idx=0; idx < nbFeatures; ++idx) { - mv[idx] = (*it)[GetSelectedItems("feat")[idx]].GetValue<double>(); + mv[idx] = static_cast<float>( (*it)[GetSelectedItems("feat")[idx]].GetValue<double>() ); + } input->PushBack(mv); } + std::cout << GetSelectedItems("feat")[0] << std::endl; + std::cout << input->GetMeasurementVector(0) << std::endl; + + + + + + + + + /** Statistics for shift/scale */ MeasurementType meanMeasurementVector; @@ -242,8 +267,9 @@ class CbDimensionalityReductionVector : public Application ListSampleType::Pointer listSample = trainingShiftScaleFilter->GetOutput(); ListSampleType::Pointer target = m_Model->PredictBatch(listSample); - - + target = input; + std::cout << target->GetMeasurementVector(0) << std::endl; + std::cout << input->GetMeasurementVector(0) << std::endl; /** Create/Update Output Shape file */ std::cout << GetParameterStringList("featout").size() << std::endl; @@ -350,7 +376,7 @@ class CbDimensionalityReductionVector : public Application for (std::size_t i=0; i<classfieldname.size(); ++i){ - dstFeature[classfieldname[i]].SetValue<ValueType>(target->GetMeasurementVector(count)[i]); + dstFeature[classfieldname[i]].SetValue<double>(target->GetMeasurementVector(count)[i]); } if (updateMode) { diff --git a/include/ImageDimensionalityReductionFilter.txx b/include/ImageDimensionalityReductionFilter.txx index 53a1739bd2..7f7b70284c 100644 --- a/include/ImageDimensionalityReductionFilter.txx +++ b/include/ImageDimensionalityReductionFilter.txx @@ -189,7 +189,7 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> // This call is threadsafe labels = m_Model->PredictBatch(samples); - + labels = samples; // Set the output values typename TargetListSampleType::ConstIterator labIt = labels->Begin(); -- GitLab From dc19d1cb0354269d7061c398a0d510842272df28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 13 Jul 2017 16:11:16 +0200 Subject: [PATCH 057/567] vec app problem solved --- app/cbDimensionalityReductionTrainer.cxx | 6 +-- app/cbDimensionalityReductionVector.cxx | 37 +++++-------------- .../ImageDimensionalityReductionFilter.txx | 2 +- 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index cde3bfd6d7..55232ef871 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -81,8 +81,6 @@ private: void DoExecute() { - std::cout << "Appli Training!" << std::endl; - std::string shapefile = GetParameterString("io.vd"); otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); @@ -103,9 +101,7 @@ private: } input->PushBack(mv); } - std::cout << GetParameterStringList("feat")[0] << std::endl; - std::cout << input->GetMeasurementVector(0) << std::endl; - + MeasurementType meanMeasurementVector; MeasurementType stddevMeasurementVector; diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index ec11ba8adc..cf2caed548 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -151,14 +151,18 @@ class CbDimensionalityReductionVector : public Application { std::string item = layerDefn.GetFieldDefn(iField)->GetNameRef(); std::string key(item); + std::string::iterator end = std::remove_if( key.begin(), key.end(), IsNotAlphaNum ); + std::transform( key.begin(), end, key.begin(), tolower ); + /* key.erase( std::remove_if(key.begin(),key.end(),IsNotAlphaNum), key.end()); - std::transform(key.begin(), key.end(), key.begin(), tolower); + std::transform(key.begin(), key.end(), key.begin(), tolower);*/ OGRFieldType fieldType = layerDefn.GetFieldDefn(iField)->GetType(); - /*if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal) + /* if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal) {*/ - std::string tmpKey="feat."+key; + //std::string tmpKey="feat."+key; + std::string tmpKey = "feat." + key.substr( 0, static_cast<unsigned long>( end - key.begin() ) ); AddChoice(tmpKey,item); - //} + //} // this is the same as in otbVectorClassifier, but it doesnt work } } @@ -170,16 +174,6 @@ class CbDimensionalityReductionVector : public Application clock_t tic = clock(); - std::cout << GetChoiceKeys("feat")[0] << std::endl; - std::cout << GetChoiceKeys("feat")[1] << std::endl; - std::cout << GetChoiceKeys("feat")[2] << std::endl; - std::cout << GetChoiceKeys("feat")[3] << std::endl; - std::cout << GetChoiceKeys("feat")[4] << std::endl; - std::cout << GetChoiceKeys("feat")[5] << std::endl; - std::cout << GetChoiceKeys("feat")[6] << std::endl; - std::cout << GetChoiceKeys("feat")[7] << std::endl; - std::cout << GetChoiceKeys("feat")[8] << std::endl; - std::string shapefile = GetParameterString("in"); otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); otb::ogr::Layer layer = source->GetLayer(0); @@ -189,7 +183,7 @@ class CbDimensionalityReductionVector : public Application input->SetMeasurementVectorSize(nbFeatures); otb::ogr::Layer::const_iterator it = layer.cbegin(); otb::ogr::Layer::const_iterator itEnd = layer.cend(); - std::cout << (*it)[GetSelectedItems("feat")[0]].GetValue<double>() << std::endl; + for( ; it!=itEnd ; ++it) { MeasurementType mv; @@ -203,17 +197,8 @@ class CbDimensionalityReductionVector : public Application input->PushBack(mv); } - std::cout << GetSelectedItems("feat")[0] << std::endl; - std::cout << input->GetMeasurementVector(0) << std::endl; - - - - - - - /** Statistics for shift/scale */ MeasurementType meanMeasurementVector; @@ -267,9 +252,7 @@ class CbDimensionalityReductionVector : public Application ListSampleType::Pointer listSample = trainingShiftScaleFilter->GetOutput(); ListSampleType::Pointer target = m_Model->PredictBatch(listSample); - target = input; - std::cout << target->GetMeasurementVector(0) << std::endl; - std::cout << input->GetMeasurementVector(0) << std::endl; + /** Create/Update Output Shape file */ std::cout << GetParameterStringList("featout").size() << std::endl; diff --git a/include/ImageDimensionalityReductionFilter.txx b/include/ImageDimensionalityReductionFilter.txx index 7f7b70284c..e98a0b79f7 100644 --- a/include/ImageDimensionalityReductionFilter.txx +++ b/include/ImageDimensionalityReductionFilter.txx @@ -189,7 +189,7 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> // This call is threadsafe labels = m_Model->PredictBatch(samples); - labels = samples; + // Set the output values typename TargetListSampleType::ConstIterator labIt = labels->Begin(); -- GitLab From f9551364cfbb97fe60f78eea87bbf7846dd564fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Mon, 17 Jul 2017 14:06:00 +0200 Subject: [PATCH 058/567] debugging vect app --- .../include/otbMachineLearningModel.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModel.h b/Modules/Learning/LearningBase/include/otbMachineLearningModel.h index 1de069ab6d..7da0aaad12 100644 --- a/Modules/Learning/LearningBase/include/otbMachineLearningModel.h +++ b/Modules/Learning/LearningBase/include/otbMachineLearningModel.h @@ -116,8 +116,10 @@ public: */ TargetSampleType Predict(const InputSampleType& input, ConfidenceValueType *quality = ITK_NULLPTR) const; - - virtual unsigned int GetDimension() {return 1;}; /// This method is used to determine the output vector size after dimensionality reduction, and should be overrided for all machine learning models used for dimensionality reduction. This method is not used for classification and regression + itkSetMacro(Dimension,unsigned int); + itkGetMacro(Dimension,unsigned int); + + // virtual unsigned int GetDimension() {return 1;}; /// This method is used to determine the output vector size after dimensionality reduction, and should be overrided for all machine learning models used for dimensionality reduction. This method is not used for classification and regression /** Predict a batch of samples (InputListSampleType) @@ -186,7 +188,9 @@ protected: /** Input list sample */ typename InputListSampleType::Pointer m_InputListSample; - + + typename InputListSampleType::Pointer m_ValidationListSample; + /** Target list sample */ typename TargetListSampleType::Pointer m_TargetListSample; @@ -195,6 +199,9 @@ protected: /** flag to choose between classification and regression modes */ bool m_RegressionMode; + /** Output Dimension of the model, used by Dimensionality Reduction models*/ + + /** flag that indicates if the model supports regression, child * classes should modify it in their constructor if they support * regression mode */ @@ -205,7 +212,8 @@ protected: /** Is DoPredictBatch multi-threaded ? */ bool m_IsDoPredictBatchMultiThreaded; - + unsigned int m_Dimension; + private: /** Actual implementation of BatchPredicition * Default implementation will call DoPredict iteratively -- GitLab From 082cc38962105a475c4fa4e4ef0067791e54c54a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Tue, 18 Jul 2017 14:51:17 +0200 Subject: [PATCH 059/567] cout error at every epochs during training (for testing purposes) --- include/AutoencoderModel.txx | 1 + 1 file changed, 1 insertion(+) diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 7103ec98eb..a308fa5586 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -167,6 +167,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(shark::A { File << optimizer.solution().value << std::endl; } + std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; } while( !criterion.stop( optimizer.solution() ) ); std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; if (this->m_WriteLearningCurve =true) -- GitLab From fecc26c1986b241115077f0a5827dfdf5c1a49ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 19 Jul 2017 17:36:36 +0200 Subject: [PATCH 060/567] changed the way ae are initialized --- include/AutoencoderModel.txx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index a308fa5586..d5ceb9deae 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -43,8 +43,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Train() Shark::ListSampleToSharkVector(this->GetInputListSample(), features); std::cout << "creating the data vector" << std::endl; shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - - + std::ofstream ofs; if (this->m_WriteLearningCurve =true) { @@ -100,8 +99,8 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneLayer(shark::Abstrac std::size_t inputs = dataDimension(samples); net.setStructure(inputs, nbneuron); - //initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); - initRandomUniform(net,-1,1); + initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + //initRandomUniform(net,-1,1); shark::ImpulseNoiseModel noise(noise_strength,0.0); //set an input pixel with probability m_Noise to 0 shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs @@ -146,8 +145,9 @@ void AutoencoderModel<TInputValue,AutoencoderType>::TrainOneSparseLayer(shark::A std::size_t inputs = dataDimension(samples); net.setStructure(inputs, nbneuron); - //initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); - initRandomUniform(net,-1,1); + initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + + //initRandomUniform(net,-1,1); shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; shark::SparseAutoencoderError error(trainSet,&net, &loss, rho, beta); -- GitLab From ea00ca9040ed23dea2879997b27a17209db0c58d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 19 Jul 2017 17:37:07 +0200 Subject: [PATCH 061/567] switched to linear linear ae --- include/DimensionalityReductionModelFactory.txx | 4 ++-- include/cbLearningApplicationBaseDR.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 183156c3e5..61dca735ae 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -36,12 +36,12 @@ namespace otb template <class TInputValue, class TTargetValue> // using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ; -using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ; +using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::LinearNeuron, shark::LinearNeuron>> ; template <class TInputValue, class TTargetValue> // using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; -using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; +using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::LinearNeuron, shark::LinearNeuron>> ; template <class TInputValue, class TTargetValue> diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 3b7557afbf..0a38da855a 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -103,11 +103,11 @@ public: #ifdef OTB_USE_SHARK // typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; + typedef shark::Autoencoder< shark::LinearNeuron, shark::LinearNeuron> AutoencoderType; typedef otb::AutoencoderModel<InputValueType, AutoencoderType> AutoencoderModelType; // typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; - typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; + typedef shark::TiedAutoencoder< shark::LinearNeuron, shark::LinearNeuron> TiedAutoencoderType; typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType; typedef otb::PCAModel<InputValueType> PCAModelType; -- GitLab From f0b2c8ddf401443a1a15e8d27dea29e06868079f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 20 Jul 2017 13:44:36 +0200 Subject: [PATCH 062/567] refactoring of the ae model seems to work, denoising ae is not implemented yet --- include/AutoencoderModel.h | 6 +- include/AutoencoderModel.txx | 131 +++++++++++++++++++++++++++-------- 2 files changed, 103 insertions(+), 34 deletions(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index cb3adeac6d..23cf4a2c17 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -86,8 +86,8 @@ public: template <class T> void TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion,unsigned int, unsigned int,double, double, shark::Data<shark::RealVector> &, std::ostream&); - template <class T> - void TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion,unsigned int, unsigned int,double, double,double, shark::Data<shark::RealVector> &, std::ostream&); + template <class T, class Autoencoder> + void TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion,Autoencoder &, unsigned int, unsigned int,double, double,double, shark::Data<shark::RealVector> &, std::ostream&); protected: AutoencoderModel(); @@ -102,8 +102,6 @@ private: /** Network attributes */ //std::vector<AutoencoderType> m_net; NetworkType m_net; - - itk::Array<unsigned int> m_NumberOfHiddenNeurons; /** Training parameters */ unsigned int m_NumberOfIterations; // stop the training after a fixed number of iterations diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 95d8721ce5..ee400c04a7 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -48,12 +48,64 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() ofs << "learning curve" << std::endl; } + /// Initialization of the feed forward neural network + std::vector<size_t> layers; + layers.push_back(shark::dataDimension(inputSamples)); + for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + { + layers.push_back(m_NumberOfHiddenNeurons[i]); + std::cout << m_NumberOfHiddenNeurons.Size() << std::endl; + } + // another loop for the decoder should be added, for now i just add the output layer size + std::cout << "i?" << static_cast<int>(m_NumberOfHiddenNeurons.Size()-1) << std::endl; + for (unsigned int i = std::max(0,static_cast<int>(m_NumberOfHiddenNeurons.Size()-1)) ; i > 0; --i) + { + std::cout << i << std::endl; + layers.push_back(m_NumberOfHiddenNeurons[i-1]); + } + layers.push_back(shark::dataDimension(inputSamples)); + m_net.setStructure(layers); + shark::initRandomNormal(m_net,0.1); + + + /// Training of the first Autoencoder (first and last layer of the FF network) + if (m_Epsilon > 0){ + shark::TrainingProgress<> criterion(5,m_Epsilon); + + if (m_Noise[0] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen + { + TrainOneLayer(criterion,0 , m_NumberOfHiddenNeurons[0],m_Noise[0],m_Regularization[0], inputSamples,ofs); + } + else + { + OutAutoencoderType net; + TrainOneSparseLayer( criterion, net , 0 , m_NumberOfHiddenNeurons[0],m_Rho[0],m_Beta[0],m_Regularization[0],inputSamples, ofs); + } + criterion.reset(); + } + else { + shark::MaxIterations<> criterion(m_NumberOfIterations); + + if (m_Noise[0] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen + { + TrainOneLayer(criterion,0, m_NumberOfHiddenNeurons[0],m_Noise[0],m_Regularization[0], inputSamples, ofs); + } + else + { + OutAutoencoderType net; + TrainOneSparseLayer(criterion, net, 0, m_NumberOfHiddenNeurons[0],m_Rho[0],m_Beta[0],m_Regularization[0], inputSamples, ofs); + } + criterion.reset(); + } + + + /// Training of the other autoencoders if (m_Epsilon > 0){ shark::TrainingProgress<> criterion(5,m_Epsilon); - for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + for (unsigned int i = 1 ; i < m_NumberOfHiddenNeurons.Size(); ++i) { if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen { @@ -61,7 +113,8 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() } else { - TrainOneSparseLayer( criterion,i , m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i],inputSamples, ofs); + AutoencoderType net; + TrainOneSparseLayer( criterion, net , i , m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i],inputSamples, ofs); } criterion.reset(); } @@ -71,7 +124,7 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() else { shark::MaxIterations<> criterion(m_NumberOfIterations); - for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + for (unsigned int i = 1 ; i < m_NumberOfHiddenNeurons.Size(); ++i) { if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen { @@ -79,7 +132,8 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() } else { - TrainOneSparseLayer(criterion,i, m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples, ofs); + AutoencoderType net; + TrainOneSparseLayer(criterion, net, i, m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples, ofs); } criterion.reset(); } @@ -95,8 +149,8 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStop std::size_t inputs = dataDimension(samples); net.setStructure(inputs, nbneuron); - //initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); - initRandomUniform(net,-1,1); + initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + //initRandomUniform(net,-1,1); shark::ImpulseNoiseModel noise(noise_strength,0.0); //set an input pixel with probability m_Noise to 0 shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs @@ -136,15 +190,15 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStop template <class TInputValue, class NeuronType> -template <class T> -void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion,unsigned int layer_index, unsigned int nbneuron,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) +template <class T, class Autoencoder> +void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion, Autoencoder & net, unsigned int layer_index, unsigned int nbneuron,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) { - AutoencoderType net; + //AutoencoderType net; std::size_t inputs = dataDimension(samples); net.setStructure(inputs, nbneuron); - //initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); - initRandomUniform(net,-1,1); + initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + //initRandomUniform(net,-1,1); shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; shark::SparseAutoencoderError error(trainSet,&net, &loss, rho, beta); @@ -172,9 +226,12 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::Abstra } net.setParameterVector(optimizer.solution().point); //m_net.push_back(net); - m_net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); - m_net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); + m_net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); // Copy the encoder in the FF neural network + m_net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); // Copy the decoder in the FF neural network samples = net.encode(samples); + std::cout << "numero zero " << m_net.layerMatrix(layer_index) << "i " << layer_index <<std::endl <<std::endl; + std::cout << "numero uno " << m_net.layerMatrix(m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index) << "i " << m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index << std::endl <<std::endl; + } template <class TInputValue, class NeuronType> @@ -202,6 +259,7 @@ bool AutoencoderModel<TInputValue,NeuronType>::CanWriteFile(const std::string & template <class TInputValue, class NeuronType> void AutoencoderModel<TInputValue,NeuronType>::Save(const std::string & filename, const std::string & name) { + std::cout << "saving model ..." << std::endl; std::ofstream ofs(filename); ofs << m_net.name() << std::endl; // the first line of the model file contains a key boost::archive::polymorphic_text_oarchive oa(ofs); @@ -271,13 +329,23 @@ void AutoencoderModel<TInputValue,NeuronType>::Load(const std::string & filename //m_net.read(ia); ia >> m_net; ifs.close(); - - m_NumberOfHiddenNeurons.SetSize(m_net.size()); - for (int i=0; i<m_net.size(); i++){ + + // This gives us the dimension if we keep the encoder and decoder + size_t feature_layer_index = m_net.layerMatrices().size()/2; + this->m_Dimension = m_net.layerMatrix(feature_layer_index).size1(); // number of neurons in the feature layer (first dimension of the first decoder weight matrix) + std::cout << this->m_Dimension << std::endl; + + + + /* This might not be needed + int number_of_layers = m_net.layerMatrices().size()/2; + std::cout << "number of layers" << number_of_layers << std::endl; + m_NumberOfHiddenNeurons.SetSize(number_of_layers); + for (int i=0; i<number_of_layers; i++){ m_NumberOfHiddenNeurons[i] = m_net[i].numberOfHiddenNeurons(); } - this->m_Dimension = m_NumberOfHiddenNeurons[m_net.size()-1]; - + this->m_Dimension = m_NumberOfHiddenNeurons[number_of_layers-1]; + */ } @@ -285,7 +353,7 @@ template <class TInputValue, class NeuronType> typename AutoencoderModel<TInputValue,NeuronType>::TargetSampleType AutoencoderModel<TInputValue,NeuronType>::DoPredict(const InputSampleType & value, ConfidenceValueType * quality) const { - /* + shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) { @@ -296,18 +364,20 @@ AutoencoderModel<TInputValue,NeuronType>::DoPredict(const InputSampleType & valu features.push_back(samples); shark::Data<shark::RealVector> data = shark::createDataFromRange(features); - + + data = m_net.evalLayer( m_net.layerMatrices().size()/2 ,data); // features layer for a network containing the encoder and decoder part + /* for (int i=0; i<m_net.size(); i++){ // loop over all autoencoders in m_net data = m_net[i].encode(data); - } + }*/ TargetSampleType target; - target.SetSize(m_NumberOfHiddenNeurons[m_net.size()-1]); + target.SetSize(this->m_Dimension); - for(unsigned int a = 0; a < m_NumberOfHiddenNeurons[m_net.size()-1]; ++a){ + for(unsigned int a = 0; a < this->m_Dimension; ++a){ target[a]=data.element(0)[a]; } return target; - */ + } @@ -315,27 +385,28 @@ template <class TInputValue, class NeuronType> void AutoencoderModel<TInputValue,NeuronType> ::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const { - /* + std::vector<shark::RealVector> features; Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); shark::Data<shark::RealVector> data = shark::createDataFromRange(features); TargetSampleType target; - + /* for (auto net :m_net ){ // loop over all autoencoders in m_net data = net.encode(data); } - + */ + data = m_net.evalLayer( m_net.layerMatrices().size()/2 ,data); // features layer for a network containing the encoder and decoder part unsigned int id = startIndex; - target.SetSize(m_NumberOfHiddenNeurons[m_net.size()-1]); + target.SetSize(this->m_Dimension); for(const auto& p : data.elements()) { - for(unsigned int a = 0; a < m_NumberOfHiddenNeurons[m_net.size()-1]; ++a){ + for(unsigned int a = 0; a < this->m_Dimension; ++a){ target[a]=p[a]; } targets->SetMeasurementVector(id,target); ++id; } - */ + } } // namespace otb -- GitLab From 4a75d17a2b60143175bb84abfefb5db8f63860a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 20 Jul 2017 15:20:12 +0200 Subject: [PATCH 063/567] switched to linear neuron (test), bug correct in the DoPredictBatch method --- include/AutoencoderModel.txx | 4 +++- include/DimensionalityReductionModelFactory.txx | 2 +- include/cbLearningApplicationBaseDR.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index ee400c04a7..4afa2692f3 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -395,9 +395,11 @@ void AutoencoderModel<TInputValue,NeuronType> data = net.encode(data); } */ - data = m_net.evalLayer( m_net.layerMatrices().size()/2 ,data); // features layer for a network containing the encoder and decoder part + data = m_net.evalLayer( m_net.layerMatrices().size()/2-1 ,data); // features layer for a network containing the encoder and decoder part + std::cout << data.element(0) << std::endl; unsigned int id = startIndex; target.SetSize(this->m_Dimension); + for(const auto& p : data.elements()) { for(unsigned int a = 0; a < this->m_Dimension; ++a){ diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index fb65be910e..42eb47e76c 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -46,7 +46,7 @@ using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTa */ template <class TInputValue, class TTargetValue> -using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TanhNeuron> ; +using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::LinearNeuron> ; template <class TInputValue, class TTargetValue> diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 084db66a4c..5814c3f3b5 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -103,7 +103,7 @@ public: #ifdef OTB_USE_SHARK // typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - typedef shark::TanhNeuron NeuronType; + typedef shark::LinearNeuron NeuronType; typedef otb::AutoencoderModel<InputValueType, NeuronType> AutoencoderModelType; /* // typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; -- GitLab From b315eb893b212296ff8500e3b4ddb0964bf06c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 20 Jul 2017 15:21:06 +0200 Subject: [PATCH 064/567] bug correct : output vector of m_net.evalLayer was not taken from the right layer --- include/AutoencoderModel.txx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 4afa2692f3..20dde00f4f 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -365,7 +365,7 @@ AutoencoderModel<TInputValue,NeuronType>::DoPredict(const InputSampleType & valu shark::Data<shark::RealVector> data = shark::createDataFromRange(features); - data = m_net.evalLayer( m_net.layerMatrices().size()/2 ,data); // features layer for a network containing the encoder and decoder part + data = m_net.evalLayer( m_net.layerMatrices().size()/2-1 ,data); // features layer for a network containing the encoder and decoder part /* for (int i=0; i<m_net.size(); i++){ // loop over all autoencoders in m_net data = m_net[i].encode(data); -- GitLab From f830632bd42b58a3392151f29acdf5568c00356b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 20 Jul 2017 15:23:58 +0200 Subject: [PATCH 065/567] output the vector after classification (debug) --- .../AppClassification/app/otbVectorClassifier.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx index 61d3a691f4..9f37f870ea 100644 --- a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx @@ -210,6 +210,7 @@ private: input->PushBack(mv); } + std::cout << input->GetMeasurementVector(0) << std::endl; // Statistics for shift/scale MeasurementType meanMeasurementVector; MeasurementType stddevMeasurementVector; @@ -240,7 +241,8 @@ private: otbAppLogINFO("Loading model"); m_Model = MachineLearningModelFactoryType::CreateMachineLearningModel(GetParameterString("model"), MachineLearningModelFactoryType::ReadMode); - + std::cout << "model_loaded" << std::endl; + if (m_Model.IsNull()) { otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") << " : unsupported model type"); -- GitLab From 9d87c506c69d198fa74764aa818d4297b123fa7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Mon, 24 Jul 2017 14:34:55 +0200 Subject: [PATCH 066/567] ae finetuning added --- app/cbDimensionalityReduction.cxx | 2 +- app/cbDimensionalityReductionTrainer.cxx | 2 +- app/cbDimensionalityReductionVector.cxx | 2 +- include/AutoencoderModel.h | 7 +- include/AutoencoderModel.txx | 80 +++++++++++++------ .../DimensionalityReductionModelFactory.txx | 2 +- include/cbLearningApplicationBaseDR.h | 2 +- include/cbTrainAutoencoder.txx | 1 - 8 files changed, 67 insertions(+), 31 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index bc9a5754fe..106f609d48 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -222,7 +222,7 @@ private: } // Rescale vector image - m_Rescaler->SetScale(stddevMeasurementVector*3); + m_Rescaler->SetScale(stddevMeasurementVector); m_Rescaler->SetShift(meanMeasurementVector); m_Rescaler->SetInput(inImage); diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index 55232ef871..4cb042427b 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -124,7 +124,7 @@ private: ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); trainingShiftScaleFilter->SetInput(input); trainingShiftScaleFilter->SetShifts(meanMeasurementVector); - trainingShiftScaleFilter->SetScales(stddevMeasurementVector*3); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector); trainingShiftScaleFilter->Update(); ListSampleType::Pointer trainingListSample= trainingShiftScaleFilter->GetOutput(); diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index cf2caed548..12e1307ad1 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -223,7 +223,7 @@ class CbDimensionalityReductionVector : public Application ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); trainingShiftScaleFilter->SetInput(input); trainingShiftScaleFilter->SetShifts(meanMeasurementVector); - trainingShiftScaleFilter->SetScales(stddevMeasurementVector*3); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector); trainingShiftScaleFilter->Update(); otbAppLogINFO("mean used: " << meanMeasurementVector); otbAppLogINFO("standard deviation used: " << stddevMeasurementVector); diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 23cf4a2c17..5dbca52e27 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -83,12 +83,15 @@ public: void Train() ITK_OVERRIDE; - template <class T> - void TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion,unsigned int, unsigned int,double, double, shark::Data<shark::RealVector> &, std::ostream&); + template <class T, class Autoencoder> + void TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion,Autoencoder &,unsigned int, unsigned int,double, double, shark::Data<shark::RealVector> &, std::ostream&); template <class T, class Autoencoder> void TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion,Autoencoder &, unsigned int, unsigned int,double, double,double, shark::Data<shark::RealVector> &, std::ostream&); + template <class T> + void TrainNetwork(shark::AbstractStoppingCriterion<T> & criterion,double, double,double, shark::Data<shark::RealVector> &, std::ostream&); + protected: AutoencoderModel(); ~AutoencoderModel() ITK_OVERRIDE; diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 20dde00f4f..668bb7d6ad 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -40,6 +40,7 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() std::vector<shark::RealVector> features; Shark::ListSampleToSharkVector(this->GetInputListSample(), features); shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); + shark::Data<shark::RealVector> inputSamples_copy = inputSamples; std::ofstream ofs; if (this->m_WriteLearningCurve =true) @@ -54,10 +55,8 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) { layers.push_back(m_NumberOfHiddenNeurons[i]); - std::cout << m_NumberOfHiddenNeurons.Size() << std::endl; } - // another loop for the decoder should be added, for now i just add the output layer size - std::cout << "i?" << static_cast<int>(m_NumberOfHiddenNeurons.Size()-1) << std::endl; + for (unsigned int i = std::max(0,static_cast<int>(m_NumberOfHiddenNeurons.Size()-1)) ; i > 0; --i) { std::cout << i << std::endl; @@ -73,13 +72,13 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() if (m_Epsilon > 0){ shark::TrainingProgress<> criterion(5,m_Epsilon); + OutAutoencoderType net; if (m_Noise[0] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen { - TrainOneLayer(criterion,0 , m_NumberOfHiddenNeurons[0],m_Noise[0],m_Regularization[0], inputSamples,ofs); + TrainOneLayer(criterion,net,0 , m_NumberOfHiddenNeurons[0],m_Noise[0],m_Regularization[0], inputSamples,ofs); } else { - OutAutoencoderType net; TrainOneSparseLayer( criterion, net , 0 , m_NumberOfHiddenNeurons[0],m_Rho[0],m_Beta[0],m_Regularization[0],inputSamples, ofs); } criterion.reset(); @@ -88,13 +87,13 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() else { shark::MaxIterations<> criterion(m_NumberOfIterations); + OutAutoencoderType net; if (m_Noise[0] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen { - TrainOneLayer(criterion,0, m_NumberOfHiddenNeurons[0],m_Noise[0],m_Regularization[0], inputSamples, ofs); + TrainOneLayer(criterion,net,0, m_NumberOfHiddenNeurons[0],m_Noise[0],m_Regularization[0], inputSamples, ofs); } else { - OutAutoencoderType net; TrainOneSparseLayer(criterion, net, 0, m_NumberOfHiddenNeurons[0],m_Rho[0],m_Beta[0],m_Regularization[0], inputSamples, ofs); } criterion.reset(); @@ -107,13 +106,13 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() for (unsigned int i = 1 ; i < m_NumberOfHiddenNeurons.Size(); ++i) { + AutoencoderType net; if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen { - TrainOneLayer(criterion,i , m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples,ofs); + TrainOneLayer(criterion,net,i , m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples,ofs); } else { - AutoencoderType net; TrainOneSparseLayer( criterion, net , i , m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i],inputSamples, ofs); } criterion.reset(); @@ -126,26 +125,29 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() for (unsigned int i = 1 ; i < m_NumberOfHiddenNeurons.Size(); ++i) { + AutoencoderType net; if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen { - TrainOneLayer(criterion,i, m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples, ofs); + TrainOneLayer(criterion,net, i,m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples, ofs); } else { - AutoencoderType net; TrainOneSparseLayer(criterion, net, i, m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples, ofs); } criterion.reset(); } } + shark::MaxIterations<> criterion(m_NumberOfIterations); + TrainNetwork(criterion, m_Rho[0],m_Beta[0],m_Regularization[0], inputSamples_copy, ofs); + } template <class TInputValue, class NeuronType> -template <class T> -void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion,unsigned int layer_index, unsigned int nbneuron,double noise_strength,double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) +template <class T, class Autoencoder> +void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion, Autoencoder & net,unsigned int layer_index, unsigned int nbneuron,double noise_strength,double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) { - AutoencoderType net; + //AutoencoderType net; std::size_t inputs = dataDimension(samples); net.setStructure(inputs, nbneuron); @@ -160,7 +162,7 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStop shark::TwoNormRegularizer regularizer(error.numberOfVariables()); error.setRegularizer(regularization,®ularizer); - shark::IRpropPlusFull optimizer; + shark::RpropPlus optimizer; error.init(); optimizer.init(error); @@ -178,13 +180,14 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStop { File << optimizer.solution().value << std::endl; } + std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; + } while( !criterion.stop( optimizer.solution() ) ); - std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; net.setParameterVector(optimizer.solution().point); - // m_net.push_back(net); - m_net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); - m_net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); + //m_net.push_back(net); + m_net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); // Copy the encoder in the FF neural network + m_net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); // Copy the decoder in the FF neural network samples = net.encode(samples); } @@ -206,7 +209,7 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::Abstra shark::TwoNormRegularizer regularizer(error.numberOfVariables()); error.setRegularizer(regularization,®ularizer); - shark::IRpropPlusFull optimizer; + shark::RpropPlus optimizer; error.init(); optimizer.init(error); std::cout<<"error before training : " << optimizer.solution().value<<std::endl; @@ -214,6 +217,7 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::Abstra do{ i++; optimizer.step(error); + std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; if (this->m_WriteLearningCurve =true) { File << optimizer.solution().value << std::endl; @@ -229,11 +233,41 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::Abstra m_net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); // Copy the encoder in the FF neural network m_net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); // Copy the decoder in the FF neural network samples = net.encode(samples); - std::cout << "numero zero " << m_net.layerMatrix(layer_index) << "i " << layer_index <<std::endl <<std::endl; - std::cout << "numero uno " << m_net.layerMatrix(m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index) << "i " << m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index << std::endl <<std::endl; } + +template <class TInputValue, class NeuronType> +template <class T> +void AutoencoderModel<TInputValue,NeuronType>::TrainNetwork(shark::AbstractStoppingCriterion<T> & criterion,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) +{ + + shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs + shark::SquaredLoss<shark::RealVector> loss; + + shark::ErrorFunction error(trainSet, &m_net, &loss); + shark::TwoNormRegularizer regularizer(error.numberOfVariables()); + error.setRegularizer(regularization,®ularizer); + + shark::RpropPlus optimizer; + error.init(); + optimizer.init(error); + std::cout<<"error before training : " << optimizer.solution().value<<std::endl; + unsigned int i=0; + do{ + i++; + optimizer.step(error); + std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; + if (this->m_WriteLearningCurve =true) + { + File << optimizer.solution().value << std::endl; + } + } while( !criterion.stop( optimizer.solution() ) ); + //std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; +} + + + template <class TInputValue, class NeuronType> bool AutoencoderModel<TInputValue,NeuronType>::CanReadFile(const std::string & filename) { @@ -396,7 +430,7 @@ void AutoencoderModel<TInputValue,NeuronType> } */ data = m_net.evalLayer( m_net.layerMatrices().size()/2-1 ,data); // features layer for a network containing the encoder and decoder part - std::cout << data.element(0) << std::endl; + unsigned int id = startIndex; target.SetSize(this->m_Dimension); diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 42eb47e76c..fb65be910e 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -46,7 +46,7 @@ using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTa */ template <class TInputValue, class TTargetValue> -using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::LinearNeuron> ; +using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TanhNeuron> ; template <class TInputValue, class TTargetValue> diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 5814c3f3b5..084db66a4c 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -103,7 +103,7 @@ public: #ifdef OTB_USE_SHARK // typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - typedef shark::LinearNeuron NeuronType; + typedef shark::TanhNeuron NeuronType; typedef otb::AutoencoderModel<InputValueType, NeuronType> AutoencoderModelType; /* // typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index b44f99461a..57d6b86144 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -143,7 +143,6 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> rho[i]=std::stof(s_rho[i]); beta[i]=std::stof(s_beta[i]); } - std::cout << nb_neuron << std::endl; dimredTrainer->SetNumberOfHiddenNeurons(nb_neuron); dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); dimredTrainer->SetEpsilon(GetParameterFloat("model.autoencoder.epsilon")); -- GitLab From e963512793edc4e0c2a7a30bcb44342f1d79a1ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 27 Jul 2017 10:44:27 +0200 Subject: [PATCH 067/567] removed irrelevants comments --- include/cbTrainSOM.txx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/cbTrainSOM.txx b/include/cbTrainSOM.txx index fa9137b309..4c6f5c89f1 100644 --- a/include/cbTrainSOM.txx +++ b/include/cbTrainSOM.txx @@ -125,14 +125,14 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> dimredTrainer->SetMaxWeight(GetParameterFloat("model.som.iv")); typename TemplateEstimatorType::SizeType size; std::vector<std::basic_string<char>> s= GetParameterStringList("model.som.s"); - for (int i=0; i<dim; i++){ // This will be templated later (the 3) + for (int i=0; i<dim; i++){ size[i]=std::stoi(s[i]); } dimredTrainer->SetMapSize(size); typename TemplateEstimatorType::SizeType radius; std::vector<std::basic_string<char>> n= GetParameterStringList("model.som.n"); - for (int i=0; i<dim; i++){ // This will be templated later (the 3) + for (int i=0; i<dim; i++){ radius[i]=std::stoi(n[i]); } dimredTrainer->SetNeighborhoodSizeInit(radius); -- GitLab From 7b78f3d759965867c18ba713b9698d463c0ae51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Thu, 27 Jul 2017 10:45:03 +0200 Subject: [PATCH 068/567] the weight initial value during training can now be set with a parameter --- app/cbDimensionalityReduction.cxx | 2 +- app/cbDimensionalityReductionTrainer.cxx | 2 +- app/cbDimensionalityReductionVector.cxx | 2 +- include/AutoencoderModel.h | 4 ++++ include/AutoencoderModel.txx | 4 ++-- include/cbTrainAutoencoder.txx | 7 +++++++ 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index 106f609d48..bc9a5754fe 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -222,7 +222,7 @@ private: } // Rescale vector image - m_Rescaler->SetScale(stddevMeasurementVector); + m_Rescaler->SetScale(stddevMeasurementVector*3); m_Rescaler->SetShift(meanMeasurementVector); m_Rescaler->SetInput(inImage); diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index 4cb042427b..55232ef871 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -124,7 +124,7 @@ private: ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); trainingShiftScaleFilter->SetInput(input); trainingShiftScaleFilter->SetShifts(meanMeasurementVector); - trainingShiftScaleFilter->SetScales(stddevMeasurementVector); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector*3); trainingShiftScaleFilter->Update(); ListSampleType::Pointer trainingListSample= trainingShiftScaleFilter->GetOutput(); diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index 12e1307ad1..cf2caed548 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -223,7 +223,7 @@ class CbDimensionalityReductionVector : public Application ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); trainingShiftScaleFilter->SetInput(input); trainingShiftScaleFilter->SetShifts(meanMeasurementVector); - trainingShiftScaleFilter->SetScales(stddevMeasurementVector); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector*3); trainingShiftScaleFilter->Update(); otbAppLogINFO("mean used: " << meanMeasurementVector); otbAppLogINFO("standard deviation used: " << stddevMeasurementVector); diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 5dbca52e27..9e63558a2c 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -54,6 +54,9 @@ public: itkGetMacro(Epsilon,double); itkSetMacro(Epsilon,double); + itkGetMacro(InitFactor,double); + itkSetMacro(InitFactor,double); + itkGetMacro(Regularization,itk::Array<double>); itkSetMacro(Regularization,itk::Array<double>); @@ -113,6 +116,7 @@ private: itk::Array<double> m_Noise; // probability for an input to be set to 0 (denosing autoencoder) itk::Array<double> m_Rho; // Sparsity parameter itk::Array<double> m_Beta; // Sparsity regularization parameter + double m_InitFactor; // Weight initialization factor (the weights are intialized at m_initfactor/sqrt(inputDimension) ) bool m_WriteLearningCurve; // Flag for writting the learning curve into a txt file std::string m_LearningCurveFileName; // Name of the output learning curve printed after training diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index 668bb7d6ad..f45d055224 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -151,7 +151,7 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStop std::size_t inputs = dataDimension(samples); net.setStructure(inputs, nbneuron); - initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); //initRandomUniform(net,-1,1); shark::ImpulseNoiseModel noise(noise_strength,0.0); //set an input pixel with probability m_Noise to 0 shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; @@ -200,7 +200,7 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::Abstra std::size_t inputs = dataDimension(samples); net.setStructure(inputs, nbneuron); - initRandomUniform(net,-0.1*std::sqrt(1.0/inputs),0.1*std::sqrt(1.0/inputs)); + initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); //initRandomUniform(net,-1,1); shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index 57d6b86144..3272376657 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -52,6 +52,12 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> " "); + AddParameter(ParameterType_Float, "model.autoencoder.initfactor", + " "); + SetParameterFloat("model.autoencoder.initfactor",1, false); + SetParameterDescription( + "model.autoencoder.initfactor", "parameter that control the weight initialization of the autoencoder"); + //Number Of Hidden Neurons AddParameter(ParameterType_StringList , "model.autoencoder.nbneuron", "Size"); /*AddParameter(ParameterType_Int, "model.autoencoder.nbneuron", @@ -146,6 +152,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> dimredTrainer->SetNumberOfHiddenNeurons(nb_neuron); dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); dimredTrainer->SetEpsilon(GetParameterFloat("model.autoencoder.epsilon")); + dimredTrainer->SetInitFactor(GetParameterFloat("model.autoencoder.initfactor")); dimredTrainer->SetRegularization(regularization); dimredTrainer->SetNoise(noise); dimredTrainer->SetRho(rho); -- GitLab From f3436d08f059d12649e8d4063a3bdd6bf6dbb75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Fri, 4 Aug 2017 15:45:00 +0200 Subject: [PATCH 069/567] bug correction for denoising ae --- include/AutoencoderModel.h | 4 ++ include/AutoencoderModel.txx | 84 ++++++++++++++++++++++++---------- include/cbTrainAutoencoder.txx | 8 ++++ 3 files changed, 72 insertions(+), 24 deletions(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 9e63558a2c..afb1c8f095 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -51,6 +51,9 @@ public: itkGetMacro(NumberOfIterations,unsigned int); itkSetMacro(NumberOfIterations,unsigned int); + itkGetMacro(NumberOfIterationsFineTuning,unsigned int); + itkSetMacro(NumberOfIterationsFineTuning,unsigned int); + itkGetMacro(Epsilon,double); itkSetMacro(Epsilon,double); @@ -111,6 +114,7 @@ private: itk::Array<unsigned int> m_NumberOfHiddenNeurons; /** Training parameters */ unsigned int m_NumberOfIterations; // stop the training after a fixed number of iterations + unsigned int m_NumberOfIterationsFineTuning; // stop the fine tuning after a fixed number of iterations double m_Epsilon; // Stops the training when the training error seems to converge itk::Array<double> m_Regularization; // L2 Regularization parameter itk::Array<double> m_Noise; // probability for an input to be set to 0 (denosing autoencoder) diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index f45d055224..88c77dd5ae 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -18,6 +18,9 @@ #include <shark/Algorithms/StoppingCriteria/MaxIterations.h> //A simple stopping criterion that stops after a fixed number of iterations #include <shark/Algorithms/StoppingCriteria/TrainingProgress.h> //Stops when the algorithm seems to converge, Tracks the progress of the training error over a period of time + +#include <shark/Algorithms/GradientDescent/SteepestDescent.h> + namespace otb { @@ -91,6 +94,7 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() if (m_Noise[0] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen { TrainOneLayer(criterion,net,0, m_NumberOfHiddenNeurons[0],m_Noise[0],m_Regularization[0], inputSamples, ofs); + std::cout << "mnoise " << m_Noise[0] << std::endl; } else { @@ -129,6 +133,7 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen { TrainOneLayer(criterion,net, i,m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples, ofs); + std::cout << "mnoise " << m_Noise[i] << std::endl; } else { @@ -138,9 +143,11 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() } } - shark::MaxIterations<> criterion(m_NumberOfIterations); - TrainNetwork(criterion, m_Rho[0],m_Beta[0],m_Regularization[0], inputSamples_copy, ofs); - + if (m_NumberOfIterationsFineTuning > 0) + { + shark::MaxIterations<> criterion(m_NumberOfIterationsFineTuning); + TrainNetwork(criterion, m_Rho[0],m_Beta[0],m_Regularization[0], inputSamples_copy, ofs); + } } template <class TInputValue, class NeuronType> @@ -148,21 +155,23 @@ template <class T, class Autoencoder> void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion, Autoencoder & net,unsigned int layer_index, unsigned int nbneuron,double noise_strength,double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) { //AutoencoderType net; - + std::cout << "noise " << noise_strength << std::endl; std::size_t inputs = dataDimension(samples); net.setStructure(inputs, nbneuron); initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); + //initRandomUniform(net,-1,1); - shark::ImpulseNoiseModel noise(noise_strength,0.0); //set an input pixel with probability m_Noise to 0 + shark::ImpulseNoiseModel noise(inputs,noise_strength,1.0); //set an input pixel with probability m_Noise to 0 shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; shark::ErrorFunction error(trainSet, &model, &loss); + shark::TwoNormRegularizer regularizer(error.numberOfVariables()); error.setRegularizer(regularization,®ularizer); - shark::RpropPlus optimizer; + shark::IRpropPlusFull optimizer; error.init(); optimizer.init(error); @@ -180,7 +189,7 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStop { File << optimizer.solution().value << std::endl; } - std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; + std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<< std::endl ; } while( !criterion.stop( optimizer.solution() ) ); @@ -197,10 +206,26 @@ template <class T, class Autoencoder> void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion, Autoencoder & net, unsigned int layer_index, unsigned int nbneuron,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) { //AutoencoderType net; - std::size_t inputs = dataDimension(samples); net.setStructure(inputs, nbneuron); - initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); + + shark::initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); + + /* Idea : set the initials value for the output weights higher than the input weights + auto weights = net.parameterVector(); + + for(unsigned int i=net.inputSize()*net.numberOfHiddenNeurons(); i< (net.inputSize()+net.outputSize())*net.numberOfHiddenNeurons(); i++ ) + { + weights(i) *= 100; + std::cout << weights(i) << std::endl; + } + net.setParameterVector(weights); + std::cout << "dec" << net.decoderMatrix()<< std::endl; + */ + + + + //std::cout << "initial seed" << net.parameterVector() << std::endl; //initRandomUniform(net,-1,1); shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; @@ -208,22 +233,30 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::Abstra shark::TwoNormRegularizer regularizer(error.numberOfVariables()); error.setRegularizer(regularization,®ularizer); - - shark::RpropPlus optimizer; + std::cout << samples.element(0) << std::endl; + /*shark::SteepestDescent optimizer; error.init(); optimizer.init(error); + optimizer.setLearningRate(0.01); + std::cout << optimizer.learningRate() << std::endl; + */ + shark::IRpropPlusFull optimizer; + error.init(); + optimizer.init(error); + + std::cout<<"error before training : " << optimizer.solution().value<<std::endl; unsigned int i=0; do{ + i++; optimizer.step(error); - std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; + std::cout<<"error after " << i << "iterations : " << optimizer.solution().value <<std::endl; if (this->m_WriteLearningCurve =true) { File << optimizer.solution().value << std::endl; } } while( !criterion.stop( optimizer.solution() ) ); - std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; if (this->m_WriteLearningCurve =true) { File << "end layer" << std::endl; @@ -249,20 +282,21 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainNetwork(shark::AbstractStopp shark::TwoNormRegularizer regularizer(error.numberOfVariables()); error.setRegularizer(regularization,®ularizer); - shark::RpropPlus optimizer; + shark::IRpropPlusFull optimizer; error.init(); optimizer.init(error); std::cout<<"error before training : " << optimizer.solution().value<<std::endl; unsigned int i=0; - do{ + while( !criterion.stop( optimizer.solution() ) ) + { i++; optimizer.step(error); std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; if (this->m_WriteLearningCurve =true) { - File << optimizer.solution().value << std::endl; + File << optimizer.solution().value << std::endl; } - } while( !criterion.stop( optimizer.solution() ) ); + } //std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; } @@ -301,19 +335,21 @@ void AutoencoderModel<TInputValue,NeuronType>::Save(const std::string & filename oa << m_net; ofs.close(); - /* + if (this->m_WriteWeights == true) // output the map vectors in a txt file { std::ofstream otxt(filename+".txt"); - for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + for (unsigned int i = 0 ; i < m_net.layerMatrices().size(); ++i) { - otxt << m_net[i].encoderMatrix() << std::endl; - otxt << m_net[i].hiddenBias() << std::endl; + otxt << "layer " << i << std::endl; + otxt << m_net.layerMatrix(i) << std::endl; + otxt << m_net.bias(i) << std::endl; + otxt << std::endl; } - + /* std::vector<shark::RealVector> features; shark::SquaredLoss<shark::RealVector> loss; @@ -338,9 +374,9 @@ void AutoencoderModel<TInputValue,NeuronType>::Save(const std::string & filename otxt.close(); - + */ } - */ + } diff --git a/include/cbTrainAutoencoder.txx b/include/cbTrainAutoencoder.txx index 3272376657..0da00f85ea 100644 --- a/include/cbTrainAutoencoder.txx +++ b/include/cbTrainAutoencoder.txx @@ -43,6 +43,13 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> SetParameterDescription( "model.autoencoder.nbiter", "The maximum number of iterations used during training."); + + AddParameter(ParameterType_Int, "model.autoencoder.nbiterfinetuning", + "Maximum number of iterations during training"); + SetParameterInt("model.autoencoder.nbiterfinetuning",0, false); + SetParameterDescription( + "model.autoencoder.nbiterfinetuning", + "The maximum number of iterations used during fine tuning of the whole network."); AddParameter(ParameterType_Float, "model.autoencoder.epsilon", " "); @@ -151,6 +158,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue> } dimredTrainer->SetNumberOfHiddenNeurons(nb_neuron); dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); + dimredTrainer->SetNumberOfIterationsFineTuning(GetParameterInt("model.autoencoder.nbiterfinetuning")); dimredTrainer->SetEpsilon(GetParameterFloat("model.autoencoder.epsilon")); dimredTrainer->SetInitFactor(GetParameterFloat("model.autoencoder.initfactor")); dimredTrainer->SetRegularization(regularization); -- GitLab From c277879ed1daf0caf0674e575ecdfa5d1cbb6e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Fri, 8 Sep 2017 10:12:02 +0200 Subject: [PATCH 070/567] Neuron type changed to Logistic --- include/AutoencoderModel.h | 1 + include/DimensionalityReductionModelFactory.txx | 2 +- include/cbLearningApplicationBaseDR.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index afb1c8f095..a8cbe6c0f5 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -36,6 +36,7 @@ public: typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; /// Neural network related typedefs + //typedef shark::Autoencoder<NeuronType,shark::LinearNeuron> OutAutoencoderType; typedef shark::Autoencoder<NeuronType,shark::LinearNeuron> OutAutoencoderType; typedef shark::Autoencoder<NeuronType,NeuronType> AutoencoderType; typedef shark::FFNet<NeuronType,shark::LinearNeuron> NetworkType; diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index fb65be910e..130dd13626 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -46,7 +46,7 @@ using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTa */ template <class TInputValue, class TTargetValue> -using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TanhNeuron> ; +using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::LogisticNeuron> ; template <class TInputValue, class TTargetValue> diff --git a/include/cbLearningApplicationBaseDR.h b/include/cbLearningApplicationBaseDR.h index 084db66a4c..281cc1866b 100644 --- a/include/cbLearningApplicationBaseDR.h +++ b/include/cbLearningApplicationBaseDR.h @@ -103,7 +103,7 @@ public: #ifdef OTB_USE_SHARK // typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - typedef shark::TanhNeuron NeuronType; + typedef shark::LogisticNeuron NeuronType; typedef otb::AutoencoderModel<InputValueType, NeuronType> AutoencoderModelType; /* // typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; -- GitLab From ac8185b7b02817668bf1ba24b0962eaae1be79e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Fri, 8 Sep 2017 10:13:57 +0200 Subject: [PATCH 071/567] comment added --- app/cbDimensionalityReduction.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index bc9a5754fe..aacadbb936 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -118,7 +118,7 @@ private: // Documentation SetDocName("DimensionalityReduction"); SetDocLongDescription("This application reduces the dimension of an input" - " image, based on a dimensionality reduction model file produced by" + " image, based on a machine learning model file produced by" " the DimensionalityReductionTrainer application. Pixels of the " "output image will contain the reduced values from" "the model. The input pixels" @@ -129,8 +129,8 @@ private: SetDocLimitations("The input image must contain the feature bands used for" " the model training. " "If a statistics file was used during training by the " - "TrainRegression, it is mandatory to use the same " - "statistics file for prediction."); + "Training application, it is mandatory to use the same " + "statistics file for reduction."); SetDocAuthors("OTB-Team"); SetDocSeeAlso("DimensionalityReductionTrainer, ComputeImagesStatistics"); -- GitLab From c50f235d96e9f82b1b2c95ce72d4b384a344cba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Fri, 8 Sep 2017 17:07:56 +0200 Subject: [PATCH 072/567] removed the factor of the variance for normalization --- app/cbDimensionalityReduction.cxx | 2 +- app/cbDimensionalityReductionTrainer.cxx | 2 +- app/cbDimensionalityReductionVector.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index aacadbb936..de6408ebcb 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -222,7 +222,7 @@ private: } // Rescale vector image - m_Rescaler->SetScale(stddevMeasurementVector*3); + m_Rescaler->SetScale(stddevMeasurementVector); m_Rescaler->SetShift(meanMeasurementVector); m_Rescaler->SetInput(inImage); diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index 55232ef871..4cb042427b 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -124,7 +124,7 @@ private: ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); trainingShiftScaleFilter->SetInput(input); trainingShiftScaleFilter->SetShifts(meanMeasurementVector); - trainingShiftScaleFilter->SetScales(stddevMeasurementVector*3); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector); trainingShiftScaleFilter->Update(); ListSampleType::Pointer trainingListSample= trainingShiftScaleFilter->GetOutput(); diff --git a/app/cbDimensionalityReductionVector.cxx b/app/cbDimensionalityReductionVector.cxx index cf2caed548..12e1307ad1 100644 --- a/app/cbDimensionalityReductionVector.cxx +++ b/app/cbDimensionalityReductionVector.cxx @@ -223,7 +223,7 @@ class CbDimensionalityReductionVector : public Application ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); trainingShiftScaleFilter->SetInput(input); trainingShiftScaleFilter->SetShifts(meanMeasurementVector); - trainingShiftScaleFilter->SetScales(stddevMeasurementVector*3); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector); trainingShiftScaleFilter->Update(); otbAppLogINFO("mean used: " << meanMeasurementVector); otbAppLogINFO("standard deviation used: " << stddevMeasurementVector); -- GitLab From 4a7f1db47eec2fc7ae540839e8a19edbf8dad128 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 2 Oct 2017 16:12:19 +0200 Subject: [PATCH 073/567] STYLE: remove output to std::out --- .../Applications/AppClassification/app/otbVectorClassifier.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx index 38f8199de3..50a0807a2c 100644 --- a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx @@ -228,7 +228,6 @@ private: input->PushBack(mv); } - std::cout << input->GetMeasurementVector(0) << std::endl; // Statistics for shift/scale MeasurementType meanMeasurementVector; MeasurementType stddevMeasurementVector; @@ -259,7 +258,6 @@ private: otbAppLogINFO("Loading model"); m_Model = MachineLearningModelFactoryType::CreateMachineLearningModel(GetParameterString("model"), MachineLearningModelFactoryType::ReadMode); - std::cout << "model_loaded" << std::endl; if (m_Model.IsNull()) { -- GitLab From b794b2518369e8aaec5f27fbcbb2a8d4ab4bdd9b Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 2 Oct 2017 16:18:42 +0200 Subject: [PATCH 074/567] STYLE: empty line --- .../Applications/AppClassification/app/otbVectorClassifier.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx index 50a0807a2c..b8ecd88713 100644 --- a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx @@ -258,7 +258,7 @@ private: otbAppLogINFO("Loading model"); m_Model = MachineLearningModelFactoryType::CreateMachineLearningModel(GetParameterString("model"), MachineLearningModelFactoryType::ReadMode); - + if (m_Model.IsNull()) { otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") << " : unsupported model type"); -- GitLab From 524d8e52cc75253911aa351ec6b28c174870384e Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 2 Oct 2017 16:27:52 +0200 Subject: [PATCH 075/567] ENH: init the dimension of the model to 0 --- .../include/otbMachineLearningModel.h | 44 +++++++++---------- .../include/otbMachineLearningModel.txx | 25 ++++++----- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModel.h b/Modules/Learning/LearningBase/include/otbMachineLearningModel.h index 7da0aaad12..2bfd9177ff 100644 --- a/Modules/Learning/LearningBase/include/otbMachineLearningModel.h +++ b/Modules/Learning/LearningBase/include/otbMachineLearningModel.h @@ -116,11 +116,11 @@ public: */ TargetSampleType Predict(const InputSampleType& input, ConfidenceValueType *quality = ITK_NULLPTR) const; + /**\name Set and get the dimension of the model for dimensionality reduction models */ + //@{ itkSetMacro(Dimension,unsigned int); itkGetMacro(Dimension,unsigned int); - - // virtual unsigned int GetDimension() {return 1;}; /// This method is used to determine the output vector size after dimensionality reduction, and should be overrided for all machine learning models used for dimensionality reduction. This method is not used for classification and regression - + //@} /** Predict a batch of samples (InputListSampleType) * \param input The batch of sample to predict @@ -132,29 +132,29 @@ public: */ typename TargetListSampleType::Pointer PredictBatch(const InputListSampleType * input, ConfidenceListSampleType * quality = ITK_NULLPTR) const; - /**\name Classification model file manipulation */ - //@{ - /** Save the model to file */ +/**\name Classification model file manipulation */ +//@{ +/** Save the model to file */ virtual void Save(const std::string & filename, const std::string & name="") = 0; - /** Load the model from file */ +/** Load the model from file */ virtual void Load(const std::string & filename, const std::string & name="") = 0; - //@} +//@} - /**\name Classification model file compatibility tests */ - //@{ - /** Is the input model file readable and compatible with the corresponding classifier ? */ +/**\name Classification model file compatibility tests */ +//@{ +/** Is the input model file readable and compatible with the corresponding classifier ? */ virtual bool CanReadFile(const std::string &) = 0; - /** Is the input model file writable and compatible with the corresponding classifier ? */ +/** Is the input model file writable and compatible with the corresponding classifier ? */ virtual bool CanWriteFile(const std::string &) = 0; - //@} +//@} - /** Query capacity to produce a confidence index */ +/** Query capacity to produce a confidence index */ bool HasConfidenceIndex() const {return m_ConfidenceIndex;} - /**\name Input list of samples accessors */ - //@{ +/**\name Input list of samples accessors */ +//@{ itkSetObjectMacro(InputListSample,InputListSampleType); itkGetObjectMacro(InputListSample,InputListSampleType); itkGetConstObjectMacro(InputListSample,InputListSampleType); @@ -188,7 +188,8 @@ protected: /** Input list sample */ typename InputListSampleType::Pointer m_InputListSample; - + + /** Validation list sample if provided for some models */ typename InputListSampleType::Pointer m_ValidationListSample; /** Target list sample */ @@ -198,10 +199,7 @@ protected: /** flag to choose between classification and regression modes */ bool m_RegressionMode; - - /** Output Dimension of the model, used by Dimensionality Reduction models*/ - - + /** flag that indicates if the model supports regression, child * classes should modify it in their constructor if they support * regression mode */ @@ -212,8 +210,10 @@ protected: /** Is DoPredictBatch multi-threaded ? */ bool m_IsDoPredictBatchMultiThreaded; - unsigned int m_Dimension; + /** Output Dimension of the model, used by Dimensionality Reduction models*/ + unsigned int m_Dimension; + private: /** Actual implementation of BatchPredicition * Default implementation will call DoPredict iteratively diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModel.txx b/Modules/Learning/LearningBase/include/otbMachineLearningModel.txx index 678974e9d4..300562a047 100644 --- a/Modules/Learning/LearningBase/include/otbMachineLearningModel.txx +++ b/Modules/Learning/LearningBase/include/otbMachineLearningModel.txx @@ -38,7 +38,8 @@ MachineLearningModel<TInputValue,TOutputValue,TConfidenceValue> m_RegressionMode(false), m_IsRegressionSupported(false), m_ConfidenceIndex(false), - m_IsDoPredictBatchMultiThreaded(false) + m_IsDoPredictBatchMultiThreaded(false), + m_Dimension(0) {} @@ -98,11 +99,11 @@ MachineLearningModel<TInputValue,TOutputValue,TConfidenceValue> else { - #ifdef _OPENMP +#ifdef _OPENMP // OpenMP threading here unsigned int nb_threads(0), threadId(0), nb_batches(0); - #pragma omp parallel shared(nb_threads,nb_batches) private(threadId) +#pragma omp parallel shared(nb_threads,nb_batches) private(threadId) { // Get number of threads configured with ITK omp_set_num_threads(itk::MultiThreader::GetGlobalDefaultNumberOfThreads()); @@ -122,9 +123,9 @@ MachineLearningModel<TInputValue,TOutputValue,TConfidenceValue> this->DoPredictBatch(input,batch_start,batch_size,targets,quality); } } - #else +#else this->DoPredictBatch(input,0,input->Size(),targets,quality); - #endif +#endif return targets; } } @@ -169,12 +170,12 @@ MachineLearningModel<TInputValue,TOutputValue,TConfidenceValue> template <class TInputValue, class TOutputValue, class TConfidenceValue> void -MachineLearningModel<TInputValue,TOutputValue,TConfidenceValue> -::PrintSelf(std::ostream& os, itk::Indent indent) const -{ - // Call superclass implementation - Superclass::PrintSelf(os,indent); -} -} + MachineLearningModel<TInputValue,TOutputValue,TConfidenceValue> + ::PrintSelf(std::ostream& os, itk::Indent indent) const + { + // Call superclass implementation + Superclass::PrintSelf(os,indent); + } + } #endif -- GitLab From a7f2dc29907a28342531ef245307b7de2b9282c4 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Tue, 3 Oct 2017 10:19:42 +0200 Subject: [PATCH 076/567] Imported dimensionality reduction module into OTB --- CMakeLists.txt | 6 ------ .../Applications/AppDimensionalityReduction}/CMakeLists.txt | 0 .../cbDimensionalityReduction.cxx | 0 .../cbDimensionalityReductionTrainer.cxx | 0 .../cbDimensionalityReductionVector.cxx | 0 .../Learning/DimensionalityReduction/README.md | 0 .../DimensionalityReduction/include}/AutoencoderModel.h | 0 .../DimensionalityReduction/include}/AutoencoderModel.txx | 0 .../include}/AutoencoderModelFactory.h | 0 .../include}/AutoencoderModelFactory.txx | 0 .../include}/DimensionalityReductionModelFactory.h | 0 .../include}/DimensionalityReductionModelFactory.txx | 0 .../include}/ImageDimensionalityReductionFilter.h | 0 .../include}/ImageDimensionalityReductionFilter.txx | 0 .../Learning/DimensionalityReduction/include}/PCAModel.h | 0 .../Learning/DimensionalityReduction/include}/PCAModel.txx | 0 .../DimensionalityReduction/include}/PCAModelFactory.h | 0 .../DimensionalityReduction/include}/PCAModelFactory.txx | 0 .../Learning/DimensionalityReduction/include}/SOMModel.h | 0 .../Learning/DimensionalityReduction/include}/SOMModel.txx | 0 .../DimensionalityReduction/include}/SOMModelFactory.h | 0 .../DimensionalityReduction/include}/SOMModelFactory.txx | 0 .../include}/cbLearningApplicationBaseDR.h | 0 .../include}/cbLearningApplicationBaseDR.txx | 0 .../DimensionalityReduction/include}/cbTrainAutoencoder.txx | 0 .../DimensionalityReduction/include}/cbTrainPCA.txx | 0 .../DimensionalityReduction/include}/cbTrainSOM.txx | 0 .../Learning/DimensionalityReduction/otb-module.cmake | 0 28 files changed, 6 deletions(-) delete mode 100644 CMakeLists.txt rename {app => Modules/Applications/AppDimensionalityReduction}/CMakeLists.txt (100%) rename {app => Modules/Applications/AppDimensionalityReduction}/cbDimensionalityReduction.cxx (100%) rename {app => Modules/Applications/AppDimensionalityReduction}/cbDimensionalityReductionTrainer.cxx (100%) rename {app => Modules/Applications/AppDimensionalityReduction}/cbDimensionalityReductionVector.cxx (100%) rename README.md => Modules/Learning/DimensionalityReduction/README.md (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/AutoencoderModel.h (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/AutoencoderModel.txx (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/AutoencoderModelFactory.h (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/AutoencoderModelFactory.txx (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/DimensionalityReductionModelFactory.h (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/DimensionalityReductionModelFactory.txx (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/ImageDimensionalityReductionFilter.h (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/ImageDimensionalityReductionFilter.txx (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/PCAModel.h (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/PCAModel.txx (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/PCAModelFactory.h (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/PCAModelFactory.txx (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/SOMModel.h (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/SOMModel.txx (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/SOMModelFactory.h (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/SOMModelFactory.txx (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/cbLearningApplicationBaseDR.h (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/cbLearningApplicationBaseDR.txx (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/cbTrainAutoencoder.txx (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/cbTrainPCA.txx (100%) rename {include => Modules/Learning/DimensionalityReduction/include}/cbTrainSOM.txx (100%) rename otb-module.cmake => Modules/Learning/DimensionalityReduction/otb-module.cmake (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index b1d9bfe596..0000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.9) - -project(CbDimensionalityReduction) -#set(CbDimensionalityReduction_LIBRARIES CbDimensionalityReduction) -otb_module_impl() - diff --git a/app/CMakeLists.txt b/Modules/Applications/AppDimensionalityReduction/CMakeLists.txt similarity index 100% rename from app/CMakeLists.txt rename to Modules/Applications/AppDimensionalityReduction/CMakeLists.txt diff --git a/app/cbDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/cbDimensionalityReduction.cxx similarity index 100% rename from app/cbDimensionalityReduction.cxx rename to Modules/Applications/AppDimensionalityReduction/cbDimensionalityReduction.cxx diff --git a/app/cbDimensionalityReductionTrainer.cxx b/Modules/Applications/AppDimensionalityReduction/cbDimensionalityReductionTrainer.cxx similarity index 100% rename from app/cbDimensionalityReductionTrainer.cxx rename to Modules/Applications/AppDimensionalityReduction/cbDimensionalityReductionTrainer.cxx diff --git a/app/cbDimensionalityReductionVector.cxx b/Modules/Applications/AppDimensionalityReduction/cbDimensionalityReductionVector.cxx similarity index 100% rename from app/cbDimensionalityReductionVector.cxx rename to Modules/Applications/AppDimensionalityReduction/cbDimensionalityReductionVector.cxx diff --git a/README.md b/Modules/Learning/DimensionalityReduction/README.md similarity index 100% rename from README.md rename to Modules/Learning/DimensionalityReduction/README.md diff --git a/include/AutoencoderModel.h b/Modules/Learning/DimensionalityReduction/include/AutoencoderModel.h similarity index 100% rename from include/AutoencoderModel.h rename to Modules/Learning/DimensionalityReduction/include/AutoencoderModel.h diff --git a/include/AutoencoderModel.txx b/Modules/Learning/DimensionalityReduction/include/AutoencoderModel.txx similarity index 100% rename from include/AutoencoderModel.txx rename to Modules/Learning/DimensionalityReduction/include/AutoencoderModel.txx diff --git a/include/AutoencoderModelFactory.h b/Modules/Learning/DimensionalityReduction/include/AutoencoderModelFactory.h similarity index 100% rename from include/AutoencoderModelFactory.h rename to Modules/Learning/DimensionalityReduction/include/AutoencoderModelFactory.h diff --git a/include/AutoencoderModelFactory.txx b/Modules/Learning/DimensionalityReduction/include/AutoencoderModelFactory.txx similarity index 100% rename from include/AutoencoderModelFactory.txx rename to Modules/Learning/DimensionalityReduction/include/AutoencoderModelFactory.txx diff --git a/include/DimensionalityReductionModelFactory.h b/Modules/Learning/DimensionalityReduction/include/DimensionalityReductionModelFactory.h similarity index 100% rename from include/DimensionalityReductionModelFactory.h rename to Modules/Learning/DimensionalityReduction/include/DimensionalityReductionModelFactory.h diff --git a/include/DimensionalityReductionModelFactory.txx b/Modules/Learning/DimensionalityReduction/include/DimensionalityReductionModelFactory.txx similarity index 100% rename from include/DimensionalityReductionModelFactory.txx rename to Modules/Learning/DimensionalityReduction/include/DimensionalityReductionModelFactory.txx diff --git a/include/ImageDimensionalityReductionFilter.h b/Modules/Learning/DimensionalityReduction/include/ImageDimensionalityReductionFilter.h similarity index 100% rename from include/ImageDimensionalityReductionFilter.h rename to Modules/Learning/DimensionalityReduction/include/ImageDimensionalityReductionFilter.h diff --git a/include/ImageDimensionalityReductionFilter.txx b/Modules/Learning/DimensionalityReduction/include/ImageDimensionalityReductionFilter.txx similarity index 100% rename from include/ImageDimensionalityReductionFilter.txx rename to Modules/Learning/DimensionalityReduction/include/ImageDimensionalityReductionFilter.txx diff --git a/include/PCAModel.h b/Modules/Learning/DimensionalityReduction/include/PCAModel.h similarity index 100% rename from include/PCAModel.h rename to Modules/Learning/DimensionalityReduction/include/PCAModel.h diff --git a/include/PCAModel.txx b/Modules/Learning/DimensionalityReduction/include/PCAModel.txx similarity index 100% rename from include/PCAModel.txx rename to Modules/Learning/DimensionalityReduction/include/PCAModel.txx diff --git a/include/PCAModelFactory.h b/Modules/Learning/DimensionalityReduction/include/PCAModelFactory.h similarity index 100% rename from include/PCAModelFactory.h rename to Modules/Learning/DimensionalityReduction/include/PCAModelFactory.h diff --git a/include/PCAModelFactory.txx b/Modules/Learning/DimensionalityReduction/include/PCAModelFactory.txx similarity index 100% rename from include/PCAModelFactory.txx rename to Modules/Learning/DimensionalityReduction/include/PCAModelFactory.txx diff --git a/include/SOMModel.h b/Modules/Learning/DimensionalityReduction/include/SOMModel.h similarity index 100% rename from include/SOMModel.h rename to Modules/Learning/DimensionalityReduction/include/SOMModel.h diff --git a/include/SOMModel.txx b/Modules/Learning/DimensionalityReduction/include/SOMModel.txx similarity index 100% rename from include/SOMModel.txx rename to Modules/Learning/DimensionalityReduction/include/SOMModel.txx diff --git a/include/SOMModelFactory.h b/Modules/Learning/DimensionalityReduction/include/SOMModelFactory.h similarity index 100% rename from include/SOMModelFactory.h rename to Modules/Learning/DimensionalityReduction/include/SOMModelFactory.h diff --git a/include/SOMModelFactory.txx b/Modules/Learning/DimensionalityReduction/include/SOMModelFactory.txx similarity index 100% rename from include/SOMModelFactory.txx rename to Modules/Learning/DimensionalityReduction/include/SOMModelFactory.txx diff --git a/include/cbLearningApplicationBaseDR.h b/Modules/Learning/DimensionalityReduction/include/cbLearningApplicationBaseDR.h similarity index 100% rename from include/cbLearningApplicationBaseDR.h rename to Modules/Learning/DimensionalityReduction/include/cbLearningApplicationBaseDR.h diff --git a/include/cbLearningApplicationBaseDR.txx b/Modules/Learning/DimensionalityReduction/include/cbLearningApplicationBaseDR.txx similarity index 100% rename from include/cbLearningApplicationBaseDR.txx rename to Modules/Learning/DimensionalityReduction/include/cbLearningApplicationBaseDR.txx diff --git a/include/cbTrainAutoencoder.txx b/Modules/Learning/DimensionalityReduction/include/cbTrainAutoencoder.txx similarity index 100% rename from include/cbTrainAutoencoder.txx rename to Modules/Learning/DimensionalityReduction/include/cbTrainAutoencoder.txx diff --git a/include/cbTrainPCA.txx b/Modules/Learning/DimensionalityReduction/include/cbTrainPCA.txx similarity index 100% rename from include/cbTrainPCA.txx rename to Modules/Learning/DimensionalityReduction/include/cbTrainPCA.txx diff --git a/include/cbTrainSOM.txx b/Modules/Learning/DimensionalityReduction/include/cbTrainSOM.txx similarity index 100% rename from include/cbTrainSOM.txx rename to Modules/Learning/DimensionalityReduction/include/cbTrainSOM.txx diff --git a/otb-module.cmake b/Modules/Learning/DimensionalityReduction/otb-module.cmake similarity index 100% rename from otb-module.cmake rename to Modules/Learning/DimensionalityReduction/otb-module.cmake -- GitLab From 545061f9e1b28840dd8bffa1480a598494b99652 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Tue, 3 Oct 2017 10:27:08 +0200 Subject: [PATCH 077/567] ADD: move files to correct dir --- .../{ => app}/cbDimensionalityReduction.cxx | 0 .../{ => app}/cbDimensionalityReductionTrainer.cxx | 0 .../{ => app}/cbDimensionalityReductionVector.cxx | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename Modules/Applications/AppDimensionalityReduction/{ => app}/cbDimensionalityReduction.cxx (100%) rename Modules/Applications/AppDimensionalityReduction/{ => app}/cbDimensionalityReductionTrainer.cxx (100%) rename Modules/Applications/AppDimensionalityReduction/{ => app}/cbDimensionalityReductionVector.cxx (100%) diff --git a/Modules/Applications/AppDimensionalityReduction/cbDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReduction.cxx similarity index 100% rename from Modules/Applications/AppDimensionalityReduction/cbDimensionalityReduction.cxx rename to Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReduction.cxx diff --git a/Modules/Applications/AppDimensionalityReduction/cbDimensionalityReductionTrainer.cxx b/Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReductionTrainer.cxx similarity index 100% rename from Modules/Applications/AppDimensionalityReduction/cbDimensionalityReductionTrainer.cxx rename to Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReductionTrainer.cxx diff --git a/Modules/Applications/AppDimensionalityReduction/cbDimensionalityReductionVector.cxx b/Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReductionVector.cxx similarity index 100% rename from Modules/Applications/AppDimensionalityReduction/cbDimensionalityReductionVector.cxx rename to Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReductionVector.cxx -- GitLab From 692458c1dff25db07038bd214182eeb8d9ebac5c Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Tue, 3 Oct 2017 10:28:08 +0200 Subject: [PATCH 078/567] ADD: new dim red applications --- .../app/CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Modules/Applications/AppDimensionalityReduction/app/CMakeLists.txt b/Modules/Applications/AppDimensionalityReduction/app/CMakeLists.txt index fcde242bb1..92ad8038f0 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/CMakeLists.txt +++ b/Modules/Applications/AppDimensionalityReduction/app/CMakeLists.txt @@ -29,3 +29,22 @@ otb_create_application( NAME DimensionalityReduction SOURCES otbDimensionalityReduction.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + +OTB_CREATE_APPLICATION( + NAME CbDimensionalityReductionTrainer + SOURCES cbDimensionalityReductionTrainer.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBITK_LIBRARIES} ${OTBBoost_LIBRARIES} ${OTBShark_LIBRARIES} + ) + +OTB_CREATE_APPLICATION( + NAME CbDimensionalityReduction + SOURCES cbDimensionalityReduction.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBITK_LIBRARIES} ${OTBBoost_LIBRARIES} ${OTBShark_LIBRARIES} + ) + +OTB_CREATE_APPLICATION( + NAME CbDimensionalityReductionVector + SOURCES cbDimensionalityReductionVector.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBITK_LIBRARIES} ${OTBBoost_LIBRARIES} ${OTBShark_LIBRARIES} + ) + -- GitLab From a0a00b98fca8e58be9570342aa55ffa3a5256572 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Tue, 3 Oct 2017 10:56:29 +0200 Subject: [PATCH 079/567] COMP: dependencies and renaming for module to compile --- .../AppDimensionalityReduction/otb-module.cmake | 4 +++- .../README.md | 0 .../include/AutoencoderModel.h | 0 .../include/AutoencoderModel.txx | 0 .../include/AutoencoderModelFactory.h | 0 .../include/AutoencoderModelFactory.txx | 0 .../include/DimensionalityReductionModelFactory.h | 0 .../include/DimensionalityReductionModelFactory.txx | 0 .../include/ImageDimensionalityReductionFilter.h | 0 .../include/ImageDimensionalityReductionFilter.txx | 0 .../include/PCAModel.h | 0 .../include/PCAModel.txx | 0 .../include/PCAModelFactory.h | 0 .../include/PCAModelFactory.txx | 0 .../include/SOMModel.h | 0 .../include/SOMModel.txx | 0 .../include/SOMModelFactory.h | 0 .../include/SOMModelFactory.txx | 0 .../include/cbLearningApplicationBaseDR.h | 0 .../include/cbLearningApplicationBaseDR.txx | 0 .../include/cbTrainAutoencoder.txx | 0 .../include/cbTrainPCA.txx | 0 .../include/cbTrainSOM.txx | 0 .../otb-module.cmake | 8 ++++---- 24 files changed, 7 insertions(+), 5 deletions(-) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/README.md (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/AutoencoderModel.h (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/AutoencoderModel.txx (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/AutoencoderModelFactory.h (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/AutoencoderModelFactory.txx (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/DimensionalityReductionModelFactory.h (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/DimensionalityReductionModelFactory.txx (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/ImageDimensionalityReductionFilter.h (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/ImageDimensionalityReductionFilter.txx (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/PCAModel.h (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/PCAModel.txx (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/PCAModelFactory.h (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/PCAModelFactory.txx (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/SOMModel.h (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/SOMModel.txx (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/SOMModelFactory.h (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/SOMModelFactory.txx (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/cbLearningApplicationBaseDR.h (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/cbLearningApplicationBaseDR.txx (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/cbTrainAutoencoder.txx (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/cbTrainPCA.txx (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/include/cbTrainSOM.txx (100%) rename Modules/Learning/{DimensionalityReduction => DimensionalityReductionLearning}/otb-module.cmake (64%) diff --git a/Modules/Applications/AppDimensionalityReduction/otb-module.cmake b/Modules/Applications/AppDimensionalityReduction/otb-module.cmake index 2ee3b794a6..4b1a936de2 100644 --- a/Modules/Applications/AppDimensionalityReduction/otb-module.cmake +++ b/Modules/Applications/AppDimensionalityReduction/otb-module.cmake @@ -25,9 +25,11 @@ otb_module(OTBAppDimensionalityReduction DEPENDS OTBImageManipulation OTBStatistics + OTBIOXML OTBApplicationEngine OTBDimensionalityReduction - TEST_DEPENDS + OTBDimensionalityReductionLearning + TEST_DEPENDS OTBTestKernel OTBCommandLine diff --git a/Modules/Learning/DimensionalityReduction/README.md b/Modules/Learning/DimensionalityReductionLearning/README.md similarity index 100% rename from Modules/Learning/DimensionalityReduction/README.md rename to Modules/Learning/DimensionalityReductionLearning/README.md diff --git a/Modules/Learning/DimensionalityReduction/include/AutoencoderModel.h b/Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModel.h similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/AutoencoderModel.h rename to Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModel.h diff --git a/Modules/Learning/DimensionalityReduction/include/AutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModel.txx similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/AutoencoderModel.txx rename to Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModel.txx diff --git a/Modules/Learning/DimensionalityReduction/include/AutoencoderModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModelFactory.h similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/AutoencoderModelFactory.h rename to Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModelFactory.h diff --git a/Modules/Learning/DimensionalityReduction/include/AutoencoderModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModelFactory.txx similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/AutoencoderModelFactory.txx rename to Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModelFactory.txx diff --git a/Modules/Learning/DimensionalityReduction/include/DimensionalityReductionModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/DimensionalityReductionModelFactory.h similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/DimensionalityReductionModelFactory.h rename to Modules/Learning/DimensionalityReductionLearning/include/DimensionalityReductionModelFactory.h diff --git a/Modules/Learning/DimensionalityReduction/include/DimensionalityReductionModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/DimensionalityReductionModelFactory.txx similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/DimensionalityReductionModelFactory.txx rename to Modules/Learning/DimensionalityReductionLearning/include/DimensionalityReductionModelFactory.txx diff --git a/Modules/Learning/DimensionalityReduction/include/ImageDimensionalityReductionFilter.h b/Modules/Learning/DimensionalityReductionLearning/include/ImageDimensionalityReductionFilter.h similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/ImageDimensionalityReductionFilter.h rename to Modules/Learning/DimensionalityReductionLearning/include/ImageDimensionalityReductionFilter.h diff --git a/Modules/Learning/DimensionalityReduction/include/ImageDimensionalityReductionFilter.txx b/Modules/Learning/DimensionalityReductionLearning/include/ImageDimensionalityReductionFilter.txx similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/ImageDimensionalityReductionFilter.txx rename to Modules/Learning/DimensionalityReductionLearning/include/ImageDimensionalityReductionFilter.txx diff --git a/Modules/Learning/DimensionalityReduction/include/PCAModel.h b/Modules/Learning/DimensionalityReductionLearning/include/PCAModel.h similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/PCAModel.h rename to Modules/Learning/DimensionalityReductionLearning/include/PCAModel.h diff --git a/Modules/Learning/DimensionalityReduction/include/PCAModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/PCAModel.txx similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/PCAModel.txx rename to Modules/Learning/DimensionalityReductionLearning/include/PCAModel.txx diff --git a/Modules/Learning/DimensionalityReduction/include/PCAModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/PCAModelFactory.h similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/PCAModelFactory.h rename to Modules/Learning/DimensionalityReductionLearning/include/PCAModelFactory.h diff --git a/Modules/Learning/DimensionalityReduction/include/PCAModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/PCAModelFactory.txx similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/PCAModelFactory.txx rename to Modules/Learning/DimensionalityReductionLearning/include/PCAModelFactory.txx diff --git a/Modules/Learning/DimensionalityReduction/include/SOMModel.h b/Modules/Learning/DimensionalityReductionLearning/include/SOMModel.h similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/SOMModel.h rename to Modules/Learning/DimensionalityReductionLearning/include/SOMModel.h diff --git a/Modules/Learning/DimensionalityReduction/include/SOMModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/SOMModel.txx similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/SOMModel.txx rename to Modules/Learning/DimensionalityReductionLearning/include/SOMModel.txx diff --git a/Modules/Learning/DimensionalityReduction/include/SOMModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.h similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/SOMModelFactory.h rename to Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.h diff --git a/Modules/Learning/DimensionalityReduction/include/SOMModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.txx similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/SOMModelFactory.txx rename to Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.txx diff --git a/Modules/Learning/DimensionalityReduction/include/cbLearningApplicationBaseDR.h b/Modules/Learning/DimensionalityReductionLearning/include/cbLearningApplicationBaseDR.h similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/cbLearningApplicationBaseDR.h rename to Modules/Learning/DimensionalityReductionLearning/include/cbLearningApplicationBaseDR.h diff --git a/Modules/Learning/DimensionalityReduction/include/cbLearningApplicationBaseDR.txx b/Modules/Learning/DimensionalityReductionLearning/include/cbLearningApplicationBaseDR.txx similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/cbLearningApplicationBaseDR.txx rename to Modules/Learning/DimensionalityReductionLearning/include/cbLearningApplicationBaseDR.txx diff --git a/Modules/Learning/DimensionalityReduction/include/cbTrainAutoencoder.txx b/Modules/Learning/DimensionalityReductionLearning/include/cbTrainAutoencoder.txx similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/cbTrainAutoencoder.txx rename to Modules/Learning/DimensionalityReductionLearning/include/cbTrainAutoencoder.txx diff --git a/Modules/Learning/DimensionalityReduction/include/cbTrainPCA.txx b/Modules/Learning/DimensionalityReductionLearning/include/cbTrainPCA.txx similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/cbTrainPCA.txx rename to Modules/Learning/DimensionalityReductionLearning/include/cbTrainPCA.txx diff --git a/Modules/Learning/DimensionalityReduction/include/cbTrainSOM.txx b/Modules/Learning/DimensionalityReductionLearning/include/cbTrainSOM.txx similarity index 100% rename from Modules/Learning/DimensionalityReduction/include/cbTrainSOM.txx rename to Modules/Learning/DimensionalityReductionLearning/include/cbTrainSOM.txx diff --git a/Modules/Learning/DimensionalityReduction/otb-module.cmake b/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake similarity index 64% rename from Modules/Learning/DimensionalityReduction/otb-module.cmake rename to Modules/Learning/DimensionalityReductionLearning/otb-module.cmake index 258fdf1c44..c700e3ba10 100644 --- a/Modules/Learning/DimensionalityReduction/otb-module.cmake +++ b/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake @@ -1,6 +1,6 @@ set(DOCUMENTATION "Dimensionality reduction application") -otb_module(CbDimensionalityReduction - DEPENDS +otb_module(OTBDimensionalityReductionLearning + DEPENDS OTBCommon OTBApplicationEngine OTBITK @@ -9,6 +9,6 @@ otb_module(CbDimensionalityReduction OTBAppClassification OTBSOM OTBLearningBase - DESCRIPTION - "${DOCUMENTATION}" + DESCRIPTION + "${DOCUMENTATION}" ) -- GitLab From 918ef4e8cd9a107be88cd87de94ba702cfe0cf93 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Tue, 3 Oct 2017 15:01:37 +0200 Subject: [PATCH 080/567] STYLE: rename new DimensionalityReduction applications --- .../app/CMakeLists.txt | 12 +- .../app/cbDimensionalityReductionTrainer.cxx | 146 ------------------ ...xx => otbImageDimensionalityReduction.cxx} | 32 ++-- .../app/otbTrainDimensionalityReduction.cxx | 146 ++++++++++++++++++ ...x => otbVectorDimensionalityReduction.cxx} | 22 +-- 5 files changed, 179 insertions(+), 179 deletions(-) delete mode 100644 Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReductionTrainer.cxx rename Modules/Applications/AppDimensionalityReduction/app/{cbDimensionalityReduction.cxx => otbImageDimensionalityReduction.cxx} (89%) create mode 100644 Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx rename Modules/Applications/AppDimensionalityReduction/app/{cbDimensionalityReductionVector.cxx => otbVectorDimensionalityReduction.cxx} (95%) diff --git a/Modules/Applications/AppDimensionalityReduction/app/CMakeLists.txt b/Modules/Applications/AppDimensionalityReduction/app/CMakeLists.txt index 92ad8038f0..75baabb957 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/CMakeLists.txt +++ b/Modules/Applications/AppDimensionalityReduction/app/CMakeLists.txt @@ -31,20 +31,20 @@ otb_create_application( LINK_LIBRARIES ${${otb-module}_LIBRARIES}) OTB_CREATE_APPLICATION( - NAME CbDimensionalityReductionTrainer - SOURCES cbDimensionalityReductionTrainer.cxx + NAME TrainDimensionalityReduction + SOURCES otbTrainDimensionalityReduction.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBITK_LIBRARIES} ${OTBBoost_LIBRARIES} ${OTBShark_LIBRARIES} ) OTB_CREATE_APPLICATION( - NAME CbDimensionalityReduction - SOURCES cbDimensionalityReduction.cxx + NAME ImageDimensionalityReduction + SOURCES otbImageDimensionalityReduction.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBITK_LIBRARIES} ${OTBBoost_LIBRARIES} ${OTBShark_LIBRARIES} ) OTB_CREATE_APPLICATION( - NAME CbDimensionalityReductionVector - SOURCES cbDimensionalityReductionVector.cxx + NAME VectorDimensionalityReduction + SOURCES otbVectorDimensionalityReduction.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBITK_LIBRARIES} ${OTBBoost_LIBRARIES} ${OTBShark_LIBRARIES} ) diff --git a/Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReductionTrainer.cxx b/Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReductionTrainer.cxx deleted file mode 100644 index 4cb042427b..0000000000 --- a/Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReductionTrainer.cxx +++ /dev/null @@ -1,146 +0,0 @@ -#include "otbWrapperApplication.h" -#include "otbWrapperApplicationFactory.h" - -#include "otbOGRDataSourceWrapper.h" -#include "otbOGRFeatureWrapper.h" - -#include "itkVariableLengthVector.h" - -#include "otbShiftScaleSampleListFilter.h" -#include "otbStatisticsXMLFileReader.h" - -//#include "otbSharkUtils.h" - -#include <fstream> // write the model file - -#include "DimensionalityReductionModelFactory.h" -#include "cbLearningApplicationBaseDR.h" - - -namespace otb -{ -namespace Wrapper -{ -class CbDimensionalityReductionTrainer : public cbLearningApplicationBaseDR<float,float> -{ -public: - typedef CbDimensionalityReductionTrainer Self; - typedef cbLearningApplicationBaseDR<float, float> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - itkNewMacro(Self); - itkTypeMacro(CbDimensionalityReductionTrainer, otb::Application); - - - typedef Superclass::SampleType SampleType; - typedef Superclass::ListSampleType ListSampleType; - typedef Superclass::SampleImageType SampleImageType; - - typedef float ValueType; - typedef itk::VariableLengthVector<ValueType> MeasurementType; - - typedef otb::StatisticsXMLFileReader<SampleType> StatisticsReader; - - typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; - - typedef otb::DimensionalityReductionModelFactory<ValueType, ValueType> ModelFactoryType; - -private: - void DoInit() - { - SetName("CbDimensionalityReductionTrainer"); - SetDescription("Trainer for the dimensionality reduction algorithms used in the cbDimensionalityReduction application."); - - AddParameter(ParameterType_Group, "io", "Input and output data"); - SetParameterDescription("io", "This group of parameters allows setting input and output data."); - - AddParameter(ParameterType_InputVectorData, "io.vd", "Input Vector Data"); - SetParameterDescription("io.vd", "Input geometries used for training (note : all geometries from the layer will be used)"); - - AddParameter(ParameterType_OutputFilename, "io.out", "Output model"); - SetParameterDescription("io.out", "Output file containing the model estimated (.txt format)."); - - - AddParameter(ParameterType_InputFilename, "io.stats", "Input XML image statistics file"); - MandatoryOff("io.stats"); - SetParameterDescription("io.stats", "XML file containing mean and variance of each feature."); - - AddParameter(ParameterType_StringList, "feat", "Field names to be calculated."); // - SetParameterDescription("feat","List of field names in the input vector data used as features for training."); // - - Superclass::DoInit(); - - AddRAMParameter(); - } - - void DoUpdateParameters() - { - } - - void DoExecute() - { - - std::string shapefile = GetParameterString("io.vd"); - - otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); - otb::ogr::Layer layer = source->GetLayer(0); - ListSampleType::Pointer input = ListSampleType::New(); - const int nbFeatures = GetParameterStringList("feat").size(); - - input->SetMeasurementVectorSize(nbFeatures); - otb::ogr::Layer::const_iterator it = layer.cbegin(); - otb::ogr::Layer::const_iterator itEnd = layer.cend(); - for( ; it!=itEnd ; ++it) - { - MeasurementType mv; - mv.SetSize(nbFeatures); - for(int idx=0; idx < nbFeatures; ++idx) - { - mv[idx] = (*it)[GetParameterStringList("feat")[idx]].GetValue<double>(); - } - input->PushBack(mv); - } - - MeasurementType meanMeasurementVector; - MeasurementType stddevMeasurementVector; - - if (HasValue("io.stats") && IsParameterEnabled("io.stats")) - { - StatisticsReader::Pointer statisticsReader = StatisticsReader::New(); - std::string XMLfile = GetParameterString("io.stats"); - statisticsReader->SetFileName(XMLfile); - meanMeasurementVector = statisticsReader->GetStatisticVectorByName("mean"); - stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); - } - else - { - meanMeasurementVector.SetSize(nbFeatures); - meanMeasurementVector.Fill(0.); - stddevMeasurementVector.SetSize(nbFeatures); - stddevMeasurementVector.Fill(1.); - } - - ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); - trainingShiftScaleFilter->SetInput(input); - trainingShiftScaleFilter->SetShifts(meanMeasurementVector); - trainingShiftScaleFilter->SetScales(stddevMeasurementVector); - trainingShiftScaleFilter->Update(); - - ListSampleType::Pointer trainingListSample= trainingShiftScaleFilter->GetOutput(); - - - this->Train(trainingListSample,GetParameterString("io.out")); - } - - - - - -}; - - -} -} - -OTB_APPLICATION_EXPORT(otb::Wrapper::CbDimensionalityReductionTrainer) diff --git a/Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx similarity index 89% rename from Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReduction.cxx rename to Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx index de6408ebcb..a4d00030fe 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx @@ -71,11 +71,11 @@ private: namespace Wrapper { -class CbDimensionalityReduction : public Application +class ImageDimensionalityReduction : public Application { public: /** Standard class typedefs. */ - typedef CbDimensionalityReduction Self; + typedef ImageDimensionalityReduction Self; typedef Application Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -83,7 +83,7 @@ public: /** Standard macro */ itkNewMacro(Self); - itkTypeMacro(CbDimensionalityReduction, otb::Application); + itkTypeMacro(ImageDimensionalityReduction, otb::Application); /** Filters typedef */ typedef UInt8ImageType MaskImageType; @@ -104,10 +104,10 @@ public: protected: - ~CbDimensionalityReduction() ITK_OVERRIDE - { + ~ImageDimensionalityReduction() ITK_OVERRIDE + { DimensionalityReductionModelFactoryType::CleanFactories(); - } + } private: void DoInit() ITK_OVERRIDE @@ -119,7 +119,7 @@ private: SetDocName("DimensionalityReduction"); SetDocLongDescription("This application reduces the dimension of an input" " image, based on a machine learning model file produced by" - " the DimensionalityReductionTrainer application. Pixels of the " + " the TrainDimensionalityReduction application. Pixels of the " "output image will contain the reduced values from" "the model. The input pixels" " can be optionally centered and reduced according " @@ -132,7 +132,7 @@ private: "Training application, it is mandatory to use the same " "statistics file for reduction."); SetDocAuthors("OTB-Team"); - SetDocSeeAlso("DimensionalityReductionTrainer, ComputeImagesStatistics"); + SetDocSeeAlso("TrainDimensionalityReduction, ComputeImagesStatistics"); AddDocTag(Tags::Learning); @@ -146,27 +146,27 @@ private: MandatoryOff("mask"); AddParameter(ParameterType_InputFilename, "model", "Model file"); - SetParameterDescription("model", "A regression model file (produced by " - "TrainRegression application)."); + SetParameterDescription("model", "A dimensionality reduction model file (produced by " + "TrainRegression application)."); AddParameter(ParameterType_InputFilename, "imstat", "Statistics file"); SetParameterDescription("imstat", "A XML file containing mean and standard" " deviation to center and reduce samples before prediction " "(produced by ComputeImagesStatistics application). If this file contains" - "one more band than the sample size, the last stat of last band will be" - "applied to expand the output predicted value"); + "one more bands than the sample size, the last stat of last band will be" + "applied to expand the output predicted value"); MandatoryOff("imstat"); AddParameter(ParameterType_OutputImage, "out", "Output Image"); - SetParameterDescription( "out", "Output image containing predicted values"); + SetParameterDescription( "out", "Output image containing reduced values"); AddRAMParameter(); // Doc example parameter settings SetDocExampleParameterValue("in", "QB_1_ortho.tif"); SetDocExampleParameterValue("imstat", "EstimateImageStatisticsQB1.xml"); - SetDocExampleParameterValue("model", "clsvmModelQB1.svm"); - SetDocExampleParameterValue("out", "clLabeledImageQB1.tif"); + SetDocExampleParameterValue("model", "clsvmModelQB1.model"); + SetDocExampleParameterValue("out", "ReducedImageQB1.tif"); } void DoUpdateParameters() ITK_OVERRIDE @@ -258,4 +258,4 @@ private: } } -OTB_APPLICATION_EXPORT(otb::Wrapper::CbDimensionalityReduction) +OTB_APPLICATION_EXPORT(otb::Wrapper::ImageDimensionalityReduction) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx new file mode 100644 index 0000000000..5f94e918b3 --- /dev/null +++ b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx @@ -0,0 +1,146 @@ +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + +#include "otbOGRDataSourceWrapper.h" +#include "otbOGRFeatureWrapper.h" + +#include "itkVariableLengthVector.h" + +#include "otbShiftScaleSampleListFilter.h" +#include "otbStatisticsXMLFileReader.h" + +//#include "otbSharkUtils.h" + +#include <fstream> // write the model file + +#include "DimensionalityReductionModelFactory.h" +#include "cbLearningApplicationBaseDR.h" + + +namespace otb +{ +namespace Wrapper +{ +class TrainDimensionalityReduction : public cbLearningApplicationBaseDR<float,float> +{ +public: + typedef TrainDimensionalityReduction Self; + typedef cbLearningApplicationBaseDR<float, float> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + itkNewMacro(Self); + itkTypeMacro(TrainDimensionalityReduction, otb::Application); + + + typedef Superclass::SampleType SampleType; + typedef Superclass::ListSampleType ListSampleType; + typedef Superclass::SampleImageType SampleImageType; + + typedef float ValueType; + typedef itk::VariableLengthVector<ValueType> MeasurementType; + + typedef otb::StatisticsXMLFileReader<SampleType> StatisticsReader; + + typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; + + typedef otb::DimensionalityReductionModelFactory<ValueType, ValueType> ModelFactoryType; + +private: + void DoInit() + { + SetName("TrainDimensionalityReduction"); + SetDescription("Trainer for the dimensionality reduction algorithms used in the ImageDimensionalityReduction and VectorDimensionalityReduction applications."); + + AddParameter(ParameterType_Group, "io", "Input and output data"); + SetParameterDescription("io", "This group of parameters allows setting input and output data."); + + AddParameter(ParameterType_InputVectorData, "io.vd", "Input Vector Data"); + SetParameterDescription("io.vd", "Input geometries used for training (note : all geometries from the layer will be used)"); + + AddParameter(ParameterType_OutputFilename, "io.out", "Output model"); + SetParameterDescription("io.out", "Output file containing the model estimated (.txt format)."); + + + AddParameter(ParameterType_InputFilename, "io.stats", "Input XML image statistics file"); + MandatoryOff("io.stats"); + SetParameterDescription("io.stats", "XML file containing mean and variance of each feature."); + + AddParameter(ParameterType_StringList, "feat", "Field names to be calculated."); // + SetParameterDescription("feat","List of field names in the input vector data used as features for training."); // + + Superclass::DoInit(); + + AddRAMParameter(); + } + + void DoUpdateParameters() + { + } + + void DoExecute() + { + + std::string shapefile = GetParameterString("io.vd"); + + otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); + otb::ogr::Layer layer = source->GetLayer(0); + ListSampleType::Pointer input = ListSampleType::New(); + const int nbFeatures = GetParameterStringList("feat").size(); + + input->SetMeasurementVectorSize(nbFeatures); + otb::ogr::Layer::const_iterator it = layer.cbegin(); + otb::ogr::Layer::const_iterator itEnd = layer.cend(); + for( ; it!=itEnd ; ++it) + { + MeasurementType mv; + mv.SetSize(nbFeatures); + for(int idx=0; idx < nbFeatures; ++idx) + { + mv[idx] = (*it)[GetParameterStringList("feat")[idx]].GetValue<double>(); + } + input->PushBack(mv); + } + + MeasurementType meanMeasurementVector; + MeasurementType stddevMeasurementVector; + + if (HasValue("io.stats") && IsParameterEnabled("io.stats")) + { + StatisticsReader::Pointer statisticsReader = StatisticsReader::New(); + std::string XMLfile = GetParameterString("io.stats"); + statisticsReader->SetFileName(XMLfile); + meanMeasurementVector = statisticsReader->GetStatisticVectorByName("mean"); + stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); + } + else + { + meanMeasurementVector.SetSize(nbFeatures); + meanMeasurementVector.Fill(0.); + stddevMeasurementVector.SetSize(nbFeatures); + stddevMeasurementVector.Fill(1.); + } + + ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); + trainingShiftScaleFilter->SetInput(input); + trainingShiftScaleFilter->SetShifts(meanMeasurementVector); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector); + trainingShiftScaleFilter->Update(); + + ListSampleType::Pointer trainingListSample= trainingShiftScaleFilter->GetOutput(); + + + this->Train(trainingListSample,GetParameterString("io.out")); + } + + + + + +}; + + +} +} + +OTB_APPLICATION_EXPORT(otb::Wrapper::TrainDimensionalityReduction) diff --git a/Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReductionVector.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx similarity index 95% rename from Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReductionVector.cxx rename to Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx index 12e1307ad1..8036bcb32f 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/cbDimensionalityReductionVector.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx @@ -41,13 +41,13 @@ bool IsNotAlphaNum(char c) return !std::isalnum(c); } -class CbDimensionalityReductionVector : public Application +class VectorDimensionalityReduction : public Application { public: /** Standard class typedefs. */ - typedef CbDimensionalityReductionVector Self; - typedef Application Superclass; + typedef VectorDimensionalityReduction Self; + typedef Application Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -68,8 +68,8 @@ class CbDimensionalityReductionVector : public Application typedef itk::VariableLengthVector<ValueType> MeasurementType; typedef otb::StatisticsXMLFileReader<MeasurementType> StatisticsReader; typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; - ~CbDimensionalityReductionVector() ITK_OVERRIDE - { + ~VectorDimensionalityReduction() ITK_OVERRIDE + { DimensionalityReductionModelFactoryType::CleanFactories(); } @@ -81,8 +81,8 @@ class CbDimensionalityReductionVector : public Application SetDescription("Performs dimensionality reduction of the input vector data according to a model file."); SetDocName("Vector Dimensionality Reduction"); SetDocAuthors("OTB-Team"); - SetDocLongDescription("This application performs a vector data dimensionality reduction based on a model file produced by the cbDimensionalityReductionTrainer application."); - SetDocSeeAlso("cbDimensionalityReductionTrainer"); + SetDocLongDescription("This application performs a vector data dimensionality reduction based on a model file produced by the TrainDimensionalityReduction application."); + SetDocSeeAlso("TrainDimensionalityReduction"); AddDocTag(Tags::Learning); AddParameter(ParameterType_InputVectorData, "in", "Name of the input vector data"); @@ -94,13 +94,13 @@ class CbDimensionalityReductionVector : public Application MandatoryOff("instat"); AddParameter(ParameterType_InputFilename, "model", "Model file"); - SetParameterDescription("model", "A model file (produced by cbDimensionalityReduction application,"); + SetParameterDescription("model", "A model file (produced by the TrainDimensionalityReduction application,"); AddParameter(ParameterType_ListView, "feat", "Field names to be calculated."); // - SetParameterDescription("feat","List of field names in the input vector data used as features for training."); // + SetParameterDescription("feat","List of field names in the input vector data used as features for reduction."); // AddParameter(ParameterType_StringList, "featout", "Field names to be calculated."); // - SetParameterDescription("featout","List of field names in the input vector data used as features for training."); // + SetParameterDescription("featout","List of field names in the input vector data used as features for reduction."); // AddParameter(ParameterType_OutputFilename, "out", "Output vector data file containing the reduced vector"); SetParameterDescription("out","Output vector data file storing sample values (OGR format)." @@ -388,4 +388,4 @@ class CbDimensionalityReductionVector : public Application }; } } -OTB_APPLICATION_EXPORT(otb::Wrapper::CbDimensionalityReductionVector) +OTB_APPLICATION_EXPORT(otb::Wrapper::VectorDimensionalityReduction) -- GitLab From 5bf575f9fc106a33dca4a60caf6ea4f90bca26b7 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Tue, 3 Oct 2017 16:14:39 +0200 Subject: [PATCH 081/567] REFAC: rename classes and files and move some of them to the application module --- .../app/otbImageDimensionalityReduction.cxx | 4 +- .../app/otbTrainDimensionalityReduction.cxx | 8 +- .../app/otbVectorDimensionalityReduction.cxx | 3 +- ...mensionalityReductionTrainAutoencoder.txx} | 11 +- .../otbDimensionalityReductionTrainPCA.txx} | 6 +- .../otbDimensionalityReductionTrainSOM.txx} | 8 +- ...inDimensionalityReductionApplicationBase.h | 170 +++++++++++++++++ ...imensionalityReductionApplicationBase.txx} | 24 +-- .../include/SOMModelFactory.txx | 9 +- .../include/cbLearningApplicationBaseDR.h | 171 ------------------ ...toencoderModel.h => otbAutoencoderModel.h} | 6 +- ...coderModel.txx => otbAutoencoderModel.txx} | 22 +-- ...Factory.h => otbAutoencoderModelFactory.h} | 2 +- ...ory.txx => otbAutoencoderModelFactory.txx} | 8 +- ... otbDimensionalityReductionModelFactory.h} | 2 +- ...tbDimensionalityReductionModelFactory.txx} | 23 +-- ...> otbImageDimensionalityReductionFilter.h} | 2 +- ...otbImageDimensionalityReductionFilter.txx} | 2 +- .../include/{PCAModel.h => otbPCAModel.h} | 2 +- .../include/{PCAModel.txx => otbPCAModel.txx} | 0 ...PCAModelFactory.h => otbPCAModelFactory.h} | 2 +- ...odelFactory.txx => otbPCAModelFactory.txx} | 8 +- .../include/{SOMModel.h => otbSOMModel.h} | 2 +- .../include/{SOMModel.txx => otbSOMModel.txx} | 0 ...SOMModelFactory.h => otbSOMModelFactory.h} | 0 25 files changed, 239 insertions(+), 256 deletions(-) rename Modules/{Learning/DimensionalityReductionLearning/include/cbTrainAutoencoder.txx => Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx} (94%) rename Modules/{Learning/DimensionalityReductionLearning/include/cbTrainPCA.txx => Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx} (85%) rename Modules/{Learning/DimensionalityReductionLearning/include/cbTrainSOM.txx => Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx} (94%) create mode 100644 Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h rename Modules/{Learning/DimensionalityReductionLearning/include/cbLearningApplicationBaseDR.txx => Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx} (77%) delete mode 100644 Modules/Learning/DimensionalityReductionLearning/include/cbLearningApplicationBaseDR.h rename Modules/Learning/DimensionalityReductionLearning/include/{AutoencoderModel.h => otbAutoencoderModel.h} (96%) rename Modules/Learning/DimensionalityReductionLearning/include/{AutoencoderModel.txx => otbAutoencoderModel.txx} (96%) rename Modules/Learning/DimensionalityReductionLearning/include/{AutoencoderModelFactory.h => otbAutoencoderModelFactory.h} (97%) rename Modules/Learning/DimensionalityReductionLearning/include/{AutoencoderModelFactory.txx => otbAutoencoderModelFactory.txx} (86%) rename Modules/Learning/DimensionalityReductionLearning/include/{DimensionalityReductionModelFactory.h => otbDimensionalityReductionModelFactory.h} (98%) rename Modules/Learning/DimensionalityReductionLearning/include/{DimensionalityReductionModelFactory.txx => otbDimensionalityReductionModelFactory.txx} (86%) rename Modules/Learning/DimensionalityReductionLearning/include/{ImageDimensionalityReductionFilter.h => otbImageDimensionalityReductionFilter.h} (98%) rename Modules/Learning/DimensionalityReductionLearning/include/{ImageDimensionalityReductionFilter.txx => otbImageDimensionalityReductionFilter.txx} (99%) rename Modules/Learning/DimensionalityReductionLearning/include/{PCAModel.h => otbPCAModel.h} (99%) rename Modules/Learning/DimensionalityReductionLearning/include/{PCAModel.txx => otbPCAModel.txx} (100%) rename Modules/Learning/DimensionalityReductionLearning/include/{PCAModelFactory.h => otbPCAModelFactory.h} (97%) rename Modules/Learning/DimensionalityReductionLearning/include/{PCAModelFactory.txx => otbPCAModelFactory.txx} (85%) rename Modules/Learning/DimensionalityReductionLearning/include/{SOMModel.h => otbSOMModel.h} (99%) rename Modules/Learning/DimensionalityReductionLearning/include/{SOMModel.txx => otbSOMModel.txx} (100%) rename Modules/Learning/DimensionalityReductionLearning/include/{SOMModelFactory.h => otbSOMModelFactory.h} (100%) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx index a4d00030fe..7543fffb96 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx @@ -23,10 +23,10 @@ #include "otbStandardWriterWatcher.h" #include "otbStatisticsXMLFileReader.h" #include "otbShiftScaleVectorImageFilter.h" -#include "ImageDimensionalityReductionFilter.h" +#include "otbImageDimensionalityReductionFilter.h" #include "otbMultiToMonoChannelExtractROI.h" #include "otbImageToVectorImageCastFilter.h" -#include "DimensionalityReductionModelFactory.h" +#include "otbDimensionalityReductionModelFactory.h" namespace otb { diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx index 5f94e918b3..dea0331cea 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx @@ -13,19 +13,19 @@ #include <fstream> // write the model file -#include "DimensionalityReductionModelFactory.h" -#include "cbLearningApplicationBaseDR.h" +#include "otbDimensionalityReductionModelFactory.h" +#include "otbTrainDimensionalityReductionApplicationBase.h" namespace otb { namespace Wrapper { -class TrainDimensionalityReduction : public cbLearningApplicationBaseDR<float,float> +class TrainDimensionalityReduction : public TrainDimensionalityReductionApplicationBase<float,float> { public: typedef TrainDimensionalityReduction Self; - typedef cbLearningApplicationBaseDR<float, float> Superclass; + typedef TrainDimensionalityReductionApplicationBase<float, float> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx index 8036bcb32f..43638c4207 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx @@ -26,8 +26,7 @@ #include "otbStatisticsXMLFileReader.h" #include "itkListSample.h" #include "otbShiftScaleSampleListFilter.h" -#include "DimensionalityReductionModelFactory.h" -//#include "DimensionalityReductionModel.h" +#include "otbDimensionalityReductionModelFactory.h" #include <time.h> namespace otb diff --git a/Modules/Learning/DimensionalityReductionLearning/include/cbTrainAutoencoder.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx similarity index 94% rename from Modules/Learning/DimensionalityReductionLearning/include/cbTrainAutoencoder.txx rename to Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx index 0da00f85ea..dc787d5d15 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/cbTrainAutoencoder.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx @@ -2,7 +2,7 @@ #ifndef cbTrainAutoencoder_txx #define cbTrainAutoencoder_txx -#include "cbLearningApplicationBaseDR.h" +#include "otbTrainDimensionalityReductionApplicationBase.h" namespace otb { @@ -11,7 +11,7 @@ namespace Wrapper template <class TInputValue, class TOutputValue> void -cbLearningApplicationBaseDR<TInputValue,TOutputValue> +TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::InitAutoencoderParams() { @@ -103,9 +103,9 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> template <class TInputValue, class TOutputValue> void -cbLearningApplicationBaseDR<TInputValue,TOutputValue> +TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample, - std::string modelPath) + std::string modelPath) { std::string TiedWeigth = GetParameterString("model.autoencoder.istied"); std::cout << TiedWeigth << std::endl; @@ -130,8 +130,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> template <class TInputValue, class TOutputValue> template <typename autoencoderchoice> -void cbLearningApplicationBaseDR<TInputValue,TOutputValue> -::TrainAutoencoder(typename ListSampleType::Pointer trainingListSample,std::string modelPath) +void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue>::TrainAutoencoder(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { typename autoencoderchoice::Pointer dimredTrainer = autoencoderchoice::New(); itk::Array<unsigned int> nb_neuron; diff --git a/Modules/Learning/DimensionalityReductionLearning/include/cbTrainPCA.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx similarity index 85% rename from Modules/Learning/DimensionalityReductionLearning/include/cbTrainPCA.txx rename to Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx index d51926469b..003ebb1ccf 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/cbTrainPCA.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx @@ -2,7 +2,7 @@ #ifndef cbTrainPCA_txx #define cbTrainPCA_txx -#include "cbLearningApplicationBaseDR.h" +#include "otbTrainDimensionalityReductionApplicationBase.h" namespace otb { @@ -11,7 +11,7 @@ namespace Wrapper template <class TInputValue, class TOutputValue> void -cbLearningApplicationBaseDR<TInputValue,TOutputValue> +TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::InitPCAParams() { @@ -34,7 +34,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> } template <class TInputValue, class TOutputValue> -void cbLearningApplicationBaseDR<TInputValue,TOutputValue> +void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::TrainPCA(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { typename PCAModelType::Pointer dimredTrainer = PCAModelType::New(); diff --git a/Modules/Learning/DimensionalityReductionLearning/include/cbTrainSOM.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx similarity index 94% rename from Modules/Learning/DimensionalityReductionLearning/include/cbTrainSOM.txx rename to Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx index 4c6f5c89f1..61975c9708 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/cbTrainSOM.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx @@ -1,7 +1,7 @@ #ifndef cbTrainSOM_txx #define cbTrainSOM_txx -#include "cbLearningApplicationBaseDR.h" +#include "otbTrainDimensionalityReductionApplicationBase.h" namespace otb { @@ -10,7 +10,7 @@ namespace Wrapper template <class TInputValue, class TOutputValue> void -cbLearningApplicationBaseDR<TInputValue,TOutputValue> +TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::InitSOMParams() { @@ -76,7 +76,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> template <class TInputValue, class TOutputValue> void -cbLearningApplicationBaseDR<TInputValue,TOutputValue> +TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath) { @@ -111,7 +111,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> template <class TInputValue, class TOutputValue> template <typename somchoice> -void cbLearningApplicationBaseDR<TInputValue,TOutputValue> +void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::TrainSOM(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { using TemplateEstimatorType = typename somchoice::EstimatorType; diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h new file mode 100644 index 0000000000..c14bfd8ca0 --- /dev/null +++ b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h @@ -0,0 +1,170 @@ +#ifndef cbLearningApplicationBaseDR_h +#define cbLearningApplicationBaseDR_h + +#include "otbConfigure.h" + +#include "otbWrapperApplication.h" + +#include <iostream> + +// ListSample +#include "itkListSample.h" +#include "itkVariableLengthVector.h" + +//Estimator +#include "otbDimensionalityReductionModelFactory.h" + +#include "otbSOMModel.h" + +#ifdef OTB_USE_SHARK +#include "otbAutoencoderModel.h" +#include "otbPCAModel.h" +#endif + +namespace otb +{ +namespace Wrapper +{ + +/** \class LearningApplicationBase + * \brief LearningApplicationBase is the base class for application that + * use machine learning model. + * + * This base class offers a DoInit() method to initialize all the parameters + * related to machine learning models. They will all be in the choice parameter + * named "classifier". The class also offers generic Train() and Classify() + * methods. The classes derived from LearningApplicationBase only need these + * 3 methods to handle the machine learning model. + * + * There are multiple machine learning models in OTB, some imported + * from OpenCV and one imported from LibSVM. They all have + * different parameters. The purpose of this class is to handle the + * creation of all parameters related to machine learning models (in + * DoInit() ), and to dispatch the calls to specific train functions + * in function Train(). + * + * This class is templated over scalar types for input and output values. + * Typically, the input value type will be either float of double. The choice + * of an output value type depends on the learning mode. This base class + * supports both classification and regression modes. For classification + * (enabled by default), the output value type corresponds to a class + * identifier so integer types suit well. For regression, the output value + * should not be an integer type, but rather a floating point type. In addition, + * an application deriving this base class for regression should initialize + * the m_RegressionFlag to true in their constructor. + * + * \sa TrainImagesClassifier + * \sa TrainRegression + * + * \ingroup OTBAppClassification + */ +template <class TInputValue, class TOutputValue> +class TrainDimensionalityReductionApplicationBase: public Application +{ +public: + /** Standard class typedefs. */ + typedef TrainDimensionalityReductionApplicationBase Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Standard macro */ + itkTypeMacro(TrainDimensionalityReductionApplicationBase, otb::Application) + + typedef TInputValue InputValueType; + typedef TOutputValue OutputValueType; + + typedef otb::VectorImage<InputValueType> SampleImageType; + typedef typename SampleImageType::PixelType PixelType; + + typedef otb::DimensionalityReductionModelFactory< + InputValueType, OutputValueType> ModelFactoryType; + typedef typename ModelFactoryType::DimensionalityReductionModelTypePointer ModelPointerType; + typedef typename ModelFactoryType::DimensionalityReductionModelType ModelType; + + typedef typename ModelType::InputSampleType SampleType; + typedef typename ModelType::InputListSampleType ListSampleType; + +// Dimensionality reduction models + +//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType; + typedef otb::SOMModel<InputValueType, 2> SOM2DModelType; + +//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType; + typedef otb::SOMModel<InputValueType, 3> SOM3DModelType; + +//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType; + typedef otb::SOMModel<InputValueType, 4> SOM4DModelType; + +//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; + typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; + + +#ifdef OTB_USE_SHARK + +// typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; + typedef shark::LogisticNeuron NeuronType; + typedef otb::AutoencoderModel<InputValueType, NeuronType> AutoencoderModelType; +/* + // typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; + typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron> TiedAutoencoderType; + typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType; + */ + typedef otb::PCAModel<InputValueType> PCAModelType; +#endif + +protected: +TrainDimensionalityReductionApplicationBase(); +~TrainDimensionalityReductionApplicationBase(); + +/** Generic method to train and save the machine learning model. This method + * uses specific train methods depending on the chosen model.*/ +void Train(typename ListSampleType::Pointer trainingListSample, + std::string modelPath); + +/** Generic method to load a model file and use it to classify a sample list*/ +void Reduce(typename ListSampleType::Pointer validationListSample, + std::string modelPath); + +/** Init method that creates all the parameters for machine learning models */ +void DoInit(); + +private: + +/** Specific Init and Train methods for each machine learning model */ +//@{ + +void InitSOMParams(); +template <class somchoice> +void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); +void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + +#ifdef OTB_USE_SHARK + void InitAutoencoderParams(); + void InitPCAParams(); + + void BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + template <class autoencoderchoice> + void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + + void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + + +#endif +//@} +}; + +} +} + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbTrainDimensionalityReductionApplicationBase.txx" +#include "otbDimensionalityReductionTrainSOM.txx" + +#ifdef OTB_USE_SHARK +#include "otbDimensionalityReductionTrainAutoencoder.txx" +#include "otbDimensionalityReductionTrainPCA.txx" +#endif +#endif + +#endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/cbLearningApplicationBaseDR.txx b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx similarity index 77% rename from Modules/Learning/DimensionalityReductionLearning/include/cbLearningApplicationBaseDR.txx rename to Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx index 19b5e4e414..04065aa97c 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/cbLearningApplicationBaseDR.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx @@ -17,7 +17,7 @@ #ifndef cbLearningApplicationBaseDR_txx #define cbLearningApplicationBaseDR_txx -#include "cbLearningApplicationBaseDR.h" +#include "otbTrainDimensionalityReductionApplicationBase.h" namespace otb { @@ -25,21 +25,21 @@ namespace Wrapper { template <class TInputValue, class TOutputValue> -cbLearningApplicationBaseDR<TInputValue,TOutputValue> -::cbLearningApplicationBaseDR() +TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> +::TrainDimensionalityReductionApplicationBase() { } template <class TInputValue, class TOutputValue> -cbLearningApplicationBaseDR<TInputValue,TOutputValue> -::~cbLearningApplicationBaseDR() +TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> +::~TrainDimensionalityReductionApplicationBase() { ModelFactoryType::CleanFactories(); } template <class TInputValue, class TOutputValue> void -cbLearningApplicationBaseDR<TInputValue,TOutputValue> +TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::DoInit() { AddDocTag(Tags::Learning); @@ -60,14 +60,14 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> template <class TInputValue, class TOutputValue> void -cbLearningApplicationBaseDR<TInputValue,TOutputValue> +TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::Reduce(typename ListSampleType::Pointer validationListSample,std::string modelPath) { } template <class TInputValue, class TOutputValue> void -cbLearningApplicationBaseDR<TInputValue,TOutputValue> +TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::Train(typename ListSampleType::Pointer trainingListSample, std::string modelPath) { @@ -84,10 +84,10 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> if(modelName == "autoencoder") { #ifdef OTB_USE_SHARK - BeforeTrainAutoencoder(trainingListSample,modelPath); - #else - otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); - #endif + BeforeTrainAutoencoder(trainingListSample,modelPath); +#else + otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); +#endif } /* if(modelName == "tiedautoencoder") diff --git a/Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.txx index 396a5f0ac9..a4ea0243b9 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.txx @@ -19,11 +19,10 @@ #define SOMFactory_txx -#include "SOMModelFactory.h" +#include "otbSOMModelFactory.h" #include "itkCreateObjectFunction.h" -#include "SOMModel.h" -//#include <shark/Algorithms/Trainers/PCA.h> +#include "otbSOMModel.h" #include "itkVersion.h" namespace otb @@ -39,8 +38,8 @@ SOMModelFactory<TInputValue,TOutputValue,MapDimension>::SOMModelFactory() subclass.c_str(), "SOM DR Model", 1, - // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); - itk::CreateObjectFunction<SOMModel<TInputValue, MapDimension>>::New()); + + itk::CreateObjectFunction<SOMModel<TInputValue, MapDimension>>::New()); } template <class TInputValue, class TOutputValue, unsigned int MapDimension> diff --git a/Modules/Learning/DimensionalityReductionLearning/include/cbLearningApplicationBaseDR.h b/Modules/Learning/DimensionalityReductionLearning/include/cbLearningApplicationBaseDR.h deleted file mode 100644 index 281cc1866b..0000000000 --- a/Modules/Learning/DimensionalityReductionLearning/include/cbLearningApplicationBaseDR.h +++ /dev/null @@ -1,171 +0,0 @@ -#ifndef cbLearningApplicationBaseDR_h -#define cbLearningApplicationBaseDR_h - -#include "otbConfigure.h" - -#include "otbWrapperApplication.h" - -#include <iostream> - -// ListSample -#include "itkListSample.h" -#include "itkVariableLengthVector.h" - -//Estimator -#include "DimensionalityReductionModelFactory.h" - -#include "SOMModel.h" - -#ifdef OTB_USE_SHARK -#include "AutoencoderModel.h" -#include "PCAModel.h" -#endif - -namespace otb -{ -namespace Wrapper -{ - -/** \class LearningApplicationBase - * \brief LearningApplicationBase is the base class for application that - * use machine learning model. - * - * This base class offers a DoInit() method to initialize all the parameters - * related to machine learning models. They will all be in the choice parameter - * named "classifier". The class also offers generic Train() and Classify() - * methods. The classes derived from LearningApplicationBase only need these - * 3 methods to handle the machine learning model. - * - * There are multiple machine learning models in OTB, some imported - * from OpenCV and one imported from LibSVM. They all have - * different parameters. The purpose of this class is to handle the - * creation of all parameters related to machine learning models (in - * DoInit() ), and to dispatch the calls to specific train functions - * in function Train(). - * - * This class is templated over scalar types for input and output values. - * Typically, the input value type will be either float of double. The choice - * of an output value type depends on the learning mode. This base class - * supports both classification and regression modes. For classification - * (enabled by default), the output value type corresponds to a class - * identifier so integer types suit well. For regression, the output value - * should not be an integer type, but rather a floating point type. In addition, - * an application deriving this base class for regression should initialize - * the m_RegressionFlag to true in their constructor. - * - * \sa TrainImagesClassifier - * \sa TrainRegression - * - * \ingroup OTBAppClassification - */ -template <class TInputValue, class TOutputValue> -class cbLearningApplicationBaseDR: public Application -{ -public: - /** Standard class typedefs. */ - typedef cbLearningApplicationBaseDR Self; - typedef Application Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Standard macro */ - itkTypeMacro(cbLearningApplicationBaseDR, otb::Application) - - typedef TInputValue InputValueType; - typedef TOutputValue OutputValueType; - - typedef otb::VectorImage<InputValueType> SampleImageType; - typedef typename SampleImageType::PixelType PixelType; - - typedef otb::DimensionalityReductionModelFactory< - InputValueType, OutputValueType> ModelFactoryType; - typedef typename ModelFactoryType::DimensionalityReductionModelTypePointer ModelPointerType; - typedef typename ModelFactoryType::DimensionalityReductionModelType ModelType; - - typedef typename ModelType::InputSampleType SampleType; - typedef typename ModelType::InputListSampleType ListSampleType; - - // Dimensionality reduction models - - //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType; - typedef otb::SOMModel<InputValueType, 2> SOM2DModelType; - - //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType; - typedef otb::SOMModel<InputValueType, 3> SOM3DModelType; - - //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType; - typedef otb::SOMModel<InputValueType, 4> SOM4DModelType; - - //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; - typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; - - -#ifdef OTB_USE_SHARK - - // typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - typedef shark::LogisticNeuron NeuronType; - typedef otb::AutoencoderModel<InputValueType, NeuronType> AutoencoderModelType; - /* - // typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; - typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron> TiedAutoencoderType; - typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType; - */ - typedef otb::PCAModel<InputValueType> PCAModelType; -#endif - -protected: - cbLearningApplicationBaseDR(); - - ~cbLearningApplicationBaseDR() ITK_OVERRIDE; - - /** Generic method to train and save the machine learning model. This method - * uses specific train methods depending on the chosen model.*/ - void Train(typename ListSampleType::Pointer trainingListSample, - std::string modelPath); - - /** Generic method to load a model file and use it to classify a sample list*/ - void Reduce(typename ListSampleType::Pointer validationListSample, - std::string modelPath); - - /** Init method that creates all the parameters for machine learning models */ - void DoInit(); - -private: - - /** Specific Init and Train methods for each machine learning model */ - //@{ - - void InitSOMParams(); - template <class somchoice> - void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); - void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); - -#ifdef OTB_USE_SHARK - void InitAutoencoderParams(); - void InitPCAParams(); - - void BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); - template <class autoencoderchoice> - void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); - - void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); - - -#endif - //@} -}; - -} -} - -#ifndef OTB_MANUAL_INSTANTIATION -#include "cbLearningApplicationBaseDR.txx" -#include "cbTrainSOM.txx" - -#ifdef OTB_USE_SHARK -#include "cbTrainAutoencoder.txx" -#include "cbTrainPCA.txx" -#endif -#endif - -#endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h similarity index 96% rename from Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModel.h rename to Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h index a8cbe6c0f5..9723a5c27a 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h @@ -16,8 +16,8 @@ class ITK_EXPORT AutoencoderModel: public MachineLearningModel<itk::VariableLen public: - typedef AutoencoderModel Self; - typedef MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> Superclass; + typedef AutoencoderModel Self; + typedef MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -131,7 +131,7 @@ private: #ifndef OTB_MANUAL_INSTANTIATION -#include "AutoencoderModel.txx" +#include "otbAutoencoderModel.txx" #endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx similarity index 96% rename from Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModel.txx rename to Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index 88c77dd5ae..e95748ff3c 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -73,18 +73,18 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() /// Training of the first Autoencoder (first and last layer of the FF network) if (m_Epsilon > 0){ - shark::TrainingProgress<> criterion(5,m_Epsilon); + shark::TrainingProgress<> criterion(5,m_Epsilon); - OutAutoencoderType net; - if (m_Noise[0] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen - { - TrainOneLayer(criterion,net,0 , m_NumberOfHiddenNeurons[0],m_Noise[0],m_Regularization[0], inputSamples,ofs); - } - else - { - TrainOneSparseLayer( criterion, net , 0 , m_NumberOfHiddenNeurons[0],m_Rho[0],m_Beta[0],m_Regularization[0],inputSamples, ofs); - } - criterion.reset(); + OutAutoencoderType net; + if (m_Noise[0] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen + { + TrainOneLayer(criterion,net,0 , m_NumberOfHiddenNeurons[0],m_Noise[0],m_Regularization[0], inputSamples,ofs); + } + else + { + TrainOneSparseLayer( criterion, net , 0 , m_NumberOfHiddenNeurons[0],m_Rho[0],m_Beta[0],m_Regularization[0],inputSamples, ofs); + } + criterion.reset(); } else { diff --git a/Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h similarity index 97% rename from Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModelFactory.h rename to Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h index c9c993b57e..5eb6a501ef 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h @@ -62,7 +62,7 @@ using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTa #ifndef OTB_MANUAL_INSTANTIATION -#include "AutoencoderModelFactory.txx" +#include "otbAutoencoderModelFactory.txx" #endif #endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx similarity index 86% rename from Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModelFactory.txx rename to Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx index 47b4669ab4..73dae93bde 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/AutoencoderModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx @@ -19,10 +19,10 @@ #define AutoencoderModelFactory_txx -#include "AutoencoderModelFactory.h" +#include "otbAutoencoderModelFactory.h" #include "itkCreateObjectFunction.h" -#include "AutoencoderModel.h" +#include "otbAutoencoderModel.h" #include "itkVersion.h" namespace otb @@ -38,8 +38,8 @@ AutoencoderModelFactoryBase<TInputValue,TOutputValue, NeuronType>::AutoencoderMo subclass.c_str(), "Shark AE ML Model", 1, - // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); - itk::CreateObjectFunction<AutoencoderModel<TInputValue,NeuronType > >::New()); + // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); + itk::CreateObjectFunction<AutoencoderModel<TInputValue,NeuronType > >::New()); } template <class TInputValue, class TOutputValue, class NeuronType> diff --git a/Modules/Learning/DimensionalityReductionLearning/include/DimensionalityReductionModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h similarity index 98% rename from Modules/Learning/DimensionalityReductionLearning/include/DimensionalityReductionModelFactory.h rename to Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h index 16fa0f416d..92603c710d 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/DimensionalityReductionModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h @@ -78,7 +78,7 @@ private: } // end namespace otb #ifndef OTB_MANUAL_INSTANTIATION -#include "DimensionalityReductionModelFactory.txx" +#include "otbDimensionalityReductionModelFactory.txx" #endif #endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/DimensionalityReductionModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx similarity index 86% rename from Modules/Learning/DimensionalityReductionLearning/include/DimensionalityReductionModelFactory.txx rename to Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx index 130dd13626..775c0842dc 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/DimensionalityReductionModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx @@ -18,14 +18,14 @@ #ifndef DimensionalityReductionModelFactory_txx #define DimensionalityReductionFactory_txx -#include "DimensionalityReductionModelFactory.h" +#include "otbDimensionalityReductionModelFactory.h" #include "otbConfigure.h" -#include "SOMModelFactory.h" +#include "otbSOMModelFactory.h" #ifdef OTB_USE_SHARK -#include "AutoencoderModelFactory.h" -#include "PCAModelFactory.h" +#include "otbAutoencoderModelFactory.h" +#include "otbPCAModelFactory.h" #endif #include "itkMutexLockHolder.h" @@ -34,16 +34,6 @@ namespace otb { -/* -template <class TInputValue, class TTargetValue> -// using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ; -using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::TanhNeuron>> ; - - -template <class TInputValue, class TTargetValue> -// using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; -using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron>> ; -*/ template <class TInputValue, class TTargetValue> using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::LogisticNeuron> ; @@ -130,7 +120,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> #ifdef OTB_USE_SHARK RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(AutoencoderModelFactory<TInputValue,TOutputValue>::New()); - // RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); + // RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); #endif } @@ -196,8 +186,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> #ifdef OTB_USE_SHARK - // Autoencoder - AutoencoderModelFactory<TInputValue,TOutputValue> *aeFactory = + AutoencoderModelFactory<TInputValue,TOutputValue> *aeFactory = dynamic_cast<AutoencoderModelFactory<TInputValue,TOutputValue> *>(*itFac); if (aeFactory) { diff --git a/Modules/Learning/DimensionalityReductionLearning/include/ImageDimensionalityReductionFilter.h b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h similarity index 98% rename from Modules/Learning/DimensionalityReductionLearning/include/ImageDimensionalityReductionFilter.h rename to Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h index 008c57d2a4..415dda921c 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/ImageDimensionalityReductionFilter.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h @@ -139,7 +139,7 @@ private: }; } // End namespace otb #ifndef OTB_MANUAL_INSTANTIATION -#include "ImageDimensionalityReductionFilter.txx" +#include "otbImageDimensionalityReductionFilter.txx" #endif #endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/ImageDimensionalityReductionFilter.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx similarity index 99% rename from Modules/Learning/DimensionalityReductionLearning/include/ImageDimensionalityReductionFilter.txx rename to Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx index e98a0b79f7..418ecb4fa2 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/ImageDimensionalityReductionFilter.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx @@ -18,7 +18,7 @@ #ifndef otbImageClassificationFilter_txx #define otbImageClassificationFilter_txx -#include "ImageDimensionalityReductionFilter.h" +#include "otbImageDimensionalityReductionFilter.h" #include "itkImageRegionIterator.h" #include "itkProgressReporter.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/PCAModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h similarity index 99% rename from Modules/Learning/DimensionalityReductionLearning/include/PCAModel.h rename to Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h index 82ea0f8443..e39ca88341 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/PCAModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h @@ -75,7 +75,7 @@ private: #ifndef OTB_MANUAL_INSTANTIATION -#include "PCAModel.txx" +#include "otbPCAModel.txx" #endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/PCAModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx similarity index 100% rename from Modules/Learning/DimensionalityReductionLearning/include/PCAModel.txx rename to Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx diff --git a/Modules/Learning/DimensionalityReductionLearning/include/PCAModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h similarity index 97% rename from Modules/Learning/DimensionalityReductionLearning/include/PCAModelFactory.h rename to Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h index 56c0b88c6c..a7a5d10491 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/PCAModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h @@ -51,7 +51,7 @@ private: #ifndef OTB_MANUAL_INSTANTIATION -#include "PCAModelFactory.txx" +#include "otbPCAModelFactory.txx" #endif #endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/PCAModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx similarity index 85% rename from Modules/Learning/DimensionalityReductionLearning/include/PCAModelFactory.txx rename to Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx index bfaa4f6f62..d7a06e94dc 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/PCAModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx @@ -19,11 +19,10 @@ #define PCAFactory_txx -#include "PCAModelFactory.h" +#include "otbPCAModelFactory.h" #include "itkCreateObjectFunction.h" -#include "PCAModel.h" -//#include <shark/Algorithms/Trainers/PCA.h> +#include "otbPCAModel.h" #include "itkVersion.h" namespace otb @@ -39,8 +38,7 @@ PCAModelFactory<TInputValue,TOutputValue>::PCAModelFactory() subclass.c_str(), "Shark PCA ML Model", 1, - // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); - itk::CreateObjectFunction<PCAModel<TInputValue>>::New()); + itk::CreateObjectFunction<PCAModel<TInputValue>>::New()); } template <class TInputValue, class TOutputValue> diff --git a/Modules/Learning/DimensionalityReductionLearning/include/SOMModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h similarity index 99% rename from Modules/Learning/DimensionalityReductionLearning/include/SOMModel.h rename to Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h index c9553cd9c3..06307b0b8d 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/SOMModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h @@ -132,7 +132,7 @@ private: #ifndef OTB_MANUAL_INSTANTIATION -#include "SOMModel.txx" +#include "otbSOMModel.txx" #endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/SOMModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx similarity index 100% rename from Modules/Learning/DimensionalityReductionLearning/include/SOMModel.txx rename to Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx diff --git a/Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h similarity index 100% rename from Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.h rename to Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h -- GitLab From 810c681cc4c354bdf4b68373fd427b5011c10be3 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Fri, 6 Oct 2017 15:48:29 +0200 Subject: [PATCH 082/567] STYLE: rename parameters of the application --- .../app/otbTrainDimensionalityReduction.cxx | 4 +- ...imensionalityReductionTrainAutoencoder.txx | 112 +++++++++--------- .../otbDimensionalityReductionTrainPCA.txx | 12 +- .../otbDimensionalityReductionTrainSOM.txx | 108 ++++++++--------- ...DimensionalityReductionApplicationBase.txx | 10 +- 5 files changed, 123 insertions(+), 123 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx index dea0331cea..91c600722a 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx @@ -59,14 +59,14 @@ private: SetParameterDescription("io.vd", "Input geometries used for training (note : all geometries from the layer will be used)"); AddParameter(ParameterType_OutputFilename, "io.out", "Output model"); - SetParameterDescription("io.out", "Output file containing the model estimated (.txt format)."); + SetParameterDescription("io.out", "Output file containing the estimated model (.txt format)."); AddParameter(ParameterType_InputFilename, "io.stats", "Input XML image statistics file"); MandatoryOff("io.stats"); SetParameterDescription("io.stats", "XML file containing mean and variance of each feature."); - AddParameter(ParameterType_StringList, "feat", "Field names to be calculated."); // + AddParameter(ParameterType_StringList, "feat", "Field names to be used for training."); // SetParameterDescription("feat","List of field names in the input vector data used as features for training."); // Superclass::DoInit(); diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx index dc787d5d15..b12a2517e5 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx @@ -16,87 +16,87 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> { - AddChoice("model.tiedautoencoder", "Shark Tied Autoencoder"); - AddChoice("model.autoencoder", "Shark Autoencoder"); - SetParameterDescription("model.autoencoder", + AddChoice("algorithm.tiedautoencoder", "Shark Tied Autoencoder"); + AddChoice("algorithm.autoencoder", "Shark Autoencoder"); + SetParameterDescription("algorithm.autoencoder", "This group of parameters allows setting Shark autoencoder parameters. " ); //Tied Autoencoder - AddParameter(ParameterType_Choice, "model.autoencoder.istied", + AddParameter(ParameterType_Choice, "algorithm.autoencoder.istied", "tied weighth <tied/untied>"); SetParameterDescription( - "model.autoencoder.istied", + "algorithm.autoencoder.istied", "Parameter that determine if the weights are tied or not <tied/untied>"); - AddChoice("model.autoencoder.istied.yes","Tied weigths"); - AddChoice("model.autoencoder.istied.no","Untied weights"); + AddChoice("algorithm.autoencoder.istied.yes","Tied weigths"); + AddChoice("algorithm.autoencoder.istied.no","Untied weights"); //Number Of Iterations - AddParameter(ParameterType_Int, "model.autoencoder.nbiter", + AddParameter(ParameterType_Int, "algorithm.autoencoder.nbiter", "Maximum number of iterations during training"); - SetParameterInt("model.autoencoder.nbiter",100, false); + SetParameterInt("algorithm.autoencoder.nbiter",100, false); SetParameterDescription( - "model.autoencoder.nbiter", + "algorithm.autoencoder.nbiter", "The maximum number of iterations used during training."); - AddParameter(ParameterType_Int, "model.autoencoder.nbiterfinetuning", + AddParameter(ParameterType_Int, "algorithm.autoencoder.nbiterfinetuning", "Maximum number of iterations during training"); - SetParameterInt("model.autoencoder.nbiterfinetuning",0, false); + SetParameterInt("algorithm.autoencoder.nbiterfinetuning",0, false); SetParameterDescription( - "model.autoencoder.nbiterfinetuning", + "algorithm.autoencoder.nbiterfinetuning", "The maximum number of iterations used during fine tuning of the whole network."); - AddParameter(ParameterType_Float, "model.autoencoder.epsilon", + AddParameter(ParameterType_Float, "algorithm.autoencoder.epsilon", " "); - SetParameterFloat("model.autoencoder.epsilon",0, false); + SetParameterFloat("algorithm.autoencoder.epsilon",0, false); SetParameterDescription( - "model.autoencoder.epsilon", + "algorithm.autoencoder.epsilon", " "); - AddParameter(ParameterType_Float, "model.autoencoder.initfactor", + AddParameter(ParameterType_Float, "algorithm.autoencoder.initfactor", " "); - SetParameterFloat("model.autoencoder.initfactor",1, false); + SetParameterFloat("algorithm.autoencoder.initfactor",1, false); SetParameterDescription( - "model.autoencoder.initfactor", "parameter that control the weight initialization of the autoencoder"); + "algorithm.autoencoder.initfactor", "parameter that control the weight initialization of the autoencoder"); //Number Of Hidden Neurons - AddParameter(ParameterType_StringList , "model.autoencoder.nbneuron", "Size"); - /*AddParameter(ParameterType_Int, "model.autoencoder.nbneuron", + AddParameter(ParameterType_StringList , "algorithm.autoencoder.nbneuron", "Size"); + /*AddParameter(ParameterType_Int, "algorithm.autoencoder.nbneuron", "Number of neurons in the hidden layer"); - SetParameterInt("model.autoencoder.nbneuron",10, false);*/ + SetParameterInt("algorithm.autoencoder.nbneuron",10, false);*/ SetParameterDescription( - "model.autoencoder.nbneuron", + "algorithm.autoencoder.nbneuron", "The number of neurons in each hidden layer."); //Regularization - AddParameter(ParameterType_StringList, "model.autoencoder.regularization", "Strength of the regularization"); - SetParameterDescription("model.autoencoder.regularization", - "Strength of the L2 regularization used during training"); + AddParameter(ParameterType_StringList, "algorithm.autoencoder.regularization", "Strength of the regularization"); + SetParameterDescription("algorithm.autoencoder.regularization", + "Strength of the L2 regularization used during training"); //Noise strength - AddParameter(ParameterType_StringList, "model.autoencoder.noise", "Strength of the noise"); - SetParameterDescription("model.autoencoder.noise", - "Strength of the noise"); + AddParameter(ParameterType_StringList, "algorithm.autoencoder.noise", "Strength of the noise"); + SetParameterDescription("algorithm.autoencoder.noise", + "Strength of the noise"); // Sparsity parameter - AddParameter(ParameterType_StringList, "model.autoencoder.rho", "Sparsity parameter"); - SetParameterDescription("model.autoencoder.rho", - "Sparsity parameter"); + AddParameter(ParameterType_StringList, "algorithm.autoencoder.rho", "Sparsity parameter"); + SetParameterDescription("algorithm.autoencoder.rho", + "Sparsity parameter"); // Sparsity regularization strength - AddParameter(ParameterType_StringList, "model.autoencoder.beta", "Sparsity regularization strength"); - SetParameterDescription("model.autoencoder.beta", - "Sparsity regularization strength"); + AddParameter(ParameterType_StringList, "algorithm.autoencoder.beta", "Sparsity regularization strength"); + SetParameterDescription("algorithm.autoencoder.beta", + "Sparsity regularization strength"); - AddParameter(ParameterType_OutputFilename, "model.autoencoder.learningcurve", "Learning curve"); - SetParameterDescription("model.autoencoder.learningcurve", "Learning error values"); - MandatoryOff("model.autoencoder.learningcurve"); + AddParameter(ParameterType_OutputFilename, "algorithm.autoencoder.learningcurve", "Learning curve"); + SetParameterDescription("algorithm.autoencoder.learningcurve", "Learning error values"); + MandatoryOff("algorithm.autoencoder.learningcurve"); } @@ -107,10 +107,10 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath) { - std::string TiedWeigth = GetParameterString("model.autoencoder.istied"); - std::cout << TiedWeigth << std::endl; + std::string TiedWeigth = GetParameterString("algorithm.autoencoder.istied"); + std::cout << TiedWeigth << std::endl; - if(TiedWeigth == "no") + if(TiedWeigth == "no") { TrainAutoencoder<AutoencoderModelType>(trainingListSample,modelPath); } @@ -138,11 +138,11 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue>::Trai itk::Array<float> regularization; itk::Array<float> rho; itk::Array<float> beta; - std::vector<std::basic_string<char>> s_nbneuron= GetParameterStringList("model.autoencoder.nbneuron"); - std::vector<std::basic_string<char>> s_noise= GetParameterStringList("model.autoencoder.noise"); - std::vector<std::basic_string<char>> s_regularization= GetParameterStringList("model.autoencoder.regularization"); - std::vector<std::basic_string<char>> s_rho= GetParameterStringList("model.autoencoder.rho"); - std::vector<std::basic_string<char>> s_beta= GetParameterStringList("model.autoencoder.beta"); + std::vector<std::basic_string<char>> s_nbneuron= GetParameterStringList("algorithm.autoencoder.nbneuron"); + std::vector<std::basic_string<char>> s_noise= GetParameterStringList("algorithm.autoencoder.noise"); + std::vector<std::basic_string<char>> s_regularization= GetParameterStringList("algorithm.autoencoder.regularization"); + std::vector<std::basic_string<char>> s_rho= GetParameterStringList("algorithm.autoencoder.rho"); + std::vector<std::basic_string<char>> s_beta= GetParameterStringList("algorithm.autoencoder.beta"); nb_neuron.SetSize(s_nbneuron.size()); noise.SetSize(s_nbneuron.size()); regularization.SetSize(s_nbneuron.size()); @@ -156,22 +156,22 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue>::Trai beta[i]=std::stof(s_beta[i]); } dimredTrainer->SetNumberOfHiddenNeurons(nb_neuron); - dimredTrainer->SetNumberOfIterations(GetParameterInt("model.autoencoder.nbiter")); - dimredTrainer->SetNumberOfIterationsFineTuning(GetParameterInt("model.autoencoder.nbiterfinetuning")); - dimredTrainer->SetEpsilon(GetParameterFloat("model.autoencoder.epsilon")); - dimredTrainer->SetInitFactor(GetParameterFloat("model.autoencoder.initfactor")); + dimredTrainer->SetNumberOfIterations(GetParameterInt("algorithm.autoencoder.nbiter")); + dimredTrainer->SetNumberOfIterationsFineTuning(GetParameterInt("algorithm.autoencoder.nbiterfinetuning")); + dimredTrainer->SetEpsilon(GetParameterFloat("algorithm.autoencoder.epsilon")); + dimredTrainer->SetInitFactor(GetParameterFloat("algorithm.autoencoder.initfactor")); dimredTrainer->SetRegularization(regularization); dimredTrainer->SetNoise(noise); dimredTrainer->SetRho(rho); dimredTrainer->SetBeta(beta); dimredTrainer->SetWriteWeights(true); - if (HasValue("model.autoencoder.learningcurve") && IsParameterEnabled("model.autoencoder.learningcurve")) - { - std::cout << "yo" << std::endl; - dimredTrainer->SetWriteLearningCurve(true); - dimredTrainer->SetLearningCurveFileName(GetParameterString("model.autoencoder.learningcurve")); - } + if (HasValue("algorithm.autoencoder.learningcurve") && IsParameterEnabled("algorithm.autoencoder.learningcurve")) + { + std::cout << "yo" << std::endl; + dimredTrainer->SetWriteLearningCurve(true); + dimredTrainer->SetLearningCurveFileName(GetParameterString("algorithm.autoencoder.learningcurve")); + } dimredTrainer->SetInputListSample(trainingListSample); std::cout << "before train" << std::endl; diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx index 003ebb1ccf..66a87aaade 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx @@ -16,18 +16,18 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> { - AddChoice("model.pca", "Shark PCA"); - SetParameterDescription("model.pca", + AddChoice("algorithm.pca", "Shark PCA"); + SetParameterDescription("algorithm.pca", "This group of parameters allows setting Shark PCA parameters. " ); //Output Dimension - AddParameter(ParameterType_Int, "model.pca.dim", + AddParameter(ParameterType_Int, "algorithm.pca.dim", "Dimension of the output of the pca transformation"); - SetParameterInt("model.pca.dim",10, false); + SetParameterInt("algorithm.pca.dim",10, false); SetParameterDescription( - "model.pca.dim", + "algorithm.pca.dim", "Dimension of the output of the pca transformation."); @@ -38,7 +38,7 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::TrainPCA(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { typename PCAModelType::Pointer dimredTrainer = PCAModelType::New(); - dimredTrainer->SetDimension(GetParameterInt("model.pca.dim")); + dimredTrainer->SetDimension(GetParameterInt("algorithm.pca.dim")); dimredTrainer->SetInputListSample(trainingListSample); dimredTrainer->SetWriteEigenvectors(true); dimredTrainer->Train(); diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx index 61975c9708..8a05ecccd7 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx @@ -14,62 +14,62 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::InitSOMParams() { - AddChoice("model.som", "OTB SOM"); - SetParameterDescription("model.som", + AddChoice("algorithm.som", "OTB SOM"); + SetParameterDescription("algorithm.som", "This group of parameters allows setting SOM parameters. " ); - AddParameter(ParameterType_Int, "model.som.dim","Dimension of the map"); - SetParameterDescription("model.som.dim","Dimension of the SOM map."); + AddParameter(ParameterType_Int, "algorithm.som.dim","Dimension of the map"); + SetParameterDescription("algorithm.som.dim","Dimension of the SOM map."); - AddParameter(ParameterType_StringList , "model.som.s", "Size"); - SetParameterDescription("model.som.s", "Size of the SOM map"); - MandatoryOff("model.som.s"); + AddParameter(ParameterType_StringList , "algorithm.som.s", "Size"); + SetParameterDescription("algorithm.som.s", "Size of the SOM map"); + MandatoryOff("algorithm.som.s"); - AddParameter(ParameterType_StringList , "model.som.n", "Size Neighborhood"); - SetParameterDescription("model.som.n", "Size of the initial neighborhood in the SOM map"); - MandatoryOff("model.som.n"); + AddParameter(ParameterType_StringList , "algorithm.som.n", "Size Neighborhood"); + SetParameterDescription("algorithm.som.n", "Size of the initial neighborhood in the SOM map"); + MandatoryOff("algorithm.som.n"); - AddParameter(ParameterType_Int, "model.som.sx", "SizeX"); - SetParameterDescription("model.som.sx", "X size of the SOM map"); - MandatoryOff("model.som.sx"); + AddParameter(ParameterType_Int, "algorithm.som.sx", "SizeX"); + SetParameterDescription("algorithm.som.sx", "X size of the SOM map"); + MandatoryOff("algorithm.som.sx"); - AddParameter(ParameterType_Int, "model.som.sy", "SizeY"); - SetParameterDescription("model.som.sy", "Y size of the SOM map"); - MandatoryOff("model.som.sy"); + AddParameter(ParameterType_Int, "algorithm.som.sy", "SizeY"); + SetParameterDescription("algorithm.som.sy", "Y size of the SOM map"); + MandatoryOff("algorithm.som.sy"); - AddParameter(ParameterType_Int, "model.som.nx", "NeighborhoodX"); - SetParameterDescription("model.som.nx", "X size of the initial neighborhood in the SOM map"); - MandatoryOff("model.som.nx"); + AddParameter(ParameterType_Int, "algorithm.som.nx", "NeighborhoodX"); + SetParameterDescription("algorithm.som.nx", "X size of the initial neighborhood in the SOM map"); + MandatoryOff("algorithm.som.nx"); - AddParameter(ParameterType_Int, "model.som.ny", "NeighborhoodY"); - SetParameterDescription("model.som.ny", "Y size of the initial neighborhood in the SOM map"); - MandatoryOff("model.som.nx"); + AddParameter(ParameterType_Int, "algorithm.som.ny", "NeighborhoodY"); + SetParameterDescription("algorithm.som.ny", "Y size of the initial neighborhood in the SOM map"); + MandatoryOff("algorithm.som.nx"); - AddParameter(ParameterType_Int, "model.som.ni", "NumberIteration"); - SetParameterDescription("model.som.ni", "Number of iterations for SOM learning"); - MandatoryOff("model.som.ni"); + AddParameter(ParameterType_Int, "algorithm.som.ni", "NumberIteration"); + SetParameterDescription("algorithm.som.ni", "Number of iterations for SOM learning"); + MandatoryOff("algorithm.som.ni"); - AddParameter(ParameterType_Float, "model.som.bi", "BetaInit"); - SetParameterDescription("model.som.bi", "Initial learning coefficient"); - MandatoryOff("model.som.bi"); + AddParameter(ParameterType_Float, "algorithm.som.bi", "BetaInit"); + SetParameterDescription("algorithm.som.bi", "Initial learning coefficient"); + MandatoryOff("algorithm.som.bi"); - AddParameter(ParameterType_Float, "model.som.bf", "BetaFinal"); - SetParameterDescription("model.som.bf", "Final learning coefficient"); - MandatoryOff("model.som.bf"); + AddParameter(ParameterType_Float, "algorithm.som.bf", "BetaFinal"); + SetParameterDescription("algorithm.som.bf", "Final learning coefficient"); + MandatoryOff("algorithm.som.bf"); - AddParameter(ParameterType_Float, "model.som.iv", "InitialValue"); - SetParameterDescription("model.som.iv", "Maximum initial neuron weight"); - MandatoryOff("model.som.iv"); + AddParameter(ParameterType_Float, "algorithm.som.iv", "InitialValue"); + SetParameterDescription("algorithm.som.iv", "Maximum initial neuron weight"); + MandatoryOff("algorithm.som.iv"); - SetDefaultParameterInt("model.som.sx", 32); - SetDefaultParameterInt("model.som.sy", 32); - SetDefaultParameterInt("model.som.nx", 10); - SetDefaultParameterInt("model.som.ny", 10); - SetDefaultParameterInt("model.som.ni", 5); - SetDefaultParameterFloat("model.som.bi", 1.0); - SetDefaultParameterFloat("model.som.bf", 0.1); - SetDefaultParameterFloat("model.som.iv", 10.0); + SetDefaultParameterInt("algorithm.som.sx", 32); + SetDefaultParameterInt("algorithm.som.sy", 32); + SetDefaultParameterInt("algorithm.som.nx", 10); + SetDefaultParameterInt("algorithm.som.ny", 10); + SetDefaultParameterInt("algorithm.som.ni", 5); + SetDefaultParameterFloat("algorithm.som.bi", 1.0); + SetDefaultParameterFloat("algorithm.som.bf", 0.1); + SetDefaultParameterFloat("algorithm.som.iv", 10.0); } @@ -80,10 +80,10 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath) { - int SomDim = GetParameterInt("model.som.dim"); - std::cout << SomDim << std::endl; + int SomDim = GetParameterInt("algorithm.som.dim"); + std::cout << SomDim << std::endl; - if(SomDim == 2) + if(SomDim == 2) { TrainSOM<SOM2DModelType >(trainingListSample,modelPath); } @@ -118,23 +118,23 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> typename somchoice::Pointer dimredTrainer = somchoice::New(); unsigned int dim = dimredTrainer->GetDimension(); std::cout << dim << std::endl; - dimredTrainer->SetNumberOfIterations(GetParameterInt("model.som.ni")); - dimredTrainer->SetBetaInit(GetParameterFloat("model.som.bi")); + dimredTrainer->SetNumberOfIterations(GetParameterInt("algorithm.som.ni")); + dimredTrainer->SetBetaInit(GetParameterFloat("algorithm.som.bi")); dimredTrainer->SetWriteMap(true); - dimredTrainer->SetBetaEnd(GetParameterFloat("model.som.bf")); - dimredTrainer->SetMaxWeight(GetParameterFloat("model.som.iv")); + dimredTrainer->SetBetaEnd(GetParameterFloat("algorithm.som.bf")); + dimredTrainer->SetMaxWeight(GetParameterFloat("algorithm.som.iv")); typename TemplateEstimatorType::SizeType size; - std::vector<std::basic_string<char>> s= GetParameterStringList("model.som.s"); + std::vector<std::basic_string<char>> s= GetParameterStringList("algorithm.som.s"); for (int i=0; i<dim; i++){ size[i]=std::stoi(s[i]); } dimredTrainer->SetMapSize(size); typename TemplateEstimatorType::SizeType radius; - std::vector<std::basic_string<char>> n= GetParameterStringList("model.som.n"); - for (int i=0; i<dim; i++){ - radius[i]=std::stoi(n[i]); - } + std::vector<std::basic_string<char>> n= GetParameterStringList("algorithm.som.n"); + for (int i=0; i<dim; i++){ + radius[i]=std::stoi(n[i]); + } dimredTrainer->SetNeighborhoodSizeInit(radius); dimredTrainer->SetListSample(trainingListSample); dimredTrainer->Train(); diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx index 04065aa97c..77a3f477cc 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx @@ -45,8 +45,8 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> AddDocTag(Tags::Learning); // main choice parameter that will contain all dimensionality reduction options - AddParameter(ParameterType_Choice, "model", "model to use for the training"); - SetParameterDescription("model", "Choice of the dimensionality reduction model to use for the training."); + AddParameter(ParameterType_Choice, "algorithm", "algorithm to use for the training"); + SetParameterDescription("algorithm", "Choice of the dimensionality reduction algorithm to use for the training."); InitSOMParams(); @@ -73,10 +73,10 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> { // get the name of the chosen machine learning model - const std::string modelName = GetParameterString("model"); - // call specific train function + const std::string modelName = GetParameterString("algorithm"); + // call specific train function - if(modelName == "som") + if(modelName == "som") { BeforeTrainSOM(trainingListSample,modelPath); } -- GitLab From 88d502fd09b03f96c4192403fcab79982a070729 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 16 Oct 2017 15:50:21 +0200 Subject: [PATCH 083/567] DOC: update documentation for overwrite/update --- .../app/otbVectorDimensionalityReduction.cxx | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx index 43638c4207..0a8f3eac00 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx @@ -95,15 +95,15 @@ class VectorDimensionalityReduction : public Application AddParameter(ParameterType_InputFilename, "model", "Model file"); SetParameterDescription("model", "A model file (produced by the TrainDimensionalityReduction application,"); - AddParameter(ParameterType_ListView, "feat", "Field names to be calculated."); // + AddParameter(ParameterType_ListView, "feat", "Input features to use for reduction."); // SetParameterDescription("feat","List of field names in the input vector data used as features for reduction."); // - AddParameter(ParameterType_StringList, "featout", "Field names to be calculated."); // - SetParameterDescription("featout","List of field names in the input vector data used as features for reduction."); // + AddParameter(ParameterType_StringList, "featout", "Names of the new output features."); // + SetParameterDescription("featout","List of field names for the output features which result from the reduction."); // AddParameter(ParameterType_OutputFilename, "out", "Output vector data file containing the reduced vector"); SetParameterDescription("out","Output vector data file storing sample values (OGR format)." - "If not given, the input vector data file is updated."); + "If not given, the input vector data file is used. In overwrite mode, the original features will be lost."); MandatoryOff("out"); AddParameter(ParameterType_Int, "indim", "Dimension of the input vector"); @@ -117,7 +117,7 @@ class VectorDimensionalityReduction : public Application AddParameter(ParameterType_String, "mode", "Writting mode"); // SetParameterString("mode","overwrite", false); - SetParameterDescription("mode","This parameter determines if the output file is overwritten or updated [overwrite/update]"); // + SetParameterDescription("mode","This parameter determines if the output file is overwritten or updated [overwrite/update]. If an output file name is given, the original file is copied before creating the new features."); // // Doc example parameter settings @@ -270,17 +270,17 @@ class VectorDimensionalityReduction : public Application // Create new OGRDataSource if (GetParameterString("mode")=="overwrite") { - output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite); - otb::ogr::Layer newLayer = output->CreateLayer(GetParameterString("out"), - const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), - layer.GetGeomType()); - // Copy existing fields - OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); - for (int k=0 ; k<inLayerDefn.GetFieldCount()-nbBands ; k++) // we don't copy the original bands - { - OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); - newLayer.CreateField(fieldDefn); - } + output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite); + otb::ogr::Layer newLayer = output->CreateLayer(GetParameterString("out"), + const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), + layer.GetGeomType()); + // Copy existing fields + OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); + for (int k=0 ; k<inLayerDefn.GetFieldCount()-nbBands ; k++) // we don't copy the original bands + { + OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); + newLayer.CreateField(fieldDefn); + } } else if (GetParameterString("mode")=="update") { -- GitLab From e5ad35987f66e3c498feeb43561286e33ee401bf Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 2 Nov 2017 16:34:49 +0100 Subject: [PATCH 084/567] ENH: suppress stdout messages --- .../app/otbVectorDimensionalityReduction.cxx | 4 +--- .../include/otbPCAModel.txx | 10 ++++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx index 0a8f3eac00..16e5dfaf17 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx @@ -253,9 +253,7 @@ class VectorDimensionalityReduction : public Application ListSampleType::Pointer target = m_Model->PredictBatch(listSample); /** Create/Update Output Shape file */ - - std::cout << GetParameterStringList("featout").size() << std::endl; - + ogr::DataSource::Pointer output; ogr::DataSource::Pointer buffer = ogr::DataSource::New(); bool updateMode = false; diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx index 364dd8def3..c5d274b324 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx @@ -93,9 +93,8 @@ void PCAModel<TInputValue>::Save(const std::string & filename, const std::string Shark::ListSampleToSharkVector(this->GetInputListSample(), features); shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); otxt << "Reconstruction error : " << loss.eval(inputSamples,m_decoder(m_encoder(inputSamples))) << std::endl; - std::cout << "Reconstruction error : " << loss.eval(inputSamples,m_decoder(m_encoder(inputSamples))) << std::endl; - otxt.close(); - } +otxt.close(); +} } template <class TInputValue> @@ -175,9 +174,8 @@ void PCAModel<TInputValue> //target.SetElement(a,p[a]); } - //std::cout << p << std::endl; - targets->SetMeasurementVector(id,target); - ++id; +targets->SetMeasurementVector(id,target); +++id; } -- GitLab From 9504936e78fd316803079c2eeee0d7f1474d06b7 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 6 Nov 2017 22:11:38 +0100 Subject: [PATCH 085/567] BUG: typo in include guard --- .../include/otbDimensionalityReductionModelFactory.txx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx index 775c0842dc..d20eb6356f 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx @@ -16,7 +16,7 @@ =========================================================================*/ #ifndef DimensionalityReductionModelFactory_txx -#define DimensionalityReductionFactory_txx +#define DimensionalityReductionModelFactory_txx #include "otbDimensionalityReductionModelFactory.h" #include "otbConfigure.h" -- GitLab From 1503f8d08de206f999a35ea3d52f0d3fb699687b Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 16 Nov 2017 15:25:26 +0100 Subject: [PATCH 086/567] ENH: add complex image support in InputImageParameter WARNING : Some methods of ComplexInputParameter have been changed --- .../include/otbWrapperApplication.h | 11 ++++- .../include/otbWrapperInputImageParameter.h | 36 +++++++++++++++ .../include/otbWrapperInputImageParameter.txx | 16 +++++++ .../ApplicationEngine/src/CMakeLists.txt | 2 + .../otbWrapperInputImageParameterCDouble.cxx | 44 +++++++++++++++++++ .../otbWrapperInputImageParameterCFloat.cxx | 43 ++++++++++++++++++ 6 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index cec459dc96..fb5a84f2ab 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -619,12 +619,19 @@ public: otbGetParameterImageMacro(UInt8RGBImage); otbGetParameterImageMacro(UInt8RGBAImage); + // Complex image + otbGetParameterImageMacro(ComplexFloatImage); + otbGetParameterImageMacro(ComplexDoubleImage); + + otbGetParameterImageMacro(ComplexFloatVectorImage); + otbGetParameterImageMacro(ComplexDoubleVectorImage); + /* Get a complex image value * * Can be called for types : * \li ParameterType_ComplexInputImage */ - +/* #define otbGetParameterComplexImageMacro( Image ) \ Image##Type * GetParameter##Image( std::string parameter ) \ { \ @@ -642,7 +649,7 @@ public: otbGetParameterComplexImageMacro(ComplexDoubleImage); otbGetParameterComplexImageMacro(ComplexFloatVectorImage); - otbGetParameterComplexImageMacro(ComplexDoubleVectorImage); + otbGetParameterComplexImageMacro(ComplexDoubleVectorImage);*/ /* Get an image list value * diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h index 6ff36eedee..99352d4292 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h @@ -80,6 +80,12 @@ public: UInt8RGBImageType* GetUInt8RGBImage(); UInt8RGBAImageType* GetUInt8RGBAImage(); + // Complex image + ComplexFloatImageType* GetComplexFloatImage(); + ComplexDoubleImageType* GetComplexDoubleImage(); + + ComplexFloatVectorImageType* GetComplexFloatVectorImage(); + ComplexDoubleVectorImageType* GetComplexDoubleVectorImage(); /** Get the input image as templated image type. */ template <class TImageType> @@ -145,6 +151,13 @@ protected: typedef otb::ImageFileReader<UInt8RGBImageType> UInt8RGBReaderType; typedef otb::ImageFileReader<UInt8RGBAImageType> UInt8RGBAReaderType; + // Complex + typedef otb::ImageFileReader<ComplexFloatImageType> ComplexFloatReaderType; + typedef otb::ImageFileReader<ComplexDoubleImageType> ComplexDoubleReaderType; + + typedef otb::ImageFileReader<ComplexFloatVectorImageType> ComplexFloatVectorReaderType; + typedef otb::ImageFileReader<ComplexDoubleVectorImageType> ComplexDoubleVectorReaderType; + itk::ProcessObject::Pointer m_Reader; itk::ProcessObject::Pointer m_Caster; @@ -189,6 +202,11 @@ otbGenericDeclareCastImageMacro(UInt32ImageType, ) otbGenericDeclareCastImageMacro(FloatImageType, ) otbGenericDeclareCastImageMacro(DoubleImageType, ) +otbDeclareCastImageMacro( ComplexDoubleImageType , ComplexDoubleImageType ) +otbDeclareCastImageMacro( ComplexDoubleImageType , ComplexFloatImageType ) + +otbDeclareCastImageMacro( ComplexFloatImageType , ComplexDoubleImageType ) +otbDeclareCastImageMacro( ComplexFloatImageType , ComplexFloatImageType ) /********************************************************************* ********************** VectorImage -> VectorImage @@ -201,6 +219,15 @@ otbGenericDeclareCastImageMacro(UInt32VectorImageType, Vector) otbGenericDeclareCastImageMacro(FloatVectorImageType, Vector) otbGenericDeclareCastImageMacro(DoubleVectorImageType, Vector) +otbDeclareCastImageMacro( ComplexDoubleVectorImageType , + ComplexDoubleVectorImageType ) +otbDeclareCastImageMacro( ComplexDoubleVectorImageType , + ComplexFloatVectorImageType ) + +otbDeclareCastImageMacro( ComplexFloatVectorImageType , + ComplexDoubleVectorImageType ) +otbDeclareCastImageMacro( ComplexFloatVectorImageType , + ComplexFloatVectorImageType ) /********************************************************************* ********************** Image -> VectorImage @@ -213,6 +240,15 @@ otbGenericDeclareCastImageMacro(UInt32ImageType, Vector) otbGenericDeclareCastImageMacro(FloatImageType, Vector) otbGenericDeclareCastImageMacro(DoubleImageType, Vector) +otbDeclareCastImageMacro( ComplexDoubleImageType , + ComplexDoubleVectorImageType ) +otbDeclareCastImageMacro( ComplexDoubleImageType , + ComplexFloatVectorImageType ) + +otbDeclareCastImageMacro( ComplexFloatImageType , ComplexDoubleVectorImageType ) +otbDeclareCastImageMacro( ComplexFloatImageType , ComplexFloatVectorImageType ) + + #undef otbDeclareCastImageMacro #undef otbGenericDeclareCastImageMacro diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx index 9db0e61408..3db013c1fb 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx @@ -174,6 +174,22 @@ InputImageParameter::GetImage() { return CastImage<UInt8RGBImageType, TImageType> (); } + else if (dynamic_cast<ComplexFloatVectorImageType*>(m_Image.GetPointer())) + { + return CastImage<ComplexFloatVectorImageType, TImageType>(); + } + else if (dynamic_cast<ComplexDoubleVectorImageType*>(m_Image.GetPointer())) + { + return CastImage<ComplexDoubleVectorImageType, TImageType>(); + } + else if (dynamic_cast<ComplexFloatImageType*>(m_Image.GetPointer())) + { + return CastImage<ComplexFloatImageType, TImageType>(); + } + else if (dynamic_cast<ComplexDoubleImageType*>(m_Image.GetPointer())) + { + return CastImage<ComplexDoubleImageType, TImageType>(); + } else { #if INPUT_IMAGE_PARAMETER_GET_IMAGE_EXCEPTION diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 343f9db835..cd0be0bd4b 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -38,6 +38,8 @@ set( OTBApplicationEngine_SRC otbWrapperInputImageParameterUInt32.cxx otbWrapperInputImageParameterFloat.cxx otbWrapperInputImageParameterDouble.cxx + otbWrapperInputImageParameterCFloat.cxx + otbWrapperInputImageParameterCDouble.cxx otbWrapperParameterKey.cxx otbWrapperDocExampleStructure.cxx otbWrapperInputVectorDataParameter.cxx diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx new file mode 100644 index 0000000000..6dbcc03406 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageMacro(ComplexDoubleImage) +otbGetImageMacro(ComplexDoubleVectorImage) +// otbGenericCastImageMacro(ComplexDoubleImage, SimpleCastImage, ) +otbCastImageMacro(ComplexDoubleImageType , ComplexDoubleImageType , SimpleCastImage) +otbCastImageMacro(ComplexDoubleImageType , ComplexFloatImageType , SimpleCastImage) +// otbGenericCastImageMacro(ComplexVectorDoubleImage, SimpleCastImage, Vector) +otbCastImageMacro(ComplexDoubleVectorImageType , ComplexDoubleVectorImageType , SimpleCastImage) +otbCastImageMacro(ComplexDoubleVectorImageType , ComplexFloatVectorImageType , SimpleCastImage) +// otbGenericCastImageMacro(ComplexDoubleImage, CastVectorImageFromImage, Vector) +otbCastImageMacro(ComplexDoubleImageType , ComplexDoubleVectorImageType , CastVectorImageFromImage) +otbCastImageMacro(ComplexDoubleImageType , ComplexFloatVectorImageType , CastVectorImageFromImage) + +} +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx new file mode 100644 index 0000000000..c961fbd252 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageMacro(ComplexFloatImage) +otbGetImageMacro(ComplexFloatVectorImage) +// otbGenericCastImageMacro(ComplexFloatImage, SimpleCastImage, ) +otbCastImageMacro(ComplexFloatImageType , ComplexDoubleImageType , SimpleCastImage) +otbCastImageMacro(ComplexFloatImageType , ComplexFloatImageType , SimpleCastImage) +// otbGenericCastImageMacro(ComplexVectorFloatImage, SimpleCastImage, Vector) +otbCastImageMacro(ComplexFloatVectorImageType , ComplexDoubleVectorImageType , SimpleCastImage) +otbCastImageMacro(ComplexFloatVectorImageType , ComplexFloatVectorImageType , SimpleCastImage) +// otbGenericCastImageMacro(ComplexFloatImage, CastVectorImageFromImage, Vector) +otbCastImageMacro(ComplexFloatImageType , ComplexDoubleVectorImageType , CastVectorImageFromImage) +otbCastImageMacro(ComplexFloatImageType , ComplexFloatVectorImageType , CastVectorImageFromImage) +} +} -- GitLab From b531882002904341d2fa77461e163846276b7c1c Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 16 Nov 2017 15:26:07 +0100 Subject: [PATCH 087/567] ENH: add support for ComplexInputImageParameter --- .../include/otbWrapperApplication.h | 9 ++++-- .../otbWrapperComplexInputImageParameter.h | 21 ++++++++++++++ .../otbWrapperComplexInputImageParameter.cxx | 29 +++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index fb5a84f2ab..57452dbb4a 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -592,11 +592,16 @@ public: { \ Image##Type::Pointer ret; \ Parameter* param = GetParameterByKey(parameter); \ - if (dynamic_cast<InputImageParameter*>(param)) \ + InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param); \ + ComplexInputImageParameter* paramDownC = dynamic_cast<ComplexInputImageParameter*>(param); \ + if ( paramDown ) \ { \ - InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param); \ ret = paramDown->Get##Image(); \ } \ + else if ( paramDownC ) /* Support of ComplexInputImageParameter */ \ + { \ + ret = paramDownC->Get##Image(); \ + } \ return ret; \ } diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h index 1fa00dd77d..938736eb14 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h @@ -66,6 +66,27 @@ public: ComplexFloatVectorImageType* GetComplexFloatVectorImage(); ComplexDoubleVectorImageType* GetComplexDoubleVectorImage(); +/* Support for ComplexInputImageParameter. This has been done to support +the macro otbGetParameterImageMacro of otbWrapperApplication.h */ + UInt8ImageType* GetUInt8Image(); + UInt16ImageType* GetUInt16Image(); + Int16ImageType* GetInt16Image(); + UInt32ImageType* GetUInt32Image(); + Int32ImageType* GetInt32Image(); + FloatImageType* GetFloatImage(); + DoubleImageType* GetDoubleImage(); + + UInt8VectorImageType* GetUInt8VectorImage(); + UInt16VectorImageType* GetUInt16VectorImage(); + Int16VectorImageType* GetInt16VectorImage(); + UInt32VectorImageType* GetUInt32VectorImage(); + Int32VectorImageType* GetInt32VectorImage(); + FloatVectorImageType* GetFloatVectorImage(); + DoubleVectorImageType* GetDoubleVectorImage(); + + UInt8RGBImageType* GetUInt8RGBImage(); + UInt8RGBAImageType* GetUInt8RGBAImage(); + /** Get the input image as templated image type. */ template <class TImageType> TImageType* GetImage(); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx index 6c59ad4c83..0eda88fb9d 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx @@ -133,6 +133,35 @@ ComplexInputImageParameter::ClearValue() m_UseFilename = true; } +/* Support for ComplexInputImageParameter. This has been done to support +the macro otbGetParameterImageMacro of otbWrapperApplication.h */ +#define otbGetFalseImageMacro(image) \ + image##Type * \ + ComplexInputImageParameter::Get##image () \ + { \ + return nullptr; \ + } + +otbGetFalseImageMacro(DoubleImage); +otbGetFalseImageMacro(DoubleVectorImage); + +otbGetFalseImageMacro(FloatImage); +otbGetFalseImageMacro(FloatVectorImage); + +otbGetFalseImageMacro(Int16Image); +otbGetFalseImageMacro(Int16VectorImage); + +otbGetFalseImageMacro(UInt16Image); +otbGetFalseImageMacro(UInt16VectorImage); + +otbGetFalseImageMacro(Int32Image); +otbGetFalseImageMacro(Int32VectorImage); + +otbGetFalseImageMacro(UInt32Image); +otbGetFalseImageMacro(UInt32VectorImage); + +otbGetFalseImageMacro(UInt8Image); +otbGetFalseImageMacro(UInt8VectorImage); } } -- GitLab From 287a1ff4a92d1df2bdf490ed25285f8fd12466ac Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 17 Nov 2017 15:23:03 +0100 Subject: [PATCH 088/567] ENH: add Complex Image support in input image parameter --- .../include/otbWrapperOutputImageParameter.h | 20 +++ .../include/otbWrapperTypes.h | 2 + .../src/otbWrapperOutputImageParameter.cxx | 170 ++++++++++++++++-- 3 files changed, 181 insertions(+), 11 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index b420299ff6..7bcb5fdb33 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -122,9 +122,15 @@ protected: template <class TInputImageType> void SwitchImageWrite(); + template <class TInputImageType> + void SwitchCImageWrite(); + template <class TInputVectorImageType> void SwitchVectorImageWrite(); + template <class TInputVectorImageType> + void SwitchVectorCImageWrite(); + template <class TInputVectorImageType> void SwitchRGBImageWrite(); @@ -156,6 +162,14 @@ protected: typedef otb::ImageFileWriter<UInt8RGBAImageType> RGBAUInt8WriterType; typedef otb::ImageFileWriter<UInt8RGBImageType> RGBUInt8WriterType; + // Complex Image + typedef otb::ImageFileWriter<ComplexFloatImageType> ComplexFloatWriterType; + typedef otb::ImageFileWriter<ComplexDoubleImageType> ComplexDoubleWriterType; + + typedef otb::ImageFileWriter<ComplexFloatVectorImageType> ComplexVectorFloatWriterType; + typedef otb::ImageFileWriter<ComplexDoubleVectorImageType> ComplexVectorDoubleWriterType; + + UInt8WriterType::Pointer m_UInt8Writer; Int16WriterType::Pointer m_Int16Writer; UInt16WriterType::Pointer m_UInt16Writer; @@ -175,6 +189,12 @@ protected: RGBUInt8WriterType::Pointer m_RGBUInt8Writer; RGBAUInt8WriterType::Pointer m_RGBAUInt8Writer; + ComplexFloatWriterType::Pointer m_ComplexFloatWriter; + ComplexDoubleWriterType::Pointer m_ComplexDoubleWriter; + + ComplexVectorFloatWriterType::Pointer m_ComplexVectorFloatWriter; + ComplexVectorDoubleWriterType::Pointer m_ComplexVectorDoubleWriter; + private: OutputImageParameter(const Parameter &); //purposely not implemented void operator =(const Parameter&); //purposely not implemented diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h index 63dafb639b..f78fb1f7e0 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h @@ -77,6 +77,8 @@ typedef enum ImagePixelType_uint32, ImagePixelType_float, ImagePixelType_double, + ImagePixelType_cfloat, + ImagePixelType_cdouble, } ImagePixelType; typedef enum diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 2790bdce25..2b22c08dfb 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -20,6 +20,7 @@ #include "otbWrapperOutputImageParameter.h" #include "otbClampImageFilter.h" +#include "itkCastImageFilter.h" #include "otbClampVectorImageFilter.h" #include "otbImageIOFactory.h" #include "itksys/SystemTools.hxx" @@ -94,6 +95,16 @@ std::string OutputImageParameter::ConvertPixelTypeToString(ImagePixelType type) ret = "double"; break; } + case ImagePixelType_cfloat: + { + ret = "cfloat"; + break; + } + case ImagePixelType_cdouble: + { + ret = "cdouble"; + break; + } } return ret; } @@ -115,6 +126,10 @@ OutputImageParameter::ConvertStringToPixelType(const std::string &value, ImagePi type = ImagePixelType_float; else if (value == "double") type = ImagePixelType_double; + else if (value == "cfloat") + type = ImagePixelType_cfloat; + else if (value == "cdouble") + type = ImagePixelType_cdouble; else return false; return true; @@ -140,13 +155,23 @@ void OutputImageParameter::InitializeWriters() m_RGBUInt8Writer = RGBUInt8WriterType::New(); m_RGBAUInt8Writer = RGBAUInt8WriterType::New(); + + m_ComplexFloatWriter = ComplexFloatWriterType::New(); + m_ComplexDoubleWriter = ComplexDoubleWriterType::New(); + + m_ComplexVectorFloatWriter = ComplexVectorFloatWriterType::New(); + m_ComplexVectorDoubleWriter = ComplexVectorDoubleWriterType::New(); } -template <typename TInput, typename TOutput> void ClampAndWriteImage(itk::ImageBase<2> * in, otb::ImageFileWriter<TOutput> * writer, const std::string & filename, const unsigned int & ramValue) +template <typename TInput, typename TOutput> +void +ClampAndWriteImage( itk::ImageBase<2> * in , + otb::ImageFileWriter<TOutput> * writer , + const std::string & filename , + const unsigned int & ramValue , + typename itk::ImageToImageFilter< TInput , TOutput > * clampFilter ) { - typedef otb::ClampImageFilter<TInput, TOutput> ClampFilterType; - typename ClampFilterType::Pointer clampFilter = ClampFilterType::New(); clampFilter->SetInput( dynamic_cast<TInput*>(in)); bool useStandardWriter = true; @@ -264,39 +289,98 @@ OutputImageParameter::SwitchImageWrite() { case ImagePixelType_uint8: { - ClampAndWriteImage<TInputImageType,UInt8ImageType>(m_Image,m_UInt8Writer,m_FileName,m_RAMValue); + ClampAndWriteImage< TInputImageType , UInt8ImageType >( m_Image , + m_UInt8Writer , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInputImageType , UInt8ImageType >::New() ); break; } case ImagePixelType_int16: { - ClampAndWriteImage<TInputImageType,Int16ImageType>(m_Image,m_Int16Writer,m_FileName,m_RAMValue); + ClampAndWriteImage< TInputImageType , Int16ImageType >( m_Image , + m_Int16Writer , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInputImageType , Int16ImageType >::New() ); break; } case ImagePixelType_uint16: { - ClampAndWriteImage<TInputImageType,UInt16ImageType>(m_Image,m_UInt16Writer,m_FileName,m_RAMValue); + ClampAndWriteImage< TInputImageType , UInt16ImageType >( m_Image , + m_UInt16Writer , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInputImageType , UInt16ImageType >::New() ); break; } case ImagePixelType_int32: { - ClampAndWriteImage<TInputImageType,Int32ImageType>(m_Image,m_Int32Writer,m_FileName,m_RAMValue); + ClampAndWriteImage< TInputImageType , Int32ImageType >( m_Image , + m_Int32Writer , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInputImageType , Int32ImageType >::New() ); break; } case ImagePixelType_uint32: { - ClampAndWriteImage<TInputImageType,UInt32ImageType>(m_Image,m_UInt32Writer,m_FileName,m_RAMValue); + ClampAndWriteImage< TInputImageType , UInt32ImageType >( m_Image , + m_UInt32Writer , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInputImageType , UInt32ImageType >::New() ); break; } case ImagePixelType_float: { - ClampAndWriteImage<TInputImageType,FloatImageType>(m_Image,m_FloatWriter,m_FileName,m_RAMValue); + ClampAndWriteImage< TInputImageType , FloatImageType >( m_Image , + m_FloatWriter , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInputImageType , FloatImageType >::New() ); break; } case ImagePixelType_double: { - ClampAndWriteImage<TInputImageType,DoubleImageType>(m_Image,m_DoubleWriter,m_FileName,m_RAMValue); + ClampAndWriteImage< TInputImageType , DoubleImageType >( m_Image , + m_DoubleWriter , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInputImageType , DoubleImageType >::New() ); + break; + } + default: + break; + } +} + +template <class TInputImageType> +void +OutputImageParameter::SwitchCImageWrite() +{ + switch(m_PixelType ) + { + case ImagePixelType_cfloat: + { + ClampAndWriteImage< TInputImageType , ComplexFloatImageType >( m_Image , + m_ComplexFloatWriter , + m_FileName , + m_RAMValue , + itk::CastImageFilter< TInputImageType , ComplexFloatImageType >::New() ); break; } + case ImagePixelType_cdouble: + { + ClampAndWriteImage< TInputImageType , ComplexDoubleImageType >( m_Image , + m_ComplexDoubleWriter , + m_FileName , + m_RAMValue , + itk::CastImageFilter< TInputImageType , ComplexDoubleImageType >::New() ); + break; + } + default: + break; } } @@ -342,9 +426,39 @@ OutputImageParameter::SwitchVectorImageWrite() ClampAndWriteVectorImage<TInputVectorImageType,DoubleVectorImageType>(m_Image,m_VectorDoubleWriter,m_FileName,m_RAMValue); break; } + default: + break; } } +template <class TInputVectorImageType> +void +OutputImageParameter::SwitchVectorCImageWrite() +{ + switch(m_PixelType ) + { + case ImagePixelType_cfloat: + { + ClampAndWriteImage< TInputVectorImageType , ComplexFloatVectorImageType >( m_Image , + m_ComplexVectorFloatWriter , + m_FileName , + m_RAMValue , + itk::CastImageFilter< TInputVectorImageType , ComplexFloatVectorImageType >::New() ); + break; + } + case ImagePixelType_cdouble: + { + ClampAndWriteImage< TInputVectorImageType , ComplexDoubleVectorImageType >( m_Image , + m_ComplexVectorDoubleWriter , + m_FileName , + m_RAMValue , + itk::CastImageFilter< TInputVectorImageType , ComplexDoubleVectorImageType >::New() ); + break; + } + default: + break; + } +} template <class TInputRGBAImageType> void @@ -409,6 +523,14 @@ OutputImageParameter::Write() { SwitchImageWrite<DoubleImageType>(); } + else if (dynamic_cast<ComplexFloatImageType*>(m_Image.GetPointer()) ) + { + SwitchCImageWrite<ComplexFloatImageType>(); + } + else if (dynamic_cast<ComplexDoubleImageType*>(m_Image.GetPointer()) ) + { + SwitchCImageWrite<ComplexDoubleImageType>(); + } else if (dynamic_cast<UInt8VectorImageType*>(m_Image.GetPointer())) { SwitchVectorImageWrite<UInt8VectorImageType>(); @@ -445,6 +567,14 @@ OutputImageParameter::Write() { SwitchRGBAImageWrite<UInt8RGBAImageType>(); } + else if (dynamic_cast<ComplexFloatVectorImageType*>(m_Image.GetPointer())) + { + SwitchVectorCImageWrite<ComplexFloatVectorImageType>(); + } + else if (dynamic_cast<ComplexDoubleVectorImageType*>(m_Image.GetPointer())) + { + SwitchVectorCImageWrite<ComplexDoubleVectorImageType>(); + } else { itkExceptionMacro("Unknown image type"); @@ -467,7 +597,9 @@ OutputImageParameter::GetWriter() || dynamic_cast<Int32VectorImageType*> (m_Image.GetPointer()) || dynamic_cast<UInt32VectorImageType*> (m_Image.GetPointer()) || dynamic_cast<FloatVectorImageType*> (m_Image.GetPointer()) - || dynamic_cast<DoubleVectorImageType*> (m_Image.GetPointer())) + || dynamic_cast<DoubleVectorImageType*> (m_Image.GetPointer()) + || dynamic_cast<ComplexFloatVectorImageType*> (m_Image.GetPointer()) + || dynamic_cast<ComplexDoubleVectorImageType*> (m_Image.GetPointer())) { type = 1; } @@ -555,6 +687,22 @@ OutputImageParameter::GetWriter() if (type == 0) writer = m_DoubleWriter; break; } + case ImagePixelType_cfloat: + { + if( type == 1 ) + writer = m_ComplexVectorFloatWriter; + else + writer = m_ComplexFloatWriter; + break; + } + case ImagePixelType_cdouble: + { + if( type == 1 ) + writer = m_ComplexVectorDoubleWriter; + else + writer = m_ComplexDoubleWriter; + break; + } } if (ITK_NULLPTR == writer) { -- GitLab From 5cbece72892c8f7221ddc0921d77a94607e5612c Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 17 Nov 2017 15:58:47 +0100 Subject: [PATCH 089/567] REFAC: changing ComplexImage parameter to Image parameter --- .../app/otbDomainTransform.cxx | 6 ++-- .../app/otbSARCalibration.cxx | 2 +- .../app/otbSARDecompositions.cxx | 18 +++++------ .../app/otbSARPolarMatrixConvert.cxx | 32 +++++++++---------- .../AppSARPolarSynth/app/otbSARPolarSynth.cxx | 2 +- .../app/otbComputeModulusAndPhase.cxx | 4 +-- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx index 54dbe894f6..531c0f656a 100644 --- a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx +++ b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx @@ -264,7 +264,7 @@ private: { // fft ttransform bool shift = IsParameterEnabled( "mode.fft.shift"); - typedef otb::Image< std::complex<OutputPixelType> > ComplexOutputImageType; + typedef otb::Image< std::complex<OutputPixelType> > OutputImageType; if (dir == 0 ) { @@ -277,7 +277,7 @@ private: //typedef itk::::ForwardFFTImageFilter over otbImage< InputPixelType > - typedef itk::ForwardFFTImageFilter < TInputImage, ComplexOutputImageType > FFTFilter; + typedef itk::ForwardFFTImageFilter < TInputImage, OutputImageType > FFTFilter; FFTFilter::Pointer fwdFilter = FFTFilter::New(); fwdFilter->SetInput( inImage ); @@ -286,7 +286,7 @@ private: typedef otb::VectorImage<OutputPixelType> TOutputImage; typedef otb::ComplexToVectorImageCastFilter< - ComplexOutputImageType, + OutputImageType, TOutputImage > ComplexToVectorImageCastFilter; ComplexToVectorImageCastFilter::Pointer unaryFunctorImageFilter = ComplexToVectorImageCastFilter::New(); diff --git a/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx b/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx index 4a91dda2f5..7516787741 100644 --- a/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx +++ b/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx @@ -60,7 +60,7 @@ private: AddDocTag(Tags::Calibration); AddDocTag(Tags::SAR); - AddParameter(ParameterType_ComplexInputImage, "in", "Input Image"); + AddParameter(ParameterType_InputImage, "in", "Input Image"); SetParameterDescription("in", "Input complex image"); AddParameter(ParameterType_OutputImage, "out", "Output Image"); diff --git a/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx index 155795417f..be25e1d35c 100644 --- a/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx +++ b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx @@ -109,21 +109,21 @@ private: AddDocTag(Tags::SAR); - AddParameter(ParameterType_ComplexInputImage, "inhh", "Input Image"); + AddParameter(ParameterType_InputImage, "inhh", "Input Image"); SetParameterDescription("inhh", "Input image (HH)"); - AddParameter(ParameterType_ComplexInputImage, "inhv", "Input Image"); + AddParameter(ParameterType_InputImage, "inhv", "Input Image"); SetParameterDescription("inhv", "Input image (HV)"); MandatoryOff("inhv"); - AddParameter(ParameterType_ComplexInputImage, "invh", "Input Image"); + AddParameter(ParameterType_InputImage, "invh", "Input Image"); SetParameterDescription("invh", "Input image (VH)"); MandatoryOff("invh"); - AddParameter(ParameterType_ComplexInputImage, "invv", "Input Image"); + AddParameter(ParameterType_InputImage, "invv", "Input Image"); SetParameterDescription("invv", "Input image (VV)"); - AddParameter(ParameterType_ComplexOutputImage, "out", "Output Image"); + AddParameter(ParameterType_OutputImage, "out", "Output Image"); SetParameterDescription("out", "Output image"); AddParameter(ParameterType_Choice, "decomp", "Decompositions"); @@ -201,7 +201,7 @@ private: m_MeanFilter->SetInput(m_SRFilter->GetOutput()); m_HAFilter->SetInput(m_MeanFilter->GetOutput()); - SetParameterComplexOutputImage("out", m_HAFilter->GetOutput() ); + SetParameterOutputImage("out", m_HAFilter->GetOutput() ); break; @@ -220,7 +220,7 @@ private: m_MeanFilter->SetInput(m_SRFilter->GetOutput()); m_BarnesFilter->SetInput(m_MeanFilter->GetOutput()); - SetParameterComplexOutputImage("out", m_BarnesFilter->GetOutput() ); + SetParameterOutputImage("out", m_BarnesFilter->GetOutput() ); break; @@ -239,7 +239,7 @@ private: m_MeanFilter->SetInput(m_SRFilter->GetOutput()); m_HuynenFilter->SetInput(m_MeanFilter->GetOutput()); - SetParameterComplexOutputImage("out", m_HuynenFilter->GetOutput() ); + SetParameterOutputImage("out", m_HuynenFilter->GetOutput() ); break; @@ -257,7 +257,7 @@ private: m_Concatener->SetInput( m_ImageList ); m_PauliFilter->SetInput(m_Concatener->GetOutput()); - SetParameterComplexOutputImage("out", m_PauliFilter->GetOutput() ); + SetParameterOutputImage("out", m_PauliFilter->GetOutput() ); break; } diff --git a/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx b/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx index 9c8c062112..657643541d 100644 --- a/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx +++ b/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx @@ -232,7 +232,7 @@ private: AddDocTag(Tags::SAR); - AddParameter(ParameterType_ComplexInputImage, "inc", "Input : multi-band complex image"); + AddParameter(ParameterType_InputImage, "inc", "Input : multi-band complex image"); SetParameterDescription("inc", "Input : multi-band complex image"); MandatoryOff("inc"); @@ -241,23 +241,23 @@ private: MandatoryOff("inf"); - AddParameter(ParameterType_ComplexInputImage, "inhh", "Input : one-band complex image (HH)"); + AddParameter(ParameterType_InputImage, "inhh", "Input : one-band complex image (HH)"); SetParameterDescription("inhh", "Input : one-band complex image (HH)"); MandatoryOff("inhh"); - AddParameter(ParameterType_ComplexInputImage, "inhv", "Input : one-band complex image (HV)"); + AddParameter(ParameterType_InputImage, "inhv", "Input : one-band complex image (HV)"); SetParameterDescription("inhv", "Input : one-band complex image (HV)"); MandatoryOff("inhv"); - AddParameter(ParameterType_ComplexInputImage, "invh", "Input : one-band complex image (VH)"); + AddParameter(ParameterType_InputImage, "invh", "Input : one-band complex image (VH)"); SetParameterDescription("invh", "Input : one-band complex image (VH)"); MandatoryOff("invh"); - AddParameter(ParameterType_ComplexInputImage, "invv", "Input : one-band complex image (VV)"); + AddParameter(ParameterType_InputImage, "invv", "Input : one-band complex image (VV)"); SetParameterDescription("invv", "Input : one-band complex image (VV)"); MandatoryOff("invv"); - AddParameter(ParameterType_ComplexOutputImage, "outc", "Output Complex Image"); + AddParameter(ParameterType_OutputImage, "outc", "Output Complex Image"); SetParameterDescription("outc", "Output Complex image."); MandatoryOff("outc"); @@ -509,7 +509,7 @@ private: m_RCohSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); m_RCohSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); - SetParameterComplexOutputImage("outc", m_RCohSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels + SetParameterOutputImage("outc", m_RCohSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels break; @@ -526,7 +526,7 @@ private: m_RCovSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); m_RCovSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); - SetParameterComplexOutputImage("outc", m_RCovSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels + SetParameterOutputImage("outc", m_RCovSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels break; @@ -544,7 +544,7 @@ private: m_RCCSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); m_RCCSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); - SetParameterComplexOutputImage("outc", m_RCCSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels + SetParameterOutputImage("outc", m_RCCSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels break; @@ -565,7 +565,7 @@ private: m_RCCDFilter = RCCDFilterType::New(); m_RCCDFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); - SetParameterComplexOutputImage("outc", m_RCCDFilter->GetOutput() ); // input : 6 complex channels | 3 complex channels + SetParameterOutputImage("outc", m_RCCDFilter->GetOutput() ); // input : 6 complex channels | 3 complex channels break; @@ -575,7 +575,7 @@ private: m_RCRCFilter = RCRCFilterType::New(); m_RCRCFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); - SetParameterComplexOutputImage("outc", m_RCRCFilter->GetOutput() ); // input : 6 complex channels | 6 complex channels + SetParameterOutputImage("outc", m_RCRCFilter->GetOutput() ); // input : 6 complex channels | 6 complex channels break; @@ -586,7 +586,7 @@ private: m_RLCRCCFilter = RLCRCCFilterType::New(); m_RLCRCCFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); - SetParameterComplexOutputImage("outc", m_RLCRCCFilter->GetOutput() ); // input : 6 complex channels | output : 6 complex channels + SetParameterOutputImage("outc", m_RLCRCCFilter->GetOutput() ); // input : 6 complex channels | output : 6 complex channels break; @@ -597,7 +597,7 @@ private: m_MRCFilter->SetInput(GetParameterDoubleVectorImage("inf")); - SetParameterComplexOutputImage("outc", m_MRCFilter->GetOutput() ); // input : 16 real channels | output : 6 complex channels + SetParameterOutputImage("outc", m_MRCFilter->GetOutput() ); // input : 16 real channels | output : 6 complex channels break; @@ -615,7 +615,7 @@ private: m_CohSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh")); m_CohSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); - SetParameterComplexOutputImage("outc", m_CohSRFilter->GetOutput() ); // input : 4 x 1 complex channel | 10 complex channels + SetParameterOutputImage("outc", m_CohSRFilter->GetOutput() ); // input : 4 x 1 complex channel | 10 complex channels break; @@ -630,7 +630,7 @@ private: m_CovSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh")); m_CovSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); - SetParameterComplexOutputImage("outc", m_CovSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 10 complex channels + SetParameterOutputImage("outc", m_CovSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 10 complex channels break; @@ -644,7 +644,7 @@ private: m_CCSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh")); m_CCSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); - SetParameterComplexOutputImage("outc", m_CCSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 10 complex channels + SetParameterOutputImage("outc", m_CCSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 10 complex channels break; diff --git a/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx b/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx index 236ac0789f..3db956847e 100644 --- a/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx +++ b/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx @@ -86,7 +86,7 @@ private: AddDocTag(Tags::SAR); - AddParameter(ParameterType_ComplexInputImage, "in", "Input Image"); + AddParameter(ParameterType_InputImage, "in", "Input Image"); SetParameterDescription("in", "Input image."); AddParameter(ParameterType_OutputImage, "out", "Output Image"); SetParameterDescription("out", "Output image."); diff --git a/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx b/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx index 39db311e79..ec91b7e53b 100644 --- a/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx +++ b/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx @@ -75,7 +75,7 @@ private: AddDocTag(Tags::SAR); AddDocTag(Tags::Manip); // Input images - AddParameter(ParameterType_ComplexInputImage, "in", "Input Image"); + AddParameter(ParameterType_InputImage, "in", "Input Image"); SetParameterDescription("in", "Input image (complex single band)"); // Outputs @@ -110,7 +110,7 @@ private: m_Modulus = ModulusFilterType::New(); m_Phase = PhaseFilterType::New(); - ComplexFloatVectorImageType::Pointer inImage = GetParameterComplexImage("in"); + ComplexFloatVectorImageType::Pointer inImage = GetParameterComplexFloatVectorImage("in"); if (inImage->GetNumberOfComponentsPerPixel() != 1) { -- GitLab From a11653ed84ae1524a6f93d472c3cc63c9b4bf870 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Sun, 19 Nov 2017 22:06:12 +0100 Subject: [PATCH 090/567] ENH: API change of Shark's RF --- .../otbSharkRandomForestsMachineLearningModel.h | 5 +++-- ...tbSharkRandomForestsMachineLearningModel.txx | 17 ++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h index 8d2c0c8123..484de95428 100644 --- a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h @@ -34,6 +34,7 @@ #pragma GCC diagnostic ignored "-Wcast-align" #pragma GCC diagnostic ignored "-Wunknown-pragmas" #endif +#include <shark/Models/Classifier.h> #include "otb_shark.h" #include "shark/Algorithms/Trainers/RFTrainer.h" #if defined(__GNUC__) || defined(__clang__) @@ -154,8 +155,8 @@ private: SharkRandomForestsMachineLearningModel(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented - shark::RFClassifier m_RFModel; - shark::RFTrainer m_RFTrainer; + shark::RFClassifier<unsigned int> m_RFModel; + shark::RFTrainer<unsigned int> m_RFTrainer; unsigned int m_NumberOfTrees; unsigned int m_MTry; diff --git a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.txx b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.txx index 207f1abdd7..4d7d9e83e3 100644 --- a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.txx +++ b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.txx @@ -32,7 +32,6 @@ #pragma GCC diagnostic ignored "-Woverloaded-virtual" #pragma GCC diagnostic ignored "-Wignored-qualifiers" #endif -#include <shark/Models/Converter.h> #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif @@ -82,7 +81,7 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> m_RFTrainer.setMTry(m_MTry); m_RFTrainer.setNTrees(m_NumberOfTrees); m_RFTrainer.setNodeSize(m_NodeSize); - m_RFTrainer.setOOBratio(m_OobRatio); + // m_RFTrainer.setOOBratio(m_OobRatio); m_RFTrainer.train(m_RFModel, TrainSamples); } @@ -125,13 +124,11 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> } if (quality != ITK_NULLPTR) { - shark::RealVector probas = m_RFModel(samples); + shark::RealVector probas = m_RFModel.decisionFunction()(samples); (*quality) = ComputeConfidence(probas, m_ComputeMargin); } - shark::ArgMaxConverter<shark::RFClassifier> amc; - amc.decisionFunction() = m_RFModel; - unsigned int res; - amc.eval(samples, res); + unsigned int res{0}; + m_RFModel.eval(samples, res); TargetSampleType target; target[0] = static_cast<TOutputValue>(res); return target; @@ -163,7 +160,7 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> if(quality != ITK_NULLPTR) { - shark::Data<shark::RealVector> probas = m_RFModel(inputSamples); + shark::Data<shark::RealVector> probas = m_RFModel.decisionFunction()(inputSamples); unsigned int id = startIndex; for(shark::RealVector && p : probas.elements()) { @@ -175,9 +172,7 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> } } - shark::ArgMaxConverter<shark::RFClassifier> amc; - amc.decisionFunction() = m_RFModel; - auto prediction = amc(inputSamples); + auto prediction = m_RFModel(inputSamples); unsigned int id = startIndex; for(const auto& p : prediction.elements()) { -- GitLab From 3fde3d39ac76b8a3bf4703fe956d98dd96c40259 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 20 Nov 2017 10:11:56 +0100 Subject: [PATCH 091/567] ADD: new class for multi-writer handling (WIP) --- .../ImageIO/include/otbMultiImageFileWriter.h | 322 ++++++++++++++ .../include/otbMultiImageFileWriter.txx | 263 +++++++++++ .../ImageIO/src/otbMultiImageFileWriter.cxx | 421 ++++++++++++++++++ 3 files changed, 1006 insertions(+) create mode 100644 Modules/IO/ImageIO/include/otbMultiImageFileWriter.h create mode 100644 Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx create mode 100644 Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx diff --git a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h new file mode 100644 index 0000000000..ca2601b32f --- /dev/null +++ b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h @@ -0,0 +1,322 @@ +/* + * Copyright (C) CS SI + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbMultiImageFileWriter_h +#define otbMultiImageFileWriter_h + +#include "otbImageFileWriter.h" +#include "itkImageBase.h" +#include "itkProcessObject.h" +#include "itkImageIOBase.h" + +//#include "s2ipfImageRegionFixedSplitter.h" + +#include <boost/shared_ptr.hpp> + +namespace otb +{ + +/** \class MultiImageFileWriter + * \brief Streams a pipeline with multiple outputs. + * It optionally writes each output to a file, and can also separate each + * output into several granules files (use SetGranuleGenerationMode). Inputs + * are connected to the writer using the AddInput method. + * The streaming occurs by strips. Each output may have a different resolution, + * specified at the AddInput call, and the strip size is proportional to the + * resolution. + */ +class MultiImageFileWriter: public itk::ProcessObject +{ + friend class Sink; +public: + /** Standard class typedefs. */ + typedef MultiImageFileWriter Self; + typedef itk::ProcessObject Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + itkNewMacro(Self); + + itkTypeMacro(MultiImageFileWriter, itk::ProcessObject); + + /** Public typedefs */ + typedef itk::ImageBase<2> ImageBaseType; + typedef ImageBaseType::RegionType RegionType; + typedef ImageBaseType::IndexType IndexType; + typedef ImageBaseType::IndexValueType IndexValueType; + typedef ImageBaseType::SizeType SizeType; + typedef ImageBaseType::SizeValueType SizeValueType; + + //typedef ImageRegionFixedSplitter<ImageBaseType::ImageDimension> SplitterType; + + typedef StreamingManager<ImageBaseType> StreamingManagerType; + + /** Return the StreamingManager object responsible for dividing + * the region to write */ + StreamingManagerType* GetStreamingManager(void) + { + return m_StreamingManager; + } + + /** Set a user-specified implementation of StreamingManager + * used to divide the largest possible region in several divisions */ + void SetStreamingManager(StreamingManagerType* streamingManager) + { + m_StreamingManager = streamingManager; + } + + virtual void UpdateOutputData(itk::DataObject * itkNotUsed(output)); + + /** Sets the number of lines used in stripped streaming for an input with + resolutionFactor == 1.0 . This number is actually multiplied by the resolution + factor to obtain the size of the strip for each input image. */ + itkSetMacro(NumberOfLinesPerStrip, int); + itkGetMacro(NumberOfLinesPerStrip, int); + + /** Set the number of rows per granule for an image with resolution factor 1.0 */ + //~ itkSetMacro(NumberOfRowsPerGranule, int); + //~ itkGetMacro(NumberOfRowsPerGranule, int); + + /** Specify whether granules are to be generated. If false, a single file is + generated for each input */ + //~ itkSetMacro(GranuleGenerationMode, bool); + //~ itkGetConstReferenceMacro(GranuleGenerationMode, bool); + //~ itkBooleanMacro(GranuleGenerationMode); + + /** Set the compression On or Off */ + //~ itkSetMacro(UseCompression, bool); + //~ itkGetConstReferenceMacro(UseCompression, bool); + //~ itkBooleanMacro(UseCompression); + + /** + * Enable/disable writing of a .geom file with the ossim keyword list along with the written image + */ + //~ itkSetMacro(WriteGeomFile, bool); + //~ itkGetMacro(WriteGeomFile, bool); + //~ itkBooleanMacro(WriteGeomFile); + + /** Connect a new input to the multi-writer. Only the input pointer is + * required. If the filename list is empty, + * streaming will occur without writing. It the filename list contains more + * than one element, then the output will be divided into this number of + * granule files. The resolution factor specifies the ratio between the height of this image and the + * height of a reference image. The number of lines per strip class parameter will be modified according to this factor, so + * that images with different resolutions can be streamed together. For example, use 1.0 for a 10m pixels image, 0.5 for a 20m + * pixels image, and specify the number of lines per strip according to the 10m pixels image. + * You may specify top and bottom margins that will be removed from the input image, according to its largest possible region. + */ + template <class TImage> + void AddInputImage(const TImage* inputPtr, const std::string & fileName) + { + Sink<TImage> * sink = new Sink<TImage>(inputPtr, fileName); + m_SinkList.push_back(SinkBase::Pointer(sink)); + unsigned int size = m_SinkList.size(); + this->SetNumberOfInputs(size); + this->SetNthInput(size - 1, const_cast<itk::DataObject*>(dynamic_cast<const itk::DataObject*>(inputPtr))); + } + + //~ /** Connect a new input to the multi-writer. Takes a single filename instead + //~ of a list of filenames */ + //~ template <class TImage> + //~ void AddInput(const TImage* inputPtr, const std::string & fileName = std::string(), double resolutionFactor = 1.0, int topMarginTrimSize = 0, int bottomMarginTrimSize = 0) + //~ { + //~ std::vector<std::string> fileNameList; + //~ fileNameList.push_back(fileName); + //~ this->AddInput(inputPtr, fileNameList, resolutionFactor, topMarginTrimSize, bottomMarginTrimSize); + //~ } +//~ + //~ /** This version of AddInput takes no input filename */ + //~ template <class TImage> + //~ void AddInput(const TImage* inputPtr, double resolutionFactor = 1.0, int topMarginTrimSize = 0, int bottomMarginTrimSize = 0) + //~ { + //~ this->AddInput(inputPtr, std::vector<std::string>(), resolutionFactor, topMarginTrimSize, bottomMarginTrimSize); + //~ } + + virtual void UpdateOutputInformation(); + + virtual void Update() + { + this->UpdateOutputInformation(); + this->UpdateOutputData(NULL); + } + +protected: + /** SetInput is changed to protected. Use AddInput to connect the pipeline to + * the writer + */ +// virtual void SetInput(const ImageBaseType* image) { this->Superclass::SetInput(image); } + + /** SetInput is changed to protected. Use AddInput to connect the pipeline to + * the writer + */ +// virtual void SetInput(unsigned int i, const ImageBaseType* image) { this->Superclass::SetInput(i, image); } + + MultiImageFileWriter(); + virtual ~MultiImageFileWriter() {} + + /** GenerateData calls the Write method for each connected input */ + virtual void GenerateData(void); + + virtual void GenerateInputRequestedRegion(); + + /** Computes the number of divisions */ + virtual void InitializeStreaming(); + + /** Goes up the pipeline starting at imagePtr, resetting all requested regions to a null region */ + void ResetAllRequestedRegions(ImageBaseType* imagePtr); + + /** Returns the current stream region of the given input */ + virtual RegionType GetStreamRegion(int inputIndex); + + /** This is the number of lines used in stripped streaming for an input with + resolutionFactor == 1.0 . This number is actually multiplied by the resolution + factor to obtain the size of the strip for each input image. */ + int m_NumberOfLinesPerStrip; + + void operator =(const MultiImageFileWriter&); //purposely not implemented + + void ObserveSourceFilterProgress(itk::Object* object, const itk::EventObject & event) + { + if (typeid(event) != typeid(itk::ProgressEvent)) + { + return; + } + + itk::ProcessObject* processObject = dynamic_cast<itk::ProcessObject*>(object); + if (processObject) + { + m_DivisionProgress = processObject->GetProgress(); + } + + this->UpdateFilterProgress(); + } + + void UpdateFilterProgress() + { + this->UpdateProgress((m_DivisionProgress + m_CurrentDivision) / m_NumberOfDivisions); + } + + //Granule Generation mode + //~ bool m_GranuleGenerationMode; + + //Division parameters + unsigned int m_NumberOfDivisions; + unsigned int m_CurrentDivision; + float m_DivisionProgress; + + bool m_IsObserving; + unsigned long m_ObserverID; + + /** compression */ + //~ bool m_UseCompression; + //~ bool m_UseInputMetaDataDictionary; // whether to use the + // MetaDataDictionary from the + // input or not. + //~ bool m_WriteGeomFile; // Write a geom file to store the kwl + + /** Number of rows per granule for an image with resolution factor 1.0 (i.e. a + * 10m band) + */ + //~ int m_NumberOfRowsPerGranule; + + //~ SplitterType::Pointer m_Splitter; + + class SinkBase + { + public: + SinkBase() {} + SinkBase(ImageBaseType::ConstPointer inputImage) : + m_InputImage(inputImage) + {} + virtual ~SinkBase() {} + virtual ImageBaseType::ConstPointer GetInput() const { return m_InputImage; } + virtual ImageBaseType::Pointer GetInput() { return const_cast<ImageBaseType*>(m_InputImage.GetPointer()); } + virtual void WriteImageInformation() = 0; + virtual void Write(const RegionType & streamRegion) = 0; + virtual bool CanStreamWrite() = 0; + typedef boost::shared_ptr<SinkBase> Pointer; + protected: + /** The image on which streaming is performed */ + ImageBaseType::ConstPointer m_InputImage; + }; + + /** \class Sink + * Parameters and methods specific to a single input + */ + template <class TImage> + class Sink : public SinkBase + { + //~ friend class MultiImageFileWriter; + public: + Sink() {} + Sink(typename TImage::ConstPointer inputImage, + const std::string & filename); + + virtual ~Sink() {} + + virtual void WriteImageInformation(); + virtual void Write(const RegionType & streamRegion); + virtual bool CanStreamWrite(); + typedef boost::shared_ptr<Sink> Pointer; + protected: + //~ void CreateImageFile(int fileIndex); + + /** There may be several output filenames in the case of granule mode + * generation. Or there may be none if no output file is required. + */ + //~ std::string m_FileName; + + /** Specifies whether image is actually written to a file */ + //~ bool m_UseImageIO; + private: + /** Actual writer for this image */ + typename otb::ImageFileWriter<TImage>::Pointer m_Writer; + + /** An ImageIO used to actually write data to a file */ + itk::ImageIOBase::Pointer m_ImageIO; + + /** The current file number into which data is written */ + //~ int m_CurrentFileIndex; + + /** The image region to write to the current file */ + //~ RegionType m_CurrentFileRegion; + + /** The height of the file, which can be the size of a granule in granule + generation mode, or else the size of the input image (minus margins). */ + //~ int m_FileHeight; + + /** A pointer to the writer to gain access to its fields */ + //~ typename MultiImageFileWriter::Pointer m_Writer; + }; + + /** The list of inputs and their associated parameters, built using AddInput */ + typedef std::vector<boost::shared_ptr<SinkBase> > SinkListType; + SinkListType m_SinkList; + + std::vector<RegionType> m_StreamRegionList; + + StreamingManagerType::Pointer m_StreamingManager; +}; + +} // end of namespace s2ipf + +//~ #include "otbMultiImageFileWriter.txx" + +#endif // otbMultiImageFileWriter_h diff --git a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx new file mode 100644 index 0000000000..81417a60ea --- /dev/null +++ b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx @@ -0,0 +1,263 @@ +/* + * Copyright (C) CS SI + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbMultiImageFileWriter_txx +#define otbMultiImageFileWriter_txx + +#include "otbMultiImageFileWriter.h" +#include "otbImageIOFactory.h" +//~ #include "itkImageFileWriter.h" +#include "otbMacro.h" +//#include "s2ipfFileUtils.h" + +namespace otb +{ + +template <class TImage> +MultiImageFileWriter::Sink<TImage> +::Sink(typename TImage::ConstPointer inputImage, + const std::string & fileName): + SinkBase(dynamic_cast<const ImageBaseType*>(inputImage.GetPointer())), + //~ m_FileName(fileName), + m_ImageIO(NULL), + m_Writer(otb::ImageFileWriter<TImage>::New()) +{ + m_Writer->SetFileName(fileName); + m_Writer->SetInput(inputImage); +} + + +template <class TImage> +bool +MultiImageFileWriter::Sink<TImage> +::CanStreamWrite() +{ + if (m_ImageIO.IsNull()) + return false; + return m_ImageIO->CanStreamWrite(); +} + +template <class TImage> +void +MultiImageFileWriter::Sink<TImage> +::WriteImageInformation() +{ + m_Writer->UpdateOutputInformation(); + m_ImageIO = m_Writer->GetImageIO(); + + + //~ // new ImageIO: close current ImageIO if exists and open the new one + //~ if (! m_ImageIO.IsNull()) { /* nothing to do to close IO ? */ } + //~ m_CurrentFileIndex = fileIndex; + //~ m_ImageIO = ImageIOFactory::CreateImageIO( m_FileNameList[fileIndex].c_str(), otb::ImageIOFactory::WriteMode ); +//~ + //~ if (m_ImageIO.IsNull()) + //~ { + //~ itk::ImageFileWriterException e(__FILE__, __LINE__); + //~ std::ostringstream msg; + //~ msg << " Could not create IO object for file " << m_FileNameList[fileIndex].c_str() << std::endl; + //~ msg << " Tried to create one of the following:" << std::endl; + //~ std::list<itk::LightObject::Pointer> allobjects = itk::ObjectFactoryBase::CreateAllInstance("itkImageIOBase"); + //~ for (std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin(); i != allobjects.end(); ++i) + //~ { + //~ itk::ImageIOBase* io = dynamic_cast<itk::ImageIOBase*>(i->GetPointer()); + //~ msg << " " << io->GetNameOfClass() << std::endl; + //~ } + //~ msg << " You probably failed to set a file suffix, or" << std::endl; + //~ msg << " set the suffix to an unsupported type." << std::endl; + //~ e.SetDescription(msg.str().c_str()); + //~ e.SetLocation(ITK_LOCATION); + //~ throw e; + //~ } +//~ + //~ m_ImageIO->SetFileName(m_FileNameList[fileIndex]); + //~ if( ! m_ImageIO->CanStreamWrite() ) + //~ { + //~ std::ostringstream oss; + //~ oss << " The ImageFactory selected for the image file <" << m_FileNameList[fileIndex] << "> does not support streaming."; + //~ throw std::runtime_error(oss.str()); + //~ } + //~ m_ImageIO->SetNumberOfDimensions(TImage::ImageDimension); + //~ // Set the region of data to write to the output file (independently of + //~ // current stream region) + //~ m_CurrentFileRegion = m_InputImage->GetLargestPossibleRegion(); + //~ m_CurrentFileRegion.SetIndex(TImage::ImageDimension - 1, fileIndex * m_FileHeight + m_TopMarginTrimSize); + //~ m_CurrentFileRegion.SetSize(TImage::ImageDimension - 1, m_FileHeight); +//~ + //~ const typename TImage::SpacingType& spacing = m_InputImage->GetSpacing(); + //~ const typename TImage::PointType& origin = m_InputImage->GetOrigin(); + //~ const typename TImage::DirectionType& direction = m_InputImage->GetDirection(); +//~ + //~ for (unsigned int i = 0; i < TImage::ImageDimension; ++i) + //~ { + //~ // Final image size + //~ m_ImageIO->SetDimensions(i, m_CurrentFileRegion.GetSize(i)); + //~ m_ImageIO->SetSpacing(i, spacing[i]); + //~ m_ImageIO->SetOrigin(i, origin[i]); // TODO: fix origin for each file + //~ vnl_vector<double> axisDirection(TImage::ImageDimension); + //~ // Please note: direction cosines are stored as columns of the + //~ // direction matrix + //~ for (unsigned int j = 0; j < TImage::ImageDimension; ++j) + //~ { + //~ axisDirection[j] = direction[j][i]; + //~ } + //~ m_ImageIO->SetDirection(i, axisDirection); + //~ } + //~ m_ImageIO->SetUseCompression(m_Writer->m_UseCompression); +//~ /* + //~ if (! hasHDRExtension(m_FileNameList[fileIndex])) // This test will disable the creation of a .raw.aux.xml file in the case of raw/hdr format + //~ { + //~ m_ImageIO->SetMetaDataDictionary(m_InputImage->GetMetaDataDictionary()); + //~ } +//~ */ + //~ m_ImageIO->SetMetaDataDictionary(m_InputImage->GetMetaDataDictionary()); +//~ + //~ /** Create Image file */ + //~ m_ImageIO->WriteImageInformation(); +//~ + //~ if (strcmp(m_InputImage->GetNameOfClass(), "VectorImage") == 0) + //~ { + //~ typedef typename TImage::InternalPixelType VectorImagePixelType; + //~ m_ImageIO->SetPixelTypeInfo(typeid(VectorImagePixelType)); +//~ + //~ typedef typename TImage::AccessorFunctorType AccessorFunctorType; + //~ const TImage* inputImage = dynamic_cast<const TImage*>(m_InputImage.GetPointer()); + //~ m_ImageIO->SetNumberOfComponents(AccessorFunctorType::GetVectorLength(inputImage)); + //~ } + //~ else + //~ { + //~ // Set the pixel and component type; the number of components. + //~ typedef typename TImage::PixelType ImagePixelType; + //~ m_ImageIO->SetPixelTypeInfo(typeid(ImagePixelType)); + //~ } + + +} + +template <class TImage> +void +MultiImageFileWriter::Sink<TImage> +::Write(const RegionType & streamRegion) +{ + // Write the whole image + itk::ImageIORegion ioRegion(TImage::ImageDimension); + for (unsigned int i = 0; i < TImage::ImageDimension; ++i) + { + ioRegion.SetSize(i, streamRegion.GetSize(i)); + ioRegion.SetIndex(i, streamRegion.GetIndex(i)); + //Set the ioRegion index using the shifted index ( (0,0 without box parameter)) + //~ ioRegion.SetIndex(i, streamRegion.GetIndex(i) - m_ShiftOutputIndex[i]); + } + //~ this->SetIORegion(ioRegion); + m_ImageIO->SetIORegion(ioRegion); + m_Writer->GenerateData(); + + //~ if( ! m_UseImageIO ) return; +//~ + //~ if(!m_Writer->GetGranuleGenerationMode() && m_FileNameList.size() > 1) + //~ { + //~ throw std::runtime_error( "There must be at most one output image filename when granule generation mode is disabled" ); + //~ } +//~ + //~ // Find first file into which streamRegion should write + //~ const IndexType & streamIndex = streamRegion.GetIndex(); + //~ const SizeType & streamSize = streamRegion.GetSize(); +//~ +//~ + //~ int firstFileIndex = 0; + //~ int lastFileIndex = 0; + //~ if(m_Writer->m_GranuleGenerationMode) + //~ { + //~ firstFileIndex = (streamIndex[1] - m_TopMarginTrimSize) / (m_Writer->m_NumberOfRowsPerGranule * m_ResolutionFactor); + //~ lastFileIndex = (streamIndex[1] - m_TopMarginTrimSize + streamSize[1] - 1) / (m_Writer->m_NumberOfRowsPerGranule * m_ResolutionFactor); + //~ // If lastFileIndex is greater than the index of the last filename, then use + //~ // the last filename + //~ lastFileIndex = std::min<int>(lastFileIndex, m_FileNameList.size() - 1); + //~ } +//~ + //~ m_FileHeight = (m_Writer->m_GranuleGenerationMode)?m_Writer->m_NumberOfRowsPerGranule * m_ResolutionFactor : (m_InputImage->GetLargestPossibleRegion().GetSize(1) - m_TopMarginTrimSize - m_BottomMarginTrimSize); +//~ + //~ for( int fileIndex = firstFileIndex; fileIndex <= lastFileIndex; ++fileIndex ) + //~ { + //~ // Create the image file only if the imageIO is not already open for this file + //~ if(m_CurrentFileIndex != fileIndex) + //~ { + //~ CreateImageFile(fileIndex); + //~ } + //~ // Write part of streamRegion matching m_CurrentFileRegion + //~ IndexValueType streamLastIndex = streamRegion.GetIndex(TImage::ImageDimension-1) + streamRegion.GetSize(TImage::ImageDimension - 1) - 1; + //~ IndexValueType fileLastIndex = m_CurrentFileRegion.GetIndex(TImage::ImageDimension-1) + m_CurrentFileRegion.GetSize(TImage::ImageDimension - 1) - 1; + //~ RegionType streamRegionForCurrentFile = streamRegion; + //~ IndexValueType streamStartIndexForCurrentFile = std::max( + //~ streamRegion.GetIndex(TImage::ImageDimension - 1), + //~ m_CurrentFileRegion.GetIndex(TImage::ImageDimension - 1) + //~ ); + //~ streamRegionForCurrentFile.SetIndex(TImage::ImageDimension - 1, streamStartIndexForCurrentFile ); + //~ streamRegionForCurrentFile.SetSize( + //~ TImage::ImageDimension-1, std::min( + //~ streamLastIndex - streamStartIndexForCurrentFile + 1, + //~ fileLastIndex - streamStartIndexForCurrentFile + 1 + //~ ) + //~ ); +//~ + //~ const TImage* inputImage = dynamic_cast<const TImage*>(m_InputImage.GetPointer()); + //~ const void* dataPtr = (const void*) inputImage->GetBufferPointer(); +//~ + //~ itk::ImageIORegion ioRegion(TImage::ImageDimension); + //~ itk::ImageIORegionAdaptor<TImage::ImageDimension>::Convert(streamRegionForCurrentFile, ioRegion, m_CurrentFileRegion.GetIndex()); + //~ m_ImageIO->SetIORegion(ioRegion); +//~ + //~ RegionType bufferedRegion = m_InputImage->GetBufferedRegion(); +//~ + //~ typename TImage::Pointer cacheImage; + //~ // before this test, bad stuff would happen when they don't match + //~ if (bufferedRegion != streamRegionForCurrentFile) + //~ { + //~ otbGenericMsgDebugMacro("Requested stream region does not match generated output"); + //~ otbGenericMsgDebugMacro("Extracting output region from buffered region"); +//~ + //~ cacheImage = TImage::New(); + //~ cacheImage->CopyInformation(m_InputImage); + //~ cacheImage->SetBufferedRegion(streamRegionForCurrentFile); + //~ cacheImage->Allocate(); + //~ typedef itk::ImageRegionConstIterator<TImage> ConstIteratorType; + //~ typedef itk::ImageRegionIterator<TImage> IteratorType; +//~ + //~ ConstIteratorType in(inputImage, streamRegionForCurrentFile); + //~ IteratorType out(cacheImage, streamRegionForCurrentFile); +//~ + //~ // copy the data into a buffer to match the ioregion + //~ for (in.GoToBegin(), out.GoToBegin(); !in.IsAtEnd(); ++in, ++out) + //~ { + //~ out.Set(in.Get()); + //~ } +//~ + //~ dataPtr = (const void*) cacheImage->GetBufferPointer(); +//~ + //~ } +//~ + //~ // Write to file + //~ m_ImageIO->Write(dataPtr); + //~ } +} + +} // end of namespace otb + +#endif // otbMultiImageFileWriter_txx diff --git a/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx b/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx new file mode 100644 index 0000000000..c6fdff5c65 --- /dev/null +++ b/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx @@ -0,0 +1,421 @@ +/* + * Copyright (C) CS SI + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbMultiImageFileWriter.h" +#include "otbImage.h" +#include "otbImageIOFactory.h" +//~ #include "itkImageFileWriter.h" + +//#include "s2ipfSensor.h" +//~ #define S2IPF_GRANULE_HEIGHT 2304 + +namespace otb +{ + +MultiImageFileWriter +::MultiImageFileWriter() : + m_NumberOfLinesPerStrip(600), + //~ m_GranuleGenerationMode(false), + m_NumberOfDivisions(0), + m_CurrentDivision(0), + m_DivisionProgress(0.0), + m_IsObserving(true), + m_ObserverID(0) + //~ m_UseCompression(false), + //~ m_UseInputMetaDataDictionary(false), + //~ m_WriteGeomFile(false), + //~ m_NumberOfRowsPerGranule(S2IPF_GRANULE_HEIGHT) +{ + // By default, we use tiled streaming, with automatic tile size + // We don't set any parameter, so the memory size is retrieved from the OTB configuration options + this->SetAutomaticAdaptativeStreaming(); + // add a fake output to drive memory estimation + this->SetNthOutput(0, otb::Image<unsigned char, 2>::New()); +} + +void +MultiImageFileWriter +::SetNumberOfDivisionsStrippedStreaming(unsigned int nbDivisions) +{ + typedef NumberOfDivisionsStrippedStreamingManager<ImageBaseType> NumberOfDivisionsStrippedStreamingManagerType; + typename NumberOfDivisionsStrippedStreamingManagerType::Pointer streamingManager = NumberOfDivisionsStrippedStreamingManagerType::New(); + streamingManager->SetNumberOfDivisions(nbDivisions); + + m_StreamingManager = streamingManager; +} + +void +MultiImageFileWriter +::SetNumberOfDivisionsTiledStreaming(unsigned int nbDivisions) +{ + typedef NumberOfDivisionsTiledStreamingManager<ImageBaseType> NumberOfDivisionsTiledStreamingManagerType; + typename NumberOfDivisionsTiledStreamingManagerType::Pointer streamingManager = NumberOfDivisionsTiledStreamingManagerType::New(); + streamingManager->SetNumberOfDivisions(nbDivisions); + + m_StreamingManager = streamingManager; +} + +void +MultiImageFileWriter +::SetNumberOfLinesStrippedStreaming(unsigned int nbLinesPerStrip) +{ + typedef NumberOfLinesStrippedStreamingManager<ImageBaseType> NumberOfLinesStrippedStreamingManagerType; + typename NumberOfLinesStrippedStreamingManagerType::Pointer streamingManager = NumberOfLinesStrippedStreamingManagerType::New(); + streamingManager->SetNumberOfLinesPerStrip(nbLinesPerStrip); + + m_StreamingManager = streamingManager; +} + +void +MultiImageFileWriter +::SetAutomaticStrippedStreaming(unsigned int availableRAM, double bias) +{ + typedef RAMDrivenStrippedStreamingManager<ImageBaseType> RAMDrivenStrippedStreamingManagerType; + typename RAMDrivenStrippedStreamingManagerType::Pointer streamingManager = RAMDrivenStrippedStreamingManagerType::New(); + streamingManager->SetAvailableRAMInMB(availableRAM); + streamingManager->SetBias(bias); + + m_StreamingManager = streamingManager; +} + +void +MultiImageFileWriter +::SetTileDimensionTiledStreaming(unsigned int tileDimension) +{ + typedef TileDimensionTiledStreamingManager<ImageBaseType> TileDimensionTiledStreamingManagerType; + typename TileDimensionTiledStreamingManagerType::Pointer streamingManager = TileDimensionTiledStreamingManagerType::New(); + streamingManager->SetTileDimension(tileDimension); + + m_StreamingManager = streamingManager; +} + +void +MultiImageFileWriter +::SetAutomaticTiledStreaming(unsigned int availableRAM, double bias) +{ + typedef RAMDrivenTiledStreamingManager<ImageBaseType> RAMDrivenTiledStreamingManagerType; + typename RAMDrivenTiledStreamingManagerType::Pointer streamingManager = RAMDrivenTiledStreamingManagerType::New(); + streamingManager->SetAvailableRAMInMB(availableRAM); + streamingManager->SetBias(bias); + m_StreamingManager = streamingManager; +} + +void +MultiImageFileWriter +::SetAutomaticAdaptativeStreaming(unsigned int availableRAM, double bias) +{ + typedef RAMDrivenAdaptativeStreamingManager<ImageBaseType> RAMDrivenAdaptativeStreamingManagerType; + typename RAMDrivenAdaptativeStreamingManagerType::Pointer streamingManager = RAMDrivenAdaptativeStreamingManagerType::New(); + streamingManager->SetAvailableRAMInMB(availableRAM); + streamingManager->SetBias(bias); + m_StreamingManager = streamingManager; +} + +void +MultiImageFileWriter +::InitializeStreaming() +{ +// const ImageBaseType* inputPtr = this->GetInput(0); + if(m_SinkList.size() == 0) + itkExceptionMacro("At least one input must be connected to the writer\n"); + const ImageBaseType* inputPtr = m_SinkList[0]->GetInput(); + if(!inputPtr) + itkExceptionMacro("At least one input must be connected to the writer\n"); + + RegionType region = inputPtr->GetLargestPossibleRegion(); + // TODO : setup streaming for every input + /** + * Determine of number of pieces to divide the input. This will be the + * minimum of what the user specified via SetNumberOfDivisionsStrippedStreaming() + * and what the Splitter thinks is a reasonable value. + */ + + /** Control if the ImageIO is CanStreamWrite */ + bool canStream = true; + bool isBuffered = true; + for (unsigned int inputIndex = 0; inputIndex < m_SinkList.size(); ++inputIndex) + { + if (!m_SinkList[inputIndex]->CanStreamWrite()) + { + canStream = false; + } + if (m_SinkList[inputIndex]->GetInput()->GetBufferedRegion() != + m_SinkList[inputIndex]->GetInput()->GetLargestPossibleRegion()) + { + isBuffered = false; + } + } + if (canStream == false) + { + otbWarningMacro( + << "The ImageFactory selected for the image file <" << m_FileName.c_str() << + "> does not support streaming."); + this->SetNumberOfDivisionsStrippedStreaming(1); + } + + /** Compare the buffered region with the inputRegion which is the largest + * possible region or a user defined region through extended filename + * Not sure that if this modification is needed */ + else if (isBuffered) + { + otbMsgDevMacro(<< "Buffered region is the largest possible region, there is no need for streaming."); + this->SetNumberOfDivisionsStrippedStreaming(1); + } + // TODO : instead of inputPtr, use an output of MultiImageWriter + m_StreamingManager->PrepareStreaming(inputPtr, inputRegion); + m_NumberOfDivisions = m_StreamingManager->GetNumberOfSplits(); + otbMsgDebugMacro(<< "Number Of Stream Divisions : " << m_NumberOfDivisions); +} + +void +MultiImageFileWriter +::ResetAllRequestedRegions(ImageBaseType* imagePtr) +{ + RegionType nullRegion = imagePtr->GetLargestPossibleRegion(); + nullRegion.SetSize(0, 0); + nullRegion.SetSize(1, 0); + + imagePtr->SetRequestedRegion(nullRegion); + if(imagePtr->GetSource()) + { + itk::ProcessObject::DataObjectPointerArray inputs = imagePtr->GetSource()->GetInputs(); + for( itk::ProcessObject::DataObjectPointerArray::iterator + it = inputs.begin(); + it != inputs.end(); + ++it ) + { + ImageBaseType * inputImagePtr = dynamic_cast<ImageBaseType*>(it->GetPointer()); + if(inputImagePtr != NULL) + { + ResetAllRequestedRegions(inputImagePtr); + } + } + } +} + +void +MultiImageFileWriter +::UpdateOutputInformation() +{ + for(unsigned int inputIndex = 0; inputIndex < m_SinkList.size(); ++inputIndex) + { + m_SinkList[inputIndex]->WriteImageInformation(); + } +} + +void +MultiImageFileWriter +::UpdateOutputData(itk::DataObject * itkNotUsed(output)) +{ + /** + * prevent chasing our tail + */ + if (this->m_Updating) + { + return; + } + + /** + * Prepare all the outputs. This may deallocate previous bulk data. + */ + this->PrepareOutputs(); + + this->SetAbortGenerateData(0); + this->SetProgress(0.0); + this->m_Updating = true; + + // Initialize streaming + this->InitializeStreaming(); + + /** + * Tell all Observers that the filter is starting + */ + this->InvokeEvent(itk::StartEvent()); + + this->UpdateProgress(0); + m_CurrentDivision = 0; + m_DivisionProgress = 0; + + /** Loop over the number of pieces, set and propagate requested regions then + * update pipeline upstream + */ + int numInputs = m_SinkList.size(); //this->GetNumberOfInputs(); + m_StreamRegionList.resize(numInputs); + itkDebugMacro( "Number of streaming divisions: " << m_NumberOfDivisions); + + // Add observer only to first input + if(numInputs > 0) + { + m_IsObserving = false; + m_ObserverID = 0; + + typedef itk::MemberCommand<Self> CommandType; + typedef CommandType::Pointer CommandPointerType; + + CommandPointerType command = CommandType::New(); + command->SetCallbackFunction(this, &Self::ObserveSourceFilterProgress); + + itk::ProcessObject* src = this->GetInput(0)->GetSource(); + m_ObserverID = src->AddObserver(itk::ProgressEvent(), command); + m_IsObserving = true; + } + + for (m_CurrentDivision = 0; m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateData(); + m_CurrentDivision++, m_DivisionProgress = 0, this->UpdateFilterProgress()) + { + + // Update all stream regions + for(int inputIndex = 0; inputIndex < numInputs; ++inputIndex) + { + m_StreamRegionList[inputIndex] = GetStreamRegion(inputIndex); + } + + // NOTE : this reset was probably designed to work with the next section + // Where the final requested region is the "union" between the computed + // requested region and the current requested region. + + // Reset requested regions for all images + for(int inputIndex = 0; inputIndex < numInputs; ++inputIndex) + { + ResetAllRequestedRegions(m_SinkList[inputIndex]->GetInput()); + } + + for(int inputIndex = 0; inputIndex < numInputs; ++inputIndex) + { + + ImageBaseType::Pointer inputPtr = m_SinkList[inputIndex]->GetInput(); // const_cast<ImageBaseType*>(this->GetInput(inputIndex)); + //RegionType streamRegion = GetStreamRegion(inputIndex); + RegionType inputRequestedRegion = m_StreamRegionList[inputIndex]; + + const RegionType & currentInputRequestedRegion = inputPtr->GetRequestedRegion(); + if( currentInputRequestedRegion != inputPtr->GetLargestPossibleRegion() && currentInputRequestedRegion.GetNumberOfPixels() != 0) + { + IndexType startIndex = currentInputRequestedRegion.GetIndex(); + IndexType lastIndex = currentInputRequestedRegion.GetUpperIndex(); + startIndex[0] = std::min(startIndex[0], inputRequestedRegion.GetIndex(0)); + startIndex[1] = std::min(startIndex[1], inputRequestedRegion.GetIndex(1)); + lastIndex[0] = std::max(lastIndex[0], inputRequestedRegion.GetUpperIndex()[0]); + lastIndex[1] = std::max(lastIndex[1], inputRequestedRegion.GetUpperIndex()[1]); + inputRequestedRegion.SetIndex(startIndex); + inputRequestedRegion.SetUpperIndex(lastIndex); + } + + inputPtr->SetRequestedRegion(inputRequestedRegion); + inputPtr->PropagateRequestedRegion(); + } + + for(int inputIndex = 0; inputIndex < numInputs; ++inputIndex) + { + ImageBaseType* inputPtr = m_SinkList[inputIndex]->GetInput(); // const_cast<ImageBaseType*>(this->GetInput(inputIndex)); + //RegionType streamRegion = GetStreamRegion(inputIndex); + inputPtr->UpdateOutputData(); + } + + /** Call GenerateData to write streams to files if needed */ + this->GenerateData(); + + } + + /** + * If we ended due to aborting, push the progress up to 1.0 (since + * it probably didn't end there) + */ + if (!this->GetAbortGenerateData()) + { + this->UpdateProgress(1.0); + } + + // Notify end event observers + this->InvokeEvent(itk::EndEvent()); + + if (m_IsObserving) + { + ImageBaseType::Pointer inputPtr = m_SinkList[0]->GetInput(); // const_cast<ImageBaseType *>(this->GetInput(0)); + itk::ProcessObject* source = inputPtr->GetSource(); + m_IsObserving = false; + source->RemoveObserver(m_ObserverID); + } + + /** + * Release any inputs if marked for release + */ + this->ReleaseInputs(); + + // Mark that we are no longer updating the data in this filter + this->m_Updating = false; + +} + + +void +MultiImageFileWriter +::GenerateInputRequestedRegion() +{ + Superclass::GenerateInputRequestedRegion(); + + int numInputs = m_SinkList.size(); //this->GetNumberOfInputs(); + + for (int i = 0; i < numInputs; ++i) + { + ImageBaseType* inputPtr = m_SinkList[i]->GetInput(); //const_cast<ImageBaseType*>(this->GetInput(i)); + + if(!inputPtr) + { + return; + } + RegionType lregion = inputPtr->GetLargestPossibleRegion(); + SizeType rsize; + rsize.Fill(0); + lregion.SetSize(rsize); + + inputPtr->SetRequestedRegion(lregion); + } +} + +void +MultiImageFileWriter +::GenerateData() +{ + int numInputs = m_SinkList.size(); //this->GetNumberOfInputs(); + + for(int inputIndex = 0; inputIndex < numInputs; ++inputIndex) + { + + //ImageBaseType* inputPtr = const_cast<ImageBaseType*>(this->GetInput(inputIndex)); + //RegionType streamRegion = GetStreamRegion(inputIndex); + + m_SinkList[inputIndex]->Write(m_StreamRegionList[inputIndex]); + } +} + +MultiImageFileWriter::RegionType +MultiImageFileWriter +::GetStreamRegion(int inputIndex) +{ + const SinkBase::Pointer sink = m_SinkList[inputIndex]; + RegionType region = sink->GetInput()->GetLargestPossibleRegion(); + //~ region.SetIndex(1, region.GetIndex(1) + sink->GetTopMarginTrimSize()); + //~ region.SetSize(1, region.GetSize(1) - sink->GetTopMarginTrimSize() - sink->GetBottomMarginTrimSize()); + + // TODO : call splitter + return region; +} + +} // end of namespace otb -- GitLab From 013fa54abf145a42a12c4f597a1f41335420ff43 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 20 Nov 2017 10:12:54 +0100 Subject: [PATCH 092/567] ENH: allow to access the splitter --- Modules/Core/Streaming/include/otbStreamingManager.h | 4 +++- Modules/Core/Streaming/include/otbStreamingManager.txx | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Modules/Core/Streaming/include/otbStreamingManager.h b/Modules/Core/Streaming/include/otbStreamingManager.h index 2095e48e8f..a8e9fea847 100644 --- a/Modules/Core/Streaming/include/otbStreamingManager.h +++ b/Modules/Core/Streaming/include/otbStreamingManager.h @@ -67,6 +67,7 @@ public: typedef typename ImageType::InternalPixelType PixelType; typedef otb::PipelineMemoryPrintCalculator::MemoryPrintType MemoryPrintType; + typedef itk::ImageRegionSplitterBase AbstractSplitterType; /** Type macro */ itkTypeMacro(StreamingManager, itk::LightObject); @@ -74,6 +75,8 @@ public: /** Dimension of input image. */ itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension); + const AbstractSplitterType * GetSplitter() const; + /** Actually computes the stream divisions, according to the specified streaming mode, * eventually using the input parameter to estimate memory consumption */ virtual void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) = 0; @@ -103,7 +106,6 @@ protected: RegionType m_Region; /** The splitter used to compute the different strips */ - typedef itk::ImageRegionSplitterBase AbstractSplitterType; typedef typename AbstractSplitterType::Pointer AbstractSplitterPointerType; AbstractSplitterPointerType m_Splitter; diff --git a/Modules/Core/Streaming/include/otbStreamingManager.txx b/Modules/Core/Streaming/include/otbStreamingManager.txx index b0fdfced06..efb462c8b6 100644 --- a/Modules/Core/Streaming/include/otbStreamingManager.txx +++ b/Modules/Core/Streaming/include/otbStreamingManager.txx @@ -39,6 +39,13 @@ StreamingManager<TImage>::~StreamingManager() { } +template <class TImage> +const typename StreamingManager<TImage>::AbstractSplitterType * +StreamingManager<TImage>::GetSplitter() const +{ + return m_Splitter; +} + template <class TImage> typename StreamingManager<TImage>::MemoryPrintType StreamingManager<TImage>::GetActualAvailableRAMInBytes(MemoryPrintType availableRAMInMB) -- GitLab From 3b67da418d7e7dfa03719f34cfdc7ee97e5e66c9 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 20 Nov 2017 10:15:38 +0100 Subject: [PATCH 093/567] ENH: move initialisation of output image file in GenerateOutputInformation() --- .../IO/ImageIO/include/otbImageFileWriter.h | 3 ++ .../IO/ImageIO/include/otbImageFileWriter.txx | 48 +++++++++++-------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.h b/Modules/IO/ImageIO/include/otbImageFileWriter.h index b7bc6499b0..93cee428aa 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.h @@ -207,6 +207,9 @@ protected: /** Does the real work. */ void GenerateData(void) ITK_OVERRIDE; + /** Prepare the streaming and write the output information on disk */ + void GenerateOutputInformation(void) override; + private: ImageFileWriter(const ImageFileWriter &); //purposely not implemented void operator =(const ImageFileWriter&); //purposely not implemented diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index b1472291f1..820d945241 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -268,13 +268,11 @@ ImageFileWriter<TInputImage> return static_cast<const InputImageType*>(this->ProcessObject::GetInput(0)); } -/** - * Update method : update output information of input and write to file - */ +/** Prepare everything and call m_ImageIO.WriteInformation() */ template<class TInputImage> void ImageFileWriter<TInputImage> -::Update() +::GenerateOutputInformation(void) { // Update output information on input image InputImagePointer inputPtr = @@ -393,14 +391,6 @@ ImageFileWriter<TInputImage> } } - this->SetAbortGenerateData(0); - this->SetProgress(0.0); - - /** - * Tell all Observers that the filter is starting - */ - this->InvokeEvent(itk::StartEvent()); - /** Prepare ImageIO : create ImageFactory */ if (m_FileName == "") @@ -479,7 +469,6 @@ ImageFileWriter<TInputImage> /** * Grab the input */ - inputPtr->UpdateOutputInformation(); InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion(); /** Parse region size modes */ @@ -544,12 +533,6 @@ ImageFileWriter<TInputImage> m_NumberOfDivisions = m_StreamingManager->GetNumberOfSplits(); otbMsgDebugMacro(<< "Number Of Stream Divisions : " << m_NumberOfDivisions); - /** - * Loop over the number of pieces, execute the upstream pipeline on each - * piece, and copy the results into the output image. - */ - InputImageRegionType streamRegion; - // // Setup the ImageIO with information from inputPtr // @@ -588,12 +571,33 @@ ImageFileWriter<TInputImage> m_ImageIO->SetFileName(m_FileName.c_str()); m_ImageIO->WriteImageInformation(); +} +/** + * Update method : update output information of input and write to file + */ +template<class TInputImage> +void +ImageFileWriter<TInputImage> +::Update() +{ + this->UpdateOutputInformation(); + + this->SetAbortGenerateData(0); + this->SetProgress(0.0); + + /** + * Tell all Observers that the filter is starting + */ + this->InvokeEvent(itk::StartEvent()); + this->UpdateProgress(0); m_CurrentDivision = 0; m_DivisionProgress = 0; // Get the source process object + InputImagePointer inputPtr = + const_cast<InputImageType *>(this->GetInput()); itk::ProcessObject* source = inputPtr->GetSource(); m_IsObserving = false; m_ObserverID = 0; @@ -615,6 +619,12 @@ ImageFileWriter<TInputImage> itkWarningMacro(<< "Could not get the source process object. Progress report might be buggy"); } + /** + * Loop over the number of pieces, execute the upstream pipeline on each + * piece, and copy the results into the output image. + */ + InputImageRegionType streamRegion; + for (m_CurrentDivision = 0; m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateData(); m_CurrentDivision++, m_DivisionProgress = 0, this->UpdateFilterProgress()) -- GitLab From 8749cf22ed97df06a4ddf8725fb2cc47bb08d2b7 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 20 Nov 2017 10:16:12 +0100 Subject: [PATCH 094/567] COMP: compile MultiImageFileWriter --- Modules/IO/ImageIO/src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/IO/ImageIO/src/CMakeLists.txt b/Modules/IO/ImageIO/src/CMakeLists.txt index 2d580c6541..e604942a7c 100644 --- a/Modules/IO/ImageIO/src/CMakeLists.txt +++ b/Modules/IO/ImageIO/src/CMakeLists.txt @@ -20,6 +20,7 @@ set(OTBImageIO_SRC otbImageIOFactory.cxx + otbMultiImageFileWriter.cxx ) add_library(OTBImageIO ${OTBImageIO_SRC}) -- GitLab From b92b742e4067a354af0372e1adf4f289020b6d2d Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 20 Nov 2017 10:18:42 +0100 Subject: [PATCH 095/567] COMP: add fake GetUInt8RGBImage and GetUInt8RGBAImage for complex image parameter --- .../src/otbWrapperComplexInputImageParameter.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx index 0eda88fb9d..1c105f25c0 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx @@ -163,6 +163,9 @@ otbGetFalseImageMacro(UInt32VectorImage); otbGetFalseImageMacro(UInt8Image); otbGetFalseImageMacro(UInt8VectorImage); +otbGetFalseImageMacro(UInt8RGBImage); +otbGetFalseImageMacro(UInt8RGBAImage); + } } -- GitLab From df16dd79f705f8b6464e735f1a64adfc6bb8e930 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 20 Nov 2017 16:25:00 +0100 Subject: [PATCH 096/567] ENH: handle streaming for all inputs --- .../ImageIO/include/otbMultiImageFileWriter.h | 80 ++++++++-- .../ImageIO/src/otbMultiImageFileWriter.cxx | 143 ++++++++++++------ 2 files changed, 164 insertions(+), 59 deletions(-) diff --git a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h index ca2601b32f..2e2d3bd879 100644 --- a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h @@ -22,6 +22,7 @@ #define otbMultiImageFileWriter_h #include "otbImageFileWriter.h" +#include "otbImage.h" #include "itkImageBase.h" #include "itkProcessObject.h" #include "itkImageIOBase.h" @@ -66,29 +67,75 @@ public: //typedef ImageRegionFixedSplitter<ImageBaseType::ImageDimension> SplitterType; - typedef StreamingManager<ImageBaseType> StreamingManagerType; - /** Return the StreamingManager object responsible for dividing * the region to write */ - StreamingManagerType* GetStreamingManager(void) - { - return m_StreamingManager; - } + //~ StreamingManagerType* GetStreamingManager(void) + //~ { + //~ return m_StreamingManager; + //~ } /** Set a user-specified implementation of StreamingManager * used to divide the largest possible region in several divisions */ - void SetStreamingManager(StreamingManagerType* streamingManager) - { - m_StreamingManager = streamingManager; - } + //~ void SetStreamingManager(StreamingManagerType* streamingManager) + //~ { + //~ m_StreamingManager = streamingManager; + //~ } + + /** Set the streaming mode to 'stripped' and configure the number of strips + * which will be used to stream the image */ + void SetNumberOfDivisionsStrippedStreaming(unsigned int nbDivisions); + + /** Set the streaming mode to 'tiled' and configure the number of tiles + * which will be used to stream the image */ + void SetNumberOfDivisionsTiledStreaming(unsigned int nbDivisions); + + /** Set the streaming mode to 'stripped' and configure the number of strips + * which will be used to stream the image with respect to a number of line + * per strip */ + void SetNumberOfLinesStrippedStreaming(unsigned int nbLinesPerStrip); + + /** Set the streaming mode to 'stripped' and configure the number of MB + * available. The actual number of divisions is computed automatically + * by estimating the memory consumption of the pipeline. + * Setting the availableRAM parameter to 0 means that the available RAM + * is set from the CMake configuration option. + * The bias parameter is a multiplier applied on the estimated memory size + * of the pipeline and can be used to fine tune the potential gap between + * estimated memory and actual memory used, which can happen because of + * composite filters for example */ + void SetAutomaticStrippedStreaming(unsigned int availableRAM = 0, double bias = 1.0); + + /** Set the streaming mode to 'tiled' and configure the dimension of the tiles + * in pixels for each dimension (square tiles will be generated) */ + void SetTileDimensionTiledStreaming(unsigned int tileDimension); + + /** Set the streaming mode to 'tiled' and configure the number of MB + * available. The actual number of divisions is computed automatically + * by estimating the memory consumption of the pipeline. + * Tiles will be square. + * Setting the availableRAM parameter to 0 means that the available RAM + * is set from the CMake configuration option + * The bias parameter is a multiplier applied on the estimated memory size + * of the pipeline and can be used to fine tune the potential gap between + * estimated memory and actual memory used, which can happen because of + * composite filters for example */ + void SetAutomaticTiledStreaming(unsigned int availableRAM = 0, double bias = 1.0); + + /** Set the streaming mode to 'adaptative' and configure the number of MB + * available. The actual number of divisions is computed automatically + * by estimating the memory consumption of the pipeline. + * Tiles will try to match the input file tile scheme. + * Setting the availableRAM parameter to 0 means that the available RAM + * is set from the CMake configuration option */ + void SetAutomaticAdaptativeStreaming(unsigned int availableRAM = 0, double bias = 1.0); virtual void UpdateOutputData(itk::DataObject * itkNotUsed(output)); /** Sets the number of lines used in stripped streaming for an input with resolutionFactor == 1.0 . This number is actually multiplied by the resolution factor to obtain the size of the strip for each input image. */ - itkSetMacro(NumberOfLinesPerStrip, int); - itkGetMacro(NumberOfLinesPerStrip, int); + //~ itkSetMacro(NumberOfLinesPerStrip, int); + //~ itkGetMacro(NumberOfLinesPerStrip, int); /** Set the number of rows per granule for an image with resolution factor 1.0 */ //~ itkSetMacro(NumberOfRowsPerGranule, int); @@ -188,7 +235,7 @@ protected: /** This is the number of lines used in stripped streaming for an input with resolutionFactor == 1.0 . This number is actually multiplied by the resolution factor to obtain the size of the strip for each input image. */ - int m_NumberOfLinesPerStrip; + //int m_NumberOfLinesPerStrip; void operator =(const MultiImageFileWriter&); //purposely not implemented @@ -213,6 +260,11 @@ protected: this->UpdateProgress((m_DivisionProgress + m_CurrentDivision) / m_NumberOfDivisions); } +private: + typedef otb::Image<unsigned char, 2> FakeOutputType; + typedef StreamingManager<FakeOutputType> StreamingManagerType; + /** Streaming manager used for the N inputs */ + StreamingManagerType::Pointer m_StreamingManager; //Granule Generation mode //~ bool m_GranuleGenerationMode; @@ -311,8 +363,6 @@ protected: SinkListType m_SinkList; std::vector<RegionType> m_StreamRegionList; - - StreamingManagerType::Pointer m_StreamingManager; }; } // end of namespace s2ipf diff --git a/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx b/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx index c6fdff5c65..21344a2026 100644 --- a/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx +++ b/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx @@ -19,7 +19,6 @@ */ #include "otbMultiImageFileWriter.h" -#include "otbImage.h" #include "otbImageIOFactory.h" //~ #include "itkImageFileWriter.h" @@ -31,7 +30,7 @@ namespace otb MultiImageFileWriter ::MultiImageFileWriter() : - m_NumberOfLinesPerStrip(600), + //m_NumberOfLinesPerStrip(600), //~ m_GranuleGenerationMode(false), m_NumberOfDivisions(0), m_CurrentDivision(0), @@ -47,15 +46,16 @@ MultiImageFileWriter // We don't set any parameter, so the memory size is retrieved from the OTB configuration options this->SetAutomaticAdaptativeStreaming(); // add a fake output to drive memory estimation - this->SetNthOutput(0, otb::Image<unsigned char, 2>::New()); + this->SetNthOutput(0, FakeOutputType::New()); } void MultiImageFileWriter ::SetNumberOfDivisionsStrippedStreaming(unsigned int nbDivisions) { - typedef NumberOfDivisionsStrippedStreamingManager<ImageBaseType> NumberOfDivisionsStrippedStreamingManagerType; - typename NumberOfDivisionsStrippedStreamingManagerType::Pointer streamingManager = NumberOfDivisionsStrippedStreamingManagerType::New(); + typedef NumberOfDivisionsStrippedStreamingManager<FakeOutputType> NumberOfDivisionsStrippedStreamingManagerType; + NumberOfDivisionsStrippedStreamingManagerType::Pointer streamingManager = + NumberOfDivisionsStrippedStreamingManagerType::New(); streamingManager->SetNumberOfDivisions(nbDivisions); m_StreamingManager = streamingManager; @@ -65,8 +65,9 @@ void MultiImageFileWriter ::SetNumberOfDivisionsTiledStreaming(unsigned int nbDivisions) { - typedef NumberOfDivisionsTiledStreamingManager<ImageBaseType> NumberOfDivisionsTiledStreamingManagerType; - typename NumberOfDivisionsTiledStreamingManagerType::Pointer streamingManager = NumberOfDivisionsTiledStreamingManagerType::New(); + typedef NumberOfDivisionsTiledStreamingManager<FakeOutputType> NumberOfDivisionsTiledStreamingManagerType; + NumberOfDivisionsTiledStreamingManagerType::Pointer streamingManager = + NumberOfDivisionsTiledStreamingManagerType::New(); streamingManager->SetNumberOfDivisions(nbDivisions); m_StreamingManager = streamingManager; @@ -76,8 +77,9 @@ void MultiImageFileWriter ::SetNumberOfLinesStrippedStreaming(unsigned int nbLinesPerStrip) { - typedef NumberOfLinesStrippedStreamingManager<ImageBaseType> NumberOfLinesStrippedStreamingManagerType; - typename NumberOfLinesStrippedStreamingManagerType::Pointer streamingManager = NumberOfLinesStrippedStreamingManagerType::New(); + typedef NumberOfLinesStrippedStreamingManager<FakeOutputType> NumberOfLinesStrippedStreamingManagerType; + NumberOfLinesStrippedStreamingManagerType::Pointer streamingManager = + NumberOfLinesStrippedStreamingManagerType::New(); streamingManager->SetNumberOfLinesPerStrip(nbLinesPerStrip); m_StreamingManager = streamingManager; @@ -87,8 +89,9 @@ void MultiImageFileWriter ::SetAutomaticStrippedStreaming(unsigned int availableRAM, double bias) { - typedef RAMDrivenStrippedStreamingManager<ImageBaseType> RAMDrivenStrippedStreamingManagerType; - typename RAMDrivenStrippedStreamingManagerType::Pointer streamingManager = RAMDrivenStrippedStreamingManagerType::New(); + typedef RAMDrivenStrippedStreamingManager<FakeOutputType> RAMDrivenStrippedStreamingManagerType; + RAMDrivenStrippedStreamingManagerType::Pointer streamingManager = + RAMDrivenStrippedStreamingManagerType::New(); streamingManager->SetAvailableRAMInMB(availableRAM); streamingManager->SetBias(bias); @@ -99,8 +102,9 @@ void MultiImageFileWriter ::SetTileDimensionTiledStreaming(unsigned int tileDimension) { - typedef TileDimensionTiledStreamingManager<ImageBaseType> TileDimensionTiledStreamingManagerType; - typename TileDimensionTiledStreamingManagerType::Pointer streamingManager = TileDimensionTiledStreamingManagerType::New(); + typedef TileDimensionTiledStreamingManager<FakeOutputType> TileDimensionTiledStreamingManagerType; + TileDimensionTiledStreamingManagerType::Pointer streamingManager = + TileDimensionTiledStreamingManagerType::New(); streamingManager->SetTileDimension(tileDimension); m_StreamingManager = streamingManager; @@ -110,8 +114,9 @@ void MultiImageFileWriter ::SetAutomaticTiledStreaming(unsigned int availableRAM, double bias) { - typedef RAMDrivenTiledStreamingManager<ImageBaseType> RAMDrivenTiledStreamingManagerType; - typename RAMDrivenTiledStreamingManagerType::Pointer streamingManager = RAMDrivenTiledStreamingManagerType::New(); + typedef RAMDrivenTiledStreamingManager<FakeOutputType> RAMDrivenTiledStreamingManagerType; + RAMDrivenTiledStreamingManagerType::Pointer streamingManager = + RAMDrivenTiledStreamingManagerType::New(); streamingManager->SetAvailableRAMInMB(availableRAM); streamingManager->SetBias(bias); m_StreamingManager = streamingManager; @@ -121,8 +126,9 @@ void MultiImageFileWriter ::SetAutomaticAdaptativeStreaming(unsigned int availableRAM, double bias) { - typedef RAMDrivenAdaptativeStreamingManager<ImageBaseType> RAMDrivenAdaptativeStreamingManagerType; - typename RAMDrivenAdaptativeStreamingManagerType::Pointer streamingManager = RAMDrivenAdaptativeStreamingManagerType::New(); + typedef RAMDrivenAdaptativeStreamingManager<FakeOutputType> RAMDrivenAdaptativeStreamingManagerType; + RAMDrivenAdaptativeStreamingManagerType::Pointer streamingManager = + RAMDrivenAdaptativeStreamingManagerType::New(); streamingManager->SetAvailableRAMInMB(availableRAM); streamingManager->SetBias(bias); m_StreamingManager = streamingManager; @@ -139,8 +145,6 @@ MultiImageFileWriter if(!inputPtr) itkExceptionMacro("At least one input must be connected to the writer\n"); - RegionType region = inputPtr->GetLargestPossibleRegion(); - // TODO : setup streaming for every input /** * Determine of number of pieces to divide the input. This will be the * minimum of what the user specified via SetNumberOfDivisionsStrippedStreaming() @@ -148,6 +152,7 @@ MultiImageFileWriter */ /** Control if the ImageIO is CanStreamWrite */ + m_NumberOfDivisions = 1; bool canStream = true; bool isBuffered = true; for (unsigned int inputIndex = 0; inputIndex < m_SinkList.size(); ++inputIndex) @@ -165,9 +170,8 @@ MultiImageFileWriter if (canStream == false) { otbWarningMacro( - << "The ImageFactory selected for the image file <" << m_FileName.c_str() << - "> does not support streaming."); - this->SetNumberOfDivisionsStrippedStreaming(1); + << "One of the selected ImageIO does not support streaming."); + this->SetNumberOfDivisionsStrippedStreaming(m_NumberOfDivisions); } /** Compare the buffered region with the inputRegion which is the largest @@ -175,13 +179,44 @@ MultiImageFileWriter * Not sure that if this modification is needed */ else if (isBuffered) { - otbMsgDevMacro(<< "Buffered region is the largest possible region, there is no need for streaming."); - this->SetNumberOfDivisionsStrippedStreaming(1); + otbMsgDevMacro(<< "Buffered region is the largest possible region, there is" + " no need for streaming."); + this->SetNumberOfDivisionsStrippedStreaming(m_NumberOfDivisions); + } + else + { + FakeOutputType * fakeOut = static_cast<FakeOutputType *>( + this->itk::ProcessObject::GetOutput(0)); + RegionType region = fakeOut->GetLargestPossibleRegion(); + m_StreamingManager->PrepareStreaming(fakeOut, region); + m_NumberOfDivisions = m_StreamingManager->GetNumberOfSplits(); + // Check this number of division is compatible with all inputs + bool nbDivValid = false; + while ( (!nbDivValid) && 1 < m_NumberOfDivisions) + { + unsigned int smallestNbDiv = m_NumberOfDivisions; + for (unsigned int i = 0; i < m_SinkList.size(); ++i) + { + unsigned int div = m_StreamingManager->GetSplitter()->GetNumberOfSplits( + m_SinkList[i]->GetInput()->GetLargestPossibleRegion(), + m_NumberOfDivisions); + smallestNbDiv = std::min(div, smallestNbDiv); + } + if (smallestNbDiv == m_NumberOfDivisions) + { + nbDivValid = true; + } + else + { + m_NumberOfDivisions = smallestNbDiv; + } + } + if (m_NumberOfDivisions == 1) + { + otbWarningMacro("Can't find a common split scheme between all inputs, streaming disabled\n"); + } + otbMsgDebugMacro(<< "Number Of Stream Divisions : " << m_NumberOfDivisions); } - // TODO : instead of inputPtr, use an output of MultiImageWriter - m_StreamingManager->PrepareStreaming(inputPtr, inputRegion); - m_NumberOfDivisions = m_StreamingManager->GetNumberOfSplits(); - otbMsgDebugMacro(<< "Number Of Stream Divisions : " << m_NumberOfDivisions); } void @@ -232,18 +267,18 @@ MultiImageFileWriter return; } + // Initialize streaming + this->InitializeStreaming(); + /** * Prepare all the outputs. This may deallocate previous bulk data. */ - this->PrepareOutputs(); + //this->PrepareOutputs(); this->SetAbortGenerateData(0); this->SetProgress(0.0); this->m_Updating = true; - // Initialize streaming - this->InitializeStreaming(); - /** * Tell all Observers that the filter is starting */ @@ -370,22 +405,39 @@ MultiImageFileWriter { Superclass::GenerateInputRequestedRegion(); + // Approximate conversion of output requested region into each input, + // but this is only to have a consistent pipeline memory estimation. int numInputs = m_SinkList.size(); //this->GetNumberOfInputs(); - for (int i = 0; i < numInputs; ++i) - { - ImageBaseType* inputPtr = m_SinkList[i]->GetInput(); //const_cast<ImageBaseType*>(this->GetInput(i)); + FakeOutputType* fakeOut = static_cast<FakeOutputType *>( + this->itk::ProcessObject::GetOutput(0)); - if(!inputPtr) + if (numInputs) + { + RegionType refLargest = fakeOut->GetLargestPossibleRegion(); + RegionType refRequest = fakeOut->GetRequestedRegion(); + IndexType idxLargest = refLargest.GetIndex(); + SizeType sizeLargest = refLargest.GetSize(); + IndexType idxRequest = refRequest.GetIndex(); + SizeType sizeRequest = refRequest.GetSize(); + for (int i = 0; i < numInputs; ++i) { - return; + ImageBaseType* inputPtr = m_SinkList[i]->GetInput(); //const_cast<ImageBaseType*>(this->GetInput(i)); + if(!inputPtr) + { + return; + } + RegionType region = inputPtr->GetLargestPossibleRegion(); + IndexType idx = region.GetIndex(); + SizeType size = region.GetSize(); + idx[0] += size[0] * (idxRequest[0] - idxLargest[0]) / sizeLargest[0]; + idx[1] += size[1] * (idxRequest[1] - idxLargest[1]) / sizeLargest[1]; + size[0] *= sizeRequest[0] / sizeLargest[0]; + size[1] *= sizeRequest[1] / sizeLargest[1]; + region.SetIndex(idx); + region.SetSize(size); + inputPtr->SetRequestedRegion(region); } - RegionType lregion = inputPtr->GetLargestPossibleRegion(); - SizeType rsize; - rsize.Fill(0); - lregion.SetSize(rsize); - - inputPtr->SetRequestedRegion(lregion); } } @@ -414,7 +466,10 @@ MultiImageFileWriter //~ region.SetIndex(1, region.GetIndex(1) + sink->GetTopMarginTrimSize()); //~ region.SetSize(1, region.GetSize(1) - sink->GetTopMarginTrimSize() - sink->GetBottomMarginTrimSize()); - // TODO : call splitter + m_StreamingManager->GetSplitter()->GetSplit( + m_CurrentDivision, + m_NumberOfDivisions, + region); return region; } -- GitLab From baee48a73dfb3b1453024034294b72394e2fc9ed Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 21 Nov 2017 10:46:06 +0100 Subject: [PATCH 097/567] ENH: fix computation of number of divisions --- .../ImageIO/include/otbMultiImageFileWriter.h | 12 ++++++----- .../include/otbMultiImageFileWriter.txx | 6 +++--- .../ImageIO/src/otbMultiImageFileWriter.cxx | 20 +++++++++++++------ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h index 2e2d3bd879..fd72fdc0f8 100644 --- a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h @@ -45,7 +45,7 @@ namespace otb */ class MultiImageFileWriter: public itk::ProcessObject { - friend class Sink; + //~ friend class Sink; public: /** Standard class typedefs. */ typedef MultiImageFileWriter Self; @@ -175,7 +175,7 @@ public: Sink<TImage> * sink = new Sink<TImage>(inputPtr, fileName); m_SinkList.push_back(SinkBase::Pointer(sink)); unsigned int size = m_SinkList.size(); - this->SetNumberOfInputs(size); + //~ this->SetNumberOfInputs(size); this->SetNthInput(size - 1, const_cast<itk::DataObject*>(dynamic_cast<const itk::DataObject*>(inputPtr))); } @@ -342,7 +342,7 @@ private: typename otb::ImageFileWriter<TImage>::Pointer m_Writer; /** An ImageIO used to actually write data to a file */ - itk::ImageIOBase::Pointer m_ImageIO; + otb::ImageIOBase::Pointer m_ImageIO; /** The current file number into which data is written */ //~ int m_CurrentFileIndex; @@ -365,8 +365,10 @@ private: std::vector<RegionType> m_StreamRegionList; }; -} // end of namespace s2ipf +} // end of namespace otb -//~ #include "otbMultiImageFileWriter.txx" +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbMultiImageFileWriter.txx" +#endif #endif // otbMultiImageFileWriter_h diff --git a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx index 81417a60ea..ab76c0991b 100644 --- a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx @@ -36,8 +36,8 @@ MultiImageFileWriter::Sink<TImage> const std::string & fileName): SinkBase(dynamic_cast<const ImageBaseType*>(inputImage.GetPointer())), //~ m_FileName(fileName), - m_ImageIO(NULL), - m_Writer(otb::ImageFileWriter<TImage>::New()) + m_Writer(otb::ImageFileWriter<TImage>::New()), + m_ImageIO(NULL) { m_Writer->SetFileName(fileName); m_Writer->SetInput(inputImage); @@ -167,7 +167,7 @@ MultiImageFileWriter::Sink<TImage> } //~ this->SetIORegion(ioRegion); m_ImageIO->SetIORegion(ioRegion); - m_Writer->GenerateData(); + m_Writer->UpdateOutputData(nullptr); //~ if( ! m_UseImageIO ) return; //~ diff --git a/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx b/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx index 21344a2026..57ad6249a0 100644 --- a/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx +++ b/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx @@ -190,6 +190,8 @@ MultiImageFileWriter RegionType region = fakeOut->GetLargestPossibleRegion(); m_StreamingManager->PrepareStreaming(fakeOut, region); m_NumberOfDivisions = m_StreamingManager->GetNumberOfSplits(); + // DEBUG + std::cout << "NbDiv :"<< m_NumberOfDivisions << std::endl; // Check this number of division is compatible with all inputs bool nbDivValid = false; while ( (!nbDivValid) && 1 < m_NumberOfDivisions) @@ -209,6 +211,8 @@ MultiImageFileWriter else { m_NumberOfDivisions = smallestNbDiv; + // DEBUG + std::cout << "Div "<< m_NumberOfDivisions << " -> "<< smallestNbDiv << std::endl; } } if (m_NumberOfDivisions == 1) @@ -253,6 +257,7 @@ MultiImageFileWriter { m_SinkList[inputIndex]->WriteImageInformation(); } + this->GenerateOutputInformation(); } void @@ -320,6 +325,9 @@ MultiImageFileWriter for(int inputIndex = 0; inputIndex < numInputs; ++inputIndex) { m_StreamRegionList[inputIndex] = GetStreamRegion(inputIndex); + // DEBUG + std::cout << "Region #"<<m_CurrentDivision<<", Image #"<<inputIndex << + ", Height : "<< m_StreamRegionList[inputIndex].GetSize(1) << std::endl; } // NOTE : this reset was probably designed to work with the next section @@ -356,12 +364,12 @@ MultiImageFileWriter inputPtr->PropagateRequestedRegion(); } - for(int inputIndex = 0; inputIndex < numInputs; ++inputIndex) - { - ImageBaseType* inputPtr = m_SinkList[inputIndex]->GetInput(); // const_cast<ImageBaseType*>(this->GetInput(inputIndex)); - //RegionType streamRegion = GetStreamRegion(inputIndex); - inputPtr->UpdateOutputData(); - } + //~ for(int inputIndex = 0; inputIndex < numInputs; ++inputIndex) + //~ { + //~ ImageBaseType* inputPtr = m_SinkList[inputIndex]->GetInput(); // const_cast<ImageBaseType*>(this->GetInput(inputIndex)); + //~ //RegionType streamRegion = GetStreamRegion(inputIndex); + //~ inputPtr->UpdateOutputData(); + //~ } /** Call GenerateData to write streams to files if needed */ this->GenerateData(); -- GitLab From fedeac5138ab7b2467991b45144db44fc831b9bc Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 21 Nov 2017 10:47:29 +0100 Subject: [PATCH 098/567] TEST: add tests for MultiImageFileWriter --- Modules/IO/ImageIO/test/CMakeLists.txt | 29 +++++++++ .../IO/ImageIO/test/otbImageIOTestDriver.cxx | 1 + .../test/otbMultiImageFileWriterTest.cxx | 65 +++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 Modules/IO/ImageIO/test/otbMultiImageFileWriterTest.cxx diff --git a/Modules/IO/ImageIO/test/CMakeLists.txt b/Modules/IO/ImageIO/test/CMakeLists.txt index aac49fcdea..110b25410e 100644 --- a/Modules/IO/ImageIO/test/CMakeLists.txt +++ b/Modules/IO/ImageIO/test/CMakeLists.txt @@ -76,6 +76,7 @@ otbImageIOFactoryNew.cxx otbCompareWritingComplexImage.cxx otbImageFileReaderOptBandTest.cxx otbImageFileWriterOptBandTest.cxx +otbMultiImageFileWriterTest.cxx ) add_executable(otbImageIOTestDriver ${OTBImageIOTests}) @@ -1339,3 +1340,31 @@ otb_add_test(NAME ioTvImageIOToWriterOptions_OptBandReorgTest COMMAND otbImageIO ${TEMP}/QB_Toulouse_Ortho_XS_WriterOptBandReorg.tif?bands=2,:,-3,2:-1 4 ) + +otb_add_test(NAME ioTvMultiImageFileWriter_SameSize + COMMAND otbImageIOTestDriver + --compare-n-images ${EPSILON_9} 2 + ${INPUTDATA}/GomaAvant.png + ${TEMP}/ioTvMultiImageFileWriter_SameSize1.tif + ${INPUTDATA}/GomaApres.png + ${TEMP}/ioTvMultiImageFileWriter_SameSize2.tif + otbMultiImageFileWriterTest + ${INPUTDATA}/GomaAvant.png + ${INPUTDATA}/GomaApres.png + ${TEMP}/ioTvMultiImageFileWriter_SameSize1.tif + ${TEMP}/ioTvMultiImageFileWriter_SameSize2.tif + 50) + +otb_add_test(NAME ioTvMultiImageFileWriter_DiffSize + COMMAND otbImageIOTestDriver + --compare-n-images ${EPSILON_9} 2 + ${INPUTDATA}/GomaAvant.png + ${TEMP}/ioTvMultiImageFileWriter_DiffSize1.tif + ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif + ${TEMP}/ioTvMultiImageFileWriter_DiffSize2.tif + otbMultiImageFileWriterTest + ${INPUTDATA}/GomaAvant.png + ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif + ${TEMP}/ioTvMultiImageFileWriter_DiffSize1.tif + ${TEMP}/ioTvMultiImageFileWriter_DiffSize2.tif + 25) diff --git a/Modules/IO/ImageIO/test/otbImageIOTestDriver.cxx b/Modules/IO/ImageIO/test/otbImageIOTestDriver.cxx index fb2aa583aa..4a7ff9409a 100644 --- a/Modules/IO/ImageIO/test/otbImageIOTestDriver.cxx +++ b/Modules/IO/ImageIO/test/otbImageIOTestDriver.cxx @@ -154,4 +154,5 @@ void RegisterTests() REGISTER_TEST(otbCompareWritingComplexImageTest); REGISTER_TEST(otbImageFileReaderOptBandTest); REGISTER_TEST(otbImageFileWriterOptBandTest); + REGISTER_TEST(otbMultiImageFileWriterTest); } diff --git a/Modules/IO/ImageIO/test/otbMultiImageFileWriterTest.cxx b/Modules/IO/ImageIO/test/otbMultiImageFileWriterTest.cxx new file mode 100644 index 0000000000..77d6ede243 --- /dev/null +++ b/Modules/IO/ImageIO/test/otbMultiImageFileWriterTest.cxx @@ -0,0 +1,65 @@ +/* + * Copyright (C) CS SI + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbMultiImageFileWriter.h" +#include "otbImage.h" +#include "otbImageFileReader.h" + +int otbMultiImageFileWriterTest(int argc, char* argv[]) +{ + typedef unsigned short PixelType1; + typedef otb::Image<PixelType1, 2> ImageType1; + typedef otb::ImageFileReader<ImageType1> ReaderType1; + + typedef double PixelType2; + typedef otb::Image<PixelType2, 2> ImageType2; + typedef otb::ImageFileReader<ImageType2> ReaderType2; + + typedef otb::MultiImageFileWriter WriterType; + + if (argc < 6) + { + std::cout << "Usage: " << argv[0] << " inputImageFileName1 inputImageFileName2 outputImageFileName1 outputImageFileName2 numberOfLinesPerStrip\n"; + return EXIT_FAILURE; + } + + const char * inputImageFileName1 = argv[1]; + const char * inputImageFileName2 = argv[2]; + const std::string outputImageFileName1 = argv[3]; + const std::string outputImageFileName2 = argv[4]; + const int numberOfLinesPerStrip = atoi(argv[5]); + + ReaderType1::Pointer reader1 = ReaderType1::New(); + reader1->SetFileName( inputImageFileName1 ); + + ReaderType2::Pointer reader2 = ReaderType2::New(); + reader2->SetFileName( inputImageFileName2 ); + + WriterType::Pointer writer = WriterType::New(); + writer->AddInputImage( reader1->GetOutput(), outputImageFileName1); + writer->AddInputImage( reader2->GetOutput(), outputImageFileName2); + writer->SetNumberOfLinesStrippedStreaming( numberOfLinesPerStrip ); + + writer->Update(); + + std::cout << writer << std::endl; + + return EXIT_SUCCESS; +} -- GitLab From b6ba91b4a3a41bfd34e4bf47be4deb3ba595117c Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 21 Nov 2017 11:11:27 +0100 Subject: [PATCH 099/567] ENH: add complex output pixel type to the Qtwidget --- .../QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx index 140ff6534f..b70cd5557a 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx @@ -75,6 +75,8 @@ void QtWidgetOutputImageParameter::DoCreateWidget() m_ComboBox->addItem( "uint 32"); m_ComboBox->addItem( "float"); m_ComboBox->addItem( "double"); + m_ComboBox->addItem( "cfloat"); + m_ComboBox->addItem( "cdouble"); m_ComboBox->setCurrentIndex(m_OutputImageParam->GetPixelType()); connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(SetPixelType(int)) ); connect( m_ComboBox, SIGNAL(currentIndexChanged(int)), GetModel(), SLOT(NotifyUpdate()) ); -- GitLab From 840e0e948b0822311499e3a4dfa0af2a0254b155 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 21 Nov 2017 11:31:36 +0100 Subject: [PATCH 100/567] DOC: clean comments, update doxygen --- .../ImageIO/include/otbMultiImageFileWriter.h | 147 +++----------- .../include/otbMultiImageFileWriter.txx | 184 +----------------- .../ImageIO/src/otbMultiImageFileWriter.cxx | 63 ++---- 3 files changed, 35 insertions(+), 359 deletions(-) diff --git a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h index fd72fdc0f8..6dac383dcf 100644 --- a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h @@ -27,8 +27,6 @@ #include "itkProcessObject.h" #include "itkImageIOBase.h" -//#include "s2ipfImageRegionFixedSplitter.h" - #include <boost/shared_ptr.hpp> namespace otb @@ -36,16 +34,15 @@ namespace otb /** \class MultiImageFileWriter * \brief Streams a pipeline with multiple outputs. - * It optionally writes each output to a file, and can also separate each - * output into several granules files (use SetGranuleGenerationMode). Inputs - * are connected to the writer using the AddInput method. - * The streaming occurs by strips. Each output may have a different resolution, - * specified at the AddInput call, and the strip size is proportional to the - * resolution. + * It writes each output to a file. Inputs + * are connected to the writer using the AddInputImage method. + * The type of streaming can be chosen. Each output may have a different size. + * When the user gives a number of lines per strip or a tile size, the value + * is interpreted on the first input to deduce the number of streams. This + * number of streams is then used to split the other inputs. */ class MultiImageFileWriter: public itk::ProcessObject { - //~ friend class Sink; public: /** Standard class typedefs. */ typedef MultiImageFileWriter Self; @@ -65,22 +62,6 @@ public: typedef ImageBaseType::SizeType SizeType; typedef ImageBaseType::SizeValueType SizeValueType; - //typedef ImageRegionFixedSplitter<ImageBaseType::ImageDimension> SplitterType; - - /** Return the StreamingManager object responsible for dividing - * the region to write */ - //~ StreamingManagerType* GetStreamingManager(void) - //~ { - //~ return m_StreamingManager; - //~ } - - /** Set a user-specified implementation of StreamingManager - * used to divide the largest possible region in several divisions */ - //~ void SetStreamingManager(StreamingManagerType* streamingManager) - //~ { - //~ m_StreamingManager = streamingManager; - //~ } - /** Set the streaming mode to 'stripped' and configure the number of strips * which will be used to stream the image */ void SetNumberOfDivisionsStrippedStreaming(unsigned int nbDivisions); @@ -131,34 +112,6 @@ public: virtual void UpdateOutputData(itk::DataObject * itkNotUsed(output)); - /** Sets the number of lines used in stripped streaming for an input with - resolutionFactor == 1.0 . This number is actually multiplied by the resolution - factor to obtain the size of the strip for each input image. */ - //~ itkSetMacro(NumberOfLinesPerStrip, int); - //~ itkGetMacro(NumberOfLinesPerStrip, int); - - /** Set the number of rows per granule for an image with resolution factor 1.0 */ - //~ itkSetMacro(NumberOfRowsPerGranule, int); - //~ itkGetMacro(NumberOfRowsPerGranule, int); - - /** Specify whether granules are to be generated. If false, a single file is - generated for each input */ - //~ itkSetMacro(GranuleGenerationMode, bool); - //~ itkGetConstReferenceMacro(GranuleGenerationMode, bool); - //~ itkBooleanMacro(GranuleGenerationMode); - - /** Set the compression On or Off */ - //~ itkSetMacro(UseCompression, bool); - //~ itkGetConstReferenceMacro(UseCompression, bool); - //~ itkBooleanMacro(UseCompression); - - /** - * Enable/disable writing of a .geom file with the ossim keyword list along with the written image - */ - //~ itkSetMacro(WriteGeomFile, bool); - //~ itkGetMacro(WriteGeomFile, bool); - //~ itkBooleanMacro(WriteGeomFile); - /** Connect a new input to the multi-writer. Only the input pointer is * required. If the filename list is empty, * streaming will occur without writing. It the filename list contains more @@ -175,27 +128,9 @@ public: Sink<TImage> * sink = new Sink<TImage>(inputPtr, fileName); m_SinkList.push_back(SinkBase::Pointer(sink)); unsigned int size = m_SinkList.size(); - //~ this->SetNumberOfInputs(size); this->SetNthInput(size - 1, const_cast<itk::DataObject*>(dynamic_cast<const itk::DataObject*>(inputPtr))); } - //~ /** Connect a new input to the multi-writer. Takes a single filename instead - //~ of a list of filenames */ - //~ template <class TImage> - //~ void AddInput(const TImage* inputPtr, const std::string & fileName = std::string(), double resolutionFactor = 1.0, int topMarginTrimSize = 0, int bottomMarginTrimSize = 0) - //~ { - //~ std::vector<std::string> fileNameList; - //~ fileNameList.push_back(fileName); - //~ this->AddInput(inputPtr, fileNameList, resolutionFactor, topMarginTrimSize, bottomMarginTrimSize); - //~ } -//~ - //~ /** This version of AddInput takes no input filename */ - //~ template <class TImage> - //~ void AddInput(const TImage* inputPtr, double resolutionFactor = 1.0, int topMarginTrimSize = 0, int bottomMarginTrimSize = 0) - //~ { - //~ this->AddInput(inputPtr, std::vector<std::string>(), resolutionFactor, topMarginTrimSize, bottomMarginTrimSize); - //~ } - virtual void UpdateOutputInformation(); virtual void Update() @@ -205,15 +140,17 @@ public: } protected: - /** SetInput is changed to protected. Use AddInput to connect the pipeline to - * the writer + /** SetInput is changed to protected. Use AddInputImage to connect the + * pipeline to the writer */ -// virtual void SetInput(const ImageBaseType* image) { this->Superclass::SetInput(image); } + virtual void SetInput(const itk::ProcessObject::DataObjectIdentifierType & key, itk::DataObject* image) + { this->Superclass::SetInput(key, image); } - /** SetInput is changed to protected. Use AddInput to connect the pipeline to - * the writer + /** SetNthInput is changed to protected. Use AddInputImage to connect the + * pipeline to the writer */ -// virtual void SetInput(unsigned int i, const ImageBaseType* image) { this->Superclass::SetInput(i, image); } + virtual void SetNthInput(itk::ProcessObject::DataObjectPointerArraySizeType i, itk::DataObject* image) + { this->Superclass::SetNthInput(i, image); } MultiImageFileWriter(); virtual ~MultiImageFileWriter() {} @@ -221,22 +158,23 @@ protected: /** GenerateData calls the Write method for each connected input */ virtual void GenerateData(void); + /** GenerateInputRequestedRegion can predict approximate input regions + * based on the requested region of the fake output. Only usefull for + * pipeline memory print estimation + */ virtual void GenerateInputRequestedRegion(); /** Computes the number of divisions */ virtual void InitializeStreaming(); - /** Goes up the pipeline starting at imagePtr, resetting all requested regions to a null region */ + /** Goes up the pipeline starting at imagePtr, resetting all requested regions + * to a null region. This may be usefull when mixing inputs of different + * resolutions. */ void ResetAllRequestedRegions(ImageBaseType* imagePtr); /** Returns the current stream region of the given input */ virtual RegionType GetStreamRegion(int inputIndex); - /** This is the number of lines used in stripped streaming for an input with - resolutionFactor == 1.0 . This number is actually multiplied by the resolution - factor to obtain the size of the strip for each input image. */ - //int m_NumberOfLinesPerStrip; - void operator =(const MultiImageFileWriter&); //purposely not implemented void ObserveSourceFilterProgress(itk::Object* object, const itk::EventObject & event) @@ -265,8 +203,6 @@ private: typedef StreamingManager<FakeOutputType> StreamingManagerType; /** Streaming manager used for the N inputs */ StreamingManagerType::Pointer m_StreamingManager; - //Granule Generation mode - //~ bool m_GranuleGenerationMode; //Division parameters unsigned int m_NumberOfDivisions; @@ -276,20 +212,7 @@ private: bool m_IsObserving; unsigned long m_ObserverID; - /** compression */ - //~ bool m_UseCompression; - //~ bool m_UseInputMetaDataDictionary; // whether to use the - // MetaDataDictionary from the - // input or not. - //~ bool m_WriteGeomFile; // Write a geom file to store the kwl - - /** Number of rows per granule for an image with resolution factor 1.0 (i.e. a - * 10m band) - */ - //~ int m_NumberOfRowsPerGranule; - - //~ SplitterType::Pointer m_Splitter; - + /** Internal base wrapper class to handle each ImageFileWriter */ class SinkBase { public: @@ -310,12 +233,11 @@ private: }; /** \class Sink - * Parameters and methods specific to a single input + * Wrapper class for each ImageFileWriter */ template <class TImage> class Sink : public SinkBase { - //~ friend class MultiImageFileWriter; public: Sink() {} Sink(typename TImage::ConstPointer inputImage, @@ -327,35 +249,12 @@ private: virtual void Write(const RegionType & streamRegion); virtual bool CanStreamWrite(); typedef boost::shared_ptr<Sink> Pointer; - protected: - //~ void CreateImageFile(int fileIndex); - - /** There may be several output filenames in the case of granule mode - * generation. Or there may be none if no output file is required. - */ - //~ std::string m_FileName; - - /** Specifies whether image is actually written to a file */ - //~ bool m_UseImageIO; private: /** Actual writer for this image */ typename otb::ImageFileWriter<TImage>::Pointer m_Writer; /** An ImageIO used to actually write data to a file */ otb::ImageIOBase::Pointer m_ImageIO; - - /** The current file number into which data is written */ - //~ int m_CurrentFileIndex; - - /** The image region to write to the current file */ - //~ RegionType m_CurrentFileRegion; - - /** The height of the file, which can be the size of a granule in granule - generation mode, or else the size of the input image (minus margins). */ - //~ int m_FileHeight; - - /** A pointer to the writer to gain access to its fields */ - //~ typename MultiImageFileWriter::Pointer m_Writer; }; /** The list of inputs and their associated parameters, built using AddInput */ diff --git a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx index ab76c0991b..01358fa4ea 100644 --- a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx @@ -23,9 +23,7 @@ #include "otbMultiImageFileWriter.h" #include "otbImageIOFactory.h" -//~ #include "itkImageFileWriter.h" #include "otbMacro.h" -//#include "s2ipfFileUtils.h" namespace otb { @@ -35,7 +33,6 @@ MultiImageFileWriter::Sink<TImage> ::Sink(typename TImage::ConstPointer inputImage, const std::string & fileName): SinkBase(dynamic_cast<const ImageBaseType*>(inputImage.GetPointer())), - //~ m_FileName(fileName), m_Writer(otb::ImageFileWriter<TImage>::New()), m_ImageIO(NULL) { @@ -61,94 +58,6 @@ MultiImageFileWriter::Sink<TImage> { m_Writer->UpdateOutputInformation(); m_ImageIO = m_Writer->GetImageIO(); - - - //~ // new ImageIO: close current ImageIO if exists and open the new one - //~ if (! m_ImageIO.IsNull()) { /* nothing to do to close IO ? */ } - //~ m_CurrentFileIndex = fileIndex; - //~ m_ImageIO = ImageIOFactory::CreateImageIO( m_FileNameList[fileIndex].c_str(), otb::ImageIOFactory::WriteMode ); -//~ - //~ if (m_ImageIO.IsNull()) - //~ { - //~ itk::ImageFileWriterException e(__FILE__, __LINE__); - //~ std::ostringstream msg; - //~ msg << " Could not create IO object for file " << m_FileNameList[fileIndex].c_str() << std::endl; - //~ msg << " Tried to create one of the following:" << std::endl; - //~ std::list<itk::LightObject::Pointer> allobjects = itk::ObjectFactoryBase::CreateAllInstance("itkImageIOBase"); - //~ for (std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin(); i != allobjects.end(); ++i) - //~ { - //~ itk::ImageIOBase* io = dynamic_cast<itk::ImageIOBase*>(i->GetPointer()); - //~ msg << " " << io->GetNameOfClass() << std::endl; - //~ } - //~ msg << " You probably failed to set a file suffix, or" << std::endl; - //~ msg << " set the suffix to an unsupported type." << std::endl; - //~ e.SetDescription(msg.str().c_str()); - //~ e.SetLocation(ITK_LOCATION); - //~ throw e; - //~ } -//~ - //~ m_ImageIO->SetFileName(m_FileNameList[fileIndex]); - //~ if( ! m_ImageIO->CanStreamWrite() ) - //~ { - //~ std::ostringstream oss; - //~ oss << " The ImageFactory selected for the image file <" << m_FileNameList[fileIndex] << "> does not support streaming."; - //~ throw std::runtime_error(oss.str()); - //~ } - //~ m_ImageIO->SetNumberOfDimensions(TImage::ImageDimension); - //~ // Set the region of data to write to the output file (independently of - //~ // current stream region) - //~ m_CurrentFileRegion = m_InputImage->GetLargestPossibleRegion(); - //~ m_CurrentFileRegion.SetIndex(TImage::ImageDimension - 1, fileIndex * m_FileHeight + m_TopMarginTrimSize); - //~ m_CurrentFileRegion.SetSize(TImage::ImageDimension - 1, m_FileHeight); -//~ - //~ const typename TImage::SpacingType& spacing = m_InputImage->GetSpacing(); - //~ const typename TImage::PointType& origin = m_InputImage->GetOrigin(); - //~ const typename TImage::DirectionType& direction = m_InputImage->GetDirection(); -//~ - //~ for (unsigned int i = 0; i < TImage::ImageDimension; ++i) - //~ { - //~ // Final image size - //~ m_ImageIO->SetDimensions(i, m_CurrentFileRegion.GetSize(i)); - //~ m_ImageIO->SetSpacing(i, spacing[i]); - //~ m_ImageIO->SetOrigin(i, origin[i]); // TODO: fix origin for each file - //~ vnl_vector<double> axisDirection(TImage::ImageDimension); - //~ // Please note: direction cosines are stored as columns of the - //~ // direction matrix - //~ for (unsigned int j = 0; j < TImage::ImageDimension; ++j) - //~ { - //~ axisDirection[j] = direction[j][i]; - //~ } - //~ m_ImageIO->SetDirection(i, axisDirection); - //~ } - //~ m_ImageIO->SetUseCompression(m_Writer->m_UseCompression); -//~ /* - //~ if (! hasHDRExtension(m_FileNameList[fileIndex])) // This test will disable the creation of a .raw.aux.xml file in the case of raw/hdr format - //~ { - //~ m_ImageIO->SetMetaDataDictionary(m_InputImage->GetMetaDataDictionary()); - //~ } -//~ */ - //~ m_ImageIO->SetMetaDataDictionary(m_InputImage->GetMetaDataDictionary()); -//~ - //~ /** Create Image file */ - //~ m_ImageIO->WriteImageInformation(); -//~ - //~ if (strcmp(m_InputImage->GetNameOfClass(), "VectorImage") == 0) - //~ { - //~ typedef typename TImage::InternalPixelType VectorImagePixelType; - //~ m_ImageIO->SetPixelTypeInfo(typeid(VectorImagePixelType)); -//~ - //~ typedef typename TImage::AccessorFunctorType AccessorFunctorType; - //~ const TImage* inputImage = dynamic_cast<const TImage*>(m_InputImage.GetPointer()); - //~ m_ImageIO->SetNumberOfComponents(AccessorFunctorType::GetVectorLength(inputImage)); - //~ } - //~ else - //~ { - //~ // Set the pixel and component type; the number of components. - //~ typedef typename TImage::PixelType ImagePixelType; - //~ m_ImageIO->SetPixelTypeInfo(typeid(ImagePixelType)); - //~ } - - } template <class TImage> @@ -156,106 +65,15 @@ void MultiImageFileWriter::Sink<TImage> ::Write(const RegionType & streamRegion) { - // Write the whole image + // Write the image stream itk::ImageIORegion ioRegion(TImage::ImageDimension); for (unsigned int i = 0; i < TImage::ImageDimension; ++i) { ioRegion.SetSize(i, streamRegion.GetSize(i)); ioRegion.SetIndex(i, streamRegion.GetIndex(i)); - //Set the ioRegion index using the shifted index ( (0,0 without box parameter)) - //~ ioRegion.SetIndex(i, streamRegion.GetIndex(i) - m_ShiftOutputIndex[i]); } - //~ this->SetIORegion(ioRegion); m_ImageIO->SetIORegion(ioRegion); m_Writer->UpdateOutputData(nullptr); - - //~ if( ! m_UseImageIO ) return; -//~ - //~ if(!m_Writer->GetGranuleGenerationMode() && m_FileNameList.size() > 1) - //~ { - //~ throw std::runtime_error( "There must be at most one output image filename when granule generation mode is disabled" ); - //~ } -//~ - //~ // Find first file into which streamRegion should write - //~ const IndexType & streamIndex = streamRegion.GetIndex(); - //~ const SizeType & streamSize = streamRegion.GetSize(); -//~ -//~ - //~ int firstFileIndex = 0; - //~ int lastFileIndex = 0; - //~ if(m_Writer->m_GranuleGenerationMode) - //~ { - //~ firstFileIndex = (streamIndex[1] - m_TopMarginTrimSize) / (m_Writer->m_NumberOfRowsPerGranule * m_ResolutionFactor); - //~ lastFileIndex = (streamIndex[1] - m_TopMarginTrimSize + streamSize[1] - 1) / (m_Writer->m_NumberOfRowsPerGranule * m_ResolutionFactor); - //~ // If lastFileIndex is greater than the index of the last filename, then use - //~ // the last filename - //~ lastFileIndex = std::min<int>(lastFileIndex, m_FileNameList.size() - 1); - //~ } -//~ - //~ m_FileHeight = (m_Writer->m_GranuleGenerationMode)?m_Writer->m_NumberOfRowsPerGranule * m_ResolutionFactor : (m_InputImage->GetLargestPossibleRegion().GetSize(1) - m_TopMarginTrimSize - m_BottomMarginTrimSize); -//~ - //~ for( int fileIndex = firstFileIndex; fileIndex <= lastFileIndex; ++fileIndex ) - //~ { - //~ // Create the image file only if the imageIO is not already open for this file - //~ if(m_CurrentFileIndex != fileIndex) - //~ { - //~ CreateImageFile(fileIndex); - //~ } - //~ // Write part of streamRegion matching m_CurrentFileRegion - //~ IndexValueType streamLastIndex = streamRegion.GetIndex(TImage::ImageDimension-1) + streamRegion.GetSize(TImage::ImageDimension - 1) - 1; - //~ IndexValueType fileLastIndex = m_CurrentFileRegion.GetIndex(TImage::ImageDimension-1) + m_CurrentFileRegion.GetSize(TImage::ImageDimension - 1) - 1; - //~ RegionType streamRegionForCurrentFile = streamRegion; - //~ IndexValueType streamStartIndexForCurrentFile = std::max( - //~ streamRegion.GetIndex(TImage::ImageDimension - 1), - //~ m_CurrentFileRegion.GetIndex(TImage::ImageDimension - 1) - //~ ); - //~ streamRegionForCurrentFile.SetIndex(TImage::ImageDimension - 1, streamStartIndexForCurrentFile ); - //~ streamRegionForCurrentFile.SetSize( - //~ TImage::ImageDimension-1, std::min( - //~ streamLastIndex - streamStartIndexForCurrentFile + 1, - //~ fileLastIndex - streamStartIndexForCurrentFile + 1 - //~ ) - //~ ); -//~ - //~ const TImage* inputImage = dynamic_cast<const TImage*>(m_InputImage.GetPointer()); - //~ const void* dataPtr = (const void*) inputImage->GetBufferPointer(); -//~ - //~ itk::ImageIORegion ioRegion(TImage::ImageDimension); - //~ itk::ImageIORegionAdaptor<TImage::ImageDimension>::Convert(streamRegionForCurrentFile, ioRegion, m_CurrentFileRegion.GetIndex()); - //~ m_ImageIO->SetIORegion(ioRegion); -//~ - //~ RegionType bufferedRegion = m_InputImage->GetBufferedRegion(); -//~ - //~ typename TImage::Pointer cacheImage; - //~ // before this test, bad stuff would happen when they don't match - //~ if (bufferedRegion != streamRegionForCurrentFile) - //~ { - //~ otbGenericMsgDebugMacro("Requested stream region does not match generated output"); - //~ otbGenericMsgDebugMacro("Extracting output region from buffered region"); -//~ - //~ cacheImage = TImage::New(); - //~ cacheImage->CopyInformation(m_InputImage); - //~ cacheImage->SetBufferedRegion(streamRegionForCurrentFile); - //~ cacheImage->Allocate(); - //~ typedef itk::ImageRegionConstIterator<TImage> ConstIteratorType; - //~ typedef itk::ImageRegionIterator<TImage> IteratorType; -//~ - //~ ConstIteratorType in(inputImage, streamRegionForCurrentFile); - //~ IteratorType out(cacheImage, streamRegionForCurrentFile); -//~ - //~ // copy the data into a buffer to match the ioregion - //~ for (in.GoToBegin(), out.GoToBegin(); !in.IsAtEnd(); ++in, ++out) - //~ { - //~ out.Set(in.Get()); - //~ } -//~ - //~ dataPtr = (const void*) cacheImage->GetBufferPointer(); -//~ - //~ } -//~ - //~ // Write to file - //~ m_ImageIO->Write(dataPtr); - //~ } } } // end of namespace otb diff --git a/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx b/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx index 57ad6249a0..a3f32a8d36 100644 --- a/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx +++ b/Modules/IO/ImageIO/src/otbMultiImageFileWriter.cxx @@ -20,27 +20,17 @@ #include "otbMultiImageFileWriter.h" #include "otbImageIOFactory.h" -//~ #include "itkImageFileWriter.h" - -//#include "s2ipfSensor.h" -//~ #define S2IPF_GRANULE_HEIGHT 2304 namespace otb { MultiImageFileWriter ::MultiImageFileWriter() : - //m_NumberOfLinesPerStrip(600), - //~ m_GranuleGenerationMode(false), m_NumberOfDivisions(0), m_CurrentDivision(0), m_DivisionProgress(0.0), m_IsObserving(true), m_ObserverID(0) - //~ m_UseCompression(false), - //~ m_UseInputMetaDataDictionary(false), - //~ m_WriteGeomFile(false), - //~ m_NumberOfRowsPerGranule(S2IPF_GRANULE_HEIGHT) { // By default, we use tiled streaming, with automatic tile size // We don't set any parameter, so the memory size is retrieved from the OTB configuration options @@ -145,12 +135,6 @@ MultiImageFileWriter if(!inputPtr) itkExceptionMacro("At least one input must be connected to the writer\n"); - /** - * Determine of number of pieces to divide the input. This will be the - * minimum of what the user specified via SetNumberOfDivisionsStrippedStreaming() - * and what the Splitter thinks is a reasonable value. - */ - /** Control if the ImageIO is CanStreamWrite */ m_NumberOfDivisions = 1; bool canStream = true; @@ -185,13 +169,17 @@ MultiImageFileWriter } else { + /** + * Determine of number of pieces to divide the input. This will be the + * first estimated on the fake output, which has the same size as the + * first input. Then there is a check that each input can be split into + * this number of pieces. + */ FakeOutputType * fakeOut = static_cast<FakeOutputType *>( this->itk::ProcessObject::GetOutput(0)); RegionType region = fakeOut->GetLargestPossibleRegion(); m_StreamingManager->PrepareStreaming(fakeOut, region); m_NumberOfDivisions = m_StreamingManager->GetNumberOfSplits(); - // DEBUG - std::cout << "NbDiv :"<< m_NumberOfDivisions << std::endl; // Check this number of division is compatible with all inputs bool nbDivValid = false; while ( (!nbDivValid) && 1 < m_NumberOfDivisions) @@ -211,8 +199,6 @@ MultiImageFileWriter else { m_NumberOfDivisions = smallestNbDiv; - // DEBUG - std::cout << "Div "<< m_NumberOfDivisions << " -> "<< smallestNbDiv << std::endl; } } if (m_NumberOfDivisions == 1) @@ -275,11 +261,6 @@ MultiImageFileWriter // Initialize streaming this->InitializeStreaming(); - /** - * Prepare all the outputs. This may deallocate previous bulk data. - */ - //this->PrepareOutputs(); - this->SetAbortGenerateData(0); this->SetProgress(0.0); this->m_Updating = true; @@ -320,14 +301,10 @@ MultiImageFileWriter for (m_CurrentDivision = 0; m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateData(); m_CurrentDivision++, m_DivisionProgress = 0, this->UpdateFilterProgress()) { - // Update all stream regions for(int inputIndex = 0; inputIndex < numInputs; ++inputIndex) { m_StreamRegionList[inputIndex] = GetStreamRegion(inputIndex); - // DEBUG - std::cout << "Region #"<<m_CurrentDivision<<", Image #"<<inputIndex << - ", Height : "<< m_StreamRegionList[inputIndex].GetSize(1) << std::endl; } // NOTE : this reset was probably designed to work with the next section @@ -342,13 +319,11 @@ MultiImageFileWriter for(int inputIndex = 0; inputIndex < numInputs; ++inputIndex) { - - ImageBaseType::Pointer inputPtr = m_SinkList[inputIndex]->GetInput(); // const_cast<ImageBaseType*>(this->GetInput(inputIndex)); - //RegionType streamRegion = GetStreamRegion(inputIndex); + ImageBaseType::Pointer inputPtr = m_SinkList[inputIndex]->GetInput(); RegionType inputRequestedRegion = m_StreamRegionList[inputIndex]; - const RegionType & currentInputRequestedRegion = inputPtr->GetRequestedRegion(); - if( currentInputRequestedRegion != inputPtr->GetLargestPossibleRegion() && currentInputRequestedRegion.GetNumberOfPixels() != 0) + if( currentInputRequestedRegion != inputPtr->GetLargestPossibleRegion() + && currentInputRequestedRegion.GetNumberOfPixels() != 0) { IndexType startIndex = currentInputRequestedRegion.GetIndex(); IndexType lastIndex = currentInputRequestedRegion.GetUpperIndex(); @@ -364,16 +339,8 @@ MultiImageFileWriter inputPtr->PropagateRequestedRegion(); } - //~ for(int inputIndex = 0; inputIndex < numInputs; ++inputIndex) - //~ { - //~ ImageBaseType* inputPtr = m_SinkList[inputIndex]->GetInput(); // const_cast<ImageBaseType*>(this->GetInput(inputIndex)); - //~ //RegionType streamRegion = GetStreamRegion(inputIndex); - //~ inputPtr->UpdateOutputData(); - //~ } - /** Call GenerateData to write streams to files if needed */ this->GenerateData(); - } /** @@ -403,7 +370,6 @@ MultiImageFileWriter // Mark that we are no longer updating the data in this filter this->m_Updating = false; - } @@ -430,7 +396,7 @@ MultiImageFileWriter SizeType sizeRequest = refRequest.GetSize(); for (int i = 0; i < numInputs; ++i) { - ImageBaseType* inputPtr = m_SinkList[i]->GetInput(); //const_cast<ImageBaseType*>(this->GetInput(i)); + ImageBaseType* inputPtr = m_SinkList[i]->GetInput(); if(!inputPtr) { return; @@ -453,14 +419,9 @@ void MultiImageFileWriter ::GenerateData() { - int numInputs = m_SinkList.size(); //this->GetNumberOfInputs(); - + int numInputs = m_SinkList.size(); for(int inputIndex = 0; inputIndex < numInputs; ++inputIndex) { - - //ImageBaseType* inputPtr = const_cast<ImageBaseType*>(this->GetInput(inputIndex)); - //RegionType streamRegion = GetStreamRegion(inputIndex); - m_SinkList[inputIndex]->Write(m_StreamRegionList[inputIndex]); } } @@ -471,8 +432,6 @@ MultiImageFileWriter { const SinkBase::Pointer sink = m_SinkList[inputIndex]; RegionType region = sink->GetInput()->GetLargestPossibleRegion(); - //~ region.SetIndex(1, region.GetIndex(1) + sink->GetTopMarginTrimSize()); - //~ region.SetSize(1, region.GetSize(1) - sink->GetTopMarginTrimSize() - sink->GetBottomMarginTrimSize()); m_StreamingManager->GetSplitter()->GetSplit( m_CurrentDivision, -- GitLab From ace6292dae6dcb060c8e867886c4f6305018c4bd Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 22 Nov 2017 12:03:31 +0100 Subject: [PATCH 101/567] ENH: allow reading complex image as real image and write it as complex image --- ...otbVectorImageToComplexVectorImageFilter.h | 146 +++++++++++++ .../src/otbWrapperOutputImageParameter.cxx | 202 ++++++++++++------ 2 files changed, 282 insertions(+), 66 deletions(-) create mode 100644 Modules/Filtering/ImageManipulation/include/otbVectorImageToComplexVectorImageFilter.h diff --git a/Modules/Filtering/ImageManipulation/include/otbVectorImageToComplexVectorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbVectorImageToComplexVectorImageFilter.h new file mode 100644 index 0000000000..857eea9716 --- /dev/null +++ b/Modules/Filtering/ImageManipulation/include/otbVectorImageToComplexVectorImageFilter.h @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otVectorbImageToComplexVectorImageFilter_h +#define otVectorbImageToComplexVectorImageFilter_h + +#include "itkUnaryFunctorImageFilter.h" +#include <complex> +#include <limits> +namespace otb +{ + +namespace Functor +{ +template < class InputPixelType , class OutputPixelType > class RealToComplex +{ + public : + typedef typename OutputPixelType::ValueType OutputComplexType; + typedef typename OutputComplexType::value_type OutputType; + RealToComplex() : m_Size(0) + { + m_Lower = std::numeric_limits< OutputType >::lowest(); + m_Dlower = static_cast< double > ( m_Lower ); + m_Upper = std::numeric_limits< OutputType >::max(); + m_Dupper = static_cast< double > ( m_Upper ); + } + ~RealToComplex() {} + + void SetSize(unsigned int m) + { + m_Size = m; + } + + OutputPixelType operator()( InputPixelType in ) + { + OutputPixelType out; + out.SetSize( m_Size ); + OutputType re , im ; + double reD , imD ; + for (unsigned int i = 0 ; i < m_Size ; i++ ) + { + re = static_cast < OutputType > ( in[ 2 * i ] ); + reD = static_cast < double > ( in[ 2 * i ] ); + im = static_cast < OutputType > ( in[ 2 * i + 1 ] ); + imD = static_cast < double > ( in[ 2 * i + 1 ] ); + if ( reD <= m_Dlower ) + re = m_Lower; + else if ( m_Dupper <= reD ) + re = m_Upper; + if ( imD <= m_Dlower ) + im = m_Lower; + else if ( m_Dupper <= imD ) + im = m_Upper; + + out[i] = std::complex < OutputType > ( re , im ); + } + return out; + } + + private: + unsigned int m_Size; + OutputType m_Lower , m_Upper; + double m_Dlower , m_Dupper; + +}; + +} // end namespace functor + + + +template < class TInputImage , class TOutputImage > +class VectorImageToComplexVectorImageFilter : +public itk::UnaryFunctorImageFilter< + TInputImage, TOutputImage, + Functor::RealToComplex< + typename TInputImage::PixelType, + typename TOutputImage::PixelType> > +{ +public : + /** Standard typedefs */ + typedef VectorImageToComplexVectorImageFilter Self; + typedef Functor::RealToComplex< typename TInputImage::PixelType, + typename TOutputImage::PixelType> FunctorType; + + typedef itk::UnaryFunctorImageFilter< TInputImage, + TOutputImage, FunctorType > Superclass; + + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Type macro */ + itkNewMacro( Self ); + + /** Creation through object factory macro */ + itkTypeMacro( VectorImageToComplexVectorImageFilter , ImageToImageFilter ); + + void SetSize( unsigned int m ) + { + m_Size = m; + m_SizeFlag = true; + } + +protected : + VectorImageToComplexVectorImageFilter(): m_Size(0) , m_SizeFlag(false) {} + ~VectorImageToComplexVectorImageFilter() override {} + + void UpdateOutputInformation() override + { + Superclass::UpdateOutputInformation(); + typename TOutputImage::Pointer output = this->GetOutput(); + if ( !m_SizeFlag ) + { + typename TInputImage::ConstPointer input = this->GetInput(); + m_Size = input -> GetNumberOfComponentsPerPixel() / 2; + } + this->GetFunctor().SetSize( m_Size ); + output->SetVectorLength( m_Size ); + }; + +private : + VectorImageToComplexVectorImageFilter(const Self&) = delete ; + void operator=(const Self&) = delete ; + unsigned int m_Size; + bool m_SizeFlag; +}; + +} // end namespace otb + +#endif diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 2b22c08dfb..e4e4049c4b 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -24,6 +24,7 @@ #include "otbClampVectorImageFilter.h" #include "otbImageIOFactory.h" #include "itksys/SystemTools.hxx" +#include "otbVectorImageToComplexVectorImageFilter.h" #ifdef OTB_USE_MPI @@ -225,10 +226,14 @@ ClampAndWriteImage( itk::ImageBase<2> * in , } } -template <typename TInput, typename TOutput > void ClampAndWriteVectorImage(itk::ImageBase<2> * in, otb::ImageFileWriter<TOutput > * writer, const std::string & filename, const unsigned int & ramValue) -{ - typedef otb::ClampVectorImageFilter<TInput, TOutput> ClampFilterType; - typename ClampFilterType::Pointer clampFilter = ClampFilterType::New(); +/*template <typename TInput, typename TOutput > +void +ClampAndWriteVectorImage( itk::ImageBase<2> * in , + otb::ImageFileWriter<TOutput > * writer , + const std::string & filename , + const unsigned int & ramValue , + typename itk::ImageToImageFilter< TInput , TOutput > * clampFilter = otb::ClampImageFilter< TInput , TOutput >::New() ) +{ clampFilter->SetInput( dynamic_cast<TInput*>(in)); bool useStandardWriter = true; @@ -278,10 +283,9 @@ template <typename TInput, typename TOutput > void ClampAndWriteVectorImage(itk: writer->SetAutomaticAdaptativeStreaming(ramValue); writer->Update(); } -} - +}*/ -template <class TInputImageType> +template <class TInput> void OutputImageParameter::SwitchImageWrite() { @@ -289,65 +293,72 @@ OutputImageParameter::SwitchImageWrite() { case ImagePixelType_uint8: { - ClampAndWriteImage< TInputImageType , UInt8ImageType >( m_Image , - m_UInt8Writer , - m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInputImageType , UInt8ImageType >::New() ); + ClampAndWriteImage< TInput , UInt8ImageType >( + m_Image , + m_UInt8Writer , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInput , UInt8ImageType >::New() ); break; } case ImagePixelType_int16: { - ClampAndWriteImage< TInputImageType , Int16ImageType >( m_Image , - m_Int16Writer , - m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInputImageType , Int16ImageType >::New() ); + ClampAndWriteImage< TInput , Int16ImageType >( + m_Image , + m_Int16Writer , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInput , Int16ImageType >::New() ); break; } case ImagePixelType_uint16: { - ClampAndWriteImage< TInputImageType , UInt16ImageType >( m_Image , - m_UInt16Writer , - m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInputImageType , UInt16ImageType >::New() ); + ClampAndWriteImage< TInput , UInt16ImageType >( + m_Image , + m_UInt16Writer , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInput , UInt16ImageType >::New() ); break; } case ImagePixelType_int32: { - ClampAndWriteImage< TInputImageType , Int32ImageType >( m_Image , - m_Int32Writer , - m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInputImageType , Int32ImageType >::New() ); + ClampAndWriteImage< TInput , Int32ImageType >( + m_Image , + m_Int32Writer , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInput , Int32ImageType >::New() ); break; } case ImagePixelType_uint32: { - ClampAndWriteImage< TInputImageType , UInt32ImageType >( m_Image , - m_UInt32Writer , - m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInputImageType , UInt32ImageType >::New() ); + ClampAndWriteImage< TInput , UInt32ImageType >( + m_Image , + m_UInt32Writer , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInput , UInt32ImageType >::New() ); break; } case ImagePixelType_float: { - ClampAndWriteImage< TInputImageType , FloatImageType >( m_Image , - m_FloatWriter , - m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInputImageType , FloatImageType >::New() ); + ClampAndWriteImage< TInput , FloatImageType >( + m_Image , + m_FloatWriter , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInput , FloatImageType >::New() ); break; } case ImagePixelType_double: { - ClampAndWriteImage< TInputImageType , DoubleImageType >( m_Image , - m_DoubleWriter , - m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInputImageType , DoubleImageType >::New() ); + ClampAndWriteImage< TInput , DoubleImageType >( + m_Image , + m_DoubleWriter , + m_FileName , + m_RAMValue , + otb::ClampImageFilter< TInput , DoubleImageType >::New() ); break; } default: @@ -355,7 +366,7 @@ OutputImageParameter::SwitchImageWrite() } } -template <class TInputImageType> +template <class TInput> void OutputImageParameter::SwitchCImageWrite() { @@ -363,20 +374,22 @@ OutputImageParameter::SwitchCImageWrite() { case ImagePixelType_cfloat: { - ClampAndWriteImage< TInputImageType , ComplexFloatImageType >( m_Image , - m_ComplexFloatWriter , - m_FileName , - m_RAMValue , - itk::CastImageFilter< TInputImageType , ComplexFloatImageType >::New() ); + ClampAndWriteImage< TInput , ComplexFloatImageType >( + m_Image , + m_ComplexFloatWriter , + m_FileName , + m_RAMValue , + itk::CastImageFilter< TInput , ComplexFloatImageType >::New() ); break; } case ImagePixelType_cdouble: { - ClampAndWriteImage< TInputImageType , ComplexDoubleImageType >( m_Image , - m_ComplexDoubleWriter , - m_FileName , - m_RAMValue , - itk::CastImageFilter< TInputImageType , ComplexDoubleImageType >::New() ); + ClampAndWriteImage< TInput , ComplexDoubleImageType >( + m_Image , + m_ComplexDoubleWriter , + m_FileName , + m_RAMValue , + itk::CastImageFilter< TInput , ComplexDoubleImageType >::New() ); break; } default: @@ -385,7 +398,7 @@ OutputImageParameter::SwitchCImageWrite() } -template <class TInputVectorImageType> +template <class TInput> void OutputImageParameter::SwitchVectorImageWrite() { @@ -393,37 +406,92 @@ OutputImageParameter::SwitchVectorImageWrite() { case ImagePixelType_uint8: { - ClampAndWriteVectorImage<TInputVectorImageType,UInt8VectorImageType>(m_Image,m_VectorUInt8Writer,m_FileName,m_RAMValue); + ClampAndWriteImage< TInput , UInt8VectorImageType > ( + m_Image , + m_VectorUInt8Writer , + m_FileName , + m_RAMValue , + otb::ClampVectorImageFilter< TInput , UInt8VectorImageType >::New() ); break; } case ImagePixelType_int16: { - ClampAndWriteVectorImage<TInputVectorImageType,Int16VectorImageType>(m_Image,m_VectorInt16Writer,m_FileName,m_RAMValue); + ClampAndWriteImage< TInput , Int16VectorImageType > ( + m_Image , + m_VectorInt16Writer , + m_FileName , + m_RAMValue , + otb::ClampVectorImageFilter< TInput , Int16VectorImageType >::New() ); break; } case ImagePixelType_uint16: { - ClampAndWriteVectorImage<TInputVectorImageType,UInt16VectorImageType>(m_Image,m_VectorUInt16Writer,m_FileName,m_RAMValue); + ClampAndWriteImage< TInput , UInt16VectorImageType > ( + m_Image , + m_VectorUInt16Writer , + m_FileName , + m_RAMValue , + otb::ClampVectorImageFilter< TInput , UInt16VectorImageType >::New() ); break; } case ImagePixelType_int32: { - ClampAndWriteVectorImage<TInputVectorImageType,Int32VectorImageType>(m_Image,m_VectorInt32Writer,m_FileName,m_RAMValue); + ClampAndWriteImage< TInput , Int32VectorImageType > ( + m_Image , + m_VectorInt32Writer , + m_FileName , + m_RAMValue , + otb::ClampVectorImageFilter< TInput , Int32VectorImageType >::New() ); break; } case ImagePixelType_uint32: { - ClampAndWriteVectorImage<TInputVectorImageType,UInt32VectorImageType>(m_Image,m_VectorUInt32Writer,m_FileName,m_RAMValue); + ClampAndWriteImage< TInput , UInt32VectorImageType > ( + m_Image , + m_VectorUInt32Writer , + m_FileName , + m_RAMValue , + otb::ClampVectorImageFilter< TInput , UInt32VectorImageType >::New() ); break; } case ImagePixelType_float: { - ClampAndWriteVectorImage<TInputVectorImageType,FloatVectorImageType>(m_Image,m_VectorFloatWriter,m_FileName,m_RAMValue); + ClampAndWriteImage< TInput , FloatVectorImageType > ( + m_Image , + m_VectorFloatWriter , + m_FileName , + m_RAMValue , + otb::ClampVectorImageFilter< TInput , FloatVectorImageType >::New() ); break; } case ImagePixelType_double: { - ClampAndWriteVectorImage<TInputVectorImageType,DoubleVectorImageType>(m_Image,m_VectorDoubleWriter,m_FileName,m_RAMValue); + ClampAndWriteImage< TInput , DoubleVectorImageType > ( + m_Image , + m_VectorDoubleWriter , + m_FileName , + m_RAMValue , + otb::ClampVectorImageFilter< TInput , DoubleVectorImageType >::New() ); + break; + } + case ImagePixelType_cfloat: + { + ClampAndWriteImage < TInput , ComplexFloatVectorImageType > ( + m_Image , + m_ComplexVectorFloatWriter , + m_FileName , + m_RAMValue , + otb::VectorImageToComplexVectorImageFilter < TInput , ComplexFloatVectorImageType >::New() ); + break; + } + case ImagePixelType_cdouble: + { + ClampAndWriteImage < TInput , ComplexDoubleVectorImageType > ( + m_Image , + m_ComplexVectorDoubleWriter , + m_FileName , + m_RAMValue , + otb::VectorImageToComplexVectorImageFilter < TInput , ComplexDoubleVectorImageType >::New() ); break; } default: @@ -431,7 +499,7 @@ OutputImageParameter::SwitchVectorImageWrite() } } -template <class TInputVectorImageType> +template <class TInput> void OutputImageParameter::SwitchVectorCImageWrite() { @@ -439,20 +507,22 @@ OutputImageParameter::SwitchVectorCImageWrite() { case ImagePixelType_cfloat: { - ClampAndWriteImage< TInputVectorImageType , ComplexFloatVectorImageType >( m_Image , + ClampAndWriteImage< TInput , ComplexFloatVectorImageType >( + m_Image , m_ComplexVectorFloatWriter , m_FileName , m_RAMValue , - itk::CastImageFilter< TInputVectorImageType , ComplexFloatVectorImageType >::New() ); + itk::CastImageFilter< TInput , ComplexFloatVectorImageType >::New() ); break; } case ImagePixelType_cdouble: { - ClampAndWriteImage< TInputVectorImageType , ComplexDoubleVectorImageType >( m_Image , + ClampAndWriteImage< TInput , ComplexDoubleVectorImageType >( + m_Image , m_ComplexVectorDoubleWriter , m_FileName , m_RAMValue , - itk::CastImageFilter< TInputVectorImageType , ComplexDoubleVectorImageType >::New() ); + itk::CastImageFilter< TInput , ComplexDoubleVectorImageType >::New() ); break; } default: -- GitLab From 2f9ddd67d10d0e98a08d9d7ee01c1b0f3714d10c Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Sun, 26 Nov 2017 23:01:09 +0100 Subject: [PATCH 102/567] ADD: cmake for dimensionality reduction learning --- .../Learning/DimensionalityReductionLearning/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Modules/Learning/DimensionalityReductionLearning/CMakeLists.txt diff --git a/Modules/Learning/DimensionalityReductionLearning/CMakeLists.txt b/Modules/Learning/DimensionalityReductionLearning/CMakeLists.txt new file mode 100644 index 0000000000..d5a517cd1b --- /dev/null +++ b/Modules/Learning/DimensionalityReductionLearning/CMakeLists.txt @@ -0,0 +1,4 @@ +project(OTBDimensionalityReduction) + + +otb_module_impl() -- GitLab From 8397fec01280010a749ccdd90ba245f9864baf9a Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 28 Nov 2017 16:05:59 +0100 Subject: [PATCH 103/567] WRG: fix gazillion wrg from shark, fix assignments in if condition and other warnings --- .../app/otbVectorDimensionalityReduction.cxx | 4 +- ...imensionalityReductionTrainAutoencoder.txx | 2 +- .../otbDimensionalityReductionTrainSOM.txx | 4 +- .../include/otbAutoencoderModel.h | 13 ++++++- .../include/otbAutoencoderModel.txx | 39 ++++++++++++------- .../include/otbAutoencoderModelFactory.h | 4 +- .../include/otbAutoencoderModelFactory.txx | 2 +- .../otbImageDimensionalityReductionFilter.txx | 8 ++-- .../include/otbPCAModel.h | 10 +++++ .../include/otbPCAModel.txx | 22 ++++++++--- .../include/otbSOMModel.txx | 16 ++++---- 11 files changed, 84 insertions(+), 40 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx index 16e5dfaf17..ffd02b56b8 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx @@ -155,7 +155,7 @@ class VectorDimensionalityReduction : public Application /* key.erase( std::remove_if(key.begin(),key.end(),IsNotAlphaNum), key.end()); std::transform(key.begin(), key.end(), key.begin(), tolower);*/ - OGRFieldType fieldType = layerDefn.GetFieldDefn(iField)->GetType(); + //OGRFieldType fieldType = layerDefn.GetFieldDefn(iField)->GetType(); /* if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal) {*/ //std::string tmpKey="feat."+key; @@ -320,7 +320,7 @@ class VectorDimensionalityReduction : public Application // Add the field of prediction in the output layer if field not exist - for (int i=0; i<GetParameterStringList("featout").size() ;i++) + for (unsigned int i=0; i<GetParameterStringList("featout").size() ;i++) { OGRFeatureDefn &layerDefn = outLayer.GetLayerDefn(); int idx = layerDefn.GetFieldIndex(GetParameterStringList("featout")[i].c_str()); diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx index b12a2517e5..a4b8d72d83 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx @@ -148,7 +148,7 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue>::Trai regularization.SetSize(s_nbneuron.size()); rho.SetSize(s_nbneuron.size()); beta.SetSize(s_nbneuron.size()); - for (int i=0; i<s_nbneuron.size(); i++){ + for (unsigned int i=0; i<s_nbneuron.size(); i++){ nb_neuron[i]=std::stoi(s_nbneuron[i]); noise[i]=std::stof(s_noise[i]); regularization[i]=std::stof(s_regularization[i]); diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx index 8a05ecccd7..e9c22f3c85 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx @@ -125,14 +125,14 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> dimredTrainer->SetMaxWeight(GetParameterFloat("algorithm.som.iv")); typename TemplateEstimatorType::SizeType size; std::vector<std::basic_string<char>> s= GetParameterStringList("algorithm.som.s"); - for (int i=0; i<dim; i++){ + for (unsigned int i=0; i<dim; i++){ size[i]=std::stoi(s[i]); } dimredTrainer->SetMapSize(size); typename TemplateEstimatorType::SizeType radius; std::vector<std::basic_string<char>> n= GetParameterStringList("algorithm.som.n"); - for (int i=0; i<dim; i++){ + for (unsigned int i=0; i<dim; i++){ radius[i]=std::stoi(n[i]); } dimredTrainer->SetNeighborhoodSizeInit(radius); diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h index 9723a5c27a..6807fe3fe9 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h @@ -4,10 +4,21 @@ #include "otbMachineLearningModelTraits.h" #include "otbMachineLearningModel.h" #include <fstream> -#include <shark/Algorithms/StoppingCriteria/AbstractStoppingCriterion.h> +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Woverloaded-virtual" +#endif +#include "otb_shark.h" +#include <shark/Algorithms/StoppingCriteria/AbstractStoppingCriterion.h> #include <shark/Models/FFNet.h> #include <shark/Models/Autoencoder.h> +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + namespace otb { template <class TInputValue, class NeuronType> diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index e95748ff3c..163dc88d7d 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -1,11 +1,19 @@ #ifndef AutoencoderModel_txx #define AutoencoderModel_txx +#include "otbAutoencoderModel.h" + + #include <fstream> -#include <shark/Data/Dataset.h> #include "itkMacro.h" -#include "otbSharkUtils.h" +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Woverloaded-virtual" +#endif +#include "otbSharkUtils.h" //include train function #include <shark/ObjectiveFunctions/ErrorFunction.h> #include <shark/ObjectiveFunctions/SparseAutoencoderError.h>//the error function performing the regularisation of the hidden neurons @@ -20,6 +28,9 @@ #include <shark/Algorithms/StoppingCriteria/TrainingProgress.h> //Stops when the algorithm seems to converge, Tracks the progress of the training error over a period of time #include <shark/Algorithms/GradientDescent/SteepestDescent.h> +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif namespace otb { @@ -46,7 +57,7 @@ void AutoencoderModel<TInputValue,NeuronType>::Train() shark::Data<shark::RealVector> inputSamples_copy = inputSamples; std::ofstream ofs; - if (this->m_WriteLearningCurve =true) + if (this->m_WriteLearningCurve == true) { ofs.open(m_LearningCurveFileName); ofs << "learning curve" << std::endl; @@ -176,7 +187,7 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStop optimizer.init(error); std::cout<<"error before training : " << optimizer.solution().value<<std::endl; - if (this->m_WriteLearningCurve =true) + if (this->m_WriteLearningCurve == true) { File << "end layer" << std::endl; } @@ -185,7 +196,7 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStop do{ i++; optimizer.step(error); - if (this->m_WriteLearningCurve =true) + if (this->m_WriteLearningCurve == true) { File << optimizer.solution().value << std::endl; } @@ -252,12 +263,12 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::Abstra i++; optimizer.step(error); std::cout<<"error after " << i << "iterations : " << optimizer.solution().value <<std::endl; - if (this->m_WriteLearningCurve =true) + if (this->m_WriteLearningCurve == true) { File << optimizer.solution().value << std::endl; } } while( !criterion.stop( optimizer.solution() ) ); - if (this->m_WriteLearningCurve =true) + if (this->m_WriteLearningCurve == true) { File << "end layer" << std::endl; } @@ -272,7 +283,7 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::Abstra template <class TInputValue, class NeuronType> template <class T> -void AutoencoderModel<TInputValue,NeuronType>::TrainNetwork(shark::AbstractStoppingCriterion<T> & criterion,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) +void AutoencoderModel<TInputValue,NeuronType>::TrainNetwork(shark::AbstractStoppingCriterion<T> & criterion,double /*rho*/,double /*beta*/, double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) { shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs @@ -292,7 +303,7 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainNetwork(shark::AbstractStopp i++; optimizer.step(error); std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; - if (this->m_WriteLearningCurve =true) + if (this->m_WriteLearningCurve == true) { File << optimizer.solution().value << std::endl; } @@ -319,13 +330,13 @@ bool AutoencoderModel<TInputValue,NeuronType>::CanReadFile(const std::string & f template <class TInputValue, class NeuronType> -bool AutoencoderModel<TInputValue,NeuronType>::CanWriteFile(const std::string & filename) +bool AutoencoderModel<TInputValue,NeuronType>::CanWriteFile(const std::string & /*filename*/) { return true; } template <class TInputValue, class NeuronType> -void AutoencoderModel<TInputValue,NeuronType>::Save(const std::string & filename, const std::string & name) +void AutoencoderModel<TInputValue,NeuronType>::Save(const std::string & filename, const std::string & /*name*/) { std::cout << "saving model ..." << std::endl; std::ofstream ofs(filename); @@ -382,7 +393,7 @@ void AutoencoderModel<TInputValue,NeuronType>::Save(const std::string & filename } template <class TInputValue, class NeuronType> -void AutoencoderModel<TInputValue,NeuronType>::Load(const std::string & filename, const std::string & name) +void AutoencoderModel<TInputValue,NeuronType>::Load(const std::string & filename, const std::string & /*name*/) { NetworkType net; @@ -421,7 +432,7 @@ void AutoencoderModel<TInputValue,NeuronType>::Load(const std::string & filename template <class TInputValue, class NeuronType> typename AutoencoderModel<TInputValue,NeuronType>::TargetSampleType -AutoencoderModel<TInputValue,NeuronType>::DoPredict(const InputSampleType & value, ConfidenceValueType * quality) const +AutoencoderModel<TInputValue,NeuronType>::DoPredict(const InputSampleType & value, ConfidenceValueType * /*quality*/) const { shark::RealVector samples(value.Size()); @@ -453,7 +464,7 @@ AutoencoderModel<TInputValue,NeuronType>::DoPredict(const InputSampleType & valu template <class TInputValue, class NeuronType> void AutoencoderModel<TInputValue,NeuronType> -::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const +::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * /*quality*/) const { std::vector<shark::RealVector> features; diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h index 5eb6a501ef..e614579f86 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h @@ -2,8 +2,8 @@ #define AutoencoderModelFactory_h -#include <shark/Models/TiedAutoencoder.h> -#include <shark/Models/Autoencoder.h> +//#include <shark/Models/TiedAutoencoder.h> +//#include <shark/Models/Autoencoder.h> #include "itkObjectFactoryBase.h" #include "itkImageIOBase.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx index 73dae93bde..b53c42b3a7 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx @@ -20,9 +20,9 @@ #include "otbAutoencoderModelFactory.h" +#include "otbAutoencoderModel.h" #include "itkCreateObjectFunction.h" -#include "otbAutoencoderModel.h" #include "itkVersion.h" namespace otb diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx index 418ecb4fa2..c32c9fd3f7 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx @@ -111,9 +111,9 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> // Define iterators typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType; - typedef itk::ImageRegionConstIterator<MaskImageType> MaskIteratorType; + //typedef itk::ImageRegionConstIterator<MaskImageType> MaskIteratorType; typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType; - typedef itk::ImageRegionIterator<ConfidenceImageType> ConfidenceMapIteratorType; + //typedef itk::ImageRegionIterator<ConfidenceImageType> ConfidenceMapIteratorType; InputIteratorType inIt(inputPtr, outputRegionForThread); OutputIteratorType outIt(outputPtr, outputRegionForThread); @@ -155,9 +155,9 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> // Define iterators typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType; - typedef itk::ImageRegionConstIterator<MaskImageType> MaskIteratorType; + //typedef itk::ImageRegionConstIterator<MaskImageType> MaskIteratorType; typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType; - typedef itk::ImageRegionIterator<ConfidenceImageType> ConfidenceMapIteratorType; + //typedef itk::ImageRegionIterator<ConfidenceImageType> ConfidenceMapIteratorType; InputIteratorType inIt(inputPtr, outputRegionForThread); OutputIteratorType outIt(outputPtr, outputRegionForThread); diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h index e39ca88341..72ad59805d 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h @@ -4,7 +4,17 @@ #include "otbMachineLearningModelTraits.h" #include "otbMachineLearningModel.h" +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Woverloaded-virtual" +#endif +#include "otb_shark.h" #include <shark/Algorithms/Trainers/PCA.h> +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif namespace otb { diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx index c5d274b324..11f07f3eb4 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx @@ -2,9 +2,16 @@ #ifndef PCAModel_txx #define PCAModel_txx +#include "otbPCAModel.h" + #include <fstream> -#include <shark/Data/Dataset.h> #include "itkMacro.h" +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Woverloaded-virtual" +#endif #include "otbSharkUtils.h" //include train function #include <shark/ObjectiveFunctions/ErrorFunction.h> @@ -13,6 +20,9 @@ #include <shark/ObjectiveFunctions/Regularizer.h> //L2 regulariziation #include <shark/ObjectiveFunctions/ErrorFunction.h> +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif namespace otb { @@ -65,13 +75,13 @@ bool PCAModel<TInputValue>::CanReadFile(const std::string & filename) template <class TInputValue> -bool PCAModel<TInputValue>::CanWriteFile(const std::string & filename) +bool PCAModel<TInputValue>::CanWriteFile(const std::string & /*filename*/) { return true; } template <class TInputValue> -void PCAModel<TInputValue>::Save(const std::string & filename, const std::string & name) +void PCAModel<TInputValue>::Save(const std::string & filename, const std::string & /*name*/) { std::ofstream ofs(filename); //ofs << m_encoder.name() << std::endl; //first line @@ -98,7 +108,7 @@ otxt.close(); } template <class TInputValue> -void PCAModel<TInputValue>::Load(const std::string & filename, const std::string & name) +void PCAModel<TInputValue>::Load(const std::string & filename, const std::string & /*name*/) { std::ifstream ifs(filename); char encoder[256]; @@ -130,7 +140,7 @@ void PCAModel<TInputValue>::Load(const std::string & filename, const std::string template <class TInputValue> typename PCAModel<TInputValue>::TargetSampleType -PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueType * quality) const +PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueType * /*quality*/) const { shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) @@ -156,7 +166,7 @@ PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueT template <class TInputValue> void PCAModel<TInputValue> -::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const +::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * /*quality*/) const { std::vector<shark::RealVector> features; diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx index 6195b9f961..2f5a69026d 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx @@ -1,6 +1,8 @@ #ifndef SOMModel_txx #define SOMModel_txx +#include "otbSOMModel.h" + #include "otbImageFileReader.h" #include "otbImageFileWriter.h" @@ -68,7 +70,7 @@ bool SOMModel<TInputValue, MapDimension>::CanReadFile(const std::string & filena template <class TInputValue, unsigned int MapDimension> -bool SOMModel<TInputValue, MapDimension>::CanWriteFile(const std::string & filename) +bool SOMModel<TInputValue, MapDimension>::CanWriteFile(const std::string & /*filename*/) { return true; } @@ -91,7 +93,7 @@ std::istream & binary_read(std::istream& stream, T& value){ template <class TInputValue, unsigned int MapDimension> -void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, const std::string & name) +void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, const std::string & /*name*/) { itk::ImageRegionConstIterator<MapType> inputIterator(m_SOMMap,m_SOMMap->GetLargestPossibleRegion()); inputIterator.GoToBegin(); @@ -133,7 +135,7 @@ void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, con } template <class TInputValue, unsigned int MapDimension> -void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, const std::string & name) +void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, const std::string & /*name*/) { std::ifstream ifs(filename, std::ios::binary); @@ -154,7 +156,7 @@ void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, con SizeType size; itk::Index< MapDimension > index; - for (int i=0 ; i<MapDimension; i++) + for (unsigned int i=0 ; i<MapDimension; i++) { binary_read(ifs,size[i]); index[i]=0; @@ -174,7 +176,7 @@ void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, con std::string value; while(!outputIterator.IsAtEnd()){ InputSampleType vect(numberOfElements); - for (int i=0 ; i<numberOfElements; i++) + for (unsigned int i=0 ; i<numberOfElements; i++) { float v; // InputValue type is not the same during training anddimredvector. binary_read(ifs,v); @@ -191,13 +193,13 @@ void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, con template <class TInputValue, unsigned int MapDimension> typename SOMModel<TInputValue, MapDimension>::TargetSampleType -SOMModel<TInputValue, MapDimension>::DoPredict(const InputSampleType & value, ConfidenceValueType * quality) const +SOMModel<TInputValue, MapDimension>::DoPredict(const InputSampleType & value, ConfidenceValueType * /*quality*/) const { TargetSampleType target; target.SetSize(this->m_Dimension); auto winner =m_SOMMap->GetWinner(value); - for (int i=0; i< this->m_Dimension ;i++) { + for (unsigned int i=0; i< this->m_Dimension ;i++) { target[i] = winner.GetElement(i); } -- GitLab From f52ef084cedbdd4bed5a742d2887d15e197269c0 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 28 Nov 2017 17:43:07 +0100 Subject: [PATCH 104/567] ENH: move specific code for each DR algorithm --- ...imensionalityReductionTrainAutoencoder.txx | 11 +++++- .../otbDimensionalityReductionTrainPCA.txx | 2 + .../otbDimensionalityReductionTrainSOM.txx | 12 +++++- ...inDimensionalityReductionApplicationBase.h | 37 ------------------- 4 files changed, 23 insertions(+), 39 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx index a4b8d72d83..01123fcdb7 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx @@ -3,6 +3,7 @@ #define cbTrainAutoencoder_txx #include "otbTrainDimensionalityReductionApplicationBase.h" +#include "otbAutoencoderModel.h" namespace otb { @@ -106,7 +107,15 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath) -{ +{ + // typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; + typedef shark::LogisticNeuron NeuronType; + typedef otb::AutoencoderModel<InputValueType, NeuronType> AutoencoderModelType; + /* + // typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; + typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron> TiedAutoencoderType; + typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType; + */ std::string TiedWeigth = GetParameterString("algorithm.autoencoder.istied"); std::cout << TiedWeigth << std::endl; diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx index 66a87aaade..4426e103b2 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx @@ -3,6 +3,7 @@ #define cbTrainPCA_txx #include "otbTrainDimensionalityReductionApplicationBase.h" +#include "otbPCAModel.h" namespace otb { @@ -37,6 +38,7 @@ template <class TInputValue, class TOutputValue> void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::TrainPCA(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { + typedef otb::PCAModel<InputValueType> PCAModelType; typename PCAModelType::Pointer dimredTrainer = PCAModelType::New(); dimredTrainer->SetDimension(GetParameterInt("algorithm.pca.dim")); dimredTrainer->SetInputListSample(trainingListSample); diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx index e9c22f3c85..b437723066 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx @@ -2,6 +2,7 @@ #ifndef cbTrainSOM_txx #define cbTrainSOM_txx #include "otbTrainDimensionalityReductionApplicationBase.h" +#include "otbSOMModel.h" namespace otb { @@ -79,7 +80,16 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath) -{ +{ + //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType; + //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType; + //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType; + //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; + typedef otb::SOMModel<InputValueType, 2> SOM2DModelType; + typedef otb::SOMModel<InputValueType, 3> SOM3DModelType; + typedef otb::SOMModel<InputValueType, 4> SOM4DModelType; + typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; + int SomDim = GetParameterInt("algorithm.som.dim"); std::cout << SomDim << std::endl; diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h index c14bfd8ca0..0dff279698 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h +++ b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h @@ -14,13 +14,6 @@ //Estimator #include "otbDimensionalityReductionModelFactory.h" -#include "otbSOMModel.h" - -#ifdef OTB_USE_SHARK -#include "otbAutoencoderModel.h" -#include "otbPCAModel.h" -#endif - namespace otb { namespace Wrapper @@ -84,34 +77,6 @@ public: typedef typename ModelType::InputSampleType SampleType; typedef typename ModelType::InputListSampleType ListSampleType; - -// Dimensionality reduction models - -//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType; - typedef otb::SOMModel<InputValueType, 2> SOM2DModelType; - -//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType; - typedef otb::SOMModel<InputValueType, 3> SOM3DModelType; - -//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType; - typedef otb::SOMModel<InputValueType, 4> SOM4DModelType; - -//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; - typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; - - -#ifdef OTB_USE_SHARK - -// typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - typedef shark::LogisticNeuron NeuronType; - typedef otb::AutoencoderModel<InputValueType, NeuronType> AutoencoderModelType; -/* - // typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; - typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron> TiedAutoencoderType; - typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType; - */ - typedef otb::PCAModel<InputValueType> PCAModelType; -#endif protected: TrainDimensionalityReductionApplicationBase(); @@ -148,8 +113,6 @@ void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::st void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); - - #endif //@} }; -- GitLab From 9a93d74e1813c793e00b0218096b6db8a80f400e Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 4 Dec 2017 17:37:40 +0100 Subject: [PATCH 105/567] DOC: fix licence headers --- .../app/otbImageDimensionalityReduction.cxx | 36 +++++++++--------- .../app/otbTrainDimensionalityReduction.cxx | 19 ++++++++++ .../app/otbVectorDimensionalityReduction.cxx | 37 +++++++++---------- ...imensionalityReductionTrainAutoencoder.txx | 20 +++++++++- .../otbDimensionalityReductionTrainPCA.txx | 20 +++++++++- .../otbDimensionalityReductionTrainSOM.txx | 20 +++++++++- ...inDimensionalityReductionApplicationBase.h | 19 ++++++++++ ...DimensionalityReductionApplicationBase.txx | 35 ++++++++++-------- .../CMakeLists.txt | 21 ++++++++++- .../include/SOMModelFactory.txx | 36 +++++++++--------- .../include/otbAutoencoderModel.h | 19 ++++++++++ .../include/otbAutoencoderModel.txx | 19 ++++++++++ .../include/otbAutoencoderModelFactory.h | 19 ++++++++++ .../include/otbAutoencoderModelFactory.txx | 36 +++++++++--------- .../otbDimensionalityReductionModelFactory.h | 36 +++++++++--------- ...otbDimensionalityReductionModelFactory.txx | 36 +++++++++--------- .../otbImageDimensionalityReductionFilter.h | 36 +++++++++--------- .../otbImageDimensionalityReductionFilter.txx | 36 +++++++++--------- .../include/otbPCAModel.h | 19 ++++++++++ .../include/otbPCAModel.txx | 20 +++++++++- .../include/otbPCAModelFactory.h | 19 ++++++++++ .../include/otbPCAModelFactory.txx | 36 +++++++++--------- .../include/otbSOMModel.h | 19 ++++++++++ .../include/otbSOMModelFactory.h | 19 ++++++++++ .../otb-module.cmake | 20 ++++++++++ 25 files changed, 476 insertions(+), 176 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx index 7543fffb96..7ac9ea1d11 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx @@ -1,20 +1,22 @@ -/*========================================================================= - - 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. - -=========================================================================*/ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "otbWrapperApplication.h" #include "otbWrapperApplicationFactory.h" diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx index 91c600722a..8b378f4f00 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "otbWrapperApplication.h" #include "otbWrapperApplicationFactory.h" diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx index ffd02b56b8..b755ddeeba 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx @@ -1,23 +1,22 @@ /* -* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -* -* This file is part of Orfeo Toolbox -* -* https://www.orfeo-toolbox.org/ -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "otbWrapperApplication.h" #include "otbWrapperApplicationFactory.h" #include "otbOGRDataSourceWrapper.h" diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx index 01123fcdb7..fff6561a21 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx @@ -1,4 +1,22 @@ - +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef cbTrainAutoencoder_txx #define cbTrainAutoencoder_txx diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx index 4426e103b2..7778c25203 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx @@ -1,4 +1,22 @@ - +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef cbTrainPCA_txx #define cbTrainPCA_txx diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx index b437723066..2beb312157 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx @@ -1,4 +1,22 @@ - +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef cbTrainSOM_txx #define cbTrainSOM_txx #include "otbTrainDimensionalityReductionApplicationBase.h" diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h index 0dff279698..dfec205de2 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h +++ b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef cbLearningApplicationBaseDR_h #define cbLearningApplicationBaseDR_h diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx index 77a3f477cc..54251e5928 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx @@ -1,19 +1,22 @@ -/*========================================================================= - 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. - - =========================================================================*/ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef cbLearningApplicationBaseDR_txx #define cbLearningApplicationBaseDR_txx diff --git a/Modules/Learning/DimensionalityReductionLearning/CMakeLists.txt b/Modules/Learning/DimensionalityReductionLearning/CMakeLists.txt index d5a517cd1b..79b6f276d5 100644 --- a/Modules/Learning/DimensionalityReductionLearning/CMakeLists.txt +++ b/Modules/Learning/DimensionalityReductionLearning/CMakeLists.txt @@ -1,4 +1,23 @@ -project(OTBDimensionalityReduction) +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +project(OTBDimensionalityReduction) otb_module_impl() diff --git a/Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.txx index a4ea0243b9..0f87ffcde3 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.txx @@ -1,20 +1,22 @@ -/*========================================================================= - - 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. - -=========================================================================*/ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SOMFactory_txx #define SOMFactory_txx diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h index 6807fe3fe9..44e98f578e 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef AutoencoderModel_h #define AutoencoderModel_h diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index 163dc88d7d..176ffb7de5 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef AutoencoderModel_txx #define AutoencoderModel_txx diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h index e614579f86..b94b3b8154 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef AutoencoderModelFactory_h #define AutoencoderModelFactory_h diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx index b53c42b3a7..b7c8a231d7 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx @@ -1,20 +1,22 @@ -/*========================================================================= - - 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. - -=========================================================================*/ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef AutoencoderModelFactory_txx #define AutoencoderModelFactory_txx diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h index 92603c710d..8e80633c01 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h @@ -1,20 +1,22 @@ -/*========================================================================= - - 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. - -=========================================================================*/ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef DimensionalityReductionModelFactory_h #define DimensionalityReductionModelFactory_h diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx index d20eb6356f..7eeeda6d5a 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx @@ -1,20 +1,22 @@ -/*========================================================================= - - 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. - -=========================================================================*/ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef DimensionalityReductionModelFactory_txx #define DimensionalityReductionModelFactory_txx diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h index 415dda921c..a868915352 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h @@ -1,20 +1,22 @@ -/*========================================================================= - - 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. - -=========================================================================*/ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef ImageDimensionalityReduction_h #define ImageDimensionalityReduction_h diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx index c32c9fd3f7..8cc87642f4 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx @@ -1,20 +1,22 @@ -/*========================================================================= - - 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. - -=========================================================================*/ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef otbImageClassificationFilter_txx #define otbImageClassificationFilter_txx diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h index 72ad59805d..b2b191155e 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef PCAModel_h #define PCAModel_h diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx index 11f07f3eb4..4d37df2003 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx @@ -1,4 +1,22 @@ - +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef PCAModel_txx #define PCAModel_txx diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h index a7a5d10491..c7c376ecd8 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef PCAModelFactory_h #define PCAModelFactory_h diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx index d7a06e94dc..05c59b292e 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx @@ -1,20 +1,22 @@ -/*========================================================================= - - 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. - -=========================================================================*/ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef PCAFactory_txx #define PCAFactory_txx diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h index 06307b0b8d..62b013eda5 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SOMModel_h #define SOMModel_h diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h index c078b07106..3d829306b5 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SOMModelFactory_h #define SOMModelFactory_h diff --git a/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake b/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake index c700e3ba10..d3f5e7fd08 100644 --- a/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake +++ b/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake @@ -1,3 +1,23 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + set(DOCUMENTATION "Dimensionality reduction application") otb_module(OTBDimensionalityReductionLearning DEPENDS -- GitLab From 9bb41c0ae46cce5585fdd26471608cbd91f12b9f Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 4 Dec 2017 18:27:52 +0100 Subject: [PATCH 106/567] ENH: rename AutoencoderModelFactoryBase into AutoencoderModelFactory to match filename --- .../include/otbAutoencoderModelFactory.h | 14 +++++++------- .../include/otbAutoencoderModelFactory.txx | 8 ++++---- .../otbDimensionalityReductionModelFactory.txx | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h index b94b3b8154..ca411f0e70 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h @@ -30,11 +30,11 @@ namespace otb { template <class TInputValue, class TTargetValue, class NeuronType> -class ITK_EXPORT AutoencoderModelFactoryBase : public itk::ObjectFactoryBase +class ITK_EXPORT AutoencoderModelFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ - typedef AutoencoderModelFactoryBase Self; + typedef AutoencoderModelFactory Self; typedef itk::ObjectFactoryBase Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; @@ -47,21 +47,21 @@ public: itkFactorylessNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro(AutoencoderModelFactoryBase, itk::ObjectFactoryBase); + itkTypeMacro(AutoencoderModelFactory, itk::ObjectFactoryBase); /** Register one factory of this type */ static void RegisterOneFactory(void) { - Pointer AEFactory = AutoencoderModelFactoryBase::New(); + Pointer AEFactory = AutoencoderModelFactory::New(); itk::ObjectFactoryBase::RegisterFactory(AEFactory); } protected: - AutoencoderModelFactoryBase(); - ~AutoencoderModelFactoryBase() ITK_OVERRIDE; + AutoencoderModelFactory(); + ~AutoencoderModelFactory() ITK_OVERRIDE; private: - AutoencoderModelFactoryBase(const Self &); //purposely not implemented + AutoencoderModelFactory(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented }; diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx index b7c8a231d7..53201871ab 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx @@ -30,7 +30,7 @@ namespace otb { template <class TInputValue, class TOutputValue, class NeuronType> -AutoencoderModelFactoryBase<TInputValue,TOutputValue, NeuronType>::AutoencoderModelFactoryBase() +AutoencoderModelFactory<TInputValue,TOutputValue, NeuronType>::AutoencoderModelFactory() { std::string classOverride = std::string("DimensionalityReductionModel"); @@ -45,18 +45,18 @@ AutoencoderModelFactoryBase<TInputValue,TOutputValue, NeuronType>::AutoencoderMo } template <class TInputValue, class TOutputValue, class NeuronType> -AutoencoderModelFactoryBase<TInputValue,TOutputValue, NeuronType>::~AutoencoderModelFactoryBase() +AutoencoderModelFactory<TInputValue,TOutputValue, NeuronType>::~AutoencoderModelFactory() { } template <class TInputValue, class TOutputValue, class NeuronType> -const char* AutoencoderModelFactoryBase<TInputValue,TOutputValue, NeuronType>::GetITKSourceVersion(void) const +const char* AutoencoderModelFactory<TInputValue,TOutputValue, NeuronType>::GetITKSourceVersion(void) const { return ITK_SOURCE_VERSION; } template <class TInputValue, class TOutputValue, class NeuronType> -const char* AutoencoderModelFactoryBase<TInputValue,TOutputValue, NeuronType>::GetDescription() const +const char* AutoencoderModelFactory<TInputValue,TOutputValue, NeuronType>::GetDescription() const { return "Autoencoder model factory"; } diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx index 7eeeda6d5a..5a9b9b7740 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx @@ -38,7 +38,7 @@ namespace otb template <class TInputValue, class TTargetValue> -using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::LogisticNeuron> ; +using LogAutoencoderModelFactory = AutoencoderModelFactory<TInputValue, TTargetValue, shark::LogisticNeuron> ; template <class TInputValue, class TTargetValue> @@ -121,7 +121,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> #ifdef OTB_USE_SHARK RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); - RegisterFactory(AutoencoderModelFactory<TInputValue,TOutputValue>::New()); + RegisterFactory(LogAutoencoderModelFactory<TInputValue,TOutputValue>::New()); // RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); #endif @@ -188,8 +188,8 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> #ifdef OTB_USE_SHARK - AutoencoderModelFactory<TInputValue,TOutputValue> *aeFactory = - dynamic_cast<AutoencoderModelFactory<TInputValue,TOutputValue> *>(*itFac); + LogAutoencoderModelFactory<TInputValue,TOutputValue> *aeFactory = + dynamic_cast<LogAutoencoderModelFactory<TInputValue,TOutputValue> *>(*itFac); if (aeFactory) { itk::ObjectFactoryBase::UnRegisterFactory(aeFactory); -- GitLab From 6ea18293c74e18b3497e05c7557fceaa8aafdc2f Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 4 Dec 2017 18:37:39 +0100 Subject: [PATCH 107/567] STYLE: rename source file to match usual pattern --- .../include/otbSOMModelFactory.h | 6 +++--- .../include/{SOMModelFactory.txx => otbSOMModelFactory.txx} | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename Modules/Learning/DimensionalityReductionLearning/include/{SOMModelFactory.txx => otbSOMModelFactory.txx} (100%) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h index 3d829306b5..4085d65199 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef SOMModelFactory_h -#define SOMModelFactory_h +#ifndef otbSOMModelFactory_h +#define otbSOMModelFactory_h #include "itkObjectFactoryBase.h" @@ -70,7 +70,7 @@ private: #ifndef OTB_MANUAL_INSTANTIATION -#include "SOMModelFactory.txx" +#include "otbSOMModelFactory.txx" #endif #endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.txx similarity index 100% rename from Modules/Learning/DimensionalityReductionLearning/include/SOMModelFactory.txx rename to Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.txx -- GitLab From 47f0a8df419700556ef1a7927e3a98f28c96f5fe Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 4 Dec 2017 18:38:19 +0100 Subject: [PATCH 108/567] DOC: one more missing licence header --- .../include/otbSOMModel.txx | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx index 2f5a69026d..1fd4c6ea20 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx @@ -1,5 +1,24 @@ -#ifndef SOMModel_txx -#define SOMModel_txx +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef otbSOMModel_txx +#define otbSOMModel_txx #include "otbSOMModel.h" -- GitLab From 414b21e153bff36c1f9922852aed649f278f7394 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 4 Dec 2017 18:45:17 +0100 Subject: [PATCH 109/567] STYLE: uniform include guards --- .../include/otbDimensionalityReductionTrainAutoencoder.txx | 4 ++-- .../include/otbDimensionalityReductionTrainPCA.txx | 4 ++-- .../include/otbDimensionalityReductionTrainSOM.txx | 4 ++-- .../include/otbTrainDimensionalityReductionApplicationBase.h | 4 ++-- .../otbTrainDimensionalityReductionApplicationBase.txx | 4 ++-- .../include/otbAutoencoderModel.h | 4 ++-- .../include/otbAutoencoderModel.txx | 4 ++-- .../include/otbAutoencoderModelFactory.h | 4 ++-- .../include/otbAutoencoderModelFactory.txx | 4 ++-- .../include/otbDimensionalityReductionModelFactory.h | 4 ++-- .../include/otbDimensionalityReductionModelFactory.txx | 4 ++-- .../include/otbImageDimensionalityReductionFilter.h | 4 ++-- .../include/otbImageDimensionalityReductionFilter.txx | 4 ++-- .../DimensionalityReductionLearning/include/otbPCAModel.h | 4 ++-- .../DimensionalityReductionLearning/include/otbPCAModel.txx | 4 ++-- .../include/otbPCAModelFactory.h | 4 ++-- .../include/otbPCAModelFactory.txx | 4 ++-- .../DimensionalityReductionLearning/include/otbSOMModel.h | 4 ++-- .../include/otbSOMModelFactory.txx | 4 ++-- 19 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx index fff6561a21..3e9107a9a8 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef cbTrainAutoencoder_txx -#define cbTrainAutoencoder_txx +#ifndef otbDimensionalityReductionTrainAutoencoder_txx +#define otbDimensionalityReductionTrainAutoencoder_txx #include "otbTrainDimensionalityReductionApplicationBase.h" #include "otbAutoencoderModel.h" diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx index 7778c25203..b04bd41eae 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef cbTrainPCA_txx -#define cbTrainPCA_txx +#ifndef otbDimensionalityReductionTrainPCA_txx +#define otbDimensionalityReductionTrainPCA_txx #include "otbTrainDimensionalityReductionApplicationBase.h" #include "otbPCAModel.h" diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx index 2beb312157..2cfeb1ad30 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef cbTrainSOM_txx -#define cbTrainSOM_txx +#ifndef otbDimensionalityReductionTrainSOM_txx +#define otbDimensionalityReductionTrainSOM_txx #include "otbTrainDimensionalityReductionApplicationBase.h" #include "otbSOMModel.h" diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h index dfec205de2..85c12a4fb8 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h +++ b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef cbLearningApplicationBaseDR_h -#define cbLearningApplicationBaseDR_h +#ifndef otbTrainDimensionalityReductionApplicationBase_h +#define otbTrainDimensionalityReductionApplicationBase_h #include "otbConfigure.h" diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx index 54251e5928..d99b51caae 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef cbLearningApplicationBaseDR_txx -#define cbLearningApplicationBaseDR_txx +#ifndef otbTrainDimensionalityReductionApplicationBase_txx +#define otbTrainDimensionalityReductionApplicationBase_txx #include "otbTrainDimensionalityReductionApplicationBase.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h index 44e98f578e..de0a221283 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef AutoencoderModel_h -#define AutoencoderModel_h +#ifndef otbAutoencoderModel_h +#define otbAutoencoderModel_h #include "otbMachineLearningModelTraits.h" #include "otbMachineLearningModel.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index 176ffb7de5..5f0708e5b4 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef AutoencoderModel_txx -#define AutoencoderModel_txx +#ifndef otbAutoencoderModel_txx +#define otbAutoencoderModel_txx #include "otbAutoencoderModel.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h index ca411f0e70..eacd2901ef 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef AutoencoderModelFactory_h -#define AutoencoderModelFactory_h +#ifndef otbAutoencoderModelFactory_h +#define otbAutoencoderModelFactory_h //#include <shark/Models/TiedAutoencoder.h> diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx index 53201871ab..0d66ea86e0 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef AutoencoderModelFactory_txx -#define AutoencoderModelFactory_txx +#ifndef otbAutoencoderModelFactory_txx +#define otbAutoencoderModelFactory_txx #include "otbAutoencoderModelFactory.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h index 8e80633c01..21c1d8a04a 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef DimensionalityReductionModelFactory_h -#define DimensionalityReductionModelFactory_h +#ifndef otbDimensionalityReductionModelFactory_h +#define otbDimensionalityReductionModelFactory_h //#include "DimensionalityReductionModel.h" #include "otbMachineLearningModelFactoryBase.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx index 5a9b9b7740..65280436ca 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef DimensionalityReductionModelFactory_txx -#define DimensionalityReductionModelFactory_txx +#ifndef otbDimensionalityReductionModelFactory_txx +#define otbDimensionalityReductionModelFactory_txx #include "otbDimensionalityReductionModelFactory.h" #include "otbConfigure.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h index a868915352..67bf3d2e4e 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef ImageDimensionalityReduction_h -#define ImageDimensionalityReduction_h +#ifndef otbImageDimensionalityReduction_h +#define otbImageDimensionalityReduction_h #include "itkImageToImageFilter.h" //#include "DimensionalityReductionModel.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx index 8cc87642f4..8f7a715621 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef otbImageClassificationFilter_txx -#define otbImageClassificationFilter_txx +#ifndef otbImageDimensionalityReductionFilter_txx +#define otbImageDimensionalityReductionFilter_txx #include "otbImageDimensionalityReductionFilter.h" #include "itkImageRegionIterator.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h index b2b191155e..f9cc914270 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef PCAModel_h -#define PCAModel_h +#ifndef otbPCAModel_h +#define otbPCAModel_h #include "otbMachineLearningModelTraits.h" #include "otbMachineLearningModel.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx index 4d37df2003..063b54f4f4 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef PCAModel_txx -#define PCAModel_txx +#ifndef otbPCAModel_txx +#define otbPCAModel_txx #include "otbPCAModel.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h index c7c376ecd8..8e044713f3 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef PCAModelFactory_h -#define PCAModelFactory_h +#ifndef otbPCAModelFactory_h +#define otbPCAModelFactory_h #include "itkObjectFactoryBase.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx index 05c59b292e..aeafff621d 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef PCAFactory_txx -#define PCAFactory_txx +#ifndef otbPCAFactory_txx +#define otbPCAFactory_txx #include "otbPCAModelFactory.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h index 62b013eda5..1025ab0e6c 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef SOMModel_h -#define SOMModel_h +#ifndef otbSOMModel_h +#define otbSOMModel_h //#include "DimensionalityReductionModel.h" #include "otbSOMMap.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.txx index 0f87ffcde3..bcef5c92a4 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.txx @@ -17,8 +17,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef SOMFactory_txx -#define SOMFactory_txx +#ifndef otbSOMFactory_txx +#define otbSOMFactory_txx #include "otbSOMModelFactory.h" -- GitLab From 692d0289a09b297739969f56a1da9ac72244971e Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 5 Dec 2017 10:28:23 +0100 Subject: [PATCH 110/567] STYLE: use OTB coding style --- .../include/otbAutoencoderModel.h | 247 +++--- .../include/otbAutoencoderModel.txx | 826 +++++++++--------- 2 files changed, 562 insertions(+), 511 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h index de0a221283..5e8fabfa9b 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h @@ -41,129 +41,154 @@ namespace otb { template <class TInputValue, class NeuronType> -class ITK_EXPORT AutoencoderModel: public MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> +class ITK_EXPORT AutoencoderModel + : public MachineLearningModel< + itk::VariableLengthVector< TInputValue>, + itk::VariableLengthVector< TInputValue> > { - public: - typedef AutoencoderModel Self; - typedef MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - typedef typename Superclass::InputValueType InputValueType; - typedef typename Superclass::InputSampleType InputSampleType; - typedef typename Superclass::InputListSampleType InputListSampleType; - typedef typename InputListSampleType::Pointer ListSamplePointerType; - typedef typename Superclass::TargetValueType TargetValueType; - typedef typename Superclass::TargetSampleType TargetSampleType; - typedef typename Superclass::TargetListSampleType TargetListSampleType; - - /// Confidence map related typedefs - - typedef typename Superclass::ConfidenceValueType ConfidenceValueType; - typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; - typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; - - /// Neural network related typedefs - //typedef shark::Autoencoder<NeuronType,shark::LinearNeuron> OutAutoencoderType; - typedef shark::Autoencoder<NeuronType,shark::LinearNeuron> OutAutoencoderType; - typedef shark::Autoencoder<NeuronType,NeuronType> AutoencoderType; - typedef shark::FFNet<NeuronType,shark::LinearNeuron> NetworkType; - - - itkNewMacro(Self); - itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); - - //unsigned int GetDimension() {return m_NumberOfHiddenNeurons[m_net.size()-1];}; // Override the Dimensionality Reduction model method, it is used in the dimensionality reduction filter to set the output image size - itkGetMacro(NumberOfHiddenNeurons,itk::Array<unsigned int>); - itkSetMacro(NumberOfHiddenNeurons,itk::Array<unsigned int>); - - itkGetMacro(NumberOfIterations,unsigned int); - itkSetMacro(NumberOfIterations,unsigned int); - - itkGetMacro(NumberOfIterationsFineTuning,unsigned int); - itkSetMacro(NumberOfIterationsFineTuning,unsigned int); - - itkGetMacro(Epsilon,double); - itkSetMacro(Epsilon,double); - - itkGetMacro(InitFactor,double); - itkSetMacro(InitFactor,double); - - itkGetMacro(Regularization,itk::Array<double>); - itkSetMacro(Regularization,itk::Array<double>); - - itkGetMacro(Noise,itk::Array<double>); - itkSetMacro(Noise,itk::Array<double>); - - itkGetMacro(Rho,itk::Array<double>); - itkSetMacro(Rho,itk::Array<double>); - - itkGetMacro(Beta,itk::Array<double>); - itkSetMacro(Beta,itk::Array<double>); - - itkGetMacro(WriteLearningCurve,bool); - itkSetMacro(WriteLearningCurve,bool); - - itkSetMacro(WriteWeights, bool); - itkGetMacro(WriteWeights, bool); - - itkGetMacro(LearningCurveFileName,std::string); - itkSetMacro(LearningCurveFileName,std::string); - - bool CanReadFile(const std::string & filename); - bool CanWriteFile(const std::string & filename); - - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; - - void Train() ITK_OVERRIDE; - - template <class T, class Autoencoder> - void TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion,Autoencoder &,unsigned int, unsigned int,double, double, shark::Data<shark::RealVector> &, std::ostream&); - - template <class T, class Autoencoder> - void TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion,Autoencoder &, unsigned int, unsigned int,double, double,double, shark::Data<shark::RealVector> &, std::ostream&); - - template <class T> - void TrainNetwork(shark::AbstractStoppingCriterion<T> & criterion,double, double,double, shark::Data<shark::RealVector> &, std::ostream&); - + typedef MachineLearningModel< + itk::VariableLengthVector< TInputValue>, + itk::VariableLengthVector< TInputValue> > Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef typename Superclass::InputValueType InputValueType; + typedef typename Superclass::InputSampleType InputSampleType; + typedef typename Superclass::InputListSampleType InputListSampleType; + typedef typename InputListSampleType::Pointer ListSamplePointerType; + typedef typename Superclass::TargetValueType TargetValueType; + typedef typename Superclass::TargetSampleType TargetSampleType; + typedef typename Superclass::TargetListSampleType TargetListSampleType; + + /// Confidence map related typedefs + typedef typename Superclass::ConfidenceValueType ConfidenceValueType; + typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; + typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; + + /// Neural network related typedefs + typedef shark::Autoencoder<NeuronType,shark::LinearNeuron> OutAutoencoderType; + typedef shark::Autoencoder<NeuronType,NeuronType> AutoencoderType; + typedef shark::FFNet<NeuronType,shark::LinearNeuron> NetworkType; + + itkNewMacro(Self); + itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); + + itkGetMacro(NumberOfHiddenNeurons,itk::Array<unsigned int>); + itkSetMacro(NumberOfHiddenNeurons,itk::Array<unsigned int>); + + itkGetMacro(NumberOfIterations,unsigned int); + itkSetMacro(NumberOfIterations,unsigned int); + + itkGetMacro(NumberOfIterationsFineTuning,unsigned int); + itkSetMacro(NumberOfIterationsFineTuning,unsigned int); + + itkGetMacro(Epsilon,double); + itkSetMacro(Epsilon,double); + + itkGetMacro(InitFactor,double); + itkSetMacro(InitFactor,double); + + itkGetMacro(Regularization,itk::Array<double>); + itkSetMacro(Regularization,itk::Array<double>); + + itkGetMacro(Noise,itk::Array<double>); + itkSetMacro(Noise,itk::Array<double>); + + itkGetMacro(Rho,itk::Array<double>); + itkSetMacro(Rho,itk::Array<double>); + + itkGetMacro(Beta,itk::Array<double>); + itkSetMacro(Beta,itk::Array<double>); + + itkGetMacro(WriteLearningCurve,bool); + itkSetMacro(WriteLearningCurve,bool); + + itkSetMacro(WriteWeights, bool); + itkGetMacro(WriteWeights, bool); + + itkGetMacro(LearningCurveFileName,std::string); + itkSetMacro(LearningCurveFileName,std::string); + + bool CanReadFile(const std::string & filename); + bool CanWriteFile(const std::string & filename); + + void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + + void Train() ITK_OVERRIDE; + + template <class T, class Autoencoder> + void TrainOneLayer( + shark::AbstractStoppingCriterion<T> & criterion, + Autoencoder &, + unsigned int, + unsigned int, + double, + double, + shark::Data<shark::RealVector> &, + std::ostream&); + + template <class T, class Autoencoder> + void TrainOneSparseLayer( + shark::AbstractStoppingCriterion<T> & criterion, + Autoencoder &, + unsigned int, + unsigned int, + double, + double, + double, + shark::Data<shark::RealVector> &, + std::ostream&); + + template <class T> + void TrainNetwork( + shark::AbstractStoppingCriterion<T> & criterion, + double, + double, + double, + shark::Data<shark::RealVector> &, + std::ostream&); + protected: - AutoencoderModel(); - ~AutoencoderModel() ITK_OVERRIDE; - - virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType * quality = ITK_NULLPTR) const; + AutoencoderModel(); + ~AutoencoderModel() ITK_OVERRIDE; + + virtual TargetSampleType DoPredict( + const InputSampleType& input, + ConfidenceValueType * quality = ITK_NULLPTR) const; + + virtual void DoPredictBatch( + const InputListSampleType *, + const unsigned int & startIndex, + const unsigned int & size, + TargetListSampleType *, + ConfidenceListSampleType * quality = ITK_NULLPTR) const; - virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * quality = ITK_NULLPTR) const; - private: - - /** Network attributes */ - //std::vector<AutoencoderType> m_net; - NetworkType m_net; - itk::Array<unsigned int> m_NumberOfHiddenNeurons; - /** Training parameters */ - unsigned int m_NumberOfIterations; // stop the training after a fixed number of iterations - unsigned int m_NumberOfIterationsFineTuning; // stop the fine tuning after a fixed number of iterations - double m_Epsilon; // Stops the training when the training error seems to converge - itk::Array<double> m_Regularization; // L2 Regularization parameter - itk::Array<double> m_Noise; // probability for an input to be set to 0 (denosing autoencoder) - itk::Array<double> m_Rho; // Sparsity parameter - itk::Array<double> m_Beta; // Sparsity regularization parameter - double m_InitFactor; // Weight initialization factor (the weights are intialized at m_initfactor/sqrt(inputDimension) ) - - bool m_WriteLearningCurve; // Flag for writting the learning curve into a txt file - std::string m_LearningCurveFileName; // Name of the output learning curve printed after training - bool m_WriteWeights; + /** Internal Network */ + NetworkType m_Net; + itk::Array<unsigned int> m_NumberOfHiddenNeurons; + /** Training parameters */ + unsigned int m_NumberOfIterations; // stop the training after a fixed number of iterations + unsigned int m_NumberOfIterationsFineTuning; // stop the fine tuning after a fixed number of iterations + double m_Epsilon; // Stops the training when the training error seems to converge + itk::Array<double> m_Regularization; // L2 Regularization parameter + itk::Array<double> m_Noise; // probability for an input to be set to 0 (denosing autoencoder) + itk::Array<double> m_Rho; // Sparsity parameter + itk::Array<double> m_Beta; // Sparsity regularization parameter + double m_InitFactor; // Weight initialization factor (the weights are intialized at m_initfactor/sqrt(inputDimension) ) + + bool m_WriteLearningCurve; // Flag for writting the learning curve into a txt file + std::string m_LearningCurveFileName; // Name of the output learning curve printed after training + bool m_WriteWeights; }; } // end namespace otb - #ifndef OTB_MANUAL_INSTANTIATION #include "otbAutoencoderModel.txx" #endif - #endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index 5f0708e5b4..83c00e755b 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -22,7 +22,6 @@ #include "otbAutoencoderModel.h" - #include <fstream> #include "itkMacro.h" @@ -57,459 +56,486 @@ namespace otb template <class TInputValue, class NeuronType> AutoencoderModel<TInputValue,NeuronType>::AutoencoderModel() { - this->m_IsDoPredictBatchMultiThreaded = true; - this->m_WriteLearningCurve = false; + this->m_IsDoPredictBatchMultiThreaded = true; + this->m_WriteLearningCurve = false; } - template <class TInputValue, class NeuronType> AutoencoderModel<TInputValue,NeuronType>::~AutoencoderModel() { } template <class TInputValue, class NeuronType> -void AutoencoderModel<TInputValue,NeuronType>::Train() +void +AutoencoderModel<TInputValue,NeuronType> +::Train() { - std::vector<shark::RealVector> features; - Shark::ListSampleToSharkVector(this->GetInputListSample(), features); - shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - shark::Data<shark::RealVector> inputSamples_copy = inputSamples; - - std::ofstream ofs; - if (this->m_WriteLearningCurve == true) - { - ofs.open(m_LearningCurveFileName); - ofs << "learning curve" << std::endl; - } - - /// Initialization of the feed forward neural network - std::vector<size_t> layers; - layers.push_back(shark::dataDimension(inputSamples)); - for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) - { - layers.push_back(m_NumberOfHiddenNeurons[i]); - } - - for (unsigned int i = std::max(0,static_cast<int>(m_NumberOfHiddenNeurons.Size()-1)) ; i > 0; --i) - { - std::cout << i << std::endl; - layers.push_back(m_NumberOfHiddenNeurons[i-1]); - } - - layers.push_back(shark::dataDimension(inputSamples)); - m_net.setStructure(layers); - shark::initRandomNormal(m_net,0.1); - - - /// Training of the first Autoencoder (first and last layer of the FF network) - if (m_Epsilon > 0){ - shark::TrainingProgress<> criterion(5,m_Epsilon); - - OutAutoencoderType net; - if (m_Noise[0] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen - { - TrainOneLayer(criterion,net,0 , m_NumberOfHiddenNeurons[0],m_Noise[0],m_Regularization[0], inputSamples,ofs); - } - else - { - TrainOneSparseLayer( criterion, net , 0 , m_NumberOfHiddenNeurons[0],m_Rho[0],m_Beta[0],m_Regularization[0],inputSamples, ofs); - } - criterion.reset(); - } - - else { - shark::MaxIterations<> criterion(m_NumberOfIterations); - - OutAutoencoderType net; - if (m_Noise[0] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen - { - TrainOneLayer(criterion,net,0, m_NumberOfHiddenNeurons[0],m_Noise[0],m_Regularization[0], inputSamples, ofs); - std::cout << "mnoise " << m_Noise[0] << std::endl; - } - else - { - TrainOneSparseLayer(criterion, net, 0, m_NumberOfHiddenNeurons[0],m_Rho[0],m_Beta[0],m_Regularization[0], inputSamples, ofs); - } - criterion.reset(); - } - - - /// Training of the other autoencoders - if (m_Epsilon > 0){ - shark::TrainingProgress<> criterion(5,m_Epsilon); - - for (unsigned int i = 1 ; i < m_NumberOfHiddenNeurons.Size(); ++i) - { - AutoencoderType net; - if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen - { - TrainOneLayer(criterion,net,i , m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples,ofs); - } - else - { - TrainOneSparseLayer( criterion, net , i , m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i],inputSamples, ofs); - } - criterion.reset(); - } - - } - - else { - shark::MaxIterations<> criterion(m_NumberOfIterations); - - for (unsigned int i = 1 ; i < m_NumberOfHiddenNeurons.Size(); ++i) - { - AutoencoderType net; - if (m_Noise[i] != 0) // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. (shark::SparseAutoencoderError takes an autoen - { - TrainOneLayer(criterion,net, i,m_NumberOfHiddenNeurons[i],m_Noise[i],m_Regularization[i], inputSamples, ofs); - std::cout << "mnoise " << m_Noise[i] << std::endl; - } - else - { - TrainOneSparseLayer(criterion, net, i, m_NumberOfHiddenNeurons[i],m_Rho[i],m_Beta[i],m_Regularization[i], inputSamples, ofs); - } - criterion.reset(); - } - - } - if (m_NumberOfIterationsFineTuning > 0) - { - shark::MaxIterations<> criterion(m_NumberOfIterationsFineTuning); - TrainNetwork(criterion, m_Rho[0],m_Beta[0],m_Regularization[0], inputSamples_copy, ofs); - } + std::vector<shark::RealVector> features; + Shark::ListSampleToSharkVector(this->GetInputListSample(), features); + shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); + shark::Data<shark::RealVector> inputSamples_copy = inputSamples; + + std::ofstream ofs; + if (this->m_WriteLearningCurve == true) + { + ofs.open(m_LearningCurveFileName); + ofs << "learning curve" << std::endl; + } + + // Initialization of the feed forward neural network + std::vector<size_t> layers; + layers.push_back(shark::dataDimension(inputSamples)); + for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + { + layers.push_back(m_NumberOfHiddenNeurons[i]); + } + + for (unsigned int i = std::max(0,static_cast<int>(m_NumberOfHiddenNeurons.Size()-1)) ; i > 0; --i) + { + std::cout << i << std::endl; + layers.push_back(m_NumberOfHiddenNeurons[i-1]); + } + + layers.push_back(shark::dataDimension(inputSamples)); + m_Net.setStructure(layers); + shark::initRandomNormal(m_Net,0.1); + + // Training of the first Autoencoder (first and last layer of the FF network) + if (m_Epsilon > 0) + { + shark::TrainingProgress<> criterion(5,m_Epsilon); + + OutAutoencoderType net; + // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. + if (m_Noise[0] != 0) + { + TrainOneLayer( + criterion, + net, + 0, + m_NumberOfHiddenNeurons[0], + m_Noise[0], + m_Regularization[0], + inputSamples, + ofs); + } + else + { + TrainOneSparseLayer( + criterion, + net, + 0, + m_NumberOfHiddenNeurons[0], + m_Rho[0], + m_Beta[0], + m_Regularization[0], + inputSamples, + ofs); + } + criterion.reset(); + } + else + { + shark::MaxIterations<> criterion(m_NumberOfIterations); + + OutAutoencoderType net; + // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. + if (m_Noise[0] != 0) + { + TrainOneLayer( + criterion, + net, + 0, + m_NumberOfHiddenNeurons[0], + m_Noise[0], + m_Regularization[0], + inputSamples, + ofs); + std::cout << "mnoise " << m_Noise[0] << std::endl; + } + else + { + TrainOneSparseLayer( + criterion, + net, + 0, + m_NumberOfHiddenNeurons[0], + m_Rho[0], + m_Beta[0], + m_Regularization[0], + inputSamples, + ofs); + } + criterion.reset(); + } + + // Training of the other autoencoders + if (m_Epsilon > 0) + { + shark::TrainingProgress<> criterion(5,m_Epsilon); + + for (unsigned int i = 1 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + { + AutoencoderType net; + // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. + if (m_Noise[i] != 0) + { + TrainOneLayer( + criterion, + net, + i, + m_NumberOfHiddenNeurons[i], + m_Noise[i], + m_Regularization[i], + inputSamples, + ofs); + } + else + { + TrainOneSparseLayer( + criterion, + net, + i, + m_NumberOfHiddenNeurons[i], + m_Rho[i], + m_Beta[i], + m_Regularization[i], + inputSamples, + ofs); + } + criterion.reset(); + } + } + else + { + shark::MaxIterations<> criterion(m_NumberOfIterations); + + for (unsigned int i = 1 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + { + AutoencoderType net; + // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. + if (m_Noise[i] != 0) + { + TrainOneLayer( + criterion, + net, + i, + m_NumberOfHiddenNeurons[i], + m_Noise[i], + m_Regularization[i], + inputSamples, + ofs); + std::cout << "mnoise " << m_Noise[i] << std::endl; + } + else + { + TrainOneSparseLayer( + criterion, + net, + i, + m_NumberOfHiddenNeurons[i], + m_Rho[i], + m_Beta[i], + m_Regularization[i], + inputSamples, + ofs); + } + criterion.reset(); + } + } + if (m_NumberOfIterationsFineTuning > 0) + { + shark::MaxIterations<> criterion(m_NumberOfIterationsFineTuning); + TrainNetwork( + criterion, + m_Rho[0], + m_Beta[0], + m_Regularization[0], + inputSamples_copy, + ofs); + } } template <class TInputValue, class NeuronType> template <class T, class Autoencoder> -void AutoencoderModel<TInputValue,NeuronType>::TrainOneLayer(shark::AbstractStoppingCriterion<T> & criterion, Autoencoder & net,unsigned int layer_index, unsigned int nbneuron,double noise_strength,double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) +void +AutoencoderModel<TInputValue,NeuronType> +::TrainOneLayer( + shark::AbstractStoppingCriterion<T> & criterion, + Autoencoder & net, + unsigned int layer_index, + unsigned int nbneuron, + double noise_strength, + double regularization, + shark::Data<shark::RealVector> &samples, + std::ostream& File) { - //AutoencoderType net; - std::cout << "noise " << noise_strength << std::endl; - std::size_t inputs = dataDimension(samples); - net.setStructure(inputs, nbneuron); - initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); - - //initRandomUniform(net,-1,1); - shark::ImpulseNoiseModel noise(inputs,noise_strength,1.0); //set an input pixel with probability m_Noise to 0 - shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; - shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs - shark::SquaredLoss<shark::RealVector> loss; - shark::ErrorFunction error(trainSet, &model, &loss); - - - shark::TwoNormRegularizer regularizer(error.numberOfVariables()); - error.setRegularizer(regularization,®ularizer); - - shark::IRpropPlusFull optimizer; - error.init(); - optimizer.init(error); - - std::cout<<"error before training : " << optimizer.solution().value<<std::endl; - if (this->m_WriteLearningCurve == true) - { - File << "end layer" << std::endl; - } - - unsigned int i=0; - do{ - i++; - optimizer.step(error); - if (this->m_WriteLearningCurve == true) - { - File << optimizer.solution().value << std::endl; - } - std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<< std::endl ; - - } while( !criterion.stop( optimizer.solution() ) ); - - net.setParameterVector(optimizer.solution().point); - //m_net.push_back(net); - m_net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); // Copy the encoder in the FF neural network - m_net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); // Copy the decoder in the FF neural network - samples = net.encode(samples); -} + //AutoencoderType net; + std::cout << "noise " << noise_strength << std::endl; + std::size_t inputs = dataDimension(samples); + net.setStructure(inputs, nbneuron); + initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); + + shark::ImpulseNoiseModel noise(inputs,noise_strength,1.0); //set an input pixel with probability m_Noise to 0 + shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; + shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs + shark::SquaredLoss<shark::RealVector> loss; + shark::ErrorFunction error(trainSet, &model, &loss); + + shark::TwoNormRegularizer regularizer(error.numberOfVariables()); + error.setRegularizer(regularization,®ularizer); + + shark::IRpropPlusFull optimizer; + error.init(); + optimizer.init(error); + + std::cout<<"error before training : " << optimizer.solution().value<<std::endl; + if (this->m_WriteLearningCurve == true) + { + File << "end layer" << std::endl; + } + unsigned int i=0; + do + { + i++; + optimizer.step(error); + if (this->m_WriteLearningCurve == true) + { + File << optimizer.solution().value << std::endl; + } + std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<< std::endl ; + } while( !criterion.stop( optimizer.solution() ) ); + + net.setParameterVector(optimizer.solution().point); + m_Net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); // Copy the encoder in the FF neural network + m_Net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); // Copy the decoder in the FF neural network + samples = net.encode(samples); +} template <class TInputValue, class NeuronType> template <class T, class Autoencoder> -void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer(shark::AbstractStoppingCriterion<T> & criterion, Autoencoder & net, unsigned int layer_index, unsigned int nbneuron,double rho,double beta, double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) +void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer( + shark::AbstractStoppingCriterion<T> & criterion, + Autoencoder & net, + unsigned int layer_index, + unsigned int nbneuron, + double rho, + double beta, + double regularization, + shark::Data<shark::RealVector> &samples, + std::ostream& File) { - //AutoencoderType net; - std::size_t inputs = dataDimension(samples); - net.setStructure(inputs, nbneuron); - - shark::initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); - - /* Idea : set the initials value for the output weights higher than the input weights - auto weights = net.parameterVector(); - - for(unsigned int i=net.inputSize()*net.numberOfHiddenNeurons(); i< (net.inputSize()+net.outputSize())*net.numberOfHiddenNeurons(); i++ ) - { - weights(i) *= 100; - std::cout << weights(i) << std::endl; - } - net.setParameterVector(weights); - std::cout << "dec" << net.decoderMatrix()<< std::endl; - */ - - - - //std::cout << "initial seed" << net.parameterVector() << std::endl; - //initRandomUniform(net,-1,1); - shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs - shark::SquaredLoss<shark::RealVector> loss; - shark::SparseAutoencoderError error(trainSet,&net, &loss, rho, beta); - - shark::TwoNormRegularizer regularizer(error.numberOfVariables()); - error.setRegularizer(regularization,®ularizer); - std::cout << samples.element(0) << std::endl; - /*shark::SteepestDescent optimizer; - error.init(); - optimizer.init(error); - optimizer.setLearningRate(0.01); - std::cout << optimizer.learningRate() << std::endl; - */ - shark::IRpropPlusFull optimizer; - error.init(); - optimizer.init(error); - - - std::cout<<"error before training : " << optimizer.solution().value<<std::endl; - unsigned int i=0; - do{ - - i++; - optimizer.step(error); - std::cout<<"error after " << i << "iterations : " << optimizer.solution().value <<std::endl; - if (this->m_WriteLearningCurve == true) - { - File << optimizer.solution().value << std::endl; - } - } while( !criterion.stop( optimizer.solution() ) ); - if (this->m_WriteLearningCurve == true) - { - File << "end layer" << std::endl; - } - net.setParameterVector(optimizer.solution().point); - //m_net.push_back(net); - m_net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); // Copy the encoder in the FF neural network - m_net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); // Copy the decoder in the FF neural network - samples = net.encode(samples); - -} + //AutoencoderType net; + std::size_t inputs = dataDimension(samples); + net.setStructure(inputs, nbneuron); + + shark::initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); + // Idea : set the initials value for the output weights higher than the input weights + + shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs + shark::SquaredLoss<shark::RealVector> loss; + shark::SparseAutoencoderError error(trainSet,&net, &loss, rho, beta); + + shark::TwoNormRegularizer regularizer(error.numberOfVariables()); + error.setRegularizer(regularization,®ularizer); + std::cout << samples.element(0) << std::endl; + shark::IRpropPlusFull optimizer; + error.init(); + optimizer.init(error); + + std::cout<<"error before training : " << optimizer.solution().value<<std::endl; + unsigned int i=0; + do + { + i++; + optimizer.step(error); + std::cout<<"error after " << i << "iterations : " << optimizer.solution().value <<std::endl; + if (this->m_WriteLearningCurve == true) + { + File << optimizer.solution().value << std::endl; + } + } while( !criterion.stop( optimizer.solution() ) ); + if (this->m_WriteLearningCurve == true) + { + File << "end layer" << std::endl; + } + net.setParameterVector(optimizer.solution().point); + m_Net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); // Copy the encoder in the FF neural network + m_Net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); // Copy the decoder in the FF neural network + samples = net.encode(samples); +} template <class TInputValue, class NeuronType> template <class T> -void AutoencoderModel<TInputValue,NeuronType>::TrainNetwork(shark::AbstractStoppingCriterion<T> & criterion,double /*rho*/,double /*beta*/, double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) +void +AutoencoderModel<TInputValue,NeuronType> +::TrainNetwork( + shark::AbstractStoppingCriterion<T> & criterion, + double /*rho*/, + double /*beta*/, + double regularization, + shark::Data<shark::RealVector> &samples, + std::ostream& File) { - - shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs - shark::SquaredLoss<shark::RealVector> loss; - - shark::ErrorFunction error(trainSet, &m_net, &loss); - shark::TwoNormRegularizer regularizer(error.numberOfVariables()); - error.setRegularizer(regularization,®ularizer); - - shark::IRpropPlusFull optimizer; - error.init(); - optimizer.init(error); - std::cout<<"error before training : " << optimizer.solution().value<<std::endl; - unsigned int i=0; - while( !criterion.stop( optimizer.solution() ) ) - { - i++; - optimizer.step(error); - std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; - if (this->m_WriteLearningCurve == true) - { - File << optimizer.solution().value << std::endl; - } - } - //std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; + shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs + shark::SquaredLoss<shark::RealVector> loss; + + shark::ErrorFunction error(trainSet, &m_Net, &loss); + shark::TwoNormRegularizer regularizer(error.numberOfVariables()); + error.setRegularizer(regularization,®ularizer); + + shark::IRpropPlusFull optimizer; + error.init(); + optimizer.init(error); + std::cout<<"error before training : " << optimizer.solution().value<<std::endl; + unsigned int i=0; + while( !criterion.stop( optimizer.solution() ) ) + { + i++; + optimizer.step(error); + std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; + if (this->m_WriteLearningCurve == true) + { + File << optimizer.solution().value << std::endl; + } + } + //std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; } - - template <class TInputValue, class NeuronType> -bool AutoencoderModel<TInputValue,NeuronType>::CanReadFile(const std::string & filename) +bool +AutoencoderModel<TInputValue,NeuronType> +::CanReadFile(const std::string & filename) { - try - { - this->Load(filename); - m_net.name(); - } - catch(...) - { - return false; - } - return true; + try + { + this->Load(filename); + m_Net.name(); + } + catch(...) + { + return false; + } + return true; } - template <class TInputValue, class NeuronType> -bool AutoencoderModel<TInputValue,NeuronType>::CanWriteFile(const std::string & /*filename*/) +bool +AutoencoderModel<TInputValue,NeuronType> +::CanWriteFile(const std::string & /*filename*/) { - return true; + return true; } template <class TInputValue, class NeuronType> -void AutoencoderModel<TInputValue,NeuronType>::Save(const std::string & filename, const std::string & /*name*/) +void +AutoencoderModel<TInputValue,NeuronType> +::Save(const std::string & filename, const std::string & /*name*/) { - std::cout << "saving model ..." << std::endl; - std::ofstream ofs(filename); - ofs << m_net.name() << std::endl; // the first line of the model file contains a key - boost::archive::polymorphic_text_oarchive oa(ofs); - //m_net.write(oa); - oa << m_net; - ofs.close(); - - - if (this->m_WriteWeights == true) // output the map vectors in a txt file - { - std::ofstream otxt(filename+".txt"); - - - for (unsigned int i = 0 ; i < m_net.layerMatrices().size(); ++i) - { - otxt << "layer " << i << std::endl; - otxt << m_net.layerMatrix(i) << std::endl; - otxt << m_net.bias(i) << std::endl; - otxt << std::endl; - } - - /* - std::vector<shark::RealVector> features; - - shark::SquaredLoss<shark::RealVector> loss; - Shark::ListSampleToSharkVector(this->GetInputListSample(), features); - shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - shark::Data<shark::RealVector> outputSamples = inputSamples; - - for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) - { - outputSamples = m_net[i].encode(outputSamples); - } - - for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) - { - outputSamples = m_net[m_NumberOfHiddenNeurons.Size()-i-1].decode(outputSamples); // We decode the data starting from the smallest layer - } - otxt << "Reconstruction error : " << loss.eval(inputSamples,outputSamples) << std::endl; // the mean squared error is returned - std::cout << "Reconstruction error : " << loss.eval(inputSamples,outputSamples) << std::endl; // the mean squared error is returned - - std::cout << "in" << inputSamples.element(0) << std::endl; - std::cout << "out" << outputSamples.element(0) << std::endl; - - otxt.close(); - - */ - } - - - + std::cout << "saving model ..." << std::endl; + std::ofstream ofs(filename); + ofs << m_Net.name() << std::endl; // the first line of the model file contains a key + boost::archive::polymorphic_text_oarchive oa(ofs); + oa << m_Net; + ofs.close(); + + if (this->m_WriteWeights == true) // output the map vectors in a txt file + { + std::ofstream otxt(filename+".txt"); + for (unsigned int i = 0 ; i < m_Net.layerMatrices().size(); ++i) + { + otxt << "layer " << i << std::endl; + otxt << m_Net.layerMatrix(i) << std::endl; + otxt << m_Net.bias(i) << std::endl; + otxt << std::endl; + } + } } template <class TInputValue, class NeuronType> -void AutoencoderModel<TInputValue,NeuronType>::Load(const std::string & filename, const std::string & /*name*/) +void +AutoencoderModel<TInputValue,NeuronType> +::Load(const std::string & filename, const std::string & /*name*/) { - - NetworkType net; - std::ifstream ifs(filename); - char autoencoder[256]; - ifs.getline(autoencoder,256); - std::string autoencoderstr(autoencoder); - - std::cout << autoencoderstr << std::endl; - if (autoencoderstr != net.name()){ - itkExceptionMacro(<< "Error opening " << filename.c_str() ); + NetworkType net; + std::ifstream ifs(filename); + char autoencoder[256]; + ifs.getline(autoencoder,256); + std::string autoencoderstr(autoencoder); + + std::cout << autoencoderstr << std::endl; + if (autoencoderstr != net.name()){ + itkExceptionMacro(<< "Error opening " << filename.c_str() ); } - boost::archive::polymorphic_text_iarchive ia(ifs); - //m_net.read(ia); - ia >> m_net; - ifs.close(); - - // This gives us the dimension if we keep the encoder and decoder - size_t feature_layer_index = m_net.layerMatrices().size()/2; - this->m_Dimension = m_net.layerMatrix(feature_layer_index).size1(); // number of neurons in the feature layer (first dimension of the first decoder weight matrix) - std::cout << this->m_Dimension << std::endl; - - - - /* This might not be needed - int number_of_layers = m_net.layerMatrices().size()/2; - std::cout << "number of layers" << number_of_layers << std::endl; - m_NumberOfHiddenNeurons.SetSize(number_of_layers); - for (int i=0; i<number_of_layers; i++){ - m_NumberOfHiddenNeurons[i] = m_net[i].numberOfHiddenNeurons(); - } - this->m_Dimension = m_NumberOfHiddenNeurons[number_of_layers-1]; - */ + boost::archive::polymorphic_text_iarchive ia(ifs); + ia >> m_Net; + ifs.close(); + + // This gives us the dimension if we keep the encoder and decoder + size_t feature_layer_index = m_Net.layerMatrices().size()/2; + this->m_Dimension = m_Net.layerMatrix(feature_layer_index).size1(); // number of neurons in the feature layer (first dimension of the first decoder weight matrix) + std::cout << this->m_Dimension << std::endl; } - template <class TInputValue, class NeuronType> typename AutoencoderModel<TInputValue,NeuronType>::TargetSampleType -AutoencoderModel<TInputValue,NeuronType>::DoPredict(const InputSampleType & value, ConfidenceValueType * /*quality*/) const +AutoencoderModel<TInputValue,NeuronType> +::DoPredict(const InputSampleType & value, ConfidenceValueType * /*quality*/) const { - - shark::RealVector samples(value.Size()); - for(size_t i = 0; i < value.Size();i++) + shark::RealVector samples(value.Size()); + for(size_t i = 0; i < value.Size();i++) { - samples[i]=value[i]; + samples[i]=value[i]; } - - std::vector<shark::RealVector> features; - features.push_back(samples); - - shark::Data<shark::RealVector> data = shark::createDataFromRange(features); - - data = m_net.evalLayer( m_net.layerMatrices().size()/2-1 ,data); // features layer for a network containing the encoder and decoder part - /* - for (int i=0; i<m_net.size(); i++){ // loop over all autoencoders in m_net - data = m_net[i].encode(data); - }*/ - TargetSampleType target; - target.SetSize(this->m_Dimension); - - for(unsigned int a = 0; a < this->m_Dimension; ++a){ - target[a]=data.element(0)[a]; - } - return target; - -} + std::vector<shark::RealVector> features; + features.push_back(samples); + + shark::Data<shark::RealVector> data = shark::createDataFromRange(features); + + data = m_Net.evalLayer( m_Net.layerMatrices().size()/2-1 ,data); // features layer for a network containing the encoder and decoder part + TargetSampleType target; + target.SetSize(this->m_Dimension); + + for(unsigned int a = 0; a < this->m_Dimension; ++a) + { + target[a]=data.element(0)[a]; + } + return target; +} template <class TInputValue, class NeuronType> -void AutoencoderModel<TInputValue,NeuronType> -::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * /*quality*/) const +void +AutoencoderModel<TInputValue,NeuronType> +::DoPredictBatch( + const InputListSampleType *input, + const unsigned int & startIndex, + const unsigned int & size, + TargetListSampleType * targets, + ConfidenceListSampleType * /*quality*/) const { - - std::vector<shark::RealVector> features; - Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); - shark::Data<shark::RealVector> data = shark::createDataFromRange(features); - TargetSampleType target; - /* - for (auto net :m_net ){ // loop over all autoencoders in m_net - data = net.encode(data); - } - */ - data = m_net.evalLayer( m_net.layerMatrices().size()/2-1 ,data); // features layer for a network containing the encoder and decoder part - - unsigned int id = startIndex; - target.SetSize(this->m_Dimension); - - for(const auto& p : data.elements()) - { - for(unsigned int a = 0; a < this->m_Dimension; ++a){ - target[a]=p[a]; - } - targets->SetMeasurementVector(id,target); - ++id; + std::vector<shark::RealVector> features; + Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); + shark::Data<shark::RealVector> data = shark::createDataFromRange(features); + TargetSampleType target; + data = m_Net.evalLayer( m_Net.layerMatrices().size()/2-1 ,data); // features layer for a network containing the encoder and decoder part + + unsigned int id = startIndex; + target.SetSize(this->m_Dimension); + + for(const auto& p : data.elements()) + { + for(unsigned int a = 0; a < this->m_Dimension; ++a) + { + target[a]=p[a]; + } + targets->SetMeasurementVector(id,target); + ++id; } - } } // namespace otb + #endif -- GitLab From 4cc6722e7b861f7df891901319a22b6c05a132f4 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 5 Dec 2017 11:05:46 +0100 Subject: [PATCH 111/567] REFAC: patching filter --- .../otbTwoNRIBandsImageToNComplexBandsImage.h | 30 ++-- ...tbTwoNRIBandsImageToNComplexBandsImage.txx | 84 ++++++---- ...otbVectorImageToComplexVectorImageFilter.h | 146 ------------------ .../src/otbWrapperOutputImageParameter.cxx | 6 +- 4 files changed, 75 insertions(+), 191 deletions(-) delete mode 100644 Modules/Filtering/ImageManipulation/include/otbVectorImageToComplexVectorImageFilter.h diff --git a/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.h b/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.h index 538b072149..22fe51e51c 100644 --- a/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.h +++ b/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.h @@ -23,7 +23,6 @@ #include "itkImageToImageFilter.h" #include "itkImage.h" -#include "itkNumericTraits.h" /* * Inputs : one single image made of 2N real bands @@ -63,26 +62,31 @@ public: /** typemacro */ itkTypeMacro(TwoNRIBandsImageToNComplexBandsImage, ImageToImageFilter); - typedef typename InputImageType::PixelType InputPixelType; - typedef typename OutputImageType::PixelType OutputPixelType; - typedef typename itk::NumericTraits<InputPixelType>::RealType InputRealType; - typedef typename InputImageType::RegionType InputImageRegionType; - typedef typename OutputImageType::RegionType OutputImageRegionType; + typedef typename InputImageType::InternalPixelType InputPixelType; + typedef typename OutputImageType::InternalPixelType OutputPixelType; + typedef typename OutputPixelType::value_type OutputRealType; + typedef typename InputImageType::RegionType InputImageRegionType; + typedef typename OutputImageType::RegionType OutputImageRegionType; protected: TwoNRIBandsImageToNComplexBandsImage(); - ~TwoNRIBandsImageToNComplexBandsImage() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~TwoNRIBandsImageToNComplexBandsImage() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateOutputInformation(void) ITK_OVERRIDE; - void BeforeThreadedGenerateData(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; + void BeforeThreadedGenerateData(void) override; void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: - TwoNRIBandsImageToNComplexBandsImage(const Self &); //purposely not implemented - void operator =(const Self&); //purposely not implemented + TwoNRIBandsImageToNComplexBandsImage(const Self &) = delete; //purposely not implemented + void operator =(const Self&) = delete; //purposely not implemented + + OutputRealType InBoundValue( InputPixelType in ) const ; + + double m_LowestBD , m_HighestBD ; + OutputRealType m_LowestB , m_HighestB ; }; diff --git a/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.txx b/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.txx index 48bf5e6c85..22aa071778 100644 --- a/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.txx +++ b/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.txx @@ -27,7 +27,7 @@ #include "itkImageRegionConstIterator.h" #include "itkProgressReporter.h" #include "itkVariableLengthVector.h" - +#include <limits> @@ -40,7 +40,10 @@ namespace otb template <class TInputImage, class TOutputImage> TwoNRIBandsImageToNComplexBandsImage<TInputImage, TOutputImage>::TwoNRIBandsImageToNComplexBandsImage() { - //this->SetNumberOfThreads(1); + m_LowestB = std::numeric_limits < OutputRealType > ::lowest(); + m_HighestB = std::numeric_limits < OutputRealType > ::max(); + m_LowestBD = static_cast < double > ( m_LowestB ); + m_HighestBD = static_cast < double > ( m_HighestB ); } /** @@ -55,15 +58,12 @@ TwoNRIBandsImageToNComplexBandsImage<TInputImage, TOutputImage> unsigned int nbCompo = this->GetInput()->GetNumberOfComponentsPerPixel(); - if ( (nbCompo % 2) != 0 ) - { - itkExceptionMacro("Number of bands of the input images must be an even number"); - } - else - this->GetOutput()->SetNumberOfComponentsPerPixel(nbCompo/2); - - std::cout << "GenerateOutputInformation : " << this->GetOutput()->GetNumberOfComponentsPerPixel() << std::endl; - + // if ( (nbCompo % 2) != 0 ) + // { + // itkExceptionMacro("Number of bands of the input images must be an even number"); + // } + // else + this->GetOutput()->SetNumberOfComponentsPerPixel( ( nbCompo + 1 ) / 2 ); } /** @@ -74,10 +74,10 @@ void TwoNRIBandsImageToNComplexBandsImage<TInputImage, TOutputImage> ::BeforeThreadedGenerateData(void) { - unsigned int nbCompo = this->GetInput()->GetNumberOfComponentsPerPixel(); + // unsigned int nbCompo = this->GetInput()->GetNumberOfComponentsPerPixel(); - if ( (nbCompo % 2) != 0 ) - itkExceptionMacro("Number of bands of the input images must be an even number"); + // if ( (nbCompo % 2) != 0 ) + // itkExceptionMacro("Number of bands of the input images must be an even number"); } @@ -93,44 +93,70 @@ void TwoNRIBandsImageToNComplexBandsImage<TInputImage, TOutputImage>::ThreadedGe unsigned int nbCompo = this->GetInput()->GetNumberOfComponentsPerPixel(); - itk::VariableLengthVector< std::complex< typename InputPixelType::ValueType > > vlv(nbCompo/2); + itk::VariableLengthVector < std::complex < OutputRealType > > + vlv( ( nbCompo+1 ) / 2 ); // support progress methods/callbacks itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); - itk::ImageRegionConstIterator<TInputImage> inIt; - inIt = itk::ImageRegionConstIterator<TInputImage>(this->GetInput(), outputRegionForThread); + auto inIt = itk::ImageRegionConstIterator < InputImageType > ( + this->GetInput() , outputRegionForThread ); - itk::ImageRegionIterator<OutputImageType> outIt; - outIt = itk::ImageRegionIterator<OutputImageType>(this->GetOutput(), outputRegionForThread); + auto outIt = itk::ImageRegionIterator < OutputImageType > ( + this->GetOutput() , outputRegionForThread ); inIt.GoToBegin(); outIt.GoToBegin(); - + OutputRealType reOut , imOut ; + InputPixelType reIn , imIn ; while (!outIt.IsAtEnd()) { - - unsigned int k=0; - for (unsigned int i=0; i<nbCompo-1; i=i+2) - { - vlv[k] = std::complex< typename InputPixelType::ValueType >(inIt.Get()[i],inIt.Get()[i+1]); - k++; + for (unsigned int i = 0 ; i < nbCompo / 2 ; ++i ) + { + reIn = inIt.Get()[ 2 * i ]; + imIn = inIt.Get()[ 2 * i + 1 ]; + reOut = InBoundValue( reIn ); + imOut = InBoundValue( imIn ); + vlv[i] = std::complex < OutputRealType > ( reOut , imOut ); } + if ( nbCompo % 2 == 1 ) + { + reIn = inIt.Get()[ nbCompo - 1 ]; + reOut = InBoundValue( reIn ); + vlv[ ( nbCompo + 1 ) / 2 ] = + std::complex < OutputRealType > ( reOut , 0 ); + } - outIt.Set(vlv); - ++inIt; ++outIt; - + progress.CompletedPixel(); } } +template <class TInputImage, class TOutput> +typename TwoNRIBandsImageToNComplexBandsImage < TInputImage , TOutput > +::OutputRealType +TwoNRIBandsImageToNComplexBandsImage<TInputImage, TOutput> +::InBoundValue( InputPixelType in ) const +{ + OutputRealType out ; + if ( static_cast < double > ( in ) >= m_HighestBD ) + out = m_HighestB; + else + out = static_cast < OutputRealType > ( in ) ; + if ( static_cast < double > ( in ) <= m_LowestBD ) + out = m_LowestB; + else + out = static_cast < OutputRealType > ( in ) ; + return out ; +} + /** * Standard "PrintSelf" method */ diff --git a/Modules/Filtering/ImageManipulation/include/otbVectorImageToComplexVectorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbVectorImageToComplexVectorImageFilter.h deleted file mode 100644 index 857eea9716..0000000000 --- a/Modules/Filtering/ImageManipulation/include/otbVectorImageToComplexVectorImageFilter.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef otVectorbImageToComplexVectorImageFilter_h -#define otVectorbImageToComplexVectorImageFilter_h - -#include "itkUnaryFunctorImageFilter.h" -#include <complex> -#include <limits> -namespace otb -{ - -namespace Functor -{ -template < class InputPixelType , class OutputPixelType > class RealToComplex -{ - public : - typedef typename OutputPixelType::ValueType OutputComplexType; - typedef typename OutputComplexType::value_type OutputType; - RealToComplex() : m_Size(0) - { - m_Lower = std::numeric_limits< OutputType >::lowest(); - m_Dlower = static_cast< double > ( m_Lower ); - m_Upper = std::numeric_limits< OutputType >::max(); - m_Dupper = static_cast< double > ( m_Upper ); - } - ~RealToComplex() {} - - void SetSize(unsigned int m) - { - m_Size = m; - } - - OutputPixelType operator()( InputPixelType in ) - { - OutputPixelType out; - out.SetSize( m_Size ); - OutputType re , im ; - double reD , imD ; - for (unsigned int i = 0 ; i < m_Size ; i++ ) - { - re = static_cast < OutputType > ( in[ 2 * i ] ); - reD = static_cast < double > ( in[ 2 * i ] ); - im = static_cast < OutputType > ( in[ 2 * i + 1 ] ); - imD = static_cast < double > ( in[ 2 * i + 1 ] ); - if ( reD <= m_Dlower ) - re = m_Lower; - else if ( m_Dupper <= reD ) - re = m_Upper; - if ( imD <= m_Dlower ) - im = m_Lower; - else if ( m_Dupper <= imD ) - im = m_Upper; - - out[i] = std::complex < OutputType > ( re , im ); - } - return out; - } - - private: - unsigned int m_Size; - OutputType m_Lower , m_Upper; - double m_Dlower , m_Dupper; - -}; - -} // end namespace functor - - - -template < class TInputImage , class TOutputImage > -class VectorImageToComplexVectorImageFilter : -public itk::UnaryFunctorImageFilter< - TInputImage, TOutputImage, - Functor::RealToComplex< - typename TInputImage::PixelType, - typename TOutputImage::PixelType> > -{ -public : - /** Standard typedefs */ - typedef VectorImageToComplexVectorImageFilter Self; - typedef Functor::RealToComplex< typename TInputImage::PixelType, - typename TOutputImage::PixelType> FunctorType; - - typedef itk::UnaryFunctorImageFilter< TInputImage, - TOutputImage, FunctorType > Superclass; - - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Type macro */ - itkNewMacro( Self ); - - /** Creation through object factory macro */ - itkTypeMacro( VectorImageToComplexVectorImageFilter , ImageToImageFilter ); - - void SetSize( unsigned int m ) - { - m_Size = m; - m_SizeFlag = true; - } - -protected : - VectorImageToComplexVectorImageFilter(): m_Size(0) , m_SizeFlag(false) {} - ~VectorImageToComplexVectorImageFilter() override {} - - void UpdateOutputInformation() override - { - Superclass::UpdateOutputInformation(); - typename TOutputImage::Pointer output = this->GetOutput(); - if ( !m_SizeFlag ) - { - typename TInputImage::ConstPointer input = this->GetInput(); - m_Size = input -> GetNumberOfComponentsPerPixel() / 2; - } - this->GetFunctor().SetSize( m_Size ); - output->SetVectorLength( m_Size ); - }; - -private : - VectorImageToComplexVectorImageFilter(const Self&) = delete ; - void operator=(const Self&) = delete ; - unsigned int m_Size; - bool m_SizeFlag; -}; - -} // end namespace otb - -#endif diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index e4e4049c4b..57f362d3ef 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -24,7 +24,7 @@ #include "otbClampVectorImageFilter.h" #include "otbImageIOFactory.h" #include "itksys/SystemTools.hxx" -#include "otbVectorImageToComplexVectorImageFilter.h" +#include "otbTwoNRIBandsImageToNComplexBandsImage.h" #ifdef OTB_USE_MPI @@ -481,7 +481,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_ComplexVectorFloatWriter , m_FileName , m_RAMValue , - otb::VectorImageToComplexVectorImageFilter < TInput , ComplexFloatVectorImageType >::New() ); + otb::TwoNRIBandsImageToNComplexBandsImage < TInput , ComplexFloatVectorImageType >::New() ); break; } case ImagePixelType_cdouble: @@ -491,7 +491,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_ComplexVectorDoubleWriter , m_FileName , m_RAMValue , - otb::VectorImageToComplexVectorImageFilter < TInput , ComplexDoubleVectorImageType >::New() ); + otb::TwoNRIBandsImageToNComplexBandsImage < TInput , ComplexDoubleVectorImageType >::New() ); break; } default: -- GitLab From 360f8c4c05b757d1a20077bfe886f14212e18726 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 5 Dec 2017 11:34:36 +0100 Subject: [PATCH 112/567] ENH: simplify interface --- .../include/otbAutoencoderModel.h | 10 -- .../include/otbAutoencoderModel.txx | 118 +++--------------- 2 files changed, 17 insertions(+), 111 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h index 5e8fabfa9b..f5c3b85e41 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h @@ -124,9 +124,6 @@ public: shark::AbstractStoppingCriterion<T> & criterion, Autoencoder &, unsigned int, - unsigned int, - double, - double, shark::Data<shark::RealVector> &, std::ostream&); @@ -135,19 +132,12 @@ public: shark::AbstractStoppingCriterion<T> & criterion, Autoencoder &, unsigned int, - unsigned int, - double, - double, - double, shark::Data<shark::RealVector> &, std::ostream&); template <class T> void TrainNetwork( shark::AbstractStoppingCriterion<T> & criterion, - double, - double, - double, shark::Data<shark::RealVector> &, std::ostream&); diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index 83c00e755b..77ac08ef45 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -109,28 +109,11 @@ AutoencoderModel<TInputValue,NeuronType> // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. if (m_Noise[0] != 0) { - TrainOneLayer( - criterion, - net, - 0, - m_NumberOfHiddenNeurons[0], - m_Noise[0], - m_Regularization[0], - inputSamples, - ofs); + TrainOneLayer(criterion, net, 0, inputSamples, ofs); } else { - TrainOneSparseLayer( - criterion, - net, - 0, - m_NumberOfHiddenNeurons[0], - m_Rho[0], - m_Beta[0], - m_Regularization[0], - inputSamples, - ofs); + TrainOneSparseLayer(criterion, net, 0, inputSamples, ofs); } criterion.reset(); } @@ -142,29 +125,12 @@ AutoencoderModel<TInputValue,NeuronType> // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. if (m_Noise[0] != 0) { - TrainOneLayer( - criterion, - net, - 0, - m_NumberOfHiddenNeurons[0], - m_Noise[0], - m_Regularization[0], - inputSamples, - ofs); + TrainOneLayer(criterion, net, 0, inputSamples, ofs); std::cout << "mnoise " << m_Noise[0] << std::endl; } else { - TrainOneSparseLayer( - criterion, - net, - 0, - m_NumberOfHiddenNeurons[0], - m_Rho[0], - m_Beta[0], - m_Regularization[0], - inputSamples, - ofs); + TrainOneSparseLayer(criterion, net, 0, inputSamples, ofs); } criterion.reset(); } @@ -180,28 +146,11 @@ AutoencoderModel<TInputValue,NeuronType> // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. if (m_Noise[i] != 0) { - TrainOneLayer( - criterion, - net, - i, - m_NumberOfHiddenNeurons[i], - m_Noise[i], - m_Regularization[i], - inputSamples, - ofs); + TrainOneLayer(criterion, net, i, inputSamples, ofs); } else { - TrainOneSparseLayer( - criterion, - net, - i, - m_NumberOfHiddenNeurons[i], - m_Rho[i], - m_Beta[i], - m_Regularization[i], - inputSamples, - ofs); + TrainOneSparseLayer(criterion, net, i, inputSamples, ofs); } criterion.reset(); } @@ -216,29 +165,12 @@ AutoencoderModel<TInputValue,NeuronType> // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. if (m_Noise[i] != 0) { - TrainOneLayer( - criterion, - net, - i, - m_NumberOfHiddenNeurons[i], - m_Noise[i], - m_Regularization[i], - inputSamples, - ofs); + TrainOneLayer(criterion, net, i, inputSamples, ofs); std::cout << "mnoise " << m_Noise[i] << std::endl; } else { - TrainOneSparseLayer( - criterion, - net, - i, - m_NumberOfHiddenNeurons[i], - m_Rho[i], - m_Beta[i], - m_Regularization[i], - inputSamples, - ofs); + TrainOneSparseLayer( criterion, net, i, inputSamples, ofs); } criterion.reset(); } @@ -246,13 +178,7 @@ AutoencoderModel<TInputValue,NeuronType> if (m_NumberOfIterationsFineTuning > 0) { shark::MaxIterations<> criterion(m_NumberOfIterationsFineTuning); - TrainNetwork( - criterion, - m_Rho[0], - m_Beta[0], - m_Regularization[0], - inputSamples_copy, - ofs); + TrainNetwork(criterion, inputSamples_copy, ofs); } } @@ -264,26 +190,23 @@ AutoencoderModel<TInputValue,NeuronType> shark::AbstractStoppingCriterion<T> & criterion, Autoencoder & net, unsigned int layer_index, - unsigned int nbneuron, - double noise_strength, - double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) { //AutoencoderType net; - std::cout << "noise " << noise_strength << std::endl; + std::cout << "noise " << m_Noise[layer_index] << std::endl; std::size_t inputs = dataDimension(samples); - net.setStructure(inputs, nbneuron); + net.setStructure(inputs, m_NumberOfHiddenNeurons[layer_index]); initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); - shark::ImpulseNoiseModel noise(inputs,noise_strength,1.0); //set an input pixel with probability m_Noise to 0 + shark::ImpulseNoiseModel noise(inputs,m_Noise[layer_index],1.0); //set an input pixel with probability m_Noise to 0 shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; shark::ErrorFunction error(trainSet, &model, &loss); shark::TwoNormRegularizer regularizer(error.numberOfVariables()); - error.setRegularizer(regularization,®ularizer); + error.setRegularizer(m_Regularization[layer_index],®ularizer); shark::IRpropPlusFull optimizer; error.init(); @@ -319,16 +242,12 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer( shark::AbstractStoppingCriterion<T> & criterion, Autoencoder & net, unsigned int layer_index, - unsigned int nbneuron, - double rho, - double beta, - double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) { //AutoencoderType net; std::size_t inputs = dataDimension(samples); - net.setStructure(inputs, nbneuron); + net.setStructure(inputs, m_NumberOfHiddenNeurons[layer_index]); shark::initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); @@ -336,10 +255,10 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer( shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; - shark::SparseAutoencoderError error(trainSet,&net, &loss, rho, beta); + shark::SparseAutoencoderError error(trainSet,&net, &loss, m_Rho[layer_index], m_Beta[layer_index]); shark::TwoNormRegularizer regularizer(error.numberOfVariables()); - error.setRegularizer(regularization,®ularizer); + error.setRegularizer(m_Regularization[layer_index],®ularizer); std::cout << samples.element(0) << std::endl; shark::IRpropPlusFull optimizer; error.init(); @@ -373,9 +292,6 @@ void AutoencoderModel<TInputValue,NeuronType> ::TrainNetwork( shark::AbstractStoppingCriterion<T> & criterion, - double /*rho*/, - double /*beta*/, - double regularization, shark::Data<shark::RealVector> &samples, std::ostream& File) { @@ -384,7 +300,7 @@ AutoencoderModel<TInputValue,NeuronType> shark::ErrorFunction error(trainSet, &m_Net, &loss); shark::TwoNormRegularizer regularizer(error.numberOfVariables()); - error.setRegularizer(regularization,®ularizer); + error.setRegularizer(m_Regularization[0],®ularizer); shark::IRpropPlusFull optimizer; error.init(); -- GitLab From d5ed9ebb5054f9f451f72419bda4c35a314beece Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 5 Dec 2017 12:05:07 +0100 Subject: [PATCH 113/567] STYLE: use OTB coding style --- .../include/otbAutoencoderModelFactory.h | 20 +------- .../include/otbAutoencoderModelFactory.txx | 20 ++++---- .../otbDimensionalityReductionModelFactory.h | 4 -- ...otbDimensionalityReductionModelFactory.txx | 51 +++++-------------- .../otbImageDimensionalityReductionFilter.h | 1 - .../otbImageDimensionalityReductionFilter.txx | 49 +++++++----------- 6 files changed, 41 insertions(+), 104 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h index eacd2901ef..a9b0065e8c 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h @@ -20,15 +20,12 @@ #ifndef otbAutoencoderModelFactory_h #define otbAutoencoderModelFactory_h - -//#include <shark/Models/TiedAutoencoder.h> -//#include <shark/Models/Autoencoder.h> #include "itkObjectFactoryBase.h" #include "itkImageIOBase.h" namespace otb { - + template <class TInputValue, class TTargetValue, class NeuronType> class ITK_EXPORT AutoencoderModelFactory : public itk::ObjectFactoryBase { @@ -63,27 +60,12 @@ protected: private: AutoencoderModelFactory(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented - }; - - -/* -template <class TInputValue, class TTargetValue> -using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; - - -template <class TInputValue, class TTargetValue> -using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; -*/ - } //namespace otb - #ifndef OTB_MANUAL_INSTANTIATION #include "otbAutoencoderModelFactory.txx" #endif #endif - - diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx index 0d66ea86e0..c55f718a62 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.txx @@ -20,7 +20,6 @@ #ifndef otbAutoencoderModelFactory_txx #define otbAutoencoderModelFactory_txx - #include "otbAutoencoderModelFactory.h" #include "otbAutoencoderModel.h" @@ -32,16 +31,15 @@ namespace otb template <class TInputValue, class TOutputValue, class NeuronType> AutoencoderModelFactory<TInputValue,TOutputValue, NeuronType>::AutoencoderModelFactory() { - std::string classOverride = std::string("DimensionalityReductionModel"); std::string subclass = std::string("AutoencoderModel"); - this->RegisterOverride(classOverride.c_str(), - subclass.c_str(), - "Shark AE ML Model", - 1, - // itk::CreateObjectFunction<AutoencoderModel<TInputValue,TOutputValue> >::New()); - itk::CreateObjectFunction<AutoencoderModel<TInputValue,NeuronType > >::New()); + this->RegisterOverride( + classOverride.c_str(), + subclass.c_str(), + "Shark AE ML Model", + 1, + itk::CreateObjectFunction<AutoencoderModel<TInputValue,NeuronType > >::New()); } template <class TInputValue, class TOutputValue, class NeuronType> @@ -50,13 +48,15 @@ AutoencoderModelFactory<TInputValue,TOutputValue, NeuronType>::~AutoencoderModel } template <class TInputValue, class TOutputValue, class NeuronType> -const char* AutoencoderModelFactory<TInputValue,TOutputValue, NeuronType>::GetITKSourceVersion(void) const +const char* +AutoencoderModelFactory<TInputValue,TOutputValue, NeuronType>::GetITKSourceVersion(void) const { return ITK_SOURCE_VERSION; } template <class TInputValue, class TOutputValue, class NeuronType> -const char* AutoencoderModelFactory<TInputValue,TOutputValue, NeuronType>::GetDescription() const +const char* +AutoencoderModelFactory<TInputValue,TOutputValue, NeuronType>::GetDescription() const { return "Autoencoder model factory"; } diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h index 21c1d8a04a..a96235ccb9 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h @@ -20,9 +20,7 @@ #ifndef otbDimensionalityReductionModelFactory_h #define otbDimensionalityReductionModelFactory_h -//#include "DimensionalityReductionModel.h" #include "otbMachineLearningModelFactoryBase.h" - #include "otbMachineLearningModel.h" namespace otb @@ -54,7 +52,6 @@ public: /** Mode in which the files is intended to be used */ typedef enum { ReadMode, WriteMode } FileModeType; - /** Create the appropriate MachineLearningModel depending on the particulars of the file. */ static DimensionalityReductionModelTypePointer CreateDimensionalityReductionModel(const std::string& path, FileModeType mode); @@ -74,7 +71,6 @@ private: /** Register a single factory, ensuring it has not been registered * twice */ static void RegisterFactory(itk::ObjectFactoryBase * factory); - }; } // end namespace otb diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx index 65280436ca..f289ab83d9 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx @@ -32,15 +32,12 @@ #include "itkMutexLockHolder.h" - namespace otb { - template <class TInputValue, class TTargetValue> using LogAutoencoderModelFactory = AutoencoderModelFactory<TInputValue, TTargetValue, shark::LogisticNeuron> ; - template <class TInputValue, class TTargetValue> using SOM2DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 2> ; @@ -55,7 +52,7 @@ using SOM5DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 5> ; template <class TInputValue, class TOutputValue> -typename MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TOutputValue>>::Pointer +typename MachineLearningModel<itk::VariableLengthVector< TInputValue>, itk::VariableLengthVector< TOutputValue> >::Pointer DimensionalityReductionModelFactory<TInputValue,TOutputValue> ::CreateDimensionalityReductionModel(const std::string& path, FileModeType mode) { @@ -64,7 +61,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> std::list<DimensionalityReductionModelTypePointer> possibleDimensionalityReductionModel; std::list<LightObject::Pointer> allobjects = itk::ObjectFactoryBase::CreateAllInstance("DimensionalityReductionModel"); - + for(std::list<LightObject::Pointer>::iterator i = allobjects.begin(); i != allobjects.end(); ++i) { @@ -75,19 +72,17 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> } else { - std::cerr << "Error DimensionalityReductionModel Factory did not return an DimensionalityReductionModel: " << (*i)->GetNameOfClass() << std::endl; } } - -for(typename std::list<DimensionalityReductionModelTypePointer>::iterator k = possibleDimensionalityReductionModel.begin(); + + for(typename std::list<DimensionalityReductionModelTypePointer>::iterator k = possibleDimensionalityReductionModel.begin(); k != possibleDimensionalityReductionModel.end(); ++k) { - if( mode == ReadMode ) + if( mode == ReadMode ) { - if((*k)->CanReadFile(path)) { return *k; @@ -99,7 +94,6 @@ for(typename std::list<DimensionalityReductionModelTypePointer>::iterator k = po { return *k; } - } } return ITK_NULLPTR; @@ -111,20 +105,16 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> ::RegisterBuiltInFactories() { itk::MutexLockHolder<itk::SimpleMutexLock> lockHolder(mutex); - - RegisterFactory(SOM2DModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(SOM3DModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(SOM4DModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(SOM5DModelFactory<TInputValue,TOutputValue>::New()); - + #ifdef OTB_USE_SHARK RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(LogAutoencoderModelFactory<TInputValue,TOutputValue>::New()); - // RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); #endif - } template <class TInputValue, class TOutputValue> @@ -151,17 +141,15 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> for (itFac = factories.begin(); itFac != factories.end() ; ++itFac) { - - // SOM - - SOM5DModelFactory<TInputValue,TOutputValue> *som5dFactory = + // SOM 5D + SOM5DModelFactory<TInputValue,TOutputValue> *som5dFactory = dynamic_cast<SOM5DModelFactory<TInputValue,TOutputValue> *>(*itFac); if (som5dFactory) { itk::ObjectFactoryBase::UnRegisterFactory(som5dFactory); continue; } - + // SOM 4D SOM4DModelFactory<TInputValue,TOutputValue> *som4dFactory = dynamic_cast<SOM4DModelFactory<TInputValue,TOutputValue> *>(*itFac); if (som4dFactory) @@ -169,7 +157,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> itk::ObjectFactoryBase::UnRegisterFactory(som4dFactory); continue; } - + // SOM 3D SOM3DModelFactory<TInputValue,TOutputValue> *som3dFactory = dynamic_cast<SOM3DModelFactory<TInputValue,TOutputValue> *>(*itFac); if (som3dFactory) @@ -177,7 +165,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> itk::ObjectFactoryBase::UnRegisterFactory(som3dFactory); continue; } - + // SOM 2D SOM2DModelFactory<TInputValue,TOutputValue> *som2dFactory = dynamic_cast<SOM2DModelFactory<TInputValue,TOutputValue> *>(*itFac); if (som2dFactory) @@ -185,9 +173,8 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> itk::ObjectFactoryBase::UnRegisterFactory(som2dFactory); continue; } - #ifdef OTB_USE_SHARK - + // Autoencoder LogAutoencoderModelFactory<TInputValue,TOutputValue> *aeFactory = dynamic_cast<LogAutoencoderModelFactory<TInputValue,TOutputValue> *>(*itFac); if (aeFactory) @@ -195,17 +182,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> itk::ObjectFactoryBase::UnRegisterFactory(aeFactory); continue; } - - /* - TiedAutoencoderModelFactory<TInputValue,TOutputValue> *taeFactory = - dynamic_cast<TiedAutoencoderModelFactory<TInputValue,TOutputValue> *>(*itFac); - if (taeFactory) - { - itk::ObjectFactoryBase::UnRegisterFactory(taeFactory); - continue; - } - */ - // PCA + // PCA PCAModelFactory<TInputValue,TOutputValue> *pcaFactory = dynamic_cast<PCAModelFactory<TInputValue,TOutputValue> *>(*itFac); if (pcaFactory) @@ -214,9 +191,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> continue; } #endif - } - } } // end namespace otb diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h index 67bf3d2e4e..93c60cf022 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h @@ -21,7 +21,6 @@ #define otbImageDimensionalityReduction_h #include "itkImageToImageFilter.h" -//#include "DimensionalityReductionModel.h" #include "otbMachineLearningModel.h" #include "otbImage.h" diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx index 8f7a715621..2656e21e1f 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx @@ -36,8 +36,6 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> this->SetNumberOfIndexedInputs(2); this->SetNumberOfRequiredInputs(1); - //m_DefaultLabel = itk::NumericTraits<LabelType>::ZeroValue(); - this->SetNumberOfRequiredOutputs(2); this->SetNthOutput(0,TOutputImage::New()); this->SetNthOutput(1,ConfidenceImageType::New()); @@ -113,9 +111,7 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> // Define iterators typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType; - //typedef itk::ImageRegionConstIterator<MaskImageType> MaskIteratorType; typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType; - //typedef itk::ImageRegionIterator<ConfidenceImageType> ConfidenceMapIteratorType; InputIteratorType inIt(inputPtr, outputRegionForThread); OutputIteratorType outIt(outputPtr, outputRegionForThread); @@ -123,43 +119,36 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> // Walk the part of the image for (inIt.GoToBegin(), outIt.GoToBegin(); !inIt.IsAtEnd() && !outIt.IsAtEnd(); ++inIt, ++outIt) { - // Classifify - - outIt.Set(m_Model->Predict(inIt.Get())); + // Classifify + outIt.Set(m_Model->Predict(inIt.Get())); progress.CompletedPixel(); } - } template <class TInputImage, class TOutputImage, class TMaskImage> void ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage>::GenerateOutputInformation() { - Superclass::GenerateOutputInformation(); + Superclass::GenerateOutputInformation(); this->GetOutput()->SetNumberOfComponentsPerPixel( m_Model->GetDimension() ); } - - template <class TInputImage, class TOutputImage, class TMaskImage> void ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> ::BatchThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) { - // Get the input pointers InputImageConstPointerType inputPtr = this->GetInput(); MaskImageConstPointerType inputMaskPtr = this->GetInputMask(); OutputImagePointerType outputPtr = this->GetOutput(); ConfidenceImagePointerType confidencePtr = this->GetOutputConfidence(); - + // Progress reporting itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); // Define iterators typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType; - //typedef itk::ImageRegionConstIterator<MaskImageType> MaskIteratorType; typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType; - //typedef itk::ImageRegionIterator<ConfidenceImageType> ConfidenceMapIteratorType; InputIteratorType inIt(inputPtr, outputRegionForThread); OutputIteratorType outIt(outputPtr, outputRegionForThread); @@ -168,45 +157,40 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> typedef typename ModelType::InputListSampleType InputListSampleType; typedef typename ModelType::TargetValueType TargetValueType; typedef typename ModelType::TargetListSampleType TargetListSampleType; - + typename InputListSampleType::Pointer samples = InputListSampleType::New(); unsigned int num_features = inputPtr->GetNumberOfComponentsPerPixel(); samples->SetMeasurementVectorSize(num_features); InputSampleType sample(num_features); + // Fill the samples - for (inIt.GoToBegin(); !inIt.IsAtEnd(); ++inIt) { - - typename InputImageType::PixelType pix = inIt.Get(); - for(size_t feat=0; feat<num_features; ++feat) - { - sample[feat]=pix[feat]; - } - samples->PushBack(sample); - + typename InputImageType::PixelType pix = inIt.Get(); + for(size_t feat=0; feat<num_features; ++feat) + { + sample[feat]=pix[feat]; + } + samples->PushBack(sample); } //Make the batch prediction typename TargetListSampleType::Pointer labels; - + // This call is threadsafe labels = m_Model->PredictBatch(samples); // Set the output values - typename TargetListSampleType::ConstIterator labIt = labels->Begin(); - for (outIt.GoToBegin(); !outIt.IsAtEnd(); ++outIt) { - - itk::VariableLengthVector<TargetValueType> labelValue; - + itk::VariableLengthVector<TargetValueType> labelValue; labelValue = labIt.GetMeasurementVector(); ++labIt; outIt.Set(labelValue); progress.CompletedPixel(); } } + template <class TInputImage, class TOutputImage, class TMaskImage> void ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> @@ -220,8 +204,8 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> { this->ClassicThreadedGenerateData(outputRegionForThread, threadId); } - } + /** * PrintSelf Method */ @@ -232,5 +216,6 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> { Superclass::PrintSelf(os, indent); } + } // End namespace otb #endif -- GitLab From f1e15408f0ef1cd6499517add5e05ee5b5065b94 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 5 Dec 2017 16:05:48 +0100 Subject: [PATCH 114/567] TEST: add test on complex image --- .../Applications/AppImageUtils/test/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Modules/Applications/AppImageUtils/test/CMakeLists.txt b/Modules/Applications/AppImageUtils/test/CMakeLists.txt index d2852f4d46..d428cc87bb 100644 --- a/Modules/Applications/AppImageUtils/test/CMakeLists.txt +++ b/Modules/Applications/AppImageUtils/test/CMakeLists.txt @@ -173,6 +173,14 @@ otb_test_application(NAME apTvUtExtractROIRightInputFile ${INPUTDATA}/couleurs_extrait.png ${TEMP}/apTvUtExtractROIRightInputFile.tif) +otb_test_application(NAME apTvUtExtractROIComplexInputFile + APP ExtractROI + OPTIONS -in ${INPUTDATA}/complexInputCfloat.tif + -out ${TEMP}/apTvUtExtractROIComplexInputFile.tif cfloat + VALID --compare-image ${NOTOL} + ${INPUTDATA}/complexInputCfloat.tif + ${TEMP}/apTvUtExtractROIComplexInputFile.tif) + #----------- Rescale TESTS ---------------- otb_test_application(NAME apTvUtRescaleTest @@ -207,6 +215,11 @@ otb_test_application(NAME apTuUtReadImageInfoExtendedFilename_reader OPTIONS -in ${INPUTDATA}/ToulouseExtract_WithGeom.tif?&skipgeom=true&skipcarto=true ) +otb_test_application(NAME apTuUtReadComplexImageInfoFilename_reader + APP ReadImageInfo + OPTIONS -in ${INPUTDATA}/complexInputCfloat.tif + ) + set(TESTNAME "gd-pleiades-1" #LARGEINPUT{PLEIADES/TLSE_JP2_DIMAPv2_PRIMARY_PMS_lossless_12bits/IMGPHR_201222215194743808/IMG_PHR1A_PMS_201201151100183_SEN_IPU_20120222_0901-001_R1C1.JP2} -- GitLab From e1b491e659be00d1ebf6e84f1a5274d12f944c6c Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 8 Dec 2017 18:24:53 +0100 Subject: [PATCH 115/567] STYLE: clean code, use OTB style --- .../app/otbImageDimensionalityReduction.cxx | 58 +- .../app/otbTrainDimensionalityReduction.cxx | 63 +- .../app/otbVectorDimensionalityReduction.cxx | 680 +++++++++--------- ...imensionalityReductionTrainAutoencoder.txx | 165 ++--- .../otbDimensionalityReductionTrainPCA.txx | 19 +- .../otbDimensionalityReductionTrainSOM.txx | 122 ++-- ...inDimensionalityReductionApplicationBase.h | 49 +- ...DimensionalityReductionApplicationBase.txx | 49 +- .../include/otbPCAModel.h | 115 +-- .../include/otbPCAModel.txx | 205 +++--- .../include/otbPCAModelFactory.h | 12 +- .../include/otbPCAModelFactory.txx | 14 +- .../include/otbSOMModel.h | 220 +++--- .../include/otbSOMModel.txx | 318 ++++---- .../include/otbSOMModelFactory.h | 11 +- .../include/otbSOMModelFactory.txx | 14 +- 16 files changed, 1026 insertions(+), 1088 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx index 7ac9ea1d11..e628b951a7 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx @@ -68,11 +68,15 @@ private: InternalType m_B; }; -} +} // end of namespace Functor namespace Wrapper { - +/** + * \class ImageDimensionalityReduction + * + * Apply a dimensionality reduction model to an image + */ class ImageDimensionalityReduction : public Application { public: @@ -88,21 +92,27 @@ public: itkTypeMacro(ImageDimensionalityReduction, otb::Application); /** Filters typedef */ - typedef UInt8ImageType MaskImageType; - typedef itk::VariableLengthVector<FloatVectorImageType::InternalPixelType> MeasurementType; - typedef otb::StatisticsXMLFileReader<MeasurementType> StatisticsReader; - typedef otb::ShiftScaleVectorImageFilter<FloatVectorImageType, FloatVectorImageType> RescalerType; + typedef UInt8ImageType MaskImageType; + typedef itk::VariableLengthVector< + FloatVectorImageType::InternalPixelType> MeasurementType; + typedef otb::StatisticsXMLFileReader<MeasurementType> StatisticsReader; + typedef otb::ShiftScaleVectorImageFilter< + FloatVectorImageType, FloatVectorImageType> RescalerType; typedef itk::UnaryFunctorImageFilter< FloatImageType, FloatImageType, - otb::Functor::AffineFunctor<float,float> > OutputRescalerType; - typedef otb::ImageDimensionalityReductionFilter<FloatVectorImageType, FloatVectorImageType, MaskImageType> DimensionalityReductionFilterType; - typedef DimensionalityReductionFilterType::Pointer DimensionalityReductionFilterPointerType; - typedef DimensionalityReductionFilterType::ModelType ModelType; - typedef ModelType::Pointer ModelPointerType; - typedef DimensionalityReductionFilterType::ValueType ValueType; - typedef DimensionalityReductionFilterType::LabelType LabelType; - typedef otb::DimensionalityReductionModelFactory<ValueType, LabelType> DimensionalityReductionModelFactoryType; + otb::Functor::AffineFunctor<float,float> > OutputRescalerType; + typedef otb::ImageDimensionalityReductionFilter< + FloatVectorImageType, + FloatVectorImageType, + MaskImageType> DimensionalityReductionFilterType; + typedef DimensionalityReductionFilterType::Pointer DimensionalityReductionFilterPointerType; + typedef DimensionalityReductionFilterType::ModelType ModelType; + typedef ModelType::Pointer ModelPointerType; + typedef DimensionalityReductionFilterType::ValueType ValueType; + typedef DimensionalityReductionFilterType::LabelType LabelType; + typedef otb::DimensionalityReductionModelFactory< + ValueType, LabelType> DimensionalityReductionModelFactoryType; protected: @@ -115,7 +125,8 @@ private: void DoInit() ITK_OVERRIDE { SetName("DimensionalityReduction"); - SetDescription("Performs dimensionality reduction of the input image according to a dimensionality reduction model file."); + SetDescription("Performs dimensionality reduction of the input image " + "according to a dimensionality reduction model file."); // Documentation SetDocName("DimensionalityReduction"); @@ -185,12 +196,14 @@ private: // Load DR model using a factory otbAppLogINFO("Loading model"); - m_Model = DimensionalityReductionModelFactoryType::CreateDimensionalityReductionModel(GetParameterString("model"), - DimensionalityReductionModelFactoryType::ReadMode); + m_Model = DimensionalityReductionModelFactoryType::CreateDimensionalityReductionModel( + GetParameterString("model"), + DimensionalityReductionModelFactoryType::ReadMode); if (m_Model.IsNull()) { - otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") << " : unsupported model type"); + otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") + << " : unsupported model type"); } m_Model->Load(GetParameterString("model")); @@ -203,7 +216,7 @@ private: FloatVectorImageType::Pointer outputImage = m_ClassificationFilter->GetOutput(); // Normalize input image if asked - if(IsParameterEnabled("imstat") ) + if( IsParameterEnabled("imstat") ) { otbAppLogINFO("Input image normalization activated."); // Normalize input image (optional) @@ -236,7 +249,6 @@ private: m_ClassificationFilter->SetInput(inImage); } - if(IsParameterEnabled("mask")) { otbAppLogINFO("Using input mask"); @@ -247,7 +259,6 @@ private: } SetParameterOutputImage<FloatVectorImageType>("out", outputImage); - } DimensionalityReductionFilterType::Pointer m_ClassificationFilter; @@ -256,8 +267,7 @@ private: OutputRescalerType::Pointer m_OutRescaler; }; - -} -} +} // end of namespace Wrapper +} // end of namespace otb OTB_APPLICATION_EXPORT(otb::Wrapper::ImageDimensionalityReduction) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx index 8b378f4f00..fa3dd7bdcb 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx @@ -28,18 +28,21 @@ #include "otbShiftScaleSampleListFilter.h" #include "otbStatisticsXMLFileReader.h" -//#include "otbSharkUtils.h" - #include <fstream> // write the model file #include "otbDimensionalityReductionModelFactory.h" #include "otbTrainDimensionalityReductionApplicationBase.h" - namespace otb { namespace Wrapper { + +/** + * \class TrainDimensionalityReduction + * + * Training of a dimensionality reduction model + */ class TrainDimensionalityReduction : public TrainDimensionalityReductionApplicationBase<float,float> { public: @@ -47,62 +50,64 @@ public: typedef TrainDimensionalityReductionApplicationBase<float, float> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - + itkNewMacro(Self); itkTypeMacro(TrainDimensionalityReduction, otb::Application); - typedef Superclass::SampleType SampleType; typedef Superclass::ListSampleType ListSampleType; typedef Superclass::SampleImageType SampleImageType; - + typedef float ValueType; typedef itk::VariableLengthVector<ValueType> MeasurementType; typedef otb::StatisticsXMLFileReader<SampleType> StatisticsReader; typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; - + typedef otb::DimensionalityReductionModelFactory<ValueType, ValueType> ModelFactoryType; - + private: void DoInit() { SetName("TrainDimensionalityReduction"); - SetDescription("Trainer for the dimensionality reduction algorithms used in the ImageDimensionalityReduction and VectorDimensionalityReduction applications."); - + SetDescription("Trainer for the dimensionality reduction algorithms used in" + " the ImageDimensionalityReduction and VectorDimensionalityReduction applications."); + AddParameter(ParameterType_Group, "io", "Input and output data"); SetParameterDescription("io", "This group of parameters allows setting input and output data."); AddParameter(ParameterType_InputVectorData, "io.vd", "Input Vector Data"); - SetParameterDescription("io.vd", "Input geometries used for training (note : all geometries from the layer will be used)"); + SetParameterDescription("io.vd", "Input geometries used for training (note " + ": all geometries from the layer will be used)"); AddParameter(ParameterType_OutputFilename, "io.out", "Output model"); SetParameterDescription("io.out", "Output file containing the estimated model (.txt format)."); - - + + AddParameter(ParameterType_InputFilename, "io.stats", "Input XML image statistics file"); MandatoryOff("io.stats"); SetParameterDescription("io.stats", "XML file containing mean and variance of each feature."); AddParameter(ParameterType_StringList, "feat", "Field names to be used for training."); // - SetParameterDescription("feat","List of field names in the input vector data used as features for training."); // - + SetParameterDescription("feat","List of field names in the input vector data" + " used as features for training."); // + Superclass::DoInit(); AddRAMParameter(); } - + void DoUpdateParameters() { } - - void DoExecute() - { + void DoExecute() + { std::string shapefile = GetParameterString("io.vd"); - otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); + otb::ogr::DataSource::Pointer source = + otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); otb::ogr::Layer layer = source->GetLayer(0); ListSampleType::Pointer input = ListSampleType::New(); const int nbFeatures = GetParameterStringList("feat").size(); @@ -120,10 +125,10 @@ private: } input->PushBack(mv); } - + MeasurementType meanMeasurementVector; MeasurementType stddevMeasurementVector; - + if (HasValue("io.stats") && IsParameterEnabled("io.stats")) { StatisticsReader::Pointer statisticsReader = StatisticsReader::New(); @@ -139,7 +144,7 @@ private: stddevMeasurementVector.SetSize(nbFeatures); stddevMeasurementVector.Fill(1.); } - + ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); trainingShiftScaleFilter->SetInput(input); trainingShiftScaleFilter->SetShifts(meanMeasurementVector); @@ -147,19 +152,13 @@ private: trainingShiftScaleFilter->Update(); ListSampleType::Pointer trainingListSample= trainingShiftScaleFilter->GetOutput(); - - + this->Train(trainingListSample,GetParameterString("io.out")); } - - - - }; - -} -} +} // end of namespace Wrapper +} // end of namespace otb OTB_APPLICATION_EXPORT(otb::Wrapper::TrainDimensionalityReduction) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx index b755ddeeba..dd4e89097b 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx @@ -32,356 +32,356 @@ namespace otb { namespace Wrapper { - + /** Utility function to negate std::isalnum */ bool IsNotAlphaNum(char c) { return !std::isalnum(c); } +/** + * \class VectorDimensionalityReduction + * + * Apply a dimensionality reduction model on a vector file + */ class VectorDimensionalityReduction : public Application { - public: - - /** Standard class typedefs. */ +public: + /** Standard class typedefs. */ typedef VectorDimensionalityReduction Self; typedef Application Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Standard macro */ - itkNewMacro(Self); - itkTypeMacro(Self, Application) - - /** Filters typedef */ - - typedef float ValueType; - typedef itk::VariableLengthVector<ValueType> InputSampleType; - typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; - typedef MachineLearningModel<itk::VariableLengthVector<ValueType>, itk::VariableLengthVector<ValueType>> DimensionalityReductionModelType; - typedef DimensionalityReductionModelFactory<ValueType,ValueType> DimensionalityReductionModelFactoryType; - typedef DimensionalityReductionModelType::Pointer ModelPointerType; - - /** Statistics Filters typedef */ - typedef itk::VariableLengthVector<ValueType> MeasurementType; - typedef otb::StatisticsXMLFileReader<MeasurementType> StatisticsReader; - typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Standard macro */ + itkNewMacro(Self); + itkTypeMacro(Self, Application) + + /** Filters typedef */ + typedef float ValueType; + typedef itk::VariableLengthVector<ValueType> InputSampleType; + typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; + typedef MachineLearningModel< + itk::VariableLengthVector<ValueType>, + itk::VariableLengthVector<ValueType> > DimensionalityReductionModelType; + typedef DimensionalityReductionModelFactory< + ValueType,ValueType> DimensionalityReductionModelFactoryType; + typedef DimensionalityReductionModelType::Pointer ModelPointerType; + + /** Statistics Filters typedef */ + typedef itk::VariableLengthVector<ValueType> MeasurementType; + typedef otb::StatisticsXMLFileReader<MeasurementType> StatisticsReader; + typedef otb::Statistics::ShiftScaleSampleListFilter< + ListSampleType, ListSampleType> ShiftScaleFilterType; + +protected: ~VectorDimensionalityReduction() ITK_OVERRIDE - { - DimensionalityReductionModelFactoryType::CleanFactories(); - } - - private: - - void DoInit() ITK_OVERRIDE - { - SetName("VectorDimensionalityReduction"); - SetDescription("Performs dimensionality reduction of the input vector data according to a model file."); - SetDocName("Vector Dimensionality Reduction"); - SetDocAuthors("OTB-Team"); - SetDocLongDescription("This application performs a vector data dimensionality reduction based on a model file produced by the TrainDimensionalityReduction application."); - SetDocSeeAlso("TrainDimensionalityReduction"); - AddDocTag(Tags::Learning); - - AddParameter(ParameterType_InputVectorData, "in", "Name of the input vector data"); - SetParameterDescription("in","The input vector data to reduce."); - - AddParameter(ParameterType_InputFilename, "instat", "Statistics file"); - SetParameterDescription("instat", "A XML file containing mean and standard deviation to center" - "and reduce samples before dimensionality reduction (produced by ComputeImagesStatistics application)."); - MandatoryOff("instat"); - - AddParameter(ParameterType_InputFilename, "model", "Model file"); - SetParameterDescription("model", "A model file (produced by the TrainDimensionalityReduction application,"); - - AddParameter(ParameterType_ListView, "feat", "Input features to use for reduction."); // - SetParameterDescription("feat","List of field names in the input vector data used as features for reduction."); // - - AddParameter(ParameterType_StringList, "featout", "Names of the new output features."); // - SetParameterDescription("featout","List of field names for the output features which result from the reduction."); // - - AddParameter(ParameterType_OutputFilename, "out", "Output vector data file containing the reduced vector"); - SetParameterDescription("out","Output vector data file storing sample values (OGR format)." - "If not given, the input vector data file is used. In overwrite mode, the original features will be lost."); - MandatoryOff("out"); - - AddParameter(ParameterType_Int, "indim", "Dimension of the input vector"); - SetParameterDescription("indim","Dimension of the whole input vector, this value is required if only a part of the bands contained in the vector are used." - "If not given, the dimension is deduced from the length of the 'feat' parameter"); - MandatoryOff("indim"); - - AddParameter(ParameterType_Int, "pcadim", "Principal component"); // - SetParameterDescription("pcadim","This optional parameter can be set to reduce the number of eignevectors used in the PCA model file."); // - MandatoryOff("pcadim"); - - AddParameter(ParameterType_String, "mode", "Writting mode"); // - SetParameterString("mode","overwrite", false); - SetParameterDescription("mode","This parameter determines if the output file is overwritten or updated [overwrite/update]. If an output file name is given, the original file is copied before creating the new features."); // - - - // Doc example parameter settings - SetDocExampleParameterValue("in", "vectorData.shp"); - SetDocExampleParameterValue("instat", "meanVar.xml"); - SetDocExampleParameterValue("model", "model.txt"); - SetDocExampleParameterValue("out", "vectorDataOut.shp"); - SetDocExampleParameterValue("feat", "perimeter area width"); - SetDocExampleParameterValue("featout", "perimeter area width"); - //SetOfficialDocLink(); - } - // - void DoUpdateParameters() ITK_OVERRIDE - { - - if ( HasValue("in") ) - { - - std::string shapefile = GetParameterString("in"); - otb::ogr::DataSource::Pointer ogrDS; - OGRSpatialReference oSRS(""); - std::vector<std::string> options; - ogrDS = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); - otb::ogr::Layer layer = ogrDS->GetLayer(0); - OGRFeatureDefn &layerDefn = layer.GetLayerDefn(); - ClearChoices("feat"); - //ClearChoices("featout"); - - for(int iField=0; iField< layerDefn.GetFieldCount(); iField++) - { - std::string item = layerDefn.GetFieldDefn(iField)->GetNameRef(); - std::string key(item); - std::string::iterator end = std::remove_if( key.begin(), key.end(), IsNotAlphaNum ); - std::transform( key.begin(), end, key.begin(), tolower ); - /* - key.erase( std::remove_if(key.begin(),key.end(),IsNotAlphaNum), key.end()); - std::transform(key.begin(), key.end(), key.begin(), tolower);*/ - //OGRFieldType fieldType = layerDefn.GetFieldDefn(iField)->GetType(); - /* if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal) - {*/ - //std::string tmpKey="feat."+key; - std::string tmpKey = "feat." + key.substr( 0, static_cast<unsigned long>( end - key.begin() ) ); - AddChoice(tmpKey,item); - //} // this is the same as in otbVectorClassifier, but it doesnt work - } - - } - - } - - void DoExecute() ITK_OVERRIDE - { - clock_t tic = clock(); - - - std::string shapefile = GetParameterString("in"); - otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); - otb::ogr::Layer layer = source->GetLayer(0); - ListSampleType::Pointer input = ListSampleType::New(); - int nbFeatures = GetSelectedItems("feat").size(); - - input->SetMeasurementVectorSize(nbFeatures); - otb::ogr::Layer::const_iterator it = layer.cbegin(); - otb::ogr::Layer::const_iterator itEnd = layer.cend(); - - for( ; it!=itEnd ; ++it) - { - MeasurementType mv; - mv.SetSize(nbFeatures); - - for(int idx=0; idx < nbFeatures; ++idx) - { - mv[idx] = static_cast<float>( (*it)[GetSelectedItems("feat")[idx]].GetValue<double>() ); - - } - input->PushBack(mv); - - } - - - /** Statistics for shift/scale */ - - MeasurementType meanMeasurementVector; - MeasurementType stddevMeasurementVector; - - if (HasValue("instat") && IsParameterEnabled("instat")) - { - StatisticsReader::Pointer statisticsReader = StatisticsReader::New(); - std::string XMLfile = GetParameterString("instat"); - statisticsReader->SetFileName(XMLfile); - meanMeasurementVector = statisticsReader->GetStatisticVectorByName("mean"); - stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); - } - else - { - meanMeasurementVector.SetSize(nbFeatures); - meanMeasurementVector.Fill(0.); - stddevMeasurementVector.SetSize(nbFeatures); - stddevMeasurementVector.Fill(1.); - } - - ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); - trainingShiftScaleFilter->SetInput(input); - trainingShiftScaleFilter->SetShifts(meanMeasurementVector); - trainingShiftScaleFilter->SetScales(stddevMeasurementVector); - trainingShiftScaleFilter->Update(); - otbAppLogINFO("mean used: " << meanMeasurementVector); - otbAppLogINFO("standard deviation used: " << stddevMeasurementVector); - otbAppLogINFO("Loading model"); - - - /** Read the model */ - - m_Model = DimensionalityReductionModelFactoryType::CreateDimensionalityReductionModel(GetParameterString("model"), - DimensionalityReductionModelFactoryType::ReadMode); - if (m_Model.IsNull()) - { - otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") << " : unsupported model type"); - } - if (HasValue("pcadim") && IsParameterEnabled("pcadim")) - { - int dimension = GetParameterInt("pcadim"); - m_Model->SetDimension(dimension ); - } - - - m_Model->Load(GetParameterString("model")); - otbAppLogINFO("Model loaded"); - - /** Perform Dimensionality Reduction */ - - ListSampleType::Pointer listSample = trainingShiftScaleFilter->GetOutput(); - ListSampleType::Pointer target = m_Model->PredictBatch(listSample); - - /** Create/Update Output Shape file */ - - ogr::DataSource::Pointer output; - ogr::DataSource::Pointer buffer = ogr::DataSource::New(); - bool updateMode = false; - - int nbBands = nbFeatures; - if (HasValue("indim") && IsParameterEnabled("indim")) - {nbBands = GetParameterInt("indim");} - - - if (IsParameterEnabled("out") && HasValue("out")) - { - // Create new OGRDataSource - if (GetParameterString("mode")=="overwrite") - { - output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite); - otb::ogr::Layer newLayer = output->CreateLayer(GetParameterString("out"), - const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), - layer.GetGeomType()); - // Copy existing fields - OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); - for (int k=0 ; k<inLayerDefn.GetFieldCount()-nbBands ; k++) // we don't copy the original bands - { - OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); - newLayer.CreateField(fieldDefn); - } - } - else if (GetParameterString("mode")=="update") - { - //output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Update_LayerCreateOnly); - // Update mode - otb::ogr::DataSource::Pointer source_output = otb::ogr::DataSource::New(GetParameterString("out"), otb::ogr::DataSource::Modes::Read); - layer = source_output->GetLayer(0); - updateMode = true; - otbAppLogINFO("Update input vector data."); - - // fill temporary buffer for the transfer - otb::ogr::Layer inputLayer = layer; - layer = buffer->CopyLayer(inputLayer, std::string("Buffer")); - // close input data source - source_output->Clear(); - // Re-open input data source in update mode - output = otb::ogr::DataSource::New(GetParameterString("out"), otb::ogr::DataSource::Modes::Update_LayerUpdate); - - } - else - { - otbAppLogFATAL(<< "Error when creating the output file" << GetParameterString("mode") << " : unsupported writting mode type"); - } - - - } - - - - - otb::ogr::Layer outLayer = output->GetLayer(0); - - OGRErr errStart = outLayer.ogr().StartTransaction(); - - if (errStart != OGRERR_NONE) - { - itkExceptionMacro(<< "Unable to start transaction for OGR layer " << outLayer.ogr().GetName() << "."); - } - - // Add the field of prediction in the output layer if field not exist - - for (unsigned int i=0; i<GetParameterStringList("featout").size() ;i++) - { - OGRFeatureDefn &layerDefn = outLayer.GetLayerDefn(); - int idx = layerDefn.GetFieldIndex(GetParameterStringList("featout")[i].c_str()); - - if (idx >= 0) - { - if (layerDefn.GetFieldDefn(idx)->GetType() != OFTReal) - itkExceptionMacro("Field name "<< GetParameterStringList("featout")[i] << " already exists with a different type!"); - } - else - { - OGRFieldDefn predictedField(GetParameterStringList("featout")[i].c_str(), OFTReal); - ogr::FieldDefn predictedFieldDef(predictedField); - outLayer.CreateField(predictedFieldDef); - } - } - - - // Fill output layer - - unsigned int count=0; - auto classfieldname = GetParameterStringList("featout"); - it = layer.cbegin(); - itEnd = layer.cend(); - - for( ; it!=itEnd ; ++it, ++count) - { - ogr::Feature dstFeature(outLayer.GetLayerDefn()); - - dstFeature.SetFrom( *it , TRUE); - dstFeature.SetFID(it->GetFID()); - - - - for (std::size_t i=0; i<classfieldname.size(); ++i){ - dstFeature[classfieldname[i]].SetValue<double>(target->GetMeasurementVector(count)[i]); - } - if (updateMode) - { - outLayer.SetFeature(dstFeature); - } - else - { - outLayer.CreateFeature(dstFeature); - } - } - - if(outLayer.ogr().TestCapability("Transactions")) - { - const OGRErr errCommitX = outLayer.ogr().CommitTransaction(); - if (errCommitX != OGRERR_NONE) - { - itkExceptionMacro(<< "Unable to commit transaction for OGR layer " << outLayer.ogr().GetName() << "."); - } - } - output->SyncToDisk(); - clock_t toc = clock(); - otbAppLogINFO( "Elapsed: "<< ((double)(toc - tic) / CLOCKS_PER_SEC)<<" seconds."); - } - - ModelPointerType m_Model; + { + DimensionalityReductionModelFactoryType::CleanFactories(); + } + +private: + void DoInit() ITK_OVERRIDE + { + SetName("VectorDimensionalityReduction"); + SetDescription("Performs dimensionality reduction of the input vector data " + "according to a model file."); + SetDocName("Vector Dimensionality Reduction"); + SetDocAuthors("OTB-Team"); + SetDocLongDescription("This application performs a vector data " + "dimensionality reduction based on a model file produced by the " + "TrainDimensionalityReduction application."); + SetDocSeeAlso("TrainDimensionalityReduction"); + AddDocTag(Tags::Learning); + + AddParameter(ParameterType_InputVectorData, "in", "Name of the input vector data"); + SetParameterDescription("in","The input vector data to reduce."); + + AddParameter(ParameterType_InputFilename, "instat", "Statistics file"); + SetParameterDescription("instat", "A XML file containing mean and standard " + "deviation to center and reduce samples before dimensionality reduction " + "(produced by ComputeImagesStatistics application)."); + MandatoryOff("instat"); + + AddParameter(ParameterType_InputFilename, "model", "Model file"); + SetParameterDescription("model", "A model file (produced by the " + "TrainDimensionalityReduction application,"); + + AddParameter(ParameterType_ListView, "feat", "Input features to use for reduction."); // + SetParameterDescription("feat","List of field names in the input vector " + "data used as features for reduction."); // + + AddParameter(ParameterType_StringList, "featout", "Names of the new output features."); // + SetParameterDescription("featout","List of field names for the output " + "features which result from the reduction."); // + + AddParameter(ParameterType_OutputFilename, "out", "Output vector data file " + "containing the reduced vector"); + SetParameterDescription("out","Output vector data file storing sample " + "values (OGR format). If not given, the input vector data file is used. " + "In overwrite mode, the original features will be lost."); + MandatoryOff("out"); + + AddParameter(ParameterType_Int, "indim", "Dimension of the input vector"); + SetParameterDescription("indim","Dimension of the whole input vector, this " + "value is required if only a part of the bands contained in the vector " + "are used. If not given, the dimension is deduced from the length of the " + "'feat' parameter"); + MandatoryOff("indim"); + + AddParameter(ParameterType_Int, "pcadim", "Principal component"); // + SetParameterDescription("pcadim","This optional parameter can be set to " + "reduce the number of eignevectors used in the PCA model file."); // + MandatoryOff("pcadim"); + + AddParameter(ParameterType_String, "mode", "Writting mode"); // + SetParameterString("mode","overwrite", false); + SetParameterDescription("mode","This parameter determines if the output " + "file is overwritten or updated [overwrite/update]. If an output file " + "name is given, the original file is copied before creating the new features."); // + + // Doc example parameter settings + SetDocExampleParameterValue("in", "vectorData.shp"); + SetDocExampleParameterValue("instat", "meanVar.xml"); + SetDocExampleParameterValue("model", "model.txt"); + SetDocExampleParameterValue("out", "vectorDataOut.shp"); + SetDocExampleParameterValue("feat", "perimeter area width"); + SetDocExampleParameterValue("featout", "perimeter area width"); + //SetOfficialDocLink(); + } + + void DoUpdateParameters() ITK_OVERRIDE + { + if ( HasValue("in") ) + { + std::string shapefile = GetParameterString("in"); + otb::ogr::DataSource::Pointer ogrDS; + OGRSpatialReference oSRS(""); + std::vector<std::string> options; + ogrDS = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); + otb::ogr::Layer layer = ogrDS->GetLayer(0); + OGRFeatureDefn &layerDefn = layer.GetLayerDefn(); + ClearChoices("feat"); + + for(int iField=0; iField< layerDefn.GetFieldCount(); iField++) + { + std::string item = layerDefn.GetFieldDefn(iField)->GetNameRef(); + std::string key(item); + std::string::iterator end = std::remove_if( key.begin(), key.end(), IsNotAlphaNum ); + std::transform( key.begin(), end, key.begin(), tolower ); + std::string tmpKey = "feat." + key.substr( 0, static_cast<unsigned long>( end - key.begin() ) ); + AddChoice(tmpKey,item); + } + } + } + + void DoExecute() ITK_OVERRIDE + { + clock_t tic = clock(); + + std::string shapefile = GetParameterString("in"); + otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New( + shapefile, otb::ogr::DataSource::Modes::Read); + otb::ogr::Layer layer = source->GetLayer(0); + ListSampleType::Pointer input = ListSampleType::New(); + int nbFeatures = GetSelectedItems("feat").size(); + + input->SetMeasurementVectorSize(nbFeatures); + otb::ogr::Layer::const_iterator it = layer.cbegin(); + otb::ogr::Layer::const_iterator itEnd = layer.cend(); + + for( ; it!=itEnd ; ++it) + { + MeasurementType mv; + mv.SetSize(nbFeatures); + + for(int idx=0; idx < nbFeatures; ++idx) + { + mv[idx] = static_cast<float>( (*it)[GetSelectedItems("feat")[idx]].GetValue<double>() ); + } + input->PushBack(mv); + } + + /** Statistics for shift/scale */ + MeasurementType meanMeasurementVector; + MeasurementType stddevMeasurementVector; + + if (HasValue("instat") && IsParameterEnabled("instat")) + { + StatisticsReader::Pointer statisticsReader = StatisticsReader::New(); + std::string XMLfile = GetParameterString("instat"); + statisticsReader->SetFileName(XMLfile); + meanMeasurementVector = statisticsReader->GetStatisticVectorByName("mean"); + stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); + } + else + { + meanMeasurementVector.SetSize(nbFeatures); + meanMeasurementVector.Fill(0.); + stddevMeasurementVector.SetSize(nbFeatures); + stddevMeasurementVector.Fill(1.); + } + + ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); + trainingShiftScaleFilter->SetInput(input); + trainingShiftScaleFilter->SetShifts(meanMeasurementVector); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector); + trainingShiftScaleFilter->Update(); + otbAppLogINFO("mean used: " << meanMeasurementVector); + otbAppLogINFO("standard deviation used: " << stddevMeasurementVector); + otbAppLogINFO("Loading model"); + + /** Read the model */ + m_Model = DimensionalityReductionModelFactoryType::CreateDimensionalityReductionModel( + GetParameterString("model"), + DimensionalityReductionModelFactoryType::ReadMode); + if (m_Model.IsNull()) + { + otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") + << " : unsupported model type"); + } + if (HasValue("pcadim") && IsParameterEnabled("pcadim")) + { + int dimension = GetParameterInt("pcadim"); + m_Model->SetDimension(dimension ); + } + + m_Model->Load(GetParameterString("model")); + otbAppLogINFO("Model loaded"); + + /** Perform Dimensionality Reduction */ + ListSampleType::Pointer listSample = trainingShiftScaleFilter->GetOutput(); + ListSampleType::Pointer target = m_Model->PredictBatch(listSample); + + /** Create/Update Output Shape file */ + ogr::DataSource::Pointer output; + ogr::DataSource::Pointer buffer = ogr::DataSource::New(); + bool updateMode = false; + + int nbBands = nbFeatures; + if (HasValue("indim") && IsParameterEnabled("indim")) + { + nbBands = GetParameterInt("indim"); + } + + if (IsParameterEnabled("out") && HasValue("out")) + { + // Create new OGRDataSource + if (GetParameterString("mode")=="overwrite") + { + output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite); + otb::ogr::Layer newLayer = output->CreateLayer( + GetParameterString("out"), + const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), + layer.GetGeomType()); + // Copy existing fields + OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); + for (int k=0 ; k<inLayerDefn.GetFieldCount()-nbBands ; k++) // we don't copy the original bands + { + OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); + newLayer.CreateField(fieldDefn); + } + } + else if (GetParameterString("mode")=="update") + { + //output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Update_LayerCreateOnly); + // Update mode + otb::ogr::DataSource::Pointer source_output = + otb::ogr::DataSource::New(GetParameterString("out"), otb::ogr::DataSource::Modes::Read); + layer = source_output->GetLayer(0); + updateMode = true; + otbAppLogINFO("Update input vector data."); + + // fill temporary buffer for the transfer + otb::ogr::Layer inputLayer = layer; + layer = buffer->CopyLayer(inputLayer, std::string("Buffer")); + // close input data source + source_output->Clear(); + // Re-open input data source in update mode + output = otb::ogr::DataSource::New( + GetParameterString("out"), + otb::ogr::DataSource::Modes::Update_LayerUpdate); + } + else + { + otbAppLogFATAL(<< "Error when creating the output file" << + GetParameterString("mode") << " : unsupported writting mode type"); + } + } + + otb::ogr::Layer outLayer = output->GetLayer(0); + OGRErr errStart = outLayer.ogr().StartTransaction(); + + if (errStart != OGRERR_NONE) + { + itkExceptionMacro(<< "Unable to start transaction for OGR layer " << outLayer.ogr().GetName() << "."); + } + + // Add the field of prediction in the output layer if field not exist + for (unsigned int i=0; i<GetParameterStringList("featout").size() ;i++) + { + OGRFeatureDefn &layerDefn = outLayer.GetLayerDefn(); + int idx = layerDefn.GetFieldIndex(GetParameterStringList("featout")[i].c_str()); + + if (idx >= 0) + { + if (layerDefn.GetFieldDefn(idx)->GetType() != OFTReal) + itkExceptionMacro("Field name "<< GetParameterStringList("featout")[i] + << " already exists with a different type!"); + } + else + { + OGRFieldDefn predictedField(GetParameterStringList("featout")[i].c_str(), OFTReal); + ogr::FieldDefn predictedFieldDef(predictedField); + outLayer.CreateField(predictedFieldDef); + } + } + + // Fill output layer + unsigned int count=0; + auto classfieldname = GetParameterStringList("featout"); + it = layer.cbegin(); + itEnd = layer.cend(); + + for( ; it!=itEnd ; ++it, ++count) + { + ogr::Feature dstFeature(outLayer.GetLayerDefn()); + + dstFeature.SetFrom( *it , TRUE); + dstFeature.SetFID(it->GetFID()); + + for (std::size_t i=0; i<classfieldname.size(); ++i) + { + dstFeature[classfieldname[i]].SetValue<double>(target->GetMeasurementVector(count)[i]); + } + if (updateMode) + { + outLayer.SetFeature(dstFeature); + } + else + { + outLayer.CreateFeature(dstFeature); + } + } + + if(outLayer.ogr().TestCapability("Transactions")) + { + const OGRErr errCommitX = outLayer.ogr().CommitTransaction(); + if (errCommitX != OGRERR_NONE) + { + itkExceptionMacro(<< "Unable to commit transaction for OGR layer " << + outLayer.ogr().GetName() << "."); + } + } + output->SyncToDisk(); + clock_t toc = clock(); + otbAppLogINFO( "Elapsed: "<< ((double)(toc - tic) / CLOCKS_PER_SEC)<<" seconds."); + } + + ModelPointerType m_Model; }; -} -} + +} // end of namespace Wrapper +} // end of namespace otb + OTB_APPLICATION_EXPORT(otb::Wrapper::VectorDimensionalityReduction) diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx index 3e9107a9a8..efcbd303b9 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx @@ -33,28 +33,22 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::InitAutoencoderParams() { - - AddChoice("algorithm.tiedautoencoder", "Shark Tied Autoencoder"); AddChoice("algorithm.autoencoder", "Shark Autoencoder"); SetParameterDescription("algorithm.autoencoder", "This group of parameters allows setting Shark autoencoder parameters. " ); - - + //Tied Autoencoder AddParameter(ParameterType_Choice, "algorithm.autoencoder.istied", "tied weighth <tied/untied>"); SetParameterDescription( "algorithm.autoencoder.istied", "Parameter that determine if the weights are tied or not <tied/untied>"); - - + AddChoice("algorithm.autoencoder.istied.yes","Tied weigths"); AddChoice("algorithm.autoencoder.istied.no","Untied weights"); - - - + //Number Of Iterations AddParameter(ParameterType_Int, "algorithm.autoencoder.nbiter", "Maximum number of iterations during training"); @@ -62,47 +56,43 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> SetParameterDescription( "algorithm.autoencoder.nbiter", "The maximum number of iterations used during training."); - + AddParameter(ParameterType_Int, "algorithm.autoencoder.nbiterfinetuning", "Maximum number of iterations during training"); SetParameterInt("algorithm.autoencoder.nbiterfinetuning",0, false); SetParameterDescription( "algorithm.autoencoder.nbiterfinetuning", "The maximum number of iterations used during fine tuning of the whole network."); - + AddParameter(ParameterType_Float, "algorithm.autoencoder.epsilon", - " "); + "Epsilon"); SetParameterFloat("algorithm.autoencoder.epsilon",0, false); SetParameterDescription( "algorithm.autoencoder.epsilon", - " "); - - + "Epsilon"); + AddParameter(ParameterType_Float, "algorithm.autoencoder.initfactor", - " "); + "Weight initialization factor"); SetParameterFloat("algorithm.autoencoder.initfactor",1, false); SetParameterDescription( - "algorithm.autoencoder.initfactor", "parameter that control the weight initialization of the autoencoder"); - + "algorithm.autoencoder.initfactor", "Parameter that control the weight initialization of the autoencoder"); + //Number Of Hidden Neurons - AddParameter(ParameterType_StringList , "algorithm.autoencoder.nbneuron", "Size"); - /*AddParameter(ParameterType_Int, "algorithm.autoencoder.nbneuron", - "Number of neurons in the hidden layer"); - SetParameterInt("algorithm.autoencoder.nbneuron",10, false);*/ + AddParameter(ParameterType_StringList, "algorithm.autoencoder.nbneuron", "Size"); SetParameterDescription( "algorithm.autoencoder.nbneuron", "The number of neurons in each hidden layer."); - + //Regularization AddParameter(ParameterType_StringList, "algorithm.autoencoder.regularization", "Strength of the regularization"); SetParameterDescription("algorithm.autoencoder.regularization", "Strength of the L2 regularization used during training"); - + //Noise strength AddParameter(ParameterType_StringList, "algorithm.autoencoder.noise", "Strength of the noise"); SetParameterDescription("algorithm.autoencoder.noise", "Strength of the noise"); - + // Sparsity parameter AddParameter(ParameterType_StringList, "algorithm.autoencoder.rho", "Sparsity parameter"); SetParameterDescription("algorithm.autoencoder.rho", @@ -116,97 +106,80 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> AddParameter(ParameterType_OutputFilename, "algorithm.autoencoder.learningcurve", "Learning curve"); SetParameterDescription("algorithm.autoencoder.learningcurve", "Learning error values"); MandatoryOff("algorithm.autoencoder.learningcurve"); - } - template <class TInputValue, class TOutputValue> void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath) { - // typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; typedef shark::LogisticNeuron NeuronType; typedef otb::AutoencoderModel<InputValueType, NeuronType> AutoencoderModelType; - /* - // typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType; - typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron> TiedAutoencoderType; - typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType; - */ std::string TiedWeigth = GetParameterString("algorithm.autoencoder.istied"); std::cout << TiedWeigth << std::endl; - + if(TiedWeigth == "no") - { - TrainAutoencoder<AutoencoderModelType>(trainingListSample,modelPath); - } - /* - if(TiedWeigth == "yes") - { - TrainAutoencoder<TiedAutoencoderModelType>(trainingListSample,modelPath); - } - */ - if(TiedWeigth != "yes" && TiedWeigth != "no") - { - std::cerr << "istied : invalid choice <yes/no>" << std::endl; - } + { + TrainAutoencoder<AutoencoderModelType>(trainingListSample,modelPath); + } + if(TiedWeigth != "yes" && TiedWeigth != "no") + { + std::cerr << "istied : invalid choice <yes/no>" << std::endl; + } } - - template <class TInputValue, class TOutputValue> template <typename autoencoderchoice> void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue>::TrainAutoencoder(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { - typename autoencoderchoice::Pointer dimredTrainer = autoencoderchoice::New(); - itk::Array<unsigned int> nb_neuron; - itk::Array<float> noise; - itk::Array<float> regularization; - itk::Array<float> rho; - itk::Array<float> beta; - std::vector<std::basic_string<char>> s_nbneuron= GetParameterStringList("algorithm.autoencoder.nbneuron"); - std::vector<std::basic_string<char>> s_noise= GetParameterStringList("algorithm.autoencoder.noise"); - std::vector<std::basic_string<char>> s_regularization= GetParameterStringList("algorithm.autoencoder.regularization"); - std::vector<std::basic_string<char>> s_rho= GetParameterStringList("algorithm.autoencoder.rho"); - std::vector<std::basic_string<char>> s_beta= GetParameterStringList("algorithm.autoencoder.beta"); - nb_neuron.SetSize(s_nbneuron.size()); - noise.SetSize(s_nbneuron.size()); - regularization.SetSize(s_nbneuron.size()); - rho.SetSize(s_nbneuron.size()); - beta.SetSize(s_nbneuron.size()); - for (unsigned int i=0; i<s_nbneuron.size(); i++){ - nb_neuron[i]=std::stoi(s_nbneuron[i]); - noise[i]=std::stof(s_noise[i]); - regularization[i]=std::stof(s_regularization[i]); - rho[i]=std::stof(s_rho[i]); - beta[i]=std::stof(s_beta[i]); - } - dimredTrainer->SetNumberOfHiddenNeurons(nb_neuron); - dimredTrainer->SetNumberOfIterations(GetParameterInt("algorithm.autoencoder.nbiter")); - dimredTrainer->SetNumberOfIterationsFineTuning(GetParameterInt("algorithm.autoencoder.nbiterfinetuning")); - dimredTrainer->SetEpsilon(GetParameterFloat("algorithm.autoencoder.epsilon")); - dimredTrainer->SetInitFactor(GetParameterFloat("algorithm.autoencoder.initfactor")); - dimredTrainer->SetRegularization(regularization); - dimredTrainer->SetNoise(noise); - dimredTrainer->SetRho(rho); - dimredTrainer->SetBeta(beta); - - dimredTrainer->SetWriteWeights(true); - if (HasValue("algorithm.autoencoder.learningcurve") && IsParameterEnabled("algorithm.autoencoder.learningcurve")) - { - std::cout << "yo" << std::endl; - dimredTrainer->SetWriteLearningCurve(true); - dimredTrainer->SetLearningCurveFileName(GetParameterString("algorithm.autoencoder.learningcurve")); - } - - dimredTrainer->SetInputListSample(trainingListSample); - std::cout << "before train" << std::endl; - dimredTrainer->Train(); - std::cout << "after train" << std::endl; - dimredTrainer->Save(modelPath); - + typename autoencoderchoice::Pointer dimredTrainer = autoencoderchoice::New(); + itk::Array<unsigned int> nb_neuron; + itk::Array<float> noise; + itk::Array<float> regularization; + itk::Array<float> rho; + itk::Array<float> beta; + std::vector<std::basic_string<char>> s_nbneuron= GetParameterStringList("algorithm.autoencoder.nbneuron"); + std::vector<std::basic_string<char>> s_noise= GetParameterStringList("algorithm.autoencoder.noise"); + std::vector<std::basic_string<char>> s_regularization= GetParameterStringList("algorithm.autoencoder.regularization"); + std::vector<std::basic_string<char>> s_rho= GetParameterStringList("algorithm.autoencoder.rho"); + std::vector<std::basic_string<char>> s_beta= GetParameterStringList("algorithm.autoencoder.beta"); + nb_neuron.SetSize(s_nbneuron.size()); + noise.SetSize(s_nbneuron.size()); + regularization.SetSize(s_nbneuron.size()); + rho.SetSize(s_nbneuron.size()); + beta.SetSize(s_nbneuron.size()); + for (unsigned int i=0; i<s_nbneuron.size(); i++) + { + nb_neuron[i]=std::stoi(s_nbneuron[i]); + noise[i]=std::stof(s_noise[i]); + regularization[i]=std::stof(s_regularization[i]); + rho[i]=std::stof(s_rho[i]); + beta[i]=std::stof(s_beta[i]); + } + dimredTrainer->SetNumberOfHiddenNeurons(nb_neuron); + dimredTrainer->SetNumberOfIterations(GetParameterInt("algorithm.autoencoder.nbiter")); + dimredTrainer->SetNumberOfIterationsFineTuning(GetParameterInt("algorithm.autoencoder.nbiterfinetuning")); + dimredTrainer->SetEpsilon(GetParameterFloat("algorithm.autoencoder.epsilon")); + dimredTrainer->SetInitFactor(GetParameterFloat("algorithm.autoencoder.initfactor")); + dimredTrainer->SetRegularization(regularization); + dimredTrainer->SetNoise(noise); + dimredTrainer->SetRho(rho); + dimredTrainer->SetBeta(beta); + dimredTrainer->SetWriteWeights(true); + if (HasValue("algorithm.autoencoder.learningcurve") && + IsParameterEnabled("algorithm.autoencoder.learningcurve")) + { + std::cout << "yo" << std::endl; + dimredTrainer->SetWriteLearningCurve(true); + dimredTrainer->SetLearningCurveFileName(GetParameterString("algorithm.autoencoder.learningcurve")); + } + dimredTrainer->SetInputListSample(trainingListSample); + std::cout << "before train" << std::endl; + dimredTrainer->Train(); + std::cout << "after train" << std::endl; + dimredTrainer->Save(modelPath); } } //end namespace wrapper diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx index b04bd41eae..03016916cb 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainPCA.txx @@ -33,14 +33,11 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::InitPCAParams() { - - AddChoice("algorithm.pca", "Shark PCA"); SetParameterDescription("algorithm.pca", "This group of parameters allows setting Shark PCA parameters. " ); - - + //Output Dimension AddParameter(ParameterType_Int, "algorithm.pca.dim", "Dimension of the output of the pca transformation"); @@ -48,8 +45,6 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> SetParameterDescription( "algorithm.pca.dim", "Dimension of the output of the pca transformation."); - - } template <class TInputValue, class TOutputValue> @@ -57,12 +52,12 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::TrainPCA(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { typedef otb::PCAModel<InputValueType> PCAModelType; - typename PCAModelType::Pointer dimredTrainer = PCAModelType::New(); - dimredTrainer->SetDimension(GetParameterInt("algorithm.pca.dim")); - dimredTrainer->SetInputListSample(trainingListSample); - dimredTrainer->SetWriteEigenvectors(true); - dimredTrainer->Train(); - dimredTrainer->Save(modelPath); + typename PCAModelType::Pointer dimredTrainer = PCAModelType::New(); + dimredTrainer->SetDimension(GetParameterInt("algorithm.pca.dim")); + dimredTrainer->SetInputListSample(trainingListSample); + dimredTrainer->SetWriteEigenvectors(true); + dimredTrainer->Train(); + dimredTrainer->Save(modelPath); } } //end namespace wrapper diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx index 2cfeb1ad30..535c839e73 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx @@ -32,20 +32,19 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::InitSOMParams() { - AddChoice("algorithm.som", "OTB SOM"); SetParameterDescription("algorithm.som", "This group of parameters allows setting SOM parameters. " ); - AddParameter(ParameterType_Int, "algorithm.som.dim","Dimension of the map"); - SetParameterDescription("algorithm.som.dim","Dimension of the SOM map."); + AddParameter(ParameterType_Int, "algorithm.som.dim","Dimension of the map"); + SetParameterDescription("algorithm.som.dim","Dimension of the SOM map."); - AddParameter(ParameterType_StringList , "algorithm.som.s", "Size"); + AddParameter(ParameterType_StringList , "algorithm.som.s", "Size"); SetParameterDescription("algorithm.som.s", "Size of the SOM map"); MandatoryOff("algorithm.som.s"); - AddParameter(ParameterType_StringList , "algorithm.som.n", "Size Neighborhood"); + AddParameter(ParameterType_StringList , "algorithm.som.n", "Size Neighborhood"); SetParameterDescription("algorithm.som.n", "Size of the initial neighborhood in the SOM map"); MandatoryOff("algorithm.som.n"); @@ -99,74 +98,69 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath) { - //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType; - //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType; - //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType; - //typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; - typedef otb::SOMModel<InputValueType, 2> SOM2DModelType; - typedef otb::SOMModel<InputValueType, 3> SOM3DModelType; - typedef otb::SOMModel<InputValueType, 4> SOM4DModelType; - typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; - int SomDim = GetParameterInt("algorithm.som.dim"); std::cout << SomDim << std::endl; - + if(SomDim == 2) - { - TrainSOM<SOM2DModelType >(trainingListSample,modelPath); - } - - if(SomDim == 3) - { - TrainSOM<SOM3DModelType >(trainingListSample,modelPath); - } - - if(SomDim == 4) - { - TrainSOM<SOM4DModelType >(trainingListSample,modelPath); - } - - if(SomDim == 5) - { - TrainSOM<SOM5DModelType >(trainingListSample,modelPath); - } - if(SomDim > 5 || SomDim < 2) - { - std::cerr << "k : invalid dimension" << std::endl; - } + { + typedef otb::SOMModel<InputValueType, 2> SOM2DModelType; + TrainSOM<SOM2DModelType >(trainingListSample,modelPath); + } + + if(SomDim == 3) + { + typedef otb::SOMModel<InputValueType, 3> SOM3DModelType; + TrainSOM<SOM3DModelType >(trainingListSample,modelPath); + } + + if(SomDim == 4) + { + typedef otb::SOMModel<InputValueType, 4> SOM4DModelType; + TrainSOM<SOM4DModelType >(trainingListSample,modelPath); + } + + if(SomDim == 5) + { + typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; + TrainSOM<SOM5DModelType >(trainingListSample,modelPath); + } + if(SomDim > 5 || SomDim < 2) + { + std::cerr << "k : invalid dimension" << std::endl; + } } - template <class TInputValue, class TOutputValue> -template <typename somchoice> +template <typename TSOM> void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::TrainSOM(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { - using TemplateEstimatorType = typename somchoice::EstimatorType; - typename somchoice::Pointer dimredTrainer = somchoice::New(); - unsigned int dim = dimredTrainer->GetDimension(); - std::cout << dim << std::endl; - dimredTrainer->SetNumberOfIterations(GetParameterInt("algorithm.som.ni")); - dimredTrainer->SetBetaInit(GetParameterFloat("algorithm.som.bi")); - dimredTrainer->SetWriteMap(true); - dimredTrainer->SetBetaEnd(GetParameterFloat("algorithm.som.bf")); - dimredTrainer->SetMaxWeight(GetParameterFloat("algorithm.som.iv")); - typename TemplateEstimatorType::SizeType size; - std::vector<std::basic_string<char>> s= GetParameterStringList("algorithm.som.s"); - for (unsigned int i=0; i<dim; i++){ - size[i]=std::stoi(s[i]); - } - - dimredTrainer->SetMapSize(size); - typename TemplateEstimatorType::SizeType radius; - std::vector<std::basic_string<char>> n= GetParameterStringList("algorithm.som.n"); - for (unsigned int i=0; i<dim; i++){ - radius[i]=std::stoi(n[i]); - } - dimredTrainer->SetNeighborhoodSizeInit(radius); - dimredTrainer->SetListSample(trainingListSample); - dimredTrainer->Train(); - dimredTrainer->Save(modelPath); + typename TSOM::Pointer dimredTrainer = TSOM::New(); + unsigned int dim = dimredTrainer->GetDimension(); + std::cout << dim << std::endl; + dimredTrainer->SetNumberOfIterations(GetParameterInt("algorithm.som.ni")); + dimredTrainer->SetBetaInit(GetParameterFloat("algorithm.som.bi")); + dimredTrainer->SetWriteMap(true); + dimredTrainer->SetBetaEnd(GetParameterFloat("algorithm.som.bf")); + dimredTrainer->SetMaxWeight(GetParameterFloat("algorithm.som.iv")); + typename TSOM::SizeType size; + std::vector<std::basic_string<char>> s= GetParameterStringList("algorithm.som.s"); + for (unsigned int i=0; i<dim; i++) + { + size[i]=std::stoi(s[i]); + } + + dimredTrainer->SetMapSize(size); + typename TSOM::SizeType radius; + std::vector<std::basic_string<char>> n= GetParameterStringList("algorithm.som.n"); + for (unsigned int i=0; i<dim; i++) + { + radius[i]=std::stoi(n[i]); + } + dimredTrainer->SetNeighborhoodSizeInit(radius); + dimredTrainer->SetListSample(trainingListSample); + dimredTrainer->Train(); + dimredTrainer->Save(modelPath); } } //end namespace wrapper diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h index 85c12a4fb8..3fca979c8a 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h +++ b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h @@ -21,17 +21,14 @@ #define otbTrainDimensionalityReductionApplicationBase_h #include "otbConfigure.h" - #include "otbWrapperApplication.h" - -#include <iostream> +#include "otbDimensionalityReductionModelFactory.h" // ListSample #include "itkListSample.h" #include "itkVariableLengthVector.h" -//Estimator -#include "otbDimensionalityReductionModelFactory.h" +#include <iostream> namespace otb { @@ -98,30 +95,29 @@ public: typedef typename ModelType::InputListSampleType ListSampleType; protected: -TrainDimensionalityReductionApplicationBase(); -~TrainDimensionalityReductionApplicationBase(); + TrainDimensionalityReductionApplicationBase(); + ~TrainDimensionalityReductionApplicationBase() override; -/** Generic method to train and save the machine learning model. This method - * uses specific train methods depending on the chosen model.*/ -void Train(typename ListSampleType::Pointer trainingListSample, - std::string modelPath); + /** Generic method to train and save the machine learning model. This method + * uses specific train methods depending on the chosen model.*/ + void Train(typename ListSampleType::Pointer trainingListSample, + std::string modelPath); -/** Generic method to load a model file and use it to classify a sample list*/ -void Reduce(typename ListSampleType::Pointer validationListSample, - std::string modelPath); + /** Generic method to load a model file and use it to classify a sample list*/ + void Reduce(typename ListSampleType::Pointer validationListSample, + std::string modelPath); -/** Init method that creates all the parameters for machine learning models */ -void DoInit(); + /** Init method that creates all the parameters for machine learning models */ + void DoInit() override; private: -/** Specific Init and Train methods for each machine learning model */ -//@{ - -void InitSOMParams(); -template <class somchoice> -void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); -void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + /** Specific Init and Train methods for each machine learning model */ + + void InitSOMParams(); + template <class somchoice> + void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); + void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); #ifdef OTB_USE_SHARK void InitAutoencoderParams(); @@ -132,12 +128,11 @@ void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::st void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); -#endif -//@} +#endif }; -} -} +} // end of namespace Wrapper +} // end of namespace otb #ifndef OTB_MANUAL_INSTANTIATION #include "otbTrainDimensionalityReductionApplicationBase.txx" diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx index d99b51caae..56a3364915 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx @@ -49,8 +49,8 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> // main choice parameter that will contain all dimensionality reduction options AddParameter(ParameterType_Choice, "algorithm", "algorithm to use for the training"); - SetParameterDescription("algorithm", "Choice of the dimensionality reduction algorithm to use for the training."); - + SetParameterDescription("algorithm", "Choice of the dimensionality reduction " + "algorithm to use for the training."); InitSOMParams(); @@ -71,48 +71,39 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> template <class TInputValue, class TOutputValue> void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> -::Train(typename ListSampleType::Pointer trainingListSample, - std::string modelPath) +::Train( + typename ListSampleType::Pointer trainingListSample, + std::string modelPath) { - - // get the name of the chosen machine learning model + // get the name of the chosen machine learning model const std::string modelName = GetParameterString("algorithm"); // call specific train function - + if(modelName == "som") - { - BeforeTrainSOM(trainingListSample,modelPath); - } - + { + BeforeTrainSOM(trainingListSample,modelPath); + } + if(modelName == "autoencoder") { - #ifdef OTB_USE_SHARK +#ifdef OTB_USE_SHARK BeforeTrainAutoencoder(trainingListSample,modelPath); #else otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); #endif } - /* - if(modelName == "tiedautoencoder") - { - #ifdef OTB_USE_SHARK - TrainAutoencoder<TiedAutoencoderModelType>(trainingListSample,modelPath); - #else - otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); - #endif - } - */ + if(modelName == "pca") { - #ifdef OTB_USE_SHARK - TrainPCA(trainingListSample,modelPath); - #else - otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); - #endif +#ifdef OTB_USE_SHARK + TrainPCA(trainingListSample,modelPath); +#else + otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); +#endif } } -} -} +} // end of namespace Wrapper +} // end of namespace otb #endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h index f9cc914270..0285f9d852 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h @@ -37,68 +37,75 @@ namespace otb { + +/** \class PCAModel + * + * This class wraps a PCA model implemented by Shark, in a otb::MachineLearningModel + */ template <class TInputValue> -class ITK_EXPORT PCAModel: public MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> +class ITK_EXPORT PCAModel + : public MachineLearningModel< + itk::VariableLengthVector< TInputValue >, + itk::VariableLengthVector< TInputValue > > { - public: - - typedef PCAModel Self; - typedef MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - typedef typename Superclass::InputValueType InputValueType; - typedef typename Superclass::InputSampleType InputSampleType; - typedef typename Superclass::InputListSampleType InputListSampleType; - typedef typename InputListSampleType::Pointer ListSamplePointerType; - typedef typename Superclass::TargetValueType TargetValueType; - typedef typename Superclass::TargetSampleType TargetSampleType; - typedef typename Superclass::TargetListSampleType TargetListSampleType; - - /// Confidence map related typedefs - - typedef typename Superclass::ConfidenceValueType ConfidenceValueType; - typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; - typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; - - - itkNewMacro(Self); - itkTypeMacro(PCAModel, DimensionalityReductionModel); -/* - unsigned int GetDimension() {return m_Dimension;}; - itkSetMacro(Dimension,unsigned int); - */ - itkSetMacro(Do_resize_flag,bool); - - itkSetMacro(WriteEigenvectors, bool); - itkGetMacro(WriteEigenvectors, bool); - - bool CanReadFile(const std::string & filename); - bool CanWriteFile(const std::string & filename); - - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; - - void Train() ITK_OVERRIDE; - //void Dimensionality_reduction() {}; // Dimensionality reduction is done by DoPredict - + typedef PCAModel Self; + typedef MachineLearningModel< + itk::VariableLengthVector< TInputValue >, + itk::VariableLengthVector< TInputValue> > Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef typename Superclass::InputValueType InputValueType; + typedef typename Superclass::InputSampleType InputSampleType; + typedef typename Superclass::InputListSampleType InputListSampleType; + typedef typename InputListSampleType::Pointer ListSamplePointerType; + typedef typename Superclass::TargetValueType TargetValueType; + typedef typename Superclass::TargetSampleType TargetSampleType; + typedef typename Superclass::TargetListSampleType TargetListSampleType; + + // Confidence map related typedefs + typedef typename Superclass::ConfidenceValueType ConfidenceValueType; + typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; + typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; + + itkNewMacro(Self); + itkTypeMacro(PCAModel, DimensionalityReductionModel); + + itkSetMacro(DoResizeFlag,bool); + + itkSetMacro(WriteEigenvectors, bool); + itkGetMacro(WriteEigenvectors, bool); + + bool CanReadFile(const std::string & filename); + bool CanWriteFile(const std::string & filename); + + void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + + void Train() ITK_OVERRIDE; protected: - PCAModel(); - ~PCAModel() ITK_OVERRIDE; + PCAModel(); + ~PCAModel() ITK_OVERRIDE; - virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType * quality = ITK_NULLPTR) const; + virtual TargetSampleType DoPredict( + const InputSampleType& input, + ConfidenceValueType * quality = ITK_NULLPTR) const; + + virtual void DoPredictBatch( + const InputListSampleType *, + const unsigned int & startIndex, + const unsigned int & size, + TargetListSampleType *, + ConfidenceListSampleType * quality = ITK_NULLPTR) const ITK_OVERRIDE; - virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * quality = ITK_NULLPTR) const ITK_OVERRIDE; - private: - shark::LinearModel<> m_encoder; - shark::LinearModel<> m_decoder; - shark::PCA m_pca; - //unsigned int m_Dimension; - bool m_Do_resize_flag; - bool m_WriteEigenvectors; + shark::LinearModel<> m_Encoder; + shark::LinearModel<> m_Decoder; + shark::PCA m_PCA; + bool m_DoResizeFlag; + bool m_WriteEigenvectors; }; } // end namespace otb diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx index 063b54f4f4..376b107da1 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx @@ -36,7 +36,6 @@ #include <shark/Algorithms/GradientDescent/Rprop.h>// the RProp optimization algorithm #include <shark/ObjectiveFunctions/Loss/SquaredLoss.h> // squared loss used for regression #include <shark/ObjectiveFunctions/Regularizer.h> //L2 regulariziation - #include <shark/ObjectiveFunctions/ErrorFunction.h> #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop @@ -45,125 +44,116 @@ namespace otb { - template <class TInputValue> PCAModel<TInputValue>::PCAModel() { - this->m_IsDoPredictBatchMultiThreaded = true; - this->m_Dimension = 0; + this->m_IsDoPredictBatchMultiThreaded = true; + this->m_Dimension = 0; } - template <class TInputValue> PCAModel<TInputValue>::~PCAModel() { } - template <class TInputValue> -void PCAModel<TInputValue>::Train() +void +PCAModel<TInputValue>::Train() { - - std::vector<shark::RealVector> features; - - Shark::ListSampleToSharkVector(this->GetInputListSample(), features); - - shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - m_pca.setData(inputSamples); - m_pca.encoder(m_encoder, this->m_Dimension); - m_pca.decoder(m_decoder, this->m_Dimension); - -} + std::vector<shark::RealVector> features; + Shark::ListSampleToSharkVector(this->GetInputListSample(), features); + + shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); + m_PCA.setData(inputSamples); + m_PCA.encoder(m_Encoder, this->m_Dimension); + m_PCA.decoder(m_Decoder, this->m_Dimension); +} template <class TInputValue> -bool PCAModel<TInputValue>::CanReadFile(const std::string & filename) +bool +PCAModel<TInputValue>::CanReadFile(const std::string & filename) { - try - { - this->Load(filename); - m_encoder.name(); - } - catch(...) - { - return false; - } - return true; + try + { + this->Load(filename); + m_Encoder.name(); + } + catch(...) + { + return false; + } + return true; } - template <class TInputValue> bool PCAModel<TInputValue>::CanWriteFile(const std::string & /*filename*/) { - return true; + return true; } template <class TInputValue> -void PCAModel<TInputValue>::Save(const std::string & filename, const std::string & /*name*/) +void +PCAModel<TInputValue>::Save(const std::string & filename, const std::string & /*name*/) { - std::ofstream ofs(filename); - //ofs << m_encoder.name() << std::endl; //first line - ofs << "pca" << std::endl; //first line - boost::archive::polymorphic_text_oarchive oa(ofs); - m_encoder.write(oa); - ofs.close(); - - if (this->m_WriteEigenvectors == true) // output the map vectors in a txt file - { - std::ofstream otxt(filename+".txt"); - - otxt << "Eigenvectors : " << m_pca.eigenvectors() << std::endl; - otxt << "Eigenvalues : " << m_pca.eigenvalues() << std::endl; - - std::vector<shark::RealVector> features; - - shark::SquaredLoss<shark::RealVector> loss; - Shark::ListSampleToSharkVector(this->GetInputListSample(), features); - shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); - otxt << "Reconstruction error : " << loss.eval(inputSamples,m_decoder(m_encoder(inputSamples))) << std::endl; -otxt.close(); -} + std::ofstream ofs(filename); + ofs << "pca" << std::endl; //first line + boost::archive::polymorphic_text_oarchive oa(ofs); + m_Encoder.write(oa); + ofs.close(); + + if (this->m_WriteEigenvectors == true) // output the map vectors in a txt file + { + std::ofstream otxt(filename+".txt"); + + otxt << "Eigenvectors : " << m_PCA.eigenvectors() << std::endl; + otxt << "Eigenvalues : " << m_PCA.eigenvalues() << std::endl; + + std::vector<shark::RealVector> features; + + shark::SquaredLoss<shark::RealVector> loss; + Shark::ListSampleToSharkVector(this->GetInputListSample(), features); + shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); + otxt << "Reconstruction error : " << + loss.eval(inputSamples,m_Decoder(m_Encoder(inputSamples))) << std::endl; + otxt.close(); + } } template <class TInputValue> -void PCAModel<TInputValue>::Load(const std::string & filename, const std::string & /*name*/) +void +PCAModel<TInputValue>::Load(const std::string & filename, const std::string & /*name*/) { - std::ifstream ifs(filename); - char encoder[256]; - ifs.getline(encoder,256); - std::string encoderstr(encoder); - - //if (encoderstr != m_encoder.name()){ - if (encoderstr != "pca"){ - itkExceptionMacro(<< "Error opening " << filename.c_str() ); + std::ifstream ifs(filename); + char encoder[256]; + ifs.getline(encoder,256); + std::string encoderstr(encoder); + + if (encoderstr != "pca"){ + itkExceptionMacro(<< "Error opening " << filename.c_str() ); } - boost::archive::polymorphic_text_iarchive ia(ifs); - m_encoder.read(ia); - ifs.close(); - if (this->m_Dimension ==0) - { - this->m_Dimension = m_encoder.outputSize(); - } - - - auto eigenvectors = m_encoder.matrix(); - eigenvectors.resize(this->m_Dimension,m_encoder.inputSize()); - - m_encoder.setStructure(eigenvectors, m_encoder.offset() ); - - - + boost::archive::polymorphic_text_iarchive ia(ifs); + m_Encoder.read(ia); + ifs.close(); + if (this->m_Dimension ==0) + { + this->m_Dimension = m_Encoder.outputSize(); + } + + auto eigenvectors = m_Encoder.matrix(); + eigenvectors.resize(this->m_Dimension,m_Encoder.inputSize()); + + m_Encoder.setStructure(eigenvectors, m_Encoder.offset() ); } - template <class TInputValue> typename PCAModel<TInputValue>::TargetSampleType PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueType * /*quality*/) const { - shark::RealVector samples(value.Size()); - for(size_t i = 0; i < value.Size();i++) + shark::RealVector samples(value.Size()); + for(size_t i = 0; i < value.Size();i++) { - samples[i]=value[i]; + samples[i]=value[i]; } std::vector<shark::RealVector> features; @@ -171,44 +161,37 @@ PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueT shark::Data<shark::RealVector> data = shark::createDataFromRange(features); - data = m_encoder(data); + data = m_Encoder(data); TargetSampleType target; target.SetSize(this->m_Dimension); - - for(unsigned int a = 0; a < this->m_Dimension; ++a){ - target[a]=data.element(0)[a]; - } - return target; + + for(unsigned int a = 0; a < this->m_Dimension; ++a){ + target[a]=data.element(0)[a]; + } + return target; } - template <class TInputValue> void PCAModel<TInputValue> ::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * /*quality*/) const { - - std::vector<shark::RealVector> features; - Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); - shark::Data<shark::RealVector> data = shark::createDataFromRange(features); - TargetSampleType target; - data = m_encoder(data); - unsigned int id = startIndex; - target.SetSize(this->m_Dimension); - for(const auto& p : data.elements()){ - - for(unsigned int a = 0; a < this->m_Dimension; ++a){ - target[a]=p[a]; - //target[a]=1; - - //target.SetElement(a,p[a]); - } -targets->SetMeasurementVector(id,target); -++id; - + std::vector<shark::RealVector> features; + Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); + shark::Data<shark::RealVector> data = shark::createDataFromRange(features); + TargetSampleType target; + data = m_Encoder(data); + unsigned int id = startIndex; + target.SetSize(this->m_Dimension); + for(const auto& p : data.elements()) + { + for(unsigned int a = 0; a < this->m_Dimension; ++a) + { + target[a]=p[a]; + } + targets->SetMeasurementVector(id,target); + ++id; } - } - } // namespace otb #endif diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h index 8e044713f3..86fb9a5676 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h @@ -20,13 +20,15 @@ #ifndef otbPCAModelFactory_h #define otbPCAModelFactory_h - #include "itkObjectFactoryBase.h" #include "itkImageIOBase.h" namespace otb { - + +/** \class PCAModelFactory + * Factory for the PCAModel + */ template <class TInputValue, class TTargetValue> class ITK_EXPORT PCAModelFactory : public itk::ObjectFactoryBase { @@ -61,18 +63,12 @@ protected: private: PCAModelFactory(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented - }; - - } //namespace otb - #ifndef OTB_MANUAL_INSTANTIATION #include "otbPCAModelFactory.txx" #endif #endif - - diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx index aeafff621d..ab31accbe0 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.txx @@ -20,7 +20,6 @@ #ifndef otbPCAFactory_txx #define otbPCAFactory_txx - #include "otbPCAModelFactory.h" #include "itkCreateObjectFunction.h" @@ -29,18 +28,19 @@ namespace otb { + template <class TInputValue, class TOutputValue> PCAModelFactory<TInputValue,TOutputValue>::PCAModelFactory() { - std::string classOverride = std::string("DimensionalityReductionModel"); std::string subclass = std::string("PCAModel"); - this->RegisterOverride(classOverride.c_str(), - subclass.c_str(), - "Shark PCA ML Model", - 1, - itk::CreateObjectFunction<PCAModel<TInputValue>>::New()); + this->RegisterOverride( + classOverride.c_str(), + subclass.c_str(), + "Shark PCA ML Model", + 1, + itk::CreateObjectFunction<PCAModel<TInputValue>>::New()); } template <class TInputValue, class TOutputValue> diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h index 1025ab0e6c..f1a10a90c8 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h @@ -20,11 +20,8 @@ #ifndef otbSOMModel_h #define otbSOMModel_h -//#include "DimensionalityReductionModel.h" #include "otbSOMMap.h" -#include "otbSOM.h" - #include "itkEuclideanDistanceMetric.h" // the distance function #include "otbCzihoSOMLearningBehaviorFunctor.h" @@ -35,125 +32,126 @@ namespace otb { + +/** \class SOMModel + * MachineLearningModel for Self-Organizing Map + */ template <class TInputValue, unsigned int MapDimension> -class ITK_EXPORT SOMModel: public MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> +class ITK_EXPORT SOMModel + : public MachineLearningModel< + itk::VariableLengthVector< TInputValue >, + itk::VariableLengthVector< TInputValue > > { - public: - - typedef SOMModel Self; - typedef MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - typedef typename Superclass::InputValueType InputValueType; - typedef typename Superclass::InputSampleType InputSampleType; - typedef typename Superclass::InputListSampleType InputListSampleType; - typedef typename InputListSampleType::Pointer ListSamplePointerType; - typedef typename Superclass::TargetValueType TargetValueType; - typedef typename Superclass::TargetSampleType TargetSampleType; - typedef typename Superclass::TargetListSampleType TargetListSampleType; - - /// Confidence map related typedefs - - typedef typename Superclass::ConfidenceValueType ConfidenceValueType; - typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; - typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; - - - - typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, MapDimension> MapType; - typedef typename MapType::SizeType SizeType; - typedef typename MapType::SpacingType SpacingType; - //typedef otb::SOM<InputListSampleType, MapType> EstimatorType; - typedef otb::SOM<InputListSampleType, MapType> EstimatorType; - - typedef Functor::CzihoSOMLearningBehaviorFunctor SOMLearningBehaviorFunctorType; - typedef Functor::CzihoSOMNeighborhoodBehaviorFunctor SOMNeighborhoodBehaviorFunctorType; - - itkNewMacro(Self); - itkTypeMacro(SOMModel, DimensionalityReductionModel); - - /** Accessors */ - itkSetMacro(NumberOfIterations, unsigned int); - itkGetMacro(NumberOfIterations, unsigned int); - itkSetMacro(BetaInit, double); - itkGetMacro(BetaInit, double); - itkSetMacro(WriteMap, bool); - itkGetMacro(WriteMap, bool); - itkSetMacro(BetaEnd, double); - itkGetMacro(BetaEnd, double); - itkSetMacro(MinWeight, InputValueType); - itkGetMacro(MinWeight, InputValueType); - itkSetMacro(MaxWeight, InputValueType); - itkGetMacro(MaxWeight, InputValueType); - itkSetMacro(MapSize, SizeType); - itkGetMacro(MapSize, SizeType); - itkSetMacro(NeighborhoodSizeInit, SizeType); - itkGetMacro(NeighborhoodSizeInit, SizeType); - itkSetMacro(RandomInit, bool); - itkGetMacro(RandomInit, bool); - itkSetMacro(Seed, unsigned int); - itkGetMacro(Seed, unsigned int); - itkGetObjectMacro(ListSample, InputListSampleType); - itkSetObjectMacro(ListSample, InputListSampleType); - - bool CanReadFile(const std::string & filename); - bool CanWriteFile(const std::string & filename); - - void Save(const std::string & filename, const std::string & name="") ; - void Load(const std::string & filename, const std::string & name="") ; - - void Train() ITK_OVERRIDE; - //void Dimensionality_reduction() {}; // Dimensionality reduction is done by DoPredict - - //unsigned int GetDimension() { return MapType::ImageDimension;}; + typedef SOMModel Self; + typedef MachineLearningModel< + itk::VariableLengthVector< TInputValue >, + itk::VariableLengthVector< TInputValue > > Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef typename Superclass::InputValueType InputValueType; + typedef typename Superclass::InputSampleType InputSampleType; + typedef typename Superclass::InputListSampleType InputListSampleType; + typedef typename InputListSampleType::Pointer ListSamplePointerType; + typedef typename Superclass::TargetValueType TargetValueType; + typedef typename Superclass::TargetSampleType TargetSampleType; + typedef typename Superclass::TargetListSampleType TargetListSampleType; + + // Confidence map related typedefs + typedef typename Superclass::ConfidenceValueType ConfidenceValueType; + typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; + typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; + + typedef SOMMap< + itk::VariableLengthVector<TInputValue>, + itk::Statistics::EuclideanDistanceMetric< + itk::VariableLengthVector<TInputValue> >, + MapDimension> MapType; + typedef typename MapType::SizeType SizeType; + typedef typename MapType::SpacingType SpacingType; + + typedef Functor::CzihoSOMLearningBehaviorFunctor SOMLearningBehaviorFunctorType; + typedef Functor::CzihoSOMNeighborhoodBehaviorFunctor SOMNeighborhoodBehaviorFunctorType; + + itkNewMacro(Self); + itkTypeMacro(SOMModel, DimensionalityReductionModel); + + /** Accessors */ + itkSetMacro(NumberOfIterations, unsigned int); + itkGetMacro(NumberOfIterations, unsigned int); + itkSetMacro(BetaInit, double); + itkGetMacro(BetaInit, double); + itkSetMacro(WriteMap, bool); + itkGetMacro(WriteMap, bool); + itkSetMacro(BetaEnd, double); + itkGetMacro(BetaEnd, double); + itkSetMacro(MinWeight, InputValueType); + itkGetMacro(MinWeight, InputValueType); + itkSetMacro(MaxWeight, InputValueType); + itkGetMacro(MaxWeight, InputValueType); + itkSetMacro(MapSize, SizeType); + itkGetMacro(MapSize, SizeType); + itkSetMacro(NeighborhoodSizeInit, SizeType); + itkGetMacro(NeighborhoodSizeInit, SizeType); + itkSetMacro(RandomInit, bool); + itkGetMacro(RandomInit, bool); + itkSetMacro(Seed, unsigned int); + itkGetMacro(Seed, unsigned int); + itkGetObjectMacro(ListSample, InputListSampleType); + itkSetObjectMacro(ListSample, InputListSampleType); + + bool CanReadFile(const std::string & filename); + bool CanWriteFile(const std::string & filename); + + void Save(const std::string & filename, const std::string & name="") ; + void Load(const std::string & filename, const std::string & name="") ; + + void Train() ITK_OVERRIDE; + protected: - SOMModel(); - ~SOMModel() ITK_OVERRIDE; - + SOMModel(); + ~SOMModel() ITK_OVERRIDE; + private: - typename MapType::Pointer m_SOMMap; - - virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType * quality = ITK_NULLPTR) const; - - /** Map Parameters used for training */ - - SizeType m_MapSize; - /** Number of iterations */ - unsigned int m_NumberOfIterations; - /** Initial learning coefficient */ - double m_BetaInit; - /** Final learning coefficient */ - double m_BetaEnd; - /** Initial neighborhood size */ - SizeType m_NeighborhoodSizeInit; - /** Minimum initial neuron weights */ - InputValueType m_MinWeight; - /** Maximum initial neuron weights */ - InputValueType m_MaxWeight; - /** Random initialization bool */ - bool m_RandomInit; - /** Seed for random initialization */ - unsigned int m_Seed; - /** The input list sample */ - ListSamplePointerType m_ListSample; - /** Behavior of the Learning weightening (link to the beta coefficient) */ - SOMLearningBehaviorFunctorType m_BetaFunctor; - /** Behavior of the Neighborhood extent */ - SOMNeighborhoodBehaviorFunctorType m_NeighborhoodSizeFunctor; - /** Write the SOM Map vectors in a txt file */ - bool m_WriteMap; + typename MapType::Pointer m_SOMMap; + + virtual TargetSampleType DoPredict( + const InputSampleType& input, + ConfidenceValueType * quality = ITK_NULLPTR) const; + + /** Map size (width, height) */ + SizeType m_MapSize; + /** Number of iterations */ + unsigned int m_NumberOfIterations; + /** Initial learning coefficient */ + double m_BetaInit; + /** Final learning coefficient */ + double m_BetaEnd; + /** Initial neighborhood size */ + SizeType m_NeighborhoodSizeInit; + /** Minimum initial neuron weights */ + InputValueType m_MinWeight; + /** Maximum initial neuron weights */ + InputValueType m_MaxWeight; + /** Random initialization bool */ + bool m_RandomInit; + /** Seed for random initialization */ + unsigned int m_Seed; + /** The input list sample */ + ListSamplePointerType m_ListSample; + /** Behavior of the Learning weightening (link to the beta coefficient) */ + SOMLearningBehaviorFunctorType m_BetaFunctor; + /** Behavior of the Neighborhood extent */ + SOMNeighborhoodBehaviorFunctorType m_NeighborhoodSizeFunctor; + /** Write the SOM Map vectors in a txt file */ + bool m_WriteMap; }; - } // end namespace otb - #ifndef OTB_MANUAL_INSTANTIATION #include "otbSOMModel.txx" #endif - #endif - diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx index 1fd4c6ea20..e0bfe52f92 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx @@ -21,208 +21,210 @@ #define otbSOMModel_txx #include "otbSOMModel.h" - +#include "otbSOM.h" #include "otbImageFileReader.h" #include "otbImageFileWriter.h" #include "itkMacro.h" - - -// test text file #include "itkImageRegionIterator.h" #include "itkImageRegionConstIterator.h" -#include <fstream> - - #include "itkImage.h" +#include <fstream> + namespace otb { - -template <class TInputValue, unsigned int MapDimension> -SOMModel<TInputValue, MapDimension>::SOMModel() +namespace internal +{ +template<typename T> +std::ostream& BinaryWrite(std::ostream& stream, const T& value) { - this->m_Dimension = MapType::ImageDimension; + return stream.write(reinterpret_cast<const char*>(&value), sizeof(T)); } - -template <class TInputValue, unsigned int MapDimension> -SOMModel<TInputValue, MapDimension>::~SOMModel() +std::ostream& BinaryWriteString(std::ofstream& stream, const std::string& value) { + return stream.write(value.c_str(), value.length()); } - -template <class TInputValue, unsigned int MapDimension> -void SOMModel<TInputValue, MapDimension>::Train() +template<typename T> +std::istream & BinaryRead(std::istream& stream, T& value) { - - typename EstimatorType::Pointer estimator = EstimatorType::New(); - - estimator->SetListSample(m_ListSample); - estimator->SetMapSize(m_MapSize); - estimator->SetNeighborhoodSizeInit(m_NeighborhoodSizeInit); - estimator->SetNumberOfIterations(m_NumberOfIterations); - estimator->SetBetaInit(m_BetaInit); - estimator->SetBetaEnd(m_BetaEnd); - estimator->SetMaxWeight(m_MaxWeight); - //AddProcess(estimator,"Learning"); - estimator->Update(); - m_SOMMap = estimator->GetOutput(); - } - - + return stream.read(reinterpret_cast<char*>(&value), sizeof(T)); +} +} // end of namespace internal template <class TInputValue, unsigned int MapDimension> -bool SOMModel<TInputValue, MapDimension>::CanReadFile(const std::string & filename) +SOMModel<TInputValue, MapDimension>::SOMModel() { - try - { - this->Load(filename); - } - catch(...) - { - return false; - } - return true; + this->m_Dimension = MapType::ImageDimension; } - template <class TInputValue, unsigned int MapDimension> -bool SOMModel<TInputValue, MapDimension>::CanWriteFile(const std::string & /*filename*/) +SOMModel<TInputValue, MapDimension>::~SOMModel() { - return true; } -template<typename T> -std::ostream& binary_write(std::ostream& stream, const T& value){ - return stream.write(reinterpret_cast<const char*>(&value), sizeof(T)); -} - - -std::ostream& binary_write_string(std::ofstream& stream, const std::string& value){ - return stream.write(value.c_str(), value.length()); +template <class TInputValue, unsigned int MapDimension> +void +SOMModel<TInputValue, MapDimension>::Train() +{ + typedef otb::SOM<InputListSampleType, MapType> EstimatorType; + typename EstimatorType::Pointer estimator = EstimatorType::New(); + estimator->SetListSample(m_ListSample); + estimator->SetMapSize(m_MapSize); + estimator->SetNeighborhoodSizeInit(m_NeighborhoodSizeInit); + estimator->SetNumberOfIterations(m_NumberOfIterations); + estimator->SetBetaInit(m_BetaInit); + estimator->SetBetaEnd(m_BetaEnd); + estimator->SetMaxWeight(m_MaxWeight); + estimator->Update(); + m_SOMMap = estimator->GetOutput(); } -template<typename T> -std::istream & binary_read(std::istream& stream, T& value){ - return stream.read(reinterpret_cast<char*>(&value), sizeof(T)); +template <class TInputValue, unsigned int MapDimension> +bool +SOMModel<TInputValue, MapDimension>::CanReadFile(const std::string & filename) +{ + try + { + this->Load(filename); + } + catch(...) + { + return false; + } + return true; } - - template <class TInputValue, unsigned int MapDimension> -void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, const std::string & /*name*/) +bool +SOMModel<TInputValue, MapDimension>::CanWriteFile(const std::string & /*filename*/) { - itk::ImageRegionConstIterator<MapType> inputIterator(m_SOMMap,m_SOMMap->GetLargestPossibleRegion()); - inputIterator.GoToBegin(); - std::ofstream ofs(filename, std::ios::binary); - binary_write_string(ofs,"som"); - binary_write(ofs,static_cast<unsigned int>(MapDimension)); - SizeType size = m_SOMMap->GetLargestPossibleRegion().GetSize() ; - for (size_t i=0;i<MapDimension;i++){ - binary_write(ofs,size[i]); - } - - binary_write(ofs,inputIterator.Get().GetNumberOfElements()); - while(!inputIterator.IsAtEnd()){ - InputSampleType vect = inputIterator.Get(); - for (size_t i=0;i<vect.GetNumberOfElements();i++){ - binary_write(ofs,vect[i]); - } - ++inputIterator; - } - ofs.close(); - - if (this->m_WriteMap == true) // output the map vectors in a txt file - { - std::ofstream otxt(filename+".txt"); - inputIterator.GoToBegin(); - while(!inputIterator.IsAtEnd()) - { - InputSampleType vect = inputIterator.Get(); - for (size_t i=0;i<vect.GetNumberOfElements();i++) - { - - otxt << vect[i] << " "; - } - otxt << std::endl; - ++inputIterator; - } - otxt.close(); - } + return true; } template <class TInputValue, unsigned int MapDimension> -void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, const std::string & /*name*/) +void +SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, const std::string & /*name*/) { - - std::ifstream ifs(filename, std::ios::binary); - - /** Read the model key (should be som) */ - char s[]=" "; - for (int i=0; i<3; i++){ - binary_read(ifs,s[i]); - } - std::string modelType(s); - /** Read the dimension of the map (should be equal to MapDimension) */ - - unsigned int dimension; - binary_read(ifs,dimension); - if (modelType != "som" || dimension != MapDimension){ - itkExceptionMacro(<< "Error opening " << filename.c_str() ); + itk::ImageRegionConstIterator<MapType> inputIterator(m_SOMMap,m_SOMMap->GetLargestPossibleRegion()); + inputIterator.GoToBegin(); + std::ofstream ofs(filename, std::ios::binary); + internal::BinaryWriteString(ofs,"som"); + internal::BinaryWrite(ofs,static_cast<unsigned int>(MapDimension)); + SizeType size = m_SOMMap->GetLargestPossibleRegion().GetSize() ; + for (size_t i=0;i<MapDimension;i++) + { + internal::BinaryWrite(ofs,size[i]); } - SizeType size; - itk::Index< MapDimension > index; - for (unsigned int i=0 ; i<MapDimension; i++) - { - binary_read(ifs,size[i]); - index[i]=0; - } - unsigned int numberOfElements; - binary_read(ifs,numberOfElements); - m_SOMMap = MapType::New(); - typename MapType::RegionType region; - region.SetSize( size ); - m_SOMMap->SetNumberOfComponentsPerPixel(numberOfElements); - region.SetIndex( index ); - m_SOMMap->SetRegions( region ); - m_SOMMap->Allocate(); - - itk::ImageRegionIterator<MapType> outputIterator(m_SOMMap,region); - outputIterator.GoToBegin(); - std::string value; - while(!outputIterator.IsAtEnd()){ - InputSampleType vect(numberOfElements); - for (unsigned int i=0 ; i<numberOfElements; i++) - { - float v; // InputValue type is not the same during training anddimredvector. - binary_read(ifs,v); - vect[i] = static_cast<double>(v); - } - outputIterator.Set(vect); - ++outputIterator; - } - ifs.close(); - - this->m_Dimension = MapType::ImageDimension; + internal::BinaryWrite(ofs,inputIterator.Get().GetNumberOfElements()); + while(!inputIterator.IsAtEnd()) + { + InputSampleType vect = inputIterator.Get(); + for (size_t i=0;i<vect.GetNumberOfElements();i++) + { + internal::BinaryWrite(ofs,vect[i]); + } + ++inputIterator; + } + ofs.close(); + + // output the map vectors in a txt file + if (this->m_WriteMap == true) + { + std::ofstream otxt(filename+".txt"); + inputIterator.GoToBegin(); + while(!inputIterator.IsAtEnd()) + { + InputSampleType vect = inputIterator.Get(); + for (size_t i=0;i<vect.GetNumberOfElements();i++) + { + otxt << vect[i] << " "; + } + otxt << std::endl; + ++inputIterator; + } + otxt.close(); + } } +template <class TInputValue, unsigned int MapDimension> +void +SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, const std::string & /*name*/) +{ + std::ifstream ifs(filename, std::ios::binary); + + /** Read the model key (should be som) */ + char s[]=" "; + for (int i=0; i<3; i++) + { + internal::BinaryRead(ifs,s[i]); + } + std::string modelType(s); + /** Read the dimension of the map (should be equal to MapDimension) */ + + unsigned int dimension; + internal::BinaryRead(ifs,dimension); + if (modelType != "som" || dimension != MapDimension) + { + itkExceptionMacro(<< "Error opening " << filename.c_str() ); + } + + SizeType size; + itk::Index< MapDimension > index; + for (unsigned int i=0 ; i<MapDimension; i++) + { + internal::BinaryRead(ifs,size[i]); + index[i]=0; + } + unsigned int numberOfElements; + internal::BinaryRead(ifs,numberOfElements); + m_SOMMap = MapType::New(); + typename MapType::RegionType region; + region.SetSize( size ); + m_SOMMap->SetNumberOfComponentsPerPixel(numberOfElements); + region.SetIndex( index ); + m_SOMMap->SetRegions( region ); + m_SOMMap->Allocate(); + + itk::ImageRegionIterator<MapType> outputIterator(m_SOMMap,region); + outputIterator.GoToBegin(); + std::string value; + while(!outputIterator.IsAtEnd()) + { + InputSampleType vect(numberOfElements); + for (unsigned int i=0 ; i<numberOfElements; i++) + { + // InputValue type is not the same during training anddimredvector. + float v; + internal::BinaryRead(ifs,v); + vect[i] = static_cast<double>(v); + } + outputIterator.Set(vect); + ++outputIterator; + } + ifs.close(); + this->m_Dimension = MapType::ImageDimension; +} template <class TInputValue, unsigned int MapDimension> typename SOMModel<TInputValue, MapDimension>::TargetSampleType -SOMModel<TInputValue, MapDimension>::DoPredict(const InputSampleType & value, ConfidenceValueType * /*quality*/) const -{ - TargetSampleType target; - target.SetSize(this->m_Dimension); - - auto winner =m_SOMMap->GetWinner(value); - for (unsigned int i=0; i< this->m_Dimension ;i++) { - target[i] = winner.GetElement(i); - } - - return target; +SOMModel<TInputValue, MapDimension>::DoPredict( + const InputSampleType & value, + ConfidenceValueType * /*quality*/) const +{ + TargetSampleType target; + target.SetSize(this->m_Dimension); + + auto winner =m_SOMMap->GetWinner(value); + for (unsigned int i=0; i< this->m_Dimension ;i++) + { + target[i] = winner.GetElement(i); + } + return target; } } // namespace otb diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h index 4085d65199..72d590a3f8 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h @@ -20,13 +20,15 @@ #ifndef otbSOMModelFactory_h #define otbSOMModelFactory_h - #include "itkObjectFactoryBase.h" #include "itkImageIOBase.h" namespace otb { - + +/** \class SOMModelFactory + * Factory for SOMModel + */ template <class TInputValue, class TTargetValue, unsigned int MapDimension> class ITK_EXPORT SOMModelFactory : public itk::ObjectFactoryBase { @@ -64,15 +66,10 @@ private: }; - - } //namespace otb - #ifndef OTB_MANUAL_INSTANTIATION #include "otbSOMModelFactory.txx" #endif #endif - - diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.txx index bcef5c92a4..5799660768 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.txx @@ -20,7 +20,6 @@ #ifndef otbSOMFactory_txx #define otbSOMFactory_txx - #include "otbSOMModelFactory.h" #include "itkCreateObjectFunction.h" @@ -32,16 +31,15 @@ namespace otb template <class TInputValue, class TOutputValue, unsigned int MapDimension> SOMModelFactory<TInputValue,TOutputValue,MapDimension>::SOMModelFactory() { - std::string classOverride = std::string("DimensionalityReductionModel"); std::string subclass = std::string("SOMModel"); - this->RegisterOverride(classOverride.c_str(), - subclass.c_str(), - "SOM DR Model", - 1, - - itk::CreateObjectFunction<SOMModel<TInputValue, MapDimension>>::New()); + this->RegisterOverride( + classOverride.c_str(), + subclass.c_str(), + "SOM DR Model", + 1, + itk::CreateObjectFunction<SOMModel<TInputValue, MapDimension>>::New()); } template <class TInputValue, class TOutputValue, unsigned int MapDimension> -- GitLab From 7eb744f1437d21f3d7d382e5532c58a5739ab0da Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 8 Dec 2017 18:50:40 +0100 Subject: [PATCH 116/567] TEST: fix ingroup test --- .../otbTrainDimensionalityReductionApplicationBase.h | 2 +- .../include/otbAutoencoderModel.h | 7 +++++++ .../include/otbAutoencoderModelFactory.h | 7 +++++++ .../include/otbDimensionalityReductionModelFactory.h | 2 +- .../include/otbImageDimensionalityReductionFilter.h | 2 +- .../DimensionalityReductionLearning/include/otbPCAModel.h | 2 ++ .../include/otbPCAModelFactory.h | 3 +++ .../DimensionalityReductionLearning/include/otbSOMModel.h | 2 ++ .../include/otbSOMModelFactory.h | 3 +++ 9 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h index 3fca979c8a..b0a2ae847a 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h +++ b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.h @@ -65,7 +65,7 @@ namespace Wrapper * \sa TrainImagesClassifier * \sa TrainRegression * - * \ingroup OTBAppClassification + * \ingroup OTBAppDimensionalityReduction */ template <class TInputValue, class TOutputValue> class TrainDimensionalityReductionApplicationBase: public Application diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h index f5c3b85e41..0707f5e182 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h @@ -40,6 +40,13 @@ namespace otb { +/** + * \class AutoencoderModel + * + * Autoencoder model wrapper class + * + * \ingroup OTBDimensionalityReductionLearning + */ template <class TInputValue, class NeuronType> class ITK_EXPORT AutoencoderModel : public MachineLearningModel< diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h index a9b0065e8c..711711ca4b 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h @@ -26,6 +26,13 @@ namespace otb { +/** + * \class AutoencoderModelFactory + * + * Factory for AutoencoderModel + * + * \ingroup OTBDimensionalityReductionLearning + */ template <class TInputValue, class TTargetValue, class NeuronType> class ITK_EXPORT AutoencoderModelFactory : public itk::ObjectFactoryBase { diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h index a96235ccb9..d088b5394d 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h @@ -28,7 +28,7 @@ namespace otb /** \class MachineLearningModelFactory * \brief Creation of object instance using object factory. * - * \ingroup OTBSupervised + * \ingroup OTBDimensionalityReductionLearning */ template <class TInputValue, class TOutputValue> class DimensionalityReductionModelFactory : public MachineLearningModelFactoryBase diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h index 93c60cf022..d5538c1700 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h @@ -36,7 +36,7 @@ namespace otb * \ingroup Streamed * \ingroup Threaded * - * \ingroup OTBSupervised + * \ingroup OTBDimensionalityReductionLearning */ template <class TInputImage, class TOutputImage, class TMaskImage = TOutputImage> class ITK_EXPORT ImageDimensionalityReductionFilter diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h index 0285f9d852..907d6a33cf 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h @@ -41,6 +41,8 @@ namespace otb /** \class PCAModel * * This class wraps a PCA model implemented by Shark, in a otb::MachineLearningModel + * + * \ingroup OTBDimensionalityReductionLearning */ template <class TInputValue> class ITK_EXPORT PCAModel diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h index 86fb9a5676..d30a2c4663 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h @@ -27,7 +27,10 @@ namespace otb { /** \class PCAModelFactory + * * Factory for the PCAModel + * + * \ingroup OTBDimensionalityReductionLearning */ template <class TInputValue, class TTargetValue> class ITK_EXPORT PCAModelFactory : public itk::ObjectFactoryBase diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h index f1a10a90c8..0e5bbaca1f 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h @@ -35,6 +35,8 @@ namespace otb /** \class SOMModel * MachineLearningModel for Self-Organizing Map + * + * \ingroup OTBDimensionalityReductionLearning */ template <class TInputValue, unsigned int MapDimension> class ITK_EXPORT SOMModel diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h index 72d590a3f8..71d314e5f5 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h @@ -27,7 +27,10 @@ namespace otb { /** \class SOMModelFactory + * * Factory for SOMModel + * + * \ingroup OTBDimensionalityReductionLearning */ template <class TInputValue, class TTargetValue, unsigned int MapDimension> class ITK_EXPORT SOMModelFactory : public itk::ObjectFactoryBase -- GitLab From 6f043c325f7d8ab8d1968570785f06de0cba8a64 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 11 Dec 2017 15:59:10 +0100 Subject: [PATCH 117/567] TEST: gather in a single template function several parsing functions for letter.scale --- .../IO/TestKernel/include/otbReadDataFile.h | 115 +++++++ .../test/otbTrainMachineLearningModel.cxx | 293 +----------------- 2 files changed, 128 insertions(+), 280 deletions(-) create mode 100644 Modules/IO/TestKernel/include/otbReadDataFile.h diff --git a/Modules/IO/TestKernel/include/otbReadDataFile.h b/Modules/IO/TestKernel/include/otbReadDataFile.h new file mode 100644 index 0000000000..5ba16330a2 --- /dev/null +++ b/Modules/IO/TestKernel/include/otbReadDataFile.h @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbStringUtils.h" +#include "otb_boost_string_header.h" + +#include "itkListSample.h" +#include <fstream> +#include <string> +#include <algorithm> + +namespace otb +{ +/** Utility function to read the data file letter.scale, a CSV type file + * (whitespace separators) with the letter index in first column, followed by + * 16 descriptors. Each descriptor is a pair 'index:value' + */ +template <typename TInput, typename TTarget> +bool ReadDataFile( + const std::string & infname, + itk::SmartPointer<itk::Statistics::ListSample<TInput> > samples, + itk::SmartPointer<itk::Statistics::ListSample<TTarget> > labels) +{ + typedef typename itk::Statistics::ListSample<TInput>::MeasurementType IValueType; + typedef typename itk::Statistics::ListSample<TTarget>::MeasurementType TValueType; + + std::ifstream ifs; + ifs.open(infname.c_str()); + + if(!ifs) + { + std::cout<<"Could not read file "<<infname<<std::endl; + return false; + } + + unsigned int nbfeatures = 0; + + while (!ifs.eof()) + { + std::string line; + std::getline(ifs, line); + boost::algorithm::trim(line); + + if(nbfeatures == 0) + { + nbfeatures = std::count(line.begin(),line.end(),' '); + samples->SetMeasurementVectorSize(nbfeatures); + } + + if(line.size()>1) + { + TInput sample; + itk::NumericTraits<TInput>::SetLength(sample, nbfeatures); + + std::string::size_type pos = line.find_first_of(" ", 0); + + // Parse label + TTarget label; + itk::NumericTraits<TTarget>::SetLength(label,1); + label[0] = boost::lexical_cast<TValueType>(line.substr(0, pos)); + + bool endOfLine = false; + unsigned int id = 0; + + while(!endOfLine) + { + std::string::size_type nextpos = line.find_first_of(" ", pos+1); + if(nextpos == std::string::npos) + { + endOfLine = true; + nextpos = line.size(); + } + + std::string::size_type semicolonpos = line.find_first_of(":", pos+1, nextpos-pos-1); + if (semicolonpos == std::string::npos) + { + id++; + sample[id - 1] = boost::lexical_cast<IValueType>(line.substr(pos+1,nextpos-pos-1)); + } + else + { + id = boost::lexical_cast<unsigned int>(line.substr(pos+1,semicolonpos-pos-1)); + sample[id - 1] = boost::lexical_cast<IValueType>( + line.substr(semicolonpos+1,nextpos-semicolonpos-1)); + } + pos = nextpos; + + } + samples->PushBack(sample); + labels->PushBack(label); + } + } + + ifs.close(); + return true; +} + +} // end of namespace otb diff --git a/Modules/Learning/Supervised/test/otbTrainMachineLearningModel.cxx b/Modules/Learning/Supervised/test/otbTrainMachineLearningModel.cxx index 0633cd0f53..dd34b41b8b 100644 --- a/Modules/Learning/Supervised/test/otbTrainMachineLearningModel.cxx +++ b/Modules/Learning/Supervised/test/otbTrainMachineLearningModel.cxx @@ -26,6 +26,8 @@ #include <otbMachineLearningModel.h> #include "otbConfusionMatrixCalculator.h" +#include "otbReadDataFile.h" + #include "otb_boost_string_header.h" typedef otb::MachineLearningModel<float,short> MachineLearningModelType; @@ -46,142 +48,6 @@ typedef MachineLearningModelRegressionType::TargetListSampleType TargetListSampl typedef otb::ConfusionMatrixCalculator<TargetListSampleType, TargetListSampleType> ConfusionMatrixCalculatorType; -bool ReadDataFile(const std::string & infname, InputListSampleType * samples, TargetListSampleType * labels) -{ - std::ifstream ifs; - ifs.open(infname.c_str()); - - if(!ifs) - { - std::cout<<"Could not read file "<<infname<<std::endl; - return false; - } - - unsigned int nbfeatures = 0; - - while (!ifs.eof()) - { - std::string line; - std::getline(ifs, line); - boost::algorithm::trim(line); - - if(nbfeatures == 0) - { - nbfeatures = std::count(line.begin(),line.end(),' '); - } - - if(line.size()>1) - { - InputSampleType sample(nbfeatures); - sample.Fill(0); - - std::string::size_type pos = line.find_first_of(" ", 0); - - // Parse label - TargetSampleType label; - label[0] = atoi(line.substr(0, pos).c_str()); - - bool endOfLine = false; - unsigned int id = 0; - - while(!endOfLine) - { - std::string::size_type nextpos = line.find_first_of(" ", pos+1); - - if(pos == std::string::npos) - { - endOfLine = true; - nextpos = line.size()-1; - } - else - { - std::string feature = line.substr(pos,nextpos-pos); - std::string::size_type semicolonpos = feature.find_first_of(":"); - id = atoi(feature.substr(0,semicolonpos).c_str()); - sample[id - 1] = atof(feature.substr(semicolonpos+1,feature.size()-semicolonpos).c_str()); - pos = nextpos; - } - - } - samples->SetMeasurementVectorSize(itk::NumericTraits<InputSampleType>::GetLength(sample)); - samples->PushBack(sample); - labels->PushBack(label); - } - } - - //std::cout<<"Retrieved "<<samples->Size()<<" samples"<<std::endl; - ifs.close(); - return true; -} - -bool ReadDataRegressionFile(const std::string & infname, InputListSampleRegressionType * samples, TargetListSampleRegressionType * labels) -{ - std::ifstream ifs; - ifs.open(infname.c_str()); - - if(!ifs) - { - std::cout<<"Could not read file "<<infname<<std::endl; - return false; - } - - unsigned int nbfeatures = 0; - - while (!ifs.eof()) - { - std::string line; - std::getline(ifs, line); - - if(nbfeatures == 0) - { - nbfeatures = std::count(line.begin(),line.end(),' ')-1; - //std::cout<<"Found "<<nbfeatures<<" features per samples"<<std::endl; - } - - if(line.size()>1) - { - InputSampleRegressionType sample(nbfeatures); - sample.Fill(0); - - std::string::size_type pos = line.find_first_of(" ", 0); - - // Parse label - TargetSampleRegressionType label; - label[0] = atof(line.substr(0, pos).c_str()); - - bool endOfLine = false; - unsigned int id = 0; - - while(!endOfLine) - { - std::string::size_type nextpos = line.find_first_of(" ", pos+1); - - if(nextpos == std::string::npos) - { - endOfLine = true; - nextpos = line.size()-1; - } - else - { - std::string feature = line.substr(pos,nextpos-pos); - std::string::size_type semicolonpos = feature.find_first_of(":"); - id = atoi(feature.substr(0,semicolonpos).c_str()); - sample[id - 1] = atof(feature.substr(semicolonpos+1,feature.size()-semicolonpos).c_str()); - pos = nextpos; - } - - } - samples->SetMeasurementVectorSize(itk::NumericTraits<InputSampleRegressionType>::GetLength(sample)); - samples->PushBack(sample); - labels->PushBack(label); - } - } - - //std::cout<<"Retrieved "<<samples->Size()<<" samples"<<std::endl; - ifs.close(); - return true; -} - #ifdef OTB_USE_LIBSVM #include "otbLibSVMMachineLearningModel.h" int otbLibSVMMachineLearningModelNew(int itkNotUsed(argc), char * itkNotUsed(argv) []) @@ -205,7 +71,7 @@ int otbLibSVMMachineLearningModel(int argc, char * argv[]) InputListSampleType::Pointer samples = InputListSampleType::New(); TargetListSampleType::Pointer labels = TargetListSampleType::New(); - if (!ReadDataFile(argv[1], samples, labels)) + if (!otb::ReadDataFile(argv[1], samples, labels)) { std::cout << "Failed to read samples file " << argv[1] << std::endl; return EXIT_FAILURE; @@ -294,7 +160,7 @@ int otbSVMMachineLearningModel(int argc, char * argv[]) InputListSampleType::Pointer samples = InputListSampleType::New(); TargetListSampleType::Pointer labels = TargetListSampleType::New(); - if(!ReadDataFile(argv[1],samples,labels)) + if(!otb::ReadDataFile(argv[1],samples,labels)) { std::cout<<"Failed to read samples file "<<argv[1]<<std::endl; return EXIT_FAILURE; @@ -364,7 +230,7 @@ int otbSVMMachineLearningRegressionModel(int argc, char * argv[]) InputListSampleRegressionType::Pointer samples = InputListSampleRegressionType::New(); TargetListSampleRegressionType::Pointer labels = TargetListSampleRegressionType::New(); - if(!ReadDataRegressionFile(argv[1],samples,labels)) + if(!otb::ReadDataFile(argv[1],samples,labels)) { std::cout<<"Failed to read samples file "<<argv[1]<<std::endl; return EXIT_FAILURE; @@ -439,7 +305,7 @@ int otbKNearestNeighborsMachineLearningModel(int argc, char * argv[]) InputListSampleType::Pointer samples = InputListSampleType::New(); TargetListSampleType::Pointer labels = TargetListSampleType::New(); - if(!ReadDataFile(argv[1],samples,labels)) + if(!otb::ReadDataFile(argv[1],samples,labels)) { std::cout<<"Failed to read samples file "<<argv[1]<<std::endl; return EXIT_FAILURE; @@ -516,7 +382,7 @@ int otbRandomForestsMachineLearningModel(int argc, char * argv[]) InputListSampleType::Pointer samples = InputListSampleType::New(); TargetListSampleType::Pointer labels = TargetListSampleType::New(); - if(!ReadDataFile(argv[1],samples,labels)) + if(!otb::ReadDataFile(argv[1],samples,labels)) { std::cout<<"Failed to read samples file "<<argv[1]<<std::endl; return EXIT_FAILURE; @@ -603,7 +469,7 @@ int otbBoostMachineLearningModel(int argc, char * argv[]) InputListSampleType::Pointer samples = InputListSampleType::New(); TargetListSampleType::Pointer labels = TargetListSampleType::New(); - if(!ReadDataFile(argv[1],samples,labels)) + if(!otb::ReadDataFile(argv[1],samples,labels)) { std::cout<<"Failed to read samples file "<<argv[1]<<std::endl; return EXIT_FAILURE; @@ -689,7 +555,7 @@ int otbANNMachineLearningModel(int argc, char * argv[]) InputListSampleType::Pointer samples = InputListSampleType::New(); TargetListSampleType::Pointer labels = TargetListSampleType::New(); - if (!ReadDataFile(argv[1], samples, labels)) + if (!otb::ReadDataFile(argv[1], samples, labels)) { std::cout << "Failed to read samples file " << argv[1] << std::endl; return EXIT_FAILURE; @@ -779,7 +645,7 @@ int otbNormalBayesMachineLearningModel(int argc, char * argv[]) InputListSampleType::Pointer samples = InputListSampleType::New(); TargetListSampleType::Pointer labels = TargetListSampleType::New(); - if(!ReadDataFile(argv[1],samples,labels)) + if(!otb::ReadDataFile(argv[1],samples,labels)) { std::cout<<"Failed to read samples file "<<argv[1]<<std::endl; return EXIT_FAILURE; @@ -856,7 +722,7 @@ int otbDecisionTreeMachineLearningModel(int argc, char * argv[]) InputListSampleType::Pointer samples = InputListSampleType::New(); TargetListSampleType::Pointer labels = TargetListSampleType::New(); - if(!ReadDataFile(argv[1],samples,labels)) + if(!otb::ReadDataFile(argv[1],samples,labels)) { std::cout<<"Failed to read samples file "<<argv[1]<<std::endl; return EXIT_FAILURE; @@ -934,7 +800,7 @@ int otbGradientBoostedTreeMachineLearningModel(int argc, char * argv[]) InputListSampleType::Pointer samples = InputListSampleType::New(); TargetListSampleType::Pointer labels = TargetListSampleType::New(); - if(!ReadDataFile(argv[1],samples,labels)) + if(!otb::ReadDataFile(argv[1],samples,labels)) { std::cout<<"Failed to read samples file "<<argv[1]<<std::endl; return EXIT_FAILURE; @@ -995,139 +861,6 @@ int otbGradientBoostedTreeMachineLearningModel(int argc, char * argv[]) #ifdef OTB_USE_SHARK #include <chrono> // If shark is on, then we are using c++11 -bool SharkReadDataFile(const std::string & infname, InputListSampleType * samples, TargetListSampleType * labels) -{ - std::ifstream ifs(infname.c_str()); - - if(!ifs) - { - std::cout<<"Could not read file "<<infname<<std::endl; - return false; - } - - unsigned int nbfeatures = 0; - - std::string line; - while (std::getline(ifs, line)) - { - boost::algorithm::trim(line); - - if(nbfeatures == 0) - { - nbfeatures = std::count(line.begin(),line.end(),' '); - } - - if(line.size()>1) - { - InputSampleType sample(nbfeatures); - sample.Fill(0); - - std::string::size_type pos = line.find_first_of(" ", 0); - - // Parse label - TargetSampleType label; - label[0] = std::stoi(line.substr(0, pos).c_str()); - - bool endOfLine = false; - unsigned int id = 0; - - while(!endOfLine) - { - std::string::size_type nextpos = line.find_first_of(" ", pos+1); - - if(pos == std::string::npos) - { - endOfLine = true; - nextpos = line.size()-1; - } - else - { - std::string feature = line.substr(pos,nextpos-pos); - std::string::size_type semicolonpos = feature.find_first_of(":"); - id = std::stoi(feature.substr(0,semicolonpos).c_str()); - sample[id - 1] = atof(feature.substr(semicolonpos+1,feature.size()-semicolonpos).c_str()); - pos = nextpos; - } - - } - samples->SetMeasurementVectorSize(itk::NumericTraits<InputSampleType>::GetLength(sample)); - samples->PushBack(sample); - labels->PushBack(label); - } - } - - //std::cout<<"Retrieved "<<samples->Size()<<" samples"<<std::endl; - ifs.close(); - return true; -} - -bool SharkReadDataRegressionFile(const std::string & infname, InputListSampleRegressionType * samples, TargetListSampleRegressionType * labels) -{ - std::ifstream ifs(infname.c_str()); - if(!ifs) - { - std::cout<<"Could not read file "<<infname<<std::endl; - return false; - } - - unsigned int nbfeatures = 0; - - while (!ifs.eof()) - { - std::string line; - std::getline(ifs, line); - - if(nbfeatures == 0) - { - nbfeatures = std::count(line.begin(),line.end(),' ')-1; - //std::cout<<"Found "<<nbfeatures<<" features per samples"<<std::endl; - } - - if(line.size()>1) - { - InputSampleRegressionType sample(nbfeatures); - sample.Fill(0); - - std::string::size_type pos = line.find_first_of(" ", 0); - - // Parse label - TargetSampleRegressionType label; - label[0] = atof(line.substr(0, pos).c_str()); - - bool endOfLine = false; - unsigned int id = 0; - - while(!endOfLine) - { - std::string::size_type nextpos = line.find_first_of(" ", pos+1); - - if(nextpos == std::string::npos) - { - endOfLine = true; - nextpos = line.size()-1; - } - else - { - std::string feature = line.substr(pos,nextpos-pos); - std::string::size_type semicolonpos = feature.find_first_of(":"); - id = std::stoi(feature.substr(0,semicolonpos).c_str()); - sample[id - 1] = atof(feature.substr(semicolonpos+1,feature.size()-semicolonpos).c_str()); - pos = nextpos; - } - - } - samples->SetMeasurementVectorSize(itk::NumericTraits<InputSampleRegressionType>::GetLength(sample)); - samples->PushBack(sample); - labels->PushBack(label); - } - } - - //std::cout<<"Retrieved "<<samples->Size()<<" samples"<<std::endl; - ifs.close(); - return true; -} - - #include "otbSharkRandomForestsMachineLearningModel.h" int otbSharkRFMachineLearningModelNew(int itkNotUsed(argc), char * itkNotUsed(argv) []) { @@ -1149,7 +882,7 @@ int otbSharkRFMachineLearningModel(int argc, char * argv[]) InputListSampleType::Pointer samples = InputListSampleType::New(); TargetListSampleType::Pointer labels = TargetListSampleType::New(); - if(!SharkReadDataFile(argv[1],samples,labels)) + if(!otb::ReadDataFile(argv[1],samples,labels)) { std::cout<<"Failed to read samples file "<<argv[1]<<std::endl; return EXIT_FAILURE; -- GitLab From fe1b7268c7eba0a317bb78e83e0463c8c4e370a9 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 11 Dec 2017 16:02:31 +0100 Subject: [PATCH 118/567] STYLE: better readability --- .../include/otbDimensionalityReductionModelFactory.h | 4 +++- .../include/otbDimensionalityReductionModelFactory.txx | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h index d088b5394d..9bbd28bc0b 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h @@ -46,7 +46,9 @@ public: itkTypeMacro(DimensionalityReductionModelFactory, itk::Object); /** Convenient typedefs. */ - typedef otb::MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TOutputValue>> DimensionalityReductionModelType; + typedef otb::MachineLearningModel< + itk::VariableLengthVector< TInputValue >, + itk::VariableLengthVector< TOutputValue> > DimensionalityReductionModelType; typedef typename DimensionalityReductionModelType::Pointer DimensionalityReductionModelTypePointer; /** Mode in which the files is intended to be used */ diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx index f289ab83d9..451fce5b7c 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.txx @@ -52,7 +52,7 @@ using SOM5DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 5> ; template <class TInputValue, class TOutputValue> -typename MachineLearningModel<itk::VariableLengthVector< TInputValue>, itk::VariableLengthVector< TOutputValue> >::Pointer +typename DimensionalityReductionModelFactory<TInputValue,TOutputValue>::DimensionalityReductionModelTypePointer DimensionalityReductionModelFactory<TInputValue,TOutputValue> ::CreateDimensionalityReductionModel(const std::string& path, FileModeType mode) { @@ -65,7 +65,8 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> for(std::list<LightObject::Pointer>::iterator i = allobjects.begin(); i != allobjects.end(); ++i) { - MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TOutputValue>> * io = dynamic_cast<MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TOutputValue>>*>(i->GetPointer()); + DimensionalityReductionModelType* io = + dynamic_cast<DimensionalityReductionModelType*>(i->GetPointer()); if(io) { possibleDimensionalityReductionModel.push_back(io); -- GitLab From dc87bec478012c8bfa6991c4e3a8788905c0d515 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 11 Dec 2017 16:03:07 +0100 Subject: [PATCH 119/567] ENH: use the InputSampleList from mother class --- .../include/otbDimensionalityReductionTrainSOM.txx | 2 +- .../DimensionalityReductionLearning/include/otbSOMModel.h | 4 ---- .../DimensionalityReductionLearning/include/otbSOMModel.txx | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx index 535c839e73..17067cc4bd 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx @@ -158,7 +158,7 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> radius[i]=std::stoi(n[i]); } dimredTrainer->SetNeighborhoodSizeInit(radius); - dimredTrainer->SetListSample(trainingListSample); + dimredTrainer->SetInputListSample(trainingListSample); dimredTrainer->Train(); dimredTrainer->Save(modelPath); } diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h index 0e5bbaca1f..7f6fb2b08e 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h @@ -100,8 +100,6 @@ public: itkGetMacro(RandomInit, bool); itkSetMacro(Seed, unsigned int); itkGetMacro(Seed, unsigned int); - itkGetObjectMacro(ListSample, InputListSampleType); - itkSetObjectMacro(ListSample, InputListSampleType); bool CanReadFile(const std::string & filename); bool CanWriteFile(const std::string & filename); @@ -140,8 +138,6 @@ private: bool m_RandomInit; /** Seed for random initialization */ unsigned int m_Seed; - /** The input list sample */ - ListSamplePointerType m_ListSample; /** Behavior of the Learning weightening (link to the beta coefficient) */ SOMLearningBehaviorFunctorType m_BetaFunctor; /** Behavior of the Neighborhood extent */ diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx index e0bfe52f92..bb9df24a6c 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx @@ -72,7 +72,7 @@ SOMModel<TInputValue, MapDimension>::Train() { typedef otb::SOM<InputListSampleType, MapType> EstimatorType; typename EstimatorType::Pointer estimator = EstimatorType::New(); - estimator->SetListSample(m_ListSample); + estimator->SetListSample(this->GetInputListSample()); estimator->SetMapSize(m_MapSize); estimator->SetNeighborhoodSizeInit(m_NeighborhoodSizeInit); estimator->SetNumberOfIterations(m_NumberOfIterations); -- GitLab From 68e2e74541ac5ee568094a15a628835dd9441a6c Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 11 Dec 2017 16:10:32 +0100 Subject: [PATCH 120/567] REFAC: change clampfilter to use a functor and be more generic --- .../include/otbClampImageFilter.h | 67 +++--- .../include/otbClampImageFilter.txx | 137 ++++++------ .../include/otbConvertTypeFunctor.h | 201 ++++++++++++++++++ .../include/otbDefaultConvertNewImpl.h | 42 ++++ 4 files changed, 357 insertions(+), 90 deletions(-) create mode 100644 Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h create mode 100644 Modules/Filtering/ImageManipulation/include/otbDefaultConvertNewImpl.h diff --git a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h index 6fdd16e955..f09cd0c54f 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h @@ -21,7 +21,8 @@ #ifndef otbClampImageFilter_h #define otbClampImageFilter_h -#include "itkImageToImageFilter.h" +#include "otbConvertTypeFunctor.h" +#include "itkUnaryFunctorImageFilter.h" namespace otb { @@ -45,61 +46,68 @@ namespace otb * \ingroup OTBImageManipulation */ template <class TInputImage, class TOutputImage=TInputImage> - class ITK_EXPORT ClampImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage> + class ITK_EXPORT ClampImageFilter + : public itk::UnaryFunctorImageFilter< TInputImage , TOutputImage , + Functor::ConvertTypeFunctor <typename TInputImage::PixelType , + typename TOutputImage::PixelType> > { public: /** Standard class typedefs. */ - typedef ClampImageFilter Self; - typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; + typedef ClampImageFilter Self; + typedef itk::UnaryFunctorImageFilter< TInputImage , TOutputImage , + Functor::ConvertTypeFunctor <typename TInputImage::PixelType , + typename TOutputImage::PixelType> > Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; /** Method for creation through the object factory. */ - itkNewMacro(Self); + itkNewMacro( Self ); /** Run-time type information (and related methods). */ - itkTypeMacro(ClampImageFilter, itk::ImageToImageFilter); + itkTypeMacro( ClampImageFilter , itk::UnaryFunctorImageFilter ); /** Some additional typedefs. */ typedef TInputImage InputImageType; - typedef typename InputImageType::ConstPointer InputImagePointer; typedef typename InputImageType::RegionType InputImageRegionType; typedef typename InputImageType::PixelType InputImagePixelType; /** Some additional typedefs. */ - typedef TOutputImage OutputImageType; - typedef typename OutputImageType::Pointer OutputImagePointer; - typedef typename OutputImageType::RegionType OutputImageRegionType; - typedef typename OutputImageType::PixelType OutputImagePixelType; + typedef TOutputImage OutputImageType; + typedef typename OutputImageType::RegionType OutputImageRegionType; + typedef typename OutputImageType::PixelType OutputImagePixelType; + typedef typename OutputImageType::InternalPixelType OutputInternalPixelType; + typedef typename itk::NumericTraits< OutputInternalPixelType >::ValueType OutputPixelValueType; /** The values greater than or equal to the value are set to OutsideValue. */ - void ClampAbove(const OutputImagePixelType &thresh); + void ClampAbove(const OutputPixelValueType &thresh); /** The values less than or equal to the value are set to OutsideValue. */ - void ClampBelow(const OutputImagePixelType &thresh); + void ClampBelow(const OutputPixelValueType &thresh); /** The values outside the range are set to OutsideValue. */ - void ClampOutside(const OutputImagePixelType &lower, const OutputImagePixelType &upper); + void ClampOutside(const OutputPixelValueType &lower, const OutputPixelValueType &upper); /** Set/Get methods to set the lower threshold */ - void SetLower(OutputImagePixelType val) + void SetLower(OutputPixelValueType val) { m_Lower = val; m_DLower = static_cast<double>(val); + this->GetFunctor().SetLowest( m_Lower ); this->Modified(); } - itkGetConstMacro(Lower, OutputImagePixelType); + itkGetConstMacro(Lower, OutputPixelValueType); /** Set/Get methods to set the upper threshold */ - void SetUpper(OutputImagePixelType val) + void SetUpper(OutputPixelValueType val) { m_Upper = val; m_DUpper = static_cast<double>(val); + this->GetFunctor().SetHighest( m_Upper ); this->Modified(); } - itkGetConstMacro(Upper, OutputImagePixelType); + itkGetConstMacro(Upper, OutputPixelValueType); protected: @@ -117,14 +125,23 @@ protected: * * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId ) ITK_OVERRIDE; + // void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, + // itk::ThreadIdType threadId ) ITK_OVERRIDE; void GenerateOutputInformation(void) ITK_OVERRIDE { Superclass::GenerateOutputInformation(); - this->GetOutput()->SetNumberOfComponentsPerPixel( this->GetInput()->GetNumberOfComponentsPerPixel() ); + // typename InputImageType::IndexType index; + // index.Fill(0); + // InputImagePixelType px = ->GetPixel( index ); + + unsigned int sizeIn = this->GetInput()->GetNumberOfComponentsPerPixel(); + // sizeIn *= itk::NumericTraits < typename itk::NumericTraits< InputImagePixelType >::ValueType > + // :: GetLength(); + + this->GetOutput()->SetNumberOfComponentsPerPixel( + this->GetFunctor().GetOutputSize ( sizeIn ) ); } private: @@ -134,8 +151,8 @@ private: double m_DLower; double m_DUpper; - OutputImagePixelType m_Lower; - OutputImagePixelType m_Upper; + OutputPixelValueType m_Lower; + OutputPixelValueType m_Upper; }; diff --git a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx index fd1ed1320e..2deb3cd4a1 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx +++ b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx @@ -25,6 +25,7 @@ #include "otbClampImageFilter.h" #include "itkImageRegionIterator.h" #include "itkNumericTraits.h" +#include <limits> #include "itkObjectFactory.h" #include "itkProgressReporter.h" @@ -38,8 +39,8 @@ template <class TInputImage, class TOutputImage> ClampImageFilter<TInputImage, TOutputImage> ::ClampImageFilter() { - m_Lower = itk::NumericTraits<OutputImagePixelType>::NonpositiveMin(); - m_Upper = itk::NumericTraits<OutputImagePixelType>::max(); + m_Lower = std::numeric_limits < OutputPixelValueType >::lowest(); + m_Upper = std::numeric_limits < OutputPixelValueType >::max(); m_DLower = static_cast<double>(m_Lower); m_DUpper = static_cast<double>(m_Upper); @@ -70,14 +71,16 @@ ClampImageFilter<TInputImage, TOutputImage> template <class TInputImage, class TOutputImage> void ClampImageFilter<TInputImage, TOutputImage> -::ClampAbove(const OutputImagePixelType &thresh) +::ClampAbove(const OutputPixelValueType &thresh) { if (m_Upper != thresh - || m_Lower > itk::NumericTraits<OutputImagePixelType>::NonpositiveMin()) + || m_Lower > std::numeric_limits < OutputPixelValueType >::lowest()) { - m_Lower = itk::NumericTraits<OutputImagePixelType>::NonpositiveMin(); + m_Lower = std::numeric_limits < OutputPixelValueType >::lowest(); m_Upper = thresh; m_DUpper = static_cast<double>(m_Upper); + this->GetFunctor().SetLowest( m_Lower ); + this->GetFunctor().SetHighest( m_Upper ); this->Modified(); } } @@ -88,13 +91,15 @@ ClampImageFilter<TInputImage, TOutputImage> template <class TInputImage, class TOutputImage> void ClampImageFilter<TInputImage, TOutputImage> -::ClampBelow(const OutputImagePixelType &thresh) +::ClampBelow(const OutputPixelValueType &thresh) { - if (m_Lower != thresh || m_Upper < itk::NumericTraits<OutputImagePixelType>::max()) + if (m_Lower != thresh || m_Upper < std::numeric_limits < OutputPixelValueType >::max()) { + m_Upper = std::numeric_limits < OutputPixelValueType >::max(); m_Lower = thresh; m_DLower = m_Lower; - m_Upper = itk::NumericTraits<InputImagePixelType>::max(); + this->GetFunctor().SetLowest( m_Lower ); + this->GetFunctor().SetHighest( m_Upper ); this->Modified(); } } @@ -106,7 +111,7 @@ ClampImageFilter<TInputImage, TOutputImage> template <class TInputImage, class TOutputImage> void ClampImageFilter<TInputImage, TOutputImage> -::ClampOutside(const OutputImagePixelType &lower, const OutputImagePixelType &upper) +::ClampOutside(const OutputPixelValueType &lower, const OutputPixelValueType &upper) { if (lower > upper) { @@ -120,6 +125,8 @@ ClampImageFilter<TInputImage, TOutputImage> m_Upper = upper; m_DLower = m_Lower; m_DUpper = m_Upper; + this->GetFunctor().SetLowest( m_Lower ); + this->GetFunctor().SetHighest( m_Upper ); this->Modified(); } } @@ -128,62 +135,62 @@ ClampImageFilter<TInputImage, TOutputImage> /** * */ -template <class TInputImage, class TOutputImage> -void -ClampImageFilter<TInputImage, TOutputImage> -::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) -{ - itkDebugMacro(<<"Actually executing"); - - // Get the input and output pointers - InputImagePointer inputPtr = this->GetInput(); - OutputImagePointer outputPtr = this->GetOutput(0); - - // Define/declare an iterator that will walk the output region for this - // thread. - typedef itk::ImageRegionConstIterator<TInputImage> InputIterator; - typedef itk::ImageRegionIterator<TOutputImage> OutputIterator; - - InputIterator inIt(inputPtr, outputRegionForThread); - OutputIterator outIt(outputPtr, outputRegionForThread); - - // support progress methods/callbacks - itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); - - // walk the regions, threshold each pixel - while( !outIt.IsAtEnd() && !inIt.IsAtEnd() ) - { - // Cast the value of the pixel to double in order to compare - // with the double version of the upper and the lower bounds of - // output image - const double value = static_cast<double>(inIt.Get()); - OutputImagePixelType outPix = m_Lower; - - if ( m_DLower <= value && value <= m_DUpper) - { - // pixel passes to output unchanged - outPix = static_cast<OutputImagePixelType>(value); - } - /* Already outPix is initialized with m_Lower even for preventing Warning. - * - else if ( value < m_DLower ) - { - outPix = m_Lower; - } - */ - else if ( value > m_DUpper) - { - outPix = m_Upper; - } - - outIt.Set( outPix ); - - ++inIt; - ++outIt; - progress.CompletedPixel(); - } -} +// template <class TInputImage, class TOutputImage> +// void +// ClampImageFilter<TInputImage, TOutputImage> +// ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, +// itk::ThreadIdType threadId) +// { +// itkDebugMacro(<<"Actually executing"); + +// // Get the input and output pointers +// typename InputImageType::ConstPointer inputPtr = this->GetInput(); +// typename OutputImageType::Pointer outputPtr = this->GetOutput(0); + +// // Define/declare an iterator that will walk the output region for this +// // thread. +// typedef itk::ImageRegionConstIterator<TInputImage> InputIterator; +// typedef itk::ImageRegionIterator<TOutputImage> OutputIterator; + +// InputIterator inIt(inputPtr, outputRegionForThread); +// OutputIterator outIt(outputPtr, outputRegionForThread); + +// // support progress methods/callbacks +// itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); + +// // walk the regions, threshold each pixel +// while( !outIt.IsAtEnd() && !inIt.IsAtEnd() ) +// { +// // Cast the value of the pixel to double in order to compare +// // with the double version of the upper and the lower bounds of +// // output image +// const double value = static_cast<double>(inIt.Get()); +// OutputImagePixelType outPix = m_Lower; + +// if ( m_DLower <= value && value <= m_DUpper) +// { +// // pixel passes to output unchanged +// outPix = static_cast<OutputImagePixelType>(value); +// } +// /* Already outPix is initialized with m_Lower even for preventing Warning. +// * +// else if ( value < m_DLower ) +// { +// outPix = m_Lower; +// } +// */ +// else if ( value > m_DUpper) +// { +// outPix = m_Upper; +// } + +// outIt.Set( outPix ); + +// ++inIt; +// ++outIt; +// progress.CompletedPixel(); +// } +// } } // end namespace itk diff --git a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h new file mode 100644 index 0000000000..c5360f2960 --- /dev/null +++ b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbConvertTypeFunctor_h +#define otbConvertTypeFunctor_h + +#include <limits> +#include <type_traits> +#include <boost/type_traits/is_complex.hpp> +#include <boost/type_traits/is_scalar.hpp> + +#include "itkVariableLengthVector.h" +#include "itkNumericTraits.h" +#include "otbDefaultConvertNewImpl.h" + +namespace otb +{ +namespace Functor +{ + +template < class TInputPixelType , class TOutputPixelType > +class ConvertTypeFunctor +{ +public: + typedef TInputPixelType InputPixelType; + typedef TOutputPixelType OutputPixelType; + typedef ConvertTypeFunctor Self; + + typedef typename itk::NumericTraits < InputPixelType > :: ValueType InputInternalPixelType; + typedef typename itk::NumericTraits < OutputPixelType > :: ValueType OutputInternalPixelType; + + typedef typename itk::NumericTraits < InputInternalPixelType > :: ValueType InputPixelValueType; + typedef typename itk::NumericTraits < OutputInternalPixelType > :: ValueType OutputPixelValueType; + + // template < class InternalPixelType > + unsigned int GetOutputSize( unsigned int sizeIn ) + { + m_CompIn = sizeIn ; + if ( m_cInPix || m_cInInternalPix ) + m_Scal = 2 * m_CompIn; + else + m_Scal = m_CompIn; + if ( m_cOutPix || m_cOutInternalPix ) + { + m_CompOut = sizeIn / 2 ; // ( sizeIn + 1 )/ 2 + return m_CompOut ; + } + else + { + m_CompOut = sizeIn ; + return m_CompOut ; + } + } + + void SetLowest( OutputPixelValueType & lowest ) + { + m_LowestB = lowest; + m_LowestBD = static_cast < double > ( m_LowestB ); + } + + void SetHighest( OutputPixelValueType & highest ) + { + m_HighestB = highest; + m_HighestBD = static_cast < double > ( m_HighestB ); + } + + ConvertTypeFunctor() + { + m_LowestB = std::numeric_limits < OutputPixelValueType >::lowest(); + m_HighestB = std::numeric_limits < OutputPixelValueType >::max(); + + m_LowestBD = static_cast < double > ( m_LowestB ); + m_HighestBD = static_cast < double > ( m_HighestB ); + + m_cInPix = boost::is_complex < InputPixelType > :: value ; + m_cOutPix = boost::is_complex < OutputPixelType > :: value ; + m_cInInternalPix = boost::is_complex < InputInternalPixelType > :: value ; + m_cOutInternalPix = boost::is_complex < OutputInternalPixelType > :: value ; + m_MultiCompIn = ! ( boost::is_complex < InputPixelType > :: value ) + || ! ( boost::is_scalar < InputPixelType > :: value) ; + m_MultiCompOut = ! ( boost::is_complex < OutputPixelType > :: value ) + || ! ( boost::is_scalar < OutputPixelType > :: value); + } + + + OutputPixelType operator() ( InputPixelType const & in ) const + { + std::vector < double > vPixel; + for ( unsigned int i = 0 ; i < m_CompIn ; i ++) + FillIn < InputPixelType > ( i , in , vPixel ); + Clamp( vPixel ); + OutputPixelType out; + int hack = 1; + if ( m_cOutPix && !m_MultiCompOut ) + hack += 1; // needed in case we have OutputPixelType == complex<t> as SetLength() will ask a length of 2! + itk::NumericTraits < OutputPixelType > :: SetLength( out , hack * m_CompOut ); + for ( unsigned int i = 0 ; i < m_CompOut ; i ++) + FillOut < OutputPixelType > ( i , out , vPixel ); + return out; + } + + ~ConvertTypeFunctor() {}; + +protected: + + template <class PixelType , + std::enable_if_t < std::is_arithmetic < PixelType > ::value , int > = 2 > + void FillIn( unsigned int i , InputPixelType const & pix , std::vector < double > & vPix ) const + { + vPix.push_back( DefaultConvertPixelTraitsTest < InputPixelType > :: + GetNthComponent( i , pix ) ); + } + + template <class PixelType , + std::enable_if_t < boost::is_complex < PixelType > :: value , int > = 1 > + void FillIn( unsigned int i , InputPixelType const & pix , std::vector < double > & vPix ) const + { + PixelType comp = DefaultConvertPixelTraitsTest < InputPixelType > :: + GetNthComponent( i , pix ); + vPix.push_back( static_cast < double > ( real( comp ) ) ); + vPix.push_back( static_cast < double > ( imag( comp ) ) ); + } + + template <class PixelType , + std::enable_if_t < !( boost::is_complex < PixelType > :: value || std::is_arithmetic < PixelType > ::value ) , int > = 0 > + void FillIn( unsigned int i , InputPixelType const & pix , std::vector < double > & vPix ) const + { + FillIn < InputInternalPixelType > ( i , pix , vPix ); + } + + void Clamp( std::vector < double > & vPixel ) const + { + assert( m_Scal == vPixel.size() ); + for ( double & comp : vPixel ) + { + if ( comp >= m_HighestBD ) + comp = m_HighestBD; + else if ( comp <= m_LowestBD ) + comp = m_LowestBD; + } + } + + template <class PixelType , + std::enable_if_t < std::is_arithmetic < PixelType > ::value , int > = 2 > + void FillOut( unsigned int i , OutputPixelType & pix , std::vector < double > & vPix ) const + { + DefaultConvertPixelTraitsTest < OutputPixelType > :: + SetNthComponent( i , pix , vPix[i] ); + } + + template <class PixelType , + std::enable_if_t < boost::is_complex < PixelType > :: value , int > = 1 > + void FillOut( unsigned int i , OutputPixelType & pix , std::vector < double > & vPix ) const + { + DefaultConvertPixelTraitsTest < OutputPixelType > :: + SetNthComponent( i , pix , + PixelType ( vPix[ 2 * i] , vPix[ 2 * i + 1] ) ); + } + + template <class PixelType , + std::enable_if_t < !( boost::is_complex < PixelType > :: value || std::is_arithmetic < PixelType > ::value ) , int > = 0 > + void FillOut( unsigned int i , OutputPixelType & pix , std::vector < double > & vPix ) const + { + FillOut < OutputInternalPixelType > ( i , pix , vPix ); + } + +private: + ConvertTypeFunctor(const Self &) = delete; + void operator =(const Self&) = delete; + + double m_LowestBD , m_HighestBD ; + OutputPixelValueType m_LowestB , m_HighestB ; + unsigned int m_CompIn , m_CompOut , m_Scal ; + bool m_cInPix , m_cInInternalPix , m_cOutPix , m_cOutInternalPix , + m_MultiCompIn , m_MultiCompOut ; + + +}; + +} //end namespace Functor + +} //end namespace otb + +#endif diff --git a/Modules/Filtering/ImageManipulation/include/otbDefaultConvertNewImpl.h b/Modules/Filtering/ImageManipulation/include/otbDefaultConvertNewImpl.h new file mode 100644 index 0000000000..44e9b17a59 --- /dev/null +++ b/Modules/Filtering/ImageManipulation/include/otbDefaultConvertNewImpl.h @@ -0,0 +1,42 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#ifndef otbDefaultConvertNewImp_h +#define otbDefaultConvertNewImp_h + +#include "itkDefaultConvertPixelTraits.h" + +namespace otb +{ +template < typename PixelType> +class DefaultConvertPixelTraitsTest : public itk::DefaultConvertPixelTraits < PixelType > +{ + +}; + +template < typename T > +class DefaultConvertPixelTraitsTest < std::complex < T > > : public itk::DefaultConvertPixelTraits < std::complex < T > > +{ +public: + typedef itk::DefaultConvertPixelTraits < std::complex < T > > SuperClass; + static typename SuperClass::TargetType GetNthComponent ( int , const typename SuperClass::TargetType & pixel ) + { + return pixel; + } +}; +} // end namespace +#endif -- GitLab From 381a994a7b8cb2b1fb84a298d0ef8f0f6b1c9729 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 11 Dec 2017 17:56:25 +0100 Subject: [PATCH 121/567] REFAC: refac defaultconvertpixel implementation with inheritance from itk --- .../include/otbDefaultConvertNewImpl.h | 92 +++++++++++++++++++ .../include/otbDefaultConvertNewImpl.h | 42 --------- .../IO/ImageIO/include/otbImageFileReader.h | 4 +- .../IO/ImageIO/include/otbImageFileReader.txx | 4 +- 4 files changed, 96 insertions(+), 46 deletions(-) create mode 100644 Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h delete mode 100644 Modules/Filtering/ImageManipulation/include/otbDefaultConvertNewImpl.h diff --git a/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h b/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h new file mode 100644 index 0000000000..bd084e77ff --- /dev/null +++ b/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h @@ -0,0 +1,92 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#ifndef otbDefaultConvertNewImp_h +#define otbDefaultConvertNewImp_h + +#include "itkDefaultConvertPixelTraits.h" +#include "itkRGBPixel.h" + +// #include "itkOffset.h" +// #include "itkVector.h" +// #include "itkMatrix.h" +// #include "itkVariableLengthVector.h" +// #include "itkVariableSizeMatrix.h" + +namespace otb +{ +template < typename PixelType> +class DefaultConvertPixelTraitsTest : public itk::DefaultConvertPixelTraits < PixelType > +{ +public: + typedef PixelType TargetType; + static void SetNthComponent(int , TargetType & pixel, const TargetType& v) + { + pixel = v; + } +}; + +template < typename T > +class DefaultConvertPixelTraitsTest < std::complex < T > > : public itk::DefaultConvertPixelTraits < std::complex < T > > +{ +public: + typedef itk::DefaultConvertPixelTraits < std::complex < T > > SuperClass; + typedef typename SuperClass::TargetType TargetType; + static void SetNthComponent(int , TargetType & pixel, const TargetType& v) + { + pixel = v; + } + static TargetType GetNthComponent ( int , const TargetType & pixel ) + { + return pixel; + } +}; + +// template <> +// class DefaultConvertPixelTraitsTest < itk::RGBPixel < short int > > +// : public itk::DefaultConvertPixelTraits < itk::FixedArray < short int > > +// { +// public: +// typedef itk::DefaultConvertPixelTraits < itk::RGBPixel < short int > > SuperClass; +// typedef itk::RGBPixel < short int > TargetType; +// static void SetNthComponent(int , TargetType & pixel, const TargetType & v) +// { +// pixel = v; +// } +// }; + +#define OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \ +template < typename TComponentType , unsigned VDimension > \ +class DefaultConvertPixelTraitsTest < type < TComponentType , VDimension > > \ +: public itk::DefaultConvertPixelTraits < type < TComponentType , VDimension > > \ +{ \ +public: \ + typedef itk::DefaultConvertPixelTraits < type < TComponentType , VDimension > > SuperClass;\ + typedef typename SuperClass::TargetType TargetType; \ + static void SetNthComponent(int , TargetType & pixel, const TargetType & v) \ + { \ + pixel = v; \ + } \ +} \ + +OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Vector); +OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::CovariantVector); +OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Point); +OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::FixedArray); + +} // end namespace +#endif diff --git a/Modules/Filtering/ImageManipulation/include/otbDefaultConvertNewImpl.h b/Modules/Filtering/ImageManipulation/include/otbDefaultConvertNewImpl.h deleted file mode 100644 index 44e9b17a59..0000000000 --- a/Modules/Filtering/ImageManipulation/include/otbDefaultConvertNewImpl.h +++ /dev/null @@ -1,42 +0,0 @@ -/*========================================================================= - * - * Copyright Insight Software Consortium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ -#ifndef otbDefaultConvertNewImp_h -#define otbDefaultConvertNewImp_h - -#include "itkDefaultConvertPixelTraits.h" - -namespace otb -{ -template < typename PixelType> -class DefaultConvertPixelTraitsTest : public itk::DefaultConvertPixelTraits < PixelType > -{ - -}; - -template < typename T > -class DefaultConvertPixelTraitsTest < std::complex < T > > : public itk::DefaultConvertPixelTraits < std::complex < T > > -{ -public: - typedef itk::DefaultConvertPixelTraits < std::complex < T > > SuperClass; - static typename SuperClass::TargetType GetNthComponent ( int , const typename SuperClass::TargetType & pixel ) - { - return pixel; - } -}; -} // end namespace -#endif diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.h b/Modules/IO/ImageIO/include/otbImageFileReader.h index 631f9d7dc2..8843e4bb2b 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.h +++ b/Modules/IO/ImageIO/include/otbImageFileReader.h @@ -33,7 +33,7 @@ #include "itkExceptionObject.h" #include "itkImageRegion.h" -#include "otbDefaultConvertPixelTraits.h" +#include "otbDefaultConvertNewImpl.h" #include "otbImageKeywordlist.h" #include "otbExtendedFilenameToReaderOptions.h" @@ -86,7 +86,7 @@ public: * \ingroup OTBImageIO */ template <class TOutputImage, - class ConvertPixelTraits=DefaultConvertPixelTraits< + class ConvertPixelTraits=DefaultConvertPixelTraitsTest< typename TOutputImage::IOPixelType > > class ITK_EXPORT ImageFileReader : public itk::ImageSource<TOutputImage> { diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx index 98a37bf87b..1c67d82e00 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.txx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx @@ -179,8 +179,8 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> this->m_ImageIO->SetIORegion(ioRegion); - typedef otb::DefaultConvertPixelTraits<typename TOutputImage::IOPixelType> ConvertIOPixelTraits; - typedef otb::DefaultConvertPixelTraits<typename TOutputImage::PixelType> ConvertOutputPixelTraits; + typedef otb::DefaultConvertPixelTraitsTest<typename TOutputImage::IOPixelType> ConvertIOPixelTraits; + typedef otb::DefaultConvertPixelTraitsTest<typename TOutputImage::PixelType> ConvertOutputPixelTraits; if (this->m_ImageIO->GetComponentTypeInfo() == typeid(typename ConvertOutputPixelTraits::ComponentType) -- GitLab From 1136b39b28ae0b55474f3979cb520c98b747e87e Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 11 Dec 2017 18:06:26 +0100 Subject: [PATCH 122/567] REFAC: add some specialisation for the class defaultconvertpixel --- .../include/otbDefaultConvertNewImpl.h | 52 ++++++++++++++----- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h b/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h index bd084e77ff..7cf9add535 100644 --- a/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h +++ b/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h @@ -40,8 +40,13 @@ public: } }; +// +// Default traits for the complex<> pixel type +// + template < typename T > -class DefaultConvertPixelTraitsTest < std::complex < T > > : public itk::DefaultConvertPixelTraits < std::complex < T > > +class DefaultConvertPixelTraitsTest < std::complex < T > > +: public itk::DefaultConvertPixelTraits < std::complex < T > > { public: typedef itk::DefaultConvertPixelTraits < std::complex < T > > SuperClass; @@ -56,18 +61,39 @@ public: } }; -// template <> -// class DefaultConvertPixelTraitsTest < itk::RGBPixel < short int > > -// : public itk::DefaultConvertPixelTraits < itk::FixedArray < short int > > -// { -// public: -// typedef itk::DefaultConvertPixelTraits < itk::RGBPixel < short int > > SuperClass; -// typedef itk::RGBPixel < short int > TargetType; -// static void SetNthComponent(int , TargetType & pixel, const TargetType & v) -// { -// pixel = v; -// } -// }; +// +// Default traits for the Offset<> pixel type +// + +template<unsigned int VDimension> +class DefaultConvertPixelTraitsTest < itk::Offset< VDimension > > : +public itk::DefaultConvertPixelTraits< itk::Offset< VDimension > > +{ +public: + typedef itk::DefaultConvertPixelTraits < itk::Offset< VDimension > > SuperClass; + typedef typename SuperClass::TargetType TargetType; + static void SetNthComponent(int , TargetType & pixel, const TargetType& v) + { + pixel = v; + } +}; + +// +// Default traits for the pixel types deriving from Matrix<> +// + +template<typename VComponent, unsigned VRows, unsigned VCols > +class DefaultConvertPixelTraitsTest < itk::Matrix< VComponent, VRows, VCols > > +: public itk::DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > +{ +public: + typedef itk::DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > SuperClass; + typedef typename SuperClass::TargetType TargetType; + static void SetNthComponent(int , TargetType & pixel, const TargetType& v) + { + pixel = v; + } +}; #define OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \ template < typename TComponentType , unsigned VDimension > \ -- GitLab From 771b4dda2d0d5a03ad5ee6163cde85b514f9e358 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 11 Dec 2017 18:10:11 +0100 Subject: [PATCH 123/567] TEST: use smaller dataset for faster tests --- .../Learning/Supervised/test/tests-libsvm.cmake | 2 +- .../Learning/Supervised/test/tests-opencv.cmake | 16 ++++++++-------- .../Learning/Supervised/test/tests-shark.cmake | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Modules/Learning/Supervised/test/tests-libsvm.cmake b/Modules/Learning/Supervised/test/tests-libsvm.cmake index bbf6647ab0..03b5118cd9 100644 --- a/Modules/Learning/Supervised/test/tests-libsvm.cmake +++ b/Modules/Learning/Supervised/test/tests-libsvm.cmake @@ -20,7 +20,7 @@ otb_add_test(NAME leTvLibSVMMachineLearningModel COMMAND otbSupervisedTestDriver otbLibSVMMachineLearningModel - ${INPUTDATA}/letter.scale + ${INPUTDATA}/letter_light.scale ${TEMP}/libsvm_model.txt ) otb_add_test(NAME leTuLibSVMMachineLearningModelNew COMMAND otbSupervisedTestDriver diff --git a/Modules/Learning/Supervised/test/tests-opencv.cmake b/Modules/Learning/Supervised/test/tests-opencv.cmake index a309c341dc..f898971f56 100644 --- a/Modules/Learning/Supervised/test/tests-opencv.cmake +++ b/Modules/Learning/Supervised/test/tests-opencv.cmake @@ -26,7 +26,7 @@ otb_add_test(NAME leTuRandomForestsMachineLearningModelNew COMMAND otbSupervised otb_add_test(NAME leTvANNMachineLearningModel COMMAND otbSupervisedTestDriver otbANNMachineLearningModel - ${INPUTDATA}/letter.scale + ${INPUTDATA}/letter_light.scale ${TEMP}/ann_model.txt ) @@ -74,7 +74,7 @@ otb_add_test(NAME leTvSVMMachineLearningRegressionModel COMMAND otbSupervisedTes otb_add_test(NAME leTvSVMMachineLearningModel COMMAND otbSupervisedTestDriver otbSVMMachineLearningModel - ${INPUTDATA}/letter.scale + ${INPUTDATA}/letter_light.scale ${TEMP}/svm_model.txt ) @@ -83,14 +83,14 @@ otb_add_test(NAME leTuBoostMachineLearningModelNew COMMAND otbSupervisedTestDriv otb_add_test(NAME leTvNormalBayesMachineLearningModel COMMAND otbSupervisedTestDriver otbNormalBayesMachineLearningModel - ${INPUTDATA}/letter.scale + ${INPUTDATA}/letter_light.scale ${TEMP}/normalbayes_model.txt ) if(NOT OTB_OPENCV_3) otb_add_test(NAME leTvGradientBoostedTreeMachineLearningModel COMMAND otbSupervisedTestDriver otbGradientBoostedTreeMachineLearningModel - ${INPUTDATA}/letter.scale + ${INPUTDATA}/letter_light.scale ${TEMP}/gbt_model.txt ) otb_add_test(NAME leTuGradientBoostedTreeMachineLearningModelNew COMMAND otbSupervisedTestDriver @@ -99,7 +99,7 @@ endif() otb_add_test(NAME leTvRandomForestsMachineLearningModel COMMAND otbSupervisedTestDriver otbRandomForestsMachineLearningModel - ${INPUTDATA}/letter.scale + ${INPUTDATA}/letter_light.scale ${TEMP}/rf_model.txt ) @@ -108,19 +108,19 @@ otb_add_test(NAME leTuANNMachineLearningModelNew COMMAND otbSupervisedTestDriver otb_add_test(NAME leTvKNearestNeighborsMachineLearningModel COMMAND otbSupervisedTestDriver otbKNearestNeighborsMachineLearningModel - ${INPUTDATA}/letter.scale + ${INPUTDATA}/letter_light.scale ${TEMP}/knn_model.txt ) otb_add_test(NAME leTvDecisionTreeMachineLearningModel COMMAND otbSupervisedTestDriver otbDecisionTreeMachineLearningModel - ${INPUTDATA}/letter.scale + ${INPUTDATA}/letter_light.scale ${TEMP}/decisiontree_model.txt ) otb_add_test(NAME leTvBoostMachineLearningModel COMMAND otbSupervisedTestDriver otbBoostMachineLearningModel - ${INPUTDATA}/letter.scale + ${INPUTDATA}/letter_light.scale ${TEMP}/boost_model.txt ) diff --git a/Modules/Learning/Supervised/test/tests-shark.cmake b/Modules/Learning/Supervised/test/tests-shark.cmake index eeda8fff3f..546e826043 100644 --- a/Modules/Learning/Supervised/test/tests-shark.cmake +++ b/Modules/Learning/Supervised/test/tests-shark.cmake @@ -23,7 +23,7 @@ otb_add_test(NAME leTuSharkRFMachineLearningModelNew COMMAND otbSupervisedTestDr otb_add_test(NAME leTvSharkRFMachineLearningModel COMMAND otbSupervisedTestDriver otbSharkRFMachineLearningModel - ${INPUTDATA}/letter.scale + ${INPUTDATA}/letter_light.scale ${TEMP}/shark_rf_model.txt ) -- GitLab From d7ba64ffd4482ff590d9916a70d60195cf734097 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 11 Dec 2017 18:11:02 +0100 Subject: [PATCH 124/567] BUG: missing call to SetMeasurementVectorSize() --- Modules/IO/TestKernel/include/otbReadDataFile.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/IO/TestKernel/include/otbReadDataFile.h b/Modules/IO/TestKernel/include/otbReadDataFile.h index 5ba16330a2..0e7174be6e 100644 --- a/Modules/IO/TestKernel/include/otbReadDataFile.h +++ b/Modules/IO/TestKernel/include/otbReadDataFile.h @@ -50,6 +50,7 @@ bool ReadDataFile( return false; } + labels->SetMeasurementVectorSize(1); unsigned int nbfeatures = 0; while (!ifs.eof()) -- GitLab From 04d6b48d5c96910603f083ea188da2ffd7cf1542 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 11 Dec 2017 18:12:03 +0100 Subject: [PATCH 125/567] STYLE: use otbMsgDevMacro instead of cout --- .../include/otbAutoencoderModel.txx | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index 77ac08ef45..ad62ef6cc0 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -21,6 +21,7 @@ #define otbAutoencoderModel_txx #include "otbAutoencoderModel.h" +#include "otbMacro.h" #include <fstream> #include "itkMacro.h" @@ -92,7 +93,6 @@ AutoencoderModel<TInputValue,NeuronType> for (unsigned int i = std::max(0,static_cast<int>(m_NumberOfHiddenNeurons.Size()-1)) ; i > 0; --i) { - std::cout << i << std::endl; layers.push_back(m_NumberOfHiddenNeurons[i-1]); } @@ -126,7 +126,7 @@ AutoencoderModel<TInputValue,NeuronType> if (m_Noise[0] != 0) { TrainOneLayer(criterion, net, 0, inputSamples, ofs); - std::cout << "mnoise " << m_Noise[0] << std::endl; + otbMsgDevMacro(<< "m_Noise " << m_Noise[0]); } else { @@ -166,7 +166,7 @@ AutoencoderModel<TInputValue,NeuronType> if (m_Noise[i] != 0) { TrainOneLayer(criterion, net, i, inputSamples, ofs); - std::cout << "mnoise " << m_Noise[i] << std::endl; + otbMsgDevMacro(<< "m_Noise " << m_Noise[0]); } else { @@ -193,8 +193,7 @@ AutoencoderModel<TInputValue,NeuronType> shark::Data<shark::RealVector> &samples, std::ostream& File) { - //AutoencoderType net; - std::cout << "noise " << m_Noise[layer_index] << std::endl; + otbMsgDevMacro(<< "Noise " << m_Noise[layer_index]); std::size_t inputs = dataDimension(samples); net.setStructure(inputs, m_NumberOfHiddenNeurons[layer_index]); initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); @@ -212,7 +211,7 @@ AutoencoderModel<TInputValue,NeuronType> error.init(); optimizer.init(error); - std::cout<<"error before training : " << optimizer.solution().value<<std::endl; + otbMsgDevMacro(<<"Error before training : " << optimizer.solution().value); if (this->m_WriteLearningCurve == true) { File << "end layer" << std::endl; @@ -227,7 +226,7 @@ AutoencoderModel<TInputValue,NeuronType> { File << optimizer.solution().value << std::endl; } - std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<< std::endl ; + otbMsgDevMacro(<<"Error after " << i << " iterations : " << optimizer.solution().value); } while( !criterion.stop( optimizer.solution() ) ); net.setParameterVector(optimizer.solution().point); @@ -259,18 +258,17 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer( shark::TwoNormRegularizer regularizer(error.numberOfVariables()); error.setRegularizer(m_Regularization[layer_index],®ularizer); - std::cout << samples.element(0) << std::endl; shark::IRpropPlusFull optimizer; error.init(); optimizer.init(error); - std::cout<<"error before training : " << optimizer.solution().value<<std::endl; + otbMsgDevMacro(<<"Error before training : " << optimizer.solution().value); unsigned int i=0; do { i++; optimizer.step(error); - std::cout<<"error after " << i << "iterations : " << optimizer.solution().value <<std::endl; + otbMsgDevMacro(<<"Error after " << i << " iterations : " << optimizer.solution().value); if (this->m_WriteLearningCurve == true) { File << optimizer.solution().value << std::endl; @@ -295,7 +293,8 @@ AutoencoderModel<TInputValue,NeuronType> shark::Data<shark::RealVector> &samples, std::ostream& File) { - shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs + //labels identical to inputs + shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples); shark::SquaredLoss<shark::RealVector> loss; shark::ErrorFunction error(trainSet, &m_Net, &loss); @@ -305,19 +304,18 @@ AutoencoderModel<TInputValue,NeuronType> shark::IRpropPlusFull optimizer; error.init(); optimizer.init(error); - std::cout<<"error before training : " << optimizer.solution().value<<std::endl; + otbMsgDevMacro(<<"Error before training : " << optimizer.solution().value); unsigned int i=0; while( !criterion.stop( optimizer.solution() ) ) { i++; optimizer.step(error); - std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; + otbMsgDevMacro(<<"Error after " << i << " iterations : " << optimizer.solution().value); if (this->m_WriteLearningCurve == true) { File << optimizer.solution().value << std::endl; } } - //std::cout<<"error after " << i << "iterations : " << optimizer.solution().value<<std::endl; } template <class TInputValue, class NeuronType> @@ -350,7 +348,7 @@ void AutoencoderModel<TInputValue,NeuronType> ::Save(const std::string & filename, const std::string & /*name*/) { - std::cout << "saving model ..." << std::endl; + otbMsgDevMacro(<< "saving model ..."); std::ofstream ofs(filename); ofs << m_Net.name() << std::endl; // the first line of the model file contains a key boost::archive::polymorphic_text_oarchive oa(ofs); @@ -381,7 +379,6 @@ AutoencoderModel<TInputValue,NeuronType> ifs.getline(autoencoder,256); std::string autoencoderstr(autoencoder); - std::cout << autoencoderstr << std::endl; if (autoencoderstr != net.name()){ itkExceptionMacro(<< "Error opening " << filename.c_str() ); } @@ -391,8 +388,8 @@ AutoencoderModel<TInputValue,NeuronType> // This gives us the dimension if we keep the encoder and decoder size_t feature_layer_index = m_Net.layerMatrices().size()/2; - this->m_Dimension = m_Net.layerMatrix(feature_layer_index).size1(); // number of neurons in the feature layer (first dimension of the first decoder weight matrix) - std::cout << this->m_Dimension << std::endl; + // number of neurons in the feature layer (first dimension of the first decoder weight matrix) + this->m_Dimension = m_Net.layerMatrix(feature_layer_index).size1(); } template <class TInputValue, class NeuronType> -- GitLab From 23d69b729a7a77898ffb9e58e243e43c475bcc6d Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 11 Dec 2017 18:12:49 +0100 Subject: [PATCH 126/567] TEST: add first tests for DR models (WIP) --- .../test/CMakeLists.txt | 52 +++++++++ .../test/otbAutoencoderModelTest.cxx | 105 ++++++++++++++++++ ...ensionalityReductionLearningTestDriver.cxx | 28 +++++ ...ImageDimensionalityReductionFilterTest.cxx | 20 ++++ .../test/otbPCAModelTest.cxx | 20 ++++ .../test/otbSOMModelTest.cxx | 20 ++++ 6 files changed, 245 insertions(+) create mode 100644 Modules/Learning/DimensionalityReductionLearning/test/CMakeLists.txt create mode 100644 Modules/Learning/DimensionalityReductionLearning/test/otbAutoencoderModelTest.cxx create mode 100644 Modules/Learning/DimensionalityReductionLearning/test/otbDimensionalityReductionLearningTestDriver.cxx create mode 100644 Modules/Learning/DimensionalityReductionLearning/test/otbImageDimensionalityReductionFilterTest.cxx create mode 100644 Modules/Learning/DimensionalityReductionLearning/test/otbPCAModelTest.cxx create mode 100644 Modules/Learning/DimensionalityReductionLearning/test/otbSOMModelTest.cxx diff --git a/Modules/Learning/DimensionalityReductionLearning/test/CMakeLists.txt b/Modules/Learning/DimensionalityReductionLearning/test/CMakeLists.txt new file mode 100644 index 0000000000..531d8e5223 --- /dev/null +++ b/Modules/Learning/DimensionalityReductionLearning/test/CMakeLists.txt @@ -0,0 +1,52 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +otb_module_test() + +set(OTBDimensionalityReductionLearningTests +otbDimensionalityReductionLearningTestDriver.cxx +otbAutoencoderModelTest.cxx +) + +add_executable(otbDimensionalityReductionLearningTestDriver ${OTBDimensionalityReductionLearningTests}) +target_link_libraries(otbDimensionalityReductionLearningTestDriver ${OTBDimensionalityReductionLearning-Test_LIBRARIES}) +otb_module_target_label(otbDimensionalityReductionLearningTestDriver) + +# Tests Declaration +# --------------- Autoencoder -------------------------------- +otb_add_test(NAME leTuAutoencoderModelNew COMMAND + otbDimensionalityReductionLearningTestDriver + otbAutoencoderModelNew + ) + +otb_add_test(NAME leTvAutoencoderModelTrain COMMAND + otbDimensionalityReductionLearningTestDriver + otbAutoencoderModeTrain + ${INPUTDATA}/letter_light.scale + ${TEMP}/ae_model.txt + ) + +otb_add_test(NAME leTvAutoencoderModelCanRead COMMAND + otbDimensionalityReductionLearningTestDriver + otbAutoencoderModelCanRead + ${TEMP}/ae_model.txt + ) + +set_property(TEST leTvAutoencoderModelCanRead APPEND PROPERTY DEPENDS leTvAutoencoderModelTrain) diff --git a/Modules/Learning/DimensionalityReductionLearning/test/otbAutoencoderModelTest.cxx b/Modules/Learning/DimensionalityReductionLearning/test/otbAutoencoderModelTest.cxx new file mode 100644 index 0000000000..5f79af16c7 --- /dev/null +++ b/Modules/Learning/DimensionalityReductionLearning/test/otbAutoencoderModelTest.cxx @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbAutoencoderModel.h" +#include "otbReadDataFile.h" +#include "itkMacro.h" + +typedef otb::AutoencoderModel<double, shark::LogisticNeuron> LogAutoencoderModel; +typedef LogAutoencoderModel::InputListSampleType InputListSampleType; +typedef LogAutoencoderModel::TargetListSampleType TargetListSampleType; + +int otbAutoencoderModelNew(int itkNotUsed(argc), char * itkNotUsed(argv) []) +{ + LogAutoencoderModel::Pointer model = LogAutoencoderModel::New(); + + return EXIT_SUCCESS; +} + +int otbAutoencoderModelCanRead(int argc, char * argv []) +{ + if (argc < 2) + { + std::cerr << "Usage: " << argv[0] << " <model>" << std::endl; + return EXIT_FAILURE; + } + + LogAutoencoderModel::Pointer model = LogAutoencoderModel::New(); + std::string filename(argv[1]); + if (! model->CanReadFile(filename) ) + { + std::cerr << "Failed to read model file : "<< filename << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +int otbAutoencoderModeTrain(int argc, char * argv []) +{ + if (argc < 3) + { + std::cerr << "Usage: " << argv[0] << " letter.scale model.out" << std::endl; + return EXIT_FAILURE; + } + + // Extract data from letter.scale + InputListSampleType::Pointer samples = InputListSampleType::New(); + TargetListSampleType::Pointer target = TargetListSampleType::New(); + if (!otb::ReadDataFile(argv[1], samples, target)) + { + std::cout << "Failed to read samples file " << argv[1] << std::endl; + return EXIT_FAILURE; + } + + itk::Array<unsigned int> nb_neuron; + itk::Array<float> noise; + itk::Array<float> regularization; + itk::Array<float> rho; + itk::Array<float> beta; + + nb_neuron.SetSize(1); + noise.SetSize(1); + regularization.SetSize(1); + rho.SetSize(1); + beta.SetSize(1); + + nb_neuron[0] = 14; + noise[0] = 0.0; + regularization[0] = 0.01; + rho[0] = 0.0; + beta[0] = 0.0; + + LogAutoencoderModel::Pointer model = LogAutoencoderModel::New(); + model->SetNumberOfHiddenNeurons(nb_neuron); + model->SetNumberOfIterations(100); + model->SetNumberOfIterationsFineTuning(0); + model->SetEpsilon(0.0); + model->SetInitFactor(1.0); + model->SetRegularization(regularization); + model->SetNoise(noise); + model->SetRho(rho); + model->SetBeta(beta); + model->SetWriteWeights(true); + model->SetInputListSample(samples); + model->Train(); + model->Save(std::string(argv[2])); + + return EXIT_SUCCESS; +} diff --git a/Modules/Learning/DimensionalityReductionLearning/test/otbDimensionalityReductionLearningTestDriver.cxx b/Modules/Learning/DimensionalityReductionLearning/test/otbDimensionalityReductionLearningTestDriver.cxx new file mode 100644 index 0000000000..d3ea9575c5 --- /dev/null +++ b/Modules/Learning/DimensionalityReductionLearning/test/otbDimensionalityReductionLearningTestDriver.cxx @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbTestMain.h" + +void RegisterTests() +{ + REGISTER_TEST(otbAutoencoderModelNew); + REGISTER_TEST(otbAutoencoderModelCanRead); + REGISTER_TEST(otbAutoencoderModeTrain); +} diff --git a/Modules/Learning/DimensionalityReductionLearning/test/otbImageDimensionalityReductionFilterTest.cxx b/Modules/Learning/DimensionalityReductionLearning/test/otbImageDimensionalityReductionFilterTest.cxx new file mode 100644 index 0000000000..a2b8da9d9a --- /dev/null +++ b/Modules/Learning/DimensionalityReductionLearning/test/otbImageDimensionalityReductionFilterTest.cxx @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + diff --git a/Modules/Learning/DimensionalityReductionLearning/test/otbPCAModelTest.cxx b/Modules/Learning/DimensionalityReductionLearning/test/otbPCAModelTest.cxx new file mode 100644 index 0000000000..a2b8da9d9a --- /dev/null +++ b/Modules/Learning/DimensionalityReductionLearning/test/otbPCAModelTest.cxx @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + diff --git a/Modules/Learning/DimensionalityReductionLearning/test/otbSOMModelTest.cxx b/Modules/Learning/DimensionalityReductionLearning/test/otbSOMModelTest.cxx new file mode 100644 index 0000000000..a2b8da9d9a --- /dev/null +++ b/Modules/Learning/DimensionalityReductionLearning/test/otbSOMModelTest.cxx @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + -- GitLab From e2113f55e2679f226c36f7cba523066120e7c2ed Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 12 Dec 2017 10:47:07 +0100 Subject: [PATCH 127/567] BUG: fix module dependencies --- .../otb-module.cmake | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake b/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake index d3f5e7fd08..aaff635d35 100644 --- a/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake +++ b/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake @@ -21,14 +21,16 @@ set(DOCUMENTATION "Dimensionality reduction application") otb_module(OTBDimensionalityReductionLearning DEPENDS - OTBCommon - OTBApplicationEngine - OTBITK - OTBShark - OTBBoost - OTBAppClassification - OTBSOM - OTBLearningBase - DESCRIPTION - "${DOCUMENTATION}" + OTBCommon + OTBITK + OTBShark + OTBBoost + OTBSOM + OTBLearningBase + + TEST_DEPENDS + OTBTestKernel + + DESCRIPTION + "${DOCUMENTATION}" ) -- GitLab From 79a87846d14aa8c35ee3271a9763e41c5f823b27 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 12 Dec 2017 10:48:20 +0100 Subject: [PATCH 128/567] WRG: unused variables --- .../include/otbTrainDimensionalityReductionApplicationBase.txx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx index 56a3364915..0575410176 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbTrainDimensionalityReductionApplicationBase.txx @@ -64,7 +64,7 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> template <class TInputValue, class TOutputValue> void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> -::Reduce(typename ListSampleType::Pointer validationListSample,std::string modelPath) +::Reduce(typename ListSampleType::Pointer /*validationListSample*/,std::string /*modelPath*/) { } -- GitLab From 902d6333173b25113052f850a15d0b7b3dd4d393 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 12 Dec 2017 10:49:41 +0100 Subject: [PATCH 129/567] COMP: missing includes to boost --- .../include/otbAutoencoderModel.txx | 3 +++ .../DimensionalityReductionLearning/include/otbPCAModel.txx | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index ad62ef6cc0..df00d43e11 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -51,6 +51,9 @@ #pragma GCC diagnostic pop #endif +#include <boost/archive/polymorphic_text_oarchive.hpp> +#include <boost/archive/polymorphic_text_iarchive.hpp> + namespace otb { diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx index 376b107da1..bfe53d7643 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx @@ -41,6 +41,9 @@ #pragma GCC diagnostic pop #endif +#include <boost/archive/polymorphic_text_oarchive.hpp> +#include <boost/archive/polymorphic_text_iarchive.hpp> + namespace otb { -- GitLab From f7b6779e413ecda914eca2700a5ef8b819ff6315 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 12 Dec 2017 17:46:49 +0100 Subject: [PATCH 130/567] BUG: bugfix in order to be able to use masked function --- .../include/otbDefaultConvertNewImpl.h | 208 +++++++++++++----- 1 file changed, 154 insertions(+), 54 deletions(-) diff --git a/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h b/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h index 7cf9add535..4ffd0d6099 100644 --- a/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h +++ b/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h @@ -19,7 +19,6 @@ #define otbDefaultConvertNewImp_h #include "itkDefaultConvertPixelTraits.h" -#include "itkRGBPixel.h" // #include "itkOffset.h" // #include "itkVector.h" @@ -29,73 +28,81 @@ namespace otb { + + template < typename PixelType> -class DefaultConvertPixelTraitsTest : public itk::DefaultConvertPixelTraits < PixelType > +class DefaultConvertPixelTraitsTest +: public itk::DefaultConvertPixelTraits < PixelType > { public: - typedef PixelType TargetType; - static void SetNthComponent(int , TargetType & pixel, const TargetType& v) - { - pixel = v; - } -}; + typedef itk::DefaultConvertPixelTraits < PixelType > SuperClass; + using SuperClass::ComponentType; -// -// Default traits for the complex<> pixel type -// + using SuperClass::SetNthComponent; -template < typename T > -class DefaultConvertPixelTraitsTest < std::complex < T > > -: public itk::DefaultConvertPixelTraits < std::complex < T > > -{ -public: - typedef itk::DefaultConvertPixelTraits < std::complex < T > > SuperClass; - typedef typename SuperClass::TargetType TargetType; - static void SetNthComponent(int , TargetType & pixel, const TargetType& v) + static void SetNthComponent(int , PixelType & pixel, const PixelType & v) { pixel = v; } - static TargetType GetNthComponent ( int , const TargetType & pixel ) - { - return pixel; - } }; +// We might not need this specialization if the compileur allow +// us to declare to function with same signature in some case : +// see "SetNthComponent" +#define OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \ + template< > \ + class DefaultConvertPixelTraitsTest < type > \ + : public itk::DefaultConvertPixelTraits < type > \ + { \ +public: \ + typedef itk::DefaultConvertPixelTraits < type > SuperClass; \ + using typename SuperClass::ComponentType; \ + }; + +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(float) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(double) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long double) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(int) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(char) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(short) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned int) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(signed char) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned char) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned short) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long long) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long long) +OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(bool) + +#undef OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL + // // Default traits for the Offset<> pixel type // -template<unsigned int VDimension> -class DefaultConvertPixelTraitsTest < itk::Offset< VDimension > > : -public itk::DefaultConvertPixelTraits< itk::Offset< VDimension > > -{ -public: - typedef itk::DefaultConvertPixelTraits < itk::Offset< VDimension > > SuperClass; - typedef typename SuperClass::TargetType TargetType; - static void SetNthComponent(int , TargetType & pixel, const TargetType& v) - { - pixel = v; - } -}; +// template<unsigned int VDimension> +// class DefaultConvertPixelTraitsTest < itk::Offset< VDimension > > : +// public itk::DefaultConvertPixelTraits< itk::Offset< VDimension > > +// { +// public: +// typedef itk::DefaultConvertPixelTraits < itk::Offset< VDimension > > SuperClass; +// using typename SuperClass::ComponentType; + +// using SuperClass::SetNthComponent; + +// static void SetNthComponent(int , TargetType & pixel, const TargetType& v) +// { +// pixel = v; +// } +// }; // -// Default traits for the pixel types deriving from Matrix<> +// Default traits for the pixel types deriving from FixedArray<> // -template<typename VComponent, unsigned VRows, unsigned VCols > -class DefaultConvertPixelTraitsTest < itk::Matrix< VComponent, VRows, VCols > > -: public itk::DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > -{ -public: - typedef itk::DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > SuperClass; - typedef typename SuperClass::TargetType TargetType; - static void SetNthComponent(int , TargetType & pixel, const TargetType& v) - { - pixel = v; - } -}; - -#define OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \ +/* +define OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \ template < typename TComponentType , unsigned VDimension > \ class DefaultConvertPixelTraitsTest < type < TComponentType , VDimension > > \ : public itk::DefaultConvertPixelTraits < type < TComponentType , VDimension > > \ @@ -108,11 +115,104 @@ public: pixel = v; \ } \ } \ +*/ +// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::FixedArray); +// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Vector); +// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::CovariantVector); +// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Point); + +// #undef OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE + +// +// Default traits for pixel types deriving from VariableLengthVector<> +// + +// template < typename T > +// class DefaultConvertPixelTraitsTest < itk::VariableLengthVector < T > > +// : public itk::DefaultConvertPixelTraits < itk::VariableLengthVector< T > > +// { +// public: +// typedef itk::DefaultConvertPixelTraits< itk::VariableLengthVector < T > > SuperClass; +// using typename SuperClass::TargetType; +// using typename SuperClass::ComponentType; +// }; + +// +// Default traits for the pixel types deriving from Matrix<> +// + +// template<typename VComponent, unsigned VRows, unsigned VCols > +// class DefaultConvertPixelTraitsTest < itk::Matrix< VComponent, VRows, VCols > > +// : public itk::DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > +// { +// public: +// typedef itk::DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > SuperClass; +// using typename SuperClass::TargetType; +// using typename SuperClass::ComponentType; + + +// using SuperClass::SetNthComponent; + +// static void SetNthComponent(int , TargetType & pixel, const TargetType& v) +// { +// pixel = v; +// } +// }; + +// +// Default traits for pixel types deriving from VariableSizeMatrix<> +// + +// template < typename T > +// class DefaultConvertPixelTraitsTest< itk::VariableSizeMatrix< T > > +// : public itk::DefaultConvertPixelTraits< itk::VariableSizeMatrix< T > > +// { +// public: +// typedef itk::DefaultConvertPixelTraits< itk::VariableSizeMatrix < T > > SuperClass; +// using typename SuperClass::TargetType; +// using typename SuperClass::ComponentType; +// }; + +// +// Default traits for pixel types deriving from std::complex<> +// -OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Vector); -OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::CovariantVector); -OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Point); -OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::FixedArray); +template < typename T > +class DefaultConvertPixelTraitsTest < ::std::complex < T > > +: public itk::DefaultConvertPixelTraits < ::std::complex < T > > +{ +public: + + typedef itk::DefaultConvertPixelTraits < ::std::complex < T > > SuperClass; + using typename SuperClass::TargetType ; + using typename SuperClass::ComponentType ; + + using SuperClass::SetNthComponent ; + + static void SetNthComponent(int , TargetType & pixel, const TargetType & v) + { + pixel = v; + } + + static TargetType GetNthComponent ( int , const TargetType & pixel ) + { + return pixel; + } + + static ComponentType GetScalarValue(const TargetType& pixel) + { + /* + * This seems to be dead code, since the complex to scalar + * conversion is done by ConvertPixelBuffer + * + * Historically, it was returning std::norm, which causes + * compilation error on MacOSX 10.9. + * Now returns the equivalent implementation of std::norm. + */ + return static_cast<ComponentType>( pixel.real()*pixel.real() + + pixel.imag()*pixel.imag() ); + } +}; } // end namespace #endif -- GitLab From 2ac1e1c18cdf1b9a1a7903db71df40526d1a1055 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 12 Dec 2017 18:12:41 +0100 Subject: [PATCH 131/567] STYLE: include not needed, otbMacro is already here --- .../include/otbAutoencoderModel.txx | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index df00d43e11..02282b4c09 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -24,7 +24,6 @@ #include "otbMacro.h" #include <fstream> -#include "itkMacro.h" #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push -- GitLab From cffb9130424238f4589a39f8090a02976d62b72a Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 12 Dec 2017 18:13:14 +0100 Subject: [PATCH 132/567] TEST: new tests for DR models --- .../test/CMakeLists.txt | 54 ++++++- .../test/otbAutoencoderModelTest.cxx | 2 +- ...ensionalityReductionLearningTestDriver.cxx | 6 + .../test/otbPCAModelTest.cxx | 58 +++++++ .../test/otbSOMModelTest.cxx | 148 ++++++++++++++++++ 5 files changed, 265 insertions(+), 3 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/test/CMakeLists.txt b/Modules/Learning/DimensionalityReductionLearning/test/CMakeLists.txt index 531d8e5223..e519062977 100644 --- a/Modules/Learning/DimensionalityReductionLearning/test/CMakeLists.txt +++ b/Modules/Learning/DimensionalityReductionLearning/test/CMakeLists.txt @@ -23,6 +23,8 @@ otb_module_test() set(OTBDimensionalityReductionLearningTests otbDimensionalityReductionLearningTestDriver.cxx otbAutoencoderModelTest.cxx +otbPCAModelTest.cxx +otbSOMModelTest.cxx ) add_executable(otbDimensionalityReductionLearningTestDriver ${OTBDimensionalityReductionLearningTests}) @@ -40,13 +42,61 @@ otb_add_test(NAME leTvAutoencoderModelTrain COMMAND otbDimensionalityReductionLearningTestDriver otbAutoencoderModeTrain ${INPUTDATA}/letter_light.scale - ${TEMP}/ae_model.txt + ${TEMP}/model.ae ) otb_add_test(NAME leTvAutoencoderModelCanRead COMMAND otbDimensionalityReductionLearningTestDriver otbAutoencoderModelCanRead - ${TEMP}/ae_model.txt + ${TEMP}/model.ae ) set_property(TEST leTvAutoencoderModelCanRead APPEND PROPERTY DEPENDS leTvAutoencoderModelTrain) + +# --------------- PCA -------------------------------- +otb_add_test(NAME leTuPCAModelNew COMMAND + otbDimensionalityReductionLearningTestDriver + otbPCAModelNew + ) + +otb_add_test(NAME leTvPCAModelTrain COMMAND + otbDimensionalityReductionLearningTestDriver + otbPCAModeTrain + ${INPUTDATA}/letter_light.scale + ${TEMP}/model.pca + ) + +otb_add_test(NAME leTvPCAModelCanRead COMMAND + otbDimensionalityReductionLearningTestDriver + otbPCAModelCanRead + ${TEMP}/model.pca + ) + +set_property(TEST leTvPCAModelCanRead APPEND PROPERTY DEPENDS leTvPCAModelTrain) + +# --------------- SOM -------------------------------- +otb_add_test(NAME leTuSOMModelNew COMMAND + otbDimensionalityReductionLearningTestDriver + otbSOMModelNew + ) + +otb_add_test(NAME leTvSOMModelTrain COMMAND + otbDimensionalityReductionLearningTestDriver + otbSOMModeTrain + ${INPUTDATA}/letter_light.scale + ${TEMP}/model2D.som + ${TEMP}/model3D.som + ${TEMP}/model4D.som + ${TEMP}/model5D.som + ) + +otb_add_test(NAME leTvSOMModelCanRead COMMAND + otbDimensionalityReductionLearningTestDriver + otbSOMModelCanRead + ${TEMP}/model2D.som + ${TEMP}/model3D.som + ${TEMP}/model4D.som + ${TEMP}/model5D.som + ) + +set_property(TEST leTvSOMModelCanRead APPEND PROPERTY DEPENDS leTvSOMModelTrain) diff --git a/Modules/Learning/DimensionalityReductionLearning/test/otbAutoencoderModelTest.cxx b/Modules/Learning/DimensionalityReductionLearning/test/otbAutoencoderModelTest.cxx index 5f79af16c7..ad3880f6f5 100644 --- a/Modules/Learning/DimensionalityReductionLearning/test/otbAutoencoderModelTest.cxx +++ b/Modules/Learning/DimensionalityReductionLearning/test/otbAutoencoderModelTest.cxx @@ -88,7 +88,7 @@ int otbAutoencoderModeTrain(int argc, char * argv []) LogAutoencoderModel::Pointer model = LogAutoencoderModel::New(); model->SetNumberOfHiddenNeurons(nb_neuron); - model->SetNumberOfIterations(100); + model->SetNumberOfIterations(50); model->SetNumberOfIterationsFineTuning(0); model->SetEpsilon(0.0); model->SetInitFactor(1.0); diff --git a/Modules/Learning/DimensionalityReductionLearning/test/otbDimensionalityReductionLearningTestDriver.cxx b/Modules/Learning/DimensionalityReductionLearning/test/otbDimensionalityReductionLearningTestDriver.cxx index d3ea9575c5..6e0c644798 100644 --- a/Modules/Learning/DimensionalityReductionLearning/test/otbDimensionalityReductionLearningTestDriver.cxx +++ b/Modules/Learning/DimensionalityReductionLearning/test/otbDimensionalityReductionLearningTestDriver.cxx @@ -25,4 +25,10 @@ void RegisterTests() REGISTER_TEST(otbAutoencoderModelNew); REGISTER_TEST(otbAutoencoderModelCanRead); REGISTER_TEST(otbAutoencoderModeTrain); + REGISTER_TEST(otbPCAModelNew); + REGISTER_TEST(otbPCAModelCanRead); + REGISTER_TEST(otbPCAModeTrain); + REGISTER_TEST(otbSOMModelNew); + REGISTER_TEST(otbSOMModelCanRead); + REGISTER_TEST(otbSOMModeTrain); } diff --git a/Modules/Learning/DimensionalityReductionLearning/test/otbPCAModelTest.cxx b/Modules/Learning/DimensionalityReductionLearning/test/otbPCAModelTest.cxx index a2b8da9d9a..6fe3945e43 100644 --- a/Modules/Learning/DimensionalityReductionLearning/test/otbPCAModelTest.cxx +++ b/Modules/Learning/DimensionalityReductionLearning/test/otbPCAModelTest.cxx @@ -18,3 +18,61 @@ * limitations under the License. */ +#include "otbPCAModel.h" +#include "otbReadDataFile.h" + +typedef otb::PCAModel<double> PCAModelType; +typedef PCAModelType::InputListSampleType InputListSampleType; +typedef PCAModelType::TargetListSampleType TargetListSampleType; + +int otbPCAModelNew(int itkNotUsed(argc), char * itkNotUsed(argv) []) +{ + PCAModelType::Pointer model = PCAModelType::New(); + + return EXIT_SUCCESS; +} + +int otbPCAModelCanRead(int argc, char * argv []) +{ + if (argc < 2) + { + std::cerr << "Usage: " << argv[0] << " <model>" << std::endl; + return EXIT_FAILURE; + } + + PCAModelType::Pointer model = PCAModelType::New(); + std::string filename(argv[1]); + if (! model->CanReadFile(filename) ) + { + std::cerr << "Failed to read model file : "<< filename << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +int otbPCAModeTrain(int argc, char * argv []) +{ + if (argc < 3) + { + std::cerr << "Usage: " << argv[0] << " letter.scale model.out" << std::endl; + return EXIT_FAILURE; + } + + // Extract data from letter.scale + InputListSampleType::Pointer samples = InputListSampleType::New(); + TargetListSampleType::Pointer target = TargetListSampleType::New(); + if (!otb::ReadDataFile(argv[1], samples, target)) + { + std::cout << "Failed to read samples file " << argv[1] << std::endl; + return EXIT_FAILURE; + } + + PCAModelType::Pointer model = PCAModelType::New(); + model->SetDimension(14); + model->SetWriteEigenvectors(true); + model->SetInputListSample(samples); + model->Train(); + model->Save(std::string(argv[2])); + + return EXIT_SUCCESS; +} diff --git a/Modules/Learning/DimensionalityReductionLearning/test/otbSOMModelTest.cxx b/Modules/Learning/DimensionalityReductionLearning/test/otbSOMModelTest.cxx index a2b8da9d9a..092cac8404 100644 --- a/Modules/Learning/DimensionalityReductionLearning/test/otbSOMModelTest.cxx +++ b/Modules/Learning/DimensionalityReductionLearning/test/otbSOMModelTest.cxx @@ -18,3 +18,151 @@ * limitations under the License. */ +#include "otbSOMModel.h" +#include "otbReadDataFile.h" + +typedef otb::SOMModel<double,2> SOMModel2D; +typedef otb::SOMModel<double,3> SOMModel3D; +typedef otb::SOMModel<double,4> SOMModel4D; +typedef otb::SOMModel<double,5> SOMModel5D; + +typedef SOMModel2D::InputListSampleType InputListSampleType; +typedef SOMModel2D::TargetListSampleType TargetListSampleType; + +int otbSOMModelNew(int itkNotUsed(argc), char * itkNotUsed(argv) []) +{ + SOMModel2D::Pointer model2D = SOMModel2D::New(); + SOMModel3D::Pointer model3D = SOMModel3D::New(); + SOMModel4D::Pointer model4D = SOMModel4D::New(); + SOMModel5D::Pointer model5D = SOMModel5D::New(); + + return EXIT_SUCCESS; +} + +int otbSOMModelCanRead(int argc, char * argv []) +{ + if (argc < 2) + { + std::cerr << "Usage: " << argv[0] << " <model2D> <model3D> <model4D> <model5D>" << std::endl; + return EXIT_FAILURE; + } + + std::string filename2D(argv[1]); + std::string filename3D(argv[2]); + std::string filename4D(argv[3]); + std::string filename5D(argv[4]); + + SOMModel2D::Pointer model2D = SOMModel2D::New(); + SOMModel3D::Pointer model3D = SOMModel3D::New(); + SOMModel4D::Pointer model4D = SOMModel4D::New(); + SOMModel5D::Pointer model5D = SOMModel5D::New(); + + if (! model2D->CanReadFile(filename2D) ) + { + std::cerr << "Failed to read model file : "<< filename2D << std::endl; + return EXIT_FAILURE; + } + if (! model3D->CanReadFile(filename3D) ) + { + std::cerr << "Failed to read model file : "<< filename3D << std::endl; + return EXIT_FAILURE; + } + if (! model4D->CanReadFile(filename4D) ) + { + std::cerr << "Failed to read model file : "<< filename4D << std::endl; + return EXIT_FAILURE; + } + if (! model5D->CanReadFile(filename5D) ) + { + std::cerr << "Failed to read model file : "<< filename5D << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + +int otbSOMModeTrain(int argc, char * argv []) +{ + if (argc < 3) + { + std::cerr << "Usage: " << argv[0] << " letter.scale model2D.out model3D.out model4D.out model5D.out" << std::endl; + return EXIT_FAILURE; + } + + // Extract data from letter.scale + InputListSampleType::Pointer samples = InputListSampleType::New(); + TargetListSampleType::Pointer target = TargetListSampleType::New(); + if (!otb::ReadDataFile(argv[1], samples, target)) + { + std::cout << "Failed to read samples file " << argv[1] << std::endl; + return EXIT_FAILURE; + } + + SOMModel2D::Pointer model2D = SOMModel2D::New(); + SOMModel3D::Pointer model3D = SOMModel3D::New(); + SOMModel4D::Pointer model4D = SOMModel4D::New(); + SOMModel5D::Pointer model5D = SOMModel5D::New(); + + SOMModel2D::SizeType size2D, radius2D; + size2D.Fill(10); + radius2D.Fill(3); + SOMModel3D::SizeType size3D, radius3D; + size3D.Fill(6); + radius3D.Fill(3); + SOMModel4D::SizeType size4D, radius4D; + size4D.Fill(4); + radius4D.Fill(2); + SOMModel5D::SizeType size5D, radius5D; + size5D.Fill(3); + radius5D.Fill(2); + + std::cout << "Train 2D model..."<< std::endl; + model2D->SetNumberOfIterations(10); + model2D->SetBetaInit(1.0); + model2D->SetWriteMap(true); + model2D->SetBetaEnd(0.1); + model2D->SetMaxWeight(10.0); + model2D->SetMapSize(size2D); + model2D->SetNeighborhoodSizeInit(radius2D); + model2D->SetInputListSample(samples); + model2D->Train(); + model2D->Save(std::string(argv[2])); + + std::cout << "Train 3D model..."<< std::endl; + model3D->SetNumberOfIterations(10); + model3D->SetBetaInit(1.0); + model3D->SetWriteMap(true); + model3D->SetBetaEnd(0.1); + model3D->SetMaxWeight(10.0); + model3D->SetMapSize(size3D); + model3D->SetNeighborhoodSizeInit(radius3D); + model3D->SetInputListSample(samples); + model3D->Train(); + model3D->Save(std::string(argv[3])); + + std::cout << "Train 4D model..."<< std::endl; + model4D->SetNumberOfIterations(10); + model4D->SetBetaInit(1.0); + model4D->SetWriteMap(true); + model4D->SetBetaEnd(0.1); + model4D->SetMaxWeight(10.0); + model4D->SetMapSize(size4D); + model4D->SetNeighborhoodSizeInit(radius4D); + model4D->SetInputListSample(samples); + model4D->Train(); + model4D->Save(std::string(argv[4])); + + std::cout << "Train 5D model..."<< std::endl; + model5D->SetNumberOfIterations(10); + model5D->SetBetaInit(1.0); + model5D->SetWriteMap(true); + model5D->SetBetaEnd(0.1); + model5D->SetMaxWeight(10.0); + model5D->SetMapSize(size5D); + model5D->SetNeighborhoodSizeInit(radius5D); + model5D->SetInputListSample(samples); + model5D->Train(); + model5D->Save(std::string(argv[5])); + + return EXIT_SUCCESS; +} + -- GitLab From a9482db4ae1343295b3f054ef03a4fc673caabfa Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 12 Dec 2017 18:13:56 +0100 Subject: [PATCH 133/567] STYLE: remove noisy prints --- .../include/otbDimensionalityReductionTrainAutoencoder.txx | 3 --- 1 file changed, 3 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx index efcbd303b9..6f073353f3 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx @@ -170,15 +170,12 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue>::Trai if (HasValue("algorithm.autoencoder.learningcurve") && IsParameterEnabled("algorithm.autoencoder.learningcurve")) { - std::cout << "yo" << std::endl; dimredTrainer->SetWriteLearningCurve(true); dimredTrainer->SetLearningCurveFileName(GetParameterString("algorithm.autoencoder.learningcurve")); } dimredTrainer->SetInputListSample(trainingListSample); - std::cout << "before train" << std::endl; dimredTrainer->Train(); - std::cout << "after train" << std::endl; dimredTrainer->Save(modelPath); } -- GitLab From 5a686bb997661bf77fe4ddd06bceeee45f4c7a3a Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 12 Dec 2017 18:23:33 +0100 Subject: [PATCH 134/567] ENH: add possibility to get a complex from a scalar with a imaginary part equal to 0 --- .../ImageManipulation/include/otbConvertTypeFunctor.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h index c5360f2960..49358d4169 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h @@ -59,7 +59,7 @@ public: m_Scal = m_CompIn; if ( m_cOutPix || m_cOutInternalPix ) { - m_CompOut = sizeIn / 2 ; // ( sizeIn + 1 )/ 2 + m_CompOut = ( sizeIn + 1 ) / 2 ; // ( sizeIn + 1 )/ 2 return m_CompOut ; } else @@ -105,6 +105,8 @@ public: std::vector < double > vPixel; for ( unsigned int i = 0 ; i < m_CompIn ; i ++) FillIn < InputPixelType > ( i , in , vPixel ); + if ( ( m_cOutPix || m_cOutInternalPix ) && vPixel.size()%2 ) + vPixel.push_back(0); // last component has no imaginary part Clamp( vPixel ); OutputPixelType out; int hack = 1; -- GitLab From e0d1634645fc6c4b00d28fe5a7553ce1a29f8293 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 12 Dec 2017 18:28:09 +0100 Subject: [PATCH 135/567] REFAC: change all the different cast filters to the one and only ClampImageFilter --- .../src/otbWrapperOutputImageParameter.cxx | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 57f362d3ef..eed6e99d42 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -379,7 +379,7 @@ OutputImageParameter::SwitchCImageWrite() m_ComplexFloatWriter , m_FileName , m_RAMValue , - itk::CastImageFilter< TInput , ComplexFloatImageType >::New() ); + otb::ClampImageFilter< TInput , ComplexFloatImageType >::New() ); break; } case ImagePixelType_cdouble: @@ -389,7 +389,7 @@ OutputImageParameter::SwitchCImageWrite() m_ComplexDoubleWriter , m_FileName , m_RAMValue , - itk::CastImageFilter< TInput , ComplexDoubleImageType >::New() ); + otb::ClampImageFilter< TInput , ComplexDoubleImageType >::New() ); break; } default: @@ -411,7 +411,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_VectorUInt8Writer , m_FileName , m_RAMValue , - otb::ClampVectorImageFilter< TInput , UInt8VectorImageType >::New() ); + otb::ClampImageFilter< TInput , UInt8VectorImageType >::New() ); break; } case ImagePixelType_int16: @@ -421,7 +421,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_VectorInt16Writer , m_FileName , m_RAMValue , - otb::ClampVectorImageFilter< TInput , Int16VectorImageType >::New() ); + otb::ClampImageFilter< TInput , Int16VectorImageType >::New() ); break; } case ImagePixelType_uint16: @@ -431,7 +431,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_VectorUInt16Writer , m_FileName , m_RAMValue , - otb::ClampVectorImageFilter< TInput , UInt16VectorImageType >::New() ); + otb::ClampImageFilter< TInput , UInt16VectorImageType >::New() ); break; } case ImagePixelType_int32: @@ -441,7 +441,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_VectorInt32Writer , m_FileName , m_RAMValue , - otb::ClampVectorImageFilter< TInput , Int32VectorImageType >::New() ); + otb::ClampImageFilter< TInput , Int32VectorImageType >::New() ); break; } case ImagePixelType_uint32: @@ -451,7 +451,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_VectorUInt32Writer , m_FileName , m_RAMValue , - otb::ClampVectorImageFilter< TInput , UInt32VectorImageType >::New() ); + otb::ClampImageFilter< TInput , UInt32VectorImageType >::New() ); break; } case ImagePixelType_float: @@ -461,7 +461,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_VectorFloatWriter , m_FileName , m_RAMValue , - otb::ClampVectorImageFilter< TInput , FloatVectorImageType >::New() ); + otb::ClampImageFilter< TInput , FloatVectorImageType >::New() ); break; } case ImagePixelType_double: @@ -471,7 +471,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_VectorDoubleWriter , m_FileName , m_RAMValue , - otb::ClampVectorImageFilter< TInput , DoubleVectorImageType >::New() ); + otb::ClampImageFilter< TInput , DoubleVectorImageType >::New() ); break; } case ImagePixelType_cfloat: @@ -481,7 +481,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_ComplexVectorFloatWriter , m_FileName , m_RAMValue , - otb::TwoNRIBandsImageToNComplexBandsImage < TInput , ComplexFloatVectorImageType >::New() ); + otb::ClampImageFilter < TInput , ComplexFloatVectorImageType >::New() ); break; } case ImagePixelType_cdouble: @@ -491,7 +491,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_ComplexVectorDoubleWriter , m_FileName , m_RAMValue , - otb::TwoNRIBandsImageToNComplexBandsImage < TInput , ComplexDoubleVectorImageType >::New() ); + otb::ClampImageFilter < TInput , ComplexDoubleVectorImageType >::New() ); break; } default: @@ -512,7 +512,7 @@ OutputImageParameter::SwitchVectorCImageWrite() m_ComplexVectorFloatWriter , m_FileName , m_RAMValue , - itk::CastImageFilter< TInput , ComplexFloatVectorImageType >::New() ); + otb::ClampImageFilter< TInput , ComplexFloatVectorImageType >::New() ); break; } case ImagePixelType_cdouble: @@ -522,7 +522,7 @@ OutputImageParameter::SwitchVectorCImageWrite() m_ComplexVectorDoubleWriter , m_FileName , m_RAMValue , - itk::CastImageFilter< TInput , ComplexDoubleVectorImageType >::New() ); + otb::ClampImageFilter< TInput , ComplexDoubleVectorImageType >::New() ); break; } default: -- GitLab From 02702e792c632ba3e1b8e0cc0ac9802938fd7e80 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 12 Dec 2017 18:36:01 +0100 Subject: [PATCH 136/567] REFAC: change all the different cast filters to the one and only ClampImageFilter for InputParameter --- .../include/otbWrapperInputImageParameter.txx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx index 3db013c1fb..791f77cdb3 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx @@ -26,6 +26,7 @@ #include "itkUnaryFunctorImageFilter.h" #include "itkCastImageFilter.h" #include "otbImageToVectorImageCastFilter.h" +#include "otbClampImageFilter.h" namespace otb { @@ -223,7 +224,7 @@ InputImageParameter::SimpleCastImage() { TInputImage* realInputImage = dynamic_cast<TInputImage*>(m_Image.GetPointer()); - typedef itk::CastImageFilter<TInputImage, TOutputImage> CasterType; + typedef ClampImageFilter<TInputImage, TOutputImage> CasterType; typename CasterType::Pointer caster = CasterType::New(); caster->SetInput(realInputImage); @@ -243,7 +244,7 @@ InputImageParameter::CastVectorImageFromImage() { TInputImage* realInputImage = dynamic_cast<TInputImage*>(m_Image.GetPointer()); - typedef ImageToVectorImageCastFilter<TInputImage, TOutputImage> CasterType; + typedef ClampImageFilter<TInputImage, TOutputImage> CasterType; typename CasterType::Pointer caster = CasterType::New(); caster->SetInput(realInputImage); -- GitLab From ee51b5875cf5c486414eb85eda6427e41f98b861 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 12 Dec 2017 18:58:14 +0100 Subject: [PATCH 137/567] ENH: move all MachineLearningModelFactoryBase to LearningBase --- Modules/Learning/LearningBase/CMakeLists.txt | 2 ++ .../otbMachineLearningModelFactoryBase.h | 4 +-- .../Learning/LearningBase/otb-module.cmake | 1 + .../Learning/LearningBase/src/CMakeLists.txt | 31 +++++++++++++++++++ .../otbMachineLearningModelFactoryBase.cxx | 0 .../Learning/Supervised/src/CMakeLists.txt | 2 +- 6 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 Modules/Learning/LearningBase/src/CMakeLists.txt rename Modules/Learning/{Supervised => LearningBase}/src/otbMachineLearningModelFactoryBase.cxx (100%) diff --git a/Modules/Learning/LearningBase/CMakeLists.txt b/Modules/Learning/LearningBase/CMakeLists.txt index b3460da963..45b573a3dc 100644 --- a/Modules/Learning/LearningBase/CMakeLists.txt +++ b/Modules/Learning/LearningBase/CMakeLists.txt @@ -20,4 +20,6 @@ project(OTBLearningBase) +set(OTBLearningBase_LIBRARIES OTBLearningBase) + otb_module_impl() diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModelFactoryBase.h b/Modules/Learning/LearningBase/include/otbMachineLearningModelFactoryBase.h index 0ca61f2c37..012e0f1d77 100644 --- a/Modules/Learning/LearningBase/include/otbMachineLearningModelFactoryBase.h +++ b/Modules/Learning/LearningBase/include/otbMachineLearningModelFactoryBase.h @@ -22,7 +22,7 @@ #define otbMachineLearningModelFactoryBase_h #include "itkMutexLock.h" -#include "OTBSupervisedExport.h" +#include "OTBLearningBaseExport.h" namespace otb { @@ -34,7 +34,7 @@ namespace otb * * \ingroup OTBLearningBase */ -class OTBSupervised_EXPORT MachineLearningModelFactoryBase : public itk::Object +class OTBLearningBase_EXPORT MachineLearningModelFactoryBase : public itk::Object { public: /** Standard class typedefs. */ diff --git a/Modules/Learning/LearningBase/otb-module.cmake b/Modules/Learning/LearningBase/otb-module.cmake index b4fab23bba..5d45c1c962 100644 --- a/Modules/Learning/LearningBase/otb-module.cmake +++ b/Modules/Learning/LearningBase/otb-module.cmake @@ -22,6 +22,7 @@ set(DOCUMENTATION "This module contains OTB generic Machine Learning framework mainly based on OpenCV.") otb_module(OTBLearningBase + ENABLE_SHARED DEPENDS OTBCommon OTBITK diff --git a/Modules/Learning/LearningBase/src/CMakeLists.txt b/Modules/Learning/LearningBase/src/CMakeLists.txt new file mode 100644 index 0000000000..9e7a49db7f --- /dev/null +++ b/Modules/Learning/LearningBase/src/CMakeLists.txt @@ -0,0 +1,31 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set(OTBLearningBase_SRC + otbMachineLearningModelFactoryBase.cxx + ) + +add_library(OTBLearningBase ${OTBLearningBase_SRC}) +target_link_libraries(OTBLearningBase + ${OTBCommon_LIBRARIES} + ${OTBITK_LIBRARIES} + ) + +otb_module_target(OTBLearningBase) diff --git a/Modules/Learning/Supervised/src/otbMachineLearningModelFactoryBase.cxx b/Modules/Learning/LearningBase/src/otbMachineLearningModelFactoryBase.cxx similarity index 100% rename from Modules/Learning/Supervised/src/otbMachineLearningModelFactoryBase.cxx rename to Modules/Learning/LearningBase/src/otbMachineLearningModelFactoryBase.cxx diff --git a/Modules/Learning/Supervised/src/CMakeLists.txt b/Modules/Learning/Supervised/src/CMakeLists.txt index 7a3c77b3a7..45e881904b 100644 --- a/Modules/Learning/Supervised/src/CMakeLists.txt +++ b/Modules/Learning/Supervised/src/CMakeLists.txt @@ -19,7 +19,6 @@ # set(OTBSupervised_SRC - otbMachineLearningModelFactoryBase.cxx otbExhaustiveExponentialOptimizer.cxx ) @@ -33,6 +32,7 @@ target_link_libraries(OTBSupervised ${OTBLibSVM_LIBRARIES} ${OTBOpenCV_LIBRARIES} ${OTBShark_LIBRARIES} + ${OTBLearningBase_LIBRARIES} ) otb_module_target(OTBSupervised) -- GitLab From c260e65edc8edfdca5106500308f883c75fb10c9 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 12 Dec 2017 19:01:38 +0100 Subject: [PATCH 138/567] ENH: simplify parameters for SOM training --- .../otbDimensionalityReductionTrainSOM.txx | 124 ++++++++---------- 1 file changed, 56 insertions(+), 68 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx index 17067cc4bd..51cdd9e1ac 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainSOM.txx @@ -34,62 +34,47 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> { AddChoice("algorithm.som", "OTB SOM"); SetParameterDescription("algorithm.som", - "This group of parameters allows setting SOM parameters. " - ); - - AddParameter(ParameterType_Int, "algorithm.som.dim","Dimension of the map"); - SetParameterDescription("algorithm.som.dim","Dimension of the SOM map."); - - AddParameter(ParameterType_StringList , "algorithm.som.s", "Size"); - SetParameterDescription("algorithm.som.s", "Size of the SOM map"); - MandatoryOff("algorithm.som.s"); - - AddParameter(ParameterType_StringList , "algorithm.som.n", "Size Neighborhood"); - SetParameterDescription("algorithm.som.n", "Size of the initial neighborhood in the SOM map"); - MandatoryOff("algorithm.som.n"); - - AddParameter(ParameterType_Int, "algorithm.som.sx", "SizeX"); - SetParameterDescription("algorithm.som.sx", "X size of the SOM map"); - MandatoryOff("algorithm.som.sx"); - - AddParameter(ParameterType_Int, "algorithm.som.sy", "SizeY"); - SetParameterDescription("algorithm.som.sy", "Y size of the SOM map"); - MandatoryOff("algorithm.som.sy"); - - AddParameter(ParameterType_Int, "algorithm.som.nx", "NeighborhoodX"); - SetParameterDescription("algorithm.som.nx", "X size of the initial neighborhood in the SOM map"); - MandatoryOff("algorithm.som.nx"); - - AddParameter(ParameterType_Int, "algorithm.som.ny", "NeighborhoodY"); - SetParameterDescription("algorithm.som.ny", "Y size of the initial neighborhood in the SOM map"); - MandatoryOff("algorithm.som.nx"); - - AddParameter(ParameterType_Int, "algorithm.som.ni", "NumberIteration"); - SetParameterDescription("algorithm.som.ni", "Number of iterations for SOM learning"); - MandatoryOff("algorithm.som.ni"); - - AddParameter(ParameterType_Float, "algorithm.som.bi", "BetaInit"); - SetParameterDescription("algorithm.som.bi", "Initial learning coefficient"); - MandatoryOff("algorithm.som.bi"); - - AddParameter(ParameterType_Float, "algorithm.som.bf", "BetaFinal"); - SetParameterDescription("algorithm.som.bf", "Final learning coefficient"); - MandatoryOff("algorithm.som.bf"); - - AddParameter(ParameterType_Float, "algorithm.som.iv", "InitialValue"); - SetParameterDescription("algorithm.som.iv", "Maximum initial neuron weight"); - MandatoryOff("algorithm.som.iv"); - - SetDefaultParameterInt("algorithm.som.sx", 32); - SetDefaultParameterInt("algorithm.som.sy", 32); - SetDefaultParameterInt("algorithm.som.nx", 10); - SetDefaultParameterInt("algorithm.som.ny", 10); - SetDefaultParameterInt("algorithm.som.ni", 5); - SetDefaultParameterFloat("algorithm.som.bi", 1.0); - SetDefaultParameterFloat("algorithm.som.bf", 0.1); - SetDefaultParameterFloat("algorithm.som.iv", 10.0); - - + "This group of parameters allows setting SOM parameters. "); + + AddParameter(ParameterType_StringList , "algorithm.som.s", "Map size"); + SetParameterDescription("algorithm.som.s", "Sizes of the SOM map (one per " + "dimension). For instance, [12;15] means a 2D map of size 12x15. Support" + "2D to 5D maps."); + MandatoryOff("algorithm.som.s"); + + AddParameter(ParameterType_StringList , "algorithm.som.n", "Neighborhood sizes"); + SetParameterDescription("algorithm.som.n", "Sizes of the initial neighborhood " + "in the SOM map (one per dimension). The number of sizes should be the same" + " as the map sizes"); + MandatoryOff("algorithm.som.n"); + + AddParameter(ParameterType_Int, "algorithm.som.ni", "NumberIteration"); + SetParameterDescription("algorithm.som.ni", "Number of iterations for SOM learning"); + MandatoryOff("algorithm.som.ni"); + + AddParameter(ParameterType_Float, "algorithm.som.bi", "BetaInit"); + SetParameterDescription("algorithm.som.bi", "Initial learning coefficient"); + MandatoryOff("algorithm.som.bi"); + + AddParameter(ParameterType_Float, "algorithm.som.bf", "BetaFinal"); + SetParameterDescription("algorithm.som.bf", "Final learning coefficient"); + MandatoryOff("algorithm.som.bf"); + + AddParameter(ParameterType_Float, "algorithm.som.iv", "InitialValue"); + SetParameterDescription("algorithm.som.iv", "Maximum initial neuron weight"); + MandatoryOff("algorithm.som.iv"); + + std::vector<std::string> size(2, std::string("10")); + std::vector<std::string> radius(2, std::string("3")); + SetParameterStringList("algorithm.som.s", size, false); + SetParameterStringList("algorithm.som.n", radius, false); + DisableParameter("algorithm.som.s"); + DisableParameter("algorithm.som.n"); + + SetDefaultParameterInt("algorithm.som.ni", 5); + SetDefaultParameterFloat("algorithm.som.bi", 1.0); + SetDefaultParameterFloat("algorithm.som.bf", 0.1); + SetDefaultParameterFloat("algorithm.som.iv", 10.0); } template <class TInputValue, class TOutputValue> @@ -98,8 +83,8 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath) { - int SomDim = GetParameterInt("algorithm.som.dim"); - std::cout << SomDim << std::endl; + std::vector<std::string> s = GetParameterStringList("algorithm.som.s"); + int SomDim = s.size(); if(SomDim == 2) { @@ -123,10 +108,11 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> { typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; TrainSOM<SOM5DModelType >(trainingListSample,modelPath); - } + } if(SomDim > 5 || SomDim < 2) { - std::cerr << "k : invalid dimension" << std::endl; + otbAppLogFATAL(<< "Invalid number of dimensions : " << SomDim << + ". Only support 2, 3, 4 or 5 dimensions"); } } @@ -136,26 +122,28 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::TrainSOM(typename ListSampleType::Pointer trainingListSample,std::string modelPath) { typename TSOM::Pointer dimredTrainer = TSOM::New(); - unsigned int dim = dimredTrainer->GetDimension(); - std::cout << dim << std::endl; dimredTrainer->SetNumberOfIterations(GetParameterInt("algorithm.som.ni")); dimredTrainer->SetBetaInit(GetParameterFloat("algorithm.som.bi")); dimredTrainer->SetWriteMap(true); dimredTrainer->SetBetaEnd(GetParameterFloat("algorithm.som.bf")); dimredTrainer->SetMaxWeight(GetParameterFloat("algorithm.som.iv")); typename TSOM::SizeType size; - std::vector<std::basic_string<char>> s= GetParameterStringList("algorithm.som.s"); - for (unsigned int i=0; i<dim; i++) + std::vector<std::string> s = GetParameterStringList("algorithm.som.s"); + for (unsigned int i=0; i<s.size(); i++) { - size[i]=std::stoi(s[i]); + size[i]=boost::lexical_cast<unsigned int>(s[i]); } dimredTrainer->SetMapSize(size); typename TSOM::SizeType radius; - std::vector<std::basic_string<char>> n= GetParameterStringList("algorithm.som.n"); - for (unsigned int i=0; i<dim; i++) + std::vector<std::string> n = GetParameterStringList("algorithm.som.n"); + if (n.size() != s.size()) + { + otbAppLogFATAL(<< "Wrong number of neighborhood radii : expected "<< s.size() << " ; got "<< n.size()); + } + for (unsigned int i=0; i < n.size(); i++) { - radius[i]=std::stoi(n[i]); + radius[i]=boost::lexical_cast<unsigned int>(n[i]); } dimredTrainer->SetNeighborhoodSizeInit(radius); dimredTrainer->SetInputListSample(trainingListSample); -- GitLab From 8d5a1617206a2949c1947ef3ed3da1b6c1d75bd8 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 12 Dec 2017 19:01:52 +0100 Subject: [PATCH 139/567] REFAC: with utilisation of ClampImageFilter no need for macro and specialization --- .../include/otbWrapperInputImageParameter.h | 12 +++++++---- .../include/otbWrapperInputImageParameter.txx | 21 ++++++++++++++++++- .../otbWrapperInputImageParameterCDouble.cxx | 5 +++-- .../otbWrapperInputImageParameterCFloat.cxx | 4 +++- .../otbWrapperInputImageParameterDouble.cxx | 2 ++ .../otbWrapperInputImageParameterFloat.cxx | 2 ++ .../otbWrapperInputImageParameterInt16.cxx | 2 ++ .../otbWrapperInputImageParameterInt32.cxx | 2 ++ .../src/otbWrapperInputImageParameterMacros.h | 4 ++-- .../otbWrapperInputImageParameterUInt16.cxx | 2 ++ .../otbWrapperInputImageParameterUInt32.cxx | 2 ++ .../otbWrapperInputImageParameterUInt8.cxx | 2 ++ 12 files changed, 50 insertions(+), 10 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h index 99352d4292..d51438cf16 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h @@ -176,7 +176,7 @@ private: // template specializations of CastImage<> should be declared in header // so that the linker knows they exist when building OTB Applications - +/* #define otbDeclareCastImageMacro(InputImageType, OutputImageType) \ template<> OTBApplicationEngine_EXPORT OutputImageType * \ InputImageParameter::CastImage<InputImageType , OutputImageType>(); \ @@ -189,11 +189,12 @@ private: otbDeclareCastImageMacro(InputImageType, Int32##prefix##ImageType) \ otbDeclareCastImageMacro(InputImageType, Float##prefix##ImageType) \ otbDeclareCastImageMacro(InputImageType, Double##prefix##ImageType) - +*/ /********************************************************************* ********************** Image -> Image **********************************************************************/ +/* otbGenericDeclareCastImageMacro(UInt8ImageType, ) otbGenericDeclareCastImageMacro(Int16ImageType, ) otbGenericDeclareCastImageMacro(UInt16ImageType, ) @@ -207,10 +208,12 @@ otbDeclareCastImageMacro( ComplexDoubleImageType , ComplexFloatImageType ) otbDeclareCastImageMacro( ComplexFloatImageType , ComplexDoubleImageType ) otbDeclareCastImageMacro( ComplexFloatImageType , ComplexFloatImageType ) +*/ /********************************************************************* ********************** VectorImage -> VectorImage **********************************************************************/ +/* otbGenericDeclareCastImageMacro(UInt8VectorImageType, Vector) otbGenericDeclareCastImageMacro(Int16VectorImageType, Vector) otbGenericDeclareCastImageMacro(UInt16VectorImageType, Vector) @@ -228,10 +231,11 @@ otbDeclareCastImageMacro( ComplexFloatVectorImageType , ComplexDoubleVectorImageType ) otbDeclareCastImageMacro( ComplexFloatVectorImageType , ComplexFloatVectorImageType ) - +*/ /********************************************************************* ********************** Image -> VectorImage **********************************************************************/ +/* otbGenericDeclareCastImageMacro(UInt8ImageType, Vector) otbGenericDeclareCastImageMacro(Int16ImageType, Vector) otbGenericDeclareCastImageMacro(UInt16ImageType, Vector) @@ -251,7 +255,7 @@ otbDeclareCastImageMacro( ComplexFloatImageType , ComplexFloatVectorImageType ) #undef otbDeclareCastImageMacro #undef otbGenericDeclareCastImageMacro - +*/ } // End namespace Wrapper } // End namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx index 791f77cdb3..b2371466a5 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx @@ -208,7 +208,26 @@ template <class TInputImage, class TOutputImage> TOutputImage* InputImageParameter::CastImage() { - itkExceptionMacro("Cast from "<<typeid(TInputImage).name()<<" to "<<typeid(TOutputImage).name()<<" not authorized."); + if ( dynamic_cast<TOutputImage*> (m_Image.GetPointer()) ) + { + return dynamic_cast<TOutputImage*> (m_Image.GetPointer()); + } + else + { + TInputImage* realInputImage = dynamic_cast<TInputImage*>(m_Image.GetPointer()); + + typedef ClampImageFilter<TInputImage, TOutputImage> CasterType; + typename CasterType::Pointer caster = CasterType::New(); + + caster->SetInput(realInputImage); + caster->UpdateOutputInformation(); + + m_Image = caster->GetOutput(); + m_Caster = caster; + + return caster->GetOutput(); + } + // itkExceptionMacro("Cast from "<<typeid(TInputImage).name()<<" to "<<typeid(TOutputImage).name()<<" not authorized."); } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx index 6dbcc03406..16ba940791 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx @@ -28,8 +28,9 @@ namespace otb { namespace Wrapper { -otbGetImageMacro(ComplexDoubleImage) +otbGetImageMacro(ComplexDoubleImage); otbGetImageMacro(ComplexDoubleVectorImage) +/* // otbGenericCastImageMacro(ComplexDoubleImage, SimpleCastImage, ) otbCastImageMacro(ComplexDoubleImageType , ComplexDoubleImageType , SimpleCastImage) otbCastImageMacro(ComplexDoubleImageType , ComplexFloatImageType , SimpleCastImage) @@ -39,6 +40,6 @@ otbCastImageMacro(ComplexDoubleVectorImageType , ComplexFloatVectorImageType , S // otbGenericCastImageMacro(ComplexDoubleImage, CastVectorImageFromImage, Vector) otbCastImageMacro(ComplexDoubleImageType , ComplexDoubleVectorImageType , CastVectorImageFromImage) otbCastImageMacro(ComplexDoubleImageType , ComplexFloatVectorImageType , CastVectorImageFromImage) - +*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx index c961fbd252..8974f25454 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx @@ -28,8 +28,9 @@ namespace otb { namespace Wrapper { -otbGetImageMacro(ComplexFloatImage) +otbGetImageMacro(ComplexFloatImage); otbGetImageMacro(ComplexFloatVectorImage) +/* // otbGenericCastImageMacro(ComplexFloatImage, SimpleCastImage, ) otbCastImageMacro(ComplexFloatImageType , ComplexDoubleImageType , SimpleCastImage) otbCastImageMacro(ComplexFloatImageType , ComplexFloatImageType , SimpleCastImage) @@ -39,5 +40,6 @@ otbCastImageMacro(ComplexFloatVectorImageType , ComplexFloatVectorImageType , Si // otbGenericCastImageMacro(ComplexFloatImage, CastVectorImageFromImage, Vector) otbCastImageMacro(ComplexFloatImageType , ComplexDoubleVectorImageType , CastVectorImageFromImage) otbCastImageMacro(ComplexFloatImageType , ComplexFloatVectorImageType , CastVectorImageFromImage) +*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx index e6a07bc294..8e58335607 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx @@ -30,8 +30,10 @@ namespace Wrapper { otbGetImageMacro(DoubleImage); otbGetImageMacro(DoubleVectorImage) +/* otbGenericCastImageMacro(DoubleImageType, SimpleCastImage, ) otbGenericCastImageMacro(DoubleVectorImageType, SimpleCastImage, Vector) otbGenericCastImageMacro(DoubleImageType, CastVectorImageFromImage, Vector) +*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx index fda1544048..877004c19a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx @@ -30,8 +30,10 @@ namespace Wrapper { otbGetImageMacro(FloatImage); otbGetImageMacro(FloatVectorImage) +/* otbGenericCastImageMacro(FloatImageType, SimpleCastImage, ) otbGenericCastImageMacro(FloatVectorImageType, SimpleCastImage, Vector) otbGenericCastImageMacro(FloatImageType, CastVectorImageFromImage, Vector) +*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx index 22f617fce4..4cd42dc166 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx @@ -30,8 +30,10 @@ namespace Wrapper { otbGetImageMacro(Int16Image); otbGetImageMacro(Int16VectorImage) +/* otbGenericCastImageMacro(Int16ImageType, SimpleCastImage, ) otbGenericCastImageMacro(Int16VectorImageType, SimpleCastImage, Vector) otbGenericCastImageMacro(Int16ImageType, CastVectorImageFromImage, Vector) +*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx index ab59107c9e..460453a88e 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx @@ -30,8 +30,10 @@ namespace Wrapper { otbGetImageMacro(Int32Image); otbGetImageMacro(Int32VectorImage) +/* otbGenericCastImageMacro(Int32ImageType, SimpleCastImage, ) otbGenericCastImageMacro(Int32VectorImageType, SimpleCastImage, Vector) otbGenericCastImageMacro(Int32ImageType, CastVectorImageFromImage, Vector) +*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterMacros.h b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterMacros.h index 4cc9d4d7ae..42f88dfbea 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterMacros.h +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterMacros.h @@ -28,7 +28,7 @@ return this->GetImage< image##Type > (); \ } - +/* #define otbCastImageMacro(InputImageType, OutputImageType, theMethod) \ template<> OutputImageType * \ InputImageParameter::CastImage<InputImageType , OutputImageType>() \ @@ -44,6 +44,6 @@ otbCastImageMacro(InputImageType, Int32##prefix##ImageType, theMethod) \ otbCastImageMacro(InputImageType, Float##prefix##ImageType, theMethod) \ otbCastImageMacro(InputImageType, Double##prefix##ImageType, theMethod) - +*/ #endif diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx index c63857e57b..b509e6a74a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx @@ -30,8 +30,10 @@ namespace Wrapper { otbGetImageMacro(UInt16Image); otbGetImageMacro(UInt16VectorImage) +/* otbGenericCastImageMacro(UInt16ImageType, SimpleCastImage, ) otbGenericCastImageMacro(UInt16VectorImageType, SimpleCastImage, Vector) otbGenericCastImageMacro(UInt16ImageType, CastVectorImageFromImage, Vector) +*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx index 50fdf0adf1..5b22c458f1 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx @@ -30,8 +30,10 @@ namespace Wrapper { otbGetImageMacro(UInt32Image); otbGetImageMacro(UInt32VectorImage) +/* otbGenericCastImageMacro(UInt32ImageType, SimpleCastImage, ) otbGenericCastImageMacro(UInt32VectorImageType, SimpleCastImage, Vector) otbGenericCastImageMacro(UInt32ImageType, CastVectorImageFromImage, Vector) +*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx index d388456e42..01bb1af83c 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx @@ -30,8 +30,10 @@ namespace Wrapper { otbGetImageMacro(UInt8Image); otbGetImageMacro(UInt8VectorImage) +/* otbGenericCastImageMacro(UInt8ImageType, SimpleCastImage, ) otbGenericCastImageMacro(UInt8VectorImageType, SimpleCastImage, Vector) otbGenericCastImageMacro(UInt8ImageType, CastVectorImageFromImage, Vector) +*/ } } -- GitLab From 1b3c41fa427e0af39aa121a33ad4c47f4f1e81aa Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 12 Dec 2017 19:11:45 +0100 Subject: [PATCH 140/567] REFAC: Change signature and function SwitchImageWrite, factoring and easier to read --- .../src/otbWrapperOutputImageParameter.cxx | 66 +++++++------------ 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index eed6e99d42..57d29cf633 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -170,9 +170,11 @@ void ClampAndWriteImage( itk::ImageBase<2> * in , otb::ImageFileWriter<TOutput> * writer , const std::string & filename , - const unsigned int & ramValue , - typename itk::ImageToImageFilter< TInput , TOutput > * clampFilter ) + const unsigned int & ramValue ) { + typedef ClampImageFilter < TInput , TOutput > ClampFilterType; + typename ClampFilterType::Pointer clampFilter ( ClampFilterType::New() ); + clampFilter->SetInput( dynamic_cast<TInput*>(in)); bool useStandardWriter = true; @@ -297,8 +299,7 @@ OutputImageParameter::SwitchImageWrite() m_Image , m_UInt8Writer , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , UInt8ImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_int16: @@ -307,8 +308,7 @@ OutputImageParameter::SwitchImageWrite() m_Image , m_Int16Writer , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , Int16ImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_uint16: @@ -317,8 +317,7 @@ OutputImageParameter::SwitchImageWrite() m_Image , m_UInt16Writer , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , UInt16ImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_int32: @@ -327,8 +326,7 @@ OutputImageParameter::SwitchImageWrite() m_Image , m_Int32Writer , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , Int32ImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_uint32: @@ -337,8 +335,7 @@ OutputImageParameter::SwitchImageWrite() m_Image , m_UInt32Writer , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , UInt32ImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_float: @@ -347,8 +344,7 @@ OutputImageParameter::SwitchImageWrite() m_Image , m_FloatWriter , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , FloatImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_double: @@ -357,8 +353,7 @@ OutputImageParameter::SwitchImageWrite() m_Image , m_DoubleWriter , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , DoubleImageType >::New() ); + m_RAMValue ); break; } default: @@ -378,8 +373,7 @@ OutputImageParameter::SwitchCImageWrite() m_Image , m_ComplexFloatWriter , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , ComplexFloatImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_cdouble: @@ -388,8 +382,7 @@ OutputImageParameter::SwitchCImageWrite() m_Image , m_ComplexDoubleWriter , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , ComplexDoubleImageType >::New() ); + m_RAMValue ); break; } default: @@ -410,8 +403,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_Image , m_VectorUInt8Writer , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , UInt8VectorImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_int16: @@ -420,8 +412,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_Image , m_VectorInt16Writer , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , Int16VectorImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_uint16: @@ -430,8 +421,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_Image , m_VectorUInt16Writer , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , UInt16VectorImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_int32: @@ -440,8 +430,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_Image , m_VectorInt32Writer , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , Int32VectorImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_uint32: @@ -450,8 +439,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_Image , m_VectorUInt32Writer , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , UInt32VectorImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_float: @@ -460,8 +448,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_Image , m_VectorFloatWriter , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , FloatVectorImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_double: @@ -470,8 +457,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_Image , m_VectorDoubleWriter , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , DoubleVectorImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_cfloat: @@ -480,8 +466,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_Image , m_ComplexVectorFloatWriter , m_FileName , - m_RAMValue , - otb::ClampImageFilter < TInput , ComplexFloatVectorImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_cdouble: @@ -490,8 +475,7 @@ OutputImageParameter::SwitchVectorImageWrite() m_Image , m_ComplexVectorDoubleWriter , m_FileName , - m_RAMValue , - otb::ClampImageFilter < TInput , ComplexDoubleVectorImageType >::New() ); + m_RAMValue ); break; } default: @@ -511,8 +495,7 @@ OutputImageParameter::SwitchVectorCImageWrite() m_Image , m_ComplexVectorFloatWriter , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , ComplexFloatVectorImageType >::New() ); + m_RAMValue ); break; } case ImagePixelType_cdouble: @@ -521,8 +504,7 @@ OutputImageParameter::SwitchVectorCImageWrite() m_Image , m_ComplexVectorDoubleWriter , m_FileName , - m_RAMValue , - otb::ClampImageFilter< TInput , ComplexDoubleVectorImageType >::New() ); + m_RAMValue ); break; } default: -- GitLab From a9d899cfdc643fb3f9ea72a53553f21dfc359520 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 13 Dec 2017 10:45:02 +0100 Subject: [PATCH 141/567] REFAC: get rid of unnecessary templatespecialization --- .../include/otbDefaultConvertNewImpl.h | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h b/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h index 4ffd0d6099..60bd0726ad 100644 --- a/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h +++ b/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h @@ -49,33 +49,35 @@ public: // We might not need this specialization if the compileur allow // us to declare to function with same signature in some case : // see "SetNthComponent" +/* #define OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \ template< > \ - class DefaultConvertPixelTraitsTest < type > \ + class DefaultConvertPixelTraitsTest < type > \ : public itk::DefaultConvertPixelTraits < type > \ { \ public: \ typedef itk::DefaultConvertPixelTraits < type > SuperClass; \ using typename SuperClass::ComponentType; \ }; - -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(float) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(double) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long double) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(int) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(char) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(short) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned int) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(signed char) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned char) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned short) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long long) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long long) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(bool) - -#undef OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL +*/ +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(float) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(double) +// Warning long double is not in itk < 4.11 +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long double) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(int) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(char) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(short) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned int) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(signed char) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned char) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned short) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long long) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long long) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(bool) + +// #undef OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL // // Default traits for the Offset<> pixel type -- GitLab From 7708683f0baf53fcb349209a9119bc941b63d6fe Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 13 Dec 2017 10:46:50 +0100 Subject: [PATCH 142/567] REFAC: get rid of switchimagewrite for complex pixel --- .../include/otbWrapperOutputImageParameter.h | 8 +- .../src/otbWrapperOutputImageParameter.cxx | 104 ++++++++++-------- 2 files changed, 65 insertions(+), 47 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index 7bcb5fdb33..c2b0727240 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -122,14 +122,14 @@ protected: template <class TInputImageType> void SwitchImageWrite(); - template <class TInputImageType> - void SwitchCImageWrite(); + // template <class TInputImageType> + // void SwitchCImageWrite(); template <class TInputVectorImageType> void SwitchVectorImageWrite(); - template <class TInputVectorImageType> - void SwitchVectorCImageWrite(); + // template <class TInputVectorImageType> + // void SwitchVectorCImageWrite(); template <class TInputVectorImageType> void SwitchRGBImageWrite(); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 57d29cf633..07cb49864b 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -356,17 +356,6 @@ OutputImageParameter::SwitchImageWrite() m_RAMValue ); break; } - default: - break; - } -} - -template <class TInput> -void -OutputImageParameter::SwitchCImageWrite() -{ - switch(m_PixelType ) - { case ImagePixelType_cfloat: { ClampAndWriteImage< TInput , ComplexFloatImageType >( @@ -390,6 +379,35 @@ OutputImageParameter::SwitchCImageWrite() } } +// template <class TInput> +// void +// OutputImageParameter::SwitchCImageWrite() +// { +// switch(m_PixelType ) +// { +// case ImagePixelType_cfloat: +// { +// ClampAndWriteImage< TInput , ComplexFloatImageType >( +// m_Image , +// m_ComplexFloatWriter , +// m_FileName , +// m_RAMValue ); +// break; +// } +// case ImagePixelType_cdouble: +// { +// ClampAndWriteImage< TInput , ComplexDoubleImageType >( +// m_Image , +// m_ComplexDoubleWriter , +// m_FileName , +// m_RAMValue ); +// break; +// } +// default: +// break; +// } +// } + template <class TInput> void @@ -483,34 +501,34 @@ OutputImageParameter::SwitchVectorImageWrite() } } -template <class TInput> -void -OutputImageParameter::SwitchVectorCImageWrite() -{ - switch(m_PixelType ) - { - case ImagePixelType_cfloat: - { - ClampAndWriteImage< TInput , ComplexFloatVectorImageType >( - m_Image , - m_ComplexVectorFloatWriter , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_cdouble: - { - ClampAndWriteImage< TInput , ComplexDoubleVectorImageType >( - m_Image , - m_ComplexVectorDoubleWriter , - m_FileName , - m_RAMValue ); - break; - } - default: - break; - } -} +// template <class TInput> +// void +// OutputImageParameter::SwitchVectorCImageWrite() +// { +// switch(m_PixelType ) +// { +// case ImagePixelType_cfloat: +// { +// ClampAndWriteImage< TInput , ComplexFloatVectorImageType >( +// m_Image , +// m_ComplexVectorFloatWriter , +// m_FileName , +// m_RAMValue ); +// break; +// } +// case ImagePixelType_cdouble: +// { +// ClampAndWriteImage< TInput , ComplexDoubleVectorImageType >( +// m_Image , +// m_ComplexVectorDoubleWriter , +// m_FileName , +// m_RAMValue ); +// break; +// } +// default: +// break; +// } +// } template <class TInputRGBAImageType> void @@ -577,11 +595,11 @@ OutputImageParameter::Write() } else if (dynamic_cast<ComplexFloatImageType*>(m_Image.GetPointer()) ) { - SwitchCImageWrite<ComplexFloatImageType>(); + SwitchImageWrite<ComplexFloatImageType>(); } else if (dynamic_cast<ComplexDoubleImageType*>(m_Image.GetPointer()) ) { - SwitchCImageWrite<ComplexDoubleImageType>(); + SwitchImageWrite<ComplexDoubleImageType>(); } else if (dynamic_cast<UInt8VectorImageType*>(m_Image.GetPointer())) { @@ -621,11 +639,11 @@ OutputImageParameter::Write() } else if (dynamic_cast<ComplexFloatVectorImageType*>(m_Image.GetPointer())) { - SwitchVectorCImageWrite<ComplexFloatVectorImageType>(); + SwitchVectorImageWrite<ComplexFloatVectorImageType>(); } else if (dynamic_cast<ComplexDoubleVectorImageType*>(m_Image.GetPointer())) { - SwitchVectorCImageWrite<ComplexDoubleVectorImageType>(); + SwitchVectorImageWrite<ComplexDoubleVectorImageType>(); } else { -- GitLab From 5af3ea2df29ee4ab9986b82d7e9a745dc7889b6f Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 13 Dec 2017 11:33:41 +0100 Subject: [PATCH 143/567] COMP: otbSharkUtils.h should be either in OTBShark or in an adapter module --- Modules/Learning/LearningBase/otb-module.cmake | 7 +------ Modules/Learning/LearningBase/src/CMakeLists.txt | 1 + .../Shark}/include/otbSharkUtils.h | 0 3 files changed, 2 insertions(+), 6 deletions(-) rename Modules/{Learning/LearningBase => ThirdParty/Shark}/include/otbSharkUtils.h (100%) diff --git a/Modules/Learning/LearningBase/otb-module.cmake b/Modules/Learning/LearningBase/otb-module.cmake index 5d45c1c962..afa2a339a1 100644 --- a/Modules/Learning/LearningBase/otb-module.cmake +++ b/Modules/Learning/LearningBase/otb-module.cmake @@ -25,17 +25,12 @@ otb_module(OTBLearningBase ENABLE_SHARED DEPENDS OTBCommon - OTBITK - OTBImageIO OTBImageBase - - OPTIONAL_DEPENDS - OTBShark + OTBITK TEST_DEPENDS OTBTestKernel OTBImageIO - OTBImageBase DESCRIPTION "${DOCUMENTATION}" diff --git a/Modules/Learning/LearningBase/src/CMakeLists.txt b/Modules/Learning/LearningBase/src/CMakeLists.txt index 9e7a49db7f..4a7ef1c0d2 100644 --- a/Modules/Learning/LearningBase/src/CMakeLists.txt +++ b/Modules/Learning/LearningBase/src/CMakeLists.txt @@ -25,6 +25,7 @@ set(OTBLearningBase_SRC add_library(OTBLearningBase ${OTBLearningBase_SRC}) target_link_libraries(OTBLearningBase ${OTBCommon_LIBRARIES} + ${OTBImageBase_LIBRARIES} ${OTBITK_LIBRARIES} ) diff --git a/Modules/Learning/LearningBase/include/otbSharkUtils.h b/Modules/ThirdParty/Shark/include/otbSharkUtils.h similarity index 100% rename from Modules/Learning/LearningBase/include/otbSharkUtils.h rename to Modules/ThirdParty/Shark/include/otbSharkUtils.h -- GitLab From 735aec7562e90a0d9a9a80b410318a03f84b9b92 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 13 Dec 2017 11:42:10 +0100 Subject: [PATCH 144/567] COMP: unused includes --- .../DimensionalityReductionLearning/include/otbSOMModel.txx | 2 -- 1 file changed, 2 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx index bb9df24a6c..e1d7dc3fc6 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.txx @@ -22,8 +22,6 @@ #include "otbSOMModel.h" #include "otbSOM.h" -#include "otbImageFileReader.h" -#include "otbImageFileWriter.h" #include "itkMacro.h" #include "itkImageRegionIterator.h" -- GitLab From 1767c40011d67aa9bff37ce22d32aa2dee86f5b2 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 13 Dec 2017 12:05:05 +0100 Subject: [PATCH 145/567] ENH: add cint16 and cint32 pixel type + REFAX :InputParameterType.h and macros --- .../include/otbWrapperInputImageParameter.h | 10 +++- .../include/otbWrapperInputImageParameter.txx | 36 +++++++++---- .../include/otbWrapperTypes.h | 12 ++++- .../ApplicationEngine/src/CMakeLists.txt | 19 +++---- .../src/otbWrapperInputImageParameterMacros.h | 5 ++ .../src/otbWrapperInputImageParameterType.cxx | 52 +++++++++++++++++++ 6 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterType.cxx diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h index d51438cf16..2a36842218 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h @@ -80,10 +80,14 @@ public: UInt8RGBImageType* GetUInt8RGBImage(); UInt8RGBAImageType* GetUInt8RGBAImage(); - // Complex image + // Complex image + ComplexInt16ImageType* GetComplexInt16Image(); + ComplexInt32ImageType* GetComplexInt32Image(); ComplexFloatImageType* GetComplexFloatImage(); ComplexDoubleImageType* GetComplexDoubleImage(); + ComplexInt16VectorImageType* GetComplexInt16VectorImage(); + ComplexInt32VectorImageType* GetComplexInt32VectorImage(); ComplexFloatVectorImageType* GetComplexFloatVectorImage(); ComplexDoubleVectorImageType* GetComplexDoubleVectorImage(); @@ -152,9 +156,13 @@ protected: typedef otb::ImageFileReader<UInt8RGBAImageType> UInt8RGBAReaderType; // Complex + typedef otb::ImageFileReader<ComplexInt16ImageType> ComplexInt16ReaderType; + typedef otb::ImageFileReader<ComplexInt32ImageType> ComplexInt32ReaderType; typedef otb::ImageFileReader<ComplexFloatImageType> ComplexFloatReaderType; typedef otb::ImageFileReader<ComplexDoubleImageType> ComplexDoubleReaderType; + typedef otb::ImageFileReader<ComplexInt16VectorImageType> ComplexInt16VectorReaderType; + typedef otb::ImageFileReader<ComplexInt32VectorImageType> ComplexInt32VectorReaderType; typedef otb::ImageFileReader<ComplexFloatVectorImageType> ComplexFloatVectorReaderType; typedef otb::ImageFileReader<ComplexDoubleVectorImageType> ComplexDoubleVectorReaderType; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx index b2371466a5..0ead9125d1 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx @@ -24,8 +24,8 @@ #include "otbWrapperInputImageParameter.h" #include "itkUnaryFunctorImageFilter.h" -#include "itkCastImageFilter.h" -#include "otbImageToVectorImageCastFilter.h" +// #include "itkCastImageFilter.h" +// #include "otbImageToVectorImageCastFilter.h" #include "otbClampImageFilter.h" namespace otb @@ -139,6 +139,22 @@ InputImageParameter::GetImage() { return CastImage<DoubleImageType, TImageType> (); } + else if (dynamic_cast<ComplexInt16ImageType*>(m_Image.GetPointer())) + { + return CastImage<ComplexInt16ImageType, TImageType>(); + } + else if (dynamic_cast<ComplexInt32ImageType*>(m_Image.GetPointer())) + { + return CastImage<ComplexInt32ImageType, TImageType>(); + } + else if (dynamic_cast<ComplexFloatImageType*>(m_Image.GetPointer())) + { + return CastImage<ComplexFloatImageType, TImageType>(); + } + else if (dynamic_cast<ComplexDoubleImageType*>(m_Image.GetPointer())) + { + return CastImage<ComplexDoubleImageType, TImageType>(); + } else if (dynamic_cast<UInt8VectorImageType*> (m_Image.GetPointer())) { return CastImage<UInt8VectorImageType, TImageType> (); @@ -175,21 +191,21 @@ InputImageParameter::GetImage() { return CastImage<UInt8RGBImageType, TImageType> (); } - else if (dynamic_cast<ComplexFloatVectorImageType*>(m_Image.GetPointer())) + else if (dynamic_cast<ComplexInt16VectorImageType*>(m_Image.GetPointer())) { - return CastImage<ComplexFloatVectorImageType, TImageType>(); + return CastImage<ComplexInt16VectorImageType, TImageType>(); } - else if (dynamic_cast<ComplexDoubleVectorImageType*>(m_Image.GetPointer())) + else if (dynamic_cast<ComplexInt32VectorImageType*>(m_Image.GetPointer())) { - return CastImage<ComplexDoubleVectorImageType, TImageType>(); + return CastImage<ComplexInt32VectorImageType, TImageType>(); } - else if (dynamic_cast<ComplexFloatImageType*>(m_Image.GetPointer())) + else if (dynamic_cast<ComplexFloatVectorImageType*>(m_Image.GetPointer())) { - return CastImage<ComplexFloatImageType, TImageType>(); + return CastImage<ComplexFloatVectorImageType, TImageType>(); } - else if (dynamic_cast<ComplexDoubleImageType*>(m_Image.GetPointer())) + else if (dynamic_cast<ComplexDoubleVectorImageType*>(m_Image.GetPointer())) { - return CastImage<ComplexDoubleImageType, TImageType>(); + return CastImage<ComplexDoubleVectorImageType, TImageType>(); } else { diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h index f78fb1f7e0..8a31e1f2c4 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h @@ -77,12 +77,16 @@ typedef enum ImagePixelType_uint32, ImagePixelType_float, ImagePixelType_double, + ImagePixelType_cint16, + ImagePixelType_cint32, ImagePixelType_cfloat, ImagePixelType_cdouble, } ImagePixelType; typedef enum { + ComplexImagePixelType_int16, + ComplexImagePixelType_int32, ComplexImagePixelType_float, ComplexImagePixelType_double, } ComplexImagePixelType; @@ -121,13 +125,19 @@ typedef otb::VectorImage<double> DoubleVectorImageType; typedef otb::Image< itk::RGBPixel<unsigned char> > UInt8RGBImageType; typedef otb::Image< itk::RGBAPixel<unsigned char> > UInt8RGBAImageType; +typedef std::complex<short> Int16ComplexPixelType; +typedef std::complex<int> Int32ComplexPixelType; typedef std::complex<float> FloatComplexPixelType; typedef std::complex<double> DoubleComplexPixelType; -// Complex Image Type (first : double and float) +// Complex Image Type +typedef otb::Image< Int16ComplexPixelType, 2 > ComplexInt16ImageType; +typedef otb::Image< Int32ComplexPixelType, 2 > ComplexInt32ImageType; typedef otb::Image< FloatComplexPixelType, 2 > ComplexFloatImageType; typedef otb::Image< DoubleComplexPixelType, 2 > ComplexDoubleImageType; +typedef otb::VectorImage< Int16ComplexPixelType, 2 > ComplexInt16VectorImageType; +typedef otb::VectorImage< Int32ComplexPixelType, 2 > ComplexInt32VectorImageType; typedef otb::VectorImage<FloatComplexPixelType, 2 > ComplexFloatVectorImageType; typedef otb::VectorImage< DoubleComplexPixelType, 2 > ComplexDoubleVectorImageType; diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index cd0be0bd4b..671b314aab 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -31,15 +31,16 @@ set( OTBApplicationEngine_SRC otbWrapperInputFilenameListParameter.cxx otbWrapperOutputImageParameter.cxx otbWrapperInputImageParameter.cxx - otbWrapperInputImageParameterUInt8.cxx - otbWrapperInputImageParameterInt16.cxx - otbWrapperInputImageParameterUInt16.cxx - otbWrapperInputImageParameterInt32.cxx - otbWrapperInputImageParameterUInt32.cxx - otbWrapperInputImageParameterFloat.cxx - otbWrapperInputImageParameterDouble.cxx - otbWrapperInputImageParameterCFloat.cxx - otbWrapperInputImageParameterCDouble.cxx + otbWrapperInputImageParameterType.cxx + #otbWrapperInputImageParameterUInt8.cxx + #otbWrapperInputImageParameterInt16.cxx + #otbWrapperInputImageParameterUInt16.cxx + #otbWrapperInputImageParameterInt32.cxx + #otbWrapperInputImageParameterUInt32.cxx + #otbWrapperInputImageParameterFloat.cxx + #otbWrapperInputImageParameterDouble.cxx + #otbWrapperInputImageParameterCFloat.cxx + #otbWrapperInputImageParameterCDouble.cxx otbWrapperParameterKey.cxx otbWrapperDocExampleStructure.cxx otbWrapperInputVectorDataParameter.cxx diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterMacros.h b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterMacros.h index 42f88dfbea..3f3525af7a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterMacros.h +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterMacros.h @@ -28,6 +28,11 @@ return this->GetImage< image##Type > (); \ } +#define otbGetImageAndVectorImageMacro(type) \ + otbGetImageMacro(type##Image); \ + otbGetImageMacro(type##VectorImage); + + /* #define otbCastImageMacro(InputImageType, OutputImageType, theMethod) \ template<> OutputImageType * \ diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterType.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterType.cxx new file mode 100644 index 0000000000..da88c171dc --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterType.cxx @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "otbWrapperTypes.h" +#include "otbWrapperInputImageParameterMacros.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageAndVectorImageMacro(UInt8); +// otbGetImageMacro(UInt8VectorImage); +otbGetImageAndVectorImageMacro(UInt16); +// otbGetImageMacro(UInt16VectorImage); +otbGetImageAndVectorImageMacro(UInt32); +// otbGetImageMacro(UInt32VectorImage); +otbGetImageAndVectorImageMacro(Int16); +// otbGetImageMacro(Int16VectorImage); +otbGetImageAndVectorImageMacro(Int32); +// otbGetImageMacro(Int32VectorImage); +otbGetImageAndVectorImageMacro(Float); +// otbGetImageMacro(FloatVectorImage); +otbGetImageAndVectorImageMacro(Double); +// otbGetImageMacro(DoubleVectorImage); +otbGetImageAndVectorImageMacro(ComplexInt16); +// otbGetImageMacro(ComplexInt16VectorImage); +otbGetImageAndVectorImageMacro(ComplexInt32); +// otbGetImageMacro(ComplexInt32VectorImage); +otbGetImageAndVectorImageMacro(ComplexFloat); +// otbGetImageMacro(ComplexFloatVectorImage); +otbGetImageAndVectorImageMacro(ComplexDouble); +// otbGetImageMacro(ComplexDoubleVectorImage); +} // end namespace wrapper +} // end namespace otb -- GitLab From f362f2358f21d2f3763ad4d984a552dc59a0a54a Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 13 Dec 2017 12:43:53 +0100 Subject: [PATCH 146/567] ENH: add new pixel types to output image parameter : cint16 and cint32 --- .../include/otbWrapperOutputImageParameter.h | 8 ++ .../src/otbWrapperOutputImageParameter.cxx | 88 +++++++++++++++++++ ...otbWrapperQtWidgetOutputImageParameter.cxx | 2 + 3 files changed, 98 insertions(+) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index c2b0727240..e47f85a230 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -163,9 +163,13 @@ protected: typedef otb::ImageFileWriter<UInt8RGBImageType> RGBUInt8WriterType; // Complex Image + typedef otb::ImageFileWriter<ComplexInt16ImageType> ComplexInt16WriterType; + typedef otb::ImageFileWriter<ComplexInt32ImageType> ComplexInt32WriterType; typedef otb::ImageFileWriter<ComplexFloatImageType> ComplexFloatWriterType; typedef otb::ImageFileWriter<ComplexDoubleImageType> ComplexDoubleWriterType; + typedef otb::ImageFileWriter<ComplexInt16VectorImageType> ComplexVectorInt16WriterType; + typedef otb::ImageFileWriter<ComplexInt32VectorImageType> ComplexVectorInt32WriterType; typedef otb::ImageFileWriter<ComplexFloatVectorImageType> ComplexVectorFloatWriterType; typedef otb::ImageFileWriter<ComplexDoubleVectorImageType> ComplexVectorDoubleWriterType; @@ -189,9 +193,13 @@ protected: RGBUInt8WriterType::Pointer m_RGBUInt8Writer; RGBAUInt8WriterType::Pointer m_RGBAUInt8Writer; + ComplexInt16WriterType::Pointer m_ComplexInt16Writer; + ComplexInt32WriterType::Pointer m_ComplexInt32Writer; ComplexFloatWriterType::Pointer m_ComplexFloatWriter; ComplexDoubleWriterType::Pointer m_ComplexDoubleWriter; + ComplexVectorInt16WriterType::Pointer m_ComplexVectorInt16Writer; + ComplexVectorInt32WriterType::Pointer m_ComplexVectorInt32Writer; ComplexVectorFloatWriterType::Pointer m_ComplexVectorFloatWriter; ComplexVectorDoubleWriterType::Pointer m_ComplexVectorDoubleWriter; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 07cb49864b..2e76ccfcff 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -96,6 +96,16 @@ std::string OutputImageParameter::ConvertPixelTypeToString(ImagePixelType type) ret = "double"; break; } + case ImagePixelType_cint16: + { + ret = "cint16"; + break; + } + case ImagePixelType_cint32: + { + ret = "cint32"; + break; + } case ImagePixelType_cfloat: { ret = "cfloat"; @@ -127,6 +137,10 @@ OutputImageParameter::ConvertStringToPixelType(const std::string &value, ImagePi type = ImagePixelType_float; else if (value == "double") type = ImagePixelType_double; + else if (value == "cint16") + type = ImagePixelType_cint16; + else if (value == "cint32") + type = ImagePixelType_cint32; else if (value == "cfloat") type = ImagePixelType_cfloat; else if (value == "cdouble") @@ -157,9 +171,13 @@ void OutputImageParameter::InitializeWriters() m_RGBUInt8Writer = RGBUInt8WriterType::New(); m_RGBAUInt8Writer = RGBAUInt8WriterType::New(); + m_ComplexInt16Writer = ComplexInt16WriterType::New(); + m_ComplexInt32Writer = ComplexInt32WriterType::New(); m_ComplexFloatWriter = ComplexFloatWriterType::New(); m_ComplexDoubleWriter = ComplexDoubleWriterType::New(); + m_ComplexVectorInt16Writer = ComplexVectorInt16WriterType::New(); + m_ComplexVectorInt32Writer = ComplexVectorInt32WriterType::New(); m_ComplexVectorFloatWriter = ComplexVectorFloatWriterType::New(); m_ComplexVectorDoubleWriter = ComplexVectorDoubleWriterType::New(); } @@ -356,6 +374,24 @@ OutputImageParameter::SwitchImageWrite() m_RAMValue ); break; } + case ImagePixelType_cint16: + { + ClampAndWriteImage< TInput , ComplexInt16ImageType >( + m_Image , + m_ComplexInt16Writer , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_cint32: + { + ClampAndWriteImage< TInput , ComplexInt32ImageType >( + m_Image , + m_ComplexInt32Writer , + m_FileName , + m_RAMValue ); + break; + } case ImagePixelType_cfloat: { ClampAndWriteImage< TInput , ComplexFloatImageType >( @@ -478,6 +514,24 @@ OutputImageParameter::SwitchVectorImageWrite() m_RAMValue ); break; } + case ImagePixelType_cint16: + { + ClampAndWriteImage < TInput , ComplexInt16VectorImageType > ( + m_Image , + m_ComplexVectorInt16Writer , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_cint32: + { + ClampAndWriteImage < TInput , ComplexInt32VectorImageType > ( + m_Image , + m_ComplexVectorInt32Writer , + m_FileName , + m_RAMValue ); + break; + } case ImagePixelType_cfloat: { ClampAndWriteImage < TInput , ComplexFloatVectorImageType > ( @@ -593,6 +647,14 @@ OutputImageParameter::Write() { SwitchImageWrite<DoubleImageType>(); } + else if (dynamic_cast<ComplexInt16ImageType*>(m_Image.GetPointer()) ) + { + SwitchImageWrite<ComplexInt16ImageType>(); + } + else if (dynamic_cast<ComplexInt32ImageType*>(m_Image.GetPointer()) ) + { + SwitchImageWrite<ComplexInt32ImageType>(); + } else if (dynamic_cast<ComplexFloatImageType*>(m_Image.GetPointer()) ) { SwitchImageWrite<ComplexFloatImageType>(); @@ -637,6 +699,14 @@ OutputImageParameter::Write() { SwitchRGBAImageWrite<UInt8RGBAImageType>(); } + else if (dynamic_cast<ComplexInt16VectorImageType*>(m_Image.GetPointer())) + { + SwitchVectorImageWrite<ComplexInt16VectorImageType>(); + } + else if (dynamic_cast<ComplexInt32VectorImageType*>(m_Image.GetPointer())) + { + SwitchVectorImageWrite<ComplexInt32VectorImageType>(); + } else if (dynamic_cast<ComplexFloatVectorImageType*>(m_Image.GetPointer())) { SwitchVectorImageWrite<ComplexFloatVectorImageType>(); @@ -668,6 +738,8 @@ OutputImageParameter::GetWriter() || dynamic_cast<UInt32VectorImageType*> (m_Image.GetPointer()) || dynamic_cast<FloatVectorImageType*> (m_Image.GetPointer()) || dynamic_cast<DoubleVectorImageType*> (m_Image.GetPointer()) + || dynamic_cast<ComplexInt16VectorImageType*> (m_Image.GetPointer()) + || dynamic_cast<ComplexInt32VectorImageType*> (m_Image.GetPointer()) || dynamic_cast<ComplexFloatVectorImageType*> (m_Image.GetPointer()) || dynamic_cast<ComplexDoubleVectorImageType*> (m_Image.GetPointer())) { @@ -757,6 +829,22 @@ OutputImageParameter::GetWriter() if (type == 0) writer = m_DoubleWriter; break; } + case ImagePixelType_cint16: + { + if( type == 1 ) + writer = m_ComplexVectorInt16Writer; + else + writer = m_ComplexInt16Writer; + break; + } + case ImagePixelType_cint32: + { + if( type == 1 ) + writer = m_ComplexVectorInt32Writer; + else + writer = m_ComplexInt32Writer; + break; + } case ImagePixelType_cfloat: { if( type == 1 ) diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx index b70cd5557a..9bcf5430d2 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetOutputImageParameter.cxx @@ -75,6 +75,8 @@ void QtWidgetOutputImageParameter::DoCreateWidget() m_ComboBox->addItem( "uint 32"); m_ComboBox->addItem( "float"); m_ComboBox->addItem( "double"); + m_ComboBox->addItem( "cint16"); + m_ComboBox->addItem( "cint32"); m_ComboBox->addItem( "cfloat"); m_ComboBox->addItem( "cdouble"); m_ComboBox->setCurrentIndex(m_OutputImageParam->GetPixelType()); -- GitLab From c32d308818198232328da3e9811a4ad27831ab55 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 13 Dec 2017 17:14:12 +0100 Subject: [PATCH 147/567] COMP: use serialization workaround in shark --- .../include/otbAutoencoderModel.txx | 7 ++----- .../include/otbPCAModel.txx | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index 02282b4c09..96eb2aa76e 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -50,9 +50,6 @@ #pragma GCC diagnostic pop #endif -#include <boost/archive/polymorphic_text_oarchive.hpp> -#include <boost/archive/polymorphic_text_iarchive.hpp> - namespace otb { @@ -353,7 +350,7 @@ AutoencoderModel<TInputValue,NeuronType> otbMsgDevMacro(<< "saving model ..."); std::ofstream ofs(filename); ofs << m_Net.name() << std::endl; // the first line of the model file contains a key - boost::archive::polymorphic_text_oarchive oa(ofs); + shark::TextOutArchive oa(ofs); oa << m_Net; ofs.close(); @@ -384,7 +381,7 @@ AutoencoderModel<TInputValue,NeuronType> if (autoencoderstr != net.name()){ itkExceptionMacro(<< "Error opening " << filename.c_str() ); } - boost::archive::polymorphic_text_iarchive ia(ifs); + shark::TextInArchive ia(ifs); ia >> m_Net; ifs.close(); diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx index bfe53d7643..dcc6b00ea2 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx @@ -41,9 +41,6 @@ #pragma GCC diagnostic pop #endif -#include <boost/archive/polymorphic_text_oarchive.hpp> -#include <boost/archive/polymorphic_text_iarchive.hpp> - namespace otb { @@ -101,7 +98,7 @@ PCAModel<TInputValue>::Save(const std::string & filename, const std::string & /* { std::ofstream ofs(filename); ofs << "pca" << std::endl; //first line - boost::archive::polymorphic_text_oarchive oa(ofs); + shark::TextOutArchive oa(ofs); m_Encoder.write(oa); ofs.close(); @@ -135,7 +132,7 @@ PCAModel<TInputValue>::Load(const std::string & filename, const std::string & /* if (encoderstr != "pca"){ itkExceptionMacro(<< "Error opening " << filename.c_str() ); } - boost::archive::polymorphic_text_iarchive ia(ifs); + shark::TextInArchive ia(ifs); m_Encoder.read(ia); ifs.close(); if (this->m_Dimension ==0) -- GitLab From 0cb12e2ca713d8c8c1a90ff2175579f366efde73 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 13 Dec 2017 17:15:34 +0100 Subject: [PATCH 148/567] COMP: enhance Shark detection with cblas, dynlib,... --- CMake/FindShark.cmake | 26 ++++++++++++------- .../ThirdParty/Shark/otb-module-init.cmake | 4 +++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CMake/FindShark.cmake b/CMake/FindShark.cmake index 59bef138f7..1fda9fdf6a 100644 --- a/CMake/FindShark.cmake +++ b/CMake/FindShark.cmake @@ -97,17 +97,25 @@ if(SHARK_CONFIG_FILE) "${SHARK_VERSION_MAJOR}.${SHARK_VERSION_MINOR}.${SHARK_VERSION_PATCH}") endif() -set(SHARK_USE_OPENMP_matched) -#define SHARK_USE_OPENMP +# Check if Shark was built with OpenMP, CBLAS, DYNLIB, ... file(STRINGS "${SHARK_INCLUDE_DIR}/shark/Core/Shark.h" SHARK_H_CONTENTS) -string(REGEX MATCH - "#define.SHARK_USE_OPENMP" - SHARK_USE_OPENMP_matched "${SHARK_H_CONTENTS}") -if(SHARK_USE_OPENMP_matched) - if(NOT OTB_USE_OPENMP) - message(WARNING "Shark library is built with OpenMP and you have OTB_USE_OPENMP set to OFF.") - endif() +if(SHARK_H_CONTENTS MATCHES "#define.SHARK_USE_OPENMP") + set(SHARK_USE_OPENMP 1) +else() + set(SHARK_USE_OPENMP 0) +endif() + +if(SHARK_H_CONTENTS MATCHES "#define.SHARK_USE_CBLAS") + set(SHARK_USE_CBLAS 1) +else() + set(SHARK_USE_CBLAS 0) +endif() + +if(SHARK_H_CONTENTS MATCHES "#define.SHARK_USE_DYNLIB") + set(SHARK_USE_DYNLIB 1) +else() + set(SHARK_USE_DYNLIB 0) endif() INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) diff --git a/Modules/ThirdParty/Shark/otb-module-init.cmake b/Modules/ThirdParty/Shark/otb-module-init.cmake index 6bdd8c6a31..23ec6090c7 100644 --- a/Modules/ThirdParty/Shark/otb-module-init.cmake +++ b/Modules/ThirdParty/Shark/otb-module-init.cmake @@ -20,4 +20,8 @@ find_package ( Shark REQUIRED ) +if(SHARK_USE_OPENMP AND NOT OTB_USE_OPENMP) + message(WARNING "Shark library is built with OpenMP and you have OTB_USE_OPENMP set to OFF.") +endif() + mark_as_advanced( Shark_DIR ) -- GitLab From 2e95a3e95943ee44cb49a3ab31deb967d3ea1a45 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 13 Dec 2017 17:45:08 +0100 Subject: [PATCH 149/567] COMP: try to detect cblas when needed by shark --- CMake/FindShark.cmake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMake/FindShark.cmake b/CMake/FindShark.cmake index 1fda9fdf6a..523f1ee7dc 100644 --- a/CMake/FindShark.cmake +++ b/CMake/FindShark.cmake @@ -118,12 +118,22 @@ else() set(SHARK_USE_DYNLIB 0) endif() +if(SHARK_USE_CBLAS AND SHARK_USE_DYNLIB) + set(REQUIRED_CBLAS_LIB CBLAS_LIBRARY) + find_library(CBLAS_LIBRARY NAMES cblas) +else() + set(REQUIRED_CBLAS_LIB) +endif() + INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Shark - REQUIRED_VARS SHARK_LIBRARY SHARK_INCLUDE_DIR + REQUIRED_VARS SHARK_LIBRARY SHARK_INCLUDE_DIR ${REQUIRED_CBLAS_LIB} VERSION_VAR SHARK_VERSION_STRING) if(SHARK_FOUND) set(SHARK_INCLUDE_DIRS ${SHARK_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ) set(SHARK_LIBRARIES ${SHARK_LIBRARY} ${Boost_LIBRARIES} ) + if(REQUIRED_CBLAS_LIB) + set(SHARK_LIBRARIES ${SHARK_LIBRARIES} ${CBLAS_LIBRARY}) + endif() endif() -- GitLab From 7b1aff431567c921cfd557965c55a171949d1165 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 13 Dec 2017 17:55:14 +0100 Subject: [PATCH 150/567] WRG: filter some shark warnings --- .../include/otbAutoencoderModel.h | 1 + .../DimensionalityReductionLearning/include/otbPCAModel.h | 1 + 2 files changed, 2 insertions(+) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h index 0707f5e182..14205f0cd8 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h @@ -29,6 +29,7 @@ #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Woverloaded-virtual" +#pragma GCC diagnostic ignored "-Wsign-compare" #endif #include "otb_shark.h" #include <shark/Algorithms/StoppingCriteria/AbstractStoppingCriterion.h> diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h index 907d6a33cf..dd8f7a6992 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h @@ -28,6 +28,7 @@ #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Woverloaded-virtual" +#pragma GCC diagnostic ignored "-Wsign-compare" #endif #include "otb_shark.h" #include <shark/Algorithms/Trainers/PCA.h> -- GitLab From f3dbbd3804a428b020f94853ca9630009c372bdb Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 13 Dec 2017 18:52:22 +0100 Subject: [PATCH 151/567] ENH: no support for tied autoencoder yet --- .../app/otbTrainDimensionalityReduction.cxx | 5 ++-- ...imensionalityReductionTrainAutoencoder.txx | 23 +------------------ 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx index fa3dd7bdcb..df735345a1 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx @@ -73,7 +73,7 @@ private: SetName("TrainDimensionalityReduction"); SetDescription("Trainer for the dimensionality reduction algorithms used in" " the ImageDimensionalityReduction and VectorDimensionalityReduction applications."); - + AddParameter(ParameterType_Group, "io", "Input and output data"); SetParameterDescription("io", "This group of parameters allows setting input and output data."); @@ -83,8 +83,7 @@ private: AddParameter(ParameterType_OutputFilename, "io.out", "Output model"); SetParameterDescription("io.out", "Output file containing the estimated model (.txt format)."); - - + AddParameter(ParameterType_InputFilename, "io.stats", "Input XML image statistics file"); MandatoryOff("io.stats"); SetParameterDescription("io.stats", "XML file containing mean and variance of each feature."); diff --git a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx index 6f073353f3..f474167e38 100644 --- a/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx +++ b/Modules/Applications/AppDimensionalityReduction/include/otbDimensionalityReductionTrainAutoencoder.txx @@ -33,22 +33,11 @@ void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> ::InitAutoencoderParams() { - AddChoice("algorithm.tiedautoencoder", "Shark Tied Autoencoder"); AddChoice("algorithm.autoencoder", "Shark Autoencoder"); SetParameterDescription("algorithm.autoencoder", "This group of parameters allows setting Shark autoencoder parameters. " ); - //Tied Autoencoder - AddParameter(ParameterType_Choice, "algorithm.autoencoder.istied", - "tied weighth <tied/untied>"); - SetParameterDescription( - "algorithm.autoencoder.istied", - "Parameter that determine if the weights are tied or not <tied/untied>"); - - AddChoice("algorithm.autoencoder.istied.yes","Tied weigths"); - AddChoice("algorithm.autoencoder.istied.no","Untied weights"); - //Number Of Iterations AddParameter(ParameterType_Int, "algorithm.autoencoder.nbiter", "Maximum number of iterations during training"); @@ -116,17 +105,7 @@ TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> { typedef shark::LogisticNeuron NeuronType; typedef otb::AutoencoderModel<InputValueType, NeuronType> AutoencoderModelType; - std::string TiedWeigth = GetParameterString("algorithm.autoencoder.istied"); - std::cout << TiedWeigth << std::endl; - - if(TiedWeigth == "no") - { - TrainAutoencoder<AutoencoderModelType>(trainingListSample,modelPath); - } - if(TiedWeigth != "yes" && TiedWeigth != "no") - { - std::cerr << "istied : invalid choice <yes/no>" << std::endl; - } + TrainAutoencoder<AutoencoderModelType>(trainingListSample,modelPath); } template <class TInputValue, class TOutputValue> -- GitLab From 0f05d4786f41e3b6e84612a085eaf0961fce73ef Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 13 Dec 2017 18:52:57 +0100 Subject: [PATCH 152/567] TEST: first test prototype (WIP) --- .../AppDimensionalityReduction/test/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Modules/Applications/AppDimensionalityReduction/test/CMakeLists.txt b/Modules/Applications/AppDimensionalityReduction/test/CMakeLists.txt index 78737f6b82..01f055c417 100644 --- a/Modules/Applications/AppDimensionalityReduction/test/CMakeLists.txt +++ b/Modules/Applications/AppDimensionalityReduction/test/CMakeLists.txt @@ -38,3 +38,15 @@ otb_test_application(NAME apTvFEDimensionalityReductionPCA ${BASELINE}/bfTvPCAImageFilter3.tif ${TEMP}/apTvChDimensionalityReductionPCA.tif) +#----------- TrainDimensionalityReduction TESTS ---------------- +otb_test_application(NAME apTvDrTrainDimensionalityReductionAE + APP TrainDimensionalityReduction + OPTIONS -io.vd ${INPUTDATA}/cuprite_samples.sqlite + -io.out ${TEMP}/cuprite_DRModel.ae + -feat value_0 value_1 value_2 value_3 value_4 value_5 value_6 value_7 value_8 value_9 + -algorithm autoencoder + -algorithm.autoencoder.nbneuron 8 + -algorithm.autoencoder.regularization 0.01 + -algorithm.autoencoder.noise 0 + -algorithm.autoencoder.rho 0 + -algorithm.autoencoder.beta 0) -- GitLab From 4ca2a7bc77653c8707d4a3b22cc2d8b6db3a7b73 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 14 Dec 2017 10:04:58 +0100 Subject: [PATCH 153/567] COMP: no dependency to ITK in otbSharkUtils --- .../ThirdParty/Shark/include/otbSharkUtils.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Modules/ThirdParty/Shark/include/otbSharkUtils.h b/Modules/ThirdParty/Shark/include/otbSharkUtils.h index 9efcf948bd..de3adf7740 100644 --- a/Modules/ThirdParty/Shark/include/otbSharkUtils.h +++ b/Modules/ThirdParty/Shark/include/otbSharkUtils.h @@ -21,7 +21,8 @@ #ifndef otbSharkUtils_h #define otbSharkUtils_h -#include "itkMacro.h" +#include <stdexcept> +#include <string> #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push @@ -41,11 +42,13 @@ namespace Shark { template <class T> void ListSampleRangeToSharkVector(const T * listSample, std::vector<shark::RealVector> & output, unsigned int start, unsigned int size) { - assert(listSample != ITK_NULLPTR); + assert(listSample != nullptr); if(start+size>listSample->Size()) { - itkGenericExceptionMacro(<<"Requested range ["<<start<<", "<<start+size<<"[ is out of bound for input list sample (range [0, "<<listSample->Size()<<"["); + std::out_of_range e_(std::string("otb::Shark::ListSampleRangeToSharkVector " + ": Requested range is out of list sample bounds")); + throw e_; } output.clear(); @@ -83,11 +86,13 @@ template <class T> void ListSampleRangeToSharkVector(const T * listSample, std:: template <class T> void ListSampleRangeToSharkVector(const T * listSample, std::vector<unsigned int> & output, unsigned int start, unsigned int size) { - assert(listSample != ITK_NULLPTR); + assert(listSample != nullptr); if(start+size>listSample->Size()) { - itkGenericExceptionMacro(<<"Requested range ["<<start<<", "<<start+size<<"[ is out of bound for input list sample (range [0, "<<listSample->Size()<<"["); + std::out_of_range e_(std::string("otb::Shark::ListSampleRangeToSharkVector " + ": Requested range is out of list sample bounds")); + throw e_; } output.clear(); @@ -113,13 +118,13 @@ template <class T> void ListSampleRangeToSharkVector(const T * listSample, std:: template <class T> void ListSampleToSharkVector(const T * listSample, std::vector<shark::RealVector> & output) { - assert(listSample != ITK_NULLPTR); + assert(listSample != nullptr); ListSampleRangeToSharkVector(listSample,output,0U,static_cast<unsigned int>(listSample->Size())); } template <class T> void ListSampleToSharkVector(const T * listSample, std::vector<unsigned int> & output) { - assert(listSample != ITK_NULLPTR); + assert(listSample != nullptr); ListSampleRangeToSharkVector(listSample,output,0, static_cast<unsigned int>(listSample->Size())); } -- GitLab From 4508cf4ea174337aef3972e470b2d615b9ad4c79 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 14 Dec 2017 10:11:13 +0100 Subject: [PATCH 154/567] REFAC: replace file after POC --- .../include/otbDefaultConvertNewImpl.h | 220 --------- .../include/otbDefaultConvertPixelTraits.h | 466 +++++++----------- .../include/otbConvertTypeFunctor.h | 10 +- .../IO/ImageIO/include/otbImageFileReader.h | 4 +- .../IO/ImageIO/include/otbImageFileReader.txx | 4 +- 5 files changed, 182 insertions(+), 522 deletions(-) delete mode 100644 Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h diff --git a/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h b/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h deleted file mode 100644 index 60bd0726ad..0000000000 --- a/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h +++ /dev/null @@ -1,220 +0,0 @@ -/*========================================================================= - * - * Copyright Insight Software Consortium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - *=========================================================================*/ -#ifndef otbDefaultConvertNewImp_h -#define otbDefaultConvertNewImp_h - -#include "itkDefaultConvertPixelTraits.h" - -// #include "itkOffset.h" -// #include "itkVector.h" -// #include "itkMatrix.h" -// #include "itkVariableLengthVector.h" -// #include "itkVariableSizeMatrix.h" - -namespace otb -{ - - -template < typename PixelType> -class DefaultConvertPixelTraitsTest -: public itk::DefaultConvertPixelTraits < PixelType > -{ -public: - typedef itk::DefaultConvertPixelTraits < PixelType > SuperClass; - using SuperClass::ComponentType; - - using SuperClass::SetNthComponent; - - static void SetNthComponent(int , PixelType & pixel, const PixelType & v) - { - pixel = v; - } -}; - -// We might not need this specialization if the compileur allow -// us to declare to function with same signature in some case : -// see "SetNthComponent" -/* -#define OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \ - template< > \ - class DefaultConvertPixelTraitsTest < type > \ - : public itk::DefaultConvertPixelTraits < type > \ - { \ -public: \ - typedef itk::DefaultConvertPixelTraits < type > SuperClass; \ - using typename SuperClass::ComponentType; \ - }; -*/ -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(float) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(double) -// Warning long double is not in itk < 4.11 -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long double) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(int) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(char) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(short) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned int) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(signed char) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned char) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned short) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long long) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long long) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(bool) - -// #undef OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL - -// -// Default traits for the Offset<> pixel type -// - -// template<unsigned int VDimension> -// class DefaultConvertPixelTraitsTest < itk::Offset< VDimension > > : -// public itk::DefaultConvertPixelTraits< itk::Offset< VDimension > > -// { -// public: -// typedef itk::DefaultConvertPixelTraits < itk::Offset< VDimension > > SuperClass; -// using typename SuperClass::ComponentType; - -// using SuperClass::SetNthComponent; - -// static void SetNthComponent(int , TargetType & pixel, const TargetType& v) -// { -// pixel = v; -// } -// }; - -// -// Default traits for the pixel types deriving from FixedArray<> -// - -/* -define OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \ -template < typename TComponentType , unsigned VDimension > \ -class DefaultConvertPixelTraitsTest < type < TComponentType , VDimension > > \ -: public itk::DefaultConvertPixelTraits < type < TComponentType , VDimension > > \ -{ \ -public: \ - typedef itk::DefaultConvertPixelTraits < type < TComponentType , VDimension > > SuperClass;\ - typedef typename SuperClass::TargetType TargetType; \ - static void SetNthComponent(int , TargetType & pixel, const TargetType & v) \ - { \ - pixel = v; \ - } \ -} \ -*/ -// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::FixedArray); -// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Vector); -// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::CovariantVector); -// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Point); - -// #undef OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE - -// -// Default traits for pixel types deriving from VariableLengthVector<> -// - -// template < typename T > -// class DefaultConvertPixelTraitsTest < itk::VariableLengthVector < T > > -// : public itk::DefaultConvertPixelTraits < itk::VariableLengthVector< T > > -// { -// public: -// typedef itk::DefaultConvertPixelTraits< itk::VariableLengthVector < T > > SuperClass; -// using typename SuperClass::TargetType; -// using typename SuperClass::ComponentType; -// }; - -// -// Default traits for the pixel types deriving from Matrix<> -// - -// template<typename VComponent, unsigned VRows, unsigned VCols > -// class DefaultConvertPixelTraitsTest < itk::Matrix< VComponent, VRows, VCols > > -// : public itk::DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > -// { -// public: -// typedef itk::DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > SuperClass; -// using typename SuperClass::TargetType; -// using typename SuperClass::ComponentType; - - -// using SuperClass::SetNthComponent; - -// static void SetNthComponent(int , TargetType & pixel, const TargetType& v) -// { -// pixel = v; -// } -// }; - -// -// Default traits for pixel types deriving from VariableSizeMatrix<> -// - -// template < typename T > -// class DefaultConvertPixelTraitsTest< itk::VariableSizeMatrix< T > > -// : public itk::DefaultConvertPixelTraits< itk::VariableSizeMatrix< T > > -// { -// public: -// typedef itk::DefaultConvertPixelTraits< itk::VariableSizeMatrix < T > > SuperClass; -// using typename SuperClass::TargetType; -// using typename SuperClass::ComponentType; -// }; - -// -// Default traits for pixel types deriving from std::complex<> -// - -template < typename T > -class DefaultConvertPixelTraitsTest < ::std::complex < T > > -: public itk::DefaultConvertPixelTraits < ::std::complex < T > > -{ -public: - - typedef itk::DefaultConvertPixelTraits < ::std::complex < T > > SuperClass; - using typename SuperClass::TargetType ; - using typename SuperClass::ComponentType ; - - using SuperClass::SetNthComponent ; - - static void SetNthComponent(int , TargetType & pixel, const TargetType & v) - { - pixel = v; - } - - static TargetType GetNthComponent ( int , const TargetType & pixel ) - { - return pixel; - } - - static ComponentType GetScalarValue(const TargetType& pixel) - { - /* - * This seems to be dead code, since the complex to scalar - * conversion is done by ConvertPixelBuffer - * - * Historically, it was returning std::norm, which causes - * compilation error on MacOSX 10.9. - * Now returns the equivalent implementation of std::norm. - */ - return static_cast<ComponentType>( pixel.real()*pixel.real() - + pixel.imag()*pixel.imag() ); - } -}; - -} // end namespace -#endif diff --git a/Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h b/Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h index 3339a54a1a..29ed2b3fee 100644 --- a/Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h +++ b/Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h @@ -1,340 +1,220 @@ -/* - * Copyright (C) 1999-2011 Insight Software Consortium - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +/*========================================================================= * - * This file is part of Orfeo Toolbox + * Copyright Insight Software Consortium * - * https://www.orfeo-toolbox.org/ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0.txt * - * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - + *=========================================================================*/ #ifndef otbDefaultConvertPixelTraits_h #define otbDefaultConvertPixelTraits_h -#include "itkOffset.h" -#include "itkVector.h" -#include "itkMatrix.h" +#include "itkDefaultConvertPixelTraits.h" -namespace otb -{ +// #include "itkOffset.h" +// #include "itkVector.h" +// #include "itkMatrix.h" +// #include "itkVariableLengthVector.h" +// #include "itkVariableSizeMatrix.h" -/** \class DefaultConvertPixelTraits - * \brief Traits class used to by ConvertPixels to convert blocks of pixels. - * - * TOutputPixelType is the destination type. The input type is inferred - * by the templated static function Convert. - * - * This implementation does a simple assignment operator, so if you are - * going from a higher bit representation to a lower bit one (int to - * char), you may want to specialize and add some sort of transfer function. - * - * \ingroup OTBImageBase - */ -template<typename PixelType> -class DefaultConvertPixelTraits +namespace otb { -public: - /** Determine the pixel data type. */ - typedef typename PixelType::ComponentType ComponentType; - - /** Return the number of components per pixel. */ - static unsigned int GetNumberOfComponents() - { return PixelType::GetNumberOfComponents(); } - - /** Return the nth component of the pixel. */ - static ComponentType GetNthComponent(int c, const PixelType& pixel) - { return pixel.GetNthComponent(c); } - /** Set the nth component of the pixel. */ - static void SetNthComponent(int c, PixelType& pixel, const ComponentType& v) - { pixel.SetNthComponent(c, v); } - static void SetNthComponent(int itkNotUsed(c), PixelType & pixel, const PixelType& v) - { pixel = v; } - /** Return a single scalar value from this pixel. */ - static ComponentType GetScalarValue(const PixelType& pixel) - { return pixel.GetScalarValue(); } +template < typename PixelType> +class DefaultConvertPixelTraits +: public itk::DefaultConvertPixelTraits < PixelType > +{ +public: + typedef itk::DefaultConvertPixelTraits < PixelType > SuperClass; + using SuperClass::ComponentType; -}; + using SuperClass::SetNthComponent; -#define OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \ -template<> \ -class DefaultConvertPixelTraits<type> \ -{ \ -public: \ - typedef type ComponentType; \ - static unsigned int GetNumberOfComponents() \ - { \ - return 1; \ - } \ - static void SetNthComponent(int , type& pixel, const ComponentType& v) \ - { \ - pixel = v; \ - } \ - static type GetScalarValue(const type& pixel) \ - { \ - return pixel; \ - } \ + static void SetNthComponent(int , PixelType & pixel, const PixelType & v) + { + pixel = v; + } }; -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(float) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(double) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(int) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(char) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(short) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned int) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(signed char) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned char) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned short) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long) -OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(bool) - -#undef OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL +// We might not need this specialization if the compileur allow +// us to declare to function with same signature in some case : +// see "SetNthComponent" +/* +#define OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \ + template< > \ + class DefaultConvertPixelTraits < type > \ + : public itk::DefaultConvertPixelTraits < type > \ + { \ +public: \ + typedef itk::DefaultConvertPixelTraits < type > SuperClass; \ + using typename SuperClass::ComponentType; \ + }; +*/ +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(float) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(double) +// Warning long double is not in itk < 4.11 +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long double) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(int) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(char) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(short) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned int) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(signed char) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned char) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned short) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long long) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long long) +// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(bool) + +// #undef OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL // // Default traits for the Offset<> pixel type // -#define OTB_DEFAULTCONVERTTRAITS_OFFSET_TYPE(dimension) \ -template<> \ -class DefaultConvertPixelTraits< itk::Offset<dimension> > \ -{ \ -public: \ - typedef itk::Offset<dimension> TargetType; \ - typedef TargetType::OffsetValueType ComponentType; \ - static unsigned int GetNumberOfComponents() \ - { \ - return dimension; \ - } \ - static void SetNthComponent(int i, TargetType & pixel, const ComponentType& v) \ - { \ - pixel[i] = v; \ - } \ - static void SetNthComponent(int , TargetType & pixel, const TargetType& v) \ - { \ - pixel = v; \ - } \ - static ComponentType GetScalarValue(const TargetType& pixel) \ - { \ - return pixel[0]; \ - } \ -}; +// template<unsigned int VDimension> +// class DefaultConvertPixelTraits < itk::Offset< VDimension > > : +// public itk::DefaultConvertPixelTraits< itk::Offset< VDimension > > +// { +// public: +// typedef itk::DefaultConvertPixelTraits < itk::Offset< VDimension > > SuperClass; +// using typename SuperClass::ComponentType; +// using SuperClass::SetNthComponent; -// Define traits for Offset<> from dimensions 1 to 5 - OTB_DEFAULTCONVERTTRAITS_OFFSET_TYPE(1) - OTB_DEFAULTCONVERTTRAITS_OFFSET_TYPE(2) - OTB_DEFAULTCONVERTTRAITS_OFFSET_TYPE(3) - OTB_DEFAULTCONVERTTRAITS_OFFSET_TYPE(4) - OTB_DEFAULTCONVERTTRAITS_OFFSET_TYPE(5) +// static void SetNthComponent(int , TargetType & pixel, const TargetType& v) +// { +// pixel = v; +// } +// }; // // Default traits for the pixel types deriving from FixedArray<> // -#define OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type,componenttype, dimension) \ -template<> \ -class DefaultConvertPixelTraits< type< componenttype, dimension> > \ -{ \ -public: \ - typedef type< componenttype, dimension > TargetType; \ - typedef componenttype ComponentType; \ - static unsigned int GetNumberOfComponents() \ - { \ - return dimension; \ - } \ - static void SetNthComponent(int i, TargetType & pixel, const ComponentType& v) \ - { \ - pixel[i] = v; \ - } \ - static void SetNthComponent(int , TargetType & pixel, const TargetType& v) \ - { \ - pixel = v; \ - } \ - static ComponentType GetScalarValue(const TargetType& pixel) \ - { \ - return pixel[0]; \ - } \ -}; \ - -// -// -// Define traits for Classed deriving from FixedArray from dimensions 1 to 6 -// These classes include: Vector, CovariantVector and Point. -// -// -#define OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, Type) \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType,Type,1) \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType,Type,2) \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType,Type,3) \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType,Type,4) \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType,Type,5) \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType,Type,6) - -#define OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_TYPES_MACRO(ArrayType) \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, char); \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, signed char); \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned char); \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, short); \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned short); \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, int); \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned int); \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, long); \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned long); \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, float); \ - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, double); - - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_TYPES_MACRO(itk::Vector); - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_TYPES_MACRO(itk::CovariantVector); - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_TYPES_MACRO(itk::Point); - OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_TYPES_MACRO(itk::FixedArray); - -// -// End of Traits for the classes deriving from FixedArray. -// -// - +/* +define OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \ +template < typename TComponentType , unsigned VDimension > \ +class DefaultConvertPixelTraits < type < TComponentType , VDimension > > \ +: public itk::DefaultConvertPixelTraits < type < TComponentType , VDimension > > \ +{ \ +public: \ + typedef itk::DefaultConvertPixelTraits < type < TComponentType , VDimension > > SuperClass;\ + typedef typename SuperClass::TargetType TargetType; \ + static void SetNthComponent(int , TargetType & pixel, const TargetType & v) \ + { \ + pixel = v; \ + } \ +} \ +*/ +// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::FixedArray); +// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Vector); +// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::CovariantVector); +// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Point); + +// #undef OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE + +// +// Default traits for pixel types deriving from VariableLengthVector<> +// + +// template < typename T > +// class DefaultConvertPixelTraits < itk::VariableLengthVector < T > > +// : public itk::DefaultConvertPixelTraits < itk::VariableLengthVector< T > > +// { +// public: +// typedef itk::DefaultConvertPixelTraits< itk::VariableLengthVector < T > > SuperClass; +// using typename SuperClass::TargetType; +// using typename SuperClass::ComponentType; +// }; // // Default traits for the pixel types deriving from Matrix<> // -#define OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE(type,componenttype,rows,cols) \ -template<> \ -class DefaultConvertPixelTraits< type< componenttype, rows, cols > > \ -{ \ -public: \ - typedef type< componenttype, rows, cols > TargetType; \ - typedef componenttype ComponentType; \ - static unsigned int GetNumberOfComponents() \ - { \ - return rows * cols; \ - } \ - static void SetNthComponent(int i, TargetType & pixel, const ComponentType& v) \ - { \ - const unsigned int row = i / cols; \ - const unsigned int col = i % cols; \ - pixel[row][col] = v; \ - } \ - static void SetNthComponent(int , TargetType & pixel, const TargetType& v) \ - { \ - pixel = v; \ - } \ - static ComponentType GetScalarValue(const TargetType& pixel) \ - { \ - return pixel[0][0]; \ - } \ -}; \ +// template<typename VComponent, unsigned VRows, unsigned VCols > +// class DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > +// : public itk::DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > +// { +// public: +// typedef itk::DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > SuperClass; +// using typename SuperClass::TargetType; +// using typename SuperClass::ComponentType; -// -// -// Define traits for Classed deriving from Matrix from dimensions 1 to 6 -// -// -#define OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, Type) \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType,Type,1,1) \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType,Type,2,2) \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType,Type,3,3) \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType,Type,4,4) \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType,Type,5,5) \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType,Type,6,6) - -#define OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_TYPES_MACRO(ArrayType) \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, char); \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, signed char); \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned char); \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, short); \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned short); \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, int); \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned int); \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, long); \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned long); \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, float); \ - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, double); -// -// Add here other classes that derive from Matrix or that have the same API -// - OTB_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_TYPES_MACRO(itk::Matrix); +// using SuperClass::SetNthComponent; + +// static void SetNthComponent(int , TargetType & pixel, const TargetType& v) +// { +// pixel = v; +// } +// }; // -// End of Traits for the classes deriving from Matrix. -// +// Default traits for pixel types deriving from VariableSizeMatrix<> // +// template < typename T > +// class DefaultConvertPixelTraits< itk::VariableSizeMatrix< T > > +// : public itk::DefaultConvertPixelTraits< itk::VariableSizeMatrix< T > > +// { +// public: +// typedef itk::DefaultConvertPixelTraits< itk::VariableSizeMatrix < T > > SuperClass; +// using typename SuperClass::TargetType; +// using typename SuperClass::ComponentType; +// }; // -// Default traits for the pixel types deriving from std::complex<> +// Default traits for pixel types deriving from std::complex<> // -#define OTB_DEFAULTCONVERTTRAITS_COMPLEX_TYPE( componenttype ) \ -template<> \ -class DefaultConvertPixelTraits< ::std::complex< componenttype > > \ -{ \ -public: \ - typedef ::std::complex< componenttype> TargetType; \ - typedef componenttype ComponentType; \ - static unsigned int GetNumberOfComponents() \ - { \ - return 2; \ - } \ - static void SetNthComponent(int i, TargetType & pixel, const ComponentType& v) \ - { \ - if( i == 0 ) \ - { \ - pixel = TargetType( v, pixel.imag() ); \ - } \ - else \ - { \ - pixel = TargetType( pixel.real(), v ); \ - } \ - } \ - static void SetNthComponent(int , TargetType & pixel, const TargetType& v) \ - { \ - pixel = v; \ - } \ - static ComponentType GetScalarValue(const TargetType& pixel) \ - { \ - /* \ - * This seems to be dead code, since the complex to scalar \ - * conversion is done by ConvertPixelBuffer \ - * \ - * Historically, it was returning std::norm, which causes \ - * compilation error on MacOSX 10.9. \ - * Now returns the equivalent implementation of std::norm. \ - */ \ - return static_cast<ComponentType>( pixel.real()*pixel.real() \ - + pixel.imag()*pixel.imag() ); \ - } \ -}; \ - -OTB_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(float); -OTB_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(double); -OTB_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(signed int); -OTB_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(unsigned int); -OTB_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(short int); -OTB_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(signed char); -OTB_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(unsigned char); -OTB_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(signed long); -OTB_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(unsigned long); +template < typename T > +class DefaultConvertPixelTraits < ::std::complex < T > > +: public itk::DefaultConvertPixelTraits < ::std::complex < T > > +{ +public: -// -// End of Traits for the classes deriving from std::complex. -// -// + typedef itk::DefaultConvertPixelTraits < ::std::complex < T > > SuperClass; + using typename SuperClass::TargetType ; + using typename SuperClass::ComponentType ; + + using SuperClass::SetNthComponent ; + + static void SetNthComponent(int , TargetType & pixel, const TargetType & v) + { + pixel = v; + } + + static TargetType GetNthComponent ( int , const TargetType & pixel ) + { + return pixel; + } + + static ComponentType GetScalarValue(const TargetType& pixel) + { + /* + * This seems to be dead code, since the complex to scalar + * conversion is done by ConvertPixelBuffer + * + * Historically, it was returning std::norm, which causes + * compilation error on MacOSX 10.9. + * Now returns the equivalent implementation of std::norm. + */ + return static_cast<ComponentType>( pixel.real()*pixel.real() + + pixel.imag()*pixel.imag() ); + } +}; -} // end namespace otb +} // end namespace #endif diff --git a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h index 49358d4169..bb2da54df7 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h @@ -28,7 +28,7 @@ #include "itkVariableLengthVector.h" #include "itkNumericTraits.h" -#include "otbDefaultConvertNewImpl.h" +#include "otbDefaultConvertPixelTraits.h" namespace otb { @@ -126,7 +126,7 @@ protected: std::enable_if_t < std::is_arithmetic < PixelType > ::value , int > = 2 > void FillIn( unsigned int i , InputPixelType const & pix , std::vector < double > & vPix ) const { - vPix.push_back( DefaultConvertPixelTraitsTest < InputPixelType > :: + vPix.push_back( DefaultConvertPixelTraits < InputPixelType > :: GetNthComponent( i , pix ) ); } @@ -134,7 +134,7 @@ protected: std::enable_if_t < boost::is_complex < PixelType > :: value , int > = 1 > void FillIn( unsigned int i , InputPixelType const & pix , std::vector < double > & vPix ) const { - PixelType comp = DefaultConvertPixelTraitsTest < InputPixelType > :: + PixelType comp = DefaultConvertPixelTraits < InputPixelType > :: GetNthComponent( i , pix ); vPix.push_back( static_cast < double > ( real( comp ) ) ); vPix.push_back( static_cast < double > ( imag( comp ) ) ); @@ -163,7 +163,7 @@ protected: std::enable_if_t < std::is_arithmetic < PixelType > ::value , int > = 2 > void FillOut( unsigned int i , OutputPixelType & pix , std::vector < double > & vPix ) const { - DefaultConvertPixelTraitsTest < OutputPixelType > :: + DefaultConvertPixelTraits < OutputPixelType > :: SetNthComponent( i , pix , vPix[i] ); } @@ -171,7 +171,7 @@ protected: std::enable_if_t < boost::is_complex < PixelType > :: value , int > = 1 > void FillOut( unsigned int i , OutputPixelType & pix , std::vector < double > & vPix ) const { - DefaultConvertPixelTraitsTest < OutputPixelType > :: + DefaultConvertPixelTraits < OutputPixelType > :: SetNthComponent( i , pix , PixelType ( vPix[ 2 * i] , vPix[ 2 * i + 1] ) ); } diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.h b/Modules/IO/ImageIO/include/otbImageFileReader.h index 8843e4bb2b..631f9d7dc2 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.h +++ b/Modules/IO/ImageIO/include/otbImageFileReader.h @@ -33,7 +33,7 @@ #include "itkExceptionObject.h" #include "itkImageRegion.h" -#include "otbDefaultConvertNewImpl.h" +#include "otbDefaultConvertPixelTraits.h" #include "otbImageKeywordlist.h" #include "otbExtendedFilenameToReaderOptions.h" @@ -86,7 +86,7 @@ public: * \ingroup OTBImageIO */ template <class TOutputImage, - class ConvertPixelTraits=DefaultConvertPixelTraitsTest< + class ConvertPixelTraits=DefaultConvertPixelTraits< typename TOutputImage::IOPixelType > > class ITK_EXPORT ImageFileReader : public itk::ImageSource<TOutputImage> { diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx index 1c67d82e00..98a37bf87b 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.txx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx @@ -179,8 +179,8 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> this->m_ImageIO->SetIORegion(ioRegion); - typedef otb::DefaultConvertPixelTraitsTest<typename TOutputImage::IOPixelType> ConvertIOPixelTraits; - typedef otb::DefaultConvertPixelTraitsTest<typename TOutputImage::PixelType> ConvertOutputPixelTraits; + typedef otb::DefaultConvertPixelTraits<typename TOutputImage::IOPixelType> ConvertIOPixelTraits; + typedef otb::DefaultConvertPixelTraits<typename TOutputImage::PixelType> ConvertOutputPixelTraits; if (this->m_ImageIO->GetComponentTypeInfo() == typeid(typename ConvertOutputPixelTraits::ComponentType) -- GitLab From e0977ace417090afb50f4c78aac333c24c1c5d03 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 14 Dec 2017 10:14:05 +0100 Subject: [PATCH 155/567] REFAC: get rid of imagewriter --- .../include/otbWrapperOutputImageParameter.h | 48 +-- .../src/otbWrapperOutputImageParameter.cxx | 356 +++++++++--------- 2 files changed, 202 insertions(+), 202 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index e47f85a230..e508b8528f 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -119,8 +119,8 @@ protected: /** Destructor */ ~OutputImageParameter() ITK_OVERRIDE; - template <class TInputImageType> - void SwitchImageWrite(); + // template <class TInputImageType> + // void SwitchImageWrite(); // template <class TInputImageType> // void SwitchCImageWrite(); @@ -143,13 +143,13 @@ protected: ImagePixelType m_PixelType; ImagePixelType m_DefaultPixelType; - typedef otb::ImageFileWriter<UInt8ImageType> UInt8WriterType; - typedef otb::ImageFileWriter<Int16ImageType> Int16WriterType; - typedef otb::ImageFileWriter<UInt16ImageType> UInt16WriterType; - typedef otb::ImageFileWriter<Int32ImageType> Int32WriterType; - typedef otb::ImageFileWriter<UInt32ImageType> UInt32WriterType; - typedef otb::ImageFileWriter<FloatImageType> FloatWriterType; - typedef otb::ImageFileWriter<DoubleImageType> DoubleWriterType; + // typedef otb::ImageFileWriter<UInt8ImageType> UInt8WriterType; + // typedef otb::ImageFileWriter<Int16ImageType> Int16WriterType; + // typedef otb::ImageFileWriter<UInt16ImageType> UInt16WriterType; + // typedef otb::ImageFileWriter<Int32ImageType> Int32WriterType; + // typedef otb::ImageFileWriter<UInt32ImageType> UInt32WriterType; + // typedef otb::ImageFileWriter<FloatImageType> FloatWriterType; + // typedef otb::ImageFileWriter<DoubleImageType> DoubleWriterType; typedef otb::ImageFileWriter<UInt8VectorImageType> VectorUInt8WriterType; typedef otb::ImageFileWriter<Int16VectorImageType> VectorInt16WriterType; @@ -163,10 +163,10 @@ protected: typedef otb::ImageFileWriter<UInt8RGBImageType> RGBUInt8WriterType; // Complex Image - typedef otb::ImageFileWriter<ComplexInt16ImageType> ComplexInt16WriterType; - typedef otb::ImageFileWriter<ComplexInt32ImageType> ComplexInt32WriterType; - typedef otb::ImageFileWriter<ComplexFloatImageType> ComplexFloatWriterType; - typedef otb::ImageFileWriter<ComplexDoubleImageType> ComplexDoubleWriterType; + // typedef otb::ImageFileWriter<ComplexInt16ImageType> ComplexInt16WriterType; + // typedef otb::ImageFileWriter<ComplexInt32ImageType> ComplexInt32WriterType; + // typedef otb::ImageFileWriter<ComplexFloatImageType> ComplexFloatWriterType; + // typedef otb::ImageFileWriter<ComplexDoubleImageType> ComplexDoubleWriterType; typedef otb::ImageFileWriter<ComplexInt16VectorImageType> ComplexVectorInt16WriterType; typedef otb::ImageFileWriter<ComplexInt32VectorImageType> ComplexVectorInt32WriterType; @@ -174,13 +174,13 @@ protected: typedef otb::ImageFileWriter<ComplexDoubleVectorImageType> ComplexVectorDoubleWriterType; - UInt8WriterType::Pointer m_UInt8Writer; - Int16WriterType::Pointer m_Int16Writer; - UInt16WriterType::Pointer m_UInt16Writer; - Int32WriterType::Pointer m_Int32Writer; - UInt32WriterType::Pointer m_UInt32Writer; - FloatWriterType::Pointer m_FloatWriter; - DoubleWriterType::Pointer m_DoubleWriter; + // UInt8WriterType::Pointer m_UInt8Writer; + // Int16WriterType::Pointer m_Int16Writer; + // UInt16WriterType::Pointer m_UInt16Writer; + // Int32WriterType::Pointer m_Int32Writer; + // UInt32WriterType::Pointer m_UInt32Writer; + // FloatWriterType::Pointer m_FloatWriter; + // DoubleWriterType::Pointer m_DoubleWriter; VectorUInt8WriterType::Pointer m_VectorUInt8Writer; VectorInt16WriterType::Pointer m_VectorInt16Writer; @@ -193,10 +193,10 @@ protected: RGBUInt8WriterType::Pointer m_RGBUInt8Writer; RGBAUInt8WriterType::Pointer m_RGBAUInt8Writer; - ComplexInt16WriterType::Pointer m_ComplexInt16Writer; - ComplexInt32WriterType::Pointer m_ComplexInt32Writer; - ComplexFloatWriterType::Pointer m_ComplexFloatWriter; - ComplexDoubleWriterType::Pointer m_ComplexDoubleWriter; + // ComplexInt16WriterType::Pointer m_ComplexInt16Writer; + // ComplexInt32WriterType::Pointer m_ComplexInt32Writer; + // ComplexFloatWriterType::Pointer m_ComplexFloatWriter; + // ComplexDoubleWriterType::Pointer m_ComplexDoubleWriter; ComplexVectorInt16WriterType::Pointer m_ComplexVectorInt16Writer; ComplexVectorInt32WriterType::Pointer m_ComplexVectorInt32Writer; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 2e76ccfcff..103b05132c 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -152,13 +152,13 @@ OutputImageParameter::ConvertStringToPixelType(const std::string &value, ImagePi void OutputImageParameter::InitializeWriters() { - m_UInt8Writer = UInt8WriterType::New(); - m_Int16Writer = Int16WriterType::New(); - m_UInt16Writer = UInt16WriterType::New(); - m_Int32Writer = Int32WriterType::New(); - m_UInt32Writer = UInt32WriterType::New(); - m_FloatWriter = FloatWriterType::New(); - m_DoubleWriter = DoubleWriterType::New(); + // m_UInt8Writer = UInt8WriterType::New(); + // m_Int16Writer = Int16WriterType::New(); + // m_UInt16Writer = UInt16WriterType::New(); + // m_Int32Writer = Int32WriterType::New(); + // m_UInt32Writer = UInt32WriterType::New(); + // m_FloatWriter = FloatWriterType::New(); + // m_DoubleWriter = DoubleWriterType::New(); m_VectorUInt8Writer = VectorUInt8WriterType::New(); m_VectorInt16Writer = VectorInt16WriterType::New(); @@ -171,10 +171,10 @@ void OutputImageParameter::InitializeWriters() m_RGBUInt8Writer = RGBUInt8WriterType::New(); m_RGBAUInt8Writer = RGBAUInt8WriterType::New(); - m_ComplexInt16Writer = ComplexInt16WriterType::New(); - m_ComplexInt32Writer = ComplexInt32WriterType::New(); - m_ComplexFloatWriter = ComplexFloatWriterType::New(); - m_ComplexDoubleWriter = ComplexDoubleWriterType::New(); + // m_ComplexInt16Writer = ComplexInt16WriterType::New(); + // m_ComplexInt32Writer = ComplexInt32WriterType::New(); + // m_ComplexFloatWriter = ComplexFloatWriterType::New(); + // m_ComplexDoubleWriter = ComplexDoubleWriterType::New(); m_ComplexVectorInt16Writer = ComplexVectorInt16WriterType::New(); m_ComplexVectorInt32Writer = ComplexVectorInt32WriterType::New(); @@ -305,115 +305,115 @@ ClampAndWriteVectorImage( itk::ImageBase<2> * in , } }*/ -template <class TInput> -void -OutputImageParameter::SwitchImageWrite() -{ - switch(m_PixelType ) - { - case ImagePixelType_uint8: - { - ClampAndWriteImage< TInput , UInt8ImageType >( - m_Image , - m_UInt8Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_int16: - { - ClampAndWriteImage< TInput , Int16ImageType >( - m_Image , - m_Int16Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_uint16: - { - ClampAndWriteImage< TInput , UInt16ImageType >( - m_Image , - m_UInt16Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_int32: - { - ClampAndWriteImage< TInput , Int32ImageType >( - m_Image , - m_Int32Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_uint32: - { - ClampAndWriteImage< TInput , UInt32ImageType >( - m_Image , - m_UInt32Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_float: - { - ClampAndWriteImage< TInput , FloatImageType >( - m_Image , - m_FloatWriter , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_double: - { - ClampAndWriteImage< TInput , DoubleImageType >( - m_Image , - m_DoubleWriter , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_cint16: - { - ClampAndWriteImage< TInput , ComplexInt16ImageType >( - m_Image , - m_ComplexInt16Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_cint32: - { - ClampAndWriteImage< TInput , ComplexInt32ImageType >( - m_Image , - m_ComplexInt32Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_cfloat: - { - ClampAndWriteImage< TInput , ComplexFloatImageType >( - m_Image , - m_ComplexFloatWriter , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_cdouble: - { - ClampAndWriteImage< TInput , ComplexDoubleImageType >( - m_Image , - m_ComplexDoubleWriter , - m_FileName , - m_RAMValue ); - break; - } - default: - break; - } -} +// template <class TInput> +// void +// OutputImageParameter::SwitchImageWrite() +// { +// switch(m_PixelType ) +// { +// case ImagePixelType_uint8: +// { +// ClampAndWriteImage< TInput , UInt8ImageType >( +// m_Image , +// m_UInt8Writer , +// m_FileName , +// m_RAMValue ); +// break; +// } +// case ImagePixelType_int16: +// { +// ClampAndWriteImage< TInput , Int16ImageType >( +// m_Image , +// m_Int16Writer , +// m_FileName , +// m_RAMValue ); +// break; +// } +// case ImagePixelType_uint16: +// { +// ClampAndWriteImage< TInput , UInt16ImageType >( +// m_Image , +// m_UInt16Writer , +// m_FileName , +// m_RAMValue ); +// break; +// } +// case ImagePixelType_int32: +// { +// ClampAndWriteImage< TInput , Int32ImageType >( +// m_Image , +// m_Int32Writer , +// m_FileName , +// m_RAMValue ); +// break; +// } +// case ImagePixelType_uint32: +// { +// ClampAndWriteImage< TInput , UInt32ImageType >( +// m_Image , +// m_UInt32Writer , +// m_FileName , +// m_RAMValue ); +// break; +// } +// case ImagePixelType_float: +// { +// ClampAndWriteImage< TInput , FloatImageType >( +// m_Image , +// m_FloatWriter , +// m_FileName , +// m_RAMValue ); +// break; +// } +// case ImagePixelType_double: +// { +// ClampAndWriteImage< TInput , DoubleImageType >( +// m_Image , +// m_DoubleWriter , +// m_FileName , +// m_RAMValue ); +// break; +// } +// case ImagePixelType_cint16: +// { +// ClampAndWriteImage< TInput , ComplexInt16ImageType >( +// m_Image , +// m_ComplexInt16Writer , +// m_FileName , +// m_RAMValue ); +// break; +// } +// case ImagePixelType_cint32: +// { +// ClampAndWriteImage< TInput , ComplexInt32ImageType >( +// m_Image , +// m_ComplexInt32Writer , +// m_FileName , +// m_RAMValue ); +// break; +// } +// case ImagePixelType_cfloat: +// { +// ClampAndWriteImage< TInput , ComplexFloatImageType >( +// m_Image , +// m_ComplexFloatWriter , +// m_FileName , +// m_RAMValue ); +// break; +// } +// case ImagePixelType_cdouble: +// { +// ClampAndWriteImage< TInput , ComplexDoubleImageType >( +// m_Image , +// m_ComplexDoubleWriter , +// m_FileName , +// m_RAMValue ); +// break; +// } +// default: +// break; +// } +// } // template <class TInput> // void @@ -621,47 +621,47 @@ OutputImageParameter::Write() if (dynamic_cast<UInt8ImageType*>(m_Image.GetPointer())) { - SwitchImageWrite<UInt8ImageType>(); + SwitchVectorImageWrite<UInt8ImageType>(); } else if (dynamic_cast<Int16ImageType*>(m_Image.GetPointer())) { - SwitchImageWrite<Int16ImageType>(); + SwitchVectorImageWrite<Int16ImageType>(); } else if (dynamic_cast<UInt16ImageType*>(m_Image.GetPointer())) { - SwitchImageWrite<UInt16ImageType>(); + SwitchVectorImageWrite<UInt16ImageType>(); } else if (dynamic_cast<Int32ImageType*>(m_Image.GetPointer())) { - SwitchImageWrite<Int32ImageType>(); + SwitchVectorImageWrite<Int32ImageType>(); } else if (dynamic_cast<UInt32ImageType*>(m_Image.GetPointer())) { - SwitchImageWrite<UInt32ImageType>(); + SwitchVectorImageWrite<UInt32ImageType>(); } else if (dynamic_cast<FloatImageType*>(m_Image.GetPointer())) { - SwitchImageWrite<FloatImageType>(); + SwitchVectorImageWrite<FloatImageType>(); } else if (dynamic_cast<DoubleImageType*>(m_Image.GetPointer())) { - SwitchImageWrite<DoubleImageType>(); + SwitchVectorImageWrite<DoubleImageType>(); } else if (dynamic_cast<ComplexInt16ImageType*>(m_Image.GetPointer()) ) { - SwitchImageWrite<ComplexInt16ImageType>(); + SwitchVectorImageWrite<ComplexInt16ImageType>(); } else if (dynamic_cast<ComplexInt32ImageType*>(m_Image.GetPointer()) ) { - SwitchImageWrite<ComplexInt32ImageType>(); + SwitchVectorImageWrite<ComplexInt32ImageType>(); } else if (dynamic_cast<ComplexFloatImageType*>(m_Image.GetPointer()) ) { - SwitchImageWrite<ComplexFloatImageType>(); + SwitchVectorImageWrite<ComplexFloatImageType>(); } else if (dynamic_cast<ComplexDoubleImageType*>(m_Image.GetPointer()) ) { - SwitchImageWrite<ComplexDoubleImageType>(); + SwitchVectorImageWrite<ComplexDoubleImageType>(); } else if (dynamic_cast<UInt8VectorImageType*>(m_Image.GetPointer())) { @@ -691,14 +691,6 @@ OutputImageParameter::Write() { SwitchVectorImageWrite<DoubleVectorImageType>(); } - else if (dynamic_cast<UInt8RGBImageType*>(m_Image.GetPointer())) - { - SwitchRGBImageWrite<UInt8RGBImageType>(); - } - else if (dynamic_cast<UInt8RGBAImageType*>(m_Image.GetPointer())) - { - SwitchRGBAImageWrite<UInt8RGBAImageType>(); - } else if (dynamic_cast<ComplexInt16VectorImageType*>(m_Image.GetPointer())) { SwitchVectorImageWrite<ComplexInt16VectorImageType>(); @@ -715,6 +707,14 @@ OutputImageParameter::Write() { SwitchVectorImageWrite<ComplexDoubleVectorImageType>(); } + else if (dynamic_cast<UInt8RGBImageType*>(m_Image.GetPointer())) + { + SwitchRGBImageWrite<UInt8RGBImageType>(); + } + else if (dynamic_cast<UInt8RGBAImageType*>(m_Image.GetPointer())) + { + SwitchRGBAImageWrite<UInt8RGBAImageType>(); + } else { itkExceptionMacro("Unknown image type"); @@ -725,27 +725,27 @@ OutputImageParameter::Write() itk::ProcessObject* OutputImageParameter::GetWriter() { - int type = 0; + int type = 1; // 0 : image // 1 : VectorImage // 2 : RGBAImage // 3 : RGBImage itk::ProcessObject* writer = ITK_NULLPTR; - if (dynamic_cast<UInt8VectorImageType*> (m_Image.GetPointer()) - || dynamic_cast<Int16VectorImageType*> (m_Image.GetPointer()) - || dynamic_cast<UInt16VectorImageType*> (m_Image.GetPointer()) - || dynamic_cast<Int32VectorImageType*> (m_Image.GetPointer()) - || dynamic_cast<UInt32VectorImageType*> (m_Image.GetPointer()) - || dynamic_cast<FloatVectorImageType*> (m_Image.GetPointer()) - || dynamic_cast<DoubleVectorImageType*> (m_Image.GetPointer()) - || dynamic_cast<ComplexInt16VectorImageType*> (m_Image.GetPointer()) - || dynamic_cast<ComplexInt32VectorImageType*> (m_Image.GetPointer()) - || dynamic_cast<ComplexFloatVectorImageType*> (m_Image.GetPointer()) - || dynamic_cast<ComplexDoubleVectorImageType*> (m_Image.GetPointer())) - { - type = 1; - } - else if (dynamic_cast<UInt8RGBAImageType*> (m_Image.GetPointer())) + // if (dynamic_cast<UInt8VectorImageType*> (m_Image.GetPointer()) + // || dynamic_cast<Int16VectorImageType*> (m_Image.GetPointer()) + // || dynamic_cast<UInt16VectorImageType*> (m_Image.GetPointer()) + // || dynamic_cast<Int32VectorImageType*> (m_Image.GetPointer()) + // || dynamic_cast<UInt32VectorImageType*> (m_Image.GetPointer()) + // || dynamic_cast<FloatVectorImageType*> (m_Image.GetPointer()) + // || dynamic_cast<DoubleVectorImageType*> (m_Image.GetPointer()) + // || dynamic_cast<ComplexInt16VectorImageType*> (m_Image.GetPointer()) + // || dynamic_cast<ComplexInt32VectorImageType*> (m_Image.GetPointer()) + // || dynamic_cast<ComplexFloatVectorImageType*> (m_Image.GetPointer()) + // || dynamic_cast<ComplexDoubleVectorImageType*> (m_Image.GetPointer())) + // { + // type = 1; + // } + if (dynamic_cast<UInt8RGBAImageType*> (m_Image.GetPointer())) { type = 2; writer = m_RGBAUInt8Writer; @@ -766,9 +766,9 @@ OutputImageParameter::GetWriter() { switch(type) { - case 0: - writer = m_UInt8Writer; - break; + // case 0: + // writer = m_UInt8Writer; + // break; case 1: writer = m_VectorUInt8Writer; break; @@ -785,80 +785,80 @@ OutputImageParameter::GetWriter() { if (type == 1) writer = m_VectorInt16Writer; - else - if (type == 0) writer = m_Int16Writer; + // else + // if (type == 0) writer = m_Int16Writer; break; } case ImagePixelType_uint16: { if (type == 1) writer = m_VectorUInt16Writer; - else - if (type == 0) writer = m_UInt16Writer; + // else + // if (type == 0) writer = m_UInt16Writer; break; } case ImagePixelType_int32: { if (type == 1) writer = m_VectorInt32Writer; - else - if (type == 0) writer = m_Int32Writer; + // else + // if (type == 0) writer = m_Int32Writer; break; } case ImagePixelType_uint32: { if (type == 1) writer = m_VectorUInt32Writer; - else - if (type == 0) writer = m_UInt32Writer; + // else + // if (type == 0) writer = m_UInt32Writer; break; } case ImagePixelType_float: { if (type == 1) writer = m_VectorFloatWriter; - else - if (type == 0) writer = m_FloatWriter; + // else + // if (type == 0) writer = m_FloatWriter; break; } case ImagePixelType_double: { if (type == 1) writer = m_VectorDoubleWriter; - else - if (type == 0) writer = m_DoubleWriter; + // else + // if (type == 0) writer = m_DoubleWriter; break; } case ImagePixelType_cint16: { if( type == 1 ) writer = m_ComplexVectorInt16Writer; - else - writer = m_ComplexInt16Writer; + // else + // writer = m_ComplexInt16Writer; break; } case ImagePixelType_cint32: { if( type == 1 ) writer = m_ComplexVectorInt32Writer; - else - writer = m_ComplexInt32Writer; + // else + // writer = m_ComplexInt32Writer; break; } case ImagePixelType_cfloat: { if( type == 1 ) writer = m_ComplexVectorFloatWriter; - else - writer = m_ComplexFloatWriter; + // else + // writer = m_ComplexFloatWriter; break; } case ImagePixelType_cdouble: { if( type == 1 ) writer = m_ComplexVectorDoubleWriter; - else - writer = m_ComplexDoubleWriter; + // else + // writer = m_ComplexDoubleWriter; break; } } -- GitLab From 10dc64898251a696802d9ad2ff0e023e69eee8e7 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 14 Dec 2017 10:24:45 +0100 Subject: [PATCH 156/567] DOC: fix applications doc --- .../app/otbTrainDimensionalityReduction.cxx | 22 +++++++++++++++++-- .../app/otbVectorDimensionalityReduction.cxx | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx index df735345a1..1cbc567c56 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx @@ -71,8 +71,18 @@ private: void DoInit() { SetName("TrainDimensionalityReduction"); - SetDescription("Trainer for the dimensionality reduction algorithms used in" - " the ImageDimensionalityReduction and VectorDimensionalityReduction applications."); + SetDescription("Train a dimensionality reduction model"); + + SetDocName("Train Dimensionality Reduction"); + SetDocLongDescription("Trainer for dimensionality reduction algorithms " + "(autoencoders, PCA, SOM). All input samples are used to compute the " + "model, like other machine learning models.\n" + "The model can be used in the ImageDimensionalityReduction and " + "VectorDimensionalityReduction applications."); + + SetDocLimitations("None"); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso("ImageDimensionalityReduction, VectorDimensionalityReduction"); AddParameter(ParameterType_Group, "io", "Input and output data"); SetParameterDescription("io", "This group of parameters allows setting input and output data."); @@ -95,6 +105,14 @@ private: Superclass::DoInit(); AddRAMParameter(); + + // Doc example parameter settings + SetDocExampleParameterValue("io.vd", "cuprite_samples.sqlite"); + SetDocExampleParameterValue("io.out", "mode.ae"); + SetDocExampleParameterValue("algorithm", "pca"); + SetDocExampleParameterValue("algorithm.pca.dim", "8"); + SetDocExampleParameterValue("feat","value_0 value_1 value_2 value_3 value_4" + " value_5 value_6 value_7 value_8 value_9"); } void DoUpdateParameters() diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx index dd4e89097b..c34039180f 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx @@ -92,6 +92,7 @@ private: "dimensionality reduction based on a model file produced by the " "TrainDimensionalityReduction application."); SetDocSeeAlso("TrainDimensionalityReduction"); + SetDocLimitations("None"); AddDocTag(Tags::Learning); AddParameter(ParameterType_InputVectorData, "in", "Name of the input vector data"); -- GitLab From 46932bb0ecb56022d0299621a1f7976f1290bcb2 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 14 Dec 2017 10:26:19 +0100 Subject: [PATCH 157/567] BUG: add typename before dependent using declaration resolved to type --- Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h b/Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h index 29ed2b3fee..1cfdd2bf16 100644 --- a/Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h +++ b/Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h @@ -36,7 +36,7 @@ class DefaultConvertPixelTraits { public: typedef itk::DefaultConvertPixelTraits < PixelType > SuperClass; - using SuperClass::ComponentType; + using typename SuperClass::ComponentType; using SuperClass::SetNthComponent; -- GitLab From 91eb09fbcfc5617ea673045af37051c75624a1dd Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 14 Dec 2017 11:21:55 +0100 Subject: [PATCH 158/567] REFAC: use clampfilter instead of other, remove some includes --- .../AppOpticalCalibration/app/otbOpticalCalibration.cxx | 4 ++-- .../AppSARDecompositions/app/otbSARDecompositions.cxx | 2 +- .../src/otbWrapperOutputImageParameter.cxx | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx index 87e7dc310f..829c4f3052 100644 --- a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx +++ b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx @@ -29,7 +29,7 @@ #include "otbReflectanceToRadianceImageFilter.h" #include "otbReflectanceToSurfaceReflectanceImageFilter.h" #include "itkMultiplyImageFilter.h" -#include "otbClampVectorImageFilter.h" +#include "otbClampImageFilter.h" #include "otbSurfaceAdjacencyEffectCorrectionSchemeFilter.h" #include "otbGroundSpacingImageFunction.h" #include "vnl/vnl_random.h" @@ -92,7 +92,7 @@ public: typedef itk::MultiplyImageFilter<DoubleVectorImageType,DoubleImageType,DoubleVectorImageType> ScaleFilterOutDoubleType; - typedef otb::ClampVectorImageFilter<DoubleVectorImageType, + typedef otb::ClampImageFilter<DoubleVectorImageType, DoubleVectorImageType> ClampFilterType; typedef ReflectanceToSurfaceReflectanceImageFilter<DoubleVectorImageType, diff --git a/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx index be25e1d35c..796d3f4e26 100644 --- a/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx +++ b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx @@ -31,7 +31,7 @@ #include "otbSinclairToReciprocalCoherencyMatrixFunctor.h" #include "otbPerBandVectorImageFilter.h" #include "itkMeanImageFilter.h" -#include "otbNRIBandImagesToOneNComplexBandsImage.h" +// #include "otbNRIBandImagesToOneNComplexBandsImage.h" #include "otbImageListToVectorImageFilter.h" #include "otbImageList.h" diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 103b05132c..24307b58da 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -20,11 +20,11 @@ #include "otbWrapperOutputImageParameter.h" #include "otbClampImageFilter.h" -#include "itkCastImageFilter.h" -#include "otbClampVectorImageFilter.h" +// #include "itkCastImageFilter.h" +// #include "otbClampVectorImageFilter.h" #include "otbImageIOFactory.h" #include "itksys/SystemTools.hxx" -#include "otbTwoNRIBandsImageToNComplexBandsImage.h" +// #include "otbTwoNRIBandsImageToNComplexBandsImage.h" #ifdef OTB_USE_MPI -- GitLab From 7381d43f1a0f308c5c8bd249dcf57a5be9345890 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 14 Dec 2017 15:29:58 +0100 Subject: [PATCH 159/567] ENH: check m_Model early during update --- .../include/otbImageDimensionalityReductionFilter.txx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx index 2656e21e1f..140a8cd874 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.txx @@ -82,10 +82,6 @@ void ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> ::BeforeThreadedGenerateData() { - if (!m_Model) - { - itkGenericExceptionMacro(<< "No model for classification"); - } if(m_BatchMode) { #ifdef _OPENMP @@ -129,7 +125,11 @@ template <class TInputImage, class TOutputImage, class TMaskImage> void ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage>::GenerateOutputInformation() { Superclass::GenerateOutputInformation(); - this->GetOutput()->SetNumberOfComponentsPerPixel( m_Model->GetDimension() ); + if (!m_Model) + { + itkGenericExceptionMacro(<< "No model for dimensionality reduction"); + } + this->GetOutput()->SetNumberOfComponentsPerPixel( m_Model->GetDimension() ); } template <class TInputImage, class TOutputImage, class TMaskImage> -- GitLab From 4164dbe09848de2adff66fe679f29d6072b88f62 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 14 Dec 2017 15:31:02 +0100 Subject: [PATCH 160/567] ENH: display dimension of model --- .../app/otbImageDimensionalityReduction.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx index e628b951a7..c221302c03 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx @@ -207,7 +207,7 @@ private: } m_Model->Load(GetParameterString("model")); - otbAppLogINFO("Model loaded"); + otbAppLogINFO("Model loaded, dimension = "<< m_Model->GetDimension()); // Classify m_ClassificationFilter = DimensionalityReductionFilterType::New(); @@ -216,7 +216,7 @@ private: FloatVectorImageType::Pointer outputImage = m_ClassificationFilter->GetOutput(); // Normalize input image if asked - if( IsParameterEnabled("imstat") ) + if( IsParameterEnabled("imstat") && HasValue("imstat") ) { otbAppLogINFO("Input image normalization activated."); // Normalize input image (optional) -- GitLab From 4c1a32f77a6b15206551c4ebd51e75c0c14106f7 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 14 Dec 2017 15:32:34 +0100 Subject: [PATCH 161/567] BUG: wrong dimension detected when reading AE model --- .../include/otbAutoencoderModel.txx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index 96eb2aa76e..33f1c28e24 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -179,6 +179,7 @@ AutoencoderModel<TInputValue,NeuronType> shark::MaxIterations<> criterion(m_NumberOfIterationsFineTuning); TrainNetwork(criterion, inputSamples_copy, ofs); } + this->SetDimension(m_NumberOfHiddenNeurons[m_NumberOfHiddenNeurons.Size()-1]); } template <class TInputValue, class NeuronType> @@ -387,8 +388,8 @@ AutoencoderModel<TInputValue,NeuronType> // This gives us the dimension if we keep the encoder and decoder size_t feature_layer_index = m_Net.layerMatrices().size()/2; - // number of neurons in the feature layer (first dimension of the first decoder weight matrix) - this->m_Dimension = m_Net.layerMatrix(feature_layer_index).size1(); + // number of neurons in the feature layer (second dimension of the first decoder weight matrix) + this->SetDimension(m_Net.layerMatrix(feature_layer_index).size2()); } template <class TInputValue, class NeuronType> @@ -407,7 +408,8 @@ AutoencoderModel<TInputValue,NeuronType> shark::Data<shark::RealVector> data = shark::createDataFromRange(features); - data = m_Net.evalLayer( m_Net.layerMatrices().size()/2-1 ,data); // features layer for a network containing the encoder and decoder part + // features layer for a network containing the encoder and decoder part + data = m_Net.evalLayer( m_Net.layerMatrices().size()/2-1 ,data); TargetSampleType target; target.SetSize(this->m_Dimension); @@ -432,7 +434,8 @@ AutoencoderModel<TInputValue,NeuronType> Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); shark::Data<shark::RealVector> data = shark::createDataFromRange(features); TargetSampleType target; - data = m_Net.evalLayer( m_Net.layerMatrices().size()/2-1 ,data); // features layer for a network containing the encoder and decoder part + // features layer for a network containing the encoder and decoder part + data = m_Net.evalLayer( m_Net.layerMatrices().size()/2-1 ,data); unsigned int id = startIndex; target.SetSize(this->m_Dimension); -- GitLab From 96343fafddf8a2f8bc09562e1086a4b891408c9c Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 14 Dec 2017 16:59:54 +0100 Subject: [PATCH 162/567] REFAC: refact ConvertTypeFunctor --- .../include/otbConvertTypeFunctor.h | 63 ++++++++++--------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h index bb2da54df7..f3cb4b0682 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h @@ -58,15 +58,11 @@ public: else m_Scal = m_CompIn; if ( m_cOutPix || m_cOutInternalPix ) - { - m_CompOut = ( sizeIn + 1 ) / 2 ; // ( sizeIn + 1 )/ 2 - return m_CompOut ; - } + m_CompOut = ( sizeIn + 1 ) / 2 ; else - { m_CompOut = sizeIn ; - return m_CompOut ; - } + + return m_CompOut ; } void SetLowest( OutputPixelValueType & lowest ) @@ -93,10 +89,6 @@ public: m_cOutPix = boost::is_complex < OutputPixelType > :: value ; m_cInInternalPix = boost::is_complex < InputInternalPixelType > :: value ; m_cOutInternalPix = boost::is_complex < OutputInternalPixelType > :: value ; - m_MultiCompIn = ! ( boost::is_complex < InputPixelType > :: value ) - || ! ( boost::is_scalar < InputPixelType > :: value) ; - m_MultiCompOut = ! ( boost::is_complex < OutputPixelType > :: value ) - || ! ( boost::is_scalar < OutputPixelType > :: value); } @@ -110,9 +102,11 @@ public: Clamp( vPixel ); OutputPixelType out; int hack = 1; - if ( m_cOutPix && !m_MultiCompOut ) - hack += 1; // needed in case we have OutputPixelType == complex<t> as SetLength() will ask a length of 2! - itk::NumericTraits < OutputPixelType > :: SetLength( out , hack * m_CompOut ); + if ( m_cOutPix && m_CompOut == 1 ) + hack += 1; // needed in case we have OutputPixelType == complex<t> as + // itk::NumericTraits::SetLength() will ask a length of 2! + itk::NumericTraits < OutputPixelType > :: SetLength( out , + hack * m_CompOut ); for ( unsigned int i = 0 ; i < m_CompOut ; i ++) FillOut < OutputPixelType > ( i , out , vPixel ); return out; @@ -123,16 +117,20 @@ public: protected: template <class PixelType , - std::enable_if_t < std::is_arithmetic < PixelType > ::value , int > = 2 > - void FillIn( unsigned int i , InputPixelType const & pix , std::vector < double > & vPix ) const + std::enable_if_t < std::is_arithmetic < PixelType > ::value , int > = 0 > + void FillIn( unsigned int i , + InputPixelType const & pix , + std::vector < double > & vPix ) const { vPix.push_back( DefaultConvertPixelTraits < InputPixelType > :: GetNthComponent( i , pix ) ); } template <class PixelType , - std::enable_if_t < boost::is_complex < PixelType > :: value , int > = 1 > - void FillIn( unsigned int i , InputPixelType const & pix , std::vector < double > & vPix ) const + std::enable_if_t < boost::is_complex < PixelType > :: value , int > = 0 > + void FillIn( unsigned int i , + InputPixelType const & pix , + std::vector < double > & vPix ) const { PixelType comp = DefaultConvertPixelTraits < InputPixelType > :: GetNthComponent( i , pix ); @@ -141,8 +139,11 @@ protected: } template <class PixelType , - std::enable_if_t < !( boost::is_complex < PixelType > :: value || std::is_arithmetic < PixelType > ::value ) , int > = 0 > - void FillIn( unsigned int i , InputPixelType const & pix , std::vector < double > & vPix ) const + std::enable_if_t < !( boost::is_complex < PixelType > :: value + || std::is_arithmetic < PixelType > ::value ) , int > = 0 > + void FillIn( unsigned int i , + InputPixelType const & pix , + std::vector < double > & vPix ) const { FillIn < InputInternalPixelType > ( i , pix , vPix ); } @@ -160,16 +161,20 @@ protected: } template <class PixelType , - std::enable_if_t < std::is_arithmetic < PixelType > ::value , int > = 2 > - void FillOut( unsigned int i , OutputPixelType & pix , std::vector < double > & vPix ) const + std::enable_if_t < std::is_arithmetic < PixelType > ::value , int > = 0 > + void FillOut( unsigned int i , + OutputPixelType & pix , + std::vector < double > & vPix ) const { DefaultConvertPixelTraits < OutputPixelType > :: SetNthComponent( i , pix , vPix[i] ); } template <class PixelType , - std::enable_if_t < boost::is_complex < PixelType > :: value , int > = 1 > - void FillOut( unsigned int i , OutputPixelType & pix , std::vector < double > & vPix ) const + std::enable_if_t < boost::is_complex < PixelType > :: value , int > = 0 > + void FillOut( unsigned int i , + OutputPixelType & pix , + std::vector < double > & vPix ) const { DefaultConvertPixelTraits < OutputPixelType > :: SetNthComponent( i , pix , @@ -177,8 +182,11 @@ protected: } template <class PixelType , - std::enable_if_t < !( boost::is_complex < PixelType > :: value || std::is_arithmetic < PixelType > ::value ) , int > = 0 > - void FillOut( unsigned int i , OutputPixelType & pix , std::vector < double > & vPix ) const + std::enable_if_t < !( boost::is_complex < PixelType > :: value + || std::is_arithmetic < PixelType > ::value ) , int > = 0 > + void FillOut( unsigned int i , + OutputPixelType & pix , + std::vector < double > & vPix ) const { FillOut < OutputInternalPixelType > ( i , pix , vPix ); } @@ -190,8 +198,7 @@ private: double m_LowestBD , m_HighestBD ; OutputPixelValueType m_LowestB , m_HighestB ; unsigned int m_CompIn , m_CompOut , m_Scal ; - bool m_cInPix , m_cInInternalPix , m_cOutPix , m_cOutInternalPix , - m_MultiCompIn , m_MultiCompOut ; + bool m_cInPix , m_cInInternalPix , m_cOutPix , m_cOutInternalPix ; }; -- GitLab From 3f5c0189a778a9bda71269b489de4227654e1b4f Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 15 Dec 2017 10:53:43 +0100 Subject: [PATCH 163/567] STYLE: indentation --- .../DimensionalityReductionLearning/include/otbPCAModel.txx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx index dcc6b00ea2..9f39326a21 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx @@ -162,8 +162,8 @@ PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueT shark::Data<shark::RealVector> data = shark::createDataFromRange(features); data = m_Encoder(data); - TargetSampleType target; - target.SetSize(this->m_Dimension); + TargetSampleType target; + target.SetSize(this->m_Dimension); for(unsigned int a = 0; a < this->m_Dimension; ++a){ target[a]=data.element(0)[a]; -- GitLab From 5a7fc8efbd1f41035297f648ad0a58a3e3857b85 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 15 Dec 2017 10:58:41 +0100 Subject: [PATCH 164/567] ENH: rework some parameters for simpler interface --- .../app/otbVectorDimensionalityReduction.cxx | 150 ++++++++++++------ 1 file changed, 98 insertions(+), 52 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx index c34039180f..132e13875c 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx @@ -108,38 +108,51 @@ private: SetParameterDescription("model", "A model file (produced by the " "TrainDimensionalityReduction application,"); - AddParameter(ParameterType_ListView, "feat", "Input features to use for reduction."); // - SetParameterDescription("feat","List of field names in the input vector " - "data used as features for reduction."); // - - AddParameter(ParameterType_StringList, "featout", "Names of the new output features."); // - SetParameterDescription("featout","List of field names for the output " - "features which result from the reduction."); // - AddParameter(ParameterType_OutputFilename, "out", "Output vector data file " "containing the reduced vector"); SetParameterDescription("out","Output vector data file storing sample " "values (OGR format). If not given, the input vector data file is used. " "In overwrite mode, the original features will be lost."); MandatoryOff("out"); - - AddParameter(ParameterType_Int, "indim", "Dimension of the input vector"); - SetParameterDescription("indim","Dimension of the whole input vector, this " - "value is required if only a part of the bands contained in the vector " - "are used. If not given, the dimension is deduced from the length of the " - "'feat' parameter"); - MandatoryOff("indim"); - - AddParameter(ParameterType_Int, "pcadim", "Principal component"); // + + AddParameter(ParameterType_ListView, "feat", "Input features to use for reduction."); // + SetParameterDescription("feat","List of field names in the input vector " + "data used as features for reduction."); // + + AddParameter(ParameterType_Choice, "featout", "Output feature"); // + SetParameterDescription("featout", "Naming of output features"); + + AddChoice("featout.prefix", "Prefix"); + SetParameterDescription("featout.prefix", "Use a name prefix"); + + AddParameter(ParameterType_String, "featout.prefix.name", "Feature name prefix"); + SetParameterDescription("featout.prefix.name","Name prefix for output " + "features. This prefix is followed by the numeric index of each output feature."); + SetParameterString("featout.prefix.name","reduced_", false); + + AddChoice("featout.list","List"); + SetParameterDescription("featout.list", "Use a list with all names"); + + AddParameter(ParameterType_StringList, "featout.list.names", "Feature name list"); + SetParameterDescription("featout.list.names","List of field names for the output " + "features which result from the reduction."); // + + AddParameter(ParameterType_Int, "pcadim", "Principal component dimension"); // SetParameterDescription("pcadim","This optional parameter can be set to " - "reduce the number of eignevectors used in the PCA model file."); // + "reduce the number of eignevectors used in the PCA model file. This " + "parameter can't be used for other models"); // MandatoryOff("pcadim"); - AddParameter(ParameterType_String, "mode", "Writting mode"); // - SetParameterString("mode","overwrite", false); - SetParameterDescription("mode","This parameter determines if the output " + AddParameter(ParameterType_Choice, "mode", "Writting mode"); // + SetParameterDescription("mode", "This parameter determines if the output " "file is overwritten or updated [overwrite/update]. If an output file " - "name is given, the original file is copied before creating the new features."); // + "name is given, the original file is copied before creating the new features."); + + AddChoice("mode.overwrite", "Overwrite"); + SetParameterDescription("mode.overwrite","Overwrite mode"); // + + AddChoice("mode.update", "Update"); + SetParameterDescription("mode.update", "Update mode"); // Doc example parameter settings SetDocExampleParameterValue("in", "vectorData.shp"); @@ -147,7 +160,6 @@ private: SetDocExampleParameterValue("model", "model.txt"); SetDocExampleParameterValue("out", "vectorDataOut.shp"); SetDocExampleParameterValue("feat", "perimeter area width"); - SetDocExampleParameterValue("featout", "perimeter area width"); //SetOfficialDocLink(); } @@ -185,12 +197,23 @@ private: shapefile, otb::ogr::DataSource::Modes::Read); otb::ogr::Layer layer = source->GetLayer(0); ListSampleType::Pointer input = ListSampleType::New(); - int nbFeatures = GetSelectedItems("feat").size(); + std::vector<int> inputIndexes = GetSelectedItems("feat"); + int nbFeatures = inputIndexes.size(); input->SetMeasurementVectorSize(nbFeatures); otb::ogr::Layer::const_iterator it = layer.cbegin(); otb::ogr::Layer::const_iterator itEnd = layer.cend(); + // Get the list of non-selected field indexes + // /!\ The 'feat' is assumed to expose all available fields, hence the + // mapping between GetSelectedItems() and OGR field indexes + OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); + std::set<int> otherInputFields; + for (int i=0 ; i < inLayerDefn.GetFieldCount() ; i++) + otherInputFields.insert(i); + for (int k=0 ; k < nbFeatures ; k++) + otherInputFields.erase(inputIndexes[k]); + for( ; it!=itEnd ; ++it) { MeasurementType mv; @@ -198,7 +221,7 @@ private: for(int idx=0; idx < nbFeatures; ++idx) { - mv[idx] = static_cast<float>( (*it)[GetSelectedItems("feat")[idx]].GetValue<double>() ); + mv[idx] = static_cast<float>( (*it)[inputIndexes[idx]].GetValue<double>() ); } input->PushBack(mv); } @@ -214,6 +237,8 @@ private: statisticsReader->SetFileName(XMLfile); meanMeasurementVector = statisticsReader->GetStatisticVectorByName("mean"); stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); + otbAppLogINFO("Mean used: " << meanMeasurementVector); + otbAppLogINFO("Standard deviation used: " << stddevMeasurementVector); } else { @@ -228,10 +253,8 @@ private: trainingShiftScaleFilter->SetShifts(meanMeasurementVector); trainingShiftScaleFilter->SetScales(stddevMeasurementVector); trainingShiftScaleFilter->Update(); - otbAppLogINFO("mean used: " << meanMeasurementVector); - otbAppLogINFO("standard deviation used: " << stddevMeasurementVector); - otbAppLogINFO("Loading model"); + otbAppLogINFO("Loading model"); /** Read the model */ m_Model = DimensionalityReductionModelFactoryType::CreateDimensionalityReductionModel( GetParameterString("model"), @@ -241,14 +264,17 @@ private: otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") << " : unsupported model type"); } + m_Model->Load(GetParameterString("model")); if (HasValue("pcadim") && IsParameterEnabled("pcadim")) { - int dimension = GetParameterInt("pcadim"); - m_Model->SetDimension(dimension ); + std::string modelName(m_Model->GetNameOfClass()); + if (modelName != "PCAModel") + { + otbAppLogFATAL(<< "Can't set 'pcadim' on a model : "<< modelName); + } + m_Model->SetDimension( GetParameterInt("pcadim") ); } - - m_Model->Load(GetParameterString("model")); - otbAppLogINFO("Model loaded"); + otbAppLogINFO("Model loaded, dimension : "<< m_Model->GetDimension()); /** Perform Dimensionality Reduction */ ListSampleType::Pointer listSample = trainingShiftScaleFilter->GetOutput(); @@ -259,12 +285,6 @@ private: ogr::DataSource::Pointer buffer = ogr::DataSource::New(); bool updateMode = false; - int nbBands = nbFeatures; - if (HasValue("indim") && IsParameterEnabled("indim")) - { - nbBands = GetParameterInt("indim"); - } - if (IsParameterEnabled("out") && HasValue("out")) { // Create new OGRDataSource @@ -275,9 +295,8 @@ private: GetParameterString("out"), const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), layer.GetGeomType()); - // Copy existing fields - OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); - for (int k=0 ; k<inLayerDefn.GetFieldCount()-nbBands ; k++) // we don't copy the original bands + // Copy existing fields except the ones selected for reduction + for (const int& k : otherInputFields) { OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); newLayer.CreateField(fieldDefn); @@ -315,24 +334,53 @@ private: if (errStart != OGRERR_NONE) { - itkExceptionMacro(<< "Unable to start transaction for OGR layer " << outLayer.ogr().GetName() << "."); + otbAppLogFATAL(<< "Unable to start transaction for OGR layer " << outLayer.ogr().GetName() << "."); + } + + // Build the list of output fields + std::vector<std::string> outFields; + if(GetParameterString("featout") == "prefix") + { + std::string prefix = GetParameterString("featout.prefix.name"); + std::ostringstream oss; + for (unsigned int i=0 ; i < m_Model->GetDimension() ; i++) + { + oss.str(prefix); + oss.seekp(0,std::ios_base::end); + oss << i; + outFields.push_back(oss.str()); + } + } + else if(GetParameterString("featout") == "list") + { + outFields = GetParameterStringList("featout.list.names"); + if (outFields.size() != m_Model->GetDimension()) + { + otbAppLogFATAL( << "Wrong number of output field names, expected " + << m_Model->GetDimension() << " , got "<< outFields.size()); + } + } + else + { + otbAppLogFATAL( << "Unsupported output feature mode : " + << GetParameterString("featout")); } // Add the field of prediction in the output layer if field not exist - for (unsigned int i=0; i<GetParameterStringList("featout").size() ;i++) + for (unsigned int i=0; i<outFields.size() ;i++) { OGRFeatureDefn &layerDefn = outLayer.GetLayerDefn(); - int idx = layerDefn.GetFieldIndex(GetParameterStringList("featout")[i].c_str()); + int idx = layerDefn.GetFieldIndex(outFields[i].c_str()); if (idx >= 0) { if (layerDefn.GetFieldDefn(idx)->GetType() != OFTReal) - itkExceptionMacro("Field name "<< GetParameterStringList("featout")[i] + otbAppLogFATAL("Field name "<< outFields[i] << " already exists with a different type!"); } else { - OGRFieldDefn predictedField(GetParameterStringList("featout")[i].c_str(), OFTReal); + OGRFieldDefn predictedField(outFields[i].c_str(), OFTReal); ogr::FieldDefn predictedFieldDef(predictedField); outLayer.CreateField(predictedFieldDef); } @@ -340,10 +388,8 @@ private: // Fill output layer unsigned int count=0; - auto classfieldname = GetParameterStringList("featout"); it = layer.cbegin(); itEnd = layer.cend(); - for( ; it!=itEnd ; ++it, ++count) { ogr::Feature dstFeature(outLayer.GetLayerDefn()); @@ -351,9 +397,9 @@ private: dstFeature.SetFrom( *it , TRUE); dstFeature.SetFID(it->GetFID()); - for (std::size_t i=0; i<classfieldname.size(); ++i) + for (std::size_t i=0; i<outFields.size(); ++i) { - dstFeature[classfieldname[i]].SetValue<double>(target->GetMeasurementVector(count)[i]); + dstFeature[outFields[i]].SetValue<double>(target->GetMeasurementVector(count)[i]); } if (updateMode) { @@ -370,7 +416,7 @@ private: const OGRErr errCommitX = outLayer.ogr().CommitTransaction(); if (errCommitX != OGRERR_NONE) { - itkExceptionMacro(<< "Unable to commit transaction for OGR layer " << + otbAppLogFATAL(<< "Unable to commit transaction for OGR layer " << outLayer.ogr().GetName() << "."); } } -- GitLab From 7592e7702bfc4be577f2680b17dc996c5b08afc0 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 15 Dec 2017 10:59:26 +0100 Subject: [PATCH 165/567] TEST: new tests for DR applications --- .../test/CMakeLists.txt | 67 +++++++++++++++---- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/test/CMakeLists.txt b/Modules/Applications/AppDimensionalityReduction/test/CMakeLists.txt index 01f055c417..0ec91c9979 100644 --- a/Modules/Applications/AppDimensionalityReduction/test/CMakeLists.txt +++ b/Modules/Applications/AppDimensionalityReduction/test/CMakeLists.txt @@ -38,15 +38,58 @@ otb_test_application(NAME apTvFEDimensionalityReductionPCA ${BASELINE}/bfTvPCAImageFilter3.tif ${TEMP}/apTvChDimensionalityReductionPCA.tif) -#----------- TrainDimensionalityReduction TESTS ---------------- -otb_test_application(NAME apTvDrTrainDimensionalityReductionAE - APP TrainDimensionalityReduction - OPTIONS -io.vd ${INPUTDATA}/cuprite_samples.sqlite - -io.out ${TEMP}/cuprite_DRModel.ae - -feat value_0 value_1 value_2 value_3 value_4 value_5 value_6 value_7 value_8 value_9 - -algorithm autoencoder - -algorithm.autoencoder.nbneuron 8 - -algorithm.autoencoder.regularization 0.01 - -algorithm.autoencoder.noise 0 - -algorithm.autoencoder.rho 0 - -algorithm.autoencoder.beta 0) +#------------------------------------------------------------------------------- +set(algos ae pca som) + +set(ae_params +-algorithm autoencoder +-algorithm.autoencoder.nbneuron 8 +-algorithm.autoencoder.regularization 0.01 +-algorithm.autoencoder.noise 0 +-algorithm.autoencoder.rho 0 +-algorithm.autoencoder.beta 0) + +set(pca_params +-algorithm pca +-algorithm.pca.dim 8) + +set(som_params +-algorithm som +-algorithm.som.s 10 10 +-algorithm.som.n 3 3 +-algorithm.som.ni 10) + +foreach(algo ${algos}) + string(TOUPPER ${algo} ualgo) + #------------------ TrainDimensionalityReduction TESTS------------------------ + otb_test_application(NAME apTvDrTrainDimensionalityReduction${ualgo} + APP TrainDimensionalityReduction + OPTIONS -io.vd ${INPUTDATA}/cuprite_samples.sqlite + -io.out ${TEMP}/cuprite_DRModel.${algo} + -io.stats ${INPUTDATA}/cupriteStats.xml + -feat value_0 value_1 value_2 value_3 value_4 value_5 value_6 value_7 value_8 value_9 + ${${algo}_params}) + + #------------------ ImageDimensionalityReduction TESTS------------------------ + otb_test_application(NAME apTvDrImageDimensionalityReduction${ualgo} + APP ImageDimensionalityReduction + OPTIONS -in ${INPUTDATA}/cupriteSubHsi.tif + -model ${TEMP}/cuprite_DRModel.${algo} + -imstat ${INPUTDATA}/cupriteStats.xml + -out ${TEMP}/cupriteReduced_${algo}.tif) + + set_tests_properties( apTvDrImageDimensionalityReduction${ualgo} + PROPERTIES DEPENDS apTvDrTrainDimensionalityReduction${ualgo}) + + #------------------ VectorDimensionalityReduction TESTS----------------------- + otb_test_application(NAME apTvDrVectorDimensionalityReduction${ualgo} + APP VectorDimensionalityReduction + OPTIONS -in ${INPUTDATA}/cuprite_samples.sqlite + -model ${TEMP}/cuprite_DRModel.${algo} + -instat ${INPUTDATA}/cupriteStats.xml + -out ${TEMP}/cupriteReduced_${algo}.sqlite + -feat value_0 value_1 value_2 value_3 value_4 value_5 value_6 value_7 value_8 value_9) + + set_tests_properties( apTvDrVectorDimensionalityReduction${ualgo} + PROPERTIES DEPENDS apTvDrTrainDimensionalityReduction${ualgo}) +endforeach() -- GitLab From e4eb0ded13ec3f89aa01dbb22573171ae4c8e33c Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 15 Dec 2017 11:39:13 +0100 Subject: [PATCH 166/567] ENH: add clampfilter use and cint16, cint32 to complex image parameter --- .../otbWrapperComplexInputImageParameter.h | 32 +- .../otbWrapperComplexInputImageParameter.txx | 43 ++- .../otbWrapperComplexOutputImageParameter.h | 13 +- .../otbWrapperComplexInputImageParameter.cxx | 20 +- .../otbWrapperComplexOutputImageParameter.cxx | 144 ++++++-- .../src/otbWrapperOutputImageParameter.cxx | 335 +++++++++--------- ...perQtWidgetComplexOutputImageParameter.cxx | 2 + 7 files changed, 347 insertions(+), 242 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h index 938736eb14..6c6d96c07e 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h @@ -60,9 +60,13 @@ public: ComplexFloatVectorImageType* GetImage(); /** Get the input image as XXXImageType */ + ComplexInt16ImageType* GetComplexInt16Image(); + ComplexInt32ImageType* GetComplexInt32Image(); ComplexFloatImageType* GetComplexFloatImage(); ComplexDoubleImageType* GetComplexDoubleImage(); + ComplexInt16VectorImageType* GetComplexInt16VectorImage(); + ComplexInt32VectorImageType* GetComplexInt32VectorImage(); ComplexFloatVectorImageType* GetComplexFloatVectorImage(); ComplexDoubleVectorImageType* GetComplexDoubleVectorImage(); @@ -104,12 +108,12 @@ the macro otbGetParameterImageMacro of otbWrapperApplication.h */ /** Cast an image to an image of the same type * Image to Image, VectorImage to VectorImage, RGBAImage to RGBAImage. */ - template <class TComplexInputImage, class TOutputImage> - TOutputImage* SimpleCastImage(); + // template <class TComplexInputImage, class TOutputImage> + // TOutputImage* SimpleCastImage(); /** Cast an image to a vector image. */ - template <class TComplexInputImage, class TOutputImage> - TOutputImage* CastVectorImageFromImage(); + // template <class TComplexInputImage, class TOutputImage> + // TOutputImage* CastVectorImageFromImage(); bool HasValue() const ITK_OVERRIDE; @@ -128,8 +132,8 @@ protected: /** Readers typedefs */ - typedef otb::ImageFileReader<ComplexFloatImageType> ComplexFloatReaderType; - typedef otb::ImageFileReader<ComplexDoubleImageType> ComplexDoubleReaderType; + // typedef otb::ImageFileReader<ComplexFloatImageType> ComplexFloatReaderType; + // typedef otb::ImageFileReader<ComplexDoubleImageType> ComplexDoubleReaderType; typedef otb::ImageFileReader<ComplexFloatVectorImageType> ComplexFloatVectorReaderType; typedef otb::ImageFileReader<ComplexDoubleVectorImageType> ComplexDoubleVectorReaderType; @@ -153,28 +157,28 @@ private: // template specializations of CastImage<> should be declared in header // so that the linker knows they exist when building OTB Applications -#define otbDefineCastImageMacro(ComplexInputImageType, OutputImageType) \ +/*#define otbDefineCastImageMacro(ComplexInputImageType, OutputImageType) \ template<> OutputImageType * \ ComplexInputImageParameter::CastImage<ComplexInputImageType , OutputImageType>(); \ #define otbGenericDefineCastImageMacro(ComplexInputImageType, prefix) \ otbDefineCastImageMacro(ComplexInputImageType, ComplexFloat##prefix##ImageType) \ otbDefineCastImageMacro(ComplexInputImageType, ComplexDouble##prefix##ImageType) +*/ - -/********************************************************************* +/******************************************************************** ********************** Image -> Image -**********************************************************************/ +*********************************************************************/ - otbGenericDefineCastImageMacro(ComplexFloatImageType, ) - otbGenericDefineCastImageMacro(ComplexDoubleImageType, ) +// otbGenericDefineCastImageMacro(ComplexFloatImageType, ) +// otbGenericDefineCastImageMacro(ComplexDoubleImageType, ) /********************************************************************* ********************** VectorImage -> VectorImage **********************************************************************/ - otbGenericDefineCastImageMacro(ComplexFloatVectorImageType, Vector) - otbGenericDefineCastImageMacro(ComplexDoubleVectorImageType, Vector) +// otbGenericDefineCastImageMacro(ComplexFloatVectorImageType, Vector) +// otbGenericDefineCastImageMacro(ComplexDoubleVectorImageType, Vector) } // End namespace Wrapper } // End namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx index 774dfdbf78..99209d593f 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx @@ -24,8 +24,9 @@ #include "otbWrapperComplexInputImageParameter.h" #include "itkUnaryFunctorImageFilter.h" -#include "itkCastImageFilter.h" -#include "otbImageToVectorImageCastFilter.h" +// #include "itkCastImageFilter.h" +// #include "otbImageToVectorImageCastFilter.h" +#include "otbClampImageFilter.h" namespace otb { @@ -91,7 +92,15 @@ ComplexInputImageParameter::GetImage() } else { - if (dynamic_cast<ComplexFloatVectorImageType*>(m_Image.GetPointer())) + if (dynamic_cast<ComplexInt16VectorImageType*>(m_Image.GetPointer())) + { + return CastImage<ComplexInt16VectorImageType, TOutputImage>(); + } + else if (dynamic_cast<ComplexInt32VectorImageType*>(m_Image.GetPointer())) + { + return CastImage<ComplexInt32VectorImageType, TOutputImage>(); + } + else if (dynamic_cast<ComplexFloatVectorImageType*>(m_Image.GetPointer())) { return CastImage<ComplexFloatVectorImageType, TOutputImage>(); } @@ -99,6 +108,14 @@ ComplexInputImageParameter::GetImage() { return CastImage<ComplexDoubleVectorImageType, TOutputImage>(); } + else if (dynamic_cast<ComplexInt16ImageType*>(m_Image.GetPointer())) + { + return CastImage<ComplexInt16ImageType, TOutputImage>(); + } + else if (dynamic_cast<ComplexInt32ImageType*>(m_Image.GetPointer())) + { + return CastImage<ComplexInt32ImageType, TOutputImage>(); + } else if (dynamic_cast<ComplexFloatImageType*>(m_Image.GetPointer())) { return CastImage<ComplexFloatImageType, TOutputImage>(); @@ -120,12 +137,24 @@ template <class TComplexInputImage, class TOutputImage> TOutputImage* ComplexInputImageParameter::CastImage() { - itkExceptionMacro("Cast from "<<typeid(TComplexInputImage).name() - <<" to "<<typeid(TOutputImage).name()<<" not authorized."); + TComplexInputImage* realComplexInputImage = dynamic_cast<TComplexInputImage*>(m_Image.GetPointer()); + + typedef ClampImageFilter<TComplexInputImage, TOutputImage> CasterType; + typename CasterType::Pointer caster = CasterType::New(); + + caster->SetInput(realComplexInputImage); + caster->UpdateOutputInformation(); + + m_Image = caster->GetOutput(); + m_Caster = caster; + + return caster->GetOutput(); + // itkExceptionMacro("Cast from "<<typeid(TComplexInputImage).name() + // <<" to "<<typeid(TOutputImage).name()<<" not authorized."); } -template <class TComplexInputImage, class TOutputImage> +/*template <class TComplexInputImage, class TOutputImage> TOutputImage* ComplexInputImageParameter::SimpleCastImage() { @@ -160,7 +189,7 @@ ComplexInputImageParameter::CastVectorImageFromImage() m_Caster = caster; return caster->GetOutput(); -} +}*/ template <class TComplexInputImage> void diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h index 371c4d4166..b5af8187c9 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h @@ -128,17 +128,20 @@ protected: ComplexImagePixelType m_ComplexPixelType; ComplexImagePixelType m_DefaultComplexPixelType; - typedef otb::ImageFileWriter<ComplexFloatImageType> ComplexFloatWriterType; - typedef otb::ImageFileWriter<ComplexDoubleImageType> ComplexDoubleWriterType; - + // typedef otb::ImageFileWriter<ComplexFloatImageType> ComplexFloatWriterType; + // typedef otb::ImageFileWriter<ComplexDoubleImageType> ComplexDoubleWriterType; + typedef otb::ImageFileWriter<ComplexInt16VectorImageType> ComplexVectorInt16WriterType; + typedef otb::ImageFileWriter<ComplexInt32VectorImageType> ComplexVectorInt32WriterType; typedef otb::ImageFileWriter<ComplexFloatVectorImageType> ComplexVectorFloatWriterType; typedef otb::ImageFileWriter<ComplexDoubleVectorImageType> ComplexVectorDoubleWriterType; - ComplexFloatWriterType::Pointer m_ComplexFloatWriter; - ComplexDoubleWriterType::Pointer m_ComplexDoubleWriter; + // ComplexFloatWriterType::Pointer m_ComplexFloatWriter; + // ComplexDoubleWriterType::Pointer m_ComplexDoubleWriter; + ComplexVectorInt16WriterType::Pointer m_ComplexVectorInt16Writer; + ComplexVectorInt32WriterType::Pointer m_ComplexVectorInt32Writer; ComplexVectorFloatWriterType::Pointer m_ComplexVectorFloatWriter; ComplexVectorDoubleWriterType::Pointer m_ComplexVectorDoubleWriter; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx index 1c105f25c0..22629f4074 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx @@ -73,14 +73,18 @@ ComplexInputImageParameter::GetImage() return this->GetImage< image##Type > (); \ } +otbGetImageMacro(ComplexInt16Image); +otbGetImageMacro(ComplexInt32Image); otbGetImageMacro(ComplexFloatImage); otbGetImageMacro(ComplexDoubleImage); +otbGetImageMacro(ComplexInt16VectorImage); +otbGetImageMacro(ComplexInt32VectorImage); otbGetImageMacro(ComplexFloatVectorImage); otbGetImageMacro(ComplexDoubleVectorImage); -#define otbCastImageMacro(ComplexInputImageType, OutputImageType, theMethod) \ +/*#define otbCastImageMacro(ComplexInputImageType, OutputImageType, theMethod) \ template<> OutputImageType * \ ComplexInputImageParameter::CastImage<ComplexInputImageType , OutputImageType>() \ { \ @@ -89,22 +93,22 @@ otbGetImageMacro(ComplexDoubleVectorImage); #define otbGenericCastImageMacro(ComplexInputImageType, theMethod, prefix) \ otbCastImageMacro(ComplexInputImageType, ComplexFloat##prefix##ImageType, theMethod) \ - otbCastImageMacro(ComplexInputImageType, ComplexDouble##prefix##ImageType, theMethod) + otbCastImageMacro(ComplexInputImageType, ComplexDouble##prefix##ImageType, theMethod)*/ -/********************************************************************* +/******************************************************************** ********************** Image -> Image -**********************************************************************/ +*********************************************************************/ - otbGenericCastImageMacro(ComplexFloatImageType, SimpleCastImage, ) - otbGenericCastImageMacro(ComplexDoubleImageType, SimpleCastImage, ) +// otbGenericCastImageMacro(ComplexFloatImageType, SimpleCastImage, ) +// otbGenericCastImageMacro(ComplexDoubleImageType, SimpleCastImage, ) /********************************************************************* ********************** VectorImage -> VectorImage **********************************************************************/ - otbGenericCastImageMacro(ComplexFloatVectorImageType, SimpleCastImage, Vector) - otbGenericCastImageMacro(ComplexDoubleVectorImageType, SimpleCastImage, Vector) +// otbGenericCastImageMacro(ComplexFloatVectorImageType, SimpleCastImage, Vector) +// otbGenericCastImageMacro(ComplexDoubleVectorImageType, SimpleCastImage, Vector) void ComplexInputImageParameter::SetImage(ComplexFloatVectorImageType* image) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx index 64ef365718..d08fe73062 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx @@ -20,8 +20,9 @@ #include "otbWrapperComplexOutputImageParameter.h" #include "itkUnaryFunctorImageFilter.h" -#include "itkCastImageFilter.h" -#include "itkVectorCastImageFilter.h" +#include "otbClampImageFilter.h" +// #include "itkCastImageFilter.h" +// #include "itkVectorCastImageFilter.h" #ifdef OTB_USE_MPI @@ -59,6 +60,16 @@ ComplexOutputImageParameter::ConvertPixelTypeToString(ComplexImagePixelType type std::string ret; switch(type) { + case ComplexImagePixelType_int16: + { + ret = "cint16"; + break; + } + case ComplexImagePixelType_int32: + { + ret = "cint32"; + break; + } case ComplexImagePixelType_float: { ret = "cfloat"; @@ -76,7 +87,11 @@ ComplexOutputImageParameter::ConvertPixelTypeToString(ComplexImagePixelType type bool ComplexOutputImageParameter::ConvertStringToPixelType(const std::string &value, ComplexImagePixelType &type) { - if (value == "cfloat") + if (value == "cint16") + type = ComplexImagePixelType_int16; + if (value == "cint32") + type = ComplexImagePixelType_int32; + else if (value == "cfloat") type = ComplexImagePixelType_float; else if (value == "cdouble") type = ComplexImagePixelType_double; @@ -87,16 +102,18 @@ ComplexOutputImageParameter::ConvertStringToPixelType(const std::string &value, void ComplexOutputImageParameter::InitializeWriters() { - m_ComplexFloatWriter = ComplexFloatWriterType::New(); - m_ComplexDoubleWriter = ComplexDoubleWriterType::New(); + // m_ComplexFloatWriter = ComplexFloatWriterType::New(); + // m_ComplexDoubleWriter = ComplexDoubleWriterType::New(); + m_ComplexVectorInt16Writer = ComplexVectorInt16WriterType::New(); + m_ComplexVectorInt32Writer = ComplexVectorInt32WriterType::New(); m_ComplexVectorFloatWriter = ComplexVectorFloatWriterType::New(); m_ComplexVectorDoubleWriter = ComplexVectorDoubleWriterType::New(); } template <typename TInput, typename TOutput> void CastAndWriteImage(itk::ImageBase<2> * in, otb::ImageFileWriter<TOutput> * writer, const std::string & filename, const unsigned int & ramValue) { - typedef itk::CastImageFilter<TInput, TOutput> ClampFilterType; + typedef ClampImageFilter<TInput, TOutput> ClampFilterType; typename ClampFilterType::Pointer clampFilter = ClampFilterType::New(); clampFilter->SetInput( dynamic_cast<TInput*>(in)); @@ -157,46 +174,79 @@ ComplexOutputImageParameter::SwitchImageWrite() { switch(m_ComplexPixelType ) { - case ComplexImagePixelType_float: + case ComplexImagePixelType_int16: { - CastAndWriteImage<TInputImageType,ComplexFloatImageType>(m_Image,m_ComplexFloatWriter,m_FileName,m_RAMValue); + CastAndWriteImage<TInputImageType,ComplexInt16VectorImageType>( + m_Image , + m_ComplexVectorInt16Writer , + m_FileName , + m_RAMValue ); break; } - case ComplexImagePixelType_double: + case ComplexImagePixelType_int32: { - CastAndWriteImage<TInputImageType,ComplexDoubleImageType>(m_Image,m_ComplexDoubleWriter,m_FileName,m_RAMValue); + CastAndWriteImage<TInputImageType,ComplexInt32VectorImageType>( + m_Image , + m_ComplexVectorInt32Writer , + m_FileName , + m_RAMValue ); break; } - } -} - - -template <class TInputVectorImageType> -void -ComplexOutputImageParameter::SwitchVectorImageWrite() - { - switch(m_ComplexPixelType ) - { case ComplexImagePixelType_float: { - CastAndWriteImage<TInputVectorImageType,ComplexFloatVectorImageType>(m_Image,m_ComplexVectorFloatWriter,m_FileName,m_RAMValue); + CastAndWriteImage<TInputImageType,ComplexFloatVectorImageType>( + m_Image , + m_ComplexVectorFloatWriter , + m_FileName , + m_RAMValue ); break; } case ComplexImagePixelType_double: { - CastAndWriteImage<TInputVectorImageType,ComplexDoubleVectorImageType>(m_Image,m_ComplexVectorDoubleWriter,m_FileName,m_RAMValue); + CastAndWriteImage<TInputImageType,ComplexDoubleVectorImageType>( + m_Image , + m_ComplexVectorDoubleWriter , + m_FileName , + m_RAMValue ); break; } } - } +} + + +// template <class TInputVectorImageType> +// void +// ComplexOutputImageParameter::SwitchVectorImageWrite() +// { +// switch(m_ComplexPixelType ) +// { +// case ComplexImagePixelType_float: +// { +// CastAndWriteImage<TInputVectorImageType,ComplexFloatVectorImageType>(m_Image,m_ComplexVectorFloatWriter,m_FileName,m_RAMValue); +// break; +// } +// case ComplexImagePixelType_double: +// { +// CastAndWriteImage<TInputVectorImageType,ComplexDoubleVectorImageType>(m_Image,m_ComplexVectorDoubleWriter,m_FileName,m_RAMValue); +// break; +// } +// } +// } void ComplexOutputImageParameter::Write() { m_Image->UpdateOutputInformation(); - - if (dynamic_cast<ComplexFloatImageType*>(m_Image.GetPointer())) + if (dynamic_cast<ComplexInt16ImageType*>(m_Image.GetPointer())) + { + SwitchImageWrite<ComplexInt16ImageType>(); + } + else if (dynamic_cast<ComplexInt16ImageType*>(m_Image.GetPointer())) + { + SwitchImageWrite<ComplexInt16ImageType>(); + } + else if (dynamic_cast<ComplexFloatImageType*>(m_Image.GetPointer())) { SwitchImageWrite<ComplexFloatImageType>(); } @@ -204,13 +254,21 @@ ComplexOutputImageParameter::Write() { SwitchImageWrite<ComplexDoubleImageType>(); } + else if (dynamic_cast<ComplexInt16VectorImageType*>(m_Image.GetPointer())) + { + SwitchImageWrite<ComplexInt16VectorImageType>(); + } + else if (dynamic_cast<ComplexInt32VectorImageType*>(m_Image.GetPointer())) + { + SwitchImageWrite<ComplexInt32VectorImageType>(); + } else if (dynamic_cast<ComplexFloatVectorImageType*>(m_Image.GetPointer())) { - SwitchVectorImageWrite<ComplexFloatVectorImageType>(); + SwitchImageWrite<ComplexFloatVectorImageType>(); } else if (dynamic_cast<ComplexDoubleVectorImageType*>(m_Image.GetPointer())) { - SwitchVectorImageWrite<ComplexDoubleVectorImageType>(); + SwitchImageWrite<ComplexDoubleVectorImageType>(); } else { @@ -221,33 +279,41 @@ ComplexOutputImageParameter::Write() itk::ProcessObject* ComplexOutputImageParameter::GetWriter() { - int type = 0; + // int type = 1; // 0 : image // 1 : VectorImage - if ( dynamic_cast<ComplexFloatVectorImageType*>( m_Image.GetPointer()) || - dynamic_cast<ComplexDoubleVectorImageType*>(m_Image.GetPointer())) - { - type = 1; - } + // if ( dynamic_cast<ComplexFloatVectorImageType*>( m_Image.GetPointer()) || + // dynamic_cast<ComplexDoubleVectorImageType*>(m_Image.GetPointer())) + // { + // type = 1; + // } itk::ProcessObject* writer = ITK_NULLPTR; switch ( GetComplexPixelType() ) { + case ComplexImagePixelType_int16: + { + writer = m_ComplexVectorInt16Writer; + } + case ComplexImagePixelType_int32: + { + writer = m_ComplexVectorInt32Writer; + } case ComplexImagePixelType_float: { - if( type == 1 ) + // if( type == 1 ) writer = m_ComplexVectorFloatWriter; - else - writer = m_ComplexFloatWriter; + // else + // writer = m_ComplexFloatWriter; break; } case ComplexImagePixelType_double: { - if( type == 1 ) + // if( type == 1 ) writer = m_ComplexVectorDoubleWriter; - else - writer = m_ComplexDoubleWriter; + // else + // writer = m_ComplexDoubleWriter; break; } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 24307b58da..8163c146d7 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -20,11 +20,8 @@ #include "otbWrapperOutputImageParameter.h" #include "otbClampImageFilter.h" -// #include "itkCastImageFilter.h" -// #include "otbClampVectorImageFilter.h" #include "otbImageIOFactory.h" #include "itksys/SystemTools.hxx" -// #include "otbTwoNRIBandsImageToNComplexBandsImage.h" #ifdef OTB_USE_MPI @@ -305,144 +302,144 @@ ClampAndWriteVectorImage( itk::ImageBase<2> * in , } }*/ -// template <class TInput> -// void -// OutputImageParameter::SwitchImageWrite() -// { -// switch(m_PixelType ) -// { -// case ImagePixelType_uint8: -// { -// ClampAndWriteImage< TInput , UInt8ImageType >( -// m_Image , -// m_UInt8Writer , -// m_FileName , -// m_RAMValue ); -// break; -// } -// case ImagePixelType_int16: -// { -// ClampAndWriteImage< TInput , Int16ImageType >( -// m_Image , -// m_Int16Writer , -// m_FileName , -// m_RAMValue ); -// break; -// } -// case ImagePixelType_uint16: -// { -// ClampAndWriteImage< TInput , UInt16ImageType >( -// m_Image , -// m_UInt16Writer , -// m_FileName , -// m_RAMValue ); -// break; -// } -// case ImagePixelType_int32: -// { -// ClampAndWriteImage< TInput , Int32ImageType >( -// m_Image , -// m_Int32Writer , -// m_FileName , -// m_RAMValue ); -// break; -// } -// case ImagePixelType_uint32: -// { -// ClampAndWriteImage< TInput , UInt32ImageType >( -// m_Image , -// m_UInt32Writer , -// m_FileName , -// m_RAMValue ); -// break; -// } -// case ImagePixelType_float: -// { -// ClampAndWriteImage< TInput , FloatImageType >( -// m_Image , -// m_FloatWriter , -// m_FileName , -// m_RAMValue ); -// break; -// } -// case ImagePixelType_double: -// { -// ClampAndWriteImage< TInput , DoubleImageType >( -// m_Image , -// m_DoubleWriter , -// m_FileName , -// m_RAMValue ); -// break; -// } -// case ImagePixelType_cint16: -// { -// ClampAndWriteImage< TInput , ComplexInt16ImageType >( -// m_Image , -// m_ComplexInt16Writer , -// m_FileName , -// m_RAMValue ); -// break; -// } -// case ImagePixelType_cint32: -// { -// ClampAndWriteImage< TInput , ComplexInt32ImageType >( -// m_Image , -// m_ComplexInt32Writer , -// m_FileName , -// m_RAMValue ); -// break; -// } -// case ImagePixelType_cfloat: -// { -// ClampAndWriteImage< TInput , ComplexFloatImageType >( -// m_Image , -// m_ComplexFloatWriter , -// m_FileName , -// m_RAMValue ); -// break; -// } -// case ImagePixelType_cdouble: -// { -// ClampAndWriteImage< TInput , ComplexDoubleImageType >( -// m_Image , -// m_ComplexDoubleWriter , -// m_FileName , -// m_RAMValue ); -// break; -// } -// default: -// break; -// } -// } - -// template <class TInput> -// void -// OutputImageParameter::SwitchCImageWrite() -// { -// switch(m_PixelType ) -// { -// case ImagePixelType_cfloat: -// { -// ClampAndWriteImage< TInput , ComplexFloatImageType >( -// m_Image , -// m_ComplexFloatWriter , -// m_FileName , -// m_RAMValue ); -// break; -// } -// case ImagePixelType_cdouble: -// { -// ClampAndWriteImage< TInput , ComplexDoubleImageType >( -// m_Image , -// m_ComplexDoubleWriter , -// m_FileName , -// m_RAMValue ); -// break; -// } -// default: -// break; -// } -// } +/*template <class TInput> +void +OutputImageParameter::SwitchImageWrite() +{ + switch(m_PixelType ) + { + case ImagePixelType_uint8: + { + ClampAndWriteImage< TInput , UInt8ImageType >( + m_Image , + m_UInt8Writer , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_int16: + { + ClampAndWriteImage< TInput , Int16ImageType >( + m_Image , + m_Int16Writer , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_uint16: + { + ClampAndWriteImage< TInput , UInt16ImageType >( + m_Image , + m_UInt16Writer , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_int32: + { + ClampAndWriteImage< TInput , Int32ImageType >( + m_Image , + m_Int32Writer , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_uint32: + { + ClampAndWriteImage< TInput , UInt32ImageType >( + m_Image , + m_UInt32Writer , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_float: + { + ClampAndWriteImage< TInput , FloatImageType >( + m_Image , + m_FloatWriter , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_double: + { + ClampAndWriteImage< TInput , DoubleImageType >( + m_Image , + m_DoubleWriter , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_cint16: + { + ClampAndWriteImage< TInput , ComplexInt16ImageType >( + m_Image , + m_ComplexInt16Writer , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_cint32: + { + ClampAndWriteImage< TInput , ComplexInt32ImageType >( + m_Image , + m_ComplexInt32Writer , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_cfloat: + { + ClampAndWriteImage< TInput , ComplexFloatImageType >( + m_Image , + m_ComplexFloatWriter , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_cdouble: + { + ClampAndWriteImage< TInput , ComplexDoubleImageType >( + m_Image , + m_ComplexDoubleWriter , + m_FileName , + m_RAMValue ); + break; + } + default: + break; + } +}*/ + +/*template <class TInput> +void +OutputImageParameter::SwitchCImageWrite() +{ + switch(m_PixelType ) + { + case ImagePixelType_cfloat: + { + ClampAndWriteImage< TInput , ComplexFloatImageType >( + m_Image , + m_ComplexFloatWriter , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_cdouble: + { + ClampAndWriteImage< TInput , ComplexDoubleImageType >( + m_Image , + m_ComplexDoubleWriter , + m_FileName , + m_RAMValue ); + break; + } + default: + break; + } +}*/ template <class TInput> @@ -555,34 +552,34 @@ OutputImageParameter::SwitchVectorImageWrite() } } -// template <class TInput> -// void -// OutputImageParameter::SwitchVectorCImageWrite() -// { -// switch(m_PixelType ) -// { -// case ImagePixelType_cfloat: -// { -// ClampAndWriteImage< TInput , ComplexFloatVectorImageType >( -// m_Image , -// m_ComplexVectorFloatWriter , -// m_FileName , -// m_RAMValue ); -// break; -// } -// case ImagePixelType_cdouble: -// { -// ClampAndWriteImage< TInput , ComplexDoubleVectorImageType >( -// m_Image , -// m_ComplexVectorDoubleWriter , -// m_FileName , -// m_RAMValue ); -// break; -// } -// default: -// break; -// } -// } +/*template <class TInput> +void +OutputImageParameter::SwitchVectorCImageWrite() +{ + switch(m_PixelType ) + { + case ImagePixelType_cfloat: + { + ClampAndWriteImage< TInput , ComplexFloatVectorImageType >( + m_Image , + m_ComplexVectorFloatWriter , + m_FileName , + m_RAMValue ); + break; + } + case ImagePixelType_cdouble: + { + ClampAndWriteImage< TInput , ComplexDoubleVectorImageType >( + m_Image , + m_ComplexVectorDoubleWriter , + m_FileName , + m_RAMValue ); + break; + } + default: + break; + } +}*/ template <class TInputRGBAImageType> void diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexOutputImageParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexOutputImageParameter.cxx index 0cd5800dfa..ab35389152 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexOutputImageParameter.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetComplexOutputImageParameter.cxx @@ -67,6 +67,8 @@ void QtWidgetComplexOutputImageParameter::DoCreateWidget() // Set the Output PixelType choice Combobox m_ComboBox = new QComboBox; m_ComboBox->setToolTip("Complex Output Pixel Type"); + m_ComboBox->addItem( "cint16"); + m_ComboBox->addItem( "cint32"); m_ComboBox->addItem( "cfloat"); m_ComboBox->addItem( "cdouble"); m_ComboBox->setCurrentIndex(m_OutputImageParam->GetComplexPixelType()); -- GitLab From 60c4084bc7d7b3579e2ee9dc5fd31783449aacf1 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 15 Dec 2017 12:01:28 +0100 Subject: [PATCH 167/567] REFAC: better naming and architecture --- .../include/otbWrapperInputImageParameter.h | 8 +++--- .../include/otbWrapperInputImageParameter.txx | 6 ++--- .../ApplicationEngine/src/CMakeLists.txt | 2 +- .../src/otbWrapperInputImageParameter.cxx | 11 ++++++++ .../src/otbWrapperOutputImageParameter.cxx | 26 +++++++++---------- 5 files changed, 32 insertions(+), 21 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h index 2a36842218..5cbcbc587a 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h @@ -109,13 +109,13 @@ public: /** Cast an image to an image of the same type * Image to Image, VectorImage to VectorImage, RGBAImage to RGBAImage. */ - template <class TInputImage, class TOutputImage> - TOutputImage* SimpleCastImage(); + // template <class TInputImage, class TOutputImage> + // TOutputImage* SimpleCastImage(); /** Cast an image to a vector image. */ - template <class TInputImage, class TOutputImage> - TOutputImage* CastVectorImageFromImage(); + // template <class TInputImage, class TOutputImage> + // TOutputImage* CastVectorImageFromImage(); bool HasValue() const ITK_OVERRIDE; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx index 0ead9125d1..0beb76ad1f 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx @@ -247,7 +247,8 @@ InputImageParameter::CastImage() } -template <class TInputImage, class TOutputImage> + +/*template <class TInputImage, class TOutputImage> TOutputImage* InputImageParameter::SimpleCastImage() { @@ -272,7 +273,6 @@ InputImageParameter::SimpleCastImage() } } - template <class TInputImage, class TOutputImage> TOutputImage* InputImageParameter::CastVectorImageFromImage() @@ -290,7 +290,7 @@ InputImageParameter::CastVectorImageFromImage() return caster->GetOutput(); } - +*/ template <class TInputImage> void diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 671b314aab..559577ece6 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -31,7 +31,7 @@ set( OTBApplicationEngine_SRC otbWrapperInputFilenameListParameter.cxx otbWrapperOutputImageParameter.cxx otbWrapperInputImageParameter.cxx - otbWrapperInputImageParameterType.cxx + #otbWrapperInputImageParameterType.cxx #otbWrapperInputImageParameterUInt8.cxx #otbWrapperInputImageParameterInt16.cxx #otbWrapperInputImageParameterUInt16.cxx diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx index 166ab2956a..fe226ef2ff 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx @@ -70,6 +70,17 @@ InputImageParameter::GetImage() otbGetImageMacro(UInt8RGBImage); otbGetImageMacro(UInt8RGBAImage); +otbGetImageAndVectorImageMacro(UInt8); +otbGetImageAndVectorImageMacro(UInt16); +otbGetImageAndVectorImageMacro(UInt32); +otbGetImageAndVectorImageMacro(Int16); +otbGetImageAndVectorImageMacro(Int32); +otbGetImageAndVectorImageMacro(Float); +otbGetImageAndVectorImageMacro(Double); +otbGetImageAndVectorImageMacro(ComplexInt16); +otbGetImageAndVectorImageMacro(ComplexInt32); +otbGetImageAndVectorImageMacro(ComplexFloat); +otbGetImageAndVectorImageMacro(ComplexDouble); void diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 8163c146d7..b6585a33b8 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -182,7 +182,7 @@ void OutputImageParameter::InitializeWriters() template <typename TInput, typename TOutput> void -ClampAndWriteImage( itk::ImageBase<2> * in , +ClampAndWriteVectorImage( itk::ImageBase<2> * in , otb::ImageFileWriter<TOutput> * writer , const std::string & filename , const unsigned int & ramValue ) @@ -245,7 +245,7 @@ ClampAndWriteImage( itk::ImageBase<2> * in , /*template <typename TInput, typename TOutput > void -ClampAndWriteVectorImage( itk::ImageBase<2> * in , +ClampAndWriteImage( itk::ImageBase<2> * in , otb::ImageFileWriter<TOutput > * writer , const std::string & filename , const unsigned int & ramValue , @@ -450,7 +450,7 @@ OutputImageParameter::SwitchVectorImageWrite() { case ImagePixelType_uint8: { - ClampAndWriteImage< TInput , UInt8VectorImageType > ( + ClampAndWriteVectorImage< TInput , UInt8VectorImageType > ( m_Image , m_VectorUInt8Writer , m_FileName , @@ -459,7 +459,7 @@ OutputImageParameter::SwitchVectorImageWrite() } case ImagePixelType_int16: { - ClampAndWriteImage< TInput , Int16VectorImageType > ( + ClampAndWriteVectorImage< TInput , Int16VectorImageType > ( m_Image , m_VectorInt16Writer , m_FileName , @@ -468,7 +468,7 @@ OutputImageParameter::SwitchVectorImageWrite() } case ImagePixelType_uint16: { - ClampAndWriteImage< TInput , UInt16VectorImageType > ( + ClampAndWriteVectorImage< TInput , UInt16VectorImageType > ( m_Image , m_VectorUInt16Writer , m_FileName , @@ -477,7 +477,7 @@ OutputImageParameter::SwitchVectorImageWrite() } case ImagePixelType_int32: { - ClampAndWriteImage< TInput , Int32VectorImageType > ( + ClampAndWriteVectorImage< TInput , Int32VectorImageType > ( m_Image , m_VectorInt32Writer , m_FileName , @@ -486,7 +486,7 @@ OutputImageParameter::SwitchVectorImageWrite() } case ImagePixelType_uint32: { - ClampAndWriteImage< TInput , UInt32VectorImageType > ( + ClampAndWriteVectorImage< TInput , UInt32VectorImageType > ( m_Image , m_VectorUInt32Writer , m_FileName , @@ -495,7 +495,7 @@ OutputImageParameter::SwitchVectorImageWrite() } case ImagePixelType_float: { - ClampAndWriteImage< TInput , FloatVectorImageType > ( + ClampAndWriteVectorImage< TInput , FloatVectorImageType > ( m_Image , m_VectorFloatWriter , m_FileName , @@ -504,7 +504,7 @@ OutputImageParameter::SwitchVectorImageWrite() } case ImagePixelType_double: { - ClampAndWriteImage< TInput , DoubleVectorImageType > ( + ClampAndWriteVectorImage< TInput , DoubleVectorImageType > ( m_Image , m_VectorDoubleWriter , m_FileName , @@ -513,7 +513,7 @@ OutputImageParameter::SwitchVectorImageWrite() } case ImagePixelType_cint16: { - ClampAndWriteImage < TInput , ComplexInt16VectorImageType > ( + ClampAndWriteVectorImage < TInput , ComplexInt16VectorImageType > ( m_Image , m_ComplexVectorInt16Writer , m_FileName , @@ -522,7 +522,7 @@ OutputImageParameter::SwitchVectorImageWrite() } case ImagePixelType_cint32: { - ClampAndWriteImage < TInput , ComplexInt32VectorImageType > ( + ClampAndWriteVectorImage < TInput , ComplexInt32VectorImageType > ( m_Image , m_ComplexVectorInt32Writer , m_FileName , @@ -531,7 +531,7 @@ OutputImageParameter::SwitchVectorImageWrite() } case ImagePixelType_cfloat: { - ClampAndWriteImage < TInput , ComplexFloatVectorImageType > ( + ClampAndWriteVectorImage < TInput , ComplexFloatVectorImageType > ( m_Image , m_ComplexVectorFloatWriter , m_FileName , @@ -540,7 +540,7 @@ OutputImageParameter::SwitchVectorImageWrite() } case ImagePixelType_cdouble: { - ClampAndWriteImage < TInput , ComplexDoubleVectorImageType > ( + ClampAndWriteVectorImage < TInput , ComplexDoubleVectorImageType > ( m_Image , m_ComplexVectorDoubleWriter , m_FileName , -- GitLab From 11bc13f01c4e175622db778cadefd49f9f78b2b4 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 15 Dec 2017 12:10:59 +0100 Subject: [PATCH 168/567] REFAC: add deprecated header to deprecated source file --- .../ApplicationEngine/src/CMakeLists.txt | 17 +++--- .../otbWrapperInputImageParameterCDouble.cxx | 45 ---------------- .../otbWrapperInputImageParameterCFloat.cxx | 45 ---------------- .../otbWrapperInputImageParameterDouble.cxx | 1 + .../otbWrapperInputImageParameterFloat.cxx | 1 + .../otbWrapperInputImageParameterInt16.cxx | 1 + .../otbWrapperInputImageParameterInt32.cxx | 1 + .../src/otbWrapperInputImageParameterType.cxx | 52 ------------------- .../otbWrapperInputImageParameterUInt16.cxx | 1 + .../otbWrapperInputImageParameterUInt32.cxx | 1 + .../otbWrapperInputImageParameterUInt8.cxx | 1 + 11 files changed, 14 insertions(+), 152 deletions(-) delete mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx delete mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx delete mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterType.cxx diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 559577ece6..343f9db835 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -31,16 +31,13 @@ set( OTBApplicationEngine_SRC otbWrapperInputFilenameListParameter.cxx otbWrapperOutputImageParameter.cxx otbWrapperInputImageParameter.cxx - #otbWrapperInputImageParameterType.cxx - #otbWrapperInputImageParameterUInt8.cxx - #otbWrapperInputImageParameterInt16.cxx - #otbWrapperInputImageParameterUInt16.cxx - #otbWrapperInputImageParameterInt32.cxx - #otbWrapperInputImageParameterUInt32.cxx - #otbWrapperInputImageParameterFloat.cxx - #otbWrapperInputImageParameterDouble.cxx - #otbWrapperInputImageParameterCFloat.cxx - #otbWrapperInputImageParameterCDouble.cxx + otbWrapperInputImageParameterUInt8.cxx + otbWrapperInputImageParameterInt16.cxx + otbWrapperInputImageParameterUInt16.cxx + otbWrapperInputImageParameterInt32.cxx + otbWrapperInputImageParameterUInt32.cxx + otbWrapperInputImageParameterFloat.cxx + otbWrapperInputImageParameterDouble.cxx otbWrapperParameterKey.cxx otbWrapperDocExampleStructure.cxx otbWrapperInputVectorDataParameter.cxx diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx deleted file mode 100644 index 16ba940791..0000000000 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "otbWrapperInputImageParameter.h" -#include "itksys/SystemTools.hxx" -#include "otbWrapperTypes.h" -#include "otbWrapperInputImageParameterMacros.h" -#include "otb_boost_string_header.h" - -namespace otb -{ -namespace Wrapper -{ -otbGetImageMacro(ComplexDoubleImage); -otbGetImageMacro(ComplexDoubleVectorImage) -/* -// otbGenericCastImageMacro(ComplexDoubleImage, SimpleCastImage, ) -otbCastImageMacro(ComplexDoubleImageType , ComplexDoubleImageType , SimpleCastImage) -otbCastImageMacro(ComplexDoubleImageType , ComplexFloatImageType , SimpleCastImage) -// otbGenericCastImageMacro(ComplexVectorDoubleImage, SimpleCastImage, Vector) -otbCastImageMacro(ComplexDoubleVectorImageType , ComplexDoubleVectorImageType , SimpleCastImage) -otbCastImageMacro(ComplexDoubleVectorImageType , ComplexFloatVectorImageType , SimpleCastImage) -// otbGenericCastImageMacro(ComplexDoubleImage, CastVectorImageFromImage, Vector) -otbCastImageMacro(ComplexDoubleImageType , ComplexDoubleVectorImageType , CastVectorImageFromImage) -otbCastImageMacro(ComplexDoubleImageType , ComplexFloatVectorImageType , CastVectorImageFromImage) -*/ -} -} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx deleted file mode 100644 index 8974f25454..0000000000 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "otbWrapperInputImageParameter.h" -#include "itksys/SystemTools.hxx" -#include "otbWrapperTypes.h" -#include "otbWrapperInputImageParameterMacros.h" -#include "otb_boost_string_header.h" - -namespace otb -{ -namespace Wrapper -{ -otbGetImageMacro(ComplexFloatImage); -otbGetImageMacro(ComplexFloatVectorImage) -/* -// otbGenericCastImageMacro(ComplexFloatImage, SimpleCastImage, ) -otbCastImageMacro(ComplexFloatImageType , ComplexDoubleImageType , SimpleCastImage) -otbCastImageMacro(ComplexFloatImageType , ComplexFloatImageType , SimpleCastImage) -// otbGenericCastImageMacro(ComplexVectorFloatImage, SimpleCastImage, Vector) -otbCastImageMacro(ComplexFloatVectorImageType , ComplexDoubleVectorImageType , SimpleCastImage) -otbCastImageMacro(ComplexFloatVectorImageType , ComplexFloatVectorImageType , SimpleCastImage) -// otbGenericCastImageMacro(ComplexFloatImage, CastVectorImageFromImage, Vector) -otbCastImageMacro(ComplexFloatImageType , ComplexDoubleVectorImageType , CastVectorImageFromImage) -otbCastImageMacro(ComplexFloatImageType , ComplexFloatVectorImageType , CastVectorImageFromImage) -*/ -} -} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx index 8e58335607..c15afe0456 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx @@ -18,6 +18,7 @@ * limitations under the License. */ +#include <vcl_deprecated_header.h> #include "otbWrapperInputImageParameter.h" #include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx index 877004c19a..22f6885901 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx @@ -18,6 +18,7 @@ * limitations under the License. */ +#include <vcl_deprecated_header.h> #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageParameterMacros.h" #include "itksys/SystemTools.hxx" diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx index 4cd42dc166..814df43810 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx @@ -18,6 +18,7 @@ * limitations under the License. */ +#include <vcl_deprecated_header.h> #include "otbWrapperInputImageParameter.h" #include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx index 460453a88e..cc5aa176b8 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx @@ -18,6 +18,7 @@ * limitations under the License. */ +#include <vcl_deprecated_header.h> #include "otbWrapperInputImageParameter.h" #include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterType.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterType.cxx deleted file mode 100644 index da88c171dc..0000000000 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterType.cxx +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "otbWrapperInputImageParameter.h" -#include "otbWrapperTypes.h" -#include "otbWrapperInputImageParameterMacros.h" - -namespace otb -{ -namespace Wrapper -{ -otbGetImageAndVectorImageMacro(UInt8); -// otbGetImageMacro(UInt8VectorImage); -otbGetImageAndVectorImageMacro(UInt16); -// otbGetImageMacro(UInt16VectorImage); -otbGetImageAndVectorImageMacro(UInt32); -// otbGetImageMacro(UInt32VectorImage); -otbGetImageAndVectorImageMacro(Int16); -// otbGetImageMacro(Int16VectorImage); -otbGetImageAndVectorImageMacro(Int32); -// otbGetImageMacro(Int32VectorImage); -otbGetImageAndVectorImageMacro(Float); -// otbGetImageMacro(FloatVectorImage); -otbGetImageAndVectorImageMacro(Double); -// otbGetImageMacro(DoubleVectorImage); -otbGetImageAndVectorImageMacro(ComplexInt16); -// otbGetImageMacro(ComplexInt16VectorImage); -otbGetImageAndVectorImageMacro(ComplexInt32); -// otbGetImageMacro(ComplexInt32VectorImage); -otbGetImageAndVectorImageMacro(ComplexFloat); -// otbGetImageMacro(ComplexFloatVectorImage); -otbGetImageAndVectorImageMacro(ComplexDouble); -// otbGetImageMacro(ComplexDoubleVectorImage); -} // end namespace wrapper -} // end namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx index b509e6a74a..9b53c906c5 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx @@ -18,6 +18,7 @@ * limitations under the License. */ +#include <vcl_deprecated_header.h> #include "otbWrapperInputImageParameter.h" #include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx index 5b22c458f1..d0f6f770f7 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx @@ -18,6 +18,7 @@ * limitations under the License. */ +#include <vcl_deprecated_header.h> #include "otbWrapperInputImageParameter.h" #include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx index 01bb1af83c..205fd80394 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx @@ -18,6 +18,7 @@ * limitations under the License. */ +#include <vcl_deprecated_header.h> #include "otbWrapperInputImageParameter.h" #include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" -- GitLab From b0231107a5459e79d089f28071f946739cfa5a99 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 15 Dec 2017 12:50:48 +0100 Subject: [PATCH 169/567] REFAC: add the deprecated header --- .../ImageManipulation/include/otbClampVectorImageFilter.h | 1 + .../include/otbOneRIBandImageToOneComplexBandImage.h | 1 + .../ImageManipulation/include/otbRealImageToComplexImageFilter.h | 1 + .../include/otbTwoNRIBandsImageToNComplexBandsImage.h | 1 + 4 files changed, 4 insertions(+) diff --git a/Modules/Filtering/ImageManipulation/include/otbClampVectorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbClampVectorImageFilter.h index 053c306000..50b43302e4 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampVectorImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbClampVectorImageFilter.h @@ -21,6 +21,7 @@ #ifndef otbClampVectorImageFilter_h #define otbClampVectorImageFilter_h +#include <vcl_deprecated_header.h> #include "itkImageToImageFilter.h" namespace otb diff --git a/Modules/Filtering/ImageManipulation/include/otbOneRIBandImageToOneComplexBandImage.h b/Modules/Filtering/ImageManipulation/include/otbOneRIBandImageToOneComplexBandImage.h index 8582158d36..01fe68c115 100644 --- a/Modules/Filtering/ImageManipulation/include/otbOneRIBandImageToOneComplexBandImage.h +++ b/Modules/Filtering/ImageManipulation/include/otbOneRIBandImageToOneComplexBandImage.h @@ -21,6 +21,7 @@ #ifndef otbOneRIBandImageToOneComplexBandImage_h #define otbOneRIBandImageToOneComplexBandImage_h +#include <vcl_deprecated_header.h> #include "itkImageToImageFilter.h" #include "itkImage.h" #include "itkNumericTraits.h" diff --git a/Modules/Filtering/ImageManipulation/include/otbRealImageToComplexImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbRealImageToComplexImageFilter.h index c426b5a2f9..8e86ee82f3 100644 --- a/Modules/Filtering/ImageManipulation/include/otbRealImageToComplexImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbRealImageToComplexImageFilter.h @@ -21,6 +21,7 @@ #ifndef otbRealImageToComplexImageFilter_h #define otbRealImageToComplexImageFilter_h +#include <vcl_deprecated_header.h> #include "itkUnaryFunctorImageFilter.h" #include "vnl/vnl_math.h" diff --git a/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.h b/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.h index 538b072149..c4adb6a9f7 100644 --- a/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.h +++ b/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.h @@ -21,6 +21,7 @@ #ifndef otbTwoNRIBandsImageToNComplexBandsImage_h #define otbTwoNRIBandsImageToNComplexBandsImage_h +#include <vcl_deprecated_header.h> #include "itkImageToImageFilter.h" #include "itkImage.h" #include "itkNumericTraits.h" -- GitLab From 4ed8f4d9e6118da74eefb36be5c8ab12fda791ca Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 15 Dec 2017 14:45:20 +0100 Subject: [PATCH 170/567] DOC: improve doc and avoid warning deprecated --- .../include/otbClampImageFilter.h | 42 +++---------- .../include/otbClampImageFilter.txx | 61 ------------------- .../ApplicationEngine/src/CMakeLists.txt | 14 ++--- 3 files changed, 17 insertions(+), 100 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h index f09cd0c54f..8ceff39624 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h @@ -28,18 +28,17 @@ namespace otb { /** \class ClampImageFilter - * \brief Set image values to a user-specified value if they are below, - * above, or between simple threshold values. + * \brief Clamp image values to be below, over, or between threhold values. * * ClampImageFilter clamp image values to be between an upper * and lower value. Values lower than m_Lower values are set to lower, * and values greater than upper threshold are set to upper threshold * value. + * This filter can also be used to cast any type of image into any other type + * as long as those types are arithmetics or complex. * * By default lower and upper thresholds are set to the maximum and - * minimum bounds of the image pixel type. - * - * The pixels must support the operators >= and <=. + * minimum bounds of the image internal pixel value. * * \ingroup IntensityImageFilters Multithreaded * @@ -112,41 +111,20 @@ public: protected: ClampImageFilter(); - ~ClampImageFilter() ITK_OVERRIDE {}; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - - /** ClampImageFilter can be implemented as a multithreaded filter. - * Therefore, this implementation provides a ThreadedGenerateData() routine - * which is called for each processing thread. The output image data is - * allocated automatically by the superclass prior to calling - * ThreadedGenerateData(). ThreadedGenerateData can only write to the - * portion of the output image specified by the parameter - * "outputRegionForThread" - * - * \sa ImageToImageFilter::ThreadedGenerateData(), - * ImageToImageFilter::GenerateData() */ - // void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - // itk::ThreadIdType threadId ) ITK_OVERRIDE; - - void GenerateOutputInformation(void) ITK_OVERRIDE + ~ClampImageFilter() override {}; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + + void GenerateOutputInformation(void) override { Superclass::GenerateOutputInformation(); - - // typename InputImageType::IndexType index; - // index.Fill(0); - // InputImagePixelType px = ->GetPixel( index ); - unsigned int sizeIn = this->GetInput()->GetNumberOfComponentsPerPixel(); - // sizeIn *= itk::NumericTraits < typename itk::NumericTraits< InputImagePixelType >::ValueType > - // :: GetLength(); - this->GetOutput()->SetNumberOfComponentsPerPixel( this->GetFunctor().GetOutputSize ( sizeIn ) ); } private: - ClampImageFilter(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented + ClampImageFilter(const Self&) delete ; + void operator=(const Self&) delete ; double m_DLower; double m_DUpper; diff --git a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx index 2deb3cd4a1..74d0c543e9 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx +++ b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx @@ -131,67 +131,6 @@ ClampImageFilter<TInputImage, TOutputImage> } } - -/** - * - */ -// template <class TInputImage, class TOutputImage> -// void -// ClampImageFilter<TInputImage, TOutputImage> -// ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, -// itk::ThreadIdType threadId) -// { -// itkDebugMacro(<<"Actually executing"); - -// // Get the input and output pointers -// typename InputImageType::ConstPointer inputPtr = this->GetInput(); -// typename OutputImageType::Pointer outputPtr = this->GetOutput(0); - -// // Define/declare an iterator that will walk the output region for this -// // thread. -// typedef itk::ImageRegionConstIterator<TInputImage> InputIterator; -// typedef itk::ImageRegionIterator<TOutputImage> OutputIterator; - -// InputIterator inIt(inputPtr, outputRegionForThread); -// OutputIterator outIt(outputPtr, outputRegionForThread); - -// // support progress methods/callbacks -// itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); - -// // walk the regions, threshold each pixel -// while( !outIt.IsAtEnd() && !inIt.IsAtEnd() ) -// { -// // Cast the value of the pixel to double in order to compare -// // with the double version of the upper and the lower bounds of -// // output image -// const double value = static_cast<double>(inIt.Get()); -// OutputImagePixelType outPix = m_Lower; - -// if ( m_DLower <= value && value <= m_DUpper) -// { -// // pixel passes to output unchanged -// outPix = static_cast<OutputImagePixelType>(value); -// } -// /* Already outPix is initialized with m_Lower even for preventing Warning. -// * -// else if ( value < m_DLower ) -// { -// outPix = m_Lower; -// } -// */ -// else if ( value > m_DUpper) -// { -// outPix = m_Upper; -// } - -// outIt.Set( outPix ); - -// ++inIt; -// ++outIt; -// progress.CompletedPixel(); -// } -// } - } // end namespace itk #endif diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 343f9db835..43482246ac 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -31,13 +31,13 @@ set( OTBApplicationEngine_SRC otbWrapperInputFilenameListParameter.cxx otbWrapperOutputImageParameter.cxx otbWrapperInputImageParameter.cxx - otbWrapperInputImageParameterUInt8.cxx - otbWrapperInputImageParameterInt16.cxx - otbWrapperInputImageParameterUInt16.cxx - otbWrapperInputImageParameterInt32.cxx - otbWrapperInputImageParameterUInt32.cxx - otbWrapperInputImageParameterFloat.cxx - otbWrapperInputImageParameterDouble.cxx + #otbWrapperInputImageParameterUInt8.cxx + #otbWrapperInputImageParameterInt16.cxx + #otbWrapperInputImageParameterUInt16.cxx + #otbWrapperInputImageParameterInt32.cxx + #otbWrapperInputImageParameterUInt32.cxx + #otbWrapperInputImageParameterFloat.cxx + #otbWrapperInputImageParameterDouble.cxx otbWrapperParameterKey.cxx otbWrapperDocExampleStructure.cxx otbWrapperInputVectorDataParameter.cxx -- GitLab From 1af38312c7da29ba5ec49da861c91942a5853af9 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 15 Dec 2017 15:44:36 +0100 Subject: [PATCH 171/567] ENH: update class application --- .../ApplicationEngine/include/otbWrapperApplication.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 57452dbb4a..06468535a5 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -624,10 +624,14 @@ public: otbGetParameterImageMacro(UInt8RGBImage); otbGetParameterImageMacro(UInt8RGBAImage); - // Complex image + // Complex image + otbGetParameterImageMacro(ComplexInt16Image); + otbGetParameterImageMacro(ComplexInt32Image); otbGetParameterImageMacro(ComplexFloatImage); otbGetParameterImageMacro(ComplexDoubleImage); + otbGetParameterImageMacro(ComplexInt16VectorImage); + otbGetParameterImageMacro(ComplexInt32VectorImage); otbGetParameterImageMacro(ComplexFloatVectorImage); otbGetParameterImageMacro(ComplexDoubleVectorImage); -- GitLab From 4b6932c7f9735cdff1d6f701fd7bc19afa7ca62c Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 19 Dec 2017 18:03:46 +0100 Subject: [PATCH 172/567] COMP: fixing deprecated warning and compilation error --- .../include/otbClampImageFilter.h | 4 ++-- .../ImageManipulation/test/CMakeLists.txt | 15 --------------- .../test/otbImageManipulationTestDriver.cxx | 2 -- .../otbOneRIBandImageToOneComplexBandImage.cxx | 5 +++-- 4 files changed, 5 insertions(+), 21 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h index 8ceff39624..d74a2d8829 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h @@ -123,8 +123,8 @@ protected: } private: - ClampImageFilter(const Self&) delete ; - void operator=(const Self&) delete ; + ClampImageFilter(const Self&) = delete ; + void operator=(const Self&) = delete ; double m_DLower; double m_DUpper; diff --git a/Modules/Filtering/ImageManipulation/test/CMakeLists.txt b/Modules/Filtering/ImageManipulation/test/CMakeLists.txt index 386b429479..d8782e61ec 100644 --- a/Modules/Filtering/ImageManipulation/test/CMakeLists.txt +++ b/Modules/Filtering/ImageManipulation/test/CMakeLists.txt @@ -58,7 +58,6 @@ otbStreamingInnerProductVectorImageFilter.cxx otbPhaseFunctorTest.cxx otbShiftScaleVectorImageFilterNew.cxx otbChangeLabelImageFilter.cxx -otbClampVectorImageFilter.cxx otbPrintableImageFilterNew.cxx otbShiftScaleImageAdaptorNew.cxx otbStreamingInnerProductVectorImageFilterNew.cxx @@ -442,20 +441,6 @@ otb_add_test(NAME bfTvChangeLabelImageFilter COMMAND otbImageManipulationTestDri 255 # upper threshold ) - -otb_add_test(NAME bfTvClampVectorImageFilterTest COMMAND otbImageManipulationTestDriver - --compare-image 0.0001 - ${BASELINE}/bfTvClampVectorImageFilterTest_Output.tif - ${TEMP}/bfTvClampVectorImageFilterTest_Output.tif - otbClampVectorImageFilterTest - ${INPUTDATA}/QB_TOULOUSE_MUL_Extract_500_500.tif - ${TEMP}/bfTvClampVectorImageFilterTest_Output.tif - ) - -otb_add_test(NAME bfTuClampVectorImageFilterNew COMMAND otbImageManipulationTestDriver - otbClampVectorImageFilterNew - ) - otb_add_test(NAME bfTuPrintableImageFilterNew COMMAND otbImageManipulationTestDriver otbPrintableImageFilterNew) diff --git a/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx b/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx index b5176d9761..e35453dde0 100644 --- a/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx +++ b/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx @@ -61,8 +61,6 @@ void RegisterTests() REGISTER_TEST(otbPhaseFunctorTest); REGISTER_TEST(otbShiftScaleVectorImageFilterNew); REGISTER_TEST(otbChangeLabelImageFilter); - REGISTER_TEST(otbClampVectorImageFilterNew); - REGISTER_TEST(otbClampVectorImageFilterTest); REGISTER_TEST(otbPrintableImageFilterNew); REGISTER_TEST(otbShiftScaleImageAdaptorNew); REGISTER_TEST(otbStreamingInnerProductVectorImageFilterNew); diff --git a/Modules/Filtering/ImageManipulation/test/otbOneRIBandImageToOneComplexBandImage.cxx b/Modules/Filtering/ImageManipulation/test/otbOneRIBandImageToOneComplexBandImage.cxx index b7d8de1665..41a18d0bb3 100644 --- a/Modules/Filtering/ImageManipulation/test/otbOneRIBandImageToOneComplexBandImage.cxx +++ b/Modules/Filtering/ImageManipulation/test/otbOneRIBandImageToOneComplexBandImage.cxx @@ -20,7 +20,8 @@ #include "itkMacro.h" -#include "otbOneRIBandImageToOneComplexBandImage.h" +// #include "otbOneRIBandImageToOneComplexBandImage.h" +#include "otbClampImageFilter.h" #include "otbImage.h" #include "otbVectorImage.h" @@ -37,7 +38,7 @@ int otbOneRIBandImageToOneComplexBandImage(int itkNotUsed(argc), char * argv[]) typedef otb::Image<OutputPixelType, 2> OutputImageType; - typedef otb::OneRIBandImageToOneComplexBandImage<InputImageType, OutputImageType> FilterType; + typedef otb::ClampImageFilter<InputImageType, OutputImageType> FilterType; typedef otb::ImageFileReader<InputImageType> ReaderType; typedef otb::ImageFileWriter<OutputImageType> WriterType; -- GitLab From e5a5fc85b69fb2a2b013928723318655d1b7124b Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Wed, 10 Jan 2018 10:28:09 +0100 Subject: [PATCH 173/567] COMP: update Shark version in Superbuild for new RF implementation --- SuperBuild/CMake/External_shark.cmake | 4 ++-- .../patches/SHARK/shark-2-find-boost-all.diff | 16 ---------------- 2 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 SuperBuild/patches/SHARK/shark-2-find-boost-all.diff diff --git a/SuperBuild/CMake/External_shark.cmake b/SuperBuild/CMake/External_shark.cmake index ce8486db08..47f07c0b09 100644 --- a/SuperBuild/CMake/External_shark.cmake +++ b/SuperBuild/CMake/External_shark.cmake @@ -30,8 +30,8 @@ ADD_SUPERBUILD_CMAKE_VAR(SHARK BOOST_LIBRARYDIR) ExternalProject_Add(SHARK PREFIX SHARK - URL "https://github.com/Shark-ML/Shark/archive/349f29bd71c370e0f88f7fc9aa66fa5c4768fcb0.zip" - URL_MD5 d6e4310f943e8dda4a0151612b5c62ce + URL "https://github.com/Shark-ML/Shark/archive/a0d1f816f474b968adbf7592bff199a96a87efc1.zip" + URL_MD5 ed0e8eb73743b39a93775599761a9273 SOURCE_DIR ${SHARK_SB_SRC} BINARY_DIR ${SHARK_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} diff --git a/SuperBuild/patches/SHARK/shark-2-find-boost-all.diff b/SuperBuild/patches/SHARK/shark-2-find-boost-all.diff deleted file mode 100644 index a97c1ac4af..0000000000 --- a/SuperBuild/patches/SHARK/shark-2-find-boost-all.diff +++ /dev/null @@ -1,16 +0,0 @@ -diff -burN Shark-349f29bd71c370e0f88f7fc9aa66fa5c4768fcb0.orig/CMakeLists.txt Shark-349f29bd71c370e0f88f7fc9aa66fa5c4768fcb0/CMakeLists.txt ---- Shark-349f29bd71c370e0f88f7fc9aa66fa5c4768fcb0.orig/CMakeLists.txt 2017-08-22 11:31:50.472052695 +0200 -+++ Shark-349f29bd71c370e0f88f7fc9aa66fa5c4768fcb0/CMakeLists.txt 2017-08-22 11:32:36.448358789 +0200 -@@ -141,10 +141,8 @@ - - find_package( - Boost 1.48.0 REQUIRED COMPONENTS -- system date_time filesystem -- program_options serialization thread -- unit_test_framework --) -+ serialization -+ ) - - if(NOT Boost_FOUND) - message(FATAL_ERROR "Please make sure Boost 1.48.0 is installed on your system") -- GitLab From 76a38295d1bf86335bd553383d44715b38963a6a Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Fri, 12 Jan 2018 11:01:51 +0100 Subject: [PATCH 174/567] DOC: Add a gitlab template for request for changes --- .../request_for_changes.md | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .gitlab/merge_request_templates/request_for_changes.md diff --git a/.gitlab/merge_request_templates/request_for_changes.md b/.gitlab/merge_request_templates/request_for_changes.md new file mode 100644 index 0000000000..6ac7059409 --- /dev/null +++ b/.gitlab/merge_request_templates/request_for_changes.md @@ -0,0 +1,31 @@ +## Title of the Request for Changes + +### Summary + +Gives a short summary of the changes. + +### Rationale + +Explain the rationale for the changes (possible link to a Request For Comments or to an issue). + +### Implementation Details + +#### Classes and files + +Give an overview of the implementation: main changes made to classes, files and module. Do not paste complete diff, as it is available in the merge request already. + +#### Applications + +Describe any changes made to existing applications, or new application that have been added. + +#### Tests + +Describe the testing strategy for new features. + +### Documentation + +List or link documentation modification that were made (doxygen, example, software guide, application documentation, cookbook). + +### Additional notes + +List remaining open issues if any, and additional notes. -- GitLab From c9c9200d777e39f0464cf7ffba1613a45fa6ffa6 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Fri, 12 Jan 2018 11:22:34 +0100 Subject: [PATCH 175/567] DOC: Adding gitlab templates for issues --- .gitlab/issue_templates/bugs.md | 13 +++++++++++++ .gitlab/issue_templates/documentation_changes.md | 9 +++++++++ .gitlab/issue_templates/feature_request.md | 3 +++ .gitlab/issue_templates/request_for_comments.md | 12 ++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 .gitlab/issue_templates/bugs.md create mode 100644 .gitlab/issue_templates/documentation_changes.md create mode 100644 .gitlab/issue_templates/feature_request.md create mode 100644 .gitlab/issue_templates/request_for_comments.md diff --git a/.gitlab/issue_templates/bugs.md b/.gitlab/issue_templates/bugs.md new file mode 100644 index 0000000000..adccec4314 --- /dev/null +++ b/.gitlab/issue_templates/bugs.md @@ -0,0 +1,13 @@ +## Title of the bug + +### Description + +Describe what happens and why you think it is a bug + +### Steps to reproduce + +Describe as precisely as possible how to reproduce the bug. Try to isolate a minimal number of steps. Also describe reproducibility (always, random ...). + +### Configuration information + +OS, OTB version or tag, information related to build (binaries, superbuild, system libs ...) diff --git a/.gitlab/issue_templates/documentation_changes.md b/.gitlab/issue_templates/documentation_changes.md new file mode 100644 index 0000000000..8150068589 --- /dev/null +++ b/.gitlab/issue_templates/documentation_changes.md @@ -0,0 +1,9 @@ +## Title of the documentation change requested + +### Target documentation ressources + +Can be a combination of Software guide, cookbook, doxygen, blog, applications doc, websites + +### Change requested + +Describe precisely the changes that are required. diff --git a/.gitlab/issue_templates/feature_request.md b/.gitlab/issue_templates/feature_request.md new file mode 100644 index 0000000000..fc0a276426 --- /dev/null +++ b/.gitlab/issue_templates/feature_request.md @@ -0,0 +1,3 @@ +## Title of the requested feature + +Short summary of the requested feature diff --git a/.gitlab/issue_templates/request_for_comments.md b/.gitlab/issue_templates/request_for_comments.md new file mode 100644 index 0000000000..d8e9cc3bdc --- /dev/null +++ b/.gitlab/issue_templates/request_for_comments.md @@ -0,0 +1,12 @@ +## Title of the resquest for comments + +### What changes will be made and why they would make a better Orfeo ToolBox? + +#### High level description + +#### Risks and benefits + +#### Alternatives for implementations + +### Who will be developing the proposed changes? + -- GitLab From 715bdbb1421915972017f6822a1081f4fceaa97b Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Fri, 12 Jan 2018 11:25:18 +0100 Subject: [PATCH 176/567] DOC: No need for titles in templates --- .gitlab/issue_templates/bugs.md | 2 -- .gitlab/issue_templates/documentation_changes.md | 2 -- .gitlab/issue_templates/feature_request.md | 2 -- .gitlab/issue_templates/request_for_comments.md | 2 -- .gitlab/merge_request_templates/request_for_changes.md | 2 -- 5 files changed, 10 deletions(-) diff --git a/.gitlab/issue_templates/bugs.md b/.gitlab/issue_templates/bugs.md index adccec4314..75b403c79f 100644 --- a/.gitlab/issue_templates/bugs.md +++ b/.gitlab/issue_templates/bugs.md @@ -1,5 +1,3 @@ -## Title of the bug - ### Description Describe what happens and why you think it is a bug diff --git a/.gitlab/issue_templates/documentation_changes.md b/.gitlab/issue_templates/documentation_changes.md index 8150068589..37545799be 100644 --- a/.gitlab/issue_templates/documentation_changes.md +++ b/.gitlab/issue_templates/documentation_changes.md @@ -1,5 +1,3 @@ -## Title of the documentation change requested - ### Target documentation ressources Can be a combination of Software guide, cookbook, doxygen, blog, applications doc, websites diff --git a/.gitlab/issue_templates/feature_request.md b/.gitlab/issue_templates/feature_request.md index fc0a276426..6031fad9a7 100644 --- a/.gitlab/issue_templates/feature_request.md +++ b/.gitlab/issue_templates/feature_request.md @@ -1,3 +1 @@ -## Title of the requested feature - Short summary of the requested feature diff --git a/.gitlab/issue_templates/request_for_comments.md b/.gitlab/issue_templates/request_for_comments.md index d8e9cc3bdc..2c74aae515 100644 --- a/.gitlab/issue_templates/request_for_comments.md +++ b/.gitlab/issue_templates/request_for_comments.md @@ -1,5 +1,3 @@ -## Title of the resquest for comments - ### What changes will be made and why they would make a better Orfeo ToolBox? #### High level description diff --git a/.gitlab/merge_request_templates/request_for_changes.md b/.gitlab/merge_request_templates/request_for_changes.md index 6ac7059409..1fcd722726 100644 --- a/.gitlab/merge_request_templates/request_for_changes.md +++ b/.gitlab/merge_request_templates/request_for_changes.md @@ -1,5 +1,3 @@ -## Title of the Request for Changes - ### Summary Gives a short summary of the changes. -- GitLab From b79555cc7f05fd479e1b364ed1ccb1e2a32c5f3c Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 26 Jan 2018 16:13:48 +0100 Subject: [PATCH 177/567] BUG: mantis 1508 fix a typo --- Modules/Applications/AppImageUtils/app/otbExtractROI.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index 0378a7024a..bd6a8d1583 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -729,7 +729,7 @@ private: urp_in[ 0 ] = ulx ; urp_in[ 1 ] = lry ; llp_in[ 0 ] = lrx ; - llp_in[ 1 ] = ulx ; + llp_in[ 1 ] = uly ; lrp_in[ 0 ] = lrx ; lrp_in[ 1 ] = lry ; ulp_out = rsTransform->TransformPoint(ulp_in); -- GitLab From 60f840a4aa07059ba0468a86c9b4bc708ca5dcc3 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 26 Jan 2018 18:31:08 +0100 Subject: [PATCH 178/567] DOC: new recipe for Python wrappings (WIP) --- .../Cookbook/rst/OTB-Applications.rst | 159 +------------ Documentation/Cookbook/rst/Recipes.rst | 1 + Documentation/Cookbook/rst/recipes/python.rst | 217 ++++++++++++++++++ 3 files changed, 229 insertions(+), 148 deletions(-) create mode 100644 Documentation/Cookbook/rst/recipes/python.rst diff --git a/Documentation/Cookbook/rst/OTB-Applications.rst b/Documentation/Cookbook/rst/OTB-Applications.rst index 55d0f53dd1..4da50bd9f4 100644 --- a/Documentation/Cookbook/rst/OTB-Applications.rst +++ b/Documentation/Cookbook/rst/OTB-Applications.rst @@ -203,165 +203,28 @@ available in the ``otb-bin`` OSGeo4W package, and the environment is configured automatically so you don’t need to tweak ``OTB_APPLICATION_PATH``. -In the ``otbApplication`` module, two main classes can be manipulated : - -- ``Registry``, which provides access to the list of available - applications, and can create applications. - -- ``Application``, the base class for all applications. This allows to - interact with an application instance created by the ``Registry``. - -Here is one example of how to use Python to run the ``Smoothing`` -application, changing the algorithm at each iteration. +Once your environment is set, you can use OTB applications from Python, just +like this small example: .. code-block:: python # Example on the use of the Smoothing application - # - - # We will use sys.argv to retrieve arguments from the command line. - # Here, the script will accept an image file as first argument, - # and the basename of the output files, without extension. - from sys import argv # The python module providing access to OTB applications is otbApplication - import otbApplication - - # otbApplication.Registry can tell you what application are available - print "Available applications: " - print str( otbApplication.Registry.GetAvailableApplications() ) + import otbApplication as otb # Let's create the application with codename "Smoothing" - app = otbApplication.Registry.CreateApplication("Smoothing") - - # We print the keys of all its parameter - print app.GetParametersKeys() - - # First, we set the input image filename - app.SetParameterString("in", argv[1]) - - # The smoothing algorithm can be set with the "type" parameter key - # and can take 3 values: 'mean', 'gaussian', 'anidif' - for type in ['mean', 'gaussian', 'anidif']: - - print 'Running with ' + type + ' smoothing type' - - # Here we configure the smoothing algorithm - app.SetParameterString("type", type) - - # Set the output filename, using the algorithm to differentiate the outputs - app.SetParameterString("out", argv[2] + type + ".tif") - - # This will execute the application and save the output file - app.ExecuteAndWriteOutput() - -Numpy array processing ----------------------- - -Input and output images to any OTB application in the form of numpy array is now possible in OTB python wrapping. -The python wrapping only exposes OTB ApplicationEngine module which allow to access existing C++ applications. -Due to blissful nature of ApplicationEngine's loading mechanism no specific wrapping is required for each application. - -Numpy extension to Python wrapping allows data exchange to application as an array rather than a disk file. -Ofcourse, it is possible to load an image from file and then convert to numpy array or just provide a file as earlier via -Application.SetParameterString(...). - -This bridge that completes numpy and OTB makes it easy to plug OTB into any image processing chain via python code that uses -GIS/Image processing tools such as GDAL, GRASS GIS, OSSIM that can deal with numpy. - - -Below code reads an input image using python pillow (PIL) and convert it to numpy array. This numpy array is -used an input to the application via *SetImageFromNumpyArray(...)* method. -The application used in this example is ExtractROI. After extracting -a small area the output image is taken as numpy array with *GetImageFromNumpyArray(...)* method thus avoid wiriting -output to a temporary file. - -:: - - import sys - import os - import numpy as np - import otbApplication - from PIL import Image as PILImage - - pilimage = PILImage.open('poupees.jpg') - npimage = np.asarray(pilimage) - inshow(pilimage) - - ExtractROI = otbApplication.Registry.CreateApplication('ExtractROI') - ExtractROI.SetImageFromNumpyArray('in', npimage) - ExtractROI.SetParameterInt('startx', 140) - ExtractROI.SetParameterInt('starty', 120) - ExtractROI.SetParameterInt('sizex', 150) - ExtractROI.SetParameterInt('sizey', 150) - ExtractROI.Execute() - - ExtractOutput = ExtractROI.GetImageAsNumpyArray('out') - output_pil_image = PILImage.fromarray(np.uint8(ExtractOutput)) - imshow(output_pil_image) - -In-memory connection --------------------- - -Applications are often use as parts of larger processing -chains. Chaining applications currently requires to write/read back -images between applications, resulting in heavy I/O operations and a -significant amount of time dedicated to writing temporary files. - -Since OTB 5.8, it is possible to connect an output image parameter -from one application to the input image parameter of the next -parameter. This results in the wiring of the internal ITK/OTB -pipelines together, allowing to perform image streaming between the -applications. There is therefore no more writing of temporary -images. The last application of the processing chain is responsible -for writing the final result images. - -In-memory connection between applications is available both at the C++ -API level and using the python bindings to the application presented -in the `Python interface`_ section. - -Here is a Python code sample connecting several applications together: - -.. code-block:: python - - import otbApplication as otb - - app1 = otb.Registry.CreateApplication("Smoothing") - app2 = otb.Registry.CreateApplication("Smoothing") - app3 = otb.Registry.CreateApplication("Smoothing") - app4 = otb.Registry.CreateApplication("ConcatenateImages") - - app1.IN = argv[1] - app1.Execute() - - # Connection between app1.out and app2.in - app2.SetParameterInputImage("in",app1.GetParameterOutputImage("out")) - - # Execute call is mandatory to wire the pipeline and expose the - # application output. It does not write image - app2.Execute() - - app3.IN = argv[1] - - # Execute call is mandatory to wire the pipeline and expose the - # application output. It does not write image - app3.Execute() - - # Connection between app2.out, app3.out and app4.il using images list - app4.AddImageToParameterInputImageList("il",app2.GetParameterOutputImage("out")); - app4.AddImageToParameterInputImageList("il",app3.GetParameterOutputImage("out")); + app = otb.Registry.CreateApplication("Smoothing") - app4.OUT = argv[2] + # We set its parameters + app.SetParameterString("in", "my_input_image.tif") + app.SetParameterString("type", "mean") + app.SetParameterString("out", "my_output_image.tif") - # Call to ExecuteAndWriteOutput() both wires the pipeline and - # actually writes the output, only necessary for last application of - # the chain. - app4.ExecuteAndWriteOutput() + # This will execute the application and save the output file + app.ExecuteAndWriteOutput() -**Note:** Streaming will only work properly if the application internal -implementation does not break it, for instance by using an internal -writer to write intermediate data. In this case, execution should -still be correct, but some intermediate data will be read or written. +For more information about this Python interface, check the recipe section. QGIS interface -------------- diff --git a/Documentation/Cookbook/rst/Recipes.rst b/Documentation/Cookbook/rst/Recipes.rst index 18cab29de9..867f8e2b85 100644 --- a/Documentation/Cookbook/rst/Recipes.rst +++ b/Documentation/Cookbook/rst/Recipes.rst @@ -18,4 +18,5 @@ and demonstrate how the can be applied. recipes/pbclassif.rst recipes/featextract.rst recipes/stereo.rst + recipes/python.rst diff --git a/Documentation/Cookbook/rst/recipes/python.rst b/Documentation/Cookbook/rst/recipes/python.rst new file mode 100644 index 0000000000..c6ccebdf0b --- /dev/null +++ b/Documentation/Cookbook/rst/recipes/python.rst @@ -0,0 +1,217 @@ +OTB processing in Python +======================== + +Basics +------ + +In the ``otbApplication`` module, two main classes can be manipulated : + +- ``Registry``, which provides access to the list of available + applications, and can create applications. + +- ``Application``, the base class for all applications. This allows to + interact with an application instance created by the ``Registry``. + +Here is one example of how to use Python to run the ``Smoothing`` +application, changing the algorithm at each iteration. + +.. code-block:: python + + # Example on the use of the Smoothing application + # + + # We will use sys.argv to retrieve arguments from the command line. + # Here, the script will accept an image file as first argument, + # and the basename of the output files, without extension. + from sys import argv + + # The python module providing access to OTB applications is otbApplication + import otbApplication + + # otbApplication.Registry can tell you what application are available + print "Available applications: " + print str( otbApplication.Registry.GetAvailableApplications() ) + + # Let's create the application with codename "Smoothing" + app = otbApplication.Registry.CreateApplication("Smoothing") + + # We print the keys of all its parameter + print app.GetParametersKeys() + + # First, we set the input image filename + app.SetParameterString("in", argv[1]) + + # The smoothing algorithm can be set with the "type" parameter key + # and can take 3 values: 'mean', 'gaussian', 'anidif' + for type in ['mean', 'gaussian', 'anidif']: + + print 'Running with ' + type + ' smoothing type' + + # Here we configure the smoothing algorithm + app.SetParameterString("type", type) + + # Set the output filename, using the algorithm to differentiate the outputs + app.SetParameterString("out", argv[2] + type + ".tif") + + # This will execute the application and save the output file + app.ExecuteAndWriteOutput() + +Numpy array processing +---------------------- + +Input and output images to any OTB application in the form of numpy array is now possible in OTB python wrapping. +The python wrapping only exposes OTB ApplicationEngine module which allow to access existing C++ applications. +Due to blissful nature of ApplicationEngine's loading mechanism no specific wrapping is required for each application. + +Numpy extension to Python wrapping allows data exchange to application as an array rather than a disk file. +Ofcourse, it is possible to load an image from file and then convert to numpy array or just provide a file as earlier via +Application.SetParameterString(...). + +This bridge that completes numpy and OTB makes it easy to plug OTB into any image processing chain via python code that uses +GIS/Image processing tools such as GDAL, GRASS GIS, OSSIM that can deal with numpy. + + +Below code reads an input image using python pillow (PIL) and convert it to numpy array. This numpy array is +used an input to the application via *SetImageFromNumpyArray(...)* method. +The application used in this example is ExtractROI. After extracting +a small area the output image is taken as numpy array with *GetImageFromNumpyArray(...)* method thus avoid wiriting +output to a temporary file. + +:: + + import sys + import os + import numpy as np + import otbApplication + from PIL import Image as PILImage + + pilimage = PILImage.open('poupees.jpg') + npimage = np.asarray(pilimage) + inshow(pilimage) + + ExtractROI = otbApplication.Registry.CreateApplication('ExtractROI') + ExtractROI.SetImageFromNumpyArray('in', npimage) + ExtractROI.SetParameterInt('startx', 140) + ExtractROI.SetParameterInt('starty', 120) + ExtractROI.SetParameterInt('sizex', 150) + ExtractROI.SetParameterInt('sizey', 150) + ExtractROI.Execute() + + ExtractOutput = ExtractROI.GetImageAsNumpyArray('out') + output_pil_image = PILImage.fromarray(np.uint8(ExtractOutput)) + imshow(output_pil_image) + +In-memory connection +-------------------- + +Applications are often use as parts of larger processing +chains. Chaining applications currently requires to write/read back +images between applications, resulting in heavy I/O operations and a +significant amount of time dedicated to writing temporary files. + +Since OTB 5.8, it is possible to connect an output image parameter +from one application to the input image parameter of the next +parameter. This results in the wiring of the internal ITK/OTB +pipelines together, allowing to perform image streaming between the +applications. There is therefore no more writing of temporary +images. The last application of the processing chain is responsible +for writing the final result images. + +In-memory connection between applications is available both at the C++ +API level and using the python bindings. + +Here is a Python code sample connecting several applications together: + +.. code-block:: python + + import otbApplication as otb + + app1 = otb.Registry.CreateApplication("Smoothing") + app2 = otb.Registry.CreateApplication("Smoothing") + app3 = otb.Registry.CreateApplication("Smoothing") + app4 = otb.Registry.CreateApplication("ConcatenateImages") + + app1.IN = argv[1] + app1.Execute() + + # Connection between app1.out and app2.in + app2.SetParameterInputImage("in",app1.GetParameterOutputImage("out")) + + # Execute call is mandatory to wire the pipeline and expose the + # application output. It does not write image + app2.Execute() + + app3.IN = argv[1] + + # Execute call is mandatory to wire the pipeline and expose the + # application output. It does not write image + app3.Execute() + + # Connection between app2.out, app3.out and app4.il using images list + app4.AddImageToParameterInputImageList("il",app2.GetParameterOutputImage("out")); + app4.AddImageToParameterInputImageList("il",app3.GetParameterOutputImage("out")); + + app4.OUT = argv[2] + + # Call to ExecuteAndWriteOutput() both wires the pipeline and + # actually writes the output, only necessary for last application of + # the chain. + app4.ExecuteAndWriteOutput() + +**Note:** Streaming will only work properly if the application internal +implementation does not break it, for instance by using an internal +writer to write intermediate data. In this case, execution should +still be correct, but some intermediate data will be read or written. + +Corner cases +------------ + +There are a few corner cases to be aware of when using Python wrappers. They are +often limitations, that one day may be solved by future developments. If it +happens, this documentation will report the OTB version that fixes the issue. + +Calling UpdateParameters() +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +These wrappers are made as a mirror of the C++ API, so there is a function +``UpdateParameters()``. Its role is to update parameters that depend on others. +It is called at least once at the beginning of ``Execute()``. + +In command line and GUI launchers, this functions gets called each time a +parameter of the application is modified. In Python, this mechanism is not +automated: there are cases where you may have to call it yourself. + +Let's take an example with the application ``PolygonClassStatictics``. In this +application, the choices available in the parameter ``field`` depend on the list +of fields actually present in the vector file ``vec``. If you try to set the +parameters ``vec`` and ``field``, you will get an error: + +.. code-block:: python + + import otbApplication as otb + app = otb.Registry.CreateApplication("PolygonClassStatistics") + app.SetParameterString("vec","../../src/OTB-Data/Input/Classification/variousVectors.sqlite") + app.SetParameterString("field", "label") + +:: + + Traceback (most recent call last): + File "<stdin>", line 1, in <module> + File "/home/gpasero/Projet_OTB/build/OTB/lib/otb/python/otbApplication.py", line 897, in SetParameterString + def SetParameterString(self, *args): return _otbApplication.Application_SetParameterString(self, *args) + RuntimeError: Exception thrown in otbApplication Application_SetParameterString: /home/gpasero/Projet_OTB/src/OTB/Modules/Wrappers/ApplicationEngine/src/otbWrapperListViewParameter.cxx:141: + itk::ERROR: ListViewParameter(0x149da10): Cannot find label + +The error says that the choice ``label`` is not recognized, because ``UpdateParameters()`` +was not called after setting the vector file. The solution is to call it before +setting the ``field`` parameter: + +.. code-block:: python + + app.UpdateParameters() + app.SetParameterString("field", "label") + +No metadata in Numpy arrays +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +TODO -- GitLab From 4dce63d8994ac5cd76a94073f6b8a9f4c94f17e8 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 29 Jan 2018 12:27:42 +0100 Subject: [PATCH 179/567] DOC: corner cases with Python API --- Documentation/Cookbook/rst/recipes/python.rst | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/Documentation/Cookbook/rst/recipes/python.rst b/Documentation/Cookbook/rst/recipes/python.rst index c6ccebdf0b..cbb119372d 100644 --- a/Documentation/Cookbook/rst/recipes/python.rst +++ b/Documentation/Cookbook/rst/recipes/python.rst @@ -214,4 +214,52 @@ setting the ``field`` parameter: No metadata in Numpy arrays ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -TODO +With the Numpy module, it is possible to convert images between OTB and Numpy +arrays. For instance, when converting from OTB to Numpy array: + +* An ``Update()`` of the underlying ``otb::VectorImage`` is requested. Be aware + that the full image is generated. +* The pixel buffer is copied into a ``numpy.array`` + +As you can see, there is no export of the metadata, such as origin, spacing, +projection WKT. It means that if you want to import back a Numpy array into OTB, +the image won't have any of these metadata. It can be a problem for applications +doing geometry, projections, and also calibration. + +Future developments will probably offer a more adapted structure to import and +export images between OTB and Python world. + +Setting of boolean parameters +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Most of the parameters are set using functions ``SetParameterXXX()``. The boolean +parameters are handled differently (also called Empty parameter). Let's take an example with the application +``ReadImageInfo``: + +.. code-block:: python + + import otbApplication as otb + app = otb.Registry.CreateApplication("ReadImageInfo") + +If you want the get the state of parameter ``keywordlist``, a boolean, use: + +.. code-block:: python + + app.IsParameterEnabled("keywordlist") + +To set this parameter ON / OFF, use the functions: + +.. code-block:: python + + app.EnableParameter("keywordlist") + app.DisableParameter("keywordlist") + +Don't try to use other functions to set the state of a boolean. For instance, +try the following commands: + +.. code-block:: python + + app.SetParameterInt("keywordlist", 0) + app.IsParameterEnabled("keywordlist") + +You will get a state ``True`` even if you asked the opposite. -- GitLab From a2119c37e64b2d449d369b7222108ddb80fd62d4 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 30 Jan 2018 08:32:38 +0100 Subject: [PATCH 180/567] DOC: update release notes --- RELEASE_NOTES.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 2421280562..42bd370fe8 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,4 +1,4 @@ -OTB-v.6.4.0 - Changes since version 6.2.0 (January 17th, 2018) +OTB-v.6.4.0 - Changes since version 6.2.0 (January 30th, 2018) ---------------------------------------------------------- * Request for Changes (http://wiki.orfeo-toolbox.org/index.php/Requests_for_Changes): @@ -16,6 +16,11 @@ OTB-v.6.4.0 - Changes since version 6.2.0 (January 17th, 2018) * Bugfixes: * Orfeo Toolbox (OTB) + * 0001508: ExtractROI does not work with mode.fit.vect + * 0001509: Patch to fix spelling errors in 6.4.0-rc1 + * 0001482: In 6.2, otbcli_Convert with MPI produces invalid tiff files + * 0001507: Segmentation segfault + * 0001488: OTB apps sometime do not appear in the widget * 0001501: Does Java wrapping works on Windows? * 0001495: Crash when setting Orthorectification input field * 0001489: BandMath and BandMathX are missing important documentation on expression syntax @@ -25,12 +30,12 @@ OTB-v.6.4.0 - Changes since version 6.2.0 (January 17th, 2018) * 0001483: Monteverdi shows a pop up terminal on windows * 0001496: Monteverdi 'build overviews' pop-up trigger condition is unclear or incorrect * 0001494: Segmentation app shows 'Select parameters' instead of 'Running' - * 0001504: OTB does not compile with ITK last stable release 4.13 * 0001492: Monteverdi 6.2 is missing some French translations - * 0001503: Fix new coverity issues in release 6.4 * 0001499: OSSIMAdapters fails to build with OSSIM 2.2.0 (error: 'class ossimRpcSolver' has no member named 'createRpcProjection') * 0001498: ExtractROI Channel list empty when application is chained in memory - * 0001476: Python wrapping not working with Python >= 3.4 + * 0001476: Python wrapping not working with Python >= 3. + * 0001504: OTB does not compile with ITK last stable release 4.13 + * 0001503: Fix new coverity issues in release 6.4 * Documentation * 0001500: Application example in OTB software guide is confusing -- GitLab From 3a5df5d7e389a09be6adc637fd12b54e119381cd Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 30 Jan 2018 14:55:40 +0100 Subject: [PATCH 181/567] REFAC: Refactor ossimSarSensorModel to add a new worldToLineSample variant that also returns y,z as defined in method documentation --- .../include/ossim/ossimSarSensorModel.h | 32 +++++- .../src/ossim/ossimSarSensorModel.cpp | 101 ++++++++++++++++-- 2 files changed, 120 insertions(+), 13 deletions(-) diff --git a/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h b/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h index 95899b213f..f6a2929744 100644 --- a/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h +++ b/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h @@ -238,13 +238,36 @@ public: * \param[in] worldPoint World point to geocode * \param[out] azimuthTime Estimated zero-doppler azimuth time * \param[out] rangeTime Estimated range time + * \param[out] interpSensorPos interpolated ECEF sensor position + * \param[out] interpSensorVel interpolated ECEF sensor velocity * \return True if success, false otherwise. In this case, * azimuthTime and rangeTime will not be modified. */ - /*virtual*/ bool worldToAzimuthRangeTime(const ossimGpt& worldPt, TimeType & azimuthTime, double & rangeTime) const; + /*virtual*/ bool worldToAzimuthRangeTime(const ossimGpt& worldPt, TimeType & azimuthTime, double & rangeTime, ossimEcefPoint & interpSensorPos, ossimEcefVector & interpSensorVel) const; - // TODO: document me - /*virtual*/ void lineSampleToAzimuthRangeTime(const ossimDpt & imPt, TimeType & azimuthTime, double & rangeTime) const; + /** + * This method implement inverse sar geolocation similar to + * worldToLineSample, except that it also returns (y,z) + * coordinates, defined as follows: + * Let n = |sensorPos|, + * ps2 = scalar_product(sensorPos,worldPoint) + * d = distance(sensorPos,worldPoint) + * + * z = n - ps2/n + * y = sqrt(d*d - z*z) + * + * sign of y is furher adapted to be inverted if sensor is left or + * right looking + * + * \param[in] worldPoint World point to geocode + * \param[out] imPt Corresponding estimated image point + * \param[out] y + * \param[out] z + * \return True if success, false otherwise. In this case, + */ + void worldToLineSampleYZ(const ossimGpt& worldPt, ossimDpt& imPt, double & y, double & z) const; + + void lineSampleToAzimuthRangeTime(const ossimDpt & imPt, TimeType & azimuthTime, double & rangeTime) const; // TODO: document me bool autovalidateInverseModelFromGCPs(const double & xtol = 1, const double & ytol = 1, const double azTimeTol = 500, const double &rangeTimeTo=0.0000000001) const; @@ -419,7 +442,8 @@ protected: ProductType theProductType; // GRD/SLC DurationType theAzimuthTimeOffset; // Offset computed double theRangeTimeOffset; // Offset in seconds, computed - + bool theRightLookingFlag; + static const double C; private: /** Disabled assignment operator. */ diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp index 46381857ea..cc0fbb30aa 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp @@ -12,7 +12,7 @@ * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -136,7 +136,8 @@ namespace ossimplugins theRangeResolution(0.), theBistaticCorrectionNeeded(false), theAzimuthTimeOffset(seconds(0)), - theRangeTimeOffset(0.) + theRangeTimeOffset(0.), + theRightLookingFlag(true) {} ossimSarSensorModel::GCPRecordType const& @@ -219,7 +220,58 @@ namespace ossimplugins TimeType azimuthTime; double rangeTime; - const bool success = worldToAzimuthRangeTime(worldPt, azimuthTime, rangeTime); + ossimEcefPoint sensorPos; + ossimEcefVector sensorVel; + + const bool success = worldToAzimuthRangeTime(worldPt, azimuthTime, rangeTime, sensorPos, sensorVel); + + if(!success) + { + imPt.makeNan(); + return; + } + // std::clog << "AzimuthTime: " << azimuthTime << "\n"; + // std::clog << "RangeTime: " << rangeTime << "\n"; + // std::clog << "GRD: " << isGRD() << "\n"; + + // Convert azimuth time to line + azimuthTimeToLine(azimuthTime,imPt.y); + + if(isGRD()) + { + // GRD case + double groundRange(0); + slantRangeToGroundRange(rangeTime*C/2,azimuthTime,groundRange); + // std::clog << "GroundRange: " << groundRange << "\n"; + // std::clog << "TheRangeResolution: " << theRangeResolution << "\n"; + + // Eq 32 p. 31 + // TODO: possible micro-optimization: precompute 1/theRangeResolution, and + // use * + imPt.x = groundRange/theRangeResolution; + } + else + { + // std::clog << "TheNearRangeTime: " << theNearRangeTime << "\n"; + // std::clog << "TheRangeSamplingRate: " << theRangeSamplingRate << "\n"; + // SLC case + // Eq 23 and 24 p. 28 + imPt.x = (rangeTime - theNearRangeTime)*theRangeSamplingRate; + } + } + +void ossimSarSensorModel::worldToLineSampleYZ(const ossimGpt& worldPt, ossimDpt & imPt, double & y, double & z) const + { + // std::clog << "ossimSarSensorModel::worldToLineSample()\n"; + assert(theRangeResolution>0&&"theRangeResolution is null."); + + // First compute azimuth and range time + TimeType azimuthTime; + double rangeTime; + ossimEcefPoint sensorPos; + ossimEcefVector sensorVel; + + const bool success = worldToAzimuthRangeTime(worldPt, azimuthTime, rangeTime,sensorPos,sensorVel); if(!success) { @@ -254,9 +306,35 @@ namespace ossimplugins // Eq 23 and 24 p. 28 imPt.x = (rangeTime - theNearRangeTime)*theRangeSamplingRate; } + + // Now computes Y and Z + ossimEcefPoint inputPt(worldPt); + double NormeS = sqrt(sensorPos[0]*sensorPos[0] + sensorPos[1]*sensorPos[1] + sensorPos[2]*sensorPos[2]); /* distance du radar */ + double PS2 = inputPt[0]*sensorPos[0] + inputPt[1]*sensorPos[1] + inputPt[2]*sensorPos[2]; + + // TODO check for small NormesS to avoid division by zero ? + // Should never happen ... + assert(NormesS>1e-6); + z = NormeS - PS2/NormeS; + + double distance = sqrt((sensorPos[0]-inputPt[0])*(sensorPos[0]-inputPt[0]) + + (sensorPos[1]-inputPt[1])*(sensorPos[1]-inputPt[1]) + + (sensorPos[2]-inputPt[2])*(sensorPos[2]-inputPt[2])); + + y = sqrt(distance*distance - z*z); + + // Check view side and change sign of Y accordingly + if ( (( sensorVel[0] * (sensorPos[1]* inputPt[2] - sensorPos[2]* inputPt[1]) + + sensorVel[1] * (sensorPos[2]* inputPt[0] - sensorPos[0]* inputPt[2]) + + sensorVel[2] * (sensorPos[0]* inputPt[1] - sensorPos[1]* inputPt[0])) > 0) ^ theRightLookingFlag ) + { + y = -y; + } } - bool ossimSarSensorModel::worldToAzimuthRangeTime(const ossimGpt& worldPt, TimeType & azimuthTime, double & rangeTime) const + + +bool ossimSarSensorModel::worldToAzimuthRangeTime(const ossimGpt& worldPt, TimeType & azimuthTime, double & rangeTime, ossimEcefPoint & interpSensorPos, ossimEcefVector & interpSensorVel) const { // std::clog << "ossimSarSensorModel::worldToAzimuthRangeTime()\n"; // First convert lat/lon to ECEF @@ -264,8 +342,6 @@ namespace ossimplugins // Compute zero doppler time TimeType interpTime; - ossimEcefPoint interpSensorPos; - ossimEcefVector interpSensorVel; const bool success = zeroDopplerLookup(inputPt,azimuthTime,interpSensorPos,interpSensorVel); @@ -856,7 +932,9 @@ namespace ossimplugins double estimatedRangeTime; // Estimate times - const bool s1 = this->worldToAzimuthRangeTime(gcpIt->worldPt,estimatedAzimuthTime,estimatedRangeTime); + ossimEcefPoint sensorPos; + ossimEcefVector sensorVel; + const bool s1 = this->worldToAzimuthRangeTime(gcpIt->worldPt,estimatedAzimuthTime,estimatedRangeTime,sensorPos, sensorVel); this->worldToLineSample(gcpIt->worldPt,estimatedImPt); const bool thisSuccess @@ -960,8 +1038,10 @@ namespace ossimplugins TimeType estimatedAzimuthTime; double estimatedRangeTime; + ossimEcefPoint sensorPos; + ossimEcefVector sensorVel; // Estimate times - const bool s1 = this->worldToAzimuthRangeTime(gcpIt->worldPt,estimatedAzimuthTime,estimatedRangeTime); + const bool s1 = this->worldToAzimuthRangeTime(gcpIt->worldPt,estimatedAzimuthTime,estimatedRangeTime, sensorPos, sensorVel); if(s1) { @@ -981,8 +1061,11 @@ namespace ossimplugins TimeType estimatedAzimuthTime; double estimatedRangeTime; + ossimEcefPoint sensorPos; + ossimEcefVector sensorVel; + // Estimate times - const bool s1 = this->worldToAzimuthRangeTime(gcpIt->worldPt,estimatedAzimuthTime,estimatedRangeTime); + const bool s1 = this->worldToAzimuthRangeTime(gcpIt->worldPt,estimatedAzimuthTime,estimatedRangeTime, sensorPos, sensorVel); if(s1) { -- GitLab From ad38ca26330df583abd33a85e339e8b57bac03d7 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 30 Jan 2018 14:56:08 +0100 Subject: [PATCH 182/567] ENH: Expose new methods in SarSensorModelAdapter --- .../include/otbSarSensorModelAdapter.h | 12 +++++ .../src/otbSarSensorModelAdapter.cxx | 52 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h index 692c1574fc..33939b1610 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h @@ -24,6 +24,7 @@ #include <memory> #include "otbDEMHandler.h" +#include "itkPoint.h" namespace ossimplugins { @@ -62,6 +63,9 @@ public: typedef std::auto_ptr<ossimplugins::ossimSarSensorModel> InternalModelPointer; + using Point2DType = itk::Point<double,2>; + using Point3DType = itk::Point<double,3>; + /** Method for creation through the object factory. */ itkNewMacro(Self); @@ -80,6 +84,14 @@ public: /** Deburst metadata if possible and return lines to keep in image file */ bool Deburst(std::vector<std::pair<unsigned long, unsigned long> > & lines); + /** Transform world point (lat,lon,hgt) to input image point + (col,row) and YZ frame */ + bool WorldToLineSampleYZ(const Point3DType & inGeoPoint, Point2DType & cr, Point2DType yz) const; + + /** Transform world point (lat,lon,hgt) to input image point + (col,row) */ + bool WorldToLineSample(const Point3DType & inGEoPOint, Point2DType & cr) const; + static bool ImageLineToDeburstLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long imageLine, unsigned long & deburstLine); static void DeburstLineToImageLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long deburstLine, unsigned long & imageLine); diff --git a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx index 62d5203af5..d81fbc2b16 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx @@ -109,6 +109,58 @@ void SarSensorModelAdapter::DeburstLineToImageLine(const std::vector<std::pair<u ossimplugins::ossimSarSensorModel::deburstLineToImageLine(lines,deburstLine,imageLine); } +bool SarSensorModelAdapter::WorldToLineSampleYZ(const Point3DType & inGeoPoint, Point2DType & cr, Point2DType yz) const +{ + if(m_SensorModel.get() == ITK_NULLPTR) + { + return false; + } + + ossimGpt inGpt; + inGpt.lat = inGeoPoint[0]; + inGpt.lon = inGeoPoint[1]; + inGpt.hgt = inGeoPoint[2]; + + ossimDpt outDpt; + + double y(0.),z(0.); + m_SensorModel->worldToLineSampleYZ(inGpt,outDpt,y,z); + + if(outDpt.isNan()) + return false; + + cr[0]=outDpt.x; + cr[1]=outDpt.y; + yz[0]=y; + yz[1]=z; + + return true; +} + +bool SarSensorModelAdapter::WorldToLineSample(const Point3DType & inGeoPoint, Point2DType & cr) const +{ + if(m_SensorModel.get() == ITK_NULLPTR) + { + return false; + } + + ossimGpt inGpt; + inGpt.lat = inGeoPoint[0]; + inGpt.lon = inGeoPoint[1]; + inGpt.hgt = inGeoPoint[2]; + + ossimDpt outDpt; + + m_SensorModel->worldToLineSample(inGpt,outDpt); + + if(outDpt.isNan()) + return false; + + cr[0]=outDpt.x; + cr[1]=outDpt.y; + + return true; +} -- GitLab From 8bf7e5b39408a76d0b8114eb69bd82458d6b2c25 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 30 Jan 2018 15:37:03 +0100 Subject: [PATCH 183/567] TEST: Add a test of SarSensorModelAdapter --- .../OSSIMAdapters/test/CMakeLists.txt | 6 ++ .../test/otbOSSIMAdaptersTestDriver.cxx | 1 + .../test/otbSarSensorModelAdapterTest.cxx | 80 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 Modules/Adapters/OSSIMAdapters/test/otbSarSensorModelAdapterTest.cxx diff --git a/Modules/Adapters/OSSIMAdapters/test/CMakeLists.txt b/Modules/Adapters/OSSIMAdapters/test/CMakeLists.txt index 54a7117fc9..8dadc14ff0 100644 --- a/Modules/Adapters/OSSIMAdapters/test/CMakeLists.txt +++ b/Modules/Adapters/OSSIMAdapters/test/CMakeLists.txt @@ -31,6 +31,7 @@ otbGeometricSarSensorModelAdapter.cxx otbPlatformPositionAdapter.cxx otbDEMHandlerTest.cxx otbRPCSolverAdapterTest.cxx +otbSarSensorModelAdapterTest.cxx ) add_executable(otbOSSIMAdaptersTestDriver ${OTBOSSIMAdaptersTests}) @@ -499,3 +500,8 @@ otb_add_test(NAME uaTvRPCSolverAdapterValidationTest COMMAND otbOSSIMAdaptersTes ${INPUTDATA}/DEM/egm96.grd ) + +otb_add_test(NAME uaTvSarSensorModelAdapter COMMAND otbOSSIMAdaptersTestDriver + otbSarSensorModelAdapterTest + ${INPUTDATA}/s1a-iw1-slc-vh-amp_xt.geom + ) diff --git a/Modules/Adapters/OSSIMAdapters/test/otbOSSIMAdaptersTestDriver.cxx b/Modules/Adapters/OSSIMAdapters/test/otbOSSIMAdaptersTestDriver.cxx index 911e57e671..5f7295d6df 100644 --- a/Modules/Adapters/OSSIMAdapters/test/otbOSSIMAdaptersTestDriver.cxx +++ b/Modules/Adapters/OSSIMAdapters/test/otbOSSIMAdaptersTestDriver.cxx @@ -33,4 +33,5 @@ void RegisterTests() REGISTER_TEST(otbPlatformPositionComputeBaselineTest); REGISTER_TEST(otbDEMHandlerTest); REGISTER_TEST(otbRPCSolverAdapterTest); + REGISTER_TEST(otbSarSensorModelAdapterTest); } diff --git a/Modules/Adapters/OSSIMAdapters/test/otbSarSensorModelAdapterTest.cxx b/Modules/Adapters/OSSIMAdapters/test/otbSarSensorModelAdapterTest.cxx new file mode 100644 index 0000000000..828ed4f747 --- /dev/null +++ b/Modules/Adapters/OSSIMAdapters/test/otbSarSensorModelAdapterTest.cxx @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <fstream> +#include <iomanip> + +#include "otbSarSensorModelAdapter.h" +#include "otbImageKeywordlist.h" + + +int otbSarSensorModelAdapterTest(int itkNotUsed(argc), char* argv[]) +{ + std::string infname = argv[1]; + + otb::SarSensorModelAdapter::Pointer sensorModel = otb::SarSensorModelAdapter::New(); + + auto kwl = otb::ReadGeometryFromGEOMFile(infname); + + bool success = sensorModel->LoadState(kwl); + + if(!success) + { + std::cerr<<"Could not LoadState() from keyword list read from"<<infname<<std::endl; + return EXIT_FAILURE; + } + + std::vector<std::pair<unsigned long, unsigned long> > lines; + success = sensorModel->Deburst(lines); + + if(!success) + { + std::cerr<<"Deburst() call failed."<<std::endl; + return EXIT_FAILURE; + } + + + otb::ImageKeywordlist outKwl; + success = sensorModel->SaveState(outKwl); + if(!success) + { + std::cerr<<"SaveState() call failed."<<std::endl; + return EXIT_FAILURE; + } + + + otb::SarSensorModelAdapter::Point2DType out1,out2; + otb::SarSensorModelAdapter::Point3DType in; + + // GCP 99 from input geom file + //support_data.geom.gcp[99].world_pt.hgt: 2.238244926818182e+02 + //support_data.geom.gcp[99].world_pt.lat: 4.323458093295080e+01 + //support_data.geom.gcp[99].world_pt.lon: 1.116316013091967e+00 + + in[0] = 4.323458093295080e+01; + in[1] = 1.116316013091967e+00; + in[2] = 2.238244926818182e+02; + + sensorModel->WorldToLineSample(in,out1); + sensorModel->WorldToLineSampleYZ(in,out1,out2); + + return EXIT_SUCCESS; +} -- GitLab From d0e48dc2ad0e60ff0f49e72f3e196d6cdf679210 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 31 Jan 2018 17:37:04 +0100 Subject: [PATCH 184/567] DOC: update URL for git repository --- Documentation/Cookbook/rst/FAQ.rst | 4 ++-- Documentation/Cookbook/rst/Installation_Linux_xdk.txt | 2 +- Documentation/Cookbook/rst/Monteverdi.rst | 2 +- Documentation/Cookbook/rst/recipes/optpreproc.rst | 2 +- Documentation/Cookbook/rst/recipes/pbclassif.rst | 2 +- Documentation/SoftwareGuide/Latex/Installation.tex | 2 +- Documentation/SoftwareGuide/Latex/Introduction.tex | 6 +++--- Documentation/SoftwareGuide/Latex/Tutorial.tex | 2 +- .../src/otbWrapperElevationParametersHandler.cxx | 6 +++++- README.md | 10 +++++----- 10 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Documentation/Cookbook/rst/FAQ.rst b/Documentation/Cookbook/rst/FAQ.rst index 490e77a34c..83faac13ab 100644 --- a/Documentation/Cookbook/rst/FAQ.rst +++ b/Documentation/Cookbook/rst/FAQ.rst @@ -189,7 +189,7 @@ The first time, you can get the source code using: :: - git clone https://git@git.orfeo-toolbox.org/git/otb.git + git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git Then you can build OTB as usual using this directory as the source (refer to build instructions). Later if you want to update your source, @@ -428,7 +428,7 @@ You can get the base doing: :: - git clone https://git@git.orfeo-toolbox.org/git/otb-data.git + git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data.git This is about 1 GB of data, so it will take a while, but you have to do it only once, as after, a simple diff --git a/Documentation/Cookbook/rst/Installation_Linux_xdk.txt b/Documentation/Cookbook/rst/Installation_Linux_xdk.txt index a81d7f1f6f..38c890f066 100644 --- a/Documentation/Cookbook/rst/Installation_Linux_xdk.txt +++ b/Documentation/Cookbook/rst/Installation_Linux_xdk.txt @@ -54,7 +54,7 @@ Download, Configure and build OTB :: mkdir -p /opt/OTB/build && cd /opt/OTB - git clone --depth=1 --branch=develop https://git@git.orfeo-toolbox.org/git/otb.git source + git clone --depth=1 --branch=develop https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git source cd build && cmake ../source make -j2 diff --git a/Documentation/Cookbook/rst/Monteverdi.rst b/Documentation/Cookbook/rst/Monteverdi.rst index 257ae1a017..ac362cc282 100644 --- a/Documentation/Cookbook/rst/Monteverdi.rst +++ b/Documentation/Cookbook/rst/Monteverdi.rst @@ -321,7 +321,7 @@ Conclusion ~~~~~~~~~~ The images used in this documentation can be found in the OTB-Data -repository (https://git.orfeo-toolbox.org/otb-data.git): +repository (https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data.git): - in OTB-Data/Input: diff --git a/Documentation/Cookbook/rst/recipes/optpreproc.rst b/Documentation/Cookbook/rst/recipes/optpreproc.rst index 41b1169fa8..e3f00ca3a4 100644 --- a/Documentation/Cookbook/rst/recipes/optpreproc.rst +++ b/Documentation/Cookbook/rst/recipes/optpreproc.rst @@ -242,7 +242,7 @@ path to a file which contains the geoid. `Geoid <http://en.wikipedia.org/wiki/Ge corresponds to the equipotential surface that would coincide with the mean ocean surface of the Earth. -We provide one geoid in the `OTB-Data <https://git.orfeo-toolbox.org/otb-data.git/tree/HEAD:/Input/DEM>`_ repository. +We provide one geoid in the `OTB-Data <https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/tree/master/Input/DEM>`_ repository. In all applications, the option **elev.geoid** allows to manage the path to the geoid. Finally, it is also possible to use an average elevation diff --git a/Documentation/Cookbook/rst/recipes/pbclassif.rst b/Documentation/Cookbook/rst/recipes/pbclassif.rst index 1e26e4c7f5..4202066085 100644 --- a/Documentation/Cookbook/rst/recipes/pbclassif.rst +++ b/Documentation/Cookbook/rst/recipes/pbclassif.rst @@ -525,7 +525,7 @@ Example We consider 4 classes: water, roads, vegetation and buildings with red roofs. Data is available in the OTB-Data -`repository <https://git.orfeo-toolbox.org/otb-data.git/tree/HEAD:/Input/Classification>`_ . +`repository <https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/tree/master/Input/Classification>`_ . .. |image_21| image:: ../Art/MonteverdiImages/classification_chain_inputimage.jpg .. |image_22| image:: ../Art/MonteverdiImages/classification_chain_fancyclassif_fusion.jpg diff --git a/Documentation/SoftwareGuide/Latex/Installation.tex b/Documentation/SoftwareGuide/Latex/Installation.tex index ea869b7531..e6ab1534d2 100644 --- a/Documentation/SoftwareGuide/Latex/Installation.tex +++ b/Documentation/SoftwareGuide/Latex/Installation.tex @@ -163,7 +163,7 @@ To setup this structure, the following commands can be used: \begin{verbatim} $ mkdir ~/OTB $ cd ~/OTB -$ git clone https://git@git.orfeo-toolbox.org/git/otb.git +$ git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git $ mkdir build $ mkdir install \end{verbatim} diff --git a/Documentation/SoftwareGuide/Latex/Introduction.tex b/Documentation/SoftwareGuide/Latex/Introduction.tex index bca731112b..f3ae6653ba 100644 --- a/Documentation/SoftwareGuide/Latex/Introduction.tex +++ b/Documentation/SoftwareGuide/Latex/Introduction.tex @@ -100,14 +100,14 @@ process described in Section \ref{chapter:Installation}. There are two other ways of getting the OTB source code: \begin{itemize} \item Clone the current release with \href{https://git-scm.com/}{Git} from the - \href{https://git.orfeo-toolbox.org/otb.git}{OTB git server}, (master branch) + \href{https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git}{OTB git server}, (master branch) \item Clone the latest revision with \href{https://git-scm.com/}{Git} from the - \href{https://git.orfeo-toolbox.org/otb.git}{OTB git server} (develop branch). + \href{https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git}{OTB git server} (develop branch). \end{itemize} These last two options need a proper \href{https://git-scm.com/}{Git} installation. To get source code from Git, do: \begin{verbatim} -git clone https://git@git.orfeo-toolbox.org/git/otb.git +git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git \end{verbatim} Using Git, you can easily navigate through the different versions. The master diff --git a/Documentation/SoftwareGuide/Latex/Tutorial.tex b/Documentation/SoftwareGuide/Latex/Tutorial.tex index be8cd232fc..4a09dc6602 100644 --- a/Documentation/SoftwareGuide/Latex/Tutorial.tex +++ b/Documentation/SoftwareGuide/Latex/Tutorial.tex @@ -224,7 +224,7 @@ Once this file is written you just have to run \code{make}. The Get one image from the \code{OTB-Data/Examples} directory from the OTB-Data repository. You can get it either by cloning the OTB data repository -(\code{git clone https://git.orfeo-toolbox.org/otb-data.git}), but that might be quite +(\code{git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data.git}), but that might be quite long as this also gets the data to run the tests. Alternatively, you can get it from \url{http://www.orfeo-toolbox.org/packages/OTB-Data-Examples.tgz}. Take for example get \code{QB\_Suburb.png}. diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx index f645553e03..726f1dbe3c 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx @@ -57,7 +57,11 @@ void ElevationParametersHandler::AddElevationParameters(Application::Pointer app oss.str(""); oss << key<<".geoid"; app->AddParameter(ParameterType_InputFilename, oss.str(), "Geoid File"); - app->SetParameterDescription(oss.str(),"Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB website (https://git.orfeo-toolbox.org/otb-data.git/blob/HEAD:/Input/DEM/egm96.grd)."); + app->SetParameterDescription(oss.str(),"Use a geoid grid to get the height " + "above the ellipsoid in case there is no DEM available, no coverage for " + "some points or pixels with no_data in the DEM tiles. A version of the " + "geoid can be found on the OTB website" + "(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd)."); app->MandatoryOff(oss.str()); std::string geoidFromConfig = otb::ConfigurationManager::GetGeoidFile(); diff --git a/README.md b/README.md index 7ae06474de..2842c132d8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#  Orfeo Toolbox +#  Orfeo Toolbox ## Open Source processing of remote sensing images Orfeo ToolBox (OTB) is an open-source project for state-of-the-art remote @@ -23,12 +23,12 @@ not a black box! * [OTB's website](https://www.orfeo-toolbox.org/) * [Documentation](https://www.orfeo-toolbox.org/documentation/) * [Downloads](https://www.orfeo-toolbox.org/download/) -* [Public git repositories](https://git.orfeo-toolbox.org/) +* [Public git repositories](https://gitlab.orfeo-toolbox.org/orfeotoolbox) * [GitHub mirror](https://github.com/orfeotoolbox/) * [Build status](http://dash.orfeo-toolbox.org/index.php?project=OTB) -* [Bug tracker](https://bugs.orfeo-toolbox.org/) +* [Bug tracker](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues?label_name%5B%5D=general) * [Wiki](http://wiki.orfeo-toolbox.org/index.php/Main_Page) -* [Task tracking](http://scrum.orfeo-toolbox.org) +* [Task tracking](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues) ### Join the community Get help, share your experience and contribute to the Orfeo-Toolbox project by @@ -43,4 +43,4 @@ Please see the wiki for contributors guidelines. Please see the license and the Copyright directory for legal issues on the use of the software. ### Issues -Please report any issue you might encouter to [our bugtracker](http://bugs.orfeo-toolbox.org). +Please report any issue you might encouter to [our bugtracker](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues). -- GitLab From e22f687c821e219b59c5350b7e12447c65e635c1 Mon Sep 17 00:00:00 2001 From: Victor Poughon <victor.poughon@cnes.fr> Date: Thu, 1 Feb 2018 09:02:21 +0000 Subject: [PATCH 185/567] DOC: Add CONTRIBUTING and PSC docs --- CONTRIBUTING.md | 99 +++++++++++++++++ PSC.md | 284 ++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 10 +- 3 files changed, 390 insertions(+), 3 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 PSC.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..4e74ed2ba5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,99 @@ +# How to contribute to Orfeo ToolBox + +Thank you for taking the time to contribute to OTB! This document will guide you +through the workflow and best practices you need to know to send your +contribution. + +There are many ways to contribute to OTB: + +* [Reporting a bug](#reporting-bugs) +* [Making a feature request](#feature-requests-and-discussions) +* [Improving documentation](#documentation-improvements) +* [Contributing code (C++, Python, CMake, etc.)](#code-contribution) +* [Publishing a remote module](#remote-modules) + +Our main workflow uses GitLab for source control, issues and task tracking. We +use a self-hosted gitlab instance: + +[`https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb`](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb) + +Remember to check out also our [developers mailing list](https://groups.google.com/forum/?hl=fr#!forum/otb-developers/join), +where we discuss some features, improvements and high level project planning. +You are welcome to ask questions there as a beginner or future OTB contributor! + +## Reporting bugs + +If you have found a bug, you can first [search the existing issues](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues) +to see if it has already been reported. + +If it's a new bug, please [open a new issue on GitLab](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues). +The 'Bug' issue template will help you provide all important information and +help fixing the bug quicker. Remember to add as much information as possible! + +## Feature requests and discussions + +Feature requests are welcome! Generally you are welcome to simply [open an issue](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues) +and discuss your idea there. + +For complex and potentially controvertial ideas, we use Request for Comments. +RFCs are normal issues but which will need more discussion from the community +and usually a formal PSC vote. For this, use the 'Request for Comments' issue +template on gitlab. Older RFCs live on the [wiki](https://wiki.orfeo-toolbox.org/index.php/Requests_for_Comments). +More long term ideas are collected on the wiki [Wishlist](https://wiki.orfeo-toolbox.org/index.php/Wishlist). + +For more peripheral contributions which do not belong in the main OTB +repository [Remote Modules](#remote-modules) are also a great option. + +## Documentation improvements + +The two main OTB documentations are the [Software Guide](https://www.orfeo-toolbox.org/SoftwareGuide/index.html) +and the [CookBook](https://www.orfeo-toolbox.org/CookBook/). Their sources are +hosted in the main OTB repository in the `Documentation/` directory. Then, to +contribute documentation use the same workflow as for code contributions (see +below). + +See also the [Compiling documentation](https://wiki.orfeo-toolbox.org/index.php/Compiling_documentation) +wiki page for help on building the Sphinx and Latex source. + +## Code contribution + +The OTB workflow is based on GitLab [Merge Requests](https://docs.gitlab.com/ee/gitlab-basics/add-merge-request.html). +Clone the repository, create a feature branch, commit your changes, push the +feature branch to a fork (or the main repository if you are a core developer), +then send a merge request. + +Note that we also accept PRs on our [GitHub mirror](https://github.com/orfeotoolbox/OTB). + +### Commit message + +On your feature branch, write a good [commit message](https://xkcd.com/1296/): +short and descriptive. If fixing an issue or bug, put the issue number in the +commit message so that GitLab can [crosslink it](https://docs.gitlab.com/ce/user/project/issues/crosslinking_issues.html). +You can prefix your commit message with an indicating flag (DOC, BUG, PKG, +TEST, SuperBuild, etc.) or the name of the module you are changing. + +For example, here are some good commit messages: + + BUG: #1701 Warn users if parameter string is unset + DOC: Fix typo in Monteverdi French translation + COMP: Allow GeoTIFF and TIFF to be disabled when no 3rd party drags them + Learning/Unsupervised: Add KMeans Shark implementation + +### Merge request + +Your contribution is ready to be added to the main OTB repository? Send a Merge +Request against the `develop` branch on GitLab using the merge request +template. + +The merge request will then be discussed by the community and the core OTB +team. Larger contributions will require code review and a formal PSC vote. + +## Remote modules + +[Remote Modules](https://wiki.orfeo-toolbox.org/index.php/Remote_Modules) are the prefered way if your contribution is about adding new classes or +application to bring new features to OTB. Remote modules are just like regular +modules, except they are not distributed inside OTB source code. Under some +conditions (dependencies, official acceptance process, etc.), we are also able +to distribute your remote module in the official standalone binaries. See [the wiki](https://wiki.orfeo-toolbox.org/index.php/Remote_Modules) +for more information. + diff --git a/PSC.md b/PSC.md new file mode 100644 index 0000000000..77c3bc6468 --- /dev/null +++ b/PSC.md @@ -0,0 +1,284 @@ +# Project Steering Committee + +This document describes the Project Steering Committee of the Orfeo ToolBox. + +## PSC scope + +The aim of the **OTB Project Steering committee (PSC)** is to provide +high level guidance and coordination for the ORFEO ToolBox. + +It provides a central point of contact for the project and arbitrates +disputes. It is also a stable base of “institutional knowledge†to the +project and tries its best to involve more developers. + +It should help to guarantee that OTB remains open and company neutral. + +### Roadmaps + +The PSC gathers and publishes high level roadmaps for OTB: + +- Feature roadmap +- Technical roadmap (developer and coding guidelines and workflows, + target systems, packaging ...) +- Infrastructure roadmap (SCM, wiki, dashboard ...) + +The PSC also publishes the guidelines and the acceptance policy for +feature requests. It enforces them. It monitors and approves new feature +requests. + +### Communication + +The PSC coordinates communication actions: + +- Ensures that the wiki is up-to-date, +- Ensures that the website is up-to-date and proposes new content, +- Ensures regular posting on the blog and social networks, +- Keeps track of opportunities to communicate: Symposium and events + where OTB should be represented, +- Keeps track of opportunities from communities: Google Summer of Code + project, link with other OSGeo and FOSS projects, +- Is responsible for the organization of events around OTB (i.e. users + meetings and hackathon). + +### User support and documentation + +The PSC ensures that users are given an appropriate support: + +- Ensures that support is working (unanswered questions, questions + from other places than the user list ...) +- Proposes addition to the documentation based on users feedback, +- Proposes new features for the roadmap based on users feedback, +- Proposes new ways for support and documentation + +### Contribution management + +The PSC publishes the guidelines and acceptance policy for +contributions. It enforces them. + +It monitors and approves new proposals. + +It ensures that contribution is as easy as possible, by monitoring +technical means for contribution and proposing evolutions to guidelines, +policies and means. + +### Release planning + +The PSC publishes release guidelines and policies, and enforces them. + +The PSC puts together the next Release roadmap and proposes a planning. +It is then responsible for the release preparation. + +The final approval for a release is given by the PSC (motion proposed to +the otb-developers mailing list). + +### Handling of legal issues + +The PSC is responsible for addressing any issue about copyright or +licensing that may occur, and most importantly, it is responsible for +taking preventive actions about those issues. + +## How does the PSC work? + +This section describes how the PSC works. It is inspired by existing +governance statuses in other open source community projects related to +OTB like +[GDAL](https://trac.osgeo.org/gdal/wiki/GovernanceAndCommunity), +[Quantum +GIS](http://www2.qgis.org/en/site/getinvolved/governance/index.html) or +[GRASS](http://trac.osgeo.org/grass/wiki/PSC). + +### PSC members + +All members have equal standing and voice in the PSC. The PSC seats are +non-expiring. PSC members may resign their position, or be asked to +vacate their seat after a unanimous vote of no confidence from the +remaining PSC members. + +The expectations on PSC members are: + +- Be willing to commit to the OTB development effort +- Be responsive to requests for information from fellow members +- Be able and willing to attend on-line meetings +- Act in the best interests of the project + +It is important to note that the PSC is not a legal entity! + +### Roles + +Members can be assigned roles corresponding to each category of the PSC +scope described above. + +Being assigned a role does not mean undertaking all necessary actions, +but rather ensuring that actions will be undertaken. + +In addition to their specific roles, members of the PSC commit to +participate actively in discussions and votes. + +One member of the PSC is designated as the Chair and is the ultimate +adjudicator in case of deadlock or irretrievable break down of +decision-making, or in case of disputes over voting. + +### When is a PSC vote required? + +A vote of the PSC is required in the following cases: + +1. Merge Request +2. Addition or removal of PSC members (including the selection of a new + Chair) +3. Release process + +In addition, a vote can be summoned for: + +1. Changing PSC rules and processes +2. Anything else that might be controversial + +#### Merge Request + +A Merge Request describes a change in Orfeo ToolBox code, API, +infrastructure or processes that need to be submitted to the PSC vote: + +- Anything that could cause backward compatibility issues, +- Adding substantial amounts of new code, +- Changing inter-subsystem APIs, or objects, + +It should describe : + +1. What changes will be made and why they will make a better Orfeo + ToolBox +2. When will those changes be available (target release or date) +3. Who will be developing the proposed changes + +Those elements can be provided in an email to the developer list or on a +git hosted platform (GitLab, GitHub, etc.). + +#### Add or remove PSC members + +To be eligible for membership in the PSC, a person should demonstrate +**a substantial and ongoing involvement in OTB**. The PSC is not only +composed of OTB developers as there are many ways to join and contribute +to the project. Anyone is eligible to be nominated to the OTB PSC. +Ideally, nominees would be OTB users or developers who have a deep +understanding of the project. In addition, nominees should meet the +qualifications set forth in this document. Anyone can submit a +nomination. + +#### Release phases + +The release manager (the PSC member in charge of release planning) +submits to vote the following release decisions: + +1. Date of the next release +2. Codename of the next release +3. Date and revision of Release Candidate +4. Date and revision of Final Release +5. Date and revision of bug-fixes Release + +### Process + +- Proposals are written up and submitted on the otb-developers mailing + list for discussion and voting, by any interested party, not just + committee members. Proposals are available for review for at least + three days before a vote can be closed. It is acknowledged that some + more complex issues may require more time for discussion and + deliberation. +- Respondents may vote “+1†to indicate support for the proposal and a + willingness to support implementation. +- Respondents may vote “-1†to veto a proposal, but must provide + argumented reasoning and alternate approaches to resolve the problem + within the two days. +- A vote of -0 indicates mild disagreement, but has no effect. A 0 + indicates no opinion. A +0 indicates mild support, but has no + effect. +- Anyone may comment and vote on proposals on the list, but only + members of the PSC's votes (including the Chair) will be counted + (“eligible votersâ€). +- A proposal will be accepted if it receives at least +2 (including + the proponent) and no vetos (-1) +- If a proposal is vetoed, and it cannot be revised to satisfy all + parties, then it can be resubmitted for an override vote in which a + majority of all eligible voters indicating +1 is sufficient to pass + it. Note that this is a majority of all committee members, not just + those who actively vote. +- Upon completion of discussion and voting the proposers should + announce whether they are proceeding (proposal accepted) or are + withdrawing their proposal (vetoed). +- The Chair adjudicates in cases of disputes about voting. + +A summary of discussions is published in a dedicated section of the wiki +[Requests for Changes](Requests_for_Changes "wikilink"). + +## Current members and roles + +In March 2015, CNES nominated 3 persons deeply involved in OTB as +initial PSC members. They are responsible for defining PSC rules and +establishing a fully functioning PSC. PSC has now 4 members. + +**Name** | **Affiliation** | **Email** | **Role** | +----------------------------|------------------|----------------------------------|--------------------------------------------| +Manuel Grizonnet (resigned) | CNES | manuel.grizonnet AT cnes DOT fr | Infrastructure, legal issues | +Rémi Cresson | IRSTEA | cresson.r AT gmail DOT com | Release Manager for release 5.2 | +Guillaume Pasero | CS-SI | guillaume.pasero AT c-s DOT fr | release planner | +Jordi Inglada (resigned) | CNES/CESBIO | jordi.inglada AT cesbio DOT eu | | +Julien Michel | CNES | julien.michel AT cnes DOT fr | Communication, contributions | +Victor Poughon | CNES | victor.poughon AT cnes DOT fr | User support and documentation, roadmaps | + +## Release manager + +A **release manager** is nominated for each release. Nomination is made +shortly after previous release announcement. A **backup release +manager** is also nominated, to assist and possibly step in if the +official release manager is not available. The **release manager** and +his/her backup can be a member of the PSC, but also another member of +otb-developers list willing to take the spot. + +The **release manager** is in charge of : + +1. Listing and tracking all major features proposed for next release + (from call for contribution in the early phase and then approved + RFCs) +2. Planing release date and ensures sync with RFCs execution, +3. Approving feature branch merges (if possible, leave at least 3 days + between RFC submission and merge, so that people have time to do a + review) +4. Actually merging feature branches when authors do not have commit + rights (github pull request for instance) +5. Tracking remote module that can be candidate for official inclusion + in next release, and ensuring they will be included (see + [Contributors guidelines](Contributors_guidelines "wikilink")) +6. Submitting the start of the [release + process](How_to_Release "wikilink") to PSC vote +7. Ensuring proper execution of [release + process](How_to_Release "wikilink") + +**Feature freeze:** Starting the release process is also called *feature +freeze* which describes the period between the creation of the release +branch and the announcement of the release. It's an important time for +the RM who should ensures the proper execution of the release process +and facilitate the communication between developers. The RM is among +other things responsible of gathering feedback on bugs that need to be +fixed before the release, making a list that is public to be able to +follow progression of the release process. + +**Remember:** all new features must be submitted by Merge Requests and +approved by the PSC. The release manager only approves the feature +branches merge. + +### Feature branch merge acceptance checklist + +1. The feature branch corresponds to an [approved + Merge Request](Project_Steering_Committee#Process "wikilink") +2. The feature branch is synched with develop +3. The feature branch is tested on the dashboard (see + [here](#NightlyFeatureBranches "wikilink")) and has no major failure + (compilation errors, tremendous amount of warning or failing tests, + segfault or not executed tests) +4. Feature branch author are available during days following the merge + to analyse dashboard and fix things in case of unexpected issues + after the merge + +It is important to note that a feature branch should be kept relatively +small and does not necessarily correspond to the full implementation of +a RFC. Small consistent branches implementing parts of RFC can be merged +early. Further evolutions and implementations of the RFC can be done by +continuing the feature branch or opening new branches, and approval of +Release Manager should be requested again before merging. diff --git a/README.md b/README.md index 2842c132d8..7a3a7e734f 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,10 @@ not a black box! * [OTB's website](https://www.orfeo-toolbox.org/) * [Documentation](https://www.orfeo-toolbox.org/documentation/) * [Downloads](https://www.orfeo-toolbox.org/download/) -* [Public git repositories](https://gitlab.orfeo-toolbox.org/orfeotoolbox) +* [Public git repositories](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb) * [GitHub mirror](https://github.com/orfeotoolbox/) * [Build status](http://dash.orfeo-toolbox.org/index.php?project=OTB) -* [Bug tracker](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues?label_name%5B%5D=general) +* [Bug tracker](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues) * [Wiki](http://wiki.orfeo-toolbox.org/index.php/Main_Page) * [Task tracking](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues) @@ -37,10 +37,14 @@ joining our community and mailing lists. [https://www.orfeo-toolbox.org/community/](https://www.orfeo-toolbox.org/community/) ### Contributing -Please see the wiki for contributors guidelines. +Please see [CONTRIBUTING.md](CONTRIBUTING.md) for contributors guidelines. ### License Please see the license and the Copyright directory for legal issues on the use of the software. ### Issues Please report any issue you might encouter to [our bugtracker](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues). + +### Governance + +The Orfeo ToolBox project is governed by the [Project Steering Committee](PSC.md) and its members. -- GitLab From 142d1feef2670451978b53f0efc1a71286f31570 Mon Sep 17 00:00:00 2001 From: Victor Poughon <victor.poughon@cnes.fr> Date: Thu, 1 Feb 2018 09:39:50 +0000 Subject: [PATCH 186/567] DOC: Fix broken links in PSC.md --- PSC.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PSC.md b/PSC.md index 77c3bc6468..2e47504e74 100644 --- a/PSC.md +++ b/PSC.md @@ -205,7 +205,7 @@ submits to vote the following release decisions: - The Chair adjudicates in cases of disputes about voting. A summary of discussions is published in a dedicated section of the wiki -[Requests for Changes](Requests_for_Changes "wikilink"). +[Requests for Changes](https://wiki.orfeo-toolbox.org/index.php/Requests_for_Changes). ## Current members and roles @@ -244,11 +244,11 @@ The **release manager** is in charge of : rights (github pull request for instance) 5. Tracking remote module that can be candidate for official inclusion in next release, and ensuring they will be included (see - [Contributors guidelines](Contributors_guidelines "wikilink")) + [Contributors guidelines](CONTRIBUTING.md)) 6. Submitting the start of the [release - process](How_to_Release "wikilink") to PSC vote + process](https://wiki.orfeo-toolbox.org/index.php/How_to_Release) to PSC vote 7. Ensuring proper execution of [release - process](How_to_Release "wikilink") + process](https://wiki.orfeo-toolbox.org/index.php/How_to_Release) **Feature freeze:** Starting the release process is also called *feature freeze* which describes the period between the creation of the release @@ -266,10 +266,10 @@ branches merge. ### Feature branch merge acceptance checklist 1. The feature branch corresponds to an [approved - Merge Request](Project_Steering_Committee#Process "wikilink") + Merge Request](#process) 2. The feature branch is synched with develop -3. The feature branch is tested on the dashboard (see - [here](#NightlyFeatureBranches "wikilink")) and has no major failure +3. The feature branch is tested on the dashboard + and has no major failure (compilation errors, tremendous amount of warning or failing tests, segfault or not executed tests) 4. Feature branch author are available during days following the merge -- GitLab From f5d2a07efc812247182de09444b3481bbd7d9dd8 Mon Sep 17 00:00:00 2001 From: Victor Poughon <victor.poughon@cnes.fr> Date: Thu, 1 Feb 2018 09:43:33 +0000 Subject: [PATCH 187/567] DOC: Fix README logo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a3a7e734f..a9a8e9dd26 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#  Orfeo Toolbox +#  Orfeo Toolbox ## Open Source processing of remote sensing images Orfeo ToolBox (OTB) is an open-source project for state-of-the-art remote -- GitLab From d7ac4da1f705d782f5b31d040c25995470a06647 Mon Sep 17 00:00:00 2001 From: Victor Poughon <victor.poughon@cnes.fr> Date: Thu, 1 Feb 2018 10:28:32 +0000 Subject: [PATCH 188/567] DOC: Filter issues with label 'bug' in links --- CONTRIBUTING.md | 4 ++-- README.md | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4e74ed2ba5..87b2a92c53 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,10 +23,10 @@ You are welcome to ask questions there as a beginner or future OTB contributor! ## Reporting bugs -If you have found a bug, you can first [search the existing issues](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues) +If you have found a bug, you can first [search the existing issues](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues?label_name%5B%5D=bug) to see if it has already been reported. -If it's a new bug, please [open a new issue on GitLab](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues). +If it's a new bug, please [open a new issue on GitLab](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues/new). The 'Bug' issue template will help you provide all important information and help fixing the bug quicker. Remember to add as much information as possible! diff --git a/README.md b/README.md index a9a8e9dd26..e2cd85671a 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ not a black box! * [Public git repositories](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb) * [GitHub mirror](https://github.com/orfeotoolbox/) * [Build status](http://dash.orfeo-toolbox.org/index.php?project=OTB) -* [Bug tracker](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues) +* [Bug tracker](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues?label_name%5B%5D=bug) * [Wiki](http://wiki.orfeo-toolbox.org/index.php/Main_Page) * [Task tracking](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues) @@ -46,5 +46,4 @@ Please see the license and the Copyright directory for legal issues on the use o Please report any issue you might encouter to [our bugtracker](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues). ### Governance - The Orfeo ToolBox project is governed by the [Project Steering Committee](PSC.md) and its members. -- GitLab From 04773b6c09d533a0ae4c606a3a0da09b19edf8cb Mon Sep 17 00:00:00 2001 From: Victor Poughon <victor.poughon@cnes.fr> Date: Thu, 1 Feb 2018 11:00:53 +0000 Subject: [PATCH 189/567] DOC: Better bug tracker link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e2cd85671a..657504a2dc 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Please see [CONTRIBUTING.md](CONTRIBUTING.md) for contributors guidelines. Please see the license and the Copyright directory for legal issues on the use of the software. ### Issues -Please report any issue you might encouter to [our bugtracker](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues). +Please report any issue you might encouter to [our bugtracker](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues?label_name%5B%5D=bug). ### Governance The Orfeo ToolBox project is governed by the [Project Steering Committee](PSC.md) and its members. -- GitLab From cf3058d78cc1c35cd68c8b807a017fc0e6fa0fbe Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 1 Feb 2018 14:45:52 +0100 Subject: [PATCH 190/567] DOC: try to add bug label in the gitlab template --- .gitlab/issue_templates/bugs.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab/issue_templates/bugs.md b/.gitlab/issue_templates/bugs.md index 75b403c79f..378d84f1b9 100644 --- a/.gitlab/issue_templates/bugs.md +++ b/.gitlab/issue_templates/bugs.md @@ -9,3 +9,5 @@ Describe as precisely as possible how to reproduce the bug. Try to isolate a min ### Configuration information OS, OTB version or tag, information related to build (binaries, superbuild, system libs ...) + +/label ~bug -- GitLab From f55cf7236703518fab31e0e20572a24329ca6c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Dinot?= <sebastien.dinot@c-s.fr> Date: Thu, 1 Feb 2018 16:51:47 +0100 Subject: [PATCH 191/567] Update link to OTB logo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2842c132d8..ba3ef53830 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#  Orfeo Toolbox +#  Orfeo Toolbox ## Open Source processing of remote sensing images Orfeo ToolBox (OTB) is an open-source project for state-of-the-art remote -- GitLab From c85f91568737b8243c42480da87153489c7a1c9a Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Thu, 1 Feb 2018 17:12:30 +0100 Subject: [PATCH 192/567] Update CONTRIBUTING.md (add list of valid prefix commit message) --- CONTRIBUTING.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 87b2a92c53..fbc7511e69 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# How to contribute to Orfeo ToolBox +# How to contribute to Orfeo ToolBox ? Thank you for taking the time to contribute to OTB! This document will guide you through the workflow and best practices you need to know to send your @@ -72,6 +72,16 @@ commit message so that GitLab can [crosslink it](https://docs.gitlab.com/ce/user You can prefix your commit message with an indicating flag (DOC, BUG, PKG, TEST, SuperBuild, etc.) or the name of the module you are changing. +Standard prefixes for OTB commit messages: + + BUG: Fix for runtime crash or incorrect result + COMP: Compiler error or warning fix + DOC: Documentation change + ENH: New functionality + PERF: Performance improvement + STYLE: No logic impact (indentation, comments) + WIP: Work In Progress not ready for merge + For example, here are some good commit messages: BUG: #1701 Warn users if parameter string is unset -- GitLab From 3c34f73983a0a73c4620f6ed457ad8b3b861b663 Mon Sep 17 00:00:00 2001 From: Victor Poughon <victor.poughon@cnes.fr> Date: Fri, 2 Feb 2018 09:32:45 +0000 Subject: [PATCH 193/567] DOC: Update CONTRIBUTING and PSC with Julien's review --- CONTRIBUTING.md | 35 +++++++++++++++++------------------ PSC.md | 20 ++++++++------------ 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fbc7511e69..5f8a409abb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,16 +33,9 @@ help fixing the bug quicker. Remember to add as much information as possible! ## Feature requests and discussions Feature requests are welcome! Generally you are welcome to simply [open an issue](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues) -and discuss your idea there. +and discuss your idea there. For more complex requests there is an issue +template for in depth description called 'Request for Comments'. -For complex and potentially controvertial ideas, we use Request for Comments. -RFCs are normal issues but which will need more discussion from the community -and usually a formal PSC vote. For this, use the 'Request for Comments' issue -template on gitlab. Older RFCs live on the [wiki](https://wiki.orfeo-toolbox.org/index.php/Requests_for_Comments). -More long term ideas are collected on the wiki [Wishlist](https://wiki.orfeo-toolbox.org/index.php/Wishlist). - -For more peripheral contributions which do not belong in the main OTB -repository [Remote Modules](#remote-modules) are also a great option. ## Documentation improvements @@ -62,7 +55,8 @@ Clone the repository, create a feature branch, commit your changes, push the feature branch to a fork (or the main repository if you are a core developer), then send a merge request. -Note that we also accept PRs on our [GitHub mirror](https://github.com/orfeotoolbox/OTB). +Note that we also accept PRs on our [GitHub mirror](https://github.com/orfeotoolbox/OTB) +which we will manually merge. ### Commit message @@ -70,7 +64,7 @@ On your feature branch, write a good [commit message](https://xkcd.com/1296/): short and descriptive. If fixing an issue or bug, put the issue number in the commit message so that GitLab can [crosslink it](https://docs.gitlab.com/ce/user/project/issues/crosslinking_issues.html). You can prefix your commit message with an indicating flag (DOC, BUG, PKG, -TEST, SuperBuild, etc.) or the name of the module you are changing. +TEST, SuperBuild, etc.). Standard prefixes for OTB commit messages: @@ -87,7 +81,6 @@ For example, here are some good commit messages: BUG: #1701 Warn users if parameter string is unset DOC: Fix typo in Monteverdi French translation COMP: Allow GeoTIFF and TIFF to be disabled when no 3rd party drags them - Learning/Unsupervised: Add KMeans Shark implementation ### Merge request @@ -98,12 +91,18 @@ template. The merge request will then be discussed by the community and the core OTB team. Larger contributions will require code review and a formal PSC vote. +* Merge requests can not be merged until all discussions have been resolved (this is enforced by GitLab). +* Merge requests **must receive at least 2 positives votes from PSC members** before being merged. +* The merger is responsible for checking that the branch is up-to-date with develop and that the dashboard is ok. +* Merge requests can be merged by anyone (not just PSC or RM) with push access to develop + ## Remote modules -[Remote Modules](https://wiki.orfeo-toolbox.org/index.php/Remote_Modules) are the prefered way if your contribution is about adding new classes or -application to bring new features to OTB. Remote modules are just like regular -modules, except they are not distributed inside OTB source code. Under some -conditions (dependencies, official acceptance process, etc.), we are also able -to distribute your remote module in the official standalone binaries. See [the wiki](https://wiki.orfeo-toolbox.org/index.php/Remote_Modules) +[Remote Modules](https://wiki.orfeo-toolbox.org/index.php/Remote_Modules) are +the prefered way if you wish to make your apps and filters available to the +community while keeping control and maintenance of their sources. Remote +modules are just like regular modules, except they are not distributed inside +OTB source code. Under some conditions (dependencies, official acceptance +process, etc.), we are also able to distribute your remote module in the +official standalone binaries. See [the wiki](https://wiki.orfeo-toolbox.org/index.php/Remote_Modules) for more information. - diff --git a/PSC.md b/PSC.md index 2e47504e74..c798cec66e 100644 --- a/PSC.md +++ b/PSC.md @@ -175,12 +175,11 @@ submits to vote the following release decisions: ### Process -- Proposals are written up and submitted on the otb-developers mailing - list for discussion and voting, by any interested party, not just - committee members. Proposals are available for review for at least - three days before a vote can be closed. It is acknowledged that some - more complex issues may require more time for discussion and - deliberation. +- Proposals are written up and submitted as GitLab merge requests or on the + otb-developers mailing list for discussion and voting, by any interested + party, not just committee members. Proposals are available for review for at + least three days before a vote can be closed. It is acknowledged that some + more complex issues may require more time for discussion and deliberation. - Respondents may vote “+1†to indicate support for the proposal and a willingness to support implementation. - Respondents may vote “-1†to veto a proposal, but must provide @@ -189,9 +188,9 @@ submits to vote the following release decisions: - A vote of -0 indicates mild disagreement, but has no effect. A 0 indicates no opinion. A +0 indicates mild support, but has no effect. -- Anyone may comment and vote on proposals on the list, but only - members of the PSC's votes (including the Chair) will be counted - (“eligible votersâ€). +- Anyone may comment and vote on proposals on the list or on the merge request + thread, but only members of the PSC's votes (including the Chair) will be + counted (“eligible votersâ€). - A proposal will be accepted if it receives at least +2 (including the proponent) and no vetos (-1) - If a proposal is vetoed, and it cannot be revised to satisfy all @@ -199,9 +198,6 @@ submits to vote the following release decisions: majority of all eligible voters indicating +1 is sufficient to pass it. Note that this is a majority of all committee members, not just those who actively vote. -- Upon completion of discussion and voting the proposers should - announce whether they are proceeding (proposal accepted) or are - withdrawing their proposal (vetoed). - The Chair adjudicates in cases of disputes about voting. A summary of discussions is published in a dedicated section of the wiki -- GitLab From 85c96ccd20cbb6279e497d457120822d83cc8e90 Mon Sep 17 00:00:00 2001 From: Victor Poughon <victor.poughon@cnes.fr> Date: Fri, 2 Feb 2018 11:17:47 +0100 Subject: [PATCH 194/567] Update CONTRIBUTING.md --- CONTRIBUTING.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5f8a409abb..5c21b7d5cc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,10 +86,8 @@ For example, here are some good commit messages: Your contribution is ready to be added to the main OTB repository? Send a Merge Request against the `develop` branch on GitLab using the merge request -template. - -The merge request will then be discussed by the community and the core OTB -team. Larger contributions will require code review and a formal PSC vote. +template. The merge request will then be discussed by the community and the core +OTB team. * Merge requests can not be merged until all discussions have been resolved (this is enforced by GitLab). * Merge requests **must receive at least 2 positives votes from PSC members** before being merged. -- GitLab From 740544f7cf8757227b8c7c9400192c86d58e0f69 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Fri, 2 Feb 2018 11:48:03 +0100 Subject: [PATCH 195/567] ENH: update superbuild shark git tag to a newer version on master branch --- SuperBuild/CMake/External_shark.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SuperBuild/CMake/External_shark.cmake b/SuperBuild/CMake/External_shark.cmake index 47f07c0b09..65a89840c4 100644 --- a/SuperBuild/CMake/External_shark.cmake +++ b/SuperBuild/CMake/External_shark.cmake @@ -30,8 +30,8 @@ ADD_SUPERBUILD_CMAKE_VAR(SHARK BOOST_LIBRARYDIR) ExternalProject_Add(SHARK PREFIX SHARK - URL "https://github.com/Shark-ML/Shark/archive/a0d1f816f474b968adbf7592bff199a96a87efc1.zip" - URL_MD5 ed0e8eb73743b39a93775599761a9273 + URL "https://github.com/Shark-ML/Shark/archive/3394e5f553e020ef5b093f388bdba29247600dbd.zip" + URL_MD5 7a3e6d45386328e7a22e1f6a6453260d SOURCE_DIR ${SHARK_SB_SRC} BINARY_DIR ${SHARK_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} -- GitLab From deb0441f54c80134de84f882390b033c6dea649a Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 2 Feb 2018 14:41:08 +0100 Subject: [PATCH 196/567] DOC: small typos in request_for_changes.md --- .gitlab/merge_request_templates/request_for_changes.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab/merge_request_templates/request_for_changes.md b/.gitlab/merge_request_templates/request_for_changes.md index 1fcd722726..354996678a 100644 --- a/.gitlab/merge_request_templates/request_for_changes.md +++ b/.gitlab/merge_request_templates/request_for_changes.md @@ -10,11 +10,11 @@ Explain the rationale for the changes (possible link to a Request For Comments o #### Classes and files -Give an overview of the implementation: main changes made to classes, files and module. Do not paste complete diff, as it is available in the merge request already. +Give an overview of the implementation: main changes made to classes, files and modules. Do not paste complete diff, as it is available in the merge request already. #### Applications -Describe any changes made to existing applications, or new application that have been added. +Describe any changes made to existing applications, or new applications that have been added. #### Tests @@ -22,7 +22,7 @@ Describe the testing strategy for new features. ### Documentation -List or link documentation modification that were made (doxygen, example, software guide, application documentation, cookbook). +List or link documentation modifications that were made (doxygen, example, software guide, application documentation, cookbook). ### Additional notes -- GitLab From ea0ce338a3be53c251e6f13558d771b23d58c2c1 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 5 Feb 2018 15:00:36 +0100 Subject: [PATCH 197/567] TEST: add a new application to work with and a vector to application class --- .../Applications/AppTest/app/CMakeLists.txt | 5 + .../AppTest/app/otbMemoryTestApplication.cxx | 106 ++++++++++++++++++ Modules/Applications/AppTest/otb-module.cmake | 1 + .../include/otbWrapperApplication.h | 2 + 4 files changed, 114 insertions(+) create mode 100644 Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx diff --git a/Modules/Applications/AppTest/app/CMakeLists.txt b/Modules/Applications/AppTest/app/CMakeLists.txt index 44d54be96b..3322351683 100644 --- a/Modules/Applications/AppTest/app/CMakeLists.txt +++ b/Modules/Applications/AppTest/app/CMakeLists.txt @@ -22,3 +22,8 @@ otb_create_application( NAME TestApplication SOURCES otbTestApplication.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + +otb_create_application( + NAME MemoryTest + SOURCES otbMemoryTestApplication.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) \ No newline at end of file diff --git a/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx b/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx new file mode 100644 index 0000000000..0e982a046a --- /dev/null +++ b/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <numeric> + +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + +#include "otbMultiToMonoChannelExtractROI.h" + +namespace otb +{ +namespace Wrapper +{ + +class MemoryTest : public Application +{ +public: + /** Standard class typedefs. */ + typedef MemoryTest Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(MemoryTest, otb::Application) + + typedef MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType, + FloatVectorImageType::InternalPixelType> ExtractROIFilterType; + + + +private: + + void DoInit() ITK_OVERRIDE + { + SetName("MemoryTest"); + SetDescription("This application is made for test"); + // Documentation + SetDocName("Memory Test"); + SetDocLongDescription(""); + SetDocLimitations("None"); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso(""); + + AddParameter(ParameterType_InputImage, "in", "Input image"); + SetParameterDescription("in", "Input image"); + + AddParameter(ParameterType_OutputImage, "out", "Output Image"); + SetParameterDescription("out", "Output image"); + SetDefaultOutputPixelType("out",ImagePixelType_uint8); + + + AddRAMParameter(); + + // Doc example parameter settings + SetDocExampleParameterValue("in", "input.tif"); + SetDocExampleParameterValue("out", "output.tif"); + + SetOfficialDocLink(); + } + + void DoUpdateParameters() ITK_OVERRIDE + { + } + + void DoExecute() ITK_OVERRIDE + { + GetParameterImage("in")->DebugOn(); + ExtractROIFilterType::Pointer extractor = ExtractROIFilterType::New(); + extractor->DebugOn(); + m_Filters.push_back(extractor.GetPointer()); + extractor->DebugOn(); + extractor->SetInput(GetParameterImage("in")); + extractor->SetChannel(1); + extractor->UpdateOutputInformation(); + extractor->GetOutput()->DebugOn(); + SetParameterOutputImage("out" , extractor->GetOutput() ); + } + +}; + +} +} + +OTB_APPLICATION_EXPORT(otb::Wrapper::MemoryTest) + diff --git a/Modules/Applications/AppTest/otb-module.cmake b/Modules/Applications/AppTest/otb-module.cmake index fc492e17d8..d67ae1c326 100644 --- a/Modules/Applications/AppTest/otb-module.cmake +++ b/Modules/Applications/AppTest/otb-module.cmake @@ -23,6 +23,7 @@ set(DOCUMENTATION "Test application.") otb_module(OTBAppTest DEPENDS OTBApplicationEngine + OTBImageBase TEST_DEPENDS OTBTestKernel OTBCommandLine diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index f97134cbd1..f33d1ba168 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -853,6 +853,8 @@ public: this->SetDocLink(link); } + std::vector<itk::ProcessObject::Pointer> m_Filters; + protected: /** Constructor */ Application(); -- GitLab From ddd6bd34f667b0112ed475981c5ea59ac006792c Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 5 Feb 2018 15:21:11 +0100 Subject: [PATCH 198/567] TEST: add several trace and clear the filter vector at the end of executeandwriteoutput --- Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx | 3 +++ Modules/Core/ImageBase/include/otbVectorImage.h | 4 +++- Modules/Core/ImageBase/include/otbVectorImage.txx | 1 + Modules/IO/ImageIO/include/otbImageFileWriter.txx | 2 ++ .../Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx | 3 ++- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx b/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx index 0e982a046a..9afb640273 100644 --- a/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx +++ b/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx @@ -85,14 +85,17 @@ private: void DoExecute() ITK_OVERRIDE { + std::cout<<"Debug on input "<<std::endl; GetParameterImage("in")->DebugOn(); ExtractROIFilterType::Pointer extractor = ExtractROIFilterType::New(); extractor->DebugOn(); m_Filters.push_back(extractor.GetPointer()); + std::cout<<"Debug on extractor "<<std::endl; extractor->DebugOn(); extractor->SetInput(GetParameterImage("in")); extractor->SetChannel(1); extractor->UpdateOutputInformation(); + std::cout<<"Debug on extractor's output "<<std::endl; extractor->GetOutput()->DebugOn(); SetParameterOutputImage("out" , extractor->GetOutput() ); } diff --git a/Modules/Core/ImageBase/include/otbVectorImage.h b/Modules/Core/ImageBase/include/otbVectorImage.h index 2fa39e599a..9e948ec5c9 100644 --- a/Modules/Core/ImageBase/include/otbVectorImage.h +++ b/Modules/Core/ImageBase/include/otbVectorImage.h @@ -194,7 +194,9 @@ public: protected: VectorImage(); - ~VectorImage() ITK_OVERRIDE {} + ~VectorImage() ITK_OVERRIDE { + std::cout<<"A vector image is deleted"<<std::endl; + } private: VectorImage(const Self &); //purposely not implemented diff --git a/Modules/Core/ImageBase/include/otbVectorImage.txx b/Modules/Core/ImageBase/include/otbVectorImage.txx index f6123af584..83c3f0f6e7 100644 --- a/Modules/Core/ImageBase/include/otbVectorImage.txx +++ b/Modules/Core/ImageBase/include/otbVectorImage.txx @@ -33,6 +33,7 @@ namespace otb template <class TPixel, unsigned int VImageDimension> VectorImage<TPixel, VImageDimension>::VectorImage() { + std::cout<<"A vector image is created"<<std::endl; } template <class TPixel, unsigned int VImageDimension> diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index b1472291f1..62b9338f30 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -80,6 +80,7 @@ ImageFileWriter<TInputImage> this->SetAutomaticAdaptativeStreaming(); m_FilenameHelper = FNameHelperType::New(); + std::cout<<"A writer is created"<<std::endl; } /** @@ -89,6 +90,7 @@ template <class TInputImage> ImageFileWriter<TInputImage> ::~ImageFileWriter() { + std::cout<<"A writer is deleted"<<std::endl; } template <class TInputImage> diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index cca32d50d3..988f9f7243 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -518,11 +518,12 @@ int Application::ExecuteAndWriteOutput() } this->AfterExecuteAndWriteOutputs(); - + m_Filters.clear(); m_Chrono.Stop(); return status; } + /* Enable the use of an optional parameter. Returns the previous state */ void Application::EnableParameter(std::string paramKey) { -- GitLab From b02e0e075d7560e670ac5e3d99bfe99f6728b0bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABlle=20USSEGLIO?= <gaelle.usseglio@cnes.fr> Date: Fri, 2 Feb 2018 10:35:09 +0000 Subject: [PATCH 199/567] ENH : Add references on Y and Z coordinates into SarSensorModelAdapter --- .../Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h | 2 +- Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h index 33939b1610..17705f7f41 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h @@ -86,7 +86,7 @@ public: /** Transform world point (lat,lon,hgt) to input image point (col,row) and YZ frame */ - bool WorldToLineSampleYZ(const Point3DType & inGeoPoint, Point2DType & cr, Point2DType yz) const; + bool WorldToLineSampleYZ(const Point3DType & inGeoPoint, Point2DType & cr, Point2DType & yz) const; /** Transform world point (lat,lon,hgt) to input image point (col,row) */ diff --git a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx index d81fbc2b16..83360cefad 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx @@ -109,7 +109,7 @@ void SarSensorModelAdapter::DeburstLineToImageLine(const std::vector<std::pair<u ossimplugins::ossimSarSensorModel::deburstLineToImageLine(lines,deburstLine,imageLine); } -bool SarSensorModelAdapter::WorldToLineSampleYZ(const Point3DType & inGeoPoint, Point2DType & cr, Point2DType yz) const +bool SarSensorModelAdapter::WorldToLineSampleYZ(const Point3DType & inGeoPoint, Point2DType & cr, Point2DType & yz) const { if(m_SensorModel.get() == ITK_NULLPTR) { -- GitLab From 7da52347822af6bb10f377bb6cf52f6e65b989bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABlle=20USSEGLIO?= <gaelle.usseglio@cnes.fr> Date: Fri, 2 Feb 2018 14:58:20 +0000 Subject: [PATCH 200/567] ENH : Update of SarSensorModelAdapter with 2 two new functions --- .../include/otbSarSensorModelAdapter.h | 8 ++- .../src/otbSarSensorModelAdapter.cxx | 56 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h index 17705f7f41..abaabd28f7 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h @@ -91,7 +91,13 @@ public: /** Transform world point (lat,lon,hgt) to input image point (col,row) */ bool WorldToLineSample(const Point3DType & inGEoPOint, Point2DType & cr) const; - + + /** Transform world point (lat,lon,hgt) to cartesian point (x,y,z) */ + bool WorldToCartesian(const Point3DType & inGeoPoint, Point3DType & outCartesianPoint) const; + +/** Transform world point (lat,lon,hgt) to satellite position (x,y,z)*/ + bool WorldToSatPosition(const Point3DType & inGeoPoint, Point3DType & satelitePosition) const; + static bool ImageLineToDeburstLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long imageLine, unsigned long & deburstLine); static void DeburstLineToImageLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long deburstLine, unsigned long & imageLine); diff --git a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx index 83360cefad..324a185565 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx @@ -162,6 +162,62 @@ bool SarSensorModelAdapter::WorldToLineSample(const Point3DType & inGeoPoint, Po return true; } +bool SarSensorModelAdapter::WorldToCartesian(const Point3DType & inGeoPoint, Point3DType & outCartesianPoint) const +{ + if(m_SensorModel.get() == ITK_NULLPTR) + { + return false; + } + + ossimGpt inGpt; + inGpt.lat = inGeoPoint[0]; + inGpt.lon = inGeoPoint[1]; + inGpt.hgt = inGeoPoint[2]; + + + ossimEcefPoint outCartesien(inGpt); + + + if(outCartesien.isNan()) + return false; + + outCartesianPoint[0] = outCartesien.x(); + outCartesianPoint[1] = outCartesien.y(); + outCartesianPoint[2] = outCartesien.z(); + + return true; + +} + +bool SarSensorModelAdapter::WorldToSatPosition(const Point3DType & inGeoPoint, Point3DType & satelitePosition) const +{ + if(m_SensorModel.get() == ITK_NULLPTR) + { + return false; + } + + ossimGpt inGpt; + inGpt.lat = inGeoPoint[0]; + inGpt.lon = inGeoPoint[1]; + inGpt.hgt = inGeoPoint[2]; + + + ossimplugins::ossimSarSensorModel::TimeType azimuthTime; + double rangeTime; + ossimEcefPoint sensorPos; + ossimEcefVector sensorVel; + + const bool success = m_SensorModel->worldToAzimuthRangeTime(inGpt, azimuthTime, rangeTime,sensorPos,sensorVel); + + if(sensorPos.isNan()) + return false; + + satelitePosition[0] = sensorPos.x(); + satelitePosition[1] = sensorPos.y(); + satelitePosition[2] = sensorPos.z(); + + return true; +} } // namespace otb -- GitLab From 4408f639d5d33190982afd147d7012dcecbecdf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABlle=20USSEGLIO?= <gaelle.usseglio@cnes.fr> Date: Mon, 5 Feb 2018 16:03:26 +0000 Subject: [PATCH 201/567] ENH : Return velocity vector in WorldToSatPositionAndVelocity of ossimSensorAdapter and add test --- .../OSSIMAdapters/include/otbSarSensorModelAdapter.h | 5 +++-- .../OSSIMAdapters/src/otbSarSensorModelAdapter.cxx | 8 +++++++- .../OSSIMAdapters/test/otbSarSensorModelAdapterTest.cxx | 6 +++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h index abaabd28f7..312caa5f3a 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h @@ -95,8 +95,9 @@ public: /** Transform world point (lat,lon,hgt) to cartesian point (x,y,z) */ bool WorldToCartesian(const Point3DType & inGeoPoint, Point3DType & outCartesianPoint) const; -/** Transform world point (lat,lon,hgt) to satellite position (x,y,z)*/ - bool WorldToSatPosition(const Point3DType & inGeoPoint, Point3DType & satelitePosition) const; +/** Transform world point (lat,lon,hgt) to satellite position (x,y,z) and satellite velocity */ + bool WorldToSatPositionAndVelocity(const Point3DType & inGeoPoint, Point3DType & satelitePosition, + Point3DType & sateliteVelocity) const; static bool ImageLineToDeburstLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long imageLine, unsigned long & deburstLine); diff --git a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx index 324a185565..e3b594a8fb 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx @@ -189,7 +189,9 @@ bool SarSensorModelAdapter::WorldToCartesian(const Point3DType & inGeoPoint, Poi } -bool SarSensorModelAdapter::WorldToSatPosition(const Point3DType & inGeoPoint, Point3DType & satelitePosition) const + bool SarSensorModelAdapter::WorldToSatPositionAndVelocity(const Point3DType & inGeoPoint, + Point3DType & satelitePosition, + Point3DType & sateliteVelocity) const { if(m_SensorModel.get() == ITK_NULLPTR) { @@ -216,6 +218,10 @@ bool SarSensorModelAdapter::WorldToSatPosition(const Point3DType & inGeoPoint, P satelitePosition[1] = sensorPos.y(); satelitePosition[2] = sensorPos.z(); + sateliteVelocity[0] = sensorVel.x(); + sateliteVelocity[1] = sensorVel.y(); + sateliteVelocity[2] = sensorVel.z(); + return true; } diff --git a/Modules/Adapters/OSSIMAdapters/test/otbSarSensorModelAdapterTest.cxx b/Modules/Adapters/OSSIMAdapters/test/otbSarSensorModelAdapterTest.cxx index 828ed4f747..d48f100661 100644 --- a/Modules/Adapters/OSSIMAdapters/test/otbSarSensorModelAdapterTest.cxx +++ b/Modules/Adapters/OSSIMAdapters/test/otbSarSensorModelAdapterTest.cxx @@ -62,7 +62,7 @@ int otbSarSensorModelAdapterTest(int itkNotUsed(argc), char* argv[]) otb::SarSensorModelAdapter::Point2DType out1,out2; - otb::SarSensorModelAdapter::Point3DType in; + otb::SarSensorModelAdapter::Point3DType in, out3, out4, out5; // GCP 99 from input geom file //support_data.geom.gcp[99].world_pt.hgt: 2.238244926818182e+02 @@ -75,6 +75,10 @@ int otbSarSensorModelAdapterTest(int itkNotUsed(argc), char* argv[]) sensorModel->WorldToLineSample(in,out1); sensorModel->WorldToLineSampleYZ(in,out1,out2); + + sensorModel->WorldToCartesian(in, out5); + sensorModel->WorldToSatPositionAndVelocity(in,out3, out4); + return EXIT_SUCCESS; } -- GitLab From b784b698c9cef59677df7fe7ee34f4434ec75366 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 5 Feb 2018 18:32:50 +0100 Subject: [PATCH 202/567] SuperBuild: Shark: add flag for GCC --- .../patches/SHARK/shark-2-ext-num-literals.diff | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 SuperBuild/patches/SHARK/shark-2-ext-num-literals.diff diff --git a/SuperBuild/patches/SHARK/shark-2-ext-num-literals.diff b/SuperBuild/patches/SHARK/shark-2-ext-num-literals.diff new file mode 100644 index 0000000000..0b964c1b9a --- /dev/null +++ b/SuperBuild/patches/SHARK/shark-2-ext-num-literals.diff @@ -0,0 +1,13 @@ +diff -burN Shark.orig/CMakeLists.txt Shark/CMakeLists.txt +--- Shark.orig/CMakeLists.txt 2018-02-05 18:04:58.012612932 +0100 ++++ Shark/CMakeLists.txt 2018-02-05 18:20:50.032233165 +0100 +@@ -415,6 +415,9 @@ + ##################################################################### + # General Path settings + ##################################################################### ++if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") ++ add_definitions(-fext-numeric-literals) ++endif() + include_directories( ${shark_SOURCE_DIR}/include ) + include_directories( ${shark_BINARY_DIR}/include ) + add_subdirectory( include ) -- GitLab From 9214e10806021ebb0f926a78ccd77c927bd6d15e Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 6 Feb 2018 10:08:46 +0100 Subject: [PATCH 203/567] TEST: add trace in image creation --- Modules/Core/ImageBase/include/otbImage.h | 4 +++- Modules/Core/ImageBase/include/otbImage.txx | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/Core/ImageBase/include/otbImage.h b/Modules/Core/ImageBase/include/otbImage.h index 3bec599c72..53462952af 100644 --- a/Modules/Core/ImageBase/include/otbImage.h +++ b/Modules/Core/ImageBase/include/otbImage.h @@ -252,7 +252,9 @@ public: protected: Image(); - ~Image() ITK_OVERRIDE {} + ~Image() ITK_OVERRIDE { + std::cout<<"An image is deleted"<<std::endl; + } private: Image(const Self &) = delete; diff --git a/Modules/Core/ImageBase/include/otbImage.txx b/Modules/Core/ImageBase/include/otbImage.txx index 096a725960..01b6fc3669 100644 --- a/Modules/Core/ImageBase/include/otbImage.txx +++ b/Modules/Core/ImageBase/include/otbImage.txx @@ -32,6 +32,7 @@ namespace otb template <class TPixel, unsigned int VImageDimension> Image<TPixel, VImageDimension>::Image() { + std::cout<<"An image is created"<<std::endl; } template <class TPixel, unsigned int VImageDimension> -- GitLab From 58909492f87bde5e1279d09d6b4a15872dbcdf19 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 6 Feb 2018 10:09:09 +0100 Subject: [PATCH 204/567] TEST : hack commandline to rerun application through cli --- .../AppTest/app/otbMemoryTestApplication.cxx | 11 ++++- .../src/otbApplicationLauncherCommandLine.cxx | 45 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx b/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx index 9afb640273..44712e35c3 100644 --- a/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx +++ b/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx @@ -64,11 +64,12 @@ private: AddParameter(ParameterType_InputImage, "in", "Input image"); SetParameterDescription("in", "Input image"); + SetParameterString("in", "/home/antoine/dev/my_data/anaglyphInput2.tif"); AddParameter(ParameterType_OutputImage, "out", "Output Image"); SetParameterDescription("out", "Output image"); SetDefaultOutputPixelType("out",ImagePixelType_uint8); - + SetParameterString("out", "/home/antoine/dev/my_data/anaglyphtestInput2.tif"); AddRAMParameter(); @@ -85,18 +86,26 @@ private: void DoExecute() ITK_OVERRIDE { + #ifdef MEM_DEBUG std::cout<<"Debug on input "<<std::endl; GetParameterImage("in")->DebugOn(); + #endif ExtractROIFilterType::Pointer extractor = ExtractROIFilterType::New(); + #ifdef MEM_DEBUG extractor->DebugOn(); + #endif m_Filters.push_back(extractor.GetPointer()); + #ifdef MEM_DEBUG std::cout<<"Debug on extractor "<<std::endl; extractor->DebugOn(); + #endif extractor->SetInput(GetParameterImage("in")); extractor->SetChannel(1); extractor->UpdateOutputInformation(); + #ifdef MEM_DEBUG std::cout<<"Debug on extractor's output "<<std::endl; extractor->GetOutput()->DebugOn(); + #endif SetParameterOutputImage("out" , extractor->GetOutput() ); } diff --git a/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx b/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx index 4c5bd8a93f..0e19743f40 100644 --- a/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx +++ b/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx @@ -22,6 +22,7 @@ #include "otbWrapperCommandLineLauncher.h" #include "otb_tinyxml.h" #include <vector> +#include <iostream> #ifdef OTB_USE_MPI #include "otbMPIConfig.h" @@ -304,9 +305,53 @@ int main(int argc, char* argv[]) ShowUsage(argv); return false; } + goto RUN; + RUN : + for (auto i : vexp) + std::cout<<i<<" "; + std::cout<<std::endl; bool success = launcher->Load(vexp) && launcher->ExecuteAndWriteOutput(); + + std::string answer; + std::cout<<"Rerun or run with other args? r : rerun ; s : small test ; b : big test ; else quit "<<std::endl; + std::cin >> answer; + if ( answer[0]=='r') + { + std::cout<<"again"<<std::endl; + goto RUN; + } + else if ( answer[0]=='s' ) + { + std::cout<<"Small test running"<<std::endl; + vexp[2] = "/home/antoine/dev/my_data/anaglyphInput2.tif"; + vexp[4] = "/home/antoine/dev/my_data/anaglyphOut.tif"; + goto RUN; + } + else if ( answer[0]=='b' ) + { + std::cout<<"Big test running"<<std::endl; + vexp[2] = "/home/antoine/dev/my_data/bigbigtestclassic.tif"; + vexp[4] = "/home/antoine/dev/my_data/bigbigtestclasssic.tif"; + goto RUN; + } + // else + // { + // vexp.clear(); + // for (int i = 1; i < argc; i++) + // { + // std::string strarg(answer[i]); + // std::string cleanArg = CleanWord(strarg); + // if (cleanArg.empty()) + // { + // // Empty argument ! + // continue; + // } + // vexp.push_back(cleanArg); + // } + // goto RUN; + // } // shutdown MPI after application finished #ifdef OTB_USE_MPI otb::MPIConfig::Instance()->terminate(); -- GitLab From 4b3cb3f738e26a4ebec5f509d1af5fee1ad222ba Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 6 Feb 2018 16:00:51 +0100 Subject: [PATCH 205/567] BUG: #1504: delete SRS after usage --- .../include/otbPersistentSamplingFilterBase.txx | 12 +++++++++++- .../test/otbImageSampleExtractorFilterTest.cxx | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx index 2973a7a8a3..502438a0d2 100644 --- a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx +++ b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx @@ -265,6 +265,11 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage> } this->m_InMemoryOutputs.push_back(tmpContainer); } + + if (oSRS) + { + oSRS->Release(); + } } template <class TInputImage, class TMaskImage> @@ -734,7 +739,7 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage> } const unsigned int nbFeatThread = std::ceil(inLayer.GetFeatureCount(true) / (float) numberOfThreads); - assert(nbFeatThread > 0); + //assert(nbFeatThread > 0); OGRFeatureDefn &layerDefn = inLayer.GetLayerDefn(); ogr::Layer::const_iterator featIt = inLayer.begin(); @@ -807,6 +812,11 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage> OGRFieldDefn fieldDefn(layerDefn.GetFieldDefn(k)); outLayer.CreateField(fieldDefn); } + + if (oSRS) + { + oSRS->Release(); + } } // Add new fields diff --git a/Modules/Learning/Sampling/test/otbImageSampleExtractorFilterTest.cxx b/Modules/Learning/Sampling/test/otbImageSampleExtractorFilterTest.cxx index 138032ea73..414a773027 100644 --- a/Modules/Learning/Sampling/test/otbImageSampleExtractorFilterTest.cxx +++ b/Modules/Learning/Sampling/test/otbImageSampleExtractorFilterTest.cxx @@ -129,6 +129,7 @@ int otbImageSampleExtractorFilterUpdate(int argc, char* argv[]) output->CreateLayer( inLayer.GetName(), oSRS, inLayer.GetLayerDefn().GetGeomType()); + oSRS->Release(); otb::ogr::Layer dstLayer = output->GetLayer(0); OGRFieldDefn labelField(classFieldName.c_str(),OFTString); dstLayer.CreateField(labelField, true); -- GitLab From 8c25bb88da272ec4a71ced949f83dc56c0a3977d Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 6 Feb 2018 16:13:07 +0100 Subject: [PATCH 206/567] TEST : still adding trace --- Modules/Core/Common/src/otbFilterWatcherBase.cxx | 1 + .../Core/Common/src/otbStandardOneLineFilterWatcher.cxx | 3 +++ Modules/Core/ImageBase/include/otbImage.h | 4 +++- Modules/Core/ImageBase/include/otbImage.txx | 5 +++++ Modules/Core/ImageBase/include/otbVectorImage.h | 4 +++- Modules/Core/ImageBase/include/otbVectorImage.txx | 4 ++++ .../include/otbWrapperAddProcessToWatchEvent.h | 8 ++++++-- .../ApplicationEngine/src/otbWrapperApplication.cxx | 2 ++ 8 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Modules/Core/Common/src/otbFilterWatcherBase.cxx b/Modules/Core/Common/src/otbFilterWatcherBase.cxx index 2e4f9644bb..bbb564b02c 100644 --- a/Modules/Core/Common/src/otbFilterWatcherBase.cxx +++ b/Modules/Core/Common/src/otbFilterWatcherBase.cxx @@ -159,6 +159,7 @@ FilterWatcherBase FilterWatcherBase ::~FilterWatcherBase() { + std::cout<<"A FilterWatcherBase is deleted... Description was "<<m_Comment<<std::endl; // Remove any observers we have on the old process object if (m_Process) { diff --git a/Modules/Core/Common/src/otbStandardOneLineFilterWatcher.cxx b/Modules/Core/Common/src/otbStandardOneLineFilterWatcher.cxx index 77e350402f..84c67d05c9 100644 --- a/Modules/Core/Common/src/otbStandardOneLineFilterWatcher.cxx +++ b/Modules/Core/Common/src/otbStandardOneLineFilterWatcher.cxx @@ -29,6 +29,7 @@ StandardOneLineFilterWatcher : m_StarsCount(50), m_CurrentNbStars(-1) { + std::cout<<"A StandardOneLineFilterWatcher is created (default)"<<std::endl; } StandardOneLineFilterWatcher @@ -38,6 +39,7 @@ StandardOneLineFilterWatcher m_StarsCount(50), m_CurrentNbStars(-1) { + std::cout<<"A StandardOneLineFilterWatcher is created with description "<<comment<<std::endl; } StandardOneLineFilterWatcher @@ -47,6 +49,7 @@ StandardOneLineFilterWatcher m_StarsCount(50), m_CurrentNbStars(-1) { + std::cout<<"A StandardOneLineFilterWatcher is created with description "<<comment<<std::endl; } void diff --git a/Modules/Core/ImageBase/include/otbImage.h b/Modules/Core/ImageBase/include/otbImage.h index 53462952af..4eb2ec9388 100644 --- a/Modules/Core/ImageBase/include/otbImage.h +++ b/Modules/Core/ImageBase/include/otbImage.h @@ -179,7 +179,7 @@ public: // { // return AccessorType(); // } - + static int m_Instance; /** Return the NeighborhoodAccessor functor */ NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() { @@ -254,6 +254,8 @@ protected: Image(); ~Image() ITK_OVERRIDE { std::cout<<"An image is deleted"<<std::endl; + m_Instance--; + std::cout<<m_Instance<<" image(s) still live(s)"<<std::endl; } private: diff --git a/Modules/Core/ImageBase/include/otbImage.txx b/Modules/Core/ImageBase/include/otbImage.txx index 01b6fc3669..6127e6b48d 100644 --- a/Modules/Core/ImageBase/include/otbImage.txx +++ b/Modules/Core/ImageBase/include/otbImage.txx @@ -29,10 +29,15 @@ namespace otb { +template <class TPixel, unsigned int VImageDimension> +int Image<TPixel, VImageDimension>::m_Instance = 0; + template <class TPixel, unsigned int VImageDimension> Image<TPixel, VImageDimension>::Image() { std::cout<<"An image is created"<<std::endl; + m_Instance++; + std::cout<<m_Instance<<" image(s) live(s)"<<std::endl; } template <class TPixel, unsigned int VImageDimension> diff --git a/Modules/Core/ImageBase/include/otbVectorImage.h b/Modules/Core/ImageBase/include/otbVectorImage.h index 9e948ec5c9..edd3b267c9 100644 --- a/Modules/Core/ImageBase/include/otbVectorImage.h +++ b/Modules/Core/ImageBase/include/otbVectorImage.h @@ -179,7 +179,7 @@ public: // { // return AccessorType( this->GetNumberOfComponentsPerPixel() ); // } - + static int m_Instance; /** Return the NeighborhoodAccessor functor */ NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() { @@ -196,6 +196,8 @@ protected: VectorImage(); ~VectorImage() ITK_OVERRIDE { std::cout<<"A vector image is deleted"<<std::endl; + m_Instance--; + std::cout<<m_Instance<<" vector image(s) still live(s)"<<std::endl; } private: diff --git a/Modules/Core/ImageBase/include/otbVectorImage.txx b/Modules/Core/ImageBase/include/otbVectorImage.txx index 83c3f0f6e7..0d95d4c6e9 100644 --- a/Modules/Core/ImageBase/include/otbVectorImage.txx +++ b/Modules/Core/ImageBase/include/otbVectorImage.txx @@ -29,11 +29,15 @@ namespace otb { +template <class TPixel, unsigned int VImageDimension> +int VectorImage<TPixel, VImageDimension>::m_Instance = 0; template <class TPixel, unsigned int VImageDimension> VectorImage<TPixel, VImageDimension>::VectorImage() { std::cout<<"A vector image is created"<<std::endl; + m_Instance++; + std::cout<<m_Instance<<" vector image(s) live(s)"<<std::endl; } template <class TPixel, unsigned int VImageDimension> diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h index 3cf9114c81..129e1e74ea 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h @@ -44,9 +44,13 @@ public: typedef AddProcessToWatchEvent Self; typedef itk::EventObject Superclass; - AddProcessToWatchEvent(){} + AddProcessToWatchEvent(){ + std::cout<<"A new AddProcessToWatchEvent is created"<<std::endl; + } AddProcessToWatchEvent(const Self& s) :itk::EventObject(s){}; - ~AddProcessToWatchEvent() ITK_OVERRIDE {} + ~AddProcessToWatchEvent() ITK_OVERRIDE { + std::cout<<"The AddProcessToWatchEvent is deleted... Description was : "<<m_ProcessDescription<<std::endl; + } /** Set/Get the process to watch */ virtual void SetProcess(itk::ProcessObject * process) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 988f9f7243..89fca70c59 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -410,6 +410,7 @@ int Application::Execute() int Application::ExecuteAndWriteOutput() { + std::cout<<"Executing..."<<std::endl; m_Chrono.Restart(); int status = this->Execute(); @@ -465,6 +466,7 @@ int Application::ExecuteAndWriteOutput() } std::ostringstream progressId; progressId << "Writing " << outputParam->GetFileName() << "..."; + std::cout<<"Add Process and write"<<std::endl; AddProcess(outputParam->GetWriter(), progressId.str()); outputParam->Write(); } -- GitLab From 896555a41253f2d30c4bce4ac38de283a152597c Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 6 Feb 2018 16:13:29 +0100 Subject: [PATCH 207/567] BUG: cleaning memory of output parameter, input parameter and watchers --- .../include/otbWrapperApplication.h | 4 ++ .../include/otbWrapperOutputImageParameter.h | 2 + .../otbWrapperOutputVectorDataParameter.h | 7 +++ .../src/otbWrapperApplication.cxx | 53 ++++++++++++++++++- .../src/otbWrapperOutputImageParameter.cxx | 32 +++++++++++ .../src/otbWrapperCommandLineLauncher.cxx | 4 +- 6 files changed, 100 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index f33d1ba168..7a499b8845 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -154,6 +154,10 @@ public: */ int ExecuteAndWriteOutput(); + /** Clear the pipeline and the various parameters that hold data + */ + virtual void ClearMemory(); + /* Get the internal application parameters * * WARNING: this method may disappear from the API */ diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index b420299ff6..de1b2eec4a 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -113,6 +113,8 @@ public: std::string CheckFileName(bool fixMissingExtension = false); + void ClearValue() override; + protected: /** Constructor */ OutputImageParameter(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h index fb90702544..9519732578 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h @@ -107,6 +107,13 @@ public: m_Writer = otb::VectorDataFileWriter<VectorDataType>::New(); } + void ClearValue() override + { + m_Writer = nullptr; + m_VectorData = nullptr; + m_FileName = ""; + Superclass::ClearValue(); + } protected: /** Constructor */ OutputVectorDataParameter() diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 89fca70c59..10a685fba7 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -469,6 +469,7 @@ int Application::ExecuteAndWriteOutput() std::cout<<"Add Process and write"<<std::endl; AddProcess(outputParam->GetWriter(), progressId.str()); outputParam->Write(); + // ClearWriter in param(); } } else if (GetParameterType(key) == ParameterType_OutputVectorData @@ -520,12 +521,62 @@ int Application::ExecuteAndWriteOutput() } this->AfterExecuteAndWriteOutputs(); - m_Filters.clear(); m_Chrono.Stop(); + ClearMemory(); return status; } +void Application::ClearMemory() +{ + // Cleaning the parameter input and output + std::vector<std::string> paramList = GetParametersKeys(true); + for (std::vector<std::string>::const_iterator it = paramList.begin(); + it != paramList.end(); + ++it) + { + std::string key = *it; + if (GetParameterType(key) == ParameterType_InputImage ) + { + Parameter* param = GetParameterByKey(key); + InputImageParameter * input = dynamic_cast<InputImageParameter*>(param); + input->ClearValue(); + } + else if (GetParameterType(key) == ParameterType_InputImageList ) + { + Parameter* param = GetParameterByKey(key); + InputImageListParameter * input = dynamic_cast<InputImageListParameter*>(param); + input->ClearValue(); + } + else if (GetParameterType(key) == ParameterType_InputVectorData ) + { + Parameter* param = GetParameterByKey(key); + InputVectorDataParameter * input = dynamic_cast<InputVectorDataParameter*>(param); + input->ClearValue(); + } + else if (GetParameterType(key) == ParameterType_InputVectorDataList ) + { + Parameter* param = GetParameterByKey(key); + InputVectorDataListParameter * input = dynamic_cast<InputVectorDataListParameter*>(param); + input->ClearValue(); + } + else if (GetParameterType(key) == ParameterType_OutputImage ) + { + Parameter* param = GetParameterByKey(key); + OutputImageParameter * input = dynamic_cast<OutputImageParameter*>(param); + input->ClearValue(); + } + else + { + continue; + } + } + // Cleaning m_ProgressSource + m_ProgressSource = nullptr; + + // Cleaning m_Filters + m_Filters.clear(); +} /* Enable the use of an optional parameter. Returns the previous state */ void Application::EnableParameter(std::string paramKey) { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 2790bdce25..623f55c84f 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -449,6 +449,9 @@ OutputImageParameter::Write() { itkExceptionMacro("Unknown image type"); } + + // Clear writer + m_UInt8Writer = nullptr; } @@ -625,5 +628,34 @@ OutputImageParameter::CheckFileName(bool fixMissingExtension) return ret; } +void OutputImageParameter::ClearValue() +{ + m_Image = nullptr; + m_FileName = ""; + + m_UInt8Writer = nullptr; + m_Int16Writer = nullptr; + m_UInt16Writer = nullptr; + m_Int32Writer = nullptr; + m_UInt32Writer = nullptr; + m_FloatWriter = nullptr; + m_DoubleWriter = nullptr; + + m_VectorUInt8Writer = nullptr; + m_VectorInt16Writer = nullptr; + m_VectorUInt16Writer = nullptr; + m_VectorInt32Writer = nullptr; + m_VectorUInt32Writer = nullptr; + m_VectorFloatWriter = nullptr; + m_VectorDoubleWriter = nullptr; + + m_RGBUInt8Writer = nullptr; + m_RGBAUInt8Writer = nullptr; + + m_RAMValue = 0; + + Superclass::ClearValue(); +} + } } diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx index cf70dc07b7..7b5caa5d02 100644 --- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx +++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx @@ -188,7 +188,9 @@ bool CommandLineLauncher::ExecuteAndWriteOutput() m_Application->GetLogger()->Fatal("Caught unknown exception during application execution.\n"); return false; } - + + // Cleaning process + DeleteWatcherList(); return true; } -- GitLab From 24065769c1c499aab1254226c31babd74aab3207 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 6 Feb 2018 16:41:16 +0100 Subject: [PATCH 208/567] REFAC: do not clear filename parameter at the end of execution --- .../include/otbWrapperOutputVectorDataParameter.h | 2 +- .../ApplicationEngine/src/otbWrapperOutputImageParameter.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h index 9519732578..adf5faf96f 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h @@ -111,7 +111,7 @@ public: { m_Writer = nullptr; m_VectorData = nullptr; - m_FileName = ""; + // m_FileName = ""; Superclass::ClearValue(); } protected: diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 623f55c84f..632b4f4d08 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -631,7 +631,7 @@ OutputImageParameter::CheckFileName(bool fixMissingExtension) void OutputImageParameter::ClearValue() { m_Image = nullptr; - m_FileName = ""; + // m_FileName = ""; m_UInt8Writer = nullptr; m_Int16Writer = nullptr; @@ -652,7 +652,7 @@ void OutputImageParameter::ClearValue() m_RGBUInt8Writer = nullptr; m_RGBAUInt8Writer = nullptr; - m_RAMValue = 0; + // m_RAMValue = 0; Superclass::ClearValue(); } -- GitLab From bbe14585cef8799ec2d9a4147d5027d14450e0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Savinaud?= <mickael.savinaud@c-s.fr> Date: Tue, 6 Feb 2018 17:27:28 +0100 Subject: [PATCH 209/567] [ENH] improve the cookbook documentation about the extended filename Extended filemame are described in the OTB-Application section which is not the right place I think No examples are provided,I have added two : one for reader and another for writer I have added also a link about create_option of GDAL for GeoTIFF --- .../Cookbook/rst/ExtendedFilenames.rst | 307 ++++++++++++++++++ .../Cookbook/rst/OTB-Applications.rst | 290 ----------------- 2 files changed, 307 insertions(+), 290 deletions(-) create mode 100644 Documentation/Cookbook/rst/ExtendedFilenames.rst diff --git a/Documentation/Cookbook/rst/ExtendedFilenames.rst b/Documentation/Cookbook/rst/ExtendedFilenames.rst new file mode 100644 index 0000000000..8185322773 --- /dev/null +++ b/Documentation/Cookbook/rst/ExtendedFilenames.rst @@ -0,0 +1,307 @@ +Extended filenames +================================ + +There are multiple ways to define geo-referencing information. For +instance, one can use a geographic transform, a cartographic projection, +or a sensor model with RPC coefficients. A single image may contain +several of these elements, such as in the “ortho-ready†products: this +is a type of product still in sensor geometry (the sensor model is +supplied with the image) but it also contains an approximative +geographic transform that can be used to have a quick estimate of the +image localisation. For instance, your product may contain a “.TIF†file +for the image, along with a “.RPB†file that contains the sensor model +coefficients and an “.IMD†file that contains a cartographic projection. + +This case leads to the following question: which geo-referencing +element should be used when opening this image in OTB. In +fact, it depends on the users need. For an orthorectification +application, the sensor model must be used. In order to specify which +information should be skipped, a syntax of extended filenames has been +developed for both reading and writing. + +The reader and writer extended file name support is based on the same +syntax, only the options are different. To benefit from the extended +file name mechanism, the following syntax is to be used: + +:: + + Path/Image.ext?&key1=<value1>&key2=<value2> + +**Note that you’ll probably need to “quote†the filename, especially if calling +applications from the bash command line.** + +Reader options +^^^^^^^^^^^^^^ + +:: + + &geom=<path/filename.geom> + +- Contains the file name of a valid geom file + +- Use the content of the specified geom file instead of + image-embedded geometric information + +- empty by default, use the image-embedded information if available + +----------------------------------------------- + +:: + + &sdataidx=<(int)idx> + +- Select the sub-dataset to read + +- 0 by default + +----------------------------------------------- + +:: + + &resol=<(int)resolution factor> + +- Select the JPEG2000 sub-resolution image to read + +- 0 by default + +----------------------------------------------- + +:: + + &bands=r1,r2,...,rn + +- Select a subset of bands from the input image + +- The syntax is inspired by Python indexing syntax with + bands=r1,r2,r3,...,rn where each ri is a band range that can be : + + - a single index (1-based) : + + - :code:`2` means 2nd band + + - :code:`-1` means last band + + - or a range of bands : + + - :code:`3:` means 3rd band until the last one + + - :code:`:-2` means the first bands until the second to last + + - :code:`2:4` means bands 2,3 and 4 + +- empty by default (all bands are read from the input image) + +----------------------------------------------- + +:: + + &skipcarto=<(bool)true> + +- Skip the cartographic information + +- Clears the projectionref, set the origin to :math:`[0,0]` and the + spacing to :math:`[1/max(1,r),1/max(1,r)]` where :math:`r` is the resolution + factor. + +- Keeps the keyword list + +- false by default + +----------------------------------------------- + +:: + + &skipgeom=<(bool)true> + +- Skip geometric information + +- Clears the keyword list + +- Keeps the projectionref and the origin/spacing information + +- false by default. + +----------------------------------------------- + +:: + + &skiprpctag=<(bool)true> + +- Skip the reading of internal RPC tags (see + [sec:TypesofSensorModels] for details) + +- false by default. + +Writer options +^^^^^^^^^^^^^^ + +:: + + &writegeom=<(bool)false> + +- To activate writing of external geom file + +- true by default + +----------------------------------------------- + +:: + + &writerpctags=<(bool)true> + +- To activate writing of RPC tags in TIFF files + +- false by default + +----------------------------------------------- + +:: + + &gdal:co:<GDALKEY>=<VALUE> + +- To specify a gdal creation option + +- For gdal creation option information, see dedicated gdal documentation +for each driver. For example, you can find `here +<http://www.gdal.org/frmt_gtiff.html>`_ the information about the GeoTiff +create options. + +- None by default + +----------------------------------------------- + +:: + + &streaming:type=<VALUE> + +- Activates configuration of streaming through extended filenames + +- Override any previous configuration of streaming + +- Allows to configure the kind of streaming to perform + +- Available values are: + + - auto: tiled or stripped streaming mode chosen automatically + depending on TileHint read from input files + + - tiled: tiled streaming mode + + - stripped: stripped streaming mode + + - none: explicitly deactivate streaming + +- Not set by default + +----------------------------------------------- + +:: + + &streaming:sizemode=<VALUE> + +- Allows to choose how the size of the streaming pieces is computed + +- Available values are: + + - auto: size is estimated from the available memory setting by + evaluating pipeline memory print + + - height: size is set by setting height of strips or tiles + + - nbsplits: size is computed from a given number of splits + +- Default is auto + +----------------------------------------------- + +:: + + &streaming:sizevalue=<VALUE> + +- Parameter for size of streaming pieces computation + +- Value is : + + - if sizemode=auto: available memory in Mb + + - if sizemode=height: height of the strip or tile in pixels + + - if sizemode=nbsplits: number of requested splits for streaming + +- If not provided, the default value is set to 0 and result in + different behaviour depending on sizemode (if set to height or + nbsplits, streaming is deactivated, if set to auto, value is + fetched from configuration or cmake configuration file) + +----------------------------------------------- + +:: + + &box=<startx>:<starty>:<sizex>:<sizey> + +- User defined parameters of output image region + +- The region must be set with 4 unsigned integers (the separator + used is the colon ’:’). Values are: + + - startx: first index on X (starting with 0) + + - starty: first index on Y (starting with 0) + + - sizex: size along X + + - sizey: size along Y + +- The definition of the region follows the same convention as + itk::Region definition in C++. A region is defined by two classes: + the itk::Index and itk::Size classes. The origin of the region + within the image with which it is associated is defined by Index + +----------------------------------------------- + +:: + + &bands=r1,r2,...,rn + +- Select a subset of bands from the output image + +- The syntax is inspired by Python indexing syntax with + bands=r1,r2,r3,...,rn where each ri is a band range that can be : + + - a single index (1-based) : + + - :code:`2` means 2nd band + + - :code:`-1` means last band + + - or a range of bands : + + - :code:`3:` means 3rd band until the last one + + - :code:`:-2` means the first bands until the second to last + + - :code:`2:4` means bands 2,3 and 4 + +- Empty by default (all bands are write from the output image) + +The available syntax for boolean options are: + +- ON, On, on, true, True, 1 are available for setting a ’true’ boolean + value + +- OFF, Off, off, false, False, 0 are available for setting a ’false’ + boolean value + +You can find below some examples: + +- Write a file with blockSize equal to 256 and with DEFLATE compression + +:: + + $ otbcli_Convert -in OTB-Data/Examples/QB_1_ortho.tif -out "/tmp/example1.tif?&gdal:co:TILED=YES&gdal:co:COMPRESS=DEFLATE" + +- Process only one band from a file + +:: + + $ otbcli_Convert -in "OTB-Data/Examples/QB_1_ortho.tif?&bands=1" -out /tmp/example2.tif diff --git a/Documentation/Cookbook/rst/OTB-Applications.rst b/Documentation/Cookbook/rst/OTB-Applications.rst index 4da50bd9f4..bf7b02056e 100644 --- a/Documentation/Cookbook/rst/OTB-Applications.rst +++ b/Documentation/Cookbook/rst/OTB-Applications.rst @@ -363,293 +363,3 @@ images output parameters. .. _extended-filenames: -Extended filenames ------------------- - -There are multiple ways to define geo-referencing information. For -instance, one can use a geographic transform, a cartographic projection, -or a sensor model with RPC coefficients. A single image may contain -several of these elements, such as in the “ortho-ready†products: this -is a type of product still in sensor geometry (the sensor model is -supplied with the image) but it also contains an approximative -geographic transform that can be used to have a quick estimate of the -image localisation. For instance, your product may contain a “.TIF†file -for the image, along with a “.RPB†file that contains the sensor model -coefficients and an “.IMD†file that contains a cartographic projection. - -This case leads to the following question: which geo-referencing -element should be used when opening this image in OTB. In -fact, it depends on the users need. For an orthorectification -application, the sensor model must be used. In order to specify which -information should be skipped, a syntax of extended filenames has been -developed for both reading and writing. - -The reader and writer extended file name support is based on the same -syntax, only the options are different. To benefit from the extended -file name mechanism, the following syntax is to be used: - -:: - - Path/Image.ext?&key1=<value1>&key2=<value2> - -Note that you’ll probably need to “quote†the filename, especially if calling -applications from the bash command line. - -Reader options -^^^^^^^^^^^^^^ - -:: - - &geom=<path/filename.geom> - -- Contains the file name of a valid geom file - -- Use the content of the specified geom file instead of - image-embedded geometric information - -- empty by default, use the image-embedded information if available - ------------------------------------------------ - -:: - - &sdataidx=<(int)idx> - -- Select the sub-dataset to read - -- 0 by default - ------------------------------------------------ - -:: - - &resol=<(int)resolution factor> - -- Select the JPEG2000 sub-resolution image to read - -- 0 by default - ------------------------------------------------ - -:: - - &bands=r1,r2,...,rn - -- Select a subset of bands from the input image - -- The syntax is inspired by Python indexing syntax with - bands=r1,r2,r3,...,rn where each ri is a band range that can be : - - - a single index (1-based) : - - - :code:`2` means 2nd band - - - :code:`-1` means last band - - - or a range of bands : - - - :code:`3:` means 3rd band until the last one - - - :code:`:-2` means the first bands until the second to last - - - :code:`2:4` means bands 2,3 and 4 - -- empty by default (all bands are read from the input image) - ------------------------------------------------ - -:: - - &skipcarto=<(bool)true> - -- Skip the cartographic information - -- Clears the projectionref, set the origin to :math:`[0,0]` and the - spacing to :math:`[1/max(1,r),1/max(1,r)]` where :math:`r` is the resolution - factor. - -- Keeps the keyword list - -- false by default - ------------------------------------------------ - -:: - - &skipgeom=<(bool)true> - -- Skip geometric information - -- Clears the keyword list - -- Keeps the projectionref and the origin/spacing information - -- false by default. - ------------------------------------------------ - -:: - - &skiprpctag=<(bool)true> - -- Skip the reading of internal RPC tags (see - [sec:TypesofSensorModels] for details) - -- false by default. - -Writer options -^^^^^^^^^^^^^^ - -:: - - &writegeom=<(bool)false> - -- To activate writing of external geom file - -- true by default - ------------------------------------------------ - -:: - - &writerpctags=<(bool)true> - -- To activate writing of RPC tags in TIFF files - -- false by default - ------------------------------------------------ - -:: - - &gdal:co:<GDALKEY>=<VALUE> - -- To specify a gdal creation option - -- For gdal creation option information, see dedicated gdal documentation - -- None by default - ------------------------------------------------ - -:: - - &streaming:type=<VALUE> - -- Activates configuration of streaming through extended filenames - -- Override any previous configuration of streaming - -- Allows to configure the kind of streaming to perform - -- Available values are: - - - auto: tiled or stripped streaming mode chosen automatically - depending on TileHint read from input files - - - tiled: tiled streaming mode - - - stripped: stripped streaming mode - - - none: explicitly deactivate streaming - -- Not set by default - ------------------------------------------------ - -:: - - &streaming:sizemode=<VALUE> - -- Allows to choose how the size of the streaming pieces is computed - -- Available values are: - - - auto: size is estimated from the available memory setting by - evaluating pipeline memory print - - - height: size is set by setting height of strips or tiles - - - nbsplits: size is computed from a given number of splits - -- Default is auto - ------------------------------------------------ - -:: - - &streaming:sizevalue=<VALUE> - -- Parameter for size of streaming pieces computation - -- Value is : - - - if sizemode=auto: available memory in Mb - - - if sizemode=height: height of the strip or tile in pixels - - - if sizemode=nbsplits: number of requested splits for streaming - -- If not provided, the default value is set to 0 and result in - different behaviour depending on sizemode (if set to height or - nbsplits, streaming is deactivated, if set to auto, value is - fetched from configuration or cmake configuration file) - ------------------------------------------------ - -:: - - &box=<startx>:<starty>:<sizex>:<sizey> - -- User defined parameters of output image region - -- The region must be set with 4 unsigned integers (the separator - used is the colon ’:’). Values are: - - - startx: first index on X (starting with 0) - - - starty: first index on Y (starting with 0) - - - sizex: size along X - - - sizey: size along Y - -- The definition of the region follows the same convention as - itk::Region definition in C++. A region is defined by two classes: - the itk::Index and itk::Size classes. The origin of the region - within the image with which it is associated is defined by Index - ------------------------------------------------ - -:: - - &bands=r1,r2,...,rn - -- Select a subset of bands from the output image - -- The syntax is inspired by Python indexing syntax with - bands=r1,r2,r3,...,rn where each ri is a band range that can be : - - - a single index (1-based) : - - - :code:`2` means 2nd band - - - :code:`-1` means last band - - - or a range of bands : - - - :code:`3:` means 3rd band until the last one - - - :code:`:-2` means the first bands until the second to last - - - :code:`2:4` means bands 2,3 and 4 - -- Empty by default (all bands are write from the output image) - -The available syntax for boolean options are: - -- ON, On, on, true, True, 1 are available for setting a ’true’ boolean - value - -- OFF, Off, off, false, False, 0 are available for setting a ’false’ - boolean value -- GitLab From a27f06da110b37a4afc42f36313a0aa5b9da986b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABlle=20USSEGLIO?= <gaelle.usseglio@cnes.fr> Date: Wed, 7 Feb 2018 09:09:18 +0000 Subject: [PATCH 210/567] ENH: Update new functions of otbSarSensorModelAdapter with the OTB usage --- .../include/otbSarSensorModelAdapter.h | 6 +-- .../src/otbSarSensorModelAdapter.cxx | 37 +++++++------------ 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h index 312caa5f3a..8a713883b6 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h @@ -92,13 +92,13 @@ public: (col,row) */ bool WorldToLineSample(const Point3DType & inGEoPOint, Point2DType & cr) const; - /** Transform world point (lat,lon,hgt) to cartesian point (x,y,z) */ - bool WorldToCartesian(const Point3DType & inGeoPoint, Point3DType & outCartesianPoint) const; - /** Transform world point (lat,lon,hgt) to satellite position (x,y,z) and satellite velocity */ bool WorldToSatPositionAndVelocity(const Point3DType & inGeoPoint, Point3DType & satelitePosition, Point3DType & sateliteVelocity) const; + /** Transform world point (lat,lon,hgt) to cartesian point (x,y,z) */ + static bool WorldToCartesian(const Point3DType & inGeoPoint, Point3DType & outCartesianPoint); + static bool ImageLineToDeburstLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long imageLine, unsigned long & deburstLine); static void DeburstLineToImageLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long deburstLine, unsigned long & imageLine); diff --git a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx index e3b594a8fb..56bcfbca01 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx @@ -117,8 +117,8 @@ bool SarSensorModelAdapter::WorldToLineSampleYZ(const Point3DType & inGeoPoint, } ossimGpt inGpt; - inGpt.lat = inGeoPoint[0]; - inGpt.lon = inGeoPoint[1]; + inGpt.lon = inGeoPoint[0]; + inGpt.lat = inGeoPoint[1]; inGpt.hgt = inGeoPoint[2]; ossimDpt outDpt; @@ -145,8 +145,8 @@ bool SarSensorModelAdapter::WorldToLineSample(const Point3DType & inGeoPoint, Po } ossimGpt inGpt; - inGpt.lat = inGeoPoint[0]; - inGpt.lon = inGeoPoint[1]; + inGpt.lon = inGeoPoint[0]; + inGpt.lat = inGeoPoint[1]; inGpt.hgt = inGeoPoint[2]; ossimDpt outDpt; @@ -162,21 +162,14 @@ bool SarSensorModelAdapter::WorldToLineSample(const Point3DType & inGeoPoint, Po return true; } -bool SarSensorModelAdapter::WorldToCartesian(const Point3DType & inGeoPoint, Point3DType & outCartesianPoint) const +bool SarSensorModelAdapter::WorldToCartesian(const Point3DType & inGeoPoint, Point3DType & outCartesianPoint) { - if(m_SensorModel.get() == ITK_NULLPTR) - { - return false; - } - ossimGpt inGpt; - inGpt.lat = inGeoPoint[0]; - inGpt.lon = inGeoPoint[1]; + inGpt.lon = inGeoPoint[0]; + inGpt.lat = inGeoPoint[1]; inGpt.hgt = inGeoPoint[2]; - ossimEcefPoint outCartesien(inGpt); - if(outCartesien.isNan()) return false; @@ -186,12 +179,11 @@ bool SarSensorModelAdapter::WorldToCartesian(const Point3DType & inGeoPoint, Poi outCartesianPoint[2] = outCartesien.z(); return true; - } - - bool SarSensorModelAdapter::WorldToSatPositionAndVelocity(const Point3DType & inGeoPoint, - Point3DType & satelitePosition, - Point3DType & sateliteVelocity) const + +bool SarSensorModelAdapter::WorldToSatPositionAndVelocity(const Point3DType & inGeoPoint, + Point3DType & satelitePosition, + Point3DType & sateliteVelocity) const { if(m_SensorModel.get() == ITK_NULLPTR) { @@ -199,10 +191,9 @@ bool SarSensorModelAdapter::WorldToCartesian(const Point3DType & inGeoPoint, Poi } ossimGpt inGpt; - inGpt.lat = inGeoPoint[0]; - inGpt.lon = inGeoPoint[1]; + inGpt.lon = inGeoPoint[0]; + inGpt.lat = inGeoPoint[1]; inGpt.hgt = inGeoPoint[2]; - ossimplugins::ossimSarSensorModel::TimeType azimuthTime; double rangeTime; @@ -211,7 +202,7 @@ bool SarSensorModelAdapter::WorldToCartesian(const Point3DType & inGeoPoint, Poi const bool success = m_SensorModel->worldToAzimuthRangeTime(inGpt, azimuthTime, rangeTime,sensorPos,sensorVel); - if(sensorPos.isNan()) + if(sensorPos.isNan() || !success) return false; satelitePosition[0] = sensorPos.x(); -- GitLab From 55c7d6fd4c3da0204919a78cf9edafa758772369 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 7 Feb 2018 11:09:59 +0100 Subject: [PATCH 211/567] ENH : change cleaning method so that we can rerun application without changing input name --- .../src/otbWrapperApplication.cxx | 15 +++++++++++++-- .../src/otbWrapperInputImageParameter.cxx | 6 +++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 10a685fba7..c32feb4b8b 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -530,6 +530,7 @@ void Application::ClearMemory() { // Cleaning the parameter input and output std::vector<std::string> paramList = GetParametersKeys(true); + std::string filename (""); for (std::vector<std::string>::const_iterator it = paramList.begin(); it != paramList.end(); ++it) @@ -539,31 +540,41 @@ void Application::ClearMemory() { Parameter* param = GetParameterByKey(key); InputImageParameter * input = dynamic_cast<InputImageParameter*>(param); + filename = input->GetFileName(); input->ClearValue(); + input->SetFromFileName(filename); } else if (GetParameterType(key) == ParameterType_InputImageList ) { Parameter* param = GetParameterByKey(key); InputImageListParameter * input = dynamic_cast<InputImageListParameter*>(param); + std::vector< std::string > filenamelist = input->GetFileNameList(); input->ClearValue(); + input->SetListFromFileName(filenamelist); } else if (GetParameterType(key) == ParameterType_InputVectorData ) { Parameter* param = GetParameterByKey(key); InputVectorDataParameter * input = dynamic_cast<InputVectorDataParameter*>(param); + filename = input->GetFileName(); input->ClearValue(); + input->SetFromFileName(filename); } else if (GetParameterType(key) == ParameterType_InputVectorDataList ) { Parameter* param = GetParameterByKey(key); InputVectorDataListParameter * input = dynamic_cast<InputVectorDataListParameter*>(param); + std::vector< std::string > filenamelist = input->GetFileNameList(); input->ClearValue(); + input->SetListFromFileName(filenamelist); } else if (GetParameterType(key) == ParameterType_OutputImage ) { Parameter* param = GetParameterByKey(key); - OutputImageParameter * input = dynamic_cast<OutputImageParameter*>(param); - input->ClearValue(); + OutputImageParameter * output = dynamic_cast<OutputImageParameter*>(param); + filename = output->GetFileName(); + output->ClearValue(); + output->SetFileName(filename); } else { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx index 166ab2956a..ebf0a10295 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx @@ -93,9 +93,9 @@ void InputImageParameter ::ClearValue() { - m_Image = ITK_NULLPTR; - m_Reader = ITK_NULLPTR; - m_Caster = ITK_NULLPTR; + m_Image = nullptr; + m_Reader = nullptr; + m_Caster = nullptr; m_FileName = ""; m_PreviousFileName=""; m_UseFilename = true; -- GitLab From 5eb5211f4925029c363220708d2de8df60978791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Savinaud?= <mickael.savinaud@c-s.fr> Date: Wed, 7 Feb 2018 13:22:28 +0100 Subject: [PATCH 212/567] [ENH] enhance documentation about the extended filenames add in TOC the file update the introduction add the reference about the section --- .../Cookbook/rst/ExtendedFilenames.rst | 30 ++++++++++++------- .../Cookbook/rst/OTB-Applications.rst | 3 -- Documentation/Cookbook/rst/index_TOC.rst | 1 + 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Documentation/Cookbook/rst/ExtendedFilenames.rst b/Documentation/Cookbook/rst/ExtendedFilenames.rst index 8185322773..02b5512351 100644 --- a/Documentation/Cookbook/rst/ExtendedFilenames.rst +++ b/Documentation/Cookbook/rst/ExtendedFilenames.rst @@ -1,7 +1,14 @@ +.. _extended-filenames: + Extended filenames ================================ -There are multiple ways to define geo-referencing information. For +Extended filenames is an interesting feature of OTB. With it, you can control +several aspects of the beahvior of the OTB in the OTB-Applications or in our +own C++ applications. Historically this feature has been desingn to solve +an issue with how to handle geo-referencing information. + +Indeed, there are multiple ways to define geo-referencing information. For instance, one can use a geographic transform, a cartographic projection, or a sensor model with RPC coefficients. A single image may contain several of these elements, such as in the “ortho-ready†products: this @@ -19,9 +26,12 @@ application, the sensor model must be used. In order to specify which information should be skipped, a syntax of extended filenames has been developed for both reading and writing. -The reader and writer extended file name support is based on the same -syntax, only the options are different. To benefit from the extended -file name mechanism, the following syntax is to be used: +Since the development of this feature we have extend this mechanism for +other aspaects: like band or overview selection in reader part or support +create option of gdal in writer part.The reader and writer extended filename +support is based on the same syntax, only the options are different. +To benefit from the extended file name mechanism, the following syntax +is to be used: :: @@ -157,14 +167,11 @@ Writer options :: - &gdal:co:<GDALKEY>=<VALUE> + &gdal:co:<GDALKEY>=<VALUE> - To specify a gdal creation option -- For gdal creation option information, see dedicated gdal documentation -for each driver. For example, you can find `here -<http://www.gdal.org/frmt_gtiff.html>`_ the information about the GeoTiff -create options. +- For gdal creation option information, see dedicated gdal documentation for each driver. For example, you can find `here <http://www.gdal.org/frmt_gtiff.html>`_ the information about the GeoTiff create options - None by default @@ -291,6 +298,9 @@ The available syntax for boolean options are: - OFF, Off, off, false, False, 0 are available for setting a ’false’ boolean value + +Examples +^^^^^^^^^^^^^^ You can find below some examples: @@ -300,7 +310,7 @@ You can find below some examples: $ otbcli_Convert -in OTB-Data/Examples/QB_1_ortho.tif -out "/tmp/example1.tif?&gdal:co:TILED=YES&gdal:co:COMPRESS=DEFLATE" -- Process only one band from a file +- Process only first band from a file :: diff --git a/Documentation/Cookbook/rst/OTB-Applications.rst b/Documentation/Cookbook/rst/OTB-Applications.rst index bf7b02056e..1905a737e7 100644 --- a/Documentation/Cookbook/rst/OTB-Applications.rst +++ b/Documentation/Cookbook/rst/OTB-Applications.rst @@ -360,6 +360,3 @@ among 560 cpus and took only 56 seconds. Note that this MPI parallel invocation of applications is only available for command-line calls to OTB applications, and only for images output parameters. - -.. _extended-filenames: - diff --git a/Documentation/Cookbook/rst/index_TOC.rst b/Documentation/Cookbook/rst/index_TOC.rst index d09049ccec..12565d1577 100644 --- a/Documentation/Cookbook/rst/index_TOC.rst +++ b/Documentation/Cookbook/rst/index_TOC.rst @@ -8,6 +8,7 @@ Table of Contents Installation OTB-Applications Monteverdi + ExtendedFilenames Recipes Applications FAQ -- GitLab From ba9963ac6bd801df17114a3fe67e175dbb727011 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 7 Feb 2018 17:22:31 +0100 Subject: [PATCH 213/567] SuperBuild: rename patch with -all prefix --- ...-2-ext-num-literals.diff => shark-2-ext-num-literals-all.diff} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename SuperBuild/patches/SHARK/{shark-2-ext-num-literals.diff => shark-2-ext-num-literals-all.diff} (100%) diff --git a/SuperBuild/patches/SHARK/shark-2-ext-num-literals.diff b/SuperBuild/patches/SHARK/shark-2-ext-num-literals-all.diff similarity index 100% rename from SuperBuild/patches/SHARK/shark-2-ext-num-literals.diff rename to SuperBuild/patches/SHARK/shark-2-ext-num-literals-all.diff -- GitLab From fc7ccf556e0cf05502e2ec45abfe426e51b02a6b Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 8 Feb 2018 14:33:35 +0100 Subject: [PATCH 214/567] ENH : adding a method to remove observer WARNING : code not clean QtProgressBar::ClearObserver() --- .../QtWidget/include/itkQtProgressBar.h | 3 ++- .../otbWrapperQtWidgetSimpleProgressReport.h | 1 + .../QtWidget/src/itkQtProgressBar.cxx | 20 +++++++++++++++++++ ...otbWrapperQtWidgetSimpleProgressReport.cxx | 13 ++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Modules/Wrappers/QtWidget/include/itkQtProgressBar.h b/Modules/Wrappers/QtWidget/include/itkQtProgressBar.h index 5dd5b1b482..9e50a25914 100644 --- a/Modules/Wrappers/QtWidget/include/itkQtProgressBar.h +++ b/Modules/Wrappers/QtWidget/include/itkQtProgressBar.h @@ -52,10 +52,11 @@ public: void ProcessEvent(itk::Object * caller, const itk::EventObject & event ); void ConstProcessEvent(const itk::Object * caller, const itk::EventObject & event ); - /** Manage a Progress event */ void Observe( itk::Object *caller ); + void ClearObserver(); + signals: void SetValueChanged(int); diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetSimpleProgressReport.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetSimpleProgressReport.h index 3f5c4605bf..3a60401cd1 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetSimpleProgressReport.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetSimpleProgressReport.h @@ -61,6 +61,7 @@ public slots: void AddNewProcessToReport(); private: + void ClearEvent(); QtWidgetSimpleProgressReport(const QtWidgetSimpleProgressReport&); //purposely not implemented void operator=(const QtWidgetSimpleProgressReport&); //purposely not //implemented diff --git a/Modules/Wrappers/QtWidget/src/itkQtProgressBar.cxx b/Modules/Wrappers/QtWidget/src/itkQtProgressBar.cxx index ba8070ca0b..0f799d02a8 100644 --- a/Modules/Wrappers/QtWidget/src/itkQtProgressBar.cxx +++ b/Modules/Wrappers/QtWidget/src/itkQtProgressBar.cxx @@ -98,4 +98,24 @@ QtProgressBar::Observe( itk::Object *caller ) m_Caller->AddObserver( itk::ProgressEvent(), m_RedrawCommand.GetPointer() ); } +void +QtProgressBar::ClearObserver() +{ + if ( m_Caller->HasObserver(itk::ProgressEvent()) ) + { + unsigned int i(0); + while ( (m_Caller->GetCommand(i)) != (m_RedrawCommand.GetPointer()) ) + { + ++i; + if (i>10) + std::cout<<"ERROR"<<std::endl; + } + std::cout<<i<<std::endl; + m_Caller->RemoveObserver(i); + + } + m_Caller = nullptr; + // m_Caller->RemoveAllObservers(); +} + } // end namespace fltk diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx index c8347b23d9..d2ee555e8f 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx @@ -78,12 +78,24 @@ QtWidgetSimpleProgressReport::ProcessEvent( itk::Object * itkNotUsed(caller), if(eventToWatch) { m_CurrentProcess = eventToWatch->GetProcess(); + std::cout<<"process in the box : "<<m_CurrentProcess->GetNameOfClass()<<std::endl; m_CurrentDescription = eventToWatch->GetProcessDescription(); + std::cout<<"Description is : "<<m_CurrentDescription<<std::endl; emit AddNewProcessToReport(); } } } +void +QtWidgetSimpleProgressReport::ClearEvent() +{ + std::cout<<"Cleaning event"<<std::endl; + m_CurrentProcess = nullptr; + m_CurrentDescription = ""; + // emit AddNewProcessToReport(); + m_Bar->ClearObserver(); +} + void QtWidgetSimpleProgressReport::ReportProcess() { m_Bar->Observe(m_CurrentProcess); @@ -93,6 +105,7 @@ void QtWidgetSimpleProgressReport::ReportProcess() void QtWidgetSimpleProgressReport::Init() { + ClearEvent(); m_Bar->setValue(0); m_Label->setText("No process"); } -- GitLab From 3267b4afc9d573fb0158a50fb79997e7fd30e175 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 9 Feb 2018 10:53:05 +0100 Subject: [PATCH 215/567] ENH: remove unused flag DefaultValueMode --- .../include/otbWrapperParameter.h | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h index 236411f8f2..7f877f6a59 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h @@ -31,26 +31,6 @@ namespace otb { namespace Wrapper { -enum DefaultValueMode - { - /** - * This parameter has no default behaviour and should be set by - * the user. - */ - DefaultValueMode_UNKNOWN, - /** - * The default value of this parameter can be estimated from - * other parameters. - */ - DefaultValueMode_RELATIVE, - - /** - * The default value of this parameter is not depending on any - * other parameter. - */ - DefaultValueMode_ABSOLUTE - }; - /** \class Parameter * \brief This class represent a parameter for the wrapper framework @@ -123,12 +103,6 @@ public: /** Toogle the parameter AutomaticValue flag */ itkBooleanMacro(AutomaticValue); - /** Set the default value mode */ - itkSetEnumMacro(DefaultValueMode, DefaultValueMode); - - /** Get the default value mode */ - itkGetEnumMacro(DefaultValueMode, DefaultValueMode); - /** Set the user access level */ itkSetEnumMacro(UserLevel, UserLevel); @@ -223,7 +197,6 @@ protected: m_Active( false ), m_UserValue( false ), m_AutomaticValue( false ), - m_DefaultValueMode( DefaultValueMode_UNKNOWN ), m_UserLevel( UserLevel_Basic ), m_Role( Role_Input ), m_Root( this ), @@ -254,9 +227,6 @@ protected: /** True if the application change the value of this parameter */ bool m_AutomaticValue; - /** Default value behaviour */ - DefaultValueMode m_DefaultValueMode; - UserLevel m_UserLevel; /** Default iotype mode */ -- GitLab From ed6ee4da3df692039e2b176dfa5f8583d00ff779 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 9 Feb 2018 11:39:03 +0100 Subject: [PATCH 216/567] ENH: UserValue and AutomaticValue become 2 sides of the same coin --- .../include/otbWrapperParameter.h | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h index 7f877f6a59..1672561d81 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h @@ -94,14 +94,29 @@ public: /** Toogle the parameter mandatory flag */ itkBooleanMacro(Mandatory); - /** Set the parameter AutomaticValue flag */ - itkSetMacro(AutomaticValue, bool); + /** Set the parameter AutomaticValue flag (which is the opposite of UserValue)*/ + virtual void SetAutomaticValue(bool flag) + { + this->SetUserValue(!flag); + } /** Get the parameter AutomaticValue flag */ - itkGetConstMacro(AutomaticValue, bool); - - /** Toogle the parameter AutomaticValue flag */ - itkBooleanMacro(AutomaticValue); + virtual bool GetAutomaticValue() const + { + return !m_UserValue; + } + + /** Toogle ON the parameter AutomaticValue flag */ + void AutomaticValueOn() + { + this->SetAutomaticValue(true); + } + + /** Toogle OFF the parameter AutomaticValue flag */ + void AutomaticValueOff() + { + this->SetAutomaticValue(false); + } /** Set the user access level */ itkSetEnumMacro(UserLevel, UserLevel); @@ -196,7 +211,6 @@ protected: m_Mandatory( true ), m_Active( false ), m_UserValue( false ), - m_AutomaticValue( false ), m_UserLevel( UserLevel_Basic ), m_Role( Role_Input ), m_Root( this ), @@ -221,12 +235,9 @@ protected: /** True if activated (a mandatory parameter is always active) */ bool m_Active; - /** True if the value is set in user mode */ + /** True if the value is set in user mode (otherwise, it is an automatic value)*/ bool m_UserValue; - /** True if the application change the value of this parameter */ - bool m_AutomaticValue; - UserLevel m_UserLevel; /** Default iotype mode */ -- GitLab From e5e2b652108e7e111b46ba6ac6a188ecdc3804ff Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 9 Feb 2018 16:29:57 +0100 Subject: [PATCH 217/567] ENH: move the m_IsChecked flag to QtWidget --- .../include/otbWrapperParameter.h | 20 +---------- .../include/otbWrapperQtWidgetParameterBase.h | 19 ++++++++++ .../otbWrapperQtWidgetParameterGroup.h | 2 +- .../src/otbWrapperQtWidgetParameterBase.cxx | 6 ++-- .../src/otbWrapperQtWidgetParameterGroup.cxx | 36 ++++++++++--------- 5 files changed, 44 insertions(+), 39 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h index 1672561d81..5776138606 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h @@ -188,20 +188,6 @@ public: return m_ChildrenList; } - /** Store the state of the check box relative to this parameter (TO - * BE MOVED to QtWrapper Model ) - */ - virtual bool IsChecked() const - { - return m_IsChecked; - } - - /** Modify the state of the checkbox relative to this parameter */ - virtual void SetChecked(const bool value) - { - m_IsChecked = value; - } - protected: /** Constructor */ Parameter() : @@ -213,8 +199,7 @@ protected: m_UserValue( false ), m_UserLevel( UserLevel_Basic ), m_Role( Role_Input ), - m_Root( this ), - m_IsChecked( false ) + m_Root( this ) {} /** Destructor */ @@ -249,9 +234,6 @@ protected: /** List of children parameters */ std::vector<Parameter::Pointer > m_ChildrenList; - /** Store the status of the checkbox */ - bool m_IsChecked; - private: Parameter(const Parameter &); //purposely not implemented void operator =(const Parameter&); //purposely not implemented diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h index db88ca9ace..86b0eeed42 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h @@ -33,6 +33,8 @@ namespace otb namespace Wrapper { +class QtWidgetParameterGroup; + /** \class QtWidgetParameterBase * \brief * @@ -41,12 +43,26 @@ namespace Wrapper class OTBQtWidget_EXPORT QtWidgetParameterBase : public QWidget { Q_OBJECT + friend class QtWidgetParameterGroup; public: QtWidgetParameterBase( Parameter *, QtWidgetModel * ); ~QtWidgetParameterBase() ITK_OVERRIDE; void CreateWidget(); + /** Store the state of the check box relative to this parameter + */ + virtual bool IsChecked() const + { + return m_IsChecked; + } + + /** Modify the state of the checkbox relative to this parameter */ + virtual void SetChecked(const bool value) + { + m_IsChecked = value; + } + public slots: void UpdateGUI(); virtual void SetActivationState( bool value ); @@ -77,6 +93,9 @@ private: QtWidgetModel * m_Model; Parameter * m_Param; + + /** Store the status of the checkbox */ + bool m_IsChecked; }; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h index 3e3969739f..da70434fbf 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h @@ -59,7 +59,7 @@ private: void DoUpdateGUI() ITK_OVERRIDE; - virtual void ProcessChild(Parameter * currentNode, bool status); + virtual void ProcessChild(QObject* currentNode, bool status); ParameterGroup::Pointer m_ParamList; diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx index eb44e1a4ee..86789e4197 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx @@ -26,7 +26,9 @@ namespace Wrapper { QtWidgetParameterBase::QtWidgetParameterBase(Parameter * param, QtWidgetModel* m) - : m_Model(m), m_Param(param) + : m_Model(m) + , m_Param(param) + , m_IsChecked( false ) { } @@ -89,7 +91,7 @@ void QtWidgetParameterBase::SetActivationState( bool value ) } this->setEnabled(value); - m_Param->SetChecked(value); + this->SetChecked(value); m_Param->SetActive(value); } diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx index 12af047e28..b9ba4673cb 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx @@ -141,10 +141,10 @@ void QtWidgetParameterGroup::DoCreateWidget() group->setChecked(false); // Update iteratively the children status - for (unsigned int idx = 0; idx < param->GetChildrenList().size(); ++idx) + for (auto child : specificWidget->children()) { // deactivate the children tree - this->ProcessChild(param->GetChildrenList()[idx], false); + this->ProcessChild(child, false); } } else @@ -176,33 +176,35 @@ void QtWidgetParameterGroup::SetActivationState( bool value ) this->setEnabled(value); // Update iteratively the children status - for (unsigned int idx = 0; idx < m_ParamList->GetChildrenList().size(); ++idx) + for (auto child : this->children() ) { - this->ProcessChild(m_ParamList->GetChildrenList()[idx], value); + this->ProcessChild(child, value); } } // Activate iteratively the children -void QtWidgetParameterGroup::ProcessChild(Parameter* currentNode, bool status) +void QtWidgetParameterGroup::ProcessChild(QObject* currentNode, bool status) { // Activate the current node if it was checked - if ( currentNode->IsChecked() && status) + QtWidgetParameterBase* widgetBase = dynamic_cast<QtWidgetParameterBase*>(currentNode); + if(widgetBase) { - currentNode->SetActive(status); - } + if ( widgetBase->IsChecked() && status) + { + widgetBase->GetParam()->SetActive(status); + } - // If the status is false (deactivating) deactivate all the children - // tree - if (!status) - { - currentNode->SetActive(status); + // If the status is false (deactivating) deactivate all the children + // tree + if (!status) + { + widgetBase->GetParam()->SetActive(status); + } } - unsigned int counter = 0; - while(counter < currentNode->GetChildrenList().size()) + for (auto child : currentNode->children() ) { - this->ProcessChild(currentNode->GetChildrenList()[counter], status); - ++counter; + this->ProcessChild(child, status); } } -- GitLab From 84fb0fed21b4bf8c86d3ad5089e94babcbb8dac6 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 9 Feb 2018 16:38:32 +0100 Subject: [PATCH 218/567] TEST: adding test for output parameter --- .../ApplicationEngine/test/CMakeLists.txt | 6 ++ .../test/otbApplicationEngineTestDriver.cxx | 1 + .../otbWrapperOutputImageParameterTest.cxx | 59 ++++++++++++++++++- 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt index 860c867363..2018d29e92 100644 --- a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt @@ -171,6 +171,12 @@ otb_add_test(NAME owTvOutputImageParameter COMMAND otbApplicationEngineTestDrive "my description" ) +otb_add_test(NAME owTvOutputImageParameterConversion COMMAND otbApplicationEngineTestDriver + otbWrapperOutputImageParameterConversionTest + ${INPUTDATA}/poupees.tif + ${TEMP}/poupees_out.tif + ) + otb_add_test(NAME owTvDocExampleStructureTest COMMAND otbApplicationEngineTestDriver --compare-ascii ${NOTOL} ${BASELINE}/owTuDocExampleStructureTest.txt diff --git a/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx b/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx index f5b3aabf3d..17a6d631ba 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx +++ b/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx @@ -51,5 +51,6 @@ void RegisterTests() REGISTER_TEST(otbWrapperInputVectorDataParameterNew); REGISTER_TEST(otbWrapperOutputImageParameterNew); REGISTER_TEST(otbWrapperOutputImageParameterTest1); + REGISTER_TEST(otbWrapperOutputImageParameterConversionTest); REGISTER_TEST(otbApplicationMemoryConnectTest); } diff --git a/Modules/Wrappers/ApplicationEngine/test/otbWrapperOutputImageParameterTest.cxx b/Modules/Wrappers/ApplicationEngine/test/otbWrapperOutputImageParameterTest.cxx index 76d6c6056e..34cbb1d6f1 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbWrapperOutputImageParameterTest.cxx +++ b/Modules/Wrappers/ApplicationEngine/test/otbWrapperOutputImageParameterTest.cxx @@ -23,8 +23,10 @@ #endif #include "otbWrapperOutputImageParameter.h" +#include "otbWrapperInputImageParameter.h" #include "otbImageFileReader.h" #include "otbWrapperTypes.h" +#include <vector> int otbWrapperOutputImageParameterNew(int itkNotUsed(argc), char * itkNotUsed(argv)[]) { @@ -34,7 +36,6 @@ int otbWrapperOutputImageParameterNew(int itkNotUsed(argc), char * itkNotUsed(ar return EXIT_SUCCESS; } - int otbWrapperOutputImageParameterTest1(int itkNotUsed(argc), char* argv[]) { typedef otb::Wrapper::OutputImageParameter OutputImageParameterType; @@ -59,3 +60,59 @@ int otbWrapperOutputImageParameterTest1(int itkNotUsed(argc), char* argv[]) return EXIT_SUCCESS; } + + +template < typename ImageType > +void Cross( int p , std::string inputfilename, std::string outputfilename) +{ + otb::Wrapper::InputImageParameter::Pointer paramIn ( + otb::Wrapper::InputImageParameter::New() ); + paramIn->SetFromFileName( inputfilename ); + otb::Wrapper::OutputImageParameter::Pointer paramOut( + otb::Wrapper::OutputImageParameter::New() ); + paramOut->SetFileName( outputfilename ); + paramOut->SetImage(paramIn->GetImage<ImageType>()); + paramOut->InitializeWriters(); + paramOut->SetPixelType(static_cast<otb::Wrapper::ImagePixelType>(p)); + paramOut->Write(); +} + + +int otbWrapperOutputImageParameterConversionTest(int , char* argv[]) +{ + std::string filenamein = argv[1]; + std::string filenameout = argv[2] ; + std::string extension = filenameout.substr( filenameout.find_last_of('.') ); + + filenameout = filenameout.substr( 0 , filenameout.find_last_of('.') ); + + for ( int i = otb::Wrapper::ImagePixelType_uint8 ; i < 11 ; i++ ) + { + std::string type = + otb::Wrapper::OutputImageParameter::ConvertPixelTypeToString( + static_cast<otb::Wrapper::ImagePixelType>(i) ); + Cross< otb::Wrapper::UInt8ImageType > (i , filenamein , filenameout+"_UInt8_"+ type + extension ) ; + Cross< otb::Wrapper::Int16ImageType > ( i , filenamein , filenameout+"_Int16_"+ type + extension ) ; + Cross< otb::Wrapper::UInt16ImageType > ( i , filenamein , filenameout+"_UInt16_"+ type + extension ) ; + Cross< otb::Wrapper::Int32ImageType > ( i , filenamein , filenameout+"_Int21_"+ type + extension ) ; + Cross< otb::Wrapper::UInt32ImageType > ( i , filenamein , filenameout+"_UInt32_"+ type + extension ) ; + Cross< otb::Wrapper::FloatImageType > ( i , filenamein , filenameout+"_float_"+ type + extension ) ; + Cross< otb::Wrapper::DoubleImageType > ( i , filenamein , filenameout+"_double_"+ type + extension ) ; + Cross< otb::Wrapper::UInt8VectorImageType > ( i , filenamein , filenameout+"_UInt8Vect_"+ type + extension ) ; + Cross< otb::Wrapper::Int16VectorImageType > ( i , filenamein , filenameout+"_Int16Vect_"+ type + extension ) ; + Cross< otb::Wrapper::UInt16VectorImageType > ( i , filenamein , filenameout+"_UInt16Vect_"+ type + extension ) ; + Cross< otb::Wrapper::Int32VectorImageType > ( i , filenamein , filenameout+"_Int21Vect_"+ type + extension ) ; + Cross< otb::Wrapper::UInt32VectorImageType > ( i , filenamein , filenameout+"_UInt32Vect_"+ type + extension ) ; + Cross< otb::Wrapper::FloatVectorImageType > ( i , filenamein , filenameout+"_floatVect_"+ type + extension ) ; + Cross< otb::Wrapper::DoubleVectorImageType > ( i , filenamein , filenameout+"_doubleVect_"+ type + extension ) ; + Cross< otb::Wrapper::ComplexInt16ImageType > ( i , filenamein , filenameout+"_CInt16_"+ type + extension ) ; + Cross< otb::Wrapper::ComplexInt32ImageType > ( i , filenamein , filenameout+"_CInt32_"+ type + extension ) ; + Cross< otb::Wrapper::ComplexFloatImageType > ( i , filenamein , filenameout+"_Cfloat_"+ type + extension ) ; + Cross< otb::Wrapper::ComplexDoubleImageType > ( i , filenamein , filenameout+"_Cdouble_"+ type + extension ) ; + Cross< otb::Wrapper::ComplexInt16VectorImageType > ( i , filenamein , filenameout+"_CInt16Vect_"+ type + extension ) ; + Cross< otb::Wrapper::ComplexInt32VectorImageType > ( i , filenamein , filenameout+"_CInt32Vect_"+ type + extension ) ; + Cross< otb::Wrapper::ComplexFloatVectorImageType > ( i , filenamein , filenameout+"_CfloatVect_"+ type + extension ) ; + Cross< otb::Wrapper::ComplexDoubleVectorImageType > ( i , filenamein , filenameout+"_CdoubleVect_"+ type + extension ) ; + } + return 0; +} -- GitLab From 31fa2cd1df163de4d06831dd2fd4721a52821dbf Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 9 Feb 2018 17:59:39 +0100 Subject: [PATCH 219/567] ENH: add IsInPrivateDoFlag --- .../include/otbWrapperApplication.h | 7 +++++++ .../src/otbWrapperApplication.cxx | 18 ++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index f97134cbd1..65a8231b1c 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -212,6 +212,9 @@ public: bool GetParameterEmpty(std::string paramKey); /** Set HasUserValue flag of parameter with key paramKey + * Note that when this function is called from DoInit, DoUpdateParameters + * or DoExecute, it will always set this flag to false, because this is + * the core behavior of the application. */ void SetParameterUserValue(std::string paramKey, bool value); @@ -1022,6 +1025,10 @@ private: bool m_HaveInXML; bool m_HaveOutXML; bool m_IsInXMLParsed; + + /** Flag is true when executing DoInit, DoUpdateParameters or DoExecute */ + bool m_IsInPrivateDo; + /** * Declare the class * - Wrapper::MapProjectionParametersHandler diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index cca32d50d3..b2d2706c87 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -65,7 +65,8 @@ Application::Application() m_Doclink(""), m_HaveInXML(true), m_HaveOutXML(true), - m_IsInXMLParsed(false) + m_IsInXMLParsed(false), + m_IsInPrivateDo(false) { // Don't call Init from the constructor, since it calls a virtual method ! m_Logger->SetName("Application.logger"); @@ -304,7 +305,14 @@ void Application::SetParameterUserValue(std::string paramKey, bool value) using Application::EnableParameter(); **/ EnableParameter(paramKey); - GetParameterByKey(paramKey)->SetUserValue(value); + if (m_IsInPrivateDo) + { + GetParameterByKey(paramKey)->SetUserValue(false); + } + else + { + GetParameterByKey(paramKey)->SetUserValue(value); + } } const Parameter* Application::GetParameterByKey(std::string name, bool follow) const @@ -320,7 +328,9 @@ void Application::Init() m_ParameterList = ParameterGroup::New(); //reset inXML parse checker in case if reinit-ing m_IsInXMLParsed = false; + m_IsInPrivateDo = true; this->DoInit(); + m_IsInPrivateDo = false; //rashad: global parameters. now used only for inxml and outxml if(this->GetHaveInXML()) @@ -352,7 +362,9 @@ void Application::UpdateParameters() } } } + m_IsInPrivateDo = true; this->DoUpdateParameters(); + m_IsInPrivateDo = false; } void Application::AfterExecuteAndWriteOutputs() @@ -387,7 +399,9 @@ int Application::Execute() itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->Initialize(); } + m_IsInPrivateDo = true; this->DoExecute(); + m_IsInPrivateDo = false; // Ensure that all output image parameter have called UpdateOutputInformation() for (auto it = paramList.begin(); it != paramList.end(); ++it) -- GitLab From 8f755e1f844005f211db6c1d8f04ac1ef126fc11 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 9 Feb 2018 18:54:25 +0100 Subject: [PATCH 220/567] BUG: #1507: rework the priority order in metadata loading --- .../OSSIMAdapters/src/otbImageKeywordlist.cxx | 55 ++----------------- .../IO/ImageIO/include/otbImageFileReader.txx | 25 +++++++-- 2 files changed, 25 insertions(+), 55 deletions(-) diff --git a/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx b/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx index 36550717ca..6063915cfb 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx @@ -287,60 +287,15 @@ ReadGeometryFromImage(const std::string& filename, bool checkRpcTag) } /**********************************************************/ - /* Third try : look for external geom file and RPC tags */ + /* Third try : look for RPC tags */ /**********************************************************/ - if (!hasMetaData) + if (!hasMetaData && checkRpcTag) { - // If still no metadata, try the ".geom" file - ossimFilename ossimGeomFile = ossimFilename(filename).setExtension(".geom"); - otb_kwl = ReadGeometryFromGEOMFile(ossimGeomFile); - - // also check any RPC tags - ImageKeywordlist rpc_kwl; - if (checkRpcTag) - { - rpc_kwl = ReadGeometryFromRPCTag(filename); - } - - if (otb_kwl.HasKey("type")) - { - // external geom has a "type" keyword - std::string geomType(otb_kwl.GetMetadataByKey("type")); - ossimProjection *testProj = ossimProjectionFactoryRegistry::instance() - ->createProjection(ossimString(geomType)); - if (dynamic_cast<ossimSensorModel*>(testProj)) - { - // "type" keyword corresponds to a sensor model : don't erase it - if (rpc_kwl.GetSize() > 0) - { - rpc_kwl.ClearMetadataByKey("type"); - } - - ossimKeywordlist ossim_test_kwl; - otb_kwl.convertToOSSIMKeywordlist(ossim_test_kwl); - testProj = ossimProjectionFactoryRegistry::instance() - ->createProjection(ossim_test_kwl); - if (testProj) - { - // external geom contains a valid sensor geometry - hasMetaData = true; - } - } - } + // check any RPC tags + otb_kwl = ReadGeometryFromRPCTag(filename); - // copy keywords found in RPC tags if the external geom is not valid - if (!hasMetaData && rpc_kwl.GetSize() > 0) + if (!otb_kwl.Empty()) { - const ImageKeywordlist::KeywordlistMap &kwlMap = rpc_kwl.GetKeywordlist(); - for (ImageKeywordlist::KeywordlistMap::const_iterator it = kwlMap.begin(); - it != kwlMap.end(); - ++it) - { - if (it->second != "") - { - otb_kwl.AddKey(it->first , it->second); - } - } hasMetaData = true; } } diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx index 98a37bf87b..8a6fe7a588 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.txx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx @@ -398,18 +398,33 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> { std::string lFileNameOssimKeywordlist = GetDerivedDatasetSourceFileName(m_FileName); + std::string extension = itksys::SystemTools::GetFilenameLastExtension(lFileNameOssimKeywordlist); + std::string attachedGeom = lFileNameOssimKeywordlist.substr( + 0, + lFileNameOssimKeywordlist.size() - extension.size()) + std::string(".geom"); // Update otb Keywordlist ImageKeywordlist otb_kwl; - if (!m_FilenameHelper->ExtGEOMFileNameIsSet()) + + // Case 1: external geom supplied through extended filename + if (m_FilenameHelper->ExtGEOMFileNameIsSet()) { - otb_kwl = ReadGeometryFromImage(lFileNameOssimKeywordlist,!m_FilenameHelper->GetSkipRpcTag()); - otbMsgDevMacro(<< "Loading internal kwl"); + otb_kwl = ReadGeometryFromGEOMFile(m_FilenameHelper->GetExtGEOMFileName()); + otbMsgDevMacro(<< "Loading external kwl"); } + // Case 2: attached geom (if present) + else if (itksys::SystemTools::FileExists(attachedGeom)) + { + otb_kwl = ReadGeometryFromGEOMFile(attachedGeom); + otbMsgDevMacro(<< "Loading attached kwl"); + } + // Case 3: find an ossimPluginProjection + // Case 4: find an ossimProjection + // Case 5: find RPC tags in TIF else { - otb_kwl = ReadGeometryFromGEOMFile(m_FilenameHelper->GetExtGEOMFileName()); - otbMsgDevMacro(<< "Loading external kwl"); + otb_kwl = ReadGeometryFromImage(lFileNameOssimKeywordlist,!m_FilenameHelper->GetSkipRpcTag()); + otbMsgDevMacro(<< "Loading internal kwl"); } // Don't add an empty ossim keyword list -- GitLab From 5fc45cb652091f7a0452bdb7056d66f095f7b6d6 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 12 Feb 2018 10:28:45 +0100 Subject: [PATCH 221/567] BUG: #1507: mention the external geom in otbMsgDevMacro --- Modules/IO/ImageIO/include/otbImageFileReader.txx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx index 8a6fe7a588..87cc50b6e3 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.txx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx @@ -410,7 +410,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> if (m_FilenameHelper->ExtGEOMFileNameIsSet()) { otb_kwl = ReadGeometryFromGEOMFile(m_FilenameHelper->GetExtGEOMFileName()); - otbMsgDevMacro(<< "Loading external kwl"); + otbMsgDevMacro(<< "Loading external kwl: "<< m_FilenameHelper->GetExtGEOMFileName()); } // Case 2: attached geom (if present) else if (itksys::SystemTools::FileExists(attachedGeom)) -- GitLab From 8bdc8adfba03274237031fe0f7b0e9e4ce4a85b6 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 6 Feb 2018 16:00:51 +0100 Subject: [PATCH 222/567] BUG: #1504: delete SRS after usage (cherry picked from commit 4b3cb3f738e26a4ebec5f509d1af5fee1ad222ba) --- .../include/otbPersistentSamplingFilterBase.txx | 12 +++++++++++- .../test/otbImageSampleExtractorFilterTest.cxx | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx index 2973a7a8a3..502438a0d2 100644 --- a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx +++ b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx @@ -265,6 +265,11 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage> } this->m_InMemoryOutputs.push_back(tmpContainer); } + + if (oSRS) + { + oSRS->Release(); + } } template <class TInputImage, class TMaskImage> @@ -734,7 +739,7 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage> } const unsigned int nbFeatThread = std::ceil(inLayer.GetFeatureCount(true) / (float) numberOfThreads); - assert(nbFeatThread > 0); + //assert(nbFeatThread > 0); OGRFeatureDefn &layerDefn = inLayer.GetLayerDefn(); ogr::Layer::const_iterator featIt = inLayer.begin(); @@ -807,6 +812,11 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage> OGRFieldDefn fieldDefn(layerDefn.GetFieldDefn(k)); outLayer.CreateField(fieldDefn); } + + if (oSRS) + { + oSRS->Release(); + } } // Add new fields diff --git a/Modules/Learning/Sampling/test/otbImageSampleExtractorFilterTest.cxx b/Modules/Learning/Sampling/test/otbImageSampleExtractorFilterTest.cxx index 138032ea73..414a773027 100644 --- a/Modules/Learning/Sampling/test/otbImageSampleExtractorFilterTest.cxx +++ b/Modules/Learning/Sampling/test/otbImageSampleExtractorFilterTest.cxx @@ -129,6 +129,7 @@ int otbImageSampleExtractorFilterUpdate(int argc, char* argv[]) output->CreateLayer( inLayer.GetName(), oSRS, inLayer.GetLayerDefn().GetGeomType()); + oSRS->Release(); otb::ogr::Layer dstLayer = output->GetLayer(0); OGRFieldDefn labelField(classFieldName.c_str(),OFTString); dstLayer.CreateField(labelField, true); -- GitLab From 599e815dbdeb17821789973180ed32a91d5dc850 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 12 Feb 2018 16:59:27 +0100 Subject: [PATCH 223/567] TEST: add test for ClampImageFilter --- .../ImageManipulation/test/CMakeLists.txt | 5 + .../test/otbClampImageFilter.cxx | 209 ++++++++++++++++++ .../test/otbImageManipulationTestDriver.cxx | 1 + 3 files changed, 215 insertions(+) diff --git a/Modules/Filtering/ImageManipulation/test/CMakeLists.txt b/Modules/Filtering/ImageManipulation/test/CMakeLists.txt index d8782e61ec..834a6d3da0 100644 --- a/Modules/Filtering/ImageManipulation/test/CMakeLists.txt +++ b/Modules/Filtering/ImageManipulation/test/CMakeLists.txt @@ -623,6 +623,11 @@ otb_add_test(NAME bfTvClampImageFilterTest COMMAND otbImageManipulationTestDrive ${TEMP}/bfTvClampImageFilterTest_Output.tif ) +otb_add_test(NAME bfTvClampImageFilterConversionTest COMMAND otbImageManipulationTestDriver + otbClampImageFilterConversionTest + ${INPUTDATA}/veryverySmallFSATSW.tif + ) + otb_add_test(NAME coTvConcatenateVectorImageFilter COMMAND otbImageManipulationTestDriver --compare-image ${NOTOL} ${BASELINE}/coConcatenateVectorImageFilterOutput1.hdr diff --git a/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx b/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx index 82deca5f4f..fa48af6d6e 100644 --- a/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx +++ b/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx @@ -21,10 +21,14 @@ #include "otbClampImageFilter.h" #include "otbImage.h" +#include "otbVectorImage.h" +#include <limits> #include "otbImageFileReader.h" #include "otbImageFileWriter.h" +#include "itkImageRegionConstIterator.h" + /** Pixel typedefs */ typedef double InputPixelType; typedef unsigned int OutputPixelType; @@ -65,3 +69,208 @@ int otbClampImageFilterTest(int itkNotUsed(argc), char* argv[]) return EXIT_SUCCESS; } + +template < class InImageType , class OutImageType > +typename OutImageType::Pointer +Cross ( std::string const & inputFileName ) +{ + typedef otb::ImageFileReader< InImageType > ReaderType; + typedef otb::ClampImageFilter< InImageType , OutImageType > ClampFilter; + typename ReaderType::Pointer reader ( ReaderType::New() ); + reader->SetFileName( inputFileName ); + typename ClampFilter::Pointer clamp ( ClampFilter::New() ); + clamp->SetInput( reader->GetOutput() ); + clamp->Update(); + return clamp->GetOutput(); +} + +typedef otb::VectorImage<double> ImageRefType; + +template <class ImageType > +bool +CompareImageReal( const ImageRefType::Pointer imRef , + const ImageType * im ) +{ + typedef typename ImageType::PixelType RealPixelType; + + RealPixelType min = std::numeric_limits< RealPixelType >::lowest(); + RealPixelType max = std::numeric_limits< RealPixelType >::max(); + auto itRef = itk::ImageRegionConstIterator< ImageRefType >( imRef , + imRef->GetLargestPossibleRegion() ); + auto it = itk::ImageRegionConstIterator< ImageType >( im , + im->GetLargestPossibleRegion() ); + itRef.GoToBegin(); + it.GoToBegin(); + RealPixelType val; + double ref; + while ( !it.IsAtEnd() ) + { + val = it.Get(); + ref = itRef.Get()[0]; + if ( ref > static_cast<double>( max ) && val != max ) + { + return false; + } + else if ( ref < static_cast<double>( min ) && val != min ) + { + return false; + } + else if ( ref != static_cast<double>( val ) ) + { + return false; + } + ++it; + ++itRef; + } + return true; +} + +template <class ImageType > +bool +CompareVectorReal( const ImageRefType::Pointer imRef , + const ImageType * im) +{ + typedef typename ImageType::InternalPixelType RealPixelType; + RealPixelType min = std::numeric_limits< RealPixelType >::lowest(); + RealPixelType max = std::numeric_limits< RealPixelType >::max(); + auto itRef = itk::ImageRegionConstIterator< ImageRefType >( imRef , + imRef->GetLargestPossibleRegion() ); + auto it = itk::ImageRegionConstIterator< ImageType >( im , + im->GetLargestPossibleRegion() ); + itRef.GoToBegin(); + it.GoToBegin(); + unsigned int nbChanel = im->GetNumberOfComponentsPerPixel (); + RealPixelType val; + double ref; + while ( !it.IsAtEnd() ) + { + for ( unsigned int i = 0 ; i < nbChanel ; i++ ) + { + val = it.Get()[i]; + ref = itRef.Get()[i]; + if ( ref > static_cast<double>( max ) && val != max ) + { + return false; + } + else if ( ref < static_cast<double>( min ) && val != min ) + { + return false; + } + else if ( ref != static_cast<double>( val ) ) + { + return false; + } + } + ++it; + ++itRef; + } + return true; +} + +template <class ImageType > +bool +CompareImageComplex( const ImageRefType::Pointer imageRef , + const ImageType * im ) +{ + typedef typename ImageType::PixelType ComplexType; + typedef typename ComplexType::value_type RealType; + + RealType min = std::numeric_limits< RealType >::lowest(); + RealType max = std::numeric_limits< RealType >::max(); + auto itRef = itk::ImageRegionConstIterator< ImageRefType >( imageRef , + imageRef->GetLargestPossibleRegion() ); + auto it = itk::ImageRegionConstIterator< ImageType >( im , + im->GetLargestPossibleRegion() ); + itRef.GoToBegin(); + it.GoToBegin(); + ComplexType val; + double reRef , imRef; + while ( !it.IsAtEnd() ) + { + val = it.Get(); + reRef = itRef.Get()[0]; + imRef = itRef.Get()[1]; + if ( ( reRef > static_cast<double>( max ) && val.real != max ) + || ( imRef > static_cast<double>( max ) && val.imag != max ) ) + { + return false; + } + else if ( ( reRef < static_cast<double>( min ) && val.real != min ) + || ( imRef < static_cast<double>( min ) && val.imag != min ) ) + { + return false; + } + else if ( reRef != static_cast<double>( val.real ) + || imRef != static_cast<double>( val.imag ) ) + { + return false; + } + ++it; + ++itRef; + } + return true; +} + +template <class ImageType > +bool +CompareVectorComplex( const ImageRefType::Pointer imageRef , + const ImageType * im ) +{ + typedef typename ImageType::InternalPixelType ComplexType; + typedef typename ComplexType::value_type RealType; + + RealType min = std::numeric_limits< RealType >::lowest(); + RealType max = std::numeric_limits< RealType >::max(); + auto itRef = itk::ImageRegionConstIterator< ImageRefType >( imageRef , + imageRef->GetLargestPossibleRegion() ); + auto it = itk::ImageRegionConstIterator< ImageType >( im , + im->GetLargestPossibleRegion() ); + itRef.GoToBegin(); + it.GoToBegin(); + unsigned int nbChanel = im->GetNumberOfComponentsPerPixel (); + ComplexType val; + double reRef , imRef; + while ( !it.IsAtEnd() ) + { + + for (unsigned int i = 0 ; i < nbChanel ; i++ ) + { + val = it.Get()[i]; + reRef = itRef.Get()[ 2 * i ]; + imRef = itRef.Get()[ 2 * i + 1 ]; + if ( ( reRef > static_cast<double>( max ) && val.real != max ) + || ( imRef > static_cast<double>( max ) && val.imag != max ) ) + { + return false; + } + else if ( ( reRef < static_cast<double>( min ) && val.real != min ) + || ( imRef < static_cast<double>( min ) && val.imag != min ) ) + { + return false; + } + else if ( reRef != static_cast<double>( val.real ) + || imRef != static_cast<double>( val.imag ) ) + { + return false; + } + } + ++it; + ++itRef; + } + return true; +} + +int otbClampImageFilterConversionTest(int itkNotUsed(argc), char* argv[]) +{ + typedef otb::ImageFileReader< ImageRefType > ReaderType; + ReaderType::Pointer reader ( ReaderType::New() ); + reader->SetFileName( argv[1] ); + reader->Update(); + ImageRefType::Pointer imageRef = reader->GetOutput(); + otb::VectorImage<int>::Pointer image = + Cross < otb::VectorImage< std::complex<float> > , otb::VectorImage<int> > ( argv[1] ); + bool test = CompareVectorReal < otb::VectorImage<int> >( imageRef , image ); + if (test) + return EXIT_SUCCESS; + return 42; +} diff --git a/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx b/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx index e35453dde0..c5b59f8ef2 100644 --- a/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx +++ b/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx @@ -85,6 +85,7 @@ void RegisterTests() REGISTER_TEST(otbMultiplyByScalarImageFilterTest); REGISTER_TEST(otbClampImageFilterNew); REGISTER_TEST(otbClampImageFilterTest); + REGISTER_TEST(otbClampImageFilterConversionTest); REGISTER_TEST(otbConcatenateVectorImageFilter); REGISTER_TEST(otbBinaryImageMinimalBoundingRegionCalculatorNew); REGISTER_TEST(otbVectorRescaleIntensityImageFilterNew); -- GitLab From f226633374810453df8c6bfc15aa2ec79782be8c Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 12 Feb 2018 17:18:37 +0100 Subject: [PATCH 224/567] ENH: remove user flag in SetParameterXXX calls (not needed anymore) --- .../app/otbDSFuzzyModelEstimation.cxx | 8 +- .../app/otbKMeansClassification.cxx | 42 +++---- .../app/otbMultiImageSamplingRate.cxx | 2 +- .../app/otbOGRLayerClassifier.cxx | 2 +- .../app/otbSampleExtraction.cxx | 2 +- .../app/otbSampleSelection.cxx | 2 +- .../app/otbTrainImagesClassifier.cxx | 2 +- .../app/otbTrainRegression.cxx | 2 +- .../app/otbVectorClassifier.cxx | 2 +- .../app/otbVectorDataDSValidation.cxx | 4 +- .../include/otbTrainBoost.txx | 8 +- .../include/otbTrainDecisionTree.txx | 14 +-- .../include/otbTrainGradientBoostedTree.txx | 8 +- .../include/otbTrainImagesBase.txx | 52 ++++----- .../AppClassification/include/otbTrainKNN.txx | 2 +- .../include/otbTrainLibSVM.txx | 12 +- .../include/otbTrainNeuralNetwork.txx | 22 ++-- .../include/otbTrainRandomForests.txx | 14 +-- .../AppClassification/include/otbTrainSVM.txx | 34 +++--- .../include/otbTrainSharkRandomForests.txx | 8 +- .../app/otbDimensionalityReduction.cxx | 8 +- .../app/otbDomainTransform.cxx | 4 +- .../AppFiltering/app/otbSmoothing.cxx | 2 +- .../app/otbHyperspectralUnmixing.cxx | 2 +- .../app/otbVertexComponentAnalysis.cxx | 2 +- .../AppImageUtils/app/otbColorMapping.cxx | 14 +-- .../AppImageUtils/app/otbCompareImages.cxx | 8 +- .../AppImageUtils/app/otbConvert.cxx | 2 +- .../AppImageUtils/app/otbDynamicConvert.cxx | 2 +- .../AppImageUtils/app/otbExtractROI.cxx | 108 +++++++++--------- .../AppImageUtils/app/otbManageNoData.cxx | 2 +- .../AppImageUtils/app/otbPixelValue.cxx | 2 +- .../AppImageUtils/app/otbQuicklook.cxx | 16 +-- .../AppImageUtils/app/otbReadImageInfo.cxx | 74 ++++++------ .../AppMathParserX/app/otbBandMathX.cxx | 2 +- .../app/otbOpticalCalibration.cxx | 20 ++-- .../app/otbConvertCartoToGeoPoint.cxx | 4 +- .../app/otbConvertSensorToGeoPoint.cxx | 8 +- .../app/otbGridBasedImageResampling.cxx | 2 +- .../app/otbObtainUTMZoneFromGeoPoint.cxx | 2 +- .../app/otbOrthoRectification.cxx | 60 +++++----- .../app/otbRigidTransformResample.cxx | 2 +- .../AppProjection/app/otbSuperimpose.cxx | 2 +- .../app/otbHooverCompareSegmentation.cxx | 8 +- .../AppSegmentation/app/otbSegmentation.cxx | 4 +- .../AppStereo/app/otbStereoFramework.cxx | 4 +- .../app/otbRasterization.cxx | 2 +- 47 files changed, 304 insertions(+), 304 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx b/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx index e6343bf4b9..ed07d2baf5 100644 --- a/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx +++ b/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx @@ -143,12 +143,12 @@ private: AddParameter(ParameterType_String, "cri", "Criterion"); SetParameterDescription("cri", "Dempster Shafer criterion (by default (belief+plausibility)/2)"); MandatoryOff("cri"); - SetParameterString("cri","((Belief + Plausibility)/2.)", false); + SetParameterString("cri","((Belief + Plausibility)/2.)"); AddParameter(ParameterType_Float,"wgt","Weighting"); SetParameterDescription("wgt","Coefficient between 0 and 1 to promote undetection or false detections (default 0.5)"); MandatoryOff("wgt"); - SetParameterFloat("wgt",0.5, false); + SetParameterFloat("wgt",0.5); AddParameter(ParameterType_InputFilename,"initmod","initialization model"); SetParameterDescription("initmod","Initialization model (xml file) to be used. If the xml initialization model is set, the descriptor list is not used (specified using the option -desclist)"); @@ -157,12 +157,12 @@ private: AddParameter(ParameterType_StringList, "desclist","Descriptor list"); SetParameterDescription("desclist","List of the descriptors to be used in the model (must be specified to perform an automatic initialization)"); MandatoryOff("desclist"); - SetParameterString("desclist","", false); + SetParameterString("desclist",""); AddParameter(ParameterType_Int,"maxnbit","Maximum number of iterations"); MandatoryOff("maxnbit"); SetParameterDescription("maxnbit","Maximum number of optimizer iteration (default 200)"); - SetParameterInt("maxnbit",200, false); + SetParameterInt("maxnbit",200); AddParameter(ParameterType_Empty,"optobs","Optimizer Observer"); SetParameterDescription("optobs","Activate the optimizer observer"); diff --git a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx index a5067bf9cd..2c7fe5c840 100644 --- a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx +++ b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx @@ -148,7 +148,7 @@ protected: void ComputeImageEnvelope(const std::string &vectorFileName) { - GetInternalApplication("imgenvelop")->SetParameterString("out", vectorFileName, false); + GetInternalApplication("imgenvelop")->SetParameterString("out", vectorFileName); GetInternalApplication("imgenvelop")->ExecuteAndWriteOutput(); } @@ -187,8 +187,8 @@ protected: { std::vector<std::string> fieldList = {fieldName}; - GetInternalApplication("polystats")->SetParameterStringList("field", fieldList, false); - GetInternalApplication("polystats")->SetParameterString("out", statisticsFileName, false); + GetInternalApplication("polystats")->SetParameterStringList("field", fieldList); + GetInternalApplication("polystats")->SetParameterString("out", statisticsFileName); ExecuteInternal("polystats"); } @@ -199,17 +199,17 @@ protected: int NBSamples) { /* SampleSelection */ - GetInternalApplication("select")->SetParameterString("out", sampleFileName, false); + GetInternalApplication("select")->SetParameterString("out", sampleFileName); UpdateInternalParameters("select"); - GetInternalApplication("select")->SetParameterString("instats", statisticsFileName, false); - GetInternalApplication("select")->SetParameterString("field", fieldName, false); + GetInternalApplication("select")->SetParameterString("instats", statisticsFileName); + GetInternalApplication("select")->SetParameterString("field", fieldName); - GetInternalApplication("select")->SetParameterString("strategy", "constant", false); - GetInternalApplication("select")->SetParameterInt("strategy.constant.nb", NBSamples, false); + GetInternalApplication("select")->SetParameterString("strategy", "constant"); + GetInternalApplication("select")->SetParameterInt("strategy.constant.nb", NBSamples); if( IsParameterEnabled("rand")) - GetInternalApplication("select")->SetParameterInt("rand", GetParameterInt("rand"), false); + GetInternalApplication("select")->SetParameterInt("rand", GetParameterInt("rand")); // select sample positions ExecuteInternal("select"); @@ -217,8 +217,8 @@ protected: /* SampleExtraction */ UpdateInternalParameters("extraction"); - GetInternalApplication("extraction")->SetParameterString("outfield", "prefix", false); - GetInternalApplication("extraction")->SetParameterString("outfield.prefix.name", "value_", false); + GetInternalApplication("extraction")->SetParameterString("outfield", "prefix"); + GetInternalApplication("extraction")->SetParameterString("outfield.prefix.name", "value_"); // extract sample descriptors GetInternalApplication("extraction")->ExecuteAndWriteOutput(); @@ -229,7 +229,7 @@ protected: const std::string &modelFileName) { std::vector<std::string> extractOutputList = {sampleTrainFileName}; - GetInternalApplication("training")->SetParameterStringList("io.vd", extractOutputList, false); + GetInternalApplication("training")->SetParameterStringList("io.vd", extractOutputList); UpdateInternalParameters("training"); // set field names @@ -242,19 +242,19 @@ protected: oss << i; selectedNames.push_back( selectPrefix + oss.str() ); } - GetInternalApplication("training")->SetParameterStringList("feat", selectedNames, false); + GetInternalApplication("training")->SetParameterStringList("feat", selectedNames); - GetInternalApplication("training")->SetParameterString("classifier", "sharkkm", false); + GetInternalApplication("training")->SetParameterString("classifier", "sharkkm"); GetInternalApplication("training")->SetParameterInt("classifier.sharkkm.maxiter", - GetParameterInt("maxit"), false); + GetParameterInt("maxit")); GetInternalApplication("training")->SetParameterInt("classifier.sharkkm.k", - GetParameterInt("nc"), false); + GetParameterInt("nc")); if( IsParameterEnabled("rand")) - GetInternalApplication("training")->SetParameterInt("rand", GetParameterInt("rand"), false); + GetInternalApplication("training")->SetParameterInt("rand", GetParameterInt("rand")); GetInternalApplication("training")->GetParameterByKey("v")->SetActive(false); - GetInternalApplication("training")->SetParameterString("io.out", modelFileName, false); + GetInternalApplication("training")->SetParameterString("io.out", modelFileName); ExecuteInternal( "training" ); otbAppLogINFO("output model : " << GetInternalApplication("training")->GetParameterString("io.out")); @@ -264,8 +264,8 @@ protected: const std::string &imagesStatsFileName) { std::vector<std::string> imageFileNameList = {imageFileName}; - GetInternalApplication("imgstats")->SetParameterStringList("il", imageFileNameList, false); - GetInternalApplication("imgstats")->SetParameterString("out", imagesStatsFileName, false); + GetInternalApplication("imgstats")->SetParameterStringList("il", imageFileNameList); + GetInternalApplication("imgstats")->SetParameterString("out", imagesStatsFileName); ExecuteInternal( "imgstats" ); otbAppLogINFO("image statistics file : " << GetInternalApplication("imgstats")->GetParameterString("out")); @@ -506,7 +506,7 @@ private: void UpdateKMPolygonClassStatisticsParameters(const std::string &vectorFileName) { - GetInternalApplication( "polystats" )->SetParameterString( "vec", vectorFileName, false ); + GetInternalApplication( "polystats" )->SetParameterString( "vec", vectorFileName); UpdateInternalParameters( "polystats" ); } diff --git a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx index 889e909cc5..85bed4e53b 100644 --- a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx +++ b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx @@ -164,7 +164,7 @@ private: SetParameterDescription("strategy.all","Take all samples"); // Default strategy : smallest - SetParameterString("strategy","smallest", false); + SetParameterString("strategy","smallest"); AddParameter(ParameterType_Choice, "mim", "Multi-Image Mode"); diff --git a/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx b/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx index eb58a7e0ac..a29b0bc527 100644 --- a/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx @@ -82,7 +82,7 @@ private: AddParameter(ParameterType_String,"cfield","Field containing the predicted class."); SetParameterDescription("cfield","Field containing the predicted class"); - SetParameterString("cfield","predicted", false); + SetParameterString("cfield","predicted"); // Doc example parameter settings SetDocExampleParameterValue("inshp", "vectorData.shp"); diff --git a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx index a9c2b07fbd..4c3d40b560 100644 --- a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx @@ -89,7 +89,7 @@ private: AddParameter(ParameterType_String, "outfield.prefix.name", "Output field prefix"); SetParameterDescription("outfield.prefix.name","Prefix used to form the field names that" "will contain the extracted values."); - SetParameterString("outfield.prefix.name", "value_", false); + SetParameterString("outfield.prefix.name", "value_"); AddChoice("outfield.list","Use the given name list"); SetParameterDescription("outfield.list","Use the given name list"); diff --git a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx index b41f20470f..cd3542db8e 100644 --- a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx @@ -200,7 +200,7 @@ private: SetParameterDescription("strategy.all","Take all samples"); // Default strategy : smallest - SetParameterString("strategy","smallest", false); + SetParameterString("strategy","smallest"); AddParameter(ParameterType_ListView, "field", "Field Name"); SetParameterDescription("field","Name of the field carrying the class name in the input vectors."); diff --git a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx index a76f81dce7..e17a4adb4e 100644 --- a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx @@ -217,7 +217,7 @@ private : void UpdatePolygonClassStatisticsParameters() { std::vector<std::string> vectorFileList = GetParameterStringList( "io.vd" ); - GetInternalApplication( "polystat" )->SetParameterString( "vec", vectorFileList[0], false ); + GetInternalApplication( "polystat" )->SetParameterString( "vec", vectorFileList[0]); UpdateInternalParameters( "polystat" ); } diff --git a/Modules/Applications/AppClassification/app/otbTrainRegression.cxx b/Modules/Applications/AppClassification/app/otbTrainRegression.cxx index 690d03da1d..9d22eb9d1a 100644 --- a/Modules/Applications/AppClassification/app/otbTrainRegression.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainRegression.cxx @@ -183,7 +183,7 @@ void DoInit() ITK_OVERRIDE SetParameterDescription( "sample.vtr" , "Ratio between training and validation samples (0.0 = all training, " "1.0 = all validation) (default = 0.5)."); - SetParameterFloat( "sample.vtr" , 0.5 , false ); + SetParameterFloat( "sample.vtr" , 0.5); Superclass::DoInit(); diff --git a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx index b8ecd88713..1a4d91215a 100644 --- a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx @@ -124,7 +124,7 @@ private: "Only geometries with this field available will be taken into account.\n" "The field is added either in the input file (if 'out' off) or in the output file.\n" "Caution, the 'cfield' must not exist in the input file if you are updating the file."); - SetParameterString("cfield","predicted", false); + SetParameterString("cfield","predicted"); AddParameter(ParameterType_ListView, "feat", "Field names to be calculated."); SetParameterDescription("feat","List of field names in the input vector data used as features for training. " diff --git a/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx b/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx index 11e75421ae..05ddb93a05 100644 --- a/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx @@ -87,12 +87,12 @@ private: AddParameter(ParameterType_String, "cri", "Criterion"); SetParameterDescription("cri", "Dempster Shafer criterion (by default (belief+plausibility)/2)"); MandatoryOff("cri"); - SetParameterString("cri", "((Belief + Plausibility)/2.)", false); + SetParameterString("cri", "((Belief + Plausibility)/2.)"); AddParameter(ParameterType_Float, "thd", "Criterion threshold"); SetParameterDescription("thd", "Criterion threshold (default 0.5)"); MandatoryOff("thd"); - SetParameterFloat("thd",0.5, false); + SetParameterFloat("thd",0.5); AddParameter(ParameterType_OutputVectorData, "out", "Output Vector Data"); SetParameterDescription("out", "Output VectorData containing only the validated samples"); diff --git a/Modules/Applications/AppClassification/include/otbTrainBoost.txx b/Modules/Applications/AppClassification/include/otbTrainBoost.txx index 46cbbbd125..f971a2a629 100644 --- a/Modules/Applications/AppClassification/include/otbTrainBoost.txx +++ b/Modules/Applications/AppClassification/include/otbTrainBoost.txx @@ -61,16 +61,16 @@ namespace Wrapper SetParameterDescription("classifier.boost.t.gentle", "A modified version of the Real Adaboost algorithm, using Newton stepping " "rather than exact optimization at each step."); - SetParameterString("classifier.boost.t", "real", false); + SetParameterString("classifier.boost.t", "real"); SetParameterDescription("classifier.boost.t", "Type of Boosting algorithm."); //Do not expose SplitCriteria //WeakCount AddParameter(ParameterType_Int, "classifier.boost.w", "Weak count"); - SetParameterInt("classifier.boost.w",100, false); + SetParameterInt("classifier.boost.w",100); SetParameterDescription("classifier.boost.w","The number of weak classifiers."); //WeightTrimRate AddParameter(ParameterType_Float, "classifier.boost.r", "Weight Trim Rate"); - SetParameterFloat("classifier.boost.r",0.95, false); + SetParameterFloat("classifier.boost.r",0.95); SetParameterDescription("classifier.boost.r", "A threshold between 0 and 1 used to save computational time. " "Samples with summary weight <= (1 - weight_trim_rate) do not participate in" @@ -78,7 +78,7 @@ namespace Wrapper "functionality."); //MaxDepth : Not sure that this parameter has to be exposed. AddParameter(ParameterType_Int, "classifier.boost.m", "Maximum depth of the tree"); - SetParameterInt("classifier.boost.m",1, false); + SetParameterInt("classifier.boost.m",1); SetParameterDescription("classifier.boost.m","Maximum depth of the tree."); } diff --git a/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx b/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx index 9803a91a7a..bfedec3306 100644 --- a/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx +++ b/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx @@ -40,9 +40,9 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxDepth AddParameter(ParameterType_Int, "classifier.dt.max", "Maximum depth of the tree"); #ifdef OTB_OPENCV_3 - SetParameterInt("classifier.dt.max",10, false); + SetParameterInt("classifier.dt.max",10); #else - SetParameterInt("classifier.dt.max",65535, false); + SetParameterInt("classifier.dt.max",65535); #endif SetParameterDescription("classifier.dt.max", "The training algorithm attempts to split each node while its depth is smaller " @@ -51,14 +51,14 @@ LearningApplicationBase<TInputValue,TOutputValue> //MinSampleCount AddParameter(ParameterType_Int, "classifier.dt.min", "Minimum number of samples in each node"); - SetParameterInt("classifier.dt.min",10, false); + SetParameterInt("classifier.dt.min",10); SetParameterDescription("classifier.dt.min", "If the number of samples in a node is smaller " "than this parameter, then this node will not be split."); //RegressionAccuracy AddParameter(ParameterType_Float, "classifier.dt.ra", "Termination criteria for regression tree"); - SetParameterFloat("classifier.dt.ra",0.01, false); + SetParameterFloat("classifier.dt.ra",0.01); SetParameterDescription("classifier.dt.ra", "If all absolute differences between an estimated value in a node " "and the values of the train samples in this node are smaller than this " @@ -72,7 +72,7 @@ LearningApplicationBase<TInputValue,TOutputValue> AddParameter(ParameterType_Int, "classifier.dt.cat", "Cluster possible values of a categorical variable into K <= cat clusters to find a " "suboptimal split"); - SetParameterInt("classifier.dt.cat",10, false); + SetParameterInt("classifier.dt.cat",10); SetParameterDescription("classifier.dt.cat", "Cluster possible values of a categorical variable into K <= cat clusters to find a " "suboptimal split."); @@ -81,9 +81,9 @@ LearningApplicationBase<TInputValue,TOutputValue> AddParameter(ParameterType_Int, "classifier.dt.f", "K-fold cross-validations"); #ifdef OTB_OPENCV_3 // disable cross validation by default (crash in opencv 3.2) - SetParameterInt("classifier.dt.f",0, false); + SetParameterInt("classifier.dt.f",0); #else - SetParameterInt("classifier.dt.f",10, false); + SetParameterInt("classifier.dt.f",10); #endif SetParameterDescription("classifier.dt.f", "If cv_folds > 1, then it prunes a tree with K-fold cross-validation where K " diff --git a/Modules/Applications/AppClassification/include/otbTrainGradientBoostedTree.txx b/Modules/Applications/AppClassification/include/otbTrainGradientBoostedTree.txx index 7f69ac9338..30a3fde157 100644 --- a/Modules/Applications/AppClassification/include/otbTrainGradientBoostedTree.txx +++ b/Modules/Applications/AppClassification/include/otbTrainGradientBoostedTree.txx @@ -52,7 +52,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //WeakCount AddParameter(ParameterType_Int, "classifier.gbt.w", "Number of boosting algorithm iterations"); - SetParameterInt("classifier.gbt.w",200, false); + SetParameterInt("classifier.gbt.w",200); SetParameterDescription( "classifier.gbt.w", "Number \"w\" of boosting algorithm iterations, with w*K being the total number of trees in " @@ -60,20 +60,20 @@ LearningApplicationBase<TInputValue,TOutputValue> //Shrinkage AddParameter(ParameterType_Float, "classifier.gbt.s", "Regularization parameter"); - SetParameterFloat("classifier.gbt.s",0.01, false); + SetParameterFloat("classifier.gbt.s",0.01); SetParameterDescription("classifier.gbt.s", "Regularization parameter."); //SubSamplePortion AddParameter(ParameterType_Float, "classifier.gbt.p", "Portion of the whole training set used for each algorithm iteration"); - SetParameterFloat("classifier.gbt.p",0.8, false); + SetParameterFloat("classifier.gbt.p",0.8); SetParameterDescription( "classifier.gbt.p", "Portion of the whole training set used for each algorithm iteration. The subset is generated randomly."); //MaxDepth AddParameter(ParameterType_Int, "classifier.gbt.max", "Maximum depth of the tree"); - SetParameterInt("classifier.gbt.max",3, false); + SetParameterInt("classifier.gbt.max",3); SetParameterDescription( "classifier.gbt.max", "The training algorithm attempts to split each node while its depth is smaller than the maximum " "possible depth of the tree. The actual depth may be smaller if the other termination criteria are met, and/or " diff --git a/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx b/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx index a646cea953..a1f4ca1c23 100644 --- a/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx +++ b/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx @@ -79,7 +79,7 @@ void TrainImagesBase::InitSampling() AddParameter( ParameterType_Float, "sample.vtr", "Training and validation sample ratio" ); SetParameterDescription( "sample.vtr", "Ratio between training and validation samples (0.0 = all training, 1.0 = " "all validation) (default = 0.5)." ); - SetParameterFloat( "sample.vtr", 0.5, false ); + SetParameterFloat( "sample.vtr", 0.5); SetMaximumParameterFloatValue( "sample.vtr", 1.0 ); SetMinimumParameterFloatValue( "sample.vtr", 0.0 ); @@ -160,8 +160,8 @@ void TrainImagesBase::ComputePolygonStatistics(FloatVectorImageListType *imageLi for( unsigned int i = 0; i < nbImages; i++ ) { GetInternalApplication( "polystat" )->SetParameterInputImage( "in", imageList->GetNthElement( i ) ); - GetInternalApplication( "polystat" )->SetParameterString( "vec", vectorFileNames[i], false ); - GetInternalApplication( "polystat" )->SetParameterString( "out", statisticsFileNames[i], false ); + GetInternalApplication( "polystat" )->SetParameterString( "vec", vectorFileNames[i]); + GetInternalApplication( "polystat" )->SetParameterString( "out", statisticsFileNames[i]); ExecuteInternal( "polystat" ); } } @@ -170,7 +170,7 @@ void TrainImagesBase::ComputePolygonStatistics(FloatVectorImageListType *imageLi TrainImagesBase::SamplingRates TrainImagesBase::ComputeFinalMaximumSamplingRates(bool dedicatedValidation) { SamplingRates rates; - GetInternalApplication( "rates" )->SetParameterString( "mim", "proportional", false ); + GetInternalApplication( "rates" )->SetParameterString( "mim", "proportional"); double vtr = GetParameterFloat( "sample.vtr" ); long mt = GetParameterInt( "sample.mt" ); long mv = GetParameterInt( "sample.mv" ); @@ -224,11 +224,11 @@ void TrainImagesBase::ComputeSamplingRate(const std::vector<std::string> &statis const std::string &ratesFileName, long maximum) { // Sampling rates - GetInternalApplication( "rates" )->SetParameterStringList( "il", statisticsFileNames, false ); - GetInternalApplication( "rates" )->SetParameterString( "out", ratesFileName, false ); + GetInternalApplication( "rates" )->SetParameterStringList( "il", statisticsFileNames); + GetInternalApplication( "rates" )->SetParameterString( "out", ratesFileName); if( GetParameterInt( "sample.bm" ) != 0 ) { - GetInternalApplication( "rates" )->SetParameterString( "strategy", "smallest", false ); + GetInternalApplication( "rates" )->SetParameterString( "strategy", "smallest"); } else { @@ -236,12 +236,12 @@ void TrainImagesBase::ComputeSamplingRate(const std::vector<std::string> &statis { std::ostringstream oss; oss << maximum; - GetInternalApplication( "rates" )->SetParameterString( "strategy", "constant", false ); - GetInternalApplication( "rates" )->SetParameterString( "strategy.constant.nb", oss.str(), false ); + GetInternalApplication( "rates" )->SetParameterString( "strategy", "constant"); + GetInternalApplication( "rates" )->SetParameterString( "strategy.constant.nb", oss.str()); } else { - GetInternalApplication( "rates" )->SetParameterString( "strategy", "all", false ); + GetInternalApplication( "rates" )->SetParameterString( "strategy", "all"); } } ExecuteInternal( "rates" ); @@ -251,9 +251,9 @@ void TrainImagesBase::TrainModel(FloatVectorImageListType *imageList, const std::vector<std::string> &sampleTrainFileNames, const std::vector<std::string> &sampleValidationFileNames) { - GetInternalApplication( "training" )->SetParameterStringList( "io.vd", sampleTrainFileNames, false ); + GetInternalApplication( "training" )->SetParameterStringList( "io.vd", sampleTrainFileNames); if( !sampleValidationFileNames.empty() ) - GetInternalApplication( "training" )->SetParameterStringList( "valid.vd", sampleValidationFileNames, false ); + GetInternalApplication( "training" )->SetParameterStringList( "valid.vd", sampleValidationFileNames); UpdateInternalParameters( "training" ); // set field names @@ -266,7 +266,7 @@ TrainImagesBase::TrainModel(FloatVectorImageListType *imageList, const std::vect oss << i; selectedNames.push_back( "value_" + oss.str() ); } - GetInternalApplication( "training" )->SetParameterStringList( "feat", selectedNames, false ); + GetInternalApplication( "training" )->SetParameterStringList( "feat", selectedNames); ExecuteInternal( "training" ); } @@ -276,38 +276,38 @@ void TrainImagesBase::SelectAndExtractSamples(FloatVectorImageType *image, std:: std::string selectedField) { GetInternalApplication( "select" )->SetParameterInputImage( "in", image ); - GetInternalApplication( "select" )->SetParameterString( "out", sampleFileName, false ); + GetInternalApplication( "select" )->SetParameterString( "out", sampleFileName); // Change the selection strategy based on selected sampling strategy switch( strategy ) { // case GEOMETRIC: -// GetInternalApplication( "select" )->SetParameterString( "sampler", "random", false ); -// GetInternalApplication( "select" )->SetParameterString( "strategy", "percent", false ); +// GetInternalApplication( "select" )->SetParameterString( "sampler", "random"); +// GetInternalApplication( "select" )->SetParameterString( "strategy", "percent"); // GetInternalApplication( "select" )->SetParameterFloat( "strategy.percent.p", -// GetParameterFloat( "sample.percent" ), false ); +// GetParameterFloat( "sample.percent" )); // break; case CLASS: default: - GetInternalApplication( "select" )->SetParameterString( "vec", vectorFileName, false ); - GetInternalApplication( "select" )->SetParameterString( "instats", statisticsFileName, false ); - GetInternalApplication( "select" )->SetParameterString( "sampler", "periodic", false ); + GetInternalApplication( "select" )->SetParameterString( "vec", vectorFileName); + GetInternalApplication( "select" )->SetParameterString( "instats", statisticsFileName); + GetInternalApplication( "select" )->SetParameterString( "sampler", "periodic"); GetInternalApplication( "select" )->SetParameterInt( "sampler.periodic.jitter", 50 ); - GetInternalApplication( "select" )->SetParameterString( "strategy", "byclass", false ); - GetInternalApplication( "select" )->SetParameterString( "strategy.byclass.in", ratesFileName, false ); + GetInternalApplication( "select" )->SetParameterString( "strategy", "byclass"); + GetInternalApplication( "select" )->SetParameterString( "strategy.byclass.in", ratesFileName); break; } // select sample positions ExecuteInternal( "select" ); - GetInternalApplication( "extraction" )->SetParameterString( "vec", sampleFileName, false ); + GetInternalApplication( "extraction" )->SetParameterString( "vec", sampleFileName); UpdateInternalParameters( "extraction" ); if( !selectedField.empty() ) - GetInternalApplication( "extraction" )->SetParameterString( "field", selectedField, false ); + GetInternalApplication( "extraction" )->SetParameterString( "field", selectedField); - GetInternalApplication( "extraction" )->SetParameterString( "outfield", "prefix", false ); - GetInternalApplication( "extraction" )->SetParameterString( "outfield.prefix.name", "value_", false ); + GetInternalApplication( "extraction" )->SetParameterString( "outfield", "prefix"); + GetInternalApplication( "extraction" )->SetParameterString( "outfield.prefix.name", "value_"); // extract sample descriptors ExecuteInternal( "extraction" ); diff --git a/Modules/Applications/AppClassification/include/otbTrainKNN.txx b/Modules/Applications/AppClassification/include/otbTrainKNN.txx index 2ff93632bc..71e02215db 100644 --- a/Modules/Applications/AppClassification/include/otbTrainKNN.txx +++ b/Modules/Applications/AppClassification/include/otbTrainKNN.txx @@ -39,7 +39,7 @@ namespace Wrapper //K parameter AddParameter(ParameterType_Int, "classifier.knn.k", "Number of Neighbors"); - SetParameterInt("classifier.knn.k",32, false); + SetParameterInt("classifier.knn.k",32); SetParameterDescription("classifier.knn.k","The number of neighbors to use."); if (this->m_RegressionFlag) diff --git a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx index 18b9f4d39a..e0ebcea32c 100644 --- a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx +++ b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx @@ -54,7 +54,7 @@ namespace Wrapper SetParameterDescription("classifier.libsvm.k.sigmoid", "The kernel is a hyperbolic tangente function of the vectors."); - SetParameterString("classifier.libsvm.k", "linear", false); + SetParameterString("classifier.libsvm.k", "linear"); SetParameterDescription("classifier.libsvm.k", "SVM Kernel Type."); AddParameter(ParameterType_Choice, "classifier.libsvm.m", "SVM Model Type"); SetParameterDescription("classifier.libsvm.m", "Type of SVM formulation."); @@ -67,7 +67,7 @@ namespace Wrapper "multiplier C is used "); AddChoice("classifier.libsvm.m.nusvr", "Nu Support Vector Regression"); - SetParameterString("classifier.libsvm.m", "epssvr", false); + SetParameterString("classifier.libsvm.m", "epssvr"); SetParameterDescription("classifier.libsvm.m.nusvr", "Same as the epsilon regression except that this time the bounded " "parameter nu is used instead of epsilon"); @@ -89,17 +89,17 @@ namespace Wrapper SetParameterDescription("classifier.libsvm.m.oneclass", "All the training data are from the same class, SVM builds a boundary " "that separates the class from the rest of the feature space."); - SetParameterString("classifier.libsvm.m", "csvc", false); + SetParameterString("classifier.libsvm.m", "csvc"); } AddParameter(ParameterType_Float, "classifier.libsvm.c", "Cost parameter C"); - SetParameterFloat("classifier.libsvm.c",1.0, false); + SetParameterFloat("classifier.libsvm.c",1.0); SetParameterDescription("classifier.libsvm.c", "SVM models have a cost parameter C (1 by default) to control the " "trade-off between training errors and forcing rigid margins."); AddParameter(ParameterType_Float, "classifier.libsvm.nu", "Cost parameter Nu"); - SetParameterFloat("classifier.libsvm.nu",0.5, false); + SetParameterFloat("classifier.libsvm.nu",0.5); SetParameterDescription("classifier.libsvm.nu", "Cost parameter Nu, in the range 0..1, the larger the value, " "the smoother the decision."); @@ -115,7 +115,7 @@ namespace Wrapper if (this->m_RegressionFlag) { AddParameter(ParameterType_Float, "classifier.libsvm.eps", "Epsilon"); - SetParameterFloat("classifier.libsvm.eps",1e-3, false); + SetParameterFloat("classifier.libsvm.eps",1e-3); SetParameterDescription("classifier.libsvm.eps", "The distance between feature vectors from the training set and " "the fitting hyper-plane must be less than Epsilon. For outliers" diff --git a/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx b/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx index 4081034a5f..33a4930ac4 100644 --- a/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx +++ b/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx @@ -52,7 +52,7 @@ LearningApplicationBase<TInputValue,TOutputValue> "take into account the magnitude of the partial derivative (coordinate " "of the gradient) but only its sign."); - SetParameterString("classifier.ann.t", "reg", false); + SetParameterString("classifier.ann.t", "reg"); SetParameterDescription("classifier.ann.t", "Type of training method for the multilayer perceptron (MLP) neural network."); @@ -73,7 +73,7 @@ LearningApplicationBase<TInputValue,TOutputValue> AddChoice("classifier.ann.f.ident", "Identity function"); AddChoice("classifier.ann.f.sig", "Symmetrical Sigmoid function"); AddChoice("classifier.ann.f.gau", "Gaussian function (Not completely supported)"); - SetParameterString("classifier.ann.f", "sig", false); + SetParameterString("classifier.ann.f", "sig"); SetParameterDescription("classifier.ann.f", "This function determine whether the output of the node is positive or not " "depending on the output of the transfert function."); @@ -81,21 +81,21 @@ LearningApplicationBase<TInputValue,TOutputValue> //Alpha AddParameter(ParameterType_Float, "classifier.ann.a", "Alpha parameter of the activation function"); - SetParameterFloat("classifier.ann.a",1., false); + SetParameterFloat("classifier.ann.a",1.); SetParameterDescription("classifier.ann.a", "Alpha parameter of the activation function (used only with sigmoid and gaussian functions)."); //Beta AddParameter(ParameterType_Float, "classifier.ann.b", "Beta parameter of the activation function"); - SetParameterFloat("classifier.ann.b",1., false); + SetParameterFloat("classifier.ann.b",1.); SetParameterDescription("classifier.ann.b", "Beta parameter of the activation function (used only with sigmoid and gaussian functions)."); //BackPropDWScale AddParameter(ParameterType_Float, "classifier.ann.bpdw", "Strength of the weight gradient term in the BACKPROP method"); - SetParameterFloat("classifier.ann.bpdw",0.1, false); + SetParameterFloat("classifier.ann.bpdw",0.1); SetParameterDescription("classifier.ann.bpdw", "Strength of the weight gradient term in the BACKPROP method. The " "recommended value is about 0.1."); @@ -103,7 +103,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //BackPropMomentScale AddParameter(ParameterType_Float, "classifier.ann.bpms", "Strength of the momentum term (the difference between weights on the 2 previous iterations)"); - SetParameterFloat("classifier.ann.bpms",0.1, false); + SetParameterFloat("classifier.ann.bpms",0.1); SetParameterDescription("classifier.ann.bpms", "Strength of the momentum term (the difference between weights on the 2 previous " "iterations). This parameter provides some inertia to smooth the random " @@ -113,14 +113,14 @@ LearningApplicationBase<TInputValue,TOutputValue> //RegPropDW0 AddParameter(ParameterType_Float, "classifier.ann.rdw", "Initial value Delta_0 of update-values Delta_{ij} in RPROP method"); - SetParameterFloat("classifier.ann.rdw",0.1, false); + SetParameterFloat("classifier.ann.rdw",0.1); SetParameterDescription("classifier.ann.rdw", "Initial value Delta_0 of update-values Delta_{ij} in RPROP method (default = 0.1)."); //RegPropDWMin AddParameter(ParameterType_Float, "classifier.ann.rdwm", "Update-values lower limit Delta_{min} in RPROP method"); - SetParameterFloat("classifier.ann.rdwm",1e-7, false); + SetParameterFloat("classifier.ann.rdwm",1e-7); SetParameterDescription("classifier.ann.rdwm", "Update-values lower limit Delta_{min} in RPROP method. It must be positive " "(default = 1e-7)."); @@ -139,20 +139,20 @@ LearningApplicationBase<TInputValue,TOutputValue> AddChoice("classifier.ann.term.all", "Max. iterations + Epsilon"); SetParameterDescription("classifier.ann.term.all", "Both termination criteria are used. Training stop at the first reached"); - SetParameterString("classifier.ann.term", "all", false); + SetParameterString("classifier.ann.term", "all"); SetParameterDescription("classifier.ann.term", "Termination criteria."); //Epsilon AddParameter(ParameterType_Float, "classifier.ann.eps", "Epsilon value used in the Termination criteria"); - SetParameterFloat("classifier.ann.eps",0.01, false); + SetParameterFloat("classifier.ann.eps",0.01); SetParameterDescription("classifier.ann.eps", "Epsilon value used in the Termination criteria."); //MaxIter AddParameter(ParameterType_Int, "classifier.ann.iter", "Maximum number of iterations used in the Termination criteria"); - SetParameterInt("classifier.ann.iter",1000, false); + SetParameterInt("classifier.ann.iter",1000); SetParameterDescription("classifier.ann.iter", "Maximum number of iterations used in the Termination criteria."); diff --git a/Modules/Applications/AppClassification/include/otbTrainRandomForests.txx b/Modules/Applications/AppClassification/include/otbTrainRandomForests.txx index f557731207..e19777a686 100644 --- a/Modules/Applications/AppClassification/include/otbTrainRandomForests.txx +++ b/Modules/Applications/AppClassification/include/otbTrainRandomForests.txx @@ -39,7 +39,7 @@ LearningApplicationBase<TInputValue,TOutputValue> "See complete documentation here \\url{http://docs.opencv.org/modules/ml/doc/random_trees.html}."); //MaxDepth AddParameter(ParameterType_Int, "classifier.rf.max", "Maximum depth of the tree"); - SetParameterInt("classifier.rf.max",5, false); + SetParameterInt("classifier.rf.max",5); SetParameterDescription( "classifier.rf.max", "The depth of the tree. A low value will likely underfit and conversely a high value will likely overfit. " @@ -47,14 +47,14 @@ LearningApplicationBase<TInputValue,TOutputValue> //MinSampleCount AddParameter(ParameterType_Int, "classifier.rf.min", "Minimum number of samples in each node"); - SetParameterInt("classifier.rf.min",10, false); + SetParameterInt("classifier.rf.min",10); SetParameterDescription( "classifier.rf.min", "If the number of samples in a node is smaller than this parameter, " "then the node will not be split. A reasonable value is a small percentage of the total data e.g. 1 percent."); //RegressionAccuracy AddParameter(ParameterType_Float, "classifier.rf.ra", "Termination Criteria for regression tree"); - SetParameterFloat("classifier.rf.ra",0., false); + SetParameterFloat("classifier.rf.ra",0.); SetParameterDescription("classifier.rf.ra", "If all absolute differences between an estimated value in a node " "and the values of the train samples in this node are smaller than this regression accuracy parameter, " "then the node will not be split."); @@ -66,7 +66,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxNumberOfCategories AddParameter(ParameterType_Int, "classifier.rf.cat", "Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split"); - SetParameterInt("classifier.rf.cat",10, false); + SetParameterInt("classifier.rf.cat",10); SetParameterDescription( "classifier.rf.cat", "Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split."); @@ -78,7 +78,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxNumberOfVariables AddParameter(ParameterType_Int, "classifier.rf.var", "Size of the randomly selected subset of features at each tree node"); - SetParameterInt("classifier.rf.var",0, false); + SetParameterInt("classifier.rf.var",0); SetParameterDescription( "classifier.rf.var", "The size of the subset of features, randomly selected at each tree node, that are used to find the best split(s). " @@ -87,7 +87,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxNumberOfTrees AddParameter(ParameterType_Int, "classifier.rf.nbtrees", "Maximum number of trees in the forest"); - SetParameterInt("classifier.rf.nbtrees",100, false); + SetParameterInt("classifier.rf.nbtrees",100); SetParameterDescription( "classifier.rf.nbtrees", "The maximum number of trees in the forest. Typically, the more trees you have, the better the accuracy. " @@ -97,7 +97,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //ForestAccuracy AddParameter(ParameterType_Float, "classifier.rf.acc", "Sufficient accuracy (OOB error)"); - SetParameterFloat("classifier.rf.acc",0.01, false); + SetParameterFloat("classifier.rf.acc",0.01); SetParameterDescription("classifier.rf.acc","Sufficient accuracy (OOB error)."); diff --git a/Modules/Applications/AppClassification/include/otbTrainSVM.txx b/Modules/Applications/AppClassification/include/otbTrainSVM.txx index ac9524faa2..71e1f38adf 100644 --- a/Modules/Applications/AppClassification/include/otbTrainSVM.txx +++ b/Modules/Applications/AppClassification/include/otbTrainSVM.txx @@ -42,14 +42,14 @@ namespace Wrapper { AddChoice("classifier.svm.m.epssvr", "Epsilon Support Vector Regression"); AddChoice("classifier.svm.m.nusvr", "Nu Support Vector Regression"); - SetParameterString("classifier.svm.m", "epssvr", false); + SetParameterString("classifier.svm.m", "epssvr"); } else { AddChoice("classifier.svm.m.csvc", "C support vector classification"); AddChoice("classifier.svm.m.nusvc", "Nu support vector classification"); AddChoice("classifier.svm.m.oneclass", "Distribution estimation (One Class SVM)"); - SetParameterString("classifier.svm.m", "csvc", false); + SetParameterString("classifier.svm.m", "csvc"); } AddParameter(ParameterType_Choice, "classifier.svm.k", "SVM Kernel Type"); AddChoice("classifier.svm.k.linear", "Linear"); @@ -57,22 +57,22 @@ namespace Wrapper AddChoice("classifier.svm.k.rbf", "Gaussian radial basis function"); AddChoice("classifier.svm.k.poly", "Polynomial"); AddChoice("classifier.svm.k.sigmoid", "Sigmoid"); - SetParameterString("classifier.svm.k", "linear", false); + SetParameterString("classifier.svm.k", "linear"); SetParameterDescription("classifier.svm.k", "SVM Kernel Type."); AddParameter(ParameterType_Float, "classifier.svm.c", "Cost parameter C"); - SetParameterFloat("classifier.svm.c",1.0, false); + SetParameterFloat("classifier.svm.c",1.0); SetParameterDescription("classifier.svm.c", "SVM models have a cost parameter C (1 by default) to control the trade-off" " between training errors and forcing rigid margins."); AddParameter(ParameterType_Float, "classifier.svm.nu", "Parameter nu of a SVM optimization problem (NU_SVC / ONE_CLASS)"); - SetParameterFloat("classifier.svm.nu",0.0, false); + SetParameterFloat("classifier.svm.nu",0.0); SetParameterDescription("classifier.svm.nu", "Parameter nu of a SVM optimization problem."); if (this->m_RegressionFlag) { AddParameter(ParameterType_Float, "classifier.svm.p", "Parameter epsilon of a SVM optimization problem (EPS_SVR)"); - SetParameterFloat("classifier.svm.p",1.0, false); + SetParameterFloat("classifier.svm.p",1.0); SetParameterDescription("classifier.svm.p", "Parameter epsilon of a SVM optimization problem (EPS_SVR)."); AddParameter(ParameterType_Choice, @@ -87,29 +87,29 @@ namespace Wrapper "Stops when either iteration or epsilon criteria is true"); AddParameter(ParameterType_Float, "classifier.svm.iter", "Maximum iteration"); - SetParameterFloat("classifier.svm.iter",1000, false); + SetParameterFloat("classifier.svm.iter",1000); SetParameterDescription("classifier.svm.iter", "Maximum number of iterations (corresponds to the termination criteria 'iter')."); AddParameter(ParameterType_Float, "classifier.svm.eps", "Epsilon accuracy threshold"); - SetParameterFloat("classifier.svm.eps",FLT_EPSILON, false); + SetParameterFloat("classifier.svm.eps",FLT_EPSILON); SetParameterDescription("classifier.svm.eps", "Epsilon accuracy (corresponds to the termination criteria 'eps')."); } AddParameter(ParameterType_Float, "classifier.svm.coef0", "Parameter coef0 of a kernel function (POLY / SIGMOID)"); - SetParameterFloat("classifier.svm.coef0",0.0, false); + SetParameterFloat("classifier.svm.coef0",0.0); SetParameterDescription("classifier.svm.coef0", "Parameter coef0 of a kernel function (POLY / SIGMOID)."); AddParameter(ParameterType_Float, "classifier.svm.gamma", "Parameter gamma of a kernel function (POLY / RBF / SIGMOID)"); - SetParameterFloat("classifier.svm.gamma",1.0, false); + SetParameterFloat("classifier.svm.gamma",1.0); SetParameterDescription("classifier.svm.gamma", "Parameter gamma of a kernel function (POLY / RBF / SIGMOID)."); AddParameter(ParameterType_Float, "classifier.svm.degree", "Parameter degree of a kernel function (POLY)"); - SetParameterFloat("classifier.svm.degree",1.0, false); + SetParameterFloat("classifier.svm.degree",1.0); SetParameterDescription("classifier.svm.degree", "Parameter degree of a kernel function (POLY)."); AddParameter(ParameterType_Empty, "classifier.svm.opt", @@ -237,15 +237,15 @@ namespace Wrapper SVMClassifier->Save(modelPath); // Update the displayed parameters in the GUI after the training process, for further use of them - SetParameterFloat("classifier.svm.c",static_cast<float> (SVMClassifier->GetOutputC()), false); - SetParameterFloat("classifier.svm.nu",static_cast<float> (SVMClassifier->GetOutputNu()), false); + SetParameterFloat("classifier.svm.c",static_cast<float> (SVMClassifier->GetOutputC())); + SetParameterFloat("classifier.svm.nu",static_cast<float> (SVMClassifier->GetOutputNu())); if (this->m_RegressionFlag) { - SetParameterFloat("classifier.svm.p",static_cast<float> (SVMClassifier->GetOutputP()), false); + SetParameterFloat("classifier.svm.p",static_cast<float> (SVMClassifier->GetOutputP())); } - SetParameterFloat("classifier.svm.coef0",static_cast<float> (SVMClassifier->GetOutputCoef0()), false); - SetParameterFloat("classifier.svm.gamma",static_cast<float> (SVMClassifier->GetOutputGamma()), false); - SetParameterFloat("classifier.svm.degree",static_cast<float> (SVMClassifier->GetOutputDegree()), false); + SetParameterFloat("classifier.svm.coef0",static_cast<float> (SVMClassifier->GetOutputCoef0())); + SetParameterFloat("classifier.svm.gamma",static_cast<float> (SVMClassifier->GetOutputGamma())); + SetParameterFloat("classifier.svm.degree",static_cast<float> (SVMClassifier->GetOutputDegree())); } } //end namespace wrapper diff --git a/Modules/Applications/AppClassification/include/otbTrainSharkRandomForests.txx b/Modules/Applications/AppClassification/include/otbTrainSharkRandomForests.txx index f2c2f97dc2..fa7ef6646a 100644 --- a/Modules/Applications/AppClassification/include/otbTrainSharkRandomForests.txx +++ b/Modules/Applications/AppClassification/include/otbTrainSharkRandomForests.txx @@ -43,7 +43,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxNumberOfTrees AddParameter(ParameterType_Int, "classifier.sharkrf.nbtrees", "Maximum number of trees in the forest"); - SetParameterInt("classifier.sharkrf.nbtrees",100, false); + SetParameterInt("classifier.sharkrf.nbtrees",100); SetParameterDescription( "classifier.sharkrf.nbtrees", "The maximum number of trees in the forest. Typically, the more trees you have, the better the accuracy. " @@ -53,7 +53,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //NodeSize AddParameter(ParameterType_Int, "classifier.sharkrf.nodesize", "Min size of the node for a split"); - SetParameterInt("classifier.sharkrf.nodesize",25, false); + SetParameterInt("classifier.sharkrf.nodesize",25); SetParameterDescription( "classifier.sharkrf.nodesize", "If the number of samples in a node is smaller than this parameter, " @@ -61,7 +61,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MTry AddParameter(ParameterType_Int, "classifier.sharkrf.mtry", "Number of features tested at each node"); - SetParameterInt("classifier.sharkrf.mtry",0, false); + SetParameterInt("classifier.sharkrf.mtry",0); SetParameterDescription( "classifier.sharkrf.mtry", "The number of features (variables) which will be tested at each node in " @@ -71,7 +71,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //OOB Ratio AddParameter(ParameterType_Float, "classifier.sharkrf.oobr", "Out of bound ratio"); - SetParameterFloat("classifier.sharkrf.oobr",0.66, false); + SetParameterFloat("classifier.sharkrf.oobr",0.66); SetParameterDescription("classifier.sharkrf.oobr", "Set the fraction of the original training dataset to use as the out of bag sample." "A good default value is 0.66. "); diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx index 686b78bb4c..c876a6983c 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx @@ -196,7 +196,7 @@ private: unsigned int nbComp = static_cast<unsigned int> (GetParameterInt("nbcomp")); if (nbComp > nbComponents) { - SetParameterInt("nbcomp",nbComponents, false); + SetParameterInt("nbcomp",nbComponents); otbAppLogINFO( << "number of selected components can't exceed image dimension : "<<nbComponents ); } @@ -206,14 +206,14 @@ private: if (this->GetParameterString("outinv").size()!= 0) { otbAppLogWARNING(<<"This application only provides the forward transform for the MAF method."); - this->SetParameterString("outinv", "", false); + this->SetParameterString("outinv", ""); } this->DisableParameter("outinv"); if (this->GetParameterString("outmatrix").size()!= 0) { otbAppLogWARNING(<<"No transformation matrix available for MAF method."); - this->SetParameterString("outmatrix", "", false); + this->SetParameterString("outmatrix", ""); } this->DisableParameter("outmatrix"); @@ -225,7 +225,7 @@ private: unsigned int nbComp = static_cast<unsigned int> (GetParameterInt("nbcomp")); if ((nbComp != 0) && (nbComp != nbComponents)) { - SetParameterInt("nbcomp",nbComponents, false); + SetParameterInt("nbcomp",nbComponents); otbAppLogINFO( << "all components are kept when using MAF filter method."); } diff --git a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx index 54dbe894f6..8aa359eca3 100644 --- a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx +++ b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx @@ -152,8 +152,8 @@ private: AddChoice("mode.wavelet.form.sym8", "SYMLET8"); // Default values for mode - SetParameterString("mode", "wavelet", false); - SetParameterString("mode.wavelet.form", "haar", false); + SetParameterString("mode", "wavelet"); + SetParameterString("mode.wavelet.form", "haar"); AddParameter(ParameterType_Choice,"direction", "Direction"); AddChoice("direction.forward", "Forward"); diff --git a/Modules/Applications/AppFiltering/app/otbSmoothing.cxx b/Modules/Applications/AppFiltering/app/otbSmoothing.cxx index a31dc93388..5f93a6b871 100644 --- a/Modules/Applications/AppFiltering/app/otbSmoothing.cxx +++ b/Modules/Applications/AppFiltering/app/otbSmoothing.cxx @@ -116,7 +116,7 @@ private: SetDefaultParameterInt( "type.anidif.nbiter" , 10 ); SetDefaultParameterInt( "type.anidif.conductance" , 1. ); - SetParameterString( "type" , "anidif" , false ); + SetParameterString( "type" , "anidif"); // Doc example parameter settings SetExampleComment( "Image smoothing using a mean filter." , 0 ); diff --git a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx index 8d510460a6..3a5032af1f 100644 --- a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx +++ b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx @@ -144,7 +144,7 @@ private: AddChoice("ua.mdmdnmf", "MDMDNMF"); SetParameterDescription("ua.mdmdnmf", "Minimum Dispersion Constrained Non Negative Matrix Factorization"); - SetParameterString("ua", "ucls", false); + SetParameterString("ua", "ucls"); // Doc example parameter settings SetDocExampleParameterValue("in", "cupriteSubHsi.tif"); SetDocExampleParameterValue("ie", "cupriteEndmembers.tif"); diff --git a/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx b/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx index c3b04df6a9..1dc286bb9c 100644 --- a/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx +++ b/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx @@ -80,7 +80,7 @@ private: AddParameter(ParameterType_Int, "ne", "Number of endmembers"); SetParameterDescription("ne","The number of endmembers to extract from the hyperspectral image."); - SetParameterInt("ne",1, false); + SetParameterInt("ne",1); MandatoryOn("ne"); AddParameter(ParameterType_OutputImage, "outendm", "Output Endmembers"); diff --git a/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx b/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx index ad8c68b614..d687767169 100644 --- a/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx +++ b/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx @@ -346,11 +346,11 @@ private: AddParameter(ParameterType_Float,"method.continuous.min","Mapping range lower value"); SetParameterDescription("method.continuous.min","Set the lower input value of the mapping range."); - SetParameterFloat("method.continuous.min",0., false); + SetParameterFloat("method.continuous.min",0.); AddParameter(ParameterType_Float,"method.continuous.max","Mapping range higher value"); SetParameterDescription("method.continuous.max","Set the higher input value of the mapping range."); - SetParameterFloat("method.continuous.max",255., false); + SetParameterFloat("method.continuous.max",255.); // Optimal LUT AddChoice("method.optimal","Compute an optimized look-up table"); @@ -359,7 +359,7 @@ private: "[color to label] Searching all the colors present in the image to compute a continuous label list"); AddParameter(ParameterType_Int,"method.optimal.background", "Background label"); SetParameterDescription("method.optimal.background","Value of the background label"); - SetParameterInt("method.optimal.background",0, false); + SetParameterInt("method.optimal.background",0); SetMinimumParameterIntValue("method.optimal.background", 0); SetMaximumParameterIntValue("method.optimal.background", 255); @@ -371,18 +371,18 @@ private: AddParameter(ParameterType_Float, "method.image.nodatavalue", "NoData value"); SetParameterDescription("method.image.nodatavalue","NoData value for each channel of the support image, which will not be handled in the LUT estimation. If NOT checked, ALL the pixel values of the support image will be handled in the LUT estimation."); MandatoryOff("method.image.nodatavalue"); - SetParameterFloat("method.image.nodatavalue",0, false); + SetParameterFloat("method.image.nodatavalue",0); DisableParameter("method.image.nodatavalue"); AddParameter(ParameterType_Int, "method.image.low", "lower quantile"); SetParameterDescription("method.image.low","lower quantile for image normalization"); MandatoryOff("method.image.low"); - SetParameterInt("method.image.low",2, false); + SetParameterInt("method.image.low",2); SetMinimumParameterIntValue("method.image.low", 0); SetMaximumParameterIntValue("method.image.low", 100); AddParameter(ParameterType_Int, "method.image.up", "upper quantile"); SetParameterDescription("method.image.up","upper quantile for image normalization"); MandatoryOff("method.image.up"); - SetParameterInt("method.image.up",2, false); + SetParameterInt("method.image.up",2); SetMinimumParameterIntValue("method.image.up", 0); SetMaximumParameterIntValue("method.image.up", 100); @@ -406,7 +406,7 @@ private: if (GetParameterInt("method")==1 || GetParameterInt("method")==3) { otbAppLogWARNING("Override method : use optimal"); - SetParameterInt("method",2, false); + SetParameterInt("method",2); } } } diff --git a/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx b/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx index 2d0d54c83c..d376e56b5c 100644 --- a/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx +++ b/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx @@ -225,10 +225,10 @@ private: otbAppLogINFO( << "PSNR: " << m_CompareFilter->GetPSNR() ); otbAppLogINFO( << "Number of Pixel different: " << m_CompareFilter->GetDiffCount() ); - SetParameterFloat( "mse",m_CompareFilter->GetMSE() , false); - SetParameterFloat( "mae",m_CompareFilter->GetMAE() , false); - SetParameterFloat( "psnr",m_CompareFilter->GetPSNR() , false); - SetParameterFloat( "count",m_CompareFilter->GetDiffCount() , false); + SetParameterFloat( "mse",m_CompareFilter->GetMSE()); + SetParameterFloat( "mae",m_CompareFilter->GetMAE()); + SetParameterFloat( "psnr",m_CompareFilter->GetPSNR()); + SetParameterFloat( "count",m_CompareFilter->GetDiffCount()); } diff --git a/Modules/Applications/AppImageUtils/app/otbConvert.cxx b/Modules/Applications/AppImageUtils/app/otbConvert.cxx index 621d48adb3..2a553a7680 100644 --- a/Modules/Applications/AppImageUtils/app/otbConvert.cxx +++ b/Modules/Applications/AppImageUtils/app/otbConvert.cxx @@ -120,7 +120,7 @@ private: AddChoice("type.none", "None"); AddChoice("type.linear", "Linear"); AddChoice("type.log2", "Log2"); - SetParameterString("type", "none", false); + SetParameterString("type", "none"); AddParameter(ParameterType_Float,"type.linear.gamma","Gamma correction factor"); SetParameterDescription("type.linear.gamma","Gamma correction factor"); diff --git a/Modules/Applications/AppImageUtils/app/otbDynamicConvert.cxx b/Modules/Applications/AppImageUtils/app/otbDynamicConvert.cxx index fa8b76c501..28d51f406e 100644 --- a/Modules/Applications/AppImageUtils/app/otbDynamicConvert.cxx +++ b/Modules/Applications/AppImageUtils/app/otbDynamicConvert.cxx @@ -124,7 +124,7 @@ private: SetParameterDescription("type", "Transfer function for the rescaling"); AddChoice("type.linear", "Linear"); AddChoice("type.log2", "Log2"); - SetParameterString("type", "linear", false); + SetParameterString("type", "linear"); AddParameter(ParameterType_Float,"type.linear.gamma", "Gamma correction factor"); diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index bd6a8d1583..6bbd121c89 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -267,8 +267,8 @@ private: // Update the sizes only if the user has not defined a size if (!HasUserValue("sizex") && !HasUserValue("sizey") ) { - SetParameterInt("sizex",largestRegion.GetSize()[0], false); - SetParameterInt("sizey",largestRegion.GetSize()[1], false); + SetParameterInt("sizex",largestRegion.GetSize()[0]); + SetParameterInt("sizey",largestRegion.GetSize()[1]); // Compute extent parameter with default sizex and sizey if ( GetParameterString( "mode" ) == "extent" && userExtent ) @@ -316,8 +316,8 @@ private: if(!this->CropRegionOfInterest()) { // Put the index of the ROI to origin and try to crop again - SetParameterInt("startx",0, false); - SetParameterInt("starty",0, false); + SetParameterInt("startx",0); + SetParameterInt("starty",0); this->CropRegionOfInterest(); } @@ -390,10 +390,10 @@ private: inImage->UpdateOutputInformation(); if (region.Crop(inImage->GetLargestPossibleRegion())) { - SetParameterInt("sizex",region.GetSize(0), HasUserValue("sizex")); - SetParameterInt("sizey",region.GetSize(1), HasUserValue("sizey")); - SetParameterInt("startx",region.GetIndex(0), HasUserValue("startx")); - SetParameterInt("starty",region.GetIndex(1), HasUserValue("starty")); + SetParameterInt("sizex",region.GetSize(0)); + SetParameterInt("sizey",region.GetSize(1)); + SetParameterInt("startx",region.GetIndex(0)); + SetParameterInt("starty",region.GetIndex(1)); return true; } } @@ -409,15 +409,15 @@ private: if (GetParameterString( "mode.extent.unit" ) == "pxl" ) { pixelValue = std::round( GetParameterFloat( "mode.extent.ulx" ) ); - SetParameterInt( "startx", pixelValue , true ); + SetParameterInt( "startx", pixelValue); pixelValue = std::round( GetParameterFloat( "mode.extent.lrx" ) \ - pixelValue ) + 1 ; - SetParameterInt( "sizex", pixelValue , true ); + SetParameterInt( "sizex", pixelValue); pixelValue = std::round( GetParameterFloat( "mode.extent.uly" ) ); - SetParameterInt( "starty", pixelValue , true ); + SetParameterInt( "starty", pixelValue); pixelValue = std::round( GetParameterFloat( "mode.extent.lry" ) \ - pixelValue ) + 1 ; - SetParameterInt( "sizey", pixelValue , true ); + SetParameterInt( "sizey", pixelValue); } else if( GetParameterString( "mode.extent.unit" ) == "phy" ) { @@ -432,11 +432,11 @@ private: inImage->TransformPhysicalPointToIndex(ulp,uli); inImage->TransformPhysicalPointToIndex(lrp,lri); - SetParameterInt( "startx", uli[0] , true ); - SetParameterInt( "starty", uli[1] , true ); + SetParameterInt( "startx", uli[0]); + SetParameterInt( "starty", uli[1]); - SetParameterInt( "sizex", lri[0] - uli[0] + 1, true ); - SetParameterInt( "sizey", lri[1] - uli[1] + 1, true ); + SetParameterInt( "sizex", lri[0] - uli[0] + 1); + SetParameterInt( "sizey", lri[1] - uli[1] + 1); } else if( GetParameterString( "mode.extent.unit" ) == "lonlat" ) @@ -458,11 +458,11 @@ private: inImage->TransformPhysicalPointToIndex(ulp_out,uli_out); inImage->TransformPhysicalPointToIndex(lrp_out,lri_out); - SetParameterInt( "startx", uli_out[0] , true ); - SetParameterInt( "starty", uli_out[1] , true ); + SetParameterInt( "startx", uli_out[0]); + SetParameterInt( "starty", uli_out[1]); - SetParameterInt( "sizex", lri_out[0] - uli_out[0] + 1, true ); - SetParameterInt( "sizey", lri_out[1] - uli_out[1] + 1, true ); + SetParameterInt( "sizex", lri_out[0] - uli_out[0] + 1); + SetParameterInt( "sizey", lri_out[1] - uli_out[1] + 1); } this->CropRegionOfInterest(); } @@ -477,22 +477,22 @@ private: lri[ 1 ] = largestRegion.GetSize()[1]; if ( GetParameterString( "mode.extent.unit" ) == "pxl" ) { - SetParameterFloat("mode.extent.ulx", uli[0] , false); - SetParameterFloat("mode.extent.uly", uli[1] , false); - SetParameterFloat("mode.extent.lrx", lri[0] , false); - SetParameterFloat("mode.extent.lry", lri[1] , false); + SetParameterFloat("mode.extent.ulx", uli[0]); + SetParameterFloat("mode.extent.uly", uli[1]); + SetParameterFloat("mode.extent.lrx", lri[0]); + SetParameterFloat("mode.extent.lry", lri[1]); } else if ( GetParameterString( "mode.extent.unit" ) == "phy" ) { itk::Point<float, 2> ulp, lrp; input->TransformIndexToPhysicalPoint(uli,ulp); - SetParameterFloat("mode.extent.ulx",ulp[0], false); - SetParameterFloat("mode.extent.uly",ulp[1], false); + SetParameterFloat("mode.extent.ulx",ulp[0]); + SetParameterFloat("mode.extent.uly",ulp[1]); input->TransformIndexToPhysicalPoint(lri,lrp); - SetParameterFloat("mode.extent.lrx",lrp[0], false); - SetParameterFloat("mode.extent.lry",lrp[1], false); + SetParameterFloat("mode.extent.lrx",lrp[0]); + SetParameterFloat("mode.extent.lry",lrp[1]); } else if ( GetParameterString( "mode.extent.unit" ) == "lonlat" ) { @@ -503,13 +503,13 @@ private: itk::Point<float, 2> ulp_in, lrp_in , ulp_out , lrp_out; input->TransformIndexToPhysicalPoint(uli,ulp_in); ulp_out = rsTransform->TransformPoint( ulp_in ); - SetParameterFloat( "mode.extent.ulx" , ulp_out[ 0 ] , false ); - SetParameterFloat( "mode.extent.uly" , ulp_out[ 1 ] , false ); + SetParameterFloat( "mode.extent.ulx" , ulp_out[ 0 ]); + SetParameterFloat( "mode.extent.uly" , ulp_out[ 1 ]); input->TransformIndexToPhysicalPoint( lri , lrp_in ); lrp_out = rsTransform->TransformPoint( lrp_in ); - SetParameterFloat( "mode.extent.lrx" , lrp_out[ 0 ] , false ); - SetParameterFloat( "mode.extent.lry" , lrp_out[ 1 ] , false ); + SetParameterFloat( "mode.extent.lrx" , lrp_out[ 0 ]); + SetParameterFloat( "mode.extent.lry" , lrp_out[ 1 ]); } } @@ -524,8 +524,8 @@ private: if ( GetParameterString( "mode.radius.unitr" ) == "pxl" ) { pixelValue = std::floor( 2 * GetParameterFloat( "mode.radius.r" ) ) + 1; - SetParameterInt( "sizey", pixelValue , true ); - SetParameterInt( "sizex", pixelValue , true ); + SetParameterInt( "sizey", pixelValue); + SetParameterInt( "sizex", pixelValue); } if ( GetParameterString( "mode.radius.unitr" ) == "phy" ) { @@ -564,8 +564,8 @@ private: { pixelValue = maxR; } - SetParameterInt( "sizey", 2 * pixelValue + 1 , true ); - SetParameterInt( "sizex", 2 * pixelValue + 1 , true ); + SetParameterInt( "sizey", 2 * pixelValue + 1); + SetParameterInt( "sizex", 2 * pixelValue + 1); } } @@ -579,9 +579,9 @@ private: if ( GetParameterString( "mode.radius.unitc" ) == "pxl" && size ) { pixelValue = std::round(GetParameterFloat( "mode.radius.cx" )); - SetParameterInt( "startx", pixelValue - radiusxi , true ); + SetParameterInt( "startx", pixelValue - radiusxi); pixelValue = std::round(GetParameterFloat( "mode.radius.cy" )); - SetParameterInt( "starty", pixelValue - radiusyi , true ); + SetParameterInt( "starty", pixelValue - radiusyi); } if ( GetParameterString( "mode.radius.unitc" ) == "phy" && size ) { @@ -593,8 +593,8 @@ private: bool isIn = inImage->TransformPhysicalPointToIndex( centerp , centeri ); if ( isIn ) { - SetParameterInt( "startx", centeri[0] - radiusxi , true ); - SetParameterInt( "starty", centeri[1] - radiusyi , true ); + SetParameterInt( "startx", centeri[0] - radiusxi); + SetParameterInt( "starty", centeri[1] - radiusyi); } } if ( GetParameterString( "mode.radius.unitc" ) == "lonlat" && size ) @@ -613,8 +613,8 @@ private: centeri_out ); if ( isIn ) { - SetParameterInt( "startx", centeri_out[0] - radiusxi , true ); - SetParameterInt( "starty", centeri_out[1] - radiusyi , true ); + SetParameterInt( "startx", centeri_out[0] - radiusxi); + SetParameterInt( "starty", centeri_out[1] - radiusyi); } } } @@ -636,7 +636,7 @@ private: if ( GetParameterString("mode.radius.unitr") == "pxl" ) { int rad = std::min( centeri[ 0 ], centeri[ 1 ] ); - SetParameterFloat( "mode.radius.r" , rad , false ); + SetParameterFloat( "mode.radius.r" , rad); } if ( GetParameterString("mode.radius.unitr") == "phy" ) { @@ -645,19 +645,19 @@ private: input->TransformIndexToPhysicalPoint(helpRxi,helpRxp); input->TransformIndexToPhysicalPoint(helpRyi,helpRyp); float rad = std::min( helpRxp[0] - helpRyp[0] , helpRyp[1] - helpRxp[1] ); - SetParameterFloat( "mode.radius.r" , rad , false ); + SetParameterFloat( "mode.radius.r" , rad); } if ( GetParameterString("mode.radius.unitc") == "pxl" ) { - SetParameterFloat( "mode.radius.cx" , centeri[0] , false ); - SetParameterFloat( "mode.radius.cy" , centeri[1] , false) ; + SetParameterFloat( "mode.radius.cx" , centeri[0]); + SetParameterFloat( "mode.radius.cy" , centeri[1]) ; } if ( GetParameterString("mode.radius.unitc") == "phy" ) { itk::Point<float, 2> centerp , helpRp; input->TransformIndexToPhysicalPoint(centeri,centerp); - SetParameterFloat( "mode.radius.cx" , centerp[0] , false ); - SetParameterFloat( "mode.radius.cy" , centerp[1] , false) ; + SetParameterFloat( "mode.radius.cx" , centerp[0]); + SetParameterFloat( "mode.radius.cy" , centerp[1]) ; } if ( GetParameterString("mode.radius.unitc") == "lonlat" ) { @@ -668,8 +668,8 @@ private: itk::Point<float, 2> centerp_in, centerp_out; input->TransformIndexToPhysicalPoint(centeri,centerp_in); centerp_out = rsTransform->TransformPoint( centerp_in ); - SetParameterFloat( "mode.radius.cx" , centerp_out[ 0 ] , false ); - SetParameterFloat( "mode.radius.cy" , centerp_out[ 1 ] , false ); + SetParameterFloat( "mode.radius.cx" , centerp_out[ 0 ]); + SetParameterFloat( "mode.radius.cy" , centerp_out[ 1 ]); } } @@ -755,10 +755,10 @@ private: lri[1] = std::max( std::max( uli_out[1] , uri_out[1] ) , std::max( lli_out[1] , lri_out[1] ) ); - SetParameterInt( "startx", uli[0] , false ); - SetParameterInt( "starty", uli[1] , false ); - SetParameterInt( "sizex", lri[0] - uli[0] , false ); - SetParameterInt( "sizey", lri[1] - uli[1] , false ); + SetParameterInt( "startx", uli[0]); + SetParameterInt( "starty", uli[1]); + SetParameterInt( "sizex", lri[0] - uli[0]); + SetParameterInt( "sizey", lri[1] - uli[1]); } } else if( HasValue( "mode.fit.im" ) && GetParameterString( "mode" ) == "fit" ) diff --git a/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx b/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx index 439ba05590..7a2c5820ba 100644 --- a/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx +++ b/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx @@ -112,7 +112,7 @@ private: SetParameterDescription("mode.apply.ndval","No Data value used according to the mask image"); SetDefaultParameterFloat("mode.apply.ndval", 0.0); - SetParameterString("mode","buildmask", false); + SetParameterString("mode","buildmask"); AddRAMParameter(); diff --git a/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx b/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx index 1bca9241ea..03f1351b8d 100644 --- a/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx +++ b/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx @@ -292,7 +292,7 @@ private: id.Fill(0); std::ostringstream oss; oss << extractor->GetOutput()->GetPixel(id); - SetParameterString("value", oss.str(), false); + SetParameterString("value", oss.str()); //Display image information in the dedicated logger otbAppLogINFO( << oss.str() ); } diff --git a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx index dd7134c620..b3b12a6efd 100644 --- a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx +++ b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx @@ -146,8 +146,8 @@ private: if (!HasUserValue("rsx") && !HasUserValue("rsy") ) { - SetParameterInt("rsx",largestRegion.GetSize()[0], false); - SetParameterInt("rsy",largestRegion.GetSize()[1], false); + SetParameterInt("rsx",largestRegion.GetSize()[0]); + SetParameterInt("rsy",largestRegion.GetSize()[1]); } // Put the limit of the index and the size relative the image @@ -168,8 +168,8 @@ private: if(!this->CropRegionOfInterest()) { // Put the index of the ROI to origin and try to crop again - SetParameterInt("rox",0, false); - SetParameterInt("roy",0, false); + SetParameterInt("rox",0); + SetParameterInt("roy",0); this->CropRegionOfInterest(); } } @@ -188,10 +188,10 @@ bool CropRegionOfInterest() { if (region.Crop(GetParameterImage("in")->GetLargestPossibleRegion())) { - SetParameterInt( "rsx", region.GetSize(0), HasUserValue("rsx") ); - SetParameterInt( "rsy", region.GetSize(1), HasUserValue("rsy") ); - SetParameterInt( "rox", region.GetIndex(0), HasUserValue("rox") ); - SetParameterInt( "roy", region.GetIndex(1), HasUserValue("roy") ); + SetParameterInt( "rsx", region.GetSize(0)); + SetParameterInt( "rsy", region.GetSize(1)); + SetParameterInt( "rox", region.GetIndex(0)); + SetParameterInt( "roy", region.GetIndex(1)); return true; } } diff --git a/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx b/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx index 74bb9c42da..71960d8aca 100644 --- a/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx +++ b/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx @@ -267,7 +267,7 @@ private: ImageMetadataInterfaceType::Pointer metadataInterface = ImageMetadataInterfaceFactory::CreateIMI(inImage->GetMetaDataDictionary()); //Get number of bands - SetParameterInt("numberbands",inImage->GetNumberOfComponentsPerPixel(), false); + SetParameterInt("numberbands",inImage->GetNumberOfComponentsPerPixel()); ossOutput << "\tNumber of bands : " << GetParameterInt("numberbands") << std::endl; std::vector<bool> noDataValueAvailable; bool ret = itk::ExposeMetaData<std::vector<bool> >(inImage->GetMetaDataDictionary(),MetaDataKey::NoDataValueAvailable,noDataValueAvailable); @@ -298,26 +298,26 @@ private: ossOutput<<std::endl; //Get image size - SetParameterInt("indexx",inImage->GetLargestPossibleRegion().GetIndex()[0], false); - SetParameterInt("indexy",inImage->GetLargestPossibleRegion().GetIndex()[1], false); + SetParameterInt("indexx",inImage->GetLargestPossibleRegion().GetIndex()[0]); + SetParameterInt("indexy",inImage->GetLargestPossibleRegion().GetIndex()[1]); ossOutput << "\tStart index : [" << GetParameterInt("indexx") << "," << GetParameterInt("indexy") << "]" << std::endl; //Get image size - SetParameterInt("sizex",inImage->GetLargestPossibleRegion().GetSize()[0], false); - SetParameterInt("sizey",inImage->GetLargestPossibleRegion().GetSize()[1], false); + SetParameterInt("sizex",inImage->GetLargestPossibleRegion().GetSize()[0]); + SetParameterInt("sizey",inImage->GetLargestPossibleRegion().GetSize()[1]); ossOutput << "\tSize : [" << GetParameterInt("sizex") << "," << GetParameterInt("sizey") << "]" << std::endl; //Get image origin - SetParameterFloat("originx",inImage->GetOrigin()[0], false); - SetParameterFloat("originy",inImage->GetOrigin()[1], false); + SetParameterFloat("originx",inImage->GetOrigin()[0]); + SetParameterFloat("originy",inImage->GetOrigin()[1]); ossOutput << "\tOrigin : [" << GetParameterFloat("originx") << "," << GetParameterFloat("originy") << "]" << std::endl; //Get image spacing - SetParameterFloat("spacingx",inImage->GetSignedSpacing()[0], false); - SetParameterFloat("spacingy",inImage->GetSignedSpacing()[1], false); + SetParameterFloat("spacingx",inImage->GetSignedSpacing()[0]); + SetParameterFloat("spacingy",inImage->GetSignedSpacing()[1]); ossOutput << "\tSpacing : [" << GetParameterFloat("spacingx") << "," << GetParameterFloat("spacingy") << "]" << std::endl; //Estimate ground spacing @@ -336,14 +336,14 @@ private: approxGroundSpacing = groundSpacing->EvaluateAtIndex(index); //Get image estimated ground spacing (in m) - SetParameterFloat("estimatedgroundspacingx",approxGroundSpacing[0], false); - SetParameterFloat("estimatedgroundspacingy",approxGroundSpacing[1], false); + SetParameterFloat("estimatedgroundspacingx",approxGroundSpacing[0]); + SetParameterFloat("estimatedgroundspacingy",approxGroundSpacing[1]); ossOutput << "\tEstimated ground spacing (in meters): [" << GetParameterFloat("estimatedgroundspacingx") << "," << GetParameterFloat("estimatedgroundspacingy") << "]" << std::endl; ossOutput << std::endl << "Image acquisition information:" << std::endl; - SetParameterString("sensor", metadataInterface->GetSensorID(), false); + SetParameterString("sensor", metadataInterface->GetSensorID()); ossOutput << "\tSensor : "; if (!GetParameterString("sensor").empty()) ossOutput << GetParameterString("sensor"); @@ -353,11 +353,11 @@ private: ossOutput << "\tImage identification number: "; if (metadataInterface->GetImageKeywordlist().HasKey("image_id")) { - SetParameterString("id", metadataInterface->GetImageKeywordlist().GetMetadataByKey("image_id"), false); + SetParameterString("id", metadataInterface->GetImageKeywordlist().GetMetadataByKey("image_id")); ossOutput << GetParameterString("id"); } ossOutput << std::endl; - SetParameterString("projectionref", metadataInterface->GetProjectionRef(), false); + SetParameterString("projectionref", metadataInterface->GetProjectionRef()); if (!GetParameterString("projectionref").empty()) ossOutput << "\tImage projection : " << GetParameterString("projectionref") << std::endl; @@ -381,7 +381,7 @@ private: osstime<<"0"; osstime<<metadataInterface->GetMinute(); osstime<<":00"; - SetParameterString("time", osstime.str(), false); + SetParameterString("time", osstime.str()); ossOutput << "\tAcquisition time : " << GetParameterString("time") << std::endl; } @@ -410,29 +410,29 @@ private: if( !coord2name->GetCountryName().empty() ) { - SetParameterString("country", coord2name->GetCountryName(), false); + SetParameterString("country", coord2name->GetCountryName()); ossOutput << "\tCountry : " << GetParameterString("country") << std::endl; } else - SetParameterString("country", "Not available", false); + SetParameterString("country", "Not available"); if( !coord2name->GetPlaceName().empty() ) { - SetParameterString("town", coord2name->GetPlaceName(), false); + SetParameterString("town", coord2name->GetPlaceName()); ossOutput << "\tTown : " << GetParameterString("town") << std::endl; } else - SetParameterString("town", "Not available", false); + SetParameterString("town", "Not available"); // Retrieve footprint - SetParameterFloat("ullat",ullat, false); - SetParameterFloat("ullon",ullon, false); - SetParameterFloat("urlat",urlat, false); - SetParameterFloat("urlon",urlon, false); - SetParameterFloat("lrlat",lrlat, false); - SetParameterFloat("lrlon",lrlon, false); - SetParameterFloat("lllat",lllat, false); - SetParameterFloat("lllon",lllon, false); + SetParameterFloat("ullat",ullat); + SetParameterFloat("ullon",ullon); + SetParameterFloat("urlat",urlat); + SetParameterFloat("urlon",urlon); + SetParameterFloat("lrlat",lrlat); + SetParameterFloat("lrlon",lrlon); + SetParameterFloat("lllat",lllat); + SetParameterFloat("lllon",lllon); ossOutput << std::endl << "Image footprint coordinates:" << std::endl; ossOutput << "\tUpper left corner (latitude, longitude) = [" << GetParameterFloat("ullat") << "," << GetParameterFloat("ullon") << "]" << std::endl; @@ -444,15 +444,15 @@ private: { } - SetParameterInt("rgb.r",metadataInterface->GetDefaultDisplay()[0], false); - SetParameterInt("rgb.g",metadataInterface->GetDefaultDisplay()[1], false); - SetParameterInt("rgb.b",metadataInterface->GetDefaultDisplay()[2], false); + SetParameterInt("rgb.r",metadataInterface->GetDefaultDisplay()[0]); + SetParameterInt("rgb.g",metadataInterface->GetDefaultDisplay()[1]); + SetParameterInt("rgb.b",metadataInterface->GetDefaultDisplay()[2]); ossOutput << std::endl << "Image default RGB composition:" << std::endl; ossOutput << "\t[R, G, B] = [" << GetParameterInt("rgb.r") << "," << GetParameterInt("rgb.g") << "," << GetParameterInt("rgb.b") << "]" << std::endl; - SetParameterInt("gcp.count",metadataInterface->GetGCPCount(), false); - SetParameterString("gcp.proj", metadataInterface->GetGCPProjection(), false); + SetParameterInt("gcp.count",metadataInterface->GetGCPCount()); + SetParameterString("gcp.proj", metadataInterface->GetGCPProjection()); ossOutput << std::endl << "Ground control points information:" << std::endl; ossOutput << "\tNumber of GCPs = " << GetParameterInt("gcp.count") << std::endl; @@ -481,16 +481,16 @@ private: ossOutput << "\t\tGround coordinates =" << gcp_geocoord.back() << std::endl; } - SetParameterStringList("gcp.ids", gcp_ids, false); - SetParameterStringList("gcp.imcoord", gcp_imcoord, false); - SetParameterStringList("gcp.geocoord", gcp_geocoord, false); - SetParameterStringList("gcp.info", gcp_infos, false); + SetParameterStringList("gcp.ids", gcp_ids); + SetParameterStringList("gcp.imcoord", gcp_imcoord); + SetParameterStringList("gcp.geocoord", gcp_geocoord); + SetParameterStringList("gcp.info", gcp_infos); if ( IsParameterEnabled("keywordlist") ) { std::ostringstream osskeywordlist; osskeywordlist<<metadataInterface->GetImageKeywordlist() << std::endl; - SetParameterString("keyword", osskeywordlist.str(), false); + SetParameterString("keyword", osskeywordlist.str()); ossOutput << std::endl << "Image OSSIM keywordlist (optional):" << std::endl; ossOutput << "\t" << GetParameterString("keyword") << std::endl; diff --git a/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx b/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx index 90a7f245a6..90be1a12b3 100644 --- a/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx +++ b/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx @@ -289,7 +289,7 @@ private: if (useContext) { // only set the first expression, 'ManyExpression' is disabled. - this->SetParameterString("exp",dummyFilter->GetExpression(0), false); + this->SetParameterString("exp",dummyFilter->GetExpression(0)); } } } diff --git a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx index 87e7dc310f..e282f5b7b4 100644 --- a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx +++ b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx @@ -197,7 +197,7 @@ private: AddChoice("level.toa", "Image to Top Of Atmosphere reflectance"); AddChoice("level.toatoim", "TOA reflectance to Image"); AddChoice("level.toc", "Image to Top Of Canopy reflectance (atmospheric corrections)"); - SetParameterString("level", "toa", false); + SetParameterString("level", "toa"); AddParameter(ParameterType_Empty, "milli", "Convert to milli reflectance"); SetParameterDescription("milli", "Flag to use milli-reflectance instead of reflectance.\n" @@ -429,21 +429,21 @@ private: ossOutput << "Acquisition Minute already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.minute",lImageMetadataInterface->GetMinute(), false); + SetParameterInt("acqui.minute",lImageMetadataInterface->GetMinute()); } if (HasUserValue("acqui.hour")) ossOutput << "Acquisition Hour already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.hour",lImageMetadataInterface->GetHour(), false); + SetParameterInt("acqui.hour",lImageMetadataInterface->GetHour()); } if (HasUserValue("acqui.day")) ossOutput << "Acquisition Day already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.day",lImageMetadataInterface->GetDay(), false); + SetParameterInt("acqui.day",lImageMetadataInterface->GetDay()); if (IsParameterEnabled("acqui.fluxnormcoeff")) DisableParameter("acqui.day"); } @@ -452,7 +452,7 @@ private: ossOutput << "Acquisition Month already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.month",lImageMetadataInterface->GetMonth(), false); + SetParameterInt("acqui.month",lImageMetadataInterface->GetMonth()); if (IsParameterEnabled("acqui.fluxnormcoeff")) DisableParameter("acqui.month"); } @@ -461,28 +461,28 @@ private: ossOutput << "Acquisition Year already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.year",lImageMetadataInterface->GetYear(), false); + SetParameterInt("acqui.year",lImageMetadataInterface->GetYear()); } if (HasUserValue("acqui.sun.elev")) ossOutput << "Acquisition Sun Elevation Angle already set by user: no overload" <<std::endl; else - SetParameterFloat("acqui.sun.elev",lImageMetadataInterface->GetSunElevation(), false); + SetParameterFloat("acqui.sun.elev",lImageMetadataInterface->GetSunElevation()); if (HasUserValue("acqui.sun.azim")) ossOutput << "Acquisition Sun Azimuth Angle already set by user: no overload" <<std::endl; else - SetParameterFloat("acqui.sun.azim",lImageMetadataInterface->GetSunAzimuth(), false); + SetParameterFloat("acqui.sun.azim",lImageMetadataInterface->GetSunAzimuth()); if (HasUserValue("acqui.view.elev")) ossOutput << "Acquisition Viewing Elevation Angle already set by user: no overload" <<std::endl; else - SetParameterFloat("acqui.view.elev",lImageMetadataInterface->GetSatElevation(), false); + SetParameterFloat("acqui.view.elev",lImageMetadataInterface->GetSatElevation()); if (HasUserValue("acqui.view.azim")) ossOutput << "Acquisition Viewing Azimuth Angle already set by user: no overload" <<std::endl; else - SetParameterFloat("acqui.view.azim",lImageMetadataInterface->GetSatAzimuth(), false); + SetParameterFloat("acqui.view.azim",lImageMetadataInterface->GetSatAzimuth()); // Set default value so that they are stored somewhere even if // they are overloaded by user values diff --git a/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx index dfecb742ea..088428ef66 100644 --- a/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx @@ -122,8 +122,8 @@ private: otbAppLogINFO( << std::setprecision(10) << "Geographic Point (Long, Lat) : (" << geoPoint[0] << ", " << geoPoint[1] << ")" ); - SetParameterFloat( "long",geoPoint[0] , false); - SetParameterFloat( "lat",geoPoint[1] , false); + SetParameterFloat( "long",geoPoint[0]); + SetParameterFloat( "lat",geoPoint[1]); } }; diff --git a/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx index 384c892f14..c7e6ee3619 100644 --- a/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx @@ -130,8 +130,8 @@ private: outputPoint = model->TransformPoint(point); // Set the value computed - SetParameterFloat("output.idx",outputPoint[0], false); - SetParameterFloat("output.idy",outputPoint[1], false); + SetParameterFloat("output.idx",outputPoint[0]); + SetParameterFloat("output.idy",outputPoint[1]); // Set the town and the neaerest city CoordinateToName::Pointer coord2name = CoordinateToName::New(); @@ -139,8 +139,8 @@ private: coord2name->SetLat(outputPoint[1]); coord2name->Evaluate(); - SetParameterString("output.town", coord2name->GetPlaceName(), false); - SetParameterString("output.country", coord2name->GetCountryName(), false); + SetParameterString("output.town", coord2name->GetPlaceName()); + SetParameterString("output.country", coord2name->GetCountryName()); } }; diff --git a/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx b/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx index 72c9073a53..750913f778 100644 --- a/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx +++ b/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx @@ -173,7 +173,7 @@ private: AddParameter(ParameterType_Radius, "interpolator.bco.radius", "Radius for bicubic interpolation"); SetParameterDescription("interpolator.bco.radius","This parameter allows controlling the size of the bicubic interpolation filter. If the target pixel size is higher than the input pixel size, increasing this parameter will reduce aliasing artifacts."); SetDefaultParameterInt("interpolator.bco.radius", 2); - SetParameterString("interpolator","bco", false); + SetParameterString("interpolator","bco"); AddRAMParameter(); diff --git a/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx index 37d0ec7b74..0cfa820b26 100644 --- a/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx @@ -93,7 +93,7 @@ private: { int utmZone = otb::Utils::GetZoneFromGeoPoint(GetParameterFloat("lon"), GetParameterFloat("lat")); - SetParameterInt("utm",utmZone, false); + SetParameterInt("utm",utmZone); } }; diff --git a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx index 3c91403e47..4c69b25151 100644 --- a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx +++ b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx @@ -274,28 +274,28 @@ private: // Fill the Gui with the computed parameters if (!HasUserValue("outputs.sizex")) - SetParameterInt("outputs.sizex",genericRSEstimator->GetOutputSize()[0], false); + SetParameterInt("outputs.sizex",genericRSEstimator->GetOutputSize()[0]); if (!HasUserValue("outputs.sizey")) - SetParameterInt("outputs.sizey",genericRSEstimator->GetOutputSize()[1], false); + SetParameterInt("outputs.sizey",genericRSEstimator->GetOutputSize()[1]); if (!HasUserValue("outputs.spacingx")) - SetParameterFloat("outputs.spacingx",genericRSEstimator->GetOutputSpacing()[0], false); + SetParameterFloat("outputs.spacingx",genericRSEstimator->GetOutputSpacing()[0]); if (!HasUserValue("outputs.spacingy")) - SetParameterFloat("outputs.spacingy",genericRSEstimator->GetOutputSpacing()[1], false); + SetParameterFloat("outputs.spacingy",genericRSEstimator->GetOutputSpacing()[1]); if (!HasUserValue("outputs.ulx")) - SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0], false); + SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0]); if (!HasUserValue("outputs.uly")) - SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1], false); + SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1]); if (!HasUserValue("outputs.lrx")) - SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); if (!HasUserValue("outputs.lry")) - SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); // Handle the spacing and size field following the mode // chose by the user @@ -336,8 +336,8 @@ private: MandatoryOff("outputs.ortho"); // Update lower right - SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); - SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); } break; case Mode_AutomaticSize: @@ -382,16 +382,16 @@ private: genericRSEstimator->Compute(); // Set the processed size relative to this forced spacing - SetParameterInt("outputs.sizex",genericRSEstimator->GetOutputSize()[0], false); - SetParameterInt("outputs.sizey",genericRSEstimator->GetOutputSize()[1], false); + SetParameterInt("outputs.sizex",genericRSEstimator->GetOutputSize()[0]); + SetParameterInt("outputs.sizey",genericRSEstimator->GetOutputSize()[1]); // Reset Origin to default - SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0], false); - SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1], false); + SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0]); + SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1]); // Update lower right - SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); - SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); } break; case Mode_AutomaticSpacing: @@ -436,16 +436,16 @@ private: genericRSEstimator->Compute(); // Set the processed spacing relative to this forced size - SetParameterFloat("outputs.spacingx",genericRSEstimator->GetOutputSpacing()[0], false); - SetParameterFloat("outputs.spacingy",genericRSEstimator->GetOutputSpacing()[1], false); + SetParameterFloat("outputs.spacingx",genericRSEstimator->GetOutputSpacing()[0]); + SetParameterFloat("outputs.spacingy",genericRSEstimator->GetOutputSpacing()[1]); // Reset Origin to default - SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0], false); - SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1], false); + SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0]); + SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1]); // Update lower right - SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); - SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); } break; @@ -489,9 +489,9 @@ private: // Set the processed size relative to this forced spacing if (vcl_abs(spacing[0]) > 0.0) - SetParameterInt("outputs.sizex",static_cast<int>(vcl_ceil((GetParameterFloat("outputs.lrx")-GetParameterFloat("outputs.ulx"))/spacing[0])), false); + SetParameterInt("outputs.sizex",static_cast<int>(vcl_ceil((GetParameterFloat("outputs.lrx")-GetParameterFloat("outputs.ulx"))/spacing[0]))); if (vcl_abs(spacing[1]) > 0.0) - SetParameterInt("outputs.sizey",static_cast<int>(vcl_ceil((GetParameterFloat("outputs.lry")-GetParameterFloat("outputs.uly"))/spacing[1])), false); + SetParameterInt("outputs.sizey",static_cast<int>(vcl_ceil((GetParameterFloat("outputs.lry")-GetParameterFloat("outputs.uly"))/spacing[1]))); } break; case Mode_OrthoFit: @@ -541,11 +541,11 @@ private: SetParameterInt("outputs.sizey",size[1]); SetParameterFloat("outputs.spacingx",spacing[0]); SetParameterFloat("outputs.spacingy",spacing[1]); - SetParameterFloat("outputs.ulx",orig[0] - 0.5 * spacing[0], false); - SetParameterFloat("outputs.uly",orig[1] - 0.5 * spacing[1], false); + SetParameterFloat("outputs.ulx",orig[0] - 0.5 * spacing[0]); + SetParameterFloat("outputs.uly",orig[1] - 0.5 * spacing[1]); // Update lower right - SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); - SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); } } break; @@ -591,11 +591,11 @@ private: // Use the smallest spacing (more precise grid) double optimalSpacing = std::min( vcl_abs(xgridspacing), vcl_abs(ygridspacing) ); otbAppLogINFO( "Setting grid spacing to " << optimalSpacing ); - SetParameterFloat("opt.gridspacing",optimalSpacing, false); + SetParameterFloat("opt.gridspacing",optimalSpacing); } else // if (m_OutputProjectionRef == otb::GeoInformationConversion::ToWKT(4326)) { - SetParameterFloat("opt.gridspacing",DefaultGridSpacingMeter, false); + SetParameterFloat("opt.gridspacing",DefaultGridSpacingMeter); } // if (m_OutputProjectionRef == otb::GeoInformationConversion::ToWKT(4326)) } // if (!HasUserValue("opt.gridspacing")) } // if (HasValue("io.in")) diff --git a/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx b/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx index 7b6da7d245..01a9d01124 100644 --- a/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx +++ b/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx @@ -159,7 +159,7 @@ private: AddParameter(ParameterType_Radius, "interpolator.bco.radius", "Radius for bicubic interpolation"); SetParameterDescription("interpolator.bco.radius","This parameter allows controlling the size of the bicubic interpolation filter. If the target pixel size is higher than the input pixel size, increasing this parameter will reduce aliasing artifacts."); SetDefaultParameterInt("interpolator.bco.radius", 2); - SetParameterString("interpolator","bco", false); + SetParameterString("interpolator","bco"); // RAM available AddRAMParameter("ram"); diff --git a/Modules/Applications/AppProjection/app/otbSuperimpose.cxx b/Modules/Applications/AppProjection/app/otbSuperimpose.cxx index 1d1018e8fc..2f5786587b 100644 --- a/Modules/Applications/AppProjection/app/otbSuperimpose.cxx +++ b/Modules/Applications/AppProjection/app/otbSuperimpose.cxx @@ -164,7 +164,7 @@ private: if(!HasUserValue("mode") && HasValue("inr") && HasValue("inm") && otb::PleiadesPToXSAffineTransformCalculator::CanCompute(GetParameterImage("inr"),GetParameterImage("inm"))) { otbAppLogWARNING("Forcing PHR mode with PHR data. You need to add \"-mode default\" to force the default mode with PHR images."); - SetParameterString("mode","phr", false); + SetParameterString("mode","phr"); } } diff --git a/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx index 48dd57c2ad..7588f4eb87 100644 --- a/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx @@ -297,10 +297,10 @@ private: m_InstanceFilter->Update(); - SetParameterFloat("rc",m_InstanceFilter->GetMeanRC(), false); - SetParameterFloat("rf",m_InstanceFilter->GetMeanRF(), false); - SetParameterFloat("ra",m_InstanceFilter->GetMeanRA(), false); - SetParameterFloat("rm",m_InstanceFilter->GetMeanRM(), false); + SetParameterFloat("rc",m_InstanceFilter->GetMeanRC()); + SetParameterFloat("rf",m_InstanceFilter->GetMeanRF()); + SetParameterFloat("ra",m_InstanceFilter->GetMeanRA()); + SetParameterFloat("rm",m_InstanceFilter->GetMeanRM()); } ImageToLabelMapFilterType::Pointer m_GTFilter; diff --git a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx index 5b3bfd2361..059ed278ae 100644 --- a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx @@ -311,11 +311,11 @@ private: AddParameter(ParameterType_String, "mode.vector.layername", "Layer name"); SetParameterDescription("mode.vector.layername", "Name of the layer in the vector file or database (default is Layer)."); - SetParameterString("mode.vector.layername", "layer", false); + SetParameterString("mode.vector.layername", "layer"); AddParameter(ParameterType_String, "mode.vector.fieldname", "Geometry index field name"); SetParameterDescription("mode.vector.fieldname", "Name of the field holding the geometry index in the output vector file or database."); - SetParameterString("mode.vector.fieldname", "DN", false); + SetParameterString("mode.vector.fieldname", "DN"); AddParameter(ParameterType_Int, "mode.vector.tilesize", "Tiles size"); SetParameterDescription("mode.vector.tilesize", diff --git a/Modules/Applications/AppStereo/app/otbStereoFramework.cxx b/Modules/Applications/AppStereo/app/otbStereoFramework.cxx index 279c09ad2f..a4f3705d58 100644 --- a/Modules/Applications/AppStereo/app/otbStereoFramework.cxx +++ b/Modules/Applications/AppStereo/app/otbStereoFramework.cxx @@ -368,7 +368,7 @@ private: "first and second image, a second couple with third and fourth image etc." " (in this case image list must be even)."); MandatoryOff("input.co"); - SetParameterString("input.co","", false); + SetParameterString("input.co",""); DisableParameter("input.co"); AddParameter(ParameterType_Int, "input.channel", "Input Image channel"); @@ -385,7 +385,7 @@ private: // // Build the Output Map Projection // for custom map projection MapProjectionParametersHandler::AddMapProjectionParameters(this, "map"); - SetParameterString("map","wgs", false); + SetParameterString("map","wgs"); AddParameter(ParameterType_Float, "output.res","Output resolution"); SetParameterDescription("output.res","Spatial sampling distance of the output elevation : the cell size (in m)"); diff --git a/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx b/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx index 748d8f27be..9ddef6c295 100644 --- a/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx +++ b/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx @@ -132,7 +132,7 @@ private: AddParameter(ParameterType_String,"mode.attribute.field","The attribute field to burn"); SetParameterDescription("mode.attribute.field","Name of the attribute field to burn"); - SetParameterString("mode.attribute.field","DN", false); + SetParameterString("mode.attribute.field","DN"); AddRAMParameter(); -- GitLab From 8df4eef2c7bf3db5fb2a73ed18d551000a0af916 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 13 Feb 2018 08:55:12 +0100 Subject: [PATCH 225/567] BUG: fix the case of an image as output --- .../include/otbConvertTypeFunctor.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h index f3cb4b0682..aa318c24ab 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h @@ -57,11 +57,14 @@ public: m_Scal = 2 * m_CompIn; else m_Scal = m_CompIn; - if ( m_cOutPix || m_cOutInternalPix ) - m_CompOut = ( sizeIn + 1 ) / 2 ; + if ( m_cOutInternalPix ) + m_CompOut = ( m_Scal + 1 ) / 2 ; else - m_CompOut = sizeIn ; - + m_CompOut = m_Scal ; + + if ( m_sOutPix || m_cOutPix ) + m_CompOut = 1; + return m_CompOut ; } @@ -87,8 +90,10 @@ public: m_cInPix = boost::is_complex < InputPixelType > :: value ; m_cOutPix = boost::is_complex < OutputPixelType > :: value ; + m_sOutPix = std::is_arithmetic< OutputPixelType > :: value ; m_cInInternalPix = boost::is_complex < InputInternalPixelType > :: value ; m_cOutInternalPix = boost::is_complex < OutputInternalPixelType > :: value ; + } @@ -198,7 +203,7 @@ private: double m_LowestBD , m_HighestBD ; OutputPixelValueType m_LowestB , m_HighestB ; unsigned int m_CompIn , m_CompOut , m_Scal ; - bool m_cInPix , m_cInInternalPix , m_cOutPix , m_cOutInternalPix ; + bool m_cInPix , m_cInInternalPix , m_cOutPix , m_cOutInternalPix , m_sOutPix ; }; -- GitLab From 2b911e7ac1e846fba7ee3620dcf7cc405bcfb4f5 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 13 Feb 2018 08:55:38 +0100 Subject: [PATCH 226/567] TEST: enhance test for clampfilter --- .../ImageManipulation/test/CMakeLists.txt | 2 +- .../test/otbClampImageFilter.cxx | 55 ++++++++++++------- .../test/otbImageManipulationTestDriver.cxx | 2 +- 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/test/CMakeLists.txt b/Modules/Filtering/ImageManipulation/test/CMakeLists.txt index 834a6d3da0..17035f96f6 100644 --- a/Modules/Filtering/ImageManipulation/test/CMakeLists.txt +++ b/Modules/Filtering/ImageManipulation/test/CMakeLists.txt @@ -624,7 +624,7 @@ otb_add_test(NAME bfTvClampImageFilterTest COMMAND otbImageManipulationTestDrive ) otb_add_test(NAME bfTvClampImageFilterConversionTest COMMAND otbImageManipulationTestDriver - otbClampImageFilterConversionTest + otbClampImageFilterConversionFromRealTest ${INPUTDATA}/veryverySmallFSATSW.tif ) diff --git a/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx b/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx index fa48af6d6e..20b2a9c3fe 100644 --- a/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx +++ b/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx @@ -115,7 +115,7 @@ CompareImageReal( const ImageRefType::Pointer imRef , { return false; } - else if ( ref != static_cast<double>( val ) ) + else if ( static_cast<RealPixelType>( ref ) != val ) { return false; } @@ -156,11 +156,12 @@ CompareVectorReal( const ImageRefType::Pointer imRef , { return false; } - else if ( ref != static_cast<double>( val ) ) + else if ( static_cast<RealPixelType>(ref) != val ) { return false; } } + std::cout<<itRef.Get()<<std::endl; ++it; ++itRef; } @@ -190,18 +191,18 @@ CompareImageComplex( const ImageRefType::Pointer imageRef , val = it.Get(); reRef = itRef.Get()[0]; imRef = itRef.Get()[1]; - if ( ( reRef > static_cast<double>( max ) && val.real != max ) - || ( imRef > static_cast<double>( max ) && val.imag != max ) ) + if ( ( reRef > static_cast<double>( max ) && val.real() != max ) + || ( imRef > static_cast<double>( max ) && val.imag() != max ) ) { return false; } - else if ( ( reRef < static_cast<double>( min ) && val.real != min ) - || ( imRef < static_cast<double>( min ) && val.imag != min ) ) + else if ( ( reRef < static_cast<double>( min ) && val.real() != min ) + || ( imRef < static_cast<double>( min ) && val.imag() != min ) ) { return false; } - else if ( reRef != static_cast<double>( val.real ) - || imRef != static_cast<double>( val.imag ) ) + else if ( static_cast<RealType>( reRef ) != val.real() + || static_cast<RealType>( imRef ) != val.imag() ) { return false; } @@ -229,27 +230,29 @@ CompareVectorComplex( const ImageRefType::Pointer imageRef , it.GoToBegin(); unsigned int nbChanel = im->GetNumberOfComponentsPerPixel (); ComplexType val; - double reRef , imRef; + float reRef , imRef; while ( !it.IsAtEnd() ) { - for (unsigned int i = 0 ; i < nbChanel ; i++ ) { val = it.Get()[i]; reRef = itRef.Get()[ 2 * i ]; imRef = itRef.Get()[ 2 * i + 1 ]; - if ( ( reRef > static_cast<double>( max ) && val.real != max ) - || ( imRef > static_cast<double>( max ) && val.imag != max ) ) + std::cout<<it.Get()[0].real()<<" , "<<it.Get()[0].imag()<<" ; "<< + it.Get()[1].real()<<" , "<<it.Get()[1].imag()<<std::endl; + std::cout<<itRef.Get()<<std::endl; + if ( ( reRef > static_cast<double>( max ) && val.real() != max ) + || ( imRef > static_cast<double>( max ) && val.imag() != max ) ) { return false; } - else if ( ( reRef < static_cast<double>( min ) && val.real != min ) - || ( imRef < static_cast<double>( min ) && val.imag != min ) ) + else if ( ( reRef < static_cast<double>( min ) && val.real() != min ) + || ( imRef < static_cast<double>( min ) && val.imag() != min ) ) { return false; } - else if ( reRef != static_cast<double>( val.real ) - || imRef != static_cast<double>( val.imag ) ) + else if ( static_cast<RealType>( reRef ) != val.real() + || static_cast<RealType>( imRef ) != val.imag() ) { return false; } @@ -260,17 +263,27 @@ CompareVectorComplex( const ImageRefType::Pointer imageRef , return true; } -int otbClampImageFilterConversionTest(int itkNotUsed(argc), char* argv[]) +int otbClampImageFilterConversionFromRealTest(int itkNotUsed(argc), char* argv[]) { typedef otb::ImageFileReader< ImageRefType > ReaderType; ReaderType::Pointer reader ( ReaderType::New() ); reader->SetFileName( argv[1] ); reader->Update(); ImageRefType::Pointer imageRef = reader->GetOutput(); - otb::VectorImage<int>::Pointer image = - Cross < otb::VectorImage< std::complex<float> > , otb::VectorImage<int> > ( argv[1] ); - bool test = CompareVectorReal < otb::VectorImage<int> >( imageRef , image ); - if (test) + otb::VectorImage< std::complex<float>>::Pointer image1 = + Cross < otb::VectorImage< float > , otb::VectorImage<std::complex<float>> > ( argv[1] ); + bool test1 = CompareVectorComplex < otb::VectorImage<std::complex<float>> >( imageRef , image1 ); + + + otb::Image<double>::Pointer image2 = + Cross < otb::VectorImage< float > , otb::Image<double> > ( argv[1] ); + bool test2 = CompareImageReal < otb::Image<double> >( imageRef , image2 ); + + otb::Image< std::complex<float>>::Pointer image3 = + Cross < otb::VectorImage< float > , otb::Image<std::complex<float>> > ( argv[1] ); + bool test3 = CompareImageComplex < otb::Image<std::complex<float>> >( imageRef , image3 ); + + if (test1 && test2 && test3) return EXIT_SUCCESS; return 42; } diff --git a/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx b/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx index c5b59f8ef2..da2d733fb9 100644 --- a/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx +++ b/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx @@ -85,7 +85,7 @@ void RegisterTests() REGISTER_TEST(otbMultiplyByScalarImageFilterTest); REGISTER_TEST(otbClampImageFilterNew); REGISTER_TEST(otbClampImageFilterTest); - REGISTER_TEST(otbClampImageFilterConversionTest); + REGISTER_TEST(otbClampImageFilterConversionFromRealTest); REGISTER_TEST(otbConcatenateVectorImageFilter); REGISTER_TEST(otbBinaryImageMinimalBoundingRegionCalculatorNew); REGISTER_TEST(otbVectorRescaleIntensityImageFilterNew); -- GitLab From 0d1911c0b40b28d84190fb92a357a8d5227741b6 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@orfeo-toolbox.org> Date: Tue, 13 Feb 2018 08:47:46 +0000 Subject: [PATCH 227/567] BUG: Track down upstream pipeline for each image in ImageList (fix #1516) --- .../include/otbPipelineMemoryPrintCalculator.h | 2 +- .../src/otbPipelineMemoryPrintCalculator.cxx | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h b/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h index 826478711d..41fe7808e9 100644 --- a/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h +++ b/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h @@ -121,7 +121,7 @@ public: static const double MegabyteToByte; /** Evaluate the print (in bytes) of a single data object */ - MemoryPrintType EvaluateDataObjectPrint(DataObjectType * data) const; + MemoryPrintType EvaluateDataObjectPrint(DataObjectType * data); protected: /** Constructor */ diff --git a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx index 033c58bc37..424d1ccd3a 100644 --- a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx +++ b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx @@ -183,11 +183,16 @@ PipelineMemoryPrintCalculator { \ ImageList<Image<type, 2> > * imageList = dynamic_cast<otb::ImageList<otb::Image<type, 2> > *>(data); \ MemoryPrintType print(0); \ - for(ImageList<Image<type, 2> >::ConstIterator it = imageList->Begin(); \ + for(ImageList<Image<type, 2> >::Iterator it = imageList->Begin(); \ it != imageList->End(); ++it) \ { \ - print += it.Get()->GetRequestedRegion().GetNumberOfPixels() \ - * it.Get()->GetNumberOfComponentsPerPixel() * sizeof(type); \ + if(it.Get()->GetSource()) \ + { \ + it.Get()->PropagateRequestedRegion(); \ + print += this->EvaluateProcessObjectPrintRecursive(it.Get()->GetSource());\ + } \ +else \ + print += this->EvaluateDataObjectPrint(it.Get()); \ } \ return print; \ } \ @@ -198,8 +203,10 @@ PipelineMemoryPrintCalculator for(ImageList<VectorImage<type, 2> >::ConstIterator it = imageList->Begin(); \ it != imageList->End(); ++it) \ { \ - print += it.Get()->GetRequestedRegion().GetNumberOfPixels() \ - * it.Get()->GetNumberOfComponentsPerPixel() * sizeof(type); \ + if(it.Get()->GetSource()) \ + print += this->EvaluateProcessObjectPrintRecursive(it.Get()->GetSource());\ + else \ + print += this->EvaluateDataObjectPrint(it.Get()); \ } \ return print; \ } \ -- GitLab From a001033b0fc94146fa7b8ce8771b08ba3449d210 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 13 Feb 2018 10:09:43 +0100 Subject: [PATCH 228/567] Update CONTRIBUTING.md to explain how to register branches for dashboard testing. --- CONTRIBUTING.md | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5c21b7d5cc..4632f689ac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,10 +89,35 @@ Request against the `develop` branch on GitLab using the merge request template. The merge request will then be discussed by the community and the core OTB team. -* Merge requests can not be merged until all discussions have been resolved (this is enforced by GitLab). -* Merge requests **must receive at least 2 positives votes from PSC members** before being merged. -* The merger is responsible for checking that the branch is up-to-date with develop and that the dashboard is ok. +* Merge requests can not be merged until all discussions have been resolved (this is enforced by GitLab) +* Merge requests **must receive at least 2 positives votes from PSC members** before being merged +* The merger is responsible for checking that the branch is up-to-date with develop * Merge requests can be merged by anyone (not just PSC or RM) with push access to develop +* Merge requests can be merged once the dashboard is proven green for this branch + +Branches can be registered for dashboard testing by adding one line in 'Config/feature_branches.txt' in [otb-devutils repository](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-devutils.git). + +Syntax is the following. + +For branches in the main repository, syntax is the following. + +``` +branch_name [otb-data_branch_name] + +``` +Second branch name is optional. It can be set if you need to modify [otb-data](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data.git) according to your changes. + +For branches in forks, syntax is the following: +``` +user/branch_name [user/otb-data_branch_name] +``` +Again, second branch name is optional. + +For user without push access to [otb-devutils repository](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-devutils.git), the modification can be asked through a merge requests to this repository. + +Once the feature branch is registered for testing, it should appear in the *FeatureBranches* section of the [OTB dashboard](https://dash.orfeo-toolbox.org/index.php?project=OTB) next day (remember tests are run on a nighlty basis). + +Do not forget to remove the feature branch for testing once it has been merged. ## Remote modules -- GitLab From de0c344e070e5c5ba6be37163c14095a8c54163f Mon Sep 17 00:00:00 2001 From: Victor Poughon <victor.poughon@cnes.fr> Date: Tue, 13 Feb 2018 10:20:23 +0100 Subject: [PATCH 229/567] Update CONTRIBUTING.md --- CONTRIBUTING.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4632f689ac..9225b00675 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -95,25 +95,23 @@ OTB team. * Merge requests can be merged by anyone (not just PSC or RM) with push access to develop * Merge requests can be merged once the dashboard is proven green for this branch -Branches can be registered for dashboard testing by adding one line in 'Config/feature_branches.txt' in [otb-devutils repository](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-devutils.git). +Branches can be registered for dashboard testing by adding one line in `Config/feature_branches.txt` in [otb-devutils repository](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-devutils.git). -Syntax is the following. - -For branches in the main repository, syntax is the following. +For branches in the main repository, the syntax is the following: ``` branch_name [otb-data_branch_name] ``` -Second branch name is optional. It can be set if you need to modify [otb-data](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data.git) according to your changes. +The second branch name is optional. It can be set if you need to modify [otb-data](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data.git) according to your changes. -For branches in forks, syntax is the following: +For branches in forks, the syntax is the following: ``` user/branch_name [user/otb-data_branch_name] ``` -Again, second branch name is optional. +Again, the second branch name is optional. -For user without push access to [otb-devutils repository](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-devutils.git), the modification can be asked through a merge requests to this repository. +For users without push access to [otb-devutils repository](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-devutils.git), the modification can be asked through a merge requests to this repository. Once the feature branch is registered for testing, it should appear in the *FeatureBranches* section of the [OTB dashboard](https://dash.orfeo-toolbox.org/index.php?project=OTB) next day (remember tests are run on a nighlty basis). -- GitLab From c47e45406b30ca7df21ade5dd6647ce2405a9609 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@orfeo-toolbox.org> Date: Tue, 13 Feb 2018 12:22:36 +0000 Subject: [PATCH 230/567] COMP: Fix compilation error (prototype mismatch) --- Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx index 424d1ccd3a..3287a6c03a 100644 --- a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx +++ b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx @@ -162,7 +162,7 @@ PipelineMemoryPrintCalculator PipelineMemoryPrintCalculator::MemoryPrintType PipelineMemoryPrintCalculator -::EvaluateDataObjectPrint(DataObjectType * data) const +::EvaluateDataObjectPrint(DataObjectType * data) { otbMsgDevMacro(<< "EvaluateMemoryPrint for " << data->GetNameOfClass() << " (" << data << ")") -- GitLab From be9987941e495b80a7539e310953d20724bf2114 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Tue, 13 Feb 2018 14:30:58 +0100 Subject: [PATCH 231/567] COMP: fix compilation error in Debug mode (NormeS instead of NormesS) --- .../ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp index bb8903ad98..61e85f63c0 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp @@ -315,7 +315,7 @@ void ossimSarSensorModel::worldToLineSampleYZ(const ossimGpt& worldPt, ossimDpt // TODO check for small NormesS to avoid division by zero ? // Should never happen ... - assert(NormesS>1e-6); + assert(NormeS>1e-6); z = NormeS - PS2/NormeS; double distance = sqrt((sensorPos[0]-inputPt[0])*(sensorPos[0]-inputPt[0]) + -- GitLab From e1b9298ec20b13ca52a27fc3d950eb02369583a0 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 13 Feb 2018 14:50:06 +0100 Subject: [PATCH 232/567] BUG: fix bug comming from itk way of counting component --- .../include/otbConvertTypeFunctor.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h index aa318c24ab..bc74ae4a99 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h @@ -53,8 +53,15 @@ public: unsigned int GetOutputSize( unsigned int sizeIn ) { m_CompIn = sizeIn ; - if ( m_cInPix || m_cInInternalPix ) + if ( m_cInInternalPix ) m_Scal = 2 * m_CompIn; + else if ( m_cInPix ) + { + // needed as ITK thinks that one complex component is actually + // two components... + m_CompIn /= 2 ; + m_Scal = 2 * m_CompIn; + } else m_Scal = m_CompIn; if ( m_cOutInternalPix ) @@ -102,8 +109,11 @@ public: std::vector < double > vPixel; for ( unsigned int i = 0 ; i < m_CompIn ; i ++) FillIn < InputPixelType > ( i , in , vPixel ); + assert( m_Scal == vPixel.size() ); if ( ( m_cOutPix || m_cOutInternalPix ) && vPixel.size()%2 ) + { vPixel.push_back(0); // last component has no imaginary part + } Clamp( vPixel ); OutputPixelType out; int hack = 1; @@ -155,7 +165,6 @@ protected: void Clamp( std::vector < double > & vPixel ) const { - assert( m_Scal == vPixel.size() ); for ( double & comp : vPixel ) { if ( comp >= m_HighestBD ) -- GitLab From cdc5ed0c46452f80d6827900b6b7998424eac7f7 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 13 Feb 2018 14:50:51 +0100 Subject: [PATCH 233/567] TEST: full conversion test for clamp filter --- .../ImageManipulation/test/CMakeLists.txt | 2 +- .../test/otbClampImageFilter.cxx | 154 ++++++++++++++++-- .../test/otbImageManipulationTestDriver.cxx | 2 +- 3 files changed, 140 insertions(+), 18 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/test/CMakeLists.txt b/Modules/Filtering/ImageManipulation/test/CMakeLists.txt index 17035f96f6..834a6d3da0 100644 --- a/Modules/Filtering/ImageManipulation/test/CMakeLists.txt +++ b/Modules/Filtering/ImageManipulation/test/CMakeLists.txt @@ -624,7 +624,7 @@ otb_add_test(NAME bfTvClampImageFilterTest COMMAND otbImageManipulationTestDrive ) otb_add_test(NAME bfTvClampImageFilterConversionTest COMMAND otbImageManipulationTestDriver - otbClampImageFilterConversionFromRealTest + otbClampImageFilterConversionTest ${INPUTDATA}/veryverySmallFSATSW.tif ) diff --git a/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx b/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx index 20b2a9c3fe..602f524e33 100644 --- a/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx +++ b/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx @@ -84,6 +84,19 @@ Cross ( std::string const & inputFileName ) return clamp->GetOutput(); } +template < class OutImageType > +typename OutImageType::Pointer +Cross ( otb::VectorImage< std::complex<float> >::Pointer input ) +{ + + typedef otb::ClampImageFilter< otb::VectorImage< std::complex<float> > , + OutImageType > ClampFilter; + typename ClampFilter::Pointer clamp ( ClampFilter::New() ); + clamp->SetInput( input ); + clamp->Update(); + return clamp->GetOutput(); +} + typedef otb::VectorImage<double> ImageRefType; template <class ImageType > @@ -128,7 +141,7 @@ CompareImageReal( const ImageRefType::Pointer imRef , template <class ImageType > bool CompareVectorReal( const ImageRefType::Pointer imRef , - const ImageType * im) + const ImageType * im ) { typedef typename ImageType::InternalPixelType RealPixelType; RealPixelType min = std::numeric_limits< RealPixelType >::lowest(); @@ -140,28 +153,37 @@ CompareVectorReal( const ImageRefType::Pointer imRef , itRef.GoToBegin(); it.GoToBegin(); unsigned int nbChanel = im->GetNumberOfComponentsPerPixel (); + // unsigned int nbChanelRef = imRef->GetNumberOfComponentsPerPixel (); RealPixelType val; double ref; while ( !it.IsAtEnd() ) { + // std::cout<<it.Get()<<std::endl; + // std::cout<<itRef.Get()<<std::endl; for ( unsigned int i = 0 ; i < nbChanel ; i++ ) { val = it.Get()[i]; ref = itRef.Get()[i]; + if ( ref > static_cast<double>( max ) && val != max ) { + std::cout<<"ref : "<<static_cast<RealPixelType>(ref)<<std::endl; + std::cout<<"val : "<<val<<std::endl; return false; } else if ( ref < static_cast<double>( min ) && val != min ) { + std::cout<<"ref : "<<static_cast<RealPixelType>(ref)<<std::endl; + std::cout<<"val : "<<val<<std::endl; return false; } else if ( static_cast<RealPixelType>(ref) != val ) { + std::cout<<"ref : "<<static_cast<RealPixelType>(ref)<<std::endl; + std::cout<<"val : "<<val<<std::endl; return false; } } - std::cout<<itRef.Get()<<std::endl; ++it; ++itRef; } @@ -215,7 +237,8 @@ CompareImageComplex( const ImageRefType::Pointer imageRef , template <class ImageType > bool CompareVectorComplex( const ImageRefType::Pointer imageRef , - const ImageType * im ) + const ImageType * im , + bool fromImage = false) { typedef typename ImageType::InternalPixelType ComplexType; typedef typename ComplexType::value_type RealType; @@ -228,7 +251,9 @@ CompareVectorComplex( const ImageRefType::Pointer imageRef , im->GetLargestPossibleRegion() ); itRef.GoToBegin(); it.GoToBegin(); - unsigned int nbChanel = im->GetNumberOfComponentsPerPixel (); + unsigned int nbChanel = 1; + if ( !fromImage ) + nbChanel = im->GetNumberOfComponentsPerPixel (); ComplexType val; float reRef , imRef; while ( !it.IsAtEnd() ) @@ -238,9 +263,6 @@ CompareVectorComplex( const ImageRefType::Pointer imageRef , val = it.Get()[i]; reRef = itRef.Get()[ 2 * i ]; imRef = itRef.Get()[ 2 * i + 1 ]; - std::cout<<it.Get()[0].real()<<" , "<<it.Get()[0].imag()<<" ; "<< - it.Get()[1].real()<<" , "<<it.Get()[1].imag()<<std::endl; - std::cout<<itRef.Get()<<std::endl; if ( ( reRef > static_cast<double>( max ) && val.real() != max ) || ( imRef > static_cast<double>( max ) && val.imag() != max ) ) { @@ -263,27 +285,127 @@ CompareVectorComplex( const ImageRefType::Pointer imageRef , return true; } -int otbClampImageFilterConversionFromRealTest(int itkNotUsed(argc), char* argv[]) +int otbClampImageFilterConversionTest(int itkNotUsed(argc), char* argv[]) { typedef otb::ImageFileReader< ImageRefType > ReaderType; ReaderType::Pointer reader ( ReaderType::New() ); reader->SetFileName( argv[1] ); reader->Update(); ImageRefType::Pointer imageRef = reader->GetOutput(); - otb::VectorImage< std::complex<float>>::Pointer image1 = - Cross < otb::VectorImage< float > , otb::VectorImage<std::complex<float>> > ( argv[1] ); - bool test1 = CompareVectorComplex < otb::VectorImage<std::complex<float>> >( imageRef , image1 ); + // vect<real> --> vect<real> + otb::VectorImage< short >::Pointer image0 = + Cross < otb::VectorImage< double > , otb::VectorImage< short > > ( argv[1] ); + bool test0 = CompareVectorReal < otb::VectorImage< short > >( imageRef , image0 ); + std::cout<< "Test 0 : "<<test0<<std::endl; + image0 =nullptr; + + // vect<real> --> vect<complex> + otb::VectorImage< std::complex<unsigned short>>::Pointer image1 = + Cross < otb::VectorImage< float > , otb::VectorImage<std::complex<unsigned short>> > ( argv[1] ); + bool test1 = CompareVectorComplex < otb::VectorImage<std::complex<unsigned short>> >( imageRef , image1 ); + std::cout<< "Test 1 : "<<test1<<std::endl; + image1 = nullptr; - otb::Image<double>::Pointer image2 = - Cross < otb::VectorImage< float > , otb::Image<double> > ( argv[1] ); - bool test2 = CompareImageReal < otb::Image<double> >( imageRef , image2 ); + // vect<real> --> image<real> + otb::Image<int>::Pointer image2 = + Cross < otb::VectorImage< float > , otb::Image<int> > ( argv[1] ); + bool test2 = CompareImageReal < otb::Image<int> >( imageRef , image2 ); + std::cout<< "Test 2 : "<<test2<<std::endl; + image2 = nullptr; + // vect<real> --> image<complex> otb::Image< std::complex<float>>::Pointer image3 = Cross < otb::VectorImage< float > , otb::Image<std::complex<float>> > ( argv[1] ); bool test3 = CompareImageComplex < otb::Image<std::complex<float>> >( imageRef , image3 ); + std::cout<< "Test 3 : "<<test3<<std::endl; + image3 = nullptr; + + // image<real> --> image<real> + otb::Image< unsigned short >::Pointer image4 = + Cross < otb::Image< itk::FixedArray < double , 4 > > , otb::Image< unsigned short > > ( argv[1] ); + bool test4 = CompareImageReal < otb::Image< unsigned short > >( imageRef , image4 ); + std::cout<< "Test 4 : "<<test4<<std::endl; + image4 = nullptr; + + // image<real> --> image<complex> + otb::Image< std::complex<int> >::Pointer image5 = + Cross < otb::Image< itk::FixedArray < double , 4 > > , otb::Image< std::complex<int> > > ( argv[1] ); + bool test5 = CompareImageComplex < otb::Image< std::complex<int> > >( imageRef , image5 ); + std::cout<< "Test 5 : "<<test5<<std::endl; + image5 = nullptr; + + // image<real> --> vector<real> + otb::VectorImage< float >::Pointer image6 = + Cross < otb::Image< itk::FixedArray < double , 4 > > , otb::VectorImage< float > > ( argv[1] ); + bool test6 = CompareVectorReal < otb::VectorImage< float > >( imageRef , image6 ); + std::cout<< "Test 6 : "<<test6<<std::endl; + image6 = nullptr; + + // image<real> --> vector<complex> + otb::VectorImage< std::complex<float> >::Pointer image7 = + Cross < otb::Image< itk::FixedArray < double , 4 > > , otb::VectorImage< std::complex<float> > > ( argv[1] ); + bool test7 = CompareVectorComplex < otb::VectorImage< std::complex<float> > >( imageRef , image7 ); + std::cout<< "Test 7 : "<<test7<<std::endl; + + // vector<complex> --> vector<real> + otb::VectorImage< int >::Pointer image8 = + Cross < otb::VectorImage< int > > ( image7 ); + bool test8 = CompareVectorReal < otb::VectorImage< int > >( imageRef , image8 ); + std::cout<< "Test 8 : "<<test8<<std::endl; + image8=nullptr; + + // vector<complex> --> vector<complex> + otb::VectorImage< std::complex<int> >::Pointer image9 = + Cross < otb::VectorImage< std::complex<int> > > ( image7 ); + bool test9 = CompareVectorComplex < otb::VectorImage< std::complex<int> > >( imageRef , image9 ); + std::cout<< "Test 9 : "<<test9<<std::endl; + image9=nullptr; + + // vector<complex> --> image<real> + otb::Image< int >::Pointer image10 = + Cross < otb::Image< int > > ( image7 ); + bool test10 = CompareImageReal < otb::Image< int > >( imageRef , image10 ); + std::cout<< "Test 10 : "<<test10<<std::endl; + image10=nullptr; + + // vector<complex> --> image<complex> + otb::Image< std::complex<unsigned short> >::Pointer image11 = + Cross < otb::Image< std::complex<unsigned short> > > ( image7 ); + bool test11 = CompareImageComplex < otb::Image< std::complex<unsigned short> > >( imageRef , image11 ); + std::cout<< "Test 11 : "<<test11<<std::endl; + image11=nullptr; + + // image<complex> --> vector<complex> + otb::VectorImage<std::complex<float>>::Pointer image12 = + Cross < otb::Image< std::complex<float> > , otb::VectorImage< std::complex<float>> > ( argv[1] ); + bool test12 = CompareVectorComplex < otb::VectorImage<std::complex<float>> >( imageRef , image12 ); + std::cout<< "Test 12 : "<<test12<<std::endl; + image12 = nullptr; + + // image<complex> --> image<complex> + otb::Image< std::complex< short >>::Pointer image13 = + Cross < otb::Image< std::complex<float> > , otb::Image< std::complex< short >> > ( argv[1] ); + bool test13 = CompareImageComplex < otb::Image< std::complex< short >> >( imageRef , image13 ); + std::cout<< "Test 13 : "<<test13<<std::endl; + image13 = nullptr; + + // image<complex> --> image<real> + otb::Image< int >::Pointer image14 = + Cross < otb::Image< std::complex<float> > , otb::Image< int > > ( argv[1] ); + bool test14 = CompareImageReal < otb::Image< int > >( imageRef , image14 ); + std::cout<< "Test 14 : "<<test14<<std::endl; + image14 = nullptr; + + // image<complex> --> vector<real> + otb::VectorImage< unsigned short >::Pointer image15 = + Cross < otb::Image< std::complex<float> > , otb::VectorImage< unsigned short > > ( argv[1] ); + bool test15 = CompareVectorReal < otb::VectorImage< unsigned short > >( imageRef , image15 ); + std::cout<< "Test 15 : "<<test15<<std::endl; + image15 = nullptr; - if (test1 && test2 && test3) + if (test1 && test2 && test3 && test4 && test5 &&test6 && test7 && test8 + && test9 && test10 && test11 && test12 && test13 && test14 && test15 ) return EXIT_SUCCESS; - return 42; + return EXIT_FAILURE; } diff --git a/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx b/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx index da2d733fb9..c5b59f8ef2 100644 --- a/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx +++ b/Modules/Filtering/ImageManipulation/test/otbImageManipulationTestDriver.cxx @@ -85,7 +85,7 @@ void RegisterTests() REGISTER_TEST(otbMultiplyByScalarImageFilterTest); REGISTER_TEST(otbClampImageFilterNew); REGISTER_TEST(otbClampImageFilterTest); - REGISTER_TEST(otbClampImageFilterConversionFromRealTest); + REGISTER_TEST(otbClampImageFilterConversionTest); REGISTER_TEST(otbConcatenateVectorImageFilter); REGISTER_TEST(otbBinaryImageMinimalBoundingRegionCalculatorNew); REGISTER_TEST(otbVectorRescaleIntensityImageFilterNew); -- GitLab From 1c10df6983dd4c3d53f601be5845d710e0c13da9 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 13 Feb 2018 15:34:37 +0100 Subject: [PATCH 234/567] COMP: remove DefaultValueMode from SWIG binding --- Modules/Wrappers/SWIG/src/otbApplication.i | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index d945d52af4..cdf95c0525 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -74,12 +74,6 @@ namespace otb { namespace Wrapper { - enum DefaultValueMode - { - DefaultValueMode_UNKNOWN, - DefaultValueMode_RELATIVE, - DefaultValueMode_ABSOLUTE - }; typedef enum { -- GitLab From 5d4c5c9761307c1a7d075a39205b19f8f97d3586 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 13 Feb 2018 16:08:31 +0100 Subject: [PATCH 235/567] Gitlab: add label feature automatically --- .gitlab/issue_templates/feature_request.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab/issue_templates/feature_request.md b/.gitlab/issue_templates/feature_request.md index 6031fad9a7..5b6ee30b89 100644 --- a/.gitlab/issue_templates/feature_request.md +++ b/.gitlab/issue_templates/feature_request.md @@ -1 +1,3 @@ Short summary of the requested feature + +/label ~feature -- GitLab From 3e2271256df682bdc40f826a652614df2f222e19 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 14 Feb 2018 08:25:34 +0100 Subject: [PATCH 236/567] BUG: Moving PropageRequestedRegion() at the correct place in ImageList, and remove the unnecessary call in PipelineMemoryPrintCalculator (part of fir for #1516) --- .../Core/ObjectList/include/otbImageList.txx | 27 ++++++++++--------- .../src/otbPipelineMemoryPrintCalculator.cxx | 5 +--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Modules/Core/ObjectList/include/otbImageList.txx b/Modules/Core/ObjectList/include/otbImageList.txx index dc0cbc9b6f..80b7276454 100644 --- a/Modules/Core/ObjectList/include/otbImageList.txx +++ b/Modules/Core/ObjectList/include/otbImageList.txx @@ -33,6 +33,19 @@ ImageList<TImage> ::UpdateOutputData() { Superclass::UpdateOutputData(); + for (ConstIterator it = this->Begin(); it != this->End(); ++it) + { + it.Get()->GetSource()->UpdateOutputData(it.Get()); + } +} + +template <class TImage> +void +ImageList<TImage> +::PropagateRequestedRegion() throw (itk::InvalidRequestedRegionError) + { + Superclass::PropagateRequestedRegion(); + for (ConstIterator it = this->Begin(); it != this->End(); ++it) { if (it.Get()->GetUpdateMTime() < it.Get()->GetPipelineMTime() @@ -42,7 +55,7 @@ ImageList<TImage> if (it.Get()->GetSource()) { it.Get()->GetSource()->PropagateRequestedRegion(it.Get()); - + // Check that the requested region lies within the largest possible region if (!it.Get()->VerifyRequestedRegion()) { @@ -51,22 +64,12 @@ ImageList<TImage> e.SetLocation(ITK_LOCATION); e.SetDataObject(it.Get()); e.SetDescription("Requested region is (at least partially) outside the largest possible region."); - + throw e; } - - it.Get()->GetSource()->UpdateOutputData(it.Get()); } } } -} - -template <class TImage> -void -ImageList<TImage> -::PropagateRequestedRegion() throw (itk::InvalidRequestedRegionError) - { - Superclass::PropagateRequestedRegion(); } template <class TImage> diff --git a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx index 3287a6c03a..d7d62e8c88 100644 --- a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx +++ b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx @@ -187,11 +187,8 @@ PipelineMemoryPrintCalculator it != imageList->End(); ++it) \ { \ if(it.Get()->GetSource()) \ - { \ - it.Get()->PropagateRequestedRegion(); \ print += this->EvaluateProcessObjectPrintRecursive(it.Get()->GetSource());\ - } \ -else \ + else \ print += this->EvaluateDataObjectPrint(it.Get()); \ } \ return print; \ -- GitLab From 344a0b3ba270faf7423c39d0755b4616449108d1 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Feb 2018 09:02:10 +0100 Subject: [PATCH 237/567] REFAC: take into account merge request comments --- .../app/otbDomainTransform.cxx | 2 +- .../include/otbDefaultConvertPixelTraits.h | 166 ++---------------- .../include/otbClampImageFilter.h | 27 +-- .../include/otbClampImageFilter.txx | 27 ++- .../include/otbConvertTypeFunctor.h | 9 +- 5 files changed, 49 insertions(+), 182 deletions(-) diff --git a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx index 531c0f656a..c3321c2bb5 100644 --- a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx +++ b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx @@ -264,7 +264,7 @@ private: { // fft ttransform bool shift = IsParameterEnabled( "mode.fft.shift"); - typedef otb::Image< std::complex<OutputPixelType> > OutputImageType; + typedef otb::Image< std::complex<OutputPixelType> > ComplexOutputImageType; if (dir == 0 ) { diff --git a/Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h b/Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h index 1cfdd2bf16..be11633e7b 100644 --- a/Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h +++ b/Modules/Core/ImageBase/include/otbDefaultConvertPixelTraits.h @@ -1,31 +1,28 @@ -/*========================================================================= +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) * - * Copyright Insight Software Consortium + * This file is part of Orfeo Toolbox * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * https://www.orfeo-toolbox.org/ * - * http://www.apache.org/licenses/LICENSE-2.0.txt + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * http://www.apache.org/licenses/LICENSE-2.0 * - *=========================================================================*/ + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #ifndef otbDefaultConvertPixelTraits_h #define otbDefaultConvertPixelTraits_h #include "itkDefaultConvertPixelTraits.h" -// #include "itkOffset.h" -// #include "itkVector.h" -// #include "itkMatrix.h" -// #include "itkVariableLengthVector.h" -// #include "itkVariableSizeMatrix.h" - namespace otb { @@ -46,139 +43,6 @@ public: } }; -// We might not need this specialization if the compileur allow -// us to declare to function with same signature in some case : -// see "SetNthComponent" -/* -#define OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \ - template< > \ - class DefaultConvertPixelTraits < type > \ - : public itk::DefaultConvertPixelTraits < type > \ - { \ -public: \ - typedef itk::DefaultConvertPixelTraits < type > SuperClass; \ - using typename SuperClass::ComponentType; \ - }; -*/ -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(float) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(double) -// Warning long double is not in itk < 4.11 -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long double) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(int) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(char) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(short) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned int) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(signed char) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned char) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned short) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long long) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long long) -// OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(bool) - -// #undef OTB_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL - -// -// Default traits for the Offset<> pixel type -// - -// template<unsigned int VDimension> -// class DefaultConvertPixelTraits < itk::Offset< VDimension > > : -// public itk::DefaultConvertPixelTraits< itk::Offset< VDimension > > -// { -// public: -// typedef itk::DefaultConvertPixelTraits < itk::Offset< VDimension > > SuperClass; -// using typename SuperClass::ComponentType; - -// using SuperClass::SetNthComponent; - -// static void SetNthComponent(int , TargetType & pixel, const TargetType& v) -// { -// pixel = v; -// } -// }; - -// -// Default traits for the pixel types deriving from FixedArray<> -// - -/* -define OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \ -template < typename TComponentType , unsigned VDimension > \ -class DefaultConvertPixelTraits < type < TComponentType , VDimension > > \ -: public itk::DefaultConvertPixelTraits < type < TComponentType , VDimension > > \ -{ \ -public: \ - typedef itk::DefaultConvertPixelTraits < type < TComponentType , VDimension > > SuperClass;\ - typedef typename SuperClass::TargetType TargetType; \ - static void SetNthComponent(int , TargetType & pixel, const TargetType & v) \ - { \ - pixel = v; \ - } \ -} \ -*/ -// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::FixedArray); -// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Vector); -// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::CovariantVector); -// OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Point); - -// #undef OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE - -// -// Default traits for pixel types deriving from VariableLengthVector<> -// - -// template < typename T > -// class DefaultConvertPixelTraits < itk::VariableLengthVector < T > > -// : public itk::DefaultConvertPixelTraits < itk::VariableLengthVector< T > > -// { -// public: -// typedef itk::DefaultConvertPixelTraits< itk::VariableLengthVector < T > > SuperClass; -// using typename SuperClass::TargetType; -// using typename SuperClass::ComponentType; -// }; - -// -// Default traits for the pixel types deriving from Matrix<> -// - -// template<typename VComponent, unsigned VRows, unsigned VCols > -// class DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > -// : public itk::DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > -// { -// public: -// typedef itk::DefaultConvertPixelTraits < itk::Matrix< VComponent, VRows, VCols > > SuperClass; -// using typename SuperClass::TargetType; -// using typename SuperClass::ComponentType; - - -// using SuperClass::SetNthComponent; - -// static void SetNthComponent(int , TargetType & pixel, const TargetType& v) -// { -// pixel = v; -// } -// }; - -// -// Default traits for pixel types deriving from VariableSizeMatrix<> -// - -// template < typename T > -// class DefaultConvertPixelTraits< itk::VariableSizeMatrix< T > > -// : public itk::DefaultConvertPixelTraits< itk::VariableSizeMatrix< T > > -// { -// public: -// typedef itk::DefaultConvertPixelTraits< itk::VariableSizeMatrix < T > > SuperClass; -// using typename SuperClass::TargetType; -// using typename SuperClass::ComponentType; -// }; - -// -// Default traits for pixel types deriving from std::complex<> -// - template < typename T > class DefaultConvertPixelTraits < ::std::complex < T > > : public itk::DefaultConvertPixelTraits < ::std::complex < T > > diff --git a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h index d74a2d8829..78bf5a6a0c 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h @@ -79,33 +79,23 @@ public: typedef typename itk::NumericTraits< OutputInternalPixelType >::ValueType OutputPixelValueType; - /** The values greater than or equal to the value are set to OutsideValue. */ + /** The values greater than or equal to the value are set to \p thresh. */ void ClampAbove(const OutputPixelValueType &thresh); - /** The values less than or equal to the value are set to OutsideValue. */ + /** The values less than or equal to the value are set to \p thresh. */ void ClampBelow(const OutputPixelValueType &thresh); - /** The values outside the range are set to OutsideValue. */ + /** The values outside the range are set to \p lower or \p upper. */ void ClampOutside(const OutputPixelValueType &lower, const OutputPixelValueType &upper); /** Set/Get methods to set the lower threshold */ - void SetLower(OutputPixelValueType val) - { - m_Lower = val; - m_DLower = static_cast<double>(val); - this->GetFunctor().SetLowest( m_Lower ); - this->Modified(); - } + void SetLower(OutputPixelValueType val); + itkGetConstMacro(Lower, OutputPixelValueType); /** Set/Get methods to set the upper threshold */ - void SetUpper(OutputPixelValueType val) - { - m_Upper = val; - m_DUpper = static_cast<double>(val); - this->GetFunctor().SetHighest( m_Upper ); - this->Modified(); - } + void SetUpper(OutputPixelValueType val); + itkGetConstMacro(Upper, OutputPixelValueType); @@ -126,9 +116,6 @@ private: ClampImageFilter(const Self&) = delete ; void operator=(const Self&) = delete ; - double m_DLower; - double m_DUpper; - OutputPixelValueType m_Lower; OutputPixelValueType m_Upper; }; diff --git a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx index 74d0c543e9..d6f146436a 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx +++ b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx @@ -41,11 +41,30 @@ ClampImageFilter<TInputImage, TOutputImage> { m_Lower = std::numeric_limits < OutputPixelValueType >::lowest(); m_Upper = std::numeric_limits < OutputPixelValueType >::max(); +} - m_DLower = static_cast<double>(m_Lower); - m_DUpper = static_cast<double>(m_Upper); +template <class TInputImage, class TOutputImage> +void +ClampImageFilter<TInputImage, TOutputImage> +::SetLower(OutputPixelValueType val) +{ + if ( m_Lower != val ) + { + m_Lower = val; + this->GetFunctor().SetLowest( m_Lower ); + this->Modified(); + } } +template <class TInputImage, class TOutputImage> +void +ClampImageFilter<TInputImage, TOutputImage> +::SetUpper(OutputPixelValueType val) +{ + m_Upper = val; + this->GetFunctor().SetHighest( m_Upper ); + this->Modified(); +} /** * @@ -78,7 +97,6 @@ ClampImageFilter<TInputImage, TOutputImage> { m_Lower = std::numeric_limits < OutputPixelValueType >::lowest(); m_Upper = thresh; - m_DUpper = static_cast<double>(m_Upper); this->GetFunctor().SetLowest( m_Lower ); this->GetFunctor().SetHighest( m_Upper ); this->Modified(); @@ -97,7 +115,6 @@ ClampImageFilter<TInputImage, TOutputImage> { m_Upper = std::numeric_limits < OutputPixelValueType >::max(); m_Lower = thresh; - m_DLower = m_Lower; this->GetFunctor().SetLowest( m_Lower ); this->GetFunctor().SetHighest( m_Upper ); this->Modified(); @@ -123,8 +140,6 @@ ClampImageFilter<TInputImage, TOutputImage> { m_Lower = lower; m_Upper = upper; - m_DLower = m_Lower; - m_DUpper = m_Upper; this->GetFunctor().SetLowest( m_Lower ); this->GetFunctor().SetHighest( m_Upper ); this->Modified(); diff --git a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h index bc74ae4a99..12fa0ed065 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h @@ -64,13 +64,14 @@ public: } else m_Scal = m_CompIn; + if ( m_cOutInternalPix ) m_CompOut = ( m_Scal + 1 ) / 2 ; + else if ( m_sOutPix || m_cOutPix ) + m_CompOut = 1; else m_CompOut = m_Scal ; - if ( m_sOutPix || m_cOutPix ) - m_CompOut = 1; return m_CompOut ; } @@ -164,7 +165,7 @@ protected: } void Clamp( std::vector < double > & vPixel ) const - { + { for ( double & comp : vPixel ) { if ( comp >= m_HighestBD ) @@ -172,7 +173,7 @@ protected: else if ( comp <= m_LowestBD ) comp = m_LowestBD; } - } + } template <class PixelType , std::enable_if_t < std::is_arithmetic < PixelType > ::value , int > = 0 > -- GitLab From 02f45c83a572cc31c08755b06c449cd6a6cccc06 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Feb 2018 10:04:36 +0100 Subject: [PATCH 238/567] ENH: change the way the size is treated --- .../include/otbConvertTypeFunctor.h | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h index 12fa0ed065..2c6d5d294f 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h @@ -117,13 +117,23 @@ public: } Clamp( vPixel ); OutputPixelType out; - int hack = 1; - if ( m_cOutPix && m_CompOut == 1 ) - hack += 1; // needed in case we have OutputPixelType == complex<t> as + unsigned int compOut = m_CompOut; + unsigned int size = + itk::NumericTraits < OutputPixelType > :: GetLength( out ); + if ( size == 0 ) // That means it is a variable size container + { + int hack = 1; + if ( m_cOutPix && m_CompOut == 1 ) + hack += 1; // needed in case we have OutputPixelType == complex<t> as // itk::NumericTraits::SetLength() will ask a length of 2! - itk::NumericTraits < OutputPixelType > :: SetLength( out , - hack * m_CompOut ); - for ( unsigned int i = 0 ; i < m_CompOut ; i ++) + itk::NumericTraits < OutputPixelType > :: SetLength( out , + hack * m_CompOut ); + } + else if ( m_cOutPix )// It is a fixed size container, m_CompOut should be equal to its size + compOut = size / 2; + else + compOut = size; + for ( unsigned int i = 0 ; i < compOut ; i ++) FillOut < OutputPixelType > ( i , out , vPixel ); return out; } -- GitLab From a99d54f089fa78aadadebfa13e8a7d1278f1d208 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Feb 2018 10:28:13 +0100 Subject: [PATCH 239/567] ENH: change for better nd lighter implementation of GetOutputSize() --- .../include/otbClampImageFilter.h | 3 +- .../include/otbConvertTypeFunctor.h | 89 ++++++++++--------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h index 78bf5a6a0c..a27574a971 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h @@ -108,8 +108,9 @@ protected: { Superclass::GenerateOutputInformation(); unsigned int sizeIn = this->GetInput()->GetNumberOfComponentsPerPixel(); + this->GetFunctor().SetInputComponents( sizeIn ); this->GetOutput()->SetNumberOfComponentsPerPixel( - this->GetFunctor().GetOutputSize ( sizeIn ) ); + this->GetFunctor().GetOutputSize () ); } private: diff --git a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h index 2c6d5d294f..b657c60240 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h @@ -49,28 +49,54 @@ public: typedef typename itk::NumericTraits < InputInternalPixelType > :: ValueType InputPixelValueType; typedef typename itk::NumericTraits < OutputInternalPixelType > :: ValueType OutputPixelValueType; - // template < class InternalPixelType > - unsigned int GetOutputSize( unsigned int sizeIn ) + ConvertTypeFunctor() { + m_LowestB = std::numeric_limits < OutputPixelValueType >::lowest(); + m_HighestB = std::numeric_limits < OutputPixelValueType >::max(); + + m_LowestBD = static_cast < double > ( m_LowestB ); + m_HighestBD = static_cast < double > ( m_HighestB ); + + m_cInPix = boost::is_complex < InputPixelType > :: value ; + m_cOutPix = boost::is_complex < OutputPixelType > :: value ; + m_cInInternalPix = boost::is_complex < InputInternalPixelType > :: value ; + m_cOutInternalPix = boost::is_complex < OutputInternalPixelType > :: value ; + } + + // template < class InternalPixelType > + void SetInputComponents( unsigned int sizeIn ) + { m_CompIn = sizeIn ; - if ( m_cInInternalPix ) - m_Scal = 2 * m_CompIn; - else if ( m_cInPix ) + if ( m_cInPix ) { // needed as ITK thinks that one complex component is actually // two components... m_CompIn /= 2 ; - m_Scal = 2 * m_CompIn; } + } + + unsigned int GetOutputSize() + { + if ( m_cInInternalPix || m_cInPix ) + m_Scal = 2 * m_CompIn; else m_Scal = m_CompIn; - if ( m_cOutInternalPix ) - m_CompOut = ( m_Scal + 1 ) / 2 ; - else if ( m_sOutPix || m_cOutPix ) - m_CompOut = 1; - else - m_CompOut = m_Scal ; + OutputPixelType out; + unsigned int size = + itk::NumericTraits < OutputPixelType > :: GetLength( out ); + if ( size == 0 ) // That means it is a variable size container + { + if ( m_cOutInternalPix ) + m_CompOut = ( m_Scal + 1 ) / 2 ; + else + m_CompOut = m_Scal ; + } + // It is a fixed size container, m_CompOut should be equal to its size + else if ( m_cOutPix ) // one complex is one component + m_CompOut = 1 ; + else // fized size container or scalar + m_CompOut = size; return m_CompOut ; @@ -88,23 +114,6 @@ public: m_HighestBD = static_cast < double > ( m_HighestB ); } - ConvertTypeFunctor() - { - m_LowestB = std::numeric_limits < OutputPixelValueType >::lowest(); - m_HighestB = std::numeric_limits < OutputPixelValueType >::max(); - - m_LowestBD = static_cast < double > ( m_LowestB ); - m_HighestBD = static_cast < double > ( m_HighestB ); - - m_cInPix = boost::is_complex < InputPixelType > :: value ; - m_cOutPix = boost::is_complex < OutputPixelType > :: value ; - m_sOutPix = std::is_arithmetic< OutputPixelType > :: value ; - m_cInInternalPix = boost::is_complex < InputInternalPixelType > :: value ; - m_cOutInternalPix = boost::is_complex < OutputInternalPixelType > :: value ; - - } - - OutputPixelType operator() ( InputPixelType const & in ) const { std::vector < double > vPixel; @@ -117,23 +126,15 @@ public: } Clamp( vPixel ); OutputPixelType out; - unsigned int compOut = m_CompOut; - unsigned int size = - itk::NumericTraits < OutputPixelType > :: GetLength( out ); - if ( size == 0 ) // That means it is a variable size container - { - int hack = 1; - if ( m_cOutPix && m_CompOut == 1 ) - hack += 1; // needed in case we have OutputPixelType == complex<t> as + + int hack = 1; + if ( m_cOutPix ) + hack += 1; // needed in case we have OutputPixelType == complex<t> as // itk::NumericTraits::SetLength() will ask a length of 2! - itk::NumericTraits < OutputPixelType > :: SetLength( out , + itk::NumericTraits < OutputPixelType > :: SetLength( out , hack * m_CompOut ); - } - else if ( m_cOutPix )// It is a fixed size container, m_CompOut should be equal to its size - compOut = size / 2; - else - compOut = size; - for ( unsigned int i = 0 ; i < compOut ; i ++) + + for ( unsigned int i = 0 ; i < m_CompOut ; i ++) FillOut < OutputPixelType > ( i , out , vPixel ); return out; } -- GitLab From f39175b2231920a8baeb2ebe49574b0b236aac1d Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Feb 2018 10:49:29 +0100 Subject: [PATCH 240/567] TEST: add new test cases --- .../test/otbClampImageFilter.cxx | 94 +++++++++++++++++-- 1 file changed, 87 insertions(+), 7 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx b/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx index 602f524e33..29ac5602ea 100644 --- a/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx +++ b/Modules/Filtering/ImageManipulation/test/otbClampImageFilter.cxx @@ -88,7 +88,6 @@ template < class OutImageType > typename OutImageType::Pointer Cross ( otb::VectorImage< std::complex<float> >::Pointer input ) { - typedef otb::ClampImageFilter< otb::VectorImage< std::complex<float> > , OutImageType > ClampFilter; typename ClampFilter::Pointer clamp ( ClampFilter::New() ); @@ -97,6 +96,18 @@ Cross ( otb::VectorImage< std::complex<float> >::Pointer input ) return clamp->GetOutput(); } +template < class OutImageType > +typename OutImageType::Pointer +Cross ( otb::Image< itk::FixedArray< std::complex<float> , 2 > >::Pointer input ) +{ + typedef otb::ClampImageFilter< otb::Image< itk::FixedArray< std::complex<float> , 2 > > , + OutImageType > ClampFilter; + typename ClampFilter::Pointer clamp ( ClampFilter::New() ); + clamp->SetInput( input ); + clamp->Update(); + return clamp->GetOutput(); +} + typedef otb::VectorImage<double> ImageRefType; template <class ImageType > @@ -237,8 +248,7 @@ CompareImageComplex( const ImageRefType::Pointer imageRef , template <class ImageType > bool CompareVectorComplex( const ImageRefType::Pointer imageRef , - const ImageType * im , - bool fromImage = false) + const ImageType * im ) { typedef typename ImageType::InternalPixelType ComplexType; typedef typename ComplexType::value_type RealType; @@ -251,9 +261,56 @@ CompareVectorComplex( const ImageRefType::Pointer imageRef , im->GetLargestPossibleRegion() ); itRef.GoToBegin(); it.GoToBegin(); - unsigned int nbChanel = 1; - if ( !fromImage ) - nbChanel = im->GetNumberOfComponentsPerPixel (); + unsigned int nbChanel = im->GetNumberOfComponentsPerPixel (); + ComplexType val; + float reRef , imRef; + while ( !it.IsAtEnd() ) + { + for (unsigned int i = 0 ; i < nbChanel ; i++ ) + { + val = it.Get()[i]; + reRef = itRef.Get()[ 2 * i ]; + imRef = itRef.Get()[ 2 * i + 1 ]; + if ( ( reRef > static_cast<double>( max ) && val.real() != max ) + || ( imRef > static_cast<double>( max ) && val.imag() != max ) ) + { + return false; + } + else if ( ( reRef < static_cast<double>( min ) && val.real() != min ) + || ( imRef < static_cast<double>( min ) && val.imag() != min ) ) + { + return false; + } + else if ( static_cast<RealType>( reRef ) != val.real() + || static_cast<RealType>( imRef ) != val.imag() ) + { + return false; + } + } + ++it; + ++itRef; + } + return true; +} + +template <class ImageType > +bool +CompareArrayComplex( const ImageRefType::Pointer imageRef , + const ImageType * im ) +{ + typedef typename ImageType::PixelType ArrayType; + typedef typename ArrayType::ValueType ComplexType; + typedef typename ComplexType::value_type RealType; + + RealType min = std::numeric_limits< RealType >::lowest(); + RealType max = std::numeric_limits< RealType >::max(); + auto itRef = itk::ImageRegionConstIterator< ImageRefType >( imageRef , + imageRef->GetLargestPossibleRegion() ); + auto it = itk::ImageRegionConstIterator< ImageType >( im , + im->GetLargestPossibleRegion() ); + itRef.GoToBegin(); + it.GoToBegin(); + unsigned int nbChanel = im->GetNumberOfComponentsPerPixel (); ComplexType val; float reRef , imRef; while ( !it.IsAtEnd() ) @@ -404,8 +461,31 @@ int otbClampImageFilterConversionTest(int itkNotUsed(argc), char* argv[]) std::cout<< "Test 15 : "<<test15<<std::endl; image15 = nullptr; + // image<fixedarray<real>> --> image<fixedarray<complex>> + otb::Image< itk::FixedArray < std::complex<float> , 2 > >::Pointer image16 = + Cross < otb::Image< itk::FixedArray < double , 4 > > , + otb::Image< itk::FixedArray < std::complex<float> , 2 > > > ( argv[1] ); + bool test16 = CompareArrayComplex < otb::Image< itk::FixedArray < std::complex<float> , 2 > > >( imageRef , image16 ); + std::cout<< "Test 16 : "<<test16<<std::endl; + + // image<fixedarray<complex>> --> vectorimage<real> + otb::VectorImage< int >::Pointer image17 = + Cross < otb::VectorImage< int > >( image16 ); + bool test17 = CompareVectorReal < otb::VectorImage< int > >( imageRef , image17 ); + std::cout<< "Test 17 : "<<test17<<std::endl; + image17 = nullptr; + + // vector<real> --> image<fixedarray<complex>> + otb::Image< itk::FixedArray < std::complex<float> , 2 > >::Pointer image18 = + Cross < otb::VectorImage< int > , + otb::Image< itk::FixedArray < std::complex<float> , 2 > > > ( argv[1] ); + bool test18 = CompareArrayComplex < otb::Image< itk::FixedArray < std::complex<float> , 2 > > >( imageRef , image18 ); + image18 = nullptr; + std::cout<< "Test 18 : "<<test18<<std::endl; + if (test1 && test2 && test3 && test4 && test5 &&test6 && test7 && test8 - && test9 && test10 && test11 && test12 && test13 && test14 && test15 ) + && test9 && test10 && test11 && test12 && test13 && test14 && test15 + && test16 && test17 && test18 ) return EXIT_SUCCESS; return EXIT_FAILURE; } -- GitLab From 547117b7a07ab420d9c49f96c32a7dff6401b1dc Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Feb 2018 11:01:49 +0100 Subject: [PATCH 241/567] ENH: make some member const --- .../include/otbConvertTypeFunctor.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h index b657c60240..baa659e785 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h @@ -49,7 +49,11 @@ public: typedef typename itk::NumericTraits < InputInternalPixelType > :: ValueType InputPixelValueType; typedef typename itk::NumericTraits < OutputInternalPixelType > :: ValueType OutputPixelValueType; - ConvertTypeFunctor() + ConvertTypeFunctor() : + m_cInPix ( boost::is_complex < InputPixelType > :: value ) , + m_cOutPix ( boost::is_complex < OutputPixelType > :: value ) , + m_cInInternalPix ( boost::is_complex < InputInternalPixelType > :: value ) , + m_cOutInternalPix ( boost::is_complex < OutputInternalPixelType > :: value ) { m_LowestB = std::numeric_limits < OutputPixelValueType >::lowest(); m_HighestB = std::numeric_limits < OutputPixelValueType >::max(); @@ -57,10 +61,10 @@ public: m_LowestBD = static_cast < double > ( m_LowestB ); m_HighestBD = static_cast < double > ( m_HighestB ); - m_cInPix = boost::is_complex < InputPixelType > :: value ; - m_cOutPix = boost::is_complex < OutputPixelType > :: value ; - m_cInInternalPix = boost::is_complex < InputInternalPixelType > :: value ; - m_cOutInternalPix = boost::is_complex < OutputInternalPixelType > :: value ; + // m_cInPix = boost::is_complex < InputPixelType > :: value ; + // m_cOutPix = boost::is_complex < OutputPixelType > :: value ; + // m_cInInternalPix = boost::is_complex < InputInternalPixelType > :: value ; + // m_cOutInternalPix = boost::is_complex < OutputInternalPixelType > :: value ; } // template < class InternalPixelType > @@ -224,7 +228,7 @@ private: double m_LowestBD , m_HighestBD ; OutputPixelValueType m_LowestB , m_HighestB ; unsigned int m_CompIn , m_CompOut , m_Scal ; - bool m_cInPix , m_cInInternalPix , m_cOutPix , m_cOutInternalPix , m_sOutPix ; + const bool m_cInPix , m_cOutPix , m_cInInternalPix , m_cOutInternalPix ; }; -- GitLab From 707df06545256a4e43f9c46e27799dc716fffffc Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Feb 2018 11:12:21 +0100 Subject: [PATCH 242/567] REFAC: cleaning commented code --- .../src/otbWrapperInputImageParameterDouble.cxx | 5 ----- .../src/otbWrapperInputImageParameterFloat.cxx | 5 ----- .../src/otbWrapperInputImageParameterInt16.cxx | 5 ----- .../src/otbWrapperInputImageParameterInt32.cxx | 5 ----- .../src/otbWrapperInputImageParameterUInt16.cxx | 5 ----- .../src/otbWrapperInputImageParameterUInt32.cxx | 5 ----- .../src/otbWrapperInputImageParameterUInt8.cxx | 5 ----- 7 files changed, 35 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx index c15afe0456..c0676eac9f 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx @@ -31,10 +31,5 @@ namespace Wrapper { otbGetImageMacro(DoubleImage); otbGetImageMacro(DoubleVectorImage) -/* -otbGenericCastImageMacro(DoubleImageType, SimpleCastImage, ) -otbGenericCastImageMacro(DoubleVectorImageType, SimpleCastImage, Vector) -otbGenericCastImageMacro(DoubleImageType, CastVectorImageFromImage, Vector) -*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx index 22f6885901..07648108de 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx @@ -31,10 +31,5 @@ namespace Wrapper { otbGetImageMacro(FloatImage); otbGetImageMacro(FloatVectorImage) -/* -otbGenericCastImageMacro(FloatImageType, SimpleCastImage, ) -otbGenericCastImageMacro(FloatVectorImageType, SimpleCastImage, Vector) -otbGenericCastImageMacro(FloatImageType, CastVectorImageFromImage, Vector) -*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx index 814df43810..39c5ec5641 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx @@ -31,10 +31,5 @@ namespace Wrapper { otbGetImageMacro(Int16Image); otbGetImageMacro(Int16VectorImage) -/* -otbGenericCastImageMacro(Int16ImageType, SimpleCastImage, ) -otbGenericCastImageMacro(Int16VectorImageType, SimpleCastImage, Vector) -otbGenericCastImageMacro(Int16ImageType, CastVectorImageFromImage, Vector) -*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx index cc5aa176b8..29679a5e39 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx @@ -31,10 +31,5 @@ namespace Wrapper { otbGetImageMacro(Int32Image); otbGetImageMacro(Int32VectorImage) -/* -otbGenericCastImageMacro(Int32ImageType, SimpleCastImage, ) -otbGenericCastImageMacro(Int32VectorImageType, SimpleCastImage, Vector) -otbGenericCastImageMacro(Int32ImageType, CastVectorImageFromImage, Vector) -*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx index 9b53c906c5..23c64f3c7a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx @@ -31,10 +31,5 @@ namespace Wrapper { otbGetImageMacro(UInt16Image); otbGetImageMacro(UInt16VectorImage) -/* -otbGenericCastImageMacro(UInt16ImageType, SimpleCastImage, ) -otbGenericCastImageMacro(UInt16VectorImageType, SimpleCastImage, Vector) -otbGenericCastImageMacro(UInt16ImageType, CastVectorImageFromImage, Vector) -*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx index d0f6f770f7..b4ae369742 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx @@ -31,10 +31,5 @@ namespace Wrapper { otbGetImageMacro(UInt32Image); otbGetImageMacro(UInt32VectorImage) -/* -otbGenericCastImageMacro(UInt32ImageType, SimpleCastImage, ) -otbGenericCastImageMacro(UInt32VectorImageType, SimpleCastImage, Vector) -otbGenericCastImageMacro(UInt32ImageType, CastVectorImageFromImage, Vector) -*/ } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx index 205fd80394..19b9544d45 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx @@ -31,10 +31,5 @@ namespace Wrapper { otbGetImageMacro(UInt8Image); otbGetImageMacro(UInt8VectorImage) -/* -otbGenericCastImageMacro(UInt8ImageType, SimpleCastImage, ) -otbGenericCastImageMacro(UInt8VectorImageType, SimpleCastImage, Vector) -otbGenericCastImageMacro(UInt8ImageType, CastVectorImageFromImage, Vector) -*/ } } -- GitLab From 62f1f7fa66c452e525199d3f71e0ed81a1e17ac6 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 14 Feb 2018 11:33:31 +0100 Subject: [PATCH 243/567] DOC: add some guidelines for gitlab --- CONTRIBUTING.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9225b00675..bc96c95933 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -127,3 +127,21 @@ OTB source code. Under some conditions (dependencies, official acceptance process, etc.), we are also able to distribute your remote module in the official standalone binaries. See [the wiki](https://wiki.orfeo-toolbox.org/index.php/Remote_Modules) for more information. + +## Gitlab guidelines + +In order to organize the issues in our Gitlab instance, we use both labels and +milestones. + +The [milestones](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/milestones) should be used to track in which release a feature is merged. +Gitlab can then provide a summary of all features and bugs added to a given release +version. + +Regarding labels, we use the following set: +* ~story: significant feature to be implemented with a detailed work plan, it can + correspond to a Request for Comments that has turned into a development action +* ~bug: Bug, crash or unexpected behavior, reported by a user or a developer +* ~feature: Feature request expressed by an OTB user/developer +* ~"To Do": action is planned +* ~Doing: work in progress +* ~api ~app ~documentation ~monteverdi ~packaging ~qgis: optional context information -- GitLab From e686968fbfda3a14abcc44aea3f9ed523796478b Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Feb 2018 11:48:08 +0100 Subject: [PATCH 244/567] REFAC: Major cleaning of commented code --- .../include/otbWrapperApplication.h | 25 -- .../otbWrapperComplexInputImageParameter.h | 39 --- .../otbWrapperComplexInputImageParameter.txx | 38 --- .../otbWrapperComplexOutputImageParameter.h | 8 - .../include/otbWrapperInputImageParameter.h | 95 ------ .../include/otbWrapperInputImageParameter.txx | 48 --- .../include/otbWrapperOutputImageParameter.h | 37 --- .../ApplicationEngine/src/CMakeLists.txt | 7 - .../otbWrapperComplexOutputImageParameter.cxx | 42 --- .../src/otbWrapperOutputImageParameter.cxx | 279 +----------------- 10 files changed, 1 insertion(+), 617 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 2adac86793..c6317be142 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -635,31 +635,6 @@ public: otbGetParameterImageMacro(ComplexFloatVectorImage); otbGetParameterImageMacro(ComplexDoubleVectorImage); - /* Get a complex image value - * - * Can be called for types : - * \li ParameterType_ComplexInputImage - */ -/* -#define otbGetParameterComplexImageMacro( Image ) \ - Image##Type * GetParameter##Image( std::string parameter ) \ - { \ - Image##Type::Pointer ret; \ - Parameter* param = GetParameterByKey(parameter); \ - ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*>(param); \ - if (paramDown) \ - { \ - ret = paramDown->Get##Image(); \ - } \ - return ret; \ - } - - otbGetParameterComplexImageMacro(ComplexFloatImage); - otbGetParameterComplexImageMacro(ComplexDoubleImage); - - otbGetParameterComplexImageMacro(ComplexFloatVectorImage); - otbGetParameterComplexImageMacro(ComplexDoubleVectorImage);*/ - /* Get an image list value * * Can be called for types : diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h index 6c6d96c07e..264967e376 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h @@ -106,15 +106,6 @@ the macro otbGetParameterImageMacro of otbWrapperApplication.h */ template <class TComplexInputImage, class TOutputImage> TOutputImage* CastImage(); - /** Cast an image to an image of the same type - * Image to Image, VectorImage to VectorImage, RGBAImage to RGBAImage. */ - // template <class TComplexInputImage, class TOutputImage> - // TOutputImage* SimpleCastImage(); - - /** Cast an image to a vector image. */ - // template <class TComplexInputImage, class TOutputImage> - // TOutputImage* CastVectorImageFromImage(); - bool HasValue() const ITK_OVERRIDE; void ClearValue() ITK_OVERRIDE; @@ -132,9 +123,6 @@ protected: /** Readers typedefs */ - // typedef otb::ImageFileReader<ComplexFloatImageType> ComplexFloatReaderType; - // typedef otb::ImageFileReader<ComplexDoubleImageType> ComplexDoubleReaderType; - typedef otb::ImageFileReader<ComplexFloatVectorImageType> ComplexFloatVectorReaderType; typedef otb::ImageFileReader<ComplexDoubleVectorImageType> ComplexDoubleVectorReaderType; @@ -153,33 +141,6 @@ private: }; // End class ComplexInputImage Parameter - -// template specializations of CastImage<> should be declared in header -// so that the linker knows they exist when building OTB Applications - -/*#define otbDefineCastImageMacro(ComplexInputImageType, OutputImageType) \ - template<> OutputImageType * \ - ComplexInputImageParameter::CastImage<ComplexInputImageType , OutputImageType>(); \ - -#define otbGenericDefineCastImageMacro(ComplexInputImageType, prefix) \ - otbDefineCastImageMacro(ComplexInputImageType, ComplexFloat##prefix##ImageType) \ - otbDefineCastImageMacro(ComplexInputImageType, ComplexDouble##prefix##ImageType) -*/ - -/******************************************************************** -********************** Image -> Image -*********************************************************************/ - -// otbGenericDefineCastImageMacro(ComplexFloatImageType, ) -// otbGenericDefineCastImageMacro(ComplexDoubleImageType, ) - - -/********************************************************************* -********************** VectorImage -> VectorImage -**********************************************************************/ -// otbGenericDefineCastImageMacro(ComplexFloatVectorImageType, Vector) -// otbGenericDefineCastImageMacro(ComplexDoubleVectorImageType, Vector) - } // End namespace Wrapper } // End namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx index 99209d593f..92e8dfd32e 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx @@ -153,44 +153,6 @@ ComplexInputImageParameter::CastImage() // <<" to "<<typeid(TOutputImage).name()<<" not authorized."); } - -/*template <class TComplexInputImage, class TOutputImage> -TOutputImage* -ComplexInputImageParameter::SimpleCastImage() -{ - TComplexInputImage* realComplexInputImage = dynamic_cast<TComplexInputImage*>(m_Image.GetPointer()); - - typedef itk::CastImageFilter<TComplexInputImage, TOutputImage> CasterType; - typename CasterType::Pointer caster = CasterType::New(); - - caster->SetInput(realComplexInputImage); - caster->UpdateOutputInformation(); - - m_Image = caster->GetOutput(); - m_Caster = caster; - - return caster->GetOutput(); -} - - -template <class TComplexInputImage, class TOutputImage> -TOutputImage* -ComplexInputImageParameter::CastVectorImageFromImage() -{ - TComplexInputImage* realComplexInputImage = dynamic_cast<TComplexInputImage*>(m_Image.GetPointer()); - - typedef ImageToVectorImageCastFilter<TComplexInputImage, TOutputImage> CasterType; - typename CasterType::Pointer caster = CasterType::New(); - - caster->SetInput(realComplexInputImage); - caster->UpdateOutputInformation(); - - m_Image = caster->GetOutput(); - m_Caster = caster; - - return caster->GetOutput(); -}*/ - template <class TComplexInputImage> void ComplexInputImageParameter::SetImage(TComplexInputImage* image) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h index b5af8187c9..0613816b47 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h @@ -122,24 +122,16 @@ protected: template <class TInputVectorImageType> void SwitchVectorImageWrite(); - //FloatVectorImageType::Pointer m_Image; ImageBaseType::Pointer m_Image; std::string m_FileName; ComplexImagePixelType m_ComplexPixelType; ComplexImagePixelType m_DefaultComplexPixelType; - // typedef otb::ImageFileWriter<ComplexFloatImageType> ComplexFloatWriterType; - // typedef otb::ImageFileWriter<ComplexDoubleImageType> ComplexDoubleWriterType; - typedef otb::ImageFileWriter<ComplexInt16VectorImageType> ComplexVectorInt16WriterType; typedef otb::ImageFileWriter<ComplexInt32VectorImageType> ComplexVectorInt32WriterType; typedef otb::ImageFileWriter<ComplexFloatVectorImageType> ComplexVectorFloatWriterType; typedef otb::ImageFileWriter<ComplexDoubleVectorImageType> ComplexVectorDoubleWriterType; - - // ComplexFloatWriterType::Pointer m_ComplexFloatWriter; - // ComplexDoubleWriterType::Pointer m_ComplexDoubleWriter; - ComplexVectorInt16WriterType::Pointer m_ComplexVectorInt16Writer; ComplexVectorInt32WriterType::Pointer m_ComplexVectorInt32Writer; ComplexVectorFloatWriterType::Pointer m_ComplexVectorFloatWriter; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h index 5cbcbc587a..3f83839de1 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h @@ -107,17 +107,6 @@ public: template <class TInputImage, class TOutputImage> TOutputImage* CastImage(); - /** Cast an image to an image of the same type - * Image to Image, VectorImage to VectorImage, RGBAImage to RGBAImage. */ - // template <class TInputImage, class TOutputImage> - // TOutputImage* SimpleCastImage(); - - - /** Cast an image to a vector image. */ - // template <class TInputImage, class TOutputImage> - // TOutputImage* CastVectorImageFromImage(); - - bool HasValue() const ITK_OVERRIDE; void ClearValue() ITK_OVERRIDE; @@ -181,90 +170,6 @@ private: }; // End class InputImage Parameter - -// template specializations of CastImage<> should be declared in header -// so that the linker knows they exist when building OTB Applications -/* -#define otbDeclareCastImageMacro(InputImageType, OutputImageType) \ - template<> OTBApplicationEngine_EXPORT OutputImageType * \ - InputImageParameter::CastImage<InputImageType , OutputImageType>(); \ - -#define otbGenericDeclareCastImageMacro(InputImageType, prefix) \ - otbDeclareCastImageMacro(InputImageType, UInt8##prefix##ImageType) \ - otbDeclareCastImageMacro(InputImageType, UInt16##prefix##ImageType) \ - otbDeclareCastImageMacro(InputImageType, Int16##prefix##ImageType) \ - otbDeclareCastImageMacro(InputImageType, UInt32##prefix##ImageType) \ - otbDeclareCastImageMacro(InputImageType, Int32##prefix##ImageType) \ - otbDeclareCastImageMacro(InputImageType, Float##prefix##ImageType) \ - otbDeclareCastImageMacro(InputImageType, Double##prefix##ImageType) -*/ - -/********************************************************************* -********************** Image -> Image -**********************************************************************/ -/* -otbGenericDeclareCastImageMacro(UInt8ImageType, ) -otbGenericDeclareCastImageMacro(Int16ImageType, ) -otbGenericDeclareCastImageMacro(UInt16ImageType, ) -otbGenericDeclareCastImageMacro(Int32ImageType, ) -otbGenericDeclareCastImageMacro(UInt32ImageType, ) -otbGenericDeclareCastImageMacro(FloatImageType, ) -otbGenericDeclareCastImageMacro(DoubleImageType, ) - -otbDeclareCastImageMacro( ComplexDoubleImageType , ComplexDoubleImageType ) -otbDeclareCastImageMacro( ComplexDoubleImageType , ComplexFloatImageType ) - -otbDeclareCastImageMacro( ComplexFloatImageType , ComplexDoubleImageType ) -otbDeclareCastImageMacro( ComplexFloatImageType , ComplexFloatImageType ) -*/ - -/********************************************************************* -********************** VectorImage -> VectorImage -**********************************************************************/ -/* -otbGenericDeclareCastImageMacro(UInt8VectorImageType, Vector) -otbGenericDeclareCastImageMacro(Int16VectorImageType, Vector) -otbGenericDeclareCastImageMacro(UInt16VectorImageType, Vector) -otbGenericDeclareCastImageMacro(Int32VectorImageType, Vector) -otbGenericDeclareCastImageMacro(UInt32VectorImageType, Vector) -otbGenericDeclareCastImageMacro(FloatVectorImageType, Vector) -otbGenericDeclareCastImageMacro(DoubleVectorImageType, Vector) - -otbDeclareCastImageMacro( ComplexDoubleVectorImageType , - ComplexDoubleVectorImageType ) -otbDeclareCastImageMacro( ComplexDoubleVectorImageType , - ComplexFloatVectorImageType ) - -otbDeclareCastImageMacro( ComplexFloatVectorImageType , - ComplexDoubleVectorImageType ) -otbDeclareCastImageMacro( ComplexFloatVectorImageType , - ComplexFloatVectorImageType ) -*/ -/********************************************************************* -********************** Image -> VectorImage -**********************************************************************/ -/* -otbGenericDeclareCastImageMacro(UInt8ImageType, Vector) -otbGenericDeclareCastImageMacro(Int16ImageType, Vector) -otbGenericDeclareCastImageMacro(UInt16ImageType, Vector) -otbGenericDeclareCastImageMacro(Int32ImageType, Vector) -otbGenericDeclareCastImageMacro(UInt32ImageType, Vector) -otbGenericDeclareCastImageMacro(FloatImageType, Vector) -otbGenericDeclareCastImageMacro(DoubleImageType, Vector) - -otbDeclareCastImageMacro( ComplexDoubleImageType , - ComplexDoubleVectorImageType ) -otbDeclareCastImageMacro( ComplexDoubleImageType , - ComplexFloatVectorImageType ) - -otbDeclareCastImageMacro( ComplexFloatImageType , ComplexDoubleVectorImageType ) -otbDeclareCastImageMacro( ComplexFloatImageType , ComplexFloatVectorImageType ) - - -#undef otbDeclareCastImageMacro -#undef otbGenericDeclareCastImageMacro -*/ - } // End namespace Wrapper } // End namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx index 0beb76ad1f..74e7385133 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx @@ -24,8 +24,6 @@ #include "otbWrapperInputImageParameter.h" #include "itkUnaryFunctorImageFilter.h" -// #include "itkCastImageFilter.h" -// #include "otbImageToVectorImageCastFilter.h" #include "otbClampImageFilter.h" namespace otb @@ -246,52 +244,6 @@ InputImageParameter::CastImage() // itkExceptionMacro("Cast from "<<typeid(TInputImage).name()<<" to "<<typeid(TOutputImage).name()<<" not authorized."); } - - -/*template <class TInputImage, class TOutputImage> -TOutputImage* -InputImageParameter::SimpleCastImage() -{ - if ( dynamic_cast<TOutputImage*> (m_Image.GetPointer()) ) - { - return dynamic_cast<TOutputImage*> (m_Image.GetPointer()); - } - else - { - TInputImage* realInputImage = dynamic_cast<TInputImage*>(m_Image.GetPointer()); - - typedef ClampImageFilter<TInputImage, TOutputImage> CasterType; - typename CasterType::Pointer caster = CasterType::New(); - - caster->SetInput(realInputImage); - caster->UpdateOutputInformation(); - - m_Image = caster->GetOutput(); - m_Caster = caster; - - return caster->GetOutput(); - } -} - -template <class TInputImage, class TOutputImage> -TOutputImage* -InputImageParameter::CastVectorImageFromImage() -{ - TInputImage* realInputImage = dynamic_cast<TInputImage*>(m_Image.GetPointer()); - - typedef ClampImageFilter<TInputImage, TOutputImage> CasterType; - typename CasterType::Pointer caster = CasterType::New(); - - caster->SetInput(realInputImage); - caster->UpdateOutputInformation(); - - m_Image = caster->GetOutput(); - m_Caster = caster; - - return caster->GetOutput(); -} -*/ - template <class TInputImage> void InputImageParameter::SetImage(TInputImage* image) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index e508b8528f..fd0c392b70 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -119,18 +119,9 @@ protected: /** Destructor */ ~OutputImageParameter() ITK_OVERRIDE; - // template <class TInputImageType> - // void SwitchImageWrite(); - - // template <class TInputImageType> - // void SwitchCImageWrite(); - template <class TInputVectorImageType> void SwitchVectorImageWrite(); - // template <class TInputVectorImageType> - // void SwitchVectorCImageWrite(); - template <class TInputVectorImageType> void SwitchRGBImageWrite(); @@ -143,14 +134,6 @@ protected: ImagePixelType m_PixelType; ImagePixelType m_DefaultPixelType; - // typedef otb::ImageFileWriter<UInt8ImageType> UInt8WriterType; - // typedef otb::ImageFileWriter<Int16ImageType> Int16WriterType; - // typedef otb::ImageFileWriter<UInt16ImageType> UInt16WriterType; - // typedef otb::ImageFileWriter<Int32ImageType> Int32WriterType; - // typedef otb::ImageFileWriter<UInt32ImageType> UInt32WriterType; - // typedef otb::ImageFileWriter<FloatImageType> FloatWriterType; - // typedef otb::ImageFileWriter<DoubleImageType> DoubleWriterType; - typedef otb::ImageFileWriter<UInt8VectorImageType> VectorUInt8WriterType; typedef otb::ImageFileWriter<Int16VectorImageType> VectorInt16WriterType; typedef otb::ImageFileWriter<UInt16VectorImageType> VectorUInt16WriterType; @@ -162,26 +145,11 @@ protected: typedef otb::ImageFileWriter<UInt8RGBAImageType> RGBAUInt8WriterType; typedef otb::ImageFileWriter<UInt8RGBImageType> RGBUInt8WriterType; - // Complex Image - // typedef otb::ImageFileWriter<ComplexInt16ImageType> ComplexInt16WriterType; - // typedef otb::ImageFileWriter<ComplexInt32ImageType> ComplexInt32WriterType; - // typedef otb::ImageFileWriter<ComplexFloatImageType> ComplexFloatWriterType; - // typedef otb::ImageFileWriter<ComplexDoubleImageType> ComplexDoubleWriterType; - typedef otb::ImageFileWriter<ComplexInt16VectorImageType> ComplexVectorInt16WriterType; typedef otb::ImageFileWriter<ComplexInt32VectorImageType> ComplexVectorInt32WriterType; typedef otb::ImageFileWriter<ComplexFloatVectorImageType> ComplexVectorFloatWriterType; typedef otb::ImageFileWriter<ComplexDoubleVectorImageType> ComplexVectorDoubleWriterType; - - // UInt8WriterType::Pointer m_UInt8Writer; - // Int16WriterType::Pointer m_Int16Writer; - // UInt16WriterType::Pointer m_UInt16Writer; - // Int32WriterType::Pointer m_Int32Writer; - // UInt32WriterType::Pointer m_UInt32Writer; - // FloatWriterType::Pointer m_FloatWriter; - // DoubleWriterType::Pointer m_DoubleWriter; - VectorUInt8WriterType::Pointer m_VectorUInt8Writer; VectorInt16WriterType::Pointer m_VectorInt16Writer; VectorUInt16WriterType::Pointer m_VectorUInt16Writer; @@ -193,11 +161,6 @@ protected: RGBUInt8WriterType::Pointer m_RGBUInt8Writer; RGBAUInt8WriterType::Pointer m_RGBAUInt8Writer; - // ComplexInt16WriterType::Pointer m_ComplexInt16Writer; - // ComplexInt32WriterType::Pointer m_ComplexInt32Writer; - // ComplexFloatWriterType::Pointer m_ComplexFloatWriter; - // ComplexDoubleWriterType::Pointer m_ComplexDoubleWriter; - ComplexVectorInt16WriterType::Pointer m_ComplexVectorInt16Writer; ComplexVectorInt32WriterType::Pointer m_ComplexVectorInt32Writer; ComplexVectorFloatWriterType::Pointer m_ComplexVectorFloatWriter; diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 43482246ac..45d0427a49 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -31,13 +31,6 @@ set( OTBApplicationEngine_SRC otbWrapperInputFilenameListParameter.cxx otbWrapperOutputImageParameter.cxx otbWrapperInputImageParameter.cxx - #otbWrapperInputImageParameterUInt8.cxx - #otbWrapperInputImageParameterInt16.cxx - #otbWrapperInputImageParameterUInt16.cxx - #otbWrapperInputImageParameterInt32.cxx - #otbWrapperInputImageParameterUInt32.cxx - #otbWrapperInputImageParameterFloat.cxx - #otbWrapperInputImageParameterDouble.cxx otbWrapperParameterKey.cxx otbWrapperDocExampleStructure.cxx otbWrapperInputVectorDataParameter.cxx diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx index d08fe73062..6d86118c45 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx @@ -21,8 +21,6 @@ #include "otbWrapperComplexOutputImageParameter.h" #include "itkUnaryFunctorImageFilter.h" #include "otbClampImageFilter.h" -// #include "itkCastImageFilter.h" -// #include "itkVectorCastImageFilter.h" #ifdef OTB_USE_MPI @@ -102,9 +100,6 @@ ComplexOutputImageParameter::ConvertStringToPixelType(const std::string &value, void ComplexOutputImageParameter::InitializeWriters() { - // m_ComplexFloatWriter = ComplexFloatWriterType::New(); - // m_ComplexDoubleWriter = ComplexDoubleWriterType::New(); - m_ComplexVectorInt16Writer = ComplexVectorInt16WriterType::New(); m_ComplexVectorInt32Writer = ComplexVectorInt32WriterType::New(); m_ComplexVectorFloatWriter = ComplexVectorFloatWriterType::New(); @@ -213,27 +208,6 @@ ComplexOutputImageParameter::SwitchImageWrite() } } - -// template <class TInputVectorImageType> -// void -// ComplexOutputImageParameter::SwitchVectorImageWrite() -// { -// switch(m_ComplexPixelType ) -// { -// case ComplexImagePixelType_float: -// { -// CastAndWriteImage<TInputVectorImageType,ComplexFloatVectorImageType>(m_Image,m_ComplexVectorFloatWriter,m_FileName,m_RAMValue); -// break; -// } -// case ComplexImagePixelType_double: -// { -// CastAndWriteImage<TInputVectorImageType,ComplexDoubleVectorImageType>(m_Image,m_ComplexVectorDoubleWriter,m_FileName,m_RAMValue); -// break; -// } -// } -// } - - void ComplexOutputImageParameter::Write() { @@ -279,16 +253,6 @@ ComplexOutputImageParameter::Write() itk::ProcessObject* ComplexOutputImageParameter::GetWriter() { - // int type = 1; - // 0 : image - // 1 : VectorImage - - // if ( dynamic_cast<ComplexFloatVectorImageType*>( m_Image.GetPointer()) || - // dynamic_cast<ComplexDoubleVectorImageType*>(m_Image.GetPointer())) - // { - // type = 1; - // } - itk::ProcessObject* writer = ITK_NULLPTR; switch ( GetComplexPixelType() ) { @@ -302,18 +266,12 @@ ComplexOutputImageParameter::GetWriter() } case ComplexImagePixelType_float: { - // if( type == 1 ) writer = m_ComplexVectorFloatWriter; - // else - // writer = m_ComplexFloatWriter; break; } case ComplexImagePixelType_double: { - // if( type == 1 ) writer = m_ComplexVectorDoubleWriter; - // else - // writer = m_ComplexDoubleWriter; break; } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index b6585a33b8..d0dd667879 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -149,14 +149,6 @@ OutputImageParameter::ConvertStringToPixelType(const std::string &value, ImagePi void OutputImageParameter::InitializeWriters() { - // m_UInt8Writer = UInt8WriterType::New(); - // m_Int16Writer = Int16WriterType::New(); - // m_UInt16Writer = UInt16WriterType::New(); - // m_Int32Writer = Int32WriterType::New(); - // m_UInt32Writer = UInt32WriterType::New(); - // m_FloatWriter = FloatWriterType::New(); - // m_DoubleWriter = DoubleWriterType::New(); - m_VectorUInt8Writer = VectorUInt8WriterType::New(); m_VectorInt16Writer = VectorInt16WriterType::New(); m_VectorUInt16Writer = VectorUInt16WriterType::New(); @@ -168,11 +160,6 @@ void OutputImageParameter::InitializeWriters() m_RGBUInt8Writer = RGBUInt8WriterType::New(); m_RGBAUInt8Writer = RGBAUInt8WriterType::New(); - // m_ComplexInt16Writer = ComplexInt16WriterType::New(); - // m_ComplexInt32Writer = ComplexInt32WriterType::New(); - // m_ComplexFloatWriter = ComplexFloatWriterType::New(); - // m_ComplexDoubleWriter = ComplexDoubleWriterType::New(); - m_ComplexVectorInt16Writer = ComplexVectorInt16WriterType::New(); m_ComplexVectorInt32Writer = ComplexVectorInt32WriterType::New(); m_ComplexVectorFloatWriter = ComplexVectorFloatWriterType::New(); @@ -243,205 +230,6 @@ ClampAndWriteVectorImage( itk::ImageBase<2> * in , } } -/*template <typename TInput, typename TOutput > -void -ClampAndWriteImage( itk::ImageBase<2> * in , - otb::ImageFileWriter<TOutput > * writer , - const std::string & filename , - const unsigned int & ramValue , - typename itk::ImageToImageFilter< TInput , TOutput > * clampFilter = otb::ClampImageFilter< TInput , TOutput >::New() ) -{ - clampFilter->SetInput( dynamic_cast<TInput*>(in)); - - bool useStandardWriter = true; - -#ifdef OTB_USE_MPI - - otb::MPIConfig::Pointer mpiConfig = otb::MPIConfig::Instance(); - - if (mpiConfig->GetNbProcs() > 1) - { - useStandardWriter = false; - - // Get file extension - std::string extension = itksys::SystemTools::GetFilenameExtension(filename); - - if(extension == ".vrt") - { - // Use the WriteMPI function - WriteMPI(clampFilter->GetOutput(),filename,ramValue); - } - #ifdef OTB_USE_SPTW - else if (extension == ".tif") - { - // Use simple parallel tiff writer - typedef otb::SimpleParallelTiffWriter<TOutput> SPTWriterType; - - typename SPTWriterType::Pointer sptWriter = SPTWriterType::New(); - sptWriter->SetFileName(filename); - sptWriter->SetInput(clampFilter->GetOutput()); - sptWriter->SetAutomaticAdaptativeStreaming(ramValue); - sptWriter->Update(); - } - - #endif - else - { - itkGenericExceptionMacro("File format "<<extension<<" not supported for parallel writing with MPI. Supported formats are .vrt and .tif. Extended filenames are not supported."); - } - } - #endif - - if(useStandardWriter) - { - - writer->SetFileName( filename ); - writer->SetInput(clampFilter->GetOutput()); - writer->SetAutomaticAdaptativeStreaming(ramValue); - writer->Update(); - } -}*/ - -/*template <class TInput> -void -OutputImageParameter::SwitchImageWrite() -{ - switch(m_PixelType ) - { - case ImagePixelType_uint8: - { - ClampAndWriteImage< TInput , UInt8ImageType >( - m_Image , - m_UInt8Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_int16: - { - ClampAndWriteImage< TInput , Int16ImageType >( - m_Image , - m_Int16Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_uint16: - { - ClampAndWriteImage< TInput , UInt16ImageType >( - m_Image , - m_UInt16Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_int32: - { - ClampAndWriteImage< TInput , Int32ImageType >( - m_Image , - m_Int32Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_uint32: - { - ClampAndWriteImage< TInput , UInt32ImageType >( - m_Image , - m_UInt32Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_float: - { - ClampAndWriteImage< TInput , FloatImageType >( - m_Image , - m_FloatWriter , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_double: - { - ClampAndWriteImage< TInput , DoubleImageType >( - m_Image , - m_DoubleWriter , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_cint16: - { - ClampAndWriteImage< TInput , ComplexInt16ImageType >( - m_Image , - m_ComplexInt16Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_cint32: - { - ClampAndWriteImage< TInput , ComplexInt32ImageType >( - m_Image , - m_ComplexInt32Writer , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_cfloat: - { - ClampAndWriteImage< TInput , ComplexFloatImageType >( - m_Image , - m_ComplexFloatWriter , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_cdouble: - { - ClampAndWriteImage< TInput , ComplexDoubleImageType >( - m_Image , - m_ComplexDoubleWriter , - m_FileName , - m_RAMValue ); - break; - } - default: - break; - } -}*/ - -/*template <class TInput> -void -OutputImageParameter::SwitchCImageWrite() -{ - switch(m_PixelType ) - { - case ImagePixelType_cfloat: - { - ClampAndWriteImage< TInput , ComplexFloatImageType >( - m_Image , - m_ComplexFloatWriter , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_cdouble: - { - ClampAndWriteImage< TInput , ComplexDoubleImageType >( - m_Image , - m_ComplexDoubleWriter , - m_FileName , - m_RAMValue ); - break; - } - default: - break; - } -}*/ - - template <class TInput> void OutputImageParameter::SwitchVectorImageWrite() @@ -552,35 +340,6 @@ OutputImageParameter::SwitchVectorImageWrite() } } -/*template <class TInput> -void -OutputImageParameter::SwitchVectorCImageWrite() -{ - switch(m_PixelType ) - { - case ImagePixelType_cfloat: - { - ClampAndWriteImage< TInput , ComplexFloatVectorImageType >( - m_Image , - m_ComplexVectorFloatWriter , - m_FileName , - m_RAMValue ); - break; - } - case ImagePixelType_cdouble: - { - ClampAndWriteImage< TInput , ComplexDoubleVectorImageType >( - m_Image , - m_ComplexVectorDoubleWriter , - m_FileName , - m_RAMValue ); - break; - } - default: - break; - } -}*/ - template <class TInputRGBAImageType> void OutputImageParameter::SwitchRGBAImageWrite() @@ -728,20 +487,7 @@ OutputImageParameter::GetWriter() // 2 : RGBAImage // 3 : RGBImage itk::ProcessObject* writer = ITK_NULLPTR; - // if (dynamic_cast<UInt8VectorImageType*> (m_Image.GetPointer()) - // || dynamic_cast<Int16VectorImageType*> (m_Image.GetPointer()) - // || dynamic_cast<UInt16VectorImageType*> (m_Image.GetPointer()) - // || dynamic_cast<Int32VectorImageType*> (m_Image.GetPointer()) - // || dynamic_cast<UInt32VectorImageType*> (m_Image.GetPointer()) - // || dynamic_cast<FloatVectorImageType*> (m_Image.GetPointer()) - // || dynamic_cast<DoubleVectorImageType*> (m_Image.GetPointer()) - // || dynamic_cast<ComplexInt16VectorImageType*> (m_Image.GetPointer()) - // || dynamic_cast<ComplexInt32VectorImageType*> (m_Image.GetPointer()) - // || dynamic_cast<ComplexFloatVectorImageType*> (m_Image.GetPointer()) - // || dynamic_cast<ComplexDoubleVectorImageType*> (m_Image.GetPointer())) - // { - // type = 1; - // } + if (dynamic_cast<UInt8RGBAImageType*> (m_Image.GetPointer())) { type = 2; @@ -763,9 +509,6 @@ OutputImageParameter::GetWriter() { switch(type) { - // case 0: - // writer = m_UInt8Writer; - // break; case 1: writer = m_VectorUInt8Writer; break; @@ -782,80 +525,60 @@ OutputImageParameter::GetWriter() { if (type == 1) writer = m_VectorInt16Writer; - // else - // if (type == 0) writer = m_Int16Writer; break; } case ImagePixelType_uint16: { if (type == 1) writer = m_VectorUInt16Writer; - // else - // if (type == 0) writer = m_UInt16Writer; break; } case ImagePixelType_int32: { if (type == 1) writer = m_VectorInt32Writer; - // else - // if (type == 0) writer = m_Int32Writer; break; } case ImagePixelType_uint32: { if (type == 1) writer = m_VectorUInt32Writer; - // else - // if (type == 0) writer = m_UInt32Writer; break; } case ImagePixelType_float: { if (type == 1) writer = m_VectorFloatWriter; - // else - // if (type == 0) writer = m_FloatWriter; break; } case ImagePixelType_double: { if (type == 1) writer = m_VectorDoubleWriter; - // else - // if (type == 0) writer = m_DoubleWriter; break; } case ImagePixelType_cint16: { if( type == 1 ) writer = m_ComplexVectorInt16Writer; - // else - // writer = m_ComplexInt16Writer; break; } case ImagePixelType_cint32: { if( type == 1 ) writer = m_ComplexVectorInt32Writer; - // else - // writer = m_ComplexInt32Writer; break; } case ImagePixelType_cfloat: { if( type == 1 ) writer = m_ComplexVectorFloatWriter; - // else - // writer = m_ComplexFloatWriter; break; } case ImagePixelType_cdouble: { if( type == 1 ) writer = m_ComplexVectorDoubleWriter; - // else - // writer = m_ComplexDoubleWriter; break; } } -- GitLab From 7d9ca32f7f67b556be40380b0eb8ee581ea9cdf3 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Feb 2018 14:14:30 +0100 Subject: [PATCH 245/567] ENH: change static const for static constexpr --- .../include/otbConvertTypeFunctor.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h index baa659e785..c5a73b5cb1 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbConvertTypeFunctor.h @@ -26,7 +26,6 @@ #include <boost/type_traits/is_complex.hpp> #include <boost/type_traits/is_scalar.hpp> -#include "itkVariableLengthVector.h" #include "itkNumericTraits.h" #include "otbDefaultConvertPixelTraits.h" @@ -49,11 +48,16 @@ public: typedef typename itk::NumericTraits < InputInternalPixelType > :: ValueType InputPixelValueType; typedef typename itk::NumericTraits < OutputInternalPixelType > :: ValueType OutputPixelValueType; - ConvertTypeFunctor() : - m_cInPix ( boost::is_complex < InputPixelType > :: value ) , - m_cOutPix ( boost::is_complex < OutputPixelType > :: value ) , - m_cInInternalPix ( boost::is_complex < InputInternalPixelType > :: value ) , - m_cOutInternalPix ( boost::is_complex < OutputInternalPixelType > :: value ) + static constexpr bool m_cInPix = boost::is_complex < InputPixelType > :: value ; + static constexpr bool m_cOutPix = boost::is_complex < OutputPixelType > :: value ; + static constexpr bool m_cInInternalPix = boost::is_complex < InputInternalPixelType > :: value ; + static constexpr bool m_cOutInternalPix = boost::is_complex < OutputInternalPixelType > :: value ; + + ConvertTypeFunctor() + // m_cInPix ( boost::is_complex < InputPixelType > :: value ) , + // m_cOutPix ( boost::is_complex < OutputPixelType > :: value ) , + // m_cInInternalPix ( boost::is_complex < InputInternalPixelType > :: value ) , + // m_cOutInternalPix ( boost::is_complex < OutputInternalPixelType > :: value ) { m_LowestB = std::numeric_limits < OutputPixelValueType >::lowest(); m_HighestB = std::numeric_limits < OutputPixelValueType >::max(); @@ -228,8 +232,7 @@ private: double m_LowestBD , m_HighestBD ; OutputPixelValueType m_LowestB , m_HighestB ; unsigned int m_CompIn , m_CompOut , m_Scal ; - const bool m_cInPix , m_cOutPix , m_cInInternalPix , m_cOutInternalPix ; - + // const bool m_cInPix , m_cOutPix , m_cInInternalPix , m_cOutInternalPix ; }; -- GitLab From ab11c7e102973b8142f895674bd8d503527dd248 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Feb 2018 14:33:27 +0100 Subject: [PATCH 246/567] REFAC: cleaning code --- .../otbWrapperInputImageParameterDouble.cxx | 35 ------ .../otbWrapperInputImageParameterFloat.cxx | 35 ------ .../otbWrapperInputImageParameterInt16.cxx | 35 ------ .../otbWrapperInputImageParameterInt32.cxx | 35 ------ .../src/otbWrapperInputImageParameterMacros.h | 18 --- .../otbWrapperInputImageParameterUInt16.cxx | 35 ------ .../otbWrapperInputImageParameterUInt32.cxx | 35 ------ .../otbWrapperInputImageParameterUInt8.cxx | 35 ------ .../otbWrapperOutputImageParameterTest.cxx | 108 +++++++++--------- 9 files changed, 54 insertions(+), 317 deletions(-) delete mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx delete mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx delete mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx delete mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx delete mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx delete mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx delete mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx deleted file mode 100644 index c0676eac9f..0000000000 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <vcl_deprecated_header.h> -#include "otbWrapperInputImageParameter.h" -#include "itksys/SystemTools.hxx" -#include "otbWrapperTypes.h" -#include "otbWrapperInputImageParameterMacros.h" -#include "otb_boost_string_header.h" - -namespace otb -{ -namespace Wrapper -{ -otbGetImageMacro(DoubleImage); -otbGetImageMacro(DoubleVectorImage) -} -} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx deleted file mode 100644 index 07648108de..0000000000 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <vcl_deprecated_header.h> -#include "otbWrapperInputImageParameter.h" -#include "otbWrapperInputImageParameterMacros.h" -#include "itksys/SystemTools.hxx" -#include "otbWrapperTypes.h" -#include "otb_boost_string_header.h" - -namespace otb -{ -namespace Wrapper -{ -otbGetImageMacro(FloatImage); -otbGetImageMacro(FloatVectorImage) -} -} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx deleted file mode 100644 index 39c5ec5641..0000000000 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <vcl_deprecated_header.h> -#include "otbWrapperInputImageParameter.h" -#include "itksys/SystemTools.hxx" -#include "otbWrapperTypes.h" -#include "otbWrapperInputImageParameterMacros.h" -#include "otb_boost_string_header.h" - -namespace otb -{ -namespace Wrapper -{ -otbGetImageMacro(Int16Image); -otbGetImageMacro(Int16VectorImage) -} -} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx deleted file mode 100644 index 29679a5e39..0000000000 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <vcl_deprecated_header.h> -#include "otbWrapperInputImageParameter.h" -#include "itksys/SystemTools.hxx" -#include "otbWrapperTypes.h" -#include "otbWrapperInputImageParameterMacros.h" -#include "otb_boost_string_header.h" - -namespace otb -{ -namespace Wrapper -{ -otbGetImageMacro(Int32Image); -otbGetImageMacro(Int32VectorImage) -} -} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterMacros.h b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterMacros.h index 3f3525af7a..2f1a7915b4 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterMacros.h +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterMacros.h @@ -33,22 +33,4 @@ otbGetImageMacro(type##VectorImage); -/* -#define otbCastImageMacro(InputImageType, OutputImageType, theMethod) \ - template<> OutputImageType * \ - InputImageParameter::CastImage<InputImageType , OutputImageType>() \ - { \ - return this->theMethod<InputImageType , OutputImageType>(); \ - } - -#define otbGenericCastImageMacro(InputImageType, theMethod, prefix) \ - otbCastImageMacro(InputImageType, UInt8##prefix##ImageType, theMethod) \ - otbCastImageMacro(InputImageType, UInt16##prefix##ImageType, theMethod) \ - otbCastImageMacro(InputImageType, Int16##prefix##ImageType, theMethod) \ - otbCastImageMacro(InputImageType, UInt32##prefix##ImageType, theMethod) \ - otbCastImageMacro(InputImageType, Int32##prefix##ImageType, theMethod) \ - otbCastImageMacro(InputImageType, Float##prefix##ImageType, theMethod) \ - otbCastImageMacro(InputImageType, Double##prefix##ImageType, theMethod) -*/ - #endif diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx deleted file mode 100644 index 23c64f3c7a..0000000000 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <vcl_deprecated_header.h> -#include "otbWrapperInputImageParameter.h" -#include "itksys/SystemTools.hxx" -#include "otbWrapperTypes.h" -#include "otbWrapperInputImageParameterMacros.h" -#include "otb_boost_string_header.h" - -namespace otb -{ -namespace Wrapper -{ -otbGetImageMacro(UInt16Image); -otbGetImageMacro(UInt16VectorImage) -} -} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx deleted file mode 100644 index b4ae369742..0000000000 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <vcl_deprecated_header.h> -#include "otbWrapperInputImageParameter.h" -#include "itksys/SystemTools.hxx" -#include "otbWrapperTypes.h" -#include "otbWrapperInputImageParameterMacros.h" -#include "otb_boost_string_header.h" - -namespace otb -{ -namespace Wrapper -{ -otbGetImageMacro(UInt32Image); -otbGetImageMacro(UInt32VectorImage) -} -} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx deleted file mode 100644 index 19b9544d45..0000000000 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <vcl_deprecated_header.h> -#include "otbWrapperInputImageParameter.h" -#include "itksys/SystemTools.hxx" -#include "otbWrapperTypes.h" -#include "otbWrapperInputImageParameterMacros.h" -#include "otb_boost_string_header.h" - -namespace otb -{ -namespace Wrapper -{ -otbGetImageMacro(UInt8Image); -otbGetImageMacro(UInt8VectorImage) -} -} diff --git a/Modules/Wrappers/ApplicationEngine/test/otbWrapperOutputImageParameterTest.cxx b/Modules/Wrappers/ApplicationEngine/test/otbWrapperOutputImageParameterTest.cxx index 34cbb1d6f1..ea8899b8e0 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbWrapperOutputImageParameterTest.cxx +++ b/Modules/Wrappers/ApplicationEngine/test/otbWrapperOutputImageParameterTest.cxx @@ -62,57 +62,57 @@ int otbWrapperOutputImageParameterTest1(int itkNotUsed(argc), char* argv[]) } -template < typename ImageType > -void Cross( int p , std::string inputfilename, std::string outputfilename) -{ - otb::Wrapper::InputImageParameter::Pointer paramIn ( - otb::Wrapper::InputImageParameter::New() ); - paramIn->SetFromFileName( inputfilename ); - otb::Wrapper::OutputImageParameter::Pointer paramOut( - otb::Wrapper::OutputImageParameter::New() ); - paramOut->SetFileName( outputfilename ); - paramOut->SetImage(paramIn->GetImage<ImageType>()); - paramOut->InitializeWriters(); - paramOut->SetPixelType(static_cast<otb::Wrapper::ImagePixelType>(p)); - paramOut->Write(); -} - - -int otbWrapperOutputImageParameterConversionTest(int , char* argv[]) -{ - std::string filenamein = argv[1]; - std::string filenameout = argv[2] ; - std::string extension = filenameout.substr( filenameout.find_last_of('.') ); - - filenameout = filenameout.substr( 0 , filenameout.find_last_of('.') ); - - for ( int i = otb::Wrapper::ImagePixelType_uint8 ; i < 11 ; i++ ) - { - std::string type = - otb::Wrapper::OutputImageParameter::ConvertPixelTypeToString( - static_cast<otb::Wrapper::ImagePixelType>(i) ); - Cross< otb::Wrapper::UInt8ImageType > (i , filenamein , filenameout+"_UInt8_"+ type + extension ) ; - Cross< otb::Wrapper::Int16ImageType > ( i , filenamein , filenameout+"_Int16_"+ type + extension ) ; - Cross< otb::Wrapper::UInt16ImageType > ( i , filenamein , filenameout+"_UInt16_"+ type + extension ) ; - Cross< otb::Wrapper::Int32ImageType > ( i , filenamein , filenameout+"_Int21_"+ type + extension ) ; - Cross< otb::Wrapper::UInt32ImageType > ( i , filenamein , filenameout+"_UInt32_"+ type + extension ) ; - Cross< otb::Wrapper::FloatImageType > ( i , filenamein , filenameout+"_float_"+ type + extension ) ; - Cross< otb::Wrapper::DoubleImageType > ( i , filenamein , filenameout+"_double_"+ type + extension ) ; - Cross< otb::Wrapper::UInt8VectorImageType > ( i , filenamein , filenameout+"_UInt8Vect_"+ type + extension ) ; - Cross< otb::Wrapper::Int16VectorImageType > ( i , filenamein , filenameout+"_Int16Vect_"+ type + extension ) ; - Cross< otb::Wrapper::UInt16VectorImageType > ( i , filenamein , filenameout+"_UInt16Vect_"+ type + extension ) ; - Cross< otb::Wrapper::Int32VectorImageType > ( i , filenamein , filenameout+"_Int21Vect_"+ type + extension ) ; - Cross< otb::Wrapper::UInt32VectorImageType > ( i , filenamein , filenameout+"_UInt32Vect_"+ type + extension ) ; - Cross< otb::Wrapper::FloatVectorImageType > ( i , filenamein , filenameout+"_floatVect_"+ type + extension ) ; - Cross< otb::Wrapper::DoubleVectorImageType > ( i , filenamein , filenameout+"_doubleVect_"+ type + extension ) ; - Cross< otb::Wrapper::ComplexInt16ImageType > ( i , filenamein , filenameout+"_CInt16_"+ type + extension ) ; - Cross< otb::Wrapper::ComplexInt32ImageType > ( i , filenamein , filenameout+"_CInt32_"+ type + extension ) ; - Cross< otb::Wrapper::ComplexFloatImageType > ( i , filenamein , filenameout+"_Cfloat_"+ type + extension ) ; - Cross< otb::Wrapper::ComplexDoubleImageType > ( i , filenamein , filenameout+"_Cdouble_"+ type + extension ) ; - Cross< otb::Wrapper::ComplexInt16VectorImageType > ( i , filenamein , filenameout+"_CInt16Vect_"+ type + extension ) ; - Cross< otb::Wrapper::ComplexInt32VectorImageType > ( i , filenamein , filenameout+"_CInt32Vect_"+ type + extension ) ; - Cross< otb::Wrapper::ComplexFloatVectorImageType > ( i , filenamein , filenameout+"_CfloatVect_"+ type + extension ) ; - Cross< otb::Wrapper::ComplexDoubleVectorImageType > ( i , filenamein , filenameout+"_CdoubleVect_"+ type + extension ) ; - } - return 0; -} +// template < typename ImageType > +// void Cross( int p , std::string inputfilename, std::string outputfilename) +// { +// otb::Wrapper::InputImageParameter::Pointer paramIn ( +// otb::Wrapper::InputImageParameter::New() ); +// paramIn->SetFromFileName( inputfilename ); +// otb::Wrapper::OutputImageParameter::Pointer paramOut( +// otb::Wrapper::OutputImageParameter::New() ); +// paramOut->SetFileName( outputfilename ); +// paramOut->SetImage(paramIn->GetImage<ImageType>()); +// paramOut->InitializeWriters(); +// paramOut->SetPixelType(static_cast<otb::Wrapper::ImagePixelType>(p)); +// paramOut->Write(); +// } + + +// int otbWrapperOutputImageParameterConversionTest(int , char* argv[]) +// { +// std::string filenamein = argv[1]; +// std::string filenameout = argv[2] ; +// std::string extension = filenameout.substr( filenameout.find_last_of('.') ); + +// filenameout = filenameout.substr( 0 , filenameout.find_last_of('.') ); + +// for ( int i = otb::Wrapper::ImagePixelType_uint8 ; i < 11 ; i++ ) +// { +// std::string type = +// otb::Wrapper::OutputImageParameter::ConvertPixelTypeToString( +// static_cast<otb::Wrapper::ImagePixelType>(i) ); +// Cross< otb::Wrapper::UInt8ImageType > (i , filenamein , filenameout+"_UInt8_"+ type + extension ) ; +// Cross< otb::Wrapper::Int16ImageType > ( i , filenamein , filenameout+"_Int16_"+ type + extension ) ; +// Cross< otb::Wrapper::UInt16ImageType > ( i , filenamein , filenameout+"_UInt16_"+ type + extension ) ; +// Cross< otb::Wrapper::Int32ImageType > ( i , filenamein , filenameout+"_Int21_"+ type + extension ) ; +// Cross< otb::Wrapper::UInt32ImageType > ( i , filenamein , filenameout+"_UInt32_"+ type + extension ) ; +// Cross< otb::Wrapper::FloatImageType > ( i , filenamein , filenameout+"_float_"+ type + extension ) ; +// Cross< otb::Wrapper::DoubleImageType > ( i , filenamein , filenameout+"_double_"+ type + extension ) ; +// Cross< otb::Wrapper::UInt8VectorImageType > ( i , filenamein , filenameout+"_UInt8Vect_"+ type + extension ) ; +// Cross< otb::Wrapper::Int16VectorImageType > ( i , filenamein , filenameout+"_Int16Vect_"+ type + extension ) ; +// Cross< otb::Wrapper::UInt16VectorImageType > ( i , filenamein , filenameout+"_UInt16Vect_"+ type + extension ) ; +// Cross< otb::Wrapper::Int32VectorImageType > ( i , filenamein , filenameout+"_Int21Vect_"+ type + extension ) ; +// Cross< otb::Wrapper::UInt32VectorImageType > ( i , filenamein , filenameout+"_UInt32Vect_"+ type + extension ) ; +// Cross< otb::Wrapper::FloatVectorImageType > ( i , filenamein , filenameout+"_floatVect_"+ type + extension ) ; +// Cross< otb::Wrapper::DoubleVectorImageType > ( i , filenamein , filenameout+"_doubleVect_"+ type + extension ) ; +// Cross< otb::Wrapper::ComplexInt16ImageType > ( i , filenamein , filenameout+"_CInt16_"+ type + extension ) ; +// Cross< otb::Wrapper::ComplexInt32ImageType > ( i , filenamein , filenameout+"_CInt32_"+ type + extension ) ; +// Cross< otb::Wrapper::ComplexFloatImageType > ( i , filenamein , filenameout+"_Cfloat_"+ type + extension ) ; +// Cross< otb::Wrapper::ComplexDoubleImageType > ( i , filenamein , filenameout+"_Cdouble_"+ type + extension ) ; +// Cross< otb::Wrapper::ComplexInt16VectorImageType > ( i , filenamein , filenameout+"_CInt16Vect_"+ type + extension ) ; +// Cross< otb::Wrapper::ComplexInt32VectorImageType > ( i , filenamein , filenameout+"_CInt32Vect_"+ type + extension ) ; +// Cross< otb::Wrapper::ComplexFloatVectorImageType > ( i , filenamein , filenameout+"_CfloatVect_"+ type + extension ) ; +// Cross< otb::Wrapper::ComplexDoubleVectorImageType > ( i , filenamein , filenameout+"_CdoubleVect_"+ type + extension ) ; +// } +// return 0; +// } -- GitLab From 6d75dddd4d02774961735d9199a8cf16b52a4668 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 14 Feb 2018 16:12:44 +0100 Subject: [PATCH 247/567] ADD: new boolean parameter --- .../include/otbWrapperBoolParameter.h | 84 +++++++++++++++++++ .../src/otbWrapperBoolParameter.cxx | 69 +++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h new file mode 100644 index 0000000000..cb4991c93b --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbWrapperBoolParameter_h +#define otbWrapperBoolParameter_h + +namespace otb +{ +namespace Wrapper +{ + +/** \class BoolParameter + * \brief This class represent a boolean parameter for the wrapper framework + * + * It is intended to replace the deprecated EmptyParameter + * + * \ingroup OTBApplicationEngine + */ +class OTBApplicationEngine_EXPORT BoolParameter + : public Parameter +{ +public: + /** Standard class typedef */ + typedef BoolParameter Self; + typedef Parameter Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Defining ::New() static method */ + itkNewMacro(Self); + + /** RTTI support */ + itkTypeMacro(BoolParameter, Parameter); + + /** This parameter is ON/OFF switch, it always has a value */ + bool HasValue() const override + { + return true; + } + + bool GetValue() const; + + void SetValue(bool state); + + void SetValue(const std::string & str); + +protected: + /** Constructor */ + BoolParameter() + : m_Value(false) + {} + + /** Destructor */ + ~BoolParameter() override + {} + +private: + BoolParameter(const BoolParameter &) = delete; + void operator =(const BoolParameter&) = delete; + + bool m_Value; +}; + +} // end of namespace Wrapper +} // end of namespace otb + +#endif diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx new file mode 100644 index 0000000000..92587a5ddd --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperBoolParameter.h" + +namespace otb +{ +namespace Wrapper +{ + +bool +BoolParameter::GetValue() const +{ + return m_Value; +} + +void +BoolParameter::SetValue(bool state) +{ + if (m_Value != state) + { + m_Value = state; + this->Modified(); + } +} + +void +BoolParameter::SetValue(const std::string & str) +{ + std::string lowerStr; + // only strings less than 10 characters expected + lowerStr.reserve(10); + for (unsigned int i=0 ; i < std::min(10,str.size()) ; i++ ) + { + lowerStr.push_back(tolower(str[i])); + } + if (lowerStr == "1" || lowerStr == "on" || lowerStr == "true") + { + this->SetValue(true); + } + else if (lowerStr == "0" || lowerStr == "off" || lowerStr == "false") + { + this->SetValue(false); + } + else + { + // TODO: exception, value not a bool + } +} + +} // end of namespace Wrapper +} // end of namespace otb -- GitLab From ed90bd5f10e0f12be6deb76f1099643631eed949 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 15 Feb 2018 08:20:13 +0100 Subject: [PATCH 248/567] REFAC: minor modification following Gitlab thread --- .../ImageManipulation/include/otbClampImageFilter.h | 4 ++-- .../ImageManipulation/include/otbClampImageFilter.txx | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h index a27574a971..478eb95222 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.h @@ -105,13 +105,13 @@ protected: void PrintSelf(std::ostream& os, itk::Indent indent) const override; void GenerateOutputInformation(void) override - { + { Superclass::GenerateOutputInformation(); unsigned int sizeIn = this->GetInput()->GetNumberOfComponentsPerPixel(); this->GetFunctor().SetInputComponents( sizeIn ); this->GetOutput()->SetNumberOfComponentsPerPixel( this->GetFunctor().GetOutputSize () ); - } + } private: ClampImageFilter(const Self&) = delete ; diff --git a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx index d6f146436a..b1ac37e2e3 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx +++ b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.txx @@ -61,9 +61,12 @@ void ClampImageFilter<TInputImage, TOutputImage> ::SetUpper(OutputPixelValueType val) { - m_Upper = val; - this->GetFunctor().SetHighest( m_Upper ); - this->Modified(); + if ( m_Upper != val ) + { + m_Upper = val; + this->GetFunctor().SetHighest( m_Upper ); + this->Modified(); + } } /** -- GitLab From 0ed8bcc3b91af7df280609b9280292004a5de26a Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Feb 2018 11:17:10 +0100 Subject: [PATCH 249/567] COMP: fix BoolParameter class --- .../ApplicationEngine/include/otbWrapperBoolParameter.h | 3 +++ Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt | 1 + .../ApplicationEngine/src/otbWrapperBoolParameter.cxx | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h index cb4991c93b..6e4c4ce3da 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h @@ -21,6 +21,9 @@ #ifndef otbWrapperBoolParameter_h #define otbWrapperBoolParameter_h +#include "otbWrapperParameter.h" +#include "OTBApplicationEngineExport.h" + namespace otb { namespace Wrapper diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 343f9db835..90853b7ede 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -52,6 +52,7 @@ set( OTBApplicationEngine_SRC otbWrapperStringListParameter.cxx otbWrapperAbstractParameterList.cxx otbWrapperParameterList.cxx + otbWrapperBoolParameter.cxx otbLogger.cxx ) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx index 92587a5ddd..61acd2fdfa 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx @@ -47,7 +47,7 @@ BoolParameter::SetValue(const std::string & str) std::string lowerStr; // only strings less than 10 characters expected lowerStr.reserve(10); - for (unsigned int i=0 ; i < std::min(10,str.size()) ; i++ ) + for (unsigned int i=0 ; i < std::min(10U,(unsigned int) str.size()) ; i++ ) { lowerStr.push_back(tolower(str[i])); } @@ -61,7 +61,7 @@ BoolParameter::SetValue(const std::string & str) } else { - // TODO: exception, value not a bool + itkGenericExceptionMacro(<< "Wrong value for BoolParameter (" << str << "), accepts: 0, 1, on, off, true, false"); } } -- GitLab From b781892f726d96dca0e4cf678e19fe2d84aa8c5f Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Feb 2018 11:18:25 +0100 Subject: [PATCH 250/567] ENH: handle BoolParameter in ApplicationEngine --- .../include/otbWrapperTypes.h | 3 +- .../src/otbWrapperApplication.cxx | 34 +++++++++++++++++-- .../src/otbWrapperParameterGroup.cxx | 15 ++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h index 63dafb639b..86fc40fa9c 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h @@ -58,7 +58,8 @@ typedef enum ParameterType_ComplexOutputImage, ParameterType_RAM, ParameterType_OutputProcessXML, - ParameterType_InputProcessXML + ParameterType_InputProcessXML, + ParameterType_Bool } ParameterType; typedef enum diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index cca32d50d3..663ec8d4b0 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -37,7 +37,7 @@ #include "otbWrapperRAMParameter.h" #include "otbWrapperProxyParameter.h" #include "otbWrapperParameterKey.h" - +#include "otbWrapperBoolParameter.h" #include "otbWrapperAddProcessToWatchEvent.h" @@ -138,6 +138,11 @@ void Application::SetParameterInt(std::string parameter, int value, bool hasUser ChoiceParameter* paramChoice = dynamic_cast<ChoiceParameter*>(param); paramChoice->SetValue(value); } + else if (dynamic_cast<BoolParameter*>(param)) + { + BoolParameter* paramBool = dynamic_cast<BoolParameter*>(param); + paramBool->SetValue(static_cast<bool>(value)); + } this->SetParameterUserValue(parameter, hasUserValueFlag); } @@ -250,6 +255,11 @@ void Application::SetParameterString(std::string parameter, std::string value, b if ( !paramDown->SetFileName(value) ) otbAppLogCRITICAL( <<"Invalid XML parameter filename " << value <<"."); } + else if (dynamic_cast<BoolParameter*>(param)) + { + BoolParameter* paramDown = dynamic_cast<BoolParameter*>(param); + paramDown->SetValue(value); + } else { otbAppLogWARNING( <<"This parameter can't be set using SetParameterString()."); @@ -724,6 +734,10 @@ ParameterType Application::GetParameterType(std::string paramKey) const { type = ParameterType_InputProcessXML; } + else if (dynamic_cast<const BoolParameter*>(param)) + { + type = ParameterType_Bool; + } else { itkExceptionMacro(<< "Unknown parameter : " << paramKey); @@ -1007,6 +1021,16 @@ int Application::GetParameterInt(std::string parameter) ChoiceParameter* paramChoice = dynamic_cast<ChoiceParameter*>(param); ret = paramChoice->GetValue(); } + else if (dynamic_cast<BoolParameter*>(param)) + { + BoolParameter* paramBool = dynamic_cast<BoolParameter*>(param); + ret = static_cast<int>(paramBool->GetValue()); + } + else if (dynamic_cast<EmptyParameter*>(param)) + { + // This case is here for compatibility purpose with deprecated EmptyParameter + ret = static_cast<int>(this->IsParameterEnabled(parameter)); + } else { itkExceptionMacro(<<parameter << " parameter can't be casted to int"); @@ -1128,6 +1152,11 @@ std::string Application::GetParameterString(std::string parameter) InputProcessXMLParameter* paramDown = dynamic_cast<InputProcessXMLParameter*>(param); ret = paramDown->GetFileName(); } + else if (dynamic_cast<BoolParameter*>(param)) + { + BoolParameter* paramDown = dynamic_cast<BoolParameter*>(param); + ret = (paramDown->GetValue()?"true":"false"); + } else { itkExceptionMacro(<<parameter << " : parameter can't be casted to string"); @@ -1450,7 +1479,8 @@ std::string Application::GetParameterAsString(std::string paramKey) || type == ParameterType_ComplexInputImage || type == ParameterType_InputVectorData || type == ParameterType_OutputImage || type == ParameterType_OutputVectorData || type == ParameterType_ListView || type == ParameterType_Choice - || type == ParameterType_OutputProcessXML || type == ParameterType_InputProcessXML ) + || type == ParameterType_OutputProcessXML || type == ParameterType_InputProcessXML + || type == ParameterType_Bool) { ret = this->GetParameterString( paramKey ); } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx index 2ba9ba9307..9846f99ce4 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx @@ -40,6 +40,7 @@ #include "otbWrapperParameterKey.h" #include "otbWrapperRAMParameter.h" #include "otbWrapperProxyParameter.h" +#include "otbWrapperBoolParameter.h" #include "otb_boost_string_header.h" @@ -332,6 +333,10 @@ ParameterGroup::GetSelectedItems(std::string paramKey) { return ParameterType_InputProcessXML; } + else if (type == "Bool") + { + return ParameterType_Bool; + } else { std::cerr << "Cannot find parameter type code for type: " << type << std::endl; @@ -466,6 +471,11 @@ std::string ParameterGroup::GetParameterTypeAsString(ParameterType type) paramType = "InputProcessXML"; } break; + case ParameterType_Bool: + { + paramType = "Bool"; + } + break; default: { std::cerr << "Cannot find string version of parameter type" << std::endl; @@ -625,6 +635,11 @@ ParameterGroup::AddParameter(ParameterType type, std::string paramKey, std::stri newParam = InputProcessXMLParameter::New(); } break; + case ParameterType_Bool: + { + newParam = BoolParameter::New(); + } + break; } if (newParam.IsNull()) -- GitLab From 1bffbe4711fe19fc06ecc78f6e94fbef792bb329 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Feb 2018 11:19:02 +0100 Subject: [PATCH 251/567] ENH: handle BoolParameter in CommandLine --- .../CommandLine/src/otbWrapperCommandLineLauncher.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx index cf70dc07b7..670bb48437 100644 --- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx +++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx @@ -435,7 +435,8 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() type == ParameterType_InputVectorData || type == ParameterType_OutputVectorData || type == ParameterType_RAM || - type == ParameterType_OutputProcessXML) // || type == ParameterType_InputProcessXML) + type == ParameterType_OutputProcessXML || + type == ParameterType_Bool) // || type == ParameterType_InputProcessXML) { // Single value parameter m_Application->SetParameterString(paramKey, values[0]); @@ -686,7 +687,7 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & { oss << "<int32> "; } - else if (type == ParameterType_Empty ) + else if (type == ParameterType_Empty || type == ParameterType_Bool) { oss << "<boolean> "; } -- GitLab From d06c9f667052fc474ce6b994083a34fcd3bb207b Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Feb 2018 11:19:54 +0100 Subject: [PATCH 252/567] ENH: replace EmptyParameter with BoolParameter (WIP) --- .../Applications/AppImageUtils/app/otbReadImageInfo.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx b/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx index 74bb9c42da..165dcec2c0 100644 --- a/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx +++ b/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx @@ -67,10 +67,8 @@ private: AddParameter(ParameterType_InputImage, "in", "Input Image"); SetParameterDescription("in", "Input image to analyse"); - AddParameter(ParameterType_Empty, "keywordlist", "Display the OSSIM keywordlist"); + AddParameter(ParameterType_Bool, "keywordlist", "Display the OSSIM keywordlist"); SetParameterDescription("keywordlist", "Output the OSSIM keyword list. It contains metadata information (sensor model, geometry ). Information is stored in keyword list (pairs of key/value)"); - DisableParameter("keywordlist"); - MandatoryOff("keywordlist"); AddParameter(ParameterType_OutputFilename, "outkwl", "Write the OSSIM keywordlist to a geom file"); SetParameterDescription("outkwl", "This option allows extracting the OSSIM keywordlist of the image into a geom file."); @@ -486,7 +484,7 @@ private: SetParameterStringList("gcp.geocoord", gcp_geocoord, false); SetParameterStringList("gcp.info", gcp_infos, false); - if ( IsParameterEnabled("keywordlist") ) + if ( GetParameterInt("keywordlist") ) { std::ostringstream osskeywordlist; osskeywordlist<<metadataInterface->GetImageKeywordlist() << std::endl; @@ -499,7 +497,7 @@ private: //Display image information in the dedicated logger otbAppLogINFO( << ossOutput.str() ); - if(IsParameterEnabled("outkwl")) + if(IsParameterEnabled("outkwl") && HasValue("outkwl")) { WriteGeometry(metadataInterface->GetImageKeywordlist(),GetParameterString("outkwl")); } -- GitLab From 14c23e6bfd8ac1718d126d3fc8c7fa809d6d3bef Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Fri, 16 Feb 2018 16:31:29 +0100 Subject: [PATCH 253/567] BUG: Only call UpdateOutputData() if object has Source --- .../Core/ObjectList/include/otbImageList.h | 2 ++ .../Core/ObjectList/include/otbImageList.txx | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Modules/Core/ObjectList/include/otbImageList.h b/Modules/Core/ObjectList/include/otbImageList.h index 611d84a47a..4cb77bddec 100644 --- a/Modules/Core/ObjectList/include/otbImageList.h +++ b/Modules/Core/ObjectList/include/otbImageList.h @@ -68,6 +68,8 @@ public: throw (itk::InvalidRequestedRegionError) ITK_OVERRIDE; void UpdateOutputData(void) ITK_OVERRIDE; + void SetRequestedRegion(const itk::DataObject * source); + protected: /** Constructor */ ImageList() {}; diff --git a/Modules/Core/ObjectList/include/otbImageList.txx b/Modules/Core/ObjectList/include/otbImageList.txx index 80b7276454..426a594027 100644 --- a/Modules/Core/ObjectList/include/otbImageList.txx +++ b/Modules/Core/ObjectList/include/otbImageList.txx @@ -35,7 +35,15 @@ ImageList<TImage> Superclass::UpdateOutputData(); for (ConstIterator it = this->Begin(); it != this->End(); ++it) { + if (it.Get()->GetUpdateMTime() < it.Get()->GetPipelineMTime() + || it.Get()->GetDataReleased() + || it.Get()->RequestedRegionIsOutsideOfTheBufferedRegion()) + { + if(it.Get()->GetSource()) + { it.Get()->GetSource()->UpdateOutputData(it.Get()); + } + } } } @@ -52,6 +60,8 @@ ImageList<TImage> || it.Get()->GetDataReleased() || it.Get()->RequestedRegionIsOutsideOfTheBufferedRegion()) { + + std::cout<<"Requested region: "<<it.Get()<<" "<<it.Get()->GetRequestedRegion()<<std::endl; if (it.Get()->GetSource()) { it.Get()->GetSource()->PropagateRequestedRegion(it.Get()); @@ -72,6 +82,17 @@ ImageList<TImage> } } +template<class TImage> +void +ImageList<TImage> +::SetRequestedRegion(const itk::DataObject * source) +{ + for (ConstIterator it = this->Begin(); it != this->End(); ++it) + { + it.Get()->SetRequestedRegion(source); + } +} + template <class TImage> void ImageList<TImage> -- GitLab From 4d02d9d0481e6f8e474acbd18184b467d78a8977 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Feb 2018 17:46:57 +0100 Subject: [PATCH 254/567] ENH: enhance the BoolParameter class --- .../include/otbWrapperBoolParameter.h | 6 ++--- .../src/otbWrapperBoolParameter.cxx | 24 ++++++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h index 6e4c4ce3da..b2a26670de 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h @@ -60,15 +60,15 @@ public: bool GetValue() const; + std::string GetValueAsString() const; + void SetValue(bool state); void SetValue(const std::string & str); protected: /** Constructor */ - BoolParameter() - : m_Value(false) - {} + BoolParameter(); /** Destructor */ ~BoolParameter() override diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx index 61acd2fdfa..d34cb43676 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx @@ -25,12 +25,22 @@ namespace otb namespace Wrapper { +BoolParameter::BoolParameter() + : m_Value(false) +{} + bool BoolParameter::GetValue() const { return m_Value; } +std::string +BoolParameter::GetValueAsString() const +{ + return std::string(m_Value?"true":"false"); +} + void BoolParameter::SetValue(bool state) { @@ -39,29 +49,31 @@ BoolParameter::SetValue(bool state) m_Value = state; this->Modified(); } + this->SetActive(true); } void BoolParameter::SetValue(const std::string & str) { std::string lowerStr; - // only strings less than 10 characters expected - lowerStr.reserve(10); - for (unsigned int i=0 ; i < std::min(10U,(unsigned int) str.size()) ; i++ ) + // only strings less than 8 characters expected + lowerStr.reserve(8); + for (unsigned int i=0 ; i < std::min(8U,(unsigned int) str.size()) ; i++ ) { lowerStr.push_back(tolower(str[i])); } - if (lowerStr == "1" || lowerStr == "on" || lowerStr == "true") + if (lowerStr == "1" || lowerStr == "on" || lowerStr == "true" || lowerStr == "yes") { this->SetValue(true); } - else if (lowerStr == "0" || lowerStr == "off" || lowerStr == "false") + else if (lowerStr == "0" || lowerStr == "off" || lowerStr == "false" || lowerStr == "no") { this->SetValue(false); } else { - itkGenericExceptionMacro(<< "Wrong value for BoolParameter (" << str << "), accepts: 0, 1, on, off, true, false"); + itkGenericExceptionMacro(<< "Wrong value for BoolParameter (" << str << ")," + " accepts: 0, 1, on, off, true, false, yes, no"); } } -- GitLab From 4355b0b62ef12fbf713d1a3c81b8601636429fe6 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Feb 2018 17:49:37 +0100 Subject: [PATCH 255/567] BUG: fix SetParameterEmpty --- .../Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 663ec8d4b0..a131a40b5a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -303,8 +303,8 @@ void Application::SetParameterStringList(std::string parameter, std::vector<std: void Application::SetParameterEmpty(std::string parameter, bool value, bool hasUserValueFlag) { - GetParameterByKey(parameter)->SetActive(value); this->SetParameterUserValue(parameter, hasUserValueFlag); + GetParameterByKey(parameter)->SetActive(value); } void Application::SetParameterUserValue(std::string paramKey, bool value) -- GitLab From de66e13cffeeeb8aaa160d4af518a6cb93fe0433 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Feb 2018 17:51:39 +0100 Subject: [PATCH 256/567] ENH: fix Application and XML parameters --- .../ApplicationEngine/src/otbWrapperApplication.cxx | 2 +- .../src/otbWrapperInputProcessXMLParameter.cxx | 5 +++-- .../src/otbWrapperOutputProcessXMLParameter.cxx | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index a131a40b5a..1e027e2bf5 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1155,7 +1155,7 @@ std::string Application::GetParameterString(std::string parameter) else if (dynamic_cast<BoolParameter*>(param)) { BoolParameter* paramDown = dynamic_cast<BoolParameter*>(param); - ret = (paramDown->GetValue()?"true":"false"); + ret = paramDown->GetValueAsString(); } else { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx index 938936ebf6..8287525aa6 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx @@ -306,8 +306,9 @@ InputProcessXMLParameter::Read(Application::Pointer this_) } } - if ( type == ParameterType_OutputFilename || type == ParameterType_OutputVectorData || - type == ParameterType_String || type == ParameterType_Choice || type == ParameterType_RAM) + if (type == ParameterType_OutputFilename || type == ParameterType_OutputVectorData || + type == ParameterType_String || type == ParameterType_Choice || + type == ParameterType_RAM || type == ParameterType_Bool) { this_->SetParameterString(key, value); } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx index 5ba103723d..cc2f69e995 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx @@ -235,7 +235,9 @@ OutputProcessXMLParameter::ParseGroup(const std::string& group) } else { - bool paramExists = m_Appli->HasUserValue(key) && m_Appli->IsParameterEnabled(key); + bool paramExists = m_Appli->HasUserValue(key) && + m_Appli->IsParameterEnabled(key) && + m_Appli->GetParameterRole(key) == Role_Input; if ( type == ParameterType_OutputProcessXML ) { paramExists = false; @@ -305,7 +307,7 @@ OutputProcessXMLParameter::ParseGroup(const std::string& group) type == ParameterType_Directory || type == ParameterType_InputImage || type == ParameterType_ComplexInputImage || type == ParameterType_InputVectorData || type == ParameterType_Choice || type == ParameterType_OutputVectorData || - type == ParameterType_OutputFilename) + type == ParameterType_OutputFilename || type == ParameterType_Bool) { value = m_Appli->GetParameterString(key); } -- GitLab From 1c19e59df2b45fc6a5435a9fee0985e81618c41b Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Feb 2018 17:53:06 +0100 Subject: [PATCH 257/567] ADD: new Qt wrapper for BoolParameter --- .../include/otbWrapperQtWidgetBoolParameter.h | 66 +++++++++++++ .../src/otbWrapperQtWidgetBoolParameter.cxx | 95 +++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetBoolParameter.h create mode 100644 Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetBoolParameter.cxx diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetBoolParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetBoolParameter.h new file mode 100644 index 0000000000..681ef9c693 --- /dev/null +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetBoolParameter.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbWrapperQtWidgetBoolParameter_h +#define otbWrapperQtWidgetBoolParameter_h + +#include <QtGui> +#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility +#include "otbWrapperBoolParameter.h" +#include "otbWrapperQtWidgetParameterBase.h" +#endif //tag=QT4-boost-compatibility + +namespace otb +{ +namespace Wrapper +{ + +/** \class QtWidgetBoolParameter + * \brief + * + * \ingroup OTBQtWidget + */ +class OTBQtWidget_EXPORT QtWidgetBoolParameter : public QtWidgetParameterBase +{ + Q_OBJECT + +public: + QtWidgetBoolParameter(BoolParameter*, QtWidgetModel*); + ~QtWidgetBoolParameter() ITK_OVERRIDE; + +public slots: + void SetValue( bool value ); + +private: + QtWidgetBoolParameter(const QtWidgetBoolParameter&) = delete; + void operator=(const QtWidgetBoolParameter&) = delete; + + void DoCreateWidget() ITK_OVERRIDE; + + void DoUpdateGUI() ITK_OVERRIDE; + + QToolButton *m_Button; +}; + + +} +} + +#endif diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetBoolParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetBoolParameter.cxx new file mode 100644 index 0000000000..effe1fc563 --- /dev/null +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetBoolParameter.cxx @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperQtWidgetBoolParameter.h" + +namespace otb +{ +namespace Wrapper +{ + +QtWidgetBoolParameter::QtWidgetBoolParameter(BoolParameter* boolParam, QtWidgetModel* m) + : QtWidgetParameterBase(boolParam, m) +{ +} + +QtWidgetBoolParameter::~QtWidgetBoolParameter() +{ +} + +void QtWidgetBoolParameter::SetValue( bool value ) +{ + BoolParameter* paramDown = dynamic_cast<BoolParameter*>(this->GetParam()); + assert(paramDown && "Not a BoolParameter"); + if (paramDown->GetValue() != value) + { + paramDown->SetValue(value); + + QString key( paramDown->GetKey() ); + emit ParameterChanged(key); + } +} + +void QtWidgetBoolParameter::DoUpdateGUI() +{ + BoolParameter* paramDown = dynamic_cast<BoolParameter*>(this->GetParam()); + assert(paramDown && "Not a BoolParameter"); + if (paramDown->GetValue() != m_Button->isChecked()) + { + m_Button->setChecked(paramDown->GetValue()); + } + QString buttonText(paramDown->GetValue()?"On":"Off"); + if (m_Button->text() != buttonText) + { + m_Button->setText(buttonText); + } +} + +void QtWidgetBoolParameter::DoCreateWidget() +{ + QHBoxLayout *hLayout = new QHBoxLayout; + hLayout->setSpacing(0); + hLayout->setContentsMargins(0, 0, 0, 0); + + m_Button = new QToolButton; + m_Button->setCheckable(true); + BoolParameter* paramDown = dynamic_cast<BoolParameter*>(this->GetParam()); + assert(paramDown && "Not a BoolParameter"); + if (paramDown->GetValue()) + { + m_Button->setText("On"); + m_Button->setChecked(true); + } + else + { + m_Button->setText("Off"); + } + + connect( m_Button, SIGNAL(toggled(bool)), this, SLOT(SetValue(bool)) ); + connect( m_Button, SIGNAL(toggled(bool)), GetModel(), SLOT(NotifyUpdate()) ); + + hLayout->addWidget(m_Button); + hLayout->addStretch(); + + this->setLayout(hLayout); +} + +} +} -- GitLab From 3bf999ff0446fa3e54761ba9c381a76e9ec5f547 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Feb 2018 17:55:30 +0100 Subject: [PATCH 258/567] ENH: use BoolParameter wrapper --- Modules/Wrappers/QtWidget/src/CMakeLists.txt | 2 ++ .../QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/Wrappers/QtWidget/src/CMakeLists.txt b/Modules/Wrappers/QtWidget/src/CMakeLists.txt index 28cb58c376..a366e0458e 100644 --- a/Modules/Wrappers/QtWidget/src/CMakeLists.txt +++ b/Modules/Wrappers/QtWidget/src/CMakeLists.txt @@ -57,6 +57,7 @@ set(OTBQtWidget_SRC otbWrapperQtWidgetListEditWidget.cxx otbWrapperQtWidgetListEditItemModel.cxx otbWrapperQtWidgetParameterList.cxx + otbWrapperQtWidgetBoolParameter.cxx ) set(OTBQtWidget_MOC_HDR @@ -97,6 +98,7 @@ set(OTBQtWidget_MOC_HDR ../include/otbWrapperQtWidgetListEditWidget.h ../include/otbWrapperQtWidgetListEditItemModel.h ../include/otbWrapperQtWidgetParameterList.h + ../include/otbWrapperQtWidgetBoolParameter.h ) set( OTBQtWidget_FORMS diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx index 89763c4237..f675050e23 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterFactory.cxx @@ -50,6 +50,7 @@ #include "otbWrapperQtWidgetRAMParameter.h" #include "otbWrapperQtWidgetStringParameter.h" #include "otbWrapperQtWidgetStringListParameter.h" +#include "otbWrapperQtWidgetBoolParameter.h" namespace otb @@ -123,7 +124,7 @@ QtWidgetParameterFactory::CreateQtWidget( Parameter* param, QtWidgetModel* model CREATEWIDGET(InputVectorDataParameter, QtWidgetInputVectorDataParameter) CREATEWIDGET(OutputImageParameter, QtWidgetOutputImageParameter) CREATEWIDGET(OutputVectorDataParameter, QtWidgetOutputVectorDataParameter) - CREATEWIDGET(EmptyParameter, QtWidgetEmptyParameter) + CREATEWIDGET(BoolParameter, QtWidgetBoolParameter) CREATEWIDGET(ParameterGroup, QtWidgetParameterGroup) CREATEWIDGET(RAMParameter, QtWidgetRAMParameter) CREATEWIDGET(OutputProcessXMLParameter, QtWidgetOutputProcessXMLParameter) -- GitLab From 7de24900d82c1ed3c78fd8fb8ceac217764858d9 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Feb 2018 17:56:38 +0100 Subject: [PATCH 259/567] ENH: update param types in SWIG wrappers --- Modules/Wrappers/SWIG/src/otbApplication.i | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index d945d52af4..56005534a7 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -106,7 +106,8 @@ namespace Wrapper ParameterType_ComplexOutputImage, ParameterType_RAM, ParameterType_OutputProcessXML, - ParameterType_InputProcessXML + ParameterType_InputProcessXML, + ParameterType_Bool } ParameterType; typedef enum -- GitLab From 94cc9d552c041f075351450f6418d9e5799c562d Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Feb 2018 18:33:26 +0100 Subject: [PATCH 260/567] BUG: only modify parameters if different --- .../Applications/AppImageUtils/app/otbQuicklook.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx index b3b12a6efd..f7f9db4a94 100644 --- a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx +++ b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx @@ -183,15 +183,20 @@ bool CropRegionOfInterest() region.SetSize(1, GetParameterInt("rsy")); region.SetIndex(0, GetParameterInt("rox")); region.SetIndex(1, GetParameterInt("roy")); + FloatVectorImageType::RegionType region0 = region; if ( HasValue("in") ) { if (region.Crop(GetParameterImage("in")->GetLargestPossibleRegion())) { - SetParameterInt( "rsx", region.GetSize(0)); - SetParameterInt( "rsy", region.GetSize(1)); - SetParameterInt( "rox", region.GetIndex(0)); - SetParameterInt( "roy", region.GetIndex(1)); + if (region0.GetSize(0) != region.GetSize(0)) + SetParameterInt( "rsx", region.GetSize(0)); + if (region0.GetSize(1) != region.GetSize(1)) + SetParameterInt( "rsy", region.GetSize(1)); + if (region0.GetIndex(0) != region.GetIndex(0)) + SetParameterInt( "rox", region.GetIndex(0)); + if (region0.GetIndex(1) != region.GetIndex(1)) + SetParameterInt( "roy", region.GetIndex(1)); return true; } } -- GitLab From c5273fd3d76902f587cfabde646bcb7d87ece5e6 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 19 Feb 2018 08:33:23 +0100 Subject: [PATCH 261/567] ENH: add a register pipeline method --- .../AppTest/app/otbMemoryTestApplication.cxx | 5 +- .../include/otbWrapperApplication.h | 2 + .../include/otbWrapperInputImageParameter.h | 4 + .../src/otbWrapperApplication.cxx | 79 +++++++++++++++++++ .../src/otbWrapperOutputImageParameter.cxx | 11 --- 5 files changed, 89 insertions(+), 12 deletions(-) diff --git a/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx b/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx index 44712e35c3..ef3f715560 100644 --- a/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx +++ b/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx @@ -94,7 +94,7 @@ private: #ifdef MEM_DEBUG extractor->DebugOn(); #endif - m_Filters.push_back(extractor.GetPointer()); + // m_Filters.push_back(extractor.GetPointer()); #ifdef MEM_DEBUG std::cout<<"Debug on extractor "<<std::endl; extractor->DebugOn(); @@ -107,6 +107,9 @@ private: extractor->GetOutput()->DebugOn(); #endif SetParameterOutputImage("out" , extractor->GetOutput() ); + std::cout<<"Registering"<<std::endl; + RegisterPipeline(); + std::cout<<"Registered"<<std::endl; } }; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 97a5626891..c6d9c6c0e4 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -848,6 +848,8 @@ public: this->SetDocLink(link); } + void RegisterPipeline(); + std::vector<itk::ProcessObject::Pointer> m_Filters; protected: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h index 3f83839de1..852006791c 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h @@ -111,6 +111,10 @@ public: void ClearValue() ITK_OVERRIDE; + ImageBaseType::Pointer GetPointer() + { + return m_Image; + } protected: /** Constructor */ diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index c32feb4b8b..0dd8d63a41 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -45,6 +45,8 @@ #include "otbWrapperTypes.h" #include <exception> #include "itkMacro.h" +#include <stack> +#include <set> namespace otb { @@ -75,6 +77,83 @@ Application::~Application() { } +void +Application::RegisterPipeline() +{ + m_Filters.clear(); + std::stack< itk::DataObject * > dataStack; + std::set< itk::DataObject * > inputData; + std::vector<std::string> paramList = GetParametersKeys(true); + for (std::vector<std::string>::const_iterator it = paramList.begin(); + it != paramList.end(); + ++it) + { + std::string key = *it; + if ( GetParameterType(key) == ParameterType_OutputImage ) + { + Parameter* param = GetParameterByKey(key); + OutputImageParameter * outP = dynamic_cast<OutputImageParameter*>(param); + itk::ImageBase<2> * outData = outP->GetValue(); + std::cout<<"one image in output"<<std::endl; + dataStack.push(outData); + } + else if ( GetParameterType(key) == ParameterType_OutputVectorData ) + { + Parameter* param = GetParameterByKey(key); + OutputVectorDataParameter * outP = dynamic_cast<OutputVectorDataParameter*>(param); + Wrapper::VectorDataType * outData = outP->GetValue(); + dataStack.push(outData); + } + else if ( GetParameterType(key) == ParameterType_InputImage ) + { + Parameter* param = GetParameterByKey(key); + InputImageParameter * inP = dynamic_cast<InputImageParameter*>(param); + itk::ImageBase<2> * inData = inP->GetPointer(); + inputData.insert(inData); + } + } + // DFS + std::set< itk::ProcessObject * > processSet; + while ( !dataStack.empty() ) + { + std::cout<<"one data is processed"<<std::endl; + itk::DataObject * current = dataStack.top(); + dataStack.pop(); + if ( inputData.find( current ) != inputData.end() ) + continue; + std::cout<<"not an input"<<std::endl; + if ( dynamic_cast<itk::ImageBase<2> * > ( current ) ) + { + itk::ImageBase<2> * image = dynamic_cast<itk::ImageBase<2> * > ( current ); + itk::ImageBase<2>::SizeType sizenull; + sizenull.Fill(0); + if ( image->GetLargestPossibleRegion() == image->GetBufferedRegion() && image->GetBufferedRegion().GetSize() != sizenull ) + continue; + } + std::cout<<"not empty"<<std::endl; + itk::ProcessObject * process = (current->GetSource()).GetPointer(); + if ( processSet.find( process ) != processSet.end()) + continue; + std::cout<<"add process to set"<<std::endl; + processSet.insert( process ); + std::vector< itk::DataObject::Pointer > inputs = process->GetInputs(); + for ( auto it : inputs ) + { + if ( inputData.find(it.GetPointer()) != inputData.end() ) + continue; + dataStack.push( it.GetPointer() ); + } + } + + for ( auto it : processSet ) + { + std::cout<<"one filter is registered"<<std::endl; + m_Filters.push_back( it ); + } + + +} + otb::Logger* Application::GetLogger() const { return m_Logger; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 71471e3fc2..37d91b86d0 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -475,9 +475,6 @@ OutputImageParameter::Write() { itkExceptionMacro("Unknown image type"); } - - // Clear writer - m_UInt8Writer = nullptr; } @@ -658,14 +655,6 @@ void OutputImageParameter::ClearValue() { m_Image = nullptr; // m_FileName = ""; - - m_UInt8Writer = nullptr; - m_Int16Writer = nullptr; - m_UInt16Writer = nullptr; - m_Int32Writer = nullptr; - m_UInt32Writer = nullptr; - m_FloatWriter = nullptr; - m_DoubleWriter = nullptr; m_VectorUInt8Writer = nullptr; m_VectorInt16Writer = nullptr; -- GitLab From 3d8ddf164889cda62a0a2d427390ce3b2d24fa42 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Mon, 19 Feb 2018 09:07:58 +0100 Subject: [PATCH 262/567] Merge branch '1516--memory-print-image-list' into 'release-6.4' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve "PipelineMemoryPrintEstimator stops at ImageList" See merge request orfeotoolbox/otb!9 (cherry picked from commit 51bbe2d9c546efbea69f4939359995b393d3e199) 0d1911c0 BUG: Track down upstream pipeline for each image in ImageList (fix #1516) c47e4540 COMP: Fix compilation error (prototype mismatch) 3e227125 BUG: Moving PropageRequestedRegion() at the correct place in ImageList, and… 14c23e6b BUG: Only call UpdateOutputData() if object has Source --- .../Core/ObjectList/include/otbImageList.h | 2 + .../Core/ObjectList/include/otbImageList.txx | 44 ++++++++++++++----- .../otbPipelineMemoryPrintCalculator.h | 2 +- .../src/otbPipelineMemoryPrintCalculator.cxx | 16 ++++--- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/Modules/Core/ObjectList/include/otbImageList.h b/Modules/Core/ObjectList/include/otbImageList.h index 611d84a47a..4cb77bddec 100644 --- a/Modules/Core/ObjectList/include/otbImageList.h +++ b/Modules/Core/ObjectList/include/otbImageList.h @@ -68,6 +68,8 @@ public: throw (itk::InvalidRequestedRegionError) ITK_OVERRIDE; void UpdateOutputData(void) ITK_OVERRIDE; + void SetRequestedRegion(const itk::DataObject * source); + protected: /** Constructor */ ImageList() {}; diff --git a/Modules/Core/ObjectList/include/otbImageList.txx b/Modules/Core/ObjectList/include/otbImageList.txx index dc0cbc9b6f..426a594027 100644 --- a/Modules/Core/ObjectList/include/otbImageList.txx +++ b/Modules/Core/ObjectList/include/otbImageList.txx @@ -39,10 +39,33 @@ ImageList<TImage> || it.Get()->GetDataReleased() || it.Get()->RequestedRegionIsOutsideOfTheBufferedRegion()) { + if(it.Get()->GetSource()) + { + it.Get()->GetSource()->UpdateOutputData(it.Get()); + } + } + } +} + +template <class TImage> +void +ImageList<TImage> +::PropagateRequestedRegion() throw (itk::InvalidRequestedRegionError) + { + Superclass::PropagateRequestedRegion(); + + for (ConstIterator it = this->Begin(); it != this->End(); ++it) + { + if (it.Get()->GetUpdateMTime() < it.Get()->GetPipelineMTime() + || it.Get()->GetDataReleased() + || it.Get()->RequestedRegionIsOutsideOfTheBufferedRegion()) + { + + std::cout<<"Requested region: "<<it.Get()<<" "<<it.Get()->GetRequestedRegion()<<std::endl; if (it.Get()->GetSource()) { it.Get()->GetSource()->PropagateRequestedRegion(it.Get()); - + // Check that the requested region lies within the largest possible region if (!it.Get()->VerifyRequestedRegion()) { @@ -51,23 +74,24 @@ ImageList<TImage> e.SetLocation(ITK_LOCATION); e.SetDataObject(it.Get()); e.SetDescription("Requested region is (at least partially) outside the largest possible region."); - + throw e; } - - it.Get()->GetSource()->UpdateOutputData(it.Get()); } } } -} + } -template <class TImage> +template<class TImage> void ImageList<TImage> -::PropagateRequestedRegion() throw (itk::InvalidRequestedRegionError) - { - Superclass::PropagateRequestedRegion(); - } +::SetRequestedRegion(const itk::DataObject * source) +{ + for (ConstIterator it = this->Begin(); it != this->End(); ++it) + { + it.Get()->SetRequestedRegion(source); + } +} template <class TImage> void diff --git a/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h b/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h index 826478711d..41fe7808e9 100644 --- a/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h +++ b/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h @@ -121,7 +121,7 @@ public: static const double MegabyteToByte; /** Evaluate the print (in bytes) of a single data object */ - MemoryPrintType EvaluateDataObjectPrint(DataObjectType * data) const; + MemoryPrintType EvaluateDataObjectPrint(DataObjectType * data); protected: /** Constructor */ diff --git a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx index 033c58bc37..d7d62e8c88 100644 --- a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx +++ b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx @@ -162,7 +162,7 @@ PipelineMemoryPrintCalculator PipelineMemoryPrintCalculator::MemoryPrintType PipelineMemoryPrintCalculator -::EvaluateDataObjectPrint(DataObjectType * data) const +::EvaluateDataObjectPrint(DataObjectType * data) { otbMsgDevMacro(<< "EvaluateMemoryPrint for " << data->GetNameOfClass() << " (" << data << ")") @@ -183,11 +183,13 @@ PipelineMemoryPrintCalculator { \ ImageList<Image<type, 2> > * imageList = dynamic_cast<otb::ImageList<otb::Image<type, 2> > *>(data); \ MemoryPrintType print(0); \ - for(ImageList<Image<type, 2> >::ConstIterator it = imageList->Begin(); \ + for(ImageList<Image<type, 2> >::Iterator it = imageList->Begin(); \ it != imageList->End(); ++it) \ { \ - print += it.Get()->GetRequestedRegion().GetNumberOfPixels() \ - * it.Get()->GetNumberOfComponentsPerPixel() * sizeof(type); \ + if(it.Get()->GetSource()) \ + print += this->EvaluateProcessObjectPrintRecursive(it.Get()->GetSource());\ + else \ + print += this->EvaluateDataObjectPrint(it.Get()); \ } \ return print; \ } \ @@ -198,8 +200,10 @@ PipelineMemoryPrintCalculator for(ImageList<VectorImage<type, 2> >::ConstIterator it = imageList->Begin(); \ it != imageList->End(); ++it) \ { \ - print += it.Get()->GetRequestedRegion().GetNumberOfPixels() \ - * it.Get()->GetNumberOfComponentsPerPixel() * sizeof(type); \ + if(it.Get()->GetSource()) \ + print += this->EvaluateProcessObjectPrintRecursive(it.Get()->GetSource());\ + else \ + print += this->EvaluateDataObjectPrint(it.Get()); \ } \ return print; \ } \ -- GitLab From cd6b69c73a05c780670b07df26fcd06b5aaed4b6 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 19 Feb 2018 10:12:27 +0100 Subject: [PATCH 263/567] TEST: comment conversion test --- Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt | 10 +++++----- .../test/otbApplicationEngineTestDriver.cxx | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt index 2018d29e92..319466cb4c 100644 --- a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt @@ -171,11 +171,11 @@ otb_add_test(NAME owTvOutputImageParameter COMMAND otbApplicationEngineTestDrive "my description" ) -otb_add_test(NAME owTvOutputImageParameterConversion COMMAND otbApplicationEngineTestDriver - otbWrapperOutputImageParameterConversionTest - ${INPUTDATA}/poupees.tif - ${TEMP}/poupees_out.tif - ) +#~ otb_add_test(NAME owTvOutputImageParameterConversion COMMAND otbApplicationEngineTestDriver + #~ otbWrapperOutputImageParameterConversionTest + #~ ${INPUTDATA}/poupees.tif + #~ ${TEMP}/poupees_out.tif + #~ ) otb_add_test(NAME owTvDocExampleStructureTest COMMAND otbApplicationEngineTestDriver --compare-ascii ${NOTOL} diff --git a/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx b/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx index 17a6d631ba..5ccef49653 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx +++ b/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx @@ -51,6 +51,6 @@ void RegisterTests() REGISTER_TEST(otbWrapperInputVectorDataParameterNew); REGISTER_TEST(otbWrapperOutputImageParameterNew); REGISTER_TEST(otbWrapperOutputImageParameterTest1); - REGISTER_TEST(otbWrapperOutputImageParameterConversionTest); + //~ REGISTER_TEST(otbWrapperOutputImageParameterConversionTest); REGISTER_TEST(otbApplicationMemoryConnectTest); } -- GitLab From d5f5dc3fed5a1ac4c09bfa716b22cf3c7a15b982 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 19 Feb 2018 10:19:17 +0100 Subject: [PATCH 264/567] COMP: wrong typedef name --- .../AppDomainTransform/app/otbDomainTransform.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx index c3321c2bb5..c853f4863b 100644 --- a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx +++ b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx @@ -277,7 +277,7 @@ private: //typedef itk::::ForwardFFTImageFilter over otbImage< InputPixelType > - typedef itk::ForwardFFTImageFilter < TInputImage, OutputImageType > FFTFilter; + typedef itk::ForwardFFTImageFilter < TInputImage, ComplexOutputImageType > FFTFilter; FFTFilter::Pointer fwdFilter = FFTFilter::New(); fwdFilter->SetInput( inImage ); @@ -286,7 +286,7 @@ private: typedef otb::VectorImage<OutputPixelType> TOutputImage; typedef otb::ComplexToVectorImageCastFilter< - OutputImageType, + ComplexOutputImageType, TOutputImage > ComplexToVectorImageCastFilter; ComplexToVectorImageCastFilter::Pointer unaryFunctorImageFilter = ComplexToVectorImageCastFilter::New(); -- GitLab From 16c70a7095c7da270dc3bb7b518020307adc7f78 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 19 Feb 2018 11:10:24 +0100 Subject: [PATCH 265/567] BUG: clearing event cause qt to crash, need to work on this --- .../QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx index d2ee555e8f..1a11aea5ad 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx @@ -105,7 +105,7 @@ void QtWidgetSimpleProgressReport::ReportProcess() void QtWidgetSimpleProgressReport::Init() { - ClearEvent(); + // ClearEvent(); m_Bar->setValue(0); m_Label->setText("No process"); } -- GitLab From 581831aad65e811c47319a518535684f2a3e7e81 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 19 Feb 2018 15:31:19 +0100 Subject: [PATCH 266/567] ENH: use bool parameter for map projection handler --- .../src/otbWrapperMapProjectionParametersHandler.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperMapProjectionParametersHandler.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperMapProjectionParametersHandler.cxx index 493191677c..a4d4557c6d 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperMapProjectionParametersHandler.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperMapProjectionParametersHandler.cxx @@ -50,7 +50,7 @@ void MapProjectionParametersHandler::AddMapProjectionParameters( Application::Po oss.str(""); oss <<key<<".utm" <<".northhem"; - app->AddParameter(ParameterType_Empty, oss.str(), "Northern Hemisphere"); + app->AddParameter(ParameterType_Bool, oss.str(), "Northern Hemisphere"); app->SetParameterDescription(oss.str(),"The transverse mercator projections are defined by their zone number as well as the hemisphere. Activate this parameter if your image is in the northern hemisphere."); -- GitLab From 793bd13f0420c6a99806e7655d725477b63dcbac Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 19 Feb 2018 15:33:50 +0100 Subject: [PATCH 267/567] ENH: update SWIG wrappers for new bool parameter --- Modules/Wrappers/SWIG/src/otbApplication.i | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index 56005534a7..fc90aa65e6 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -503,6 +503,7 @@ class ApplicationProxy(object): ParameterType_Empty : 'ParameterType_Empty', ParameterType_Choice : 'ParameterType_Choice', ParameterType_Group : 'ParameterType_Group', + ParameterType_Bool : 'ParameterType_Bool' }.get(parameter_type, 'ParameterType_UNKNOWN') def __str__(self): @@ -530,6 +531,8 @@ class ApplicationProxy(object): return self.SetParameterFloat(paramKey, value) elif paramType in [ParameterType_Empty]: return self.EnableParameter(paramKey) + elif paramType in [ParameterType_Bool]: + return self.SetParameterString(paramKey, str(value) ) elif paramType in [ParameterType_Group]: return ApplicationProxy(self, paramKey) elif paramType in [ParameterType_Choice]: @@ -557,6 +560,8 @@ class ApplicationProxy(object): return self.GetParameterFloat(paramKey) elif paramType in [ParameterType_Empty]: return self.IsParameterEnabled(paramKey) + elif paramType in [ParameterType_Bool]: + return bool(self.GetParameterInt(paramKey)) elif paramType in [ParameterType_Group, ParameterType_Choice]: return ApplicationProxy(self, paramKey) else: -- GitLab From 66b32a13d8bdd0bac00766dcad0aabbb8b9ac9f8 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 19 Feb 2018 15:34:24 +0100 Subject: [PATCH 268/567] TEST: update test with new ParameterType_Bool --- .../SWIG/test/python/PythonNewStyleParametersTest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Wrappers/SWIG/test/python/PythonNewStyleParametersTest.py b/Modules/Wrappers/SWIG/test/python/PythonNewStyleParametersTest.py index 4cb17b6fe5..c6cb4f3c4b 100644 --- a/Modules/Wrappers/SWIG/test/python/PythonNewStyleParametersTest.py +++ b/Modules/Wrappers/SWIG/test/python/PythonNewStyleParametersTest.py @@ -84,12 +84,12 @@ def test(otb, argv): cm_assert(app.MAP.UTM.ZONE, 31) # 10 - bool type sub parameters of choice parameter get - app.DisableParameter('map.utm.northhem') + app.SetParameterInt('map.utm.northhem',0) cm_assert(app.MAP.UTM.NORTHHEM, False) # 11 - bool type sub parameters of choice parameter set app.MAP.UTM.NORTHHEM = True - cm_assert(True, app.IsParameterEnabled('map.utm.northhem') ) + cm_assert(True, app.GetParameterInt('map.utm.northhem') ) #12 - simple choice parameter set app.OUTPUTS.MODE = 'auto' @@ -128,7 +128,7 @@ def test(otb, argv): cm_assert(app.IsParameterEnabled('outputs.isotropic'), True) #21 - parameter bool get - app.DisableParameter('outputs.isotropic') + app.SetParameterInt('outputs.isotropic',0) cm_assert(False, app.OUTPUTS.ISOTROPIC) #Do not execute. we need LARGEINPUT. so we tried a small application -- GitLab From d2458cd0bc421a65d8cde90225581fa32eac47ce Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 19 Feb 2018 15:34:57 +0100 Subject: [PATCH 269/567] ENH: replace Empty by Bool parameter in Applications --- .../otbClassificationMapRegularization.cxx | 8 +++--- .../app/otbDSFuzzyModelEstimation.cxx | 5 ++-- .../app/otbKMeansClassification.cxx | 7 ++--- .../app/otbTrainImagesClassifier.cxx | 2 +- .../app/otbTrainVectorClassifier.cxx | 2 +- .../app/otbVectorClassifier.cxx | 7 ++--- .../include/otbTrainDecisionTree.txx | 8 +++--- .../include/otbTrainImagesBase.txx | 5 ++-- .../include/otbTrainLibSVM.txx | 17 ++++------- .../AppClassification/include/otbTrainSVM.txx | 8 ++---- .../include/otbTrainVectorBase.txx | 5 ++-- .../app/otbHomologousPointsExtraction.cxx | 14 ++++------ .../app/otbDimensionalityReduction.cxx | 5 ++-- .../app/otbDomainTransform.cxx | 4 +-- .../AppEdge/app/otbLineSegmentDetection.cxx | 5 ++-- .../app/otbContrastEnhancement.cxx | 8 +++--- .../AppImageUtils/app/otbManageNoData.cxx | 8 ++---- .../app/otbMultiResolutionPyramid.cxx | 5 ++-- .../app/otbOpticalCalibration.cxx | 17 +++++------ .../app/otbOrthoRectification.cxx | 6 ++-- .../app/otbSARCalibration.cxx | 16 ++--------- .../app/otbLSMSSegmentation.cxx | 9 +++--- .../app/otbLargeScaleMeanShift.cxx | 5 ++-- .../app/otbMeanShiftSmoothing.cxx | 8 ++---- .../AppSegmentation/app/otbSegmentation.cxx | 14 ++++------ .../AppStereo/app/otbBlockMatching.cxx | 4 +-- .../AppStereo/app/otbStereoFramework.cxx | 28 ++++++++----------- .../AppTest/app/otbTestApplication.cxx | 3 +- .../AppVectorUtils/app/otbOSMDownloader.cxx | 15 +++++----- 29 files changed, 100 insertions(+), 148 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbClassificationMapRegularization.cxx b/Modules/Applications/AppClassification/app/otbClassificationMapRegularization.cxx index c5b0262be4..269a6f5bf5 100644 --- a/Modules/Applications/AppClassification/app/otbClassificationMapRegularization.cxx +++ b/Modules/Applications/AppClassification/app/otbClassificationMapRegularization.cxx @@ -92,7 +92,7 @@ private: SetParameterDescription("ip.radius", "The radius of the ball shaped structuring element (expressed in pixels). By default, 'ip.radius = 1 pixel'."); SetDefaultParameterInt("ip.radius", 1.0); - AddParameter(ParameterType_Empty, "ip.suvbool", "Multiple majority: Undecided(X)/Original"); + AddParameter(ParameterType_Bool, "ip.suvbool", "Multiple majority: Undecided(X)/Original"); SetParameterDescription("ip.suvbool", "Pixels with more than 1 majority class are marked as Undecided if this parameter is checked (true), or keep their Original labels otherwise (false). Please note that the Undecided value must be different from existing labels in the input labeled image. By default, 'ip.suvbool = false'."); AddParameter(ParameterType_Int, "ip.nodatalabel", "Label for the NoData class"); @@ -103,7 +103,7 @@ private: SetParameterDescription("ip.undecidedlabel", "Label for the Undecided class. By default, 'ip.undecidedlabel = 0'."); SetDefaultParameterInt("ip.undecidedlabel", 0.0); - AddParameter(ParameterType_Empty, "ip.onlyisolatedpixels", "Process isolated pixels only"); + AddParameter(ParameterType_Bool, "ip.onlyisolatedpixels", "Process isolated pixels only"); SetParameterDescription("ip.onlyisolatedpixels", "Only pixels whose label is unique in the neighbordhood will be processed. By default, 'ip.onlyisolatedpixels = false'."); AddParameter(ParameterType_Int, "ip.isolatedthreshold", "Threshold for isolated pixels"); @@ -153,7 +153,7 @@ private: m_NeighMajVotingFilter->SetLabelForUndecidedPixels(GetParameterInt("ip.undecidedlabel")); // Set to Undecided label if NOT unique Majority Voting - if (IsParameterEnabled("ip.suvbool")) + if (GetParameterInt("ip.suvbool")) { m_NeighMajVotingFilter->SetKeepOriginalLabelBool(false); } @@ -164,7 +164,7 @@ private: } // Process isolated pixels only - if (IsParameterEnabled("ip.onlyisolatedpixels")) + if (GetParameterInt("ip.onlyisolatedpixels")) { m_NeighMajVotingFilter->SetOnlyIsolatedPixels(true); m_NeighMajVotingFilter->SetIsolatedThreshold(GetParameterInt("ip.isolatedthreshold")); diff --git a/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx b/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx index e6343bf4b9..3e19be7a51 100644 --- a/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx +++ b/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx @@ -164,9 +164,8 @@ private: SetParameterDescription("maxnbit","Maximum number of optimizer iteration (default 200)"); SetParameterInt("maxnbit",200, false); - AddParameter(ParameterType_Empty,"optobs","Optimizer Observer"); + AddParameter(ParameterType_Bool,"optobs","Optimizer Observer"); SetParameterDescription("optobs","Activate the optimizer observer"); - MandatoryOff("optobs"); AddParameter(ParameterType_OutputFilename,"out","Output filename"); SetParameterDescription("out","Output model file name (xml file) contains the optimal model to perform information fusion."); @@ -405,7 +404,7 @@ private: // Create the Command observer and register it with the optimizer. CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); - if (IsParameterEnabled("optobs")) + if (GetParameterInt("optobs")) { m_Optimizer->AddObserver(itk::IterationEvent(), observer); } diff --git a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx index a5067bf9cd..67b86ac30e 100644 --- a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx +++ b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx @@ -59,11 +59,10 @@ protected: InitKMClassification(); // init at the end cleanup - AddParameter( ParameterType_Empty, "cleanup", "Temporary files cleaning" ); - EnableParameter( "cleanup" ); + AddParameter( ParameterType_Bool, "cleanup", "Temporary files cleaning" ); SetParameterDescription( "cleanup", "If activated, the application will try to clean all temporary files it created" ); - MandatoryOff( "cleanup" ); + SetParameterInt("cleanup", 1); } void InitKMSampling() @@ -497,7 +496,7 @@ private: Superclass::CreateOutMeansFile(GetParameterImage("in"), fileNames.modelFile, GetParameterInt("nc")); // Remove all tempory files - if( IsParameterEnabled( "cleanup" ) ) + if( GetParameterInt( "cleanup" ) ) { otbAppLogINFO( <<"Final clean-up ..." ); fileNames.clear(); diff --git a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx index a76f81dce7..bb8b14c639 100644 --- a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx @@ -205,7 +205,7 @@ public: TrainModel( imageList, fileNames.sampleTrainOutputs, fileNames.sampleValidOutputs ); // cleanup - if( IsParameterEnabled( "cleanup" ) ) + if( GetParameterInt( "cleanup" ) ) { otbAppLogINFO( <<"Final clean-up ..." ); fileNames.clear(); diff --git a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx index f37eb3020f..c1f6a9456d 100644 --- a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx @@ -112,7 +112,7 @@ protected: contingencyTableCalculator->Compute(performanceLabeledListSample->Begin(), performanceLabeledListSample->End(),predictedListSample->Begin(), predictedListSample->End()); - if(IsParameterEnabled("v")) + if(GetParameterInt("v")) { otbAppLogINFO( "Training performances:" ); otbAppLogINFO(<<"Contingency table: reference labels (rows) vs. produced labels (cols)\n" diff --git a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx index b8ecd88713..9b996ed189 100644 --- a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx @@ -130,7 +130,7 @@ private: SetParameterDescription("feat","List of field names in the input vector data used as features for training. " "Put the same field names as the TrainVectorClassifier application."); - AddParameter(ParameterType_Empty, "confmap", "Confidence map"); + AddParameter(ParameterType_Bool, "confmap", "Confidence map"); SetParameterDescription( "confmap", "Confidence map of the produced classification. " "The confidence index depends on the model : \n" " - LibSVM : difference between the two highest probabilities " @@ -145,7 +145,6 @@ private: " * RandomForest : Confidence (proportion of votes for the majority class). " "Margin (normalized difference of the votes of the 2 majority classes) is not available for now.\n" " * SVM : distance to margin (only works for 2-class models).\n"); - MandatoryOff("confmap"); AddParameter(ParameterType_OutputFilename, "out", "Output vector data file containing class labels"); SetParameterDescription("out","Output vector data file storing sample values (OGR format)." @@ -271,10 +270,10 @@ private: ConfidenceListSampleType::Pointer quality; - bool computeConfidenceMap(IsParameterEnabled("confmap") && m_Model->HasConfidenceIndex() + bool computeConfidenceMap(GetParameterInt("confmap") && m_Model->HasConfidenceIndex() && !m_Model->GetRegressionMode()); - if (!m_Model->HasConfidenceIndex() && IsParameterEnabled("confmap")) + if (!m_Model->HasConfidenceIndex() && GetParameterInt("confmap")) { otbAppLogWARNING("Confidence map requested but the classifier doesn't support it!"); } diff --git a/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx b/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx index 9803a91a7a..0de1daea60 100644 --- a/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx +++ b/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx @@ -90,13 +90,13 @@ LearningApplicationBase<TInputValue,TOutputValue> "is equal to cv_folds."); //Use1seRule - AddParameter(ParameterType_Empty, "classifier.dt.r", "Set Use1seRule flag to false"); + AddParameter(ParameterType_Bool, "classifier.dt.r", "Set Use1seRule flag to false"); SetParameterDescription("classifier.dt.r", "If true, then a pruning will be harsher. This will make a tree more compact and more " "resistant to the training data noise but a bit less accurate."); //TruncatePrunedTree - AddParameter(ParameterType_Empty, "classifier.dt.t", "Set TruncatePrunedTree flag to false"); + AddParameter(ParameterType_Bool, "classifier.dt.t", "Set TruncatePrunedTree flag to false"); SetParameterDescription("classifier.dt.t", "If true, then pruned branches are physically removed from the tree."); @@ -121,11 +121,11 @@ LearningApplicationBase<TInputValue,TOutputValue> classifier->SetRegressionAccuracy(GetParameterFloat("classifier.dt.ra")); classifier->SetMaxCategories(GetParameterInt("classifier.dt.cat")); classifier->SetCVFolds(GetParameterInt("classifier.dt.f")); - if (IsParameterEnabled("classifier.dt.r")) + if (GetParameterInt("classifier.dt.r")) { classifier->SetUse1seRule(false); } - if (IsParameterEnabled("classifier.dt.t")) + if (GetParameterInt("classifier.dt.t")) { classifier->SetTruncatePrunedTree(false); } diff --git a/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx b/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx index a646cea953..2c8f60ee0d 100644 --- a/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx +++ b/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx @@ -39,11 +39,10 @@ void TrainImagesBase::InitIO() SetParameterDescription( "io.vd", "A list of vector data to select the training samples." ); MandatoryOn( "io.vd" ); - AddParameter( ParameterType_Empty, "cleanup", "Temporary files cleaning" ); - EnableParameter( "cleanup" ); + AddParameter( ParameterType_Bool, "cleanup", "Temporary files cleaning" ); SetParameterDescription( "cleanup", "If activated, the application will try to clean all temporary files it created" ); - MandatoryOff( "cleanup" ); + SetParameterInt( "cleanup", 1); } void TrainImagesBase::InitSampling() diff --git a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx index 18b9f4d39a..6ffd5faccc 100644 --- a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx +++ b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx @@ -105,11 +105,10 @@ namespace Wrapper "the smoother the decision."); // It seems that it miss a nu parameter for the nu-SVM use. - AddParameter(ParameterType_Empty, "classifier.libsvm.opt", "Parameters optimization"); - MandatoryOff("classifier.libsvm.opt"); + AddParameter(ParameterType_Bool, "classifier.libsvm.opt", "Parameters optimization"); SetParameterDescription("classifier.libsvm.opt", "SVM parameters optimization flag."); - AddParameter(ParameterType_Empty, "classifier.libsvm.prob", "Probability estimation"); - MandatoryOff("classifier.libsvm.prob"); + + AddParameter(ParameterType_Bool, "classifier.libsvm.prob", "Probability estimation"); SetParameterDescription("classifier.libsvm.prob", "Probability estimation flag."); if (this->m_RegressionFlag) @@ -137,14 +136,8 @@ namespace Wrapper libSVMClassifier->SetTargetListSample(trainingLabeledListSample); //SVM Option //TODO : Add other options ? - if (IsParameterEnabled("classifier.libsvm.opt")) - { - libSVMClassifier->SetParameterOptimization(true); - } - if (IsParameterEnabled("classifier.libsvm.prob")) - { - libSVMClassifier->SetDoProbabilityEstimates(true); - } + libSVMClassifier->SetParameterOptimization(GetParameterInt("classifier.libsvm.opt")); + libSVMClassifier->SetDoProbabilityEstimates(GetParameterInt("classifier.libsvm.prob")); libSVMClassifier->SetNu(GetParameterFloat("classifier.libsvm.nu")); libSVMClassifier->SetC(GetParameterFloat("classifier.libsvm.c")); diff --git a/Modules/Applications/AppClassification/include/otbTrainSVM.txx b/Modules/Applications/AppClassification/include/otbTrainSVM.txx index ac9524faa2..8a748e4997 100644 --- a/Modules/Applications/AppClassification/include/otbTrainSVM.txx +++ b/Modules/Applications/AppClassification/include/otbTrainSVM.txx @@ -112,9 +112,8 @@ namespace Wrapper SetParameterFloat("classifier.svm.degree",1.0, false); SetParameterDescription("classifier.svm.degree", "Parameter degree of a kernel function (POLY)."); - AddParameter(ParameterType_Empty, "classifier.svm.opt", + AddParameter(ParameterType_Bool, "classifier.svm.opt", "Parameters optimization"); - MandatoryOff("classifier.svm.opt"); SetParameterDescription("classifier.svm.opt", "SVM parameters optimization flag.\n" "-If set to True, then the optimal SVM parameters will be estimated. " "Parameters are considered optimal by OpenCV when the cross-validation estimate of " @@ -229,10 +228,7 @@ namespace Wrapper SVMClassifier->SetCoef0(GetParameterFloat("classifier.svm.coef0")); SVMClassifier->SetGamma(GetParameterFloat("classifier.svm.gamma")); SVMClassifier->SetDegree(GetParameterFloat("classifier.svm.degree")); - if (IsParameterEnabled("classifier.svm.opt")) - { - SVMClassifier->SetParameterOptimization(true); - } + SVMClassifier->SetParameterOptimization(GetParameterInt("classifier.svm.opt")); SVMClassifier->Train(); SVMClassifier->Save(modelPath); diff --git a/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx b/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx index 2c3575c2ea..453db3f3f0 100644 --- a/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx +++ b/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx @@ -91,10 +91,9 @@ void TrainVectorBase::DoInit() "The contingency table is output when we unsupervised algorithms is used otherwise the confusion matrix is output." ); MandatoryOff( "io.confmatout" ); - AddParameter(ParameterType_Empty, "v", "Verbose mode"); - EnableParameter("v"); + AddParameter(ParameterType_Bool, "v", "Verbose mode"); SetParameterDescription("v", "Verbose mode, display the contingency table result."); - MandatoryOff("v"); + SetParameterInt("v", 1); // Doc example parameter settings SetDocExampleParameterValue( "io.vd", "vectorData.shp" ); diff --git a/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx b/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx index 073e53727f..04cf50df4d 100644 --- a/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx +++ b/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx @@ -135,10 +135,8 @@ private: SetMinimumParameterFloatValue("threshold",0.0); SetDefaultParameterFloat("threshold",0.6); - AddParameter(ParameterType_Empty,"backmatching","Use back-matching to filter matches."); + AddParameter(ParameterType_Bool,"backmatching","Use back-matching to filter matches."); SetParameterDescription("backmatching","If set to true, matches should be consistent in both ways."); - MandatoryOff("backmatching"); - DisableParameter("backmatching"); AddParameter(ParameterType_Choice,"mode","Keypoints search mode"); @@ -177,10 +175,10 @@ private: SetParameterDescription("precision","Estimated precision of the colocalisation function in pixels"); SetDefaultParameterFloat("precision",0.); - AddParameter(ParameterType_Empty,"mfilter","Filter points according to geographical or sensor based colocalisation"); + AddParameter(ParameterType_Bool,"mfilter","Filter points according to geographical or sensor based colocalisation"); SetParameterDescription("mfilter","If enabled, this option allows one to filter matches according to colocalisation from sensor or geographical information, using the given tolerancy expressed in pixels"); - AddParameter(ParameterType_Empty,"2wgs84","If enabled, points from second image will be exported in WGS84"); + AddParameter(ParameterType_Bool,"2wgs84","If enabled, points from second image will be exported in WGS84"); // Elevation ElevationParametersHandler::AddElevationParameters(this, "elev"); @@ -251,7 +249,7 @@ private: matchingFilter->SetInput1(surf1->GetOutput()); matchingFilter->SetInput2(surf2->GetOutput()); matchingFilter->SetDistanceThreshold(GetParameterFloat("threshold")); - matchingFilter->SetUseBackMatching(IsParameterEnabled("backmatching")); + matchingFilter->SetUseBackMatching(GetParameterInt("backmatching")); } try @@ -276,7 +274,7 @@ private: bool filtered = false; - if(IsParameterEnabled("mfilter")) + if(GetParameterInt("mfilter")) { pprime1 = rsTransform->TransformPoint(point1); error = vcl_sqrt((point2[0]-pprime1[0])*(point2[0]-pprime1[0])+(point2[1]-pprime1[1])*(point2[1]-pprime1[1])); @@ -289,7 +287,7 @@ private: if(!filtered) { - if(IsParameterEnabled("2wgs84")) + if(GetParameterInt("2wgs84")) { pprime2 = rsTransform2ToWGS84->TransformPoint(point2); diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx index 686b78bb4c..1bf27acc11 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx @@ -164,9 +164,8 @@ private: MandatoryOff("nbcomp"); SetMinimumParameterIntValue("nbcomp", 0); - AddParameter(ParameterType_Empty, "normalize", "Normalize."); + AddParameter(ParameterType_Bool, "normalize", "Normalize."); SetParameterDescription("normalize", "center AND reduce data before Dimensionality reduction."); - MandatoryOff("normalize"); AddParameter(ParameterType_OutputFilename, "outmatrix", "Transformation matrix output (text format)"); SetParameterDescription("outmatrix", "Filename to store the transformation matrix (csv format)"); @@ -237,7 +236,7 @@ private: // Get Parameters int nbComp = GetParameterInt("nbcomp"); - bool normalize = IsParameterEnabled("normalize"); + bool normalize = GetParameterInt("normalize"); bool rescale = IsParameterEnabled("rescale"); bool invTransform = HasValue("outinv") && IsParameterEnabled("outinv"); diff --git a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx index 54dbe894f6..dbe4c4bce0 100644 --- a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx +++ b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx @@ -134,7 +134,7 @@ private: AddChoice("mode.fft", "FFT transform"); SetParameterDescription("mode.fft", "FFT transform"); - AddParameter(ParameterType_Empty, "mode.fft.shift", "Shift fft transform"); + AddParameter(ParameterType_Bool, "mode.fft.shift", "Shift fft transform"); SetParameterDescription("mode.fft.shift", "Shift transform of fft filter"); AddChoice("mode.wavelet", "Wavelet"); @@ -263,7 +263,7 @@ private: else { // fft ttransform - bool shift = IsParameterEnabled( "mode.fft.shift"); + bool shift = GetParameterInt( "mode.fft.shift"); typedef otb::Image< std::complex<OutputPixelType> > ComplexOutputImageType; if (dir == 0 ) diff --git a/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx b/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx index 45bc66c51d..588e8e1ff6 100644 --- a/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx +++ b/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx @@ -85,11 +85,10 @@ private: // Elevation ElevationParametersHandler::AddElevationParameters(this, "elev"); - AddParameter(ParameterType_Empty, "norescale", "No rescaling in [0, 255]"); + AddParameter(ParameterType_Bool, "norescale", "No rescaling in [0, 255]"); SetParameterDescription("norescale", "By default, the input image amplitude is rescaled between [0,255]." " Turn on this parameter to skip rescaling"); - MandatoryOff("norescale"); AddRAMParameter(); @@ -132,7 +131,7 @@ private: = ShiftScaleImageFilterType::New(); // Default behavior is to do the rescaling - if ( !IsParameterEnabled("norescale") ) + if ( !GetParameterInt("norescale") ) { stats->SetInput(amplitudeConverter->GetOutput()); stats->GetStreamer()->SetAutomaticAdaptativeStreaming(GetParameterInt("ram")); diff --git a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx index 3c55bf6efa..0ec0c56286 100644 --- a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx +++ b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx @@ -229,7 +229,7 @@ private: SetParameterDescription("minmax.auto" , "Minimum and maximum value will " "be computed on the image (nodata value won't be taken " "into account) . Each band will have a minimum and a maximum."); - AddParameter(ParameterType_Empty, "minmax.auto.global", "Global"); + AddParameter(ParameterType_Bool, "minmax.auto.global", "Global"); SetParameterDescription("minmax.auto.global" , "Automatic" "Min/max computation will result in the same minimum and maximum for " "all the bands."); @@ -488,7 +488,7 @@ private: if ( m_MinMaxMode == "auto" ) { oss << "automatic"; - if ( IsParameterEnabled( "minmax.auto.global" ) ) + if ( GetParameterInt( "minmax.auto.global" ) ) { oss << " and global"; } @@ -584,7 +584,7 @@ private: statFilter->Update(); min = statFilter->GetMinimum(); max = statFilter->GetMaximum(); - if ( IsParameterEnabled("minmax.auto.global") ) + if ( GetParameterInt("minmax.auto.global") ) { float temp(min[0]); for ( unsigned int i = 1 ; i < min.GetSize() ; i++ ) @@ -602,7 +602,7 @@ private: } std::ostringstream oss; oss<<"Minimum and maximum are for each channel : "; - if ( IsParameterEnabled("minmax.auto.global") || + if ( GetParameterInt("minmax.auto.global") || m_MinMaxMode == "manuel" ) { oss<<std::endl<<min[0]<<" and "<<max[0]; diff --git a/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx b/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx index 439ba05590..744d8f049e 100644 --- a/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx +++ b/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx @@ -79,10 +79,8 @@ private: AddParameter(ParameterType_OutputImage, "out", "Output Image"); SetParameterDescription("out", "Output image"); - AddParameter(ParameterType_Empty,"usenan", "Consider NaN as no-data"); + AddParameter(ParameterType_Bool,"usenan", "Consider NaN as no-data"); SetParameterDescription("usenan","If active, the application will consider NaN as no-data values as well"); - MandatoryOff("usenan"); - DisableParameter("usenan"); AddParameter(ParameterType_Choice,"mode","No-data handling mode"); SetParameterDescription("mode","Allows choosing between different no-data handling options"); @@ -138,12 +136,12 @@ private: m_Filter = FilterType::New(); m_Filter->SetInsideValue(this->GetParameterFloat("mode.buildmask.inv")); m_Filter->SetOutsideValue(this->GetParameterFloat("mode.buildmask.outv")); - m_Filter->SetNaNIsNoData(IsParameterEnabled("usenan")); + m_Filter->SetNaNIsNoData(GetParameterInt("usenan")); m_Filter->SetInput(inputPtr); m_ChangeNoDataFilter = ChangeNoDataFilterType::New(); m_ChangeNoDataFilter->SetInput(inputPtr); - m_ChangeNoDataFilter->SetNaNIsNoData(IsParameterEnabled("usenan")); + m_ChangeNoDataFilter->SetNaNIsNoData(GetParameterInt("usenan")); std::vector<double> newNoData(inputPtr->GetNumberOfComponentsPerPixel(),GetParameterFloat("mode.changevalue.newv")); diff --git a/Modules/Applications/AppImageUtils/app/otbMultiResolutionPyramid.cxx b/Modules/Applications/AppImageUtils/app/otbMultiResolutionPyramid.cxx index d94f67b260..8117e4c165 100644 --- a/Modules/Applications/AppImageUtils/app/otbMultiResolutionPyramid.cxx +++ b/Modules/Applications/AppImageUtils/app/otbMultiResolutionPyramid.cxx @@ -96,12 +96,11 @@ private: SetParameterDescription( "vfactor", "Variance factor use in smoothing. It is multiplied by the subsampling factor of each level in the pyramid (default is 0.6)."); // Boolean Fast scheme - AddParameter(ParameterType_Empty, "fast", "Use Fast Scheme"); + AddParameter(ParameterType_Bool, "fast", "Use Fast Scheme"); std::ostringstream desc; desc<<"If used, this option allows one to speed-up computation by iteratively" <<" subsampling previous level of pyramid instead of processing the full input."; SetParameterDescription("fast", desc.str()); - MandatoryOff("fast"); // Doc example parameter settings SetDocExampleParameterValue("in", "QB_Toulouse_Ortho_XS.tif"); @@ -132,7 +131,7 @@ private: unsigned int shrinkFactor = GetParameterInt("sfactor"); double varianceFactor = GetParameterFloat("vfactor"); - bool fastScheme = IsParameterEnabled("fast"); + bool fastScheme = GetParameterInt("fast"); // Get the input image FloatVectorImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx index 87e7dc310f..7b7e5ef1e2 100644 --- a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx +++ b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx @@ -199,16 +199,13 @@ private: AddChoice("level.toc", "Image to Top Of Canopy reflectance (atmospheric corrections)"); SetParameterString("level", "toa", false); - AddParameter(ParameterType_Empty, "milli", "Convert to milli reflectance"); + AddParameter(ParameterType_Bool, "milli", "Convert to milli reflectance"); SetParameterDescription("milli", "Flag to use milli-reflectance instead of reflectance.\n" "This allows saving the image with integer pixel type (in the range [0, 1000] instead of floating point in the range [0, 1]. In order to do that, use this option and set the output pixel type (-out filename double for example)"); - DisableParameter("milli"); - MandatoryOff("milli"); - AddParameter(ParameterType_Empty, "clamp", "Clamp of reflectivity values between [0, 1]"); + AddParameter(ParameterType_Bool, "clamp", "Clamp of reflectivity values between [0, 1]"); SetParameterDescription("clamp", "Clamping in the range [0, 1]. It can be useful to preserve area with specular reflectance."); - EnableParameter("clamp"); - MandatoryOff("clamp"); + SetParameterInt("clamp",1); //Acquisition parameters AddParameter(ParameterType_Group,"acqui","Acquisition parameters"); @@ -751,12 +748,12 @@ private: m_ImageToRadianceFilter->SetInput(inImage); m_RadianceToReflectanceFilter->SetInput(m_ImageToRadianceFilter->GetOutput()); - if (IsParameterEnabled("clamp")) + if (GetParameterInt("clamp")) { GetLogger()->Info("Clamp values between [0, 100]\n"); } - m_RadianceToReflectanceFilter->SetUseClamp(IsParameterEnabled("clamp")); + m_RadianceToReflectanceFilter->SetUseClamp(GetParameterInt("clamp")); m_RadianceToReflectanceFilter->UpdateOutputInformation(); m_ScaleFilter->SetInput(m_RadianceToReflectanceFilter->GetOutput()); } @@ -894,7 +891,7 @@ private: } //Rescale the surface reflectance in milli-reflectance - if (!IsParameterEnabled("clamp")) + if (!GetParameterInt("clamp")) { if (!adjComputation) m_ScaleFilter->SetInput(m_ReflectanceToSurfaceReflectanceFilter->GetOutput()); @@ -920,7 +917,7 @@ private: // Output Image double scale = 1.; - if (IsParameterEnabled("milli")) + if (GetParameterInt("milli")) { GetLogger()->Info("Use milli-reflectance\n"); if ( (GetParameterInt("level") == Level_IM_TOA) || (GetParameterInt("level") == Level_TOC) ) diff --git a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx index 3c91403e47..0ebf9ba058 100644 --- a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx +++ b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx @@ -177,13 +177,13 @@ private: MandatoryOff("outputs.lry"); MandatoryOff("outputs.ortho"); - AddParameter(ParameterType_Empty,"outputs.isotropic","Force isotropic spacing by default"); + AddParameter(ParameterType_Bool,"outputs.isotropic","Force isotropic spacing by default"); std::ostringstream isotropOss; isotropOss << "Default spacing (pixel size) values are estimated from the sensor modeling of the image. It can therefore result in a non-isotropic spacing. "; isotropOss << "This option allows you to force default values to be isotropic (in this case, the minimum of spacing in both direction is applied. "; isotropOss << "Values overridden by user are not affected by this option."; SetParameterDescription("outputs.isotropic", isotropOss.str()); - EnableParameter("outputs.isotropic"); + SetParameterInt("outputs.isotropic", 1); AddParameter(ParameterType_Float, "outputs.default", "Default pixel value"); SetParameterDescription("outputs.default","Default value to write when outside of input image."); @@ -259,7 +259,7 @@ private: typedef otb::ImageToGenericRSOutputParameters<FloatVectorImageType> OutputParametersEstimatorType; OutputParametersEstimatorType::Pointer genericRSEstimator = OutputParametersEstimatorType::New(); - if(IsParameterEnabled("outputs.isotropic")) + if(GetParameterInt("outputs.isotropic")) { genericRSEstimator->EstimateIsotropicSpacingOn(); } diff --git a/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx b/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx index 4a91dda2f5..07f4e0dadc 100644 --- a/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx +++ b/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx @@ -68,9 +68,8 @@ private: AddRAMParameter(); - AddParameter(ParameterType_Empty, "noise", "Disable Noise"); + AddParameter(ParameterType_Bool, "noise", "Disable Noise"); SetParameterDescription("noise", "Flag to disable noise. For 5.2.0 release, the noise values are only read by TerraSARX product."); - MandatoryOff("noise"); AddParameter(ParameterType_Choice, "lut", "Lookup table sigma /gamma/ beta/ DN."); SetParameterDescription("lut", "Lookup table values are not available with all SAR products. Products that provide lookup table with metadata are: Sentinel1, Radarsat2."); @@ -104,17 +103,8 @@ private: // Set the filer input m_CalibrationFilter = CalibrationFilterType::New(); m_CalibrationFilter->SetInput(floatComplexImage); - - if (IsParameterEnabled("noise")) - { - m_CalibrationFilter->SetEnableNoise(false); - } - - short lut = 0; - - lut = GetParameterInt("lut"); - - m_CalibrationFilter->SetLookupSelected(lut); + m_CalibrationFilter->SetEnableNoise( !bool(GetParameterInt("noise")) ); + m_CalibrationFilter->SetLookupSelected(GetParameterInt("lut")); // Set the output image SetParameterOutputImage("out", m_CalibrationFilter->GetOutput()); diff --git a/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx index 93694cc420..280faee001 100644 --- a/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx @@ -139,7 +139,7 @@ private: void RemoveFile(std::string tile) { // Cleanup - if(IsParameterEnabled("cleanup")) + if(GetParameterInt("cleanup")) { // Try to remove the geom file if existing std::string geomfile = tile.substr(0,tile.size() - itksys::SystemTools::GetFilenameExtension(tile.c_str()).size()).append(".geom"); @@ -302,10 +302,9 @@ private: MandatoryOff("tmpdir"); DisableParameter("tmpdir"); - AddParameter(ParameterType_Empty,"cleanup","Temporary files cleaning"); - EnableParameter("cleanup"); + AddParameter(ParameterType_Bool,"cleanup","Temporary files cleaning"); SetParameterDescription("cleanup","If activated, the application will try to remove all temporary files it created."); - MandatoryOff("cleanup"); + SetParameterInt("cleanup",1); // Doc example parameter settings SetDocExampleParameterValue("in","smooth.tif"); @@ -724,7 +723,7 @@ private: // Release input files m_FinalReader = ITK_NULLPTR; - if(IsParameterEnabled("cleanup")) + if(GetParameterInt("cleanup")) { otbAppLogINFO(<<"Final clean-up ..."); diff --git a/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx b/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx index 27f8da8377..05ca673b64 100644 --- a/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx +++ b/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx @@ -120,11 +120,10 @@ private: "The output raster image", "It corresponds to the output of the small region merging step."); - AddParameter( ParameterType_Empty, "cleanup", "Temporary files cleaning" ); - EnableParameter( "cleanup" ); + AddParameter( ParameterType_Bool, "cleanup", "Temporary files cleaning" ); SetParameterDescription( "cleanup", "If activated, the application will try to clean all temporary files it created" ); - MandatoryOff( "cleanup" ); + SetParameterInt("cleanup",1); // Setup RAM ShareParameter("ram","smoothing.ram"); diff --git a/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx b/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx index 8f63bf13ef..d8980392b0 100644 --- a/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx +++ b/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx @@ -159,10 +159,8 @@ private: SetMinimumParameterFloatValue("rangeramp", 0); MandatoryOff("rangeramp"); - AddParameter(ParameterType_Empty, "modesearch", "Mode search."); + AddParameter(ParameterType_Bool, "modesearch", "Mode search."); SetParameterDescription("modesearch", "If activated pixel iterative convergence is stopped if the path crosses an already converged pixel. Be careful, with this option, the result will slightly depend on thread number and the results will not be stable (see [4] for more details)."); - DisableParameter("modesearch"); - // Doc example parameter settings SetDocExampleParameterValue("in", "maur_rgb.png"); @@ -192,7 +190,7 @@ private: m_Filter->SetThreshold(GetParameterFloat("thres")); m_Filter->SetMaxIterationNumber(GetParameterInt("maxiter")); m_Filter->SetRangeBandwidthRamp(GetParameterFloat("rangeramp")); - m_Filter->SetModeSearch(IsParameterEnabled("modesearch")); + m_Filter->SetModeSearch(GetParameterInt("modesearch")); //Compute the margin used to ensure exact results (tile wise smoothing) //This margin is valid for the default uniform kernel used by the @@ -211,7 +209,7 @@ private: { SetParameterOutputImage("foutpos", m_Filter->GetSpatialOutput()); } - if(!IsParameterEnabled("modesearch")) + if(!GetParameterInt("modesearch")) { otbAppLogINFO(<<"Mode Search is disabled." << std::endl); } diff --git a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx index 5b3bfd2361..cbb1c0b959 100644 --- a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx @@ -282,17 +282,13 @@ private: SetParameterDescription("mode.vector.inmask", "Only pixels whose mask value is strictly positive will be segmented."); MandatoryOff("mode.vector.inmask"); - AddParameter(ParameterType_Empty, "mode.vector.neighbor", "8-neighbor connectivity"); + AddParameter(ParameterType_Bool, "mode.vector.neighbor", "8-neighbor connectivity"); SetParameterDescription("mode.vector.neighbor", "Activate 8-Neighborhood connectivity (default is 4)."); - MandatoryOff("mode.vector.neighbor"); - DisableParameter("mode.vector.neighbor"); - - AddParameter(ParameterType_Empty,"mode.vector.stitch","Stitch polygons"); + AddParameter(ParameterType_Bool,"mode.vector.stitch","Stitch polygons"); SetParameterDescription("mode.vector.stitch", "Scan polygons on each side of tiles and stitch polygons which connect by more than one pixel."); - MandatoryOff("mode.vector.stitch"); - EnableParameter("mode.vector.stitch"); + SetParameterInt("mode.vector.stitch",1); AddParameter(ParameterType_Int, "mode.vector.minsize", "Minimum object size"); SetParameterDescription("mode.vector.minsize", @@ -365,7 +361,7 @@ private: // Retrieve tile size parameter const unsigned int tileSize = static_cast<unsigned int> (this->GetParameterInt("mode.vector.tilesize")); // Retrieve the 8-connected option - bool use8connected = IsParameterEnabled("mode.vector.neighbor"); + bool use8connected = GetParameterInt("mode.vector.neighbor"); // Retrieve min object size parameter const unsigned int minSize = static_cast<unsigned int> (this->GetParameterInt("mode.vector.minsize")); @@ -673,7 +669,7 @@ private: ogrDS->SyncToDisk(); // Stitching mode - if (IsParameterEnabled("mode.vector.stitch")) + if (GetParameterInt("mode.vector.stitch")) { otbAppLogINFO(<<"Segmentation done, stiching polygons ..."); diff --git a/Modules/Applications/AppStereo/app/otbBlockMatching.cxx b/Modules/Applications/AppStereo/app/otbBlockMatching.cxx index 2ec8f7e63a..41c9257ac0 100644 --- a/Modules/Applications/AppStereo/app/otbBlockMatching.cxx +++ b/Modules/Applications/AppStereo/app/otbBlockMatching.cxx @@ -202,7 +202,7 @@ private: DisableParameter("io.outmask"); MandatoryOff("io.outmask"); - AddParameter(ParameterType_Empty,"io.outmetric","Flag to output optimal " + AddParameter(ParameterType_Bool,"io.outmetric","Flag to output optimal " "metric values as well"); SetParameterDescription("io.outmetric","If enabled, the output image will " "have a third component with metric optimal values"); @@ -847,7 +847,7 @@ private: m_OutputImageList->PushBack(hdispImage); m_OutputImageList->PushBack(vdispImage); - if(IsParameterEnabled("io.outmetric")) + if(GetParameterInt("io.outmetric")) { m_OutputImageList->PushBack(metricImage); } diff --git a/Modules/Applications/AppStereo/app/otbStereoFramework.cxx b/Modules/Applications/AppStereo/app/otbStereoFramework.cxx index 279c09ad2f..ee462306f8 100644 --- a/Modules/Applications/AppStereo/app/otbStereoFramework.cxx +++ b/Modules/Applications/AppStereo/app/otbStereoFramework.cxx @@ -525,20 +525,16 @@ private: AddParameter(ParameterType_Group,"postproc","Postprocessing parameters"); SetParameterDescription("postproc","This group of parameters allow use optional filters."); - AddParameter(ParameterType_Empty,"postproc.bij","Use bijection consistency" + AddParameter(ParameterType_Bool,"postproc.bij","Use bijection consistency" " in block matching strategy"); SetParameterDescription("postproc.bij","Use bijection consistency. " "Right to Left correlation is computed to validate Left to Right " "disparities. If bijection is not found, the disparity is rejected."); - MandatoryOff("postproc.bij"); - EnableParameter("postproc.bij"); + SetParameterInt("postproc.bij", 1); - AddParameter(ParameterType_Empty,"postproc.med","Use median disparities filtering"); + AddParameter(ParameterType_Bool,"postproc.med","Use median disparities filtering"); SetParameterDescription("postproc.med","Disparity map can be filtered using" " median post filtering (disabled by default)."); - MandatoryOff("postproc.med"); - DisableParameter("postproc.med"); - AddParameter(ParameterType_Float,"postproc.metrict","Correlation metric threshold"); SetParameterDescription("postproc.metrict","Use block matching metric " @@ -624,7 +620,7 @@ private: } else blockMatcherFilter->MinimizeOff(); - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { invBlockMatcherFilter->SetLeftInput(rightImage); invBlockMatcherFilter->SetRightInput(leftImage); @@ -947,7 +943,7 @@ private: m_Filters.push_back(lBandMathFilter.GetPointer()); BandMathFilterType::Pointer finalMaskFilter; - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { finalMaskFilter = BandMathFilterType::New(); finalMaskFilter->SetNthInput(0, lBandMathFilter->GetOutput(), "inmask"); @@ -992,7 +988,7 @@ private: blockMatcherFilterPointer = SSDDivMeanBlockMatcherFilter.GetPointer(); m_Filters.push_back(blockMatcherFilterPointer); - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { //Reverse correlation invSSDDivMeanBlockMatcherFilter = SSDDivMeanBlockMatchingFilterType::New(); @@ -1025,7 +1021,7 @@ private: blockMatcherFilterPointer = SSDBlockMatcherFilter.GetPointer(); m_Filters.push_back(blockMatcherFilterPointer); - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { //Reverse correlation invSSDBlockMatcherFilter = SSDBlockMatchingFilterType::New(); @@ -1056,7 +1052,7 @@ private: blockMatcherFilterPointer = NCCBlockMatcherFilter.GetPointer(); m_Filters.push_back(blockMatcherFilterPointer); - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { //Reverse correlation invNCCBlockMatcherFilter = NCCBlockMatchingFilterType::New(); @@ -1090,7 +1086,7 @@ private: blockMatcherFilterPointer = LPBlockMatcherFilter.GetPointer(); m_Filters.push_back(blockMatcherFilterPointer); - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { //Reverse correlation invLPBlockMatcherFilter = LPBlockMatchingFilterType::New(); @@ -1119,7 +1115,7 @@ private: break; } - if (IsParameterEnabled("postproc.bij")) + if (GetParameterInt("postproc.bij")) { otbAppLogINFO(<<"Using reverse block-matching to filter incoherent disparity values."); bijectFilter = BijectionFilterType::New(); @@ -1149,7 +1145,7 @@ private: FloatImageType::Pointer hDispOutput = subPixelFilterPointer->GetOutput(0); FloatImageType::Pointer finalMaskImage=finalMaskFilter->GetOutput(); - if (IsParameterEnabled("postproc.med")) + if (GetParameterInt("postproc.med")) { MedianFilterType::Pointer hMedianFilter = MedianFilterType::New(); hMedianFilter->SetInput(subPixelFilterPointer->GetOutput(0)); @@ -1183,7 +1179,7 @@ private: FloatImageType::Pointer hDispOutput2 = disparityTranslateFilter->GetHorizontalDisparityMapOutput(); FloatImageType::Pointer vDispOutput2 = disparityTranslateFilter->GetVerticalDisparityMapOutput(); FloatImageType::Pointer translatedMaskImage = dispTranslateMaskFilter->GetOutput(); - if (IsParameterEnabled("postproc.med")) + if (GetParameterInt("postproc.med")) { MedianFilterType::Pointer hMedianFilter2 = MedianFilterType::New(); MedianFilterType::Pointer vMedianFilter2 = MedianFilterType::New(); diff --git a/Modules/Applications/AppTest/app/otbTestApplication.cxx b/Modules/Applications/AppTest/app/otbTestApplication.cxx index a2e9ee940d..4407d76ed3 100644 --- a/Modules/Applications/AppTest/app/otbTestApplication.cxx +++ b/Modules/Applications/AppTest/app/otbTestApplication.cxx @@ -56,7 +56,8 @@ private: AddDocTag("Test"); //std::cout << "TestApplication::DoInit" << std::endl; - AddParameter(ParameterType_Empty, "boolean", "Boolean"); + AddParameter(ParameterType_Empty, "empty", "Boolean (old impl.)"); + AddParameter(ParameterType_Bool, "boolean", "Boolean"); AddParameter(ParameterType_Int, "int", "Integer"); MandatoryOff("int"); AddParameter(ParameterType_Float, "float", "Float"); diff --git a/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx b/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx index d55626ed0b..ba625b5f48 100644 --- a/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx +++ b/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx @@ -98,11 +98,10 @@ private: // Elevation ElevationParametersHandler::AddElevationParameters(this, "elev"); - AddParameter(ParameterType_Empty, "printclasses", "Displays available key/value classes"); + AddParameter(ParameterType_Bool, "printclasses", "Displays available key/value classes"); SetParameterDescription("printclasses","Print the key/value classes " "available for the selected support image. If enabled, the OSM tag Key " "(-key) and the output (-out) become optional" ); - MandatoryOff("printclasses"); // Doc example parameter settings SetDocExampleParameterValue("support", "qb_RoadExtract.tif"); @@ -118,15 +117,15 @@ private: // CASE: when the -print option is not required and the User // does not set the option OSMKey or the option Output or does not // set both of them - if ( !this->HasValue("printclasses") ) + if ( GetParameterInt("printclasses") ) { - MandatoryOn("out"); - MandatoryOn("key"); + MandatoryOff("out"); + MandatoryOff("key"); } else { - MandatoryOff("out"); - MandatoryOff("key"); + MandatoryOn("out"); + MandatoryOn("key"); } } @@ -178,7 +177,7 @@ private: // If the user wants to print the Key/Values present in the XML file // downloaded : - if ( this->HasValue("printclasses")) + if ( GetParameterInt("printclasses")) { // Print the classes VectorDataProviderType::KeyMapType keymap = m_VdOSMGenerator->GetKeysMap(); -- GitLab From eb477d2ab9aabbd808f20c764f8e4a9af48507fc Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 19 Feb 2018 15:35:52 +0100 Subject: [PATCH 270/567] DOC: update CookBook script --- Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py index 70d55ce7c9..7f0606992f 100755 --- a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py +++ b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py @@ -95,7 +95,8 @@ def GenerateChoice(app,param,paramlist, count = 0): return output def GenerateParameterType(app,param): - if app.GetParameterType(param) == otbApplication.ParameterType_Empty: + if app.GetParameterType(param) == otbApplication.ParameterType_Empty \ + or app.GetParameterType(param) == otbApplication.ParameterType_Bool: return "Boolean" if app.GetParameterType(param) == otbApplication.ParameterType_Int \ or app.GetParameterType(param) == otbApplication.ParameterType_Radius \ @@ -346,6 +347,8 @@ def GetApplicationExamplePythonSnippet(app,idx,expand = False, inputpath="",outp if paramtype == otbApplication.ParameterType_Empty: app.EnableParameter(param) output+= "\t" + appname + ".EnableParameter("+EncloseString(param)+")" + linesep + if paramtype == otbApplication.ParameterType_Bool: + output+= "\t" + appname + ".SetParameterString("+EncloseString(param)+","+EncloseString(value)+")" + linesep if paramtype == otbApplication.ParameterType_Int \ or paramtype == otbApplication.ParameterType_Radius \ or paramtype == otbApplication.ParameterType_RAM: -- GitLab From 2ed552831f852cbdad39d96c4acaa94ee599c848 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 19 Feb 2018 15:42:07 +0100 Subject: [PATCH 271/567] DOC: deprecate EmptyParameter --- .../ApplicationEngine/include/otbWrapperEmptyParameter.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperEmptyParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperEmptyParameter.h index 7978c5fb4f..cb34ef1e3f 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperEmptyParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperEmptyParameter.h @@ -31,6 +31,8 @@ namespace Wrapper /** \class EmptyParameter * \brief This class represent an empty parameter for the wrapper framework (boolean value) * + * \deprecated in OTB 6.6, use BoolParameter instead + * * \ingroup OTBApplicationEngine */ class OTBApplicationEngine_EXPORT EmptyParameter -- GitLab From 2482322754dbfb7394d129c53d043914770097e3 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@orfeo-toolbox.org> Date: Tue, 20 Feb 2018 08:57:58 +0000 Subject: [PATCH 272/567] STY: Removing debug trace --- Modules/Core/ObjectList/include/otbImageList.txx | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/Core/ObjectList/include/otbImageList.txx b/Modules/Core/ObjectList/include/otbImageList.txx index 426a594027..dec0ab8b3e 100644 --- a/Modules/Core/ObjectList/include/otbImageList.txx +++ b/Modules/Core/ObjectList/include/otbImageList.txx @@ -61,7 +61,6 @@ ImageList<TImage> || it.Get()->RequestedRegionIsOutsideOfTheBufferedRegion()) { - std::cout<<"Requested region: "<<it.Get()<<" "<<it.Get()->GetRequestedRegion()<<std::endl; if (it.Get()->GetSource()) { it.Get()->GetSource()->PropagateRequestedRegion(it.Get()); -- GitLab From 8cf8a3bbf293311d35002be1738d3ef264543b23 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@orfeo-toolbox.org> Date: Tue, 20 Feb 2018 08:57:58 +0000 Subject: [PATCH 273/567] STY: Removing debug trace (cherry picked from commit 2482322754dbfb7394d129c53d043914770097e3) --- Modules/Core/ObjectList/include/otbImageList.txx | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/Core/ObjectList/include/otbImageList.txx b/Modules/Core/ObjectList/include/otbImageList.txx index 426a594027..dec0ab8b3e 100644 --- a/Modules/Core/ObjectList/include/otbImageList.txx +++ b/Modules/Core/ObjectList/include/otbImageList.txx @@ -61,7 +61,6 @@ ImageList<TImage> || it.Get()->RequestedRegionIsOutsideOfTheBufferedRegion()) { - std::cout<<"Requested region: "<<it.Get()<<" "<<it.Get()->GetRequestedRegion()<<std::endl; if (it.Get()->GetSource()) { it.Get()->GetSource()->PropagateRequestedRegion(it.Get()); -- GitLab From 510e852f1dae3218f34e7870415e721c0f93ab8e Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 20 Feb 2018 11:47:18 +0100 Subject: [PATCH 274/567] ENH: new function to stop processing (WIP) --- .../ApplicationEngine/include/otbWrapperApplication.h | 3 +++ .../ApplicationEngine/src/otbWrapperApplication.cxx | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index f97134cbd1..d73e49baad 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -154,6 +154,9 @@ public: */ int ExecuteAndWriteOutput(); + /** Request the application to stop its processing */ + void Stop(); + /* Get the internal application parameters * * WARNING: this method may disappear from the API */ diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index cca32d50d3..7676634a52 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -523,6 +523,14 @@ int Application::ExecuteAndWriteOutput() return status; } +void +Application::Stop() +{ + // TODO : call AbortGenerateData on ProcessObjects (but no mutex) + // TODO : set an internal AbortExecute flag with mutex + std::cout << "Stop !" << std::endl; +} + /* Enable the use of an optional parameter. Returns the previous state */ void Application::EnableParameter(std::string paramKey) { -- GitLab From 496253f0d67468c2a0a9972dc12a65847e91753f Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 20 Feb 2018 11:47:55 +0100 Subject: [PATCH 275/567] ENH: handle Execute/Cancel button in QtWidgets --- .../QtWidget/include/otbWrapperQtWidgetModel.h | 9 +++++++++ .../Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx | 11 ++++++++++- .../Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx | 10 ++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetModel.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetModel.h index 92c135dd6e..78cc68bd5f 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetModel.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetModel.h @@ -68,6 +68,13 @@ signals: */ void ExceptionRaised( QString what ); +public slots: + /** Ask the running application to stop */ + void Stop() + { + m_Application->Stop(); + } + protected: void run() ITK_OVERRIDE; @@ -139,6 +146,8 @@ signals: void UpdateGui(); + void Stop(); + protected slots: /** * \brief Slot called when execution is requested (e.g. by diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx index a0d61138d7..eaef5e473b 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx @@ -200,7 +200,7 @@ QtWidgetModel } // launch the output image writing - AppliThread * taskAppli = new AppliThread( m_Application ); + AppliThread *taskAppli = new AppliThread( m_Application ); QObject::connect( taskAppli, @@ -225,10 +225,19 @@ QtWidgetModel SLOT( deleteLater() ) ); + QObject::connect( + this, + SIGNAL( Stop() ), + taskAppli, + SLOT( Stop() ) + ); + // Tell the Progress Reporter to begin emit SetProgressReportBegin(); taskAppli->Execute(); + + emit SetApplicationReady(true); } void diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx index 39c9d80bd4..9238875575 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx @@ -91,6 +91,11 @@ void QtWidgetView::CreateGui() void QtWidgetView::UpdateMessageAfterExecuteClicked() { m_Message->setText("<center><font color=\"#FF0000\">Running</font></center>"); + m_ExecButton->setText(QObject::tr("Cancel")); + + disconnect( m_ExecButton, SIGNAL(clicked()), m_Model, SLOT(ExecuteAndWriteOutputSlot() ) ); + disconnect( m_ExecButton, SIGNAL(clicked()), this, SLOT(UpdateMessageAfterExecuteClicked() ) ); + connect( m_ExecButton, SIGNAL(clicked()), m_Model, SIGNAL(Stop())); } void QtWidgetView::UpdateMessageAfterExecution(int status) @@ -103,6 +108,11 @@ void QtWidgetView::UpdateMessageAfterExecution(int status) { m_Message->setText("<center><font color=\"#FF0000\">Failed</font></center>"); } + m_ExecButton->setText(QObject::tr("Execute")); + + disconnect( m_ExecButton, SIGNAL(clicked()), m_Model, SIGNAL(Stop())); + connect( m_ExecButton, SIGNAL(clicked()), m_Model, SLOT(ExecuteAndWriteOutputSlot() ) ); + connect( m_ExecButton, SIGNAL(clicked()), this, SLOT(UpdateMessageAfterExecuteClicked() ) ); } void QtWidgetView::UpdateMessageAfterApplicationReady( bool val ) -- GitLab From 782ae6cbaf5f70b6d8332a0fe81849c294387c7d Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Tue, 13 Feb 2018 10:35:07 +0100 Subject: [PATCH 276/567] DOC: use analyze instead of analyse (more coherent with itk/otb code) --- .../AppClassification/app/otbPolygonClassStatistics.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx index ff4f4b01e4..3e104dbe35 100644 --- a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx +++ b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx @@ -76,7 +76,7 @@ private: SetDocName("Polygon Class Statistics"); SetDocLongDescription("The application processes a set of geometries " "intended for training (they should have a field giving the associated " - "class). The geometries are analysed against a support image to compute " + "class). The geometries are analyzed against a support image to compute " "statistics : \n" " - number of samples per class\n" " - number of samples per geometry\n" @@ -100,7 +100,7 @@ private: MandatoryOff("mask"); AddParameter(ParameterType_InputFilename, "vec", "Input vectors"); - SetParameterDescription("vec","Input geometries to analyse"); + SetParameterDescription("vec","Input geometries to analyze"); AddParameter(ParameterType_OutputFilename, "out", "Output Statistics"); SetParameterDescription("out","Output file to store statistics (XML format)"); @@ -223,7 +223,7 @@ private: filter->SetLayerIndex(this->GetParameterInt("layer")); filter->GetStreamer()->SetAutomaticAdaptativeStreaming(GetParameterInt("ram")); - AddProcess(filter->GetStreamer(),"Analyse polygons..."); + AddProcess(filter->GetStreamer(),"Analyze polygons..."); filter->Update(); FilterType::ClassCountMapType &classCount = filter->GetClassCountOutput()->Get(); -- GitLab From 57ad476c453cd7e220865c52dcc9fd8b8ecd30f9 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Tue, 13 Feb 2018 10:36:18 +0100 Subject: [PATCH 277/567] DOC: Indicate that PoilygonClassStatistics out parameter is an xml file in short description --- .../AppClassification/app/otbPolygonClassStatistics.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx index 3e104dbe35..dc6bc16001 100644 --- a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx +++ b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx @@ -102,7 +102,7 @@ private: AddParameter(ParameterType_InputFilename, "vec", "Input vectors"); SetParameterDescription("vec","Input geometries to analyze"); - AddParameter(ParameterType_OutputFilename, "out", "Output Statistics"); + AddParameter(ParameterType_OutputFilename, "out", "Output XML statistics file"); SetParameterDescription("out","Output file to store statistics (XML format)"); AddParameter(ParameterType_ListView, "field", "Field Name"); -- GitLab From c961654cb790c8bfa706d4c6729f5b062fabff7a Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Tue, 13 Feb 2018 10:49:45 +0100 Subject: [PATCH 278/567] ENH: use const string to store filename extension --- Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.txx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.txx b/Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.txx index f1d830132a..b20416b4d7 100644 --- a/Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.txx +++ b/Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.txx @@ -72,7 +72,7 @@ StatisticsXMLFileWriter<TMeasurementVector> itkExceptionMacro(<<"The XML output FileName is empty, please set the filename via the method SetFileName"); // Check that the right extension is given : expected .xml */ - std::string extension = itksys::SystemTools::GetFilenameLastExtension(m_FileName); + const std::string extension = itksys::SystemTools::GetFilenameLastExtension(m_FileName); if (itksys::SystemTools::LowerCase(extension) != ".xml") { itkExceptionMacro(<<extension -- GitLab From 025e59c3e7736a9e90737ff3653356ed7f284256 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Tue, 13 Feb 2018 11:16:08 +0100 Subject: [PATCH 279/567] ENH: check output filename extension before polygon analysis to avoid useless computation --- .../app/otbPolygonClassStatistics.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx index dc6bc16001..665c0facb5 100644 --- a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx +++ b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx @@ -155,6 +155,22 @@ private: } } } + + // Check that the extension of the output parameter is XML (mandatory for + // StatisticsXMLFileWriter) + // Check it here to trigger the error before polygons analysis + + if ( HasValue("out") ) + { + // Store filename extension + // Check that the right extension is given : expected .xml + const std::string extension = itksys::SystemTools::GetFilenameLastExtension(this->GetParameterString("out")); + + if (itksys::SystemTools::LowerCase(extension) != ".xml") + { + otbAppLogFATAL( << extension << " is a wrong extension for parameter \"out\": Expected .xml" ); + } + } } void DoExecute() ITK_OVERRIDE -- GitLab From 16300a8d4080c869cd3746e511b4b70f2b21ca1d Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Tue, 13 Feb 2018 11:27:41 +0100 Subject: [PATCH 280/567] DOC: clarify in polygon class statistics that the mask corresponds to a validy mask --- .../AppClassification/app/otbPolygonClassStatistics.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx index 665c0facb5..4a35145462 100644 --- a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx +++ b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx @@ -92,10 +92,10 @@ private: AddDocTag(Tags::Learning); - AddParameter(ParameterType_InputImage, "in", "InputImage"); + AddParameter(ParameterType_InputImage, "in", "Input image"); SetParameterDescription("in", "Support image that will be classified"); - AddParameter(ParameterType_InputImage, "mask", "InputMask"); + AddParameter(ParameterType_InputImage, "mask", "Input validity mask"); SetParameterDescription("mask", "Validity mask (only pixels corresponding to a mask value greater than 0 will be used for statistics)"); MandatoryOff("mask"); -- GitLab From 82b28e06ab4a6e6c4c452482f858aa1927bdc51e Mon Sep 17 00:00:00 2001 From: Alexia Mondot <alexia.mondot@c-s.fr> Date: Tue, 20 Feb 2018 14:43:12 +0100 Subject: [PATCH 281/567] BUG: typo with SetParameterStringList --- Modules/Wrappers/SWIG/src/otbApplication.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index d945d52af4..9932f82547 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -522,7 +522,7 @@ class ApplicationProxy(object): elif paramType in [ParameterType_InputImageList, ParameterType_InputVectorDataList, ParameterType_InputFilenameList, ParameterType_StringList, ParameterType_ListView]: - return self.setParameterStringList(paramKey, value) + return self.SetParameterStringList(paramKey, value) elif paramType in [ParameterType_Int, ParameterType_Radius]: return self.SetParameterInt(paramKey, value) elif paramType in [ParameterType_Float]: -- GitLab From 1da4ead169c4ccee0329ffe715f6e14a9b643b43 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 20 Feb 2018 14:53:15 +0100 Subject: [PATCH 282/567] ENH: add a new method to register DataObject and to call ReleaseData() --- .../include/otbWrapperApplication.h | 2 +- .../src/otbWrapperApplication.cxx | 287 +++++++++++------- 2 files changed, 177 insertions(+), 112 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index c6d9c6c0e4..556a1f11cb 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -849,7 +849,7 @@ public: } void RegisterPipeline(); - + void ReleaseDataFromPipeline(); std::vector<itk::ProcessObject::Pointer> m_Filters; protected: diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 0dd8d63a41..9367558dc0 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -77,83 +77,6 @@ Application::~Application() { } -void -Application::RegisterPipeline() -{ - m_Filters.clear(); - std::stack< itk::DataObject * > dataStack; - std::set< itk::DataObject * > inputData; - std::vector<std::string> paramList = GetParametersKeys(true); - for (std::vector<std::string>::const_iterator it = paramList.begin(); - it != paramList.end(); - ++it) - { - std::string key = *it; - if ( GetParameterType(key) == ParameterType_OutputImage ) - { - Parameter* param = GetParameterByKey(key); - OutputImageParameter * outP = dynamic_cast<OutputImageParameter*>(param); - itk::ImageBase<2> * outData = outP->GetValue(); - std::cout<<"one image in output"<<std::endl; - dataStack.push(outData); - } - else if ( GetParameterType(key) == ParameterType_OutputVectorData ) - { - Parameter* param = GetParameterByKey(key); - OutputVectorDataParameter * outP = dynamic_cast<OutputVectorDataParameter*>(param); - Wrapper::VectorDataType * outData = outP->GetValue(); - dataStack.push(outData); - } - else if ( GetParameterType(key) == ParameterType_InputImage ) - { - Parameter* param = GetParameterByKey(key); - InputImageParameter * inP = dynamic_cast<InputImageParameter*>(param); - itk::ImageBase<2> * inData = inP->GetPointer(); - inputData.insert(inData); - } - } - // DFS - std::set< itk::ProcessObject * > processSet; - while ( !dataStack.empty() ) - { - std::cout<<"one data is processed"<<std::endl; - itk::DataObject * current = dataStack.top(); - dataStack.pop(); - if ( inputData.find( current ) != inputData.end() ) - continue; - std::cout<<"not an input"<<std::endl; - if ( dynamic_cast<itk::ImageBase<2> * > ( current ) ) - { - itk::ImageBase<2> * image = dynamic_cast<itk::ImageBase<2> * > ( current ); - itk::ImageBase<2>::SizeType sizenull; - sizenull.Fill(0); - if ( image->GetLargestPossibleRegion() == image->GetBufferedRegion() && image->GetBufferedRegion().GetSize() != sizenull ) - continue; - } - std::cout<<"not empty"<<std::endl; - itk::ProcessObject * process = (current->GetSource()).GetPointer(); - if ( processSet.find( process ) != processSet.end()) - continue; - std::cout<<"add process to set"<<std::endl; - processSet.insert( process ); - std::vector< itk::DataObject::Pointer > inputs = process->GetInputs(); - for ( auto it : inputs ) - { - if ( inputData.find(it.GetPointer()) != inputData.end() ) - continue; - dataStack.push( it.GetPointer() ); - } - } - - for ( auto it : processSet ) - { - std::cout<<"one filter is registered"<<std::endl; - m_Filters.push_back( it ); - } - - -} - otb::Logger* Application::GetLogger() const { return m_Logger; @@ -437,6 +360,81 @@ void Application::UpdateParameters() void Application::AfterExecuteAndWriteOutputs() {} +void +Application::RegisterPipeline() +{ + m_Filters.clear(); + std::stack< itk::DataObject * > dataStack; + std::set< itk::DataObject * > inputData; + std::vector<std::string> paramList = GetParametersKeys(true); + for (std::vector<std::string>::const_iterator it = paramList.begin(); + it != paramList.end(); + ++it) + { + std::string key = *it; + if ( GetParameterType(key) == ParameterType_OutputImage ) + { + Parameter* param = GetParameterByKey(key); + OutputImageParameter * outP = dynamic_cast<OutputImageParameter*>(param); + itk::ImageBase<2> * outData = outP->GetValue(); + std::cout<<"one image in output"<<std::endl; + dataStack.push(outData); + } + else if ( GetParameterType(key) == ParameterType_OutputVectorData ) + { + Parameter* param = GetParameterByKey(key); + OutputVectorDataParameter * outP = dynamic_cast<OutputVectorDataParameter*>(param); + Wrapper::VectorDataType * outData = outP->GetValue(); + dataStack.push(outData); + } + else if ( GetParameterType(key) == ParameterType_InputImage ) + { + Parameter* param = GetParameterByKey(key); + InputImageParameter * inP = dynamic_cast<InputImageParameter*>(param); + itk::ImageBase<2> * inData = inP->GetPointer(); + inputData.insert(inData); + } + } + // DFS + std::set< itk::ProcessObject * > processSet; + while ( !dataStack.empty() ) + { + std::cout<<"one data is processed"<<std::endl; + itk::DataObject * current = dataStack.top(); + dataStack.pop(); + if ( inputData.find( current ) != inputData.end() ) + continue; + std::cout<<"not an input"<<std::endl; + if ( dynamic_cast<itk::ImageBase<2> * > ( current ) ) + { + itk::ImageBase<2> * image = dynamic_cast<itk::ImageBase<2> * > ( current ); + itk::ImageBase<2>::SizeType sizenull; + sizenull.Fill(0); + if ( image->GetLargestPossibleRegion() == image->GetBufferedRegion() && image->GetBufferedRegion().GetSize() != sizenull ) + continue; + } + std::cout<<"not empty"<<std::endl; + itk::ProcessObject * process = (current->GetSource()).GetPointer(); + if ( processSet.find( process ) != processSet.end()) + continue; + std::cout<<"add process to set"<<std::endl; + processSet.insert( process ); + std::vector< itk::DataObject::Pointer > inputs = process->GetInputs(); + for ( auto it : inputs ) + { + if ( inputData.find(it.GetPointer()) != inputData.end() ) + continue; + dataStack.push( it.GetPointer() ); + } + } + + for ( auto it : processSet ) + { + std::cout<<"one filter is registered"<<std::endl; + m_Filters.push_back( it ); + } +} + int Application::Execute() { @@ -487,6 +485,72 @@ int Application::Execute() return 0; } +void +Application::ReleaseDataFromPipeline() +{ + std::stack< itk::DataObject * > dataStack; + std::set< itk::DataObject * > dataSet; + std::vector<std::string> paramList = GetParametersKeys(true); + for (std::vector<std::string>::const_iterator it = paramList.begin(); + it != paramList.end(); + ++it) + { + std::string key = *it; + if ( GetParameterType(key) == ParameterType_OutputImage ) + { + Parameter* param = GetParameterByKey(key); + OutputImageParameter * outP = dynamic_cast<OutputImageParameter*>(param); + itk::ImageBase<2> * outData = outP->GetValue(); + std::cout<<"one image in output"<<std::endl; + dataSet.insert(outData); + } + else if ( GetParameterType(key) == ParameterType_OutputVectorData ) + { + Parameter* param = GetParameterByKey(key); + OutputVectorDataParameter * outP = dynamic_cast<OutputVectorDataParameter*>(param); + Wrapper::VectorDataType * outData = outP->GetValue(); + dataSet.insert(outData); + } + else + continue; + } + // DFS + std::stack< itk::ProcessObject * > processStack; + for ( auto data : dataSet ) + { + auto process = (data->GetSource()).GetPointer(); + if ( process != nullptr ) + processStack.push( process ); + } + + while ( !processStack.empty() ) + { + std::cout<<"one process is processed"<<std::endl; + itk::ProcessObject * current = processStack.top(); + std::cout<<"top"<<std::endl; + processStack.pop(); + std::cout<<"pop"<<std::endl; + std::cout<<current->GetNameOfClass()<<std::endl; + auto inputVector = current->GetInputs(); + for ( auto data : inputVector ) + { + if ( dataSet.find( data.GetPointer() ) != dataSet.end() && data != nullptr ) + continue; + std::cout<<"one data is stored"<<std::endl; + dataSet.insert( data.GetPointer() ); + itk::ProcessObject * process = data->GetSource().GetPointer(); + if ( process != nullptr ) + processStack.push( process ); + } + } + + for ( auto data : dataSet ) + { + std::cout<<"one bulk is freed"<<std::endl; + data->ReleaseData(); + } +} + int Application::ExecuteAndWriteOutput() { std::cout<<"Executing..."<<std::endl; @@ -601,6 +665,7 @@ int Application::ExecuteAndWriteOutput() this->AfterExecuteAndWriteOutputs(); m_Chrono.Stop(); + ReleaseDataFromPipeline(); ClearMemory(); return status; } @@ -615,39 +680,39 @@ void Application::ClearMemory() ++it) { std::string key = *it; - if (GetParameterType(key) == ParameterType_InputImage ) - { - Parameter* param = GetParameterByKey(key); - InputImageParameter * input = dynamic_cast<InputImageParameter*>(param); - filename = input->GetFileName(); - input->ClearValue(); - input->SetFromFileName(filename); - } - else if (GetParameterType(key) == ParameterType_InputImageList ) - { - Parameter* param = GetParameterByKey(key); - InputImageListParameter * input = dynamic_cast<InputImageListParameter*>(param); - std::vector< std::string > filenamelist = input->GetFileNameList(); - input->ClearValue(); - input->SetListFromFileName(filenamelist); - } - else if (GetParameterType(key) == ParameterType_InputVectorData ) - { - Parameter* param = GetParameterByKey(key); - InputVectorDataParameter * input = dynamic_cast<InputVectorDataParameter*>(param); - filename = input->GetFileName(); - input->ClearValue(); - input->SetFromFileName(filename); - } - else if (GetParameterType(key) == ParameterType_InputVectorDataList ) - { - Parameter* param = GetParameterByKey(key); - InputVectorDataListParameter * input = dynamic_cast<InputVectorDataListParameter*>(param); - std::vector< std::string > filenamelist = input->GetFileNameList(); - input->ClearValue(); - input->SetListFromFileName(filenamelist); - } - else if (GetParameterType(key) == ParameterType_OutputImage ) + // if (GetParameterType(key) == ParameterType_InputImage ) + // { + // Parameter* param = GetParameterByKey(key); + // InputImageParameter * input = dynamic_cast<InputImageParameter*>(param); + // filename = input->GetFileName(); + // input->ClearValue(); + // input->SetFromFileName(filename); + // } + // else if (GetParameterType(key) == ParameterType_InputImageList ) + // { + // Parameter* param = GetParameterByKey(key); + // InputImageListParameter * input = dynamic_cast<InputImageListParameter*>(param); + // std::vector< std::string > filenamelist = input->GetFileNameList(); + // input->ClearValue(); + // input->SetListFromFileName(filenamelist); + // } + // else if (GetParameterType(key) == ParameterType_InputVectorData ) + // { + // Parameter* param = GetParameterByKey(key); + // InputVectorDataParameter * input = dynamic_cast<InputVectorDataParameter*>(param); + // filename = input->GetFileName(); + // input->ClearValue(); + // input->SetFromFileName(filename); + // } + // else if (GetParameterType(key) == ParameterType_InputVectorDataList ) + // { + // Parameter* param = GetParameterByKey(key); + // InputVectorDataListParameter * input = dynamic_cast<InputVectorDataListParameter*>(param); + // std::vector< std::string > filenamelist = input->GetFileNameList(); + // input->ClearValue(); + // input->SetListFromFileName(filenamelist); + // } + if (GetParameterType(key) == ParameterType_OutputImage ) { Parameter* param = GetParameterByKey(key); OutputImageParameter * output = dynamic_cast<OutputImageParameter*>(param); @@ -662,7 +727,7 @@ void Application::ClearMemory() } // Cleaning m_ProgressSource - m_ProgressSource = nullptr; + // m_ProgressSource = nullptr; // Cleaning m_Filters m_Filters.clear(); -- GitLab From fa01c736b6d72ecc11f50e27fea8b5996197c132 Mon Sep 17 00:00:00 2001 From: Alexia Mondot <alexia.mondot@c-s.fr> Date: Tue, 20 Feb 2018 14:54:21 +0100 Subject: [PATCH 283/567] ENH: new method SetParameters using dict --- Modules/Wrappers/SWIG/src/otbApplication.i | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index 9932f82547..4f12fd3c4a 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -510,6 +510,10 @@ class ApplicationProxy(object): s += self.GetDocLongDescription() return s + def SetParameters(self, dict_params): + for param_key, param_value in dict_params.iteritems(): + self.SetParameterValue(param_key, param_value) + def SetParameterValue(self, paramKey, value): paramType = self.GetParameterType(paramKey) if paramType in [ParameterType_InputProcessXML, ParameterType_RAM, -- GitLab From 9fad52b45b733317b021b90fc58800553c19848d Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 20 Feb 2018 15:25:38 +0100 Subject: [PATCH 284/567] ENH: GetParameters() returns a dict of enabled input parameters with value --- Modules/Wrappers/SWIG/src/otbApplication.i | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index 4f12fd3c4a..3baf415d1a 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -541,6 +541,13 @@ class ApplicationProxy(object): print ("Unsupported parameter type '%s' with key '%s'" %(self.GetParameterTypeAsString(paramType) ,paramKey)) return + def GetParameters(self): + ret = {} + for key in self.GetParametersKeys(): + if self.HasValue(key) and self.IsParameterEnabled(key) and self.GetParameterRole(key) == 0: + ret[key] = self.GetParameterValue(key) + return ret + def GetParameterValue(self, paramKey): paramType = self.GetParameterType(paramKey) if paramType in [ParameterType_InputProcessXML, -- GitLab From e53617909440b8d1774647b756d36c42437f766c Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 20 Feb 2018 15:26:45 +0100 Subject: [PATCH 285/567] TEST: new test to validate the parameter dict --- .../Wrappers/SWIG/test/python/CMakeLists.txt | 5 ++ .../SWIG/test/python/PythonParametersDict.py | 46 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 Modules/Wrappers/SWIG/test/python/PythonParametersDict.py diff --git a/Modules/Wrappers/SWIG/test/python/CMakeLists.txt b/Modules/Wrappers/SWIG/test/python/CMakeLists.txt index b0e0ac49bc..bd5865b570 100644 --- a/Modules/Wrappers/SWIG/test/python/CMakeLists.txt +++ b/Modules/Wrappers/SWIG/test/python/CMakeLists.txt @@ -141,3 +141,8 @@ add_test( NAME pyTvBug1498 ${OTB_DATA_ROOT}/Input/poupees.tif ${TEMP}/Bu1498-output.tif) +add_test( NAME pyTvParametersDict + COMMAND ${TEST_DRIVER} Execute + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py + PythonParametersDict + ${OTB_DATA_ROOT}/Input/poupees.tif) diff --git a/Modules/Wrappers/SWIG/test/python/PythonParametersDict.py b/Modules/Wrappers/SWIG/test/python/PythonParametersDict.py new file mode 100644 index 0000000000..d05161acc4 --- /dev/null +++ b/Modules/Wrappers/SWIG/test/python/PythonParametersDict.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# -*- coding: utf-8 -*- + +# +# Example on the use of parameters dictionaries +# + +def test(otb, argv): + app = otb.Registry.CreateApplication("Smoothing") + + app.SetParameterString("out", "myOutput.tif") + app.SetParameterInt("type.mean.radius",4) + prm = app.GetParameters() + if prm["out"] != "myOutput.tif": + exit(1) + if prm["type.mean.radius"] != 4: + exit(1) + prm["in"] = argv[1] + prm["type"] = "anidif" + prm["type.anidif.nbiter"] = 12 + app.SetParameters(prm) + if app.GetParameterString("in") != argv[1]: + exit(1) + if app.GetParameterInt("type.anidif.nbiter") != 12: + exit(1) + -- GitLab From 04d14853c15ee264c7aca6af4bbb924aeaf2e2b9 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 20 Feb 2018 15:39:11 +0100 Subject: [PATCH 286/567] DOC: update CookBook with Get/SetParameters() --- Documentation/Cookbook/rst/recipes/python.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/Cookbook/rst/recipes/python.rst b/Documentation/Cookbook/rst/recipes/python.rst index cbb119372d..33e46e1977 100644 --- a/Documentation/Cookbook/rst/recipes/python.rst +++ b/Documentation/Cookbook/rst/recipes/python.rst @@ -56,6 +56,15 @@ application, changing the algorithm at each iteration. # This will execute the application and save the output file app.ExecuteAndWriteOutput() +If you want to handle the parameters from a Python dictionary, you can use the +functions *SetParameters()* and *GetParameters()*. + +.. code-block:: python + + params = {"in":"myInput.tif", "type.mean.radius":4} + app.SetParameters(params) + params2 = app.GetParameters() + Numpy array processing ---------------------- -- GitLab From 5350109281cc1d95fcaede6ddd11e4cb9c68f84b Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 09:22:46 +0100 Subject: [PATCH 287/567] REFAC: Moving otb::Logger to Core/Common --- .../ApplicationEngine => Core/Common}/include/otbLogger.h | 0 Modules/Core/Common/src/CMakeLists.txt | 1 + .../ApplicationEngine => Core/Common}/src/otbLogger.cxx | 0 Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt | 3 ++- 4 files changed, 3 insertions(+), 1 deletion(-) rename Modules/{Wrappers/ApplicationEngine => Core/Common}/include/otbLogger.h (100%) rename Modules/{Wrappers/ApplicationEngine => Core/Common}/src/otbLogger.cxx (100%) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h similarity index 100% rename from Modules/Wrappers/ApplicationEngine/include/otbLogger.h rename to Modules/Core/Common/include/otbLogger.h diff --git a/Modules/Core/Common/src/CMakeLists.txt b/Modules/Core/Common/src/CMakeLists.txt index 02ff6250e7..50e410e9c8 100644 --- a/Modules/Core/Common/src/CMakeLists.txt +++ b/Modules/Core/Common/src/CMakeLists.txt @@ -29,6 +29,7 @@ set(OTBCommon_SRC otbWriterWatcherBase.cxx otbStopwatch.cxx otbStringToHTML.cxx + otbLogger.cxx ) add_library(OTBCommon ${OTBCommon_SRC}) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx similarity index 100% rename from Modules/Wrappers/ApplicationEngine/src/otbLogger.cxx rename to Modules/Core/Common/src/otbLogger.cxx diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 45d0427a49..de5e6bf15e 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -45,9 +45,10 @@ set( OTBApplicationEngine_SRC otbWrapperStringListParameter.cxx otbWrapperAbstractParameterList.cxx otbWrapperParameterList.cxx - otbLogger.cxx ) +message("Common libraries: ${OTBCommon_LIBRARIES}") + add_library(OTBApplicationEngine ${OTBApplicationEngine_SRC}) target_link_libraries(OTBApplicationEngine ${OTBVectorDataBase_LIBRARIES} -- GitLab From 9243d2602d7e6649a34d5ccdb66482e7474c483f Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 13:37:03 +0100 Subject: [PATCH 288/567] COMP: Fix export of Logger class --- Modules/Core/Common/include/otbLogger.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index ba43072a19..32b34b0635 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -23,6 +23,7 @@ #include "itkLoggerBase.h" #include "itkLogger.h" +#include "OTBCommonExport.h" namespace otb { @@ -33,7 +34,7 @@ namespace otb { * * \ingroup OTBApplicationEngine */ -class Logger : public itk::Logger +class OTBCommon_EXPORT Logger : public itk::Logger { public: typedef Logger Self; -- GitLab From 7967c3f3ef72d7fcf08ae8f91cfc9c8c86ba10e7 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 13:40:06 +0100 Subject: [PATCH 289/567] STY: Small fixes in otb::Logger class --- Modules/Core/Common/include/otbLogger.h | 6 +++--- Modules/Core/Common/src/otbLogger.cxx | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index 32b34b0635..047c225f76 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -42,15 +42,15 @@ public: typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - itkTypeMacro(Logger, Object); + itkTypeMacro(Logger, itk::Logger); itkNewMacro(Self); // Overwrite this to provide custom formatting of log entries - std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; + virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; protected: Logger(); - virtual ~Logger(); + virtual ~Logger() ITK_OVERRIDE; }; // class Logger } // namespace otb diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index f7994eed4d..09f08cb22e 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -24,8 +24,7 @@ namespace otb { -Logger::Logger() : - itk::Logger::Logger() +Logger::Logger() { #if OTB_DEBUG this->SetPriorityLevel(itk::LoggerBase::DEBUG); -- GitLab From 9d41905b2ce199a02e516bfdb244b974f420e445 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 14:06:44 +0100 Subject: [PATCH 290/567] ENH: Make otb::Logger a singleton --- Modules/Core/Common/include/otbLogger.h | 16 +++++++++++++--- Modules/Core/Common/src/otbLogger.cxx | 11 +++++++++++ .../include/otbWrapperApplication.h | 5 ----- .../src/otbWrapperApplication.cxx | 17 +++-------------- .../src/otbWrapperCompositeApplication.cxx | 2 -- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index 047c225f76..7325a9adcd 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -43,14 +43,24 @@ public: typedef itk::SmartPointer< const Self > ConstPointer; itkTypeMacro(Logger, itk::Logger); - itkNewMacro(Self); + static Pointer Instance(); + + // Overwrite this to provide custom formatting of log entries virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; protected: - Logger(); - virtual ~Logger() ITK_OVERRIDE; + itkNewMacro(Self); + Logger(); + virtual ~Logger() ITK_OVERRIDE; + +private: + Logger(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + + static Pointer Singleton; + }; // class Logger } // namespace otb diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index 09f08cb22e..c088a2d5a0 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -24,6 +24,17 @@ namespace otb { +Logger::Pointer Logger::Singleton = ITK_NULLPTR; + +Logger::Pointer Logger::Instance() +{ + if(!Logger::Singleton) + Logger::Singleton = Logger::New(); + + return Logger::Singleton; +} + + Logger::Logger() { #if OTB_DEBUG diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index c6317be142..76ccd9bb5f 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -101,7 +101,6 @@ public: m_Name = name; GetDocExample()->SetApplicationName(name); this->Modified(); - m_Logger->SetName(name); } itkGetStringMacro(Name); @@ -709,9 +708,6 @@ public: otb::Logger* GetLogger() const; - /** Sets the logger instance of the application (use with caution) */ - void SetLogger(otb::Logger *logger); - itk::ProcessObject* GetProgressSource() const; std::string GetProgressDescription() const; @@ -984,7 +980,6 @@ private: std::string m_Name; std::string m_Description; ParameterGroup::Pointer m_ParameterList; - otb::Logger::Pointer m_Logger; itk::ProcessObject::Pointer m_ProgressSource; std::string m_ProgressSourceDescription; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index cca32d50d3..4a7804d527 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -46,6 +46,7 @@ #include <exception> #include "itkMacro.h" + namespace otb { namespace Wrapper @@ -54,7 +55,6 @@ namespace Wrapper Application::Application() : m_Name(""), m_Description(""), - m_Logger(otb::Logger::New()), m_ProgressSourceDescription(""), m_DocName(""), m_DocLongDescription(""), @@ -66,10 +66,7 @@ Application::Application() m_HaveInXML(true), m_HaveOutXML(true), m_IsInXMLParsed(false) -{ - // Don't call Init from the constructor, since it calls a virtual method ! - m_Logger->SetName("Application.logger"); -} +{} Application::~Application() { @@ -77,15 +74,7 @@ Application::~Application() otb::Logger* Application::GetLogger() const { - return m_Logger; -} - -void Application::SetLogger(otb::Logger *logger) -{ - if (m_Logger != logger) - { - m_Logger = logger; - } + return otb::Logger::Instance(); } std::vector<std::string> diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx index db216594f5..7ebfa4d59a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx @@ -62,8 +62,6 @@ CompositeApplication InternalApplication container; container.App = ApplicationRegistry::CreateApplication(appType); container.Desc = desc; - // Setup logger - container.App->SetLogger(this->GetLogger()); container.App->AddObserver(AddProcessToWatchEvent(), m_AddProcessCommand.GetPointer()); m_AppContainer[key] = container; return true; -- GitLab From bd7ed780f5de9b3d11352a005841b19fe7fd7de1 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 15:37:22 +0100 Subject: [PATCH 291/567] ENH: Read log level from env variable in Configuration manager --- .../Common/include/otbConfigurationManager.h | 6 +++- .../Common/src/otbConfigurationManager.cxx | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/otbConfigurationManager.h b/Modules/Core/Common/include/otbConfigurationManager.h index 8c8f9af7cc..4ac1dcc372 100644 --- a/Modules/Core/Common/include/otbConfigurationManager.h +++ b/Modules/Core/Common/include/otbConfigurationManager.h @@ -31,7 +31,7 @@ #include <string> #include <boost/cstdint.hpp> - +#include "itkLoggerBase.h" #include "OTBCommonExport.h" namespace otb @@ -84,6 +84,10 @@ public: */ static RAMValueType GetMaxRAMHint(); + + static itk::LoggerBase::PriorityLevelType GetLoggerLevel(); + + private: ConfigurationManager(); //purposely not implemented ~ConfigurationManager(); //purposely not implemented diff --git a/Modules/Core/Common/src/otbConfigurationManager.cxx b/Modules/Core/Common/src/otbConfigurationManager.cxx index de0ea04579..4add4e19be 100644 --- a/Modules/Core/Common/src/otbConfigurationManager.cxx +++ b/Modules/Core/Common/src/otbConfigurationManager.cxx @@ -23,6 +23,8 @@ #include "itksys/SystemTools.hxx" #include <cstdlib> +#include <algorithm> +#include <string> namespace otb { @@ -59,6 +61,35 @@ ConfigurationManager::RAMValueType ConfigurationManager::GetMaxRAMHint() } return value; +} + + +#define level_macro(x) \ + { \ + std::string target = #x; \ + if(std::equal(svalue.begin(),svalue.end(),target.begin(),target.end())) \ + level = itk::LoggerBase::x; \ + } \ + + +itk::LoggerBase::PriorityLevelType ConfigurationManager::GetLoggerLevel() +{ + std::string svalue; + + #ifndef NDEBUG + itk::LoggerBase::PriorityLevelType level = itk::LoggerBase::DEBUG; + #else + itk::LoggerBase::PriorityLevelType level = itk::LoggerBase::WARNING; + #endif + + if(itksys::SystemTools::GetEnv("OTB_LOGGER_LEVEL",svalue)) + { + level_macro(DEBUG); + level_macro(WARNING); + level_macro(INFO); + } + return level; } + } -- GitLab From fcaf2cf35cf393054355ac9cc5c9960f2c7609ba Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 15:38:47 +0100 Subject: [PATCH 292/567] ENH: Use ConfigurationManager to configure log level in otb::Logger at instaciation time --- Modules/Core/Common/src/otbLogger.cxx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index c088a2d5a0..98b099ac57 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -20,6 +20,7 @@ #include "otbLogger.h" #include "itksys/SystemTools.hxx" +#include "otbConfigurationManager.h" namespace otb { @@ -37,11 +38,7 @@ Logger::Pointer Logger::Instance() Logger::Logger() { -#if OTB_DEBUG - this->SetPriorityLevel(itk::LoggerBase::DEBUG); -#else - this->SetPriorityLevel(itk::LoggerBase::INFO); -#endif + this->SetPriorityLevel(otb::ConfigurationManager::GetLoggerLevel()); this->SetLevelForFlushing(itk::LoggerBase::CRITICAL); -- GitLab From dd762867f5c9bc5275fe84ee0ae901f524b81023 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 15:47:16 +0100 Subject: [PATCH 293/567] STY: Small change in log message --- Modules/Core/Common/include/otbMacro.h | 100 +++++++------------------ 1 file changed, 26 insertions(+), 74 deletions(-) diff --git a/Modules/Core/Common/include/otbMacro.h b/Modules/Core/Common/include/otbMacro.h index 84a5ffc773..4ffd8eed9b 100644 --- a/Modules/Core/Common/include/otbMacro.h +++ b/Modules/Core/Common/include/otbMacro.h @@ -31,6 +31,7 @@ #include "itkMacro.h" #include "itkObject.h" #include "otbConfigure.h" +#include "otbLogger.h" /** * \namespace otb @@ -42,86 +43,37 @@ namespace otb { } // end namespace otb - this is here for documentation purposes -/** This macro is used to print debug (or other information). They are - * also used to catch errors, etc. Example usage looks like: - * itkDebugMacro(<< "this is debug info" << this->SomeVariable); */ -#define otbDebugMacro(x) itkDebugMacro(x) -/* { if ( this->GetDebug() && *::itk::Object::GetGlobalWarningDisplay()) \ - { std::ostringstream itkmsg; \ - itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \ - << this->GetNameOfClass() << " (" << this << "): " x \ - << "\n\n"; \ - ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); } \ -}*/ - -#define otbMsgDebugMacro(x) \ - { \ - if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \ - { \ - std::ostringstream itkmsg; \ - itkmsg << " Msg Debug: " x << "\n"; \ - ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \ - } \ - } +#define otbFileContext(x) \ + << "file " __FILE__ ", line " << __LINE__<<", " x -#ifndef NDEBUG -#define otbGenericMsgDebugMacro(x) \ - { \ - if (::itk::Object::GetGlobalWarningDisplay()) \ - { \ - std::ostringstream itkmsg; \ - itkmsg << " Generic Msg Debug: " x << "\n"; \ - ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \ - } \ - } -#else -#define otbGenericMsgDebugMacro(x) -#endif +#define otbClassContext(x) \ + << this->GetNameOfClass() << " (" << this << "): " x -#define otbGenericMsgTestingMacro(x) \ - { \ - std::cout x << std::endl; \ - } +#define otbLogMacro(level,msg) \ + { \ + std::ostringstream itkmsg; \ + itkmsg msg << "\n"; \ + otb::Logger::Instance()->level(itkmsg.str().c_str()); \ + } -#ifdef OTB_SHOW_ALL_MSG_DEBUG -#define otbMsgDevMacro(x) \ - { \ - { \ - std::ostringstream itkmsg; \ - itkmsg << " Msg Dev: (" << __FILE__ << ":" << __LINE__ << ") " x << "\n"; \ - ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \ - } \ - } -#else -#define otbMsgDevMacro(x) -#endif - -/** This macro is used to print warning information (i.e., unusual circumstance - * but not necessarily fatal.) Example usage looks like: - * itkWarningMacro(<< "this is warning info" << this->SomeVariable); */ -#define otbWarningMacro(x) \ - { \ - if (itk::Object::GetGlobalWarningDisplay()) \ - { \ - std::ostringstream itkmsg; \ - itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \ - << this->GetNameOfClass() << " (" << this << "): " x \ - << "\n\n"; \ - itk::OutputWindowDisplayWarningText(itkmsg.str().c_str()); \ - } \ - } -#define otbGenericWarningMacro(x) \ - { \ - if (itk::Object::GetGlobalWarningDisplay()) \ - { \ - std::ostringstream itkmsg; \ - itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << ": " x <<"\n";\ - itk::OutputWindowDisplayWarningText(itkmsg.str().c_str()); \ - } \ - } +#define otbDebugMacro(x) otbLogMacro(Debug,otbFileContext(otbClassContext(x))) +#define otbMsgDebugMacro(x) otbLogMacro(Debug,otbFileContext(x)) +#define otbGenericMsgDebugMacro(x) otbLogMacro(Debug,x) +#define otbMsgDevMacro(x) otbLogMacro(Info,otbFileContext(x)) +#define otbWarningMacro(x) otbLogMacro(Warning,otbFileContext(otbClassContext(x))) +#define otbGenericWarningMacro(x) otbLogMacro(Warning,otbFileContext(x)) + + + +// TODO: Address this macro as well +#define otbGenericMsgTestingMacro(x) \ + { \ + std::cout x << std::endl; \ + } + /** This macro is used to control condition. It use ONLY by the OTB developers * */ -- GitLab From ce236e90d2151ce1961917dffccb56698121f03f Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 21 Feb 2018 14:42:43 +0100 Subject: [PATCH 294/567] REFAC: cleaning old trace --- .../app/otbPolygonClassStatistics.cxx | 28 +++- .../app/otbDomainTransform.cxx | 4 +- .../Applications/AppTest/app/CMakeLists.txt | 5 - Modules/Applications/AppTest/otb-module.cmake | 1 - .../Core/Common/src/otbFilterWatcherBase.cxx | 1 - .../src/otbStandardOneLineFilterWatcher.cxx | 3 - Modules/Core/ImageBase/include/otbImage.h | 8 +- Modules/Core/ImageBase/include/otbImage.txx | 6 - .../Core/ImageBase/include/otbVectorImage.h | 8 +- .../Core/ImageBase/include/otbVectorImage.txx | 5 - .../Core/ObjectList/include/otbImageList.h | 2 + .../Core/ObjectList/include/otbImageList.txx | 43 ++++-- .../otbPipelineMemoryPrintCalculator.h | 2 +- .../src/otbPipelineMemoryPrintCalculator.cxx | 16 ++- .../include/otbStatisticsXMLFileWriter.txx | 2 +- .../IO/ImageIO/include/otbImageFileWriter.txx | 2 - .../otbWrapperAddProcessToWatchEvent.h | 8 +- .../include/otbWrapperApplication.h | 5 - .../include/otbWrapperOutputImageParameter.h | 2 - .../otbWrapperOutputVectorDataParameter.h | 7 - .../src/otbWrapperApplication.cxx | 131 +----------------- .../src/otbWrapperInputImageParameter.cxx | 6 +- .../src/otbWrapperOutputImageParameter.cxx | 21 --- .../ApplicationEngine/test/CMakeLists.txt | 10 +- .../test/otbApplicationEngineTestDriver.cxx | 2 +- .../src/otbApplicationLauncherCommandLine.cxx | 45 ------ .../src/otbWrapperCommandLineLauncher.cxx | 4 +- .../QtWidget/include/itkQtProgressBar.h | 3 +- .../otbWrapperQtWidgetSimpleProgressReport.h | 1 - .../QtWidget/src/itkQtProgressBar.cxx | 20 --- ...otbWrapperQtWidgetSimpleProgressReport.cxx | 13 -- 31 files changed, 89 insertions(+), 325 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx index ff4f4b01e4..4a35145462 100644 --- a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx +++ b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx @@ -76,7 +76,7 @@ private: SetDocName("Polygon Class Statistics"); SetDocLongDescription("The application processes a set of geometries " "intended for training (they should have a field giving the associated " - "class). The geometries are analysed against a support image to compute " + "class). The geometries are analyzed against a support image to compute " "statistics : \n" " - number of samples per class\n" " - number of samples per geometry\n" @@ -92,17 +92,17 @@ private: AddDocTag(Tags::Learning); - AddParameter(ParameterType_InputImage, "in", "InputImage"); + AddParameter(ParameterType_InputImage, "in", "Input image"); SetParameterDescription("in", "Support image that will be classified"); - AddParameter(ParameterType_InputImage, "mask", "InputMask"); + AddParameter(ParameterType_InputImage, "mask", "Input validity mask"); SetParameterDescription("mask", "Validity mask (only pixels corresponding to a mask value greater than 0 will be used for statistics)"); MandatoryOff("mask"); AddParameter(ParameterType_InputFilename, "vec", "Input vectors"); - SetParameterDescription("vec","Input geometries to analyse"); + SetParameterDescription("vec","Input geometries to analyze"); - AddParameter(ParameterType_OutputFilename, "out", "Output Statistics"); + AddParameter(ParameterType_OutputFilename, "out", "Output XML statistics file"); SetParameterDescription("out","Output file to store statistics (XML format)"); AddParameter(ParameterType_ListView, "field", "Field Name"); @@ -155,6 +155,22 @@ private: } } } + + // Check that the extension of the output parameter is XML (mandatory for + // StatisticsXMLFileWriter) + // Check it here to trigger the error before polygons analysis + + if ( HasValue("out") ) + { + // Store filename extension + // Check that the right extension is given : expected .xml + const std::string extension = itksys::SystemTools::GetFilenameLastExtension(this->GetParameterString("out")); + + if (itksys::SystemTools::LowerCase(extension) != ".xml") + { + otbAppLogFATAL( << extension << " is a wrong extension for parameter \"out\": Expected .xml" ); + } + } } void DoExecute() ITK_OVERRIDE @@ -223,7 +239,7 @@ private: filter->SetLayerIndex(this->GetParameterInt("layer")); filter->GetStreamer()->SetAutomaticAdaptativeStreaming(GetParameterInt("ram")); - AddProcess(filter->GetStreamer(),"Analyse polygons..."); + AddProcess(filter->GetStreamer(),"Analyze polygons..."); filter->Update(); FilterType::ClassCountMapType &classCount = filter->GetClassCountOutput()->Get(); diff --git a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx index c3321c2bb5..c853f4863b 100644 --- a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx +++ b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx @@ -277,7 +277,7 @@ private: //typedef itk::::ForwardFFTImageFilter over otbImage< InputPixelType > - typedef itk::ForwardFFTImageFilter < TInputImage, OutputImageType > FFTFilter; + typedef itk::ForwardFFTImageFilter < TInputImage, ComplexOutputImageType > FFTFilter; FFTFilter::Pointer fwdFilter = FFTFilter::New(); fwdFilter->SetInput( inImage ); @@ -286,7 +286,7 @@ private: typedef otb::VectorImage<OutputPixelType> TOutputImage; typedef otb::ComplexToVectorImageCastFilter< - OutputImageType, + ComplexOutputImageType, TOutputImage > ComplexToVectorImageCastFilter; ComplexToVectorImageCastFilter::Pointer unaryFunctorImageFilter = ComplexToVectorImageCastFilter::New(); diff --git a/Modules/Applications/AppTest/app/CMakeLists.txt b/Modules/Applications/AppTest/app/CMakeLists.txt index 3322351683..44d54be96b 100644 --- a/Modules/Applications/AppTest/app/CMakeLists.txt +++ b/Modules/Applications/AppTest/app/CMakeLists.txt @@ -22,8 +22,3 @@ otb_create_application( NAME TestApplication SOURCES otbTestApplication.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES}) - -otb_create_application( - NAME MemoryTest - SOURCES otbMemoryTestApplication.cxx - LINK_LIBRARIES ${${otb-module}_LIBRARIES}) \ No newline at end of file diff --git a/Modules/Applications/AppTest/otb-module.cmake b/Modules/Applications/AppTest/otb-module.cmake index d67ae1c326..fc492e17d8 100644 --- a/Modules/Applications/AppTest/otb-module.cmake +++ b/Modules/Applications/AppTest/otb-module.cmake @@ -23,7 +23,6 @@ set(DOCUMENTATION "Test application.") otb_module(OTBAppTest DEPENDS OTBApplicationEngine - OTBImageBase TEST_DEPENDS OTBTestKernel OTBCommandLine diff --git a/Modules/Core/Common/src/otbFilterWatcherBase.cxx b/Modules/Core/Common/src/otbFilterWatcherBase.cxx index bbb564b02c..2e4f9644bb 100644 --- a/Modules/Core/Common/src/otbFilterWatcherBase.cxx +++ b/Modules/Core/Common/src/otbFilterWatcherBase.cxx @@ -159,7 +159,6 @@ FilterWatcherBase FilterWatcherBase ::~FilterWatcherBase() { - std::cout<<"A FilterWatcherBase is deleted... Description was "<<m_Comment<<std::endl; // Remove any observers we have on the old process object if (m_Process) { diff --git a/Modules/Core/Common/src/otbStandardOneLineFilterWatcher.cxx b/Modules/Core/Common/src/otbStandardOneLineFilterWatcher.cxx index 84c67d05c9..77e350402f 100644 --- a/Modules/Core/Common/src/otbStandardOneLineFilterWatcher.cxx +++ b/Modules/Core/Common/src/otbStandardOneLineFilterWatcher.cxx @@ -29,7 +29,6 @@ StandardOneLineFilterWatcher : m_StarsCount(50), m_CurrentNbStars(-1) { - std::cout<<"A StandardOneLineFilterWatcher is created (default)"<<std::endl; } StandardOneLineFilterWatcher @@ -39,7 +38,6 @@ StandardOneLineFilterWatcher m_StarsCount(50), m_CurrentNbStars(-1) { - std::cout<<"A StandardOneLineFilterWatcher is created with description "<<comment<<std::endl; } StandardOneLineFilterWatcher @@ -49,7 +47,6 @@ StandardOneLineFilterWatcher m_StarsCount(50), m_CurrentNbStars(-1) { - std::cout<<"A StandardOneLineFilterWatcher is created with description "<<comment<<std::endl; } void diff --git a/Modules/Core/ImageBase/include/otbImage.h b/Modules/Core/ImageBase/include/otbImage.h index 4eb2ec9388..3bec599c72 100644 --- a/Modules/Core/ImageBase/include/otbImage.h +++ b/Modules/Core/ImageBase/include/otbImage.h @@ -179,7 +179,7 @@ public: // { // return AccessorType(); // } - static int m_Instance; + /** Return the NeighborhoodAccessor functor */ NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() { @@ -252,11 +252,7 @@ public: protected: Image(); - ~Image() ITK_OVERRIDE { - std::cout<<"An image is deleted"<<std::endl; - m_Instance--; - std::cout<<m_Instance<<" image(s) still live(s)"<<std::endl; - } + ~Image() ITK_OVERRIDE {} private: Image(const Self &) = delete; diff --git a/Modules/Core/ImageBase/include/otbImage.txx b/Modules/Core/ImageBase/include/otbImage.txx index 6127e6b48d..096a725960 100644 --- a/Modules/Core/ImageBase/include/otbImage.txx +++ b/Modules/Core/ImageBase/include/otbImage.txx @@ -29,15 +29,9 @@ namespace otb { -template <class TPixel, unsigned int VImageDimension> -int Image<TPixel, VImageDimension>::m_Instance = 0; - template <class TPixel, unsigned int VImageDimension> Image<TPixel, VImageDimension>::Image() { - std::cout<<"An image is created"<<std::endl; - m_Instance++; - std::cout<<m_Instance<<" image(s) live(s)"<<std::endl; } template <class TPixel, unsigned int VImageDimension> diff --git a/Modules/Core/ImageBase/include/otbVectorImage.h b/Modules/Core/ImageBase/include/otbVectorImage.h index edd3b267c9..2fa39e599a 100644 --- a/Modules/Core/ImageBase/include/otbVectorImage.h +++ b/Modules/Core/ImageBase/include/otbVectorImage.h @@ -179,7 +179,7 @@ public: // { // return AccessorType( this->GetNumberOfComponentsPerPixel() ); // } - static int m_Instance; + /** Return the NeighborhoodAccessor functor */ NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() { @@ -194,11 +194,7 @@ public: protected: VectorImage(); - ~VectorImage() ITK_OVERRIDE { - std::cout<<"A vector image is deleted"<<std::endl; - m_Instance--; - std::cout<<m_Instance<<" vector image(s) still live(s)"<<std::endl; - } + ~VectorImage() ITK_OVERRIDE {} private: VectorImage(const Self &); //purposely not implemented diff --git a/Modules/Core/ImageBase/include/otbVectorImage.txx b/Modules/Core/ImageBase/include/otbVectorImage.txx index 0d95d4c6e9..f6123af584 100644 --- a/Modules/Core/ImageBase/include/otbVectorImage.txx +++ b/Modules/Core/ImageBase/include/otbVectorImage.txx @@ -29,15 +29,10 @@ namespace otb { -template <class TPixel, unsigned int VImageDimension> -int VectorImage<TPixel, VImageDimension>::m_Instance = 0; template <class TPixel, unsigned int VImageDimension> VectorImage<TPixel, VImageDimension>::VectorImage() { - std::cout<<"A vector image is created"<<std::endl; - m_Instance++; - std::cout<<m_Instance<<" vector image(s) live(s)"<<std::endl; } template <class TPixel, unsigned int VImageDimension> diff --git a/Modules/Core/ObjectList/include/otbImageList.h b/Modules/Core/ObjectList/include/otbImageList.h index 611d84a47a..4cb77bddec 100644 --- a/Modules/Core/ObjectList/include/otbImageList.h +++ b/Modules/Core/ObjectList/include/otbImageList.h @@ -68,6 +68,8 @@ public: throw (itk::InvalidRequestedRegionError) ITK_OVERRIDE; void UpdateOutputData(void) ITK_OVERRIDE; + void SetRequestedRegion(const itk::DataObject * source); + protected: /** Constructor */ ImageList() {}; diff --git a/Modules/Core/ObjectList/include/otbImageList.txx b/Modules/Core/ObjectList/include/otbImageList.txx index dc0cbc9b6f..dec0ab8b3e 100644 --- a/Modules/Core/ObjectList/include/otbImageList.txx +++ b/Modules/Core/ObjectList/include/otbImageList.txx @@ -39,10 +39,32 @@ ImageList<TImage> || it.Get()->GetDataReleased() || it.Get()->RequestedRegionIsOutsideOfTheBufferedRegion()) { + if(it.Get()->GetSource()) + { + it.Get()->GetSource()->UpdateOutputData(it.Get()); + } + } + } +} + +template <class TImage> +void +ImageList<TImage> +::PropagateRequestedRegion() throw (itk::InvalidRequestedRegionError) + { + Superclass::PropagateRequestedRegion(); + + for (ConstIterator it = this->Begin(); it != this->End(); ++it) + { + if (it.Get()->GetUpdateMTime() < it.Get()->GetPipelineMTime() + || it.Get()->GetDataReleased() + || it.Get()->RequestedRegionIsOutsideOfTheBufferedRegion()) + { + if (it.Get()->GetSource()) { it.Get()->GetSource()->PropagateRequestedRegion(it.Get()); - + // Check that the requested region lies within the largest possible region if (!it.Get()->VerifyRequestedRegion()) { @@ -51,23 +73,24 @@ ImageList<TImage> e.SetLocation(ITK_LOCATION); e.SetDataObject(it.Get()); e.SetDescription("Requested region is (at least partially) outside the largest possible region."); - + throw e; } - - it.Get()->GetSource()->UpdateOutputData(it.Get()); } } } -} + } -template <class TImage> +template<class TImage> void ImageList<TImage> -::PropagateRequestedRegion() throw (itk::InvalidRequestedRegionError) - { - Superclass::PropagateRequestedRegion(); - } +::SetRequestedRegion(const itk::DataObject * source) +{ + for (ConstIterator it = this->Begin(); it != this->End(); ++it) + { + it.Get()->SetRequestedRegion(source); + } +} template <class TImage> void diff --git a/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h b/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h index 826478711d..41fe7808e9 100644 --- a/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h +++ b/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h @@ -121,7 +121,7 @@ public: static const double MegabyteToByte; /** Evaluate the print (in bytes) of a single data object */ - MemoryPrintType EvaluateDataObjectPrint(DataObjectType * data) const; + MemoryPrintType EvaluateDataObjectPrint(DataObjectType * data); protected: /** Constructor */ diff --git a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx index 033c58bc37..d7d62e8c88 100644 --- a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx +++ b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx @@ -162,7 +162,7 @@ PipelineMemoryPrintCalculator PipelineMemoryPrintCalculator::MemoryPrintType PipelineMemoryPrintCalculator -::EvaluateDataObjectPrint(DataObjectType * data) const +::EvaluateDataObjectPrint(DataObjectType * data) { otbMsgDevMacro(<< "EvaluateMemoryPrint for " << data->GetNameOfClass() << " (" << data << ")") @@ -183,11 +183,13 @@ PipelineMemoryPrintCalculator { \ ImageList<Image<type, 2> > * imageList = dynamic_cast<otb::ImageList<otb::Image<type, 2> > *>(data); \ MemoryPrintType print(0); \ - for(ImageList<Image<type, 2> >::ConstIterator it = imageList->Begin(); \ + for(ImageList<Image<type, 2> >::Iterator it = imageList->Begin(); \ it != imageList->End(); ++it) \ { \ - print += it.Get()->GetRequestedRegion().GetNumberOfPixels() \ - * it.Get()->GetNumberOfComponentsPerPixel() * sizeof(type); \ + if(it.Get()->GetSource()) \ + print += this->EvaluateProcessObjectPrintRecursive(it.Get()->GetSource());\ + else \ + print += this->EvaluateDataObjectPrint(it.Get()); \ } \ return print; \ } \ @@ -198,8 +200,10 @@ PipelineMemoryPrintCalculator for(ImageList<VectorImage<type, 2> >::ConstIterator it = imageList->Begin(); \ it != imageList->End(); ++it) \ { \ - print += it.Get()->GetRequestedRegion().GetNumberOfPixels() \ - * it.Get()->GetNumberOfComponentsPerPixel() * sizeof(type); \ + if(it.Get()->GetSource()) \ + print += this->EvaluateProcessObjectPrintRecursive(it.Get()->GetSource());\ + else \ + print += this->EvaluateDataObjectPrint(it.Get()); \ } \ return print; \ } \ diff --git a/Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.txx b/Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.txx index f1d830132a..b20416b4d7 100644 --- a/Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.txx +++ b/Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.txx @@ -72,7 +72,7 @@ StatisticsXMLFileWriter<TMeasurementVector> itkExceptionMacro(<<"The XML output FileName is empty, please set the filename via the method SetFileName"); // Check that the right extension is given : expected .xml */ - std::string extension = itksys::SystemTools::GetFilenameLastExtension(m_FileName); + const std::string extension = itksys::SystemTools::GetFilenameLastExtension(m_FileName); if (itksys::SystemTools::LowerCase(extension) != ".xml") { itkExceptionMacro(<<extension diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index 62b9338f30..b1472291f1 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -80,7 +80,6 @@ ImageFileWriter<TInputImage> this->SetAutomaticAdaptativeStreaming(); m_FilenameHelper = FNameHelperType::New(); - std::cout<<"A writer is created"<<std::endl; } /** @@ -90,7 +89,6 @@ template <class TInputImage> ImageFileWriter<TInputImage> ::~ImageFileWriter() { - std::cout<<"A writer is deleted"<<std::endl; } template <class TInputImage> diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h index 129e1e74ea..3cf9114c81 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h @@ -44,13 +44,9 @@ public: typedef AddProcessToWatchEvent Self; typedef itk::EventObject Superclass; - AddProcessToWatchEvent(){ - std::cout<<"A new AddProcessToWatchEvent is created"<<std::endl; - } + AddProcessToWatchEvent(){} AddProcessToWatchEvent(const Self& s) :itk::EventObject(s){}; - ~AddProcessToWatchEvent() ITK_OVERRIDE { - std::cout<<"The AddProcessToWatchEvent is deleted... Description was : "<<m_ProcessDescription<<std::endl; - } + ~AddProcessToWatchEvent() ITK_OVERRIDE {} /** Set/Get the process to watch */ virtual void SetProcess(itk::ProcessObject * process) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 556a1f11cb..e5b6ea2dcf 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -154,10 +154,6 @@ public: */ int ExecuteAndWriteOutput(); - /** Clear the pipeline and the various parameters that hold data - */ - virtual void ClearMemory(); - /* Get the internal application parameters * * WARNING: this method may disappear from the API */ @@ -849,7 +845,6 @@ public: } void RegisterPipeline(); - void ReleaseDataFromPipeline(); std::vector<itk::ProcessObject::Pointer> m_Filters; protected: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index 55b6145035..fd0c392b70 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -113,8 +113,6 @@ public: std::string CheckFileName(bool fixMissingExtension = false); - void ClearValue() override; - protected: /** Constructor */ OutputImageParameter(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h index adf5faf96f..fb90702544 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h @@ -107,13 +107,6 @@ public: m_Writer = otb::VectorDataFileWriter<VectorDataType>::New(); } - void ClearValue() override - { - m_Writer = nullptr; - m_VectorData = nullptr; - // m_FileName = ""; - Superclass::ClearValue(); - } protected: /** Constructor */ OutputVectorDataParameter() diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 9367558dc0..69df972b30 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -485,72 +485,6 @@ int Application::Execute() return 0; } -void -Application::ReleaseDataFromPipeline() -{ - std::stack< itk::DataObject * > dataStack; - std::set< itk::DataObject * > dataSet; - std::vector<std::string> paramList = GetParametersKeys(true); - for (std::vector<std::string>::const_iterator it = paramList.begin(); - it != paramList.end(); - ++it) - { - std::string key = *it; - if ( GetParameterType(key) == ParameterType_OutputImage ) - { - Parameter* param = GetParameterByKey(key); - OutputImageParameter * outP = dynamic_cast<OutputImageParameter*>(param); - itk::ImageBase<2> * outData = outP->GetValue(); - std::cout<<"one image in output"<<std::endl; - dataSet.insert(outData); - } - else if ( GetParameterType(key) == ParameterType_OutputVectorData ) - { - Parameter* param = GetParameterByKey(key); - OutputVectorDataParameter * outP = dynamic_cast<OutputVectorDataParameter*>(param); - Wrapper::VectorDataType * outData = outP->GetValue(); - dataSet.insert(outData); - } - else - continue; - } - // DFS - std::stack< itk::ProcessObject * > processStack; - for ( auto data : dataSet ) - { - auto process = (data->GetSource()).GetPointer(); - if ( process != nullptr ) - processStack.push( process ); - } - - while ( !processStack.empty() ) - { - std::cout<<"one process is processed"<<std::endl; - itk::ProcessObject * current = processStack.top(); - std::cout<<"top"<<std::endl; - processStack.pop(); - std::cout<<"pop"<<std::endl; - std::cout<<current->GetNameOfClass()<<std::endl; - auto inputVector = current->GetInputs(); - for ( auto data : inputVector ) - { - if ( dataSet.find( data.GetPointer() ) != dataSet.end() && data != nullptr ) - continue; - std::cout<<"one data is stored"<<std::endl; - dataSet.insert( data.GetPointer() ); - itk::ProcessObject * process = data->GetSource().GetPointer(); - if ( process != nullptr ) - processStack.push( process ); - } - } - - for ( auto data : dataSet ) - { - std::cout<<"one bulk is freed"<<std::endl; - data->ReleaseData(); - } -} - int Application::ExecuteAndWriteOutput() { std::cout<<"Executing..."<<std::endl; @@ -665,73 +599,10 @@ int Application::ExecuteAndWriteOutput() this->AfterExecuteAndWriteOutputs(); m_Chrono.Stop(); - ReleaseDataFromPipeline(); - ClearMemory(); + return status; } -void Application::ClearMemory() -{ - // Cleaning the parameter input and output - std::vector<std::string> paramList = GetParametersKeys(true); - std::string filename (""); - for (std::vector<std::string>::const_iterator it = paramList.begin(); - it != paramList.end(); - ++it) - { - std::string key = *it; - // if (GetParameterType(key) == ParameterType_InputImage ) - // { - // Parameter* param = GetParameterByKey(key); - // InputImageParameter * input = dynamic_cast<InputImageParameter*>(param); - // filename = input->GetFileName(); - // input->ClearValue(); - // input->SetFromFileName(filename); - // } - // else if (GetParameterType(key) == ParameterType_InputImageList ) - // { - // Parameter* param = GetParameterByKey(key); - // InputImageListParameter * input = dynamic_cast<InputImageListParameter*>(param); - // std::vector< std::string > filenamelist = input->GetFileNameList(); - // input->ClearValue(); - // input->SetListFromFileName(filenamelist); - // } - // else if (GetParameterType(key) == ParameterType_InputVectorData ) - // { - // Parameter* param = GetParameterByKey(key); - // InputVectorDataParameter * input = dynamic_cast<InputVectorDataParameter*>(param); - // filename = input->GetFileName(); - // input->ClearValue(); - // input->SetFromFileName(filename); - // } - // else if (GetParameterType(key) == ParameterType_InputVectorDataList ) - // { - // Parameter* param = GetParameterByKey(key); - // InputVectorDataListParameter * input = dynamic_cast<InputVectorDataListParameter*>(param); - // std::vector< std::string > filenamelist = input->GetFileNameList(); - // input->ClearValue(); - // input->SetListFromFileName(filenamelist); - // } - if (GetParameterType(key) == ParameterType_OutputImage ) - { - Parameter* param = GetParameterByKey(key); - OutputImageParameter * output = dynamic_cast<OutputImageParameter*>(param); - filename = output->GetFileName(); - output->ClearValue(); - output->SetFileName(filename); - } - else - { - continue; - } - } - - // Cleaning m_ProgressSource - // m_ProgressSource = nullptr; - - // Cleaning m_Filters - m_Filters.clear(); -} /* Enable the use of an optional parameter. Returns the previous state */ void Application::EnableParameter(std::string paramKey) { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx index 3c5adf6fe6..fe226ef2ff 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx @@ -104,9 +104,9 @@ void InputImageParameter ::ClearValue() { - m_Image = nullptr; - m_Reader = nullptr; - m_Caster = nullptr; + m_Image = ITK_NULLPTR; + m_Reader = ITK_NULLPTR; + m_Caster = ITK_NULLPTR; m_FileName = ""; m_PreviousFileName=""; m_UseFilename = true; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 37d91b86d0..d0dd667879 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -651,26 +651,5 @@ OutputImageParameter::CheckFileName(bool fixMissingExtension) return ret; } -void OutputImageParameter::ClearValue() -{ - m_Image = nullptr; - // m_FileName = ""; - - m_VectorUInt8Writer = nullptr; - m_VectorInt16Writer = nullptr; - m_VectorUInt16Writer = nullptr; - m_VectorInt32Writer = nullptr; - m_VectorUInt32Writer = nullptr; - m_VectorFloatWriter = nullptr; - m_VectorDoubleWriter = nullptr; - - m_RGBUInt8Writer = nullptr; - m_RGBAUInt8Writer = nullptr; - - // m_RAMValue = 0; - - Superclass::ClearValue(); -} - } } diff --git a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt index 2018d29e92..319466cb4c 100644 --- a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt @@ -171,11 +171,11 @@ otb_add_test(NAME owTvOutputImageParameter COMMAND otbApplicationEngineTestDrive "my description" ) -otb_add_test(NAME owTvOutputImageParameterConversion COMMAND otbApplicationEngineTestDriver - otbWrapperOutputImageParameterConversionTest - ${INPUTDATA}/poupees.tif - ${TEMP}/poupees_out.tif - ) +#~ otb_add_test(NAME owTvOutputImageParameterConversion COMMAND otbApplicationEngineTestDriver + #~ otbWrapperOutputImageParameterConversionTest + #~ ${INPUTDATA}/poupees.tif + #~ ${TEMP}/poupees_out.tif + #~ ) otb_add_test(NAME owTvDocExampleStructureTest COMMAND otbApplicationEngineTestDriver --compare-ascii ${NOTOL} diff --git a/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx b/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx index 17a6d631ba..5ccef49653 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx +++ b/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx @@ -51,6 +51,6 @@ void RegisterTests() REGISTER_TEST(otbWrapperInputVectorDataParameterNew); REGISTER_TEST(otbWrapperOutputImageParameterNew); REGISTER_TEST(otbWrapperOutputImageParameterTest1); - REGISTER_TEST(otbWrapperOutputImageParameterConversionTest); + //~ REGISTER_TEST(otbWrapperOutputImageParameterConversionTest); REGISTER_TEST(otbApplicationMemoryConnectTest); } diff --git a/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx b/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx index 0e19743f40..4c5bd8a93f 100644 --- a/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx +++ b/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx @@ -22,7 +22,6 @@ #include "otbWrapperCommandLineLauncher.h" #include "otb_tinyxml.h" #include <vector> -#include <iostream> #ifdef OTB_USE_MPI #include "otbMPIConfig.h" @@ -305,53 +304,9 @@ int main(int argc, char* argv[]) ShowUsage(argv); return false; } - goto RUN; - RUN : - for (auto i : vexp) - std::cout<<i<<" "; - std::cout<<std::endl; bool success = launcher->Load(vexp) && launcher->ExecuteAndWriteOutput(); - - std::string answer; - std::cout<<"Rerun or run with other args? r : rerun ; s : small test ; b : big test ; else quit "<<std::endl; - std::cin >> answer; - if ( answer[0]=='r') - { - std::cout<<"again"<<std::endl; - goto RUN; - } - else if ( answer[0]=='s' ) - { - std::cout<<"Small test running"<<std::endl; - vexp[2] = "/home/antoine/dev/my_data/anaglyphInput2.tif"; - vexp[4] = "/home/antoine/dev/my_data/anaglyphOut.tif"; - goto RUN; - } - else if ( answer[0]=='b' ) - { - std::cout<<"Big test running"<<std::endl; - vexp[2] = "/home/antoine/dev/my_data/bigbigtestclassic.tif"; - vexp[4] = "/home/antoine/dev/my_data/bigbigtestclasssic.tif"; - goto RUN; - } - // else - // { - // vexp.clear(); - // for (int i = 1; i < argc; i++) - // { - // std::string strarg(answer[i]); - // std::string cleanArg = CleanWord(strarg); - // if (cleanArg.empty()) - // { - // // Empty argument ! - // continue; - // } - // vexp.push_back(cleanArg); - // } - // goto RUN; - // } // shutdown MPI after application finished #ifdef OTB_USE_MPI otb::MPIConfig::Instance()->terminate(); diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx index 7b5caa5d02..cf70dc07b7 100644 --- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx +++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx @@ -188,9 +188,7 @@ bool CommandLineLauncher::ExecuteAndWriteOutput() m_Application->GetLogger()->Fatal("Caught unknown exception during application execution.\n"); return false; } - - // Cleaning process - DeleteWatcherList(); + return true; } diff --git a/Modules/Wrappers/QtWidget/include/itkQtProgressBar.h b/Modules/Wrappers/QtWidget/include/itkQtProgressBar.h index 9e50a25914..5dd5b1b482 100644 --- a/Modules/Wrappers/QtWidget/include/itkQtProgressBar.h +++ b/Modules/Wrappers/QtWidget/include/itkQtProgressBar.h @@ -52,11 +52,10 @@ public: void ProcessEvent(itk::Object * caller, const itk::EventObject & event ); void ConstProcessEvent(const itk::Object * caller, const itk::EventObject & event ); + /** Manage a Progress event */ void Observe( itk::Object *caller ); - void ClearObserver(); - signals: void SetValueChanged(int); diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetSimpleProgressReport.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetSimpleProgressReport.h index 3a60401cd1..3f5c4605bf 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetSimpleProgressReport.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetSimpleProgressReport.h @@ -61,7 +61,6 @@ public slots: void AddNewProcessToReport(); private: - void ClearEvent(); QtWidgetSimpleProgressReport(const QtWidgetSimpleProgressReport&); //purposely not implemented void operator=(const QtWidgetSimpleProgressReport&); //purposely not //implemented diff --git a/Modules/Wrappers/QtWidget/src/itkQtProgressBar.cxx b/Modules/Wrappers/QtWidget/src/itkQtProgressBar.cxx index 0f799d02a8..ba8070ca0b 100644 --- a/Modules/Wrappers/QtWidget/src/itkQtProgressBar.cxx +++ b/Modules/Wrappers/QtWidget/src/itkQtProgressBar.cxx @@ -98,24 +98,4 @@ QtProgressBar::Observe( itk::Object *caller ) m_Caller->AddObserver( itk::ProgressEvent(), m_RedrawCommand.GetPointer() ); } -void -QtProgressBar::ClearObserver() -{ - if ( m_Caller->HasObserver(itk::ProgressEvent()) ) - { - unsigned int i(0); - while ( (m_Caller->GetCommand(i)) != (m_RedrawCommand.GetPointer()) ) - { - ++i; - if (i>10) - std::cout<<"ERROR"<<std::endl; - } - std::cout<<i<<std::endl; - m_Caller->RemoveObserver(i); - - } - m_Caller = nullptr; - // m_Caller->RemoveAllObservers(); -} - } // end namespace fltk diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx index 1a11aea5ad..c8347b23d9 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSimpleProgressReport.cxx @@ -78,24 +78,12 @@ QtWidgetSimpleProgressReport::ProcessEvent( itk::Object * itkNotUsed(caller), if(eventToWatch) { m_CurrentProcess = eventToWatch->GetProcess(); - std::cout<<"process in the box : "<<m_CurrentProcess->GetNameOfClass()<<std::endl; m_CurrentDescription = eventToWatch->GetProcessDescription(); - std::cout<<"Description is : "<<m_CurrentDescription<<std::endl; emit AddNewProcessToReport(); } } } -void -QtWidgetSimpleProgressReport::ClearEvent() -{ - std::cout<<"Cleaning event"<<std::endl; - m_CurrentProcess = nullptr; - m_CurrentDescription = ""; - // emit AddNewProcessToReport(); - m_Bar->ClearObserver(); -} - void QtWidgetSimpleProgressReport::ReportProcess() { m_Bar->Observe(m_CurrentProcess); @@ -105,7 +93,6 @@ void QtWidgetSimpleProgressReport::ReportProcess() void QtWidgetSimpleProgressReport::Init() { - // ClearEvent(); m_Bar->setValue(0); m_Label->setText("No process"); } -- GitLab From 01ddcd99d9f8ef2b37c6cca223c73aa2bdb7ef81 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 22 Feb 2018 10:24:57 +0100 Subject: [PATCH 295/567] REFAC: expose only one ImageBaseType --- .../include/otbWrapperApplication.h | 12 ++++++------ .../include/otbWrapperComplexInputImageParameter.h | 2 -- .../include/otbWrapperComplexOutputImageParameter.h | 2 -- .../include/otbWrapperInputImageListParameter.h | 2 -- .../include/otbWrapperInputImageParameter.h | 2 -- .../include/otbWrapperOutputImageParameter.h | 2 -- .../ApplicationEngine/include/otbWrapperTypes.h | 2 ++ .../ApplicationEngine/src/otbWrapperApplication.cxx | 12 ++++++------ .../src/otbWrapperComplexOutputImageParameter.cxx | 2 +- .../src/otbWrapperOutputImageParameter.cxx | 2 +- 10 files changed, 16 insertions(+), 24 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index f97134cbd1..7fc61ce68b 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -475,7 +475,7 @@ public: * \throw itk::Exception if parameter is not found or not an * InputImageParameter */ - void SetParameterInputImage(std::string parameter, InputImageParameter::ImageBaseType * inputImage); + void SetParameterInputImage(std::string parameter, ImageBaseType * inputImage); /** * Get the output image parameter as an ImageBase * instead @@ -486,7 +486,7 @@ public: * \throw itk::Exception if parameter is not found or not an * OutputImageParameter */ - OutputImageParameter::ImageBaseType * GetParameterOutputImage(std::string parameter); + ImageBaseType * GetParameterOutputImage(std::string parameter); /** * Set the input complex image parameter as an ImageBase * instead @@ -497,7 +497,7 @@ public: * \throw itk::Exception if parameter is not found or not an * ComplexInputImageParameter */ - void SetParameterComplexInputImage(std::string parameter, ComplexInputImageParameter::ImageBaseType * inputImage); + void SetParameterComplexInputImage(std::string parameter, ImageBaseType * inputImage); /** * Get the complex output image parameter as an ImageBase * instead @@ -508,7 +508,7 @@ public: * \throw itk::Exception if parameter is not found or not an * ComplexOutputImageParameter */ - ComplexOutputImageParameter::ImageBaseType * GetParameterComplexOutputImage(std::string parameter); + ImageBaseType * GetParameterComplexOutputImage(std::string parameter); /** * Add an image to an InputImageList parameter as an ImageBase @@ -519,7 +519,7 @@ public: * \throw itk::Exception if parameter is not found or not an * InputImageList parameter */ - void AddImageToParameterInputImageList(std::string parameter, InputImageListParameter::ImageBaseType * img); + void AddImageToParameterInputImageList(std::string parameter, ImageBaseType * img); /** * Set the nth image of an InputImageList parameter as an ImageBase pointer @@ -531,7 +531,7 @@ public: * \throw itk::Exception if parameter is not found or not an * InputImageList parameter or if id is out of bounds */ - void SetNthParameterInputImageList(std::string parameter, const unsigned int &id, InputImageListParameter::ImageBaseType * img); + void SetNthParameterInputImageList(std::string parameter, const unsigned int &id, ImageBaseType * img); /** * Add a value to a parameter list as a string diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h index 1fa00dd77d..030ece38b1 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h @@ -44,8 +44,6 @@ public: typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - typedef itk::ImageBase<2> ImageBaseType; - /** Defining ::New() static method */ itkNewMacro(Self); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h index 371c4d4166..ef3e06fb1c 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h @@ -44,8 +44,6 @@ public: typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - typedef itk::ImageBase<2> ImageBaseType; - /** Defining ::New() static method */ itkNewMacro(Self); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h index 889e6d8df2..914ab7b249 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h @@ -48,8 +48,6 @@ public: typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef itk::ImageBase< 2 > ImageBaseType; - /** Defining ::New() static method */ itkNewMacro( Self ); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h index 6ff36eedee..a82fdca9a4 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h @@ -44,8 +44,6 @@ public: typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - typedef itk::ImageBase<2> ImageBaseType; - /** Defining ::New() static method */ itkNewMacro(Self); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index b420299ff6..d29a5b6c37 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -45,8 +45,6 @@ public: typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - typedef itk::ImageBase<2> ImageBaseType; - /** Defining ::New() static method */ itkNewMacro(Self); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h index 63dafb639b..3b964f227a 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h @@ -141,6 +141,8 @@ typedef otb::ObjectList<VectorDataType> VectorDataListType; typedef otb::ObjectList<FloatVectorImageType> FloatVectorImageListType; typedef otb::ObjectList<FloatImageType> FloatImageListType; +typedef itk::ImageBase<2> ImageBaseType; + } // end namespace Wrapper } // end namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index cca32d50d3..3a69b616f2 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1180,7 +1180,7 @@ Application return ret; } -void Application::SetParameterInputImage(std::string parameter, InputImageParameter::ImageBaseType * inputImage) +void Application::SetParameterInputImage(std::string parameter, ImageBaseType * inputImage) { Parameter* param = GetParameterByKey(parameter); @@ -1196,7 +1196,7 @@ void Application::SetParameterInputImage(std::string parameter, InputImageParame } } -OutputImageParameter::ImageBaseType * Application::GetParameterOutputImage(std::string parameter) +ImageBaseType * Application::GetParameterOutputImage(std::string parameter) { Parameter* param = GetParameterByKey(parameter); @@ -1213,7 +1213,7 @@ OutputImageParameter::ImageBaseType * Application::GetParameterOutputImage(std:: } -void Application::SetParameterComplexInputImage(std::string parameter, ComplexInputImageParameter::ImageBaseType * inputImage) +void Application::SetParameterComplexInputImage(std::string parameter, ImageBaseType * inputImage) { Parameter* param = GetParameterByKey(parameter); @@ -1229,7 +1229,7 @@ void Application::SetParameterComplexInputImage(std::string parameter, ComplexIn } } -ComplexOutputImageParameter::ImageBaseType * Application::GetParameterComplexOutputImage(std::string parameter) +ImageBaseType * Application::GetParameterComplexOutputImage(std::string parameter) { Parameter* param = GetParameterByKey(parameter); @@ -1245,7 +1245,7 @@ ComplexOutputImageParameter::ImageBaseType * Application::GetParameterComplexOut } } -void Application::AddImageToParameterInputImageList(std::string parameter, InputImageListParameter::ImageBaseType * img) +void Application::AddImageToParameterInputImageList(std::string parameter, ImageBaseType * img) { Parameter* param = GetParameterByKey(parameter); @@ -1262,7 +1262,7 @@ void Application::AddImageToParameterInputImageList(std::string parameter, Input } -void Application::SetNthParameterInputImageList(std::string parameter, const unsigned int &id, InputImageListParameter::ImageBaseType * img) +void Application::SetNthParameterInputImageList(std::string parameter, const unsigned int &id, ImageBaseType * img) { Parameter* param = GetParameterByKey(parameter); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx index 64ef365718..9c3c47cd68 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx @@ -254,7 +254,7 @@ ComplexOutputImageParameter::GetWriter() return writer; } -ComplexOutputImageParameter::ImageBaseType* +ImageBaseType* ComplexOutputImageParameter::GetValue( ) { return m_Image; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 2790bdce25..78dbd4d2b2 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -564,7 +564,7 @@ OutputImageParameter::GetWriter() return writer; } -OutputImageParameter::ImageBaseType* +ImageBaseType* OutputImageParameter::GetValue( ) { return m_Image; -- GitLab From ed3172fe5f3e921903072bd389531c1602f3ee29 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 22 Feb 2018 10:28:21 +0100 Subject: [PATCH 296/567] ENH: allow to get InputImage and ComplexInputImage as ImageBaseType --- .../include/otbWrapperComplexInputImageParameter.txx | 4 ++++ .../include/otbWrapperInputImageParameter.txx | 4 ++++ .../src/otbWrapperComplexInputImageParameter.cxx | 9 +++++++++ .../src/otbWrapperInputImageParameter.cxx | 10 ++++++++++ 4 files changed, 27 insertions(+) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx index 774dfdbf78..6a23b68640 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx @@ -115,6 +115,10 @@ ComplexInputImageParameter::GetImage() } } +/** declare a specialization for ImageBaseType */ +template <> +ImageBaseType* +ComplexInputImageParameter::GetImage(); template <class TComplexInputImage, class TOutputImage> TOutputImage* diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx index 9db0e61408..28a59e27bd 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx @@ -186,6 +186,10 @@ InputImageParameter::GetImage() } } +/** declare a specialization for ImageBaseType */ +template <> +ImageBaseType* +InputImageParameter::GetImage(); template <class TInputImage, class TOutputImage> TOutputImage* diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx index 6c59ad4c83..90fcc4840c 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx @@ -65,6 +65,15 @@ ComplexInputImageParameter::GetImage() return this->GetImage<ComplexFloatVectorImageType>(); } +template <> +ImageBaseType* +ComplexInputImageParameter::GetImage() +{ + if (m_Image.IsNull()) + return this->GetImage<ComplexFloatVectorImageType>(); + + return m_Image; +} #define otbGetImageMacro(image) \ image##Type * \ diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx index 166ab2956a..7ff1a8d977 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx @@ -68,6 +68,16 @@ InputImageParameter::GetImage() return this->GetImage<FloatVectorImageType>(); } +template <> +ImageBaseType* +InputImageParameter::GetImage() +{ + if (m_Image.IsNull()) + return this->GetImage<FloatVectorImageType>(); + + return m_Image; +} + otbGetImageMacro(UInt8RGBImage); otbGetImageMacro(UInt8RGBAImage); -- GitLab From 66cf112c4bc7872324ae73701909b745d4fb625e Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 22 Feb 2018 10:29:25 +0100 Subject: [PATCH 297/567] ENH: flag to disable propagation in PipelineMemoryPrintCalculator --- .../include/otbPipelineMemoryPrintCalculator.h | 2 +- .../src/otbPipelineMemoryPrintCalculator.cxx | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h b/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h index 41fe7808e9..0574d38c56 100644 --- a/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h +++ b/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h @@ -114,7 +114,7 @@ public: itkSetObjectMacro(DataToWrite, DataObjectType); /** Compute pipeline memory print */ - void Compute(); + void Compute(bool propagate=true); /** Const conversion factor */ static const double ByteToMegabyte; diff --git a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx index d7d62e8c88..92237b2808 100644 --- a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx +++ b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx @@ -71,15 +71,18 @@ PipelineMemoryPrintCalculator void PipelineMemoryPrintCalculator -::Compute() +::Compute(bool propagate) { // Clear the visited process objects set m_VisitedProcessObjects.clear(); // Dry run of pipeline synchronisation - m_DataToWrite->UpdateOutputInformation(); - m_DataToWrite->SetRequestedRegionToLargestPossibleRegion(); - m_DataToWrite->PropagateRequestedRegion(); + if (propagate) + { + m_DataToWrite->UpdateOutputInformation(); + m_DataToWrite->SetRequestedRegionToLargestPossibleRegion(); + m_DataToWrite->PropagateRequestedRegion(); + } // Get the source process object ProcessObjectType * source = m_DataToWrite->GetSource(); -- GitLab From 18a479637db02a38249b6db3b3075d9264626f65 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 22 Feb 2018 10:30:46 +0100 Subject: [PATCH 298/567] ENH: new image-services in otb::Wrapper::Application --- .../include/otbWrapperApplication.h | 48 ++++++++ .../src/otbWrapperApplication.cxx | 114 ++++++++++++++++++ 2 files changed, 162 insertions(+) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 7fc61ce68b..ef2b24a364 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -853,6 +853,42 @@ public: this->SetDocLink(link); } + /** Get the origin of the image parameter 'key'. The optional 'idx' allows + * to select the image in an InputImageList. */ + ImageBaseType::PointType GetImageOrigin(const std::string & key, unsigned int idx = 0); + + /** Get the spacing of the image parameter 'key'. The optional 'idx' allows to + * select the image in an InputImageList. We use the signed spacing convention. */ + ImageBaseType::SpacingType GetImageSpacing(const std::string & key, unsigned int idx = 0); + + /** Get the size of the image parameter 'key'. The optional 'idx' allows to + * select the image in an InputImageList. It corresponds to the size of LargestPossibleRegion*/ + ImageBaseType::SizeType GetImageSize(const std::string & key, unsigned int idx = 0); + + /** Get the number of bands in the image parameter 'key'. The optional 'idx' + * allows to select the image in an InputImageList.*/ + unsigned int GetImageNbBands(const std::string & key, unsigned int idx = 0); + + /** Get the projection of the image parameter 'key'. The optional 'idx' allows + * to select the image in an InputImageList.*/ + std::string GetImageProjection(const std::string & key, unsigned int idx = 0); + + /** Get the keywordlist of the image parameter 'key'. The optional 'idx' + * allows to select the image in an InputImageList.*/ + std::map<std::string,std::string> GetImageKeywordlist(const std::string & key, unsigned int idx = 0); + + /** Set the requested region on the image parameter 'key' and propagate it. + * The returned value is an estimate of the RAM usage (in Bytes) to process + * this region. It should be assumed that the index of the largest possible + * region starts at (0,0). The optional 'idx' allows to select the image in + * an InputImageList*/ + unsigned long PropagateRequestedRegion(const std::string & key, ImageBaseType::RegionType region, unsigned int idx = 0); + + /** Get the requested region of the image parameter 'key'. The optional 'idx' + * allows to select the image in an InputImageList. It should be assumed that + * the index of the largest possible region starts at (0,0).*/ + ImageBaseType::RegionType GetImageRequestedRegion(const std::string & key, unsigned int idx = 0); + protected: /** Constructor */ Application(); @@ -972,6 +1008,18 @@ protected: } } + /** Return the image from parameter 'key' as a base type. The optional 'idx' + * allows to access InputImageList. + * + * Works on parameters: + * \li ParameterType_InputImage + * \li ParameterType_InputImageList + * \li ParameterType_OutputImage + * \li ParameterType_ComplexInputImage + * \li ParameterType_ComplexOutputImage + */ + ImageBaseType* GetParameterImageBase(const std::string & key, unsigned int idx = 0); + private: /* Implement this method to add parameters */ virtual void DoInit() = 0; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 3a69b616f2..623a026e11 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1703,5 +1703,119 @@ double Application::GetLastExecutionTiming() const return m_Chrono.GetElapsedMilliseconds() / 1000.0; } +ImageBaseType::PointType +Application::GetImageOrigin(const std::string & key, unsigned int idx) +{ + return this->GetParameterImageBase(key, idx)->GetOrigin(); +} + +ImageBaseType::SpacingType +Application::GetImageSpacing(const std::string & key, unsigned int idx) +{ + return otb::internal::GetSignedSpacing(this->GetParameterImageBase(key, idx)); +} + +ImageBaseType::SizeType +Application::GetImageSize(const std::string & key, unsigned int idx) +{ + return this->GetParameterImageBase(key, idx)->GetLargestPossibleRegion().GetSize(); +} + +unsigned int +Application::GetImageNbBands(const std::string & key, unsigned int idx) +{ + return this->GetParameterImageBase(key, idx)->GetNumberOfComponentsPerPixel(); +} + +std::string +Application::GetImageProjection(const std::string & key, unsigned int idx) +{ + std::string proj; + const itk::MetaDataDictionary& dict = + this->GetParameterImageBase(key, idx)->GetMetaDataDictionary(); + + if (!dict.HasKey(MetaDataKey::ProjectionRefKey)) + return std::string(""); + + itk::ExposeMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey, proj); + return proj; +} + +std::map<std::string,std::string> +Application::GetImageKeywordlist(const std::string & key, unsigned int idx) +{ + ImageKeywordlist kwl; + const itk::MetaDataDictionary& dict = + this->GetParameterImageBase(key, idx)->GetMetaDataDictionary(); + + if (!dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) + return std::map<std::string,std::string>(); + + itk::ExposeMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey, kwl); + return kwl.GetKeywordlist(); +} + +unsigned long +Application::PropagateRequestedRegion(const std::string & key, ImageBaseType::RegionType region, unsigned int idx) +{ + ImageBaseType* image = this->GetParameterImageBase(key, idx); + ImageBaseType::RegionType largest = image->GetLargestPossibleRegion(); + ImageBaseType::RegionType requested = region; + requested.SetIndex(0, requested.GetIndex(0) + largest.GetIndex(0)); + requested.SetIndex(1, requested.GetIndex(1) + largest.GetIndex(1)); + image->SetRequestedRegion(requested); + image->PropagateRequestedRegion(); + // estimate RAM usage + otb::PipelineMemoryPrintCalculator::Pointer memoryPrintCalculator = + otb::PipelineMemoryPrintCalculator::New(); + memoryPrintCalculator->SetDataToWrite(image); + memoryPrintCalculator->SetBiasCorrectionFactor(1); + memoryPrintCalculator->Compute(false); + return memoryPrintCalculator->GetMemoryPrint(); +} + +ImageBaseType::RegionType +Application::GetImageRequestedRegion(const std::string & key, unsigned int idx) +{ + ImageBaseType* image = this->GetParameterImageBase(key, idx); + ImageBaseType::RegionType largest = image->GetLargestPossibleRegion(); + ImageBaseType::RegionType requested = image->GetRequestedRegion(); + requested.SetIndex(0, requested.GetIndex(0) - largest.GetIndex(0)); + requested.SetIndex(1, requested.GetIndex(1) - largest.GetIndex(1)); + return requested; +} + +ImageBaseType* +Application::GetParameterImageBase(const std::string & key, unsigned int idx) +{ + Parameter* param = GetParameterByKey(key); + if (dynamic_cast<InputImageParameter*>(param)) + { + InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param); + return paramDown->GetImage<ImageBaseType>(); + } + else if (dynamic_cast<InputImageListParameter*>(param)) + { + InputImageListParameter* paramDown = dynamic_cast<InputImageListParameter*>(param); + return paramDown->GetNthImage(idx); + } + else if (dynamic_cast<ComplexInputImageParameter*>(param)) + { + ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*>(param); + return paramDown->GetImage<ImageBaseType>(); + } + else if (dynamic_cast<OutputImageParameter*>(param)) + { + OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(param); + return paramDown->GetValue(); + } + else if (dynamic_cast<ComplexOutputImageParameter*>(param)) + { + ComplexOutputImageParameter* paramDown = dynamic_cast<ComplexOutputImageParameter*>(param); + return paramDown->GetValue(); + } + return nullptr; +} + } } -- GitLab From 9e8eb6f38dd0446b516c85d200ebf5f4c20d2ba6 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 22 Feb 2018 11:16:17 +0100 Subject: [PATCH 299/567] TEST: new test for image-services in Application --- .../ApplicationEngine/test/CMakeLists.txt | 11 +++ .../test/otbApplicationEngineTestDriver.cxx | 1 + .../test/otbWrapperImageInterface.cxx | 91 +++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx diff --git a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt index 860c867363..3f3fcd7913 100644 --- a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt @@ -41,6 +41,7 @@ otbWrapperApplicationHtmlDocGeneratorTest.cxx otbWrapperInputVectorDataParameterTest.cxx otbWrapperOutputImageParameterTest.cxx otbApplicationMemoryConnectTest.cxx +otbWrapperImageInterface.cxx ) add_executable(otbApplicationEngineTestDriver ${OTBApplicationEngineTests}) @@ -191,3 +192,13 @@ otb_add_test(NAME owTvApplicationMemoryConnectTest COMMAND otbApplicationEngineT otb_add_test(NAME owTvParameterGroup COMMAND otbApplicationEngineTestDriver otbWrapperParameterList ) + +otb_add_test(NAME owTvImageInterface COMMAND otbApplicationEngineTestDriver + --compare-ascii ${NOTOL} + ${BASELINE_FILES}/owTvImageInterfaceOut.txt + ${TEMP}/owTvImageInterfaceOut.txt + otbWrapperImageInterface + $<TARGET_FILE_DIR:otbapp_Smoothing> + ${INPUTDATA}/Capitole_Rasterization.tif + ${TEMP}/owTvImageInterfaceOut.txt + ) diff --git a/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx b/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx index f5b3aabf3d..1d43d8d38a 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx +++ b/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx @@ -52,4 +52,5 @@ void RegisterTests() REGISTER_TEST(otbWrapperOutputImageParameterNew); REGISTER_TEST(otbWrapperOutputImageParameterTest1); REGISTER_TEST(otbApplicationMemoryConnectTest); + REGISTER_TEST(otbWrapperImageInterface); } diff --git a/Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx b/Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx new file mode 100644 index 0000000000..4f06dc1906 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbWrapperApplicationRegistry.h" + + +int otbWrapperImageInterface(int argc, char * argv[]) +{ + if(argc<4) + { + std::cerr<<"Usage: "<<argv[0]<<" application_path input_image output_txt"<<std::endl; + return EXIT_FAILURE; + } + + std::string path = argv[1]; + std::string input = argv[2]; + std::string output = argv[3]; + + otb::Wrapper::ApplicationRegistry::SetApplicationPath(path); + + otb::Wrapper::Application::Pointer app1 = otb::Wrapper::ApplicationRegistry::CreateApplication("Smoothing"); + + if(app1.IsNull()) + { + std::cerr<<"Failed to create application"<<std::endl; + return EXIT_FAILURE; + } + + std::ofstream ofs( output ); + if (!ofs.is_open()) + { + fprintf(stderr, "Error, can't open file"); + return EXIT_FAILURE; + } + + app1->SetParameterString("in",input); + app1->Execute(); + + ofs << "Size: "<< app1->GetImageSize("out") << std::endl; + ofs << "Origin: "<< app1->GetImageOrigin("out") << std::endl; + ofs << "Spacing: "<< app1->GetImageSpacing("out") << std::endl; + ofs << "Keywordlist: "<< std::endl; + for (auto item : app1->GetImageKeywordlist("out")) + { + ofs <<" ["<<item.first<<"] = "<<item.second << std::endl; + } + ofs << "ProjectionRef: "<< std::endl; + ofs << app1->GetImageProjection("out") << std::endl; + + otb::Wrapper::ImageBaseType::RegionType region; + region.SetIndex(0,10); + region.SetIndex(1,10); + region.SetSize(0,7); + region.SetSize(1,7); + + ofs << "RAM usage (in Bytes): "<< app1->PropagateRequestedRegion("out",region) << std::endl; + ofs << "Input requested: "<< app1->GetImageRequestedRegion("in") << std::endl; + + otb::Wrapper::Application::Pointer app2 = + otb::Wrapper::ApplicationRegistry::CreateApplication("ConcatenateImages"); + app2->AddParameterStringList("il",input); + app2->AddParameterStringList("il",input); + app2->Execute(); + + ofs << "Number of bands [il]: "<< app2->GetImageNbBands("il",0) << "+" + << app2->GetImageNbBands("il",1) << std::endl; + ofs << "Number of bands [out]: "<< app2->GetImageNbBands("out")<< std::endl; + ofs.close(); + return EXIT_SUCCESS; +} -- GitLab From e2b0fdb9c1cc6ad4ea6f34448beac325b01befb9 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 22 Feb 2018 11:30:04 +0100 Subject: [PATCH 300/567] COMP: Wipe out all traces of OTB_SHOW_ALL_MSG_DEBUG --- CMakeLists.txt | 4 ---- Modules/Core/Common/src/otbConfigure.h.in | 3 --- .../Supervised/include/otbLibSVMMachineLearningModel.txx | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5e1130921..dc4875285f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,10 +231,6 @@ mark_as_advanced(OTB_USE_DEPRECATED) option(OTB_USE_OPENMP "Add openmp compiler and linker flags" OFF) option(OTB_USE_SSE_FLAGS "Enable SIMD optimizations (hardware dependent)." ON) -#----------------------------------------------------------------------------- -# SHOW_ALL_MSG_DEBUG option -option(OTB_SHOW_ALL_MSG_DEBUG "Show all debug messages (very verbose)" OFF) -#mark_as_advanced(OTB_SHOW_ALL_MSG_DEBUG) include(OTBSetStandardCompilerFlags) #--------------------------------------------------------------- diff --git a/Modules/Core/Common/src/otbConfigure.h.in b/Modules/Core/Common/src/otbConfigure.h.in index 5194398344..2146cf15bf 100644 --- a/Modules/Core/Common/src/otbConfigure.h.in +++ b/Modules/Core/Common/src/otbConfigure.h.in @@ -27,9 +27,6 @@ #cmakedefine OTB_BUILD_SHARED_LIBS -/* Show developer debug messages */ -#cmakedefine OTB_SHOW_ALL_MSG_DEBUG - #cmakedefine OTB_USE_GDAL_20 #cmakedefine OTB_USE_OPENMP diff --git a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.txx b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.txx index 2b14f6dca9..1d1c03e39a 100644 --- a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.txx +++ b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.txx @@ -66,7 +66,7 @@ LibSVMMachineLearningModel<TInputValue,TOutputValue> this->m_Problem.l = 0; this->m_Problem.y = ITK_NULLPTR; this->m_Problem.x = ITK_NULLPTR; -#ifndef OTB_SHOW_ALL_MSG_DEBUG +#ifndef NDEBUG svm_set_print_string_function(&otb::Utils::PrintNothing); #endif } -- GitLab From 066890ff42d202f655b40a2b93fc25b5a68a63d3 Mon Sep 17 00:00:00 2001 From: Yannick TANGUY <yannick.tanguy@cnes.fr> Date: Thu, 22 Feb 2018 10:33:08 +0000 Subject: [PATCH 301/567] Misprint in documentation --- .../Applications/AppFiltering/app/otbContrastEnhancement.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx index 3c55bf6efa..ec8f866960 100644 --- a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx +++ b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx @@ -11,7 +11,7 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreened to in writing, software + * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and @@ -258,7 +258,7 @@ private: SetDefaultParameterFloat("mode.lum.red.coef", 0.21 ); AddParameter(ParameterType_Group , "mode.lum.green" , "Green Channel" ); - AddParameter(ParameterType_Int , "mode.lum.green.ch" , "Greenen Channel" ); + AddParameter(ParameterType_Int , "mode.lum.green.ch" , "Green Channel" ); SetDefaultParameterInt("mode.lum.green.ch", 1 ); AddParameter(ParameterType_Float , "mode.lum.green.coef" , "Value for luminance computation" ); -- GitLab From 6775c1aed3df5c7ac401eb9c9163bc2e7e551167 Mon Sep 17 00:00:00 2001 From: Yannick TANGUY <tanguyy@visu01.sis.cnes.fr> Date: Wed, 21 Feb 2018 16:17:27 +0000 Subject: [PATCH 302/567] Improve documentation (luminance mode) --- .../app/otbContrastEnhancement.cxx | 59 +++++++------------ 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx index ec8f866960..4e27af85d4 100644 --- a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx +++ b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx @@ -154,7 +154,7 @@ private: "or to reduce the dynamic of the image without losing too much contrast. " "It offers several options as a no data value, " "a contrast limitation factor, a local version of the algorithm and " - "also a mode to equalized the luminance of the image."); + "also a mode to equalize the luminance of the image."); // Documentation SetDocName("Contrast Enhancement"); @@ -164,13 +164,14 @@ private: "over the image and then use the whole dynamic : meaning flattening the " "histogram. That gives us gain for each bin that transform the original " "histogram into the flat one. This gain is then apply on the original " - "image. Upon this coarse algorithm we added several option to allow " - "a finer result. First there is the limitation of the contrast. Many " - "ways can be used to do it, we choose to limit the contrast by modifying " - "the original histogram. To do so we clip the histogram at a given " - "height and redistribute equally among the bins the clipped population. " - "Then we add a local version of the algorithm. It is possible to apply " - "the algorithm on tiles of the image. That gives us gain depending on " + "image." + "\nThe application proposes several option to allow a finer result : " + "\n- There is an option to limit contrast. We choose to limit the contrast " + "by modifying the original histogram. To do so we clip the histogram at a " + "given height and redistribute equally among the bins the clipped population. " + "Then we add a local version of the algorithm. " + "\n- It is possible to apply the algorithm on tiles of the image, instead " + "of on the whole image. That gives us gain depending on " "the value of the pixel and its position in the image. In order to " "smoothen the result we interpolate the gain between tiles."); SetDocLimitations("None"); @@ -195,7 +196,8 @@ private: "height accepted in a bin on the input image histogram. " "The maximum height will be computed as hfact*eqHeight where eqHeight " "is the height of the theoretical flat histogram. The higher hfact, the " - "higher the contrast."); + "higher the contrast." + "\nWhen using 'luminance mode', it is recommended to limit this factor to a small value (ex : 4)"); MandatoryOff("hfact"); AddParameter(ParameterType_Float , "nodata" , "Nodata Value"); @@ -208,7 +210,7 @@ private: "for the histogram computation"); AddChoice( "spatial.local" , "Local" ); SetParameterDescription("spatial.local" , "The histograms will be " - "computed on the each thumbnail. Each of the histogram will be " + "computed on each thumbnail. Each of the histogram will be " "equalized and the corresponding gain will be interpolated."); AddChoice( "spatial.global" , "Global" ); SetParameterDescription("spatial.global" , "The histogram will be " @@ -247,9 +249,14 @@ private: "Each channel is equalized independently" ); AddChoice( "mode.lum" , "Luminance" ); SetParameterDescription( "mode.lum" , - "The luminance is equalized and then a gain is applied " - "on each channels. This gain for each channels will depend on" - "the weight (coef) of the channel in the luminance." ); + "The relative luminance is calculated thanks to the coefficients." + "Then the histogram is equalized and then a gain is applied on each channels." + "This gain for each channels will depend on" + "the weight (coef) of the channel in the luminance." + "\nNote that default values come from color space theories " + "on how human eyes perceive colors)" + +); AddParameter(ParameterType_Group , "mode.lum.red" , "Red Channel" ); AddParameter(ParameterType_Int , "mode.lum.red.ch" , "Red Channel" ); SetDefaultParameterInt("mode.lum.red.ch", 0 ); @@ -300,12 +307,6 @@ private: FloatVectorImageType::RegionType::SizeType size; size = inImage->GetLargestPossibleRegion().GetSize() ; - // if ( !HasUserValue("spatial.local.w") ) - // SetParameterInt( "spatial.local.w" , size[0] ); - - // if ( !HasUserValue("spatial.local.h") ) - // SetParameterInt( "spatial.local.h" , size[1] ); - if ( GetParameterString("spatial") == "local" && HasValue("spatial.local.h") && HasValue("spatial.local.w") && HasValue("bins") ) @@ -320,26 +321,6 @@ private: !HasUserValue("mode.lum.green.ch") && !HasUserValue("mode.lum.blue.ch") ) SetDefaultValue( inImage , "RGB" ); - - // if ( HasUserValue("minmax.manuel.min") && - // HasUserValue("minmax.manuel.max") ) - // { - // if ( GetParameterFloat( "minmax.manuel.min" ) > - // GetParameterFloat( "minmax.manuel.max" ) ) - // { - // float temp = GetParameterFloat( "minmax.manuel.min" ); - // SetParameterFloat( "minmax.manuel.min" , - // GetParameterFloat( "minmax.manuel.max" )); - // SetParameterFloat( "minmax.manuel.max" , temp ); - // } - // else if ( GetParameterFloat( "minmax.manuel.min" ) == - // GetParameterFloat( "minmax.manuel.max" ) ) - // { - // std::ostringstream oss; - // oss<<"Warning minimum and maximum are equal."<<std::endl; - // otbAppLogINFO( << oss.str() ); - // } - // } } if ( GetParameterString("minmax") == "manuel" ) -- GitLab From 6c4e3e3892503a9d42a5d97a6f97f98bdbf63129 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 22 Feb 2018 13:48:54 +0100 Subject: [PATCH 303/567] BUG: Split otbWrapperInputImageParameter.cxx file into several one to limit memory usage during compilation --- .../ApplicationEngine/src/CMakeLists.txt | 11 +++++++ .../src/otbWrapperInputImageParameter.cxx | 12 ------- .../otbWrapperInputImageParameterCDouble.cxx | 33 +++++++++++++++++++ .../otbWrapperInputImageParameterCFloat.cxx | 33 +++++++++++++++++++ .../otbWrapperInputImageParameterCInt16.cxx | 33 +++++++++++++++++++ .../otbWrapperInputImageParameterCInt32.cxx | 33 +++++++++++++++++++ .../otbWrapperInputImageParameterDouble.cxx | 33 +++++++++++++++++++ .../otbWrapperInputImageParameterFloat.cxx | 33 +++++++++++++++++++ .../otbWrapperInputImageParameterInt16.cxx | 33 +++++++++++++++++++ .../otbWrapperInputImageParameterInt32.cxx | 33 +++++++++++++++++++ .../otbWrapperInputImageParameterUInt16.cxx | 33 +++++++++++++++++++ .../otbWrapperInputImageParameterUInt32.cxx | 33 +++++++++++++++++++ .../otbWrapperInputImageParameterUInt8.cxx | 33 +++++++++++++++++++ 13 files changed, 374 insertions(+), 12 deletions(-) create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt16.cxx create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt32.cxx create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 45d0427a49..db3f434b5f 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -31,6 +31,17 @@ set( OTBApplicationEngine_SRC otbWrapperInputFilenameListParameter.cxx otbWrapperOutputImageParameter.cxx otbWrapperInputImageParameter.cxx + otbWrapperInputImageParameterUInt8.cxx + otbWrapperInputImageParameterUInt16.cxx + otbWrapperInputImageParameterUInt32.cxx + otbWrapperInputImageParameterInt16.cxx + otbWrapperInputImageParameterInt32.cxx + otbWrapperInputImageParameterCInt16.cxx + otbWrapperInputImageParameterCInt32.cxx + otbWrapperInputImageParameterCFloat.cxx + otbWrapperInputImageParameterCDouble.cxx + otbWrapperInputImageParameterFloat.cxx + otbWrapperInputImageParameterDouble.cxx otbWrapperParameterKey.cxx otbWrapperDocExampleStructure.cxx otbWrapperInputVectorDataParameter.cxx diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx index fe226ef2ff..96b315b050 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx @@ -70,18 +70,6 @@ InputImageParameter::GetImage() otbGetImageMacro(UInt8RGBImage); otbGetImageMacro(UInt8RGBAImage); -otbGetImageAndVectorImageMacro(UInt8); -otbGetImageAndVectorImageMacro(UInt16); -otbGetImageAndVectorImageMacro(UInt32); -otbGetImageAndVectorImageMacro(Int16); -otbGetImageAndVectorImageMacro(Int32); -otbGetImageAndVectorImageMacro(Float); -otbGetImageAndVectorImageMacro(Double); -otbGetImageAndVectorImageMacro(ComplexInt16); -otbGetImageAndVectorImageMacro(ComplexInt32); -otbGetImageAndVectorImageMacro(ComplexFloat); -otbGetImageAndVectorImageMacro(ComplexDouble); - void InputImageParameter::SetImage(FloatVectorImageType* image) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx new file mode 100644 index 0000000000..0ab35a7de9 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageAndVectorImageMacro(ComplexDouble); +} +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx new file mode 100644 index 0000000000..454b8abb56 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageAndVectorImageMacro(ComplexFloat); +} +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt16.cxx new file mode 100644 index 0000000000..c6de185a12 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt16.cxx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageAndVectorImageMacro(ComplexInt16); +} +} \ No newline at end of file diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt32.cxx new file mode 100644 index 0000000000..d6cbab06f1 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt32.cxx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageAndVectorImageMacro(ComplexInt32); +} +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx new file mode 100644 index 0000000000..b3b6ec7d51 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageAndVectorImageMacro(Double); +} +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx new file mode 100644 index 0000000000..77dab91387 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageAndVectorImageMacro(Float); +} +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx new file mode 100644 index 0000000000..4b645f1560 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageAndVectorImageMacro(Int16); +} +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx new file mode 100644 index 0000000000..66b6e3fa89 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageAndVectorImageMacro(Int32); +} +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx new file mode 100644 index 0000000000..89dcd5b648 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageAndVectorImageMacro(UInt16); +} +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx new file mode 100644 index 0000000000..2df611b114 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageAndVectorImageMacro(UInt32); +} +} diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx new file mode 100644 index 0000000000..9f1c38e815 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperInputImageParameter.h" +#include "otbWrapperInputImageParameterMacros.h" +#include "itksys/SystemTools.hxx" +#include "otbWrapperTypes.h" +#include "otb_boost_string_header.h" + +namespace otb +{ +namespace Wrapper +{ +otbGetImageAndVectorImageMacro(UInt8); +} +} -- GitLab From 67d18c2cf385d8f2d35049dca6e1d52b128ebfd8 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 22 Feb 2018 15:18:15 +0100 Subject: [PATCH 304/567] REFAC: Review most verbose log messages to make them more compact and informative --- .../OSSIMAdapters/src/otbImageKeywordlist.cxx | 3 - .../ImageBase/include/otbExtractROIBase.txx | 5 - ...otbRAMDrivenAdaptativeStreamingManager.txx | 2 +- .../Streaming/include/otbStreamingManager.txx | 15 +- .../src/otbPipelineMemoryPrintCalculator.cxx | 7 +- Modules/IO/IOGDAL/src/otbGDALImageIO.cxx | 342 ++---------------- .../IO/ImageIO/include/otbImageFileReader.txx | 15 +- .../IO/ImageIO/include/otbImageFileWriter.txx | 55 +-- .../include/otbWrapperInputImageParameter.txx | 2 - 9 files changed, 58 insertions(+), 388 deletions(-) diff --git a/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx b/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx index 6063915cfb..22aef9289e 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx @@ -241,8 +241,6 @@ ReadGeometryFromImage(const std::string& filename, bool checkRpcTag) if (projection) { - otbMsgDevMacro(<< "OSSIM plugin projection instantiated ! "); - hasMetaData = projection->saveState(geom_kwl); otb_kwl.SetKeywordlist(geom_kwl); } @@ -479,7 +477,6 @@ WriteGeometry(const ImageKeywordlist& otb_kwl, const std::string& filename) if (geom_kwl.getSize() > 0) { - otbMsgDevMacro(<< "Exporting keywordlist ..."); ossimFilename geomFileName(filename); geomFileName.setExtension(".geom"); geom_kwl.write(geomFileName.chars()); diff --git a/Modules/Core/ImageBase/include/otbExtractROIBase.txx b/Modules/Core/ImageBase/include/otbExtractROIBase.txx index 78f546387f..26108adf67 100644 --- a/Modules/Core/ImageBase/include/otbExtractROIBase.txx +++ b/Modules/Core/ImageBase/include/otbExtractROIBase.txx @@ -152,11 +152,6 @@ ExtractROIBase<TInputImage, TOutputImage> } requestedRegion.SetIndex(index); inputPtr->SetRequestedRegion(requestedRegion); - - otbMsgDevMacro(<< "InputRequestedRegion (otbExtractROIBase): "); - otbMsgDevMacro(<< " - index: " << requestedRegion.GetIndex()); - otbMsgDevMacro(<< " - size: " << requestedRegion.GetSize()); - } /** diff --git a/Modules/Core/Streaming/include/otbRAMDrivenAdaptativeStreamingManager.txx b/Modules/Core/Streaming/include/otbRAMDrivenAdaptativeStreamingManager.txx index 07dcdbd82d..743d5de281 100644 --- a/Modules/Core/Streaming/include/otbRAMDrivenAdaptativeStreamingManager.txx +++ b/Modules/Core/Streaming/include/otbRAMDrivenAdaptativeStreamingManager.txx @@ -72,7 +72,7 @@ RAMDrivenAdaptativeStreamingManager<TImage>::PrepareStreaming( itk::DataObject * this->m_Splitter = splitter; this->m_ComputedNumberOfSplits = this->m_Splitter->GetNumberOfSplits(region, nbDivisions); - otbMsgDevMacro(<< "Number of split : " << this->m_ComputedNumberOfSplits) + this->m_Region = region; } diff --git a/Modules/Core/Streaming/include/otbStreamingManager.txx b/Modules/Core/Streaming/include/otbStreamingManager.txx index b0fdfced06..22aed33102 100644 --- a/Modules/Core/Streaming/include/otbStreamingManager.txx +++ b/Modules/Core/Streaming/include/otbStreamingManager.txx @@ -47,12 +47,9 @@ StreamingManager<TImage>::GetActualAvailableRAMInBytes(MemoryPrintType available if (availableRAMInBytes == 0) { - otbMsgDevMacro(<< "Retrieving available RAM size from configuration"); // Retrieve it from the configuration availableRAMInBytes = 1024*1024*ConfigurationManager::GetMaxRAMHint(); } - - otbMsgDevMacro("RAM used to estimate memory footprint : " << availableRAMInBytes / 1024 / 1024 << " MB") return availableRAMInBytes; } @@ -62,8 +59,6 @@ StreamingManager<TImage>::EstimateOptimalNumberOfDivisions(itk::DataObject * inp MemoryPrintType availableRAM, double bias) { - otbMsgDevMacro(<< "availableRAM " << availableRAM) - MemoryPrintType availableRAMInBytes = GetActualAvailableRAMInBytes(availableRAM); otb::PipelineMemoryPrintCalculator::Pointer memoryPrintCalculator; @@ -103,7 +98,6 @@ StreamingManager<TImage>::EstimateOptimalNumberOfDivisions(itk::DataObject * inp if (smallRegionSuccess) { - otbMsgDevMacro("Using an extract to estimate memory : " << smallRegion) // the region is well behaved, inside the largest possible region memoryPrintCalculator->SetDataToWrite(extractFilter->GetOutput() ); @@ -114,7 +108,6 @@ StreamingManager<TImage>::EstimateOptimalNumberOfDivisions(itk::DataObject * inp } else { - otbMsgDevMacro("Using the input region to estimate memory : " << region) // the region is not well behaved // use the full region memoryPrintCalculator->SetDataToWrite(input); @@ -148,11 +141,9 @@ StreamingManager<TImage>::EstimateOptimalNumberOfDivisions(itk::DataObject * inp unsigned int optimalNumberOfDivisions = otb::PipelineMemoryPrintCalculator::EstimateOptimalNumberOfStreamDivisions(pipelineMemoryPrint, availableRAMInBytes); - otbMsgDevMacro( "Estimated Memory print for the full image : " - << static_cast<unsigned int>(pipelineMemoryPrint * otb::PipelineMemoryPrintCalculator::ByteToMegabyte ) << std::endl) - otbMsgDevMacro( "Optimal number of stream divisions: " - << optimalNumberOfDivisions << std::endl) - + otbLogMacro(Info,<<"Available memory: "<<availableRAMInBytes * otb::PipelineMemoryPrintCalculator::ByteToMegabyte + <<" Mb, estimated needed memory for full processing: "<<pipelineMemoryPrint * otb::PipelineMemoryPrintCalculator::ByteToMegabyte + <<" Mb, optimal number of stream divisions: "<<optimalNumberOfDivisions); return optimalNumberOfDivisions; } diff --git a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx index d7d62e8c88..403c9d3867 100644 --- a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx +++ b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx @@ -105,7 +105,7 @@ PipelineMemoryPrintCalculator::MemoryPrintType PipelineMemoryPrintCalculator ::EvaluateProcessObjectPrintRecursive(ProcessObjectType * process) { - otbMsgDevMacro(<< "EvaluateMemoryPrint for " << process->GetNameOfClass() << " (" << process << ")") + otbLogMacro(Debug,<<"Recursive evaluation of memory print for ProcessObject" << process->GetNameOfClass() << " (" << process << ")"); // This variable will store the final print MemoryPrintType print = 0; @@ -164,8 +164,9 @@ PipelineMemoryPrintCalculator::MemoryPrintType PipelineMemoryPrintCalculator ::EvaluateDataObjectPrint(DataObjectType * data) { - otbMsgDevMacro(<< "EvaluateMemoryPrint for " << data->GetNameOfClass() << " (" << data << ")") - + + otbLogMacro(Debug,<<"Evaluation of memory print for DataObject " << data->GetNameOfClass() << " (" << data << ")"); + #define OTB_IMAGE_SIZE_BLOCK(type) \ if(dynamic_cast<itk::Image<type, 2> *>(data) != NULL) \ { \ diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx index f4cfe1ecfd..944bbf51f9 100644 --- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx @@ -74,57 +74,6 @@ public: }; // end of GDALDataTypeWrapper -/* -template<class InputType> -void printOutputData(InputType *pData, int nbBands, int nbPixelToRead) -{ - for (unsigned int itPxl = 0; itPxl < (unsigned int) (nbPixelToRead * nbBands); itPxl++) - { - std::cout << "Buffer["<< itPxl << "] = " << *(pData + itPxl) << std::endl; - } -}; - -void printDataBuffer(unsigned char *pData, GDALDataType pxlType, int nbBands, int nbPixelToRead) -{ - if (pxlType == GDT_Int16) - { - printOutputData( static_cast<short*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_Int32) - { - printOutputData( static_cast<int*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_Float32) - { - printOutputData( static_cast<float*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_Float64) - { - printOutputData( static_cast<double*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_CInt16) - { - printOutputData( static_cast<std::complex<short>*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_CInt32) - { - printOutputData( static_cast<std::complex<int>*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_CFloat32) - { - printOutputData( static_cast<std::complex<float>*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_CFloat64) - { - printOutputData( static_cast<std::complex<double>*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else - { - std::cerr << "Pixel type unknown" << std::endl; - } -}; -*/ - GDALImageIO::GDALImageIO() { // By default set number of dimensions to two. @@ -147,9 +96,6 @@ GDALImageIO::GDALImageIO() m_IsIndexed = false; m_DatasetNumber = 0; - //m_poBands = NULL; - //m_hDriver = NULL; - //m_poDataset = NULL; m_NbBands = 0; m_FlagWriteImageInformation = true; @@ -177,7 +123,6 @@ bool GDALImageIO::CanReadFile(const char* file) // First check the extension if (file == ITK_NULLPTR) { - itkDebugMacro(<< "No filename specified."); return false; } m_Dataset = GDALDriverManagerWrapper::GetInstance().Open(file); @@ -207,7 +152,7 @@ void GDALImageIO::Read(void* buffer) // Check if conversion succeed if (p == ITK_NULLPTR) { - itkExceptionMacro(<< "GDAL : Bad alloc"); + itkExceptionMacro(<< "Buffer passed to GDALImageIO for reading is NULL."); return; } @@ -219,15 +164,10 @@ void GDALImageIO::Read(void* buffer) int lNbLinesRegion = this->GetIORegion().GetSize()[1]; int lNbColumnsRegion = this->GetIORegion().GetSize()[0]; - //std::cout << "OriginBuffer= " << lFirstLineRegion << " x " << lFirstColumnRegion << std::endl; - //std::cout << "SizeBuffer= " << lNbLinesRegion << " x " << lNbColumnsRegion << std::endl; - // Compute the origin of the image region to read at the initial resolution int lFirstLine = lFirstLineRegion * (1 << m_ResolutionFactor); int lFirstColumn = lFirstColumnRegion * (1 << m_ResolutionFactor); - //std::cout << "OriginImage= " << lFirstLine << " x " << lFirstColumn << std::endl; - // Compute the size of the image region to read at the initial resolution int lNbLines = lNbLinesRegion * (1 << m_ResolutionFactor); int lNbColumns = lNbColumnsRegion * (1 << m_ResolutionFactor); @@ -238,103 +178,11 @@ void GDALImageIO::Read(void* buffer) if (lFirstColumn + lNbColumns > static_cast<int>(m_OriginalDimensions[0])) lNbColumns = static_cast<int>(m_OriginalDimensions[0]-lFirstColumn); - //std::cout << "SizeImage= " << lNbLines << " x " << lNbColumns << std::endl; - - GDALDataset* dataset = m_Dataset->GetDataSet(); - // This special case is due to the fact the CINT/CLONG types - // do not exists in ITK. In this case we only report the first band - // TODO This should be fixed - /*if (GDALDataTypeIsComplex(m_PxType->pixType) - && (m_PxType->pixType != GDT_CFloat32) - && (m_PxType->pixType != GDT_CFloat64)) - { - int pixelOffset = m_BytePerPixel * m_NbBands; - int lineOffset = m_BytePerPixel * m_NbBands * lNbColumns; - int bandOffset = m_BytePerPixel; - int nbBands = m_NbBands; - - int nbPixelToRead = lNbColumns * lNbLines; - std::streamoff nbBytes = static_cast<std::streamoff>(m_NbBands) * static_cast<std::streamoff>(nbPixelToRead) * static_cast<std::streamoff>(m_BytePerPixel); - unsigned char *pBufferTemp = new unsigned char[static_cast<unsigned int>(nbBytes)]; - - // keep it for the moment - otbMsgDevMacro(<< "Parameters RasterIO (case CInt and CShort):" - << "\n indX = " << lFirstColumn - << "\n indY = " << lFirstLine - << "\n sizeX = " << lNbColumns - << "\n sizeY = " << lNbLines - << "\n GDAL Data Type = " << GDALGetDataTypeName(m_PxType->pixType) - << "\n pixelOffset = " << pixelOffset - << "\n lineOffset = " << lineOffset - << "\n bandOffset = " << bandOffset); - - CPLErr lCrGdal = m_Dataset->GetDataSet()->RasterIO(GF_Read, - lFirstColumn, - lFirstLine, - lNbColumns, - lNbLines, - pBufferTemp, //p, // pData - lNbColumns, - lNbLines, - m_PxType->pixType, - nbBands, - // We want to read all bands - NULL, - pixelOffset, - lineOffset, - bandOffset); - // Check for gdal error - if (lCrGdal == CE_Failure) - { - itkExceptionMacro(<< "Error while reading image (GDAL format) " << m_FileName ); - delete[] pBufferTemp; - return; - } - //std::cout << "RAW BUFFER:" <<std::endl; - //printDataBuffer(pBufferTemp, m_PxType->pixType, m_NbBands, lNbColumns*lNbLines); - - // Convert the buffer to GDT_Float64 type - typedef std::complex<float> RealType; - typedef double ScalarRealType; - - if (m_PxType->pixType == GDT_CInt32) - { - //std::cout << "Convert input File from GDT_CInt32 to GDT_CFloat32" << std::endl; - typedef std::complex<int> ComplexIntType; - - for (unsigned int itPxl = 0; itPxl < (unsigned int) (nbPixelToRead * m_NbBands); itPxl++) - { - ComplexIntType pxlValue = *(static_cast<ComplexIntType*>( static_cast<void*>(pBufferTemp)) + itPxl ); - - RealType pxlValueReal( static_cast<ScalarRealType>(pxlValue.real()), static_cast<ScalarRealType>(pxlValue.imag()) ); - - memcpy((void*) (&(p[itPxl*sizeof(RealType)])), (const void*) (&(pxlValueReal)), (size_t) (sizeof(RealType))); - } - } - else if (m_PxType->pixType == GDT_CInt16) - { - //std::cout << "Convert input File from GDT_CInt16 to GDT_CFloat32" << std::endl; - typedef std::complex<short> ComplexShortType; - - for (unsigned int itPxl = 0; itPxl < (unsigned int) (nbPixelToRead * m_NbBands); itPxl++) - { - ComplexShortType pxlValue = *(static_cast<ComplexShortType*>( static_cast<void*>(pBufferTemp)) + itPxl ); - - RealType pxlValueReal( static_cast<ScalarRealType>(pxlValue.real()), static_cast<ScalarRealType>(pxlValue.imag()) ); - - memcpy((void*) (&(p[itPxl*sizeof(RealType)])), (const void*) (&(pxlValueReal)), (size_t) (sizeof(RealType))); - } - } - //std::cout << "CONVERTED BUFFER:" <<std::endl; - //printDataBuffer(p, GDT_CFloat64, m_NbBands, lNbColumns*lNbLines); - delete[] pBufferTemp; - } - // In the indexed case, one has to retrieve the index image and the // color table, and translate p to a 4 components color values buffer - else*/ if (m_IsIndexed) + if (m_IsIndexed) { // TODO: This is a very special case and seems to be working only // for unsigned char pixels. There might be a gdal method to do @@ -346,8 +194,9 @@ void GDALImageIO::Read(void* buffer) std::streamoff step = static_cast<std::streamoff>(this->GetNumberOfComponents()) * static_cast<std::streamoff>(m_BytePerPixel); - - CPLErr lCrGdal = dataset->GetRasterBand(1)->RasterIO(GF_Read, + otbLogMacro(Debug,<<"GDAL reads ["<<lFirstColumn<<", "<<lFirstColumn+lNbColumns-1<<"]x["<<lFirstLine<<", "<<lFirstLine+lNbLines-1<<"] indexed color image of type "<<GDALGetDataTypeName(m_PxType->pixType)<<" from file "<<m_FileName); + otb::Stopwatch chrono = otb::Stopwatch::StartNew(); + CPLErr lCrGdal = dataset->GetRasterBand(1)->RasterIO(GF_Read, lFirstColumn, lFirstLine, lNbColumns, @@ -358,11 +207,16 @@ void GDALImageIO::Read(void* buffer) m_PxType->pixType, 0, 0); - if (lCrGdal == CE_Failure) + chrono.Stop(); + + if (lCrGdal == CE_Failure) { itkExceptionMacro(<< "Error while reading image (GDAL format) '" << m_FileName.c_str() << "' : " << CPLGetLastErrorMsg()); } + + otbLogMacro(Debug,<< "GDAL read took " << chrono.GetElapsedMilliseconds() << " ms") + // Interpret index as color std::streamoff cpt(0); GDALColorTable* colorTable = dataset->GetRasterBand(1)->GetColorTable(); @@ -394,19 +248,7 @@ void GDALImageIO::Read(void* buffer) } // keep it for the moment - //otbMsgDevMacro(<< "Number of bands inside input file: " << m_NbBands); - otbMsgDevMacro(<< "Parameters RasterIO : \n" - << " indX = " << lFirstColumn << "\n" - << " indY = " << lFirstLine << "\n" - << " sizeX = " << lNbColumns << "\n" - << " sizeY = " << lNbLines << "\n" - << " Buffer Size X = " << lNbColumnsRegion << "\n" - << " Buffer Size Y = " << lNbLinesRegion << "\n" - << " GDAL Data Type = " << GDALGetDataTypeName(m_PxType->pixType) << "\n" - << " nbBands = " << nbBands << "\n" - << " pixelOffset = " << pixelOffset << "\n" - << " lineOffset = " << lineOffset << "\n" - << " bandOffset = " << bandOffset ); + otbLogMacro(Debug,<<"GDAL reads ["<<lFirstColumn<<", "<<lFirstColumnRegion+lNbColumnsRegion-1<<"]x["<<lFirstLineRegion<<", "<<lFirstLineRegion+lNbLinesRegion-1<<"] x "<<nbBands<<" bands of type "<<GDALGetDataTypeName(m_PxType->pixType)<<" from file "<<m_FileName); otb::Stopwatch chrono = otb::Stopwatch::StartNew(); CPLErr lCrGdal = m_Dataset->GetDataSet()->RasterIO(GF_Read, @@ -425,8 +267,6 @@ void GDALImageIO::Read(void* buffer) lineOffset, bandOffset); chrono.Stop(); - otbMsgDevMacro(<< "RasterIO Read took " << chrono.GetElapsedMilliseconds() << " ms") - // Check if gdal call succeed if (lCrGdal == CE_Failure) { @@ -434,8 +274,10 @@ void GDALImageIO::Read(void* buffer) << m_FileName.c_str() << "' : " << CPLGetLastErrorMsg()); return; } - //printDataBuffer(p, m_PxType->pixType, m_NbBands, lNbColumnsRegion*lNbLinesRegion); - } + + otbLogMacro(Debug,<< "GDAL read took " << chrono.GetElapsedMilliseconds() << " ms") + + } } bool GDALImageIO::GetSubDatasetInfo(std::vector<std::string> &names, std::vector<std::string> &desc) @@ -456,8 +298,6 @@ bool GDALImageIO::GetSubDatasetInfo(std::vector<std::string> &names, std::vector std::string key, name; if (System::ParseHdfSubsetName(papszMetadata[cpt], key, name)) { - otbMsgDevMacro(<< "- key: " << key); - otbMsgDevMacro(<< "- name: " << name); // check if this is a dataset name if (key.find("_NAME") != std::string::npos) names.push_back(name); // check if this is a dataset descriptor @@ -609,8 +449,6 @@ void GDALImageIO::InternalReadImageInformation() std::string key, name; if (System::ParseHdfSubsetName(papszMetadata[cpt], key, name)) { - otbMsgDevMacro(<< "- key: " << key); - otbMsgDevMacro(<< "- name: " << name); // check if this is a dataset name if (key.find("_NAME") != std::string::npos) names.push_back(name); } @@ -618,7 +456,6 @@ void GDALImageIO::InternalReadImageInformation() } if (m_DatasetNumber < names.size()) { - otbMsgDevMacro(<< "Reading: " << names[m_DatasetNumber]); m_Dataset = GDALDriverManagerWrapper::GetInstance().Open(names[m_DatasetNumber]); } else @@ -643,8 +480,6 @@ void GDALImageIO::InternalReadImageInformation() m_OriginalDimensions.push_back(dataset->GetRasterXSize()); m_OriginalDimensions.push_back(dataset->GetRasterYSize()); - otbMsgDevMacro(<< "Original Dimensions of the input file: " << m_OriginalDimensions[0] << " x " << m_OriginalDimensions[1]); - // Get Number of Bands m_NbBands = dataset->GetRasterCount(); @@ -661,21 +496,13 @@ void GDALImageIO::InternalReadImageInformation() /*std::cout << "Overviews size of input file" << m_FileName << ": " << m_OverviewsSize.back().first << " x " << m_OverviewsSize.back().second << std::endl; */ - otbMsgDevMacro( << "Overviews size of input file" << m_FileName << ": " - << m_OverviewsSize.back().first << " x " << m_OverviewsSize.back().second); } - otbMsgDevMacro(<< "Number of Overviews inside input file: " << m_NumberOfOverviews); - otbMsgDevMacro(<< "Input file dimension: " << m_Dimensions[0] << ", " << m_Dimensions[1]); - otbMsgDevMacro(<< "Number of bands inside input file: " << m_NbBands); - this->SetNumberOfComponents(m_NbBands); // Set the number of dimensions (verify for the dim ) this->SetNumberOfDimensions(2); - otbMsgDevMacro(<< "Nb of Dimensions of the input file: " << m_NumberOfDimensions); - // Automatically set the Type to Binary for GDAL data this->SetFileTypeToBinary(); @@ -683,7 +510,7 @@ void GDALImageIO::InternalReadImageInformation() // Consider only the data type given by the first band // Maybe be could changed (to check) m_PxType->pixType = dataset->GetRasterBand(1)->GetRasterDataType(); - otbMsgDevMacro(<< "PixelType inside input file: "<< GDALGetDataTypeName(m_PxType->pixType) ); + if (m_PxType->pixType == GDT_Byte) { SetComponentType(UCHAR); @@ -809,7 +636,7 @@ void GDALImageIO::InternalReadImageInformation() // we are reading a complex data set into an image where the pixel // type is Vector<real>: we have to double the number of component // for that to work - otbMsgDevMacro( << "GDALtypeIO= Complex and IFReader::InternalPixelType= Scalar and IFReader::PixelType= Vector"); + otbLogMacro(Warning,<<"Encoding of file ("<<m_FileName<<") is complex but will be read as a VectorImage of scalar type, with twice the number of bands."); this->SetNumberOfComponents(m_NbBands*2); this->SetPixelType(VECTOR); } @@ -831,12 +658,6 @@ void GDALImageIO::InternalReadImageInformation() } } - /*** Parameters set by Internal Read function ***/ - otbMsgDevMacro( << "Pixel Type IFReader = " << GetPixelTypeAsString(this->GetPixelType()) ) - otbMsgDevMacro( << "Number of component IFReader = " << this->GetNumberOfComponents() ) - otbMsgDevMacro( << "Byte per pixel set = " << m_BytePerPixel ) - otbMsgDevMacro( << "Component Type set = " << GetComponentTypeAsString(this->GetComponentType()) ); - /*----------------------------------------------------------------------*/ /*-------------------------- METADATA ----------------------------------*/ /*----------------------------------------------------------------------*/ @@ -854,8 +675,6 @@ void GDALImageIO::InternalReadImageInformation() if(blockSizeX > 0 && blockSizeY > 0) { - otbMsgDevMacro(<< "Original blockSize: "<< blockSizeX << " x " << blockSizeY ); - blockSizeX = uint_ceildivpow2(blockSizeX,m_ResolutionFactor); if (m_Dataset->IsJPEG2000()) { @@ -868,8 +687,6 @@ void GDALImageIO::InternalReadImageInformation() blockSizeY = blockSizeY * (1 << m_ResolutionFactor); } - otbMsgDevMacro(<< "Decimated blockSize: "<< blockSizeX << " x " << blockSizeY ); - itk::EncapsulateMetaData<unsigned int>(dict, MetaDataKey::TileHintX, blockSizeX); itk::EncapsulateMetaData<unsigned int>(dict, MetaDataKey::TileHintY, blockSizeY); } @@ -948,7 +765,6 @@ void GDALImageIO::InternalReadImageInformation() } else { - otbMsgDevMacro( << "No projection => sensor model" ); // Special case for Jpeg2000 files : try to read the origin in the GML box if (m_Dataset->IsJPEG2000()) { @@ -1044,7 +860,7 @@ void GDALImageIO::InternalReadImageInformation() } else { - otbWarningMacro(<< "Incorrect geotransform (spacing = 0)!"); + otbLogMacro(Warning,<< "Geotransform reported by Gdal is invalid (spacing = 0)"); m_Spacing[0] = 1; m_Spacing[1] = 1; } @@ -1065,23 +881,6 @@ void GDALImageIO::InternalReadImageInformation() m_Origin[0] += 0.5*m_Spacing[0]; m_Origin[1] += 0.5*m_Spacing[1]; - // Dataset info - otbMsgDevMacro(<< "**** ReadImageInformation() DATASET INFO: ****" ); - otbMsgDevMacro(<< "Projection Ref: "<< dataset->GetProjectionRef() ); - double GT[6]; - if (dataset->GetGeoTransform(GT) == CE_None) - { - otbMsgDevMacro( <<"Geo Transform: "<< GT[0] << ", " << GT[1] << ", " - << GT[2] << ", " << GT[3] << ", " - << GT[4] << ", " << GT[5] ); - } - else - { - otbMsgDevMacro( << "No Geo Transform: "); - } - otbMsgDevMacro(<< "GCP Projection Ref: "<< dataset->GetGCPProjection() ); - otbMsgDevMacro(<< "GCP Count: " << dataset->GetGCPCount() ); - /* -------------------------------------------------------------------- */ /* Report metadata. */ /* -------------------------------------------------------------------- */ @@ -1289,7 +1088,6 @@ bool GDALImageIO::CanWriteFile(const char* name) // First check the filename if (name == ITK_NULLPTR) { - itkDebugMacro(<< "No filename specified."); return false; } @@ -1307,7 +1105,7 @@ bool GDALImageIO::CanWriteFile(const char* name) if ( GDALGetMetadataItem( driver, GDAL_DCAP_CREATE, ITK_NULLPTR ) == ITK_NULLPTR && GDALGetMetadataItem( driver, GDAL_DCAP_CREATECOPY, ITK_NULLPTR ) == ITK_NULLPTR ) { - itkDebugMacro(<< "The driver " << GDALGetDriverShortName(driver) << " does not support writing"); + otbLogMacro(Warning,<< "Gdal driver " << GDALGetDriverShortName(driver) << " does not support writing"); return false; } return true; @@ -1321,7 +1119,6 @@ bool GDALImageIO::CanStreamWrite() if (driver == ITK_NULLPTR) { - itkDebugMacro(<< "Unable to instantiate driver " << gdalDriverShortName); m_CanStreamWrite = false; } if ( GDALGetMetadataItem( driver, GDAL_DCAP_CREATE, ITK_NULLPTR ) != ITK_NULLPTR ) @@ -1347,7 +1144,7 @@ void GDALImageIO::Write(const void* buffer) // Check if conversion succeed if (buffer == ITK_NULLPTR) { - itkExceptionMacro(<< "GDAL : Bad alloc"); + itkExceptionMacro(<< "Null buffer passed to GDALImageIO for writing."); return; } @@ -1373,18 +1170,7 @@ void GDALImageIO::Write(const void* buffer) // If driver supports streaming if (m_CanStreamWrite) { - - otbMsgDevMacro(<< "RasterIO Write requested region : " << this->GetIORegion() << - "\n, lFirstColumn =" << lFirstColumn << - "\n, lFirstLine =" << lFirstLine << - "\n, lNbColumns =" << lNbColumns << - "\n, lNbLines =" << lNbLines << - "\n, m_PxType =" << GDALGetDataTypeName(m_PxType->pixType) << - "\n, m_NbBands =" << m_NbBands << - "\n, m_BytePerPixel ="<< m_BytePerPixel << - "\n, Pixel offset =" << m_BytePerPixel * m_NbBands << // is nbComp * BytePerPixel - "\n, Line offset =" << m_BytePerPixel * m_NbBands * lNbColumns << // is pixelOffset * nbColumns - "\n, Band offset =" << m_BytePerPixel) // is BytePerPixel + otbLogMacro(Debug,<<"GDAL writes ["<<lFirstColumn<<", "<<lFirstColumn+lNbColumns-1<<"]x["<<lFirstLine<<", "<<lFirstLine+lNbLines-1<<"] x "<<m_NbBands<<" bands of type "<<GDALGetDataTypeName(m_PxType->pixType)<<" to file "<<m_FileName); otb::Stopwatch chrono = otb::Stopwatch::StartNew(); CPLErr lCrGdal = m_Dataset->GetDataSet()->RasterIO(GF_Write, @@ -1408,7 +1194,6 @@ void GDALImageIO::Write(const void* buffer) // Band offset is BytePerPixel m_BytePerPixel); chrono.Stop(); - otbMsgDevMacro(<< "RasterIO Write took " << chrono.GetElapsedMilliseconds() << " ms") // Check if writing succeed if (lCrGdal == CE_Failure) @@ -1416,6 +1201,9 @@ void GDALImageIO::Write(const void* buffer) itkExceptionMacro(<< "Error while writing image (GDAL format) '" << m_FileName.c_str() << "' : " << CPLGetLastErrorMsg()); } + + otbLogMacro(Debug,<< "GDAL write took " << chrono.GetElapsedMilliseconds() << " ms") + // Flush dataset cache m_Dataset->GetDataSet()->FlushCache(); } @@ -1582,55 +1370,6 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) if (m_CanStreamWrite) { GDALCreationOptionsType creationOptions = m_CreationOptions; -/* - // Force tile mode for TIFF format if no creation option are given - if( driverShortName == "GTiff" ) - { - if ( CreationOptionContains( "TILED=YES" ) ) - { - // User requested tiled TIFF explicitly - // - // Let GDAL set up the BLOCKXSIZE and BLOCKYSIZE - // or suppose the user have set it also along with TILED=YES - // This allows the user to have complete - // control over the tiling scheme - } - else if ( CreationOptionContains( "BLOCKYSIZE=" ) ) - { - // User did not set "TILED=YES" but set "BLOCKYSIZE=" - // -> He requested a stripped TIFF - } - else - { - // User did not specify "TILED=YES" nor "BLOCKYSIZE=?" - // Switch to TILED mode automatically, and choose BLOCKXSIZE and BLOCKYSIZE for him - - otbMsgDevMacro(<< "Enabling TIFF Tiled mode") - - // Use a fixed tile size - // Take as reference is a 256*256 short int 4 bands tile - const unsigned int ReferenceTileSizeInBytes = 256 * 256 * 4 * 2; - const unsigned int NbPixelPerTile = ReferenceTileSizeInBytes / m_BytePerPixel / m_NbBands; - const unsigned int IdealTileDimension = static_cast<unsigned int>( vcl_sqrt(static_cast<float>(NbPixelPerTile)) ); - - // Set tileDimension to the nearest power of two and aligned to - // 16 pixels (needed by TIFF spec) - unsigned int tileDimension = 16; - while(2*tileDimension < IdealTileDimension) - { - tileDimension*=2; - } - otbMsgDevMacro(<< "Tile dimension : " << tileDimension << " * " << tileDimension) - - std::ostringstream tileDimensionStr; - tileDimensionStr << tileDimension; - - creationOptions.push_back( "TILED=YES" ); - creationOptions.push_back( std::string("BLOCKXSIZE=") + tileDimensionStr.str() ); - creationOptions.push_back( std::string("BLOCKYSIZE=") + tileDimensionStr.str() ); - } - } -*/ m_Dataset = GDALDriverManagerWrapper::GetInstance().Create( driverShortName, GetGdalWriteImageFileName(driverShortName, m_FileName), @@ -1691,7 +1430,7 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) // If there is no ProjectionRef, and the GeoTransform is not the identity, // then saving also GCPs is undefined behavior for GDAL, and a WGS84 projection crs // is assigned arbitrarily - otbMsgDevMacro(<< "Skipping GCPs saving to prevent GDAL from assigning a WGS84 projection ref to the file") + otbLogMacro(Warning,<< "Skipping GCPs saving to prevent GDAL from assigning a WGS84 projref to file ("<<m_FileName<<")") } else { @@ -1802,7 +1541,6 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) unsigned int equalityPos = svalue.find_first_of('='); std::string tag = svalue.substr(0, equalityPos); std::string value = svalue.substr(equalityPos + 1); - otbMsgDevMacro(<< "Metadata: " << tag << "=" << value); dataset->SetMetadataItem(tag.c_str(), value.c_str(), ITK_NULLPTR); } } @@ -1810,24 +1548,6 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) // END - // Dataset info - otbMsgDevMacro( << "**** WriteImageInformation() DATASET INFO: ****" ); - otbMsgDevMacro( << "Projection Ref: "<<dataset->GetProjectionRef() ); - double GT[6]; - if (dataset->GetGeoTransform(GT) == CE_None) - { - otbMsgDevMacro( <<"Geo Transform: "<< GT[0] << ", " << GT[1] << ", " - << GT[2] << ", " << GT[3] << ", " - << GT[4] << ", " << GT[5] ); - } - else - { - otbMsgDevMacro( << "No Geo Transform: "); - } - - otbMsgDevMacro( << "GCP Projection Ref: "<< dataset->GetGCPProjection() ); - otbMsgDevMacro( << "GCP Count: " << dataset->GetGCPCount() ); - // Write no-data flags std::vector<bool> noDataValueAvailable; bool ret = itk::ExposeMetaData<std::vector<bool> >(dict,MetaDataKey::NoDataValueAvailable,noDataValueAvailable); @@ -1926,7 +1646,6 @@ bool GDALImageIO::GetOriginFromGMLBox(std::vector<double> &origin) std::string gmlString = static_cast<std::string>(jp2Metadata.papszGMLMetadata[0]); gmlString.erase(0,18); // We need to remove first part to create a true xml stream - otbMsgDevMacro( << "XML extract from GML box: " << gmlString ); TiXmlDocument doc; doc.Parse(gmlString.c_str()); // Create xml doc from a string @@ -1942,13 +1661,8 @@ bool GDALImageIO::GetOriginFromGMLBox(std::vector<double> &origin) .FirstChild( "gml:limits" ) .FirstChild( "gml:GridEnvelope" ) .FirstChild( "gml:low").ToElement(); - if(originTag) + if(!originTag) { - otbMsgDevMacro( << "\t Origin (" << originTag->Value() <<" tag)= "<< originTag->GetText()); - } - else - { - otbMsgDevMacro( << "Didn't find the GML element which indicate the origin!" ); return false; } @@ -1963,8 +1677,6 @@ bool GDALImageIO::GetOriginFromGMLBox(std::vector<double> &origin) origin[0] += -1.0; origin[1] += -1.0; - otbMsgDevMacro( << "\t Origin from GML box: " << origin[0] << ", " << origin[1] ); - return true; } diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx index 87cc50b6e3..155ce0503d 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.txx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx @@ -107,7 +107,6 @@ void ImageFileReader<TOutputImage, ConvertPixelTraits> ::SetImageIO( otb::ImageIOBase * imageIO) { - itkDebugMacro("setting ImageIO to " << imageIO ); if (this->m_ImageIO != imageIO ) { this->m_ImageIO = imageIO; @@ -207,12 +206,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> char * loadBuffer = new char[nbBytes]; - otbMsgDevMacro(<< "buffer size for ImageIO::read = " << nbBytes << " = \n" - << "ComponentSize ("<< this->m_ImageIO->GetComponentSize() << ") x " \ - << "Nb of Component ( max(" << this->m_ImageIO->GetNumberOfComponents() \ - << " , "<<m_BandList.size() << ") ) x " \ - << "Nb of Pixel to read (" << region.GetNumberOfPixels() << ")"); - this->m_ImageIO->Read(loadBuffer); if (m_FilenameHelper->BandRangeIsSet()) @@ -410,13 +403,13 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> if (m_FilenameHelper->ExtGEOMFileNameIsSet()) { otb_kwl = ReadGeometryFromGEOMFile(m_FilenameHelper->GetExtGEOMFileName()); - otbMsgDevMacro(<< "Loading external kwl: "<< m_FilenameHelper->GetExtGEOMFileName()); + otbLogMacro(Info,<< "Loading metadata from external geom file "<< m_FilenameHelper->GetExtGEOMFileName()); } // Case 2: attached geom (if present) else if (itksys::SystemTools::FileExists(attachedGeom)) { otb_kwl = ReadGeometryFromGEOMFile(attachedGeom); - otbMsgDevMacro(<< "Loading attached kwl"); + otbLogMacro(Info,<< "Loading metadata from attached geom file "<<attachedGeom); } // Case 3: find an ossimPluginProjection // Case 4: find an ossimProjection @@ -424,7 +417,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> else { otb_kwl = ReadGeometryFromImage(lFileNameOssimKeywordlist,!m_FilenameHelper->GetSkipRpcTag()); - otbMsgDevMacro(<< "Loading internal kwl"); + otbLogMacro(Info,<< "Loading metadata from product files"); } // Don't add an empty ossim keyword list @@ -644,8 +637,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> fic_trouve = true; } - otbMsgDevMacro(<< "lFileNameGdal : " << GdalFileName.c_str()); - otbMsgDevMacro(<< "fic_trouve : " << fic_trouve); return (fic_trouve); } diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index b1472291f1..4cc2c316da 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -99,7 +99,6 @@ ImageFileWriter<TInputImage> typedef NumberOfDivisionsStrippedStreamingManager<TInputImage> NumberOfDivisionsStrippedStreamingManagerType; typename NumberOfDivisionsStrippedStreamingManagerType::Pointer streamingManager = NumberOfDivisionsStrippedStreamingManagerType::New(); streamingManager->SetNumberOfDivisions(nbDivisions); - m_StreamingManager = streamingManager; } @@ -111,7 +110,6 @@ ImageFileWriter<TInputImage> typedef NumberOfDivisionsTiledStreamingManager<TInputImage> NumberOfDivisionsTiledStreamingManagerType; typename NumberOfDivisionsTiledStreamingManagerType::Pointer streamingManager = NumberOfDivisionsTiledStreamingManagerType::New(); streamingManager->SetNumberOfDivisions(nbDivisions); - m_StreamingManager = streamingManager; } @@ -123,7 +121,6 @@ ImageFileWriter<TInputImage> typedef NumberOfLinesStrippedStreamingManager<TInputImage> NumberOfLinesStrippedStreamingManagerType; typename NumberOfLinesStrippedStreamingManagerType::Pointer streamingManager = NumberOfLinesStrippedStreamingManagerType::New(); streamingManager->SetNumberOfLinesPerStrip(nbLinesPerStrip); - m_StreamingManager = streamingManager; } @@ -136,7 +133,6 @@ ImageFileWriter<TInputImage> typename RAMDrivenStrippedStreamingManagerType::Pointer streamingManager = RAMDrivenStrippedStreamingManagerType::New(); streamingManager->SetAvailableRAMInMB(availableRAM); streamingManager->SetBias(bias); - m_StreamingManager = streamingManager; } @@ -147,8 +143,7 @@ ImageFileWriter<TInputImage> { typedef TileDimensionTiledStreamingManager<TInputImage> TileDimensionTiledStreamingManagerType; typename TileDimensionTiledStreamingManagerType::Pointer streamingManager = TileDimensionTiledStreamingManagerType::New(); - streamingManager->SetTileDimension(tileDimension); - + streamingManager->SetTileDimension(tileDimension); m_StreamingManager = streamingManager; } @@ -238,7 +233,6 @@ void ImageFileWriter<TInputImage> ::SetIORegion(const itk::ImageIORegion& region) { - itkDebugMacro("setting IORegion to " << region); if (m_IORegion != region) { m_IORegion = region; @@ -289,7 +283,7 @@ ImageFileWriter<TInputImage> /** Parse streaming modes */ if(m_FilenameHelper->StreamingTypeIsSet()) { - itkWarningMacro(<<"Streaming configuration through extended filename is used. Any previous streaming configuration (ram value, streaming mode ...) will be ignored."); + otbLogMacro(Warning,<<"Streaming configuration through extended filename is used. Any previous streaming configuration (ram value, streaming mode ...) will be ignored."); std::string type = m_FilenameHelper->GetStreamingType(); @@ -311,11 +305,11 @@ ImageFileWriter<TInputImage> { if(sizemode != "auto") { - itkWarningMacro(<<"In auto streaming type, the sizemode option will be ignored."); + otbLogMacro(Warning,<<"In auto streaming type, the sizemode option will be ignored."); } if(sizevalue == 0.) { - itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from the OTB_MAX_RAM_HINT environment variable if set, or else use the default value"); + otbLogMacro(Warning,<<"sizemode is auto but sizevalue is 0. Value will be fetched from the OTB_MAX_RAM_HINT environment variable if set, or else use the default value"); } this->SetAutomaticAdaptativeStreaming(sizevalue); } @@ -325,7 +319,7 @@ ImageFileWriter<TInputImage> { if(sizevalue == 0.) { - itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from the OTB_MAX_RAM_HINT environment variable if set, or else use the default value"); + otbLogMacro(Warning,<<"sizemode is auto but sizevalue is 0. Value will be fetched from the OTB_MAX_RAM_HINT environment variable if set, or else use the default value"); } this->SetAutomaticTiledStreaming(sizevalue); } @@ -333,7 +327,7 @@ ImageFileWriter<TInputImage> { if(sizevalue == 0.) { - itkWarningMacro("Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); + otbLogMacro(Warning,<<"Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } this->SetNumberOfDivisionsTiledStreaming(static_cast<unsigned int>(sizevalue)); } @@ -341,7 +335,7 @@ ImageFileWriter<TInputImage> { if(sizevalue == 0.) { - itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); + otbLogMacro(Warning,<<"Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } this->SetTileDimensionTiledStreaming(static_cast<unsigned int>(sizevalue)); @@ -353,7 +347,7 @@ ImageFileWriter<TInputImage> { if(sizevalue == 0.) { - itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from configuration file if any, or from cmake configuration otherwise."); + otbLogMacro(Warning,<<"sizemode is auto but sizevalue is 0. Value will be fetched from configuration file if any, or from cmake configuration otherwise."); } this->SetAutomaticStrippedStreaming(sizevalue); @@ -362,7 +356,7 @@ ImageFileWriter<TInputImage> { if(sizevalue == 0.) { - itkWarningMacro("Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); + otbLogMacro(Warning,<<"Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } this->SetNumberOfDivisionsStrippedStreaming(static_cast<unsigned int>(sizevalue)); } @@ -370,7 +364,7 @@ ImageFileWriter<TInputImage> { if(sizevalue == 0.) { - itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); + otbLogMacro(Warning,<<"Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } this->SetNumberOfLinesStrippedStreaming(static_cast<unsigned int>(sizevalue)); } @@ -380,7 +374,7 @@ ImageFileWriter<TInputImage> { if(sizemode!="" || sizevalue!=0.) { - itkWarningMacro("Streaming is explicitly disabled, sizemode and sizevalue will be ignored."); + otbLogMacro(Warning,<<"Streaming is explicitly disabled, sizemode and sizevalue will be ignored."); } this->SetNumberOfDivisionsTiledStreaming(0); } @@ -389,7 +383,7 @@ ImageFileWriter<TInputImage> { if(m_FilenameHelper->StreamingSizeValueIsSet() || m_FilenameHelper->StreamingSizeModeIsSet()) { - itkWarningMacro(<<"No streaming type is set, streaming sizemode and sizevalue will be ignored."); + otbLogMacro(Warning,<<"No streaming type is set, streaming sizemode and sizevalue will be ignored."); } } @@ -418,8 +412,6 @@ ImageFileWriter<TInputImage> if (m_ImageIO.IsNull()) //try creating via factory { - itkDebugMacro(<< "Attempting factory creation of ImageIO for file: " - << m_FileName); this->SetImageIO(ImageIOFactory::CreateImageIO(m_FileName.c_str(), otb::ImageIOFactory::WriteMode)); @@ -429,13 +421,8 @@ ImageFileWriter<TInputImage> { if (!m_ImageIO->CanWriteFile(m_FileName.c_str())) { - itkDebugMacro(<< "ImageIO exists but doesn't know how to write file:" - << m_FileName); - if (m_FactorySpecifiedImageIO) { - itkDebugMacro(<< "Attempting creation of ImageIO with a factory for file:" - << m_FileName); m_ImageIO = ImageIOFactory::CreateImageIO(m_FileName.c_str(), otb::ImageIOFactory::WriteMode); m_FactorySpecifiedImageIO = true; @@ -514,7 +501,7 @@ ImageFileWriter<TInputImage> e.SetDataObject(inputPtr); throw e; } - otbMsgDevMacro(<< "inputRegion " << inputRegion); + otbLogMacro(Info,<<"Writing user defined region ["<<start[0]<<", "<<start[0]+size[0]-1<<"]x["<<start[1]<<", "<<start[1]+size[1]<<"]"); } /** @@ -526,9 +513,8 @@ ImageFileWriter<TInputImage> /** Control if the ImageIO is CanStreamWrite */ if (m_ImageIO->CanStreamWrite() == false) { - otbWarningMacro( - << "The ImageFactory selected for the image file <" << m_FileName.c_str() << - "> does not support streaming."); + otbLogMacro(Warning,<<"The file format of " << m_FileName.c_str() << + " does not support streaming. All data will be loaded to memory"); this->SetNumberOfDivisionsStrippedStreaming(1); } @@ -537,12 +523,14 @@ ImageFileWriter<TInputImage> * Not sure that if this modification is needed */ else if (inputPtr->GetBufferedRegion() == inputRegion) { - otbMsgDevMacro(<< "Buffered region is the largest possible region, there is no need for streaming."); + otbLogMacro(Debug,<< "Buffered region is the largest possible region, there is no need for streaming."); this->SetNumberOfDivisionsStrippedStreaming(1); } m_StreamingManager->PrepareStreaming(inputPtr, inputRegion); m_NumberOfDivisions = m_StreamingManager->GetNumberOfSplits(); - otbMsgDebugMacro(<< "Number Of Stream Divisions : " << m_NumberOfDivisions); + + const auto firstSplitSize = m_StreamingManager->GetSplit(0).GetSize(); + otbLogMacro(Info,<<"File "<<m_FileName<<" will be written in "<<m_NumberOfDivisions<<" blocks of "<<firstSplitSize[0]<<"x"<<firstSplitSize[1]<<" pixels"); /** * Loop over the number of pieces, execute the upstream pipeline on each @@ -612,7 +600,7 @@ ImageFileWriter<TInputImage> } else { - itkWarningMacro(<< "Could not get the source process object. Progress report might be buggy"); + otbLogMacro(Warning,<< "Could not get the source process object. Progress report might be buggy"); } for (m_CurrentDivision = 0; @@ -746,9 +734,6 @@ ImageFileWriter<TInputImage> { if ( m_NumberOfDivisions > 1 || m_UserSpecifiedIORegion) { - itkDebugMacro("Requested stream region does not match generated output"); - itkDebugMacro("input filter may not support streaming well"); - cacheImage = InputImageType::New(); cacheImage->CopyInformation(input); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx index 74e7385133..814695045a 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx @@ -38,8 +38,6 @@ template <class TImageType> TImageType* InputImageParameter::GetImage() { - otbMsgDevMacro(<< "GetImage()"); - // Used m_PreviousFileName because if not, when the user call twice GetImage, // it without changing the filename, it returns 2 different // image pointers -- GitLab From 53c2697b644961eb2e2800f9cd34e02590fe4740 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 22 Feb 2018 15:19:10 +0100 Subject: [PATCH 305/567] ENH: move cesbio remote modules to OTB's gitlab --- Modules/Remote/otb-bv.remote.cmake | 4 ++-- Modules/Remote/phenotb.remote.cmake | 4 ++-- Modules/Remote/temporal-gapfilling.remote.cmake | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/Remote/otb-bv.remote.cmake b/Modules/Remote/otb-bv.remote.cmake index 06e067e658..739f46126b 100644 --- a/Modules/Remote/otb-bv.remote.cmake +++ b/Modules/Remote/otb-bv.remote.cmake @@ -22,8 +22,8 @@ otb_fetch_module(OTBBioVars "Biophysical variable estimation from remote sensing imagery. A more detailed description can be found on the project website: -http://tully.ups-tlse.fr/jordi/otb-bv +https://gitlab.orfeo-toolbox.org/jinglada/otb-bv " - GIT_REPOSITORY http://tully.ups-tlse.fr/jordi/otb-bv.git + GIT_REPOSITORY https://gitlab.orfeo-toolbox.org/jinglada/otb-bv.git GIT_TAG 0e56e487aebc4a493e25223960560e9ef0ca27ec ) diff --git a/Modules/Remote/phenotb.remote.cmake b/Modules/Remote/phenotb.remote.cmake index aa9e9a8ead..74d83a9d96 100644 --- a/Modules/Remote/phenotb.remote.cmake +++ b/Modules/Remote/phenotb.remote.cmake @@ -24,8 +24,8 @@ otb_fetch_module(OTBPhenology information from time profiles. These time profiles should represent vegetation status as for instance NDVI, LAI, etc. A more detailed description can be found on the project website: -http://tully.ups-tlse.fr/jordi/phenotb +https://gitlab.orfeo-toolbox.org/jinglada/phenotb " - GIT_REPOSITORY http://tully.ups-tlse.fr/jordi/phenotb.git + GIT_REPOSITORY https://gitlab.orfeo-toolbox.org/jinglada/phenotb.git GIT_TAG c9349eb89a652a18b28a40dfb3fa352b76388527 ) diff --git a/Modules/Remote/temporal-gapfilling.remote.cmake b/Modules/Remote/temporal-gapfilling.remote.cmake index 469a857fb8..2dd788d213 100644 --- a/Modules/Remote/temporal-gapfilling.remote.cmake +++ b/Modules/Remote/temporal-gapfilling.remote.cmake @@ -23,9 +23,9 @@ otb_fetch_module(OTBTemporalGapFilling "Gapfilling for time series replaces invalid pixels (as designated by a mask) by an interpolation using the valid dates of the series. A more detailed description can be found on the project website: -http://tully.ups-tlse.fr/jordi/temporalgapfilling +https://gitlab.orfeo-toolbox.org/jinglada/temporalgapfilling " - GIT_REPOSITORY http://tully.ups-tlse.fr/jordi/temporalgapfilling.git + GIT_REPOSITORY https://gitlab.orfeo-toolbox.org/jinglada/temporalgapfilling.git # Commit on develop branch which includes patches for Windows support GIT_TAG 4fc4a71acf7b9b051cda5a3b950de2cdb9d26287 ) -- GitLab From dcc64be8c7d0536412ca196151873ca036eb59a8 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Thu, 22 Feb 2018 15:24:22 +0100 Subject: [PATCH 306/567] DOC: review and fix minor typo in python recipe --- Documentation/Cookbook/rst/recipes/python.rst | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/Documentation/Cookbook/rst/recipes/python.rst b/Documentation/Cookbook/rst/recipes/python.rst index cbb119372d..eaff6e537d 100644 --- a/Documentation/Cookbook/rst/recipes/python.rst +++ b/Documentation/Cookbook/rst/recipes/python.rst @@ -32,10 +32,10 @@ application, changing the algorithm at each iteration. print "Available applications: " print str( otbApplication.Registry.GetAvailableApplications() ) - # Let's create the application with codename "Smoothing" + # Let's create the application "Smoothing" app = otbApplication.Registry.CreateApplication("Smoothing") - # We print the keys of all its parameter + # We print the keys of all its parameters print app.GetParametersKeys() # First, we set the input image filename @@ -47,35 +47,36 @@ application, changing the algorithm at each iteration. print 'Running with ' + type + ' smoothing type' - # Here we configure the smoothing algorithm + # Now we configure the smoothing algorithm app.SetParameterString("type", type) - # Set the output filename, using the algorithm to differentiate the outputs + # Set the output filename, using the algorithm type to differentiate the outputs app.SetParameterString("out", argv[2] + type + ".tif") - # This will execute the application and save the output file + # This will execute the application and save the output to argv[2] app.ExecuteAndWriteOutput() -Numpy array processing +NumPy array processing ---------------------- -Input and output images to any OTB application in the form of numpy array is now possible in OTB python wrapping. -The python wrapping only exposes OTB ApplicationEngine module which allow to access existing C++ applications. +Input and output images to any OTB application in the form of NumPy array is now possible in OTB Python wrapping. +The Python wrapping only exposes OTB Application engine module (called *ApplicationEngine*) which allows to access existing C++ applications. Due to blissful nature of ApplicationEngine's loading mechanism no specific wrapping is required for each application. -Numpy extension to Python wrapping allows data exchange to application as an array rather than a disk file. -Ofcourse, it is possible to load an image from file and then convert to numpy array or just provide a file as earlier via +NumPy extension to Python wrapping allows data exchange to application as an array rather than a disk file. +Of course, it is possible to load an image from file and then convert to NumPy +array or just provide a file as explained in the previous section via Application.SetParameterString(...). -This bridge that completes numpy and OTB makes it easy to plug OTB into any image processing chain via python code that uses -GIS/Image processing tools such as GDAL, GRASS GIS, OSSIM that can deal with numpy. +The bridge between NumPy and OTB makes it easy to plug OTB into any image processing chain via Python code that uses +GIS/Image processing tools such as GDAL, GRASS GIS, OSSIM that can deal with NumPy. - -Below code reads an input image using python pillow (PIL) and convert it to numpy array. This numpy array is -used an input to the application via *SetImageFromNumpyArray(...)* method. -The application used in this example is ExtractROI. After extracting -a small area the output image is taken as numpy array with *GetImageFromNumpyArray(...)* method thus avoid wiriting -output to a temporary file. +Below code reads an input image using Python pillow (PIL) and convert it to +NumPy array. The NumPy array is used an input to the application via +*SetImageFromNumpyArray(...)* method. The application used in this example is +ExtractROI. After extracting a small area the output image is taken as NumPy +array with *GetImageFromNumpyArray(...)* method thus avoid writing output to a +temporary file. :: @@ -105,7 +106,7 @@ In-memory connection -------------------- Applications are often use as parts of larger processing -chains. Chaining applications currently requires to write/read back +workflow. Chaining applications currently requires to write/read back images between applications, resulting in heavy I/O operations and a significant amount of time dedicated to writing temporary files. @@ -118,9 +119,9 @@ images. The last application of the processing chain is responsible for writing the final result images. In-memory connection between applications is available both at the C++ -API level and using the python bindings. +API level and using the Python bindings. -Here is a Python code sample connecting several applications together: +Here is a Python code sample which connects several applications together: .. code-block:: python @@ -167,7 +168,7 @@ Corner cases ------------ There are a few corner cases to be aware of when using Python wrappers. They are -often limitations, that one day may be solved by future developments. If it +often limitations, that one day may be solved in future versions. If it happens, this documentation will report the OTB version that fixes the issue. Calling UpdateParameters() @@ -211,23 +212,23 @@ setting the ``field`` parameter: app.UpdateParameters() app.SetParameterString("field", "label") -No metadata in Numpy arrays +No metadata in NumPy arrays ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -With the Numpy module, it is possible to convert images between OTB and Numpy -arrays. For instance, when converting from OTB to Numpy array: +With the NumPy module, it is possible to convert images between OTB and NumPy +arrays. For instance, when converting from OTB to NumPy array: * An ``Update()`` of the underlying ``otb::VectorImage`` is requested. Be aware that the full image is generated. * The pixel buffer is copied into a ``numpy.array`` As you can see, there is no export of the metadata, such as origin, spacing, -projection WKT. It means that if you want to import back a Numpy array into OTB, +geographic projection. It means that if you want to import back a NumPy array into OTB, the image won't have any of these metadata. It can be a problem for applications doing geometry, projections, and also calibration. Future developments will probably offer a more adapted structure to import and -export images between OTB and Python world. +export images between OTB and the Python world. Setting of boolean parameters ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- GitLab From f0551089be317a085c2eb2d4c9fe543d8685a33f Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 22 Feb 2018 15:28:02 +0100 Subject: [PATCH 307/567] REFAC: Cover all logger modes --- Modules/Core/Common/src/otbConfigurationManager.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/Core/Common/src/otbConfigurationManager.cxx b/Modules/Core/Common/src/otbConfigurationManager.cxx index 4add4e19be..2e2707d0fe 100644 --- a/Modules/Core/Common/src/otbConfigurationManager.cxx +++ b/Modules/Core/Common/src/otbConfigurationManager.cxx @@ -88,6 +88,8 @@ itk::LoggerBase::PriorityLevelType ConfigurationManager::GetLoggerLevel() level_macro(DEBUG); level_macro(WARNING); level_macro(INFO); + level_macro(CRITICAL); + level_macro(FATAL); } return level; } -- GitLab From 7eff8302d82f891e7bbe079c4eb210a06caba4d9 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 22 Feb 2018 15:28:27 +0100 Subject: [PATCH 308/567] DOC: Add proper documentation on the behavior of OTB_LOGGER_LEVEL macro --- .../Common/include/otbConfigurationManager.h | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/otbConfigurationManager.h b/Modules/Core/Common/include/otbConfigurationManager.h index 4ac1dcc372..7b32b3dc72 100644 --- a/Modules/Core/Common/include/otbConfigurationManager.h +++ b/Modules/Core/Common/include/otbConfigurationManager.h @@ -84,7 +84,25 @@ public: */ static RAMValueType GetMaxRAMHint(); - + /** + * Logger level controls the level of logging that OTB will output. + * + * This is used to set-up the otb::Logger class. + * + * If OTB_LOGGER_LEVEL environment variable is set to one of DEBUG, + * INFO, WARNING, CRITICAL or FATAL, the logger level will be + * set accordingly. + * + * Priority is DEBUG < INFO < WARNING < CRITICAL < FATAL. + * + * Only messages with a higher priority than the logger level will + * be displayed. + * + * By default (if OTB_LOGGER_LEVEL is not set or can not be + * decoded), level is DEBUG in Debug or RelWithDebInfo builds, and + * WARNING otherwise. + * + */ static itk::LoggerBase::PriorityLevelType GetLoggerLevel(); -- GitLab From bf4660bd853565768136c28c97bad982f93421b5 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 22 Feb 2018 16:36:10 +0100 Subject: [PATCH 309/567] ENH: Replace a few more traces --- .../ApplicationEngine/src/otbWrapperApplication.cxx | 5 ----- .../src/otbWrapperApplicationRegistry.cxx | 10 +--------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 4a7804d527..cc0790f406 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1656,11 +1656,6 @@ Application::IsParameterMissing(const std::string &key) const } level++; } - if (ret) - { - // the missing parameter is on an active branch : we need it - otbDebugMacro("MISSING : "<< key << " (Level "<< split.size()<<")"); - } } return ret; } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx index f022af0ddb..f68d3a3923 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx @@ -211,10 +211,6 @@ ApplicationRegistry::CreateApplication(const std::string& name, bool useFactory) appli = app; appli->Init(); } - else - { - otbMsgDevMacro( << "Error ApplicationRegistry factory did not return an Application: " << possibleApp->GetNameOfClass() << std::endl ); - } } } @@ -350,10 +346,6 @@ ApplicationRegistry::GetAvailableApplications(bool useFactory) std::string curName(app->GetName()); appSet.insert(curName); } - else - { - otbMsgDevMacro( << "Error ApplicationRegistry factory did not return an Application: " << (*i)->GetNameOfClass() << std::endl ); - } } } @@ -438,7 +430,7 @@ ApplicationRegistry::LoadApplicationFromPath(std::string path,std::string name) } else { - otbMsgDevMacro( << "Can't load library : " << path << std::endl ); + otbLogMacro(Warning,<< "Failed to load libraries from " << path << " while trying to create application "<<name ); } } return appli; -- GitLab From 8b01f6b66aff9e85a0f8091b99f08b23b8a8d963 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 22 Feb 2018 17:05:10 +0100 Subject: [PATCH 310/567] ENH: More logs cleanup --- .../OSSIMAdapters/src/otbImageKeywordlist.cxx | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx b/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx index 22aef9289e..0294d5f744 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx @@ -255,7 +255,6 @@ ReadGeometryFromImage(const std::string& filename, bool checkRpcTag) ->open(ossimFilename(filename.c_str()))); if (handler) { - otbMsgDevMacro(<< "OSSIM Open Image SUCCESS ! "); // Add ossimPlugins model ossimProjectionFactoryRegistry::instance()->registerFactory(ossimplugins::ossimPluginProjectionFactory::instance()); @@ -271,7 +270,6 @@ ReadGeometryFromImage(const std::string& filename, bool checkRpcTag) // if the handler has found a sensor model, copy the tags found if (hasMetaData && dynamic_cast<ossimSensorModel const*>(projection)) { - otbMsgDevMacro(<<"OSSIM sensor projection instantiated ! "); otb_kwl.SetKeywordlist(geom_kwl); // geom_kwl.print(std::cout); } @@ -315,16 +313,6 @@ ReadGeometryFromImage(const std::string& filename, bool checkRpcTag) // which uses ossimSensorModelFactory and ossimPluginProjectionFactory internally, // thus by-passing the need for a valid ossimImageHandler. - if (!hasMetaData) - { - otbMsgDevMacro(<< "OSSIM MetaData not present ! "); - } - else - { - otbMsgDevMacro(<< "OSSIM MetaData present ! "); - //otbMsgDevMacro(<< geom_kwl); - } - return otb_kwl; } -- GitLab From 9097c16bc4e5df9763bc0a0bab1b244690ef0902 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Thu, 22 Feb 2018 17:15:25 +0100 Subject: [PATCH 311/567] DOC: add that Pillow Python lib is a fork of PIL --- Documentation/Cookbook/rst/recipes/python.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/Cookbook/rst/recipes/python.rst b/Documentation/Cookbook/rst/recipes/python.rst index eaff6e537d..987a7830c7 100644 --- a/Documentation/Cookbook/rst/recipes/python.rst +++ b/Documentation/Cookbook/rst/recipes/python.rst @@ -71,7 +71,7 @@ Application.SetParameterString(...). The bridge between NumPy and OTB makes it easy to plug OTB into any image processing chain via Python code that uses GIS/Image processing tools such as GDAL, GRASS GIS, OSSIM that can deal with NumPy. -Below code reads an input image using Python pillow (PIL) and convert it to +Below code reads an input image using Python Pillow library (fork of PIL) and convert it to NumPy array. The NumPy array is used an input to the application via *SetImageFromNumpyArray(...)* method. The application used in this example is ExtractROI. After extracting a small area the output image is taken as NumPy @@ -248,7 +248,7 @@ If you want the get the state of parameter ``keywordlist``, a boolean, use: app.IsParameterEnabled("keywordlist") -To set this parameter ON / OFF, use the functions: +To set this parameter ON/OFF, use the functions: .. code-block:: python -- GitLab From 6168454ebeb518ebf3589c8a5cff91aca70f23e5 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 22 Feb 2018 17:44:16 +0100 Subject: [PATCH 312/567] BUG: beware of nullptr --- .../src/otbWrapperApplication.cxx | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 69df972b30..e93134628a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -363,6 +363,7 @@ void Application::AfterExecuteAndWriteOutputs() void Application::RegisterPipeline() { + std::cout<<"Registering Pipeline"<<std::endl; m_Filters.clear(); std::stack< itk::DataObject * > dataStack; std::set< itk::DataObject * > inputData; @@ -377,23 +378,26 @@ Application::RegisterPipeline() Parameter* param = GetParameterByKey(key); OutputImageParameter * outP = dynamic_cast<OutputImageParameter*>(param); itk::ImageBase<2> * outData = outP->GetValue(); - std::cout<<"one image in output"<<std::endl; - dataStack.push(outData); + if ( outData ) + dataStack.push(outData); } else if ( GetParameterType(key) == ParameterType_OutputVectorData ) { Parameter* param = GetParameterByKey(key); OutputVectorDataParameter * outP = dynamic_cast<OutputVectorDataParameter*>(param); Wrapper::VectorDataType * outData = outP->GetValue(); - dataStack.push(outData); + if ( outData ) + dataStack.push(outData); } else if ( GetParameterType(key) == ParameterType_InputImage ) { Parameter* param = GetParameterByKey(key); InputImageParameter * inP = dynamic_cast<InputImageParameter*>(param); itk::ImageBase<2> * inData = inP->GetPointer(); - inputData.insert(inData); + if ( inData ) + inputData.insert(inData); } + // need to take care of list object } // DFS std::set< itk::ProcessObject * > processSet; @@ -402,35 +406,27 @@ Application::RegisterPipeline() std::cout<<"one data is processed"<<std::endl; itk::DataObject * current = dataStack.top(); dataStack.pop(); - if ( inputData.find( current ) != inputData.end() ) + if ( inputData.count( current ) || !current ) continue; std::cout<<"not an input"<<std::endl; - if ( dynamic_cast<itk::ImageBase<2> * > ( current ) ) - { - itk::ImageBase<2> * image = dynamic_cast<itk::ImageBase<2> * > ( current ); - itk::ImageBase<2>::SizeType sizenull; - sizenull.Fill(0); - if ( image->GetLargestPossibleRegion() == image->GetBufferedRegion() && image->GetBufferedRegion().GetSize() != sizenull ) - continue; - } - std::cout<<"not empty"<<std::endl; itk::ProcessObject * process = (current->GetSource()).GetPointer(); - if ( processSet.find( process ) != processSet.end()) + if ( processSet.find( process ) != processSet.end() || !process ) continue; std::cout<<"add process to set"<<std::endl; processSet.insert( process ); std::vector< itk::DataObject::Pointer > inputs = process->GetInputs(); for ( auto it : inputs ) { - if ( inputData.find(it.GetPointer()) != inputData.end() ) + if ( inputData.count( it.GetPointer() ) ) continue; dataStack.push( it.GetPointer() ); } } - + // Convert the set into a vector + // Might not need it for ( auto it : processSet ) { - std::cout<<"one filter is registered"<<std::endl; + std::cout<<"one filter is registered : "<<it->GetNameOfClass()<<std::endl; m_Filters.push_back( it ); } } -- GitLab From 170eb99dd0200958a204b827bfc9f18482cfb30e Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 23 Feb 2018 08:56:58 +0100 Subject: [PATCH 313/567] ENH: prefer set to vector and take into account list parameter --- .../include/otbWrapperApplication.h | 3 +- .../src/otbWrapperApplication.cxx | 84 +++++++++++++------ 2 files changed, 60 insertions(+), 27 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index e5b6ea2dcf..29743f26dd 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -22,6 +22,7 @@ #define otbWrapperApplication_h #include <string> +#include <set> #include "otbWrapperTypes.h" #include "otbWrapperTags.h" #include "otbWrapperParameterGroup.h" @@ -845,7 +846,7 @@ public: } void RegisterPipeline(); - std::vector<itk::ProcessObject::Pointer> m_Filters; + std::set<itk::ProcessObject::Pointer> m_Filters; protected: /** Constructor */ diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index e93134628a..e3458e9fab 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -364,27 +364,25 @@ void Application::RegisterPipeline() { std::cout<<"Registering Pipeline"<<std::endl; - m_Filters.clear(); std::stack< itk::DataObject * > dataStack; std::set< itk::DataObject * > inputData; std::vector<std::string> paramList = GetParametersKeys(true); - for (std::vector<std::string>::const_iterator it = paramList.begin(); - it != paramList.end(); - ++it) + for ( key : paramList ) { - std::string key = *it; if ( GetParameterType(key) == ParameterType_OutputImage ) { Parameter* param = GetParameterByKey(key); - OutputImageParameter * outP = dynamic_cast<OutputImageParameter*>(param); - itk::ImageBase<2> * outData = outP->GetValue(); + OutputImageParameter * outP = + dynamic_cast< OutputImageParameter * >( param ); + itk::ImageBase< 2 > * outData = outP->GetValue(); if ( outData ) dataStack.push(outData); } else if ( GetParameterType(key) == ParameterType_OutputVectorData ) { Parameter* param = GetParameterByKey(key); - OutputVectorDataParameter * outP = dynamic_cast<OutputVectorDataParameter*>(param); + OutputVectorDataParameter * outP = + dynamic_cast< OutputVectorDataParameter * >( param ); Wrapper::VectorDataType * outData = outP->GetValue(); if ( outData ) dataStack.push(outData); @@ -392,28 +390,70 @@ Application::RegisterPipeline() else if ( GetParameterType(key) == ParameterType_InputImage ) { Parameter* param = GetParameterByKey(key); - InputImageParameter * inP = dynamic_cast<InputImageParameter*>(param); - itk::ImageBase<2> * inData = inP->GetPointer(); - if ( inData ) + InputImageParameter * inP = + dynamic_cast< InputImageParameter * >( param ); + itk::ImageBase< 2 > * inData = inP->GetPointer(); + if ( inData && !inputData.count(inData) ) + inputData.insert(inData); + } + else if ( GetParameterType(key) == ParameterType_InputImageList ) + { + Parameter * param = GetParameterByKey(key); + InputImageListParameter * inP = + dynamic_cast< InputImageListParameter * > ( param ); + const FloatVectorImageListType * list = inP->GetImageList(); + auto it = list->Begin(); + while ( it != list->End() ) + { + FloatVectorImageType * inData = it.Get().GetPointer(); + if ( inData && !inputData.count(inData) ) + inputData.insert(inData); + ++it; + } + } + else if ( GetParameterType(key) == ParameterType_InputVectorData ) + { + Parameter * param = GetParameterByKey(key); + InputVectorDataParameter * inP = + dynamic_cast< InputVectorDataParameter * > ( param ); + VectorDataType * inData = inP->GetVectorData(); + if ( inData && !inputData.count(inData) ) inputData.insert(inData); } - // need to take care of list object + else if ( GetParameterType(key) == ParameterType_InputVectorDataList ) + { + Parameter * param = GetParameterByKey(key); + InputVectorDataListParameter * inP = + dynamic_cast< InputVectorDataListParameter * > ( param ); + VectorDataListType * list = inP->GetVectorDataList(); + auto it = list->Begin(); + while ( it != list->End() ) + { + VectorDataType * inData = it.Get().GetPointer(); + if ( inData && !inputData.count(inData) ) + inputData.insert(inData); + ++it; + } + } + else + continue; } + // DFS std::set< itk::ProcessObject * > processSet; while ( !dataStack.empty() ) { - std::cout<<"one data is processed"<<std::endl; + std::cout<<"one node (data) is processed"<<std::endl; itk::DataObject * current = dataStack.top(); dataStack.pop(); if ( inputData.count( current ) || !current ) continue; - std::cout<<"not an input"<<std::endl; + std::cout<<"it is not an input"<<std::endl; itk::ProcessObject * process = (current->GetSource()).GetPointer(); - if ( processSet.find( process ) != processSet.end() || !process ) + if ( m_Filters.find( process ) != m_Filters.end() || !process ) continue; - std::cout<<"add process to set"<<std::endl; - processSet.insert( process ); + std::cout<<"add process to set : "<<process->GetNameOfClass()<<std::endl; + m_Filters.insert( process ); std::vector< itk::DataObject::Pointer > inputs = process->GetInputs(); for ( auto it : inputs ) { @@ -422,13 +462,6 @@ Application::RegisterPipeline() dataStack.push( it.GetPointer() ); } } - // Convert the set into a vector - // Might not need it - for ( auto it : processSet ) - { - std::cout<<"one filter is registered : "<<it->GetNameOfClass()<<std::endl; - m_Filters.push_back( it ); - } } int Application::Execute() @@ -578,7 +611,6 @@ int Application::ExecuteAndWriteOutput() outputParam->Write(); } } - //xml writer parameter else if (m_HaveOutXML && GetParameterType(key) == ParameterType_OutputProcessXML && IsParameterEnabled(key) && HasValue(key) ) @@ -595,7 +627,7 @@ int Application::ExecuteAndWriteOutput() this->AfterExecuteAndWriteOutputs(); m_Chrono.Stop(); - + m_Filters.clear(); return status; } -- GitLab From 1d5ae38990bc188ca0cfef16dd5cb15ecef9925c Mon Sep 17 00:00:00 2001 From: Yannick TANGUY <yannick.tanguy@cnes.fr> Date: Fri, 23 Feb 2018 10:41:21 +0100 Subject: [PATCH 314/567] Update PSC.md after PSC meeting (2018-02-22) : new rules to accept Merge Request --- PSC.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/PSC.md b/PSC.md index c798cec66e..d3bcd96a78 100644 --- a/PSC.md +++ b/PSC.md @@ -122,7 +122,7 @@ decision-making, or in case of disputes over voting. A vote of the PSC is required in the following cases: -1. Merge Request +1. Some Merge Request (see below) 2. Addition or removal of PSC members (including the selection of a new Chair) 3. Release process @@ -134,22 +134,28 @@ In addition, a vote can be summoned for: #### Merge Request -A Merge Request describes a change in Orfeo ToolBox code, API, -infrastructure or processes that need to be submitted to the PSC vote: +All changes in Orfeo ToolBox (code, API, infrastructure or processes) must be +handle with a Merge Request : - Anything that could cause backward compatibility issues, - Adding substantial amounts of new code, - Changing inter-subsystem APIs, or objects, +- Any change in the code or in the documentation. -It should describe : +Merge Request can be linked to an issue and should describe : 1. What changes will be made and why they will make a better Orfeo ToolBox 2. When will those changes be available (target release or date) 3. Who will be developing the proposed changes -Those elements can be provided in an email to the developer list or on a -git hosted platform (GitLab, GitHub, etc.). +Those elements must be provided to a git hosted platform (GitLab, GitHub, etc.). +Merge request can be discussed on the developer list or directly on GitLab. + +Votes are necessary to accept Merge Request : +- Core developers members can vote +- At least two +1 are necessary +- PSC members have veto #### Add or remove PSC members -- GitLab From e66617e9bca1d387944f89a3e3f88b8604608151 Mon Sep 17 00:00:00 2001 From: Yannick TANGUY <yannick.tanguy@cnes.fr> Date: Fri, 23 Feb 2018 10:47:02 +0100 Subject: [PATCH 315/567] Update CONTRIBUTING.md after PSC meeting (2018-02-22) --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bc96c95933..f2b219ad78 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,7 +90,7 @@ template. The merge request will then be discussed by the community and the core OTB team. * Merge requests can not be merged until all discussions have been resolved (this is enforced by GitLab) -* Merge requests **must receive at least 2 positives votes from PSC members** before being merged +* Merge requests **must receive at least 2 positives votes from core developers** before being merged * The merger is responsible for checking that the branch is up-to-date with develop * Merge requests can be merged by anyone (not just PSC or RM) with push access to develop * Merge requests can be merged once the dashboard is proven green for this branch -- GitLab From 0b89b60c7a47d4f740ea68a285a8a9179f1755a5 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 23 Feb 2018 15:52:55 +0100 Subject: [PATCH 316/567] ENH: adding an ugly objectlistinterface class and method... --- .../Core/ObjectList/include/otbObjectList.h | 8 +++- .../Core/ObjectList/include/otbObjectList.txx | 10 +++++ .../include/otbObjectListInterface.h | 45 +++++++++++++++++++ .../src/otbWrapperApplication.cxx | 14 ++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 Modules/Core/ObjectList/include/otbObjectListInterface.h diff --git a/Modules/Core/ObjectList/include/otbObjectList.h b/Modules/Core/ObjectList/include/otbObjectList.h index b9db494bec..dcd1182b56 100644 --- a/Modules/Core/ObjectList/include/otbObjectList.h +++ b/Modules/Core/ObjectList/include/otbObjectList.h @@ -23,6 +23,7 @@ #include <vector> #include "itkDataObject.h" +#include "otbObjectListInterface.h" #include "itkObjectFactory.h" namespace otb @@ -36,7 +37,7 @@ namespace otb * \ingroup OTBObjectList */ template <class TObject> -class ITK_EXPORT ObjectList : public itk::DataObject +class ITK_EXPORT ObjectList : public itk::DataObject , public ObjectListInterface { public: /** Standard typedefs */ @@ -99,6 +100,11 @@ public: * \return The pointer to the nth element of the list. */ ObjectPointerType GetNthElement(unsigned int index) const; + /** + * Get the nth element of the list as a DataObject *. + * \param index The index of the object to get. + */ + Superclass * GetNthDataObject(unsigned int index) const; /** * Return the first element of the list. * \return The first element of the list. diff --git a/Modules/Core/ObjectList/include/otbObjectList.txx b/Modules/Core/ObjectList/include/otbObjectList.txx index 26044b1432..121dfd90b0 100644 --- a/Modules/Core/ObjectList/include/otbObjectList.txx +++ b/Modules/Core/ObjectList/include/otbObjectList.txx @@ -162,6 +162,16 @@ ObjectList<TObject> } return m_InternalContainer[index]; } + +template <class TObject> +typename ObjectList<TObject>::Superclass * +ObjectList<TObject> +::GetNthDataObject(unsigned int index) const +{ + ObjectType * object = GetNthElement(index).GetPointer(); + return dynamic_cast< Superclass * > ( object ); +} + /** * Return the first element of the list. * \return The first element of the list. diff --git a/Modules/Core/ObjectList/include/otbObjectListInterface.h b/Modules/Core/ObjectList/include/otbObjectListInterface.h new file mode 100644 index 0000000000..a99df955c6 --- /dev/null +++ b/Modules/Core/ObjectList/include/otbObjectListInterface.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbObjectListInterface_h +#define otbObjectListInterface_h + +#include "itkDataObject.h" + +namespace otb +{ + +class ObjectListInterface +{ + +public: + + ObjectListInterface() {}; + virtual ~ObjectListInterface(){}; + + virtual itk::DataObject * GetNthDataObject(unsigned int index) const = 0; + + virtual std::size_t Size(void) const = 0; + +}; + +} // end of otb namespace + +#endif diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index e3458e9fab..dbf71f5647 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -449,6 +449,20 @@ Application::RegisterPipeline() if ( inputData.count( current ) || !current ) continue; std::cout<<"it is not an input"<<std::endl; + if ( dynamic_cast< ObjectListInterface *> (current) ) + { + ObjectListInterface * list = + dynamic_cast< ObjectListInterface *> (current); + int length = list->Size(); + for ( int i = 0 ; i < length ; i++ ) + { + itk::DataObject * newData = list->GetNthDataObject(i); + if ( inputData.count( current ) || !current ) + continue; + dataStack.push( newData ); + } + continue; + } itk::ProcessObject * process = (current->GetSource()).GetPointer(); if ( m_Filters.find( process ) != m_Filters.end() || !process ) continue; -- GitLab From c2e43d3325defbfc2c6970895c5bf5316f548100 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 23 Feb 2018 16:16:59 +0100 Subject: [PATCH 317/567] BUG: check for value before looking for pointer in input parameter --- .../ApplicationEngine/src/otbWrapperApplication.cxx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index dbf71f5647..4a0eaa82d9 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -383,7 +383,7 @@ Application::RegisterPipeline() Parameter* param = GetParameterByKey(key); OutputVectorDataParameter * outP = dynamic_cast< OutputVectorDataParameter * >( param ); - Wrapper::VectorDataType * outData = outP->GetValue(); + VectorDataType * outData = outP->GetValue(); if ( outData ) dataStack.push(outData); } @@ -392,6 +392,8 @@ Application::RegisterPipeline() Parameter* param = GetParameterByKey(key); InputImageParameter * inP = dynamic_cast< InputImageParameter * >( param ); + if ( !inP->HasValue() ) + continue; itk::ImageBase< 2 > * inData = inP->GetPointer(); if ( inData && !inputData.count(inData) ) inputData.insert(inData); @@ -401,6 +403,8 @@ Application::RegisterPipeline() Parameter * param = GetParameterByKey(key); InputImageListParameter * inP = dynamic_cast< InputImageListParameter * > ( param ); + if ( !inP->HasValue() ) + continue; const FloatVectorImageListType * list = inP->GetImageList(); auto it = list->Begin(); while ( it != list->End() ) @@ -416,6 +420,9 @@ Application::RegisterPipeline() Parameter * param = GetParameterByKey(key); InputVectorDataParameter * inP = dynamic_cast< InputVectorDataParameter * > ( param ); + std::cout<<"Getting data from outputvectordataparameter"<<std::endl; + if ( !inP->HasValue() ) + continue; VectorDataType * inData = inP->GetVectorData(); if ( inData && !inputData.count(inData) ) inputData.insert(inData); @@ -425,6 +432,8 @@ Application::RegisterPipeline() Parameter * param = GetParameterByKey(key); InputVectorDataListParameter * inP = dynamic_cast< InputVectorDataListParameter * > ( param ); + if ( !inP->HasValue() ) + continue; VectorDataListType * list = inP->GetVectorDataList(); auto it = list->Begin(); while ( it != list->End() ) @@ -438,7 +447,7 @@ Application::RegisterPipeline() else continue; } - + std::cout<<"Beginning DFS"<<std::endl; // DFS std::set< itk::ProcessObject * > processSet; while ( !dataStack.empty() ) -- GitLab From ca3cb17975ede38d85ab966c014ad9abd5997139 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Fri, 23 Feb 2018 16:24:17 +0100 Subject: [PATCH 318/567] ADD: stub for DataAugmentation application --- .../AppClassification/app/CMakeLists.txt | 5 + .../app/otbSampleAugmentation.cxx | 174 ++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx diff --git a/Modules/Applications/AppClassification/app/CMakeLists.txt b/Modules/Applications/AppClassification/app/CMakeLists.txt index 3e1dbd85f5..d34c3842d0 100644 --- a/Modules/Applications/AppClassification/app/CMakeLists.txt +++ b/Modules/Applications/AppClassification/app/CMakeLists.txt @@ -125,5 +125,10 @@ otb_create_application( SOURCES otbVectorClassifier.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES}) +otb_create_application( + NAME SampleAugmentation + SOURCES otbSampleAugmentation.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + # Mantis-1427 : temporary fix add_dependencies(${otb-module}-all otbapp_ImageEnvelope) diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx new file mode 100644 index 0000000000..cc2ebfb6dd --- /dev/null +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" +#include "otbOGRDataSourceWrapper.h" + +namespace otb +{ +namespace Wrapper +{ + +class SampleAugmentation : public Application +{ +public: + /** Standard class typedefs. */ + typedef SampleAugmentation Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(SampleAugmentation, otb::Application); + + /** Filters typedef */ + +private: + SampleAugmentation() {} + + void DoInit() + { + SetName("SampleAugmentation"); + SetDescription("Generates synthetic samples from a sample data file."); + + // Documentation + SetDocName("Sample Extraction"); + SetDocLongDescription("The application takes a sample data file as " + "generated by the SampleExtraction application and " + "generates synthetic samples to increase the number of " + "available samples."); + SetDocLimitations("None"); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso(" "); + + AddDocTag(Tags::Learning); + + AddParameter(ParameterType_InputFilename, "vec", "Input samples"); + SetParameterDescription("vec","Vector data file containing samples (OGR format)"); + + AddParameter(ParameterType_OutputFilename, "out", "Output samples"); + SetParameterDescription("out","Output vector data file storing new samples" + "(OGR format). If not given, the input vector data file is updated"); + MandatoryOff("out"); + + AddParameter(ParameterType_ListView, "field", "Field Name"); + SetParameterDescription("field","Name of the field carrying the class name in the input vectors."); + SetListViewSingleSelectionMode("field",true); + + AddParameter(ParameterType_Int, "layer", "Layer Index"); + SetParameterDescription("layer", "Layer index to read in the input vector file."); + MandatoryOff("layer"); + SetDefaultParameterInt("layer",0); + + AddParameter(ParameterType_Int, "label", "Label of the class to be augmented"); + SetParameterDescription("label", "Label of the class of the input file for which " + "new samples will be generated."); + SetDefaultParameterInt("label",1); + + AddParameter(ParameterType_Int, "samples", "Number of generated samples"); + SetParameterDescription("samples", "Number of synthetic samples that will " + "be generated."); + SetDefaultParameterInt("samples",100); + + AddRAMParameter(); + + // Doc example parameter settings + SetDocExampleParameterValue("vec", "samples.sqlite"); + SetDocExampleParameterValue("field", "class"); + SetDocExampleParameterValue("label", "3"); + SetDocExampleParameterValue("samples", "100"); + SetDocExampleParameterValue("out","augmented_samples.sqlite"); + + SetOfficialDocLink(); + } + + void DoUpdateParameters() + { + if ( HasValue("vec") ) + { + std::string vectorFile = GetParameterString("vec"); + ogr::DataSource::Pointer ogrDS = + ogr::DataSource::New(vectorFile, ogr::DataSource::Modes::Read); + ogr::Layer layer = ogrDS->GetLayer(this->GetParameterInt("layer")); + ogr::Feature feature = layer.ogr().GetNextFeature(); + + ClearChoices("field"); + + for(int iField=0; iField<feature.ogr().GetFieldCount(); iField++) + { + std::string key, item = feature.ogr().GetFieldDefnRef(iField)->GetNameRef(); + key = item; + std::string::iterator end = std::remove_if(key.begin(),key.end(), + [](auto c){return !std::isalnum(c);}); + std::transform(key.begin(), end, key.begin(), tolower); + + OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType(); + + if(fieldType == OFTString || fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType)) + { + std::string tmpKey="field."+key.substr(0, end - key.begin()); + AddChoice(tmpKey,item); + } + } + } + } + + void DoExecute() + { + ogr::DataSource::Pointer vectors; + ogr::DataSource::Pointer output; + if (IsParameterEnabled("out") && HasValue("out")) + { + vectors = ogr::DataSource::New(this->GetParameterString("vec")); + output = ogr::DataSource::New(this->GetParameterString("out"), + ogr::DataSource::Modes::Overwrite); + } + else + { + // Update mode + vectors = ogr::DataSource::New(this->GetParameterString("vec"), + ogr::DataSource::Modes::Update_LayerUpdate); + output = vectors; + } + + // Retrieve the field name + std::vector<int> selectedCFieldIdx = GetSelectedItems("field"); + + if(selectedCFieldIdx.empty()) + { + otbAppLogFATAL(<<"No field has been selected for data labelling!"); + } + + std::vector<std::string> cFieldNames = GetChoiceNames("field"); + std::string fieldName = cFieldNames[selectedCFieldIdx.front()]; + + + output->SyncToDisk(); + } + +}; + +} // end of namespace Wrapper +} // end of namespace otb + +OTB_APPLICATION_EXPORT(otb::Wrapper::SampleAugmentation) -- GitLab From 6ce027b144c5b166a8dfbf5fa1ae9b785b7aede1 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 23 Feb 2018 16:47:21 +0100 Subject: [PATCH 319/567] REFAC: add register pipeline methode on some application in imageutils module --- .../AppImageUtils/app/otbCompareImages.cxx | 15 +++++++------ .../app/otbConcatenateImages.cxx | 21 +++++++------------ .../AppImageUtils/app/otbExtractROI.cxx | 6 ++---- .../AppImageUtils/app/otbQuicklook.cxx | 10 ++++----- .../AppImageUtils/app/otbRescale.cxx | 11 +++++----- .../AppImageUtils/app/otbSplitImage.cxx | 5 ++--- .../AppImageUtils/app/otbTileFusion.cxx | 5 ++--- 7 files changed, 30 insertions(+), 43 deletions(-) diff --git a/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx b/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx index 2d0d54c83c..4199105b3e 100644 --- a/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx +++ b/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx @@ -172,9 +172,12 @@ private: void DoExecute() ITK_OVERRIDE { // Init filters - m_ExtractRefFilter = ExtractROIMonoFilterType::New(); - m_ExtractMeasFilter = ExtractROIMonoFilterType::New(); - m_CompareFilter = StreamingCompareImageFilterType::New(); + ExtractROIMonoFilterType::Pointer m_ExtractRefFilter = + ExtractROIMonoFilterType::New(); + ExtractROIMonoFilterType::Pointer m_ExtractMeasFilter = + ExtractROIMonoFilterType::New(); + StreamingCompareImageFilterType::Pointer m_CompareFilter = + StreamingCompareImageFilterType::New(); // Get input image pointers FloatVectorImageType::Pointer refIm = this->GetParameterImage("ref.in"); @@ -229,12 +232,8 @@ private: SetParameterFloat( "mae",m_CompareFilter->GetMAE() , false); SetParameterFloat( "psnr",m_CompareFilter->GetPSNR() , false); SetParameterFloat( "count",m_CompareFilter->GetDiffCount() , false); + RegisterPipeline(); } - - - ExtractROIMonoFilterType::Pointer m_ExtractRefFilter; - ExtractROIMonoFilterType::Pointer m_ExtractMeasFilter; - StreamingCompareImageFilterType::Pointer m_CompareFilter; }; } diff --git a/Modules/Applications/AppImageUtils/app/otbConcatenateImages.cxx b/Modules/Applications/AppImageUtils/app/otbConcatenateImages.cxx index 185872b828..171166b072 100644 --- a/Modules/Applications/AppImageUtils/app/otbConcatenateImages.cxx +++ b/Modules/Applications/AppImageUtils/app/otbConcatenateImages.cxx @@ -72,10 +72,6 @@ private: AddDocTag("Concatenation"); AddDocTag("Multi-channel"); - m_Concatener = ListConcatenerFilterType::New(); - m_ExtractorList = ExtractROIFilterListType::New(); - m_ImageList = ImageListType::New(); - AddParameter(ParameterType_InputImageList, "il", "Input images list"); SetParameterDescription("il", "The list of images to concatenate, must have the same size."); @@ -94,15 +90,16 @@ private: void DoUpdateParameters() ITK_OVERRIDE { // Nothing to do here for the parameters : all are independent - - // Reinitialize the object - m_Concatener = ListConcatenerFilterType::New(); - m_ImageList = ImageListType::New(); - m_ExtractorList = ExtractROIFilterListType::New(); } void DoExecute() ITK_OVERRIDE { + ListConcatenerFilterType::Pointer m_Concatener = + ListConcatenerFilterType::New(); + ExtractROIFilterListType::Pointer m_ExtractorList = + ExtractROIFilterListType::New(); + ImageListType::Pointer m_ImageList = + ImageListType::New(); // Get the input image list FloatVectorImageListType::Pointer inList = this->GetParameterImageList("il"); @@ -140,12 +137,8 @@ private: m_Concatener->SetInput( m_ImageList ); SetParameterOutputImage("out", m_Concatener->GetOutput()); + RegisterPipeline(); } - - - ListConcatenerFilterType::Pointer m_Concatener; - ExtractROIFilterListType::Pointer m_ExtractorList; - ImageListType::Pointer m_ImageList; }; } diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index bd6a8d1583..0f20b17664 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -828,7 +828,7 @@ private: this->CropRegionOfInterest(); - m_ExtractROIFilter = ExtractROIFilterType::New(); + ExtractROIFilterType::Pointer m_ExtractROIFilter = ExtractROIFilterType::New(); m_ExtractROIFilter->SetInput(inImage); m_ExtractROIFilter->SetStartX(GetParameterInt("startx")); m_ExtractROIFilter->SetStartY(GetParameterInt("starty")); @@ -841,10 +841,8 @@ private: } SetParameterOutputImage("out", m_ExtractROIFilter->GetOutput()); + RegisterPipeline(); } - - ExtractROIFilterType::Pointer m_ExtractROIFilter; - }; } diff --git a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx index dd7134c620..154e2dee7f 100644 --- a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx +++ b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx @@ -202,8 +202,10 @@ bool CropRegionOfInterest() { InputImageType::Pointer inImage = GetParameterImage("in"); - m_ExtractROIFilter = ExtractROIFilterType::New(); - m_ResamplingFilter = ShrinkImageFilterType::New(); + ExtractROIFilterType::Pointer m_ExtractROIFilter = + ExtractROIFilterType::New(); + ShrinkImageFilterType::Pointer m_ResamplingFilter = + ShrinkImageFilterType::New(); // The image on which the quicklook will be generated // Will eventually be the m_ExtractROIFilter output @@ -277,11 +279,9 @@ bool CropRegionOfInterest() m_ResamplingFilter->Update(); SetParameterOutputImage("out", m_ResamplingFilter->GetOutput()); + RegisterPipeline(); } - ExtractROIFilterType::Pointer m_ExtractROIFilter; - ShrinkImageFilterType::Pointer m_ResamplingFilter; - }; } diff --git a/Modules/Applications/AppImageUtils/app/otbRescale.cxx b/Modules/Applications/AppImageUtils/app/otbRescale.cxx index f5c08c80a2..e9f7f2a58d 100644 --- a/Modules/Applications/AppImageUtils/app/otbRescale.cxx +++ b/Modules/Applications/AppImageUtils/app/otbRescale.cxx @@ -100,8 +100,8 @@ private: FloatVectorImageType::Pointer inImage = GetParameterImage("in"); otbAppLogDEBUG( << "Starting Min/Max computation" ) - - m_MinMaxFilter = MinMaxFilterType::New(); + + MinMaxFilterType::Pointer m_MinMaxFilter = MinMaxFilterType::New(); m_MinMaxFilter->SetInput( inImage ); m_MinMaxFilter->GetStreamer()->SetAutomaticAdaptativeStreaming(GetParameterInt("ram")); @@ -113,7 +113,8 @@ private: FloatVectorImageType::PixelType inMin, inMax; - m_RescaleFilter = RescaleImageFilterType::New(); + RescaleImageFilterType::Pointer m_RescaleFilter = + RescaleImageFilterType::New(); m_RescaleFilter->SetInput( inImage ); m_RescaleFilter->SetAutomaticInputMinMaxComputation(false); m_RescaleFilter->SetInputMinimum( m_MinMaxFilter->GetMinimum() ); @@ -130,10 +131,8 @@ private: m_RescaleFilter->UpdateOutputInformation(); SetParameterOutputImage("out", m_RescaleFilter->GetOutput()); + RegisterPipeline(); } - - RescaleImageFilterType::Pointer m_RescaleFilter; - MinMaxFilterType::Pointer m_MinMaxFilter; }; } diff --git a/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx b/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx index e23eaa57eb..cda99e6618 100644 --- a/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx +++ b/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx @@ -103,7 +103,7 @@ private: ext = itksys::SystemTools::GetFilenameExtension(ofname); // Set the extract filter input image - m_Filter = FilterType::New(); + FilterType::Pointer m_Filter = FilterType::New(); m_Filter->SetInput(inImage); for (unsigned int i = 0; i < inImage->GetNumberOfComponentsPerPixel(); ++i) @@ -140,9 +140,8 @@ private: // Disable the output Image parameter to avoid writing // the last image (Application::ExecuteAndWriteOutput method) DisableParameter("out"); + RegisterPipeline(); } - - FilterType::Pointer m_Filter; }; } } diff --git a/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx b/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx index 5dd80bc10e..0b6065b220 100644 --- a/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx +++ b/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx @@ -95,7 +95,7 @@ private: itkExceptionMacro("No input Image set..."); } - m_FusionFilter = TileFilterType::New(); + TileFilterType::Pointer m_FusionFilter = TileFilterType::New(); TileFilterType::SizeType layout; layout[0] = this->GetParameterInt("cols"); @@ -108,10 +108,9 @@ private: } SetParameterOutputImage("out", m_FusionFilter->GetOutput()); + RegisterPipeline(); } - TileFilterType::Pointer m_FusionFilter; - }; } -- GitLab From a8bb2a9290e9f1e74052066ac5b86840e6102ed3 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 23 Feb 2018 16:57:18 +0100 Subject: [PATCH 320/567] ENH: register pipeline POC on composite application --- .../AppSegmentation/app/otbLSMSSegmentation.cxx | 16 ++++++++++------ .../app/otbMeanShiftSmoothing.cxx | 5 ++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx index 93694cc420..fc9649a03a 100644 --- a/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx @@ -88,13 +88,14 @@ public: LabelImageType, AffineFunctorType> LabelShiftFilterType; - LSMSSegmentation(): m_FinalReader(),m_ImportGeoInformationFilter(),m_FilesToRemoveAfterExecute(),m_TmpDirCleanup(false){} + LSMSSegmentation(): //m_FinalReader(),m_ImportGeoInformationFilter(), + m_FilesToRemoveAfterExecute(),m_TmpDirCleanup(false){} ~LSMSSegmentation() ITK_OVERRIDE{} private: - LabelImageReaderType::Pointer m_FinalReader; - ImportGeoInformationImageFilterType::Pointer m_ImportGeoInformationFilter; + // LabelImageReaderType::Pointer m_FinalReader; + // ImportGeoInformationImageFilterType::Pointer m_ImportGeoInformationFilter; std::vector<std::string> m_FilesToRemoveAfterExecute; bool m_TmpDirCleanup; @@ -709,20 +710,23 @@ private: otbAppLogINFO(<<"Elapsed time: "<<(double)(toc - tic) / CLOCKS_PER_SEC<<" seconds"); // Final writing - m_FinalReader = LabelImageReaderType::New(); + LabelImageReaderType::Pointer m_FinalReader = LabelImageReaderType::New(); m_FinalReader->SetFileName(vrtfile); - m_ImportGeoInformationFilter = ImportGeoInformationImageFilterType::New(); + ImportGeoInformationImageFilterType::Pointer + m_ImportGeoInformationFilter = + ImportGeoInformationImageFilterType::New(); m_ImportGeoInformationFilter->SetInput(m_FinalReader->GetOutput()); m_ImportGeoInformationFilter->SetSource(imageIn); SetParameterOutputImage("out",m_ImportGeoInformationFilter->GetOutput()); + RegisterPipeline(); } void AfterExecuteAndWriteOutputs() ITK_OVERRIDE { // Release input files - m_FinalReader = ITK_NULLPTR; + // m_FinalReader = ITK_NULLPTR; if(IsParameterEnabled("cleanup")) { diff --git a/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx b/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx index 8f63bf13ef..ffe53dd9b1 100644 --- a/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx +++ b/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx @@ -183,7 +183,7 @@ private: { FloatVectorImageType* input = GetParameterImage("in"); - m_Filter = MSFilterType::New(); + MSFilterType::Pointer m_Filter = MSFilterType::New(); m_Filter->SetInput(input); @@ -215,10 +215,9 @@ private: { otbAppLogINFO(<<"Mode Search is disabled." << std::endl); } + RegisterPipeline(); } - MSFilterType::Pointer m_Filter; - }; -- GitLab From d1216adb7ba445b3893c4c58a6d32fbce330af33 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 23 Feb 2018 18:53:56 +0100 Subject: [PATCH 321/567] ENH: update SWIG interface for new services --- Modules/Wrappers/SWIG/src/otbApplication.i | 223 +++++++++++++++++- .../SWIG/src/otbWrapperSWIGIncludes.h | 6 + 2 files changed, 220 insertions(+), 9 deletions(-) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index d945d52af4..e227a0f37f 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -21,7 +21,7 @@ %module otbApplication - %{ +%{ #include "itkBase.includes" #include "otbWrapperSWIGIncludes.h" #include <string> // std::string @@ -37,6 +37,8 @@ %include "itkMacro.i" %include "itkBase.i" +%include "std_map.i" + #if OTB_SWIGNUMPY %include "numpy.i" @@ -142,6 +144,203 @@ namespace Wrapper } +namespace std { +%template(keywordlist) map<string,string>; + +#if SWIGPYTHON +%extend map<string,string> +{ + %pythoncode + { + def __str__(self): + ret = "{" + for key in self: + ret += str(key)+":"+str(self[key])+", " + if len(ret) == 1: + ret += ", " + return ret[:-2]+"}" + } +}; +#endif +} // end of namespace std + +class itkSize +{ +public: + itkSize(); + virtual ~itkSize(); + void Fill(unsigned long val); + unsigned long GetElement(unsigned long element) const; + void SetElement(unsigned long element, unsigned long val); + static unsigned int GetSizeDimension(); +}; + +class itkIndex +{ +public: + itkIndex(); + virtual ~itkIndex(); + void Fill(signed long val); + signed long GetElement(unsigned long element) const; + void SetElement(unsigned long element, signed long val); + static unsigned int GetIndexDimension(); +}; + +class itkRegion +{ +public: + itkRegion(); + itkRegion(const itkIndex &index, const itkSize &size); + virtual ~itkRegion(); + void SetIndex(const itkIndex &index); + void SetSize(const itkSize &size); + void SetUpperIndex(const itkIndex &idx); + itkIndex GetUpperIndex() const; + const itkIndex & GetIndex() const; + const itkSize & GetSize() const; + bool IsInside(const itkIndex & index) const; + void SetSize(unsigned int i, unsigned long val); + unsigned long GetSize(unsigned int i) const; + void SetIndex(unsigned int i, signed long val); + signed long GetIndex(unsigned int i) const; +private: + itkIndex m_Index; + itkSize m_Size; +}; + +namespace itk +{ +template <typename TValue, unsigned int VLength = 3> +class FixedArray +{ +public: + FixedArray(); + virtual ~FixedArray(); + unsigned int Size(); + void SetElement(unsigned short idx, const TValue &val); + const TValue & GetElement(unsigned short idx); +}; + +%template(itkFixedArrayD2) FixedArray<double,2>; +%template(itkFixedArrayF2) FixedArray<float,2>; + +template <typename TValue, unsigned int NDim = 3> +class Vector: public FixedArray<TValue,NDim> +{ +public: + Vector(); + virtual ~Vector(); + typedef NumericTraits<TValue>::RealType RealValueType; + RealValueType GetNorm() const; + RealValueType GetSquaredNorm() const; + RealValueType Normalize(); +}; + +%template(itkVectorD2) Vector<double,2>; +%template(itkVectorF2) Vector<float,2>; + +template <typename TCoord, unsigned int NDim = 3> +class Point: public FixedArray<TCoord,NDim> +{ +public: + Point(); + virtual ~Point(); +}; + +%template(itkPointD2) Point<double,2>; +%template(itkPointF2) Point<float,2>; + + +} // end of namespace itk + +#if SWIGPYTHON + +%define WRAP_AS_LIST(N) + %pythoncode + { + def __str__(self): + ret = "[" + for index in range(N): + ret += str(self.GetElement(index))+"," + ret = ret[:-1] + "]" + return ret + def __len__(self): + return N + def __getitem__(self,idx): + if idx >= N or idx < 0: + raise IndexError('Index outside [0,'+str(N-1)+']') + return self.GetElement(idx) + def __setitem__(self,idx,val): + if idx >= N or idx < 0: + raise IndexError('Index outside [0,'+str(N-1)+']') + return self.SetElement(idx,val) + } +%enddef + +%extend itkSize +{ + WRAP_AS_LIST(2) +}; +%extend itkIndex +{ + WRAP_AS_LIST(2) +}; + +namespace itk +{ +%extend FixedArray<double,2> +{ + WRAP_AS_LIST(2) +}; +%extend FixedArray<float,2> +{ + WRAP_AS_LIST(2) +}; +%extend Vector<double,2> +{ + WRAP_AS_LIST(2) +}; +%extend Vector<float,2> +{ + WRAP_AS_LIST(2) +}; +%extend Point<double,2> +{ + WRAP_AS_LIST(2) +}; +%extend Point<float,2> +{ + WRAP_AS_LIST(2) +}; +} // end of namespace itk + +%extend itkRegion +{ + %pythoncode + { + def __str__(self): + return "{index:"+str(self.GetIndex())+", size:"+str(self.GetSize())+"}" + def __len__(self): + return 2 + def __getitem__(self,key): + if key == 'index': + return self.GetIndex() + elif key == 'size': + return self.GetSize() + else: + raise IndexError('Key not in ["index","size"]') + def __setitem__(self,key,val): + if key == 'index': + self.SetIndex(val) + elif key == 'size': + self.SetSize(val) + else: + raise IndexError('Key not in ["index","size"]') + + } +} +#endif + class Application: public itkObject { public: @@ -199,18 +398,25 @@ public: std::vector<std::string> GetParameterStringList(std::string parameter); std::string GetParameterAsString(std::string paramKey); - InputImageParameter::ImageBaseType * GetParameterOutputImage(std::string parameter); - void SetParameterInputImage(std::string parameter, InputImageParameter::ImageBaseType * inputImage); - ComplexInputImageParameter::ImageBaseType * GetParameterComplexOutputImage(std::string parameter); - void SetParameterComplexInputImage(std::string parameter, ComplexInputImageParameter::ImageBaseType * inputImage); - void AddImageToParameterInputImageList(std::string parameter,InputImageParameter::ImageBaseType * img); + ImageBaseType * GetParameterOutputImage(std::string parameter); + void SetParameterInputImage(std::string parameter, ImageBaseType * inputImage); + ImageBaseType * GetParameterComplexOutputImage(std::string parameter); + void SetParameterComplexInputImage(std::string parameter, ImageBaseType * inputImage); + void AddImageToParameterInputImageList(std::string parameter,ImageBaseType * img); void AddParameterStringList(std::string parameter,const std::string & str); - void SetNthParameterInputImageList(std::string parameter, const unsigned int &id, InputImageParameter::ImageBaseType * img); + void SetNthParameterInputImageList(std::string parameter, const unsigned int &id, ImageBaseType * img); void SetNthParameterStringList(std::string parameter, const unsigned int &id, const std::string& str); void ClearParameterInputImageList(std::string parameter); unsigned int GetNumberOfElementsInParameterInputImageList(std::string parameter); - + itk::Point<double,2> GetImageOrigin(const std::string & key, unsigned int idx = 0); + itk::Vector<double,2> GetImageSpacing(const std::string & key, unsigned int idx = 0); + itkSize GetImageSize(const std::string & key, unsigned int idx = 0); + unsigned int GetImageNbBands(const std::string & key, unsigned int idx = 0); + std::string GetImageProjection(const std::string & key, unsigned int idx = 0); + std::map<std::string,std::string> GetImageKeywordlist(const std::string & key, unsigned int idx = 0); + unsigned long PropagateRequestedRegion(const std::string & key, itkRegion region, unsigned int idx = 0); + itkRegion GetImageRequestedRegion(const std::string & key, unsigned int idx = 0); itkProcessObject* GetProgressSource() const; @@ -320,7 +526,6 @@ public: { \ otb::Wrapper::Parameter *parameter = $self->GetParameterList()->GetParameterByKey(pkey); \ OutputImageParameter* outputImageParam = dynamic_cast<OutputImageParameter*>(parameter); \ - typedef itk::ImageBase<2> ImageBaseType; \ typedef ImageBaseType::RegionType RegionType; \ ImageBaseType::Pointer imageBase; \ imageBase = outputImageParam->GetValue(); \ diff --git a/Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h b/Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h index 9bd940ef78..b7f84f06fc 100644 --- a/Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h +++ b/Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h @@ -36,4 +36,10 @@ typedef otb::Wrapper::InputImageParameter InputImageParameter; typedef otb::Wrapper::ComplexOutputImageParameter ComplexOutputImageParameter; typedef otb::Wrapper::ComplexInputImageParameter ComplexInputImageParameter; +typedef otb::Wrapper::ImageBaseType ImageBaseType; + +typedef ImageBaseType::SizeType itkSize; +typedef ImageBaseType::RegionType itkRegion; +typedef ImageBaseType::IndexType itkIndex; + #endif -- GitLab From a048449dbdfd9e9c55d6412cfcc05ece9cdc6d6f Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 23 Feb 2018 19:38:45 +0100 Subject: [PATCH 322/567] ENH: protect AbortGenerateData with mutex for ImageFileReader --- .../IO/ImageIO/include/otbImageFileWriter.h | 9 +++++++ .../IO/ImageIO/include/otbImageFileWriter.txx | 25 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.h b/Modules/IO/ImageIO/include/otbImageFileWriter.h index b7bc6499b0..93be343529 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.h @@ -25,6 +25,7 @@ #include "itkProcessObject.h" #include "otbStreamingManager.h" #include "otbExtendedFilenameToWriterOptions.h" +#include "itkFastMutexLock.h" namespace otb { @@ -199,6 +200,11 @@ public: itkGetObjectMacro(ImageIO, otb::ImageIOBase); itkGetConstObjectMacro(ImageIO, otb::ImageIOBase); + // the interface of the superclass getter function is not thread safe + bool GetAbortGenerateDataMutex() const; + + void SetAbortGenerateData(bool val) override; + protected: ImageFileWriter(); ~ImageFileWriter() ITK_OVERRIDE; @@ -270,6 +276,9 @@ private: * This variable can be the number of components in m_ImageIO or the * number of components in the m_BandList (if used) */ unsigned int m_IOComponents; + + /** Lock to ensure thread-safety (added for the AbortGenerateData flag) */ + itk::SimpleFastMutexLock m_Lock; }; } // end namespace otb diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index b1472291f1..454fdea478 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -616,7 +616,7 @@ ImageFileWriter<TInputImage> } for (m_CurrentDivision = 0; - m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateData(); + m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateDataMutex(); m_CurrentDivision++, m_DivisionProgress = 0, this->UpdateFilterProgress()) { streamRegion = m_StreamingManager->GetSplit(m_CurrentDivision); @@ -645,7 +645,7 @@ ImageFileWriter<TInputImage> * If we ended due to aborting, push the progress up to 1.0 (since * it probably didn't end there) */ - if (!this->GetAbortGenerateData()) + if (!this->GetAbortGenerateDataMutex()) { this->UpdateProgress(1.0); } @@ -843,6 +843,27 @@ ImageFileWriter<TInputImage> return this->m_FilenameHelper->GetSimpleFileName(); } +template <class TInputImage> +bool +ImageFileWriter<TInputImage> +::GetAbortGenerateDataMutex() const +{ + m_Lock.Lock(); + bool ret = Superclass::GetAbortGenerateData(); + m_Lock.Unlock(); + return ret; +} + +template <class TInputImage> +void +ImageFileWriter<TInputImage> +::SetAbortGenerateData(bool val) +{ + m_Lock.Lock(); + Superclass::SetAbortGenerateData(val); + m_Lock.Unlock(); +} + } // end namespace otb #endif -- GitLab From 796c0e01c8e1b710fd9a3193c822aa89e32c7496 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 23 Feb 2018 19:40:30 +0100 Subject: [PATCH 323/567] ENH: send Abort for OutputImageParameters (WIP) --- .../src/otbWrapperApplication.cxx | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 7676634a52..dc66786557 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -517,6 +517,7 @@ int Application::ExecuteAndWriteOutput() } } + // TODO: only if no Stop() was called this->AfterExecuteAndWriteOutputs(); m_Chrono.Stop(); @@ -526,9 +527,24 @@ int Application::ExecuteAndWriteOutput() void Application::Stop() { - // TODO : call AbortGenerateData on ProcessObjects (but no mutex) - // TODO : set an internal AbortExecute flag with mutex - std::cout << "Stop !" << std::endl; + std::vector<std::string> paramList = GetParametersKeys(true); + for (std::vector<std::string>::const_iterator it = paramList.begin(); + it != paramList.end(); + ++it) + { + std::string key = *it; + if (GetParameterType(key) == ParameterType_OutputImage + && IsParameterEnabled(key) && HasValue(key) ) + { + Parameter* param = GetParameterByKey(key); + OutputImageParameter* outputParam = dynamic_cast<OutputImageParameter*>(param); + + if(outputParam!=ITK_NULLPTR) + { + outputParam->GetWriter()->SetAbortGenerateData(true); + } + } + } } /* Enable the use of an optional parameter. Returns the previous state */ -- GitLab From c0a506e7a97a76feb102160834b243a7406a9fdb Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 23 Feb 2018 19:41:10 +0100 Subject: [PATCH 324/567] ENH: change message when cancelling --- Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h | 1 + Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h index 08857a2420..d9a984092c 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h @@ -59,6 +59,7 @@ public slots: private slots: void UpdateMessageAfterExecuteClicked(); + void UpdateMessageAfterCancelClicked(); void UpdateMessageAfterExecution(int status); void UpdateMessageAfterApplicationReady(bool val); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx index 9238875575..b265b5e886 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx @@ -96,6 +96,12 @@ void QtWidgetView::UpdateMessageAfterExecuteClicked() disconnect( m_ExecButton, SIGNAL(clicked()), m_Model, SLOT(ExecuteAndWriteOutputSlot() ) ); disconnect( m_ExecButton, SIGNAL(clicked()), this, SLOT(UpdateMessageAfterExecuteClicked() ) ); connect( m_ExecButton, SIGNAL(clicked()), m_Model, SIGNAL(Stop())); + connect( m_ExecButton, SIGNAL(clicked()), this, SLOT(UpdateMessageAfterCancelClicked())); +} + +void QtWidgetView::UpdateMessageAfterCancelClicked() +{ + m_Message->setText("<center><font color=\"#FF0000\">Cancelling...</font></center>"); } void QtWidgetView::UpdateMessageAfterExecution(int status) @@ -111,6 +117,7 @@ void QtWidgetView::UpdateMessageAfterExecution(int status) m_ExecButton->setText(QObject::tr("Execute")); disconnect( m_ExecButton, SIGNAL(clicked()), m_Model, SIGNAL(Stop())); + disconnect( m_ExecButton, SIGNAL(clicked()), this, SLOT(UpdateMessageAfterCancelClicked())); connect( m_ExecButton, SIGNAL(clicked()), m_Model, SLOT(ExecuteAndWriteOutputSlot() ) ); connect( m_ExecButton, SIGNAL(clicked()), this, SLOT(UpdateMessageAfterExecuteClicked() ) ); } -- GitLab From 2541beae26fc6ed7f8aae3e29b0ed4aaa6888c2a Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 26 Feb 2018 08:13:44 +0100 Subject: [PATCH 325/567] ENH: Remove unused headers --- .../src/otbWrapperInputImageParameterCDouble.cxx | 2 -- .../src/otbWrapperInputImageParameterCFloat.cxx | 2 -- .../src/otbWrapperInputImageParameterCInt16.cxx | 2 -- .../src/otbWrapperInputImageParameterCInt32.cxx | 2 -- .../src/otbWrapperInputImageParameterDouble.cxx | 2 -- .../src/otbWrapperInputImageParameterFloat.cxx | 2 -- .../src/otbWrapperInputImageParameterInt16.cxx | 2 -- .../src/otbWrapperInputImageParameterInt32.cxx | 2 -- .../src/otbWrapperInputImageParameterUInt16.cxx | 2 -- .../src/otbWrapperInputImageParameterUInt32.cxx | 2 -- .../src/otbWrapperInputImageParameterUInt8.cxx | 2 -- 11 files changed, 22 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx index 0ab35a7de9..304a871a77 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCDouble.cxx @@ -20,9 +20,7 @@ #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageParameterMacros.h" -#include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" -#include "otb_boost_string_header.h" namespace otb { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx index 454b8abb56..264b851038 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCFloat.cxx @@ -20,9 +20,7 @@ #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageParameterMacros.h" -#include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" -#include "otb_boost_string_header.h" namespace otb { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt16.cxx index c6de185a12..d49f3d031a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt16.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt16.cxx @@ -20,9 +20,7 @@ #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageParameterMacros.h" -#include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" -#include "otb_boost_string_header.h" namespace otb { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt32.cxx index d6cbab06f1..5d675543ad 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt32.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterCInt32.cxx @@ -20,9 +20,7 @@ #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageParameterMacros.h" -#include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" -#include "otb_boost_string_header.h" namespace otb { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx index b3b6ec7d51..b7735195ea 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterDouble.cxx @@ -20,9 +20,7 @@ #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageParameterMacros.h" -#include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" -#include "otb_boost_string_header.h" namespace otb { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx index 77dab91387..9d41953f67 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterFloat.cxx @@ -20,9 +20,7 @@ #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageParameterMacros.h" -#include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" -#include "otb_boost_string_header.h" namespace otb { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx index 4b645f1560..217fda3d3f 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt16.cxx @@ -20,9 +20,7 @@ #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageParameterMacros.h" -#include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" -#include "otb_boost_string_header.h" namespace otb { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx index 66b6e3fa89..6a38bb1a30 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterInt32.cxx @@ -20,9 +20,7 @@ #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageParameterMacros.h" -#include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" -#include "otb_boost_string_header.h" namespace otb { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx index 89dcd5b648..d2e58d1503 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt16.cxx @@ -20,9 +20,7 @@ #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageParameterMacros.h" -#include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" -#include "otb_boost_string_header.h" namespace otb { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx index 2df611b114..fe75efce28 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt32.cxx @@ -20,9 +20,7 @@ #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageParameterMacros.h" -#include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" -#include "otb_boost_string_header.h" namespace otb { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx index 9f1c38e815..e8af7e127a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameterUInt8.cxx @@ -20,9 +20,7 @@ #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageParameterMacros.h" -#include "itksys/SystemTools.hxx" #include "otbWrapperTypes.h" -#include "otb_boost_string_header.h" namespace otb { -- GitLab From 75270b0227b572a1cf1a9716758f67a88045cf18 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 26 Feb 2018 09:28:16 +0100 Subject: [PATCH 326/567] ENH: add a trace to get RefCount of ProcessObject --- .../ApplicationEngine/src/otbWrapperApplication.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 4a0eaa82d9..c97090f6e0 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -650,6 +650,12 @@ int Application::ExecuteAndWriteOutput() this->AfterExecuteAndWriteOutputs(); m_Chrono.Stop(); + for ( auto filter : m_Filters ) + { + std::cout<<"For filter : "<<filter->GetNameOfClass()<< + " count : "<<filter->GetReferenceCount()<<std::endl; + } + m_Filters.clear(); return status; } -- GitLab From a4dd4c51b2e5ebcf0e4c5b8059d7736d03ac0a51 Mon Sep 17 00:00:00 2001 From: Yannick TANGUY <yannick.tanguy@cnes.fr> Date: Mon, 26 Feb 2018 14:00:25 +0100 Subject: [PATCH 327/567] Simplification : some text related to former "requests for comments" has been deleted. --- PSC.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/PSC.md b/PSC.md index d3bcd96a78..848da5edce 100644 --- a/PSC.md +++ b/PSC.md @@ -142,14 +142,9 @@ handle with a Merge Request : - Changing inter-subsystem APIs, or objects, - Any change in the code or in the documentation. -Merge Request can be linked to an issue and should describe : +Merge Request can implement an issue in GitLab. -1. What changes will be made and why they will make a better Orfeo - ToolBox -2. When will those changes be available (target release or date) -3. Who will be developing the proposed changes - -Those elements must be provided to a git hosted platform (GitLab, GitHub, etc.). +Merge Requests must be provided to a git hosted platform (GitLab, GitHub, etc.). Merge request can be discussed on the developer list or directly on GitLab. Votes are necessary to accept Merge Request : -- GitLab From 60c8326036655407ba86ef8be1366ec45f197ab3 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 26 Feb 2018 14:36:53 +0100 Subject: [PATCH 328/567] BUG: correct a translation error --- .../app/otbContrastEnhancement.cxx | 42 +++++++++---------- .../AppFiltering/test/CMakeLists.txt | 6 +-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx index 4e27af85d4..d74b2a79e1 100644 --- a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx +++ b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx @@ -235,13 +235,13 @@ private: SetParameterDescription("minmax.auto.global" , "Automatic" "Min/max computation will result in the same minimum and maximum for " "all the bands."); - AddChoice( "minmax.manuel" , "Manuel" ); + AddChoice( "minmax.manual" , "Manual" ); SetParameterDescription("minmax.auto","Minimum and maximum value will be " "set by the user"); - AddParameter(ParameterType_Float , "minmax.manuel.min" , "Minimum"); - AddParameter(ParameterType_Float , "minmax.manuel.max" , "Maximum"); - MandatoryOff("minmax.manuel.min"); - MandatoryOff("minmax.manuel.max"); + AddParameter(ParameterType_Float , "minmax.manual.min" , "Minimum"); + AddParameter(ParameterType_Float , "minmax.manual.max" , "Maximum"); + MandatoryOff("minmax.manual.min"); + MandatoryOff("minmax.manual.max"); AddParameter(ParameterType_Choice , "mode" , "What to equalized"); AddChoice( "mode.each" , "Channels" ); @@ -323,15 +323,15 @@ private: SetDefaultValue( inImage , "RGB" ); } - if ( GetParameterString("minmax") == "manuel" ) + if ( GetParameterString("minmax") == "manual" ) { - MandatoryOn("minmax.manuel.min"); - MandatoryOn("minmax.manuel.max"); + MandatoryOn("minmax.manual.min"); + MandatoryOn("minmax.manual.max"); } else if ( GetParameterString("minmax") == "auto" ) { - MandatoryOff("minmax.manuel.min"); - MandatoryOff("minmax.manuel.max"); + MandatoryOff("minmax.manual.min"); + MandatoryOff("minmax.manual.max"); } } @@ -476,8 +476,8 @@ private: } else { - oss << GetParameterFloat("minmax.manuel.min") << "/" << - GetParameterFloat("minmax.manuel.max"); + oss << GetParameterFloat("minmax.manual.min") << "/" << + GetParameterFloat("minmax.manual.max"); } otbAppLogINFO( << oss.str() ); @@ -511,14 +511,14 @@ private: // Check for min max validity void WarningMinMax() { - if ( m_MinMaxMode == "manuel" && - GetParameterFloat( "minmax.manuel.min" ) > - GetParameterFloat( "minmax.manuel.max" ) ) + if ( m_MinMaxMode == "manual" && + GetParameterFloat( "minmax.manual.min" ) > + GetParameterFloat( "minmax.manual.max" ) ) { std::ostringstream oss; - oss<<"The minimum (" << GetParameterFloat( "minmax.manuel.min" ) << + oss<<"The minimum (" << GetParameterFloat( "minmax.manual.min" ) << ") is superior to the maximum (" - << GetParameterFloat( "minmax.manuel.max" ) + << GetParameterFloat( "minmax.manual.max" ) << ") please correct this error or allow the application to compute " "those parameters"; otbAppLogFATAL( << oss.str() ) @@ -545,10 +545,10 @@ private: FloatVectorImageType::PixelType & max , FloatVectorImageType::PixelType & min ) { - if ( m_MinMaxMode == "manuel" ) + if ( m_MinMaxMode == "manual" ) { - min.Fill( GetParameterFloat("minmax.manuel.min") ); - max.Fill( GetParameterFloat("minmax.manuel.max") ); + min.Fill( GetParameterFloat("minmax.manual.min") ); + max.Fill( GetParameterFloat("minmax.manual.max") ); } else { @@ -584,7 +584,7 @@ private: std::ostringstream oss; oss<<"Minimum and maximum are for each channel : "; if ( IsParameterEnabled("minmax.auto.global") || - m_MinMaxMode == "manuel" ) + m_MinMaxMode == "manual" ) { oss<<std::endl<<min[0]<<" and "<<max[0]; } diff --git a/Modules/Applications/AppFiltering/test/CMakeLists.txt b/Modules/Applications/AppFiltering/test/CMakeLists.txt index f8195d22ce..1c16ed0193 100644 --- a/Modules/Applications/AppFiltering/test/CMakeLists.txt +++ b/Modules/Applications/AppFiltering/test/CMakeLists.txt @@ -68,9 +68,9 @@ otb_test_application(NAME apTvUtContrastTest_base_glob -out ${TEMP}/apTvUtContrastTest_base_glob.tif int16 -bins 256 -spatial global - -minmax manuel - -minmax.manuel.min 0 - -minmax.manuel.max 255 + -minmax manual + -minmax.manual.min 0 + -minmax.manual.max 255 VALID --compare-image ${NOTOL} ${BASELINE}/apTvUtContrastTest_base_glob.tif ${TEMP}/apTvUtContrastTest_base_glob.tif) -- GitLab From 8d42eb266eb6452a7011e689931037684f9b3aa6 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 26 Feb 2018 16:00:59 +0100 Subject: [PATCH 329/567] ENH: better writing of SWIG bindings for ITK types --- Modules/Wrappers/SWIG/src/otbApplication.i | 140 +++++++++------------ 1 file changed, 59 insertions(+), 81 deletions(-) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index e227a0f37f..0ef567b2c6 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -164,52 +164,57 @@ namespace std { #endif } // end of namespace std -class itkSize +// BASIC ITK TYPES WRAPPING +%include "itkFloatTypes.h" +%include "itkIntTypes.h" + +namespace itk +{ + +template <unsigned int VDim = 2> +class Size { public: - itkSize(); - virtual ~itkSize(); + Size(); + virtual ~Size(); void Fill(unsigned long val); - unsigned long GetElement(unsigned long element) const; - void SetElement(unsigned long element, unsigned long val); + SizeValueType GetElement(unsigned long element) const; + void SetElement(unsigned long element, SizeValueType val); static unsigned int GetSizeDimension(); }; -class itkIndex +template <unsigned int VDim = 2> +class Index { public: - itkIndex(); - virtual ~itkIndex(); + Index(); + virtual ~Index(); void Fill(signed long val); - signed long GetElement(unsigned long element) const; - void SetElement(unsigned long element, signed long val); + IndexValueType GetElement(unsigned long element) const; + void SetElement(unsigned long element, IndexValueType val); static unsigned int GetIndexDimension(); }; -class itkRegion +template <unsigned int VDim> +class ImageRegion { public: - itkRegion(); - itkRegion(const itkIndex &index, const itkSize &size); - virtual ~itkRegion(); - void SetIndex(const itkIndex &index); - void SetSize(const itkSize &size); - void SetUpperIndex(const itkIndex &idx); - itkIndex GetUpperIndex() const; - const itkIndex & GetIndex() const; - const itkSize & GetSize() const; - bool IsInside(const itkIndex & index) const; - void SetSize(unsigned int i, unsigned long val); - unsigned long GetSize(unsigned int i) const; - void SetIndex(unsigned int i, signed long val); - signed long GetIndex(unsigned int i) const; -private: - itkIndex m_Index; - itkSize m_Size; + ImageRegion(); + ImageRegion(const Index<VDim> &index, const Size<VDim> &size); + virtual ~ImageRegion(); + void SetIndex(const Index<VDim> &index); + void SetSize(const Size<VDim> &size); + void SetUpperIndex(const Index<VDim> &idx); + Index<VDim> GetUpperIndex() const; + const Index<VDim> & GetIndex() const; + const Size<VDim> & GetSize() const; + bool IsInside(const Index<VDim> & index) const; + void SetSize(unsigned int i, SizeValueType val); + SizeValueType GetSize(unsigned int i) const; + void SetIndex(unsigned int i, IndexValueType val); + IndexValueType GetIndex(unsigned int i) const; }; -namespace itk -{ template <typename TValue, unsigned int VLength = 3> class FixedArray { @@ -221,9 +226,6 @@ public: const TValue & GetElement(unsigned short idx); }; -%template(itkFixedArrayD2) FixedArray<double,2>; -%template(itkFixedArrayF2) FixedArray<float,2>; - template <typename TValue, unsigned int NDim = 3> class Vector: public FixedArray<TValue,NDim> { @@ -236,9 +238,6 @@ public: RealValueType Normalize(); }; -%template(itkVectorD2) Vector<double,2>; -%template(itkVectorF2) Vector<float,2>; - template <typename TCoord, unsigned int NDim = 3> class Point: public FixedArray<TCoord,NDim> { @@ -247,15 +246,22 @@ public: virtual ~Point(); }; -%template(itkPointD2) Point<double,2>; -%template(itkPointF2) Point<float,2>; +// Instanciate the needed templates +%template(itkSize) Size<2>; +%template(itkIndex) Index<2>; +%template(itkRegion) ImageRegion<2>; +%template(itkFixedArray) FixedArray<SpacePrecisionType,2>; +%template(itkVector) Vector<SpacePrecisionType,2>; +%template(itkPoint) Point<SpacePrecisionType,2>; } // end of namespace itk #if SWIGPYTHON -%define WRAP_AS_LIST(N) +%define WRAP_AS_LIST(N, T...) +%extend T + { %pythoncode { def __str__(self): @@ -275,46 +281,18 @@ public: raise IndexError('Index outside [0,'+str(N-1)+']') return self.SetElement(idx,val) } + }; %enddef -%extend itkSize -{ - WRAP_AS_LIST(2) -}; -%extend itkIndex -{ - WRAP_AS_LIST(2) -}; - namespace itk { -%extend FixedArray<double,2> -{ - WRAP_AS_LIST(2) -}; -%extend FixedArray<float,2> -{ - WRAP_AS_LIST(2) -}; -%extend Vector<double,2> -{ - WRAP_AS_LIST(2) -}; -%extend Vector<float,2> -{ - WRAP_AS_LIST(2) -}; -%extend Point<double,2> -{ - WRAP_AS_LIST(2) -}; -%extend Point<float,2> -{ - WRAP_AS_LIST(2) -}; -} // end of namespace itk +WRAP_AS_LIST(2, Size<2>) +WRAP_AS_LIST(2, Index<2>) +WRAP_AS_LIST(2, FixedArray<SpacePrecisionType,2>) +WRAP_AS_LIST(2, Vector<SpacePrecisionType,2>) +WRAP_AS_LIST(2, Point<SpacePrecisionType,2>) -%extend itkRegion +%extend ImageRegion<2> { %pythoncode { @@ -336,9 +314,9 @@ namespace itk self.SetSize(val) else: raise IndexError('Key not in ["index","size"]') - } -} +}; +} // end of namespace itk #endif class Application: public itkObject @@ -409,14 +387,14 @@ public: void ClearParameterInputImageList(std::string parameter); unsigned int GetNumberOfElementsInParameterInputImageList(std::string parameter); - itk::Point<double,2> GetImageOrigin(const std::string & key, unsigned int idx = 0); - itk::Vector<double,2> GetImageSpacing(const std::string & key, unsigned int idx = 0); - itkSize GetImageSize(const std::string & key, unsigned int idx = 0); + itk::Point<SpacePrecisionType,2> GetImageOrigin(const std::string & key, unsigned int idx = 0); + itk::Vector<SpacePrecisionType,2> GetImageSpacing(const std::string & key, unsigned int idx = 0); + itk::Size<2> GetImageSize(const std::string & key, unsigned int idx = 0); unsigned int GetImageNbBands(const std::string & key, unsigned int idx = 0); std::string GetImageProjection(const std::string & key, unsigned int idx = 0); std::map<std::string,std::string> GetImageKeywordlist(const std::string & key, unsigned int idx = 0); - unsigned long PropagateRequestedRegion(const std::string & key, itkRegion region, unsigned int idx = 0); - itkRegion GetImageRequestedRegion(const std::string & key, unsigned int idx = 0); + unsigned long PropagateRequestedRegion(const std::string & key, itk::ImageRegion<2> region, unsigned int idx = 0); + itk::ImageRegion<2> GetImageRequestedRegion(const std::string & key, unsigned int idx = 0); itkProcessObject* GetProgressSource() const; -- GitLab From 3c437a4b4471ddfe588c85041181ae61a98cbebd Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 26 Feb 2018 19:22:32 +0100 Subject: [PATCH 330/567] ENH: application is able to populate an output file wit samples --- .../app/otbSampleAugmentation.cxx | 189 +++++++++++++++++- .../AppClassification/test/CMakeLists.txt | 11 + 2 files changed, 190 insertions(+), 10 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx index cc2ebfb6dd..c182711c77 100644 --- a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -27,6 +27,7 @@ namespace otb namespace Wrapper { + class SampleAugmentation : public Application { public: @@ -42,6 +43,9 @@ public: itkTypeMacro(SampleAugmentation, otb::Application); /** Filters typedef */ + using SampleType = std::vector<double>; + using SampleVectorType = std::vector<SampleType>; + private: SampleAugmentation() {} @@ -63,8 +67,8 @@ private: AddDocTag(Tags::Learning); - AddParameter(ParameterType_InputFilename, "vec", "Input samples"); - SetParameterDescription("vec","Vector data file containing samples (OGR format)"); + AddParameter(ParameterType_InputFilename, "in", "Input samples"); + SetParameterDescription("in","Vector data file containing samples (OGR format)"); AddParameter(ParameterType_OutputFilename, "out", "Output samples"); SetParameterDescription("out","Output vector data file storing new samples" @@ -90,28 +94,33 @@ private: "be generated."); SetDefaultParameterInt("samples",100); - AddRAMParameter(); + AddParameter(ParameterType_ListView, "exclude", "Field names for excluded features."); + SetParameterDescription("exclude", + "List of field names in the input vector data that will not be generated in the output file."); + // Doc example parameter settings - SetDocExampleParameterValue("vec", "samples.sqlite"); + SetDocExampleParameterValue("in", "samples.sqlite"); SetDocExampleParameterValue("field", "class"); SetDocExampleParameterValue("label", "3"); SetDocExampleParameterValue("samples", "100"); SetDocExampleParameterValue("out","augmented_samples.sqlite"); + SetDocExampleParameterValue( "exclude", "OGC_FID name class originfid" ); SetOfficialDocLink(); } void DoUpdateParameters() { - if ( HasValue("vec") ) + if ( HasValue("in") ) { - std::string vectorFile = GetParameterString("vec"); + std::string vectorFile = GetParameterString("in"); ogr::DataSource::Pointer ogrDS = ogr::DataSource::New(vectorFile, ogr::DataSource::Modes::Read); ogr::Layer layer = ogrDS->GetLayer(this->GetParameterInt("layer")); ogr::Feature feature = layer.ogr().GetNextFeature(); + ClearChoices( "exclude" ); ClearChoices("field"); for(int iField=0; iField<feature.ogr().GetFieldCount(); iField++) @@ -129,6 +138,11 @@ private: std::string tmpKey="field."+key.substr(0, end - key.begin()); AddChoice(tmpKey,item); } + if( fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64( fieldType ) || fieldType == OFTReal ) + { + std::string tmpKey = "exclude." + key.substr( 0, static_cast<unsigned long>( end - key.begin() ) ); + AddChoice( tmpKey, item ); + } } } } @@ -139,15 +153,15 @@ private: ogr::DataSource::Pointer output; if (IsParameterEnabled("out") && HasValue("out")) { - vectors = ogr::DataSource::New(this->GetParameterString("vec")); + vectors = ogr::DataSource::New(this->GetParameterString("in")); output = ogr::DataSource::New(this->GetParameterString("out"), ogr::DataSource::Modes::Overwrite); } else { // Update mode - vectors = ogr::DataSource::New(this->GetParameterString("vec"), - ogr::DataSource::Modes::Update_LayerUpdate); + vectors = ogr::DataSource::New(this->GetParameterString("in"), + ogr::DataSource::Modes::Update_LayerUpdate); output = vectors; } @@ -162,10 +176,165 @@ private: std::vector<std::string> cFieldNames = GetChoiceNames("field"); std::string fieldName = cFieldNames[selectedCFieldIdx.front()]; - + std::vector<std::string> excludedFeatures = GetExcludedFeatures( GetChoiceNames( "exclude" ), GetSelectedItems( "exclude" )); + for(const auto& ef : excludedFeatures) + std::cout << ef << " excluded\n"; + auto inSamples = extractSamples(vectors, this->GetParameterInt("layer"), + fieldName, + this->GetParameterInt("label"), + excludedFeatures); + auto newSamples = augmentSamples(inSamples, this->GetParameterInt("samples")); + writeSamples(vectors, output, newSamples, this->GetParameterInt("layer"), + fieldName, + this->GetParameterInt("label"), + excludedFeatures); output->SyncToDisk(); } +/** Extracts the samples of a single class from the vector data to a +* vector and excludes some unwanted features. +*/ + SampleVectorType extractSamples(const ogr::DataSource::Pointer vectors, size_t layerName, + std::string classField, int label, + const std::vector<std::string>& excludedFeatures = {}) + { + ogr::Layer layer = vectors->GetLayer(layerName); + ogr::Feature feature = layer.ogr().GetNextFeature(); + if(feature.addr() == 0) + { + otbAppLogFATAL("Layer " << layerName << " of input sample file is empty.\n"); + } + int cFieldIndex = feature.ogr().GetFieldIndex( classField.c_str() ); + if( cFieldIndex < 0 ) + { + otbAppLogFATAL( "The field name for class label (" << classField + << ") has not been found in the vector file " ); + } + + auto numberOfFields = feature.ogr().GetFieldCount(); + std::set<size_t> excludedIds; + if( excludedFeatures.size() != 0) + { + for(const auto& fieldName : excludedFeatures) + { + auto idx = feature.ogr().GetFieldIndex( fieldName.c_str() ); + excludedIds.insert(idx); + } + } + otbAppLogINFO("The vector file contains " << numberOfFields << " fields.\n"); + SampleVectorType samples; + bool goesOn{feature.addr() != 0}; + while( goesOn ) + { + // Retrieve all the features for each field in the ogr layer. + if(feature.ogr().GetFieldAsInteger(classField.c_str()) == label) + { + SampleType mv; + for(auto idx=0; idx<numberOfFields; ++idx) + { + OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(idx)->GetType(); + if(excludedIds.find(idx) == excludedIds.cend() && + (fieldType == OFTInteger + || ogr::version_proxy::IsOFTInteger64( fieldType ) + || fieldType == OFTReal)) + mv.push_back(feature.ogr().GetFieldAsDouble(idx)); + } + samples.push_back(mv); + } + feature = layer.ogr().GetNextFeature(); + goesOn = feature.addr() != 0; + } + return samples; + } + + SampleVectorType augmentSamples(const SampleVectorType& inSamples, + const size_t nbSamples) + { + SampleVectorType newSamples; + for(size_t i=0; i<nbSamples; ++i) + { + newSamples.push_back(inSamples[i%inSamples.size()]); + } + return newSamples; + } + + void writeSamples(const ogr::DataSource::Pointer vectors, + ogr::DataSource::Pointer output, + const SampleVectorType& samples, + size_t layerName, + std::string classField, int label, + const std::vector<std::string>& excludedFeatures = {}) + { + + auto inputLayer = vectors->GetLayer(layerName); + std::set<size_t> excludedIds; + if( excludedFeatures.size() != 0) + { + auto feature = *(inputLayer).begin(); + for(const auto& fieldName : excludedFeatures) + { + auto idx = feature.ogr().GetFieldIndex( fieldName.c_str() ); + excludedIds.insert(idx); + } + } + + + OGRSpatialReference * oSRS = nullptr; + if (inputLayer.GetSpatialRef()) + { + oSRS = inputLayer.GetSpatialRef()->Clone(); + } + OGRFeatureDefn &layerDefn = inputLayer.GetLayerDefn(); + + auto outputLayer = output->CreateLayer(inputLayer.GetName(), oSRS, + inputLayer.GetGeomType()); + for (int k=0 ; k < layerDefn.GetFieldCount() ; k++) + { + OGRFieldDefn originDefn(layerDefn.GetFieldDefn(k)); + ogr::FieldDefn fieldDefn(originDefn); + outputLayer.CreateField(fieldDefn); + } + + auto featureCount = outputLayer.GetFeatureCount(false); + auto templateFeature = *(inputLayer).begin(); + for(const auto& sample : samples) + { + ogr::Feature dstFeature(outputLayer.GetLayerDefn()); + dstFeature.SetFrom( templateFeature, TRUE ); + dstFeature.SetFID(++featureCount); + auto sampleFieldCounter = 0; + for (int k=0 ; k < layerDefn.GetFieldCount() ; k++) + { + OGRFieldType fieldType = dstFeature.ogr().GetFieldDefnRef(k)->GetType(); + if(excludedIds.find(k) == excludedIds.cend() && + (fieldType == OFTInteger + || ogr::version_proxy::IsOFTInteger64( fieldType ) + || fieldType == OFTReal)) + { + dstFeature.ogr().SetField(k, sample[sampleFieldCounter++]); + } + } + // for (unsigned int i=0 ; i<nbBand ; ++i) + // { + // imgComp = static_cast<double>(itk::DefaultConvertPixelTraits<PixelType>::GetNthComponent(i,imgPixel)); + // // Fill the output OGRDataSource + // dstFeature[m_SampleFieldNames[i]].SetValue(imgComp); + // } + outputLayer.CreateFeature( dstFeature ); + } + } + + std::vector<std::string> GetExcludedFeatures(std::vector <std::string> fieldNames, + std::vector<int> selectedIdx) + { + auto nbFeatures = static_cast<unsigned int>(selectedIdx.size()); + std::vector<std::string> result( nbFeatures ); + for( unsigned int i = 0; i < nbFeatures; ++i ) + { + result[i] = fieldNames[selectedIdx[i]]; + } + return result; + } }; } // end of namespace Wrapper diff --git a/Modules/Applications/AppClassification/test/CMakeLists.txt b/Modules/Applications/AppClassification/test/CMakeLists.txt index fae1474266..c30773decb 100644 --- a/Modules/Applications/AppClassification/test/CMakeLists.txt +++ b/Modules/Applications/AppClassification/test/CMakeLists.txt @@ -972,3 +972,14 @@ otb_test_application( ${OTBAPP_BASELINE_FILES}/apTvClMultiImageSamplingRate_out_3.csv ${TEMP}/apTvClMultiImageSamplingRate_out_3.csv ) + +#------------ SampleAgmentation TESTS ---------------- +otb_test_application(NAME apTvClSampleAugmentation + APP SampleAugmentation + OPTIONS -in ${INPUTDATA}/Classification/apTvClSampleExtractionOut.sqlite + -field class + -label 3 + -samples 100 + -out ${TEMP}/apTvClSampleAugmentation.sqlite + # -excluded_features OGC_FID name class originfid + ) -- GitLab From 825a0b3d6ab432917fb7b928040805e5ea803a0a Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Tue, 27 Feb 2018 15:48:06 +0100 Subject: [PATCH 331/567] ENH: implementation of 3 augmentation algorithms --- .../app/otbSampleAugmentation.cxx | 129 +++++------ .../include/otbSampleAugmentation.h | 203 ++++++++++++++++++ .../AppClassification/test/CMakeLists.txt | 2 +- 3 files changed, 272 insertions(+), 62 deletions(-) create mode 100644 Modules/Applications/AppClassification/include/otbSampleAugmentation.h diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx index c182711c77..36fc02f8bf 100644 --- a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -21,6 +21,7 @@ #include "otbWrapperApplication.h" #include "otbWrapperApplicationFactory.h" #include "otbOGRDataSourceWrapper.h" +#include "otbSampleAugmentation.h" namespace otb { @@ -43,8 +44,8 @@ public: itkTypeMacro(SampleAugmentation, otb::Application); /** Filters typedef */ - using SampleType = std::vector<double>; - using SampleVectorType = std::vector<SampleType>; + using SampleType = sampleAugmentation::SampleType; + using SampleVectorType = sampleAugmentation::SampleVectorType; private: @@ -120,7 +121,7 @@ private: ogr::Layer layer = ogrDS->GetLayer(this->GetParameterInt("layer")); ogr::Feature feature = layer.ogr().GetNextFeature(); - ClearChoices( "exclude" ); + ClearChoices("exclude"); ClearChoices("field"); for(int iField=0; iField<feature.ogr().GetFieldCount(); iField++) @@ -176,14 +177,21 @@ private: std::vector<std::string> cFieldNames = GetChoiceNames("field"); std::string fieldName = cFieldNames[selectedCFieldIdx.front()]; - std::vector<std::string> excludedFeatures = GetExcludedFeatures( GetChoiceNames( "exclude" ), GetSelectedItems( "exclude" )); + std::vector<std::string> excludedFeatures = + GetExcludedFeatures( GetChoiceNames( "exclude" ), + GetSelectedItems( "exclude" )); for(const auto& ef : excludedFeatures) - std::cout << ef << " excluded\n"; + otbAppLogINFO("Excluding feature " << ef << '\n'); auto inSamples = extractSamples(vectors, this->GetParameterInt("layer"), fieldName, this->GetParameterInt("label"), excludedFeatures); - auto newSamples = augmentSamples(inSamples, this->GetParameterInt("samples")); + SampleVectorType newSamples; + // sampleAugmentation::replicateSamples(inSamples, this->GetParameterInt("samples"), + // newSamples); + sampleAugmentation::smote(inSamples, this->GetParameterInt("samples"), + newSamples, + 4); writeSamples(vectors, output, newSamples, this->GetParameterInt("layer"), fieldName, this->GetParameterInt("label"), @@ -194,8 +202,9 @@ private: /** Extracts the samples of a single class from the vector data to a * vector and excludes some unwanted features. */ - SampleVectorType extractSamples(const ogr::DataSource::Pointer vectors, size_t layerName, - std::string classField, int label, + SampleVectorType extractSamples(const ogr::DataSource::Pointer vectors, + size_t layerName, + const std::string& classField, const int label, const std::vector<std::string>& excludedFeatures = {}) { ogr::Layer layer = vectors->GetLayer(layerName); @@ -212,15 +221,7 @@ private: } auto numberOfFields = feature.ogr().GetFieldCount(); - std::set<size_t> excludedIds; - if( excludedFeatures.size() != 0) - { - for(const auto& fieldName : excludedFeatures) - { - auto idx = feature.ogr().GetFieldIndex( fieldName.c_str() ); - excludedIds.insert(idx); - } - } + auto excludedIds = getExcludedFeaturesIds(excludedFeatures, layer); otbAppLogINFO("The vector file contains " << numberOfFields << " fields.\n"); SampleVectorType samples; bool goesOn{feature.addr() != 0}; @@ -229,14 +230,12 @@ private: // Retrieve all the features for each field in the ogr layer. if(feature.ogr().GetFieldAsInteger(classField.c_str()) == label) { + SampleType mv; for(auto idx=0; idx<numberOfFields; ++idx) { - OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(idx)->GetType(); if(excludedIds.find(idx) == excludedIds.cend() && - (fieldType == OFTInteger - || ogr::version_proxy::IsOFTInteger64( fieldType ) - || fieldType == OFTReal)) + isNumericField(feature, idx)) mv.push_back(feature.ogr().GetFieldAsDouble(idx)); } samples.push_back(mv); @@ -247,37 +246,16 @@ private: return samples; } - SampleVectorType augmentSamples(const SampleVectorType& inSamples, - const size_t nbSamples) - { - SampleVectorType newSamples; - for(size_t i=0; i<nbSamples; ++i) - { - newSamples.push_back(inSamples[i%inSamples.size()]); - } - return newSamples; - } - - void writeSamples(const ogr::DataSource::Pointer vectors, - ogr::DataSource::Pointer output, + void writeSamples(const ogr::DataSource::Pointer& vectors, + ogr::DataSource::Pointer& output, const SampleVectorType& samples, - size_t layerName, - std::string classField, int label, + const size_t layerName, + const std::string& classField, int label, const std::vector<std::string>& excludedFeatures = {}) { auto inputLayer = vectors->GetLayer(layerName); - std::set<size_t> excludedIds; - if( excludedFeatures.size() != 0) - { - auto feature = *(inputLayer).begin(); - for(const auto& fieldName : excludedFeatures) - { - auto idx = feature.ogr().GetFieldIndex( fieldName.c_str() ); - excludedIds.insert(idx); - } - } - + auto excludedIds = getExcludedFeaturesIds(excludedFeatures, inputLayer); OGRSpatialReference * oSRS = nullptr; if (inputLayer.GetSpatialRef()) @@ -296,7 +274,7 @@ private: } auto featureCount = outputLayer.GetFeatureCount(false); - auto templateFeature = *(inputLayer).begin(); + auto templateFeature = selectTemplateFeature(inputLayer, classField, label); for(const auto& sample : samples) { ogr::Feature dstFeature(outputLayer.GetLayerDefn()); @@ -305,27 +283,18 @@ private: auto sampleFieldCounter = 0; for (int k=0 ; k < layerDefn.GetFieldCount() ; k++) { - OGRFieldType fieldType = dstFeature.ogr().GetFieldDefnRef(k)->GetType(); if(excludedIds.find(k) == excludedIds.cend() && - (fieldType == OFTInteger - || ogr::version_proxy::IsOFTInteger64( fieldType ) - || fieldType == OFTReal)) + isNumericField(dstFeature, k)) { dstFeature.ogr().SetField(k, sample[sampleFieldCounter++]); } } - // for (unsigned int i=0 ; i<nbBand ; ++i) - // { - // imgComp = static_cast<double>(itk::DefaultConvertPixelTraits<PixelType>::GetNthComponent(i,imgPixel)); - // // Fill the output OGRDataSource - // dstFeature[m_SampleFieldNames[i]].SetValue(imgComp); - // } outputLayer.CreateFeature( dstFeature ); } } - std::vector<std::string> GetExcludedFeatures(std::vector <std::string> fieldNames, - std::vector<int> selectedIdx) + std::vector<std::string> GetExcludedFeatures(const std::vector<std::string>& fieldNames, + const std::vector<int>& selectedIdx) { auto nbFeatures = static_cast<unsigned int>(selectedIdx.size()); std::vector<std::string> result( nbFeatures ); @@ -335,7 +304,45 @@ private: } return result; } -}; + ogr::Feature selectTemplateFeature(const ogr::Layer& inputLayer, + const std::string& classField, int label) + { + auto featureIt = inputLayer.begin(); + bool goesOn{(*featureIt).addr() != 0}; + while( goesOn ) + { + if((*featureIt).ogr().GetFieldAsInteger(classField.c_str()) == label) + { + return *featureIt; + } + ++featureIt; + } + return *(inputLayer.begin()); + } + std::set<size_t> getExcludedFeaturesIds(const std::vector<std::string>& excludedFeatures, + const ogr::Layer& inputLayer) + { + auto feature = *(inputLayer).begin(); + std::set<size_t> excludedIds; + if( excludedFeatures.size() != 0) + { + for(const auto& fieldName : excludedFeatures) + { + auto idx = feature.ogr().GetFieldIndex( fieldName.c_str() ); + excludedIds.insert(idx); + } + } + return excludedIds; + } + bool isNumericField(const ogr::Feature& feature, + const int idx) + { + OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(idx)->GetType(); + return (fieldType == OFTInteger + || ogr::version_proxy::IsOFTInteger64( fieldType ) + || fieldType == OFTReal); + } + }; } // end of namespace Wrapper } // end of namespace otb diff --git a/Modules/Applications/AppClassification/include/otbSampleAugmentation.h b/Modules/Applications/AppClassification/include/otbSampleAugmentation.h new file mode 100644 index 0000000000..27b9f07847 --- /dev/null +++ b/Modules/Applications/AppClassification/include/otbSampleAugmentation.h @@ -0,0 +1,203 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbSampleAugmentation_h +#define otbSampleAugmentation_h + +#include <vector> +#include <algorithm> +#include <random> +#include <ctime> +#include <cassert> +#include <iostream> + +namespace otb +{ + +namespace sampleAugmentation +{ +using SampleType = std::vector<double>; +using SampleVectorType = std::vector<SampleType>; + +/** +Estimate standard deviations of the components in one pass using +Welford's algorithm +*/ +SampleType estimateStds(SampleVectorType samples) +{ + const auto nbSamples = samples.size(); + const auto nbComponents = samples[0].size(); + SampleType stds(nbComponents, 0.0); + SampleType means(nbComponents, 0.0); + for(size_t i=0; i<nbSamples; ++i) + { + for(size_t j=0; j<nbComponents; ++j) + { + const auto mu = means[j]; + const auto x = samples[i][j]; + auto muNew = mu+(x-mu)/(i+1); + stds[j] += (x-mu)*(x-muNew); + means[j] = muNew; + } + } + for(auto std : stds) + std = std::sqrt(std/nbSamples); + return stds; +} + +/** Create new samples by replicating input samples. We loop through +* the input samples and add them to the new data set until nbSamples +* are added. The elements of newSamples are removed before proceeding. +*/ +void replicateSamples(const SampleVectorType& inSamples, + const size_t nbSamples, + SampleVectorType& newSamples) +{ + newSamples.resize(nbSamples); + for(size_t i=0; i<nbSamples; ++i) + { + newSamples[i] = inSamples[i%inSamples.size()]; + } +} + +/** Create new samples by adding noise to existing samples. Gaussian +* noise is added to randomly selected samples. The standard deviation +* of the noise added to each component is the same as the one of the +* input variables multiplied by stdFactor (defaults to 1). The +* elements of newSamples are removed before proceeding. +*/ +void jitterSamples(const SampleVectorType& inSamples, + const size_t nbSamples, + SampleVectorType& newSamples, + float stdFactor=1.0, + const int seed = std::time(nullptr)) +{ + newSamples.resize(nbSamples); + const auto nbComponents = inSamples[0].size(); + std::random_device rd; + std::mt19937 gen(rd()); + // The input samples are selected randomly with replacement + std::srand(seed); + // We use one gaussian distribution per component since they may + // have different stds + auto stds = estimateStds(inSamples); + std::vector<std::normal_distribution<double>> gaussDis; + for(size_t i=0; i<nbComponents; ++i) + gaussDis.emplace_back(std::normal_distribution<double>{0.0, stds[i]*stdFactor}); + for(size_t i=0; i<nbSamples; ++i) + { + newSamples[i] = inSamples[std::rand()%nbSamples]; + for(size_t j=0; j<nbComponents; ++j) + newSamples[i][j] += gaussDis[j](gen); + } +} + + +struct NeighborType +{ + size_t index; + double distance; +}; + +struct NeighborSorter +{ + constexpr bool operator ()(const NeighborType& a, const NeighborType& b) const + { + return b.distance > a.distance; + } +}; + +double computeDistance(const SampleType& x, const SampleType& y) +{ + assert(x.size()==y.size()); + double dist{0}; + for(size_t i=0; i<x.size(); ++i) + { + dist += (x[i]-y[i])*(x[i]-y[i])/(x.size()*x.size()); + } + return std::sqrt(dist); +} + +using NNIndicesType = std::vector<NeighborType>; +using NNVectorType = std::vector<NNIndicesType>; +/** Returns the indices of the nearest neighbors for each input sample +*/ +void findKNNIndices(const SampleVectorType& inSamples, + const size_t nbNeighbors, + NNVectorType& nnVector) +{ + const auto nbSamples = inSamples.size(); + nnVector.resize(nbSamples); + for(size_t sampleIdx=0; sampleIdx<nbSamples; ++sampleIdx) + { + NNIndicesType nns; + for(size_t neighborIdx=0; neighborIdx<nbSamples; ++neighborIdx) + { + if(sampleIdx!=neighborIdx) + nns.push_back({neighborIdx, computeDistance(inSamples[sampleIdx], + inSamples[neighborIdx])}); + } + std::partial_sort(nns.begin(), nns.begin()+nbNeighbors, nns.end(), NeighborSorter{}); + nns.resize(nbNeighbors); + nnVector[sampleIdx] = nns; + } +} + +/** Generate the new sample in the line linking s1 and s2 +*/ +SampleType smoteCombine(SampleType s1, SampleType s2, double position) +{ + auto result = s1; + for(size_t i=0; i<s1.size(); ++i) + result[i] = s1[i]+(s2[i]-s1[i])*position; + return result; +} + +/** Create new samples using the SMOTE algorithm +Chawla, N. V., Bowyer, K. W., Hall, L. O., & Kegelmeyer, W. P., Smote: +synthetic minority over-sampling technique, Journal of artificial +intelligence research, 16(), 321–357 (2002). +http://dx.doi.org/10.1613/jair.953 +*/ +void smote(const SampleVectorType& inSamples, + const size_t nbSamples, + SampleVectorType& newSamples, + const int nbNeighbors, + const int seed = std::time(nullptr)) +{ + newSamples.resize(nbSamples); + NNVectorType nnVector; + findKNNIndices(inSamples, nbNeighbors, nnVector); + // The input samples are selected randomly with replacement + std::srand(seed); + for(size_t i=0; i<nbSamples; ++i) + { + const auto sampleIdx = std::rand()%nbSamples; + const auto sample = inSamples[sampleIdx]; + const auto neighborIdx = nnVector[sampleIdx][std::rand()%nbNeighbors].index; + const auto neighbor = inSamples[neighborIdx]; + newSamples[i] = smoteCombine(sample, neighbor, std::rand()/double{RAND_MAX}); + } +} + +} +} + +#endif diff --git a/Modules/Applications/AppClassification/test/CMakeLists.txt b/Modules/Applications/AppClassification/test/CMakeLists.txt index c30773decb..c0ec37fea3 100644 --- a/Modules/Applications/AppClassification/test/CMakeLists.txt +++ b/Modules/Applications/AppClassification/test/CMakeLists.txt @@ -981,5 +981,5 @@ otb_test_application(NAME apTvClSampleAugmentation -label 3 -samples 100 -out ${TEMP}/apTvClSampleAugmentation.sqlite - # -excluded_features OGC_FID name class originfid + -exclude originfid ) -- GitLab From b0a4f4a57ba46d0b18d84acf21bd4cbdecf3ad94 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Tue, 27 Feb 2018 17:35:35 +0100 Subject: [PATCH 332/567] ENH: add options for the different strategies --- .../app/otbSampleAugmentation.cxx | 75 +++++++++++++++++-- .../include/otbSampleAugmentation.h | 6 +- .../AppClassification/test/CMakeLists.txt | 29 ++++++- 3 files changed, 101 insertions(+), 9 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx index 36fc02f8bf..a12e3912b1 100644 --- a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -99,6 +99,42 @@ private: SetParameterDescription("exclude", "List of field names in the input vector data that will not be generated in the output file."); + AddParameter(ParameterType_Choice, "strategy", "Augmentation strategy"); + + AddChoice("strategy.replicate","Replicate input samples"); + SetParameterDescription("strategy.replicate","The new samples are generated " + "by replicating input samples which are randomly " + "selected with replacement."); + + AddChoice("strategy.jitter","Jitter input samples"); + SetParameterDescription("strategy.jitter","The new samples are generated " + "by adding gaussian noise to input samples which are " + "randomly selected with replacement."); + AddParameter(ParameterType_Float, "strategy.jitter.stdfactor", + "Factor for dividing the standard deviation of each feature"); + SetParameterDescription("strategy.jitter.stdfactor", + "The noise added to the input samples will have the " + "standard deviation of the input features divided " + "by the value of this parameter. "); + SetDefaultParameterFloat("strategy.jitter.stdfactor",10000); + + AddChoice("strategy.smote","Smote input samples"); + SetParameterDescription("strategy.smote","The new samples are generated " + "by using the SMOTE algorithm (http://dx.doi.org/10.1613/jair.953) " + "on input samples which are " + "randomly selected with replacement."); + AddParameter(ParameterType_Int, "strategy.smote.neighbors", + "Number of nearest neighbors."); + SetParameterDescription("strategy.smote.neighbors", + "Number of nearest neighbors to be used in the " + "SMOTE algorithm"); + SetDefaultParameterFloat("strategy.smote.neighbors", 5); + + AddParameter(ParameterType_Int, "seed", + "Random seed."); + SetParameterDescription("seed", + "Seed for the random number generator."); + MandatoryOff("seed"); // Doc example parameter settings SetDocExampleParameterValue("in", "samples.sqlite"); @@ -107,6 +143,8 @@ private: SetDocExampleParameterValue("samples", "100"); SetDocExampleParameterValue("out","augmented_samples.sqlite"); SetDocExampleParameterValue( "exclude", "OGC_FID name class originfid" ); + SetDocExampleParameterValue("strategy", "smote"); + SetDocExampleParameterValue("strategy.smote.neighbors", "5"); SetOfficialDocLink(); } @@ -186,12 +224,39 @@ private: fieldName, this->GetParameterInt("label"), excludedFeatures); + int seed = std::time(nullptr); + if(IsParameterEnabled("seed")) seed = this->GetParameterInt("seed"); SampleVectorType newSamples; - // sampleAugmentation::replicateSamples(inSamples, this->GetParameterInt("samples"), - // newSamples); - sampleAugmentation::smote(inSamples, this->GetParameterInt("samples"), - newSamples, - 4); + switch (this->GetParameterInt("strategy")) + { + // replicate + case 0: + { + otbAppLogINFO("Augmentation strategy : replicate"); + sampleAugmentation::replicateSamples(inSamples, this->GetParameterInt("samples"), + newSamples); + } + break; + // jitter + case 1: + { + otbAppLogINFO("Augmentation strategy : jitter"); + sampleAugmentation::jitterSamples(inSamples, this->GetParameterInt("samples"), + newSamples, + this->GetParameterFloat("strategy.jitter.stdfactor"), + seed); + } + break; + case 2: + { + otbAppLogINFO("Augmentation strategy : smote"); + sampleAugmentation::smote(inSamples, this->GetParameterInt("samples"), + newSamples, + this->GetParameterInt("strategy.smote.neighbors"), + seed); + } + break; + } writeSamples(vectors, output, newSamples, this->GetParameterInt("layer"), fieldName, this->GetParameterInt("label"), diff --git a/Modules/Applications/AppClassification/include/otbSampleAugmentation.h b/Modules/Applications/AppClassification/include/otbSampleAugmentation.h index 27b9f07847..43fd6657a0 100644 --- a/Modules/Applications/AppClassification/include/otbSampleAugmentation.h +++ b/Modules/Applications/AppClassification/include/otbSampleAugmentation.h @@ -58,7 +58,9 @@ SampleType estimateStds(SampleVectorType samples) } } for(auto std : stds) + { std = std::sqrt(std/nbSamples); + } return stds; } @@ -86,7 +88,7 @@ void replicateSamples(const SampleVectorType& inSamples, void jitterSamples(const SampleVectorType& inSamples, const size_t nbSamples, SampleVectorType& newSamples, - float stdFactor=1.0, + float stdFactor=10000, const int seed = std::time(nullptr)) { newSamples.resize(nbSamples); @@ -100,7 +102,7 @@ void jitterSamples(const SampleVectorType& inSamples, auto stds = estimateStds(inSamples); std::vector<std::normal_distribution<double>> gaussDis; for(size_t i=0; i<nbComponents; ++i) - gaussDis.emplace_back(std::normal_distribution<double>{0.0, stds[i]*stdFactor}); + gaussDis.emplace_back(std::normal_distribution<double>{0.0, stds[i]/stdFactor}); for(size_t i=0; i<nbSamples; ++i) { newSamples[i] = inSamples[std::rand()%nbSamples]; diff --git a/Modules/Applications/AppClassification/test/CMakeLists.txt b/Modules/Applications/AppClassification/test/CMakeLists.txt index c0ec37fea3..c134b6b355 100644 --- a/Modules/Applications/AppClassification/test/CMakeLists.txt +++ b/Modules/Applications/AppClassification/test/CMakeLists.txt @@ -974,12 +974,37 @@ otb_test_application( ) #------------ SampleAgmentation TESTS ---------------- -otb_test_application(NAME apTvClSampleAugmentation +otb_test_application(NAME apTvClSampleAugmentationReplicate APP SampleAugmentation OPTIONS -in ${INPUTDATA}/Classification/apTvClSampleExtractionOut.sqlite -field class -label 3 -samples 100 - -out ${TEMP}/apTvClSampleAugmentation.sqlite + -out ${TEMP}/apTvClSampleAugmentationReplicate.sqlite -exclude originfid + -strategy replicate + ) + +otb_test_application(NAME apTvClSampleAugmentationJitter + APP SampleAugmentation + OPTIONS -in ${INPUTDATA}/Classification/apTvClSampleExtractionOut.sqlite + -field class + -label 3 + -samples 100 + -out ${TEMP}/apTvClSampleAugmentationJitter.sqlite + -exclude originfid + -strategy jitter + -strategy.jitter.stdfactor 10000 + ) + +otb_test_application(NAME apTvClSampleAugmentationSmote + APP SampleAugmentation + OPTIONS -in ${INPUTDATA}/Classification/apTvClSampleExtractionOut.sqlite + -field class + -label 3 + -samples 100 + -out ${TEMP}/apTvClSampleAugmentationSmote.sqlite + -exclude originfid + -strategy smote + -strategy.smote.neighbors 5 ) -- GitLab From d61a7165289da7252d9bc52977e6fe8d974c992f Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 28 Feb 2018 08:01:00 +0100 Subject: [PATCH 333/567] ENH: prepare the OGR extended filename service --- .../otbOGRExtendedFilenameToReaderOptions.h | 72 +++++++++++++++++++ .../otbOGRExtendedFilenameToWriterOptions.h | 39 ++++++++++ .../Adapters/GdalAdapters/src/CMakeLists.txt | 2 + .../otbOGRExtendedFilenameToReaderOptions.cxx | 51 +++++++++++++ .../otbOGRExtendedFilenameToWriterOptions.cxx | 27 +++++++ .../include/otbExtendedFilenameHelper.h | 3 +- Modules/Core/Common/otb-module.cmake | 2 + Modules/Core/Common/src/CMakeLists.txt | 2 +- .../Common}/src/otbExtendedFilenameHelper.cxx | 0 Modules/IO/ExtendedFilename/otb-module.cmake | 2 +- .../IO/ExtendedFilename/src/CMakeLists.txt | 4 +- 11 files changed, 198 insertions(+), 6 deletions(-) create mode 100644 Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h create mode 100644 Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h create mode 100644 Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx create mode 100644 Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx rename Modules/{IO/ExtendedFilename => Core/Common}/include/otbExtendedFilenameHelper.h (96%) rename Modules/{IO/ExtendedFilename => Core/Common}/src/otbExtendedFilenameHelper.cxx (100%) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h new file mode 100644 index 0000000000..0f5f47df6d --- /dev/null +++ b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbOGRExtendedFilenameToReaderOptions_h +#define otbOGRExtendedFilenameToReaderOptions_h + +#include <set> +#include "otbExtendedFilenameHelper.h" + +namespace otb +{ + +/** \class OGRExtendedFilenameToReaderOptions + */ + +class ITK_EXPORT OGRExtendedFilenameToReaderOptions : public ExtendedFilenameHelper +{ +public: + /** Standard class typedefs. */ + typedef OGRExtendedFilenameToReaderOptions Self; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + typedef ExtendedFilenameHelper Superclass; + + typedef Superclass::OptionMapType OptionMapType; + typedef OptionMapType::iterator MapIteratorType; + + itkTypeMacro(OGRExtendedFilenameToReaderOptions, otb::ExtendedFilenameHelper); + itkNewMacro(Self); + + /** The creation option structure. */ + struct OptionType + { + std::pair< bool , std::string > simpleFileName; + std::pair< bool , std::string > shapeFileType; + std::set< std::string > availableOptions; + }; + + /* Set Methods */ + void SetExtendedFileName(const char * extFname) override; + +protected: + OGRExtendedFilenameToReaderOptions(); + ~OGRExtendedFilenameToReaderOptions() override {}; + +private: + OGRExtendedFilenameToReaderOptions(const Self &) = delete ; + void operator =(const Self&) = delete ; + + OptionType m_Options; +}; + +} //end namespace otb + +#endif // otbOGRExtendedFilenameToReaderOptions_h diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h new file mode 100644 index 0000000000..8c8422166f --- /dev/null +++ b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbOGRExtendedFilenameToWriterOptions_h +#define otbOGRExtendedFilenameToWriterOptions_h + +#include "otbExtendedFilenameHelper.h" + +namespace otb +{ + +/** \class OGRExtendedFilenameToWriterOptions + */ + +class ITK_EXPORT OGRExtendedFilenameToWriterOptions : public ExtendedFilenameHelper +{ +public: +}; + +} //end namespace otb + +#endif // otbOGRExtendedFilenameToWriterOptions_h \ No newline at end of file diff --git a/Modules/Adapters/GdalAdapters/src/CMakeLists.txt b/Modules/Adapters/GdalAdapters/src/CMakeLists.txt index 4ba50ff1e2..0cfe725108 100644 --- a/Modules/Adapters/GdalAdapters/src/CMakeLists.txt +++ b/Modules/Adapters/GdalAdapters/src/CMakeLists.txt @@ -29,6 +29,8 @@ set(OTBGdalAdapters_SRC otbGeometriesToGeometriesFilter.cxx otbOGRDataSourceWrapper.cxx otbOGRVersionProxy.cxx + otbOGRExtendedFilenameToReaderOptions.cxx + otbOGRExtendedFilenameToWriterOptions.cxx ) add_library(OTBGdalAdapters ${OTBGdalAdapters_SRC}) diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx new file mode 100644 index 0000000000..e82b738c35 --- /dev/null +++ b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbOGRExtendedFilenameToReaderOptions.h" + +namespace otb +{ + +OGRExtendedFilenameToReaderOptions:: +OGRExtendedFilenameToReaderOptions() +{ + m_Options.simpleFileName.first = false; + m_Options.simpleFileName.second = ""; + + m_Options.shapeFileType.first = false; + m_Options.shapeFileType.second = ""; + + m_Options.availableOptions.insert("shpt"); +} + +void +OGRExtendedFilenameToReaderOptions:: +SetExtendedFileName(const char *extFname) +{ + Superclass::SetExtendedFileName(extFname); + OptionMapType map = GetOptionMap(); + + m_Options.simpleFileName.first = true; + m_Options.simpleFileName.second = this->GetSimpleFileName(); + +} + + +} //end namespace otb diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx new file mode 100644 index 0000000000..dc491e3680 --- /dev/null +++ b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbOGRExtendedFilenameToReaderOptions.h" + +namespace otb +{ + + +} //end namespace otb \ No newline at end of file diff --git a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameHelper.h b/Modules/Core/Common/include/otbExtendedFilenameHelper.h similarity index 96% rename from Modules/IO/ExtendedFilename/include/otbExtendedFilenameHelper.h rename to Modules/Core/Common/include/otbExtendedFilenameHelper.h index b6d29171cd..018647b821 100644 --- a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameHelper.h +++ b/Modules/Core/Common/include/otbExtendedFilenameHelper.h @@ -23,6 +23,7 @@ #include "itkObject.h" #include "itkObjectFactory.h" +#include "OTBCommonExport.h" namespace otb { @@ -35,7 +36,7 @@ namespace otb * \ingroup OTBExtendedFilename */ -class ITK_EXPORT ExtendedFilenameHelper : public itk::Object +class OTBCommon_EXPORT ExtendedFilenameHelper : public itk::Object { public: /** Standard class typedefs. */ diff --git a/Modules/Core/Common/otb-module.cmake b/Modules/Core/Common/otb-module.cmake index 97ba992dd7..b3276d6942 100644 --- a/Modules/Core/Common/otb-module.cmake +++ b/Modules/Core/Common/otb-module.cmake @@ -27,6 +27,8 @@ ENABLE_SHARED OTBITK #Add dependency to OTBGDAL as GDAL module need to set OTB_USE_GDAL_20 before configuring otbConfigure.h OTBGDAL + #Add dependency for extended filename helper class + OTBBoostAdapters TEST_DEPENDS OTBImageBase diff --git a/Modules/Core/Common/src/CMakeLists.txt b/Modules/Core/Common/src/CMakeLists.txt index 02ff6250e7..9f7cbe71db 100644 --- a/Modules/Core/Common/src/CMakeLists.txt +++ b/Modules/Core/Common/src/CMakeLists.txt @@ -29,12 +29,12 @@ set(OTBCommon_SRC otbWriterWatcherBase.cxx otbStopwatch.cxx otbStringToHTML.cxx + otbExtendedFilenameHelper.cxx ) add_library(OTBCommon ${OTBCommon_SRC}) target_link_libraries(OTBCommon ${OTBITK_LIBRARIES} - ) otb_module_target(OTBCommon) diff --git a/Modules/IO/ExtendedFilename/src/otbExtendedFilenameHelper.cxx b/Modules/Core/Common/src/otbExtendedFilenameHelper.cxx similarity index 100% rename from Modules/IO/ExtendedFilename/src/otbExtendedFilenameHelper.cxx rename to Modules/Core/Common/src/otbExtendedFilenameHelper.cxx diff --git a/Modules/IO/ExtendedFilename/otb-module.cmake b/Modules/IO/ExtendedFilename/otb-module.cmake index cf194a8edd..1e46b70a5b 100644 --- a/Modules/IO/ExtendedFilename/otb-module.cmake +++ b/Modules/IO/ExtendedFilename/otb-module.cmake @@ -26,8 +26,8 @@ product by skipping either geographic or sensor-model information.") otb_module(OTBExtendedFilename DEPENDS + OTBCommon OTBIOGDAL - OTBBoostAdapters OTBITK TEST_DEPENDS diff --git a/Modules/IO/ExtendedFilename/src/CMakeLists.txt b/Modules/IO/ExtendedFilename/src/CMakeLists.txt index 033f0db2d9..35ec302ad4 100644 --- a/Modules/IO/ExtendedFilename/src/CMakeLists.txt +++ b/Modules/IO/ExtendedFilename/src/CMakeLists.txt @@ -20,15 +20,13 @@ set(OTBExtendedFilename_SRC otbExtendedFilenameToReaderOptions.cxx - otbExtendedFilenameHelper.cxx otbExtendedFilenameToWriterOptions.cxx ) add_library(OTBExtendedFilename ${OTBExtendedFilename_SRC}) target_link_libraries(OTBExtendedFilename + ${OTBCommon_LIBRARIES} ${OTBIOGDAL_LIBRARIES} - ${OTBBoost_LIBRARIES} - ) otb_module_target(OTBExtendedFilename) -- GitLab From cdaf666cfe76b2271d6771fc707b560264d9291e Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 28 Feb 2018 08:01:00 +0100 Subject: [PATCH 334/567] ENH: prepare the OGR extended filename service --- .../otbOGRExtendedFilenameToReaderOptions.h | 72 +++++++++++++++++++ .../otbOGRExtendedFilenameToWriterOptions.h | 39 ++++++++++ .../Adapters/GdalAdapters/src/CMakeLists.txt | 2 + .../otbOGRExtendedFilenameToReaderOptions.cxx | 52 ++++++++++++++ .../otbOGRExtendedFilenameToWriterOptions.cxx | 27 +++++++ .../include/otbExtendedFilenameHelper.h | 3 +- Modules/Core/Common/otb-module.cmake | 2 + Modules/Core/Common/src/CMakeLists.txt | 2 +- .../Common}/src/otbExtendedFilenameHelper.cxx | 0 Modules/IO/ExtendedFilename/otb-module.cmake | 2 +- .../IO/ExtendedFilename/src/CMakeLists.txt | 4 +- 11 files changed, 199 insertions(+), 6 deletions(-) create mode 100644 Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h create mode 100644 Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h create mode 100644 Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx create mode 100644 Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx rename Modules/{IO/ExtendedFilename => Core/Common}/include/otbExtendedFilenameHelper.h (96%) rename Modules/{IO/ExtendedFilename => Core/Common}/src/otbExtendedFilenameHelper.cxx (100%) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h new file mode 100644 index 0000000000..4aa7b78b31 --- /dev/null +++ b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbOGRExtendedFilenameToReaderOptions_h +#define otbOGRExtendedFilenameToReaderOptions_h + +#include <set> +#include "otbExtendedFilenameHelper.h" + +namespace otb +{ + +/** \class OGRExtendedFilenameToReaderOptions + */ + +class ITK_EXPORT OGRExtendedFilenameToReaderOptions : public ExtendedFilenameHelper +{ +public: + /** Standard class typedefs. */ + typedef OGRExtendedFilenameToReaderOptions Self; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + typedef ExtendedFilenameHelper Superclass; + + typedef Superclass::OptionMapType OptionMapType; + typedef OptionMapType::iterator MapIteratorType; + + itkTypeMacro(OGRExtendedFilenameToReaderOptions, otb::ExtendedFilenameHelper); + itkNewMacro(Self); + + /** The creation option structure. */ + struct OptionType + { + std::pair< bool , std::string > simpleFileName; + std::pair< bool , std::string > encoding; + std::set< std::string > availableOptions; + }; + + /* Set Methods */ + void SetExtendedFileName(const char * extFname) override; + +protected: + OGRExtendedFilenameToReaderOptions(); + ~OGRExtendedFilenameToReaderOptions() override {}; + +private: + OGRExtendedFilenameToReaderOptions(const Self &) = delete ; + void operator =(const Self&) = delete ; + + OptionType m_Options; +}; + +} //end namespace otb + +#endif // otbOGRExtendedFilenameToReaderOptions_h diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h new file mode 100644 index 0000000000..8c8422166f --- /dev/null +++ b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbOGRExtendedFilenameToWriterOptions_h +#define otbOGRExtendedFilenameToWriterOptions_h + +#include "otbExtendedFilenameHelper.h" + +namespace otb +{ + +/** \class OGRExtendedFilenameToWriterOptions + */ + +class ITK_EXPORT OGRExtendedFilenameToWriterOptions : public ExtendedFilenameHelper +{ +public: +}; + +} //end namespace otb + +#endif // otbOGRExtendedFilenameToWriterOptions_h \ No newline at end of file diff --git a/Modules/Adapters/GdalAdapters/src/CMakeLists.txt b/Modules/Adapters/GdalAdapters/src/CMakeLists.txt index 4ba50ff1e2..0cfe725108 100644 --- a/Modules/Adapters/GdalAdapters/src/CMakeLists.txt +++ b/Modules/Adapters/GdalAdapters/src/CMakeLists.txt @@ -29,6 +29,8 @@ set(OTBGdalAdapters_SRC otbGeometriesToGeometriesFilter.cxx otbOGRDataSourceWrapper.cxx otbOGRVersionProxy.cxx + otbOGRExtendedFilenameToReaderOptions.cxx + otbOGRExtendedFilenameToWriterOptions.cxx ) add_library(OTBGdalAdapters ${OTBGdalAdapters_SRC}) diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx new file mode 100644 index 0000000000..73fb4b311c --- /dev/null +++ b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbOGRExtendedFilenameToReaderOptions.h" + +namespace otb +{ + +OGRExtendedFilenameToReaderOptions:: +OGRExtendedFilenameToReaderOptions() +{ + m_Options.simpleFileName.first = false; + m_Options.simpleFileName.second = ""; + + m_Options.encoding.first = false; + m_Options.encoding.second = ""; + + m_Options.availableOptions.insert("encoding"); +} + +void +OGRExtendedFilenameToReaderOptions:: +SetExtendedFileName(const char *extFname) +{ + Superclass::SetExtendedFileName(extFname); + OptionMapType map = GetOptionMap(); + + m_Options.simpleFileName.first = true; + m_Options.simpleFileName.second = this->GetSimpleFileName(); + + +} + + +} //end namespace otb diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx new file mode 100644 index 0000000000..dc491e3680 --- /dev/null +++ b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbOGRExtendedFilenameToReaderOptions.h" + +namespace otb +{ + + +} //end namespace otb \ No newline at end of file diff --git a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameHelper.h b/Modules/Core/Common/include/otbExtendedFilenameHelper.h similarity index 96% rename from Modules/IO/ExtendedFilename/include/otbExtendedFilenameHelper.h rename to Modules/Core/Common/include/otbExtendedFilenameHelper.h index b6d29171cd..018647b821 100644 --- a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameHelper.h +++ b/Modules/Core/Common/include/otbExtendedFilenameHelper.h @@ -23,6 +23,7 @@ #include "itkObject.h" #include "itkObjectFactory.h" +#include "OTBCommonExport.h" namespace otb { @@ -35,7 +36,7 @@ namespace otb * \ingroup OTBExtendedFilename */ -class ITK_EXPORT ExtendedFilenameHelper : public itk::Object +class OTBCommon_EXPORT ExtendedFilenameHelper : public itk::Object { public: /** Standard class typedefs. */ diff --git a/Modules/Core/Common/otb-module.cmake b/Modules/Core/Common/otb-module.cmake index 97ba992dd7..b3276d6942 100644 --- a/Modules/Core/Common/otb-module.cmake +++ b/Modules/Core/Common/otb-module.cmake @@ -27,6 +27,8 @@ ENABLE_SHARED OTBITK #Add dependency to OTBGDAL as GDAL module need to set OTB_USE_GDAL_20 before configuring otbConfigure.h OTBGDAL + #Add dependency for extended filename helper class + OTBBoostAdapters TEST_DEPENDS OTBImageBase diff --git a/Modules/Core/Common/src/CMakeLists.txt b/Modules/Core/Common/src/CMakeLists.txt index 02ff6250e7..9f7cbe71db 100644 --- a/Modules/Core/Common/src/CMakeLists.txt +++ b/Modules/Core/Common/src/CMakeLists.txt @@ -29,12 +29,12 @@ set(OTBCommon_SRC otbWriterWatcherBase.cxx otbStopwatch.cxx otbStringToHTML.cxx + otbExtendedFilenameHelper.cxx ) add_library(OTBCommon ${OTBCommon_SRC}) target_link_libraries(OTBCommon ${OTBITK_LIBRARIES} - ) otb_module_target(OTBCommon) diff --git a/Modules/IO/ExtendedFilename/src/otbExtendedFilenameHelper.cxx b/Modules/Core/Common/src/otbExtendedFilenameHelper.cxx similarity index 100% rename from Modules/IO/ExtendedFilename/src/otbExtendedFilenameHelper.cxx rename to Modules/Core/Common/src/otbExtendedFilenameHelper.cxx diff --git a/Modules/IO/ExtendedFilename/otb-module.cmake b/Modules/IO/ExtendedFilename/otb-module.cmake index cf194a8edd..1e46b70a5b 100644 --- a/Modules/IO/ExtendedFilename/otb-module.cmake +++ b/Modules/IO/ExtendedFilename/otb-module.cmake @@ -26,8 +26,8 @@ product by skipping either geographic or sensor-model information.") otb_module(OTBExtendedFilename DEPENDS + OTBCommon OTBIOGDAL - OTBBoostAdapters OTBITK TEST_DEPENDS diff --git a/Modules/IO/ExtendedFilename/src/CMakeLists.txt b/Modules/IO/ExtendedFilename/src/CMakeLists.txt index 033f0db2d9..35ec302ad4 100644 --- a/Modules/IO/ExtendedFilename/src/CMakeLists.txt +++ b/Modules/IO/ExtendedFilename/src/CMakeLists.txt @@ -20,15 +20,13 @@ set(OTBExtendedFilename_SRC otbExtendedFilenameToReaderOptions.cxx - otbExtendedFilenameHelper.cxx otbExtendedFilenameToWriterOptions.cxx ) add_library(OTBExtendedFilename ${OTBExtendedFilename_SRC}) target_link_libraries(OTBExtendedFilename + ${OTBCommon_LIBRARIES} ${OTBIOGDAL_LIBRARIES} - ${OTBBoost_LIBRARIES} - ) otb_module_target(OTBExtendedFilename) -- GitLab From 7e38156c0d5f81ddc3315844cad849730286e651 Mon Sep 17 00:00:00 2001 From: Yannick TANGUY <yannick.tanguy@cnes.fr> Date: Wed, 28 Feb 2018 10:20:41 +0100 Subject: [PATCH 335/567] Add definition of core developers --- PSC.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PSC.md b/PSC.md index 848da5edce..9552a3141f 100644 --- a/PSC.md +++ b/PSC.md @@ -148,7 +148,7 @@ Merge Requests must be provided to a git hosted platform (GitLab, GitHub, etc.). Merge request can be discussed on the developer list or directly on GitLab. Votes are necessary to accept Merge Request : -- Core developers members can vote +- Core developers (PSC members + 'Master' members in Gitlab) can vote - At least two +1 are necessary - PSC members have veto -- GitLab From 5fb9e14169a05870e1b22dad95ae37b455174477 Mon Sep 17 00:00:00 2001 From: Yannick TANGUY <yannick.tanguy@cnes.fr> Date: Wed, 28 Feb 2018 10:22:33 +0100 Subject: [PATCH 336/567] Add definition of core developers --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f2b219ad78..b98c3b7209 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,7 +90,7 @@ template. The merge request will then be discussed by the community and the core OTB team. * Merge requests can not be merged until all discussions have been resolved (this is enforced by GitLab) -* Merge requests **must receive at least 2 positives votes from core developers** before being merged +* Merge requests **must receive at least 2 positives votes from core developers** ("Master" members in Gitlab : include PSC members) before being merged * The merger is responsible for checking that the branch is up-to-date with develop * Merge requests can be merged by anyone (not just PSC or RM) with push access to develop * Merge requests can be merged once the dashboard is proven green for this branch -- GitLab From 85d3d9b4e8e2a4472acf852ab573042fa939ea59 Mon Sep 17 00:00:00 2001 From: Yannick TANGUY <yannick.tanguy@cnes.fr> Date: Wed, 28 Feb 2018 10:27:01 +0100 Subject: [PATCH 337/567] change definition : "master" members include PSC members and other core developers --- PSC.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PSC.md b/PSC.md index 9552a3141f..cb617baf96 100644 --- a/PSC.md +++ b/PSC.md @@ -148,7 +148,7 @@ Merge Requests must be provided to a git hosted platform (GitLab, GitHub, etc.). Merge request can be discussed on the developer list or directly on GitLab. Votes are necessary to accept Merge Request : -- Core developers (PSC members + 'Master' members in Gitlab) can vote +- Core developers ('Master' members in Gitlab ; it includes PSC members) can vote - At least two +1 are necessary - PSC members have veto -- GitLab From c8f4b7bc3b3bc4e08ef0c147ff8788e67851471e Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 28 Feb 2018 17:08:25 +0100 Subject: [PATCH 338/567] ENH: return the ImageKeywordlist itself --- .../ApplicationEngine/include/otbWrapperApplication.h | 2 +- .../ApplicationEngine/src/otbWrapperApplication.cxx | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index ef2b24a364..9315a6a525 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -875,7 +875,7 @@ public: /** Get the keywordlist of the image parameter 'key'. The optional 'idx' * allows to select the image in an InputImageList.*/ - std::map<std::string,std::string> GetImageKeywordlist(const std::string & key, unsigned int idx = 0); + otb::ImageKeywordlist GetImageKeywordlist(const std::string & key, unsigned int idx = 0); /** Set the requested region on the image parameter 'key' and propagate it. * The returned value is an estimate of the RAM usage (in Bytes) to process diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 623a026e11..2c2dddbf4c 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1741,18 +1741,17 @@ Application::GetImageProjection(const std::string & key, unsigned int idx) return proj; } -std::map<std::string,std::string> +otb::ImageKeywordlist Application::GetImageKeywordlist(const std::string & key, unsigned int idx) { ImageKeywordlist kwl; const itk::MetaDataDictionary& dict = this->GetParameterImageBase(key, idx)->GetMetaDataDictionary(); - if (!dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) - return std::map<std::string,std::string>(); + if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) + itk::ExposeMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey, kwl); - itk::ExposeMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey, kwl); - return kwl.GetKeywordlist(); + return kwl; } unsigned long -- GitLab From 33fd99b410ba0e3da929901d702eb247137e4fad Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 28 Feb 2018 17:09:20 +0100 Subject: [PATCH 339/567] ENH: new function to return the full MetaDataDictionary --- .../ApplicationEngine/include/otbWrapperApplication.h | 3 +++ .../ApplicationEngine/src/otbWrapperApplication.cxx | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 9315a6a525..0825ad392a 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -889,6 +889,9 @@ public: * the index of the largest possible region starts at (0,0).*/ ImageBaseType::RegionType GetImageRequestedRegion(const std::string & key, unsigned int idx = 0); + /** Returns a copy of the metadata dictionary of the image */ + itk::MetaDataDictionary GetImageMetaData(const std::string & key, unsigned int idx = 0); + protected: /** Constructor */ Application(); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 2c2dddbf4c..9ca4a95a56 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1784,6 +1784,13 @@ Application::GetImageRequestedRegion(const std::string & key, unsigned int idx) return requested; } +itk::MetaDataDictionary +Application::GetImageMetaData(const std::string & key, unsigned int idx) +{ + ImageBaseType* image = this->GetParameterImageBase(key, idx); + return image->GetMetaDataDictionary(); +} + ImageBaseType* Application::GetParameterImageBase(const std::string & key, unsigned int idx) { -- GitLab From f58c1419638338b09dde590b22f1d82a162e47c2 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 28 Feb 2018 17:15:51 +0100 Subject: [PATCH 340/567] TEST: update the test for new image services --- .../test/otbWrapperImageInterface.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx b/Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx index 4f06dc1906..56c1cba520 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx +++ b/Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx @@ -61,13 +61,15 @@ int otbWrapperImageInterface(int argc, char * argv[]) ofs << "Origin: "<< app1->GetImageOrigin("out") << std::endl; ofs << "Spacing: "<< app1->GetImageSpacing("out") << std::endl; ofs << "Keywordlist: "<< std::endl; - for (auto item : app1->GetImageKeywordlist("out")) - { - ofs <<" ["<<item.first<<"] = "<<item.second << std::endl; - } - ofs << "ProjectionRef: "<< std::endl; + otb::ImageKeywordlist kwl = app1->GetImageKeywordlist("out"); + kwl.Print(ofs); + ofs << "ProjectionRef:"<< std::endl; ofs << app1->GetImageProjection("out") << std::endl; + itk::MetaDataDictionary dict = app1->GetImageMetaData("out"); + ofs << "Dictionary:"<< std::endl; + dict.Print(ofs); + otb::Wrapper::ImageBaseType::RegionType region; region.SetIndex(0,10); region.SetIndex(1,10); -- GitLab From 230e4081018c00c1b8d33524a7b5b85151afb39d Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 28 Feb 2018 17:19:19 +0100 Subject: [PATCH 341/567] ADD: new helper class to handle itk::MetaDataDictionary --- .../include/otbWrapperMetaDataHelper.h | 133 ++++++++++ .../ApplicationEngine/src/CMakeLists.txt | 1 + .../src/otbWrapperMetaDataHelper.cxx | 227 ++++++++++++++++++ 3 files changed, 361 insertions(+) create mode 100644 Modules/Wrappers/ApplicationEngine/include/otbWrapperMetaDataHelper.h create mode 100644 Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperMetaDataHelper.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperMetaDataHelper.h new file mode 100644 index 0000000000..e2d2926799 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperMetaDataHelper.h @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbWrapperMetaDataHelper_h +#define otbWrapperMetaDataHelper_h + +#include "otbMetaDataKey.h" +#include "otbImageKeywordlist.h" +#include "otbVectorDataKeywordlist.h" +#include "itkMetaDataDictionary.h" +#include "OTBApplicationEngineExport.h" + +namespace otb +{ +namespace Wrapper +{ + +/** + * \class MetaDataHelper + * + * \brief Small helper to manipulate itk::MetaDataDictionary + * + * This class is only here to instanciate the different template function that + * allow to get/set values in MetaDataDictionary. All functions are static. + * + * \ingroup OTBApplicationEngine + */ +class OTBApplicationEngine_EXPORT MetaDataHelper +{ +public: + MetaDataHelper(); + virtual ~MetaDataHelper(); + + typedef enum + { + MDType_STRING, + MDType_INT, + MDType_DOUBLE, + MDType_GCP, + MDType_VECTOR, + MDType_IMAGEKWL, + MDType_VECTORDATAKWL, + MDType_BOOLVECTOR + } MDType; + + static MDType GetType(const std::string &val); + + static std::string GetString( + const itk::MetaDataDictionary &dict, + const std::string &key); + static void SetString( + itk::MetaDataDictionary &dict, + const std::string &key, + const std::string &val); + + static unsigned int GetInt( + const itk::MetaDataDictionary &dict, + const std::string &key); + static void SetInt( + itk::MetaDataDictionary &dict, + const std::string &key, + unsigned int val); + + static double GetDouble( + const itk::MetaDataDictionary &dict, + const std::string &key); + static void SetDouble( + itk::MetaDataDictionary &dict, + const std::string &key, + double val); + + static otb::OTB_GCP GetGCP( + const itk::MetaDataDictionary &dict, + const std::string &key); + static void SetGCP( + itk::MetaDataDictionary &dict, + const std::string &key, + const otb::OTB_GCP &val); + + static otb::MetaDataKey::VectorType GetVector( + const itk::MetaDataDictionary &dict, + const std::string &key); + static void SetVector( + itk::MetaDataDictionary &dict, + const std::string &key, + const otb::MetaDataKey::VectorType &val); + + static otb::ImageKeywordlist GetImageKWL( + const itk::MetaDataDictionary &dict, + const std::string &key); + static void SetImageKWL( + itk::MetaDataDictionary &dict, + const std::string &key, + const otb::ImageKeywordlist &val); + + static otb::VectorDataKeywordlist GetVectorDataKWL( + const itk::MetaDataDictionary &dict, + const std::string &key); + static void SetVectorDataKWL( + itk::MetaDataDictionary &dict, + const std::string &key, + const otb::VectorDataKeywordlist &val); + + static otb::MetaDataKey::BoolVectorType GetBoolVector( + const itk::MetaDataDictionary &dict, + const std::string &key); + static void SetBoolVector( + itk::MetaDataDictionary &dict, + const std::string &key, + const otb::MetaDataKey::BoolVectorType &val); +}; + +} // end of namespace Wrapper +} // end of namespace otb + +#endif diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 343f9db835..003014728f 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -53,6 +53,7 @@ set( OTBApplicationEngine_SRC otbWrapperAbstractParameterList.cxx otbWrapperParameterList.cxx otbLogger.cxx + otbWrapperMetaDataHelper.cxx ) add_library(OTBApplicationEngine ${OTBApplicationEngine_SRC}) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx new file mode 100644 index 0000000000..661d5c6264 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperMetaDataHelper.h" +#include "itkMetaDataObject.h" + +namespace otb +{ +namespace Wrapper +{ + +MetaDataHelper::MetaDataHelper() +{ +} + +MetaDataHelper::~MetaDataHelper() +{ +} + +MetaDataHelper::MDType +MetaDataHelper::GetType(const std::string &val) +{ + MDType ret; + otb::MetaDataKey::KeyType kt = otb::MetaDataKey::GetKeyType(val); + switch (kt) + { + case otb::MetaDataKey::TSTRING: + ret = MDType_STRING; + break; + case otb::MetaDataKey::TENTIER: + ret = MDType_INT; + break; + case otb::MetaDataKey::TDOUBLE: + ret = MDType_DOUBLE; + break; + case otb::MetaDataKey::TOTB_GCP: + ret = MDType_GCP; + break; + case otb::MetaDataKey::TVECTOR: + ret = MDType_VECTOR; + break; + case otb::MetaDataKey::TOSSIMKEYWORDLIST: + ret = MDType_IMAGEKWL; + break; + case otb::MetaDataKey::TVECTORDATAKEYWORDLIST: + ret = MDType_VECTORDATAKWL; + break; + case otb::MetaDataKey::TBOOLVECTOR: + ret = MDType_BOOLVECTOR; + break; + default: + break; + } + return ret; +} + +std::string +MetaDataHelper::GetString( + const itk::MetaDataDictionary &dict, + const std::string &key) +{ + std::string ret; + itk::ExposeMetaData<std::string>(dict, key, ret); + return ret; +} + +void +MetaDataHelper::SetString( + itk::MetaDataDictionary &dict, + const std::string &key, + const std::string &val) +{ + itk::EncapsulateMetaData<std::string>(dict, key, val); +} + +unsigned int +MetaDataHelper::GetInt( + const itk::MetaDataDictionary &dict, + const std::string &key) +{ + unsigned int ret; + itk::ExposeMetaData<unsigned int>(dict, key, ret); + return ret; +} + +void +MetaDataHelper::SetInt( + itk::MetaDataDictionary &dict, + const std::string &key, + unsigned int val) +{ + itk::EncapsulateMetaData<unsigned int>(dict, key, val); +} + +double +MetaDataHelper::GetDouble( + const itk::MetaDataDictionary &dict, + const std::string &key) +{ + double ret; + itk::ExposeMetaData<double>(dict, key, ret); + return ret; +} + +void +MetaDataHelper::SetDouble( + itk::MetaDataDictionary &dict, + const std::string &key, + double val) +{ + itk::EncapsulateMetaData<double>(dict, key, val); +} + +otb::OTB_GCP +MetaDataHelper::GetGCP( + const itk::MetaDataDictionary &dict, + const std::string &key) +{ + otb::OTB_GCP ret; + itk::ExposeMetaData<otb::OTB_GCP>(dict, key, ret); + return ret; +} + +void +MetaDataHelper::SetGCP( + itk::MetaDataDictionary &dict, + const std::string &key, + const otb::OTB_GCP &val) +{ + itk::EncapsulateMetaData<otb::OTB_GCP>(dict, key, val); +} + +otb::MetaDataKey::VectorType +MetaDataHelper::GetVector( + const itk::MetaDataDictionary &dict, + const std::string &key) +{ + otb::MetaDataKey::VectorType ret; + itk::ExposeMetaData<otb::MetaDataKey::VectorType>(dict, key, ret); + return ret; +} + +void +MetaDataHelper::SetVector( + itk::MetaDataDictionary &dict, + const std::string &key, + const otb::MetaDataKey::VectorType &val) +{ + itk::EncapsulateMetaData<otb::MetaDataKey::VectorType>(dict, key, val); +} + +otb::ImageKeywordlist +MetaDataHelper::GetImageKWL( + const itk::MetaDataDictionary &dict, + const std::string &key) +{ + otb::ImageKeywordlist ret; + itk::ExposeMetaData<otb::ImageKeywordlist>(dict, key, ret); + return ret; +} + +void +MetaDataHelper::SetImageKWL( + itk::MetaDataDictionary &dict, + const std::string &key, + const otb::ImageKeywordlist &val) +{ + itk::EncapsulateMetaData<otb::ImageKeywordlist>(dict, key, val); +} + +otb::VectorDataKeywordlist +MetaDataHelper::GetVectorDataKWL( + const itk::MetaDataDictionary &dict, + const std::string &key) +{ + otb::VectorDataKeywordlist ret; + itk::ExposeMetaData<otb::VectorDataKeywordlist>(dict, key, ret); + return ret; +} + +void +MetaDataHelper::SetVectorDataKWL( + itk::MetaDataDictionary &dict, + const std::string &key, + const otb::VectorDataKeywordlist &val) +{ + itk::EncapsulateMetaData<otb::VectorDataKeywordlist>(dict, key, val); +} + +otb::MetaDataKey::BoolVectorType +MetaDataHelper::GetBoolVector( + const itk::MetaDataDictionary &dict, + const std::string &key) +{ + otb::MetaDataKey::BoolVectorType ret; + itk::ExposeMetaData<otb::MetaDataKey::BoolVectorType>(dict, key, ret); + return ret; +} + +void +MetaDataHelper::SetBoolVector( + itk::MetaDataDictionary &dict, + const std::string &key, + const otb::MetaDataKey::BoolVectorType &val) +{ + itk::EncapsulateMetaData<otb::MetaDataKey::BoolVectorType>(dict, key, val); +} + +} // end of namespace Wrapper +} // end of namespace otb -- GitLab From 043480e342cd3df6059bb573a3544303665625ef Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 28 Feb 2018 17:20:43 +0100 Subject: [PATCH 342/567] ENH: move wrapping of ITK classes in itkBase --- Modules/Wrappers/SWIG/src/itkBase.i | 208 ++++++++++++++++++++- Modules/Wrappers/SWIG/src/itkBase.includes | 2 + 2 files changed, 209 insertions(+), 1 deletion(-) diff --git a/Modules/Wrappers/SWIG/src/itkBase.i b/Modules/Wrappers/SWIG/src/itkBase.i index 2a15719f26..b9e5e3a06d 100644 --- a/Modules/Wrappers/SWIG/src/itkBase.i +++ b/Modules/Wrappers/SWIG/src/itkBase.i @@ -44,13 +44,191 @@ } } +// BASIC ITK TYPES WRAPPING +%include "itkFloatTypes.h" +%include "itkIntTypes.h" + // Some code from STL // Do not wrap if not necessary as it really slows down compilation %include <std_string.i> %include <std_vector.i> +%include <std_map.i> + +%template(vectorstring) std::vector< std::string >; +%template(mapstringstring) std::map< std::string, std::string >; +%template(vectorbool) std::vector<bool>; +%template(vectordouble) std::vector<double>; + +#if SWIGPYTHON +%extend std::map< std::string, std::string > +{ + %pythoncode + { + def __str__(self): + ret = "{" + for key in self: + ret += str(key)+":"+str(self[key])+", " + if len(ret) == 1: + ret += ", " + return ret[:-2]+"}" + } +}; +#endif + +//---------------- ITK classes ------------------------------------ + +namespace itk +{ + +template <unsigned int VDim = 2> +class Size +{ +public: + Size(); + virtual ~Size(); + void Fill(unsigned long val); + SizeValueType GetElement(unsigned long element) const; + void SetElement(unsigned long element, SizeValueType val); + static unsigned int GetSizeDimension(); +}; + +template <unsigned int VDim = 2> +class Index +{ +public: + Index(); + virtual ~Index(); + void Fill(signed long val); + IndexValueType GetElement(unsigned long element) const; + void SetElement(unsigned long element, IndexValueType val); + static unsigned int GetIndexDimension(); +}; + +template <unsigned int VDim> +class ImageRegion +{ +public: + ImageRegion(); + ImageRegion(const Index<VDim> &index, const Size<VDim> &size); + virtual ~ImageRegion(); + void SetIndex(const Index<VDim> &index); + void SetSize(const Size<VDim> &size); + void SetUpperIndex(const Index<VDim> &idx); + Index<VDim> GetUpperIndex() const; + const Index<VDim> & GetIndex() const; + const Size<VDim> & GetSize() const; + bool IsInside(const Index<VDim> & index) const; + void SetSize(unsigned int i, SizeValueType val); + SizeValueType GetSize(unsigned int i) const; + void SetIndex(unsigned int i, IndexValueType val); + IndexValueType GetIndex(unsigned int i) const; +}; + +template <typename TValue, unsigned int VLength = 3> +class FixedArray +{ +public: + FixedArray(); + virtual ~FixedArray(); + unsigned int Size(); + void SetElement(unsigned short idx, const TValue &val); + const TValue & GetElement(unsigned short idx); +}; + +template <typename TValue, unsigned int NDim = 3> +class Vector: public FixedArray<TValue,NDim> +{ +public: + Vector(); + virtual ~Vector(); + typedef NumericTraits<TValue>::RealType RealValueType; + RealValueType GetNorm() const; + RealValueType GetSquaredNorm() const; + RealValueType Normalize(); +}; + +template <typename TCoord, unsigned int NDim = 3> +class Point: public FixedArray<TCoord,NDim> +{ +public: + Point(); + virtual ~Point(); +}; + +// Instanciate the needed templates +%template(itkSize) Size<2>; +%template(itkIndex) Index<2>; +%template(itkRegion) ImageRegion<2>; +%template(itkFixedArray) FixedArray<SpacePrecisionType,2>; +%template(itkVector) Vector<SpacePrecisionType,2>; +%template(itkPoint) Point<SpacePrecisionType,2>; -%template(vectorstring) std::vector< std::string >; +} // end of namespace itk + +#if SWIGPYTHON + +%define WRAP_AS_LIST(N, T...) +%extend T + { + %pythoncode + { + def __str__(self): + ret = "[" + for index in range(N): + ret += str(self.GetElement(index))+"," + ret = ret[:-1] + "]" + return ret + def __len__(self): + return N + def __getitem__(self,idx): + if idx >= N or idx < 0: + raise IndexError('Index outside [0,'+str(N-1)+']') + return self.GetElement(idx) + def __setitem__(self,idx,val): + if idx >= N or idx < 0: + raise IndexError('Index outside [0,'+str(N-1)+']') + return self.SetElement(idx,val) + } + }; +%enddef + +namespace itk +{ +WRAP_AS_LIST(2, Size<2>) +WRAP_AS_LIST(2, Index<2>) +WRAP_AS_LIST(2, FixedArray<SpacePrecisionType,2>) +WRAP_AS_LIST(2, Vector<SpacePrecisionType,2>) +WRAP_AS_LIST(2, Point<SpacePrecisionType,2>) + +%extend ImageRegion<2> +{ + %pythoncode + { + def __str__(self): + return "{index:"+str(self.GetIndex())+", size:"+str(self.GetSize())+"}" + def __len__(self): + return 2 + def keys(self): + return ['index', 'size'] + def __getitem__(self,key): + if key == 'index': + return self.GetIndex() + elif key == 'size': + return self.GetSize() + else: + raise IndexError('Key not in ["index","size"]') + def __setitem__(self,key,val): + if key == 'index': + self.SetIndex(val) + elif key == 'size': + self.SetSize(val) + else: + raise IndexError('Key not in ["index","size"]') + } +}; +} // end of namespace itk +#endif class itkIndent { public: @@ -155,6 +333,21 @@ class itkIndent { }; DECLARE_REF_COUNT_CLASS( itkObjectFactoryBase ) +class itkMetaDataObjectBase : public itkLightObject +{ +public: + virtual const std::type_info & GetMetaDataObjectTypeInfo() const; + virtual const char * GetMetaDataObjectTypeName() const; + virtual const char * GetNameOfClass() const; + virtual void Print(std::ostream &os) const; +protected: + itkMetaDataObjectBase(); +#if SWIGJAVA + ~itkMetaDataObjectBase(); +#endif +}; +DECLARE_REF_COUNT_CLASS(itkMetaDataObjectBase) + class itkMetaDataDictionary { public: virtual void Print(std::ostream & os) const; @@ -163,7 +356,20 @@ class itkIndent { ~itkMetaDataDictionary(); std::vector< std::string > GetKeys() const; bool HasKey(std::string const & arg0) const; + const itkMetaDataObjectBase* Get(const std::string &) const; + void Set(const std::string &, itkMetaDataObjectBase *); }; + +namespace itk +{ + +template <typename T> +inline bool ExposeMetaData(const itkMetaDataDictionary & Dictionary, const std::string key, T & outval); + +template <typename T> +inline void EncapsulateMetaData(itkMetaDataDictionary & Dictionary, const std::string & key, const T & invalue); + +} class itkCommand : public itkObject { public: diff --git a/Modules/Wrappers/SWIG/src/itkBase.includes b/Modules/Wrappers/SWIG/src/itkBase.includes index 8cf4ee05bc..4f7902f3a4 100644 --- a/Modules/Wrappers/SWIG/src/itkBase.includes +++ b/Modules/Wrappers/SWIG/src/itkBase.includes @@ -38,6 +38,8 @@ typedef itk::ProcessObject::Pointer itkProcessObject_Pointer; typedef itk::ObjectFactoryBase itkObjectFactoryBase; typedef itk::ObjectFactoryBase::Pointer itkObjectFactoryBase_Pointer; typedef itk::MetaDataDictionary itkMetaDataDictionary; +typedef itk::MetaDataObjectBase itkMetaDataObjectBase; +typedef itk::MetaDataObjectBase::Pointer itkMetaDataObjectBase_Pointer; typedef itk::Indent itkIndent; typedef itk::Command itkCommand; -- GitLab From 4cf9f1996a9b1326d31039e42e86c44a28a4d87f Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 28 Feb 2018 17:21:53 +0100 Subject: [PATCH 343/567] ENH: typedefs not necessary anymore --- Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h b/Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h index b7f84f06fc..8ded93c90a 100644 --- a/Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h +++ b/Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h @@ -24,6 +24,7 @@ #include "otbWrapperApplicationRegistry.h" #include "otbWrapperAddProcessToWatchEvent.h" #include "otbWrapperDocExampleStructure.h" +#include "otbWrapperMetaDataHelper.h" typedef otb::Wrapper::Application Application; typedef otb::Wrapper::Application::Pointer Application_Pointer; @@ -38,8 +39,4 @@ typedef otb::Wrapper::ComplexInputImageParameter ComplexInputImageParame typedef otb::Wrapper::ImageBaseType ImageBaseType; -typedef ImageBaseType::SizeType itkSize; -typedef ImageBaseType::RegionType itkRegion; -typedef ImageBaseType::IndexType itkIndex; - #endif -- GitLab From ba66a21a0e9dea932dd41cae4a06c2f114eedfa5 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 28 Feb 2018 17:23:32 +0100 Subject: [PATCH 344/567] ENH: update SWIG wrappers with new services --- Modules/Wrappers/SWIG/src/otbApplication.i | 350 +++++++++++---------- 1 file changed, 192 insertions(+), 158 deletions(-) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index 0ef567b2c6..8444bc84e9 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -37,8 +37,6 @@ %include "itkMacro.i" %include "itkBase.i" -%include "std_map.i" - #if OTB_SWIGNUMPY %include "numpy.i" @@ -140,185 +138,71 @@ namespace Wrapper ComplexImagePixelType_double, } ComplexImagePixelType; -} - -} - -namespace std { -%template(keywordlist) map<string,string>; - -#if SWIGPYTHON -%extend map<string,string> -{ - %pythoncode - { - def __str__(self): - ret = "{" - for key in self: - ret += str(key)+":"+str(self[key])+", " - if len(ret) == 1: - ret += ", " - return ret[:-2]+"}" - } -}; -#endif -} // end of namespace std - -// BASIC ITK TYPES WRAPPING -%include "itkFloatTypes.h" -%include "itkIntTypes.h" - -namespace itk -{ - -template <unsigned int VDim = 2> -class Size -{ -public: - Size(); - virtual ~Size(); - void Fill(unsigned long val); - SizeValueType GetElement(unsigned long element) const; - void SetElement(unsigned long element, SizeValueType val); - static unsigned int GetSizeDimension(); -}; - -template <unsigned int VDim = 2> -class Index -{ -public: - Index(); - virtual ~Index(); - void Fill(signed long val); - IndexValueType GetElement(unsigned long element) const; - void SetElement(unsigned long element, IndexValueType val); - static unsigned int GetIndexDimension(); -}; +} // end of namespace Wrapper -template <unsigned int VDim> -class ImageRegion +class ImageKeywordlist { public: - ImageRegion(); - ImageRegion(const Index<VDim> &index, const Size<VDim> &size); - virtual ~ImageRegion(); - void SetIndex(const Index<VDim> &index); - void SetSize(const Size<VDim> &size); - void SetUpperIndex(const Index<VDim> &idx); - Index<VDim> GetUpperIndex() const; - const Index<VDim> & GetIndex() const; - const Size<VDim> & GetSize() const; - bool IsInside(const Index<VDim> & index) const; - void SetSize(unsigned int i, SizeValueType val); - SizeValueType GetSize(unsigned int i) const; - void SetIndex(unsigned int i, IndexValueType val); - IndexValueType GetIndex(unsigned int i) const; + typedef std::map<std::string, std::string> KeywordlistMap; + typedef KeywordlistMap::size_type KeywordlistMapSizeType; + ImageKeywordlist(); + virtual ~ImageKeywordlist(); + const KeywordlistMap& GetKeywordlist() const; + void Clear(void); + KeywordlistMapSizeType Empty() const; + KeywordlistMapSizeType GetSize(void) const; + const std::string& GetMetadataByKey(const std::string& key) const; + bool HasKey(const std::string& key) const; + virtual void ClearMetadataByKey(const std::string& key); + virtual void AddKey(const std::string& key, const std::string& value); + virtual void Print(std::ostream& os, itkIndent indent = 0) const; }; -template <typename TValue, unsigned int VLength = 3> -class FixedArray +class VectorDataKeywordlist { public: - FixedArray(); - virtual ~FixedArray(); - unsigned int Size(); - void SetElement(unsigned short idx, const TValue &val); - const TValue & GetElement(unsigned short idx); + VectorDataKeywordlist(); + ~VectorDataKeywordlist(); + // VectorDataKeywordlist(const Self& other); + // TODO : finish wrapping }; -template <typename TValue, unsigned int NDim = 3> -class Vector: public FixedArray<TValue,NDim> -{ -public: - Vector(); - virtual ~Vector(); - typedef NumericTraits<TValue>::RealType RealValueType; - RealValueType GetNorm() const; - RealValueType GetSquaredNorm() const; - RealValueType Normalize(); -}; - -template <typename TCoord, unsigned int NDim = 3> -class Point: public FixedArray<TCoord,NDim> +class OTB_GCP { public: - Point(); - virtual ~Point(); + std::string m_Id; + std::string m_Info; + double m_GCPCol; + double m_GCPRow; + double m_GCPX; + double m_GCPY; + double m_GCPZ; + OTB_GCP(); + ~OTB_GCP(); + void Print(std::ostream& os) const; }; - -// Instanciate the needed templates -%template(itkSize) Size<2>; -%template(itkIndex) Index<2>; -%template(itkRegion) ImageRegion<2>; -%template(itkFixedArray) FixedArray<SpacePrecisionType,2>; -%template(itkVector) Vector<SpacePrecisionType,2>; -%template(itkPoint) Point<SpacePrecisionType,2>; - -} // end of namespace itk - #if SWIGPYTHON - -%define WRAP_AS_LIST(N, T...) -%extend T +%extend ImageKeywordlist { %pythoncode { def __str__(self): - ret = "[" - for index in range(N): - ret += str(self.GetElement(index))+"," - ret = ret[:-1] + "]" - return ret - def __len__(self): - return N - def __getitem__(self,idx): - if idx >= N or idx < 0: - raise IndexError('Index outside [0,'+str(N-1)+']') - return self.GetElement(idx) - def __setitem__(self,idx,val): - if idx >= N or idx < 0: - raise IndexError('Index outside [0,'+str(N-1)+']') - return self.SetElement(idx,val) - } - }; -%enddef - -namespace itk -{ -WRAP_AS_LIST(2, Size<2>) -WRAP_AS_LIST(2, Index<2>) -WRAP_AS_LIST(2, FixedArray<SpacePrecisionType,2>) -WRAP_AS_LIST(2, Vector<SpacePrecisionType,2>) -WRAP_AS_LIST(2, Point<SpacePrecisionType,2>) - -%extend ImageRegion<2> -{ - %pythoncode - { - def __str__(self): - return "{index:"+str(self.GetIndex())+", size:"+str(self.GetSize())+"}" + return str(self.GetKeywordlist()) def __len__(self): - return 2 + return self.GetSize() def __getitem__(self,key): - if key == 'index': - return self.GetIndex() - elif key == 'size': - return self.GetSize() - else: - raise IndexError('Key not in ["index","size"]') + return self.GetKeywordlist()[key] def __setitem__(self,key,val): - if key == 'index': - self.SetIndex(val) - elif key == 'size': - self.SetSize(val) - else: - raise IndexError('Key not in ["index","size"]') + self.GetKeywordlist()[key] = val + def keys(self): + return self.GetKeywordlist().keys() } -}; -} // end of namespace itk + } #endif +} // end of namespace otb + class Application: public itkObject { public: @@ -392,9 +276,10 @@ public: itk::Size<2> GetImageSize(const std::string & key, unsigned int idx = 0); unsigned int GetImageNbBands(const std::string & key, unsigned int idx = 0); std::string GetImageProjection(const std::string & key, unsigned int idx = 0); - std::map<std::string,std::string> GetImageKeywordlist(const std::string & key, unsigned int idx = 0); + otb::ImageKeywordlist GetImageKeywordlist(const std::string & key, unsigned int idx = 0); unsigned long PropagateRequestedRegion(const std::string & key, itk::ImageRegion<2> region, unsigned int idx = 0); itk::ImageRegion<2> GetImageRequestedRegion(const std::string & key, unsigned int idx = 0); + itkMetaDataDictionary GetImageMetaData(const std::string & key, unsigned int idx = 0); itkProcessObject* GetProgressSource() const; @@ -976,3 +861,152 @@ public: }; %include "PyCommand.i" + +namespace otb +{ +namespace Wrapper +{ +class MetaDataHelper +{ +public: + MetaDataHelper(); + virtual ~MetaDataHelper(); + typedef enum + { + MDType_STRING, + MDType_INT, + MDType_DOUBLE, + MDType_GCP, + MDType_VECTOR, + MDType_IMAGEKWL, + MDType_VECTORDATAKWL, + MDType_BOOLVECTOR + } MDType; + + static MDType GetType(const std::string &val); + + static std::string GetString( + const itkMetaDataDictionary &dict, + const std::string &key); + static void SetString( + itkMetaDataDictionary &dict, + const std::string &key, + const std::string &val); + + static unsigned int GetInt( + const itkMetaDataDictionary &dict, + const std::string &key); + static void SetInt( + itkMetaDataDictionary &dict, + const std::string &key, + unsigned int val); + + static double GetDouble( + const itkMetaDataDictionary &dict, + const std::string &key); + static void SetDouble( + itkMetaDataDictionary &dict, + const std::string &key, + double val); + + static OTB_GCP GetGCP( + const itkMetaDataDictionary &dict, + const std::string &key); + static void SetGCP( + itkMetaDataDictionary &dict, + const std::string &key, + const OTB_GCP &val); + + static std::vector<double> GetVector( + const itkMetaDataDictionary &dict, + const std::string &key); + static void SetVector( + itkMetaDataDictionary &dict, + const std::string &key, + const std::vector<double> &val); + + static ImageKeywordlist GetImageKWL( + const itkMetaDataDictionary &dict, + const std::string &key); + static void SetImageKWL( + itkMetaDataDictionary &dict, + const std::string &key, + const ImageKeywordlist &val); + + static VectorDataKeywordlist GetVectorDataKWL( + const itkMetaDataDictionary &dict, + const std::string &key); + static void SetVectorDataKWL( + itkMetaDataDictionary &dict, + const std::string &key, + const VectorDataKeywordlist &val); + + static std::vector<bool> GetBoolVector( + const itkMetaDataDictionary &dict, + const std::string &key); + static void SetBoolVector( + itkMetaDataDictionary &dict, + const std::string &key, + const std::vector<bool> &val); +}; + +} // end of namespace Wrapper +} // end of namespace otb + + + +#if SWIGPYTHON +%pythoncode +{ +MetaDataHelper.GetterMap = { + MetaDataHelper.MDType_STRING : MetaDataHelper.GetString, + MetaDataHelper.MDType_INT : MetaDataHelper.GetInt, + MetaDataHelper.MDType_DOUBLE : MetaDataHelper.GetDouble, + MetaDataHelper.MDType_GCP : MetaDataHelper.GetGCP, + MetaDataHelper.MDType_VECTOR : MetaDataHelper.GetVector, + MetaDataHelper.MDType_IMAGEKWL : MetaDataHelper.GetImageKWL, + MetaDataHelper.MDType_VECTORDATAKWL : MetaDataHelper.GetVectorDataKWL, + MetaDataHelper.MDType_BOOLVECTOR : MetaDataHelper.GetBoolVector, + } + +MetaDataHelper.SetterMap = { + MetaDataHelper.MDType_STRING : MetaDataHelper.SetString, + MetaDataHelper.MDType_INT : MetaDataHelper.SetInt, + MetaDataHelper.MDType_DOUBLE : MetaDataHelper.SetDouble, + MetaDataHelper.MDType_GCP : MetaDataHelper.SetGCP, + MetaDataHelper.MDType_VECTOR : MetaDataHelper.SetVector, + MetaDataHelper.MDType_IMAGEKWL : MetaDataHelper.SetImageKWL, + MetaDataHelper.MDType_VECTORDATAKWL : MetaDataHelper.SetVectorDataKWL, + MetaDataHelper.MDType_BOOLVECTOR : MetaDataHelper.SetBoolVector, + } +} + +// enhance the MetaDataDictionary class for Python +%extend itkMetaDataDictionary +{ + %pythoncode + { + def __str__(self): + ret = '' + for k in self.GetKeys(): + ret += k + ':<...>, ' + if len(ret) == 0: + ret += ', ' + return "{"+ret[:-2] +"}" + def __len__(self): + return len(self.GetKeys()) + def keys(self): + return self.GetKeys() + def __getitem__(self,key): + if key in self.GetKeys(): + return MetaDataHelper.GetterMap[MetaDataHelper.GetType(key)](self,key) + else: + raise IndexError('Key not recognized') + def __setitem__(self,key,val): + if key in self.GetKeys(): + MetaDataHelper.SetterMap[MetaDataHelper.GetType(key)](self,key,val) + else: + raise IndexError('Key not recognized') + } +}; +#endif -- GitLab From a9ce08a64d25e4d954f6864e403c44c652f5d682 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 28 Feb 2018 17:24:13 +0100 Subject: [PATCH 345/567] ENH: expose the Registry::CleanRegistry function --- Modules/Wrappers/SWIG/src/otbApplication.i | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index 8444bc84e9..5f24af0f53 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -838,6 +838,7 @@ public: static Application_Pointer CreateApplication(const std::string& name); static void AddApplicationPath(std::string newpath); static void SetApplicationPath(std::string newpath); + static void CleanRegistry(); protected: Registry(); -- GitLab From d4a174c0b59ac06f076c79fa7799e6888a940362 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Wed, 28 Feb 2018 18:29:59 +0100 Subject: [PATCH 346/567] ENH: implement sample augmentation as a filter --- .../app/otbSampleAugmentation.cxx | 181 ++---------- .../include/otbSampleAugmentation.h | 4 +- .../include/otbSampleAugmentationFilter.h | 168 +++++++++++ .../include/otbSampleAugmentationFilter.txx | 268 ++++++++++++++++++ 4 files changed, 463 insertions(+), 158 deletions(-) create mode 100644 Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.h create mode 100644 Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.txx diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx index a12e3912b1..eed67c8fb8 100644 --- a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -21,7 +21,7 @@ #include "otbWrapperApplication.h" #include "otbWrapperApplicationFactory.h" #include "otbOGRDataSourceWrapper.h" -#include "otbSampleAugmentation.h" +#include "otbSampleAugmentationFilter.h" namespace otb { @@ -44,9 +44,9 @@ public: itkTypeMacro(SampleAugmentation, otb::Application); /** Filters typedef */ - using SampleType = sampleAugmentation::SampleType; - using SampleVectorType = sampleAugmentation::SampleVectorType; - + using FilterType = otb::SampleAugmentationFilter; + using SampleType = FilterType::SampleType; + using SampleVectorType = FilterType::SampleVectorType; private: SampleAugmentation() {} @@ -220,143 +220,49 @@ private: GetSelectedItems( "exclude" )); for(const auto& ef : excludedFeatures) otbAppLogINFO("Excluding feature " << ef << '\n'); - auto inSamples = extractSamples(vectors, this->GetParameterInt("layer"), - fieldName, - this->GetParameterInt("label"), - excludedFeatures); + int seed = std::time(nullptr); if(IsParameterEnabled("seed")) seed = this->GetParameterInt("seed"); - SampleVectorType newSamples; + + + FilterType::Pointer filter = FilterType::New(); + filter->SetInput(vectors); + filter->SetLayer(this->GetParameterInt("layer")); + filter->SetNumberOfSamples(this->GetParameterInt("samples")); + filter->SetOutputSamples(output); + filter->SetClassFieldName(fieldName); + filter->SetLabel(this->GetParameterInt("label")); + filter->SetExcludedFeatures(excludedFeatures); + filter->SetSeed(seed); switch (this->GetParameterInt("strategy")) { // replicate case 0: { otbAppLogINFO("Augmentation strategy : replicate"); - sampleAugmentation::replicateSamples(inSamples, this->GetParameterInt("samples"), - newSamples); + filter->SetStrategy(FilterType::Strategy::Replicate); } - break; + break; // jitter case 1: { otbAppLogINFO("Augmentation strategy : jitter"); - sampleAugmentation::jitterSamples(inSamples, this->GetParameterInt("samples"), - newSamples, - this->GetParameterFloat("strategy.jitter.stdfactor"), - seed); + filter->SetStrategy(FilterType::Strategy::Jitter); + filter->SetStdFactor(this->GetParameterFloat("stdfactor")); } break; case 2: { otbAppLogINFO("Augmentation strategy : smote"); - sampleAugmentation::smote(inSamples, this->GetParameterInt("samples"), - newSamples, - this->GetParameterInt("strategy.smote.neighbors"), - seed); + filter->SetStrategy(FilterType::Strategy::Smote); + filter->SetSmoteNeighbors(this->GetParameterInt("neighbors")); } break; } - writeSamples(vectors, output, newSamples, this->GetParameterInt("layer"), - fieldName, - this->GetParameterInt("label"), - excludedFeatures); + filter->Update(); output->SyncToDisk(); } -/** Extracts the samples of a single class from the vector data to a -* vector and excludes some unwanted features. -*/ - SampleVectorType extractSamples(const ogr::DataSource::Pointer vectors, - size_t layerName, - const std::string& classField, const int label, - const std::vector<std::string>& excludedFeatures = {}) - { - ogr::Layer layer = vectors->GetLayer(layerName); - ogr::Feature feature = layer.ogr().GetNextFeature(); - if(feature.addr() == 0) - { - otbAppLogFATAL("Layer " << layerName << " of input sample file is empty.\n"); - } - int cFieldIndex = feature.ogr().GetFieldIndex( classField.c_str() ); - if( cFieldIndex < 0 ) - { - otbAppLogFATAL( "The field name for class label (" << classField - << ") has not been found in the vector file " ); - } - - auto numberOfFields = feature.ogr().GetFieldCount(); - auto excludedIds = getExcludedFeaturesIds(excludedFeatures, layer); - otbAppLogINFO("The vector file contains " << numberOfFields << " fields.\n"); - SampleVectorType samples; - bool goesOn{feature.addr() != 0}; - while( goesOn ) - { - // Retrieve all the features for each field in the ogr layer. - if(feature.ogr().GetFieldAsInteger(classField.c_str()) == label) - { - - SampleType mv; - for(auto idx=0; idx<numberOfFields; ++idx) - { - if(excludedIds.find(idx) == excludedIds.cend() && - isNumericField(feature, idx)) - mv.push_back(feature.ogr().GetFieldAsDouble(idx)); - } - samples.push_back(mv); - } - feature = layer.ogr().GetNextFeature(); - goesOn = feature.addr() != 0; - } - return samples; - } - - void writeSamples(const ogr::DataSource::Pointer& vectors, - ogr::DataSource::Pointer& output, - const SampleVectorType& samples, - const size_t layerName, - const std::string& classField, int label, - const std::vector<std::string>& excludedFeatures = {}) - { - - auto inputLayer = vectors->GetLayer(layerName); - auto excludedIds = getExcludedFeaturesIds(excludedFeatures, inputLayer); - - OGRSpatialReference * oSRS = nullptr; - if (inputLayer.GetSpatialRef()) - { - oSRS = inputLayer.GetSpatialRef()->Clone(); - } - OGRFeatureDefn &layerDefn = inputLayer.GetLayerDefn(); - - auto outputLayer = output->CreateLayer(inputLayer.GetName(), oSRS, - inputLayer.GetGeomType()); - for (int k=0 ; k < layerDefn.GetFieldCount() ; k++) - { - OGRFieldDefn originDefn(layerDefn.GetFieldDefn(k)); - ogr::FieldDefn fieldDefn(originDefn); - outputLayer.CreateField(fieldDefn); - } - - auto featureCount = outputLayer.GetFeatureCount(false); - auto templateFeature = selectTemplateFeature(inputLayer, classField, label); - for(const auto& sample : samples) - { - ogr::Feature dstFeature(outputLayer.GetLayerDefn()); - dstFeature.SetFrom( templateFeature, TRUE ); - dstFeature.SetFID(++featureCount); - auto sampleFieldCounter = 0; - for (int k=0 ; k < layerDefn.GetFieldCount() ; k++) - { - if(excludedIds.find(k) == excludedIds.cend() && - isNumericField(dstFeature, k)) - { - dstFeature.ogr().SetField(k, sample[sampleFieldCounter++]); - } - } - outputLayer.CreateFeature( dstFeature ); - } - } std::vector<std::string> GetExcludedFeatures(const std::vector<std::string>& fieldNames, const std::vector<int>& selectedIdx) @@ -369,45 +275,8 @@ private: } return result; } - ogr::Feature selectTemplateFeature(const ogr::Layer& inputLayer, - const std::string& classField, int label) - { - auto featureIt = inputLayer.begin(); - bool goesOn{(*featureIt).addr() != 0}; - while( goesOn ) - { - if((*featureIt).ogr().GetFieldAsInteger(classField.c_str()) == label) - { - return *featureIt; - } - ++featureIt; - } - return *(inputLayer.begin()); - } - std::set<size_t> getExcludedFeaturesIds(const std::vector<std::string>& excludedFeatures, - const ogr::Layer& inputLayer) - { - auto feature = *(inputLayer).begin(); - std::set<size_t> excludedIds; - if( excludedFeatures.size() != 0) - { - for(const auto& fieldName : excludedFeatures) - { - auto idx = feature.ogr().GetFieldIndex( fieldName.c_str() ); - excludedIds.insert(idx); - } - } - return excludedIds; - } - bool isNumericField(const ogr::Feature& feature, - const int idx) - { - OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(idx)->GetType(); - return (fieldType == OFTInteger - || ogr::version_proxy::IsOFTInteger64( fieldType ) - || fieldType == OFTReal); - } - }; + +}; } // end of namespace Wrapper } // end of namespace otb diff --git a/Modules/Applications/AppClassification/include/otbSampleAugmentation.h b/Modules/Applications/AppClassification/include/otbSampleAugmentation.h index 43fd6657a0..432dbe8a26 100644 --- a/Modules/Applications/AppClassification/include/otbSampleAugmentation.h +++ b/Modules/Applications/AppClassification/include/otbSampleAugmentation.h @@ -199,7 +199,7 @@ void smote(const SampleVectorType& inSamples, } } -} -} +}//end namespaces sampleAugmentation +}//end namespace otb #endif diff --git a/Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.h b/Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.h new file mode 100644 index 0000000000..754e96ef33 --- /dev/null +++ b/Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.h @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbSampleAugmentationFilter_h +#define otbSampleAugmentationFilter_h + +#include "itkProcessObject.h" +#include "otbOGRDataSourceWrapper.h" +#include "otbSampleAugmentation.h" + +namespace otb +{ + +/** \class SampleAugmentationFilter +This class + */ + +class ITK_EXPORT SampleAugmentationFilter : + public itk::ProcessObject +{ +public: + + /** typedef for the classes standards. */ + typedef SampleAugmentationFilter Self; + typedef itk::ProcessObject Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Method for management of the object factory. */ + itkNewMacro(Self); + + /** Return the name of the class. */ + itkTypeMacro(SampleAugmentationFilter, ProcessObject); + + typedef ogr::DataSource OGRDataSourceType; + typedef typename OGRDataSourceType::Pointer OGRDataSourcePointerType; + typedef ogr::Layer OGRLayerType; + + typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType; + + using SampleType = sampleAugmentation::SampleType; + using SampleVectorType = sampleAugmentation::SampleVectorType; + + enum class Strategy { Replicate, Jitter, Smote }; + + /** Set/Get the input OGRDataSource of this process object. */ + using Superclass::SetInput; + virtual void SetInput(const OGRDataSourceType* ds); + const OGRDataSourceType* GetInput(unsigned int idx); + + virtual void SetOutputSamples(ogr::DataSource* data); + + /** Set the Field Name in which labels will be written. (default is "class") + * A field "ClassFieldName" of type integer is created in the output memory layer. + */ + itkSetMacro(ClassFieldName, std::string); + /** + * Return the Field name in which labels have been written. + */ + itkGetMacro(ClassFieldName, std::string); + + + itkSetMacro(Layer, size_t); + itkGetMacro(Layer, size_t); + itkSetMacro(Label, int); + itkGetMacro(Label, int); + void SetStrategy(Strategy s) + { + m_Strategy = s; + } + Strategy GetStrategy() const + { + return m_Strategy; + } + itkSetMacro(NumberOfSamples, int); + itkGetMacro(NumberOfSamples, int); + void SetExcludedFeatures(const std::vector<std::string>& ef) + { + m_ExcludedFeatures = ef; + } + std::vector<std::string> GetExcludedFeatures() const + { + return m_ExcludedFeatures; + } + itkSetMacro(StdFactor, double); + itkGetMacro(StdFactor, double); + itkSetMacro(SmoteNeighbors, size_t); + itkGetMacro(SmoteNeighbors, size_t); + itkSetMacro(Seed, int); + itkGetMacro(Seed, int); +/** + * Get the output \c ogr::DataSource which is a "memory" datasource. + */ + const OGRDataSourceType * GetOutput(); + +protected: + SampleAugmentationFilter(); + ~SampleAugmentationFilter() ITK_OVERRIDE {} + + /** Generate Data method*/ + void GenerateData() ITK_OVERRIDE; + + /** DataObject pointer */ + typedef itk::DataObject::Pointer DataObjectPointer; + + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + using Superclass::MakeOutput; + + + SampleVectorType extractSamples(const ogr::DataSource::Pointer vectors, + size_t layerName, + const std::string& classField, const int label, + const std::vector<std::string>& excludedFeatures = {}); + + void sampleToOGRFeatures(const ogr::DataSource::Pointer& vectors, + ogr::DataSource* output, + const SampleVectorType& samples, + const size_t layerName, + const std::string& classField, int label, + const std::vector<std::string>& excludedFeatures = {}); + +std::set<size_t> getExcludedFeaturesIds(const std::vector<std::string>& excludedFeatures, + const ogr::Layer& inputLayer); +bool isNumericField(const ogr::Feature& feature, const int idx); + +ogr::Feature selectTemplateFeature(const ogr::Layer& inputLayer, + const std::string& classField, int label); +private: + SampleAugmentationFilter(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + + std::string m_ClassFieldName; + size_t m_Layer; + int m_Label; + std::vector<std::string> m_ExcludedFeatures; + Strategy m_Strategy; + int m_NumberOfSamples; + double m_StdFactor; + size_t m_SmoteNeighbors; + int m_Seed; + +}; + + +} // end namespace otb + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbSampleAugmentationFilter.txx" +#endif + +#endif diff --git a/Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.txx b/Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.txx new file mode 100644 index 0000000000..41590a0109 --- /dev/null +++ b/Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.txx @@ -0,0 +1,268 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbSampleAugmentationFilter_txx +#define otbSampleAugmentationFilter_txx + +#include "otbSampleAugmentationFilter.h" +#include "stdint.h" //needed for uintptr_t + +namespace otb +{ + +SampleAugmentationFilter +::SampleAugmentationFilter() : m_ClassFieldName("class") +{ + this->SetNumberOfRequiredInputs(1); + this->SetNumberOfRequiredOutputs(1); + this->ProcessObject::SetNthOutput(0, this->MakeOutput(0) ); +} + + +typename SampleAugmentationFilter::DataObjectPointer +SampleAugmentationFilter +::MakeOutput(DataObjectPointerArraySizeType itkNotUsed(idx)) +{ + return static_cast< DataObjectPointer >(OGRDataSourceType::New().GetPointer()); +} + +const typename SampleAugmentationFilter::OGRDataSourceType * +SampleAugmentationFilter +::GetOutput() +{ + return static_cast< const OGRDataSourceType *>( + this->ProcessObject::GetOutput(0)); +} + +void +SampleAugmentationFilter +::SetInput(const otb::ogr::DataSource* ds) +{ + this->Superclass::SetNthInput(0, const_cast<otb::ogr::DataSource *>(ds)); +} + +const typename SampleAugmentationFilter::OGRDataSourceType * +SampleAugmentationFilter +::GetInput(unsigned int idx) +{ + return static_cast<const OGRDataSourceType *> + (this->itk::ProcessObject::GetInput(idx)); +} + +void +SampleAugmentationFilter +::SetOutputSamples(ogr::DataSource* data) +{ + this->SetNthOutput(0,data); +} + + +void +SampleAugmentationFilter +::GenerateData(void) +{ + + OGRDataSourcePointerType inputDS = dynamic_cast<OGRDataSourceType*>(this->itk::ProcessObject::GetInput(0)); + auto outputDS = static_cast<ogr::DataSource *>(this->itk::ProcessObject::GetOutput(1)); + auto inSamples = this->extractSamples(inputDS, m_Layer, + m_ClassFieldName, + m_Label, + m_ExcludedFeatures); + SampleVectorType newSamples; + switch (m_Strategy) + { + case Strategy::Replicate: + { + sampleAugmentation::replicateSamples(inSamples, m_NumberOfSamples, + newSamples); + } + break; + case Strategy::Jitter: + { + sampleAugmentation::jitterSamples(inSamples, m_NumberOfSamples, + newSamples, + m_StdFactor, + m_Seed); + } + break; + case Strategy::Smote: + { + sampleAugmentation::smote(inSamples, m_NumberOfSamples, + newSamples, + m_SmoteNeighbors, + m_Seed); + } + break; + } + this->sampleToOGRFeatures(inputDS, outputDS, newSamples, m_Layer, + m_ClassFieldName, + m_Label, + m_ExcludedFeatures); + + + // this->SetNthOutput(0,outputDS); +} + +/** Extracts the samples of a single class from the vector data to a +* vector and excludes some unwanted features. +*/ +SampleAugmentationFilter::SampleVectorType +SampleAugmentationFilter +::extractSamples(const ogr::DataSource::Pointer vectors, + size_t layerName, + const std::string& classField, const int label, + const std::vector<std::string>& excludedFeatures) +{ + ogr::Layer layer = vectors->GetLayer(layerName); + ogr::Feature feature = layer.ogr().GetNextFeature(); + if(feature.addr() == 0) + { + itkExceptionMacro("Layer " << layerName << " of input sample file is empty.\n"); + } + int cFieldIndex = feature.ogr().GetFieldIndex( classField.c_str() ); + if( cFieldIndex < 0 ) + { + itkExceptionMacro( "The field name for class label (" << classField + << ") has not been found in the vector file " ); + } + + auto numberOfFields = feature.ogr().GetFieldCount(); + auto excludedIds = this->getExcludedFeaturesIds(excludedFeatures, layer); + SampleVectorType samples; + bool goesOn{feature.addr() != 0}; + while( goesOn ) + { + // Retrieve all the features for each field in the ogr layer. + if(feature.ogr().GetFieldAsInteger(classField.c_str()) == label) + { + + SampleType mv; + for(auto idx=0; idx<numberOfFields; ++idx) + { + if(excludedIds.find(idx) == excludedIds.cend() && + this->isNumericField(feature, idx)) + mv.push_back(feature.ogr().GetFieldAsDouble(idx)); + } + samples.push_back(mv); + } + feature = layer.ogr().GetNextFeature(); + goesOn = feature.addr() != 0; + } + return samples; +} + +void +SampleAugmentationFilter +::sampleToOGRFeatures(const ogr::DataSource::Pointer& vectors, + ogr::DataSource* output, + const SampleAugmentationFilter::SampleVectorType& samples, + const size_t layerName, + const std::string& classField, int label, + const std::vector<std::string>& excludedFeatures) +{ + + auto inputLayer = vectors->GetLayer(layerName); + auto excludedIds = this->getExcludedFeaturesIds(excludedFeatures, inputLayer); + + OGRSpatialReference * oSRS = nullptr; + if (inputLayer.GetSpatialRef()) + { + oSRS = inputLayer.GetSpatialRef()->Clone(); + } + OGRFeatureDefn &layerDefn = inputLayer.GetLayerDefn(); + + auto outputLayer = output->CreateLayer(inputLayer.GetName(), oSRS, + inputLayer.GetGeomType()); + for (int k=0 ; k < layerDefn.GetFieldCount() ; k++) + { + OGRFieldDefn originDefn(layerDefn.GetFieldDefn(k)); + ogr::FieldDefn fieldDefn(originDefn); + outputLayer.CreateField(fieldDefn); + } + + auto featureCount = outputLayer.GetFeatureCount(false); + auto templateFeature = this->selectTemplateFeature(inputLayer, classField, label); + for(const auto& sample : samples) + { + ogr::Feature dstFeature(outputLayer.GetLayerDefn()); + dstFeature.SetFrom( templateFeature, TRUE ); + dstFeature.SetFID(++featureCount); + auto sampleFieldCounter = 0; + for (int k=0 ; k < layerDefn.GetFieldCount() ; k++) + { + if(excludedIds.find(k) == excludedIds.cend() && + this->isNumericField(dstFeature, k)) + { + dstFeature.ogr().SetField(k, sample[sampleFieldCounter++]); + } + } + outputLayer.CreateFeature( dstFeature ); + } +} + + std::set<size_t> + SampleAugmentationFilter + ::getExcludedFeaturesIds(const std::vector<std::string>& excludedFeatures, + const ogr::Layer& inputLayer) + { + auto feature = *(inputLayer).begin(); + std::set<size_t> excludedIds; + if( excludedFeatures.size() != 0) + { + for(const auto& fieldName : excludedFeatures) + { + auto idx = feature.ogr().GetFieldIndex( fieldName.c_str() ); + excludedIds.insert(idx); + } + } + return excludedIds; + } + + bool +SampleAugmentationFilter +::isNumericField(const ogr::Feature& feature, + const int idx) +{ + OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(idx)->GetType(); + return (fieldType == OFTInteger + || ogr::version_proxy::IsOFTInteger64( fieldType ) + || fieldType == OFTReal); +} + +ogr::Feature +SampleAugmentationFilter +::selectTemplateFeature(const ogr::Layer& inputLayer, + const std::string& classField, int label) +{ + auto featureIt = inputLayer.begin(); + bool goesOn{(*featureIt).addr() != 0}; + while( goesOn ) + { + if((*featureIt).ogr().GetFieldAsInteger(classField.c_str()) == label) + { + return *featureIt; + } + ++featureIt; + } + return *(inputLayer.begin()); +} +} // end namespace otb + +#endif -- GitLab From 589a4085c917786e9e4a3091620e6a605bdfcf98 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 28 Feb 2018 18:43:47 +0100 Subject: [PATCH 347/567] ENH: add SetParameterImageBase function --- .../include/otbWrapperApplication.h | 10 ++++++ .../src/otbWrapperApplication.cxx | 32 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 0825ad392a..137f219151 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -1023,6 +1023,16 @@ protected: */ ImageBaseType* GetParameterImageBase(const std::string & key, unsigned int idx = 0); + /** Set the image in parameter 'key' as a base type. The optional 'idx' + * allows to access InputImageList. + * + * Works on parameters: + * \li ParameterType_InputImage + * \li ParameterType_InputImageList + * \li ParameterType_ComplexInputImage + */ + void SetParameterImageBase(const std::string & key, ImageBaseType* img, unsigned int idx = 0); + private: /* Implement this method to add parameters */ virtual void DoInit() = 0; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 9ca4a95a56..9f66cd5d65 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1823,5 +1823,37 @@ Application::GetParameterImageBase(const std::string & key, unsigned int idx) return nullptr; } +void +Application::SetParameterImageBase(const std::string & key, ImageBaseType* img, unsigned int idx) +{ + Parameter* param = GetParameterByKey(key); + if (dynamic_cast<InputImageParameter*>(param)) + { + InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param); + paramDown->SetImage<ImageBaseType>(img); + } + else if (dynamic_cast<InputImageListParameter*>(param)) + { + InputImageListParameter* paramDown = dynamic_cast<InputImageListParameter*>(param); + if (idx >= paramDown->Size()) + { + paramDown->AddImage(img); + } + else + { + paramDown->SetNthImage(idx, img); + } + } + else if (dynamic_cast<ComplexInputImageParameter*>(param)) + { + ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*>(param); + paramDown->SetImage<ImageBaseType>(img); + } + else + { + itkExceptionMacro("Wrong parameter type, expect InputImageParameter, InputImageListParameter or ComplexInputImageParameter"); + } +} + } } -- GitLab From 758194abe2d40cfb5be9709cba859706a1269f9d Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 1 Mar 2018 09:58:30 +0100 Subject: [PATCH 348/567] ENH: include class ExtendedFilename as member of OGRDataSource --- .../include/otbOGRDataSourceWrapper.h | 3 + ...ns.h => otbOGRExtendedFilenameToOptions.h} | 47 ++++++---- .../otbOGRExtendedFilenameToWriterOptions.h | 39 --------- .../Adapters/GdalAdapters/src/CMakeLists.txt | 3 +- .../src/otbOGRDataSourceWrapper.cxx | 2 + .../src/otbOGRExtendedFilenameToOptions.cxx | 87 +++++++++++++++++++ .../otbOGRExtendedFilenameToReaderOptions.cxx | 52 ----------- .../otbOGRExtendedFilenameToWriterOptions.cxx | 27 ------ .../include/otbVectorDataIOBase.h | 5 ++ 9 files changed, 130 insertions(+), 135 deletions(-) rename Modules/Adapters/GdalAdapters/include/{otbOGRExtendedFilenameToReaderOptions.h => otbOGRExtendedFilenameToOptions.h} (53%) delete mode 100644 Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h create mode 100644 Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx delete mode 100644 Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx delete mode 100644 Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h index bf6d799fd5..1af4c22558 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h @@ -46,6 +46,7 @@ #include "otbOGRLayerWrapper.h" #include "otbOGRVersionProxy.h" +#include "otbOGRExtendedFilenameToOptions.h" class OGRLayer; class OGRSpatialReference; @@ -88,6 +89,7 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; //@} + typedef OGRExtendedFilenameToOptions FileNameHelperType; /**\name Standard macros */ //@{ /** Default builder. @@ -549,6 +551,7 @@ private: private: ogr::version_proxy::GDALDatasetType *m_DataSource; + FileNameHelperType::Pointer m_FileNameHelper; Modes::type m_OpenMode; int m_FirstModifiableLayerID; }; // end class DataSource diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h similarity index 53% rename from Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h rename to Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h index 4aa7b78b31..1d1983eec1 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h @@ -18,8 +18,8 @@ * limitations under the License. */ -#ifndef otbOGRExtendedFilenameToReaderOptions_h -#define otbOGRExtendedFilenameToReaderOptions_h +#ifndef otbOGRExtendedFilenameToOptions_h +#define otbOGRExtendedFilenameToOptions_h #include <set> #include "otbExtendedFilenameHelper.h" @@ -27,14 +27,14 @@ namespace otb { -/** \class OGRExtendedFilenameToReaderOptions +/** \class OGRExtendedFilenameToOptions */ -class ITK_EXPORT OGRExtendedFilenameToReaderOptions : public ExtendedFilenameHelper +class ITK_EXPORT OGRExtendedFilenameToOptions : public ExtendedFilenameHelper { public: /** Standard class typedefs. */ - typedef OGRExtendedFilenameToReaderOptions Self; + typedef OGRExtendedFilenameToOptions Self; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; typedef ExtendedFilenameHelper Superclass; @@ -42,31 +42,48 @@ public: typedef Superclass::OptionMapType OptionMapType; typedef OptionMapType::iterator MapIteratorType; - itkTypeMacro(OGRExtendedFilenameToReaderOptions, otb::ExtendedFilenameHelper); + itkTypeMacro(OGRExtendedFilenameToOptions, otb::ExtendedFilenameHelper); itkNewMacro(Self); + typedef std::vector<std::string> GDALOptionType; + /** The creation option structure. */ - struct OptionType + struct OpenOptionType + { + std::pair< bool, std::string > simpleFileName; + std::pair< bool, GDALOptionType > gdalOptions; + std::map< std::string , bool > availableOptions; + }; + + struct CreationOptionType + { + std::pair< bool, std::string > simpleFileName; + std::pair< bool, GDALOptionType > gdalOptions; + std::map< std::string , bool > availableOptions; + }; + + struct LayerOptionType { - std::pair< bool , std::string > simpleFileName; - std::pair< bool , std::string > encoding; - std::set< std::string > availableOptions; + std::pair< bool, GDALOptionType > gdalOptions; + std::map< std::string , bool > availableOptions; }; /* Set Methods */ void SetExtendedFileName(const char * extFname) override; protected: - OGRExtendedFilenameToReaderOptions(); - ~OGRExtendedFilenameToReaderOptions() override {}; + OGRExtendedFilenameToOptions(); + ~OGRExtendedFilenameToOptions() override {}; private: - OGRExtendedFilenameToReaderOptions(const Self &) = delete ; + OGRExtendedFilenameToOptions(const Self &) = delete ; void operator =(const Self&) = delete ; - OptionType m_Options; + OpenOptionType m_OpenOptions; + CreationOptionType m_CreationOptions; + LayerOptionType m_LayerOptions; }; } //end namespace otb -#endif // otbOGRExtendedFilenameToReaderOptions_h +#endif // otbOGRExtendedFilenameToOptions_h diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h deleted file mode 100644 index 8c8422166f..0000000000 --- a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef otbOGRExtendedFilenameToWriterOptions_h -#define otbOGRExtendedFilenameToWriterOptions_h - -#include "otbExtendedFilenameHelper.h" - -namespace otb -{ - -/** \class OGRExtendedFilenameToWriterOptions - */ - -class ITK_EXPORT OGRExtendedFilenameToWriterOptions : public ExtendedFilenameHelper -{ -public: -}; - -} //end namespace otb - -#endif // otbOGRExtendedFilenameToWriterOptions_h \ No newline at end of file diff --git a/Modules/Adapters/GdalAdapters/src/CMakeLists.txt b/Modules/Adapters/GdalAdapters/src/CMakeLists.txt index 0cfe725108..0f73c07a03 100644 --- a/Modules/Adapters/GdalAdapters/src/CMakeLists.txt +++ b/Modules/Adapters/GdalAdapters/src/CMakeLists.txt @@ -29,8 +29,7 @@ set(OTBGdalAdapters_SRC otbGeometriesToGeometriesFilter.cxx otbOGRDataSourceWrapper.cxx otbOGRVersionProxy.cxx - otbOGRExtendedFilenameToReaderOptions.cxx - otbOGRExtendedFilenameToWriterOptions.cxx + otbOGRExtendedFilenameToOptions.cxx ) add_library(OTBGdalAdapters ${OTBGdalAdapters_SRC}) diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx index ac43afbb4d..1f699174d6 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx @@ -117,6 +117,7 @@ char const* DeduceDriverName(std::string filename) otb::ogr::DataSource::DataSource() : m_DataSource(ITK_NULLPTR), + m_FileNameHelper(), m_OpenMode(Modes::Update_LayerUpdate), m_FirstModifiableLayerID(0) { @@ -128,6 +129,7 @@ otb::ogr::DataSource::DataSource() if (!m_DataSource) { itkExceptionMacro(<< "Failed to create OGRMemDataSource: " << CPLGetLastErrorMsg()); } + m_FileNameHelper = FileNameHelperType::New(); } otb::ogr::DataSource::DataSource(otb::ogr::version_proxy::GDALDatasetType * source, Modes::type mode) diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx new file mode 100644 index 0000000000..fb51cf4d8f --- /dev/null +++ b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbOGRExtendedFilenameToOptions.h" +#include "otb_boost_string_header.h" +#include "otb_boost_tokenizer_header.h" + +namespace otb +{ + +OGRExtendedFilenameToOptions:: +OGRExtendedFilenameToOptions() +{ + m_OpenOptions.simpleFileName.first = false; + m_OpenOptions.simpleFileName.second = ""; + + m_CreationOptions.simpleFileName.first = false; + m_CreationOptions.simpleFileName.second = ""; + +} + +void +OGRExtendedFilenameToOptions:: +SetExtendedFileName(const char *extFname) +{ + Superclass::SetExtendedFileName(extFname); + OptionMapType map = GetOptionMap(); + + m_OpenOptions.simpleFileName.first = true; + m_OpenOptions.simpleFileName.second = this->GetSimpleFileName(); + + m_CreationOptions.simpleFileName.first = true; + m_CreationOptions.simpleFileName.second = this->GetSimpleFileName(); + + MapIteratorType it; + for ( it=map.begin(); it != map.end(); it++ ) + { + std::vector<std::string> tmp; + boost::split(tmp, it->first, boost::is_any_of(":"), boost::token_compress_on); + + if (tmp.size()>2 && (tmp[0]=="gdal") ) + { + if ( tmp[1]=="oo" ) + { + m_OpenOptions.gdalOptions.first = true; + m_OpenOptions.gdalOptions.second.push_back(tmp[2] + "=" +it->second); + } + else if ( tmp[1]=="co" ) + { + m_CreationOptions.gdalOptions.first = true; + m_CreationOptions.gdalOptions.second.push_back(tmp[2] + "=" +it->second); + } + else if ( tmp[1]=="lco" ) + { + m_LayerOptions.gdalOptions.first = true; + m_LayerOptions.gdalOptions.second.push_back(tmp[2] + "=" +it->second); + } + else + { + // log a warning + } + } + + } + + +} + + +} //end namespace otb diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx deleted file mode 100644 index 73fb4b311c..0000000000 --- a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "otbOGRExtendedFilenameToReaderOptions.h" - -namespace otb -{ - -OGRExtendedFilenameToReaderOptions:: -OGRExtendedFilenameToReaderOptions() -{ - m_Options.simpleFileName.first = false; - m_Options.simpleFileName.second = ""; - - m_Options.encoding.first = false; - m_Options.encoding.second = ""; - - m_Options.availableOptions.insert("encoding"); -} - -void -OGRExtendedFilenameToReaderOptions:: -SetExtendedFileName(const char *extFname) -{ - Superclass::SetExtendedFileName(extFname); - OptionMapType map = GetOptionMap(); - - m_Options.simpleFileName.first = true; - m_Options.simpleFileName.second = this->GetSimpleFileName(); - - -} - - -} //end namespace otb diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx deleted file mode 100644 index dc491e3680..0000000000 --- a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "otbOGRExtendedFilenameToReaderOptions.h" - -namespace otb -{ - - -} //end namespace otb \ No newline at end of file diff --git a/Modules/Core/VectorDataBase/include/otbVectorDataIOBase.h b/Modules/Core/VectorDataBase/include/otbVectorDataIOBase.h index de1e241fc2..e95b2e53aa 100644 --- a/Modules/Core/VectorDataBase/include/otbVectorDataIOBase.h +++ b/Modules/Core/VectorDataBase/include/otbVectorDataIOBase.h @@ -29,6 +29,7 @@ #include "itkDataObject.h" #include "OTBVectorDataBaseExport.h" +#include "otbOGRExtendedFilenameToOptions.h" namespace otb { @@ -72,6 +73,8 @@ public: typedef itk::Vector<double, VDimension> SpacingType; typedef itk::Point<double, VDimension> PointType; + typedef otb::OGRExtendedFilenameToOptions FileNameHelperType; + /** Set/Get the name of the file to be read. */ itkSetStringMacro(FileName); itkGetStringMacro(FileName); @@ -173,6 +176,8 @@ private: VectorDataIOBase(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented + FileNameHelperType m_FileNameHelper; + }; } // end namespace otb -- GitLab From 58df79178aa40aeaaaf1a80ac87d23b30b506b94 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 1 Mar 2018 10:25:08 +0100 Subject: [PATCH 349/567] ENH: error checking in GetParameterImageBase --- .../ApplicationEngine/src/otbWrapperApplication.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 9f66cd5d65..843ef1f08c 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1794,6 +1794,10 @@ Application::GetImageMetaData(const std::string & key, unsigned int idx) ImageBaseType* Application::GetParameterImageBase(const std::string & key, unsigned int idx) { + if (! this->HasValue(key)) + { + itkExceptionMacro("Can't get the image, parameter has no value"); + } Parameter* param = GetParameterByKey(key); if (dynamic_cast<InputImageParameter*>(param)) { @@ -1820,6 +1824,12 @@ Application::GetParameterImageBase(const std::string & key, unsigned int idx) ComplexOutputImageParameter* paramDown = dynamic_cast<ComplexOutputImageParameter*>(param); return paramDown->GetValue(); } + else + { + itkExceptionMacro("Wrong parameter type, expect InputImageParameter, " + "InputImageListParameter, ComplexInputImageParameter, " + "OutputImageParameter, ComplexOutputImageParameter"); + } return nullptr; } -- GitLab From f3812ec2e27a0f1ad1d8480bbd62412d59baf91d Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 1 Mar 2018 10:31:26 +0100 Subject: [PATCH 350/567] BUG: wrong parameter names and wrong output --- .../AppClassification/app/otbSampleAugmentation.cxx | 4 ++-- .../AppClassification/include/otbSampleAugmentationFilter.txx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx index eed67c8fb8..b2fcb1deb6 100644 --- a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -248,14 +248,14 @@ private: { otbAppLogINFO("Augmentation strategy : jitter"); filter->SetStrategy(FilterType::Strategy::Jitter); - filter->SetStdFactor(this->GetParameterFloat("stdfactor")); + filter->SetStdFactor(this->GetParameterFloat("strategy.jitter.stdfactor")); } break; case 2: { otbAppLogINFO("Augmentation strategy : smote"); filter->SetStrategy(FilterType::Strategy::Smote); - filter->SetSmoteNeighbors(this->GetParameterInt("neighbors")); + filter->SetSmoteNeighbors(this->GetParameterInt("strategy.smote.neighbors")); } break; } diff --git a/Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.txx b/Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.txx index 41590a0109..612e0e22f5 100644 --- a/Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.txx +++ b/Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.txx @@ -80,7 +80,7 @@ SampleAugmentationFilter { OGRDataSourcePointerType inputDS = dynamic_cast<OGRDataSourceType*>(this->itk::ProcessObject::GetInput(0)); - auto outputDS = static_cast<ogr::DataSource *>(this->itk::ProcessObject::GetOutput(1)); + auto outputDS = static_cast<ogr::DataSource *>(this->itk::ProcessObject::GetOutput(0)); auto inSamples = this->extractSamples(inputDS, m_Layer, m_ClassFieldName, m_Label, -- GitLab From 2970a499a70bd19a317a36cd6b0d3dce67c6527b Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 1 Mar 2018 10:37:14 +0100 Subject: [PATCH 351/567] ADD: move sample augmentation utilities to Learning/Sample module --- .../Sampling}/include/otbSampleAugmentation.h | 0 .../Sampling}/include/otbSampleAugmentationFilter.h | 0 .../Sampling}/include/otbSampleAugmentationFilter.txx | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename Modules/{Applications/AppClassification => Learning/Sampling}/include/otbSampleAugmentation.h (100%) rename Modules/{Applications/AppClassification => Learning/Sampling}/include/otbSampleAugmentationFilter.h (100%) rename Modules/{Applications/AppClassification => Learning/Sampling}/include/otbSampleAugmentationFilter.txx (100%) diff --git a/Modules/Applications/AppClassification/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h similarity index 100% rename from Modules/Applications/AppClassification/include/otbSampleAugmentation.h rename to Modules/Learning/Sampling/include/otbSampleAugmentation.h diff --git a/Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.h b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h similarity index 100% rename from Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.h rename to Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h diff --git a/Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.txx b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx similarity index 100% rename from Modules/Applications/AppClassification/include/otbSampleAugmentationFilter.txx rename to Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx -- GitLab From 48f48bdf66d46895e84e895ff622eb3a68b29cce Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 1 Mar 2018 11:24:52 +0100 Subject: [PATCH 352/567] ENH: OpenDataSource can use extended filename Warning : static member is used, might be a bad design --- .../include/otbOGRDataSourceWrapper.h | 1 + .../include/otbOGRExtendedFilenameToOptions.h | 8 +++++ .../GdalAdapters/include/otbOGRVersionProxy.h | 4 +-- .../src/otbOGRDataSourceWrapper.cxx | 17 +++++++-- .../src/otbOGRExtendedFilenameToOptions.cxx | 35 ++++++++++++++++++- .../GdalAdapters/src/otbOGRVersionProxy.cxx | 19 +++++++--- 6 files changed, 75 insertions(+), 9 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h index 1af4c22558..edee98817a 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h @@ -552,6 +552,7 @@ private: private: ogr::version_proxy::GDALDatasetType *m_DataSource; FileNameHelperType::Pointer m_FileNameHelper; + static FileNameHelperType::Pointer staticFileNameHelper; Modes::type m_OpenMode; int m_FirstModifiableLayerID; }; // end class DataSource diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h index 1d1983eec1..b33fcd8a77 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h @@ -71,6 +71,14 @@ public: /* Set Methods */ void SetExtendedFileName(const char * extFname) override; + GDALOptionType GetGDALOptions( const std::string & type ) const ; + + GDALOptionType GetGDALOpenOptions() const ; + GDALOptionType GetGDALCreationOptions() const ; + GDALOptionType GetGDALLayerOptions() const ; + + + protected: OGRExtendedFilenameToOptions(); ~OGRExtendedFilenameToOptions() override {}; diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h b/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h index 7fdc308413..7cae3f6dba 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h @@ -97,7 +97,7 @@ OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType type); * \return NULL if file could not be open. */ OTBGdalAdapters_EXPORT - GDALDatasetType * Open(const char * filename, bool readOnly = true); + GDALDatasetType * Open(const char * filename, bool readOnly = true , std::vector< std::string > const & options = std::vector< std::string >() ); /** * This function closes a dataset. @@ -126,7 +126,7 @@ OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType type); * \return NULL if dataset could not be created. */ OTBGdalAdapters_EXPORT - GDALDatasetType * Create(GDALDriverType * driver, const char * name); + GDALDatasetType * Create(GDALDriverType * driver, const char * name , std::vector< std::string > const & options = std::vector< std::string >() ); /** diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx index 1f699174d6..bd30ef8bb6 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx @@ -41,6 +41,11 @@ /*===========================================================================*/ /*=======================[ construction/destruction ]========================*/ /*===========================================================================*/ + +otb::ogr::DataSource::FileNameHelperType::Pointer + otb::ogr::DataSource::staticFileNameHelper = + otb::ogr::DataSource::FileNameHelperType::New(); + bool otb::ogr::DataSource::Clear() { Reset(ITK_NULLPTR); @@ -143,8 +148,13 @@ otb::ogr::DataSource::DataSource(otb::ogr::version_proxy::GDALDatasetType * sour otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string const& datasourceName, Modes::type mode) { bool update = (mode != Modes::Read); + staticFileNameHelper->SetExtendedFileName( datasourceName.c_str() ); - ogr::version_proxy::GDALDatasetType * source = ogr::version_proxy::Open(datasourceName.c_str(),!update); + std::string simpleFileName = staticFileNameHelper->GetSimpleFileName(); + ogr::version_proxy::GDALDatasetType * source = + ogr::version_proxy::Open( simpleFileName.c_str() , + !update , + staticFileNameHelper->GetGDALOpenOptions() ); if (!source) { // In read mode, this is a failure @@ -170,7 +180,10 @@ otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string c itkGenericExceptionMacro(<<"Could not create OGR driver "<<driverName<<", check your OGR configuration for available drivers."); } - source = ogr::version_proxy::Create(d,datasourceName.c_str()); + source = ogr::version_proxy::Create( + d , + simpleFileName.c_str() , + staticFileNameHelper->GetGDALCreationOptions() ); if (!source) { itkGenericExceptionMacro(<< "Failed to create GDALDataset <"<<datasourceName <<"> (driver name: <" << driverName<<">: " << CPLGetLastErrorMsg()); diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx index fb51cf4d8f..81b4784e3c 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx @@ -79,9 +79,42 @@ SetExtendedFileName(const char *extFname) } } +} - +OGRExtendedFilenameToOptions:: +GDALOptionType +OGRExtendedFilenameToOptions:: +GetGDALOptions( const std::string & type ) const +{ + if ( type == "layer" ) + return m_LayerOptions.gdalOptions.second; + else if ( type == "creation" ) + return m_CreationOptions.gdalOptions.second; + else if ( type == "open" ) + return m_OpenOptions.gdalOptions.second; + else + { + // warn user : wrong option + return GDALOptionType(); + } } + + +#define GetGDALOptionMacro( Type ) \ +OGRExtendedFilenameToOptions:: \ +GDALOptionType \ +OGRExtendedFilenameToOptions:: \ +GetGDAL##Type##Options() const \ +{ \ + return m_##Type##Options.gdalOptions.second; \ +} \ + +GetGDALOptionMacro( Open ) +GetGDALOptionMacro( Creation ) +GetGDALOptionMacro( Layer ) + + + } //end namespace otb diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx index 22b7a612ca..54fc19e190 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx @@ -19,6 +19,7 @@ */ #include "otbOGRVersionProxy.h" +#include "otbOGRHelpers.h" #include "itkMacro.h" @@ -60,12 +61,17 @@ OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType type) } -GDALDatasetType * Open(const char * filename, bool readOnly) +GDALDatasetType * Open(const char * filename, bool readOnly , std::vector< std::string > const & options ) { #if GDAL_VERSION_NUM<2000000 return OGRSFDriverRegistrar::Open(filename,!readOnly); #else - return (GDALDatasetType *)GDALOpenEx(filename, (readOnly? GDAL_OF_READONLY : GDAL_OF_UPDATE) | GDAL_OF_VECTOR,NULL,NULL,NULL); + return (GDALDatasetType *)GDALOpenEx( + filename, + (readOnly? GDAL_OF_READONLY : GDAL_OF_UPDATE) | GDAL_OF_VECTOR, + NULL, + otb::ogr::StringListConverter( options ).to_ogr(), + NULL); #endif } @@ -78,7 +84,7 @@ void Close(GDALDatasetType * dataset) #endif } -GDALDatasetType * Create(GDALDriverType * driver, const char * name) +GDALDatasetType * Create(GDALDriverType * driver, const char * name , std::vector< std::string > const & options ) { #if GDAL_VERSION_NUM<2000000 GDALDatasetType * ds = driver->CreateDataSource(name); @@ -88,7 +94,12 @@ GDALDatasetType * Create(GDALDriverType * driver, const char * name) return ds; #else - return driver->Create(name,0,0,0,GDT_Unknown,NULL); + return driver->Create( name , + 0 , + 0 , + 0 , + GDT_Unknown , + otb::ogr::StringListConverter( options ).to_ogr() ); #endif } -- GitLab From 33179fa7092197c725b639b64be781355de5bb02 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 1 Mar 2018 12:07:29 +0100 Subject: [PATCH 353/567] REFAC: change signature of CopyLayer method, change in API --- .../Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h | 6 +++--- .../Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h index edee98817a..f3f71a4fba 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h @@ -370,7 +370,7 @@ public: Layer CopyLayer( Layer & srcLayer, std::string const& newName, - char ** papszOptions = ITK_NULLPTR); + std::vector<std::string> const& papszOptions = std::vector<std::string>() ); //@} /**\name Layers access @@ -550,9 +550,9 @@ private: std::string GetDatasetDescription() const; private: - ogr::version_proxy::GDALDatasetType *m_DataSource; - FileNameHelperType::Pointer m_FileNameHelper; static FileNameHelperType::Pointer staticFileNameHelper; + ogr::version_proxy::GDALDatasetType *m_DataSource; + FileNameHelperType::GDALOptionType m_LayerOptions; Modes::type m_OpenMode; int m_FirstModifiableLayerID; }; // end class DataSource diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx index bd30ef8bb6..c3d7e57326 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx @@ -122,7 +122,6 @@ char const* DeduceDriverName(std::string filename) otb::ogr::DataSource::DataSource() : m_DataSource(ITK_NULLPTR), - m_FileNameHelper(), m_OpenMode(Modes::Update_LayerUpdate), m_FirstModifiableLayerID(0) { @@ -134,7 +133,6 @@ otb::ogr::DataSource::DataSource() if (!m_DataSource) { itkExceptionMacro(<< "Failed to create OGRMemDataSource: " << CPLGetLastErrorMsg()); } - m_FileNameHelper = FileNameHelperType::New(); } otb::ogr::DataSource::DataSource(otb::ogr::version_proxy::GDALDatasetType * source, Modes::type mode) @@ -368,7 +366,7 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer( otb::ogr::Layer otb::ogr::DataSource::CopyLayer( Layer & srcLayer, std::string const& newName, - char ** papszOptions/* = NULL */) + std::vector<std::string> const& papszOptions/* = NULL */) { assert(m_DataSource && "Datasource not initialized"); @@ -386,7 +384,7 @@ otb::ogr::Layer otb::ogr::DataSource::CopyLayer( } OGRLayer * l0 = &srcLayer.ogr(); - OGRLayer * ol = m_DataSource->CopyLayer(l0, newName.c_str(), papszOptions); + OGRLayer * ol = m_DataSource->CopyLayer(l0, newName.c_str(), otb::ogr::StringListConverter(papszOptions).to_ogr()); if (!ol) { itkGenericExceptionMacro(<< "Failed to copy the layer <" -- GitLab From 1eabd31e0f650195843dcadd67ede953d97cc791 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 1 Mar 2018 12:26:07 +0100 Subject: [PATCH 354/567] ENH: Get rid of static member and use temporary FileNameHelper --- .../include/otbOGRDataSourceWrapper.h | 5 ++-- .../src/otbOGRDataSourceWrapper.cxx | 24 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h index f3f71a4fba..c51e2636d2 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h @@ -513,7 +513,7 @@ protected: /** Init constructor. * \post The newly constructed object owns the \c source parameter. */ - DataSource(ogr::version_proxy::GDALDatasetType * source, Modes::type mode); + DataSource(ogr::version_proxy::GDALDatasetType * source, Modes::type mode , std::vector< std::string > layerOption = std::vector< std::string >() ); /** Destructor. * \post The \c GDALDataset owned is released (if not null). */ @@ -550,9 +550,8 @@ private: std::string GetDatasetDescription() const; private: - static FileNameHelperType::Pointer staticFileNameHelper; ogr::version_proxy::GDALDatasetType *m_DataSource; - FileNameHelperType::GDALOptionType m_LayerOptions; + std::vector< std::string > m_LayerOptions; Modes::type m_OpenMode; int m_FirstModifiableLayerID; }; // end class DataSource diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx index c3d7e57326..8660354fec 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx @@ -42,10 +42,6 @@ /*=======================[ construction/destruction ]========================*/ /*===========================================================================*/ -otb::ogr::DataSource::FileNameHelperType::Pointer - otb::ogr::DataSource::staticFileNameHelper = - otb::ogr::DataSource::FileNameHelperType::New(); - bool otb::ogr::DataSource::Clear() { Reset(ITK_NULLPTR); @@ -122,6 +118,7 @@ char const* DeduceDriverName(std::string filename) otb::ogr::DataSource::DataSource() : m_DataSource(ITK_NULLPTR), + m_LayerOptions() , m_OpenMode(Modes::Update_LayerUpdate), m_FirstModifiableLayerID(0) { @@ -135,9 +132,13 @@ otb::ogr::DataSource::DataSource() } } -otb::ogr::DataSource::DataSource(otb::ogr::version_proxy::GDALDatasetType * source, Modes::type mode) -: m_DataSource(source), - m_OpenMode(mode), +otb::ogr::DataSource::DataSource( + otb::ogr::version_proxy::GDALDatasetType * source , + Modes::type mode , + std::vector< std::string > options /*NULL*/ ) +: m_DataSource(source) , + m_LayerOptions(options) , + m_OpenMode(mode) , m_FirstModifiableLayerID(0) { m_FirstModifiableLayerID = GetLayersCount(); @@ -145,14 +146,15 @@ otb::ogr::DataSource::DataSource(otb::ogr::version_proxy::GDALDatasetType * sour otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string const& datasourceName, Modes::type mode) { + FileNameHelperType::Pointer fileNameHelper = FileNameHelperType::New(); bool update = (mode != Modes::Read); - staticFileNameHelper->SetExtendedFileName( datasourceName.c_str() ); + fileNameHelper->SetExtendedFileName( datasourceName.c_str() ); - std::string simpleFileName = staticFileNameHelper->GetSimpleFileName(); + std::string simpleFileName = fileNameHelper->GetSimpleFileName(); ogr::version_proxy::GDALDatasetType * source = ogr::version_proxy::Open( simpleFileName.c_str() , !update , - staticFileNameHelper->GetGDALOpenOptions() ); + fileNameHelper->GetGDALOpenOptions() ); if (!source) { // In read mode, this is a failure @@ -181,7 +183,7 @@ otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string c source = ogr::version_proxy::Create( d , simpleFileName.c_str() , - staticFileNameHelper->GetGDALCreationOptions() ); + fileNameHelper->GetGDALCreationOptions() ); if (!source) { itkGenericExceptionMacro(<< "Failed to create GDALDataset <"<<datasourceName <<"> (driver name: <" << driverName<<">: " << CPLGetLastErrorMsg()); -- GitLab From 1f3e110cce503526f72fb23a045c787e25afb5d5 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 1 Mar 2018 14:31:39 +0100 Subject: [PATCH 355/567] ENH: add support for OGR CSV driver (compiled by default into gdal) --- Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx index ac43afbb4d..2f5ed9df5b 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx @@ -85,6 +85,7 @@ const ExtensionDriverAssociation k_ExtensionDriverMap[] = {".GPX", "GPX"}, {".SQLITE", "SQLite"}, {".KML", "KML"}, + {".CSV", "CSV"}, }; /**\ingroup GeometryInternals * \brief Returns the OGR driver name associated to a filename. -- GitLab From ef3973f3f50b52cb8009b47ed956cf9aaed9d83c Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 1 Mar 2018 15:08:08 +0100 Subject: [PATCH 356/567] ENH: pas by const ref to sampleCombine --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index 432dbe8a26..b778e79f26 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -164,7 +164,7 @@ void findKNNIndices(const SampleVectorType& inSamples, /** Generate the new sample in the line linking s1 and s2 */ -SampleType smoteCombine(SampleType s1, SampleType s2, double position) +SampleType smoteCombine(const SampleType& s1, const SampleType& s2, double position) { auto result = s1; for(size_t i=0; i<s1.size(); ++i) -- GitLab From a18cf8c6341df534a8d1b7cd68168825ce1e40d5 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 1 Mar 2018 15:11:29 +0100 Subject: [PATCH 357/567] ENH: find KNN in parallel for smote --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index b778e79f26..a64e663e28 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -147,6 +147,7 @@ void findKNNIndices(const SampleVectorType& inSamples, { const auto nbSamples = inSamples.size(); nnVector.resize(nbSamples); + #pragma omp parallel for for(size_t sampleIdx=0; sampleIdx<nbSamples; ++sampleIdx) { NNIndicesType nns; -- GitLab From ac462e2301a2443fe9fd2e9f9efc3ed80219ddf3 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 1 Mar 2018 15:17:18 +0100 Subject: [PATCH 358/567] ENH: generate samples in parallel for smote --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index a64e663e28..60f5e1c952 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -190,6 +190,7 @@ void smote(const SampleVectorType& inSamples, findKNNIndices(inSamples, nbNeighbors, nnVector); // The input samples are selected randomly with replacement std::srand(seed); + #pragma omp parallel for for(size_t i=0; i<nbSamples; ++i) { const auto sampleIdx = std::rand()%nbSamples; -- GitLab From f5f2db61f360b57c5d97f6f233307bc9ae4c041f Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 1 Mar 2018 15:30:10 +0100 Subject: [PATCH 359/567] BUG: modulo must be on the nb of input and not generated samples --- .../Sampling/include/otbSampleAugmentation.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index 60f5e1c952..8afa3d9925 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -192,13 +192,13 @@ void smote(const SampleVectorType& inSamples, std::srand(seed); #pragma omp parallel for for(size_t i=0; i<nbSamples; ++i) - { - const auto sampleIdx = std::rand()%nbSamples; - const auto sample = inSamples[sampleIdx]; - const auto neighborIdx = nnVector[sampleIdx][std::rand()%nbNeighbors].index; - const auto neighbor = inSamples[neighborIdx]; - newSamples[i] = smoteCombine(sample, neighbor, std::rand()/double{RAND_MAX}); - } + { + const auto sampleIdx = std::rand()%(inSamples.size()); + const auto sample = inSamples[sampleIdx]; + const auto neighborIdx = nnVector[sampleIdx][std::rand()%nbNeighbors].index; + const auto neighbor = inSamples[neighborIdx]; + newSamples[i] = smoteCombine(sample, neighbor, std::rand()/double{RAND_MAX}); + } } }//end namespaces sampleAugmentation -- GitLab From bb4296c597b509fea17d5dacf521aeccb1d407fb Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 1 Mar 2018 16:38:08 +0100 Subject: [PATCH 360/567] ENH: rename exluded features to excluded fields --- .../app/otbSampleAugmentation.cxx | 14 ++--- .../include/otbSampleAugmentationFilter.h | 16 +++--- .../include/otbSampleAugmentationFilter.txx | 51 ++++++++++--------- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx index b2fcb1deb6..ab00897140 100644 --- a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -215,10 +215,10 @@ private: std::vector<std::string> cFieldNames = GetChoiceNames("field"); std::string fieldName = cFieldNames[selectedCFieldIdx.front()]; - std::vector<std::string> excludedFeatures = - GetExcludedFeatures( GetChoiceNames( "exclude" ), - GetSelectedItems( "exclude" )); - for(const auto& ef : excludedFeatures) + std::vector<std::string> excludedFields = + GetExcludedFields( GetChoiceNames( "exclude" ), + GetSelectedItems( "exclude" )); + for(const auto& ef : excludedFields) otbAppLogINFO("Excluding feature " << ef << '\n'); int seed = std::time(nullptr); @@ -232,7 +232,7 @@ private: filter->SetOutputSamples(output); filter->SetClassFieldName(fieldName); filter->SetLabel(this->GetParameterInt("label")); - filter->SetExcludedFeatures(excludedFeatures); + filter->SetExcludedFields(excludedFields); filter->SetSeed(seed); switch (this->GetParameterInt("strategy")) { @@ -264,8 +264,8 @@ private: } - std::vector<std::string> GetExcludedFeatures(const std::vector<std::string>& fieldNames, - const std::vector<int>& selectedIdx) + std::vector<std::string> GetExcludedFields(const std::vector<std::string>& fieldNames, + const std::vector<int>& selectedIdx) { auto nbFeatures = static_cast<unsigned int>(selectedIdx.size()); std::vector<std::string> result( nbFeatures ); diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h index 754e96ef33..09467dfd26 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h @@ -91,13 +91,13 @@ public: } itkSetMacro(NumberOfSamples, int); itkGetMacro(NumberOfSamples, int); - void SetExcludedFeatures(const std::vector<std::string>& ef) + void SetExcludedFields(const std::vector<std::string>& ef) { - m_ExcludedFeatures = ef; + m_ExcludedFields = ef; } - std::vector<std::string> GetExcludedFeatures() const + std::vector<std::string> GetExcludedFields() const { - return m_ExcludedFeatures; + return m_ExcludedFields; } itkSetMacro(StdFactor, double); itkGetMacro(StdFactor, double); @@ -127,16 +127,16 @@ protected: SampleVectorType extractSamples(const ogr::DataSource::Pointer vectors, size_t layerName, const std::string& classField, const int label, - const std::vector<std::string>& excludedFeatures = {}); + const std::vector<std::string>& excludedFields = {}); void sampleToOGRFeatures(const ogr::DataSource::Pointer& vectors, ogr::DataSource* output, const SampleVectorType& samples, const size_t layerName, const std::string& classField, int label, - const std::vector<std::string>& excludedFeatures = {}); + const std::vector<std::string>& excludedFields = {}); -std::set<size_t> getExcludedFeaturesIds(const std::vector<std::string>& excludedFeatures, + std::set<size_t> getExcludedFieldsIds(const std::vector<std::string>& excludedFields, const ogr::Layer& inputLayer); bool isNumericField(const ogr::Feature& feature, const int idx); @@ -149,7 +149,7 @@ private: std::string m_ClassFieldName; size_t m_Layer; int m_Label; - std::vector<std::string> m_ExcludedFeatures; + std::vector<std::string> m_ExcludedFields; Strategy m_Strategy; int m_NumberOfSamples; double m_StdFactor; diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx index 612e0e22f5..9c0efb1491 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx +++ b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx @@ -84,7 +84,7 @@ SampleAugmentationFilter auto inSamples = this->extractSamples(inputDS, m_Layer, m_ClassFieldName, m_Label, - m_ExcludedFeatures); + m_ExcludedFields); SampleVectorType newSamples; switch (m_Strategy) { @@ -114,7 +114,7 @@ SampleAugmentationFilter this->sampleToOGRFeatures(inputDS, outputDS, newSamples, m_Layer, m_ClassFieldName, m_Label, - m_ExcludedFeatures); + m_ExcludedFields); // this->SetNthOutput(0,outputDS); @@ -128,7 +128,7 @@ SampleAugmentationFilter ::extractSamples(const ogr::DataSource::Pointer vectors, size_t layerName, const std::string& classField, const int label, - const std::vector<std::string>& excludedFeatures) + const std::vector<std::string>& excludedFields) { ogr::Layer layer = vectors->GetLayer(layerName); ogr::Feature feature = layer.ogr().GetNextFeature(); @@ -144,9 +144,10 @@ SampleAugmentationFilter } auto numberOfFields = feature.ogr().GetFieldCount(); - auto excludedIds = this->getExcludedFeaturesIds(excludedFeatures, layer); + auto excludedIds = this->getExcludedFieldsIds(excludedFields, layer); SampleVectorType samples; bool goesOn{feature.addr() != 0}; + int sampleCount{0}; while( goesOn ) { // Retrieve all the features for each field in the ogr layer. @@ -161,10 +162,12 @@ SampleAugmentationFilter mv.push_back(feature.ogr().GetFieldAsDouble(idx)); } samples.push_back(mv); + ++sampleCount; } feature = layer.ogr().GetNextFeature(); goesOn = feature.addr() != 0; } + std::cout << "Read " << sampleCount << "samples\n"; return samples; } @@ -175,11 +178,11 @@ SampleAugmentationFilter const SampleAugmentationFilter::SampleVectorType& samples, const size_t layerName, const std::string& classField, int label, - const std::vector<std::string>& excludedFeatures) + const std::vector<std::string>& excludedFields) { auto inputLayer = vectors->GetLayer(layerName); - auto excludedIds = this->getExcludedFeaturesIds(excludedFeatures, inputLayer); + auto excludedIds = this->getExcludedFieldsIds(excludedFields, inputLayer); OGRSpatialReference * oSRS = nullptr; if (inputLayer.GetSpatialRef()) @@ -217,25 +220,25 @@ SampleAugmentationFilter } } - std::set<size_t> - SampleAugmentationFilter - ::getExcludedFeaturesIds(const std::vector<std::string>& excludedFeatures, - const ogr::Layer& inputLayer) - { - auto feature = *(inputLayer).begin(); - std::set<size_t> excludedIds; - if( excludedFeatures.size() != 0) - { - for(const auto& fieldName : excludedFeatures) - { - auto idx = feature.ogr().GetFieldIndex( fieldName.c_str() ); - excludedIds.insert(idx); - } - } - return excludedIds; - } +std::set<size_t> +SampleAugmentationFilter +::getExcludedFieldsIds(const std::vector<std::string>& excludedFields, + const ogr::Layer& inputLayer) +{ + auto feature = *(inputLayer).begin(); + std::set<size_t> excludedIds; + if( excludedFields.size() != 0) + { + for(const auto& fieldName : excludedFields) + { + auto idx = feature.ogr().GetFieldIndex( fieldName.c_str() ); + excludedIds.insert(idx); + } + } + return excludedIds; +} - bool +bool SampleAugmentationFilter ::isNumericField(const ogr::Feature& feature, const int idx) -- GitLab From fdd5029708d0b58db7a063d1381b89db66d855c6 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 1 Mar 2018 16:48:53 +0100 Subject: [PATCH 361/567] ENH: change map to unordered_map and add layer option manipulation function --- .../include/otbOGRExtendedFilenameToOptions.h | 16 +++--- .../src/otbOGRExtendedFilenameToOptions.cxx | 53 +++++++++++++++---- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h index b33fcd8a77..d0a1ba667e 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h @@ -21,7 +21,7 @@ #ifndef otbOGRExtendedFilenameToOptions_h #define otbOGRExtendedFilenameToOptions_h -#include <set> +#include <unordered_map> #include "otbExtendedFilenameHelper.h" namespace otb @@ -51,21 +51,20 @@ public: struct OpenOptionType { std::pair< bool, std::string > simpleFileName; - std::pair< bool, GDALOptionType > gdalOptions; - std::map< std::string , bool > availableOptions; + GDALOptionType gdalOptions; + // std::unordered_map< std::string , bool > availableOptions; }; struct CreationOptionType { std::pair< bool, std::string > simpleFileName; - std::pair< bool, GDALOptionType > gdalOptions; - std::map< std::string , bool > availableOptions; + GDALOptionType gdalOptions; + // std::unordered_map< std::string , bool > availableOptions; }; struct LayerOptionType { - std::pair< bool, GDALOptionType > gdalOptions; - std::map< std::string , bool > availableOptions; + std::unordered_map< std::string , std::string > gdalOptions; }; /* Set Methods */ @@ -77,6 +76,9 @@ public: GDALOptionType GetGDALCreationOptions() const ; GDALOptionType GetGDALLayerOptions() const ; + void SetGDALLayerOptions( const GDALOptionType & options ); + void AddGDALLayerOptions( const GDALOptionType & options ); + protected: diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx index 81b4784e3c..75ada98385 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx @@ -59,18 +59,15 @@ SetExtendedFileName(const char *extFname) { if ( tmp[1]=="oo" ) { - m_OpenOptions.gdalOptions.first = true; - m_OpenOptions.gdalOptions.second.push_back(tmp[2] + "=" +it->second); + m_OpenOptions.gdalOptions.push_back(tmp[2] + "=" +it->second); } else if ( tmp[1]=="co" ) { - m_CreationOptions.gdalOptions.first = true; - m_CreationOptions.gdalOptions.second.push_back(tmp[2] + "=" +it->second); + m_CreationOptions.gdalOptions.push_back(tmp[2] + "=" +it->second); } else if ( tmp[1]=="lco" ) { - m_LayerOptions.gdalOptions.first = true; - m_LayerOptions.gdalOptions.second.push_back(tmp[2] + "=" +it->second); + m_LayerOptions.gdalOptions[tmp[2]] = it->second; } else { @@ -87,11 +84,11 @@ OGRExtendedFilenameToOptions:: GetGDALOptions( const std::string & type ) const { if ( type == "layer" ) - return m_LayerOptions.gdalOptions.second; + return GetGDALLayerOptions(); else if ( type == "creation" ) - return m_CreationOptions.gdalOptions.second; + return m_CreationOptions.gdalOptions; else if ( type == "open" ) - return m_OpenOptions.gdalOptions.second; + return m_OpenOptions.gdalOptions; else { // warn user : wrong option @@ -99,8 +96,42 @@ GetGDALOptions( const std::string & type ) const } } +OGRExtendedFilenameToOptions:: +GDALOptionType +OGRExtendedFilenameToOptions:: +GetGDALLayerOptions() const +{ + GDALOptionType options; + for (const auto & option : m_LayerOptions.gdalOptions ) + { + options.push_back( option.first + "=" + option.second ); + } + return options; +} +void +OGRExtendedFilenameToOptions:: +SetGDALLayerOptions( const OGRExtendedFilenameToOptions::GDALOptionType & options ) +{ + std::vector<std::string> tmp; + for ( const auto & option : options ) + { + boost::split(tmp, option , boost::is_any_of(":"), boost::token_compress_on); + m_LayerOptions.gdalOptions[ tmp[0] ] = tmp[1] ; + } +} +void +OGRExtendedFilenameToOptions:: +AddGDALLayerOptions( const OGRExtendedFilenameToOptions::GDALOptionType & options ) +{ + std::vector<std::string> tmp; + for ( const auto & option : options ) + { + boost::split(tmp, option , boost::is_any_of(":"), boost::token_compress_on); + m_LayerOptions.gdalOptions[ tmp[0] ] = tmp[1] ; + } +} #define GetGDALOptionMacro( Type ) \ OGRExtendedFilenameToOptions:: \ @@ -108,12 +139,12 @@ GDALOptionType \ OGRExtendedFilenameToOptions:: \ GetGDAL##Type##Options() const \ { \ - return m_##Type##Options.gdalOptions.second; \ + return m_##Type##Options.gdalOptions; \ } \ GetGDALOptionMacro( Open ) GetGDALOptionMacro( Creation ) -GetGDALOptionMacro( Layer ) +// GetGDALOptionMacro( Layer ) -- GitLab From e8e36d9ecccc861f10cc02e267d0cec1ba77e720 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 1 Mar 2018 17:01:12 +0100 Subject: [PATCH 362/567] ENH: use iterators instead of get next feature --- .../include/otbSampleAugmentationFilter.txx | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx index 9c0efb1491..ad77a0762f 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx +++ b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx @@ -131,41 +131,39 @@ SampleAugmentationFilter const std::vector<std::string>& excludedFields) { ogr::Layer layer = vectors->GetLayer(layerName); - ogr::Feature feature = layer.ogr().GetNextFeature(); - if(feature.addr() == 0) + auto featureIt = layer.begin(); + if(featureIt==layer.end()) { itkExceptionMacro("Layer " << layerName << " of input sample file is empty.\n"); } - int cFieldIndex = feature.ogr().GetFieldIndex( classField.c_str() ); + int cFieldIndex = (*featureIt).ogr().GetFieldIndex( classField.c_str() ); if( cFieldIndex < 0 ) { itkExceptionMacro( "The field name for class label (" << classField << ") has not been found in the vector file " ); } - auto numberOfFields = feature.ogr().GetFieldCount(); + auto numberOfFields = (*featureIt).ogr().GetFieldCount(); auto excludedIds = this->getExcludedFieldsIds(excludedFields, layer); SampleVectorType samples; - bool goesOn{feature.addr() != 0}; int sampleCount{0}; - while( goesOn ) + while( featureIt!=layer.end() ) { // Retrieve all the features for each field in the ogr layer. - if(feature.ogr().GetFieldAsInteger(classField.c_str()) == label) + if((*featureIt).ogr().GetFieldAsInteger(classField.c_str()) == label) { SampleType mv; for(auto idx=0; idx<numberOfFields; ++idx) { if(excludedIds.find(idx) == excludedIds.cend() && - this->isNumericField(feature, idx)) - mv.push_back(feature.ogr().GetFieldAsDouble(idx)); + this->isNumericField((*featureIt), idx)) + mv.push_back((*featureIt).ogr().GetFieldAsDouble(idx)); } samples.push_back(mv); ++sampleCount; } - feature = layer.ogr().GetNextFeature(); - goesOn = feature.addr() != 0; + ++featureIt; } std::cout << "Read " << sampleCount << "samples\n"; return samples; @@ -175,9 +173,9 @@ void SampleAugmentationFilter ::sampleToOGRFeatures(const ogr::DataSource::Pointer& vectors, ogr::DataSource* output, - const SampleAugmentationFilter::SampleVectorType& samples, - const size_t layerName, - const std::string& classField, int label, + const SampleAugmentationFilter::SampleVectorType& samples, + const size_t layerName, + const std::string& classField, int label, const std::vector<std::string>& excludedFields) { @@ -255,8 +253,7 @@ SampleAugmentationFilter const std::string& classField, int label) { auto featureIt = inputLayer.begin(); - bool goesOn{(*featureIt).addr() != 0}; - while( goesOn ) + while( featureIt!=inputLayer.end() ) { if((*featureIt).ogr().GetFieldAsInteger(classField.c_str()) == label) { -- GitLab From b36ef1e8730c57a8008a4df593723007b05bad7f Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 1 Mar 2018 17:02:39 +0100 Subject: [PATCH 363/567] ENH: add manipulation layer in datasource --- .../include/otbOGRDataSourceWrapper.h | 4 +++ .../src/otbOGRDataSourceWrapper.cxx | 26 +++++++++++++++++++ .../src/otbOGRExtendedFilenameToOptions.cxx | 4 +++ 3 files changed, 34 insertions(+) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h index c51e2636d2..700b80bdb9 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h @@ -499,6 +499,10 @@ public: */ ogr::version_proxy::GDALDatasetType & ogr(); + void SetLayerCreationOptions( std::vector< std::string > options ); + void AddLayerCreationOptions( std::vector< std::string > options ); + std::vector< std::string > GetLayerCreationOptions(); + protected: /** Default constructor. * The actual \c GDALDataset is using the <em>in-memory</em> \c diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx index 8660354fec..4ea0057464 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx @@ -567,7 +567,33 @@ otb::ogr::Layer otb::ogr::DataSource::ExecuteSQL( return otb::ogr::Layer(layer_ptr, *m_DataSource, modifiable); } +void +otb::ogr::DataSource:: +SetLayerCreationOptions( std::vector< std::string > options ) +{ + FileNameHelperType::Pointer helper = FileNameHelperType::New(); + helper->SetGDALLayerOptions( options ); + m_LayerOptions = helper->GetGDALLayerOptions(); + // perf : do we move code from helper->SetGDALLayerOptions in here? +} +void +otb::ogr::DataSource:: +AddLayerCreationOptions( std::vector< std::string > options ) +{ + FileNameHelperType::Pointer helper = FileNameHelperType::New(); + helper->SetGDALLayerOptions( m_LayerOptions ); + helper->AddGDALLayerOptions( options ); + m_LayerOptions = helper->GetGDALLayerOptions(); + // perf : do we move code from helper->AddGDALLayerOptions in here? +} + +std::vector< std::string > +otb::ogr::DataSource:: +GetLayerCreationOptions() +{ + return m_LayerOptions; +} /*===========================================================================*/ /*===============================[ features ]================================*/ /*===========================================================================*/ diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx index 75ada98385..59defd8f47 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx @@ -117,6 +117,8 @@ SetGDALLayerOptions( const OGRExtendedFilenameToOptions::GDALOptionType & option for ( const auto & option : options ) { boost::split(tmp, option , boost::is_any_of(":"), boost::token_compress_on); + if ( tmp.size()<2 ) + boost::split(tmp, option , boost::is_any_of("="), boost::token_compress_on); m_LayerOptions.gdalOptions[ tmp[0] ] = tmp[1] ; } } @@ -129,6 +131,8 @@ AddGDALLayerOptions( const OGRExtendedFilenameToOptions::GDALOptionType & option for ( const auto & option : options ) { boost::split(tmp, option , boost::is_any_of(":"), boost::token_compress_on); + if ( tmp.size()<2 ) + boost::split(tmp, option , boost::is_any_of("="), boost::token_compress_on); m_LayerOptions.gdalOptions[ tmp[0] ] = tmp[1] ; } } -- GitLab From c288f6d8de3ece912120c227359100be97929596 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 2 Mar 2018 08:34:56 +0100 Subject: [PATCH 364/567] ENH: create and copy layer concatenation of option --- .../include/otbOGRExtendedFilenameToOptions.h | 3 +- .../src/otbOGRDataSourceWrapper.cxx | 35 ++++++++++++++++--- .../src/otbOGRExtendedFilenameToOptions.cxx | 17 +++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h index d0a1ba667e..243b1d0f05 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h @@ -79,10 +79,11 @@ public: void SetGDALLayerOptions( const GDALOptionType & options ); void AddGDALLayerOptions( const GDALOptionType & options ); - + static Pointer GetGDALLayerOptionsHelper( const GDALOptionType & options ); protected: OGRExtendedFilenameToOptions(); + OGRExtendedFilenameToOptions( const GDALOptionType & options ); ~OGRExtendedFilenameToOptions() override {}; private: diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx index 4ea0057464..b48d691178 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx @@ -284,6 +284,12 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer( // Other mode : Check if the layer already exists. otb::ogr::Layer layer = GetLayer(name); // won't throw on failure + FileNameHelperType::Pointer layerOptionHelper = + FileNameHelperType::GetGDALLayerOptionsHelper( m_LayerOptions ); + layerOptionHelper->AddGDALLayerOptions( papszOptions ); + std::vector<std::string> layerOptions = + layerOptionHelper->GetGDALLayerOptions(); + switch (m_OpenMode) { case Modes::Update_LayerOverwrite: @@ -296,7 +302,11 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer( // Then create it OGRLayer * ol = m_DataSource->CreateLayer( - name.c_str(), poSpatialRef, eGType, otb::ogr::StringListConverter(papszOptions).to_ogr()); + name.c_str() , + poSpatialRef , + eGType , + otb::ogr::StringListConverter( layerOptions ).to_ogr() ); + if (!ol) { itkGenericExceptionMacro(<< "Failed to create the layer <"<<name @@ -319,7 +329,11 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer( { // Then create it OGRLayer * ol = m_DataSource->CreateLayer( - name.c_str(), poSpatialRef, eGType, otb::ogr::StringListConverter(papszOptions).to_ogr()); + name.c_str() , + poSpatialRef , + eGType , + otb::ogr::StringListConverter( layerOptions ).to_ogr() ); + if (!ol) { itkGenericExceptionMacro(<< "Failed to create the layer <"<<name @@ -343,7 +357,11 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer( // Case where the layer does not exists OGRLayer * ol = m_DataSource->CreateLayer( - name.c_str(), poSpatialRef, eGType, otb::ogr::StringListConverter(papszOptions).to_ogr()); + name.c_str() , + poSpatialRef , + eGType , + otb::ogr::StringListConverter( layerOptions ).to_ogr() ); + if (!ol) { itkGenericExceptionMacro(<< "Failed to create the layer <"<<name @@ -384,9 +402,18 @@ otb::ogr::Layer otb::ogr::DataSource::CopyLayer( default: break; } + + FileNameHelperType::Pointer layerOptionHelper = + FileNameHelperType::GetGDALLayerOptionsHelper( m_LayerOptions ); + layerOptionHelper->AddGDALLayerOptions( papszOptions ); + std::vector<std::string> layerOptions = + layerOptionHelper->GetGDALLayerOptions(); OGRLayer * l0 = &srcLayer.ogr(); - OGRLayer * ol = m_DataSource->CopyLayer(l0, newName.c_str(), otb::ogr::StringListConverter(papszOptions).to_ogr()); + OGRLayer * ol = m_DataSource->CopyLayer( + l0 , + newName.c_str() , + otb::ogr::StringListConverter( layerOptions ).to_ogr() ); if (!ol) { itkGenericExceptionMacro(<< "Failed to copy the layer <" diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx index 59defd8f47..69892352cd 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx @@ -36,6 +36,23 @@ OGRExtendedFilenameToOptions() } +OGRExtendedFilenameToOptions:: +OGRExtendedFilenameToOptions( const GDALOptionType & options ): +m_LayerOptions() +{ + this->SetGDALLayerOptions( options ); +} + +OGRExtendedFilenameToOptions::Pointer +OGRExtendedFilenameToOptions:: +GetGDALLayerOptionsHelper( const GDALOptionType & options ) +{ + Pointer res = new OGRExtendedFilenameToOptions( options ); + res->UnRegister(); + return res; +} + + void OGRExtendedFilenameToOptions:: SetExtendedFileName(const char *extFname) -- GitLab From 3dd9998d41f29a86028eaf30106b8efe435b065b Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 2 Mar 2018 08:39:54 +0100 Subject: [PATCH 365/567] REFAC: 80 char / line remove file from old merge --- .../src/otbOGRDataSourceWrapper.cxx | 87 +++++++++++-------- 1 file changed, 53 insertions(+), 34 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx index b48d691178..84b5b420de 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx @@ -124,11 +124,13 @@ otb::ogr::DataSource::DataSource() { Drivers::Init(); - ogr::version_proxy::GDALDriverType * d = ogr::version_proxy::GetDriverByName("Memory"); + ogr::version_proxy::GDALDriverType * d = + ogr::version_proxy::GetDriverByName("Memory"); assert(d && "OGR Memory driver not found"); m_DataSource = ogr::version_proxy::Create(d,"in-memory"); if (!m_DataSource) { - itkExceptionMacro(<< "Failed to create OGRMemDataSource: " << CPLGetLastErrorMsg()); + itkExceptionMacro(<< "Failed to create OGRMemDataSource: " + << CPLGetLastErrorMsg()); } } @@ -169,15 +171,18 @@ otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string c char const* driverName = DeduceDriverName(datasourceName); if (!driverName) { - itkGenericExceptionMacro(<< "No OGR driver known to OTB to create and handle a DataSource named <" + itkGenericExceptionMacro(<< "No OGR driver known to OTB to create and " + "handle a DataSource named <" <<datasourceName<<">."); } - ogr::version_proxy::GDALDriverType * d = ogr::version_proxy::GetDriverByName(driverName); + ogr::version_proxy::GDALDriverType * d = + ogr::version_proxy::GetDriverByName( driverName ); if(!d) { - itkGenericExceptionMacro(<<"Could not create OGR driver "<<driverName<<", check your OGR configuration for available drivers."); + itkGenericExceptionMacro(<< "Could not create OGR driver " << driverName + << ", check your OGR configuration for available drivers." ); } source = ogr::version_proxy::Create( @@ -185,11 +190,12 @@ otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string c simpleFileName.c_str() , fileNameHelper->GetGDALCreationOptions() ); if (!source) { - itkGenericExceptionMacro(<< "Failed to create GDALDataset <"<<datasourceName - <<"> (driver name: <" << driverName<<">: " << CPLGetLastErrorMsg()); + itkGenericExceptionMacro(<< "Failed to create GDALDataset <" + << datasourceName << "> (driver name: <" << driverName + <<">: " << CPLGetLastErrorMsg()); } } - return otb::ogr::DataSource::New(source, mode); + return otb::ogr::DataSource::New( source, mode ); } void DeleteDataSource(std::string const& datasourceName) @@ -207,12 +213,13 @@ otb::ogr::DataSource::New(std::string const& datasourceName, Modes::type mode) { if (mode < Modes::Read || mode >= Modes::MAX__) { - itkGenericExceptionMacro(<< "Wrong mode when opening " << datasourceName); + itkGenericExceptionMacro(<< "Wrong mode when opening " << datasourceName ); } Drivers::Init(); - ogr::version_proxy::GDALDatasetType * ds = ogr::version_proxy::Open(datasourceName.c_str(),true); + ogr::version_proxy::GDALDatasetType * ds = + ogr::version_proxy::Open( datasourceName.c_str() , true ); bool ds_exists = (ds!=ITK_NULLPTR); @@ -277,7 +284,8 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer( if (m_OpenMode == Modes::Read) { otb::ogr::Layer l = GetLayerChecked(name); // will throw if not existing - itkGenericOutputMacro(<< "Requesting layer creation in read-only GDALDataset. Returning the existing layer"); + itkGenericOutputMacro(<< "Requesting layer creation in read-only " + "GDALDataset. Returning the existing layer"); return l; } @@ -310,7 +318,7 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer( if (!ol) { itkGenericExceptionMacro(<< "Failed to create the layer <"<<name - << "> in the GDALDataset file <" << GetDatasetDescription() + << "> in the GDALDataset file <" << GetDatasetDescription() <<">: " << CPLGetLastErrorMsg()); } @@ -337,7 +345,7 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer( if (!ol) { itkGenericExceptionMacro(<< "Failed to create the layer <"<<name - << "> in the GDALDataset file <" << GetDatasetDescription() + << "> in the GDALDataset file <" << GetDatasetDescription() <<">: " << CPLGetLastErrorMsg()); } @@ -365,7 +373,7 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer( if (!ol) { itkGenericExceptionMacro(<< "Failed to create the layer <"<<name - << "> in the GDALDataset file <" << GetDatasetDescription() + << "> in the GDALDataset file <" << GetDatasetDescription() <<">: " << CPLGetLastErrorMsg()); } @@ -397,7 +405,8 @@ otb::ogr::Layer otb::ogr::DataSource::CopyLayer( itkGenericExceptionMacro(<< "Invalid GDALDataset opening mode"); break; case Modes::Read: - itkGenericExceptionMacro(<< "GDALDataset is opened in Read mode : cannot create a layer"); + itkGenericExceptionMacro(<< "GDALDataset is opened in Read mode : " + "cannot create a layer"); break; default: break; @@ -417,12 +426,12 @@ otb::ogr::Layer otb::ogr::DataSource::CopyLayer( if (!ol) { itkGenericExceptionMacro(<< "Failed to copy the layer <" - << srcLayer.GetName() << "> into the new layer <" <<newName - << "> in the GDALDataset file <" << GetDatasetDescription() + << srcLayer.GetName() << "> into the new layer <" << newName + << "> in the GDALDataset file <" << GetDatasetDescription() <<">: " << CPLGetLastErrorMsg()); } const bool modifiable = true; - Layer l(ol, modifiable); + Layer l( ol , modifiable ); return l; } @@ -437,10 +446,12 @@ void otb::ogr::DataSource::DeleteLayer(size_t i) itkGenericExceptionMacro(<< "Invalid GDALDataset opening mode"); break; case Modes::Read: - itkGenericExceptionMacro(<< "GDALDataset is opened in Read mode : cannot delete a layer"); + itkGenericExceptionMacro(<< "GDALDataset is opened in Read mode : " + "cannot delete a layer"); break; case Modes::Update_LayerCreateOnly: - itkGenericExceptionMacro(<< "GDALDataset is opened in Update_LayerCreateOnly mode : cannot delete a layer"); + itkGenericExceptionMacro(<< "GDALDataset is opened in " + "Update_LayerCreateOnly mode : cannot delete a layer"); break; default: break; @@ -449,14 +460,16 @@ void otb::ogr::DataSource::DeleteLayer(size_t i) const int nb_layers = GetLayersCount(); if (int(i) >= nb_layers) { - itkExceptionMacro(<< "Cannot delete " << i << "th layer in the GDALDataset <" - << GetDatasetDescription() << "> as it contains only " << nb_layers << "layers."); + itkExceptionMacro(<< "Cannot delete " << i + << "th layer in the GDALDataset <" << GetDatasetDescription() + << "> as it contains only " << nb_layers << "layers."); } const OGRErr err = m_DataSource->DeleteLayer(int(i)); if (err != OGRERR_NONE) { - itkExceptionMacro(<< "Cannot delete " << i << "th layer in the GDALDataset <" - << GetDatasetDescription() << ">: " << CPLGetLastErrorMsg()); + itkExceptionMacro(<< "Cannot delete " << i + << "th layer in the GDALDataset <" << GetDatasetDescription() + << ">: " << CPLGetLastErrorMsg()); } } @@ -513,7 +526,7 @@ size_t otb::ogr::DataSource::GetLayerID(std::string const& name) const if (id < 0) { itkExceptionMacro( << "Cannot fetch any layer named <" << name - << "> in the GDALDataset <" << GetDatasetDescription() << ">: " + << "> in the GDALDataset <" << GetDatasetDescription() << ">: " << CPLGetLastErrorMsg()); } return 0; // keep compiler happy @@ -526,13 +539,15 @@ otb::ogr::Layer otb::ogr::DataSource::GetLayerChecked(size_t i) if (int(i) >= nb_layers) { itkExceptionMacro(<< "Cannot fetch " << i << "th layer in the GDALDataset <" - << GetDatasetDescription() << "> as it contains only " << nb_layers << "layers."); + << GetDatasetDescription() << "> as it contains only " << nb_layers + << "layers."); } OGRLayer * layer_ptr = m_DataSource->GetLayer(int(i)); if (!layer_ptr) { - itkExceptionMacro( << "Unexpected error: cannot fetch " << i << "th layer in the GDALDataset <" - << GetDatasetDescription() << ">: " << CPLGetLastErrorMsg()); + itkExceptionMacro( << "Unexpected error: cannot fetch " << i + << "th layer in the GDALDataset <" << GetDatasetDescription() + << ">: " << CPLGetLastErrorMsg()); } return otb::ogr::Layer(layer_ptr, IsLayerModifiable(i)); } @@ -582,8 +597,9 @@ otb::ogr::Layer otb::ogr::DataSource::ExecuteSQL( if (!layer_ptr) { #if defined(PREFER_EXCEPTION) - itkExceptionMacro( << "Unexpected error: cannot execute the SQL request <" << statement - << "> in the GDALDataset <" << GetDatasetDescription() << ">: " << CPLGetLastErrorMsg()); + itkExceptionMacro( << "Unexpected error: cannot execute the SQL request <" + << statement << "> in the GDALDataset <" << GetDatasetDescription() + << ">: " << CPLGetLastErrorMsg()); #else // Cannot use the deleter made for result sets obtained from // GDALDataset::ExecuteSQL because it checks for non-nullity.... @@ -659,7 +675,8 @@ OGREnvelope otb::ogr::DataSource::GetGlobalExtent(bool force/* = false */, std:: if(lit==this->end()) { - itkGenericExceptionMacro(<< "Cannot compute global extent because there are no layers in the DataSource"); + itkGenericExceptionMacro(<< "Cannot compute global extent because there " + "are no layers in the DataSource"); } const OGRSpatialReference * ref_srs = lit->GetSpatialRef(); @@ -763,16 +780,18 @@ void otb::ogr::DataSource::SyncToDisk() if(!ret) { itkExceptionMacro( << "Cannot flush the pending of the OGRDataSource <" - << GetDatasetDescription() << ">: " << CPLGetLastErrorMsg()); + << GetDatasetDescription() << ">: " << CPLGetLastErrorMsg()); } } std::string otb::ogr::DataSource::GetDatasetDescription() const { - std::vector<std::string> files = otb::ogr::version_proxy::GetFileListAsStringVector(m_DataSource); + std::vector<std::string> files = + otb::ogr::version_proxy::GetFileListAsStringVector( m_DataSource ); std::string description = ""; - for(std::vector<std::string>::const_iterator it = files.begin();it!=files.end();++it) + for( std::vector<std::string>::const_iterator it = files.begin() ; + it!=files.end() ; ++it ) description+=(*it)+", "; return description; -- GitLab From 964aa04434aa2f9d1c80837a3268232dbf835da2 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 2 Mar 2018 08:56:31 +0100 Subject: [PATCH 366/567] REFAC: delete file from old merge and restore VectorDataIOBase --- .../otbOGRExtendedFilenameToReaderOptions.h | 72 ------------------- .../otbOGRExtendedFilenameToWriterOptions.h | 39 ---------- .../otbOGRExtendedFilenameToReaderOptions.cxx | 51 ------------- .../otbOGRExtendedFilenameToWriterOptions.cxx | 27 ------- .../include/otbVectorDataIOBase.h | 5 -- 5 files changed, 194 deletions(-) delete mode 100644 Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h delete mode 100644 Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h delete mode 100644 Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx delete mode 100644 Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h deleted file mode 100644 index 0f5f47df6d..0000000000 --- a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToReaderOptions.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef otbOGRExtendedFilenameToReaderOptions_h -#define otbOGRExtendedFilenameToReaderOptions_h - -#include <set> -#include "otbExtendedFilenameHelper.h" - -namespace otb -{ - -/** \class OGRExtendedFilenameToReaderOptions - */ - -class ITK_EXPORT OGRExtendedFilenameToReaderOptions : public ExtendedFilenameHelper -{ -public: - /** Standard class typedefs. */ - typedef OGRExtendedFilenameToReaderOptions Self; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - typedef ExtendedFilenameHelper Superclass; - - typedef Superclass::OptionMapType OptionMapType; - typedef OptionMapType::iterator MapIteratorType; - - itkTypeMacro(OGRExtendedFilenameToReaderOptions, otb::ExtendedFilenameHelper); - itkNewMacro(Self); - - /** The creation option structure. */ - struct OptionType - { - std::pair< bool , std::string > simpleFileName; - std::pair< bool , std::string > shapeFileType; - std::set< std::string > availableOptions; - }; - - /* Set Methods */ - void SetExtendedFileName(const char * extFname) override; - -protected: - OGRExtendedFilenameToReaderOptions(); - ~OGRExtendedFilenameToReaderOptions() override {}; - -private: - OGRExtendedFilenameToReaderOptions(const Self &) = delete ; - void operator =(const Self&) = delete ; - - OptionType m_Options; -}; - -} //end namespace otb - -#endif // otbOGRExtendedFilenameToReaderOptions_h diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h deleted file mode 100644 index 8c8422166f..0000000000 --- a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToWriterOptions.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef otbOGRExtendedFilenameToWriterOptions_h -#define otbOGRExtendedFilenameToWriterOptions_h - -#include "otbExtendedFilenameHelper.h" - -namespace otb -{ - -/** \class OGRExtendedFilenameToWriterOptions - */ - -class ITK_EXPORT OGRExtendedFilenameToWriterOptions : public ExtendedFilenameHelper -{ -public: -}; - -} //end namespace otb - -#endif // otbOGRExtendedFilenameToWriterOptions_h \ No newline at end of file diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx deleted file mode 100644 index e82b738c35..0000000000 --- a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToReaderOptions.cxx +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "otbOGRExtendedFilenameToReaderOptions.h" - -namespace otb -{ - -OGRExtendedFilenameToReaderOptions:: -OGRExtendedFilenameToReaderOptions() -{ - m_Options.simpleFileName.first = false; - m_Options.simpleFileName.second = ""; - - m_Options.shapeFileType.first = false; - m_Options.shapeFileType.second = ""; - - m_Options.availableOptions.insert("shpt"); -} - -void -OGRExtendedFilenameToReaderOptions:: -SetExtendedFileName(const char *extFname) -{ - Superclass::SetExtendedFileName(extFname); - OptionMapType map = GetOptionMap(); - - m_Options.simpleFileName.first = true; - m_Options.simpleFileName.second = this->GetSimpleFileName(); - -} - - -} //end namespace otb diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx deleted file mode 100644 index dc491e3680..0000000000 --- a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToWriterOptions.cxx +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "otbOGRExtendedFilenameToReaderOptions.h" - -namespace otb -{ - - -} //end namespace otb \ No newline at end of file diff --git a/Modules/Core/VectorDataBase/include/otbVectorDataIOBase.h b/Modules/Core/VectorDataBase/include/otbVectorDataIOBase.h index e95b2e53aa..de1e241fc2 100644 --- a/Modules/Core/VectorDataBase/include/otbVectorDataIOBase.h +++ b/Modules/Core/VectorDataBase/include/otbVectorDataIOBase.h @@ -29,7 +29,6 @@ #include "itkDataObject.h" #include "OTBVectorDataBaseExport.h" -#include "otbOGRExtendedFilenameToOptions.h" namespace otb { @@ -73,8 +72,6 @@ public: typedef itk::Vector<double, VDimension> SpacingType; typedef itk::Point<double, VDimension> PointType; - typedef otb::OGRExtendedFilenameToOptions FileNameHelperType; - /** Set/Get the name of the file to be read. */ itkSetStringMacro(FileName); itkGetStringMacro(FileName); @@ -176,8 +173,6 @@ private: VectorDataIOBase(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented - FileNameHelperType m_FileNameHelper; - }; } // end namespace otb -- GitLab From 3b3914648d9d5504d8bd1840e79cd6fab69d4086 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Fri, 2 Mar 2018 09:25:17 +0100 Subject: [PATCH 367/567] Review parameters description of otbContrastEnhancement application --- .../app/otbContrastEnhancement.cxx | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx index d74b2a79e1..ec2af7c1a4 100644 --- a/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx +++ b/Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx @@ -186,10 +186,10 @@ private: AddParameter(ParameterType_OutputImage, "out", "Output Image"); SetParameterDescription("out", "Output image."); - AddParameter(ParameterType_Int , "bins" , "Number of bin"); + AddParameter(ParameterType_Int , "bins" , "Number of bins"); SetDefaultParameterInt("bins", 256); SetParameterDescription("bins", - "Number of bin used to create the histogram"); + "Number of bins in the histogram"); AddParameter(ParameterType_Float , "hfact" , "Contrast Limitation"); SetParameterDescription("hfact","This parameter will set the maximum " @@ -214,8 +214,8 @@ private: "equalized and the corresponding gain will be interpolated."); AddChoice( "spatial.global" , "Global" ); SetParameterDescription("spatial.global" , "The histogram will be " - "computed on the whole image. The equalization will be done on " - "this single histogram."); + "computed on the whole image. The equalization will be computed on " + "this histogram."); AddParameter(ParameterType_Int,"spatial.local.h" , @@ -224,7 +224,7 @@ private: "Thumbnail width in pixel"); AddParameter(ParameterType_Choice , "minmax" , "Minimum and maximum " - "definition"); + "settings"); SetParameterDescription("minmax","Minimum and maximum value that will " "bound the histogram."); AddChoice( "minmax.auto" , "Automatic" ); @@ -235,11 +235,11 @@ private: SetParameterDescription("minmax.auto.global" , "Automatic" "Min/max computation will result in the same minimum and maximum for " "all the bands."); - AddChoice( "minmax.manual" , "Manual" ); + AddChoice( "minmax.manual" , "Manual settings of min/max values" ); SetParameterDescription("minmax.auto","Minimum and maximum value will be " "set by the user"); - AddParameter(ParameterType_Float , "minmax.manual.min" , "Minimum"); - AddParameter(ParameterType_Float , "minmax.manual.max" , "Maximum"); + AddParameter(ParameterType_Float , "minmax.manual.min" , "Minimum value"); + AddParameter(ParameterType_Float , "minmax.manual.max" , "Maximum value"); MandatoryOff("minmax.manual.min"); MandatoryOff("minmax.manual.max"); @@ -257,25 +257,25 @@ private: "on how human eyes perceive colors)" ); - AddParameter(ParameterType_Group , "mode.lum.red" , "Red Channel" ); - AddParameter(ParameterType_Int , "mode.lum.red.ch" , "Red Channel" ); + AddParameter(ParameterType_Group , "mode.lum.red" , "Red channel" ); + AddParameter(ParameterType_Int , "mode.lum.red.ch" , "Red channel" ); SetDefaultParameterInt("mode.lum.red.ch", 0 ); AddParameter(ParameterType_Float , "mode.lum.red.coef" , - "Value for luminance computation" ); + "Value for luminance computation for the red channel" ); SetDefaultParameterFloat("mode.lum.red.coef", 0.21 ); - AddParameter(ParameterType_Group , "mode.lum.green" , "Green Channel" ); - AddParameter(ParameterType_Int , "mode.lum.green.ch" , "Green Channel" ); + AddParameter(ParameterType_Group , "mode.lum.green" , "Green channel" ); + AddParameter(ParameterType_Int , "mode.lum.green.ch" , "Green channel" ); SetDefaultParameterInt("mode.lum.green.ch", 1 ); AddParameter(ParameterType_Float , "mode.lum.green.coef" , - "Value for luminance computation" ); + "Value for luminance computation of the green channel" ); SetDefaultParameterFloat("mode.lum.green.coef", 0.71 ); - AddParameter(ParameterType_Group , "mode.lum.blue" , "Blue Channel" ); - AddParameter(ParameterType_Int , "mode.lum.blue.ch" , "Blue Channel" ); + AddParameter(ParameterType_Group , "mode.lum.blue" , "Blue channel" ); + AddParameter(ParameterType_Int , "mode.lum.blue.ch" , "Blue channel" ); SetDefaultParameterInt("mode.lum.blue.ch", 2 ); AddParameter(ParameterType_Float , "mode.lum.blue.coef" , - "Value for luminance computation" ); + "Value for luminance computation of the blue channel" ); SetDefaultParameterFloat("mode.lum.blue.coef", 0.08 ); SetDefaultParameterInt( "spatial.local.w" , 256 ); @@ -289,8 +289,8 @@ private: SetMinimumParameterIntValue("spatial.local.w", 1); SetExampleComment( "Local contrast enhancement by luminance" , 0 ); - SetDocExampleParameterValue( "in" , "couleurs.tif" ); - SetDocExampleParameterValue( "out" , "equalizedcouleurs.tif float" ); + SetDocExampleParameterValue( "in" , "colours.tif" ); + SetDocExampleParameterValue( "out" , "equalizedcolors.tif float" ); SetDocExampleParameterValue( "bins" , "256" ); SetDocExampleParameterValue( "spatial.local.w" , "500" ); SetDocExampleParameterValue( "spatial.local.h" , "500"); -- GitLab From d4b4ec23125246a644c81a3536c160af2bb079da Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Fri, 2 Mar 2018 11:12:12 +0100 Subject: [PATCH 368/567] BUG: deal with the case where no samples are found --- .../Sampling/include/otbSampleAugmentationFilter.txx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx index ad77a0762f..168631df9d 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx +++ b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx @@ -165,8 +165,12 @@ SampleAugmentationFilter } ++featureIt; } - std::cout << "Read " << sampleCount << "samples\n"; - return samples; + if(sampleCount==0) + { + itkExceptionMacro("Could not find any samples in layer " << layerName << + " with label " << label << '\n'); + } + return samples; } void -- GitLab From 12d72d1249821f67230ccfd7bb9346d672526743 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Fri, 2 Mar 2018 11:13:39 +0100 Subject: [PATCH 369/567] BUG: memory allocation and modulo over the wrong size --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index 8afa3d9925..cbfd1d3882 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -100,12 +100,14 @@ void jitterSamples(const SampleVectorType& inSamples, // We use one gaussian distribution per component since they may // have different stds auto stds = estimateStds(inSamples); - std::vector<std::normal_distribution<double>> gaussDis; + std::vector<std::normal_distribution<double>> gaussDis(nbComponents); +#pragma omp parallel for for(size_t i=0; i<nbComponents; ++i) - gaussDis.emplace_back(std::normal_distribution<double>{0.0, stds[i]/stdFactor}); + gaussDis[i] = std::normal_distribution<double>{0.0, stds[i]/stdFactor}; +#pragma omp parallel for for(size_t i=0; i<nbSamples; ++i) { - newSamples[i] = inSamples[std::rand()%nbSamples]; + newSamples[i] = inSamples[std::rand()%inSamples.size()]; for(size_t j=0; j<nbComponents; ++j) newSamples[i][j] += gaussDis[j](gen); } -- GitLab From 40d2240a97bde83da6286c298df4d7aea8df01ac Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Fri, 2 Mar 2018 11:14:03 +0100 Subject: [PATCH 370/567] ENH: parallel loops when possible --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index cbfd1d3882..40f62d0cb8 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -46,6 +46,7 @@ SampleType estimateStds(SampleVectorType samples) const auto nbComponents = samples[0].size(); SampleType stds(nbComponents, 0.0); SampleType means(nbComponents, 0.0); +#pragma omp parallel for for(size_t i=0; i<nbSamples; ++i) { for(size_t j=0; j<nbComponents; ++j) @@ -57,9 +58,10 @@ SampleType estimateStds(SampleVectorType samples) means[j] = muNew; } } - for(auto std : stds) +#pragma omp parallel for + for(size_t j=0; j<nbComponents; ++j) { - std = std::sqrt(std/nbSamples); + stds[j] = std::sqrt(stds[j]/nbSamples); } return stds; } @@ -73,6 +75,7 @@ void replicateSamples(const SampleVectorType& inSamples, SampleVectorType& newSamples) { newSamples.resize(nbSamples); +#pragma omp parallel for for(size_t i=0; i<nbSamples; ++i) { newSamples[i] = inSamples[i%inSamples.size()]; -- GitLab From e3028af8537f66aa927f8352ed1b61322aee5f1a Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Fri, 2 Mar 2018 11:30:32 +0100 Subject: [PATCH 371/567] TEST: adapt stdfactor value for test --- Modules/Applications/AppClassification/test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Applications/AppClassification/test/CMakeLists.txt b/Modules/Applications/AppClassification/test/CMakeLists.txt index c134b6b355..e848e08ed8 100644 --- a/Modules/Applications/AppClassification/test/CMakeLists.txt +++ b/Modules/Applications/AppClassification/test/CMakeLists.txt @@ -994,7 +994,7 @@ otb_test_application(NAME apTvClSampleAugmentationJitter -out ${TEMP}/apTvClSampleAugmentationJitter.sqlite -exclude originfid -strategy jitter - -strategy.jitter.stdfactor 10000 + -strategy.jitter.stdfactor 10 ) otb_test_application(NAME apTvClSampleAugmentationSmote -- GitLab From b567e688e4c1ead82afef03a095ea0671e0e26ed Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Fri, 2 Mar 2018 11:33:08 +0100 Subject: [PATCH 372/567] ENH: correct default stdfactor for jitter strategy --- .../AppClassification/app/otbSampleAugmentation.cxx | 2 +- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx index ab00897140..9749a9f4c4 100644 --- a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -116,7 +116,7 @@ private: "The noise added to the input samples will have the " "standard deviation of the input features divided " "by the value of this parameter. "); - SetDefaultParameterFloat("strategy.jitter.stdfactor",10000); + SetDefaultParameterFloat("strategy.jitter.stdfactor",10); AddChoice("strategy.smote","Smote input samples"); SetParameterDescription("strategy.smote","The new samples are generated " diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index 40f62d0cb8..f562a636e6 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -85,13 +85,13 @@ void replicateSamples(const SampleVectorType& inSamples, /** Create new samples by adding noise to existing samples. Gaussian * noise is added to randomly selected samples. The standard deviation * of the noise added to each component is the same as the one of the -* input variables multiplied by stdFactor (defaults to 1). The +* input variables divided by stdFactor (defaults to 10). The * elements of newSamples are removed before proceeding. */ void jitterSamples(const SampleVectorType& inSamples, const size_t nbSamples, SampleVectorType& newSamples, - float stdFactor=10000, + float stdFactor=10, const int seed = std::time(nullptr)) { newSamples.resize(nbSamples); -- GitLab From 815841d612550ea2ab22321490c4a3878af8ad83 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Fri, 2 Mar 2018 11:38:59 +0100 Subject: [PATCH 373/567] ENH: initialize members and indent --- .../include/otbSampleAugmentationFilter.txx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx index 168631df9d..f7023c9b33 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx +++ b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx @@ -28,7 +28,10 @@ namespace otb { SampleAugmentationFilter -::SampleAugmentationFilter() : m_ClassFieldName("class") +::SampleAugmentationFilter() : m_ClassFieldName{"class"}, m_Layer{0}, m_Label{1}, + m_Strategy{SampleAugmentationFilter::Strategy::Replicate}, + m_NumberOfSamples{100}, m_StdFactor{10.0}, + m_SmoteNeighbors{5}, m_Seed{0} { this->SetNumberOfRequiredInputs(1); this->SetNumberOfRequiredOutputs(1); @@ -170,7 +173,7 @@ SampleAugmentationFilter itkExceptionMacro("Could not find any samples in layer " << layerName << " with label " << label << '\n'); } - return samples; + return samples; } void @@ -246,9 +249,9 @@ SampleAugmentationFilter const int idx) { OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(idx)->GetType(); - return (fieldType == OFTInteger - || ogr::version_proxy::IsOFTInteger64( fieldType ) - || fieldType == OFTReal); + return (fieldType == OFTInteger + || ogr::version_proxy::IsOFTInteger64( fieldType ) + || fieldType == OFTReal); } ogr::Feature -- GitLab From 736a05e1945729019330e7af4166a93f2f29e136 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Fri, 2 Mar 2018 14:25:39 +0100 Subject: [PATCH 374/567] ENH: remove readme of template remote module from MPIConfig module --- Modules/MPI/MPIConfig/README | 71 ------------------------------------ 1 file changed, 71 deletions(-) delete mode 100644 Modules/MPI/MPIConfig/README diff --git a/Modules/MPI/MPIConfig/README b/Modules/MPI/MPIConfig/README deleted file mode 100644 index e30ca8bb5c..0000000000 --- a/Modules/MPI/MPIConfig/README +++ /dev/null @@ -1,71 +0,0 @@ -General -======= - -This is a template module for the ORFEO -Toolbox(https://www.orfeo-toolbox.org/). It is designed to work with OTBv5 -modular system and to be places in OTB/Module/Remote. - -This module is empty it is just a template to be used as a starting point for a -module with actual content. It contains the template for sources (src folder), -test (test folder) and application (app folder). - -Getting Started -=============== - -The official OTB Wiki documentation on adding an external module is here: -http://wiki.orfeo-toolbox.org/index.php/How_to_write_a_remote_module - -Remote Module -------------- - -After a module has been created as a git repository it can be included -as a remote module, which enables automatic fetching. Add a file in -"OTB/Modules/Remote" called "YourModule.remote.cmake", for this module -it would be "ExternalExample.remote.cmake" with the followlowing contents: - -otb_fetch_module(ExternalTemplate - "A template for a module." - GIT_REPOSITORY https://github.com/orfeotoolbox/otbExternalModuleTemplate - GIT_TAG master - ) - -Editing -======= - -The CMakeLists.txt and otb-modules need to be modified with the name of the -module, something along the following: - -sed 's/ExternalTemplate/MyModule/g' CMakeLists.txt otb-module.cmake - -There is the inplace option to sed, but it's not portable, so do this change by -hand or look up the option in sed. - -Then hack away at you code in include, src, test and app folders. - -License -======= - -This software is distributed under the Apache License. Please see LICENSE for -details. - -Author -====== - -Manuel Grizonnet - -Thanks -====== - -It is a fork of the ITK template module provided by Bradley Lowekamp -(https://github.com/blowekamp/itkExternalTemplate.git) which was adapted for the -ORFEO ToolBox. - -Compilation des tests -===================== -module load cmake/3.4.3 openmpi/1.10.2 otb/develop -cd build -rm -rf * -cmake -DCMAKE_CXX_FLAGS="-Wno-unused-local-typedefs -std=c++11" .. -make -ctest - -- GitLab From e285d9ec09d3cf8d5e7ec3703cbf25d8818419d6 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Fri, 2 Mar 2018 14:26:16 +0100 Subject: [PATCH 375/567] ENH: remove MPIConfig_LIBRARIES cmake variable (use OTBMPIConfig_LIBRARIES instead) --- Modules/MPI/MPIConfig/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/Modules/MPI/MPIConfig/CMakeLists.txt b/Modules/MPI/MPIConfig/CMakeLists.txt index ed0784dadc..dabc7a26ac 100644 --- a/Modules/MPI/MPIConfig/CMakeLists.txt +++ b/Modules/MPI/MPIConfig/CMakeLists.txt @@ -19,9 +19,6 @@ # project(MPIConfig) -set(MPIConfig_LIBRARIES MPIConfig) - set(OTBMPIConfig_LIBRARIES OTBMPIConfig) otb_module_impl() - -- GitLab From 159176148b6e43e7200d085de5689c1f8b210883 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 2 Mar 2018 14:50:57 +0100 Subject: [PATCH 376/567] REFAC: change export and change design --- .../include/otbOGRExtendedFilenameToOptions.h | 11 ++-- .../src/otbOGRExtendedFilenameToOptions.cxx | 64 +++++++++++-------- 2 files changed, 43 insertions(+), 32 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h index 243b1d0f05..c60d8c3be4 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h @@ -29,8 +29,9 @@ namespace otb /** \class OGRExtendedFilenameToOptions */ +#include "OTBGdalAdaptersExport.h" -class ITK_EXPORT OGRExtendedFilenameToOptions : public ExtendedFilenameHelper +class OTBGdalAdapters_EXPORT OGRExtendedFilenameToOptions : public ExtendedFilenameHelper { public: /** Standard class typedefs. */ @@ -41,23 +42,21 @@ public: typedef Superclass::OptionMapType OptionMapType; typedef OptionMapType::iterator MapIteratorType; + typedef std::vector<std::string> GDALOptionType; itkTypeMacro(OGRExtendedFilenameToOptions, otb::ExtendedFilenameHelper); itkNewMacro(Self); - typedef std::vector<std::string> GDALOptionType; /** The creation option structure. */ struct OpenOptionType { - std::pair< bool, std::string > simpleFileName; GDALOptionType gdalOptions; // std::unordered_map< std::string , bool > availableOptions; }; struct CreationOptionType { - std::pair< bool, std::string > simpleFileName; GDALOptionType gdalOptions; // std::unordered_map< std::string , bool > availableOptions; }; @@ -76,6 +75,9 @@ public: GDALOptionType GetGDALCreationOptions() const ; GDALOptionType GetGDALLayerOptions() const ; + bool SimpleFileNameIsSet() const; + bool HasGDALLayerOption() const; + void SetGDALLayerOptions( const GDALOptionType & options ); void AddGDALLayerOptions( const GDALOptionType & options ); @@ -93,6 +95,7 @@ private: OpenOptionType m_OpenOptions; CreationOptionType m_CreationOptions; LayerOptionType m_LayerOptions; + bool m_HasFileName; }; } //end namespace otb diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx index 69892352cd..4e760c74cb 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx @@ -26,19 +26,15 @@ namespace otb { OGRExtendedFilenameToOptions:: -OGRExtendedFilenameToOptions() +OGRExtendedFilenameToOptions(): +m_HasFileName(false) { - m_OpenOptions.simpleFileName.first = false; - m_OpenOptions.simpleFileName.second = ""; - - m_CreationOptions.simpleFileName.first = false; - m_CreationOptions.simpleFileName.second = ""; - } OGRExtendedFilenameToOptions:: OGRExtendedFilenameToOptions( const GDALOptionType & options ): -m_LayerOptions() +m_LayerOptions(), +m_HasFileName(false) { this->SetGDALLayerOptions( options ); } @@ -58,13 +54,9 @@ OGRExtendedFilenameToOptions:: SetExtendedFileName(const char *extFname) { Superclass::SetExtendedFileName(extFname); - OptionMapType map = GetOptionMap(); + m_HasFileName = true; - m_OpenOptions.simpleFileName.first = true; - m_OpenOptions.simpleFileName.second = this->GetSimpleFileName(); - - m_CreationOptions.simpleFileName.first = true; - m_CreationOptions.simpleFileName.second = this->GetSimpleFileName(); + OptionMapType map = GetOptionMap(); MapIteratorType it; for ( it=map.begin(); it != map.end(); it++ ) @@ -113,19 +105,6 @@ GetGDALOptions( const std::string & type ) const } } -OGRExtendedFilenameToOptions:: -GDALOptionType -OGRExtendedFilenameToOptions:: -GetGDALLayerOptions() const -{ - GDALOptionType options; - for (const auto & option : m_LayerOptions.gdalOptions ) - { - options.push_back( option.first + "=" + option.second ); - } - return options; -} - void OGRExtendedFilenameToOptions:: SetGDALLayerOptions( const OGRExtendedFilenameToOptions::GDALOptionType & options ) @@ -144,9 +123,9 @@ void OGRExtendedFilenameToOptions:: AddGDALLayerOptions( const OGRExtendedFilenameToOptions::GDALOptionType & options ) { - std::vector<std::string> tmp; for ( const auto & option : options ) { + std::vector<std::string> tmp; boost::split(tmp, option , boost::is_any_of(":"), boost::token_compress_on); if ( tmp.size()<2 ) boost::split(tmp, option , boost::is_any_of("="), boost::token_compress_on); @@ -154,6 +133,35 @@ AddGDALLayerOptions( const OGRExtendedFilenameToOptions::GDALOptionType & option } } +bool +OGRExtendedFilenameToOptions:: +SimpleFileNameIsSet() const +{ + return m_HasFileName; +} + +bool +OGRExtendedFilenameToOptions:: +HasGDALLayerOption() const +{ + if ( m_LayerOptions.gdalOptions.empty() ) + return false; + return true; +} + +OGRExtendedFilenameToOptions:: +GDALOptionType +OGRExtendedFilenameToOptions:: +GetGDALLayerOptions() const +{ + GDALOptionType options; + for (const auto & option : m_LayerOptions.gdalOptions ) + { + options.push_back( option.first + "=" + option.second ); + } + return options; +} + #define GetGDALOptionMacro( Type ) \ OGRExtendedFilenameToOptions:: \ GDALOptionType \ -- GitLab From 99d7c46751bd330e65988991ced5c82a5784387a Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 2 Mar 2018 14:51:21 +0100 Subject: [PATCH 377/567] TEST: add test for the OGRExtendedFileName class --- .../Adapters/GdalAdapters/test/CMakeLists.txt | 13 ++- .../otbOGRExtendedFilenameToOptionsTest.cxx | 91 +++++++++++++++++++ 2 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx diff --git a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt index 5a0de85148..9f22efeeef 100644 --- a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt +++ b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt @@ -35,5 +35,16 @@ endif() add_executable(otbOGRTestsIO otbOGRDataSourceWrapperIO.cxx) target_link_libraries(otbOGRTestsIO ${OTBGdalAdapters-Test_LIBRARIES}) -add_test(NAME coTuOGRDataSourceWrapperIO +otb_add_test(NAME coTuOGRDataSourceWrapperIO COMMAND otbOGRTestsIO ${INPUTDATA}/ToulousePoints-examples.shp ) + +add_executable(otbOGRExtendedFilenameTest otbOGRExtendedFilenameToOptionsTest.cxx) +target_link_libraries(otbOGRExtendedFilenameTest ${OTBGdalAdapters-Test_LIBRARIES}) + +otb_add_test(NAME TvOGRExtendedFilename + COMMAND otbOGRExtendedFilenameTest + test.shp?&writegeom=ON&gdal:co:QUALITY=75&gdal:co:TILED=YES&gdal:co:BLOCKYSIZE=1024&gdal:lco:layeroption=OPTION&gdal:oo:openoption=OPTION + ${TEMP}/OGRtest.txt ) +otb_module_target_label(otbOGRExtendedFilenameTest) + +message(STATUS "Test link : ${OTBGdalAdapters-Test_LIBRARIES}") \ No newline at end of file diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx new file mode 100644 index 0000000000..1540fc40f2 --- /dev/null +++ b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbOGRExtendedFilenameToOptions.h" +#include <iostream> +#include <fstream> + +using namespace otb; + + +typedef OGRExtendedFilenameToOptions FilenameHelperType; + +int main(int argc, char* argv[]) +{ + // Verify the number of parameters in the command line + const char * inputExtendedFilename = argv[1]; + const char * outputFilename = argv[2]; + + FilenameHelperType::Pointer helper = FilenameHelperType::New(); + + helper->SetExtendedFileName(inputExtendedFilename); + + std::ofstream file; + file.open(outputFilename); + + file << helper->SimpleFileNameIsSet() << std::endl; + file << helper->GetSimpleFileName() << std::endl; + + file << "Open option :"<<std::endl; + FilenameHelperType::GDALOptionType open = helper->GetGDALOpenOptions(); + for ( auto option : open ) + { + file<< option << std::endl; + } + + file << "Create option :"<<std::endl; + FilenameHelperType::GDALOptionType create = helper->GetGDALOptions("creation"); + for ( auto option : create ) + { + file<< option << std::endl; + } + + file << "Layer option :"<<std::endl; + FilenameHelperType::GDALOptionType layer = helper->GetGDALOptions("layer"); + for ( auto option : layer ) + { + file<< option << std::endl; + } + + file<< "End of classic helper."<<std::endl; + + layer.push_back("TOTO=first"); + FilenameHelperType::Pointer layerHelper = + FilenameHelperType::GetGDALLayerOptionsHelper ( layer ); + FilenameHelperType::GDALOptionType newOptions; + // std::vector< std::string> newOptions; + newOptions.push_back("TOTO=second"); + newOptions.push_back("TiTi=option"); + layerHelper->AddGDALLayerOptions( newOptions ); + + file << layerHelper->SimpleFileNameIsSet() << std::endl; + file << layerHelper->HasGDALLayerOption() << std::endl; + file << "Layer option from layer helper:"<<std::endl; + FilenameHelperType::GDALOptionType latestOptions = layerHelper->GetGDALOptions("layer"); + for ( auto option : latestOptions ) + { + file<< option << std::endl; + } + // test + + file.close(); + return EXIT_SUCCESS; +} + -- GitLab From 75a26dd81fcd024ea5ef617bd6b943afed5186db Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 2 Mar 2018 15:11:00 +0100 Subject: [PATCH 378/567] WRG: unused argument in main test --- .../GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx index 1540fc40f2..47636bf5ec 100644 --- a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx +++ b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx @@ -27,7 +27,7 @@ using namespace otb; typedef OGRExtendedFilenameToOptions FilenameHelperType; -int main(int argc, char* argv[]) +int main(int , char* argv[]) { // Verify the number of parameters in the command line const char * inputExtendedFilename = argv[1]; -- GitLab From c1a163a483312f97fad13e8b226e8f3265768ec5 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Fri, 2 Mar 2018 17:44:44 +0100 Subject: [PATCH 379/567] COMP: update shark version --- SuperBuild/CMake/External_shark.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SuperBuild/CMake/External_shark.cmake b/SuperBuild/CMake/External_shark.cmake index 47f07c0b09..523f1b8943 100644 --- a/SuperBuild/CMake/External_shark.cmake +++ b/SuperBuild/CMake/External_shark.cmake @@ -30,8 +30,8 @@ ADD_SUPERBUILD_CMAKE_VAR(SHARK BOOST_LIBRARYDIR) ExternalProject_Add(SHARK PREFIX SHARK - URL "https://github.com/Shark-ML/Shark/archive/a0d1f816f474b968adbf7592bff199a96a87efc1.zip" - URL_MD5 ed0e8eb73743b39a93775599761a9273 + URL "https://github.com/Shark-ML/Shark/archive/d63962161d9e7229c804373f812015f84a121139.zip" + URL_MD5 abc434362a692c66184679e45ad9f974 SOURCE_DIR ${SHARK_SB_SRC} BINARY_DIR ${SHARK_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} -- GitLab From d799ec027d0eca4c09b17df18f956b76f0affb49 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 5 Mar 2018 08:13:02 +0100 Subject: [PATCH 380/567] TEST: add baseline for test --- Modules/Adapters/GdalAdapters/test/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt index 9f22efeeef..e3c150a7c4 100644 --- a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt +++ b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt @@ -42,9 +42,12 @@ add_executable(otbOGRExtendedFilenameTest otbOGRExtendedFilenameToOptionsTest.cx target_link_libraries(otbOGRExtendedFilenameTest ${OTBGdalAdapters-Test_LIBRARIES}) otb_add_test(NAME TvOGRExtendedFilename - COMMAND otbOGRExtendedFilenameTest + COMMAND otbOGRExtendedFilenameTest + --compare-ascii ${NOTOL} + ${BASELINE}/TvOGRExtendedFilename.txt + ${TEMP}/TvOGRExtendedFilename.txt test.shp?&writegeom=ON&gdal:co:QUALITY=75&gdal:co:TILED=YES&gdal:co:BLOCKYSIZE=1024&gdal:lco:layeroption=OPTION&gdal:oo:openoption=OPTION - ${TEMP}/OGRtest.txt ) + ${TEMP}/TvOGRExtendedFilename.txt ) otb_module_target_label(otbOGRExtendedFilenameTest) message(STATUS "Test link : ${OTBGdalAdapters-Test_LIBRARIES}") \ No newline at end of file -- GitLab From b11f12fa84b8d44fe5fc28514b9f35d940301216 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 5 Mar 2018 09:02:57 +0100 Subject: [PATCH 381/567] COMP: use a shark version which is compatible with the dimensionality reduction branch of OTB --- SuperBuild/CMake/External_shark.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SuperBuild/CMake/External_shark.cmake b/SuperBuild/CMake/External_shark.cmake index 523f1b8943..a4430d8018 100644 --- a/SuperBuild/CMake/External_shark.cmake +++ b/SuperBuild/CMake/External_shark.cmake @@ -30,8 +30,8 @@ ADD_SUPERBUILD_CMAKE_VAR(SHARK BOOST_LIBRARYDIR) ExternalProject_Add(SHARK PREFIX SHARK - URL "https://github.com/Shark-ML/Shark/archive/d63962161d9e7229c804373f812015f84a121139.zip" - URL_MD5 abc434362a692c66184679e45ad9f974 + URL "https://github.com/Shark-ML/Shark/archive/a7346060ba50edaf7d31e2677058258ad7d11692.zip" + URL_MD5 120b7ea9d93e329ddaf310985c295c5e SOURCE_DIR ${SHARK_SB_SRC} BINARY_DIR ${SHARK_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} -- GitLab From 25e3ad96fdf99615dd106051ed5fd935f67aef2e Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 5 Mar 2018 10:53:46 +0100 Subject: [PATCH 382/567] REFAC: cleaning branch --- .../AppTest/app/otbMemoryTestApplication.cxx | 121 ------------------ .../include/otbWrapperApplication.h | 3 +- .../src/otbWrapperApplication.cxx | 32 +++-- 3 files changed, 17 insertions(+), 139 deletions(-) delete mode 100644 Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx diff --git a/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx b/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx deleted file mode 100644 index ef3f715560..0000000000 --- a/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <numeric> - -#include "otbWrapperApplication.h" -#include "otbWrapperApplicationFactory.h" - -#include "otbMultiToMonoChannelExtractROI.h" - -namespace otb -{ -namespace Wrapper -{ - -class MemoryTest : public Application -{ -public: - /** Standard class typedefs. */ - typedef MemoryTest Self; - typedef Application Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Standard macro */ - itkNewMacro(Self); - - itkTypeMacro(MemoryTest, otb::Application) - - typedef MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType, - FloatVectorImageType::InternalPixelType> ExtractROIFilterType; - - - -private: - - void DoInit() ITK_OVERRIDE - { - SetName("MemoryTest"); - SetDescription("This application is made for test"); - // Documentation - SetDocName("Memory Test"); - SetDocLongDescription(""); - SetDocLimitations("None"); - SetDocAuthors("OTB-Team"); - SetDocSeeAlso(""); - - AddParameter(ParameterType_InputImage, "in", "Input image"); - SetParameterDescription("in", "Input image"); - SetParameterString("in", "/home/antoine/dev/my_data/anaglyphInput2.tif"); - - AddParameter(ParameterType_OutputImage, "out", "Output Image"); - SetParameterDescription("out", "Output image"); - SetDefaultOutputPixelType("out",ImagePixelType_uint8); - SetParameterString("out", "/home/antoine/dev/my_data/anaglyphtestInput2.tif"); - - AddRAMParameter(); - - // Doc example parameter settings - SetDocExampleParameterValue("in", "input.tif"); - SetDocExampleParameterValue("out", "output.tif"); - - SetOfficialDocLink(); - } - - void DoUpdateParameters() ITK_OVERRIDE - { - } - - void DoExecute() ITK_OVERRIDE - { - #ifdef MEM_DEBUG - std::cout<<"Debug on input "<<std::endl; - GetParameterImage("in")->DebugOn(); - #endif - ExtractROIFilterType::Pointer extractor = ExtractROIFilterType::New(); - #ifdef MEM_DEBUG - extractor->DebugOn(); - #endif - // m_Filters.push_back(extractor.GetPointer()); - #ifdef MEM_DEBUG - std::cout<<"Debug on extractor "<<std::endl; - extractor->DebugOn(); - #endif - extractor->SetInput(GetParameterImage("in")); - extractor->SetChannel(1); - extractor->UpdateOutputInformation(); - #ifdef MEM_DEBUG - std::cout<<"Debug on extractor's output "<<std::endl; - extractor->GetOutput()->DebugOn(); - #endif - SetParameterOutputImage("out" , extractor->GetOutput() ); - std::cout<<"Registering"<<std::endl; - RegisterPipeline(); - std::cout<<"Registered"<<std::endl; - } - -}; - -} -} - -OTB_APPLICATION_EXPORT(otb::Wrapper::MemoryTest) - diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 29743f26dd..658cff5473 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -846,7 +846,6 @@ public: } void RegisterPipeline(); - std::set<itk::ProcessObject::Pointer> m_Filters; protected: /** Constructor */ @@ -993,6 +992,8 @@ private: itk::ProcessObject::Pointer m_ProgressSource; std::string m_ProgressSourceDescription; + std::set<itk::ProcessObject::Pointer> m_Filters; + /** Long name of the application (that can be displayed...) */ std::string m_DocName; /** Long and precise application description . */ diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index c97090f6e0..b283df7a2a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -363,7 +363,6 @@ void Application::AfterExecuteAndWriteOutputs() void Application::RegisterPipeline() { - std::cout<<"Registering Pipeline"<<std::endl; std::stack< itk::DataObject * > dataStack; std::set< itk::DataObject * > inputData; std::vector<std::string> paramList = GetParametersKeys(true); @@ -447,17 +446,16 @@ Application::RegisterPipeline() else continue; } - std::cout<<"Beginning DFS"<<std::endl; + // DFS - std::set< itk::ProcessObject * > processSet; while ( !dataStack.empty() ) { - std::cout<<"one node (data) is processed"<<std::endl; itk::DataObject * current = dataStack.top(); dataStack.pop(); - if ( inputData.count( current ) || !current ) + // whether current = null or is an input data it has no source + if ( !current || inputData.count( current ) ) continue; - std::cout<<"it is not an input"<<std::endl; + // if current is a list push every of its members in datastack if ( dynamic_cast< ObjectListInterface *> (current) ) { ObjectListInterface * list = @@ -466,18 +464,19 @@ Application::RegisterPipeline() for ( int i = 0 ; i < length ; i++ ) { itk::DataObject * newData = list->GetNthDataObject(i); - if ( inputData.count( current ) || !current ) + if ( !current || inputData.count( current ) ) continue; dataStack.push( newData ); - } continue; + } } + // Finally get the current's process object source itk::ProcessObject * process = (current->GetSource()).GetPointer(); - if ( m_Filters.find( process ) != m_Filters.end() || !process ) + if ( !process || m_Filters.find( process ) != m_Filters.end() ) continue; - std::cout<<"add process to set : "<<process->GetNameOfClass()<<std::endl; m_Filters.insert( process ); std::vector< itk::DataObject::Pointer > inputs = process->GetInputs(); + // Push back all source's inputs in datastack for ( auto it : inputs ) { if ( inputData.count( it.GetPointer() ) ) @@ -539,7 +538,6 @@ int Application::Execute() int Application::ExecuteAndWriteOutput() { - std::cout<<"Executing..."<<std::endl; m_Chrono.Restart(); int status = this->Execute(); @@ -598,7 +596,6 @@ int Application::ExecuteAndWriteOutput() std::cout<<"Add Process and write"<<std::endl; AddProcess(outputParam->GetWriter(), progressId.str()); outputParam->Write(); - // ClearWriter in param(); } } else if (GetParameterType(key) == ParameterType_OutputVectorData @@ -650,11 +647,12 @@ int Application::ExecuteAndWriteOutput() this->AfterExecuteAndWriteOutputs(); m_Chrono.Stop(); - for ( auto filter : m_Filters ) - { - std::cout<<"For filter : "<<filter->GetNameOfClass()<< - " count : "<<filter->GetReferenceCount()<<std::endl; - } + + // for ( auto filter : m_Filters ) + // { + // std::cout<<"For filter : "<<filter->GetNameOfClass()<< + // " count : "<<filter->GetReferenceCount()<<std::endl; + // } m_Filters.clear(); return status; -- GitLab From 6d9f5cffc0780cd3b5ad0733a4cecd759368e153 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 5 Mar 2018 16:50:59 +0100 Subject: [PATCH 383/567] BUG: fix SetSignedSpacing macro --- Modules/Core/ImageBase/include/otbImage.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Core/ImageBase/include/otbImage.h b/Modules/Core/ImageBase/include/otbImage.h index 3bec599c72..6fddf898fd 100644 --- a/Modules/Core/ImageBase/include/otbImage.h +++ b/Modules/Core/ImageBase/include/otbImage.h @@ -49,18 +49,18 @@ namespace internal } template < class InputImage , typename SpacingType > - void SetSignedSpacing( InputImage input , SpacingType spacing ) + void SetSignedSpacing( InputImage *input , SpacingType spacing ) { // TODO check for spacing size ==> error typename InputImage::DirectionType direction = input->GetDirection(); - for ( unsigned int i = 0 ; i < InputImage::VImageDimension ; i++ ) + for ( unsigned int i = 0 ; i < InputImage::ImageDimension ; i++ ) { // TODO check if spacing[i] = 0 ==> error if ( spacing[ i ] < 0 ) { if ( direction[i][i] > 0 ) { - for ( unsigned int j = 0 ; j < InputImage::VImageDimension ; j++ ) + for ( unsigned int j = 0 ; j < InputImage::ImageDimension ; j++ ) { direction[j][i] = - direction[j][i]; } -- GitLab From 832b255b6840cdfbb6f1c61a862a8c443bccea97 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 5 Mar 2018 16:52:45 +0100 Subject: [PATCH 384/567] BUG: HasValue() check doesn't work for output images with no path --- .../Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 843ef1f08c..c6d5c8858f 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1794,10 +1794,6 @@ Application::GetImageMetaData(const std::string & key, unsigned int idx) ImageBaseType* Application::GetParameterImageBase(const std::string & key, unsigned int idx) { - if (! this->HasValue(key)) - { - itkExceptionMacro("Can't get the image, parameter has no value"); - } Parameter* param = GetParameterByKey(key); if (dynamic_cast<InputImageParameter*>(param)) { -- GitLab From a05fec4d71a081efd3c0056a0bfefdc0e429d2cc Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 5 Mar 2018 16:58:35 +0100 Subject: [PATCH 385/567] ENH: function to guess the pixel type in an itkImageBase --- .../src/otbWrapperApplication.cxx | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index c6d5c8858f..8cfcd49a29 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1861,5 +1861,59 @@ Application::SetParameterImageBase(const std::string & key, ImageBaseType* img, } } +ImagePixelType +Application::GetImageBasePixelType(const std::string & key, unsigned int idx) +{ + ImageBaseType* img = this->GetParameterImageBase(key, idx); + if (! img) + { + itkExceptionMacro("No input image"); + } + std::string className(img->GetNameOfClass()); + if (className == "VectorImage") + { +#define FindVectorImagePixelTypeMacro(TImage, TPixel) \ + TImage##VectorImageType* img##TImage = dynamic_cast< TImage##VectorImageType* >(img); \ + if ( img##TImage ) return ImagePixelType_##TPixel ; + + FindVectorImagePixelTypeMacro(UInt8, uint8) + FindVectorImagePixelTypeMacro(Int16, int16) + FindVectorImagePixelTypeMacro(UInt16, uint16) + FindVectorImagePixelTypeMacro(Int32, int32) + FindVectorImagePixelTypeMacro(UInt32, uint32) + FindVectorImagePixelTypeMacro(Float, float) + FindVectorImagePixelTypeMacro(Double, double) + FindVectorImagePixelTypeMacro(ComplexInt16, cint16) + FindVectorImagePixelTypeMacro(ComplexInt32, cint32) + FindVectorImagePixelTypeMacro(ComplexFloat, cfloat) + FindVectorImagePixelTypeMacro(ComplexDouble, cdouble) +#undef FindVectorImagePixelTypeMacro + } + else + { +#define FindImagePixelTypeMacro(TImage, TPixel) \ + TImage##ImageType* img##TImage = dynamic_cast< TImage##ImageType* >(img); \ + if ( img##TImage ) return ImagePixelType_##TPixel ; + + FindImagePixelTypeMacro(UInt8, uint8) + FindImagePixelTypeMacro(Int16, int16) + FindImagePixelTypeMacro(UInt16, uint16) + FindImagePixelTypeMacro(Int32, int32) + FindImagePixelTypeMacro(UInt32, uint32) + FindImagePixelTypeMacro(Float, float) + FindImagePixelTypeMacro(Double, double) + FindImagePixelTypeMacro(ComplexInt16, cint16) + FindImagePixelTypeMacro(ComplexInt32, cint32) + FindImagePixelTypeMacro(ComplexFloat, cfloat) + FindImagePixelTypeMacro(ComplexDouble, cdouble) + FindImagePixelTypeMacro(UInt8RGB, uint8) + FindImagePixelTypeMacro(UInt8RGBA, uint8) +#undef FindImagePixelTypeMacro + } + itkWarningMacro("Unknown pixel type"); + // by default uint8 + return ImagePixelType_uint8; +} + } } -- GitLab From 9b60513407fd85927a338501819d4a7992ffd7a8 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 5 Mar 2018 16:59:06 +0100 Subject: [PATCH 386/567] ENH: some functions need to be public to be used by SWIG --- .../include/otbWrapperApplication.h | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 37a10b493c..0fba9be828 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -883,6 +883,34 @@ public: /** Returns a copy of the metadata dictionary of the image */ itk::MetaDataDictionary GetImageMetaData(const std::string & key, unsigned int idx = 0); + /** Find out what is the pixel type from an image parameter + * This function assumes that the underlying object is either an otb::Image + * or an otb::VectorImage. The optional 'idx' allows to access InputImageList. + */ + ImagePixelType GetImageBasePixelType(const std::string & key, unsigned int idx = 0); + + /** Return the image from parameter 'key' as a base type. The optional 'idx' + * allows to access InputImageList. + * + * Works on parameters: + * \li ParameterType_InputImage + * \li ParameterType_InputImageList + * \li ParameterType_OutputImage + * \li ParameterType_ComplexInputImage + * \li ParameterType_ComplexOutputImage + */ + ImageBaseType* GetParameterImageBase(const std::string & key, unsigned int idx = 0); + + /** Set the image in parameter 'key' as a base type. The optional 'idx' + * allows to access InputImageList. + * + * Works on parameters: + * \li ParameterType_InputImage + * \li ParameterType_InputImageList + * \li ParameterType_ComplexInputImage + */ + void SetParameterImageBase(const std::string & key, ImageBaseType* img, unsigned int idx = 0); + protected: /** Constructor */ Application(); @@ -1002,28 +1030,6 @@ protected: } } - /** Return the image from parameter 'key' as a base type. The optional 'idx' - * allows to access InputImageList. - * - * Works on parameters: - * \li ParameterType_InputImage - * \li ParameterType_InputImageList - * \li ParameterType_OutputImage - * \li ParameterType_ComplexInputImage - * \li ParameterType_ComplexOutputImage - */ - ImageBaseType* GetParameterImageBase(const std::string & key, unsigned int idx = 0); - - /** Set the image in parameter 'key' as a base type. The optional 'idx' - * allows to access InputImageList. - * - * Works on parameters: - * \li ParameterType_InputImage - * \li ParameterType_InputImageList - * \li ParameterType_ComplexInputImage - */ - void SetParameterImageBase(const std::string & key, ImageBaseType* img, unsigned int idx = 0); - private: /* Implement this method to add parameters */ virtual void DoInit() = 0; -- GitLab From 52b759a621e0447cdfd91f889f74bbdebc7664ea Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 5 Mar 2018 17:02:45 +0100 Subject: [PATCH 387/567] ENH: include std_complex for wrapping --- Modules/Wrappers/SWIG/src/itkBase.i | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Wrappers/SWIG/src/itkBase.i b/Modules/Wrappers/SWIG/src/itkBase.i index b9e5e3a06d..02d713407c 100644 --- a/Modules/Wrappers/SWIG/src/itkBase.i +++ b/Modules/Wrappers/SWIG/src/itkBase.i @@ -54,6 +54,7 @@ %include <std_string.i> %include <std_vector.i> %include <std_map.i> +%include <std_complex.i> %template(vectorstring) std::vector< std::string >; %template(mapstringstring) std::map< std::string, std::string >; -- GitLab From 739241eea51c7195466126a6ff7c57447b67fddf Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 5 Mar 2018 17:08:19 +0100 Subject: [PATCH 388/567] ENH: rework Numpy wrappings and Import/Export functions --- Modules/Wrappers/SWIG/src/otbApplication.i | 534 +++++++++++---------- 1 file changed, 284 insertions(+), 250 deletions(-) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index 5f24af0f53..23bf44903e 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -67,6 +67,8 @@ import_array(); %apply (unsigned int** ARGOUTVIEW_ARRAY3, int *DIM1, int *DIM2, int *DIM3) {(unsigned int** buffer, int *dim1, int *dim2, int *dim3)}; %apply (unsigned long** ARGOUTVIEW_ARRAY3, int *DIM1, int *DIM2, int *DIM3) {(unsigned long** buffer, int *dim1, int *dim2, int *dim3)}; %apply (double** ARGOUTVIEW_ARRAY3, int *DIM1, int *DIM2, int *DIM3) {(double** buffer, int *dim1, int *dim2, int *dim3)}; +%apply (std::complex<float>** ARGOUTVIEW_ARRAY3, int *DIM1, int *DIM2, int *DIM3) {(std::complex<float>** buffer, int *dim1, int *dim2, int *dim3)}; +%apply (std::complex<double>** ARGOUTVIEW_ARRAY3, int *DIM1, int *DIM2, int *DIM3) {(std::complex<double>** buffer, int *dim1, int *dim2, int *dim3)}; #endif /* OTB_SWIGNUMPY */ @@ -124,6 +126,10 @@ namespace Wrapper ImagePixelType_uint32, ImagePixelType_float, ImagePixelType_double, + ImagePixelType_cint16, + ImagePixelType_cint32, + ImagePixelType_cfloat, + ImagePixelType_cdouble, } ImagePixelType; typedef enum @@ -280,6 +286,7 @@ public: unsigned long PropagateRequestedRegion(const std::string & key, itk::ImageRegion<2> region, unsigned int idx = 0); itk::ImageRegion<2> GetImageRequestedRegion(const std::string & key, unsigned int idx = 0); itkMetaDataDictionary GetImageMetaData(const std::string & key, unsigned int idx = 0); + otb::Wrapper::ImagePixelType GetImageBasePixelType(const std::string & key, unsigned int idx = 0); itkProcessObject* GetProgressSource() const; @@ -319,153 +326,161 @@ public: %extend { #define SetFromNumpyArrayMacro(prefix, PixelDataType, ImageClass) \ - void Set##ImageClass##From##prefix##NumpyArray_(std::string pkey, ##PixelDataType##* buffer, int dim1, int dim2, int dim3) \ - { \ - otb::Wrapper::Parameter *parameter = $self->GetParameterList()->GetParameterByKey(pkey); \ - InputImageParameter* inputImageParam = dynamic_cast<InputImageParameter*>(parameter); \ - typedef otb::##ImageClass##<##PixelDataType##> ImageType; \ - ImageType::Pointer output = ImageType::New(); \ - typedef ImageType::SizeType SizeType; \ - typedef ImageType::IndexType IndexType; \ - typedef ImageType::RegionType RegionType; \ - typedef ImageType::PointType PointType; \ - typedef ImageType::SpacingType SpacingType; \ - typedef ImageType::DirectionType DirectionType; \ - IndexType start; \ - DirectionType direction; \ - start.Fill( 0 ); \ - SizeType size; \ - size[0] = dim2; size[1] = dim1; \ - SetVectorLengthMacro \ - output->Allocate(); \ - unsigned int numberOfPixels = dim1 * dim2 * dim3; \ - RegionType region; \ - region.SetIndex( start ); \ - region.SetSize( size ); \ - PointType origin; \ - origin.Fill( 0.0 ); \ - SpacingType spacing; \ - spacing.Fill( 1.0 ); \ - direction.SetIdentity(); \ - output->SetOrigin( origin ); \ - output->SetSignedSpacing( spacing ); \ - output->SetDirection(direction); \ - output->SetLargestPossibleRegion(region); \ - output->SetRequestedRegion(output->GetLargestPossibleRegion()); \ - output->SetBufferedRegion(output->GetLargestPossibleRegion()); \ - output->GetPixelContainer()->SetImportPointer(buffer, numberOfPixels, false); \ - inputImageParam->SetImage<ImageType>(output); \ + ImageBaseType* Set##ImageClass##From##prefix##NumpyArray_(std::string pkey, int idx, ##PixelDataType##* buffer, int dim1, int dim2, int dim3) \ + { \ + typedef otb::##ImageClass##<##PixelDataType##> ImageType; \ + ImageType::Pointer output = ImageType::New(); \ + unsigned int numberOfPixels = dim1 * dim2 * dim3; \ + ImageType::RegionType region; \ + region.SetIndex(0, 0); \ + region.SetIndex(1, 0); \ + region.SetSize( 0, dim2); \ + region.SetSize( 1, dim1); \ + output->SetNumberOfComponentsPerPixel(dim3); \ + output->SetRegions(region); \ + output->GetPixelContainer()->SetImportPointer(buffer, numberOfPixels, false); \ + $self->SetParameterImageBase(pkey,output.GetPointer(),idx); \ + return output.GetPointer(); \ } -#define SetVectorLengthMacro output->SetVectorLength(dim3); - SetFromNumpyArrayMacro(Float, float, VectorImage) - SetFromNumpyArrayMacro(Int8, signed char, VectorImage) - SetFromNumpyArrayMacro(Int16, signed short, VectorImage) - SetFromNumpyArrayMacro(Int32, signed int, VectorImage) - SetFromNumpyArrayMacro(Int64, signed long, VectorImage) - SetFromNumpyArrayMacro(UInt8, unsigned char, VectorImage) - SetFromNumpyArrayMacro(UInt16, unsigned short, VectorImage) - SetFromNumpyArrayMacro(UInt32, unsigned int, VectorImage) - SetFromNumpyArrayMacro(UInt64, unsigned long, VectorImage) - SetFromNumpyArrayMacro(Double, double, VectorImage) -#undef SetVectorLengthMacro - -#define SetVectorLengthMacro dim3=1; - SetFromNumpyArrayMacro(Float, float, Image) - SetFromNumpyArrayMacro(Int8, signed char, Image) - SetFromNumpyArrayMacro(Int16, signed short, Image) - SetFromNumpyArrayMacro(Int32, signed int, Image) - SetFromNumpyArrayMacro(Int64, signed long, Image) - SetFromNumpyArrayMacro(UInt8, unsigned char, Image) - SetFromNumpyArrayMacro(UInt16, unsigned short, Image) - SetFromNumpyArrayMacro(UInt32, unsigned int, Image) - SetFromNumpyArrayMacro(UInt64, unsigned long, Image) - SetFromNumpyArrayMacro(Double, double, Image) -#undef SetVectorLengthMacro + SetFromNumpyArrayMacro(UInt8, unsigned char, VectorImage) + SetFromNumpyArrayMacro(Int16, signed short, VectorImage) + SetFromNumpyArrayMacro(UInt16, unsigned short, VectorImage) + SetFromNumpyArrayMacro(Int32, signed int, VectorImage) + SetFromNumpyArrayMacro(UInt32, unsigned int, VectorImage) + // SetFromNumpyArrayMacro(Int64, signed long, VectorImage) + // SetFromNumpyArrayMacro(UInt64, unsigned long, VectorImage) + SetFromNumpyArrayMacro(Float, float, VectorImage) + SetFromNumpyArrayMacro(Double, double, VectorImage) + SetFromNumpyArrayMacro(CFloat, std::complex<float>, VectorImage) + SetFromNumpyArrayMacro(CDouble, std::complex<double>, VectorImage) + + SetFromNumpyArrayMacro(UInt8, unsigned char, Image) + SetFromNumpyArrayMacro(Int16, signed short, Image) + SetFromNumpyArrayMacro(UInt16, unsigned short, Image) + SetFromNumpyArrayMacro(Int32, signed int, Image) + SetFromNumpyArrayMacro(UInt32, unsigned int, Image) + // SetFromNumpyArrayMacro(Int64, signed long, Image) + // SetFromNumpyArrayMacro(UInt64, unsigned long, Image) + SetFromNumpyArrayMacro(Float, float, Image) + SetFromNumpyArrayMacro(Double, double, Image) + SetFromNumpyArrayMacro(CFloat, std::complex<float>, Image) + SetFromNumpyArrayMacro(CDouble, std::complex<double>, Image) #undef SetFromNumpyArrayMacro -#define GetVectorImageAsNumpyArrayMacro(prefix, PixelType) \ - void GetVectorImageAs##prefix##NumpyArray_(std::string pkey, ##PixelType##** buffer, int *dim1, int *dim2, int *dim3) \ - { \ - otb::Wrapper::Parameter *parameter = $self->GetParameterList()->GetParameterByKey(pkey); \ - OutputImageParameter* outputImageParam = dynamic_cast<OutputImageParameter*>(parameter); \ - typedef ImageBaseType::RegionType RegionType; \ - ImageBaseType::Pointer imageBase; \ - imageBase = outputImageParam->GetValue(); \ - imageBase->Update(); \ - typedef ImageBaseType::SizeType SizeType; \ - typedef ImageBaseType::IndexType IndexType; \ - typedef ImageBaseType::PointType PointType; \ - typedef ImageBaseType::SpacingType SpacingType; \ - RegionType region = imageBase->GetBufferedRegion(); \ - SizeType size = region.GetSize(); \ - *dim1 = size[1]; \ - *dim2 = size[0]; \ - typedef otb::VectorImage<signed char> Int8ImageType; \ - typedef otb::VectorImage<signed short> Int16ImageType; \ - typedef otb::VectorImage<signed int> Int32ImageType; \ - typedef otb::VectorImage<unsigned char> UInt8ImageType; \ - typedef otb::VectorImage<unsigned short> UInt16ImageType; \ - typedef otb::VectorImage<unsigned int> UInt32ImageType; \ - typedef otb::VectorImage<float> FloatImageType; \ - typedef otb::VectorImage<double> DoubleImageType; \ - if (dynamic_cast<UInt8ImageType*>(imageBase.GetPointer())) \ - { \ - UInt8ImageType* output = dynamic_cast<UInt8ImageType*>(imageBase.GetPointer()); \ - *buffer = reinterpret_cast<##PixelType##*>(output->GetBufferPointer()); \ - *dim3 = output->GetNumberOfComponentsPerPixel(); \ - } \ - else if (dynamic_cast<Int16ImageType*>(imageBase.GetPointer())) \ - { \ - Int16ImageType* output = dynamic_cast<Int16ImageType*>(imageBase.GetPointer()); \ - *buffer = reinterpret_cast<##PixelType##*>(output->GetBufferPointer()); \ - *dim3 = output->GetNumberOfComponentsPerPixel(); \ - } \ - else if (dynamic_cast<UInt16ImageType*>(imageBase.GetPointer())) \ - { \ - UInt16ImageType* output = dynamic_cast<UInt16ImageType*>(imageBase.GetPointer()); \ - *buffer = reinterpret_cast<##PixelType##*>(output->GetBufferPointer()); \ - *dim3 = output->GetNumberOfComponentsPerPixel(); \ - } \ - else if (dynamic_cast<Int32ImageType*>(imageBase.GetPointer())) \ - { \ - Int32ImageType* output = dynamic_cast<Int32ImageType*>(imageBase.GetPointer()); \ - *buffer = reinterpret_cast<##PixelType##*>(output->GetBufferPointer()); \ - *dim3 = output->GetNumberOfComponentsPerPixel(); \ - } \ - else if (dynamic_cast<UInt32ImageType*>(imageBase.GetPointer())) \ - { \ - UInt32ImageType* output = dynamic_cast<UInt32ImageType*>(imageBase.GetPointer()); \ - *buffer = reinterpret_cast<##PixelType##*>(output->GetBufferPointer()); \ - *dim3 = output->GetNumberOfComponentsPerPixel(); \ - } \ - else if (dynamic_cast<FloatImageType*>(imageBase.GetPointer())) \ - { \ - FloatImageType* output = dynamic_cast<FloatImageType*>(imageBase.GetPointer()); \ - *buffer = reinterpret_cast<##PixelType##*>(output->GetBufferPointer()); \ - *dim3 = output->GetNumberOfComponentsPerPixel(); \ - } \ - else if (dynamic_cast<DoubleImageType*>(imageBase.GetPointer())) \ - { \ - DoubleImageType* output = dynamic_cast<DoubleImageType*>(imageBase.GetPointer()); \ - *buffer = reinterpret_cast<##PixelType##*>(output->GetBufferPointer()); \ - *dim3 = output->GetNumberOfComponentsPerPixel(); \ - } \ - else \ - { \ - std::cerr << "unknown image type. cannot make a numpy array" << std::endl; \ - } \ - } +#define GetVectorImageAsNumpyArrayMacro(suffix, TPixel) \ + void GetVectorImageAs##suffix##NumpyArray_ \ + (std::string pkey, ##TPixel##** buffer, int *dim1, int *dim2, int *dim3) \ + { \ + ImageBaseType *img = $self->GetParameterOutputImage(pkey); \ + img->Update(); \ + unsigned int nbComp = img->GetNumberOfComponentsPerPixel(); \ + ImageBaseType::RegionType region = img->GetBufferedRegion(); \ + ImageBaseType::SizeType size = region.GetSize(); \ + *dim1 = region.GetSize(1); \ + *dim2 = region.GetSize(0); \ + *dim3 = nbComp; \ + std::string className(img->GetNameOfClass()); \ + if (className == "VectorImage") \ + { \ + typedef otb::VectorImage<##TPixel##,2> LocalVectorImageType; \ + LocalVectorImageType* imgDown = dynamic_cast<LocalVectorImageType*>(img); \ + if (imgDown) \ + *buffer = reinterpret_cast<##TPixel##*>(imgDown->GetBufferPointer()); \ + else \ + std::cerr << "VectorImage type doesn't match" << std::endl; \ + } \ + else \ + { \ + if (nbComp == 1) \ + { \ + otb::Image<##TPixel##,2>* imgDown = dynamic_cast< otb::Image<##TPixel##,2>* >(img); \ + if (imgDown) \ + *buffer = reinterpret_cast<##TPixel##*>(imgDown->GetBufferPointer()); \ + else \ + std::cerr << "Image type doesn't match" << std::endl; \ + } \ + else \ + { \ + std::cerr << "Unhandled number of components in otb::Image (RGB<T> " \ + "and RGBA<T> not supported yet)" << std::endl; \ + } \ + } \ + } - GetVectorImageAsNumpyArrayMacro(Float, float) - GetVectorImageAsNumpyArrayMacro(Int16, signed short) - GetVectorImageAsNumpyArrayMacro(Int32, signed int) - GetVectorImageAsNumpyArrayMacro(UInt8, unsigned char) - GetVectorImageAsNumpyArrayMacro(UInt16, unsigned short) - GetVectorImageAsNumpyArrayMacro(UInt32, unsigned int) - GetVectorImageAsNumpyArrayMacro(Double, double) + GetVectorImageAsNumpyArrayMacro(UInt8, unsigned char) + GetVectorImageAsNumpyArrayMacro(Int16,signed short); + GetVectorImageAsNumpyArrayMacro(UInt16,unsigned short); + GetVectorImageAsNumpyArrayMacro(Int32,signed int); + GetVectorImageAsNumpyArrayMacro(UInt32,unsigned int); + GetVectorImageAsNumpyArrayMacro(Float,float); + GetVectorImageAsNumpyArrayMacro(Double,double); + GetVectorImageAsNumpyArrayMacro(CFloat,std::complex<float> ); + GetVectorImageAsNumpyArrayMacro(CDouble,std::complex<double> ); + // CInt16 and CInt32 are not supported in Numpy #undef GetVectorImageAsNumpyArrayMacro + std::string ConvertPixelTypeToNumpy(otb::Wrapper::ImagePixelType pixType) + { + std::ostringstream oss; + switch (pixType) + { + case otb::Wrapper::ImagePixelType_uint8 : + oss << "uint" << (sizeof(unsigned char) * 8); + break; + case otb::Wrapper::ImagePixelType_int16 : + oss << "int" << (sizeof(signed short) * 8); + break; + case otb::Wrapper::ImagePixelType_uint16 : + oss << "uint" << (sizeof(unsigned short) * 8); + break; + case otb::Wrapper::ImagePixelType_int32 : + oss << "int" << (sizeof(signed int) * 8); + break; + case otb::Wrapper::ImagePixelType_uint32 : + oss << "uint" << (sizeof(unsigned int) * 8); + break; + case otb::Wrapper::ImagePixelType_float : + oss << "float" << (sizeof(float) * 8); + break; + case otb::Wrapper::ImagePixelType_double : + oss << "float" << (sizeof(double) * 8); + break; + case otb::Wrapper::ImagePixelType_cfloat : + oss << "complex" << (sizeof(std::complex<float>) * 8); + break; + case otb::Wrapper::ImagePixelType_cdouble : + oss << "complex" << (sizeof(std::complex<double>) * 8); + break; + default: + std::cerr << "Pixel type not handled" << std::endl; + break; + } + return oss.str(); + } + + void SetupImageInformation( + ImageBaseType* img, + itk::Point<SpacePrecisionType,2> origin, + itk::Vector<SpacePrecisionType,2> spacing, + itk::Size<2> size, + itk::ImageRegion<2> bufferRegion, + itkMetaDataDictionary metadata) + { + img->SetOrigin(origin); + otb::internal::SetSignedSpacing(img, spacing); + itk::ImageRegion<2> largest; + largest.SetSize(size); + img->SetLargestPossibleRegion(largest); + if (bufferRegion.GetSize() != img->GetBufferedRegion().GetSize()) + { + std::cerr << "Given buffered size doesn't match actual buffer size" << std::endl; + return; + } + img->SetRequestedRegion(bufferRegion); + img->SetBufferedRegion(bufferRegion); + img->SetMetaDataDictionary(metadata); + } } /* end of %extend */ #endif /* OTB_SWIGNUMPY */ @@ -690,140 +705,159 @@ class ApplicationProxy(object): { %pythoncode { - def SetImageFromNumpyArray(self, paramKey, npArray): + NumpyExporterMap = { + ImagePixelType_uint8 : GetVectorImageAsUInt8NumpyArray_, + ImagePixelType_int16 : GetVectorImageAsInt16NumpyArray_, + ImagePixelType_uint16 : GetVectorImageAsUInt16NumpyArray_, + ImagePixelType_int32 : GetVectorImageAsInt32NumpyArray_, + ImagePixelType_uint32 : GetVectorImageAsUInt32NumpyArray_, + ImagePixelType_float : GetVectorImageAsFloatNumpyArray_, + ImagePixelType_double : GetVectorImageAsDoubleNumpyArray_, + ImagePixelType_cfloat : GetVectorImageAsCFloatNumpyArray_, + ImagePixelType_cdouble : GetVectorImageAsCDoubleNumpyArray_, + } + ImageImporterMap = { + ImagePixelType_uint8 : SetImageFromUInt8NumpyArray_, + ImagePixelType_int16 : SetImageFromInt16NumpyArray_, + ImagePixelType_uint16 : SetImageFromUInt16NumpyArray_, + ImagePixelType_int32 : SetImageFromInt32NumpyArray_, + ImagePixelType_uint32 : SetImageFromUInt32NumpyArray_, + ImagePixelType_float : SetImageFromFloatNumpyArray_, + ImagePixelType_double : SetImageFromDoubleNumpyArray_, + ImagePixelType_cfloat : SetImageFromCFloatNumpyArray_, + ImagePixelType_cdouble : SetImageFromCDoubleNumpyArray_, + } + VectorImageImporterMap = { + ImagePixelType_uint8 : SetVectorImageFromUInt8NumpyArray_, + ImagePixelType_int16 : SetVectorImageFromInt16NumpyArray_, + ImagePixelType_uint16 : SetVectorImageFromUInt16NumpyArray_, + ImagePixelType_int32 : SetVectorImageFromInt32NumpyArray_, + ImagePixelType_uint32 : SetVectorImageFromUInt32NumpyArray_, + ImagePixelType_float : SetVectorImageFromFloatNumpyArray_, + ImagePixelType_double : SetVectorImageFromDoubleNumpyArray_, + ImagePixelType_cfloat : SetVectorImageFromCFloatNumpyArray_, + ImagePixelType_cdouble : SetVectorImageFromCDoubleNumpyArray_, + } + + def SetImageFromNumpyArray(self, paramKey, npArray, index=0): """ This method takes a numpy array and set ImageIOBase of InputImageParameter by creating an otbImage with same pixel type as numpyarray.dtype """ - if len(npArray.shape) == 3: - raise ValueError( "(len(npArray.shape) == 3)\n" - "Input array given is of 3 dimension.\n" - "SetImageFromNumpyArray create ImageIO from otbImage and thus demands a 2d array.\n" - "you can either provide an 2d numpy array or use SetVectorImageFromNumpyArray depending on your application.\n") - - dt = npArray.dtype.name - if dt == 'int8': - self.SetImageFromInt8NumpyArray_(paramKey, npArray) - elif dt == 'int16': - self.SetImageFromInt16NumpyArray_(paramKey, npArray) - elif dt == 'int32': - self.SetImageFromInt32NumpyArray_(paramKey, npArray) - elif dt == 'uint8': - self.SetImageFromUInt8NumpyArray_(paramKey, npArray) - elif dt == 'uint16': - self.SetImageFromUInt16NumpyArray_(paramKey, npArray) - elif dt == 'uint32': - self.SetImageFromUInt32NumpyArray_(paramKey, npArray) - elif dt == 'float': - self.SetImageFromFloatNumpyArray_(paramKey, npArray) - elif dt == 'double': - self.SetImageFromDoubleNumpyArray_(paramKey, npArray) + shp = npArray.shape + if len(shp) == 2: + npArray = npArray.reshape((shp[0],shp[1],1)) + elif len(shp) == 3: + if shp[2] > 1: + raise ValueError( "More than 1 band in numpy array\n" + "Cannot convert to Image, use SetVectorImageFromNumpyArray instead\n") else: - self.SetImageFromFloatNumpyArray_(paramKey, npArray) - return - - def SetVectorImageFromNumpyArray(self, paramKey, npArray): + raise ValueError( "Expected 2 or 3 dimensions for numpyarray\n") + dt = npArray.dtype.name + isFound = False + for pixT in self.ImageImporterMap: + if dt == self.ConvertPixelTypeToNumpy(pixT): + isFound = True + img = self.ImageImporterMap[pixT](self,paramKey, index, npArray) + break + if len(shp) == 2: + npArray = npArray.reshape(shp) + if not isFound: + raise ValueError("Can't convert Numpy array of dtype "+dt) + return img + + def SetVectorImageFromNumpyArray(self, paramKey, npArray, index=0): """ - This method takes a numpy array and set ImageIOBase of + This method takes a numpy array and set InputImageParameter by creating an otbVectorImage with same pixel type as numpyarray.dtype. - NOTE: Input (npArray) must be an ndarray with 3 dimension, - len(npArray.shape) must be > 2 + NOTE: Input (npArray) must be an ndarray with 2 or 3 dimensions, """ - if len(npArray.shape) < 3: - raise ValueError( "(len(npArray.shape) < 3)\n" - "Input array given is not of 3 dimension.\n" - "SetVectorImageFromNumpyArray create ImageIO from otbVectorImage and thus demands an array of shape 3.\n" - "you can either provide an 3d numpy array or use SetImageFromNumpyArray depending on your application.\n") - + shp = npArray.shape + if len(shp) == 2: + npArray = npArray.reshape((shp[0],shp[1],1)) + elif len(npArray.shape) != 3: + raise ValueError( "Expected 2 or 3 dimensions for numpyarray") dt = npArray.dtype.name - if dt == 'int8': - self.SetVectorImageFromInt8NumpyArray_(paramKey, npArray) - elif dt == 'int16': - self.SetVectorImageFromInt16NumpyArray_(paramKey, npArray) - elif dt == 'int32': - self.SetVectorImageFromInt32NumpyArray_(paramKey, npArray) - elif dt == 'uint8': - self.SetVectorImageFromUInt8NumpyArray_(paramKey, npArray) - elif dt == 'uint16': - self.SetVectorImageFromUInt16NumpyArray_(paramKey, npArray) - elif dt == 'uint32': - self.SetVectorImageFromUInt32NumpyArray_(paramKey, npArray) - elif dt == 'float': - self.SetVectorImageFromFloatNumpyArray_(paramKey, npArray) - elif dt == 'double': - self.SetVectorImageFromDoubleNumpyArray_(paramKey, npArray) - else: - self.SetVectorImageFromFloatNumpyArray_(paramKey, npArray) - return + isFound = False + for pixT in self.VectorImageImporterMap: + if dt == self.ConvertPixelTypeToNumpy(pixT): + isFound = True + img = self.VectorImageImporterMap[pixT](self,paramKey, index, npArray) + break + if len(shp) == 2: + npArray = npArray.reshape(shp) + if not isFound: + raise ValueError("Can't convert Numpy array of dtype "+dt) + return img def GetVectorImageAsNumpyArray(self, paramKey, dt='float'): """ - If datatype is unknown this method assumes to numpy.float32 - Valid datatypes are: - int8, int16, int32, uint8, uint16, uint32, float, double. - NOTE: This method always return an numpy array with dimension 3 + This function retrieves an output image parameter as a Numpy array. + The array datatype is guessed automatically from the underlying + otb::VectorImage<T,2> type (should also work with otb::Image<T,2>). The + optional parameter dt is deprecated and should not be used anymore. The + possible output datatypes are: + int8, int16, int32, uint8, uint16, uint32, float, double, cint16, cint32, + cfloat, cdouble. + NOTE: This method always return an numpy array with 3 dimensions + NOTE: cint16 and cint32 are not supported yet """ - if dt == 'int8': - return self.GetVectorImageAsInt8NumpyArray_(paramKey) - elif dt == 'int16': - return self.GetVectorImageAsInt16NumpyArray_(paramKey) - elif dt == 'int32': - return self.GetVectorImageAsInt32NumpyArray_(paramKey) - elif dt == 'uint8': - return self.GetVectorImageAsUInt8NumpyArray_(paramKey) - elif dt == 'uint16': - return self.GetVectorImageAsUInt16NumpyArray_(paramKey) - elif dt == 'uint32': - return self.GetVectorImageAsUInt32NumpyArray_(paramKey) - elif dt == 'float': - return self.GetVectorImageAsFloatNumpyArray_(paramKey) - elif dt == 'double': - return self.GetVectorImageAsDoubleNumpyArray_(paramKey) - else: - print ("Unknown datatype '" + dt + "'. Using float instead. Available types are:") - print ("int8, int16, int32, uint8, uint16, uint32, float, double") - return self.GetVectorImageAsFloatNumpyArray_(paramKey) + pixT = self.GetImageBasePixelType(paramKey) + return self.NumpyExporterMap[pixT](self,paramKey) def GetImageAsNumpyArray(self, paramKey, dt='float'): """ - If datatype is unknown this method assumes to numpy.float32 - Valid datatypes are: - int8, int16, int32, uint8, uint16, uint32, float, double. - NOTE: This method always return an numpy array with dimension 3 + This function retrieves an output image parameter as a Numpy array. + The array datatype is guessed automatically from the underlying + otb::VectorImage<T,2> type (should also work with otb::Image<T,2>). The + optional parameter dt is deprecated and should not be used anymore. The + possible output datatypes are: + int8, int16, int32, uint8, uint16, uint32, float, double, cint16, cint32, + cfloat, cdouble. + NOTE: This method always return an numpy array with 2 dimensions + NOTE: cint16 and cint32 are not supported yet """ - if dt == 'int8': - numpy_vector_image = self.GetVectorImageAsInt8NumpyArray_(paramKey) - elif dt == 'int16': - numpy_vector_image = self.GetVectorImageAsInt16NumpyArray_(paramKey) - elif dt == 'int32': - numpy_vector_image = self.GetVectorImageAsInt32NumpyArray_(paramKey) - elif dt == 'uint8': - numpy_vector_image = self.GetVectorImageAsUInt8NumpyArray_(paramKey) - elif dt == 'uint16': - numpy_vector_image = self.GetVectorImageAsUInt16NumpyArray_(paramKey) - elif dt == 'uint32': - numpy_vector_image = self.GetVectorImageAsUInt32NumpyArray_(paramKey) - elif dt == 'float': - numpy_vector_image = self.GetVectorImageAsFloatNumpyArray_(paramKey) - elif dt == 'double': - numpy_vector_image = self.GetVectorImageAsDoubleNumpyArray_(paramKey) - - else: - print ("Unknown datatype '" + dt + "'. Using float instead. Available types are:") - print ("int8, int16, int32, uint8, uint16, uint32, float, double") - numpy_vector_image = self.GetVectorImageAsFloatNumpyArray_(paramKey) - - if numpy_vector_image.shape[2] > 1: - raise ValueError("numpy_vector_image.shape[2] > 1\n" + pixT = self.GetImageBasePixelType(paramKey) + array = self.NumpyExporterMap[pixT](self,paramKey) + if array.shape[2] > 1: + raise ValueError("array.shape[2] > 1\n" "Output image from application has more than 1 band\n" "GetImageFromNumpyArray only returns the first band, which will result in a loss of data.\n" "In this case you must use GetVectorImageFromNumpyArray which is capable of return a 3 dimension image.\n") + array = array[:,:,0] + return array - numpy_vector_image = numpy_vector_image[:,:,0] - return numpy_vector_image + def ImportImage(self, paramKey, pyImg, index = 0): + """ + Import an image into a parameter, from a Python dict. with the following + keys: array, origin, spacing, size, region, metadata + """ + img = self.SetImageFromNumpyArray(paramKey, pyImg["array"], index) + self.SetupImageInformation(img, pyImg["origin"], pyImg["spacing"], pyImg["size"], pyImg["region"], pyImg["metadata"]) + def ImportVectorImage(self, paramKey, pyImg, index = 0): + """ + Import a vector image into a parameter, from a Python dict. with the following + keys: array, origin, spacing, size, region, metadata + """ + img = self.SetVectorImageFromNumpyArray(paramKey, pyImg["array"], index) + self.SetupImageInformation(img, pyImg["origin"], pyImg["spacing"], pyImg["size"], pyImg["region"], pyImg["metadata"]) + + def ExportImage(self, paramKey): + """ + Export an output image from an otbApplication into a python dictionary with the + following fields: array, origin, spacing, size, region, metadata + """ + output = {} + output["array"] = self.GetVectorImageAsNumpyArray(paramKey) + output["origin"] = self.GetImageOrigin(paramKey) + output["spacing"] = self.GetImageSpacing(paramKey) + output["size"] = self.GetImageSize(paramKey) + output["region"] = self.GetImageRequestedRegion(paramKey) + output["metadata"] = self.GetImageMetaData(paramKey) + return output } } -- GitLab From f96785aff76bd81966932c79465263eb04c365ca Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 5 Mar 2018 17:44:36 +0100 Subject: [PATCH 389/567] ENH: add function to translate labels to range [0 ... nbClasses-1] for Shark --- Modules/Learning/LearningBase/test/CMakeLists.txt | 3 +++ .../Learning/LearningBase/test/otbLearningBaseTestDriver.cxx | 1 + 2 files changed, 4 insertions(+) diff --git a/Modules/Learning/LearningBase/test/CMakeLists.txt b/Modules/Learning/LearningBase/test/CMakeLists.txt index d1d16c3e65..d1917c1be1 100644 --- a/Modules/Learning/LearningBase/test/CMakeLists.txt +++ b/Modules/Learning/LearningBase/test/CMakeLists.txt @@ -30,6 +30,7 @@ otbSEMClassifierNew.cxx otbDecisionTreeNew.cxx otbKMeansImageClassificationFilterNew.cxx otbMachineLearningModelTemplates.cxx +otbSharkUtilsTests.cxx ) add_executable(otbLearningBaseTestDriver ${OTBLearningBaseTests}) @@ -68,3 +69,5 @@ otb_add_test(NAME leTuDecisionTreeNew COMMAND otbLearningBaseTestDriver otb_add_test(NAME leTuKMeansImageClassificationFilterNew COMMAND otbLearningBaseTestDriver otbKMeansImageClassificationFilterNew) +otb_add_test(NAME leTuSharkNormalizeLabels COMMAND otbLearningBaseTestDriver + otbSharkNormalizeLabels) diff --git a/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx b/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx index 5b38bf300d..305b712c31 100644 --- a/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx +++ b/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx @@ -29,4 +29,5 @@ void RegisterTests() REGISTER_TEST(otbSEMClassifierNew); REGISTER_TEST(otbDecisionTreeNew); REGISTER_TEST(otbKMeansImageClassificationFilterNew); + REGISTER_TEST(otbSharkNormalizeLabels); } -- GitLab From 1c766f822a0187718fa27bd8ac61a92fbdc7dcc9 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Tue, 6 Mar 2018 10:26:43 +0100 Subject: [PATCH 390/567] DOC: grammatical corrections in otb app python recipe (review) --- Documentation/Cookbook/rst/recipes/python.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/Cookbook/rst/recipes/python.rst b/Documentation/Cookbook/rst/recipes/python.rst index 8c7d1125e8..4f5089cb95 100644 --- a/Documentation/Cookbook/rst/recipes/python.rst +++ b/Documentation/Cookbook/rst/recipes/python.rst @@ -73,7 +73,7 @@ The Python wrapping only exposes OTB Application engine module (called *Applicat Due to blissful nature of ApplicationEngine's loading mechanism no specific wrapping is required for each application. NumPy extension to Python wrapping allows data exchange to application as an array rather than a disk file. -Of course, it is possible to load an image from file and then convert to NumPy +Of course, it is possible to load an image from file and then convert it to NumPy array or just provide a file as explained in the previous section via Application.SetParameterString(...). @@ -81,7 +81,7 @@ The bridge between NumPy and OTB makes it easy to plug OTB into any image proces GIS/Image processing tools such as GDAL, GRASS GIS, OSSIM that can deal with NumPy. Below code reads an input image using Python Pillow library (fork of PIL) and convert it to -NumPy array. The NumPy array is used an input to the application via +NumPy array. The NumPy array is used as an input to the application via *SetImageFromNumpyArray(...)* method. The application used in this example is ExtractROI. After extracting a small area the output image is taken as NumPy array with *GetImageFromNumpyArray(...)* method thus avoid writing output to a -- GitLab From 046afb48a705ca66c76cf2e119b5e4badca63550 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Tue, 6 Mar 2018 13:18:01 +0100 Subject: [PATCH 391/567] ENH: use the class dictionary in Shark RF and store it in the serialised model --- ...tbSharkRandomForestsMachineLearningModel.h | 1 + ...SharkRandomForestsMachineLearningModel.txx | 24 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h index 484de95428..7f782d73c8 100644 --- a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h @@ -157,6 +157,7 @@ private: shark::RFClassifier<unsigned int> m_RFModel; shark::RFTrainer<unsigned int> m_RFTrainer; + std::vector<unsigned int> m_ClassDictionary; unsigned int m_NumberOfTrees; unsigned int m_MTry; diff --git a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.txx b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.txx index 4d7d9e83e3..eae8ca2ccc 100644 --- a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.txx +++ b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.txx @@ -75,6 +75,7 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> Shark::ListSampleToSharkVector(this->GetInputListSample(), features); Shark::ListSampleToSharkVector(this->GetTargetListSample(), class_labels); + Shark::NormalizeLabelsAndGetDictionary(class_labels, m_ClassDictionary); shark::ClassificationDataset TrainSamples = shark::createLabeledDataFromRange(features,class_labels); //Set parameters @@ -130,7 +131,7 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> unsigned int res{0}; m_RFModel.eval(samples, res); TargetSampleType target; - target[0] = static_cast<TOutputValue>(res); + target[0] = m_ClassDictionary[static_cast<TOutputValue>(res)]; return target; } @@ -154,9 +155,9 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange(features); - #ifdef _OPENMP +#ifdef _OPENMP omp_set_num_threads(itk::MultiThreader::GetGlobalDefaultNumberOfThreads()); - #endif +#endif if(quality != ITK_NULLPTR) { @@ -177,7 +178,7 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> for(const auto& p : prediction.elements()) { TargetSampleType target; - target[0] = static_cast<TOutputValue>(p); + target[0] = m_ClassDictionary[static_cast<TOutputValue>(p)]; targets->SetMeasurementVector(id,target); ++id; } @@ -195,6 +196,12 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> } // Add comment with model file name ofs << "#" << m_RFModel.name() << std::endl; + ofs << m_ClassDictionary.size() << " "; + for(const auto& l : m_ClassDictionary) + { + ofs << l << " "; + } + ofs << std::endl; shark::TextOutArchive oa(ofs); m_RFModel.save(oa,0); } @@ -221,6 +228,15 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> ifs.clear(); ifs.seekg( 0, std::ios::beg ); } + size_t nbLabels{0}; + ifs >> nbLabels; + m_ClassDictionary.resize(nbLabels); + for(size_t i=0; i<nbLabels; ++i) + { + unsigned int label; + ifs >> label; + m_ClassDictionary[i]=label; + } shark::TextInArchive ia( ifs ); m_RFModel.load( ia, 0 ); } -- GitLab From 679ed2582d670fe077669631431f86727208fd2d Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Tue, 6 Mar 2018 14:21:25 +0100 Subject: [PATCH 392/567] ENH: compatibility for serialised models without class dictionnary --- ...tbSharkRandomForestsMachineLearningModel.h | 5 ++ ...SharkRandomForestsMachineLearningModel.txx | 60 ++++++++++++++----- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h index 7f782d73c8..63d86ab90e 100644 --- a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h @@ -135,6 +135,10 @@ public: /** If true, margin confidence value will be computed */ itkSetMacro(ComputeMargin, bool); + /** If true, class labels will be normalised in [0 ... nbClasses] */ + itkGetMacro(NormalizeClassLabels, bool); + itkSetMacro(NormalizeClassLabels, bool); + protected: /** Constructor */ SharkRandomForestsMachineLearningModel(); @@ -158,6 +162,7 @@ private: shark::RFClassifier<unsigned int> m_RFModel; shark::RFTrainer<unsigned int> m_RFTrainer; std::vector<unsigned int> m_ClassDictionary; + bool m_NormalizeClassLabels; unsigned int m_NumberOfTrees; unsigned int m_MTry; diff --git a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.txx b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.txx index eae8ca2ccc..72c816069b 100644 --- a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.txx +++ b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.txx @@ -51,6 +51,7 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> this->m_ConfidenceIndex = true; this->m_IsRegressionSupported = false; this->m_IsDoPredictBatchMultiThreaded = true; + this->m_NormalizeClassLabels = true; } @@ -75,7 +76,10 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> Shark::ListSampleToSharkVector(this->GetInputListSample(), features); Shark::ListSampleToSharkVector(this->GetTargetListSample(), class_labels); - Shark::NormalizeLabelsAndGetDictionary(class_labels, m_ClassDictionary); + if(m_NormalizeClassLabels) + { + Shark::NormalizeLabelsAndGetDictionary(class_labels, m_ClassDictionary); + } shark::ClassificationDataset TrainSamples = shark::createLabeledDataFromRange(features,class_labels); //Set parameters @@ -131,7 +135,14 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> unsigned int res{0}; m_RFModel.eval(samples, res); TargetSampleType target; - target[0] = m_ClassDictionary[static_cast<TOutputValue>(res)]; + if(m_NormalizeClassLabels) + { + target[0] = m_ClassDictionary[static_cast<TOutputValue>(res)]; + } + else + { + target[0] = static_cast<TOutputValue>(res); + } return target; } @@ -178,7 +189,14 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> for(const auto& p : prediction.elements()) { TargetSampleType target; - target[0] = m_ClassDictionary[static_cast<TOutputValue>(p)]; + if(m_NormalizeClassLabels) + { + target[0] = m_ClassDictionary[static_cast<TOutputValue>(p)]; + } + else + { + target[0] = static_cast<TOutputValue>(p); + } targets->SetMeasurementVector(id,target); ++id; } @@ -195,13 +213,18 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> itkExceptionMacro(<< "Error opening " << filename.c_str() ); } // Add comment with model file name - ofs << "#" << m_RFModel.name() << std::endl; - ofs << m_ClassDictionary.size() << " "; - for(const auto& l : m_ClassDictionary) + ofs << "#" << m_RFModel.name(); + if(m_NormalizeClassLabels) ofs << " with_dictionary"; + ofs << std::endl; + if(m_NormalizeClassLabels) { - ofs << l << " "; + ofs << m_ClassDictionary.size() << " "; + for(const auto& l : m_ClassDictionary) + { + ofs << l << " "; + } + ofs << std::endl; } - ofs << std::endl; shark::TextOutArchive oa(ofs); m_RFModel.save(oa,0); } @@ -221,6 +244,10 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> { if( line.find( m_RFModel.name() ) == std::string::npos ) itkExceptionMacro( "The model file : " + filename + " cannot be read." ); + if( line.find( "with_dictionary" ) == std::string::npos ) + { + m_NormalizeClassLabels=false; + } } else { @@ -228,14 +255,17 @@ SharkRandomForestsMachineLearningModel<TInputValue,TOutputValue> ifs.clear(); ifs.seekg( 0, std::ios::beg ); } - size_t nbLabels{0}; - ifs >> nbLabels; - m_ClassDictionary.resize(nbLabels); - for(size_t i=0; i<nbLabels; ++i) + if(m_NormalizeClassLabels) { - unsigned int label; - ifs >> label; - m_ClassDictionary[i]=label; + size_t nbLabels{0}; + ifs >> nbLabels; + m_ClassDictionary.resize(nbLabels); + for(size_t i=0; i<nbLabels; ++i) + { + unsigned int label; + ifs >> label; + m_ClassDictionary[i]=label; + } } shark::TextInArchive ia( ifs ); m_RFModel.load( ia, 0 ); -- GitLab From 02d315af2924e00cfdba09e052b61e84c2df2fa2 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 09:22:46 +0100 Subject: [PATCH 393/567] REFAC: Moving otb::Logger to Core/Common --- .../ApplicationEngine => Core/Common}/include/otbLogger.h | 0 Modules/Core/Common/src/CMakeLists.txt | 1 + .../ApplicationEngine => Core/Common}/src/otbLogger.cxx | 0 Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt | 3 ++- 4 files changed, 3 insertions(+), 1 deletion(-) rename Modules/{Wrappers/ApplicationEngine => Core/Common}/include/otbLogger.h (100%) rename Modules/{Wrappers/ApplicationEngine => Core/Common}/src/otbLogger.cxx (100%) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h similarity index 100% rename from Modules/Wrappers/ApplicationEngine/include/otbLogger.h rename to Modules/Core/Common/include/otbLogger.h diff --git a/Modules/Core/Common/src/CMakeLists.txt b/Modules/Core/Common/src/CMakeLists.txt index 02ff6250e7..50e410e9c8 100644 --- a/Modules/Core/Common/src/CMakeLists.txt +++ b/Modules/Core/Common/src/CMakeLists.txt @@ -29,6 +29,7 @@ set(OTBCommon_SRC otbWriterWatcherBase.cxx otbStopwatch.cxx otbStringToHTML.cxx + otbLogger.cxx ) add_library(OTBCommon ${OTBCommon_SRC}) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx similarity index 100% rename from Modules/Wrappers/ApplicationEngine/src/otbLogger.cxx rename to Modules/Core/Common/src/otbLogger.cxx diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index db3f434b5f..9107d2961e 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -56,9 +56,10 @@ set( OTBApplicationEngine_SRC otbWrapperStringListParameter.cxx otbWrapperAbstractParameterList.cxx otbWrapperParameterList.cxx - otbLogger.cxx ) +message("Common libraries: ${OTBCommon_LIBRARIES}") + add_library(OTBApplicationEngine ${OTBApplicationEngine_SRC}) target_link_libraries(OTBApplicationEngine ${OTBVectorDataBase_LIBRARIES} -- GitLab From 22e938815cf9bbb78ee211e191a355a05d33ffeb Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 13:37:03 +0100 Subject: [PATCH 394/567] COMP: Fix export of Logger class --- Modules/Core/Common/include/otbLogger.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index ba43072a19..32b34b0635 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -23,6 +23,7 @@ #include "itkLoggerBase.h" #include "itkLogger.h" +#include "OTBCommonExport.h" namespace otb { @@ -33,7 +34,7 @@ namespace otb { * * \ingroup OTBApplicationEngine */ -class Logger : public itk::Logger +class OTBCommon_EXPORT Logger : public itk::Logger { public: typedef Logger Self; -- GitLab From aed0c1a4f117c2d12c389d297fd5925a0fdb0ab3 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 13:40:06 +0100 Subject: [PATCH 395/567] STY: Small fixes in otb::Logger class --- Modules/Core/Common/include/otbLogger.h | 6 +++--- Modules/Core/Common/src/otbLogger.cxx | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index 32b34b0635..047c225f76 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -42,15 +42,15 @@ public: typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - itkTypeMacro(Logger, Object); + itkTypeMacro(Logger, itk::Logger); itkNewMacro(Self); // Overwrite this to provide custom formatting of log entries - std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; + virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; protected: Logger(); - virtual ~Logger(); + virtual ~Logger() ITK_OVERRIDE; }; // class Logger } // namespace otb diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index f7994eed4d..09f08cb22e 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -24,8 +24,7 @@ namespace otb { -Logger::Logger() : - itk::Logger::Logger() +Logger::Logger() { #if OTB_DEBUG this->SetPriorityLevel(itk::LoggerBase::DEBUG); -- GitLab From f9727e4019ec9b1f36bf8c9979f0e20629612e9a Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 14:06:44 +0100 Subject: [PATCH 396/567] ENH: Make otb::Logger a singleton --- Modules/Core/Common/include/otbLogger.h | 16 +++++++++++++--- Modules/Core/Common/src/otbLogger.cxx | 11 +++++++++++ .../include/otbWrapperApplication.h | 5 ----- .../src/otbWrapperApplication.cxx | 17 +++-------------- .../src/otbWrapperCompositeApplication.cxx | 2 -- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index 047c225f76..7325a9adcd 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -43,14 +43,24 @@ public: typedef itk::SmartPointer< const Self > ConstPointer; itkTypeMacro(Logger, itk::Logger); - itkNewMacro(Self); + static Pointer Instance(); + + // Overwrite this to provide custom formatting of log entries virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; protected: - Logger(); - virtual ~Logger() ITK_OVERRIDE; + itkNewMacro(Self); + Logger(); + virtual ~Logger() ITK_OVERRIDE; + +private: + Logger(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + + static Pointer Singleton; + }; // class Logger } // namespace otb diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index 09f08cb22e..c088a2d5a0 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -24,6 +24,17 @@ namespace otb { +Logger::Pointer Logger::Singleton = ITK_NULLPTR; + +Logger::Pointer Logger::Instance() +{ + if(!Logger::Singleton) + Logger::Singleton = Logger::New(); + + return Logger::Singleton; +} + + Logger::Logger() { #if OTB_DEBUG diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index c6317be142..76ccd9bb5f 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -101,7 +101,6 @@ public: m_Name = name; GetDocExample()->SetApplicationName(name); this->Modified(); - m_Logger->SetName(name); } itkGetStringMacro(Name); @@ -709,9 +708,6 @@ public: otb::Logger* GetLogger() const; - /** Sets the logger instance of the application (use with caution) */ - void SetLogger(otb::Logger *logger); - itk::ProcessObject* GetProgressSource() const; std::string GetProgressDescription() const; @@ -984,7 +980,6 @@ private: std::string m_Name; std::string m_Description; ParameterGroup::Pointer m_ParameterList; - otb::Logger::Pointer m_Logger; itk::ProcessObject::Pointer m_ProgressSource; std::string m_ProgressSourceDescription; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index cca32d50d3..4a7804d527 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -46,6 +46,7 @@ #include <exception> #include "itkMacro.h" + namespace otb { namespace Wrapper @@ -54,7 +55,6 @@ namespace Wrapper Application::Application() : m_Name(""), m_Description(""), - m_Logger(otb::Logger::New()), m_ProgressSourceDescription(""), m_DocName(""), m_DocLongDescription(""), @@ -66,10 +66,7 @@ Application::Application() m_HaveInXML(true), m_HaveOutXML(true), m_IsInXMLParsed(false) -{ - // Don't call Init from the constructor, since it calls a virtual method ! - m_Logger->SetName("Application.logger"); -} +{} Application::~Application() { @@ -77,15 +74,7 @@ Application::~Application() otb::Logger* Application::GetLogger() const { - return m_Logger; -} - -void Application::SetLogger(otb::Logger *logger) -{ - if (m_Logger != logger) - { - m_Logger = logger; - } + return otb::Logger::Instance(); } std::vector<std::string> diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx index db216594f5..7ebfa4d59a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx @@ -62,8 +62,6 @@ CompositeApplication InternalApplication container; container.App = ApplicationRegistry::CreateApplication(appType); container.Desc = desc; - // Setup logger - container.App->SetLogger(this->GetLogger()); container.App->AddObserver(AddProcessToWatchEvent(), m_AddProcessCommand.GetPointer()); m_AppContainer[key] = container; return true; -- GitLab From 380c077eaa14663ba05d43ed27d55e769dd5bede Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 15:37:22 +0100 Subject: [PATCH 397/567] ENH: Read log level from env variable in Configuration manager --- .../Common/include/otbConfigurationManager.h | 6 +++- .../Common/src/otbConfigurationManager.cxx | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/otbConfigurationManager.h b/Modules/Core/Common/include/otbConfigurationManager.h index 8c8f9af7cc..4ac1dcc372 100644 --- a/Modules/Core/Common/include/otbConfigurationManager.h +++ b/Modules/Core/Common/include/otbConfigurationManager.h @@ -31,7 +31,7 @@ #include <string> #include <boost/cstdint.hpp> - +#include "itkLoggerBase.h" #include "OTBCommonExport.h" namespace otb @@ -84,6 +84,10 @@ public: */ static RAMValueType GetMaxRAMHint(); + + static itk::LoggerBase::PriorityLevelType GetLoggerLevel(); + + private: ConfigurationManager(); //purposely not implemented ~ConfigurationManager(); //purposely not implemented diff --git a/Modules/Core/Common/src/otbConfigurationManager.cxx b/Modules/Core/Common/src/otbConfigurationManager.cxx index de0ea04579..4add4e19be 100644 --- a/Modules/Core/Common/src/otbConfigurationManager.cxx +++ b/Modules/Core/Common/src/otbConfigurationManager.cxx @@ -23,6 +23,8 @@ #include "itksys/SystemTools.hxx" #include <cstdlib> +#include <algorithm> +#include <string> namespace otb { @@ -59,6 +61,35 @@ ConfigurationManager::RAMValueType ConfigurationManager::GetMaxRAMHint() } return value; +} + + +#define level_macro(x) \ + { \ + std::string target = #x; \ + if(std::equal(svalue.begin(),svalue.end(),target.begin(),target.end())) \ + level = itk::LoggerBase::x; \ + } \ + + +itk::LoggerBase::PriorityLevelType ConfigurationManager::GetLoggerLevel() +{ + std::string svalue; + + #ifndef NDEBUG + itk::LoggerBase::PriorityLevelType level = itk::LoggerBase::DEBUG; + #else + itk::LoggerBase::PriorityLevelType level = itk::LoggerBase::WARNING; + #endif + + if(itksys::SystemTools::GetEnv("OTB_LOGGER_LEVEL",svalue)) + { + level_macro(DEBUG); + level_macro(WARNING); + level_macro(INFO); + } + return level; } + } -- GitLab From 9dd5111f70a19bf03d65408e3a581d2350403507 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 15:38:47 +0100 Subject: [PATCH 398/567] ENH: Use ConfigurationManager to configure log level in otb::Logger at instaciation time --- Modules/Core/Common/src/otbLogger.cxx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index c088a2d5a0..98b099ac57 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -20,6 +20,7 @@ #include "otbLogger.h" #include "itksys/SystemTools.hxx" +#include "otbConfigurationManager.h" namespace otb { @@ -37,11 +38,7 @@ Logger::Pointer Logger::Instance() Logger::Logger() { -#if OTB_DEBUG - this->SetPriorityLevel(itk::LoggerBase::DEBUG); -#else - this->SetPriorityLevel(itk::LoggerBase::INFO); -#endif + this->SetPriorityLevel(otb::ConfigurationManager::GetLoggerLevel()); this->SetLevelForFlushing(itk::LoggerBase::CRITICAL); -- GitLab From 528e6b65fc133061907e4fefcdfc8cb4c487f56f Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 21 Feb 2018 15:47:16 +0100 Subject: [PATCH 399/567] STY: Small change in log message --- Modules/Core/Common/include/otbMacro.h | 100 +++++++------------------ 1 file changed, 26 insertions(+), 74 deletions(-) diff --git a/Modules/Core/Common/include/otbMacro.h b/Modules/Core/Common/include/otbMacro.h index 84a5ffc773..4ffd8eed9b 100644 --- a/Modules/Core/Common/include/otbMacro.h +++ b/Modules/Core/Common/include/otbMacro.h @@ -31,6 +31,7 @@ #include "itkMacro.h" #include "itkObject.h" #include "otbConfigure.h" +#include "otbLogger.h" /** * \namespace otb @@ -42,86 +43,37 @@ namespace otb { } // end namespace otb - this is here for documentation purposes -/** This macro is used to print debug (or other information). They are - * also used to catch errors, etc. Example usage looks like: - * itkDebugMacro(<< "this is debug info" << this->SomeVariable); */ -#define otbDebugMacro(x) itkDebugMacro(x) -/* { if ( this->GetDebug() && *::itk::Object::GetGlobalWarningDisplay()) \ - { std::ostringstream itkmsg; \ - itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \ - << this->GetNameOfClass() << " (" << this << "): " x \ - << "\n\n"; \ - ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); } \ -}*/ - -#define otbMsgDebugMacro(x) \ - { \ - if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \ - { \ - std::ostringstream itkmsg; \ - itkmsg << " Msg Debug: " x << "\n"; \ - ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \ - } \ - } +#define otbFileContext(x) \ + << "file " __FILE__ ", line " << __LINE__<<", " x -#ifndef NDEBUG -#define otbGenericMsgDebugMacro(x) \ - { \ - if (::itk::Object::GetGlobalWarningDisplay()) \ - { \ - std::ostringstream itkmsg; \ - itkmsg << " Generic Msg Debug: " x << "\n"; \ - ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \ - } \ - } -#else -#define otbGenericMsgDebugMacro(x) -#endif +#define otbClassContext(x) \ + << this->GetNameOfClass() << " (" << this << "): " x -#define otbGenericMsgTestingMacro(x) \ - { \ - std::cout x << std::endl; \ - } +#define otbLogMacro(level,msg) \ + { \ + std::ostringstream itkmsg; \ + itkmsg msg << "\n"; \ + otb::Logger::Instance()->level(itkmsg.str().c_str()); \ + } -#ifdef OTB_SHOW_ALL_MSG_DEBUG -#define otbMsgDevMacro(x) \ - { \ - { \ - std::ostringstream itkmsg; \ - itkmsg << " Msg Dev: (" << __FILE__ << ":" << __LINE__ << ") " x << "\n"; \ - ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \ - } \ - } -#else -#define otbMsgDevMacro(x) -#endif - -/** This macro is used to print warning information (i.e., unusual circumstance - * but not necessarily fatal.) Example usage looks like: - * itkWarningMacro(<< "this is warning info" << this->SomeVariable); */ -#define otbWarningMacro(x) \ - { \ - if (itk::Object::GetGlobalWarningDisplay()) \ - { \ - std::ostringstream itkmsg; \ - itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \ - << this->GetNameOfClass() << " (" << this << "): " x \ - << "\n\n"; \ - itk::OutputWindowDisplayWarningText(itkmsg.str().c_str()); \ - } \ - } -#define otbGenericWarningMacro(x) \ - { \ - if (itk::Object::GetGlobalWarningDisplay()) \ - { \ - std::ostringstream itkmsg; \ - itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << ": " x <<"\n";\ - itk::OutputWindowDisplayWarningText(itkmsg.str().c_str()); \ - } \ - } +#define otbDebugMacro(x) otbLogMacro(Debug,otbFileContext(otbClassContext(x))) +#define otbMsgDebugMacro(x) otbLogMacro(Debug,otbFileContext(x)) +#define otbGenericMsgDebugMacro(x) otbLogMacro(Debug,x) +#define otbMsgDevMacro(x) otbLogMacro(Info,otbFileContext(x)) +#define otbWarningMacro(x) otbLogMacro(Warning,otbFileContext(otbClassContext(x))) +#define otbGenericWarningMacro(x) otbLogMacro(Warning,otbFileContext(x)) + + + +// TODO: Address this macro as well +#define otbGenericMsgTestingMacro(x) \ + { \ + std::cout x << std::endl; \ + } + /** This macro is used to control condition. It use ONLY by the OTB developers * */ -- GitLab From 66fc866deb64fd34e2c88de08b511a367bb4c224 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 22 Feb 2018 11:30:04 +0100 Subject: [PATCH 400/567] COMP: Wipe out all traces of OTB_SHOW_ALL_MSG_DEBUG --- CMakeLists.txt | 4 ---- Modules/Core/Common/src/otbConfigure.h.in | 3 --- .../Supervised/include/otbLibSVMMachineLearningModel.txx | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5e1130921..dc4875285f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,10 +231,6 @@ mark_as_advanced(OTB_USE_DEPRECATED) option(OTB_USE_OPENMP "Add openmp compiler and linker flags" OFF) option(OTB_USE_SSE_FLAGS "Enable SIMD optimizations (hardware dependent)." ON) -#----------------------------------------------------------------------------- -# SHOW_ALL_MSG_DEBUG option -option(OTB_SHOW_ALL_MSG_DEBUG "Show all debug messages (very verbose)" OFF) -#mark_as_advanced(OTB_SHOW_ALL_MSG_DEBUG) include(OTBSetStandardCompilerFlags) #--------------------------------------------------------------- diff --git a/Modules/Core/Common/src/otbConfigure.h.in b/Modules/Core/Common/src/otbConfigure.h.in index 5194398344..2146cf15bf 100644 --- a/Modules/Core/Common/src/otbConfigure.h.in +++ b/Modules/Core/Common/src/otbConfigure.h.in @@ -27,9 +27,6 @@ #cmakedefine OTB_BUILD_SHARED_LIBS -/* Show developer debug messages */ -#cmakedefine OTB_SHOW_ALL_MSG_DEBUG - #cmakedefine OTB_USE_GDAL_20 #cmakedefine OTB_USE_OPENMP diff --git a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.txx b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.txx index 2b14f6dca9..1d1c03e39a 100644 --- a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.txx +++ b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.txx @@ -66,7 +66,7 @@ LibSVMMachineLearningModel<TInputValue,TOutputValue> this->m_Problem.l = 0; this->m_Problem.y = ITK_NULLPTR; this->m_Problem.x = ITK_NULLPTR; -#ifndef OTB_SHOW_ALL_MSG_DEBUG +#ifndef NDEBUG svm_set_print_string_function(&otb::Utils::PrintNothing); #endif } -- GitLab From c27ca52e8af8222f58726ef77f76dc2f1dddd3ed Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 22 Feb 2018 15:18:15 +0100 Subject: [PATCH 401/567] REFAC: Review most verbose log messages to make them more compact and informative --- .../OSSIMAdapters/src/otbImageKeywordlist.cxx | 3 - .../ImageBase/include/otbExtractROIBase.txx | 5 - ...otbRAMDrivenAdaptativeStreamingManager.txx | 2 +- .../Streaming/include/otbStreamingManager.txx | 15 +- .../src/otbPipelineMemoryPrintCalculator.cxx | 7 +- Modules/IO/IOGDAL/src/otbGDALImageIO.cxx | 342 ++---------------- .../IO/ImageIO/include/otbImageFileReader.txx | 15 +- .../IO/ImageIO/include/otbImageFileWriter.txx | 55 +-- .../include/otbWrapperInputImageParameter.txx | 2 - 9 files changed, 58 insertions(+), 388 deletions(-) diff --git a/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx b/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx index 6063915cfb..22aef9289e 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx @@ -241,8 +241,6 @@ ReadGeometryFromImage(const std::string& filename, bool checkRpcTag) if (projection) { - otbMsgDevMacro(<< "OSSIM plugin projection instantiated ! "); - hasMetaData = projection->saveState(geom_kwl); otb_kwl.SetKeywordlist(geom_kwl); } @@ -479,7 +477,6 @@ WriteGeometry(const ImageKeywordlist& otb_kwl, const std::string& filename) if (geom_kwl.getSize() > 0) { - otbMsgDevMacro(<< "Exporting keywordlist ..."); ossimFilename geomFileName(filename); geomFileName.setExtension(".geom"); geom_kwl.write(geomFileName.chars()); diff --git a/Modules/Core/ImageBase/include/otbExtractROIBase.txx b/Modules/Core/ImageBase/include/otbExtractROIBase.txx index 78f546387f..26108adf67 100644 --- a/Modules/Core/ImageBase/include/otbExtractROIBase.txx +++ b/Modules/Core/ImageBase/include/otbExtractROIBase.txx @@ -152,11 +152,6 @@ ExtractROIBase<TInputImage, TOutputImage> } requestedRegion.SetIndex(index); inputPtr->SetRequestedRegion(requestedRegion); - - otbMsgDevMacro(<< "InputRequestedRegion (otbExtractROIBase): "); - otbMsgDevMacro(<< " - index: " << requestedRegion.GetIndex()); - otbMsgDevMacro(<< " - size: " << requestedRegion.GetSize()); - } /** diff --git a/Modules/Core/Streaming/include/otbRAMDrivenAdaptativeStreamingManager.txx b/Modules/Core/Streaming/include/otbRAMDrivenAdaptativeStreamingManager.txx index 07dcdbd82d..743d5de281 100644 --- a/Modules/Core/Streaming/include/otbRAMDrivenAdaptativeStreamingManager.txx +++ b/Modules/Core/Streaming/include/otbRAMDrivenAdaptativeStreamingManager.txx @@ -72,7 +72,7 @@ RAMDrivenAdaptativeStreamingManager<TImage>::PrepareStreaming( itk::DataObject * this->m_Splitter = splitter; this->m_ComputedNumberOfSplits = this->m_Splitter->GetNumberOfSplits(region, nbDivisions); - otbMsgDevMacro(<< "Number of split : " << this->m_ComputedNumberOfSplits) + this->m_Region = region; } diff --git a/Modules/Core/Streaming/include/otbStreamingManager.txx b/Modules/Core/Streaming/include/otbStreamingManager.txx index b0fdfced06..22aed33102 100644 --- a/Modules/Core/Streaming/include/otbStreamingManager.txx +++ b/Modules/Core/Streaming/include/otbStreamingManager.txx @@ -47,12 +47,9 @@ StreamingManager<TImage>::GetActualAvailableRAMInBytes(MemoryPrintType available if (availableRAMInBytes == 0) { - otbMsgDevMacro(<< "Retrieving available RAM size from configuration"); // Retrieve it from the configuration availableRAMInBytes = 1024*1024*ConfigurationManager::GetMaxRAMHint(); } - - otbMsgDevMacro("RAM used to estimate memory footprint : " << availableRAMInBytes / 1024 / 1024 << " MB") return availableRAMInBytes; } @@ -62,8 +59,6 @@ StreamingManager<TImage>::EstimateOptimalNumberOfDivisions(itk::DataObject * inp MemoryPrintType availableRAM, double bias) { - otbMsgDevMacro(<< "availableRAM " << availableRAM) - MemoryPrintType availableRAMInBytes = GetActualAvailableRAMInBytes(availableRAM); otb::PipelineMemoryPrintCalculator::Pointer memoryPrintCalculator; @@ -103,7 +98,6 @@ StreamingManager<TImage>::EstimateOptimalNumberOfDivisions(itk::DataObject * inp if (smallRegionSuccess) { - otbMsgDevMacro("Using an extract to estimate memory : " << smallRegion) // the region is well behaved, inside the largest possible region memoryPrintCalculator->SetDataToWrite(extractFilter->GetOutput() ); @@ -114,7 +108,6 @@ StreamingManager<TImage>::EstimateOptimalNumberOfDivisions(itk::DataObject * inp } else { - otbMsgDevMacro("Using the input region to estimate memory : " << region) // the region is not well behaved // use the full region memoryPrintCalculator->SetDataToWrite(input); @@ -148,11 +141,9 @@ StreamingManager<TImage>::EstimateOptimalNumberOfDivisions(itk::DataObject * inp unsigned int optimalNumberOfDivisions = otb::PipelineMemoryPrintCalculator::EstimateOptimalNumberOfStreamDivisions(pipelineMemoryPrint, availableRAMInBytes); - otbMsgDevMacro( "Estimated Memory print for the full image : " - << static_cast<unsigned int>(pipelineMemoryPrint * otb::PipelineMemoryPrintCalculator::ByteToMegabyte ) << std::endl) - otbMsgDevMacro( "Optimal number of stream divisions: " - << optimalNumberOfDivisions << std::endl) - + otbLogMacro(Info,<<"Available memory: "<<availableRAMInBytes * otb::PipelineMemoryPrintCalculator::ByteToMegabyte + <<" Mb, estimated needed memory for full processing: "<<pipelineMemoryPrint * otb::PipelineMemoryPrintCalculator::ByteToMegabyte + <<" Mb, optimal number of stream divisions: "<<optimalNumberOfDivisions); return optimalNumberOfDivisions; } diff --git a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx index d7d62e8c88..403c9d3867 100644 --- a/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx +++ b/Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx @@ -105,7 +105,7 @@ PipelineMemoryPrintCalculator::MemoryPrintType PipelineMemoryPrintCalculator ::EvaluateProcessObjectPrintRecursive(ProcessObjectType * process) { - otbMsgDevMacro(<< "EvaluateMemoryPrint for " << process->GetNameOfClass() << " (" << process << ")") + otbLogMacro(Debug,<<"Recursive evaluation of memory print for ProcessObject" << process->GetNameOfClass() << " (" << process << ")"); // This variable will store the final print MemoryPrintType print = 0; @@ -164,8 +164,9 @@ PipelineMemoryPrintCalculator::MemoryPrintType PipelineMemoryPrintCalculator ::EvaluateDataObjectPrint(DataObjectType * data) { - otbMsgDevMacro(<< "EvaluateMemoryPrint for " << data->GetNameOfClass() << " (" << data << ")") - + + otbLogMacro(Debug,<<"Evaluation of memory print for DataObject " << data->GetNameOfClass() << " (" << data << ")"); + #define OTB_IMAGE_SIZE_BLOCK(type) \ if(dynamic_cast<itk::Image<type, 2> *>(data) != NULL) \ { \ diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx index f4cfe1ecfd..944bbf51f9 100644 --- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx @@ -74,57 +74,6 @@ public: }; // end of GDALDataTypeWrapper -/* -template<class InputType> -void printOutputData(InputType *pData, int nbBands, int nbPixelToRead) -{ - for (unsigned int itPxl = 0; itPxl < (unsigned int) (nbPixelToRead * nbBands); itPxl++) - { - std::cout << "Buffer["<< itPxl << "] = " << *(pData + itPxl) << std::endl; - } -}; - -void printDataBuffer(unsigned char *pData, GDALDataType pxlType, int nbBands, int nbPixelToRead) -{ - if (pxlType == GDT_Int16) - { - printOutputData( static_cast<short*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_Int32) - { - printOutputData( static_cast<int*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_Float32) - { - printOutputData( static_cast<float*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_Float64) - { - printOutputData( static_cast<double*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_CInt16) - { - printOutputData( static_cast<std::complex<short>*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_CInt32) - { - printOutputData( static_cast<std::complex<int>*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_CFloat32) - { - printOutputData( static_cast<std::complex<float>*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else if (pxlType == GDT_CFloat64) - { - printOutputData( static_cast<std::complex<double>*>( static_cast<void*>(pData) ), nbBands, nbPixelToRead); - } - else - { - std::cerr << "Pixel type unknown" << std::endl; - } -}; -*/ - GDALImageIO::GDALImageIO() { // By default set number of dimensions to two. @@ -147,9 +96,6 @@ GDALImageIO::GDALImageIO() m_IsIndexed = false; m_DatasetNumber = 0; - //m_poBands = NULL; - //m_hDriver = NULL; - //m_poDataset = NULL; m_NbBands = 0; m_FlagWriteImageInformation = true; @@ -177,7 +123,6 @@ bool GDALImageIO::CanReadFile(const char* file) // First check the extension if (file == ITK_NULLPTR) { - itkDebugMacro(<< "No filename specified."); return false; } m_Dataset = GDALDriverManagerWrapper::GetInstance().Open(file); @@ -207,7 +152,7 @@ void GDALImageIO::Read(void* buffer) // Check if conversion succeed if (p == ITK_NULLPTR) { - itkExceptionMacro(<< "GDAL : Bad alloc"); + itkExceptionMacro(<< "Buffer passed to GDALImageIO for reading is NULL."); return; } @@ -219,15 +164,10 @@ void GDALImageIO::Read(void* buffer) int lNbLinesRegion = this->GetIORegion().GetSize()[1]; int lNbColumnsRegion = this->GetIORegion().GetSize()[0]; - //std::cout << "OriginBuffer= " << lFirstLineRegion << " x " << lFirstColumnRegion << std::endl; - //std::cout << "SizeBuffer= " << lNbLinesRegion << " x " << lNbColumnsRegion << std::endl; - // Compute the origin of the image region to read at the initial resolution int lFirstLine = lFirstLineRegion * (1 << m_ResolutionFactor); int lFirstColumn = lFirstColumnRegion * (1 << m_ResolutionFactor); - //std::cout << "OriginImage= " << lFirstLine << " x " << lFirstColumn << std::endl; - // Compute the size of the image region to read at the initial resolution int lNbLines = lNbLinesRegion * (1 << m_ResolutionFactor); int lNbColumns = lNbColumnsRegion * (1 << m_ResolutionFactor); @@ -238,103 +178,11 @@ void GDALImageIO::Read(void* buffer) if (lFirstColumn + lNbColumns > static_cast<int>(m_OriginalDimensions[0])) lNbColumns = static_cast<int>(m_OriginalDimensions[0]-lFirstColumn); - //std::cout << "SizeImage= " << lNbLines << " x " << lNbColumns << std::endl; - - GDALDataset* dataset = m_Dataset->GetDataSet(); - // This special case is due to the fact the CINT/CLONG types - // do not exists in ITK. In this case we only report the first band - // TODO This should be fixed - /*if (GDALDataTypeIsComplex(m_PxType->pixType) - && (m_PxType->pixType != GDT_CFloat32) - && (m_PxType->pixType != GDT_CFloat64)) - { - int pixelOffset = m_BytePerPixel * m_NbBands; - int lineOffset = m_BytePerPixel * m_NbBands * lNbColumns; - int bandOffset = m_BytePerPixel; - int nbBands = m_NbBands; - - int nbPixelToRead = lNbColumns * lNbLines; - std::streamoff nbBytes = static_cast<std::streamoff>(m_NbBands) * static_cast<std::streamoff>(nbPixelToRead) * static_cast<std::streamoff>(m_BytePerPixel); - unsigned char *pBufferTemp = new unsigned char[static_cast<unsigned int>(nbBytes)]; - - // keep it for the moment - otbMsgDevMacro(<< "Parameters RasterIO (case CInt and CShort):" - << "\n indX = " << lFirstColumn - << "\n indY = " << lFirstLine - << "\n sizeX = " << lNbColumns - << "\n sizeY = " << lNbLines - << "\n GDAL Data Type = " << GDALGetDataTypeName(m_PxType->pixType) - << "\n pixelOffset = " << pixelOffset - << "\n lineOffset = " << lineOffset - << "\n bandOffset = " << bandOffset); - - CPLErr lCrGdal = m_Dataset->GetDataSet()->RasterIO(GF_Read, - lFirstColumn, - lFirstLine, - lNbColumns, - lNbLines, - pBufferTemp, //p, // pData - lNbColumns, - lNbLines, - m_PxType->pixType, - nbBands, - // We want to read all bands - NULL, - pixelOffset, - lineOffset, - bandOffset); - // Check for gdal error - if (lCrGdal == CE_Failure) - { - itkExceptionMacro(<< "Error while reading image (GDAL format) " << m_FileName ); - delete[] pBufferTemp; - return; - } - //std::cout << "RAW BUFFER:" <<std::endl; - //printDataBuffer(pBufferTemp, m_PxType->pixType, m_NbBands, lNbColumns*lNbLines); - - // Convert the buffer to GDT_Float64 type - typedef std::complex<float> RealType; - typedef double ScalarRealType; - - if (m_PxType->pixType == GDT_CInt32) - { - //std::cout << "Convert input File from GDT_CInt32 to GDT_CFloat32" << std::endl; - typedef std::complex<int> ComplexIntType; - - for (unsigned int itPxl = 0; itPxl < (unsigned int) (nbPixelToRead * m_NbBands); itPxl++) - { - ComplexIntType pxlValue = *(static_cast<ComplexIntType*>( static_cast<void*>(pBufferTemp)) + itPxl ); - - RealType pxlValueReal( static_cast<ScalarRealType>(pxlValue.real()), static_cast<ScalarRealType>(pxlValue.imag()) ); - - memcpy((void*) (&(p[itPxl*sizeof(RealType)])), (const void*) (&(pxlValueReal)), (size_t) (sizeof(RealType))); - } - } - else if (m_PxType->pixType == GDT_CInt16) - { - //std::cout << "Convert input File from GDT_CInt16 to GDT_CFloat32" << std::endl; - typedef std::complex<short> ComplexShortType; - - for (unsigned int itPxl = 0; itPxl < (unsigned int) (nbPixelToRead * m_NbBands); itPxl++) - { - ComplexShortType pxlValue = *(static_cast<ComplexShortType*>( static_cast<void*>(pBufferTemp)) + itPxl ); - - RealType pxlValueReal( static_cast<ScalarRealType>(pxlValue.real()), static_cast<ScalarRealType>(pxlValue.imag()) ); - - memcpy((void*) (&(p[itPxl*sizeof(RealType)])), (const void*) (&(pxlValueReal)), (size_t) (sizeof(RealType))); - } - } - //std::cout << "CONVERTED BUFFER:" <<std::endl; - //printDataBuffer(p, GDT_CFloat64, m_NbBands, lNbColumns*lNbLines); - delete[] pBufferTemp; - } - // In the indexed case, one has to retrieve the index image and the // color table, and translate p to a 4 components color values buffer - else*/ if (m_IsIndexed) + if (m_IsIndexed) { // TODO: This is a very special case and seems to be working only // for unsigned char pixels. There might be a gdal method to do @@ -346,8 +194,9 @@ void GDALImageIO::Read(void* buffer) std::streamoff step = static_cast<std::streamoff>(this->GetNumberOfComponents()) * static_cast<std::streamoff>(m_BytePerPixel); - - CPLErr lCrGdal = dataset->GetRasterBand(1)->RasterIO(GF_Read, + otbLogMacro(Debug,<<"GDAL reads ["<<lFirstColumn<<", "<<lFirstColumn+lNbColumns-1<<"]x["<<lFirstLine<<", "<<lFirstLine+lNbLines-1<<"] indexed color image of type "<<GDALGetDataTypeName(m_PxType->pixType)<<" from file "<<m_FileName); + otb::Stopwatch chrono = otb::Stopwatch::StartNew(); + CPLErr lCrGdal = dataset->GetRasterBand(1)->RasterIO(GF_Read, lFirstColumn, lFirstLine, lNbColumns, @@ -358,11 +207,16 @@ void GDALImageIO::Read(void* buffer) m_PxType->pixType, 0, 0); - if (lCrGdal == CE_Failure) + chrono.Stop(); + + if (lCrGdal == CE_Failure) { itkExceptionMacro(<< "Error while reading image (GDAL format) '" << m_FileName.c_str() << "' : " << CPLGetLastErrorMsg()); } + + otbLogMacro(Debug,<< "GDAL read took " << chrono.GetElapsedMilliseconds() << " ms") + // Interpret index as color std::streamoff cpt(0); GDALColorTable* colorTable = dataset->GetRasterBand(1)->GetColorTable(); @@ -394,19 +248,7 @@ void GDALImageIO::Read(void* buffer) } // keep it for the moment - //otbMsgDevMacro(<< "Number of bands inside input file: " << m_NbBands); - otbMsgDevMacro(<< "Parameters RasterIO : \n" - << " indX = " << lFirstColumn << "\n" - << " indY = " << lFirstLine << "\n" - << " sizeX = " << lNbColumns << "\n" - << " sizeY = " << lNbLines << "\n" - << " Buffer Size X = " << lNbColumnsRegion << "\n" - << " Buffer Size Y = " << lNbLinesRegion << "\n" - << " GDAL Data Type = " << GDALGetDataTypeName(m_PxType->pixType) << "\n" - << " nbBands = " << nbBands << "\n" - << " pixelOffset = " << pixelOffset << "\n" - << " lineOffset = " << lineOffset << "\n" - << " bandOffset = " << bandOffset ); + otbLogMacro(Debug,<<"GDAL reads ["<<lFirstColumn<<", "<<lFirstColumnRegion+lNbColumnsRegion-1<<"]x["<<lFirstLineRegion<<", "<<lFirstLineRegion+lNbLinesRegion-1<<"] x "<<nbBands<<" bands of type "<<GDALGetDataTypeName(m_PxType->pixType)<<" from file "<<m_FileName); otb::Stopwatch chrono = otb::Stopwatch::StartNew(); CPLErr lCrGdal = m_Dataset->GetDataSet()->RasterIO(GF_Read, @@ -425,8 +267,6 @@ void GDALImageIO::Read(void* buffer) lineOffset, bandOffset); chrono.Stop(); - otbMsgDevMacro(<< "RasterIO Read took " << chrono.GetElapsedMilliseconds() << " ms") - // Check if gdal call succeed if (lCrGdal == CE_Failure) { @@ -434,8 +274,10 @@ void GDALImageIO::Read(void* buffer) << m_FileName.c_str() << "' : " << CPLGetLastErrorMsg()); return; } - //printDataBuffer(p, m_PxType->pixType, m_NbBands, lNbColumnsRegion*lNbLinesRegion); - } + + otbLogMacro(Debug,<< "GDAL read took " << chrono.GetElapsedMilliseconds() << " ms") + + } } bool GDALImageIO::GetSubDatasetInfo(std::vector<std::string> &names, std::vector<std::string> &desc) @@ -456,8 +298,6 @@ bool GDALImageIO::GetSubDatasetInfo(std::vector<std::string> &names, std::vector std::string key, name; if (System::ParseHdfSubsetName(papszMetadata[cpt], key, name)) { - otbMsgDevMacro(<< "- key: " << key); - otbMsgDevMacro(<< "- name: " << name); // check if this is a dataset name if (key.find("_NAME") != std::string::npos) names.push_back(name); // check if this is a dataset descriptor @@ -609,8 +449,6 @@ void GDALImageIO::InternalReadImageInformation() std::string key, name; if (System::ParseHdfSubsetName(papszMetadata[cpt], key, name)) { - otbMsgDevMacro(<< "- key: " << key); - otbMsgDevMacro(<< "- name: " << name); // check if this is a dataset name if (key.find("_NAME") != std::string::npos) names.push_back(name); } @@ -618,7 +456,6 @@ void GDALImageIO::InternalReadImageInformation() } if (m_DatasetNumber < names.size()) { - otbMsgDevMacro(<< "Reading: " << names[m_DatasetNumber]); m_Dataset = GDALDriverManagerWrapper::GetInstance().Open(names[m_DatasetNumber]); } else @@ -643,8 +480,6 @@ void GDALImageIO::InternalReadImageInformation() m_OriginalDimensions.push_back(dataset->GetRasterXSize()); m_OriginalDimensions.push_back(dataset->GetRasterYSize()); - otbMsgDevMacro(<< "Original Dimensions of the input file: " << m_OriginalDimensions[0] << " x " << m_OriginalDimensions[1]); - // Get Number of Bands m_NbBands = dataset->GetRasterCount(); @@ -661,21 +496,13 @@ void GDALImageIO::InternalReadImageInformation() /*std::cout << "Overviews size of input file" << m_FileName << ": " << m_OverviewsSize.back().first << " x " << m_OverviewsSize.back().second << std::endl; */ - otbMsgDevMacro( << "Overviews size of input file" << m_FileName << ": " - << m_OverviewsSize.back().first << " x " << m_OverviewsSize.back().second); } - otbMsgDevMacro(<< "Number of Overviews inside input file: " << m_NumberOfOverviews); - otbMsgDevMacro(<< "Input file dimension: " << m_Dimensions[0] << ", " << m_Dimensions[1]); - otbMsgDevMacro(<< "Number of bands inside input file: " << m_NbBands); - this->SetNumberOfComponents(m_NbBands); // Set the number of dimensions (verify for the dim ) this->SetNumberOfDimensions(2); - otbMsgDevMacro(<< "Nb of Dimensions of the input file: " << m_NumberOfDimensions); - // Automatically set the Type to Binary for GDAL data this->SetFileTypeToBinary(); @@ -683,7 +510,7 @@ void GDALImageIO::InternalReadImageInformation() // Consider only the data type given by the first band // Maybe be could changed (to check) m_PxType->pixType = dataset->GetRasterBand(1)->GetRasterDataType(); - otbMsgDevMacro(<< "PixelType inside input file: "<< GDALGetDataTypeName(m_PxType->pixType) ); + if (m_PxType->pixType == GDT_Byte) { SetComponentType(UCHAR); @@ -809,7 +636,7 @@ void GDALImageIO::InternalReadImageInformation() // we are reading a complex data set into an image where the pixel // type is Vector<real>: we have to double the number of component // for that to work - otbMsgDevMacro( << "GDALtypeIO= Complex and IFReader::InternalPixelType= Scalar and IFReader::PixelType= Vector"); + otbLogMacro(Warning,<<"Encoding of file ("<<m_FileName<<") is complex but will be read as a VectorImage of scalar type, with twice the number of bands."); this->SetNumberOfComponents(m_NbBands*2); this->SetPixelType(VECTOR); } @@ -831,12 +658,6 @@ void GDALImageIO::InternalReadImageInformation() } } - /*** Parameters set by Internal Read function ***/ - otbMsgDevMacro( << "Pixel Type IFReader = " << GetPixelTypeAsString(this->GetPixelType()) ) - otbMsgDevMacro( << "Number of component IFReader = " << this->GetNumberOfComponents() ) - otbMsgDevMacro( << "Byte per pixel set = " << m_BytePerPixel ) - otbMsgDevMacro( << "Component Type set = " << GetComponentTypeAsString(this->GetComponentType()) ); - /*----------------------------------------------------------------------*/ /*-------------------------- METADATA ----------------------------------*/ /*----------------------------------------------------------------------*/ @@ -854,8 +675,6 @@ void GDALImageIO::InternalReadImageInformation() if(blockSizeX > 0 && blockSizeY > 0) { - otbMsgDevMacro(<< "Original blockSize: "<< blockSizeX << " x " << blockSizeY ); - blockSizeX = uint_ceildivpow2(blockSizeX,m_ResolutionFactor); if (m_Dataset->IsJPEG2000()) { @@ -868,8 +687,6 @@ void GDALImageIO::InternalReadImageInformation() blockSizeY = blockSizeY * (1 << m_ResolutionFactor); } - otbMsgDevMacro(<< "Decimated blockSize: "<< blockSizeX << " x " << blockSizeY ); - itk::EncapsulateMetaData<unsigned int>(dict, MetaDataKey::TileHintX, blockSizeX); itk::EncapsulateMetaData<unsigned int>(dict, MetaDataKey::TileHintY, blockSizeY); } @@ -948,7 +765,6 @@ void GDALImageIO::InternalReadImageInformation() } else { - otbMsgDevMacro( << "No projection => sensor model" ); // Special case for Jpeg2000 files : try to read the origin in the GML box if (m_Dataset->IsJPEG2000()) { @@ -1044,7 +860,7 @@ void GDALImageIO::InternalReadImageInformation() } else { - otbWarningMacro(<< "Incorrect geotransform (spacing = 0)!"); + otbLogMacro(Warning,<< "Geotransform reported by Gdal is invalid (spacing = 0)"); m_Spacing[0] = 1; m_Spacing[1] = 1; } @@ -1065,23 +881,6 @@ void GDALImageIO::InternalReadImageInformation() m_Origin[0] += 0.5*m_Spacing[0]; m_Origin[1] += 0.5*m_Spacing[1]; - // Dataset info - otbMsgDevMacro(<< "**** ReadImageInformation() DATASET INFO: ****" ); - otbMsgDevMacro(<< "Projection Ref: "<< dataset->GetProjectionRef() ); - double GT[6]; - if (dataset->GetGeoTransform(GT) == CE_None) - { - otbMsgDevMacro( <<"Geo Transform: "<< GT[0] << ", " << GT[1] << ", " - << GT[2] << ", " << GT[3] << ", " - << GT[4] << ", " << GT[5] ); - } - else - { - otbMsgDevMacro( << "No Geo Transform: "); - } - otbMsgDevMacro(<< "GCP Projection Ref: "<< dataset->GetGCPProjection() ); - otbMsgDevMacro(<< "GCP Count: " << dataset->GetGCPCount() ); - /* -------------------------------------------------------------------- */ /* Report metadata. */ /* -------------------------------------------------------------------- */ @@ -1289,7 +1088,6 @@ bool GDALImageIO::CanWriteFile(const char* name) // First check the filename if (name == ITK_NULLPTR) { - itkDebugMacro(<< "No filename specified."); return false; } @@ -1307,7 +1105,7 @@ bool GDALImageIO::CanWriteFile(const char* name) if ( GDALGetMetadataItem( driver, GDAL_DCAP_CREATE, ITK_NULLPTR ) == ITK_NULLPTR && GDALGetMetadataItem( driver, GDAL_DCAP_CREATECOPY, ITK_NULLPTR ) == ITK_NULLPTR ) { - itkDebugMacro(<< "The driver " << GDALGetDriverShortName(driver) << " does not support writing"); + otbLogMacro(Warning,<< "Gdal driver " << GDALGetDriverShortName(driver) << " does not support writing"); return false; } return true; @@ -1321,7 +1119,6 @@ bool GDALImageIO::CanStreamWrite() if (driver == ITK_NULLPTR) { - itkDebugMacro(<< "Unable to instantiate driver " << gdalDriverShortName); m_CanStreamWrite = false; } if ( GDALGetMetadataItem( driver, GDAL_DCAP_CREATE, ITK_NULLPTR ) != ITK_NULLPTR ) @@ -1347,7 +1144,7 @@ void GDALImageIO::Write(const void* buffer) // Check if conversion succeed if (buffer == ITK_NULLPTR) { - itkExceptionMacro(<< "GDAL : Bad alloc"); + itkExceptionMacro(<< "Null buffer passed to GDALImageIO for writing."); return; } @@ -1373,18 +1170,7 @@ void GDALImageIO::Write(const void* buffer) // If driver supports streaming if (m_CanStreamWrite) { - - otbMsgDevMacro(<< "RasterIO Write requested region : " << this->GetIORegion() << - "\n, lFirstColumn =" << lFirstColumn << - "\n, lFirstLine =" << lFirstLine << - "\n, lNbColumns =" << lNbColumns << - "\n, lNbLines =" << lNbLines << - "\n, m_PxType =" << GDALGetDataTypeName(m_PxType->pixType) << - "\n, m_NbBands =" << m_NbBands << - "\n, m_BytePerPixel ="<< m_BytePerPixel << - "\n, Pixel offset =" << m_BytePerPixel * m_NbBands << // is nbComp * BytePerPixel - "\n, Line offset =" << m_BytePerPixel * m_NbBands * lNbColumns << // is pixelOffset * nbColumns - "\n, Band offset =" << m_BytePerPixel) // is BytePerPixel + otbLogMacro(Debug,<<"GDAL writes ["<<lFirstColumn<<", "<<lFirstColumn+lNbColumns-1<<"]x["<<lFirstLine<<", "<<lFirstLine+lNbLines-1<<"] x "<<m_NbBands<<" bands of type "<<GDALGetDataTypeName(m_PxType->pixType)<<" to file "<<m_FileName); otb::Stopwatch chrono = otb::Stopwatch::StartNew(); CPLErr lCrGdal = m_Dataset->GetDataSet()->RasterIO(GF_Write, @@ -1408,7 +1194,6 @@ void GDALImageIO::Write(const void* buffer) // Band offset is BytePerPixel m_BytePerPixel); chrono.Stop(); - otbMsgDevMacro(<< "RasterIO Write took " << chrono.GetElapsedMilliseconds() << " ms") // Check if writing succeed if (lCrGdal == CE_Failure) @@ -1416,6 +1201,9 @@ void GDALImageIO::Write(const void* buffer) itkExceptionMacro(<< "Error while writing image (GDAL format) '" << m_FileName.c_str() << "' : " << CPLGetLastErrorMsg()); } + + otbLogMacro(Debug,<< "GDAL write took " << chrono.GetElapsedMilliseconds() << " ms") + // Flush dataset cache m_Dataset->GetDataSet()->FlushCache(); } @@ -1582,55 +1370,6 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) if (m_CanStreamWrite) { GDALCreationOptionsType creationOptions = m_CreationOptions; -/* - // Force tile mode for TIFF format if no creation option are given - if( driverShortName == "GTiff" ) - { - if ( CreationOptionContains( "TILED=YES" ) ) - { - // User requested tiled TIFF explicitly - // - // Let GDAL set up the BLOCKXSIZE and BLOCKYSIZE - // or suppose the user have set it also along with TILED=YES - // This allows the user to have complete - // control over the tiling scheme - } - else if ( CreationOptionContains( "BLOCKYSIZE=" ) ) - { - // User did not set "TILED=YES" but set "BLOCKYSIZE=" - // -> He requested a stripped TIFF - } - else - { - // User did not specify "TILED=YES" nor "BLOCKYSIZE=?" - // Switch to TILED mode automatically, and choose BLOCKXSIZE and BLOCKYSIZE for him - - otbMsgDevMacro(<< "Enabling TIFF Tiled mode") - - // Use a fixed tile size - // Take as reference is a 256*256 short int 4 bands tile - const unsigned int ReferenceTileSizeInBytes = 256 * 256 * 4 * 2; - const unsigned int NbPixelPerTile = ReferenceTileSizeInBytes / m_BytePerPixel / m_NbBands; - const unsigned int IdealTileDimension = static_cast<unsigned int>( vcl_sqrt(static_cast<float>(NbPixelPerTile)) ); - - // Set tileDimension to the nearest power of two and aligned to - // 16 pixels (needed by TIFF spec) - unsigned int tileDimension = 16; - while(2*tileDimension < IdealTileDimension) - { - tileDimension*=2; - } - otbMsgDevMacro(<< "Tile dimension : " << tileDimension << " * " << tileDimension) - - std::ostringstream tileDimensionStr; - tileDimensionStr << tileDimension; - - creationOptions.push_back( "TILED=YES" ); - creationOptions.push_back( std::string("BLOCKXSIZE=") + tileDimensionStr.str() ); - creationOptions.push_back( std::string("BLOCKYSIZE=") + tileDimensionStr.str() ); - } - } -*/ m_Dataset = GDALDriverManagerWrapper::GetInstance().Create( driverShortName, GetGdalWriteImageFileName(driverShortName, m_FileName), @@ -1691,7 +1430,7 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) // If there is no ProjectionRef, and the GeoTransform is not the identity, // then saving also GCPs is undefined behavior for GDAL, and a WGS84 projection crs // is assigned arbitrarily - otbMsgDevMacro(<< "Skipping GCPs saving to prevent GDAL from assigning a WGS84 projection ref to the file") + otbLogMacro(Warning,<< "Skipping GCPs saving to prevent GDAL from assigning a WGS84 projref to file ("<<m_FileName<<")") } else { @@ -1802,7 +1541,6 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) unsigned int equalityPos = svalue.find_first_of('='); std::string tag = svalue.substr(0, equalityPos); std::string value = svalue.substr(equalityPos + 1); - otbMsgDevMacro(<< "Metadata: " << tag << "=" << value); dataset->SetMetadataItem(tag.c_str(), value.c_str(), ITK_NULLPTR); } } @@ -1810,24 +1548,6 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) // END - // Dataset info - otbMsgDevMacro( << "**** WriteImageInformation() DATASET INFO: ****" ); - otbMsgDevMacro( << "Projection Ref: "<<dataset->GetProjectionRef() ); - double GT[6]; - if (dataset->GetGeoTransform(GT) == CE_None) - { - otbMsgDevMacro( <<"Geo Transform: "<< GT[0] << ", " << GT[1] << ", " - << GT[2] << ", " << GT[3] << ", " - << GT[4] << ", " << GT[5] ); - } - else - { - otbMsgDevMacro( << "No Geo Transform: "); - } - - otbMsgDevMacro( << "GCP Projection Ref: "<< dataset->GetGCPProjection() ); - otbMsgDevMacro( << "GCP Count: " << dataset->GetGCPCount() ); - // Write no-data flags std::vector<bool> noDataValueAvailable; bool ret = itk::ExposeMetaData<std::vector<bool> >(dict,MetaDataKey::NoDataValueAvailable,noDataValueAvailable); @@ -1926,7 +1646,6 @@ bool GDALImageIO::GetOriginFromGMLBox(std::vector<double> &origin) std::string gmlString = static_cast<std::string>(jp2Metadata.papszGMLMetadata[0]); gmlString.erase(0,18); // We need to remove first part to create a true xml stream - otbMsgDevMacro( << "XML extract from GML box: " << gmlString ); TiXmlDocument doc; doc.Parse(gmlString.c_str()); // Create xml doc from a string @@ -1942,13 +1661,8 @@ bool GDALImageIO::GetOriginFromGMLBox(std::vector<double> &origin) .FirstChild( "gml:limits" ) .FirstChild( "gml:GridEnvelope" ) .FirstChild( "gml:low").ToElement(); - if(originTag) + if(!originTag) { - otbMsgDevMacro( << "\t Origin (" << originTag->Value() <<" tag)= "<< originTag->GetText()); - } - else - { - otbMsgDevMacro( << "Didn't find the GML element which indicate the origin!" ); return false; } @@ -1963,8 +1677,6 @@ bool GDALImageIO::GetOriginFromGMLBox(std::vector<double> &origin) origin[0] += -1.0; origin[1] += -1.0; - otbMsgDevMacro( << "\t Origin from GML box: " << origin[0] << ", " << origin[1] ); - return true; } diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx index 87cc50b6e3..155ce0503d 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.txx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx @@ -107,7 +107,6 @@ void ImageFileReader<TOutputImage, ConvertPixelTraits> ::SetImageIO( otb::ImageIOBase * imageIO) { - itkDebugMacro("setting ImageIO to " << imageIO ); if (this->m_ImageIO != imageIO ) { this->m_ImageIO = imageIO; @@ -207,12 +206,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> char * loadBuffer = new char[nbBytes]; - otbMsgDevMacro(<< "buffer size for ImageIO::read = " << nbBytes << " = \n" - << "ComponentSize ("<< this->m_ImageIO->GetComponentSize() << ") x " \ - << "Nb of Component ( max(" << this->m_ImageIO->GetNumberOfComponents() \ - << " , "<<m_BandList.size() << ") ) x " \ - << "Nb of Pixel to read (" << region.GetNumberOfPixels() << ")"); - this->m_ImageIO->Read(loadBuffer); if (m_FilenameHelper->BandRangeIsSet()) @@ -410,13 +403,13 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> if (m_FilenameHelper->ExtGEOMFileNameIsSet()) { otb_kwl = ReadGeometryFromGEOMFile(m_FilenameHelper->GetExtGEOMFileName()); - otbMsgDevMacro(<< "Loading external kwl: "<< m_FilenameHelper->GetExtGEOMFileName()); + otbLogMacro(Info,<< "Loading metadata from external geom file "<< m_FilenameHelper->GetExtGEOMFileName()); } // Case 2: attached geom (if present) else if (itksys::SystemTools::FileExists(attachedGeom)) { otb_kwl = ReadGeometryFromGEOMFile(attachedGeom); - otbMsgDevMacro(<< "Loading attached kwl"); + otbLogMacro(Info,<< "Loading metadata from attached geom file "<<attachedGeom); } // Case 3: find an ossimPluginProjection // Case 4: find an ossimProjection @@ -424,7 +417,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> else { otb_kwl = ReadGeometryFromImage(lFileNameOssimKeywordlist,!m_FilenameHelper->GetSkipRpcTag()); - otbMsgDevMacro(<< "Loading internal kwl"); + otbLogMacro(Info,<< "Loading metadata from product files"); } // Don't add an empty ossim keyword list @@ -644,8 +637,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> fic_trouve = true; } - otbMsgDevMacro(<< "lFileNameGdal : " << GdalFileName.c_str()); - otbMsgDevMacro(<< "fic_trouve : " << fic_trouve); return (fic_trouve); } diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index b1472291f1..4cc2c316da 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -99,7 +99,6 @@ ImageFileWriter<TInputImage> typedef NumberOfDivisionsStrippedStreamingManager<TInputImage> NumberOfDivisionsStrippedStreamingManagerType; typename NumberOfDivisionsStrippedStreamingManagerType::Pointer streamingManager = NumberOfDivisionsStrippedStreamingManagerType::New(); streamingManager->SetNumberOfDivisions(nbDivisions); - m_StreamingManager = streamingManager; } @@ -111,7 +110,6 @@ ImageFileWriter<TInputImage> typedef NumberOfDivisionsTiledStreamingManager<TInputImage> NumberOfDivisionsTiledStreamingManagerType; typename NumberOfDivisionsTiledStreamingManagerType::Pointer streamingManager = NumberOfDivisionsTiledStreamingManagerType::New(); streamingManager->SetNumberOfDivisions(nbDivisions); - m_StreamingManager = streamingManager; } @@ -123,7 +121,6 @@ ImageFileWriter<TInputImage> typedef NumberOfLinesStrippedStreamingManager<TInputImage> NumberOfLinesStrippedStreamingManagerType; typename NumberOfLinesStrippedStreamingManagerType::Pointer streamingManager = NumberOfLinesStrippedStreamingManagerType::New(); streamingManager->SetNumberOfLinesPerStrip(nbLinesPerStrip); - m_StreamingManager = streamingManager; } @@ -136,7 +133,6 @@ ImageFileWriter<TInputImage> typename RAMDrivenStrippedStreamingManagerType::Pointer streamingManager = RAMDrivenStrippedStreamingManagerType::New(); streamingManager->SetAvailableRAMInMB(availableRAM); streamingManager->SetBias(bias); - m_StreamingManager = streamingManager; } @@ -147,8 +143,7 @@ ImageFileWriter<TInputImage> { typedef TileDimensionTiledStreamingManager<TInputImage> TileDimensionTiledStreamingManagerType; typename TileDimensionTiledStreamingManagerType::Pointer streamingManager = TileDimensionTiledStreamingManagerType::New(); - streamingManager->SetTileDimension(tileDimension); - + streamingManager->SetTileDimension(tileDimension); m_StreamingManager = streamingManager; } @@ -238,7 +233,6 @@ void ImageFileWriter<TInputImage> ::SetIORegion(const itk::ImageIORegion& region) { - itkDebugMacro("setting IORegion to " << region); if (m_IORegion != region) { m_IORegion = region; @@ -289,7 +283,7 @@ ImageFileWriter<TInputImage> /** Parse streaming modes */ if(m_FilenameHelper->StreamingTypeIsSet()) { - itkWarningMacro(<<"Streaming configuration through extended filename is used. Any previous streaming configuration (ram value, streaming mode ...) will be ignored."); + otbLogMacro(Warning,<<"Streaming configuration through extended filename is used. Any previous streaming configuration (ram value, streaming mode ...) will be ignored."); std::string type = m_FilenameHelper->GetStreamingType(); @@ -311,11 +305,11 @@ ImageFileWriter<TInputImage> { if(sizemode != "auto") { - itkWarningMacro(<<"In auto streaming type, the sizemode option will be ignored."); + otbLogMacro(Warning,<<"In auto streaming type, the sizemode option will be ignored."); } if(sizevalue == 0.) { - itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from the OTB_MAX_RAM_HINT environment variable if set, or else use the default value"); + otbLogMacro(Warning,<<"sizemode is auto but sizevalue is 0. Value will be fetched from the OTB_MAX_RAM_HINT environment variable if set, or else use the default value"); } this->SetAutomaticAdaptativeStreaming(sizevalue); } @@ -325,7 +319,7 @@ ImageFileWriter<TInputImage> { if(sizevalue == 0.) { - itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from the OTB_MAX_RAM_HINT environment variable if set, or else use the default value"); + otbLogMacro(Warning,<<"sizemode is auto but sizevalue is 0. Value will be fetched from the OTB_MAX_RAM_HINT environment variable if set, or else use the default value"); } this->SetAutomaticTiledStreaming(sizevalue); } @@ -333,7 +327,7 @@ ImageFileWriter<TInputImage> { if(sizevalue == 0.) { - itkWarningMacro("Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); + otbLogMacro(Warning,<<"Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } this->SetNumberOfDivisionsTiledStreaming(static_cast<unsigned int>(sizevalue)); } @@ -341,7 +335,7 @@ ImageFileWriter<TInputImage> { if(sizevalue == 0.) { - itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); + otbLogMacro(Warning,<<"Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } this->SetTileDimensionTiledStreaming(static_cast<unsigned int>(sizevalue)); @@ -353,7 +347,7 @@ ImageFileWriter<TInputImage> { if(sizevalue == 0.) { - itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from configuration file if any, or from cmake configuration otherwise."); + otbLogMacro(Warning,<<"sizemode is auto but sizevalue is 0. Value will be fetched from configuration file if any, or from cmake configuration otherwise."); } this->SetAutomaticStrippedStreaming(sizevalue); @@ -362,7 +356,7 @@ ImageFileWriter<TInputImage> { if(sizevalue == 0.) { - itkWarningMacro("Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); + otbLogMacro(Warning,<<"Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } this->SetNumberOfDivisionsStrippedStreaming(static_cast<unsigned int>(sizevalue)); } @@ -370,7 +364,7 @@ ImageFileWriter<TInputImage> { if(sizevalue == 0.) { - itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); + otbLogMacro(Warning,<<"Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } this->SetNumberOfLinesStrippedStreaming(static_cast<unsigned int>(sizevalue)); } @@ -380,7 +374,7 @@ ImageFileWriter<TInputImage> { if(sizemode!="" || sizevalue!=0.) { - itkWarningMacro("Streaming is explicitly disabled, sizemode and sizevalue will be ignored."); + otbLogMacro(Warning,<<"Streaming is explicitly disabled, sizemode and sizevalue will be ignored."); } this->SetNumberOfDivisionsTiledStreaming(0); } @@ -389,7 +383,7 @@ ImageFileWriter<TInputImage> { if(m_FilenameHelper->StreamingSizeValueIsSet() || m_FilenameHelper->StreamingSizeModeIsSet()) { - itkWarningMacro(<<"No streaming type is set, streaming sizemode and sizevalue will be ignored."); + otbLogMacro(Warning,<<"No streaming type is set, streaming sizemode and sizevalue will be ignored."); } } @@ -418,8 +412,6 @@ ImageFileWriter<TInputImage> if (m_ImageIO.IsNull()) //try creating via factory { - itkDebugMacro(<< "Attempting factory creation of ImageIO for file: " - << m_FileName); this->SetImageIO(ImageIOFactory::CreateImageIO(m_FileName.c_str(), otb::ImageIOFactory::WriteMode)); @@ -429,13 +421,8 @@ ImageFileWriter<TInputImage> { if (!m_ImageIO->CanWriteFile(m_FileName.c_str())) { - itkDebugMacro(<< "ImageIO exists but doesn't know how to write file:" - << m_FileName); - if (m_FactorySpecifiedImageIO) { - itkDebugMacro(<< "Attempting creation of ImageIO with a factory for file:" - << m_FileName); m_ImageIO = ImageIOFactory::CreateImageIO(m_FileName.c_str(), otb::ImageIOFactory::WriteMode); m_FactorySpecifiedImageIO = true; @@ -514,7 +501,7 @@ ImageFileWriter<TInputImage> e.SetDataObject(inputPtr); throw e; } - otbMsgDevMacro(<< "inputRegion " << inputRegion); + otbLogMacro(Info,<<"Writing user defined region ["<<start[0]<<", "<<start[0]+size[0]-1<<"]x["<<start[1]<<", "<<start[1]+size[1]<<"]"); } /** @@ -526,9 +513,8 @@ ImageFileWriter<TInputImage> /** Control if the ImageIO is CanStreamWrite */ if (m_ImageIO->CanStreamWrite() == false) { - otbWarningMacro( - << "The ImageFactory selected for the image file <" << m_FileName.c_str() << - "> does not support streaming."); + otbLogMacro(Warning,<<"The file format of " << m_FileName.c_str() << + " does not support streaming. All data will be loaded to memory"); this->SetNumberOfDivisionsStrippedStreaming(1); } @@ -537,12 +523,14 @@ ImageFileWriter<TInputImage> * Not sure that if this modification is needed */ else if (inputPtr->GetBufferedRegion() == inputRegion) { - otbMsgDevMacro(<< "Buffered region is the largest possible region, there is no need for streaming."); + otbLogMacro(Debug,<< "Buffered region is the largest possible region, there is no need for streaming."); this->SetNumberOfDivisionsStrippedStreaming(1); } m_StreamingManager->PrepareStreaming(inputPtr, inputRegion); m_NumberOfDivisions = m_StreamingManager->GetNumberOfSplits(); - otbMsgDebugMacro(<< "Number Of Stream Divisions : " << m_NumberOfDivisions); + + const auto firstSplitSize = m_StreamingManager->GetSplit(0).GetSize(); + otbLogMacro(Info,<<"File "<<m_FileName<<" will be written in "<<m_NumberOfDivisions<<" blocks of "<<firstSplitSize[0]<<"x"<<firstSplitSize[1]<<" pixels"); /** * Loop over the number of pieces, execute the upstream pipeline on each @@ -612,7 +600,7 @@ ImageFileWriter<TInputImage> } else { - itkWarningMacro(<< "Could not get the source process object. Progress report might be buggy"); + otbLogMacro(Warning,<< "Could not get the source process object. Progress report might be buggy"); } for (m_CurrentDivision = 0; @@ -746,9 +734,6 @@ ImageFileWriter<TInputImage> { if ( m_NumberOfDivisions > 1 || m_UserSpecifiedIORegion) { - itkDebugMacro("Requested stream region does not match generated output"); - itkDebugMacro("input filter may not support streaming well"); - cacheImage = InputImageType::New(); cacheImage->CopyInformation(input); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx index 74e7385133..814695045a 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx @@ -38,8 +38,6 @@ template <class TImageType> TImageType* InputImageParameter::GetImage() { - otbMsgDevMacro(<< "GetImage()"); - // Used m_PreviousFileName because if not, when the user call twice GetImage, // it without changing the filename, it returns 2 different // image pointers -- GitLab From d00cd6c75e2dc36a1679a7d91db26f7bb179bb8c Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 22 Feb 2018 15:28:02 +0100 Subject: [PATCH 402/567] REFAC: Cover all logger modes --- Modules/Core/Common/src/otbConfigurationManager.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/Core/Common/src/otbConfigurationManager.cxx b/Modules/Core/Common/src/otbConfigurationManager.cxx index 4add4e19be..2e2707d0fe 100644 --- a/Modules/Core/Common/src/otbConfigurationManager.cxx +++ b/Modules/Core/Common/src/otbConfigurationManager.cxx @@ -88,6 +88,8 @@ itk::LoggerBase::PriorityLevelType ConfigurationManager::GetLoggerLevel() level_macro(DEBUG); level_macro(WARNING); level_macro(INFO); + level_macro(CRITICAL); + level_macro(FATAL); } return level; } -- GitLab From ea4144046ebe11388344243b61bd202efcd77343 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 22 Feb 2018 15:28:27 +0100 Subject: [PATCH 403/567] DOC: Add proper documentation on the behavior of OTB_LOGGER_LEVEL macro --- .../Common/include/otbConfigurationManager.h | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/otbConfigurationManager.h b/Modules/Core/Common/include/otbConfigurationManager.h index 4ac1dcc372..7b32b3dc72 100644 --- a/Modules/Core/Common/include/otbConfigurationManager.h +++ b/Modules/Core/Common/include/otbConfigurationManager.h @@ -84,7 +84,25 @@ public: */ static RAMValueType GetMaxRAMHint(); - + /** + * Logger level controls the level of logging that OTB will output. + * + * This is used to set-up the otb::Logger class. + * + * If OTB_LOGGER_LEVEL environment variable is set to one of DEBUG, + * INFO, WARNING, CRITICAL or FATAL, the logger level will be + * set accordingly. + * + * Priority is DEBUG < INFO < WARNING < CRITICAL < FATAL. + * + * Only messages with a higher priority than the logger level will + * be displayed. + * + * By default (if OTB_LOGGER_LEVEL is not set or can not be + * decoded), level is DEBUG in Debug or RelWithDebInfo builds, and + * WARNING otherwise. + * + */ static itk::LoggerBase::PriorityLevelType GetLoggerLevel(); -- GitLab From 051bdb4963227c1d5afb4c9431e94a63641d1f62 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 22 Feb 2018 16:36:10 +0100 Subject: [PATCH 404/567] ENH: Replace a few more traces --- .../ApplicationEngine/src/otbWrapperApplication.cxx | 5 ----- .../src/otbWrapperApplicationRegistry.cxx | 10 +--------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 4a7804d527..cc0790f406 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1656,11 +1656,6 @@ Application::IsParameterMissing(const std::string &key) const } level++; } - if (ret) - { - // the missing parameter is on an active branch : we need it - otbDebugMacro("MISSING : "<< key << " (Level "<< split.size()<<")"); - } } return ret; } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx index f022af0ddb..f68d3a3923 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx @@ -211,10 +211,6 @@ ApplicationRegistry::CreateApplication(const std::string& name, bool useFactory) appli = app; appli->Init(); } - else - { - otbMsgDevMacro( << "Error ApplicationRegistry factory did not return an Application: " << possibleApp->GetNameOfClass() << std::endl ); - } } } @@ -350,10 +346,6 @@ ApplicationRegistry::GetAvailableApplications(bool useFactory) std::string curName(app->GetName()); appSet.insert(curName); } - else - { - otbMsgDevMacro( << "Error ApplicationRegistry factory did not return an Application: " << (*i)->GetNameOfClass() << std::endl ); - } } } @@ -438,7 +430,7 @@ ApplicationRegistry::LoadApplicationFromPath(std::string path,std::string name) } else { - otbMsgDevMacro( << "Can't load library : " << path << std::endl ); + otbLogMacro(Warning,<< "Failed to load libraries from " << path << " while trying to create application "<<name ); } } return appli; -- GitLab From 807ae33f042ccd49319a703198b2d078e6bc7b57 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 22 Feb 2018 17:05:10 +0100 Subject: [PATCH 405/567] ENH: More logs cleanup --- .../OSSIMAdapters/src/otbImageKeywordlist.cxx | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx b/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx index 22aef9289e..0294d5f744 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbImageKeywordlist.cxx @@ -255,7 +255,6 @@ ReadGeometryFromImage(const std::string& filename, bool checkRpcTag) ->open(ossimFilename(filename.c_str()))); if (handler) { - otbMsgDevMacro(<< "OSSIM Open Image SUCCESS ! "); // Add ossimPlugins model ossimProjectionFactoryRegistry::instance()->registerFactory(ossimplugins::ossimPluginProjectionFactory::instance()); @@ -271,7 +270,6 @@ ReadGeometryFromImage(const std::string& filename, bool checkRpcTag) // if the handler has found a sensor model, copy the tags found if (hasMetaData && dynamic_cast<ossimSensorModel const*>(projection)) { - otbMsgDevMacro(<<"OSSIM sensor projection instantiated ! "); otb_kwl.SetKeywordlist(geom_kwl); // geom_kwl.print(std::cout); } @@ -315,16 +313,6 @@ ReadGeometryFromImage(const std::string& filename, bool checkRpcTag) // which uses ossimSensorModelFactory and ossimPluginProjectionFactory internally, // thus by-passing the need for a valid ossimImageHandler. - if (!hasMetaData) - { - otbMsgDevMacro(<< "OSSIM MetaData not present ! "); - } - else - { - otbMsgDevMacro(<< "OSSIM MetaData present ! "); - //otbMsgDevMacro(<< geom_kwl); - } - return otb_kwl; } -- GitLab From e1626f784ebfac5914023b2e31d8fd1c74b8c184 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 6 Mar 2018 10:22:22 +0100 Subject: [PATCH 406/567] ENH: More traces clean-up --- .../include/otbStreamingImageVirtualWriter.txx | 9 ++++----- Modules/IO/ImageIO/include/otbImageFileReader.txx | 13 ++++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx index b4fc50fbfa..008b6c0eaa 100644 --- a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx +++ b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx @@ -227,11 +227,11 @@ StreamingImageVirtualWriter<TInputImage> m_ObserverID = source->AddObserver(itk::ProgressEvent(), command); m_IsObserving = true; } - else - { - itkWarningMacro(<< "Could not get the source process object. Progress report might be buggy"); - } + const auto firstSplitSize = m_StreamingManager->GetSplit(0).GetSize(); + otbLogMacro(Info,<<"Estimation will be performed in "<<m_NumberOfDivisions<<" blocks of "<<firstSplitSize[0]<<"x"<<firstSplitSize[1]<<" pixels"); + + /** * Loop over the number of pieces, execute the upstream pipeline on each * piece, and copy the results into the output image. @@ -242,7 +242,6 @@ StreamingImageVirtualWriter<TInputImage> m_CurrentDivision++, m_DivisionProgress = 0, this->UpdateFilterProgress()) { streamRegion = m_StreamingManager->GetSplit(m_CurrentDivision); - otbMsgDevMacro(<< "Processing region : " << streamRegion ) //inputPtr->ReleaseData(); //inputPtr->SetRequestedRegion(streamRegion); //inputPtr->Update(); diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx index 155ce0503d..c8d4fb2d0f 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.txx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx @@ -403,13 +403,13 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> if (m_FilenameHelper->ExtGEOMFileNameIsSet()) { otb_kwl = ReadGeometryFromGEOMFile(m_FilenameHelper->GetExtGEOMFileName()); - otbLogMacro(Info,<< "Loading metadata from external geom file "<< m_FilenameHelper->GetExtGEOMFileName()); + otbLogMacro(Info,<< "Loading kwl metadata from external geom file "<< m_FilenameHelper->GetExtGEOMFileName()); } // Case 2: attached geom (if present) else if (itksys::SystemTools::FileExists(attachedGeom)) { otb_kwl = ReadGeometryFromGEOMFile(attachedGeom); - otbLogMacro(Info,<< "Loading metadata from attached geom file "<<attachedGeom); + otbLogMacro(Info,<< "Loading kwl metadata from attached geom file "<<attachedGeom); } // Case 3: find an ossimPluginProjection // Case 4: find an ossimProjection @@ -417,7 +417,14 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> else { otb_kwl = ReadGeometryFromImage(lFileNameOssimKeywordlist,!m_FilenameHelper->GetSkipRpcTag()); - otbLogMacro(Info,<< "Loading metadata from product files"); + if(!otb_kwl.Empty()) + { + otbLogMacro(Info,<< "Loading kwl metadata from official product in file "<<lFileNameOssimKeywordlist); + } + else + { + otbLogMacro(Info,<< "No kwl metadata found in file "<<lFileNameOssimKeywordlist); + } } // Don't add an empty ossim keyword list -- GitLab From f703e27af548e790991672c5f9d13b6b80717ba7 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 6 Mar 2018 14:58:00 +0100 Subject: [PATCH 407/567] ENH: Revert changes on ApplicationEngine, keep its logging as is --- .../include/otbWrapperApplication.h | 5 +++++ .../src/otbWrapperApplication.cxx | 22 ++++++++++++++++--- .../src/otbWrapperCompositeApplication.cxx | 2 ++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 76ccd9bb5f..c6317be142 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -101,6 +101,7 @@ public: m_Name = name; GetDocExample()->SetApplicationName(name); this->Modified(); + m_Logger->SetName(name); } itkGetStringMacro(Name); @@ -708,6 +709,9 @@ public: otb::Logger* GetLogger() const; + /** Sets the logger instance of the application (use with caution) */ + void SetLogger(otb::Logger *logger); + itk::ProcessObject* GetProgressSource() const; std::string GetProgressDescription() const; @@ -980,6 +984,7 @@ private: std::string m_Name; std::string m_Description; ParameterGroup::Pointer m_ParameterList; + otb::Logger::Pointer m_Logger; itk::ProcessObject::Pointer m_ProgressSource; std::string m_ProgressSourceDescription; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index cc0790f406..cca32d50d3 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -46,7 +46,6 @@ #include <exception> #include "itkMacro.h" - namespace otb { namespace Wrapper @@ -55,6 +54,7 @@ namespace Wrapper Application::Application() : m_Name(""), m_Description(""), + m_Logger(otb::Logger::New()), m_ProgressSourceDescription(""), m_DocName(""), m_DocLongDescription(""), @@ -66,7 +66,10 @@ Application::Application() m_HaveInXML(true), m_HaveOutXML(true), m_IsInXMLParsed(false) -{} +{ + // Don't call Init from the constructor, since it calls a virtual method ! + m_Logger->SetName("Application.logger"); +} Application::~Application() { @@ -74,7 +77,15 @@ Application::~Application() otb::Logger* Application::GetLogger() const { - return otb::Logger::Instance(); + return m_Logger; +} + +void Application::SetLogger(otb::Logger *logger) +{ + if (m_Logger != logger) + { + m_Logger = logger; + } } std::vector<std::string> @@ -1656,6 +1667,11 @@ Application::IsParameterMissing(const std::string &key) const } level++; } + if (ret) + { + // the missing parameter is on an active branch : we need it + otbDebugMacro("MISSING : "<< key << " (Level "<< split.size()<<")"); + } } return ret; } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx index 7ebfa4d59a..db216594f5 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx @@ -62,6 +62,8 @@ CompositeApplication InternalApplication container; container.App = ApplicationRegistry::CreateApplication(appType); container.Desc = desc; + // Setup logger + container.App->SetLogger(this->GetLogger()); container.App->AddObserver(AddProcessToWatchEvent(), m_AddProcessCommand.GetPointer()); m_AppContainer[key] = container; return true; -- GitLab From d4228e21db29a1e9efa9f88a76055946bb3e6e5b Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 6 Mar 2018 14:58:31 +0100 Subject: [PATCH 408/567] ENH: Make std::cout the default output for library logs --- Modules/Core/Common/include/otbLogger.h | 3 +-- Modules/Core/Common/src/otbLogger.cxx | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index 7325a9adcd..5a70bff641 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -45,13 +45,12 @@ public: itkTypeMacro(Logger, itk::Logger); static Pointer Instance(); - + itkNewMacro(Self); // Overwrite this to provide custom formatting of log entries virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; protected: - itkNewMacro(Self); Logger(); virtual ~Logger() ITK_OVERRIDE; diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index 98b099ac57..0ed6b6f790 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -21,6 +21,8 @@ #include "otbLogger.h" #include "itksys/SystemTools.hxx" #include "otbConfigurationManager.h" +#include "itkStdStreamLogOutput.h" +#include <iostream> namespace otb { @@ -30,8 +32,16 @@ Logger::Pointer Logger::Singleton = ITK_NULLPTR; Logger::Pointer Logger::Instance() { if(!Logger::Singleton) + { Logger::Singleton = Logger::New(); + // By default, redirect logs to std::cout + itk::StdStreamLogOutput::Pointer defaultOutput = itk::StdStreamLogOutput::New(); + defaultOutput->SetStream(std::cout); + + Logger::Singleton->AddLogOutput(defaultOutput); + } + return Logger::Singleton; } -- GitLab From 28f957d0066407e75944a323ea7aa2770abe8ffc Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 6 Mar 2018 15:54:58 +0100 Subject: [PATCH 409/567] ENH: Report useful info at logger startup --- Modules/Core/Common/include/otbLogger.h | 2 ++ Modules/Core/Common/src/CMakeLists.txt | 3 +-- Modules/Core/Common/src/otbLogger.cxx | 23 ++++++++++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index 7325a9adcd..f4814d1fd7 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -50,6 +50,8 @@ public: // Overwrite this to provide custom formatting of log entries virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; + void LogSetupInformation(); + protected: itkNewMacro(Self); Logger(); diff --git a/Modules/Core/Common/src/CMakeLists.txt b/Modules/Core/Common/src/CMakeLists.txt index 50e410e9c8..ce5d20761e 100644 --- a/Modules/Core/Common/src/CMakeLists.txt +++ b/Modules/Core/Common/src/CMakeLists.txt @@ -34,8 +34,7 @@ set(OTBCommon_SRC add_library(OTBCommon ${OTBCommon_SRC}) target_link_libraries(OTBCommon - ${OTBITK_LIBRARIES} - + ${OTBITK_LIBRARIES} ${OTBGDAL_LIBRARIES} ) otb_module_target(OTBCommon) diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index 0ed6b6f790..1dd9303f26 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -23,6 +23,8 @@ #include "otbConfigurationManager.h" #include "itkStdStreamLogOutput.h" #include <iostream> +#include "gdal.h" +#include "itkMultiThreader.h" namespace otb { @@ -40,12 +42,14 @@ Logger::Pointer Logger::Instance() defaultOutput->SetStream(std::cout); Logger::Singleton->AddLogOutput(defaultOutput); + + // Log setup information + Logger::Singleton->LogSetupInformation(); } return Logger::Singleton; } - Logger::Logger() { this->SetPriorityLevel(otb::ConfigurationManager::GetLoggerLevel()); @@ -60,6 +64,23 @@ Logger::~Logger() { } +void Logger::LogSetupInformation() +{ + std::ostringstream oss; + + oss<<"Default RAM limit for OTB is "<<otb::ConfigurationManager::GetMaxRAMHint()<<" Mb"<<std::endl; + this->Info(oss.str()); + oss.str(""); + + oss<<"Gdal maximum cache size is "<<GDALGetCacheMax64()/(1024*1024)<<" Mb"<<std::endl; + this->Info(oss.str()); + oss.str(""); + + oss<<"OTB will use at most "<<itk::MultiThreader::GetGlobalDefaultNumberOfThreads()<<" threads"<<std::endl; + this->Info(oss.str()); + oss.str(""); +} + std::string Logger::BuildFormattedEntry(itk::Logger::PriorityLevelType level, std::string const & content) { static const std::string levelString[] = { "(MUSTFLUSH)", "(FATAL)", "(CRITICAL)", -- GitLab From 21576409192f8753a7d8022db25f38728c2ab2be Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 6 Mar 2018 15:58:32 +0100 Subject: [PATCH 410/567] ENH: Revert application logging to its previous state (it has been un-undone by eronous rebase) --- Modules/Core/Common/include/otbLogger.h | 2 +- .../include/otbWrapperApplication.h | 5 +++++ .../src/otbWrapperApplication.cxx | 22 ++++++++++++++++--- .../src/otbWrapperCompositeApplication.cxx | 2 ++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index f4814d1fd7..60ee81ff51 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -46,6 +46,7 @@ public: static Pointer Instance(); + itkNewMacro(Self); // Overwrite this to provide custom formatting of log entries virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; @@ -53,7 +54,6 @@ public: void LogSetupInformation(); protected: - itkNewMacro(Self); Logger(); virtual ~Logger() ITK_OVERRIDE; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 76ccd9bb5f..c6317be142 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -101,6 +101,7 @@ public: m_Name = name; GetDocExample()->SetApplicationName(name); this->Modified(); + m_Logger->SetName(name); } itkGetStringMacro(Name); @@ -708,6 +709,9 @@ public: otb::Logger* GetLogger() const; + /** Sets the logger instance of the application (use with caution) */ + void SetLogger(otb::Logger *logger); + itk::ProcessObject* GetProgressSource() const; std::string GetProgressDescription() const; @@ -980,6 +984,7 @@ private: std::string m_Name; std::string m_Description; ParameterGroup::Pointer m_ParameterList; + otb::Logger::Pointer m_Logger; itk::ProcessObject::Pointer m_ProgressSource; std::string m_ProgressSourceDescription; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index cc0790f406..cca32d50d3 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -46,7 +46,6 @@ #include <exception> #include "itkMacro.h" - namespace otb { namespace Wrapper @@ -55,6 +54,7 @@ namespace Wrapper Application::Application() : m_Name(""), m_Description(""), + m_Logger(otb::Logger::New()), m_ProgressSourceDescription(""), m_DocName(""), m_DocLongDescription(""), @@ -66,7 +66,10 @@ Application::Application() m_HaveInXML(true), m_HaveOutXML(true), m_IsInXMLParsed(false) -{} +{ + // Don't call Init from the constructor, since it calls a virtual method ! + m_Logger->SetName("Application.logger"); +} Application::~Application() { @@ -74,7 +77,15 @@ Application::~Application() otb::Logger* Application::GetLogger() const { - return otb::Logger::Instance(); + return m_Logger; +} + +void Application::SetLogger(otb::Logger *logger) +{ + if (m_Logger != logger) + { + m_Logger = logger; + } } std::vector<std::string> @@ -1656,6 +1667,11 @@ Application::IsParameterMissing(const std::string &key) const } level++; } + if (ret) + { + // the missing parameter is on an active branch : we need it + otbDebugMacro("MISSING : "<< key << " (Level "<< split.size()<<")"); + } } return ret; } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx index 7ebfa4d59a..db216594f5 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx @@ -62,6 +62,8 @@ CompositeApplication InternalApplication container; container.App = ApplicationRegistry::CreateApplication(appType); container.Desc = desc; + // Setup logger + container.App->SetLogger(this->GetLogger()); container.App->AddObserver(AddProcessToWatchEvent(), m_AddProcessCommand.GetPointer()); m_AppContainer[key] = container; return true; -- GitLab From 5999f15ca27f7f4dd5be78da6def445615e131d1 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 6 Mar 2018 16:21:30 +0100 Subject: [PATCH 411/567] ENH: Change level of old otbMsgDevMacro from Info to Debug --- Modules/Core/Common/include/otbMacro.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/otbMacro.h b/Modules/Core/Common/include/otbMacro.h index 4ffd8eed9b..5dcca1bab9 100644 --- a/Modules/Core/Common/include/otbMacro.h +++ b/Modules/Core/Common/include/otbMacro.h @@ -61,7 +61,7 @@ namespace otb #define otbDebugMacro(x) otbLogMacro(Debug,otbFileContext(otbClassContext(x))) #define otbMsgDebugMacro(x) otbLogMacro(Debug,otbFileContext(x)) #define otbGenericMsgDebugMacro(x) otbLogMacro(Debug,x) -#define otbMsgDevMacro(x) otbLogMacro(Info,otbFileContext(x)) +#define otbMsgDevMacro(x) otbLogMacro(Debug,otbFileContext(x)) #define otbWarningMacro(x) otbLogMacro(Warning,otbFileContext(otbClassContext(x))) #define otbGenericWarningMacro(x) otbLogMacro(Warning,otbFileContext(x)) -- GitLab From 40e7f2a400de2eca5ce1c75022c7cf0cf76c57ae Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 6 Mar 2018 17:19:57 +0100 Subject: [PATCH 412/567] WRG: Fix a bunch of clang warnings, mostly missing override --- .../AppClassification/app/otbTrainImagesClassifier.cxx | 2 +- Modules/Core/ObjectList/include/otbImageList.h | 2 +- .../MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h | 4 ++-- .../OssimPlugins/include/ossim/ossimSarSensorModel.h | 4 ++-- .../ApplicationEngine/include/otbWrapperParameterList.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx index a76f81dce7..f26b4b32d4 100644 --- a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx @@ -157,7 +157,7 @@ public: } - void DoExecute() + void DoExecute() ITK_OVERRIDE { TrainFileNamesHandler fileNames; std::vector<std::string> vectorFileList; diff --git a/Modules/Core/ObjectList/include/otbImageList.h b/Modules/Core/ObjectList/include/otbImageList.h index 4cb77bddec..fc836cb047 100644 --- a/Modules/Core/ObjectList/include/otbImageList.h +++ b/Modules/Core/ObjectList/include/otbImageList.h @@ -68,7 +68,7 @@ public: throw (itk::InvalidRequestedRegionError) ITK_OVERRIDE; void UpdateOutputData(void) ITK_OVERRIDE; - void SetRequestedRegion(const itk::DataObject * source); + void SetRequestedRegion(const itk::DataObject * source) ITK_OVERRIDE; protected: /** Constructor */ diff --git a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h index c404d25d50..64e574384a 100644 --- a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h +++ b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h @@ -214,7 +214,7 @@ public: const InputImageType* GetInput(); /** Does the real work. */ - virtual void Update(); + virtual void Update() ITK_OVERRIDE; /** SimpleParallelTiffWriter Methods */ virtual void SetFileName(const char* extendedFileName); @@ -255,7 +255,7 @@ public: protected: SimpleParallelTiffWriter(); virtual ~SimpleParallelTiffWriter(); - void PrintSelf(std::ostream& os, itk::Indent indent) const; + void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; private: SimpleParallelTiffWriter(const SimpleParallelTiffWriter &); //purposely not implemented diff --git a/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h b/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h index 542b29e6f8..c1d0cb7761 100644 --- a/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h +++ b/Modules/ThirdParty/OssimPlugins/include/ossim/ossimSarSensorModel.h @@ -276,7 +276,7 @@ public: bool autovalidateForwardModelFromGCPs(double resTol = 25); //Pure virtual in base class - bool useForward() const; + bool useForward() const override; void optimizeTimeOffsetsFromGcps(); @@ -336,7 +336,7 @@ public: virtual std::ostream& print(std::ostream& out) const override; protected: - TYPE_DATA; + TYPE_DATA /** * Compute range and doppler frequency from an input point, sensor diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.h index 2c9c699fbe..e54590e42f 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.h @@ -91,7 +91,7 @@ public: void SetNthFileName( std::size_t, const std::string & ) override; /** */ - std::size_t SetStrings( const StringVector & ); + std::size_t SetStrings( const StringVector & ) override; /** */ std::size_t GetStrings( StringVector & ) const override; -- GitLab From 4e9eebdaadecbc2eb9ba1a81a979d7a0c6e479b8 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 7 Mar 2018 08:15:38 +0100 Subject: [PATCH 413/567] STY: Remove cmake debug trace --- Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 9107d2961e..858aaaf1af 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -58,8 +58,6 @@ set( OTBApplicationEngine_SRC otbWrapperParameterList.cxx ) -message("Common libraries: ${OTBCommon_LIBRARIES}") - add_library(OTBApplicationEngine ${OTBApplicationEngine_SRC}) target_link_libraries(OTBApplicationEngine ${OTBVectorDataBase_LIBRARIES} -- GitLab From 4010f7013141a43de61204d460fe4b7d604f530f Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 7 Mar 2018 08:16:42 +0100 Subject: [PATCH 414/567] DOC: Add correct group in doxygen --- Modules/Core/Common/include/otbLogger.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index 60ee81ff51..21aff6e14b 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -32,7 +32,7 @@ namespace otb { * * Sets OTB wide settings in its constructor * - * \ingroup OTBApplicationEngine + * \ingroup OTBCommon */ class OTBCommon_EXPORT Logger : public itk::Logger { -- GitLab From 0769470e0f6a079ff826c82d96d55e6fa9284494 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 7 Mar 2018 08:13:33 +0100 Subject: [PATCH 415/567] WRG: Fix more missing override warnings --- .../app/otbMultiImageSamplingRate.cxx | 6 +++--- .../AppClassification/app/otbSampleExtraction.cxx | 6 +++--- .../AppClassification/app/otbSampleSelection.cxx | 6 +++--- .../AppClassification/app/otbTrainVectorClassifier.cxx | 6 +++--- .../app/otbTrainDimensionalityReduction.cxx | 6 +++--- .../AppSARUtils/app/otbComputeModulusAndPhase.cxx | 6 +++--- .../Filtering/Wavelet/include/otbWaveletImageFilter.h | 6 +++--- .../Wavelet/include/otbWaveletInverseImageFilter.h | 8 ++++---- ...otbWaveletsBandsListToWaveletsSynopsisImageFilter.h | 8 ++++---- ...otbWaveletsSynopsisImageToWaveletsBandsListFilter.h | 10 +++++----- .../include/otbAutoencoderModel.h | 8 ++++---- .../include/otbImageDimensionalityReductionFilter.h | 2 +- .../include/otbPCAModel.h | 6 +++--- .../include/otbSOMModel.h | 10 +++++----- .../otbSharkRandomForestsMachineLearningModel.h | 2 +- .../otbSharkRandomForestsMachineLearningModelFactory.h | 4 ++-- .../include/otbSharkKMeansMachineLearningModel.h | 2 +- .../otbSharkKMeansMachineLearningModelFactory.h | 4 ++-- .../Simulation/include/otbProSailParameters.h | 2 +- Modules/Wrappers/SWIG/src/python/itkPyCommand.h | 4 ++-- 20 files changed, 56 insertions(+), 56 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx index 889e909cc5..cf142f76f6 100644 --- a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx +++ b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx @@ -57,7 +57,7 @@ private: m_CalculatorList = RateCalculatorListType::New(); } - void DoInit() + void DoInit() ITK_OVERRIDE { SetName("MultiImageSamplingRate"); SetDescription("Compute sampling rate for an input set of images."); @@ -186,11 +186,11 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() + void DoUpdateParameters() ITK_OVERRIDE { } - void DoExecute() + void DoExecute() ITK_OVERRIDE { // Clear state m_CalculatorList->Clear(); diff --git a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx index a9c2b07fbd..63615e03cc 100644 --- a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx @@ -53,7 +53,7 @@ public: private: SampleExtraction() {} - void DoInit() + void DoInit() ITK_OVERRIDE { SetName("SampleExtraction"); SetDescription("Extracts samples values from an image."); @@ -119,7 +119,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() + void DoUpdateParameters() ITK_OVERRIDE { if ( HasValue("vec") ) { @@ -149,7 +149,7 @@ private: } } - void DoExecute() + void DoExecute() ITK_OVERRIDE { ogr::DataSource::Pointer vectors; ogr::DataSource::Pointer output; diff --git a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx index b41f20470f..8faee83496 100644 --- a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx @@ -80,7 +80,7 @@ private: m_RateCalculator = RateCalculatorType::New(); } - void DoInit() + void DoInit() ITK_OVERRIDE { SetName("SampleSelection"); SetDescription("Selects samples from a training vector data set."); @@ -227,7 +227,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() + void DoUpdateParameters() ITK_OVERRIDE { if ( HasValue("vec") ) { @@ -257,7 +257,7 @@ private: } } - void DoExecute() + void DoExecute() ITK_OVERRIDE { // Clear state m_RateCalculator->ClearRates(); diff --git a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx index f37eb3020f..9de1efb8b1 100644 --- a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx @@ -54,7 +54,7 @@ public: typedef ContingencyTableType::Pointer ContingencyTablePointerType; protected: - void DoInit() + void DoInit() ITK_OVERRIDE { SetName( "TrainVectorClassifier" ); SetDescription( "Train a classifier based on labeled geometries and a " @@ -73,12 +73,12 @@ protected: Superclass::DoInit(); } - void DoUpdateParameters() + void DoUpdateParameters() ITK_OVERRIDE { Superclass::DoUpdateParameters(); } - void DoExecute() + void DoExecute() ITK_OVERRIDE { m_FeaturesInfo.SetClassFieldNames( GetChoiceNames( "cfield" ), GetSelectedItems( "cfield" ) ); diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx index 1cbc567c56..8d52132dec 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx @@ -68,7 +68,7 @@ public: typedef otb::DimensionalityReductionModelFactory<ValueType, ValueType> ModelFactoryType; private: - void DoInit() + void DoInit() ITK_OVERRIDE { SetName("TrainDimensionalityReduction"); SetDescription("Train a dimensionality reduction model"); @@ -115,11 +115,11 @@ private: " value_5 value_6 value_7 value_8 value_9"); } - void DoUpdateParameters() + void DoUpdateParameters() ITK_OVERRIDE { } - void DoExecute() + void DoExecute() ITK_OVERRIDE { std::string shapefile = GetParameterString("io.vd"); diff --git a/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx b/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx index ec91b7e53b..6c949a2b9d 100644 --- a/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx +++ b/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx @@ -57,7 +57,7 @@ public: typedef itk::ComplexToPhaseImageFilter<ComplexFloatImageType, FloatImageType> PhaseFilterType; private: - void DoInit() + void DoInit() ITK_OVERRIDE { SetName("ComputeModulusAndPhase"); SetDescription("This application computes the modulus and the phase of a complex SAR image."); @@ -100,12 +100,12 @@ private: } // DoUpdateParameters() is called as soon as a parameter value change. - void DoUpdateParameters() + void DoUpdateParameters() ITK_OVERRIDE { } // DoExecute() contains the application core. - void DoExecute() + void DoExecute() ITK_OVERRIDE { m_Modulus = ModulusFilterType::New(); m_Phase = PhaseFilterType::New(); diff --git a/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.h index d1022824dd..1d4f15234a 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.h @@ -92,11 +92,11 @@ protected: WaveletImageFilter(); virtual ~WaveletImageFilter(); - virtual void GenerateInputRequestedRegion(); + virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; - virtual void GenerateData(); + virtual void GenerateData() ITK_OVERRIDE; - virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; private: WaveletImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.h index 52030d8444..1b28666526 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.h @@ -87,17 +87,17 @@ public: itkSetMacro(NumberOfDecompositions,unsigned int); /** If the filter is modified, the internal filters need to be modified too */ - virtual void Modified() const; + virtual void Modified() const ITK_OVERRIDE; protected: WaveletInverseImageFilter(); virtual ~WaveletInverseImageFilter(); - virtual void GenerateInputRequestedRegion(); + virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; - virtual void GenerateData(); + virtual void GenerateData() ITK_OVERRIDE; - virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; private: WaveletInverseImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h index 2c3225cf24..ea26fe6226 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h @@ -68,19 +68,19 @@ public: protected: /** Main computation method */ - virtual void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId); + virtual void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; /** GenerateOutputInformation * Set the number of bands of the output. * Copy information from the first image of the list if existing. **/ - virtual void GenerateOutputInformation(void); + virtual void GenerateOutputInformation(void) ITK_OVERRIDE; /** * GenerateInputRequestedRegion * Set the requested region of each image in the list. */ - virtual void GenerateInputRequestedRegion(void); + virtual void GenerateInputRequestedRegion(void) ITK_OVERRIDE; /** Constructor */ WaveletsBandsListToWaveletsSynopsisImageFilter(); @@ -89,7 +89,7 @@ protected: virtual ~WaveletsBandsListToWaveletsSynopsisImageFilter(); /**PrintSelf method */ - virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; private: WaveletsBandsListToWaveletsSynopsisImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.h index 5714fc1cab..a19c09bacb 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.h @@ -80,7 +80,7 @@ public: itkGetMacro(DecimationRatio,unsigned int); /** If the filter is modified, the extract list need to be regenerated */ - virtual void Modified() const; + virtual void Modified() const ITK_OVERRIDE; protected: /** Constructor */ @@ -90,16 +90,16 @@ protected: virtual ~WaveletsSynopsisImageToWaveletsBandsListFilter(); /**PrintSelf method */ - virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; /** Generate the input requested region from the first element in the list. */ - virtual void GenerateInputRequestedRegion(void); + virtual void GenerateInputRequestedRegion(void) ITK_OVERRIDE; /** Generate the output information by building the output list. */ - virtual void GenerateOutputInformation(void); + virtual void GenerateOutputInformation(void) ITK_OVERRIDE; /** Main computation method */ - virtual void GenerateData(void); + virtual void GenerateData(void) ITK_OVERRIDE; private: WaveletsSynopsisImageToWaveletsBandsListFilter(const Self&); //purposely not implemented diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h index 14205f0cd8..ee58a9428b 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h @@ -119,8 +119,8 @@ public: itkGetMacro(LearningCurveFileName,std::string); itkSetMacro(LearningCurveFileName,std::string); - bool CanReadFile(const std::string & filename); - bool CanWriteFile(const std::string & filename); + bool CanReadFile(const std::string & filename) ITK_OVERRIDE; + bool CanWriteFile(const std::string & filename) ITK_OVERRIDE; void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; @@ -155,14 +155,14 @@ protected: virtual TargetSampleType DoPredict( const InputSampleType& input, - ConfidenceValueType * quality = ITK_NULLPTR) const; + ConfidenceValueType * quality = ITK_NULLPTR) const ITK_OVERRIDE; virtual void DoPredictBatch( const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, - ConfidenceListSampleType * quality = ITK_NULLPTR) const; + ConfidenceListSampleType * quality = ITK_NULLPTR) const ITK_OVERRIDE; private: /** Internal Network */ diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h index d5538c1700..e3fdf5d8f5 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h @@ -115,7 +115,7 @@ protected: ~ImageDimensionalityReductionFilter() ITK_OVERRIDE {} /** Generate output information */ - virtual void GenerateOutputInformation(); + virtual void GenerateOutputInformation() ITK_OVERRIDE; /** Threaded generate data */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h index dd8f7a6992..064ca263da 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h @@ -80,8 +80,8 @@ public: itkSetMacro(WriteEigenvectors, bool); itkGetMacro(WriteEigenvectors, bool); - bool CanReadFile(const std::string & filename); - bool CanWriteFile(const std::string & filename); + bool CanReadFile(const std::string & filename) ITK_OVERRIDE; + bool CanWriteFile(const std::string & filename) ITK_OVERRIDE; void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; @@ -94,7 +94,7 @@ protected: virtual TargetSampleType DoPredict( const InputSampleType& input, - ConfidenceValueType * quality = ITK_NULLPTR) const; + ConfidenceValueType * quality = ITK_NULLPTR) const ITK_OVERRIDE; virtual void DoPredictBatch( const InputListSampleType *, diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h index 7f6fb2b08e..5aa7130a6a 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h @@ -101,11 +101,11 @@ public: itkSetMacro(Seed, unsigned int); itkGetMacro(Seed, unsigned int); - bool CanReadFile(const std::string & filename); - bool CanWriteFile(const std::string & filename); + bool CanReadFile(const std::string & filename) ITK_OVERRIDE; + bool CanWriteFile(const std::string & filename) ITK_OVERRIDE; - void Save(const std::string & filename, const std::string & name="") ; - void Load(const std::string & filename, const std::string & name="") ; + void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; void Train() ITK_OVERRIDE; @@ -118,7 +118,7 @@ private: virtual TargetSampleType DoPredict( const InputSampleType& input, - ConfidenceValueType * quality = ITK_NULLPTR) const; + ConfidenceValueType * quality = ITK_NULLPTR) const ITK_OVERRIDE; /** Map size (width, height) */ SizeType m_MapSize; diff --git a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h index 8d2c0c8123..162aa10255 100644 --- a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h @@ -148,7 +148,7 @@ protected: virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const ITK_OVERRIDE; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const; + void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; private: SharkRandomForestsMachineLearningModel(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModelFactory.h b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModelFactory.h index 313d9db9a1..7361ee38cc 100644 --- a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModelFactory.h +++ b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModelFactory.h @@ -42,8 +42,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - virtual const char* GetITKSourceVersion(void) const; - virtual const char* GetDescription(void) const; + virtual const char* GetITKSourceVersion(void) const ITK_OVERRIDE; + virtual const char* GetDescription(void) const ITK_OVERRIDE; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); diff --git a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.h b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.h index ef74d52f40..a479248e1e 100644 --- a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.h +++ b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.h @@ -140,7 +140,7 @@ protected: DataType NormalizeData(const DataType &data) const; /** PrintSelf method */ - void PrintSelf(std::ostream &os, itk::Indent indent) const; + void PrintSelf(std::ostream &os, itk::Indent indent) const ITK_OVERRIDE; private: SharkKMeansMachineLearningModel(const Self &); //purposely not implemented diff --git a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModelFactory.h b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModelFactory.h index a072d5d719..3c9ed55da1 100644 --- a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModelFactory.h +++ b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModelFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - virtual const char* GetITKSourceVersion(void) const; - virtual const char* GetDescription(void) const; + virtual const char* GetITKSourceVersion(void) const ITK_OVERRIDE; + virtual const char* GetDescription(void) const ITK_OVERRIDE; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); diff --git a/Modules/Radiometry/Simulation/include/otbProSailParameters.h b/Modules/Radiometry/Simulation/include/otbProSailParameters.h index ea021d2811..c2264c104c 100644 --- a/Modules/Radiometry/Simulation/include/otbProSailParameters.h +++ b/Modules/Radiometry/Simulation/include/otbProSailParameters.h @@ -115,7 +115,7 @@ class ITK_EXPORT ProSailParameters : public itk::DataObject /** Destructor */ virtual ~ProSailParameters() {}; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const; + void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; private: diff --git a/Modules/Wrappers/SWIG/src/python/itkPyCommand.h b/Modules/Wrappers/SWIG/src/python/itkPyCommand.h index d65c4eea7b..f7f28333ea 100644 --- a/Modules/Wrappers/SWIG/src/python/itkPyCommand.h +++ b/Modules/Wrappers/SWIG/src/python/itkPyCommand.h @@ -70,8 +70,8 @@ public: PyObject * GetCommandCallable(); - void Execute(Object *, const EventObject&); - void Execute(const Object *, const EventObject&); + void Execute(Object *, const EventObject&) ITK_OVERRIDE; + void Execute(const Object *, const EventObject&) ITK_OVERRIDE; protected: PyCommand(); -- GitLab From 64081fba53f9752881d9fbb25fe4dfbbf709ae75 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 7 Mar 2018 15:18:35 +0100 Subject: [PATCH 416/567] REFAC: compatibility of Autoencoders with recent changes in Shark --- .../include/otbAutoencoderModel.h | 21 +- .../include/otbAutoencoderModel.txx | 202 ++++++++---------- .../include/otbPCAModel.txx | 4 +- 3 files changed, 104 insertions(+), 123 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h index 14205f0cd8..3a3f1223be 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h @@ -33,8 +33,9 @@ #endif #include "otb_shark.h" #include <shark/Algorithms/StoppingCriteria/AbstractStoppingCriterion.h> -#include <shark/Models/FFNet.h> -#include <shark/Models/Autoencoder.h> +#include <shark/Models/LinearModel.h> +#include <shark/Models/ConcatenatedModel.h> +#include <shark/Models/NeuronLayers.h> #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif @@ -76,9 +77,9 @@ public: typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; /// Neural network related typedefs - typedef shark::Autoencoder<NeuronType,shark::LinearNeuron> OutAutoencoderType; - typedef shark::Autoencoder<NeuronType,NeuronType> AutoencoderType; - typedef shark::FFNet<NeuronType,shark::LinearNeuron> NetworkType; + typedef shark::ConcatenatedModel<shark::RealVector> ModelType; + typedef shark::LinearModel<shark::RealVector,NeuronType> LayerType; + typedef shark::LinearModel<shark::RealVector, shark::LinearNeuron> OutLayerType; itkNewMacro(Self); itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); @@ -127,18 +128,16 @@ public: void Train() ITK_OVERRIDE; - template <class T, class Autoencoder> + template <class T> void TrainOneLayer( shark::AbstractStoppingCriterion<T> & criterion, - Autoencoder &, unsigned int, shark::Data<shark::RealVector> &, std::ostream&); - template <class T, class Autoencoder> + template <class T> void TrainOneSparseLayer( shark::AbstractStoppingCriterion<T> & criterion, - Autoencoder &, unsigned int, shark::Data<shark::RealVector> &, std::ostream&); @@ -166,7 +165,9 @@ protected: private: /** Internal Network */ - NetworkType m_Net; + ModelType m_Encoder; + std::vector<LayerType> m_InLayers; + OutLayerType m_OutLayer; itk::Array<unsigned int> m_NumberOfHiddenNeurons; /** Training parameters */ unsigned int m_NumberOfIterations; // stop the training after a fixed number of iterations diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index 33f1c28e24..254143a501 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -34,13 +34,12 @@ #include "otbSharkUtils.h" //include train function #include <shark/ObjectiveFunctions/ErrorFunction.h> -#include <shark/ObjectiveFunctions/SparseAutoencoderError.h>//the error function performing the regularisation of the hidden neurons +//~ #include <shark/ObjectiveFunctions/SparseAutoencoderError.h>//the error function performing the regularisation of the hidden neurons #include <shark/Algorithms/GradientDescent/Rprop.h>// the RProp optimization algorithm #include <shark/ObjectiveFunctions/Loss/SquaredLoss.h> // squared loss used for regression #include <shark/ObjectiveFunctions/Regularizer.h> //L2 regulariziation -#include <shark/Models/ImpulseNoiseModel.h> //noise source to corrupt the inputs -#include <shark/Models/ConcatenatedModel.h>//to concatenate the noise with the model +//~ #include <shark/Models/ImpulseNoiseModel.h> //noise source to corrupt the inputs #include <shark/Algorithms/StoppingCriteria/MaxIterations.h> //A simple stopping criterion that stops after a fixed number of iterations #include <shark/Algorithms/StoppingCriteria/TrainingProgress.h> //Stops when the algorithm seems to converge, Tracks the progress of the training error over a period of time @@ -83,96 +82,56 @@ AutoencoderModel<TInputValue,NeuronType> } // Initialization of the feed forward neural network - std::vector<size_t> layers; - layers.push_back(shark::dataDimension(inputSamples)); + m_Encoder = ModelType(); + m_InLayers.clear(); + size_t previousShape = shark::dataDimension(inputSamples); for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) { - layers.push_back(m_NumberOfHiddenNeurons[i]); + m_InLayers.push_back( LayerType(previousShape, m_NumberOfHiddenNeurons[i]) ); + previousShape = m_NumberOfHiddenNeurons[i]; + m_Encoder.add(&(m_InLayers.back()), true); } - for (unsigned int i = std::max(0,static_cast<int>(m_NumberOfHiddenNeurons.Size()-1)) ; i > 0; --i) { - layers.push_back(m_NumberOfHiddenNeurons[i-1]); - } - - layers.push_back(shark::dataDimension(inputSamples)); - m_Net.setStructure(layers); - shark::initRandomNormal(m_Net,0.1); - - // Training of the first Autoencoder (first and last layer of the FF network) - if (m_Epsilon > 0) - { - shark::TrainingProgress<> criterion(5,m_Epsilon); - - OutAutoencoderType net; - // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. - if (m_Noise[0] != 0) - { - TrainOneLayer(criterion, net, 0, inputSamples, ofs); - } - else - { - TrainOneSparseLayer(criterion, net, 0, inputSamples, ofs); - } - criterion.reset(); + m_InLayers.push_back( LayerType(previousShape, m_NumberOfHiddenNeurons[i-1]) ); + previousShape = m_NumberOfHiddenNeurons[i-1]; } - else - { - shark::MaxIterations<> criterion(m_NumberOfIterations); + m_OutLayer = OutLayerType(previousShape, shark::dataDimension(inputSamples)); - OutAutoencoderType net; - // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. - if (m_Noise[0] != 0) - { - TrainOneLayer(criterion, net, 0, inputSamples, ofs); - otbMsgDevMacro(<< "m_Noise " << m_Noise[0]); - } - else - { - TrainOneSparseLayer(criterion, net, 0, inputSamples, ofs); - } - criterion.reset(); - } - - // Training of the other autoencoders - if (m_Epsilon > 0) + // Training of the autoencoders pairwise, starting from the first and last layers + for (unsigned int i = 0 ; i < m_NumberOfHiddenNeurons.Size(); ++i) { - shark::TrainingProgress<> criterion(5,m_Epsilon); - - for (unsigned int i = 1 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + if (m_Epsilon > 0) { - AutoencoderType net; + shark::TrainingProgress<> criterion(5,m_Epsilon); // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. if (m_Noise[i] != 0) { - TrainOneLayer(criterion, net, i, inputSamples, ofs); + TrainOneLayer(criterion, i, inputSamples, ofs); } else { - TrainOneSparseLayer(criterion, net, i, inputSamples, ofs); + TrainOneSparseLayer(criterion, i, inputSamples, ofs); } criterion.reset(); } - } - else - { - shark::MaxIterations<> criterion(m_NumberOfIterations); - - for (unsigned int i = 1 ; i < m_NumberOfHiddenNeurons.Size(); ++i) + else { - AutoencoderType net; + shark::MaxIterations<> criterion(m_NumberOfIterations); // Shark doesn't allow to train a layer using a sparsity term AND a noisy input. if (m_Noise[i] != 0) { - TrainOneLayer(criterion, net, i, inputSamples, ofs); + TrainOneLayer(criterion, i, inputSamples, ofs); otbMsgDevMacro(<< "m_Noise " << m_Noise[0]); } else { - TrainOneSparseLayer( criterion, net, i, inputSamples, ofs); + TrainOneSparseLayer( criterion, i, inputSamples, ofs); } criterion.reset(); } + // encode the samples with the last encoder trained + inputSamples = m_InLayers[i](inputSamples); } if (m_NumberOfIterationsFineTuning > 0) { @@ -183,26 +142,32 @@ AutoencoderModel<TInputValue,NeuronType> } template <class TInputValue, class NeuronType> -template <class T, class Autoencoder> +template <class T> void AutoencoderModel<TInputValue,NeuronType> ::TrainOneLayer( shark::AbstractStoppingCriterion<T> & criterion, - Autoencoder & net, unsigned int layer_index, shark::Data<shark::RealVector> &samples, std::ostream& File) { + typedef shark::AbstractModel<shark::RealVector,shark::RealVector> BaseModelType; + ModelType net; + net.add(&(m_InLayers[layer_index]), true); + net.add( (layer_index ? + (BaseModelType*) &(m_InLayers[m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index]) : + (BaseModelType*) &m_OutLayer) , true); + otbMsgDevMacro(<< "Noise " << m_Noise[layer_index]); std::size_t inputs = dataDimension(samples); - net.setStructure(inputs, m_NumberOfHiddenNeurons[layer_index]); initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); - shark::ImpulseNoiseModel noise(inputs,m_Noise[layer_index],1.0); //set an input pixel with probability m_Noise to 0 - shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; + //~ shark::ImpulseNoiseModel noise(inputs,m_Noise[layer_index],1.0); //set an input pixel with probability m_Noise to 0 + //~ shark::ConcatenatedModel<shark::RealVector,shark::RealVector> model = noise>> net; shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; - shark::ErrorFunction error(trainSet, &model, &loss); + //~ shark::ErrorFunction error(trainSet, &model, &loss); + shark::ErrorFunction error(trainSet, &net, &loss); shark::TwoNormRegularizer regularizer(error.numberOfVariables()); error.setRegularizer(m_Regularization[layer_index],®ularizer); @@ -230,32 +195,34 @@ AutoencoderModel<TInputValue,NeuronType> } while( !criterion.stop( optimizer.solution() ) ); net.setParameterVector(optimizer.solution().point); - m_Net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); // Copy the encoder in the FF neural network - m_Net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); // Copy the decoder in the FF neural network - samples = net.encode(samples); } template <class TInputValue, class NeuronType> -template <class T, class Autoencoder> +template <class T> void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer( shark::AbstractStoppingCriterion<T> & criterion, - Autoencoder & net, unsigned int layer_index, shark::Data<shark::RealVector> &samples, std::ostream& File) { - //AutoencoderType net; - std::size_t inputs = dataDimension(samples); - net.setStructure(inputs, m_NumberOfHiddenNeurons[layer_index]); + typedef shark::AbstractModel<shark::RealVector,shark::RealVector> BaseModelType; + ModelType net; + net.add(&(m_InLayers[layer_index]), true); + net.add( (layer_index ? + (BaseModelType*) &(m_InLayers[m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index]) : + (BaseModelType*) &m_OutLayer) , true); + std::size_t inputs = dataDimension(samples); shark::initRandomUniform(net,-m_InitFactor*std::sqrt(1.0/inputs),m_InitFactor*std::sqrt(1.0/inputs)); // Idea : set the initials value for the output weights higher than the input weights shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; - shark::SparseAutoencoderError error(trainSet,&net, &loss, m_Rho[layer_index], m_Beta[layer_index]); - + //~ shark::SparseAutoencoderError error(trainSet,&net, &loss, m_Rho[layer_index], m_Beta[layer_index]); + // SparseAutoencoderError doesn't exist anymore, for now use a plain ErrorFunction + shark::ErrorFunction error(trainSet, &net, &loss); + shark::TwoNormRegularizer regularizer(error.numberOfVariables()); error.setRegularizer(m_Regularization[layer_index],®ularizer); shark::IRpropPlusFull optimizer; @@ -279,9 +246,6 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer( File << "end layer" << std::endl; } net.setParameterVector(optimizer.solution().point); - m_Net.setLayer(layer_index,net.encoderMatrix(),net.hiddenBias()); // Copy the encoder in the FF neural network - m_Net.setLayer( m_NumberOfHiddenNeurons.Size()*2 - 1 - layer_index,net.decoderMatrix(),net.outputBias()); // Copy the decoder in the FF neural network - samples = net.encode(samples); } template <class TInputValue, class NeuronType> @@ -293,11 +257,19 @@ AutoencoderModel<TInputValue,NeuronType> shark::Data<shark::RealVector> &samples, std::ostream& File) { + // create full network + ModelType net; + for (auto &layer : m_InLayers) + { + net.add(&layer, true); + } + net.add(&m_OutLayer, true); + //labels identical to inputs shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples); shark::SquaredLoss<shark::RealVector> loss; - shark::ErrorFunction error(trainSet, &m_Net, &loss); + shark::ErrorFunction error(trainSet, &net, &loss); shark::TwoNormRegularizer regularizer(error.numberOfVariables()); error.setRegularizer(m_Regularization[0],®ularizer); @@ -326,7 +298,6 @@ AutoencoderModel<TInputValue,NeuronType> try { this->Load(filename); - m_Net.name(); } catch(...) { @@ -350,22 +321,15 @@ AutoencoderModel<TInputValue,NeuronType> { otbMsgDevMacro(<< "saving model ..."); std::ofstream ofs(filename); - ofs << m_Net.name() << std::endl; // the first line of the model file contains a key + ofs << "Autoencoder" << std::endl; // the first line of the model file contains a key + ofs << (m_InLayers.size() + 1) << std::endl; // second line is the number of encoders/decoders shark::TextOutArchive oa(ofs); - oa << m_Net; - ofs.close(); - - if (this->m_WriteWeights == true) // output the map vectors in a txt file + for (const auto &layer : m_InLayers) { - std::ofstream otxt(filename+".txt"); - for (unsigned int i = 0 ; i < m_Net.layerMatrices().size(); ++i) - { - otxt << "layer " << i << std::endl; - otxt << m_Net.layerMatrix(i) << std::endl; - otxt << m_Net.bias(i) << std::endl; - otxt << std::endl; - } + oa << layer; } + oa << m_OutLayer; + ofs.close(); } template <class TInputValue, class NeuronType> @@ -373,23 +337,39 @@ void AutoencoderModel<TInputValue,NeuronType> ::Load(const std::string & filename, const std::string & /*name*/) { - NetworkType net; std::ifstream ifs(filename); - char autoencoder[256]; - ifs.getline(autoencoder,256); - std::string autoencoderstr(autoencoder); - - if (autoencoderstr != net.name()){ + char buffer[256]; + // check first line + ifs.getline(buffer,256); + std::string bufferStr(buffer); + if (bufferStr != "Autoencoder"){ itkExceptionMacro(<< "Error opening " << filename.c_str() ); } + // check second line + ifs.getline(buffer,256); + int nbLevels = boost::lexical_cast<int>(buffer); + if (nbLevels < 2 || nbLevels%2 == 1) + { + itkExceptionMacro(<< "Unexpected number of levels : "<<buffer ); + } + m_InLayers.clear(); + m_Encoder = ModelType(); shark::TextInArchive ia(ifs); - ia >> m_Net; + for (int i=0 ; (i+1) < nbLevels ; i++) + { + LayerType layer; + ia >> layer; + m_InLayers.push_back(layer); + } + ia >> m_OutLayer; ifs.close(); - // This gives us the dimension if we keep the encoder and decoder - size_t feature_layer_index = m_Net.layerMatrices().size()/2; - // number of neurons in the feature layer (second dimension of the first decoder weight matrix) - this->SetDimension(m_Net.layerMatrix(feature_layer_index).size2()); + for (int i=0 ; i < nbLevels/2 ; i++) + { + m_Encoder.add(&(m_InLayers[i]) ,true); + } + + this->SetDimension( m_Encoder.outputShape()[0] ); } template <class TInputValue, class NeuronType> @@ -409,7 +389,7 @@ AutoencoderModel<TInputValue,NeuronType> shark::Data<shark::RealVector> data = shark::createDataFromRange(features); // features layer for a network containing the encoder and decoder part - data = m_Net.evalLayer( m_Net.layerMatrices().size()/2-1 ,data); + data = m_Encoder(data); TargetSampleType target; target.SetSize(this->m_Dimension); @@ -435,7 +415,7 @@ AutoencoderModel<TInputValue,NeuronType> shark::Data<shark::RealVector> data = shark::createDataFromRange(features); TargetSampleType target; // features layer for a network containing the encoder and decoder part - data = m_Net.evalLayer( m_Net.layerMatrices().size()/2-1 ,data); + data = m_Encoder(data); unsigned int id = startIndex; target.SetSize(this->m_Dimension); diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx index 9f39326a21..a387852fec 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.txx @@ -137,11 +137,11 @@ PCAModel<TInputValue>::Load(const std::string & filename, const std::string & /* ifs.close(); if (this->m_Dimension ==0) { - this->m_Dimension = m_Encoder.outputSize(); + this->m_Dimension = m_Encoder.outputShape()[0]; } auto eigenvectors = m_Encoder.matrix(); - eigenvectors.resize(this->m_Dimension,m_Encoder.inputSize()); + eigenvectors.resize(this->m_Dimension,m_Encoder.inputShape()[0]); m_Encoder.setStructure(eigenvectors, m_Encoder.offset() ); } -- GitLab From 1af65dbefa2ce3bdd4a059dd43e05518c0dd1776 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 7 Mar 2018 16:03:57 +0100 Subject: [PATCH 417/567] TEST: new test for Python wrapping of new services --- .../Wrappers/SWIG/test/python/CMakeLists.txt | 6 +++++ .../SWIG/test/python/PythonImageInterface.py | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Modules/Wrappers/SWIG/test/python/PythonImageInterface.py diff --git a/Modules/Wrappers/SWIG/test/python/CMakeLists.txt b/Modules/Wrappers/SWIG/test/python/CMakeLists.txt index b0e0ac49bc..342a806df2 100644 --- a/Modules/Wrappers/SWIG/test/python/CMakeLists.txt +++ b/Modules/Wrappers/SWIG/test/python/CMakeLists.txt @@ -141,3 +141,9 @@ add_test( NAME pyTvBug1498 ${OTB_DATA_ROOT}/Input/poupees.tif ${TEMP}/Bu1498-output.tif) +add_test( NAME pyTvImageInterface + COMMAND ${TEST_DRIVER} Execute + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py + PythonImageInterface + ${OTB_DATA_ROOT}/Examples/QB_Toulouse_Ortho_XS.tif + ) diff --git a/Modules/Wrappers/SWIG/test/python/PythonImageInterface.py b/Modules/Wrappers/SWIG/test/python/PythonImageInterface.py new file mode 100644 index 0000000000..62aade511e --- /dev/null +++ b/Modules/Wrappers/SWIG/test/python/PythonImageInterface.py @@ -0,0 +1,23 @@ + +def test(otb, argv): + # Create a smoothing application + app = otb.Registry.CreateApplication("Smoothing") + app.SetParameterString("in",argv[1]) + app.Execute() + + # Setup a special requested region + myRegion = otb.itkRegion() + myRegion.GetSize()[0] = 20 + myRegion.GetSize()[1] = 25 + myRegion.GetIndex().Fill(10) + app.PropagateRequestedRegion("out",myRegion) + print(app.GetImageRequestedRegion("in")) + + # Create a ReadImageInfo application and plug the output of app + app2 = otb.Registry.CreateApplication("ReadImageInfo") + ex = app.ExportImage("out") + app2.ImportVectorImage("in", ex) + app2.Execute() + someKeys = ['sizex', 'sizey', 'spacingx', 'spacingy', 'sensor', 'projectionref'] + for key in someKeys: + print(key + ' : ' + str(app2.GetParameterValue(key)) ) -- GitLab From a3ab4813c19b74ba7495d4264e7c5a928f3f6640 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 7 Mar 2018 16:41:28 +0100 Subject: [PATCH 418/567] DOC: clarification about EmptyParameter/BoolParameter --- Documentation/Cookbook/rst/recipes/python.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Documentation/Cookbook/rst/recipes/python.rst b/Documentation/Cookbook/rst/recipes/python.rst index cbb119372d..92c6b2dabd 100644 --- a/Documentation/Cookbook/rst/recipes/python.rst +++ b/Documentation/Cookbook/rst/recipes/python.rst @@ -229,12 +229,16 @@ doing geometry, projections, and also calibration. Future developments will probably offer a more adapted structure to import and export images between OTB and Python world. -Setting of boolean parameters -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Setting of EmptyParameter +^^^^^^^^^^^^^^^^^^^^^^^^^ -Most of the parameters are set using functions ``SetParameterXXX()``. The boolean -parameters are handled differently (also called Empty parameter). Let's take an example with the application -``ReadImageInfo``: +Most of the parameters are set using functions ``SetParameterXXX()``, except for +one type of parameter: the ``EmptyParameter``. This class was the first +implementation of a boolean. It is now **deprecated**, you should use ``BoolParameter`` +instead. + +Let's take an example with the application ``ReadImageInfo`` when it was still +using an ``EmptyParameter`` for parameter ``keywordlist``: .. code-block:: python -- GitLab From 73f79bba0bbf763be2499f704efb4d446e794a4c Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Wed, 7 Mar 2018 20:15:43 +0100 Subject: [PATCH 419/567] COMP: update shark version to use RF with node id --- SuperBuild/CMake/External_shark.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SuperBuild/CMake/External_shark.cmake b/SuperBuild/CMake/External_shark.cmake index a4430d8018..547eb6ce37 100644 --- a/SuperBuild/CMake/External_shark.cmake +++ b/SuperBuild/CMake/External_shark.cmake @@ -30,8 +30,8 @@ ADD_SUPERBUILD_CMAKE_VAR(SHARK BOOST_LIBRARYDIR) ExternalProject_Add(SHARK PREFIX SHARK - URL "https://github.com/Shark-ML/Shark/archive/a7346060ba50edaf7d31e2677058258ad7d11692.zip" - URL_MD5 120b7ea9d93e329ddaf310985c295c5e + URL "https://github.com/Shark-ML/Shark/archive/75eac83266e3713e00af2d1ca1264fc6e44322b8.zip" + URL_MD5 bfbdf1fe8e0563dbf8af87da9419dc0f SOURCE_DIR ${SHARK_SB_SRC} BINARY_DIR ${SHARK_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} -- GitLab From c115e2f41be380e81d1f231d63ccd586f9664fe2 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 8 Mar 2018 09:40:11 +0100 Subject: [PATCH 420/567] REFAC: get rid of unnecessary cast --- Modules/Core/ObjectList/include/otbObjectList.txx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Modules/Core/ObjectList/include/otbObjectList.txx b/Modules/Core/ObjectList/include/otbObjectList.txx index 121dfd90b0..1542fec511 100644 --- a/Modules/Core/ObjectList/include/otbObjectList.txx +++ b/Modules/Core/ObjectList/include/otbObjectList.txx @@ -168,8 +168,7 @@ typename ObjectList<TObject>::Superclass * ObjectList<TObject> ::GetNthDataObject(unsigned int index) const { - ObjectType * object = GetNthElement(index).GetPointer(); - return dynamic_cast< Superclass * > ( object ); + return GetNthElement(index).GetPointer(); } /** -- GitLab From 1e4ee320e7f6082539d4d25fd61ff902050bbcbd Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Thu, 8 Mar 2018 14:53:16 +0100 Subject: [PATCH 421/567] ENH: Make default logging level Info when not in Debug build --- Modules/Core/Common/src/otbConfigurationManager.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/Common/src/otbConfigurationManager.cxx b/Modules/Core/Common/src/otbConfigurationManager.cxx index 2e2707d0fe..4b5875b3c5 100644 --- a/Modules/Core/Common/src/otbConfigurationManager.cxx +++ b/Modules/Core/Common/src/otbConfigurationManager.cxx @@ -79,7 +79,7 @@ itk::LoggerBase::PriorityLevelType ConfigurationManager::GetLoggerLevel() #ifndef NDEBUG itk::LoggerBase::PriorityLevelType level = itk::LoggerBase::DEBUG; #else - itk::LoggerBase::PriorityLevelType level = itk::LoggerBase::WARNING; + itk::LoggerBase::PriorityLevelType level = itk::LoggerBase::INFO; #endif -- GitLab From f6f3220e4a1988804b57f6d6bbf9fbcde0ebcd52 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Fri, 9 Mar 2018 13:18:50 +0100 Subject: [PATCH 422/567] STY: Mb -> MB --- Modules/Core/Common/src/otbLogger.cxx | 4 ++-- Modules/Core/Streaming/include/otbStreamingManager.txx | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index 1dd9303f26..e03253aa94 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -68,11 +68,11 @@ void Logger::LogSetupInformation() { std::ostringstream oss; - oss<<"Default RAM limit for OTB is "<<otb::ConfigurationManager::GetMaxRAMHint()<<" Mb"<<std::endl; + oss<<"Default RAM limit for OTB is "<<otb::ConfigurationManager::GetMaxRAMHint()<<" MB"<<std::endl; this->Info(oss.str()); oss.str(""); - oss<<"Gdal maximum cache size is "<<GDALGetCacheMax64()/(1024*1024)<<" Mb"<<std::endl; + oss<<"Gdal maximum cache size is "<<GDALGetCacheMax64()/(1024*1024)<<" MB"<<std::endl; this->Info(oss.str()); oss.str(""); diff --git a/Modules/Core/Streaming/include/otbStreamingManager.txx b/Modules/Core/Streaming/include/otbStreamingManager.txx index 22aed33102..5f3be76142 100644 --- a/Modules/Core/Streaming/include/otbStreamingManager.txx +++ b/Modules/Core/Streaming/include/otbStreamingManager.txx @@ -141,9 +141,8 @@ StreamingManager<TImage>::EstimateOptimalNumberOfDivisions(itk::DataObject * inp unsigned int optimalNumberOfDivisions = otb::PipelineMemoryPrintCalculator::EstimateOptimalNumberOfStreamDivisions(pipelineMemoryPrint, availableRAMInBytes); - otbLogMacro(Info,<<"Available memory: "<<availableRAMInBytes * otb::PipelineMemoryPrintCalculator::ByteToMegabyte - <<" Mb, estimated needed memory for full processing: "<<pipelineMemoryPrint * otb::PipelineMemoryPrintCalculator::ByteToMegabyte - <<" Mb, optimal number of stream divisions: "<<optimalNumberOfDivisions); + otbLogMacro(Info,<<"Estimated memory for full processing: "<<pipelineMemoryPrint * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<"MB (avail.: "<<availableRAMInBytes * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<" NB), optimal image partitioning: "<<optimalNumberOfDivisions<<" blocs"); + return optimalNumberOfDivisions; } -- GitLab From c134a480086f2d1d4b7ce6daab0c2a96fdd5846a Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 9 Mar 2018 14:55:14 +0100 Subject: [PATCH 423/567] BUG: #1526: add a per-instance default ram value in StreamingManager --- .../Core/Streaming/include/otbStreamingManager.h | 11 ++++++++--- .../Core/Streaming/include/otbStreamingManager.txx | 14 +++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Modules/Core/Streaming/include/otbStreamingManager.h b/Modules/Core/Streaming/include/otbStreamingManager.h index 2095e48e8f..5d94b191ba 100644 --- a/Modules/Core/Streaming/include/otbStreamingManager.h +++ b/Modules/Core/Streaming/include/otbStreamingManager.h @@ -88,6 +88,9 @@ public: * GetNumberOfSplits() returns. */ virtual RegionType GetSplit(unsigned int i); + itkSetMacro(DefaultRAM, MemoryPrintType); + itkGetMacro(DefaultRAM, MemoryPrintType); + protected: StreamingManager(); ~StreamingManager() ITK_OVERRIDE; @@ -111,11 +114,13 @@ private: StreamingManager(const StreamingManager &); //purposely not implemented void operator =(const StreamingManager&); //purposely not implemented - /* Compute the available RAM from configuration settings if the input parameter is 0, - * otherwise, simply returns the input parameter */ + /** Compute the available RAM in Bytes from an input value in MByte. + * If the input value is 0, it uses the m_DefaultRAM value. + * If m_DefaultRAM is also 0, it uses the configuration settings */ MemoryPrintType GetActualAvailableRAMInBytes(MemoryPrintType availableRAMInMB); - + /** Default available RAM in MB */ + MemoryPrintType m_DefaultRAM; }; } // End namespace otb diff --git a/Modules/Core/Streaming/include/otbStreamingManager.txx b/Modules/Core/Streaming/include/otbStreamingManager.txx index b0fdfced06..e43dc86d75 100644 --- a/Modules/Core/Streaming/include/otbStreamingManager.txx +++ b/Modules/Core/Streaming/include/otbStreamingManager.txx @@ -31,6 +31,7 @@ namespace otb template <class TImage> StreamingManager<TImage>::StreamingManager() : m_ComputedNumberOfSplits(0) + , m_DefaultRAM(0) { } @@ -47,9 +48,16 @@ StreamingManager<TImage>::GetActualAvailableRAMInBytes(MemoryPrintType available if (availableRAMInBytes == 0) { - otbMsgDevMacro(<< "Retrieving available RAM size from configuration"); - // Retrieve it from the configuration - availableRAMInBytes = 1024*1024*ConfigurationManager::GetMaxRAMHint(); + if (m_DefaultRAM != 0) + { + availableRAMInBytes = 1024*1024*m_DefaultRAM; + } + else + { + otbMsgDevMacro(<< "Retrieving available RAM size from configuration"); + // Retrieve it from the configuration + availableRAMInBytes = 1024*1024*ConfigurationManager::GetMaxRAMHint(); + } } otbMsgDevMacro("RAM used to estimate memory footprint : " << availableRAMInBytes / 1024 / 1024 << " MB") -- GitLab From 893739abfa24467f93fef970a0fe1f3ac7b473ab Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 9 Mar 2018 14:59:05 +0100 Subject: [PATCH 424/567] BUG: #1526: use the defaultRAM with extended filenames, always cast sizevalue to uint --- .../IO/ImageIO/include/otbImageFileWriter.txx | 38 +++++++++++------- .../include/otbSimpleParallelTiffWriter.txx | 39 ++++++++++++------- 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index b1472291f1..7649a80bf1 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -300,11 +300,17 @@ ImageFileWriter<TInputImage> sizemode = m_FilenameHelper->GetStreamingSizeMode(); } - double sizevalue = 0.; + unsigned int sizevalue = 0; + // Save the DefaultRAM value for later + unsigned int oldDefaultRAM = m_StreamingManager->GetDefaultRAM(); + if (sizemode == "auto") + { + sizevalue = oldDefaultRAM; + } if(m_FilenameHelper->StreamingSizeValueIsSet()) { - sizevalue = m_FilenameHelper->GetStreamingSizeValue(); + sizevalue = static_cast<unsigned int>(m_FilenameHelper->GetStreamingSizeValue()); } if(type == "auto") @@ -313,7 +319,7 @@ ImageFileWriter<TInputImage> { itkWarningMacro(<<"In auto streaming type, the sizemode option will be ignored."); } - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from the OTB_MAX_RAM_HINT environment variable if set, or else use the default value"); } @@ -323,7 +329,7 @@ ImageFileWriter<TInputImage> { if(sizemode == "auto") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from the OTB_MAX_RAM_HINT environment variable if set, or else use the default value"); } @@ -331,27 +337,27 @@ ImageFileWriter<TInputImage> } else if(sizemode == "nbsplits") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetNumberOfDivisionsTiledStreaming(static_cast<unsigned int>(sizevalue)); + this->SetNumberOfDivisionsTiledStreaming(sizevalue); } else if(sizemode == "height") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetTileDimensionTiledStreaming(static_cast<unsigned int>(sizevalue)); + this->SetTileDimensionTiledStreaming(sizevalue); } } else if(type == "stripped") { if(sizemode == "auto") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from configuration file if any, or from cmake configuration otherwise."); } @@ -360,30 +366,34 @@ ImageFileWriter<TInputImage> } else if(sizemode == "nbsplits") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetNumberOfDivisionsStrippedStreaming(static_cast<unsigned int>(sizevalue)); + this->SetNumberOfDivisionsStrippedStreaming(sizevalue); } else if(sizemode == "height") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetNumberOfLinesStrippedStreaming(static_cast<unsigned int>(sizevalue)); + this->SetNumberOfLinesStrippedStreaming(sizevalue); } } else if (type == "none") { - if(sizemode!="" || sizevalue!=0.) + if(sizemode!="" || sizevalue!=0) { itkWarningMacro("Streaming is explicitly disabled, sizemode and sizevalue will be ignored."); } this->SetNumberOfDivisionsTiledStreaming(0); } + + // since we change the m_StreamingManager under the hood, we copy the DefaultRAM + // value to the new streamingManager. + m_StreamingManager->SetDefaultRAM(oldDefaultRAM); } else { diff --git a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx index 96cbf7120c..01fd32f266 100644 --- a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx +++ b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx @@ -315,11 +315,16 @@ SimpleParallelTiffWriter<TInputImage> sizemode = m_FilenameHelper->GetStreamingSizeMode(); } - double sizevalue = 0.; - + unsigned int sizevalue = 0; + // Save the DefaultRAM value for later + unsigned int oldDefaultRAM = m_StreamingManager->GetDefaultRAM(); + if (sizemode == "auto") + { + sizevalue = oldDefaultRAM; + } if(m_FilenameHelper->StreamingSizeValueIsSet()) { - sizevalue = m_FilenameHelper->GetStreamingSizeValue(); + sizevalue = static_cast<unsigned int>(m_FilenameHelper->GetStreamingSizeValue()); } if(type == "auto") @@ -328,7 +333,7 @@ SimpleParallelTiffWriter<TInputImage> { itkWarningMacro(<<"In auto streaming type, the sizemode option will be ignored."); } - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from configuration file if any, or from cmake configuration otherwise."); } @@ -338,7 +343,7 @@ SimpleParallelTiffWriter<TInputImage> { if(sizemode == "auto") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from configuration file if any, or from cmake configuration otherwise."); } @@ -346,27 +351,27 @@ SimpleParallelTiffWriter<TInputImage> } else if(sizemode == "nbsplits") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetNumberOfDivisionsTiledStreaming(static_cast<unsigned int>(sizevalue)); + this->SetNumberOfDivisionsTiledStreaming(sizevalue); } else if(sizemode == "height") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetTileDimensionTiledStreaming(static_cast<unsigned int>(sizevalue)); + this->SetTileDimensionTiledStreaming(sizevalue); } } else if(type == "stripped") { if(sizemode == "auto") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("sizemode is auto but sizevalue is 0. Value will be fetched from configuration file if any, or from cmake configuration otherwise."); } @@ -375,30 +380,34 @@ SimpleParallelTiffWriter<TInputImage> } else if(sizemode == "nbsplits") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to nbsplits but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetNumberOfDivisionsStrippedStreaming(static_cast<unsigned int>(sizevalue)); + this->SetNumberOfDivisionsStrippedStreaming(sizevalue); } else if(sizemode == "height") { - if(sizevalue == 0.) + if(sizevalue == 0) { itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x."); } - this->SetNumberOfLinesStrippedStreaming(static_cast<unsigned int>(sizevalue)); + this->SetNumberOfLinesStrippedStreaming(sizevalue); } } else if (type == "none") { - if(sizemode!="" || sizevalue!=0.) + if(sizemode!="" || sizevalue!=0) { itkWarningMacro("Streaming is explicitly disabled, sizemode and sizevalue will be ignored."); } this->SetNumberOfDivisionsTiledStreaming(0); } + + // since we change the m_StreamingManager under the hood, we copy the DefaultRAM + // value to the new streamingManager. + m_StreamingManager->SetDefaultRAM(oldDefaultRAM); } else { -- GitLab From 55718b5011d6cda6c987bdc53f4ea584a150f0c3 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 9 Mar 2018 15:00:35 +0100 Subject: [PATCH 425/567] BUG: #1526: set DefaultRAM in StreamingManager, AutomaticAdaptativeStreaming is already the default for ImageFileWriter --- .../src/otbWrapperOutputImageParameter.cxx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 2790bdce25..f327f49a0a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -177,6 +177,7 @@ template <typename TInput, typename TOutput> void ClampAndWriteImage(itk::ImageB sptWriter->SetFileName(filename); sptWriter->SetInput(clampFilter->GetOutput()); sptWriter->SetAutomaticAdaptativeStreaming(ramValue); + sptWriter->GetStreamingManager()->SetDefaultRAM(ramValue); sptWriter->Update(); } @@ -192,10 +193,9 @@ template <typename TInput, typename TOutput> void ClampAndWriteImage(itk::ImageB if(useStandardWriter) { - - writer->SetFileName( filename ); - writer->SetInput(clampFilter->GetOutput()); - writer->SetAutomaticAdaptativeStreaming(ramValue); + writer->SetFileName( filename ); + writer->SetInput(clampFilter->GetOutput()); + writer->GetStreamingManager()->SetDefaultRAM(ramValue); writer->Update(); } } @@ -234,6 +234,7 @@ template <typename TInput, typename TOutput > void ClampAndWriteVectorImage(itk: sptWriter->SetFileName(filename); sptWriter->SetInput(clampFilter->GetOutput()); sptWriter->SetAutomaticAdaptativeStreaming(ramValue); + sptWriter->GetStreamingManager()->SetDefaultRAM(ramValue); sptWriter->Update(); } @@ -247,10 +248,9 @@ template <typename TInput, typename TOutput > void ClampAndWriteVectorImage(itk: if(useStandardWriter) { - - writer->SetFileName( filename ); - writer->SetInput(clampFilter->GetOutput()); - writer->SetAutomaticAdaptativeStreaming(ramValue); + writer->SetFileName( filename ); + writer->SetInput(clampFilter->GetOutput()); + writer->GetStreamingManager()->SetDefaultRAM(ramValue); writer->Update(); } } @@ -354,7 +354,7 @@ OutputImageParameter::SwitchRGBAImageWrite() { m_RGBAUInt8Writer->SetFileName( this->GetFileName() ); m_RGBAUInt8Writer->SetInput(dynamic_cast<UInt8RGBAImageType*>(m_Image.GetPointer()) ); - m_RGBAUInt8Writer->SetAutomaticAdaptativeStreaming(m_RAMValue); + m_RGBAUInt8Writer->GetStreamingManager()->SetDefaultRAM(m_RAMValue); m_RGBAUInt8Writer->Update(); } else @@ -369,7 +369,7 @@ OutputImageParameter::SwitchRGBImageWrite() { m_RGBUInt8Writer->SetFileName( this->GetFileName() ); m_RGBUInt8Writer->SetInput(dynamic_cast<UInt8RGBImageType*>(m_Image.GetPointer()) ); - m_RGBUInt8Writer->SetAutomaticAdaptativeStreaming(m_RAMValue); + m_RGBUInt8Writer->GetStreamingManager()->SetDefaultRAM(m_RAMValue); m_RGBUInt8Writer->Update(); } else -- GitLab From f88b77c1d6fdeca4dc0bf8747c19f7e54d3ab7a7 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Fri, 9 Mar 2018 15:50:09 +0100 Subject: [PATCH 426/567] STY: typo --- Modules/Core/Streaming/include/otbStreamingManager.txx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/Streaming/include/otbStreamingManager.txx b/Modules/Core/Streaming/include/otbStreamingManager.txx index 5f3be76142..d30e3a2580 100644 --- a/Modules/Core/Streaming/include/otbStreamingManager.txx +++ b/Modules/Core/Streaming/include/otbStreamingManager.txx @@ -141,7 +141,7 @@ StreamingManager<TImage>::EstimateOptimalNumberOfDivisions(itk::DataObject * inp unsigned int optimalNumberOfDivisions = otb::PipelineMemoryPrintCalculator::EstimateOptimalNumberOfStreamDivisions(pipelineMemoryPrint, availableRAMInBytes); - otbLogMacro(Info,<<"Estimated memory for full processing: "<<pipelineMemoryPrint * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<"MB (avail.: "<<availableRAMInBytes * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<" NB), optimal image partitioning: "<<optimalNumberOfDivisions<<" blocs"); + otbLogMacro(Info,<<"Estimated memory for full processing: "<<pipelineMemoryPrint * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<"MB (avail.: "<<availableRAMInBytes * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<" NB), optimal image partitioning: "<<optimalNumberOfDivisions<<" blocks"); return optimalNumberOfDivisions; } -- GitLab From e6d362ac8775fc6c5635e9221325ac9684fd3229 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 9 Mar 2018 16:00:07 +0100 Subject: [PATCH 427/567] COMP: fix compilation error on windows --- Modules/Core/Common/include/otbExtendedFilenameHelper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/otbExtendedFilenameHelper.h b/Modules/Core/Common/include/otbExtendedFilenameHelper.h index 018647b821..2ee1126855 100644 --- a/Modules/Core/Common/include/otbExtendedFilenameHelper.h +++ b/Modules/Core/Common/include/otbExtendedFilenameHelper.h @@ -56,7 +56,7 @@ public: itkGetStringMacro(ExtendedFileName); itkGetStringMacro(SimpleFileName); - struct GenericBandRange : std::pair<int,int> + struct OTBCommon_EXPORT GenericBandRange : std::pair<int,int> { GenericBandRange() {} -- GitLab From 63422ee5c1e1aac647b54bc5bf89683325cd8e8a Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 9 Mar 2018 16:00:40 +0100 Subject: [PATCH 428/567] BUG: Pass creation option to DataSource at its creation --- .../include/otbOGRDataSourceWrapper.h | 2 +- .../src/otbOGRDataSourceWrapper.cxx | 36 +++++++++++-------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h index 700b80bdb9..cbac97245f 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h @@ -164,7 +164,7 @@ public: * \note No condition is assumed on the non-nullity of \c source. * \see \c DataSource(GDALDataset *) */ - static Pointer New(ogr::version_proxy::GDALDatasetType * sourcemode, Modes::type mode = Modes::Read); + static Pointer New(ogr::version_proxy::GDALDatasetType * sourcemode, Modes::type mode = Modes::Read , std::vector< std::string > layerOptions = std::vector< std::string >() ); //@} /**\name Projection Reference property */ diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx index 84b5b420de..91ec386f4e 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx @@ -149,10 +149,10 @@ otb::ogr::DataSource::DataSource( otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string const& datasourceName, Modes::type mode) { FileNameHelperType::Pointer fileNameHelper = FileNameHelperType::New(); - bool update = (mode != Modes::Read); fileNameHelper->SetExtendedFileName( datasourceName.c_str() ); - std::string simpleFileName = fileNameHelper->GetSimpleFileName(); + + bool update = (mode != Modes::Read); ogr::version_proxy::GDALDatasetType * source = ogr::version_proxy::Open( simpleFileName.c_str() , !update , @@ -164,16 +164,16 @@ otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string c if (mode == Modes::Read) { itkGenericExceptionMacro(<< "Failed to open GDALDataset file " - << datasourceName<<" : " << CPLGetLastErrorMsg()); + << simpleFileName<<" : " << CPLGetLastErrorMsg()); } // Hand made factory based on file extension. - char const* driverName = DeduceDriverName(datasourceName); + char const* driverName = DeduceDriverName(simpleFileName); if (!driverName) { itkGenericExceptionMacro(<< "No OGR driver known to OTB to create and " "handle a DataSource named <" - <<datasourceName<<">."); + <<simpleFileName<<">."); } ogr::version_proxy::GDALDriverType * d = @@ -191,19 +191,24 @@ otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string c fileNameHelper->GetGDALCreationOptions() ); if (!source) { itkGenericExceptionMacro(<< "Failed to create GDALDataset <" - << datasourceName << "> (driver name: <" << driverName + << simpleFileName << "> (driver name: <" << driverName <<">: " << CPLGetLastErrorMsg()); } } - return otb::ogr::DataSource::New( source, mode ); + return otb::ogr::DataSource::New( source , mode , fileNameHelper->GetGDALLayerOptions() ); } void DeleteDataSource(std::string const& datasourceName) { - bool ret = otb::ogr::version_proxy::Delete(datasourceName.c_str()); + otb::OGRExtendedFilenameToOptions::Pointer fileNameHelper = + otb::OGRExtendedFilenameToOptions::New(); + fileNameHelper->SetExtendedFileName( datasourceName.c_str() ); + std::string simpleFileName = fileNameHelper->GetSimpleFileName(); + + bool ret = otb::ogr::version_proxy::Delete(simpleFileName.c_str()); if (!ret) { - itkGenericExceptionMacro(<< "Deletion of data source " << datasourceName + itkGenericExceptionMacro(<< "Deletion of data source " << simpleFileName << " failed: " << CPLGetLastErrorMsg()); } } @@ -211,15 +216,18 @@ void DeleteDataSource(std::string const& datasourceName) otb::ogr::DataSource::Pointer otb::ogr::DataSource::New(std::string const& datasourceName, Modes::type mode) { + FileNameHelperType::Pointer fileNameHelper = FileNameHelperType::New(); + fileNameHelper->SetExtendedFileName( datasourceName.c_str() ); + std::string simpleFileName = fileNameHelper->GetSimpleFileName(); + if (mode < Modes::Read || mode >= Modes::MAX__) { - itkGenericExceptionMacro(<< "Wrong mode when opening " << datasourceName ); + itkGenericExceptionMacro(<< "Wrong mode when opening " << simpleFileName ); } Drivers::Init(); - ogr::version_proxy::GDALDatasetType * ds = - ogr::version_proxy::Open( datasourceName.c_str() , true ); + ogr::version_proxy::Open( simpleFileName.c_str() , true ); bool ds_exists = (ds!=ITK_NULLPTR); @@ -236,9 +244,9 @@ otb::ogr::DataSource::New(std::string const& datasourceName, Modes::type mode) /*static*/ otb::ogr::DataSource::Pointer -otb::ogr::DataSource::New(otb::ogr::version_proxy::GDALDatasetType * source, Modes::type mode) +otb::ogr::DataSource::New(otb::ogr::version_proxy::GDALDatasetType * source , Modes::type mode , std::vector< std::string > layerOptions ) { - Pointer res = new DataSource(source, mode); + Pointer res = new DataSource( source , mode , layerOptions ); res->UnRegister(); return res; } -- GitLab From 1ee0605428a25f512f241f9a83ef0c810106463c Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 12 Mar 2018 08:47:20 +0100 Subject: [PATCH 429/567] COMP: add dynamic cast to object list method GetNthDataObject --- Modules/Core/ObjectList/include/otbObjectList.txx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Core/ObjectList/include/otbObjectList.txx b/Modules/Core/ObjectList/include/otbObjectList.txx index 1542fec511..9fcbc82a8a 100644 --- a/Modules/Core/ObjectList/include/otbObjectList.txx +++ b/Modules/Core/ObjectList/include/otbObjectList.txx @@ -168,7 +168,8 @@ typename ObjectList<TObject>::Superclass * ObjectList<TObject> ::GetNthDataObject(unsigned int index) const { - return GetNthElement(index).GetPointer(); + + return dynamic_cast<itk::DataObject *> ( GetNthElement(index).GetPointer() ); } /** -- GitLab From 3c023d6e519a0d537d197f93af929458166b6374 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Mon, 12 Mar 2018 09:23:53 +0100 Subject: [PATCH 430/567] ENH: Adressing minor comments from @lnicola --- .../Common/include/otbConfigurationManager.h | 2 +- Modules/Core/Common/include/otbLogger.h | 2 +- Modules/Core/Common/include/otbMacro.h | 12 +++------ .../Common/src/otbConfigurationManager.cxx | 27 +++++++++++++++---- Modules/Core/Common/src/otbLogger.cxx | 5 +++- Modules/IO/IOGDAL/src/otbGDALImageIO.cxx | 2 +- .../IO/ImageIO/include/otbImageFileWriter.txx | 2 +- 7 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Modules/Core/Common/include/otbConfigurationManager.h b/Modules/Core/Common/include/otbConfigurationManager.h index 7b32b3dc72..30e3d11220 100644 --- a/Modules/Core/Common/include/otbConfigurationManager.h +++ b/Modules/Core/Common/include/otbConfigurationManager.h @@ -93,7 +93,7 @@ public: * INFO, WARNING, CRITICAL or FATAL, the logger level will be * set accordingly. * - * Priority is DEBUG < INFO < WARNING < CRITICAL < FATAL. + * Priority is DEBUG < INFO < WARNING < CRITICAL < FATAL. * * Only messages with a higher priority than the logger level will * be displayed. diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index 21aff6e14b..d61c22bf4a 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -49,7 +49,7 @@ public: itkNewMacro(Self); // Overwrite this to provide custom formatting of log entries - virtual std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; + std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; void LogSetupInformation(); diff --git a/Modules/Core/Common/include/otbMacro.h b/Modules/Core/Common/include/otbMacro.h index 5dcca1bab9..6a248d4551 100644 --- a/Modules/Core/Common/include/otbMacro.h +++ b/Modules/Core/Common/include/otbMacro.h @@ -50,6 +50,7 @@ namespace otb #define otbClassContext(x) \ << this->GetNameOfClass() << " (" << this << "): " x +// Beware that to log to CRITICAL level, level should be passed as "Error" #define otbLogMacro(level,msg) \ { \ std::ostringstream itkmsg; \ @@ -58,21 +59,14 @@ namespace otb } +// Re-definition of old log macros to use the otbLogMacro #define otbDebugMacro(x) otbLogMacro(Debug,otbFileContext(otbClassContext(x))) #define otbMsgDebugMacro(x) otbLogMacro(Debug,otbFileContext(x)) #define otbGenericMsgDebugMacro(x) otbLogMacro(Debug,x) #define otbMsgDevMacro(x) otbLogMacro(Debug,otbFileContext(x)) #define otbWarningMacro(x) otbLogMacro(Warning,otbFileContext(otbClassContext(x))) #define otbGenericWarningMacro(x) otbLogMacro(Warning,otbFileContext(x)) - - - -// TODO: Address this macro as well -#define otbGenericMsgTestingMacro(x) \ - { \ - std::cout x << std::endl; \ - } - +#define otbGenericMsgTestingMAcro(x) otbLogMacro(Info,"[testing] "<<x) /** This macro is used to control condition. It use ONLY by the OTB developers * diff --git a/Modules/Core/Common/src/otbConfigurationManager.cxx b/Modules/Core/Common/src/otbConfigurationManager.cxx index 4b5875b3c5..48108116bf 100644 --- a/Modules/Core/Common/src/otbConfigurationManager.cxx +++ b/Modules/Core/Common/src/otbConfigurationManager.cxx @@ -20,6 +20,8 @@ #include "otbConfigurationManager.h" +#include "otbMacro.h" + #include "itksys/SystemTools.hxx" #include <cstdlib> @@ -85,11 +87,26 @@ itk::LoggerBase::PriorityLevelType ConfigurationManager::GetLoggerLevel() if(itksys::SystemTools::GetEnv("OTB_LOGGER_LEVEL",svalue)) { - level_macro(DEBUG); - level_macro(WARNING); - level_macro(INFO); - level_macro(CRITICAL); - level_macro(FATAL); + if(svalue.compare("DEBUG") == 0) + { + level = itk::LoggerBase::DEBUG; + } + else if(svalue.compare("INFO") == 0) + { + level = itk::LoggerBase::INFO; + } + else if(svalue.compare("WARNING") == 0) + { + level = itk::LoggerBase::WARNING; + } + else if(svalue.compare("CRITICAL") == 0) + { + level = itk::LoggerBase::CRITICAL; + } + else + { + otbLogMacro(Error,<<"Unknown value for OTB_LOGGER_LEVEL_MACRO. Possible values are DEBUG, INFO, WARNING, CRITICAL."); + } } return level; } diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index e03253aa94..37a2ef0540 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -71,14 +71,17 @@ void Logger::LogSetupInformation() oss<<"Default RAM limit for OTB is "<<otb::ConfigurationManager::GetMaxRAMHint()<<" MB"<<std::endl; this->Info(oss.str()); oss.str(""); + oss.clear(); - oss<<"Gdal maximum cache size is "<<GDALGetCacheMax64()/(1024*1024)<<" MB"<<std::endl; + oss<<"GDAL maximum cache size is "<<GDALGetCacheMax64()/(1024*1024)<<" MB"<<std::endl; this->Info(oss.str()); oss.str(""); + oss.clear(); oss<<"OTB will use at most "<<itk::MultiThreader::GetGlobalDefaultNumberOfThreads()<<" threads"<<std::endl; this->Info(oss.str()); oss.str(""); + oss.clear(); } std::string Logger::BuildFormattedEntry(itk::Logger::PriorityLevelType level, std::string const & content) diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx index 944bbf51f9..ee8f3b6297 100644 --- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx @@ -860,7 +860,7 @@ void GDALImageIO::InternalReadImageInformation() } else { - otbLogMacro(Warning,<< "Geotransform reported by Gdal is invalid (spacing = 0)"); + otbLogMacro(Warning,<< "Geotransform reported by GDAL is invalid (spacing = 0)"); m_Spacing[0] = 1; m_Spacing[1] = 1; } diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index 4cc2c316da..907da0d9bd 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -513,7 +513,7 @@ ImageFileWriter<TInputImage> /** Control if the ImageIO is CanStreamWrite */ if (m_ImageIO->CanStreamWrite() == false) { - otbLogMacro(Warning,<<"The file format of " << m_FileName.c_str() << + otbLogMacro(Warning,<<"The file format of " << m_FileName << " does not support streaming. All data will be loaded to memory"); this->SetNumberOfDivisionsStrippedStreaming(1); } -- GitLab From aa2205990851da31ad36597be64764db2fd197da Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Mon, 12 Mar 2018 09:25:41 +0100 Subject: [PATCH 431/567] ENH: Adressing minor comments from @lnicola --- Modules/IO/IOGDAL/src/otbGDALImageIO.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx index ee8f3b6297..4f55f67b2b 100644 --- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx @@ -1105,7 +1105,7 @@ bool GDALImageIO::CanWriteFile(const char* name) if ( GDALGetMetadataItem( driver, GDAL_DCAP_CREATE, ITK_NULLPTR ) == ITK_NULLPTR && GDALGetMetadataItem( driver, GDAL_DCAP_CREATECOPY, ITK_NULLPTR ) == ITK_NULLPTR ) { - otbLogMacro(Warning,<< "Gdal driver " << GDALGetDriverShortName(driver) << " does not support writing"); + otbLogMacro(Warning,<< "GDAL driver " << GDALGetDriverShortName(driver) << " does not support writing"); return false; } return true; -- GitLab From f1fa383015624e9e069597b26c41b08d5bf29d8a Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Mon, 12 Mar 2018 09:33:42 +0100 Subject: [PATCH 432/567] STY: Remove macro (not used anymore) --- Modules/Core/Common/src/otbConfigurationManager.cxx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Modules/Core/Common/src/otbConfigurationManager.cxx b/Modules/Core/Common/src/otbConfigurationManager.cxx index 48108116bf..6e4819539d 100644 --- a/Modules/Core/Common/src/otbConfigurationManager.cxx +++ b/Modules/Core/Common/src/otbConfigurationManager.cxx @@ -65,15 +65,6 @@ ConfigurationManager::RAMValueType ConfigurationManager::GetMaxRAMHint() return value; } - -#define level_macro(x) \ - { \ - std::string target = #x; \ - if(std::equal(svalue.begin(),svalue.end(),target.begin(),target.end())) \ - level = itk::LoggerBase::x; \ - } \ - - itk::LoggerBase::PriorityLevelType ConfigurationManager::GetLoggerLevel() { std::string svalue; -- GitLab From 4b430cdb51f1440f5778f536d9205afd4551629a Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Mon, 12 Mar 2018 10:10:48 +0100 Subject: [PATCH 433/567] DOC: Create a new chapter with extended filenames and environment variables in cookbook. Document all environment variables --- ...{ExtendedFilenames.rst => AdvancedUse.rst} | 22 ++++++++++++++++--- Documentation/Cookbook/rst/index_TOC.rst | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) rename Documentation/Cookbook/rst/{ExtendedFilenames.rst => AdvancedUse.rst} (87%) diff --git a/Documentation/Cookbook/rst/ExtendedFilenames.rst b/Documentation/Cookbook/rst/AdvancedUse.rst similarity index 87% rename from Documentation/Cookbook/rst/ExtendedFilenames.rst rename to Documentation/Cookbook/rst/AdvancedUse.rst index 02b5512351..d985193932 100644 --- a/Documentation/Cookbook/rst/ExtendedFilenames.rst +++ b/Documentation/Cookbook/rst/AdvancedUse.rst @@ -1,7 +1,24 @@ -.. _extended-filenames: +Advanced Use +============ + +This section describes advanced configuration options and tricks. + +Environment variables that affects Orfeo ToolBox +------------------------------------------------ + +The following environment variables are parsed by Orfeo ToolBox. Note +that they only affect default values, and that settings in extended +filenames, applications, monteverdi or custom C++ code might override +those values. + +* ``OTB_DEM_DIRECTORY``: Default directory were DEM tiles are stored. It should only contain ```.hgt`` or or georeferenced ``.tif`` files. Empty if not set (no directory set) +* ``OTB_GEOID_FILE``: Default path to the geoid file that will be used to retrieve height of DEM above ellipsoid. Empty if not set (no geoid set) +* ``OTB_MAX_RAM_HINT``: Default maximum memory that OTB should use for processing, in MB. If not set, default value is 128 MB. +* ``OTB_LOGGER_LEVEL``: Default level of logging for OTB. Should be one of ``DEBUG``, ``INFO``, ``WARNING``, ``CRITICAL`` or ``FATAL``, by increasing order of priority. Only messages with a higher priority than the level of logging will be displayed. By default level is ``DEBUG`` for Debug build and ``INFO`` otherwise. Extended filenames -================================ +------------------ +.. _extended-filenames: Extended filenames is an interesting feature of OTB. With it, you can control several aspects of the beahvior of the OTB in the OTB-Applications or in our @@ -42,7 +59,6 @@ applications from the bash command line.** Reader options ^^^^^^^^^^^^^^ - :: &geom=<path/filename.geom> diff --git a/Documentation/Cookbook/rst/index_TOC.rst b/Documentation/Cookbook/rst/index_TOC.rst index 12565d1577..126fc8debf 100644 --- a/Documentation/Cookbook/rst/index_TOC.rst +++ b/Documentation/Cookbook/rst/index_TOC.rst @@ -8,7 +8,7 @@ Table of Contents Installation OTB-Applications Monteverdi - ExtendedFilenames + AdvancedUse Recipes Applications FAQ -- GitLab From 7e1229c0b3794513dc33620d41bd6c90e2f8b4b7 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Mon, 12 Mar 2018 10:11:11 +0100 Subject: [PATCH 434/567] DOC: Wrong default value in doc --- Modules/Core/Common/include/otbConfigurationManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/otbConfigurationManager.h b/Modules/Core/Common/include/otbConfigurationManager.h index 30e3d11220..0c6b9118ae 100644 --- a/Modules/Core/Common/include/otbConfigurationManager.h +++ b/Modules/Core/Common/include/otbConfigurationManager.h @@ -100,7 +100,7 @@ public: * * By default (if OTB_LOGGER_LEVEL is not set or can not be * decoded), level is DEBUG in Debug or RelWithDebInfo builds, and - * WARNING otherwise. + * INFO otherwise. * */ static itk::LoggerBase::PriorityLevelType GetLoggerLevel(); -- GitLab From 5c989b9d7f701635fb6f45397f563d63a2d5b302 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Mon, 12 Mar 2018 10:42:14 +0100 Subject: [PATCH 435/567] ENH: Refactor singleton pattern to be thread-safe and simpler --- Modules/Core/Common/include/otbLogger.h | 2 +- Modules/Core/Common/src/otbLogger.cxx | 33 ++++++++++++++----------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index d61c22bf4a..3e69d173c0 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -61,7 +61,7 @@ private: Logger(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented - static Pointer Singleton; + static Pointer CreateInstance(); }; // class Logger diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index 37a2ef0540..b3730cf445 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -29,25 +29,28 @@ namespace otb { -Logger::Pointer Logger::Singleton = ITK_NULLPTR; - -Logger::Pointer Logger::Instance() +Logger::Pointer Logger::CreateInstance() { - if(!Logger::Singleton) - { - Logger::Singleton = Logger::New(); + Logger::Pointer instance = Logger::New(); - // By default, redirect logs to std::cout - itk::StdStreamLogOutput::Pointer defaultOutput = itk::StdStreamLogOutput::New(); - defaultOutput->SetStream(std::cout); + // By default, redirect logs to std::cout + itk::StdStreamLogOutput::Pointer defaultOutput = itk::StdStreamLogOutput::New(); + defaultOutput->SetStream(std::cout); + + instance->AddLogOutput(defaultOutput); + + // Log setup information + instance->LogSetupInformation(); - Logger::Singleton->AddLogOutput(defaultOutput); + return instance; +} - // Log setup information - Logger::Singleton->LogSetupInformation(); - } - - return Logger::Singleton; +Logger::Pointer Logger::Instance() +{ + // Static locales are initialized once in a thread-safe way + static Logger::Pointer instance = CreateInstance(); + + return instance; } Logger::Logger() -- GitLab From 756ee5dca5baf01d100d01d51c97ab33d892b334 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Mon, 12 Mar 2018 10:52:35 +0100 Subject: [PATCH 436/567] STY: Change ITK_OVERRIDE for override in whole code (find Modules -type f -exec sed -i 's/ITK_OVERRIDE/override/g' {} +) --- .../CurlAdapters/include/otbCurlHelper.h | 12 +- .../include/otbCurlHelperInterface.h | 2 +- .../CurlAdapters/include/otbCurlHelperStub.h | 12 +- .../CurlAdapters/src/otbCurlHelper.cxx | 6 +- .../GdalAdapters/include/otbGeometriesSet.h | 4 +- .../include/otbGeometriesSource.h | 4 +- .../include/otbGeometriesToGeometriesFilter.h | 10 +- .../include/otbOGRDataSourceWrapper.h | 6 +- .../include/otbOGRFieldWrapper.txx | 4 +- .../include/otbDEMConvertAdapter.h | 2 +- .../OSSIMAdapters/include/otbDEMHandler.h | 4 +- .../include/otbDateTimeAdapter.h | 2 +- .../include/otbEllipsoidAdapter.h | 2 +- .../include/otbFilterFunctionValues.h | 4 +- .../otbGeometricSarSensorModelAdapter.h | 2 +- .../include/otbMapProjectionAdapter.h | 2 +- .../include/otbPlatformPositionAdapter.h | 2 +- .../include/otbSarSensorModelAdapter.h | 2 +- .../include/otbSensorModelAdapter.h | 2 +- .../app/otbMultivariateAlterationDetector.cxx | 6 +- .../otbClassificationMapRegularization.cxx | 6 +- .../app/otbComputeConfusionMatrix.cxx | 6 +- .../app/otbComputeImagesStatistics.cxx | 6 +- .../otbComputeOGRLayersFeaturesStatistics.cxx | 6 +- .../otbComputePolylineFeatureFromImage.cxx | 6 +- .../app/otbDSFuzzyModelEstimation.cxx | 10 +- .../app/otbFusionOfClassifications.cxx | 6 +- .../app/otbImageClassifier.cxx | 8 +- .../app/otbKMeansClassification.cxx | 6 +- .../app/otbMultiImageSamplingRate.cxx | 6 +- .../app/otbOGRLayerClassifier.cxx | 6 +- .../app/otbPolygonClassStatistics.cxx | 6 +- .../app/otbPredictRegression.cxx | 8 +- .../app/otbSOMClassification.cxx | 6 +- .../app/otbSampleExtraction.cxx | 6 +- .../app/otbSampleSelection.cxx | 6 +- .../app/otbTrainImagesClassifier.cxx | 6 +- .../app/otbTrainRegression.cxx | 6 +- .../app/otbTrainVectorClassifier.cxx | 6 +- .../app/otbVectorClassifier.cxx | 8 +- .../app/otbVectorDataDSValidation.cxx | 6 +- .../include/otbLearningApplicationBase.h | 4 +- .../include/otbTrainVectorBase.h | 6 +- .../app/otbHomologousPointsExtraction.cxx | 6 +- .../app/otbDimensionalityReduction.cxx | 6 +- .../app/otbImageDimensionalityReduction.cxx | 8 +- .../app/otbTrainDimensionalityReduction.cxx | 6 +- .../app/otbVectorDimensionalityReduction.cxx | 8 +- .../app/otbDomainTransform.cxx | 8 +- .../AppEdge/app/otbEdgeExtraction.cxx | 6 +- .../AppEdge/app/otbLineSegmentDetection.cxx | 6 +- .../AppFiltering/app/otbSmoothing.cxx | 6 +- .../app/otbBundleToPerfectSensor.cxx | 6 +- .../AppFusion/app/otbPansharpening.cxx | 6 +- .../app/otbHyperspectralUnmixing.cxx | 6 +- .../app/otbVertexComponentAnalysis.cxx | 6 +- .../AppImageUtils/app/otbColorMapping.cxx | 6 +- .../AppImageUtils/app/otbCompareImages.cxx | 6 +- .../app/otbConcatenateImages.cxx | 6 +- .../AppImageUtils/app/otbConvert.cxx | 6 +- .../AppImageUtils/app/otbDEMConvert.cxx | 6 +- .../AppImageUtils/app/otbDynamicConvert.cxx | 4 +- .../AppImageUtils/app/otbExtractROI.cxx | 6 +- .../AppImageUtils/app/otbManageNoData.cxx | 6 +- .../app/otbMultiResolutionPyramid.cxx | 6 +- .../AppImageUtils/app/otbPixelValue.cxx | 6 +- .../AppImageUtils/app/otbQuicklook.cxx | 6 +- .../AppImageUtils/app/otbReadImageInfo.cxx | 6 +- .../AppImageUtils/app/otbRescale.cxx | 6 +- .../AppImageUtils/app/otbSplitImage.cxx | 6 +- .../AppImageUtils/app/otbTileFusion.cxx | 6 +- .../AppIndices/app/otbRadiometricIndices.cxx | 6 +- .../Applications/AppKMZ/app/otbKmzExport.cxx | 6 +- .../AppMathParser/app/otbBandMath.cxx | 6 +- .../AppMathParserX/app/otbBandMathX.cxx | 6 +- .../app/otbLocalStatisticExtraction.cxx | 6 +- .../app/otbBinaryMorphologicalOperation.cxx | 6 +- .../otbGrayScaleMorphologicalOperation.cxx | 6 +- .../app/otbMorphologicalClassification.cxx | 6 +- ...tbMorphologicalMultiScaleDecomposition.cxx | 6 +- .../app/otbMorphologicalProfilesAnalysis.cxx | 6 +- .../app/otbOpticalCalibration.cxx | 6 +- .../app/otbConvertCartoToGeoPoint.cxx | 6 +- .../app/otbConvertSensorToGeoPoint.cxx | 6 +- .../app/otbGenerateRPCSensorModel.cxx | 6 +- .../app/otbGridBasedImageResampling.cxx | 6 +- .../AppProjection/app/otbImageEnvelope.cxx | 6 +- .../app/otbObtainUTMZoneFromGeoPoint.cxx | 8 +- .../app/otbOrthoRectification.cxx | 6 +- .../app/otbRefineSensorModel.cxx | 6 +- .../app/otbRigidTransformResample.cxx | 6 +- .../AppProjection/app/otbSuperimpose.cxx | 6 +- .../app/otbVectorDataReprojection.cxx | 6 +- .../app/otbSARCalibration.cxx | 6 +- .../AppSARCalibration/app/otbSARDeburst.cxx | 6 +- .../app/otbSARDecompositions.cxx | 6 +- .../app/otbSARPolarMatrixConvert.cxx | 6 +- .../AppSARPolarSynth/app/otbSARPolarSynth.cxx | 6 +- .../app/otbComputeModulusAndPhase.cxx | 6 +- .../AppSARUtils/app/otbDespeckle.cxx | 6 +- .../app/otbConnectedComponentSegmentation.cxx | 6 +- .../app/otbHooverCompareSegmentation.cxx | 6 +- .../app/otbLSMSSegmentation.cxx | 10 +- .../app/otbLSMSSmallRegionsMerging.cxx | 6 +- .../app/otbLSMSVectorization.cxx | 6 +- .../app/otbLargeScaleMeanShift.cxx | 6 +- .../app/otbMeanShiftSmoothing.cxx | 6 +- .../AppSegmentation/app/otbSegmentation.cxx | 6 +- .../AppStereo/app/otbBlockMatching.cxx | 6 +- .../app/otbDisparityMapToElevationMap.cxx | 6 +- .../AppStereo/app/otbFineRegistration.cxx | 6 +- .../AppStereo/app/otbGeneratePlyFile.cxx | 6 +- .../AppStereo/app/otbStereoFramework.cxx | 6 +- .../otbStereoRectificationGridGenerator.cxx | 6 +- .../AppTest/app/otbTestApplication.cxx | 6 +- .../app/otbHaralickTextureExtraction.cxx | 6 +- .../app/otbSFSTextureExtraction.cxx | 6 +- .../app/otbRasterization.cxx | 6 +- .../app/otbConcatenateVectorData.cxx | 6 +- .../AppVectorUtils/app/otbOSMDownloader.cxx | 6 +- .../app/otbVectorDataExtractROI.cxx | 6 +- .../app/otbVectorDataSetField.cxx | 6 +- .../app/otbVectorDataTransform.cxx | 6 +- .../include/otbCommandLineArgumentParser.h | 6 +- .../include/otbChannelSelectorFunctor.h | 2 +- .../Common/include/otbCommandProgressUpdate.h | 4 +- .../otbComplexToIntensityImageFilter.h | 2 +- .../otbComplexToVectorImageCastFilter.h | 4 +- .../Common/include/otbDotProductImageFilter.h | 4 +- .../Common/include/otbFunctionToImageFilter.h | 6 +- .../otbImageAndVectorImageOperationFilter.h | 6 +- .../otbImageRegionAdaptativeSplitter.h | 10 +- ...RegionNonUniformMultidimensionalSplitter.h | 8 +- .../otbImageRegionSquareTileSplitter.h | 8 +- .../include/otbImageRegionTileMapSplitter.h | 8 +- ...otbImageToModulusAndDirectionImageFilter.h | 6 +- .../otbImaginaryImageToComplexImageFilter.h | 2 +- .../Common/include/otbImportImageFilter.h | 12 +- .../include/otbImportVectorImageFilter.h | 2 +- .../Common/include/otbModelComponentBase.h | 4 +- .../Common/include/otbModelComponentBase.txx | 2 +- .../include/otbQuaternaryFunctorImageFilter.h | 6 +- .../Common/include/otbRGBAPixelConverter.h | 12 +- Modules/Core/Common/include/otbRectangle.h | 4 +- .../Common/include/otbStandardFilterWatcher.h | 6 +- .../include/otbStandardOneLineFilterWatcher.h | 6 +- .../Common/include/otbStandardWriterWatcher.h | 12 +- .../otbSubsampledImageRegionConstIterator.h | 2 +- .../include/otbUnaryFunctorImageFilter.h | 4 +- ...naryFunctorNeighborhoodVectorImageFilter.h | 6 +- .../otbUnaryFunctorVectorImageFilter.h | 6 +- ...unctorWithIndexWithOutputSizeImageFilter.h | 8 +- .../otbVariableLengthVectorConverter.h | 24 +-- .../include/otbVectorImageToASImageAdaptor.h | 2 +- .../Core/ImageBase/include/otbExtractROI.h | 8 +- .../ImageBase/include/otbExtractROIBase.h | 12 +- Modules/Core/ImageBase/include/otbImage.h | 6 +- .../include/otbImageFunctionAdaptor.h | 10 +- .../Core/ImageBase/include/otbImageIOBase.h | 4 +- ...otbImageOfVectorsToMonoChannelExtractROI.h | 8 +- .../ImageBase/include/otbMetaImageFunction.h | 6 +- .../include/otbMultiChannelExtractROI.h | 8 +- .../include/otbMultiToMonoChannelExtractROI.h | 8 +- .../include/otbRemoteSensingRegion.h | 6 +- .../Core/ImageBase/include/otbVectorImage.h | 6 +- .../include/otbBCOInterpolateImageFunction.h | 18 +- .../otbBSplineDecompositionImageFilter.h | 6 +- .../otbBSplineInterpolateImageFunction.h | 8 +- .../otbGenericInterpolateImageFunction.h | 8 +- .../otbProlateInterpolateImageFunction.h | 4 +- ...owedSincInterpolateImageBlackmanFunction.h | 4 +- ...ndowedSincInterpolateImageCosineFunction.h | 4 +- ...WindowedSincInterpolateImageFunctionBase.h | 4 +- ...owedSincInterpolateImageGaussianFunction.h | 4 +- ...dowedSincInterpolateImageHammingFunction.h | 4 +- ...dowedSincInterpolateImageLanczosFunction.h | 4 +- ...indowedSincInterpolateImageWelchFunction.h | 4 +- .../include/otbAttributesMapLabelObject.h | 4 +- ...tbAttributesMapLabelObjectWithClassLabel.h | 6 +- .../otbAttributesMapOpeningLabelMapFilter.h | 6 +- ...bBandsStatisticsAttributesLabelMapFilter.h | 12 +- .../otbImageToLabelMapWithAttributesFilter.h | 8 +- .../otbKMeansAttributesLabelMapFilter.h | 2 +- ...bLabelImageToLabelMapWithAdjacencyFilter.h | 14 +- .../otbLabelMapFeaturesFunctorImageFilter.h | 6 +- .../Core/LabelMap/include/otbLabelMapSource.h | 4 +- .../otbLabelMapToAttributeImageFilter.h | 8 +- .../include/otbLabelMapToSampleListFilter.h | 8 +- .../include/otbLabelMapWithAdjacency.h | 6 +- ...MapWithClassLabelToClassLabelImageFilter.h | 6 +- ...pWithClassLabelToLabeledSampleListFilter.h | 8 +- .../otbMinMaxAttributesLabelMapFilter.h | 6 +- .../otbNormalizeAttributesLabelMapFilter.h | 4 +- .../otbShapeAttributesLabelMapFilter.h | 12 +- .../otbStatisticsAttributesLabelMapFilter.h | 6 +- .../otbDefaultImageMetadataInterface.h | 24 +-- .../otbDefaultImageMetadataInterfaceFactory.h | 6 +- .../otbFormosatImageMetadataInterface.h | 42 ++-- ...otbFormosatImageMetadataInterfaceFactory.h | 6 +- .../include/otbIkonosImageMetadataInterface.h | 40 ++-- .../otbIkonosImageMetadataInterfaceFactory.h | 6 +- .../include/otbImageMetadataInterfaceBase.h | 4 +- .../otbImageMetadataInterfaceFactory.h | 2 +- .../otbOpticalDefaultImageMetadataInterface.h | 40 ++-- ...icalDefaultImageMetadataInterfaceFactory.h | 6 +- .../otbOpticalImageMetadataInterface.h | 6 +- .../otbOpticalImageMetadataInterfaceFactory.h | 2 +- .../otbPleiadesImageMetadataInterface.h | 42 ++-- ...otbPleiadesImageMetadataInterfaceFactory.h | 6 +- .../otbQuickBirdImageMetadataInterface.h | 40 ++-- ...tbQuickBirdImageMetadataInterfaceFactory.h | 6 +- .../otbRadarsat2ImageMetadataInterface.h | 38 ++-- ...tbRadarsat2ImageMetadataInterfaceFactory.h | 6 +- .../include/otbSarCalibrationLookupData.h | 4 +- .../otbSarDefaultImageMetadataInterface.h | 52 ++--- ...bSarDefaultImageMetadataInterfaceFactory.h | 6 +- .../include/otbSarImageMetadataInterface.h | 6 +- .../otbSarImageMetadataInterfaceFactory.h | 2 +- .../otbSentinel1ImageMetadataInterface.h | 36 ++-- ...tbSentinel1ImageMetadataInterfaceFactory.h | 6 +- .../include/otbSpot6ImageMetadataInterface.h | 42 ++-- .../otbSpot6ImageMetadataInterfaceFactory.h | 6 +- .../include/otbSpotImageMetadataInterface.h | 42 ++-- .../otbSpotImageMetadataInterfaceFactory.h | 6 +- .../otbTerraSarImageMetadataInterface.h | 42 ++-- ...otbTerraSarImageMetadataInterfaceFactory.h | 6 +- .../otbWorldView2ImageMetadataInterface.h | 40 ++-- ...bWorldView2ImageMetadataInterfaceFactory.h | 6 +- .../Core/ObjectList/include/otbImageList.h | 12 +- .../ObjectList/include/otbImageListSource.h | 4 +- .../include/otbImageListToImageFilter.h | 4 +- .../otbImageListToImageListApplyFilter.h | 10 +- .../include/otbImageListToImageListFilter.h | 4 +- .../include/otbImageListToSingleImageFilter.h | 6 +- .../include/otbImageListToVectorImageFilter.h | 10 +- .../include/otbImageToImageListFilter.h | 4 +- .../Core/ObjectList/include/otbObjectList.h | 4 +- .../ObjectList/include/otbObjectListSource.h | 8 +- .../include/otbObjectListSource.txx | 2 +- .../include/otbObjectListToObjectListFilter.h | 6 +- .../otbObjectListToObjectListFilter.txx | 4 +- .../otbUnaryFunctorObjectListBooleanFilter.h | 6 +- .../include/otbUnaryFunctorObjectListFilter.h | 6 +- .../include/otbVectorImageToImageListFilter.h | 10 +- .../include/otbImageToPointSetFilter.h | 8 +- .../include/otbImageToPointSetFilter.txx | 4 +- .../PointSet/include/otbPointSetExtractROI.h | 6 +- .../PointSet/include/otbPointSetFunction.h | 4 +- .../Core/PointSet/include/otbPointSetSource.h | 8 +- .../include/otbPointSetToPointSetFilter.h | 4 +- .../include/otbRandomPointSetSource.h | 4 +- .../otbThresholdImageToPointSetFilter.h | 6 +- .../include/otbTransformPointSetFilter.h | 6 +- .../include/otbDrawLineSpatialObjectFilter.h | 6 +- .../otbDrawLineSpatialObjectListFilter.h | 6 +- .../otbImageToLineSpatialObjectListFilter.h | 4 +- .../include/otbLineSpatialObject.h | 18 +- .../include/otbLineSpatialObjectList.h | 2 +- ...otbLineSpatialObjectListToPointSetFilter.h | 4 +- .../include/otbSpatialObjectSource.h | 4 +- .../otbSpatialObjectToImageDrawingFilter.h | 8 +- ...umberOfDivisionsStrippedStreamingManager.h | 4 +- ...tbNumberOfDivisionsTiledStreamingManager.h | 4 +- ...otbNumberOfLinesStrippedStreamingManager.h | 4 +- .../otbPersistentFilterStreamingDecorator.h | 8 +- .../include/otbPersistentImageFilter.h | 4 +- .../otbPipelineMemoryPrintCalculator.h | 4 +- .../otbRAMDrivenAdaptativeStreamingManager.h | 4 +- .../otbRAMDrivenStrippedStreamingManager.h | 4 +- .../otbRAMDrivenTiledStreamingManager.h | 4 +- .../include/otbStreamingImageVirtualWriter.h | 10 +- .../Streaming/include/otbStreamingManager.h | 2 +- .../otbTileDimensionTiledStreamingManager.h | 4 +- .../Transform/include/otbCompositeTransform.h | 4 +- .../Transform/include/otbForwardSensorModel.h | 6 +- .../include/otbGenericMapProjection.h | 6 +- .../Transform/include/otbGenericRSTransform.h | 14 +- .../include/otbGeocentricTransform.h | 4 +- .../otbImageToGenericRSOutputParameters.h | 2 +- .../include/otbInverseLogPolarTransform.h | 18 +- .../Transform/include/otbInverseSensorModel.h | 6 +- .../Transform/include/otbLogPolarTransform.h | 18 +- .../Transform/include/otbSensorModelBase.h | 4 +- .../include/otbStreamingWarpImageFilter.h | 10 +- Modules/Core/Transform/include/otbTransform.h | 38 ++-- .../Core/VectorDataBase/include/otbDataNode.h | 4 +- .../include/otbDataNodeFunctionBase.h | 6 +- .../include/otbDataNodeImageFunction.h | 6 +- .../include/otbDataNodeVectorDataFunction.h | 6 +- .../otbPolyLineParametricPathWithValue.h | 6 +- .../Core/VectorDataBase/include/otbPolygon.h | 10 +- .../VectorDataBase/include/otbVectorData.h | 6 +- .../include/otbVectorDataIOBase.h | 4 +- .../include/otbVectorDataProperties.h | 4 +- .../include/otbVectorDataSource.h | 4 +- .../include/otbCloudDetectionFilter.h | 6 +- .../include/otbCloudEstimatorFilter.h | 6 +- .../otbDescriptorsListSampleGenerator.h | 26 +-- .../include/otbFlusserMomentsIFFactory.h | 4 +- .../otbFourierMellinDescriptorsIFFactory.h | 4 +- .../include/otbHaralickTexturesIFFactory.h | 4 +- .../otbLabeledSampleLocalizationGenerator.h | 6 +- .../include/otbLocalHistogramIFFactory.h | 4 +- .../include/otbObjectDetectionClassifier.h | 26 +-- .../include/otbRadiometricMomentsIFFactory.h | 4 +- .../otbStandardMetaImageFunctionBuilder.h | 4 +- .../include/otbBreakAngularPathListFilter.h | 6 +- .../include/otbGenericRoadExtractionFilter.h | 6 +- .../include/otbImageToPathListAlignFilter.h | 8 +- .../include/otbLikelihoodPathListFilter.h | 6 +- .../include/otbLinkPathListFilter.h | 6 +- ...otbModulusAndDirectionImageToImageFilter.h | 6 +- .../otbNeighborhoodScalarProductFilter.h | 6 +- .../otbNonMaxRemovalByDirectionFilter.h | 6 +- .../include/otbParallelLinePathListFilter.h | 6 +- .../otbRemoveIsolatedByDirectionFilter.h | 6 +- .../include/otbRemoveWrongDirectionFilter.h | 6 +- .../include/otbRoadExtractionFilter.h | 6 +- .../otbVectorDataToRoadDescriptionFilter.h | 6 +- .../otbUrbanAreaDetectionImageFilter.h | 4 +- .../Corner/include/otbHarrisImageFilter.h | 6 +- .../include/otbHarrisImageToPointSetFilter.h | 6 +- ...tialObjectListToRightAnglePointSetFilter.h | 8 +- ...tbVectorDataToRightAngleVectorDataFilter.h | 6 +- .../include/otbKeyPointDensityImageFilter.h | 6 +- .../otbPointSetDensityEpanechnikovFunction.h | 6 +- .../include/otbPointSetDensityFunction.h | 6 +- .../otbPointSetDensityGaussianFunction.h | 6 +- .../include/otbPointSetToDensityImageFilter.h | 10 +- ...ForwardFourierMellinTransformImageFilter.h | 10 +- ...otbFourierMellinDescriptorsImageFunction.h | 10 +- .../include/otbHessianToScalarImageFilter.h | 2 +- ...OfOrientedGradientCovariantImageFunction.h | 10 +- .../otbImageToHessianDeterminantImageFilter.h | 6 +- .../include/otbImageToSIFTKeyPointSetFilter.h | 6 +- .../include/otbImageToSURFKeyPointSetFilter.h | 6 +- .../include/otbKeyPointSetsMatchingFilter.h | 6 +- .../Feature/Descriptors/include/otbLandmark.h | 4 +- .../include/otbSiftFastImageFilter.h | 6 +- .../otbAssociativeSymmetricalSumImageFilter.h | 2 +- ...symmetricFusionOfLineDetectorImageFilter.h | 6 +- .../Edge/include/otbEdgeDensityImageFilter.h | 6 +- .../Edge/include/otbEdgeDetectorImageFilter.h | 6 +- .../include/otbExtractSegmentsImageFilter.h | 6 +- .../Feature/Edge/include/otbFillGapsFilter.h | 6 +- .../otbHorizontalSobelVectorImageFilter.h | 2 +- .../otbHoughTransform2DLinesImageFilter.h | 12 +- .../otbLineCorrelationDetectorImageFilter.h | 6 +- .../include/otbLineDetectorImageFilterBase.h | 10 +- .../include/otbLineRatioDetectorImageFilter.h | 6 +- .../Edge/include/otbLineSegmentDetector.h | 8 +- .../Edge/include/otbLocalHoughFilter.h | 6 +- .../otbPersistentVectorizationImageFilter.h | 10 +- ...tbPixelSuppressionByDirectionImageFilter.h | 8 +- .../Edge/include/otbSobelVectorImageFilter.h | 2 +- .../include/otbStreamingLineSegmentDetector.h | 6 +- .../include/otbTouziEdgeDetectorImageFilter.h | 10 +- .../otbVerticalSobelVectorImageFilter.h | 2 +- .../include/otbComplexMomentPathFunction.h | 6 +- .../include/otbComplexMomentsImageFunction.h | 10 +- .../include/otbFlusserMomentsImageFunction.h | 10 +- .../Moments/include/otbFlusserPathFunction.h | 6 +- .../include/otbGeometricMomentPathFunction.h | 4 +- .../include/otbHuMomentsImageFunction.h | 10 +- .../Moments/include/otbHuPathFunction.h | 6 +- .../otbRadiometricMomentsImageFilter.h | 8 +- .../otbRadiometricMomentsImageFunction.h | 10 +- .../include/otbRealMomentPathFunction.h | 4 +- .../include/otbRealMomentsImageFunction.h | 10 +- .../include/otbAddCarvingPathFilter.h | 10 +- .../include/otbImageToCarvingPathFilter.h | 8 +- .../include/otbRemoveCarvingPathFilter.h | 8 +- .../otbGreyLevelCooccurrenceIndexedList.h | 4 +- .../otbHaralickTexturesImageFunction.h | 10 +- .../include/otbSFSTexturesImageFilter.h | 12 +- .../otbScalarImageToAdvancedTexturesFilter.h | 10 +- ...tbScalarImageToHigherOrderTexturesFilter.h | 8 +- .../otbScalarImageToPanTexTextureFilter.h | 6 +- .../include/otbScalarImageToTexturesFilter.h | 10 +- .../include/otbTextureImageFunction.h | 10 +- ...ctorNeighborhoodJoinHistogramImageFilter.h | 8 +- .../include/otbCBAMIChangeDetector.h | 2 +- .../include/otbCorrelationChangeDetector.h | 2 +- .../include/otbJoinHistogramMIImageFilter.h | 2 +- .../otbKullbackLeiblerDistanceImageFilter.h | 2 +- .../otbKullbackLeiblerProfileImageFilter.h | 2 +- ...backLeiblerSupervizedDistanceImageFilter.h | 4 +- .../include/otbLHMIChangeDetector.h | 2 +- .../include/otbMeanDifferenceImageFilter.h | 2 +- .../include/otbMeanRatioImageFilter.h | 2 +- ...ultivariateAlterationDetectorImageFilter.h | 6 +- .../include/otbReliefColormapFunctor.h | 4 +- .../otbScalarToRainbowRGBPixelFunctor.h | 4 +- .../include/otbConvolutionImageFilter.h | 8 +- .../include/otbGaborFilterGenerator.h | 6 +- .../otbOverlapSaveConvolutionImageFilter.h | 8 +- .../include/otbDEMCaracteristicsExtractor.h | 6 +- .../DEM/include/otbDEMToImageGenerator.h | 10 +- .../otbAngularProjectionBinaryImageFilter.h | 6 +- .../include/otbAngularProjectionImageFilter.h | 6 +- .../otbAngularProjectionSetImageFilter.h | 4 +- .../otbEstimateInnerProductPCAImageFilter.h | 10 +- .../include/otbFastICAImageFilter.h | 6 +- ...astICAInternalOptimizerVectorImageFilter.h | 10 +- .../include/otbInnerProductPCAImageFilter.h | 8 +- .../otbLocalActivityVectorImageFilter.h | 2 +- .../include/otbMNFImageFilter.h | 8 +- ...bMaximumAutocorrelationFactorImageFilter.h | 6 +- .../include/otbNAPCAImageFilter.h | 4 +- .../otbNormalizeInnerProductPCAImageFilter.h | 10 +- .../include/otbPCAImageFilter.h | 8 +- .../otbSparseWvltToAngleMapperListFilter.h | 8 +- .../include/otbAmplitudeFunctor.h | 12 +- .../include/otbBinaryFunctorImageFilter.h | 4 +- .../otbBinaryFunctorNeighborhoodImageFilter.h | 6 +- ...naryFunctorNeighborhoodVectorImageFilter.h | 6 +- .../include/otbBinaryImageDensityFunction.h | 10 +- ...naryImageMinimalBoundingRegionCalculator.h | 6 +- .../otbBinaryImageToDensityImageFilter.h | 10 +- .../include/otbBoxAndWhiskerImageFilter.h | 8 +- .../include/otbChangeInformationImageFilter.h | 4 +- .../include/otbChangeLabelImageFilter.h | 6 +- .../include/otbChangeNoDataValueFilter.h | 4 +- .../include/otbClampVectorImageFilter.h | 8 +- .../otbConcatenateScalarValueImageFilter.h | 6 +- .../include/otbConcatenateVectorImageFilter.h | 10 +- ...bEuclideanDistanceMetricWithMissingValue.h | 6 +- ...lideanDistanceMetricWithMissingValuePow2.h | 6 +- .../otbFlexibleDistanceWithMissingValue.h | 6 +- ...otbFunctionWithNeighborhoodToImageFilter.h | 8 +- .../include/otbGridResampleImageFilter.h | 16 +- .../include/otbHillShadingFilter.h | 2 +- .../include/otbImageToNoDataMaskFilter.h | 4 +- .../include/otbImageToVectorImageCastFilter.h | 6 +- .../otbLocalGradientVectorImageFilter.h | 2 +- .../include/otbLog10ThresholdedImageFilter.h | 2 +- .../include/otbMatrixImageFilter.h | 8 +- .../include/otbMultiplyByScalarImageFilter.h | 2 +- .../otbNRIBandImagesToOneNComplexBandsImage.h | 10 +- .../otbOneRIBandImageToOneComplexBandImage.h | 8 +- .../include/otbPerBandVectorImageFilter.h | 10 +- .../include/otbPhaseFunctor.h | 12 +- .../include/otbPrintableImageFilter.h | 6 +- ...ealAndImaginaryImageToComplexImageFilter.h | 2 +- .../otbRealImageToComplexImageFilter.h | 2 +- .../include/otbShiftScaleImageAdaptor.h | 2 +- .../include/otbShiftScaleVectorImageFilter.h | 8 +- .../otbSpectralAngleDistanceImageFilter.h | 8 +- .../include/otbSqrtSpectralAngleFunctor.h | 4 +- ...tbStreamingInnerProductVectorImageFilter.h | 18 +- ...treamingMatrixTransposeMatrixImageFilter.h | 20 +- .../include/otbStreamingResampleImageFilter.h | 10 +- .../include/otbStreamingShrinkImageFilter.h | 34 +-- .../include/otbTernaryFunctorImageFilter.h | 4 +- .../include/otbThresholdVectorImageFilter.h | 8 +- .../include/otbTileImageFilter.h | 12 +- .../otbTwoNRIBandsImageToNComplexBandsImage.h | 10 +- .../otbUnaryFunctorNeighborhoodImageFilter.h | 6 +- ...FunctorNeighborhoodWithOffsetImageFilter.h | 8 +- .../otbUnaryFunctorWithIndexImageFilter.h | 6 +- ...tbUnaryImageFunctorWithVectorImageFilter.h | 8 +- .../otbVectorImageTo3DScalarImageFilter.h | 10 +- .../otbVectorImageToAmplitudeImageFilter.h | 4 +- .../otbVectorRescaleIntensityImageFilter.h | 10 +- .../ImageNoise/include/otbFrostImageFilter.h | 8 +- .../include/otbGammaMAPImageFilter.h | 8 +- .../ImageNoise/include/otbKuanImageFilter.h | 8 +- .../ImageNoise/include/otbLeeImageFilter.h | 8 +- .../include/otbBandMathImageFilter.h | 10 +- .../include/otbMaskMuParserFilter.h | 10 +- .../include/otbMaskMuParserFunctor.h | 2 +- .../Filtering/MathParser/include/otbParser.h | 4 +- ...tbParserConditionDataNodeFeatureFunction.h | 6 +- .../Filtering/MathParser/src/otbParser.cxx | 4 +- .../include/otbBandMathXImageFilter.h | 14 +- .../MathParserX/include/otbParserX.h | 4 +- .../MathParserX/include/otbParserXPlugins.h | 198 +++++++++--------- .../Filtering/MathParserX/src/otbParserX.cxx | 4 +- .../otbMorphologicalPyramidAnalysisFilter.h | 10 +- .../otbMorphologicalPyramidMRToMSConverter.h | 12 +- .../otbMorphologicalPyramidResampler.h | 12 +- ...tbMorphologicalPyramidSegmentationFilter.h | 8 +- .../otbMorphologicalPyramidSegmenter.h | 8 +- .../otbMorphologicalPyramidSynthesisFilter.h | 8 +- .../Path/include/otbCompacityPathFunction.h | 6 +- .../Path/include/otbDrawPathFilter.h | 6 +- .../Path/include/otbDrawPathListFilter.h | 6 +- .../otbImageFittingPolygonListFilter.h | 6 +- .../Path/include/otbImageToEdgePathFilter.h | 8 +- .../Path/include/otbImageToPathFilter.h | 4 +- .../Path/include/otbImageToPathListFilter.h | 4 +- .../Path/include/otbOrientationPathFunction.h | 6 +- .../Filtering/Path/include/otbPathFunction.h | 4 +- .../Path/include/otbPathListSource.h | 2 +- .../include/otbPathListToHistogramGenerator.h | 8 +- .../include/otbPathListToPathListFilter.h | 2 +- .../Path/include/otbPolyLineImageIterator.h | 2 +- ...tbRegionImageToRectangularPathListFilter.h | 8 +- .../include/otbVectorizationPathListFilter.h | 6 +- ...rToPolarisationDegreeAndPowerImageFilter.h | 2 +- ...MuellerToReciprocalCovarianceImageFilter.h | 2 +- ...MultiChannelsPolarimetricSynthesisFilter.h | 10 +- .../Polarimetry/include/otbPolarimetricData.h | 4 +- .../otbReciprocalBarnesDecompImageFilter.h | 2 +- ...lCoherencyToReciprocalMuellerImageFilter.h | 2 +- ...alCovarianceToCoherencyDegreeImageFilter.h | 2 +- ...varianceToReciprocalCoherencyImageFilter.h | 2 +- .../include/otbReciprocalHAlphaImageFilter.h | 2 +- .../otbReciprocalHuynenDecompImageFilter.h | 2 +- ...oReciprocalCircularCovarianceImageFilter.h | 2 +- .../otbReciprocalPauliDecompImageFilter.h | 2 +- .../include/otbSinclairImageFilter.h | 6 +- .../otbSinclairReciprocalImageFilter.h | 6 +- .../include/otbEckert4MapProjection.h | 2 +- .../otbGCPsToRPCSensorModelImageFilter.h | 8 +- .../include/otbGenericRSResampleImageFilter.h | 10 +- .../otbGenericRSResampleImageFilter.txx | 2 +- .../include/otbGeographicalDistance.h | 8 +- .../include/otbGeometriesProjectionFilter.h | 12 +- .../include/otbGroundSpacingImageFunction.h | 10 +- .../otbImageToEnvelopeVectorDataFilter.h | 8 +- .../otbImportGeoInformationImageFilter.h | 10 +- .../include/otbLambert2EtenduProjection.h | 2 +- .../include/otbLambert93Projection.h | 2 +- .../otbLambertConformalConicMapProjection.h | 2 +- .../otbLeastSquareAffineTransformEstimator.h | 4 +- .../include/otbMollweidMapProjection.h | 2 +- .../include/otbOrthoRectificationFilter.h | 8 +- .../otbPhysicalToRPCSensorModelImageFilter.h | 8 +- .../otbProjectiveProjectionImageFilter.h | 6 +- .../Projection/include/otbROIdataConversion.h | 10 +- .../Projection/include/otbRationalTransform.h | 10 +- .../include/otbSVY21MapProjection.h | 2 +- .../include/otbSinusoidalMapProjection.h | 2 +- .../Projection/include/otbTileMapTransform.h | 4 +- .../include/otbTransMercatorMapProjection.h | 2 +- .../Projection/include/otbUtmMapProjection.h | 2 +- .../otbVectorDataIntoImageProjectionFilter.h | 4 +- .../include/otbVectorDataProjectionFilter.h | 14 +- .../include/otbVectorDataTransformFilter.h | 12 +- .../otbMeanShiftSmoothingImageFilter.h | 16 +- .../include/otbConcatenateSampleListFilter.h | 6 +- ...bContinuousMinimumMaximumImageCalculator.h | 4 +- ...otbGaussianAdditiveNoiseSampleListFilter.h | 6 +- .../include/otbHistogramStatisticsFunction.h | 6 +- .../include/otbListSampleGenerator.h | 10 +- .../Statistics/include/otbListSampleSource.h | 6 +- .../otbListSampleToBalancedListSampleFilter.h | 8 +- .../otbListSampleToHistogramListGenerator.h | 8 +- .../include/otbListSampleToListSampleFilter.h | 4 +- ...pleToVariableDimensionHistogramGenerator.h | 8 +- .../include/otbLocalHistogramImageFunction.h | 10 +- .../include/otbNormalizeVectorImageFilter.h | 4 +- .../Statistics/include/otbPatternSampler.h | 4 +- .../Statistics/include/otbPeriodicSampler.h | 4 +- .../Statistics/include/otbRandomSampler.h | 4 +- .../Statistics/include/otbSamplerBase.h | 2 +- .../include/otbShiftScaleSampleListFilter.h | 6 +- .../include/otbStreamingCompareImageFilter.h | 20 +- .../otbStreamingHistogramVectorImageFilter.h | 18 +- .../include/otbStreamingMinMaxImageFilter.h | 18 +- .../otbStreamingMinMaxVectorImageFilter.h | 18 +- .../otbStreamingStatisticsImageFilter.h | 18 +- ...reamingStatisticsMapFromLabelImageFilter.h | 20 +- .../otbStreamingStatisticsVectorImageFilter.h | 18 +- .../include/otbVarianceImageFilter.h | 8 +- .../otbVectorImageToIntensityImageFilter.h | 6 +- .../otbVectorImageToMatrixImageFilter.h | 18 +- .../include/otbConcatenateVectorDataFilter.h | 6 +- .../otbDBOverlapDataNodeFeatureFunction.h | 6 +- ...sWithNeighborhoodDataNodeFeatureFunction.h | 6 +- .../otbSpectralAngleDataNodeFeatureFunction.h | 6 +- .../include/otbVectorDataAdapter.h | 10 +- .../include/otbVectorDataExtractROI.h | 6 +- .../otbVectorDataToRandomLineGenerator.h | 6 +- ...ectorDataToSpecificDescriptionFilterBase.h | 4 +- .../include/otbVectorDataToVectorDataFilter.h | 8 +- .../Wavelet/include/otbSubsampleImageFilter.h | 14 +- .../Wavelet/include/otbWaveletFilterBank.h | 34 +-- .../Wavelet/include/otbWaveletGenerator.h | 2 +- .../include/otbWaveletHighPassOperator.h | 4 +- .../Wavelet/include/otbWaveletImageFilter.h | 6 +- .../include/otbWaveletInverseImageFilter.h | 8 +- .../include/otbWaveletLowPassOperator.h | 4 +- .../Wavelet/include/otbWaveletOperatorBase.h | 6 +- .../otbWaveletPacketDecompositionCosts.h | 2 +- .../include/otbWaveletPacketTransform.h | 10 +- .../Wavelet/include/otbWaveletTransform.h | 10 +- ...tsBandsListToWaveletsSynopsisImageFilter.h | 8 +- ...tsSynopsisImageToWaveletsBandsListFilter.h | 10 +- .../Fusion/Fuzzy/include/otbFuzzyVariable.h | 4 +- ...otbNeighborhoodMajorityVotingImageFilter.h | 6 +- .../include/otbBayesianFusionFilter.h | 6 +- .../otbLmvmPanSharpeningFusionImageFilter.h | 6 +- ...bSimpleRcsPanSharpeningFusionImageFilter.h | 6 +- .../include/otbLocalRxDetectorFilter.h | 10 +- .../otbLocalRxDetectorNonThreadFilter.h | 8 +- .../otbEigenvalueLikelihoodMaximisation.h | 4 +- .../include/otbVcaImageFilter.h | 12 +- .../include/otbVirtualDimensionality.h | 4 +- .../include/otbISRAUnmixingImageFilter.h | 4 +- .../Unmixing/include/otbMDMDNMFImageFilter.h | 10 +- .../include/otbNCLSUnmixingImageFilter.h | 4 +- .../include/otbSparseUnmixingImageFilter.h | 4 +- .../otbUnConstrainedLeastSquareImageFilter.h | 4 +- .../IO/Carto/include/otbCoordinateToName.h | 4 +- .../otbImageToOSMVectorDataGenerator.h | 4 +- .../Carto/include/otbMapFileProductWriter.h | 6 +- .../include/otbOSMDataToVectorDataGenerator.h | 4 +- .../IO/Carto/include/otbPlaceNameToLonLat.h | 4 +- Modules/IO/Carto/include/otbWorldFile.h | 2 +- .../include/otbExtendedFilenameHelper.h | 2 +- .../otbExtendedFilenameToReaderOptions.h | 4 +- .../otbExtendedFilenameToWriterOptions.h | 4 +- Modules/IO/IOBSQ/include/otbBSQImageIO.h | 26 +-- .../IO/IOBSQ/include/otbBSQImageIOFactory.h | 6 +- .../IO/IOGDAL/include/otbGDALDatasetWrapper.h | 2 +- Modules/IO/IOGDAL/include/otbGDALImageIO.h | 26 +-- .../IO/IOGDAL/include/otbGDALImageIOFactory.h | 6 +- .../IOGDAL/include/otbGDALOverviewsBuilder.h | 6 +- Modules/IO/IOGDAL/include/otbOGRIOHelper.h | 2 +- .../IO/IOGDAL/include/otbOGRVectorDataIO.h | 12 +- .../include/otbOGRVectorDataIOFactory.h | 6 +- Modules/IO/IOKML/include/otbKMLVectorDataIO.h | 12 +- .../IOKML/include/otbKMLVectorDataIOFactory.h | 6 +- Modules/IO/IOLUM/include/otbLUMImageIO.h | 26 +-- .../IO/IOLUM/include/otbLUMImageIOFactory.h | 6 +- Modules/IO/IOMSTAR/include/otbMSTARImageIO.h | 26 +-- .../IOMSTAR/include/otbMSTARImageIOFactory.h | 6 +- Modules/IO/IOONERA/include/otbONERAImageIO.h | 26 +-- .../IOONERA/include/otbONERAImageIOFactory.h | 6 +- Modules/IO/IORAD/include/otbRADImageIO.h | 26 +-- .../IO/IORAD/include/otbRADImageIOFactory.h | 6 +- .../IO/IOTileMap/include/otbTileMapImageIO.h | 30 +-- .../include/otbTileMapImageIOFactory.h | 6 +- .../include/otbTileMapImageIOHelper.h | 2 +- .../include/otbStatisticsXMLFileReader.h | 6 +- .../include/otbStatisticsXMLFileWriter.h | 4 +- .../IO/ImageIO/include/otbImageFileReader.h | 10 +- .../IO/ImageIO/include/otbImageFileWriter.h | 8 +- .../IO/ImageIO/include/otbImageIOFactory.h | 2 +- .../include/otbImageSeriesFileReader.h | 10 +- .../include/otbImageSeriesFileReaderBase.h | 10 +- .../otbScalarBufferToImageFileWriter.h | 8 +- .../KMZWriter/include/otbKmzProductWriter.h | 6 +- .../include/otbDifferenceImageFilter.h | 12 +- Modules/IO/TestKernel/include/otbTestHelper.h | 2 +- .../include/otbVectorDataFileReader.h | 8 +- .../include/otbVectorDataFileWriter.h | 8 +- .../include/otbVectorDataIOFactory.h | 2 +- .../otbConfusionMatrixToMassOfBelief.h | 6 +- .../otbDSFusionOfClassifiersImageFilter.h | 10 +- .../include/otbJointMassOfBeliefFilter.h | 10 +- .../DempsterShafer/include/otbMassOfBelief.h | 4 +- .../include/otbStandardDSCostFunction.h | 10 +- ...bVectorDataToDSValidatedVectorDataFilter.h | 6 +- .../include/otbAutoencoderModel.h | 16 +- .../include/otbAutoencoderModelFactory.h | 6 +- .../otbDimensionalityReductionModelFactory.h | 2 +- .../otbImageDimensionalityReductionFilter.h | 10 +- .../include/otbPCAModel.h | 16 +- .../include/otbPCAModelFactory.h | 6 +- .../include/otbSOMModel.h | 14 +- .../include/otbSOMModelFactory.h | 6 +- .../LearningBase/include/otbDecisionTree.h | 4 +- .../include/otbGaussianModelComponent.h | 10 +- .../include/otbImageClassificationFilter.h | 8 +- .../otbKMeansImageClassificationFilter.h | 8 +- .../include/otbMachineLearningModel.h | 4 +- .../otbMachineLearningModelFactoryBase.h | 2 +- .../LearningBase/include/otbSEMClassifier.h | 8 +- .../Learning/Markov/include/otbMRFEnergy.h | 4 +- .../Markov/include/otbMRFEnergyEdgeFidelity.h | 4 +- .../otbMRFEnergyFisherClassification.h | 6 +- .../Markov/include/otbMRFEnergyGaussian.h | 4 +- .../otbMRFEnergyGaussianClassification.h | 6 +- .../Markov/include/otbMRFEnergyPotts.h | 4 +- .../Learning/Markov/include/otbMRFOptimizer.h | 2 +- .../Markov/include/otbMRFOptimizerICM.h | 4 +- .../include/otbMRFOptimizerMetropolis.h | 4 +- .../Learning/Markov/include/otbMRFSampler.h | 2 +- .../Markov/include/otbMRFSamplerMAP.h | 4 +- .../Markov/include/otbMRFSamplerRandom.h | 4 +- .../Markov/include/otbMRFSamplerRandomMAP.h | 6 +- .../include/otbMarkovRandomFieldFilter.h | 12 +- Modules/Learning/SOM/include/otbPeriodicSOM.h | 14 +- Modules/Learning/SOM/include/otbSOM.h | 10 +- .../SOM/include/otbSOMActivationBuilder.h | 6 +- .../Learning/SOM/include/otbSOMClassifier.h | 6 +- .../include/otbSOMImageClassificationFilter.h | 8 +- Modules/Learning/SOM/include/otbSOMMap.h | 4 +- .../SOM/include/otbSOMWithMissingValue.h | 14 +- .../SOM/include/otbSOMbasedImageFilter.h | 4 +- .../include/otbImageSampleExtractorFilter.h | 14 +- .../otbOGRDataToClassStatisticsFilter.h | 14 +- .../otbOGRDataToSamplePositionFilter.h | 16 +- .../include/otbPersistentSamplingFilterBase.h | 10 +- .../include/otbSamplingRateCalculator.h | 4 +- .../include/otbSamplingRateCalculatorList.h | 2 +- .../include/otbBoostMachineLearningModel.h | 16 +- .../otbBoostMachineLearningModelFactory.h | 6 +- .../include/otbConfusionMatrixCalculator.h | 4 +- .../include/otbConfusionMatrixMeasurements.h | 2 +- .../Supervised/include/otbCvRTreesWrapper.h | 2 +- .../otbDecisionTreeMachineLearningModel.h | 16 +- ...bDecisionTreeMachineLearningModelFactory.h | 6 +- .../otbExhaustiveExponentialOptimizer.h | 6 +- ...bGradientBoostedTreeMachineLearningModel.h | 16 +- ...ntBoostedTreeMachineLearningModelFactory.h | 6 +- ...otbKNearestNeighborsMachineLearningModel.h | 16 +- ...restNeighborsMachineLearningModelFactory.h | 6 +- .../include/otbLabelMapClassifier.h | 6 +- .../include/otbLibSVMMachineLearningModel.h | 16 +- .../otbLibSVMMachineLearningModelFactory.h | 6 +- .../include/otbMachineLearningModelFactory.h | 2 +- .../otbNeuralNetworkMachineLearningModel.h | 16 +- ...NeuralNetworkMachineLearningModelFactory.h | 6 +- .../otbNormalBayesMachineLearningModel.h | 16 +- ...tbNormalBayesMachineLearningModelFactory.h | 6 +- .../otbRandomForestsMachineLearningModel.h | 16 +- ...RandomForestsMachineLearningModelFactory.h | 6 +- .../otbSVMCrossValidationCostFunction.h | 8 +- .../include/otbSVMMachineLearningModel.h | 16 +- .../otbSVMMachineLearningModelFactory.h | 6 +- .../Supervised/include/otbSVMMarginSampler.h | 6 +- ...tbSharkRandomForestsMachineLearningModel.h | 16 +- ...RandomForestsMachineLearningModelFactory.h | 4 +- .../otbExhaustiveExponentialOptimizerTest.cxx | 8 +- .../include/otbContingencyTable.h | 4 +- .../include/otbContingencyTableCalculator.h | 4 +- .../otbSharkKMeansMachineLearningModel.h | 16 +- ...tbSharkKMeansMachineLearningModelFactory.h | 4 +- .../include/otbSimpleParallelTiffWriter.h | 4 +- .../include/otbImageListToRCC8GraphFilter.h | 4 +- ...bImageMultiSegmentationToRCC8GraphFilter.h | 6 +- .../include/otbImageToImageRCC8Calculator.h | 6 +- .../include/otbPolygonListToRCC8GraphFilter.h | 6 +- .../otbPolygonToPolygonRCC8Calculator.h | 4 +- Modules/OBIA/RCC8/include/otbRCC8Edge.h | 4 +- Modules/OBIA/RCC8/include/otbRCC8Graph.h | 4 +- .../RCC8/include/otbRCC8GraphFileReader.h | 6 +- .../RCC8/include/otbRCC8GraphFileWriter.h | 8 +- .../OBIA/RCC8/include/otbRCC8GraphSource.h | 4 +- Modules/OBIA/RCC8/include/otbRCC8VertexBase.h | 4 +- .../RCC8/include/otbRCC8VertexWithCompacity.h | 8 +- .../include/otbBuiltUpIndicesFunctor.h | 12 +- .../include/otbGAndRIndexImageFilter.h | 4 +- .../Indices/include/otbLandsatTMIndices.h | 114 +++++----- .../otbMultiChannelGAndRIndexImageFilter.h | 6 +- ...bMultiChannelRAndBAndNIRIndexImageFilter.h | 6 +- ...bMultiChannelRAndGAndNIRIndexImageFilter.h | 6 +- .../otbMultiChannelRAndNIRIndexImageFilter.h | 6 +- .../include/otbNDVIDataNodeFeatureFunction.h | 6 +- .../include/otbRAndBAndNIRIndexImageFilter.h | 4 +- .../include/otbRAndGAndNIRIndexImageFilter.h | 4 +- .../include/otbRAndNIRIndexImageFilter.h | 4 +- .../Indices/include/otbSoilIndicesFunctor.h | 24 +-- .../include/otbVegetationIndicesFunctor.h | 108 +++++----- .../Indices/include/otbWaterIndicesFunctor.h | 22 +- .../otbWaterSqrtSpectralAngleImageFilter.h | 2 +- .../otbLandsatTMSpectralRuleBasedClassifier.h | 4 +- .../include/otbAeronetData.h | 4 +- .../include/otbAeronetFileReader.h | 6 +- .../otbAtmosphericCorrectionParameters.h | 4 +- .../include/otbAtmosphericRadiativeTerms.h | 8 +- .../otbImageMetadataCorrectionParameters.h | 4 +- .../include/otbImageToRadianceImageFilter.h | 4 +- .../otbImageToReflectanceImageFilter.h | 4 +- .../include/otbRadianceToImageImageFilter.h | 4 +- .../otbRadianceToReflectanceImageFilter.h | 4 +- .../otbReflectanceToImageImageFilter.h | 4 +- .../otbReflectanceToRadianceImageFilter.h | 4 +- ...flectanceToSurfaceReflectanceImageFilter.h | 8 +- .../include/otbSpectralSensitivityReader.h | 6 +- ...aceAdjacencyEffectCorrectionSchemeFilter.h | 8 +- .../include/otbWavelengthSpectralBands.h | 4 +- .../include/otbSarBrightnessFunction.h | 12 +- .../include/otbSarBrightnessToImageFilter.h | 6 +- .../include/otbSarDeburstImageFilter.h | 8 +- .../include/otbSarParametricMapFunction.h | 10 +- .../otbSarRadiometricCalibrationFunction.h | 12 +- ...tbSarRadiometricCalibrationToImageFilter.h | 6 +- .../otbTerraSarBrightnessImageFilter.h | 4 +- .../include/otbAtmosphericEffects.h | 2 +- .../include/otbImageSimulationMethod.h | 6 +- .../otbLabelMapToSimulatedImageFilter.h | 10 +- .../include/otbLabelToProSailParameters.h | 4 +- .../otbLabelToSimulationParametersBase.h | 2 +- .../Simulation/include/otbLeafParameters.h | 4 +- .../Simulation/include/otbProSailParameters.h | 2 +- .../Simulation/include/otbProspectModel.h | 12 +- .../include/otbReduceSpectralResponse.h | 4 +- ...bReduceSpectralResponseClassifierRAndNIR.h | 4 +- .../Simulation/include/otbSatelliteRSR.h | 4 +- .../include/otbSimulationStep1Base.h | 2 +- .../include/otbSimulationStep2Base.h | 2 +- .../include/otbSpatialisationFilter.h | 8 +- .../Simulation/include/otbSpectralResponse.h | 4 +- ...otbSurfaceReflectanceToReflectanceFilter.h | 6 +- .../include/otbDisparityMapEstimationMethod.h | 6 +- .../include/otbDisparityMapMedianFilter.h | 10 +- .../include/otbDisparityMapTo3DFilter.h | 12 +- .../include/otbDisparityMapToDEMFilter.h | 14 +- .../include/otbDisparityTranslateFilter.h | 10 +- .../include/otbFineRegistrationImageFilter.h | 8 +- .../include/otbMultiDisparityMapTo3DFilter.h | 10 +- .../include/otbNCCRegistrationFilter.h | 8 +- .../include/otbNCCRegistrationFunction.h | 14 +- .../otbPixelWiseBlockMatchingImageFilter.h | 14 +- .../include/otbSubPixelDisparityImageFilter.h | 14 +- ...nesInterpolateDisplacementFieldGenerator.h | 6 +- ...olateTransformDisplacementFieldGenerator.h | 8 +- ...earInterpolateDisplacementFieldGenerator.h | 6 +- ...earInterpolateDisplacementFieldGenerator.h | 6 +- ...tbNearestPointDisplacementFieldGenerator.h | 6 +- ...arestTransformDisplacementFieldGenerator.h | 6 +- .../otbPointSetToDisplacementFieldGenerator.h | 6 +- ...ithTransformToDisplacementFieldGenerator.h | 4 +- .../include/otbAdhesionCorrectionFilter.h | 8 +- .../include/otbBijectionCoherencyFilter.h | 8 +- .../Stereo/include/otbLineOfSightOptimizer.h | 2 +- .../Stereo/include/otbMulti3DMapToDEMFilter.h | 14 +- ...otbStereoSensorModelToElevationMapFilter.h | 10 +- ...ereorectificationDisplacementFieldSource.h | 10 +- .../otbLabelObjectOpeningMuParserFilter.h | 12 +- ...ponentSegmentationOBIAToVectorDataFilter.h | 6 +- .../otbLabelImageRegionMergingFilter.h | 10 +- .../otbLabelImageRegionPruningFilter.h | 10 +- .../otbLabelImageToOGRDataSourceFilter.h | 8 +- .../include/otbLabelImageToVectorDataFilter.h | 6 +- .../include/otbLabelMapToVectorDataFilter.h | 6 +- .../otbOGRDataSourceToLabelImageFilter.h | 8 +- .../otbPersistentImageToOGRLayerFilter.h | 12 +- .../otbPersistentImageToVectorDataFilter.h | 12 +- .../include/otbRasterizeVectorDataFilter.h | 8 +- .../include/otbVectorDataToLabelImageFilter.h | 8 +- .../include/otbVectorDataToLabelMapFilter.h | 8 +- ...VectorDataToLabelMapWithAttributesFilter.h | 8 +- .../include/otbLabelToBoundaryImageFilter.h | 2 +- ...tbLabelizeConfidenceConnectedImageFilter.h | 6 +- ...otbLabelizeConnectedThresholdImageFilter.h | 6 +- .../include/otbLabelizeImageFilterBase.h | 6 +- ...LabelizeNeighborhoodConnectedImageFilter.h | 6 +- ...hiftConnectedComponentSegmentationFilter.h | 6 +- .../include/otbMeanShiftSegmentationFilter.h | 4 +- .../Metrics/include/otbHooverInstanceFilter.h | 12 +- .../Metrics/include/otbHooverMatrixFilter.h | 6 +- .../otbClosingOpeningMorphologicalFilter.h | 6 +- .../otbConvexOrConcaveClassificationFilter.h | 8 +- ...odesicMorphologyDecompositionImageFilter.h | 6 +- ...phologyIterativeDecompositionImageFilter.h | 12 +- .../otbGeodesicMorphologyLevelingFilter.h | 6 +- .../include/otbImageToProfileFilter.h | 10 +- .../otbMorphologicalClosingProfileFilter.h | 6 +- .../otbMorphologicalOpeningProfileFilter.h | 6 +- ...bMorphologicalProfilesSegmentationFilter.h | 4 +- ...ScaleConvexOrConcaveClassificationFilter.h | 6 +- .../otbOpeningClosingMorphologicalFilter.h | 6 +- ...ivativeToMultiScaleCharacteristicsFilter.h | 10 +- .../otbProfileToProfileDerivativeFilter.h | 10 +- .../otbOGRLayerStreamStitchingFilter.h | 4 +- ...reamingImageToOGRLayerSegmentationFilter.h | 6 +- .../include/otbWatershedSegmentationFilter.h | 4 +- .../ITK/include/itkImageRegionSplitter.h | 8 +- .../itkTransformToDisplacementFieldSource.h | 16 +- .../ITK/include/itkUnaryFunctorImageFilter.h | 6 +- .../Ice/include/otbFragmentShader.h | 2 +- .../Ice/include/otbFragmentShaderRegistry.h | 2 +- .../Visualization/Ice/include/otbGlActor.h | 2 +- .../Ice/include/otbGlImageActor.h | 22 +- .../Visualization/Ice/include/otbGlROIActor.h | 10 +- .../Ice/include/otbGlVectorActor.h | 14 +- Modules/Visualization/Ice/include/otbGlView.h | 2 +- .../Ice/include/otbImageSettings.h | 2 +- .../Ice/include/otbStandardShader.h | 8 +- .../Ice/include/otbViewSettings.h | 2 +- .../IceViewer/include/otbIceViewer.h | 2 +- .../Mapla/include/mvdMaplaApplication.h | 4 +- .../Mapla/include/mvdMaplaMainWindow.h | 12 +- .../Monteverdi/include/mvdApplication.h | 4 +- .../Monteverdi/include/mvdMainWindow.h | 14 +- .../Monteverdi/include/mvdPreferencesDialog.h | 2 +- .../include/mvdAbstractImageModel.h | 4 +- .../include/mvdAbstractLayerModel.h | 4 +- .../MonteverdiCore/include/mvdAbstractModel.h | 2 +- .../include/mvdAbstractWorker.h | 2 +- .../include/mvdApplicationsBrowser.h | 2 +- .../include/mvdBackgroundTask.h | 2 +- .../include/mvdHistogramModel.h | 8 +- .../include/mvdI18nCoreApplication.h | 2 +- .../MonteverdiCore/include/mvdImageImporter.h | 6 +- .../MonteverdiCore/include/mvdMyClass.h | 2 +- .../include/mvdOverviewBuilder.h | 8 +- .../include/mvdProcessObjectObserver.h | 6 +- .../include/mvdQuicklookModel.h | 4 +- .../include/mvdStackedLayerModel.h | 2 +- .../MonteverdiCore/include/mvdSystemError.h | 2 +- .../include/mvdVectorImageModel.h | 24 +-- .../include/mvdVectorImageSettings.h | 2 +- .../MonteverdiGui/include/mvdAboutDialog.h | 2 +- .../mvdAbstractDragAndDropEventFilter.h | 4 +- .../include/mvdAbstractImageViewManipulator.h | 2 +- .../include/mvdAbstractImageViewRenderer.h | 2 +- .../include/mvdAbstractModelController.h | 2 +- .../include/mvdApplicationLauncher.h | 2 +- .../include/mvdApplicationsToolBox.h | 2 +- .../mvdApplicationsToolBoxController.h | 10 +- .../include/mvdColorBandDynamicsWidget.h | 2 +- .../include/mvdColorDynamicsController.h | 10 +- .../include/mvdColorDynamicsWidget.h | 2 +- .../include/mvdColorSetupController.h | 10 +- .../include/mvdColorSetupWidget.h | 2 +- .../include/mvdDoubleValidator.h | 4 +- .../MonteverdiGui/include/mvdDropLineEdit.h | 8 +- .../mvdFilenameDragAndDropEventFilter.h | 10 +- .../include/mvdHistogramController.h | 10 +- .../include/mvdHistogramPlotPicker.h | 6 +- .../include/mvdHistogramWidget.h | 2 +- .../include/mvdI18nApplication.h | 4 +- .../MonteverdiGui/include/mvdI18nMainWindow.h | 4 +- .../include/mvdImageViewManipulator.h | 54 ++--- .../include/mvdImageViewRenderer.h | 52 ++--- .../include/mvdImageViewWidget.h | 24 +-- .../include/mvdImportImagesDialog.h | 2 +- .../include/mvdImportSubDatasetDialog.h | 2 +- .../MonteverdiGui/include/mvdKeymapDialog.h | 2 +- .../include/mvdLayerStackController.h | 10 +- .../include/mvdLayerStackItemModel.h | 32 +-- .../include/mvdLayerStackWidget.h | 4 +- .../include/mvdMultiResolutionPyramidWidget.h | 2 +- .../include/mvdOTBApplicationsModel.h | 4 +- .../include/mvdPixelDescriptionWidget.h | 2 +- .../include/mvdProjectionBarWidget.h | 2 +- .../MonteverdiGui/include/mvdQtWidgetView.h | 4 +- .../include/mvdQuicklookViewManipulator.h | 20 +- .../include/mvdQuicklookViewRenderer.h | 14 +- .../include/mvdSearchableTreeWidget.h | 2 +- .../MonteverdiGui/include/mvdShaderWidget.h | 4 +- .../include/mvdStatusBarWidget.h | 2 +- .../include/mvdTaskProgressDialog.h | 2 +- .../MonteverdiGui/include/mvdTreeWidget.h | 18 +- .../MonteverdiGui/include/mvdTreeWidgetItem.h | 4 +- .../mvdTreeWidgetItemDragAndDropEventFilter.h | 10 +- .../ApplicationEngine/include/otbLogger.h | 2 +- .../otbWrapperAddProcessToWatchEvent.h | 8 +- .../include/otbWrapperApplication.h | 2 +- .../include/otbWrapperApplicationFactory.h | 10 +- .../otbWrapperApplicationFactoryBase.h | 2 +- .../include/otbWrapperApplicationRegistry.h | 2 +- .../include/otbWrapperChoiceParameter.h | 6 +- .../otbWrapperComplexInputImageParameter.h | 6 +- .../otbWrapperComplexOutputImageParameter.h | 6 +- .../include/otbWrapperCompositeApplication.h | 2 +- .../include/otbWrapperDirectoryParameter.h | 8 +- .../include/otbWrapperDocExampleStructure.h | 2 +- .../include/otbWrapperEmptyParameter.h | 6 +- .../otbWrapperInputFilenameParameter.h | 6 +- .../include/otbWrapperInputImageParameter.h | 6 +- .../otbWrapperInputProcessXMLParameter.h | 4 +- .../otbWrapperInputVectorDataParameter.h | 6 +- .../include/otbWrapperListViewParameter.h | 6 +- .../include/otbWrapperNumericalParameter.h | 8 +- .../otbWrapperOutputFilenameParameter.h | 6 +- .../include/otbWrapperOutputImageParameter.h | 6 +- .../otbWrapperOutputProcessXMLParameter.h | 6 +- .../otbWrapperOutputVectorDataParameter.h | 4 +- .../include/otbWrapperParameter.h | 2 +- .../include/otbWrapperParameterGroup.h | 4 +- .../include/otbWrapperProxyParameter.h | 2 +- .../include/otbWrapperRAMParameter.h | 10 +- .../include/otbWrapperRadiusParameter.h | 4 +- .../include/otbWrapperStringParameter.h | 6 +- .../include/otbWrapperCommandLineLauncher.h | 2 +- .../include/otbWrapperCommandLineParser.h | 2 +- .../QtWidget/include/itkQtProgressBar.h | 2 +- .../QtWidget/include/otbQtApplication.h | 2 +- .../include/otbQtFileSelectionWidget.h | 2 +- .../QtWidget/include/otbQtLogOutput.h | 12 +- .../include/otbQtStringSelectionWidget.h | 2 +- .../otbWrapperQtWidgetChoiceParameter.h | 6 +- ...rapperQtWidgetComplexInputImageParameter.h | 6 +- ...apperQtWidgetComplexOutputImageParameter.h | 6 +- .../otbWrapperQtWidgetDirectoryParameter.h | 6 +- .../otbWrapperQtWidgetEmptyParameter.h | 6 +- .../otbWrapperQtWidgetFloatParameter.h | 6 +- ...otbWrapperQtWidgetInputFilenameParameter.h | 6 +- .../otbWrapperQtWidgetInputImageParameter.h | 6 +- ...bWrapperQtWidgetInputProcessXMLParameter.h | 6 +- ...bWrapperQtWidgetInputVectorDataParameter.h | 6 +- .../include/otbWrapperQtWidgetIntParameter.h | 6 +- .../otbWrapperQtWidgetListEditItemModel.h | 24 +-- .../otbWrapperQtWidgetListViewParameter.h | 6 +- .../include/otbWrapperQtWidgetModel.h | 6 +- ...tbWrapperQtWidgetOutputFilenameParameter.h | 6 +- .../otbWrapperQtWidgetOutputImageParameter.h | 6 +- ...WrapperQtWidgetOutputProcessXMLParameter.h | 6 +- ...WrapperQtWidgetOutputVectorDataParameter.h | 6 +- .../include/otbWrapperQtWidgetParameterBase.h | 2 +- .../otbWrapperQtWidgetParameterFactory.h | 2 +- .../otbWrapperQtWidgetParameterGroup.h | 8 +- .../otbWrapperQtWidgetParameterLabel.h | 2 +- .../otbWrapperQtWidgetProgressReport.h | 2 +- .../include/otbWrapperQtWidgetRAMParameter.h | 6 +- .../otbWrapperQtWidgetSimpleProgressReport.h | 2 +- .../otbWrapperQtWidgetStringParameter.h | 6 +- .../QtWidget/include/otbWrapperQtWidgetView.h | 2 +- .../otbWrapperQtWidgetParameterFactory.cxx | 8 +- .../Wrappers/SWIG/src/python/itkPyCommand.h | 4 +- 1008 files changed, 3869 insertions(+), 3869 deletions(-) diff --git a/Modules/Adapters/CurlAdapters/include/otbCurlHelper.h b/Modules/Adapters/CurlAdapters/include/otbCurlHelper.h index 1ee320daeb..fa00e3615b 100644 --- a/Modules/Adapters/CurlAdapters/include/otbCurlHelper.h +++ b/Modules/Adapters/CurlAdapters/include/otbCurlHelper.h @@ -48,19 +48,19 @@ public: itkTypeMacro(CurlHelper, CurlHelperInterface); itkNewMacro(Self); - bool TestUrlAvailability(const std::string& url) const ITK_OVERRIDE; + bool TestUrlAvailability(const std::string& url) const override; bool IsCurlReturnHttpError(const std::string& url) const; - int RetrieveFile(const std::ostringstream& urlStream, std::string filename) const ITK_OVERRIDE; + int RetrieveFile(const std::ostringstream& urlStream, std::string filename) const override; - int RetrieveFile(const std::string& urlString, std::string filename) const ITK_OVERRIDE; + int RetrieveFile(const std::string& urlString, std::string filename) const override; - int RetrieveUrlInMemory(const std::string& urlString, std::string& output) const ITK_OVERRIDE; + int RetrieveUrlInMemory(const std::string& urlString, std::string& output) const override; int RetrieveFileMulti(const std::vector<std::string>& listURLs, const std::vector<std::string>& listFiles, - int maxConnect) const ITK_OVERRIDE; + int maxConnect) const override; itkGetMacro(Timeout,long int); @@ -71,7 +71,7 @@ protected: m_Browser("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.11) " "Gecko/20071127 Firefox/2.0.0.11"), m_Timeout(10) {} - ~CurlHelper() ITK_OVERRIDE {} + ~CurlHelper() override {} private: CurlHelper(const Self &); //purposely not implemented diff --git a/Modules/Adapters/CurlAdapters/include/otbCurlHelperInterface.h b/Modules/Adapters/CurlAdapters/include/otbCurlHelperInterface.h index 8fed05b3d2..a5cb6a56a0 100644 --- a/Modules/Adapters/CurlAdapters/include/otbCurlHelperInterface.h +++ b/Modules/Adapters/CurlAdapters/include/otbCurlHelperInterface.h @@ -66,7 +66,7 @@ public: protected: CurlHelperInterface() {} - ~CurlHelperInterface() ITK_OVERRIDE {} + ~CurlHelperInterface() override {} private: CurlHelperInterface(const Self &); //purposely not implemented diff --git a/Modules/Adapters/CurlAdapters/include/otbCurlHelperStub.h b/Modules/Adapters/CurlAdapters/include/otbCurlHelperStub.h index 58d56edaad..5393b36ff5 100644 --- a/Modules/Adapters/CurlAdapters/include/otbCurlHelperStub.h +++ b/Modules/Adapters/CurlAdapters/include/otbCurlHelperStub.h @@ -47,20 +47,20 @@ public: itkNewMacro(Self); - bool TestUrlAvailability(const std::string& url) const ITK_OVERRIDE; + bool TestUrlAvailability(const std::string& url) const override; - int RetrieveUrlInMemory(const std::string& urlString, std::string& output) const ITK_OVERRIDE; + int RetrieveUrlInMemory(const std::string& urlString, std::string& output) const override; - int RetrieveFile(const std::ostringstream& urlStream, std::string filename) const ITK_OVERRIDE; + int RetrieveFile(const std::ostringstream& urlStream, std::string filename) const override; - int RetrieveFile(const std::string& urlString, std::string filename) const ITK_OVERRIDE; + int RetrieveFile(const std::string& urlString, std::string filename) const override; int RetrieveFileMulti(const std::vector<std::string>& listURLs, const std::vector<std::string>& listFiles, - int maxConnect) const ITK_OVERRIDE; + int maxConnect) const override; protected: CurlHelperStub() {} - ~CurlHelperStub() ITK_OVERRIDE {} + ~CurlHelperStub() override {} private: CurlHelperStub(const Self &); //purposely not implemented diff --git a/Modules/Adapters/CurlAdapters/src/otbCurlHelper.cxx b/Modules/Adapters/CurlAdapters/src/otbCurlHelper.cxx index a9021f5efd..39bd3f0706 100644 --- a/Modules/Adapters/CurlAdapters/src/otbCurlHelper.cxx +++ b/Modules/Adapters/CurlAdapters/src/otbCurlHelper.cxx @@ -94,7 +94,7 @@ protected: } } - ~CurlResource() ITK_OVERRIDE + ~CurlResource() override { curl_easy_cleanup(m_Curl); } @@ -140,7 +140,7 @@ protected: } } - ~CurlMultiResource() ITK_OVERRIDE + ~CurlMultiResource() override { curl_multi_cleanup(m_Curl); } @@ -187,7 +187,7 @@ public: protected: CurlFileDescriptorResource(){} - ~CurlFileDescriptorResource() ITK_OVERRIDE + ~CurlFileDescriptorResource() override { fclose(m_File); } diff --git a/Modules/Adapters/GdalAdapters/include/otbGeometriesSet.h b/Modules/Adapters/GdalAdapters/include/otbGeometriesSet.h index 14e9f815ca..9306c6575b 100644 --- a/Modules/Adapters/GdalAdapters/include/otbGeometriesSet.h +++ b/Modules/Adapters/GdalAdapters/include/otbGeometriesSet.h @@ -159,10 +159,10 @@ protected: GeometriesSet(ogr::Layer layer); /** Destructor. */ - ~GeometriesSet() ITK_OVERRIDE; + ~GeometriesSet() override; /** Prints self to stream. */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: typedef boost::variant<ogr::DataSource::Pointer, ogr::Layer> AnyGeometriesSetType; AnyGeometriesSetType m_GeometriesSet; diff --git a/Modules/Adapters/GdalAdapters/include/otbGeometriesSource.h b/Modules/Adapters/GdalAdapters/include/otbGeometriesSource.h index 7361aa0c23..5b8c862671 100644 --- a/Modules/Adapters/GdalAdapters/include/otbGeometriesSource.h +++ b/Modules/Adapters/GdalAdapters/include/otbGeometriesSource.h @@ -119,7 +119,7 @@ public: * initializing them. * \post <tt>GetOutput() != NULL</tt> */ - void PrepareOutputs() ITK_OVERRIDE; + void PrepareOutputs() override; protected: /** Default constructor. @@ -129,7 +129,7 @@ protected: /** Destructor. * Does nothing. */ - ~GeometriesSource() ITK_OVERRIDE; + ~GeometriesSource() override; /** Ensures that the output geometries are allocated before processing. * If the output hasn't been set, at this point, the default output geometries diff --git a/Modules/Adapters/GdalAdapters/include/otbGeometriesToGeometriesFilter.h b/Modules/Adapters/GdalAdapters/include/otbGeometriesToGeometriesFilter.h index 5f3ce22675..26089652fb 100644 --- a/Modules/Adapters/GdalAdapters/include/otbGeometriesToGeometriesFilter.h +++ b/Modules/Adapters/GdalAdapters/include/otbGeometriesToGeometriesFilter.h @@ -91,13 +91,13 @@ protected: /** Destructor. * Does nothing. */ - ~GeometriesToGeometriesFilter() ITK_OVERRIDE; + ~GeometriesToGeometriesFilter() override; /** Processes the input to fill the output. * This is the main processing function. It either works \em in-place or by * \em copying the transformed input \c Feature s into the output. */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; private: /** \e In-place processing function. @@ -364,7 +364,7 @@ protected: /** Default constructor. */ DefaultGeometriesToGeometriesFilter(); /** Destructor. */ - ~DefaultGeometriesToGeometriesFilter() ITK_OVERRIDE; + ~DefaultGeometriesToGeometriesFilter() override; /** * Hook that actually filters an OGR \c Layer. @@ -376,7 +376,7 @@ protected: * \note When <tt>source == destination</tt>, it means this is an \em in-place * filter. */ - void DoProcessLayer(ogr::Layer const& source, ogr::Layer & destination) const ITK_OVERRIDE; + void DoProcessLayer(ogr::Layer const& source, ogr::Layer & destination) const override; /** * Hook used to define the fields of the new layer. * \param[in] source source \c Layer -- for reference @@ -385,7 +385,7 @@ protected: * Just forwards the fields definition to the \c FieldTransformationPolicy * inherited from the \c TransformationFunctorDispatcherType. */ - void DoDefineNewLayerFields(ogr::Layer const& source, ogr::Layer & dest) const ITK_OVERRIDE + void DoDefineNewLayerFields(ogr::Layer const& source, ogr::Layer & dest) const override { this->DefineFields(source, dest); } diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h index bf6d799fd5..eb6daff5f0 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h @@ -291,7 +291,7 @@ public: * meta information of another data source and use the same underlying \c * GDALDataset. */ - void Graft(const itk::DataObject *data) ITK_OVERRIDE; + void Graft(const itk::DataObject *data) override; /** * Resets current data source with the one in parameter. @@ -515,12 +515,12 @@ protected: /** Destructor. * \post The \c GDALDataset owned is released (if not null). */ - ~DataSource() ITK_OVERRIDE; + ~DataSource() override; static Pointer OpenDataSource(std::string const& datasourceName, Modes::type mode); /** Prints self into stream. */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.txx b/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.txx index d83540cac5..d3468a20ec 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.txx +++ b/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.txx @@ -132,7 +132,7 @@ template * <tt> = T</tt>) * * \internal - * This ITK_OVERRIDE is required because of the particular nature of the + * This override is required because of the particular nature of the * <tt>char**</tt> type chosen by OGR API, plus the fact this is the only * const-correct getter... * \since OTB v 3.14.0 @@ -262,7 +262,7 @@ template * <tt> = T</tt>) * * \internal - * This ITK_OVERRIDE is required because of the particular nature of the + * This override is required because of the particular nature of the * <tt>char**</tt> type chosen by OGR API. * \since OTB v 3.14.0 */ diff --git a/Modules/Adapters/OSSIMAdapters/include/otbDEMConvertAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbDEMConvertAdapter.h index 3e12cbe3b5..109f67dba7 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbDEMConvertAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbDEMConvertAdapter.h @@ -49,7 +49,7 @@ public: protected: DEMConvertAdapter(); - ~DEMConvertAdapter() ITK_OVERRIDE; + ~DEMConvertAdapter() override; private: DEMConvertAdapter(const Self &); //purposely not implemented diff --git a/Modules/Adapters/OSSIMAdapters/include/otbDEMHandler.h b/Modules/Adapters/OSSIMAdapters/include/otbDEMHandler.h index dc7a552e2a..498b0374d2 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbDEMHandler.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbDEMHandler.h @@ -169,9 +169,9 @@ public: protected: DEMHandler(); - ~DEMHandler() ITK_OVERRIDE {} + ~DEMHandler() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; // Ossim does not allow retrieving the geoid file path // We therefore must keep it on our side diff --git a/Modules/Adapters/OSSIMAdapters/include/otbDateTimeAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbDateTimeAdapter.h index 0d4101c1f9..5a0a3d4855 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbDateTimeAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbDateTimeAdapter.h @@ -85,7 +85,7 @@ public: protected: DateTimeAdapter(); - ~DateTimeAdapter() ITK_OVERRIDE; + ~DateTimeAdapter() override; private: DateTimeAdapter(const Self &); //purposely not implemented diff --git a/Modules/Adapters/OSSIMAdapters/include/otbEllipsoidAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbEllipsoidAdapter.h index 539d8b0e8b..d6a6de8e30 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbEllipsoidAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbEllipsoidAdapter.h @@ -67,7 +67,7 @@ public: protected: EllipsoidAdapter(); - ~EllipsoidAdapter() ITK_OVERRIDE; + ~EllipsoidAdapter() override; private: EllipsoidAdapter(const Self &); //purposely not implemented diff --git a/Modules/Adapters/OSSIMAdapters/include/otbFilterFunctionValues.h b/Modules/Adapters/OSSIMAdapters/include/otbFilterFunctionValues.h index 065197b830..2e835d0cde 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbFilterFunctionValues.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbFilterFunctionValues.h @@ -103,10 +103,10 @@ protected: /** Constructor */ FilterFunctionValues(); /** Destructor */ - ~FilterFunctionValues() ITK_OVERRIDE {} + ~FilterFunctionValues() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: FilterFunctionValues(const Self &); //purposely not implemented diff --git a/Modules/Adapters/OSSIMAdapters/include/otbGeometricSarSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbGeometricSarSensorModelAdapter.h index 690deb7b91..02173165dc 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbGeometricSarSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbGeometricSarSensorModelAdapter.h @@ -78,7 +78,7 @@ public: protected: GeometricSarSensorModelAdapter(); - ~GeometricSarSensorModelAdapter() ITK_OVERRIDE; + ~GeometricSarSensorModelAdapter() override; private: GeometricSarSensorModelAdapter(const Self &); //purposely not implemented diff --git a/Modules/Adapters/OSSIMAdapters/include/otbMapProjectionAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbMapProjectionAdapter.h index 7ba5ffe592..ed71e227f0 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbMapProjectionAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbMapProjectionAdapter.h @@ -89,7 +89,7 @@ public: protected: MapProjectionAdapter(); - ~MapProjectionAdapter() ITK_OVERRIDE; + ~MapProjectionAdapter() override; private: MapProjectionAdapter(const Self &); //purposely not implemented diff --git a/Modules/Adapters/OSSIMAdapters/include/otbPlatformPositionAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbPlatformPositionAdapter.h index 2f74ac90a8..ea770482aa 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbPlatformPositionAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbPlatformPositionAdapter.h @@ -78,7 +78,7 @@ public: protected: PlatformPositionAdapter(); - ~PlatformPositionAdapter() ITK_OVERRIDE; + ~PlatformPositionAdapter() override; private: PlatformPositionAdapter(const Self &); //purposely not implemented diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h index 8a713883b6..48e05c8941 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h @@ -106,7 +106,7 @@ public: protected: SarSensorModelAdapter(); - virtual ~SarSensorModelAdapter() ITK_OVERRIDE; + virtual ~SarSensorModelAdapter() override; private: SarSensorModelAdapter(const Self &); //purposely not implemented diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSensorModelAdapter.h index d6099e9a73..fe55f03488 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbSensorModelAdapter.h @@ -111,7 +111,7 @@ public: protected: SensorModelAdapter(); - ~SensorModelAdapter() ITK_OVERRIDE; + ~SensorModelAdapter() override; private: SensorModelAdapter(const Self &); //purposely not implemented diff --git a/Modules/Applications/AppChangeDetection/app/otbMultivariateAlterationDetector.cxx b/Modules/Applications/AppChangeDetection/app/otbMultivariateAlterationDetector.cxx index 668930e922..b2ec075b68 100644 --- a/Modules/Applications/AppChangeDetection/app/otbMultivariateAlterationDetector.cxx +++ b/Modules/Applications/AppChangeDetection/app/otbMultivariateAlterationDetector.cxx @@ -43,7 +43,7 @@ public: itkTypeMacro(MultivariateAlterationDetector, otb::Wrapper::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("MultivariateAlterationDetector"); SetDescription("Change detection by Multivariate Alteration Detector (MAD) algorithm"); @@ -110,11 +110,11 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { typedef otb::MultivariateAlterationDetectorImageFilter< FloatVectorImageType, diff --git a/Modules/Applications/AppClassification/app/otbClassificationMapRegularization.cxx b/Modules/Applications/AppClassification/app/otbClassificationMapRegularization.cxx index c5b0262be4..1e89016af7 100644 --- a/Modules/Applications/AppClassification/app/otbClassificationMapRegularization.cxx +++ b/Modules/Applications/AppClassification/app/otbClassificationMapRegularization.cxx @@ -57,7 +57,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ClassificationMapRegularization"); SetDescription("Filters the input labeled image using Majority Voting in a ball shaped neighbordhood."); @@ -125,12 +125,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Majority Voting m_NeighMajVotingFilter = NeighborhoodMajorityVotingFilterType::New(); diff --git a/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx b/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx index 4bee3df4fe..d009f21f0a 100644 --- a/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx +++ b/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx @@ -103,7 +103,7 @@ private: }; - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ComputeConfusionMatrix"); SetDescription("Computes the confusion matrix of a classification"); @@ -183,7 +183,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if ( HasValue("ref.vector.in") ) { @@ -363,7 +363,7 @@ private: return sid; } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { StreamingInitializationData sid = InitStreamingData(); diff --git a/Modules/Applications/AppClassification/app/otbComputeImagesStatistics.cxx b/Modules/Applications/AppClassification/app/otbComputeImagesStatistics.cxx index 0956eb7a00..055bc703e8 100644 --- a/Modules/Applications/AppClassification/app/otbComputeImagesStatistics.cxx +++ b/Modules/Applications/AppClassification/app/otbComputeImagesStatistics.cxx @@ -45,7 +45,7 @@ public: itkTypeMacro(ComputeImagesStatistics, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ComputeImagesStatistics"); SetDocName("Compute Images second order statistics"); @@ -85,12 +85,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { //Statistics estimator typedef otb::StreamingStatisticsVectorImageFilter<FloatVectorImageType> StreamingStatisticsVImageFilterType; diff --git a/Modules/Applications/AppClassification/app/otbComputeOGRLayersFeaturesStatistics.cxx b/Modules/Applications/AppClassification/app/otbComputeOGRLayersFeaturesStatistics.cxx index 5f108a9a13..0774475d1d 100644 --- a/Modules/Applications/AppClassification/app/otbComputeOGRLayersFeaturesStatistics.cxx +++ b/Modules/Applications/AppClassification/app/otbComputeOGRLayersFeaturesStatistics.cxx @@ -46,7 +46,7 @@ public: ; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ComputeOGRLayersFeaturesStatistics"); SetDescription("Compute statistics of the features in a set of OGR Layers"); @@ -75,7 +75,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if ( HasValue("inshp") ) { @@ -117,7 +117,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { clock_t tic = clock(); diff --git a/Modules/Applications/AppClassification/app/otbComputePolylineFeatureFromImage.cxx b/Modules/Applications/AppClassification/app/otbComputePolylineFeatureFromImage.cxx index 1e098e7846..1c9c715bed 100644 --- a/Modules/Applications/AppClassification/app/otbComputePolylineFeatureFromImage.cxx +++ b/Modules/Applications/AppClassification/app/otbComputePolylineFeatureFromImage.cxx @@ -76,7 +76,7 @@ public: ; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ComputePolylineFeatureFromImage"); SetDescription("This application compute for each studied polyline, contained in the input VectorData, the chosen descriptors."); @@ -116,12 +116,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Vector Data into Image projection FloatVectorImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx b/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx index e6343bf4b9..9b62f4be45 100644 --- a/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx +++ b/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx @@ -51,12 +51,12 @@ typedef itk::AmoebaOptimizer OptimizerType; typedef const OptimizerType * OptimizerPointer; -void Execute(itk::Object *caller, const itk::EventObject & event) ITK_OVERRIDE +void Execute(itk::Object *caller, const itk::EventObject & event) override { Execute( (const itk::Object *)caller, event); } -void Execute(const itk::Object * object, const itk::EventObject & event) ITK_OVERRIDE +void Execute(const itk::Object * object, const itk::EventObject & event) override { OptimizerPointer optimizer = dynamic_cast< OptimizerPointer >( object ); @@ -115,7 +115,7 @@ public: itkTypeMacro(DSFuzzyModelEstimation, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("DSFuzzyModelEstimation"); SetDescription("Estimate feature fuzzy model parameters using 2 vector data (ground truth samples and wrong samples)."); @@ -184,7 +184,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent @@ -194,7 +194,7 @@ private: } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { //Instantiate diff --git a/Modules/Applications/AppClassification/app/otbFusionOfClassifications.cxx b/Modules/Applications/AppClassification/app/otbFusionOfClassifications.cxx index b31ae21c16..4fa71c70e5 100644 --- a/Modules/Applications/AppClassification/app/otbFusionOfClassifications.cxx +++ b/Modules/Applications/AppClassification/app/otbFusionOfClassifications.cxx @@ -93,7 +93,7 @@ public: itkTypeMacro(FusionOfClassifications, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("FusionOfClassifications"); SetDescription("Fuses several classifications maps of the same image on the basis of class labels."); @@ -173,7 +173,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } @@ -285,7 +285,7 @@ private: } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Clear any previous filter m_Filters.clear(); diff --git a/Modules/Applications/AppClassification/app/otbImageClassifier.cxx b/Modules/Applications/AppClassification/app/otbImageClassifier.cxx index 1f94d27143..59f3cd2936 100644 --- a/Modules/Applications/AppClassification/app/otbImageClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbImageClassifier.cxx @@ -67,13 +67,13 @@ public: protected: - ~ImageClassifier() ITK_OVERRIDE + ~ImageClassifier() override { MachineLearningModelFactoryType::CleanFactories(); } private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ImageClassifier"); SetDescription("Performs a classification of the input image according to a model file."); @@ -141,12 +141,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Load input image FloatVectorImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx index a5067bf9cd..54d5f81700 100644 --- a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx +++ b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx @@ -395,7 +395,7 @@ public: itkTypeMacro(Self, Superclass); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("KMeansClassification"); SetDescription("Unsupervised KMeans image classification"); @@ -449,11 +449,11 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { if (IsParameterEnabled("vm") && HasValue("vm")) Superclass::ConnectKMClassificationMask(); diff --git a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx index cf142f76f6..37d97e2701 100644 --- a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx +++ b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx @@ -57,7 +57,7 @@ private: m_CalculatorList = RateCalculatorListType::New(); } - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("MultiImageSamplingRate"); SetDescription("Compute sampling rate for an input set of images."); @@ -186,11 +186,11 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Clear state m_CalculatorList->Clear(); diff --git a/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx b/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx index eb58a7e0ac..ca5d597fff 100644 --- a/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx @@ -55,7 +55,7 @@ public: ; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("OGRLayerClassifier"); SetDescription("Classify an OGR layer based on a machine learning model and a list of features to consider."); @@ -94,7 +94,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if ( HasValue("inshp") ) { @@ -135,7 +135,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { #ifdef OTB_USE_LIBSVM diff --git a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx index 4a35145462..3fa23e056d 100644 --- a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx +++ b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx @@ -67,7 +67,7 @@ private: } - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("PolygonClassStatistics"); SetDescription("Computes statistics on a training polygon set."); @@ -127,7 +127,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if ( HasValue("vec") ) { @@ -173,7 +173,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { otb::ogr::DataSource::Pointer vectors = otb::ogr::DataSource::New(this->GetParameterString("vec")); diff --git a/Modules/Applications/AppClassification/app/otbPredictRegression.cxx b/Modules/Applications/AppClassification/app/otbPredictRegression.cxx index 8a4401679f..0c8dce2d86 100644 --- a/Modules/Applications/AppClassification/app/otbPredictRegression.cxx +++ b/Modules/Applications/AppClassification/app/otbPredictRegression.cxx @@ -107,13 +107,13 @@ public: protected: - ~PredictRegression() ITK_OVERRIDE + ~PredictRegression() override { MachineLearningModelFactoryType::CleanFactories(); } private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("PredictRegression"); SetDescription("Performs a prediction of the input image according to a regression model file."); @@ -182,12 +182,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Load input image FloatVectorImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppClassification/app/otbSOMClassification.cxx b/Modules/Applications/AppClassification/app/otbSOMClassification.cxx index 86572e90ad..1b0b7ffcc7 100644 --- a/Modules/Applications/AppClassification/app/otbSOMClassification.cxx +++ b/Modules/Applications/AppClassification/app/otbSOMClassification.cxx @@ -76,7 +76,7 @@ private: m_Classifier = ClassificationFilterType::New(); } - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("SOMClassification"); SetDescription("SOM image classification."); @@ -178,12 +178,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // initiating random number generation itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer diff --git a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx index 63615e03cc..908bff1929 100644 --- a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx @@ -53,7 +53,7 @@ public: private: SampleExtraction() {} - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("SampleExtraction"); SetDescription("Extracts samples values from an image."); @@ -119,7 +119,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if ( HasValue("vec") ) { @@ -149,7 +149,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { ogr::DataSource::Pointer vectors; ogr::DataSource::Pointer output; diff --git a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx index 8faee83496..4c3ecca0f0 100644 --- a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx @@ -80,7 +80,7 @@ private: m_RateCalculator = RateCalculatorType::New(); } - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("SampleSelection"); SetDescription("Selects samples from a training vector data set."); @@ -227,7 +227,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if ( HasValue("vec") ) { @@ -257,7 +257,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Clear state m_RateCalculator->ClearRates(); diff --git a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx index f26b4b32d4..b8cca0f946 100644 --- a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx @@ -35,7 +35,7 @@ public: itkNewMacro( Self ) itkTypeMacro( Self, Superclass ) - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName( "TrainImagesClassifier" ); SetDescription( "Train a classifier from multiple pairs of images and training vector data." ); @@ -86,7 +86,7 @@ public: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if( HasValue( "io.vd" ) && IsParameterEnabled( "io.vd" )) { @@ -157,7 +157,7 @@ public: } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { TrainFileNamesHandler fileNames; std::vector<std::string> vectorFileList; diff --git a/Modules/Applications/AppClassification/app/otbTrainRegression.cxx b/Modules/Applications/AppClassification/app/otbTrainRegression.cxx index 690d03da1d..ef92edc57e 100644 --- a/Modules/Applications/AppClassification/app/otbTrainRegression.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainRegression.cxx @@ -98,7 +98,7 @@ protected: private: -void DoInit() ITK_OVERRIDE +void DoInit() override { SetName("TrainRegression"); SetDescription( @@ -198,7 +198,7 @@ void DoInit() ITK_OVERRIDE SetOfficialDocLink(); } -void DoUpdateParameters() ITK_OVERRIDE +void DoUpdateParameters() override { if (HasValue("io.csv") && IsParameterEnabled("io.csv")) { @@ -279,7 +279,7 @@ void ParseCSVPredictors(std::string path, ListSampleType* outputList) ifs.close(); } -void DoExecute() ITK_OVERRIDE +void DoExecute() override { GetLogger()->Debug("Entering DoExecute\n"); //Create training and validation for list samples and label list samples diff --git a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx index 9de1efb8b1..9bf094e6bd 100644 --- a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx @@ -54,7 +54,7 @@ public: typedef ContingencyTableType::Pointer ContingencyTablePointerType; protected: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName( "TrainVectorClassifier" ); SetDescription( "Train a classifier based on labeled geometries and a " @@ -73,12 +73,12 @@ protected: Superclass::DoInit(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { Superclass::DoUpdateParameters(); } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { m_FeaturesInfo.SetClassFieldNames( GetChoiceNames( "cfield" ), GetSelectedItems( "cfield" ) ); diff --git a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx index b8ecd88713..f20a4aeac3 100644 --- a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx @@ -80,13 +80,13 @@ public: typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; - ~VectorClassifier() ITK_OVERRIDE + ~VectorClassifier() override { MachineLearningModelFactoryType::CleanFactories(); } private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("VectorClassifier"); SetDescription("Performs a classification of the input vector data according to a model file."); @@ -163,7 +163,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if ( HasValue("in") ) { @@ -197,7 +197,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { clock_t tic = clock(); diff --git a/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx b/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx index 11e75421ae..ab80a98740 100644 --- a/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx @@ -58,7 +58,7 @@ public: itkTypeMacro(VectorDataDSValidation, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("VectorDataDSValidation"); SetDescription("Vector data validation based on the fusion of features using Dempster-Shafer evidence theory framework."); @@ -106,7 +106,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent @@ -116,7 +116,7 @@ private: } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { //Read the vector data diff --git a/Modules/Applications/AppClassification/include/otbLearningApplicationBase.h b/Modules/Applications/AppClassification/include/otbLearningApplicationBase.h index e71be64021..72e87a389c 100644 --- a/Modules/Applications/AppClassification/include/otbLearningApplicationBase.h +++ b/Modules/Applications/AppClassification/include/otbLearningApplicationBase.h @@ -121,7 +121,7 @@ public: protected: LearningApplicationBase(); - ~LearningApplicationBase() ITK_OVERRIDE; + ~LearningApplicationBase() override; /** Generic method to train and save the machine learning model. This method * uses specific train methods depending on the chosen model.*/ @@ -135,7 +135,7 @@ protected: std::string modelPath); /** Init method that creates all the parameters for machine learning models */ - void DoInit() ITK_OVERRIDE; + void DoInit() override; /** Flag to switch between classification and regression mode. * False by default, child classes may change it in their constructor */ diff --git a/Modules/Applications/AppClassification/include/otbTrainVectorBase.h b/Modules/Applications/AppClassification/include/otbTrainVectorBase.h index 9bcf6df386..300b1b5879 100644 --- a/Modules/Applications/AppClassification/include/otbTrainVectorBase.h +++ b/Modules/Applications/AppClassification/include/otbTrainVectorBase.h @@ -180,9 +180,9 @@ protected: TargetListSampleType::Pointer m_PredictedList; FeaturesInfo m_FeaturesInfo; - void DoInit() ITK_OVERRIDE; - void DoUpdateParameters() ITK_OVERRIDE; - void DoExecute() ITK_OVERRIDE; + void DoInit() override; + void DoUpdateParameters() override; + void DoExecute() override; }; diff --git a/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx b/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx index 073e53727f..fa79cd7334 100644 --- a/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx +++ b/Modules/Applications/AppDescriptors/app/otbHomologousPointsExtraction.cxx @@ -80,7 +80,7 @@ public: itkTypeMacro(HomologousPointsExtraction, otb::Wrapper::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("HomologousPointsExtraction"); SetDocName("Homologous points extraction"); @@ -202,7 +202,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } @@ -326,7 +326,7 @@ private: } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { OGRMultiLineString mls; diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx index 686b78bb4c..7db943d308 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx @@ -89,7 +89,7 @@ public: ; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("DimensionalityReduction"); SetDescription("Perform Dimension reduction of the input image."); @@ -184,7 +184,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if (HasValue("in")) { @@ -232,7 +232,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get Parameters diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx index c221302c03..1df2c463fc 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx @@ -116,13 +116,13 @@ public: protected: - ~ImageDimensionalityReduction() ITK_OVERRIDE + ~ImageDimensionalityReduction() override { DimensionalityReductionModelFactoryType::CleanFactories(); } private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("DimensionalityReduction"); SetDescription("Performs dimensionality reduction of the input image " @@ -182,12 +182,12 @@ private: SetDocExampleParameterValue("out", "ReducedImageQB1.tif"); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Load input image FloatVectorImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx index 8d52132dec..34390791ab 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx @@ -68,7 +68,7 @@ public: typedef otb::DimensionalityReductionModelFactory<ValueType, ValueType> ModelFactoryType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("TrainDimensionalityReduction"); SetDescription("Train a dimensionality reduction model"); @@ -115,11 +115,11 @@ private: " value_5 value_6 value_7 value_8 value_9"); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { std::string shapefile = GetParameterString("io.vd"); diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx index 132e13875c..24e7ba98ff 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx @@ -75,13 +75,13 @@ public: ListSampleType, ListSampleType> ShiftScaleFilterType; protected: - ~VectorDimensionalityReduction() ITK_OVERRIDE + ~VectorDimensionalityReduction() override { DimensionalityReductionModelFactoryType::CleanFactories(); } private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("VectorDimensionalityReduction"); SetDescription("Performs dimensionality reduction of the input vector data " @@ -163,7 +163,7 @@ private: //SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if ( HasValue("in") ) { @@ -188,7 +188,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { clock_t tic = clock(); diff --git a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx index c853f4863b..e312f58d9c 100644 --- a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx +++ b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx @@ -81,7 +81,7 @@ public: private: DomainTransform() {} - ~DomainTransform() ITK_OVERRIDE + ~DomainTransform() override { } @@ -99,7 +99,7 @@ private: #endif } - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("DomainTransform"); SetDescription("Domain Transform application for wavelet and fourier"); @@ -173,12 +173,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { int dir = GetParameterInt("direction"); int mode = GetParameterInt("mode"); diff --git a/Modules/Applications/AppEdge/app/otbEdgeExtraction.cxx b/Modules/Applications/AppEdge/app/otbEdgeExtraction.cxx index a608338dde..cbadc412bb 100644 --- a/Modules/Applications/AppEdge/app/otbEdgeExtraction.cxx +++ b/Modules/Applications/AppEdge/app/otbEdgeExtraction.cxx @@ -61,7 +61,7 @@ itkTypeMacro(EdgeExtraction, otb::Application); private: -void DoInit() ITK_OVERRIDE +void DoInit() override { SetName("EdgeExtraction"); SetDescription( @@ -142,12 +142,12 @@ SetDocExampleParameterValue("out", "Edges.tif"); SetOfficialDocLink(); } -void DoUpdateParameters() ITK_OVERRIDE +void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } -void DoExecute() ITK_OVERRIDE +void DoExecute() override { FloatVectorImageType::Pointer inImage = GetParameterImage("in"); inImage->UpdateOutputInformation(); diff --git a/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx b/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx index 45bc66c51d..c0eef79ebc 100644 --- a/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx +++ b/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx @@ -53,7 +53,7 @@ public: itkTypeMacro(LineSegmentDetection, otb::Wrapper::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("LineSegmentDetection"); SetDescription("Detect line segments in raster"); @@ -100,11 +100,11 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { typedef otb::VectorImageToAmplitudeImageFilter<FloatVectorImageType, FloatImageType> VectorImageToAmplitudeImageFilterType; diff --git a/Modules/Applications/AppFiltering/app/otbSmoothing.cxx b/Modules/Applications/AppFiltering/app/otbSmoothing.cxx index a31dc93388..44309b82d7 100644 --- a/Modules/Applications/AppFiltering/app/otbSmoothing.cxx +++ b/Modules/Applications/AppFiltering/app/otbSmoothing.cxx @@ -55,7 +55,7 @@ public: itkTypeMacro(Smoothing, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName( "Smoothing" ); SetDescription( "Apply a smoothing filter to an image" ); @@ -136,12 +136,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { GetLogger()->Debug("Entering DoExecute\n"); diff --git a/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx b/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx index bd52a805c5..40a439e340 100644 --- a/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx +++ b/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx @@ -42,7 +42,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("BundleToPerfectSensor"); SetDescription("Perform P+XS pansharpening"); @@ -85,12 +85,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { UpdateInternalParameters("superimpose"); } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { ExecuteInternal("superimpose"); diff --git a/Modules/Applications/AppFusion/app/otbPansharpening.cxx b/Modules/Applications/AppFusion/app/otbPansharpening.cxx index 15fa33cc7e..fce89cc116 100644 --- a/Modules/Applications/AppFusion/app/otbPansharpening.cxx +++ b/Modules/Applications/AppFusion/app/otbPansharpening.cxx @@ -73,7 +73,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("Pansharpening"); SetDescription("Perform P+XS pansharpening"); @@ -138,12 +138,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType* panchroV = GetParameterImage("inp"); if ( panchroV->GetNumberOfComponentsPerPixel() != 1 ) diff --git a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx index 8d510460a6..790c79357b 100644 --- a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx +++ b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx @@ -88,7 +88,7 @@ public: itkTypeMacro(HyperspectralUnmixing, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("HyperspectralUnmixing"); SetDescription("Estimate abundance maps from an hyperspectral image and a set of endmembers."); @@ -154,12 +154,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { m_ProcessObjects.clear(); diff --git a/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx b/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx index c3b04df6a9..3a9e09d4eb 100644 --- a/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx +++ b/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx @@ -47,7 +47,7 @@ public: itkTypeMacro(VertexComponentAnalysis, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("VertexComponentAnalysis"); SetDescription("Given a set of mixed spectral vectors, estimate" @@ -99,12 +99,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { DoubleVectorImageType::Pointer inputImage = GetParameterDoubleVectorImage("in"); DoubleVectorImageType::Pointer endmembersImage; diff --git a/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx b/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx index ad8c68b614..ceaadf550f 100644 --- a/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx +++ b/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx @@ -248,7 +248,7 @@ public: <FloatImageType, LabelImageType> CasterToLabelImageType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ColorMapping"); SetDescription("Maps an input label image to 8-bits RGB using look-up tables."); @@ -397,7 +397,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Make sure the operation color->label is not called with methods continuous or image. // These methods are not implemented for this operation yet. @@ -411,7 +411,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { if(GetParameterInt("op")==0) { diff --git a/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx b/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx index 2d0d54c83c..e8a4ddae50 100644 --- a/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx +++ b/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx @@ -49,7 +49,7 @@ public: typedef otb::StreamingCompareImageFilter<FloatImageType> StreamingCompareImageFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("CompareImages"); SetDescription("Estimator between 2 images."); @@ -134,7 +134,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Set channel interval if( HasValue("ref.in") ) @@ -169,7 +169,7 @@ private: } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Init filters m_ExtractRefFilter = ExtractROIMonoFilterType::New(); diff --git a/Modules/Applications/AppImageUtils/app/otbConcatenateImages.cxx b/Modules/Applications/AppImageUtils/app/otbConcatenateImages.cxx index 185872b828..7e3459d154 100644 --- a/Modules/Applications/AppImageUtils/app/otbConcatenateImages.cxx +++ b/Modules/Applications/AppImageUtils/app/otbConcatenateImages.cxx @@ -54,7 +54,7 @@ public: typedef ObjectList<ExtractROIFilterType> ExtractROIFilterListType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ConcatenateImages"); SetDescription("Concatenate a list of images of the same size into a single multi-channel one."); @@ -91,7 +91,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here for the parameters : all are independent @@ -101,7 +101,7 @@ private: m_ExtractorList = ExtractROIFilterListType::New(); } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the input image list FloatVectorImageListType::Pointer inList = this->GetParameterImageList("il"); diff --git a/Modules/Applications/AppImageUtils/app/otbConvert.cxx b/Modules/Applications/AppImageUtils/app/otbConvert.cxx index 621d48adb3..5b87b57147 100644 --- a/Modules/Applications/AppImageUtils/app/otbConvert.cxx +++ b/Modules/Applications/AppImageUtils/app/otbConvert.cxx @@ -85,7 +85,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("Convert"); SetDescription("Convert an image to a different format, optionally rescaling the data" @@ -192,7 +192,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Read information if ( HasValue("in") ) @@ -482,7 +482,7 @@ private: } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { switch ( this->GetParameterOutputImagePixelType("out") ) { diff --git a/Modules/Applications/AppImageUtils/app/otbDEMConvert.cxx b/Modules/Applications/AppImageUtils/app/otbDEMConvert.cxx index 3e79f0ad67..cee406ad9f 100644 --- a/Modules/Applications/AppImageUtils/app/otbDEMConvert.cxx +++ b/Modules/Applications/AppImageUtils/app/otbDEMConvert.cxx @@ -45,7 +45,7 @@ public: itkTypeMacro(DEMConvert, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("DEMConvert"); SetDescription("Converts a geo-referenced DEM image into a general raster file compatible with OTB DEM handling."); @@ -75,7 +75,7 @@ private: SetOfficialDocLink(); } -void DoUpdateParameters() ITK_OVERRIDE +void DoUpdateParameters() override { // nothing to update } @@ -85,7 +85,7 @@ void DoUpdateParameters() ITK_OVERRIDE * (.ras, .geom and . omd) */ -void DoExecute() ITK_OVERRIDE +void DoExecute() override { // Load input image FloatVectorImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppImageUtils/app/otbDynamicConvert.cxx b/Modules/Applications/AppImageUtils/app/otbDynamicConvert.cxx index fa8b76c501..d61430287c 100644 --- a/Modules/Applications/AppImageUtils/app/otbDynamicConvert.cxx +++ b/Modules/Applications/AppImageUtils/app/otbDynamicConvert.cxx @@ -85,7 +85,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("DynamicConvert"); SetDescription("Change the pixel type and rescale the image's dynamic"); @@ -212,7 +212,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Read information if ( HasValue("in") ) diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index bd6a8d1583..78a32dd969 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -63,7 +63,7 @@ public: private: void - DoInit() ITK_OVERRIDE + DoInit() override { SetName("ExtractROI"); SetDescription("Extract a ROI defined by the user."); @@ -247,7 +247,7 @@ private: } void - DoUpdateParameters() ITK_OVERRIDE + DoUpdateParameters() override { if ( HasValue("in") ) { @@ -674,7 +674,7 @@ private: } void - DoExecute() ITK_OVERRIDE + DoExecute() override { ImageType* inImage = GetParameterImage("in"); inImage->UpdateOutputInformation(); diff --git a/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx b/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx index 439ba05590..3554436f73 100644 --- a/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx +++ b/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx @@ -58,7 +58,7 @@ public: typedef otb::ChangeInformationImageFilter<FloatVectorImageType> ChangeInfoFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ManageNoData"); SetDescription("Manage No-Data"); @@ -125,13 +125,13 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here for the parameters : all are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType::Pointer inputPtr = this->GetParameterImage("in"); diff --git a/Modules/Applications/AppImageUtils/app/otbMultiResolutionPyramid.cxx b/Modules/Applications/AppImageUtils/app/otbMultiResolutionPyramid.cxx index d94f67b260..5d394a3dc0 100644 --- a/Modules/Applications/AppImageUtils/app/otbMultiResolutionPyramid.cxx +++ b/Modules/Applications/AppImageUtils/app/otbMultiResolutionPyramid.cxx @@ -58,7 +58,7 @@ public: FloatVectorImageType> ShrinkFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("MultiResolutionPyramid"); SetDescription("Build a multi-resolution pyramid of the image."); @@ -114,14 +114,14 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here for the parameters : all are independent // Reinitialize the internal process used } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Initializing the process m_SmoothingFilter = SmoothingVectorImageFilterType::New(); diff --git a/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx b/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx index 1bca9241ea..78ecfa8165 100644 --- a/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx +++ b/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx @@ -48,7 +48,7 @@ public: itkTypeMacro(PixelValue, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("PixelValue"); SetDescription("Get the value of a pixel."); @@ -120,7 +120,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if ( HasValue("in") ) { @@ -206,7 +206,7 @@ private: return box; } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { std::string mode = GetParameterString( "mode" ); FloatVectorImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx index dd7134c620..37edda3ea8 100644 --- a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx +++ b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx @@ -53,7 +53,7 @@ public: <ExtractROIFilterType::OutputImageType, ExtractROIFilterType::OutputImageType> ShrinkImageFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("Quicklook"); SetDescription("Generates a subsampled version of an image extract"); @@ -121,7 +121,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Update the sizes only if the user does not defined a size if ( HasValue("in") ) @@ -198,7 +198,7 @@ bool CropRegionOfInterest() return false; } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { InputImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx b/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx index 74bb9c42da..a272e7ed2b 100644 --- a/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx +++ b/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx @@ -48,7 +48,7 @@ public: itkTypeMacro(ReadImageInfo, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ReadImageInfo"); SetDescription("Get information about the image"); @@ -250,12 +250,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { std::ostringstream ossOutput; FloatVectorImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppImageUtils/app/otbRescale.cxx b/Modules/Applications/AppImageUtils/app/otbRescale.cxx index f5c08c80a2..a94e8440ac 100644 --- a/Modules/Applications/AppImageUtils/app/otbRescale.cxx +++ b/Modules/Applications/AppImageUtils/app/otbRescale.cxx @@ -49,7 +49,7 @@ public: typedef otb::VectorRescaleIntensityImageFilter<FloatVectorImageType> RescaleImageFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("Rescale"); SetDescription("Rescale the image between two given values."); @@ -90,12 +90,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here for the parameters : all are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx b/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx index e23eaa57eb..fba6fb7580 100644 --- a/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx +++ b/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx @@ -49,7 +49,7 @@ public: FloatVectorImageType::InternalPixelType> FilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("SplitImage"); SetDescription("Split a N multiband image into N images."); @@ -83,12 +83,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here for the parameters : all are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the input image FloatVectorImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx b/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx index 5dd80bc10e..fd53f599b9 100644 --- a/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx +++ b/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx @@ -45,7 +45,7 @@ public: typedef otb::TileImageFilter<FloatVectorImageType> TileFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("TileFusion"); SetDescription("Fusion of an image made of several tile files."); @@ -80,12 +80,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to be done } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the input image list FloatVectorImageListType::Pointer tileList = this->GetParameterImageList("il"); diff --git a/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx b/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx index 7204d68c7e..c9e5bdcb56 100644 --- a/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx +++ b/Modules/Applications/AppIndices/app/otbRadiometricIndices.cxx @@ -129,7 +129,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("RadiometricIndices"); SetDescription("Compute radiometric indices."); @@ -438,7 +438,7 @@ private: } } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { //Nothing to do here } @@ -488,7 +488,7 @@ private: otbAppLogINFO(<< m_Map[GetSelectedItems("list")[idx]].item << " added.");\ } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { int nbChan = GetParameterImage("in")->GetNumberOfComponentsPerPixel(); diff --git a/Modules/Applications/AppKMZ/app/otbKmzExport.cxx b/Modules/Applications/AppKMZ/app/otbKmzExport.cxx index efda73d3c9..6d00a5e411 100644 --- a/Modules/Applications/AppKMZ/app/otbKmzExport.cxx +++ b/Modules/Applications/AppKMZ/app/otbKmzExport.cxx @@ -45,7 +45,7 @@ public: itkTypeMacro(KmzExport, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("KmzExport"); SetDescription("Export the input image in a KMZ product."); @@ -91,12 +91,12 @@ private: } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here for the parameters : all are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { typedef otb::KmzProductWriter<FloatVectorImageType> KmzProductWriterType; diff --git a/Modules/Applications/AppMathParser/app/otbBandMath.cxx b/Modules/Applications/AppMathParser/app/otbBandMath.cxx index 37a9054ec9..2503d924eb 100644 --- a/Modules/Applications/AppMathParser/app/otbBandMath.cxx +++ b/Modules/Applications/AppMathParser/app/otbBandMath.cxx @@ -53,7 +53,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName( "BandMath" ); @@ -132,7 +132,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Check if the expression is correctly set if (HasValue("il")) @@ -203,7 +203,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the input image list FloatVectorImageListType::Pointer inList = GetParameterImageList("il"); diff --git a/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx b/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx index 90a7f245a6..8e65868a7e 100644 --- a/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx +++ b/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx @@ -55,7 +55,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName( "BandMathX" ); @@ -251,7 +251,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // check if input context should be used bool useContext = this->ContextCheck(); @@ -345,7 +345,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the input image list FloatVectorImageListType::Pointer inList = GetParameterImageList("il"); diff --git a/Modules/Applications/AppMoments/app/otbLocalStatisticExtraction.cxx b/Modules/Applications/AppMoments/app/otbLocalStatisticExtraction.cxx index f04bb70a5a..095da8b17f 100644 --- a/Modules/Applications/AppMoments/app/otbLocalStatisticExtraction.cxx +++ b/Modules/Applications/AppMoments/app/otbLocalStatisticExtraction.cxx @@ -53,7 +53,7 @@ itkTypeMacro(LocalStatisticExtraction, otb::Application); private: -void DoInit() ITK_OVERRIDE +void DoInit() override { SetName("LocalStatisticExtraction"); SetDescription("Computes local statistical moments on every pixel in the selected channel of the input image"); @@ -95,12 +95,12 @@ SetDocExampleParameterValue("out", "Statistics.tif"); SetOfficialDocLink(); } -void DoUpdateParameters() ITK_OVERRIDE +void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } -void DoExecute() ITK_OVERRIDE +void DoExecute() override { FloatVectorImageType::Pointer inImage = GetParameterImage("in"); inImage->UpdateOutputInformation(); diff --git a/Modules/Applications/AppMorphology/app/otbBinaryMorphologicalOperation.cxx b/Modules/Applications/AppMorphology/app/otbBinaryMorphologicalOperation.cxx index c4a59616b6..dada95c498 100644 --- a/Modules/Applications/AppMorphology/app/otbBinaryMorphologicalOperation.cxx +++ b/Modules/Applications/AppMorphology/app/otbBinaryMorphologicalOperation.cxx @@ -74,7 +74,7 @@ itkTypeMacro(BinaryMorphologicalOperation, otb::Application); private: -void DoInit() ITK_OVERRIDE +void DoInit() override { SetName( "BinaryMorphologicalOperation" ); SetDescription( "Performs morphological operations on an input image channel" ); @@ -183,12 +183,12 @@ SetDocExampleParameterValue("filter", "erode"); SetOfficialDocLink(); } -void DoUpdateParameters() ITK_OVERRIDE +void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } -void DoExecute() ITK_OVERRIDE +void DoExecute() override { FloatVectorImageType::Pointer inImage = GetParameterImage("in"); inImage->UpdateOutputInformation(); diff --git a/Modules/Applications/AppMorphology/app/otbGrayScaleMorphologicalOperation.cxx b/Modules/Applications/AppMorphology/app/otbGrayScaleMorphologicalOperation.cxx index e35aad5d0c..1e9a059f6e 100644 --- a/Modules/Applications/AppMorphology/app/otbGrayScaleMorphologicalOperation.cxx +++ b/Modules/Applications/AppMorphology/app/otbGrayScaleMorphologicalOperation.cxx @@ -74,7 +74,7 @@ itkTypeMacro(GrayScaleMorphologicalOperation, otb::Application); private: -void DoInit() ITK_OVERRIDE +void DoInit() override { SetName("GrayScaleMorphologicalOperation"); SetDescription("Performs morphological operations on a grayscale input image"); @@ -142,12 +142,12 @@ SetDocExampleParameterValue("filter", "erode"); SetOfficialDocLink(); } -void DoUpdateParameters() ITK_OVERRIDE +void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } -void DoExecute() ITK_OVERRIDE +void DoExecute() override { FloatVectorImageType::Pointer inImage = GetParameterImage("in"); inImage->UpdateOutputInformation(); diff --git a/Modules/Applications/AppMorphology/app/otbMorphologicalClassification.cxx b/Modules/Applications/AppMorphology/app/otbMorphologicalClassification.cxx index a117a2f178..bd47a89c76 100644 --- a/Modules/Applications/AppMorphology/app/otbMorphologicalClassification.cxx +++ b/Modules/Applications/AppMorphology/app/otbMorphologicalClassification.cxx @@ -70,7 +70,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName( "MorphologicalClassification" ); SetDescription( "Performs morphological convex, concave and flat " @@ -153,12 +153,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType::Pointer inImage = GetParameterImage( "in" ); diff --git a/Modules/Applications/AppMorphology/app/otbMorphologicalMultiScaleDecomposition.cxx b/Modules/Applications/AppMorphology/app/otbMorphologicalMultiScaleDecomposition.cxx index fc27fd88fa..052e8d9be3 100644 --- a/Modules/Applications/AppMorphology/app/otbMorphologicalMultiScaleDecomposition.cxx +++ b/Modules/Applications/AppMorphology/app/otbMorphologicalMultiScaleDecomposition.cxx @@ -65,7 +65,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName( "MorphologicalMultiScaleDecomposition" ); SetDescription( "Perform a geodesic morphology based image analysis on an input image channel" ); @@ -155,12 +155,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType::Pointer inImage = GetParameterImage( "in" ); int nBComp = inImage->GetNumberOfComponentsPerPixel(); diff --git a/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx b/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx index c314b8d6ac..a7bc15c56b 100644 --- a/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx +++ b/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx @@ -71,7 +71,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName( "MorphologicalProfilesAnalysis" ); SetDescription( "Performs morphological profiles analysis on an input image channel." ); @@ -173,12 +173,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType::Pointer inImage = GetParameterImage( "in" ); diff --git a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx index 829c4f3052..c8ce25bd28 100644 --- a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx +++ b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx @@ -124,7 +124,7 @@ private: std::string m_inImageName; bool m_currentEnabledStateOfFluxParam; - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("OpticalCalibration"); SetDescription("Perform optical calibration TOA/TOC (Top Of Atmosphere/Top Of Canopy). Supported sensors: QuickBird, Ikonos, WorldView2, Formosat, Spot5, Pleiades, Spot6, Spot7. For other sensors the application also allows providing calibration parameters manually."); @@ -359,7 +359,7 @@ private: m_currentEnabledStateOfFluxParam=false; } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { std::ostringstream ossOutput; //ossOutput << std::endl << "--DoUpdateParameters--" << std::endl; @@ -563,7 +563,7 @@ private: } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { //Main filters instantiations m_ImageToRadianceFilter = ImageToRadianceImageFilterType::New(); diff --git a/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx index dfecb742ea..f34e799f51 100644 --- a/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx @@ -50,7 +50,7 @@ public: typedef otb::GenericRSTransform<> TransformType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ConvertCartoToGeoPoint"); SetDescription("Convert cartographic coordinates to geographic ones."); @@ -93,11 +93,11 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the projectionRef std::string inputProjRef = MapProjectionParametersHandler::GetProjectionRefFromChoice(this, "mapproj"); diff --git a/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx index 384c892f14..6e2b876cbe 100644 --- a/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx @@ -49,7 +49,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ConvertSensorToGeoPoint"); SetDescription("Sensor to geographic coordinates conversion."); @@ -101,11 +101,11 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get input Image FloatVectorImageType::Pointer inImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx b/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx index 1e3691514c..c4b4b58d7d 100644 --- a/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx +++ b/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx @@ -57,7 +57,7 @@ public: itkTypeMacro(GenerateRPCSensorModel, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("GenerateRPCSensorModel"); SetDescription("Generate a RPC sensor model from a list of Ground Control Points."); @@ -108,12 +108,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { OGRMultiLineString mls; diff --git a/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx b/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx index 72c9073a53..4a556f78b0 100644 --- a/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx +++ b/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx @@ -104,7 +104,7 @@ private: m_DisplacementFieldCaster = DisplacementFieldCastFilterType::New(); } - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("GridBasedImageResampling"); SetDescription("Resamples an image according to a resampling grid"); @@ -188,12 +188,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here } -void DoExecute() ITK_OVERRIDE +void DoExecute() override { // Get the input image FloatVectorImageType* inImage = GetParameterImage("io.in"); diff --git a/Modules/Applications/AppProjection/app/otbImageEnvelope.cxx b/Modules/Applications/AppProjection/app/otbImageEnvelope.cxx index cda6b1fc64..d276558e6f 100644 --- a/Modules/Applications/AppProjection/app/otbImageEnvelope.cxx +++ b/Modules/Applications/AppProjection/app/otbImageEnvelope.cxx @@ -49,7 +49,7 @@ public: <FloatVectorImageType, VectorDataType> EnvelopeFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ImageEnvelope"); SetDescription("Extracts an image envelope."); @@ -93,12 +93,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to be done } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType::Pointer input = GetParameterImage("in"); diff --git a/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx index 37d0ec7b74..24608c0530 100644 --- a/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx @@ -47,11 +47,11 @@ private: { } - ~ObtainUTMZoneFromGeoPoint() ITK_OVERRIDE + ~ObtainUTMZoneFromGeoPoint() override { } - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ObtainUTMZoneFromGeoPoint"); SetDescription("UTM zone determination from a geographic point."); @@ -84,12 +84,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { int utmZone = otb::Utils::GetZoneFromGeoPoint(GetParameterFloat("lon"), GetParameterFloat("lat")); diff --git a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx index 3c91403e47..fdc3308889 100644 --- a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx +++ b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx @@ -87,7 +87,7 @@ public: typedef otb::BCOInterpolateImageFunction<FloatVectorImageType> BCOInterpolationType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("OrthoRectification"); std::ostringstream oss; @@ -237,7 +237,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if (HasValue("io.in")) { @@ -601,7 +601,7 @@ private: } // if (HasValue("io.in")) } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the input image FloatVectorImageType* inImage = GetParameterImage("io.in"); diff --git a/Modules/Applications/AppProjection/app/otbRefineSensorModel.cxx b/Modules/Applications/AppProjection/app/otbRefineSensorModel.cxx index e5829eb164..653a4b77b8 100644 --- a/Modules/Applications/AppProjection/app/otbRefineSensorModel.cxx +++ b/Modules/Applications/AppProjection/app/otbRefineSensorModel.cxx @@ -56,7 +56,7 @@ public: itkTypeMacro(RefineSensorModel, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("RefineSensorModel"); SetDescription("Perform least-square fit of a sensor model to a set of tie points"); @@ -105,12 +105,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { OGRMultiLineString mls; diff --git a/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx b/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx index 7b6da7d245..e137a17eb8 100644 --- a/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx +++ b/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx @@ -80,7 +80,7 @@ public: private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("RigidTransformResample"); SetDescription("Resample an image with a rigid transform"); @@ -176,12 +176,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType* inputImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppProjection/app/otbSuperimpose.cxx b/Modules/Applications/AppProjection/app/otbSuperimpose.cxx index 1d1018e8fc..2c576c146d 100644 --- a/Modules/Applications/AppProjection/app/otbSuperimpose.cxx +++ b/Modules/Applications/AppProjection/app/otbSuperimpose.cxx @@ -81,7 +81,7 @@ public: FloatVectorImageType> BasicResamplerType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("Superimpose"); SetDescription("Using available image metadata, project one image onto another one"); @@ -159,7 +159,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if(!HasUserValue("mode") && HasValue("inr") && HasValue("inm") && otb::PleiadesPToXSAffineTransformCalculator::CanCompute(GetParameterImage("inr"),GetParameterImage("inm"))) { @@ -169,7 +169,7 @@ private: } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the inputs FloatVectorImageType* refImage = GetParameterImage("inr"); diff --git a/Modules/Applications/AppProjection/app/otbVectorDataReprojection.cxx b/Modules/Applications/AppProjection/app/otbVectorDataReprojection.cxx index fe9e070a8b..9d82850935 100644 --- a/Modules/Applications/AppProjection/app/otbVectorDataReprojection.cxx +++ b/Modules/Applications/AppProjection/app/otbVectorDataReprojection.cxx @@ -60,7 +60,7 @@ public: ; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("VectorDataReprojection"); std::ostringstream oss; @@ -117,12 +117,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { GetLogger()->Debug("Entering DoExecute\n"); diff --git a/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx b/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx index 7516787741..f43ab24301 100644 --- a/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx +++ b/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx @@ -45,7 +45,7 @@ public: FloatImageType> CalibrationFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("SARCalibration"); SetDescription("Perform radiometric calibration of SAR images. Following sensors are supported: TerraSAR-X, Sentinel1 and Radarsat-2.Both Single Look Complex(SLC) and detected products are supported as input.\n"); @@ -91,12 +91,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the input complex image ComplexFloatImageType* floatComplexImage = GetParameterComplexFloatImage("in"); diff --git a/Modules/Applications/AppSARCalibration/app/otbSARDeburst.cxx b/Modules/Applications/AppSARCalibration/app/otbSARDeburst.cxx index 01e09464a3..e86f601529 100644 --- a/Modules/Applications/AppSARCalibration/app/otbSARDeburst.cxx +++ b/Modules/Applications/AppSARCalibration/app/otbSARDeburst.cxx @@ -44,7 +44,7 @@ public: typedef otb::SarDeburstImageFilter<FloatVectorImageType> DeburstFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("SARDeburst"); SetDescription("This application performs deburst of Sentinel1 IW SLC images by removing redundant lines.\n"); @@ -88,10 +88,10 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override {} - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the input complex image FloatVectorImageType* in = GetParameterImage("in"); diff --git a/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx index 796d3f4e26..2a6ccbcf08 100644 --- a/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx +++ b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx @@ -84,7 +84,7 @@ public: itkTypeMacro(SARDecompositions, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("SARDecompositions"); SetDescription("From one-band complex images (each one related to an element of the Sinclair matrix), returns the selected decomposition."); @@ -160,12 +160,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { bool inhv = HasUserValue("inhv"); diff --git a/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx b/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx index 657643541d..c6a4122b0b 100644 --- a/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx +++ b/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx @@ -184,7 +184,7 @@ public: itkTypeMacro(SARPolarMatrixConvert, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("SARPolarMatrixConvert"); SetDescription("This applications allows converting classical polarimetric matrices to each other."); @@ -356,7 +356,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { int convType = GetParameterInt("conv"); @@ -440,7 +440,7 @@ private: } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { //**************************************** diff --git a/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx b/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx index 3db956847e..8fb514d814 100644 --- a/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx +++ b/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx @@ -44,7 +44,7 @@ public: itkTypeMacro(SARPolarSynth, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("SARPolarSynth"); SetDescription("Gives, for each pixel, the power that would have been received by a SAR system with a basis different from the classical (H,V) one (polarimetric synthetis)."); @@ -154,12 +154,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { m_MCPSFilter = MCPSFilterType::New(); diff --git a/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx b/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx index 6c949a2b9d..d6f580b773 100644 --- a/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx +++ b/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx @@ -57,7 +57,7 @@ public: typedef itk::ComplexToPhaseImageFilter<ComplexFloatImageType, FloatImageType> PhaseFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ComputeModulusAndPhase"); SetDescription("This application computes the modulus and the phase of a complex SAR image."); @@ -100,12 +100,12 @@ private: } // DoUpdateParameters() is called as soon as a parameter value change. - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } // DoExecute() contains the application core. - void DoExecute() ITK_OVERRIDE + void DoExecute() override { m_Modulus = ModulusFilterType::New(); m_Phase = PhaseFilterType::New(); diff --git a/Modules/Applications/AppSARUtils/app/otbDespeckle.cxx b/Modules/Applications/AppSARUtils/app/otbDespeckle.cxx index f469402397..e1fd6c8333 100644 --- a/Modules/Applications/AppSARUtils/app/otbDespeckle.cxx +++ b/Modules/Applications/AppSARUtils/app/otbDespeckle.cxx @@ -54,7 +54,7 @@ public: itkTypeMacro(Despeckle, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("Despeckle"); SetDescription("Perform speckle noise reduction on SAR image."); @@ -167,12 +167,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType* inVImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppSegmentation/app/otbConnectedComponentSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbConnectedComponentSegmentation.cxx index b9bc876f11..fa1acfa4d9 100644 --- a/Modules/Applications/AppSegmentation/app/otbConnectedComponentSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbConnectedComponentSegmentation.cxx @@ -69,7 +69,7 @@ public: <VectorDataType, VectorDataType> VectorDataProjectionFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ConnectedComponentSegmentation"); SetDescription("Connected component segmentation and object based image filtering of the input image according to user-defined criterions."); @@ -124,12 +124,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here for the parameters : all are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { InputVectorImageType::Pointer inputImage = GetParameterImage("in"); diff --git a/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx index 48dd57c2ad..936795067d 100644 --- a/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx @@ -130,7 +130,7 @@ public: <FloatPixelType, Int16PixelType> > HooverColorFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("HooverCompareSegmentation"); SetDescription("Compare two segmentations with Hoover metrics"); @@ -202,12 +202,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { UInt32ImageType::Pointer inputGT = GetParameterUInt32Image("ingt"); UInt32ImageType::Pointer inputMS = GetParameterUInt32Image("inms"); diff --git a/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx index 93694cc420..d1389c4355 100644 --- a/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx @@ -90,7 +90,7 @@ public: LSMSSegmentation(): m_FinalReader(),m_ImportGeoInformationFilter(),m_FilesToRemoveAfterExecute(),m_TmpDirCleanup(false){} - ~LSMSSegmentation() ITK_OVERRIDE{} + ~LSMSSegmentation() override{} private: LabelImageReaderType::Pointer m_FinalReader; @@ -214,7 +214,7 @@ private: return vrtfname; } - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("LSMSSegmentation"); SetDescription("This application performs the second step of the exact Large-Scale Mean-Shift segmentation workflow (LSMS) [1]."); @@ -320,11 +320,11 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { m_FilesToRemoveAfterExecute.clear(); @@ -719,7 +719,7 @@ private: SetParameterOutputImage("out",m_ImportGeoInformationFilter->GetOutput()); } - void AfterExecuteAndWriteOutputs() ITK_OVERRIDE + void AfterExecuteAndWriteOutputs() override { // Release input files m_FinalReader = ITK_NULLPTR; diff --git a/Modules/Applications/AppSegmentation/app/otbLSMSSmallRegionsMerging.cxx b/Modules/Applications/AppSegmentation/app/otbLSMSSmallRegionsMerging.cxx index 14c8354a14..afda10be1c 100644 --- a/Modules/Applications/AppSegmentation/app/otbLSMSSmallRegionsMerging.cxx +++ b/Modules/Applications/AppSegmentation/app/otbLSMSSmallRegionsMerging.cxx @@ -73,7 +73,7 @@ public: private: ChangeLabelImageFilterType::Pointer m_ChangeLabelFilter; - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("LSMSSmallRegionsMerging"); SetDescription("This application performs the third (optional) step of the exact Large-Scale Mean-Shift segmentation workflow [1]."); @@ -144,11 +144,11 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { clock_t tic = clock(); diff --git a/Modules/Applications/AppSegmentation/app/otbLSMSVectorization.cxx b/Modules/Applications/AppSegmentation/app/otbLSMSVectorization.cxx index 166b87141d..9881309a6b 100644 --- a/Modules/Applications/AppSegmentation/app/otbLSMSVectorization.cxx +++ b/Modules/Applications/AppSegmentation/app/otbLSMSVectorization.cxx @@ -66,7 +66,7 @@ public: itkTypeMacro(Vectorization, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("LSMSVectorization"); SetDescription("This application performs the fourth step of the exact Large-Scale Mean-Shift segmentation workflow [1]."); @@ -124,11 +124,11 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { clock_t tic = clock(); diff --git a/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx b/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx index 27f8da8377..e0527c5bc1 100644 --- a/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx +++ b/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx @@ -50,7 +50,7 @@ public: itkTypeMacro(LargeScaleMeanShift, otb::CompositeApplication); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("LargeScaleMeanShift"); SetDescription("Large-scale segmentation using MeanShift"); @@ -153,10 +153,10 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override {} - void DoExecute() ITK_OVERRIDE + void DoExecute() override { bool isVector(GetParameterString("mode") == "vector"); std::string outPath(isVector ? diff --git a/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx b/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx index 8f63bf13ef..937fc864cd 100644 --- a/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx +++ b/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx @@ -46,7 +46,7 @@ public: itkTypeMacro(MeanShiftSmoothing, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("MeanShiftSmoothing"); SetDescription("This application smooths an image using the MeanShift algorithm."); @@ -176,10 +176,10 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override {} - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType* input = GetParameterImage("in"); diff --git a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx index 5b3bfd2361..cd8fccf97c 100644 --- a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx @@ -137,7 +137,7 @@ public: itkTypeMacro(Segmentation, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("Segmentation"); SetDescription("Performs segmentation of an image, and output either a raster or a vector file. In vector mode, large input datasets are supported."); @@ -348,7 +348,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } @@ -457,7 +457,7 @@ private: return streamingVectorizedFilter->GetStreamSize(); } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Switch on segmentation mode const std::string segModeType = GetParameterString("mode"); diff --git a/Modules/Applications/AppStereo/app/otbBlockMatching.cxx b/Modules/Applications/AppStereo/app/otbBlockMatching.cxx index 2ec8f7e63a..328065b7ea 100644 --- a/Modules/Applications/AppStereo/app/otbBlockMatching.cxx +++ b/Modules/Applications/AppStereo/app/otbBlockMatching.cxx @@ -124,7 +124,7 @@ private: m_VMedianFilter = MedianFilterType::New(); } - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("BlockMatching"); SetDescription("Performs block-matching to estimate pixel-wise disparities" @@ -425,7 +425,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if(IsParameterEnabled("mask.variancet") || IsParameterEnabled("mask.nodata")) { @@ -458,7 +458,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatImageType::Pointer leftImage = GetParameterFloatImage("io.inleft"); FloatImageType::Pointer rightImage = GetParameterFloatImage("io.inright"); diff --git a/Modules/Applications/AppStereo/app/otbDisparityMapToElevationMap.cxx b/Modules/Applications/AppStereo/app/otbDisparityMapToElevationMap.cxx index 25e4b96189..551ad0f1e4 100644 --- a/Modules/Applications/AppStereo/app/otbDisparityMapToElevationMap.cxx +++ b/Modules/Applications/AppStereo/app/otbDisparityMapToElevationMap.cxx @@ -62,7 +62,7 @@ private: m_DispToElev = DisparityToElevationFilterType::New(); } - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("DisparityMapToElevationMap"); SetDescription("Projects a disparity map into a regular elevation map."); @@ -163,12 +163,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType::Pointer inputDisp = this->GetParameterImage("io.in"); FloatVectorImageType::Pointer sensorLeft = this->GetParameterImage("io.left"); diff --git a/Modules/Applications/AppStereo/app/otbFineRegistration.cxx b/Modules/Applications/AppStereo/app/otbFineRegistration.cxx index a7fed89a0e..64bf6ca0e4 100644 --- a/Modules/Applications/AppStereo/app/otbFineRegistration.cxx +++ b/Modules/Applications/AppStereo/app/otbFineRegistration.cxx @@ -114,7 +114,7 @@ public: typedef otb::ImageFileReader<VectorImageType> InternalReaderType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("FineRegistration"); SetDescription("Estimate disparity map between two images."); @@ -266,12 +266,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType::Pointer refImage = GetParameterImage("ref"); // fixed FloatVectorImageType::Pointer secImage = GetParameterImage("sec"); // moved diff --git a/Modules/Applications/AppStereo/app/otbGeneratePlyFile.cxx b/Modules/Applications/AppStereo/app/otbGeneratePlyFile.cxx index 928b1da3e6..4f1fce4ee2 100644 --- a/Modules/Applications/AppStereo/app/otbGeneratePlyFile.cxx +++ b/Modules/Applications/AppStereo/app/otbGeneratePlyFile.cxx @@ -52,7 +52,7 @@ public: private: GeneratePlyFile(){} - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("GeneratePlyFile"); SetDescription("Generate a 3D Ply file from a DEM and a color image."); @@ -115,13 +115,13 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Update the UTM zone params MapProjectionParametersHandler::InitializeUTMParameters(this, "incolor", "map"); } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { std::string outfname = GetParameterString("out"); diff --git a/Modules/Applications/AppStereo/app/otbStereoFramework.cxx b/Modules/Applications/AppStereo/app/otbStereoFramework.cxx index 279c09ad2f..1737d04e29 100644 --- a/Modules/Applications/AppStereo/app/otbStereoFramework.cxx +++ b/Modules/Applications/AppStereo/app/otbStereoFramework.cxx @@ -311,7 +311,7 @@ private: } - void DoInit() ITK_OVERRIDE + void DoInit() override { // TODO : implement this application as a CompositeApplication... SetName("StereoFramework"); @@ -584,7 +584,7 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { if( HasValue("input.il") ) { @@ -650,7 +650,7 @@ private: } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Setup the DSM Handler otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this, "elev"); diff --git a/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx b/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx index 616594a6bb..c95a08e1d4 100644 --- a/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx +++ b/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx @@ -99,7 +99,7 @@ private: m_StatisticsFilter = StatisticsFilterType::New(); } - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("StereoRectificationGridGenerator"); SetDescription("Generates two deformation fields to resample in epipolar " @@ -249,12 +249,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { m_DisplacementFieldSource->SetLeftImage(GetParameterImage("io.inleft")); m_DisplacementFieldSource->SetRightImage(GetParameterImage("io.inright")); diff --git a/Modules/Applications/AppTest/app/otbTestApplication.cxx b/Modules/Applications/AppTest/app/otbTestApplication.cxx index a2e9ee940d..5746409209 100644 --- a/Modules/Applications/AppTest/app/otbTestApplication.cxx +++ b/Modules/Applications/AppTest/app/otbTestApplication.cxx @@ -42,7 +42,7 @@ public: itkTypeMacro(TestApplication, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("TestApplication"); SetDescription("This application helps developers to test parameters types"); @@ -112,10 +112,10 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override {} - void DoExecute() ITK_OVERRIDE + void DoExecute() override { if( HasValue("il") && IsParameterEnabled("il") ) { diff --git a/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx b/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx index 43e6b0b0e1..fdf5f44e7c 100644 --- a/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx +++ b/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx @@ -67,7 +67,7 @@ itkTypeMacro(HaralickTextureExtraction, otb::Application); private: -void DoInit() ITK_OVERRIDE +void DoInit() override { SetName("HaralickTextureExtraction"); SetDescription("Computes Haralick textural features on the selected channel of the input image"); @@ -192,12 +192,12 @@ SetDocExampleParameterValue("out", "HaralickTextures.tif"); SetOfficialDocLink(); } -void DoUpdateParameters() ITK_OVERRIDE +void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } -void DoExecute() ITK_OVERRIDE +void DoExecute() override { FloatVectorImageType::Pointer inImage = GetParameterImage("in"); inImage->UpdateOutputInformation(); diff --git a/Modules/Applications/AppTextures/app/otbSFSTextureExtraction.cxx b/Modules/Applications/AppTextures/app/otbSFSTextureExtraction.cxx index 94fcc42905..13ade82049 100644 --- a/Modules/Applications/AppTextures/app/otbSFSTextureExtraction.cxx +++ b/Modules/Applications/AppTextures/app/otbSFSTextureExtraction.cxx @@ -56,7 +56,7 @@ itkTypeMacro(SFSTextureExtraction, otb::Application); private: -void DoInit() ITK_OVERRIDE +void DoInit() override { SetName("SFSTextureExtraction"); SetDescription("Computes Structural Feature Set textures on every pixel of the " @@ -129,12 +129,12 @@ SetDocExampleParameterValue("out", "SFSTextures.tif"); SetOfficialDocLink(); } -void DoUpdateParameters() ITK_OVERRIDE +void DoUpdateParameters() override { // Nothing to do here : all parameters are independent } -void DoExecute() ITK_OVERRIDE +void DoExecute() override { FloatVectorImageType::Pointer inImage = GetParameterImage("in"); inImage->UpdateOutputInformation(); diff --git a/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx b/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx index 748d8f27be..7d784ae306 100644 --- a/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx +++ b/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx @@ -60,7 +60,7 @@ public: typedef otb::OGRDataSourceToLabelImageFilter<FloatImageType> OGRDataSourceToMapFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("Rasterization"); SetDescription("Rasterize a vector dataset."); @@ -144,13 +144,13 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { otb::ogr::DataSource::Pointer ogrDS; UInt8ImageType::Pointer referenceImage; diff --git a/Modules/Applications/AppVectorUtils/app/otbConcatenateVectorData.cxx b/Modules/Applications/AppVectorUtils/app/otbConcatenateVectorData.cxx index 92b972eafc..d8b51471a3 100644 --- a/Modules/Applications/AppVectorUtils/app/otbConcatenateVectorData.cxx +++ b/Modules/Applications/AppVectorUtils/app/otbConcatenateVectorData.cxx @@ -47,7 +47,7 @@ public: typedef otb::ConcatenateVectorDataFilter<VectorDataType> ConcatenateFilterType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("ConcatenateVectorData"); SetDescription("Concatenate vector data files"); @@ -81,12 +81,12 @@ private: } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here for the parameters : all are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the input VectorData list VectorDataListType* vectorDataList = GetParameterVectorDataList("vd"); diff --git a/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx b/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx index d55626ed0b..e1f9a53600 100644 --- a/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx +++ b/Modules/Applications/AppVectorUtils/app/otbOSMDownloader.cxx @@ -50,7 +50,7 @@ public: typedef otb::OSMDataToVectorDataGenerator VectorDataProviderType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("OSMDownloader"); SetDescription("Download vector data from OSM and store it to file"); @@ -113,7 +113,7 @@ private: } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // CASE: when the -print option is not required and the User // does not set the option OSMKey or the option Output or does not @@ -130,7 +130,7 @@ private: } } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { typedef otb::ImageToEnvelopeVectorDataFilter<FloatVectorImageType, VectorDataType> EnvelopeFilterType; diff --git a/Modules/Applications/AppVectorUtils/app/otbVectorDataExtractROI.cxx b/Modules/Applications/AppVectorUtils/app/otbVectorDataExtractROI.cxx index 1b4e8c8bf7..de6f6f9db7 100644 --- a/Modules/Applications/AppVectorUtils/app/otbVectorDataExtractROI.cxx +++ b/Modules/Applications/AppVectorUtils/app/otbVectorDataExtractROI.cxx @@ -65,7 +65,7 @@ public: typedef otb::RemoteSensingRegion<double> RemoteSensingRegionType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("VectorDataExtractROI"); SetDescription("Perform an extract ROI on the input vector data according to the input image extent"); @@ -106,12 +106,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do here for the parameters : all are independent } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the inputs VectorDataType* vd = GetParameterVectorData("io.vd"); diff --git a/Modules/Applications/AppVectorUtils/app/otbVectorDataSetField.cxx b/Modules/Applications/AppVectorUtils/app/otbVectorDataSetField.cxx index 696a48a7f2..21d09e16ce 100644 --- a/Modules/Applications/AppVectorUtils/app/otbVectorDataSetField.cxx +++ b/Modules/Applications/AppVectorUtils/app/otbVectorDataSetField.cxx @@ -43,7 +43,7 @@ public: itkTypeMacro(VectorDataSetField, otb::Application); private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("VectorDataSetField"); SetDescription("Set a field in vector data."); @@ -76,12 +76,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // Nothing to do (for now) } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { m_InputData = GetParameterVectorData("in"); diff --git a/Modules/Applications/AppVectorUtils/app/otbVectorDataTransform.cxx b/Modules/Applications/AppVectorUtils/app/otbVectorDataTransform.cxx index be16319089..ba4614d77b 100644 --- a/Modules/Applications/AppVectorUtils/app/otbVectorDataTransform.cxx +++ b/Modules/Applications/AppVectorUtils/app/otbVectorDataTransform.cxx @@ -54,7 +54,7 @@ public: typedef itk::CenteredSimilarity2DTransform<double> TransformType; private: - void DoInit() ITK_OVERRIDE + void DoInit() override { SetName("VectorDataTransform"); SetDescription("Apply a transform to each vertex of the input VectorData"); @@ -129,12 +129,12 @@ private: SetOfficialDocLink(); } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { // nothing to update } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { // Get the support image FloatVectorImageType* inImage = GetParameterImage("in"); diff --git a/Modules/Core/CommandLineParser/include/otbCommandLineArgumentParser.h b/Modules/Core/CommandLineParser/include/otbCommandLineArgumentParser.h index ba7fc9601f..0132979d2f 100644 --- a/Modules/Core/CommandLineParser/include/otbCommandLineArgumentParser.h +++ b/Modules/Core/CommandLineParser/include/otbCommandLineArgumentParser.h @@ -140,7 +140,7 @@ public: // const char *GetOptionParameter(const char *option, unsigned int number = 0); int GetNumberOfParameters(const std::string& option); - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; #define otbGetParameterMacro(name, type) \ virtual type GetParameter ## name (const std::string& option, unsigned int number = 0) const \ @@ -170,7 +170,7 @@ public: protected: CommandLineArgumentParseResult(); - ~CommandLineArgumentParseResult() ITK_OVERRIDE; + ~CommandLineArgumentParseResult() override; private: template<typename TypeValeur> @@ -254,7 +254,7 @@ public: protected: CommandLineArgumentParser(); - ~CommandLineArgumentParser() ITK_OVERRIDE; + ~CommandLineArgumentParser() override; private: diff --git a/Modules/Core/Common/include/otbChannelSelectorFunctor.h b/Modules/Core/Common/include/otbChannelSelectorFunctor.h index d1cf2304d9..f758fb7b2a 100644 --- a/Modules/Core/Common/include/otbChannelSelectorFunctor.h +++ b/Modules/Core/Common/include/otbChannelSelectorFunctor.h @@ -248,7 +248,7 @@ protected: } /** Destructor */ - ~ChannelSelectorFunctor() ITK_OVERRIDE {} + ~ChannelSelectorFunctor() override {} private: diff --git a/Modules/Core/Common/include/otbCommandProgressUpdate.h b/Modules/Core/Common/include/otbCommandProgressUpdate.h index c9e553703b..14e61cb810 100644 --- a/Modules/Core/Common/include/otbCommandProgressUpdate.h +++ b/Modules/Core/Common/include/otbCommandProgressUpdate.h @@ -48,9 +48,9 @@ protected: public: typedef const TFilter * FilterPointer; - void Execute(itk::Object *caller, const itk::EventObject& event) ITK_OVERRIDE; + void Execute(itk::Object *caller, const itk::EventObject& event) override; - void Execute(const itk::Object * object, const itk::EventObject& event) ITK_OVERRIDE; + void Execute(const itk::Object * object, const itk::EventObject& event) override; }; } // end namespace otb diff --git a/Modules/Core/Common/include/otbComplexToIntensityImageFilter.h b/Modules/Core/Common/include/otbComplexToIntensityImageFilter.h index e98900b9c3..a3faddf351 100644 --- a/Modules/Core/Common/include/otbComplexToIntensityImageFilter.h +++ b/Modules/Core/Common/include/otbComplexToIntensityImageFilter.h @@ -99,7 +99,7 @@ public: protected: ComplexToIntensityImageFilter() {} - ~ComplexToIntensityImageFilter() ITK_OVERRIDE {} + ~ComplexToIntensityImageFilter() override {} private: ComplexToIntensityImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Core/Common/include/otbComplexToVectorImageCastFilter.h b/Modules/Core/Common/include/otbComplexToVectorImageCastFilter.h index 377f537ee0..85598ccecb 100644 --- a/Modules/Core/Common/include/otbComplexToVectorImageCastFilter.h +++ b/Modules/Core/Common/include/otbComplexToVectorImageCastFilter.h @@ -140,7 +140,7 @@ public: protected: ComplexToVectorImageCastFilter() {} - ~ComplexToVectorImageCastFilter() ITK_OVERRIDE {} + ~ComplexToVectorImageCastFilter() override {} template<class T> bool PixelIsSingle(const T& /*dummy*/) @@ -154,7 +154,7 @@ protected: return false; } - void GenerateOutputInformation() ITK_OVERRIDE + void GenerateOutputInformation() override { Superclass::GenerateOutputInformation(); InputPixelType dummy; diff --git a/Modules/Core/Common/include/otbDotProductImageFilter.h b/Modules/Core/Common/include/otbDotProductImageFilter.h index 49dc8e5df1..1112606aca 100644 --- a/Modules/Core/Common/include/otbDotProductImageFilter.h +++ b/Modules/Core/Common/include/otbDotProductImageFilter.h @@ -140,9 +140,9 @@ public: protected: DotProductImageFilter(); - ~DotProductImageFilter() ITK_OVERRIDE {} + ~DotProductImageFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: DotProductImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/Common/include/otbFunctionToImageFilter.h b/Modules/Core/Common/include/otbFunctionToImageFilter.h index a126c9c3d1..29098833a9 100644 --- a/Modules/Core/Common/include/otbFunctionToImageFilter.h +++ b/Modules/Core/Common/include/otbFunctionToImageFilter.h @@ -108,11 +108,11 @@ public: protected: FunctionToImageFilter(); - ~FunctionToImageFilter() ITK_OVERRIDE {} + ~FunctionToImageFilter() override {} /** Validate the presence of all three inputs. If one or more inputs * are missing, throw an exception. */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** SpatialFunctionImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -125,7 +125,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: FunctionToImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/Common/include/otbImageAndVectorImageOperationFilter.h b/Modules/Core/Common/include/otbImageAndVectorImageOperationFilter.h index d5e32b6564..060b01ba29 100644 --- a/Modules/Core/Common/include/otbImageAndVectorImageOperationFilter.h +++ b/Modules/Core/Common/include/otbImageAndVectorImageOperationFilter.h @@ -163,7 +163,7 @@ public: /** Set the input images of this process object. */ using Superclass::SetInput; - void SetInput(const InputImageType *input) ITK_OVERRIDE; + void SetInput(const InputImageType *input) override; void SetVectorInput(const VectorInputImageType *input); /** Get the input images of this process object. */ @@ -215,12 +215,12 @@ public: protected: ImageAndVectorImageOperationFilter(); - ~ImageAndVectorImageOperationFilter() ITK_OVERRIDE; + ~ImageAndVectorImageOperationFilter() override; /** This is a source, so it must set the spacing, size, and largest possible * region for the output image that it will produce. * \sa ProcessObject::GenerateOutputInformation() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: ImageAndVectorImageOperationFilter(const ImageAndVectorImageOperationFilter &); //purposely not implemented diff --git a/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.h b/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.h index 3d65acecdc..91bdde5214 100644 --- a/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.h +++ b/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.h @@ -123,16 +123,16 @@ public: * necessary. */ unsigned int GetNumberOfSplits(const RegionType& region, - unsigned int requestedNumber) ITK_OVERRIDE; + unsigned int requestedNumber) override; /** Calling this method will set the image region and the requested * number of splits, and call the EstimateSplitMap() method if * necessary. */ RegionType GetSplit(unsigned int i, unsigned int numberOfPieces, - const RegionType& region) ITK_OVERRIDE; + const RegionType& region) override; /** Make the Modified() method update the IsUpToDate flag */ - void Modified() const ITK_OVERRIDE + void Modified() const override { // Call superclass implementation Superclass::Modified(); @@ -149,8 +149,8 @@ protected: m_IsUpToDate(false) {} - ~ImageRegionAdaptativeSplitter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageRegionAdaptativeSplitter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** This methods actually estimate the split map and stores it in a diff --git a/Modules/Core/Common/include/otbImageRegionNonUniformMultidimensionalSplitter.h b/Modules/Core/Common/include/otbImageRegionNonUniformMultidimensionalSplitter.h index 497122f769..dfd3132fb6 100644 --- a/Modules/Core/Common/include/otbImageRegionNonUniformMultidimensionalSplitter.h +++ b/Modules/Core/Common/include/otbImageRegionNonUniformMultidimensionalSplitter.h @@ -97,18 +97,18 @@ public: * method returns a number less than or equal to the requested number * of pieces. */ unsigned int GetNumberOfSplits(const RegionType& region, - unsigned int requestedNumber) ITK_OVERRIDE; + unsigned int requestedNumber) override; /** Get a region definition that represents the ith piece a specified region. * The "numberOfPieces" specified should be less than or equal to what * GetNumberOfSplits() returns. */ RegionType GetSplit(unsigned int i, unsigned int numberOfPieces, - const RegionType& region) ITK_OVERRIDE; + const RegionType& region) override; protected: ImageRegionNonUniformMultidimensionalSplitter() {} - ~ImageRegionNonUniformMultidimensionalSplitter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageRegionNonUniformMultidimensionalSplitter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageRegionNonUniformMultidimensionalSplitter(const Self &); //purposely not implemented diff --git a/Modules/Core/Common/include/otbImageRegionSquareTileSplitter.h b/Modules/Core/Common/include/otbImageRegionSquareTileSplitter.h index 3665210b5d..a26e4f8269 100644 --- a/Modules/Core/Common/include/otbImageRegionSquareTileSplitter.h +++ b/Modules/Core/Common/include/otbImageRegionSquareTileSplitter.h @@ -113,13 +113,13 @@ public: * a certain dimensions, then some splits will not be possible. */ unsigned int GetNumberOfSplits(const RegionType& region, - unsigned int requestedNumber) ITK_OVERRIDE; + unsigned int requestedNumber) override; /** Get a region definition that represents the ith piece a specified region. * The "numberOfPieces" specified should be less than or equal to what * GetNumberOfSplits() returns. */ RegionType GetSplit(unsigned int i, unsigned int numberOfPieces, - const RegionType& region) ITK_OVERRIDE; + const RegionType& region) override; itkGetMacro(TileSizeAlignment, unsigned int); itkSetMacro(TileSizeAlignment, unsigned int); @@ -128,8 +128,8 @@ public: protected: ImageRegionSquareTileSplitter() : m_SplitsPerDimension(0U), m_TileDimension(0), m_TileSizeAlignment(16) {} - ~ImageRegionSquareTileSplitter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageRegionSquareTileSplitter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageRegionSquareTileSplitter(const ImageRegionSquareTileSplitter &); //purposely not implemented diff --git a/Modules/Core/Common/include/otbImageRegionTileMapSplitter.h b/Modules/Core/Common/include/otbImageRegionTileMapSplitter.h index d8dd4dc0bc..091ff9e88f 100644 --- a/Modules/Core/Common/include/otbImageRegionTileMapSplitter.h +++ b/Modules/Core/Common/include/otbImageRegionTileMapSplitter.h @@ -114,18 +114,18 @@ public: * method returns a number less than or equal to the requested number * of pieces. */ unsigned int GetNumberOfSplits(const RegionType& region, - unsigned int requestedNumber) ITK_OVERRIDE; + unsigned int requestedNumber) override; /** Get a region definition that represents the ith piece a specified region. * The "numberOfPieces" specified should be less than or equal to what * GetNumberOfSplits() returns. */ RegionType GetSplit(unsigned int i, unsigned int numberOfPieces, - const RegionType& region) ITK_OVERRIDE; + const RegionType& region) override; protected: ImageRegionTileMapSplitter() : m_AlignStep(256){} - ~ImageRegionTileMapSplitter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageRegionTileMapSplitter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageRegionTileMapSplitter(const ImageRegionTileMapSplitter &); //purposely not implemented diff --git a/Modules/Core/Common/include/otbImageToModulusAndDirectionImageFilter.h b/Modules/Core/Common/include/otbImageToModulusAndDirectionImageFilter.h index f6cc79abff..32192a6833 100644 --- a/Modules/Core/Common/include/otbImageToModulusAndDirectionImageFilter.h +++ b/Modules/Core/Common/include/otbImageToModulusAndDirectionImageFilter.h @@ -86,12 +86,12 @@ public: /** Return the output image direction */ OutputImageDirectionType * GetOutputDirection(); - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; protected: ImageToModulusAndDirectionImageFilter(); - ~ImageToModulusAndDirectionImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageToModulusAndDirectionImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageToModulusAndDirectionImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/Common/include/otbImaginaryImageToComplexImageFilter.h b/Modules/Core/Common/include/otbImaginaryImageToComplexImageFilter.h index 9ee44c5a2d..26e99427a9 100644 --- a/Modules/Core/Common/include/otbImaginaryImageToComplexImageFilter.h +++ b/Modules/Core/Common/include/otbImaginaryImageToComplexImageFilter.h @@ -92,7 +92,7 @@ public: protected: ImaginaryImageToComplexImageFilter() {} - ~ImaginaryImageToComplexImageFilter() ITK_OVERRIDE {} + ~ImaginaryImageToComplexImageFilter() override {} private: ImaginaryImageToComplexImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Core/Common/include/otbImportImageFilter.h b/Modules/Core/Common/include/otbImportImageFilter.h index 9f21873c3c..4965422f06 100644 --- a/Modules/Core/Common/include/otbImportImageFilter.h +++ b/Modules/Core/Common/include/otbImportImageFilter.h @@ -143,26 +143,26 @@ public: protected: ImportImageFilter(); - ~ImportImageFilter() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImportImageFilter() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** This filter does not actually "produce" any data, rather it "wraps" * the user supplied data into an itk::Image. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** This is a source, so it must set the spacing, size, and largest possible * region for the output image that it will produce. * \sa ProcessObject::GenerateOutputInformation() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** This filter can only produce the amount of data that it is given, - * so we must ITK_OVERRIDE ProcessObject::EnlargeOutputRequestedRegion() + * so we must override ProcessObject::EnlargeOutputRequestedRegion() * (The default implementation of a source produces the amount of * data requested. This source, however, can only produce what it is * given.) * * \sa ProcessObject::EnlargeOutputRequestedRegion() */ - void EnlargeOutputRequestedRegion(itk::DataObject *output) ITK_OVERRIDE; + void EnlargeOutputRequestedRegion(itk::DataObject *output) override; private: ImportImageFilter(const ImportImageFilter &); //purposely not implemented diff --git a/Modules/Core/Common/include/otbImportVectorImageFilter.h b/Modules/Core/Common/include/otbImportVectorImageFilter.h index c7db035c25..b333f99ac9 100644 --- a/Modules/Core/Common/include/otbImportVectorImageFilter.h +++ b/Modules/Core/Common/include/otbImportVectorImageFilter.h @@ -160,7 +160,7 @@ protected: virtual void GenerateOutputInformation(); /** This filter can only produce the amount of data that it is given, - * so we must ITK_OVERRIDE ProcessObject::EnlargeOutputRequestedRegion() + * so we must override ProcessObject::EnlargeOutputRequestedRegion() * (The default implementation of a source produces the amount of * data requested. This source, however, can only produce what it is * given.) diff --git a/Modules/Core/Common/include/otbModelComponentBase.h b/Modules/Core/Common/include/otbModelComponentBase.h index 1bb6180576..758c887ac9 100644 --- a/Modules/Core/Common/include/otbModelComponentBase.h +++ b/Modules/Core/Common/include/otbModelComponentBase.h @@ -130,8 +130,8 @@ public: protected: ModelComponentBase(); - ~ModelComponentBase() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ModelComponentBase() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; virtual void GenerateData(); diff --git a/Modules/Core/Common/include/otbModelComponentBase.txx b/Modules/Core/Common/include/otbModelComponentBase.txx index ff48935796..74bf396ded 100644 --- a/Modules/Core/Common/include/otbModelComponentBase.txx +++ b/Modules/Core/Common/include/otbModelComponentBase.txx @@ -188,7 +188,7 @@ void ModelComponentBase<TSample> ::GenerateData() { - /** subclasses should ITK_OVERRIDE this function to perform + /** subclasses should override this function to perform * parameter estimation. But it allows switching m_SampleModified * when necessary. */ diff --git a/Modules/Core/Common/include/otbQuaternaryFunctorImageFilter.h b/Modules/Core/Common/include/otbQuaternaryFunctorImageFilter.h index cf3a1d8b27..0373dbf769 100644 --- a/Modules/Core/Common/include/otbQuaternaryFunctorImageFilter.h +++ b/Modules/Core/Common/include/otbQuaternaryFunctorImageFilter.h @@ -142,11 +142,11 @@ public: protected: QuaternaryFunctorImageFilter(); - ~QuaternaryFunctorImageFilter() ITK_OVERRIDE {} + ~QuaternaryFunctorImageFilter() override {} /** Validate the presence of all three inputs. If one or more inputs * are missing, throw an exception. */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** QuaternaryFunctorImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -159,7 +159,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: QuaternaryFunctorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/Common/include/otbRGBAPixelConverter.h b/Modules/Core/Common/include/otbRGBAPixelConverter.h index 8384c3c815..45741fb683 100644 --- a/Modules/Core/Common/include/otbRGBAPixelConverter.h +++ b/Modules/Core/Common/include/otbRGBAPixelConverter.h @@ -66,8 +66,8 @@ public: protected: RGBAPixelConverter(){} - ~RGBAPixelConverter() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~RGBAPixelConverter() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } @@ -103,8 +103,8 @@ public: protected: RGBAPixelConverter(){} - ~RGBAPixelConverter() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~RGBAPixelConverter() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } @@ -140,8 +140,8 @@ public: protected: RGBAPixelConverter(){} - ~RGBAPixelConverter() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~RGBAPixelConverter() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Core/Common/include/otbRectangle.h b/Modules/Core/Common/include/otbRectangle.h index b5da22fd45..17a90c6c29 100644 --- a/Modules/Core/Common/include/otbRectangle.h +++ b/Modules/Core/Common/include/otbRectangle.h @@ -100,10 +100,10 @@ protected: }; /** Destructor */ - ~Rectangle() ITK_OVERRIDE {} + ~Rectangle() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** */ virtual double ComputeEuclideanDistanceMetricToSegment(VertexType q1, VertexType q2, VertexType p) const; diff --git a/Modules/Core/Common/include/otbStandardFilterWatcher.h b/Modules/Core/Common/include/otbStandardFilterWatcher.h index 2e4670bc86..f9216d5077 100644 --- a/Modules/Core/Common/include/otbStandardFilterWatcher.h +++ b/Modules/Core/Common/include/otbStandardFilterWatcher.h @@ -83,13 +83,13 @@ public: protected: /** Callback method to show the ProgressEvent */ - void ShowProgress() ITK_OVERRIDE; + void ShowProgress() override; /** Callback method to show the StartEvent */ - void StartFilter() ITK_OVERRIDE; + void StartFilter() override; /** Callback method to show the EndEvent */ - void EndFilter() ITK_OVERRIDE; + void EndFilter() override; private: diff --git a/Modules/Core/Common/include/otbStandardOneLineFilterWatcher.h b/Modules/Core/Common/include/otbStandardOneLineFilterWatcher.h index 0f7ba0fe6a..9ee3992b0b 100644 --- a/Modules/Core/Common/include/otbStandardOneLineFilterWatcher.h +++ b/Modules/Core/Common/include/otbStandardOneLineFilterWatcher.h @@ -77,13 +77,13 @@ public: protected: /** Callback method to show the ProgressEvent */ - void ShowProgress() ITK_OVERRIDE; + void ShowProgress() override; /** Callback method to show the StartEvent */ - void StartFilter() ITK_OVERRIDE; + void StartFilter() override; /** Callback method to show the EndEvent */ - void EndFilter() ITK_OVERRIDE; + void EndFilter() override; private: diff --git a/Modules/Core/Common/include/otbStandardWriterWatcher.h b/Modules/Core/Common/include/otbStandardWriterWatcher.h index b66b199792..ab3936d9b7 100644 --- a/Modules/Core/Common/include/otbStandardWriterWatcher.h +++ b/Modules/Core/Common/include/otbStandardWriterWatcher.h @@ -87,22 +87,22 @@ public: protected: /** Callback method to show the ProgressEvent */ - void ShowWriterProgress() ITK_OVERRIDE; + void ShowWriterProgress() override; /** Callback method to show the StartEvent */ - void StartWriter() ITK_OVERRIDE; + void StartWriter() override; /** Callback method to show the EndEvent */ - void EndWriter() ITK_OVERRIDE; + void EndWriter() override; /** Callback method to show the ProgressEvent */ - void ShowFilterProgress() ITK_OVERRIDE; + void ShowFilterProgress() override; /** Callback method to show the StartEvent */ - void StartFilter() ITK_OVERRIDE {} + void StartFilter() override {} /** Callback method to show the EndEvent */ - void EndFilter() ITK_OVERRIDE {} + void EndFilter() override {} /** This is the method invoked by ShowFilterProgress() and ShowWriterProgress() */ virtual void ShowProgress(); diff --git a/Modules/Core/Common/include/otbSubsampledImageRegionConstIterator.h b/Modules/Core/Common/include/otbSubsampledImageRegionConstIterator.h index 8301929fd1..1b80e8f8cf 100644 --- a/Modules/Core/Common/include/otbSubsampledImageRegionConstIterator.h +++ b/Modules/Core/Common/include/otbSubsampledImageRegionConstIterator.h @@ -166,7 +166,7 @@ public: /** Set the index. * It is moved to the next available (usable) index. * \sa GetIndex */ - void SetIndex(const IndexType& ind) ITK_OVERRIDE; + void SetIndex(const IndexType& ind) override; /** Get the Index. */ IndexType GetIndex() const diff --git a/Modules/Core/Common/include/otbUnaryFunctorImageFilter.h b/Modules/Core/Common/include/otbUnaryFunctorImageFilter.h index 2217de58ba..bfffcd8ad2 100644 --- a/Modules/Core/Common/include/otbUnaryFunctorImageFilter.h +++ b/Modules/Core/Common/include/otbUnaryFunctorImageFilter.h @@ -58,7 +58,7 @@ public: protected: UnaryFunctorImageFilter() {}; - ~UnaryFunctorImageFilter() ITK_OVERRIDE {} + ~UnaryFunctorImageFilter() override {} /** UnaryFunctorImageFilter can produce an image which has a different number of bands * than its input image. As such, UnaryFunctorImageFilter @@ -68,7 +68,7 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE + void GenerateOutputInformation() override { Superclass::GenerateOutputInformation(); typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); diff --git a/Modules/Core/Common/include/otbUnaryFunctorNeighborhoodVectorImageFilter.h b/Modules/Core/Common/include/otbUnaryFunctorNeighborhoodVectorImageFilter.h index e38717f813..bdd7dfbf72 100644 --- a/Modules/Core/Common/include/otbUnaryFunctorNeighborhoodVectorImageFilter.h +++ b/Modules/Core/Common/include/otbUnaryFunctorNeighborhoodVectorImageFilter.h @@ -108,7 +108,7 @@ public: protected: UnaryFunctorNeighborhoodVectorImageFilter(); - ~UnaryFunctorNeighborhoodVectorImageFilter() ITK_OVERRIDE { } + ~UnaryFunctorNeighborhoodVectorImageFilter() override { } /** UnaryFunctorNeighborhoodVectorImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -121,13 +121,13 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; /** * Since the number of components per pixel depends on the radius range, one must reimplement * this method to set the proper number of component on the filter output. */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; RadiusType m_Radius; diff --git a/Modules/Core/Common/include/otbUnaryFunctorVectorImageFilter.h b/Modules/Core/Common/include/otbUnaryFunctorVectorImageFilter.h index b83b659424..cd24feafdf 100644 --- a/Modules/Core/Common/include/otbUnaryFunctorVectorImageFilter.h +++ b/Modules/Core/Common/include/otbUnaryFunctorVectorImageFilter.h @@ -93,7 +93,7 @@ public: protected: UnaryFunctorVectorImageFilter(); - ~UnaryFunctorVectorImageFilter() ITK_OVERRIDE { } + ~UnaryFunctorVectorImageFilter() override { } /** UnaryFunctorVectorImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -106,13 +106,13 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; /** * Since the number of components per pixel depends on the radius range, one must reimplement * this method to set the proper number of component on the filter output. */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; private: UnaryFunctorVectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/Common/include/otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h b/Modules/Core/Common/include/otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h index edd0854c39..ddaeca2e00 100644 --- a/Modules/Core/Common/include/otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h +++ b/Modules/Core/Common/include/otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h @@ -111,7 +111,7 @@ protected: /** * Destructor */ - ~UnaryFunctorWithIndexWithOutputSizeImageFilter() ITK_OVERRIDE {} + ~UnaryFunctorWithIndexWithOutputSizeImageFilter() override {} /** UnaryFunctorWithIndexWithOutputSizeImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -123,12 +123,12 @@ protected: * * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** * Pad the input requested region by radius */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** UnaryFunctorWithIndexWithOutputSizeImageFilter can produce an image which has a different number of bands * than its input image. As such, UnaryFunctorImageFilter @@ -138,7 +138,7 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE + void GenerateOutputInformation() override { Superclass::GenerateOutputInformation(); typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); diff --git a/Modules/Core/Common/include/otbVariableLengthVectorConverter.h b/Modules/Core/Common/include/otbVariableLengthVectorConverter.h index 365df014e7..79c0c9718c 100644 --- a/Modules/Core/Common/include/otbVariableLengthVectorConverter.h +++ b/Modules/Core/Common/include/otbVariableLengthVectorConverter.h @@ -73,8 +73,8 @@ public: protected: VariableLengthVectorConverter(){} - ~VariableLengthVectorConverter() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~VariableLengthVectorConverter() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); os << "Attempt to use inexistant implementation of the converter!" @@ -116,8 +116,8 @@ public: protected: VariableLengthVectorConverter(){} - ~VariableLengthVectorConverter() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~VariableLengthVectorConverter() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); os << "Attempt to use inexistant implementation of the converter!" @@ -157,8 +157,8 @@ public: protected: VariableLengthVectorConverter(){} - ~VariableLengthVectorConverter() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~VariableLengthVectorConverter() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); os << "Converter: std::vector<std::vector<RealType>> => VariableLengthVector<RealType>" @@ -198,8 +198,8 @@ public: protected: VariableLengthVectorConverter(){} - ~VariableLengthVectorConverter() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~VariableLengthVectorConverter() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); os << "Converter: std::vector<std::vector<std::complex<RealType>>> => VariableLengthVector<RealType>" @@ -239,8 +239,8 @@ public: protected: VariableLengthVectorConverter(){} - ~VariableLengthVectorConverter() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~VariableLengthVectorConverter() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); os << "Converter: itk::FixedArray<RealType, VArrayDimension> => VariableLengthVector<RealType>" @@ -279,8 +279,8 @@ public: protected: VariableLengthVectorConverter(){} - ~VariableLengthVectorConverter() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~VariableLengthVectorConverter() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); os << "Converter: itk::Statistics::Histogram<RealType, VMeasurementVectorSize, TFrequencyContainer> => VariableLengthVector<RealType>" diff --git a/Modules/Core/Common/include/otbVectorImageToASImageAdaptor.h b/Modules/Core/Common/include/otbVectorImageToASImageAdaptor.h index 36844c6136..9fa9bb3bc4 100644 --- a/Modules/Core/Common/include/otbVectorImageToASImageAdaptor.h +++ b/Modules/Core/Common/include/otbVectorImageToASImageAdaptor.h @@ -66,7 +66,7 @@ public: protected: VectorImageToASImageAdaptor() {} - ~VectorImageToASImageAdaptor() ITK_OVERRIDE {} + ~VectorImageToASImageAdaptor() override {} private: VectorImageToASImageAdaptor(const Self &); //purposely not implemented diff --git a/Modules/Core/ImageBase/include/otbExtractROI.h b/Modules/Core/ImageBase/include/otbExtractROI.h index 52f45375d6..e094ef471a 100644 --- a/Modules/Core/ImageBase/include/otbExtractROI.h +++ b/Modules/Core/ImageBase/include/otbExtractROI.h @@ -80,17 +80,17 @@ public: OutputImageType::ImageDimension); void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; protected: ExtractROI(); - ~ExtractROI() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ExtractROI() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** ExtractROI * * \sa ExtractROIBase::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: ExtractROI(const Self &); //purposely not implemented diff --git a/Modules/Core/ImageBase/include/otbExtractROIBase.h b/Modules/Core/ImageBase/include/otbExtractROIBase.h index 6fbe6ed294..07906dfe07 100644 --- a/Modules/Core/ImageBase/include/otbExtractROIBase.h +++ b/Modules/Core/ImageBase/include/otbExtractROIBase.h @@ -108,10 +108,10 @@ public: protected: ExtractROIBase(); - ~ExtractROIBase() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ExtractROIBase() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** ExtractROIBase can produce an image which is a different * resolution than its input image. As such, ExtractROIBase @@ -121,7 +121,7 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** This function calls the actual region copier to do the mapping from * output image space to input image space. It uses a @@ -134,7 +134,7 @@ protected: * * \sa ImageToImageFilter::CallCopyRegion() */ void CallCopyOutputRegionToInputRegion(InputImageRegionType& destRegion, - const OutputImageRegionType& srcRegion) ITK_OVERRIDE; + const OutputImageRegionType& srcRegion) override; /** ExtractROIBase can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() @@ -149,7 +149,7 @@ protected: // ATTENTION bizarre void ThreadedGenerateData(const OutputImageRegionType& /*outputRegionForThread*/, - itk::ThreadIdType /*threadId*/) ITK_OVERRIDE + itk::ThreadIdType /*threadId*/) override { diff --git a/Modules/Core/ImageBase/include/otbImage.h b/Modules/Core/ImageBase/include/otbImage.h index 3bec599c72..109a557143 100644 --- a/Modules/Core/ImageBase/include/otbImage.h +++ b/Modules/Core/ImageBase/include/otbImage.h @@ -245,14 +245,14 @@ public: virtual void SetImageKeywordList(const ImageKeywordlistType& kwl); - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /// Copy metadata from a DataObject - void CopyInformation(const itk::DataObject *) ITK_OVERRIDE; + void CopyInformation(const itk::DataObject *) override; protected: Image(); - ~Image() ITK_OVERRIDE {} + ~Image() override {} private: Image(const Self &) = delete; diff --git a/Modules/Core/ImageBase/include/otbImageFunctionAdaptor.h b/Modules/Core/ImageBase/include/otbImageFunctionAdaptor.h index 82ae1aa084..2daa2aaefa 100644 --- a/Modules/Core/ImageBase/include/otbImageFunctionAdaptor.h +++ b/Modules/Core/ImageBase/include/otbImageFunctionAdaptor.h @@ -88,17 +88,17 @@ class ITK_EXPORT ImageFunctionAdaptor : itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension); // Evalulate the function at specified index // - OutputType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtIndex(const IndexType& index) const override; // Evaluate the function at non-integer positions // - OutputType Evaluate(const PointType& point) const ITK_OVERRIDE + OutputType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } OutputType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -111,8 +111,8 @@ class ITK_EXPORT ImageFunctionAdaptor : protected: ImageFunctionAdaptor(); - ~ImageFunctionAdaptor() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageFunctionAdaptor() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageFunctionAdaptor(const Self &); //purposely not implemented diff --git a/Modules/Core/ImageBase/include/otbImageIOBase.h b/Modules/Core/ImageBase/include/otbImageIOBase.h index e1c1d84111..6a7bf4e12d 100644 --- a/Modules/Core/ImageBase/include/otbImageIOBase.h +++ b/Modules/Core/ImageBase/include/otbImageIOBase.h @@ -429,8 +429,8 @@ public: protected: ImageIOBase(); - ~ImageIOBase() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageIOBase() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Used internally to keep track of the type of the pixel. */ IOPixelType m_PixelType; diff --git a/Modules/Core/ImageBase/include/otbImageOfVectorsToMonoChannelExtractROI.h b/Modules/Core/ImageBase/include/otbImageOfVectorsToMonoChannelExtractROI.h index 21910ccb70..40c2f86725 100644 --- a/Modules/Core/ImageBase/include/otbImageOfVectorsToMonoChannelExtractROI.h +++ b/Modules/Core/ImageBase/include/otbImageOfVectorsToMonoChannelExtractROI.h @@ -86,8 +86,8 @@ public: protected: ImageOfVectorsToMonoChannelExtractROI(); - ~ImageOfVectorsToMonoChannelExtractROI() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageOfVectorsToMonoChannelExtractROI() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** ExtractImageFilter can produce an image which is a different * resolution than its input image. As such, ExtractImageFilter @@ -97,13 +97,13 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** ExtractImageFilter can be implemented as a multithreaded filter. * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: ImageOfVectorsToMonoChannelExtractROI(const Self &); //purposely not implemented diff --git a/Modules/Core/ImageBase/include/otbMetaImageFunction.h b/Modules/Core/ImageBase/include/otbMetaImageFunction.h index 79f863b989..d8eba8a50a 100644 --- a/Modules/Core/ImageBase/include/otbMetaImageFunction.h +++ b/Modules/Core/ImageBase/include/otbMetaImageFunction.h @@ -75,7 +75,7 @@ public: typedef std::vector<FunctionPointerType> FunctionContainerType; /** Evaluate the function at the given location */ - OutputType Evaluate(const PointType & point) const ITK_OVERRIDE; + OutputType Evaluate(const PointType & point) const override; /** Add a new function to the functions vector */ void AddFunction(FunctionType * function); @@ -100,10 +100,10 @@ protected: MetaImageFunction(); /** Destructor */ - ~MetaImageFunction() ITK_OVERRIDE; + ~MetaImageFunction() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: MetaImageFunction(const Self& ); //purposely not implemented diff --git a/Modules/Core/ImageBase/include/otbMultiChannelExtractROI.h b/Modules/Core/ImageBase/include/otbMultiChannelExtractROI.h index a087a12399..cf17b63d3c 100644 --- a/Modules/Core/ImageBase/include/otbMultiChannelExtractROI.h +++ b/Modules/Core/ImageBase/include/otbMultiChannelExtractROI.h @@ -115,8 +115,8 @@ public: protected: MultiChannelExtractROI(); - ~MultiChannelExtractROI() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~MultiChannelExtractROI() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** MultiChannelExtractROI can produce an image which is a different * resolution than its input image. As such, MultiChannelExtractROI @@ -126,7 +126,7 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Reinitialize channels vector for multiple Update.*/ void ChannelsReInitialization(); @@ -137,7 +137,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: MultiChannelExtractROI(const Self &); //purposely not implemented diff --git a/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.h b/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.h index 2724bcf8e6..4733af5450 100644 --- a/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.h +++ b/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.h @@ -93,8 +93,8 @@ public: protected: MultiToMonoChannelExtractROI(); - ~MultiToMonoChannelExtractROI() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~MultiToMonoChannelExtractROI() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** ExtractImageFilter can produce an image which is a different * resolution than its input image. As such, ExtractImageFilter @@ -104,13 +104,13 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** ExtractImageFilter can be implemented as a multithreaded filter. * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: MultiToMonoChannelExtractROI(const Self &); //purposely not implemented diff --git a/Modules/Core/ImageBase/include/otbRemoteSensingRegion.h b/Modules/Core/ImageBase/include/otbRemoteSensingRegion.h index 82eb5eebd4..3c000d43bb 100644 --- a/Modules/Core/ImageBase/include/otbRemoteSensingRegion.h +++ b/Modules/Core/ImageBase/include/otbRemoteSensingRegion.h @@ -81,7 +81,7 @@ public: /** ImageRegion typedef needed by the GetImageRegion() method */ typedef itk::ImageRegion<2> ImageRegionType; - typename Superclass::RegionType GetRegionType() const ITK_OVERRIDE + typename Superclass::RegionType GetRegionType() const override {return Superclass::ITK_STRUCTURED_REGION; } /** Constructor. RemoteSensingRegion is a lightweight object that is not reference @@ -106,7 +106,7 @@ public: /** Destructor. RemoteSensingRegion is a lightweight object that is not reference * counted, so the destructor is public. */ - ~RemoteSensingRegion() ITK_OVERRIDE{} + ~RemoteSensingRegion() override{} /** operator=. RemoteSensingRegion is a lightweight object that is not reference * counted, so operator= is public. */ @@ -334,7 +334,7 @@ public: protected: - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { os << std::setprecision(15); os << indent << "RemoteSensingRegion" << std::endl; diff --git a/Modules/Core/ImageBase/include/otbVectorImage.h b/Modules/Core/ImageBase/include/otbVectorImage.h index 2fa39e599a..dcb2ec2377 100644 --- a/Modules/Core/ImageBase/include/otbVectorImage.h +++ b/Modules/Core/ImageBase/include/otbVectorImage.h @@ -164,9 +164,9 @@ public: virtual void SetImageKeywordList(const ImageKeywordlistType& kwl); /// Copy metadata from a DataObject - void CopyInformation(const itk::DataObject *) ITK_OVERRIDE; + void CopyInformation(const itk::DataObject *) override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Return the Pixel Accessor object */ // AccessorType GetPixelAccessor( void ) @@ -194,7 +194,7 @@ public: protected: VectorImage(); - ~VectorImage() ITK_OVERRIDE {} + ~VectorImage() override {} private: VectorImage(const Self &); //purposely not implemented diff --git a/Modules/Core/Interpolation/include/otbBCOInterpolateImageFunction.h b/Modules/Core/Interpolation/include/otbBCOInterpolateImageFunction.h index 460414ab79..6acb8b23ac 100644 --- a/Modules/Core/Interpolation/include/otbBCOInterpolateImageFunction.h +++ b/Modules/Core/Interpolation/include/otbBCOInterpolateImageFunction.h @@ -109,12 +109,12 @@ public: * * ImageFunction::IsInsideBuffer() can be used to check bounds before * calling the method. */ - OutputType EvaluateAtContinuousIndex( const ContinuousIndexType & index ) const ITK_OVERRIDE = 0; + OutputType EvaluateAtContinuousIndex( const ContinuousIndexType & index ) const override = 0; protected: BCOInterpolateImageFunctionBase() : m_Radius(2), m_WinSize(5), m_Alpha(-0.5) {}; - ~BCOInterpolateImageFunctionBase() ITK_OVERRIDE {}; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~BCOInterpolateImageFunctionBase() override {}; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Compute the BCO coefficients. */ virtual CoefContainerType EvaluateCoef( const ContinuousIndexValueType & indexValue ) const; @@ -157,12 +157,12 @@ public: typedef typename Superclass::ContinuousIndexType ContinuousIndexType; typedef typename Superclass::CoefContainerType CoefContainerType; - OutputType EvaluateAtContinuousIndex( const ContinuousIndexType & index ) const ITK_OVERRIDE; + OutputType EvaluateAtContinuousIndex( const ContinuousIndexType & index ) const override; protected: BCOInterpolateImageFunction() {}; - ~BCOInterpolateImageFunction() ITK_OVERRIDE {}; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~BCOInterpolateImageFunction() override {}; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: BCOInterpolateImageFunction( const Self& ); //purposely not implemented @@ -196,12 +196,12 @@ public: typedef typename Superclass::ContinuousIndexType ContinuousIndexType; typedef typename Superclass::CoefContainerType CoefContainerType; - OutputType EvaluateAtContinuousIndex( const ContinuousIndexType & index ) const ITK_OVERRIDE; + OutputType EvaluateAtContinuousIndex( const ContinuousIndexType & index ) const override; protected: BCOInterpolateImageFunction() {}; - ~BCOInterpolateImageFunction() ITK_OVERRIDE {}; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~BCOInterpolateImageFunction() override {}; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: BCOInterpolateImageFunction( const Self& ); //purposely not implemented diff --git a/Modules/Core/Interpolation/include/otbBSplineDecompositionImageFilter.h b/Modules/Core/Interpolation/include/otbBSplineDecompositionImageFilter.h index d4199249b6..627b18af54 100644 --- a/Modules/Core/Interpolation/include/otbBSplineDecompositionImageFilter.h +++ b/Modules/Core/Interpolation/include/otbBSplineDecompositionImageFilter.h @@ -77,10 +77,10 @@ public: protected: BSplineDecompositionImageFilter(); - ~BSplineDecompositionImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~BSplineDecompositionImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** These are needed by the smoothing spline routine. */ std::vector<double> m_Scratch; // temp storage for processing of Coefficients diff --git a/Modules/Core/Interpolation/include/otbBSplineInterpolateImageFunction.h b/Modules/Core/Interpolation/include/otbBSplineInterpolateImageFunction.h index c5161bcdaa..fb653f3beb 100644 --- a/Modules/Core/Interpolation/include/otbBSplineInterpolateImageFunction.h +++ b/Modules/Core/Interpolation/include/otbBSplineInterpolateImageFunction.h @@ -108,7 +108,7 @@ public: * ImageFunction::IsInsideBuffer() can be used to check bounds before * calling the method. */ OutputType EvaluateAtContinuousIndex( - const ContinuousIndexType& index) const ITK_OVERRIDE; + const ContinuousIndexType& index) const override; /** Derivative typedef support */ typedef itk::CovariantVector<OutputType, @@ -131,7 +131,7 @@ public: itkGetMacro(SplineOrder, int); /** Set the input image. This must be set by the user. */ - void SetInputImage(const TImageType * inputData) ITK_OVERRIDE; + void SetInputImage(const TImageType * inputData) override; /** Update coefficients filter. Coefficient filter are computed over the buffered region of the input image. */ @@ -139,9 +139,9 @@ public: protected: BSplineInterpolateImageFunction(); - ~BSplineInterpolateImageFunction() ITK_OVERRIDE {} + ~BSplineInterpolateImageFunction() override {} void operator =(const Self&); //purposely not implemented - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; // These are needed by the smoothing spline routine. std::vector<CoefficientDataType> m_Scratch; // temp storage for processing of Coefficients diff --git a/Modules/Core/Interpolation/include/otbGenericInterpolateImageFunction.h b/Modules/Core/Interpolation/include/otbGenericInterpolateImageFunction.h index a993e857e1..1119453b2b 100644 --- a/Modules/Core/Interpolation/include/otbGenericInterpolateImageFunction.h +++ b/Modules/Core/Interpolation/include/otbGenericInterpolateImageFunction.h @@ -86,7 +86,7 @@ public: * * ImageFunction::IsInsideBuffer() can be used to check bounds before * calling the method. */ - OutputType EvaluateAtContinuousIndex(const ContinuousIndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtContinuousIndex(const ContinuousIndexType& index) const override; /** Set/Get the window radius*/ virtual void SetRadius(unsigned int rad); @@ -115,12 +115,12 @@ public: protected: GenericInterpolateImageFunction(); - ~GenericInterpolateImageFunction() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~GenericInterpolateImageFunction() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Call the superclass implementation and set the TablesHaveBeenGenerated * flag to false */ - void Modified(void) const ITK_OVERRIDE; + void Modified(void) const override; /** Delete tables.*/ virtual void ResetOffsetTable(); diff --git a/Modules/Core/Interpolation/include/otbProlateInterpolateImageFunction.h b/Modules/Core/Interpolation/include/otbProlateInterpolateImageFunction.h index 6942e57988..1a057edfce 100644 --- a/Modules/Core/Interpolation/include/otbProlateInterpolateImageFunction.h +++ b/Modules/Core/Interpolation/include/otbProlateInterpolateImageFunction.h @@ -313,8 +313,8 @@ public: protected: ProlateInterpolateImageFunction(); - ~ProlateInterpolateImageFunction() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ProlateInterpolateImageFunction() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ProlateInterpolateImageFunction(const Self &); //purposely not implemented diff --git a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageBlackmanFunction.h b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageBlackmanFunction.h index 7bd3a88546..36d1d72264 100644 --- a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageBlackmanFunction.h +++ b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageBlackmanFunction.h @@ -134,8 +134,8 @@ public: protected: WindowedSincInterpolateImageBlackmanFunction() {}; - ~WindowedSincInterpolateImageBlackmanFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~WindowedSincInterpolateImageBlackmanFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageCosineFunction.h b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageCosineFunction.h index 34d2a79699..94cae64c24 100644 --- a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageCosineFunction.h +++ b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageCosineFunction.h @@ -127,8 +127,8 @@ public: protected: WindowedSincInterpolateImageCosineFunction() {}; - ~WindowedSincInterpolateImageCosineFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~WindowedSincInterpolateImageCosineFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageFunctionBase.h b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageFunctionBase.h index 34be4a944d..57703395ba 100644 --- a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageFunctionBase.h +++ b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageFunctionBase.h @@ -179,8 +179,8 @@ public: protected: WindowedSincInterpolateImageFunctionBase(); - ~WindowedSincInterpolateImageFunctionBase() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~WindowedSincInterpolateImageFunctionBase() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: WindowedSincInterpolateImageFunctionBase(const Self &); //purposely not implemented diff --git a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageGaussianFunction.h b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageGaussianFunction.h index fde1fabcc2..ce0358ded4 100644 --- a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageGaussianFunction.h +++ b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageGaussianFunction.h @@ -127,8 +127,8 @@ public: protected: WindowedSincInterpolateImageGaussianFunction() {}; - ~WindowedSincInterpolateImageGaussianFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~WindowedSincInterpolateImageGaussianFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageHammingFunction.h b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageHammingFunction.h index d2371c037b..31fca5a236 100644 --- a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageHammingFunction.h +++ b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageHammingFunction.h @@ -128,8 +128,8 @@ public: protected: WindowedSincInterpolateImageHammingFunction() {}; - ~WindowedSincInterpolateImageHammingFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~WindowedSincInterpolateImageHammingFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageLanczosFunction.h b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageLanczosFunction.h index 33c51bb957..38da528f66 100644 --- a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageLanczosFunction.h +++ b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageLanczosFunction.h @@ -138,8 +138,8 @@ public: protected: WindowedSincInterpolateImageLanczosFunction() {}; - ~WindowedSincInterpolateImageLanczosFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~WindowedSincInterpolateImageLanczosFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageWelchFunction.h b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageWelchFunction.h index fc1d52b85f..24245cea27 100644 --- a/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageWelchFunction.h +++ b/Modules/Core/Interpolation/include/otbWindowedSincInterpolateImageWelchFunction.h @@ -127,8 +127,8 @@ public: protected: WindowedSincInterpolateImageWelchFunction() {}; - ~WindowedSincInterpolateImageWelchFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~WindowedSincInterpolateImageWelchFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Core/LabelMap/include/otbAttributesMapLabelObject.h b/Modules/Core/LabelMap/include/otbAttributesMapLabelObject.h index 342c288105..4918ff363d 100644 --- a/Modules/Core/LabelMap/include/otbAttributesMapLabelObject.h +++ b/Modules/Core/LabelMap/include/otbAttributesMapLabelObject.h @@ -306,10 +306,10 @@ protected: /** Constructor */ AttributesMapLabelObject() : m_Attributes(), m_Polygon(PolygonType::New()) {} /** Destructor */ - ~AttributesMapLabelObject() ITK_OVERRIDE {} + ~AttributesMapLabelObject() override {} /** The printself method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); os << indent << "Attributes: " << std::endl; diff --git a/Modules/Core/LabelMap/include/otbAttributesMapLabelObjectWithClassLabel.h b/Modules/Core/LabelMap/include/otbAttributesMapLabelObjectWithClassLabel.h index 9573d6218a..f9d822cdd6 100644 --- a/Modules/Core/LabelMap/include/otbAttributesMapLabelObjectWithClassLabel.h +++ b/Modules/Core/LabelMap/include/otbAttributesMapLabelObjectWithClassLabel.h @@ -105,7 +105,7 @@ public: m_HasClassLabel = false; } - void CopyAttributesFrom( const LabelObjectType * lo ) ITK_OVERRIDE + void CopyAttributesFrom( const LabelObjectType * lo ) override { Superclass::CopyAttributesFrom( lo ); @@ -125,10 +125,10 @@ protected: AttributesMapLabelObjectWithClassLabel() : m_ClassLabel(itk::NumericTraits<ClassLabelType>::Zero), m_HasClassLabel(false) {} /** Destructor */ - ~AttributesMapLabelObjectWithClassLabel() ITK_OVERRIDE {} + ~AttributesMapLabelObjectWithClassLabel() override {} /** The printself method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf( os, indent ); if(m_HasClassLabel) diff --git a/Modules/Core/LabelMap/include/otbAttributesMapOpeningLabelMapFilter.h b/Modules/Core/LabelMap/include/otbAttributesMapOpeningLabelMapFilter.h index 1e10e1783a..c8a138ffec 100644 --- a/Modules/Core/LabelMap/include/otbAttributesMapOpeningLabelMapFilter.h +++ b/Modules/Core/LabelMap/include/otbAttributesMapOpeningLabelMapFilter.h @@ -71,16 +71,16 @@ public: AttributeAccessorType & GetAccessor(); - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; protected: /** Constructor */ AttributesMapOpeningLabelMapFilter(); /** Destructor */ - ~AttributesMapOpeningLabelMapFilter() ITK_OVERRIDE; + ~AttributesMapOpeningLabelMapFilter() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Core/LabelMap/include/otbBandsStatisticsAttributesLabelMapFilter.h b/Modules/Core/LabelMap/include/otbBandsStatisticsAttributesLabelMapFilter.h index 2083db54d9..89ffbe2326 100644 --- a/Modules/Core/LabelMap/include/otbBandsStatisticsAttributesLabelMapFilter.h +++ b/Modules/Core/LabelMap/include/otbBandsStatisticsAttributesLabelMapFilter.h @@ -191,19 +191,19 @@ protected: /** Constructor */ BandsStatisticsAttributesLabelMapFilter(); /** Destructor */ - ~BandsStatisticsAttributesLabelMapFilter() ITK_OVERRIDE {} + ~BandsStatisticsAttributesLabelMapFilter() override {} - void AllocateOutputs() ITK_OVERRIDE; + void AllocateOutputs() override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; - void EnlargeOutputRequestedRegion(itk::DataObject *) ITK_OVERRIDE{}; + void EnlargeOutputRequestedRegion(itk::DataObject *) override{}; /** Before threaded data generation */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: BandsStatisticsAttributesLabelMapFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/LabelMap/include/otbImageToLabelMapWithAttributesFilter.h b/Modules/Core/LabelMap/include/otbImageToLabelMapWithAttributesFilter.h index e18b9ac7d1..985e57cb96 100644 --- a/Modules/Core/LabelMap/include/otbImageToLabelMapWithAttributesFilter.h +++ b/Modules/Core/LabelMap/include/otbImageToLabelMapWithAttributesFilter.h @@ -75,21 +75,21 @@ public: typedef BandsStatisticsAttributesLabelMapFilter<LabelMapType, InputImageType> BandStatisticsLabelMapFilterType; using Superclass::SetInput; - void SetInput( const InputImageType *image) ITK_OVERRIDE; + void SetInput( const InputImageType *image) override; virtual void SetLabeledImage( const LabeledImageType * image); const InputImageType * GetInput(void); const LabeledImageType * GetLabeledImage(); virtual LabelMapType* GetOutput(); - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; protected: /** Constructor */ ImageToLabelMapWithAttributesFilter(); /** Destructor */ - ~ImageToLabelMapWithAttributesFilter() ITK_OVERRIDE{}; + ~ImageToLabelMapWithAttributesFilter() override{}; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; private: diff --git a/Modules/Core/LabelMap/include/otbKMeansAttributesLabelMapFilter.h b/Modules/Core/LabelMap/include/otbKMeansAttributesLabelMapFilter.h index 49125da9f7..d65e2b3c04 100644 --- a/Modules/Core/LabelMap/include/otbKMeansAttributesLabelMapFilter.h +++ b/Modules/Core/LabelMap/include/otbKMeansAttributesLabelMapFilter.h @@ -123,7 +123,7 @@ public: protected: KMeansAttributesLabelMapFilter(); - ~KMeansAttributesLabelMapFilter() ITK_OVERRIDE {}; + ~KMeansAttributesLabelMapFilter() override {}; private: diff --git a/Modules/Core/LabelMap/include/otbLabelImageToLabelMapWithAdjacencyFilter.h b/Modules/Core/LabelMap/include/otbLabelImageToLabelMapWithAdjacencyFilter.h index 7612335023..2e3c61d5c8 100644 --- a/Modules/Core/LabelMap/include/otbLabelImageToLabelMapWithAdjacencyFilter.h +++ b/Modules/Core/LabelMap/include/otbLabelImageToLabelMapWithAdjacencyFilter.h @@ -91,9 +91,9 @@ protected: /** Constructor */ LabelImageToLabelMapWithAdjacencyFilter(); /** Destructor */ - ~LabelImageToLabelMapWithAdjacencyFilter() ITK_OVERRIDE {}; + ~LabelImageToLabelMapWithAdjacencyFilter() override {}; /** Printself */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; // class to store a RLE class RLE @@ -121,16 +121,16 @@ protected: /** LabelImageToLabelMapWithAdjacencyFilter needs the entire input be * available. Thus, it needs to provide an implementation of * GenerateInputRequestedRegion(). */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** LabelImageToLabelMapWithAdjacencyFilter will produce the entire output. */ - void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output)) ITK_OVERRIDE; + void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output)) override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; - void AfterThreadedGenerateData() ITK_OVERRIDE; + void AfterThreadedGenerateData() override; /** Add a new adjacency */ void AddAdjacency(LabelType label1, LabelType label2, itk::ThreadIdType threadId); diff --git a/Modules/Core/LabelMap/include/otbLabelMapFeaturesFunctorImageFilter.h b/Modules/Core/LabelMap/include/otbLabelMapFeaturesFunctorImageFilter.h index 2ae6625d77..56083fc5c7 100644 --- a/Modules/Core/LabelMap/include/otbLabelMapFeaturesFunctorImageFilter.h +++ b/Modules/Core/LabelMap/include/otbLabelMapFeaturesFunctorImageFilter.h @@ -97,17 +97,17 @@ protected: LabelMapFeaturesFunctorImageFilter() : m_Functor() {} /** Destructor */ - ~LabelMapFeaturesFunctorImageFilter() ITK_OVERRIDE {} + ~LabelMapFeaturesFunctorImageFilter() override {} /** Threaded generate data */ - void ThreadedProcessLabelObject(LabelObjectType * labelObject) ITK_OVERRIDE + void ThreadedProcessLabelObject(LabelObjectType * labelObject) override { // Call the functor m_Functor(labelObject); } /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { // Call superclass implementation Superclass::PrintSelf(os, indent); diff --git a/Modules/Core/LabelMap/include/otbLabelMapSource.h b/Modules/Core/LabelMap/include/otbLabelMapSource.h index 489dd06e92..a03be1bd83 100644 --- a/Modules/Core/LabelMap/include/otbLabelMapSource.h +++ b/Modules/Core/LabelMap/include/otbLabelMapSource.h @@ -64,9 +64,9 @@ public: protected: LabelMapSource(); - ~LabelMapSource() ITK_OVERRIDE; + ~LabelMapSource() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Ensure that the output vector data are cleared before processing */ virtual void AllocateOutputs(); diff --git a/Modules/Core/LabelMap/include/otbLabelMapToAttributeImageFilter.h b/Modules/Core/LabelMap/include/otbLabelMapToAttributeImageFilter.h index 202b7e3792..50dcc9f616 100644 --- a/Modules/Core/LabelMap/include/otbLabelMapToAttributeImageFilter.h +++ b/Modules/Core/LabelMap/include/otbLabelMapToAttributeImageFilter.h @@ -102,13 +102,13 @@ public: protected: LabelMapToAttributeImageFilter(); - ~LabelMapToAttributeImageFilter() ITK_OVERRIDE {}; + ~LabelMapToAttributeImageFilter() override {}; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; - void ThreadedProcessLabelObject( LabelObjectType * labelObject ) ITK_OVERRIDE; + void ThreadedProcessLabelObject( LabelObjectType * labelObject ) override; private: /** Background pixel value */ diff --git a/Modules/Core/LabelMap/include/otbLabelMapToSampleListFilter.h b/Modules/Core/LabelMap/include/otbLabelMapToSampleListFilter.h index 3485f79944..55040a6e5e 100644 --- a/Modules/Core/LabelMap/include/otbLabelMapToSampleListFilter.h +++ b/Modules/Core/LabelMap/include/otbLabelMapToSampleListFilter.h @@ -96,15 +96,15 @@ public: protected: LabelMapToSampleListFilter(); - ~LabelMapToSampleListFilter() ITK_OVERRIDE; + ~LabelMapToSampleListFilter() override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Make Output */ - DataObjectPointerType MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointerType MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LabelMapToSampleListFilter(const Self&); //purposely not implemented diff --git a/Modules/Core/LabelMap/include/otbLabelMapWithAdjacency.h b/Modules/Core/LabelMap/include/otbLabelMapWithAdjacency.h index b1d9301980..3400aec812 100644 --- a/Modules/Core/LabelMap/include/otbLabelMapWithAdjacency.h +++ b/Modules/Core/LabelMap/include/otbLabelMapWithAdjacency.h @@ -218,16 +218,16 @@ protected: /** Constructor */ LabelMapWithAdjacency(){} /** Destructor */ - ~LabelMapWithAdjacency() ITK_OVERRIDE{} + ~LabelMapWithAdjacency() override{} /** Printself */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } /** Re-implement CopyInformation to pass the adjancency graph * through */ - void CopyInformation(const itk::DataObject * data) ITK_OVERRIDE + void CopyInformation(const itk::DataObject * data) override { // Call superclass implementation Superclass::CopyInformation(data); diff --git a/Modules/Core/LabelMap/include/otbLabelMapWithClassLabelToClassLabelImageFilter.h b/Modules/Core/LabelMap/include/otbLabelMapWithClassLabelToClassLabelImageFilter.h index 5f67ba3d95..ccc3a6dd45 100644 --- a/Modules/Core/LabelMap/include/otbLabelMapWithClassLabelToClassLabelImageFilter.h +++ b/Modules/Core/LabelMap/include/otbLabelMapWithClassLabelToClassLabelImageFilter.h @@ -75,11 +75,11 @@ public: protected: LabelMapWithClassLabelToClassLabelImageFilter(); - ~LabelMapWithClassLabelToClassLabelImageFilter() ITK_OVERRIDE {}; + ~LabelMapWithClassLabelToClassLabelImageFilter() override {}; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; - void ThreadedProcessLabelObject( LabelObjectType * labelObject ) ITK_OVERRIDE; + void ThreadedProcessLabelObject( LabelObjectType * labelObject ) override; private: LabelMapWithClassLabelToClassLabelImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Core/LabelMap/include/otbLabelMapWithClassLabelToLabeledSampleListFilter.h b/Modules/Core/LabelMap/include/otbLabelMapWithClassLabelToLabeledSampleListFilter.h index bf7f6859da..cd4bc3086e 100644 --- a/Modules/Core/LabelMap/include/otbLabelMapWithClassLabelToLabeledSampleListFilter.h +++ b/Modules/Core/LabelMap/include/otbLabelMapWithClassLabelToLabeledSampleListFilter.h @@ -100,14 +100,14 @@ public: protected: LabelMapWithClassLabelToLabeledSampleListFilter(); - ~LabelMapWithClassLabelToLabeledSampleListFilter() ITK_OVERRIDE; + ~LabelMapWithClassLabelToLabeledSampleListFilter() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Make Output */ - DataObjectPointerType MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointerType MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; private: diff --git a/Modules/Core/LabelMap/include/otbMinMaxAttributesLabelMapFilter.h b/Modules/Core/LabelMap/include/otbMinMaxAttributesLabelMapFilter.h index 9a9f3251d1..96ae25ce4c 100644 --- a/Modules/Core/LabelMap/include/otbMinMaxAttributesLabelMapFilter.h +++ b/Modules/Core/LabelMap/include/otbMinMaxAttributesLabelMapFilter.h @@ -89,14 +89,14 @@ public: AttributesMapObjectType* GetMaximumOutput(); const AttributesMapObjectType* GetMaximumOutput() const; - DataObjectPointerType MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointerType MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; protected: MinMaxAttributesLabelMapFilter(); - ~MinMaxAttributesLabelMapFilter() ITK_OVERRIDE {}; + ~MinMaxAttributesLabelMapFilter() override {}; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: MinMaxAttributesLabelMapFilter(const Self&); //purposely not implemented diff --git a/Modules/Core/LabelMap/include/otbNormalizeAttributesLabelMapFilter.h b/Modules/Core/LabelMap/include/otbNormalizeAttributesLabelMapFilter.h index a3c01d3dbc..afc376eabe 100644 --- a/Modules/Core/LabelMap/include/otbNormalizeAttributesLabelMapFilter.h +++ b/Modules/Core/LabelMap/include/otbNormalizeAttributesLabelMapFilter.h @@ -143,10 +143,10 @@ protected: NormalizeAttributesLabelMapFilter(){} /** Destructor */ - ~NormalizeAttributesLabelMapFilter() ITK_OVERRIDE{} + ~NormalizeAttributesLabelMapFilter() override{} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: NormalizeAttributesLabelMapFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.h b/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.h index eb2dfbc8fb..083b4b7c1f 100644 --- a/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.h +++ b/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.h @@ -288,19 +288,19 @@ protected: ShapeAttributesLabelMapFilter(){} /** Destructor */ - ~ShapeAttributesLabelMapFilter() ITK_OVERRIDE{} + ~ShapeAttributesLabelMapFilter() override{} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void AllocateOutputs() ITK_OVERRIDE; + void AllocateOutputs() override; /** Things to to before threaded data generation */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; - void EnlargeOutputRequestedRegion(itk::DataObject *) ITK_OVERRIDE{}; + void EnlargeOutputRequestedRegion(itk::DataObject *) override{}; private: ShapeAttributesLabelMapFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/LabelMap/include/otbStatisticsAttributesLabelMapFilter.h b/Modules/Core/LabelMap/include/otbStatisticsAttributesLabelMapFilter.h index c0c2d1ed6c..3f2826b789 100644 --- a/Modules/Core/LabelMap/include/otbStatisticsAttributesLabelMapFilter.h +++ b/Modules/Core/LabelMap/include/otbStatisticsAttributesLabelMapFilter.h @@ -195,13 +195,13 @@ protected: StatisticsAttributesLabelMapFilter(); /** Destructor */ - ~StatisticsAttributesLabelMapFilter() ITK_OVERRIDE; + ~StatisticsAttributesLabelMapFilter() override; /** Before threaded data generation */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: StatisticsAttributesLabelMapFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbDefaultImageMetadataInterface.h b/Modules/Core/Metadata/include/otbDefaultImageMetadataInterface.h index 6faccb6d41..f81e74966a 100644 --- a/Modules/Core/Metadata/include/otbDefaultImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbDefaultImageMetadataInterface.h @@ -75,49 +75,49 @@ public: } /** Get the imaging acquisition day from the ossim metadata */ - int GetDay() const ITK_OVERRIDE + int GetDay() const override { itkExceptionMacro("GetDay not implemented in DefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition month from the ossim metadata */ - int GetMonth() const ITK_OVERRIDE + int GetMonth() const override { itkExceptionMacro("GetMonth not implemented in DefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition year from the ossim metadata */ - int GetYear() const ITK_OVERRIDE + int GetYear() const override { itkExceptionMacro("GetYear not implemented in DefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition hour from the ossim metadata */ - int GetHour() const ITK_OVERRIDE + int GetHour() const override { itkExceptionMacro("GetHour not implemented in DefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition minute from the ossim metadata */ - int GetMinute() const ITK_OVERRIDE + int GetMinute() const override { itkExceptionMacro("GetMinute not implemented in DefaultImageMetadataInterface, no captor type found"); } /** Get the imaging production day from the ossim metadata */ - int GetProductionDay() const ITK_OVERRIDE + int GetProductionDay() const override { itkExceptionMacro("GetProductionDay not implemented in DefaultImageMetadataInterface, no captor type found"); } /** Get the imaging production month from the ossim metadata */ - int GetProductionMonth() const ITK_OVERRIDE + int GetProductionMonth() const override { itkExceptionMacro("GetProductionMonth not implemented in DefaultImageMetadataInterface, no captor type found"); } /** Get the imaging production year from the ossim metadata */ - int GetProductionYear() const ITK_OVERRIDE + int GetProductionYear() const override { itkExceptionMacro("GetProductionYear not implemented in DefaultImageMetadataInterface, no captor type found"); } @@ -147,13 +147,13 @@ public: } /** Get the enhanced band names */ - std::vector<std::string> GetEnhancedBandNames() const ITK_OVERRIDE + std::vector<std::string> GetEnhancedBandNames() const override { itkExceptionMacro("GetEnhancedBandNames not implemented in DefaultImageMetadataInterface, no captor type found"); } - bool CanRead() const ITK_OVERRIDE + bool CanRead() const override { // This class is the default one, it has to be able to call every metadata return true; @@ -166,7 +166,7 @@ public: * When one spectral band is available : the only band is given to the R, G and B channel. * */ - std::vector<unsigned int> GetDefaultDisplay() const ITK_OVERRIDE + std::vector<unsigned int> GetDefaultDisplay() const override { unsigned int i = 0; std::vector<unsigned int> rgb(3); @@ -193,7 +193,7 @@ public: protected: DefaultImageMetadataInterface(){}; - ~DefaultImageMetadataInterface() ITK_OVERRIDE {} + ~DefaultImageMetadataInterface() override {} private: diff --git a/Modules/Core/Metadata/include/otbDefaultImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbDefaultImageMetadataInterfaceFactory.h index aa0a851a2b..0f19d38b83 100644 --- a/Modules/Core/Metadata/include/otbDefaultImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbDefaultImageMetadataInterfaceFactory.h @@ -42,8 +42,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -60,7 +60,7 @@ public: protected: DefaultImageMetadataInterfaceFactory(); - ~DefaultImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~DefaultImageMetadataInterfaceFactory() override; private: DefaultImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbFormosatImageMetadataInterface.h b/Modules/Core/Metadata/include/otbFormosatImageMetadataInterface.h index df122554b5..271d3d8d81 100644 --- a/Modules/Core/Metadata/include/otbFormosatImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbFormosatImageMetadataInterface.h @@ -54,55 +54,55 @@ public: typedef Superclass::ImageKeywordlistType ImageKeywordlistType; /** Get the radiometric bias from the ossim metadata */ - VariableLengthVectorType GetPhysicalBias() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalBias() const override; /** Get the radiometric gain from the ossim metadata */ - VariableLengthVectorType GetPhysicalGain() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalGain() const override; /** Get the solar irradiance from the ossim metadata */ - VariableLengthVectorType GetSolarIrradiance() const ITK_OVERRIDE; + VariableLengthVectorType GetSolarIrradiance() const override; /** Get the imaging acquisition day from the ossim metadata : IMAGING_DATE metadata variable */ - int GetDay() const ITK_OVERRIDE; + int GetDay() const override; /** Get the imaging acquisition month from the ossim metadata : IMAGING_DATE metadata variable */ - int GetMonth() const ITK_OVERRIDE; + int GetMonth() const override; /** Get the imaging acquisition year from the ossim metadata : IMAGING_DATE metadata variable */ - int GetYear() const ITK_OVERRIDE; + int GetYear() const override; /** Get the imaging acquisition hour from the ossim metadata : IMAGING_DATE metadata variable */ - int GetHour() const ITK_OVERRIDE; + int GetHour() const override; /** Get the imaging acquisition year from the ossim metadata : IMAGING_DATE metadata variable */ - int GetMinute() const ITK_OVERRIDE; + int GetMinute() const override; /** Get the imaging production day from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionDay() const ITK_OVERRIDE; + int GetProductionDay() const override; /** Get the imaging production month from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionMonth() const ITK_OVERRIDE; + int GetProductionMonth() const override; /** Get the imaging production year from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionYear() const ITK_OVERRIDE; + int GetProductionYear() const override; /** Get the sat elevation from the ossim metadata */ - double GetSatElevation() const ITK_OVERRIDE; + double GetSatElevation() const override; /** Get the sat azimuth from the ossim metadata */ - double GetSatAzimuth() const ITK_OVERRIDE; + double GetSatAzimuth() const override; /** Get the first wavelength for the spectral band definition */ - VariableLengthVectorType GetFirstWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetFirstWavelengths() const override; /** Get the last wavelength for the spectral band definition */ - VariableLengthVectorType GetLastWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetLastWavelengths() const override; /** Get Instrument */ std::string GetInstrument() const; /** Get the enhanced band names (here nothing because the metadata did not provide band names) */ - std::vector<std::string> GetEnhancedBandNames() const ITK_OVERRIDE + std::vector<std::string> GetEnhancedBandNames() const override { return this->Superclass::GetBandName(); } @@ -114,21 +114,21 @@ public: * in most cases, this method won't change the value, but for SPOT data, the bands are set up as * 2 1 0 3 in the tiff file, this method which is overloaded for SPOT enables to retrieve the * proper band. */ - unsigned int BandIndexToWavelengthPosition(unsigned int i) const ITK_OVERRIDE; + unsigned int BandIndexToWavelengthPosition(unsigned int i) const override; /** Get the 3 spectral band numbers corresponding to the default display for visualization, * in the order R, G, B */ - std::vector<unsigned int> GetDefaultDisplay() const ITK_OVERRIDE; + std::vector<unsigned int> GetDefaultDisplay() const override; - bool CanRead() const ITK_OVERRIDE; + bool CanRead() const override; /** Vector that contains the filter function value in 6S format (step of 0.0025 micro m). * There values a computed by 6S. */ - WavelengthSpectralBandVectorType GetSpectralSensitivity() const ITK_OVERRIDE; + WavelengthSpectralBandVectorType GetSpectralSensitivity() const override; protected: FormosatImageMetadataInterface(); - ~FormosatImageMetadataInterface() ITK_OVERRIDE {} + ~FormosatImageMetadataInterface() override {} private: diff --git a/Modules/Core/Metadata/include/otbFormosatImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbFormosatImageMetadataInterfaceFactory.h index dcd95d08c6..372212d77d 100644 --- a/Modules/Core/Metadata/include/otbFormosatImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbFormosatImageMetadataInterfaceFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: FormosatImageMetadataInterfaceFactory(); - ~FormosatImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~FormosatImageMetadataInterfaceFactory() override; private: FormosatImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbIkonosImageMetadataInterface.h b/Modules/Core/Metadata/include/otbIkonosImageMetadataInterface.h index f4f2ccbf45..6d39a3eafd 100644 --- a/Modules/Core/Metadata/include/otbIkonosImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbIkonosImageMetadataInterface.h @@ -54,66 +54,66 @@ public: typedef Superclass::ImageKeywordlistType ImageKeywordlistType; /** Get the radiometric bias from the ossim metadata */ - VariableLengthVectorType GetPhysicalBias() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalBias() const override; /** Get the radiometric gain from the ossim metadata */ - VariableLengthVectorType GetPhysicalGain() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalGain() const override; /** Get the solar irradiance from the ossim metadata */ - VariableLengthVectorType GetSolarIrradiance() const ITK_OVERRIDE; + VariableLengthVectorType GetSolarIrradiance() const override; /** Get the imaging acquisition day from the ossim metadata : "Acquisition Date/Time" metadata variable */ - int GetDay() const ITK_OVERRIDE; + int GetDay() const override; /** Get the imaging acquisition month from the ossim metadata : "Acquisition Date/Time" metadata variable */ - int GetMonth() const ITK_OVERRIDE; + int GetMonth() const override; /** Get the imaging acquisition year from the ossim metadata : "Acquisition Date/Time" metadata variable */ - int GetYear() const ITK_OVERRIDE; + int GetYear() const override; /** Get the imaging acquisition hour from the ossim metadata : "Acquisition Date/Time" metadata variable */ - int GetHour() const ITK_OVERRIDE; + int GetHour() const override; /** Get the imaging acquisition year from the ossim metadata : "Acquisition Date/Time" metadata variable */ - int GetMinute() const ITK_OVERRIDE; + int GetMinute() const override; /** Get the imaging production day from the ossim metadata : "Creation Date" metadata variable */ - int GetProductionDay() const ITK_OVERRIDE; + int GetProductionDay() const override; /** Get the imaging production month from the ossim metadata : "Creation Date" metadata variable */ - int GetProductionMonth() const ITK_OVERRIDE; + int GetProductionMonth() const override; /** Get the imaging production year from the ossim metadata : "Creation Date" metadata variable */ - int GetProductionYear() const ITK_OVERRIDE; + int GetProductionYear() const override; /** Get the sat elevation from the ossim metadata */ - double GetSatElevation() const ITK_OVERRIDE; + double GetSatElevation() const override; /** Get the sat azimuth from the ossim metadata */ - double GetSatAzimuth() const ITK_OVERRIDE; + double GetSatAzimuth() const override; /** Get the first wavelength for the spectral band definition */ - VariableLengthVectorType GetFirstWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetFirstWavelengths() const override; /** Get the last wavelength for the spectral band definition */ - VariableLengthVectorType GetLastWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetLastWavelengths() const override; - bool CanRead() const ITK_OVERRIDE; + bool CanRead() const override; /** Get the enhanced band names of Ikonos data*/ - std::vector<std::string> GetEnhancedBandNames() const ITK_OVERRIDE; + std::vector<std::string> GetEnhancedBandNames() const override; /** Get the 3 spectral band numbers corresponding to the default display for visualization, * in the order R, G, B */ - std::vector<unsigned int> GetDefaultDisplay() const ITK_OVERRIDE; + std::vector<unsigned int> GetDefaultDisplay() const override; /** Vector that contains the filter function value in 6S format (step of 0.0025 micro m). * There values a computed by 6S. */ - WavelengthSpectralBandVectorType GetSpectralSensitivity() const ITK_OVERRIDE; + WavelengthSpectralBandVectorType GetSpectralSensitivity() const override; protected: IkonosImageMetadataInterface(); - ~IkonosImageMetadataInterface() ITK_OVERRIDE {} + ~IkonosImageMetadataInterface() override {} private: diff --git a/Modules/Core/Metadata/include/otbIkonosImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbIkonosImageMetadataInterfaceFactory.h index a0118eb5a0..b19c1e4d3a 100644 --- a/Modules/Core/Metadata/include/otbIkonosImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbIkonosImageMetadataInterfaceFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: IkonosImageMetadataInterfaceFactory(); - ~IkonosImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~IkonosImageMetadataInterfaceFactory() override; private: IkonosImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbImageMetadataInterfaceBase.h b/Modules/Core/Metadata/include/otbImageMetadataInterfaceBase.h index 0d4c891042..218cbe12ae 100644 --- a/Modules/Core/Metadata/include/otbImageMetadataInterfaceBase.h +++ b/Modules/Core/Metadata/include/otbImageMetadataInterfaceBase.h @@ -214,9 +214,9 @@ public: protected: ImageMetadataInterfaceBase(); - ~ImageMetadataInterfaceBase() ITK_OVERRIDE {} + ~ImageMetadataInterfaceBase() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; MetaDataDictionaryType m_MetaDataDictionary; diff --git a/Modules/Core/Metadata/include/otbImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbImageMetadataInterfaceFactory.h index c20f95b535..0b1f1fd78e 100644 --- a/Modules/Core/Metadata/include/otbImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbImageMetadataInterfaceFactory.h @@ -61,7 +61,7 @@ public: protected: ImageMetadataInterfaceFactory(); - ~ImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~ImageMetadataInterfaceFactory() override; private: ImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbOpticalDefaultImageMetadataInterface.h b/Modules/Core/Metadata/include/otbOpticalDefaultImageMetadataInterface.h index da26a6f015..dcd33a7426 100644 --- a/Modules/Core/Metadata/include/otbOpticalDefaultImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbOpticalDefaultImageMetadataInterface.h @@ -57,103 +57,103 @@ public: typedef Superclass::ImageKeywordlistType ImageKeywordlistType; /** Get the radiometric bias from the ossim metadata */ - VariableLengthVectorType GetPhysicalBias() const ITK_OVERRIDE + VariableLengthVectorType GetPhysicalBias() const override { itkExceptionMacro("GetPhysicalBias not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the radiometric gain from the ossim metadata */ - VariableLengthVectorType GetPhysicalGain() const ITK_OVERRIDE + VariableLengthVectorType GetPhysicalGain() const override { itkExceptionMacro("GetPhysicalGain not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the solar irradiance from the ossim metadata */ - VariableLengthVectorType GetSolarIrradiance() const ITK_OVERRIDE + VariableLengthVectorType GetSolarIrradiance() const override { itkExceptionMacro("GetSolarIrradiance not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition day from the ossim metadata */ - int GetDay() const ITK_OVERRIDE + int GetDay() const override { itkExceptionMacro("GetDay not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition month from the ossim metadata */ - int GetMonth() const ITK_OVERRIDE + int GetMonth() const override { itkExceptionMacro("GetMonth not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition year from the ossim metadata */ - int GetYear() const ITK_OVERRIDE + int GetYear() const override { itkExceptionMacro("GetYear not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition hour from the ossim metadata */ - int GetHour() const ITK_OVERRIDE + int GetHour() const override { itkExceptionMacro("GetHour not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition minute from the ossim metadata */ - int GetMinute() const ITK_OVERRIDE + int GetMinute() const override { itkExceptionMacro("GetMinute not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging production day from the ossim metadata */ - int GetProductionDay() const ITK_OVERRIDE + int GetProductionDay() const override { itkExceptionMacro("GetProductionDay not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging production month from the ossim metadata */ - int GetProductionMonth() const ITK_OVERRIDE + int GetProductionMonth() const override { itkExceptionMacro("GetProductionMonth not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging production year from the ossim metadata */ - int GetProductionYear() const ITK_OVERRIDE + int GetProductionYear() const override { itkExceptionMacro("GetProductionYear not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the sat elevation from the ossim metadata */ - double GetSatElevation() const ITK_OVERRIDE + double GetSatElevation() const override { itkExceptionMacro("GetSatElevation not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the sat azimuth from the ossim metadata */ - double GetSatAzimuth() const ITK_OVERRIDE + double GetSatAzimuth() const override { itkExceptionMacro("GetSatElevation not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the first wavelength for the spectral band definition */ - VariableLengthVectorType GetFirstWavelengths() const ITK_OVERRIDE + VariableLengthVectorType GetFirstWavelengths() const override { itkExceptionMacro("GetFirstWavelengths not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the last wavelength for the spectral band definition */ - VariableLengthVectorType GetLastWavelengths() const ITK_OVERRIDE + VariableLengthVectorType GetLastWavelengths() const override { itkExceptionMacro("GetLastWavelengths not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } /** Get the enhanced band names (here nothing because the sensor is not identify) */ - std::vector<std::string> GetEnhancedBandNames() const ITK_OVERRIDE + std::vector<std::string> GetEnhancedBandNames() const override { std::vector<std::string> nothing; return nothing; } - bool CanRead() const ITK_OVERRIDE + bool CanRead() const override { // This class is the default one, it has to be able to call every metadata return false; @@ -161,7 +161,7 @@ public: /** Get the 3 spectral band numbers corresponding to the default display for visualization, * in the order R, G, B */ - std::vector<unsigned int> GetDefaultDisplay() const ITK_OVERRIDE + std::vector<unsigned int> GetDefaultDisplay() const override { std::vector<unsigned int> rgb(3); rgb[0] = 0; @@ -172,14 +172,14 @@ public: /** Vector that contains the filter function value in 6S format (step of 0.0025 micro m). * There values a computed by 6S. */ - WavelengthSpectralBandVectorType GetSpectralSensitivity() const ITK_OVERRIDE + WavelengthSpectralBandVectorType GetSpectralSensitivity() const override { itkExceptionMacro("GetSpectralSensitivity not implemented in OpticalDefaultImageMetadataInterface, no captor type found"); } protected: OpticalDefaultImageMetadataInterface(){}; - ~OpticalDefaultImageMetadataInterface() ITK_OVERRIDE {} + ~OpticalDefaultImageMetadataInterface() override {} private: diff --git a/Modules/Core/Metadata/include/otbOpticalDefaultImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbOpticalDefaultImageMetadataInterfaceFactory.h index 0d8db3ce03..e4226adf6b 100644 --- a/Modules/Core/Metadata/include/otbOpticalDefaultImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbOpticalDefaultImageMetadataInterfaceFactory.h @@ -42,8 +42,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -60,7 +60,7 @@ public: protected: OpticalDefaultImageMetadataInterfaceFactory(); - ~OpticalDefaultImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~OpticalDefaultImageMetadataInterfaceFactory() override; private: OpticalDefaultImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbOpticalImageMetadataInterface.h b/Modules/Core/Metadata/include/otbOpticalImageMetadataInterface.h index 210534ce3d..8a94830980 100644 --- a/Modules/Core/Metadata/include/otbOpticalImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbOpticalImageMetadataInterface.h @@ -86,7 +86,7 @@ public: virtual VariableLengthVectorType GetLastWavelengths() const = 0; /** Get the enhanced band names */ - std::vector<std::string> GetEnhancedBandNames() const ITK_OVERRIDE = 0; + std::vector<std::string> GetEnhancedBandNames() const override = 0; /** This method is to handle the permutation of the spectral band by some image provider * in most cases, this method won't change the value, but for SPOT data, the bands are set up as @@ -99,9 +99,9 @@ public: virtual WavelengthSpectralBandVectorType GetSpectralSensitivity () const = 0; protected: OpticalImageMetadataInterface(); - ~OpticalImageMetadataInterface() ITK_OVERRIDE {} + ~OpticalImageMetadataInterface() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Core/Metadata/include/otbOpticalImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbOpticalImageMetadataInterfaceFactory.h index 314f0b7edf..a543c766e0 100644 --- a/Modules/Core/Metadata/include/otbOpticalImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbOpticalImageMetadataInterfaceFactory.h @@ -61,7 +61,7 @@ public: protected: OpticalImageMetadataInterfaceFactory(); - ~OpticalImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~OpticalImageMetadataInterfaceFactory() override; private: OpticalImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbPleiadesImageMetadataInterface.h b/Modules/Core/Metadata/include/otbPleiadesImageMetadataInterface.h index ddc9bc114f..65412134ca 100644 --- a/Modules/Core/Metadata/include/otbPleiadesImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbPleiadesImageMetadataInterface.h @@ -54,49 +54,49 @@ public: typedef Superclass::ImageKeywordlistType ImageKeywordlistType; /** Get the radiometric bias from the ossim metadata */ - VariableLengthVectorType GetPhysicalBias() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalBias() const override; /** Get the radiometric gain from the ossim metadata */ - VariableLengthVectorType GetPhysicalGain() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalGain() const override; /** Get the solar irradiance from the ossim metadata */ - VariableLengthVectorType GetSolarIrradiance() const ITK_OVERRIDE; + VariableLengthVectorType GetSolarIrradiance() const override; /** Get the imaging acquisition day from the ossim metadata : IMAGING_DATE metadata variable */ - int GetDay() const ITK_OVERRIDE; + int GetDay() const override; /** Get the imaging acquisition month from the ossim metadata : IMAGING_DATE metadata variable */ - int GetMonth() const ITK_OVERRIDE; + int GetMonth() const override; /** Get the imaging acquisition year from the ossim metadata : IMAGING_DATE metadata variable */ - int GetYear() const ITK_OVERRIDE; + int GetYear() const override; /** Get the imaging acquisition hour from the ossim metadata : IMAGING_DATE metadata variable */ - int GetHour() const ITK_OVERRIDE; + int GetHour() const override; /** Get the imaging acquisition year from the ossim metadata : IMAGING_DATE metadata variable */ - int GetMinute() const ITK_OVERRIDE; + int GetMinute() const override; /** Get the imaging production day from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionDay() const ITK_OVERRIDE; + int GetProductionDay() const override; /** Get the imaging production month from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionMonth() const ITK_OVERRIDE; + int GetProductionMonth() const override; /** Get the imaging production year from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionYear() const ITK_OVERRIDE; + int GetProductionYear() const override; /** Get the sat elevation from the ossim metadata */ - double GetSatElevation() const ITK_OVERRIDE; + double GetSatElevation() const override; /** Get the sat azimuth from the ossim metadata */ - double GetSatAzimuth() const ITK_OVERRIDE; + double GetSatAzimuth() const override; /** Get the first wavelength for the spectral band definition */ - VariableLengthVectorType GetFirstWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetFirstWavelengths() const override; /** Get the last wavelength for the spectral band definition */ - VariableLengthVectorType GetLastWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetLastWavelengths() const override; /** Get Instrument */ std::string GetInstrument() const; @@ -108,25 +108,25 @@ public: * in most cases, this method won't change the value, but for SPOT data, the bands are set up as * 2 1 0 3 in the tiff file, this method which is overloaded for SPOT enables to retrieve the * proper band. */ - unsigned int BandIndexToWavelengthPosition(unsigned int i) const ITK_OVERRIDE; + unsigned int BandIndexToWavelengthPosition(unsigned int i) const override; /** Get the 3 spectral band numbers corresponding to the default display for visualization, * in the order R, G, B */ - std::vector<unsigned int> GetDefaultDisplay() const ITK_OVERRIDE; + std::vector<unsigned int> GetDefaultDisplay() const override; - bool CanRead() const ITK_OVERRIDE; + bool CanRead() const override; /** Get the enhanced band names of the Pleiades data */ - std::vector<std::string> GetEnhancedBandNames() const ITK_OVERRIDE; + std::vector<std::string> GetEnhancedBandNames() const override; /** Vector that contains the filter function value in 6S format (step of 0.0025 micro m). * There values a computed by 6S. */ - WavelengthSpectralBandVectorType GetSpectralSensitivity() const ITK_OVERRIDE; + WavelengthSpectralBandVectorType GetSpectralSensitivity() const override; protected: PleiadesImageMetadataInterface(); - ~PleiadesImageMetadataInterface() ITK_OVERRIDE {} + ~PleiadesImageMetadataInterface() override {} private: diff --git a/Modules/Core/Metadata/include/otbPleiadesImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbPleiadesImageMetadataInterfaceFactory.h index 8384183d18..a1a9578445 100644 --- a/Modules/Core/Metadata/include/otbPleiadesImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbPleiadesImageMetadataInterfaceFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: PleiadesImageMetadataInterfaceFactory(); - ~PleiadesImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~PleiadesImageMetadataInterfaceFactory() override; private: PleiadesImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbQuickBirdImageMetadataInterface.h b/Modules/Core/Metadata/include/otbQuickBirdImageMetadataInterface.h index b8bd98555d..836056c5f1 100644 --- a/Modules/Core/Metadata/include/otbQuickBirdImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbQuickBirdImageMetadataInterface.h @@ -54,65 +54,65 @@ public: typedef Superclass::ImageKeywordlistType ImageKeywordlistType; /** Get the radiometric bias from the ossim metadata */ - VariableLengthVectorType GetPhysicalBias() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalBias() const override; /** Get the radiometric gain from the ossim metadata */ - VariableLengthVectorType GetPhysicalGain() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalGain() const override; /** Get the solar irradiance from the ossim metadata */ - VariableLengthVectorType GetSolarIrradiance() const ITK_OVERRIDE; + VariableLengthVectorType GetSolarIrradiance() const override; /** Get the imaging acquisition day from the ossim metadata : TLCTime metadata value */ - int GetDay() const ITK_OVERRIDE; + int GetDay() const override; /** Get the imaging acquisition month from the ossim metadata : TLCTime metadata value */ - int GetMonth() const ITK_OVERRIDE; + int GetMonth() const override; /** Get the imaging acquisition year from the ossim metadata : TLCTime metadata value */ - int GetYear() const ITK_OVERRIDE; + int GetYear() const override; /** Get the imaging acquisition hour from the ossim metadata : TLCTime metadata value */ - int GetHour() const ITK_OVERRIDE; + int GetHour() const override; /** Get the imaging acquisition year from the ossim metadata : TLCTime metadata value */ - int GetMinute() const ITK_OVERRIDE; + int GetMinute() const override; /** Get the imaging production day from the ossim metadata : generationTime metadata value */ - int GetProductionDay() const ITK_OVERRIDE; + int GetProductionDay() const override; /** Get the imaging production month from the ossim metadata : generationTime metadata value */ - int GetProductionMonth() const ITK_OVERRIDE; + int GetProductionMonth() const override; /** Get the imaging production year from the ossim metadata : generationTime metadata value */ - int GetProductionYear() const ITK_OVERRIDE; + int GetProductionYear() const override; /** Get the sat elevation from the ossim metadata */ - double GetSatElevation() const ITK_OVERRIDE; + double GetSatElevation() const override; /** Get the sat azimuth from the ossim metadata */ - double GetSatAzimuth() const ITK_OVERRIDE; + double GetSatAzimuth() const override; /** Get the first wavelength for the spectral band definition */ - VariableLengthVectorType GetFirstWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetFirstWavelengths() const override; /** Get the last wavelength for the spectral band definition */ - VariableLengthVectorType GetLastWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetLastWavelengths() const override; /** Get the enhanced band names of QuickBird data */ - std::vector<std::string> GetEnhancedBandNames() const ITK_OVERRIDE; + std::vector<std::string> GetEnhancedBandNames() const override; - bool CanRead() const ITK_OVERRIDE; + bool CanRead() const override; /** Get the 3 spectral band numbers corresponding to the default display for visualization, * in the order R, G, B */ - std::vector<unsigned int> GetDefaultDisplay() const ITK_OVERRIDE; + std::vector<unsigned int> GetDefaultDisplay() const override; /** Vector that contains the filter function value in 6S format (step of 0.0025 micro m). * There values a computed by 6S. */ - WavelengthSpectralBandVectorType GetSpectralSensitivity() const ITK_OVERRIDE; + WavelengthSpectralBandVectorType GetSpectralSensitivity() const override; protected: QuickBirdImageMetadataInterface(); - ~QuickBirdImageMetadataInterface() ITK_OVERRIDE {} + ~QuickBirdImageMetadataInterface() override {} private: diff --git a/Modules/Core/Metadata/include/otbQuickBirdImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbQuickBirdImageMetadataInterfaceFactory.h index 8f6eb08cba..bd00c02bf7 100644 --- a/Modules/Core/Metadata/include/otbQuickBirdImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbQuickBirdImageMetadataInterfaceFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: QuickBirdImageMetadataInterfaceFactory(); - ~QuickBirdImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~QuickBirdImageMetadataInterfaceFactory() override; private: QuickBirdImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbRadarsat2ImageMetadataInterface.h b/Modules/Core/Metadata/include/otbRadarsat2ImageMetadataInterface.h index 2d720a1644..2c4d231fb3 100644 --- a/Modules/Core/Metadata/include/otbRadarsat2ImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbRadarsat2ImageMetadataInterface.h @@ -58,40 +58,40 @@ public: /*ImageMetadataInterfaceBase pure virtuals */ /** Get the imaging production day from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionDay() const ITK_OVERRIDE; + int GetProductionDay() const override; /** Get the imaging production month from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionMonth() const ITK_OVERRIDE; + int GetProductionMonth() const override; /** Get the imaging production year from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionYear() const ITK_OVERRIDE; + int GetProductionYear() const override; /** check sensor ID */ - bool CanRead() const ITK_OVERRIDE; + bool CanRead() const override; - int GetDay() const ITK_OVERRIDE; + int GetDay() const override; - int GetMonth() const ITK_OVERRIDE; + int GetMonth() const override; - int GetYear() const ITK_OVERRIDE; + int GetYear() const override; - int GetHour() const ITK_OVERRIDE; + int GetHour() const override; - int GetMinute() const ITK_OVERRIDE; + int GetMinute() const override; - UIntVectorType GetDefaultDisplay() const ITK_OVERRIDE; + UIntVectorType GetDefaultDisplay() const override; /*SarImageMetadataInterface pure virutals rituals */ - double GetPRF() const ITK_OVERRIDE; + double GetPRF() const override; - double GetRSF() const ITK_OVERRIDE; + double GetRSF() const override; - double GetRadarFrequency() const ITK_OVERRIDE; + double GetRadarFrequency() const override; - double GetCenterIncidenceAngle() const ITK_OVERRIDE; + double GetCenterIncidenceAngle() const override; /*get lookup data for calculating backscatter */ - void CreateCalibrationLookupData(const short type) ITK_OVERRIDE; + void CreateCalibrationLookupData(const short type) override; protected: @@ -99,7 +99,7 @@ protected: Radarsat2ImageMetadataInterface(); /* class desctructor */ - ~Radarsat2ImageMetadataInterface() ITK_OVERRIDE {} + ~Radarsat2ImageMetadataInterface() override {} private: Radarsat2ImageMetadataInterface(const Self &); //purposely not implemented @@ -147,7 +147,7 @@ public: } - ~Radarsat2CalibrationLookupData() ITK_OVERRIDE + ~Radarsat2CalibrationLookupData() override { } @@ -159,7 +159,7 @@ public: m_Gains = gains; } - double GetValue(const IndexValueType x, const IndexValueType itkNotUsed(y)) const ITK_OVERRIDE + double GetValue(const IndexValueType x, const IndexValueType itkNotUsed(y)) const override { double lutVal = 1.0; @@ -175,7 +175,7 @@ public: return lutVal; } - void PrintSelf(std::ostream & os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream & os, itk::Indent indent) const override { os << indent << " offset:'" << m_Offset << "'" << std::endl; os << " referenceNoiseLevel.gain: " << std::endl; diff --git a/Modules/Core/Metadata/include/otbRadarsat2ImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbRadarsat2ImageMetadataInterfaceFactory.h index ca77603d2e..df837f6e6e 100644 --- a/Modules/Core/Metadata/include/otbRadarsat2ImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbRadarsat2ImageMetadataInterfaceFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: Radarsat2ImageMetadataInterfaceFactory(); - ~Radarsat2ImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~Radarsat2ImageMetadataInterfaceFactory() override; private: Radarsat2ImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbSarCalibrationLookupData.h b/Modules/Core/Metadata/include/otbSarCalibrationLookupData.h index 98669c7205..04328dfaff 100644 --- a/Modules/Core/Metadata/include/otbSarCalibrationLookupData.h +++ b/Modules/Core/Metadata/include/otbSarCalibrationLookupData.h @@ -59,7 +59,7 @@ class OTBMetadata_EXPORT SarCalibrationLookupData : public itk::LightObject { { } - ~SarCalibrationLookupData() ITK_OVERRIDE + ~SarCalibrationLookupData() override { } @@ -75,7 +75,7 @@ class OTBMetadata_EXPORT SarCalibrationLookupData : public itk::LightObject { itkGetMacro(Type, short); - void PrintSelf(std::ostream & os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream & os, itk::Indent indent) const override { os << indent << " lookup table type:'" << m_Type << "'" << std::endl; Superclass::PrintSelf(os, indent); diff --git a/Modules/Core/Metadata/include/otbSarDefaultImageMetadataInterface.h b/Modules/Core/Metadata/include/otbSarDefaultImageMetadataInterface.h index c842d4fcad..0782320bfd 100644 --- a/Modules/Core/Metadata/include/otbSarDefaultImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbSarDefaultImageMetadataInterface.h @@ -61,134 +61,134 @@ public: typedef double RealType; typedef PointSetType::PointType PointType; - RealType GetRadiometricCalibrationScale() const ITK_OVERRIDE + RealType GetRadiometricCalibrationScale() const override { itkExceptionMacro("GetRadiometricCalibrationScale() not implemented in SarDefaultImageMetadataInterface, no captor type found"); } - PointSetPointer GetRadiometricCalibrationAntennaPatternNewGain() const ITK_OVERRIDE + PointSetPointer GetRadiometricCalibrationAntennaPatternNewGain() const override { itkExceptionMacro("GetRadiometricCalibrationAntennaPatternNewGain() not implemented in SarDefaultImageMetadataInterface, no captor type found"); } - PointSetPointer GetRadiometricCalibrationAntennaPatternOldGain() const ITK_OVERRIDE + PointSetPointer GetRadiometricCalibrationAntennaPatternOldGain() const override { itkExceptionMacro("GetRadiometricCalibrationAntennaPatternOldGain() not implemented in SarDefaultImageMetadataInterface, no captor type found"); } - PointSetPointer GetRadiometricCalibrationIncidenceAngle() const ITK_OVERRIDE + PointSetPointer GetRadiometricCalibrationIncidenceAngle() const override { itkExceptionMacro("GetRadiometricCalibrationIncidenceAngle() not implemented in SarDefaultImageMetadataInterface, no captor type found"); } - PointSetPointer GetRadiometricCalibrationRangeSpreadLoss() const ITK_OVERRIDE + PointSetPointer GetRadiometricCalibrationRangeSpreadLoss() const override { itkExceptionMacro("GetRadiometricCalibrationRangeSpreadLoss() not implemented in SarDefaultImageMetadataInterface, no captor type found"); } - PointSetPointer GetRadiometricCalibrationNoise() const ITK_OVERRIDE + PointSetPointer GetRadiometricCalibrationNoise() const override { itkExceptionMacro("GetRadiometricCalibrationNoise() not implemented in SarDefaultImageMetadataInterface, no captor type found"); } - IndexType GetRadiometricCalibrationAntennaPatternNewGainPolynomialDegree() const ITK_OVERRIDE + IndexType GetRadiometricCalibrationAntennaPatternNewGainPolynomialDegree() const override { itkExceptionMacro("GetRadiometricCalibrationAntennaPatternNewGainPolynomialDegree() not implemented in SarDefaultImageMetadataInterface, no captor type found"); } - IndexType GetRadiometricCalibrationAntennaPatternOldGainPolynomialDegree() const ITK_OVERRIDE + IndexType GetRadiometricCalibrationAntennaPatternOldGainPolynomialDegree() const override { itkExceptionMacro("GetRadiometricCalibrationAntennaPatternOldGainPolynomialDegree() not implemented in SarDefaultImageMetadataInterface, no captor type found"); } - IndexType GetRadiometricCalibrationIncidenceAnglePolynomialDegree() const ITK_OVERRIDE + IndexType GetRadiometricCalibrationIncidenceAnglePolynomialDegree() const override { itkExceptionMacro("GetRadiometricCalibrationIncidenceAnglePolynomialDegree() not implemented in SarDefaultImageMetadataInterface, no captor type found"); } - IndexType GetRadiometricCalibrationRangeSpreadLossPolynomialDegree() const ITK_OVERRIDE + IndexType GetRadiometricCalibrationRangeSpreadLossPolynomialDegree() const override { itkExceptionMacro("GetRadiometricCalibrationRangeSpreadLossPolynomialDegree() not implemented in SarDefaultImageMetadataInterface, no captor type found"); } - IndexType GetRadiometricCalibrationNoisePolynomialDegree() const ITK_OVERRIDE + IndexType GetRadiometricCalibrationNoisePolynomialDegree() const override { itkExceptionMacro("GetRadiometricCalibrationNoisePolynomialDegree() not implemented in SarDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition day from the ossim metadata */ - int GetDay() const ITK_OVERRIDE + int GetDay() const override { itkExceptionMacro("GetDay not implemented in SarDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition month from the ossim metadata */ - int GetMonth() const ITK_OVERRIDE + int GetMonth() const override { itkExceptionMacro("GetMonth not implemented in SarDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition year from the ossim metadata */ - int GetYear() const ITK_OVERRIDE + int GetYear() const override { itkExceptionMacro("GetYear not implemented in SarDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition hour from the ossim metadata */ - int GetHour() const ITK_OVERRIDE + int GetHour() const override { itkExceptionMacro("GetHour not implemented in SarDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging acquisition minute from the ossim metadata */ - int GetMinute() const ITK_OVERRIDE + int GetMinute() const override { itkExceptionMacro("GetMinute not implemented in SarDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging production day from the ossim metadata */ - int GetProductionDay() const ITK_OVERRIDE + int GetProductionDay() const override { itkExceptionMacro("GetProductionDay not implemented in SarDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging production month from the ossim metadata */ - int GetProductionMonth() const ITK_OVERRIDE + int GetProductionMonth() const override { itkExceptionMacro("GetProductionMonth not implemented in SarDefaultImageMetadataInterface, no captor type found"); } /** Get the imaging production year from the ossim metadata */ - int GetProductionYear() const ITK_OVERRIDE + int GetProductionYear() const override { itkExceptionMacro("GetProductionYear not implemented in SarDefaultImageMetadataInterface, no captor type found"); } /** Get the PRF */ - double GetPRF() const ITK_OVERRIDE + double GetPRF() const override { itkExceptionMacro("GetPRF not implemented in SarDefaultImageMetadataInterface, no captor type found"); } /** Get the RSF */ - double GetRSF() const ITK_OVERRIDE + double GetRSF() const override { itkExceptionMacro("GetRSF not implemented in SarDefaultImageMetadataInterface, no captor type found"); } /** Get the radar frequency */ - double GetRadarFrequency() const ITK_OVERRIDE + double GetRadarFrequency() const override { itkExceptionMacro("GetRadarFrequency not implemented in SarDefaultImageMetadataInterface, no captor type found"); } /** Get the center incidence angle */ - double GetCenterIncidenceAngle() const ITK_OVERRIDE + double GetCenterIncidenceAngle() const override { itkExceptionMacro("GetCenterIncidenceAngle not implemented in SarDefaultImageMetadataInterface, no captor type found"); } - bool CanRead() const ITK_OVERRIDE + bool CanRead() const override { // This class is the default one, it has to be able to call every metadata return false; @@ -196,7 +196,7 @@ public: /** Get the 3 spectral band numbers corresponding to the default display for visualization, * in the order R, G, B */ - UIntVectorType GetDefaultDisplay() const ITK_OVERRIDE + UIntVectorType GetDefaultDisplay() const override { UIntVectorType rgb(3); rgb[0] = 0; @@ -207,7 +207,7 @@ public: protected: SarDefaultImageMetadataInterface(){}; - ~SarDefaultImageMetadataInterface() ITK_OVERRIDE {} + ~SarDefaultImageMetadataInterface() override {} private: diff --git a/Modules/Core/Metadata/include/otbSarDefaultImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbSarDefaultImageMetadataInterfaceFactory.h index 957a9867e9..3d30545b75 100644 --- a/Modules/Core/Metadata/include/otbSarDefaultImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbSarDefaultImageMetadataInterfaceFactory.h @@ -42,8 +42,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -60,7 +60,7 @@ public: protected: SarDefaultImageMetadataInterfaceFactory(); - ~SarDefaultImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~SarDefaultImageMetadataInterfaceFactory() override; private: SarDefaultImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbSarImageMetadataInterface.h b/Modules/Core/Metadata/include/otbSarImageMetadataInterface.h index 32fc7e3cfc..efd60bd15e 100644 --- a/Modules/Core/Metadata/include/otbSarImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbSarImageMetadataInterface.h @@ -104,7 +104,7 @@ public: virtual const std::string GetAcquisitionMode() const; /** Get the enhanced band names (No enhanced band name support for SAR) */ - StringVectorType GetEnhancedBandNames() const ITK_OVERRIDE + StringVectorType GetEnhancedBandNames() const override { StringVectorType nothing; return nothing; @@ -112,12 +112,12 @@ public: protected: SarImageMetadataInterface(); - ~SarImageMetadataInterface() ITK_OVERRIDE {} + ~SarImageMetadataInterface() override {} PointSetPointer GetConstantValuePointSet(const RealType& value) const; IndexType GetConstantPolynomialDegree() const; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; LookupDataPointerType m_SarLut; diff --git a/Modules/Core/Metadata/include/otbSarImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbSarImageMetadataInterfaceFactory.h index 9e1c180395..b9cd10bc28 100644 --- a/Modules/Core/Metadata/include/otbSarImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbSarImageMetadataInterfaceFactory.h @@ -61,7 +61,7 @@ public: protected: SarImageMetadataInterfaceFactory(); - ~SarImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~SarImageMetadataInterfaceFactory() override; private: SarImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterface.h b/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterface.h index ebefb70553..c863639858 100644 --- a/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterface.h @@ -59,40 +59,40 @@ public: typedef Superclass::LookupDataPointerType LookupDataPointerType; /** Get the imaging production day from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionDay() const ITK_OVERRIDE; + int GetProductionDay() const override; /** Get the imaging production month from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionMonth() const ITK_OVERRIDE; + int GetProductionMonth() const override; /** Get the imaging production year from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionYear() const ITK_OVERRIDE; + int GetProductionYear() const override; /** check sensor ID */ - bool CanRead() const ITK_OVERRIDE; + bool CanRead() const override; - int GetDay() const ITK_OVERRIDE; + int GetDay() const override; - int GetMonth() const ITK_OVERRIDE; + int GetMonth() const override; - int GetYear() const ITK_OVERRIDE; + int GetYear() const override; - int GetHour() const ITK_OVERRIDE; + int GetHour() const override; - int GetMinute() const ITK_OVERRIDE; + int GetMinute() const override; - UIntVectorType GetDefaultDisplay() const ITK_OVERRIDE; + UIntVectorType GetDefaultDisplay() const override; /*SarImageMetadataInterface pure virutals rituals */ - double GetPRF() const ITK_OVERRIDE; + double GetPRF() const override; - double GetRSF() const ITK_OVERRIDE; + double GetRSF() const override; - double GetRadarFrequency() const ITK_OVERRIDE; + double GetRadarFrequency() const override; - double GetCenterIncidenceAngle() const ITK_OVERRIDE; + double GetCenterIncidenceAngle() const override; /*get lookup data for calculating backscatter */ - void CreateCalibrationLookupData(const short type) ITK_OVERRIDE; + void CreateCalibrationLookupData(const short type) override; protected: @@ -100,7 +100,7 @@ protected: Sentinel1ImageMetadataInterface(); /* class dtor */ - ~Sentinel1ImageMetadataInterface() ITK_OVERRIDE {} + ~Sentinel1ImageMetadataInterface() override {} private: @@ -159,7 +159,7 @@ public: { } - ~Sentinel1CalibrationLookupData() ITK_OVERRIDE + ~Sentinel1CalibrationLookupData() override { } @@ -176,7 +176,7 @@ public: lineTimeInterval = (lt - ft) / ((lines - 1) * 1.0); } - double GetValue(const IndexValueType x, const IndexValueType y) const ITK_OVERRIDE + double GetValue(const IndexValueType x, const IndexValueType y) const override { const int calVecIdx = GetVectorIndex(y); assert(calVecIdx>=0 && calVecIdx < count-1); diff --git a/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterfaceFactory.h index cfdfea8dcd..fafe69dd8f 100644 --- a/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterfaceFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: Sentinel1ImageMetadataInterfaceFactory(); - ~Sentinel1ImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~Sentinel1ImageMetadataInterfaceFactory() override; private: Sentinel1ImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbSpot6ImageMetadataInterface.h b/Modules/Core/Metadata/include/otbSpot6ImageMetadataInterface.h index f3af38e7a9..a63b9fa362 100644 --- a/Modules/Core/Metadata/include/otbSpot6ImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbSpot6ImageMetadataInterface.h @@ -54,49 +54,49 @@ public: typedef Superclass::ImageKeywordlistType ImageKeywordlistType; /** Get the radiometric bias from the ossim metadata */ - VariableLengthVectorType GetPhysicalBias() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalBias() const override; /** Get the radiometric gain from the ossim metadata */ - VariableLengthVectorType GetPhysicalGain() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalGain() const override; /** Get the solar irradiance from the ossim metadata */ - VariableLengthVectorType GetSolarIrradiance() const ITK_OVERRIDE; + VariableLengthVectorType GetSolarIrradiance() const override; /** Get the imaging acquisition day from the ossim metadata : IMAGING_DATE metadata variable */ - int GetDay() const ITK_OVERRIDE; + int GetDay() const override; /** Get the imaging acquisition month from the ossim metadata : IMAGING_DATE metadata variable */ - int GetMonth() const ITK_OVERRIDE; + int GetMonth() const override; /** Get the imaging acquisition year from the ossim metadata : IMAGING_DATE metadata variable */ - int GetYear() const ITK_OVERRIDE; + int GetYear() const override; /** Get the imaging acquisition hour from the ossim metadata : IMAGING_DATE metadata variable */ - int GetHour() const ITK_OVERRIDE; + int GetHour() const override; /** Get the imaging acquisition year from the ossim metadata : IMAGING_DATE metadata variable */ - int GetMinute() const ITK_OVERRIDE; + int GetMinute() const override; /** Get the imaging production day from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionDay() const ITK_OVERRIDE; + int GetProductionDay() const override; /** Get the imaging production month from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionMonth() const ITK_OVERRIDE; + int GetProductionMonth() const override; /** Get the imaging production year from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionYear() const ITK_OVERRIDE; + int GetProductionYear() const override; /** Get the sat elevation from the ossim metadata */ - double GetSatElevation() const ITK_OVERRIDE; + double GetSatElevation() const override; /** Get the sat azimuth from the ossim metadata */ - double GetSatAzimuth() const ITK_OVERRIDE; + double GetSatAzimuth() const override; /** Get the first wavelength for the spectral band definition */ - VariableLengthVectorType GetFirstWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetFirstWavelengths() const override; /** Get the last wavelength for the spectral band definition */ - VariableLengthVectorType GetLastWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetLastWavelengths() const override; /** Get Instrument */ std::string GetInstrument() const; @@ -108,25 +108,25 @@ public: * in most cases, this method won't change the value, but for SPOT data, the bands are set up as * 2 1 0 3 in the tiff file, this method which is overloaded for SPOT enables to retrieve the * proper band. */ - unsigned int BandIndexToWavelengthPosition(unsigned int i) const ITK_OVERRIDE; + unsigned int BandIndexToWavelengthPosition(unsigned int i) const override; /** Get the 3 spectral band numbers corresponding to the default display for visualization, * in the order R, G, B */ - std::vector<unsigned int> GetDefaultDisplay() const ITK_OVERRIDE; + std::vector<unsigned int> GetDefaultDisplay() const override; - bool CanRead() const ITK_OVERRIDE; + bool CanRead() const override; /** Get the enhanced band names of the Spot6 data */ - std::vector<std::string> GetEnhancedBandNames() const ITK_OVERRIDE; + std::vector<std::string> GetEnhancedBandNames() const override; /** Vector that contains the filter function value in 6S format (step of 0.0025 micro m). * There values a computed by 6S. */ - WavelengthSpectralBandVectorType GetSpectralSensitivity() const ITK_OVERRIDE; + WavelengthSpectralBandVectorType GetSpectralSensitivity() const override; protected: Spot6ImageMetadataInterface(); - ~Spot6ImageMetadataInterface() ITK_OVERRIDE {} + ~Spot6ImageMetadataInterface() override {} private: diff --git a/Modules/Core/Metadata/include/otbSpot6ImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbSpot6ImageMetadataInterfaceFactory.h index 139181d54e..83e9ee40ec 100644 --- a/Modules/Core/Metadata/include/otbSpot6ImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbSpot6ImageMetadataInterfaceFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: Spot6ImageMetadataInterfaceFactory(); - ~Spot6ImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~Spot6ImageMetadataInterfaceFactory() override; private: Spot6ImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbSpotImageMetadataInterface.h b/Modules/Core/Metadata/include/otbSpotImageMetadataInterface.h index 7ccdb45d60..3f855595ee 100644 --- a/Modules/Core/Metadata/include/otbSpotImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbSpotImageMetadataInterface.h @@ -54,52 +54,52 @@ public: typedef Superclass::ImageKeywordlistType ImageKeywordlistType; /** Get the radiometric bias from the ossim metadata */ - VariableLengthVectorType GetPhysicalBias() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalBias() const override; /** Get the radiometric gain from the ossim metadata */ - VariableLengthVectorType GetPhysicalGain() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalGain() const override; /** Get the solar irradiance from the ossim metadata */ - VariableLengthVectorType GetSolarIrradiance() const ITK_OVERRIDE; + VariableLengthVectorType GetSolarIrradiance() const override; /** Get the imaging acquisition day from the ossim metadata : IMAGING_DATE metadata variable */ - int GetDay() const ITK_OVERRIDE; + int GetDay() const override; /** Get the imaging acquisition month from the ossim metadata : IMAGING_DATE metadata variable */ - int GetMonth() const ITK_OVERRIDE; + int GetMonth() const override; /** Get the imaging acquisition year from the ossim metadata : IMAGING_DATE metadata variable */ - int GetYear() const ITK_OVERRIDE; + int GetYear() const override; /** Get the imaging acquisition hour from the ossim metadata : IMAGING_DATE metadata variable */ - int GetHour() const ITK_OVERRIDE; + int GetHour() const override; /** Get the imaging acquisition year from the ossim metadata : IMAGING_DATE metadata variable */ - int GetMinute() const ITK_OVERRIDE; + int GetMinute() const override; /** Get the imaging production day from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionDay() const ITK_OVERRIDE; + int GetProductionDay() const override; /** Get the imaging production month from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionMonth() const ITK_OVERRIDE; + int GetProductionMonth() const override; /** Get the imaging production year from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ - int GetProductionYear() const ITK_OVERRIDE; + int GetProductionYear() const override; /** Get the sat elevation from the ossim metadata */ - double GetSatElevation() const ITK_OVERRIDE; + double GetSatElevation() const override; /** Get the sat azimuth from the ossim metadata */ - double GetSatAzimuth() const ITK_OVERRIDE; + double GetSatAzimuth() const override; /** Get the first wavelength for the spectral band definition */ - VariableLengthVectorType GetFirstWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetFirstWavelengths() const override; /** Get the last wavelength for the spectral band definition */ - VariableLengthVectorType GetLastWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetLastWavelengths() const override; /** Get the enhanced band names (here nothing because the metadata did not provide band names) */ - std::vector<std::string> GetEnhancedBandNames() const ITK_OVERRIDE + std::vector<std::string> GetEnhancedBandNames() const override { return this->Superclass::GetBandName(); } @@ -114,21 +114,21 @@ public: * in most cases, this method won't change the value, but for SPOT data, the bands are set up as * 2 1 0 3 in the tiff file, this method which is overloaded for SPOT enables to retrieve the * proper band. */ - unsigned int BandIndexToWavelengthPosition(unsigned int i) const ITK_OVERRIDE; + unsigned int BandIndexToWavelengthPosition(unsigned int i) const override; /** Get the 3 spectral band numbers corresponding to the default display for visualization, * in the order R, G, B */ - std::vector<unsigned int> GetDefaultDisplay() const ITK_OVERRIDE; + std::vector<unsigned int> GetDefaultDisplay() const override; - bool CanRead() const ITK_OVERRIDE; + bool CanRead() const override; /** Vector that contains the filter function value in 6S format (step of 0.0025 micro m). * There values a computed by 6S. */ - WavelengthSpectralBandVectorType GetSpectralSensitivity() const ITK_OVERRIDE; + WavelengthSpectralBandVectorType GetSpectralSensitivity() const override; protected: SpotImageMetadataInterface(); - ~SpotImageMetadataInterface() ITK_OVERRIDE {} + ~SpotImageMetadataInterface() override {} private: diff --git a/Modules/Core/Metadata/include/otbSpotImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbSpotImageMetadataInterfaceFactory.h index 8b4af6d83d..8516b694b5 100644 --- a/Modules/Core/Metadata/include/otbSpotImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbSpotImageMetadataInterfaceFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: SpotImageMetadataInterfaceFactory(); - ~SpotImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~SpotImageMetadataInterfaceFactory() override; private: SpotImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbTerraSarImageMetadataInterface.h b/Modules/Core/Metadata/include/otbTerraSarImageMetadataInterface.h index 17d8a7fde5..321623631f 100644 --- a/Modules/Core/Metadata/include/otbTerraSarImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbTerraSarImageMetadataInterface.h @@ -67,28 +67,28 @@ public: typedef double RealType; /** Get the imaging start acquisition day from the ossim metadata */ - int GetDay() const ITK_OVERRIDE; + int GetDay() const override; /** Get the imaging start acquisition month from the ossim metadata */ - int GetMonth() const ITK_OVERRIDE; + int GetMonth() const override; /** Get the imaging start acquisition year from the ossim metadata */ - int GetYear() const ITK_OVERRIDE; + int GetYear() const override; /** Get the imaging start acquisition hour from the ossim metadata */ - int GetHour() const ITK_OVERRIDE; + int GetHour() const override; /** Get the imaging start acquisition minute from the ossim metadata */ - int GetMinute() const ITK_OVERRIDE; + int GetMinute() const override; /** Get the imaging production day from the ossim metadata : generationTime variable */ - int GetProductionDay() const ITK_OVERRIDE; + int GetProductionDay() const override; /** Get the imaging production month from the ossim metadata : generationTime variable */ - int GetProductionMonth() const ITK_OVERRIDE; + int GetProductionMonth() const override; /** Get the imaging production year from the ossim metadata : generationTime variable */ - int GetProductionYear() const ITK_OVERRIDE; + int GetProductionYear() const override; /** Get the calibration.calFactor : generationTime variable */ double GetCalibrationFactor() const; @@ -115,13 +115,13 @@ public: DoubleVectorType GetNoiseReferencePointList() const; /** Get the radar frequency */ - double GetRadarFrequency() const ITK_OVERRIDE; + double GetRadarFrequency() const override; /** Get the PRF */ - double GetPRF() const ITK_OVERRIDE; + double GetPRF() const override; /** Get the RSF */ - double GetRSF() const ITK_OVERRIDE; + double GetRSF() const override; /** Get the number of corner incidence angles */ unsigned int GetNumberOfCornerIncidenceAngles() const; @@ -130,7 +130,7 @@ public: double GetMeanIncidenceAngles() const; /** Get the center incidence angle */ - double GetCenterIncidenceAngle() const ITK_OVERRIDE; + double GetCenterIncidenceAngle() const override; /** Get the center index */ IndexType GetCenterIncidenceAngleIndex() const; @@ -142,26 +142,26 @@ public: IndexVectorType GetCornersIncidenceAnglesIndex() const; /** Get the constant calibration factor */ - RealType GetRadiometricCalibrationScale() const ITK_OVERRIDE; + RealType GetRadiometricCalibrationScale() const override; - PointSetPointer GetRadiometricCalibrationNoise() const ITK_OVERRIDE; - IndexType GetRadiometricCalibrationNoisePolynomialDegree() const ITK_OVERRIDE; + PointSetPointer GetRadiometricCalibrationNoise() const override; + IndexType GetRadiometricCalibrationNoisePolynomialDegree() const override; //PointSetPointer GetRadiometricCalibrationAntennaPatternOldGain() const; - PointSetPointer GetRadiometricCalibrationIncidenceAngle() const ITK_OVERRIDE; - IndexType GetRadiometricCalibrationIncidenceAnglePolynomialDegree() const ITK_OVERRIDE; + PointSetPointer GetRadiometricCalibrationIncidenceAngle() const override; + IndexType GetRadiometricCalibrationIncidenceAnglePolynomialDegree() const override; - bool CanRead() const ITK_OVERRIDE; + bool CanRead() const override; /** Get the 3 spectral band numbers corresponding to the default display for visualization, * in the order R, G, B */ - std::vector<unsigned int> GetDefaultDisplay() const ITK_OVERRIDE; + std::vector<unsigned int> GetDefaultDisplay() const override; protected: TerraSarImageMetadataInterface(); - ~TerraSarImageMetadataInterface() ITK_OVERRIDE {} + ~TerraSarImageMetadataInterface() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Evaluate polynom with Horner scheme*/ inline double Horner(std::vector<double>& coefficients, const double tauMinusTauRef) const; diff --git a/Modules/Core/Metadata/include/otbTerraSarImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbTerraSarImageMetadataInterfaceFactory.h index 2bd3f8b7f4..3d68e5b6de 100644 --- a/Modules/Core/Metadata/include/otbTerraSarImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbTerraSarImageMetadataInterfaceFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: TerraSarImageMetadataInterfaceFactory(); - ~TerraSarImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~TerraSarImageMetadataInterfaceFactory() override; private: TerraSarImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/Metadata/include/otbWorldView2ImageMetadataInterface.h b/Modules/Core/Metadata/include/otbWorldView2ImageMetadataInterface.h index 0bcc79936a..3d21958848 100644 --- a/Modules/Core/Metadata/include/otbWorldView2ImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbWorldView2ImageMetadataInterface.h @@ -54,66 +54,66 @@ public: typedef Superclass::ImageKeywordlistType ImageKeywordlistType; /** Get the radiometric bias from the ossim metadata */ - VariableLengthVectorType GetPhysicalBias() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalBias() const override; /** Get the radiometric gain from the ossim metadata */ - VariableLengthVectorType GetPhysicalGain() const ITK_OVERRIDE; + VariableLengthVectorType GetPhysicalGain() const override; /** Get the solar irradiance from the ossim metadata */ - VariableLengthVectorType GetSolarIrradiance() const ITK_OVERRIDE; + VariableLengthVectorType GetSolarIrradiance() const override; /** Get the imaging acquisition day from the ossim metadata : TLCTime metadata value */ - int GetDay() const ITK_OVERRIDE; + int GetDay() const override; /** Get the imaging acquisition month from the ossim metadata : TLCTime metadata value */ - int GetMonth() const ITK_OVERRIDE; + int GetMonth() const override; /** Get the imaging acquisition year from the ossim metadata : TLCTime metadata value */ - int GetYear() const ITK_OVERRIDE; + int GetYear() const override; /** Get the imaging acquisition hour from the ossim metadata : TLCTime metadata value */ - int GetHour() const ITK_OVERRIDE; + int GetHour() const override; /** Get the imaging acquisition year from the ossim metadata : TLCTime metadata value */ - int GetMinute() const ITK_OVERRIDE; + int GetMinute() const override; /** Get the imaging production day from the ossim metadata : generationTime metadata value */ - int GetProductionDay() const ITK_OVERRIDE; + int GetProductionDay() const override; /** Get the imaging production month from the ossim metadata : generationTime metadata value */ - int GetProductionMonth() const ITK_OVERRIDE; + int GetProductionMonth() const override; /** Get the imaging production year from the ossim metadata : generationTime metadata value */ - int GetProductionYear() const ITK_OVERRIDE; + int GetProductionYear() const override; /** Get the sat elevation from the ossim metadata */ - double GetSatElevation() const ITK_OVERRIDE; + double GetSatElevation() const override; /** Get the sat azimuth from the ossim metadata */ - double GetSatAzimuth() const ITK_OVERRIDE; + double GetSatAzimuth() const override; /** Get the first wavelength for the spectral band definition */ - VariableLengthVectorType GetFirstWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetFirstWavelengths() const override; /** Get the last wavelength for the spectral band definition */ - VariableLengthVectorType GetLastWavelengths() const ITK_OVERRIDE; + VariableLengthVectorType GetLastWavelengths() const override; - bool CanRead() const ITK_OVERRIDE; + bool CanRead() const override; /** Get the 3 spectral band numbers corresponding to the default display for visualization, * in the order R, G, B */ - std::vector<unsigned int> GetDefaultDisplay() const ITK_OVERRIDE; + std::vector<unsigned int> GetDefaultDisplay() const override; /** Vector that contains the filter function value in 6S format (step of 0.0025 micro m). * There values a computed by 6S. */ - WavelengthSpectralBandVectorType GetSpectralSensitivity() const ITK_OVERRIDE; + WavelengthSpectralBandVectorType GetSpectralSensitivity() const override; /** Get the enhanced band names from band names collected by ossim */ - std::vector<std::string> GetEnhancedBandNames() const ITK_OVERRIDE; + std::vector<std::string> GetEnhancedBandNames() const override; protected: WorldView2ImageMetadataInterface(); - ~WorldView2ImageMetadataInterface() ITK_OVERRIDE {} + ~WorldView2ImageMetadataInterface() override {} private: diff --git a/Modules/Core/Metadata/include/otbWorldView2ImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbWorldView2ImageMetadataInterfaceFactory.h index 597306f622..b48d21fa40 100644 --- a/Modules/Core/Metadata/include/otbWorldView2ImageMetadataInterfaceFactory.h +++ b/Modules/Core/Metadata/include/otbWorldView2ImageMetadataInterfaceFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -60,7 +60,7 @@ public: protected: WorldView2ImageMetadataInterfaceFactory(); - ~WorldView2ImageMetadataInterfaceFactory() ITK_OVERRIDE; + ~WorldView2ImageMetadataInterfaceFactory() override; private: WorldView2ImageMetadataInterfaceFactory(const Self &); //purposely not implemented diff --git a/Modules/Core/ObjectList/include/otbImageList.h b/Modules/Core/ObjectList/include/otbImageList.h index fc836cb047..cc7d167bcb 100644 --- a/Modules/Core/ObjectList/include/otbImageList.h +++ b/Modules/Core/ObjectList/include/otbImageList.h @@ -63,20 +63,20 @@ public: /** * Update images in the list. */ - void UpdateOutputInformation(void) ITK_OVERRIDE; + void UpdateOutputInformation(void) override; void PropagateRequestedRegion(void) - throw (itk::InvalidRequestedRegionError) ITK_OVERRIDE; - void UpdateOutputData(void) ITK_OVERRIDE; + throw (itk::InvalidRequestedRegionError) override; + void UpdateOutputData(void) override; - void SetRequestedRegion(const itk::DataObject * source) ITK_OVERRIDE; + void SetRequestedRegion(const itk::DataObject * source) override; protected: /** Constructor */ ImageList() {}; /** Destructor */ - ~ImageList() ITK_OVERRIDE {} + ~ImageList() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Core/ObjectList/include/otbImageListSource.h b/Modules/Core/ObjectList/include/otbImageListSource.h index d37f072185..1ebbd143ef 100644 --- a/Modules/Core/ObjectList/include/otbImageListSource.h +++ b/Modules/Core/ObjectList/include/otbImageListSource.h @@ -65,9 +65,9 @@ protected: /** Constructor */ ImageListSource(); /** Destructor */ - ~ImageListSource() ITK_OVERRIDE {} + ~ImageListSource() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageListSource(const Self &); //purposely not implemented diff --git a/Modules/Core/ObjectList/include/otbImageListToImageFilter.h b/Modules/Core/ObjectList/include/otbImageListToImageFilter.h index a322ca085a..67c27465b6 100644 --- a/Modules/Core/ObjectList/include/otbImageListToImageFilter.h +++ b/Modules/Core/ObjectList/include/otbImageListToImageFilter.h @@ -75,9 +75,9 @@ protected: /** Constructor */ ImageListToImageFilter(); /** Destructor */ - ~ImageListToImageFilter() ITK_OVERRIDE {} + ~ImageListToImageFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageListToImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/ObjectList/include/otbImageListToImageListApplyFilter.h b/Modules/Core/ObjectList/include/otbImageListToImageListApplyFilter.h index 9501d33078..9865945dc4 100644 --- a/Modules/Core/ObjectList/include/otbImageListToImageListApplyFilter.h +++ b/Modules/Core/ObjectList/include/otbImageListToImageListApplyFilter.h @@ -81,20 +81,20 @@ public: /** Generate output information for the ImageList and for each image in the list. */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** Generate input requested region for each image in the list. */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; protected: /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Constructor */ ImageListToImageListApplyFilter(); /** Destructor */ - ~ImageListToImageListApplyFilter() ITK_OVERRIDE {} + ~ImageListToImageListApplyFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageListToImageListApplyFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/ObjectList/include/otbImageListToImageListFilter.h b/Modules/Core/ObjectList/include/otbImageListToImageListFilter.h index cde7284b19..1a48386220 100644 --- a/Modules/Core/ObjectList/include/otbImageListToImageListFilter.h +++ b/Modules/Core/ObjectList/include/otbImageListToImageListFilter.h @@ -73,9 +73,9 @@ protected: /** Constructor */ ImageListToImageListFilter(); /** Destructor */ - ~ImageListToImageListFilter() ITK_OVERRIDE {} + ~ImageListToImageListFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageListToImageListFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/ObjectList/include/otbImageListToSingleImageFilter.h b/Modules/Core/ObjectList/include/otbImageListToSingleImageFilter.h index 164bb2d9bd..d290e9e849 100644 --- a/Modules/Core/ObjectList/include/otbImageListToSingleImageFilter.h +++ b/Modules/Core/ObjectList/include/otbImageListToSingleImageFilter.h @@ -73,13 +73,13 @@ protected: /** Constructor */ ImageListToSingleImageFilter(); /** Destructor */ - ~ImageListToSingleImageFilter() ITK_OVERRIDE {} + ~ImageListToSingleImageFilter() override {} /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Core/ObjectList/include/otbImageListToVectorImageFilter.h b/Modules/Core/ObjectList/include/otbImageListToVectorImageFilter.h index 7149869c74..ac84491ee5 100644 --- a/Modules/Core/ObjectList/include/otbImageListToVectorImageFilter.h +++ b/Modules/Core/ObjectList/include/otbImageListToVectorImageFilter.h @@ -67,26 +67,26 @@ public: protected: /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** GenerateOutputInformation * Set the number of bands of the output. * Copy information from the first image of the list if existing. **/ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** * GenerateInputRequestedRegion * Set the requested region of each image in the list. */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** Constructor */ ImageListToVectorImageFilter() {}; /** Destructor */ - ~ImageListToVectorImageFilter() ITK_OVERRIDE {} + ~ImageListToVectorImageFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageListToVectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/ObjectList/include/otbImageToImageListFilter.h b/Modules/Core/ObjectList/include/otbImageToImageListFilter.h index 26047d998e..1978e6966f 100644 --- a/Modules/Core/ObjectList/include/otbImageToImageListFilter.h +++ b/Modules/Core/ObjectList/include/otbImageToImageListFilter.h @@ -71,9 +71,9 @@ protected: /** Constructor */ ImageToImageListFilter(); /** Destructor */ - ~ImageToImageListFilter() ITK_OVERRIDE {} + ~ImageToImageListFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageToImageListFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/ObjectList/include/otbObjectList.h b/Modules/Core/ObjectList/include/otbObjectList.h index b9db494bec..6df4f167c8 100644 --- a/Modules/Core/ObjectList/include/otbObjectList.h +++ b/Modules/Core/ObjectList/include/otbObjectList.h @@ -600,9 +600,9 @@ protected: /** Constructor */ ObjectList(); /** Destructor */ - ~ObjectList() ITK_OVERRIDE {} + ~ObjectList() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ObjectList(const Self &); //purposely not implemented diff --git a/Modules/Core/ObjectList/include/otbObjectListSource.h b/Modules/Core/ObjectList/include/otbObjectListSource.h index 183c90c93d..586bd3535a 100644 --- a/Modules/Core/ObjectList/include/otbObjectListSource.h +++ b/Modules/Core/ObjectList/include/otbObjectListSource.h @@ -79,7 +79,7 @@ public: * SmartPointer to a DataObject. If a subclass of ImageSource has * multiple outputs of different types, then that class must provide * an implementation of MakeOutput(). */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; /** Graft the specified DataObject onto this ProcessObject's output. @@ -173,9 +173,9 @@ protected: /** Constructor */ ObjectListSource(); /** Destructor */ - ~ObjectListSource() ITK_OVERRIDE {} + ~ObjectListSource() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Ensure that the output lists are cleared before processing */ virtual void AllocateOutputs(); @@ -190,7 +190,7 @@ protected: * * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; private: ObjectListSource(const Self &); //purposely not implemented diff --git a/Modules/Core/ObjectList/include/otbObjectListSource.txx b/Modules/Core/ObjectList/include/otbObjectListSource.txx index 20163671fe..10bf6116a7 100644 --- a/Modules/Core/ObjectList/include/otbObjectListSource.txx +++ b/Modules/Core/ObjectList/include/otbObjectListSource.txx @@ -145,7 +145,7 @@ void ObjectListSource<TOutputList> ::GenerateData(void) { - itkExceptionMacro("subclass should ITK_OVERRIDE this method!!!"); + itkExceptionMacro("subclass should override this method!!!"); } /** diff --git a/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.h b/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.h index 28ee8ea75e..1b8bfec0ec 100644 --- a/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.h +++ b/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.h @@ -77,11 +77,11 @@ protected: /** Constructor */ ObjectListToObjectListFilter(); /** Destructor */ - ~ObjectListToObjectListFilter() ITK_OVERRIDE {} + ~ObjectListToObjectListFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Multi-threading implementation */ diff --git a/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.txx b/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.txx index 471131c726..2104ebf4ea 100644 --- a/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.txx +++ b/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.txx @@ -134,12 +134,12 @@ ObjectListToObjectListFilter<TInputList, TOutputList> ::ThreadedGenerateData(unsigned int /*startIndex*/, unsigned int /*stopIndex*/, itk::ThreadIdType /*threadId*/) { // The following code is equivalent to: - // itkExceptionMacro("subclass should ITK_OVERRIDE this method!!!"); + // itkExceptionMacro("subclass should override this method!!!"); // The ExceptionMacro is not used because gcc warns that a // 'noreturn' function does return std::ostringstream message; message << "itk::ERROR: " << this->GetNameOfClass() - << "(" << this << "): " << "Subclass should ITK_OVERRIDE this method!!!"; + << "(" << this << "): " << "Subclass should override this method!!!"; itk::ExceptionObject e_(__FILE__, __LINE__, message.str().c_str(), ITK_LOCATION); throw e_; diff --git a/Modules/Core/ObjectList/include/otbUnaryFunctorObjectListBooleanFilter.h b/Modules/Core/ObjectList/include/otbUnaryFunctorObjectListBooleanFilter.h index 46985fc3bd..8f6fa80b67 100644 --- a/Modules/Core/ObjectList/include/otbUnaryFunctorObjectListBooleanFilter.h +++ b/Modules/Core/ObjectList/include/otbUnaryFunctorObjectListBooleanFilter.h @@ -93,15 +93,15 @@ public: protected: UnaryFunctorObjectListBooleanFilter(); - ~UnaryFunctorObjectListBooleanFilter() ITK_OVERRIDE {} + ~UnaryFunctorObjectListBooleanFilter() override {} /** Multi-threading implementation */ - void AfterThreadedGenerateData() ITK_OVERRIDE; + void AfterThreadedGenerateData() override; /** startIndex and stopIndex represent the indices of the Objects to examine in thread threadId */ - void ThreadedGenerateData(unsigned int startIndex, unsigned int stopIndex, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(unsigned int startIndex, unsigned int stopIndex, itk::ThreadIdType threadId) override; /** Internal structure used for passing image data into the threading library */ struct ThreadStruct diff --git a/Modules/Core/ObjectList/include/otbUnaryFunctorObjectListFilter.h b/Modules/Core/ObjectList/include/otbUnaryFunctorObjectListFilter.h index 3b8a023dce..bf101d6181 100644 --- a/Modules/Core/ObjectList/include/otbUnaryFunctorObjectListFilter.h +++ b/Modules/Core/ObjectList/include/otbUnaryFunctorObjectListFilter.h @@ -94,15 +94,15 @@ public: protected: UnaryFunctorObjectListFilter(); - ~UnaryFunctorObjectListFilter() ITK_OVERRIDE {} + ~UnaryFunctorObjectListFilter() override {} /** Multi-threading implementation */ - void AfterThreadedGenerateData() ITK_OVERRIDE; + void AfterThreadedGenerateData() override; /** startIndex and stopIndex represent the indices of the Objects to examine in thread threadId */ - void ThreadedGenerateData(unsigned int startIndex, unsigned int stopIndex, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(unsigned int startIndex, unsigned int stopIndex, itk::ThreadIdType threadId) override; /** End Multi-threading implementation */ diff --git a/Modules/Core/ObjectList/include/otbVectorImageToImageListFilter.h b/Modules/Core/ObjectList/include/otbVectorImageToImageListFilter.h index fe62ef5cc5..dc864f192c 100644 --- a/Modules/Core/ObjectList/include/otbVectorImageToImageListFilter.h +++ b/Modules/Core/ObjectList/include/otbVectorImageToImageListFilter.h @@ -67,22 +67,22 @@ public: typedef typename OutputImageType::Pointer OutputImagePointerType; /** Generate the input requested region from the first element in the list. */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** Generate the output information by building the output list. */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; protected: /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Constructor */ VectorImageToImageListFilter() {}; /** Destructor */ - ~VectorImageToImageListFilter() ITK_OVERRIDE {} + ~VectorImageToImageListFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: VectorImageToImageListFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/PointSet/include/otbImageToPointSetFilter.h b/Modules/Core/PointSet/include/otbImageToPointSetFilter.h index f200163aef..c14ed78b77 100644 --- a/Modules/Core/PointSet/include/otbImageToPointSetFilter.h +++ b/Modules/Core/PointSet/include/otbImageToPointSetFilter.h @@ -79,14 +79,14 @@ public: const InputImageType * GetInput(); /** Prepare the output */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; protected: ImageToPointSetFilter(); - ~ImageToPointSetFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageToPointSetFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Multi-threading implementation */ diff --git a/Modules/Core/PointSet/include/otbImageToPointSetFilter.txx b/Modules/Core/PointSet/include/otbImageToPointSetFilter.txx index 405aa2a2b2..91e3d755f6 100644 --- a/Modules/Core/PointSet/include/otbImageToPointSetFilter.txx +++ b/Modules/Core/PointSet/include/otbImageToPointSetFilter.txx @@ -259,12 +259,12 @@ ImageToPointSetFilter<TInputImage, TOutputPointSet> ::ThreadedGenerateData(const InputImageRegionType&, itk::ThreadIdType) { // The following code is equivalent to: - // itkExceptionMacro("subclass should ITK_OVERRIDE this method!!!"); + // itkExceptionMacro("subclass should override this method!!!"); // The ExceptionMacro is not used because gcc warns that a // 'noreturn' function does return std::ostringstream message; message << "itk::ERROR: " << this->GetNameOfClass() - << "(" << this << "): " << "Subclass should ITK_OVERRIDE this method!!!"; + << "(" << this << "): " << "Subclass should override this method!!!"; itk::ExceptionObject e_(__FILE__, __LINE__, message.str().c_str(), ITK_LOCATION); throw e_; diff --git a/Modules/Core/PointSet/include/otbPointSetExtractROI.h b/Modules/Core/PointSet/include/otbPointSetExtractROI.h index 76e3c757c0..158bfae6f7 100644 --- a/Modules/Core/PointSet/include/otbPointSetExtractROI.h +++ b/Modules/Core/PointSet/include/otbPointSetExtractROI.h @@ -78,11 +78,11 @@ public: protected: PointSetExtractROI(); - ~PointSetExtractROI() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PointSetExtractROI() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Generate Requested Data */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; private: PointSetExtractROI(const PointSetExtractROI &); //purposely not implemented diff --git a/Modules/Core/PointSet/include/otbPointSetFunction.h b/Modules/Core/PointSet/include/otbPointSetFunction.h index a13340f283..785753bac2 100644 --- a/Modules/Core/PointSet/include/otbPointSetFunction.h +++ b/Modules/Core/PointSet/include/otbPointSetFunction.h @@ -71,9 +71,9 @@ public: protected: PointSetFunction(); - ~PointSetFunction() ITK_OVERRIDE {} + ~PointSetFunction() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: PointSetFunction(const Self &); //purposely not implemented diff --git a/Modules/Core/PointSet/include/otbPointSetSource.h b/Modules/Core/PointSet/include/otbPointSetSource.h index 8a545d4bbe..601c8b65db 100644 --- a/Modules/Core/PointSet/include/otbPointSetSource.h +++ b/Modules/Core/PointSet/include/otbPointSetSource.h @@ -125,18 +125,18 @@ public: * SmartPointer to a DataObject. If a subclass of MeshSource has * multiple outputs of different types, then that class must provide * an implementation of MakeOutput(). */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; protected: PointSetSource(); - ~PointSetSource() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PointSetSource() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Requested region of Point Set is specified as i of N unstructured regions. * Since all DataObjects should be able to set the requested region in * unstructured form, just copy output->RequestedRegion all inputs. */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; private: PointSetSource(const Self &); //purposely not implemented diff --git a/Modules/Core/PointSet/include/otbPointSetToPointSetFilter.h b/Modules/Core/PointSet/include/otbPointSetToPointSetFilter.h index f208cb6140..bbe2091f4b 100644 --- a/Modules/Core/PointSet/include/otbPointSetToPointSetFilter.h +++ b/Modules/Core/PointSet/include/otbPointSetToPointSetFilter.h @@ -73,8 +73,8 @@ public: protected: PointSetToPointSetFilter(); - ~PointSetToPointSetFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PointSetToPointSetFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: PointSetToPointSetFilter(const PointSetToPointSetFilter &); //purposely not implemented diff --git a/Modules/Core/PointSet/include/otbRandomPointSetSource.h b/Modules/Core/PointSet/include/otbRandomPointSetSource.h index 34f3ad64f2..e84e807a0a 100644 --- a/Modules/Core/PointSet/include/otbRandomPointSetSource.h +++ b/Modules/Core/PointSet/include/otbRandomPointSetSource.h @@ -87,9 +87,9 @@ public: protected: RandomPointSetSource(); - ~RandomPointSetSource() ITK_OVERRIDE {} + ~RandomPointSetSource() override {} - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; private: RandomPointSetSource(const Self &); //purposely not implemented diff --git a/Modules/Core/PointSet/include/otbThresholdImageToPointSetFilter.h b/Modules/Core/PointSet/include/otbThresholdImageToPointSetFilter.h index 0115bbef31..b3a7fca707 100644 --- a/Modules/Core/PointSet/include/otbThresholdImageToPointSetFilter.h +++ b/Modules/Core/PointSet/include/otbThresholdImageToPointSetFilter.h @@ -84,11 +84,11 @@ public: protected: ThresholdImageToPointSetFilter(); - ~ThresholdImageToPointSetFilter() ITK_OVERRIDE {} + ~ThresholdImageToPointSetFilter() override {} - void ThreadedGenerateData(const InputImageRegionType& inputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const InputImageRegionType& inputRegionForThread, itk::ThreadIdType threadId) override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ThresholdImageToPointSetFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/PointSet/include/otbTransformPointSetFilter.h b/Modules/Core/PointSet/include/otbTransformPointSetFilter.h index 16f9c5e920..06867c5a98 100644 --- a/Modules/Core/PointSet/include/otbTransformPointSetFilter.h +++ b/Modules/Core/PointSet/include/otbTransformPointSetFilter.h @@ -75,11 +75,11 @@ public: protected: TransformPointSetFilter(); - ~TransformPointSetFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~TransformPointSetFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Generate Requested Data */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Transform to apply to all the PointSet points. */ typename TransformType::Pointer m_Transform; diff --git a/Modules/Core/SpatialObjects/include/otbDrawLineSpatialObjectFilter.h b/Modules/Core/SpatialObjects/include/otbDrawLineSpatialObjectFilter.h index 6001dec77a..fd49d3ec5e 100644 --- a/Modules/Core/SpatialObjects/include/otbDrawLineSpatialObjectFilter.h +++ b/Modules/Core/SpatialObjects/include/otbDrawLineSpatialObjectFilter.h @@ -101,10 +101,10 @@ public: protected: DrawLineSpatialObjectFilter(); - ~DrawLineSpatialObjectFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~DrawLineSpatialObjectFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: DrawLineSpatialObjectFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/SpatialObjects/include/otbDrawLineSpatialObjectListFilter.h b/Modules/Core/SpatialObjects/include/otbDrawLineSpatialObjectListFilter.h index 74e752e043..72a6854b6e 100644 --- a/Modules/Core/SpatialObjects/include/otbDrawLineSpatialObjectListFilter.h +++ b/Modules/Core/SpatialObjects/include/otbDrawLineSpatialObjectListFilter.h @@ -92,10 +92,10 @@ public: protected: DrawLineSpatialObjectListFilter(); - ~DrawLineSpatialObjectListFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~DrawLineSpatialObjectListFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** * compute the intersection of the segment to draw with the region diff --git a/Modules/Core/SpatialObjects/include/otbImageToLineSpatialObjectListFilter.h b/Modules/Core/SpatialObjects/include/otbImageToLineSpatialObjectListFilter.h index 673ada59a9..f4af3ce59b 100644 --- a/Modules/Core/SpatialObjects/include/otbImageToLineSpatialObjectListFilter.h +++ b/Modules/Core/SpatialObjects/include/otbImageToLineSpatialObjectListFilter.h @@ -85,8 +85,8 @@ public: protected: ImageToLineSpatialObjectListFilter(); - ~ImageToLineSpatialObjectListFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageToLineSpatialObjectListFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageToLineSpatialObjectListFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/SpatialObjects/include/otbLineSpatialObject.h b/Modules/Core/SpatialObjects/include/otbLineSpatialObject.h index a4adf2d054..536f2b305b 100644 --- a/Modules/Core/SpatialObjects/include/otbLineSpatialObject.h +++ b/Modules/Core/SpatialObjects/include/otbLineSpatialObject.h @@ -74,19 +74,19 @@ public: void SetPoints(PointListType& newPoints); /** Return a point in the list given the index */ - const SpatialObjectPointType* GetPoint(IdentifierType id) const ITK_OVERRIDE + const SpatialObjectPointType* GetPoint(IdentifierType id) const override { return &(m_Points[id]); } /** Return a point in the list given the index */ - SpatialObjectPointType* GetPoint(IdentifierType id) ITK_OVERRIDE + SpatialObjectPointType* GetPoint(IdentifierType id) override { return &(m_Points[id]); } /** Return the number of points in the list */ - SizeValueType GetNumberOfPoints(void) const ITK_OVERRIDE + SizeValueType GetNumberOfPoints(void) const override { return m_Points.size(); } @@ -94,18 +94,18 @@ public: /** Returns true if the line is evaluable at the requested point, * false otherwise. */ bool IsEvaluableAt(const PointType& point, - unsigned int depth = 0, char * name = ITK_NULLPTR) const ITK_OVERRIDE; + unsigned int depth = 0, char * name = ITK_NULLPTR) const override; /** Returns the value of the line at that point. * Currently this function returns a binary value, * but it might want to return a degree of membership * in case of fuzzy Lines. */ bool ValueAt(const PointType& point, double& value, - unsigned int depth = 0, char * name = ITK_NULLPTR) const ITK_OVERRIDE; + unsigned int depth = 0, char * name = ITK_NULLPTR) const override; /** Returns true if the point is inside the line, false otherwise. */ bool IsInside(const PointType& point, - unsigned int depth, char * name) const ITK_OVERRIDE; + unsigned int depth, char * name) const override; /** Test whether a point is inside or outside the object * For computational speed purposes, it is faster if the method does not @@ -113,15 +113,15 @@ public: virtual bool IsInside(const PointType& point) const; /** Compute the boundaries of the line.*/ - bool ComputeLocalBoundingBox() const ITK_OVERRIDE; + bool ComputeLocalBoundingBox() const override; protected: /** Constructor */ LineSpatialObject(); /** Destructor */ - ~LineSpatialObject() ITK_OVERRIDE; + ~LineSpatialObject() override; /** Method to print the object. */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LineSpatialObject(const Self &); //purposely not implemented diff --git a/Modules/Core/SpatialObjects/include/otbLineSpatialObjectList.h b/Modules/Core/SpatialObjects/include/otbLineSpatialObjectList.h index 794b1efdc6..c1ab636cb3 100644 --- a/Modules/Core/SpatialObjects/include/otbLineSpatialObjectList.h +++ b/Modules/Core/SpatialObjects/include/otbLineSpatialObjectList.h @@ -58,7 +58,7 @@ public: protected: LineSpatialObjectList() {}; - ~LineSpatialObjectList() ITK_OVERRIDE {} + ~LineSpatialObjectList() override {} private: LineSpatialObjectList(const Self &); //purposely not implemented diff --git a/Modules/Core/SpatialObjects/include/otbLineSpatialObjectListToPointSetFilter.h b/Modules/Core/SpatialObjects/include/otbLineSpatialObjectListToPointSetFilter.h index 9d15dcf219..9da17bfef6 100644 --- a/Modules/Core/SpatialObjects/include/otbLineSpatialObjectListToPointSetFilter.h +++ b/Modules/Core/SpatialObjects/include/otbLineSpatialObjectListToPointSetFilter.h @@ -74,8 +74,8 @@ public: protected: LineSpatialObjectListToPointSetFilter(); - ~LineSpatialObjectListToPointSetFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LineSpatialObjectListToPointSetFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LineSpatialObjectListToPointSetFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/SpatialObjects/include/otbSpatialObjectSource.h b/Modules/Core/SpatialObjects/include/otbSpatialObjectSource.h index 05a5439464..fadfaff42a 100644 --- a/Modules/Core/SpatialObjects/include/otbSpatialObjectSource.h +++ b/Modules/Core/SpatialObjects/include/otbSpatialObjectSource.h @@ -67,9 +67,9 @@ protected: /** Constructor */ SpatialObjectSource(); /** Destructor */ - ~SpatialObjectSource() ITK_OVERRIDE {} + ~SpatialObjectSource() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SpatialObjectSource(const Self &); //purposely not implemented diff --git a/Modules/Core/SpatialObjects/include/otbSpatialObjectToImageDrawingFilter.h b/Modules/Core/SpatialObjects/include/otbSpatialObjectToImageDrawingFilter.h index aa10112f6e..26326dc30c 100644 --- a/Modules/Core/SpatialObjects/include/otbSpatialObjectToImageDrawingFilter.h +++ b/Modules/Core/SpatialObjects/include/otbSpatialObjectToImageDrawingFilter.h @@ -140,10 +140,10 @@ public: protected: SpatialObjectToImageDrawingFilter(); - ~SpatialObjectToImageDrawingFilter() ITK_OVERRIDE; + ~SpatialObjectToImageDrawingFilter() override; - void GenerateOutputInformation() ITK_OVERRIDE; // do nothing - void GenerateData() ITK_OVERRIDE; + void GenerateOutputInformation() override; // do nothing + void GenerateData() override; SizeType m_Size; double m_Spacing[OutputImageDimension]; @@ -153,7 +153,7 @@ protected: ValueType m_OutsideValue; bool m_UseObjectValue; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SpatialObjectToImageDrawingFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/Streaming/include/otbNumberOfDivisionsStrippedStreamingManager.h b/Modules/Core/Streaming/include/otbNumberOfDivisionsStrippedStreamingManager.h index e1045bcdc1..10283c7db8 100644 --- a/Modules/Core/Streaming/include/otbNumberOfDivisionsStrippedStreamingManager.h +++ b/Modules/Core/Streaming/include/otbNumberOfDivisionsStrippedStreamingManager.h @@ -68,11 +68,11 @@ public: itkGetMacro(NumberOfDivisions, unsigned int); /** Actually computes the stream divisions given a DataObject and its region to write */ - void PrepareStreaming(itk::DataObject * /*input*/, const RegionType ®ion) ITK_OVERRIDE; + void PrepareStreaming(itk::DataObject * /*input*/, const RegionType ®ion) override; protected: NumberOfDivisionsStrippedStreamingManager(); - ~NumberOfDivisionsStrippedStreamingManager() ITK_OVERRIDE; + ~NumberOfDivisionsStrippedStreamingManager() override; /** The splitter type used to generate the different strips */ typedef itk::ImageRegionSplitterSlowDimension SplitterType; diff --git a/Modules/Core/Streaming/include/otbNumberOfDivisionsTiledStreamingManager.h b/Modules/Core/Streaming/include/otbNumberOfDivisionsTiledStreamingManager.h index 0b72ca8f92..270dc471e7 100644 --- a/Modules/Core/Streaming/include/otbNumberOfDivisionsTiledStreamingManager.h +++ b/Modules/Core/Streaming/include/otbNumberOfDivisionsTiledStreamingManager.h @@ -67,11 +67,11 @@ public: itkGetMacro(NumberOfDivisions, unsigned int); /** Actually computes the stream divisions given a DataObject and its region to write */ - void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) ITK_OVERRIDE; + void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) override; protected: NumberOfDivisionsTiledStreamingManager(); - ~NumberOfDivisionsTiledStreamingManager() ITK_OVERRIDE; + ~NumberOfDivisionsTiledStreamingManager() override; /** The number of lines per strip desired by the user. * This may be different than the one computed by the Splitter */ diff --git a/Modules/Core/Streaming/include/otbNumberOfLinesStrippedStreamingManager.h b/Modules/Core/Streaming/include/otbNumberOfLinesStrippedStreamingManager.h index a6b5c1bf2d..6426c858b6 100644 --- a/Modules/Core/Streaming/include/otbNumberOfLinesStrippedStreamingManager.h +++ b/Modules/Core/Streaming/include/otbNumberOfLinesStrippedStreamingManager.h @@ -69,11 +69,11 @@ public: /** Actually computes the stream divisions, according to the specified streaming mode, * eventually using the input parameter to estimate memory consumption */ - void PrepareStreaming(itk::DataObject * /*input*/, const RegionType ®ion) ITK_OVERRIDE; + void PrepareStreaming(itk::DataObject * /*input*/, const RegionType ®ion) override; protected: NumberOfLinesStrippedStreamingManager(); - ~NumberOfLinesStrippedStreamingManager() ITK_OVERRIDE; + ~NumberOfLinesStrippedStreamingManager() override; /** The splitter type used to generate the different strips */ typedef itk::ImageRegionSplitter<itkGetStaticConstMacro(ImageDimension)> SplitterType; diff --git a/Modules/Core/Streaming/include/otbPersistentFilterStreamingDecorator.h b/Modules/Core/Streaming/include/otbPersistentFilterStreamingDecorator.h index 47c08879e6..692848d833 100644 --- a/Modules/Core/Streaming/include/otbPersistentFilterStreamingDecorator.h +++ b/Modules/Core/Streaming/include/otbPersistentFilterStreamingDecorator.h @@ -73,17 +73,17 @@ public: itkGetConstObjectMacro(Filter, FilterType); itkGetObjectMacro(Streamer, StreamerType); - void Update(void) ITK_OVERRIDE; + void Update(void) override; protected: /** Constructor */ PersistentFilterStreamingDecorator(); /** Destructor */ - ~PersistentFilterStreamingDecorator() ITK_OVERRIDE {} + ~PersistentFilterStreamingDecorator() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /// Object responsible for streaming StreamerPointerType m_Streamer; diff --git a/Modules/Core/Streaming/include/otbPersistentImageFilter.h b/Modules/Core/Streaming/include/otbPersistentImageFilter.h index 69267fd730..f40159b95e 100644 --- a/Modules/Core/Streaming/include/otbPersistentImageFilter.h +++ b/Modules/Core/Streaming/include/otbPersistentImageFilter.h @@ -73,9 +73,9 @@ protected: /** Constructor */ PersistentImageFilter() {} /** Destructor */ - ~PersistentImageFilter() ITK_OVERRIDE {} + ~PersistentImageFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h b/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h index 41fe7808e9..19c6507142 100644 --- a/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h +++ b/Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h @@ -128,10 +128,10 @@ protected: PipelineMemoryPrintCalculator(); /** Destructor */ - ~PipelineMemoryPrintCalculator() ITK_OVERRIDE; + ~PipelineMemoryPrintCalculator() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Recursive method to evaluate memory print in bytes */ MemoryPrintType EvaluateProcessObjectPrintRecursive(ProcessObjectType * process); diff --git a/Modules/Core/Streaming/include/otbRAMDrivenAdaptativeStreamingManager.h b/Modules/Core/Streaming/include/otbRAMDrivenAdaptativeStreamingManager.h index 2fd4796803..2ddeccf215 100644 --- a/Modules/Core/Streaming/include/otbRAMDrivenAdaptativeStreamingManager.h +++ b/Modules/Core/Streaming/include/otbRAMDrivenAdaptativeStreamingManager.h @@ -83,11 +83,11 @@ public: /** Actually computes the stream divisions, according to the specified streaming mode, * eventually using the input parameter to estimate memory consumption */ - void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) ITK_OVERRIDE; + void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) override; protected: RAMDrivenAdaptativeStreamingManager(); - ~RAMDrivenAdaptativeStreamingManager() ITK_OVERRIDE; + ~RAMDrivenAdaptativeStreamingManager() override; /** The number of MegaBytes of RAM available */ unsigned int m_AvailableRAMInMB; diff --git a/Modules/Core/Streaming/include/otbRAMDrivenStrippedStreamingManager.h b/Modules/Core/Streaming/include/otbRAMDrivenStrippedStreamingManager.h index 1fc33b9ac1..332c2610d2 100644 --- a/Modules/Core/Streaming/include/otbRAMDrivenStrippedStreamingManager.h +++ b/Modules/Core/Streaming/include/otbRAMDrivenStrippedStreamingManager.h @@ -78,11 +78,11 @@ public: /** Actually computes the stream divisions, according to the specified streaming mode, * eventually using the input parameter to estimate memory consumption */ - void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) ITK_OVERRIDE; + void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) override; protected: RAMDrivenStrippedStreamingManager(); - ~RAMDrivenStrippedStreamingManager() ITK_OVERRIDE; + ~RAMDrivenStrippedStreamingManager() override; /** The splitter type used to generate the different strips */ typedef itk::ImageRegionSplitter<itkGetStaticConstMacro(ImageDimension)> SplitterType; diff --git a/Modules/Core/Streaming/include/otbRAMDrivenTiledStreamingManager.h b/Modules/Core/Streaming/include/otbRAMDrivenTiledStreamingManager.h index 6ea176b708..d5b40a858c 100644 --- a/Modules/Core/Streaming/include/otbRAMDrivenTiledStreamingManager.h +++ b/Modules/Core/Streaming/include/otbRAMDrivenTiledStreamingManager.h @@ -77,11 +77,11 @@ public: /** Actually computes the stream divisions, according to the specified streaming mode, * eventually using the input parameter to estimate memory consumption */ - void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) ITK_OVERRIDE; + void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) override; protected: RAMDrivenTiledStreamingManager(); - ~RAMDrivenTiledStreamingManager() ITK_OVERRIDE; + ~RAMDrivenTiledStreamingManager() override; /** The number of MegaBytes of RAM available */ unsigned int m_AvailableRAMInMB; diff --git a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h index feff1c60c5..998ba4c287 100644 --- a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h +++ b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h @@ -140,18 +140,18 @@ public: /** Override Update() from ProcessObject * This filter does not produce an output */ - void Update() ITK_OVERRIDE; + void Update() override; protected: StreamingImageVirtualWriter(); - ~StreamingImageVirtualWriter() ITK_OVERRIDE; + ~StreamingImageVirtualWriter() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; private: StreamingImageVirtualWriter(const StreamingImageVirtualWriter &); //purposely not implemented diff --git a/Modules/Core/Streaming/include/otbStreamingManager.h b/Modules/Core/Streaming/include/otbStreamingManager.h index 2095e48e8f..e5a853309a 100644 --- a/Modules/Core/Streaming/include/otbStreamingManager.h +++ b/Modules/Core/Streaming/include/otbStreamingManager.h @@ -90,7 +90,7 @@ public: protected: StreamingManager(); - ~StreamingManager() ITK_OVERRIDE; + ~StreamingManager() override; virtual unsigned int EstimateOptimalNumberOfDivisions(itk::DataObject * input, const RegionType ®ion, MemoryPrintType availableRAMInMB, diff --git a/Modules/Core/Streaming/include/otbTileDimensionTiledStreamingManager.h b/Modules/Core/Streaming/include/otbTileDimensionTiledStreamingManager.h index 0bb3ee36dd..a4286febb0 100644 --- a/Modules/Core/Streaming/include/otbTileDimensionTiledStreamingManager.h +++ b/Modules/Core/Streaming/include/otbTileDimensionTiledStreamingManager.h @@ -72,11 +72,11 @@ public: /** Actually computes the stream divisions, according to the specified streaming mode, * eventually using the input parameter to estimate memory consumption */ - void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) ITK_OVERRIDE; + void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) override; protected: TileDimensionTiledStreamingManager(); - ~TileDimensionTiledStreamingManager() ITK_OVERRIDE; + ~TileDimensionTiledStreamingManager() override; /** The number of lines per strip desired by the user. * This may be different than the one computed by the Splitter */ diff --git a/Modules/Core/Transform/include/otbCompositeTransform.h b/Modules/Core/Transform/include/otbCompositeTransform.h index 3a5e8a643e..f638c97233 100644 --- a/Modules/Core/Transform/include/otbCompositeTransform.h +++ b/Modules/Core/Transform/include/otbCompositeTransform.h @@ -118,7 +118,7 @@ public: itkGetConstReferenceMacro(SecondTransform, SecondTransformPointerType); /** Method to transform a point. */ - SecondTransformOutputPointType TransformPoint(const FirstTransformInputPointType&) const ITK_OVERRIDE; + SecondTransformOutputPointType TransformPoint(const FirstTransformInputPointType&) const override; /** Method to transform a vector. */ // virtual OutputVectorType TransformVector(const InputVectorType &) const; @@ -131,7 +131,7 @@ public: protected: CompositeTransform(); - ~CompositeTransform() ITK_OVERRIDE; + ~CompositeTransform() override; FirstTransformPointerType m_FirstTransform; SecondTransformPointerType m_SecondTransform; diff --git a/Modules/Core/Transform/include/otbForwardSensorModel.h b/Modules/Core/Transform/include/otbForwardSensorModel.h index eb09f6f209..c158426674 100644 --- a/Modules/Core/Transform/include/otbForwardSensorModel.h +++ b/Modules/Core/Transform/include/otbForwardSensorModel.h @@ -74,14 +74,14 @@ public: itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions); /** Compute the world coordinates. */ - OutputPointType TransformPoint(const InputPointType& point) const ITK_OVERRIDE; + OutputPointType TransformPoint(const InputPointType& point) const override; protected: ForwardSensorModel(); - ~ForwardSensorModel() ITK_OVERRIDE; + ~ForwardSensorModel() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Core/Transform/include/otbGenericMapProjection.h b/Modules/Core/Transform/include/otbGenericMapProjection.h index d7030760b4..4e6d5f15ff 100644 --- a/Modules/Core/Transform/include/otbGenericMapProjection.h +++ b/Modules/Core/Transform/include/otbGenericMapProjection.h @@ -98,7 +98,7 @@ public: virtual void PrintMap() const; - OutputPointType TransformPoint(const InputPointType& point) const ITK_OVERRIDE; + OutputPointType TransformPoint(const InputPointType& point) const override; virtual bool InstantiateProjection(); @@ -111,9 +111,9 @@ public: protected: GenericMapProjection(); - ~GenericMapProjection() ITK_OVERRIDE; + ~GenericMapProjection() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; MapProjectionAdapter::Pointer m_MapProjection; diff --git a/Modules/Core/Transform/include/otbGenericRSTransform.h b/Modules/Core/Transform/include/otbGenericRSTransform.h index aac8f94684..35f0bc7cde 100644 --- a/Modules/Core/Transform/include/otbGenericRSTransform.h +++ b/Modules/Core/Transform/include/otbGenericRSTransform.h @@ -168,31 +168,31 @@ public: /** Methods prototypes */ virtual const TransformType * GetTransform() const; - OutputPointType TransformPoint(const InputPointType& point) const ITK_OVERRIDE; + OutputPointType TransformPoint(const InputPointType& point) const override; virtual void InstantiateTransform(); // Get inverse methods bool GetInverse(Self * inverseTransform) const; - InverseTransformBasePointer GetInverseTransform() const ITK_OVERRIDE; + InverseTransformBasePointer GetInverseTransform() const override; // Dummy set parameter method - void SetParameters(const typename Superclass::ParametersType &) ITK_OVERRIDE {} + void SetParameters(const typename Superclass::ParametersType &) override {} // Dummy ComputeJacobianWithRespectToParameters method - void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType& ) const ITK_OVERRIDE {} + void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType& ) const override {} protected: GenericRSTransform(); - ~GenericRSTransform() ITK_OVERRIDE {} + ~GenericRSTransform() override {} - void Modified() const ITK_OVERRIDE + void Modified() const override { this->Superclass::Modified(); m_TransformUpToDate = false; } - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: GenericRSTransform(const Self &); //purposely not implemented diff --git a/Modules/Core/Transform/include/otbGeocentricTransform.h b/Modules/Core/Transform/include/otbGeocentricTransform.h index c7874d5413..9d53f04f14 100644 --- a/Modules/Core/Transform/include/otbGeocentricTransform.h +++ b/Modules/Core/Transform/include/otbGeocentricTransform.h @@ -66,11 +66,11 @@ public: itkStaticConstMacro(SpaceDimension, unsigned int, NInputDimensions); itkStaticConstMacro(ParametersDimension, unsigned int, NInputDimensions * (NInputDimensions + 1)); - OutputPointType TransformPoint(const InputPointType& point) const ITK_OVERRIDE; + OutputPointType TransformPoint(const InputPointType& point) const override; protected: GeocentricTransform(); - ~GeocentricTransform() ITK_OVERRIDE; + ~GeocentricTransform() override; EllipsoidAdapter::Pointer m_Ellipsoid; private: diff --git a/Modules/Core/Transform/include/otbImageToGenericRSOutputParameters.h b/Modules/Core/Transform/include/otbImageToGenericRSOutputParameters.h index 27742733b6..79850a27d9 100644 --- a/Modules/Core/Transform/include/otbImageToGenericRSOutputParameters.h +++ b/Modules/Core/Transform/include/otbImageToGenericRSOutputParameters.h @@ -163,7 +163,7 @@ public: protected: ImageToGenericRSOutputParameters(); - ~ImageToGenericRSOutputParameters() ITK_OVERRIDE {} + ~ImageToGenericRSOutputParameters() override {} private: ImageToGenericRSOutputParameters(const Self&); //purposely not implemented diff --git a/Modules/Core/Transform/include/otbInverseLogPolarTransform.h b/Modules/Core/Transform/include/otbInverseLogPolarTransform.h index 99b220d91a..14d60db886 100644 --- a/Modules/Core/Transform/include/otbInverseLogPolarTransform.h +++ b/Modules/Core/Transform/include/otbInverseLogPolarTransform.h @@ -83,50 +83,50 @@ public: * Set the transform parameters through the standard interface. * \param parameters The parameters of the transform. */ - void SetParameters(const ParametersType& parameters) ITK_OVERRIDE; + void SetParameters(const ParametersType& parameters) override; /** * Get the transform parameters through the standard interface. * \return The parameters of the transform. */ - ParametersType& GetParameters(void) const ITK_OVERRIDE; + ParametersType& GetParameters(void) const override; /** * Set the Fixed Parameters * \param param The fixed parameters of the transform. */ - void SetFixedParameters( const ParametersType & param) ITK_OVERRIDE + void SetFixedParameters( const ParametersType & param) override { this->m_FixedParameters = param; } /** * Get the Fixed Parameters * \return The Fixed parameters of the transform. */ - const ParametersType& GetFixedParameters(void) const ITK_OVERRIDE{return this->m_FixedParameters; } + const ParametersType& GetFixedParameters(void) const override{return this->m_FixedParameters; } /** * Transform a point. * \param point The point to transform. * \return The transformed point. */ using Superclass::TransformVector; - OutputPointType TransformPoint(const InputPointType& point) const ITK_OVERRIDE; + OutputPointType TransformPoint(const InputPointType& point) const override; /** * Transform a vector representing a point. * \param vector The point to transform. * \return The transformed point. */ - OutputVectorType TransformVector(const InputVectorType& vector) const ITK_OVERRIDE; + OutputVectorType TransformVector(const InputVectorType& vector) const override; /** * Transform a vnl vector representing a point. * \param vector The point to transform. * \return The transformed point. */ - OutputVnlVectorType TransformVector(const InputVnlVectorType& vector) const ITK_OVERRIDE; + OutputVnlVectorType TransformVector(const InputVnlVectorType& vector) const override; protected: /** Constructor */ InverseLogPolarTransform(); /** Destructor */ - ~InverseLogPolarTransform() ITK_OVERRIDE; + ~InverseLogPolarTransform() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: InverseLogPolarTransform(const Self &); // purposely not implemented diff --git a/Modules/Core/Transform/include/otbInverseSensorModel.h b/Modules/Core/Transform/include/otbInverseSensorModel.h index 92461591c5..acb24a2f5e 100644 --- a/Modules/Core/Transform/include/otbInverseSensorModel.h +++ b/Modules/Core/Transform/include/otbInverseSensorModel.h @@ -74,16 +74,16 @@ public: itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions); // Transform of geographic point in image sensor index - OutputPointType TransformPoint(const InputPointType& point) const ITK_OVERRIDE; + OutputPointType TransformPoint(const InputPointType& point) const override; // Transform of geographic point in image sensor index -- Backward Compatibility // OutputPointType TransformPoint(const InputPointType &point, double height) const; protected: InverseSensorModel(); - ~InverseSensorModel() ITK_OVERRIDE; + ~InverseSensorModel() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Core/Transform/include/otbLogPolarTransform.h b/Modules/Core/Transform/include/otbLogPolarTransform.h index 19081e97be..110595ffa9 100644 --- a/Modules/Core/Transform/include/otbLogPolarTransform.h +++ b/Modules/Core/Transform/include/otbLogPolarTransform.h @@ -84,53 +84,53 @@ public: * Set the transform parameters through the standard interface. * \param parameters The parameters of the transform. */ - void SetParameters(const ParametersType& parameters) ITK_OVERRIDE; + void SetParameters(const ParametersType& parameters) override; /** * Get the transform parameters through the standard interface. * \return The parameters of the transform. */ - ParametersType& GetParameters(void) const ITK_OVERRIDE; + ParametersType& GetParameters(void) const override; /** * Set the Fixed Parameters * \param param The fixed parameters of the transform. */ - void SetFixedParameters( const ParametersType & param) ITK_OVERRIDE + void SetFixedParameters( const ParametersType & param) override { this->m_FixedParameters = param; } /** * Get the Fixed Parameters * \return The Fixed parameters of the transform. */ - const ParametersType& GetFixedParameters(void) const ITK_OVERRIDE{return this->m_FixedParameters; } + const ParametersType& GetFixedParameters(void) const override{return this->m_FixedParameters; } /** * Transform a point. * \param point The point to transform. * \return The transformed point. */ - OutputPointType TransformPoint(const InputPointType& point) const ITK_OVERRIDE; + OutputPointType TransformPoint(const InputPointType& point) const override; /** * Transform a vector representing a point. * \param vector The point to transform. * \return The transformed point. */ using Superclass::TransformVector; - OutputVectorType TransformVector(const InputVectorType& vector) const ITK_OVERRIDE; + OutputVectorType TransformVector(const InputVectorType& vector) const override; /** * Transform a vnl vector representing a point. * \param vector The point to transform. * \return The transformed point. */ - OutputVnlVectorType TransformVector(const InputVnlVectorType& vector) const ITK_OVERRIDE; + OutputVnlVectorType TransformVector(const InputVnlVectorType& vector) const override; protected: /** Constructor */ LogPolarTransform(); /** Destructor */ - ~LogPolarTransform() ITK_OVERRIDE; + ~LogPolarTransform() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LogPolarTransform(const Self &); // purposely not implemented diff --git a/Modules/Core/Transform/include/otbSensorModelBase.h b/Modules/Core/Transform/include/otbSensorModelBase.h index 07d4e2353f..f2ae212e5d 100644 --- a/Modules/Core/Transform/include/otbSensorModelBase.h +++ b/Modules/Core/Transform/include/otbSensorModelBase.h @@ -92,10 +92,10 @@ public: protected: SensorModelBase(); - ~SensorModelBase() ITK_OVERRIDE; + ~SensorModelBase() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** ImageKeywordlist */ ImageKeywordlist m_ImageKeywordlist; diff --git a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h index 97a32a5701..41b7058b52 100644 --- a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h +++ b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h @@ -96,22 +96,22 @@ protected: /** Constructor */ StreamingWarpImageFilter(); /** Destructor */ - ~StreamingWarpImageFilter() ITK_OVERRIDE {} + ~StreamingWarpImageFilter() override {} /** PrintSelf */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * This filters requires only a part of the input and of the displacement field to * produce its output. As such, we need to overload the GenerateInputRequestedRegion() method. */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** * Re-implement the method ThreadedGenerateData to mask area outside the deformation grid */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId ) ITK_OVERRIDE; + itk::ThreadIdType threadId ) override; private: StreamingWarpImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Core/Transform/include/otbTransform.h b/Modules/Core/Transform/include/otbTransform.h index 41e90ac5ec..17dd9e92e0 100644 --- a/Modules/Core/Transform/include/otbTransform.h +++ b/Modules/Core/Transform/include/otbTransform.h @@ -58,10 +58,10 @@ public: itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions); /** Get the size of the input space */ - unsigned int GetInputSpaceDimension(void) const ITK_OVERRIDE { return NInputDimensions; } + unsigned int GetInputSpaceDimension(void) const override { return NInputDimensions; } /** Get the size of the output space */ - unsigned int GetOutputSpaceDimension(void) const ITK_OVERRIDE { return NOutputDimensions; } + unsigned int GetOutputSpaceDimension(void) const override { return NOutputDimensions; } /** Type of the scalar representing coordinate and vector elements. */ typedef TScalarType ScalarType; @@ -98,12 +98,12 @@ public: /** Method to transform a point. */ - OutputPointType TransformPoint(const InputPointType & ) const ITK_OVERRIDE + OutputPointType TransformPoint(const InputPointType & ) const override { return OutputPointType(); } using Superclass::TransformVector; /** Method to transform a vector. */ - OutputVectorType TransformVector(const InputVectorType &) const ITK_OVERRIDE + OutputVectorType TransformVector(const InputVectorType &) const override { return OutputVectorType(); } /** Method to transform a vnl_vector. */ @@ -113,7 +113,7 @@ public: using Superclass::TransformCovariantVector; /** Method to transform a CovariantVector. */ OutputCovariantVectorType TransformCovariantVector( - const InputCovariantVectorType &) const ITK_OVERRIDE + const InputCovariantVectorType &) const override { return OutputCovariantVectorType(); } @@ -124,12 +124,12 @@ public: * SetParametersByValue. * \sa SetParametersByValue */ - void SetParameters( const ParametersType & ) ITK_OVERRIDE - { itkExceptionMacro( << "Subclasses should ITK_OVERRIDE this method (SetParameters)" ) } + void SetParameters( const ParametersType & ) override + { itkExceptionMacro( << "Subclasses should override this method (SetParameters)" ) } - void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType& ) const ITK_OVERRIDE + void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType& ) const override { - itkExceptionMacro(<< "Subclasses should ITK_OVERRIDE this method (ComputeJacobianWithRespectToParameters)" ); + itkExceptionMacro(<< "Subclasses should override this method (ComputeJacobianWithRespectToParameters)" ); } /** Set the transformation parameters and update internal transformation. @@ -139,23 +139,23 @@ public: * by keeping a reference to the parameters. * \sa SetParameters */ - void SetParametersByValue(const ParametersType & p) ITK_OVERRIDE + void SetParametersByValue(const ParametersType & p) override { this->SetParameters (p); } /** Get the Transformation Parameters. */ - const ParametersType & GetParameters(void) const ITK_OVERRIDE + const ParametersType & GetParameters(void) const override { return m_Parameters; } /** Set the fixed parameters and update internal transformation. */ - void SetFixedParameters( const ParametersType & ) ITK_OVERRIDE - { itkExceptionMacro( << "Subclasses should ITK_OVERRIDE this method (SetFixedParameters)" ) } + void SetFixedParameters( const ParametersType & ) override + { itkExceptionMacro( << "Subclasses should override this method (SetFixedParameters)" ) } /** Get the Fixed Parameters. */ - const ParametersType& GetFixedParameters(void) const ITK_OVERRIDE + const ParametersType& GetFixedParameters(void) const override { - itkExceptionMacro( << "Subclasses should ITK_OVERRIDE this method (GetFixedParameters)" ); + itkExceptionMacro( << "Subclasses should override this method (GetFixedParameters)" ); // Next line is needed to avoid errors due to: // "function must return a value". return this->m_FixedParameters; @@ -190,14 +190,14 @@ public: * */ virtual const JacobianType & GetJacobian(const InputPointType &) const { - itkExceptionMacro( << "Subclass should ITK_OVERRIDE this method (GetJacobian)" ); + itkExceptionMacro( << "Subclass should override this method (GetJacobian)" ); // Next line is needed to avoid errors due to: // "function must return a value" . return this->m_Jacobian; } /** Return the number of parameters that completely define the Transfom */ - NumberOfParametersType GetNumberOfParameters(void) const ITK_OVERRIDE + NumberOfParametersType GetNumberOfParameters(void) const override { return this->m_Parameters.Size(); } protected: @@ -208,9 +208,9 @@ protected: : Superclass::Transform(numberOfParameters) {} - ~Transform() ITK_OVERRIDE {} + ~Transform() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); #if 0 diff --git a/Modules/Core/VectorDataBase/include/otbDataNode.h b/Modules/Core/VectorDataBase/include/otbDataNode.h index b1669467fc..f3752c8c88 100644 --- a/Modules/Core/VectorDataBase/include/otbDataNode.h +++ b/Modules/Core/VectorDataBase/include/otbDataNode.h @@ -290,9 +290,9 @@ protected: /** Constructor */ DataNode(); /** Destructor */ - ~DataNode() ITK_OVERRIDE {} + ~DataNode() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; OGRGeometry* ConvertDataNodeToOGRGeometry(const DataNode* dataNode); diff --git a/Modules/Core/VectorDataBase/include/otbDataNodeFunctionBase.h b/Modules/Core/VectorDataBase/include/otbDataNodeFunctionBase.h index b3264ded63..33016b73da 100644 --- a/Modules/Core/VectorDataBase/include/otbDataNodeFunctionBase.h +++ b/Modules/Core/VectorDataBase/include/otbDataNodeFunctionBase.h @@ -32,7 +32,7 @@ namespace otb * the abstract method Evaluate() maps a DataNode from the input space to a element * in the output space. * - * Subclasses must ITK_OVERRIDE Evaluate(). + * Subclasses must override Evaluate(). * * This class is template over the input DataNode type and * the output (range) type. @@ -66,11 +66,11 @@ public: typedef TOutput OutputType; /** Evaluate at the specified input position */ - OutputType Evaluate( const DataNodeType& node ) const ITK_OVERRIDE = 0; + OutputType Evaluate( const DataNodeType& node ) const override = 0; protected: DataNodeFunctionBase(){}; - ~DataNodeFunctionBase() ITK_OVERRIDE{}; + ~DataNodeFunctionBase() override{}; private: DataNodeFunctionBase(const Self& ); //purposely not implemented diff --git a/Modules/Core/VectorDataBase/include/otbDataNodeImageFunction.h b/Modules/Core/VectorDataBase/include/otbDataNodeImageFunction.h index ece3dc41b8..5f389b35b6 100644 --- a/Modules/Core/VectorDataBase/include/otbDataNodeImageFunction.h +++ b/Modules/Core/VectorDataBase/include/otbDataNodeImageFunction.h @@ -107,7 +107,7 @@ public: /** Evaluate the function at specified DataNode position. * Subclasses must provide this method. */ - TOutput Evaluate( const DataNodeType& node ) const ITK_OVERRIDE = 0; + TOutput Evaluate( const DataNodeType& node ) const override = 0; /** Check if an index is inside the image buffer. * we take into account the fact that each voxel has its @@ -186,8 +186,8 @@ public: protected: DataNodeImageFunction(); - ~DataNodeImageFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~DataNodeImageFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Const pointer to the input image. */ InputImageConstPointer m_Image; diff --git a/Modules/Core/VectorDataBase/include/otbDataNodeVectorDataFunction.h b/Modules/Core/VectorDataBase/include/otbDataNodeVectorDataFunction.h index 7adb0b06ad..798dd99dbe 100644 --- a/Modules/Core/VectorDataBase/include/otbDataNodeVectorDataFunction.h +++ b/Modules/Core/VectorDataBase/include/otbDataNodeVectorDataFunction.h @@ -88,12 +88,12 @@ public: /** Evaluate the function at specified DataNode position. * Subclasses must provide this method. */ - TOutput Evaluate( const DataNodeType& node ) const ITK_OVERRIDE = 0; + TOutput Evaluate( const DataNodeType& node ) const override = 0; protected: DataNodeVectorDataFunction(); - ~DataNodeVectorDataFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~DataNodeVectorDataFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Const pointer to the input VectorData. */ VectorDataConstPointerType m_VectorData; diff --git a/Modules/Core/VectorDataBase/include/otbPolyLineParametricPathWithValue.h b/Modules/Core/VectorDataBase/include/otbPolyLineParametricPathWithValue.h index a6ff72468a..1a54429a79 100644 --- a/Modules/Core/VectorDataBase/include/otbPolyLineParametricPathWithValue.h +++ b/Modules/Core/VectorDataBase/include/otbPolyLineParametricPathWithValue.h @@ -117,13 +117,13 @@ protected: /** Constructor */ PolyLineParametricPathWithValue(); /** Destructor */ - ~PolyLineParametricPathWithValue() ITK_OVERRIDE {} + ~PolyLineParametricPathWithValue() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; virtual void ComputeLength() const; virtual void ComputeBoundingRegion() const; - void Modified() const ITK_OVERRIDE; + void Modified() const override; private: PolyLineParametricPathWithValue(const Self &); //purposely not implemented diff --git a/Modules/Core/VectorDataBase/include/otbPolygon.h b/Modules/Core/VectorDataBase/include/otbPolygon.h index a85c8a138a..1d7cd20fae 100644 --- a/Modules/Core/VectorDataBase/include/otbPolygon.h +++ b/Modules/Core/VectorDataBase/include/otbPolygon.h @@ -126,9 +126,9 @@ public: * Return the polygon length (perimeter). * \return The length. */ - double GetLength() const ITK_OVERRIDE; + double GetLength() const override; - void AddVertex(const ContinuousIndexType& vertex) ITK_OVERRIDE; + void AddVertex(const ContinuousIndexType& vertex) override; protected: /** Constructor */ @@ -140,13 +140,13 @@ protected: }; /** Destructor */ - ~Polygon() ITK_OVERRIDE {} + ~Polygon() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; virtual void ComputeArea() const; - void Modified() const ITK_OVERRIDE; + void Modified() const override; private: Polygon(const Self &); //purposely not implemented diff --git a/Modules/Core/VectorDataBase/include/otbVectorData.h b/Modules/Core/VectorDataBase/include/otbVectorData.h index 0a1b8968e0..75c1f0bee4 100644 --- a/Modules/Core/VectorDataBase/include/otbVectorData.h +++ b/Modules/Core/VectorDataBase/include/otbVectorData.h @@ -129,15 +129,15 @@ public: * SmartPointers to the same VectorData since separate DataObjects are * still maintained. This method is similar to * VectorDataSource::GraftOutput(). */ - void Graft(const itk::DataObject *data) ITK_OVERRIDE; + void Graft(const itk::DataObject *data) override; protected: /** Constructor */ VectorData(); /** Destructor */ - ~VectorData() ITK_OVERRIDE {} + ~VectorData() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: VectorData(const Self&); //purposely not implemented diff --git a/Modules/Core/VectorDataBase/include/otbVectorDataIOBase.h b/Modules/Core/VectorDataBase/include/otbVectorDataIOBase.h index de1e241fc2..fac29ae71b 100644 --- a/Modules/Core/VectorDataBase/include/otbVectorDataIOBase.h +++ b/Modules/Core/VectorDataBase/include/otbVectorDataIOBase.h @@ -153,9 +153,9 @@ public: protected: VectorDataIOBase(); - ~VectorDataIOBase() ITK_OVERRIDE; + ~VectorDataIOBase() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Big or Little Endian, and the type of the file. (May be ignored.) */ ByteOrder m_ByteOrder; diff --git a/Modules/Core/VectorDataBase/include/otbVectorDataProperties.h b/Modules/Core/VectorDataBase/include/otbVectorDataProperties.h index f1e8633b23..59f22cca0e 100644 --- a/Modules/Core/VectorDataBase/include/otbVectorDataProperties.h +++ b/Modules/Core/VectorDataBase/include/otbVectorDataProperties.h @@ -86,9 +86,9 @@ protected: /** Constructor */ VectorDataProperties() : m_VectorDataObject(ITK_NULLPTR) {}; /** Destructor */ - ~VectorDataProperties() ITK_OVERRIDE {} + ~VectorDataProperties() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; void ProcessNode(InternalTreeNodeType * source); bool IsBoundingRegionNull(); diff --git a/Modules/Core/VectorDataBase/include/otbVectorDataSource.h b/Modules/Core/VectorDataBase/include/otbVectorDataSource.h index 7700768b4c..4031a0b466 100644 --- a/Modules/Core/VectorDataBase/include/otbVectorDataSource.h +++ b/Modules/Core/VectorDataBase/include/otbVectorDataSource.h @@ -83,9 +83,9 @@ public: protected: VectorDataSource(); - ~VectorDataSource() ITK_OVERRIDE; + ~VectorDataSource() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Ensure that the output vector data are cleared before processing */ virtual void AllocateOutputs(); diff --git a/Modules/Detection/CloudDetection/include/otbCloudDetectionFilter.h b/Modules/Detection/CloudDetection/include/otbCloudDetectionFilter.h index 51f432a1a4..024c296191 100644 --- a/Modules/Detection/CloudDetection/include/otbCloudDetectionFilter.h +++ b/Modules/Detection/CloudDetection/include/otbCloudDetectionFilter.h @@ -71,11 +71,11 @@ public: protected: CloudDetectionFilter(); - ~CloudDetectionFilter() ITK_OVERRIDE {} + ~CloudDetectionFilter() override {} - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: CloudDetectionFilter(const Self &); //purposely not implemented diff --git a/Modules/Detection/CloudDetection/include/otbCloudEstimatorFilter.h b/Modules/Detection/CloudDetection/include/otbCloudEstimatorFilter.h index 5f0d5eadc7..fc795bbf1f 100644 --- a/Modules/Detection/CloudDetection/include/otbCloudEstimatorFilter.h +++ b/Modules/Detection/CloudDetection/include/otbCloudEstimatorFilter.h @@ -73,11 +73,11 @@ public: protected: CloudEstimatorFilter(); - ~CloudEstimatorFilter() ITK_OVERRIDE {} + ~CloudEstimatorFilter() override {} - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: CloudEstimatorFilter(const Self &); //purposely not implemented diff --git a/Modules/Detection/ObjectDetection/include/otbDescriptorsListSampleGenerator.h b/Modules/Detection/ObjectDetection/include/otbDescriptorsListSampleGenerator.h index a7d582d848..3ab76e6b45 100644 --- a/Modules/Detection/ObjectDetection/include/otbDescriptorsListSampleGenerator.h +++ b/Modules/Detection/ObjectDetection/include/otbDescriptorsListSampleGenerator.h @@ -151,31 +151,31 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; - void AllocateOutputs() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; - void Reset(void) ITK_OVERRIDE; - void Synthetize(void) ITK_OVERRIDE; + void AllocateOutputs() override; + void GenerateOutputInformation() override; + void Reset(void) override; + void Synthetize(void) override; - void AddInput(itk::DataObject * dataObject) ITK_OVERRIDE + void AddInput(itk::DataObject * dataObject) override { Superclass::AddInput(dataObject); } protected: PersistentDescriptorsListSampleGenerator(); - ~PersistentDescriptorsListSampleGenerator() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PersistentDescriptorsListSampleGenerator() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Multi-thread version GenerateData. */ void ThreadedGenerateData(const RegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: PersistentDescriptorsListSampleGenerator(const Self &); //purposely not implemented @@ -303,7 +303,7 @@ public: return this->GetFilter()->GetInput(); } - void AddInput(itk::DataObject * dataObject) ITK_OVERRIDE + void AddInput(itk::DataObject * dataObject) override { this->GetFilter()->AddInput(dataObject); } @@ -363,7 +363,7 @@ public: DescriptorsListSampleGenerator(); /** Destructor */ - ~DescriptorsListSampleGenerator() ITK_OVERRIDE; + ~DescriptorsListSampleGenerator() override; private: DescriptorsListSampleGenerator(const Self &); //purposely not implemented diff --git a/Modules/Detection/ObjectDetection/include/otbFlusserMomentsIFFactory.h b/Modules/Detection/ObjectDetection/include/otbFlusserMomentsIFFactory.h index 8aff97fc81..46ff16f5af 100644 --- a/Modules/Detection/ObjectDetection/include/otbFlusserMomentsIFFactory.h +++ b/Modules/Detection/ObjectDetection/include/otbFlusserMomentsIFFactory.h @@ -82,8 +82,8 @@ public: protected: FlusserMomentsIFFactory(){} - ~FlusserMomentsIFFactory() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~FlusserMomentsIFFactory() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: FlusserMomentsIFFactory(const Self& ); //purposely not implemented diff --git a/Modules/Detection/ObjectDetection/include/otbFourierMellinDescriptorsIFFactory.h b/Modules/Detection/ObjectDetection/include/otbFourierMellinDescriptorsIFFactory.h index 36f7890b0c..4a55751a55 100644 --- a/Modules/Detection/ObjectDetection/include/otbFourierMellinDescriptorsIFFactory.h +++ b/Modules/Detection/ObjectDetection/include/otbFourierMellinDescriptorsIFFactory.h @@ -81,8 +81,8 @@ public: protected: FourierMellinDescriptorsIFFactory(){} - ~FourierMellinDescriptorsIFFactory() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~FourierMellinDescriptorsIFFactory() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: FourierMellinDescriptorsIFFactory(const Self& ); //purposely not implemented diff --git a/Modules/Detection/ObjectDetection/include/otbHaralickTexturesIFFactory.h b/Modules/Detection/ObjectDetection/include/otbHaralickTexturesIFFactory.h index 570ba05b99..1169695ab1 100644 --- a/Modules/Detection/ObjectDetection/include/otbHaralickTexturesIFFactory.h +++ b/Modules/Detection/ObjectDetection/include/otbHaralickTexturesIFFactory.h @@ -83,8 +83,8 @@ public: protected: HaralickTexturesIFFactory(){} - ~HaralickTexturesIFFactory() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~HaralickTexturesIFFactory() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: HaralickTexturesIFFactory(const Self& ); //purposely not implemented diff --git a/Modules/Detection/ObjectDetection/include/otbLabeledSampleLocalizationGenerator.h b/Modules/Detection/ObjectDetection/include/otbLabeledSampleLocalizationGenerator.h index a0d118d046..75d2d09a9c 100644 --- a/Modules/Detection/ObjectDetection/include/otbLabeledSampleLocalizationGenerator.h +++ b/Modules/Detection/ObjectDetection/include/otbLabeledSampleLocalizationGenerator.h @@ -116,11 +116,11 @@ public: protected: LabeledSampleLocalizationGenerator(); - ~LabeledSampleLocalizationGenerator() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LabeledSampleLocalizationGenerator() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Triggers the Computation of the sample list */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; PointVectorType RandomPointsGenerator(DataNodeType * node); diff --git a/Modules/Detection/ObjectDetection/include/otbLocalHistogramIFFactory.h b/Modules/Detection/ObjectDetection/include/otbLocalHistogramIFFactory.h index f52cc96fb7..2ff4b90c98 100644 --- a/Modules/Detection/ObjectDetection/include/otbLocalHistogramIFFactory.h +++ b/Modules/Detection/ObjectDetection/include/otbLocalHistogramIFFactory.h @@ -82,8 +82,8 @@ public: protected: LocalHistogramIFFactory(){} - ~LocalHistogramIFFactory() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LocalHistogramIFFactory() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LocalHistogramIFFactory(const Self& ); //purposely not implemented diff --git a/Modules/Detection/ObjectDetection/include/otbObjectDetectionClassifier.h b/Modules/Detection/ObjectDetection/include/otbObjectDetectionClassifier.h index c051b33997..276062f0f0 100644 --- a/Modules/Detection/ObjectDetection/include/otbObjectDetectionClassifier.h +++ b/Modules/Detection/ObjectDetection/include/otbObjectDetectionClassifier.h @@ -123,7 +123,7 @@ public: typedef itk::Statistics::ListSample<DescriptorType> ListSampleType; - void AddInput(itk::DataObject * dataObject) ITK_OVERRIDE + void AddInput(itk::DataObject * dataObject) override { this->Superclass::AddInput(dataObject); } @@ -161,29 +161,29 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; - void AllocateOutputs() ITK_OVERRIDE; + void AllocateOutputs() override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void Reset(void) ITK_OVERRIDE; + void Reset(void) override; - void Synthetize(void) ITK_OVERRIDE; + void Synthetize(void) override; protected: PersistentObjectDetectionClassifier(); - ~PersistentObjectDetectionClassifier() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PersistentObjectDetectionClassifier() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Multi-thread version GenerateData. */ void ThreadedGenerateData(const RegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: PersistentObjectDetectionClassifier(const Self &); //purposely not implemented @@ -319,7 +319,7 @@ public: return this->GetFilter()->GetOutputVectorData(); } - void AddInput(itk::DataObject * dataObject) ITK_OVERRIDE + void AddInput(itk::DataObject * dataObject) override { this->GetFilter()->AddInput(dataObject); } @@ -377,7 +377,7 @@ public: ObjectDetectionClassifier(); /** Destructor */ - ~ObjectDetectionClassifier() ITK_OVERRIDE; + ~ObjectDetectionClassifier() override; private: ObjectDetectionClassifier(const Self &); //purposely not implemented diff --git a/Modules/Detection/ObjectDetection/include/otbRadiometricMomentsIFFactory.h b/Modules/Detection/ObjectDetection/include/otbRadiometricMomentsIFFactory.h index 6d642ec504..9d971e97b2 100644 --- a/Modules/Detection/ObjectDetection/include/otbRadiometricMomentsIFFactory.h +++ b/Modules/Detection/ObjectDetection/include/otbRadiometricMomentsIFFactory.h @@ -82,8 +82,8 @@ public: protected: RadiometricMomentsIFFactory(){} - ~RadiometricMomentsIFFactory() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~RadiometricMomentsIFFactory() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: RadiometricMomentsIFFactory(const Self& ); //purposely not implemented diff --git a/Modules/Detection/ObjectDetection/include/otbStandardMetaImageFunctionBuilder.h b/Modules/Detection/ObjectDetection/include/otbStandardMetaImageFunctionBuilder.h index eb747ff5a7..3d03e06d99 100644 --- a/Modules/Detection/ObjectDetection/include/otbStandardMetaImageFunctionBuilder.h +++ b/Modules/Detection/ObjectDetection/include/otbStandardMetaImageFunctionBuilder.h @@ -170,8 +170,8 @@ public: protected: StandardMetaImageFunctionBuilder(); - ~StandardMetaImageFunctionBuilder() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~StandardMetaImageFunctionBuilder() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: StandardMetaImageFunctionBuilder(const Self& ); //purposely not implemented diff --git a/Modules/Detection/RoadExtraction/include/otbBreakAngularPathListFilter.h b/Modules/Detection/RoadExtraction/include/otbBreakAngularPathListFilter.h index 2b75f86699..6781f42e64 100644 --- a/Modules/Detection/RoadExtraction/include/otbBreakAngularPathListFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbBreakAngularPathListFilter.h @@ -67,11 +67,11 @@ protected: /** Constructor */ BreakAngularPathListFilter(); /** Destructor */ - ~BreakAngularPathListFilter() ITK_OVERRIDE {} + ~BreakAngularPathListFilter() override {} /** GenerateData method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: BreakAngularPathListFilter(const Self &); //purposely not implemented diff --git a/Modules/Detection/RoadExtraction/include/otbGenericRoadExtractionFilter.h b/Modules/Detection/RoadExtraction/include/otbGenericRoadExtractionFilter.h index e016246411..e3680973f1 100644 --- a/Modules/Detection/RoadExtraction/include/otbGenericRoadExtractionFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbGenericRoadExtractionFilter.h @@ -189,7 +189,7 @@ protected: /** Constructor */ GenericRoadExtractionFilter(); /** Destructor */ - ~GenericRoadExtractionFilter() ITK_OVERRIDE {} + ~GenericRoadExtractionFilter() override {} /** Prepare main computation method * Note : this function isn't called @@ -197,9 +197,9 @@ protected: void BeforeGenerateData(void); /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Detection/RoadExtraction/include/otbImageToPathListAlignFilter.h b/Modules/Detection/RoadExtraction/include/otbImageToPathListAlignFilter.h index 5002375fe4..a6dd5526b4 100644 --- a/Modules/Detection/RoadExtraction/include/otbImageToPathListAlignFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbImageToPathListAlignFilter.h @@ -121,10 +121,10 @@ public: protected: ImageToPathListAlignFilter(); - ~ImageToPathListAlignFilter() ITK_OVERRIDE; + ~ImageToPathListAlignFilter() override; - void GenerateOutputInformation() ITK_OVERRIDE {} // do nothing - void GenerateData() ITK_OVERRIDE; + void GenerateOutputInformation() override {} // do nothing + void GenerateData() override; virtual std::vector<double> tab(int n, double p, double m); virtual void AngleCalculate(const InputImageType* InputImageIn); @@ -134,7 +134,7 @@ protected: ValueType m_PathValue; ValueType m_BackgroundValue; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageToPathListAlignFilter(const Self &); //purposely not implemented diff --git a/Modules/Detection/RoadExtraction/include/otbLikelihoodPathListFilter.h b/Modules/Detection/RoadExtraction/include/otbLikelihoodPathListFilter.h index 85f0a3109d..9d34f04ff7 100644 --- a/Modules/Detection/RoadExtraction/include/otbLikelihoodPathListFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbLikelihoodPathListFilter.h @@ -85,11 +85,11 @@ protected: /** Constructor */ LikelihoodPathListFilter(); /** Destructor */ - ~LikelihoodPathListFilter() ITK_OVERRIDE {} + ~LikelihoodPathListFilter() override {} /** GenerateData method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LikelihoodPathListFilter(const Self &); //purposely not implemented diff --git a/Modules/Detection/RoadExtraction/include/otbLinkPathListFilter.h b/Modules/Detection/RoadExtraction/include/otbLinkPathListFilter.h index 772ec632f3..e5ab1942d4 100644 --- a/Modules/Detection/RoadExtraction/include/otbLinkPathListFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbLinkPathListFilter.h @@ -84,11 +84,11 @@ protected: /** Constructor */ LinkPathListFilter(); /** Destructor */ - ~LinkPathListFilter() ITK_OVERRIDE {} + ~LinkPathListFilter() override {} /** GenerateData method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Verify the angular condition to link a path. diff --git a/Modules/Detection/RoadExtraction/include/otbModulusAndDirectionImageToImageFilter.h b/Modules/Detection/RoadExtraction/include/otbModulusAndDirectionImageToImageFilter.h index 22f4468f82..83e8345b9b 100644 --- a/Modules/Detection/RoadExtraction/include/otbModulusAndDirectionImageToImageFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbModulusAndDirectionImageToImageFilter.h @@ -70,15 +70,15 @@ public: /** Set/Get the image input of this process object. */ using Superclass::SetInput; - void SetInput(const InputImageType *input) ITK_OVERRIDE; + void SetInput(const InputImageType *input) override; virtual void SetInputDirection(const InputImageDirectionType *direction); const InputImageType * GetInput(void); const InputImageDirectionType * GetInputDirection(void); protected: ModulusAndDirectionImageToImageFilter(); - ~ModulusAndDirectionImageToImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ModulusAndDirectionImageToImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ModulusAndDirectionImageToImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Detection/RoadExtraction/include/otbNeighborhoodScalarProductFilter.h b/Modules/Detection/RoadExtraction/include/otbNeighborhoodScalarProductFilter.h index 2a7ec8dd62..6e24abebee 100644 --- a/Modules/Detection/RoadExtraction/include/otbNeighborhoodScalarProductFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbNeighborhoodScalarProductFilter.h @@ -84,9 +84,9 @@ protected: /** Constructor */ NeighborhoodScalarProductFilter(); /** Destructor */ - ~NeighborhoodScalarProductFilter() ITK_OVERRIDE {} + ~NeighborhoodScalarProductFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** NeighborhoodScalarProductImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine * which is called for each processing thread. The output image data is @@ -98,7 +98,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: NeighborhoodScalarProductFilter(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented diff --git a/Modules/Detection/RoadExtraction/include/otbNonMaxRemovalByDirectionFilter.h b/Modules/Detection/RoadExtraction/include/otbNonMaxRemovalByDirectionFilter.h index e428d28601..fb60b080f3 100644 --- a/Modules/Detection/RoadExtraction/include/otbNonMaxRemovalByDirectionFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbNonMaxRemovalByDirectionFilter.h @@ -136,14 +136,14 @@ protected: /** Constructor */ NonMaxRemovalByDirectionFilter() {}; /** Destructor */ - ~NonMaxRemovalByDirectionFilter() ITK_OVERRIDE {} + ~NonMaxRemovalByDirectionFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE + void GenerateData(void) override { typename ComputingFilterType::Pointer filter = ComputingFilterType::New(); filter->SetInput1(this->GetInput()); diff --git a/Modules/Detection/RoadExtraction/include/otbParallelLinePathListFilter.h b/Modules/Detection/RoadExtraction/include/otbParallelLinePathListFilter.h index d39d37eee1..ff27709602 100644 --- a/Modules/Detection/RoadExtraction/include/otbParallelLinePathListFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbParallelLinePathListFilter.h @@ -90,11 +90,11 @@ protected: /** Constructor */ ParallelLinePathListFilter(); /** Destructor */ - ~ParallelLinePathListFilter() ITK_OVERRIDE {} + ~ParallelLinePathListFilter() override {} /** GenerateData method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Verify the angular condition to find parallel lines. diff --git a/Modules/Detection/RoadExtraction/include/otbRemoveIsolatedByDirectionFilter.h b/Modules/Detection/RoadExtraction/include/otbRemoveIsolatedByDirectionFilter.h index d937c7108d..ca4a40efdd 100644 --- a/Modules/Detection/RoadExtraction/include/otbRemoveIsolatedByDirectionFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbRemoveIsolatedByDirectionFilter.h @@ -109,14 +109,14 @@ protected: /** Constructor */ RemoveIsolatedByDirectionFilter() {}; /** Destructor */ - ~RemoveIsolatedByDirectionFilter() ITK_OVERRIDE {} + ~RemoveIsolatedByDirectionFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE + void GenerateData(void) override { typename ComputingFilterType::Pointer filter = ComputingFilterType::New(); filter->SetInput1(this->GetInput()); diff --git a/Modules/Detection/RoadExtraction/include/otbRemoveWrongDirectionFilter.h b/Modules/Detection/RoadExtraction/include/otbRemoveWrongDirectionFilter.h index 4733c42fa4..8812c85fa2 100644 --- a/Modules/Detection/RoadExtraction/include/otbRemoveWrongDirectionFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbRemoveWrongDirectionFilter.h @@ -104,14 +104,14 @@ protected: /** Constructor */ RemoveWrongDirectionFilter() {}; /** Destructor */ - ~RemoveWrongDirectionFilter() ITK_OVERRIDE {} + ~RemoveWrongDirectionFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE + void GenerateData(void) override { typename ComputingFilterType::Pointer filter = ComputingFilterType::New(); filter->SetInput1(this->GetInput()); diff --git a/Modules/Detection/RoadExtraction/include/otbRoadExtractionFilter.h b/Modules/Detection/RoadExtraction/include/otbRoadExtractionFilter.h index d58dd5166c..79e05822d3 100644 --- a/Modules/Detection/RoadExtraction/include/otbRoadExtractionFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbRoadExtractionFilter.h @@ -141,15 +141,15 @@ protected: /** Constructor */ RoadExtractionFilter(); /** Destructor */ - ~RoadExtractionFilter() ITK_OVERRIDE {} + ~RoadExtractionFilter() override {} /** Prepare main computation method */ void BeforeGenerateData(void); /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Detection/RoadExtraction/include/otbVectorDataToRoadDescriptionFilter.h b/Modules/Detection/RoadExtraction/include/otbVectorDataToRoadDescriptionFilter.h index ab759a79ba..48744453c0 100644 --- a/Modules/Detection/RoadExtraction/include/otbVectorDataToRoadDescriptionFilter.h +++ b/Modules/Detection/RoadExtraction/include/otbVectorDataToRoadDescriptionFilter.h @@ -116,11 +116,11 @@ protected: /** Constructor */ VectorDataToRoadDescriptionFilter(); /** Destructor */ - ~VectorDataToRoadDescriptionFilter() ITK_OVERRIDE {} + ~VectorDataToRoadDescriptionFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Triggers the Computation of the Descriptors */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; private: VectorDataToRoadDescriptionFilter(const Self &); //purposely not implemented diff --git a/Modules/Detection/UrbanArea/include/otbUrbanAreaDetectionImageFilter.h b/Modules/Detection/UrbanArea/include/otbUrbanAreaDetectionImageFilter.h index a5b50ddf10..f8c133af97 100644 --- a/Modules/Detection/UrbanArea/include/otbUrbanAreaDetectionImageFilter.h +++ b/Modules/Detection/UrbanArea/include/otbUrbanAreaDetectionImageFilter.h @@ -232,11 +232,11 @@ public: itkSetMacro(SobelUpperThreshold, double); /** Methods */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; protected: UrbanAreaDetectionImageFilter(); - ~UrbanAreaDetectionImageFilter() ITK_OVERRIDE{} + ~UrbanAreaDetectionImageFilter() override{} private: UrbanAreaDetectionImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Corner/include/otbHarrisImageFilter.h b/Modules/Feature/Corner/include/otbHarrisImageFilter.h index 38aadf4acf..f784a3159a 100644 --- a/Modules/Feature/Corner/include/otbHarrisImageFilter.h +++ b/Modules/Feature/Corner/include/otbHarrisImageFilter.h @@ -104,11 +104,11 @@ public: protected: HarrisImageFilter(); - ~HarrisImageFilter() ITK_OVERRIDE {} + ~HarrisImageFilter() override {} - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: HarrisImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Feature/Corner/include/otbHarrisImageToPointSetFilter.h b/Modules/Feature/Corner/include/otbHarrisImageToPointSetFilter.h index 8069c053c0..badc48a0d1 100644 --- a/Modules/Feature/Corner/include/otbHarrisImageToPointSetFilter.h +++ b/Modules/Feature/Corner/include/otbHarrisImageToPointSetFilter.h @@ -78,11 +78,11 @@ public: protected: HarrisImageToPointSetFilter(); - ~HarrisImageToPointSetFilter() ITK_OVERRIDE {} + ~HarrisImageToPointSetFilter() override {} - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: HarrisImageToPointSetFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Corner/include/otbLineSpatialObjectListToRightAnglePointSetFilter.h b/Modules/Feature/Corner/include/otbLineSpatialObjectListToRightAnglePointSetFilter.h index 8726c3009f..68c594ec0b 100644 --- a/Modules/Feature/Corner/include/otbLineSpatialObjectListToRightAnglePointSetFilter.h +++ b/Modules/Feature/Corner/include/otbLineSpatialObjectListToRightAnglePointSetFilter.h @@ -104,7 +104,7 @@ protected: * */ - void GenerateOutputInformation() ITK_OVERRIDE{} + void GenerateOutputInformation() override{} /** * Constructor. @@ -113,15 +113,15 @@ protected: /** * Destructor. */ - ~LineSpatialObjectListToRightAnglePointSetFilter() ITK_OVERRIDE{} + ~LineSpatialObjectListToRightAnglePointSetFilter() override{} /** * Standard PrintSelf method. */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Main computation method. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** * Angle computation */ diff --git a/Modules/Feature/Corner/include/otbVectorDataToRightAngleVectorDataFilter.h b/Modules/Feature/Corner/include/otbVectorDataToRightAngleVectorDataFilter.h index c034f2315c..a2c985fc20 100644 --- a/Modules/Feature/Corner/include/otbVectorDataToRightAngleVectorDataFilter.h +++ b/Modules/Feature/Corner/include/otbVectorDataToRightAngleVectorDataFilter.h @@ -87,11 +87,11 @@ protected: /** Constructor.*/ VectorDataToRightAngleVectorDataFilter(); /**Destructor.*/ - ~VectorDataToRightAngleVectorDataFilter() ITK_OVERRIDE{} + ~VectorDataToRightAngleVectorDataFilter() override{} /** Standard PrintSelf method.*/ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /**Main computation method.*/ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /**Angle computation.*/ virtual double ComputeAngleFormedBySegments(LineType * lineDst, LineType * lineSrc); /** When we find a right angle, one compute the coordinate of the segments intersection.*/ diff --git a/Modules/Feature/Density/include/otbKeyPointDensityImageFilter.h b/Modules/Feature/Density/include/otbKeyPointDensityImageFilter.h index ad33f74572..2944414abd 100644 --- a/Modules/Feature/Density/include/otbKeyPointDensityImageFilter.h +++ b/Modules/Feature/Density/include/otbKeyPointDensityImageFilter.h @@ -99,16 +99,16 @@ protected: /** * Destructor. */ - ~KeyPointDensityImageFilter() ITK_OVERRIDE; + ~KeyPointDensityImageFilter() override; /** * Standard PrintSelf method. */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Main computation method. */ //virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ); - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: diff --git a/Modules/Feature/Density/include/otbPointSetDensityEpanechnikovFunction.h b/Modules/Feature/Density/include/otbPointSetDensityEpanechnikovFunction.h index ade7a2bace..6abb4fc1c0 100644 --- a/Modules/Feature/Density/include/otbPointSetDensityEpanechnikovFunction.h +++ b/Modules/Feature/Density/include/otbPointSetDensityEpanechnikovFunction.h @@ -65,13 +65,13 @@ public: itkGetMacro(Radius, unsigned int); /** Evaluate Method */ - OutputType Evaluate(const InputType& input) const ITK_OVERRIDE; + OutputType Evaluate(const InputType& input) const override; protected: PointSetDensityEpanechnikovFunction() : m_Radius(1) {}; - ~PointSetDensityEpanechnikovFunction() ITK_OVERRIDE {} + ~PointSetDensityEpanechnikovFunction() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: PointSetDensityEpanechnikovFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Density/include/otbPointSetDensityFunction.h b/Modules/Feature/Density/include/otbPointSetDensityFunction.h index 622e28ff19..fc1d0ccff4 100644 --- a/Modules/Feature/Density/include/otbPointSetDensityFunction.h +++ b/Modules/Feature/Density/include/otbPointSetDensityFunction.h @@ -64,13 +64,13 @@ public: itkGetMacro(Radius, unsigned int); /** Evaluate Method */ - OutputType Evaluate(const InputType& input) const ITK_OVERRIDE; + OutputType Evaluate(const InputType& input) const override; protected: PointSetDensityFunction() : m_Radius(1) {}; - ~PointSetDensityFunction() ITK_OVERRIDE {} + ~PointSetDensityFunction() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: PointSetDensityFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Density/include/otbPointSetDensityGaussianFunction.h b/Modules/Feature/Density/include/otbPointSetDensityGaussianFunction.h index 56955afdf7..44fadcfc97 100644 --- a/Modules/Feature/Density/include/otbPointSetDensityGaussianFunction.h +++ b/Modules/Feature/Density/include/otbPointSetDensityGaussianFunction.h @@ -65,13 +65,13 @@ public: itkGetMacro(Radius, unsigned int); /** Evaluate Method */ - OutputType Evaluate(const InputType& input) const ITK_OVERRIDE; + OutputType Evaluate(const InputType& input) const override; protected: PointSetDensityGaussianFunction() : m_Radius(1) {}; - ~PointSetDensityGaussianFunction() ITK_OVERRIDE {} + ~PointSetDensityGaussianFunction() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: PointSetDensityGaussianFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Density/include/otbPointSetToDensityImageFilter.h b/Modules/Feature/Density/include/otbPointSetToDensityImageFilter.h index a68b729dad..47f61fe050 100644 --- a/Modules/Feature/Density/include/otbPointSetToDensityImageFilter.h +++ b/Modules/Feature/Density/include/otbPointSetToDensityImageFilter.h @@ -82,27 +82,27 @@ protected: /** * Destructor. */ - ~PointSetToDensityImageFilter() ITK_OVERRIDE {} + ~PointSetToDensityImageFilter() override {} /** * Standard PrintSelf method. */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Call the ImageSource::GenerateData which handle multithreading */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** * Main computation method. */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; /** * Main computation method. */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: diff --git a/Modules/Feature/Descriptors/include/otbForwardFourierMellinTransformImageFilter.h b/Modules/Feature/Descriptors/include/otbForwardFourierMellinTransformImageFilter.h index de10e1cf11..56fa10d27f 100644 --- a/Modules/Feature/Descriptors/include/otbForwardFourierMellinTransformImageFilter.h +++ b/Modules/Feature/Descriptors/include/otbForwardFourierMellinTransformImageFilter.h @@ -129,15 +129,15 @@ public: protected: ForwardFourierMellinTransformImageFilter(); - ~ForwardFourierMellinTransformImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ForwardFourierMellinTransformImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** Main Computation Method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: ForwardFourierMellinTransformImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Descriptors/include/otbFourierMellinDescriptorsImageFunction.h b/Modules/Feature/Descriptors/include/otbFourierMellinDescriptorsImageFunction.h index b2e6864a13..9eac6eeebc 100644 --- a/Modules/Feature/Descriptors/include/otbFourierMellinDescriptorsImageFunction.h +++ b/Modules/Feature/Descriptors/include/otbFourierMellinDescriptorsImageFunction.h @@ -101,17 +101,17 @@ public: InputImageType::ImageDimension); /** Evalulate the function at specified index */ - OutputType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PointType& point) const ITK_OVERRIDE + OutputType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } OutputType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -131,8 +131,8 @@ public: protected: FourierMellinDescriptorsImageFunction(); - ~FourierMellinDescriptorsImageFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~FourierMellinDescriptorsImageFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: FourierMellinDescriptorsImageFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Descriptors/include/otbHessianToScalarImageFilter.h b/Modules/Feature/Descriptors/include/otbHessianToScalarImageFilter.h index 04e0d2bdcd..67a5ca55c6 100644 --- a/Modules/Feature/Descriptors/include/otbHessianToScalarImageFilter.h +++ b/Modules/Feature/Descriptors/include/otbHessianToScalarImageFilter.h @@ -107,7 +107,7 @@ public: } protected: HessianToScalarImageFilter() {} - ~HessianToScalarImageFilter() ITK_OVERRIDE {} + ~HessianToScalarImageFilter() override {} private: HessianToScalarImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Descriptors/include/otbHistogramOfOrientedGradientCovariantImageFunction.h b/Modules/Feature/Descriptors/include/otbHistogramOfOrientedGradientCovariantImageFunction.h index 6a464dd648..930982a8ab 100644 --- a/Modules/Feature/Descriptors/include/otbHistogramOfOrientedGradientCovariantImageFunction.h +++ b/Modules/Feature/Descriptors/include/otbHistogramOfOrientedGradientCovariantImageFunction.h @@ -103,17 +103,17 @@ public: InputImageType::ImageDimension); /** Evalulate the function at specified index */ - OutputType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PointType& point) const ITK_OVERRIDE + OutputType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } OutputType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -134,8 +134,8 @@ public: protected: HistogramOfOrientedGradientCovariantImageFunction(); - ~HistogramOfOrientedGradientCovariantImageFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~HistogramOfOrientedGradientCovariantImageFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: HistogramOfOrientedGradientCovariantImageFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Descriptors/include/otbImageToHessianDeterminantImageFilter.h b/Modules/Feature/Descriptors/include/otbImageToHessianDeterminantImageFilter.h index 7466591cdf..009f709194 100644 --- a/Modules/Feature/Descriptors/include/otbImageToHessianDeterminantImageFilter.h +++ b/Modules/Feature/Descriptors/include/otbImageToHessianDeterminantImageFilter.h @@ -133,15 +133,15 @@ protected: /** * Destructor. */ - ~ImageToHessianDeterminantImageFilter() ITK_OVERRIDE; + ~ImageToHessianDeterminantImageFilter() override; /** * Standard PrintSelf method. */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Main computation method. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: diff --git a/Modules/Feature/Descriptors/include/otbImageToSIFTKeyPointSetFilter.h b/Modules/Feature/Descriptors/include/otbImageToSIFTKeyPointSetFilter.h index deba621934..e554389b15 100644 --- a/Modules/Feature/Descriptors/include/otbImageToSIFTKeyPointSetFilter.h +++ b/Modules/Feature/Descriptors/include/otbImageToSIFTKeyPointSetFilter.h @@ -227,16 +227,16 @@ public: protected: /** Actually process the input */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Constructor */ ImageToSIFTKeyPointSetFilter(); /** Destructor */ - ~ImageToSIFTKeyPointSetFilter() ITK_OVERRIDE {} + ~ImageToSIFTKeyPointSetFilter() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Initialize input image */ void InitializeInputImage(); diff --git a/Modules/Feature/Descriptors/include/otbImageToSURFKeyPointSetFilter.h b/Modules/Feature/Descriptors/include/otbImageToSURFKeyPointSetFilter.h index eec0eef16e..bb8b1f2e6d 100644 --- a/Modules/Feature/Descriptors/include/otbImageToSURFKeyPointSetFilter.h +++ b/Modules/Feature/Descriptors/include/otbImageToSURFKeyPointSetFilter.h @@ -134,15 +134,15 @@ protected: /** * Destructor. */ - ~ImageToSURFKeyPointSetFilter() ITK_OVERRIDE; + ~ImageToSURFKeyPointSetFilter() override; /** * Standard PrintSelf method. */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Main computation method. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Check local extremum for 8 neighbors (current) * diff --git a/Modules/Feature/Descriptors/include/otbKeyPointSetsMatchingFilter.h b/Modules/Feature/Descriptors/include/otbKeyPointSetsMatchingFilter.h index 671c19bc43..bf16d31549 100644 --- a/Modules/Feature/Descriptors/include/otbKeyPointSetsMatchingFilter.h +++ b/Modules/Feature/Descriptors/include/otbKeyPointSetsMatchingFilter.h @@ -102,12 +102,12 @@ protected: /// Constructor KeyPointSetsMatchingFilter(); /// Destructor - ~KeyPointSetsMatchingFilter() ITK_OVERRIDE {} + ~KeyPointSetsMatchingFilter() override {} /// PrintSelf method - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /// Generate Data - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** * Find the nearest neighbor of data1 in pointset. diff --git a/Modules/Feature/Descriptors/include/otbLandmark.h b/Modules/Feature/Descriptors/include/otbLandmark.h index 70573df764..997e5da5e5 100644 --- a/Modules/Feature/Descriptors/include/otbLandmark.h +++ b/Modules/Feature/Descriptors/include/otbLandmark.h @@ -72,9 +72,9 @@ protected: /// Constructor Landmark() {} /// Destructor - ~Landmark() ITK_OVERRIDE {} + ~Landmark() override {} /// PrintSelf method - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); os << indent << "Landmark: P1= " << m_Point1 << " P2= " << m_Point2 << std::endl; diff --git a/Modules/Feature/Descriptors/include/otbSiftFastImageFilter.h b/Modules/Feature/Descriptors/include/otbSiftFastImageFilter.h index 4cbbce49b6..ff1e7ef2b5 100644 --- a/Modules/Feature/Descriptors/include/otbSiftFastImageFilter.h +++ b/Modules/Feature/Descriptors/include/otbSiftFastImageFilter.h @@ -91,16 +91,16 @@ public: protected: /** Actually process the input */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Constructor */ SiftFastImageFilter(); /** Destructor */ - ~SiftFastImageFilter() ITK_OVERRIDE {} + ~SiftFastImageFilter() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** The number of scales */ diff --git a/Modules/Feature/Edge/include/otbAssociativeSymmetricalSumImageFilter.h b/Modules/Feature/Edge/include/otbAssociativeSymmetricalSumImageFilter.h index 5e8f72c6f5..b0c011244c 100644 --- a/Modules/Feature/Edge/include/otbAssociativeSymmetricalSumImageFilter.h +++ b/Modules/Feature/Edge/include/otbAssociativeSymmetricalSumImageFilter.h @@ -94,7 +94,7 @@ public: protected: AssociativeSymmetricalSumImageFilter() {} - ~AssociativeSymmetricalSumImageFilter() ITK_OVERRIDE {} + ~AssociativeSymmetricalSumImageFilter() override {} private: AssociativeSymmetricalSumImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Edge/include/otbAsymmetricFusionOfLineDetectorImageFilter.h b/Modules/Feature/Edge/include/otbAsymmetricFusionOfLineDetectorImageFilter.h index 463564db4a..991f9c1b5e 100644 --- a/Modules/Feature/Edge/include/otbAsymmetricFusionOfLineDetectorImageFilter.h +++ b/Modules/Feature/Edge/include/otbAsymmetricFusionOfLineDetectorImageFilter.h @@ -81,7 +81,7 @@ public: protected: AsymmetricFusionOfLineDetectorImageFilter(); - ~AsymmetricFusionOfLineDetectorImageFilter() ITK_OVERRIDE {} + ~AsymmetricFusionOfLineDetectorImageFilter() override {} typedef otb::LineRatioDetectorImageFilter<InputImageType, OutputImageType, OutputImageDirectionType, InterpolatorType> LineRatioType; @@ -90,9 +90,9 @@ protected: typedef otb::AssociativeSymmetricalSumImageFilter<InputImageType1, InputImageType2, OutputImageType> AssSymSumType; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: AsymmetricFusionOfLineDetectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Edge/include/otbEdgeDensityImageFilter.h b/Modules/Feature/Edge/include/otbEdgeDensityImageFilter.h index 0be9d6a1bc..2b789dfe75 100644 --- a/Modules/Feature/Edge/include/otbEdgeDensityImageFilter.h +++ b/Modules/Feature/Edge/include/otbEdgeDensityImageFilter.h @@ -104,15 +104,15 @@ protected: /** * Destructor. */ - ~EdgeDensityImageFilter() ITK_OVERRIDE; + ~EdgeDensityImageFilter() override; /** * Standard PrintSelf method. */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Main computation method. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: diff --git a/Modules/Feature/Edge/include/otbEdgeDetectorImageFilter.h b/Modules/Feature/Edge/include/otbEdgeDetectorImageFilter.h index 611459bde9..33fffc7376 100644 --- a/Modules/Feature/Edge/include/otbEdgeDetectorImageFilter.h +++ b/Modules/Feature/Edge/include/otbEdgeDetectorImageFilter.h @@ -110,9 +110,9 @@ public: protected: EdgeDetectorImageFilter(); - ~EdgeDetectorImageFilter() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - void GenerateData() ITK_OVERRIDE; + ~EdgeDetectorImageFilter() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + void GenerateData() override; private: diff --git a/Modules/Feature/Edge/include/otbExtractSegmentsImageFilter.h b/Modules/Feature/Edge/include/otbExtractSegmentsImageFilter.h index e04a582c19..76323b278a 100644 --- a/Modules/Feature/Edge/include/otbExtractSegmentsImageFilter.h +++ b/Modules/Feature/Edge/include/otbExtractSegmentsImageFilter.h @@ -129,16 +129,16 @@ public: protected: ExtractSegmentsImageFilter(); - ~ExtractSegmentsImageFilter() ITK_OVERRIDE {} + ~ExtractSegmentsImageFilter() override {} typedef PixelSuppressionByDirectionImageFilter<InputImageType, PSOutputImageType> PixelSuppressionType; typedef LocalHoughFilter<InputImageType> LocalHoughType; typedef FillGapsFilter FillGapsType; typedef DrawLineSpatialObjectListFilter<InputImageType, OutputImageType> DrawLineListType; typedef itk::RescaleIntensityImageFilter<TInputImage, TInputImage> RescaleType; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ExtractSegmentsImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Edge/include/otbFillGapsFilter.h b/Modules/Feature/Edge/include/otbFillGapsFilter.h index 4df477cd18..3364b55fab 100644 --- a/Modules/Feature/Edge/include/otbFillGapsFilter.h +++ b/Modules/Feature/Edge/include/otbFillGapsFilter.h @@ -71,11 +71,11 @@ public: protected: FillGapsFilter(); - ~FillGapsFilter() ITK_OVERRIDE {} + ~FillGapsFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: FillGapsFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Edge/include/otbHorizontalSobelVectorImageFilter.h b/Modules/Feature/Edge/include/otbHorizontalSobelVectorImageFilter.h index 6bd4edb5bc..e00af221d1 100644 --- a/Modules/Feature/Edge/include/otbHorizontalSobelVectorImageFilter.h +++ b/Modules/Feature/Edge/include/otbHorizontalSobelVectorImageFilter.h @@ -91,7 +91,7 @@ protected: typename Superclass::RadiusType radius = {{1, 1}}; this->SetRadius( radius ); } - ~HorizontalSobelVectorImageFilter() ITK_OVERRIDE { } + ~HorizontalSobelVectorImageFilter() override { } private: HorizontalSobelVectorImageFilter( const Self & ); // Not implemented diff --git a/Modules/Feature/Edge/include/otbHoughTransform2DLinesImageFilter.h b/Modules/Feature/Edge/include/otbHoughTransform2DLinesImageFilter.h index 532c26d917..758e33dd45 100644 --- a/Modules/Feature/Edge/include/otbHoughTransform2DLinesImageFilter.h +++ b/Modules/Feature/Edge/include/otbHoughTransform2DLinesImageFilter.h @@ -108,7 +108,7 @@ public: itkNewMacro(Self); /** Method for evaluating the implicit function over the image. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Accessors for the threshold above which the filter should consider the point as a valid point */ @@ -184,17 +184,17 @@ public: protected: HoughTransform2DLinesImageFilter(); - ~HoughTransform2DLinesImageFilter() ITK_OVERRIDE {} + ~HoughTransform2DLinesImageFilter() override {} HoughTransform2DLinesImageFilter(const Self &) {} void operator =(const Self&) {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** HoughTransform2DLinesImageFilter needs the entire input. Therefore * it must provide an implementation GenerateInputRequestedRegion(). * \sa ProcessObject::GenerateInputRequestedRegion(). */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** HoughTransform2DLinesImageFilter's output is the accumulator * array. The size of the output is a function of the size of the @@ -202,10 +202,10 @@ protected: * has a different size than the input, it must provide an implementation * of GenerateOutputInformation. * \sa ProcessObject::GenerateOutputRequestedRegion() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** HoughTransform2DLinesImageFilter must produce the entire output */ - void EnlargeOutputRequestedRegion(itk::DataObject *output) ITK_OVERRIDE; + void EnlargeOutputRequestedRegion(itk::DataObject *output) override; int GetAngleIndex(double); diff --git a/Modules/Feature/Edge/include/otbLineCorrelationDetectorImageFilter.h b/Modules/Feature/Edge/include/otbLineCorrelationDetectorImageFilter.h index ab4d3d3278..915054394b 100644 --- a/Modules/Feature/Edge/include/otbLineCorrelationDetectorImageFilter.h +++ b/Modules/Feature/Edge/include/otbLineCorrelationDetectorImageFilter.h @@ -85,11 +85,11 @@ public: protected: LineCorrelationDetectorImageFilter(); - ~LineCorrelationDetectorImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LineCorrelationDetectorImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Compute the measure */ - double ComputeMeasure(std::vector<double>* m1, std::vector<double>* m2, std::vector<double>* m3) ITK_OVERRIDE; + double ComputeMeasure(std::vector<double>* m1, std::vector<double>* m2, std::vector<double>* m3) override; private: LineCorrelationDetectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Edge/include/otbLineDetectorImageFilterBase.h b/Modules/Feature/Edge/include/otbLineDetectorImageFilterBase.h index 03ef00ec2e..bcc411f568 100644 --- a/Modules/Feature/Edge/include/otbLineDetectorImageFilterBase.h +++ b/Modules/Feature/Edge/include/otbLineDetectorImageFilterBase.h @@ -132,14 +132,14 @@ public: itkGetConstReferenceMacro(NumberOfDirections, unsigned int); void GenerateInputRequestedRegion() - throw(itk::InvalidRequestedRegionError) ITK_OVERRIDE; + throw(itk::InvalidRequestedRegionError) override; protected: LineDetectorImageFilterBase(); - ~LineDetectorImageFilterBase() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LineDetectorImageFilterBase() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** LineDetectorImageFilterBase can be implemented for a treatment of filter multithreaded. * Thus, the ThreadedGenerateData() method is called for each thread process. @@ -151,7 +151,7 @@ protected: * \sa ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; virtual double ComputeMeasure(std::vector<double>* m1, std::vector<double>* m2, std::vector<double>* m3); diff --git a/Modules/Feature/Edge/include/otbLineRatioDetectorImageFilter.h b/Modules/Feature/Edge/include/otbLineRatioDetectorImageFilter.h index 1940cbbb2f..3ed85b87e2 100644 --- a/Modules/Feature/Edge/include/otbLineRatioDetectorImageFilter.h +++ b/Modules/Feature/Edge/include/otbLineRatioDetectorImageFilter.h @@ -114,10 +114,10 @@ public: protected: LineRatioDetectorImageFilter(); - ~LineRatioDetectorImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LineRatioDetectorImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - double ComputeMeasure(std::vector<double>* m1, std::vector<double>* m2, std::vector<double>* m3) ITK_OVERRIDE; + double ComputeMeasure(std::vector<double>* m1, std::vector<double>* m2, std::vector<double>* m3) override; private: LineRatioDetectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Edge/include/otbLineSegmentDetector.h b/Modules/Feature/Edge/include/otbLineSegmentDetector.h index 25c0872bd6..ef78f8c8f1 100644 --- a/Modules/Feature/Edge/include/otbLineSegmentDetector.h +++ b/Modules/Feature/Edge/include/otbLineSegmentDetector.h @@ -192,12 +192,12 @@ public: protected: LineSegmentDetector(); - ~LineSegmentDetector() ITK_OVERRIDE {} + ~LineSegmentDetector() override {} - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Generate Data method*/ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Sort the image and store the coordinates in a histogram * this method is used to determine the seeds where to begin the search segments @@ -257,7 +257,7 @@ protected: virtual void CopyRectangle(RectangleType& rDst, RectangleType& rSrc) const; /** Printself method*/ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LineSegmentDetector(const Self &); //purposely not implemented diff --git a/Modules/Feature/Edge/include/otbLocalHoughFilter.h b/Modules/Feature/Edge/include/otbLocalHoughFilter.h index f8d52baace..38ff44693b 100644 --- a/Modules/Feature/Edge/include/otbLocalHoughFilter.h +++ b/Modules/Feature/Edge/include/otbLocalHoughFilter.h @@ -130,13 +130,13 @@ public: protected: LocalHoughFilter(); - ~LocalHoughFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LocalHoughFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Definition of the Hough Filter. */ typedef itk::HoughTransform2DLinesImageFilter<InputPixelType, AccumulatorPixelType> HoughFilterType; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: LocalHoughFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Edge/include/otbPersistentVectorizationImageFilter.h b/Modules/Feature/Edge/include/otbPersistentVectorizationImageFilter.h index f7d883212a..4bcf136cdc 100644 --- a/Modules/Feature/Edge/include/otbPersistentVectorizationImageFilter.h +++ b/Modules/Feature/Edge/include/otbPersistentVectorizationImageFilter.h @@ -82,16 +82,16 @@ public: typedef otb::ImageToEdgePathFilter<ImageType, PathType> ImageToEdgePathFilterType; typedef typename ImageToEdgePathFilterType::Pointer ImageToEdgePathFilterPointerType; - void Reset(void) ITK_OVERRIDE; - void Synthetize(void) ITK_OVERRIDE; + void Reset(void) override; + void Synthetize(void) override; itkGetObjectMacro(PathList, PathListType); protected: PersistentVectorizationImageFilter(); - ~PersistentVectorizationImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - void GenerateData() ITK_OVERRIDE; + ~PersistentVectorizationImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + void GenerateData() override; private: PersistentVectorizationImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Edge/include/otbPixelSuppressionByDirectionImageFilter.h b/Modules/Feature/Edge/include/otbPixelSuppressionByDirectionImageFilter.h index 647ba25f5f..1213469178 100644 --- a/Modules/Feature/Edge/include/otbPixelSuppressionByDirectionImageFilter.h +++ b/Modules/Feature/Edge/include/otbPixelSuppressionByDirectionImageFilter.h @@ -103,15 +103,15 @@ public: const InputImageType * GetInputImageDirection(void); void GenerateInputRequestedRegion() - throw(itk::InvalidRequestedRegionError) ITK_OVERRIDE; + throw(itk::InvalidRequestedRegionError) override; protected: PixelSuppressionByDirectionImageFilter(); - ~PixelSuppressionByDirectionImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PixelSuppressionByDirectionImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: PixelSuppressionByDirectionImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Edge/include/otbSobelVectorImageFilter.h b/Modules/Feature/Edge/include/otbSobelVectorImageFilter.h index 37f45c5f14..cfe3d0d709 100644 --- a/Modules/Feature/Edge/include/otbSobelVectorImageFilter.h +++ b/Modules/Feature/Edge/include/otbSobelVectorImageFilter.h @@ -100,7 +100,7 @@ protected: typename Superclass::RadiusType radius = {{1, 1}}; this->SetRadius( radius ); } - ~SobelVectorImageFilter() ITK_OVERRIDE { } + ~SobelVectorImageFilter() override { } private: SobelVectorImageFilter( const Self & ); // Not implemented diff --git a/Modules/Feature/Edge/include/otbStreamingLineSegmentDetector.h b/Modules/Feature/Edge/include/otbStreamingLineSegmentDetector.h index 9f1ad77392..a161d2beea 100644 --- a/Modules/Feature/Edge/include/otbStreamingLineSegmentDetector.h +++ b/Modules/Feature/Edge/include/otbStreamingLineSegmentDetector.h @@ -77,15 +77,15 @@ public: protected: PersistentStreamingLineSegmentDetector(); - ~PersistentStreamingLineSegmentDetector() ITK_OVERRIDE; + ~PersistentStreamingLineSegmentDetector() override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; private: PersistentStreamingLineSegmentDetector(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented - OutputVectorDataPointerType ProcessTile() ITK_OVERRIDE; + OutputVectorDataPointerType ProcessTile() override; }; template <class TImageType> diff --git a/Modules/Feature/Edge/include/otbTouziEdgeDetectorImageFilter.h b/Modules/Feature/Edge/include/otbTouziEdgeDetectorImageFilter.h index ad0c0d3704..90b1cc18e9 100644 --- a/Modules/Feature/Edge/include/otbTouziEdgeDetectorImageFilter.h +++ b/Modules/Feature/Edge/include/otbTouziEdgeDetectorImageFilter.h @@ -101,14 +101,14 @@ public: * * \sa ImageToImageFilter::GenerateInputRequestedRegion() */ void GenerateInputRequestedRegion() - throw(itk::InvalidRequestedRegionError) ITK_OVERRIDE; + throw(itk::InvalidRequestedRegionError) override; protected: TouziEdgeDetectorImageFilter(); - ~TouziEdgeDetectorImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~TouziEdgeDetectorImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** TouziEdgeDetectorImageFilter can be implemented for a multithreaded filter treatment. * Thus, this implementation give the ThreadedGenerateData() method. @@ -119,7 +119,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: TouziEdgeDetectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Edge/include/otbVerticalSobelVectorImageFilter.h b/Modules/Feature/Edge/include/otbVerticalSobelVectorImageFilter.h index fd480b5795..b244398da4 100644 --- a/Modules/Feature/Edge/include/otbVerticalSobelVectorImageFilter.h +++ b/Modules/Feature/Edge/include/otbVerticalSobelVectorImageFilter.h @@ -91,7 +91,7 @@ protected: typename Superclass::RadiusType radius = {{1, 1}}; this->SetRadius( radius ); } - ~VerticalSobelVectorImageFilter() ITK_OVERRIDE { } + ~VerticalSobelVectorImageFilter() override { } private: VerticalSobelVectorImageFilter( const Self & ); // Not implemented diff --git a/Modules/Feature/Moments/include/otbComplexMomentPathFunction.h b/Modules/Feature/Moments/include/otbComplexMomentPathFunction.h index c6de473c73..83d638752e 100644 --- a/Modules/Feature/Moments/include/otbComplexMomentPathFunction.h +++ b/Modules/Feature/Moments/include/otbComplexMomentPathFunction.h @@ -92,7 +92,7 @@ public: typedef std::complex<PrecisionType> ComplexPrecisionType; /** Evalulate the function */ - OutputType Evaluate(const PathType& path) const ITK_OVERRIDE; + OutputType Evaluate(const PathType& path) const override; virtual OutputType Evaluate() const; itkSetMacro(P, unsigned int); @@ -102,8 +102,8 @@ public: protected: ComplexMomentPathFunction(); - ~ComplexMomentPathFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ComplexMomentPathFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ComplexMomentPathFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Moments/include/otbComplexMomentsImageFunction.h b/Modules/Feature/Moments/include/otbComplexMomentsImageFunction.h index ea7ccac8fc..5f86297032 100644 --- a/Modules/Feature/Moments/include/otbComplexMomentsImageFunction.h +++ b/Modules/Feature/Moments/include/otbComplexMomentsImageFunction.h @@ -92,17 +92,17 @@ public: InputImageType::ImageDimension); /** Evalulate the function at specified index */ - OutputType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PointType& point) const ITK_OVERRIDE + OutputType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } OutputType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -122,8 +122,8 @@ public: protected: ComplexMomentsImageFunction(); - ~ComplexMomentsImageFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ComplexMomentsImageFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ComplexMomentsImageFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Moments/include/otbFlusserMomentsImageFunction.h b/Modules/Feature/Moments/include/otbFlusserMomentsImageFunction.h index 38914022de..4590e02153 100644 --- a/Modules/Feature/Moments/include/otbFlusserMomentsImageFunction.h +++ b/Modules/Feature/Moments/include/otbFlusserMomentsImageFunction.h @@ -108,17 +108,17 @@ public: InputImageType::ImageDimension); /** Evalulate the function at specified index */ - OutputType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PointType& point) const ITK_OVERRIDE + OutputType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } OutputType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -133,8 +133,8 @@ public: protected: FlusserMomentsImageFunction(); - ~FlusserMomentsImageFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~FlusserMomentsImageFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: FlusserMomentsImageFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Moments/include/otbFlusserPathFunction.h b/Modules/Feature/Moments/include/otbFlusserPathFunction.h index 8564016eac..4f6e4788b8 100644 --- a/Modules/Feature/Moments/include/otbFlusserPathFunction.h +++ b/Modules/Feature/Moments/include/otbFlusserPathFunction.h @@ -93,7 +93,7 @@ public: typedef typename Superclass::PrecisionType PrecisionType; /** Evaluate the function at non-integer positions */ - RealType Evaluate(const PathType& path) const ITK_OVERRIDE; + RealType Evaluate(const PathType& path) const override; virtual RealType Evaluate() const; /** Get/Set the radius of the neighborhood over which the statistics are evaluated */ @@ -102,8 +102,8 @@ public: protected: FlusserPathFunction(); - ~FlusserPathFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~FlusserPathFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: FlusserPathFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Moments/include/otbGeometricMomentPathFunction.h b/Modules/Feature/Moments/include/otbGeometricMomentPathFunction.h index 4ebbc49a6d..c02171118b 100644 --- a/Modules/Feature/Moments/include/otbGeometricMomentPathFunction.h +++ b/Modules/Feature/Moments/include/otbGeometricMomentPathFunction.h @@ -63,8 +63,8 @@ public: protected: GeometricMomentPathFunction() {}; - ~GeometricMomentPathFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~GeometricMomentPathFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Feature/Moments/include/otbHuMomentsImageFunction.h b/Modules/Feature/Moments/include/otbHuMomentsImageFunction.h index e74f864342..3c319ecfb3 100644 --- a/Modules/Feature/Moments/include/otbHuMomentsImageFunction.h +++ b/Modules/Feature/Moments/include/otbHuMomentsImageFunction.h @@ -104,17 +104,17 @@ public: InputImageType::ImageDimension); /** Evalulate the function at specified index */ - OutputType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PointType& point) const ITK_OVERRIDE + OutputType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } OutputType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -129,8 +129,8 @@ public: protected: HuMomentsImageFunction(); - ~HuMomentsImageFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~HuMomentsImageFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: HuMomentsImageFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Moments/include/otbHuPathFunction.h b/Modules/Feature/Moments/include/otbHuPathFunction.h index 6014af005c..855460a704 100644 --- a/Modules/Feature/Moments/include/otbHuPathFunction.h +++ b/Modules/Feature/Moments/include/otbHuPathFunction.h @@ -90,7 +90,7 @@ public: typedef typename Superclass::PrecisionType PrecisionType; /** Evaluate the function at non-integer positions */ - RealType Evaluate(const PathType& path) const ITK_OVERRIDE; + RealType Evaluate(const PathType& path) const override; virtual RealType Evaluate() const; /** Get/Set the radius of the neighborhood over which the statistics are evaluated */ @@ -99,8 +99,8 @@ public: protected: HuPathFunction(); - ~HuPathFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~HuPathFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: HuPathFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Moments/include/otbRadiometricMomentsImageFilter.h b/Modules/Feature/Moments/include/otbRadiometricMomentsImageFilter.h index 0324437e3d..6508a9ce8e 100644 --- a/Modules/Feature/Moments/include/otbRadiometricMomentsImageFilter.h +++ b/Modules/Feature/Moments/include/otbRadiometricMomentsImageFilter.h @@ -92,10 +92,10 @@ public: protected: RadiometricMomentsImageFilter(); - ~RadiometricMomentsImageFilter() ITK_OVERRIDE {} - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; - void GenerateOutputInformation(void) ITK_OVERRIDE; + ~RadiometricMomentsImageFilter() override {} + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; + void GenerateInputRequestedRegion(void) override; + void GenerateOutputInformation(void) override; private: RadiometricMomentsImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Moments/include/otbRadiometricMomentsImageFunction.h b/Modules/Feature/Moments/include/otbRadiometricMomentsImageFunction.h index 1fd7355e7c..49563faaaf 100644 --- a/Modules/Feature/Moments/include/otbRadiometricMomentsImageFunction.h +++ b/Modules/Feature/Moments/include/otbRadiometricMomentsImageFunction.h @@ -89,17 +89,17 @@ public: InputImageType::ImageDimension); /** Evalulate the function at specified index */ - OutputType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PointType& point) const ITK_OVERRIDE + OutputType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } OutputType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -114,8 +114,8 @@ public: protected: RadiometricMomentsImageFunction(); - ~RadiometricMomentsImageFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~RadiometricMomentsImageFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: RadiometricMomentsImageFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Moments/include/otbRealMomentPathFunction.h b/Modules/Feature/Moments/include/otbRealMomentPathFunction.h index 70765ce6f7..fdb123749a 100644 --- a/Modules/Feature/Moments/include/otbRealMomentPathFunction.h +++ b/Modules/Feature/Moments/include/otbRealMomentPathFunction.h @@ -67,8 +67,8 @@ public: protected: RealMomentPathFunction() {} - ~RealMomentPathFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~RealMomentPathFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Feature/Moments/include/otbRealMomentsImageFunction.h b/Modules/Feature/Moments/include/otbRealMomentsImageFunction.h index 7dcfce0489..d535d989cb 100644 --- a/Modules/Feature/Moments/include/otbRealMomentsImageFunction.h +++ b/Modules/Feature/Moments/include/otbRealMomentsImageFunction.h @@ -79,17 +79,17 @@ public: InputImageType::ImageDimension); /** Evalulate the function at specified index */ - OutputType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PointType& point) const ITK_OVERRIDE + OutputType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } OutputType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -109,8 +109,8 @@ public: protected: RealMomentsImageFunction(); - ~RealMomentsImageFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~RealMomentsImageFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: RealMomentsImageFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/SeamCarving/include/otbAddCarvingPathFilter.h b/Modules/Feature/SeamCarving/include/otbAddCarvingPathFilter.h index 2b0e1a4b9d..4c8f48760d 100644 --- a/Modules/Feature/SeamCarving/include/otbAddCarvingPathFilter.h +++ b/Modules/Feature/SeamCarving/include/otbAddCarvingPathFilter.h @@ -114,15 +114,15 @@ public: itkSetMacro(Direction, unsigned int); itkGetConstMacro(Direction, unsigned int); - void GenerateOutputInformation() ITK_OVERRIDE; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateOutputInformation() override; + void GenerateInputRequestedRegion() override; protected: AddCarvingPathFilter(); - ~AddCarvingPathFilter() ITK_OVERRIDE {} + ~AddCarvingPathFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - void GenerateData() ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + void GenerateData() override; private: AddCarvingPathFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/SeamCarving/include/otbImageToCarvingPathFilter.h b/Modules/Feature/SeamCarving/include/otbImageToCarvingPathFilter.h index a3cdcc3623..d48e79b04c 100644 --- a/Modules/Feature/SeamCarving/include/otbImageToCarvingPathFilter.h +++ b/Modules/Feature/SeamCarving/include/otbImageToCarvingPathFilter.h @@ -93,10 +93,10 @@ public: protected: ImageToCarvingPathFilter(); - ~ImageToCarvingPathFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE {} //does nothing - void GenerateData() ITK_OVERRIDE; + ~ImageToCarvingPathFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + void GenerateOutputInformation() override {} //does nothing + void GenerateData() override; private: ImageToCarvingPathFilter(const Self &); // purposely not implemented diff --git a/Modules/Feature/SeamCarving/include/otbRemoveCarvingPathFilter.h b/Modules/Feature/SeamCarving/include/otbRemoveCarvingPathFilter.h index 81cdd304b1..3ad0f99046 100644 --- a/Modules/Feature/SeamCarving/include/otbRemoveCarvingPathFilter.h +++ b/Modules/Feature/SeamCarving/include/otbRemoveCarvingPathFilter.h @@ -115,14 +115,14 @@ public: itkSetMacro(Direction, unsigned int); itkGetConstMacro(Direction, unsigned int); - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; protected: RemoveCarvingPathFilter(); - ~RemoveCarvingPathFilter() ITK_OVERRIDE {} + ~RemoveCarvingPathFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - void GenerateData() ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + void GenerateData() override; private: RemoveCarvingPathFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Textures/include/otbGreyLevelCooccurrenceIndexedList.h b/Modules/Feature/Textures/include/otbGreyLevelCooccurrenceIndexedList.h index f4c1692d28..6e3cd1707a 100644 --- a/Modules/Feature/Textures/include/otbGreyLevelCooccurrenceIndexedList.h +++ b/Modules/Feature/Textures/include/otbGreyLevelCooccurrenceIndexedList.h @@ -138,7 +138,7 @@ public: protected: GreyLevelCooccurrenceIndexedList(); - ~GreyLevelCooccurrenceIndexedList() ITK_OVERRIDE { } + ~GreyLevelCooccurrenceIndexedList() override { } /** create a cooccurrence pair with given index and frequency = 1 * value. Next occurrence of same index is checked via m_LookupArray and the @@ -155,7 +155,7 @@ protected: /** Get index of the pixelPair combination and save the result in index **/ bool GetIndex(const PixelPairType & pixelPair, IndexType & index) const; - void PrintSelf(std::ostream & os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream & os, itk::Indent indent) const override; private: diff --git a/Modules/Feature/Textures/include/otbHaralickTexturesImageFunction.h b/Modules/Feature/Textures/include/otbHaralickTexturesImageFunction.h index 167fd36770..bc717f3838 100644 --- a/Modules/Feature/Textures/include/otbHaralickTexturesImageFunction.h +++ b/Modules/Feature/Textures/include/otbHaralickTexturesImageFunction.h @@ -149,17 +149,17 @@ public: InputImageType::ImageDimension); /** Evalulate the function at specified index */ - OutputType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PointType& point) const ITK_OVERRIDE + OutputType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } OutputType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -203,8 +203,8 @@ public: protected: HaralickTexturesImageFunction(); - ~HaralickTexturesImageFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~HaralickTexturesImageFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: HaralickTexturesImageFunction(const Self &); //purposely not implemented diff --git a/Modules/Feature/Textures/include/otbSFSTexturesImageFilter.h b/Modules/Feature/Textures/include/otbSFSTexturesImageFilter.h index 2ac676e4ae..a415527900 100644 --- a/Modules/Feature/Textures/include/otbSFSTexturesImageFilter.h +++ b/Modules/Feature/Textures/include/otbSFSTexturesImageFilter.h @@ -213,18 +213,18 @@ public: const OutputImageType * GetSDOutput() const; OutputImageType * GetSDOutput(); - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; std::vector<FunctorType> m_FunctorList; protected: SFSTexturesImageFilter(); - ~SFSTexturesImageFilter() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~SFSTexturesImageFilter() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** Pad the input requested region by radius */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; private: SFSTexturesImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.h b/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.h index 8ed418c5f0..22d3fe478e 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.h +++ b/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.h @@ -213,15 +213,15 @@ protected: /** Constructor */ ScalarImageToAdvancedTexturesFilter(); /** Destructor */ - ~ScalarImageToAdvancedTexturesFilter() ITK_OVERRIDE; + ~ScalarImageToAdvancedTexturesFilter() override; /** Generate the output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate the input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Before Parallel textures extraction */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Parallel textures extraction */ - void ThreadedGenerateData(const OutputRegionType& outputRegion, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputRegionType& outputRegion, itk::ThreadIdType threadId) override; private: ScalarImageToAdvancedTexturesFilter(const Self&); //purposely not implemented diff --git a/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.h b/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.h index f252b673ca..72b6517fff 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.h +++ b/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.h @@ -200,13 +200,13 @@ protected: /** Constructor */ ScalarImageToHigherOrderTexturesFilter(); /** Destructor */ - ~ScalarImageToHigherOrderTexturesFilter() ITK_OVERRIDE; + ~ScalarImageToHigherOrderTexturesFilter() override; /** Generate the output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate the input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Parallel textures extraction */ - void ThreadedGenerateData(const OutputRegionType& outputRegion, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputRegionType& outputRegion, itk::ThreadIdType threadId) override; private: ScalarImageToHigherOrderTexturesFilter(const Self&); //purposely not implemented diff --git a/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.h b/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.h index 74e040025e..3c5d650069 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.h +++ b/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.h @@ -114,11 +114,11 @@ protected: /** Constructor */ ScalarImageToPanTexTextureFilter(); /** Destructor */ - ~ScalarImageToPanTexTextureFilter() ITK_OVERRIDE; + ~ScalarImageToPanTexTextureFilter() override; /** Generate the input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Parallel textures extraction */ - void ThreadedGenerateData(const OutputRegionType& outputRegion, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputRegionType& outputRegion, itk::ThreadIdType threadId) override; private: ScalarImageToPanTexTextureFilter(const Self&); //purposely not implemented diff --git a/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.h b/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.h index 3b9b8dfaf2..b3732a164a 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.h +++ b/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.h @@ -209,15 +209,15 @@ protected: /** Constructor */ ScalarImageToTexturesFilter(); /** Destructor */ - ~ScalarImageToTexturesFilter() ITK_OVERRIDE; + ~ScalarImageToTexturesFilter() override; /** Generate the output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate the input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Before Parallel textures extraction */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Parallel textures extraction */ - void ThreadedGenerateData(const OutputRegionType& outputRegion, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputRegionType& outputRegion, itk::ThreadIdType threadId) override; private: ScalarImageToTexturesFilter(const Self&); //purposely not implemented diff --git a/Modules/Feature/Textures/include/otbTextureImageFunction.h b/Modules/Feature/Textures/include/otbTextureImageFunction.h index 316a39c0ff..02040fe05f 100644 --- a/Modules/Feature/Textures/include/otbTextureImageFunction.h +++ b/Modules/Feature/Textures/include/otbTextureImageFunction.h @@ -77,17 +77,17 @@ public: itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension); /** Evalulate the function at specified index */ - RealType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + RealType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - RealType Evaluate(const PointType& point) const ITK_OVERRIDE + RealType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } RealType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -120,8 +120,8 @@ public: protected: TextureImageFunction(); - ~TextureImageFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~TextureImageFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: TextureImageFunction(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ChangeDetection/include/otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h b/Modules/Filtering/ChangeDetection/include/otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h index e9822f5cb7..3b82bad169 100644 --- a/Modules/Filtering/ChangeDetection/include/otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h +++ b/Modules/Filtering/ChangeDetection/include/otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h @@ -148,9 +148,9 @@ public: protected: BinaryFunctorNeighborhoodJoinHistogramImageFilter(); - ~BinaryFunctorNeighborhoodJoinHistogramImageFilter() ITK_OVERRIDE {} + ~BinaryFunctorNeighborhoodJoinHistogramImageFilter() override {} - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** BinaryFunctorNeighborhoodJoinHistogramImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -163,12 +163,12 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; /** * Pad the inputs requested regions by radius */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; RadiusSizeType m_Radius; diff --git a/Modules/Filtering/ChangeDetection/include/otbCBAMIChangeDetector.h b/Modules/Filtering/ChangeDetection/include/otbCBAMIChangeDetector.h index 31f47e259f..e6650ce676 100644 --- a/Modules/Filtering/ChangeDetection/include/otbCBAMIChangeDetector.h +++ b/Modules/Filtering/ChangeDetection/include/otbCBAMIChangeDetector.h @@ -84,7 +84,7 @@ public: protected: CBAMIChangeDetector() {} - ~CBAMIChangeDetector() ITK_OVERRIDE {} + ~CBAMIChangeDetector() override {} private: CBAMIChangeDetector(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ChangeDetection/include/otbCorrelationChangeDetector.h b/Modules/Filtering/ChangeDetection/include/otbCorrelationChangeDetector.h index e6831bceba..4b710c4bba 100644 --- a/Modules/Filtering/ChangeDetection/include/otbCorrelationChangeDetector.h +++ b/Modules/Filtering/ChangeDetection/include/otbCorrelationChangeDetector.h @@ -83,7 +83,7 @@ public: protected: CorrelationChangeDetector() {} - ~CorrelationChangeDetector() ITK_OVERRIDE {} + ~CorrelationChangeDetector() override {} private: CorrelationChangeDetector(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ChangeDetection/include/otbJoinHistogramMIImageFilter.h b/Modules/Filtering/ChangeDetection/include/otbJoinHistogramMIImageFilter.h index 56b3f5ae70..98f736f84a 100644 --- a/Modules/Filtering/ChangeDetection/include/otbJoinHistogramMIImageFilter.h +++ b/Modules/Filtering/ChangeDetection/include/otbJoinHistogramMIImageFilter.h @@ -84,7 +84,7 @@ public: protected: JoinHistogramMIImageFilter() {} - ~JoinHistogramMIImageFilter() ITK_OVERRIDE {} + ~JoinHistogramMIImageFilter() override {} private: JoinHistogramMIImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerDistanceImageFilter.h b/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerDistanceImageFilter.h index b28e9d8b10..ad9c088b64 100644 --- a/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerDistanceImageFilter.h +++ b/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerDistanceImageFilter.h @@ -170,7 +170,7 @@ public: protected: KullbackLeiblerDistanceImageFilter() {} - ~KullbackLeiblerDistanceImageFilter() ITK_OVERRIDE {} + ~KullbackLeiblerDistanceImageFilter() override {} private: KullbackLeiblerDistanceImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerProfileImageFilter.h b/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerProfileImageFilter.h index 2a04a140b7..bced45b78b 100644 --- a/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerProfileImageFilter.h +++ b/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerProfileImageFilter.h @@ -187,7 +187,7 @@ public: protected: KullbackLeiblerProfileImageFilter() {} - ~KullbackLeiblerProfileImageFilter() ITK_OVERRIDE {} + ~KullbackLeiblerProfileImageFilter() override {} private: KullbackLeiblerProfileImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerSupervizedDistanceImageFilter.h b/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerSupervizedDistanceImageFilter.h index e74d68c904..b26619d8e2 100644 --- a/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerSupervizedDistanceImageFilter.h +++ b/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerSupervizedDistanceImageFilter.h @@ -146,13 +146,13 @@ public: void SetTrainingArea(const TInputROIImage * trainingImage); protected: - void BeforeThreadedGenerateData(void) ITK_OVERRIDE; + void BeforeThreadedGenerateData(void) override; KullbackLeiblerSupervizedDistanceImageFilter() { this->SetNumberOfRequiredInputs(3); } - ~KullbackLeiblerSupervizedDistanceImageFilter() ITK_OVERRIDE {} + ~KullbackLeiblerSupervizedDistanceImageFilter() override {} private: KullbackLeiblerSupervizedDistanceImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ChangeDetection/include/otbLHMIChangeDetector.h b/Modules/Filtering/ChangeDetection/include/otbLHMIChangeDetector.h index 391d622411..bb54a51f66 100644 --- a/Modules/Filtering/ChangeDetection/include/otbLHMIChangeDetector.h +++ b/Modules/Filtering/ChangeDetection/include/otbLHMIChangeDetector.h @@ -84,7 +84,7 @@ public: protected: LHMIChangeDetector() {} - ~LHMIChangeDetector() ITK_OVERRIDE {} + ~LHMIChangeDetector() override {} private: LHMIChangeDetector(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ChangeDetection/include/otbMeanDifferenceImageFilter.h b/Modules/Filtering/ChangeDetection/include/otbMeanDifferenceImageFilter.h index 7d0a70ed2c..a93d1b6bc9 100644 --- a/Modules/Filtering/ChangeDetection/include/otbMeanDifferenceImageFilter.h +++ b/Modules/Filtering/ChangeDetection/include/otbMeanDifferenceImageFilter.h @@ -82,7 +82,7 @@ public: protected: MeanDifferenceImageFilter() {} - ~MeanDifferenceImageFilter() ITK_OVERRIDE {} + ~MeanDifferenceImageFilter() override {} private: MeanDifferenceImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ChangeDetection/include/otbMeanRatioImageFilter.h b/Modules/Filtering/ChangeDetection/include/otbMeanRatioImageFilter.h index 6de8f8cf3d..48aa6ae096 100644 --- a/Modules/Filtering/ChangeDetection/include/otbMeanRatioImageFilter.h +++ b/Modules/Filtering/ChangeDetection/include/otbMeanRatioImageFilter.h @@ -80,7 +80,7 @@ public: protected: MeanRatioImageFilter() {} - ~MeanRatioImageFilter() ITK_OVERRIDE {} + ~MeanRatioImageFilter() override {} private: MeanRatioImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ChangeDetection/include/otbMultivariateAlterationDetectorImageFilter.h b/Modules/Filtering/ChangeDetection/include/otbMultivariateAlterationDetectorImageFilter.h index 9e608d3c1b..51bc83c9b8 100644 --- a/Modules/Filtering/ChangeDetection/include/otbMultivariateAlterationDetectorImageFilter.h +++ b/Modules/Filtering/ChangeDetection/include/otbMultivariateAlterationDetectorImageFilter.h @@ -155,11 +155,11 @@ public: protected: MultivariateAlterationDetectorImageFilter(); - ~MultivariateAlterationDetectorImageFilter() ITK_OVERRIDE {} + ~MultivariateAlterationDetectorImageFilter() override {} - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: MultivariateAlterationDetectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ColorMap/include/otbReliefColormapFunctor.h b/Modules/Filtering/ColorMap/include/otbReliefColormapFunctor.h index 26a6265414..5ea5632698 100644 --- a/Modules/Filtering/ColorMap/include/otbReliefColormapFunctor.h +++ b/Modules/Filtering/ColorMap/include/otbReliefColormapFunctor.h @@ -58,11 +58,11 @@ public: typedef typename Superclass::ScalarType ScalarType; typedef typename Superclass::RealType RealType; - RGBPixelType operator ()(const TScalar&) const ITK_OVERRIDE; + RGBPixelType operator ()(const TScalar&) const override; protected: ReliefColormapFunctor(){}; - ~ReliefColormapFunctor() ITK_OVERRIDE {} + ~ReliefColormapFunctor() override {} private: ReliefColormapFunctor(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ColorMap/include/otbScalarToRainbowRGBPixelFunctor.h b/Modules/Filtering/ColorMap/include/otbScalarToRainbowRGBPixelFunctor.h index ba1e0cb6e9..c5b8a54923 100644 --- a/Modules/Filtering/ColorMap/include/otbScalarToRainbowRGBPixelFunctor.h +++ b/Modules/Filtering/ColorMap/include/otbScalarToRainbowRGBPixelFunctor.h @@ -139,7 +139,7 @@ class ITK_EXPORT ScalarToRainbowRGBPixelFunctor { public: ScalarToRainbowRGBPixelFunctor(); - ~ScalarToRainbowRGBPixelFunctor() ITK_OVERRIDE {} + ~ScalarToRainbowRGBPixelFunctor() override {} typedef ScalarToRainbowRGBPixelFunctor Self; typedef itk::Function::ColormapFunction<TScalar, TRGBPixel> Superclass; @@ -154,7 +154,7 @@ public: typedef TScalar ScalarType; typedef HSVToRGBFunctor<RGBPixelType> HSVToRGBFunctorType; - RGBPixelType operator ()(const TScalar&) const ITK_OVERRIDE; + RGBPixelType operator ()(const TScalar&) const override; protected: RGBPixelType HSVToRGB(double h, double s, double v) const; diff --git a/Modules/Filtering/Convolution/include/otbConvolutionImageFilter.h b/Modules/Filtering/Convolution/include/otbConvolutionImageFilter.h index 9517e1ecd0..1eabaf7c1a 100644 --- a/Modules/Filtering/Convolution/include/otbConvolutionImageFilter.h +++ b/Modules/Filtering/Convolution/include/otbConvolutionImageFilter.h @@ -157,8 +157,8 @@ public: protected: ConvolutionImageFilter(); - ~ConvolutionImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ConvolutionImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** ConvolutionImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() @@ -171,7 +171,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; /** ConvolutionImageFilter needs a larger input requested region than * the output requested region. As such, ConvolutionImageFilter needs @@ -180,7 +180,7 @@ protected: * * \sa ImageToImageFilter::GenerateInputRequestedRegion() */ void GenerateInputRequestedRegion() - throw(itk::InvalidRequestedRegionError) ITK_OVERRIDE; + throw(itk::InvalidRequestedRegionError) override; private: ConvolutionImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Convolution/include/otbGaborFilterGenerator.h b/Modules/Filtering/Convolution/include/otbGaborFilterGenerator.h index b4b42f067f..9f26a1c94d 100644 --- a/Modules/Filtering/Convolution/include/otbGaborFilterGenerator.h +++ b/Modules/Filtering/Convolution/include/otbGaborFilterGenerator.h @@ -112,17 +112,17 @@ protected: /** constructor */ GaborFilterGenerator(); /** destructor */ - ~GaborFilterGenerator() ITK_OVERRIDE {} + ~GaborFilterGenerator() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Generate the filter coefficients */ void GenerateFilter(); /** Reimplement the Modified() method *to set the NeedToGenerateFilter to true */ - void Modified() const ITK_OVERRIDE; + void Modified() const override; private: GaborFilterGenerator(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Convolution/include/otbOverlapSaveConvolutionImageFilter.h b/Modules/Filtering/Convolution/include/otbOverlapSaveConvolutionImageFilter.h index 6ecf591280..a72ed2dfa9 100644 --- a/Modules/Filtering/Convolution/include/otbOverlapSaveConvolutionImageFilter.h +++ b/Modules/Filtering/Convolution/include/otbOverlapSaveConvolutionImageFilter.h @@ -142,7 +142,7 @@ public: * region than the output region. */ void GenerateInputRequestedRegion() - throw(itk::InvalidRequestedRegionError) ITK_OVERRIDE; + throw(itk::InvalidRequestedRegionError) override; #ifdef ITK_USE_CONCEPT_CHECKING /** Begin concept checking */ @@ -154,13 +154,13 @@ protected: /** Constructor */ OverlapSaveConvolutionImageFilter(); /** destructor */ - ~OverlapSaveConvolutionImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~OverlapSaveConvolutionImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /* TODO For the moment this class provide only a GenerateData(), * due to limited thread-safety of FFTW plan creation. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; // void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId); private: diff --git a/Modules/Filtering/DEM/include/otbDEMCaracteristicsExtractor.h b/Modules/Filtering/DEM/include/otbDEMCaracteristicsExtractor.h index cfa03e7a8d..110850719e 100644 --- a/Modules/Filtering/DEM/include/otbDEMCaracteristicsExtractor.h +++ b/Modules/Filtering/DEM/include/otbDEMCaracteristicsExtractor.h @@ -144,11 +144,11 @@ public: protected: DEMCaracteristicsExtractor(); - ~DEMCaracteristicsExtractor() ITK_OVERRIDE; + ~DEMCaracteristicsExtractor() override; /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: /** Angle parameters*/ diff --git a/Modules/Filtering/DEM/include/otbDEMToImageGenerator.h b/Modules/Filtering/DEM/include/otbDEMToImageGenerator.h index 26464e39fc..cc1e5d4de7 100644 --- a/Modules/Filtering/DEM/include/otbDEMToImageGenerator.h +++ b/Modules/Filtering/DEM/include/otbDEMToImageGenerator.h @@ -176,13 +176,13 @@ public: protected: DEMToImageGenerator(); - ~DEMToImageGenerator() ITK_OVERRIDE{} + ~DEMToImageGenerator() override{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + void BeforeThreadedGenerateData() override; void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; + itk::ThreadIdType threadId) override; + void GenerateOutputInformation() override; DEMHandlerType::Pointer m_DEMHandler; PointType m_OutputOrigin; diff --git a/Modules/Filtering/DimensionalityReduction/include/otbAngularProjectionBinaryImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbAngularProjectionBinaryImageFilter.h index 2497d6b0ee..5dd2c46622 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbAngularProjectionBinaryImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbAngularProjectionBinaryImageFilter.h @@ -89,10 +89,10 @@ public: protected: AngularProjectionBinaryImageFilter(); - ~AngularProjectionBinaryImageFilter() ITK_OVERRIDE { } + ~AngularProjectionBinaryImageFilter() override { } - void GenerateOutputInformation() ITK_OVERRIDE; - void ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, itk::ThreadIdType threadID ) ITK_OVERRIDE; + void GenerateOutputInformation() override; + void ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, itk::ThreadIdType threadID ) override; private: AngularProjectionBinaryImageFilter(const Self&); // not implemented diff --git a/Modules/Filtering/DimensionalityReduction/include/otbAngularProjectionImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbAngularProjectionImageFilter.h index f7976fe05f..4a8a4f906c 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbAngularProjectionImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbAngularProjectionImageFilter.h @@ -84,7 +84,7 @@ public: itkGetMacro(AngleArray, AngleArrayType); itkSetMacro(AngleArray, AngleArrayType); - void SetInput ( unsigned int i, const InputImageType * ) ITK_OVERRIDE; + void SetInput ( unsigned int i, const InputImageType * ) override; using Superclass::SetInput; const InputImageType * GetInput( unsigned int i ) const; @@ -92,9 +92,9 @@ public: protected: AngularProjectionImageFilter(); - ~AngularProjectionImageFilter() ITK_OVERRIDE { } + ~AngularProjectionImageFilter() override { } - void ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, itk::ThreadIdType threadID ) ITK_OVERRIDE; + void ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, itk::ThreadIdType threadID ) override; virtual OutputImagePixelType InternalGenerateData ( const ImageRegionConstIteratorVectorType & ) const; private: diff --git a/Modules/Filtering/DimensionalityReduction/include/otbAngularProjectionSetImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbAngularProjectionSetImageFilter.h index 3b1e8e2b12..9a8bdd9e4f 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbAngularProjectionSetImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbAngularProjectionSetImageFilter.h @@ -126,9 +126,9 @@ public: protected: AngularProjectionSetImageFilter(); - ~AngularProjectionSetImageFilter() ITK_OVERRIDE { } + ~AngularProjectionSetImageFilter() override { } - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: AngularProjectionSetImageFilter(const Self&); // not implemented diff --git a/Modules/Filtering/DimensionalityReduction/include/otbEstimateInnerProductPCAImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbEstimateInnerProductPCAImageFilter.h index 870d196f1b..1864a7e5f9 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbEstimateInnerProductPCAImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbEstimateInnerProductPCAImageFilter.h @@ -78,21 +78,21 @@ public: protected: EstimateInnerProductPCAImageFilter(); - ~EstimateInnerProductPCAImageFilter() ITK_OVERRIDE {} + ~EstimateInnerProductPCAImageFilter() override {} /** GenerateOutputInformation * Set the number of bands of the output. * Copy information from the first image of the list if existing. **/ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** * BeforeThreadedGenerateData **/ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: EstimateInnerProductPCAImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/DimensionalityReduction/include/otbFastICAImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbFastICAImageFilter.h index aab7b1a5cd..5e9d614342 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbFastICAImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbFastICAImageFilter.h @@ -149,7 +149,7 @@ public: protected: FastICAImageFilter (); - ~FastICAImageFilter() ITK_OVERRIDE { } + ~FastICAImageFilter() override { } /** GenerateOutputInformation * Propagate vector length info and modify if needed @@ -159,12 +159,12 @@ protected: * (which may not be square) has to be given, * otherwize, GenerateOutputInformation throws an itk::ExceptionObject */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** GenerateData * Through a filter of filter structure */ - void GenerateData () ITK_OVERRIDE; + void GenerateData () override; /** Internal methods */ void ForwardGenerateOutputInformation(); diff --git a/Modules/Filtering/DimensionalityReduction/include/otbFastICAInternalOptimizerVectorImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbFastICAInternalOptimizerVectorImageFilter.h index ed81ac736e..30be138c35 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbFastICAInternalOptimizerVectorImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbFastICAInternalOptimizerVectorImageFilter.h @@ -96,12 +96,12 @@ public: protected: FastICAInternalOptimizerVectorImageFilter(); - ~FastICAInternalOptimizerVectorImageFilter() ITK_OVERRIDE { } + ~FastICAInternalOptimizerVectorImageFilter() override { } - void GenerateOutputInformation() ITK_OVERRIDE; - void BeforeThreadedGenerateData () ITK_OVERRIDE; - void ThreadedGenerateData ( const OutputRegionType &, itk::ThreadIdType ) ITK_OVERRIDE; - void AfterThreadedGenerateData() ITK_OVERRIDE; + void GenerateOutputInformation() override; + void BeforeThreadedGenerateData () override; + void ThreadedGenerateData ( const OutputRegionType &, itk::ThreadIdType ) override; + void AfterThreadedGenerateData() override; unsigned int m_CurrentBandForLoop; diff --git a/Modules/Filtering/DimensionalityReduction/include/otbInnerProductPCAImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbInnerProductPCAImageFilter.h index b92d7f619f..d63ad8da0f 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbInnerProductPCAImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbInnerProductPCAImageFilter.h @@ -121,13 +121,13 @@ public: protected: /** GenerateData */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Constructor */ InnerProductPCAImageFilter(); /** Destructor */ - ~InnerProductPCAImageFilter() ITK_OVERRIDE {} + ~InnerProductPCAImageFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** NormalizeInnerProductPCAImageFilter can produce an image which is a different * resolution than its input image. As such, NormalizeInnerProductPCAImageFilter @@ -137,7 +137,7 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: InnerProductPCAImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/DimensionalityReduction/include/otbLocalActivityVectorImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbLocalActivityVectorImageFilter.h index 5f9816285f..cb48b11886 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbLocalActivityVectorImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbLocalActivityVectorImageFilter.h @@ -109,7 +109,7 @@ public: protected: LocalActivityVectorImageFilter() { } - ~LocalActivityVectorImageFilter() ITK_OVERRIDE { } + ~LocalActivityVectorImageFilter() override { } private: LocalActivityVectorImageFilter( const Self & ); // Not implemented diff --git a/Modules/Filtering/DimensionalityReduction/include/otbMNFImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbMNFImageFilter.h index 50557f1fe2..5fb0c7812a 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbMNFImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbMNFImageFilter.h @@ -149,7 +149,7 @@ public: protected: MNFImageFilter(); - ~MNFImageFilter() ITK_OVERRIDE { } + ~MNFImageFilter() override { } /** GenerateOutputInformation * Propagate vector length info and modify if needed @@ -159,14 +159,14 @@ protected: * (which may not be square) has to be given, * otherwize, GenerateOutputInformation throws an itk::ExceptionObject */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** GenerateData * Through a filter of filter structure */ - void GenerateData () ITK_OVERRIDE; + void GenerateData () override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Internal methods */ void ForwardGenerateOutputInformation(); diff --git a/Modules/Filtering/DimensionalityReduction/include/otbMaximumAutocorrelationFactorImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbMaximumAutocorrelationFactorImageFilter.h index 6acb4c466f..d32b18d0a9 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbMaximumAutocorrelationFactorImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbMaximumAutocorrelationFactorImageFilter.h @@ -134,11 +134,11 @@ public: protected: MaximumAutocorrelationFactorImageFilter(); - ~MaximumAutocorrelationFactorImageFilter() ITK_OVERRIDE {} + ~MaximumAutocorrelationFactorImageFilter() override {} - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: MaximumAutocorrelationFactorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/DimensionalityReduction/include/otbNAPCAImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbNAPCAImageFilter.h index c7847771c3..791d9cc993 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbNAPCAImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbNAPCAImageFilter.h @@ -89,10 +89,10 @@ public: protected: NAPCAImageFilter() { } - ~NAPCAImageFilter () ITK_OVERRIDE { } + ~NAPCAImageFilter () override { } /** Specific functionality of NAPCA */ - void GenerateTransformationMatrix() ITK_OVERRIDE; + void GenerateTransformationMatrix() override; }; // end of class } // end of namespace otb diff --git a/Modules/Filtering/DimensionalityReduction/include/otbNormalizeInnerProductPCAImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbNormalizeInnerProductPCAImageFilter.h index d58f83aaec..ed2e9055c9 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbNormalizeInnerProductPCAImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbNormalizeInnerProductPCAImageFilter.h @@ -82,7 +82,7 @@ public: protected: NormalizeInnerProductPCAImageFilter(); - ~NormalizeInnerProductPCAImageFilter() ITK_OVERRIDE {} + ~NormalizeInnerProductPCAImageFilter() override {} /** NormalizeInnerProductPCAImageFilter can produce an image which is a different * resolution than its input image. As such, NormalizeInnerProductPCAImageFilter @@ -92,7 +92,7 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** NormalizeInnerProductPCAImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -104,12 +104,12 @@ protected: * * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** BeforeThreadedGenerateData method */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Filtering/DimensionalityReduction/include/otbPCAImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbPCAImageFilter.h index 63f69b86c1..4b64ed6c90 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbPCAImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbPCAImageFilter.h @@ -161,7 +161,7 @@ public: protected: PCAImageFilter(); - ~PCAImageFilter() ITK_OVERRIDE { } + ~PCAImageFilter() override { } /** GenerateOutputInformation * Propagate vector length info and modify if needed @@ -171,14 +171,14 @@ protected: * (which may not be square) has to be given, * otherwize, GenerateOutputInformation throws an itk::ExceptionObject */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** GenerateData * Through a filter of filter structure */ - void GenerateData () ITK_OVERRIDE; + void GenerateData () override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Internal methods */ virtual void ForwardGenerateOutputInformation(); diff --git a/Modules/Filtering/DimensionalityReduction/include/otbSparseWvltToAngleMapperListFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbSparseWvltToAngleMapperListFilter.h index cae9cbb747..c419eb0937 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbSparseWvltToAngleMapperListFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbSparseWvltToAngleMapperListFilter.h @@ -108,16 +108,16 @@ public: protected: SparseWvltToAngleMapperListFilter(); - ~SparseWvltToAngleMapperListFilter() ITK_OVERRIDE { } + ~SparseWvltToAngleMapperListFilter() override { } /** Standard itk::ProcessObject subclass method. */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** This method causes the filter to generate its output. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /* Internal functions */ virtual bool IsToGenerate ( const ImageConstIteratorVectorType & ) const; diff --git a/Modules/Filtering/ImageManipulation/include/otbAmplitudeFunctor.h b/Modules/Filtering/ImageManipulation/include/otbAmplitudeFunctor.h index da27e0389d..a543b2ae58 100644 --- a/Modules/Filtering/ImageManipulation/include/otbAmplitudeFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbAmplitudeFunctor.h @@ -70,17 +70,17 @@ public: } /** Destructor */ - ~AmplitudeFunctor() ITK_OVERRIDE {} + ~AmplitudeFunctor() override {} const char *GetDescription() const {return "Amplitude"; } - unsigned int GetOutputSize() const ITK_OVERRIDE + unsigned int GetOutputSize() const override { return 1; } - OutputPixelType operator ()(const VectorPixelType& inPixel) const ITK_OVERRIDE + OutputPixelType operator ()(const VectorPixelType& inPixel) const override { OutputPixelType outPixel; outPixel.SetSize(1); @@ -91,13 +91,13 @@ public: return outPixel; } - OutputPixelType operator ()(ScalarType) const ITK_OVERRIDE + OutputPixelType operator ()(ScalarType) const override { //FIXME we don't handle the std::complex<> yet itkExceptionMacro(<< "Can't compute amplitude from a scalar value"); } - OutputPixelType operator ()(const RGBPixelType& inPixel) const ITK_OVERRIDE + OutputPixelType operator ()(const RGBPixelType& inPixel) const override { OutputPixelType outPixel; outPixel.SetSize(1); @@ -110,7 +110,7 @@ public: return outPixel; } - OutputPixelType operator ()(const RGBAPixelType& inPixel) const ITK_OVERRIDE + OutputPixelType operator ()(const RGBAPixelType& inPixel) const override { OutputPixelType outPixel; outPixel.SetSize(1); diff --git a/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorImageFilter.h index e0e246aee5..ec60c693df 100644 --- a/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorImageFilter.h @@ -55,7 +55,7 @@ public: protected: BinaryFunctorImageFilter() {}; - ~BinaryFunctorImageFilter() ITK_OVERRIDE {} + ~BinaryFunctorImageFilter() override {} /** BinaryFunctorImageFilter can produce an image which has a different number of bands * than its input image. As such, BinaryFunctorImageFilter @@ -65,7 +65,7 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE + void GenerateOutputInformation() override { Superclass::GenerateOutputInformation(); typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); diff --git a/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodImageFilter.h index 2b0cc52d13..a8f69d607e 100644 --- a/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodImageFilter.h @@ -130,7 +130,7 @@ public: protected: BinaryFunctorNeighborhoodImageFilter(); - ~BinaryFunctorNeighborhoodImageFilter() ITK_OVERRIDE {} + ~BinaryFunctorNeighborhoodImageFilter() override {} /** BinaryFunctorNeighborhoodImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -143,12 +143,12 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; /** * Pad the inputs requested regions by radius */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; RadiusSizeType m_Radius; diff --git a/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodVectorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodVectorImageFilter.h index d282ec933b..dfc99b5f0b 100644 --- a/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodVectorImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodVectorImageFilter.h @@ -119,7 +119,7 @@ public: protected: BinaryFunctorNeighborhoodVectorImageFilter(); - ~BinaryFunctorNeighborhoodVectorImageFilter() ITK_OVERRIDE {} + ~BinaryFunctorNeighborhoodVectorImageFilter() override {} /** BinaryFunctorNeighborhoodVectorImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -132,13 +132,13 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; /** * Since the number of components per pixel depends on the radius range, one must reimplement * this method to set the proper number of component on the filter output. */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; RadiusSizeType m_Radius; diff --git a/Modules/Filtering/ImageManipulation/include/otbBinaryImageDensityFunction.h b/Modules/Filtering/ImageManipulation/include/otbBinaryImageDensityFunction.h index a751322a72..8ab7e0c989 100644 --- a/Modules/Filtering/ImageManipulation/include/otbBinaryImageDensityFunction.h +++ b/Modules/Filtering/ImageManipulation/include/otbBinaryImageDensityFunction.h @@ -78,17 +78,17 @@ public: RealType; /** Evalulate the function at specified index */ - RealType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + RealType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - RealType Evaluate(const PointType& point) const ITK_OVERRIDE + RealType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } RealType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -107,8 +107,8 @@ public: protected: BinaryImageDensityFunction(); - ~BinaryImageDensityFunction() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~BinaryImageDensityFunction() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: BinaryImageDensityFunction(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbBinaryImageMinimalBoundingRegionCalculator.h b/Modules/Filtering/ImageManipulation/include/otbBinaryImageMinimalBoundingRegionCalculator.h index 2a420761d1..fea7f9a8e8 100644 --- a/Modules/Filtering/ImageManipulation/include/otbBinaryImageMinimalBoundingRegionCalculator.h +++ b/Modules/Filtering/ImageManipulation/include/otbBinaryImageMinimalBoundingRegionCalculator.h @@ -70,11 +70,11 @@ protected: /** Constructor */ BinaryImageMinimalBoundingRegionCalculator(); /** Destructor */ - ~BinaryImageMinimalBoundingRegionCalculator() ITK_OVERRIDE {} + ~BinaryImageMinimalBoundingRegionCalculator() override {} /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: BinaryImageMinimalBoundingRegionCalculator(const Self &); // purposely not implemented void operator =(const Self&); // purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbBinaryImageToDensityImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbBinaryImageToDensityImageFilter.h index 7f0e16a0e9..029b9344b3 100644 --- a/Modules/Filtering/ImageManipulation/include/otbBinaryImageToDensityImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbBinaryImageToDensityImageFilter.h @@ -77,17 +77,17 @@ public: } /** Main computation method */ - void ThreadedGenerateData(const InputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; - void BeforeThreadedGenerateData() ITK_OVERRIDE; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void ThreadedGenerateData(const InputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; + void BeforeThreadedGenerateData() override; + void GenerateInputRequestedRegion() override; protected: /** Constructor */ BinaryImageToDensityImageFilter(); /** Destructor */ - ~BinaryImageToDensityImageFilter() ITK_OVERRIDE; + ~BinaryImageToDensityImageFilter() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: BinaryImageToDensityImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbBoxAndWhiskerImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbBoxAndWhiskerImageFilter.h index 67203519be..1bd82ea6dd 100644 --- a/Modules/Filtering/ImageManipulation/include/otbBoxAndWhiskerImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbBoxAndWhiskerImageFilter.h @@ -94,12 +94,12 @@ public: protected: BoxAndWhiskerImageFilter (); - ~BoxAndWhiskerImageFilter () ITK_OVERRIDE {} + ~BoxAndWhiskerImageFilter () override {} /** Main computation method implemented as a multithreaded filter */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; - void AllocateOutputs() ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; + void GenerateOutputInformation() override; + void AllocateOutputs() override; /** Perform the outlier detection */ PixelType PerformBoxAndWhiskerDetection(const PixelType& pixel); diff --git a/Modules/Filtering/ImageManipulation/include/otbChangeInformationImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbChangeInformationImageFilter.h index 7ae72a4706..3bbce052ee 100644 --- a/Modules/Filtering/ImageManipulation/include/otbChangeInformationImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbChangeInformationImageFilter.h @@ -69,10 +69,10 @@ public: protected: ChangeInformationImageFilter() {} - ~ChangeInformationImageFilter() ITK_OVERRIDE {} + ~ChangeInformationImageFilter() override {} /** Apply changes to the output image metadata. */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: ChangeInformationImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbChangeLabelImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbChangeLabelImageFilter.h index 9c32e30611..b367f140c8 100644 --- a/Modules/Filtering/ImageManipulation/include/otbChangeLabelImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbChangeLabelImageFilter.h @@ -165,11 +165,11 @@ public: protected: ChangeLabelImageFilter(); - ~ChangeLabelImageFilter() ITK_OVERRIDE {} + ~ChangeLabelImageFilter() override {} /** Generate the output information missing */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ChangeLabelImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbChangeNoDataValueFilter.h b/Modules/Filtering/ImageManipulation/include/otbChangeNoDataValueFilter.h index 5ab3cf2435..d19f2184a3 100644 --- a/Modules/Filtering/ImageManipulation/include/otbChangeNoDataValueFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbChangeNoDataValueFilter.h @@ -137,10 +137,10 @@ protected: ChangeNoDataValueFilter() {} - ~ChangeNoDataValueFilter() ITK_OVERRIDE + ~ChangeNoDataValueFilter() override {} - void GenerateOutputInformation() ITK_OVERRIDE + void GenerateOutputInformation() override { Superclass::GenerateOutputInformation(); diff --git a/Modules/Filtering/ImageManipulation/include/otbClampVectorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbClampVectorImageFilter.h index 50b43302e4..84ff84cb59 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampVectorImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbClampVectorImageFilter.h @@ -107,8 +107,8 @@ public: protected: ClampVectorImageFilter(); - ~ClampVectorImageFilter() ITK_OVERRIDE {}; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ClampVectorImageFilter() override {}; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** ClampVectorImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -121,9 +121,9 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId ) ITK_OVERRIDE; + itk::ThreadIdType threadId ) override; - void GenerateOutputInformation(void) ITK_OVERRIDE + void GenerateOutputInformation(void) override { Superclass::GenerateOutputInformation(); diff --git a/Modules/Filtering/ImageManipulation/include/otbConcatenateScalarValueImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbConcatenateScalarValueImageFilter.h index dcb79a8f25..7f9cf3f068 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConcatenateScalarValueImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbConcatenateScalarValueImageFilter.h @@ -141,11 +141,11 @@ public: protected: ConcatenateScalarValueImageFilter(); - ~ConcatenateScalarValueImageFilter() ITK_OVERRIDE {} + ~ConcatenateScalarValueImageFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: ConcatenateScalarValueImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbConcatenateVectorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbConcatenateVectorImageFilter.h index 06bfad6d0d..30fad1ad60 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConcatenateVectorImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbConcatenateVectorImageFilter.h @@ -95,13 +95,13 @@ protected: /** Constructor. */ ConcatenateVectorImageFilter(); /** Destructor. */ - ~ConcatenateVectorImageFilter() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + ~ConcatenateVectorImageFilter() override; + void GenerateOutputInformation() override; + void BeforeThreadedGenerateData() override; /** Main computation method. */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ConcatenateVectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbEuclideanDistanceMetricWithMissingValue.h b/Modules/Filtering/ImageManipulation/include/otbEuclideanDistanceMetricWithMissingValue.h index 4d802c46ea..37e08144ba 100644 --- a/Modules/Filtering/ImageManipulation/include/otbEuclideanDistanceMetricWithMissingValue.h +++ b/Modules/Filtering/ImageManipulation/include/otbEuclideanDistanceMetricWithMissingValue.h @@ -70,13 +70,13 @@ public: typedef typename TVector::ValueType ValueType; /** Gets the distance between the origin and x */ - double Evaluate(const TVector& x) const ITK_OVERRIDE + double Evaluate(const TVector& x) const override { return ::vcl_sqrt(Superclass::Evaluate(x)); } /** Gets the distance between x1 and x2 */ - double Evaluate(const TVector& x1, const TVector& x2) const ITK_OVERRIDE + double Evaluate(const TVector& x1, const TVector& x2) const override { return ::vcl_sqrt(Superclass::Evaluate(x1, x2)); } @@ -97,7 +97,7 @@ public: protected: EuclideanDistanceMetricWithMissingValue() {} - ~EuclideanDistanceMetricWithMissingValue() ITK_OVERRIDE {} + ~EuclideanDistanceMetricWithMissingValue() override {} }; // end of class } // end namespace statistics diff --git a/Modules/Filtering/ImageManipulation/include/otbEuclideanDistanceMetricWithMissingValuePow2.h b/Modules/Filtering/ImageManipulation/include/otbEuclideanDistanceMetricWithMissingValuePow2.h index 49b8885bbe..3fe2d4f77a 100644 --- a/Modules/Filtering/ImageManipulation/include/otbEuclideanDistanceMetricWithMissingValuePow2.h +++ b/Modules/Filtering/ImageManipulation/include/otbEuclideanDistanceMetricWithMissingValuePow2.h @@ -69,10 +69,10 @@ public: typedef typename TVector::ValueType ValueType; /** Gets the distance between the origin and x */ - double Evaluate(const TVector& x) const ITK_OVERRIDE; + double Evaluate(const TVector& x) const override; /** Gets the distance between x1 and x2 */ - double Evaluate(const TVector& x1, const TVector& x2) const ITK_OVERRIDE; + double Evaluate(const TVector& x1, const TVector& x2) const override; /** Gets the cooridnate distance between a and b. NOTE: a and b * should be type of component */ @@ -93,7 +93,7 @@ public: protected: EuclideanDistanceMetricWithMissingValuePow2() {} - ~EuclideanDistanceMetricWithMissingValuePow2() ITK_OVERRIDE {} + ~EuclideanDistanceMetricWithMissingValuePow2() override {} }; // end of class } // end namespace statistics diff --git a/Modules/Filtering/ImageManipulation/include/otbFlexibleDistanceWithMissingValue.h b/Modules/Filtering/ImageManipulation/include/otbFlexibleDistanceWithMissingValue.h index 05298aa14d..3a703c921a 100644 --- a/Modules/Filtering/ImageManipulation/include/otbFlexibleDistanceWithMissingValue.h +++ b/Modules/Filtering/ImageManipulation/include/otbFlexibleDistanceWithMissingValue.h @@ -73,10 +73,10 @@ public: typedef typename TVector::ValueType ValueType; /** Gets the distance between the origin and x */ - double Evaluate(const TVector& x) const ITK_OVERRIDE; + double Evaluate(const TVector& x) const override; /** Gets the distance between x1 and x2 */ - double Evaluate(const TVector& x1, const TVector& x2) const ITK_OVERRIDE; + double Evaluate(const TVector& x1, const TVector& x2) const override; /** Gets the cooridnate distance between a and b. NOTE: a and b * should be type of component */ @@ -101,7 +101,7 @@ public: protected: FlexibleDistanceWithMissingValue() {} - ~FlexibleDistanceWithMissingValue() ITK_OVERRIDE {} + ~FlexibleDistanceWithMissingValue() override {} }; // end of class /** Static variable instantiation */ diff --git a/Modules/Filtering/ImageManipulation/include/otbFunctionWithNeighborhoodToImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbFunctionWithNeighborhoodToImageFilter.h index 2febd16f5f..61168d59d1 100644 --- a/Modules/Filtering/ImageManipulation/include/otbFunctionWithNeighborhoodToImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbFunctionWithNeighborhoodToImageFilter.h @@ -122,11 +122,11 @@ public: protected: FunctionWithNeighborhoodToImageFilter(); - ~FunctionWithNeighborhoodToImageFilter() ITK_OVERRIDE{} + ~FunctionWithNeighborhoodToImageFilter() override{} - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** SpatialFunctionImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -139,7 +139,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: FunctionWithNeighborhoodToImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbGridResampleImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbGridResampleImageFilter.h index b67760965c..23655ef667 100644 --- a/Modules/Filtering/ImageManipulation/include/otbGridResampleImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbGridResampleImageFilter.h @@ -137,23 +137,23 @@ public: void SetOutputParametersFromImage(const ImageBaseType * image); /** Method Compute the Modified Time based on changed to the components. */ - itk::ModifiedTimeType GetMTime(void) const ITK_OVERRIDE; + itk::ModifiedTimeType GetMTime(void) const override; protected: GridResampleImageFilter(); /** Destructor */ - ~GridResampleImageFilter() ITK_OVERRIDE {}; + ~GridResampleImageFilter() override {}; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; - void AfterThreadedGenerateData() ITK_OVERRIDE; + void AfterThreadedGenerateData() override; inline void CastPixelWithBoundsChecking( const InterpolatorOutputType& value, const InterpolatorComponentType& minComponent, @@ -186,7 +186,7 @@ protected: } - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: GridResampleImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbHillShadingFilter.h b/Modules/Filtering/ImageManipulation/include/otbHillShadingFilter.h index 8463f1821a..9779f1de6f 100644 --- a/Modules/Filtering/ImageManipulation/include/otbHillShadingFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbHillShadingFilter.h @@ -82,7 +82,7 @@ public: protected: HillShadingFilter() {} - ~HillShadingFilter() ITK_OVERRIDE {} + ~HillShadingFilter() override {} private: HillShadingFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbImageToNoDataMaskFilter.h b/Modules/Filtering/ImageManipulation/include/otbImageToNoDataMaskFilter.h index 5f96a9652e..8ec6c7850a 100644 --- a/Modules/Filtering/ImageManipulation/include/otbImageToNoDataMaskFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbImageToNoDataMaskFilter.h @@ -133,10 +133,10 @@ protected: ImageToNoDataMaskFilter() {} - ~ImageToNoDataMaskFilter() ITK_OVERRIDE + ~ImageToNoDataMaskFilter() override {} - void BeforeThreadedGenerateData() ITK_OVERRIDE + void BeforeThreadedGenerateData() override { std::vector<bool> noDataValueAvailable; std::vector<double> noDataValues; diff --git a/Modules/Filtering/ImageManipulation/include/otbImageToVectorImageCastFilter.h b/Modules/Filtering/ImageManipulation/include/otbImageToVectorImageCastFilter.h index 49d44f57c2..3425e90a5e 100644 --- a/Modules/Filtering/ImageManipulation/include/otbImageToVectorImageCastFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbImageToVectorImageCastFilter.h @@ -96,15 +96,15 @@ protected: /// Constructor ImageToVectorImageCastFilter() {} /// Detructor - ~ImageToVectorImageCastFilter() ITK_OVERRIDE {} + ~ImageToVectorImageCastFilter() override {} /// Additional output information for allocation - void GenerateOutputInformation(void) ITK_OVERRIDE + void GenerateOutputInformation(void) override { Superclass::GenerateOutputInformation(); this->GetOutput()->SetNumberOfComponentsPerPixel(1); } /// Copy output requested region to input requested region - void GenerateInputRequestedRegion(void) ITK_OVERRIDE + void GenerateInputRequestedRegion(void) override { if (this->GetInput()) { diff --git a/Modules/Filtering/ImageManipulation/include/otbLocalGradientVectorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbLocalGradientVectorImageFilter.h index b7e90fae49..f2bf9db5f4 100644 --- a/Modules/Filtering/ImageManipulation/include/otbLocalGradientVectorImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbLocalGradientVectorImageFilter.h @@ -96,7 +96,7 @@ protected: typename Superclass::RadiusType radius = {{1, 1}}; this->SetRadius( radius ); } - ~LocalGradientVectorImageFilter() ITK_OVERRIDE { } + ~LocalGradientVectorImageFilter() override { } private: LocalGradientVectorImageFilter( const Self & ); // Not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbLog10ThresholdedImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbLog10ThresholdedImageFilter.h index bd5882214c..36c7fb14bb 100644 --- a/Modules/Filtering/ImageManipulation/include/otbLog10ThresholdedImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbLog10ThresholdedImageFilter.h @@ -104,7 +104,7 @@ public: } protected: Log10ThresholdedImageFilter() {} - ~Log10ThresholdedImageFilter() ITK_OVERRIDE {} + ~Log10ThresholdedImageFilter() override {} private: Log10ThresholdedImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbMatrixImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbMatrixImageFilter.h index 4199951dfa..611dc22ef3 100644 --- a/Modules/Filtering/ImageManipulation/include/otbMatrixImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbMatrixImageFilter.h @@ -111,13 +111,13 @@ public: protected: MatrixImageFilter(); - ~MatrixImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~MatrixImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Before threaded generate data method. */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** MatrixImageFilter can be implemented for a multithreaded filter treatment. * Thus, this implementation give the ThreadedGenerateData() method. @@ -128,7 +128,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: MatrixImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbMultiplyByScalarImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbMultiplyByScalarImageFilter.h index 3f0f6c678b..8cc130a728 100644 --- a/Modules/Filtering/ImageManipulation/include/otbMultiplyByScalarImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbMultiplyByScalarImageFilter.h @@ -101,7 +101,7 @@ public: } protected: MultiplyByScalarImageFilter() {} - ~MultiplyByScalarImageFilter() ITK_OVERRIDE {} + ~MultiplyByScalarImageFilter() override {} private: MultiplyByScalarImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbNRIBandImagesToOneNComplexBandsImage.h b/Modules/Filtering/ImageManipulation/include/otbNRIBandImagesToOneNComplexBandsImage.h index 205da84a19..9d482cd70d 100644 --- a/Modules/Filtering/ImageManipulation/include/otbNRIBandImagesToOneNComplexBandsImage.h +++ b/Modules/Filtering/ImageManipulation/include/otbNRIBandImagesToOneNComplexBandsImage.h @@ -72,13 +72,13 @@ public: protected: NRIBandImagesToOneNComplexBandsImage(); - ~NRIBandImagesToOneNComplexBandsImage() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~NRIBandImagesToOneNComplexBandsImage() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateOutputInformation(void) ITK_OVERRIDE; - void BeforeThreadedGenerateData(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; + void BeforeThreadedGenerateData(void) override; void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: NRIBandImagesToOneNComplexBandsImage(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbOneRIBandImageToOneComplexBandImage.h b/Modules/Filtering/ImageManipulation/include/otbOneRIBandImageToOneComplexBandImage.h index 01fe68c115..faf49f1b09 100644 --- a/Modules/Filtering/ImageManipulation/include/otbOneRIBandImageToOneComplexBandImage.h +++ b/Modules/Filtering/ImageManipulation/include/otbOneRIBandImageToOneComplexBandImage.h @@ -73,12 +73,12 @@ public: protected: OneRIBandImageToOneComplexBandImage(); - ~OneRIBandImageToOneComplexBandImage() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~OneRIBandImageToOneComplexBandImage() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void BeforeThreadedGenerateData(void) ITK_OVERRIDE; + void BeforeThreadedGenerateData(void) override; void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: OneRIBandImageToOneComplexBandImage(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbPerBandVectorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbPerBandVectorImageFilter.h index 82f6019425..9654ccebf4 100644 --- a/Modules/Filtering/ImageManipulation/include/otbPerBandVectorImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbPerBandVectorImageFilter.h @@ -94,18 +94,18 @@ public: itkSetMacro(OutputIndex, unsigned int); itkGetMacro(OutputIndex, unsigned int); - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; + void GenerateOutputInformation(void) override; protected: /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Constructor */ PerBandVectorImageFilter(); /** Destructor */ - ~PerBandVectorImageFilter() ITK_OVERRIDE {} + ~PerBandVectorImageFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: PerBandVectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbPhaseFunctor.h b/Modules/Filtering/ImageManipulation/include/otbPhaseFunctor.h index 99646f8823..b289c7f4c7 100644 --- a/Modules/Filtering/ImageManipulation/include/otbPhaseFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbPhaseFunctor.h @@ -70,17 +70,17 @@ public: } /** Destructor */ - ~PhaseFunctor() ITK_OVERRIDE {} + ~PhaseFunctor() override {} const char *GetDescription() const {return "Phase"; } - unsigned int GetOutputSize() const ITK_OVERRIDE + unsigned int GetOutputSize() const override { return 1; } - OutputPixelType operator ()(const VectorPixelType& inPixel) const ITK_OVERRIDE + OutputPixelType operator ()(const VectorPixelType& inPixel) const override { OutputPixelType outPixel; outPixel.SetSize(1); @@ -91,13 +91,13 @@ public: return outPixel; } - OutputPixelType operator ()(ScalarType /*inPixel*/) const ITK_OVERRIDE + OutputPixelType operator ()(ScalarType /*inPixel*/) const override { //FIXME we don't handle the std::complex<> yet itkExceptionMacro(<< "Can't compute amplitude from a scalar value"); } - OutputPixelType operator ()(const RGBPixelType& inPixel) const ITK_OVERRIDE + OutputPixelType operator ()(const RGBPixelType& inPixel) const override { OutputPixelType outPixel; outPixel.SetSize(1); @@ -109,7 +109,7 @@ public: return outPixel; } - OutputPixelType operator ()(const RGBAPixelType& inPixel) const ITK_OVERRIDE + OutputPixelType operator ()(const RGBAPixelType& inPixel) const override { OutputPixelType outPixel; outPixel.SetSize(1); diff --git a/Modules/Filtering/ImageManipulation/include/otbPrintableImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbPrintableImageFilter.h index ee35f261fc..346a34f2ff 100644 --- a/Modules/Filtering/ImageManipulation/include/otbPrintableImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbPrintableImageFilter.h @@ -161,7 +161,7 @@ public: itk::ImageToImageFilter); /** Display */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; void SetChannel(unsigned int channel); const ChannelsType GetChannels(void) const; @@ -232,14 +232,14 @@ public: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; protected: PrintableImageFilter(); void BeforeGenerateData(); - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: diff --git a/Modules/Filtering/ImageManipulation/include/otbRealAndImaginaryImageToComplexImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbRealAndImaginaryImageToComplexImageFilter.h index 23d924f804..e473277d1c 100644 --- a/Modules/Filtering/ImageManipulation/include/otbRealAndImaginaryImageToComplexImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbRealAndImaginaryImageToComplexImageFilter.h @@ -116,7 +116,7 @@ public: protected: RealAndImaginaryImageToComplexImageFilter() {} - ~RealAndImaginaryImageToComplexImageFilter() ITK_OVERRIDE {} + ~RealAndImaginaryImageToComplexImageFilter() override {} private: RealAndImaginaryImageToComplexImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbRealImageToComplexImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbRealImageToComplexImageFilter.h index 8e86ee82f3..0c4168b247 100644 --- a/Modules/Filtering/ImageManipulation/include/otbRealImageToComplexImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbRealImageToComplexImageFilter.h @@ -93,7 +93,7 @@ public: protected: RealImageToComplexImageFilter() {} - ~RealImageToComplexImageFilter() ITK_OVERRIDE {} + ~RealImageToComplexImageFilter() override {} private: RealImageToComplexImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbShiftScaleImageAdaptor.h b/Modules/Filtering/ImageManipulation/include/otbShiftScaleImageAdaptor.h index b22dcd8e69..68f9865352 100644 --- a/Modules/Filtering/ImageManipulation/include/otbShiftScaleImageAdaptor.h +++ b/Modules/Filtering/ImageManipulation/include/otbShiftScaleImageAdaptor.h @@ -166,7 +166,7 @@ public: protected: ShiftScaleImageAdaptor() {} - ~ShiftScaleImageAdaptor() ITK_OVERRIDE {} + ~ShiftScaleImageAdaptor() override {} private: ShiftScaleImageAdaptor(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbShiftScaleVectorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbShiftScaleVectorImageFilter.h index 0d5868b6f9..9b90aee8cd 100644 --- a/Modules/Filtering/ImageManipulation/include/otbShiftScaleVectorImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbShiftScaleVectorImageFilter.h @@ -197,16 +197,16 @@ public: protected: ShiftScaleVectorImageFilter() {} - ~ShiftScaleVectorImageFilter() ITK_OVERRIDE {} + ~ShiftScaleVectorImageFilter() override {} /** Process to execute before entering the multithreaded section */ - void BeforeThreadedGenerateData(void) ITK_OVERRIDE; + void BeforeThreadedGenerateData(void) override; /** Generate output information */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** Generate input requested region */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; private: ShiftScaleVectorImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbSpectralAngleDistanceImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbSpectralAngleDistanceImageFilter.h index b071637c6f..7cf4f3c442 100644 --- a/Modules/Filtering/ImageManipulation/include/otbSpectralAngleDistanceImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbSpectralAngleDistanceImageFilter.h @@ -84,9 +84,9 @@ protected: /** Constructor */ SpectralAngleDistanceImageFilter(); /** Destructor */ - ~SpectralAngleDistanceImageFilter() ITK_OVERRIDE {} + ~SpectralAngleDistanceImageFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** SpectralAngleDistanceImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine * which is called for each processing thread. The output image data is @@ -98,9 +98,9 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; private: SpectralAngleDistanceImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbSqrtSpectralAngleFunctor.h b/Modules/Filtering/ImageManipulation/include/otbSqrtSpectralAngleFunctor.h index 7f06d1c3de..48226356e2 100644 --- a/Modules/Filtering/ImageManipulation/include/otbSqrtSpectralAngleFunctor.h +++ b/Modules/Filtering/ImageManipulation/include/otbSqrtSpectralAngleFunctor.h @@ -43,10 +43,10 @@ public: typedef SpectralAngleFunctor<TInputVectorPixel, TOutputPixel> Superclass; SqrtSpectralAngleFunctor() {} - ~SqrtSpectralAngleFunctor() ITK_OVERRIDE {} + ~SqrtSpectralAngleFunctor() override {} protected: - TOutputPixel Evaluate(const TInputVectorPixel& inPix) const ITK_OVERRIDE + TOutputPixel Evaluate(const TInputVectorPixel& inPix) const override { return static_cast<TOutputPixel>(vcl_sqrt(Superclass::Evaluate(inPix))); } diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingInnerProductVectorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbStreamingInnerProductVectorImageFilter.h index da666dbb2a..423cbab313 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingInnerProductVectorImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingInnerProductVectorImageFilter.h @@ -102,16 +102,16 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; /** Pass the input through unmodified. Do this by Grafting in the * AllocateOutputs method. */ - void AllocateOutputs() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; - void Synthetize(void) ITK_OVERRIDE; - void Reset(void) ITK_OVERRIDE; + void AllocateOutputs() override; + void GenerateOutputInformation() override; + void Synthetize(void) override; + void Reset(void) override; /** Enable/Disable center data */ itkSetMacro(CenterData, bool); @@ -120,10 +120,10 @@ public: protected: PersistentInnerProductVectorImageFilter(); - ~PersistentInnerProductVectorImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PersistentInnerProductVectorImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Multi-thread version GenerateData. */ - void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override; private: PersistentInnerProductVectorImageFilter(const Self &); //purposely not implemented @@ -217,7 +217,7 @@ protected: /** Constructor */ StreamingInnerProductVectorImageFilter() {}; /** Destructor */ - ~StreamingInnerProductVectorImageFilter() ITK_OVERRIDE {} + ~StreamingInnerProductVectorImageFilter() override {} private: StreamingInnerProductVectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingMatrixTransposeMatrixImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbStreamingMatrixTransposeMatrixImageFilter.h index 3cb5ddb1a5..f79ead12bb 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingMatrixTransposeMatrixImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingMatrixTransposeMatrixImageFilter.h @@ -122,18 +122,18 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; /** Pass the input through unmodified. Do this by Grafting in the * AllocateOutputs method. */ - void AllocateOutputs() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; + void AllocateOutputs() override; + void GenerateOutputInformation() override; // Override since the filter needs all the data for the algorithm - void GenerateInputRequestedRegion() ITK_OVERRIDE; - void Reset(void) ITK_OVERRIDE; - void Synthetize(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; + void Reset(void) override; + void Synthetize(void) override; /** Input wrapper */ void SetFirstInput(const TInputImage *input1) @@ -165,10 +165,10 @@ public: protected: PersistentMatrixTransposeMatrixImageFilter(); - ~PersistentMatrixTransposeMatrixImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PersistentMatrixTransposeMatrixImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Multi-thread version GenerateData. */ - void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override; private: PersistentMatrixTransposeMatrixImageFilter(const Self &); //purposely not implemented @@ -274,7 +274,7 @@ protected: /** Constructor */ StreamingMatrixTransposeMatrixImageFilter() {}; /** Destructor */ - ~StreamingMatrixTransposeMatrixImageFilter() ITK_OVERRIDE {} + ~StreamingMatrixTransposeMatrixImageFilter() override {} private: StreamingMatrixTransposeMatrixImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.h index d42cea94c9..164d9d19e2 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.h @@ -172,19 +172,19 @@ public: } /** Override itk::ProcessObject method to let the internal filter do the propagation */ - void PropagateRequestedRegion(itk::DataObject *output) ITK_OVERRIDE; + void PropagateRequestedRegion(itk::DataObject *output) override; protected: StreamingResampleImageFilter(); /** Destructor */ - ~StreamingResampleImageFilter() ITK_OVERRIDE {}; + ~StreamingResampleImageFilter() override {}; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: StreamingResampleImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.h index c00878892f..c48e2d2e2e 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.h @@ -72,13 +72,13 @@ public: * a certain dimensions, then some splits will not be possible. */ unsigned int GetNumberOfSplits(const RegionType& region, - unsigned int requestedNumber) ITK_OVERRIDE; + unsigned int requestedNumber) override; /** Get a region definition that represents the ith piece a specified region. * The "numberOfPieces" specified should be less than or equal to what * GetNumberOfSplits() returns. */ RegionType GetSplit(unsigned int i, unsigned int numberOfPieces, - const RegionType& region) ITK_OVERRIDE; + const RegionType& region) override; itkGetMacro(TileSizeAlignment, unsigned int); @@ -89,8 +89,8 @@ public: protected: StreamingShrinkImageRegionSplitter() : m_SplitsPerDimension(0U), m_TileDimension(0), m_TileSizeAlignment(0), m_ShrinkFactor(10) {} - ~StreamingShrinkImageRegionSplitter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~StreamingShrinkImageRegionSplitter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: StreamingShrinkImageRegionSplitter(const StreamingShrinkImageRegionSplitter &); //purposely not implemented @@ -130,7 +130,7 @@ public: /** Actually computes the stream divisions, according to the specified streaming mode, * eventually using the input parameter to estimate memory consumption */ - void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) ITK_OVERRIDE; + void PrepareStreaming(itk::DataObject * input, const RegionType ®ion) override; void SetShrinkFactor(unsigned int val) { @@ -144,7 +144,7 @@ public: protected: StreamingShrinkStreamingManager(); - ~StreamingShrinkStreamingManager() ITK_OVERRIDE; + ~StreamingShrinkStreamingManager() override; private: StreamingShrinkStreamingManager(const StreamingShrinkStreamingManager &); //purposely not implemented @@ -203,9 +203,9 @@ public: return m_ShrunkOutput; } - void Synthetize(void) ITK_OVERRIDE; + void Synthetize(void) override; - void Reset(void) ITK_OVERRIDE; + void Reset(void) override; itkSetMacro(ShrinkFactor, unsigned int); itkGetMacro(ShrinkFactor, unsigned int); @@ -213,23 +213,23 @@ public: protected: PersistentShrinkImageFilter(); - ~PersistentShrinkImageFilter() ITK_OVERRIDE; + ~PersistentShrinkImageFilter() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Multi-thread version GenerateData. */ - void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override; - void AfterThreadedGenerateData() ITK_OVERRIDE; + void AfterThreadedGenerateData() override; /** Pass the input through unmodified. Do this by Grafting in the * AllocateOutputs method. */ - void AllocateOutputs() ITK_OVERRIDE; + void AllocateOutputs() override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: @@ -305,7 +305,7 @@ public: otbSetObjectMemberMacro(Filter, ShrinkFactor, unsigned int); otbGetObjectMemberMacro(Filter, ShrinkFactor, unsigned int); - void Update(void) ITK_OVERRIDE + void Update(void) override { m_StreamingManager->SetShrinkFactor( this->GetFilter()->GetShrinkFactor() ); Superclass::Update(); @@ -321,7 +321,7 @@ protected: } /** Destructor */ - ~StreamingShrinkImageFilter() ITK_OVERRIDE {} + ~StreamingShrinkImageFilter() override {} private: StreamingShrinkImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbTernaryFunctorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbTernaryFunctorImageFilter.h index 3e6d3f5405..483f2e3275 100644 --- a/Modules/Filtering/ImageManipulation/include/otbTernaryFunctorImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbTernaryFunctorImageFilter.h @@ -55,7 +55,7 @@ public: protected: TernaryFunctorImageFilter() {}; - ~TernaryFunctorImageFilter() ITK_OVERRIDE {} + ~TernaryFunctorImageFilter() override {} /** TernaryFunctorImageFilter can produce an image which has a different number of bands * than its input image. As such, TernaryFunctorImageFilter @@ -65,7 +65,7 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE + void GenerateOutputInformation() override { Superclass::GenerateOutputInformation(); typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); diff --git a/Modules/Filtering/ImageManipulation/include/otbThresholdVectorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbThresholdVectorImageFilter.h index ef2a903cd4..cf87797e75 100644 --- a/Modules/Filtering/ImageManipulation/include/otbThresholdVectorImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbThresholdVectorImageFilter.h @@ -98,8 +98,8 @@ public: protected: ThresholdVectorImageFilter(); - ~ThresholdVectorImageFilter() ITK_OVERRIDE {}; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ThresholdVectorImageFilter() override {}; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** ThresholdVectorImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -112,9 +112,9 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType ThrethreadId ) ITK_OVERRIDE; + itk::ThreadIdType ThrethreadId ) override; - void GenerateOutputInformation(void) ITK_OVERRIDE + void GenerateOutputInformation(void) override { Superclass::GenerateOutputInformation(); diff --git a/Modules/Filtering/ImageManipulation/include/otbTileImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbTileImageFilter.h index 34c1c5aa48..7eb50db4f4 100644 --- a/Modules/Filtering/ImageManipulation/include/otbTileImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbTileImageFilter.h @@ -80,26 +80,26 @@ protected: TileImageFilter(); /** Destructor */ - ~TileImageFilter() ITK_OVERRIDE; + ~TileImageFilter() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Threaded generate data */ - void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** Generate input requested region method */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Generate input requested region method */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Override VerifyInputInformation() since this filter's inputs do * not need to occupy the same physical space. * * \sa ProcessObject::VerifyInputInformation */ - void VerifyInputInformation() ITK_OVERRIDE {} + void VerifyInputInformation() override {} private: diff --git a/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.h b/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.h index c4adb6a9f7..64020282a3 100644 --- a/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.h +++ b/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.h @@ -73,13 +73,13 @@ public: protected: TwoNRIBandsImageToNComplexBandsImage(); - ~TwoNRIBandsImageToNComplexBandsImage() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~TwoNRIBandsImageToNComplexBandsImage() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateOutputInformation(void) ITK_OVERRIDE; - void BeforeThreadedGenerateData(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; + void BeforeThreadedGenerateData(void) override; void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: TwoNRIBandsImageToNComplexBandsImage(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodImageFilter.h index de00941439..b925c64959 100644 --- a/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodImageFilter.h @@ -123,7 +123,7 @@ protected: /** * Destructor */ - ~UnaryFunctorNeighborhoodImageFilter() ITK_OVERRIDE {} + ~UnaryFunctorNeighborhoodImageFilter() override {} /** UnaryFunctorNeighborhoodImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -135,12 +135,12 @@ protected: * * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** * Pad the input requested region by radius */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; private: UnaryFunctorNeighborhoodImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h index 05f86d0857..d562ea0810 100644 --- a/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h @@ -133,9 +133,9 @@ protected: /** * Destructor */ - ~UnaryFunctorNeighborhoodWithOffsetImageFilter() ITK_OVERRIDE {} + ~UnaryFunctorNeighborhoodWithOffsetImageFilter() override {} - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** UnaryFunctorNeighborhoodWithOffsetImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -147,12 +147,12 @@ protected: * * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** * Pad the input requested region by radius */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; std::vector<FunctorType> m_FunctorList; private: diff --git a/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorWithIndexImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorWithIndexImageFilter.h index 6a241dd5a2..34e42c34bc 100644 --- a/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorWithIndexImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorWithIndexImageFilter.h @@ -111,7 +111,7 @@ protected: /** * Destructor */ - ~UnaryFunctorWithIndexImageFilter() ITK_OVERRIDE {} + ~UnaryFunctorWithIndexImageFilter() override {} /** UnaryFunctorWithIndexImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -123,12 +123,12 @@ protected: * * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** * Pad the input requested region by radius */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; private: UnaryFunctorWithIndexImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbUnaryImageFunctorWithVectorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbUnaryImageFunctorWithVectorImageFilter.h index fe37b97905..f2519e2a59 100644 --- a/Modules/Filtering/ImageManipulation/include/otbUnaryImageFunctorWithVectorImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbUnaryImageFunctorWithVectorImageFilter.h @@ -89,7 +89,7 @@ public: protected: UnaryImageFunctorWithVectorImageFilter(); - ~UnaryImageFunctorWithVectorImageFilter() ITK_OVERRIDE {} + ~UnaryImageFunctorWithVectorImageFilter() override {} /** UnaryImageFunctorWithVectorImageFilter can produce an image which is a different * resolution than its input image. As such, UnaryImageFunctorWithVectorImageFilter @@ -99,7 +99,7 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** UnaryImageFunctorWithVectorImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -111,9 +111,9 @@ protected: * * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** Ponderation declaration*/ diff --git a/Modules/Filtering/ImageManipulation/include/otbVectorImageTo3DScalarImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbVectorImageTo3DScalarImageFilter.h index 368f049691..ba02992064 100644 --- a/Modules/Filtering/ImageManipulation/include/otbVectorImageTo3DScalarImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbVectorImageTo3DScalarImageFilter.h @@ -74,21 +74,21 @@ public: protected: /** Generate output information */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** Generate input requested region */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** Threaded Generate data */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; /** Constructor */ VectorImageTo3DScalarImageFilter(); /** Destructor */ - ~VectorImageTo3DScalarImageFilter() ITK_OVERRIDE {} + ~VectorImageTo3DScalarImageFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: VectorImageTo3DScalarImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageManipulation/include/otbVectorImageToAmplitudeImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbVectorImageToAmplitudeImageFilter.h index 7a8875e488..09602f7650 100644 --- a/Modules/Filtering/ImageManipulation/include/otbVectorImageToAmplitudeImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbVectorImageToAmplitudeImageFilter.h @@ -84,9 +84,9 @@ protected: /** Constructor */ VectorImageToAmplitudeImageFilter() {}; /** Destructor */ - ~VectorImageToAmplitudeImageFilter() ITK_OVERRIDE {} + ~VectorImageToAmplitudeImageFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Filtering/ImageManipulation/include/otbVectorRescaleIntensityImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbVectorRescaleIntensityImageFilter.h index 8b5633863c..e2227f0b70 100644 --- a/Modules/Filtering/ImageManipulation/include/otbVectorRescaleIntensityImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbVectorRescaleIntensityImageFilter.h @@ -260,20 +260,20 @@ public: itkGetConstReferenceMacro(Gamma,double); /** Process to execute before entering the multithreaded section */ - void BeforeThreadedGenerateData(void) ITK_OVERRIDE; + void BeforeThreadedGenerateData(void) override; /** Generate output information */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** Generate input requested region */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** Print internal ivars */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; protected: VectorRescaleIntensityImageFilter(); - ~VectorRescaleIntensityImageFilter() ITK_OVERRIDE {} + ~VectorRescaleIntensityImageFilter() override {} private: VectorRescaleIntensityImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageNoise/include/otbFrostImageFilter.h b/Modules/Filtering/ImageNoise/include/otbFrostImageFilter.h index b7bed10f9b..deaa62aed9 100644 --- a/Modules/Filtering/ImageNoise/include/otbFrostImageFilter.h +++ b/Modules/Filtering/ImageNoise/include/otbFrostImageFilter.h @@ -99,12 +99,12 @@ public: * an input processing area larger than the output one. * \sa ImageToImageFilter::GenerateInputRequestedRegion() */ void GenerateInputRequestedRegion() - throw(itk::InvalidRequestedRegionError) ITK_OVERRIDE; + throw(itk::InvalidRequestedRegionError) override; protected: FrostImageFilter(); - ~FrostImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~FrostImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** FrostImageFilter can be implemented for a multithreaded filter treatment. * Thus, this implementation give the ThreadedGenerateData() method. @@ -115,7 +115,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: FrostImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageNoise/include/otbGammaMAPImageFilter.h b/Modules/Filtering/ImageNoise/include/otbGammaMAPImageFilter.h index aacd79527f..7aae5b4199 100644 --- a/Modules/Filtering/ImageNoise/include/otbGammaMAPImageFilter.h +++ b/Modules/Filtering/ImageNoise/include/otbGammaMAPImageFilter.h @@ -91,18 +91,18 @@ public: * * \sa ImageToImageFilter::GenerateInputRequestedRegion() */ void GenerateInputRequestedRegion() - throw(itk::InvalidRequestedRegionError) ITK_OVERRIDE; + throw(itk::InvalidRequestedRegionError) override; protected: GammaMAPImageFilter(); - ~GammaMAPImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~GammaMAPImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** GammaMAPImageFilter can be multithreaded. */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: GammaMAPImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageNoise/include/otbKuanImageFilter.h b/Modules/Filtering/ImageNoise/include/otbKuanImageFilter.h index 4233766bd5..b2701daf37 100644 --- a/Modules/Filtering/ImageNoise/include/otbKuanImageFilter.h +++ b/Modules/Filtering/ImageNoise/include/otbKuanImageFilter.h @@ -91,18 +91,18 @@ public: * * \sa ImageToImageFilter::GenerateInputRequestedRegion() */ void GenerateInputRequestedRegion() - throw(itk::InvalidRequestedRegionError) ITK_OVERRIDE; + throw(itk::InvalidRequestedRegionError) override; protected: KuanImageFilter(); - ~KuanImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~KuanImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** KuanImageFilter can be multithreaded. */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: KuanImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/ImageNoise/include/otbLeeImageFilter.h b/Modules/Filtering/ImageNoise/include/otbLeeImageFilter.h index 6479cc5e2d..a502acb05a 100644 --- a/Modules/Filtering/ImageNoise/include/otbLeeImageFilter.h +++ b/Modules/Filtering/ImageNoise/include/otbLeeImageFilter.h @@ -98,12 +98,12 @@ public: * * \sa ImageToImageFilter::GenerateInputRequestedRegion() */ void GenerateInputRequestedRegion() - throw(itk::InvalidRequestedRegionError) ITK_OVERRIDE; + throw(itk::InvalidRequestedRegionError) override; protected: LeeImageFilter(); - ~LeeImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LeeImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** LeeImageFilter can be multithreaded. * As such, it provides a definition of ThreadedGenerateData() @@ -116,7 +116,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: LeeImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/MathParser/include/otbBandMathImageFilter.h b/Modules/Filtering/MathParser/include/otbBandMathImageFilter.h index 6f79f68ca6..2ae2485e72 100644 --- a/Modules/Filtering/MathParser/include/otbBandMathImageFilter.h +++ b/Modules/Filtering/MathParser/include/otbBandMathImageFilter.h @@ -128,12 +128,12 @@ public: protected : BandMathImageFilter(); - ~BandMathImageFilter() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~BandMathImageFilter() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; - void ThreadedGenerateData(const ImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ) ITK_OVERRIDE; - void AfterThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; + void ThreadedGenerateData(const ImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ) override; + void AfterThreadedGenerateData() override; private : BandMathImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/MathParser/include/otbMaskMuParserFilter.h b/Modules/Filtering/MathParser/include/otbMaskMuParserFilter.h index 7fef900379..a6cd78452f 100644 --- a/Modules/Filtering/MathParser/include/otbMaskMuParserFilter.h +++ b/Modules/Filtering/MathParser/include/otbMaskMuParserFilter.h @@ -120,12 +120,12 @@ public: protected: MaskMuParserFilter(); - ~MaskMuParserFilter() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~MaskMuParserFilter() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; - void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; - void AfterThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; + void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId) override; + void AfterThreadedGenerateData() override; private: MaskMuParserFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/MathParser/include/otbMaskMuParserFunctor.h b/Modules/Filtering/MathParser/include/otbMaskMuParserFunctor.h index d88e533e4f..e9ddd48734 100644 --- a/Modules/Filtering/MathParser/include/otbMaskMuParserFunctor.h +++ b/Modules/Filtering/MathParser/include/otbMaskMuParserFunctor.h @@ -98,7 +98,7 @@ public: protected: MaskMuParserFunctor(); - ~MaskMuParserFunctor() ITK_OVERRIDE; + ~MaskMuParserFunctor() override; private: diff --git a/Modules/Filtering/MathParser/include/otbParser.h b/Modules/Filtering/MathParser/include/otbParser.h index 4dd914b9f7..053c1b4566 100644 --- a/Modules/Filtering/MathParser/include/otbParser.h +++ b/Modules/Filtering/MathParser/include/otbParser.h @@ -89,8 +89,8 @@ public: protected: Parser(); - ~Parser() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~Parser() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Filtering/MathParser/include/otbParserConditionDataNodeFeatureFunction.h b/Modules/Filtering/MathParser/include/otbParserConditionDataNodeFeatureFunction.h index d0d036a7df..5212da806d 100644 --- a/Modules/Filtering/MathParser/include/otbParserConditionDataNodeFeatureFunction.h +++ b/Modules/Filtering/MathParser/include/otbParserConditionDataNodeFeatureFunction.h @@ -87,7 +87,7 @@ public: typedef std::vector<PrecisionType> OutputType; - OutputType Evaluate( const DataNodeType& node ) const ITK_OVERRIDE; + OutputType Evaluate( const DataNodeType& node ) const override; std::string GetExpression() const { @@ -106,8 +106,8 @@ public: protected: ParserConditionDataNodeFeatureFunction(); - ~ParserConditionDataNodeFeatureFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ParserConditionDataNodeFeatureFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ParserConditionDataNodeFeatureFunction(const Self&); //purposely not implemented diff --git a/Modules/Filtering/MathParser/src/otbParser.cxx b/Modules/Filtering/MathParser/src/otbParser.cxx index 4280d3ac9c..ac57dd9a85 100644 --- a/Modules/Filtering/MathParser/src/otbParser.cxx +++ b/Modules/Filtering/MathParser/src/otbParser.cxx @@ -184,11 +184,11 @@ protected: InitConst(); } - ~ParserImpl() ITK_OVERRIDE + ~ParserImpl() override { } - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.h b/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.h index 5dd1085c05..b491cef10f 100644 --- a/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.h +++ b/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.h @@ -132,15 +132,15 @@ public: protected : BandMathXImageFilter(); - ~BandMathXImageFilter() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~BandMathXImageFilter() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateOutputInformation() ITK_OVERRIDE; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateOutputInformation() override; + void GenerateInputRequestedRegion() override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; - void ThreadedGenerateData(const ImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ) ITK_OVERRIDE; - void AfterThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; + void ThreadedGenerateData(const ImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ) override; + void AfterThreadedGenerateData() override; private : diff --git a/Modules/Filtering/MathParserX/include/otbParserX.h b/Modules/Filtering/MathParserX/include/otbParserX.h index ef75a31eaf..d0eab3a05e 100644 --- a/Modules/Filtering/MathParserX/include/otbParserX.h +++ b/Modules/Filtering/MathParserX/include/otbParserX.h @@ -107,8 +107,8 @@ public: protected: ParserX(); - ~ParserX() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ParserX() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Filtering/MathParserX/include/otbParserXPlugins.h b/Modules/Filtering/MathParserX/include/otbParserXPlugins.h index e9da00fd05..195a7e955b 100644 --- a/Modules/Filtering/MathParserX/include/otbParserXPlugins.h +++ b/Modules/Filtering/MathParserX/include/otbParserXPlugins.h @@ -36,14 +36,14 @@ public: bands():ICallback(mup::cmFUNC, "bands", 2) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "bands - A bands selector"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new bands(*this); } @@ -56,14 +56,14 @@ public: dotpr():ICallback(mup::cmFUNC, "dotpr", -1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "dotpr(m1,m2) - A vector/matrix dot product"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new dotpr(*this); } @@ -75,14 +75,14 @@ class ElementWiseDivision : public mup::IOprtBin ElementWiseDivision():IOprtBin(_T("div"), (int)(mup::prMUL_DIV), mup::oaLEFT) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return _T("x div y - Element-wise division (vectors / matrices)"); } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new ElementWiseDivision(*this); } @@ -95,14 +95,14 @@ class DivisionByScalar : public mup::IOprtBin DivisionByScalar():IOprtBin(_T("dv"), (int)(mup::prMUL_DIV), mup::oaLEFT) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return _T("x dv y - division of vectors / matrices by a scalar"); } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new DivisionByScalar(*this); } @@ -115,14 +115,14 @@ class ElementWiseMultiplication : public mup::IOprtBin ElementWiseMultiplication():IOprtBin(_T("mult"), (int)(mup::prMUL_DIV), mup::oaLEFT) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return _T("x mult y - Element wise multiplication (vectors / matrices)"); } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new ElementWiseMultiplication(*this); } @@ -135,14 +135,14 @@ class MultiplicationByScalar : public mup::IOprtBin MultiplicationByScalar():IOprtBin(_T("mlt"), (int)(mup::prMUL_DIV), mup::oaLEFT) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return _T("x mlt y - multiplication of vectors / matrices by a scalar"); } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new MultiplicationByScalar(*this); } @@ -155,14 +155,14 @@ public: ElementWisePower():IOprtBin(_T("pow"), (int) mup::prPOW, mup::oaRIGHT) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return _T("pow - Power for noncomplex vectors & matrices"); } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new ElementWisePower(*this); } @@ -175,14 +175,14 @@ class PowerByScalar : public mup::IOprtBin PowerByScalar():IOprtBin(_T("pw"), (int)(mup::prMUL_DIV), mup::oaLEFT) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return _T("x pw y - power of vectors / matrices by a scalar"); } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new PowerByScalar(*this); } @@ -195,14 +195,14 @@ public: ndvi():ICallback(mup::cmFUNC, "ndvi", 2) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "NDVI - Normalized Difference Vegetation Index"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new ndvi(*this); } @@ -215,14 +215,14 @@ public: cat():ICallback(mup::cmFUNC, "cat", -1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "cat(m1,m2) - Values concatenation"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new cat(*this); } @@ -235,14 +235,14 @@ public: mean():ICallback(mup::cmFUNC, "mean", -1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "mean(m1,m2,..) - mean of each neighborhood"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new mean(*this); } @@ -255,14 +255,14 @@ public: var():ICallback(mup::cmFUNC, "var", -1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "var(m1,m2,..) - variance of each neighborhood"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new var(*this); } @@ -275,14 +275,14 @@ public: corr():ICallback(mup::cmFUNC, "corr", 2) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "corr(m1,m2) - variance of two variables m1 and m2"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new corr(*this); } @@ -295,14 +295,14 @@ public: median():ICallback(mup::cmFUNC, "median", -1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "median(m1,m2,..) - median value of each neighborhood"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new median(*this); } @@ -315,14 +315,14 @@ public: maj():ICallback(mup::cmFUNC, "maj", -1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "maj(m1,m2,..) - majority value of each neighborhood"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new maj(*this); } @@ -335,14 +335,14 @@ public: vnorm():ICallback(mup::cmFUNC, "vnorm", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int a_iArgc) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vnorm(v1) - Norm for a vector : sqrt(sum of squared elements); works also with matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vnorm(*this); } @@ -354,14 +354,14 @@ public: vmin():ICallback(mup::cmFUNC, "vmin", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vmin(m1) - overall minimum"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vmin(*this); } @@ -374,14 +374,14 @@ public: vmax():ICallback(mup::cmFUNC, "vmax", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vmax(m1) - overall maximun"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vmax(*this); } @@ -394,14 +394,14 @@ public: vect2scal():ICallback(mup::cmFUNC, "vect2scal", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vect2scal - Convert one dimensional vector to scalar"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vect2scal(*this); } @@ -415,14 +415,14 @@ public: vcos():ICallback(mup::cmFUNC, "vcos", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vcos - Cosinus for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vcos(*this); } @@ -435,14 +435,14 @@ public: vacos():ICallback(mup::cmFUNC, "vacos", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vacos - Arccosinus for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vacos(*this); } @@ -454,14 +454,14 @@ public: vsin():ICallback(mup::cmFUNC, "vsin", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vsin - Sinus for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vsin(*this); } @@ -473,14 +473,14 @@ public: vasin():ICallback(mup::cmFUNC, "vasin", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vasin - Arcsinus for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vasin(*this); } @@ -493,14 +493,14 @@ public: vtan():ICallback(mup::cmFUNC, "vtan", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vtan - Tangent for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vtan(*this); } @@ -513,14 +513,14 @@ public: vatan():ICallback(mup::cmFUNC, "vatan", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vatan - Arctangent for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vatan(*this); } @@ -533,14 +533,14 @@ public: vtanh():ICallback(mup::cmFUNC, "vtanh", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vtanh - Hyperbolic tangent for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vtanh(*this); } @@ -553,14 +553,14 @@ public: vsinh():ICallback(mup::cmFUNC, "vsinh", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vsinh - Hyperbolic sinus for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vsinh(*this); } @@ -573,14 +573,14 @@ public: vcosh():ICallback(mup::cmFUNC, "vcosh", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vcosh - Hyperbolic cosinus for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vcosh(*this); } @@ -593,14 +593,14 @@ public: vlog():ICallback(mup::cmFUNC, "vlog", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vlog - Log for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vlog(*this); } @@ -613,14 +613,14 @@ public: vlog10():ICallback(mup::cmFUNC, "vlog10", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vlog10 - Log10 for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vlog10(*this); } @@ -633,14 +633,14 @@ public: vabs():ICallback(mup::cmFUNC, "vabs", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vabs - Absolute value for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vabs(*this); } @@ -653,14 +653,14 @@ public: vexp():ICallback(mup::cmFUNC, "vexp", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vexp - Exponential for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vexp(*this); } @@ -673,14 +673,14 @@ public: vsqrt():ICallback(mup::cmFUNC, "vsqrt", 1) {} - void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) ITK_OVERRIDE; + void Eval(mup::ptr_val_type &ret, const mup::ptr_val_type *a_pArg, int itkNotUsed(a_iArgc)) override; - const mup::char_type* GetDesc() const ITK_OVERRIDE + const mup::char_type* GetDesc() const override { return "vsqrt - Sqrt for noncomplex vectors & matrices"; } - mup::IToken* Clone() const ITK_OVERRIDE + mup::IToken* Clone() const override { return new vsqrt(*this); } diff --git a/Modules/Filtering/MathParserX/src/otbParserX.cxx b/Modules/Filtering/MathParserX/src/otbParserX.cxx index b57ac98fec..c7b0be5625 100644 --- a/Modules/Filtering/MathParserX/src/otbParserX.cxx +++ b/Modules/Filtering/MathParserX/src/otbParserX.cxx @@ -250,11 +250,11 @@ protected: InitConst(); } - ~ParserXImpl() ITK_OVERRIDE + ~ParserXImpl() override { } - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidAnalysisFilter.h b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidAnalysisFilter.h index da70e60c48..5a72c260d4 100644 --- a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidAnalysisFilter.h +++ b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidAnalysisFilter.h @@ -93,7 +93,7 @@ public: * Get The Analyse image at each level of the pyramid. * \return The analysed image at each level of the pyramid. */ - OutputImageListType* GetOutput(void) ITK_OVERRIDE; + OutputImageListType* GetOutput(void) override; /** * Get The SupFilter details * \return The brighter details extracted from the filtering operation. @@ -119,12 +119,12 @@ protected: /** Constructor */ MorphologicalPyramidAnalysisFilter(); /** Destructor */ - ~MorphologicalPyramidAnalysisFilter() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE {} // does nothing + ~MorphologicalPyramidAnalysisFilter() override; + void GenerateOutputInformation() override {} // does nothing /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Printself method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** Number of levels of the algorithm */ diff --git a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidMRToMSConverter.h b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidMRToMSConverter.h index 6ca0f65408..7b49a7fd3e 100644 --- a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidMRToMSConverter.h +++ b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidMRToMSConverter.h @@ -71,7 +71,7 @@ public: * \param imageList The analysed image at each level of the pyramid. */ using Superclass::SetInput; - void SetInput(const InputImageListType * imageList) ITK_OVERRIDE; + void SetInput(const InputImageListType * imageList) override; /** * Set The SupFilter details * \param imageList The brighter details extracted from the filtering operation. @@ -96,7 +96,7 @@ public: * Get the input list. * \return The list of the analysed image at each pyramid level. */ - InputImageListType* GetInput(void) ITK_OVERRIDE; + InputImageListType* GetInput(void) override; /** * Get The SupFilter details * \return The brighter details extracted from the filtering operation. @@ -122,7 +122,7 @@ public: * \return The analysed image at each pyramid level * resampled at full resolution. */ - OutputImageListType* GetOutput(void) ITK_OVERRIDE; + OutputImageListType* GetOutput(void) override; /** * Get The SupFilter details at full resolution. * \return The brighter details extracted from the filtering operation @@ -152,12 +152,12 @@ protected: /** Constructor */ MRToMSConverter(); /** Destructor */ - ~MRToMSConverter() ITK_OVERRIDE {} + ~MRToMSConverter() override {} /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: MRToMSConverter(const Self &); // purposely not implemented diff --git a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidResampler.h b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidResampler.h index 3de2246b07..732149b211 100644 --- a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidResampler.h +++ b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidResampler.h @@ -77,17 +77,17 @@ protected: /** Constructor */ Resampler(); /** Destructor */ - ~Resampler() ITK_OVERRIDE {} + ~Resampler() override {} /** Generate output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Configure input requested region to be the largest possible region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Configure output requested region to be the largest possible region */ - void EnlargeOutputRequestedRegion(itk::DataObject * itkNotUsed(output)) ITK_OVERRIDE; + void EnlargeOutputRequestedRegion(itk::DataObject * itkNotUsed(output)) override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: Resampler(const Self &); // purposely not implemented void operator =(const Self&); // purposely not implemented diff --git a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidSegmentationFilter.h b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidSegmentationFilter.h index a000cf5dfc..5312f55b0a 100644 --- a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidSegmentationFilter.h +++ b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidSegmentationFilter.h @@ -141,12 +141,12 @@ protected: /** Constructor */ MorphologicalPyramidSegmentationFilter(); /** Destructor */ - ~MorphologicalPyramidSegmentationFilter() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE {} // does nothing + ~MorphologicalPyramidSegmentationFilter() override; + void GenerateOutputInformation() override {} // does nothing /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Printself method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: unsigned long m_MinimumObjectSize; /** Quantile for seeds determination */ diff --git a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidSegmenter.h b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidSegmenter.h index 09969ede26..47a9929ff7 100644 --- a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidSegmenter.h +++ b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidSegmenter.h @@ -120,15 +120,15 @@ protected: /** Constructor */ Segmenter(); /** Destructor */ - ~Segmenter() ITK_OVERRIDE {} + ~Segmenter() override {} /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Configure the input datas. */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** * Configure the output data. */ diff --git a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidSynthesisFilter.h b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidSynthesisFilter.h index 3cd4c2653d..3b83773a44 100644 --- a/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidSynthesisFilter.h +++ b/Modules/Filtering/MorphologicalPyramid/include/otbMorphologicalPyramidSynthesisFilter.h @@ -128,12 +128,12 @@ protected: /** Constructor */ MorphologicalPyramidSynthesisFilter(); /** Destructor */ - ~MorphologicalPyramidSynthesisFilter() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE {} // does nothing + ~MorphologicalPyramidSynthesisFilter() override; + void GenerateOutputInformation() override {} // does nothing /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Printself method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; }; } // End namespace otb diff --git a/Modules/Filtering/Path/include/otbCompacityPathFunction.h b/Modules/Filtering/Path/include/otbCompacityPathFunction.h index 6341a81fd3..b668d970e3 100644 --- a/Modules/Filtering/Path/include/otbCompacityPathFunction.h +++ b/Modules/Filtering/Path/include/otbCompacityPathFunction.h @@ -70,13 +70,13 @@ public: typedef double RealType; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PathType& path) const ITK_OVERRIDE; + OutputType Evaluate(const PathType& path) const override; virtual OutputType Evaluate() const; protected: CompacityPathFunction() {}; - ~CompacityPathFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~CompacityPathFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: CompacityPathFunction(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Path/include/otbDrawPathFilter.h b/Modules/Filtering/Path/include/otbDrawPathFilter.h index c0f24975e7..1fda8044e1 100644 --- a/Modules/Filtering/Path/include/otbDrawPathFilter.h +++ b/Modules/Filtering/Path/include/otbDrawPathFilter.h @@ -90,10 +90,10 @@ public: protected: DrawPathFilter(); - ~DrawPathFilter() ITK_OVERRIDE {} + ~DrawPathFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - void GenerateData() ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + void GenerateData() override; private: DrawPathFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Path/include/otbDrawPathListFilter.h b/Modules/Filtering/Path/include/otbDrawPathListFilter.h index efa0645b5a..9c9de8abee 100644 --- a/Modules/Filtering/Path/include/otbDrawPathListFilter.h +++ b/Modules/Filtering/Path/include/otbDrawPathListFilter.h @@ -111,11 +111,11 @@ protected: /** Constructor */ DrawPathListFilter(); /** Desctructor */ - ~DrawPathListFilter() ITK_OVERRIDE {} + ~DrawPathListFilter() override {} /** Printself method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: DrawPathListFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Path/include/otbImageFittingPolygonListFilter.h b/Modules/Filtering/Path/include/otbImageFittingPolygonListFilter.h index c33c6afc7e..ac5d3b89b3 100644 --- a/Modules/Filtering/Path/include/otbImageFittingPolygonListFilter.h +++ b/Modules/Filtering/Path/include/otbImageFittingPolygonListFilter.h @@ -94,11 +94,11 @@ protected: /** Constructor */ ImageFittingPolygonListFilter(); /** Destructor */ - ~ImageFittingPolygonListFilter() ITK_OVERRIDE {} + ~ImageFittingPolygonListFilter() override {} /** GenerateData method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; virtual double computeValue(ImageConstPointerType image, VertexType middlePoint, diff --git a/Modules/Filtering/Path/include/otbImageToEdgePathFilter.h b/Modules/Filtering/Path/include/otbImageToEdgePathFilter.h index 2bf48180fc..f976eb805f 100644 --- a/Modules/Filtering/Path/include/otbImageToEdgePathFilter.h +++ b/Modules/Filtering/Path/include/otbImageToEdgePathFilter.h @@ -86,10 +86,10 @@ public: protected: ImageToEdgePathFilter(); - ~ImageToEdgePathFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE {} //does nothing - void GenerateData() ITK_OVERRIDE; + ~ImageToEdgePathFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + void GenerateOutputInformation() override {} //does nothing + void GenerateData() override; private: ImageToEdgePathFilter(const Self &); // purposely not implemented diff --git a/Modules/Filtering/Path/include/otbImageToPathFilter.h b/Modules/Filtering/Path/include/otbImageToPathFilter.h index 9011677b0a..8e09616793 100644 --- a/Modules/Filtering/Path/include/otbImageToPathFilter.h +++ b/Modules/Filtering/Path/include/otbImageToPathFilter.h @@ -61,8 +61,8 @@ public: protected: ImageToPathFilter(); - ~ImageToPathFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageToPathFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageToPathFilter(const Self &); diff --git a/Modules/Filtering/Path/include/otbImageToPathListFilter.h b/Modules/Filtering/Path/include/otbImageToPathListFilter.h index d43671930b..146d7d4d6d 100644 --- a/Modules/Filtering/Path/include/otbImageToPathListFilter.h +++ b/Modules/Filtering/Path/include/otbImageToPathListFilter.h @@ -76,9 +76,9 @@ public: protected: ImageToPathListFilter(); - ~ImageToPathListFilter() ITK_OVERRIDE {} + ~ImageToPathListFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageToPathListFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Path/include/otbOrientationPathFunction.h b/Modules/Filtering/Path/include/otbOrientationPathFunction.h index d3bdd5a27f..ca1b010e23 100644 --- a/Modules/Filtering/Path/include/otbOrientationPathFunction.h +++ b/Modules/Filtering/Path/include/otbOrientationPathFunction.h @@ -66,13 +66,13 @@ public: typedef double RealType; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PathType& path) const ITK_OVERRIDE; + OutputType Evaluate(const PathType& path) const override; virtual OutputType Evaluate() const; protected: OrientationPathFunction() {}; - ~OrientationPathFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~OrientationPathFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: OrientationPathFunction(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Path/include/otbPathFunction.h b/Modules/Filtering/Path/include/otbPathFunction.h index 065a7d5f36..e260d86b32 100644 --- a/Modules/Filtering/Path/include/otbPathFunction.h +++ b/Modules/Filtering/Path/include/otbPathFunction.h @@ -80,8 +80,8 @@ public: protected: PathFunction(); - ~PathFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PathFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; InputPathConstPointer m_Path; diff --git a/Modules/Filtering/Path/include/otbPathListSource.h b/Modules/Filtering/Path/include/otbPathListSource.h index 31eaebc2b7..0181cc7276 100644 --- a/Modules/Filtering/Path/include/otbPathListSource.h +++ b/Modules/Filtering/Path/include/otbPathListSource.h @@ -172,7 +172,7 @@ public: protected: PathListSource() {}; - ~PathListSource() ITK_OVERRIDE {} + ~PathListSource() override {} // void PrintSelf(std::ostream& os, itk::Indent indent) const; private: diff --git a/Modules/Filtering/Path/include/otbPathListToHistogramGenerator.h b/Modules/Filtering/Path/include/otbPathListToHistogramGenerator.h index 17569744ed..e5f99af968 100644 --- a/Modules/Filtering/Path/include/otbPathListToHistogramGenerator.h +++ b/Modules/Filtering/Path/include/otbPathListToHistogramGenerator.h @@ -117,12 +117,12 @@ public: protected: PathListToHistogramGenerator(); - ~PathListToHistogramGenerator() ITK_OVERRIDE {} - void GenerateData() ITK_OVERRIDE; - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType) ITK_OVERRIDE; + ~PathListToHistogramGenerator() override {} + void GenerateData() override; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType) override; using Superclass::MakeOutput; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Filtering/Path/include/otbPathListToPathListFilter.h b/Modules/Filtering/Path/include/otbPathListToPathListFilter.h index a7baf6f52e..88fcb21c63 100644 --- a/Modules/Filtering/Path/include/otbPathListToPathListFilter.h +++ b/Modules/Filtering/Path/include/otbPathListToPathListFilter.h @@ -63,7 +63,7 @@ protected: /** Constructor */ PathListToPathListFilter() {}; /** Destructor */ - ~PathListToPathListFilter() ITK_OVERRIDE {} + ~PathListToPathListFilter() override {} private: PathListToPathListFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Path/include/otbPolyLineImageIterator.h b/Modules/Filtering/Path/include/otbPolyLineImageIterator.h index 2b1eebd04b..e56e3e2ac8 100644 --- a/Modules/Filtering/Path/include/otbPolyLineImageIterator.h +++ b/Modules/Filtering/Path/include/otbPolyLineImageIterator.h @@ -95,7 +95,7 @@ public: PolyLineImageIterator(ImageType * imagePtr, PathType * pathPtr) : Superclass(imagePtr, pathPtr) {}; /** Default Destructor. */ - ~PolyLineImageIterator() ITK_OVERRIDE {} + ~PolyLineImageIterator() override {} }; } // End namespace otb diff --git a/Modules/Filtering/Path/include/otbRegionImageToRectangularPathListFilter.h b/Modules/Filtering/Path/include/otbRegionImageToRectangularPathListFilter.h index fd3e1c0c50..21176cb50e 100644 --- a/Modules/Filtering/Path/include/otbRegionImageToRectangularPathListFilter.h +++ b/Modules/Filtering/Path/include/otbRegionImageToRectangularPathListFilter.h @@ -102,16 +102,16 @@ public: protected: RegionImageToRectangularPathListFilter(); - ~RegionImageToRectangularPathListFilter() ITK_OVERRIDE; + ~RegionImageToRectangularPathListFilter() override; - void GenerateOutputInformation() ITK_OVERRIDE{} // do nothing - void GenerateData() ITK_OVERRIDE; + void GenerateOutputInformation() override{} // do nothing + void GenerateData() override; double m_MinimumFit; double m_MinimumSize; int m_CrossTermFormula; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; //jgc typedef Image<unsigned char, itkGetStaticConstMacro(NDimensions)> MarkerImageType; diff --git a/Modules/Filtering/Path/include/otbVectorizationPathListFilter.h b/Modules/Filtering/Path/include/otbVectorizationPathListFilter.h index 7d6f3f13fb..3e0b32a71b 100644 --- a/Modules/Filtering/Path/include/otbVectorizationPathListFilter.h +++ b/Modules/Filtering/Path/include/otbVectorizationPathListFilter.h @@ -117,11 +117,11 @@ protected: /** Constructor */ VectorizationPathListFilter(); /** Destructor */ - ~VectorizationPathListFilter() ITK_OVERRIDE {} + ~VectorizationPathListFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** * Compute a vector of the 8 neighbors to explore from the direction and the type of search (forward or backward). * \param direction The direction diff --git a/Modules/Filtering/Polarimetry/include/otbMuellerToPolarisationDegreeAndPowerImageFilter.h b/Modules/Filtering/Polarimetry/include/otbMuellerToPolarisationDegreeAndPowerImageFilter.h index 6d0ce02fc5..fcec423adc 100644 --- a/Modules/Filtering/Polarimetry/include/otbMuellerToPolarisationDegreeAndPowerImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbMuellerToPolarisationDegreeAndPowerImageFilter.h @@ -230,7 +230,7 @@ public: protected: MuellerToPolarisationDegreeAndPowerImageFilter() {} - ~MuellerToPolarisationDegreeAndPowerImageFilter() ITK_OVERRIDE {} + ~MuellerToPolarisationDegreeAndPowerImageFilter() override {} private: MuellerToPolarisationDegreeAndPowerImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Polarimetry/include/otbMuellerToReciprocalCovarianceImageFilter.h b/Modules/Filtering/Polarimetry/include/otbMuellerToReciprocalCovarianceImageFilter.h index f867aa7ede..77a13cbb04 100644 --- a/Modules/Filtering/Polarimetry/include/otbMuellerToReciprocalCovarianceImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbMuellerToReciprocalCovarianceImageFilter.h @@ -158,7 +158,7 @@ public: protected: MuellerToReciprocalCovarianceImageFilter() {} - ~MuellerToReciprocalCovarianceImageFilter() ITK_OVERRIDE {} + ~MuellerToReciprocalCovarianceImageFilter() override {} private: MuellerToReciprocalCovarianceImageFilter(const Self&); // purposely not implemented diff --git a/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.h b/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.h index bb08aa2ffe..7c3ab103d0 100644 --- a/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.h @@ -155,7 +155,7 @@ protected: /** Constructor */ MultiChannelsPolarimetricSynthesisFilter(); /** Destructor */ - ~MultiChannelsPolarimetricSynthesisFilter() ITK_OVERRIDE {} + ~MultiChannelsPolarimetricSynthesisFilter() override {} /** MultiChannelsPolarimetricSynthesisFilter can produce an image * which is a synthesis of channels HH, HV, VH and VV. @@ -167,9 +167,9 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** MultiChannelsPolarimetricSynthesisFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -182,7 +182,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; /** Computation of the electromagnetic fields Ei Er */ void ComputeElectromagneticFields(); @@ -190,7 +190,7 @@ protected: /** Verify and force the inputs, if only 2 or 3 channels are present */ void VerifyAndForceInputs(); - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: MultiChannelsPolarimetricSynthesisFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Polarimetry/include/otbPolarimetricData.h b/Modules/Filtering/Polarimetry/include/otbPolarimetricData.h index 2207165b5c..78a3d1c1cc 100644 --- a/Modules/Filtering/Polarimetry/include/otbPolarimetricData.h +++ b/Modules/Filtering/Polarimetry/include/otbPolarimetricData.h @@ -79,9 +79,9 @@ protected: /** Constructor */ PolarimetricData(); /** Destructor */ - ~PolarimetricData() ITK_OVERRIDE {} + ~PolarimetricData() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: PolarimetricData(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalBarnesDecompImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalBarnesDecompImageFilter.h index d6fd45092a..54dd975da4 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalBarnesDecompImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalBarnesDecompImageFilter.h @@ -151,7 +151,7 @@ public: protected: ReciprocalBarnesDecompImageFilter() {} - ~ReciprocalBarnesDecompImageFilter() ITK_OVERRIDE {} + ~ReciprocalBarnesDecompImageFilter() override {} private: ReciprocalBarnesDecompImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalCoherencyToReciprocalMuellerImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalCoherencyToReciprocalMuellerImageFilter.h index 438d27a10b..71e7d6917d 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalCoherencyToReciprocalMuellerImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalCoherencyToReciprocalMuellerImageFilter.h @@ -163,7 +163,7 @@ public: protected: ReciprocalCoherencyToReciprocalMuellerImageFilter() {} - ~ReciprocalCoherencyToReciprocalMuellerImageFilter() ITK_OVERRIDE {} + ~ReciprocalCoherencyToReciprocalMuellerImageFilter() override {} private: diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h index 64412304a9..8d346c7149 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h @@ -147,7 +147,7 @@ public: protected: ReciprocalCovarianceToCoherencyDegreeImageFilter() {} - ~ReciprocalCovarianceToCoherencyDegreeImageFilter() ITK_OVERRIDE {} + ~ReciprocalCovarianceToCoherencyDegreeImageFilter() override {} private: ReciprocalCovarianceToCoherencyDegreeImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h index 4c92f4d88f..761f4a0f74 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h @@ -138,7 +138,7 @@ public: protected: ReciprocalCovarianceToReciprocalCoherencyImageFilter() {} - ~ReciprocalCovarianceToReciprocalCoherencyImageFilter() ITK_OVERRIDE {} + ~ReciprocalCovarianceToReciprocalCoherencyImageFilter() override {} private: ReciprocalCovarianceToReciprocalCoherencyImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalHAlphaImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalHAlphaImageFilter.h index ad2404e657..2e95fff07c 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalHAlphaImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalHAlphaImageFilter.h @@ -220,7 +220,7 @@ public: protected: ReciprocalHAlphaImageFilter() {} - ~ReciprocalHAlphaImageFilter() ITK_OVERRIDE {} + ~ReciprocalHAlphaImageFilter() override {} private: ReciprocalHAlphaImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalHuynenDecompImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalHuynenDecompImageFilter.h index fc9973dc28..2da4369697 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalHuynenDecompImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalHuynenDecompImageFilter.h @@ -122,7 +122,7 @@ public: protected: ReciprocalHuynenDecompImageFilter() {} - ~ReciprocalHuynenDecompImageFilter() ITK_OVERRIDE {} + ~ReciprocalHuynenDecompImageFilter() override {} private: ReciprocalHuynenDecompImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h index d762a266bd..900eeb4947 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h @@ -143,7 +143,7 @@ public: protected: ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter() {} - ~ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter() ITK_OVERRIDE {} + ~ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter() override {} private: ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalPauliDecompImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalPauliDecompImageFilter.h index d24da9a307..319c19be77 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalPauliDecompImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalPauliDecompImageFilter.h @@ -113,7 +113,7 @@ public: protected: ReciprocalPauliDecompImageFilter() {this->SetNumberOfThreads(1);} - ~ReciprocalPauliDecompImageFilter() ITK_OVERRIDE {} + ~ReciprocalPauliDecompImageFilter() override {} private: ReciprocalPauliDecompImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Polarimetry/include/otbSinclairImageFilter.h b/Modules/Filtering/Polarimetry/include/otbSinclairImageFilter.h index 1bbd3f1213..bb9c04c06f 100644 --- a/Modules/Filtering/Polarimetry/include/otbSinclairImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbSinclairImageFilter.h @@ -109,11 +109,11 @@ protected: /** Constructor */ SinclairImageFilter() {} /** Destructor */ - ~SinclairImageFilter() ITK_OVERRIDE {} + ~SinclairImageFilter() override {} - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Filtering/Polarimetry/include/otbSinclairReciprocalImageFilter.h b/Modules/Filtering/Polarimetry/include/otbSinclairReciprocalImageFilter.h index 4dea852f42..2b9d4dc321 100644 --- a/Modules/Filtering/Polarimetry/include/otbSinclairReciprocalImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbSinclairReciprocalImageFilter.h @@ -108,11 +108,11 @@ protected: /** Constructor */ SinclairReciprocalImageFilter() {} /** Destructor */ - ~SinclairReciprocalImageFilter() ITK_OVERRIDE {} + ~SinclairReciprocalImageFilter() override {} - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Filtering/Projection/include/otbEckert4MapProjection.h b/Modules/Filtering/Projection/include/otbEckert4MapProjection.h index cddb18af87..d02d5a6888 100644 --- a/Modules/Filtering/Projection/include/otbEckert4MapProjection.h +++ b/Modules/Filtering/Projection/include/otbEckert4MapProjection.h @@ -61,7 +61,7 @@ public: protected: Eckert4MapProjection(); - ~Eckert4MapProjection() ITK_OVERRIDE; + ~Eckert4MapProjection() override; private: Eckert4MapProjection(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbGCPsToRPCSensorModelImageFilter.h b/Modules/Filtering/Projection/include/otbGCPsToRPCSensorModelImageFilter.h index e2f6aac470..06436338f0 100644 --- a/Modules/Filtering/Projection/include/otbGCPsToRPCSensorModelImageFilter.h +++ b/Modules/Filtering/Projection/include/otbGCPsToRPCSensorModelImageFilter.h @@ -170,17 +170,17 @@ protected: /** Constructor */ GCPsToRPCSensorModelImageFilter(); /** Destructor */ - ~GCPsToRPCSensorModelImageFilter() ITK_OVERRIDE; + ~GCPsToRPCSensorModelImageFilter() override; /** The PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Actual estimation of the sensor model takes place in the * GenerateOutputInformation() method */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Drive the model up-to-date flag */ - void Modified() const ITK_OVERRIDE; + void Modified() const override; private: GCPsToRPCSensorModelImageFilter (const Self &); // purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.h b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.h index 233d736e85..0f93d53e91 100644 --- a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.h +++ b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.h @@ -268,20 +268,20 @@ public: } /** Override itk::ProcessObject method to let the internal filter do the propagation */ - void PropagateRequestedRegion(itk::DataObject *output) ITK_OVERRIDE; + void PropagateRequestedRegion(itk::DataObject *output) override; protected: GenericRSResampleImageFilter(); /** Destructor */ - ~GenericRSResampleImageFilter() ITK_OVERRIDE {}; + ~GenericRSResampleImageFilter() override {}; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; virtual void UpdateTransform(); - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: GenericRSResampleImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx index 7635cdcea7..ee70f41a72 100644 --- a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx +++ b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx @@ -203,7 +203,7 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage> m_InputRpcEstimator->SetInput(tempPtr); m_InputRpcEstimator->UpdateOutputInformation(); - // No need to ITK_OVERRIDE the input kwl, just setup the + // No need to override the input kwl, just setup the // transform with the kwl estimated if(m_InputRpcEstimator->GetInput()->GetImageKeywordlist().GetSize() > 0) m_Transform->SetOutputKeywordList(m_InputRpcEstimator->GetOutput()->GetImageKeywordlist()); diff --git a/Modules/Filtering/Projection/include/otbGeographicalDistance.h b/Modules/Filtering/Projection/include/otbGeographicalDistance.h index 11b7dacd6f..225aa44e4a 100644 --- a/Modules/Filtering/Projection/include/otbGeographicalDistance.h +++ b/Modules/Filtering/Projection/include/otbGeographicalDistance.h @@ -68,10 +68,10 @@ public: /** Gets the distance between the origin point and x. This function * work with SetOrigin() function */ - double Evaluate(const VectorType & x) const ITK_OVERRIDE; + double Evaluate(const VectorType & x) const override; /* Gets the distance between x and y points */ - double Evaluate(const VectorType & x, const VectorType & y) const ITK_OVERRIDE; + double Evaluate(const VectorType & x, const VectorType & y) const override; /** Set the earth radius */ itkSetMacro(EarthRadius, double); @@ -84,10 +84,10 @@ protected: GeographicalDistance(); /** Destructor */ - ~GeographicalDistance() ITK_OVERRIDE{} + ~GeographicalDistance() override{} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: GeographicalDistance(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbGeometriesProjectionFilter.h b/Modules/Filtering/Projection/include/otbGeometriesProjectionFilter.h index 50e7ea5b2f..4229ae3771 100644 --- a/Modules/Filtering/Projection/include/otbGeometriesProjectionFilter.h +++ b/Modules/Filtering/Projection/include/otbGeometriesProjectionFilter.h @@ -195,7 +195,7 @@ private: * of the filter. It's up to the caller to take responsibility of the returned * object. */ - OGRSpatialReference* DoDefineNewLayerSpatialReference(ogr::Layer const& source) const ITK_OVERRIDE; + OGRSpatialReference* DoDefineNewLayerSpatialReference(ogr::Layer const& source) const override; /** * Hook that actually filters an OGR \c Layer. * \param[in] source Input layer @@ -207,13 +207,13 @@ private: * inner-filter working on \c ogr::DataSource cannot be globally configured * once and for all. */ - void DoProcessLayer(ogr::Layer const& source, ogr::Layer & destination) const ITK_OVERRIDE; + void DoProcessLayer(ogr::Layer const& source, ogr::Layer & destination) const override; /** Hook used to conclude the initialization phase. * Global \c ogr::DataSource settings for the \c m_Transform functor are * forwarded to the functor. \c ogr::Layer specific settings will be set at * the last moment from \c DoProcessLayer(). */ - void DoFinalizeInitialization() ITK_OVERRIDE; + void DoFinalizeInitialization() override; /** * Hook used to define the fields of the new layer. @@ -223,18 +223,18 @@ private: * Just forwards the fields definition to the \c FieldTransformationPolicy * encapsuled in the \c TransformationFunctorDispatcherType. */ - void DoDefineNewLayerFields(ogr::Layer const& source, ogr::Layer & dest) const ITK_OVERRIDE; + void DoDefineNewLayerFields(ogr::Layer const& source, ogr::Layer & dest) const override; protected: /** Default constructor. */ GeometriesProjectionFilter(); /** Destructor. */ - ~GeometriesProjectionFilter() ITK_OVERRIDE; + ~GeometriesProjectionFilter() override; /** Computes output information. * \post \c m_OutputProjectionRef contains all its related meta-data */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; public: /**\name Image Reference (origin, spacing) */ diff --git a/Modules/Filtering/Projection/include/otbGroundSpacingImageFunction.h b/Modules/Filtering/Projection/include/otbGroundSpacingImageFunction.h index 6f60e7b74a..925069f259 100644 --- a/Modules/Filtering/Projection/include/otbGroundSpacingImageFunction.h +++ b/Modules/Filtering/Projection/include/otbGroundSpacingImageFunction.h @@ -81,10 +81,10 @@ public: itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension); /** Evalulate the function at specified index */ - FloatType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + FloatType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - FloatType Evaluate(const PointType& point) const ITK_OVERRIDE + FloatType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); @@ -92,7 +92,7 @@ public: } FloatType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -103,8 +103,8 @@ public: protected: GroundSpacingImageFunction(); - ~GroundSpacingImageFunction() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~GroundSpacingImageFunction() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: GroundSpacingImageFunction(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbImageToEnvelopeVectorDataFilter.h b/Modules/Filtering/Projection/include/otbImageToEnvelopeVectorDataFilter.h index 2c4bd9779b..827b852e8f 100644 --- a/Modules/Filtering/Projection/include/otbImageToEnvelopeVectorDataFilter.h +++ b/Modules/Filtering/Projection/include/otbImageToEnvelopeVectorDataFilter.h @@ -96,13 +96,13 @@ public: protected: ImageToEnvelopeVectorDataFilter(); - ~ImageToEnvelopeVectorDataFilter() ITK_OVERRIDE {} + ~ImageToEnvelopeVectorDataFilter() override {} - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; void InstantiateTransform(); diff --git a/Modules/Filtering/Projection/include/otbImportGeoInformationImageFilter.h b/Modules/Filtering/Projection/include/otbImportGeoInformationImageFilter.h index 6245f9b0a1..f22b21de3b 100644 --- a/Modules/Filtering/Projection/include/otbImportGeoInformationImageFilter.h +++ b/Modules/Filtering/Projection/include/otbImportGeoInformationImageFilter.h @@ -81,20 +81,20 @@ protected: /** Constructor */ ImportGeoInformationImageFilter(); /** Destructor */ - ~ImportGeoInformationImageFilter() ITK_OVERRIDE {} + ~ImportGeoInformationImageFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Generate input requested region */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** Generate output information */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** Override VerifyInputInformation() since this filter's inputs do * not need to occupy the same physical space. * * \sa ProcessObject::VerifyInputInformation */ - void VerifyInputInformation() ITK_OVERRIDE {} + void VerifyInputInformation() override {} private: ImportGeoInformationImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbLambert2EtenduProjection.h b/Modules/Filtering/Projection/include/otbLambert2EtenduProjection.h index d66432cfcf..76dfc2c415 100644 --- a/Modules/Filtering/Projection/include/otbLambert2EtenduProjection.h +++ b/Modules/Filtering/Projection/include/otbLambert2EtenduProjection.h @@ -60,7 +60,7 @@ protected: this->SetParameter("StandardParallel2", "47.69601389"); } - ~Lambert2EtenduProjection() ITK_OVERRIDE {} + ~Lambert2EtenduProjection() override {} private: Lambert2EtenduProjection(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbLambert93Projection.h b/Modules/Filtering/Projection/include/otbLambert93Projection.h index 6949cbb9ea..377d61acc6 100644 --- a/Modules/Filtering/Projection/include/otbLambert93Projection.h +++ b/Modules/Filtering/Projection/include/otbLambert93Projection.h @@ -60,7 +60,7 @@ protected: this->SetParameter("StandardParallel2", "49"); } - ~Lambert93Projection() ITK_OVERRIDE {} + ~Lambert93Projection() override {} private: Lambert93Projection(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbLambertConformalConicMapProjection.h b/Modules/Filtering/Projection/include/otbLambertConformalConicMapProjection.h index d0031487d6..53bf34e8ec 100644 --- a/Modules/Filtering/Projection/include/otbLambertConformalConicMapProjection.h +++ b/Modules/Filtering/Projection/include/otbLambertConformalConicMapProjection.h @@ -64,7 +64,7 @@ public: protected: LambertConformalConicMapProjection(); - ~LambertConformalConicMapProjection() ITK_OVERRIDE {}; + ~LambertConformalConicMapProjection() override {}; private: LambertConformalConicMapProjection(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbLeastSquareAffineTransformEstimator.h b/Modules/Filtering/Projection/include/otbLeastSquareAffineTransformEstimator.h index f85ec67263..a3d1f273c4 100644 --- a/Modules/Filtering/Projection/include/otbLeastSquareAffineTransformEstimator.h +++ b/Modules/Filtering/Projection/include/otbLeastSquareAffineTransformEstimator.h @@ -138,10 +138,10 @@ protected: /** Constructor */ LeastSquareAffineTransformEstimator(); /** Destructor */ - ~LeastSquareAffineTransformEstimator() ITK_OVERRIDE; + ~LeastSquareAffineTransformEstimator() override; /** The PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LeastSquareAffineTransformEstimator (const Self &); // purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbMollweidMapProjection.h b/Modules/Filtering/Projection/include/otbMollweidMapProjection.h index 807239a0fa..27c7f71417 100644 --- a/Modules/Filtering/Projection/include/otbMollweidMapProjection.h +++ b/Modules/Filtering/Projection/include/otbMollweidMapProjection.h @@ -59,7 +59,7 @@ public: protected: MollweidMapProjection(); - ~MollweidMapProjection() ITK_OVERRIDE; + ~MollweidMapProjection() override; private: MollweidMapProjection(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbOrthoRectificationFilter.h b/Modules/Filtering/Projection/include/otbOrthoRectificationFilter.h index 72b4aeb38c..17c6ef257b 100644 --- a/Modules/Filtering/Projection/include/otbOrthoRectificationFilter.h +++ b/Modules/Filtering/Projection/include/otbOrthoRectificationFilter.h @@ -93,11 +93,11 @@ public: protected: OrthoRectificationFilter(); - ~OrthoRectificationFilter() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~OrthoRectificationFilter() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; + void GenerateOutputInformation(void) override; private: OrthoRectificationFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbPhysicalToRPCSensorModelImageFilter.h b/Modules/Filtering/Projection/include/otbPhysicalToRPCSensorModelImageFilter.h index 877bc433ca..0fb3a72973 100644 --- a/Modules/Filtering/Projection/include/otbPhysicalToRPCSensorModelImageFilter.h +++ b/Modules/Filtering/Projection/include/otbPhysicalToRPCSensorModelImageFilter.h @@ -110,19 +110,19 @@ public: } /** Reimplement the method Modified() */ - void Modified() const ITK_OVERRIDE; + void Modified() const override; protected: /** Constructor */ PhysicalToRPCSensorModelImageFilter(); /** Destructor */ - ~PhysicalToRPCSensorModelImageFilter() ITK_OVERRIDE; + ~PhysicalToRPCSensorModelImageFilter() override; /** The PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Generate the Output image information*/ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: PhysicalToRPCSensorModelImageFilter(const Self &); // purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbProjectiveProjectionImageFilter.h b/Modules/Filtering/Projection/include/otbProjectiveProjectionImageFilter.h index 29fea2c18d..22b92e4a05 100644 --- a/Modules/Filtering/Projection/include/otbProjectiveProjectionImageFilter.h +++ b/Modules/Filtering/Projection/include/otbProjectiveProjectionImageFilter.h @@ -154,11 +154,11 @@ public: protected: ProjectiveProjectionImageFilter(); - ~ProjectiveProjectionImageFilter() ITK_OVERRIDE {} + ~ProjectiveProjectionImageFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateOutputInformation() ITK_OVERRIDE + void GenerateOutputInformation() override { Superclass::GenerateOutputInformation(); typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); diff --git a/Modules/Filtering/Projection/include/otbROIdataConversion.h b/Modules/Filtering/Projection/include/otbROIdataConversion.h index ed7f9469f2..1c74b75a40 100644 --- a/Modules/Filtering/Projection/include/otbROIdataConversion.h +++ b/Modules/Filtering/Projection/include/otbROIdataConversion.h @@ -82,16 +82,16 @@ public: protected: ROIdataConversion(); - ~ROIdataConversion() ITK_OVERRIDE {} - void GenerateOutputInformation() ITK_OVERRIDE; - void GenerateInputRequestedRegion() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + ~ROIdataConversion() override {} + void GenerateOutputInformation() override; + void GenerateInputRequestedRegion() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } /** Performs its job! */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Count the number for sample in the training area */ SizeValueType GetNumberOfSample(); diff --git a/Modules/Filtering/Projection/include/otbRationalTransform.h b/Modules/Filtering/Projection/include/otbRationalTransform.h index 9ce1720ac6..5cc26f3bb6 100644 --- a/Modules/Filtering/Projection/include/otbRationalTransform.h +++ b/Modules/Filtering/Projection/include/otbRationalTransform.h @@ -101,7 +101,7 @@ public: itkGetConstMacro(DenominatorDegree, unsigned int); /** The transform point method */ - OutputPointType TransformPoint(const InputPointType& point) const ITK_OVERRIDE + OutputPointType TransformPoint(const InputPointType& point) const override { // Check for consistency if(this->GetNumberOfParameters() != this->m_Parameters.size()) @@ -148,13 +148,13 @@ public: } /** Get the number of parameters */ - NumberOfParametersType GetNumberOfParameters() const ITK_OVERRIDE + NumberOfParametersType GetNumberOfParameters() const override { return (static_cast <NumberOfParametersType> ( (m_NumeratorDegree +1 + m_DenominatorDegree+1)*SpaceDimension )); } // Set parameter method - void SetParameters(const typename Superclass::ParametersType & params) ITK_OVERRIDE + void SetParameters(const typename Superclass::ParametersType & params) override { // Check for the appropriate size if(params.Size() != this->GetNumberOfParameters()) @@ -187,9 +187,9 @@ protected: } - ~RationalTransform() ITK_OVERRIDE {} + ~RationalTransform() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); os << indent << "Numerator Degree : " << m_NumeratorDegree << std::endl; diff --git a/Modules/Filtering/Projection/include/otbSVY21MapProjection.h b/Modules/Filtering/Projection/include/otbSVY21MapProjection.h index a2a82cf174..415f9f9e4f 100644 --- a/Modules/Filtering/Projection/include/otbSVY21MapProjection.h +++ b/Modules/Filtering/Projection/include/otbSVY21MapProjection.h @@ -62,7 +62,7 @@ protected: this->SetParameter("FalseEasting", "28001.642"); this->SetParameter("ScaleFactor", "1.00"); } - ~SVY21MapProjection() ITK_OVERRIDE {} + ~SVY21MapProjection() override {} private: SVY21MapProjection(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbSinusoidalMapProjection.h b/Modules/Filtering/Projection/include/otbSinusoidalMapProjection.h index 2a2d7ca276..e8b7a190d3 100644 --- a/Modules/Filtering/Projection/include/otbSinusoidalMapProjection.h +++ b/Modules/Filtering/Projection/include/otbSinusoidalMapProjection.h @@ -62,7 +62,7 @@ public: protected: SinusoidalMapProjection(); - ~SinusoidalMapProjection() ITK_OVERRIDE; + ~SinusoidalMapProjection() override; private: SinusoidalMapProjection(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbTileMapTransform.h b/Modules/Filtering/Projection/include/otbTileMapTransform.h index f02bbb7438..c6d2125ba1 100644 --- a/Modules/Filtering/Projection/include/otbTileMapTransform.h +++ b/Modules/Filtering/Projection/include/otbTileMapTransform.h @@ -73,7 +73,7 @@ public: void SetLevel(unsigned int level); unsigned int GetLevel() const; - OutputPointType TransformPoint(const InputPointType& point) const ITK_OVERRIDE; + OutputPointType TransformPoint(const InputPointType& point) const override; virtual void PrintMap() const; @@ -85,7 +85,7 @@ public: protected: TileMapTransform(); - ~TileMapTransform() ITK_OVERRIDE; + ~TileMapTransform() override; private: TileMapTransform(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbTransMercatorMapProjection.h b/Modules/Filtering/Projection/include/otbTransMercatorMapProjection.h index b89d16333e..35a384373a 100644 --- a/Modules/Filtering/Projection/include/otbTransMercatorMapProjection.h +++ b/Modules/Filtering/Projection/include/otbTransMercatorMapProjection.h @@ -64,7 +64,7 @@ public: protected: TransMercatorMapProjection(); - ~TransMercatorMapProjection() ITK_OVERRIDE; + ~TransMercatorMapProjection() override; private: TransMercatorMapProjection(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbUtmMapProjection.h b/Modules/Filtering/Projection/include/otbUtmMapProjection.h index 5310eeb42a..60992d15b3 100644 --- a/Modules/Filtering/Projection/include/otbUtmMapProjection.h +++ b/Modules/Filtering/Projection/include/otbUtmMapProjection.h @@ -63,7 +63,7 @@ public: protected: UtmMapProjection(); - ~UtmMapProjection() ITK_OVERRIDE {}; + ~UtmMapProjection() override {}; private: UtmMapProjection(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbVectorDataIntoImageProjectionFilter.h b/Modules/Filtering/Projection/include/otbVectorDataIntoImageProjectionFilter.h index b86c9c78ac..34743bb569 100644 --- a/Modules/Filtering/Projection/include/otbVectorDataIntoImageProjectionFilter.h +++ b/Modules/Filtering/Projection/include/otbVectorDataIntoImageProjectionFilter.h @@ -105,9 +105,9 @@ public: protected: VectorDataIntoImageProjectionFilter(); - ~VectorDataIntoImageProjectionFilter() ITK_OVERRIDE {} + ~VectorDataIntoImageProjectionFilter() override {} - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; // Projection filter typedef VectorDataProjectionFilter<InputVectorDataType, InputVectorDataType> diff --git a/Modules/Filtering/Projection/include/otbVectorDataProjectionFilter.h b/Modules/Filtering/Projection/include/otbVectorDataProjectionFilter.h index 3178d4c71a..d455ec83d7 100644 --- a/Modules/Filtering/Projection/include/otbVectorDataProjectionFilter.h +++ b/Modules/Filtering/Projection/include/otbVectorDataProjectionFilter.h @@ -175,17 +175,17 @@ public: protected: VectorDataProjectionFilter(); - ~VectorDataProjectionFilter() ITK_OVERRIDE {} + ~VectorDataProjectionFilter() override {} - OutputPointType ProcessPoint(InputPointType point) const ITK_OVERRIDE; - OutputLinePointerType ProcessLine(InputLinePointerType line) const ITK_OVERRIDE; - OutputPolygonPointerType ProcessPolygon(InputPolygonPointerType polygon) const ITK_OVERRIDE; - OutputPolygonListPointerType ProcessPolygonList(InputPolygonListPointerType polygonList) const ITK_OVERRIDE; + OutputPointType ProcessPoint(InputPointType point) const override; + OutputLinePointerType ProcessLine(InputLinePointerType line) const override; + OutputPolygonPointerType ProcessPolygon(InputPolygonPointerType polygon) const override; + OutputPolygonListPointerType ProcessPolygonList(InputPolygonListPointerType polygonList) const override; virtual void InstantiateTransform(void); - void GenerateOutputInformation(void) ITK_OVERRIDE; - void GenerateData(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; + void GenerateData(void) override; private: VectorDataProjectionFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Projection/include/otbVectorDataTransformFilter.h b/Modules/Filtering/Projection/include/otbVectorDataTransformFilter.h index df815dd7d7..0ba5ce9031 100644 --- a/Modules/Filtering/Projection/include/otbVectorDataTransformFilter.h +++ b/Modules/Filtering/Projection/include/otbVectorDataTransformFilter.h @@ -102,14 +102,14 @@ public: protected: VectorDataTransformFilter(); - ~VectorDataTransformFilter() ITK_OVERRIDE {}; + ~VectorDataTransformFilter() override {}; - PointType ProcessPoint(PointType point) const ITK_OVERRIDE; - LinePointerType ProcessLine(LinePointerType line) const ITK_OVERRIDE; - PolygonPointerType ProcessPolygon(PolygonPointerType polygon) const ITK_OVERRIDE; - PolygonListPointerType ProcessPolygonList(PolygonListPointerType polygonList) const ITK_OVERRIDE; + PointType ProcessPoint(PointType point) const override; + LinePointerType ProcessLine(LinePointerType line) const override; + PolygonPointerType ProcessPolygon(PolygonPointerType polygon) const override; + PolygonListPointerType ProcessPolygonList(PolygonListPointerType polygonList) const override; - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; private: VectorDataTransformFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Smoothing/include/otbMeanShiftSmoothingImageFilter.h b/Modules/Filtering/Smoothing/include/otbMeanShiftSmoothingImageFilter.h index b91668884b..845f7dc00d 100644 --- a/Modules/Filtering/Smoothing/include/otbMeanShiftSmoothingImageFilter.h +++ b/Modules/Filtering/Smoothing/include/otbMeanShiftSmoothingImageFilter.h @@ -576,11 +576,11 @@ protected: * Define output pixel size * **/ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** MeanShiftFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() @@ -592,21 +592,21 @@ protected: * * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ - void ThreadedGenerateData(const OutputRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; - void AfterThreadedGenerateData() ITK_OVERRIDE; + void AfterThreadedGenerateData() override; /** Allocates the outputs (need to be reimplemented since outputs have different type) */ - void AllocateOutputs() ITK_OVERRIDE; + void AllocateOutputs() override; /** Constructor */ MeanShiftSmoothingImageFilter(); /** Destructor */ - ~MeanShiftSmoothingImageFilter() ITK_OVERRIDE; + ~MeanShiftSmoothingImageFilter() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; virtual void CalculateMeanShiftVector(const typename RealVectorImageType::Pointer inputImagePtr, const RealVector& jointPixel, const OutputRegionType& outputRegion, diff --git a/Modules/Filtering/Statistics/include/otbConcatenateSampleListFilter.h b/Modules/Filtering/Statistics/include/otbConcatenateSampleListFilter.h index 7208ac16f5..4fa8981e15 100644 --- a/Modules/Filtering/Statistics/include/otbConcatenateSampleListFilter.h +++ b/Modules/Filtering/Statistics/include/otbConcatenateSampleListFilter.h @@ -67,11 +67,11 @@ public: protected: /** This method causes the filter to generate its output. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; ConcatenateSampleListFilter(); - ~ConcatenateSampleListFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ConcatenateSampleListFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ConcatenateSampleListFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbContinuousMinimumMaximumImageCalculator.h b/Modules/Filtering/Statistics/include/otbContinuousMinimumMaximumImageCalculator.h index d10a702d4e..d22fcaba45 100644 --- a/Modules/Filtering/Statistics/include/otbContinuousMinimumMaximumImageCalculator.h +++ b/Modules/Filtering/Statistics/include/otbContinuousMinimumMaximumImageCalculator.h @@ -137,8 +137,8 @@ public: protected: ContinuousMinimumMaximumImageCalculator(); - ~ContinuousMinimumMaximumImageCalculator() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ContinuousMinimumMaximumImageCalculator() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; PixelType m_Minimum; PixelType m_Maximum; diff --git a/Modules/Filtering/Statistics/include/otbGaussianAdditiveNoiseSampleListFilter.h b/Modules/Filtering/Statistics/include/otbGaussianAdditiveNoiseSampleListFilter.h index dd104feb2c..9bc1a1e555 100644 --- a/Modules/Filtering/Statistics/include/otbGaussianAdditiveNoiseSampleListFilter.h +++ b/Modules/Filtering/Statistics/include/otbGaussianAdditiveNoiseSampleListFilter.h @@ -88,7 +88,7 @@ public: protected: /** This method causes the filter to generate its output. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Generate a white gaussian noise with mean m_Mean and variance * m_Variance @@ -96,8 +96,8 @@ protected: void GenerateRandomSequence(); GaussianAdditiveNoiseSampleListFilter(); - ~GaussianAdditiveNoiseSampleListFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~GaussianAdditiveNoiseSampleListFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: GaussianAdditiveNoiseSampleListFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbHistogramStatisticsFunction.h b/Modules/Filtering/Statistics/include/otbHistogramStatisticsFunction.h index c1cd905fcd..c2c04c9ea5 100644 --- a/Modules/Filtering/Statistics/include/otbHistogramStatisticsFunction.h +++ b/Modules/Filtering/Statistics/include/otbHistogramStatisticsFunction.h @@ -83,7 +83,7 @@ public: } /** Calculates the thresholds and save them */ - void Compute() ITK_OVERRIDE + void Compute() override { this->GenerateData(); } @@ -91,8 +91,8 @@ public: protected: HistogramStatisticsFunction(); - ~HistogramStatisticsFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~HistogramStatisticsFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Calculates the thresholds and save them */ void GenerateData(); diff --git a/Modules/Filtering/Statistics/include/otbListSampleGenerator.h b/Modules/Filtering/Statistics/include/otbListSampleGenerator.h index 58ece65e87..2a074d8748 100644 --- a/Modules/Filtering/Statistics/include/otbListSampleGenerator.h +++ b/Modules/Filtering/Statistics/include/otbListSampleGenerator.h @@ -98,7 +98,7 @@ public: // Build the outputs typedef itk::DataObject::Pointer DataObjectPointer; - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; //virtual void Update(); @@ -152,13 +152,13 @@ public: protected: ListSampleGenerator(); - ~ListSampleGenerator() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ListSampleGenerator() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Triggers the Computation of the sample list */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** Compute the calss statistics*/ void GenerateClassStatistics(); diff --git a/Modules/Filtering/Statistics/include/otbListSampleSource.h b/Modules/Filtering/Statistics/include/otbListSampleSource.h index 68efdd1c38..88bf53f9c2 100644 --- a/Modules/Filtering/Statistics/include/otbListSampleSource.h +++ b/Modules/Filtering/Statistics/include/otbListSampleSource.h @@ -73,12 +73,12 @@ public: protected: /** Standard itk::ProcessObject subclass method. */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; ListSampleSource(); - ~ListSampleSource() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ListSampleSource() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ListSampleSource(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbListSampleToBalancedListSampleFilter.h b/Modules/Filtering/Statistics/include/otbListSampleToBalancedListSampleFilter.h index f011996601..d904e39073 100644 --- a/Modules/Filtering/Statistics/include/otbListSampleToBalancedListSampleFilter.h +++ b/Modules/Filtering/Statistics/include/otbListSampleToBalancedListSampleFilter.h @@ -120,7 +120,7 @@ public: protected: /** This method causes the filter to generate its output. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** In order to respect the fair data principle, the number of samples for * each label must be the same. This method computes the label that @@ -129,12 +129,12 @@ protected: void ComputeMaxSampleFrequency(); /** Make Output */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; ListSampleToBalancedListSampleFilter(); - ~ListSampleToBalancedListSampleFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ListSampleToBalancedListSampleFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ListSampleToBalancedListSampleFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbListSampleToHistogramListGenerator.h b/Modules/Filtering/Statistics/include/otbListSampleToHistogramListGenerator.h index 3e46220642..f524aee705 100644 --- a/Modules/Filtering/Statistics/include/otbListSampleToHistogramListGenerator.h +++ b/Modules/Filtering/Statistics/include/otbListSampleToHistogramListGenerator.h @@ -147,14 +147,14 @@ public: protected: ListSampleToHistogramListGenerator(); - ~ListSampleToHistogramListGenerator() ITK_OVERRIDE {} + ~ListSampleToHistogramListGenerator() override {} - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: //ListSampleConstPointerType m_List; diff --git a/Modules/Filtering/Statistics/include/otbListSampleToListSampleFilter.h b/Modules/Filtering/Statistics/include/otbListSampleToListSampleFilter.h index 9e5f34cbc0..152788ef81 100644 --- a/Modules/Filtering/Statistics/include/otbListSampleToListSampleFilter.h +++ b/Modules/Filtering/Statistics/include/otbListSampleToListSampleFilter.h @@ -88,8 +88,8 @@ public: protected: ListSampleToListSampleFilter(); - ~ListSampleToListSampleFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ListSampleToListSampleFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ListSampleToListSampleFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbListSampleToVariableDimensionHistogramGenerator.h b/Modules/Filtering/Statistics/include/otbListSampleToVariableDimensionHistogramGenerator.h index 58e4340942..01bdb85060 100644 --- a/Modules/Filtering/Statistics/include/otbListSampleToVariableDimensionHistogramGenerator.h +++ b/Modules/Filtering/Statistics/include/otbListSampleToVariableDimensionHistogramGenerator.h @@ -111,10 +111,10 @@ public: protected: ListSampleToVariableDimensionHistogramGenerator(); - ~ListSampleToVariableDimensionHistogramGenerator() ITK_OVERRIDE {} - void GenerateData() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + ~ListSampleToVariableDimensionHistogramGenerator() override {} + void GenerateData() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; private: diff --git a/Modules/Filtering/Statistics/include/otbLocalHistogramImageFunction.h b/Modules/Filtering/Statistics/include/otbLocalHistogramImageFunction.h index b92dfab981..38eec749bc 100644 --- a/Modules/Filtering/Statistics/include/otbLocalHistogramImageFunction.h +++ b/Modules/Filtering/Statistics/include/otbLocalHistogramImageFunction.h @@ -89,17 +89,17 @@ public: InputImageType::ImageDimension); /** Evalulate the function at specified index */ - OutputType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PointType& point) const ITK_OVERRIDE + OutputType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } OutputType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -128,8 +128,8 @@ public: protected: LocalHistogramImageFunction(); - ~LocalHistogramImageFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LocalHistogramImageFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LocalHistogramImageFunction(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbNormalizeVectorImageFilter.h b/Modules/Filtering/Statistics/include/otbNormalizeVectorImageFilter.h index 56edd91384..f75d244c61 100644 --- a/Modules/Filtering/Statistics/include/otbNormalizeVectorImageFilter.h +++ b/Modules/Filtering/Statistics/include/otbNormalizeVectorImageFilter.h @@ -196,9 +196,9 @@ public: protected: NormalizeVectorImageFilter (); - ~NormalizeVectorImageFilter() ITK_OVERRIDE { } + ~NormalizeVectorImageFilter() override { } - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: diff --git a/Modules/Filtering/Statistics/include/otbPatternSampler.h b/Modules/Filtering/Statistics/include/otbPatternSampler.h index cc9dd9465d..90432a595b 100644 --- a/Modules/Filtering/Statistics/include/otbPatternSampler.h +++ b/Modules/Filtering/Statistics/include/otbPatternSampler.h @@ -89,7 +89,7 @@ public: /** * Method that resets the internal state of the sampler */ - void Reset(void) ITK_OVERRIDE; + void Reset(void) override; /** * Method to call during iteration, returns true if the sample is selected, @@ -118,7 +118,7 @@ protected: PatternSampler(); /** Destructor */ - ~PatternSampler() ITK_OVERRIDE {} + ~PatternSampler() override {} private: // Not implemented diff --git a/Modules/Filtering/Statistics/include/otbPeriodicSampler.h b/Modules/Filtering/Statistics/include/otbPeriodicSampler.h index dde341a6cd..c5b8185f77 100644 --- a/Modules/Filtering/Statistics/include/otbPeriodicSampler.h +++ b/Modules/Filtering/Statistics/include/otbPeriodicSampler.h @@ -86,7 +86,7 @@ public: /** * Method that resets the internal state of the sampler */ - void Reset(void) ITK_OVERRIDE; + void Reset(void) override; /** * Method to call during iteration, returns true if the sample is selected, @@ -99,7 +99,7 @@ protected: PeriodicSampler(); /** Destructor */ - ~PeriodicSampler() ITK_OVERRIDE {} + ~PeriodicSampler() override {} private: // Not implemented diff --git a/Modules/Filtering/Statistics/include/otbRandomSampler.h b/Modules/Filtering/Statistics/include/otbRandomSampler.h index 0ea7eb23d7..035b9d54ec 100644 --- a/Modules/Filtering/Statistics/include/otbRandomSampler.h +++ b/Modules/Filtering/Statistics/include/otbRandomSampler.h @@ -80,7 +80,7 @@ public: /** * Reset internal counter (to be called before starting iteration) */ - void Reset(void) ITK_OVERRIDE; + void Reset(void) override; /** * Method to call during iteration, returns true if the sample is selected, @@ -93,7 +93,7 @@ protected: RandomSampler(); /** Destructor */ - ~RandomSampler() ITK_OVERRIDE {} + ~RandomSampler() override {} private: // Not implemented diff --git a/Modules/Filtering/Statistics/include/otbSamplerBase.h b/Modules/Filtering/Statistics/include/otbSamplerBase.h index b32f2e46e2..be5602873a 100644 --- a/Modules/Filtering/Statistics/include/otbSamplerBase.h +++ b/Modules/Filtering/Statistics/include/otbSamplerBase.h @@ -78,7 +78,7 @@ protected: SamplerBase(); /** Destructor */ - ~SamplerBase() ITK_OVERRIDE {} + ~SamplerBase() override {} /** Current count of selected elements */ unsigned long m_ChosenElements; diff --git a/Modules/Filtering/Statistics/include/otbShiftScaleSampleListFilter.h b/Modules/Filtering/Statistics/include/otbShiftScaleSampleListFilter.h index b25d2782cc..00ed571aa8 100644 --- a/Modules/Filtering/Statistics/include/otbShiftScaleSampleListFilter.h +++ b/Modules/Filtering/Statistics/include/otbShiftScaleSampleListFilter.h @@ -87,11 +87,11 @@ public: protected: /** This method causes the filter to generate its output. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; ShiftScaleSampleListFilter(); - ~ShiftScaleSampleListFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ShiftScaleSampleListFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ShiftScaleSampleListFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbStreamingCompareImageFilter.h b/Modules/Filtering/Statistics/include/otbStreamingCompareImageFilter.h index c911b3b699..aefd0fc2e1 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingCompareImageFilter.h +++ b/Modules/Filtering/Statistics/include/otbStreamingCompareImageFilter.h @@ -138,31 +138,31 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; /** Pass the input through unmodified. Do this by Grafting in the * AllocateOutputs method. */ - void AllocateOutputs() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; - void Synthetize(void) ITK_OVERRIDE; - void Reset(void) ITK_OVERRIDE; + void AllocateOutputs() override; + void GenerateOutputInformation() override; + void Synthetize(void) override; + void Reset(void) override; protected: PersistentCompareImageFilter(); - ~PersistentCompareImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PersistentCompareImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Multi-thread version GenerateData. */ void ThreadedGenerateData(const RegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; /** Allows skipping the verification of physical space between * the two input images (see flag m_PhysicalSpaceCheck) */ - void VerifyInputInformation() ITK_OVERRIDE; + void VerifyInputInformation() override; private: PersistentCompareImageFilter(const Self &); //purposely not implemented @@ -319,7 +319,7 @@ protected: /** Constructor */ StreamingCompareImageFilter() {}; /** Destructor */ - ~StreamingCompareImageFilter() ITK_OVERRIDE {} + ~StreamingCompareImageFilter() override {} private: StreamingCompareImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbStreamingHistogramVectorImageFilter.h b/Modules/Filtering/Statistics/include/otbStreamingHistogramVectorImageFilter.h index 0972e3790b..e370076879 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingHistogramVectorImageFilter.h +++ b/Modules/Filtering/Statistics/include/otbStreamingHistogramVectorImageFilter.h @@ -169,23 +169,23 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; /** Pass the input through unmodified. Do this by Grafting in the * AllocateOutputs method. */ - void AllocateOutputs() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; - void Synthetize(void) ITK_OVERRIDE; - void Reset(void) ITK_OVERRIDE; + void AllocateOutputs() override; + void GenerateOutputInformation() override; + void Synthetize(void) override; + void Reset(void) override; protected: PersistentHistogramVectorImageFilter(); - ~PersistentHistogramVectorImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PersistentHistogramVectorImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Multi-thread version GenerateData. */ - void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override; private: PersistentHistogramVectorImageFilter(const Self &); //purposely not implemented @@ -271,7 +271,7 @@ protected: /** Constructor */ StreamingHistogramVectorImageFilter() {}; /** Destructor */ - ~StreamingHistogramVectorImageFilter() ITK_OVERRIDE {} + ~StreamingHistogramVectorImageFilter() override {} private: StreamingHistogramVectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbStreamingMinMaxImageFilter.h b/Modules/Filtering/Statistics/include/otbStreamingMinMaxImageFilter.h index 567ba10295..a10a93cfc8 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingMinMaxImageFilter.h +++ b/Modules/Filtering/Statistics/include/otbStreamingMinMaxImageFilter.h @@ -124,26 +124,26 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; /** Pass the input through unmodified. Do this by Grafting in the * AllocateOutputs method. */ - void AllocateOutputs() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; - void Synthetize(void) ITK_OVERRIDE; - void Reset(void) ITK_OVERRIDE; + void AllocateOutputs() override; + void GenerateOutputInformation() override; + void Synthetize(void) override; + void Reset(void) override; protected: PersistentMinMaxImageFilter(); - ~PersistentMinMaxImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PersistentMinMaxImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Multi-thread version GenerateData. */ void ThreadedGenerateData(const RegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: PersistentMinMaxImageFilter(const Self &); //purposely not implemented @@ -280,7 +280,7 @@ protected: /** Constructor */ StreamingMinMaxImageFilter() {} /** Destructor */ - ~StreamingMinMaxImageFilter() ITK_OVERRIDE {} + ~StreamingMinMaxImageFilter() override {} private: StreamingMinMaxImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbStreamingMinMaxVectorImageFilter.h b/Modules/Filtering/Statistics/include/otbStreamingMinMaxVectorImageFilter.h index 90de7efb4e..9b8c7b3a9d 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingMinMaxVectorImageFilter.h +++ b/Modules/Filtering/Statistics/include/otbStreamingMinMaxVectorImageFilter.h @@ -144,23 +144,23 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; /** Pass the input through unmodified. Do this by Grafting in the * AllocateOutputs method. */ - void AllocateOutputs() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; - void Synthetize(void) ITK_OVERRIDE; - void Reset(void) ITK_OVERRIDE; + void AllocateOutputs() override; + void GenerateOutputInformation() override; + void Synthetize(void) override; + void Reset(void) override; protected: PersistentMinMaxVectorImageFilter(); - ~PersistentMinMaxVectorImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PersistentMinMaxVectorImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Multi-thread version GenerateData. */ - void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override; private: PersistentMinMaxVectorImageFilter(const Self &); //purposely not implemented @@ -271,7 +271,7 @@ protected: /** Constructor */ StreamingMinMaxVectorImageFilter() {}; /** Destructor */ - ~StreamingMinMaxVectorImageFilter() ITK_OVERRIDE {} + ~StreamingMinMaxVectorImageFilter() override {} private: StreamingMinMaxVectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbStreamingStatisticsImageFilter.h b/Modules/Filtering/Statistics/include/otbStreamingStatisticsImageFilter.h index 04ad8dfc8f..2cc0a9e543 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingStatisticsImageFilter.h +++ b/Modules/Filtering/Statistics/include/otbStreamingStatisticsImageFilter.h @@ -142,16 +142,16 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; /** Pass the input through unmodified. Do this by Grafting in the * AllocateOutputs method. */ - void AllocateOutputs() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; - void Synthetize(void) ITK_OVERRIDE; - void Reset(void) ITK_OVERRIDE; + void AllocateOutputs() override; + void GenerateOutputInformation() override; + void Synthetize(void) override; + void Reset(void) override; itkSetMacro(IgnoreInfiniteValues, bool); itkGetMacro(IgnoreInfiniteValues, bool); @@ -164,13 +164,13 @@ public: protected: PersistentStatisticsImageFilter(); - ~PersistentStatisticsImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PersistentStatisticsImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Multi-thread version GenerateData. */ void ThreadedGenerateData(const RegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: PersistentStatisticsImageFilter(const Self &); //purposely not implemented @@ -358,7 +358,7 @@ protected: /** Constructor */ StreamingStatisticsImageFilter() {}; /** Destructor */ - ~StreamingStatisticsImageFilter() ITK_OVERRIDE {} + ~StreamingStatisticsImageFilter() override {} private: StreamingStatisticsImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbStreamingStatisticsMapFromLabelImageFilter.h b/Modules/Filtering/Statistics/include/otbStreamingStatisticsMapFromLabelImageFilter.h index 1223832496..d917452638 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingStatisticsMapFromLabelImageFilter.h +++ b/Modules/Filtering/Statistics/include/otbStreamingStatisticsMapFromLabelImageFilter.h @@ -110,31 +110,31 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; /** Pass the input through unmodified. Do this by Grafting in the * AllocateOutputs method. */ - void AllocateOutputs() ITK_OVERRIDE; + void AllocateOutputs() override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void Synthetize(void) ITK_OVERRIDE; + void Synthetize(void) override; - void Reset(void) ITK_OVERRIDE; + void Reset(void) override; /** Due to heterogeneous input template GenerateInputRequestedRegion must be reimplemented using explicit cast **/ /** This new implementation is inspired by the one of itk::ImageToImageFilter **/ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; protected: PersistentStreamingStatisticsMapFromLabelImageFilter(); - ~PersistentStreamingStatisticsMapFromLabelImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PersistentStreamingStatisticsMapFromLabelImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** GenerateData. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: PersistentStreamingStatisticsMapFromLabelImageFilter(const Self &); //purposely not implemented @@ -258,7 +258,7 @@ protected: /** Constructor */ StreamingStatisticsMapFromLabelImageFilter() {} /** Destructor */ - ~StreamingStatisticsMapFromLabelImageFilter() ITK_OVERRIDE {} + ~StreamingStatisticsMapFromLabelImageFilter() override {} private: StreamingStatisticsMapFromLabelImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbStreamingStatisticsVectorImageFilter.h b/Modules/Filtering/Statistics/include/otbStreamingStatisticsVectorImageFilter.h index bedfb4c832..83fcb6014a 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingStatisticsVectorImageFilter.h +++ b/Modules/Filtering/Statistics/include/otbStreamingStatisticsVectorImageFilter.h @@ -185,12 +185,12 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; - void Reset(void) ITK_OVERRIDE; + void Reset(void) override; - void Synthetize(void) ITK_OVERRIDE; + void Synthetize(void) override; itkSetMacro(EnableMinMax, bool); itkGetMacro(EnableMinMax, bool); @@ -216,19 +216,19 @@ public: protected: PersistentStreamingStatisticsVectorImageFilter(); - ~PersistentStreamingStatisticsVectorImageFilter() ITK_OVERRIDE {} + ~PersistentStreamingStatisticsVectorImageFilter() override {} /** Pass the input through unmodified. Do this by Grafting in the * AllocateOutputs method. */ - void AllocateOutputs() ITK_OVERRIDE; + void AllocateOutputs() override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Multi-thread version GenerateData. */ - void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override; private: PersistentStreamingStatisticsVectorImageFilter(const Self &); //purposely not implemented @@ -493,7 +493,7 @@ protected: StreamingStatisticsVectorImageFilter() {} /** Destructor */ - ~StreamingStatisticsVectorImageFilter() ITK_OVERRIDE {} + ~StreamingStatisticsVectorImageFilter() override {} private: StreamingStatisticsVectorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbVarianceImageFilter.h b/Modules/Filtering/Statistics/include/otbVarianceImageFilter.h index e89a853967..1b0839c7b7 100644 --- a/Modules/Filtering/Statistics/include/otbVarianceImageFilter.h +++ b/Modules/Filtering/Statistics/include/otbVarianceImageFilter.h @@ -93,7 +93,7 @@ public: * * \sa ImageToImageFilter::GenerateInputRequestedRegion() */ void GenerateInputRequestedRegion() - throw(itk::InvalidRequestedRegionError) ITK_OVERRIDE; + throw(itk::InvalidRequestedRegionError) override; #ifdef ITK_USE_CONCEPT_CHECKING /** Begin concept checking */ @@ -104,8 +104,8 @@ public: protected: VarianceImageFilter(); - ~VarianceImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~VarianceImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** VarianceImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() @@ -118,7 +118,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: VarianceImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbVectorImageToIntensityImageFilter.h b/Modules/Filtering/Statistics/include/otbVectorImageToIntensityImageFilter.h index 82d481aa36..17d9155e3f 100644 --- a/Modules/Filtering/Statistics/include/otbVectorImageToIntensityImageFilter.h +++ b/Modules/Filtering/Statistics/include/otbVectorImageToIntensityImageFilter.h @@ -79,9 +79,9 @@ protected: /** Constructor */ VectorImageToIntensityImageFilter(); /** Destructor */ - ~VectorImageToIntensityImageFilter() ITK_OVERRIDE {} + ~VectorImageToIntensityImageFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** VectorImageToIntensityImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine * which is called for each processing thread. The output image data is @@ -93,7 +93,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; private: VectorImageToIntensityImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Statistics/include/otbVectorImageToMatrixImageFilter.h b/Modules/Filtering/Statistics/include/otbVectorImageToMatrixImageFilter.h index e14ab4bd51..3bd7150ec5 100644 --- a/Modules/Filtering/Statistics/include/otbVectorImageToMatrixImageFilter.h +++ b/Modules/Filtering/Statistics/include/otbVectorImageToMatrixImageFilter.h @@ -101,22 +101,22 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; /** Pass the input through unmodified. Do this by Grafting in the * AllocateOutputs method. */ - void AllocateOutputs() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; - void Synthetize(void) ITK_OVERRIDE; - void Reset(void) ITK_OVERRIDE; + void AllocateOutputs() override; + void GenerateOutputInformation() override; + void Synthetize(void) override; + void Reset(void) override; protected: PersistentVectorImageToMatrixFilter(); - ~PersistentVectorImageToMatrixFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + ~PersistentVectorImageToMatrixFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override; private: PersistentVectorImageToMatrixFilter(const Self &); //purposely not implemented @@ -197,7 +197,7 @@ protected: /** Constructor */ VectorImageToMatrixImageFilter() {}; /** Destructor */ - ~VectorImageToMatrixImageFilter() ITK_OVERRIDE {} + ~VectorImageToMatrixImageFilter() override {} private: VectorImageToMatrixImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/VectorDataManipulation/include/otbConcatenateVectorDataFilter.h b/Modules/Filtering/VectorDataManipulation/include/otbConcatenateVectorDataFilter.h index 2d384b5734..bd18a932c8 100644 --- a/Modules/Filtering/VectorDataManipulation/include/otbConcatenateVectorDataFilter.h +++ b/Modules/Filtering/VectorDataManipulation/include/otbConcatenateVectorDataFilter.h @@ -82,11 +82,11 @@ public: protected: ConcatenateVectorDataFilter(); - ~ConcatenateVectorDataFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ConcatenateVectorDataFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Triggers the Computation of the sample list */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Recursive method to visit efficiently the vectordata*/ void ProcessNode(TreeNodeType * source, DataNodeType * outputDocument); diff --git a/Modules/Filtering/VectorDataManipulation/include/otbDBOverlapDataNodeFeatureFunction.h b/Modules/Filtering/VectorDataManipulation/include/otbDBOverlapDataNodeFeatureFunction.h index a3f103ebf7..6b53590057 100644 --- a/Modules/Filtering/VectorDataManipulation/include/otbDBOverlapDataNodeFeatureFunction.h +++ b/Modules/Filtering/VectorDataManipulation/include/otbDBOverlapDataNodeFeatureFunction.h @@ -76,7 +76,7 @@ public: typedef std::vector<PrecisionType> OutputType; - OutputType Evaluate( const DataNodeType& node ) const ITK_OVERRIDE; + OutputType Evaluate( const DataNodeType& node ) const override; /** Set/Get methods */ itkGetConstMacro(DistanceThreshold, PrecisionType); @@ -87,8 +87,8 @@ public: protected: DBOverlapDataNodeFeatureFunction(); - ~DBOverlapDataNodeFeatureFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~DBOverlapDataNodeFeatureFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: DBOverlapDataNodeFeatureFunction(const Self&); //purposely not implemented diff --git a/Modules/Filtering/VectorDataManipulation/include/otbRadiometryHomogenousWithNeighborhoodDataNodeFeatureFunction.h b/Modules/Filtering/VectorDataManipulation/include/otbRadiometryHomogenousWithNeighborhoodDataNodeFeatureFunction.h index a602566f10..3f7fdb9977 100644 --- a/Modules/Filtering/VectorDataManipulation/include/otbRadiometryHomogenousWithNeighborhoodDataNodeFeatureFunction.h +++ b/Modules/Filtering/VectorDataManipulation/include/otbRadiometryHomogenousWithNeighborhoodDataNodeFeatureFunction.h @@ -108,7 +108,7 @@ public: typedef std::vector<PrecisionType> OutputType; /* Compute the descriptor value along this DataNode */ - OutputType Evaluate( const DataNodeType& node ) const ITK_OVERRIDE; + OutputType Evaluate( const DataNodeType& node ) const override; /* Get the radius used to define the area around a line segment. * A radius of 0 means that the area is reduced to a line joining @@ -138,8 +138,8 @@ public: protected: RadiometryHomogenousWithNeighborhoodDataNodeFeatureFunction(); - ~RadiometryHomogenousWithNeighborhoodDataNodeFeatureFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~RadiometryHomogenousWithNeighborhoodDataNodeFeatureFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: RadiometryHomogenousWithNeighborhoodDataNodeFeatureFunction(const Self&); //purposely not implemented diff --git a/Modules/Filtering/VectorDataManipulation/include/otbSpectralAngleDataNodeFeatureFunction.h b/Modules/Filtering/VectorDataManipulation/include/otbSpectralAngleDataNodeFeatureFunction.h index 4d4c8792bd..919c6ff50c 100644 --- a/Modules/Filtering/VectorDataManipulation/include/otbSpectralAngleDataNodeFeatureFunction.h +++ b/Modules/Filtering/VectorDataManipulation/include/otbSpectralAngleDataNodeFeatureFunction.h @@ -101,7 +101,7 @@ public: typedef std::pair<IndexType, IndexType> IndexPairType; typedef std::vector<PrecisionType> OutputType; - OutputType Evaluate( const DataNodeType& node ) const ITK_OVERRIDE; + OutputType Evaluate( const DataNodeType& node ) const override; /** Set/Get methods */ itkGetConstMacro(RefPixel, PixelType); @@ -112,8 +112,8 @@ public: protected: SpectralAngleDataNodeFeatureFunction(); - ~SpectralAngleDataNodeFeatureFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~SpectralAngleDataNodeFeatureFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SpectralAngleDataNodeFeatureFunction(const Self&); //purposely not implemented diff --git a/Modules/Filtering/VectorDataManipulation/include/otbVectorDataAdapter.h b/Modules/Filtering/VectorDataManipulation/include/otbVectorDataAdapter.h index 7eb8a10565..b3b43bfeee 100644 --- a/Modules/Filtering/VectorDataManipulation/include/otbVectorDataAdapter.h +++ b/Modules/Filtering/VectorDataManipulation/include/otbVectorDataAdapter.h @@ -78,12 +78,12 @@ public: protected: VectorDataAdapter() {}; - ~VectorDataAdapter() ITK_OVERRIDE {} + ~VectorDataAdapter() override {} - OutputPointType ProcessPoint(InputPointType point) const ITK_OVERRIDE; - OutputLinePointerType ProcessLine(InputLinePointerType line) const ITK_OVERRIDE; - OutputPolygonPointerType ProcessPolygon(InputPolygonPointerType polygon) const ITK_OVERRIDE; - OutputPolygonListPointerType ProcessPolygonList(InputPolygonListPointerType polygonList) const ITK_OVERRIDE; + OutputPointType ProcessPoint(InputPointType point) const override; + OutputLinePointerType ProcessLine(InputLinePointerType line) const override; + OutputPolygonPointerType ProcessPolygon(InputPolygonPointerType polygon) const override; + OutputPolygonListPointerType ProcessPolygonList(InputPolygonListPointerType polygonList) const override; private: VectorDataAdapter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/VectorDataManipulation/include/otbVectorDataExtractROI.h b/Modules/Filtering/VectorDataManipulation/include/otbVectorDataExtractROI.h index 002536578e..87ed0a2f9c 100644 --- a/Modules/Filtering/VectorDataManipulation/include/otbVectorDataExtractROI.h +++ b/Modules/Filtering/VectorDataManipulation/include/otbVectorDataExtractROI.h @@ -106,8 +106,8 @@ public: protected: VectorDataExtractROI(); - ~VectorDataExtractROI() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~VectorDataExtractROI() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Method to compare the projection embedded in the cartoRegion And the the InputVectorData*/ virtual void CompareInputAndRegionProjection(); @@ -122,7 +122,7 @@ protected: virtual VertexType PointToContinuousIndex(ProjPointType point); /** Prototype of the generate data method*/ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Method to check if the polygon Bounding Box ha ve a non-null intersection with the ROI*/ virtual bool IsPolygonIntersectionNotNull(PolygonPointerType polygon); diff --git a/Modules/Filtering/VectorDataManipulation/include/otbVectorDataToRandomLineGenerator.h b/Modules/Filtering/VectorDataManipulation/include/otbVectorDataToRandomLineGenerator.h index ab38d43e82..2db1bee395 100644 --- a/Modules/Filtering/VectorDataManipulation/include/otbVectorDataToRandomLineGenerator.h +++ b/Modules/Filtering/VectorDataManipulation/include/otbVectorDataToRandomLineGenerator.h @@ -97,11 +97,11 @@ public: protected: VectorDataToRandomLineGenerator(); - ~VectorDataToRandomLineGenerator() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~VectorDataToRandomLineGenerator() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Triggers the Computation of the sample list */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; PointVectorType RandomPointsGenerator(DataNodeType * node); diff --git a/Modules/Filtering/VectorDataManipulation/include/otbVectorDataToSpecificDescriptionFilterBase.h b/Modules/Filtering/VectorDataManipulation/include/otbVectorDataToSpecificDescriptionFilterBase.h index 4285db7869..2dca72eaf4 100644 --- a/Modules/Filtering/VectorDataManipulation/include/otbVectorDataToSpecificDescriptionFilterBase.h +++ b/Modules/Filtering/VectorDataManipulation/include/otbVectorDataToSpecificDescriptionFilterBase.h @@ -76,9 +76,9 @@ protected: /** Constructor */ VectorDataToSpecificDescriptionFilterBase(); /** Destructor */ - ~VectorDataToSpecificDescriptionFilterBase() ITK_OVERRIDE {} + ~VectorDataToSpecificDescriptionFilterBase() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: VectorDataToSpecificDescriptionFilterBase(const Self &); //purposely not implemented diff --git a/Modules/Filtering/VectorDataManipulation/include/otbVectorDataToVectorDataFilter.h b/Modules/Filtering/VectorDataManipulation/include/otbVectorDataToVectorDataFilter.h index 05859c811e..a3ba98b719 100644 --- a/Modules/Filtering/VectorDataManipulation/include/otbVectorDataToVectorDataFilter.h +++ b/Modules/Filtering/VectorDataManipulation/include/otbVectorDataToVectorDataFilter.h @@ -94,7 +94,7 @@ protected: /** Constructor */ VectorDataToVectorDataFilter(); /** Destructor */ - ~VectorDataToVectorDataFilter() ITK_OVERRIDE {} + ~VectorDataToVectorDataFilter() override {} virtual OutputPointType ProcessPoint(InputPointType itkNotUsed(point)) const { @@ -113,14 +113,14 @@ protected: itkExceptionMacro( << "Subclass should reimplement this method"); } - void GenerateOutputInformation(void) ITK_OVERRIDE; - void GenerateData(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; + void GenerateData(void) override; /** Go through the vector data tree and process the nodes */ virtual void ProcessNode(InputInternalTreeNodeType * source, OutputInternalTreeNodeType * destination) const; /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: VectorDataToVectorDataFilter(const Self &); //purposely not implemented diff --git a/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.h b/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.h index 56371e3bea..b39a267f71 100644 --- a/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.h +++ b/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.h @@ -105,7 +105,7 @@ protected: { m_SubsampleFactor.Fill(1); } - ~SubsampleImageFilter() ITK_OVERRIDE {} + ~SubsampleImageFilter() override {} /** Internal test function to check if there is any direction to subsample */ bool IsSubsampleFactorOne() const; @@ -114,23 +114,23 @@ protected: * Region estimation functions has to be reimplemented */ void CallCopyOutputRegionToInputRegion - (InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) ITK_OVERRIDE; + (InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) override; void CallCopyInputRegionToOutputRegion - (OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion) ITK_OVERRIDE; + (OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion) override; /** Output image region size is not of the same dimension as the input. * That is why GenerateOutputInformation has to be redefined. */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Set output image to 0 before processing */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Allows multithreading */ void ThreadedGenerateData - (const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + (const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SubsampleImageFilter (const Self &); // purposely not implemented diff --git a/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.h b/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.h index 04d897c7ef..cb0d78d25a 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.h @@ -214,13 +214,13 @@ public: protected: WaveletFilterBank(); - ~WaveletFilterBank() ITK_OVERRIDE {} + ~WaveletFilterBank() override {} /** GenerateOutputInformation * Set the size of the output image depending on the decimation factor * Copy information from the input image if existing. **/ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** The forward transformation needs a larger input requested * region than the output requested region (larger by subsampling @@ -232,12 +232,12 @@ protected: * * \sa ImageToImageFilter::GenerateInputRequestedRegion() */ void GenerateInputRequestedRegion() - throw (itk::InvalidRequestedRegionError) ITK_OVERRIDE; + throw (itk::InvalidRequestedRegionError) override; /** BeforeThreadedGenerateData. * It allocates also internal images */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Internal Data Allocation * If m_SubsampleImageFactor != 1, internal data with progressive region size @@ -248,7 +248,7 @@ protected: /** AfterThreadedGenerateData. * It enforce memory destruction of internal images */ - void AfterThreadedGenerateData() ITK_OVERRIDE; + void AfterThreadedGenerateData() override; /** CallCopyOutputRegionToInputRegion * Since input and output image may be of different size when a @@ -256,9 +256,9 @@ protected: * functions has to be reimplemented */ void CallCopyOutputRegionToInputRegion - (InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) ITK_OVERRIDE; + (InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) override; void CallCopyInputRegionToOutputRegion - (OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion) ITK_OVERRIDE; + (OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion) override; /** CallCopyOutputRegionToInputRegion * This function is also redefined in order to adapt the shape of the regions with @@ -272,7 +272,7 @@ protected: const InputImageRegionType& srcRegion); /** Generate data redefinition */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** Iterative call to the forward filter bank at each dimension. */ virtual void ThreadedGenerateDataAtDimensionN(unsigned int idx, unsigned int direction, @@ -399,9 +399,9 @@ public: protected: WaveletFilterBank(); - ~WaveletFilterBank() ITK_OVERRIDE {} + ~WaveletFilterBank() override {} - void VerifyInputInformation() ITK_OVERRIDE + void VerifyInputInformation() override { } @@ -410,7 +410,7 @@ protected: * Set the size of the output image depending on the decimation factor * Copy information from the input image if existing. **/ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** The inverse transformation needs larger inputs requested * region than the output requested region (larger by subsampling @@ -422,12 +422,12 @@ protected: * * \sa ImageToImageFilter::GenerateInputRequestedRegion() */ void GenerateInputRequestedRegion() - throw (itk::InvalidRequestedRegionError) ITK_OVERRIDE; + throw (itk::InvalidRequestedRegionError) override; /** BeforeThreadedGenerateData * If SubsampleImageFactor neq 1, it is necessary to up sample input images in the Wavelet::INVERSE mode */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Internal Data Allocation * If m_SubsampleImageFactor != 1, internal data with progressive region size @@ -438,7 +438,7 @@ protected: /** AfterThreadedGenerateData. * It enforce memory destruction of internal images */ - void AfterThreadedGenerateData() ITK_OVERRIDE; + void AfterThreadedGenerateData() override; /** CallCopyOutputRegionToInputRegion * Since input and output image may be of different size when a @@ -446,9 +446,9 @@ protected: * functions has to be reimplemented */ void CallCopyOutputRegionToInputRegion - (InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) ITK_OVERRIDE; + (InputImageRegionType& destRegion, const OutputImageRegionType& srcRegion) override; void CallCopyInputRegionToOutputRegion - (OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion) ITK_OVERRIDE; + (OutputImageRegionType& destRegion, const InputImageRegionType& srcRegion) override; /** CallCopyOutputRegionToInputRegion * This function is also redefined in order to adapt the shape of the regions with @@ -462,7 +462,7 @@ protected: const InputImageRegionType& srcRegion); /** Generate data redefinition */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** * Iterative call to the forward filter bank at each dimension. diff --git a/Modules/Filtering/Wavelet/include/otbWaveletGenerator.h b/Modules/Filtering/Wavelet/include/otbWaveletGenerator.h index e52d6e7d66..ba5a8a0b83 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletGenerator.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletGenerator.h @@ -100,7 +100,7 @@ public: protected: WaveletGenerator() {} - ~WaveletGenerator() ITK_OVERRIDE {} + ~WaveletGenerator() override {} private: WaveletGenerator(const Self &); // not implemented diff --git a/Modules/Filtering/Wavelet/include/otbWaveletHighPassOperator.h b/Modules/Filtering/Wavelet/include/otbWaveletHighPassOperator.h index 632bf1d79b..1310f178bf 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletHighPassOperator.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletHighPassOperator.h @@ -60,7 +60,7 @@ public: protected: - void PrintSelf(std::ostream& os, itk::Indent i) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent i) const override { os << i << "WaveletHighPassOperator {this=" << this << "}" << std::endl; Superclass::PrintSelf(os, i.GetNextIndent()); @@ -76,7 +76,7 @@ protected: /** * Set operator coefficients. */ - CoefficientVector GenerateCoefficients() ITK_OVERRIDE + CoefficientVector GenerateCoefficients() override { CoefficientVector coeff; if (DirectionOfTransformation == Wavelet::FORWARD) diff --git a/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.h index 1d4f15234a..68d914c7af 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.h @@ -92,11 +92,11 @@ protected: WaveletImageFilter(); virtual ~WaveletImageFilter(); - virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; + virtual void GenerateInputRequestedRegion() override; - virtual void GenerateData() ITK_OVERRIDE; + virtual void GenerateData() override; - virtual void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: WaveletImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.h index 1b28666526..e064511df5 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.h @@ -87,17 +87,17 @@ public: itkSetMacro(NumberOfDecompositions,unsigned int); /** If the filter is modified, the internal filters need to be modified too */ - virtual void Modified() const ITK_OVERRIDE; + virtual void Modified() const override; protected: WaveletInverseImageFilter(); virtual ~WaveletInverseImageFilter(); - virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; + virtual void GenerateInputRequestedRegion() override; - virtual void GenerateData() ITK_OVERRIDE; + virtual void GenerateData() override; - virtual void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: WaveletInverseImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Wavelet/include/otbWaveletLowPassOperator.h b/Modules/Filtering/Wavelet/include/otbWaveletLowPassOperator.h index 1169158949..7eaeaed296 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletLowPassOperator.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletLowPassOperator.h @@ -59,7 +59,7 @@ public: protected: - void PrintSelf(std::ostream& os, itk::Indent i) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent i) const override { os << i << "WaveletLowPassOperator {this=" << this << "}" << std::endl; Superclass::PrintSelf(os, i.GetNextIndent()); @@ -75,7 +75,7 @@ protected: /** * Set operator coefficients. */ - CoefficientVector GenerateCoefficients() ITK_OVERRIDE + CoefficientVector GenerateCoefficients() override { CoefficientVector coeff; if (DirectionOfTransformation == Wavelet::FORWARD) diff --git a/Modules/Filtering/Wavelet/include/otbWaveletOperatorBase.h b/Modules/Filtering/Wavelet/include/otbWaveletOperatorBase.h index f3f4c6c464..c8e1d21ede 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletOperatorBase.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletOperatorBase.h @@ -100,7 +100,7 @@ public: m_WaveletGenerator = WaveletGeneratorType::New(); } - ~WaveletOperatorBase() ITK_OVERRIDE {} + ~WaveletOperatorBase() override {} /** Assignment operator */ Self & operator =(const Self& other) @@ -138,7 +138,7 @@ protected: /** * Prints some debugging information */ - void PrintSelf(std::ostream& os, itk::Indent i) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent i) const override; typedef WaveletGenerator<TMotherWaveletOperator> WaveletGeneratorType; typedef typename WaveletGeneratorType::Pointer WaveletGeneratorPointerType; @@ -187,7 +187,7 @@ protected: void ReduceFilterLength(CoefficientVector& coeff); /** Arranges coefficients spatially in the memory buffer. */ - void Fill(const CoefficientVector& coeff) ITK_OVERRIDE + void Fill(const CoefficientVector& coeff) override { this->FillCenteredDirectional(coeff); } diff --git a/Modules/Filtering/Wavelet/include/otbWaveletPacketDecompositionCosts.h b/Modules/Filtering/Wavelet/include/otbWaveletPacketDecompositionCosts.h index e11648fe24..36a4999486 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletPacketDecompositionCosts.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletPacketDecompositionCosts.h @@ -69,7 +69,7 @@ public: protected: FullyDecomposedWaveletPacketCost () {} - ~FullyDecomposedWaveletPacketCost() ITK_OVERRIDE {} + ~FullyDecomposedWaveletPacketCost() override {} private: FullyDecomposedWaveletPacketCost (const Self &); // not implemented diff --git a/Modules/Filtering/Wavelet/include/otbWaveletPacketTransform.h b/Modules/Filtering/Wavelet/include/otbWaveletPacketTransform.h index c0ea33c8c1..4efc0a1286 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletPacketTransform.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletPacketTransform.h @@ -185,13 +185,13 @@ public: protected: WaveletPacketTransform(); - ~WaveletPacketTransform() ITK_OVERRIDE {} + ~WaveletPacketTransform() override {} /** Generate data redefinition. * This class does not performs multi-threading directly. But it uses step by step the * GenerateData() of TFilter. If This one can thread, the transformation is threaded * (e.g. WaveletFilterBank) */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Performs (if any) the local decomposition (called recursively) */ virtual void GenerateData(unsigned int depth, OutputImageType * outputPtr, @@ -323,19 +323,19 @@ public: protected: WaveletPacketTransform(); - ~WaveletPacketTransform() ITK_OVERRIDE {} + ~WaveletPacketTransform() override {} /** GenerateOutputInformation * Set the size of the output image depending on the decimation factor * Copy information from the input image if existing. **/ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate data redefinition. * This class does not performs multi-threading directly. But it uses step by step the * GenerateData() of TFilter. If This one can thread, the transformation is threaded * (e.g. WaveletFilterBank) */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Performs (if any) the local decomposition (called recursively) */ virtual unsigned int SetInputFilters(unsigned int& ruleID, InputImageIterator& inputIter, diff --git a/Modules/Filtering/Wavelet/include/otbWaveletTransform.h b/Modules/Filtering/Wavelet/include/otbWaveletTransform.h index d4aa6d4fdf..4a0a43f8d5 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletTransform.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletTransform.h @@ -175,10 +175,10 @@ public: protected: WaveletTransform(); - ~WaveletTransform() ITK_OVERRIDE {} + ~WaveletTransform() override {} /** Generate data redefinition */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: WaveletTransform (const Self &); @@ -306,16 +306,16 @@ public: protected: WaveletTransform(); - ~WaveletTransform() ITK_OVERRIDE {} + ~WaveletTransform() override {} /** GenerateOutputInformation * Set the size of the output image depending on the decimation factor * Copy information from the input image if existing. **/ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate data redefinition */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: WaveletTransform (const Self &); diff --git a/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h index ea26fe6226..064a79856b 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h @@ -68,19 +68,19 @@ public: protected: /** Main computation method */ - virtual void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + virtual void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) override; /** GenerateOutputInformation * Set the number of bands of the output. * Copy information from the first image of the list if existing. **/ - virtual void GenerateOutputInformation(void) ITK_OVERRIDE; + virtual void GenerateOutputInformation(void) override; /** * GenerateInputRequestedRegion * Set the requested region of each image in the list. */ - virtual void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + virtual void GenerateInputRequestedRegion(void) override; /** Constructor */ WaveletsBandsListToWaveletsSynopsisImageFilter(); @@ -89,7 +89,7 @@ protected: virtual ~WaveletsBandsListToWaveletsSynopsisImageFilter(); /**PrintSelf method */ - virtual void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: WaveletsBandsListToWaveletsSynopsisImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.h index a19c09bacb..2c547f8b51 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.h @@ -80,7 +80,7 @@ public: itkGetMacro(DecimationRatio,unsigned int); /** If the filter is modified, the extract list need to be regenerated */ - virtual void Modified() const ITK_OVERRIDE; + virtual void Modified() const override; protected: /** Constructor */ @@ -90,16 +90,16 @@ protected: virtual ~WaveletsSynopsisImageToWaveletsBandsListFilter(); /**PrintSelf method */ - virtual void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Generate the input requested region from the first element in the list. */ - virtual void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + virtual void GenerateInputRequestedRegion(void) override; /** Generate the output information by building the output list. */ - virtual void GenerateOutputInformation(void) ITK_OVERRIDE; + virtual void GenerateOutputInformation(void) override; /** Main computation method */ - virtual void GenerateData(void) ITK_OVERRIDE; + virtual void GenerateData(void) override; private: WaveletsSynopsisImageToWaveletsBandsListFilter(const Self&); //purposely not implemented diff --git a/Modules/Fusion/Fuzzy/include/otbFuzzyVariable.h b/Modules/Fusion/Fuzzy/include/otbFuzzyVariable.h index 4781b8e4e3..8ff9ae486c 100644 --- a/Modules/Fusion/Fuzzy/include/otbFuzzyVariable.h +++ b/Modules/Fusion/Fuzzy/include/otbFuzzyVariable.h @@ -107,9 +107,9 @@ protected: /** Constructor */ FuzzyVariable(); /** Destructor */ - ~FuzzyVariable() ITK_OVERRIDE {} + ~FuzzyVariable() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** Map containing the membership functions */ diff --git a/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h b/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h index bc4bc866b7..042106701c 100644 --- a/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h +++ b/Modules/Fusion/MajorityVoting/include/otbNeighborhoodMajorityVotingImageFilter.h @@ -159,7 +159,7 @@ public: protected: NeighborhoodMajorityVotingImageFilter(); - ~NeighborhoodMajorityVotingImageFilter() ITK_OVERRIDE {}; + ~NeighborhoodMajorityVotingImageFilter() override {}; /** Evaluate image neighborhood with kernel to find the new value * for the center pixel value @@ -169,9 +169,9 @@ protected: * Evaluate is used for non-boundary pixels. */ PixelType Evaluate(const NeighborhoodIteratorType &nit, const KernelIteratorType kernelBegin, - const KernelIteratorType kernelEnd) ITK_OVERRIDE; + const KernelIteratorType kernelEnd) override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; //Type to store the useful information from the label histogram diff --git a/Modules/Fusion/PanSharpening/include/otbBayesianFusionFilter.h b/Modules/Fusion/PanSharpening/include/otbBayesianFusionFilter.h index 80290995ac..c57b46d568 100644 --- a/Modules/Fusion/PanSharpening/include/otbBayesianFusionFilter.h +++ b/Modules/Fusion/PanSharpening/include/otbBayesianFusionFilter.h @@ -298,14 +298,14 @@ public: protected: BayesianFusionFilter(); - ~BayesianFusionFilter() ITK_OVERRIDE; + ~BayesianFusionFilter() override; /** Check if internal statistics need to be computed, and do so */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Compute internal statistics required for fusion */ void ComputeInternalStatistics(void); /** Call the superclass implementation and set the StatisticsHaveBeenGenerated * flag to false */ - void Modified(void) const ITK_OVERRIDE; + void Modified(void) const override; private: /** Ponderation declaration*/ diff --git a/Modules/Fusion/PanSharpening/include/otbLmvmPanSharpeningFusionImageFilter.h b/Modules/Fusion/PanSharpening/include/otbLmvmPanSharpeningFusionImageFilter.h index 4a87bd3f0f..df34eeadeb 100644 --- a/Modules/Fusion/PanSharpening/include/otbLmvmPanSharpeningFusionImageFilter.h +++ b/Modules/Fusion/PanSharpening/include/otbLmvmPanSharpeningFusionImageFilter.h @@ -110,13 +110,13 @@ protected: LmvmPanSharpeningFusionImageFilter(); /** Destructor */ - ~LmvmPanSharpeningFusionImageFilter() ITK_OVERRIDE {}; + ~LmvmPanSharpeningFusionImageFilter() override {}; /** Call to generate data, wiring composite internal minipipeline */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LmvmPanSharpeningFusionImageFilter(Self &); // intentionally not implemented diff --git a/Modules/Fusion/PanSharpening/include/otbSimpleRcsPanSharpeningFusionImageFilter.h b/Modules/Fusion/PanSharpening/include/otbSimpleRcsPanSharpeningFusionImageFilter.h index 75cb290f5e..2808c721eb 100644 --- a/Modules/Fusion/PanSharpening/include/otbSimpleRcsPanSharpeningFusionImageFilter.h +++ b/Modules/Fusion/PanSharpening/include/otbSimpleRcsPanSharpeningFusionImageFilter.h @@ -95,13 +95,13 @@ protected: SimpleRcsPanSharpeningFusionImageFilter(); /** Destructor */ - ~SimpleRcsPanSharpeningFusionImageFilter() ITK_OVERRIDE {}; + ~SimpleRcsPanSharpeningFusionImageFilter() override {}; /** Call to generate data, wiring composite internal minipipeline */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SimpleRcsPanSharpeningFusionImageFilter(Self &); // intentionally not implemented diff --git a/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorFilter.h b/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorFilter.h index 0876c7427d..0207220ff0 100644 --- a/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorFilter.h +++ b/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorFilter.h @@ -94,16 +94,16 @@ public: itkGetMacro(ExternalRadius, int); /** Main computation method */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; // virtual void GenerateData(); - void BeforeThreadedGenerateData() ITK_OVERRIDE; - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; protected: LocalRxDetectorFilter(); - ~LocalRxDetectorFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LocalRxDetectorFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LocalRxDetectorFilter(const Self&); //purposely not implemented diff --git a/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorNonThreadFilter.h b/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorNonThreadFilter.h index e369bc5eb6..257efd5c6c 100644 --- a/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorNonThreadFilter.h +++ b/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorNonThreadFilter.h @@ -93,16 +93,16 @@ public: itkGetMacro(ExternalRadius, int); /** Main computation method */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; - void GenerateData() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; + void GenerateData() override; // virtual void BeforeThreadedGenerateData(); // virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId); protected: LocalRxDetectorNonThreadFilter(); - ~LocalRxDetectorNonThreadFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LocalRxDetectorNonThreadFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LocalRxDetectorNonThreadFilter(const Self&); //purposely not implemented diff --git a/Modules/Hyperspectral/EndmembersExtraction/include/otbEigenvalueLikelihoodMaximisation.h b/Modules/Hyperspectral/EndmembersExtraction/include/otbEigenvalueLikelihoodMaximisation.h index 548d493a4a..68bc950a42 100644 --- a/Modules/Hyperspectral/EndmembersExtraction/include/otbEigenvalueLikelihoodMaximisation.h +++ b/Modules/Hyperspectral/EndmembersExtraction/include/otbEigenvalueLikelihoodMaximisation.h @@ -105,8 +105,8 @@ public: protected: EigenvalueLikelihoodMaximisation(); - ~EigenvalueLikelihoodMaximisation() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~EigenvalueLikelihoodMaximisation() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: EigenvalueLikelihoodMaximisation(const Self &); //purposely not implemented diff --git a/Modules/Hyperspectral/EndmembersExtraction/include/otbVcaImageFilter.h b/Modules/Hyperspectral/EndmembersExtraction/include/otbVcaImageFilter.h index c921d60ab8..e91d2346dc 100644 --- a/Modules/Hyperspectral/EndmembersExtraction/include/otbVcaImageFilter.h +++ b/Modules/Hyperspectral/EndmembersExtraction/include/otbVcaImageFilter.h @@ -104,12 +104,12 @@ public: itkGetMacro( NumberOfEndmembers, unsigned int ); itkSetMacro( NumberOfEndmembers, unsigned int ); - void Update() ITK_OVERRIDE + void Update() override { this->GenerateData(); } - void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output)) ITK_OVERRIDE + void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output)) override { this->GetOutput() ->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion() ); @@ -118,13 +118,13 @@ public: protected: VCAImageFilter(); - ~VCAImageFilter() ITK_OVERRIDE; + ~VCAImageFilter() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: VCAImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Hyperspectral/EndmembersExtraction/include/otbVirtualDimensionality.h b/Modules/Hyperspectral/EndmembersExtraction/include/otbVirtualDimensionality.h index 979f7f8bbb..89e8b9066f 100644 --- a/Modules/Hyperspectral/EndmembersExtraction/include/otbVirtualDimensionality.h +++ b/Modules/Hyperspectral/EndmembersExtraction/include/otbVirtualDimensionality.h @@ -118,8 +118,8 @@ public: protected: VirtualDimensionality(); - ~VirtualDimensionality() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~VirtualDimensionality() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: VirtualDimensionality(const Self &); //purposely not implemented diff --git a/Modules/Hyperspectral/Unmixing/include/otbISRAUnmixingImageFilter.h b/Modules/Hyperspectral/Unmixing/include/otbISRAUnmixingImageFilter.h index ae0dcb19fd..965c5180e8 100644 --- a/Modules/Hyperspectral/Unmixing/include/otbISRAUnmixingImageFilter.h +++ b/Modules/Hyperspectral/Unmixing/include/otbISRAUnmixingImageFilter.h @@ -171,9 +171,9 @@ public: protected: ISRAUnmixingImageFilter(); - ~ISRAUnmixingImageFilter() ITK_OVERRIDE; + ~ISRAUnmixingImageFilter() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ISRAUnmixingImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Hyperspectral/Unmixing/include/otbMDMDNMFImageFilter.h b/Modules/Hyperspectral/Unmixing/include/otbMDMDNMFImageFilter.h index ebef4fe9ca..14d05bbca4 100644 --- a/Modules/Hyperspectral/Unmixing/include/otbMDMDNMFImageFilter.h +++ b/Modules/Hyperspectral/Unmixing/include/otbMDMDNMFImageFilter.h @@ -193,18 +193,18 @@ public: protected: MDMDNMFImageFilter(); - ~MDMDNMFImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~MDMDNMFImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** GenerateOutputInformation * Propagate vector length info and modify if needed */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: diff --git a/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.h b/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.h index fc433e998d..e7fe656079 100644 --- a/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.h +++ b/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.h @@ -174,9 +174,9 @@ public: protected: NCLSUnmixingImageFilter(); - ~NCLSUnmixingImageFilter() ITK_OVERRIDE; + ~NCLSUnmixingImageFilter() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: NCLSUnmixingImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Hyperspectral/Unmixing/include/otbSparseUnmixingImageFilter.h b/Modules/Hyperspectral/Unmixing/include/otbSparseUnmixingImageFilter.h index 71adb011c1..4e38022e23 100644 --- a/Modules/Hyperspectral/Unmixing/include/otbSparseUnmixingImageFilter.h +++ b/Modules/Hyperspectral/Unmixing/include/otbSparseUnmixingImageFilter.h @@ -162,9 +162,9 @@ public: protected: SparseUnmixingImageFilter(); - ~SparseUnmixingImageFilter() ITK_OVERRIDE { } + ~SparseUnmixingImageFilter() override { } - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; virtual void GenerateNumberOfComponentsRequired (); private: SparseUnmixingImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Hyperspectral/Unmixing/include/otbUnConstrainedLeastSquareImageFilter.h b/Modules/Hyperspectral/Unmixing/include/otbUnConstrainedLeastSquareImageFilter.h index 128cf2af00..ad8ef27c1b 100644 --- a/Modules/Hyperspectral/Unmixing/include/otbUnConstrainedLeastSquareImageFilter.h +++ b/Modules/Hyperspectral/Unmixing/include/otbUnConstrainedLeastSquareImageFilter.h @@ -174,9 +174,9 @@ public: protected: UnConstrainedLeastSquareImageFilter(); - ~UnConstrainedLeastSquareImageFilter() ITK_OVERRIDE {} + ~UnConstrainedLeastSquareImageFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: UnConstrainedLeastSquareImageFilter(const Self &); //purposely not implemented diff --git a/Modules/IO/Carto/include/otbCoordinateToName.h b/Modules/IO/Carto/include/otbCoordinateToName.h index 7fe3307a04..b2bc93de52 100644 --- a/Modules/IO/Carto/include/otbCoordinateToName.h +++ b/Modules/IO/Carto/include/otbCoordinateToName.h @@ -118,8 +118,8 @@ public: protected: CoordinateToName(); - ~CoordinateToName() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~CoordinateToName() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; void ParseXMLGeonames(std::string& placeName, std::string& countryName) const; virtual void DoEvaluate(); diff --git a/Modules/IO/Carto/include/otbImageToOSMVectorDataGenerator.h b/Modules/IO/Carto/include/otbImageToOSMVectorDataGenerator.h index 85c797c601..d69770c378 100644 --- a/Modules/IO/Carto/include/otbImageToOSMVectorDataGenerator.h +++ b/Modules/IO/Carto/include/otbImageToOSMVectorDataGenerator.h @@ -81,13 +81,13 @@ public: const ImageType* GetInput() const; protected: - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; // Method to compute the extent of the image void EstimateImageExtent(); ImageToOSMVectorDataGenerator(); - ~ImageToOSMVectorDataGenerator() ITK_OVERRIDE {} + ~ImageToOSMVectorDataGenerator() override {} private: ImageToOSMVectorDataGenerator(const Self&); //purposely not implemented diff --git a/Modules/IO/Carto/include/otbMapFileProductWriter.h b/Modules/IO/Carto/include/otbMapFileProductWriter.h index edfaf5b272..4ec15cd4e4 100644 --- a/Modules/IO/Carto/include/otbMapFileProductWriter.h +++ b/Modules/IO/Carto/include/otbMapFileProductWriter.h @@ -154,7 +154,7 @@ public: itkGetStringMacro(ShapeIndexPath); /** Update Method : Call a porotected Write method */ - void Update() ITK_OVERRIDE + void Update() override { this->Write(); } @@ -164,8 +164,8 @@ public: protected: MapFileProductWriter(); - ~MapFileProductWriter() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~MapFileProductWriter() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /**Method for Tiling the input image*/ virtual void Tiling(); diff --git a/Modules/IO/Carto/include/otbOSMDataToVectorDataGenerator.h b/Modules/IO/Carto/include/otbOSMDataToVectorDataGenerator.h index a9f1e10655..5c3383e807 100644 --- a/Modules/IO/Carto/include/otbOSMDataToVectorDataGenerator.h +++ b/Modules/IO/Carto/include/otbOSMDataToVectorDataGenerator.h @@ -166,7 +166,7 @@ public: protected: /** Generate Data method : launch the process */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** * Parse the xml file get from OSM to compose the requested vector @@ -186,7 +186,7 @@ protected: OSMDataToVectorDataGenerator(); - ~OSMDataToVectorDataGenerator() ITK_OVERRIDE; + ~OSMDataToVectorDataGenerator() override; private: OSMDataToVectorDataGenerator(const Self&); //purposely not implemented diff --git a/Modules/IO/Carto/include/otbPlaceNameToLonLat.h b/Modules/IO/Carto/include/otbPlaceNameToLonLat.h index 002a130ce7..3ea71f9ccf 100644 --- a/Modules/IO/Carto/include/otbPlaceNameToLonLat.h +++ b/Modules/IO/Carto/include/otbPlaceNameToLonLat.h @@ -61,8 +61,8 @@ public: protected: PlaceNameToLonLat(); - ~PlaceNameToLonLat() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~PlaceNameToLonLat() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; void RetrieveXML(const std::ostringstream& urlStream); void ParseXMLYahoo(); void ParseXMLGoogle(); diff --git a/Modules/IO/Carto/include/otbWorldFile.h b/Modules/IO/Carto/include/otbWorldFile.h index 0c07086a32..5e26171a94 100644 --- a/Modules/IO/Carto/include/otbWorldFile.h +++ b/Modules/IO/Carto/include/otbWorldFile.h @@ -96,7 +96,7 @@ protected: m_LonSpacing(0.0), m_LatSpacing(0.0), m_LonRotation(0.0), m_LatRotation(0.0), m_ImageFilename("") {} - ~WorldFile() ITK_OVERRIDE {} + ~WorldFile() override {} private: WorldFile(const Self &); //purposely not implemented diff --git a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameHelper.h b/Modules/IO/ExtendedFilename/include/otbExtendedFilenameHelper.h index b6d29171cd..72123839c7 100644 --- a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameHelper.h +++ b/Modules/IO/ExtendedFilename/include/otbExtendedFilenameHelper.h @@ -81,7 +81,7 @@ public: protected: ExtendedFilenameHelper() {} - ~ExtendedFilenameHelper() ITK_OVERRIDE {} + ~ExtendedFilenameHelper() override {} private: ExtendedFilenameHelper(const Self &); //purposely not implemented diff --git a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToReaderOptions.h b/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToReaderOptions.h index 79c8bb00e0..374e9dbe56 100644 --- a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToReaderOptions.h +++ b/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToReaderOptions.h @@ -79,7 +79,7 @@ public: }; /* Set Methods */ - void SetExtendedFileName(const char * extFname) ITK_OVERRIDE; + void SetExtendedFileName(const char * extFname) override; /* Get Methods */ bool SimpleFileNameIsSet () const; bool ExtGEOMFileNameIsSet () const; @@ -101,7 +101,7 @@ public: protected: ExtendedFilenameToReaderOptions(); - ~ExtendedFilenameToReaderOptions() ITK_OVERRIDE {} + ~ExtendedFilenameToReaderOptions() override {} private: ExtendedFilenameToReaderOptions(const Self &); //purposely not implemented diff --git a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToWriterOptions.h b/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToWriterOptions.h index 81909d1528..c1754bd2cd 100644 --- a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToWriterOptions.h +++ b/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToWriterOptions.h @@ -77,7 +77,7 @@ public: }; /* Set Methods */ - void SetExtendedFileName(const char * extFname) ITK_OVERRIDE; + void SetExtendedFileName(const char * extFname) override; /* Get Methods */ bool SimpleFileNameIsSet () const; bool WriteGEOMFileIsSet () const; @@ -102,7 +102,7 @@ public: protected: ExtendedFilenameToWriterOptions(); - ~ExtendedFilenameToWriterOptions() ITK_OVERRIDE {} + ~ExtendedFilenameToWriterOptions() override {} private: ExtendedFilenameToWriterOptions(const Self &); //purposely not implemented diff --git a/Modules/IO/IOBSQ/include/otbBSQImageIO.h b/Modules/IO/IOBSQ/include/otbBSQImageIO.h index 9b6efa368b..b954895cc5 100644 --- a/Modules/IO/IOBSQ/include/otbBSQImageIO.h +++ b/Modules/IO/IOBSQ/include/otbBSQImageIO.h @@ -63,19 +63,19 @@ public: /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanReadFile(const char*) ITK_OVERRIDE; + bool CanReadFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream read the specified file */ - bool CanStreamRead() ITK_OVERRIDE + bool CanStreamRead() override { return true; } /** Set the spacing and dimension information for the set filename. */ - void ReadImageInformation() ITK_OVERRIDE; + void ReadImageInformation() override; /** Reads the data from disk into the memory buffer provided. */ - void Read(void* buffer) ITK_OVERRIDE; + void Read(void* buffer) override; /** Reads 3D data from multiple files assuming one slice per file. */ virtual void ReadVolume(void* buffer); @@ -84,28 +84,28 @@ public: /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanWriteFile(const char*) ITK_OVERRIDE; + bool CanWriteFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream write the specified file */ - bool CanStreamWrite() ITK_OVERRIDE + bool CanStreamWrite() override { return true; } /** Writes the spacing and dimensions of the image. * Assumes SetFileName has been called with a valid file name. */ - void WriteImageInformation() ITK_OVERRIDE; + void WriteImageInformation() override; /** Writes the data to disk from the memory buffer provided. Make sure * that the IORegion has been set properly. */ - void Write(const void* buffer) ITK_OVERRIDE; + void Write(const void* buffer) override; // JULIEN: NOT USED, NOT IMPLEMENTED // void SampleImage(void* buffer, int XBegin, int YBegin, int SizeXRead, int SizeYRead, int XSample, int YSample); /** Get the number of overviews available into the file specified * This imageIO didn't support overviews */ - unsigned int GetOverviewsCount() ITK_OVERRIDE + unsigned int GetOverviewsCount() override { // MANTIS-1154: Source image is always considered as the best // resolution overview. @@ -114,7 +114,7 @@ public: /** Get information about overviews available into the file specified * This imageIO didn't support overviews */ - std::vector<std::string> GetOverviewsInfo() ITK_OVERRIDE + std::vector<std::string> GetOverviewsInfo() override { std::vector<std::string> desc; return desc; @@ -123,13 +123,13 @@ public: /** Provide hist about the output container to deal with complex pixel * type (Not used here) */ void SetOutputImagePixelType( bool itkNotUsed(isComplexInternalPixelType), - bool itkNotUsed(isVectorImage)) ITK_OVERRIDE{} + bool itkNotUsed(isVectorImage)) override{} protected: /** Constructor.*/ BSQImageIO(); /** Destructor.*/ - ~BSQImageIO() ITK_OVERRIDE; + ~BSQImageIO() override; bool OpenOneraDataFileForReading(const char* filename); bool OpenOneraHeaderFileForReading(const char* filename); @@ -138,7 +138,7 @@ protected: bool OpenOneraDataFileForWriting(const char* filename); bool OpenOneraHeaderFileForWriting(const char* filename); - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: BSQImageIO(const Self &); //purposely not implemented diff --git a/Modules/IO/IOBSQ/include/otbBSQImageIOFactory.h b/Modules/IO/IOBSQ/include/otbBSQImageIOFactory.h index 56337e23a7..702729fd34 100644 --- a/Modules/IO/IOBSQ/include/otbBSQImageIOFactory.h +++ b/Modules/IO/IOBSQ/include/otbBSQImageIOFactory.h @@ -40,8 +40,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: BSQImageIOFactory(); - ~BSQImageIOFactory() ITK_OVERRIDE; + ~BSQImageIOFactory() override; private: BSQImageIOFactory(const Self &); //purposely not implemented diff --git a/Modules/IO/IOGDAL/include/otbGDALDatasetWrapper.h b/Modules/IO/IOGDAL/include/otbGDALDatasetWrapper.h index a20b1405a1..667b8f7283 100644 --- a/Modules/IO/IOGDAL/include/otbGDALDatasetWrapper.h +++ b/Modules/IO/IOGDAL/include/otbGDALDatasetWrapper.h @@ -79,7 +79,7 @@ public: protected : GDALDatasetWrapper(); - ~GDALDatasetWrapper() ITK_OVERRIDE; + ~GDALDatasetWrapper() override; private: diff --git a/Modules/IO/IOGDAL/include/otbGDALImageIO.h b/Modules/IO/IOGDAL/include/otbGDALImageIO.h index 49b4678ac4..e494c588dc 100644 --- a/Modules/IO/IOGDAL/include/otbGDALImageIO.h +++ b/Modules/IO/IOGDAL/include/otbGDALImageIO.h @@ -119,7 +119,7 @@ public: /** Provide hist about the output container to deal with complex pixel * type */ void SetOutputImagePixelType( bool isComplexInternalPixelType, - bool isVectorImage) ITK_OVERRIDE + bool isVectorImage) override { this->SetIsComplex(isComplexInternalPixelType); this->SetIsVectorImage(isVectorImage); @@ -129,19 +129,19 @@ public: /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanReadFile(const char*) ITK_OVERRIDE; + bool CanReadFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream read the specified file */ - bool CanStreamRead() ITK_OVERRIDE + bool CanStreamRead() override { return true; } /** Set the spacing and dimension information for the set filename. */ - void ReadImageInformation() ITK_OVERRIDE; + void ReadImageInformation() override; /** Reads the data from disk into the memory buffer provided. */ - void Read(void* buffer) ITK_OVERRIDE; + void Read(void* buffer) override; /** Reads 3D data from multiple files assuming one slice per file. */ virtual void ReadVolume(void* buffer); @@ -156,18 +156,18 @@ public: /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanWriteFile(const char*) ITK_OVERRIDE; + bool CanWriteFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream write the specified file */ - bool CanStreamWrite() ITK_OVERRIDE; + bool CanStreamWrite() override; /** Writes the spacing and dimensions of the image. * Assumes SetFileName has been called with a valid file name. */ - void WriteImageInformation() ITK_OVERRIDE; + void WriteImageInformation() override; /** Writes the data to disk from the memory buffer provided. Make sure * that the IORegion has been set properly. */ - void Write(const void* buffer) ITK_OVERRIDE; + void Write(const void* buffer) override; /** Get all resolutions possible from the file dimensions */ bool GetAvailableResolutions(std::vector<unsigned int>& res); @@ -180,10 +180,10 @@ public: * Currently this overview count is only based on the first band * If no pre-computed overviews are available we provide the overview * count based on size division by 2*/ - unsigned int GetOverviewsCount() ITK_OVERRIDE; + unsigned int GetOverviewsCount() override; /** Get description about overviews available into the file specified */ - std::vector<std::string> GetOverviewsInfo() ITK_OVERRIDE; + std::vector<std::string> GetOverviewsInfo() override; /** Returns gdal pixel type as string */ std::string GetGdalPixelTypeAsString() const; @@ -196,9 +196,9 @@ protected: */ GDALImageIO(); /** Destructor.*/ - ~GDALImageIO() ITK_OVERRIDE; + ~GDALImageIO() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Read all information on the image*/ void InternalReadImageInformation(); /** Write all information on the image*/ diff --git a/Modules/IO/IOGDAL/include/otbGDALImageIOFactory.h b/Modules/IO/IOGDAL/include/otbGDALImageIOFactory.h index e4e13cd11a..275c0db252 100644 --- a/Modules/IO/IOGDAL/include/otbGDALImageIOFactory.h +++ b/Modules/IO/IOGDAL/include/otbGDALImageIOFactory.h @@ -43,8 +43,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -62,7 +62,7 @@ public: protected: GDALImageIOFactory(); - ~GDALImageIOFactory() ITK_OVERRIDE; + ~GDALImageIOFactory() override; private: GDALImageIOFactory(const Self &); //purposely not implemented diff --git a/Modules/IO/IOGDAL/include/otbGDALOverviewsBuilder.h b/Modules/IO/IOGDAL/include/otbGDALOverviewsBuilder.h index 50815a7124..1a803887fa 100644 --- a/Modules/IO/IOGDAL/include/otbGDALOverviewsBuilder.h +++ b/Modules/IO/IOGDAL/include/otbGDALOverviewsBuilder.h @@ -160,15 +160,15 @@ public: void SetInputFileName( const std::string & str ); - void Update() ITK_OVERRIDE; + void Update() override; protected: GDALOverviewsBuilder(); - ~GDALOverviewsBuilder() ITK_OVERRIDE {}; + ~GDALOverviewsBuilder() override {}; - void PrintSelf( std::ostream & os, itk::Indent indent ) const ITK_OVERRIDE; + void PrintSelf( std::ostream & os, itk::Indent indent ) const override; private: diff --git a/Modules/IO/IOGDAL/include/otbOGRIOHelper.h b/Modules/IO/IOGDAL/include/otbOGRIOHelper.h index af76c375c2..003ea24d91 100644 --- a/Modules/IO/IOGDAL/include/otbOGRIOHelper.h +++ b/Modules/IO/IOGDAL/include/otbOGRIOHelper.h @@ -93,7 +93,7 @@ public: protected: OGRIOHelper(); - ~OGRIOHelper() ITK_OVERRIDE; + ~OGRIOHelper() override; private: OGRIOHelper(const Self &); //purposely not implemented diff --git a/Modules/IO/IOGDAL/include/otbOGRVectorDataIO.h b/Modules/IO/IOGDAL/include/otbOGRVectorDataIO.h index d4b1b8c46c..2344ef6fca 100644 --- a/Modules/IO/IOGDAL/include/otbOGRVectorDataIO.h +++ b/Modules/IO/IOGDAL/include/otbOGRVectorDataIO.h @@ -91,29 +91,29 @@ public: /** Determine the file type. Returns true if this VectorDataIO can read the * file specified. */ - bool CanReadFile(const char*) const ITK_OVERRIDE; + bool CanReadFile(const char*) const override; /** Reads the data from disk into the memory buffer provided. */ - void Read(itk::DataObject* data) ITK_OVERRIDE; + void Read(itk::DataObject* data) override; /*-------- This part of the interfaces deals with writing data. ----- */ /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanWriteFile(const char*) const ITK_OVERRIDE; + bool CanWriteFile(const char*) const override; /** Writes the data to disk from the memory buffer provided */ - void Write(const itk::DataObject* data, char ** papszOptions = ITK_NULLPTR) ITK_OVERRIDE; + void Write(const itk::DataObject* data, char ** papszOptions = ITK_NULLPTR) override; protected: /** Constructor.*/ OGRVectorDataIO(); /** Destructor.*/ - ~OGRVectorDataIO() ITK_OVERRIDE; + ~OGRVectorDataIO() override; /* virtual void InternalReadVectorDataInformation(){}; */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: OGRVectorDataIO(const Self &); //purposely not implemented diff --git a/Modules/IO/IOGDAL/include/otbOGRVectorDataIOFactory.h b/Modules/IO/IOGDAL/include/otbOGRVectorDataIOFactory.h index 8202f5d704..c872aeeba8 100644 --- a/Modules/IO/IOGDAL/include/otbOGRVectorDataIOFactory.h +++ b/Modules/IO/IOGDAL/include/otbOGRVectorDataIOFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: OGRVectorDataIOFactory(); - ~OGRVectorDataIOFactory() ITK_OVERRIDE; + ~OGRVectorDataIOFactory() override; private: OGRVectorDataIOFactory(const Self &); //purposely not implemented diff --git a/Modules/IO/IOKML/include/otbKMLVectorDataIO.h b/Modules/IO/IOKML/include/otbKMLVectorDataIO.h index a48dfcb309..c991edea6c 100644 --- a/Modules/IO/IOKML/include/otbKMLVectorDataIO.h +++ b/Modules/IO/IOKML/include/otbKMLVectorDataIO.h @@ -90,27 +90,27 @@ public: /** Determine the file type. Returns true if this VectorDataIO can read the * file specified. */ - bool CanReadFile(const char*) const ITK_OVERRIDE; + bool CanReadFile(const char*) const override; /** Reads the data from disk into the data structure provided. */ - void Read(itk::DataObject* data) ITK_OVERRIDE; + void Read(itk::DataObject* data) override; /*-------- This part of the interfaces deals with writing data. ----- */ /** Determine the file type. Returns true if this VectorDataIO can read the * file specified. */ - bool CanWriteFile(const char*) const ITK_OVERRIDE; + bool CanWriteFile(const char*) const override; /** Writes the data to disk from the data structure provided */ - void Write(const itk::DataObject* data, char ** papszOptions = ITK_NULLPTR) ITK_OVERRIDE; + void Write(const itk::DataObject* data, char ** papszOptions = ITK_NULLPTR) override; protected: /** Constructor.*/ KMLVectorDataIO(); /** Destructor.*/ - ~KMLVectorDataIO() ITK_OVERRIDE; + ~KMLVectorDataIO() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; static const kmldom::FeaturePtr GetRootFeature(const kmldom::ElementPtr& root); diff --git a/Modules/IO/IOKML/include/otbKMLVectorDataIOFactory.h b/Modules/IO/IOKML/include/otbKMLVectorDataIOFactory.h index b480454ac9..590eaf25fe 100644 --- a/Modules/IO/IOKML/include/otbKMLVectorDataIOFactory.h +++ b/Modules/IO/IOKML/include/otbKMLVectorDataIOFactory.h @@ -40,8 +40,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -58,7 +58,7 @@ public: protected: KMLVectorDataIOFactory(); - ~KMLVectorDataIOFactory() ITK_OVERRIDE; + ~KMLVectorDataIOFactory() override; private: KMLVectorDataIOFactory(const Self &); //purposely not implemented diff --git a/Modules/IO/IOLUM/include/otbLUMImageIO.h b/Modules/IO/IOLUM/include/otbLUMImageIO.h index 0597064be5..effe0388ca 100644 --- a/Modules/IO/IOLUM/include/otbLUMImageIO.h +++ b/Modules/IO/IOLUM/include/otbLUMImageIO.h @@ -62,19 +62,19 @@ public: /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanReadFile(const char*) ITK_OVERRIDE; + bool CanReadFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream read the specified file */ - bool CanStreamRead() ITK_OVERRIDE + bool CanStreamRead() override { return true; } /** Set the spacing and dimension information for the set filename. */ - void ReadImageInformation() ITK_OVERRIDE; + void ReadImageInformation() override; /** Reads the data from disk into the memory buffer provided. */ - void Read(void* buffer) ITK_OVERRIDE; + void Read(void* buffer) override; /** Reads 3D data from multiple files assuming one slice per file. */ virtual void ReadVolume(void* buffer); @@ -83,27 +83,27 @@ public: /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanWriteFile(const char*) ITK_OVERRIDE; + bool CanWriteFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream write the specified file */ - bool CanStreamWrite() ITK_OVERRIDE + bool CanStreamWrite() override { return true; } /** Writes the spacing and dimensions of the image. * Assumes SetFileName has been called with a valid file name. */ - void WriteImageInformation() ITK_OVERRIDE; + void WriteImageInformation() override; /** Writes the data to disk from the memory buffer provided. Make sure * that the IORegion has been set properly. */ - void Write(const void* buffer) ITK_OVERRIDE; + void Write(const void* buffer) override; // JULIEN: NOT USED, NOT IMPLEMENTED //void SampleImage(void* buffer, int XBegin, int YBegin, int SizeXRead, int SizeYRead, int XSample, int YSample); /** Get the number of overviews available into the file specified * This imageIO didn't support overviews */ - unsigned int GetOverviewsCount() ITK_OVERRIDE + unsigned int GetOverviewsCount() override { // MANTIS-1154: Source image is always considered as the best // resolution overview. @@ -112,7 +112,7 @@ public: /** Get information about overviews available into the file specified * This imageIO didn't support overviews */ - std::vector<std::string> GetOverviewsInfo() ITK_OVERRIDE + std::vector<std::string> GetOverviewsInfo() override { std::vector<std::string> desc; return desc; @@ -121,13 +121,13 @@ public: /** Provide hist about the output container to deal with complex pixel * type (Not used here) */ void SetOutputImagePixelType( bool itkNotUsed(isComplexInternalPixelType), - bool itkNotUsed(isVectorImage)) ITK_OVERRIDE{} + bool itkNotUsed(isVectorImage)) override{} protected: /** Constructor.*/ LUMImageIO(); /** Destructor.*/ - ~LUMImageIO() ITK_OVERRIDE; + ~LUMImageIO() override; bool OpenOneraDataFileForReading(const char* filename); bool OpenOneraHeaderFileForReading(const char* filename); @@ -136,7 +136,7 @@ protected: bool OpenOneraDataFileForWriting(const char* filename); bool OpenOneraHeaderFileForWriting(const char* filename); - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LUMImageIO(const Self &); //purposely not implemented diff --git a/Modules/IO/IOLUM/include/otbLUMImageIOFactory.h b/Modules/IO/IOLUM/include/otbLUMImageIOFactory.h index 8a11fe3595..f1c06592f7 100644 --- a/Modules/IO/IOLUM/include/otbLUMImageIOFactory.h +++ b/Modules/IO/IOLUM/include/otbLUMImageIOFactory.h @@ -40,8 +40,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: LUMImageIOFactory(); - ~LUMImageIOFactory() ITK_OVERRIDE; + ~LUMImageIOFactory() override; private: LUMImageIOFactory(const Self &); //purposely not implemented diff --git a/Modules/IO/IOMSTAR/include/otbMSTARImageIO.h b/Modules/IO/IOMSTAR/include/otbMSTARImageIO.h index 6de01a473c..fed00e395b 100644 --- a/Modules/IO/IOMSTAR/include/otbMSTARImageIO.h +++ b/Modules/IO/IOMSTAR/include/otbMSTARImageIO.h @@ -55,47 +55,47 @@ public: /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanReadFile(const char*) ITK_OVERRIDE; + bool CanReadFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream read the specified file */ - bool CanStreamRead() ITK_OVERRIDE + bool CanStreamRead() override { return true; } /** Set the spacing and dimension information for the set filename. */ - void ReadImageInformation() ITK_OVERRIDE; + void ReadImageInformation() override; /** Reads the data from disk into the memory buffer provided. */ - void Read(void* buffer) ITK_OVERRIDE; + void Read(void* buffer) override; /*-------- This part of the interfaces deals with writing data. ----- */ /** Determine the file type. Returns true if this ImageIO can write the * file specified. */ - bool CanWriteFile(const char*) ITK_OVERRIDE; + bool CanWriteFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream write the specified file */ - bool CanStreamWrite() ITK_OVERRIDE + bool CanStreamWrite() override { return true; } /** Set the spacing and dimension information for the set filename. */ - void WriteImageInformation() ITK_OVERRIDE; + void WriteImageInformation() override; /** Writes the data to disk from the memory buffer provided. Make sure * that the IORegions has been set properly. */ - void Write(const void* buffer) ITK_OVERRIDE; + void Write(const void* buffer) override; MSTARImageIO(); - ~MSTARImageIO() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~MSTARImageIO() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Get the number of overviews available into the file specified * This imageIO didn't support overviews */ - unsigned int GetOverviewsCount() ITK_OVERRIDE + unsigned int GetOverviewsCount() override { // MANTIS-1154: Source image is always considered as the best // resolution overview. @@ -104,7 +104,7 @@ public: /** Get information about overviews available into the file specified * This imageIO didn't support overviews */ - std::vector<std::string> GetOverviewsInfo() ITK_OVERRIDE + std::vector<std::string> GetOverviewsInfo() override { std::vector<std::string> desc; return desc; @@ -113,7 +113,7 @@ public: /** Provide hist about the output container to deal with complex pixel * type (Not used here) */ void SetOutputImagePixelType( bool itkNotUsed(isComplexInternalPixelType), - bool itkNotUsed(isVectorImage)) ITK_OVERRIDE{} + bool itkNotUsed(isVectorImage)) override{} private: MSTARImageIO(const Self &); //purposely not implemented diff --git a/Modules/IO/IOMSTAR/include/otbMSTARImageIOFactory.h b/Modules/IO/IOMSTAR/include/otbMSTARImageIOFactory.h index c72d136008..0b980fd77e 100644 --- a/Modules/IO/IOMSTAR/include/otbMSTARImageIOFactory.h +++ b/Modules/IO/IOMSTAR/include/otbMSTARImageIOFactory.h @@ -40,8 +40,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: MSTARImageIOFactory(); - ~MSTARImageIOFactory() ITK_OVERRIDE; + ~MSTARImageIOFactory() override; private: MSTARImageIOFactory(const Self &); //purposely not implemented diff --git a/Modules/IO/IOONERA/include/otbONERAImageIO.h b/Modules/IO/IOONERA/include/otbONERAImageIO.h index 3715471e8f..620f9ddb6f 100644 --- a/Modules/IO/IOONERA/include/otbONERAImageIO.h +++ b/Modules/IO/IOONERA/include/otbONERAImageIO.h @@ -60,19 +60,19 @@ public: /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanReadFile(const char*) ITK_OVERRIDE; + bool CanReadFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream read the specified file */ - bool CanStreamRead() ITK_OVERRIDE + bool CanStreamRead() override { return true; } /** Set the spacing and dimension information for the set filename. */ - void ReadImageInformation() ITK_OVERRIDE; + void ReadImageInformation() override; /** Reads the data from disk into the memory buffer provided. */ - void Read(void* buffer) ITK_OVERRIDE; + void Read(void* buffer) override; /** Reads 3D data from multiple files assuming one slice per file. */ virtual void ReadVolume(void* buffer); @@ -81,27 +81,27 @@ public: /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanWriteFile(const char*) ITK_OVERRIDE; + bool CanWriteFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream write the specified file */ - bool CanStreamWrite() ITK_OVERRIDE + bool CanStreamWrite() override { return true; } /** Writes the spacing and dimensions of the image. * Assumes SetFileName has been called with a valid file name. */ - void WriteImageInformation() ITK_OVERRIDE; + void WriteImageInformation() override; /** Writes the data to disk from the memory buffer provided. Make sure * that the IORegion has been set properly. */ - void Write(const void* buffer) ITK_OVERRIDE; + void Write(const void* buffer) override; // JULIEN: NOT USED, NOT IMPLEMENTED //void SampleImage(void* buffer, int XBegin, int YBegin, int SizeXRead, int SizeYRead, int XSample, int YSample); /** Get the number of overviews available into the file specified * This imageIO didn't support overviews */ - unsigned int GetOverviewsCount() ITK_OVERRIDE + unsigned int GetOverviewsCount() override { // MANTIS-1154: Source image is always considered as the best // resolution overview. @@ -110,7 +110,7 @@ public: /** Get information about overviews available into the file specified * This imageIO didn't support overviews */ - std::vector<std::string> GetOverviewsInfo() ITK_OVERRIDE + std::vector<std::string> GetOverviewsInfo() override { std::vector<std::string> desc; return desc; @@ -119,13 +119,13 @@ public: /** Provide hist about the output container to deal with complex pixel * type (Not used here) */ void SetOutputImagePixelType( bool itkNotUsed(isComplexInternalPixelType), - bool itkNotUsed(isVectorImage)) ITK_OVERRIDE{} + bool itkNotUsed(isVectorImage)) override{} protected: /** Constructor.*/ ONERAImageIO(); /** Destructor.*/ - ~ONERAImageIO() ITK_OVERRIDE; + ~ONERAImageIO() override; bool OpenOneraDataFileForReading(const char* filename); bool OpenOneraHeaderFileForReading(const char* filename); @@ -136,7 +136,7 @@ protected: bool OpenOneraDataFileForWriting(const char* filename); bool OpenOneraHeaderFileForWriting(const char* filename); - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Dimension along Ox of the image*/ int m_width; diff --git a/Modules/IO/IOONERA/include/otbONERAImageIOFactory.h b/Modules/IO/IOONERA/include/otbONERAImageIOFactory.h index 7b0f638342..6733607127 100644 --- a/Modules/IO/IOONERA/include/otbONERAImageIOFactory.h +++ b/Modules/IO/IOONERA/include/otbONERAImageIOFactory.h @@ -40,8 +40,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: ONERAImageIOFactory(); - ~ONERAImageIOFactory() ITK_OVERRIDE; + ~ONERAImageIOFactory() override; private: ONERAImageIOFactory(const Self &); //purposely not implemented diff --git a/Modules/IO/IORAD/include/otbRADImageIO.h b/Modules/IO/IORAD/include/otbRADImageIO.h index c5ebbd9aee..d7823fd036 100644 --- a/Modules/IO/IORAD/include/otbRADImageIO.h +++ b/Modules/IO/IORAD/include/otbRADImageIO.h @@ -62,19 +62,19 @@ public: /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanReadFile(const char*) ITK_OVERRIDE; + bool CanReadFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream read the specified file */ - bool CanStreamRead() ITK_OVERRIDE + bool CanStreamRead() override { return true; } /** Set the spacing and dimension information for the set filename. */ - void ReadImageInformation() ITK_OVERRIDE; + void ReadImageInformation() override; /** Reads the data from disk into the memory buffer provided. */ - void Read(void* buffer) ITK_OVERRIDE; + void Read(void* buffer) override; /** Reads 3D data from multiple files assuming one slice per file. */ virtual void ReadVolume(void* buffer); @@ -83,28 +83,28 @@ public: /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanWriteFile(const char*) ITK_OVERRIDE; + bool CanWriteFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream write the specified file */ - bool CanStreamWrite() ITK_OVERRIDE + bool CanStreamWrite() override { return true; } /** Writes the spacing and dimensions of the image. * Assumes SetFileName has been called with a valid file name. */ - void WriteImageInformation() ITK_OVERRIDE; + void WriteImageInformation() override; /** Writes the data to disk from the memory buffer provided. Make sure * that the IORegion has been set properly. */ - void Write(const void* buffer) ITK_OVERRIDE; + void Write(const void* buffer) override; // JULIEN: NOT USED, NOT IMPLEMENTED // void SampleImage(void* buffer, int XBegin, int YBegin, int SizeXRead, int SizeYRead, int XSample, int YSample); /** Get the number of overviews available into the file specified * This imageIO didn't support overviews */ - unsigned int GetOverviewsCount() ITK_OVERRIDE + unsigned int GetOverviewsCount() override { // MANTIS-1154: Source image is always considered as the best // resolution overview. @@ -113,7 +113,7 @@ public: /** Get information about overviews available into the file specified * This imageIO didn't support overviews */ - std::vector<std::string> GetOverviewsInfo() ITK_OVERRIDE + std::vector<std::string> GetOverviewsInfo() override { std::vector<std::string> desc; return desc; @@ -122,13 +122,13 @@ public: /** Provide hist about the output container to deal with complex pixel * type (Not used here) */ void SetOutputImagePixelType( bool itkNotUsed(isComplexInternalPixelType), - bool itkNotUsed(isVectorImage)) ITK_OVERRIDE{} + bool itkNotUsed(isVectorImage)) override{} protected: /** Constructor.*/ RADImageIO(); /** Destructor.*/ - ~RADImageIO() ITK_OVERRIDE; + ~RADImageIO() override; bool OpenOneraDataFileForReading(const char* filename); bool OpenOneraHeaderFileForReading(const char* filename); @@ -138,7 +138,7 @@ protected: bool OpenOneraDataFileForWriting(const char* filename); bool OpenOneraHeaderFileForWriting(const char* filename); - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: RADImageIO(const Self &); //purposely not implemented diff --git a/Modules/IO/IORAD/include/otbRADImageIOFactory.h b/Modules/IO/IORAD/include/otbRADImageIOFactory.h index 19f884fd39..1a01a6187a 100644 --- a/Modules/IO/IORAD/include/otbRADImageIOFactory.h +++ b/Modules/IO/IORAD/include/otbRADImageIOFactory.h @@ -40,8 +40,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -59,7 +59,7 @@ public: protected: RADImageIOFactory(); - ~RADImageIOFactory() ITK_OVERRIDE; + ~RADImageIOFactory() override; private: RADImageIOFactory(const Self &); //purposely not implemented diff --git a/Modules/IO/IOTileMap/include/otbTileMapImageIO.h b/Modules/IO/IOTileMap/include/otbTileMapImageIO.h index 99ac2bd784..27a8db556e 100644 --- a/Modules/IO/IOTileMap/include/otbTileMapImageIO.h +++ b/Modules/IO/IOTileMap/include/otbTileMapImageIO.h @@ -92,41 +92,41 @@ public: /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanReadFile(const char*) ITK_OVERRIDE; + bool CanReadFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream read the specified file */ - bool CanStreamRead() ITK_OVERRIDE + bool CanStreamRead() override { return true; } /** Set the spacing and dimension information for the set filename. */ - void ReadImageInformation() ITK_OVERRIDE; + void ReadImageInformation() override; /** Reads the data from disk into the memory buffer provided. */ - void Read(void* buffer) ITK_OVERRIDE; + void Read(void* buffer) override; /** Determine the file type. Returns true if this ImageIO can read the * file specified. */ - bool CanWriteFile(const char*) ITK_OVERRIDE; + bool CanWriteFile(const char*) override; /** Determine the file type. Returns true if the ImageIO can stream write the specified file */ - bool CanStreamWrite() ITK_OVERRIDE + bool CanStreamWrite() override { return true; } /** Writes the spacing and dimensions of the image. * Assumes SetFileName has been called with a valid file name. */ - void WriteImageInformation() ITK_OVERRIDE; + void WriteImageInformation() override; /** Writes the data to disk from the memory buffer provided. Make sure * that the IORegion has been set properly. */ - void Write(const void* buffer) ITK_OVERRIDE; + void Write(const void* buffer) override; /** Get the number of overviews available into the file specified * This imageIO didn't support overviews */ - unsigned int GetOverviewsCount() ITK_OVERRIDE + unsigned int GetOverviewsCount() override { // MANTIS-1154: Source image is always considered as the best // resolution overview. @@ -135,7 +135,7 @@ public: /** Get information about overviews available into the file specified * This imageIO didn't support overviews */ - std::vector<std::string> GetOverviewsInfo() ITK_OVERRIDE + std::vector<std::string> GetOverviewsInfo() override { std::vector<std::string> desc; return desc; @@ -144,26 +144,26 @@ public: /** Provide hist about the output container to deal with complex pixel * type (Not used here) */ void SetOutputImagePixelType( bool itkNotUsed(isComplexInternalPixelType), - bool itkNotUsed(isVectorImage)) ITK_OVERRIDE{} + bool itkNotUsed(isVectorImage)) override{} protected: /** Constructor.*/ TileMapImageIO(); /** Destructor.*/ - ~TileMapImageIO() ITK_OVERRIDE; + ~TileMapImageIO() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Read all information on the image*/ void InternalReadImageInformation(); /** Write all information on the image*/ void InternalWriteImageInformation(); unsigned int GetActualNumberOfSplitsForWritingCanStreamWrite(unsigned int numberOfRequestedSplits, - const ImageIORegion& pasteRegion) const ITK_OVERRIDE; + const ImageIORegion& pasteRegion) const override; ImageIORegion GetSplitRegionForWritingCanStreamWrite(unsigned int ithPiece, unsigned int numberOfActualSplits, - const ImageIORegion& pasteRegion) const ITK_OVERRIDE; + const ImageIORegion& pasteRegion) const override; /** Number of bands of the image*/ int m_NbBands; diff --git a/Modules/IO/IOTileMap/include/otbTileMapImageIOFactory.h b/Modules/IO/IOTileMap/include/otbTileMapImageIOFactory.h index 9edcbc2365..e946e40641 100644 --- a/Modules/IO/IOTileMap/include/otbTileMapImageIOFactory.h +++ b/Modules/IO/IOTileMap/include/otbTileMapImageIOFactory.h @@ -42,8 +42,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -61,7 +61,7 @@ public: protected: TileMapImageIOFactory(); - ~TileMapImageIOFactory() ITK_OVERRIDE; + ~TileMapImageIOFactory() override; private: TileMapImageIOFactory(const Self &); //purposely not implemented diff --git a/Modules/IO/IOTileMap/include/otbTileMapImageIOHelper.h b/Modules/IO/IOTileMap/include/otbTileMapImageIOHelper.h index 412e31f2cf..b9286c5cb7 100644 --- a/Modules/IO/IOTileMap/include/otbTileMapImageIOHelper.h +++ b/Modules/IO/IOTileMap/include/otbTileMapImageIOHelper.h @@ -58,7 +58,7 @@ public: protected: TileMapImageIOHelper() {} - ~TileMapImageIOHelper() ITK_OVERRIDE {} + ~TileMapImageIOHelper() override {} private: TileMapImageIOHelper(const Self &); //purposely not implemented diff --git a/Modules/IO/IOXML/include/otbStatisticsXMLFileReader.h b/Modules/IO/IOXML/include/otbStatisticsXMLFileReader.h index 3eb362df0f..bf4dc01a6c 100644 --- a/Modules/IO/IOXML/include/otbStatisticsXMLFileReader.h +++ b/Modules/IO/IOXML/include/otbStatisticsXMLFileReader.h @@ -64,7 +64,7 @@ public: typedef std::map<std::string , std::string> GenericMapType; typedef std::map<std::string , GenericMapType> GenericMapContainer; - void Modified() const ITK_OVERRIDE + void Modified() const override { m_IsUpdated = false; } @@ -95,8 +95,8 @@ protected: virtual void Read(); StatisticsXMLFileReader(); - ~StatisticsXMLFileReader() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~StatisticsXMLFileReader() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: StatisticsXMLFileReader(const Self&); //purposely not implemented diff --git a/Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.h b/Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.h index 0ea02ea82f..c39686c525 100644 --- a/Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.h +++ b/Modules/IO/IOXML/include/otbStatisticsXMLFileWriter.h @@ -92,8 +92,8 @@ protected: virtual void GenerateData(); StatisticsXMLFileWriter(); - ~StatisticsXMLFileWriter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~StatisticsXMLFileWriter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: StatisticsXMLFileWriter(const Self&); //purposely not implemented diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.h b/Modules/IO/ImageIO/include/otbImageFileReader.h index 631f9d7dc2..f2094973c9 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.h +++ b/Modules/IO/ImageIO/include/otbImageFileReader.h @@ -118,17 +118,17 @@ public: typedef ExtendedFilenameToReaderOptions FNameHelperType; /** Prepare image allocation at the first call of the pipeline processing */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** Does the real work. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Give the reader a chance to indicate that it will produce more * output than it was requested to produce. ImageFileReader cannot * currently read a portion of an image (since the ImageIO objects * cannot read a portion of an image), so the ImageFileReader must * enlarge the RequestedRegion to the size of the image on disk. */ - void EnlargeOutputRequestedRegion(itk::DataObject *output) ITK_OVERRIDE; + void EnlargeOutputRequestedRegion(itk::DataObject *output) override; /** Set/Get the ImageIO helper class. Often this is created via the object * factory mechanism that determines whether a particular ImageIO can @@ -158,8 +158,8 @@ public: protected: ImageFileReader(); - ~ImageFileReader() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageFileReader() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Convert a block of pixels from one type to another. */ void DoConvertBuffer(void* buffer, size_t numberOfPixels); diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.h b/Modules/IO/ImageIO/include/otbImageFileWriter.h index b7bc6499b0..2851c8b03d 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.h @@ -168,7 +168,7 @@ public: /** Override Update() from ProcessObject because this filter * has no output. */ - void Update() ITK_OVERRIDE; + void Update() override; /** ImageFileWriter Methods */ virtual void SetFileName(const char* extendedFileName); @@ -201,11 +201,11 @@ public: protected: ImageFileWriter(); - ~ImageFileWriter() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ImageFileWriter() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Does the real work. */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; private: ImageFileWriter(const ImageFileWriter &); //purposely not implemented diff --git a/Modules/IO/ImageIO/include/otbImageIOFactory.h b/Modules/IO/ImageIO/include/otbImageIOFactory.h index 13643537e9..287c149792 100644 --- a/Modules/IO/ImageIO/include/otbImageIOFactory.h +++ b/Modules/IO/ImageIO/include/otbImageIOFactory.h @@ -59,7 +59,7 @@ public: protected: ImageIOFactory(); - ~ImageIOFactory() ITK_OVERRIDE; + ~ImageIOFactory() override; private: ImageIOFactory(const Self &); //purposely not implemented diff --git a/Modules/IO/ImageIO/include/otbImageSeriesFileReader.h b/Modules/IO/ImageIO/include/otbImageSeriesFileReader.h index 173ccc99d4..d31a890d68 100644 --- a/Modules/IO/ImageIO/include/otbImageSeriesFileReader.h +++ b/Modules/IO/ImageIO/include/otbImageSeriesFileReader.h @@ -428,12 +428,12 @@ public: protected: ImageSeriesFileReader(); - ~ImageSeriesFileReader () ITK_OVERRIDE {} + ~ImageSeriesFileReader () override {} /** * Tests the coherency of the Meta File (especifically band selection) with the image types */ - void TestBandSelection(std::vector<unsigned int>& itkNotUsed(bands)) ITK_OVERRIDE{} + void TestBandSelection(std::vector<unsigned int>& itkNotUsed(bands)) override{} /** GenerateData * This method will be specialised if template definitions follow: @@ -441,7 +441,7 @@ protected: * - TImage is an Image and TInteranalImage is a VectorImage * - TImage and TInternalImage are of Image type. */ - void GenerateData(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + void GenerateData(DataObjectPointerArraySizeType idx) override; using Superclass::GenerateData; /** @@ -449,10 +449,10 @@ protected: * This allows specific (or global) initialization in the GenerateData methods, * that the user may invoke through GenerateOutput() or GenerateOutput( idx ). */ - void AllocateListOfComponents(void) ITK_OVERRIDE; + void AllocateListOfComponents(void) override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { return Superclass::PrintSelf(os, indent); } diff --git a/Modules/IO/ImageIO/include/otbImageSeriesFileReaderBase.h b/Modules/IO/ImageIO/include/otbImageSeriesFileReaderBase.h index fa32e38fc2..58b071957e 100644 --- a/Modules/IO/ImageIO/include/otbImageSeriesFileReaderBase.h +++ b/Modules/IO/ImageIO/include/otbImageSeriesFileReaderBase.h @@ -133,7 +133,7 @@ public: { return m_ListOfFileNames.size(); } - OutputImageListType * GetOutput(void) ITK_OVERRIDE; + OutputImageListType * GetOutput(void) override; virtual OutputImageType * GetOutput(DataObjectPointerArraySizeType idx); /** Performs selective file extraction */ @@ -141,14 +141,14 @@ public: virtual OutputImageType * GenerateOutput(DataObjectPointerArraySizeType idx); /** Synchronization */ - void Update() ITK_OVERRIDE + void Update() override { this->GenerateData(); } protected: ImageSeriesFileReaderBase(); - ~ImageSeriesFileReaderBase () ITK_OVERRIDE {} + ~ImageSeriesFileReaderBase () override {} enum FileType { kFileName = 0, kImageFileName, kAnyFileName }; /** @@ -159,7 +159,7 @@ protected: virtual void TestFileExistenceAndReadability(std::string& file, FileType fileType); virtual void TestBandSelection(std::vector<unsigned int>& itkNotUsed(bands)) {} - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** GenerateData * This method will be specialised if template definitions follow: @@ -181,7 +181,7 @@ protected: virtual void AllocateListOfComponents(void); /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; std::string m_FileName; OutputImageListPointerType m_OutputList; diff --git a/Modules/IO/ImageIO/include/otbScalarBufferToImageFileWriter.h b/Modules/IO/ImageIO/include/otbScalarBufferToImageFileWriter.h index 548611ada1..b09880bce2 100644 --- a/Modules/IO/ImageIO/include/otbScalarBufferToImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbScalarBufferToImageFileWriter.h @@ -91,17 +91,17 @@ public: m_Buffer = pBuff; } - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; - void Update() ITK_OVERRIDE + void Update() override { this->GenerateData(); } protected: ScalarBufferToImageFileWriter(); - ~ScalarBufferToImageFileWriter() ITK_OVERRIDE { /* don't call ClearBuffer, user's care */} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ScalarBufferToImageFileWriter() override { /* don't call ClearBuffer, user's care */} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/IO/KMZWriter/include/otbKmzProductWriter.h b/Modules/IO/KMZWriter/include/otbKmzProductWriter.h index 869fe49bc2..d8957ee2d6 100644 --- a/Modules/IO/KMZWriter/include/otbKmzProductWriter.h +++ b/Modules/IO/KMZWriter/include/otbKmzProductWriter.h @@ -136,7 +136,7 @@ public: itkSetStringMacro(Path); /** Update Method */ - void Update() ITK_OVERRIDE + void Update() override { this->Write(); } @@ -167,8 +167,8 @@ public: protected: KmzProductWriter(); - ~KmzProductWriter() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~KmzProductWriter() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /**Method for Tiling the input image*/ virtual void Tiling(); diff --git a/Modules/IO/TestKernel/include/otbDifferenceImageFilter.h b/Modules/IO/TestKernel/include/otbDifferenceImageFilter.h index 042e2a5a5b..1eb5e1e774 100644 --- a/Modules/IO/TestKernel/include/otbDifferenceImageFilter.h +++ b/Modules/IO/TestKernel/include/otbDifferenceImageFilter.h @@ -91,9 +91,9 @@ public: protected: DifferenceImageFilter(); - ~DifferenceImageFilter() ITK_OVERRIDE {} + ~DifferenceImageFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** DifferenceImageFilter can be implemented as a multithreaded * filter. Therefore, this implementation provides a @@ -107,11 +107,11 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& threadRegion, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; - void AfterThreadedGenerateData() ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; + void AfterThreadedGenerateData() override; + void GenerateOutputInformation() override; ScalarRealType m_DifferenceThreshold; RealType m_MeanDifference; diff --git a/Modules/IO/TestKernel/include/otbTestHelper.h b/Modules/IO/TestKernel/include/otbTestHelper.h index 32e0dba890..0bf593400f 100644 --- a/Modules/IO/TestKernel/include/otbTestHelper.h +++ b/Modules/IO/TestKernel/include/otbTestHelper.h @@ -71,7 +71,7 @@ public: std::string("Integer"),std::string("Integer64"))); } - ~TestHelper() ITK_OVERRIDE{} + ~TestHelper() override{} int RegressionTestAllImages(const StringList& baselineFilenamesImage, const StringList& testFilenamesImage); diff --git a/Modules/IO/VectorDataIO/include/otbVectorDataFileReader.h b/Modules/IO/VectorDataIO/include/otbVectorDataFileReader.h index 71b3bea7bc..3571baf21b 100644 --- a/Modules/IO/VectorDataIO/include/otbVectorDataFileReader.h +++ b/Modules/IO/VectorDataIO/include/otbVectorDataFileReader.h @@ -120,20 +120,20 @@ public: /** Prepare the allocation of the output vector data during the first back * propagation of the pipeline. */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** Does the real work. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; protected: VectorDataFileReader(); - ~VectorDataFileReader() ITK_OVERRIDE; + ~VectorDataFileReader() override; std::string m_ExceptionMessage; typename VectorDataIOBaseType::Pointer m_VectorDataIO; bool m_UserSpecifiedVectorDataIO; // keep track whether the - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; std::string m_FileName; // The file to be read diff --git a/Modules/IO/VectorDataIO/include/otbVectorDataFileWriter.h b/Modules/IO/VectorDataIO/include/otbVectorDataFileWriter.h index 520586e661..4ef6ba6e12 100644 --- a/Modules/IO/VectorDataIO/include/otbVectorDataFileWriter.h +++ b/Modules/IO/VectorDataIO/include/otbVectorDataFileWriter.h @@ -93,9 +93,9 @@ public: /** Does the real work. */ virtual void Write(); - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; - void Update() ITK_OVERRIDE + void Update() override { this->Write(); } @@ -106,9 +106,9 @@ public: protected: VectorDataFileWriter(); - ~VectorDataFileWriter() ITK_OVERRIDE; + ~VectorDataFileWriter() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; std::string m_FileName; // The file to be read typename VectorDataIOBaseType::Pointer m_VectorDataIO; diff --git a/Modules/IO/VectorDataIO/include/otbVectorDataIOFactory.h b/Modules/IO/VectorDataIO/include/otbVectorDataIOFactory.h index 556722fb3b..62754644fa 100644 --- a/Modules/IO/VectorDataIO/include/otbVectorDataIOFactory.h +++ b/Modules/IO/VectorDataIO/include/otbVectorDataIOFactory.h @@ -62,7 +62,7 @@ public: protected: VectorDataIOFactory(); - ~VectorDataIOFactory() ITK_OVERRIDE; + ~VectorDataIOFactory() override; private: VectorDataIOFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/DempsterShafer/include/otbConfusionMatrixToMassOfBelief.h b/Modules/Learning/DempsterShafer/include/otbConfusionMatrixToMassOfBelief.h index da0cdcfa22..bc5891e246 100644 --- a/Modules/Learning/DempsterShafer/include/otbConfusionMatrixToMassOfBelief.h +++ b/Modules/Learning/DempsterShafer/include/otbConfusionMatrixToMassOfBelief.h @@ -85,7 +85,7 @@ public: enum MassOfBeliefDefinitionMethod {PRECISION, RECALL, ACCURACY, KAPPA}; - void Update() ITK_OVERRIDE; + void Update() override; /** Accessors */ itkSetMacro(ConfusionMatrix, ConfusionMatrixType); @@ -141,10 +141,10 @@ protected: ConfusionMatrixToMassOfBelief(); /** Destructor */ - ~ConfusionMatrixToMassOfBelief() ITK_OVERRIDE {}; + ~ConfusionMatrixToMassOfBelief() override {}; /** Triggers the computation of the confusion matrix */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; private: ConfusionMatrixToMassOfBelief(const Self&); //purposely not implemented diff --git a/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.h b/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.h index 723a1aed1b..32d4d430fd 100644 --- a/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.h +++ b/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.h @@ -140,16 +140,16 @@ protected: /** Constructor */ DSFusionOfClassifiersImageFilter(); /** Destructor */ - ~DSFusionOfClassifiersImageFilter() ITK_OVERRIDE {} + ~DSFusionOfClassifiersImageFilter() override {} /** Generate output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Threaded generate data */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** Before threaded generate data */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: DSFusionOfClassifiersImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Learning/DempsterShafer/include/otbJointMassOfBeliefFilter.h b/Modules/Learning/DempsterShafer/include/otbJointMassOfBeliefFilter.h index ac454c1e6f..8e8807b712 100644 --- a/Modules/Learning/DempsterShafer/include/otbJointMassOfBeliefFilter.h +++ b/Modules/Learning/DempsterShafer/include/otbJointMassOfBeliefFilter.h @@ -71,11 +71,11 @@ public: /** Remove the last input */ using Superclass::PopBackInput; - void PopBackInput() ITK_OVERRIDE; + void PopBackInput() override; /** Remove the first input */ using Superclass::PopFrontInput; - void PopFrontInput() ITK_OVERRIDE; + void PopFrontInput() override; /** Get the idx th input */ const MassFunctionType * GetInput(unsigned int idx); @@ -88,13 +88,13 @@ protected: JointMassOfBeliefFilter(); /** Destructor */ - ~JointMassOfBeliefFilter() ITK_OVERRIDE {} + ~JointMassOfBeliefFilter() override {} /** GenerateData */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: JointMassOfBeliefFilter(const Self&); //purposely not implemented diff --git a/Modules/Learning/DempsterShafer/include/otbMassOfBelief.h b/Modules/Learning/DempsterShafer/include/otbMassOfBelief.h index 7e2eff5636..70e8f909fe 100644 --- a/Modules/Learning/DempsterShafer/include/otbMassOfBelief.h +++ b/Modules/Learning/DempsterShafer/include/otbMassOfBelief.h @@ -180,10 +180,10 @@ protected: MassOfBelief() {} /** Desctructor */ - ~MassOfBelief() ITK_OVERRIDE {} + ~MassOfBelief() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: MassOfBelief(const Self&); //purposely not implemented diff --git a/Modules/Learning/DempsterShafer/include/otbStandardDSCostFunction.h b/Modules/Learning/DempsterShafer/include/otbStandardDSCostFunction.h index 6623a41895..2c90a53c1e 100644 --- a/Modules/Learning/DempsterShafer/include/otbStandardDSCostFunction.h +++ b/Modules/Learning/DempsterShafer/include/otbStandardDSCostFunction.h @@ -95,14 +95,14 @@ public: /** This method returns the value of the cost function corresponding * to the specified parameters. */ - MeasureType GetValue( const ParametersType & parameters ) const ITK_OVERRIDE; + MeasureType GetValue( const ParametersType & parameters ) const override; /** This method returns the derivative of the cost function corresponding * to the specified parameters. */ void GetDerivative( const ParametersType & parameters, - DerivativeType & derivative ) const ITK_OVERRIDE; + DerivativeType & derivative ) const override; - unsigned int GetNumberOfParameters(void) const ITK_OVERRIDE; + unsigned int GetNumberOfParameters(void) const override; itkSetMacro(Weight, double); itkGetConstMacro(Weight, double); @@ -151,9 +151,9 @@ protected: /** Constructor */ StandardDSCostFunction(); /** Destructor */ - ~StandardDSCostFunction() ITK_OVERRIDE {} + ~StandardDSCostFunction() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: StandardDSCostFunction(const Self &); //purposely not implemented diff --git a/Modules/Learning/DempsterShafer/include/otbVectorDataToDSValidatedVectorDataFilter.h b/Modules/Learning/DempsterShafer/include/otbVectorDataToDSValidatedVectorDataFilter.h index 5b331ae6aa..2a3731307e 100644 --- a/Modules/Learning/DempsterShafer/include/otbVectorDataToDSValidatedVectorDataFilter.h +++ b/Modules/Learning/DempsterShafer/include/otbVectorDataToDSValidatedVectorDataFilter.h @@ -161,13 +161,13 @@ public: protected: /** Triggers the Computation */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Constructor */ VectorDataToDSValidatedVectorDataFilter(); /** Destructor */ - ~VectorDataToDSValidatedVectorDataFilter() ITK_OVERRIDE {} + ~VectorDataToDSValidatedVectorDataFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; std::string GetNextID() { diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h index ee58a9428b..7bf3231a9b 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.h @@ -119,13 +119,13 @@ public: itkGetMacro(LearningCurveFileName,std::string); itkSetMacro(LearningCurveFileName,std::string); - bool CanReadFile(const std::string & filename) ITK_OVERRIDE; - bool CanWriteFile(const std::string & filename) ITK_OVERRIDE; + bool CanReadFile(const std::string & filename) override; + bool CanWriteFile(const std::string & filename) override; - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string & filename, const std::string & name="") override; + void Load(const std::string & filename, const std::string & name="") override; - void Train() ITK_OVERRIDE; + void Train() override; template <class T, class Autoencoder> void TrainOneLayer( @@ -151,18 +151,18 @@ public: protected: AutoencoderModel(); - ~AutoencoderModel() ITK_OVERRIDE; + ~AutoencoderModel() override; virtual TargetSampleType DoPredict( const InputSampleType& input, - ConfidenceValueType * quality = ITK_NULLPTR) const ITK_OVERRIDE; + ConfidenceValueType * quality = ITK_NULLPTR) const override; virtual void DoPredictBatch( const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, - ConfidenceListSampleType * quality = ITK_NULLPTR) const ITK_OVERRIDE; + ConfidenceListSampleType * quality = ITK_NULLPTR) const override; private: /** Internal Network */ diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h index 711711ca4b..e04170ec37 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModelFactory.h @@ -44,8 +44,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -62,7 +62,7 @@ public: protected: AutoencoderModelFactory(); - ~AutoencoderModelFactory() ITK_OVERRIDE; + ~AutoencoderModelFactory() override; private: AutoencoderModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h index 9bbd28bc0b..98c8490383 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.h @@ -61,7 +61,7 @@ public: protected: DimensionalityReductionModelFactory(); - ~DimensionalityReductionModelFactory() ITK_OVERRIDE; + ~DimensionalityReductionModelFactory() override; private: DimensionalityReductionModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h index e3fdf5d8f5..0cfab267dd 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.h @@ -112,19 +112,19 @@ protected: /** Constructor */ ImageDimensionalityReductionFilter(); /** Destructor */ - ~ImageDimensionalityReductionFilter() ITK_OVERRIDE {} + ~ImageDimensionalityReductionFilter() override {} /** Generate output information */ - virtual void GenerateOutputInformation() ITK_OVERRIDE; + virtual void GenerateOutputInformation() override; /** Threaded generate data */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; void ClassicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId); void BatchThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId); /** Before threaded generate data */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageDimensionalityReductionFilter(const Self &); //purposely not implemented diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h index 064ca263da..cfecceb390 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModel.h @@ -80,28 +80,28 @@ public: itkSetMacro(WriteEigenvectors, bool); itkGetMacro(WriteEigenvectors, bool); - bool CanReadFile(const std::string & filename) ITK_OVERRIDE; - bool CanWriteFile(const std::string & filename) ITK_OVERRIDE; + bool CanReadFile(const std::string & filename) override; + bool CanWriteFile(const std::string & filename) override; - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string & filename, const std::string & name="") override; + void Load(const std::string & filename, const std::string & name="") override; - void Train() ITK_OVERRIDE; + void Train() override; protected: PCAModel(); - ~PCAModel() ITK_OVERRIDE; + ~PCAModel() override; virtual TargetSampleType DoPredict( const InputSampleType& input, - ConfidenceValueType * quality = ITK_NULLPTR) const ITK_OVERRIDE; + ConfidenceValueType * quality = ITK_NULLPTR) const override; virtual void DoPredictBatch( const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, - ConfidenceListSampleType * quality = ITK_NULLPTR) const ITK_OVERRIDE; + ConfidenceListSampleType * quality = ITK_NULLPTR) const override; private: shark::LinearModel<> m_Encoder; diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h index d30a2c4663..4080014b10 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbPCAModelFactory.h @@ -43,8 +43,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -61,7 +61,7 @@ public: protected: PCAModelFactory(); - ~PCAModelFactory() ITK_OVERRIDE; + ~PCAModelFactory() override; private: PCAModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h index 5aa7130a6a..e7c77a245c 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModel.h @@ -101,24 +101,24 @@ public: itkSetMacro(Seed, unsigned int); itkGetMacro(Seed, unsigned int); - bool CanReadFile(const std::string & filename) ITK_OVERRIDE; - bool CanWriteFile(const std::string & filename) ITK_OVERRIDE; + bool CanReadFile(const std::string & filename) override; + bool CanWriteFile(const std::string & filename) override; - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string & filename, const std::string & name="") override; + void Load(const std::string & filename, const std::string & name="") override; - void Train() ITK_OVERRIDE; + void Train() override; protected: SOMModel(); - ~SOMModel() ITK_OVERRIDE; + ~SOMModel() override; private: typename MapType::Pointer m_SOMMap; virtual TargetSampleType DoPredict( const InputSampleType& input, - ConfidenceValueType * quality = ITK_NULLPTR) const ITK_OVERRIDE; + ConfidenceValueType * quality = ITK_NULLPTR) const override; /** Map size (width, height) */ SizeType m_MapSize; diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h index 71d314e5f5..3276d63596 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbSOMModelFactory.h @@ -43,8 +43,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -61,7 +61,7 @@ public: protected: SOMModelFactory(); - ~SOMModelFactory() ITK_OVERRIDE; + ~SOMModelFactory() override; private: SOMModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/LearningBase/include/otbDecisionTree.h b/Modules/Learning/LearningBase/include/otbDecisionTree.h index 9a9d277dc4..1bb14365c0 100644 --- a/Modules/Learning/LearningBase/include/otbDecisionTree.h +++ b/Modules/Learning/LearningBase/include/otbDecisionTree.h @@ -100,11 +100,11 @@ protected: /** Constructor */ DecisionTree(); /** Destructor */ - ~DecisionTree() ITK_OVERRIDE; + ~DecisionTree() override; /** Output information redefinition */ /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: DecisionTree(const Self &); // purposely not implemented diff --git a/Modules/Learning/LearningBase/include/otbGaussianModelComponent.h b/Modules/Learning/LearningBase/include/otbGaussianModelComponent.h index 58472ddf43..3677f64c12 100644 --- a/Modules/Learning/LearningBase/include/otbGaussianModelComponent.h +++ b/Modules/Learning/LearningBase/include/otbGaussianModelComponent.h @@ -80,21 +80,21 @@ public: typedef typename CovarianceEstimatorType::MatrixType CovarianceType; /** Sets the input sample */ - void SetSample(const TSample* sample) ITK_OVERRIDE; + void SetSample(const TSample* sample) override; /** Sets the component's distribution parameters. * e.g. Then user can call directly Pdf( MeasurementVectorType & ) */ void SetParameters(const ParametersType& parameters); /** Show the parameters in a minimal form in comparison to PrintSelf */ - void ShowParameters(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void ShowParameters(std::ostream& os, itk::Indent indent) const override; protected: GaussianModelComponent(); - ~GaussianModelComponent() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~GaussianModelComponent() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: GaussianModelComponent(const Self &); //purposely not implemented diff --git a/Modules/Learning/LearningBase/include/otbImageClassificationFilter.h b/Modules/Learning/LearningBase/include/otbImageClassificationFilter.h index 620177e5af..ee2eddff5a 100644 --- a/Modules/Learning/LearningBase/include/otbImageClassificationFilter.h +++ b/Modules/Learning/LearningBase/include/otbImageClassificationFilter.h @@ -113,16 +113,16 @@ protected: /** Constructor */ ImageClassificationFilter(); /** Destructor */ - ~ImageClassificationFilter() ITK_OVERRIDE {} + ~ImageClassificationFilter() override {} /** Threaded generate data */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; void ClassicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId); void BatchThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId); /** Before threaded generate data */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageClassificationFilter(const Self &); //purposely not implemented diff --git a/Modules/Learning/LearningBase/include/otbKMeansImageClassificationFilter.h b/Modules/Learning/LearningBase/include/otbKMeansImageClassificationFilter.h index c188f31198..53a0a83fe5 100644 --- a/Modules/Learning/LearningBase/include/otbKMeansImageClassificationFilter.h +++ b/Modules/Learning/LearningBase/include/otbKMeansImageClassificationFilter.h @@ -106,14 +106,14 @@ protected: /** Constructor */ KMeansImageClassificationFilter(); /** Destructor */ - ~KMeansImageClassificationFilter() ITK_OVERRIDE {} + ~KMeansImageClassificationFilter() override {} /** Threaded generate data */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** Before threaded generate data */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: KMeansImageClassificationFilter(const Self &); //purposely not implemented diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModel.h b/Modules/Learning/LearningBase/include/otbMachineLearningModel.h index 2bfd9177ff..49e409ec8f 100644 --- a/Modules/Learning/LearningBase/include/otbMachineLearningModel.h +++ b/Modules/Learning/LearningBase/include/otbMachineLearningModel.h @@ -181,10 +181,10 @@ protected: MachineLearningModel(); /** Destructor */ - ~MachineLearningModel() ITK_OVERRIDE; + ~MachineLearningModel() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Input list sample */ typename InputListSampleType::Pointer m_InputListSample; diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModelFactoryBase.h b/Modules/Learning/LearningBase/include/otbMachineLearningModelFactoryBase.h index 012e0f1d77..ef2d6f02bf 100644 --- a/Modules/Learning/LearningBase/include/otbMachineLearningModelFactoryBase.h +++ b/Modules/Learning/LearningBase/include/otbMachineLearningModelFactoryBase.h @@ -48,7 +48,7 @@ public: protected: MachineLearningModelFactoryBase(); - ~MachineLearningModelFactoryBase() ITK_OVERRIDE; + ~MachineLearningModelFactoryBase() override; static itk::SimpleMutexLock mutex; diff --git a/Modules/Learning/LearningBase/include/otbSEMClassifier.h b/Modules/Learning/LearningBase/include/otbSEMClassifier.h index a97ba10eb1..0b598f44b5 100644 --- a/Modules/Learning/LearningBase/include/otbSEMClassifier.h +++ b/Modules/Learning/LearningBase/include/otbSEMClassifier.h @@ -156,7 +156,7 @@ public: int AddComponent(int id, ComponentType* component); /** Runs the optimization process. */ - void Update() ITK_OVERRIDE; + void Update() override; /** Termination status after running optimization */ typedef enum { CONVERGED = 0, NOT_CONVERGED = 1 } TerminationCodeType; @@ -176,12 +176,12 @@ public: /* Return the classification result (as an image) */ TOutputImage * GetOutputImage(); - void Modified() const ITK_OVERRIDE; + void Modified() const override; protected: SEMClassifier(); - ~SEMClassifier() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~SEMClassifier() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Initialize the first segmentation, either randomly or by using * a ClassLabelVectorType given in SetClassLabels. */ diff --git a/Modules/Learning/Markov/include/otbMRFEnergy.h b/Modules/Learning/Markov/include/otbMRFEnergy.h index c8acb54385..933539d7ce 100644 --- a/Modules/Learning/Markov/include/otbMRFEnergy.h +++ b/Modules/Learning/Markov/include/otbMRFEnergy.h @@ -142,7 +142,7 @@ protected: MRFEnergy() : m_NumberOfParameters(1), m_Parameters(0) {}; - ~MRFEnergy() ITK_OVERRIDE {} + ~MRFEnergy() override {} unsigned int m_NumberOfParameters; ParametersType m_Parameters; }; @@ -224,7 +224,7 @@ protected: m_NumberOfParameters(1), m_Parameters(0) {}; - ~MRFEnergy() ITK_OVERRIDE {} + ~MRFEnergy() override {} unsigned int m_NumberOfParameters; ParametersType m_Parameters; }; diff --git a/Modules/Learning/Markov/include/otbMRFEnergyEdgeFidelity.h b/Modules/Learning/Markov/include/otbMRFEnergyEdgeFidelity.h index d37e5f7655..5aa6715c91 100644 --- a/Modules/Learning/Markov/include/otbMRFEnergyEdgeFidelity.h +++ b/Modules/Learning/Markov/include/otbMRFEnergyEdgeFidelity.h @@ -63,7 +63,7 @@ public: itkTypeMacro(MRFEnergyEdgeFidelity, MRFEnergy); - double GetSingleValue(const InputImagePixelType& value1, const LabelledImagePixelType& value2) ITK_OVERRIDE + double GetSingleValue(const InputImagePixelType& value1, const LabelledImagePixelType& value2) override { double val1 = static_cast<double>(value1); double val2 = static_cast<double>(value2); @@ -74,7 +74,7 @@ public: protected: // The constructor and destructor. MRFEnergyEdgeFidelity() {}; - ~MRFEnergyEdgeFidelity() ITK_OVERRIDE {} + ~MRFEnergyEdgeFidelity() override {} }; } diff --git a/Modules/Learning/Markov/include/otbMRFEnergyFisherClassification.h b/Modules/Learning/Markov/include/otbMRFEnergyFisherClassification.h index 574a589e07..5950ad2046 100644 --- a/Modules/Learning/Markov/include/otbMRFEnergyFisherClassification.h +++ b/Modules/Learning/Markov/include/otbMRFEnergyFisherClassification.h @@ -59,14 +59,14 @@ public: itkNewMacro(Self); itkTypeMacro(MRFEnergyFisherClassification, MRFEnergy); - void SetNumberOfParameters(const unsigned int nParameters) ITK_OVERRIDE + void SetNumberOfParameters(const unsigned int nParameters) override { Superclass::SetNumberOfParameters(nParameters); this->m_Parameters.SetSize(nParameters); this->Modified(); } - double GetSingleValue(const InputImagePixelType & value1, const LabelledImagePixelType & value2) ITK_OVERRIDE + double GetSingleValue(const InputImagePixelType & value1, const LabelledImagePixelType & value2) override { if ((unsigned int)value2 >= this->GetNumberOfParameters()/3) { @@ -88,7 +88,7 @@ public: protected: // The constructor and destructor. MRFEnergyFisherClassification() {}; - ~MRFEnergyFisherClassification() ITK_OVERRIDE {}; + ~MRFEnergyFisherClassification() override {}; }; } #endif diff --git a/Modules/Learning/Markov/include/otbMRFEnergyGaussian.h b/Modules/Learning/Markov/include/otbMRFEnergyGaussian.h index 5670c06c90..556e402433 100644 --- a/Modules/Learning/Markov/include/otbMRFEnergyGaussian.h +++ b/Modules/Learning/Markov/include/otbMRFEnergyGaussian.h @@ -68,7 +68,7 @@ public: itkNewMacro(Self); - double GetSingleValue(const InputImagePixelType& value1, const LabelledImagePixelType& value2) ITK_OVERRIDE + double GetSingleValue(const InputImagePixelType& value1, const LabelledImagePixelType& value2) override { return vnl_math_sqr((static_cast<double>(value1)) - (static_cast<double>(value2))); @@ -81,7 +81,7 @@ protected: this->m_NumberOfParameters = 0; this->m_Parameters.SetSize(this->m_NumberOfParameters); }; - ~MRFEnergyGaussian() ITK_OVERRIDE {} + ~MRFEnergyGaussian() override {} }; } diff --git a/Modules/Learning/Markov/include/otbMRFEnergyGaussianClassification.h b/Modules/Learning/Markov/include/otbMRFEnergyGaussianClassification.h index 09d6175876..1864da2897 100644 --- a/Modules/Learning/Markov/include/otbMRFEnergyGaussianClassification.h +++ b/Modules/Learning/Markov/include/otbMRFEnergyGaussianClassification.h @@ -64,14 +64,14 @@ public: itkTypeMacro(MRFEnergyGaussianClassification, MRFEnergy); - void SetNumberOfParameters(const unsigned int nParameters) ITK_OVERRIDE + void SetNumberOfParameters(const unsigned int nParameters) override { Superclass::SetNumberOfParameters(nParameters); this->m_Parameters.SetSize(nParameters); this->Modified(); } - double GetSingleValue(const InputImagePixelType& value1, const LabelledImagePixelType& value2) ITK_OVERRIDE + double GetSingleValue(const InputImagePixelType& value1, const LabelledImagePixelType& value2) override { if ((unsigned int) value2 >= this->GetNumberOfParameters() / 2) { @@ -89,7 +89,7 @@ public: protected: // The constructor and destructor. MRFEnergyGaussianClassification() {}; - ~MRFEnergyGaussianClassification() ITK_OVERRIDE {} + ~MRFEnergyGaussianClassification() override {} }; } diff --git a/Modules/Learning/Markov/include/otbMRFEnergyPotts.h b/Modules/Learning/Markov/include/otbMRFEnergyPotts.h index 5f41c47a42..3c54c69179 100644 --- a/Modules/Learning/Markov/include/otbMRFEnergyPotts.h +++ b/Modules/Learning/Markov/include/otbMRFEnergyPotts.h @@ -66,7 +66,7 @@ public: itkNewMacro(Self); - double GetSingleValue(const InputImagePixelType& value1, const LabelledImagePixelType& value2) ITK_OVERRIDE + double GetSingleValue(const InputImagePixelType& value1, const LabelledImagePixelType& value2) override { if (value1 != value2) { @@ -86,7 +86,7 @@ protected: this->m_Parameters.SetSize(this->m_NumberOfParameters); this->m_Parameters[0] = 1.0; }; - ~MRFEnergyPotts() ITK_OVERRIDE {} + ~MRFEnergyPotts() override {} }; } diff --git a/Modules/Learning/Markov/include/otbMRFOptimizer.h b/Modules/Learning/Markov/include/otbMRFOptimizer.h index 110db833e4..65638b0ed2 100644 --- a/Modules/Learning/Markov/include/otbMRFOptimizer.h +++ b/Modules/Learning/Markov/include/otbMRFOptimizer.h @@ -76,7 +76,7 @@ protected: MRFOptimizer() : m_NumberOfParameters(1), m_Parameters(1) {} - ~MRFOptimizer() ITK_OVERRIDE {} + ~MRFOptimizer() override {} unsigned int m_NumberOfParameters; ParametersType m_Parameters; diff --git a/Modules/Learning/Markov/include/otbMRFOptimizerICM.h b/Modules/Learning/Markov/include/otbMRFOptimizerICM.h index f6f777e059..4380e161a8 100644 --- a/Modules/Learning/Markov/include/otbMRFOptimizerICM.h +++ b/Modules/Learning/Markov/include/otbMRFOptimizerICM.h @@ -52,7 +52,7 @@ public: itkTypeMacro(MRFOptimizerICM, MRFOptimizer); - inline bool Compute(double deltaEnergy) ITK_OVERRIDE + inline bool Compute(double deltaEnergy) override { if (deltaEnergy < 0) { @@ -66,7 +66,7 @@ public: protected: MRFOptimizerICM() {} - ~MRFOptimizerICM() ITK_OVERRIDE {} + ~MRFOptimizerICM() override {} }; diff --git a/Modules/Learning/Markov/include/otbMRFOptimizerMetropolis.h b/Modules/Learning/Markov/include/otbMRFOptimizerMetropolis.h index 5b7c75d668..f188046bed 100644 --- a/Modules/Learning/Markov/include/otbMRFOptimizerMetropolis.h +++ b/Modules/Learning/Markov/include/otbMRFOptimizerMetropolis.h @@ -72,7 +72,7 @@ public: this->Modified(); } - inline bool Compute(double deltaEnergy) ITK_OVERRIDE + inline bool Compute(double deltaEnergy) override { if (deltaEnergy < 0) { @@ -112,7 +112,7 @@ protected: m_Generator = RandomGeneratorType::GetInstance(); m_Generator->SetSeed(); } - ~MRFOptimizerMetropolis() ITK_OVERRIDE {} + ~MRFOptimizerMetropolis() override {} RandomGeneratorType::Pointer m_Generator; }; diff --git a/Modules/Learning/Markov/include/otbMRFSampler.h b/Modules/Learning/Markov/include/otbMRFSampler.h index 74daee5d84..bc505d7b1b 100644 --- a/Modules/Learning/Markov/include/otbMRFSampler.h +++ b/Modules/Learning/Markov/include/otbMRFSampler.h @@ -111,7 +111,7 @@ protected: m_EnergyRegularization = EnergyRegularizationType::New(); m_EnergyFidelity = EnergyFidelityType::New(); }; - ~MRFSampler() ITK_OVERRIDE {} + ~MRFSampler() override {} }; diff --git a/Modules/Learning/Markov/include/otbMRFSamplerMAP.h b/Modules/Learning/Markov/include/otbMRFSamplerMAP.h index dc14a7aafb..2bd8688102 100644 --- a/Modules/Learning/Markov/include/otbMRFSamplerMAP.h +++ b/Modules/Learning/Markov/include/otbMRFSamplerMAP.h @@ -65,7 +65,7 @@ public: itkTypeMacro(MRFSamplerMAP, MRFSampler); inline int Compute(const InputImageNeighborhoodIterator& itData, - const LabelledImageNeighborhoodIterator& itRegul) ITK_OVERRIDE + const LabelledImageNeighborhoodIterator& itRegul) override { if (this->m_NumberOfClasses == 0) { @@ -103,7 +103,7 @@ public: protected: // The constructor and destructor. MRFSamplerMAP() {}; - ~MRFSamplerMAP() ITK_OVERRIDE {} + ~MRFSamplerMAP() override {} }; diff --git a/Modules/Learning/Markov/include/otbMRFSamplerRandom.h b/Modules/Learning/Markov/include/otbMRFSamplerRandom.h index d00eb26929..5f60b4aca9 100644 --- a/Modules/Learning/Markov/include/otbMRFSamplerRandom.h +++ b/Modules/Learning/Markov/include/otbMRFSamplerRandom.h @@ -66,7 +66,7 @@ public: itkTypeMacro(MRFSamplerRandom, MRFSampler); - inline int Compute(const InputImageNeighborhoodIterator& itData, const LabelledImageNeighborhoodIterator& itRegul) ITK_OVERRIDE + inline int Compute(const InputImageNeighborhoodIterator& itData, const LabelledImageNeighborhoodIterator& itRegul) override { this->m_EnergyBefore = this->m_EnergyFidelity->GetValue(itData, itRegul.GetCenterPixel()); this->m_EnergyBefore += this->m_Lambda @@ -97,7 +97,7 @@ protected: m_Generator = RandomGeneratorType::GetInstance(); m_Generator->SetSeed(); } - ~MRFSamplerRandom() ITK_OVERRIDE {} + ~MRFSamplerRandom() override {} private: RandomGeneratorType::Pointer m_Generator; diff --git a/Modules/Learning/Markov/include/otbMRFSamplerRandomMAP.h b/Modules/Learning/Markov/include/otbMRFSamplerRandomMAP.h index 2ebf55bad5..5c37d94230 100644 --- a/Modules/Learning/Markov/include/otbMRFSamplerRandomMAP.h +++ b/Modules/Learning/Markov/include/otbMRFSamplerRandomMAP.h @@ -72,7 +72,7 @@ public: itkTypeMacro(MRFSamplerRandomMAP, MRFSampler); - void SetNumberOfClasses(const unsigned int nClasses) ITK_OVERRIDE + void SetNumberOfClasses(const unsigned int nClasses) override { if ((nClasses != this->m_NumberOfClasses) || (m_EnergiesInvalid == true)) { @@ -85,7 +85,7 @@ public: } } - inline int Compute(const InputImageNeighborhoodIterator& itData, const LabelledImageNeighborhoodIterator& itRegul) ITK_OVERRIDE + inline int Compute(const InputImageNeighborhoodIterator& itData, const LabelledImageNeighborhoodIterator& itRegul) override { if (this->m_NumberOfClasses == 0) { @@ -166,7 +166,7 @@ protected: m_Generator = RandomGeneratorType::GetInstance(); m_Generator->SetSeed(); } - ~MRFSamplerRandomMAP() ITK_OVERRIDE + ~MRFSamplerRandomMAP() override { if (m_Energy != ITK_NULLPTR) free(m_Energy); if (m_RepartitionFunction != ITK_NULLPTR) free(m_RepartitionFunction); diff --git a/Modules/Learning/Markov/include/otbMarkovRandomFieldFilter.h b/Modules/Learning/Markov/include/otbMarkovRandomFieldFilter.h index 9e5eeed25b..1d94c27531 100644 --- a/Modules/Learning/Markov/include/otbMarkovRandomFieldFilter.h +++ b/Modules/Learning/Markov/include/otbMarkovRandomFieldFilter.h @@ -319,8 +319,8 @@ public: protected: MarkovRandomFieldFilter(); - ~MarkovRandomFieldFilter() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~MarkovRandomFieldFilter() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Allocate memory for labelled images. This is automatically called * in GenerateData(). @@ -335,10 +335,10 @@ protected: virtual void ApplyMarkovRandomFieldFilter(); - void GenerateData() ITK_OVERRIDE; - void GenerateInputRequestedRegion() ITK_OVERRIDE; - void EnlargeOutputRequestedRegion(itk::DataObject *) ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateData() override; + void GenerateInputRequestedRegion() override; + void EnlargeOutputRequestedRegion(itk::DataObject *) override; + void GenerateOutputInformation() override; MarkovRandomFieldFilter(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented diff --git a/Modules/Learning/SOM/include/otbPeriodicSOM.h b/Modules/Learning/SOM/include/otbPeriodicSOM.h index c1a5d60329..5f71f8cac2 100644 --- a/Modules/Learning/SOM/include/otbPeriodicSOM.h +++ b/Modules/Learning/SOM/include/otbPeriodicSOM.h @@ -91,19 +91,19 @@ protected: /** Constructor */ PeriodicSOM() {} /** Destructor */ - ~PeriodicSOM() ITK_OVERRIDE {} + ~PeriodicSOM() override {} /** Output information redefinition */ - void GenerateOutputInformation() ITK_OVERRIDE + void GenerateOutputInformation() override { Superclass::GenerateOutputInformation (); } /** Output allocation redefinition */ - void AllocateOutputs() ITK_OVERRIDE + void AllocateOutputs() override { Superclass::AllocateOutputs(); } /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE + void GenerateData(void) override { Superclass::GenerateData(); } @@ -113,16 +113,16 @@ protected: * \param beta The learning coefficient, * \param radius The radius of the nieghbourhood. */ - void UpdateMap(const NeuronType& sample, double beta, SizeType& radius) ITK_OVERRIDE; + void UpdateMap(const NeuronType& sample, double beta, SizeType& radius) override; /** * Step one iteration. */ - void Step(unsigned int currentIteration) ITK_OVERRIDE + void Step(unsigned int currentIteration) override { Superclass::Step(currentIteration); } /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Learning/SOM/include/otbSOM.h b/Modules/Learning/SOM/include/otbSOM.h index 1563b51165..56daddf8bb 100644 --- a/Modules/Learning/SOM/include/otbSOM.h +++ b/Modules/Learning/SOM/include/otbSOM.h @@ -125,13 +125,13 @@ protected: /** Constructor */ SOM(); /** Destructor */ - ~SOM() ITK_OVERRIDE; + ~SOM() override; /** Output information redefinition */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Output allocation redefinition */ - void AllocateOutputs() ITK_OVERRIDE; + void AllocateOutputs() override; /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** * Update the output map with a new sample. * \param sample The new sample to learn, @@ -144,7 +144,7 @@ protected: */ virtual void Step(unsigned int currentIteration); /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SOM(const Self &); // purposely not implemented diff --git a/Modules/Learning/SOM/include/otbSOMActivationBuilder.h b/Modules/Learning/SOM/include/otbSOMActivationBuilder.h index 3d3ff39168..928d720826 100644 --- a/Modules/Learning/SOM/include/otbSOMActivationBuilder.h +++ b/Modules/Learning/SOM/include/otbSOMActivationBuilder.h @@ -74,11 +74,11 @@ protected: /** Constructor */ SOMActivationBuilder(); /** Destructor */ - ~SOMActivationBuilder() ITK_OVERRIDE; + ~SOMActivationBuilder() override; /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SOMActivationBuilder(const Self &); // purposely not implemented diff --git a/Modules/Learning/SOM/include/otbSOMClassifier.h b/Modules/Learning/SOM/include/otbSOMClassifier.h index 6bc0e09701..55027d4435 100644 --- a/Modules/Learning/SOM/include/otbSOMClassifier.h +++ b/Modules/Learning/SOM/include/otbSOMClassifier.h @@ -88,11 +88,11 @@ protected: /** Constructor */ SOMClassifier(); /** Destructor */ - ~SOMClassifier() ITK_OVERRIDE {} + ~SOMClassifier() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Starts the classification process */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: /// The input sample diff --git a/Modules/Learning/SOM/include/otbSOMImageClassificationFilter.h b/Modules/Learning/SOM/include/otbSOMImageClassificationFilter.h index 2d1dbb35f2..08bbb8bf05 100644 --- a/Modules/Learning/SOM/include/otbSOMImageClassificationFilter.h +++ b/Modules/Learning/SOM/include/otbSOMImageClassificationFilter.h @@ -104,14 +104,14 @@ protected: /** Constructor */ SOMImageClassificationFilter(); /** Destructor */ - ~SOMImageClassificationFilter() ITK_OVERRIDE {} + ~SOMImageClassificationFilter() override {} /** Threaded generate data */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override; /** Before threaded generate data */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SOMImageClassificationFilter(const Self &); //purposely not implemented diff --git a/Modules/Learning/SOM/include/otbSOMMap.h b/Modules/Learning/SOM/include/otbSOMMap.h index 662d782b07..160a38e299 100644 --- a/Modules/Learning/SOM/include/otbSOMMap.h +++ b/Modules/Learning/SOM/include/otbSOMMap.h @@ -92,9 +92,9 @@ protected: /** Constructor */ SOMMap(); /** Destructor */ - ~SOMMap() ITK_OVERRIDE; + ~SOMMap() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SOMMap(const Self &); // purposely not implemented diff --git a/Modules/Learning/SOM/include/otbSOMWithMissingValue.h b/Modules/Learning/SOM/include/otbSOMWithMissingValue.h index aadcbe20fe..02fba263c4 100644 --- a/Modules/Learning/SOM/include/otbSOMWithMissingValue.h +++ b/Modules/Learning/SOM/include/otbSOMWithMissingValue.h @@ -81,34 +81,34 @@ protected: /** Constructor */ SOMWithMissingValue (); /** Destructor */ - ~SOMWithMissingValue() ITK_OVERRIDE; + ~SOMWithMissingValue() override; /** Output information redefinition */ - void GenerateOutputInformation() ITK_OVERRIDE + void GenerateOutputInformation() override { Superclass::GenerateOutputInformation (); } /** Output allocation redefinition */ - void AllocateOutputs() ITK_OVERRIDE + void AllocateOutputs() override { Superclass::AllocateOutputs(); } /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE + void GenerateData(void) override { Superclass::GenerateData(); } /** * Update the output map with a new sample, depending on the availability of the data */ - void UpdateMap(const NeuronType& sample, double beta, SizeType& radius) ITK_OVERRIDE; + void UpdateMap(const NeuronType& sample, double beta, SizeType& radius) override; /** Step one iteration. */ - void Step(unsigned int currentIteration) ITK_OVERRIDE + void Step(unsigned int currentIteration) override { Superclass::Step(currentIteration); } /** PrintSelf method */ -void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; +void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Learning/SOM/include/otbSOMbasedImageFilter.h b/Modules/Learning/SOM/include/otbSOMbasedImageFilter.h index 7e9105ad1f..f33342d6a1 100644 --- a/Modules/Learning/SOM/include/otbSOMbasedImageFilter.h +++ b/Modules/Learning/SOM/include/otbSOMbasedImageFilter.h @@ -144,10 +144,10 @@ public: protected: // throw the Map to the functor - void BeforeThreadedGenerateData(void) ITK_OVERRIDE; + void BeforeThreadedGenerateData(void) override; SOMbasedImageFilter (); - ~SOMbasedImageFilter () ITK_OVERRIDE {} + ~SOMbasedImageFilter () override {} private: SOMbasedImageFilter (const Self &); diff --git a/Modules/Learning/Sampling/include/otbImageSampleExtractorFilter.h b/Modules/Learning/Sampling/include/otbImageSampleExtractorFilter.h index c36b029b1c..d7c32c9d18 100644 --- a/Modules/Learning/Sampling/include/otbImageSampleExtractorFilter.h +++ b/Modules/Learning/Sampling/include/otbImageSampleExtractorFilter.h @@ -73,10 +73,10 @@ public: /** Get the output samples OGR container */ ogr::DataSource* GetOutputSamples(); - void Synthetize(void) ITK_OVERRIDE{} + void Synthetize(void) override{} /** Reset method called before starting the streaming*/ - void Reset(void) ITK_OVERRIDE; + void Reset(void) override; itkSetMacro(SampleFieldPrefix, std::string); itkGetMacro(SampleFieldPrefix, std::string); @@ -91,14 +91,14 @@ protected: /** Constructor */ PersistentImageSampleExtractorFilter(); /** Destructor */ - ~PersistentImageSampleExtractorFilter() ITK_OVERRIDE {} + ~PersistentImageSampleExtractorFilter() override {} - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** process only points */ - void ThreadedGenerateVectorData(const ogr::Layer& layerForThread, itk::ThreadIdType threadid) ITK_OVERRIDE; + void ThreadedGenerateVectorData(const ogr::Layer& layerForThread, itk::ThreadIdType threadid) override; private: PersistentImageSampleExtractorFilter(const Self &); //purposely not implemented @@ -178,7 +178,7 @@ protected: /** Constructor */ ImageSampleExtractorFilter() {} /** Destructor */ - ~ImageSampleExtractorFilter() ITK_OVERRIDE {} + ~ImageSampleExtractorFilter() override {} private: ImageSampleExtractorFilter(const Self &); //purposely not implemented diff --git a/Modules/Learning/Sampling/include/otbOGRDataToClassStatisticsFilter.h b/Modules/Learning/Sampling/include/otbOGRDataToClassStatisticsFilter.h index f7e03efd36..0b34b436e2 100644 --- a/Modules/Learning/Sampling/include/otbOGRDataToClassStatisticsFilter.h +++ b/Modules/Learning/Sampling/include/otbOGRDataToClassStatisticsFilter.h @@ -67,10 +67,10 @@ public: /** Runtime information support. */ itkTypeMacro(PersistentOGRDataToClassStatisticsFilter, PersistentSamplingFilterBase); - void Synthetize(void) ITK_OVERRIDE; + void Synthetize(void) override; /** Reset method called before starting the streaming*/ - void Reset(void) ITK_OVERRIDE; + void Reset(void) override; /** the class count map is stored as output #2 */ const ClassCountObjectType* GetClassCountOutput() const; @@ -82,24 +82,24 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; protected: /** Constructor */ PersistentOGRDataToClassStatisticsFilter(); /** Destructor */ - ~PersistentOGRDataToClassStatisticsFilter() ITK_OVERRIDE {} + ~PersistentOGRDataToClassStatisticsFilter() override {} /** Implement generic method called at each candidate position */ void ProcessSample(const ogr::Feature& feature, typename TInputImage::IndexType& imgIndex, typename TInputImage::PointType& imgPoint, - itk::ThreadIdType& threadid) ITK_OVERRIDE; + itk::ThreadIdType& threadid) override; /** Prepare temporary variables for the current feature */ void PrepareFeature(const ogr::Feature& feature, - itk::ThreadIdType& threadid) ITK_OVERRIDE; + itk::ThreadIdType& threadid) override; private: PersistentOGRDataToClassStatisticsFilter(const Self &); //purposely not implemented @@ -183,7 +183,7 @@ protected: /** Constructor */ OGRDataToClassStatisticsFilter() {} /** Destructor */ - ~OGRDataToClassStatisticsFilter() ITK_OVERRIDE {} + ~OGRDataToClassStatisticsFilter() override {} private: OGRDataToClassStatisticsFilter(const Self &); //purposely not implemented diff --git a/Modules/Learning/Sampling/include/otbOGRDataToSamplePositionFilter.h b/Modules/Learning/Sampling/include/otbOGRDataToSamplePositionFilter.h index 8393766bcb..5b1364e277 100644 --- a/Modules/Learning/Sampling/include/otbOGRDataToSamplePositionFilter.h +++ b/Modules/Learning/Sampling/include/otbOGRDataToSamplePositionFilter.h @@ -88,10 +88,10 @@ public: /** Runtime information support. */ itkTypeMacro(PersistentOGRDataToSamplePositionFilter, PersistentSamplingFilterBase); - void Synthetize(void) ITK_OVERRIDE{} + void Synthetize(void) override{} /** Reset method called before starting the streaming*/ - void Reset(void) ITK_OVERRIDE; + void Reset(void) override; /** Get a reference to the internal samplers at a given level */ SamplerMapType& GetSamplers(unsigned int level); @@ -115,7 +115,7 @@ public: /** Make a DataObject of the correct type to be used as the specified * output. */ - itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; /** Get/Set of the field name storing the original FID of each sample */ @@ -126,21 +126,21 @@ protected: /** Constructor */ PersistentOGRDataToSamplePositionFilter(); /** Destructor */ - ~PersistentOGRDataToSamplePositionFilter() ITK_OVERRIDE {} + ~PersistentOGRDataToSamplePositionFilter() override {} /** Call samplers on a current position, for a given class */ void ProcessSample(const ogr::Feature& feature, typename TInputImage::IndexType& imgIndex, typename TInputImage::PointType& imgPoint, - itk::ThreadIdType& threadid) ITK_OVERRIDE; + itk::ThreadIdType& threadid) override; /** Method to split the input OGRDataSource * according to the class partition */ - void DispatchInputVectors(void) ITK_OVERRIDE; + void DispatchInputVectors(void) override; /** Fill the output vectors with a special ordering (class partition) */ - void FillOneOutput(unsigned int outIdx, ogr::DataSource* outDS, bool update) ITK_OVERRIDE; + void FillOneOutput(unsigned int outIdx, ogr::DataSource* outDS, bool update) override; private: PersistentOGRDataToSamplePositionFilter(const Self &); //purposely not implemented @@ -259,7 +259,7 @@ protected: /** Constructor */ OGRDataToSamplePositionFilter() {} /** Destructor */ - ~OGRDataToSamplePositionFilter() ITK_OVERRIDE {} + ~OGRDataToSamplePositionFilter() override {} private: OGRDataToSamplePositionFilter(const Self &); //purposely not implemented diff --git a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.h b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.h index bb3b0ac406..6c8e2ab53c 100644 --- a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.h +++ b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.h @@ -97,21 +97,21 @@ protected: /** Constructor */ PersistentSamplingFilterBase(); /** Destructor */ - ~PersistentSamplingFilterBase() ITK_OVERRIDE {} + ~PersistentSamplingFilterBase() override {} /** Use the same output information as input image, check the field index * and the mask footprint */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Use an empty region to input image (pixel values not needed) and set * the requested region for the mask */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Generate data should thread over */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Allocate in-memory layers for input and outputs */ - void AllocateOutputs(void) ITK_OVERRIDE; + void AllocateOutputs(void) override; /** Start of main processing loop */ virtual void ThreadedGenerateVectorData(const ogr::Layer& layerForThread, itk::ThreadIdType threadid); diff --git a/Modules/Learning/Sampling/include/otbSamplingRateCalculator.h b/Modules/Learning/Sampling/include/otbSamplingRateCalculator.h index f391a23410..e16e8a9a48 100644 --- a/Modules/Learning/Sampling/include/otbSamplingRateCalculator.h +++ b/Modules/Learning/Sampling/include/otbSamplingRateCalculator.h @@ -110,10 +110,10 @@ protected: SamplingRateCalculator(); /** Destructor */ - ~SamplingRateCalculator() ITK_OVERRIDE {} + ~SamplingRateCalculator() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SamplingRateCalculator(const Self &); //purposely not implemented diff --git a/Modules/Learning/Sampling/include/otbSamplingRateCalculatorList.h b/Modules/Learning/Sampling/include/otbSamplingRateCalculatorList.h index 56dc647b53..7bc78c188d 100644 --- a/Modules/Learning/Sampling/include/otbSamplingRateCalculatorList.h +++ b/Modules/Learning/Sampling/include/otbSamplingRateCalculatorList.h @@ -98,7 +98,7 @@ protected: SamplingRateCalculatorList(){} /** Destructor */ - ~SamplingRateCalculatorList() ITK_OVERRIDE {} + ~SamplingRateCalculatorList() override {} private: SamplingRateCalculatorList(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbBoostMachineLearningModel.h b/Modules/Learning/Supervised/include/otbBoostMachineLearningModel.h index ec96746f6d..36c22666d5 100644 --- a/Modules/Learning/Supervised/include/otbBoostMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbBoostMachineLearningModel.h @@ -99,21 +99,21 @@ public: itkSetMacro(MaxDepth, int); /** Train the machine learning model */ - void Train() ITK_OVERRIDE; + void Train() override; /** Save the model to file */ - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string & filename, const std::string & name="") override; /** Load the model from file */ - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") override; /**\name Classification model file compatibility tests */ //@{ /** Is the input model file readable and compatible with the corresponding classifier ? */ - bool CanReadFile(const std::string &) ITK_OVERRIDE; + bool CanReadFile(const std::string &) override; /** Is the input model file writable and compatible with the corresponding classifier ? */ - bool CanWriteFile(const std::string &) ITK_OVERRIDE; + bool CanWriteFile(const std::string &) override; //@} protected: @@ -121,14 +121,14 @@ protected: BoostMachineLearningModel(); /** Destructor */ - ~BoostMachineLearningModel() ITK_OVERRIDE; + ~BoostMachineLearningModel() override; /** Predict values using the model */ - TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: BoostMachineLearningModel(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbBoostMachineLearningModelFactory.h b/Modules/Learning/Supervised/include/otbBoostMachineLearningModelFactory.h index 2344f857b1..909dc5e84c 100644 --- a/Modules/Learning/Supervised/include/otbBoostMachineLearningModelFactory.h +++ b/Modules/Learning/Supervised/include/otbBoostMachineLearningModelFactory.h @@ -44,8 +44,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -62,7 +62,7 @@ public: protected: BoostMachineLearningModelFactory(); - ~BoostMachineLearningModelFactory() ITK_OVERRIDE; + ~BoostMachineLearningModelFactory() override; private: BoostMachineLearningModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbConfusionMatrixCalculator.h b/Modules/Learning/Supervised/include/otbConfusionMatrixCalculator.h index 465b0ae9a3..6db693ce26 100644 --- a/Modules/Learning/Supervised/include/otbConfusionMatrixCalculator.h +++ b/Modules/Learning/Supervised/include/otbConfusionMatrixCalculator.h @@ -137,8 +137,8 @@ public: protected: ConfusionMatrixCalculator(); - ~ConfusionMatrixCalculator() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ConfusionMatrixCalculator() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Learning/Supervised/include/otbConfusionMatrixMeasurements.h b/Modules/Learning/Supervised/include/otbConfusionMatrixMeasurements.h index 2b50388427..96790db5a8 100644 --- a/Modules/Learning/Supervised/include/otbConfusionMatrixMeasurements.h +++ b/Modules/Learning/Supervised/include/otbConfusionMatrixMeasurements.h @@ -143,7 +143,7 @@ public: protected: ConfusionMatrixMeasurements(); - ~ConfusionMatrixMeasurements() ITK_OVERRIDE {} + ~ConfusionMatrixMeasurements() override {} //void PrintSelf(std::ostream& os, itk::Indent indent) const; diff --git a/Modules/Learning/Supervised/include/otbCvRTreesWrapper.h b/Modules/Learning/Supervised/include/otbCvRTreesWrapper.h index a3874b1c5f..7ec5896901 100644 --- a/Modules/Learning/Supervised/include/otbCvRTreesWrapper.h +++ b/Modules/Learning/Supervised/include/otbCvRTreesWrapper.h @@ -42,7 +42,7 @@ class OTBSupervised_EXPORT CvRTreesWrapper public: typedef std::vector<unsigned int> VotesVectorType; CvRTreesWrapper(); - ~CvRTreesWrapper() ITK_OVERRIDE; + ~CvRTreesWrapper() override; /** Compute the number of votes for each class. */ void get_votes(const cv::Mat& sample, diff --git a/Modules/Learning/Supervised/include/otbDecisionTreeMachineLearningModel.h b/Modules/Learning/Supervised/include/otbDecisionTreeMachineLearningModel.h index 260fc835c7..fc47f21405 100644 --- a/Modules/Learning/Supervised/include/otbDecisionTreeMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbDecisionTreeMachineLearningModel.h @@ -154,21 +154,21 @@ public: } /** Train the machine learning model */ - void Train() ITK_OVERRIDE; + void Train() override; /** Save the model to file */ - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string & filename, const std::string & name="") override; /** Load the model from file */ - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") override; /**\name Classification model file compatibility tests */ //@{ /** Is the input model file readable and compatible with the corresponding classifier ? */ - bool CanReadFile(const std::string &) ITK_OVERRIDE; + bool CanReadFile(const std::string &) override; /** Is the input model file writable and compatible with the corresponding classifier ? */ - bool CanWriteFile(const std::string &) ITK_OVERRIDE; + bool CanWriteFile(const std::string &) override; //@} protected: @@ -176,13 +176,13 @@ protected: DecisionTreeMachineLearningModel(); /** Destructor */ - ~DecisionTreeMachineLearningModel() ITK_OVERRIDE; + ~DecisionTreeMachineLearningModel() override; /** Predict values using the model */ - TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: DecisionTreeMachineLearningModel(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbDecisionTreeMachineLearningModelFactory.h b/Modules/Learning/Supervised/include/otbDecisionTreeMachineLearningModelFactory.h index 1c73cf6de6..5635cee32d 100644 --- a/Modules/Learning/Supervised/include/otbDecisionTreeMachineLearningModelFactory.h +++ b/Modules/Learning/Supervised/include/otbDecisionTreeMachineLearningModelFactory.h @@ -44,8 +44,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -62,7 +62,7 @@ public: protected: DecisionTreeMachineLearningModelFactory(); - ~DecisionTreeMachineLearningModelFactory() ITK_OVERRIDE; + ~DecisionTreeMachineLearningModelFactory() override; private: DecisionTreeMachineLearningModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbExhaustiveExponentialOptimizer.h b/Modules/Learning/Supervised/include/otbExhaustiveExponentialOptimizer.h index cae5fb092d..ae1c135e0a 100644 --- a/Modules/Learning/Supervised/include/otbExhaustiveExponentialOptimizer.h +++ b/Modules/Learning/Supervised/include/otbExhaustiveExponentialOptimizer.h @@ -61,7 +61,7 @@ public: /** Run-time type information (and related methods). */ itkTypeMacro(ExhaustiveExponentialOptimizer,itk::SingleValuedNonLinearOptimizer); - void StartOptimization(void) ITK_OVERRIDE; + void StartOptimization(void) override; void StartWalking(void); void ResumeWalking(void); @@ -83,8 +83,8 @@ public: protected: ExhaustiveExponentialOptimizer(); - ~ExhaustiveExponentialOptimizer() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ExhaustiveExponentialOptimizer() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Advance to the next grid position. */ void AdvanceOneStep(void); diff --git a/Modules/Learning/Supervised/include/otbGradientBoostedTreeMachineLearningModel.h b/Modules/Learning/Supervised/include/otbGradientBoostedTreeMachineLearningModel.h index 4ff453acb0..19bbab10de 100644 --- a/Modules/Learning/Supervised/include/otbGradientBoostedTreeMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbGradientBoostedTreeMachineLearningModel.h @@ -105,21 +105,21 @@ public: itkSetMacro(UseSurrogates, bool); /** Train the machine learning model */ - void Train() ITK_OVERRIDE; + void Train() override; /** Save the model to file */ - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string & filename, const std::string & name="") override; /** Load the model from file */ - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") override; /**\name Classification model file compatibility tests */ //@{ /** Is the input model file readable and compatible with the corresponding classifier ? */ - bool CanReadFile(const std::string &) ITK_OVERRIDE; + bool CanReadFile(const std::string &) override; /** Is the input model file writable and compatible with the corresponding classifier ? */ - bool CanWriteFile(const std::string &) ITK_OVERRIDE; + bool CanWriteFile(const std::string &) override; //@} protected: @@ -127,14 +127,14 @@ protected: GradientBoostedTreeMachineLearningModel(); /** Destructor */ - ~GradientBoostedTreeMachineLearningModel() ITK_OVERRIDE; + ~GradientBoostedTreeMachineLearningModel() override; /** Predict values using the model */ - TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: GradientBoostedTreeMachineLearningModel(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbGradientBoostedTreeMachineLearningModelFactory.h b/Modules/Learning/Supervised/include/otbGradientBoostedTreeMachineLearningModelFactory.h index 7d4d1faad8..4cc7203d88 100644 --- a/Modules/Learning/Supervised/include/otbGradientBoostedTreeMachineLearningModelFactory.h +++ b/Modules/Learning/Supervised/include/otbGradientBoostedTreeMachineLearningModelFactory.h @@ -46,8 +46,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -64,7 +64,7 @@ public: protected: GradientBoostedTreeMachineLearningModelFactory(); - ~GradientBoostedTreeMachineLearningModelFactory() ITK_OVERRIDE; + ~GradientBoostedTreeMachineLearningModelFactory() override; private: GradientBoostedTreeMachineLearningModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbKNearestNeighborsMachineLearningModel.h b/Modules/Learning/Supervised/include/otbKNearestNeighborsMachineLearningModel.h index 069ff1eb47..d23411d923 100644 --- a/Modules/Learning/Supervised/include/otbKNearestNeighborsMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbKNearestNeighborsMachineLearningModel.h @@ -79,21 +79,21 @@ public: itkSetMacro(DecisionRule, int); /** Train the machine learning model */ - void Train() ITK_OVERRIDE; + void Train() override; /** Save the model to file */ - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string & filename, const std::string & name="") override; /** Load the model from file */ - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") override; /**\name Classification model file compatibility tests */ //@{ /** Is the input model file readable and compatible with the corresponding classifier ? */ - bool CanReadFile(const std::string &) ITK_OVERRIDE; + bool CanReadFile(const std::string &) override; /** Is the input model file writable and compatible with the corresponding classifier ? */ - bool CanWriteFile(const std::string &) ITK_OVERRIDE; + bool CanWriteFile(const std::string &) override; //@} protected: @@ -101,14 +101,14 @@ protected: KNearestNeighborsMachineLearningModel(); /** Destructor */ - ~KNearestNeighborsMachineLearningModel() ITK_OVERRIDE; + ~KNearestNeighborsMachineLearningModel() override; /** Predict values using the model */ - TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: KNearestNeighborsMachineLearningModel(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbKNearestNeighborsMachineLearningModelFactory.h b/Modules/Learning/Supervised/include/otbKNearestNeighborsMachineLearningModelFactory.h index acb79f0543..717a09313e 100644 --- a/Modules/Learning/Supervised/include/otbKNearestNeighborsMachineLearningModelFactory.h +++ b/Modules/Learning/Supervised/include/otbKNearestNeighborsMachineLearningModelFactory.h @@ -44,8 +44,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -62,7 +62,7 @@ public: protected: KNearestNeighborsMachineLearningModelFactory(); - ~KNearestNeighborsMachineLearningModelFactory() ITK_OVERRIDE; + ~KNearestNeighborsMachineLearningModelFactory() override; private: KNearestNeighborsMachineLearningModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbLabelMapClassifier.h b/Modules/Learning/Supervised/include/otbLabelMapClassifier.h index 75dc291f3d..51f102b96c 100644 --- a/Modules/Learning/Supervised/include/otbLabelMapClassifier.h +++ b/Modules/Learning/Supervised/include/otbLabelMapClassifier.h @@ -89,11 +89,11 @@ public: protected: LabelMapClassifier(); - ~LabelMapClassifier() ITK_OVERRIDE {}; + ~LabelMapClassifier() override {}; - void ThreadedProcessLabelObject( LabelObjectType * labelObject ) ITK_OVERRIDE; + void ThreadedProcessLabelObject( LabelObjectType * labelObject ) override; - void ReleaseInputs() ITK_OVERRIDE; + void ReleaseInputs() override; private: diff --git a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h index 329722af5a..8d96b2a179 100644 --- a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h @@ -64,21 +64,21 @@ public: itkTypeMacro(SVMMachineLearningModel, MachineLearningModel); /** Train the machine learning model */ - void Train() ITK_OVERRIDE; + void Train() override; /** Save the model to file */ - void Save(const std::string &filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string &filename, const std::string & name="") override; /** Load the model from file */ - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") override; /**\name Classification model file compatibility tests */ //@{ /** Is the input model file readable and compatible with the corresponding classifier ? */ - bool CanReadFile(const std::string &) ITK_OVERRIDE; + bool CanReadFile(const std::string &) override; /** Is the input model file writable and compatible with the corresponding classifier ? */ - bool CanWriteFile(const std::string &) ITK_OVERRIDE; + bool CanWriteFile(const std::string &) override; //@} #define otbSetSVMParameterMacro(name, alias, type) \ @@ -269,13 +269,13 @@ protected: LibSVMMachineLearningModel(); /** Destructor */ - ~LibSVMMachineLearningModel() ITK_OVERRIDE; + ~LibSVMMachineLearningModel() override; /** Predict values using the model */ - TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LibSVMMachineLearningModel(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModelFactory.h b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModelFactory.h index 288573e735..08bd6c767e 100644 --- a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModelFactory.h +++ b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModelFactory.h @@ -42,8 +42,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -60,7 +60,7 @@ public: protected: LibSVMMachineLearningModelFactory(); - ~LibSVMMachineLearningModelFactory() ITK_OVERRIDE; + ~LibSVMMachineLearningModelFactory() override; private: LibSVMMachineLearningModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbMachineLearningModelFactory.h b/Modules/Learning/Supervised/include/otbMachineLearningModelFactory.h index 5339802b1d..67ef0758cb 100644 --- a/Modules/Learning/Supervised/include/otbMachineLearningModelFactory.h +++ b/Modules/Learning/Supervised/include/otbMachineLearningModelFactory.h @@ -60,7 +60,7 @@ public: protected: MachineLearningModelFactory(); - ~MachineLearningModelFactory() ITK_OVERRIDE; + ~MachineLearningModelFactory() override; private: MachineLearningModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbNeuralNetworkMachineLearningModel.h b/Modules/Learning/Supervised/include/otbNeuralNetworkMachineLearningModel.h index 3253c23686..44a1bad585 100644 --- a/Modules/Learning/Supervised/include/otbNeuralNetworkMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbNeuralNetworkMachineLearningModel.h @@ -153,21 +153,21 @@ public: itkSetMacro(Epsilon, double); /** Train the machine learning model */ - void Train() ITK_OVERRIDE; + void Train() override; /** Save the model to file */ - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string & filename, const std::string & name="") override; /** Load the model from file */ - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") override; /**\name Classification model file compatibility tests */ //@{ /** Is the input model file readable and compatible with the corresponding classifier ? */ - bool CanReadFile(const std::string &) ITK_OVERRIDE; + bool CanReadFile(const std::string &) override; /** Is the input model file writable and compatible with the corresponding classifier ? */ - bool CanWriteFile(const std::string &) ITK_OVERRIDE; + bool CanWriteFile(const std::string &) override; //@} protected: @@ -175,15 +175,15 @@ protected: NeuralNetworkMachineLearningModel(); /** Destructor */ - ~NeuralNetworkMachineLearningModel() ITK_OVERRIDE; + ~NeuralNetworkMachineLearningModel() override; /** Predict values using the model */ - TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const override; void LabelsToMat(const TargetListSampleType * listSample, cv::Mat & output); /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: NeuralNetworkMachineLearningModel(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbNeuralNetworkMachineLearningModelFactory.h b/Modules/Learning/Supervised/include/otbNeuralNetworkMachineLearningModelFactory.h index af6c7b0a26..ad8f1dce90 100644 --- a/Modules/Learning/Supervised/include/otbNeuralNetworkMachineLearningModelFactory.h +++ b/Modules/Learning/Supervised/include/otbNeuralNetworkMachineLearningModelFactory.h @@ -44,8 +44,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -62,7 +62,7 @@ public: protected: NeuralNetworkMachineLearningModelFactory(); - ~NeuralNetworkMachineLearningModelFactory() ITK_OVERRIDE; + ~NeuralNetworkMachineLearningModelFactory() override; private: NeuralNetworkMachineLearningModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbNormalBayesMachineLearningModel.h b/Modules/Learning/Supervised/include/otbNormalBayesMachineLearningModel.h index 0b1ddc2c3c..da1ae46c05 100644 --- a/Modules/Learning/Supervised/include/otbNormalBayesMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbNormalBayesMachineLearningModel.h @@ -59,21 +59,21 @@ public: itkTypeMacro(NormalBayesMachineLearningModel, MachineLearningModel); /** Train the machine learning model */ - void Train() ITK_OVERRIDE; + void Train() override; /** Save the model to file */ - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string & filename, const std::string & name="") override; /** Load the model from file */ - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") override; /**\name Classification model file compatibility tests */ //@{ /** Is the input model file readable and compatible with the corresponding classifier ? */ - bool CanReadFile(const std::string &) ITK_OVERRIDE; + bool CanReadFile(const std::string &) override; /** Is the input model file writable and compatible with the corresponding classifier ? */ - bool CanWriteFile(const std::string &) ITK_OVERRIDE; + bool CanWriteFile(const std::string &) override; //@} protected: @@ -81,14 +81,14 @@ protected: NormalBayesMachineLearningModel(); /** Destructor */ - ~NormalBayesMachineLearningModel() ITK_OVERRIDE; + ~NormalBayesMachineLearningModel() override; /** Predict values using the model */ - TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: NormalBayesMachineLearningModel(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbNormalBayesMachineLearningModelFactory.h b/Modules/Learning/Supervised/include/otbNormalBayesMachineLearningModelFactory.h index 517b93cfef..13306b5b82 100644 --- a/Modules/Learning/Supervised/include/otbNormalBayesMachineLearningModelFactory.h +++ b/Modules/Learning/Supervised/include/otbNormalBayesMachineLearningModelFactory.h @@ -44,8 +44,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -62,7 +62,7 @@ public: protected: NormalBayesMachineLearningModelFactory(); - ~NormalBayesMachineLearningModelFactory() ITK_OVERRIDE; + ~NormalBayesMachineLearningModelFactory() override; private: NormalBayesMachineLearningModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbRandomForestsMachineLearningModel.h b/Modules/Learning/Supervised/include/otbRandomForestsMachineLearningModel.h index 04bbbca951..4dd7f0c828 100644 --- a/Modules/Learning/Supervised/include/otbRandomForestsMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbRandomForestsMachineLearningModel.h @@ -64,21 +64,21 @@ public: itkTypeMacro(RandomForestsMachineLearningModel, MachineLearningModel); /** Train the machine learning model */ - void Train() ITK_OVERRIDE; + void Train() override; /** Save the model to file */ - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string & filename, const std::string & name="") override; /** Load the model from file */ - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") override; /**\name Classification model file compatibility tests */ //@{ /** Is the input model file readable and compatible with the corresponding classifier ? */ - bool CanReadFile(const std::string &) ITK_OVERRIDE; + bool CanReadFile(const std::string &) override; /** Is the input model file writable and compatible with the corresponding classifier ? */ - bool CanWriteFile(const std::string &) ITK_OVERRIDE; + bool CanWriteFile(const std::string &) override; //@} //Setters of RT parameters (documentation get from opencv doxygen 2.4) @@ -135,14 +135,14 @@ protected: RandomForestsMachineLearningModel(); /** Destructor */ - ~RandomForestsMachineLearningModel() ITK_OVERRIDE; + ~RandomForestsMachineLearningModel() override; /** Predict values using the model */ - TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /* /\** Input list sample *\/ */ /* typename InputListSampleType::Pointer m_InputListSample; */ diff --git a/Modules/Learning/Supervised/include/otbRandomForestsMachineLearningModelFactory.h b/Modules/Learning/Supervised/include/otbRandomForestsMachineLearningModelFactory.h index f84f937213..92dd605664 100644 --- a/Modules/Learning/Supervised/include/otbRandomForestsMachineLearningModelFactory.h +++ b/Modules/Learning/Supervised/include/otbRandomForestsMachineLearningModelFactory.h @@ -44,8 +44,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -62,7 +62,7 @@ public: protected: RandomForestsMachineLearningModelFactory(); - ~RandomForestsMachineLearningModelFactory() ITK_OVERRIDE; + ~RandomForestsMachineLearningModelFactory() override; private: RandomForestsMachineLearningModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbSVMCrossValidationCostFunction.h b/Modules/Learning/Supervised/include/otbSVMCrossValidationCostFunction.h index ceb76a1486..4056c47c54 100644 --- a/Modules/Learning/Supervised/include/otbSVMCrossValidationCostFunction.h +++ b/Modules/Learning/Supervised/include/otbSVMCrossValidationCostFunction.h @@ -82,19 +82,19 @@ public: itkGetMacro(DerivativeStep, ParametersValueType); /** \return The accuracy value corresponding the parameters */ - MeasureType GetValue(const ParametersType& parameters) const ITK_OVERRIDE; + MeasureType GetValue(const ParametersType& parameters) const override; /** \return The accuracy derivative corresponding to the parameters */ - void GetDerivative(const ParametersType& parameters, DerivativeType& derivative) const ITK_OVERRIDE; + void GetDerivative(const ParametersType& parameters, DerivativeType& derivative) const override; /** \return the number of parameters to optimize */ - unsigned int GetNumberOfParameters(void) const ITK_OVERRIDE; + unsigned int GetNumberOfParameters(void) const override; protected: /// Constructor SVMCrossValidationCostFunction(); /// Destructor - ~SVMCrossValidationCostFunction() ITK_OVERRIDE; + ~SVMCrossValidationCostFunction() override; /** Update svm parameters struct according to the input parameters */ diff --git a/Modules/Learning/Supervised/include/otbSVMMachineLearningModel.h b/Modules/Learning/Supervised/include/otbSVMMachineLearningModel.h index 07059be9b8..d0c36eeb3b 100644 --- a/Modules/Learning/Supervised/include/otbSVMMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbSVMMachineLearningModel.h @@ -66,21 +66,21 @@ public: itkTypeMacro(SVMMachineLearningModel, MachineLearningModel); /** Train the machine learning model */ - void Train() ITK_OVERRIDE; + void Train() override; /** Save the model to file */ - void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Save(const std::string & filename, const std::string & name="") override; /** Load the model from file */ - void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + void Load(const std::string & filename, const std::string & name="") override; /**\name Classification model file compatibility tests */ //@{ /** Is the input model file readable and compatible with the corresponding classifier ? */ - bool CanReadFile(const std::string &) ITK_OVERRIDE; + bool CanReadFile(const std::string &) override; /** Is the input model file writable and compatible with the corresponding classifier ? */ - bool CanWriteFile(const std::string &) ITK_OVERRIDE; + bool CanWriteFile(const std::string &) override; //@} //Setters/Getters to SVM model @@ -138,14 +138,14 @@ protected: SVMMachineLearningModel(); /** Destructor */ - ~SVMMachineLearningModel() ITK_OVERRIDE; + ~SVMMachineLearningModel() override; /** Predict values using the model */ - TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SVMMachineLearningModel(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbSVMMachineLearningModelFactory.h b/Modules/Learning/Supervised/include/otbSVMMachineLearningModelFactory.h index 7ea10ad559..07ab9b744d 100644 --- a/Modules/Learning/Supervised/include/otbSVMMachineLearningModelFactory.h +++ b/Modules/Learning/Supervised/include/otbSVMMachineLearningModelFactory.h @@ -44,8 +44,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - const char* GetDescription(void) const ITK_OVERRIDE; + const char* GetITKSourceVersion(void) const override; + const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); @@ -62,7 +62,7 @@ public: protected: SVMMachineLearningModelFactory(); - ~SVMMachineLearningModelFactory() ITK_OVERRIDE; + ~SVMMachineLearningModelFactory() override; private: SVMMachineLearningModelFactory(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbSVMMarginSampler.h b/Modules/Learning/Supervised/include/otbSVMMarginSampler.h index c6a3ae1dae..ab02a0f7b5 100644 --- a/Modules/Learning/Supervised/include/otbSVMMarginSampler.h +++ b/Modules/Learning/Supervised/include/otbSVMMarginSampler.h @@ -86,11 +86,11 @@ public: protected: SVMMarginSampler(); - ~SVMMarginSampler() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~SVMMarginSampler() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Starts the classification process */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; virtual void DoMarginSampling(); private: diff --git a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h index 162aa10255..7dd41d6eed 100644 --- a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.h @@ -83,21 +83,21 @@ public: itkTypeMacro(SharkRandomForestsMachineLearningModel, MachineLearningModel); /** Train the machine learning model */ - virtual void Train() ITK_OVERRIDE; + virtual void Train() override; /** Save the model to file */ - virtual void Save(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + virtual void Save(const std::string & filename, const std::string & name="") override; /** Load the model from file */ - virtual void Load(const std::string & filename, const std::string & name="") ITK_OVERRIDE; + virtual void Load(const std::string & filename, const std::string & name="") override; /**\name Classification model file compatibility tests */ //@{ /** Is the input model file readable and compatible with the corresponding classifier ? */ - virtual bool CanReadFile(const std::string &) ITK_OVERRIDE; + virtual bool CanReadFile(const std::string &) override; /** Is the input model file writable and compatible with the corresponding classifier ? */ - virtual bool CanWriteFile(const std::string &) ITK_OVERRIDE; + virtual bool CanWriteFile(const std::string &) override; //@} /** From Shark doc: Get the number of trees to grow.*/ @@ -142,13 +142,13 @@ protected: virtual ~SharkRandomForestsMachineLearningModel(); /** Predict values using the model */ - virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const override; - virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const ITK_OVERRIDE; + virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SharkRandomForestsMachineLearningModel(const Self &); //purposely not implemented diff --git a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModelFactory.h b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModelFactory.h index 7361ee38cc..756d5102a1 100644 --- a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModelFactory.h +++ b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModelFactory.h @@ -42,8 +42,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - virtual const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - virtual const char* GetDescription(void) const ITK_OVERRIDE; + virtual const char* GetITKSourceVersion(void) const override; + virtual const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); diff --git a/Modules/Learning/Supervised/test/otbExhaustiveExponentialOptimizerTest.cxx b/Modules/Learning/Supervised/test/otbExhaustiveExponentialOptimizerTest.cxx index c818411586..1b0dec3f63 100644 --- a/Modules/Learning/Supervised/test/otbExhaustiveExponentialOptimizerTest.cxx +++ b/Modules/Learning/Supervised/test/otbExhaustiveExponentialOptimizerTest.cxx @@ -72,7 +72,7 @@ public: }; /** \return The accuracy value corresponding the parameters */ - MeasureType GetValue(const ParametersType& parameters) const ITK_OVERRIDE + MeasureType GetValue(const ParametersType& parameters) const override { return static_cast<MeasureType> ( m_FunctionInternalParameters.GetElement(0) * parameters.GetElement(0) * parameters.GetElement(0) + m_FunctionInternalParameters.GetElement(1) * parameters.GetElement(1) * parameters.GetElement(1) + @@ -83,10 +83,10 @@ public: }; /** \return the number of parameters to optimize */ - unsigned int GetNumberOfParameters(void) const ITK_OVERRIDE {return 2; }; + unsigned int GetNumberOfParameters(void) const override {return 2; }; /** \return The accuracy derivative corresponding to the parameters */ - void GetDerivative(const ParametersType& itkNotUsed(parameters), DerivativeType& itkNotUsed(derivative)) const ITK_OVERRIDE {}; + void GetDerivative(const ParametersType& itkNotUsed(parameters), DerivativeType& itkNotUsed(derivative)) const override {}; /// Constructor Quadratic2DCostFunction() @@ -95,7 +95,7 @@ public: m_FunctionInternalParameters.Fill(0.0); }; /// Destructor - ~Quadratic2DCostFunction() ITK_OVERRIDE{}; + ~Quadratic2DCostFunction() override{}; private: Quadratic2DCostFunction(const Self &); //purposely not implemented diff --git a/Modules/Learning/Unsupervised/include/otbContingencyTable.h b/Modules/Learning/Unsupervised/include/otbContingencyTable.h index b27436a03c..f7d1b10183 100644 --- a/Modules/Learning/Unsupervised/include/otbContingencyTable.h +++ b/Modules/Learning/Unsupervised/include/otbContingencyTable.h @@ -137,8 +137,8 @@ protected: { SetLabels(LabelList(), LabelList()); } - ~ContingencyTable() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent itkNotUsed(indent)) const ITK_OVERRIDE + ~ContingencyTable() override {} + void PrintSelf(std::ostream& os, itk::Indent itkNotUsed(indent)) const override { os << *this; } diff --git a/Modules/Learning/Unsupervised/include/otbContingencyTableCalculator.h b/Modules/Learning/Unsupervised/include/otbContingencyTableCalculator.h index b8d8d924af..614146a8ee 100644 --- a/Modules/Learning/Unsupervised/include/otbContingencyTableCalculator.h +++ b/Modules/Learning/Unsupervised/include/otbContingencyTableCalculator.h @@ -83,8 +83,8 @@ public: protected: ContingencyTableCalculator(); - ~ContingencyTableCalculator() ITK_OVERRIDE {} - //void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ContingencyTableCalculator() override {} + //void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ContingencyTableCalculator(const Self &); //purposely not implemented diff --git a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.h b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.h index a479248e1e..a060046c61 100644 --- a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.h +++ b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.h @@ -90,21 +90,21 @@ public: itkTypeMacro( SharkKMeansMachineLearningModel, MachineLearningModel ); /** Train the machine learning model */ - virtual void Train() ITK_OVERRIDE; + virtual void Train() override; /** Save the model to file */ - virtual void Save(const std::string &filename, const std::string &name = "") ITK_OVERRIDE; + virtual void Save(const std::string &filename, const std::string &name = "") override; /** Load the model from file */ - virtual void Load(const std::string &filename, const std::string &name = "") ITK_OVERRIDE; + virtual void Load(const std::string &filename, const std::string &name = "") override; /**\name Classification model file compatibility tests */ //@{ /** Is the input model file readable and compatible with the corresponding classifier ? */ - virtual bool CanReadFile(const std::string &) ITK_OVERRIDE; + virtual bool CanReadFile(const std::string &) override; /** Is the input model file writable and compatible with the corresponding classifier ? */ - virtual bool CanWriteFile(const std::string &) ITK_OVERRIDE; + virtual bool CanWriteFile(const std::string &) override; //@} /** Get the maximum number of iteration for the kMeans algorithm.*/ @@ -130,17 +130,17 @@ protected: /** Predict values using the model */ virtual TargetSampleType - DoPredict(const InputSampleType &input, ConfidenceValueType *quality = ITK_NULLPTR) const ITK_OVERRIDE; + DoPredict(const InputSampleType &input, ConfidenceValueType *quality = ITK_NULLPTR) const override; virtual void DoPredictBatch(const InputListSampleType *, const unsigned int &startIndex, const unsigned int &size, - TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const ITK_OVERRIDE; + TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const override; template<typename DataType> DataType NormalizeData(const DataType &data) const; /** PrintSelf method */ - void PrintSelf(std::ostream &os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream &os, itk::Indent indent) const override; private: SharkKMeansMachineLearningModel(const Self &); //purposely not implemented diff --git a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModelFactory.h b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModelFactory.h index 3c9ed55da1..05365b8ff7 100644 --- a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModelFactory.h +++ b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModelFactory.h @@ -41,8 +41,8 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - virtual const char* GetITKSourceVersion(void) const ITK_OVERRIDE; - virtual const char* GetDescription(void) const ITK_OVERRIDE; + virtual const char* GetITKSourceVersion(void) const override; + virtual const char* GetDescription(void) const override; /** Method for class instantiation. */ itkFactorylessNewMacro(Self); diff --git a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h index 64e574384a..f008e22bbb 100644 --- a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h +++ b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h @@ -214,7 +214,7 @@ public: const InputImageType* GetInput(); /** Does the real work. */ - virtual void Update() ITK_OVERRIDE; + virtual void Update() override; /** SimpleParallelTiffWriter Methods */ virtual void SetFileName(const char* extendedFileName); @@ -255,7 +255,7 @@ public: protected: SimpleParallelTiffWriter(); virtual ~SimpleParallelTiffWriter(); - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SimpleParallelTiffWriter(const SimpleParallelTiffWriter &); //purposely not implemented diff --git a/Modules/OBIA/RCC8/include/otbImageListToRCC8GraphFilter.h b/Modules/OBIA/RCC8/include/otbImageListToRCC8GraphFilter.h index e14f374ca4..2a31c34c09 100644 --- a/Modules/OBIA/RCC8/include/otbImageListToRCC8GraphFilter.h +++ b/Modules/OBIA/RCC8/include/otbImageListToRCC8GraphFilter.h @@ -73,9 +73,9 @@ protected: /** Constructor */ ImageListToRCC8GraphFilter(); /** Destructor */ - ~ImageListToRCC8GraphFilter() ITK_OVERRIDE {} + ~ImageListToRCC8GraphFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageListToRCC8GraphFilter(const Self &); //purposely not implemented diff --git a/Modules/OBIA/RCC8/include/otbImageMultiSegmentationToRCC8GraphFilter.h b/Modules/OBIA/RCC8/include/otbImageMultiSegmentationToRCC8GraphFilter.h index 345de1067a..16e7b21960 100644 --- a/Modules/OBIA/RCC8/include/otbImageMultiSegmentationToRCC8GraphFilter.h +++ b/Modules/OBIA/RCC8/include/otbImageMultiSegmentationToRCC8GraphFilter.h @@ -84,11 +84,11 @@ protected: /** Constructor */ ImageMultiSegmentationToRCC8GraphFilter(); /** Destructor */ - ~ImageMultiSegmentationToRCC8GraphFilter() ITK_OVERRIDE; + ~ImageMultiSegmentationToRCC8GraphFilter() override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Get the composition knowledge. * \param r1 First RCC8 relation value, diff --git a/Modules/OBIA/RCC8/include/otbImageToImageRCC8Calculator.h b/Modules/OBIA/RCC8/include/otbImageToImageRCC8Calculator.h index c1778371ff..7e074277a8 100644 --- a/Modules/OBIA/RCC8/include/otbImageToImageRCC8Calculator.h +++ b/Modules/OBIA/RCC8/include/otbImageToImageRCC8Calculator.h @@ -118,7 +118,7 @@ protected: /** Constructor */ ImageToImageRCC8Calculator(); /** Destructor */ - ~ImageToImageRCC8Calculator() ITK_OVERRIDE {} + ~ImageToImageRCC8Calculator() override {} /** * Compute the minimal image region required. * \return The minimal region required. @@ -173,9 +173,9 @@ protected: */ BoolImagePointerType ConvertToBoolImage(ImagePointerType image, PixelType insideValue); /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** The RCC8 relation value */ diff --git a/Modules/OBIA/RCC8/include/otbPolygonListToRCC8GraphFilter.h b/Modules/OBIA/RCC8/include/otbPolygonListToRCC8GraphFilter.h index aab4a679cc..2dd119d946 100644 --- a/Modules/OBIA/RCC8/include/otbPolygonListToRCC8GraphFilter.h +++ b/Modules/OBIA/RCC8/include/otbPolygonListToRCC8GraphFilter.h @@ -123,9 +123,9 @@ protected: /** Constructor */ PolygonListToRCC8GraphFilter(); /** Destructor */ - ~PolygonListToRCC8GraphFilter() ITK_OVERRIDE; + ~PolygonListToRCC8GraphFilter() override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Multi-threading implementation */ @@ -151,7 +151,7 @@ protected: /** End Multi-threading implementation */ /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Get the composition knowledge. * \param r1 First RCC8 relation value, diff --git a/Modules/OBIA/RCC8/include/otbPolygonToPolygonRCC8Calculator.h b/Modules/OBIA/RCC8/include/otbPolygonToPolygonRCC8Calculator.h index 5c27c5f8d2..4f81008a08 100644 --- a/Modules/OBIA/RCC8/include/otbPolygonToPolygonRCC8Calculator.h +++ b/Modules/OBIA/RCC8/include/otbPolygonToPolygonRCC8Calculator.h @@ -109,9 +109,9 @@ protected: /** Constructor */ PolygonToPolygonRCC8Calculator(); /** Destructor */ - ~PolygonToPolygonRCC8Calculator() ITK_OVERRIDE {} + ~PolygonToPolygonRCC8Calculator() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** The RCC8 relation value */ diff --git a/Modules/OBIA/RCC8/include/otbRCC8Edge.h b/Modules/OBIA/RCC8/include/otbRCC8Edge.h index 9dfb9005dd..58490e89c5 100644 --- a/Modules/OBIA/RCC8/include/otbRCC8Edge.h +++ b/Modules/OBIA/RCC8/include/otbRCC8Edge.h @@ -56,9 +56,9 @@ protected: /** Constructor */ RCC8Edge(); /** Desctructor */ - ~RCC8Edge() ITK_OVERRIDE {} + ~RCC8Edge() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** The RCC8 value */ diff --git a/Modules/OBIA/RCC8/include/otbRCC8Graph.h b/Modules/OBIA/RCC8/include/otbRCC8Graph.h index 4130636425..fc1f7f965f 100644 --- a/Modules/OBIA/RCC8/include/otbRCC8Graph.h +++ b/Modules/OBIA/RCC8/include/otbRCC8Graph.h @@ -127,9 +127,9 @@ protected: /** Constructor */ RCC8Graph(); /** Destructor */ - ~RCC8Graph() ITK_OVERRIDE {} + ~RCC8Graph() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Initialize a range of vertex. * \param num The index of the last vertices to initialize. diff --git a/Modules/OBIA/RCC8/include/otbRCC8GraphFileReader.h b/Modules/OBIA/RCC8/include/otbRCC8GraphFileReader.h index 08d8bf3a1e..31879d4809 100644 --- a/Modules/OBIA/RCC8/include/otbRCC8GraphFileReader.h +++ b/Modules/OBIA/RCC8/include/otbRCC8GraphFileReader.h @@ -92,9 +92,9 @@ protected: /** Constructor */ RCC8GraphFileReader(); /** Destructor */ - ~RCC8GraphFileReader() ITK_OVERRIDE; + ~RCC8GraphFileReader() override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** * Parse edge information from a given line. * \param line The line to parse. @@ -107,7 +107,7 @@ protected: void ParseVertex(const std::string& line); /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** File name */ diff --git a/Modules/OBIA/RCC8/include/otbRCC8GraphFileWriter.h b/Modules/OBIA/RCC8/include/otbRCC8GraphFileWriter.h index 010e42fe0a..f9c893cb51 100644 --- a/Modules/OBIA/RCC8/include/otbRCC8GraphFileWriter.h +++ b/Modules/OBIA/RCC8/include/otbRCC8GraphFileWriter.h @@ -107,17 +107,17 @@ public: /** * Update method. */ - void Update(void) ITK_OVERRIDE; + void Update(void) override; protected: /** Constructor */ RCC8GraphFileWriter(); /** Destructor */ - ~RCC8GraphFileWriter() ITK_OVERRIDE; + ~RCC8GraphFileWriter() override; /** * Main computation method. */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** * Write Method. * Performs checkings and invoke GenerateData(). @@ -143,7 +143,7 @@ protected: /** * PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** Filename of the graph file to write */ diff --git a/Modules/OBIA/RCC8/include/otbRCC8GraphSource.h b/Modules/OBIA/RCC8/include/otbRCC8GraphSource.h index 0c4acf40b0..a70f4bcf6a 100644 --- a/Modules/OBIA/RCC8/include/otbRCC8GraphSource.h +++ b/Modules/OBIA/RCC8/include/otbRCC8GraphSource.h @@ -57,9 +57,9 @@ protected: /** Constructor */ RCC8GraphSource(); /** Destructor */ - ~RCC8GraphSource() ITK_OVERRIDE {} + ~RCC8GraphSource() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: RCC8GraphSource(const Self &); //purposely not implemented diff --git a/Modules/OBIA/RCC8/include/otbRCC8VertexBase.h b/Modules/OBIA/RCC8/include/otbRCC8VertexBase.h index a7c02a152d..b432ded549 100644 --- a/Modules/OBIA/RCC8/include/otbRCC8VertexBase.h +++ b/Modules/OBIA/RCC8/include/otbRCC8VertexBase.h @@ -82,9 +82,9 @@ protected: /** Constructor */ RCC8VertexBase(); /** Desctructor */ - ~RCC8VertexBase() ITK_OVERRIDE {} + ~RCC8VertexBase() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** The segmentation level */ diff --git a/Modules/OBIA/RCC8/include/otbRCC8VertexWithCompacity.h b/Modules/OBIA/RCC8/include/otbRCC8VertexWithCompacity.h index c1dc529974..c9695fb2e3 100644 --- a/Modules/OBIA/RCC8/include/otbRCC8VertexWithCompacity.h +++ b/Modules/OBIA/RCC8/include/otbRCC8VertexWithCompacity.h @@ -61,20 +61,20 @@ public: * Set the VertexWithCompacity attributes from the attributes vector. * \param attributes The vector containing the parsed attributes. */ - void SetAttributesMap(AttributesMapType attributes) ITK_OVERRIDE; + void SetAttributesMap(AttributesMapType attributes) override; /** * Get an attributes vector representing the VertexWithCompacity attributes. * \return The attributes vector */ - AttributesMapType GetAttributesMap(void) ITK_OVERRIDE; + AttributesMapType GetAttributesMap(void) override; protected: /** Constructor */ RCC8VertexWithCompacity(); /** Desctructor */ - ~RCC8VertexWithCompacity() ITK_OVERRIDE {} + ~RCC8VertexWithCompacity() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** The compacity */ diff --git a/Modules/Radiometry/Indices/include/otbBuiltUpIndicesFunctor.h b/Modules/Radiometry/Indices/include/otbBuiltUpIndicesFunctor.h index dbf78a9c4a..6b8ca2c517 100644 --- a/Modules/Radiometry/Indices/include/otbBuiltUpIndicesFunctor.h +++ b/Modules/Radiometry/Indices/include/otbBuiltUpIndicesFunctor.h @@ -151,7 +151,7 @@ class NDBI : public TM4AndTM5IndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "NDBI"; } @@ -159,10 +159,10 @@ public: /// Constructor NDBI() {} /// Desctructor - ~NDBI() ITK_OVERRIDE {} + ~NDBI() override {} // Operator on r and nir single pixel values protected: - inline TOutput Evaluate(const TInput1& pTM4, const TInput2& pTM5) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& pTM4, const TInput2& pTM5) const override { double dTM4 = static_cast<double>(pTM4); double dTM5 = static_cast<double>(pTM5); @@ -190,7 +190,7 @@ class ISU : public RAndNIRIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "ISU"; } @@ -198,7 +198,7 @@ public: /// Constructor ISU() : m_A(100.), m_B(25.) {} /// Desctructor - ~ISU() ITK_OVERRIDE {} + ~ISU() override {} /** Set/Get A correction */ void SetA(const double pA) @@ -220,7 +220,7 @@ public: } protected: - inline TOutput Evaluate(const TInput1& pRed, const TInput2& pNIR) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& pRed, const TInput2& pNIR) const override { double dRed = static_cast<double>(pRed); double dNIR = static_cast<double>(pNIR); diff --git a/Modules/Radiometry/Indices/include/otbGAndRIndexImageFilter.h b/Modules/Radiometry/Indices/include/otbGAndRIndexImageFilter.h index 829d3c4f48..000fd04623 100644 --- a/Modules/Radiometry/Indices/include/otbGAndRIndexImageFilter.h +++ b/Modules/Radiometry/Indices/include/otbGAndRIndexImageFilter.h @@ -72,9 +72,9 @@ public: protected: GAndRIndexImageFilter(); - ~GAndRIndexImageFilter() ITK_OVERRIDE {} + ~GAndRIndexImageFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /* void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ); diff --git a/Modules/Radiometry/Indices/include/otbLandsatTMIndices.h b/Modules/Radiometry/Indices/include/otbLandsatTMIndices.h index fd586c9474..a94a63f162 100644 --- a/Modules/Radiometry/Indices/include/otbLandsatTMIndices.h +++ b/Modules/Radiometry/Indices/include/otbLandsatTMIndices.h @@ -343,7 +343,7 @@ public: virtual std::string GetName() const = 0; LandsatTMIndex() {} - ~LandsatTMIndex() ITK_OVERRIDE {} + ~LandsatTMIndex() override {} }; @@ -370,13 +370,13 @@ class Bright : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "Bright"; } Bright() {} - ~Bright() ITK_OVERRIDE {} + ~Bright() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -411,13 +411,13 @@ class Vis : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "Vis"; } Vis() {} - ~Vis() ITK_OVERRIDE {} + ~Vis() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -444,13 +444,13 @@ class NIR : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "NIR"; } NIR() {} - ~NIR() ITK_OVERRIDE {} + ~NIR() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -476,13 +476,13 @@ class MIR1 : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "MIR1"; } MIR1() {} - ~MIR1() ITK_OVERRIDE {} + ~MIR1() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -508,13 +508,13 @@ class MIR2 : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "MIR2"; } MIR2() {} - ~MIR2() ITK_OVERRIDE {} + ~MIR2() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -540,13 +540,13 @@ class TIR : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "TIR"; } TIR() {} - ~TIR() ITK_OVERRIDE {} + ~TIR() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -586,13 +586,13 @@ class MIRTIR : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "MIRTIR"; } MIRTIR() {} - ~MIRTIR() ITK_OVERRIDE {} + ~MIRTIR() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -626,13 +626,13 @@ class NDVI : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "NDVI"; } NDVI() {} - ~NDVI() ITK_OVERRIDE {} + ~NDVI() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -673,13 +673,13 @@ class NDBSI : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "NDBSI"; } NDBSI() {} - ~NDBSI() ITK_OVERRIDE {} + ~NDBSI() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -716,13 +716,13 @@ class BIO : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "BIO"; } BIO() {} - ~BIO() ITK_OVERRIDE {} + ~BIO() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -762,13 +762,13 @@ class NDSI : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "NDSI"; } NDSI() {} - ~NDSI() ITK_OVERRIDE {} + ~NDSI() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -819,13 +819,13 @@ class NDSIVis : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "NDSIVis"; } NDSIVis() {} - ~NDSIVis() ITK_OVERRIDE {} + ~NDSIVis() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -864,13 +864,13 @@ class NDBBBI : public LandsatTMIndex<TInput, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "NDBBBI"; } NDBBBI() {} - ~NDBBBI() ITK_OVERRIDE {} + ~NDBBBI() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -984,7 +984,7 @@ public: m_FvNDBSI->SetMembership(Medium, -0.20, -0.20, 0.0, 0.0); m_FvNDBSI->SetMembership(High, 0.0, 0.0, maximumValue, maximumValue); } - ~LinguisticVariables() ITK_OVERRIDE {} + ~LinguisticVariables() override {} inline itk::FixedArray<unsigned int, 11> operator ()(const TInput& inputPixel) { @@ -1068,7 +1068,7 @@ public: } KernelSpectralRule() : m_TV1(0.7), m_TV2(0.5) { } - ~KernelSpectralRule() ITK_OVERRIDE {} + ~KernelSpectralRule() override {} void SetTV1(PrecisionType tv1) { @@ -1163,13 +1163,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM ThickCloudsSpectralRule"; } ThickCloudsSpectralRule() { } - ~ThickCloudsSpectralRule() ITK_OVERRIDE {} + ~ThickCloudsSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1221,13 +1221,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM ThinCloudsSpectralRule"; } ThinCloudsSpectralRule() { } - ~ThinCloudsSpectralRule() ITK_OVERRIDE {} + ~ThinCloudsSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1282,13 +1282,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM SnowOrIceSpectralRule"; } SnowOrIceSpectralRule() { } - ~SnowOrIceSpectralRule() ITK_OVERRIDE {} + ~SnowOrIceSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1341,13 +1341,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM WaterOrShadowSpectralRule"; } WaterOrShadowSpectralRule() { } - ~WaterOrShadowSpectralRule() ITK_OVERRIDE {} + ~WaterOrShadowSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1388,13 +1388,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM PitbogOrGreenhouseSpectralRule"; } PitbogOrGreenhouseSpectralRule() { } - ~PitbogOrGreenhouseSpectralRule() ITK_OVERRIDE {} + ~PitbogOrGreenhouseSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1446,13 +1446,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM DominantBlueSpectralRule"; } DominantBlueSpectralRule() { } - ~DominantBlueSpectralRule() ITK_OVERRIDE {} + ~DominantBlueSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1494,13 +1494,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM VegetationSpectralRule"; } VegetationSpectralRule() { } - ~VegetationSpectralRule() ITK_OVERRIDE {} + ~VegetationSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1554,13 +1554,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM RangelandSpectralRule"; } RangelandSpectralRule() { } - ~RangelandSpectralRule() ITK_OVERRIDE {} + ~RangelandSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1615,13 +1615,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM BarrenLandOrBuiltUpOrCloudsSpectralRule"; } BarrenLandOrBuiltUpOrCloudsSpectralRule() { } - ~BarrenLandOrBuiltUpOrCloudsSpectralRule() ITK_OVERRIDE {} + ~BarrenLandOrBuiltUpOrCloudsSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1673,13 +1673,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM FlatResponseBarrenLandOrBuiltUpSpectralRule"; } FlatResponseBarrenLandOrBuiltUpSpectralRule() { } - ~FlatResponseBarrenLandOrBuiltUpSpectralRule() ITK_OVERRIDE {} + ~FlatResponseBarrenLandOrBuiltUpSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1727,13 +1727,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM ShadowWithBarrenLandSpectralRule"; } ShadowWithBarrenLandSpectralRule() { } - ~ShadowWithBarrenLandSpectralRule() ITK_OVERRIDE {} + ~ShadowWithBarrenLandSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1774,13 +1774,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM ShadowWithVegetationSpectralRule"; } ShadowWithVegetationSpectralRule() { } - ~ShadowWithVegetationSpectralRule() ITK_OVERRIDE {} + ~ShadowWithVegetationSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1822,13 +1822,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM ShadowCloudOrSnowSpectralRule"; } ShadowCloudOrSnowSpectralRule() { } - ~ShadowCloudOrSnowSpectralRule() ITK_OVERRIDE {} + ~ShadowCloudOrSnowSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { @@ -1877,13 +1877,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM WetlandSpectralRule"; } WetlandSpectralRule() { } - ~WetlandSpectralRule() ITK_OVERRIDE {} + ~WetlandSpectralRule() override {} inline TOutput operator ()(const TInput& inputPixel) { diff --git a/Modules/Radiometry/Indices/include/otbMultiChannelGAndRIndexImageFilter.h b/Modules/Radiometry/Indices/include/otbMultiChannelGAndRIndexImageFilter.h index d6a1b16768..3a230c4a10 100644 --- a/Modules/Radiometry/Indices/include/otbMultiChannelGAndRIndexImageFilter.h +++ b/Modules/Radiometry/Indices/include/otbMultiChannelGAndRIndexImageFilter.h @@ -98,9 +98,9 @@ protected: /// Constructor MultiChannelGAndRIndexImageFilter() : m_GreenIndex(1), m_RedIndex(2) {}; /// Destructor - ~MultiChannelGAndRIndexImageFilter() ITK_OVERRIDE {} + ~MultiChannelGAndRIndexImageFilter() override {} /// Before generating data, set functor parameters - void BeforeThreadedGenerateData() ITK_OVERRIDE + void BeforeThreadedGenerateData() override { unsigned int lNbChan = this->GetInput()->GetNumberOfComponentsPerPixel(); if (m_GreenIndex < 1 || m_RedIndex < 1 || @@ -112,7 +112,7 @@ protected: this->GetFunctor().SetRedIndex(m_RedIndex); } /// PrintSelf Method - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { this->Superclass::PrintSelf(os, indent); os << indent << "Green index: " << m_GreenIndex << std::endl; diff --git a/Modules/Radiometry/Indices/include/otbMultiChannelRAndBAndNIRIndexImageFilter.h b/Modules/Radiometry/Indices/include/otbMultiChannelRAndBAndNIRIndexImageFilter.h index f01f00d11b..8094f66ac4 100644 --- a/Modules/Radiometry/Indices/include/otbMultiChannelRAndBAndNIRIndexImageFilter.h +++ b/Modules/Radiometry/Indices/include/otbMultiChannelRAndBAndNIRIndexImageFilter.h @@ -110,9 +110,9 @@ protected: /// Constructor MultiChannelRAndBAndNIRIndexImageFilter() : m_RedIndex(3), m_BlueIndex(1), m_NIRIndex(4) {}; /// Destructor - ~MultiChannelRAndBAndNIRIndexImageFilter() ITK_OVERRIDE {} + ~MultiChannelRAndBAndNIRIndexImageFilter() override {} /// Before generating data, set functor parameters - void BeforeThreadedGenerateData() ITK_OVERRIDE + void BeforeThreadedGenerateData() override { unsigned int lNbChan = this->GetInput()->GetNumberOfComponentsPerPixel(); if (m_RedIndex < 1 || m_BlueIndex < 1 || m_NIRIndex < 1 || @@ -125,7 +125,7 @@ protected: this->GetFunctor().SetNIRIndex(m_NIRIndex); } /// PrintSelf - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { this->Superclass::PrintSelf(os, indent); os << indent << "Red index: " << m_RedIndex << std::endl; diff --git a/Modules/Radiometry/Indices/include/otbMultiChannelRAndGAndNIRIndexImageFilter.h b/Modules/Radiometry/Indices/include/otbMultiChannelRAndGAndNIRIndexImageFilter.h index bdd0cb1045..6b8daf81ed 100644 --- a/Modules/Radiometry/Indices/include/otbMultiChannelRAndGAndNIRIndexImageFilter.h +++ b/Modules/Radiometry/Indices/include/otbMultiChannelRAndGAndNIRIndexImageFilter.h @@ -110,9 +110,9 @@ protected: /// Constructor MultiChannelRAndGAndNIRIndexImageFilter() : m_RedIndex(3), m_GreenIndex(2), m_NIRIndex(4) {}; /// Destructor - ~MultiChannelRAndGAndNIRIndexImageFilter() ITK_OVERRIDE {} + ~MultiChannelRAndGAndNIRIndexImageFilter() override {} /// Before generating data, set functor parameters - void BeforeThreadedGenerateData() ITK_OVERRIDE + void BeforeThreadedGenerateData() override { unsigned int lNbChan = this->GetInput()->GetNumberOfComponentsPerPixel(); @@ -126,7 +126,7 @@ protected: this->GetFunctor().SetNIRIndex(m_NIRIndex); } /// PrintSelf - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { this->Superclass::PrintSelf(os, indent); os << indent << "Red index: " << m_RedIndex << std::endl; diff --git a/Modules/Radiometry/Indices/include/otbMultiChannelRAndNIRIndexImageFilter.h b/Modules/Radiometry/Indices/include/otbMultiChannelRAndNIRIndexImageFilter.h index 3bc1c49d72..7b07d757d8 100644 --- a/Modules/Radiometry/Indices/include/otbMultiChannelRAndNIRIndexImageFilter.h +++ b/Modules/Radiometry/Indices/include/otbMultiChannelRAndNIRIndexImageFilter.h @@ -98,9 +98,9 @@ protected: /// Constructor MultiChannelRAndNIRIndexImageFilter() : m_RedIndex(3), m_NIRIndex(4) {}; /// Destructor - ~MultiChannelRAndNIRIndexImageFilter() ITK_OVERRIDE {} + ~MultiChannelRAndNIRIndexImageFilter() override {} /// Before generating data, set functor parameters - void BeforeThreadedGenerateData() ITK_OVERRIDE + void BeforeThreadedGenerateData() override { unsigned int lNbChan = this->GetInput()->GetNumberOfComponentsPerPixel(); if (m_RedIndex < 1 || m_NIRIndex < 1 || @@ -112,7 +112,7 @@ protected: this->GetFunctor().SetNIRIndex(m_NIRIndex); } /// PrintSelf Method - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { this->Superclass::PrintSelf(os, indent); os << indent << "Red index: " << m_RedIndex << std::endl; diff --git a/Modules/Radiometry/Indices/include/otbNDVIDataNodeFeatureFunction.h b/Modules/Radiometry/Indices/include/otbNDVIDataNodeFeatureFunction.h index f3e704d08c..028adb1623 100644 --- a/Modules/Radiometry/Indices/include/otbNDVIDataNodeFeatureFunction.h +++ b/Modules/Radiometry/Indices/include/otbNDVIDataNodeFeatureFunction.h @@ -88,7 +88,7 @@ public: typedef std::vector<PrecisionType> OutputType; - OutputType Evaluate( const DataNodeType& node ) const ITK_OVERRIDE; + OutputType Evaluate( const DataNodeType& node ) const override; /** Set/Get methods */ itkGetConstMacro(NDVIThreshold, PrecisionType); @@ -117,8 +117,8 @@ public: protected: NDVIDataNodeFeatureFunction(); - ~NDVIDataNodeFeatureFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~NDVIDataNodeFeatureFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: NDVIDataNodeFeatureFunction(const Self&); //purposely not implemented diff --git a/Modules/Radiometry/Indices/include/otbRAndBAndNIRIndexImageFilter.h b/Modules/Radiometry/Indices/include/otbRAndBAndNIRIndexImageFilter.h index 04646b1f18..ad01b1b2c6 100644 --- a/Modules/Radiometry/Indices/include/otbRAndBAndNIRIndexImageFilter.h +++ b/Modules/Radiometry/Indices/include/otbRAndBAndNIRIndexImageFilter.h @@ -74,9 +74,9 @@ public: protected: RAndBAndNIRIndexImageFilter(); - ~RAndBAndNIRIndexImageFilter() ITK_OVERRIDE {} + ~RAndBAndNIRIndexImageFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: RAndBAndNIRIndexImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Radiometry/Indices/include/otbRAndGAndNIRIndexImageFilter.h b/Modules/Radiometry/Indices/include/otbRAndGAndNIRIndexImageFilter.h index 5a721b6746..26cb6eb0a4 100644 --- a/Modules/Radiometry/Indices/include/otbRAndGAndNIRIndexImageFilter.h +++ b/Modules/Radiometry/Indices/include/otbRAndGAndNIRIndexImageFilter.h @@ -74,9 +74,9 @@ public: protected: RAndGAndNIRIndexImageFilter(); - ~RAndGAndNIRIndexImageFilter() ITK_OVERRIDE {} + ~RAndGAndNIRIndexImageFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: RAndGAndNIRIndexImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Radiometry/Indices/include/otbRAndNIRIndexImageFilter.h b/Modules/Radiometry/Indices/include/otbRAndNIRIndexImageFilter.h index fc118fb663..c93b6df863 100644 --- a/Modules/Radiometry/Indices/include/otbRAndNIRIndexImageFilter.h +++ b/Modules/Radiometry/Indices/include/otbRAndNIRIndexImageFilter.h @@ -71,9 +71,9 @@ public: protected: RAndNIRIndexImageFilter(); - ~RAndNIRIndexImageFilter() ITK_OVERRIDE {} + ~RAndNIRIndexImageFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /* void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ); diff --git a/Modules/Radiometry/Indices/include/otbSoilIndicesFunctor.h b/Modules/Radiometry/Indices/include/otbSoilIndicesFunctor.h index 57d2179871..6ed1b201c0 100644 --- a/Modules/Radiometry/Indices/include/otbSoilIndicesFunctor.h +++ b/Modules/Radiometry/Indices/include/otbSoilIndicesFunctor.h @@ -287,7 +287,7 @@ class IR : public GAndRIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "IR"; } @@ -295,10 +295,10 @@ public: /// Constructor IR() {} /// Desctructor - ~IR() ITK_OVERRIDE {} + ~IR() override {} // Operator on r and nir single pixel values protected: - inline TOutput Evaluate(const TInput1& pGreen, const TInput2& pRed) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& pGreen, const TInput2& pRed) const override { double dGreen = static_cast<double>(pGreen); double dRed = static_cast<double>(pRed); @@ -330,7 +330,7 @@ class IC : public GAndRIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "IC"; } @@ -338,10 +338,10 @@ public: /// Constructor IC() {} /// Desctructor - ~IC() ITK_OVERRIDE {} + ~IC() override {} // Operator on r and nir single pixel values protected: - inline TOutput Evaluate(const TInput1& pGreen, const TInput2& pRed) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& pGreen, const TInput2& pRed) const override { double dGreen = static_cast<double>(pGreen); double dRed = static_cast<double>(pRed); @@ -369,7 +369,7 @@ class IB : public GAndRIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "IB"; } @@ -377,10 +377,10 @@ public: /// Constructor IB() {} /// Desctructor - ~IB() ITK_OVERRIDE {} + ~IB() override {} // Operator on r and nir single pixel values protected: - inline TOutput Evaluate(const TInput1& pGreen, const TInput2& pRed) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& pGreen, const TInput2& pRed) const override { double dGreen = static_cast<double>(pGreen); double dRed = static_cast<double>(pRed); @@ -404,7 +404,7 @@ class IB2 : public GAndRAndNirIndexBase<TInput1, TInput2, TInput3, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "IB2"; } @@ -412,10 +412,10 @@ public: /// Constructor IB2() {} /// Desctructor - ~IB2() ITK_OVERRIDE {} + ~IB2() override {} // Operator on r and nir single pixel values protected: - inline TOutput Evaluate(const TInput1& pGreen, const TInput2& pRed, const TInput2& pNir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& pGreen, const TInput2& pRed, const TInput2& pNir) const override { double dGreen = static_cast<double>(pGreen); double dRed = static_cast<double>(pRed); diff --git a/Modules/Radiometry/Indices/include/otbVegetationIndicesFunctor.h b/Modules/Radiometry/Indices/include/otbVegetationIndicesFunctor.h index 48b3402d8f..a83cc354d7 100644 --- a/Modules/Radiometry/Indices/include/otbVegetationIndicesFunctor.h +++ b/Modules/Radiometry/Indices/include/otbVegetationIndicesFunctor.h @@ -414,7 +414,7 @@ class NDVI : public RAndNIRIndexBase<TInput1, TInput2, TOutput> public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "NDVI"; } @@ -422,10 +422,10 @@ public: /// Constructor NDVI() {} /// Desctructor - ~NDVI() ITK_OVERRIDE {} + ~NDVI() override {} // Operator on r and nir single pixel values protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double dr = static_cast<double>(r); double dnir = static_cast<double>(nir); @@ -454,15 +454,15 @@ class RVI : public RAndNIRIndexBase<TInput1, TInput2, TOutput> public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "RVI"; } RVI() {} - ~RVI() ITK_OVERRIDE {} + ~RVI() override {} protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double dr = static_cast<double>(r); double dnir = static_cast<double>(nir); @@ -493,13 +493,13 @@ class PVI : public RAndNIRIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "PVI"; } PVI() : m_A(0.90893), m_B(7.46216), m_Coeff(0.74) {} - ~PVI() ITK_OVERRIDE {} + ~PVI() override {} /** Set/Get A and B parameters */ void SetA(const double A) { @@ -519,7 +519,7 @@ public: return (m_B); } protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double dnir = static_cast<double>(nir); double dr = static_cast<double>(r); @@ -552,13 +552,13 @@ class SAVI : public RAndNIRIndexBase<TInput1, TInput2, TOutput> public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "SAVI"; } SAVI() : m_L(0.5) {} - ~SAVI() ITK_OVERRIDE {} + ~SAVI() override {} /** Set/Get L correction */ void SetL(const double L) @@ -571,7 +571,7 @@ public: } protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double dnir = static_cast<double>(nir); double dr = static_cast<double>(r); @@ -606,13 +606,13 @@ class TSAVI : public RAndNIRIndexBase<TInput1, TInput2, TOutput> public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "TSAVI"; } TSAVI() : m_A(0.7), m_S(0.9), m_X(0.08) {} - ~TSAVI() ITK_OVERRIDE {} + ~TSAVI() override {} /** Set/Get S and A parameters */ void SetS(const double S) @@ -642,7 +642,7 @@ public: } protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double dnir = static_cast<double>(nir); double dr = static_cast<double>(r); @@ -679,7 +679,7 @@ class WDVI : public RAndNIRIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "WDVI"; } @@ -687,7 +687,7 @@ public: /// Constructor WDVI() : m_S(0.4) {} /// Desctructor - ~WDVI() ITK_OVERRIDE {} + ~WDVI() override {} // Operator on r and nir single pixel values /** Set/Get Slop of soil line */ void SetS(const double s) @@ -699,7 +699,7 @@ public: return (m_S); } protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double dr = static_cast<double>(r); double dnir = static_cast<double>(nir); @@ -727,7 +727,7 @@ class MSAVI : public RAndNIRIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "MSAVI"; } @@ -739,7 +739,7 @@ public: { m_WDVIfunctor.SetS(m_S); } - ~MSAVI() ITK_OVERRIDE {} + ~MSAVI() override {} /** Set/Get Slop of soil line */ void SetS(const double s) { @@ -760,7 +760,7 @@ public: } protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double dnir = static_cast<double>(nir); double dr = static_cast<double>(r); @@ -802,16 +802,16 @@ class MSAVI2 : public RAndNIRIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "MSAVI2"; } MSAVI2() {} - ~MSAVI2() ITK_OVERRIDE {} + ~MSAVI2() override {} protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double dnir = static_cast<double>(nir); double dr = static_cast<double>(r); @@ -840,16 +840,16 @@ class GEMI : public RAndNIRIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "GEMI"; } GEMI() {} - ~GEMI() ITK_OVERRIDE {} + ~GEMI() override {} protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double dnir = static_cast<double>(nir); double dr = static_cast<double>(r); @@ -894,13 +894,13 @@ class AVI : public RAndGAndNIRIndexBase<TInput1, TInput2, TInput3, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "AVI"; } AVI() : m_LambdaG(560.), m_LambdaR(660.), m_LambdaNir(830.) {} - ~AVI() ITK_OVERRIDE {} + ~AVI() override {} /** Set/Get Lambda red parameter*/ void SetLambdaR(const double lr) { @@ -929,7 +929,7 @@ public: return (m_LambdaNir); } protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& g, const TInput3& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& g, const TInput3& nir) const override { double dr = static_cast<double>(r); double dg = static_cast<double>(g); @@ -989,13 +989,13 @@ class ARVI : public RAndBAndNIRIndexBase<TInput1, TInput2, TInput3, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "ARVI"; } ARVI() : m_Gamma(0.5) {} - ~ARVI() ITK_OVERRIDE {} + ~ARVI() override {} /** Set/Get Gamma parameter */ void SetGamma(const double gamma) @@ -1008,7 +1008,7 @@ public: } protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& b, const TInput3& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& b, const TInput3& nir) const override { double dr = static_cast<double>(r); double db = static_cast<double>(b); @@ -1043,13 +1043,13 @@ class TSARVI : public RAndBAndNIRIndexBase<TInput1, TInput2, TInput3, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "TSARVI"; } TSARVI() : m_A(0.0), m_B(0.0), m_X(0.08), m_Gamma(0.5) {} - ~TSARVI() ITK_OVERRIDE {} + ~TSARVI() override {} /** Set/Get A and B parameters */ void SetA(const double A) @@ -1088,7 +1088,7 @@ public: } protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& b, const TInput3& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& b, const TInput3& nir) const override { double dr = static_cast<double>(r); double db = static_cast<double>(b); @@ -1131,13 +1131,13 @@ class EVI : public RAndBAndNIRIndexBase<TInput1, TInput2, TInput3, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "EVI"; } EVI() : m_G(2.5), m_C1(6.0), m_C2(7.5), m_L(1.0) {} - ~EVI() ITK_OVERRIDE {} + ~EVI() override {} /** Set/Get G parameter */ void SetG(const double g) { @@ -1175,7 +1175,7 @@ public: return (m_L); } protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& b, const TInput3& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& b, const TInput3& nir) const override { double dr = static_cast<double>(r); double db = static_cast<double>(b); @@ -1218,16 +1218,16 @@ class IPVI : public RAndNIRIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "IPVI"; } IPVI() {} - ~IPVI() ITK_OVERRIDE {} + ~IPVI() override {} protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double dr = static_cast<double>(r); double dnir = static_cast<double>(nir); @@ -1257,14 +1257,14 @@ class TNDVI : public RAndNIRIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "TNDVI"; } typedef NDVI<TInput1, TInput2, TOutput> NDVIFunctorType; TNDVI() {} - ~TNDVI() ITK_OVERRIDE {} + ~TNDVI() override {} NDVIFunctorType GetNDVI(void) const { @@ -1272,7 +1272,7 @@ public: } protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double dval = this->GetNDVI() (r, nir) + 0.5; if (dval < 0) @@ -1309,14 +1309,14 @@ class LAIFromNDVILogarithmic : public RAndNIRIndexBase<TInput1, TInput2, TOutput { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LAIFromNDVILogarithmic"; } typedef NDVI<TInput1, TInput2, TOutput> NDVIFunctorType; LAIFromNDVILogarithmic() : m_NdviSoil(0.10), m_NdviInf(0.89), m_ExtinctionCoefficient(0.71) {} - ~LAIFromNDVILogarithmic() ITK_OVERRIDE {} + ~LAIFromNDVILogarithmic() override {} NDVIFunctorType GetNDVI(void) const { @@ -1351,7 +1351,7 @@ public: } protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double dval = this->GetNDVI() (r, nir); if (dval < 0) @@ -1395,14 +1395,14 @@ class LAIFromReflectancesLinear : public RAndNIRIndexBase<TInput1, TInput2, TOut { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LAIFromReflectancesLinear"; } typedef NDVI<TInput1, TInput2, TOutput> NDVIFunctorType; LAIFromReflectancesLinear() : m_RedCoef(-17.91), m_NirCoef(12.26) {} - ~LAIFromReflectancesLinear() ITK_OVERRIDE {} + ~LAIFromReflectancesLinear() override {} NDVIFunctorType GetReflectances(void) const { @@ -1428,7 +1428,7 @@ public: } protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { return (static_cast<TOutput>(m_RedCoef*r+m_NirCoef*nir)); } @@ -1464,7 +1464,7 @@ private: public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LAIFromNDVIFormosat2Functor"; } @@ -1472,10 +1472,10 @@ private: /// Constructor LAIFromNDVIFormosat2Functor() {} /// Desctructor - ~LAIFromNDVIFormosat2Functor() ITK_OVERRIDE {} + ~LAIFromNDVIFormosat2Functor() override {} // Operator on r and nir single pixel values protected: - inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& r, const TInput2& nir) const override { double a = 0.1519; double b = 3.9443; diff --git a/Modules/Radiometry/Indices/include/otbWaterIndicesFunctor.h b/Modules/Radiometry/Indices/include/otbWaterIndicesFunctor.h index 10f11fa3a8..feb14fc3c9 100644 --- a/Modules/Radiometry/Indices/include/otbWaterIndicesFunctor.h +++ b/Modules/Radiometry/Indices/include/otbWaterIndicesFunctor.h @@ -126,15 +126,15 @@ class WaterIndexFunctor : public WaterIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "WaterIndexFunctor"; } WaterIndexFunctor() {} - ~WaterIndexFunctor() ITK_OVERRIDE {} + ~WaterIndexFunctor() override {} protected: - inline TOutput Evaluate(const TInput1& id1, const TInput2& id2) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& id1, const TInput2& id2) const override { double dindex1 = static_cast<double>(id1); double dindex2 = static_cast<double>(id2); @@ -202,7 +202,7 @@ class NDWI : public WaterIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "NDWI"; } @@ -211,7 +211,7 @@ public: /// Constructor NDWI() {} /// Desctructor - ~NDWI() ITK_OVERRIDE {} + ~NDWI() override {} WIFunctorType GetWIFunctor(void) const { return (m_WIFunctor); @@ -263,7 +263,7 @@ public: } protected: - inline TOutput Evaluate(const TInput1& nir, const TInput2& mir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& nir, const TInput2& mir) const override { return (static_cast<TOutput>(GetWIFunctor() (nir, mir))); } @@ -287,7 +287,7 @@ class NDWI2 : public WaterIndexBase<TInput1, TInput2, TOutput> { public: /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "NDWI2"; } @@ -296,7 +296,7 @@ public: /// Constructor NDWI2() {} /// Desctructor - ~NDWI2() ITK_OVERRIDE {} + ~NDWI2() override {} WIFunctorType GetWIFunctor(void) const { return (m_WIFunctor); @@ -348,7 +348,7 @@ public: } protected: - inline TOutput Evaluate(const TInput1& g, const TInput2& nir) const ITK_OVERRIDE + inline TOutput Evaluate(const TInput1& g, const TInput2& nir) const override { return (static_cast<TOutput>(GetWIFunctor() (g, nir))); } @@ -650,7 +650,7 @@ public: reference[0] = 136.0; reference[1] = 132.0; reference[2] = 47.0; reference[3] = 24.0; this->SetReferenceWaterPixel(reference); } - ~WaterSqrtSpectralAngleFunctor() ITK_OVERRIDE {} + ~WaterSqrtSpectralAngleFunctor() override {} /** Set Reference Pixel */ void SetReferenceWaterPixel(InputVectorPixelType ref) @@ -742,7 +742,7 @@ public: } protected: - inline TOutputPixel Evaluate(const TInputVectorPixel& inPix) const ITK_OVERRIDE + inline TOutputPixel Evaluate(const TInputVectorPixel& inPix) const override { return static_cast<TOutputPixel>(Superclass::Evaluate(inPix)); } diff --git a/Modules/Radiometry/Indices/include/otbWaterSqrtSpectralAngleImageFilter.h b/Modules/Radiometry/Indices/include/otbWaterSqrtSpectralAngleImageFilter.h index d90d827fd4..0ad1616833 100644 --- a/Modules/Radiometry/Indices/include/otbWaterSqrtSpectralAngleImageFilter.h +++ b/Modules/Radiometry/Indices/include/otbWaterSqrtSpectralAngleImageFilter.h @@ -73,7 +73,7 @@ public: protected: WaterSqrtSpectralAngleImageFilter() {} - ~WaterSqrtSpectralAngleImageFilter() ITK_OVERRIDE {} + ~WaterSqrtSpectralAngleImageFilter() override {} private: WaterSqrtSpectralAngleImageFilter(Self &); // purposely not implemented diff --git a/Modules/Radiometry/LandSatClassifier/include/otbLandsatTMSpectralRuleBasedClassifier.h b/Modules/Radiometry/LandSatClassifier/include/otbLandsatTMSpectralRuleBasedClassifier.h index 284312d819..f3bc345849 100644 --- a/Modules/Radiometry/LandSatClassifier/include/otbLandsatTMSpectralRuleBasedClassifier.h +++ b/Modules/Radiometry/LandSatClassifier/include/otbLandsatTMSpectralRuleBasedClassifier.h @@ -183,13 +183,13 @@ public: typedef bool OutputPixelType; /** Return the index name */ - std::string GetName() const ITK_OVERRIDE + std::string GetName() const override { return "LandsatTM SpectralRuleBasedClassifier"; } SpectralRuleBasedClassifier() { } - ~SpectralRuleBasedClassifier() ITK_OVERRIDE {} + ~SpectralRuleBasedClassifier() override {} inline TOutput operator ()(const TInput& inputPixel) { diff --git a/Modules/Radiometry/OpticalCalibration/include/otbAeronetData.h b/Modules/Radiometry/OpticalCalibration/include/otbAeronetData.h index 801554d157..20adbd6e39 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbAeronetData.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbAeronetData.h @@ -87,9 +87,9 @@ protected: /** Constructor */ AeronetData(); /** Destructor */ - ~AeronetData() ITK_OVERRIDE {} + ~AeronetData() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** Angstrom coefficient */ diff --git a/Modules/Radiometry/OpticalCalibration/include/otbAeronetFileReader.h b/Modules/Radiometry/OpticalCalibration/include/otbAeronetFileReader.h index 93b16a7979..74a514a465 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbAeronetFileReader.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbAeronetFileReader.h @@ -126,12 +126,12 @@ protected: /** Constructor */ AeronetFileReader(); /** Destructor */ - ~AeronetFileReader() ITK_OVERRIDE; + ~AeronetFileReader() override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Radiometry/OpticalCalibration/include/otbAtmosphericCorrectionParameters.h b/Modules/Radiometry/OpticalCalibration/include/otbAtmosphericCorrectionParameters.h index 56f45de702..f1516e26ef 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbAtmosphericCorrectionParameters.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbAtmosphericCorrectionParameters.h @@ -137,12 +137,12 @@ public: /** Constructor */ AtmosphericCorrectionParameters(); /** Destructor */ - ~AtmosphericCorrectionParameters() ITK_OVERRIDE {} + ~AtmosphericCorrectionParameters() override {} protected: /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: AtmosphericCorrectionParameters(const Self &); //purposely not implemented diff --git a/Modules/Radiometry/OpticalCalibration/include/otbAtmosphericRadiativeTerms.h b/Modules/Radiometry/OpticalCalibration/include/otbAtmosphericRadiativeTerms.h index b219982e79..5daf902b5a 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbAtmosphericRadiativeTerms.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbAtmosphericRadiativeTerms.h @@ -119,9 +119,9 @@ protected: /** Constructor */ AtmosphericRadiativeTermsSingleChannel(); /** Destructor */ - ~AtmosphericRadiativeTermsSingleChannel() ITK_OVERRIDE {} + ~AtmosphericRadiativeTermsSingleChannel() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: AtmosphericRadiativeTermsSingleChannel(const Self &); //purposely not implemented @@ -266,9 +266,9 @@ protected: /** Constructor */ AtmosphericRadiativeTerms(); /** Destructor */ - ~AtmosphericRadiativeTerms() ITK_OVERRIDE {} + ~AtmosphericRadiativeTerms() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: AtmosphericRadiativeTerms(const Self &); //purposely not implemented diff --git a/Modules/Radiometry/OpticalCalibration/include/otbImageMetadataCorrectionParameters.h b/Modules/Radiometry/OpticalCalibration/include/otbImageMetadataCorrectionParameters.h index 6bcb770447..3a1b75de08 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbImageMetadataCorrectionParameters.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbImageMetadataCorrectionParameters.h @@ -145,12 +145,12 @@ public: /** Constructor */ ImageMetadataCorrectionParameters(); /** Destructor */ - ~ImageMetadataCorrectionParameters() ITK_OVERRIDE {} + ~ImageMetadataCorrectionParameters() override {} protected: /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageMetadataCorrectionParameters(const Self &); //purposely not implemented diff --git a/Modules/Radiometry/OpticalCalibration/include/otbImageToRadianceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbImageToRadianceImageFilter.h index fc8b7c3bbd..695bdf33e1 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbImageToRadianceImageFilter.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbImageToRadianceImageFilter.h @@ -171,10 +171,10 @@ protected: }; /** Destructor */ - ~ImageToRadianceImageFilter() ITK_OVERRIDE {} + ~ImageToRadianceImageFilter() override {} /** Update the functor list and input parameters */ - void BeforeThreadedGenerateData(void) ITK_OVERRIDE + void BeforeThreadedGenerateData(void) override { OpticalImageMetadataInterface::Pointer imageMetadataInterface = OpticalImageMetadataInterfaceFactory::CreateIMI( this->GetInput()->GetMetaDataDictionary()); diff --git a/Modules/Radiometry/OpticalCalibration/include/otbImageToReflectanceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbImageToReflectanceImageFilter.h index 6dbc688a7f..8bca51abee 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbImageToReflectanceImageFilter.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbImageToReflectanceImageFilter.h @@ -251,10 +251,10 @@ protected: }; /** Destructor */ - ~ImageToReflectanceImageFilter() ITK_OVERRIDE {} + ~ImageToReflectanceImageFilter() override {} /** Update the functor list and input parameters */ - void BeforeThreadedGenerateData(void) ITK_OVERRIDE + void BeforeThreadedGenerateData(void) override { OpticalImageMetadataInterface::Pointer imageMetadataInterface = OpticalImageMetadataInterfaceFactory::CreateIMI( diff --git a/Modules/Radiometry/OpticalCalibration/include/otbRadianceToImageImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbRadianceToImageImageFilter.h index b52793fb48..b7585dbfff 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbRadianceToImageImageFilter.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbRadianceToImageImageFilter.h @@ -172,10 +172,10 @@ protected: }; /** Destructor */ - ~RadianceToImageImageFilter() ITK_OVERRIDE {} + ~RadianceToImageImageFilter() override {} /** Update the functor list and input parameters */ - void BeforeThreadedGenerateData(void) ITK_OVERRIDE + void BeforeThreadedGenerateData(void) override { OpticalImageMetadataInterface::Pointer imageMetadataInterface = OpticalImageMetadataInterfaceFactory::CreateIMI( this->GetInput()->GetMetaDataDictionary()); diff --git a/Modules/Radiometry/OpticalCalibration/include/otbRadianceToReflectanceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbRadianceToReflectanceImageFilter.h index 9e4d667b5e..07c6de1dac 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbRadianceToReflectanceImageFilter.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbRadianceToReflectanceImageFilter.h @@ -247,10 +247,10 @@ protected: }; /** Destructor */ - ~RadianceToReflectanceImageFilter() ITK_OVERRIDE {} + ~RadianceToReflectanceImageFilter() override {} /** Update the functor list and input parameters */ - void BeforeThreadedGenerateData(void) ITK_OVERRIDE + void BeforeThreadedGenerateData(void) override { OpticalImageMetadataInterface::Pointer imageMetadataInterface = OpticalImageMetadataInterfaceFactory::CreateIMI( this->GetInput()->GetMetaDataDictionary()); diff --git a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToImageImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToImageImageFilter.h index 6050d66777..cba938f79d 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToImageImageFilter.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToImageImageFilter.h @@ -237,10 +237,10 @@ protected: }; /** Destructor */ - ~ReflectanceToImageImageFilter() ITK_OVERRIDE {} + ~ReflectanceToImageImageFilter() override {} /** Update the functor list and input parameters */ - void BeforeThreadedGenerateData(void) ITK_OVERRIDE + void BeforeThreadedGenerateData(void) override { OpticalImageMetadataInterface::Pointer imageMetadataInterface = OpticalImageMetadataInterfaceFactory::CreateIMI( diff --git a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToRadianceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToRadianceImageFilter.h index 69352382fe..64e72fa0cd 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToRadianceImageFilter.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToRadianceImageFilter.h @@ -231,10 +231,10 @@ protected: }; /** Destructor */ - ~ReflectanceToRadianceImageFilter() ITK_OVERRIDE {} + ~ReflectanceToRadianceImageFilter() override {} /** Update the functor list and input parameters */ - void BeforeThreadedGenerateData(void) ITK_OVERRIDE + void BeforeThreadedGenerateData(void) override { OpticalImageMetadataInterface::Pointer imageMetadataInterface = OpticalImageMetadataInterfaceFactory::CreateIMI( this->GetInput()->GetMetaDataDictionary()); diff --git a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToSurfaceReflectanceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToSurfaceReflectanceImageFilter.h index 7fc9c22350..df71735c0f 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToSurfaceReflectanceImageFilter.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToSurfaceReflectanceImageFilter.h @@ -240,18 +240,18 @@ protected: /** Constructor */ ReflectanceToSurfaceReflectanceImageFilter(); /** Destructor */ - ~ReflectanceToSurfaceReflectanceImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~ReflectanceToSurfaceReflectanceImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Initialize the parameters of the functor before the threads run. */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Fill AtmosphericRadiativeTerms using image metadata*/ void UpdateAtmosphericRadiativeTerms(); /** Update Functors parameters */ void UpdateFunctors(); /** If modified, we need to compute the functor parameters again */ - void Modified() const ITK_OVERRIDE; + void Modified() const override; private: diff --git a/Modules/Radiometry/OpticalCalibration/include/otbSpectralSensitivityReader.h b/Modules/Radiometry/OpticalCalibration/include/otbSpectralSensitivityReader.h index f1cb28992a..ddd04f0ef5 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbSpectralSensitivityReader.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbSpectralSensitivityReader.h @@ -79,16 +79,16 @@ public: protected: SpectralSensitivityReader(); - ~SpectralSensitivityReader() ITK_OVERRIDE; + ~SpectralSensitivityReader() override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Find the filename using image metadata */ void FindFileName(); /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Struct use to remove multiple spaces in file */ struct BothAre diff --git a/Modules/Radiometry/OpticalCalibration/include/otbSurfaceAdjacencyEffectCorrectionSchemeFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbSurfaceAdjacencyEffectCorrectionSchemeFilter.h index 435a88c001..8b1290f976 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbSurfaceAdjacencyEffectCorrectionSchemeFilter.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbSurfaceAdjacencyEffectCorrectionSchemeFilter.h @@ -267,11 +267,11 @@ public: protected: SurfaceAdjacencyEffectCorrectionSchemeFilter(); - ~SurfaceAdjacencyEffectCorrectionSchemeFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~SurfaceAdjacencyEffectCorrectionSchemeFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Initialize the parameters of the functor before the threads run. */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Fill AtmosphericRadiativeTerms using image metadata*/ void UpdateAtmosphericRadiativeTerms(); @@ -280,7 +280,7 @@ protected: void UpdateFunctors(); /** If modified, we need to compute the functor parameters again */ - void Modified() const ITK_OVERRIDE; + void Modified() const override; private: diff --git a/Modules/Radiometry/OpticalCalibration/include/otbWavelengthSpectralBands.h b/Modules/Radiometry/OpticalCalibration/include/otbWavelengthSpectralBands.h index 94d5afcb8b..444e811611 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbWavelengthSpectralBands.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbWavelengthSpectralBands.h @@ -63,10 +63,10 @@ protected: /** Constructor */ WavelengthSpectralBands(); /** Destructor */ - ~WavelengthSpectralBands() ITK_OVERRIDE {} + ~WavelengthSpectralBands() override {} /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: WavelengthSpectralBands(const Self &); //purposely not implemented diff --git a/Modules/Radiometry/SARCalibration/include/otbSarBrightnessFunction.h b/Modules/Radiometry/SARCalibration/include/otbSarBrightnessFunction.h index 6284aba4f7..2b4ae21d3f 100644 --- a/Modules/Radiometry/SARCalibration/include/otbSarBrightnessFunction.h +++ b/Modules/Radiometry/SARCalibration/include/otbSarBrightnessFunction.h @@ -85,17 +85,17 @@ public: typedef typename ParametricFunctionType::ConstPointer ParametricFunctionConstPointer; /** Evalulate the function at specified index */ - OutputType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PointType& point) const ITK_OVERRIDE + OutputType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } OutputType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -106,7 +106,7 @@ public: * \warning this method caches BufferedRegion information. * If the BufferedRegion has changed, user must call * SetInputImage again to update cached values. */ - void SetInputImage( const InputImageType * ptr ) ITK_OVERRIDE; + void SetInputImage( const InputImageType * ptr ) override; /** Get/Set the Scale value */ @@ -140,8 +140,8 @@ public: protected: SarBrightnessFunction(); - ~SarBrightnessFunction() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~SarBrightnessFunction() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SarBrightnessFunction(const Self &); //purposely not implemented diff --git a/Modules/Radiometry/SARCalibration/include/otbSarBrightnessToImageFilter.h b/Modules/Radiometry/SARCalibration/include/otbSarBrightnessToImageFilter.h index 7fa55f16c2..f7587b4130 100644 --- a/Modules/Radiometry/SARCalibration/include/otbSarBrightnessToImageFilter.h +++ b/Modules/Radiometry/SARCalibration/include/otbSarBrightnessToImageFilter.h @@ -84,12 +84,12 @@ public: protected: SarBrightnessToImageFilter(); - ~SarBrightnessToImageFilter() ITK_OVERRIDE {} + ~SarBrightnessToImageFilter() override {} /** Update the function list and input parameters*/ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SarBrightnessToImageFilter(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented diff --git a/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.h b/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.h index 9733b50c1d..e65b7e6809 100644 --- a/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.h +++ b/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.h @@ -70,16 +70,16 @@ protected: SarDeburstImageFilter(); // Destructor - virtual ~SarDeburstImageFilter() ITK_OVERRIDE {}; + virtual ~SarDeburstImageFilter() override {}; // Needs to be re-implemented since size of output is modified - virtual void GenerateOutputInformation() ITK_OVERRIDE; + virtual void GenerateOutputInformation() override; // Needs to be re-implemented since size of output is modified - virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; + virtual void GenerateInputRequestedRegion() override; // Actual processing - virtual void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + virtual void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) override; RegionType OutputRegionToInputRegion(const RegionType& outputRegion) const; diff --git a/Modules/Radiometry/SARCalibration/include/otbSarParametricMapFunction.h b/Modules/Radiometry/SARCalibration/include/otbSarParametricMapFunction.h index 0ce4d69bb9..17dd6372fd 100644 --- a/Modules/Radiometry/SARCalibration/include/otbSarParametricMapFunction.h +++ b/Modules/Radiometry/SARCalibration/include/otbSarParametricMapFunction.h @@ -79,10 +79,10 @@ public: typedef typename itk::NumericTraits<InputPixelType>::ScalarRealType RealType; /** Evaluate the function at specific positions */ - RealType Evaluate(const PointType& point) const ITK_OVERRIDE; + RealType Evaluate(const PointType& point) const override; /** Evalulate the function at specified index */ - RealType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE + RealType EvaluateAtIndex(const IndexType& index) const override { PointType point; point[0] = static_cast<typename PointType::ValueType>(index[0]); @@ -91,7 +91,7 @@ public: } RealType EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex) const ITK_OVERRIDE + const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -127,8 +127,8 @@ public: protected: SarParametricMapFunction(); - ~SarParametricMapFunction() ITK_OVERRIDE{} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~SarParametricMapFunction() override{} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: SarParametricMapFunction(const Self &); //purposely not implemented diff --git a/Modules/Radiometry/SARCalibration/include/otbSarRadiometricCalibrationFunction.h b/Modules/Radiometry/SARCalibration/include/otbSarRadiometricCalibrationFunction.h index eb78e1d765..3fb6463376 100644 --- a/Modules/Radiometry/SARCalibration/include/otbSarRadiometricCalibrationFunction.h +++ b/Modules/Radiometry/SARCalibration/include/otbSarRadiometricCalibrationFunction.h @@ -82,17 +82,17 @@ public: typedef typename ParametricFunctionType::ConstPointer ParametricFunctionConstPointer; /** Evalulate the function at specified index */ - OutputType EvaluateAtIndex(const IndexType& index) const ITK_OVERRIDE; + OutputType EvaluateAtIndex(const IndexType& index) const override; /** Evaluate the function at non-integer positions */ - OutputType Evaluate(const PointType& point) const ITK_OVERRIDE + OutputType Evaluate(const PointType& point) const override { IndexType index; this->ConvertPointToNearestIndex(point, index); return this->EvaluateAtIndex(index); } - OutputType EvaluateAtContinuousIndex(const ContinuousIndexType& cindex) const ITK_OVERRIDE + OutputType EvaluateAtContinuousIndex(const ContinuousIndexType& cindex) const override { IndexType index; this->ConvertContinuousIndexToNearestIndex(cindex, index); @@ -103,7 +103,7 @@ public: * \warning this method caches BufferedRegion information. * If the BufferedRegion has changed, user must call * SetInputImage again to update cached values. */ - void SetInputImage( const InputImageType * ptr ) ITK_OVERRIDE; + void SetInputImage( const InputImageType * ptr ) override; /** Get/Set the Scale value */ @@ -172,10 +172,10 @@ protected: SarRadiometricCalibrationFunction(); /** default, empty, virtual dtor */ - ~SarRadiometricCalibrationFunction() ITK_OVERRIDE{} + ~SarRadiometricCalibrationFunction() override{} /** print method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Flags to indicate if these values needs to be applied in calibration*/ diff --git a/Modules/Radiometry/SARCalibration/include/otbSarRadiometricCalibrationToImageFilter.h b/Modules/Radiometry/SARCalibration/include/otbSarRadiometricCalibrationToImageFilter.h index 9910ddf76e..19e49832d8 100644 --- a/Modules/Radiometry/SARCalibration/include/otbSarRadiometricCalibrationToImageFilter.h +++ b/Modules/Radiometry/SARCalibration/include/otbSarRadiometricCalibrationToImageFilter.h @@ -112,13 +112,13 @@ protected: SarRadiometricCalibrationToImageFilter(); /** Empty, default virtual dtor */ - ~SarRadiometricCalibrationToImageFilter() ITK_OVERRIDE {} + ~SarRadiometricCalibrationToImageFilter() override {} /** Generate output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Update the function list and input parameters*/ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; private: diff --git a/Modules/Radiometry/SARCalibration/include/otbTerraSarBrightnessImageFilter.h b/Modules/Radiometry/SARCalibration/include/otbTerraSarBrightnessImageFilter.h index 0fe02d2e35..ca65a82c49 100644 --- a/Modules/Radiometry/SARCalibration/include/otbTerraSarBrightnessImageFilter.h +++ b/Modules/Radiometry/SARCalibration/include/otbTerraSarBrightnessImageFilter.h @@ -143,10 +143,10 @@ protected: /** Constructor */ TerraSarBrightnessImageFilter(){}; /** Destructor */ - ~TerraSarBrightnessImageFilter() ITK_OVERRIDE {} + ~TerraSarBrightnessImageFilter() override {} /** Initialize the functor vector */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; private: TerraSarBrightnessImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Radiometry/Simulation/include/otbAtmosphericEffects.h b/Modules/Radiometry/Simulation/include/otbAtmosphericEffects.h index 1ed84cf295..bf33680f86 100644 --- a/Modules/Radiometry/Simulation/include/otbAtmosphericEffects.h +++ b/Modules/Radiometry/Simulation/include/otbAtmosphericEffects.h @@ -96,7 +96,7 @@ class AtmosphericEffects /** Constructor from a ASCII file */ //AtmosphericEffects( const std::string & filename ); /** Destructor */ - ~AtmosphericEffects() ITK_OVERRIDE {}; + ~AtmosphericEffects() override {}; /** PrintSelf method */ //void PrintSelf(std::ostream& os, itk::Indent indent) const; diff --git a/Modules/Radiometry/Simulation/include/otbImageSimulationMethod.h b/Modules/Radiometry/Simulation/include/otbImageSimulationMethod.h index 999d65aafe..04973ed9a7 100644 --- a/Modules/Radiometry/Simulation/include/otbImageSimulationMethod.h +++ b/Modules/Radiometry/Simulation/include/otbImageSimulationMethod.h @@ -166,13 +166,13 @@ public: protected: ImageSimulationMethod(); - ~ImageSimulationMethod() ITK_OVERRIDE + ~ImageSimulationMethod() override { } - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; // virtual void GenerateData(); - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: ImageSimulationMethod(const Self &); //purposely not implemented diff --git a/Modules/Radiometry/Simulation/include/otbLabelMapToSimulatedImageFilter.h b/Modules/Radiometry/Simulation/include/otbLabelMapToSimulatedImageFilter.h index 2bbed5e700..c8dd54ea89 100644 --- a/Modules/Radiometry/Simulation/include/otbLabelMapToSimulatedImageFilter.h +++ b/Modules/Radiometry/Simulation/include/otbLabelMapToSimulatedImageFilter.h @@ -120,12 +120,12 @@ public: protected: LabelMapToSimulatedImageFilter(); - ~LabelMapToSimulatedImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LabelMapToSimulatedImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void BeforeThreadedGenerateData() ITK_OVERRIDE; - void ThreadedProcessLabelObject( LabelObjectType * labelObject ) ITK_OVERRIDE; - void GenerateOutputInformation() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; + void ThreadedProcessLabelObject( LabelObjectType * labelObject ) override; + void GenerateOutputInformation() override; private: diff --git a/Modules/Radiometry/Simulation/include/otbLabelToProSailParameters.h b/Modules/Radiometry/Simulation/include/otbLabelToProSailParameters.h index a91fbae793..a65f6998e4 100644 --- a/Modules/Radiometry/Simulation/include/otbLabelToProSailParameters.h +++ b/Modules/Radiometry/Simulation/include/otbLabelToProSailParameters.h @@ -86,11 +86,11 @@ public: // virtual const ParametersType & GetStep1Parameters(); //virtual const ParametersType & GetStep2Parameters(); - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; protected: LabelToProSailParameters(); - ~LabelToProSailParameters() ITK_OVERRIDE {} + ~LabelToProSailParameters() override {} private: diff --git a/Modules/Radiometry/Simulation/include/otbLabelToSimulationParametersBase.h b/Modules/Radiometry/Simulation/include/otbLabelToSimulationParametersBase.h index 0b52497155..db03b1bbe2 100644 --- a/Modules/Radiometry/Simulation/include/otbLabelToSimulationParametersBase.h +++ b/Modules/Radiometry/Simulation/include/otbLabelToSimulationParametersBase.h @@ -93,7 +93,7 @@ public: protected: LabelToSimulationParametersBase(){}; - ~LabelToSimulationParametersBase() ITK_OVERRIDE {} + ~LabelToSimulationParametersBase() override {} private: diff --git a/Modules/Radiometry/Simulation/include/otbLeafParameters.h b/Modules/Radiometry/Simulation/include/otbLeafParameters.h index 1ed4e20a10..ed7af69394 100644 --- a/Modules/Radiometry/Simulation/include/otbLeafParameters.h +++ b/Modules/Radiometry/Simulation/include/otbLeafParameters.h @@ -78,9 +78,9 @@ class OTBSimulation_EXPORT LeafParameters : public itk::DataObject /** Constructor */ LeafParameters(); /** Destructor */ - ~LeafParameters() ITK_OVERRIDE; + ~LeafParameters() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LeafParameters(const Self&); //purposely not implemented diff --git a/Modules/Radiometry/Simulation/include/otbProSailParameters.h b/Modules/Radiometry/Simulation/include/otbProSailParameters.h index c2264c104c..5790a66ed3 100644 --- a/Modules/Radiometry/Simulation/include/otbProSailParameters.h +++ b/Modules/Radiometry/Simulation/include/otbProSailParameters.h @@ -115,7 +115,7 @@ class ITK_EXPORT ProSailParameters : public itk::DataObject /** Destructor */ virtual ~ProSailParameters() {}; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: diff --git a/Modules/Radiometry/Simulation/include/otbProspectModel.h b/Modules/Radiometry/Simulation/include/otbProspectModel.h index 7b7468068a..668659c09d 100644 --- a/Modules/Radiometry/Simulation/include/otbProspectModel.h +++ b/Modules/Radiometry/Simulation/include/otbProspectModel.h @@ -66,21 +66,21 @@ class OTBSimulation_EXPORT ProspectModel : public SimulationStep1Base LeafParametersType * GetInput(); /** GenerateData */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Get Output reflectance/transmittance*/ - SpectralResponseType * GetReflectance() ITK_OVERRIDE; - SpectralResponseType * GetTransmittance() ITK_OVERRIDE; + SpectralResponseType * GetReflectance() override; + SpectralResponseType * GetTransmittance() override; protected: /** Constructor */ ProspectModel(); /** Destructor */ - ~ProspectModel() ITK_OVERRIDE; + ~ProspectModel() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType) override; using Superclass::MakeOutput; /** Compute Transmission of isotropic radiation across an interface between two dielectrics*/ diff --git a/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.h b/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.h index d9a944bf7d..4a97b1ec99 100644 --- a/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.h +++ b/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.h @@ -113,7 +113,7 @@ public: virtual bool Clear(); /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * \param PrecisionType @@ -135,7 +135,7 @@ protected: /** Constructor from a ASCII file */ //ReduceSpectralResponse( const std::string & filename ); /** Destructor */ - ~ReduceSpectralResponse() ITK_OVERRIDE + ~ReduceSpectralResponse() override { } ; diff --git a/Modules/Radiometry/Simulation/include/otbReduceSpectralResponseClassifierRAndNIR.h b/Modules/Radiometry/Simulation/include/otbReduceSpectralResponseClassifierRAndNIR.h index 7050b8c0a5..c8e334ae5e 100644 --- a/Modules/Radiometry/Simulation/include/otbReduceSpectralResponseClassifierRAndNIR.h +++ b/Modules/Radiometry/Simulation/include/otbReduceSpectralResponseClassifierRAndNIR.h @@ -109,7 +109,7 @@ namespace otb /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** @@ -125,7 +125,7 @@ namespace otb /** Constructor from a ASCII file */ //ReduceSpectralResponseClassifierRAndNIR( const std::string & filename ); /** Destructor */ - ~ReduceSpectralResponseClassifierRAndNIR() ITK_OVERRIDE {}; + ~ReduceSpectralResponseClassifierRAndNIR() override {}; /** PrintSelf method */ //void PrintSelf(std::ostream& os, itk::Indent indent) const; diff --git a/Modules/Radiometry/Simulation/include/otbSatelliteRSR.h b/Modules/Radiometry/Simulation/include/otbSatelliteRSR.h index 4cc13e1598..2fde7522df 100644 --- a/Modules/Radiometry/Simulation/include/otbSatelliteRSR.h +++ b/Modules/Radiometry/Simulation/include/otbSatelliteRSR.h @@ -127,7 +127,7 @@ public: inline ValuePrecisionType operator()(const PrecisionType & lambda, const unsigned int numBand); /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** get vector of RSR */ RSRVectorType & GetRSR() @@ -147,7 +147,7 @@ protected: /** Constructor from a ASCII file */ //SatelliteRSR( const std::string & filename ); /** Destructor */ - ~SatelliteRSR() ITK_OVERRIDE + ~SatelliteRSR() override { } ; diff --git a/Modules/Radiometry/Simulation/include/otbSimulationStep1Base.h b/Modules/Radiometry/Simulation/include/otbSimulationStep1Base.h index 9bb396188b..ecf5472ab0 100644 --- a/Modules/Radiometry/Simulation/include/otbSimulationStep1Base.h +++ b/Modules/Radiometry/Simulation/include/otbSimulationStep1Base.h @@ -69,7 +69,7 @@ public: protected: SimulationStep1Base(){}; - ~SimulationStep1Base() ITK_OVERRIDE {} + ~SimulationStep1Base() override {} private: diff --git a/Modules/Radiometry/Simulation/include/otbSimulationStep2Base.h b/Modules/Radiometry/Simulation/include/otbSimulationStep2Base.h index 10db201a36..5aed410ef7 100644 --- a/Modules/Radiometry/Simulation/include/otbSimulationStep2Base.h +++ b/Modules/Radiometry/Simulation/include/otbSimulationStep2Base.h @@ -70,7 +70,7 @@ protected: { } ; - ~SimulationStep2Base() ITK_OVERRIDE + ~SimulationStep2Base() override { } diff --git a/Modules/Radiometry/Simulation/include/otbSpatialisationFilter.h b/Modules/Radiometry/Simulation/include/otbSpatialisationFilter.h index 3009be20fe..7e5b72aa98 100644 --- a/Modules/Radiometry/Simulation/include/otbSpatialisationFilter.h +++ b/Modules/Radiometry/Simulation/include/otbSpatialisationFilter.h @@ -112,12 +112,12 @@ public: protected: SpatialisationFilter(); - ~SpatialisationFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~SpatialisationFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; virtual void ProcessObject(unsigned int obj); - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; private: SpatialisationFilter(const Self &); //purposely not implemented diff --git a/Modules/Radiometry/Simulation/include/otbSpectralResponse.h b/Modules/Radiometry/Simulation/include/otbSpectralResponse.h index 5ccd1fa935..789924e4f5 100644 --- a/Modules/Radiometry/Simulation/include/otbSpectralResponse.h +++ b/Modules/Radiometry/Simulation/include/otbSpectralResponse.h @@ -104,7 +104,7 @@ public: void Load(const std::string & filename, ValuePrecisionType coefNormalization = 1.0); /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** get vector of spectral responses */ VectorPairType & GetResponse() @@ -163,7 +163,7 @@ protected: /** Constructor from a ASCII file */ //SpectralResponse( const std::string & filename ); /** Destructor */ - ~SpectralResponse() ITK_OVERRIDE + ~SpectralResponse() override { } ; diff --git a/Modules/Radiometry/Simulation/include/otbSurfaceReflectanceToReflectanceFilter.h b/Modules/Radiometry/Simulation/include/otbSurfaceReflectanceToReflectanceFilter.h index c07fbd4c97..840f880dbe 100644 --- a/Modules/Radiometry/Simulation/include/otbSurfaceReflectanceToReflectanceFilter.h +++ b/Modules/Radiometry/Simulation/include/otbSurfaceReflectanceToReflectanceFilter.h @@ -263,18 +263,18 @@ protected: /** Constructor */ SurfaceReflectanceToReflectanceFilter(); /** Destructor */ - ~SurfaceReflectanceToReflectanceFilter() ITK_OVERRIDE {}; + ~SurfaceReflectanceToReflectanceFilter() override {}; /** Initialize the functor vector */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Fill AtmosphericRadiativeTerms using image metadata*/ void UpdateAtmosphericRadiativeTerms(); /** Update Functors parameters */ void UpdateFunctors(); /** If modified, we need to compute the functor parameters again */ - void Modified() const ITK_OVERRIDE; + void Modified() const override; private: diff --git a/Modules/Registration/DisparityMap/include/otbDisparityMapEstimationMethod.h b/Modules/Registration/DisparityMap/include/otbDisparityMapEstimationMethod.h index 0ace44f23c..56a89eeccb 100644 --- a/Modules/Registration/DisparityMap/include/otbDisparityMapEstimationMethod.h +++ b/Modules/Registration/DisparityMap/include/otbDisparityMapEstimationMethod.h @@ -184,15 +184,15 @@ protected: /** * Destructor. */ - ~DisparityMapEstimationMethod() ITK_OVERRIDE; + ~DisparityMapEstimationMethod() override; /** * Standard PrintSelf method. */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Main computation method. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: DisparityMapEstimationMethod(const Self &); //purposely not implemented diff --git a/Modules/Registration/DisparityMap/include/otbDisparityMapMedianFilter.h b/Modules/Registration/DisparityMap/include/otbDisparityMapMedianFilter.h index 3c8b7d22e7..1031f95bbf 100644 --- a/Modules/Registration/DisparityMap/include/otbDisparityMapMedianFilter.h +++ b/Modules/Registration/DisparityMap/include/otbDisparityMapMedianFilter.h @@ -151,8 +151,8 @@ public: protected: DisparityMapMedianFilter(); - ~DisparityMapMedianFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~DisparityMapMedianFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** MedianImageFilter needs a larger input requested region than * the output requested region. As such, MedianImageFilter needs @@ -160,13 +160,13 @@ protected: * in order to inform the pipeline execution model. * * \sa ImageToImageFilter::GenerateInputRequestedRegion() */ - void GenerateInputRequestedRegion() throw(itk::InvalidRequestedRegionError) ITK_OVERRIDE; + void GenerateInputRequestedRegion() throw(itk::InvalidRequestedRegionError) override; /** Generate output information */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** apply median filter */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: DisparityMapMedianFilter(const Self&); //purposely not implemented diff --git a/Modules/Registration/DisparityMap/include/otbDisparityMapTo3DFilter.h b/Modules/Registration/DisparityMap/include/otbDisparityMapTo3DFilter.h index eb505e58dd..1558f7592f 100644 --- a/Modules/Registration/DisparityMap/include/otbDisparityMapTo3DFilter.h +++ b/Modules/Registration/DisparityMap/include/otbDisparityMapTo3DFilter.h @@ -144,26 +144,26 @@ protected: DisparityMapTo3DFilter(); /** Destructor */ - ~DisparityMapTo3DFilter() ITK_OVERRIDE; + ~DisparityMapTo3DFilter() override; /** Generate output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Before threaded generate data */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Threaded generate data */ - void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) override; /** Override VerifyInputInformation() since this filter's inputs do * not need to occupy the same physical space. * * \sa ProcessObject::VerifyInputInformation */ - void VerifyInputInformation() ITK_OVERRIDE {} + void VerifyInputInformation() override {} private: diff --git a/Modules/Registration/DisparityMap/include/otbDisparityMapToDEMFilter.h b/Modules/Registration/DisparityMap/include/otbDisparityMapToDEMFilter.h index 0e3bb5905d..7ed891c1f2 100644 --- a/Modules/Registration/DisparityMap/include/otbDisparityMapToDEMFilter.h +++ b/Modules/Registration/DisparityMap/include/otbDisparityMapToDEMFilter.h @@ -149,29 +149,29 @@ protected: DisparityMapToDEMFilter(); /** Destructor */ - ~DisparityMapToDEMFilter() ITK_OVERRIDE; + ~DisparityMapToDEMFilter() override; /** Generate output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Before threaded generate data */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Threaded generate data */ - void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) override; /** After threaded generate data : sum up temporary DEMs */ - void AfterThreadedGenerateData() ITK_OVERRIDE; + void AfterThreadedGenerateData() override; /** Override VerifyInputInformation() since this filter's inputs do * not need to occupy the same physical space. * * \sa ProcessObject::VerifyInputInformation */ - void VerifyInputInformation() ITK_OVERRIDE {} + void VerifyInputInformation() override {} private: diff --git a/Modules/Registration/DisparityMap/include/otbDisparityTranslateFilter.h b/Modules/Registration/DisparityMap/include/otbDisparityTranslateFilter.h index fb811e230f..92133ed381 100644 --- a/Modules/Registration/DisparityMap/include/otbDisparityTranslateFilter.h +++ b/Modules/Registration/DisparityMap/include/otbDisparityTranslateFilter.h @@ -119,23 +119,23 @@ protected: DisparityTranslateFilter(); /** Destructor */ - ~DisparityTranslateFilter() ITK_OVERRIDE{}; + ~DisparityTranslateFilter() override{}; /** Generate output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Threaded generate data */ - void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) override; /** Override VerifyInputInformation() since this filter's inputs do * not need to occupy the same physical space. * * \sa ProcessObject::VerifyInputInformation */ - void VerifyInputInformation() ITK_OVERRIDE {} + void VerifyInputInformation() override {} private: diff --git a/Modules/Registration/DisparityMap/include/otbFineRegistrationImageFilter.h b/Modules/Registration/DisparityMap/include/otbFineRegistrationImageFilter.h index 18bd032b64..5d909dd279 100644 --- a/Modules/Registration/DisparityMap/include/otbFineRegistrationImageFilter.h +++ b/Modules/Registration/DisparityMap/include/otbFineRegistrationImageFilter.h @@ -189,16 +189,16 @@ protected: /** Constructor */ FineRegistrationImageFilter(); /** Destructor */ - ~FineRegistrationImageFilter() ITK_OVERRIDE {}; + ~FineRegistrationImageFilter() override {}; /** Threaded generate data */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Generate the input requested regions */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** Generate output information */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; private: FineRegistrationImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Registration/DisparityMap/include/otbMultiDisparityMapTo3DFilter.h b/Modules/Registration/DisparityMap/include/otbMultiDisparityMapTo3DFilter.h index c6cdc5f211..94a28101d5 100644 --- a/Modules/Registration/DisparityMap/include/otbMultiDisparityMapTo3DFilter.h +++ b/Modules/Registration/DisparityMap/include/otbMultiDisparityMapTo3DFilter.h @@ -157,19 +157,19 @@ protected: MultiDisparityMapTo3DFilter(); /** Destructor */ - ~MultiDisparityMapTo3DFilter() ITK_OVERRIDE; + ~MultiDisparityMapTo3DFilter() override; /** Generate output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Before threaded generate data */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Threaded generate data */ - void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) override; private: MultiDisparityMapTo3DFilter(const Self&); //purposely not implemented diff --git a/Modules/Registration/DisparityMap/include/otbNCCRegistrationFilter.h b/Modules/Registration/DisparityMap/include/otbNCCRegistrationFilter.h index c33bb17914..b7b7a72436 100644 --- a/Modules/Registration/DisparityMap/include/otbNCCRegistrationFilter.h +++ b/Modules/Registration/DisparityMap/include/otbNCCRegistrationFilter.h @@ -137,18 +137,18 @@ public: protected: NCCRegistrationFilter(); - ~NCCRegistrationFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~NCCRegistrationFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Initialize the state of filter and equation before each iteration. */ - void InitializeIteration() ITK_OVERRIDE; + void InitializeIteration() override; /** Apply update. */ using Superclass::ApplyUpdate; virtual void ApplyUpdate(TimeStepType dt); /** Update the Input requested region. */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; private: NCCRegistrationFilter(const Self &); //purposely not implemented diff --git a/Modules/Registration/DisparityMap/include/otbNCCRegistrationFunction.h b/Modules/Registration/DisparityMap/include/otbNCCRegistrationFunction.h index 352ea6d16c..ac5580ab6f 100644 --- a/Modules/Registration/DisparityMap/include/otbNCCRegistrationFunction.h +++ b/Modules/Registration/DisparityMap/include/otbNCCRegistrationFunction.h @@ -120,38 +120,38 @@ public: } /** This class uses a constant timestep of 1. */ - TimeStepType ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const ITK_OVERRIDE + TimeStepType ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const override { return m_TimeStep; } /** Return a pointer to a global data structure that is passed to * this object from the solver at each calculation. */ - void *GetGlobalDataPointer() const ITK_OVERRIDE + void *GetGlobalDataPointer() const override { GlobalDataStruct *global = new GlobalDataStruct(); return global; } /** Release memory for global data structure. */ - void ReleaseGlobalDataPointer(void *GlobalData) const ITK_OVERRIDE + void ReleaseGlobalDataPointer(void *GlobalData) const override { delete (GlobalDataStruct *) GlobalData; } /** Set the object's state before each iteration. */ - void InitializeIteration() ITK_OVERRIDE; + void InitializeIteration() override; /** This method is called by a finite difference solver image filter at * each pixel that does not lie on a data set boundary */ PixelType ComputeUpdate(const NeighborhoodType& neighborhood, void *globalData, - const FloatOffsetType& offset = FloatOffsetType(0.0)) ITK_OVERRIDE; + const FloatOffsetType& offset = FloatOffsetType(0.0)) override; protected: NCCRegistrationFunction(); - ~NCCRegistrationFunction() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~NCCRegistrationFunction() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** FixedImage image neighborhood iterator type. */ typedef itk::ConstNeighborhoodIterator<FixedImageType> FixedImageNeighborhoodIteratorType; diff --git a/Modules/Registration/DisparityMap/include/otbPixelWiseBlockMatchingImageFilter.h b/Modules/Registration/DisparityMap/include/otbPixelWiseBlockMatchingImageFilter.h index 824e65da5d..496ee3a423 100644 --- a/Modules/Registration/DisparityMap/include/otbPixelWiseBlockMatchingImageFilter.h +++ b/Modules/Registration/DisparityMap/include/otbPixelWiseBlockMatchingImageFilter.h @@ -418,10 +418,10 @@ public: return m_Functor; } - /** Set initial horizontal disparity field (optional, ITK_OVERRIDE m_InitHorizontalDisparity) */ + /** Set initial horizontal disparity field (optional, override m_InitHorizontalDisparity) */ void SetHorizontalDisparityInput( const TOutputDisparityImage * hfield); - /** Set initial vertical disparity field (optional, ITK_OVERRIDE m_InitVerticalDisparity) */ + /** Set initial vertical disparity field (optional, override m_InitVerticalDisparity) */ void SetVerticalDisparityInput( const TOutputDisparityImage * vfield); /** Get the initial disparity fields */ @@ -447,19 +447,19 @@ protected: PixelWiseBlockMatchingImageFilter(); /** Destructor */ - ~PixelWiseBlockMatchingImageFilter() ITK_OVERRIDE; + ~PixelWiseBlockMatchingImageFilter() override; /** Generate output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Before threaded generate data */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Threaded generate data */ - void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) override; private: PixelWiseBlockMatchingImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Registration/DisparityMap/include/otbSubPixelDisparityImageFilter.h b/Modules/Registration/DisparityMap/include/otbSubPixelDisparityImageFilter.h index 316930a2aa..c5489f78ea 100644 --- a/Modules/Registration/DisparityMap/include/otbSubPixelDisparityImageFilter.h +++ b/Modules/Registration/DisparityMap/include/otbSubPixelDisparityImageFilter.h @@ -210,29 +210,29 @@ protected: SubPixelDisparityImageFilter(); /** Destructor */ - ~SubPixelDisparityImageFilter() ITK_OVERRIDE; + ~SubPixelDisparityImageFilter() override; /** \brief Verify that the input images are compatible * * This method needs to be re-implemented from ImageToImageFilter since * the initial images and disparity maps may not have the same size */ - void VerifyInputInformation() ITK_OVERRIDE; + void VerifyInputInformation() override; /** Generate output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Before threaded generate data */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Threaded generate data */ - void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) override; /** After threaded generate data */ - void AfterThreadedGenerateData() ITK_OVERRIDE; + void AfterThreadedGenerateData() override; private: SubPixelDisparityImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Registration/DisplacementField/include/otbBSplinesInterpolateDisplacementFieldGenerator.h b/Modules/Registration/DisplacementField/include/otbBSplinesInterpolateDisplacementFieldGenerator.h index 8f89e63155..93d440ead4 100644 --- a/Modules/Registration/DisplacementField/include/otbBSplinesInterpolateDisplacementFieldGenerator.h +++ b/Modules/Registration/DisplacementField/include/otbBSplinesInterpolateDisplacementFieldGenerator.h @@ -66,11 +66,11 @@ protected: /** Constructor */ BSplinesInterpolateDisplacementFieldGenerator() {}; /** Destructor */ - ~BSplinesInterpolateDisplacementFieldGenerator() ITK_OVERRIDE {} + ~BSplinesInterpolateDisplacementFieldGenerator() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: BSplinesInterpolateDisplacementFieldGenerator(const Self &); //purposely not implemented diff --git a/Modules/Registration/DisplacementField/include/otbBSplinesInterpolateTransformDisplacementFieldGenerator.h b/Modules/Registration/DisplacementField/include/otbBSplinesInterpolateTransformDisplacementFieldGenerator.h index 4af2d2a82e..8ead3ebe92 100644 --- a/Modules/Registration/DisplacementField/include/otbBSplinesInterpolateTransformDisplacementFieldGenerator.h +++ b/Modules/Registration/DisplacementField/include/otbBSplinesInterpolateTransformDisplacementFieldGenerator.h @@ -106,13 +106,13 @@ protected: /** Constructor */ BSplinesInterpolateTransformDisplacementFieldGenerator(); /** Destructor */ - ~BSplinesInterpolateTransformDisplacementFieldGenerator() ITK_OVERRIDE {} + ~BSplinesInterpolateTransformDisplacementFieldGenerator() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** * Test whether a parameter is angular or not. diff --git a/Modules/Registration/DisplacementField/include/otbNNearestPointsLinearInterpolateDisplacementFieldGenerator.h b/Modules/Registration/DisplacementField/include/otbNNearestPointsLinearInterpolateDisplacementFieldGenerator.h index 341499979f..0aaa57fcca 100644 --- a/Modules/Registration/DisplacementField/include/otbNNearestPointsLinearInterpolateDisplacementFieldGenerator.h +++ b/Modules/Registration/DisplacementField/include/otbNNearestPointsLinearInterpolateDisplacementFieldGenerator.h @@ -67,11 +67,11 @@ protected: /** Constructor */ NNearestPointsLinearInterpolateDisplacementFieldGenerator() {}; /** Destructor */ - ~NNearestPointsLinearInterpolateDisplacementFieldGenerator() ITK_OVERRIDE {} + ~NNearestPointsLinearInterpolateDisplacementFieldGenerator() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: NNearestPointsLinearInterpolateDisplacementFieldGenerator(const Self &); //purposely not implemented diff --git a/Modules/Registration/DisplacementField/include/otbNNearestTransformsLinearInterpolateDisplacementFieldGenerator.h b/Modules/Registration/DisplacementField/include/otbNNearestTransformsLinearInterpolateDisplacementFieldGenerator.h index e83a367561..a3f307fb40 100644 --- a/Modules/Registration/DisplacementField/include/otbNNearestTransformsLinearInterpolateDisplacementFieldGenerator.h +++ b/Modules/Registration/DisplacementField/include/otbNNearestTransformsLinearInterpolateDisplacementFieldGenerator.h @@ -74,11 +74,11 @@ protected: /** Constructor */ NNearestTransformsLinearInterpolateDisplacementFieldGenerator() {}; /** Destructor */ - ~NNearestTransformsLinearInterpolateDisplacementFieldGenerator() ITK_OVERRIDE {} + ~NNearestTransformsLinearInterpolateDisplacementFieldGenerator() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: NNearestTransformsLinearInterpolateDisplacementFieldGenerator(const Self &); //purposely not implemented diff --git a/Modules/Registration/DisplacementField/include/otbNearestPointDisplacementFieldGenerator.h b/Modules/Registration/DisplacementField/include/otbNearestPointDisplacementFieldGenerator.h index cfe80219b1..b52405d6c1 100644 --- a/Modules/Registration/DisplacementField/include/otbNearestPointDisplacementFieldGenerator.h +++ b/Modules/Registration/DisplacementField/include/otbNearestPointDisplacementFieldGenerator.h @@ -64,11 +64,11 @@ protected: /** Constructor */ NearestPointDisplacementFieldGenerator() {}; /** Destructor */ - ~NearestPointDisplacementFieldGenerator() ITK_OVERRIDE {} + ~NearestPointDisplacementFieldGenerator() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: NearestPointDisplacementFieldGenerator(const Self &); //purposely not implemented diff --git a/Modules/Registration/DisplacementField/include/otbNearestTransformDisplacementFieldGenerator.h b/Modules/Registration/DisplacementField/include/otbNearestTransformDisplacementFieldGenerator.h index 0ddae1eb84..cda5218322 100644 --- a/Modules/Registration/DisplacementField/include/otbNearestTransformDisplacementFieldGenerator.h +++ b/Modules/Registration/DisplacementField/include/otbNearestTransformDisplacementFieldGenerator.h @@ -67,11 +67,11 @@ protected: /** Constructor */ NearestTransformDisplacementFieldGenerator() {}; /** Destructor */ - ~NearestTransformDisplacementFieldGenerator() ITK_OVERRIDE {} + ~NearestTransformDisplacementFieldGenerator() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: NearestTransformDisplacementFieldGenerator(const Self &); //purposely not implemented diff --git a/Modules/Registration/DisplacementField/include/otbPointSetToDisplacementFieldGenerator.h b/Modules/Registration/DisplacementField/include/otbPointSetToDisplacementFieldGenerator.h index 77028b48b4..bbd237cb10 100644 --- a/Modules/Registration/DisplacementField/include/otbPointSetToDisplacementFieldGenerator.h +++ b/Modules/Registration/DisplacementField/include/otbPointSetToDisplacementFieldGenerator.h @@ -125,11 +125,11 @@ protected: /** Constructor */ PointSetToDisplacementFieldGenerator(); /** Destructor */ - ~PointSetToDisplacementFieldGenerator() ITK_OVERRIDE {} + ~PointSetToDisplacementFieldGenerator() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Generate output information */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** * Generate the n nearest valid point in point set, where a valid point has a sufficient metric value. * \param index The index of the pixel to compute. diff --git a/Modules/Registration/DisplacementField/include/otbPointSetWithTransformToDisplacementFieldGenerator.h b/Modules/Registration/DisplacementField/include/otbPointSetWithTransformToDisplacementFieldGenerator.h index 998c1f57c2..7618deceb6 100644 --- a/Modules/Registration/DisplacementField/include/otbPointSetWithTransformToDisplacementFieldGenerator.h +++ b/Modules/Registration/DisplacementField/include/otbPointSetWithTransformToDisplacementFieldGenerator.h @@ -84,9 +84,9 @@ protected: /** Constructor */ PointSetWithTransformToDisplacementFieldGenerator(); /** Destructor */ - ~PointSetWithTransformToDisplacementFieldGenerator() ITK_OVERRIDE {} + ~PointSetWithTransformToDisplacementFieldGenerator() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: PointSetWithTransformToDisplacementFieldGenerator(const Self &); //purposely not implemented diff --git a/Modules/Registration/Stereo/include/otbAdhesionCorrectionFilter.h b/Modules/Registration/Stereo/include/otbAdhesionCorrectionFilter.h index 1f3e48d177..9e6542dfd2 100644 --- a/Modules/Registration/Stereo/include/otbAdhesionCorrectionFilter.h +++ b/Modules/Registration/Stereo/include/otbAdhesionCorrectionFilter.h @@ -151,16 +151,16 @@ protected: /** Constructor */ AdhesionCorrectionFilter(); /** Destructor */ - ~AdhesionCorrectionFilter() ITK_OVERRIDE {}; + ~AdhesionCorrectionFilter() override {}; /** Threaded generate data */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Generate the input requested regions */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** Generate output information */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; private: AdhesionCorrectionFilter(const Self&); //purposely not implemented diff --git a/Modules/Registration/Stereo/include/otbBijectionCoherencyFilter.h b/Modules/Registration/Stereo/include/otbBijectionCoherencyFilter.h index a9f620fbc2..07cd1703d7 100644 --- a/Modules/Registration/Stereo/include/otbBijectionCoherencyFilter.h +++ b/Modules/Registration/Stereo/include/otbBijectionCoherencyFilter.h @@ -114,16 +114,16 @@ protected: BijectionCoherencyFilter(); /** Destructor */ - ~BijectionCoherencyFilter() ITK_OVERRIDE{}; + ~BijectionCoherencyFilter() override{}; /** Generate output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Threaded generate data */ - void ThreadedGenerateData(const OutputRegionType & outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const OutputRegionType & outputRegionForThread, itk::ThreadIdType threadId) override; private: BijectionCoherencyFilter(const Self&); //purposely not implemented diff --git a/Modules/Registration/Stereo/include/otbLineOfSightOptimizer.h b/Modules/Registration/Stereo/include/otbLineOfSightOptimizer.h index 419381bc19..c7e96cbb10 100644 --- a/Modules/Registration/Stereo/include/otbLineOfSightOptimizer.h +++ b/Modules/Registration/Stereo/include/otbLineOfSightOptimizer.h @@ -87,7 +87,7 @@ protected: LineOfSightOptimizer(); /** Destructor */ - ~LineOfSightOptimizer() ITK_OVERRIDE{}; + ~LineOfSightOptimizer() override{}; private: diff --git a/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.h b/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.h index 21e8287b64..6dc2c0e1a9 100644 --- a/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.h +++ b/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.h @@ -232,29 +232,29 @@ protected: Multi3DMapToDEMFilter(); /** Destructor */ - ~Multi3DMapToDEMFilter() ITK_OVERRIDE; + ~Multi3DMapToDEMFilter() override; /** Generate output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Before threaded generate data */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Threaded generate data */ - void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) override; /** After threaded generate data */ - void AfterThreadedGenerateData() ITK_OVERRIDE; + void AfterThreadedGenerateData() override; /** Override VerifyInputInformation() since this filter's inputs do * not need to occupy the same physical space. * * \sa ProcessObject::VerifyInputInformation */ - void VerifyInputInformation() ITK_OVERRIDE {} + void VerifyInputInformation() override {} private: diff --git a/Modules/Registration/Stereo/include/otbStereoSensorModelToElevationMapFilter.h b/Modules/Registration/Stereo/include/otbStereoSensorModelToElevationMapFilter.h index 8a5137c4f6..40d1423006 100644 --- a/Modules/Registration/Stereo/include/otbStereoSensorModelToElevationMapFilter.h +++ b/Modules/Registration/Stereo/include/otbStereoSensorModelToElevationMapFilter.h @@ -190,24 +190,24 @@ protected: StereoSensorModelToElevationFilter(); /** Destructor */ - ~StereoSensorModelToElevationFilter() ITK_OVERRIDE; + ~StereoSensorModelToElevationFilter() override; /** Threaded generate data */ void ThreadedGenerateData(const OutputRegionType& outputRegionForThread, - itk::ThreadIdType threadId) ITK_OVERRIDE; + itk::ThreadIdType threadId) override; /** Generate the input requested regions */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** Things to do before the threaded generate-data */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Override VerifyInputInformation() since this filter's inputs do * not need to occupy the same physical space. * * \sa ProcessObject::VerifyInputInformation */ - void VerifyInputInformation() ITK_OVERRIDE {} + void VerifyInputInformation() override {} private: diff --git a/Modules/Registration/Stereo/include/otbStereorectificationDisplacementFieldSource.h b/Modules/Registration/Stereo/include/otbStereorectificationDisplacementFieldSource.h index 8fe1adc44f..efd6ed38cf 100644 --- a/Modules/Registration/Stereo/include/otbStereorectificationDisplacementFieldSource.h +++ b/Modules/Registration/Stereo/include/otbStereorectificationDisplacementFieldSource.h @@ -166,19 +166,19 @@ protected: StereorectificationDisplacementFieldSource( void ); /** Destructor */ - ~StereorectificationDisplacementFieldSource( void ) ITK_OVERRIDE {}; + ~StereorectificationDisplacementFieldSource( void ) override {}; /** Generate output images information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Enlarge output requested region (no streaming) */ - void EnlargeOutputRequestedRegion(itk::DataObject * itkNotUsed(output)) ITK_OVERRIDE; + void EnlargeOutputRequestedRegion(itk::DataObject * itkNotUsed(output)) override; /** Compute the deformation field */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf( std::ostream& os, itk::Indent indent ) const ITK_OVERRIDE; + void PrintSelf( std::ostream& os, itk::Indent indent ) const override; private: StereorectificationDisplacementFieldSource( const Self& ); // purposely diff --git a/Modules/Segmentation/CCOBIA/include/otbLabelObjectOpeningMuParserFilter.h b/Modules/Segmentation/CCOBIA/include/otbLabelObjectOpeningMuParserFilter.h index 867b94ec40..b5bf076015 100644 --- a/Modules/Segmentation/CCOBIA/include/otbLabelObjectOpeningMuParserFilter.h +++ b/Modules/Segmentation/CCOBIA/include/otbLabelObjectOpeningMuParserFilter.h @@ -111,18 +111,18 @@ public: /** return list of Mu Parser functions**/ Parser::FunctionMapType GetFunList() const; - void AllocateOutputs() ITK_OVERRIDE; + void AllocateOutputs() override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; - void EnlargeOutputRequestedRegion(itk::DataObject *) ITK_OVERRIDE {} + void EnlargeOutputRequestedRegion(itk::DataObject *) override {} - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; protected: LabelObjectOpeningMuParserFilter(); - ~LabelObjectOpeningMuParserFilter() ITK_OVERRIDE; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LabelObjectOpeningMuParserFilter() override; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: LabelObjectOpeningMuParserFilter(const Self&); //purposely not implemented diff --git a/Modules/Segmentation/CCOBIA/include/otbStreamingConnectedComponentSegmentationOBIAToVectorDataFilter.h b/Modules/Segmentation/CCOBIA/include/otbStreamingConnectedComponentSegmentationOBIAToVectorDataFilter.h index a33dd9d86c..047c0efafc 100644 --- a/Modules/Segmentation/CCOBIA/include/otbStreamingConnectedComponentSegmentationOBIAToVectorDataFilter.h +++ b/Modules/Segmentation/CCOBIA/include/otbStreamingConnectedComponentSegmentationOBIAToVectorDataFilter.h @@ -181,9 +181,9 @@ public: protected: PersistentConnectedComponentSegmentationOBIAToVectorDataFilter(); - ~PersistentConnectedComponentSegmentationOBIAToVectorDataFilter() ITK_OVERRIDE; + ~PersistentConnectedComponentSegmentationOBIAToVectorDataFilter() override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; private: ObjectSizeType m_MinimumObjectSize; @@ -199,7 +199,7 @@ private: bool m_ComputeFeretDiameter; bool m_ComputePerimeter; - VectorDataPointerType ProcessTile() ITK_OVERRIDE; + VectorDataPointerType ProcessTile() override; }; /** \class StreamingConnectedComponentSegmentationOBIAToVectorDataFilter diff --git a/Modules/Segmentation/Conversion/include/otbLabelImageRegionMergingFilter.h b/Modules/Segmentation/Conversion/include/otbLabelImageRegionMergingFilter.h index b3781f7237..0664c20e27 100644 --- a/Modules/Segmentation/Conversion/include/otbLabelImageRegionMergingFilter.h +++ b/Modules/Segmentation/Conversion/include/otbLabelImageRegionMergingFilter.h @@ -115,20 +115,20 @@ public: InputSpectralImageType * GetInputSpectralImage(); protected: - void EnlargeOutputRequestedRegion( itk::DataObject *output ) ITK_OVERRIDE; + void EnlargeOutputRequestedRegion( itk::DataObject *output ) override; - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Constructor */ LabelImageRegionMergingFilter(); /** Destructor */ - ~LabelImageRegionMergingFilter() ITK_OVERRIDE; + ~LabelImageRegionMergingFilter() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Method to build a map of adjacent regions */ RegionAdjacencyMapType LabelImageToRegionAdjacencyMap(typename OutputLabelImageType::Pointer inputLabelImage); diff --git a/Modules/Segmentation/Conversion/include/otbLabelImageRegionPruningFilter.h b/Modules/Segmentation/Conversion/include/otbLabelImageRegionPruningFilter.h index b881185a76..932d64309a 100644 --- a/Modules/Segmentation/Conversion/include/otbLabelImageRegionPruningFilter.h +++ b/Modules/Segmentation/Conversion/include/otbLabelImageRegionPruningFilter.h @@ -114,20 +114,20 @@ public: InputSpectralImageType * GetInputSpectralImage(); protected: - void EnlargeOutputRequestedRegion( itk::DataObject *output ) ITK_OVERRIDE; + void EnlargeOutputRequestedRegion( itk::DataObject *output ) override; - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Constructor */ LabelImageRegionPruningFilter(); /** Destructor */ - ~LabelImageRegionPruningFilter() ITK_OVERRIDE; + ~LabelImageRegionPruningFilter() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Method to build a map of adjacent regions */ RegionAdjacencyMapType LabelImageToRegionAdjacencyMap(typename OutputLabelImageType::Pointer inputLabelImage); diff --git a/Modules/Segmentation/Conversion/include/otbLabelImageToOGRDataSourceFilter.h b/Modules/Segmentation/Conversion/include/otbLabelImageToOGRDataSourceFilter.h index eef1020ad7..9e0202ef81 100644 --- a/Modules/Segmentation/Conversion/include/otbLabelImageToOGRDataSourceFilter.h +++ b/Modules/Segmentation/Conversion/include/otbLabelImageToOGRDataSourceFilter.h @@ -114,17 +114,17 @@ public: protected: LabelImageToOGRDataSourceFilter(); - ~LabelImageToOGRDataSourceFilter() ITK_OVERRIDE {} + ~LabelImageToOGRDataSourceFilter() override {} - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Generate Data method*/ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** DataObject pointer */ typedef itk::DataObject::Pointer DataObjectPointer; - DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE; + DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override; using Superclass::MakeOutput; private: diff --git a/Modules/Segmentation/Conversion/include/otbLabelImageToVectorDataFilter.h b/Modules/Segmentation/Conversion/include/otbLabelImageToVectorDataFilter.h index a72ae77386..6d1b189be3 100644 --- a/Modules/Segmentation/Conversion/include/otbLabelImageToVectorDataFilter.h +++ b/Modules/Segmentation/Conversion/include/otbLabelImageToVectorDataFilter.h @@ -104,12 +104,12 @@ public: protected: LabelImageToVectorDataFilter(); - ~LabelImageToVectorDataFilter() ITK_OVERRIDE {} + ~LabelImageToVectorDataFilter() override {} - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Generate Data method*/ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: LabelImageToVectorDataFilter(const Self &); //purposely not implemented diff --git a/Modules/Segmentation/Conversion/include/otbLabelMapToVectorDataFilter.h b/Modules/Segmentation/Conversion/include/otbLabelMapToVectorDataFilter.h index 8b81e03653..3e17c8983f 100644 --- a/Modules/Segmentation/Conversion/include/otbLabelMapToVectorDataFilter.h +++ b/Modules/Segmentation/Conversion/include/otbLabelMapToVectorDataFilter.h @@ -115,9 +115,9 @@ public: protected: LabelMapToVectorDataFilter(); - ~LabelMapToVectorDataFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; - void GenerateData() ITK_OVERRIDE; + ~LabelMapToVectorDataFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; + void GenerateData() override; private: LabelMapToVectorDataFilter(const Self &); //purposely not implemented diff --git a/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.h b/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.h index 421075334f..bec0926d8d 100644 --- a/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.h +++ b/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.h @@ -140,14 +140,14 @@ public: void SetOutputParametersFromImage(const ImageBaseType * image); protected: - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; OGRDataSourceToLabelImageFilter(); - ~OGRDataSourceToLabelImageFilter() ITK_OVERRIDE {} + ~OGRDataSourceToLabelImageFilter() override {} - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: OGRDataSourceToLabelImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Segmentation/Conversion/include/otbPersistentImageToOGRLayerFilter.h b/Modules/Segmentation/Conversion/include/otbPersistentImageToOGRLayerFilter.h index 433917b811..98c5760c62 100644 --- a/Modules/Segmentation/Conversion/include/otbPersistentImageToOGRLayerFilter.h +++ b/Modules/Segmentation/Conversion/include/otbPersistentImageToOGRLayerFilter.h @@ -74,9 +74,9 @@ public: typedef ogr::Layer OGRLayerType; typedef ogr::Feature OGRFeatureType; - void AllocateOutputs() ITK_OVERRIDE; - void Reset(void) ITK_OVERRIDE; - void Synthetize(void) ITK_OVERRIDE; + void AllocateOutputs() override; + void Reset(void) override; + void Synthetize(void) override; /** This method creates the output layer in the OGRLayer set by the user. * \note This methode must be called before the call of Update . @@ -96,11 +96,11 @@ public: protected: PersistentImageToOGRLayerFilter(); - ~PersistentImageToOGRLayerFilter() ITK_OVERRIDE; + ~PersistentImageToOGRLayerFilter() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: diff --git a/Modules/Segmentation/Conversion/include/otbPersistentImageToVectorDataFilter.h b/Modules/Segmentation/Conversion/include/otbPersistentImageToVectorDataFilter.h index e5f1aef461..3b49caaa61 100644 --- a/Modules/Segmentation/Conversion/include/otbPersistentImageToVectorDataFilter.h +++ b/Modules/Segmentation/Conversion/include/otbPersistentImageToVectorDataFilter.h @@ -86,11 +86,11 @@ public: OutputVectorDataType* GetOutputVectorData() const; - void AllocateOutputs() ITK_OVERRIDE; + void AllocateOutputs() override; - void Reset(void) ITK_OVERRIDE; + void Reset(void) override; - void Synthetize(void) ITK_OVERRIDE; + void Synthetize(void) override; /** Specify the name of the output shapefile to write. */ itkSetStringMacro(FileName); @@ -98,11 +98,11 @@ public: protected: PersistentImageToVectorDataFilter(); - ~PersistentImageToVectorDataFilter() ITK_OVERRIDE {} + ~PersistentImageToVectorDataFilter() override {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; ExtractImageFilterPointerType m_ExtractFilter; diff --git a/Modules/Segmentation/Conversion/include/otbRasterizeVectorDataFilter.h b/Modules/Segmentation/Conversion/include/otbRasterizeVectorDataFilter.h index be354efbb6..eb197d050f 100644 --- a/Modules/Segmentation/Conversion/include/otbRasterizeVectorDataFilter.h +++ b/Modules/Segmentation/Conversion/include/otbRasterizeVectorDataFilter.h @@ -136,10 +136,10 @@ public: } protected: - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; RasterizeVectorDataFilter(); - ~RasterizeVectorDataFilter() ITK_OVERRIDE + ~RasterizeVectorDataFilter() override { if (m_OGRDataSourcePointer != ITK_NULLPTR) { @@ -147,9 +147,9 @@ protected: } } - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: RasterizeVectorDataFilter(const Self&); //purposely not implemented diff --git a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelImageFilter.h b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelImageFilter.h index c7a0627250..d240df3fc7 100644 --- a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelImageFilter.h +++ b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelImageFilter.h @@ -124,10 +124,10 @@ public: void SetOutputParametersFromImage(const ImageBaseType * image); protected: - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; VectorDataToLabelImageFilter(); - ~VectorDataToLabelImageFilter() ITK_OVERRIDE + ~VectorDataToLabelImageFilter() override { // Destroy the geometries stored for (unsigned int idx = 0; idx < m_SrcDataSetGeometries.size(); ++idx) @@ -141,9 +141,9 @@ protected: } } - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: VectorDataToLabelImageFilter(const Self&); //purposely not implemented diff --git a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapFilter.h b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapFilter.h index 924b6ff894..9c3656dd34 100644 --- a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapFilter.h +++ b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapFilter.h @@ -161,18 +161,18 @@ public: const InputVectorDataType * GetInput(void); const InputVectorDataType * GetInput(unsigned int idx); - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; protected: VectorDataToLabelMapFilter(); - ~VectorDataToLabelMapFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~VectorDataToLabelMapFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Standard pipeline method. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** VectorDataToLabelMapFilter needs the entire input. Therefore * it must provide an implementation GenerateInputRequestedRegion(). diff --git a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapWithAttributesFilter.h b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapWithAttributesFilter.h index acedfcebeb..28a2baec1e 100644 --- a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapWithAttributesFilter.h +++ b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapWithAttributesFilter.h @@ -187,20 +187,20 @@ public: ; itkGetMacro(InitialLabel, LabelType) ; - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; protected: VectorDataToLabelMapWithAttributesFilter(); - ~VectorDataToLabelMapWithAttributesFilter() ITK_OVERRIDE + ~VectorDataToLabelMapWithAttributesFilter() override { } - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Standard pipeline method. */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** VectorDataToLabelMapWithAttributesFilter needs the entire input. Therefore * it must provide an implementation GenerateInputRequestedRegion(). diff --git a/Modules/Segmentation/Labelling/include/otbLabelToBoundaryImageFilter.h b/Modules/Segmentation/Labelling/include/otbLabelToBoundaryImageFilter.h index b1a67e4200..4e34052d21 100644 --- a/Modules/Segmentation/Labelling/include/otbLabelToBoundaryImageFilter.h +++ b/Modules/Segmentation/Labelling/include/otbLabelToBoundaryImageFilter.h @@ -98,7 +98,7 @@ protected: { this->SetRadius(1); } - ~LabelToBoundaryImageFilter() ITK_OVERRIDE { } + ~LabelToBoundaryImageFilter() override { } private: LabelToBoundaryImageFilter( const Self & ); // Not implemented diff --git a/Modules/Segmentation/Labelling/include/otbLabelizeConfidenceConnectedImageFilter.h b/Modules/Segmentation/Labelling/include/otbLabelizeConfidenceConnectedImageFilter.h index 3e8c27e092..be83bcb2a2 100644 --- a/Modules/Segmentation/Labelling/include/otbLabelizeConfidenceConnectedImageFilter.h +++ b/Modules/Segmentation/Labelling/include/otbLabelizeConfidenceConnectedImageFilter.h @@ -109,11 +109,11 @@ public: protected: LabelizeConfidenceConnectedImageFilter(); - ~LabelizeConfidenceConnectedImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LabelizeConfidenceConnectedImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Region growing */ - void RegionGrowing(const IndexType indexSeed) ITK_OVERRIDE; + void RegionGrowing(const IndexType indexSeed) override; private: LabelizeConfidenceConnectedImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Segmentation/Labelling/include/otbLabelizeConnectedThresholdImageFilter.h b/Modules/Segmentation/Labelling/include/otbLabelizeConnectedThresholdImageFilter.h index 37ce1dfd74..018f343997 100644 --- a/Modules/Segmentation/Labelling/include/otbLabelizeConnectedThresholdImageFilter.h +++ b/Modules/Segmentation/Labelling/include/otbLabelizeConnectedThresholdImageFilter.h @@ -82,11 +82,11 @@ public: protected: LabelizeConnectedThresholdImageFilter(); - ~LabelizeConnectedThresholdImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LabelizeConnectedThresholdImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Region growing */ - void RegionGrowing(const IndexType indexSeed) ITK_OVERRIDE; + void RegionGrowing(const IndexType indexSeed) override; private: LabelizeConnectedThresholdImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Segmentation/Labelling/include/otbLabelizeImageFilterBase.h b/Modules/Segmentation/Labelling/include/otbLabelizeImageFilterBase.h index d817bb3f6b..1f8b5305bd 100644 --- a/Modules/Segmentation/Labelling/include/otbLabelizeImageFilterBase.h +++ b/Modules/Segmentation/Labelling/include/otbLabelizeImageFilterBase.h @@ -96,11 +96,11 @@ public: protected: LabelizeImageFilterBase(); - ~LabelizeImageFilterBase() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LabelizeImageFilterBase() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Region growing */ virtual void RegionGrowing(const IndexType itkNotUsed(indexSeed)) {} diff --git a/Modules/Segmentation/Labelling/include/otbLabelizeNeighborhoodConnectedImageFilter.h b/Modules/Segmentation/Labelling/include/otbLabelizeNeighborhoodConnectedImageFilter.h index 768377f48c..9264ba669e 100644 --- a/Modules/Segmentation/Labelling/include/otbLabelizeNeighborhoodConnectedImageFilter.h +++ b/Modules/Segmentation/Labelling/include/otbLabelizeNeighborhoodConnectedImageFilter.h @@ -104,11 +104,11 @@ public: protected: LabelizeNeighborhoodConnectedImageFilter(); - ~LabelizeNeighborhoodConnectedImageFilter() ITK_OVERRIDE {} - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + ~LabelizeNeighborhoodConnectedImageFilter() override {} + void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** Region growing */ - void RegionGrowing(const IndexType indexSeed) ITK_OVERRIDE; + void RegionGrowing(const IndexType indexSeed) override; private: LabelizeNeighborhoodConnectedImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Segmentation/MeanShift/include/otbMeanShiftConnectedComponentSegmentationFilter.h b/Modules/Segmentation/MeanShift/include/otbMeanShiftConnectedComponentSegmentationFilter.h index c02dd8e432..b065125bc7 100644 --- a/Modules/Segmentation/MeanShift/include/otbMeanShiftConnectedComponentSegmentationFilter.h +++ b/Modules/Segmentation/MeanShift/include/otbMeanShiftConnectedComponentSegmentationFilter.h @@ -130,10 +130,10 @@ public: protected: MeanShiftConnectedComponentSegmentationFilter(); - ~MeanShiftConnectedComponentSegmentationFilter() ITK_OVERRIDE; + ~MeanShiftConnectedComponentSegmentationFilter() override; - void GenerateInputRequestedRegion() ITK_OVERRIDE; - void GenerateData() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; + void GenerateData() override; private: diff --git a/Modules/Segmentation/MeanShift/include/otbMeanShiftSegmentationFilter.h b/Modules/Segmentation/MeanShift/include/otbMeanShiftSegmentationFilter.h index 5f33cefe4a..03c19157eb 100644 --- a/Modules/Segmentation/MeanShift/include/otbMeanShiftSegmentationFilter.h +++ b/Modules/Segmentation/MeanShift/include/otbMeanShiftSegmentationFilter.h @@ -173,11 +173,11 @@ public: protected: MeanShiftSegmentationFilter(); - ~MeanShiftSegmentationFilter() ITK_OVERRIDE; + ~MeanShiftSegmentationFilter() override; // virtual void GenerateOutputInformation(void); - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: diff --git a/Modules/Segmentation/Metrics/include/otbHooverInstanceFilter.h b/Modules/Segmentation/Metrics/include/otbHooverInstanceFilter.h index fa71ec68ab..cae56e1625 100644 --- a/Modules/Segmentation/Metrics/include/otbHooverInstanceFilter.h +++ b/Modules/Segmentation/Metrics/include/otbHooverInstanceFilter.h @@ -210,30 +210,30 @@ public: protected: HooverInstanceFilter(); - ~HooverInstanceFilter() ITK_OVERRIDE {}; + ~HooverInstanceFilter() override {}; /** Re implement the allocate output method to handle the second output correctly */ - void AllocateOutputs() ITK_OVERRIDE; + void AllocateOutputs() override; /** Re implement the release input method to handle the second input correctly */ - void ReleaseInputs() ITK_OVERRIDE; + void ReleaseInputs() override; /** Actions : * - Fill cardinalities of GT regions */ - void ThreadedProcessLabelObject( LabelObjectType * labelObject ) ITK_OVERRIDE; + void ThreadedProcessLabelObject( LabelObjectType * labelObject ) override; /** Actions: * - Check matrix size * - Init cardinalities lists * - Fill cardinalities list for MS (GT is done by ThreadedProcessLabelObject) */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Actions : * - Compute Hoover instances */ - void AfterThreadedGenerateData() ITK_OVERRIDE; + void AfterThreadedGenerateData() override; private: diff --git a/Modules/Segmentation/Metrics/include/otbHooverMatrixFilter.h b/Modules/Segmentation/Metrics/include/otbHooverMatrixFilter.h index 2daca45480..efedebd57f 100644 --- a/Modules/Segmentation/Metrics/include/otbHooverMatrixFilter.h +++ b/Modules/Segmentation/Metrics/include/otbHooverMatrixFilter.h @@ -89,16 +89,16 @@ protected: /** Constructor */ HooverMatrixFilter(); - ~HooverMatrixFilter() ITK_OVERRIDE {}; + ~HooverMatrixFilter() override {}; /** Action : Resize the matrix */ - void BeforeThreadedGenerateData() ITK_OVERRIDE; + void BeforeThreadedGenerateData() override; /** Action : fill the line of the confusion matrix corresponding to * the given label object */ - void ThreadedProcessLabelObject( LabelObjectType * labelObject ) ITK_OVERRIDE; + void ThreadedProcessLabelObject( LabelObjectType * labelObject ) override; private: diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbClosingOpeningMorphologicalFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbClosingOpeningMorphologicalFilter.h index c3639adf0a..f1d5e29ae6 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbClosingOpeningMorphologicalFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbClosingOpeningMorphologicalFilter.h @@ -79,15 +79,15 @@ protected: /** Constructor */ ClosingOpeningMorphologicalFilter(); /** Destructor */ - ~ClosingOpeningMorphologicalFilter() ITK_OVERRIDE {} + ~ClosingOpeningMorphologicalFilter() override {} /* void GenerateInputRequestedRegion(); */ /* void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output)); */ /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ClosingOpeningMorphologicalFilter(const Self &); //purposely not implemented diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbConvexOrConcaveClassificationFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbConvexOrConcaveClassificationFilter.h index f409881fcb..dcd0f39432 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbConvexOrConcaveClassificationFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbConvexOrConcaveClassificationFilter.h @@ -215,7 +215,7 @@ public: * */ using Superclass::SetInput; - void SetInput(const TInputImage * image) ITK_OVERRIDE + void SetInput(const TInputImage * image) override { this->SetInput1(image); } @@ -242,7 +242,7 @@ public: itkGetMacro(Sigma, double); /** Set the functor parameters before calling the ThreadedGenerateData() */ - void BeforeThreadedGenerateData(void) ITK_OVERRIDE + void BeforeThreadedGenerateData(void) override { this->GetFunctor().SetConvexLabel(m_ConvexLabel); this->GetFunctor().SetConcaveLabel(m_ConcaveLabel); @@ -260,9 +260,9 @@ protected: m_Sigma = 0.0; }; /** Destructor */ - ~ConvexOrConcaveClassificationFilter() ITK_OVERRIDE {} + ~ConvexOrConcaveClassificationFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); os << indent << "ConvexLabel: " << m_ConvexLabel << std::endl; diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyDecompositionImageFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyDecompositionImageFilter.h index 6c2174532a..d2e77b8772 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyDecompositionImageFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyDecompositionImageFilter.h @@ -149,13 +149,13 @@ public: protected: /** GenerateData */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Constructor */ GeodesicMorphologyDecompositionImageFilter(); /** Destructor */ - ~GeodesicMorphologyDecompositionImageFilter() ITK_OVERRIDE {} + ~GeodesicMorphologyDecompositionImageFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: GeodesicMorphologyDecompositionImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyIterativeDecompositionImageFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyIterativeDecompositionImageFilter.h index 92cfb85df6..91d51758e8 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyIterativeDecompositionImageFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyIterativeDecompositionImageFilter.h @@ -116,7 +116,7 @@ public: * Get The leveling images for each scale. * \return The leveling images for each scale. */ - OutputImageListType* GetOutput(void) ITK_OVERRIDE; + OutputImageListType* GetOutput(void) override; /** * Get convex membership function for each scale * \return The convex membership function for each scale. @@ -132,15 +132,15 @@ protected: /** Constructor */ GeodesicMorphologyIterativeDecompositionImageFilter(); /** Destructor */ - ~GeodesicMorphologyIterativeDecompositionImageFilter() ITK_OVERRIDE {} + ~GeodesicMorphologyIterativeDecompositionImageFilter() override {} /** Generate output information */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** Generate input requested region */ - void GenerateInputRequestedRegion() ITK_OVERRIDE; + void GenerateInputRequestedRegion() override; /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** Printself method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: /** The step for the scale analysis */ diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyLevelingFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyLevelingFilter.h index 3c7a16920d..6211c59697 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyLevelingFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyLevelingFilter.h @@ -117,7 +117,7 @@ public: * Set the original input image */ using Superclass::SetInput; - void SetInput(const TInputImage * input) ITK_OVERRIDE + void SetInput(const TInputImage * input) override { this->SetInput1(input); } @@ -126,9 +126,9 @@ protected: /** Constructor */ GeodesicMorphologyLevelingFilter() {}; /** Destructor */ - ~GeodesicMorphologyLevelingFilter() ITK_OVERRIDE {} + ~GeodesicMorphologyLevelingFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbImageToProfileFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbImageToProfileFilter.h index 0c6a3f6604..85223e736c 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbImageToProfileFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbImageToProfileFilter.h @@ -91,17 +91,17 @@ protected: /** Get the pointer to the filter */ itkGetObjectMacro(Filter, FilterType); /** GenerateData method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** GenerateOutputInformation method */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** Generate input requested region */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** Constructor */ ImageToProfileFilter(); /** Destructor */ - ~ImageToProfileFilter() ITK_OVERRIDE {} + ~ImageToProfileFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ImageToProfileFilter(const Self &); //purposely not implemented diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbMorphologicalClosingProfileFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbMorphologicalClosingProfileFilter.h index f3d08451e3..a5af964287 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbMorphologicalClosingProfileFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbMorphologicalClosingProfileFilter.h @@ -77,7 +77,7 @@ public: protected: /** Set the profile parameter */ - void SetProfileParameter(ParameterType param) ITK_OVERRIDE + void SetProfileParameter(ParameterType param) override { StructuringElementType se; se.SetRadius(param); @@ -87,9 +87,9 @@ protected: /** Constructor */ MorphologicalClosingProfileFilter() {}; /** Destructor */ - ~MorphologicalClosingProfileFilter() ITK_OVERRIDE {} + ~MorphologicalClosingProfileFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbMorphologicalOpeningProfileFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbMorphologicalOpeningProfileFilter.h index 83fde0a9f8..2c8d5bdbbf 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbMorphologicalOpeningProfileFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbMorphologicalOpeningProfileFilter.h @@ -77,7 +77,7 @@ public: protected: /** Set the profile parameter */ - void SetProfileParameter(ParameterType param) ITK_OVERRIDE + void SetProfileParameter(ParameterType param) override { StructuringElementType se; se.SetRadius(param); @@ -87,9 +87,9 @@ protected: /** Constructor */ MorphologicalOpeningProfileFilter() {}; /** Destructor */ - ~MorphologicalOpeningProfileFilter() ITK_OVERRIDE {} + ~MorphologicalOpeningProfileFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbMorphologicalProfilesSegmentationFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbMorphologicalProfilesSegmentationFilter.h index 401c3fde23..f61f87fc82 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbMorphologicalProfilesSegmentationFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbMorphologicalProfilesSegmentationFilter.h @@ -106,9 +106,9 @@ itkGetConstReferenceMacro(Sigma,double); protected: MorphologicalProfilesSegmentationFilter(); -~MorphologicalProfilesSegmentationFilter() ITK_OVERRIDE; +~MorphologicalProfilesSegmentationFilter() override; -void GenerateData() ITK_OVERRIDE; +void GenerateData() override; private: typename OpeningProfileFilterType::Pointer m_OpeningProfile; diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbMultiScaleConvexOrConcaveClassificationFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbMultiScaleConvexOrConcaveClassificationFilter.h index 5bf49f3356..bcb21040a6 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbMultiScaleConvexOrConcaveClassificationFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbMultiScaleConvexOrConcaveClassificationFilter.h @@ -222,7 +222,7 @@ public: itkGetMacro(LabelSeparator, LabelType); /** Set the functor parameters before calling the ThreadedGenerateData() */ - void BeforeThreadedGenerateData(void) ITK_OVERRIDE + void BeforeThreadedGenerateData(void) override { this->GetFunctor().SetLabelSeparator(m_LabelSeparator); this->GetFunctor().SetSigma(m_Sigma); @@ -236,9 +236,9 @@ protected: m_Sigma = 0.0; }; /** Destructor */ - ~MultiScaleConvexOrConcaveClassificationFilter() ITK_OVERRIDE {} + ~MultiScaleConvexOrConcaveClassificationFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE + void PrintSelf(std::ostream& os, itk::Indent indent) const override { Superclass::PrintSelf(os, indent); os << indent << "LabelSeparator: " << m_LabelSeparator << std::endl; diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbOpeningClosingMorphologicalFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbOpeningClosingMorphologicalFilter.h index d434913a51..4e69011508 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbOpeningClosingMorphologicalFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbOpeningClosingMorphologicalFilter.h @@ -79,15 +79,15 @@ protected: /** Constructor */ OpeningClosingMorphologicalFilter(); /** Destructor */ - ~OpeningClosingMorphologicalFilter() ITK_OVERRIDE {} + ~OpeningClosingMorphologicalFilter() override {} /* void GenerateInputRequestedRegion(); */ /* void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output)); */ /** Main computation method */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: OpeningClosingMorphologicalFilter(const Self &); //purposely not implemented diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbProfileDerivativeToMultiScaleCharacteristicsFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbProfileDerivativeToMultiScaleCharacteristicsFilter.h index 64ed396fa0..805070251d 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbProfileDerivativeToMultiScaleCharacteristicsFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbProfileDerivativeToMultiScaleCharacteristicsFilter.h @@ -86,26 +86,26 @@ public: protected: /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** GenerateOutputInformation * Set the number of bands of the output. * Copy information from the first image of the list if existing. **/ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** * GenerateInputRequestedRegion * Set the requested region of each image in the list. */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; /** Constructor */ ProfileDerivativeToMultiScaleCharacteristicsFilter(); /** Destructor */ - ~ProfileDerivativeToMultiScaleCharacteristicsFilter() ITK_OVERRIDE {} + ~ProfileDerivativeToMultiScaleCharacteristicsFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ProfileDerivativeToMultiScaleCharacteristicsFilter(const Self &); //purposely not implemented diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbProfileToProfileDerivativeFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbProfileToProfileDerivativeFilter.h index f71b7c5536..cef78cc730 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbProfileToProfileDerivativeFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbProfileToProfileDerivativeFilter.h @@ -78,20 +78,20 @@ public: /** Generate output information for the ImageList and for each image in the list. */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** Generate input requested region for each image in the list. */ - void GenerateInputRequestedRegion(void) ITK_OVERRIDE; + void GenerateInputRequestedRegion(void) override; protected: /** Main computation method */ - void GenerateData(void) ITK_OVERRIDE; + void GenerateData(void) override; /** Constructor */ ProfileToProfileDerivativeFilter(); /** Destructor */ - ~ProfileToProfileDerivativeFilter() ITK_OVERRIDE {} + ~ProfileToProfileDerivativeFilter() override {} /**PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream& os, itk::Indent indent) const override; private: ProfileToProfileDerivativeFilter(const Self &); //purposely not implemented diff --git a/Modules/Segmentation/OGRProcessing/include/otbOGRLayerStreamStitchingFilter.h b/Modules/Segmentation/OGRProcessing/include/otbOGRLayerStreamStitchingFilter.h index 9f111d292a..9149fbf213 100644 --- a/Modules/Segmentation/OGRProcessing/include/otbOGRLayerStreamStitchingFilter.h +++ b/Modules/Segmentation/OGRProcessing/include/otbOGRLayerStreamStitchingFilter.h @@ -106,11 +106,11 @@ public: itkGetMacro(StreamSize, SizeType); /** Generate Data method. This method must be called explicitly (not through the \c Update method). */ - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; protected: OGRLayerStreamStitchingFilter(); - ~OGRLayerStreamStitchingFilter() ITK_OVERRIDE {} + ~OGRLayerStreamStitchingFilter() override {} struct FusionStruct { diff --git a/Modules/Segmentation/OGRProcessing/include/otbStreamingImageToOGRLayerSegmentationFilter.h b/Modules/Segmentation/OGRProcessing/include/otbStreamingImageToOGRLayerSegmentationFilter.h index a64db1a245..f797bafee2 100644 --- a/Modules/Segmentation/OGRProcessing/include/otbStreamingImageToOGRLayerSegmentationFilter.h +++ b/Modules/Segmentation/OGRProcessing/include/otbStreamingImageToOGRLayerSegmentationFilter.h @@ -144,14 +144,14 @@ public: protected: PersistentImageToOGRLayerSegmentationFilter(); - ~PersistentImageToOGRLayerSegmentationFilter() ITK_OVERRIDE; + ~PersistentImageToOGRLayerSegmentationFilter() override; private: PersistentImageToOGRLayerSegmentationFilter(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented - OGRDataSourcePointerType ProcessTile() ITK_OVERRIDE; + OGRDataSourcePointerType ProcessTile() override; int m_TileMaxLabel; @@ -349,7 +349,7 @@ protected: /** Constructor */ StreamingImageToOGRLayerSegmentationFilter() {} /** Destructor */ - ~StreamingImageToOGRLayerSegmentationFilter() ITK_OVERRIDE {} + ~StreamingImageToOGRLayerSegmentationFilter() override {} private: StreamingImageToOGRLayerSegmentationFilter(const Self &); //purposely not implemented diff --git a/Modules/Segmentation/Watersheds/include/otbWatershedSegmentationFilter.h b/Modules/Segmentation/Watersheds/include/otbWatershedSegmentationFilter.h index 9d35385b12..32239f115a 100644 --- a/Modules/Segmentation/Watersheds/include/otbWatershedSegmentationFilter.h +++ b/Modules/Segmentation/Watersheds/include/otbWatershedSegmentationFilter.h @@ -84,9 +84,9 @@ public: protected: WatershedSegmentationFilter(); - ~WatershedSegmentationFilter() ITK_OVERRIDE; + ~WatershedSegmentationFilter() override; - void GenerateData() ITK_OVERRIDE; + void GenerateData() override; private: typename CastImageFilterType::Pointer m_CastFilter; diff --git a/Modules/ThirdParty/ITK/include/itkImageRegionSplitter.h b/Modules/ThirdParty/ITK/include/itkImageRegionSplitter.h index f9304f511b..13fc872f86 100644 --- a/Modules/ThirdParty/ITK/include/itkImageRegionSplitter.h +++ b/Modules/ThirdParty/ITK/include/itkImageRegionSplitter.h @@ -121,12 +121,12 @@ public: protected: ImageRegionSplitter() {} - ~ImageRegionSplitter() ITK_OVERRIDE {} + ~ImageRegionSplitter() override {} unsigned int GetNumberOfSplitsInternal(unsigned int, const IndexValueType regionIndex[], const SizeValueType regionSize[], - unsigned int requestedNumber) const ITK_OVERRIDE + unsigned int requestedNumber) const override { // this function adapts the legecy method, defined in this class // be used by the ImageRegionSplitterBase. @@ -145,7 +145,7 @@ protected: unsigned int i, unsigned int numberOfPieces, IndexValueType regionIndex[], - SizeValueType regionSize[]) const ITK_OVERRIDE + SizeValueType regionSize[]) const override { // this function adapts the legecy method, defined in this class // be used by the ImageRegionSplitterBase. @@ -166,7 +166,7 @@ protected: return numberOfPieces; } - void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream & os, Indent indent) const override; private: ImageRegionSplitter(const ImageRegionSplitter &); //purposely not implemented diff --git a/Modules/ThirdParty/ITK/include/itkTransformToDisplacementFieldSource.h b/Modules/ThirdParty/ITK/include/itkTransformToDisplacementFieldSource.h index ecdc5a421a..2a9b77c394 100644 --- a/Modules/ThirdParty/ITK/include/itkTransformToDisplacementFieldSource.h +++ b/Modules/ThirdParty/ITK/include/itkTransformToDisplacementFieldSource.h @@ -37,9 +37,9 @@ namespace itk * spacing, origin and direction of the reference image will be used. * * Since this filter produces an image which is a different size than - * its input, it needs to ITK_OVERRIDE several of the methods defined + * its input, it needs to override several of the methods defined * in ProcessObject in order to properly manage the pipeline execution model. - * In particular, this filter ITK_OVERRIDEs + * In particular, this filter overrides * ProcessObject::GenerateInputRequestedRegion() and * ProcessObject::GenerateOutputInformation(). * @@ -154,13 +154,13 @@ public: void SetOutputParametersFromImage(const ImageBaseType *image); /** DisplacementFieldImageFilter produces a vector image. */ - void GenerateOutputInformation(void) ITK_OVERRIDE; + void GenerateOutputInformation(void) override; /** Just checking if transform is set. */ - void BeforeThreadedGenerateData(void) ITK_OVERRIDE; + void BeforeThreadedGenerateData(void) override; /** Compute the Modified Time based on changes to the components. */ - ModifiedTimeType GetMTime(void) const ITK_OVERRIDE; + ModifiedTimeType GetMTime(void) const override; #ifdef ITK_USE_CONCEPT_CHECKING /** Begin concept checking */ @@ -173,16 +173,16 @@ public: protected: TransformToDisplacementFieldSource(void); - ~TransformToDisplacementFieldSource(void) ITK_OVERRIDE {} + ~TransformToDisplacementFieldSource(void) override {} - void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream & os, Indent indent) const override; /** TransformToDisplacementFieldSource can be implemented as a multithreaded * filter. */ void ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, - ThreadIdType threadId) ITK_OVERRIDE; + ThreadIdType threadId) override; /** Default implementation for resampling that works for any * transformation type. diff --git a/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.h b/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.h index a47d8cf82a..8e268752d5 100644 --- a/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.h +++ b/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.h @@ -102,7 +102,7 @@ public: protected: UnaryFunctorImageFilter(); - ~UnaryFunctorImageFilter() ITK_OVERRIDE {} + ~UnaryFunctorImageFilter() override {} /** UnaryFunctorImageFilter can produce an image which is a different * resolution than its input image. As such, UnaryFunctorImageFilter @@ -112,7 +112,7 @@ protected: * below. * * \sa ProcessObject::GenerateOutputInformaton() */ - void GenerateOutputInformation() ITK_OVERRIDE; + void GenerateOutputInformation() override; /** UnaryFunctorImageFilter can be implemented as a multithreaded filter. * Therefore, this implementation provides a ThreadedGenerateData() routine @@ -125,7 +125,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, - ThreadIdType threadId) ITK_OVERRIDE; + ThreadIdType threadId) override; private: UnaryFunctorImageFilter(const Self &); //purposely not implemented diff --git a/Modules/Visualization/Ice/include/otbFragmentShader.h b/Modules/Visualization/Ice/include/otbFragmentShader.h index 99559dd163..7b931c8699 100644 --- a/Modules/Visualization/Ice/include/otbFragmentShader.h +++ b/Modules/Visualization/Ice/include/otbFragmentShader.h @@ -58,7 +58,7 @@ public: protected: FragmentShader(); - ~FragmentShader() ITK_OVERRIDE; + ~FragmentShader() override; void BuildShader(); diff --git a/Modules/Visualization/Ice/include/otbFragmentShaderRegistry.h b/Modules/Visualization/Ice/include/otbFragmentShaderRegistry.h index 6e5fc6e08f..f1aae8be0d 100644 --- a/Modules/Visualization/Ice/include/otbFragmentShaderRegistry.h +++ b/Modules/Visualization/Ice/include/otbFragmentShaderRegistry.h @@ -55,7 +55,7 @@ public: protected: FragmentShaderRegistry(); - ~FragmentShaderRegistry() ITK_OVERRIDE; + ~FragmentShaderRegistry() override; private: typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ShaderMapType; diff --git a/Modules/Visualization/Ice/include/otbGlActor.h b/Modules/Visualization/Ice/include/otbGlActor.h index 2c20ce7bc3..d11a4ef3c1 100644 --- a/Modules/Visualization/Ice/include/otbGlActor.h +++ b/Modules/Visualization/Ice/include/otbGlActor.h @@ -72,7 +72,7 @@ public: protected: GlActor(); - ~GlActor() ITK_OVERRIDE; + ~GlActor() override; private: // prevent implementation diff --git a/Modules/Visualization/Ice/include/otbGlImageActor.h b/Modules/Visualization/Ice/include/otbGlImageActor.h index b70ecc429b..9f2c4b7ac1 100644 --- a/Modules/Visualization/Ice/include/otbGlImageActor.h +++ b/Modules/Visualization/Ice/include/otbGlImageActor.h @@ -80,16 +80,16 @@ public: void Initialize(const std::string & filename); // Retrieve the full extent of the actor - void GetExtent(double & ulx, double & uly, double & lrx, double & lry) const ITK_OVERRIDE; + void GetExtent(double & ulx, double & uly, double & lrx, double & lry) const override; // Update internal actor state with respect to ViewSettings - void ProcessViewSettings() ITK_OVERRIDE; + void ProcessViewSettings() override; // Heavy load/unload operations of data - void UpdateData() ITK_OVERRIDE; + void UpdateData() override; // Gl rendering of current state - void Render() ITK_OVERRIDE; + void Render() override; // Automatic color adjustment void AutoColorAdjustment( double & minRed, double & maxRed, @@ -101,15 +101,15 @@ public: const PointType & GetOrigin() const; - const GeoInterface::Spacing2 & GetSpacing() const ITK_OVERRIDE; + const GeoInterface::Spacing2 & GetSpacing() const override; - std::string GetWkt() const ITK_OVERRIDE; + std::string GetWkt() const override; ImageKeywordlistType GetKwl() const; - bool HasKwl() const ITK_OVERRIDE; + bool HasKwl() const override; - bool GetKwl( ImageKeywordlist & ) const ITK_OVERRIDE; + bool GetKwl( ImageKeywordlist & ) const override; MetaDataDictionaryType & GetMetaDataDictionary() const; @@ -191,11 +191,11 @@ public: bool TransformFromViewport( Point2d & out, const Point2d & in, - bool isPhysical = true ) const ITK_OVERRIDE; + bool isPhysical = true ) const override; bool TransformToViewport( Point2d & out, const Point2d & in, - bool isPhysical = true ) const ITK_OVERRIDE; + bool isPhysical = true ) const override; void UpdateTransforms(); @@ -203,7 +203,7 @@ public: protected: GlImageActor(); - ~GlImageActor() ITK_OVERRIDE; + ~GlImageActor() override; typedef ImageFileReader<VectorImageType> ReaderType; typedef MultiChannelExtractROI<float,float> ExtractROIFilterType; diff --git a/Modules/Visualization/Ice/include/otbGlROIActor.h b/Modules/Visualization/Ice/include/otbGlROIActor.h index 769bb414e8..907b424afc 100644 --- a/Modules/Visualization/Ice/include/otbGlROIActor.h +++ b/Modules/Visualization/Ice/include/otbGlROIActor.h @@ -49,16 +49,16 @@ public: itkNewMacro(Self); // Retrieve the full extent of the actor - void GetExtent(double & ulx, double & uly, double & lrx, double & lry) const ITK_OVERRIDE; + void GetExtent(double & ulx, double & uly, double & lrx, double & lry) const override; // Update internal actor state with respect to ViewSettings - void ProcessViewSettings() ITK_OVERRIDE; + void ProcessViewSettings() override; // Heavy load/unload operations of data - void UpdateData() ITK_OVERRIDE; + void UpdateData() override; // Gl rendering of current state - void Render() ITK_OVERRIDE; + void Render() override; void SetUL( const PointType & ); @@ -87,7 +87,7 @@ public: protected: GlROIActor(); - ~GlROIActor() ITK_OVERRIDE; + ~GlROIActor() override; private: // prevent implementation diff --git a/Modules/Visualization/Ice/include/otbGlVectorActor.h b/Modules/Visualization/Ice/include/otbGlVectorActor.h index 3ab74c1ac7..7c40b41ef9 100644 --- a/Modules/Visualization/Ice/include/otbGlVectorActor.h +++ b/Modules/Visualization/Ice/include/otbGlVectorActor.h @@ -67,19 +67,19 @@ public: void SetCurrentLayer(const std::string & layername); // Retrieve the full extent of the actor - void GetExtent(double & ulx, double & uly, double & lrx, double & lry) const ITK_OVERRIDE; + void GetExtent(double & ulx, double & uly, double & lrx, double & lry) const override; // Return actor extent in its own geometry void GetBoundingBox(double & ulx, double & uly, double & lrx, double & lry) const; // Update internal actor state with respect to ViewSettings - void ProcessViewSettings() ITK_OVERRIDE; + void ProcessViewSettings() override; // Heavy load/unload operations of data - void UpdateData() ITK_OVERRIDE; + void UpdateData() override; // Gl rendering of current state - void Render() ITK_OVERRIDE; + void Render() override; PointType ViewportToVectorTransform(const PointType & point) const; @@ -106,7 +106,7 @@ public: itkSetMacro(LineWidth,double); itkGetConstReferenceMacro(LineWidth,double); - std::string GetWkt() const ITK_OVERRIDE; + std::string GetWkt() const override; // // otb::GlActor overloads. @@ -114,13 +114,13 @@ public: bool TransformFromViewport( Point2d & out, const Point2d & in, - bool isPhysical = true ) const ITK_OVERRIDE; + bool isPhysical = true ) const override; protected: GlVectorActor(); - ~GlVectorActor() ITK_OVERRIDE; + ~GlVectorActor() override; // Internal class to hold tiles diff --git a/Modules/Visualization/Ice/include/otbGlView.h b/Modules/Visualization/Ice/include/otbGlView.h index 58c2022941..63c43a3753 100644 --- a/Modules/Visualization/Ice/include/otbGlView.h +++ b/Modules/Visualization/Ice/include/otbGlView.h @@ -280,7 +280,7 @@ public: protected: GlView(); - ~GlView() ITK_OVERRIDE; + ~GlView() override; private: // prevent implementation diff --git a/Modules/Visualization/Ice/include/otbImageSettings.h b/Modules/Visualization/Ice/include/otbImageSettings.h index 5b026f0bf4..a530f45494 100644 --- a/Modules/Visualization/Ice/include/otbImageSettings.h +++ b/Modules/Visualization/Ice/include/otbImageSettings.h @@ -81,7 +81,7 @@ public: protected: ImageSettings(); - ~ImageSettings() ITK_OVERRIDE; + ~ImageSettings() override; private: diff --git a/Modules/Visualization/Ice/include/otbStandardShader.h b/Modules/Visualization/Ice/include/otbStandardShader.h index 1b31793023..1553f39bd1 100644 --- a/Modules/Visualization/Ice/include/otbStandardShader.h +++ b/Modules/Visualization/Ice/include/otbStandardShader.h @@ -89,18 +89,18 @@ public: itkSetMacro(Center,PointType); itkGetConstReferenceMacro(Center,PointType); - void SetupShader() ITK_OVERRIDE; + void SetupShader() override; itkNewMacro(Self); protected: StandardShader(); - ~StandardShader() ITK_OVERRIDE; + ~StandardShader() override; - std::string GetSource() const ITK_OVERRIDE; + std::string GetSource() const override; - std::string GetName() const ITK_OVERRIDE; + std::string GetName() const override; private: // prevent implementation diff --git a/Modules/Visualization/Ice/include/otbViewSettings.h b/Modules/Visualization/Ice/include/otbViewSettings.h index 40637d0890..a29ea74d02 100644 --- a/Modules/Visualization/Ice/include/otbViewSettings.h +++ b/Modules/Visualization/Ice/include/otbViewSettings.h @@ -148,7 +148,7 @@ public: protected: ViewSettings(); - ~ViewSettings() ITK_OVERRIDE; + ~ViewSettings() override; private: // prevent implementation diff --git a/Modules/Visualization/IceViewer/include/otbIceViewer.h b/Modules/Visualization/IceViewer/include/otbIceViewer.h index af409bdbab..75539f0979 100644 --- a/Modules/Visualization/IceViewer/include/otbIceViewer.h +++ b/Modules/Visualization/IceViewer/include/otbIceViewer.h @@ -76,7 +76,7 @@ protected: IceViewer(); - ~IceViewer() ITK_OVERRIDE; + ~IceViewer() override; // Non-static callbacks virtual void scroll_callback(GLFWwindow * window, double xoffset, double yoffset); diff --git a/Modules/Visualization/Mapla/include/mvdMaplaApplication.h b/Modules/Visualization/Mapla/include/mvdMaplaApplication.h index c425d8fede..dcb85aefea 100644 --- a/Modules/Visualization/Mapla/include/mvdMaplaApplication.h +++ b/Modules/Visualization/Mapla/include/mvdMaplaApplication.h @@ -100,7 +100,7 @@ public: MaplaApplication( QApplication* qtApp ); /** \brief Destructor. */ - ~MaplaApplication() ITK_OVERRIDE; + ~MaplaApplication() override; // // STATIC METHODS. @@ -143,7 +143,7 @@ protected: // Protected attributes. protected: - void virtual_InitializeCore() ITK_OVERRIDE; + void virtual_InitializeCore() override; /*-[ PRIVATE SECTION ]-----------------------------------------------------*/ diff --git a/Modules/Visualization/Mapla/include/mvdMaplaMainWindow.h b/Modules/Visualization/Mapla/include/mvdMaplaMainWindow.h index e66c4a9548..2af3740a50 100644 --- a/Modules/Visualization/Mapla/include/mvdMaplaMainWindow.h +++ b/Modules/Visualization/Mapla/include/mvdMaplaMainWindow.h @@ -104,7 +104,7 @@ public: MaplaMainWindow( QWidget* Parent =0, Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~MaplaMainWindow() ITK_OVERRIDE; + ~MaplaMainWindow() override; /*-[ SIGNALS SECTION ]-----------------------------------------------------*/ @@ -121,7 +121,7 @@ protected: // // QMainWindow methods. - void closeEvent( QCloseEvent* event ) ITK_OVERRIDE; + void closeEvent( QCloseEvent* event ) override; // // Protected attributes. @@ -135,11 +135,11 @@ protected slots: /** */ - void OnAboutToChangeModel( const AbstractModel* ) ITK_OVERRIDE; + void OnAboutToChangeModel( const AbstractModel* ) override; /** */ - void OnModelChanged( AbstractModel* ) ITK_OVERRIDE; + void OnModelChanged( AbstractModel* ) override; /** */ @@ -178,9 +178,9 @@ private: // // I18nMainWindow methods. - void virtual_SetupUI() ITK_OVERRIDE; + void virtual_SetupUI() override; - void virtual_ConnectUI() ITK_OVERRIDE; + void virtual_ConnectUI() override; // // Private attributes. diff --git a/Modules/Visualization/Monteverdi/include/mvdApplication.h b/Modules/Visualization/Monteverdi/include/mvdApplication.h index dff4eed963..c9cf8b6e87 100644 --- a/Modules/Visualization/Monteverdi/include/mvdApplication.h +++ b/Modules/Visualization/Monteverdi/include/mvdApplication.h @@ -99,7 +99,7 @@ public: Application( QApplication* qtApp ); /** \brief Destructor. */ - ~Application() ITK_OVERRIDE; + ~Application() override; /** * \return The number of outdated dataset-models present in the @@ -160,7 +160,7 @@ protected: // Protected attributes. protected: - void virtual_InitializeCore() ITK_OVERRIDE; + void virtual_InitializeCore() override; /*-[ PRIVATE SECTION ]-----------------------------------------------------*/ diff --git a/Modules/Visualization/Monteverdi/include/mvdMainWindow.h b/Modules/Visualization/Monteverdi/include/mvdMainWindow.h index f8523b7f5d..3ae223763f 100644 --- a/Modules/Visualization/Monteverdi/include/mvdMainWindow.h +++ b/Modules/Visualization/Monteverdi/include/mvdMainWindow.h @@ -125,7 +125,7 @@ public: MainWindow( QWidget* p =0, Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~MainWindow() ITK_OVERRIDE; + ~MainWindow() override; /** */ @@ -183,7 +183,7 @@ protected: // // QMainWindow methods. - void closeEvent( QCloseEvent* event ) ITK_OVERRIDE; + void closeEvent( QCloseEvent* event ) override; // // Protected attributes. @@ -197,11 +197,11 @@ protected slots: /** */ - void OnAboutToChangeModel( const AbstractModel * ) ITK_OVERRIDE; + void OnAboutToChangeModel( const AbstractModel * ) override; /** */ - void OnModelChanged( AbstractModel * ) ITK_OVERRIDE; + void OnModelChanged( AbstractModel * ) override; /** */ @@ -344,11 +344,11 @@ private: // // I18nMainWindow methods. - void virtual_SetupUI() ITK_OVERRIDE; + void virtual_SetupUI() override; - void virtual_ConnectUI() ITK_OVERRIDE; + void virtual_ConnectUI() override; - void virtual_InitializeUI() ITK_OVERRIDE; + void virtual_InitializeUI() override; // // Private attributes. diff --git a/Modules/Visualization/Monteverdi/include/mvdPreferencesDialog.h b/Modules/Visualization/Monteverdi/include/mvdPreferencesDialog.h index c330308498..25a555cb99 100644 --- a/Modules/Visualization/Monteverdi/include/mvdPreferencesDialog.h +++ b/Modules/Visualization/Monteverdi/include/mvdPreferencesDialog.h @@ -92,7 +92,7 @@ public: PreferencesDialog( QWidget* p =NULL, Qt::WindowFlags flags =0 ); /** Destructor */ - ~PreferencesDialog() ITK_OVERRIDE; + ~PreferencesDialog() override; /*-[ SIGNALS SECTION ]-----------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiCore/include/mvdAbstractImageModel.h b/Modules/Visualization/MonteverdiCore/include/mvdAbstractImageModel.h index 8eff3030eb..d2e6723d4b 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdAbstractImageModel.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdAbstractImageModel.h @@ -171,7 +171,7 @@ public: public: /** Destructor */ - ~AbstractImageModel() ITK_OVERRIDE; + ~AbstractImageModel() override; /** */ inline int GetId() const; @@ -322,7 +322,7 @@ protected: // // AbstractModel methods. - void virtual_BuildModel( void* context ) ITK_OVERRIDE; + void virtual_BuildModel( void* context ) override; // // Protected attributes. diff --git a/Modules/Visualization/MonteverdiCore/include/mvdAbstractLayerModel.h b/Modules/Visualization/MonteverdiCore/include/mvdAbstractLayerModel.h index ab4065a91b..e556edf4c4 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdAbstractLayerModel.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdAbstractLayerModel.h @@ -121,7 +121,7 @@ class OTBMonteverdiCore_EXPORT AbstractLayerModel : public: /** \brief Destructor. */ - ~AbstractLayerModel() ITK_OVERRIDE; + ~AbstractLayerModel() override; /** */ @@ -201,7 +201,7 @@ private: // // VisibleInterface overloads. - void virtual_SignalVisibilityChanged( bool ) ITK_OVERRIDE; + void virtual_SignalVisibilityChanged( bool ) override; // // Private attributes. diff --git a/Modules/Visualization/MonteverdiCore/include/mvdAbstractModel.h b/Modules/Visualization/MonteverdiCore/include/mvdAbstractModel.h index e6b9178c3c..f6f84f3782 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdAbstractModel.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdAbstractModel.h @@ -91,7 +91,7 @@ class OTBMonteverdiCore_EXPORT AbstractModel : public: /** Destructor */ - ~AbstractModel() ITK_OVERRIDE; + ~AbstractModel() override; /** */ template< typename TModel > diff --git a/Modules/Visualization/MonteverdiCore/include/mvdAbstractWorker.h b/Modules/Visualization/MonteverdiCore/include/mvdAbstractWorker.h index 800bbbc130..4ae16dc4ee 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdAbstractWorker.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdAbstractWorker.h @@ -91,7 +91,7 @@ class OTBMonteverdiCore_EXPORT AbstractWorker : public: /** \brief Destructor. */ - ~AbstractWorker() ITK_OVERRIDE; + ~AbstractWorker() override; /** */ diff --git a/Modules/Visualization/MonteverdiCore/include/mvdApplicationsBrowser.h b/Modules/Visualization/MonteverdiCore/include/mvdApplicationsBrowser.h index 68956e666a..eeeb38fc12 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdApplicationsBrowser.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdApplicationsBrowser.h @@ -112,7 +112,7 @@ public: ApplicationsBrowser( QObject* p =NULL ); /** \brief Destructor. */ - ~ApplicationsBrowser() ITK_OVERRIDE; + ~ApplicationsBrowser() override; /** set the path where to look for applications */ void SetAutoLoadPath(const std::string & itk_auto_load_path); diff --git a/Modules/Visualization/MonteverdiCore/include/mvdBackgroundTask.h b/Modules/Visualization/MonteverdiCore/include/mvdBackgroundTask.h index 3baa0ceed2..9fc7805114 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdBackgroundTask.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdBackgroundTask.h @@ -100,7 +100,7 @@ public: /** * \brief Destructor. */ - ~BackgroundTask() ITK_OVERRIDE; + ~BackgroundTask() override; /** */ diff --git a/Modules/Visualization/MonteverdiCore/include/mvdHistogramModel.h b/Modules/Visualization/MonteverdiCore/include/mvdHistogramModel.h index 52d3b56043..aa1aec0371 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdHistogramModel.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdHistogramModel.h @@ -175,7 +175,7 @@ public: HistogramModel( QObject* p =NULL ); /** \brief Destructor. */ - ~HistogramModel() ITK_OVERRIDE; + ~HistogramModel() override; /** */ @@ -234,7 +234,7 @@ protected: // AbstractModel methods. /** */ - void virtual_BuildModel( void* context =NULL ) ITK_OVERRIDE; + void virtual_BuildModel( void* context =NULL ) override; // // Protected attributes. @@ -276,9 +276,9 @@ private: // SerializableInterface methods. // - void virtual_Read( QIODevice* device ) ITK_OVERRIDE; + void virtual_Read( QIODevice* device ) override; - void virtual_Write( QIODevice& device ) const ITK_OVERRIDE; + void virtual_Write( QIODevice& device ) const override; // // Private attributes. diff --git a/Modules/Visualization/MonteverdiCore/include/mvdI18nCoreApplication.h b/Modules/Visualization/MonteverdiCore/include/mvdI18nCoreApplication.h index 52a2f263a7..778030ccdb 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdI18nCoreApplication.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdI18nCoreApplication.h @@ -142,7 +142,7 @@ public: I18nCoreApplication( QCoreApplication* qtApp ); /** \brief Destructor. */ - ~I18nCoreApplication() ITK_OVERRIDE; + ~I18nCoreApplication() override; /** */ diff --git a/Modules/Visualization/MonteverdiCore/include/mvdImageImporter.h b/Modules/Visualization/MonteverdiCore/include/mvdImageImporter.h index ab735e5cc8..00e574ff5a 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdImageImporter.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdImageImporter.h @@ -122,7 +122,7 @@ public: /** * \brief Destructor. */ - ~ImageImporter() ITK_OVERRIDE; + ~ImageImporter() override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ @@ -177,9 +177,9 @@ private: // // AbstractWorker oveloads. - QObject* virtual_Do() ITK_OVERRIDE; + QObject* virtual_Do() override; - QString virtual_GetFirstProgressText() const ITK_OVERRIDE; + QString virtual_GetFirstProgressText() const override; // diff --git a/Modules/Visualization/MonteverdiCore/include/mvdMyClass.h b/Modules/Visualization/MonteverdiCore/include/mvdMyClass.h index 854ebbb31e..2dcf415eb2 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdMyClass.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdMyClass.h @@ -94,7 +94,7 @@ public: MyClass( QObject* p =NULL ); /** \brief Destructor. */ - ~MyClass() ITK_OVERRIDE; + ~MyClass() override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiCore/include/mvdOverviewBuilder.h b/Modules/Visualization/MonteverdiCore/include/mvdOverviewBuilder.h index eb40330126..a7cdbc3330 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdOverviewBuilder.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdOverviewBuilder.h @@ -110,12 +110,12 @@ public: /** * \brief Destructor. */ - ~OverviewBuilder() ITK_OVERRIDE; + ~OverviewBuilder() override; // // ProgressInterface overloads. - void SetProgress( double ) ITK_OVERRIDE; + void SetProgress( double ) override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ @@ -166,9 +166,9 @@ private: // // AbstractWorker oveloads. - QObject * virtual_Do() ITK_OVERRIDE; + QObject * virtual_Do() override; - QString virtual_GetFirstProgressText() const ITK_OVERRIDE; + QString virtual_GetFirstProgressText() const override; // diff --git a/Modules/Visualization/MonteverdiCore/include/mvdProcessObjectObserver.h b/Modules/Visualization/MonteverdiCore/include/mvdProcessObjectObserver.h index b4468924cd..207cec9d22 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdProcessObjectObserver.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdProcessObjectObserver.h @@ -101,7 +101,7 @@ public: public: /** \brief Destructor. */ - ~ProcessObjectObserver() ITK_OVERRIDE; + ~ProcessObjectObserver() override; const ProgressInterface * GetProgressInterface() const; ProgressInterface * GetProgressInterface(); @@ -112,10 +112,10 @@ public: // itk::Command overloads. void Execute( itk::Object * caller, - const itk::EventObject & event ) ITK_OVERRIDE; + const itk::EventObject & event ) override; void Execute( const itk::Object * caller, - const itk::EventObject & event ) ITK_OVERRIDE; + const itk::EventObject & event ) override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiCore/include/mvdQuicklookModel.h b/Modules/Visualization/MonteverdiCore/include/mvdQuicklookModel.h index e34adf8a50..1930cb73d9 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdQuicklookModel.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdQuicklookModel.h @@ -100,7 +100,7 @@ public: QuicklookModel( QObject* p =NULL ); /** Destructor */ - ~QuicklookModel() ITK_OVERRIDE; + ~QuicklookModel() override; /** * \brief Get the parent image-model of this quicklook image as an @@ -161,7 +161,7 @@ signals: protected: /** */ - void virtual_BuildModel( void* context =NULL ) ITK_OVERRIDE; + void virtual_BuildModel( void* context =NULL ) override; // // Protected attributes. diff --git a/Modules/Visualization/MonteverdiCore/include/mvdStackedLayerModel.h b/Modules/Visualization/MonteverdiCore/include/mvdStackedLayerModel.h index 035914cb21..8291038e15 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdStackedLayerModel.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdStackedLayerModel.h @@ -116,7 +116,7 @@ public: StackedLayerModel( QObject* p =NULL ); /** \brief Destructor. */ - ~StackedLayerModel() ITK_OVERRIDE; + ~StackedLayerModel() override; inline const AbstractLayerModel * operator[]( SizeType ) const; inline AbstractLayerModel * operator[]( SizeType ); diff --git a/Modules/Visualization/MonteverdiCore/include/mvdSystemError.h b/Modules/Visualization/MonteverdiCore/include/mvdSystemError.h index b14a1207f4..6fe4b0329d 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdSystemError.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdSystemError.h @@ -96,7 +96,7 @@ public: + ": " + message) {}; /** \brief Destructor. */ - ~SystemError() throw() ITK_OVERRIDE {}; + ~SystemError() throw() override {}; /*-[ PROTECTED SECTION ]---------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiCore/include/mvdVectorImageModel.h b/Modules/Visualization/MonteverdiCore/include/mvdVectorImageModel.h index 29e9aba7e3..a54dfa0fe6 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdVectorImageModel.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdVectorImageModel.h @@ -118,7 +118,7 @@ public: VectorImageModel( QObject* p =NULL ); /** Destructor */ - ~VectorImageModel() ITK_OVERRIDE; + ~VectorImageModel() override; /** */ static void EnsureValidImage( const QString& filename ); @@ -166,17 +166,17 @@ public: /** * Get the number of available LOD. */ - CountType GetNbLod() const ITK_OVERRIDE; + CountType GetNbLod() const override; /** * Get a smart-pointer to the current LOD image-base. */ - ImageBaseType::ConstPointer ToImageBase() const ITK_OVERRIDE; + ImageBaseType::ConstPointer ToImageBase() const override; /** * Get a smart-pointer to the current LOD image-base. */ - ImageBaseType::Pointer ToImageBase() ITK_OVERRIDE; + ImageBaseType::Pointer ToImageBase() override; /** * Get the placename from the center pixel @@ -186,9 +186,9 @@ public: // // AbstractModel methods. - bool IsModified() const ITK_OVERRIDE; + bool IsModified() const override; - void ClearModified() ITK_OVERRIDE; + void ClearModified() override; // get image size in byte std::streamoff GetImageSizeInBytes() @@ -242,7 +242,7 @@ protected: // // AbstractModel methods. - void virtual_BuildModel( void* context =NULL ) ITK_OVERRIDE; + void virtual_BuildModel( void* context =NULL ) override; // // AbstractImageModel methods. @@ -292,18 +292,18 @@ private: // // AbstractLayerModel methods. - std::string virtual_GetWkt() const ITK_OVERRIDE; - bool virtual_HasKwl() const ITK_OVERRIDE; + std::string virtual_GetWkt() const override; + bool virtual_HasKwl() const override; void virtual_ToWgs84( const PointType &, PointType &, - double & alt ) const ITK_OVERRIDE; + double & alt ) const override; // // AbstractImageModel methods. - void virtual_SetCurrentLod( CountType lod ) ITK_OVERRIDE; + void virtual_SetCurrentLod( CountType lod ) override; - void virtual_RefreshHistogram() ITK_OVERRIDE; + void virtual_RefreshHistogram() override; // // Private attributes. diff --git a/Modules/Visualization/MonteverdiCore/include/mvdVectorImageSettings.h b/Modules/Visualization/MonteverdiCore/include/mvdVectorImageSettings.h index 441ffdca5f..01c78d04f6 100644 --- a/Modules/Visualization/MonteverdiCore/include/mvdVectorImageSettings.h +++ b/Modules/Visualization/MonteverdiCore/include/mvdVectorImageSettings.h @@ -110,7 +110,7 @@ public: /** * \brief Destructor. */ - ~VectorImageSettings() ITK_OVERRIDE; + ~VectorImageSettings() override; /** * \brief Assignment operator. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdAboutDialog.h b/Modules/Visualization/MonteverdiGui/include/mvdAboutDialog.h index b8ee19010e..10be3b5e7d 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdAboutDialog.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdAboutDialog.h @@ -77,7 +77,7 @@ public: AboutDialog( QWidget* p =NULL, Qt::WindowFlags flags =0 ); /** Destructor */ - ~AboutDialog() ITK_OVERRIDE; + ~AboutDialog() override; // // SIGNALS. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdAbstractDragAndDropEventFilter.h b/Modules/Visualization/MonteverdiGui/include/mvdAbstractDragAndDropEventFilter.h index babdc18145..8b9169530e 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdAbstractDragAndDropEventFilter.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdAbstractDragAndDropEventFilter.h @@ -90,7 +90,7 @@ class OTBMonteverdiGUI_EXPORT AbstractDragAndDropEventFilter : public: /** \brief Destructor. */ - ~AbstractDragAndDropEventFilter() ITK_OVERRIDE; + ~AbstractDragAndDropEventFilter() override; // // QObject overloads. @@ -98,7 +98,7 @@ public: /** * \see http://qt-project.org/doc/qt-4.8/qobject.html#eventFilter */ - bool eventFilter( QObject* watched, QEvent* event ) ITK_OVERRIDE; + bool eventFilter( QObject* watched, QEvent* event ) override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdAbstractImageViewManipulator.h b/Modules/Visualization/MonteverdiGui/include/mvdAbstractImageViewManipulator.h index 3d34198cef..28b2038b25 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdAbstractImageViewManipulator.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdAbstractImageViewManipulator.h @@ -90,7 +90,7 @@ class OTBMonteverdiGUI_EXPORT AbstractImageViewManipulator : public: /** \brief Destructor. */ - ~AbstractImageViewManipulator() ITK_OVERRIDE {}; + ~AbstractImageViewManipulator() override {}; // // Accessors diff --git a/Modules/Visualization/MonteverdiGui/include/mvdAbstractImageViewRenderer.h b/Modules/Visualization/MonteverdiGui/include/mvdAbstractImageViewRenderer.h index 28a6891f2c..eb0a0f26ba 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdAbstractImageViewRenderer.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdAbstractImageViewRenderer.h @@ -122,7 +122,7 @@ public: /** * Destructor. */ - ~AbstractImageViewRenderer() ITK_OVERRIDE{}; + ~AbstractImageViewRenderer() override{}; /** */ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdAbstractModelController.h b/Modules/Visualization/MonteverdiGui/include/mvdAbstractModelController.h index fbefaee858..01c38d2725 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdAbstractModelController.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdAbstractModelController.h @@ -90,7 +90,7 @@ public: public: /** Destructor */ - ~AbstractModelController() ITK_OVERRIDE; + ~AbstractModelController() override; /** */ void SetModel( AbstractModel* ); diff --git a/Modules/Visualization/MonteverdiGui/include/mvdApplicationLauncher.h b/Modules/Visualization/MonteverdiGui/include/mvdApplicationLauncher.h index 8e5e155b3a..47ae4d2c8c 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdApplicationLauncher.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdApplicationLauncher.h @@ -96,7 +96,7 @@ public: ApplicationLauncher( QObject* p =NULL ); /** \brief Destructor. */ - ~ApplicationLauncher() ITK_OVERRIDE; + ~ApplicationLauncher() override; /** * \return A new instance of the automatically-generated widget of diff --git a/Modules/Visualization/MonteverdiGui/include/mvdApplicationsToolBox.h b/Modules/Visualization/MonteverdiGui/include/mvdApplicationsToolBox.h index 2cc6cc13e5..64b9939b0f 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdApplicationsToolBox.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdApplicationsToolBox.h @@ -99,7 +99,7 @@ public: ApplicationsToolBox( QWidget* p =NULL, Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~ApplicationsToolBox() ITK_OVERRIDE; + ~ApplicationsToolBox() override; /** Get TreeWidget */ // QTreeWidget * GetAlgorithmsTree(); diff --git a/Modules/Visualization/MonteverdiGui/include/mvdApplicationsToolBoxController.h b/Modules/Visualization/MonteverdiGui/include/mvdApplicationsToolBoxController.h index b8f36d5db6..2c9c3209c8 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdApplicationsToolBoxController.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdApplicationsToolBoxController.h @@ -105,7 +105,7 @@ public: /** * \brief Destructor. */ - ~ApplicationsToolBoxController() ITK_OVERRIDE; + ~ApplicationsToolBoxController() override; /** Get the seleceted application Gui */ // QWidget * GetSelectedApplicationWidget(const QString& appName); @@ -126,13 +126,13 @@ protected: // // AbstractModelController methods. - void Connect( AbstractModel* ) ITK_OVERRIDE; + void Connect( AbstractModel* ) override; - void ClearWidget() ITK_OVERRIDE; + void ClearWidget() override; - void virtual_ResetWidget( bool ) ITK_OVERRIDE; + void virtual_ResetWidget( bool ) override; - void Disconnect( AbstractModel* ) ITK_OVERRIDE; + void Disconnect( AbstractModel* ) override; // // Protected attributes. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdColorBandDynamicsWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdColorBandDynamicsWidget.h index 1130f1b106..57695a9051 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdColorBandDynamicsWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdColorBandDynamicsWidget.h @@ -142,7 +142,7 @@ public: ColorBandDynamicsWidget( QWidget* p =NULL, Qt::WindowFlags flags =0 ); /** Destructor */ - ~ColorBandDynamicsWidget() ITK_OVERRIDE; + ~ColorBandDynamicsWidget() override; /** */ RgbwChannel GetChannelLabel() const; diff --git a/Modules/Visualization/MonteverdiGui/include/mvdColorDynamicsController.h b/Modules/Visualization/MonteverdiGui/include/mvdColorDynamicsController.h index 4acdf66eb8..2fe26daa79 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdColorDynamicsController.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdColorDynamicsController.h @@ -98,7 +98,7 @@ public: ColorDynamicsController( ColorDynamicsWidget* widget, QObject* p =NULL ); /** \brief Destructor. */ - ~ColorDynamicsController() ITK_OVERRIDE; + ~ColorDynamicsController() override; /*-[ PUBLIC SLOTS SECTION ]-----------------------------------------------**/ @@ -168,13 +168,13 @@ private: // // AbstractModelController methods. - void Connect( AbstractModel* ) ITK_OVERRIDE; + void Connect( AbstractModel* ) override; - void ClearWidget() ITK_OVERRIDE; + void ClearWidget() override; - void virtual_ResetWidget( bool ) ITK_OVERRIDE; + void virtual_ResetWidget( bool ) override; - void Disconnect( AbstractModel* ) ITK_OVERRIDE; + void Disconnect( AbstractModel* ) override; /** * \brief Reset intensity ranges to default values for given RGB diff --git a/Modules/Visualization/MonteverdiGui/include/mvdColorDynamicsWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdColorDynamicsWidget.h index 4866fc70d5..288005ce89 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdColorDynamicsWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdColorDynamicsWidget.h @@ -122,7 +122,7 @@ public: ColorDynamicsWidget( QWidget* p =NULL, Qt::WindowFlags flags =0 ); /** Destructor. */ - ~ColorDynamicsWidget() ITK_OVERRIDE; + ~ColorDynamicsWidget() override; /** */ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdColorSetupController.h b/Modules/Visualization/MonteverdiGui/include/mvdColorSetupController.h index d9f6ff02d0..aadf7f3920 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdColorSetupController.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdColorSetupController.h @@ -100,7 +100,7 @@ public: /** * \brief Destructor. */ - ~ColorSetupController() ITK_OVERRIDE; + ~ColorSetupController() override; /*-[ SIGNALS SECTION ]-----------------------------------------------------*/ @@ -168,13 +168,13 @@ private: // // AbstractModelController methods. - void Connect( AbstractModel* ) ITK_OVERRIDE; + void Connect( AbstractModel* ) override; - void ClearWidget() ITK_OVERRIDE; + void ClearWidget() override; - void virtual_ResetWidget( bool ) ITK_OVERRIDE; + void virtual_ResetWidget( bool ) override; - void Disconnect( AbstractModel* ) ITK_OVERRIDE; + void Disconnect( AbstractModel* ) override; // // Private attributes. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdColorSetupWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdColorSetupWidget.h index 1a09ed3c10..ae1cd0331c 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdColorSetupWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdColorSetupWidget.h @@ -89,7 +89,7 @@ public: ColorSetupWidget( QWidget* p =NULL, Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~ColorSetupWidget() ITK_OVERRIDE; + ~ColorSetupWidget() override; /** * \brief Set the component-name list. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdDoubleValidator.h b/Modules/Visualization/MonteverdiGui/include/mvdDoubleValidator.h index 8872a4ce90..bb17e54a05 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdDoubleValidator.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdDoubleValidator.h @@ -99,12 +99,12 @@ public: QObject *p = 0 ); /** \brief Destructor. */ - ~DoubleValidator() ITK_OVERRIDE; + ~DoubleValidator() override; // // QDoubleValidator overloads. - void fixup( QString& input ) const ITK_OVERRIDE; + void fixup( QString& input ) const override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdDropLineEdit.h b/Modules/Visualization/MonteverdiGui/include/mvdDropLineEdit.h index 4c2a83be25..837b28795e 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdDropLineEdit.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdDropLineEdit.h @@ -100,7 +100,7 @@ public: DropLineEdit( const QString& contents, QWidget* p =0 ); /** \brief Destructor. */ - ~DropLineEdit() ITK_OVERRIDE; + ~DropLineEdit() override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ @@ -120,9 +120,9 @@ signals: // Protected methods. protected: - void dragEnterEvent( QDragEnterEvent* event ) ITK_OVERRIDE; - void dragMoveEvent( QDragMoveEvent* event ) ITK_OVERRIDE; - void dropEvent( QDropEvent* event ) ITK_OVERRIDE; + void dragEnterEvent( QDragEnterEvent* event ) override; + void dragMoveEvent( QDragMoveEvent* event ) override; + void dropEvent( QDropEvent* event ) override; /*-[ PRIVATE SECTION ]-----------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdFilenameDragAndDropEventFilter.h b/Modules/Visualization/MonteverdiGui/include/mvdFilenameDragAndDropEventFilter.h index 9595df1c0c..003d313a56 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdFilenameDragAndDropEventFilter.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdFilenameDragAndDropEventFilter.h @@ -93,7 +93,7 @@ public: FilenameDragAndDropEventFilter( QObject* p =NULL ); /** \brief Destructor. */ - ~FilenameDragAndDropEventFilter() ITK_OVERRIDE; + ~FilenameDragAndDropEventFilter() override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ @@ -125,22 +125,22 @@ protected: /** * \see http://qt-project.org/doc/qt-4.8/qwidget.html#dragEnterEvent */ - bool DragEnterEvent( QObject* object, QDragEnterEvent* event ) ITK_OVERRIDE; + bool DragEnterEvent( QObject* object, QDragEnterEvent* event ) override; /** * \see http://qt-project.org/doc/qt-4.8/qwidget.html#dragLeaveEvent */ - bool DragLeaveEvent( QObject* object, QDragLeaveEvent* event ) ITK_OVERRIDE; + bool DragLeaveEvent( QObject* object, QDragLeaveEvent* event ) override; /** * \see http://qt-project.org/doc/qt-4.8/qwidget.html#dragMoveEvent */ - bool DragMoveEvent( QObject* object, QDragMoveEvent* event ) ITK_OVERRIDE; + bool DragMoveEvent( QObject* object, QDragMoveEvent* event ) override; /** * \see http://qt-project.org/doc/qt-4.8/qwidget.html#dropEvent */ - bool DropEvent( QObject* object, QDropEvent* event ) ITK_OVERRIDE; + bool DropEvent( QObject* object, QDropEvent* event ) override; // // Protected attributes. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdHistogramController.h b/Modules/Visualization/MonteverdiGui/include/mvdHistogramController.h index a28ba38fe7..2416c58ddd 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdHistogramController.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdHistogramController.h @@ -101,7 +101,7 @@ public: /** * \brief Destructor. */ - ~HistogramController() ITK_OVERRIDE; + ~HistogramController() override; /*-[ SIGNALS SECTION ]-----------------------------------------------------*/ @@ -134,13 +134,13 @@ private: // // AbstractModelController methods. - void Connect( AbstractModel* ) ITK_OVERRIDE; + void Connect( AbstractModel* ) override; - void ClearWidget() ITK_OVERRIDE; + void ClearWidget() override; - void virtual_ResetWidget( bool = false ) ITK_OVERRIDE; + void virtual_ResetWidget( bool = false ) override; - void Disconnect( AbstractModel* ) ITK_OVERRIDE; + void Disconnect( AbstractModel* ) override; // // Private attributes. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdHistogramPlotPicker.h b/Modules/Visualization/MonteverdiGui/include/mvdHistogramPlotPicker.h index 0e58a1f5d8..d7a3690c12 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdHistogramPlotPicker.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdHistogramPlotPicker.h @@ -123,7 +123,7 @@ public: QwtPlotCanvas* canvas ); /** \brief Destructor. */ - ~HistogramPlotPicker() ITK_OVERRIDE; + ~HistogramPlotPicker() override; /** */ @@ -136,7 +136,7 @@ public: // // QwtPlotPicker methods. - void drawRubberBand( QPainter* painter ) const ITK_OVERRIDE; + void drawRubberBand( QPainter* painter ) const override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ @@ -161,7 +161,7 @@ protected: using QwtPlotPicker::trackerText; - QwtText trackerTextF( const QPointF & ) const ITK_OVERRIDE; + QwtText trackerTextF( const QPointF & ) const override; // // Protected attributes. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdHistogramWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdHistogramWidget.h index cbda62ba08..91f9d90f44 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdHistogramWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdHistogramWidget.h @@ -113,7 +113,7 @@ public: HistogramWidget( QWidget* p =NULL, Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~HistogramWidget() ITK_OVERRIDE; + ~HistogramWidget() override; /** * \brief diff --git a/Modules/Visualization/MonteverdiGui/include/mvdI18nApplication.h b/Modules/Visualization/MonteverdiGui/include/mvdI18nApplication.h index 39e9b08f97..8fdcb9e941 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdI18nApplication.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdI18nApplication.h @@ -105,7 +105,7 @@ public: I18nApplication( QApplication* qtApp ); /** \brief Destructor. */ - ~I18nApplication() ITK_OVERRIDE; + ~I18nApplication() override; // // APPLICATION SINGLETON. @@ -147,7 +147,7 @@ signals: // Protected methods. protected: - void virtual_InitializeCore() ITK_OVERRIDE; + void virtual_InitializeCore() override; // // Protected attributes. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdI18nMainWindow.h b/Modules/Visualization/MonteverdiGui/include/mvdI18nMainWindow.h index e4414dfac5..15af81cc82 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdI18nMainWindow.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdI18nMainWindow.h @@ -103,7 +103,7 @@ public: // Public methods. public: /** \brief Destructor. */ - ~I18nMainWindow() ITK_OVERRIDE; + ~I18nMainWindow() override; /** */ @@ -194,7 +194,7 @@ protected: // // QMainWindow methods. - void closeEvent( QCloseEvent* event ) ITK_OVERRIDE; + void closeEvent( QCloseEvent* event ) override; // // Protected attributes. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdImageViewManipulator.h b/Modules/Visualization/MonteverdiGui/include/mvdImageViewManipulator.h index 477e50206e..ed63a785f3 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdImageViewManipulator.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdImageViewManipulator.h @@ -123,7 +123,7 @@ public: #endif // USE_VIEW_SETTINGS_SIDE_EFFECT /** \brief Destructor. */ - ~ImageViewManipulator() ITK_OVERRIDE; + ~ImageViewManipulator() override; // // AbstractImageViewManipulator overloads. @@ -132,29 +132,29 @@ public: // // Accessors. - void SetViewportSize( int width, int height ) ITK_OVERRIDE; + void SetViewportSize( int width, int height ) override; - SizeType GetViewportSize() const ITK_OVERRIDE; + SizeType GetViewportSize() const override; - void SetOrigin( const PointType& origin ) ITK_OVERRIDE; + void SetOrigin( const PointType& origin ) override; - PointType GetOrigin() const ITK_OVERRIDE; + PointType GetOrigin() const override; - void SetSpacing( const SpacingType& spacing ) ITK_OVERRIDE; + void SetSpacing( const SpacingType& spacing ) override; - SpacingType GetSpacing() const ITK_OVERRIDE; + SpacingType GetSpacing() const override; - void SetNativeSpacing( const SpacingType& ) ITK_OVERRIDE; + void SetNativeSpacing( const SpacingType& ) override; - void SetWkt( const std::string& wkt ) ITK_OVERRIDE; + void SetWkt( const std::string& wkt ) override; void SetKeywordList( const DefaultImageType::ImageKeywordlistType& kwl - ) ITK_OVERRIDE; + ) override; - PointType GetCenter() const ITK_OVERRIDE; + PointType GetCenter() const override; - ZoomType GetFixedZoomType() const ITK_OVERRIDE; + ZoomType GetFixedZoomType() const override; // // Controls. @@ -162,34 +162,34 @@ public: void SetupRenderingContext( - AbstractImageViewRenderer::RenderingContext * const ) const ITK_OVERRIDE; + AbstractImageViewRenderer::RenderingContext * const ) const override; - void ZoomIn() ITK_OVERRIDE; + void ZoomIn() override; - void ZoomOut() ITK_OVERRIDE; + void ZoomOut() override; - const PointType& Transform( PointType&, const QPoint& ) const ITK_OVERRIDE; + const PointType& Transform( PointType&, const QPoint& ) const override; - void ResetViewport() ITK_OVERRIDE; + void ResetViewport() override; // // Events. - void MouseMoveEvent( QMouseEvent* event ) ITK_OVERRIDE; + void MouseMoveEvent( QMouseEvent* event ) override; - void MousePressEvent( QMouseEvent* event ) ITK_OVERRIDE; + void MousePressEvent( QMouseEvent* event ) override; - void MouseReleaseEvent( QMouseEvent* event ) ITK_OVERRIDE; + void MouseReleaseEvent( QMouseEvent* event ) override; - void MouseDoubleClickEvent( QMouseEvent * ) ITK_OVERRIDE; + void MouseDoubleClickEvent( QMouseEvent * ) override; - void WheelEvent( QWheelEvent* event) ITK_OVERRIDE; + void WheelEvent( QWheelEvent* event) override; - void ResizeEvent( QResizeEvent* event ) ITK_OVERRIDE; + void ResizeEvent( QResizeEvent* event ) override; - void KeyPressEvent( QKeyEvent* event ) ITK_OVERRIDE; + void KeyPressEvent( QKeyEvent* event ) override; - void KeyReleaseEvent( QKeyEvent* event ) ITK_OVERRIDE; + void KeyReleaseEvent( QKeyEvent* event ) override; /*-[ PUBLIC SLOTS SECTION ]-----------------------------------------------**/ @@ -200,9 +200,9 @@ public slots: // // AbstractImageViewManipulator overloads. - void CenterOn( const PointType& point ) ITK_OVERRIDE; + void CenterOn( const PointType& point ) override; - void ZoomTo( double scale ) ITK_OVERRIDE; + void ZoomTo( double scale ) override; /*-[ SIGNALS SECTION ]-----------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdImageViewRenderer.h b/Modules/Visualization/MonteverdiGui/include/mvdImageViewRenderer.h index c1d68cc82e..e8c3599d33 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdImageViewRenderer.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdImageViewRenderer.h @@ -111,7 +111,7 @@ public: /** */ - ~RenderingContext() ITK_OVERRIDE; + ~RenderingContext() override; /** */ @@ -136,11 +136,11 @@ public: ImageViewRenderer( QObject* p = NULL ); /** Destructor */ - ~ImageViewRenderer() ITK_OVERRIDE; + ~ImageViewRenderer() override; /** */ - bool CheckGLCapabilities( int * ) ITK_OVERRIDE; + bool CheckGLCapabilities( int * ) override; /** */ @@ -154,43 +154,43 @@ public: bool GetLayerDynamics( const StackedLayerModel::KeyType & key, ParametersType & params, - bool isGlobal ) const ITK_OVERRIDE; + bool isGlobal ) const override; - const AbstractLayerModel* GetReferenceModel() const ITK_OVERRIDE; + const AbstractLayerModel* GetReferenceModel() const override; - AbstractLayerModel * GetReferenceModel() ITK_OVERRIDE; + AbstractLayerModel * GetReferenceModel() override; void GetLayerExtent( const StackedLayerModel::KeyType & key, PointType& origin, - PointType& extent ) const ITK_OVERRIDE; + PointType& extent ) const override; void GetReferenceExtent( PointType& origin, - PointType& extent ) const ITK_OVERRIDE; + PointType& extent ) const override; void GetViewExtent( PointType& origin, - PointType& extent ) const ITK_OVERRIDE; + PointType& extent ) const override; - AbstractImageViewRenderer::RenderingContext* NewRenderingContext() const ITK_OVERRIDE; + AbstractImageViewRenderer::RenderingContext* NewRenderingContext() const override; - void InitializeGL() ITK_OVERRIDE; + void InitializeGL() override; - void ResizeGL( int width, int height ) ITK_OVERRIDE; + void ResizeGL( int width, int height ) override; - void PaintGL( const AbstractImageViewRenderer::RenderingContext* context ) ITK_OVERRIDE; + void PaintGL( const AbstractImageViewRenderer::RenderingContext* context ) override; void Pick( const PointType & view, - PixelInfo::Vector & pixels ) const ITK_OVERRIDE; + PixelInfo::Vector & pixels ) const override; - void GetResolutions( PixelInfo::Vector & pixels ) const ITK_OVERRIDE; + void GetResolutions( PixelInfo::Vector & pixels ) const override; bool TransformToView( PointType & point, const StackedLayerModel::KeyType &, const IndexType &, - bool isPhysical ) const ITK_OVERRIDE; + bool isPhysical ) const override; - void SaveScreenshot( const QString & ) const ITK_OVERRIDE; + void SaveScreenshot( const QString & ) const override; bool Reproject( PointType & center, @@ -198,7 +198,7 @@ public: const PointType & vcenter, const SpacingType & vspacing ) const; - bool IsEffectsEnabled() const ITK_OVERRIDE; + bool IsEffectsEnabled() const override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ @@ -206,7 +206,7 @@ public: public slots: void UpdatePixelInfo( const QPoint & screen, const PointType & view, - const PixelInfo::Vector & pixels ) ITK_OVERRIDE; + const PixelInfo::Vector & pixels ) override; /*-[ SIGNALS SECTION ]-----------------------------------------------------*/ @@ -271,24 +271,24 @@ private: // // AbstractImageViewRenderer overloads. - void virtual_ClearScene( bool ) ITK_OVERRIDE; - void virtual_UpdateScene() ITK_OVERRIDE; - void virtual_RefreshScene() ITK_OVERRIDE; + void virtual_ClearScene( bool ) override; + void virtual_UpdateScene() override; + void virtual_RefreshScene() override; bool virtual_ZoomToRegion( const PointType & origin, const PointType & extent, PointType & center, - SpacingType & spacing ) const ITK_OVERRIDE; + SpacingType & spacing ) const override; - bool virtual_ZoomToExtent( PointType & center, SpacingType & spacing ) const ITK_OVERRIDE; + bool virtual_ZoomToExtent( PointType & center, SpacingType & spacing ) const override; bool virtual_ZoomToLayer( const StackedLayerModel::KeyType & key, PointType & center, - SpacingType & spacing ) const ITK_OVERRIDE; + SpacingType & spacing ) const override; bool virtual_ZoomToFull( const StackedLayerModel::KeyType & key, PointType & center, - SpacingType & spacing ) const ITK_OVERRIDE; + SpacingType & spacing ) const override; // // Private attributes. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdImageViewWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdImageViewWidget.h index c32699f712..9c917ec68f 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdImageViewWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdImageViewWidget.h @@ -117,7 +117,7 @@ public: Qt::WindowFlags f =0 ); /** \brief Destructor. */ - ~ImageViewWidget() ITK_OVERRIDE; + ~ImageViewWidget() override; /** */ @@ -255,21 +255,21 @@ protected: // // Qt overloads. - void initializeGL() ITK_OVERRIDE; - void resizeGL( int widgth, int height ) ITK_OVERRIDE; - void paintGL() ITK_OVERRIDE; + void initializeGL() override; + void resizeGL( int widgth, int height ) override; + void paintGL() override; - void mouseMoveEvent( QMouseEvent* event ) ITK_OVERRIDE; - void mouseReleaseEvent( QMouseEvent* event ) ITK_OVERRIDE; - void mousePressEvent( QMouseEvent* event ) ITK_OVERRIDE; - void mouseDoubleClickEvent( QMouseEvent * event ) ITK_OVERRIDE; + void mouseMoveEvent( QMouseEvent* event ) override; + void mouseReleaseEvent( QMouseEvent* event ) override; + void mousePressEvent( QMouseEvent* event ) override; + void mouseDoubleClickEvent( QMouseEvent * event ) override; - void wheelEvent( QWheelEvent* event) ITK_OVERRIDE; + void wheelEvent( QWheelEvent* event) override; - void keyPressEvent( QKeyEvent* event ) ITK_OVERRIDE; - void keyReleaseEvent( QKeyEvent* event ) ITK_OVERRIDE; + void keyPressEvent( QKeyEvent* event ) override; + void keyReleaseEvent( QKeyEvent* event ) override; - void resizeEvent( QResizeEvent* event ) ITK_OVERRIDE; + void resizeEvent( QResizeEvent* event ) override; // diff --git a/Modules/Visualization/MonteverdiGui/include/mvdImportImagesDialog.h b/Modules/Visualization/MonteverdiGui/include/mvdImportImagesDialog.h index 0441b49919..bee6287291 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdImportImagesDialog.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdImportImagesDialog.h @@ -105,7 +105,7 @@ public: Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~ImportImagesDialog() ITK_OVERRIDE; + ~ImportImagesDialog() override; /** */ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdImportSubDatasetDialog.h b/Modules/Visualization/MonteverdiGui/include/mvdImportSubDatasetDialog.h index e1fe0659cf..09b2b13149 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdImportSubDatasetDialog.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdImportSubDatasetDialog.h @@ -104,7 +104,7 @@ public: Qt::WindowFlags flags = 0 ); /** \brief Destructor. */ - ~ImportSubDatasetDialog() ITK_OVERRIDE; + ~ImportSubDatasetDialog() override; /** */ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdKeymapDialog.h b/Modules/Visualization/MonteverdiGui/include/mvdKeymapDialog.h index 3d8400db1d..3abb2722f5 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdKeymapDialog.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdKeymapDialog.h @@ -77,7 +77,7 @@ public: KeymapDialog( QWidget* p =NULL, Qt::WindowFlags flags =0 ); /** Destructor */ - ~KeymapDialog() ITK_OVERRIDE; + ~KeymapDialog() override; // // SIGNALS. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdLayerStackController.h b/Modules/Visualization/MonteverdiGui/include/mvdLayerStackController.h index 084945ebe4..80af1a4f8e 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdLayerStackController.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdLayerStackController.h @@ -93,7 +93,7 @@ public: LayerStackController( LayerStackWidget * widget, QObject * p =NULL ); /** \brief Destructor. */ - ~LayerStackController() ITK_OVERRIDE; + ~LayerStackController() override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ @@ -135,19 +135,19 @@ private: /** */ - void Connect( AbstractModel * ) ITK_OVERRIDE; + void Connect( AbstractModel * ) override; /** */ - void Disconnect( AbstractModel * ) ITK_OVERRIDE; + void Disconnect( AbstractModel * ) override; /** */ - void ClearWidget() ITK_OVERRIDE; + void ClearWidget() override; /** */ - void virtual_ResetWidget( bool ) ITK_OVERRIDE; + void virtual_ResetWidget( bool ) override; // diff --git a/Modules/Visualization/MonteverdiGui/include/mvdLayerStackItemModel.h b/Modules/Visualization/MonteverdiGui/include/mvdLayerStackItemModel.h index 97f096ad9f..44b557b5cd 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdLayerStackItemModel.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdLayerStackItemModel.h @@ -136,7 +136,7 @@ public: LayerStackItemModel( QObject* p =NULL ); /** \brief Destructor. */ - ~LayerStackItemModel() ITK_OVERRIDE; + ~LayerStackItemModel() override; /** */ @@ -152,13 +152,13 @@ public: /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#columnCount */ - int columnCount( const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; + int columnCount( const QModelIndex & p = QModelIndex() ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#data */ QVariant - data( const QModelIndex & index, int role = Qt::DisplayRole ) const ITK_OVERRIDE; + data( const QModelIndex & index, int role = Qt::DisplayRole ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#dropMimeData @@ -168,24 +168,24 @@ public: Qt::DropAction action, int row, int column, - const QModelIndex & p ) ITK_OVERRIDE; + const QModelIndex & p ) override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#flags */ - Qt::ItemFlags flags( const QModelIndex & index ) const ITK_OVERRIDE; + Qt::ItemFlags flags( const QModelIndex & index ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#hasChildren */ - bool hasChildren( const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; + bool hasChildren( const QModelIndex & p = QModelIndex() ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#headerData */ QVariant headerData( int section, Qt::Orientation orientation, - int role = Qt::DisplayRole ) const ITK_OVERRIDE; + int role = Qt::DisplayRole ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#index @@ -193,7 +193,7 @@ public: QModelIndex index( int row, int column, - const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; + const QModelIndex & p = QModelIndex() ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#insertRows @@ -201,22 +201,22 @@ public: bool insertRows( int row, int count, - const QModelIndex & p = QModelIndex() ) ITK_OVERRIDE; + const QModelIndex & p = QModelIndex() ) override; /** * \see http://doc.qt.io/qt-4.8/qabstractitemmodel.html#mimeData */ - QMimeData * mimeData( const QModelIndexList & indexes ) const ITK_OVERRIDE; + QMimeData * mimeData( const QModelIndexList & indexes ) const override; /** * \see http://doc.qt.io/qt-4.8/qabstractitemmodel.html#mimeTypes */ - QStringList mimeTypes() const ITK_OVERRIDE; + QStringList mimeTypes() const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#parent */ - QModelIndex parent( const QModelIndex & index ) const ITK_OVERRIDE; + QModelIndex parent( const QModelIndex & index ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#removeRows @@ -224,12 +224,12 @@ public: bool removeRows( int row, int count, - const QModelIndex & p = QModelIndex() ) ITK_OVERRIDE; + const QModelIndex & p = QModelIndex() ) override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#rowCount */ - int rowCount( const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; + int rowCount( const QModelIndex & p = QModelIndex() ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#setData @@ -237,12 +237,12 @@ public: bool setData( const QModelIndex & index, const QVariant & value, - int role = Qt::EditRole ) ITK_OVERRIDE; + int role = Qt::EditRole ) override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#supportedDropActions */ - Qt::DropActions supportedDropActions() const ITK_OVERRIDE; + Qt::DropActions supportedDropActions() const override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdLayerStackWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdLayerStackWidget.h index 25b402072c..0eb357d2f2 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdLayerStackWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdLayerStackWidget.h @@ -99,7 +99,7 @@ public: LayerStackWidget( QWidget* p =NULL, Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~LayerStackWidget() ITK_OVERRIDE; + ~LayerStackWidget() override; /** */ @@ -146,7 +146,7 @@ public: /** * \see http://qt-project.org/doc/qt-4.8/qobject.html#eventFilter */ - bool eventFilter( QObject * watched, QEvent * event ) ITK_OVERRIDE; + bool eventFilter( QObject * watched, QEvent * event ) override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdMultiResolutionPyramidWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdMultiResolutionPyramidWidget.h index 0ff225da38..52e4995814 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdMultiResolutionPyramidWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdMultiResolutionPyramidWidget.h @@ -100,7 +100,7 @@ public: Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~MultiResolutionPyramidWidget() ITK_OVERRIDE; + ~MultiResolutionPyramidWidget() override; /** */ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdOTBApplicationsModel.h b/Modules/Visualization/MonteverdiGui/include/mvdOTBApplicationsModel.h index 25c96da09a..89a0a78503 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdOTBApplicationsModel.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdOTBApplicationsModel.h @@ -99,7 +99,7 @@ public: OTBApplicationsModel( QObject* p =NULL ); /** \brief Destructor. */ - ~OTBApplicationsModel() ITK_OVERRIDE; + ~OTBApplicationsModel() override; /** \brief Fill Widget Tree */ void FillTree(); @@ -135,7 +135,7 @@ protected: // // AbstractModel methods. - void virtual_BuildModel( void* context =NULL ) ITK_OVERRIDE; + void virtual_BuildModel( void* context =NULL ) override; // // Protected attributes. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdPixelDescriptionWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdPixelDescriptionWidget.h index 615ba575e1..94addba237 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdPixelDescriptionWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdPixelDescriptionWidget.h @@ -95,7 +95,7 @@ public: PixelDescriptionWidget( QWidget* p =NULL, Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~PixelDescriptionWidget() ITK_OVERRIDE; + ~PixelDescriptionWidget() override; /** Get TreeWidget */ QTreeWidget * GetDescriptionTree(); diff --git a/Modules/Visualization/MonteverdiGui/include/mvdProjectionBarWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdProjectionBarWidget.h index be92647e61..c934d84dad 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdProjectionBarWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdProjectionBarWidget.h @@ -82,7 +82,7 @@ public: explicit ProjectionBarWidget(QWidget *p = NULL, Qt::WindowFlags flags = Qt::Widget ); /** \brief Destructor. */ - ~ProjectionBarWidget() ITK_OVERRIDE; + ~ProjectionBarWidget() override; public slots: void SetProjectionScale(double scale_x, double scale_y); diff --git a/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetView.h b/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetView.h index 9aba72c53a..c55664e2dc 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetView.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetView.h @@ -110,7 +110,7 @@ public: Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~QtWidgetView() ITK_OVERRIDE; + ~QtWidgetView() override; /** \brief Gui Creation. */ void CreateGui(); @@ -163,7 +163,7 @@ protected: // // QWidget overloads. - void closeEvent( QCloseEvent * event ) ITK_OVERRIDE; + void closeEvent( QCloseEvent * event ) override; // // Protected attributes. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdQuicklookViewManipulator.h b/Modules/Visualization/MonteverdiGui/include/mvdQuicklookViewManipulator.h index 052a39a470..a3ef9066d0 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdQuicklookViewManipulator.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdQuicklookViewManipulator.h @@ -98,36 +98,36 @@ public: #endif // USE_VIEW_SETTINGS_SIDE_EFFECT /** \brief Destructor. */ - ~QuicklookViewManipulator() ITK_OVERRIDE; + ~QuicklookViewManipulator() override; // // ImageViewManipulator overloads. - ZoomType GetFixedZoomType() const ITK_OVERRIDE; + ZoomType GetFixedZoomType() const override; void SetupRenderingContext( - AbstractImageViewRenderer::RenderingContext * const ) const ITK_OVERRIDE; + AbstractImageViewRenderer::RenderingContext * const ) const override; - void MousePressEvent( QMouseEvent* event ) ITK_OVERRIDE; + void MousePressEvent( QMouseEvent* event ) override; - void MouseMoveEvent( QMouseEvent* event ) ITK_OVERRIDE; + void MouseMoveEvent( QMouseEvent* event ) override; // virtual void MousePressEvent( QMouseEvent* event ); // virtual void MouseReleaseEvent( QMouseEvent* event ); - void MouseDoubleClickEvent( QMouseEvent * ) ITK_OVERRIDE {}; + void MouseDoubleClickEvent( QMouseEvent * ) override {}; - void WheelEvent( QWheelEvent* event) ITK_OVERRIDE; + void WheelEvent( QWheelEvent* event) override; - void ResizeEvent( QResizeEvent * event ) ITK_OVERRIDE; + void ResizeEvent( QResizeEvent * event ) override; - void KeyPressEvent( QKeyEvent* event ) ITK_OVERRIDE; + void KeyPressEvent( QKeyEvent* event ) override; - void KeyReleaseEvent( QKeyEvent* event ) ITK_OVERRIDE; + void KeyReleaseEvent( QKeyEvent* event ) override; /*-[ PUBLIC SLOTS SECTION ]-----------------------------------------------**/ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdQuicklookViewRenderer.h b/Modules/Visualization/MonteverdiGui/include/mvdQuicklookViewRenderer.h index 5c86c1f943..d0124848c2 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdQuicklookViewRenderer.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdQuicklookViewRenderer.h @@ -108,7 +108,7 @@ public: m_RoiOrigin.Fill( 0 ); } - ~RenderingContext() ITK_OVERRIDE {} + ~RenderingContext() override {} PointType m_RoiOrigin; PointType m_RoiExtent; @@ -121,13 +121,13 @@ public: QuicklookViewRenderer( QObject* p = NULL ); /** Destructor */ - ~QuicklookViewRenderer() ITK_OVERRIDE; + ~QuicklookViewRenderer() override; // // ImageViewRenderer overloads. - AbstractImageViewRenderer::RenderingContext* NewRenderingContext() const ITK_OVERRIDE; + AbstractImageViewRenderer::RenderingContext* NewRenderingContext() const override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ @@ -150,7 +150,7 @@ protected: // ImageViewRenderer overloads. - void UpdateActors( const AbstractImageViewRenderer::RenderingContext* c ) ITK_OVERRIDE; + void UpdateActors( const AbstractImageViewRenderer::RenderingContext* c ) override; // // Protected attributes. @@ -170,13 +170,13 @@ private: // // ImageViewRenderer methods. - void virtual_SetProjection() ITK_OVERRIDE; - void virtual_UpdateProjection() ITK_OVERRIDE; + void virtual_SetProjection() override; + void virtual_UpdateProjection() override; // // AbstractImageViewRenderer overloads. // TODO: Move virtual_*Scene() methods to protected section. - void virtual_FinishScene() ITK_OVERRIDE; + void virtual_FinishScene() override; // // Private attributes. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdSearchableTreeWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdSearchableTreeWidget.h index cafadc9473..a6d12edee2 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdSearchableTreeWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdSearchableTreeWidget.h @@ -102,7 +102,7 @@ public: SearchableTreeWidget( QWidget* p =NULL, Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~SearchableTreeWidget() ITK_OVERRIDE; + ~SearchableTreeWidget() override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdShaderWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdShaderWidget.h index 4d1b55c63c..22bae26ea0 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdShaderWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdShaderWidget.h @@ -101,7 +101,7 @@ public: Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~ShaderWidget() ITK_OVERRIDE; + ~ShaderWidget() override; /** */ @@ -144,7 +144,7 @@ private: void SetEffectVisible(const Effect & effect, bool visible); /** */ - void virtual_SetSettings( ImageSettings * ) ITK_OVERRIDE; + void virtual_SetSettings( ImageSettings * ) override; /** * Set the ComboBox effects item for the corresponding image settings. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdStatusBarWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdStatusBarWidget.h index 6ff51de45d..8377dcffd6 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdStatusBarWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdStatusBarWidget.h @@ -97,7 +97,7 @@ public: StatusBarWidget( QWidget* p =NULL, Qt::WindowFlags flags =0 ); /** \brief Destructor. */ - ~StatusBarWidget() ITK_OVERRIDE; + ~StatusBarWidget() override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdTaskProgressDialog.h b/Modules/Visualization/MonteverdiGui/include/mvdTaskProgressDialog.h index 700399768f..8c4765d337 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdTaskProgressDialog.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdTaskProgressDialog.h @@ -99,7 +99,7 @@ public: /** * \brief Destructor. */ - ~TaskProgressDialog() ITK_OVERRIDE; + ~TaskProgressDialog() override; /** */ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdTreeWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdTreeWidget.h index 7f4d0f0c40..ba83567d72 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdTreeWidget.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdTreeWidget.h @@ -124,7 +124,7 @@ public: TreeWidget( QWidget* p =NULL ); /** \brief Destructor. */ - ~TreeWidget() ITK_OVERRIDE; + ~TreeWidget() override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ @@ -151,17 +151,17 @@ protected: // // QTreeWidget overloads. - QStringList mimeTypes() const ITK_OVERRIDE; + QStringList mimeTypes() const override; - QMimeData* mimeData( const QList< QTreeWidgetItem* > items ) const ITK_OVERRIDE; + QMimeData* mimeData( const QList< QTreeWidgetItem* > items ) const override; - void dragEnterEvent( QDragEnterEvent* event ) ITK_OVERRIDE; - void dragMoveEvent( QDragMoveEvent* event ) ITK_OVERRIDE; - void dragLeaveEvent( QDragLeaveEvent* event ) ITK_OVERRIDE; - void dropEvent( QDropEvent* event ) ITK_OVERRIDE; + void dragEnterEvent( QDragEnterEvent* event ) override; + void dragMoveEvent( QDragMoveEvent* event ) override; + void dragLeaveEvent( QDragLeaveEvent* event ) override; + void dropEvent( QDropEvent* event ) override; - Qt::DropActions supportedDropActions() const ITK_OVERRIDE; - void startDrag( Qt::DropActions supportedActions ) ITK_OVERRIDE; + Qt::DropActions supportedDropActions() const override; + void startDrag( Qt::DropActions supportedActions ) override; // // Protected attributes. diff --git a/Modules/Visualization/MonteverdiGui/include/mvdTreeWidgetItem.h b/Modules/Visualization/MonteverdiGui/include/mvdTreeWidgetItem.h index 248c831483..a1950223da 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdTreeWidgetItem.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdTreeWidgetItem.h @@ -120,7 +120,7 @@ public: /** * \brief Destructor. */ - ~TreeWidgetItem() ITK_OVERRIDE; + ~TreeWidgetItem() override; /** */ @@ -145,7 +145,7 @@ public: /** * \see http://qt-project.org/doc/qt-4.8/qtreewidgetitem.html#clone */ - QTreeWidgetItem* clone() const ITK_OVERRIDE; + QTreeWidgetItem* clone() const override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ diff --git a/Modules/Visualization/MonteverdiGui/include/mvdTreeWidgetItemDragAndDropEventFilter.h b/Modules/Visualization/MonteverdiGui/include/mvdTreeWidgetItemDragAndDropEventFilter.h index b66b4e991e..c09a9ff1b1 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdTreeWidgetItemDragAndDropEventFilter.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdTreeWidgetItemDragAndDropEventFilter.h @@ -93,7 +93,7 @@ public: TreeWidgetItemDragAndDropEventFilter( QObject* p =NULL ); /** \brief Destructor. */ - ~TreeWidgetItemDragAndDropEventFilter() ITK_OVERRIDE; + ~TreeWidgetItemDragAndDropEventFilter() override; /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ @@ -121,22 +121,22 @@ protected: /** * \see http://qt-project.org/doc/qt-4.8/qwidget.html#dragEnterEvent */ - bool DragEnterEvent( QObject* object, QDragEnterEvent* event ) ITK_OVERRIDE; + bool DragEnterEvent( QObject* object, QDragEnterEvent* event ) override; /** * \see http://qt-project.org/doc/qt-4.8/qwidget.html#dragLeaveEvent */ - bool DragLeaveEvent( QObject* object, QDragLeaveEvent* event ) ITK_OVERRIDE; + bool DragLeaveEvent( QObject* object, QDragLeaveEvent* event ) override; /** * \see http://qt-project.org/doc/qt-4.8/qwidget.html#dragMoveEvent */ - bool DragMoveEvent( QObject* object, QDragMoveEvent* event ) ITK_OVERRIDE; + bool DragMoveEvent( QObject* object, QDragMoveEvent* event ) override; /** * \see http://qt-project.org/doc/qt-4.8/qwidget.html#dropEvent */ - bool DropEvent( QObject* object, QDropEvent* event ) ITK_OVERRIDE; + bool DropEvent( QObject* object, QDropEvent* event ) override; // // Protected attributes. diff --git a/Modules/Wrappers/ApplicationEngine/include/otbLogger.h b/Modules/Wrappers/ApplicationEngine/include/otbLogger.h index ba43072a19..c1c87e05e3 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbLogger.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbLogger.h @@ -45,7 +45,7 @@ public: itkNewMacro(Self); // Overwrite this to provide custom formatting of log entries - std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE; + std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) override; protected: Logger(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h index 3cf9114c81..9dec89465c 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h @@ -46,7 +46,7 @@ public: AddProcessToWatchEvent(){} AddProcessToWatchEvent(const Self& s) :itk::EventObject(s){}; - ~AddProcessToWatchEvent() ITK_OVERRIDE {} + ~AddProcessToWatchEvent() override {} /** Set/Get the process to watch */ virtual void SetProcess(itk::ProcessObject * process) @@ -70,16 +70,16 @@ public: } /** Virtual pure method to implement */ - itk::EventObject* MakeObject() const ITK_OVERRIDE + itk::EventObject* MakeObject() const override { return new Self; } - const char* GetEventName() const ITK_OVERRIDE + const char* GetEventName() const override { return "AddProcess"; } - bool CheckEvent(const itk::EventObject* e) const ITK_OVERRIDE + bool CheckEvent(const itk::EventObject* e) const override { return dynamic_cast<const Self*>(e); } diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index c6317be142..bf5ac14c5d 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -849,7 +849,7 @@ protected: Application(); /** Destructor */ - ~Application() ITK_OVERRIDE; + ~Application() override; /* Register a ProcessObject as a new progress source */ void AddProcess(itk::ProcessObject* object, std::string description); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplicationFactory.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplicationFactory.h index 4b3119096c..f0461e2982 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplicationFactory.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplicationFactory.h @@ -40,12 +40,12 @@ public: typedef itk::SmartPointer<const Self> ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const ITK_OVERRIDE + const char* GetITKSourceVersion(void) const override { return ITK_SOURCE_VERSION; } - const char* GetDescription(void) const ITK_OVERRIDE + const char* GetDescription(void) const override { return "ApplicationFactory"; } @@ -74,7 +74,7 @@ protected: } - ~ApplicationFactory() ITK_OVERRIDE + ~ApplicationFactory() override { } @@ -82,7 +82,7 @@ protected: /** This method is provided by sub-classes of ObjectFactoryBase. * It should create the named itk object or return 0 if that object * is not supported by the factory implementation. */ - LightObject::Pointer CreateObject(const char* itkclassname ) ITK_OVERRIDE + LightObject::Pointer CreateObject(const char* itkclassname ) override { LightObject::Pointer ret; if ( m_ClassName == itkclassname) @@ -95,7 +95,7 @@ protected: * itkclass name, which are provide by this object */ std::list<LightObject::Pointer> - CreateAllObject(const char* itkclassname) ITK_OVERRIDE + CreateAllObject(const char* itkclassname) override { const std::string applicationClass("otbWrapperApplication"); std::list<LightObject::Pointer> list; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplicationFactoryBase.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplicationFactoryBase.h index cafab0a141..2012736f81 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplicationFactoryBase.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplicationFactoryBase.h @@ -48,7 +48,7 @@ public: protected: ApplicationFactoryBase(){} - ~ApplicationFactoryBase() ITK_OVERRIDE{} + ~ApplicationFactoryBase() override{} private: ApplicationFactoryBase(const Self &); //purposely not implemented diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplicationRegistry.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplicationRegistry.h index 0bb290c71e..b31c8ed3b0 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplicationRegistry.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplicationRegistry.h @@ -79,7 +79,7 @@ public: protected: ApplicationRegistry(); - ~ApplicationRegistry() ITK_OVERRIDE; + ~ApplicationRegistry() override; private: ApplicationRegistry(const Self&); //purposely not implemented diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h index b376323214..b2bd1d55f7 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h @@ -88,12 +88,12 @@ public: /** Return any value */ virtual unsigned int GetValue(); - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { return !m_ChoiceList.empty(); } - void ClearValue() ITK_OVERRIDE + void ClearValue() override { // Same as constructor init value // Note that this may be invalid if HasValue() == false @@ -105,7 +105,7 @@ protected: ChoiceParameter(); /** Destructor */ - ~ChoiceParameter() ITK_OVERRIDE; + ~ChoiceParameter() override; struct Choice { diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h index 264967e376..0c9fdfe7e7 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h @@ -106,9 +106,9 @@ the macro otbGetParameterImageMacro of otbWrapperApplication.h */ template <class TComplexInputImage, class TOutputImage> TOutputImage* CastImage(); - bool HasValue() const ITK_OVERRIDE; + bool HasValue() const override; - void ClearValue() ITK_OVERRIDE; + void ClearValue() override; protected: @@ -116,7 +116,7 @@ protected: ComplexInputImageParameter(); /** Destructor */ - ~ComplexInputImageParameter() ITK_OVERRIDE; + ~ComplexInputImageParameter() override; ImageBaseType::Pointer m_Image; std::string m_FileName; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h index 0613816b47..c43b21cdef 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h @@ -77,7 +77,7 @@ public: itkGetMacro(RAMValue, unsigned int); /** Implement the reset method (replace pixel type by default type) */ - void Reset() ITK_OVERRIDE + void Reset() override { m_ComplexPixelType = m_DefaultComplexPixelType; } @@ -90,7 +90,7 @@ public: static bool ConvertStringToPixelType(const std::string &value, ComplexImagePixelType &type); /** Return true if a filename is set */ - bool HasValue() const ITK_OVERRIDE; + bool HasValue() const override; void SetFileName (const char* filename) { @@ -114,7 +114,7 @@ protected: /** Constructor */ ComplexOutputImageParameter(); /** Destructor */ - ~ComplexOutputImageParameter() ITK_OVERRIDE; + ~ComplexOutputImageParameter() override; template <class TInputImageType> void SwitchImageWrite(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h index 601b9450a9..49c46aef40 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h @@ -72,7 +72,7 @@ protected: CompositeApplication(); /** Destructor */ - ~CompositeApplication() ITK_OVERRIDE; + ~CompositeApplication() override; /** * Callback function to retrieve the process watchers on internal filters diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperDirectoryParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperDirectoryParameter.h index 252ea13f57..9e461109d9 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperDirectoryParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperDirectoryParameter.h @@ -52,7 +52,7 @@ public: /** RTTI support */ itkTypeMacro(DirectoryParameter, Parameter); - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { return m_StringParam->HasValue(); } @@ -62,13 +62,13 @@ public: otbGetObjectMemberMacro(StringParam, Value , std::string); // Clear Value - void ClearValue() ITK_OVERRIDE + void ClearValue() override { m_StringParam->ClearValue(); } // Reimplement the SetActive method - void SetActive( const bool value ) ITK_OVERRIDE + void SetActive( const bool value ) override { Superclass::SetActive( value ); m_StringParam->SetActive( value ); @@ -85,7 +85,7 @@ protected: } /** Destructor */ - ~DirectoryParameter() ITK_OVERRIDE + ~DirectoryParameter() override {} private: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperDocExampleStructure.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperDocExampleStructure.h index b7ab6885a1..c8bdf7a960 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperDocExampleStructure.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperDocExampleStructure.h @@ -120,7 +120,7 @@ protected: /** Constructor */ DocExampleStructure(); /** Destructor */ - ~DocExampleStructure() ITK_OVERRIDE; + ~DocExampleStructure() override; private: DocExampleStructure(const DocExampleStructure &); //purposely not implemented diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperEmptyParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperEmptyParameter.h index 7978c5fb4f..fd6fbc3aa2 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperEmptyParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperEmptyParameter.h @@ -50,12 +50,12 @@ public: itkTypeMacro(EmptyParameter, Parameter); /** HasValue */ - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { return false; } - bool HasUserValue() const ITK_OVERRIDE + bool HasUserValue() const override { return this->m_UserValue; } @@ -69,7 +69,7 @@ protected: } /** Destructor */ - ~EmptyParameter() ITK_OVERRIDE + ~EmptyParameter() override {} private: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameParameter.h index 5186853f01..2fafb3ecd5 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameParameter.h @@ -51,7 +51,7 @@ public: itkTypeMacro(InputFilenameParameter, Parameter); - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { return m_StringParam->HasValue(); } @@ -69,7 +69,7 @@ public: } // Clear Value - void ClearValue() ITK_OVERRIDE + void ClearValue() override { m_StringParam->ClearValue(); } @@ -85,7 +85,7 @@ protected: } /** Destructor */ - ~InputFilenameParameter() ITK_OVERRIDE + ~InputFilenameParameter() override {} private: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h index 3f83839de1..a12dba6efe 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h @@ -107,9 +107,9 @@ public: template <class TInputImage, class TOutputImage> TOutputImage* CastImage(); - bool HasValue() const ITK_OVERRIDE; + bool HasValue() const override; - void ClearValue() ITK_OVERRIDE; + void ClearValue() override; protected: @@ -117,7 +117,7 @@ protected: InputImageParameter(); /** Destructor */ - ~InputImageParameter() ITK_OVERRIDE; + ~InputImageParameter() override; ImageBaseType::Pointer m_Image; std::string m_FileName; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputProcessXMLParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputProcessXMLParameter.h index 889d79600d..b896b7f23d 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputProcessXMLParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputProcessXMLParameter.h @@ -52,7 +52,7 @@ public: itkGetStringMacro(FileName); - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { if(m_FileName.empty()) return false; @@ -86,7 +86,7 @@ protected: InputProcessXMLParameter(); /** Destructor */ - ~InputProcessXMLParameter() ITK_OVERRIDE; + ~InputProcessXMLParameter() override; private: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h index f84a3834eb..9442815771 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h @@ -62,16 +62,16 @@ public: void SetVectorData(VectorDataType* vectorData); - bool HasValue() const ITK_OVERRIDE; + bool HasValue() const override; - void ClearValue() ITK_OVERRIDE; + void ClearValue() override; protected: /** Constructor */ InputVectorDataParameter(); /** Destructor */ - ~InputVectorDataParameter() ITK_OVERRIDE; + ~InputVectorDataParameter() override; typedef otb::VectorDataFileReader<VectorDataType> VectorDataFileReaderType; VectorDataType::Pointer m_VectorData; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperListViewParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperListViewParameter.h index fb03f066f0..aa5e3feb57 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperListViewParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperListViewParameter.h @@ -84,13 +84,13 @@ public: /** Return any value */ virtual unsigned int GetValue(); - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { // a choice parameter always has a value return true; } - void ClearValue() ITK_OVERRIDE + void ClearValue() override { // nothing to do : a choice parameter always has a value } @@ -155,7 +155,7 @@ protected: ListViewParameter(); /** Destructor */ - ~ListViewParameter() ITK_OVERRIDE; + ~ListViewParameter() override; struct ListViewChoice { diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperNumericalParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperNumericalParameter.h index 6fc5d551ae..de97a3471b 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperNumericalParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperNumericalParameter.h @@ -54,7 +54,7 @@ public: typedef T ScalarType; /** Implement the reset method (replace value by default value) */ - void Reset() ITK_OVERRIDE + void Reset() override { m_Value = m_DefaultValue; } @@ -88,12 +88,12 @@ public: return boost::any_cast<ScalarType>(m_Value); } - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { return !m_Value.empty(); } - void ClearValue() ITK_OVERRIDE + void ClearValue() override { m_Value = boost::any(); } @@ -125,7 +125,7 @@ protected: {} /** Destructor */ - ~NumericalParameter() ITK_OVERRIDE + ~NumericalParameter() override {} /** Value */ diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputFilenameParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputFilenameParameter.h index c8b7437b55..a528a39927 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputFilenameParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputFilenameParameter.h @@ -51,7 +51,7 @@ public: itkTypeMacro(OutputFilenameParameter, Parameter); - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { return m_StringParam->HasValue(); } @@ -69,7 +69,7 @@ public: } // Clear Value - void ClearValue() ITK_OVERRIDE + void ClearValue() override { m_StringParam->ClearValue(); } @@ -85,7 +85,7 @@ protected: } /** Destructor */ - ~OutputFilenameParameter() ITK_OVERRIDE + ~OutputFilenameParameter() override {} private: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index fd0c392b70..aab831aba8 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -78,7 +78,7 @@ public: itkGetMacro(RAMValue, unsigned int); /** Implement the reset method (replace pixel type by default type) */ - void Reset() ITK_OVERRIDE + void Reset() override { m_PixelType = m_DefaultPixelType; } @@ -91,7 +91,7 @@ public: static bool ConvertStringToPixelType(const std::string &value, ImagePixelType &type); /** Return true if a filename is set */ - bool HasValue() const ITK_OVERRIDE; + bool HasValue() const override; void SetFileName (const char* filename) { @@ -117,7 +117,7 @@ protected: /** Constructor */ OutputImageParameter(); /** Destructor */ - ~OutputImageParameter() ITK_OVERRIDE; + ~OutputImageParameter() override; template <class TInputVectorImageType> void SwitchVectorImageWrite(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h index 7f247f2baa..d870ee8023 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h @@ -66,7 +66,7 @@ public: this->Modified(); } - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { if(m_FileName.empty()) return false; @@ -74,7 +74,7 @@ public: return true; } - void ClearValue() ITK_OVERRIDE + void ClearValue() override { m_FileName = ""; } @@ -94,7 +94,7 @@ protected: OutputProcessXMLParameter(); /** Destructor */ - ~OutputProcessXMLParameter() ITK_OVERRIDE; + ~OutputProcessXMLParameter() override; private: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h index fb90702544..d1b9c31d37 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h @@ -59,7 +59,7 @@ public: itkGetObjectMacro(VectorData, VectorDataType); /** Return true if a filename is set */ - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { std::string filename(this->GetFileName()); return !filename.empty(); @@ -116,7 +116,7 @@ protected: } /** Destructor */ - ~OutputVectorDataParameter() ITK_OVERRIDE + ~OutputVectorDataParameter() override {} diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h index 236411f8f2..bbd0e47ff6 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h @@ -231,7 +231,7 @@ protected: {} /** Destructor */ - ~Parameter() ITK_OVERRIDE {} + ~Parameter() override {} /** Name of the parameter */ std::string m_Name; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h index f6d552c6d3..36c8240990 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h @@ -95,7 +95,7 @@ public: std::vector<std::string> GetParametersKeys(bool recursive = true); // Always has value - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { return true; } @@ -106,7 +106,7 @@ public: protected: ParameterGroup(); - ~ParameterGroup() ITK_OVERRIDE; + ~ParameterGroup() override; typedef std::vector<Parameter::Pointer> ParameterListType; ParameterListType m_ParameterList; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperProxyParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperProxyParameter.h index c7594f8c5d..1bc45bbd74 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperProxyParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperProxyParameter.h @@ -77,7 +77,7 @@ public: protected: ProxyParameter() {} - ~ProxyParameter() ITK_OVERRIDE {} + ~ProxyParameter() override {} private: ProxyParameter(const Self &); //purposely not implemented diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperRAMParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperRAMParameter.h index 0d6b36c229..e9c4fb97d5 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperRAMParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperRAMParameter.h @@ -52,7 +52,7 @@ public: typedef NumericalParameter<unsigned int> UnsignedIntParameter; typedef UnsignedIntParameter::ScalarType ScalarType; - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { return m_UnsignedIntParam->HasValue(); } @@ -71,19 +71,19 @@ public: otbGetObjectMemberMacro(UnsignedIntParam, MaximumValue, ScalarType); // Clear Value - void ClearValue() ITK_OVERRIDE + void ClearValue() override { m_UnsignedIntParam->ClearValue(); } // Reset - void Reset() ITK_OVERRIDE + void Reset() override { m_UnsignedIntParam->Reset(); } // Reimplement the SetActive method - void SetActive( const bool value ) ITK_OVERRIDE + void SetActive( const bool value ) override { Superclass::SetActive( value ); m_UnsignedIntParam->SetActive( value ); @@ -107,7 +107,7 @@ protected: } /** Destructor */ - ~RAMParameter() ITK_OVERRIDE + ~RAMParameter() override {} private: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperRadiusParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperRadiusParameter.h index 27e9e726fe..020e647bbf 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperRadiusParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperRadiusParameter.h @@ -49,7 +49,7 @@ public: /** RTTI support */ itkTypeMacro(RadiusParameter, Parameter); - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { return true; } @@ -64,7 +64,7 @@ protected: } /** Destructor */ - ~RadiusParameter() ITK_OVERRIDE + ~RadiusParameter() override {} private: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h index 9c8b1e88a9..861e0b428c 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h @@ -63,12 +63,12 @@ public: return m_Value; } - bool HasValue() const ITK_OVERRIDE + bool HasValue() const override { return !m_Value.empty(); } - void ClearValue() ITK_OVERRIDE + void ClearValue() override { m_Value = ""; } @@ -79,7 +79,7 @@ protected: {} /** Destructor */ - ~StringParameter() ITK_OVERRIDE + ~StringParameter() override {} std::string m_Value; diff --git a/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineLauncher.h b/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineLauncher.h index c54d4a9fed..51b76e9b0b 100644 --- a/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineLauncher.h +++ b/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineLauncher.h @@ -122,7 +122,7 @@ protected: CommandLineLauncher(); /** Destructor */ - ~CommandLineLauncher() ITK_OVERRIDE; + ~CommandLineLauncher() override; /** Load the executable path. It looks for the key --modulePath, * extract and interpret as path the following strings. diff --git a/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineParser.h b/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineParser.h index 42c449f18c..9f35a7b892 100644 --- a/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineParser.h +++ b/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineParser.h @@ -90,7 +90,7 @@ protected: CommandLineParser(); /** Destructor */ - ~CommandLineParser() ITK_OVERRIDE; + ~CommandLineParser() override; private: CommandLineParser(const CommandLineParser &); //purposely not implemented diff --git a/Modules/Wrappers/QtWidget/include/itkQtProgressBar.h b/Modules/Wrappers/QtWidget/include/itkQtProgressBar.h index 5dd5b1b482..c158f64d11 100644 --- a/Modules/Wrappers/QtWidget/include/itkQtProgressBar.h +++ b/Modules/Wrappers/QtWidget/include/itkQtProgressBar.h @@ -42,7 +42,7 @@ public: QtProgressBar( QWidget *parent ); /** Destructor */ - ~QtProgressBar() ITK_OVERRIDE; + ~QtProgressBar() override; /** Get Command */ RedrawCommandType * GetRedrawCommand( void ) const; diff --git a/Modules/Wrappers/QtWidget/include/otbQtApplication.h b/Modules/Wrappers/QtWidget/include/otbQtApplication.h index 3950aaf3a5..24b10bdceb 100644 --- a/Modules/Wrappers/QtWidget/include/otbQtApplication.h +++ b/Modules/Wrappers/QtWidget/include/otbQtApplication.h @@ -40,7 +40,7 @@ class OTBQtWidget_EXPORT QtApplication : public QApplication public: QtApplication(int& argc, char** argv); - bool notify(QObject *object, QEvent* event) ITK_OVERRIDE; + bool notify(QObject *object, QEvent* event) override; signals: diff --git a/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h b/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h index ec1977b33a..ad51f5af1d 100644 --- a/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h +++ b/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h @@ -51,7 +51,7 @@ public: }; QtFileSelectionWidget(); - ~QtFileSelectionWidget() ITK_OVERRIDE; + ~QtFileSelectionWidget() override; bool IsChecked() { diff --git a/Modules/Wrappers/QtWidget/include/otbQtLogOutput.h b/Modules/Wrappers/QtWidget/include/otbQtLogOutput.h index b4ca74de99..cdf9a6e806 100644 --- a/Modules/Wrappers/QtWidget/include/otbQtLogOutput.h +++ b/Modules/Wrappers/QtWidget/include/otbQtLogOutput.h @@ -55,16 +55,16 @@ public: itkNewMacro(QtLogOutput); /** flush a buffer */ - void Flush() ITK_OVERRIDE; + void Flush() override; /** Write to multiple outputs */ - void Write(double timestamp) ITK_OVERRIDE; + void Write(double timestamp) override; /** Write to a buffer */ - void Write(std::string const &content) ITK_OVERRIDE; + void Write(std::string const &content) override; /** Write to a buffer */ - void Write(std::string const &content, double timestamp) ITK_OVERRIDE; + void Write(std::string const &content, double timestamp) override; signals: void NewContentLog(QString); @@ -74,9 +74,9 @@ protected: QtLogOutput(); /** Destructor */ - ~QtLogOutput() ITK_OVERRIDE; + ~QtLogOutput() override; - void PrintSelf(std::ostream &os, itk::Indent indent) const ITK_OVERRIDE; + void PrintSelf(std::ostream &os, itk::Indent indent) const override; }; } diff --git a/Modules/Wrappers/QtWidget/include/otbQtStringSelectionWidget.h b/Modules/Wrappers/QtWidget/include/otbQtStringSelectionWidget.h index 1b65bb6d2e..90db3a01cb 100644 --- a/Modules/Wrappers/QtWidget/include/otbQtStringSelectionWidget.h +++ b/Modules/Wrappers/QtWidget/include/otbQtStringSelectionWidget.h @@ -49,7 +49,7 @@ signals: public: QtStringSelectionWidget(); - ~QtStringSelectionWidget() ITK_OVERRIDE; + ~QtStringSelectionWidget() override; bool IsChecked() { diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetChoiceParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetChoiceParameter.h index 855a26e9c8..0d6067c68f 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetChoiceParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetChoiceParameter.h @@ -42,7 +42,7 @@ class OTBQtWidget_EXPORT QtWidgetChoiceParameter : public QtWidgetParameterBase Q_OBJECT public: QtWidgetChoiceParameter(ChoiceParameter*, QtWidgetModel*); - ~QtWidgetChoiceParameter() ITK_OVERRIDE; + ~QtWidgetChoiceParameter() override; protected slots: void SetValue( int value ); @@ -51,9 +51,9 @@ private: QtWidgetChoiceParameter(const QtWidgetChoiceParameter&); //purposely not implemented void operator=(const QtWidgetChoiceParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; ChoiceParameter::Pointer m_ChoiceParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexInputImageParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexInputImageParameter.h index 249283011e..ec2a3c4a6e 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexInputImageParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexInputImageParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetComplexInputImageParameter : public QtWidgetPar Q_OBJECT public: QtWidgetComplexInputImageParameter(ComplexInputImageParameter*, QtWidgetModel*); - ~QtWidgetComplexInputImageParameter() ITK_OVERRIDE; + ~QtWidgetComplexInputImageParameter() override; inline const QLineEdit* GetInput() const; inline QLineEdit* GetInput(); @@ -56,9 +56,9 @@ private: QtWidgetComplexInputImageParameter(const QtWidgetComplexInputImageParameter&); //purposely not implemented void operator=(const QtWidgetComplexInputImageParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; ComplexInputImageParameter::Pointer m_ComplexInputImageParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexOutputImageParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexOutputImageParameter.h index 1ec7b3f325..0dbda46016 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexOutputImageParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexOutputImageParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetComplexOutputImageParameter : public QtWidgetPa Q_OBJECT public: QtWidgetComplexOutputImageParameter(ComplexOutputImageParameter*, QtWidgetModel*); - ~QtWidgetComplexOutputImageParameter() ITK_OVERRIDE; + ~QtWidgetComplexOutputImageParameter() override; inline const QLineEdit* GetInput() const; inline QLineEdit* GetInput(); @@ -62,9 +62,9 @@ private: QtWidgetComplexOutputImageParameter(const QtWidgetComplexOutputImageParameter&); //purposely not implemented void operator=(const QtWidgetComplexOutputImageParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; std::string m_FileName; ComplexOutputImageParameter::Pointer m_OutputImageParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetDirectoryParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetDirectoryParameter.h index 8a9a4951bb..e7d051f72d 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetDirectoryParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetDirectoryParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetDirectoryParameter : public QtWidgetParameterBa Q_OBJECT public: QtWidgetDirectoryParameter(DirectoryParameter*, QtWidgetModel*); - ~QtWidgetDirectoryParameter() ITK_OVERRIDE; + ~QtWidgetDirectoryParameter() override; protected slots: void SetFileName( const QString& value ); @@ -53,9 +53,9 @@ private: QtWidgetDirectoryParameter(const QtWidgetDirectoryParameter&); //purposely not implemented void operator=(const QtWidgetDirectoryParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; DirectoryParameter::Pointer m_DirectoryParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetEmptyParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetEmptyParameter.h index c5c9f6a7bd..44f0625ceb 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetEmptyParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetEmptyParameter.h @@ -43,15 +43,15 @@ class OTBQtWidget_EXPORT QtWidgetEmptyParameter : public QtWidgetParameterBase public: QtWidgetEmptyParameter(EmptyParameter*, QtWidgetModel*); - ~QtWidgetEmptyParameter() ITK_OVERRIDE; + ~QtWidgetEmptyParameter() override; private: QtWidgetEmptyParameter(const QtWidgetEmptyParameter&); //purposely not implemented void operator=(const QtWidgetEmptyParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; }; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetFloatParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetFloatParameter.h index 47275ef86c..3eb2b23890 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetFloatParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetFloatParameter.h @@ -42,7 +42,7 @@ class OTBQtWidget_EXPORT QtWidgetFloatParameter : public QtWidgetParameterBase Q_OBJECT public: QtWidgetFloatParameter(FloatParameter*, QtWidgetModel*); - ~QtWidgetFloatParameter() ITK_OVERRIDE; + ~QtWidgetFloatParameter() override; protected slots: void SetValue( double value ); @@ -51,9 +51,9 @@ private: QtWidgetFloatParameter(const QtWidgetFloatParameter&); //purposely not implemented void operator=(const QtWidgetFloatParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; QHBoxLayout * m_QHBoxLayout; QDoubleSpinBox * m_QDoubleSpinBox; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputFilenameParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputFilenameParameter.h index 110c18a292..9069ccabc3 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputFilenameParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputFilenameParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetInputFilenameParameter : public QtWidgetParamet Q_OBJECT public: QtWidgetInputFilenameParameter(InputFilenameParameter*, QtWidgetModel*); - ~QtWidgetInputFilenameParameter() ITK_OVERRIDE; + ~QtWidgetInputFilenameParameter() override; inline const QLineEdit* GetInput() const; inline QLineEdit* GetInput(); @@ -56,9 +56,9 @@ private: QtWidgetInputFilenameParameter(const QtWidgetInputFilenameParameter&); //purposely not implemented void operator=(const QtWidgetInputFilenameParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; InputFilenameParameter::Pointer m_FilenameParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h index 5c970fc5c7..a335ee5e06 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetInputImageParameter : public QtWidgetParameterB Q_OBJECT public: QtWidgetInputImageParameter(InputImageParameter*, QtWidgetModel*); - ~QtWidgetInputImageParameter() ITK_OVERRIDE; + ~QtWidgetInputImageParameter() override; inline const QLineEdit* GetInput() const; inline QLineEdit* GetInput(); @@ -62,9 +62,9 @@ private: QtWidgetInputImageParameter(const QtWidgetInputImageParameter&); //purposely not implemented void operator=(const QtWidgetInputImageParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; InputImageParameter::Pointer m_InputImageParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputProcessXMLParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputProcessXMLParameter.h index 407d76c3ad..0c78193d4d 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputProcessXMLParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputProcessXMLParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetInputProcessXMLParameter : public QtWidgetParam Q_OBJECT public: QtWidgetInputProcessXMLParameter(InputProcessXMLParameter*, QtWidgetModel*); - ~QtWidgetInputProcessXMLParameter() ITK_OVERRIDE; + ~QtWidgetInputProcessXMLParameter() override; inline const QLineEdit* GetInput() const; inline QLineEdit* GetInput(); @@ -56,9 +56,9 @@ private: QtWidgetInputProcessXMLParameter(const QtWidgetInputProcessXMLParameter&); //purposely not implemented void operator=(const QtWidgetInputProcessXMLParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; InputProcessXMLParameter::Pointer m_XMLParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputVectorDataParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputVectorDataParameter.h index 8b7a6d785c..9106b98550 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputVectorDataParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputVectorDataParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetInputVectorDataParameter : public QtWidgetParam Q_OBJECT public: QtWidgetInputVectorDataParameter(InputVectorDataParameter*, QtWidgetModel*); - ~QtWidgetInputVectorDataParameter() ITK_OVERRIDE; + ~QtWidgetInputVectorDataParameter() override; inline const QLineEdit* GetInput() const; inline QLineEdit* GetInput(); @@ -56,9 +56,9 @@ private: QtWidgetInputVectorDataParameter(const QtWidgetInputVectorDataParameter&); //purposely not implemented void operator=(const QtWidgetInputVectorDataParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; InputVectorDataParameter::Pointer m_InputVectorDataParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetIntParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetIntParameter.h index aa39992d98..1acab2f590 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetIntParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetIntParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetIntParameter : public QtWidgetParameterBase Q_OBJECT public: QtWidgetIntParameter(IntParameter*, QtWidgetModel*); - ~QtWidgetIntParameter() ITK_OVERRIDE; + ~QtWidgetIntParameter() override; protected slots: void SetValue( int value ); @@ -52,9 +52,9 @@ private: QtWidgetIntParameter(const QtWidgetIntParameter&); //purposely not implemented void operator=(const QtWidgetIntParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; QHBoxLayout * m_QHBoxLayout; QSpinBox * m_QSpinBox; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListEditItemModel.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListEditItemModel.h index 34000ebc98..4c87960744 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListEditItemModel.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListEditItemModel.h @@ -122,7 +122,7 @@ public: QObject * p = nullptr ); /** \brief Destructor. */ - ~ListEditItemModel() ITK_OVERRIDE; + ~ListEditItemModel() override; // // QAbstractItemModel overloads. @@ -130,31 +130,31 @@ public: /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#columnCount */ - int columnCount( const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; + int columnCount( const QModelIndex & p = QModelIndex() ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#data */ QVariant data( const QModelIndex & index, - int role = Qt::DisplayRole ) const ITK_OVERRIDE; + int role = Qt::DisplayRole ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#flags */ - Qt::ItemFlags flags( const QModelIndex & index ) const ITK_OVERRIDE; + Qt::ItemFlags flags( const QModelIndex & index ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#hasChildren */ - bool hasChildren( const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; + bool hasChildren( const QModelIndex & p = QModelIndex() ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#headerData */ QVariant headerData( int section, Qt::Orientation orientation, - int role = Qt::DisplayRole ) const ITK_OVERRIDE; + int role = Qt::DisplayRole ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#index @@ -162,7 +162,7 @@ public: QModelIndex index( int row, int column, - const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; + const QModelIndex & p = QModelIndex() ) const override; /** * \see http://doc.qt.io/qt-4.8/qabstractitemmodel.html#insertRow @@ -176,12 +176,12 @@ public: bool insertRows( int row, int count, - const QModelIndex & p = QModelIndex() ) ITK_OVERRIDE; + const QModelIndex & p = QModelIndex() ) override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#parent */ - QModelIndex parent( const QModelIndex & index ) const ITK_OVERRIDE; + QModelIndex parent( const QModelIndex & index ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#removeRows @@ -189,12 +189,12 @@ public: bool removeRows( int row, int count, - const QModelIndex & p = QModelIndex() ) ITK_OVERRIDE; + const QModelIndex & p = QModelIndex() ) override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#rowCount */ - int rowCount( const QModelIndex & p = QModelIndex() ) const ITK_OVERRIDE; + int rowCount( const QModelIndex & p = QModelIndex() ) const override; /** * \see http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#setData @@ -202,7 +202,7 @@ public: bool setData( const QModelIndex & index, const QVariant & value, - int role = Qt::EditRole ) ITK_OVERRIDE; + int role = Qt::EditRole ) override; /** */ virtual bool Swap( int, int ); diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListViewParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListViewParameter.h index 3f8685810f..afef1c44d4 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListViewParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetListViewParameter.h @@ -42,7 +42,7 @@ class OTBQtWidget_EXPORT QtWidgetListViewParameter : public QtWidgetParameterBas Q_OBJECT public: QtWidgetListViewParameter(ListViewParameter*, QtWidgetModel*); - ~QtWidgetListViewParameter() ITK_OVERRIDE; + ~QtWidgetListViewParameter() override; std::vector<int> GetSelectedItems() { @@ -56,9 +56,9 @@ private: QtWidgetListViewParameter(const QtWidgetListViewParameter&); //purposely not implemented void operator=(const QtWidgetListViewParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; ListViewParameter::Pointer m_ListViewParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetModel.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetModel.h index 92c135dd6e..2fefeda56e 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetModel.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetModel.h @@ -44,7 +44,7 @@ class OTBQtWidget_EXPORT AppliThread : public QThread m_Application = app; } - ~AppliThread() ITK_OVERRIDE; + ~AppliThread() override; inline void Execute() { @@ -69,7 +69,7 @@ signals: void ExceptionRaised( QString what ); protected: - void run() ITK_OVERRIDE; + void run() override; private: AppliThread(const AppliThread&); //purposely not implemented @@ -90,7 +90,7 @@ class OTBQtWidget_EXPORT QtWidgetModel : public QObject public: QtWidgetModel(Application* app); - ~QtWidgetModel() ITK_OVERRIDE; + ~QtWidgetModel() override; Application* GetApplication() { diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputFilenameParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputFilenameParameter.h index fc39587360..4a8d089f52 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputFilenameParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputFilenameParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetOutputFilenameParameter : public QtWidgetParame Q_OBJECT public: QtWidgetOutputFilenameParameter(OutputFilenameParameter*, QtWidgetModel*); - ~QtWidgetOutputFilenameParameter() ITK_OVERRIDE; + ~QtWidgetOutputFilenameParameter() override; inline const QLineEdit* GetInput() const; inline QLineEdit* GetInput(); @@ -58,9 +58,9 @@ private: QtWidgetOutputFilenameParameter(const QtWidgetOutputFilenameParameter&); //purposely not implemented void operator=(const QtWidgetOutputFilenameParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; OutputFilenameParameter::Pointer m_FilenameParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputImageParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputImageParameter.h index 878f7ee56f..8ae053cf1b 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputImageParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputImageParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetOutputImageParameter : public QtWidgetParameter Q_OBJECT public: QtWidgetOutputImageParameter(OutputImageParameter*, QtWidgetModel*); - ~QtWidgetOutputImageParameter() ITK_OVERRIDE; + ~QtWidgetOutputImageParameter() override; inline const QLineEdit* GetInput() const; inline QLineEdit* GetInput(); @@ -62,9 +62,9 @@ private: QtWidgetOutputImageParameter(const QtWidgetOutputImageParameter&); //purposely not implemented void operator=(const QtWidgetOutputImageParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; std::string m_FileName; OutputImageParameter::Pointer m_OutputImageParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputProcessXMLParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputProcessXMLParameter.h index 10cd6481e7..9b8d519f73 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputProcessXMLParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputProcessXMLParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetOutputProcessXMLParameter : public QtWidgetPara Q_OBJECT public: QtWidgetOutputProcessXMLParameter(OutputProcessXMLParameter*, QtWidgetModel*); - ~QtWidgetOutputProcessXMLParameter() ITK_OVERRIDE; + ~QtWidgetOutputProcessXMLParameter() override; inline const QLineEdit* GetInput() const; inline QLineEdit* GetInput(); @@ -58,9 +58,9 @@ private: QtWidgetOutputProcessXMLParameter(const QtWidgetOutputProcessXMLParameter&); //purposely not implemented void operator=(const QtWidgetOutputProcessXMLParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; OutputProcessXMLParameter::Pointer m_XMLParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputVectorDataParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputVectorDataParameter.h index 2e9fcae1ee..f859b8a60e 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputVectorDataParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetOutputVectorDataParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetOutputVectorDataParameter : public QtWidgetPara Q_OBJECT public: QtWidgetOutputVectorDataParameter(OutputVectorDataParameter*, QtWidgetModel*); - ~QtWidgetOutputVectorDataParameter() ITK_OVERRIDE; + ~QtWidgetOutputVectorDataParameter() override; inline const QLineEdit* GetInput() const; inline QLineEdit* GetInput(); @@ -61,9 +61,9 @@ private: QtWidgetOutputVectorDataParameter(const QtWidgetOutputVectorDataParameter&); //purposely not implemented void operator=(const QtWidgetOutputVectorDataParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; std::string m_FileName; OutputVectorDataParameter::Pointer m_OutputVectorDataParam; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h index db88ca9ace..225427ef18 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetParameterBase : public QWidget Q_OBJECT public: QtWidgetParameterBase( Parameter *, QtWidgetModel * ); - ~QtWidgetParameterBase() ITK_OVERRIDE; + ~QtWidgetParameterBase() override; void CreateWidget(); diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterFactory.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterFactory.h index d5ae3f2a48..6fd1f14f41 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterFactory.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterFactory.h @@ -64,7 +64,7 @@ public: protected: QtWidgetParameterFactory(); - ~QtWidgetParameterFactory() ITK_OVERRIDE; + ~QtWidgetParameterFactory() override; private: QtWidgetParameterFactory(const Self&); //purposely not implemented diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h index 3e3969739f..0ecf0bd6cb 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h @@ -46,18 +46,18 @@ class OTBQtWidget_EXPORT QtWidgetParameterGroup : public QtWidgetParameterBase Q_OBJECT public: QtWidgetParameterGroup(ParameterGroup::Pointer, QtWidgetModel*); - ~QtWidgetParameterGroup() ITK_OVERRIDE; + ~QtWidgetParameterGroup() override; public slots: - void SetActivationState( bool value ) ITK_OVERRIDE; + void SetActivationState( bool value ) override; private: QtWidgetParameterGroup(const QtWidgetParameterGroup&); //purposely not implemented void operator=(const QtWidgetParameterGroup&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; virtual void ProcessChild(Parameter * currentNode, bool status); diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterLabel.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterLabel.h index bbe31014cb..1bb699dfff 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterLabel.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterLabel.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetParameterLabel : public QWidget Q_OBJECT public: QtWidgetParameterLabel(Parameter*); - ~QtWidgetParameterLabel() ITK_OVERRIDE; + ~QtWidgetParameterLabel() override; private: QtWidgetParameterLabel(const QtWidgetParameterLabel&); //purposely not implemented diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetProgressReport.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetProgressReport.h index 521a109acb..3c3f017aa4 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetProgressReport.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetProgressReport.h @@ -45,7 +45,7 @@ class OTBQtWidget_EXPORT QtWidgetProgressReport : public QWidget Q_OBJECT public: QtWidgetProgressReport(QtWidgetModel * model); - ~QtWidgetProgressReport() ITK_OVERRIDE; + ~QtWidgetProgressReport() override; void SetApplication(Application::Pointer app); diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetRAMParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetRAMParameter.h index eabf78f1e9..c8fcc31011 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetRAMParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetRAMParameter.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetRAMParameter : public QtWidgetParameterBase Q_OBJECT public: QtWidgetRAMParameter(RAMParameter*, QtWidgetModel*); - ~QtWidgetRAMParameter() ITK_OVERRIDE; + ~QtWidgetRAMParameter() override; protected slots: void SetValue( int value ); @@ -52,9 +52,9 @@ private: QtWidgetRAMParameter(const QtWidgetRAMParameter&); //purposely not implemented void operator=(const QtWidgetRAMParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; QHBoxLayout * m_QHBoxLayout; QSpinBox * m_QSpinBox; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetSimpleProgressReport.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetSimpleProgressReport.h index 3f5c4605bf..df13944c65 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetSimpleProgressReport.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetSimpleProgressReport.h @@ -45,7 +45,7 @@ class OTBQtWidget_EXPORT QtWidgetSimpleProgressReport : public QWidget Q_OBJECT public: QtWidgetSimpleProgressReport(QtWidgetModel * model); - ~QtWidgetSimpleProgressReport() ITK_OVERRIDE; + ~QtWidgetSimpleProgressReport() override; void SetApplication(Application::Pointer app); diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetStringParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetStringParameter.h index b639cf3797..bf3bb78275 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetStringParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetStringParameter.h @@ -42,7 +42,7 @@ class OTBQtWidget_EXPORT QtWidgetStringParameter : public QtWidgetParameterBase Q_OBJECT public: QtWidgetStringParameter(StringParameter*, QtWidgetModel*); - ~QtWidgetStringParameter() ITK_OVERRIDE; + ~QtWidgetStringParameter() override; protected slots: void SetValue( const QString& value ); @@ -51,9 +51,9 @@ private: QtWidgetStringParameter(const QtWidgetStringParameter&); //purposely not implemented void operator=(const QtWidgetStringParameter&); //purposely not implemented - void DoCreateWidget() ITK_OVERRIDE; + void DoCreateWidget() override; - void DoUpdateGUI() ITK_OVERRIDE; + void DoUpdateGUI() override; StringParameter::Pointer m_StringParam; QHBoxLayout * m_HLayout; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h index 08857a2420..5a004af2dc 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h @@ -43,7 +43,7 @@ class OTBQtWidget_EXPORT QtWidgetView : public QWidget Q_OBJECT public: QtWidgetView(Application* app); - ~QtWidgetView() ITK_OVERRIDE; + ~QtWidgetView() override; void CreateGui(); diff --git a/Modules/Wrappers/QtWidget/test/otbWrapperQtWidgetParameterFactory.cxx b/Modules/Wrappers/QtWidget/test/otbWrapperQtWidgetParameterFactory.cxx index 9ff2a0eea2..e830bd1324 100644 --- a/Modules/Wrappers/QtWidget/test/otbWrapperQtWidgetParameterFactory.cxx +++ b/Modules/Wrappers/QtWidget/test/otbWrapperQtWidgetParameterFactory.cxx @@ -54,19 +54,19 @@ protected: { } - ~StubApplication() ITK_OVERRIDE + ~StubApplication() override { } - void DoInit() ITK_OVERRIDE + void DoInit() override { } - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } - void DoExecute() ITK_OVERRIDE + void DoExecute() override { } }; diff --git a/Modules/Wrappers/SWIG/src/python/itkPyCommand.h b/Modules/Wrappers/SWIG/src/python/itkPyCommand.h index f7f28333ea..5537bd56c3 100644 --- a/Modules/Wrappers/SWIG/src/python/itkPyCommand.h +++ b/Modules/Wrappers/SWIG/src/python/itkPyCommand.h @@ -70,8 +70,8 @@ public: PyObject * GetCommandCallable(); - void Execute(Object *, const EventObject&) ITK_OVERRIDE; - void Execute(const Object *, const EventObject&) ITK_OVERRIDE; + void Execute(Object *, const EventObject&) override; + void Execute(const Object *, const EventObject&) override; protected: PyCommand(); -- GitLab From 9ec53d342a990137148491299d87bdf363c12069 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 12 Mar 2018 11:11:55 +0100 Subject: [PATCH 437/567] BUG: fix parsing of Kmeans model files --- .../AppClassification/app/otbKMeansClassification.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx index a5067bf9cd..eb28154478 100644 --- a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx +++ b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx @@ -292,12 +292,15 @@ protected: itkExceptionMacro(<< "File : " << modelFileName << " couldn't be opened"); } - // get the end line with the centroids + // get the line with the centroids (starts with "2 ") std::string line, centroidLine; while(std::getline(infile,line)) { - if (!line.empty()) + if (line.size() > 2 && line[0] == '2' && line[1] == ' ') + { centroidLine = line; + break; + } } std::vector<std::string> centroidElm; -- GitLab From 4782e82f02fa33e3840a27ddd3cb540f996b917a Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 12 Mar 2018 11:15:49 +0100 Subject: [PATCH 438/567] ENH: add a free ressources method to release Data Object --- .../include/otbWrapperApplication.h | 4 + .../src/otbWrapperApplication.cxx | 92 +++++++++++++++++-- 2 files changed, 89 insertions(+), 7 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index a05931d46b..1f7a60c933 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -850,6 +850,8 @@ public: void RegisterPipeline(); + void FreeRessources(); + protected: /** Constructor */ Application(); @@ -984,6 +986,8 @@ private: * implementation does nothing */ virtual void AfterExecuteAndWriteOutputs(); + virtual void DoFreeRessources(){}; + Application(const Application &); //purposely not implemented void operator =(const Application&); //purposely not implemented diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 9a3c032c4a..ba2c32bb3d 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -441,7 +441,6 @@ Application::RegisterPipeline() Parameter * param = GetParameterByKey(key); InputVectorDataParameter * inP = dynamic_cast< InputVectorDataParameter * > ( param ); - std::cout<<"Getting data from outputvectordataparameter"<<std::endl; if ( !inP->HasValue() ) continue; VectorDataType * inData = inP->GetVectorData(); @@ -508,6 +507,90 @@ Application::RegisterPipeline() } } +void Application::FreeRessources() +{ + std::set< itk::DataObject * > dataSet; + std::vector<std::string> paramList = GetParametersKeys(true); + for (std::vector<std::string>::const_iterator it = paramList.begin(); + it != paramList.end(); + ++it) + { + std::string key = *it; + if ( GetParameterType(key) == ParameterType_OutputImage ) + { + Parameter* param = GetParameterByKey(key); + OutputImageParameter * outP = dynamic_cast<OutputImageParameter*>(param); + itk::ImageBase<2> * outData = outP->GetValue(); + if ( outData ) + dataSet.insert(outData); + } + else if ( GetParameterType(key) == ParameterType_OutputVectorData ) + { + Parameter* param = GetParameterByKey(key); + OutputVectorDataParameter * outP = dynamic_cast<OutputVectorDataParameter*>(param); + Wrapper::VectorDataType * outData = outP->GetValue(); + if ( outData ) + dataSet.insert(outData); + } + else + continue; + } + // DFS + std::stack< itk::ProcessObject * > processStack; + for ( auto data : dataSet ) + { + auto process = (data->GetSource()).GetPointer(); + if ( process ) + processStack.push( process ); + } + + while ( !processStack.empty() ) + { + itk::ProcessObject * current = processStack.top(); + processStack.pop(); + std::cout<<current->GetNameOfClass()<<std::endl; + if ( !current ) + continue; + auto inputVector = current->GetInputs(); + for ( auto data : inputVector ) + { + if ( !data.GetPointer() || dataSet.count( data.GetPointer() ) ) + continue; + if ( dynamic_cast< ObjectListInterface *> (data.GetPointer()) ) + { + ObjectListInterface * list = + dynamic_cast< ObjectListInterface *> (data.GetPointer()); + int length = list->Size(); + for ( int i = 0 ; i < length ; i++ ) + { + itk::DataObject * newData = list->GetNthDataObject(i); + if ( !newData || dataSet.count( newData ) ) + continue; + dataSet.insert( newData ); + itk::ProcessObject * process = newData->GetSource().GetPointer(); + if ( process ) + processStack.push( process ); + } + } + else + { + dataSet.insert( data.GetPointer() ); + itk::ProcessObject * process = data->GetSource().GetPointer(); + if ( process ) + processStack.push( process ); + } + } + } + + for ( auto data : dataSet ) + { + std::cout<<"one bulk is freed"<<std::endl; + data->ReleaseData(); + } + + DoFreeRessources(); +} + int Application::Execute() { @@ -672,12 +755,7 @@ int Application::ExecuteAndWriteOutput() this->AfterExecuteAndWriteOutputs(); m_Chrono.Stop(); - // for ( auto filter : m_Filters ) - // { - // std::cout<<"For filter : "<<filter->GetNameOfClass()<< - // " count : "<<filter->GetReferenceCount()<<std::endl; - // } - + FreeRessources(); m_Filters.clear(); return status; } -- GitLab From a9c3d553ed1527d54f95f1f8c25deb3595102abc Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Mon, 12 Mar 2018 11:26:02 +0100 Subject: [PATCH 439/567] TEST: Fix failing test (comparing stdout to a ref is a bad test design ...) --- Modules/Feature/Descriptors/test/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Feature/Descriptors/test/CMakeLists.txt b/Modules/Feature/Descriptors/test/CMakeLists.txt index 587685882e..6382e7b260 100644 --- a/Modules/Feature/Descriptors/test/CMakeLists.txt +++ b/Modules/Feature/Descriptors/test/CMakeLists.txt @@ -263,9 +263,10 @@ otb_add_test(NAME feTvFourierMellinDescriptors COMMAND otbDescriptorsTestDriver ) otb_add_test(NAME feTvImageToSIFTKeyPointSetFilterDistanceMap COMMAND otbDescriptorsTestDriver - --compare-ascii ${EPSILON_3} + --compare-ascii ${EPSILON_3} ${BASELINE_FILES}/feTvImageToSIFTKeyPointSetFilterDistanceMap.txt ${TEMP}/feTvImageToSIFTKeyPointSetFilterDistanceMap.txt + --ignore-lines-with 2 INFO DEBUG otbImageToSIFTKeyPointSetFilterDistanceMap ${INPUTDATA}/scene.png 6 3 0.08 10.0 -- GitLab From 73d6e308afc72bc38a2ca11b67000254d21784f3 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 12 Mar 2018 14:10:45 +0100 Subject: [PATCH 440/567] TEST: add test for shark relabelling function --- .../Learning/LearningBase/otb-module.cmake | 5 ++++- .../Learning/LearningBase/test/CMakeLists.txt | 11 +++++++--- .../test/otbLearningBaseTestDriver.cxx | 2 ++ .../ThirdParty/Shark/include/otbSharkUtils.h | 22 +++++++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Modules/Learning/LearningBase/otb-module.cmake b/Modules/Learning/LearningBase/otb-module.cmake index afa2a339a1..22ea02236a 100644 --- a/Modules/Learning/LearningBase/otb-module.cmake +++ b/Modules/Learning/LearningBase/otb-module.cmake @@ -28,7 +28,10 @@ otb_module(OTBLearningBase OTBImageBase OTBITK - TEST_DEPENDS + OPTIONAL_DEPENDS + OTBShark + + TEST_DEPENDS OTBTestKernel OTBImageIO diff --git a/Modules/Learning/LearningBase/test/CMakeLists.txt b/Modules/Learning/LearningBase/test/CMakeLists.txt index d1917c1be1..48e28cc5ca 100644 --- a/Modules/Learning/LearningBase/test/CMakeLists.txt +++ b/Modules/Learning/LearningBase/test/CMakeLists.txt @@ -30,9 +30,12 @@ otbSEMClassifierNew.cxx otbDecisionTreeNew.cxx otbKMeansImageClassificationFilterNew.cxx otbMachineLearningModelTemplates.cxx -otbSharkUtilsTests.cxx ) +if(OTB_USE_SHARK) + set(OTBLearningBaseTests ${OTBLearningBaseTests} otbSharkUtilsTests.cxx) +endif() + add_executable(otbLearningBaseTestDriver ${OTBLearningBaseTests}) target_link_libraries(otbLearningBaseTestDriver ${OTBLearningBase-Test_LIBRARIES}) otb_module_target_label(otbLearningBaseTestDriver) @@ -69,5 +72,7 @@ otb_add_test(NAME leTuDecisionTreeNew COMMAND otbLearningBaseTestDriver otb_add_test(NAME leTuKMeansImageClassificationFilterNew COMMAND otbLearningBaseTestDriver otbKMeansImageClassificationFilterNew) -otb_add_test(NAME leTuSharkNormalizeLabels COMMAND otbLearningBaseTestDriver - otbSharkNormalizeLabels) +if(OTB_USE_SHARK) + otb_add_test(NAME leTuSharkNormalizeLabels COMMAND otbLearningBaseTestDriver + otbSharkNormalizeLabels) +endif() diff --git a/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx b/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx index 305b712c31..dc2d36b794 100644 --- a/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx +++ b/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx @@ -29,5 +29,7 @@ void RegisterTests() REGISTER_TEST(otbSEMClassifierNew); REGISTER_TEST(otbDecisionTreeNew); REGISTER_TEST(otbKMeansImageClassificationFilterNew); +#ifdef OTB_USE_SHARK REGISTER_TEST(otbSharkNormalizeLabels); +#endif } diff --git a/Modules/ThirdParty/Shark/include/otbSharkUtils.h b/Modules/ThirdParty/Shark/include/otbSharkUtils.h index de3adf7740..04c57b6d4e 100644 --- a/Modules/ThirdParty/Shark/include/otbSharkUtils.h +++ b/Modules/ThirdParty/Shark/include/otbSharkUtils.h @@ -23,6 +23,7 @@ #include <stdexcept> #include <string> +#include <unordered_map> #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push @@ -127,6 +128,27 @@ template <class T> void ListSampleToSharkVector(const T * listSample, std::vecto assert(listSample != nullptr); ListSampleRangeToSharkVector(listSample,output,0, static_cast<unsigned int>(listSample->Size())); } + +/** Shark assumes that labels are 0 ... (nbClasses-1). This function modifies the labels contained in the input vector and returns a vector with size = nbClasses which allows the translation from the normalised labels to the new ones oldLabel = dictionary[newLabel]. +*/ +template <typename T> void NormalizeLabelsAndGetDictionary(std::vector<T>& labels, + std::vector<T>& dictionary) +{ + std::unordered_map<T, T> dictMap; + T labelCount{0}; + for(const auto& l : labels) + { + if(dictMap.find(l)==dictMap.end()) + dictMap.insert({l, labelCount++}); + } + dictionary.resize(labelCount); + for(auto& l : labels) + { + auto newLabel = dictMap[l]; + dictionary[newLabel] = l; + l = newLabel; + } +} } } -- GitLab From 3075e433590d8daef57f71eb55bffd276978ea9e Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 12 Mar 2018 14:53:51 +0100 Subject: [PATCH 441/567] ENH: correct doc name --- .../AppClassification/app/otbSampleAugmentation.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx index 9749a9f4c4..c0367e6efd 100644 --- a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -57,7 +57,7 @@ private: SetDescription("Generates synthetic samples from a sample data file."); // Documentation - SetDocName("Sample Extraction"); + SetDocName("Sample Augmentation"); SetDocLongDescription("The application takes a sample data file as " "generated by the SampleExtraction application and " "generates synthetic samples to increase the number of " -- GitLab From 79ce383f0a0d3df13216d51651e3c5acc6b19223 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 12 Mar 2018 15:04:03 +0100 Subject: [PATCH 442/567] ENH: remove the option to update the input file --- .../app/otbSampleAugmentation.cxx | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx index c0367e6efd..452119d05f 100644 --- a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -73,8 +73,7 @@ private: AddParameter(ParameterType_OutputFilename, "out", "Output samples"); SetParameterDescription("out","Output vector data file storing new samples" - "(OGR format). If not given, the input vector data file is updated"); - MandatoryOff("out"); + "(OGR format)."); AddParameter(ParameterType_ListView, "field", "Field Name"); SetParameterDescription("field","Name of the field carrying the class name in the input vectors."); @@ -190,19 +189,9 @@ private: { ogr::DataSource::Pointer vectors; ogr::DataSource::Pointer output; - if (IsParameterEnabled("out") && HasValue("out")) - { - vectors = ogr::DataSource::New(this->GetParameterString("in")); - output = ogr::DataSource::New(this->GetParameterString("out"), - ogr::DataSource::Modes::Overwrite); - } - else - { - // Update mode - vectors = ogr::DataSource::New(this->GetParameterString("in"), - ogr::DataSource::Modes::Update_LayerUpdate); - output = vectors; - } + vectors = ogr::DataSource::New(this->GetParameterString("in")); + output = ogr::DataSource::New(this->GetParameterString("out"), + ogr::DataSource::Modes::Overwrite); // Retrieve the field name std::vector<int> selectedCFieldIdx = GetSelectedItems("field"); -- GitLab From 37125f58a5afd52262c2476905f017a55f17f4c5 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 12 Mar 2018 17:35:31 +0100 Subject: [PATCH 443/567] COMP: link error with Boost on Windows --- Modules/ThirdParty/Boost/otb-module-init.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Modules/ThirdParty/Boost/otb-module-init.cmake b/Modules/ThirdParty/Boost/otb-module-init.cmake index a5f58041fb..0a07bdfdbc 100644 --- a/Modules/ThirdParty/Boost/otb-module-init.cmake +++ b/Modules/ThirdParty/Boost/otb-module-init.cmake @@ -31,3 +31,8 @@ if (BUILD_TESTING) message(STATUS "Found Boost components: unit_test_framework") endif() endif() #BUILD_TESTING + +if(WIN32) + # disable autolinking in boost + add_definitions( -DBOOST_ALL_NO_LIB ) +endif() -- GitLab From e08d948b8417adc595677ca7faa7db9d0520cd27 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 12 Mar 2018 18:53:17 +0100 Subject: [PATCH 444/567] ENH: support AbortGenerateData in virtual streamer --- .../include/otbStreamingImageVirtualWriter.h | 8 +++++ .../otbStreamingImageVirtualWriter.txx | 31 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h index feff1c60c5..dceefc9d0f 100644 --- a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h +++ b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h @@ -142,6 +142,11 @@ public: * This filter does not produce an output */ void Update() ITK_OVERRIDE; + // the interface of the superclass getter function is not thread safe + bool GetAbortGenerateDataMutex() const; + + void SetAbortGenerateData(bool val) override; + protected: StreamingImageVirtualWriter(); @@ -186,6 +191,9 @@ private: bool m_IsObserving; unsigned long m_ObserverID; + + /** Lock to ensure thread-safety (added for the AbortGenerateData flag) */ + itk::SimpleFastMutexLock m_Lock; }; } // end namespace otb diff --git a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx index b4fc50fbfa..71ef9b909e 100644 --- a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx +++ b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx @@ -238,7 +238,7 @@ StreamingImageVirtualWriter<TInputImage> */ InputImageRegionType streamRegion; for (m_CurrentDivision = 0; - m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateData(); + m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateDataMutex(); m_CurrentDivision++, m_DivisionProgress = 0, this->UpdateFilterProgress()) { streamRegion = m_StreamingManager->GetSplit(m_CurrentDivision); @@ -255,10 +255,17 @@ StreamingImageVirtualWriter<TInputImage> * If we ended due to aborting, push the progress up to 1.0 (since * it probably didn't end there) */ - if (!this->GetAbortGenerateData()) + if (!this->GetAbortGenerateDataMutex()) { this->UpdateProgress(1.0); } + else + { + itk::ProcessAborted e(__FILE__, __LINE__); + e.SetLocation(ITK_LOCATION); + e.SetDescription("Image streaming has been aborted"); + throw e; + } // Notify end event observers this->InvokeEvent(itk::EndEvent()); @@ -286,6 +293,26 @@ StreamingImageVirtualWriter<TInputImage> this->ReleaseInputs(); } +template <class TInputImage> +bool +StreamingImageVirtualWriter<TInputImage> +::GetAbortGenerateDataMutex() const +{ + m_Lock.Lock(); + bool ret = Superclass::GetAbortGenerateData(); + m_Lock.Unlock(); + return ret; +} + +template <class TInputImage> +void +StreamingImageVirtualWriter<TInputImage> +::SetAbortGenerateData(bool val) +{ + m_Lock.Lock(); + Superclass::SetAbortGenerateData(val); + m_Lock.Unlock(); +} } // end namespace otb -- GitLab From 88a6c35392f6d175c3f8c8fed97167f184b4ef3e Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 12 Mar 2018 18:54:37 +0100 Subject: [PATCH 445/567] ENH: throw an exception when process is aborted --- Modules/IO/ImageIO/include/otbImageFileWriter.txx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index 454fdea478..2cfc72794d 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -649,6 +649,13 @@ ImageFileWriter<TInputImage> { this->UpdateProgress(1.0); } + else + { + itk::ProcessAborted e(__FILE__, __LINE__); + e.SetLocation(ITK_LOCATION); + e.SetDescription("Image writing has been aborted"); + throw e; + } // Notify end event observers this->InvokeEvent(itk::EndEvent()); -- GitLab From 4d76ceb0c9e2019a5d02e4d00183715b420b463e Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 12 Mar 2018 18:55:19 +0100 Subject: [PATCH 446/567] ENH: stop the current watched process --- .../src/otbWrapperApplication.cxx | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index dc66786557..9053fa9326 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -527,24 +527,7 @@ int Application::ExecuteAndWriteOutput() void Application::Stop() { - std::vector<std::string> paramList = GetParametersKeys(true); - for (std::vector<std::string>::const_iterator it = paramList.begin(); - it != paramList.end(); - ++it) - { - std::string key = *it; - if (GetParameterType(key) == ParameterType_OutputImage - && IsParameterEnabled(key) && HasValue(key) ) - { - Parameter* param = GetParameterByKey(key); - OutputImageParameter* outputParam = dynamic_cast<OutputImageParameter*>(param); - - if(outputParam!=ITK_NULLPTR) - { - outputParam->GetWriter()->SetAbortGenerateData(true); - } - } - } + m_ProgressSource->SetAbortGenerateData(true); } /* Enable the use of an optional parameter. Returns the previous state */ -- GitLab From a2964ec68a292547719fede66752cbc13582697a Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 12 Mar 2018 18:57:06 +0100 Subject: [PATCH 447/567] ENH: catch the ProcessAborted exception --- .../Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx | 1 - Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 9053fa9326..7700ef8f2b 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -517,7 +517,6 @@ int Application::ExecuteAndWriteOutput() } } - // TODO: only if no Stop() was called this->AfterExecuteAndWriteOutputs(); m_Chrono.Stop(); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx index eaef5e473b..5d458d0f15 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx @@ -331,6 +331,10 @@ AppliThread m_Application->GetLogger()->Fatal(string("Cannot open image ") + err.m_Filename + string(". ") + err.GetDescription() + string("\n")); emit ExceptionRaised( err.what() ); } + catch(itk::ProcessAborted& err) + { + m_Application->GetLogger()->Info("Processing aborted\n"); + } catch(itk::ExceptionObject& err) { m_Application->GetLogger()->Debug("Caught itk::ExceptionObject during application execution:\n"); -- GitLab From 581f80785bbabff387b49c042e8631e0271ec22a Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 13 Mar 2018 09:28:43 +0100 Subject: [PATCH 448/567] COMP: std_complex.i doesn't exist for Java --- Modules/Wrappers/SWIG/src/itkBase.i | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/Wrappers/SWIG/src/itkBase.i b/Modules/Wrappers/SWIG/src/itkBase.i index 02d713407c..66cb0d1f50 100644 --- a/Modules/Wrappers/SWIG/src/itkBase.i +++ b/Modules/Wrappers/SWIG/src/itkBase.i @@ -54,7 +54,9 @@ %include <std_string.i> %include <std_vector.i> %include <std_map.i> +#if SWIGPYTHON %include <std_complex.i> +#endif %template(vectorstring) std::vector< std::string >; %template(mapstringstring) std::map< std::string, std::string >; -- GitLab From ee7eac625a07220b53ed74fa4e555f23ad7a831a Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Tue, 13 Mar 2018 14:41:59 +0100 Subject: [PATCH 449/567] ENH: Change default level to INFO whatever compilation options --- Documentation/Cookbook/rst/AdvancedUse.rst | 2 +- Modules/Core/Common/include/otbConfigurationManager.h | 3 +-- Modules/Core/Common/src/otbConfigurationManager.cxx | 6 +----- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Documentation/Cookbook/rst/AdvancedUse.rst b/Documentation/Cookbook/rst/AdvancedUse.rst index d985193932..604380e57a 100644 --- a/Documentation/Cookbook/rst/AdvancedUse.rst +++ b/Documentation/Cookbook/rst/AdvancedUse.rst @@ -14,7 +14,7 @@ those values. * ``OTB_DEM_DIRECTORY``: Default directory were DEM tiles are stored. It should only contain ```.hgt`` or or georeferenced ``.tif`` files. Empty if not set (no directory set) * ``OTB_GEOID_FILE``: Default path to the geoid file that will be used to retrieve height of DEM above ellipsoid. Empty if not set (no geoid set) * ``OTB_MAX_RAM_HINT``: Default maximum memory that OTB should use for processing, in MB. If not set, default value is 128 MB. -* ``OTB_LOGGER_LEVEL``: Default level of logging for OTB. Should be one of ``DEBUG``, ``INFO``, ``WARNING``, ``CRITICAL`` or ``FATAL``, by increasing order of priority. Only messages with a higher priority than the level of logging will be displayed. By default level is ``DEBUG`` for Debug build and ``INFO`` otherwise. +* ``OTB_LOGGER_LEVEL``: Default level of logging for OTB. Should be one of ``DEBUG``, ``INFO``, ``WARNING``, ``CRITICAL`` or ``FATAL``, by increasing order of priority. Only messages with a higher priority than the level of logging will be displayed. If not set, default level is ``INFO``. Extended filenames ------------------ diff --git a/Modules/Core/Common/include/otbConfigurationManager.h b/Modules/Core/Common/include/otbConfigurationManager.h index 0c6b9118ae..71e45fe727 100644 --- a/Modules/Core/Common/include/otbConfigurationManager.h +++ b/Modules/Core/Common/include/otbConfigurationManager.h @@ -99,8 +99,7 @@ public: * be displayed. * * By default (if OTB_LOGGER_LEVEL is not set or can not be - * decoded), level is DEBUG in Debug or RelWithDebInfo builds, and - * INFO otherwise. + * decoded), level is INFO. * */ static itk::LoggerBase::PriorityLevelType GetLoggerLevel(); diff --git a/Modules/Core/Common/src/otbConfigurationManager.cxx b/Modules/Core/Common/src/otbConfigurationManager.cxx index 6e4819539d..d12d183362 100644 --- a/Modules/Core/Common/src/otbConfigurationManager.cxx +++ b/Modules/Core/Common/src/otbConfigurationManager.cxx @@ -69,12 +69,8 @@ itk::LoggerBase::PriorityLevelType ConfigurationManager::GetLoggerLevel() { std::string svalue; - #ifndef NDEBUG - itk::LoggerBase::PriorityLevelType level = itk::LoggerBase::DEBUG; - #else + // Default value is INFO itk::LoggerBase::PriorityLevelType level = itk::LoggerBase::INFO; - #endif - if(itksys::SystemTools::GetEnv("OTB_LOGGER_LEVEL",svalue)) { -- GitLab From 155e3b9d300e9335336e48fda11a8c02537db83d Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 14 Mar 2018 08:09:50 +0100 Subject: [PATCH 450/567] DOC: Change required level to merge from master to developer --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b98c3b7209..5bfaa30ffb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,7 +90,7 @@ template. The merge request will then be discussed by the community and the core OTB team. * Merge requests can not be merged until all discussions have been resolved (this is enforced by GitLab) -* Merge requests **must receive at least 2 positives votes from core developers** ("Master" members in Gitlab : include PSC members) before being merged +* Merge requests **must receive at least 2 positives votes from core developers** (members of Orfeo ToolBox project in Gitlab with at least "Developer" level: include PSC members) before being merged * The merger is responsible for checking that the branch is up-to-date with develop * Merge requests can be merged by anyone (not just PSC or RM) with push access to develop * Merge requests can be merged once the dashboard is proven green for this branch -- GitLab From 7511a25e44aa9b9d10b98942bc1931f47658d3ce Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 14 Mar 2018 08:24:32 +0100 Subject: [PATCH 451/567] DOC: Small rephrasing --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5bfaa30ffb..0df03904ec 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,7 +90,7 @@ template. The merge request will then be discussed by the community and the core OTB team. * Merge requests can not be merged until all discussions have been resolved (this is enforced by GitLab) -* Merge requests **must receive at least 2 positives votes from core developers** (members of Orfeo ToolBox project in Gitlab with at least "Developer" level: include PSC members) before being merged +* Merge requests **must receive at least 2 positives votes from core developers** (members of Main Repositories group in Gitlab with at least "Developer" level; this includes PSC members) before being merged * The merger is responsible for checking that the branch is up-to-date with develop * Merge requests can be merged by anyone (not just PSC or RM) with push access to develop * Merge requests can be merged once the dashboard is proven green for this branch -- GitLab From 15bee4886796b78d352ec04562008ff4abf11823 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Mar 2018 08:37:03 +0100 Subject: [PATCH 452/567] TEST: add test and test driver --- .../Adapters/GdalAdapters/otb-module.cmake | 3 + .../Adapters/GdalAdapters/test/CMakeLists.txt | 29 +++++-- ...tbOGRExtendedFilenameToOptionsGDALTest.cxx | 75 +++++++++++++++++++ .../otbOGRExtendedFilenameToOptionsTest.cxx | 4 +- .../GdalAdapters/test/otbOGRTestDriver.cxx | 27 +++++++ 5 files changed, 130 insertions(+), 8 deletions(-) create mode 100644 Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx create mode 100644 Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx diff --git a/Modules/Adapters/GdalAdapters/otb-module.cmake b/Modules/Adapters/GdalAdapters/otb-module.cmake index 637a63ed42..c985c5fb0e 100644 --- a/Modules/Adapters/GdalAdapters/otb-module.cmake +++ b/Modules/Adapters/GdalAdapters/otb-module.cmake @@ -29,6 +29,9 @@ ENABLE_SHARED OTBGDAL OTBITK + TEST_DEPENDS + OTBTestKernel + DESCRIPTION "${DOCUMENTATION}" ) diff --git a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt index e3c150a7c4..cf846f576d 100644 --- a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt +++ b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt @@ -38,16 +38,31 @@ target_link_libraries(otbOGRTestsIO ${OTBGdalAdapters-Test_LIBRARIES}) otb_add_test(NAME coTuOGRDataSourceWrapperIO COMMAND otbOGRTestsIO ${INPUTDATA}/ToulousePoints-examples.shp ) -add_executable(otbOGRExtendedFilenameTest otbOGRExtendedFilenameToOptionsTest.cxx) -target_link_libraries(otbOGRExtendedFilenameTest ${OTBGdalAdapters-Test_LIBRARIES}) +set(OTBOGRTests +otbOGRTestDriver.cxx +otbOGRExtendedFilenameToOptionsTest.cxx +otbOGRExtendedFilenameToOptionsGDALTest.cxx +) + +add_executable(otbOGRTestDriver ${OTBOGRTests}) +target_link_libraries(otbOGRTestDriver ${OTBGdalAdapters-Test_LIBRARIES}) +otb_module_target_label(otbOGRTestDriver) otb_add_test(NAME TvOGRExtendedFilename - COMMAND otbOGRExtendedFilenameTest + COMMAND otbOGRTestDriver --compare-ascii ${NOTOL} - ${BASELINE}/TvOGRExtendedFilename.txt - ${TEMP}/TvOGRExtendedFilename.txt + ${BASELINE}/TvOGRExtendedFilename.txt + ${TEMP}/TvOGRExtendedFilenameTest.txt + otbOGRExtendedFileName test.shp?&writegeom=ON&gdal:co:QUALITY=75&gdal:co:TILED=YES&gdal:co:BLOCKYSIZE=1024&gdal:lco:layeroption=OPTION&gdal:oo:openoption=OPTION - ${TEMP}/TvOGRExtendedFilename.txt ) -otb_module_target_label(otbOGRExtendedFilenameTest) + ${TEMP}/TvOGRExtendedFilenameTest.txt ) + +otb_add_test(NAME TvOGRExtendedFilenameGDAL + COMMAND otbOGRTestDriver + otbOGRExtendedFileNameGDAL + ${INPUTDATA}/ToulousePoints-examples.shp?&gdal:oo:openOption=OPTION + ${TEMP}/test.shp?&gdal:co:creationOption=OPTION&gdal:lco:layerOption=OPTION + ) + message(STATUS "Test link : ${OTBGdalAdapters-Test_LIBRARIES}") \ No newline at end of file diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx new file mode 100644 index 0000000000..a35f21042f --- /dev/null +++ b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "cpl_error.h" +#include "otbOGRExtendedFilenameToOptions.h" +#include "otbOGRDataSourceWrapper.h" +#include <iostream> +#include <fstream> + + +int otbOGRExtendedFileNameGDAL(int , char* argv[]) +{ + bool success = true ; + const char * inputOpen = argv[1]; + const char * inputCreation = argv[2]; + auto test = otb::ogr::DataSource::New( inputOpen ); + // std::cout<<"here"<<std::endl; + std::string error = CPLGetLastErrorMsg(); + if ( !error.empty() ) + std::cout<<error<<std::endl; + // if ( error.find( "does not support open option openOption" ) != std::string::npos ) + // success = true && success ; + // else + // success = false ; + // std::cout<<success<<std::endl; + + + test = otb::ogr::DataSource::New( inputCreation , otb::ogr::DataSource::Modes::Update_LayerOverwrite); +error = CPLGetLastErrorMsg(); + if ( !error.empty() ) + std::cout<<error<<std::endl; + // error = CPLGetLastErrorMsg(); + // std::cout<<error<<std::endl; + // if ( std::string(error).find( "does not support creation option creationOption" ) != std::string::npos ) + // success = true && success ; + // else + // success = false ; + // std::cout<<success<<std::endl; + + test->CreateLayer( "2layertest" , + ITK_NULLPTR , + wkbUnknown , + std::vector< std::string > { "newOption=OPTION" } ); +error = CPLGetLastErrorMsg(); + if ( !error.empty() ) + std::cout<<error<<std::endl; + // error = CPLGetLastErrorMsg(); + // std::cout<<error<<std::endl; + // if ( std::string(error).find( "toto" ) != std::string::npos ) + // success = true && success; + // else + // success = false ; + // std::cout<<success<<std::endl; + + return EXIT_SUCCESS; +} + + diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx index 47636bf5ec..45c39a2b23 100644 --- a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx +++ b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx @@ -27,12 +27,13 @@ using namespace otb; typedef OGRExtendedFilenameToOptions FilenameHelperType; -int main(int , char* argv[]) +int otbOGRExtendedFileName(int , char* argv[]) { // Verify the number of parameters in the command line const char * inputExtendedFilename = argv[1]; const char * outputFilename = argv[2]; + std::cout<< argv[1] <<" "<<argv[2]<<std::endl; FilenameHelperType::Pointer helper = FilenameHelperType::New(); helper->SetExtendedFileName(inputExtendedFilename); @@ -69,6 +70,7 @@ int main(int , char* argv[]) layer.push_back("TOTO=first"); FilenameHelperType::Pointer layerHelper = FilenameHelperType::GetGDALLayerOptionsHelper ( layer ); + std::cout<< layerHelper->GetGDALLayerOptions()[0] <<std::endl; FilenameHelperType::GDALOptionType newOptions; // std::vector< std::string> newOptions; newOptions.push_back("TOTO=second"); diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx new file mode 100644 index 0000000000..0793f8c07d --- /dev/null +++ b/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbTestMain.h" + +void RegisterTests() +{ + REGISTER_TEST(otbOGRExtendedFileName); + REGISTER_TEST(otbOGRExtendedFileNameGDAL); +} -- GitLab From a222b183fb912d604f6d77ab8915dc41d2463bd2 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Wed, 14 Mar 2018 08:52:43 +0100 Subject: [PATCH 453/567] DOC: Add warning about corner case of logger instance --- Modules/Core/Common/include/otbLogger.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index d252a93d31..ef420c7b23 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -44,6 +44,14 @@ public: itkTypeMacro(Logger, itk::Logger); + /** + * If Logger crashes when called from the destructor of a static + * or global object, the singleton might have already been destroyed. + * You can prolong its lifetime by calling Logger::Instance() + * from that object's constructor. + * + * See https://stackoverflow.com/questions/335369/finding-c-static-initialization-order-problems#335746 + */ static Pointer Instance(); itkNewMacro(Self); -- GitLab From 7270cf168f7f2c29147634a54c8f9e608586feaf Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Mar 2018 10:47:44 +0100 Subject: [PATCH 454/567] ENH: add FreeRessources method to SWIG wrapping --- Modules/Wrappers/SWIG/src/otbApplication.i | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index 88802af41a..b16280c198 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -211,6 +211,8 @@ public: std::string GetProgressDescription() const; + void FreeRessources(); + itkSetStringMacro(DocName); itkGetStringMacro(DocName); itkSetStringMacro(DocLongDescription); -- GitLab From 76a985980647e2d59fde318533e3ff4ea2d12e5a Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Mar 2018 11:06:14 +0100 Subject: [PATCH 455/567] DOC: enhance code documentation --- .../include/otbWrapperApplication.h | 17 +++++++++++++++++ .../src/otbWrapperApplication.cxx | 14 ++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 1f7a60c933..aa9e719c82 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -848,8 +848,25 @@ public: this->SetDocLink(link); } + /** + Register all ProcessObject that are linked to parameters : + \li ParameterType_OutputImage + \li ParameterType_OutputVectorData + + Those ProcessObjects are stored in the m_Filters set and are deleted at the + end of ExecuteAndWriteOutput (if there are only held by the set) + This method can be called just before the end of a DoExecute in a derived + class of Application. + */ void RegisterPipeline(); + /** + Register all DataObject that are reachable from : + \li ParameterType_OutputImage + \li ParameterType_OutputVectorData + + Once registered, the methode ReleaseData is called on each one of them. + */ void FreeRessources(); protected: diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index ba2c32bb3d..089777f20d 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -388,6 +388,7 @@ Application::RegisterPipeline() std::stack< itk::DataObject * > dataStack; std::set< itk::DataObject * > inputData; std::vector<std::string> paramList = GetParametersKeys(true); + // Get both end of the pipeline for ( key : paramList ) { if ( GetParameterType(key) == ParameterType_OutputImage ) @@ -511,6 +512,7 @@ void Application::FreeRessources() { std::set< itk::DataObject * > dataSet; std::vector<std::string> paramList = GetParametersKeys(true); + // Get the end of the pipeline for (std::vector<std::string>::const_iterator it = paramList.begin(); it != paramList.end(); ++it) @@ -535,7 +537,7 @@ void Application::FreeRessources() else continue; } - // DFS + // initialize DFS std::stack< itk::ProcessObject * > processStack; for ( auto data : dataSet ) { @@ -543,19 +545,23 @@ void Application::FreeRessources() if ( process ) processStack.push( process ); } - + // DFS while ( !processStack.empty() ) { itk::ProcessObject * current = processStack.top(); processStack.pop(); std::cout<<current->GetNameOfClass()<<std::endl; + // if null continue if ( !current ) continue; + // Get all inputs auto inputVector = current->GetInputs(); for ( auto data : inputVector ) { + // If input is null or already in the set continue if ( !data.GetPointer() || dataSet.count( data.GetPointer() ) ) continue; + // If input is a list if ( dynamic_cast< ObjectListInterface *> (data.GetPointer()) ) { ObjectListInterface * list = @@ -581,13 +587,13 @@ void Application::FreeRessources() } } } - + // Release data for ( auto data : dataSet ) { std::cout<<"one bulk is freed"<<std::endl; data->ReleaseData(); } - + // Call overrode method DoFreeRessources(); } -- GitLab From b5263f8f5c16bbb55d44fa080b840a599340e9b2 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Mar 2018 11:33:55 +0100 Subject: [PATCH 456/567] DOC: add brief documentation for objectlistinterface class --- .../Core/ObjectList/include/otbObjectListInterface.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Modules/Core/ObjectList/include/otbObjectListInterface.h b/Modules/Core/ObjectList/include/otbObjectListInterface.h index a99df955c6..8b920a40ef 100644 --- a/Modules/Core/ObjectList/include/otbObjectListInterface.h +++ b/Modules/Core/ObjectList/include/otbObjectListInterface.h @@ -28,12 +28,22 @@ namespace otb class ObjectListInterface { - +/** \class ObjectListInterface + * \brief This non template class is an interface that wrapp ObjectList + * + * New method that do not need the template parameter of ObjectList + * should be declare here. + * + * \ingroup ObjectListInterface + */ public: ObjectListInterface() {}; virtual ~ObjectListInterface(){}; + /** + Get the nth element of the list as a DataObject *. + */ virtual itk::DataObject * GetNthDataObject(unsigned int index) const = 0; virtual std::size_t Size(void) const = 0; -- GitLab From ab4c8cab37bb92b5333d49428791a9732870d8f8 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 14 Mar 2018 13:51:04 +0100 Subject: [PATCH 457/567] DOC: add code documentation --- .../include/otbOGRExtendedFilenameToOptions.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h index c60d8c3be4..3b7b34653e 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h @@ -28,6 +28,10 @@ namespace otb { /** \class OGRExtendedFilenameToOptions + * \brief This class aim at processing GDAL option that can be pass through + * extended filename. + * + * \ingroup OTBExtendedFilename */ #include "OTBGdalAdaptersExport.h" @@ -66,11 +70,13 @@ public: std::unordered_map< std::string , std::string > gdalOptions; }; - /* Set Methods */ + /** Set extended filename */ void SetExtendedFileName(const char * extFname) override; + /** Get the GDAL option for type operation */ GDALOptionType GetGDALOptions( const std::string & type ) const ; + /** Get the deffierent GDAL options*/ GDALOptionType GetGDALOpenOptions() const ; GDALOptionType GetGDALCreationOptions() const ; GDALOptionType GetGDALLayerOptions() const ; @@ -78,9 +84,15 @@ public: bool SimpleFileNameIsSet() const; bool HasGDALLayerOption() const; + /** Set GDAL layer option through a vector of string */ void SetGDALLayerOptions( const GDALOptionType & options ); + + /** Add GDAL layer option to existing one */ void AddGDALLayerOptions( const GDALOptionType & options ); + /** Constructor that return a pointer to an OGRExtendedFilename with + * GDAL layer option as options + */ static Pointer GetGDALLayerOptionsHelper( const GDALOptionType & options ); protected: -- GitLab From 2ef5e7f0e96879110a05dbdbaab74c10aad854de Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 14 Mar 2018 19:16:45 +0100 Subject: [PATCH 458/567] DOC: start documenting python new services --- Documentation/Cookbook/rst/recipes/python.rst | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Documentation/Cookbook/rst/recipes/python.rst b/Documentation/Cookbook/rst/recipes/python.rst index f0b2e95f25..08f5ac8025 100644 --- a/Documentation/Cookbook/rst/recipes/python.rst +++ b/Documentation/Cookbook/rst/recipes/python.rst @@ -173,6 +173,31 @@ implementation does not break it, for instance by using an internal writer to write intermediate data. In this case, execution should still be correct, but some intermediate data will be read or written. +Interactions with OTB pipeline +------------------------------ + +[since OTB 6.6] + +The application framework has been extended in order to provide ways to +interact with the pipelines inside each application. It applies only to +applications that use input or output images. Let's check what are the +functions added to the ``Application`` class: + +* ``GetImageOrigin(key, idx=0)``: returns the origin of the image (physical position of the first pixel center) +* ``GetImageSpacing(key, idx=0)``: returns the signed spacing of the image +* ``GetImageSize(key, idx=0)``: returns the size of the LargestPossibleRegion +* ``GetImageNbBands(key, idx=0)``: returns the number of components per pixel +* ``GetImageProjection(key, idx=0)``: returns the ProjRef +* ``GetImageKeywordlist(key, idx=0)``: returns the Ossim keywordlist +* ``GetImageMetaData(key, idx=0)``: returns the itk::MetaDataDictionary +* ``GetImageRequestedRegion(key, idx=0)`` +* ``PropagateRequestedRegion(key, region, idx=0)``: set a given RequestedRegion on the image and propagate it, returns the memory print estimation +* ``GetImageBasePixelType(key, idx=0)``: helper function to guess the pixel type of the underlying Image/VectorImage. +* ``GetParameterImageBase(key, idx=0)``: helper, returns the image as a ImageBaseType (works on all image parameters) +* ``SetParameterImageBase(key, idx=0)``: helper, sets the parameter InputImage/InputImageList/ComplexInputImage with an ImageBaseType + +Note: some of these function use an optional index to refer to an image parameter. By default this index is 0. It allows to access InputImageLists transparently. + Corner cases ------------ -- GitLab From 574937269f649eeafb491d3934fe75edda0af553 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 15 Mar 2018 17:37:02 +0100 Subject: [PATCH 459/567] DOC: python recipe on new services --- Documentation/Cookbook/rst/recipes/python.rst | 142 ++++++++++++++++-- 1 file changed, 126 insertions(+), 16 deletions(-) diff --git a/Documentation/Cookbook/rst/recipes/python.rst b/Documentation/Cookbook/rst/recipes/python.rst index 08f5ac8025..89d0bae895 100644 --- a/Documentation/Cookbook/rst/recipes/python.rst +++ b/Documentation/Cookbook/rst/recipes/python.rst @@ -181,22 +181,132 @@ Interactions with OTB pipeline The application framework has been extended in order to provide ways to interact with the pipelines inside each application. It applies only to applications that use input or output images. Let's check what are the -functions added to the ``Application`` class: - -* ``GetImageOrigin(key, idx=0)``: returns the origin of the image (physical position of the first pixel center) -* ``GetImageSpacing(key, idx=0)``: returns the signed spacing of the image -* ``GetImageSize(key, idx=0)``: returns the size of the LargestPossibleRegion -* ``GetImageNbBands(key, idx=0)``: returns the number of components per pixel -* ``GetImageProjection(key, idx=0)``: returns the ProjRef -* ``GetImageKeywordlist(key, idx=0)``: returns the Ossim keywordlist -* ``GetImageMetaData(key, idx=0)``: returns the itk::MetaDataDictionary -* ``GetImageRequestedRegion(key, idx=0)`` -* ``PropagateRequestedRegion(key, region, idx=0)``: set a given RequestedRegion on the image and propagate it, returns the memory print estimation -* ``GetImageBasePixelType(key, idx=0)``: helper function to guess the pixel type of the underlying Image/VectorImage. -* ``GetParameterImageBase(key, idx=0)``: helper, returns the image as a ImageBaseType (works on all image parameters) -* ``SetParameterImageBase(key, idx=0)``: helper, sets the parameter InputImage/InputImageList/ComplexInputImage with an ImageBaseType - -Note: some of these function use an optional index to refer to an image parameter. By default this index is 0. It allows to access InputImageLists transparently. +functions added to the ``Application`` class. There are a lot of getter +functions: + ++---------------------------------+---------------------------------------+ +| Function name | return value | ++=================================+=======================================+ +| ``GetImageOrigin(...)`` | origin of the image (physical position| +| | of the first pixel center) | ++---------------------------------+---------------------------------------+ +| ``GetImageSpacing(...)`` | signed spacing of the image | ++---------------------------------+---------------------------------------+ +| ``GetImageSize(...)`` | size of the LargestPossibleRegion | ++---------------------------------+---------------------------------------+ +| ``GetImageNbBands(...)`` | number of components per pixel | ++---------------------------------+---------------------------------------+ +| ``GetImageProjection(...)`` | Projection WKT string | ++---------------------------------+---------------------------------------+ +| ``GetImageKeywordlist(...)`` | Ossim keywordlist (sensor model) | ++---------------------------------+---------------------------------------+ +| ``GetImageMetaData(...)`` | the entire MetaDataDictionary | ++---------------------------------+---------------------------------------+ +| ``GetImageRequestedRegion(...)``| requested region | ++---------------------------------+---------------------------------------+ +| ``GetImageBasePixelType(...)`` | pixel type of the underlying | +| | Image/VectorImage. | ++---------------------------------+---------------------------------------+ + +All these getters functions use the following arguments: + +* ``key``: a string containing the key of the image parameter +* ``idx``: an optional index (default is 0) that can be used to access ImageList + parameters transparently + +There is also a function to send orders to the pipeline: + + ``PropagateRequestedRegion(key, region, idx=0)``: set a given RequestedRegion + on the image and propagate it, returns the memory print estimation. This function + can be used to measure the requested portion of input images necessary to produce + an extract of the full output. + +Note: a requested region (like other regions in the C++ API of otb::Image) is +just a pair of an image index and a size, that define a rectangular extract of +the full image. + +This set of function has been used to enhance the bridge between OTB images +and Numpy arrays. There are now import and export functions available in +Python that preserve the metadata of the image during conversions to Numpy +arrays: + +* ``ExportImage(self, key)``: export an output image parameter into a Python + dictionary. +* ``ImportImage(self, key, dict, index=0)``: import the image from a Python + dictionary into an image parameter (as a monoband image). +* ``ImportVectorImage(self, key, dict, index=0)``: import the image from a + Python dictionary into an image parameter (as a multiband image). + +The Python dictionary used has the following entries: + + * ``'array'``: the Numpy array containing the pixel buffer + * ``'origin'``: origin of the image + * ``'spacing'``: signed spacing of the image + * ``'size'``: full size of the image + * ``'region'``: region of the image present in the buffer + * ``'metadata'``: metadata dictionary (contains projection, sensor model,...) + +Now some basic Q&A about this interface: + + Q: What portion of the image is exported to Numpy array? + A: By default, the whole image is exported. If you had a non-empty requested + region (the result of calling PropagateRequestedRegion()), then this region + is exported. + + Q: What is the difference between ImportImage and ImportVectorImage? + A: The first one is here for Applications that expect a monoband otb::Image. + In most cases, you will use the second one: ImportVectorImage. + + Q: What kind of object are there in this dictionary export? + A: The array is a numpy.ndarray. The other fields are wrapped + objects from the OTB library but you can interact with them in a + Python way: they support ``len()`` and ``str()`` operator, as well as + bracket operator ``[]``. Some of them also have a ``keys()`` function just like + dictionaries. + +This interface allows you to export OTB images (or extracts) to Numpy array, +process them by other means, and re-import them with preserved metadatas. + +Here is a small example of what can be done: + +.. code-block:: python + + import otbApplication as otb + + # Create a smoothing application + app = otb.Registry.CreateApplication("Smoothing") + app.SetParameterString("in",argv[1]) + + # only call Execute() to setup the pipeline, not ExecuteAndWriteOutput() which would + # run it and write the output image + app.Execute() + + # Setup a special requested region + myRegion = otb.itkRegion() + myRegion['size'][0] = 20 + myRegion['size'][1] = 25 + myRegion['index'].Fill(10) + ram = app.PropagateRequestedRegion("out",myRegion) + + # Check the requested region on the input image + print(app.GetImageRequestedRegion("in")) + + # Create a ReadImageInfo application + app2 = otb.Registry.CreateApplication("ReadImageInfo") + + # export "out" from Smoothing and import it as "in" in ReadImageInfo + ex = app.ExportImage("out") + app2.ImportVectorImage("in", ex) + app2.Execute() + + # Check the result of ReadImageInfo + someKeys = ['sizex', 'sizey', 'spacingx', 'spacingy', 'sensor', 'projectionref'] + for key in someKeys: + print(key + ' : ' + str(app2.GetParameterValue(key)) ) + + # Only a portion of "out" was exported but ReadImageInfo is still able to detect the + # correct full size of the image + Corner cases ------------ -- GitLab From 70f46e2eb9e134c34be7e04f5876826d46c69c4b Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 15 Mar 2018 17:57:50 +0100 Subject: [PATCH 460/567] DOC: python recipe new services --- Documentation/Cookbook/rst/recipes/python.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Documentation/Cookbook/rst/recipes/python.rst b/Documentation/Cookbook/rst/recipes/python.rst index 89d0bae895..41306ac1ea 100644 --- a/Documentation/Cookbook/rst/recipes/python.rst +++ b/Documentation/Cookbook/rst/recipes/python.rst @@ -176,7 +176,7 @@ still be correct, but some intermediate data will be read or written. Interactions with OTB pipeline ------------------------------ -[since OTB 6.6] +[Since OTB 6.6] The application framework has been extended in order to provide ways to interact with the pipelines inside each application. It applies only to @@ -216,7 +216,7 @@ All these getters functions use the following arguments: There is also a function to send orders to the pipeline: - ``PropagateRequestedRegion(key, region, idx=0)``: set a given RequestedRegion + ``PropagateRequestedRegion(key, region, idx=0)``: sets a given RequestedRegion on the image and propagate it, returns the memory print estimation. This function can be used to measure the requested portion of input images necessary to produce an extract of the full output. @@ -230,11 +230,11 @@ and Numpy arrays. There are now import and export functions available in Python that preserve the metadata of the image during conversions to Numpy arrays: -* ``ExportImage(self, key)``: export an output image parameter into a Python +* ``ExportImage(self, key)``: exports an output image parameter into a Python dictionary. -* ``ImportImage(self, key, dict, index=0)``: import the image from a Python +* ``ImportImage(self, key, dict, index=0)``: imports the image from a Python dictionary into an image parameter (as a monoband image). -* ``ImportVectorImage(self, key, dict, index=0)``: import the image from a +* ``ImportVectorImage(self, key, dict, index=0)``: imports the image from a Python dictionary into an image parameter (as a multiband image). The Python dictionary used has the following entries: @@ -265,7 +265,8 @@ Now some basic Q&A about this interface: dictionaries. This interface allows you to export OTB images (or extracts) to Numpy array, -process them by other means, and re-import them with preserved metadatas. +process them by other means, and re-import them with preserved metadatas. Please +note that this is different from an in-memory connection. Here is a small example of what can be done: -- GitLab From b61960b4861a9fbb8f867afa2ec5f1054224782e Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 15 Mar 2018 20:55:35 +0100 Subject: [PATCH 461/567] ENH: pass vector as const& --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index f562a636e6..87cbf9b466 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -40,7 +40,7 @@ using SampleVectorType = std::vector<SampleType>; Estimate standard deviations of the components in one pass using Welford's algorithm */ -SampleType estimateStds(SampleVectorType samples) +SampleType estimateStds(const SampleVectorType& samples) { const auto nbSamples = samples.size(); const auto nbComponents = samples[0].size(); -- GitLab From 9e823ab6250e2cd6f46207d796d9b377bbeae7f0 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 15 Mar 2018 20:59:19 +0100 Subject: [PATCH 462/567] ENH: compute normalization factor outside of the loop --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index 87cbf9b466..a62424894b 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -49,11 +49,12 @@ SampleType estimateStds(const SampleVectorType& samples) #pragma omp parallel for for(size_t i=0; i<nbSamples; ++i) { + auto norm_factor = 1.0/(i+1); for(size_t j=0; j<nbComponents; ++j) { const auto mu = means[j]; const auto x = samples[i][j]; - auto muNew = mu+(x-mu)/(i+1); + auto muNew = mu+(x-mu)*norm_factor; stds[j] += (x-mu)*(x-muNew); means[j] = muNew; } -- GitLab From eaf9352ba2b436b87c8639a702520e0ab86827f3 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 15 Mar 2018 21:02:07 +0100 Subject: [PATCH 463/567] ENH: square distance is enough for sorting --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index a62424894b..a839031cf2 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -132,7 +132,7 @@ struct NeighborSorter } }; -double computeDistance(const SampleType& x, const SampleType& y) +double computeSquareDistance(const SampleType& x, const SampleType& y) { assert(x.size()==y.size()); double dist{0}; @@ -140,7 +140,7 @@ double computeDistance(const SampleType& x, const SampleType& y) { dist += (x[i]-y[i])*(x[i]-y[i])/(x.size()*x.size()); } - return std::sqrt(dist); + return dist; } using NNIndicesType = std::vector<NeighborType>; @@ -160,8 +160,8 @@ void findKNNIndices(const SampleVectorType& inSamples, for(size_t neighborIdx=0; neighborIdx<nbSamples; ++neighborIdx) { if(sampleIdx!=neighborIdx) - nns.push_back({neighborIdx, computeDistance(inSamples[sampleIdx], - inSamples[neighborIdx])}); + nns.push_back({neighborIdx, computeSquareDistance(inSamples[sampleIdx], + inSamples[neighborIdx])}); } std::partial_sort(nns.begin(), nns.begin()+nbNeighbors, nns.end(), NeighborSorter{}); nns.resize(nbNeighbors); -- GitLab From a55ea065f13cd36ec28bdf90be695c0eb145ea45 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 15 Mar 2018 21:03:12 +0100 Subject: [PATCH 464/567] ENH: avoid copy by moving --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index a839031cf2..869295b781 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -165,7 +165,7 @@ void findKNNIndices(const SampleVectorType& inSamples, } std::partial_sort(nns.begin(), nns.begin()+nbNeighbors, nns.end(), NeighborSorter{}); nns.resize(nbNeighbors); - nnVector[sampleIdx] = nns; + nnVector[sampleIdx] = std::move(nns); } } -- GitLab From 68b293a4a6c49802d69358abe2317f75065f2dcc Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 15 Mar 2018 21:12:39 +0100 Subject: [PATCH 465/567] ENH: use find_if instead of hand made loop --- .../include/otbSampleAugmentationFilter.txx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx index f7023c9b33..75895891ae 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx +++ b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx @@ -259,16 +259,14 @@ SampleAugmentationFilter ::selectTemplateFeature(const ogr::Layer& inputLayer, const std::string& classField, int label) { - auto featureIt = inputLayer.begin(); - while( featureIt!=inputLayer.end() ) - { - if((*featureIt).ogr().GetFieldAsInteger(classField.c_str()) == label) - { - return *featureIt; - } - ++featureIt; - } - return *(inputLayer.begin()); + auto wh = std::find_if(inputLayer.begin(), inputLayer.end(), + [&](auto& featureIt) + { + return featureIt.ogr().GetFieldAsInteger(classField.c_str()) == + label; + }); + return (wh == inputLayer.end()) ? *(inputLayer.begin()) : *wh; + } } // end namespace otb -- GitLab From 0db768ff01fea5d1082798ad02c23deb8f62f108 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 15 Mar 2018 21:30:06 +0100 Subject: [PATCH 466/567] ENH: parallelise the inner loop for cache friendliness --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index 869295b781..d0b1725d2a 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -46,10 +46,10 @@ SampleType estimateStds(const SampleVectorType& samples) const auto nbComponents = samples[0].size(); SampleType stds(nbComponents, 0.0); SampleType means(nbComponents, 0.0); -#pragma omp parallel for for(size_t i=0; i<nbSamples; ++i) { auto norm_factor = 1.0/(i+1); +#pragma omp parallel for for(size_t j=0; j<nbComponents; ++j) { const auto mu = means[j]; -- GitLab From 36de0e2b5da4c9687063b22a0cbb593d72b0238a Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Thu, 15 Mar 2018 21:38:59 +0100 Subject: [PATCH 467/567] ENH: normalization factor can be applied after the loop --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index d0b1725d2a..66753a09fe 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -138,9 +138,9 @@ double computeSquareDistance(const SampleType& x, const SampleType& y) double dist{0}; for(size_t i=0; i<x.size(); ++i) { - dist += (x[i]-y[i])*(x[i]-y[i])/(x.size()*x.size()); + dist += (x[i]-y[i])*(x[i]-y[i]); } - return dist; + return dist/(x.size()*x.size()); } using NNIndicesType = std::vector<NeighborType>; -- GitLab From c1384e44807977f619c2c8c1fc53c8c32d43ea46 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Mar 2018 09:43:20 +0100 Subject: [PATCH 468/567] TEST: only print dictionary keys --- .../ApplicationEngine/test/otbWrapperImageInterface.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx b/Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx index 56c1cba520..cc1963ecd1 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx +++ b/Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx @@ -67,8 +67,11 @@ int otbWrapperImageInterface(int argc, char * argv[]) ofs << app1->GetImageProjection("out") << std::endl; itk::MetaDataDictionary dict = app1->GetImageMetaData("out"); - ofs << "Dictionary:"<< std::endl; - dict.Print(ofs); + ofs << "Dictionary keys:"<< std::endl; + for (auto & key : dict.GetKeys()) + { + ofs << " - "<< key << std::endl; + } otb::Wrapper::ImageBaseType::RegionType region; region.SetIndex(0,10); -- GitLab From 4d5c8ce82d8bb5348e47e03801925773cc5c2d04 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 16 Mar 2018 10:04:10 +0100 Subject: [PATCH 469/567] Doc : add Cookbool documentation --- Documentation/Cookbook/rst/AdvancedUse.rst | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Documentation/Cookbook/rst/AdvancedUse.rst b/Documentation/Cookbook/rst/AdvancedUse.rst index 604380e57a..5ce7228d2f 100644 --- a/Documentation/Cookbook/rst/AdvancedUse.rst +++ b/Documentation/Cookbook/rst/AdvancedUse.rst @@ -315,6 +315,36 @@ The available syntax for boolean options are: - OFF, Off, off, false, False, 0 are available for setting a ’false’ boolean value +OGR DataSource options +^^^^^^^^^^^^^^^^^^^^^^^ + +We extended this process to OGR DataSource. There are three different type of +option : open, creation and layer creation. Those options come from the GDAL +API. In order to use them one just need to specify to which of this family +the option one want to use is from. + +For open option : + +:: + + &gdal:oo:<GDALKEY>=<VALUE> + + +For creation option : + +:: + + &gdal:co:<GDALKEY>=<VALUE> + + +For layer creation option : + +:: + + &gdal:lco:<GDALKEY>=<VALUE> + + + Examples ^^^^^^^^^^^^^^ -- GitLab From 037d422ea9c3bb2227e284f3225e4fd971a85323 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 16 Mar 2018 10:16:41 +0100 Subject: [PATCH 470/567] REFAC: take Luc comments into account : const& for vector --- .../GdalAdapters/include/otbOGRDataSourceWrapper.h | 8 ++++---- .../GdalAdapters/src/otbOGRDataSourceWrapper.cxx | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h index c288ec3c68..b06a173fd9 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h @@ -164,7 +164,7 @@ public: * \note No condition is assumed on the non-nullity of \c source. * \see \c DataSource(GDALDataset *) */ - static Pointer New(ogr::version_proxy::GDALDatasetType * sourcemode, Modes::type mode = Modes::Read , std::vector< std::string > layerOptions = std::vector< std::string >() ); + static Pointer New(ogr::version_proxy::GDALDatasetType * sourcemode, Modes::type mode = Modes::Read , const std::vector< std::string > & layerOptions = std::vector< std::string >() ); //@} /**\name Projection Reference property */ @@ -499,9 +499,9 @@ public: */ ogr::version_proxy::GDALDatasetType & ogr(); - void SetLayerCreationOptions( std::vector< std::string > options ); + void SetLayerCreationOptions( const std::vector< std::string > & options ); void AddLayerCreationOptions( std::vector< std::string > options ); - std::vector< std::string > GetLayerCreationOptions(); + const std::vector< std::string > & GetLayerCreationOptions() const ; protected: /** Default constructor. @@ -517,7 +517,7 @@ protected: /** Init constructor. * \post The newly constructed object owns the \c source parameter. */ - DataSource(ogr::version_proxy::GDALDatasetType * source, Modes::type mode , std::vector< std::string > layerOption = std::vector< std::string >() ); + DataSource(ogr::version_proxy::GDALDatasetType * source, Modes::type mode , const std::vector< std::string > & layerOption = std::vector< std::string >() ); /** Destructor. * \post The \c GDALDataset owned is released (if not null). */ diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx index 91ec386f4e..d5cfec4ef9 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx @@ -137,7 +137,7 @@ otb::ogr::DataSource::DataSource() otb::ogr::DataSource::DataSource( otb::ogr::version_proxy::GDALDatasetType * source , Modes::type mode , - std::vector< std::string > options /*NULL*/ ) + const std::vector< std::string > & options /*NULL*/ ) : m_DataSource(source) , m_LayerOptions(options) , m_OpenMode(mode) , @@ -244,7 +244,7 @@ otb::ogr::DataSource::New(std::string const& datasourceName, Modes::type mode) /*static*/ otb::ogr::DataSource::Pointer -otb::ogr::DataSource::New(otb::ogr::version_proxy::GDALDatasetType * source , Modes::type mode , std::vector< std::string > layerOptions ) +otb::ogr::DataSource::New(otb::ogr::version_proxy::GDALDatasetType * source , Modes::type mode , const std::vector< std::string > & layerOptions ) { Pointer res = new DataSource( source , mode , layerOptions ); res->UnRegister(); @@ -620,7 +620,7 @@ otb::ogr::Layer otb::ogr::DataSource::ExecuteSQL( void otb::ogr::DataSource:: -SetLayerCreationOptions( std::vector< std::string > options ) +SetLayerCreationOptions( const std::vector< std::string > & options ) { FileNameHelperType::Pointer helper = FileNameHelperType::New(); helper->SetGDALLayerOptions( options ); @@ -639,9 +639,9 @@ AddLayerCreationOptions( std::vector< std::string > options ) // perf : do we move code from helper->AddGDALLayerOptions in here? } -std::vector< std::string > +const std::vector< std::string > & otb::ogr::DataSource:: -GetLayerCreationOptions() +GetLayerCreationOptions() const { return m_LayerOptions; } -- GitLab From fb1a4876089e1b596d7cf7476525855e83b2a01f Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 16 Mar 2018 10:30:16 +0100 Subject: [PATCH 471/567] REFAC: take Luc comments into account (2) for OGRExtendedFileName class --- .../include/otbOGRExtendedFilenameToOptions.h | 2 +- .../GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h index 3b7b34653e..91ada31780 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h @@ -45,7 +45,7 @@ public: typedef ExtendedFilenameHelper Superclass; typedef Superclass::OptionMapType OptionMapType; - typedef OptionMapType::iterator MapIteratorType; + typedef OptionMapType::const_iterator ConstMapIteratorType; typedef std::vector<std::string> GDALOptionType; itkTypeMacro(OGRExtendedFilenameToOptions, otb::ExtendedFilenameHelper); diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx index 4e760c74cb..a34e709471 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRExtendedFilenameToOptions.cxx @@ -56,9 +56,9 @@ SetExtendedFileName(const char *extFname) Superclass::SetExtendedFileName(extFname); m_HasFileName = true; - OptionMapType map = GetOptionMap(); + const OptionMapType & map = GetOptionMap(); - MapIteratorType it; + ConstMapIteratorType it; for ( it=map.begin(); it != map.end(); it++ ) { std::vector<std::string> tmp; @@ -144,9 +144,7 @@ bool OGRExtendedFilenameToOptions:: HasGDALLayerOption() const { - if ( m_LayerOptions.gdalOptions.empty() ) - return false; - return true; + return ! m_LayerOptions.gdalOptions.empty() ; } OGRExtendedFilenameToOptions:: -- GitLab From c4b2eaf48b4630c196751d3a5411bf26e571e78b Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 16 Mar 2018 11:06:18 +0100 Subject: [PATCH 472/567] REFAC: remove m_ for non member variable --- .../AppImageUtils/app/otbCompareImages.cxx | 48 +++++++++---------- .../AppImageUtils/app/otbExtractROI.cxx | 16 +++---- .../AppImageUtils/app/otbQuicklook.cxx | 30 ++++++------ .../AppImageUtils/app/otbRescale.cxx | 32 ++++++------- .../AppImageUtils/app/otbSplitImage.cxx | 8 ++-- .../AppImageUtils/app/otbTileFusion.cxx | 8 ++-- .../app/otbLSMSSegmentation.cxx | 14 +++--- .../app/otbMeanShiftSmoothing.cxx | 22 ++++----- 8 files changed, 89 insertions(+), 89 deletions(-) diff --git a/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx b/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx index 6932ea634d..cbdcb90795 100644 --- a/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx +++ b/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx @@ -172,11 +172,11 @@ private: void DoExecute() override { // Init filters - ExtractROIMonoFilterType::Pointer m_ExtractRefFilter = + ExtractROIMonoFilterType::Pointer extractRefFilter = ExtractROIMonoFilterType::New(); - ExtractROIMonoFilterType::Pointer m_ExtractMeasFilter = + ExtractROIMonoFilterType::Pointer extractMeasFilter = ExtractROIMonoFilterType::New(); - StreamingCompareImageFilterType::Pointer m_CompareFilter = + StreamingCompareImageFilterType::Pointer compareFilter = StreamingCompareImageFilterType::New(); // Get input image pointers @@ -203,35 +203,35 @@ private: otbAppLogFATAL( << "ROI is not contained in the images regions"); } - m_ExtractRefFilter->SetInput( refIm ); - m_ExtractMeasFilter->SetInput( measIm ); + extractRefFilter->SetInput( refIm ); + extractMeasFilter->SetInput( measIm ); - m_ExtractRefFilter->SetExtractionRegion(region); - m_ExtractMeasFilter->SetExtractionRegion(region); + extractRefFilter->SetExtractionRegion(region); + extractMeasFilter->SetExtractionRegion(region); // Set channels to extract otbAppLogINFO( << "reference image channel "<<this->GetParameterInt("ref.channel")<<" is compared with measured image channel "<<this->GetParameterInt("meas.channel")); - m_ExtractRefFilter->SetChannel( this->GetParameterInt("ref.channel") ); - m_ExtractMeasFilter->SetChannel( this->GetParameterInt("meas.channel") ); + extractRefFilter->SetChannel( this->GetParameterInt("ref.channel") ); + extractMeasFilter->SetChannel( this->GetParameterInt("meas.channel") ); // Compute comparison - m_CompareFilter->SetInput1(m_ExtractRefFilter->GetOutput()); - m_CompareFilter->SetInput2(m_ExtractMeasFilter->GetOutput()); - m_CompareFilter->SetPhysicalSpaceCheck(false); - m_CompareFilter->GetStreamer()->SetAutomaticAdaptativeStreaming(GetParameterInt("ram")); - AddProcess(m_CompareFilter->GetStreamer(), "Comparing..."); - m_CompareFilter->Update(); + compareFilter->SetInput1(extractRefFilter->GetOutput()); + compareFilter->SetInput2(extractMeasFilter->GetOutput()); + compareFilter->SetPhysicalSpaceCheck(false); + compareFilter->GetStreamer()->SetAutomaticAdaptativeStreaming(GetParameterInt("ram")); + AddProcess(compareFilter->GetStreamer(), "Comparing..."); + compareFilter->Update(); // Show result - otbAppLogINFO( << "MSE: " << m_CompareFilter->GetMSE() ); - otbAppLogINFO( << "MAE: " << m_CompareFilter->GetMAE() ); - otbAppLogINFO( << "PSNR: " << m_CompareFilter->GetPSNR() ); - otbAppLogINFO( << "Number of Pixel different: " << m_CompareFilter->GetDiffCount() ); - - SetParameterFloat( "mse",m_CompareFilter->GetMSE()); - SetParameterFloat( "mae",m_CompareFilter->GetMAE()); - SetParameterFloat( "psnr",m_CompareFilter->GetPSNR()); - SetParameterFloat( "count",m_CompareFilter->GetDiffCount()); + otbAppLogINFO( << "MSE: " << compareFilter->GetMSE() ); + otbAppLogINFO( << "MAE: " << compareFilter->GetMAE() ); + otbAppLogINFO( << "PSNR: " << compareFilter->GetPSNR() ); + otbAppLogINFO( << "Number of Pixel different: " << compareFilter->GetDiffCount() ); + + SetParameterFloat( "mse",compareFilter->GetMSE()); + SetParameterFloat( "mae",compareFilter->GetMAE()); + SetParameterFloat( "psnr",compareFilter->GetPSNR()); + SetParameterFloat( "count",compareFilter->GetDiffCount()); RegisterPipeline(); } }; diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index b733a31fb8..66f2886edc 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -828,19 +828,19 @@ private: this->CropRegionOfInterest(); - ExtractROIFilterType::Pointer m_ExtractROIFilter = ExtractROIFilterType::New(); - m_ExtractROIFilter->SetInput(inImage); - m_ExtractROIFilter->SetStartX(GetParameterInt("startx")); - m_ExtractROIFilter->SetStartY(GetParameterInt("starty")); - m_ExtractROIFilter->SetSizeX(GetParameterInt("sizex")); - m_ExtractROIFilter->SetSizeY(GetParameterInt("sizey")); + ExtractROIFilterType::Pointer extractROIFilter = ExtractROIFilterType::New(); + extractROIFilter->SetInput(inImage); + extractROIFilter->SetStartX(GetParameterInt("startx")); + extractROIFilter->SetStartY(GetParameterInt("starty")); + extractROIFilter->SetSizeX(GetParameterInt("sizex")); + extractROIFilter->SetSizeY(GetParameterInt("sizey")); for (unsigned int idx = 0; idx < GetSelectedItems("cl").size(); ++idx) { - m_ExtractROIFilter->SetChannel(GetSelectedItems("cl")[idx] + 1 ); + extractROIFilter->SetChannel(GetSelectedItems("cl")[idx] + 1 ); } - SetParameterOutputImage("out", m_ExtractROIFilter->GetOutput()); + SetParameterOutputImage("out", extractROIFilter->GetOutput()); RegisterPipeline(); } }; diff --git a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx index 5de1f9268a..f31b64075b 100644 --- a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx +++ b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx @@ -207,29 +207,29 @@ bool CropRegionOfInterest() { InputImageType::Pointer inImage = GetParameterImage("in"); - ExtractROIFilterType::Pointer m_ExtractROIFilter = + ExtractROIFilterType::Pointer extractROIFilter = ExtractROIFilterType::New(); - ShrinkImageFilterType::Pointer m_ResamplingFilter = + ShrinkImageFilterType::Pointer resamplingFilter = ShrinkImageFilterType::New(); // The image on which the quicklook will be generated - // Will eventually be the m_ExtractROIFilter output + // Will eventually be the extractROIFilter output if (HasUserValue("rox") || HasUserValue("roy") || HasUserValue("rsx") || HasUserValue("rsy") || (GetSelectedItems("cl").size() > 0)) { - m_ExtractROIFilter->SetInput(inImage); - m_ExtractROIFilter->SetStartX(GetParameterInt("rox")); - m_ExtractROIFilter->SetStartY(GetParameterInt("roy")); - m_ExtractROIFilter->SetSizeX(GetParameterInt("rsx")); - m_ExtractROIFilter->SetSizeY(GetParameterInt("rsy")); + extractROIFilter->SetInput(inImage); + extractROIFilter->SetStartX(GetParameterInt("rox")); + extractROIFilter->SetStartY(GetParameterInt("roy")); + extractROIFilter->SetSizeX(GetParameterInt("rsx")); + extractROIFilter->SetSizeY(GetParameterInt("rsy")); if ((GetSelectedItems("cl").size() > 0)) { for (unsigned int idx = 0; idx < GetSelectedItems("cl").size(); ++idx) { - m_ExtractROIFilter->SetChannel(GetSelectedItems("cl")[idx] + 1 ); + extractROIFilter->SetChannel(GetSelectedItems("cl")[idx] + 1 ); } } else @@ -237,14 +237,14 @@ bool CropRegionOfInterest() unsigned int nbComponents = inImage->GetNumberOfComponentsPerPixel(); for (unsigned int idx = 0; idx < nbComponents; ++idx) { - m_ExtractROIFilter->SetChannel(idx + 1); + extractROIFilter->SetChannel(idx + 1); } } - m_ResamplingFilter->SetInput( m_ExtractROIFilter->GetOutput() ); + resamplingFilter->SetInput( extractROIFilter->GetOutput() ); } else { - m_ResamplingFilter->SetInput(inImage); + resamplingFilter->SetInput(inImage); } unsigned int Ratio = static_cast<unsigned int>(GetParameterInt("sr")); @@ -280,10 +280,10 @@ bool CropRegionOfInterest() } otbAppLogINFO( << "Ratio used: "<<Ratio << "."); - m_ResamplingFilter->SetShrinkFactor( Ratio ); - m_ResamplingFilter->Update(); + resamplingFilter->SetShrinkFactor( Ratio ); + resamplingFilter->Update(); - SetParameterOutputImage("out", m_ResamplingFilter->GetOutput()); + SetParameterOutputImage("out", resamplingFilter->GetOutput()); RegisterPipeline(); } diff --git a/Modules/Applications/AppImageUtils/app/otbRescale.cxx b/Modules/Applications/AppImageUtils/app/otbRescale.cxx index e9c97529c6..ad0992f504 100644 --- a/Modules/Applications/AppImageUtils/app/otbRescale.cxx +++ b/Modules/Applications/AppImageUtils/app/otbRescale.cxx @@ -101,24 +101,24 @@ private: otbAppLogDEBUG( << "Starting Min/Max computation" ) - MinMaxFilterType::Pointer m_MinMaxFilter = MinMaxFilterType::New(); - m_MinMaxFilter->SetInput( inImage ); - m_MinMaxFilter->GetStreamer()->SetAutomaticAdaptativeStreaming(GetParameterInt("ram")); + MinMaxFilterType::Pointer minMaxFilter = MinMaxFilterType::New(); + minMaxFilter->SetInput( inImage ); + minMaxFilter->GetStreamer()->SetAutomaticAdaptativeStreaming(GetParameterInt("ram")); - AddProcess(m_MinMaxFilter->GetStreamer(), "Min/Max computing"); - m_MinMaxFilter->Update(); + AddProcess(minMaxFilter->GetStreamer(), "Min/Max computing"); + minMaxFilter->Update(); - otbAppLogDEBUG( << "Min/Max computation done : min=" << m_MinMaxFilter->GetMinimum() - << " max=" << m_MinMaxFilter->GetMaximum() ) + otbAppLogDEBUG( << "Min/Max computation done : min=" << minMaxFilter->GetMinimum() + << " max=" << minMaxFilter->GetMaximum() ) FloatVectorImageType::PixelType inMin, inMax; - RescaleImageFilterType::Pointer m_RescaleFilter = + RescaleImageFilterType::Pointer rescaleFilter = RescaleImageFilterType::New(); - m_RescaleFilter->SetInput( inImage ); - m_RescaleFilter->SetAutomaticInputMinMaxComputation(false); - m_RescaleFilter->SetInputMinimum( m_MinMaxFilter->GetMinimum() ); - m_RescaleFilter->SetInputMaximum( m_MinMaxFilter->GetMaximum() ); + rescaleFilter->SetInput( inImage ); + rescaleFilter->SetAutomaticInputMinMaxComputation(false); + rescaleFilter->SetInputMinimum( minMaxFilter->GetMinimum() ); + rescaleFilter->SetInputMaximum( minMaxFilter->GetMaximum() ); FloatVectorImageType::PixelType outMin, outMax; outMin.SetSize( inImage->GetNumberOfComponentsPerPixel() ); @@ -126,11 +126,11 @@ private: outMin.Fill( GetParameterFloat("outmin") ); outMax.Fill( GetParameterFloat("outmax") ); - m_RescaleFilter->SetOutputMinimum( outMin ); - m_RescaleFilter->SetOutputMaximum( outMax ); - m_RescaleFilter->UpdateOutputInformation(); + rescaleFilter->SetOutputMinimum( outMin ); + rescaleFilter->SetOutputMaximum( outMax ); + rescaleFilter->UpdateOutputInformation(); - SetParameterOutputImage("out", m_RescaleFilter->GetOutput()); + SetParameterOutputImage("out", rescaleFilter->GetOutput()); RegisterPipeline(); } }; diff --git a/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx b/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx index b769712e79..3f73fba77a 100644 --- a/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx +++ b/Modules/Applications/AppImageUtils/app/otbSplitImage.cxx @@ -103,13 +103,13 @@ private: ext = itksys::SystemTools::GetFilenameExtension(ofname); // Set the extract filter input image - FilterType::Pointer m_Filter = FilterType::New(); - m_Filter->SetInput(inImage); + FilterType::Pointer filter = FilterType::New(); + filter->SetInput(inImage); for (unsigned int i = 0; i < inImage->GetNumberOfComponentsPerPixel(); ++i) { // Set the channel to extract - m_Filter->SetChannel(i+1); + filter->SetChannel(i+1); // build the current output filename std::ostringstream oss; @@ -129,7 +129,7 @@ private: // Set the filename of the current output image paramOut->SetFileName(oss.str()); otbAppLogINFO(<< "File: "<<paramOut->GetFileName() << " will be written."); - paramOut->SetValue(m_Filter->GetOutput()); + paramOut->SetValue(filter->GetOutput()); paramOut->SetPixelType(this->GetParameterOutputImagePixelType("out")); // Add the current level to be written paramOut->InitializeWriters(); diff --git a/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx b/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx index c16431f985..7ba75ba1a3 100644 --- a/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx +++ b/Modules/Applications/AppImageUtils/app/otbTileFusion.cxx @@ -95,19 +95,19 @@ private: itkExceptionMacro("No input Image set..."); } - TileFilterType::Pointer m_FusionFilter = TileFilterType::New(); + TileFilterType::Pointer fusionFilter = TileFilterType::New(); TileFilterType::SizeType layout; layout[0] = this->GetParameterInt("cols"); layout[1] = this->GetParameterInt("rows"); - m_FusionFilter->SetLayout(layout); + fusionFilter->SetLayout(layout); for (unsigned int i=0; i<(layout[0]*layout[1]); i++) { - m_FusionFilter->SetInput(i,tileList->GetNthElement(i)); + fusionFilter->SetInput(i,tileList->GetNthElement(i)); } - SetParameterOutputImage("out", m_FusionFilter->GetOutput()); + SetParameterOutputImage("out", fusionFilter->GetOutput()); RegisterPipeline(); } diff --git a/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx index 52a9e9060f..290b393e84 100644 --- a/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx @@ -709,23 +709,23 @@ private: otbAppLogINFO(<<"Elapsed time: "<<(double)(toc - tic) / CLOCKS_PER_SEC<<" seconds"); // Final writing - LabelImageReaderType::Pointer m_FinalReader = LabelImageReaderType::New(); - m_FinalReader->SetFileName(vrtfile); + LabelImageReaderType::Pointer finalReader = LabelImageReaderType::New(); + finalReader->SetFileName(vrtfile); ImportGeoInformationImageFilterType::Pointer - m_ImportGeoInformationFilter = + importGeoInformationFilter = ImportGeoInformationImageFilterType::New(); - m_ImportGeoInformationFilter->SetInput(m_FinalReader->GetOutput()); - m_ImportGeoInformationFilter->SetSource(imageIn); + importGeoInformationFilter->SetInput(finalReader->GetOutput()); + importGeoInformationFilter->SetSource(imageIn); - SetParameterOutputImage("out",m_ImportGeoInformationFilter->GetOutput()); + SetParameterOutputImage("out",importGeoInformationFilter->GetOutput()); RegisterPipeline(); } void AfterExecuteAndWriteOutputs() override { // Release input files - // m_FinalReader = ITK_NULLPTR; + // finalReader = ITK_NULLPTR; if(GetParameterInt("cleanup")) { diff --git a/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx b/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx index 15c637f547..1d30963c54 100644 --- a/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx +++ b/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx @@ -181,21 +181,21 @@ private: { FloatVectorImageType* input = GetParameterImage("in"); - MSFilterType::Pointer m_Filter = MSFilterType::New(); + MSFilterType::Pointer filter = MSFilterType::New(); - m_Filter->SetInput(input); + filter->SetInput(input); - m_Filter->SetSpatialBandwidth(GetParameterInt("spatialr")); - m_Filter->SetRangeBandwidth(GetParameterFloat("ranger")); - m_Filter->SetThreshold(GetParameterFloat("thres")); - m_Filter->SetMaxIterationNumber(GetParameterInt("maxiter")); - m_Filter->SetRangeBandwidthRamp(GetParameterFloat("rangeramp")); - m_Filter->SetModeSearch(GetParameterInt("modesearch")); + filter->SetSpatialBandwidth(GetParameterInt("spatialr")); + filter->SetRangeBandwidth(GetParameterFloat("ranger")); + filter->SetThreshold(GetParameterFloat("thres")); + filter->SetMaxIterationNumber(GetParameterInt("maxiter")); + filter->SetRangeBandwidthRamp(GetParameterFloat("rangeramp")); + filter->SetModeSearch(GetParameterInt("modesearch")); //Compute the margin used to ensure exact results (tile wise smoothing) //This margin is valid for the default uniform kernel used by the //MeanShiftSmoothing filter (bandwidth equal to radius in this case) - const unsigned int margin = (m_Filter->GetMaxIterationNumber() * m_Filter->GetSpatialBandwidth()) + 1; + const unsigned int margin = (filter->GetMaxIterationNumber() * filter->GetSpatialBandwidth()) + 1; otbAppLogINFO(<<"Margin of " << margin << " pixels applied to each tile to stabilized mean shift filtering." << std::endl); @@ -204,10 +204,10 @@ private: otbAppLogWARNING(<<"Margin value exceed the input image size." << std::endl); } - SetParameterOutputImage("fout", m_Filter->GetOutput()); + SetParameterOutputImage("fout", filter->GetOutput()); if (IsParameterEnabled("foutpos") && HasValue("foutpos")) { - SetParameterOutputImage("foutpos", m_Filter->GetSpatialOutput()); + SetParameterOutputImage("foutpos", filter->GetSpatialOutput()); } if(!GetParameterInt("modesearch")) { -- GitLab From a83446dc30d27cdb814d8731f5e0cf0afb9ba7d6 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Mar 2018 11:29:45 +0100 Subject: [PATCH 473/567] COMP: missing include --- Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h index dceefc9d0f..0d6757fe3e 100644 --- a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h +++ b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h @@ -24,6 +24,7 @@ #include "itkMacro.h" #include "itkImageToImageFilter.h" #include "otbStreamingManager.h" +#include "itkFastMutexLock.h" namespace otb { -- GitLab From 25d2eb9e12a711a081b25494bc4f33e23e75204a Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 16 Mar 2018 11:33:27 +0100 Subject: [PATCH 474/567] ENH: Abort supported in SimpleParallelTiffWriter --- .../include/otbSimpleParallelTiffWriter.h | 9 +++++ .../include/otbSimpleParallelTiffWriter.txx | 35 +++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h index c404d25d50..bb611a9690 100644 --- a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h +++ b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h @@ -31,6 +31,7 @@ #include "itkImageFileWriter.h" #include "itkObjectFactoryBase.h" +#include "itkFastMutexLock.h" #include "itkImageRegionMultidimensionalSplitter.h" #include "otbImageIOFactory.h" @@ -252,6 +253,11 @@ public: itkSetMacro(TiffTiledMode, bool); itkGetMacro(TiffTiledMode, bool); + // the interface of the superclass getter function is not thread safe + bool GetAbortGenerateDataMutex() const; + + void SetAbortGenerateData(bool val) override; + protected: SimpleParallelTiffWriter(); virtual ~SimpleParallelTiffWriter(); @@ -325,6 +331,9 @@ private: bool m_Verbose; bool m_VirtualMode; bool m_TiffTiledMode; + + /** Lock to ensure thread-safety (added for the AbortGenerateData flag) */ + itk::SimpleFastMutexLock m_Lock; }; diff --git a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx index 96cbf7120c..4d51c77383 100644 --- a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx +++ b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx @@ -682,7 +682,7 @@ SimpleParallelTiffWriter<TInputImage> double processDuration(0), writeDuration(0), numberOfProcessedRegions(0); InputImageRegionType streamRegion; for (m_CurrentDivision = 0; - m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateData(); + m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateDataMutex(); m_CurrentDivision++, m_DivisionProgress = 0, this->UpdateFilterProgress()) { streamRegion = m_StreamingManager->GetSplit(m_CurrentDivision); @@ -716,6 +716,16 @@ SimpleParallelTiffWriter<TInputImage> } } + // abort case + if (this->GetAbortGenerateDataMutex()) + { + itk::ProcessAborted e(__FILE__, __LINE__); + e.SetLocation(ITK_LOCATION); + e.SetDescription("Image writing has been aborted"); + throw e; + otb::MPIConfig::Instance()->abort(EXIT_FAILURE); + } + // Clean up close_raster(output_raster); output_raster = NULL; @@ -758,7 +768,7 @@ SimpleParallelTiffWriter<TInputImage> * If we ended due to aborting, push the progress up to 1.0 (since * it probably didn't end there) */ - if (!this->GetAbortGenerateData()) + if (!this->GetAbortGenerateDataMutex()) { this->UpdateProgress(1.0); } @@ -824,5 +834,26 @@ SimpleParallelTiffWriter<TInputImage> return this->m_FilenameHelper->GetSimpleFileName(); } +template <class TInputImage> +bool +SimpleParallelTiffWriter<TInputImage> +::GetAbortGenerateDataMutex() const +{ + m_Lock.Lock(); + bool ret = Superclass::GetAbortGenerateData(); + m_Lock.Unlock(); + return ret; +} + +template <class TInputImage> +void +SimpleParallelTiffWriter<TInputImage> +::SetAbortGenerateData(bool val) +{ + m_Lock.Lock(); + Superclass::SetAbortGenerateData(val); + m_Lock.Unlock(); +} + } #endif -- GitLab From 3801570f58e9ba2f1020075a2a1aa5da02f23f0c Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 16 Mar 2018 11:51:17 +0100 Subject: [PATCH 475/567] REFAC: and const& in for loop --- .../ApplicationEngine/src/otbWrapperApplication.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 089777f20d..8cb9b8eee2 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -389,7 +389,7 @@ Application::RegisterPipeline() std::set< itk::DataObject * > inputData; std::vector<std::string> paramList = GetParametersKeys(true); // Get both end of the pipeline - for ( key : paramList ) + for ( auto const & key : paramList ) { if ( GetParameterType(key) == ParameterType_OutputImage ) { @@ -465,8 +465,6 @@ Application::RegisterPipeline() ++it; } } - else - continue; } // DFS @@ -499,7 +497,7 @@ Application::RegisterPipeline() m_Filters.insert( process ); std::vector< itk::DataObject::Pointer > inputs = process->GetInputs(); // Push back all source's inputs in datastack - for ( auto it : inputs ) + for ( auto const & it : inputs ) { if ( inputData.count( it.GetPointer() ) ) continue; -- GitLab From 1542ec83daced631dbd53cff0765e494cbffd38b Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 16 Mar 2018 17:10:14 +0100 Subject: [PATCH 476/567] TEST: enhance test --- .../Adapters/GdalAdapters/test/CMakeLists.txt | 23 ++++++- ...tbOGRExtendedFilenameToOptionsGDALTest.cxx | 67 +++++++++---------- .../GdalAdapters/test/otbOGRTestDriver.cxx | 5 +- 3 files changed, 54 insertions(+), 41 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt index cf846f576d..11c44bb8c1 100644 --- a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt +++ b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt @@ -57,11 +57,28 @@ otb_add_test(NAME TvOGRExtendedFilename test.shp?&writegeom=ON&gdal:co:QUALITY=75&gdal:co:TILED=YES&gdal:co:BLOCKYSIZE=1024&gdal:lco:layeroption=OPTION&gdal:oo:openoption=OPTION ${TEMP}/TvOGRExtendedFilenameTest.txt ) -otb_add_test(NAME TvOGRExtendedFilenameGDAL +otb_add_test(NAME TvOGRExtendedFilenameGDALOpen COMMAND otbOGRTestDriver - otbOGRExtendedFileNameGDAL + otbOGRExtendedFileNameGDALOpen ${INPUTDATA}/ToulousePoints-examples.shp?&gdal:oo:openOption=OPTION - ${TEMP}/test.shp?&gdal:co:creationOption=OPTION&gdal:lco:layerOption=OPTION + ) + +otb_add_test(NAME TvOGRExtendedFilenameGDALCreate + COMMAND otbOGRTestDriver + otbOGRExtendedFileNameGDALCreate + test.shp?gdal:co:creationOption=OPTION + ) + +otb_add_test(NAME TvOGRExtendedFilenameGDALLayer + COMMAND otbOGRTestDriver + otbOGRExtendedFileNameGDALLayer + test.shp?&gdal:lco:layeroption=OPTION + ) + +otb_add_test(NAME TvOGRExtendedFilenameGDALLayerOption + COMMAND otbOGRTestDriver + otbOGRExtendedFileNameGDALLayerOption + test.shp ) diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx index a35f21042f..cbfbe4f0e2 100644 --- a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx +++ b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx @@ -25,51 +25,44 @@ #include <fstream> -int otbOGRExtendedFileNameGDAL(int , char* argv[]) +int otbOGRExtendedFileNameGDALOpen(int , char* argv[]) { - bool success = true ; - const char * inputOpen = argv[1]; - const char * inputCreation = argv[2]; - auto test = otb::ogr::DataSource::New( inputOpen ); - // std::cout<<"here"<<std::endl; + auto test = otb::ogr::DataSource::New( argv[1] ); std::string error = CPLGetLastErrorMsg(); if ( !error.empty() ) std::cout<<error<<std::endl; - // if ( error.find( "does not support open option openOption" ) != std::string::npos ) - // success = true && success ; - // else - // success = false ; - // std::cout<<success<<std::endl; - + return 0; +} - test = otb::ogr::DataSource::New( inputCreation , otb::ogr::DataSource::Modes::Update_LayerOverwrite); -error = CPLGetLastErrorMsg(); - if ( !error.empty() ) - std::cout<<error<<std::endl; - // error = CPLGetLastErrorMsg(); - // std::cout<<error<<std::endl; - // if ( std::string(error).find( "does not support creation option creationOption" ) != std::string::npos ) - // success = true && success ; - // else - // success = false ; - // std::cout<<success<<std::endl; +int otbOGRExtendedFileNameGDALCreate(int , char* argv[]) +{ + auto test = otb::ogr::DataSource::New( argv[1] , otb::ogr::DataSource::Modes::Overwrite); + std::string error = CPLGetLastErrorMsg(); + std::cout<<error<<std::endl; + return error.empty(); +} +int otbOGRExtendedFileNameGDALLayer(int , char* argv[]) +{ + auto test = otb::ogr::DataSource::New( argv[1] , otb::ogr::DataSource::Modes::Update_LayerOverwrite); test->CreateLayer( "2layertest" , ITK_NULLPTR , - wkbUnknown , - std::vector< std::string > { "newOption=OPTION" } ); -error = CPLGetLastErrorMsg(); - if ( !error.empty() ) - std::cout<<error<<std::endl; - // error = CPLGetLastErrorMsg(); - // std::cout<<error<<std::endl; - // if ( std::string(error).find( "toto" ) != std::string::npos ) - // success = true && success; - // else - // success = false ; - // std::cout<<success<<std::endl; - - return EXIT_SUCCESS; + wkbUnknown ); + std::string error = CPLGetLastErrorMsg(); + std::cout<<error<<std::endl; + return error.empty(); } +int otbOGRExtendedFileNameGDALLayerOption(int , char* argv[]) +{ + auto test = otb::ogr::DataSource::New( argv[1] , otb::ogr::DataSource::Modes::Update_LayerOverwrite); + std::vector<std::string> option { "vectorlayeroption=OPTION" }; + test->CreateLayer( "2layertest" , + ITK_NULLPTR , + wkbUnknown , + option ); + std::string error = CPLGetLastErrorMsg(); + std::cout<<error<<std::endl; + return error.empty(); +} diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx index 0793f8c07d..dba04ea4d7 100644 --- a/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx +++ b/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx @@ -23,5 +23,8 @@ void RegisterTests() { REGISTER_TEST(otbOGRExtendedFileName); - REGISTER_TEST(otbOGRExtendedFileNameGDAL); + REGISTER_TEST(otbOGRExtendedFileNameGDALOpen); + REGISTER_TEST(otbOGRExtendedFileNameGDALCreate); + REGISTER_TEST(otbOGRExtendedFileNameGDALLayer); + REGISTER_TEST(otbOGRExtendedFileNameGDALLayerOption); } -- GitLab From 59c5d11c607da378118b29024d569638aaee6834 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 19 Mar 2018 08:26:41 +0100 Subject: [PATCH 477/567] REFAC: objectlist derived from boost::noncopyable and const & in for loop --- .../Core/ObjectList/include/otbObjectListInterface.h | 10 +++++----- .../ApplicationEngine/src/otbWrapperApplication.cxx | 5 +---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Modules/Core/ObjectList/include/otbObjectListInterface.h b/Modules/Core/ObjectList/include/otbObjectListInterface.h index 8b920a40ef..bec8e87838 100644 --- a/Modules/Core/ObjectList/include/otbObjectListInterface.h +++ b/Modules/Core/ObjectList/include/otbObjectListInterface.h @@ -22,11 +22,12 @@ #define otbObjectListInterface_h #include "itkDataObject.h" +#include "boost/core/noncopyable.hpp" namespace otb { -class ObjectListInterface +class ObjectListInterface : public boost::noncopyable { /** \class ObjectListInterface * \brief This non template class is an interface that wrapp ObjectList @@ -37,10 +38,6 @@ class ObjectListInterface * \ingroup ObjectListInterface */ public: - - ObjectListInterface() {}; - virtual ~ObjectListInterface(){}; - /** Get the nth element of the list as a DataObject *. */ @@ -48,6 +45,9 @@ public: virtual std::size_t Size(void) const = 0; +protected: + ObjectListInterface() = default ; + virtual ~ObjectListInterface() = default ; }; } // end of otb namespace diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 8cb9b8eee2..144b22429e 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -511,11 +511,8 @@ void Application::FreeRessources() std::set< itk::DataObject * > dataSet; std::vector<std::string> paramList = GetParametersKeys(true); // Get the end of the pipeline - for (std::vector<std::string>::const_iterator it = paramList.begin(); - it != paramList.end(); - ++it) + for ( const auto & key : paramList ) { - std::string key = *it; if ( GetParameterType(key) == ParameterType_OutputImage ) { Parameter* param = GetParameterByKey(key); -- GitLab From 000c51d402f56e8637e92bc8c8a01f423e4d9859 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 19 Mar 2018 09:45:18 +0100 Subject: [PATCH 478/567] TEST: refactor and comment the open test --- .../Adapters/GdalAdapters/test/CMakeLists.txt | 11 ++++++----- .../otbOGRExtendedFilenameToOptionsGDALTest.cxx | 17 +++++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt index 11c44bb8c1..fcfa764079 100644 --- a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt +++ b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt @@ -57,11 +57,12 @@ otb_add_test(NAME TvOGRExtendedFilename test.shp?&writegeom=ON&gdal:co:QUALITY=75&gdal:co:TILED=YES&gdal:co:BLOCKYSIZE=1024&gdal:lco:layeroption=OPTION&gdal:oo:openoption=OPTION ${TEMP}/TvOGRExtendedFilenameTest.txt ) -otb_add_test(NAME TvOGRExtendedFilenameGDALOpen - COMMAND otbOGRTestDriver - otbOGRExtendedFileNameGDALOpen - ${INPUTDATA}/ToulousePoints-examples.shp?&gdal:oo:openOption=OPTION - ) +#Problem with error thrown by GDAL : unable to catch it with "CPLGetLastErrorMsg" +# otb_add_test(NAME TvOGRExtendedFilenameGDALOpen +# COMMAND otbOGRTestDriver +# otbOGRExtendedFileNameGDALOpen +# ${INPUTDATA}/ToulousePoints-examples.shp?&gdal:oo:openOption=OPTION +# ) otb_add_test(NAME TvOGRExtendedFilenameGDALCreate COMMAND otbOGRTestDriver diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx index cbfbe4f0e2..37368ea118 100644 --- a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx +++ b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx @@ -29,8 +29,6 @@ int otbOGRExtendedFileNameGDALOpen(int , char* argv[]) { auto test = otb::ogr::DataSource::New( argv[1] ); std::string error = CPLGetLastErrorMsg(); - if ( !error.empty() ) - std::cout<<error<<std::endl; return 0; } @@ -38,8 +36,9 @@ int otbOGRExtendedFileNameGDALCreate(int , char* argv[]) { auto test = otb::ogr::DataSource::New( argv[1] , otb::ogr::DataSource::Modes::Overwrite); std::string error = CPLGetLastErrorMsg(); - std::cout<<error<<std::endl; - return error.empty(); + if ( error.find( "does not support creation option creationOption" ) ) + return EXIT_SUCCESS; + return EXIT_FAILURE; } int otbOGRExtendedFileNameGDALLayer(int , char* argv[]) @@ -49,8 +48,9 @@ int otbOGRExtendedFileNameGDALLayer(int , char* argv[]) ITK_NULLPTR , wkbUnknown ); std::string error = CPLGetLastErrorMsg(); - std::cout<<error<<std::endl; - return error.empty(); + if ( error.find( "does not support layer creation option layeroption" ) ) + return EXIT_SUCCESS; + return EXIT_FAILURE; } int otbOGRExtendedFileNameGDALLayerOption(int , char* argv[]) @@ -62,7 +62,8 @@ int otbOGRExtendedFileNameGDALLayerOption(int , char* argv[]) wkbUnknown , option ); std::string error = CPLGetLastErrorMsg(); - std::cout<<error<<std::endl; - return error.empty(); + if ( error.find( "does not support layer creation option vectorlayeroption" ) ) + return EXIT_SUCCESS; + return EXIT_FAILURE; } -- GitLab From 04fcc3b6df0169c00e4623a1049dadbc242e7359 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 19 Mar 2018 10:09:34 +0100 Subject: [PATCH 479/567] REFAC: add ingroup doxygen tags --- .../GdalAdapters/include/otbOGRExtendedFilenameToOptions.h | 3 ++- Modules/Core/Common/include/otbExtendedFilenameHelper.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h index 91ada31780..6ae631531f 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRExtendedFilenameToOptions.h @@ -30,8 +30,9 @@ namespace otb /** \class OGRExtendedFilenameToOptions * \brief This class aim at processing GDAL option that can be pass through * extended filename. - * * \ingroup OTBExtendedFilename + * \ingroup OTBGdalAdapters + * */ #include "OTBGdalAdaptersExport.h" diff --git a/Modules/Core/Common/include/otbExtendedFilenameHelper.h b/Modules/Core/Common/include/otbExtendedFilenameHelper.h index 53a5431ced..549ad2451d 100644 --- a/Modules/Core/Common/include/otbExtendedFilenameHelper.h +++ b/Modules/Core/Common/include/otbExtendedFilenameHelper.h @@ -34,6 +34,7 @@ namespace otb * \sa ImageFileReader * * \ingroup OTBExtendedFilename + * \ingroup OTBCommon */ class OTBCommon_EXPORT ExtendedFilenameHelper : public itk::Object -- GitLab From 53fb598996f6d6656c5bce6841a0464b811f58a6 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 19 Mar 2018 10:59:33 +0100 Subject: [PATCH 480/567] BUG: change public inheritance to private --- Modules/Core/ObjectList/include/otbObjectListInterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/ObjectList/include/otbObjectListInterface.h b/Modules/Core/ObjectList/include/otbObjectListInterface.h index bec8e87838..ce907a03d8 100644 --- a/Modules/Core/ObjectList/include/otbObjectListInterface.h +++ b/Modules/Core/ObjectList/include/otbObjectListInterface.h @@ -27,7 +27,7 @@ namespace otb { -class ObjectListInterface : public boost::noncopyable +class ObjectListInterface : private boost::noncopyable { /** \class ObjectListInterface * \brief This non template class is an interface that wrapp ObjectList -- GitLab From 84195465f8563f4f82802378877aa0253d7e53e9 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 19 Mar 2018 17:08:56 +0100 Subject: [PATCH 481/567] Refac: port some code from mvd::Wrapper::QtWidgetView to otb::Wrapper::QtWidgetView --- .../QtWidget/include/otbWrapperQtWidgetView.h | 198 +++++++++++++++-- .../QtWidget/src/otbWrapperQtWidgetView.cxx | 201 ++++++++++++------ 2 files changed, 315 insertions(+), 84 deletions(-) diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h index e0f2044962..09f905c46b 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h @@ -22,52 +22,128 @@ #define otbWrapperQtWidgetView_h #include <QtGui> -#include <QObject> #include <QShortcut> + +// +// OTB includes (sorted by alphabetic order) #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility +#include "otbWrapperApplication.h" #include "otbWrapperQtWidgetModel.h" #endif //tag=QT4-boost-compatibility +#include "OTBQtWidgetExport.h" namespace otb { namespace Wrapper { -/** \class QtWidgetView - * \brief +/*****************************************************************************/ +/* CLASS DEFINITION SECTION */ + +/** + * \class QtWidgetView * * \ingroup OTBQtWidget + * + * \brief WIP. */ -class OTBQtWidget_EXPORT QtWidgetView : public QWidget + +class OTBQtWidget_EXPORT QtWidgetView : + public QWidget { + /*-[ QOBJECT SECTION ]-----------------------------------------------------*/ + Q_OBJECT + + Q_PROPERTY( bool isClosable + READ IsClosable + WRITE SetClosable ); + + /*-[ PUBLIC SECTION ]------------------------------------------------------*/ + +// +// Public methods. public: - QtWidgetView(Application* app); + + /** + */ + static char const * const OBJECT_NAME; + + /** \brief Constructor. */ + QtWidgetView( const otb::Wrapper::Application::Pointer & otbApp, + QWidget* p =0, + Qt::WindowFlags flags =0 ); + + /** \brief Destructor. */ ~QtWidgetView() override; + /** \brief Gui Creation. */ void CreateGui(); - QtWidgetModel* GetModel() + /** \brief Model Accessor */ + inline otb::Wrapper::QtWidgetModel* GetModel() { return m_Model; } + /** + * \return The OTB-application pointer of this view. + */ + //~ otb::Wrapper::Application::ConstPointer GetApplication() const + //~ { + //~ return otb::ConstCast< otb::Wrapper::Application >( + //~ m_Application + //~ ); + //~ } + + /** + */ + inline bool IsClosable() const; + + /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ + +// +// Public SLOTS. public slots: - void CloseSlot(); void UnhandledException(QString message); - void OnExceptionRaised(QString message); - -private slots: - void UpdateMessageAfterExecuteClicked(); - void UpdateMessageAfterCancelClicked(); - void UpdateMessageAfterExecution(int status); - void UpdateMessageAfterApplicationReady(bool val); + void OnExceptionRaised( QString what ); + /*-[ SIGNALS SECTION ]-----------------------------------------------------*/ +// +// Signals. signals: void QuitSignal(); + void ExecuteAndWriteOutput(); + void Stop(); + + + /*-[ PROTECTED SECTION ]---------------------------------------------------*/ + +// +// Protected methods. +protected: + + // + // QWidget overloads. + + void closeEvent( QCloseEvent * event ) override; + +// +// Protected attributes. +protected: + + /** Html section for 'Done' icon */ + std::string m_IconPathDone; + /** Html section for 'Failed' icon */ + std::string m_IconPathFailed; + + /*-[ PRIVATE SECTION ]-----------------------------------------------------*/ +// +// Private methods. private: + QtWidgetView(const QtWidgetView&); //purposely not implemented void operator=(const QtWidgetView&); //purposely not implemented @@ -77,21 +153,107 @@ private: QWidget* CreateDoc(); - Application::Pointer m_Application; - QtWidgetModel* m_Model; +// +// Private attributes. - QTextEdit *m_LogText; - QTabWidget *m_TabWidget; +private: + + otb::Wrapper::QtWidgetModel* m_Model; QPushButton* m_ExecButton; QPushButton* m_QuitButton; QShortcut* m_QuitShortcut; QLabel* m_Message; + QTextEdit *m_LogText; + QTabWidget *m_TabWidget; + + bool m_IsClosable : 1; + + bool m_IsRunning; + + /*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/ + +// +// Slots. +private slots: + void UpdateMessageAfterExecution(int status); + void UpdateMessageAfterApplicationReady(bool val); + + /** + */ + void OnExecButtonClicked(); + + /** + */ + inline void OnProgressReportBegin(); + + /** + */ + inline void OnProgressReportEnd( int status ); + + /** + */ + inline void SetClosable( bool ); + }; +} // end namespace 'Wrapper' + +} // end namespace 'otb' + +/*****************************************************************************/ +/* INLINE SECTION */ + +namespace otb +{ + +namespace Wrapper +{ + +/*****************************************************************************/ +inline +bool +QtWidgetView +::IsClosable() const +{ + return m_IsClosable; +} + +/*****************************************************************************/ +inline +void +QtWidgetView +::SetClosable( bool enabled ) +{ + m_IsClosable = enabled; + + setEnabled( true ); + + if( m_QuitButton!=NULL ) + m_QuitButton->setEnabled( m_IsClosable ); +} +/*******************************************************************************/ +inline +void +QtWidgetView +::OnProgressReportBegin() +{ + SetClosable( false ); } + +/*******************************************************************************/ +inline +void +QtWidgetView +::OnProgressReportEnd( int ) +{ + SetClosable( true ); } +} // end namespace 'Wrapper' + +} // end namespace 'otb' + #endif diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx index b265b5e886..2daeb8d697 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx @@ -20,31 +20,77 @@ #include "otbWrapperQtWidgetView.h" +#include <functional> + #include "otbWrapperQtWidgetParameterGroup.h" #include "otbWrapperQtWidgetParameterFactory.h" -#include "otbWrapperQtWidgetProgressReport.h" -#include "otbWrapperOutputImageParameter.h" -#include "otbWrapperChoiceParameter.h" -#include "otbWrapperQtWidgetSimpleProgressReport.h" #include "otbWrapperApplicationHtmlDocGenerator.h" - -#include "itksys/SystemTools.hxx" - +#include "otbWrapperOutputFilenameParameter.h" +#include "otbWrapperOutputVectorDataParameter.h" +#include "otbWrapperQtWidgetSimpleProgressReport.h" namespace otb { namespace Wrapper { - -QtWidgetView::QtWidgetView(Application* app) +/* + TRANSLATOR mvd::Wrapper::QtWidgetView + + Necessary for lupdate to be aware of C++ namespaces. + + Context comment for translator. +*/ + +/*****************************************************************************/ +/* CONSTANTS */ + +char const * const +QtWidgetView +::OBJECT_NAME = "otb::Wrapper::QtWidgetView"; + +/*****************************************************************************/ +/* CLASS IMPLEMENTATION SECTION */ +/*****************************************************************************/ +QtWidgetView::QtWidgetView( const otb::Wrapper::Application::Pointer & otbApp, + QWidget* p, + Qt::WindowFlags flags ) : + QWidget( p, flags ), + m_IconPathDone(""), + m_IconPathFailed(""), + m_Model( NULL ), + m_ExecButton( NULL ), + m_QuitButton( NULL ), + m_Message( NULL ), + m_LogText( NULL ), + m_TabWidget( NULL ), + m_IsClosable( true ), + m_IsRunning(false) { - m_Model = new QtWidgetModel(app); - m_Application = app; + setObjectName( QtWidgetView::OBJECT_NAME ); + + m_Model = new otb::Wrapper::QtWidgetModel( otbApp ); + m_QuitShortcut = new QShortcut(QKeySequence("Ctrl+Q"), this); + + QObject::connect( + m_Model, SIGNAL( SetProgressReportBegin() ), + this, SLOT( OnProgressReportBegin() ) + ); + + QObject::connect( + m_Model, SIGNAL( SetProgressReportDone( int ) ), + this, SLOT( OnProgressReportEnd( int ) ) + ); + + QObject::connect( + m_Model, SIGNAL( ExceptionRaised( QString ) ), + this, SLOT( OnExceptionRaised( QString ) ) + ); } QtWidgetView::~QtWidgetView() { delete m_Model; + m_Model = NULL; } void QtWidgetView::CreateGui() @@ -53,88 +99,74 @@ void QtWidgetView::CreateGui() QVBoxLayout *mainLayout = new QVBoxLayout(); m_TabWidget = new QTabWidget(); - m_TabWidget->addTab(CreateInputWidgets(), "Parameters"); + m_TabWidget->addTab(CreateInputWidgets(), tr("Parameters")); m_LogText = new QTextEdit(); connect( m_Model->GetLogOutput(), SIGNAL(NewContentLog(QString)), m_LogText, SLOT(append(QString) ) ); - m_TabWidget->addTab(m_LogText, "Logs"); - QtWidgetProgressReport* prog = new QtWidgetProgressReport(m_Model); - prog->SetApplication(m_Application); - m_TabWidget->addTab(prog, "Progress"); - m_TabWidget->addTab(CreateDoc(), "Documentation"); + m_TabWidget->addTab(m_LogText, tr("Logs")); + m_TabWidget->addTab(CreateDoc(), tr("Documentation")); mainLayout->addWidget(m_TabWidget); - m_Message = new QLabel("<center><font color=\"#FF0000\">Select parameters</font></center>"); - connect( m_Model, SIGNAL(SetApplicationReady(bool)), this, SLOT(UpdateMessageAfterApplicationReady(bool)) ); + m_Message = new QLabel("<center><font color=\"#FF0000\">"+tr("Select parameters")+"</font></center>"); + connect( m_Model, SIGNAL(SetApplicationReady(bool)), this, SLOT( UpdateMessageAfterApplicationReady(bool)) ); connect( m_Model, SIGNAL(SetProgressReportDone(int)), this, SLOT(UpdateMessageAfterExecution(int)) ); mainLayout->addWidget(m_Message); - QtWidgetSimpleProgressReport * progressReport = new QtWidgetSimpleProgressReport(m_Model); - progressReport->SetApplication(m_Application); + otb::Wrapper::QtWidgetSimpleProgressReport * progressReport = new otb::Wrapper::QtWidgetSimpleProgressReport(m_Model); + progressReport->SetApplication(m_Model->GetApplication()); + QWidget* footer = CreateFooter(); + QHBoxLayout *footLayout = new QHBoxLayout; footLayout->addWidget(progressReport); - footLayout->addWidget(CreateFooter()); + footLayout->addWidget(footer); mainLayout->addLayout(footLayout); + footLayout->setAlignment(footer, Qt::AlignBottom); + QGroupBox *mainGroup = new QGroupBox(); mainGroup->setLayout(mainLayout); QVBoxLayout *finalLayout = new QVBoxLayout(); finalLayout->addWidget(mainGroup); - connect( m_Model, SIGNAL(ExceptionRaised(QString)), this, SLOT(OnExceptionRaised(QString)) ); - // Make the final layout to the widget this->setLayout(finalLayout); } -void QtWidgetView::UpdateMessageAfterExecuteClicked() -{ - m_Message->setText("<center><font color=\"#FF0000\">Running</font></center>"); - m_ExecButton->setText(QObject::tr("Cancel")); - - disconnect( m_ExecButton, SIGNAL(clicked()), m_Model, SLOT(ExecuteAndWriteOutputSlot() ) ); - disconnect( m_ExecButton, SIGNAL(clicked()), this, SLOT(UpdateMessageAfterExecuteClicked() ) ); - connect( m_ExecButton, SIGNAL(clicked()), m_Model, SIGNAL(Stop())); - connect( m_ExecButton, SIGNAL(clicked()), this, SLOT(UpdateMessageAfterCancelClicked())); -} - -void QtWidgetView::UpdateMessageAfterCancelClicked() -{ - m_Message->setText("<center><font color=\"#FF0000\">Cancelling...</font></center>"); -} - void QtWidgetView::UpdateMessageAfterExecution(int status) { if (status >= 0) { - m_Message->setText("<center><font color=\"#00A000\">Done</font></center>"); + m_Message->setText("<center>"+QString(m_IconPathDone.c_str())+ + "<font color=\"#00A000\">"+tr("Done")+"</font></center>"); } else { - m_Message->setText("<center><font color=\"#FF0000\">Failed</font></center>"); + m_Message->setText("<center>"+QString(m_IconPathFailed.c_str())+ + "<font color=\"#FF0000\">"+tr("Failed")+"</font></center>"); } m_ExecButton->setText(QObject::tr("Execute")); - - disconnect( m_ExecButton, SIGNAL(clicked()), m_Model, SIGNAL(Stop())); - disconnect( m_ExecButton, SIGNAL(clicked()), this, SLOT(UpdateMessageAfterCancelClicked())); - connect( m_ExecButton, SIGNAL(clicked()), m_Model, SLOT(ExecuteAndWriteOutputSlot() ) ); - connect( m_ExecButton, SIGNAL(clicked()), this, SLOT(UpdateMessageAfterExecuteClicked() ) ); + m_IsRunning = false; } void QtWidgetView::UpdateMessageAfterApplicationReady( bool val ) { - if(val == true) - m_Message->setText("<center><font color=\"#00A000\">Ready to run</font></center>"); - else - m_Message->setText("<center><font color=\"#FF0000\">Select parameters</font></center>"); + if(!m_IsRunning) + { + if(val == true) + m_Message->setText("<center><font color=\"#00A000\">"+tr("Ready to run")+"</font></center>"); + else + m_Message->setText("<center><font color=\"#FF0000\">"+tr("Select parameters")+"</font></center>"); + } } QWidget* QtWidgetView::CreateInputWidgets() { QScrollArea *scrollArea = new QScrollArea; - // Put the main group inside a scroll area - scrollArea->setWidget(QtWidgetParameterFactory::CreateQtWidget(m_Model->GetApplication()->GetParameterList(), m_Model)); + + scrollArea->setWidget( otb::Wrapper::QtWidgetParameterFactory::CreateQtWidget( + m_Model->GetApplication()->GetParameterList(), + m_Model)); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); scrollArea->setWidgetResizable(true); @@ -148,7 +180,7 @@ QWidget* QtWidgetView::CreateFooter() // an HLayout with two buttons : Execute and Quit QGroupBox *footerGroup = new QGroupBox; QHBoxLayout *footerLayout = new QHBoxLayout; - + footerGroup->setFixedHeight(40); footerGroup->setContentsMargins(0, 0, 0, 0); footerLayout->setContentsMargins(5, 5, 5, 5); @@ -157,17 +189,17 @@ QWidget* QtWidgetView::CreateFooter() m_ExecButton->setDefault(true); m_ExecButton->setEnabled(false); m_ExecButton->setText(QObject::tr("Execute")); - connect( m_ExecButton, SIGNAL(clicked()), m_Model, SLOT(ExecuteAndWriteOutputSlot() ) ); - connect( m_Model, SIGNAL(SetApplicationReady(bool)), m_ExecButton, SLOT(setEnabled(bool)) ); - connect( m_ExecButton, SIGNAL(clicked()), this, SLOT(UpdateMessageAfterExecuteClicked() ) ); + connect( m_Model, SIGNAL( SetApplicationReady( bool ) ), m_ExecButton, SLOT( setEnabled( bool ) )); + QObject::connect( m_ExecButton, SIGNAL( clicked() ), this, SLOT( OnExecButtonClicked() )); + QObject::connect( this, SIGNAL( ExecuteAndWriteOutput() ), m_Model, SLOT( ExecuteAndWriteOutputSlot() )); + QObject::connect( this, SIGNAL( Stop() ), m_Model, SIGNAL( Stop() )); m_QuitButton = new QPushButton(footerGroup); m_QuitButton->setText(QObject::tr("Quit")); - connect( m_QuitButton, SIGNAL(clicked()), this, SLOT(CloseSlot()) ); + connect(m_QuitButton, SIGNAL( clicked() ), this, SLOT( close() )); // Add Ctrl-Q shortcut to quit - m_QuitShortcut = new QShortcut(QKeySequence("Ctrl+Q"), this); - connect( m_QuitShortcut, SIGNAL(activated()), this, SLOT(CloseSlot()) ); + connect( m_QuitShortcut, SIGNAL(activated()), this, SLOT(close()) ); // Put the buttons on the right footerLayout->addStretch(); @@ -187,7 +219,7 @@ QWidget* QtWidgetView::CreateDoc() QTextDocument * doc = new QTextDocument(); std::string docContain; - ApplicationHtmlDocGenerator::GenerateDoc( m_Application, docContain, true); + otb::Wrapper::ApplicationHtmlDocGenerator::GenerateDoc( GetModel()->GetApplication(), docContain); doc->setHtml(docContain.c_str()); @@ -196,13 +228,49 @@ QWidget* QtWidgetView::CreateDoc() return text; } -void QtWidgetView::CloseSlot() +void QtWidgetView::closeEvent( QCloseEvent * e ) { - // Close the widget - this->close(); + assert( e!=NULL ); + + if( !IsClosable() ) + { + assert( GetModel()->GetApplication() ); + + QMessageBox::warning( + this, + tr( "Warning!" ), + tr( "OTB-Application '%1' cannot be closed while running!") + .arg( GetModel()->GetApplication()->GetDocName() ) + ); + + e->ignore(); + + return; + } + + QWidget::closeEvent( e ); - // Emit a signal to close any widget that this gui belonging to emit QuitSignal(); + + deleteLater(); +} + +void +QtWidgetView +::OnExecButtonClicked() +{ + if (m_IsRunning) + { + m_Message->setText("<center><font color=\"#FF0000\">"+tr("Cancelling")+"...</font></center>"); + emit Stop(); + } + else + { + m_IsRunning = true; + m_Message->setText("<center><font color=\"#FF0000\">"+tr("Running")+"</font></center>"); + m_ExecButton->setText(QObject::tr("Cancel")); + emit ExecuteAndWriteOutput(); + } } void QtWidgetView::UnhandledException(QString message) @@ -211,10 +279,11 @@ void QtWidgetView::UnhandledException(QString message) m_LogText->append(message); } -void QtWidgetView::OnExceptionRaised(QString /*message*/) +void QtWidgetView::OnExceptionRaised( QString /*message*/) { m_TabWidget->setCurrentIndex(1); } } } + -- GitLab From 808cd176688cf3821a2450e8caae580894afb154 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 20 Mar 2018 12:01:51 +0100 Subject: [PATCH 482/567] REFAC: change visibility of some functions in QtWidgetView --- .../QtWidget/include/otbWrapperQtWidgetView.h | 22 ++++++++++++------- .../QtWidget/src/otbWrapperQtWidgetView.cxx | 7 +++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h index 09f905c46b..0f1ac8a345 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h @@ -105,8 +105,7 @@ public: // // Public SLOTS. public slots: - void UnhandledException(QString message); - void OnExceptionRaised( QString what ); + /*-[ SIGNALS SECTION ]-----------------------------------------------------*/ // @@ -123,6 +122,10 @@ signals: // Protected methods. protected: + bool IsRunning(); + + virtual QWidget* CreateInputWidgets(); + // // QWidget overloads. @@ -137,6 +140,15 @@ protected: /** Html section for 'Failed' icon */ std::string m_IconPathFailed; + +protected slots: + + /** + */ + void OnExecButtonClicked(); + + void UnhandledException(QString message); + void OnExceptionRaised( QString what ); /*-[ PRIVATE SECTION ]-----------------------------------------------------*/ @@ -149,8 +161,6 @@ private: QWidget* CreateFooter(); - QWidget* CreateInputWidgets(); - QWidget* CreateDoc(); @@ -180,10 +190,6 @@ private slots: void UpdateMessageAfterExecution(int status); void UpdateMessageAfterApplicationReady(bool val); - /** - */ - void OnExecButtonClicked(); - /** */ inline void OnProgressReportBegin(); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx index 2daeb8d697..f689d59d81 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx @@ -284,6 +284,11 @@ void QtWidgetView::OnExceptionRaised( QString /*message*/) m_TabWidget->setCurrentIndex(1); } +bool QtWidgetView::IsRunning() +{ + return m_IsRunning; } -} + +} // end of namespace Wrapper +} // end of namespace otb -- GitLab From 7b5b83ed3c8b3ccf854ee1cd90f10c34b060758c Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 20 Mar 2018 12:05:20 +0100 Subject: [PATCH 483/567] REFAC: mvd::Wrapper::QtWidgetView now derives from otb::Wrapper::QtWidgetView --- .../MonteverdiGui/include/mvdQtWidgetView.h | 150 +---- .../MonteverdiGui/src/mvdQtWidgetView.cxx | 606 +++++------------- 2 files changed, 186 insertions(+), 570 deletions(-) diff --git a/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetView.h b/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetView.h index c55664e2dc..08ead75886 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetView.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetView.h @@ -37,16 +37,10 @@ #include <QtGui> #include <QShortcut> -// -// System includes (sorted by alphabetic order) - -// -// ITK includes (sorted by alphabetic order) - // // OTB includes (sorted by alphabetic order) #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility -#include "otbWrapperApplication.h" +#include "otbWrapperQtWidgetView.h" #include "otbWrapperQtWidgetModel.h" #endif //tag=QT4-boost-compatibility #include "OTBMonteverdiGUIExport.h" @@ -57,18 +51,8 @@ #include "mvdTypes.h" #endif //tag=QT4-boost-compatibility -/*****************************************************************************/ -/* PRE-DECLARATION SECTION */ - -// -// External classes pre-declaration. -namespace -{ -} - namespace mvd { - namespace Wrapper { @@ -84,16 +68,12 @@ namespace Wrapper */ class OTBMonteverdiGUI_EXPORT QtWidgetView : - public QWidget + public otb::Wrapper::QtWidgetView { /*-[ QOBJECT SECTION ]-----------------------------------------------------*/ Q_OBJECT - Q_PROPERTY( bool isClosable - READ IsClosable - WRITE SetClosable ); - /*-[ PUBLIC SECTION ]------------------------------------------------------*/ // @@ -112,29 +92,6 @@ public: /** \brief Destructor. */ ~QtWidgetView() override; - /** \brief Gui Creation. */ - void CreateGui(); - - /** \brief Model Accessor */ - inline otb::Wrapper::QtWidgetModel* GetModel() - { - return m_Model; - } - - /** - * \return The OTB-application pointer of this view. - */ - otb::Wrapper::Application::ConstPointer GetApplication() const - { - return otb::ConstCast< otb::Wrapper::Application >( - m_Application - ); - } - - /** - */ - inline bool IsClosable() const; - /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ // @@ -146,12 +103,9 @@ public slots: // // Signals. signals: - void QuitSignal(); void OTBApplicationOutputImageChanged( const QString &, const QString &); - void ExecuteAndWriteOutput(); - void ExecutionDone( int nbOutputs ); /*-[ PROTECTED SECTION ]---------------------------------------------------*/ @@ -160,14 +114,16 @@ signals: // Protected methods. protected: - // - // QWidget overloads. + QWidget* CreateInputWidgets() override; - void closeEvent( QCloseEvent * event ) override; +protected slots: -// -// Protected attributes. -protected: + /** extend the behaviour of base class OnExecButtonClicked */ + void OnExecButtonClicked(); + + /** modify the behaviour of base class OnExceptionRaised + */ + void OnExceptionRaised( QString what ); /*-[ PRIVATE SECTION ]-----------------------------------------------------*/ @@ -178,12 +134,6 @@ private: QtWidgetView(const QtWidgetView&); //purposely not implemented void operator=(const QtWidgetView&); //purposely not implemented - QWidget* CreateFooter(); - - QWidget* CreateInputWidgets(); - - QWidget* CreateDoc(); - /** */ void SetupParameterWidgets( QWidget* widget ); @@ -192,21 +142,6 @@ private: */ void SetupFileSelectionWidget( QWidget * ); -// -// Private attributes. - -private: - - otb::Wrapper::Application::Pointer m_Application; - otb::Wrapper::QtWidgetModel* m_Model; - - QPushButton* m_ExecButton; - QPushButton* m_QuitButton; - QShortcut* m_QuitShortcut; - QLabel* m_Message; - - bool m_IsClosable : 1; - /*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/ // @@ -218,30 +153,6 @@ private slots: // image filename{s} set by the user in this OTB application (if any). void OnApplicationExecutionDone( int ); - void UpdateMessageAfterApplicationReady(bool val); - - void UpdateMessageAfterExecution(int status); - - /** - */ - void OnExecButtonClicked(); - - /** - */ - inline void OnProgressReportBegin(); - - /** - */ - inline void OnProgressReportEnd( int status ); - - /** - */ - void OnExceptionRaised( QString what ); - - /** - */ - inline void SetClosable( bool ); - /** */ inline void OnFileSelectionWidgetAdded0( QWidget * ); @@ -264,47 +175,6 @@ namespace mvd namespace Wrapper { -/*****************************************************************************/ -inline -bool -QtWidgetView -::IsClosable() const -{ - return m_IsClosable; -} - -/*****************************************************************************/ -inline -void -QtWidgetView -::SetClosable( bool enabled ) -{ - m_IsClosable = enabled; - - setEnabled( true ); - - if( m_QuitButton!=NULL ) - m_QuitButton->setEnabled( m_IsClosable ); -} - -/*******************************************************************************/ -inline -void -QtWidgetView -::OnProgressReportBegin() -{ - SetClosable( false ); -} - -/*******************************************************************************/ -inline -void -QtWidgetView -::OnProgressReportEnd( int ) -{ - SetClosable( true ); -} - /*******************************************************************************/ inline void diff --git a/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx b/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx index 3c33015a5b..252c604379 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx @@ -23,28 +23,16 @@ /*****************************************************************************/ /* INCLUDE SECTION */ -// -// Qt includes (sorted by alphabetic order) -//// Must be included before system/custom includes. - // // System includes (sorted by alphabetic order) #include <functional> -// -// ITK includes (sorted by alphabetic order) - // // OTB includes (sorted by alphabetic order) #include "otbWrapperApplicationHtmlDocGenerator.h" -// #include "otbWrapperComplexOutputImageParameter.h" #include "otbWrapperOutputFilenameParameter.h" -// #include "otbWrapperOutputImageParameter.h" #include "otbWrapperOutputVectorDataParameter.h" -// #include "otbWrapperQtWidgetOutputImageParameter.h" -// #include "otbWrapperQtWidgetProgressReport.h" #include "otbWrapperQtWidgetSimpleProgressReport.h" -// #include "otbWrapperTypes.h" // // Monteverdi includes (sorted by alphabetic order) @@ -140,208 +128,43 @@ QtWidgetView ::QtWidgetView( const otb::Wrapper::Application::Pointer & otbApp, QWidget* p, Qt::WindowFlags flags ) : - QWidget( p, flags ), - m_Application( otbApp ), - m_Model( NULL ), - m_ExecButton( NULL ), - m_QuitButton( NULL ), - m_Message( NULL ), - m_IsClosable( true ) + otb::Wrapper::QtWidgetView( otbApp, p, flags ) { setObjectName( QtWidgetView::OBJECT_NAME ); - m_Model = new otb::Wrapper::QtWidgetModel( otbApp ); - m_QuitShortcut = new QShortcut(QKeySequence("Ctrl+Q"), this); - - QObject::connect( - m_Model, SIGNAL( SetProgressReportBegin() ), - this, SLOT( OnProgressReportBegin() ) - ); - - QObject::connect( - m_Model, SIGNAL( SetProgressReportDone( int ) ), - this, SLOT( OnProgressReportEnd( int ) ) - ); - - QObject::connect( - m_Model, SIGNAL( ExceptionRaised( QString ) ), - this, SLOT( OnExceptionRaised( QString ) ) - ); -} - -/*******************************************************************************/ -QtWidgetView -::~QtWidgetView() -{ - // m_Application is smart-pointed and will be automatically deleted. - - delete m_Model; - m_Model = NULL; -} - -/*******************************************************************************/ -void -QtWidgetView -::CreateGui() -{ - // Create a VBoxLayout with the header, the input widgets, and the footer - QVBoxLayout *mainLayout = new QVBoxLayout(); - QTabWidget *tab = new QTabWidget(); - tab->addTab(CreateInputWidgets(), tr("Parameters")); - - //otb::Wrapper::QtWidgetProgressReport* prog = new otb::Wrapper::QtWidgetProgressReport(m_Model); - //prog->SetApplication(m_Application); - //tab->addTab(prog, "Progress"); - tab->addTab(CreateDoc(), tr("Documentation")); - mainLayout->addWidget(tab); - - QTextEdit *log = new QTextEdit(); - connect( m_Model->GetLogOutput(), SIGNAL(NewContentLog(QString)), log, SLOT(append(QString) ) ); - tab->addTab(log, tr("Logs")); - - m_Message = new QLabel("<center><font color=\"#FF0000\">"+tr("Select parameters")+"</font></center>"); - connect( - m_Model, - SIGNAL( SetApplicationReady( bool ) ), - this, SLOT( UpdateMessageAfterApplicationReady( bool ) ) - ); - connect( - m_Model, - SIGNAL(SetProgressReportDone(int)), - this, SLOT(UpdateMessageAfterExecution(int)) ); - mainLayout->addWidget(m_Message); - - otb::Wrapper::QtWidgetSimpleProgressReport* progressReport = - new otb::Wrapper::QtWidgetSimpleProgressReport(m_Model); - progressReport->SetApplication(m_Application); - - QWidget* footer = CreateFooter(); - - QHBoxLayout *footLayout = new QHBoxLayout; - footLayout->addWidget(progressReport); - footLayout->addWidget(footer); - mainLayout->addLayout(footLayout); - - footLayout->setAlignment(footer, Qt::AlignBottom); - - QGroupBox *mainGroup = new QGroupBox(); - mainGroup->setLayout(mainLayout); - - QVBoxLayout *finalLayout = new QVBoxLayout(); - finalLayout->addWidget(mainGroup); - - // Make the final layout to the widget - this->setLayout(finalLayout); -} - -/*******************************************************************************/ -QWidget* -QtWidgetView -::CreateInputWidgets() -{ - QScrollArea *scrollArea = new QScrollArea; - - QWidget * widget = - otb::Wrapper::QtWidgetParameterFactory::CreateQtWidget( - m_Model->GetApplication()->GetParameterList(), - m_Model - ); - - scrollArea->setWidget( widget ); - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - scrollArea->setWidgetResizable(true); + m_IconPathDone = std::string("<img src=\":/icons/done\" width=\"16\" height=\"16\" />"); + m_IconPathFailed = std::string("<img src=\":/icons/failed\" width=\"16\" height=\"16\" />"); // // need to be connected to the end of a process QObject::connect( - m_Model, + GetModel(), SIGNAL( SetProgressReportDone( int ) ), // to: this, SLOT ( OnApplicationExecutionDone( int ) ) ); - - SetupParameterWidgets( widget ); - - return scrollArea; } /*******************************************************************************/ -QWidget* QtWidgetView -::CreateFooter() +::~QtWidgetView() { - // an HLayout with two buttons : Execute and Quit - QGroupBox *footerGroup = new QGroupBox; - QHBoxLayout *footerLayout = new QHBoxLayout; - - footerGroup->setFixedHeight(40); - footerGroup->setContentsMargins(0, 0, 0, 0); - footerLayout->setContentsMargins(5, 5, 5, 5); - - m_ExecButton = new QPushButton(footerGroup); - m_ExecButton->setDefault(true); - m_ExecButton->setEnabled(false); - m_ExecButton->setText(QObject::tr("Execute")); - connect( - m_Model, SIGNAL( SetApplicationReady( bool ) ), - m_ExecButton, SLOT( setEnabled( bool ) ) - ); - - QObject::connect( - m_ExecButton, SIGNAL( clicked() ), - // to: - this, SLOT( OnExecButtonClicked() ) - ); - QObject::connect( - this, SIGNAL( ExecuteAndWriteOutput() ), - // to: - m_Model, SLOT( ExecuteAndWriteOutputSlot() ) - ); - - m_QuitButton = new QPushButton(footerGroup); - m_QuitButton->setText(QObject::tr("Quit")); - connect( - m_QuitButton, - SIGNAL( clicked() ), - // to: - this, - SLOT( close() ) - ); - - // Add Ctrl-Q shortcut to quit - connect( m_QuitShortcut, SIGNAL(activated()), this, SLOT(close()) ); - - - // Put the buttons on the right - footerLayout->addStretch(); - footerLayout->addWidget(m_ExecButton); - footerLayout->addWidget(m_QuitButton); - - footerGroup->setLayout(footerLayout); - - return footerGroup; } /*******************************************************************************/ QWidget* QtWidgetView -::CreateDoc() +::CreateInputWidgets() { - QTextEdit *text = new QTextEdit; - text->setReadOnly(true); - - QTextDocument * doc = new QTextDocument(); + QWidget * widget = otb::Wrapper::QtWidgetView::CreateInputWidgets(); - std::string docContain; - otb::Wrapper::ApplicationHtmlDocGenerator::GenerateDoc( m_Application, docContain); + otb::Wrapper::QtWidgetParameterBase *paramWidget = + widget->findChild<otb::Wrapper::QtWidgetParameterBase*>(); - doc->setHtml(docContain.c_str()); + SetupParameterWidgets(paramWidget); - text->setDocument(doc); - - return text; + return widget; } /*******************************************************************************/ @@ -369,11 +192,11 @@ QtWidgetView SetupWidget( widget, - OutputImageInitializer( m_Application->GetName() ) + OutputImageInitializer( GetModel()->GetApplication()->GetName() ) ); SetupWidget( widget, - ComplexOutputImageInitializer( m_Application->GetName() ) + ComplexOutputImageInitializer( GetModel()->GetApplication()->GetName() ) ); SetupWidget( widget, OutputVectorDataInitializer() ); @@ -394,36 +217,6 @@ QtWidgetView initialize( qobject_cast< FileSelectionInitializer::argument_type >( widget ) ); } -/*******************************************************************************/ -void -QtWidgetView -::closeEvent( QCloseEvent * e ) -{ - assert( e!=NULL ); - - if( !IsClosable() ) - { - assert( !m_Application.IsNull() ); - - QMessageBox::warning( - this, - tr( "Warning!" ), - tr( "OTB-Application '%1' cannot be closed while running!") - .arg( m_Application->GetDocName() ) - ); - - e->ignore(); - - return; - } - - QWidget::closeEvent( e ); - - emit QuitSignal(); - - deleteLater(); -} - /*******************************************************************************/ /* SLOTS */ /*******************************************************************************/ @@ -431,226 +224,180 @@ void QtWidgetView ::OnExecButtonClicked() { - assert( m_Model!=NULL ); - assert( m_Model->GetApplication()!=NULL ); - - - assert( I18nCoreApplication::Instance()!=NULL ); - - // - // Get layer-stack, if any. - StackedLayerModel * layerStack = - I18nCoreApplication::Instance()->GetModel< StackedLayerModel >(); - - otb::Wrapper::Application::Pointer otbApp( m_Model->GetApplication() ); - - // - // Check output parameters of OTB-application. - StringVector paramKeys( otbApp->GetParametersKeys() ); - QStringList filenames1; - - KeyLayerAccumulator::KeyLayerPairList layers; - QStringList filenames2; - - for( StringVector::const_iterator it( paramKeys.begin() ); - it!=paramKeys.end(); - ++it ) + if ( !IsRunning() ) { - if( otbApp->IsParameterEnabled( *it, true ) && - otbApp->HasValue( *it ) ) + assert( GetModel()!=NULL ); + assert( GetModel()->GetApplication()!=NULL ); + + + assert( I18nCoreApplication::Instance()!=NULL ); + + // + // Get layer-stack, if any. + StackedLayerModel * layerStack = + I18nCoreApplication::Instance()->GetModel< StackedLayerModel >(); + + otb::Wrapper::Application::Pointer otbApp( GetModel()->GetApplication() ); + + // + // Check output parameters of OTB-application. + StringVector paramKeys( otbApp->GetParametersKeys() ); + QStringList filenames1; + + KeyLayerAccumulator::KeyLayerPairList layers; + QStringList filenames2; + + for( StringVector::const_iterator it( paramKeys.begin() ); + it!=paramKeys.end(); + ++it ) { - otb::Wrapper::Parameter::Pointer param( otbApp->GetParameterByKey( *it ) ); - assert( !param.IsNull() ); - - // qDebug() - // << it->c_str() << ": type" << otbApp->GetParameterType( *it ); - - // const char* filename = NULL; - std::string filename; - - switch( otbApp->GetParameterType( *it ) ) - { - case otb::Wrapper::ParameterType_OutputFilename: - filename = - otb::DynamicCast< otb::Wrapper::OutputFilenameParameter >( param ) - ->GetValue(); - break; - // - // FILENAME. - // - // IMAGE. - case otb::Wrapper::ParameterType_OutputImage: - filename = - otb::DynamicCast< otb::Wrapper::OutputImageParameter >( param ) - ->GetFileName(); - break; - // - // VECTOR-DATA. - case otb::Wrapper::ParameterType_OutputVectorData: - filename = - otb::DynamicCast< otb::Wrapper::OutputVectorDataParameter >( param ) - ->GetFileName(); - break; - // - // COMPLEX IMAGE. - case otb::Wrapper::ParameterType_ComplexOutputImage: - filename = - otb::DynamicCast< otb::Wrapper::ComplexOutputImageParameter >( param ) - ->GetFileName(); - break; - // - // NONE. - default: - break; - } - - if( QFileInfo( filename.c_str() ).exists() ) - filenames1.push_back( filename.c_str() ); - - if( layerStack!=NULL ) - { - KeyLayerAccumulator accumulator( - std::for_each( - layerStack->Begin(), - layerStack->End(), KeyLayerAccumulator( filename, layers ) - ) - ); - - if( accumulator.GetCount()>0 ) - filenames2.push_back( filename.c_str() ); - } - } - } - - { - QString message; - - if( filenames1.size()==1 ) - { - // qDebug() - // << it->c_str() << ":" << QString( filename.c_str() ); - - message = - tr( "Are you sure you want to overwrite file '%1'?" ) - .arg( filenames1.front() ); - } - else if( filenames1.size()>1 ) - { - message = - tr( "Following files will be overwritten. Are you sure you want to continue?\n- %1" ) - .arg( filenames1.join( "\n- " ) ); - } - - if( !message.isEmpty() ) + if( otbApp->IsParameterEnabled( *it, true ) && + otbApp->HasValue( *it ) ) + { + otb::Wrapper::Parameter::Pointer param( otbApp->GetParameterByKey( *it ) ); + assert( !param.IsNull() ); + + // qDebug() + // << it->c_str() << ": type" << otbApp->GetParameterType( *it ); + + // const char* filename = NULL; + std::string filename; + + switch( otbApp->GetParameterType( *it ) ) { - QMessageBox::StandardButton button = - QMessageBox::question( - this, - PROJECT_NAME, - message, - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No - ); - - if( button==QMessageBox::No ) - return; + case otb::Wrapper::ParameterType_OutputFilename: + filename = + otb::DynamicCast< otb::Wrapper::OutputFilenameParameter >( param ) + ->GetValue(); + break; + // + // FILENAME. + // + // IMAGE. + case otb::Wrapper::ParameterType_OutputImage: + filename = + otb::DynamicCast< otb::Wrapper::OutputImageParameter >( param ) + ->GetFileName(); + break; + // + // VECTOR-DATA. + case otb::Wrapper::ParameterType_OutputVectorData: + filename = + otb::DynamicCast< otb::Wrapper::OutputVectorDataParameter >( param ) + ->GetFileName(); + break; + // + // COMPLEX IMAGE. + case otb::Wrapper::ParameterType_ComplexOutputImage: + filename = + otb::DynamicCast< otb::Wrapper::ComplexOutputImageParameter >( param ) + ->GetFileName(); + break; + // + // NONE. + default: + break; } - } - - { - QString message; - - if( filenames2.size()==1 ) + + if( QFileInfo( filename.c_str() ).exists() ) + filenames1.push_back( filename.c_str() ); + + if( layerStack!=NULL ) { - // qDebug() - // << it->c_str() << ":" << QString( filename.c_str() ); - - message = - tr( "File '%1' is being viewed in " PROJECT_NAME " and will be concurrently overwritten by running this %2. File will be removed from layer-stack before running %2 and reloaded after.\n\nDo you want to continue?" ) - .arg( filenames2.front() ) - .arg( otbApp->GetDocName() ); + KeyLayerAccumulator accumulator( + std::for_each( + layerStack->Begin(), + layerStack->End(), KeyLayerAccumulator( filename, layers ) + ) + ); + + if( accumulator.GetCount()>0 ) + filenames2.push_back( filename.c_str() ); } - else if( filenames2.size()>1 ) + } + } + { - message = - tr( "Following files are being viewed in " PROJECT_NAME " and will be concurrently overwritter by running %2. Files will be removed from layer-stack before running %2. Do you want to continue?\n- %1" ) - .arg( filenames2.join( "\n- " ) ) - .arg( otbApp->GetDocName() ); + QString message; + + if( filenames1.size()==1 ) + { + // qDebug() + // << it->c_str() << ":" << QString( filename.c_str() ); + + message = + tr( "Are you sure you want to overwrite file '%1'?" ) + .arg( filenames1.front() ); + } + else if( filenames1.size()>1 ) + { + message = + tr( "Following files will be overwritten. Are you sure you want to continue?\n- %1" ) + .arg( filenames1.join( "\n- " ) ); + } + + if( !message.isEmpty() ) + { + QMessageBox::StandardButton button = + QMessageBox::question( + this, + PROJECT_NAME, + message, + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No + ); + + if( button==QMessageBox::No ) + return; + } } - - if( !message.isEmpty() ) + { - QMessageBox::StandardButton button = - QMessageBox::question( - this, - PROJECT_NAME, - message, - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No - ); - - if( button==QMessageBox::No ) - return; - - while( !layers.empty() ) + QString message; + + if( filenames2.size()==1 ) { - layerStack->Delete( layers.front().first ); - - layers.pop_front(); + // qDebug() + // << it->c_str() << ":" << QString( filename.c_str() ); + + message = + tr( "File '%1' is being viewed in " PROJECT_NAME " and will be concurrently overwritten by running this %2. File will be removed from layer-stack before running %2 and reloaded after.\n\nDo you want to continue?" ) + .arg( filenames2.front() ) + .arg( otbApp->GetDocName() ); + } + else if( filenames2.size()>1 ) + { + message = + tr( "Following files are being viewed in " PROJECT_NAME " and will be concurrently overwritter by running %2. Files will be removed from layer-stack before running %2. Do you want to continue?\n- %1" ) + .arg( filenames2.join( "\n- " ) ) + .arg( otbApp->GetDocName() ); + } + + if( !message.isEmpty() ) + { + QMessageBox::StandardButton button = + QMessageBox::question( + this, + PROJECT_NAME, + message, + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No + ); + + if( button==QMessageBox::No ) + return; + + while( !layers.empty() ) + { + layerStack->Delete( layers.front().first ); + + layers.pop_front(); + } } } } - - /* U N S A F E - // BUGFIX: Mantis-750 - // - // Remove files which will be overwritten in order to use - // file-existence to check whether to emit the OutputImageChanged - // signal (see ::OnApplicationExecutionDone()). - for( FileInfoVector::const_iterator it( fileInfos.begin() ); - it!=fileInfos.end(); - ++it ) - { - qDebug() << "Removing:" << it->filePath(); - - it->dir().remove( it->fileName() ); - } - */ - - emit ExecuteAndWriteOutput(); - - m_Message->setText("<center><font color=\"#FF0000\">"+tr("Running")+"</font></center>"); -} - -/******************************************************************************/ -void -QtWidgetView -::UpdateMessageAfterExecution(int status) -{ - if (status >= 0) - { - m_Message->setText("<center>" - "<img src=\":/icons/done\" width=\"16\" height=\"16\" />" - "<font color=\"#00A000\">"+tr("Done")+"</font></center>"); - } - else - { - m_Message->setText("<center>" - "<img src=\":/icons/failed\" width=\"16\" height=\"16\" />" - "<font color=\"#FF0000\">"+tr("Failed")+"</font></center>"); - } -} - -/*******************************************************************************/ -void -QtWidgetView -::UpdateMessageAfterApplicationReady( bool val ) -{ - if(val == true) - m_Message->setText("<center><font color=\"#00A000\">"+tr("Ready to run")+"</font></center>"); - else - m_Message->setText("<center><font color=\"#FF0000\">"+tr("Select parameters")+"</font></center>"); + otb::Wrapper::QtWidgetView::OnExecButtonClicked(); } /*******************************************************************************/ @@ -675,7 +422,7 @@ void QtWidgetView ::OnApplicationExecutionDone( int status ) { - otb::Wrapper::Application::Pointer otbApp( m_Model->GetApplication() ); + otb::Wrapper::Application::Pointer otbApp( GetModel()->GetApplication() ); if( status!=0 ) { @@ -765,6 +512,5 @@ QtWidgetView emit ExecutionDone( status ); } -} - -} +} // end of namespace Wrapper +} // end of namespace mvd -- GitLab From 6549e83eea9b2b497d64363aa6fef88bf04a81a6 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 20 Mar 2018 12:06:30 +0100 Subject: [PATCH 484/567] REFAC: QtWidgetView doesn't have to provide direct access to the Application --- Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx | 4 ++-- .../MonteverdiGui/src/mvdApplicationLauncher.cxx | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx b/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx index 6b1d92cf58..9420452e32 100644 --- a/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx +++ b/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx @@ -1431,11 +1431,11 @@ MainWindow if( !( *it )->IsClosable() ) { - assert( !( *it )->GetApplication().IsNull() ); + assert( ( *it )->GetModel()->GetApplication() ); // qDebug() << "OTB-application:" << ( *it )->GetApplication()->GetDocName(); - names.push_back( ( *it )->GetApplication()->GetDocName() ); + names.push_back( ( *it )->GetModel()->GetApplication()->GetDocName() ); } } diff --git a/Modules/Visualization/MonteverdiGui/src/mvdApplicationLauncher.cxx b/Modules/Visualization/MonteverdiGui/src/mvdApplicationLauncher.cxx index 7d571ff73b..b3a28a432f 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdApplicationLauncher.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdApplicationLauncher.cxx @@ -217,13 +217,13 @@ ApplicationLauncher ApplicationLauncher::NewOtbApplicationWidget( appName, isStandalone ); assert( appWidget!=NULL ); - assert( appWidget->GetApplication() ); + assert( appWidget->GetModel()->GetApplication() ); QMainWindow * mainWindow = new QMainWindow( p, flags ); mainWindow->setWindowTitle( QString( "%1 (OTB-" OTB_VERSION_STRING ")" ) - .arg( appWidget->GetApplication()->GetDocName() ) + .arg( appWidget->GetModel()->GetApplication()->GetDocName() ) ); mainWindow->setWindowIcon( QIcon( ":/otb_small.png" ) ); @@ -251,11 +251,11 @@ ApplicationLauncher ); assert( appWidget!=NULL ); - assert( appWidget->GetApplication() ); + assert( appWidget->GetModel()->GetApplication() ); appWidget->setWindowTitle( QString( "%1 (OTB-" OTB_VERSION_STRING ")" ) - .arg( appWidget->GetApplication()->GetDocName() ) + .arg( appWidget->GetModel()->GetApplication()->GetDocName() ) ); appWidget->setWindowIcon( QIcon( ":/icons/process" ) ); -- GitLab From 9ce7fad674d83abadfbb70c70a79b0cadea5256f Mon Sep 17 00:00:00 2001 From: remi cresson <remi.cresson@teledetection.fr> Date: Tue, 20 Mar 2018 14:22:57 +0000 Subject: [PATCH 485/567] REFAC: correct indentation --- Modules/IO/ImageIO/include/otbImageFileWriter.txx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index 907da0d9bd..593019fd92 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -472,11 +472,11 @@ ImageFileWriter<TInputImage> /** Parse region size modes */ if(m_FilenameHelper->BoxIsSet()) { - std::vector<int> boxVector; - Utils::ConvertStringToVector( - m_FilenameHelper->GetBox(), boxVector, "ExtendedFileName:box", ":"); - - typename InputImageRegionType::IndexType start; + std::vector<int> boxVector; + Utils::ConvertStringToVector( + m_FilenameHelper->GetBox(), boxVector, "ExtendedFileName:box", ":"); + + typename InputImageRegionType::IndexType start; typename InputImageRegionType::SizeType size; start[0] = boxVector[0]; // first index on X -- GitLab From f55c18be3d4b1e8dd850ba92c7179330b82def1d Mon Sep 17 00:00:00 2001 From: remi cresson <remi.cresson@teledetection.fr> Date: Tue, 20 Mar 2018 14:40:28 +0000 Subject: [PATCH 486/567] FIX: update image origin --- Modules/IO/ImageIO/include/otbImageFileWriter.txx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index 593019fd92..711ccd99b5 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -468,6 +468,9 @@ ImageFileWriter<TInputImage> */ inputPtr->UpdateOutputInformation(); InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion(); + typename TInputImage::PointType origin = inputPtr->GetOrigin(); + const typename TInputImage::SpacingType& spacing = inputPtr->GetSpacing(); + const typename TInputImage::DirectionType& direction = inputPtr->GetDirection(); /** Parse region size modes */ if(m_FilenameHelper->BoxIsSet()) @@ -483,7 +486,6 @@ ImageFileWriter<TInputImage> start[1] = boxVector[1]; // first index on Y size[0] = boxVector[2]; // size along X size[1] = boxVector[3]; // size along Y - inputRegion.SetSize(size); m_ShiftOutputIndex = start; @@ -501,6 +503,9 @@ ImageFileWriter<TInputImage> e.SetDataObject(inputPtr); throw e; } + + inputPtr->TransformIndexToPhysicalPoint(inputRegion.GetIndex(), origin); + otbLogMacro(Info,<<"Writing user defined region ["<<start[0]<<", "<<start[0]+size[0]-1<<"]x["<<start[1]<<", "<<start[1]+size[1]<<"]"); } @@ -542,9 +547,6 @@ ImageFileWriter<TInputImage> // Setup the ImageIO with information from inputPtr // m_ImageIO->SetNumberOfDimensions(TInputImage::ImageDimension); - const typename TInputImage::SpacingType& spacing = inputPtr->GetSpacing(); - const typename TInputImage::PointType& origin = inputPtr->GetOrigin(); - const typename TInputImage::DirectionType& direction = inputPtr->GetDirection(); int direction_sign(0); for (unsigned int i = 0; i < TInputImage::ImageDimension; ++i) { @@ -555,7 +557,7 @@ ImageFileWriter<TInputImage> // Final image size m_ImageIO->SetDimensions(i, inputRegion.GetSize(i)); m_ImageIO->SetSpacing(i, direction_sign * spacing[i]); - m_ImageIO->SetOrigin(i, origin[i] + static_cast<double>(inputRegion.GetIndex()[i]) * spacing[i]); + m_ImageIO->SetOrigin(i, origin[i]); vnl_vector<double> axisDirection(TInputImage::ImageDimension); // Please note: direction cosines are stored as columns of the -- GitLab From fd998699a0ab8d3788c72a47b7d6d00a32c45fcc Mon Sep 17 00:00:00 2001 From: remi cresson <remi.cresson@teledetection.fr> Date: Tue, 20 Mar 2018 15:25:06 +0000 Subject: [PATCH 487/567] REFAC: remove ioRegion.SetIndex(i, streamRegion.GetIndex(i)) --- Modules/IO/ImageIO/include/otbImageFileWriter.txx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index 711ccd99b5..87a0d50453 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -469,8 +469,6 @@ ImageFileWriter<TInputImage> inputPtr->UpdateOutputInformation(); InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion(); typename TInputImage::PointType origin = inputPtr->GetOrigin(); - const typename TInputImage::SpacingType& spacing = inputPtr->GetSpacing(); - const typename TInputImage::DirectionType& direction = inputPtr->GetDirection(); /** Parse region size modes */ if(m_FilenameHelper->BoxIsSet()) @@ -546,6 +544,8 @@ ImageFileWriter<TInputImage> // // Setup the ImageIO with information from inputPtr // + const typename TInputImage::SpacingType& spacing = inputPtr->GetSpacing(); + const typename TInputImage::DirectionType& direction = inputPtr->GetDirection(); m_ImageIO->SetNumberOfDimensions(TInputImage::ImageDimension); int direction_sign(0); for (unsigned int i = 0; i < TInputImage::ImageDimension; ++i) @@ -620,7 +620,6 @@ ImageFileWriter<TInputImage> for (unsigned int i = 0; i < TInputImage::ImageDimension; ++i) { ioRegion.SetSize(i, streamRegion.GetSize(i)); - ioRegion.SetIndex(i, streamRegion.GetIndex(i)); //Set the ioRegion index using the shifted index ( (0,0 without box parameter)) ioRegion.SetIndex(i, streamRegion.GetIndex(i) - m_ShiftOutputIndex[i]); } -- GitLab From ca470c1eeb4e5ffc61666c09818af8761ab353e0 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 20 Mar 2018 17:47:26 +0100 Subject: [PATCH 488/567] ENH: use a namespace instead of static functions --- .../include/otbWrapperMetaDataHelper.h | 77 +++---- .../src/otbWrapperMetaDataHelper.cxx | 60 +++-- Modules/Wrappers/SWIG/src/otbApplication.i | 215 ++++++++---------- 3 files changed, 162 insertions(+), 190 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperMetaDataHelper.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperMetaDataHelper.h index e2d2926799..36274a5a08 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperMetaDataHelper.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperMetaDataHelper.h @@ -33,99 +33,96 @@ namespace Wrapper { /** - * \class MetaDataHelper + * \namespace MetaDataHelper * - * \brief Small helper to manipulate itk::MetaDataDictionary + * \brief Contains small helper functions to manipulate itk::MetaDataDictionary + * + * These functions are only here to instanciate the different template function that + * allow to get/set values in MetaDataDictionary. * - * This class is only here to instanciate the different template function that - * allow to get/set values in MetaDataDictionary. All functions are static. - * - * \ingroup OTBApplicationEngine */ -class OTBApplicationEngine_EXPORT MetaDataHelper +namespace MetaDataHelper { -public: - MetaDataHelper(); - virtual ~MetaDataHelper(); - typedef enum + enum class MDType { - MDType_STRING, - MDType_INT, - MDType_DOUBLE, - MDType_GCP, - MDType_VECTOR, - MDType_IMAGEKWL, - MDType_VECTORDATAKWL, - MDType_BOOLVECTOR - } MDType; - - static MDType GetType(const std::string &val); - - static std::string GetString( + String, + Int, + Double, + GCP, + Vector, + ImageKWL, + VectorDataKWL, + BoolVector + }; + + OTBApplicationEngine_EXPORT MDType GetType(const std::string &val); + + OTBApplicationEngine_EXPORT std::string GetString( const itk::MetaDataDictionary &dict, const std::string &key); - static void SetString( + OTBApplicationEngine_EXPORT void SetString( itk::MetaDataDictionary &dict, const std::string &key, const std::string &val); - static unsigned int GetInt( + OTBApplicationEngine_EXPORT unsigned int GetInt( const itk::MetaDataDictionary &dict, const std::string &key); - static void SetInt( + OTBApplicationEngine_EXPORT void SetInt( itk::MetaDataDictionary &dict, const std::string &key, unsigned int val); - static double GetDouble( + OTBApplicationEngine_EXPORT double GetDouble( const itk::MetaDataDictionary &dict, const std::string &key); - static void SetDouble( + OTBApplicationEngine_EXPORT void SetDouble( itk::MetaDataDictionary &dict, const std::string &key, double val); - static otb::OTB_GCP GetGCP( + OTBApplicationEngine_EXPORT otb::OTB_GCP GetGCP( const itk::MetaDataDictionary &dict, const std::string &key); - static void SetGCP( + OTBApplicationEngine_EXPORT void SetGCP( itk::MetaDataDictionary &dict, const std::string &key, const otb::OTB_GCP &val); - static otb::MetaDataKey::VectorType GetVector( + OTBApplicationEngine_EXPORT otb::MetaDataKey::VectorType GetVector( const itk::MetaDataDictionary &dict, const std::string &key); - static void SetVector( + OTBApplicationEngine_EXPORT void SetVector( itk::MetaDataDictionary &dict, const std::string &key, const otb::MetaDataKey::VectorType &val); - static otb::ImageKeywordlist GetImageKWL( + OTBApplicationEngine_EXPORT otb::ImageKeywordlist GetImageKWL( const itk::MetaDataDictionary &dict, const std::string &key); - static void SetImageKWL( + OTBApplicationEngine_EXPORT void SetImageKWL( itk::MetaDataDictionary &dict, const std::string &key, const otb::ImageKeywordlist &val); - static otb::VectorDataKeywordlist GetVectorDataKWL( + OTBApplicationEngine_EXPORT otb::VectorDataKeywordlist GetVectorDataKWL( const itk::MetaDataDictionary &dict, const std::string &key); - static void SetVectorDataKWL( + OTBApplicationEngine_EXPORT void SetVectorDataKWL( itk::MetaDataDictionary &dict, const std::string &key, const otb::VectorDataKeywordlist &val); - static otb::MetaDataKey::BoolVectorType GetBoolVector( + OTBApplicationEngine_EXPORT otb::MetaDataKey::BoolVectorType GetBoolVector( const itk::MetaDataDictionary &dict, const std::string &key); - static void SetBoolVector( + OTBApplicationEngine_EXPORT void SetBoolVector( itk::MetaDataDictionary &dict, const std::string &key, const otb::MetaDataKey::BoolVectorType &val); -}; + +} // end of namespace MetaDataHelper } // end of namespace Wrapper } // end of namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx index 661d5c6264..4cf7c602e1 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx @@ -25,45 +25,38 @@ namespace otb { namespace Wrapper { - -MetaDataHelper::MetaDataHelper() +namespace MetaDataHelper { -} - -MetaDataHelper::~MetaDataHelper() -{ -} -MetaDataHelper::MDType -MetaDataHelper::GetType(const std::string &val) +MDType GetType(const std::string &val) { MDType ret; otb::MetaDataKey::KeyType kt = otb::MetaDataKey::GetKeyType(val); switch (kt) { case otb::MetaDataKey::TSTRING: - ret = MDType_STRING; + ret = MDType::String; break; case otb::MetaDataKey::TENTIER: - ret = MDType_INT; + ret = MDType::Int; break; case otb::MetaDataKey::TDOUBLE: - ret = MDType_DOUBLE; + ret = MDType::Double; break; case otb::MetaDataKey::TOTB_GCP: - ret = MDType_GCP; + ret = MDType::GCP; break; case otb::MetaDataKey::TVECTOR: - ret = MDType_VECTOR; + ret = MDType::Vector; break; case otb::MetaDataKey::TOSSIMKEYWORDLIST: - ret = MDType_IMAGEKWL; + ret = MDType::ImageKWL; break; case otb::MetaDataKey::TVECTORDATAKEYWORDLIST: - ret = MDType_VECTORDATAKWL; + ret = MDType::VectorDataKWL; break; case otb::MetaDataKey::TBOOLVECTOR: - ret = MDType_BOOLVECTOR; + ret = MDType::BoolVector; break; default: break; @@ -72,7 +65,7 @@ MetaDataHelper::GetType(const std::string &val) } std::string -MetaDataHelper::GetString( +GetString( const itk::MetaDataDictionary &dict, const std::string &key) { @@ -82,7 +75,7 @@ MetaDataHelper::GetString( } void -MetaDataHelper::SetString( +SetString( itk::MetaDataDictionary &dict, const std::string &key, const std::string &val) @@ -91,7 +84,7 @@ MetaDataHelper::SetString( } unsigned int -MetaDataHelper::GetInt( +GetInt( const itk::MetaDataDictionary &dict, const std::string &key) { @@ -101,7 +94,7 @@ MetaDataHelper::GetInt( } void -MetaDataHelper::SetInt( +SetInt( itk::MetaDataDictionary &dict, const std::string &key, unsigned int val) @@ -110,7 +103,7 @@ MetaDataHelper::SetInt( } double -MetaDataHelper::GetDouble( +GetDouble( const itk::MetaDataDictionary &dict, const std::string &key) { @@ -120,7 +113,7 @@ MetaDataHelper::GetDouble( } void -MetaDataHelper::SetDouble( +SetDouble( itk::MetaDataDictionary &dict, const std::string &key, double val) @@ -129,7 +122,7 @@ MetaDataHelper::SetDouble( } otb::OTB_GCP -MetaDataHelper::GetGCP( +GetGCP( const itk::MetaDataDictionary &dict, const std::string &key) { @@ -139,7 +132,7 @@ MetaDataHelper::GetGCP( } void -MetaDataHelper::SetGCP( +SetGCP( itk::MetaDataDictionary &dict, const std::string &key, const otb::OTB_GCP &val) @@ -148,7 +141,7 @@ MetaDataHelper::SetGCP( } otb::MetaDataKey::VectorType -MetaDataHelper::GetVector( +GetVector( const itk::MetaDataDictionary &dict, const std::string &key) { @@ -158,7 +151,7 @@ MetaDataHelper::GetVector( } void -MetaDataHelper::SetVector( +SetVector( itk::MetaDataDictionary &dict, const std::string &key, const otb::MetaDataKey::VectorType &val) @@ -167,7 +160,7 @@ MetaDataHelper::SetVector( } otb::ImageKeywordlist -MetaDataHelper::GetImageKWL( +GetImageKWL( const itk::MetaDataDictionary &dict, const std::string &key) { @@ -177,7 +170,7 @@ MetaDataHelper::GetImageKWL( } void -MetaDataHelper::SetImageKWL( +SetImageKWL( itk::MetaDataDictionary &dict, const std::string &key, const otb::ImageKeywordlist &val) @@ -186,7 +179,7 @@ MetaDataHelper::SetImageKWL( } otb::VectorDataKeywordlist -MetaDataHelper::GetVectorDataKWL( +GetVectorDataKWL( const itk::MetaDataDictionary &dict, const std::string &key) { @@ -196,7 +189,7 @@ MetaDataHelper::GetVectorDataKWL( } void -MetaDataHelper::SetVectorDataKWL( +SetVectorDataKWL( itk::MetaDataDictionary &dict, const std::string &key, const otb::VectorDataKeywordlist &val) @@ -205,7 +198,7 @@ MetaDataHelper::SetVectorDataKWL( } otb::MetaDataKey::BoolVectorType -MetaDataHelper::GetBoolVector( +GetBoolVector( const itk::MetaDataDictionary &dict, const std::string &key) { @@ -215,7 +208,7 @@ MetaDataHelper::GetBoolVector( } void -MetaDataHelper::SetBoolVector( +SetBoolVector( itk::MetaDataDictionary &dict, const std::string &key, const otb::MetaDataKey::BoolVectorType &val) @@ -223,5 +216,6 @@ MetaDataHelper::SetBoolVector( itk::EncapsulateMetaData<otb::MetaDataKey::BoolVectorType>(dict, key, val); } +} // end of namespace MetaDataHelper } // end of namespace Wrapper } // end of namespace otb diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index b242048c49..c8b97c12e2 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -908,130 +908,111 @@ public: %include "PyCommand.i" -namespace otb -{ -namespace Wrapper -{ -class MetaDataHelper +%extend itkMetaDataDictionary { -public: - MetaDataHelper(); - virtual ~MetaDataHelper(); - typedef enum - { - MDType_STRING, - MDType_INT, - MDType_DOUBLE, - MDType_GCP, - MDType_VECTOR, - MDType_IMAGEKWL, - MDType_VECTORDATAKWL, - MDType_BOOLVECTOR - } MDType; - - static MDType GetType(const std::string &val); - - static std::string GetString( - const itkMetaDataDictionary &dict, - const std::string &key); - static void SetString( - itkMetaDataDictionary &dict, - const std::string &key, - const std::string &val); - - static unsigned int GetInt( - const itkMetaDataDictionary &dict, - const std::string &key); - static void SetInt( - itkMetaDataDictionary &dict, - const std::string &key, - unsigned int val); - - static double GetDouble( - const itkMetaDataDictionary &dict, - const std::string &key); - static void SetDouble( - itkMetaDataDictionary &dict, - const std::string &key, - double val); - - static OTB_GCP GetGCP( - const itkMetaDataDictionary &dict, - const std::string &key); - static void SetGCP( - itkMetaDataDictionary &dict, - const std::string &key, - const OTB_GCP &val); - - static std::vector<double> GetVector( - const itkMetaDataDictionary &dict, - const std::string &key); - static void SetVector( - itkMetaDataDictionary &dict, - const std::string &key, - const std::vector<double> &val); - - static ImageKeywordlist GetImageKWL( - const itkMetaDataDictionary &dict, - const std::string &key); - static void SetImageKWL( - itkMetaDataDictionary &dict, - const std::string &key, - const ImageKeywordlist &val); - - static VectorDataKeywordlist GetVectorDataKWL( - const itkMetaDataDictionary &dict, - const std::string &key); - static void SetVectorDataKWL( - itkMetaDataDictionary &dict, - const std::string &key, - const VectorDataKeywordlist &val); - - static std::vector<bool> GetBoolVector( - const itkMetaDataDictionary &dict, - const std::string &key); - static void SetBoolVector( - itkMetaDataDictionary &dict, - const std::string &key, - const std::vector<bool> &val); -}; + int GetType(const std::string &key) + { + return (int) otb::Wrapper::MetaDataHelper::GetType(key); + } -} // end of namespace Wrapper -} // end of namespace otb + std::string GetString(const std::string &key) + { + return otb::Wrapper::MetaDataHelper::GetString(* $self,key); + } + void SetString(const std::string &key, const std::string &val) + { + otb::Wrapper::MetaDataHelper::SetString(* $self,key,val); + } + unsigned int GetInt(const std::string &key) + { + return otb::Wrapper::MetaDataHelper::GetInt(* $self,key); + } + void SetInt(const std::string &key, unsigned int val) + { + otb::Wrapper::MetaDataHelper::SetInt(* $self,key,val); + } + double GetDouble(const std::string &key) + { + return otb::Wrapper::MetaDataHelper::GetDouble(* $self,key); + } + void SetDouble(const std::string &key, double val) + { + otb::Wrapper::MetaDataHelper::SetDouble(* $self,key,val); + } -#if SWIGPYTHON -%pythoncode -{ -MetaDataHelper.GetterMap = { - MetaDataHelper.MDType_STRING : MetaDataHelper.GetString, - MetaDataHelper.MDType_INT : MetaDataHelper.GetInt, - MetaDataHelper.MDType_DOUBLE : MetaDataHelper.GetDouble, - MetaDataHelper.MDType_GCP : MetaDataHelper.GetGCP, - MetaDataHelper.MDType_VECTOR : MetaDataHelper.GetVector, - MetaDataHelper.MDType_IMAGEKWL : MetaDataHelper.GetImageKWL, - MetaDataHelper.MDType_VECTORDATAKWL : MetaDataHelper.GetVectorDataKWL, - MetaDataHelper.MDType_BOOLVECTOR : MetaDataHelper.GetBoolVector, - } + otb::OTB_GCP GetGCP(const std::string &key) + { + return otb::Wrapper::MetaDataHelper::GetGCP(* $self,key); + } + void SetGCP(const std::string &key, const otb::OTB_GCP &val) + { + otb::Wrapper::MetaDataHelper::SetGCP(* $self,key,val); + } -MetaDataHelper.SetterMap = { - MetaDataHelper.MDType_STRING : MetaDataHelper.SetString, - MetaDataHelper.MDType_INT : MetaDataHelper.SetInt, - MetaDataHelper.MDType_DOUBLE : MetaDataHelper.SetDouble, - MetaDataHelper.MDType_GCP : MetaDataHelper.SetGCP, - MetaDataHelper.MDType_VECTOR : MetaDataHelper.SetVector, - MetaDataHelper.MDType_IMAGEKWL : MetaDataHelper.SetImageKWL, - MetaDataHelper.MDType_VECTORDATAKWL : MetaDataHelper.SetVectorDataKWL, - MetaDataHelper.MDType_BOOLVECTOR : MetaDataHelper.SetBoolVector, - } -} + std::vector<double> GetVector(const std::string &key) + { + return otb::Wrapper::MetaDataHelper::GetVector(* $self,key); + } + void SetVector(const std::string &key, const std::vector<double> &val) + { + otb::Wrapper::MetaDataHelper::SetVector(* $self,key,val); + } + + otb::ImageKeywordlist GetImageKWL(const std::string &key) + { + return otb::Wrapper::MetaDataHelper::GetImageKWL(* $self,key); + } + void SetImageKWL(const std::string &key, const otb::ImageKeywordlist &val) + { + otb::Wrapper::MetaDataHelper::SetImageKWL(* $self,key,val); + } + otb::VectorDataKeywordlist GetVectorDataKWL(const std::string &key) + { + return otb::Wrapper::MetaDataHelper::GetVectorDataKWL(* $self,key); + } + void SetVectorDataKWL(const std::string &key, const otb::VectorDataKeywordlist &val) + { + otb::Wrapper::MetaDataHelper::SetVectorDataKWL(* $self,key,val); + } + + std::vector<bool> GetBoolVector(const std::string &key) + { + return otb::Wrapper::MetaDataHelper::GetBoolVector(* $self,key); + } + void SetBoolVector(const std::string &key, const std::vector<bool> &val) + { + otb::Wrapper::MetaDataHelper::SetBoolVector(* $self,key,val); + } + +#if SWIGPYTHON // enhance the MetaDataDictionary class for Python -%extend itkMetaDataDictionary -{ %pythoncode { + GetterMap = { + 0 : GetString, + 1 : GetInt, + 2 : GetDouble, + 3 : GetGCP, + 4 : GetVector, + 5 : GetImageKWL, + 6 : GetVectorDataKWL, + 7 : GetBoolVector, + } + + SetterMap = { + 0 : SetString, + 1 : SetInt, + 2 : SetDouble, + 3 : SetGCP, + 4 : SetVector, + 5 : SetImageKWL, + 6 : SetVectorDataKWL, + 7 : SetBoolVector, + } + def __str__(self): ret = '' for k in self.GetKeys(): @@ -1045,14 +1026,14 @@ MetaDataHelper.SetterMap = { return self.GetKeys() def __getitem__(self,key): if key in self.GetKeys(): - return MetaDataHelper.GetterMap[MetaDataHelper.GetType(key)](self,key) + return self.GetterMap[self.GetType(key)](self,key) else: raise IndexError('Key not recognized') def __setitem__(self,key,val): if key in self.GetKeys(): - MetaDataHelper.SetterMap[MetaDataHelper.GetType(key)](self,key,val) + self.SetterMap[self.GetType(key)](self,key,val) else: raise IndexError('Key not recognized') } -}; #endif +}; -- GitLab From c9f5f978f701b30b4a0621bd3723f0292ecd5081 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 20 Mar 2018 18:00:09 +0100 Subject: [PATCH 489/567] ENH: virtual not needed in itkBase.i --- Modules/Wrappers/SWIG/src/itkBase.i | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/Wrappers/SWIG/src/itkBase.i b/Modules/Wrappers/SWIG/src/itkBase.i index 66cb0d1f50..f2ae37cc3d 100644 --- a/Modules/Wrappers/SWIG/src/itkBase.i +++ b/Modules/Wrappers/SWIG/src/itkBase.i @@ -89,7 +89,7 @@ class Size { public: Size(); - virtual ~Size(); + ~Size(); void Fill(unsigned long val); SizeValueType GetElement(unsigned long element) const; void SetElement(unsigned long element, SizeValueType val); @@ -101,7 +101,7 @@ class Index { public: Index(); - virtual ~Index(); + ~Index(); void Fill(signed long val); IndexValueType GetElement(unsigned long element) const; void SetElement(unsigned long element, IndexValueType val); @@ -114,7 +114,7 @@ class ImageRegion public: ImageRegion(); ImageRegion(const Index<VDim> &index, const Size<VDim> &size); - virtual ~ImageRegion(); + ~ImageRegion(); void SetIndex(const Index<VDim> &index); void SetSize(const Size<VDim> &size); void SetUpperIndex(const Index<VDim> &idx); @@ -133,7 +133,7 @@ class FixedArray { public: FixedArray(); - virtual ~FixedArray(); + ~FixedArray(); unsigned int Size(); void SetElement(unsigned short idx, const TValue &val); const TValue & GetElement(unsigned short idx); @@ -144,7 +144,7 @@ class Vector: public FixedArray<TValue,NDim> { public: Vector(); - virtual ~Vector(); + ~Vector(); typedef NumericTraits<TValue>::RealType RealValueType; RealValueType GetNorm() const; RealValueType GetSquaredNorm() const; @@ -156,7 +156,7 @@ class Point: public FixedArray<TCoord,NDim> { public: Point(); - virtual ~Point(); + ~Point(); }; // Instanciate the needed templates -- GitLab From a0b350125fb6a66d3e34f0c96afcf6b563c53b18 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Wed, 21 Mar 2018 13:07:44 +0100 Subject: [PATCH 490/567] ENH: manual modulo for speed --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index 66753a09fe..b0cac95af2 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -76,11 +76,14 @@ void replicateSamples(const SampleVectorType& inSamples, SampleVectorType& newSamples) { newSamples.resize(nbSamples); + size_t imod{0}; #pragma omp parallel for for(size_t i=0; i<nbSamples; ++i) { - newSamples[i] = inSamples[i%inSamples.size()]; + if (imod == inSamples.size()) imod = 0; + newSamples[i] = inSamples[imod++]; } + } /** Create new samples by adding noise to existing samples. Gaussian -- GitLab From 93b069632218d76b1ac76ee9872019dbf01d5acc Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Wed, 21 Mar 2018 13:11:54 +0100 Subject: [PATCH 491/567] ENH: OMP parallel in the inner loop --- Modules/Learning/Sampling/include/otbSampleAugmentation.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index b0cac95af2..bddfef9c3e 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -111,10 +111,11 @@ void jitterSamples(const SampleVectorType& inSamples, #pragma omp parallel for for(size_t i=0; i<nbComponents; ++i) gaussDis[i] = std::normal_distribution<double>{0.0, stds[i]/stdFactor}; -#pragma omp parallel for + for(size_t i=0; i<nbSamples; ++i) { newSamples[i] = inSamples[std::rand()%inSamples.size()]; +#pragma omp parallel for for(size_t j=0; j<nbComponents; ++j) newSamples[i][j] += gaussDis[j](gen); } -- GitLab From afc88b8921e6b0cd46c2b138f55b4052f5be4e8f Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Wed, 21 Mar 2018 13:16:10 +0100 Subject: [PATCH 492/567] ENH: use RAND parameter for the seed --- .../AppClassification/app/otbSampleAugmentation.cxx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx index 452119d05f..6bb7382856 100644 --- a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -129,10 +129,7 @@ private: "SMOTE algorithm"); SetDefaultParameterFloat("strategy.smote.neighbors", 5); - AddParameter(ParameterType_Int, "seed", - "Random seed."); - SetParameterDescription("seed", - "Seed for the random number generator."); + AddRANDParameter("seed"); MandatoryOff("seed"); // Doc example parameter settings -- GitLab From 00160593a010c018215fd9fb79e5344c0365e8af Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Wed, 21 Mar 2018 13:24:12 +0100 Subject: [PATCH 493/567] STYLE: naming conventions --- .../Sampling/include/otbSampleAugmentation.h | 22 +++++++------- .../include/otbSampleAugmentationFilter.h | 12 ++++---- .../include/otbSampleAugmentationFilter.txx | 30 +++++++++---------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index bddfef9c3e..84e67ffdd4 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -40,7 +40,7 @@ using SampleVectorType = std::vector<SampleType>; Estimate standard deviations of the components in one pass using Welford's algorithm */ -SampleType estimateStds(const SampleVectorType& samples) +SampleType EstimateStds(const SampleVectorType& samples) { const auto nbSamples = samples.size(); const auto nbComponents = samples[0].size(); @@ -71,7 +71,7 @@ SampleType estimateStds(const SampleVectorType& samples) * the input samples and add them to the new data set until nbSamples * are added. The elements of newSamples are removed before proceeding. */ -void replicateSamples(const SampleVectorType& inSamples, +void ReplicateSamples(const SampleVectorType& inSamples, const size_t nbSamples, SampleVectorType& newSamples) { @@ -92,7 +92,7 @@ void replicateSamples(const SampleVectorType& inSamples, * input variables divided by stdFactor (defaults to 10). The * elements of newSamples are removed before proceeding. */ -void jitterSamples(const SampleVectorType& inSamples, +void JitterSamples(const SampleVectorType& inSamples, const size_t nbSamples, SampleVectorType& newSamples, float stdFactor=10, @@ -106,7 +106,7 @@ void jitterSamples(const SampleVectorType& inSamples, std::srand(seed); // We use one gaussian distribution per component since they may // have different stds - auto stds = estimateStds(inSamples); + auto stds = EstimateStds(inSamples); std::vector<std::normal_distribution<double>> gaussDis(nbComponents); #pragma omp parallel for for(size_t i=0; i<nbComponents; ++i) @@ -136,7 +136,7 @@ struct NeighborSorter } }; -double computeSquareDistance(const SampleType& x, const SampleType& y) +double ComputeSquareDistance(const SampleType& x, const SampleType& y) { assert(x.size()==y.size()); double dist{0}; @@ -151,7 +151,7 @@ using NNIndicesType = std::vector<NeighborType>; using NNVectorType = std::vector<NNIndicesType>; /** Returns the indices of the nearest neighbors for each input sample */ -void findKNNIndices(const SampleVectorType& inSamples, +void FindKNNIndices(const SampleVectorType& inSamples, const size_t nbNeighbors, NNVectorType& nnVector) { @@ -164,7 +164,7 @@ void findKNNIndices(const SampleVectorType& inSamples, for(size_t neighborIdx=0; neighborIdx<nbSamples; ++neighborIdx) { if(sampleIdx!=neighborIdx) - nns.push_back({neighborIdx, computeSquareDistance(inSamples[sampleIdx], + nns.push_back({neighborIdx, ComputeSquareDistance(inSamples[sampleIdx], inSamples[neighborIdx])}); } std::partial_sort(nns.begin(), nns.begin()+nbNeighbors, nns.end(), NeighborSorter{}); @@ -175,7 +175,7 @@ void findKNNIndices(const SampleVectorType& inSamples, /** Generate the new sample in the line linking s1 and s2 */ -SampleType smoteCombine(const SampleType& s1, const SampleType& s2, double position) +SampleType SmoteCombine(const SampleType& s1, const SampleType& s2, double position) { auto result = s1; for(size_t i=0; i<s1.size(); ++i) @@ -189,7 +189,7 @@ synthetic minority over-sampling technique, Journal of artificial intelligence research, 16(), 321–357 (2002). http://dx.doi.org/10.1613/jair.953 */ -void smote(const SampleVectorType& inSamples, +void Smote(const SampleVectorType& inSamples, const size_t nbSamples, SampleVectorType& newSamples, const int nbNeighbors, @@ -197,7 +197,7 @@ void smote(const SampleVectorType& inSamples, { newSamples.resize(nbSamples); NNVectorType nnVector; - findKNNIndices(inSamples, nbNeighbors, nnVector); + FindKNNIndices(inSamples, nbNeighbors, nnVector); // The input samples are selected randomly with replacement std::srand(seed); #pragma omp parallel for @@ -207,7 +207,7 @@ void smote(const SampleVectorType& inSamples, const auto sample = inSamples[sampleIdx]; const auto neighborIdx = nnVector[sampleIdx][std::rand()%nbNeighbors].index; const auto neighbor = inSamples[neighborIdx]; - newSamples[i] = smoteCombine(sample, neighbor, std::rand()/double{RAND_MAX}); + newSamples[i] = SmoteCombine(sample, neighbor, std::rand()/double{RAND_MAX}); } } diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h index 09467dfd26..e06f03b0ab 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h @@ -124,24 +124,24 @@ protected: using Superclass::MakeOutput; - SampleVectorType extractSamples(const ogr::DataSource::Pointer vectors, + SampleVectorType ExtractSamples(const ogr::DataSource::Pointer vectors, size_t layerName, const std::string& classField, const int label, const std::vector<std::string>& excludedFields = {}); - void sampleToOGRFeatures(const ogr::DataSource::Pointer& vectors, + void SampleToOGRFeatures(const ogr::DataSource::Pointer& vectors, ogr::DataSource* output, const SampleVectorType& samples, const size_t layerName, const std::string& classField, int label, const std::vector<std::string>& excludedFields = {}); - std::set<size_t> getExcludedFieldsIds(const std::vector<std::string>& excludedFields, + std::set<size_t> GetExcludedFieldsIds(const std::vector<std::string>& excludedFields, const ogr::Layer& inputLayer); -bool isNumericField(const ogr::Feature& feature, const int idx); + bool IsNumericField(const ogr::Feature& feature, const int idx); -ogr::Feature selectTemplateFeature(const ogr::Layer& inputLayer, - const std::string& classField, int label); + ogr::Feature SelectTemplateFeature(const ogr::Layer& inputLayer, + const std::string& classField, int label); private: SampleAugmentationFilter(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx index 75895891ae..8976c1c55b 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx +++ b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx @@ -84,7 +84,7 @@ SampleAugmentationFilter OGRDataSourcePointerType inputDS = dynamic_cast<OGRDataSourceType*>(this->itk::ProcessObject::GetInput(0)); auto outputDS = static_cast<ogr::DataSource *>(this->itk::ProcessObject::GetOutput(0)); - auto inSamples = this->extractSamples(inputDS, m_Layer, + auto inSamples = this->ExtractSamples(inputDS, m_Layer, m_ClassFieldName, m_Label, m_ExcludedFields); @@ -93,13 +93,13 @@ SampleAugmentationFilter { case Strategy::Replicate: { - sampleAugmentation::replicateSamples(inSamples, m_NumberOfSamples, + sampleAugmentation::ReplicateSamples(inSamples, m_NumberOfSamples, newSamples); } break; case Strategy::Jitter: { - sampleAugmentation::jitterSamples(inSamples, m_NumberOfSamples, + sampleAugmentation::JitterSamples(inSamples, m_NumberOfSamples, newSamples, m_StdFactor, m_Seed); @@ -107,14 +107,14 @@ SampleAugmentationFilter break; case Strategy::Smote: { - sampleAugmentation::smote(inSamples, m_NumberOfSamples, + sampleAugmentation::Smote(inSamples, m_NumberOfSamples, newSamples, m_SmoteNeighbors, m_Seed); } break; } - this->sampleToOGRFeatures(inputDS, outputDS, newSamples, m_Layer, + this->SampleToOGRFeatures(inputDS, outputDS, newSamples, m_Layer, m_ClassFieldName, m_Label, m_ExcludedFields); @@ -128,7 +128,7 @@ SampleAugmentationFilter */ SampleAugmentationFilter::SampleVectorType SampleAugmentationFilter -::extractSamples(const ogr::DataSource::Pointer vectors, +::ExtractSamples(const ogr::DataSource::Pointer vectors, size_t layerName, const std::string& classField, const int label, const std::vector<std::string>& excludedFields) @@ -147,7 +147,7 @@ SampleAugmentationFilter } auto numberOfFields = (*featureIt).ogr().GetFieldCount(); - auto excludedIds = this->getExcludedFieldsIds(excludedFields, layer); + auto excludedIds = this->GetExcludedFieldsIds(excludedFields, layer); SampleVectorType samples; int sampleCount{0}; while( featureIt!=layer.end() ) @@ -160,7 +160,7 @@ SampleAugmentationFilter for(auto idx=0; idx<numberOfFields; ++idx) { if(excludedIds.find(idx) == excludedIds.cend() && - this->isNumericField((*featureIt), idx)) + this->IsNumericField((*featureIt), idx)) mv.push_back((*featureIt).ogr().GetFieldAsDouble(idx)); } samples.push_back(mv); @@ -178,7 +178,7 @@ SampleAugmentationFilter void SampleAugmentationFilter -::sampleToOGRFeatures(const ogr::DataSource::Pointer& vectors, +::SampleToOGRFeatures(const ogr::DataSource::Pointer& vectors, ogr::DataSource* output, const SampleAugmentationFilter::SampleVectorType& samples, const size_t layerName, @@ -187,7 +187,7 @@ SampleAugmentationFilter { auto inputLayer = vectors->GetLayer(layerName); - auto excludedIds = this->getExcludedFieldsIds(excludedFields, inputLayer); + auto excludedIds = this->GetExcludedFieldsIds(excludedFields, inputLayer); OGRSpatialReference * oSRS = nullptr; if (inputLayer.GetSpatialRef()) @@ -206,7 +206,7 @@ SampleAugmentationFilter } auto featureCount = outputLayer.GetFeatureCount(false); - auto templateFeature = this->selectTemplateFeature(inputLayer, classField, label); + auto templateFeature = this->SelectTemplateFeature(inputLayer, classField, label); for(const auto& sample : samples) { ogr::Feature dstFeature(outputLayer.GetLayerDefn()); @@ -216,7 +216,7 @@ SampleAugmentationFilter for (int k=0 ; k < layerDefn.GetFieldCount() ; k++) { if(excludedIds.find(k) == excludedIds.cend() && - this->isNumericField(dstFeature, k)) + this->IsNumericField(dstFeature, k)) { dstFeature.ogr().SetField(k, sample[sampleFieldCounter++]); } @@ -227,7 +227,7 @@ SampleAugmentationFilter std::set<size_t> SampleAugmentationFilter -::getExcludedFieldsIds(const std::vector<std::string>& excludedFields, +::GetExcludedFieldsIds(const std::vector<std::string>& excludedFields, const ogr::Layer& inputLayer) { auto feature = *(inputLayer).begin(); @@ -245,7 +245,7 @@ SampleAugmentationFilter bool SampleAugmentationFilter -::isNumericField(const ogr::Feature& feature, +::IsNumericField(const ogr::Feature& feature, const int idx) { OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(idx)->GetType(); @@ -256,7 +256,7 @@ SampleAugmentationFilter ogr::Feature SampleAugmentationFilter -::selectTemplateFeature(const ogr::Layer& inputLayer, +::SelectTemplateFeature(const ogr::Layer& inputLayer, const std::string& classField, int label) { auto wh = std::find_if(inputLayer.begin(), inputLayer.end(), -- GitLab From e30efff663db89ae480fe049cf28151fef440da7 Mon Sep 17 00:00:00 2001 From: remi cresson <remi.cresson@teledetection.fr> Date: Wed, 21 Mar 2018 14:41:06 +0000 Subject: [PATCH 494/567] FIX: enable box (extended parameter) in MPITiffTWriter --- .../include/otbSimpleParallelTiffWriter.txx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx index 96cbf7120c..336f399df8 100644 --- a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx +++ b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx @@ -458,6 +458,7 @@ SimpleParallelTiffWriter<TInputImage> */ inputPtr->UpdateOutputInformation(); InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion(); + typename InputImageType::PointType origin = inputPtr->GetOrigin(); /** Parse region size modes */ if(m_FilenameHelper->BoxIsSet()) @@ -497,6 +498,9 @@ SimpleParallelTiffWriter<TInputImage> throw e; } otbMsgDevMacro(<< "inputRegion " << inputRegion); + + // Update the origin + inputPtr->TransformIndexToPhysicalPoint(inputRegion.GetIndex(), origin); } // Get number of bands & pixel data type @@ -538,7 +542,7 @@ SimpleParallelTiffWriter<TInputImage> else { // When mode is not tiled (i.e. striped) - block_size_x = inputPtr->GetLargestPossibleRegion().GetSize()[0]; + block_size_x = inputRegion.GetSize()[0]; } // Master process (Rank 0) is responsible for the creation of the output raster. @@ -546,10 +550,10 @@ SimpleParallelTiffWriter<TInputImage> { // Set geotransform double geotransform[6]; - geotransform[0] = inputPtr->GetOrigin()[0] - 0.5*inputPtr->GetSignedSpacing()[0]; + geotransform[0] = origin[0] - 0.5*inputPtr->GetSignedSpacing()[0]; geotransform[1] = inputPtr->GetSignedSpacing()[0]; geotransform[2] = 0.0; - geotransform[3] = inputPtr->GetOrigin()[1] - 0.5*inputPtr->GetSignedSpacing()[1]; + geotransform[3] = origin[1] - 0.5*inputPtr->GetSignedSpacing()[1]; geotransform[4] = 0.0; geotransform[5] = inputPtr->GetSignedSpacing()[1]; @@ -557,8 +561,8 @@ SimpleParallelTiffWriter<TInputImage> if(!m_TiffTiledMode) { SPTW_ERROR sperr = sptw::create_raster(m_FileName, - inputPtr->GetLargestPossibleRegion().GetSize()[0], - inputPtr->GetLargestPossibleRegion().GetSize()[1], + inputRegion.GetSize()[0], + inputRegion.GetSize()[1], nBands, dataType, geotransform, @@ -573,8 +577,8 @@ SimpleParallelTiffWriter<TInputImage> else { SPTW_ERROR sperr = sptw::create_tiled_raster(m_FileName, - inputPtr->GetLargestPossibleRegion().GetSize()[0], - inputPtr->GetLargestPossibleRegion().GetSize()[1], + inputRegion.GetSize()[0], + inputRegion.GetSize()[1], nBands, dataType, geotransform, -- GitLab From 75663d12dced701f0e6f0c27b787604e199d066e Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 21 Mar 2018 18:29:14 +0100 Subject: [PATCH 495/567] TEST: missing file, comment the test for now --- Modules/Learning/LearningBase/test/CMakeLists.txt | 6 +++--- .../LearningBase/test/otbLearningBaseTestDriver.cxx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/Learning/LearningBase/test/CMakeLists.txt b/Modules/Learning/LearningBase/test/CMakeLists.txt index 48e28cc5ca..5c7bd7f85a 100644 --- a/Modules/Learning/LearningBase/test/CMakeLists.txt +++ b/Modules/Learning/LearningBase/test/CMakeLists.txt @@ -33,7 +33,7 @@ otbMachineLearningModelTemplates.cxx ) if(OTB_USE_SHARK) - set(OTBLearningBaseTests ${OTBLearningBaseTests} otbSharkUtilsTests.cxx) + #~ set(OTBLearningBaseTests ${OTBLearningBaseTests} otbSharkUtilsTests.cxx) endif() add_executable(otbLearningBaseTestDriver ${OTBLearningBaseTests}) @@ -73,6 +73,6 @@ otb_add_test(NAME leTuKMeansImageClassificationFilterNew COMMAND otbLearningBase otbKMeansImageClassificationFilterNew) if(OTB_USE_SHARK) - otb_add_test(NAME leTuSharkNormalizeLabels COMMAND otbLearningBaseTestDriver - otbSharkNormalizeLabels) + #~ otb_add_test(NAME leTuSharkNormalizeLabels COMMAND otbLearningBaseTestDriver + #~ otbSharkNormalizeLabels) endif() diff --git a/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx b/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx index dc2d36b794..5b8234d9d3 100644 --- a/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx +++ b/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx @@ -30,6 +30,6 @@ void RegisterTests() REGISTER_TEST(otbDecisionTreeNew); REGISTER_TEST(otbKMeansImageClassificationFilterNew); #ifdef OTB_USE_SHARK - REGISTER_TEST(otbSharkNormalizeLabels); + //~ REGISTER_TEST(otbSharkNormalizeLabels); #endif } -- GitLab From 745f8f6aef9a20c7365fdbc7f88e82dc1db9bfb5 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Wed, 21 Mar 2018 20:31:35 +0100 Subject: [PATCH 496/567] ADD: test for shark utils --- .../LearningBase/test/otbSharkUtilsTests.cxx | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Modules/Learning/LearningBase/test/otbSharkUtilsTests.cxx diff --git a/Modules/Learning/LearningBase/test/otbSharkUtilsTests.cxx b/Modules/Learning/LearningBase/test/otbSharkUtilsTests.cxx new file mode 100644 index 0000000000..bc3783cb72 --- /dev/null +++ b/Modules/Learning/LearningBase/test/otbSharkUtilsTests.cxx @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "itkMacro.h" +#include "otbSharkUtils.h" + + +int otbSharkNormalizeLabels(int itkNotUsed(argc), char* itkNotUsed(argv) []) +{ + std::vector<unsigned int> inLabels = {2, 2, 3, 20, 1}; + std::vector<unsigned int> expectedDictionary = {2, 3, 20, 1}; + std::vector<unsigned int> expectedLabels = {0, 0, 1, 2, 3}; + + auto newLabels = inLabels; + std::vector<unsigned int> labelDict; + otb::Shark::NormalizeLabelsAndGetDictionary(newLabels, labelDict); + + if(newLabels != expectedLabels) + { + std::cout << "Wrong new labels\n"; + for(size_t i = 0; i<newLabels.size(); ++i) + std::cout << "Got " << newLabels[i] << " expected " << expectedLabels[i] << '\n'; + + return EXIT_FAILURE; + } + + if(labelDict != expectedDictionary) + { + std::cout << "Wrong dictionary\n"; + for(size_t i = 0; i<labelDict.size(); ++i) + std::cout << "Got " << labelDict[i] << " expected " << expectedDictionary[i] << '\n'; + + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} -- GitLab From 923018c9804c3b4fef89c728d788892084d1d72c Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Wed, 21 Mar 2018 20:36:06 +0100 Subject: [PATCH 497/567] TEST: activate test after adding missing file --- Modules/Learning/LearningBase/test/CMakeLists.txt | 6 +++--- .../LearningBase/test/otbLearningBaseTestDriver.cxx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/Learning/LearningBase/test/CMakeLists.txt b/Modules/Learning/LearningBase/test/CMakeLists.txt index 5c7bd7f85a..48e28cc5ca 100644 --- a/Modules/Learning/LearningBase/test/CMakeLists.txt +++ b/Modules/Learning/LearningBase/test/CMakeLists.txt @@ -33,7 +33,7 @@ otbMachineLearningModelTemplates.cxx ) if(OTB_USE_SHARK) - #~ set(OTBLearningBaseTests ${OTBLearningBaseTests} otbSharkUtilsTests.cxx) + set(OTBLearningBaseTests ${OTBLearningBaseTests} otbSharkUtilsTests.cxx) endif() add_executable(otbLearningBaseTestDriver ${OTBLearningBaseTests}) @@ -73,6 +73,6 @@ otb_add_test(NAME leTuKMeansImageClassificationFilterNew COMMAND otbLearningBase otbKMeansImageClassificationFilterNew) if(OTB_USE_SHARK) - #~ otb_add_test(NAME leTuSharkNormalizeLabels COMMAND otbLearningBaseTestDriver - #~ otbSharkNormalizeLabels) + otb_add_test(NAME leTuSharkNormalizeLabels COMMAND otbLearningBaseTestDriver + otbSharkNormalizeLabels) endif() diff --git a/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx b/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx index 5b8234d9d3..dc2d36b794 100644 --- a/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx +++ b/Modules/Learning/LearningBase/test/otbLearningBaseTestDriver.cxx @@ -30,6 +30,6 @@ void RegisterTests() REGISTER_TEST(otbDecisionTreeNew); REGISTER_TEST(otbKMeansImageClassificationFilterNew); #ifdef OTB_USE_SHARK - //~ REGISTER_TEST(otbSharkNormalizeLabels); + REGISTER_TEST(otbSharkNormalizeLabels); #endif } -- GitLab From 06a7b1c277bed5cbc6a6ff63c325330767f35ee3 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 22 Mar 2018 10:06:30 +0100 Subject: [PATCH 498/567] REFAC: get rid of std::cout --- .../Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 485ff1a0dd..92bf408c70 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -545,7 +545,6 @@ void Application::FreeRessources() { itk::ProcessObject * current = processStack.top(); processStack.pop(); - std::cout<<current->GetNameOfClass()<<std::endl; // if null continue if ( !current ) continue; @@ -585,7 +584,6 @@ void Application::FreeRessources() // Release data for ( auto data : dataSet ) { - std::cout<<"one bulk is freed"<<std::endl; data->ReleaseData(); } // Call overrode method @@ -701,7 +699,6 @@ int Application::ExecuteAndWriteOutput() } std::ostringstream progressId; progressId << "Writing " << outputParam->GetFileName() << "..."; - std::cout<<"Add Process and write"<<std::endl; AddProcess(outputParam->GetWriter(), progressId.str()); outputParam->Write(); } -- GitLab From bb94305f87db931aa351c398fba2d1fc01651470 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 22 Mar 2018 10:41:27 +0100 Subject: [PATCH 499/567] REFAC: get rid of duplicate function and use for loop instead of while --- .../include/otbWrapperInputImageParameter.h | 5 ----- .../ApplicationEngine/src/otbWrapperApplication.cxx | 10 +++------- Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt | 1 + 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h index 29785f0789..29b9ac2866 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h @@ -109,11 +109,6 @@ public: void ClearValue() override; - ImageBaseType::Pointer GetPointer() - { - return m_Image; - } - protected: /** Constructor */ InputImageParameter(); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 92bf408c70..f1b87de858 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -416,7 +416,7 @@ Application::RegisterPipeline() dynamic_cast< InputImageParameter * >( param ); if ( !inP->HasValue() ) continue; - itk::ImageBase< 2 > * inData = inP->GetPointer(); + ImageBaseType * inData = inP->GetImage< ImageBaseType >(); if ( inData && !inputData.count(inData) ) inputData.insert(inData); } @@ -428,13 +428,11 @@ Application::RegisterPipeline() if ( !inP->HasValue() ) continue; const FloatVectorImageListType * list = inP->GetImageList(); - auto it = list->Begin(); - while ( it != list->End() ) + for ( auto it = list->Begin() ; it != list->End() ; ++it ) { FloatVectorImageType * inData = it.Get().GetPointer(); if ( inData && !inputData.count(inData) ) inputData.insert(inData); - ++it; } } else if ( GetParameterType(key) == ParameterType_InputVectorData ) @@ -456,13 +454,11 @@ Application::RegisterPipeline() if ( !inP->HasValue() ) continue; VectorDataListType * list = inP->GetVectorDataList(); - auto it = list->Begin(); - while ( it != list->End() ) + for ( auto it = list->Begin() ; it != list->End() ; ++it ) { VectorDataType * inData = it.Get().GetPointer(); if ( inData && !inputData.count(inData) ) inputData.insert(inData); - ++it; } } } diff --git a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt index 856191df14..e92b69dc03 100644 --- a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt @@ -190,6 +190,7 @@ otb_add_test(NAME owTuDocExampleStructureNew COMMAND otbApplicationEngineTestDri otbWrapperDocExampleStructureNew ) +# Warning this test require otbapp_Smoothing and otbapp_ConcatenateImages to be built otb_add_test(NAME owTvApplicationMemoryConnectTest COMMAND otbApplicationEngineTestDriver otbApplicationMemoryConnectTest $<TARGET_FILE_DIR:otbapp_Smoothing> ${INPUTDATA}/poupees.tif -- GitLab From 928adeaf02e5accce84a2e68032904e71723aec6 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 22 Mar 2018 11:17:38 +0100 Subject: [PATCH 500/567] BUG: #1534: support cases where input largest doesn't start at (0,0) --- .../IO/ImageIO/include/otbImageFileWriter.txx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index 87a0d50453..50384debf3 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -468,7 +468,6 @@ ImageFileWriter<TInputImage> */ inputPtr->UpdateOutputInformation(); InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion(); - typename TInputImage::PointType origin = inputPtr->GetOrigin(); /** Parse region size modes */ if(m_FilenameHelper->BoxIsSet()) @@ -485,9 +484,7 @@ ImageFileWriter<TInputImage> size[0] = boxVector[2]; // size along X size[1] = boxVector[3]; // size along Y inputRegion.SetSize(size); - - m_ShiftOutputIndex = start; - inputRegion.SetIndex(m_ShiftOutputIndex); + inputRegion.SetIndex(start); if (!inputRegion.Crop(inputPtr->GetLargestPossibleRegion())) { @@ -501,11 +498,9 @@ ImageFileWriter<TInputImage> e.SetDataObject(inputPtr); throw e; } - - inputPtr->TransformIndexToPhysicalPoint(inputRegion.GetIndex(), origin); - otbLogMacro(Info,<<"Writing user defined region ["<<start[0]<<", "<<start[0]+size[0]-1<<"]x["<<start[1]<<", "<<start[1]+size[1]<<"]"); } + m_ShiftOutputIndex = inputRegion.GetIndex(); /** * Determine of number of pieces to divide the input. This will be the @@ -544,6 +539,8 @@ ImageFileWriter<TInputImage> // // Setup the ImageIO with information from inputPtr // + typename TInputImage::PointType origin; + inputPtr->TransformIndexToPhysicalPoint(inputRegion.GetIndex(), origin); const typename TInputImage::SpacingType& spacing = inputPtr->GetSpacing(); const typename TInputImage::DirectionType& direction = inputPtr->GetDirection(); m_ImageIO->SetNumberOfDimensions(TInputImage::ImageDimension); @@ -665,7 +662,7 @@ ImageFileWriter<TInputImage> //Reset global shift on input region (box parameter) //It allows calling multiple update over the writer - m_ShiftOutputIndex.Fill(0); + m_ShiftOutputIndex = inputPtr->GetLargestPossibleRegion().GetIndex(); } @@ -721,10 +718,7 @@ ImageFileWriter<TInputImage> InputImageRegionType ioRegion; // No shift of the ioRegion from the buffered region is expected - typename InputImageRegionType::IndexType tmpIndex; - tmpIndex.Fill(0); itk::ImageIORegionAdaptor<TInputImage::ImageDimension>:: - //Convert(m_ImageIO->GetIORegion(), ioRegion, tmpIndex); Convert(m_ImageIO->GetIORegion(), ioRegion, m_ShiftOutputIndex); InputImageRegionType bufferedRegion = input->GetBufferedRegion(); -- GitLab From f7a85b0aa3ad9ad7b4759dc7262b3c440134dbfb Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 22 Mar 2018 14:30:39 +0100 Subject: [PATCH 501/567] COMP: missing Boost libs for linking on windows --- Modules/Learning/LearningBase/otb-module.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Learning/LearningBase/otb-module.cmake b/Modules/Learning/LearningBase/otb-module.cmake index 22ea02236a..c0af985032 100644 --- a/Modules/Learning/LearningBase/otb-module.cmake +++ b/Modules/Learning/LearningBase/otb-module.cmake @@ -32,6 +32,7 @@ otb_module(OTBLearningBase OTBShark TEST_DEPENDS + OTBBoost OTBTestKernel OTBImageIO -- GitLab From 31232585904d51841da9a69c15990ad74a5be8fe Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 22 Mar 2018 16:08:00 +0100 Subject: [PATCH 502/567] ENH: allow to set a new output image from a writer --- .../IO/ImageIO/include/otbMultiImageFileWriter.h | 14 ++++++++++++++ .../IO/ImageIO/include/otbMultiImageFileWriter.txx | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h index 6dac383dcf..0d2a1fc8af 100644 --- a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h @@ -131,6 +131,19 @@ public: this->SetNthInput(size - 1, const_cast<itk::DataObject*>(dynamic_cast<const itk::DataObject*>(inputPtr))); } + /** Add a new ImageFileWriter to the multi-writer. This is an alternative method + * when you already have an instanciated writer. + */ + template <class TWriter> + void AddInputWriter(const TWriter* writer) + { + Sink<typename TWriter::InputImageType > * sink = + new Sink<typename TWriter::InputImageType >(writer); + m_SinkList.push_back(SinkBase::Pointer(sink)); + unsigned int size = m_SinkList.size(); + this->SetNthInput(size - 1, const_cast<itk::DataObject*>(dynamic_cast<const itk::DataObject*>(writer->GetInput()))); + } + virtual void UpdateOutputInformation(); virtual void Update() @@ -242,6 +255,7 @@ private: Sink() {} Sink(typename TImage::ConstPointer inputImage, const std::string & filename); + Sink(typename otb::ImageFileWriter<TImage>::ConstPointer writer); virtual ~Sink() {} diff --git a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx index 01358fa4ea..5e6d6304dc 100644 --- a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.txx @@ -40,6 +40,14 @@ MultiImageFileWriter::Sink<TImage> m_Writer->SetInput(inputImage); } +template <class TImage> +MultiImageFileWriter::Sink<TImage> +::Sink(typename otb::ImageFileWriter<TImage>::ConstPointer writer): + SinkBase(dynamic_cast<const ImageBaseType*>(writer->GetInput()->GetPointer())), + m_Writer(writer), + m_ImageIO(NULL) +{ +} template <class TImage> bool -- GitLab From d3c8486f9a6d580407c2fbbf5c25432b8748d53a Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 22 Mar 2018 16:42:32 +0100 Subject: [PATCH 503/567] TEST: ordered vector of string to get the same output on every OS --- .../test/otbOGRExtendedFilenameToOptionsTest.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx index 45c39a2b23..63df6eeed0 100644 --- a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx +++ b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx @@ -19,9 +19,11 @@ */ #include "otbOGRExtendedFilenameToOptions.h" +#include <algorithm> #include <iostream> #include <fstream> + using namespace otb; @@ -81,11 +83,12 @@ int otbOGRExtendedFileName(int , char* argv[]) file << layerHelper->HasGDALLayerOption() << std::endl; file << "Layer option from layer helper:"<<std::endl; FilenameHelperType::GDALOptionType latestOptions = layerHelper->GetGDALOptions("layer"); - for ( auto option : latestOptions ) + // need to sort for dummy windows + std::sort( latestOptions.begin() , latestOptions.end() ); + for ( auto option : latestOptions ) { file<< option << std::endl; } - // test file.close(); return EXIT_SUCCESS; -- GitLab From 01bf91b7d30c2ef418084253190c10a19d2d99c6 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Fri, 23 Mar 2018 11:05:23 +0100 Subject: [PATCH 504/567] REFAC: change name of class ObjectListInterface to DataObjectListInterface --- ...tInterface.h => otbDataObjectListInterface.h} | 16 ++++++++-------- Modules/Core/ObjectList/include/otbObjectList.h | 4 ++-- .../src/otbWrapperApplication.cxx | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) rename Modules/Core/ObjectList/include/{otbObjectListInterface.h => otbDataObjectListInterface.h} (78%) diff --git a/Modules/Core/ObjectList/include/otbObjectListInterface.h b/Modules/Core/ObjectList/include/otbDataObjectListInterface.h similarity index 78% rename from Modules/Core/ObjectList/include/otbObjectListInterface.h rename to Modules/Core/ObjectList/include/otbDataObjectListInterface.h index ce907a03d8..8cfb50cb71 100644 --- a/Modules/Core/ObjectList/include/otbObjectListInterface.h +++ b/Modules/Core/ObjectList/include/otbDataObjectListInterface.h @@ -18,24 +18,24 @@ * limitations under the License. */ -#ifndef otbObjectListInterface_h -#define otbObjectListInterface_h +#ifndef otbDataObjectListInterface_h +#define otbDataObjectListInterface_h #include "itkDataObject.h" -#include "boost/core/noncopyable.hpp" +#include <boost/noncopyable.hpp> namespace otb { -class ObjectListInterface : private boost::noncopyable +class DataObjectListInterface : private boost::noncopyable { -/** \class ObjectListInterface +/** \class DataObjectListInterface * \brief This non template class is an interface that wrapp ObjectList * * New method that do not need the template parameter of ObjectList * should be declare here. * - * \ingroup ObjectListInterface + * \ingroup DataObjectListInterface */ public: /** @@ -46,8 +46,8 @@ public: virtual std::size_t Size(void) const = 0; protected: - ObjectListInterface() = default ; - virtual ~ObjectListInterface() = default ; + DataObjectListInterface() = default ; + virtual ~DataObjectListInterface() = default ; }; } // end of otb namespace diff --git a/Modules/Core/ObjectList/include/otbObjectList.h b/Modules/Core/ObjectList/include/otbObjectList.h index 879024ffb0..2f14d80117 100644 --- a/Modules/Core/ObjectList/include/otbObjectList.h +++ b/Modules/Core/ObjectList/include/otbObjectList.h @@ -23,7 +23,7 @@ #include <vector> #include "itkDataObject.h" -#include "otbObjectListInterface.h" +#include "otbDataObjectListInterface.h" #include "itkObjectFactory.h" namespace otb @@ -37,7 +37,7 @@ namespace otb * \ingroup OTBObjectList */ template <class TObject> -class ITK_EXPORT ObjectList : public itk::DataObject , public ObjectListInterface +class ITK_EXPORT ObjectList : public itk::DataObject , public DataObjectListInterface { public: /** Standard typedefs */ diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index f1b87de858..2580e59de5 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -472,10 +472,10 @@ Application::RegisterPipeline() if ( !current || inputData.count( current ) ) continue; // if current is a list push every of its members in datastack - if ( dynamic_cast< ObjectListInterface *> (current) ) + if ( dynamic_cast< DataObjectListInterface *> (current) ) { - ObjectListInterface * list = - dynamic_cast< ObjectListInterface *> (current); + DataObjectListInterface * list = + dynamic_cast< DataObjectListInterface *> (current); int length = list->Size(); for ( int i = 0 ; i < length ; i++ ) { @@ -552,10 +552,10 @@ void Application::FreeRessources() if ( !data.GetPointer() || dataSet.count( data.GetPointer() ) ) continue; // If input is a list - if ( dynamic_cast< ObjectListInterface *> (data.GetPointer()) ) + if ( dynamic_cast< DataObjectListInterface *> (data.GetPointer()) ) { - ObjectListInterface * list = - dynamic_cast< ObjectListInterface *> (data.GetPointer()); + DataObjectListInterface * list = + dynamic_cast< DataObjectListInterface *> (data.GetPointer()); int length = list->Size(); for ( int i = 0 ; i < length ; i++ ) { -- GitLab From 80d384e1a8d78b68ad645cb7b37ce219d475e90f Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Fri, 23 Mar 2018 13:07:29 +0100 Subject: [PATCH 505/567] BUG: HoughTransform GetLines parameter (n) is obsolete in ITK 4.13, use new API instead --- Modules/Feature/Edge/include/otbLocalHoughFilter.txx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Feature/Edge/include/otbLocalHoughFilter.txx b/Modules/Feature/Edge/include/otbLocalHoughFilter.txx index a3b0d6e6be..d93835e676 100644 --- a/Modules/Feature/Edge/include/otbLocalHoughFilter.txx +++ b/Modules/Feature/Edge/include/otbLocalHoughFilter.txx @@ -229,7 +229,7 @@ LocalHoughFilter<TInputImage> // Get the list of LineSpatialObject lines // --------------------------------------- - lines = houghFilter->GetLines(m_NumberOfLines); + lines = houghFilter->GetLines(); LineIterator itLines = lines.begin(); -- GitLab From 7c8450276a5779245d17d434de2474f71eaf7a59 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 23 Mar 2018 13:56:27 +0100 Subject: [PATCH 506/567] ENH: OutputImageParameter refactored with fewer dynamic_cast --- .../include/otbWrapperOutputImageParameter.h | 56 +-- .../src/otbWrapperApplication.cxx | 2 +- .../src/otbWrapperOutputImageParameter.cxx | 475 +++++++----------- 3 files changed, 193 insertions(+), 340 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index b9bc451c3b..eac7df4cad 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -117,14 +117,8 @@ protected: /** Destructor */ ~OutputImageParameter() override; - template <class TInputVectorImageType> - void SwitchVectorImageWrite(); - - template <class TInputVectorImageType> - void SwitchRGBImageWrite(); - - template <class TInputVectorImageType> - void SwitchRGBAImageWrite(); + template <class TInput> + int SwitchInput(TInput *img); //FloatVectorImageType::Pointer m_Image; ImageBaseType::Pointer m_Image; @@ -132,46 +126,28 @@ protected: ImagePixelType m_PixelType; ImagePixelType m_DefaultPixelType; - typedef otb::ImageFileWriter<UInt8VectorImageType> VectorUInt8WriterType; - typedef otb::ImageFileWriter<Int16VectorImageType> VectorInt16WriterType; - typedef otb::ImageFileWriter<UInt16VectorImageType> VectorUInt16WriterType; - typedef otb::ImageFileWriter<Int32VectorImageType> VectorInt32WriterType; - typedef otb::ImageFileWriter<UInt32VectorImageType> VectorUInt32WriterType; - typedef otb::ImageFileWriter<FloatVectorImageType> VectorFloatWriterType; - typedef otb::ImageFileWriter<DoubleVectorImageType> VectorDoubleWriterType; - - typedef otb::ImageFileWriter<UInt8RGBAImageType> RGBAUInt8WriterType; - typedef otb::ImageFileWriter<UInt8RGBImageType> RGBUInt8WriterType; - - typedef otb::ImageFileWriter<ComplexInt16VectorImageType> ComplexVectorInt16WriterType; - typedef otb::ImageFileWriter<ComplexInt32VectorImageType> ComplexVectorInt32WriterType; - typedef otb::ImageFileWriter<ComplexFloatVectorImageType> ComplexVectorFloatWriterType; - typedef otb::ImageFileWriter<ComplexDoubleVectorImageType> ComplexVectorDoubleWriterType; - - VectorUInt8WriterType::Pointer m_VectorUInt8Writer; - VectorInt16WriterType::Pointer m_VectorInt16Writer; - VectorUInt16WriterType::Pointer m_VectorUInt16Writer; - VectorInt32WriterType::Pointer m_VectorInt32Writer; - VectorUInt32WriterType::Pointer m_VectorUInt32Writer; - VectorFloatWriterType::Pointer m_VectorFloatWriter; - VectorDoubleWriterType::Pointer m_VectorDoubleWriter; - - RGBUInt8WriterType::Pointer m_RGBUInt8Writer; - RGBAUInt8WriterType::Pointer m_RGBAUInt8Writer; - - ComplexVectorInt16WriterType::Pointer m_ComplexVectorInt16Writer; - ComplexVectorInt32WriterType::Pointer m_ComplexVectorInt32Writer; - ComplexVectorFloatWriterType::Pointer m_ComplexVectorFloatWriter; - ComplexVectorDoubleWriterType::Pointer m_ComplexVectorDoubleWriter; - private: OutputImageParameter(const Parameter &); //purposely not implemented void operator =(const Parameter&); //purposely not implemented unsigned int m_RAMValue; + itk::ProcessObject::Pointer m_Caster; + + itk::ProcessObject::Pointer m_Writer; + }; // End class OutputImage Parameter +// Declare specialisation for UInt8RGBAImageType +template <> +int +OutputImageParameter::SwitchInput(UInt8RGBAImageType *img); + +// Declare specialisation for UInt8RGBImageType +template <> +int +OutputImageParameter::SwitchInput(UInt8RGBImageType *img); + } // End namespace Wrapper } // End namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 5f20a11ace..30f22786b8 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -477,7 +477,6 @@ int Application::ExecuteAndWriteOutput() if(outputParam!=ITK_NULLPTR) { - outputParam->InitializeWriters(); std::string checkReturn = outputParam->CheckFileName(true); if (!checkReturn.empty()) { @@ -487,6 +486,7 @@ int Application::ExecuteAndWriteOutput() { outputParam->SetRAMValue(ram); } + outputParam->InitializeWriters(); std::ostringstream progressId; progressId << "Writing " << outputParam->GetFileName() << "..."; AddProcess(outputParam->GetWriter(), progressId.str()); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index 32b0cfaa49..a5a9401d21 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -42,7 +42,9 @@ namespace Wrapper OutputImageParameter::OutputImageParameter() : m_PixelType(ImagePixelType_float), m_DefaultPixelType(ImagePixelType_float), - m_RAMValue(0) + m_RAMValue(0), + m_Caster(nullptr), + m_Writer(nullptr) { this->SetName("Output Image"); this->SetKey("out"); @@ -149,35 +151,102 @@ OutputImageParameter::ConvertStringToPixelType(const std::string &value, ImagePi void OutputImageParameter::InitializeWriters() { - m_VectorUInt8Writer = VectorUInt8WriterType::New(); - m_VectorInt16Writer = VectorInt16WriterType::New(); - m_VectorUInt16Writer = VectorUInt16WriterType::New(); - m_VectorInt32Writer = VectorInt32WriterType::New(); - m_VectorUInt32Writer = VectorUInt32WriterType::New(); - m_VectorFloatWriter = VectorFloatWriterType::New(); - m_VectorDoubleWriter = VectorDoubleWriterType::New(); - - m_RGBUInt8Writer = RGBUInt8WriterType::New(); - m_RGBAUInt8Writer = RGBAUInt8WriterType::New(); - - m_ComplexVectorInt16Writer = ComplexVectorInt16WriterType::New(); - m_ComplexVectorInt32Writer = ComplexVectorInt32WriterType::New(); - m_ComplexVectorFloatWriter = ComplexVectorFloatWriterType::New(); - m_ComplexVectorDoubleWriter = ComplexVectorDoubleWriterType::New(); + ImageBaseType* imgBase = m_Image.GetPointer(); + // Guess the image type + std::string className(m_Image->GetNameOfClass()); + if (className == "VectorImage") + { + UInt8VectorImageType* imgUInt8 = dynamic_cast<UInt8VectorImageType*>(imgBase); + if (imgUInt8 && SwitchInput(imgUInt8)) return; + + Int16VectorImageType* imgInt16 = dynamic_cast<Int16VectorImageType*>(imgBase); + if (imgInt16 && SwitchInput(imgInt16)) return; + + UInt16VectorImageType* imgUInt16 = dynamic_cast<UInt16VectorImageType*>(imgBase); + if (imgUInt16 && SwitchInput(imgUInt16)) return; + + Int32VectorImageType* imgInt32 = dynamic_cast<Int32VectorImageType*>(imgBase); + if (imgInt32 && SwitchInput(imgInt32)) return; + + UInt32VectorImageType* imgUInt32 = dynamic_cast<UInt32VectorImageType*>(imgBase); + if (imgUInt32 && SwitchInput(imgUInt32)) return; + + FloatVectorImageType* imgFloat = dynamic_cast<FloatVectorImageType*>(imgBase); + if (imgFloat && SwitchInput(imgFloat)) return; + + DoubleVectorImageType* imgDouble = dynamic_cast<DoubleVectorImageType*>(imgBase); + if (imgDouble && SwitchInput(imgDouble)) return; + + ComplexInt16VectorImageType* imgCInt16 = dynamic_cast<ComplexInt16VectorImageType*>(imgBase); + if (imgCInt16 && SwitchInput(imgCInt16)) return; + + ComplexInt32VectorImageType* imgCInt32 = dynamic_cast<ComplexInt32VectorImageType*>(imgBase); + if (imgCInt32 && SwitchInput(imgCInt32)) return; + + ComplexFloatVectorImageType* imgCFloat = dynamic_cast<ComplexFloatVectorImageType*>(imgBase); + if (imgCFloat && SwitchInput(imgCFloat)) return; + + ComplexDoubleVectorImageType* imgCDouble = dynamic_cast<ComplexDoubleVectorImageType*>(imgBase); + if (imgCDouble && SwitchInput(imgCDouble)) return; + } + else + { + UInt8ImageType* imgUInt8 = dynamic_cast<UInt8ImageType*>(imgBase); + if (imgUInt8 && SwitchInput(imgUInt8)) return; + + Int16ImageType* imgInt16 = dynamic_cast<Int16ImageType*>(imgBase); + if (imgInt16 && SwitchInput(imgInt16)) return; + + UInt16ImageType* imgUInt16 = dynamic_cast<UInt16ImageType*>(imgBase); + if (imgUInt16 && SwitchInput(imgUInt16)) return; + + Int32ImageType* imgInt32 = dynamic_cast<Int32ImageType*>(imgBase); + if (imgInt32 && SwitchInput(imgInt32)) return; + + UInt32ImageType* imgUInt32 = dynamic_cast<UInt32ImageType*>(imgBase); + if (imgUInt32 && SwitchInput(imgUInt32)) return; + + FloatImageType* imgFloat = dynamic_cast<FloatImageType*>(imgBase); + if (imgFloat && SwitchInput(imgFloat)) return; + + DoubleImageType* imgDouble = dynamic_cast<DoubleImageType*>(imgBase); + if (imgDouble && SwitchInput(imgDouble)) return; + + ComplexInt16ImageType* imgCInt16 = dynamic_cast<ComplexInt16ImageType*>(imgBase); + if (imgCInt16 && SwitchInput(imgCInt16)) return; + + ComplexInt32ImageType* imgCInt32 = dynamic_cast<ComplexInt32ImageType*>(imgBase); + if (imgCInt32 && SwitchInput(imgCInt32)) return; + + ComplexFloatImageType* imgCFloat = dynamic_cast<ComplexFloatImageType*>(imgBase); + if (imgCFloat && SwitchInput(imgCFloat)) return; + + ComplexDoubleImageType* imgCDouble = dynamic_cast<ComplexDoubleImageType*>(imgBase); + if (imgCDouble && SwitchInput(imgCDouble)) return; + + UInt8RGBImageType* imgRGB = dynamic_cast<UInt8RGBImageType*>(imgBase); + if (imgRGB && SwitchInput(imgRGB)) return; + + UInt8RGBAImageType* imgRGBA = dynamic_cast<UInt8RGBAImageType*>(imgBase); + if (imgRGBA && SwitchInput(imgRGBA)) return; + } + + itkExceptionMacro("Unknown image type"); } template <typename TInput, typename TOutput> -void -ClampAndWriteVectorImage( itk::ImageBase<2> * in , - otb::ImageFileWriter<TOutput> * writer , +std::pair<itk::ProcessObject::Pointer,itk::ProcessObject::Pointer> +ClampAndWriteVectorImage( TInput * in , const std::string & filename , const unsigned int & ramValue ) { + std::pair<itk::ProcessObject::Pointer,itk::ProcessObject::Pointer> ret; typedef ClampImageFilter < TInput , TOutput > ClampFilterType; typename ClampFilterType::Pointer clampFilter ( ClampFilterType::New() ); - clampFilter->SetInput( dynamic_cast<TInput*>(in)); + clampFilter->SetInput( in); + ret.first = clampFilter.GetPointer(); bool useStandardWriter = true; @@ -195,7 +264,8 @@ ClampAndWriteVectorImage( itk::ImageBase<2> * in , if(extension == ".vrt") { // Use the WriteMPI function - WriteMPI(clampFilter->GetOutput(),filename,ramValue); + // TODO : create a dedicated filter + //~ WriteMPI(clampFilter->GetOutput(),filename,ramValue); } #ifdef OTB_USE_SPTW else if (extension == ".tif") @@ -207,7 +277,7 @@ ClampAndWriteVectorImage( itk::ImageBase<2> * in , sptWriter->SetFileName(filename); sptWriter->SetInput(clampFilter->GetOutput()); sptWriter->SetAutomaticAdaptativeStreaming(ramValue); - sptWriter->Update(); + ret.second = sptWriter.GetPointer(); } #endif @@ -222,115 +292,110 @@ ClampAndWriteVectorImage( itk::ImageBase<2> * in , if(useStandardWriter) { - + typename otb::ImageFileWriter<TOutput>::Pointer writer = + otb::ImageFileWriter<TOutput>::New(); writer->SetFileName( filename ); writer->SetInput(clampFilter->GetOutput()); writer->SetAutomaticAdaptativeStreaming(ramValue); - writer->Update(); + ret.second = writer.GetPointer(); } + + return ret; } template <class TInput> -void -OutputImageParameter::SwitchVectorImageWrite() - { +int +OutputImageParameter::SwitchInput(TInput *img) +{ + if (! img) return 0; + + std::pair<itk::ProcessObject::Pointer,itk::ProcessObject::Pointer> ret; switch(m_PixelType ) { case ImagePixelType_uint8: { - ClampAndWriteVectorImage< TInput , UInt8VectorImageType > ( - m_Image , - m_VectorUInt8Writer , + ret = ClampAndWriteVectorImage< TInput , UInt8VectorImageType > ( + img , m_FileName , m_RAMValue ); break; } case ImagePixelType_int16: { - ClampAndWriteVectorImage< TInput , Int16VectorImageType > ( - m_Image , - m_VectorInt16Writer , + ret = ClampAndWriteVectorImage< TInput , Int16VectorImageType > ( + img , m_FileName , m_RAMValue ); break; } case ImagePixelType_uint16: { - ClampAndWriteVectorImage< TInput , UInt16VectorImageType > ( - m_Image , - m_VectorUInt16Writer , + ret = ClampAndWriteVectorImage< TInput , UInt16VectorImageType > ( + img , m_FileName , m_RAMValue ); break; } case ImagePixelType_int32: { - ClampAndWriteVectorImage< TInput , Int32VectorImageType > ( - m_Image , - m_VectorInt32Writer , + ret = ClampAndWriteVectorImage< TInput , Int32VectorImageType > ( + img , m_FileName , m_RAMValue ); break; } case ImagePixelType_uint32: { - ClampAndWriteVectorImage< TInput , UInt32VectorImageType > ( - m_Image , - m_VectorUInt32Writer , + ret = ClampAndWriteVectorImage< TInput , UInt32VectorImageType > ( + img , m_FileName , m_RAMValue ); break; } case ImagePixelType_float: { - ClampAndWriteVectorImage< TInput , FloatVectorImageType > ( - m_Image , - m_VectorFloatWriter , + ret = ClampAndWriteVectorImage< TInput , FloatVectorImageType > ( + img , m_FileName , m_RAMValue ); break; } case ImagePixelType_double: { - ClampAndWriteVectorImage< TInput , DoubleVectorImageType > ( - m_Image , - m_VectorDoubleWriter , + ret = ClampAndWriteVectorImage< TInput , DoubleVectorImageType > ( + img , m_FileName , m_RAMValue ); break; } case ImagePixelType_cint16: { - ClampAndWriteVectorImage < TInput , ComplexInt16VectorImageType > ( - m_Image , - m_ComplexVectorInt16Writer , + ret = ClampAndWriteVectorImage < TInput , ComplexInt16VectorImageType > ( + img , m_FileName , m_RAMValue ); break; } case ImagePixelType_cint32: { - ClampAndWriteVectorImage < TInput , ComplexInt32VectorImageType > ( - m_Image , - m_ComplexVectorInt32Writer , + ret = ClampAndWriteVectorImage < TInput , ComplexInt32VectorImageType > ( + img , m_FileName , m_RAMValue ); break; } case ImagePixelType_cfloat: { - ClampAndWriteVectorImage < TInput , ComplexFloatVectorImageType > ( - m_Image , - m_ComplexVectorFloatWriter , + ret = ClampAndWriteVectorImage < TInput , ComplexFloatVectorImageType > ( + img , m_FileName , m_RAMValue ); break; } case ImagePixelType_cdouble: { - ClampAndWriteVectorImage < TInput , ComplexDoubleVectorImageType > ( - m_Image , - m_ComplexVectorDoubleWriter , + ret = ClampAndWriteVectorImage < TInput , ComplexDoubleVectorImageType > ( + img , m_FileName , m_RAMValue ); break; @@ -338,256 +403,28 @@ OutputImageParameter::SwitchVectorImageWrite() default: break; } - } - -template <class TInputRGBAImageType> -void -OutputImageParameter::SwitchRGBAImageWrite() - { - if( m_PixelType == ImagePixelType_uint8 ) - { - m_RGBAUInt8Writer->SetFileName( this->GetFileName() ); - m_RGBAUInt8Writer->SetInput(dynamic_cast<UInt8RGBAImageType*>(m_Image.GetPointer()) ); - m_RGBAUInt8Writer->SetAutomaticAdaptativeStreaming(m_RAMValue); - m_RGBAUInt8Writer->Update(); - } - else - itkExceptionMacro("Unknown PixelType for RGBA Image. Only uint8 is supported."); - } + // Save the caster and writer + m_Caster = ret.first; + m_Writer = ret.second; + return 1; +} -template <class TInputRGBImageType> -void -OutputImageParameter::SwitchRGBImageWrite() - { - if( m_PixelType == ImagePixelType_uint8 ) - { - m_RGBUInt8Writer->SetFileName( this->GetFileName() ); - m_RGBUInt8Writer->SetInput(dynamic_cast<UInt8RGBImageType*>(m_Image.GetPointer()) ); - m_RGBUInt8Writer->SetAutomaticAdaptativeStreaming(m_RAMValue); - m_RGBUInt8Writer->Update(); - } - else - itkExceptionMacro("Unknown PixelType for RGB Image. Only uint8 is supported."); - } void OutputImageParameter::Write() { - m_Image->UpdateOutputInformation(); + m_Writer->Update(); - if (dynamic_cast<UInt8ImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<UInt8ImageType>(); - } - else if (dynamic_cast<Int16ImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<Int16ImageType>(); - } - else if (dynamic_cast<UInt16ImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<UInt16ImageType>(); - } - else if (dynamic_cast<Int32ImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<Int32ImageType>(); - } - else if (dynamic_cast<UInt32ImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<UInt32ImageType>(); - } - else if (dynamic_cast<FloatImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<FloatImageType>(); - } - else if (dynamic_cast<DoubleImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<DoubleImageType>(); - } - else if (dynamic_cast<ComplexInt16ImageType*>(m_Image.GetPointer()) ) - { - SwitchVectorImageWrite<ComplexInt16ImageType>(); - } - else if (dynamic_cast<ComplexInt32ImageType*>(m_Image.GetPointer()) ) - { - SwitchVectorImageWrite<ComplexInt32ImageType>(); - } - else if (dynamic_cast<ComplexFloatImageType*>(m_Image.GetPointer()) ) - { - SwitchVectorImageWrite<ComplexFloatImageType>(); - } - else if (dynamic_cast<ComplexDoubleImageType*>(m_Image.GetPointer()) ) - { - SwitchVectorImageWrite<ComplexDoubleImageType>(); - } - else if (dynamic_cast<UInt8VectorImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<UInt8VectorImageType>(); - } - else if (dynamic_cast<Int16VectorImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<Int16VectorImageType>(); - } - else if (dynamic_cast<UInt16VectorImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<UInt16VectorImageType>(); - } - else if (dynamic_cast<Int32VectorImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<Int32VectorImageType>(); - } - else if (dynamic_cast<UInt32VectorImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<UInt32VectorImageType>(); - } - else if (dynamic_cast<FloatVectorImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<FloatVectorImageType>(); - } - else if (dynamic_cast<DoubleVectorImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<DoubleVectorImageType>(); - } - else if (dynamic_cast<ComplexInt16VectorImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<ComplexInt16VectorImageType>(); - } - else if (dynamic_cast<ComplexInt32VectorImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<ComplexInt32VectorImageType>(); - } - else if (dynamic_cast<ComplexFloatVectorImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<ComplexFloatVectorImageType>(); - } - else if (dynamic_cast<ComplexDoubleVectorImageType*>(m_Image.GetPointer())) - { - SwitchVectorImageWrite<ComplexDoubleVectorImageType>(); - } - else if (dynamic_cast<UInt8RGBImageType*>(m_Image.GetPointer())) - { - SwitchRGBImageWrite<UInt8RGBImageType>(); - } - else if (dynamic_cast<UInt8RGBAImageType*>(m_Image.GetPointer())) - { - SwitchRGBAImageWrite<UInt8RGBAImageType>(); - } - else - { - itkExceptionMacro("Unknown image type"); - } - } + // Clean internal filters + m_Caster = nullptr; + m_Writer = nullptr; +} itk::ProcessObject* OutputImageParameter::GetWriter() { - int type = 1; - // 0 : image - // 1 : VectorImage - // 2 : RGBAImage - // 3 : RGBImage - itk::ProcessObject* writer = ITK_NULLPTR; - - if (dynamic_cast<UInt8RGBAImageType*> (m_Image.GetPointer())) - { - type = 2; - writer = m_RGBAUInt8Writer; - itkWarningMacro("UInt8RGBAImageType will be saved in UInt8 format."); - return writer; - } - else if (dynamic_cast<UInt8RGBImageType*> (m_Image.GetPointer())) - { - type = 3; - writer = m_RGBUInt8Writer; - itkWarningMacro("UInt8RGBImageType will be saved in UInt8 format."); - return writer; - } - - switch (GetPixelType()) - { - case ImagePixelType_uint8: - { - switch(type) - { - case 1: - writer = m_VectorUInt8Writer; - break; - case 2: - writer = m_RGBAUInt8Writer; - break; - default: - writer = m_RGBUInt8Writer; - break; - } - break; - } - case ImagePixelType_int16: - { - if (type == 1) - writer = m_VectorInt16Writer; - break; - } - case ImagePixelType_uint16: - { - if (type == 1) - writer = m_VectorUInt16Writer; - break; - } - case ImagePixelType_int32: - { - if (type == 1) - writer = m_VectorInt32Writer; - break; - } - case ImagePixelType_uint32: - { - if (type == 1) - writer = m_VectorUInt32Writer; - break; - } - case ImagePixelType_float: - { - if (type == 1) - writer = m_VectorFloatWriter; - break; - } - case ImagePixelType_double: - { - if (type == 1) - writer = m_VectorDoubleWriter; - break; - } - case ImagePixelType_cint16: - { - if( type == 1 ) - writer = m_ComplexVectorInt16Writer; - break; - } - case ImagePixelType_cint32: - { - if( type == 1 ) - writer = m_ComplexVectorInt32Writer; - break; - } - case ImagePixelType_cfloat: - { - if( type == 1 ) - writer = m_ComplexVectorFloatWriter; - break; - } - case ImagePixelType_cdouble: - { - if( type == 1 ) - writer = m_ComplexVectorDoubleWriter; - break; - } - } - if (ITK_NULLPTR == writer) - { - itkExceptionMacro("Unknown Writer type."); - } - - return writer; + return m_Writer; } ImageBaseType* @@ -651,5 +488,45 @@ OutputImageParameter::CheckFileName(bool fixMissingExtension) return ret; } +// Specialization for UInt8RGBAImageType +template <> +int +OutputImageParameter::SwitchInput(UInt8RGBAImageType *img) +{ + if (! img) return 0; + if( m_PixelType == ImagePixelType_uint8 ) + { + typename otb::ImageFileWriter<UInt8RGBAImageType>::Pointer writer = + otb::ImageFileWriter<UInt8RGBAImageType>::New(); + writer->SetFileName( this->GetFileName() ); + writer->SetInput(img); + writer->SetAutomaticAdaptativeStreaming(m_RAMValue); + m_Writer = writer.GetPointer(); + } + else + itkExceptionMacro("Unknown PixelType for RGBA Image. Only uint8 is supported."); + return 1; +} + +// Specialization for UInt8RGBImageType +template <> +int +OutputImageParameter::SwitchInput(UInt8RGBImageType *img) +{ + if (! img) return 0; + if( m_PixelType == ImagePixelType_uint8 ) + { + typename otb::ImageFileWriter<UInt8RGBImageType>::Pointer writer = + otb::ImageFileWriter<UInt8RGBImageType>::New(); + writer->SetFileName( this->GetFileName() ); + writer->SetInput(img); + writer->SetAutomaticAdaptativeStreaming(m_RAMValue); + m_Writer = writer.GetPointer(); + } + else + itkExceptionMacro("Unknown PixelType for RGB Image. Only uint8 is supported."); + return 1; +} + } } -- GitLab From f395da16d983ec33655f527508ab5c74261dbe54 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Fri, 23 Mar 2018 16:25:35 +0100 Subject: [PATCH 507/567] ENH: use ITK_LEGACY_REMOVE macro to maintain backward compatibility with previous itk version --- Modules/Feature/Edge/include/otbLocalHoughFilter.txx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/Feature/Edge/include/otbLocalHoughFilter.txx b/Modules/Feature/Edge/include/otbLocalHoughFilter.txx index d93835e676..b6a21b20f2 100644 --- a/Modules/Feature/Edge/include/otbLocalHoughFilter.txx +++ b/Modules/Feature/Edge/include/otbLocalHoughFilter.txx @@ -229,7 +229,11 @@ LocalHoughFilter<TInputImage> // Get the list of LineSpatialObject lines // --------------------------------------- + #if !defined(ITK_LEGACY_REMOVE) + lines = houghFilter->GetLines(m_NumberOfLines); + #else lines = houghFilter->GetLines(); + #endif LineIterator itLines = lines.begin(); -- GitLab From a4abbe2ac74a2adf34e5bc231dbe3415dce365f0 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Mon, 26 Mar 2018 08:19:16 +0200 Subject: [PATCH 508/567] DOC: correct in group doxygen tag --- Modules/Core/ObjectList/include/otbDataObjectListInterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/ObjectList/include/otbDataObjectListInterface.h b/Modules/Core/ObjectList/include/otbDataObjectListInterface.h index 8cfb50cb71..c1a1ac722f 100644 --- a/Modules/Core/ObjectList/include/otbDataObjectListInterface.h +++ b/Modules/Core/ObjectList/include/otbDataObjectListInterface.h @@ -35,7 +35,7 @@ class DataObjectListInterface : private boost::noncopyable * New method that do not need the template parameter of ObjectList * should be declare here. * - * \ingroup DataObjectListInterface + * \ingroup OTBObjectList */ public: /** -- GitLab From 5a8c649e0153e065b49fec2e6aa2aa8397b462a5 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 26 Mar 2018 09:19:43 +0200 Subject: [PATCH 509/567] BUG: update Shark version for serialization error --- SuperBuild/CMake/External_shark.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SuperBuild/CMake/External_shark.cmake b/SuperBuild/CMake/External_shark.cmake index 547eb6ce37..5a3c6d0a74 100644 --- a/SuperBuild/CMake/External_shark.cmake +++ b/SuperBuild/CMake/External_shark.cmake @@ -30,8 +30,8 @@ ADD_SUPERBUILD_CMAKE_VAR(SHARK BOOST_LIBRARYDIR) ExternalProject_Add(SHARK PREFIX SHARK - URL "https://github.com/Shark-ML/Shark/archive/75eac83266e3713e00af2d1ca1264fc6e44322b8.zip" - URL_MD5 bfbdf1fe8e0563dbf8af87da9419dc0f + URL "https://github.com/Shark-ML/Shark/archive/a48155fb9ce2f01b33d958ec6a3aaf115f330fbf.zip" + URL_MD5 a43fb09673b7a99f83b4bcf88dc5a109 SOURCE_DIR ${SHARK_SB_SRC} BINARY_DIR ${SHARK_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} -- GitLab From 112206feb2d2d05fd4de276dad4c71f7ae5c80a0 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Mon, 26 Mar 2018 09:20:05 +0200 Subject: [PATCH 510/567] ENH: update AE tests with new Shark API --- .../include/otbAutoencoderModel.txx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx index 254143a501..e5a26e9ee3 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbAutoencoderModel.txx @@ -44,7 +44,7 @@ #include <shark/Algorithms/StoppingCriteria/MaxIterations.h> //A simple stopping criterion that stops after a fixed number of iterations #include <shark/Algorithms/StoppingCriteria/TrainingProgress.h> //Stops when the algorithm seems to converge, Tracks the progress of the training error over a period of time -#include <shark/Algorithms/GradientDescent/SteepestDescent.h> +#include <shark/Algorithms/GradientDescent/Adam.h> #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif @@ -167,12 +167,12 @@ AutoencoderModel<TInputValue,NeuronType> shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples);//labels identical to inputs shark::SquaredLoss<shark::RealVector> loss; //~ shark::ErrorFunction error(trainSet, &model, &loss); - shark::ErrorFunction error(trainSet, &net, &loss); + shark::ErrorFunction<> error(trainSet, &net, &loss); - shark::TwoNormRegularizer regularizer(error.numberOfVariables()); + shark::TwoNormRegularizer<> regularizer(error.numberOfVariables()); error.setRegularizer(m_Regularization[layer_index],®ularizer); - shark::IRpropPlusFull optimizer; + shark::Adam<> optimizer; error.init(); optimizer.init(error); @@ -221,11 +221,11 @@ void AutoencoderModel<TInputValue,NeuronType>::TrainOneSparseLayer( shark::SquaredLoss<shark::RealVector> loss; //~ shark::SparseAutoencoderError error(trainSet,&net, &loss, m_Rho[layer_index], m_Beta[layer_index]); // SparseAutoencoderError doesn't exist anymore, for now use a plain ErrorFunction - shark::ErrorFunction error(trainSet, &net, &loss); + shark::ErrorFunction<> error(trainSet, &net, &loss); - shark::TwoNormRegularizer regularizer(error.numberOfVariables()); + shark::TwoNormRegularizer<> regularizer(error.numberOfVariables()); error.setRegularizer(m_Regularization[layer_index],®ularizer); - shark::IRpropPlusFull optimizer; + shark::Adam<> optimizer; error.init(); optimizer.init(error); @@ -269,11 +269,11 @@ AutoencoderModel<TInputValue,NeuronType> shark::LabeledData<shark::RealVector,shark::RealVector> trainSet(samples,samples); shark::SquaredLoss<shark::RealVector> loss; - shark::ErrorFunction error(trainSet, &net, &loss); - shark::TwoNormRegularizer regularizer(error.numberOfVariables()); + shark::ErrorFunction<> error(trainSet, &net, &loss); + shark::TwoNormRegularizer<> regularizer(error.numberOfVariables()); error.setRegularizer(m_Regularization[0],®ularizer); - shark::IRpropPlusFull optimizer; + shark::Adam<> optimizer; error.init(); optimizer.init(error); otbMsgDevMacro(<<"Error before training : " << optimizer.solution().value); -- GitLab From af207e2a3d2bcbcfadd567613aadaa0784b5c525 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Mon, 26 Mar 2018 14:32:20 +0200 Subject: [PATCH 511/567] ENH: change source file for standalone packages README to rst --- Documentation/Cookbook/rst/Installation.rst | 12 ++++++------ ...Installation_Linux.txt => Installation_Linux.rst} | 0 ...tion_Linux_xdk.txt => Installation_Linux_xdk.rst} | 0 ...{Installation_Macx.txt => Installation_Macos.rst} | 0 ...ation_Macx_xdk.txt => Installation_Macos_xsk.rst} | 0 ...allation_Windows.txt => Installation_Windows.rst} | 0 ..._Windows_xdk.txt => Installation_Windows_xdk.rst} | 0 Packaging/README.md | 2 +- Packaging/installer_files.cmake | 6 +++--- 9 files changed, 10 insertions(+), 10 deletions(-) rename Documentation/Cookbook/rst/{Installation_Linux.txt => Installation_Linux.rst} (100%) rename Documentation/Cookbook/rst/{Installation_Linux_xdk.txt => Installation_Linux_xdk.rst} (100%) rename Documentation/Cookbook/rst/{Installation_Macx.txt => Installation_Macos.rst} (100%) rename Documentation/Cookbook/rst/{Installation_Macx_xdk.txt => Installation_Macos_xsk.rst} (100%) rename Documentation/Cookbook/rst/{Installation_Windows.txt => Installation_Windows.rst} (100%) rename Documentation/Cookbook/rst/{Installation_Windows_xdk.txt => Installation_Windows_xdk.rst} (100%) diff --git a/Documentation/Cookbook/rst/Installation.rst b/Documentation/Cookbook/rst/Installation.rst index 6058b155e9..4a18859fc7 100644 --- a/Documentation/Cookbook/rst/Installation.rst +++ b/Documentation/Cookbook/rst/Installation.rst @@ -3,9 +3,9 @@ Installation We provide different standalone binary packages for OTB-Applications: -- for Windows platform (7 or higher) +- for Windows platform (Seven or higher) -- for 64bit Linux distribution +- for 64 bits Linux distribution - for MacOS X @@ -21,17 +21,17 @@ You can get latest binary packages from our `Download page <https://www.orfeo-to Windows ------- -.. include:: Installation_Windows.txt +.. include:: Installation_Windows.rst -Linux x86_64 +Linux ------------ -.. include:: Installation_Linux.txt +.. include:: Installation_Linux.rst MacOS X ------- -.. include:: Installation_Macx.txt +.. include:: Installation_Macos.rst Other packages -------------- diff --git a/Documentation/Cookbook/rst/Installation_Linux.txt b/Documentation/Cookbook/rst/Installation_Linux.rst similarity index 100% rename from Documentation/Cookbook/rst/Installation_Linux.txt rename to Documentation/Cookbook/rst/Installation_Linux.rst diff --git a/Documentation/Cookbook/rst/Installation_Linux_xdk.txt b/Documentation/Cookbook/rst/Installation_Linux_xdk.rst similarity index 100% rename from Documentation/Cookbook/rst/Installation_Linux_xdk.txt rename to Documentation/Cookbook/rst/Installation_Linux_xdk.rst diff --git a/Documentation/Cookbook/rst/Installation_Macx.txt b/Documentation/Cookbook/rst/Installation_Macos.rst similarity index 100% rename from Documentation/Cookbook/rst/Installation_Macx.txt rename to Documentation/Cookbook/rst/Installation_Macos.rst diff --git a/Documentation/Cookbook/rst/Installation_Macx_xdk.txt b/Documentation/Cookbook/rst/Installation_Macos_xsk.rst similarity index 100% rename from Documentation/Cookbook/rst/Installation_Macx_xdk.txt rename to Documentation/Cookbook/rst/Installation_Macos_xsk.rst diff --git a/Documentation/Cookbook/rst/Installation_Windows.txt b/Documentation/Cookbook/rst/Installation_Windows.rst similarity index 100% rename from Documentation/Cookbook/rst/Installation_Windows.txt rename to Documentation/Cookbook/rst/Installation_Windows.rst diff --git a/Documentation/Cookbook/rst/Installation_Windows_xdk.txt b/Documentation/Cookbook/rst/Installation_Windows_xdk.rst similarity index 100% rename from Documentation/Cookbook/rst/Installation_Windows_xdk.txt rename to Documentation/Cookbook/rst/Installation_Windows_xdk.rst diff --git a/Packaging/README.md b/Packaging/README.md index e845566c06..df83d58b21 100644 --- a/Packaging/README.md +++ b/Packaging/README.md @@ -1 +1 @@ -README +OTB recipes to build standalone binary packages for Windows/Linux/Mac OS X diff --git a/Packaging/installer_files.cmake b/Packaging/installer_files.cmake index 941f7f8cdf..b864b74b7e 100644 --- a/Packaging/installer_files.cmake +++ b/Packaging/installer_files.cmake @@ -22,11 +22,11 @@ macro(installer_files) #configure README from rst docs set(RSTDOC_DIR "${PACKAGE_OTB_SRC_DIR}/Documentation/Cookbook/rst") if(APPLE) - set(README_FILE ${RSTDOC_DIR}/Installation_Macx.txt) + set(README_FILE ${RSTDOC_DIR}/Installation_Macos.rst) elseif(LINUX) #not osx - set(README_FILE ${RSTDOC_DIR}/Installation_Linux.txt) + set(README_FILE ${RSTDOC_DIR}/Installation_Linux.rst) elseif(WIN32) #windows - set(README_FILE ${RSTDOC_DIR}/Installation_Windows.txt) + set(README_FILE ${RSTDOC_DIR}/Installation_Windows.rst) endif() configure_file("${README_FILE}" ${CMAKE_BINARY_DIR}/README ) install(FILES ${CMAKE_BINARY_DIR}/README DESTINATION ${PKG_STAGE_DIR} ) -- GitLab From 5e625ef75de7bf2cc30543f52207df6dca192e9f Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Mon, 26 Mar 2018 14:44:54 +0200 Subject: [PATCH 512/567] DOC: document in installer readme the corner case with Python3 on Linux --- .../Cookbook/rst/Installation_Linux.rst | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Documentation/Cookbook/rst/Installation_Linux.rst b/Documentation/Cookbook/rst/Installation_Linux.rst index a236e906a5..3435446f7d 100644 --- a/Documentation/Cookbook/rst/Installation_Linux.rst +++ b/Documentation/Cookbook/rst/Installation_Linux.rst @@ -115,7 +115,7 @@ Notes: FAQ ~~~ -Q: I am getting an error message... +Q: I am getting an error message related to Qt library... +++++++++++++++++++++++++++++++++++ :: @@ -130,6 +130,25 @@ A: This is due to a conflict with system Qt4 (usually seen on KDE) and Qt4 + gtk cd /path/to/OTB-|release|-Linux64 rm -f lib/libQt* && rm -fr lib/gtk +Q: Unable to import otbApplication library with Python3 ++++++++++++++++++++++++++++++++++++ + +:: + + ImportError: libpython3.5m.so.rh-python35-1.0: cannot open shared object file: No such file or directory + +A: You need to add a symlink to libpython3.5m.so.rh-python35-1.0 to make it works. + +Here is the solution: + +- find the libpython3.5XX on your system : find /usr/lib -iname *libpython3.5* +(on Ubuntu 14.04, it is /usr/lib/x86_64-linux-gnu/libpython3.5m.so) +- create a symlink : ln -s path/to/lib/python3.5XX +path/to/lib/libpython3.5m.so.rh-python35-1.0 +- Try to import otbApplication again + +See this discussion on `OTB issue tracker <https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues/1540#note_67864>`_ + Q: Monteverdi and Mapla applications look different from my other applications. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- GitLab From e1415c90d17dacd07b5c665e049355c8f9ae8fe9 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Mon, 26 Mar 2018 14:47:36 +0200 Subject: [PATCH 513/567] DOC: ispell linux package instructions --- Documentation/Cookbook/rst/Installation_Linux.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/Cookbook/rst/Installation_Linux.rst b/Documentation/Cookbook/rst/Installation_Linux.rst index 3435446f7d..84f5de7a38 100644 --- a/Documentation/Cookbook/rst/Installation_Linux.rst +++ b/Documentation/Cookbook/rst/Installation_Linux.rst @@ -91,9 +91,9 @@ OTB wrappings. If no compatible Python 2.x version is found a notification is generated during the installation process. If the installation completes without issue, information relating to your Python bindings will be provided. -You must have Python numpy bindings installed in your system. They can be installed locally +You must have Python NumPy bindings installed in your system. They can be installed locally without admin rights as follows: "pip install --user numpy". This is to give users the option -to select their own existing Python installation rather than the one dibstributed by the OTB package. +to select their own existing Python installation rather than the one distributed by the OTB package. By default, bindings for Python 2.7 will be enabled with the ``otbenv`` script. If you want to use bindings for Python 3.5, you can copy this script and modify: @@ -165,7 +165,7 @@ To use the distributed GTK libraries you need to set the OTB_USE_LOCAL_GTK: export OTB_USE_LOCAL_GTK=1 And now start ``monteverdi.sh`` or ``mapla.sh`` from OTB-6.0.0-Linux64 -To get back default behaviour, unset OTB_USE_LOCAL_GTK=1 or set OTB_USE_LOCAL_GTK=0 +To get back default behavior, unset OTB_USE_LOCAL_GTK=1 or set OTB_USE_LOCAL_GTK=0 In version 6.2 and older, the Linux binaries are built without GTK support to cut some dependencies. -- GitLab From faa820b522e9ab6441906baeb44c1e2d0c7dc8da Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 26 Mar 2018 14:54:32 +0200 Subject: [PATCH 514/567] ENH: dedicated filter for MPIVrtWriter --- .../MPIVrtWriter/include/otbMPIVrtWriter.h | 271 ++++----------- .../MPIVrtWriter/include/otbMPIVrtWriter.txx | 327 ++++++++++++++++++ Modules/MPI/MPIVrtWriter/otb-module.cmake | 5 +- 3 files changed, 398 insertions(+), 205 deletions(-) create mode 100644 Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx diff --git a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h index ecec379e6d..3b21985b16 100644 --- a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h +++ b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h @@ -47,231 +47,96 @@ namespace otb { /** - *\brief Write image data to multiple files with MPI processus and add a VRT file. + * \class MPIVrtWriter * - * The image is divided into several pieces. - * Each pieces is distributed to a MPI processus. - * Each MPI processus write their pieces into a separate - * file. - * The master processus writes a VRT file (optional). + * \brief Write each tile of an image into a separate Tiff file and join them in a VRT * - *\param img Image - *\param output Output Filename - *\param availableRAM Available memory for streaming - *\param writeVRTFile Activate the VRT file writing + * \ingroup OTBMPIVrtWriter */ -template <typename TImage> void WriteMPI(TImage *img, const std::string &output, unsigned int availableRAM = 0, bool writeVRTFile=true) +template <typename TImage> +class MPIVrtWriter: public itk::ProcessObject { - typename otb::MPIConfig::Pointer mpiConfig = otb::MPIConfig::Instance(); - - unsigned int myRank = mpiConfig->GetMyRank(); - unsigned int nbProcs = mpiConfig->GetNbProcs(); - - typedef otb::ImageFileWriter<TImage> WriterType; - typedef otb::NumberOfDivisionsTiledStreamingManager<TImage> StreamingManagerType; - typedef itk::RegionOfInterestImageFilter<TImage, TImage> ExtractFilterType; - - // First, update infomration from image to write - img->UpdateOutputInformation(); - - // Configure streaming manager - typename StreamingManagerType::Pointer streamingManager = StreamingManagerType::New(); - streamingManager->SetNumberOfDivisions(nbProcs); - streamingManager->PrepareStreaming(img,img->GetLargestPossibleRegion()); - unsigned int numberOfSplits = streamingManager->GetNumberOfSplits(); - - // This vector will hold all regions to write for current rank - std::vector<typename TImage::RegionType> regionsToWrite; - - // Handle both cases when there are much more (resp. less) region to - // write than NbProcs - if(myRank < numberOfSplits) - { - unsigned int splitIdx = myRank; - while(splitIdx < numberOfSplits) - { - typename TImage::RegionType currentRegion = streamingManager->GetSplit(splitIdx); - regionsToWrite.push_back(currentRegion); - splitIdx+=nbProcs; - } - } - - // Output prefix - std::string extension = itksys::SystemTools::GetFilenameExtension(output); - if (extension != ".vrt") - { - - // TODO: Maybe remove this - if (extension == "") - { - // Missing extension - mpiConfig->logInfo("Filename has no extension. Adding <.vrt> extension."); - } - else - { - // Bad extension - mpiConfig->logError("Filename must have .vrt extension!"); - mpiConfig->abort(EXIT_FAILURE); - } - } - std::vector<std::string> joins; - joins.push_back(itksys::SystemTools::GetFilenamePath(output).append("/")); - joins.push_back(itksys::SystemTools::GetFilenameWithoutExtension(output)); - std::string prefix = itksys::SystemTools::JoinPath(joins); +public: + /** Standard class typedefs. */ + typedef MPIVrtWriter Self; + typedef itk::ProcessObject Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + typedef TImage InputImageType; - // Data type - std::string dataTypeStr = "Float32"; - GDALImageIO::Pointer gdalImageIO; + /** Method for creation through the object factory. */ + itkNewMacro(Self); - // Now write all the regions - for(typename std::vector<typename TImage::RegionType>::const_iterator it = regionsToWrite.begin(); - it!=regionsToWrite.end();++it) - { - typename ExtractFilterType::Pointer extractFilter = ExtractFilterType::New(); - extractFilter->SetInput(img); - extractFilter->SetRegionOfInterest(*it); - // Writer - // Output Filename - std::stringstream ss; - ss<<prefix<<"_"<<it->GetIndex()[0]<<"_"<<it->GetIndex()[1]<<"_"<<it->GetSize()[0]<<"_"<<it->GetSize()[1]<<".tif"; - typename WriterType::Pointer writer = WriterType::New(); - writer->SetFileName(ss.str()); - writer->SetInput(extractFilter->GetOutput()); - // Datatype - gdalImageIO = dynamic_cast<GDALImageIO *>(writer->GetImageIO()); - if(gdalImageIO.IsNotNull()) - { - dataTypeStr = gdalImageIO->GetGdalPixelTypeAsString(); - } + /** Run-time type information (and related methods). */ + itkTypeMacro(MPIVrtWriter, itk::ProcessObject); - if (!availableRAM) - { - writer->SetNumberOfDivisionsTiledStreaming(0); - } - else - { - writer->SetAutomaticAdaptativeStreaming(availableRAM); - } + using Superclass::SetInput; + virtual void SetInput(const InputImageType *input); - // Pipeline execution - try - { - writer->Update(); - } - catch (itk::ExceptionObject& err) - { - std::stringstream message; - message << "ExceptionObject caught: " << err << std::endl; - mpiConfig->logError(message.str()); - mpiConfig->abort(EXIT_FAILURE); - } - } + /** Get writer only input */ + const InputImageType* GetInput(); - // MPI process synchronization - mpiConfig->barrier(); + /** Does the real work. */ + virtual void Update() override; - // Write VRT file - try - { - if (writeVRTFile && (myRank == 0)) - { - // VRT Filename - std::stringstream vrtfOut; - vrtfOut<< prefix << ".vrt"; + /** SimpleParallelTiffWriter Methods */ + virtual void SetFileName(const char* extendedFileName); + virtual void SetFileName(std::string extendedFileName); + virtual const char* GetFileName () const; - // Data type - GDALDataType dataType; - dataType = GDALGetDataTypeByName(dataTypeStr.c_str()); + /** Specify the region to write. If left NULL, then the whole image + * is written. */ + void SetIORegion(const itk::ImageIORegion& region); + itkGetConstReferenceMacro(IORegion, itk::ImageIORegion); - int imageSizeY = img->GetLargestPossibleRegion().GetSize()[1]; - int imageSizeX = img->GetLargestPossibleRegion().GetSize()[0]; - const unsigned int nbBands = img->GetNumberOfComponentsPerPixel(); + itkSetMacro(WriteVRT, bool); + itkGetMacro(WriteVRT, bool); - // Get VRT driver - GDALAllRegister(); - GDALDriver *driver = GetGDALDriverManager()->GetDriverByName("VRT"); - if (driver == NULL) { - mpiConfig->logError("Error opening VRT driver."); - mpiConfig->abort(EXIT_FAILURE); - } + itkSetMacro(AvailableRAM, unsigned int); + itkGetMacro(AvailableRAM, unsigned int); - // Create output raster - GDALDataset *VRTOutput = driver->Create(vrtfOut.str().c_str(), - imageSizeX, - imageSizeY, - 0, - dataType, - NULL); // No options - if (VRTOutput == NULL) { - mpiConfig->logError("driver->Create call failed.\n"); - mpiConfig->abort(EXIT_FAILURE); - } +protected: + MPIVrtWriter(); + virtual ~MPIVrtWriter(); + void PrintSelf(std::ostream& os, itk::Indent indent) const override; - // Set GeoTransform - double gt[6]; - gt[0] = img->GetOrigin()[0] - 0.5*img->GetSignedSpacing()[0]; - gt[1] = img->GetSignedSpacing()[0]; - gt[2] = 0.0; - gt[3] = img->GetOrigin()[1] - 0.5*img->GetSignedSpacing()[1]; - gt[4] = 0.0; - gt[5] = img->GetSignedSpacing()[1]; - VRTOutput->SetGeoTransform(gt); +private: + MPIVrtWriter(const MPIVrtWriter &) = delete; + void operator =(const MPIVrtWriter&) = delete; - // Set projection - OGRSpatialReference out_sr; - char *wkt = NULL; - out_sr.SetFromUserInput(img->GetProjectionRef().c_str()); - out_sr.exportToWkt(&wkt); - VRTOutput->SetProjection(wkt); + unsigned int m_AvailableRAM; - for(unsigned int band = 1; band<=nbBands;++band) - { - VRTOutput->AddBand(dataType, NULL); + itk::ImageIORegion m_IORegion; - typename TImage::RegionType currentRegion; - for(unsigned int id=0; id < numberOfSplits; ++id) - { - currentRegion = streamingManager->GetSplit(id); - int tileSizeX = currentRegion.GetSize()[0]; - int tileSizeY = currentRegion.GetSize()[1]; - int tileIndexX = currentRegion.GetIndex()[0]; - int tileIndexY = currentRegion.GetIndex()[1]; - std::stringstream tileFileName; - tileFileName <<prefix<<"_"<<tileIndexX<<"_"<<tileIndexY<<"_"<<tileSizeX<<"_"<<tileSizeY<<".tif"; - std::cout<<tileFileName.str()<<std::endl; + std::string m_Filename; - GDALDataset *dataset = (GDALDataset*) GDALOpen(tileFileName.str().c_str(), GA_ReadOnly); + bool m_WriteVRT; - VRTSourcedRasterBand *VRTBand = dynamic_cast<VRTSourcedRasterBand*> (VRTOutput->GetRasterBand(band)); - VRTBand->AddSimpleSource(dataset->GetRasterBand(band), - 0, //xOffSrc - 0, //yOffSrc - tileSizeX, //xSizeSrc - tileSizeY, //ySizeSrc - tileIndexX, //xOffDest - tileIndexY, //yOffDest - tileSizeX, //xSizeDest - tileSizeY, //ySizeDest - "near", - VRT_NODATA_UNSET); - } - - } - - // Close - CPLFree(wkt); - GDALClose(VRTOutput); - } - } - catch (itk::ExceptionObject& err) - { - std::stringstream message; - message << "ExceptionObject caught: " << err << std::endl; - mpiConfig->logError(message.str()); - mpiConfig->abort(EXIT_FAILURE); - } +}; +/** + *\brief Write image data to multiple files with MPI processus and add a VRT file. + * + * The image is divided into several pieces. + * Each pieces is distributed to a MPI processus. + * Each MPI processus write their pieces into a separate + * file. + * The master processus writes a VRT file (optional). + * + *\param img Image + *\param output Output Filename + *\param availableRAM Available memory for streaming + *\param writeVRTFile Activate the VRT file writing + */ +template <typename TImage> void WriteMPI(TImage *img, const std::string &output, unsigned int availableRAM = 0, bool writeVRTFile=true) +{ + typename MPIVrtWriter<TImage>::Pointer writer = MPIVrtWriter<TImage>::New(); + writer->SetInput(img); + writer->SetFileName(output); + writer->SetAvailableRAM(availableRAM); + writer->SetWriteVRT(writeVRTFile); + writer->Update(); } } // End namespace otb diff --git a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx new file mode 100644 index 0000000000..db11192919 --- /dev/null +++ b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx @@ -0,0 +1,327 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef otbMPIVrtWriter_txx +#define otbMPIVrtWriter_txx + +#include "otbMPIVrtWriter.h" + +namespace otb +{ + +template <typename TImage> +MPIVrtWriter<TImage>::MPIVrtWriter() + : m_AvailableRAM(0) + , m_IORegion() + , m_Filename("") + , m_WriteVRT(true) +{ +} + +template <typename TImage> +MPIVrtWriter<TImage>::~MPIVrtWriter() +{ +} + +template <typename TImage> +void +MPIVrtWriter<TImage>::SetInput(const InputImageType *input) +{ + this->ProcessObject::SetNthInput(0,const_cast<InputImageType*>(input)); +} + +template <typename TImage> +const InputImageType* +MPIVrtWriter<TImage>::GetInput() +{ + if (this->GetNumberOfInputs() < 1) + { + return 0; + } + return static_cast<const InputImageType*>(this->ProcessObject::GetInput(0)); +} + +template <typename TImage> +void +MPIVrtWriter<TImage>::SetFileName(const char* extendedFileName) +{ + if (m_Filename.compare(extendedFileName) != 0 ) + { + m_Filename = std::string(extendedFileName); + this->Modified(); + } +} + +template <typename TImage> +void +MPIVrtWriter<TImage>::SetFileName(std::string extendedFileName) +{ + this->SetFileName(extendedFileName.c_str()); +} + +template <typename TImage> +const char* +MPIVrtWriter<TImage>::GetFileName () const +{ + return m_Filename.c_str(); +} + +template <typename TImage> +void +MPIVrtWriter<TImage>::SetIORegion(const itk::ImageIORegion& region) +{ + if (m_IORegion != region) + { + m_IORegion = region; + this->Modified(); + } +} + +template <typename TImage> +void +MPIVrtWriter<TImage>::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); + os << indent << "File Name: "<< m_Filename << std::endl; + os << indent << "Available RAM: "<< m_AvailableRAM << std::endl; + os << indent << "Write VRT: "<< m_WriteVRT << std::endl; +} + +template <typename TImage> +void +MPIVrtWriter<TImage>::Update() +{ + typename otb::MPIConfig::Pointer mpiConfig = otb::MPIConfig::Instance(); + + unsigned int myRank = mpiConfig->GetMyRank(); + unsigned int nbProcs = mpiConfig->GetNbProcs(); + + typedef otb::ImageFileWriter<TImage> WriterType; + typedef otb::NumberOfDivisionsTiledStreamingManager<TImage> StreamingManagerType; + typedef itk::RegionOfInterestImageFilter<TImage, TImage> ExtractFilterType; + + // First, update infomration from image to write + UpdateOutputInformation(); + InputImageType* img = const_cast<InputImageType*>(GetInput()); + std::string output = GetFileName(); + + // Configure streaming manager + typename StreamingManagerType::Pointer streamingManager = StreamingManagerType::New(); + streamingManager->SetNumberOfDivisions(nbProcs); + streamingManager->PrepareStreaming(img,img->GetLargestPossibleRegion()); + unsigned int numberOfSplits = streamingManager->GetNumberOfSplits(); + + // This vector will hold all regions to write for current rank + std::vector<typename TImage::RegionType> regionsToWrite; + + // Handle both cases when there are much more (resp. less) region to + // write than NbProcs + if(myRank < numberOfSplits) + { + unsigned int splitIdx = myRank; + while(splitIdx < numberOfSplits) + { + typename TImage::RegionType currentRegion = streamingManager->GetSplit(splitIdx); + regionsToWrite.push_back(currentRegion); + splitIdx+=nbProcs; + } + } + + // Output prefix + std::string extension = itksys::SystemTools::GetFilenameExtension(output); + if (extension != ".vrt") + { + + // TODO: Maybe remove this + if (extension == "") + { + // Missing extension + mpiConfig->logInfo("Filename has no extension. Adding <.vrt> extension."); + } + else + { + // Bad extension + mpiConfig->logError("Filename must have .vrt extension!"); + mpiConfig->abort(EXIT_FAILURE); + } + } + std::vector<std::string> joins; + joins.push_back(itksys::SystemTools::GetFilenamePath(output).append("/")); + joins.push_back(itksys::SystemTools::GetFilenameWithoutExtension(output)); + std::string prefix = itksys::SystemTools::JoinPath(joins); + + + // Data type + std::string dataTypeStr = "Float32"; + GDALImageIO::Pointer gdalImageIO; + + // Now write all the regions + for(typename std::vector<typename TImage::RegionType>::const_iterator it = regionsToWrite.begin(); + it!=regionsToWrite.end();++it) + { + typename ExtractFilterType::Pointer extractFilter = ExtractFilterType::New(); + extractFilter->SetInput(img); + extractFilter->SetRegionOfInterest(*it); + // Writer + // Output Filename + std::stringstream ss; + ss<<prefix<<"_"<<it->GetIndex()[0]<<"_"<<it->GetIndex()[1]<<"_"<<it->GetSize()[0]<<"_"<<it->GetSize()[1]<<".tif"; + typename WriterType::Pointer writer = WriterType::New(); + writer->SetFileName(ss.str()); + writer->SetInput(extractFilter->GetOutput()); + // Datatype + gdalImageIO = dynamic_cast<GDALImageIO *>(writer->GetImageIO()); + if(gdalImageIO.IsNotNull()) + { + dataTypeStr = gdalImageIO->GetGdalPixelTypeAsString(); + } + + if (!m_AvailableRAM) + { + writer->SetNumberOfDivisionsTiledStreaming(0); + } + else + { + writer->SetAutomaticAdaptativeStreaming(m_AvailableRAM); + } + + // Pipeline execution + try + { + writer->Update(); + } + catch (itk::ExceptionObject& err) + { + std::stringstream message; + message << "ExceptionObject caught: " << err << std::endl; + mpiConfig->logError(message.str()); + mpiConfig->abort(EXIT_FAILURE); + } + } + + // MPI process synchronization + mpiConfig->barrier(); + + // Write VRT file + try + { + if (m_WriteVRT && (myRank == 0)) + { + // VRT Filename + std::stringstream vrtfOut; + vrtfOut<< prefix << ".vrt"; + + // Data type + GDALDataType dataType; + dataType = GDALGetDataTypeByName(dataTypeStr.c_str()); + + int imageSizeY = img->GetLargestPossibleRegion().GetSize()[1]; + int imageSizeX = img->GetLargestPossibleRegion().GetSize()[0]; + const unsigned int nbBands = img->GetNumberOfComponentsPerPixel(); + + // Get VRT driver + GDALAllRegister(); + GDALDriver *driver = GetGDALDriverManager()->GetDriverByName("VRT"); + if (driver == NULL) { + mpiConfig->logError("Error opening VRT driver."); + mpiConfig->abort(EXIT_FAILURE); + } + + // Create output raster + GDALDataset *VRTOutput = driver->Create(vrtfOut.str().c_str(), + imageSizeX, + imageSizeY, + 0, + dataType, + NULL); // No options + if (VRTOutput == NULL) { + mpiConfig->logError("driver->Create call failed.\n"); + mpiConfig->abort(EXIT_FAILURE); + } + + // Set GeoTransform + double gt[6]; + gt[0] = img->GetOrigin()[0] - 0.5*img->GetSignedSpacing()[0]; + gt[1] = img->GetSignedSpacing()[0]; + gt[2] = 0.0; + gt[3] = img->GetOrigin()[1] - 0.5*img->GetSignedSpacing()[1]; + gt[4] = 0.0; + gt[5] = img->GetSignedSpacing()[1]; + VRTOutput->SetGeoTransform(gt); + + // Set projection + OGRSpatialReference out_sr; + char *wkt = NULL; + out_sr.SetFromUserInput(img->GetProjectionRef().c_str()); + out_sr.exportToWkt(&wkt); + VRTOutput->SetProjection(wkt); + + for(unsigned int band = 1; band<=nbBands;++band) + { + VRTOutput->AddBand(dataType, NULL); + + typename TImage::RegionType currentRegion; + for(unsigned int id=0; id < numberOfSplits; ++id) + { + currentRegion = streamingManager->GetSplit(id); + int tileSizeX = currentRegion.GetSize()[0]; + int tileSizeY = currentRegion.GetSize()[1]; + int tileIndexX = currentRegion.GetIndex()[0]; + int tileIndexY = currentRegion.GetIndex()[1]; + std::stringstream tileFileName; + tileFileName <<prefix<<"_"<<tileIndexX<<"_"<<tileIndexY<<"_"<<tileSizeX<<"_"<<tileSizeY<<".tif"; + std::cout<<tileFileName.str()<<std::endl; + + GDALDataset *dataset = (GDALDataset*) GDALOpen(tileFileName.str().c_str(), GA_ReadOnly); + + VRTSourcedRasterBand *VRTBand = dynamic_cast<VRTSourcedRasterBand*> (VRTOutput->GetRasterBand(band)); + VRTBand->AddSimpleSource(dataset->GetRasterBand(band), + 0, //xOffSrc + 0, //yOffSrc + tileSizeX, //xSizeSrc + tileSizeY, //ySizeSrc + tileIndexX, //xOffDest + tileIndexY, //yOffDest + tileSizeX, //xSizeDest + tileSizeY, //ySizeDest + "near", + VRT_NODATA_UNSET); + } + + } + + // Close + CPLFree(wkt); + GDALClose(VRTOutput); + } + } + catch (itk::ExceptionObject& err) + { + std::stringstream message; + message << "ExceptionObject caught: " << err << std::endl; + mpiConfig->logError(message.str()); + mpiConfig->abort(EXIT_FAILURE); + } +} + + +} // end of namespace otb + +#endif diff --git a/Modules/MPI/MPIVrtWriter/otb-module.cmake b/Modules/MPI/MPIVrtWriter/otb-module.cmake index 0e95d97f7c..f98ab957d2 100644 --- a/Modules/MPI/MPIVrtWriter/otb-module.cmake +++ b/Modules/MPI/MPIVrtWriter/otb-module.cmake @@ -22,8 +22,9 @@ set(DOCUMENTATION "Provides a template function for MPI writing to a VRT file") otb_module(OTBMPIVrtWriter DEPENDS - OTBMPIConfig - OTBPanSharpening + OTBCommon + OTBMPIConfig +# OTBPanSharpening OTBProjection OTBInterpolation OTBTestKernel -- GitLab From 3d73c2e022cdbee3eb31780cbc2a8d591ecad962 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Mon, 26 Mar 2018 15:20:27 +0200 Subject: [PATCH 515/567] BUG: use print as a function in Python recipes to be compatible with Python3 --- Documentation/Cookbook/rst/recipes/python.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/Cookbook/rst/recipes/python.rst b/Documentation/Cookbook/rst/recipes/python.rst index 41306ac1ea..f4d5ff597e 100644 --- a/Documentation/Cookbook/rst/recipes/python.rst +++ b/Documentation/Cookbook/rst/recipes/python.rst @@ -29,14 +29,14 @@ application, changing the algorithm at each iteration. import otbApplication # otbApplication.Registry can tell you what application are available - print "Available applications: " - print str( otbApplication.Registry.GetAvailableApplications() ) + print('Available applications: ') + print (str( otbApplication.Registry.GetAvailableApplications())) # Let's create the application "Smoothing" app = otbApplication.Registry.CreateApplication("Smoothing") # We print the keys of all its parameters - print app.GetParametersKeys() + print (app.GetParametersKeys()) # First, we set the input image filename app.SetParameterString("in", argv[1]) @@ -45,7 +45,7 @@ application, changing the algorithm at each iteration. # and can take 3 values: 'mean', 'gaussian', 'anidif' for type in ['mean', 'gaussian', 'anidif']: - print 'Running with ' + type + ' smoothing type' + print('Running with ' + type + ' smoothing type') # Now we configure the smoothing algorithm app.SetParameterString("type", type) @@ -303,7 +303,7 @@ Here is a small example of what can be done: # Check the result of ReadImageInfo someKeys = ['sizex', 'sizey', 'spacingx', 'spacingy', 'sensor', 'projectionref'] for key in someKeys: - print(key + ' : ' + str(app2.GetParameterValue(key)) ) + print(key + ' : ' + str(app2.GetParameterValue(key))) # Only a portion of "out" was exported but ReadImageInfo is still able to detect the # correct full size of the image -- GitLab From b54952920ef65722fa1a02b9545f65e345831339 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Tue, 27 Mar 2018 13:39:12 +0200 Subject: [PATCH 516/567] DOC: remove outdated questions from installation instructions FAQ following rashad advises --- .../Cookbook/rst/Installation_Linux.rst | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/Documentation/Cookbook/rst/Installation_Linux.rst b/Documentation/Cookbook/rst/Installation_Linux.rst index 84f5de7a38..8f90e6cd81 100644 --- a/Documentation/Cookbook/rst/Installation_Linux.rst +++ b/Documentation/Cookbook/rst/Installation_Linux.rst @@ -115,21 +115,6 @@ Notes: FAQ ~~~ -Q: I am getting an error message related to Qt library... -+++++++++++++++++++++++++++++++++++ - -:: - - Cannot mix incompatible Qt library (version 0x40806) with this library (version 0x40807) - Aborted - -A: This is due to a conflict with system Qt4 (usually seen on KDE) and Qt4 + gtk libs in OTB package. The fix you need is to remove those libs from package. - -.. parsed-literal:: - - cd /path/to/OTB-|release|-Linux64 - rm -f lib/libQt* && rm -fr lib/gtk - Q: Unable to import otbApplication library with Python3 +++++++++++++++++++++++++++++++++++ @@ -148,24 +133,3 @@ path/to/lib/libpython3.5m.so.rh-python35-1.0 - Try to import otbApplication again See this discussion on `OTB issue tracker <https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/issues/1540#note_67864>`_ - -Q: Monteverdi and Mapla applications look different from my other applications. -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -A: In versions 6.0, Monteverdi, Mapla and otbapplication (otbgui\_\*) -use the system gtk theme. If you can't install GTK on your system you can use the -one distributed with the OTB package. Note that using system GTK is the preferred -way with the OTB standalone package as the distributed version of GTK do not -work on recent Linux distributions. - -To use the distributed GTK libraries you need to set the OTB_USE_LOCAL_GTK: - -:: - - export OTB_USE_LOCAL_GTK=1 - -And now start ``monteverdi.sh`` or ``mapla.sh`` from OTB-6.0.0-Linux64 -To get back default behavior, unset OTB_USE_LOCAL_GTK=1 or set OTB_USE_LOCAL_GTK=0 - -In version 6.2 and older, the Linux binaries are built without GTK support to cut some -dependencies. -- GitLab From e5a7486fc831619064d4a5e624ecaf69983c1e59 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 27 Mar 2018 16:15:01 +0200 Subject: [PATCH 517/567] BUG: remove print in cmakelist --- Modules/Adapters/GdalAdapters/test/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt index fcfa764079..bc03ae797e 100644 --- a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt +++ b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt @@ -80,7 +80,4 @@ otb_add_test(NAME TvOGRExtendedFilenameGDALLayerOption COMMAND otbOGRTestDriver otbOGRExtendedFileNameGDALLayerOption test.shp - ) - - -message(STATUS "Test link : ${OTBGdalAdapters-Test_LIBRARIES}") \ No newline at end of file + ) \ No newline at end of file -- GitLab From 7a30611a3c2351463d75d61e81d444279b81f41b Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 27 Mar 2018 16:16:26 +0200 Subject: [PATCH 518/567] BUG: do not release the output for python user --- .../ApplicationEngine/src/otbWrapperApplication.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 2580e59de5..3d469f239b 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -504,6 +504,7 @@ Application::RegisterPipeline() void Application::FreeRessources() { + std::set< itk::DataObject * > dataSetToRelease; // do not release output std::set< itk::DataObject * > dataSet; std::vector<std::string> paramList = GetParametersKeys(true); // Get the end of the pipeline @@ -563,6 +564,7 @@ void Application::FreeRessources() if ( !newData || dataSet.count( newData ) ) continue; dataSet.insert( newData ); + dataSetToRelease.insert( newData ); itk::ProcessObject * process = newData->GetSource().GetPointer(); if ( process ) processStack.push( process ); @@ -571,6 +573,7 @@ void Application::FreeRessources() else { dataSet.insert( data.GetPointer() ); + dataSetToRelease.insert( data.GetPointer() ); itk::ProcessObject * process = data->GetSource().GetPointer(); if ( process ) processStack.push( process ); @@ -578,11 +581,11 @@ void Application::FreeRessources() } } // Release data - for ( auto data : dataSet ) + for ( auto data : dataSetToRelease ) { data->ReleaseData(); } - // Call overrode method + // Call override method DoFreeRessources(); } -- GitLab From f860368fd422c352b96f85bd565b4784b8734dde Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 27 Mar 2018 17:03:09 +0200 Subject: [PATCH 519/567] BUG: fix error warning on windows --- Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h | 2 +- Modules/IO/ImageIO/include/otbImageFileWriter.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h index bbdb9c94ee..26b529fdf3 100644 --- a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h +++ b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h @@ -146,7 +146,7 @@ public: // the interface of the superclass getter function is not thread safe bool GetAbortGenerateDataMutex() const; - void SetAbortGenerateData(bool val) override; + void SetAbortGenerateData(const bool val) override; protected: StreamingImageVirtualWriter(); diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.h b/Modules/IO/ImageIO/include/otbImageFileWriter.h index cc35acf115..d8d18f634a 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.h @@ -203,7 +203,7 @@ public: // the interface of the superclass getter function is not thread safe bool GetAbortGenerateDataMutex() const; - void SetAbortGenerateData(bool val) override; + void SetAbortGenerateData(const bool val) override; protected: ImageFileWriter(); -- GitLab From 28639b65008635fb1ffd39636d34c59a82cadc5b Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 27 Mar 2018 17:26:20 +0200 Subject: [PATCH 520/567] ENH: two boolean constants --- Modules/Core/Common/include/otbUtils.h | 3 +++ Modules/Core/Common/src/otbUtils.cxx | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Modules/Core/Common/include/otbUtils.h b/Modules/Core/Common/include/otbUtils.h index da2ecc286e..ec8ed54759 100644 --- a/Modules/Core/Common/include/otbUtils.h +++ b/Modules/Core/Common/include/otbUtils.h @@ -51,6 +51,9 @@ namespace Utils /** Function that prints nothing (useful to disable libsvm logs)*/ void OTBCommon_EXPORT PrintNothing(const char *s); + extern OTBCommon_EXPORT bool const TrueConstant; + + extern OTBCommon_EXPORT bool const FalseConstant; } } // namespace otb diff --git a/Modules/Core/Common/src/otbUtils.cxx b/Modules/Core/Common/src/otbUtils.cxx index f837789ba6..7bdf9edb71 100644 --- a/Modules/Core/Common/src/otbUtils.cxx +++ b/Modules/Core/Common/src/otbUtils.cxx @@ -41,6 +41,10 @@ void PrintNothing(const char * /* s */) { } +bool const TrueConstant = true; + +bool const FalseConstant = false; + } } -- GitLab From 83c31a67575ce38d780e999b3a0f60169fc8bbde Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 27 Mar 2018 17:29:24 +0200 Subject: [PATCH 521/567] ENH: use a trick to override ProcessObject::GetAbortGenerateData in a thread safe way --- .../include/otbStreamingImageVirtualWriter.h | 4 ++-- .../include/otbStreamingImageVirtualWriter.txx | 12 +++++++----- Modules/IO/ImageIO/include/otbImageFileWriter.h | 4 ++-- Modules/IO/ImageIO/include/otbImageFileWriter.txx | 13 ++++++++----- .../include/otbSimpleParallelTiffWriter.h | 4 ++-- .../include/otbSimpleParallelTiffWriter.txx | 14 ++++++++------ 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h index 26b529fdf3..29fafc6bf5 100644 --- a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h +++ b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h @@ -143,8 +143,8 @@ public: * This filter does not produce an output */ void Update() override; - // the interface of the superclass getter function is not thread safe - bool GetAbortGenerateDataMutex() const; + /** This override doesn't return a const ref on the actual boolean */ + const bool & GetAbortGenerateData() const override; void SetAbortGenerateData(const bool val) override; diff --git a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx index 4d724bd8b1..ec0ae5ae6d 100644 --- a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx +++ b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx @@ -32,6 +32,7 @@ #include "otbTileDimensionTiledStreamingManager.h" #include "otbRAMDrivenTiledStreamingManager.h" #include "otbRAMDrivenAdaptativeStreamingManager.h" +#include "otbUtils.h" namespace otb { @@ -238,7 +239,7 @@ StreamingImageVirtualWriter<TInputImage> */ InputImageRegionType streamRegion; for (m_CurrentDivision = 0; - m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateDataMutex(); + m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateData(); m_CurrentDivision++, m_DivisionProgress = 0, this->UpdateFilterProgress()) { streamRegion = m_StreamingManager->GetSplit(m_CurrentDivision); @@ -254,7 +255,7 @@ StreamingImageVirtualWriter<TInputImage> * If we ended due to aborting, push the progress up to 1.0 (since * it probably didn't end there) */ - if (!this->GetAbortGenerateDataMutex()) + if (!this->GetAbortGenerateData()) { this->UpdateProgress(1.0); } @@ -293,14 +294,15 @@ StreamingImageVirtualWriter<TInputImage> } template <class TInputImage> -bool +const bool & StreamingImageVirtualWriter<TInputImage> -::GetAbortGenerateDataMutex() const +::GetAbortGenerateData() const { m_Lock.Lock(); bool ret = Superclass::GetAbortGenerateData(); m_Lock.Unlock(); - return ret; + if (ret) return otb::Utils::TrueConstant; + return otb::Utils::FalseConstant; } template <class TInputImage> diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.h b/Modules/IO/ImageIO/include/otbImageFileWriter.h index d8d18f634a..cbc4c6c4e9 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.h @@ -200,8 +200,8 @@ public: itkGetObjectMacro(ImageIO, otb::ImageIOBase); itkGetConstObjectMacro(ImageIO, otb::ImageIOBase); - // the interface of the superclass getter function is not thread safe - bool GetAbortGenerateDataMutex() const; + /** This override doesn't return a const ref on the actual boolean */ + const bool & GetAbortGenerateData() const override; void SetAbortGenerateData(const bool val) override; diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index 3229d46a3e..62277a49c1 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -48,6 +48,7 @@ #include "otb_boost_tokenizer_header.h" #include "otbStringUtils.h" +#include "otbUtils.h" namespace otb { @@ -604,7 +605,7 @@ ImageFileWriter<TInputImage> } for (m_CurrentDivision = 0; - m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateDataMutex(); + m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateData(); m_CurrentDivision++, m_DivisionProgress = 0, this->UpdateFilterProgress()) { streamRegion = m_StreamingManager->GetSplit(m_CurrentDivision); @@ -633,7 +634,7 @@ ImageFileWriter<TInputImage> * If we ended due to aborting, push the progress up to 1.0 (since * it probably didn't end there) */ - if (!this->GetAbortGenerateDataMutex()) + if (!this->GetAbortGenerateData()) { this->UpdateProgress(1.0); } @@ -836,14 +837,16 @@ return this->m_FilenameHelper->GetSimpleFileName(); } template <class TInputImage> -bool +const bool & ImageFileWriter<TInputImage> -::GetAbortGenerateDataMutex() const +::GetAbortGenerateData() const { m_Lock.Lock(); + // protected read here bool ret = Superclass::GetAbortGenerateData(); m_Lock.Unlock(); - return ret; + if (ret) return otb::Utils::TrueConstant; + return otb::Utils::FalseConstant; } template <class TInputImage> diff --git a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h index 8b2e9b1b8e..a7c413064a 100644 --- a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h +++ b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h @@ -253,8 +253,8 @@ public: itkSetMacro(TiffTiledMode, bool); itkGetMacro(TiffTiledMode, bool); - // the interface of the superclass getter function is not thread safe - bool GetAbortGenerateDataMutex() const; + /** This override doesn't return a const ref on the actual boolean */ + const bool & GetAbortGenerateData() const override; void SetAbortGenerateData(bool val) override; diff --git a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx index 4d51c77383..b037a67566 100644 --- a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx +++ b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.txx @@ -23,6 +23,7 @@ #include "otbSimpleParallelTiffWriter.h" #include "otbStopwatch.h" +#include "otbUtils.h" using std::vector; @@ -682,7 +683,7 @@ SimpleParallelTiffWriter<TInputImage> double processDuration(0), writeDuration(0), numberOfProcessedRegions(0); InputImageRegionType streamRegion; for (m_CurrentDivision = 0; - m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateDataMutex(); + m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateData(); m_CurrentDivision++, m_DivisionProgress = 0, this->UpdateFilterProgress()) { streamRegion = m_StreamingManager->GetSplit(m_CurrentDivision); @@ -717,7 +718,7 @@ SimpleParallelTiffWriter<TInputImage> } // abort case - if (this->GetAbortGenerateDataMutex()) + if (this->GetAbortGenerateData()) { itk::ProcessAborted e(__FILE__, __LINE__); e.SetLocation(ITK_LOCATION); @@ -768,7 +769,7 @@ SimpleParallelTiffWriter<TInputImage> * If we ended due to aborting, push the progress up to 1.0 (since * it probably didn't end there) */ - if (!this->GetAbortGenerateDataMutex()) + if (!this->GetAbortGenerateData()) { this->UpdateProgress(1.0); } @@ -835,14 +836,15 @@ SimpleParallelTiffWriter<TInputImage> } template <class TInputImage> -bool +const bool & SimpleParallelTiffWriter<TInputImage> -::GetAbortGenerateDataMutex() const +::GetAbortGenerateData() const { m_Lock.Lock(); bool ret = Superclass::GetAbortGenerateData(); m_Lock.Unlock(); - return ret; + if (ret) return otb::Utils::TrueConstant; + return otb::Utils::FalseConstant; } template <class TInputImage> -- GitLab From d5b2026db134356b63363c975bd45e5bf316d465 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 27 Mar 2018 18:27:07 +0200 Subject: [PATCH 522/567] COMP: fix compilation of MPIVrtWriter --- Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h | 5 +++++ Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h index 3b21985b16..1800dc62ae 100644 --- a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h +++ b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h @@ -140,4 +140,9 @@ template <typename TImage> void WriteMPI(TImage *img, const std::string &output, } } // End namespace otb + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbMPIVrtWriter.txx" +#endif + #endif //__otbMPIVrtWriter_h diff --git a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx index db11192919..ebece9e026 100644 --- a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx +++ b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx @@ -48,7 +48,7 @@ MPIVrtWriter<TImage>::SetInput(const InputImageType *input) } template <typename TImage> -const InputImageType* +const TImage* MPIVrtWriter<TImage>::GetInput() { if (this->GetNumberOfInputs() < 1) -- GitLab From 9a45bda7621fe6b64821b663d46efc5ab112d844 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 27 Mar 2018 18:28:31 +0200 Subject: [PATCH 523/567] ENH: use the new MPIVrtWriter in OutputImageParameter --- .../src/otbWrapperOutputImageParameter.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx index a5a9401d21..dab96d903f 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx @@ -263,9 +263,14 @@ ClampAndWriteVectorImage( TInput * in , if(extension == ".vrt") { - // Use the WriteMPI function - // TODO : create a dedicated filter - //~ WriteMPI(clampFilter->GetOutput(),filename,ramValue); + // Use the MPIVrtWriter + typedef otb::MPIVrtWriter<TOutput> VRTWriterType; + + typename VRTWriterType::Pointer vrtWriter = VRTWriterType::New(); + vrtWriter->SetInput(clampFilter->GetOutput()); + vrtWriter->SetFileName(filename); + vrtWriter->SetAvailableRAM(ramValue); + ret.second = vrtWriter.GetPointer(); } #ifdef OTB_USE_SPTW else if (extension == ".tif") -- GitLab From 051e9d4e58803eec68494b164afc065244de4a0d Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 27 Mar 2018 18:57:16 +0200 Subject: [PATCH 524/567] BUG: fix handling of relative path, use dedicated macro for logs --- Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx index ebece9e026..b57518ed73 100644 --- a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx +++ b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.txx @@ -22,6 +22,7 @@ #define otbMPIVrtWriter_txx #include "otbMPIVrtWriter.h" +#include "otbMacro.h" namespace otb { @@ -163,11 +164,10 @@ MPIVrtWriter<TImage>::Update() } } std::vector<std::string> joins; - joins.push_back(itksys::SystemTools::GetFilenamePath(output).append("/")); - joins.push_back(itksys::SystemTools::GetFilenameWithoutExtension(output)); + itksys::SystemTools::SplitPath(output, joins); + joins.back() = itksys::SystemTools::GetFilenameWithoutExtension(output); std::string prefix = itksys::SystemTools::JoinPath(joins); - // Data type std::string dataTypeStr = "Float32"; GDALImageIO::Pointer gdalImageIO; @@ -287,7 +287,7 @@ MPIVrtWriter<TImage>::Update() int tileIndexY = currentRegion.GetIndex()[1]; std::stringstream tileFileName; tileFileName <<prefix<<"_"<<tileIndexX<<"_"<<tileIndexY<<"_"<<tileSizeX<<"_"<<tileSizeY<<".tif"; - std::cout<<tileFileName.str()<<std::endl; + otbDebugMacro(<<tileFileName.str()); GDALDataset *dataset = (GDALDataset*) GDALOpen(tileFileName.str().c_str(), GA_ReadOnly); -- GitLab From 48c5bbf284baaef6e56a60eaa4c8b5a8e8501613 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Wed, 28 Mar 2018 09:52:23 +0200 Subject: [PATCH 525/567] DOC: add doxygen doc for SampleAugmentationFilter --- .../Sampling/include/otbSampleAugmentationFilter.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h index e06f03b0ab..99bf925f50 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h @@ -28,8 +28,18 @@ namespace otb { -/** \class SampleAugmentationFilter -This class + +/** + * \class SampleAugmentationFilter + * + * \brief Filter to generate synthetic samples from existing ones + * + * This class generates synthetic samples from existing ones either by + * replication, jitter (adding gaussian noise to the features of + * existing samples) or SMOTE (linear combination of pairs + * neighbouring samples of the same class. + * + * \ingroup OTBSampling */ class ITK_EXPORT SampleAugmentationFilter : -- GitLab From 1e9112377787a8f06787ed8e5f40ef29e0c72139 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Wed, 28 Mar 2018 16:45:52 +0200 Subject: [PATCH 526/567] ENH: non templated class txx moved to cxx --- .../Learning/Sampling/include/otbSampleAugmentationFilter.h | 4 ---- Modules/Learning/Sampling/src/CMakeLists.txt | 3 ++- .../otbSampleAugmentationFilter.cxx} | 4 ---- 3 files changed, 2 insertions(+), 9 deletions(-) rename Modules/Learning/Sampling/{include/otbSampleAugmentationFilter.txx => src/otbSampleAugmentationFilter.cxx} (98%) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h index 99bf925f50..074bbe6a1f 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h @@ -171,8 +171,4 @@ private: } // end namespace otb -#ifndef OTB_MANUAL_INSTANTIATION -#include "otbSampleAugmentationFilter.txx" -#endif - #endif diff --git a/Modules/Learning/Sampling/src/CMakeLists.txt b/Modules/Learning/Sampling/src/CMakeLists.txt index 8504c688f4..bef592365b 100644 --- a/Modules/Learning/Sampling/src/CMakeLists.txt +++ b/Modules/Learning/Sampling/src/CMakeLists.txt @@ -21,7 +21,8 @@ set(OTBSampling_SRC otbSamplingRateCalculator.cxx otbSamplingRateCalculatorList.cxx -) + otbSampleAugmentationFilter.cxx + ) add_library(OTBSampling ${OTBSampling_SRC}) target_link_libraries(OTBSampling diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx b/Modules/Learning/Sampling/src/otbSampleAugmentationFilter.cxx similarity index 98% rename from Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx rename to Modules/Learning/Sampling/src/otbSampleAugmentationFilter.cxx index 8976c1c55b..5778de0d93 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.txx +++ b/Modules/Learning/Sampling/src/otbSampleAugmentationFilter.cxx @@ -18,9 +18,6 @@ * limitations under the License. */ -#ifndef otbSampleAugmentationFilter_txx -#define otbSampleAugmentationFilter_txx - #include "otbSampleAugmentationFilter.h" #include "stdint.h" //needed for uintptr_t @@ -270,4 +267,3 @@ SampleAugmentationFilter } } // end namespace otb -#endif -- GitLab From 477699742a01a1eb2d79546f173fa0090e5c7478 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 28 Mar 2018 17:23:14 +0200 Subject: [PATCH 527/567] SuperBuild: make sure shark library goes to install/lib --- SuperBuild/CMake/External_shark.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/SuperBuild/CMake/External_shark.cmake b/SuperBuild/CMake/External_shark.cmake index 5a3c6d0a74..741a46008b 100644 --- a/SuperBuild/CMake/External_shark.cmake +++ b/SuperBuild/CMake/External_shark.cmake @@ -45,6 +45,7 @@ ExternalProject_Add(SHARK -DENABLE_HDF5:BOOL=OFF -DENABLE_CBLAS:BOOL=OFF -DENABLE_OPENMP:BOOL=${OTB_USE_OPENMP} + -DSHARK_INSTALL_LIB_DIR:STRING=lib/ ${SHARK_SB_CONFIG} CMAKE_COMMAND ${SB_CMAKE_COMMAND} LOG_DOWNLOAD 1 -- GitLab From 3556522846ab1ce85a0b997f9c34844fa1509411 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 28 Mar 2018 19:01:11 +0200 Subject: [PATCH 528/567] COMP: allow tests to link with optional deps, no dragged by module lib --- CMake/OTBModuleMacros.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMake/OTBModuleMacros.cmake b/CMake/OTBModuleMacros.cmake index 0938a0f2fb..afb9a29f5c 100644 --- a/CMake/OTBModuleMacros.cmake +++ b/CMake/OTBModuleMacros.cmake @@ -277,6 +277,12 @@ macro(otb_module_test) foreach(dep IN LISTS OTB_MODULE_${otb-module-test}_DEPENDS) list(APPEND ${otb-module-test}_LIBRARIES "${${dep}_LIBRARIES}") endforeach() + # make sure the test can link with optional libs + foreach(dep IN LISTS OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS) + if (${dep}_ENABLED) + list(APPEND ${otb-module-test}_LIBRARIES "${${dep}_LIBRARIES}") + endif() + endforeach() endmacro() macro(otb_module_warnings_disable) -- GitLab From 814cd85da28e870c3d51a3ae20aae991c02f51bc Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 29 Mar 2018 10:46:46 +0200 Subject: [PATCH 529/567] COMP: proper export of library OTBSampling --- .../Learning/Sampling/include/otbSampleAugmentationFilter.h | 3 ++- Modules/Learning/Sampling/include/otbSamplingRateCalculator.h | 3 ++- .../Learning/Sampling/include/otbSamplingRateCalculatorList.h | 3 ++- Modules/Learning/Sampling/otb-module.cmake | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h index 074bbe6a1f..63b8af0a7a 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentationFilter.h @@ -24,6 +24,7 @@ #include "itkProcessObject.h" #include "otbOGRDataSourceWrapper.h" #include "otbSampleAugmentation.h" +#include "OTBSamplingExport.h" namespace otb { @@ -42,7 +43,7 @@ namespace otb * \ingroup OTBSampling */ -class ITK_EXPORT SampleAugmentationFilter : +class OTBSampling_EXPORT SampleAugmentationFilter : public itk::ProcessObject { public: diff --git a/Modules/Learning/Sampling/include/otbSamplingRateCalculator.h b/Modules/Learning/Sampling/include/otbSamplingRateCalculator.h index e16e8a9a48..04517fb15a 100644 --- a/Modules/Learning/Sampling/include/otbSamplingRateCalculator.h +++ b/Modules/Learning/Sampling/include/otbSamplingRateCalculator.h @@ -24,6 +24,7 @@ #include "itkImageRegion.h" #include "itkVectorContainer.h" #include <set> +#include "OTBSamplingExport.h" namespace otb { @@ -36,7 +37,7 @@ namespace otb * \ingroup OTBSampling */ -class ITK_EXPORT SamplingRateCalculator +class OTBSampling_EXPORT SamplingRateCalculator : public itk::Object { public: diff --git a/Modules/Learning/Sampling/include/otbSamplingRateCalculatorList.h b/Modules/Learning/Sampling/include/otbSamplingRateCalculatorList.h index 7bc78c188d..ad9d86a54e 100644 --- a/Modules/Learning/Sampling/include/otbSamplingRateCalculatorList.h +++ b/Modules/Learning/Sampling/include/otbSamplingRateCalculatorList.h @@ -23,6 +23,7 @@ #include "otbSamplingRateCalculator.h" #include "otbObjectList.h" +#include "OTBSamplingExport.h" namespace otb { @@ -37,7 +38,7 @@ namespace otb * * \ingroup OTBSampling */ -class ITK_EXPORT SamplingRateCalculatorList +class OTBSampling_EXPORT SamplingRateCalculatorList : public ObjectList<SamplingRateCalculator> { public: diff --git a/Modules/Learning/Sampling/otb-module.cmake b/Modules/Learning/Sampling/otb-module.cmake index 4eb65c3982..2b8ca50f8a 100644 --- a/Modules/Learning/Sampling/otb-module.cmake +++ b/Modules/Learning/Sampling/otb-module.cmake @@ -21,6 +21,7 @@ set(DOCUMENTATION "This module contains OTB sampling framework.") otb_module(OTBSampling + ENABLE_SHARED DEPENDS OTBCommon OTBConversion -- GitLab From 3ea7ef42a9945ce98d6dafacbd1bf49bd1428466 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 29 Mar 2018 11:06:37 +0200 Subject: [PATCH 530/567] COMP: wrong usage of reverse_iterator --- Modules/Core/ObjectList/include/otbObjectList.h | 2 +- Modules/Core/ObjectList/include/otbObjectList.txx | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Modules/Core/ObjectList/include/otbObjectList.h b/Modules/Core/ObjectList/include/otbObjectList.h index 2f14d80117..7c3737c88d 100644 --- a/Modules/Core/ObjectList/include/otbObjectList.h +++ b/Modules/Core/ObjectList/include/otbObjectList.h @@ -468,7 +468,7 @@ public: friend class ConstIterator; friend class ReverseIterator; /** typedef of the internal iterator */ - typedef typename InternalContainerType::reverse_iterator InternalReverseConstIteratorType; + typedef typename InternalContainerType::const_reverse_iterator InternalReverseConstIteratorType; /** Constructor */ ReverseConstIterator() {}; /** Constructor with iternal iterator parameter */ diff --git a/Modules/Core/ObjectList/include/otbObjectList.txx b/Modules/Core/ObjectList/include/otbObjectList.txx index 9fcbc82a8a..84f600c6fd 100644 --- a/Modules/Core/ObjectList/include/otbObjectList.txx +++ b/Modules/Core/ObjectList/include/otbObjectList.txx @@ -246,7 +246,11 @@ typename ObjectList<TObject>::ReverseIterator ObjectList<TObject> ::Insert(ReverseIterator position, ObjectPointerType element) { - ReverseIterator iter(m_InternalContainer.insert(position.GetIter(), element)); + ReverseIterator iter( + InternalContainerType::reverse_iterator( + m_InternalContainer.insert(position.GetIter().base(), element) + ) + ); this->Modified(); return iter; } -- GitLab From ac991f09616f31682467427e9c9a8a6eca9a8d46 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 29 Mar 2018 11:11:25 +0200 Subject: [PATCH 531/567] COMP: missing exports for Triplet --- Modules/Learning/Sampling/include/otbSamplingRateCalculator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Learning/Sampling/include/otbSamplingRateCalculator.h b/Modules/Learning/Sampling/include/otbSamplingRateCalculator.h index 04517fb15a..c16a758a5d 100644 --- a/Modules/Learning/Sampling/include/otbSamplingRateCalculator.h +++ b/Modules/Learning/Sampling/include/otbSamplingRateCalculator.h @@ -50,7 +50,7 @@ public: /** typdefs **/ typedef std::map<std::string, unsigned long> ClassCountMapType; typedef ClassCountMapType::const_iterator constItMapType; - typedef struct Triplet + typedef struct OTBSampling_EXPORT Triplet { unsigned long Required; unsigned long Tot; -- GitLab From d0e2ae711541bd809e62e135cad19d572abc2290 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 29 Mar 2018 15:09:31 +0200 Subject: [PATCH 532/567] PKG: fix packaging test (app name must be consistent) --- .../app/otbImageDimensionalityReduction.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx index 1df2c463fc..d9dd8e8816 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbImageDimensionalityReduction.cxx @@ -124,12 +124,12 @@ protected: private: void DoInit() override { - SetName("DimensionalityReduction"); + SetName("ImageDimensionalityReduction"); SetDescription("Performs dimensionality reduction of the input image " "according to a dimensionality reduction model file."); // Documentation - SetDocName("DimensionalityReduction"); + SetDocName("Image Dimensionality Reduction"); SetDocLongDescription("This application reduces the dimension of an input" " image, based on a machine learning model file produced by" " the TrainDimensionalityReduction application. Pixels of the " -- GitLab From 9d66a51f8ce0663dce414446bcec6d0414b63b19 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 29 Mar 2018 17:38:24 +0200 Subject: [PATCH 533/567] BUG: fix confidence index in SharkKMeans --- .../include/otbSharkKMeansMachineLearningModel.txx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.txx b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.txx index 9dd43948a7..1b08d538c9 100644 --- a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.txx +++ b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.txx @@ -55,6 +55,7 @@ SharkKMeansMachineLearningModel<TInputValue, TOutputValue> m_Normalized( false ), m_K(2), m_MaximumNumberOfIterations( 10 ) { // Default set HardClusteringModel + this->m_ConfidenceIndex = true; m_ClusteringModel = boost::make_shared<ClusteringModelType>( &m_Centroids ); } @@ -174,7 +175,7 @@ SharkKMeansMachineLearningModel<TInputValue, TOutputValue> // Change quality measurement only if SoftClustering or other clustering method is used. if( quality != ITK_NULLPTR ) { - for( unsigned int qid = startIndex; qid < size; ++qid ) + for( unsigned int qid = startIndex; qid < startIndex+size; ++qid ) { quality->SetMeasurementVector( qid, static_cast<ConfidenceValueType>(1.) ); } -- GitLab From dd99b2982b609cc2bf647d0de5f42bacd98977cd Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 29 Mar 2018 18:25:30 +0200 Subject: [PATCH 534/567] ENH: LogSetupInformation in CreateInstance is too invasive --- Modules/Core/Common/src/otbLogger.cxx | 3 --- Modules/IO/TestKernel/include/otbTestMain.h | 3 ++- .../Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index b3730cf445..51cc7adae9 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -38,9 +38,6 @@ Logger::Pointer Logger::CreateInstance() defaultOutput->SetStream(std::cout); instance->AddLogOutput(defaultOutput); - - // Log setup information - instance->LogSetupInformation(); return instance; } diff --git a/Modules/IO/TestKernel/include/otbTestMain.h b/Modules/IO/TestKernel/include/otbTestMain.h index ccb70a639c..7a833306b5 100644 --- a/Modules/IO/TestKernel/include/otbTestMain.h +++ b/Modules/IO/TestKernel/include/otbTestMain.h @@ -28,7 +28,7 @@ #include <iostream> #include "itkMultiThreader.h" -#include "itkMacro.h" +#include "otbMacro.h" #include "otbOGRDriversInit.h" #include "otbTestHelper.h" @@ -298,6 +298,7 @@ int main(int ac, char* av[]) } else { + otb::Logger::Instance()->LogSetupInformation(); MainFuncPointer f = j->second; int result; try diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 7aec4f8762..b700c4c289 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -645,6 +645,8 @@ int Application::ExecuteAndWriteOutput() { m_Chrono.Restart(); + m_Logger->LogSetupInformation(); + int status = this->Execute(); if (status == 0) -- GitLab From b9073e4bebfd8b16ff63f9f87b22e2b96dfb9af2 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Fri, 30 Mar 2018 10:36:23 +0200 Subject: [PATCH 535/567] BUG: 1547 remove deprecated instructions to compile monteverdi --- .../Latex/CompilingMonteverdi.tex | 59 ------------------- .../SoftwareGuide/Latex/SoftwareGuide.tex | 4 -- 2 files changed, 63 deletions(-) delete mode 100644 Documentation/SoftwareGuide/Latex/CompilingMonteverdi.tex diff --git a/Documentation/SoftwareGuide/Latex/CompilingMonteverdi.tex b/Documentation/SoftwareGuide/Latex/CompilingMonteverdi.tex deleted file mode 100644 index 7c38627bd2..0000000000 --- a/Documentation/SoftwareGuide/Latex/CompilingMonteverdi.tex +++ /dev/null @@ -1,59 +0,0 @@ -\setcounter{secnumdepth}{3} - -\chapter{Compiling Monteverdi from source} -\label{chapter:CompilingMonteverdi} - -\section{Linux and Mac OS X} - -Compiling Monteverdi from source follows the same procedure as a regular CMake project: setup a directory for an -out-of-source build, configure and compile. - -\subsection{Monteverdi} - -Make sure OTB is compiled with at least \texttt{OTB\_USE\_QT4}, \texttt{OTB\_USE\_GLUT}, \texttt{OTB\_USE\_GLFW} and \texttt{OTB\_USE\_GLEW} set to ON. -Setup another out-of-source build environment for Monteverdi: -\begin{verbatim} -$ mkdir ~/monteverdi -$ cd ~/monteverdi -$ git clone https://git@git.orfeo-toolbox.org/git/monteverdi2.git -$ mkdir build -$ mkdir install -\end{verbatim} - -Remember to checkout the develop branch if you want the current development version: -\begin{verbatim} -$ cd ~/monteverdi/monteverdi2 -$ git checkout develop -\end{verbatim} - -CMake needs to find both OTB and QWT installation locations. -For example, set an CMake cache pre-population script with the following content: -\begin{verbatim} -# monteverdi-configuration.cmake -set(CMAKE_INSTALL_PREFIX "~/monteverdi/install" CACHE STRING "" FORCE) -set(OTB_DIR "~/OTB/install/lib/cmake/OTB-5.0" CACHE STRING "" FORCE) -set(QWT_INCLUDE_DIR "/usr/include/qwt5-qt4" CACHE STRING "" FORCE) -set(QWT_LIBRARY "/usr/lib64/libqwt.so.5" CACHE STRING "" FORCE) -\end{verbatim} - -Configure and compile monteverdi: -\begin{verbatim} -$ cd ~/monteverdi/build -$ cmake -C monteverdi-configuration.cmake ../monteverdi2 -$ make -$ make install -\end{verbatim} - -Remember to set the \texttt{OTB\_APPLICATION\_PATH} environment variable to -allow monteverdi to find the OTB applications: -\begin{verbatim} -export OTB_APPLICATION_PATH=~/OTB/build/lib/otb/applications -./bin/monteverdi -\end{verbatim} - -\section{Windows} - -Everything that is needed for Monteverdi development on Windows, including compiling from source, is covered in details on the OTB wiki at: -\begin{center} -\url{http://wiki.orfeo-toolbox.org/index.php/OTB_development_on_Windows} -\end{center} diff --git a/Documentation/SoftwareGuide/Latex/SoftwareGuide.tex b/Documentation/SoftwareGuide/Latex/SoftwareGuide.tex index c5bd1dff82..8cf39aa7a0 100644 --- a/Documentation/SoftwareGuide/Latex/SoftwareGuide.tex +++ b/Documentation/SoftwareGuide/Latex/SoftwareGuide.tex @@ -217,12 +217,8 @@ colorlinks,linkcolor={blue},citecolor={blue},urlcolor={blue}, \input{Introduction.tex} \input{Installation.tex} -%Monteverdi is integrated in OTB as a module since release 5.8 so there is no -%need to maintain a specific section regarding monteverdi compilation. -%\input{CompilingMonteverdi.tex} \input{SystemOverview.tex} - \part{Tutorials}\label{part:tutorials} \input{Tutorial.tex} -- GitLab From ba5862065f3efb6247e1927f7809282546cda09d Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Fri, 30 Mar 2018 13:04:58 +0200 Subject: [PATCH 536/567] WRG: bool literal returned from main --- .../CommandLine/src/otbApplicationLauncherCommandLine.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx b/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx index 4c5bd8a93f..72f8b84d95 100644 --- a/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx +++ b/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx @@ -270,7 +270,7 @@ int main(int argc, char* argv[]) if (argc < 2) { ShowUsage(argv); - return false; + return EXIT_FAILURE; } std::vector<std::string> vexp; @@ -302,7 +302,7 @@ int main(int argc, char* argv[]) if (vexp.empty()) { ShowUsage(argv); - return false; + return EXIT_FAILURE; } bool success = launcher->Load(vexp) && launcher->ExecuteAndWriteOutput(); -- GitLab From 76febce9e5aa20b98555aca0e297d65b0232ed78 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Fri, 30 Mar 2018 13:16:25 +0200 Subject: [PATCH 537/567] WRG: this 'if' clause does not guard --- .../Feature/Edge/include/otbLineSegmentDetector.txx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Modules/Feature/Edge/include/otbLineSegmentDetector.txx b/Modules/Feature/Edge/include/otbLineSegmentDetector.txx index c06344e183..8ff969c22c 100644 --- a/Modules/Feature/Edge/include/otbLineSegmentDetector.txx +++ b/Modules/Feature/Edge/include/otbLineSegmentDetector.txx @@ -792,8 +792,14 @@ LineSegmentDetector<TInputImage, TPrecision> l = (static_cast<double>((*it)[0]) - x) * dx + (static_cast<double>((*it)[1]) - y) * dy; w = -(static_cast<double>((*it)[0]) - x) * dy + (static_cast<double>((*it)[1]) - y) * dx; - if (l < l_min) l_min = l; if (l > l_max) l_max = l; - if (w < w_min) w_min = w; if (w > w_max) w_max = w; + if (l < l_min) + l_min = l; + if (l > l_max) + l_max = l; + if (w < w_min) + w_min = w; + if (w > w_max) + w_max = w; sum_l[static_cast < int > (vcl_floor(l) + 0.5) + Diagonal] += static_cast<MagnitudePixelType>(weight); sum_w[static_cast < int > (vcl_floor(w) + 0.5) + Diagonal] += static_cast<MagnitudePixelType>(weight); -- GitLab From 5ff771946afc3415dff84ceb261a7d65c620bc5a Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 30 Mar 2018 17:11:57 +0200 Subject: [PATCH 538/567] WRG: various warning fix --- Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx | 2 ++ Modules/Core/ObjectList/include/otbObjectList.h | 4 ++-- .../ApplicationEngine/src/otbWrapperMetaDataHelper.cxx | 6 +++--- Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx index 54fc19e190..b616fe7526 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx @@ -64,6 +64,7 @@ OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType type) GDALDatasetType * Open(const char * filename, bool readOnly , std::vector< std::string > const & options ) { #if GDAL_VERSION_NUM<2000000 + (void)options; return OGRSFDriverRegistrar::Open(filename,!readOnly); #else return (GDALDatasetType *)GDALOpenEx( @@ -87,6 +88,7 @@ void Close(GDALDatasetType * dataset) GDALDatasetType * Create(GDALDriverType * driver, const char * name , std::vector< std::string > const & options ) { #if GDAL_VERSION_NUM<2000000 + (void)options; GDALDatasetType * ds = driver->CreateDataSource(name); if(ds) diff --git a/Modules/Core/ObjectList/include/otbObjectList.h b/Modules/Core/ObjectList/include/otbObjectList.h index 7c3737c88d..80464782d4 100644 --- a/Modules/Core/ObjectList/include/otbObjectList.h +++ b/Modules/Core/ObjectList/include/otbObjectList.h @@ -72,7 +72,7 @@ public: * Get the number of elements in the vector. * \return The number of elements in the vector. */ - InternalContainerSizeType Size(void) const; + InternalContainerSizeType Size(void) const override; /** * Resize the maximal list capacity. * \param size The new maximal size of the list. @@ -104,7 +104,7 @@ public: * Get the nth element of the list as a DataObject *. * \param index The index of the object to get. */ - Superclass * GetNthDataObject(unsigned int index) const; + Superclass * GetNthDataObject(unsigned int index) const override; /** * Return the first element of the list. * \return The first element of the list. diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx index 4cf7c602e1..02ddfea898 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx @@ -30,7 +30,7 @@ namespace MetaDataHelper MDType GetType(const std::string &val) { - MDType ret; + MDType ret(MDType::String); otb::MetaDataKey::KeyType kt = otb::MetaDataKey::GetKeyType(val); switch (kt) { @@ -88,7 +88,7 @@ GetInt( const itk::MetaDataDictionary &dict, const std::string &key) { - unsigned int ret; + unsigned int ret=0; itk::ExposeMetaData<unsigned int>(dict, key, ret); return ret; } @@ -107,7 +107,7 @@ GetDouble( const itk::MetaDataDictionary &dict, const std::string &key) { - double ret; + double ret = 0.0; itk::ExposeMetaData<double>(dict, key, ret); return ret; } diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx index 5d458d0f15..d19102fa8f 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx @@ -331,7 +331,7 @@ AppliThread m_Application->GetLogger()->Fatal(string("Cannot open image ") + err.m_Filename + string(". ") + err.GetDescription() + string("\n")); emit ExceptionRaised( err.what() ); } - catch(itk::ProcessAborted& err) + catch(itk::ProcessAborted& /*err*/) { m_Application->GetLogger()->Info("Processing aborted\n"); } -- GitLab From 90652689f5f41981fbddc01706af92ae5a80925e Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Fri, 30 Mar 2018 17:54:47 +0200 Subject: [PATCH 539/567] WRG: this statement may fall through --- .../src/otbWrapperComplexOutputImageParameter.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx index b97171cb71..4218836ed7 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx @@ -259,20 +259,22 @@ ComplexOutputImageParameter::GetWriter() case ComplexImagePixelType_int16: { writer = m_ComplexVectorInt16Writer; + break; } case ComplexImagePixelType_int32: { writer = m_ComplexVectorInt32Writer; + break; } case ComplexImagePixelType_float: { writer = m_ComplexVectorFloatWriter; - break; + break; } case ComplexImagePixelType_double: { writer = m_ComplexVectorDoubleWriter; - break; + break; } } return writer; -- GitLab From 1ba1b7ce9a8a927e99b1362e296e15ebf39a78c8 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Sun, 1 Apr 2018 21:32:20 +0200 Subject: [PATCH 540/567] ENH: update shark version for ensemble model --- SuperBuild/CMake/External_shark.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SuperBuild/CMake/External_shark.cmake b/SuperBuild/CMake/External_shark.cmake index 741a46008b..ea5531cf00 100644 --- a/SuperBuild/CMake/External_shark.cmake +++ b/SuperBuild/CMake/External_shark.cmake @@ -30,8 +30,8 @@ ADD_SUPERBUILD_CMAKE_VAR(SHARK BOOST_LIBRARYDIR) ExternalProject_Add(SHARK PREFIX SHARK - URL "https://github.com/Shark-ML/Shark/archive/a48155fb9ce2f01b33d958ec6a3aaf115f330fbf.zip" - URL_MD5 a43fb09673b7a99f83b4bcf88dc5a109 + URL "https://github.com/Shark-ML/Shark/archive/91595920f02ad90217465e7f4c100cd165d9947e.zip" + URL_MD5 09ee12050ed4236db252adbc407a52ce SOURCE_DIR ${SHARK_SB_SRC} BINARY_DIR ${SHARK_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} -- GitLab From e055fb08c199accee7210ecb748de98721791597 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 3 Apr 2018 08:32:03 +0200 Subject: [PATCH 541/567] BUG: correcting typo --- Modules/Core/Streaming/include/otbStreamingManager.txx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/Streaming/include/otbStreamingManager.txx b/Modules/Core/Streaming/include/otbStreamingManager.txx index 1d76ff1fe4..f1fd34df5b 100644 --- a/Modules/Core/Streaming/include/otbStreamingManager.txx +++ b/Modules/Core/Streaming/include/otbStreamingManager.txx @@ -149,7 +149,7 @@ StreamingManager<TImage>::EstimateOptimalNumberOfDivisions(itk::DataObject * inp unsigned int optimalNumberOfDivisions = otb::PipelineMemoryPrintCalculator::EstimateOptimalNumberOfStreamDivisions(pipelineMemoryPrint, availableRAMInBytes); - otbLogMacro(Info,<<"Estimated memory for full processing: "<<pipelineMemoryPrint * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<"MB (avail.: "<<availableRAMInBytes * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<" NB), optimal image partitioning: "<<optimalNumberOfDivisions<<" blocks"); + otbLogMacro(Info,<<"Estimated memory for full processing: "<<pipelineMemoryPrint * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<"MB (avail.: "<<availableRAMInBytes * otb::PipelineMemoryPrintCalculator::ByteToMegabyte<<" MB), optimal image partitioning: "<<optimalNumberOfDivisions<<" blocks"); return optimalNumberOfDivisions; } -- GitLab From 64dfcac955fba513bf1852ede0aa3113acd8e27e Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 3 Apr 2018 09:33:52 +0200 Subject: [PATCH 542/567] REFAC: new default behaviour --- .../AppImageUtils/app/otbExtractROI.cxx | 91 +++++++++++-------- 1 file changed, 54 insertions(+), 37 deletions(-) diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index 66f2886edc..2320c6c127 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -249,6 +249,21 @@ private: void DoUpdateParameters() override { + if( GetParameterString("mode") != "standard" ) + { + this->DisableParameter("startx"); + this->DisableParameter("starty"); + this->DisableParameter("sizex"); + this->DisableParameter("sizey"); + } + else + { + this->EnableParameter("startx"); + this->EnableParameter("starty"); + this->EnableParameter("sizex"); + this->EnableParameter("sizey"); + } + if ( HasValue("in") ) { ImageType* inImage = GetParameterImage("in"); @@ -265,21 +280,36 @@ private: && !HasUserValue( "mode.radius.cy" ); // Update the sizes only if the user has not defined a size - if (!HasUserValue("sizex") && !HasUserValue("sizey") ) + ImageType::RegionType currentLargest; + currentLargest.SetSize( 0 , GetParameterInt("sizex") ); // need a methode to get default value + currentLargest.SetSize( 1 , GetParameterInt("sizey") ); // need a methode to get default value + currentLargest.SetIndex( 0, 0 ); + currentLargest.SetIndex( 1, 0 ); + if ( currentLargest != largestRegion ) { - SetParameterInt("sizex",largestRegion.GetSize()[0]); - SetParameterInt("sizey",largestRegion.GetSize()[1]); - - // Compute extent parameter with default sizex and sizey - if ( GetParameterString( "mode" ) == "extent" && userExtent ) - ComputeExtentFromIndex( inImage, largestRegion ); + // Put the limit of the index and the size relative the image + SetMaximumParameterIntValue("sizex", largestRegion.GetSize(0)); + SetMaximumParameterIntValue("sizey", largestRegion.GetSize(1)); + SetMaximumParameterIntValue("startx", largestRegion.GetSize(0)); + SetMaximumParameterIntValue("starty", largestRegion.GetSize(1)); + + SetDefaultParameterInt( "sizex" , largestRegion.GetSize(0) ); + SetDefaultParameterInt( "sizey" , largestRegion.GetSize(1) ); + // if ( !HasUserValue("sizex") ) + // SetParameterInt( "sizex" , largestRegion.GetSize(0) ); + // if ( !HasUserValue("sizey") ) + // SetParameterInt( "sizey" , largestRegion.GetSize(1) ); // Compute radius parameter with default sizex and sizey if ( GetParameterString( "mode" ) == "radius" && userRadius ) ComputeRadiusFromIndex( inImage , largestRegion ); + // Compute extent parameter with default sizex and sizey + if ( GetParameterString( "mode" ) == "extent" && userExtent ) + ComputeExtentFromIndex( inImage, largestRegion ); } + unsigned int nbComponents = inImage->GetNumberOfComponentsPerPixel(); ListViewParameter *clParam = dynamic_cast<ListViewParameter*>(GetParameterByKey("cl")); @@ -296,20 +326,11 @@ private: } } - // Put the limit of the index and the size relative the image - - SetMaximumParameterIntValue("sizex", largestRegion.GetSize(0)); - SetMaximumParameterIntValue("sizey", largestRegion.GetSize(1)); - SetMaximumParameterIntValue("startx", largestRegion.GetSize(0)); - SetMaximumParameterIntValue("starty", largestRegion.GetSize(1)); - - // Update the start and size parameter depending on the mode if ( GetParameterString("mode") == "extent" && !userExtent) ComputeIndexFromExtent(); if (GetParameterString("mode") == "radius" && !userRadius) ComputeIndexFromRadius(); - // Crop the roi region to be included in the largest possible // region @@ -327,24 +348,13 @@ private: this->SetParameterRole("starty",Role_Output); this->SetParameterRole("sizex",Role_Output); this->SetParameterRole("sizey",Role_Output); - this->DisableParameter("startx"); - this->DisableParameter("starty"); - this->DisableParameter("sizex"); - this->DisableParameter("sizey"); } - - else if(GetParameterString("mode")=="standard" || - GetParameterString("mode")=="extent" || - GetParameterString("mode")== "radius" ) + else { this->SetParameterRole("startx",Role_Input); this->SetParameterRole("starty",Role_Input); this->SetParameterRole("sizex",Role_Input); this->SetParameterRole("sizey",Role_Input); - this->EnableParameter("startx"); - this->EnableParameter("starty"); - this->EnableParameter("sizex"); - this->EnableParameter("sizey"); } } @@ -636,7 +646,7 @@ private: if ( GetParameterString("mode.radius.unitr") == "pxl" ) { int rad = std::min( centeri[ 0 ], centeri[ 1 ] ); - SetParameterFloat( "mode.radius.r" , rad); + SetDefaultParameterFloat( "mode.radius.r" , rad); } if ( GetParameterString("mode.radius.unitr") == "phy" ) { @@ -645,19 +655,22 @@ private: input->TransformIndexToPhysicalPoint(helpRxi,helpRxp); input->TransformIndexToPhysicalPoint(helpRyi,helpRyp); float rad = std::min( helpRxp[0] - helpRyp[0] , helpRyp[1] - helpRxp[1] ); - SetParameterFloat( "mode.radius.r" , rad); + SetDefaultParameterFloat( "mode.radius.r" , rad); } + // if ( !HasUserValue( "mode.radius.r" ) + // setvalueasdefault + if ( GetParameterString("mode.radius.unitc") == "pxl" ) { - SetParameterFloat( "mode.radius.cx" , centeri[0]); - SetParameterFloat( "mode.radius.cy" , centeri[1]) ; + SetDefaultParameterFloat( "mode.radius.cx" , centeri[0] ); + SetDefaultParameterFloat( "mode.radius.cy" , centeri[1] ); } if ( GetParameterString("mode.radius.unitc") == "phy" ) { - itk::Point<float, 2> centerp , helpRp; + itk::Point<float, 2> centerp ; input->TransformIndexToPhysicalPoint(centeri,centerp); - SetParameterFloat( "mode.radius.cx" , centerp[0]); - SetParameterFloat( "mode.radius.cy" , centerp[1]) ; + SetDefaultParameterFloat( "mode.radius.cx" , centerp[0] ); + SetDefaultParameterFloat( "mode.radius.cy" , centerp[1] ); } if ( GetParameterString("mode.radius.unitc") == "lonlat" ) { @@ -668,9 +681,13 @@ private: itk::Point<float, 2> centerp_in, centerp_out; input->TransformIndexToPhysicalPoint(centeri,centerp_in); centerp_out = rsTransform->TransformPoint( centerp_in ); - SetParameterFloat( "mode.radius.cx" , centerp_out[ 0 ]); - SetParameterFloat( "mode.radius.cy" , centerp_out[ 1 ]); + SetDefaultParameterFloat( "mode.radius.cx" , centerp_out[ 0 ]); + SetDefaultParameterFloat( "mode.radius.cy" , centerp_out[ 1 ]); } + // if ( !HasUserValue( "mode.radius.cx")) + //setasdefault + // if ( !HasUserValue( "mode.radius.cy")) + //setasdefault } void -- GitLab From 0839b9100c79508e4c5784dd1c380a0b22b8bf00 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 3 Apr 2018 11:35:59 +0200 Subject: [PATCH 543/567] ENH: add getters for default float and int value --- .../include/otbWrapperApplication.h | 21 ++++++++- .../src/otbWrapperApplication.cxx | 43 +++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 4748ab0c5d..421ef9a4a7 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -307,7 +307,7 @@ public: */ bool IsParameterMissing(const std::string &key) const; - /* Set an default integer value, must used in the + /* Set a default integer value, must be used in the * DoInit when setting a value by default * for the parameter * @@ -319,7 +319,17 @@ public: */ void SetDefaultParameterInt(std::string parameter, int value); - /* Set a default floating value, must used in the + /* Get the default integer value of a parameter + * + * Can be called for types : + * \li ParameterType_Int + * \li ParameterType_Float + * \li ParameterType_Radius + * \li ParameterType_Choice + */ + int GetDefaultParameterInt(std::string parameter); + + /* Set a default floating value, must be used in the * DoInit when setting a value by default * for the parameter * @@ -328,6 +338,13 @@ public: */ void SetDefaultParameterFloat(std::string parameter, float value); + /* Get the default floating value of a parameter + * + * Can be called for types : + * \li ParameterType_Float + */ + float GetDefaultParameterFloat(std::string parameter); + /** Set a default pixel type for an output image parameter * * \param[in] parameter Name of the output image parameter diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 7aec4f8762..7dbba9892d 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1040,6 +1040,37 @@ void Application::SetDefaultParameterInt(std::string parameter, int value) } } +int Application::GetDefaultParameterInt(std::string parameter) +{ + Parameter* param = GetParameterByKey(parameter); + int ret = 0 ; + if (dynamic_cast<RadiusParameter*>(param)) + { + RadiusParameter* paramRadius = dynamic_cast<RadiusParameter*>(param); + ret = paramRadius->GetDefaultValue(); + } + else if (dynamic_cast<IntParameter*>(param)) + { + IntParameter* paramInt = dynamic_cast<IntParameter*>(param); + ret = paramInt->GetDefaultValue(); + } + else if (dynamic_cast<FloatParameter*>(param)) + { + FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); + ret = paramFloat->GetDefaultValue(); + } + else if (dynamic_cast<RAMParameter*>(param)) + { + RAMParameter* paramRAM = dynamic_cast<RAMParameter*>(param); + ret = paramRAM->GetDefaultValue(); + } + else + { + // log + } + return ret; +} + void Application::SetDefaultParameterFloat(std::string parameter, float value) { Parameter* param = GetParameterByKey(parameter); @@ -1052,6 +1083,18 @@ void Application::SetDefaultParameterFloat(std::string parameter, float value) } } +float Application::GetDefaultParameterFloat(std::string parameter) +{ + Parameter* param = GetParameterByKey(parameter); + + if (dynamic_cast<FloatParameter*>(param)) + { + FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); + return paramFloat->GetDefaultValue(); + } + return 0; +} + void Application::SetDefaultOutputPixelType(std::string parameter, ImagePixelType type) { Parameter* param = GetParameterByKey(parameter); -- GitLab From 1b4d2e087cf89ca7d159db67fa9124e43ef0c5fb Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 3 Apr 2018 14:43:09 +0200 Subject: [PATCH 544/567] REFAC: get rid of useless this --- .../AppImageUtils/app/otbExtractROI.cxx | 97 +++++++++---------- 1 file changed, 47 insertions(+), 50 deletions(-) diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index 2320c6c127..87e21aba12 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -249,62 +249,52 @@ private: void DoUpdateParameters() override { - if( GetParameterString("mode") != "standard" ) - { - this->DisableParameter("startx"); - this->DisableParameter("starty"); - this->DisableParameter("sizex"); - this->DisableParameter("sizey"); - } - else - { - this->EnableParameter("startx"); - this->EnableParameter("starty"); - this->EnableParameter("sizex"); - this->EnableParameter("sizey"); - } - if ( HasValue("in") ) { ImageType* inImage = GetParameterImage("in"); inImage->UpdateOutputInformation(); ImageType::RegionType largestRegion = inImage->GetLargestPossibleRegion(); - bool userExtent = !HasUserValue( "mode.extent.ulx" ) \ - && !HasUserValue( "mode.extent.uly" ) \ - && !HasUserValue( "mode.extent.lrx" ) \ - && !HasUserValue( "mode.extent.lry" ); + // bool userExtent = !HasUserValue( "mode.extent.ulx" ) \ + // && !HasUserValue( "mode.extent.uly" ) \ + // && !HasUserValue( "mode.extent.lrx" ) \ + // && !HasUserValue( "mode.extent.lry" ); - bool userRadius = !HasUserValue( "mode.radius.r" ) \ - && !HasUserValue( "mode.radius.cx" ) \ - && !HasUserValue( "mode.radius.cy" ); + // bool userRadius = !HasUserValue( "mode.radius.r" ) \ + // && !HasUserValue( "mode.radius.cx" ) \ + // && !HasUserValue( "mode.radius.cy" ); - // Update the sizes only if the user has not defined a size ImageType::RegionType currentLargest; - currentLargest.SetSize( 0 , GetParameterInt("sizex") ); // need a methode to get default value - currentLargest.SetSize( 1 , GetParameterInt("sizey") ); // need a methode to get default value - currentLargest.SetIndex( 0, 0 ); - currentLargest.SetIndex( 1, 0 ); - if ( currentLargest != largestRegion ) + currentLargest.SetSize( 0 , GetDefaultParameterInt("sizex") ); // need a methode to get default value + currentLargest.SetSize( 1 , GetDefaultParameterInt("sizey") ); // need a methode to get default value + currentLargest.SetIndex( 1 , GetDefaultParameterInt("starty") ); + currentLargest.SetIndex( 0 , GetDefaultParameterInt("startx") ); + // Update default only if largest has changed + if ( !(currentLargest == largestRegion) ) { + std::cout<<"Reseting default value"<<std::endl; // Put the limit of the index and the size relative the image - SetMaximumParameterIntValue("sizex", largestRegion.GetSize(0)); - SetMaximumParameterIntValue("sizey", largestRegion.GetSize(1)); - SetMaximumParameterIntValue("startx", largestRegion.GetSize(0)); - SetMaximumParameterIntValue("starty", largestRegion.GetSize(1)); - + SetMaximumParameterIntValue( "sizex" , largestRegion.GetSize(0) ); + SetMaximumParameterIntValue( "sizey" , largestRegion.GetSize(1) ); + SetMaximumParameterIntValue( "startx" , + largestRegion.GetIndex(0) + largestRegion.GetSize(0) ); + SetMaximumParameterIntValue( "starty" , + largestRegion.GetIndex(1) + largestRegion.GetSize(1) ); + SetDefaultParameterInt( "sizex" , largestRegion.GetSize(0) ); SetDefaultParameterInt( "sizey" , largestRegion.GetSize(1) ); + SetDefaultParameterInt( "startx" , largestRegion.GetIndex(0) ); + SetDefaultParameterInt( "starty" , largestRegion.GetIndex(1) ); // if ( !HasUserValue("sizex") ) // SetParameterInt( "sizex" , largestRegion.GetSize(0) ); // if ( !HasUserValue("sizey") ) // SetParameterInt( "sizey" , largestRegion.GetSize(1) ); // Compute radius parameter with default sizex and sizey - if ( GetParameterString( "mode" ) == "radius" && userRadius ) + // if ( GetParameterString( "mode" ) == "radius" && userRadius ) ComputeRadiusFromIndex( inImage , largestRegion ); // Compute extent parameter with default sizex and sizey - if ( GetParameterString( "mode" ) == "extent" && userExtent ) + // if ( GetParameterString( "mode" ) == "extent" && userExtent ) ComputeExtentFromIndex( inImage, largestRegion ); } @@ -327,34 +317,34 @@ private: } // Update the start and size parameter depending on the mode - if ( GetParameterString("mode") == "extent" && !userExtent) + if ( GetParameterString("mode") == "extent" )//&& !userExtent) ComputeIndexFromExtent(); - if (GetParameterString("mode") == "radius" && !userRadius) + if (GetParameterString("mode") == "radius" )//&& !userRadius) ComputeIndexFromRadius(); // Crop the roi region to be included in the largest possible // region - if(!this->CropRegionOfInterest()) + /* if(!this->CropRegionOfInterest()) { // Put the index of the ROI to origin and try to crop again SetParameterInt("startx",0); SetParameterInt("starty",0); this->CropRegionOfInterest(); - } + }*/ if(GetParameterString("mode")=="fit") { - this->SetParameterRole("startx",Role_Output); - this->SetParameterRole("starty",Role_Output); - this->SetParameterRole("sizex",Role_Output); - this->SetParameterRole("sizey",Role_Output); + SetParameterRole("startx",Role_Output); + SetParameterRole("starty",Role_Output); + SetParameterRole("sizex",Role_Output); + SetParameterRole("sizey",Role_Output); } else { - this->SetParameterRole("startx",Role_Input); - this->SetParameterRole("starty",Role_Input); - this->SetParameterRole("sizex",Role_Input); - this->SetParameterRole("sizey",Role_Input); + SetParameterRole("startx",Role_Input); + SetParameterRole("starty",Role_Input); + SetParameterRole("sizex",Role_Input); + SetParameterRole("sizey",Role_Input); } } @@ -365,6 +355,10 @@ private: MandatoryOff("starty"); MandatoryOff("sizex"); MandatoryOff("sizey"); + DisableParameter("startx"); + DisableParameter("starty"); + DisableParameter("sizex"); + DisableParameter("sizey"); } else { @@ -372,6 +366,10 @@ private: MandatoryOn("starty"); MandatoryOn("sizex"); MandatoryOn("sizey"); + EnableParameter("startx"); + EnableParameter("starty"); + EnableParameter("sizex"); + EnableParameter("sizey"); } if ( GetParameterString( "mode" ) == "fit" && HasValue( "mode.fit.im" ) ) @@ -474,7 +472,6 @@ private: SetParameterInt( "sizex", lri_out[0] - uli_out[0] + 1); SetParameterInt( "sizey", lri_out[1] - uli_out[1] + 1); } - this->CropRegionOfInterest(); } void @@ -783,7 +780,7 @@ private: // Setup the DEM Handler otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev"); - FloatVectorImageType::Pointer referencePtr = this->GetParameterImage("mode.fit.im"); + FloatVectorImageType::Pointer referencePtr = GetParameterImage("mode.fit.im"); referencePtr->UpdateOutputInformation(); RSTransformType::Pointer rsTransform = RSTransformType::New(); @@ -843,7 +840,7 @@ private: } - this->CropRegionOfInterest(); + CropRegionOfInterest(); ExtractROIFilterType::Pointer extractROIFilter = ExtractROIFilterType::New(); extractROIFilter->SetInput(inImage); -- GitLab From 6adeaada715f2c338dbd3c325fbb6cd6dc5f01a6 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 3 Apr 2018 14:44:00 +0200 Subject: [PATCH 545/567] REFAC: do not set the value but the default value --- .../AppImageUtils/app/otbExtractROI.cxx | 81 +++++++++++-------- 1 file changed, 48 insertions(+), 33 deletions(-) diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index 87e21aba12..2371d985bd 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -412,18 +412,17 @@ private: ComputeIndexFromExtent() { assert( GetParameterString( "mode" ) == "extent" ); - int pixelValue = -1 ; // Compute standard parameter depending on the unit chosen by the user if (GetParameterString( "mode.extent.unit" ) == "pxl" ) { - pixelValue = std::round( GetParameterFloat( "mode.extent.ulx" ) ); + int pixelValue = std::round( GetParameterFloat( "mode.extent.ulx" ) ); SetParameterInt( "startx", pixelValue); - pixelValue = std::round( GetParameterFloat( "mode.extent.lrx" ) \ + pixelValue = std::round( GetParameterFloat( "mode.extent.lrx" ) - pixelValue ) + 1 ; SetParameterInt( "sizex", pixelValue); pixelValue = std::round( GetParameterFloat( "mode.extent.uly" ) ); SetParameterInt( "starty", pixelValue); - pixelValue = std::round( GetParameterFloat( "mode.extent.lry" ) \ + pixelValue = std::round( GetParameterFloat( "mode.extent.lry" ) - pixelValue ) + 1 ; SetParameterInt( "sizey", pixelValue); } @@ -447,7 +446,7 @@ private: SetParameterInt( "sizey", lri[1] - uli[1] + 1); } - else if( GetParameterString( "mode.extent.unit" ) == "lonlat" ) + else // if( GetParameterString( "mode.extent.unit" ) == "lonlat" ) { RSTransformType::Pointer rsTransform = RSTransformType::New(); ImageType* inImage = GetParameterImage("in"); @@ -484,24 +483,24 @@ private: lri[ 1 ] = largestRegion.GetSize()[1]; if ( GetParameterString( "mode.extent.unit" ) == "pxl" ) { - SetParameterFloat("mode.extent.ulx", uli[0]); - SetParameterFloat("mode.extent.uly", uli[1]); - SetParameterFloat("mode.extent.lrx", lri[0]); - SetParameterFloat("mode.extent.lry", lri[1]); + SetDefaultParameterFloat("mode.extent.ulx", uli[0]); + SetDefaultParameterFloat("mode.extent.uly", uli[1]); + SetDefaultParameterFloat("mode.extent.lrx", lri[0]); + SetDefaultParameterFloat("mode.extent.lry", lri[1]); } else if ( GetParameterString( "mode.extent.unit" ) == "phy" ) { itk::Point<float, 2> ulp, lrp; input->TransformIndexToPhysicalPoint(uli,ulp); - SetParameterFloat("mode.extent.ulx",ulp[0]); - SetParameterFloat("mode.extent.uly",ulp[1]); + SetDefaultParameterFloat("mode.extent.ulx",ulp[0]); + SetDefaultParameterFloat("mode.extent.uly",ulp[1]); input->TransformIndexToPhysicalPoint(lri,lrp); - SetParameterFloat("mode.extent.lrx",lrp[0]); - SetParameterFloat("mode.extent.lry",lrp[1]); + SetDefaultParameterFloat("mode.extent.lrx",lrp[0]); + SetDefaultParameterFloat("mode.extent.lry",lrp[1]); } - else if ( GetParameterString( "mode.extent.unit" ) == "lonlat" ) + else // if ( GetParameterString( "mode.extent.unit" ) == "lonlat" ) { RSTransformType::Pointer rsTransform = RSTransformType::New(); rsTransform->SetInputKeywordList( input->GetImageKeywordlist() ); @@ -510,14 +509,26 @@ private: itk::Point<float, 2> ulp_in, lrp_in , ulp_out , lrp_out; input->TransformIndexToPhysicalPoint(uli,ulp_in); ulp_out = rsTransform->TransformPoint( ulp_in ); - SetParameterFloat( "mode.extent.ulx" , ulp_out[ 0 ]); - SetParameterFloat( "mode.extent.uly" , ulp_out[ 1 ]); + SetDefaultParameterFloat( "mode.extent.ulx" , ulp_out[ 0 ]); + SetDefaultParameterFloat( "mode.extent.uly" , ulp_out[ 1 ]); input->TransformIndexToPhysicalPoint( lri , lrp_in ); lrp_out = rsTransform->TransformPoint( lrp_in ); - SetParameterFloat( "mode.extent.lrx" , lrp_out[ 0 ]); - SetParameterFloat( "mode.extent.lry" , lrp_out[ 1 ]); + SetDefaultParameterFloat( "mode.extent.lrx" , lrp_out[ 0 ]); + SetDefaultParameterFloat( "mode.extent.lry" , lrp_out[ 1 ]); } + if ( !HasUserValue( "mode.extent.ulx" ) ) + SetParameterFloat( "mode.extent.ulx" , + GetDefaultParameterFloat( "mode.extent.ulx" ) ); + if ( !HasUserValue( "mode.extent.uly" ) ) + SetParameterFloat( "mode.extent.uly" , + GetDefaultParameterFloat( "mode.extent.uly" ) ); + if ( !HasUserValue( "mode.extent.lrx" ) ) + SetParameterFloat( "mode.extent.lrx" , + GetDefaultParameterFloat( "mode.extent.lrx" ) ); + if ( !HasUserValue( "mode.extent.lry" ) ) + SetParameterFloat( "mode.extent.lry" , + GetDefaultParameterFloat( "mode.extent.lry" ) ); } void @@ -526,7 +537,7 @@ private: int pixelValue = -1; assert( GetParameterString( "mode" ) == "radius" ); // First compute sizex sizey thanks to the radius - if ( HasUserValue( "mode.radius.r" ) ) + if ( HasValue( "mode.radius.r" ) ) { if ( GetParameterString( "mode.radius.unitr" ) == "pxl" ) { @@ -577,20 +588,19 @@ private: } // Then compute startx and starty - bool size = ( HasValue("sizex") && HasValue("sizey") ); - if ( size ) + if ( HasValue("sizex") && HasValue("sizey") ) { int radiusxi = GetParameterInt("sizex") / 2 ; int radiusyi = GetParameterInt("sizey") / 2 ; - if ( GetParameterString( "mode.radius.unitc" ) == "pxl" && size ) + if ( GetParameterString( "mode.radius.unitc" ) == "pxl" ) { pixelValue = std::round(GetParameterFloat( "mode.radius.cx" )); SetParameterInt( "startx", pixelValue - radiusxi); pixelValue = std::round(GetParameterFloat( "mode.radius.cy" )); SetParameterInt( "starty", pixelValue - radiusyi); } - if ( GetParameterString( "mode.radius.unitc" ) == "phy" && size ) + else if ( GetParameterString( "mode.radius.unitc" ) == "phy" ) { ImageType * inImage = GetParameterImage("in"); itk::Point<float, 2> centerp; @@ -604,7 +614,7 @@ private: SetParameterInt( "starty", centeri[1] - radiusyi); } } - if ( GetParameterString( "mode.radius.unitc" ) == "lonlat" && size ) + else // if ( GetParameterString( "mode.radius.unitc" ) == "lonlat" ) { ImageType* inImage = GetParameterImage("in"); RSTransformType::Pointer rsTransform = RSTransformType::New(); @@ -645,7 +655,7 @@ private: int rad = std::min( centeri[ 0 ], centeri[ 1 ] ); SetDefaultParameterFloat( "mode.radius.r" , rad); } - if ( GetParameterString("mode.radius.unitr") == "phy" ) + else // if ( GetParameterString("mode.radius.unitr") == "phy" ) { itk::Point<float, 2> centerp , helpRxp, helpRyp; input->TransformIndexToPhysicalPoint(centeri,centerp); @@ -654,22 +664,25 @@ private: float rad = std::min( helpRxp[0] - helpRyp[0] , helpRyp[1] - helpRxp[1] ); SetDefaultParameterFloat( "mode.radius.r" , rad); } - // if ( !HasUserValue( "mode.radius.r" ) - // setvalueasdefault + if ( !HasUserValue( "mode.radius.r" ) ) + SetParameterFloat( "mode.radius.r" , + GetDefaultParameterFloat( "mode.radius.r" ) ); + + // Center if ( GetParameterString("mode.radius.unitc") == "pxl" ) { SetDefaultParameterFloat( "mode.radius.cx" , centeri[0] ); SetDefaultParameterFloat( "mode.radius.cy" , centeri[1] ); } - if ( GetParameterString("mode.radius.unitc") == "phy" ) + else if ( GetParameterString("mode.radius.unitc") == "phy" ) { itk::Point<float, 2> centerp ; input->TransformIndexToPhysicalPoint(centeri,centerp); SetDefaultParameterFloat( "mode.radius.cx" , centerp[0] ); SetDefaultParameterFloat( "mode.radius.cy" , centerp[1] ); } - if ( GetParameterString("mode.radius.unitc") == "lonlat" ) + else // if ( GetParameterString("mode.radius.unitc") == "lonlat" ) { RSTransformType::Pointer rsTransform = RSTransformType::New(); rsTransform->SetInputKeywordList( input->GetImageKeywordlist() ); @@ -681,10 +694,12 @@ private: SetDefaultParameterFloat( "mode.radius.cx" , centerp_out[ 0 ]); SetDefaultParameterFloat( "mode.radius.cy" , centerp_out[ 1 ]); } - // if ( !HasUserValue( "mode.radius.cx")) - //setasdefault - // if ( !HasUserValue( "mode.radius.cy")) - //setasdefault + if ( !HasUserValue( "mode.radius.cx") ) + SetParameterFloat( "mode.radius.cx" , + GetDefaultParameterFloat( "mode.radius.cx" ) ); + if ( !HasUserValue( "mode.radius.cy") ) + SetParameterFloat( "mode.radius.cy" , + GetDefaultParameterFloat( "mode.radius.cy" ) ); } void -- GitLab From 503a3f88a300e89dc163f558ab6f4cac57326685 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 3 Apr 2018 14:58:50 +0200 Subject: [PATCH 546/567] STYLE: Get rid of commented code --- .../AppImageUtils/app/otbExtractROI.cxx | 58 ++++++------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index 2371d985bd..3c928ac009 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -255,51 +255,39 @@ private: inImage->UpdateOutputInformation(); ImageType::RegionType largestRegion = inImage->GetLargestPossibleRegion(); - // bool userExtent = !HasUserValue( "mode.extent.ulx" ) \ - // && !HasUserValue( "mode.extent.uly" ) \ - // && !HasUserValue( "mode.extent.lrx" ) \ - // && !HasUserValue( "mode.extent.lry" ); - - // bool userRadius = !HasUserValue( "mode.radius.r" ) \ - // && !HasUserValue( "mode.radius.cx" ) \ - // && !HasUserValue( "mode.radius.cy" ); - ImageType::RegionType currentLargest; - currentLargest.SetSize( 0 , GetDefaultParameterInt("sizex") ); // need a methode to get default value - currentLargest.SetSize( 1 , GetDefaultParameterInt("sizey") ); // need a methode to get default value + currentLargest.SetSize( 0 , GetDefaultParameterInt("sizex") ); + currentLargest.SetSize( 1 , GetDefaultParameterInt("sizey") ); currentLargest.SetIndex( 1 , GetDefaultParameterInt("starty") ); currentLargest.SetIndex( 0 , GetDefaultParameterInt("startx") ); // Update default only if largest has changed - if ( !(currentLargest == largestRegion) ) + if ( currentLargest != largestRegion ) { - std::cout<<"Reseting default value"<<std::endl; - // Put the limit of the index and the size relative the image + // Setting maximum value SetMaximumParameterIntValue( "sizex" , largestRegion.GetSize(0) ); SetMaximumParameterIntValue( "sizey" , largestRegion.GetSize(1) ); SetMaximumParameterIntValue( "startx" , largestRegion.GetIndex(0) + largestRegion.GetSize(0) ); SetMaximumParameterIntValue( "starty" , largestRegion.GetIndex(1) + largestRegion.GetSize(1) ); - + // Setting default value SetDefaultParameterInt( "sizex" , largestRegion.GetSize(0) ); SetDefaultParameterInt( "sizey" , largestRegion.GetSize(1) ); SetDefaultParameterInt( "startx" , largestRegion.GetIndex(0) ); SetDefaultParameterInt( "starty" , largestRegion.GetIndex(1) ); - // if ( !HasUserValue("sizex") ) - // SetParameterInt( "sizex" , largestRegion.GetSize(0) ); - // if ( !HasUserValue("sizey") ) - // SetParameterInt( "sizey" , largestRegion.GetSize(1) ); - - // Compute radius parameter with default sizex and sizey - // if ( GetParameterString( "mode" ) == "radius" && userRadius ) - ComputeRadiusFromIndex( inImage , largestRegion ); - // Compute extent parameter with default sizex and sizey - // if ( GetParameterString( "mode" ) == "extent" && userExtent ) - ComputeExtentFromIndex( inImage, largestRegion ); + // Setting actual value + if ( !HasUserValue("sizex") ) + SetParameterFloat( "sizex" , + GetDefaultParameterFloat( "sizex" ) ); + if ( !HasUserValue("sizey") ) + SetParameterFloat( "sizey" , + GetDefaultParameterFloat( "sizey" ) ); + // Compute radius parameters default value + ComputeRadiusFromIndex( inImage , largestRegion ); + // Compute extent parameters default value + ComputeExtentFromIndex( inImage, largestRegion ); } - - unsigned int nbComponents = inImage->GetNumberOfComponentsPerPixel(); ListViewParameter *clParam = dynamic_cast<ListViewParameter*>(GetParameterByKey("cl")); @@ -317,20 +305,10 @@ private: } // Update the start and size parameter depending on the mode - if ( GetParameterString("mode") == "extent" )//&& !userExtent) + if ( GetParameterString("mode") == "extent" ) ComputeIndexFromExtent(); - if (GetParameterString("mode") == "radius" )//&& !userRadius) + if (GetParameterString("mode") == "radius" ) ComputeIndexFromRadius(); - - // Crop the roi region to be included in the largest possible - // region - /* if(!this->CropRegionOfInterest()) - { - // Put the index of the ROI to origin and try to crop again - SetParameterInt("startx",0); - SetParameterInt("starty",0); - this->CropRegionOfInterest(); - }*/ if(GetParameterString("mode")=="fit") { -- GitLab From c6bea05f9f83a6976a6a59ff5ec2edac51236305 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Tue, 3 Apr 2018 15:23:52 +0200 Subject: [PATCH 547/567] WRG: ifdef for pragma omp and include omp header file --- .../Sampling/include/otbSampleAugmentation.h | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Modules/Learning/Sampling/include/otbSampleAugmentation.h b/Modules/Learning/Sampling/include/otbSampleAugmentation.h index 84e67ffdd4..8196b3e9da 100644 --- a/Modules/Learning/Sampling/include/otbSampleAugmentation.h +++ b/Modules/Learning/Sampling/include/otbSampleAugmentation.h @@ -21,6 +21,10 @@ #ifndef otbSampleAugmentation_h #define otbSampleAugmentation_h +#ifdef _OPENMP + # include <omp.h> +#endif + #include <vector> #include <algorithm> #include <random> @@ -49,7 +53,9 @@ SampleType EstimateStds(const SampleVectorType& samples) for(size_t i=0; i<nbSamples; ++i) { auto norm_factor = 1.0/(i+1); -#pragma omp parallel for +#ifdef _OPENMP +#pragma omp parallel for +#endif for(size_t j=0; j<nbComponents; ++j) { const auto mu = means[j]; @@ -59,7 +65,9 @@ SampleType EstimateStds(const SampleVectorType& samples) means[j] = muNew; } } +#ifdef _OPENMP #pragma omp parallel for +#endif for(size_t j=0; j<nbComponents; ++j) { stds[j] = std::sqrt(stds[j]/nbSamples); @@ -77,7 +85,9 @@ void ReplicateSamples(const SampleVectorType& inSamples, { newSamples.resize(nbSamples); size_t imod{0}; +#ifdef _OPENMP #pragma omp parallel for +#endif for(size_t i=0; i<nbSamples; ++i) { if (imod == inSamples.size()) imod = 0; @@ -108,14 +118,18 @@ void JitterSamples(const SampleVectorType& inSamples, // have different stds auto stds = EstimateStds(inSamples); std::vector<std::normal_distribution<double>> gaussDis(nbComponents); +#ifdef _OPENMP #pragma omp parallel for +#endif for(size_t i=0; i<nbComponents; ++i) gaussDis[i] = std::normal_distribution<double>{0.0, stds[i]/stdFactor}; for(size_t i=0; i<nbSamples; ++i) { newSamples[i] = inSamples[std::rand()%inSamples.size()]; +#ifdef _OPENMP #pragma omp parallel for +#endif for(size_t j=0; j<nbComponents; ++j) newSamples[i][j] += gaussDis[j](gen); } @@ -157,7 +171,9 @@ void FindKNNIndices(const SampleVectorType& inSamples, { const auto nbSamples = inSamples.size(); nnVector.resize(nbSamples); + #ifdef _OPENMP #pragma omp parallel for + #endif for(size_t sampleIdx=0; sampleIdx<nbSamples; ++sampleIdx) { NNIndicesType nns; @@ -200,7 +216,9 @@ void Smote(const SampleVectorType& inSamples, FindKNNIndices(inSamples, nbNeighbors, nnVector); // The input samples are selected randomly with replacement std::srand(seed); + #ifdef _OPENMP #pragma omp parallel for + #endif for(size_t i=0; i<nbSamples; ++i) { const auto sampleIdx = std::rand()%(inSamples.size()); -- GitLab From 706a7b5a8a5c5dbea1c7a924e8cfd5fec7fda99d Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Tue, 3 Apr 2018 16:00:00 +0200 Subject: [PATCH 548/567] WRG: lastVertex may be used uninitialized in this function --- Modules/Filtering/Path/include/otbClosePathFunctor.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/Filtering/Path/include/otbClosePathFunctor.h b/Modules/Filtering/Path/include/otbClosePathFunctor.h index 90924a2b42..d880196c9f 100644 --- a/Modules/Filtering/Path/include/otbClosePathFunctor.h +++ b/Modules/Filtering/Path/include/otbClosePathFunctor.h @@ -59,6 +59,9 @@ public: if(input->GetVertexList()->Size()>0) { + //Initialization of lastVertex to GetVertexList + lastVertex = input->GetVertexList()->Begin().Value(); + for (VertexListConstIteratorType vertexIt = input->GetVertexList()->Begin(); vertexIt != input->GetVertexList()->End(); ++vertexIt) -- GitLab From 2749c2a800db431ba68f920e2ec7a8786dbbd095 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 3 Apr 2018 16:03:36 +0200 Subject: [PATCH 549/567] ENH: additional calls to LogSetupInformation, and a boolean guardian --- Modules/Core/Common/include/otbLogger.h | 11 +++- Modules/Core/Common/src/otbLogger.cxx | 51 +++++++++++++------ .../otbStreamingImageVirtualWriter.txx | 2 + .../IO/ImageIO/include/otbImageFileWriter.txx | 2 + 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/Modules/Core/Common/include/otbLogger.h b/Modules/Core/Common/include/otbLogger.h index ef420c7b23..0da8d38219 100644 --- a/Modules/Core/Common/include/otbLogger.h +++ b/Modules/Core/Common/include/otbLogger.h @@ -59,8 +59,15 @@ public: // Overwrite this to provide custom formatting of log entries std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) override; + /** Output logs about the RAM, caching and multi-threading settings */ void LogSetupInformation(); - + + /** Return true if the LogSetupInformation has already been called*/ + bool IsLogSetupInformationDone(); + + /** Set the flag m_LogSetupInfoDone to true */ + void LogSetupInformationDone(); + protected: Logger(); virtual ~Logger() ITK_OVERRIDE; @@ -71,6 +78,8 @@ private: static Pointer CreateInstance(); + bool m_LogSetupInfoDone; + }; // class Logger } // namespace otb diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index 51cc7adae9..6678aa1632 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -58,6 +58,8 @@ Logger::Logger() this->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE); this->SetHumanReadableFormat("%Y-%m-%d %H:%M:%S"); + + m_LogSetupInfoDone = false; } Logger::~Logger() @@ -66,22 +68,29 @@ Logger::~Logger() void Logger::LogSetupInformation() { - std::ostringstream oss; - - oss<<"Default RAM limit for OTB is "<<otb::ConfigurationManager::GetMaxRAMHint()<<" MB"<<std::endl; - this->Info(oss.str()); - oss.str(""); - oss.clear(); - - oss<<"GDAL maximum cache size is "<<GDALGetCacheMax64()/(1024*1024)<<" MB"<<std::endl; - this->Info(oss.str()); - oss.str(""); - oss.clear(); - - oss<<"OTB will use at most "<<itk::MultiThreader::GetGlobalDefaultNumberOfThreads()<<" threads"<<std::endl; - this->Info(oss.str()); - oss.str(""); - oss.clear(); + if (! IsLogSetupInformationDone()) + { + std::ostringstream oss; + + oss<<"Default RAM limit for OTB is "<<otb::ConfigurationManager::GetMaxRAMHint()<<" MB"<<std::endl; + this->Info(oss.str()); + oss.str(""); + oss.clear(); + + oss<<"GDAL maximum cache size is "<<GDALGetCacheMax64()/(1024*1024)<<" MB"<<std::endl; + this->Info(oss.str()); + oss.str(""); + oss.clear(); + + oss<<"OTB will use at most "<<itk::MultiThreader::GetGlobalDefaultNumberOfThreads()<<" threads"<<std::endl; + this->Info(oss.str()); + oss.str(""); + oss.clear(); + + // only switch the flag for the singleton, so that other instances can call + // LogSetupInformation() several times + Instance()->LogSetupInformationDone(); + } } std::string Logger::BuildFormattedEntry(itk::Logger::PriorityLevelType level, std::string const & content) @@ -113,4 +122,14 @@ std::string Logger::BuildFormattedEntry(itk::Logger::PriorityLevelType level, st return s.str(); } +bool Logger::IsLogSetupInformationDone() +{ + return m_LogSetupInfoDone; +} + +void Logger::LogSetupInformationDone() +{ + m_LogSetupInfoDone = true; +} + } // namespace otb diff --git a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx index ec0ae5ae6d..7336993ed3 100644 --- a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx +++ b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.txx @@ -183,6 +183,8 @@ void StreamingImageVirtualWriter<TInputImage> ::GenerateData(void) { + otb::Logger::Instance()->LogSetupInformation(); + /** * Prepare all the outputs. This may deallocate previous bulk data. */ diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index 2ddaf018bf..db7261ae70 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -281,6 +281,8 @@ ImageFileWriter<TInputImage> itkExceptionMacro(<< "No input to writer"); } + otb::Logger::Instance()->LogSetupInformation(); + /** Parse streaming modes */ if(m_FilenameHelper->StreamingTypeIsSet()) { -- GitLab From f2e7036b45e67475cc2bebc533656d4f40ed0bbc Mon Sep 17 00:00:00 2001 From: Rashad Kanavath <rashad.kanavath.email.com> Date: Tue, 3 Apr 2018 16:19:46 +0200 Subject: [PATCH 550/567] WRG: return EXIT_FAILURE and not false --- .../CommandLine/src/otbApplicationLauncherCommandLine.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx b/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx index 4c5bd8a93f..72f8b84d95 100644 --- a/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx +++ b/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx @@ -270,7 +270,7 @@ int main(int argc, char* argv[]) if (argc < 2) { ShowUsage(argv); - return false; + return EXIT_FAILURE; } std::vector<std::string> vexp; @@ -302,7 +302,7 @@ int main(int argc, char* argv[]) if (vexp.empty()) { ShowUsage(argv); - return false; + return EXIT_FAILURE; } bool success = launcher->Load(vexp) && launcher->ExecuteAndWriteOutput(); -- GitLab From 535f60380474833a557320a5afbd07350bbd5258 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 3 Apr 2018 17:02:47 +0200 Subject: [PATCH 551/567] REFAC: cleaner code and better radius computation --- .../AppImageUtils/app/otbExtractROI.cxx | 149 ++++++------------ 1 file changed, 52 insertions(+), 97 deletions(-) diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index 3c928ac009..1e4a84d465 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -370,18 +370,15 @@ private: region.SetSize(1, GetParameterInt("sizey")); region.SetIndex(0, GetParameterInt("startx")); region.SetIndex(1, GetParameterInt("starty")); - if ( HasValue("in") ) + ImageType* inImage = GetParameterImage("in"); + inImage->UpdateOutputInformation(); + if (region.Crop(inImage->GetLargestPossibleRegion())) { - ImageType* inImage = GetParameterImage("in"); - inImage->UpdateOutputInformation(); - if (region.Crop(inImage->GetLargestPossibleRegion())) - { - SetParameterInt("sizex",region.GetSize(0)); - SetParameterInt("sizey",region.GetSize(1)); - SetParameterInt("startx",region.GetIndex(0)); - SetParameterInt("starty",region.GetIndex(1)); - return true; - } + SetParameterInt("sizex",region.GetSize(0)); + SetParameterInt("sizey",region.GetSize(1)); + SetParameterInt("startx",region.GetIndex(0)); + SetParameterInt("starty",region.GetIndex(1)); + return true; } return false; } @@ -391,18 +388,13 @@ private: { assert( GetParameterString( "mode" ) == "extent" ); // Compute standard parameter depending on the unit chosen by the user + FloatVectorImageType::IndexType uli , lri; if (GetParameterString( "mode.extent.unit" ) == "pxl" ) { - int pixelValue = std::round( GetParameterFloat( "mode.extent.ulx" ) ); - SetParameterInt( "startx", pixelValue); - pixelValue = std::round( GetParameterFloat( "mode.extent.lrx" ) - - pixelValue ) + 1 ; - SetParameterInt( "sizex", pixelValue); - pixelValue = std::round( GetParameterFloat( "mode.extent.uly" ) ); - SetParameterInt( "starty", pixelValue); - pixelValue = std::round( GetParameterFloat( "mode.extent.lry" ) - - pixelValue ) + 1 ; - SetParameterInt( "sizey", pixelValue); + uli[0] = std::round( GetParameterFloat( "mode.extent.ulx" ) ); + uli[1] = std::round( GetParameterFloat( "mode.extent.uly" ) ); + lri[0] = std::round( GetParameterFloat( "mode.extent.lrx" ) ); + lri[1] = std::round( GetParameterFloat( "mode.extent.lry" ) ); } else if( GetParameterString( "mode.extent.unit" ) == "phy" ) { @@ -411,18 +403,9 @@ private: ulp[ 1 ] = GetParameterFloat( "mode.extent.uly" ); lrp[ 0 ] = GetParameterFloat( "mode.extent.lrx" ); lrp[ 1 ] = GetParameterFloat( "mode.extent.lry" ); - ImageType * inImage = GetParameterImage("in"); - FloatVectorImageType::IndexType uli , lri; inImage->TransformPhysicalPointToIndex(ulp,uli); - inImage->TransformPhysicalPointToIndex(lrp,lri); - - SetParameterInt( "startx", uli[0]); - SetParameterInt( "starty", uli[1]); - - SetParameterInt( "sizex", lri[0] - uli[0] + 1); - SetParameterInt( "sizey", lri[1] - uli[1] + 1); - + inImage->TransformPhysicalPointToIndex(lrp,lri); } else // if( GetParameterString( "mode.extent.unit" ) == "lonlat" ) { @@ -438,17 +421,13 @@ private: lrp_in[ 1 ] = GetParameterFloat( "mode.extent.lry" ); ulp_out = rsTransform->TransformPoint(ulp_in); lrp_out = rsTransform->TransformPoint(lrp_in); - - FloatVectorImageType::IndexType uli_out , lri_out; - inImage->TransformPhysicalPointToIndex(ulp_out,uli_out); - inImage->TransformPhysicalPointToIndex(lrp_out,lri_out); - - SetParameterInt( "startx", uli_out[0]); - SetParameterInt( "starty", uli_out[1]); - - SetParameterInt( "sizex", lri_out[0] - uli_out[0] + 1); - SetParameterInt( "sizey", lri_out[1] - uli_out[1] + 1); + inImage->TransformPhysicalPointToIndex(ulp_out,uli); + inImage->TransformPhysicalPointToIndex(lrp_out,lri); } + SetParameterInt( "startx", uli[0]); + SetParameterInt( "starty", uli[1]); + SetParameterInt( "sizex", lri[0] - uli[0] + 1); + SetParameterInt( "sizey", lri[1] - uli[1] + 1); } void @@ -512,18 +491,16 @@ private: void ComputeIndexFromRadius() { - int pixelValue = -1; + FloatVectorImageType::SizeType radiusi ; assert( GetParameterString( "mode" ) == "radius" ); - // First compute sizex sizey thanks to the radius if ( HasValue( "mode.radius.r" ) ) { if ( GetParameterString( "mode.radius.unitr" ) == "pxl" ) { - pixelValue = std::floor( 2 * GetParameterFloat( "mode.radius.r" ) ) + 1; - SetParameterInt( "sizey", pixelValue); - SetParameterInt( "sizex", pixelValue); + radiusi[0] = std::floor( GetParameterFloat( "mode.radius.r" ) ); + radiusi[1] = std::floor( GetParameterFloat( "mode.radius.r" ) ); } - if ( GetParameterString( "mode.radius.unitr" ) == "phy" ) + else //if ( GetParameterString( "mode.radius.unitr" ) == "phy" ) { ImageType * inImage = GetParameterImage("in"); itk::Point<float, 2> radxp , radyp , ulp ; @@ -536,47 +513,24 @@ private: radyp[1] += GetParameterFloat( "mode.radius.r" ); bool lgtx = inImage->TransformPhysicalPointToIndex( radxp , radxi ); bool lgty = inImage->TransformPhysicalPointToIndex( radyp , radyi ); - FloatVectorImageType::IndexValueType maxR = - std::min( inImage->GetLargestPossibleRegion().GetSize()[0] , - inImage->GetLargestPossibleRegion().GetSize()[1] ); - maxR = maxR / 2 - ( (maxR + 1) % 2 ); - if ( lgtx && lgty) - { - pixelValue = std::max( radxi[0] , radyi[1] ); - if ( maxR<pixelValue ) - { - pixelValue = std::min( std::min( radxi[0] , radyi[1] ) , maxR ); - } - } - else if ( lgtx ) - { - pixelValue = std::min( radxi[0] , maxR ); - } - else if ( lgty ) - { - pixelValue = std::min( radyi[1] , maxR ); - } + if ( lgtx ) + radiusi[0] = radxp[0]; else - { - pixelValue = maxR; - } - SetParameterInt( "sizey", 2 * pixelValue + 1); - SetParameterInt( "sizex", 2 * pixelValue + 1); + radiusi[0] = GetDefaultParameterInt( "sizex"); + if ( lgty ) + radiusi[1] = radyp[1]; + else + radiusi[1] = GetDefaultParameterInt( "sizey"); } } - - // Then compute startx and starty + FloatVectorImageType::IndexType centeri ; + bool isIn(true); if ( HasValue("sizex") && HasValue("sizey") ) { - int radiusxi = GetParameterInt("sizex") / 2 ; - int radiusyi = GetParameterInt("sizey") / 2 ; - if ( GetParameterString( "mode.radius.unitc" ) == "pxl" ) { - pixelValue = std::round(GetParameterFloat( "mode.radius.cx" )); - SetParameterInt( "startx", pixelValue - radiusxi); - pixelValue = std::round(GetParameterFloat( "mode.radius.cy" )); - SetParameterInt( "starty", pixelValue - radiusyi); + centeri[0] = std::round(GetParameterFloat( "mode.radius.cx" )); + centeri[1] = std::round(GetParameterFloat( "mode.radius.cy" )); } else if ( GetParameterString( "mode.radius.unitc" ) == "phy" ) { @@ -584,13 +538,7 @@ private: itk::Point<float, 2> centerp; centerp[ 0 ] = GetParameterFloat( "mode.radius.cx" ); centerp[ 1 ] = GetParameterFloat( "mode.radius.cy" ); - FloatVectorImageType::IndexType centeri ; - bool isIn = inImage->TransformPhysicalPointToIndex( centerp , centeri ); - if ( isIn ) - { - SetParameterInt( "startx", centeri[0] - radiusxi); - SetParameterInt( "starty", centeri[1] - radiusyi); - } + isIn = inImage->TransformPhysicalPointToIndex( centerp , centeri ); } else // if ( GetParameterString( "mode.radius.unitc" ) == "lonlat" ) { @@ -603,16 +551,21 @@ private: centerp_in[ 0 ] = GetParameterFloat( "mode.radius.cx" ); centerp_in[ 1 ] = GetParameterFloat( "mode.radius.cy" ); centerp_out = rsTransform->TransformPoint(centerp_in); - FloatVectorImageType::IndexType centeri_out; - bool isIn = inImage->TransformPhysicalPointToIndex( centerp_out , - centeri_out ); - if ( isIn ) - { - SetParameterInt( "startx", centeri_out[0] - radiusxi); - SetParameterInt( "starty", centeri_out[1] - radiusyi); - } + isIn = inImage->TransformPhysicalPointToIndex( centerp_out , + centeri ); } } + if ( isIn ) + { + SetParameterInt( "startx", centeri[0] - radiusi[0]); + SetParameterInt( "sizex", centeri[0] + radiusi[0] + 1 ); + SetParameterInt( "starty", centeri[1] - radiusi[1]); + SetParameterInt( "sizey", centeri[1] + radiusi[1] + 1 ); + } + else + { + // log + } } void @@ -833,7 +786,9 @@ private: } - CropRegionOfInterest(); + if ( !CropRegionOfInterest() ) + otbAppLogFATAL(<<"Could not extract the ROI as it is out of the " + "input image."); ExtractROIFilterType::Pointer extractROIFilter = ExtractROIFilterType::New(); extractROIFilter->SetInput(inImage); -- GitLab From 27976387b15ef96b1b9fa236612c45341388822e Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 3 Apr 2018 18:03:37 +0200 Subject: [PATCH 552/567] BUG: #1548: reset direction when skipcarto=true --- Modules/IO/ImageIO/include/otbImageFileReader.txx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx index c8d4fb2d0f..512be71058 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.txx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx @@ -380,6 +380,17 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> spacing[i] = 1.0; } origin[i] = 0.5*spacing[i]; + for (unsigned j = 0; j < TOutputImage::ImageDimension; ++j) + { + if (i == j) + { + direction[j][i] = 1.0; + } + else + { + direction[j][i] = 0.0; + } + } } } -- GitLab From 595484268060d045e8fafecce6dbef9d642da75d Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Tue, 3 Apr 2018 18:15:59 +0200 Subject: [PATCH 553/567] BUG: take min and max value into account : clamp when setting outside --- .../ApplicationEngine/include/otbWrapperNumericalParameter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperNumericalParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperNumericalParameter.h index de97a3471b..54871040f3 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperNumericalParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperNumericalParameter.h @@ -62,8 +62,8 @@ public: /** Set the value */ void SetValue( ScalarType value) { - // TODO check minimum/maximum - m_Value = value; + m_Value = ( value < m_MinimumValue ) ? m_MinimumValue : + ( value < m_MaximumValue ) ? value : m_MaximumValue ; // Set Active only if the parameter is not automatically set if (!GetAutomaticValue()) -- GitLab From e8f2558f0b38cdb562c683a9b4aaeb2f0633bbe2 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 3 Apr 2018 18:24:34 +0200 Subject: [PATCH 554/567] BUG: #1549: fix end-of-line reading with SamplingRateCalculator --- Modules/Learning/Sampling/src/otbSamplingRateCalculator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Learning/Sampling/src/otbSamplingRateCalculator.cxx b/Modules/Learning/Sampling/src/otbSamplingRateCalculator.cxx index a7e8f2bc3f..86de38dfb0 100644 --- a/Modules/Learning/Sampling/src/otbSamplingRateCalculator.cxx +++ b/Modules/Learning/Sampling/src/otbSamplingRateCalculator.cxx @@ -233,7 +233,7 @@ SamplingRateCalculator std::string::size_type pos5 = line.find_first_not_of(" \t", parts[2].begin() - line.begin()); std::string::size_type pos6 = line.find_last_not_of(" \t", parts[2].end() - line.begin() -1); std::string::size_type pos7 = line.find_first_not_of(" \t", parts[3].begin() - line.begin()); - std::string::size_type pos8 = line.find_last_not_of(" \t", parts[3].end() - line.begin() -1); + std::string::size_type pos8 = line.find_last_not_of(" \t\r", parts[3].end() - line.begin() -1); if (pos2 != std::string::npos && pos1 <= pos2 && pos4 != std::string::npos && pos3 <= pos4 && pos6 != std::string::npos && pos5 <= pos6 && @@ -336,7 +336,7 @@ SamplingRateCalculator std::string::size_type pos1 = line.find_first_not_of(" \t", parts[0].begin() - line.begin()); std::string::size_type pos2 = line.find_last_not_of(" \t", parts[0].end() - line.begin() -1); std::string::size_type pos3 = line.find_first_not_of(" \t", parts[1].begin() - line.begin()); - std::string::size_type pos4 = line.find_last_not_of(" \t", parts[1].end() - line.begin() -1); + std::string::size_type pos4 = line.find_last_not_of(" \t\r", parts[1].end() - line.begin() -1); if (pos2 != std::string::npos && pos1 <= pos2 && pos4 != std::string::npos && pos3 <= pos4) { -- GitLab From 9f052720026568a0b0b77179eef581fafb5f5523 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 4 Apr 2018 10:32:57 +0200 Subject: [PATCH 555/567] ENH: remove min and max value for param acqui.view.azim --- .../AppOpticalCalibration/app/otbOpticalCalibration.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx index 1bd81011be..ab1691d1fc 100644 --- a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx +++ b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx @@ -270,8 +270,8 @@ private: //Viewing azimuth angle AddParameter(ParameterType_Float, "acqui.view.azim", "Viewing azimuth angle (deg)"); SetParameterDescription("acqui.view.azim", "Viewing azimuth angle (in degrees)"); - SetMinimumParameterFloatValue("acqui.view.azim", 0.); - SetMaximumParameterFloatValue("acqui.view.azim", 360.); + // SetMinimumParameterFloatValue("acqui.view.azim", 0.); + // SetMaximumParameterFloatValue("acqui.view.azim", 360.); SetDefaultParameterFloat("acqui.view.azim",0.0); //Gain & bias -- GitLab From ea3519baa09865c05804de1c6c9789d9f08c243a Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 4 Apr 2018 10:39:09 +0200 Subject: [PATCH 556/567] BUG: keep old behavior for null size ROI --- Modules/Applications/AppImageUtils/app/otbExtractROI.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index 1e4a84d465..43f3ec1f45 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -787,7 +787,7 @@ private: } if ( !CropRegionOfInterest() ) - otbAppLogFATAL(<<"Could not extract the ROI as it is out of the " + otbAppLogWARNING(<<"Could not extract the ROI as it is out of the " "input image."); ExtractROIFilterType::Pointer extractROIFilter = ExtractROIFilterType::New(); -- GitLab From a3eee349875b65f3e68754f323eb1e06c5a14f37 Mon Sep 17 00:00:00 2001 From: Jordi Inglada <jordi.inglada@cesbio.cnes.fr> Date: Wed, 4 Apr 2018 16:18:19 +0200 Subject: [PATCH 557/567] ENH: Update Shark for MSVC bugfix --- SuperBuild/CMake/External_shark.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SuperBuild/CMake/External_shark.cmake b/SuperBuild/CMake/External_shark.cmake index ea5531cf00..33934d4bb9 100644 --- a/SuperBuild/CMake/External_shark.cmake +++ b/SuperBuild/CMake/External_shark.cmake @@ -30,8 +30,8 @@ ADD_SUPERBUILD_CMAKE_VAR(SHARK BOOST_LIBRARYDIR) ExternalProject_Add(SHARK PREFIX SHARK - URL "https://github.com/Shark-ML/Shark/archive/91595920f02ad90217465e7f4c100cd165d9947e.zip" - URL_MD5 09ee12050ed4236db252adbc407a52ce + URL "https://github.com/Shark-ML/Shark/archive/2fd55e2b83f0666d05b403b291712668f4b76a13.zip" + URL_MD5 863bb5f0d94b01be5292867beb05a0bb SOURCE_DIR ${SHARK_SB_SRC} BINARY_DIR ${SHARK_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} -- GitLab From ec03d18658acfd56148ecd7cef86f024f0ab1377 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 5 Apr 2018 15:35:59 +0200 Subject: [PATCH 558/567] COMP: missing OTBImageIO_EXPORT macro for class MultiImageFileWriter --- Modules/IO/ImageIO/include/otbMultiImageFileWriter.h | 3 ++- Modules/IO/ImageIO/otb-module.cmake | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h index 0d2a1fc8af..5d2cf24f80 100644 --- a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h @@ -26,6 +26,7 @@ #include "itkImageBase.h" #include "itkProcessObject.h" #include "itkImageIOBase.h" +#include "OTBImageIOExport.h" #include <boost/shared_ptr.hpp> @@ -41,7 +42,7 @@ namespace otb * is interpreted on the first input to deduce the number of streams. This * number of streams is then used to split the other inputs. */ -class MultiImageFileWriter: public itk::ProcessObject +class OTBImageIO_EXPORT MultiImageFileWriter: public itk::ProcessObject { public: /** Standard class typedefs. */ diff --git a/Modules/IO/ImageIO/otb-module.cmake b/Modules/IO/ImageIO/otb-module.cmake index 552d431d5a..d592ba8b08 100644 --- a/Modules/IO/ImageIO/otb-module.cmake +++ b/Modules/IO/ImageIO/otb-module.cmake @@ -22,6 +22,7 @@ set(DOCUMENTATION "This module contains classes related to the reading and the writing of remote sensing images.") otb_module(OTBImageIO + ENABLE_SHARED DEPENDS OTBBoostAdapters OTBCommon -- GitLab From cdc6045177c4627cf9f885a8206aa3f389b5ebbb Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 5 Apr 2018 16:43:01 +0200 Subject: [PATCH 559/567] COMP: missing another export macro --- Modules/IO/ImageIO/include/otbImageIOFactory.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/IO/ImageIO/include/otbImageIOFactory.h b/Modules/IO/ImageIO/include/otbImageIOFactory.h index 287c149792..591999ac6e 100644 --- a/Modules/IO/ImageIO/include/otbImageIOFactory.h +++ b/Modules/IO/ImageIO/include/otbImageIOFactory.h @@ -23,6 +23,7 @@ #include "itkObject.h" #include "otbImageIOBase.h" +#include "OTBImageIOExport.h" namespace otb { @@ -31,7 +32,7 @@ namespace otb * * \ingroup OTBImageIO */ -class ITK_EXPORT ImageIOFactory : public itk::Object +class OTBImageIO_EXPORT ImageIOFactory : public itk::Object { public: /** Standard class typedefs. */ -- GitLab From 3bb90c27d86cae8ae4e3ee8a65da8ba0c1006247 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Thu, 5 Apr 2018 16:10:06 +0200 Subject: [PATCH 560/567] TEST: fix ingroup test and doxygen section --- Modules/IO/ImageIO/include/otbMultiImageFileWriter.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h index 5d2cf24f80..d8b05f5c4b 100644 --- a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.h @@ -41,6 +41,8 @@ namespace otb * When the user gives a number of lines per strip or a tile size, the value * is interpreted on the first input to deduce the number of streams. This * number of streams is then used to split the other inputs. + * + * \ingroup OTBImageIO */ class OTBImageIO_EXPORT MultiImageFileWriter: public itk::ProcessObject { @@ -226,7 +228,11 @@ private: bool m_IsObserving; unsigned long m_ObserverID; - /** Internal base wrapper class to handle each ImageFileWriter */ + /** \class SinkBase + * Internal base wrapper class to handle each ImageFileWriter + * + * \ingroup OTBImageIO + */ class SinkBase { public: @@ -248,6 +254,8 @@ private: /** \class Sink * Wrapper class for each ImageFileWriter + * + * \ingroup OTBImageIO */ template <class TImage> class Sink : public SinkBase -- GitLab From ce65e7008f64efbf6bf5f3636fb37d0cc891c9e1 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 6 Apr 2018 10:39:29 +0200 Subject: [PATCH 561/567] DOC: clarification about pushing directly on develop --- CONTRIBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0df03904ec..ef95be0bfc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,6 +58,11 @@ then send a merge request. Note that we also accept PRs on our [GitHub mirror](https://github.com/orfeotoolbox/OTB) which we will manually merge. +Caveat: if the Dashboard build on develop branch is broken, it is possible for +core developers to push their fixes directly on develop (to gain time) but this +is strictly limited to compilation error fixes. It is assumed that core +developers are aware of the multi-platform environment on the Dashboard. + ### Commit message On your feature branch, write a good [commit message](https://xkcd.com/1296/): -- GitLab From 510509dc863f1c4815a0de12a8394b193c701039 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 6 Apr 2018 18:30:13 +0200 Subject: [PATCH 562/567] DOC: alternative proposal for broken dashboard fixes --- CONTRIBUTING.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ef95be0bfc..d31b3f3f9d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,10 +58,14 @@ then send a merge request. Note that we also accept PRs on our [GitHub mirror](https://github.com/orfeotoolbox/OTB) which we will manually merge. -Caveat: if the Dashboard build on develop branch is broken, it is possible for -core developers to push their fixes directly on develop (to gain time) but this -is strictly limited to compilation error fixes. It is assumed that core -developers are aware of the multi-platform environment on the Dashboard. +Caveat: even if the Dashboard build on develop branch is broken, it is not +allowed to push fixes directly on develop. The developer trying to fix the +build should create a merge request and submit it for review. However in that +case, it is not mandatory to wait for a green dashboard if: + +* the developer has confirmed that proposed changes fix the compilation +* the reviewers agree for a fast merge. + ### Commit message -- GitLab From 65a8d9f28efb4d54157d835dea779b8abf4636b1 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Tue, 10 Apr 2018 09:35:18 +0200 Subject: [PATCH 563/567] DOC: simplify a bit the rules for merge requests --- CONTRIBUTING.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d31b3f3f9d..2c0cb47fb0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,12 +60,8 @@ which we will manually merge. Caveat: even if the Dashboard build on develop branch is broken, it is not allowed to push fixes directly on develop. The developer trying to fix the -build should create a merge request and submit it for review. However in that -case, it is not mandatory to wait for a green dashboard if: - -* the developer has confirmed that proposed changes fix the compilation -* the reviewers agree for a fast merge. - +build should create a merge request and submit it for review. Direct push to +develop without review must be avoided. ### Commit message @@ -102,7 +98,10 @@ OTB team. * Merge requests **must receive at least 2 positives votes from core developers** (members of Main Repositories group in Gitlab with at least "Developer" level; this includes PSC members) before being merged * The merger is responsible for checking that the branch is up-to-date with develop * Merge requests can be merged by anyone (not just PSC or RM) with push access to develop -* Merge requests can be merged once the dashboard is proven green for this branch +* Merge requests can be merged once the dashboard is proven green for this branch. + This condition is mandatory unless reviewers and authors explicitely agree that + it can be skipped (for instance in case of documentation merges or compilation + fixes on develop) Branches can be registered for dashboard testing by adding one line in `Config/feature_branches.txt` in [otb-devutils repository](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-devutils.git). -- GitLab From b6583597d0e955a0441931d09878d8834129756e Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Tue, 10 Apr 2018 09:47:27 +0200 Subject: [PATCH 564/567] Add description and link of the dashboard --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2c0cb47fb0..5379cb6443 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,6 +58,8 @@ then send a merge request. Note that we also accept PRs on our [GitHub mirror](https://github.com/orfeotoolbox/OTB) which we will manually merge. +The feature branch are then tested on multiple platforms on the OTB test infrastructure (a.k.a the [Dashboard](https://dash.orfeo-toolbox.org/)) in the FeatureBranches section. + Caveat: even if the Dashboard build on develop branch is broken, it is not allowed to push fixes directly on develop. The developer trying to fix the build should create a merge request and submit it for review. Direct push to -- GitLab From aa29718df356f733206f3e555686d09c12f644cf Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Tue, 10 Apr 2018 09:48:43 +0200 Subject: [PATCH 565/567] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5379cb6443..e1e390c36a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,7 +58,7 @@ then send a merge request. Note that we also accept PRs on our [GitHub mirror](https://github.com/orfeotoolbox/OTB) which we will manually merge. -The feature branch are then tested on multiple platforms on the OTB test infrastructure (a.k.a the [Dashboard](https://dash.orfeo-toolbox.org/)) in the FeatureBranches section. +Feature branches are tested on multiple platforms on the OTB test infrastructure (a.k.a the [Dashboard](https://dash.orfeo-toolbox.org/)). They appear in the FeatureBranches section. Caveat: even if the Dashboard build on develop branch is broken, it is not allowed to push fixes directly on develop. The developer trying to fix the -- GitLab From ce1e3e30bf5e9cde38665916487ba01ffbeebb82 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Wed, 11 Apr 2018 10:57:35 +0200 Subject: [PATCH 566/567] BUG: change value of test and restor min/max val on param --- .../AppOpticalCalibration/app/otbOpticalCalibration.cxx | 4 ++-- .../Applications/AppOpticalCalibration/test/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx index ab1691d1fc..1bd81011be 100644 --- a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx +++ b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx @@ -270,8 +270,8 @@ private: //Viewing azimuth angle AddParameter(ParameterType_Float, "acqui.view.azim", "Viewing azimuth angle (deg)"); SetParameterDescription("acqui.view.azim", "Viewing azimuth angle (in degrees)"); - // SetMinimumParameterFloatValue("acqui.view.azim", 0.); - // SetMaximumParameterFloatValue("acqui.view.azim", 360.); + SetMinimumParameterFloatValue("acqui.view.azim", 0.); + SetMaximumParameterFloatValue("acqui.view.azim", 360.); SetDefaultParameterFloat("acqui.view.azim",0.0); //Gain & bias diff --git a/Modules/Applications/AppOpticalCalibration/test/CMakeLists.txt b/Modules/Applications/AppOpticalCalibration/test/CMakeLists.txt index a3068e1a64..7be8316cb8 100644 --- a/Modules/Applications/AppOpticalCalibration/test/CMakeLists.txt +++ b/Modules/Applications/AppOpticalCalibration/test/CMakeLists.txt @@ -87,7 +87,7 @@ otb_test_application(NAME apTvRaOpticalCalibration_UnknownSensor -acqui.sun.elev 62.7 -acqui.sun.azim 152.7 -acqui.view.elev 87.5 - -acqui.view.azim -77.0 + -acqui.view.azim 283 -acqui.solarilluminations ${INPUTDATA}/apTvRaOpticalCalibrationUnknownSensorSolarIllumations2.txt -atmo.rsr ${INPUTDATA}/apTvRaOpticalCalibrationUnknownSensorRSR.txt -atmo.pressure 1013.0 -- GitLab From a21aa0819420f4d59fbe7c9a7535c93ad22e1a22 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 12 Apr 2018 08:28:38 +0200 Subject: [PATCH 567/567] WRG: fix a -Wmaybe-uninitialized in extractROI application --- Modules/Applications/AppImageUtils/app/otbExtractROI.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index 43f3ec1f45..adcb2f3f43 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -492,6 +492,7 @@ private: ComputeIndexFromRadius() { FloatVectorImageType::SizeType radiusi ; + radiusi.Fill(0); assert( GetParameterString( "mode" ) == "radius" ); if ( HasValue( "mode.radius.r" ) ) { -- GitLab