[otb] 01/13: New upstream version 6.2.0~rc1+dfsg

Bas Couwenberg sebastic at debian.org
Thu Oct 5 10:04:07 UTC 2017


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository otb.

commit 873b6809e114d3f54d49abb0db04e91805b8458e
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Wed Oct 4 20:41:33 2017 +0200

    New upstream version 6.2.0~rc1+dfsg
---
 CMake/CTestCustom.cmake.in                         |    5 +-
 CMake/FindGLEW.cmake                               |   57 +-
 CMake/FindGLFW.cmake                               |    2 +-
 CMake/FindLibKML.cmake                             |   66 +-
 CMake/FindLibSVM.cmake                             |    2 +-
 CMake/FindOpenCV.cmake                             |    4 +-
 CMake/FindOpenThreads.cmake                        |   49 +-
 CMake/FindQwt.cmake                                |   28 +-
 CMake/FindShark.cmake                              |   53 +-
 CMake/OTBCheckCpp11Keywords.cmake                  |    3 +
 CMake/OTBCheckSSEFeatures.cmake                    |   63 +
 CMake/OTBConfig.cmake.in                           |   17 +
 CMake/OTBModuleEnablement.cmake                    |   25 +-
 CMake/OTBModuleExternal.cmake                      |  145 +-
 CMake/OTBModuleMacros.cmake                        |   10 +-
 CMake/OTBSetStandardCompilerFlags.cmake            |   68 +-
 ...acros.cmake => OTBStandaloneModuleMacros.cmake} |  318 +--
 CMake/otbcli.bat.in                                |    4 +-
 CMake/otbcli.sh.in                                 |   16 +-
 CMake/otbgui.bat.in                                |    5 +
 CMake/otbgui.sh.in                                 |   16 +-
 CMakeLists.txt                                     |   29 +-
 Examples/Application/ApplicationExample.cxx        |    4 +-
 .../Classification/BayesianPluginClassifier.cxx    |    2 +-
 ...xpectationMaximizationMixtureModelEstimator.cxx |    2 +-
 .../DataRepresentation/Image/ImageListExample.cxx  |   10 +-
 .../FineRegistrationImageFilterExample.cxx         |    4 +-
 .../FeatureExtraction/ExtractSegmentsExample.cxx   |    4 +-
 .../LineSegmentDetectorExample.cxx                 |    2 +-
 .../RightAngleDetectionExample.cxx                 |    2 +-
 .../FeatureExtraction/TouziEdgeDetectorExample.cxx |    4 +-
 Examples/IO/ExtractROI.cxx                         |    2 +-
 Examples/Iterators/ImageSliceIteratorWithIndex.cxx |    4 +-
 Examples/Iterators/NeighborhoodIterators5.cxx      |    6 +-
 Examples/Learning/SEMModelEstimatorExample.cxx     |    8 +-
 Examples/Learning/SOMClassifierExample.cxx         |    6 +-
 Examples/Learning/SOMExample.cxx                   |    2 +-
 .../AtmosphericCorrectionSequencement.cxx          |   56 +-
 Examples/Radiometry/test/CMakeLists.txt            |    4 +-
 .../Segmentation/VectorConfidenceConnected.cxx     |    9 +-
 .../Simulation/LAIAndPROSAILToSensorResponse.cxx   |    4 +-
 .../GdalAdapters/include/otbOGRDataSourceWrapper.h |    2 +-
 .../GdalAdapters/include/otbOGRFeatureWrapper.h    |    2 +-
 .../GdalAdapters/include/otbOGRFieldWrapper.h      |    2 +-
 .../GdalAdapters/include/otbOGRLayerWrapper.h      |    2 +-
 .../GdalAdapters/include/otbOGRVersionProxy.h      |   11 +
 Modules/Adapters/GdalAdapters/src/CMakeLists.txt   |    7 +-
 .../GdalAdapters/src/otbOGRFieldWrapper.cxx        |    3 +-
 ...GRVersionProxy2x.cxx => otbOGRVersionProxy.cxx} |   96 +-
 .../GdalAdapters/src/otbOGRVersionProxy1x.cxx      |  140 --
 .../app/otbMultivariateAlterationDetector.cxx      |   91 +-
 .../AppClassification/app/CMakeLists.txt           |    3 +
 .../app/otbComputeImagesStatistics.cxx             |   15 +-
 .../app/otbComputeOGRLayersFeaturesStatistics.cxx  |   13 +-
 .../app/otbFusionOfClassifications.cxx             |    2 +-
 .../AppClassification/app/otbImageClassifier.cxx   |   16 +-
 .../app/otbKMeansClassification.cxx                |  788 +++----
 .../app/otbMultiImageSamplingRate.cxx              |    2 +-
 .../app/otbOGRLayerClassifier.cxx                  |   12 +-
 .../app/otbPolygonClassStatistics.cxx              |    2 +-
 .../AppClassification/app/otbSOMClassification.cxx |    4 +
 .../AppClassification/app/otbSampleSelection.cxx   |    2 +-
 .../app/otbTrainVectorClassifier.cxx               |    9 +-
 .../AppClassification/app/otbVectorClassifier.cxx  |   56 +-
 .../AppClassification/include/otbTrainBoost.txx    |   35 +-
 .../include/otbTrainDecisionTree.txx               |   47 +-
 .../include/otbTrainImagesBase.txx                 |    5 +-
 .../AppClassification/include/otbTrainLibSVM.txx   |   58 +-
 .../include/otbTrainNeuralNetwork.txx              |  102 +-
 .../AppClassification/include/otbTrainSVM.txx      |   70 +-
 .../include/otbTrainVectorBase.txx                 |   49 +-
 .../AppClassification/otb-module.cmake             |    1 +
 .../AppClassification/test/CMakeLists.txt          |   91 +-
 .../Applications/AppEdge/app/otbEdgeExtraction.cxx |   26 +-
 .../AppEdge/app/otbLineSegmentDetection.cxx        |   17 +-
 .../Applications/AppFiltering/app/CMakeLists.txt   |    6 -
 Modules/Applications/AppFiltering/otb-module.cmake |    3 +-
 .../Applications/AppFiltering/test/CMakeLists.txt  |   44 -
 Modules/Applications/AppFusion/app/CMakeLists.txt  |    3 +
 .../AppFusion/app/otbBundleToPerfectSensor.cxx     |    5 +-
 .../app/otbHyperspectralUnmixing.cxx               |   25 +-
 .../Applications/AppImageUtils/app/otbConvert.cxx  |  283 ++-
 .../AppImageUtils/app/otbDownloadSRTMTiles.cxx     | 2448 +++++++++++++++++---
 .../AppImageUtils/app/otbExtractROI.cxx            |  683 +++++-
 .../AppImageUtils/app/otbPixelValue.cxx            |  215 +-
 .../Applications/AppImageUtils/otb-module.cmake    |    1 +
 .../Applications/AppImageUtils/test/CMakeLists.txt |   81 +-
 .../Applications/AppMathParser/app/otbBandMath.cxx |   82 +-
 .../AppMathParserX/app/otbBandMathX.cxx            |  316 ++-
 .../app/otbMorphologicalProfilesAnalysis.cxx       |    2 +-
 .../app/otbOpticalCalibration.cxx                  |  106 +-
 .../AppOpticalCalibration/test/CMakeLists.txt      |   16 +-
 .../AppProjection/app/otbImageEnvelope.cxx         |   16 +-
 .../AppProjection/app/otbOrthoRectification.cxx    |    4 +-
 .../AppSARCalibration/app/otbSARCalibration.cxx    |    2 +-
 .../AppSARCalibration/app/otbSARDeburst.cxx        |   31 +-
 .../app/otbSARDecompositions.cxx                   |    2 +-
 .../app/otbSARPolarMatrixConvert.cxx               |    2 +-
 .../AppSARPolarSynth/test/CMakeLists.txt           |    2 +-
 .../Applications/AppSARUtils/app/CMakeLists.txt    |    8 +
 .../AppSARUtils/app/otbComputeModulusAndPhase.cxx  |   21 +-
 .../app/otbDespeckle.cxx                           |   75 +-
 Modules/Applications/AppSARUtils/otb-module.cmake  |    4 +
 .../Applications/AppSARUtils/test/CMakeLists.txt   |   86 +-
 .../AppSegmentation/app/CMakeLists.txt             |    5 +
 .../AppSegmentation/app/otbLSMSSegmentation.cxx    |   64 +-
 .../app/otbLSMSSmallRegionsMerging.cxx             |   42 +-
 .../AppSegmentation/app/otbLSMSVectorization.cxx   |   29 +-
 .../AppSegmentation/app/otbLargeScaleMeanShift.cxx |  233 ++
 .../AppSegmentation/app/otbMeanShiftSmoothing.cxx  |   93 +-
 .../AppSegmentation/app/otbSegmentation.cxx        |  310 +--
 .../AppSegmentation/test/CMakeLists.txt            |   15 +
 .../AppStereo/app/otbBlockMatching.cxx             |  229 +-
 .../app/otbDisparityMapToElevationMap.cxx          |   63 +-
 .../AppStereo/app/otbFineRegistration.cxx          |   66 +-
 .../AppStereo/app/otbGeneratePlyFile.cxx           |   39 +-
 .../app/otbStereoRectificationGridGenerator.cxx    |    2 +-
 .../AppTest/test/otbWrapperApplicationDocTests.cxx |  130 +-
 .../app/otbHaralickTextureExtraction.cxx           |    4 +-
 .../test/otbTestCommandLineArgumentParserHelp.cxx  |    1 -
 .../include/otbImageRegionAdaptativeSplitter.txx   |    2 +-
 .../Core/Common/include/otbModelComponentBase.h    |    2 +-
 .../Common/include/otbUnaryFunctorImageFilter.h    |    2 +-
 Modules/Core/Common/src/otbConfigure.h.in          |    4 +
 .../Core/ImageBase/include/otbExtractROIBase.txx   |    7 +-
 Modules/Core/ImageBase/include/otbImage.h          |    4 +-
 .../otbImageOfVectorsToMonoChannelExtractROI.h     |    2 +-
 .../include/otbMultiToMonoChannelExtractROI.h      |    2 +-
 .../include/otbMultiToMonoChannelExtractROI.txx    |    2 +-
 Modules/Core/ImageBase/src/otbImageIOBase.cxx      |    4 +-
 .../test/otbMultiToMonoChannelExtractROI.cxx       |    2 +-
 .../include/otbShapeAttributesLabelMapFilter.h     |    4 +-
 .../SpatialObjects/include/otbLineSpatialObject.h  |    8 +-
 .../include/otbGeoInformationConversion.h          |   11 +-
 .../Core/Transform/include/otbSensorModelBase.h    |    2 +-
 .../Transform/src/otbGeoInformationConversion.cxx  |   31 +
 ...ogramOfOrientedGradientCovariantImageFunction.h |    2 +-
 ...FTKeyPointSetFilterOutputInterestPointAscii.cxx |   27 +-
 .../include/otbLineDetectorImageFilterBase.txx     |    2 +-
 .../Textures/include/otbSFSTexturesFunctor.h       |   12 +-
 .../include/otbConvolutionImageFilter.txx          |    6 +-
 .../include/otbMNFImageFilter.h                    |    2 +-
 .../include/otbNAPCAImageFilter.h                  |    2 +-
 .../include/otbBinaryFunctorImageFilter.h          |   84 +
 .../include/otbTernaryFunctorImageFilter.h         |   84 +
 .../ImageNoise/include/otbLeeImageFilter.h         |    2 +-
 ...otbMultiChannelsPolarimetricSynthesisFilter.txx |    2 +-
 Modules/Filtering/Polarimetry/test/CMakeLists.txt  |    2 +-
 .../Wavelet/include/otbWaveletFilterBank.txx       |    2 +-
 .../include/otbLocalRxDetectorNonThreadFilter.txx  |    3 -
 .../include/otbVcaImageFilter.txx                  |    2 +-
 Modules/IO/IOGDAL/src/otbGDALImageIO.cxx           |   39 +-
 Modules/IO/IOGDAL/src/otbOGRIOHelper.cxx           |    2 +-
 Modules/IO/ImageIO/include/otbImageFileReader.h    |   27 +-
 Modules/IO/ImageIO/include/otbImageFileReader.txx  |  173 +-
 Modules/IO/ImageIO/include/otbImageFileWriter.txx  |   15 +-
 Modules/IO/ImageIO/src/otbImageIOFactory.cxx       |   33 +-
 Modules/IO/ImageIO/test/CMakeLists.txt             |    6 +-
 Modules/IO/TestKernel/src/otbTestHelper.cxx        |    2 +-
 Modules/IO/TestKernel/test/CMakeLists.txt          |   32 +
 .../include/otbGaussianModelComponent.h            |    2 +-
 .../LearningBase/include/otbMachineLearningModel.h |   21 +-
 .../include/otbMachineLearningModelTraits.h        |  104 +
 Modules/Learning/LearningBase/test/CMakeLists.txt  |    1 +
 .../test/otbMachineLearningModelTemplates.cxx      |   40 +
 .../include/otbImageSampleExtractorFilter.txx      |    1 +
 .../include/otbPersistentSamplingFilterBase.txx    |   13 +-
 .../include/otbLibSVMMachineLearningModel.h        |    2 +-
 Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h |    2 +-
 .../include/otbImageToLuminanceImageFilter.h       |  191 +-
 ...ageFilter.h => otbImageToRadianceImageFilter.h} |   38 +-
 .../include/otbImageToReflectanceImageFilter.h     |   18 +-
 .../include/otbLuminanceToImageImageFilter.h       |  193 +-
 .../include/otbLuminanceToReflectanceImageFilter.h |  309 +--
 ...ageFilter.h => otbRadianceToImageImageFilter.h} |   38 +-
 ...ter.h => otbRadianceToReflectanceImageFilter.h} |   40 +-
 .../include/otbReflectanceToImageImageFilter.h     |   18 +-
 .../include/otbReflectanceToLuminanceImageFilter.h |  292 +--
 ...ter.h => otbReflectanceToRadianceImageFilter.h} |   40 +-
 ...otbReflectanceToSurfaceReflectanceImageFilter.h |    2 +-
 .../Radiometry/OpticalCalibration/otb-module.cmake |    2 +-
 .../OpticalCalibration/test/CMakeLists.txt         |  400 ++--
 .../test/otbAtmosphericCorrectionSequencement.cxx  |   44 +-
 ...ilter.cxx => otbImageToRadianceImageFilter.cxx} |   10 +-
 ...o.cxx => otbImageToRadianceImageFilterAuto.cxx} |    8 +-
 ...ew.cxx => otbImageToRadianceImageFilterNew.cxx} |    8 +-
 .../test/otbOpticalCalibrationTestDriver.cxx       |   24 +-
 ...ilter.cxx => otbRadianceToImageImageFilter.cxx} |   10 +-
 ...o.cxx => otbRadianceToImageImageFilterAuto.cxx} |    8 +-
 ...ew.cxx => otbRadianceToImageImageFilterNew.cxx} |    8 +-
 ...cxx => otbRadianceToReflectanceImageFilter.cxx} |   10 +-
 ...=> otbRadianceToReflectanceImageFilterAuto.cxx} |   20 +-
 ... => otbRadianceToReflectanceImageFilterNew.cxx} |    8 +-
 .../test/otbReflectanceToImageImageFilter.cxx      |   14 +-
 ...cxx => otbReflectanceToRadianceImageFilter.cxx} |   10 +-
 ...=> otbReflectanceToRadianceImageFilterAuto.cxx} |   14 +-
 ... => otbReflectanceToRadianceImageFilterNew.cxx} |    8 +-
 .../include/otbImageSimulationMethod.txx           |    4 +-
 .../Simulation/include/otbReduceSpectralResponse.h |    4 +-
 .../include/otbReduceSpectralResponse.txx          |   47 +-
 .../Radiometry/Simulation/include/otbSailModel.h   |  229 +-
 .../Simulation/include/otbSoilDataBase.h           |   57 +
 .../otbSurfaceReflectanceToReflectanceFilter.h     |    2 +-
 Modules/Radiometry/Simulation/src/CMakeLists.txt   |    1 +
 Modules/Radiometry/Simulation/src/otbSailModel.cxx |  411 ++--
 .../Radiometry/Simulation/src/otbSoilDataBase.cxx  |  134 ++
 Modules/Radiometry/Simulation/test/CMakeLists.txt  |   46 +-
 .../Simulation/test/otbReduceSpectralResponse.cxx  |    6 +-
 .../Simulation/test/otbSailReflHTest.cxx           |   34 +-
 .../Simulation/test/otbSimulationTestDriver.cxx    |    1 +
 .../Radiometry/Simulation/test/otbSoilDBTest.cxx   |   77 +
 Modules/Remote/Mosaic.remote.cmake                 |    2 +-
 Modules/Remote/SertitObject.remote.cmake           |    2 +-
 Modules/Remote/otb-bv.remote.cmake                 |    2 +-
 Modules/Remote/otbFFSforGMM.remote.cmake           |    2 +-
 Modules/Remote/otbGRM.remote.cmake                 |    4 +-
 Modules/Remote/phenotb.remote.cmake                |    2 +-
 Modules/Remote/temporal-gapfilling.remote.cmake    |    2 +-
 Modules/ThirdParty/GeoTIFF/otb-module.cmake        |    2 +
 Modules/ThirdParty/MuParserX/otb-module.cmake      |    2 -
 Modules/ThirdParty/OpenCV/CMakeLists.txt           |    2 -
 Modules/ThirdParty/OpenGL/CMakeLists.txt           |    7 +
 .../src/ossim/ossimCosmoSkymedModel.cpp            |    2 +-
 .../src/ossim/ossimEnvisatAsarModel.cpp            |    2 +-
 .../src/ossim/ossimPleiadesDimapSupportData.cpp    |    4 +-
 .../OssimPlugins/src/ossim/ossimSarSensorModel.cpp |   10 +-
 .../src/ossim/ossimSpot6DimapSupportData.cpp       |    4 +-
 .../OssimPlugins/src/ossim/ossimTerraSarModel.cpp  |   78 +-
 .../OssimPlugins/src/ossim/otb/CivilDateTime.h     |    6 +-
 .../OssimPlugins/src/ossim/otb/GalileanEphemeris.h |    2 +-
 .../src/ossim/otb/GeographicEphemeris.h            |    2 +-
 .../OssimPlugins/src/ossim/otb/JSDDateTime.h       |    2 +-
 .../OssimPlugins/src/ossim/otb/JulianDate.h        |    2 +-
 .../OssimPlugins/src/ossim/otb/PlatformPosition.h  |    2 +-
 Modules/ThirdParty/Qt4/otb-module-init.cmake       |    4 +-
 Modules/ThirdParty/Qwt/otb-module-init.cmake       |    4 +-
 Modules/ThirdParty/SPTW/otb-module.cmake           |    1 +
 Modules/ThirdParty/SPTW/src/CMakeLists.txt         |    6 +-
 Modules/ThirdParty/Shark/otb-module.cmake          |    3 -
 Modules/ThirdParty/SiftFast/src/CMakeLists.txt     |  135 +-
 .../otb-module-init.cmake => TIFF/CMakeLists.txt}  |   10 +-
 .../ThirdParty/{Qt4 => TIFF}/otb-module-init.cmake |    5 +-
 .../ThirdParty/{GeoTIFF => TIFF}/otb-module.cmake  |    6 +-
 Modules/Visualization/Mapla/src/CMakeLists.txt     |    1 -
 .../Visualization/Mapla/src/mvdMaplaWin32.rc.in    |    2 +-
 .../Visualization/Monteverdi/src/CMakeLists.txt    |    1 -
 .../Visualization/Monteverdi/src/mvdMainWindow.cxx |   36 +-
 .../Visualization/Monteverdi/src/mvdWin32.rc.in    |    4 +-
 .../MonteverdiCore/include/mvdAbstractLayerModel.h |   10 +
 .../MonteverdiCore/include/mvdStackedLayerModel.h  |    2 +
 .../MonteverdiCore/src/ConfigureMonteverdi.h.in    |    3 +
 .../MonteverdiCore/src/mvdAbstractLayerModel.cxx   |   52 +-
 .../MonteverdiCore/src/mvdI18nCoreApplication.cxx  |    8 +-
 .../MonteverdiCore/src/mvdStackedLayerModel.cxx    |   18 +
 .../MonteverdiCore/src/mvdVectorImageModel.cxx     |    1 +
 .../MonteverdiGui/include/mvdHistogramPlotPicker.h |    4 +-
 .../MonteverdiGui/include/mvdHistogramWidget.h     |   20 +-
 .../include/mvdQtWidgetParameterInitializers.h     |  122 +-
 .../MonteverdiGui/src/mvdAboutDialog.ui            |    2 +-
 .../MonteverdiGui/src/mvdHistogramPlotPicker.cxx   |  174 +-
 .../MonteverdiGui/src/mvdHistogramWidget.cxx       |  122 +-
 .../MonteverdiGui/src/mvdLayerStackItemModel.cxx   |   60 +-
 .../MonteverdiGui/src/mvdQtWidgetView.cxx          |    5 +
 .../Wrappers/ApplicationEngine/include/otbLogger.h |   57 +
 .../include/otbWrapperApplication.h                |   59 +-
 .../include/otbWrapperCompositeApplication.h       |    4 -
 .../include/otbWrapperInputImageListParameter.h    |    4 +-
 .../include/otbWrapperInputImageParameter.txx      |    9 +-
 .../ApplicationEngine/include/otbWrapperMacros.h   |   13 +-
 .../include/otbWrapperOutputProcessXMLParameter.h  |    9 +
 .../Wrappers/ApplicationEngine/src/CMakeLists.txt  |    1 +
 .../Wrappers/ApplicationEngine/src/otbLogger.cxx   |   75 +
 .../src/otbWrapperApplication.cxx                  |  124 +-
 .../src/otbWrapperChoiceParameter.cxx              |    2 +-
 .../src/otbWrapperCompositeApplication.cxx         |   35 +-
 .../src/otbWrapperInputFilenameListParameter.cxx   |   45 +-
 .../src/otbWrapperInputImageListParameter.cxx      |  157 +-
 .../src/otbWrapperInputImageParameter.cxx          |   25 +-
 .../src/otbWrapperInputProcessXMLParameter.cxx     |    3 +
 .../src/otbWrapperOutputProcessXMLParameter.cxx    |   83 +-
 .../src/otbWrapperParameterGroup.cxx               |    4 +-
 .../include/otbWrapperCommandLineLauncher.h        |   12 +-
 .../src/otbApplicationLauncherCommandLine.cxx      |   33 +-
 .../src/otbWrapperCommandLineLauncher.cxx          |  472 ++--
 .../QtWidget/include/otbQtFileSelectionWidget.h    |    5 +
 .../otbWrapperQtWidgetComplexInputImageParameter.h |   18 +
 ...otbWrapperQtWidgetComplexOutputImageParameter.h |   22 +-
 .../otbWrapperQtWidgetInputImageParameter.h        |    8 +-
 .../QtWidget/src/otbQtFileSelectionWidget.cxx      |   18 +-
 ...tbWrapperQtWidgetInputFilenameListParameter.cxx |    4 +
 .../otbWrapperQtWidgetInputImageListParameter.cxx  |   20 +-
 .../src/otbWrapperQtWidgetInputImageParameter.cxx  |   15 +-
 .../otbWrapperQtWidgetInputProcessXMLParameter.cxx |    4 +-
 ...WrapperQtWidgetInputVectorDataListParameter.cxx |    4 +
 .../src/otbWrapperQtWidgetListViewParameter.cxx    |   52 +-
 .../QtWidget/src/otbWrapperQtWidgetModel.cxx       |   68 +-
 .../src/otbWrapperQtWidgetStringListParameter.cxx  |    3 +
 Modules/Wrappers/SWIG/src/itkBase.i                |    4 +
 Modules/Wrappers/SWIG/src/otbApplication.i         |    4 +-
 Modules/Wrappers/SWIG/test/python/CMakeLists.txt   |    7 +-
 .../Wrappers/SWIG/test/python/PythonInXMLTest.py   |    3 -
 Packaging/CMakeLists.txt                           |  238 ++
 .../CTestConfig.cmake                              |   25 +-
 Packaging/External_patchelf.cmake                  |   61 +
 Packaging/Files/Monteverdi.icns                    |  Bin 0 -> 42798 bytes
 Packaging/Files/OTB Project.zip                    |  Bin 0 -> 454333 bytes
 Packaging/Files/build_examples.cmake               |   97 +
 Packaging/Files/linux_pkgsetup.in                  |   96 +
 Packaging/Files/macx_pkgsetup.in                   |  120 +
 Packaging/Files/mapla.bat                          |   38 +
 .../Files/mapla.sh                                 |    8 +-
 Packaging/Files/monteverdi.bat                     |   38 +
 .../Files/monteverdi.sh                            |    8 +-
 Packaging/Files/otb_loader.cxx                     |   75 +
 .../CMakeLists.txt => Packaging/Files/otbenv.bash  |   32 +-
 Packaging/Files/otbenv.bat                         |   30 +
 Packaging/Files/otbenv.profile                     |   75 +
 Packaging/Files/qt.conf                            |    3 +
 Packaging/Files/selftester.bat                     |  255 ++
 Packaging/Files/selftester.sh                      |  223 ++
 Packaging/Files/setup_python.sh                    |   98 +
 Packaging/Files/start_devenv.bat                   |   41 +
 Packaging/Files/template.app/Contents/Info.plist   |   18 +
 Packaging/Files/uninstall_otb.bat                  |   39 +
 .../Files/uninstall_otb.sh                         |   26 +-
 Packaging/PackageGlobals.cmake                     |  170 ++
 Packaging/README.md                                |    1 +
 Packaging/check_cmake_variables.cmake              |   57 +
 Packaging/cleanup_package.cmake                    |   58 +
 .../clear_cmakecache_variables.cmake               |   28 +-
 Packaging/configure_loader.cmake                   |   50 +
 Packaging/create_package.cmake                     |   45 +
 Packaging/detect_using_file_command.cmake          |  111 +
 .../get_variables_ending_with.cmake                |   10 +-
 Packaging/howto_update_makeself                    |   11 +
 .../install_cmake_files.cmake                      |   31 +-
 Packaging/install_importlibs.cmake                 |   43 +
 Packaging/install_include_dirs.cmake               |   36 +
 Packaging/install_otbapp_wrapper_scripts.cmake     |   58 +
 .../install_python_bindings.cmake                  |   18 +-
 Packaging/install_qtdev_files.cmake                |   46 +
 Packaging/install_rule.cmake                       |  123 +
 Packaging/install_share_dirs.cmake                 |   97 +
 .../install_vstudio_files.cmake                    |   13 +-
 Packaging/install_without_message.cmake            |   40 +
 Packaging/installer_files.cmake                    |  133 ++
 Packaging/isfile_symlink.cmake                     |   89 +
 Packaging/makeself/COPYING                         |  339 +++
 Packaging/makeself/README.md                       |  220 ++
 Packaging/makeself/makeself-header.sh              |  553 +++++
 Packaging/makeself/makeself.1                      |  104 +
 Packaging/makeself/makeself.lsm                    |   16 +
 Packaging/makeself/makeself.sh                     |  620 +++++
 Packaging/otb_update_makeself                      |   11 +
 Packaging/patch_cmake_files.cmake                  |   63 +
 Packaging/post_install.cmake                       |   46 +
 Packaging/prepare_file_list.cmake                  |   95 +
 Packaging/prepare_search_dirs.cmake                |   59 +
 Packaging/process_file_recurse.cmake               |  148 ++
 .../search_library.cmake                           |   32 +-
 .../setif_value_in_list.cmake                      |   31 +-
 Packaging/testing.cmake                            |   85 +
 RELEASE_NOTES.txt                                  |   91 +-
 Utilities/Doxygen/doxygen.config.in                |    2 +-
 Utilities/Maintenance/SuperbuildDownloadList.sh    |   81 +-
 i18n/fr_FR.ts                                      |   10 +-
 366 files changed, 14712 insertions(+), 5731 deletions(-)

diff --git a/CMake/CTestCustom.cmake.in b/CMake/CTestCustom.cmake.in
index 612027d..a2416c6 100644
--- a/CMake/CTestCustom.cmake.in
+++ b/CMake/CTestCustom.cmake.in
@@ -38,9 +38,11 @@
 #----------------------------------------------------------------------
 
 set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
-set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 300)
 set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
 
+if(NOT DEFINED CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS)
+  set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 300)
+endif()
 
 set(CTEST_CUSTOM_COVERAGE_EXCLUDE
  ${CTEST_CUSTOM_COVERAGE_EXCLUDE}
@@ -86,6 +88,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION
   # Ignore clang's summary warning, assuming prior text has matched some
   # other warning expression:
   "[0-9,]+ warnings? generated."
+  "cl...Command.line.warning.D9025"
   ".*include.opencv2.*warning.*"
   ".*include.opencv2.*note.*"
   ".*include.kml.*warning.*"
diff --git a/CMake/FindGLEW.cmake b/CMake/FindGLEW.cmake
index c54e365..243191d 100644
--- a/CMake/FindGLEW.cmake
+++ b/CMake/FindGLEW.cmake
@@ -28,54 +28,33 @@
 #
 # Try to find GLEW library and include path.
 # Once done this will define
+#rewritten for OTB by Rashad Kanavath
 #
 # GLEW_FOUND
 # GLEW_INCLUDE_PATH
 # GLEW_LIBRARY
 #
 
-IF (WIN32)
-	FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h
-		$ENV{PROGRAMFILES}/GLEW/include
-		${GLEW_ROOT_DIR}/include
-		DOC "The directory where GL/glew.h resides")
+find_path(
+  GLEW_INCLUDE_DIR GL/glew.h
+  DOC "The directory where GL/glew.h resides"
+  )
 
-    FIND_LIBRARY( GLEW_LIBRARY
-        NAMES glew GLEW glew32 glew32s
-        PATHS
-        $ENV{PROGRAMFILES}/GLEW/lib
-        ${GLEW_ROOT_DIR}/lib
-        ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
-        ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
-        DOC "The GLEW library")
-ELSE (WIN32)
-	FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h
-		/usr/include
-		/usr/local/include
-		/sw/include
-		/opt/local/include
-		${GLEW_ROOT_DIR}/include
-		DOC "The directory where GL/glew.h resides")
+if(WIN32)
+  set(GLEW_LIB_NAMES glew GLEW glew32 glew32s)
+else()
+  set(GLEW_LIB_NAMES libGLEW GLEW)
+endif()
 
-	# Prefer the static library.
-	FIND_LIBRARY( GLEW_LIBRARY
-		NAMES libGLEW.so GLEW
-		PATHS
-		/usr/lib64
-		/usr/lib
-		/usr/local/lib64
-		/usr/local/lib
-		/sw/lib
-		/opt/local/lib
-		${GLEW_ROOT_DIR}/lib
-		DOC "The GLEW library")
-ENDIF (WIN32)
+FIND_LIBRARY( GLEW_LIBRARY
+  NAMES ${GLEW_LIB_NAMES}
+  DOC "The GLEW library")
 
-SET(GLEW_FOUND "NO")
-IF (GLEW_INCLUDE_DIR AND GLEW_LIBRARY)
-	SET(GLEW_LIBRARIES ${GLEW_LIBRARY})
-	SET(GLEW_FOUND "YES")
-ENDIF ()
+set(GLEW_FOUND FALSE)
+if (GLEW_INCLUDE_DIR AND GLEW_LIBRARY)
+  set(GLEW_LIBRARIES ${GLEW_LIBRARY})
+  set(GLEW_FOUND TRUE)
+endif()
 
 INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLEW
diff --git a/CMake/FindGLFW.cmake b/CMake/FindGLFW.cmake
index 3f4c29e..2accc1c 100644
--- a/CMake/FindGLFW.cmake
+++ b/CMake/FindGLFW.cmake
@@ -80,4 +80,4 @@ ENDIF()
 INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLFW
                                   REQUIRED_VARS GLFW_LIBRARY GLFW_INCLUDE_DIR
-                                  VERSION_VAR GLFW_VERSION_STRING)
\ No newline at end of file
+                                  VERSION_VAR GLFW_VERSION_STRING)
diff --git a/CMake/FindLibKML.cmake b/CMake/FindLibKML.cmake
index bb3136e..0a3706d 100644
--- a/CMake/FindLibKML.cmake
+++ b/CMake/FindLibKML.cmake
@@ -31,55 +31,35 @@ if( LIBKML_INCLUDE_DIR )
     set( LibKML_FIND_QUIETLY TRUE )
 endif()
 
-find_path( LIBKML_INCLUDE_DIR kml/dom.h )
+find_path( LIBKML_INCLUDE_DIR       kml/dom.h )
+find_library( LIBKML_BASE_LIBRARY   NAMES kmlbase )
+find_library( LIBKML_DOM_LIBRARY    NAMES kmldom )
+find_library( LIBKML_ENGINE_LIBRARY NAMES kmlengine )
 
-find_library( LIBKML_BASE_LIBRARY
-              NAMES kmlbase )
-
-# TODO : add HINTS derived from path of LIBKML_BASE_LIBRARY
-find_library( LIBKML_CONVENIENCE_LIBRARY
-              NAMES kmlconvenience )
-find_library( LIBKML_DOM_LIBRARY
-              NAMES kmldom )
-find_library( LIBKML_ENGINE_LIBRARY
-              NAMES kmlengine )
-find_library( LIBKML_REGIONATOR_LIBRARY
-              NAMES kmlregionator )
-find_library( LIBKML_XSD_LIBRARY
-              NAMES kmlxsd )
-find_library( LIBKML_MINIZIP_LIBRARY
-              NAMES minizip )
-
-mark_as_advanced(   LIBKML_INCLUDE_DIR
-                    LIBKML_BASE_LIBRARY
-                    LIBKML_CONVENIENCE_LIBRARY
-                    LIBKML_DOM_LIBRARY
-                    LIBKML_ENGINE_LIBRARY
-                    LIBKML_REGIONATOR_LIBRARY
-                    LIBKML_XSD_LIBRARY
-                    LIBKML_MINIZIP_LIBRARY )
+mark_as_advanced(
+  LIBKML_INCLUDE_DIR
+  LIBKML_BASE_LIBRARY
+  LIBKML_DOM_LIBRARY
+  LIBKML_ENGINE_LIBRARY
+  )
 
 # handle the QUIETLY and REQUIRED arguments and set LIBKML_FOUND to TRUE if
 # all listed variables are TRUE
 include( FindPackageHandleStandardArgs )
-FIND_PACKAGE_HANDLE_STANDARD_ARGS( LibKML DEFAULT_MSG
-                                    LIBKML_BASE_LIBRARY
-                                    LIBKML_CONVENIENCE_LIBRARY
-                                    LIBKML_DOM_LIBRARY
-                                    LIBKML_ENGINE_LIBRARY
-                                    LIBKML_REGIONATOR_LIBRARY
-                                    LIBKML_XSD_LIBRARY
-                                    LIBKML_MINIZIP_LIBRARY
-                                    LIBKML_INCLUDE_DIR
-                                     )
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+  LibKML
+  DEFAULT_MSG
+  LIBKML_INCLUDE_DIR
+  LIBKML_BASE_LIBRARY
+  LIBKML_DOM_LIBRARY
+  LIBKML_ENGINE_LIBRARY
+  )
 
 if(LIBKML_FOUND)
   set(LIBKML_INCLUDE_DIRS ${LIBKML_INCLUDE_DIR})
-  set(LIBKML_LIBRARIES ${LIBKML_BASE_LIBRARY}
-                       ${LIBKML_CONVENIENCE_LIBRARY}
-                       ${LIBKML_DOM_LIBRARY}
-                       ${LIBKML_ENGINE_LIBRARY}
-                       ${LIBKML_REGIONATOR_LIBRARY}
-                       ${LIBKML_XSD_LIBRARY}
-                       ${LIBKML_MINIZIP_LIBRARY})
+  set(LIBKML_LIBRARIES
+    ${LIBKML_BASE_LIBRARY}
+    ${LIBKML_DOM_LIBRARY}
+    ${LIBKML_ENGINE_LIBRARY}
+    )
 endif()
diff --git a/CMake/FindLibSVM.cmake b/CMake/FindLibSVM.cmake
index cc15db6..93b2c9d 100644
--- a/CMake/FindLibSVM.cmake
+++ b/CMake/FindLibSVM.cmake
@@ -14,7 +14,7 @@
 #  LIBSVM_MINOR_VERSION - minor version
 #  LIBSVM_PATCH_VERSION - patch version
 #  LIBSVM_VERSION_STRING - version (ex. 2.9.0)
-#  LIBSVM_ROOT_DIR - root dir (ex. /usr/local)
+#  LIBSVM_ROOT_DIR - libsvm install directory
 
 #=============================================================================
 # Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
diff --git a/CMake/FindOpenCV.cmake b/CMake/FindOpenCV.cmake
index f14c205..6ffebad 100644
--- a/CMake/FindOpenCV.cmake
+++ b/CMake/FindOpenCV.cmake
@@ -116,7 +116,7 @@ find_library(
   OPENCV_core_LIBRARY
   NAMES ${opencv_core_NAMES}
   PATHS ${OPENCV_SEARCH_PATH}
-  PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu"
+  PATH_SUFFIXES "lib" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
   NO_DEFAULT_PATH
   DOC "Path to opencv_core library")
 
@@ -124,7 +124,7 @@ find_library(
   OPENCV_ml_LIBRARY
   NAMES ${opencv_ml_NAMES}
   PATHS ${OPENCV_SEARCH_PATH}
-  PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu"
+  PATH_SUFFIXES "lib" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
   NO_DEFAULT_PATH
   DOC "Path to opencv_ml library")
 
diff --git a/CMake/FindOpenThreads.cmake b/CMake/FindOpenThreads.cmake
index e57dff2..2462dbf 100644
--- a/CMake/FindOpenThreads.cmake
+++ b/CMake/FindOpenThreads.cmake
@@ -58,23 +58,9 @@
 # standard install paths.
 # Explicit -DVAR=value arguments should still be able to override everything.
 
-find_path(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
-    HINTS
-        # enough environment variables?
-        $ENV{OPENTHREADS_INCLUDE_DIR}
-        $ENV{OPENTHREADS_DIR}
-        $ENV{OSG_INCLUDE_DIR}
-        $ENV{OSG_DIR}
-        $ENV{OSGDIR}
-        $ENV{OpenThreads_ROOT}
-        $ENV{OSG_ROOT}
-    PATHS
-        /sw # Fink
-        /opt/local # DarwinPorts
-        /opt/csw # Blastwave
-        /opt
-        /usr/freeware
-    PATH_SUFFIXES include
+find_path(
+  OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
+  PATH_SUFFIXES include
 )
 mark_as_advanced(OPENTHREADS_INCLUDE_DIR)
 
@@ -95,41 +81,12 @@ endif()
 
 find_library(OPENTHREADS_LIBRARY
     NAMES OpenThreads OpenThreadsWin32
-    HINTS
-        $ENV{OPENTHREADS_LIBRARY_DIR}
-        $ENV{OPENTHREADS_DIR}
-        $ENV{OSG_LIBRARY_DIR}
-        $ENV{OSG_DIR}
-        $ENV{OSGDIR}
-        $ENV{OpenThreads_ROOT}
-        $ENV{OSG_ROOT}
-    PATHS
-        /sw
-        /opt/local
-        /opt/csw
-        /opt
-        /usr/freeware
     PATH_SUFFIXES lib64 lib
 )
 mark_as_advanced(OPENTHREADS_LIBRARY)
 
 find_library(OPENTHREADS_LIBRARY_DEBUG
     NAMES OpenThreadsd OpenThreadsWin32d
-    HINTS
-        $ENV{OPENTHREADS_DEBUG_LIBRARY_DIR}
-        $ENV{OPENTHREADS_LIBRARY_DIR}
-        $ENV{OPENTHREADS_DIR}
-        $ENV{OSG_LIBRARY_DIR}
-        $ENV{OSG_DIR}
-        $ENV{OSGDIR}
-        $ENV{OpenThreads_ROOT}
-        $ENV{OSG_ROOT}
-    PATHS
-        /sw
-        /opt/local
-        /opt/csw
-        /opt
-        /usr/freeware
     PATH_SUFFIXES lib64 lib
 )
 mark_as_advanced(OPENTHREADS_LIBRARY_DEBUG)
diff --git a/CMake/FindQwt.cmake b/CMake/FindQwt.cmake
index d0c8a70..1c37f55 100644
--- a/CMake/FindQwt.cmake
+++ b/CMake/FindQwt.cmake
@@ -31,20 +31,20 @@
 #  QWT_MINOR_VERSION - minor version
 #  QWT_PATCH_VERSION - patch version
 #  QWT_VERSION_STRING - version (ex. 5.2.1)
-#  QWT_ROOT_DIR - root dir (ex. /usr/local)
+#  QWT_ROOT_DIR - root dir
 
 #=============================================================================
 # Copyright 2010-2013, Julien Schueller
 # All rights reserved.
-# 
+#
 # Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met: 
-# 
+# modification, are permitted provided that the following conditions are met:
+#
 # 1. Redistributions of source code must retain the above copyright notice, this
-#    list of conditions and the following disclaimer. 
+#    list of conditions and the following disclaimer.
 # 2. Redistributions in binary form must reproduce the above copyright notice,
 #    this list of conditions and the following disclaimer in the documentation
-#    and/or other materials provided with the distribution. 
+#    and/or other materials provided with the distribution.
 #
 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -58,17 +58,21 @@
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 # The views and conclusions contained in the software and documentation are those
-# of the authors and should not be interpreted as representing official policies, 
+# of the authors and should not be interpreted as representing official policies,
 # either expressed or implied, of the FreeBSD Project.
 #=============================================================================
 
+# message( "QWT_INCLUDE_DIR: '${QWT_INCLUDE_DIR}'" )
+# message( "QWT_INCLUDE_DIR: '${QT_INCLUDE_DIR}'" )
 
-find_path ( QWT_INCLUDE_DIR
+find_path( QWT_INCLUDE_DIR
   NAMES qwt_plot.h
-  HINTS ${QT_INCLUDE_DIR}
-  PATH_SUFFIXES qwt qwt-qt3 qwt-qt4 qwt-qt5
+  PATH_SUFFIXES qwt
 )
 
+# message( "QWT_INCLUDE_DIR: '${QWT_INCLUDE_DIR}'" )
+# message( "QWT_INCLUDE_DIR: '${QT_INCLUDE_DIR}'" )
+
 set ( QWT_INCLUDE_DIRS ${QWT_INCLUDE_DIR} )
 
 # version
@@ -100,7 +104,7 @@ endif ()
 
 
 find_library ( QWT_LIBRARY
-  NAMES qwt qwt-qt3 qwt-qt4 qwt-qt5 qwt${QWT_MAJOR_VERSION}
+  NAMES qwt qwt${QWT_MAJOR_VERSION}
   HINTS ${QT_LIBRARY_DIR}
 )
 
@@ -126,7 +130,7 @@ endif ()
 
 
 mark_as_advanced (
-  QWT_LIBRARY 
+  QWT_LIBRARY
   QWT_LIBRARIES
   QWT_INCLUDE_DIR
   QWT_INCLUDE_DIRS
diff --git a/CMake/FindShark.cmake b/CMake/FindShark.cmake
index 9e1e973..59bef13 100644
--- a/CMake/FindShark.cmake
+++ b/CMake/FindShark.cmake
@@ -41,9 +41,11 @@ if(Shark_DIR)
 
 endif() #if(Shark_DIR)
 
-find_path( SHARK_INCLUDE_DIR shark/Core/Shark.h
+find_path( SHARK_INCLUDE_DIR
+  NAMES shark/Core/Shark.h
   PATHS "${SHARK_SEARCH_PATH}"
-  PATH_SUFFIXES include include/shark shark)
+  PATH_SUFFIXES include include/shark shark
+  )
 
 find_library( SHARK_LIBRARY
   NAMES shark shark_debug
@@ -51,22 +53,34 @@ find_library( SHARK_LIBRARY
   PATH_SUFFIXES lib
   )
 
-mark_as_advanced( SHARK_INCLUDE_DIR
-                  SHARK_LIBRARY )
-find_package( 
-	Boost 1.48.0 REQUIRED QUIET COMPONENTS
-	system date_time filesystem
-	program_options serialization thread
-	unit_test_framework
-)
+mark_as_advanced( SHARK_INCLUDE_DIR  SHARK_LIBRARY )
 
+find_package( Boost 1.48.0 REQUIRED QUIET
+  COMPONENTS serialization
+  )
 if(NOT Boost_FOUND)
   message(FATAL_ERROR "Please make sure Boost 1.48.0 is installed on your system")
 endif()
 
+if(NOT SHARK_LIBRARY)
+  message(FATAL_ERROR "Cannot find SHARK_LIBRARY. set it with cmake -DSHARK_LIBRARY=")
+  return()
+endif()
+
+if(NOT SHARK_INCLUDE_DIR)
+  message(FATAL_ERROR "Cannot find SHARK_INCLUDE_DIR. Set it with cmake -DSHARK_INCLUDE_DIR=")
+  return()
+endif()
+
+get_filename_component(SHARK_INSTALLDIR ${SHARK_LIBRARY} PATH)
+get_filename_component(SHARK_INSTALLDIR ${SHARK_INSTALLDIR} PATH)
+
 if(NOT SHARK_CONFIG_FILE)
-  find_file(SHARK_CONFIG_FILE SharkConfig.cmake PATH_SUFFIXES lib/cmake/Shark share/Shark)
+  find_file(SHARK_CONFIG_FILE SharkConfig.cmake
+    PATHS ${SHARK_INSTALLDIR}
+    PATH_SUFFIXES lib/cmake/Shark share/Shark cmake/Shark)
 endif()
+
 if(SHARK_CONFIG_FILE)
   file(STRINGS "${SHARK_CONFIG_FILE}" SHARK_CONFIG_FILE_CONTENTS)
   string(REGEX REPLACE
@@ -81,13 +95,26 @@ if(SHARK_CONFIG_FILE)
 
   set(SHARK_VERSION_STRING 
   "${SHARK_VERSION_MAJOR}.${SHARK_VERSION_MINOR}.${SHARK_VERSION_PATCH}")
+endif()
 
+set(SHARK_USE_OPENMP_matched)
+#define SHARK_USE_OPENMP
+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()
 endif()
 
 INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Shark
-                                  REQUIRED_VARS SHARK_LIBRARY SHARK_INCLUDE_DIR
-                                  VERSION_VAR SHARK_VERSION_STRING)
+  REQUIRED_VARS SHARK_LIBRARY SHARK_INCLUDE_DIR
+  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} )
diff --git a/CMake/OTBCheckCpp11Keywords.cmake b/CMake/OTBCheckCpp11Keywords.cmake
index 707fe8b..337c6ce 100644
--- a/CMake/OTBCheckCpp11Keywords.cmake
+++ b/CMake/OTBCheckCpp11Keywords.cmake
@@ -18,6 +18,9 @@
 # limitations under the License.
 #
 
+# DEPRECATED: Not used in OTB cmake configuration
+# DEPRECATED: should be removed after 6.2 release
+
 include(CheckCXXSourceCompiles)
 
 set(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS})
diff --git a/CMake/OTBCheckSSEFeatures.cmake b/CMake/OTBCheckSSEFeatures.cmake
new file mode 100644
index 0000000..a7c67ed
--- /dev/null
+++ b/CMake/OTBCheckSSEFeatures.cmake
@@ -0,0 +1,63 @@
+function(check_sse_features sse_flags )
+  include(CheckCXXSourceRuns)
+  include(CheckCXXCompilerFlag)
+
+  set(${sse_flags} "0" PARENT_SCOPE)
+  # For apple assume sse2 is on for all intel builds, check for 64 and 32 bit versions
+  if(APPLE)
+      message(STATUS "For apple assume sse2 is on for all intel builds")
+    return()
+  endif()
+  set(sse_flags_detected)
+  if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
+    set(CMAKE_REQUIRED_FLAGS "-msse2")
+    set(sse_flags_detected "-msse2 -mfpmath=sse")
+  elseif(MSVC AND NOT CMAKE_CL_64)
+    set(CMAKE_REQUIRED_FLAGS "/arch:SSE2")
+    set(sse_flags_detected "/arch:SSE2")
+  endif()
+
+  check_cxx_source_runs("
+    #include <emmintrin.h>
+    int main ()
+    {
+     __m128d a, b;
+     double vals[2] = {0};
+     a = _mm_loadu_pd (vals);
+     b = _mm_add_pd (a,a);
+     _mm_storeu_pd (vals,b);
+     return (0);
+    }"
+    HAVE_SSE2_EXTENSIONS)
+
+  if(HAVE_SSE2_EXTENSIONS)
+    set(${sse_flags} "${sse_flags_detected}" PARENT_SCOPE)
+    return()
+  endif()
+
+  if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
+    set(CMAKE_REQUIRED_FLAGS "-msse")
+    set(sse_flags_detected "-msse -mfpmath=sse")
+  elseif(MSVC AND NOT CMAKE_CL_64)
+    set(CMAKE_REQUIRED_FLAGS "/arch:SSE")
+    set(sse_flags_detected "/arch:SSE")
+  endif()
+
+  check_cxx_source_runs("
+    #include <xmmintrin.h>
+    int main()
+    {
+        __m128 a, b;
+        float vals[4] = {0};
+        a = _mm_loadu_ps(vals);
+        b = a;
+        b = _mm_add_ps(a,b);
+        _mm_storeu_ps(vals,b);
+        return 0;
+    }" HAVE_SSE_EXTENSIONS)
+
+  if(HAVE_SSE_EXTENSIONS)
+    set(${sse_flags} "${sse_flags_detected}" PARENT_SCOPE)
+    return()
+  endif()
+endfunction() #check_sse_features
diff --git a/CMake/OTBConfig.cmake.in b/CMake/OTBConfig.cmake.in
index d036183..fcaed33 100644
--- a/CMake/OTBConfig.cmake.in
+++ b/CMake/OTBConfig.cmake.in
@@ -26,6 +26,11 @@
 # to load OTB's settings for an external project.
 @OTB_CONFIG_CODE@
 
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+#RK: TODO: add sse2, see4, see4.1, openmp flags
+
 # The C and C++ flags added by OTB to the cmake-configured flags.
 set(OTB_REQUIRED_C_FLAGS "@OTB_REQUIRED_C_FLAGS@")
 set(OTB_REQUIRED_CXX_FLAGS "@OTB_REQUIRED_CXX_FLAGS@")
@@ -39,12 +44,24 @@ set(OTB_VERSION_PATCH "@OTB_VERSION_PATCH@")
 # OTB's CMake directory with modules OTB uses.
 set(OTB_CMAKE_DIR "@OTB_CONFIG_CMAKE_DIR@")
 
+# OTB uses OPENMP
+set(OTB_USE_OPENMP "@OTB_USE_OPENMP@")
+
+# OTB uses SSE optim
+set(OTB_USE_SSE_FLAGS "@OTB_USE_SSE_FLAGS@")
+
+# use Find*.cmake files included in OTB package for external dependencies. (OpenCV, GDAL etc..)
+set(CMAKE_MODULE_PATH ${OTB_CMAKE_DIR} ${CMAKE_MODULE_PATH})
+
 # The location of the UseOTB.cmake file.
 set(OTB_USE_FILE "@OTB_USE_FILE@")
 
 # Whether OTB was built with shared libraries.
 set(OTB_BUILD_SHARED "@BUILD_SHARED_LIBS@")
 
+# Default value for WINDOWS_EXPORT_ALL_SYMBOLS target property
+set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "@OTB_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS@")
+
 # List of available OTB modules.
 set(OTB_MODULES_ENABLED "@OTB_CONFIG_MODULES_ENABLED@")
 
diff --git a/CMake/OTBModuleEnablement.cmake b/CMake/OTBModuleEnablement.cmake
index 5efd94a..4ec34d9 100644
--- a/CMake/OTBModuleEnablement.cmake
+++ b/CMake/OTBModuleEnablement.cmake
@@ -157,14 +157,18 @@ macro(otb_module_enable otb-module _needed_by)
   endif()
   if(NOT ${otb-module}_ENABLED)
     set(${otb-module}_ENABLED 1)
-    foreach(dep IN LISTS OTB_MODULE_${otb-module}_DEPENDS)
-      otb_module_enable(${dep} ${otb-module})
-    endforeach()
-    foreach(dep IN LISTS OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS)
-      otb_module_enable(${dep} ${otb-module})
-    endforeach()
-    if(${otb-module}_TESTED_BY AND (OTB_BUILD_DEFAULT_MODULES OR OTB_BUILD_ALL_MODULES_FOR_TESTS OR Module_${otb-module}))
-      otb_module_enable(${${otb-module}_TESTED_BY} "")
+    # if this module has an ACTIVATION_OPTION=OFF, don't bother enable its dependencies
+    if(NOT (OTB_MODULE_${otb-module}_ACTIVATION_OPTION
+     AND NOT ${OTB_MODULE_${otb-module}_ACTIVATION_OPTION}))
+      foreach(dep IN LISTS OTB_MODULE_${otb-module}_DEPENDS)
+        otb_module_enable(${dep} ${otb-module})
+      endforeach()
+      foreach(dep IN LISTS OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS)
+        otb_module_enable(${dep} ${otb-module})
+      endforeach()
+      if(${otb-module}_TESTED_BY AND (OTB_BUILD_DEFAULT_MODULES OR OTB_BUILD_ALL_MODULES_FOR_TESTS OR Module_${otb-module}))
+        otb_module_enable(${${otb-module}_TESTED_BY} "")
+      endif()
     endif()
   endif()
 endmacro()
@@ -200,11 +204,6 @@ set(OTB_MODULES_ENABLED "")
 set(OTB_MODULES_DISABLED "")
 foreach(otb-module ${OTB_MODULES_ALL})
   if(${otb-module}_ENABLED)
-    # check cxx11 requirement after all enable/disable macros have been passed
-    if(OTB_MODULE_${otb-module}_REQUIRES_CXX11 AND NOT OTB_HAS_CXX11)
-      message(FATAL_ERROR "Module ${otb-module} requires C++11 support. Consider adding -std=c++11 to your compiler flags or disabling it.")
-    endif()
-
     list(APPEND OTB_MODULES_ENABLED ${otb-module})
 
     # We will sort modules according to their dependency graph,
diff --git a/CMake/OTBModuleExternal.cmake b/CMake/OTBModuleExternal.cmake
index 400808a..8fdf276 100644
--- a/CMake/OTBModuleExternal.cmake
+++ b/CMake/OTBModuleExternal.cmake
@@ -23,6 +23,8 @@
 # OTB before including OTBModuleMacros. This is the preferred way to build an
 # OTB module outside of the OTB source tree.
 
+option(OTB_BUILD_MODULE_AS_STANDALONE "Build module as a standalone cmake project" OFF)
+
 if(NOT OTB_FOUND)
   message(FATAL_ERROR "OTB must be found before module macros can be used.")
 endif()
@@ -30,80 +32,89 @@ if(NOT OTB_VERSION VERSION_GREATER "5.2")
   message(FATAL_ERROR "Requires OTB 5.4 or later to work.")
 endif()
 if(NOT EXISTS ${OTB_CMAKE_DIR}/OTBModuleMacros.cmake)
-  message(FATAL_ERROR "Modules can only be built against an OTB build tree; they cannot be built against an OTB install tree.")
+  if(NOT OTB_BUILD_MODULE_AS_STANDALONE)
+    message(FATAL_ERROR "Modules can only be built against an OTB build tree; they cannot be built against an OTB install tree. You can build your module as a standalone CMake project instead, by activating the BUILD_MODULE_AS_STANDALONE option. Beware that dependency between remote modules will NOT be tracked.")
+  endif()
 endif()
 
-# Setup build locations.
-if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
-  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OTB_DIR}/bin)
-endif()
-if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
-  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OTB_DIR}/lib)
-endif()
-if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
-  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OTB_DIR}/lib)
-endif()
+if(OTB_BUILD_MODULE_AS_STANDALONE)
+  message(STATUS "You are building this module as a standalone CMake project. Beware that dependencies to other remote modules will not be tracked.")
+  include(OTBStandaloneModuleMacros)
+  otb_module_impl()
+else()
+  
+  # Setup build locations.
+  if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
+    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OTB_DIR}/bin)
+  endif()
+  if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
+    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OTB_DIR}/lib)
+  endif()
+  if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
+    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OTB_DIR}/lib)
+  endif()
 
-# OTB installation structure
-if(NOT OTB_INSTALL_RUNTIME_DIR)
-  set(OTB_INSTALL_RUNTIME_DIR bin)
-endif()
-if(NOT OTB_INSTALL_LIBRARY_DIR)
-  set(OTB_INSTALL_LIBRARY_DIR lib)
-endif()
-if(NOT OTB_INSTALL_ARCHIVE_DIR)
-  set(OTB_INSTALL_ARCHIVE_DIR lib)
-endif()
-if(NOT OTB_INSTALL_INCLUDE_DIR)
-  set(OTB_INSTALL_INCLUDE_DIR include/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR})
-endif()
-if(NOT OTB_INSTALL_DATA_DIR)
-  set(OTB_INSTALL_DATA_DIR share/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR})
-endif()
-if(NOT OTB_INSTALL_DOC_DIR)
-  set(OTB_INSTALL_DOC_DIR share/doc/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR})
-endif()
-if(NOT OTB_INSTALL_PACKAGE_DIR)
-  set(OTB_INSTALL_PACKAGE_DIR "lib/cmake/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}")
-endif()
+  # OTB installation structure
+  if(NOT OTB_INSTALL_RUNTIME_DIR)
+    set(OTB_INSTALL_RUNTIME_DIR bin)
+  endif()
+  if(NOT OTB_INSTALL_LIBRARY_DIR)
+    set(OTB_INSTALL_LIBRARY_DIR lib)
+  endif()
+  if(NOT OTB_INSTALL_ARCHIVE_DIR)
+    set(OTB_INSTALL_ARCHIVE_DIR lib)
+  endif()
+  if(NOT OTB_INSTALL_INCLUDE_DIR)
+    set(OTB_INSTALL_INCLUDE_DIR include/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR})
+  endif()
+  if(NOT OTB_INSTALL_DATA_DIR)
+    set(OTB_INSTALL_DATA_DIR share/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR})
+  endif()
+  if(NOT OTB_INSTALL_DOC_DIR)
+    set(OTB_INSTALL_DOC_DIR share/doc/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR})
+  endif()
+  if(NOT OTB_INSTALL_PACKAGE_DIR)
+    set(OTB_INSTALL_PACKAGE_DIR "lib/cmake/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}")
+  endif()
 
-# Use OTB's flags.
-set(CMAKE_C_FLAGS "${OTB_REQUIRED_C_FLAGS} ${CMAKE_C_FLAGS}")
-set(CMAKE_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
-set(CMAKE_EXE_LINKER_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")
-set(CMAKE_SHARED_LINKER_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}")
-set(CMAKE_MODULE_LINKER_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}")
-option(BUILD_SHARED_LIBS "Build OTB with shared libraries." ${OTB_BUILD_SHARED})
+  # Use OTB's flags.
+  set(CMAKE_C_FLAGS "${OTB_REQUIRED_C_FLAGS} ${CMAKE_C_FLAGS}")
+  set(CMAKE_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
+  set(CMAKE_EXE_LINKER_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")
+  set(CMAKE_SHARED_LINKER_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}")
+  set(CMAKE_MODULE_LINKER_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}")
+  option(BUILD_SHARED_LIBS "Build OTB with shared libraries." ${OTB_BUILD_SHARED})
 
-# Add the OTB_MODULES_DIR to the CMAKE_MODULE_PATH and then use the binary
-# directory for the project to write out new ones to.
-if(OTB_MODULES_DIR)
-  set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OTB_MODULES_DIR})
-endif()
-set(OTB_MODULES_DIR "${OTB_DIR}/${OTB_INSTALL_PACKAGE_DIR}/Modules")
+  # Add the OTB_MODULES_DIR to the CMAKE_MODULE_PATH and then use the binary
+  # directory for the project to write out new ones to.
+  if(OTB_MODULES_DIR)
+    set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OTB_MODULES_DIR})
+  endif()
+  set(OTB_MODULES_DIR "${OTB_DIR}/${OTB_INSTALL_PACKAGE_DIR}/Modules")
 
-#include(OTBExternalData)
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt)
-  include(CTest)
-  include(OTBModuleTest)
-endif()
+  #include(OTBExternalData)
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt)
+    include(CTest)
+    include(OTBModuleTest)
+  endif()
 
-include(OTBModuleMacros)
-include(otb-module.cmake)
-set(${otb-module}-targets ${otb-module}Targets)
-set(${otb-module}-targets-install "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}/${otb-module}Targets.cmake")
-set(${otb-module}_TARGETS_FILE_INSTALL "${${otb-module}-targets-install}")
-set(${otb-module}-targets-build "${OTB_DIR}/${OTB_INSTALL_PACKAGE_DIR}/Modules/${otb-module}Targets.cmake")
-set(${otb-module}_TARGETS_FILE_BUILD "${${otb-module}-targets-build}")
-otb_module_impl()
+  include(OTBModuleMacros)
+  include(otb-module.cmake)
+  set(${otb-module}-targets ${otb-module}Targets)
+  set(${otb-module}-targets-install "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}/${otb-module}Targets.cmake")
+  set(${otb-module}_TARGETS_FILE_INSTALL "${${otb-module}-targets-install}")
+  set(${otb-module}-targets-build "${OTB_DIR}/${OTB_INSTALL_PACKAGE_DIR}/Modules/${otb-module}Targets.cmake")
+  set(${otb-module}_TARGETS_FILE_BUILD "${${otb-module}-targets-build}")
+  otb_module_impl()
 
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt AND NOT ${otb-module}_NO_SRC AND "${${otb-module}-targets}")
-  install(EXPORT ${${otb-module}-targets} DESTINATION "${OTB_INSTALL_PACKAGE_DIR}/Modules"
-          COMPONENT Development)
-endif()
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt AND NOT ${otb-module}_NO_SRC AND "${${otb-module}-targets}")
+    install(EXPORT ${${otb-module}-targets} DESTINATION "${OTB_INSTALL_PACKAGE_DIR}/Modules"
+      COMPONENT Development)
+  endif()
 
-set(OTB_TEST_OUTPUT_DIR "${CMAKE_BINARY_DIR}/Testing/Temporary")
-if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
-  add_subdirectory(test)
-endif()
+  set(OTB_TEST_OUTPUT_DIR "${CMAKE_BINARY_DIR}/Testing/Temporary")
+  if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
+    add_subdirectory(test)
+  endif()
 
+endif()
diff --git a/CMake/OTBModuleMacros.cmake b/CMake/OTBModuleMacros.cmake
index f2591ca..0938a0f 100644
--- a/CMake/OTBModuleMacros.cmake
+++ b/CMake/OTBModuleMacros.cmake
@@ -230,9 +230,12 @@ macro(otb_module_impl)
     if (BUILD_SHARED_LIBS)
       # export flags are only added when building shared libs, they cause
       # mismatched visibility warnings when building statically.
-      add_compiler_export_flags(my_abi_flags)
-      set_property(TARGET ${otb-module} APPEND
-        PROPERTY COMPILE_FLAGS "${my_abi_flags}")
+      if (USE_COMPILER_HIDDEN_VISIBILITY)
+        # Prefer to use target properties supported by newer cmake
+        set_target_properties(${otb-module} PROPERTIES CXX_VISIBILITY_PRESET hidden)
+        set_target_properties(${otb-module} PROPERTIES C_VISIBILITY_PRESET hidden)
+        set_target_properties(${otb-module} PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
+      endif()
     endif()
   endif()
 
@@ -356,5 +359,6 @@ macro(otb_module_target _name)
 endmacro()
 
 macro(otb_module_requires_cxx11)
+  message(WARNING "otb_module_requires_cxx11 is deprecated since OTB version 6.2 which build with c++14 by default. You can safely remove the call to this macro.")
   set(OTB_MODULE_${otb-module}_REQUIRES_CXX11 1)
 endmacro()
diff --git a/CMake/OTBSetStandardCompilerFlags.cmake b/CMake/OTBSetStandardCompilerFlags.cmake
index 1d6d5fe..d2495d4 100644
--- a/CMake/OTBSetStandardCompilerFlags.cmake
+++ b/CMake/OTBSetStandardCompilerFlags.cmake
@@ -209,6 +209,9 @@ macro(check_compiler_platform_flags)
         set(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-auto-import")
       endif()
     else()
+      if(MSVC)
+        set(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} /MANIFEST:NO")
+      endif()
       # if CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS is on, then
       # BUILD_SHARED_LIBS works as it would on other systems
       if(NOT CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS)
@@ -232,35 +235,11 @@ macro(check_compiler_platform_flags)
       ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER "4.8" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.9") ))
       set(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -Wno-array-bounds")
     endif()
+  endif()
 
-   if(APPLE)
-     option(OTB_USE_64BITS_APPLE_TRUNCATION_WARNING "Turn on warnings on 64bits to 32bits truncations." OFF)
-     mark_as_advanced(OTB_USE_64BITS_APPLE_TRUNCATION_WARNING)
-
-     execute_process(COMMAND "${CMAKE_C_COMPILER}" --version
-       OUTPUT_VARIABLE _version ERROR_VARIABLE _version)
-
-     # -fopenmp breaks compiling the HDF5 library in shared library mode
-     # on the OS X platform -- at least with gcc 4.2 from Xcode.
-     set(compile_flag_lists CMAKE_C_FLAGS CMAKE_CXX_FLAGS
-       CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL
-       CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO
-       CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL
-       CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO)
-     foreach(listname ${compile_flag_lists})
-       if("${${listname}}" MATCHES ".*-fopenmp.*")
-         string(REPLACE "-fopenmp" "" tmpFlags "${${listname}}")
-         set(${listname} "${tmpFlags}")
-         message("-fopenmp causes incorrect compliation of HDF, removing from ${listname}")
-       endif()
-     endforeach()
-   endif()
-
-   # gcc must have -msse2 option to enable sse2 support
-   if(VNL_CONFIG_ENABLE_SSE2 OR VNL_CONFIG_ENABLE_SSE2_ROUNDING)
-     set(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -msse2")
-   endif()
-
+  if(APPLE)
+    option(OTB_USE_64BITS_APPLE_TRUNCATION_WARNING "Turn on warnings on 64bits to 32bits truncations." OFF)
+    mark_as_advanced(OTB_USE_64BITS_APPLE_TRUNCATION_WARNING)
   endif()
 
   #-----------------------------------------------------------------------------
@@ -293,6 +272,36 @@ macro(check_compiler_platform_flags)
     set(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} -mthreads")
   endif()
 
+  if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
+    set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
+    set(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} -Wl,--no-undefined")
+  endif()
+
+  # check for OpenMP
+  if(OTB_USE_OPENMP)
+    message(STATUS "OpenMP support requested with OTB_USE_OPENMP=${OTB_USE_OPENMP}")
+    find_package(OpenMP QUIET)
+  endif()
+  if(OPENMP_FOUND)
+    message(STATUS "Adding '${OpenMP_CXX_FLAGS}' to OTB_REQUIRED_CXX_FLAGS ")
+    set(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+    if(OpenMP_EXE_LINKER_FLAGS)
+      set(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
+    endif()
+  endif()
+
+  set(OTB_SSE_FLAGS)
+  if(OTB_USE_SSE_FLAGS)
+    message(STATUS "SIMD extensions requested with OTB_USE_SSE_FLAGS=${OTB_USE_SSE_FLAGS}")
+    include(OTBCheckSSEFeatures)
+    check_sse_features(OTB_SSE_FLAGS)
+    if(OTB_SSE_FLAGS)
+      message(STATUS "Adding '${OTB_SSE_FLAGS}' to OTB_REQUIRED_CXX_FLAGS")
+      set(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} ${OTB_SSE_FLAGS}")
+    endif()
+  endif()
 
   #-----------------------------------------------------------------------------
   # The frename-registers option does not work due to a bug in the gnu compiler.
@@ -300,6 +309,7 @@ macro(check_compiler_platform_flags)
   # will be produced.  This is first documented in the gcc4 man page.
   if(CMAKE_COMPILER_IS_GNUCXX)
     set(ALL_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
+    #TODO: list(REMOVE_DUPLICATES ALL_FLAGS)
     separate_arguments(ALL_FLAGS)
     foreach(COMP_OPTION ${ALL_FLAGS})
       if("${COMP_OPTION}" STREQUAL "-frename-registers")
@@ -349,4 +359,4 @@ macro(set_linker_stack_size_flag exe_target requested_stack_size)
   elseif(MINGW)
     set_target_properties(${exe_target} PROPERTIES LINK_FLAGS "-Wl,--stack,${requested_stack_size}")
   endif()
-endmacro()
\ No newline at end of file
+endmacro()
diff --git a/CMake/OTBModuleMacros.cmake b/CMake/OTBStandaloneModuleMacros.cmake
similarity index 71%
copy from CMake/OTBModuleMacros.cmake
copy to CMake/OTBStandaloneModuleMacros.cmake
index f2591ca..0ae7355 100644
--- a/CMake/OTBModuleMacros.cmake
+++ b/CMake/OTBStandaloneModuleMacros.cmake
@@ -18,30 +18,165 @@
 # limitations under the License.
 #
 
-get_filename_component(_OTBModuleMacros_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+#Adapted from ITKModuleExternal.cmake
+# This file ensures the appropriate variables are set up for a project extending
+# OTB before including OTBModuleMacros. This is the preferred way to build an
+# OTB module outside of the OTB source tree.
 
-set(_OTBModuleMacros_DEFAULT_LABEL "OTBModular")
+macro(otb_module_test)
+  include(../otb-module.cmake) # Load module meta-data
+  set(${otb-module-test}_LIBRARIES "")
+  foreach(dep IN LISTS OTB_MODULE_${otb-module-test}_DEPENDS)
+    list(APPEND ${otb-module-test}_LIBRARIES "${${dep}_LIBRARIES}")
+  endforeach()
+endmacro()
+
+
+function(otb_add_test)
+  set(largeinput_regex "LARGEINPUT{([^;{}\r\n]*)}")
+
+  set(_depends_on_largeinput OFF)
+  foreach(arg IN LISTS ARGN)
+     if("x${arg}" MATCHES "${largeinput_regex}")
+       string(REGEX REPLACE "${largeinput_regex}" "\\1" largeinput_relative_path "${arg}")
+       set(_fullpath "${OTB_DATA_LARGEINPUT_ROOT}/${largeinput_relative_path}")
+       list(APPEND _out_arg ${_fullpath})
+       set(_depends_on_largeinput ON)
+     else()
+       list(APPEND _out_arg ${arg})
+     endif()
+  endforeach()
+
+  if (_depends_on_largeinput AND NOT OTB_DATA_USE_LARGEINPUT)
+    return()
+  endif()
+
+  add_test(${_out_arg})
+
+  if("NAME" STREQUAL "${ARGV0}")
+    set(_iat_testname ${ARGV1})
+  else()
+    set(_iat_testname ${ARGV0})
+  endif()
+
+  if(otb-module)
+    set(_label ${otb-module})
+  else()
+    set(_label ${main_project_name})
+  endif()
 
-include(${_OTBModuleMacros_DIR}/OTBModuleAPI.cmake)
-include(${_OTBModuleMacros_DIR}/OTBModuleDoxygen.cmake)
-include(${_OTBModuleMacros_DIR}/OTBModuleHeaderTest.cmake)
-include(${_OTBModuleMacros_DIR}/OTBApplicationMacros.cmake)
+  set_property(TEST ${_iat_testname} PROPERTY LABELS ${_label})
 
-# With Apple's GGC <=4.2 and LLVM-GCC <=4.2 visibility of template
-# don't work. Set the option to off and hide it.
-if(APPLE AND CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION  VERSION_LESS "4.3")
-  set( USE_COMPILER_HIDDEN_VISIBILITY OFF CACHE INTERNAL "" )
-elseif(APPLE)
-  #RK:  compiler visibility nor woking on osx with appleclang xcode.
-  #gcc is a symlink to clang
-  set( USE_COMPILER_HIDDEN_VISIBILITY OFF CACHE INTERNAL "" )
-endif()
+endfunction()
 
-include(GenerateExportHeader)
 
-if(OTB_CPPCHECK_TEST)
-  include(${_OTBModuleMacros_DIR}/OTBModuleCPPCheckTest.cmake)
-endif()
+macro(otb_test_application)
+  cmake_parse_arguments(TESTAPPLICATION  "" "NAME;APP" "OPTIONS;TESTENVOPTIONS;VALID" ${ARGN} )
+  if(otb-module)
+    otb_add_test(NAME ${TESTAPPLICATION_NAME}
+                  COMMAND otbTestDriver
+                  ${TESTAPPLICATION_VALID}
+                  Execute $<TARGET_FILE:otbApplicationLauncherCommandLine>
+                  ${TESTAPPLICATION_APP}
+                  $<TARGET_FILE_DIR:otbapp_${TESTAPPLICATION_APP}>
+                  ${TESTAPPLICATION_OPTIONS}
+                  -testenv ${TESTAPPLICATION_TESTENVOPTIONS})
+    # Be sure that the ${otb-module}-all target triggers the build of commandline launcher and testdriver
+    add_dependencies(${otb-module}-all otbApplicationLauncherCommandLine)
+    add_dependencies(${otb-module}-all otbTestDriver)
+  else()
+    add_test(NAME ${TESTAPPLICATION_NAME}
+            COMMAND otbTestDriver
+            ${TESTAPPLICATION_VALID}
+            Execute $<TARGET_FILE:otbApplicationLauncherCommandLine>
+            ${TESTAPPLICATION_APP}
+            $<TARGET_FILE_DIR:otbapp_${TESTAPPLICATION_APP}>
+            ${TESTAPPLICATION_OPTIONS}
+            -testenv ${TESTAPPLICATION_TESTENVOPTIONS})
+  endif()
+endmacro()
+
+#-----------------------------------------------------------------------------
+# Function otb_add_test_mpi to run mpi tests
+function(otb_add_test_mpi)
+   set( _OPTIONS_ARGS )
+   set( _ONE_VALUE_ARGS NAME NBPROCS COMMAND)
+   set( _MULTI_VALUE_ARGS )
+   cmake_parse_arguments( TEST_MPI "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
+
+   # Test nb procs
+   if( NOT TEST_MPI_NBPROCS )
+     set(TEST_MPI_NBPROCS 2)
+   endif()
+   # Test command line
+   foreach(arg IN LISTS TEST_MPI_UNPARSED_ARGUMENTS)
+     list(APPEND ARGS ${arg})
+   endforeach()
+   set (test_parameters -np ${TEST_MPI_NBPROCS} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_MPI_COMMAND} ${ARGS})
+   otb_add_test(NAME ${TEST_MPI_NAME} COMMAND ${MPIEXEC} ${test_parameters})
+endfunction()
+
+
+macro(otb_module_target_label _target_name)
+  if(otb-module)
+    set(_label ${otb-module})
+    if(TARGET ${otb-module}-all)
+      add_dependencies(${otb-module}-all ${_target_name})
+    endif()
+  else()
+    set(_label ${_OTBModuleMacros_DEFAULT_LABEL})
+  endif()
+  set_property(TARGET ${_target_name} PROPERTY LABELS ${_label})
+endmacro()
+
+macro(otb_module_target_name _name)
+  get_property(_target_type TARGET ${_name} PROPERTY TYPE)
+  if (NOT ${_target_type} STREQUAL "EXECUTABLE")
+    if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
+      set_property(TARGET ${_name} PROPERTY VERSION 1)
+      set_property(TARGET ${_name} PROPERTY SOVERSION 1)
+    endif()
+    if("${_name}" MATCHES "^[Oo][Tt][Bb]")
+      set(_otb "")
+    else()
+      set(_otb "otb")
+    endif()
+    set_property(TARGET ${_name} PROPERTY OUTPUT_NAME ${_otb}${_name}-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR})
+  endif()
+endmacro()
+
+macro(otb_module_target_install _name)
+  #Use specific runtime components for executables and libraries separately when installing a module,
+  #considering that the target of a module could be either an executable or a library.
+  get_property(_ttype TARGET ${_name} PROPERTY TYPE)
+  if("${_ttype}" STREQUAL EXECUTABLE)
+    set(runtime_component Runtime)
+  else()
+    set(runtime_component RuntimeLibraries)
+  endif()
+  install(TARGETS ${_name}
+    EXPORT  ${${otb-module}-targets}
+    RUNTIME DESTINATION ${${otb-module}_INSTALL_RUNTIME_DIR} COMPONENT ${runtime_component}
+    LIBRARY DESTINATION ${${otb-module}_INSTALL_LIBRARY_DIR} COMPONENT RuntimeLibraries
+    ARCHIVE DESTINATION ${${otb-module}_INSTALL_ARCHIVE_DIR} COMPONENT Development
+    )
+endmacro()
+
+macro(otb_module_target _name)
+  set(_install 1)
+  foreach(arg ${ARGN})
+    if("${arg}" MATCHES "^(NO_INSTALL)$")
+      set(_install 0)
+    else()
+      message(FATAL_ERROR "Unknown argument [${arg}]")
+    endif()
+  endforeach()
+  otb_module_target_name(${_name})
+  otb_module_target_label(${_name})
+  if(_install)
+    otb_module_target_install(${_name})
+  endif()
+endmacro()
 
 macro(otb_module _name)
   otb_module_check_name(${_name})
@@ -109,12 +244,37 @@ macro(otb_module_check_name _name)
 endmacro()
 
 macro(otb_module_impl)
-  include(otb-module.cmake) # Load module meta-data
-  set(${otb-module}_INSTALL_RUNTIME_DIR ${OTB_INSTALL_RUNTIME_DIR})
-  set(${otb-module}_INSTALL_LIBRARY_DIR ${OTB_INSTALL_LIBRARY_DIR})
-  set(${otb-module}_INSTALL_ARCHIVE_DIR ${OTB_INSTALL_ARCHIVE_DIR})
-  set(${otb-module}_INSTALL_INCLUDE_DIR ${OTB_INSTALL_INCLUDE_DIR})
 
+  # Force shared lib and testing
+  OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON)
+  OPTION(BUILD_TESTING "Build testing" OFF)
+
+  find_path(OTB_DATA_ROOT
+  NAMES README-OTB-Data
+  HINTS $ENV{OTB_DATA_ROOT} ${CMAKE_CURRENT_SOURCE_DIR}/../OTB-Data)
+  mark_as_advanced(OTB_DATA_ROOT)
+
+  set(BASELINE       ${OTB_DATA_ROOT}/Baseline/OTB/Images)
+  set(BASELINE_FILES ${OTB_DATA_ROOT}/Baseline/OTB/Files)
+  set(INPUTDATA      ${OTB_DATA_ROOT}/Input)
+  set(TEMP           ${CMAKE_BINARY_DIR}/Testing/Temporary)
+  set(EXAMPLEDATA    ${OTB_DATA_ROOT}/Examples)
+  set(OTBAPP_BASELINE       ${OTB_DATA_ROOT}/Baseline/OTB-Applications/Images)
+  set(OTBAPP_BASELINE_FILES ${OTB_DATA_ROOT}/Baseline/OTB-Applications/Files)
+  
+  if(${BUILD_TESTING})
+    enable_testing()
+  endif()
+  
+  include(otb-module.cmake) # Load module meta-data
+  set(${otb-module}_INSTALL_RUNTIME_DIR ${CMAKE_INSTALL_PREFIX}/bin)
+  set(${otb-module}_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/lib)
+  set(${otb-module}_INSTALL_ARCHIVE_DIR ${CMAKE_INSTALL_PREFIX}/lib)
+  set(${otb-module}_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
+
+  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+  
   # Collect all sources and headers for IDE projects.
   set(_srcs "")
   if("${CMAKE_GENERATOR}" MATCHES "Xcode|Visual Studio|KDevelop"
@@ -194,9 +354,6 @@ macro(otb_module_impl)
     if(OTB_CPPCHECK_TEST)
       otb_module_cppcheck_test( ${otb-module} )
     endif()
-    if(EXISTS "${${otb-module}_SOURCE_DIR}/include" AND BUILD_TESTING)
-      otb_module_headertest(${otb-module})
-    endif()
   endif()
 
   if(EXISTS ${${otb-module}_SOURCE_DIR}/src/CMakeLists.txt)
@@ -205,9 +362,13 @@ macro(otb_module_impl)
   endif()
 
   if(EXISTS ${${otb-module}_SOURCE_DIR}/app/CMakeLists.txt AND NOT ${otb-module}_NO_SRC)
-    add_subdirectory(app)
+    add_subdirectory(app) 
   endif()
 
+  if(BUILD_TESTING AND EXISTS ${${otb-module}_SOURCE_DIR}/test/CMakeLists.txt)
+    add_subdirectory(test)
+    endif()
+
   if( OTB_MODULE_${otb-module}_ENABLE_SHARED )
     if(OTB_SOURCE_DIR)
       set(_export_header_file "${OTBCommon_BINARY_DIR}/${otb-module}Export.h")
@@ -255,106 +416,5 @@ macro(otb_module_impl)
   set(otb-module-LIBRARY_DIRS "${${otb-module}_SYSTEM_LIBRARY_DIRS}")
   set(otb-module-INCLUDE_DIRS "${otb-module-INCLUDE_DIRS-build}")
   set(otb-module-EXPORT_CODE "${otb-module-EXPORT_CODE-build}")
-  configure_file(${_OTBModuleMacros_DIR}/OTBModuleInfo.cmake.in ${OTB_MODULES_DIR}/${otb-module}.cmake @ONLY)
-  set(otb-module-INCLUDE_DIRS "${otb-module-INCLUDE_DIRS-install}")
-  set(otb-module-EXPORT_CODE "${otb-module-EXPORT_CODE-install}")
-  configure_file(${_OTBModuleMacros_DIR}/OTBModuleInfo.cmake.in CMakeFiles/${otb-module}.cmake @ONLY)
-  install(FILES
-    ${${otb-module}_BINARY_DIR}/CMakeFiles/${otb-module}.cmake
-    DESTINATION ${OTB_INSTALL_PACKAGE_DIR}/Modules
-    COMPONENT Development
-    )
-  otb_module_doxygen(${otb-module})   # module name
-endmacro()
-
-macro(otb_module_test)
-  include(../otb-module.cmake) # Load module meta-data
-  set(${otb-module-test}_LIBRARIES "")
-  otb_module_use(${OTB_MODULE_${otb-module-test}_DEPENDS})
-  foreach(dep IN LISTS OTB_MODULE_${otb-module-test}_DEPENDS)
-    list(APPEND ${otb-module-test}_LIBRARIES "${${dep}_LIBRARIES}")
-  endforeach()
-endmacro()
-
-macro(otb_module_warnings_disable)
-  foreach(lang ${ARGN})
-    if(MSVC)
-      string(REGEX REPLACE "(^| )[/-]W[0-4]( |$)" " "
-        CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -w")
-    elseif(BORLAND)
-      set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -w-")
-    else()
-      set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -w")
-    endif()
-  endforeach()
-endmacro()
-
-macro(otb_module_target_label _target_name)
-  if(otb-module)
-    set(_label ${otb-module})
-    if(TARGET ${otb-module}-all)
-      add_dependencies(${otb-module}-all ${_target_name})
-    endif()
-  else()
-    set(_label ${_OTBModuleMacros_DEFAULT_LABEL})
-  endif()
-  set_property(TARGET ${_target_name} PROPERTY LABELS ${_label})
-endmacro()
-
-macro(otb_module_target_name _name)
-  get_property(_target_type TARGET ${_name} PROPERTY TYPE)
-  if (NOT ${_target_type} STREQUAL "EXECUTABLE")
-    if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
-      set_property(TARGET ${_name} PROPERTY VERSION 1)
-      set_property(TARGET ${_name} PROPERTY SOVERSION 1)
-    endif()
-    if("${_name}" MATCHES "^[Oo][Tt][Bb]")
-      set(_otb "")
-    else()
-      set(_otb "otb")
-    endif()
-    set_property(TARGET ${_name} PROPERTY OUTPUT_NAME ${_otb}${_name}-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR})
-  endif()
-endmacro()
-
-macro(otb_module_target_export _name)
-  export(TARGETS ${_name} APPEND FILE ${${otb-module}-targets-build})
 endmacro()
 
-macro(otb_module_target_install _name)
-  #Use specific runtime components for executables and libraries separately when installing a module,
-  #considering that the target of a module could be either an executable or a library.
-  get_property(_ttype TARGET ${_name} PROPERTY TYPE)
-  if("${_ttype}" STREQUAL EXECUTABLE)
-    set(runtime_component Runtime)
-  else()
-    set(runtime_component RuntimeLibraries)
-  endif()
-  install(TARGETS ${_name}
-    EXPORT  ${${otb-module}-targets}
-    RUNTIME DESTINATION ${${otb-module}_INSTALL_RUNTIME_DIR} COMPONENT ${runtime_component}
-    LIBRARY DESTINATION ${${otb-module}_INSTALL_LIBRARY_DIR} COMPONENT RuntimeLibraries
-    ARCHIVE DESTINATION ${${otb-module}_INSTALL_ARCHIVE_DIR} COMPONENT Development
-    )
-endmacro()
-
-macro(otb_module_target _name)
-  set(_install 1)
-  foreach(arg ${ARGN})
-    if("${arg}" MATCHES "^(NO_INSTALL)$")
-      set(_install 0)
-    else()
-      message(FATAL_ERROR "Unknown argument [${arg}]")
-    endif()
-  endforeach()
-  otb_module_target_name(${_name})
-  otb_module_target_label(${_name})
-  otb_module_target_export(${_name})
-  if(_install)
-    otb_module_target_install(${_name})
-  endif()
-endmacro()
-
-macro(otb_module_requires_cxx11)
-  set(OTB_MODULE_${otb-module}_REQUIRES_CXX11 1)
-endmacro()
diff --git a/CMake/otbcli.bat.in b/CMake/otbcli.bat.in
index 165d833..3016c02 100644
--- a/CMake/otbcli.bat.in
+++ b/CMake/otbcli.bat.in
@@ -21,8 +21,8 @@ if exist %CURRENT_SCRIPT_DIR%..\@OTB_INSTALL_APP_DIR_NATIVE@ (
 )
 
 ::set GDAL_DATA, EPSG_CSV and update PATH
-if exist %CURRENT_SCRIPT_DIR%\..\otbenv.cmd (
-    call %CURRENT_SCRIPT_DIR%\..\otbenv.cmd
+if exist %CURRENT_SCRIPT_DIR%\..\otbenv.bat (
+    call %CURRENT_SCRIPT_DIR%\..\otbenv.bat
 )
 
 set LC_NUMERIC=C
diff --git a/CMake/otbcli.sh.in b/CMake/otbcli.sh.in
index 3026dad..65bec68 100644
--- a/CMake/otbcli.sh.in
+++ b/CMake/otbcli.sh.in
@@ -16,15 +16,6 @@ else
   OTB_CLI_LAUNCHER=otbApplicationLauncherCommandLine
 fi
 
-# works for install tree
-if [ -d "$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@" ]
-then
-  OTB_APPLICATION_PATH=$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@:$OTB_APPLICATION_PATH
-fi
-
-# export it to make it available to otbApplicationLauncherCommandLine environment
-export OTB_APPLICATION_PATH
-
 # avoid numerical issues caused by locale
 export LC_NUMERIC=C
 
@@ -32,6 +23,13 @@ export LC_NUMERIC=C
 # Note that OTB_APPLICATION_PATH is reset here.
 if [ -f "$CURRENT_SCRIPT_DIR/../otbenv.profile" ]; then
     . "$CURRENT_SCRIPT_DIR/../otbenv.profile"
+else
+    # works for install tree
+    if [ -d "$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@" ]; then
+	OTB_APPLICATION_PATH=$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@:$OTB_APPLICATION_PATH
+    fi
+    # export it to make it available to otbApplicationLauncherCommandLine environment
+    export OTB_APPLICATION_PATH
 fi
 
 # start the application
diff --git a/CMake/otbgui.bat.in b/CMake/otbgui.bat.in
index c02e16e..a450ce7 100644
--- a/CMake/otbgui.bat.in
+++ b/CMake/otbgui.bat.in
@@ -22,6 +22,11 @@ if exist %CURRENT_SCRIPT_DIR%../@OTB_INSTALL_APP_DIR@ (
 
 set LC_NUMERIC=C
 
+::set GDAL_DATA, EPSG_CSV and update PATH
+if exist %CURRENT_SCRIPT_DIR%\..\otbenv.bat (
+    call %CURRENT_SCRIPT_DIR%\..\otbenv.bat
+)
+
 :: start the application
 %OTB_GUI_LAUNCHER% %*
 endlocal
diff --git a/CMake/otbgui.sh.in b/CMake/otbgui.sh.in
index 5f6354a..8633efa 100644
--- a/CMake/otbgui.sh.in
+++ b/CMake/otbgui.sh.in
@@ -16,21 +16,19 @@ else
   OTB_GUI_LAUNCHER=otbApplicationLauncherQt
 fi
 
-# use the default install tree path for applications
-if [ -d "$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@" ]
-then
-  OTB_APPLICATION_PATH=$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@:$OTB_APPLICATION_PATH
-fi
-
-# export it to make it available to otbApplicationLauncherCommandLine environment
-export OTB_APPLICATION_PATH
-
 # avoid numerical issues caused by locale
 export LC_NUMERIC=C
 
 # Export GDAL_DATA, EPSG_CSV
 if [ -f "$CURRENT_SCRIPT_DIR/../otbenv.profile" ]; then
     . "$CURRENT_SCRIPT_DIR/../otbenv.profile"
+else
+    # use the default install tree path for applications
+    if [ -d "$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@" ]; then
+	OTB_APPLICATION_PATH=$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@:$OTB_APPLICATION_PATH
+    fi
+    # export it to make it available to otbApplicationLauncherCommandLine environment
+    export OTB_APPLICATION_PATH
 fi
 
 # start the application
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c900480..0d5309f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,7 +18,7 @@
 # limitations under the License.
 #
 
-cmake_minimum_required(VERSION 2.8.11)
+cmake_minimum_required(VERSION 3.1.0)
 
 foreach(p
     CMP0025 # CMake 3.0
@@ -43,6 +43,10 @@ endif()
 
 project(OTB)
 
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
 include(CMakeDependentOption)
 #
 # use ExternalProject
@@ -95,7 +99,7 @@ find_path(OTB_DATA_ROOT
   NAMES README-OTB-Data
   HINTS $ENV{OTB_DATA_ROOT} ${OTB_SOURCE_DIR}/../OTB-Data
 )
-mark_as_advanced(OTB_DATA_ROOT)
+#mark_as_advanced(OTB_DATA_ROOT)
 
 if(OTB_DATA_ROOT)
   repository_status(${OTB_DATA_ROOT} OTB_DATA_GIT_STATUS_MESSAGE)
@@ -106,7 +110,7 @@ set(main_project_name ${_OTBModuleMacros_DEFAULT_LABEL})
 #-----------------------------------------------------------------------------
 # OTB version number.
 set(OTB_VERSION_MAJOR "6")
-set(OTB_VERSION_MINOR "0")
+set(OTB_VERSION_MINOR "2")
 set(OTB_VERSION_PATCH "0")
 set(OTB_VERSION_STRING "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}.${OTB_VERSION_PATCH}")
 
@@ -209,10 +213,12 @@ endif()
 option(OTB_USE_DEPRECATED "Turn on the use and test of deprecated classes" OFF)
 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)
+#mark_as_advanced(OTB_SHOW_ALL_MSG_DEBUG)
 
 include(OTBSetStandardCompilerFlags)
 #---------------------------------------------------------------
@@ -227,9 +233,6 @@ set(CMAKE_EXE_LINKER_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}
 set(CMAKE_SHARED_LINKER_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}")
 set(CMAKE_MODULE_LINKER_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}")
 
-# detect some C++11 keywords
-include(OTBCheckCpp11Keywords)
-
 # TODO BUILD_TESTING is created by default by CTest.cmake, and is ON by default.
 option(BUILD_TESTING "Build the testing tree." OFF)
 
@@ -332,12 +335,7 @@ if(OTB_WRAP_PYTHON)
 set(OTB_CONFIG_CODE "${OTB_CONFIG_CODE}
 set(OTB_PYTHONPATH \"${OTB_BINARY_DIR}/${OTB_INSTALL_PYTHON_DIR}\")")
 endif()
-if(OTB_HAS_CXX11)
-  if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
-     "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-    set(OTB_REQUIRED_CXX_FLAGS " -std=c++11")
-  endif()
-endif()
+
 set(OTB_CONFIG_APPLICATION_PATH "${OTB_BINARY_DIR}/${OTB_INSTALL_APP_DIR}")
 set(OTB_CONFIG_TARGETS_CONDITION " AND NOT OTB_BINARY_DIR")
 set(OTB_CONFIG_TARGETS_FILE "${OTB_BINARY_DIR}/OTBTargets.cmake")
@@ -385,6 +383,8 @@ install(FILES ${OTB_BINARY_DIR}/CMakeFiles/OTBConfig.cmake
               ${OTB_BINARY_DIR}/OTBConfigVersion.cmake
               CMake/OTBApplicationMacros.cmake
               CMake/OTBModuleAPI.cmake
+              CMake/OTBStandaloneModuleMacros.cmake
+              CMake/OTBModuleExternal.cmake
               CMake/UseOTB.cmake
   DESTINATION ${OTB_INSTALL_PACKAGE_DIR}
   COMPONENT Development)
@@ -502,11 +502,12 @@ foreach(otb_option
     CMAKE_BUILD_TYPE
     CMAKE_C_FLAGS
     CMAKE_CXX_FLAGS
-    OTB_HAS_CXX11
     ${option_list}
     OTB_WRAP_PYTHON
     OTB_WRAP_JAVA
     OTB_DATA_ROOT
+    OTB_USE_OPENMP
+    OTB_USE_SSE_FLAGS
     )
     get_white_spaces("${otb_option}" spaces)
   message("${otb_option} ${spaces} = ${${otb_option}}")
diff --git a/Examples/Application/ApplicationExample.cxx b/Examples/Application/ApplicationExample.cxx
index 698c7d6..007a204 100644
--- a/Examples/Application/ApplicationExample.cxx
+++ b/Examples/Application/ApplicationExample.cxx
@@ -28,7 +28,7 @@
 
 //  Software Guide : BeginLatex
 // This example illustrates the creation of an application.
-// A new application is a class, which derives from \doxygen{otb}{Wrapper::Application} class.
+// A new application is a class, which derives from \subdoxygen{otb}{Wrapper}{Application} class.
 // We start by including the needed header files.
 //
 //  Software Guide : EndLatex
@@ -147,7 +147,7 @@ private:
     // Software Guide : BeginLatex
     // Application parameters declaration is done using \code{AddParameter()} method.
     // \code{AddParameter()} requires Parameter type, its name and description.
-    // \doxygen{otb}{Wrapper::Application} class contains methods to set parameters characteristics.
+    // \subdoxygen{otb}{Wrapper}{Application} class contains methods to set parameters characteristics.
     // Software Guide : EndLatex
 
     //  Software Guide : BeginCodeSnippet
diff --git a/Examples/Classification/BayesianPluginClassifier.cxx b/Examples/Classification/BayesianPluginClassifier.cxx
index 792b682..fa5d0c7 100644
--- a/Examples/Classification/BayesianPluginClassifier.cxx
+++ b/Examples/Classification/BayesianPluginClassifier.cxx
@@ -32,7 +32,7 @@
 // all the components of the classifier system and the data flow. This system
 // differs with the previous k-means clustering algorithms in several
 // ways. The biggest difference is that this classifier uses the
-// \subdoxygen{itk}{Statistics}{itkGaussianMembershipFunction} as membership functions
+// \subdoxygen{itk}{Statistics}{GaussianMembershipFunction} as membership functions
 // instead of the \subdoxygen{itk}{Statistics}{EuclideanDistanceMetric}. Since the
 // membership function is different, the membership function requires a
 // different set of parameters, mean vectors and covariance matrices. We
diff --git a/Examples/Classification/ExpectationMaximizationMixtureModelEstimator.cxx b/Examples/Classification/ExpectationMaximizationMixtureModelEstimator.cxx
index 3d16c58..63067f6 100644
--- a/Examples/Classification/ExpectationMaximizationMixtureModelEstimator.cxx
+++ b/Examples/Classification/ExpectationMaximizationMixtureModelEstimator.cxx
@@ -74,7 +74,7 @@
 // class assumes that such type of components.
 //
 // In the following example we use the \subdoxygen{itk}{Statistics}{ListSample} as
-// the sample (test and training). The \subdoxygen{itk}{Vector} is our measurement
+// the sample (test and training). The \doxygen{itk}{Vector} is our measurement
 // vector class. To store measurement vectors into two separate sample
 // container, we use the \subdoxygen{itk}{Statistics}{Subsample} objects.
 //
diff --git a/Examples/DataRepresentation/Image/ImageListExample.cxx b/Examples/DataRepresentation/Image/ImageListExample.cxx
index 81f21bc..d2f0962 100644
--- a/Examples/DataRepresentation/Image/ImageListExample.cxx
+++ b/Examples/DataRepresentation/Image/ImageListExample.cxx
@@ -21,7 +21,7 @@
 
 //  Software Guide : BeginLatex
 //
-//  This example illustrates the use of the \subdoxygen{otb}{ImageList}
+//  This example illustrates the use of the \doxygen{otb}{ImageList}
 //  class. This class provides the functionnalities needed in order to
 //  integrate image lists as data objects into the OTB
 //  pipeline. Indeed, if a \code{std::list< ImageType >} was used, the
@@ -29,10 +29,10 @@
 //  effects.
 //
 //  In this example, we will only present the basic operations which
-//  can be applied on an \subdoxygen{otb}{ImageList} object.
+//  can be applied on an \doxygen{otb}{ImageList} object.
 //
 //  The first thing required to read an image from a file is to include
-//  the header file of the \subdoxygen{otb}{ImageFileReader} class.
+//  the header file of the \doxygen{otb}{ImageFileReader} class.
 //
 //  Software Guide : EndLatex
 
@@ -70,7 +70,7 @@ int main(int itkNotUsed(argc), char * argv[])
 // Software Guide : BeginLatex
 //
 // We can now define the type for the image list. The
-// \subdoxygen{otb}{ImageList} class is templated over the type of image
+// \doxygen{otb}{ImageList} class is templated over the type of image
 // contained in it. This means that all images in a list must have the
 // same type.
 //
@@ -146,7 +146,7 @@ int main(int itkNotUsed(argc), char * argv[])
 //
 // Also, iterator classes are defined in order to have an efficient
 // mean of moving through the list. Finally, the
-// \subdoxygen{otb}{ImageListToImageListFilter} is provided in order
+// \doxygen{otb}{ImageListToImageListFilter} is provided in order
 // to implement filter which operate on image lists and produce image lists.
 // Software Guide : EndLatex
 
diff --git a/Examples/DisparityMap/FineRegistrationImageFilterExample.cxx b/Examples/DisparityMap/FineRegistrationImageFilterExample.cxx
index 7e730b2..97fb63f 100644
--- a/Examples/DisparityMap/FineRegistrationImageFilterExample.cxx
+++ b/Examples/DisparityMap/FineRegistrationImageFilterExample.cxx
@@ -125,7 +125,7 @@ int main(int argc, char** argv)
 
   // Software Guide : BeginLatex
   //
-  // Now, we declare and instantiate the \doxygen{otb}{FineCorrelationImageFilter} which is going to perform the registration:
+  // Now, we declare and instantiate the \doxygen{otb}{FineRegistrationImageFilter} which is going to perform the registration:
   //
   // Software Guide : EndLatex
 
@@ -188,7 +188,7 @@ int main(int argc, char** argv)
 
   // Software Guide : BeginLatex
   //
-  // The default matching metric used by the \doxygen{FineRegistrationImageFilter} is standard correlation.
+  // The default matching metric used by the \doxygen{otb}{FineRegistrationImageFilter} is standard correlation.
   // However, we may also use any other image-to-image metric provided by ITK. For instance, here is how we
   // would use the \doxygen{itk}{MutualInformationImageToImageMetric} (do not forget to include the proper header).
   //
diff --git a/Examples/FeatureExtraction/ExtractSegmentsExample.cxx b/Examples/FeatureExtraction/ExtractSegmentsExample.cxx
index 7fc0b46..4e4a370 100644
--- a/Examples/FeatureExtraction/ExtractSegmentsExample.cxx
+++ b/Examples/FeatureExtraction/ExtractSegmentsExample.cxx
@@ -99,7 +99,7 @@ int main(int argc, char * argv[])
 
   //  Software Guide : BeginLatex
   //
-  //  An \doxygen{ImageFileReader} class is also instantiated in order to read
+  //  An \doxygen{otb}{ImageFileReader} class is also instantiated in order to read
   //  image data from a file.
   //
   //  Software Guide : EndLatex
@@ -110,7 +110,7 @@ int main(int argc, char * argv[])
 
   //  Software Guide : BeginLatex
   //
-  // An \doxygen{ImageFileWriter} is instantiated in order to write the
+  // An \doxygen{otb}{ImageFileWriter} is instantiated in order to write the
   // output image to a file.
   //
   //  Software Guide : EndLatex
diff --git a/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx b/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx
index c1277a2..0cfac19 100644
--- a/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx
+++ b/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx
@@ -156,7 +156,7 @@ int main(int argc, char * argv[])
   //
   // Before calling the \code{Update()} method of the writer in order to
   // trigger the pipeline execution, we call the
-  // \doxygen{GenerateOutputInformation()} of the reader, so the LSD
+  // \code{GenerateOutputInformation()} of the reader, so the LSD
   // filter gets the information about image size and spacing.
   //
   // Software Guide : EndLatex
diff --git a/Examples/FeatureExtraction/RightAngleDetectionExample.cxx b/Examples/FeatureExtraction/RightAngleDetectionExample.cxx
index 5d7fa92..04eaaf3 100644
--- a/Examples/FeatureExtraction/RightAngleDetectionExample.cxx
+++ b/Examples/FeatureExtraction/RightAngleDetectionExample.cxx
@@ -194,7 +194,7 @@ int main(int argc, char * argv[])
   //
   // Before calling the \code{Update()} method of the writer in order to
   // trigger the pipeline execution, we call the
-  // \doxygen{GenerateOutputInformation()} of the reader, so the
+  // \code{GenerateOutputInformation()} of the reader, so the
   // filter gets the information about image size and spacing.
   //
   // Software Guide : EndLatex
diff --git a/Examples/FeatureExtraction/TouziEdgeDetectorExample.cxx b/Examples/FeatureExtraction/TouziEdgeDetectorExample.cxx
index df67b6b..a68817f 100644
--- a/Examples/FeatureExtraction/TouziEdgeDetectorExample.cxx
+++ b/Examples/FeatureExtraction/TouziEdgeDetectorExample.cxx
@@ -105,7 +105,7 @@ int main(int argc, char * argv[])
 
   //  Software Guide : BeginLatex
   //
-  //  An \doxygen{ImageFileReader} class is also instantiated in order to read
+  //  An \doxygen{otb}{ImageFileReader} class is also instantiated in order to read
   //  image data from a file.
   //
   //  Software Guide : EndLatex
@@ -116,7 +116,7 @@ int main(int argc, char * argv[])
 
   //  Software Guide : BeginLatex
   //
-  // An \doxygen{ImageFileWriter} is instantiated in order to write the
+  // An \doxygen{otb}{ImageFileWriter} is instantiated in order to write the
   // output image to a file.
   //
   //  Software Guide : EndLatex
diff --git a/Examples/IO/ExtractROI.cxx b/Examples/IO/ExtractROI.cxx
index 1479243..041ba51 100644
--- a/Examples/IO/ExtractROI.cxx
+++ b/Examples/IO/ExtractROI.cxx
@@ -242,7 +242,7 @@ int main(int argc, char * argv[])
   monoWriterType::Pointer monoWriter = monoWriterType::New();
 
   monoReader->SetFileName(inputFilename);
-  monoReader->Update(); //Necessaire pour connaitre le nombre de canaux dans l'image
+  monoReader->Update(); // Needed to know the number of channels in the image
   monoWriter->SetFileName(outputFilenameMIR);
   extractROIMonoFilter->SetInput(monoReader->GetOutput());
 
diff --git a/Examples/Iterators/ImageSliceIteratorWithIndex.cxx b/Examples/Iterators/ImageSliceIteratorWithIndex.cxx
index 1e4d4bf..1c7976d 100644
--- a/Examples/Iterators/ImageSliceIteratorWithIndex.cxx
+++ b/Examples/Iterators/ImageSliceIteratorWithIndex.cxx
@@ -24,8 +24,8 @@
 //
 // \index{Iterators!and image slices}
 //
-// The \doxygen{ImageSliceIteratorWithIndex} class is an extension of
-// \doxygen{ImageLinearIteratorWithIndex} from iteration along lines to
+// The \doxygen{itk}{ImageSliceIteratorWithIndex} class is an extension of
+// \doxygen{itk}{ImageLinearIteratorWithIndex} from iteration along lines to
 // iteration along both lines \emph{and planes} in an image.
 // A \emph{slice} is a 2D
 // plane spanned by two vectors pointing along orthogonal coordinate axes.  The
diff --git a/Examples/Iterators/NeighborhoodIterators5.cxx b/Examples/Iterators/NeighborhoodIterators5.cxx
index f379203..b182309 100644
--- a/Examples/Iterators/NeighborhoodIterators5.cxx
+++ b/Examples/Iterators/NeighborhoodIterators5.cxx
@@ -46,9 +46,9 @@
 // 2, stride = 3, end = 8)}, that represents the neighborhood offsets $(1,
 // -1)$, $(1, 0)$, $(1, 1)$ (see Figure~\ref{fig:NeighborhoodIteratorFig2}). If we
 // pass this slice as an extra argument to the
-// \doxygen{NeighborhoodInnerProduct} function, then the inner product is taken
+// \doxygen{itk}{NeighborhoodInnerProduct} function, then the inner product is taken
 // only along that slice.  This ``sliced'' inner product with a 1D
-// \doxygen{DerivativeOperator} gives the desired derivative.
+// \doxygen{itk}{DerivativeOperator} gives the desired derivative.
 //
 // The previous separable Gaussian filtering example can be rewritten using
 // slices and slice-based inner products.  In general, slice-based processing
@@ -57,7 +57,7 @@
 // Section~\ref{sec:NeighborhoodExample4} becomes impractical or inefficient.
 // Good examples of slice-based neighborhood processing can be found in any of
 // the ND anisotropic diffusion function objects, such as
-// \doxygen{CurvatureNDAnisotropicDiffusionFunction}.
+// \doxygen{itk}{CurvatureNDAnisotropicDiffusionFunction}.
 //
 // Software Guide : EndLatex
 
diff --git a/Examples/Learning/SEMModelEstimatorExample.cxx b/Examples/Learning/SEMModelEstimatorExample.cxx
index e13d2e6..65ec496 100644
--- a/Examples/Learning/SEMModelEstimatorExample.cxx
+++ b/Examples/Learning/SEMModelEstimatorExample.cxx
@@ -32,11 +32,11 @@
 // \doxygen{otb}{SEMClassifier}. This class performs a stochastic version
 // of the EM algorithm, but instead of inheriting from
 // \doxygen{itk}{ExpectationMaximizationMixtureModelEstimator}, we chose to
-// inherit from \subdoxygen{itk}{Statistics}{ListSample< TSample >},
+// inherit from \subdoxygen{itk}{Statistics}{ListSample},
 // in the same way as \doxygen{otb}{SVMClassifier}.
 //
 // The program begins with \doxygen{otb}{VectorImage} and outputs
-// \doxygen{itb}{Image}. Then appropriate header files have to be included:
+// \doxygen{otb}{Image}. Then appropriate header files have to be included:
 //
 // Software Guide : EndLatex
 
@@ -144,7 +144,7 @@ int main(int argc, char * argv[])
 // When an initial segmentation is available, the classifier may use it
 // as image (of type \code{OutputImageType}) or as a
 // \doxygen{itk}{SampleClassifier} result (of type
-// \subdoxygen{itk}{Statistics}{MembershipSample< SampleType >}).
+// \subdoxygen{itk}{Statistics}{MembershipSample}).
 //  Software Guide : EndLatex
 
 //  Software Guide : BeginCodeSnippet
@@ -205,7 +205,7 @@ int main(int argc, char * argv[])
 //  Software Guide : BeginLatex
 //
 //  The segmentation may outputs a result of type
-// \subdoxygen{itk}{Statistics}{MembershipSample< SampleType >} as it is the
+// \subdoxygen{itk}{Statistics}{MembershipSample} as it is the
 // case for the \doxygen{otb}{SVMClassifier}. But when using
 // \code{GetOutputImage} the output is directly an Image.
 //
diff --git a/Examples/Learning/SOMClassifierExample.cxx b/Examples/Learning/SOMClassifierExample.cxx
index d168105..cbd6f2d 100644
--- a/Examples/Learning/SOMClassifierExample.cxx
+++ b/Examples/Learning/SOMClassifierExample.cxx
@@ -77,7 +77,7 @@ int main(int argc, char* argv[])
 // As for the SOM learning step, we must define the types for the
 // \code{otb::SOMMap}, and therefore, also for the distance to be
 // used. We will also define the type for the SOM reader, which is
-// actually an \subdoxygen{otb}{ImageFileReader} which the appropriate
+// actually an \doxygen{otb}{ImageFileReader} which the appropriate
 // image type.
 //
 //  Software Guide : EndLatex
@@ -94,7 +94,7 @@ int main(int argc, char* argv[])
 //  Software Guide : BeginLatex
 //
 //  The classification will be performed by the
-//  \subdoxygen{otb}{SOMClassifier}, which, as most of the
+//  \doxygen{otb}{SOMClassifier}, which, as most of the
 //  classifiers, works on
 //  \subdoxygen{itk}{Statistics}{ListSample}s. In order to be able
 //  to perform an image classification, we will need to use the
@@ -218,7 +218,7 @@ int main(int argc, char* argv[])
 //
 //  Software Guide : BeginLatex
 //
-//  We also declare an \subdoxygen{itk}{ImageRegionIterator} in order
+//  We also declare an \doxygen{itk}{ImageRegionIterator} in order
 //  to fill the output image with the class labels.
 //
 //  Software Guide : EndLatex
diff --git a/Examples/Learning/SOMExample.cxx b/Examples/Learning/SOMExample.cxx
index 9f9d164..814214c 100644
--- a/Examples/Learning/SOMExample.cxx
+++ b/Examples/Learning/SOMExample.cxx
@@ -118,7 +118,7 @@ int main(int itkNotUsed(argc), char* argv[])
 //
 //  Software Guide : BeginLatex
 //
-// We can now define the type for the map. The \subdoxygen{otb}{SOMMap}
+// We can now define the type for the map. The \doxygen{otb}{SOMMap}
 // class is templated over the neuron type -- \code{PixelType} here
 // --, the distance type and the number of dimensions. Note that the
 // number of dimensions of the map could be different from the one of
diff --git a/Examples/Radiometry/AtmosphericCorrectionSequencement.cxx b/Examples/Radiometry/AtmosphericCorrectionSequencement.cxx
index a065605..9fa1862 100644
--- a/Examples/Radiometry/AtmosphericCorrectionSequencement.cxx
+++ b/Examples/Radiometry/AtmosphericCorrectionSequencement.cxx
@@ -38,8 +38,8 @@
 // an optical multispectral image similar to Pleiades.
 // These corrections are made in four steps :
 // \begin{itemize}
-// \item digital number to luminance correction;
-// \item luminance to refletance image conversion;
+// \item digital number to radiance correction;
+// \item radiance to refletance image conversion;
 // \item atmospheric correction for TOA (top of atmosphere) to TOC (top of canopy)
 // reflectance estimation;
 // \item correction of the adjacency effects taking into account the neighborhood contribution.
@@ -61,15 +61,15 @@
 // Let's look at the minimal code required to use this
 // algorithm. First, the following header defining the
 // \doxygen{otb}{AtmosphericCorrectionSequencement} class must be
-// included.  For the numerical to luminance image, luminance to
+// included.  For the numerical to radiance image, radiance to
 // refletance image, and reflectance to atmospheric correction image
 // corrections and the neighborhood correction, four header files are
 // required.
 // Software Guide : EndLatex
 
 // Software Guide : BeginCodeSnippet
-#include "otbImageToLuminanceImageFilter.h"
-#include "otbLuminanceToReflectanceImageFilter.h"
+#include "otbImageToRadianceImageFilter.h"
+#include "otbRadianceToReflectanceImageFilter.h"
 #include "otbReflectanceToSurfaceReflectanceImageFilter.h"
 #include "otbSurfaceAdjacencyEffectCorrectionSchemeFilter.h"
 // Software Guide : EndCodeSnippet
@@ -178,7 +178,7 @@ int main(int argc, char *argv[])
   //-------------------------------
   // Software Guide : BeginLatex
   //
-  // The \doxygen{otb}{ImageToLuminanceImageFilter}
+  // The \doxygen{otb}{ImageToRadianceImageFilter}
   // type is defined and instancied. This class uses a functor applied
   // to each component of each pixel ($\mathbf{X^{k}}$) whose formula is:
   //
@@ -188,7 +188,7 @@ int main(int argc, char *argv[])
   //
   // Where :
   // \begin{itemize}
-  // \item $\mathbf{L_{TOA}^{k}}$ is the incident luminance (in
+  // \item $\mathbf{L_{TOA}^{k}}$ is the incident radiance (in
   // $W.m^{-2}.sr^{-1}.\mu m^{-1}$);
   // \item $\mathbf{X^{k}}$ is the measured digital number (ie. the input image pixel component);
   // \item $\alpha_{k}$ is the absolute calibration gain for the channel k;
@@ -198,13 +198,13 @@ int main(int argc, char *argv[])
   // Software Guide : EndLatex
 
   // Software Guide : BeginCodeSnippet
-  typedef otb::ImageToLuminanceImageFilter<ImageType, ImageType>
-  ImageToLuminanceImageFilterType;
+  typedef otb::ImageToRadianceImageFilter<ImageType, ImageType>
+  ImageToRadianceImageFilterType;
 
-  ImageToLuminanceImageFilterType::Pointer filterImageToLuminance
-    = ImageToLuminanceImageFilterType::New();
+  ImageToRadianceImageFilterType::Pointer filterImageToRadiance
+    = ImageToRadianceImageFilterType::New();
 // Software Guide : EndCodeSnippet
-  typedef ImageToLuminanceImageFilterType::VectorType VectorType;
+  typedef ImageToRadianceImageFilterType::VectorType VectorType;
   VectorType alpha(nbOfComponent);
   VectorType beta(nbOfComponent);
   alpha.Fill(0);
@@ -227,17 +227,17 @@ int main(int argc, char *argv[])
   // Software Guide : EndLatex
 
   // Software Guide : BeginCodeSnippet
-  filterImageToLuminance->SetAlpha(alpha);
-  filterImageToLuminance->SetBeta(beta);
+  filterImageToRadiance->SetAlpha(alpha);
+  filterImageToRadiance->SetBeta(beta);
   // Software Guide : EndCodeSnippet
 
   //-------------------------------
   // Software Guide : BeginLatex
   //
-  // The \doxygen{otb}{LuminanceToReflectanceImageFilter}
+  // The \doxygen{otb}{RadianceToReflectanceImageFilter}
   // type is defined and instancied.
   // This class used a functor applied to each component of each pixel
-  // of the luminance filter output ($\mathbf{L_{TOA}^{k}}$):
+  // of the radiance filter output ($\mathbf{L_{TOA}^{k}}$):
   //
   // \begin{equation}
   // \rho_{TOA}^{k} = \frac{ \pi.\mathbf{L_{TOA}^{k}} } { E_{S}^{k}.cos(\theta_{S}).d/d_{0} }.
@@ -259,13 +259,13 @@ int main(int argc, char *argv[])
   // Software Guide : EndLatex
 
   // Software Guide : BeginCodeSnippet
-  typedef otb::LuminanceToReflectanceImageFilter<ImageType, ImageType>
-  LuminanceToReflectanceImageFilterType;
-  LuminanceToReflectanceImageFilterType::Pointer filterLuminanceToReflectance
-    = LuminanceToReflectanceImageFilterType::New();
+  typedef otb::RadianceToReflectanceImageFilter<ImageType, ImageType>
+  RadianceToReflectanceImageFilterType;
+  RadianceToReflectanceImageFilterType::Pointer filterRadianceToReflectance
+    = RadianceToReflectanceImageFilterType::New();
 // Software Guide : EndCodeSnippet
 
-  typedef LuminanceToReflectanceImageFilterType::VectorType VectorType;
+  typedef RadianceToReflectanceImageFilterType::VectorType VectorType;
 
   VectorType solarIllumination(nbOfComponent);
   solarIllumination.Fill(0);
@@ -287,11 +287,11 @@ int main(int argc, char *argv[])
   // Software Guide : EndLatex
 
   // Software Guide : BeginCodeSnippet
-  filterLuminanceToReflectance->SetZenithalSolarAngle(
+  filterRadianceToReflectance->SetZenithalSolarAngle(
     static_cast<double>(atof(argv[6])));
-  filterLuminanceToReflectance->SetDay(atoi(argv[7]));
-  filterLuminanceToReflectance->SetMonth(atoi(argv[8]));
-  filterLuminanceToReflectance->SetSolarIllumination(solarIllumination);
+  filterRadianceToReflectance->SetDay(atoi(argv[7]));
+  filterRadianceToReflectance->SetMonth(atoi(argv[8]));
+  filterRadianceToReflectance->SetSolarIllumination(solarIllumination);
   // Software Guide : EndCodeSnippet
 
 //-------------------------------
@@ -635,10 +635,10 @@ int main(int argc, char *argv[])
   // Software Guide : BeginCodeSnippet
   writer->SetFileName(argv[2]);
 
-  filterImageToLuminance->SetInput(reader->GetOutput());
-  filterLuminanceToReflectance->SetInput(filterImageToLuminance->GetOutput());
+  filterImageToRadiance->SetInput(reader->GetOutput());
+  filterRadianceToReflectance->SetInput(filterImageToRadiance->GetOutput());
   filterReflectanceToSurfaceReflectanceImageFilter->SetInput(
-    filterLuminanceToReflectance->GetOutput());
+    filterRadianceToReflectance->GetOutput());
   filterSurfaceAdjacencyEffectCorrectionSchemeFilter->SetInput(
     filterReflectanceToSurfaceReflectanceImageFilter->GetOutput());
 
diff --git a/Examples/Radiometry/test/CMakeLists.txt b/Examples/Radiometry/test/CMakeLists.txt
index 67e6f39..43c5edc 100644
--- a/Examples/Radiometry/test/CMakeLists.txt
+++ b/Examples/Radiometry/test/CMakeLists.txt
@@ -84,8 +84,8 @@ otb_add_test(NAME raTeAtmosphericCorrectionSequencementTest COMMAND ${OTB_TEST_D
     ${INPUTDATA}/atmosphericCorrectionSequencement_solar_illumination.txt
     ${INPUTDATA}/atmosphericCorrectionSequencement_wavelength_spectral_bands_spot4_1.txt
 
-    # ImageToLuminance parameters
-    # LuminanceToReflectance parameters
+    # ImageToRadiance parameters
+    # RadianceToReflectance parameters
     27.3    #solar azimuthal elevation
     4       #day
     12      #month
diff --git a/Examples/Segmentation/VectorConfidenceConnected.cxx b/Examples/Segmentation/VectorConfidenceConnected.cxx
index 357577c..3e4fa50 100644
--- a/Examples/Segmentation/VectorConfidenceConnected.cxx
+++ b/Examples/Segmentation/VectorConfidenceConnected.cxx
@@ -42,12 +42,13 @@
 //  This example illustrates the use of the confidence connected concept
 //  applied to images with vector pixel types. The confidence connected
 //  algorithm is implemented for vector images in the class
-//  \doxygen{VectorConfidenceConnected}. The basic difference between the
+//  \doxygen{itk}{VectorConfidenceConnectedImageFilter}. The basic difference
+//  between the
 //  scalar and vector version is that the vector version uses the covariance
 //  matrix instead of a variance, and a vector mean instead of a scalar mean.
 //  The membership of a vector pixel value to the region is measured using the
 //  Mahalanobis distance as implemented in the class
-//  \subdoxygen{Statistics}{MahalanobisDistanceThresholdImageFunction}.
+//  \subdoxygen{itk}{Statistics}{MahalanobisDistanceThresholdImageFunction}.
 //
 //  Software Guide : EndLatex
 
@@ -108,7 +109,7 @@ int main( int argc, char *argv[] )
   //  Software Guide : BeginLatex
   //
   //  We now declare the type of the region growing filter. In this case it
-  //  is the \doxygen{VectorConfidenceConnectedImageFilter}.
+  //  is the \doxygen{itk}{VectorConfidenceConnectedImageFilter}.
   //
   //  Software Guide : EndLatex
 
@@ -211,7 +212,7 @@ int main( int argc, char *argv[] )
   //  anatomical structure to be segmented. A small neighborhood around the
   //  seed point will be used to compute the initial mean and standard
   //  deviation for the inclusion criterion. The seed is passed in the form
-  //  of a \doxygen{Index} to the \code{SetSeed()} method.
+  //  of a \doxygen{itk}{Index} to the \code{SetSeed()} method.
   //
   //  \index{itk::Vector\-Confidence\-Connected\-Image\-Filter!SetSeed()}
   //  \index{itk::Vector\-Confidence\-Connected\-Image\-Filter!SetInitialNeighborhoodRadius()}
diff --git a/Examples/Simulation/LAIAndPROSAILToSensorResponse.cxx b/Examples/Simulation/LAIAndPROSAILToSensorResponse.cxx
index fa7886b..e61faf0 100644
--- a/Examples/Simulation/LAIAndPROSAILToSensorResponse.cxx
+++ b/Examples/Simulation/LAIAndPROSAILToSensorResponse.cxx
@@ -422,7 +422,7 @@ protected:
 // Software Guide : BeginLatex
 //
 // \code{TernaryFunctorImageFilterWithNBands} class is defined here.
-// This class inherits form \doxygen{itk::TernaryFunctorImageFilter} with additional nuber of band parameters.
+// This class inherits form \doxygen{itk}{TernaryFunctorImageFilter} with additional nuber of band parameters.
 // It's implementation is done to process Label, LAI, and mask image with Simulation functor.
 // Software Guide : EndLatex
 
@@ -595,7 +595,7 @@ int main(int argc, char *argv[])
   // Software Guide : BeginLatex
   //
   // Acquisition parameters are loaded using text file. A detailed definition of acquisition parameters can
-  // be found in class \doxygen{SailModel}.
+  // be found in class \doxygen{otb}{SailModel}.
   //
   // Software Guide : EndLatex
 
diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h
index 9fbc47e..bf6d799 100644
--- a/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h
+++ b/Modules/Adapters/GdalAdapters/include/otbOGRDataSourceWrapper.h
@@ -492,7 +492,7 @@ public:
    * underlying \c GDALDataset is required.
    * \pre The underlying \c GDALDataset must be valid, i.e.
    * <tt>m_DataSource != 0</tt>, an assertion is fired otherwise.
-   * \warning You must under no circonstance try to delete the \c GDALDataset
+   * \warning You must under no circumstance try to delete the \c GDALDataset
    * obtained this way.
    */
     ogr::version_proxy::GDALDatasetType & ogr();
diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRFeatureWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRFeatureWrapper.h
index 0e4e68e..945241b 100644
--- a/Modules/Adapters/GdalAdapters/include/otbOGRFeatureWrapper.h
+++ b/Modules/Adapters/GdalAdapters/include/otbOGRFeatureWrapper.h
@@ -142,7 +142,7 @@ public:
    * underlying \c OGRFeature is required.
    * \invariant The underlying \c OGRFeature must be valid, i.e.
    * <tt>m_DataSource != 0</tt>, an assertion is fired otherwise.
-   * \warning You must under no circonstance try to delete the \c OGRFeature
+   * \warning You must under no circumstance try to delete the \c OGRFeature
    * obtained this way.
    */
   OGRFeature & ogr() const;
diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.h
index 2e7e56f..8b3f627 100644
--- a/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.h
+++ b/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.h
@@ -175,7 +175,7 @@ public:
   /** Access to the raw underlying OGR data.
    * This function provides an abstraction leak in case deeper control on the
    * underlying \c OGRFeature is required.
-   * \warning You must under no circonstance try to delete the \c OGRField
+   * \warning You must under no circumstance try to delete the \c OGRField
    * obtained this way.
    */
   OGRField & ogr() const;
diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRLayerWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRLayerWrapper.h
index 6c129b9..8ebd74c 100644
--- a/Modules/Adapters/GdalAdapters/include/otbOGRLayerWrapper.h
+++ b/Modules/Adapters/GdalAdapters/include/otbOGRLayerWrapper.h
@@ -242,7 +242,7 @@ public:
    * underlying \c OGRLayer is required.
    * \pre The underlying \c OGRLayer must be valid, i.e.
    * <tt>m_Layer != 0</tt>, an assertion is fired otherwise.
-   * \warning You must under no circonstance try to delete the \c OGRLayer
+   * \warning You must under no circumstance try to delete the \c OGRLayer
    * obtained this way.
    */
   OGRLayer & ogr();
diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h b/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h
index 12c94cd..7fdc308 100644
--- a/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h
+++ b/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h
@@ -44,6 +44,8 @@ class OGRDataSource;
 class OGRSFDriver;
 #endif
 
+class OGRFeature;
+
 #include "OTBGdalAdaptersExport.h"
 
 namespace otb
@@ -212,6 +214,15 @@ OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType type);
   OTBGdalAdapters_EXPORT
   std::vector<std::string> GetAvailableDriversAsStringVector();
 
+  /**
+   * Returns true if the field 'index' is set and not-null in the given feature
+   *
+   * Before gdal 2.2, it calls OGRFeature::IsFieldSet().
+   * After gdal 2.2, it calls OGRFeature::IsFieldSetAndNotNull()
+   */
+   OTBGdalAdapters_EXPORT
+   bool IsFieldSetAndNotNull(OGRFeature *feat, int index);
+
 }
 }
 } // end namespace otb
diff --git a/Modules/Adapters/GdalAdapters/src/CMakeLists.txt b/Modules/Adapters/GdalAdapters/src/CMakeLists.txt
index 95a0167..4ba50ff 100644
--- a/Modules/Adapters/GdalAdapters/src/CMakeLists.txt
+++ b/Modules/Adapters/GdalAdapters/src/CMakeLists.txt
@@ -28,14 +28,9 @@ set(OTBGdalAdapters_SRC
   otbOGRDriversInit.cxx
   otbGeometriesToGeometriesFilter.cxx
   otbOGRDataSourceWrapper.cxx
+  otbOGRVersionProxy.cxx
   )
 
-if(OTB_USE_GDAL_20)
-  set(OTBGdalAdapters_SRC ${OTBGdalAdapters_SRC} otbOGRVersionProxy2x.cxx)
-else(Otb_use_gdal_20)
-  set(OTBGdalAdapters_SRC ${OTBGdalAdapters_SRC} otbOGRVersionProxy1x.cxx)
-endif(OTB_USE_GDAL_20)
-
 add_library(OTBGdalAdapters ${OTBGdalAdapters_SRC})
 target_link_libraries(OTBGdalAdapters 
   ${OTBBoost_LIBRARIES}
diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRFieldWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRFieldWrapper.cxx
index 3b54c06..49f95f0 100644
--- a/Modules/Adapters/GdalAdapters/src/otbOGRFieldWrapper.cxx
+++ b/Modules/Adapters/GdalAdapters/src/otbOGRFieldWrapper.cxx
@@ -37,6 +37,7 @@
 #endif
 #include "otbOGRFeatureWrapper.h"
 #include "otbJoinContainer.h"
+#include "otbOGRVersionProxy.h"
 #include <boost/array.hpp>
 /*===========================================================================*/
 /*===========================[ Static Assertions ]===========================*/
@@ -166,7 +167,7 @@ std::ostream & otb::ogr::Field::UncheckedPrintSelf(
 
 bool otb::ogr::Field::UncheckedHasBeenSet() const
 {
-  return m_Feature->IsFieldSet(m_index);
+  return otb::ogr::version_proxy::IsFieldSetAndNotNull(m_Feature.get(), m_index);
 }
 
 void otb::ogr::Field::UncheckedUnset() const
diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy2x.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx
similarity index 62%
rename from Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy2x.cxx
rename to Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx
index 2ca46ae..22b7a61 100644
--- a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy2x.cxx
+++ b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx
@@ -20,15 +20,26 @@
 
 #include "otbOGRVersionProxy.h"
 
+#include "itkMacro.h"
+
 #if defined(__GNUC__) || defined(__clang__)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wshadow"
+#if GDAL_VERSION_NUM<2000000
+#include "ogrsf_frmts.h"
+#else
 #include "gdal_priv.h"
+#endif
+#include "ogr_feature.h"
 #pragma GCC diagnostic pop
 #else
+#if GDAL_VERSION_NUM<2000000
+#include "ogrsf_frmts.h"
+#else
 #include "gdal_priv.h"
 #endif
-
+#include "ogr_feature.h"
+#endif // __GNUC__ || __clang__
 
 namespace otb
 {
@@ -37,24 +48,48 @@ namespace ogr
 namespace version_proxy
 {
 
+/*-------------------------[GDAL v2 API change]-------------------------------*/
 OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType type)
 {
+#if GDAL_VERSION_NUM<2000000
+  (void)type;
+  return false;
+#else
   return type == OFTInteger64;
+#endif
 }
 
+
 GDALDatasetType * Open(const char * filename, bool readOnly)
 {
+#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);
+#endif
 }
 
 void Close(GDALDatasetType * dataset)
 {
+#if GDAL_VERSION_NUM<2000000
+  OGRDataSource::DestroyDataSource(dataset);
+#else
   GDALClose(dataset);
+#endif
 }
 
 GDALDatasetType * Create(GDALDriverType * driver, const char * name)
 {
+#if GDAL_VERSION_NUM<2000000
+  GDALDatasetType * ds = driver->CreateDataSource(name);
+
+  if(ds)
+    ds->SetDriver(driver);
+
+  return ds;
+#else
   return driver->Create(name,0,0,0,GDT_Unknown,NULL);
+#endif
 }
 
 bool Delete(const char * name)
@@ -67,31 +102,50 @@ bool Delete(const char * name)
     poDriver = poDS->GetDriver();
     Close(poDS);
     }
-
+#if GDAL_VERSION_NUM<2000000
+  if(poDriver && poDriver->TestCapability(ODrCDeleteDataSource))
+    {
+    OGRErr ret = poDriver->DeleteDataSource(name);
+    return (ret == OGRERR_NONE);
+    }
+#else
   if(poDriver)
     {
     OGRErr ret = poDriver->Delete(name);
-
     return (ret == OGRERR_NONE);
     }
+#endif
   return false;
 }
 
 GDALDriverType *  GetDriverByName(const char * name)
 {
+#if GDAL_VERSION_NUM<2000000
+  return OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(name);
+#else
   return GetGDALDriverManager()->GetDriverByName(name);
+#endif
 }
 
 std::string GetDatasetClassName()
 {
+#if GDAL_VERSION_NUM<2000000
+  return std::string("OGRDataSource");
+#else
   return std::string("GDALDataset");
+#endif
 }
 
 std::string GetDriverClassName()
 {
+#if GDAL_VERSION_NUM<2000000
+  return std::string("OGRSFDriver");
+#else
   return std::string("GDALDriver");
+#endif
 }
 
+#if GDAL_VERSION_NUM>=2000000
 namespace raii
 {
 // This class is used in the next function, so as to prevent any
@@ -118,11 +172,14 @@ private:
   char ** m_P;
 };
 }
+#endif
 
 std::vector<std::string> GetFileListAsStringVector(GDALDatasetType * dataset)
 {
   std::vector<std::string> ret;
-
+#if GDAL_VERSION_NUM<2000000
+  ret.push_back(std::string(dataset->GetName()));
+#else
   raii::CharPPCapsule capsule(dataset->GetFileList());
 
   std::string files_str="";
@@ -136,35 +193,62 @@ std::vector<std::string> GetFileListAsStringVector(GDALDatasetType * dataset)
       ++i;
       }
     }
+#endif
   return ret;
 }
 
 bool SyncToDisk(GDALDatasetType * dataset)
 {
+#if GDAL_VERSION_NUM<2000000
+  const OGRErr res= dataset->SyncToDisk();
+  return (res == OGRERR_NONE);
+#else
   dataset->FlushCache();
-
   return true;
+#endif
 }
 
 std::vector<std::string> GetAvailableDriversAsStringVector()
 {
   std::vector<std::string> ret;
+#if GDAL_VERSION_NUM<2000000
+  int nbDrivers = OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount();
 
+  for(int i = 0; i < nbDrivers;++i)
+    {
+    ret.push_back(OGRSFDriverRegistrar::GetRegistrar()->GetDriver(i)->GetName());
+    }
+#else
   int nbDrivers = GetGDALDriverManager()->GetDriverCount();
 
   for(int i = 0; i < nbDrivers;++i)
     {
     ret.push_back(GDALGetDriverShortName(GetGDALDriverManager()->GetDriver(i)));
     }
-
+#endif
   return ret;
 }
 
 std::string GetDriverNameFromDataSource(const GDALDatasetType * ds)
 {
+#if GDAL_VERSION_NUM<2000000
+  return std::string(const_cast<GDALDatasetType *>(ds)->GetDriver()->GetName());
+#else
   return std::string(const_cast<GDALDatasetType *>(ds)->GetDriverName());
+#endif
+}
+
+/*----------------------[GDAL 2.2 change on IsFieldSet()]---------------------*/
+bool IsFieldSetAndNotNull(OGRFeature *feat, int index)
+{
+#if GDAL_VERSION_NUM<2020000
+  return feat->IsFieldSet(index);
+#else
+  return feat->IsFieldSetAndNotNull(index);
+#endif
 }
 
 }
 }
 } // end namespace
+
diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy1x.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy1x.cxx
deleted file mode 100644
index 47c9153..0000000
--- a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy1x.cxx
+++ /dev/null
@@ -1,140 +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 "otbOGRVersionProxy.h"
-
-#include "itkMacro.h"
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wshadow"
-#include "ogrsf_frmts.h"
-#pragma GCC diagnostic pop
-#else
-#include "ogrsf_frmts.h"
-#endif
-
-namespace otb
-{
-namespace ogr
-{
-namespace version_proxy
-{
-
-OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType itkNotUsed(type))
-{
-  return false;
-}
-
-
-GDALDatasetType * Open(const char * filename, bool readOnly)
-{
-  return OGRSFDriverRegistrar::Open(filename,!readOnly);
-}
-
-void Close(GDALDatasetType * dataset)
-{
-  OGRDataSource::DestroyDataSource(dataset);
-}
-
-GDALDatasetType * Create(GDALDriverType * driver, const char * name)
-{
-  GDALDatasetType * ds = driver->CreateDataSource(name);
-
-  if(ds)
-    ds->SetDriver(driver);
-
-  return ds;
-}
-
-bool Delete(const char * name)
-{
-  // Open dataset
-  GDALDatasetType * poDS = Open(name,false);
-  GDALDriverType * poDriver = ITK_NULLPTR;
-  if(poDS)
-    {
-    poDriver = poDS->GetDriver();
-    Close(poDS);
-    }
-
-  if(poDriver && poDriver->TestCapability(ODrCDeleteDataSource))
-    {
-
-    OGRErr ret = poDriver->DeleteDataSource(name);
-    return (ret == OGRERR_NONE);
-    }
-
-  return false;
-}
-
-GDALDriverType *  GetDriverByName(const char * name)
-{
-  return OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(name);
-}
-
-std::string GetDatasetClassName()
-{
-  return std::string("OGRDataSource");
-}
-
-std::string GetDriverClassName()
-{
-  return std::string("OGRSFDriver");
-}
-
-std::vector<std::string> GetFileListAsStringVector(GDALDatasetType * dataset)
-{
-  std::vector<std::string> ret;
-
-  ret.push_back(std::string(dataset->GetName()));
-
-  return ret;
-}
-
-bool SyncToDisk(GDALDatasetType * dataset)
-{
-  const OGRErr res= dataset->SyncToDisk();
-
-  return (res == OGRERR_NONE);
-}
-
-std::vector<std::string> GetAvailableDriversAsStringVector()
-{
-  std::vector<std::string> ret;
-
-  int nbDrivers = OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount();
-
-  for(int i = 0; i < nbDrivers;++i)
-    {
-    ret.push_back(OGRSFDriverRegistrar::GetRegistrar()->GetDriver(i)->GetName());
-    }
-
-  return ret;
-}
-
-std::string GetDriverNameFromDataSource(const GDALDatasetType * ds)
-{
-  return std::string(const_cast<GDALDatasetType *>(ds)->GetDriver()->GetName());
-}
-
-}
-}
-} // end namespace
diff --git a/Modules/Applications/AppChangeDetection/app/otbMultivariateAlterationDetector.cxx b/Modules/Applications/AppChangeDetection/app/otbMultivariateAlterationDetector.cxx
index c549407..668930e 100644
--- a/Modules/Applications/AppChangeDetection/app/otbMultivariateAlterationDetector.cxx
+++ b/Modules/Applications/AppChangeDetection/app/otbMultivariateAlterationDetector.cxx
@@ -46,58 +46,59 @@ private:
   void DoInit() ITK_OVERRIDE
   {
     SetName("MultivariateAlterationDetector");
-    SetDescription("Multivariate Alteration Detector");
+    SetDescription("Change detection by Multivariate Alteration Detector (MAD) algorithm");
 
     // Documentation
-    SetDocName("Multivariate alteration detector");
-    SetDocLongDescription("This application detects change between two given images.");
-    SetDocLimitations("None");
+    SetDocName("Multivariate Alteration Detector");
+    SetDocLongDescription("This application performs change detection between two multispectral"
+                          " images using the Multivariate Alteration Detector (MAD) [1]"
+                          " algorithm.\n\n"
+                          "The MAD algorithm produces a set of N change maps (where N is the"
+                          " maximum number of bands in first and second input images), with the"
+                          " following properties:\n"
+                          " - Change maps are differences of a pair of linear combinations of "
+                          " bands from image 1 and bands from image 2 chosen to maximize the "
+                          " correlation, \n"
+                          " - Each change map is orthogonal to the others.\n"
+                          " \n"
+                          "This is a statistical method which can handle different modalities"
+                          " and even different bands and number of bands between images. \n"
+                          " \n"
+                          "The application will output all change maps into a single multiband"
+                          " image. If numbers of bands in image 1 and 2 are equal, then change"
+                          " maps are sorted by increasing correlation. If number of bands is"
+                          " different, the change maps are sorted by decreasing correlation. \n"
+                          " \n"
+                          "The application will also print the following information:\n"
+                          "- Mean1 and Mean2 which are the mean values of bands for both input"
+                          " images,\n"
+                          "- V1 and V2 which are the two linear transform that are applied to"
+                          " input image 1 and input image 2 to build the change map,\n"
+                          "- Rho, the vector of correlation associated to each change map.\n"
+                          " \n"
+                          "The OTB filter used in this application has been implemented from the"
+                          " Matlab code kindly made available by the authors here [2]. Both cases"
+                          " (same and different number of bands) have been validated"
+                          " by comparing the output image to the output produced by the Matlab "
+                          " code, and the reference images for testing have been generated from "
+                          " the Matlab code using Octave." );
+
+                          
+    SetDocLimitations("Input images 1 and 2 should share exactly the same origin, spacing, size, and projection if any.");
     SetDocAuthors("OTB-Team");
-    SetDocSeeAlso(" This filter implements the Multivariate Alteration Detector, based "
-                  " on the following work: \n"
-                  " A. A. Nielsen and K. Conradsen, Multivariate alteration detection"
-                  " (mad) in multispectral, bi-temporal image data: a new approach to"
-                  " change detection studies, Remote Sens. Environ., vol. 64,"
-                  " pp. 1-19, (1998) \n"
-                  " \n"
-                  " Multivariate Alteration Detector takes two images as inputs and "
-                  " produce a set of N change maps as a VectorImage (where N is the "
-                  " maximum of number of bands in first and second image) with the "
-                  " following properties: \n"
-                  " - Change maps are differences of a pair of linear combinations of "
-                  " bands from image 1 and bands from image 2 chosen to maximize the "
-                  " correlation. \n"
-                  " - Each change map is orthogonal to the others. \n"
-                  " \n"
-                  " This is a statistical method which can handle different modalities "
-                  " and even different bands and number of bands between images. \n"
-                  " \n"
-                  " If numbers of bands in image 1 and 2 are equal, then change maps "
-                  " are sorted by increasing correlation. If number of bands is "
-                  " different, the change maps are sorted by decreasing correlation. \n"
-                  " \n"
-                  " The GetV1() and GetV2() methods allow retrieving the linear "
-                  " combinations used to generate the Mad change maps as a vnl_matrix of "
-                  " double, and the GetRho() method allows retrieving the correlation "
-                  " associated to each Mad change maps as a vnl_vector. \n"
-                  " \n"
-                  " This filter has been implemented from the Matlab code kindly made "
-                  " available by the authors here: \n"
-                  " http://www2.imm.dtu.dk/~aa/software.html \n"
-                  " \n"
-                  " Both cases (same and different number of bands) have been validated "
-                  " by comparing the output image to the output produced by the Matlab "
-                  " code, and the reference images for testing have been generated from "
-                  " the Matlab code using Octave." );
-
-    AddDocTag(Tags::FeatureExtraction);
+    SetDocSeeAlso("[1] Nielsen, A. A., & Conradsen, K. (1997). Multivariate alteration"
+                  "detection (MAD) in multispectral, bi-temporal image data: A new"
+                  "approach to change detection studies.\n"
+                  "[2] http://www2.imm.dtu.dk/~aa/software.html");
+
+    AddDocTag(Tags::ChangeDetection);
 
     AddParameter(ParameterType_InputImage,  "in1", "Input Image 1");
-    SetParameterDescription("in1","Image which describe initial state of the scene.");
+    SetParameterDescription("in1","Multiband image of the scene before perturbations");
     AddParameter(ParameterType_InputImage,  "in2", "Input Image 2");
-    SetParameterDescription("in2","Image which describe scene after perturbations.");
+    SetParameterDescription("in2","Mutliband image of the scene after perturbations.");
     AddParameter(ParameterType_OutputImage, "out", "Change Map");
-    SetParameterDescription("out","Image of detected changes.");
+    SetParameterDescription("out","Multiband image containing change maps. Each map will be in range [-1,1], so a floating point output type is advised.");
 
     AddRAMParameter();
 
diff --git a/Modules/Applications/AppClassification/app/CMakeLists.txt b/Modules/Applications/AppClassification/app/CMakeLists.txt
index 881f0b6..cfa104e 100644
--- a/Modules/Applications/AppClassification/app/CMakeLists.txt
+++ b/Modules/Applications/AppClassification/app/CMakeLists.txt
@@ -149,3 +149,6 @@ otb_create_application(
   NAME           VectorClassifier
   SOURCES        otbVectorClassifier.cxx
   LINK_LIBRARIES ${${otb-module}_LIBRARIES})
+
+# Mantis-1427 : temporary fix
+add_dependencies(${otb-module}-all otbapp_ImageEnvelope)
diff --git a/Modules/Applications/AppClassification/app/otbComputeImagesStatistics.cxx b/Modules/Applications/AppClassification/app/otbComputeImagesStatistics.cxx
index fbb8bef..0956eb7 100644
--- a/Modules/Applications/AppClassification/app/otbComputeImagesStatistics.cxx
+++ b/Modules/Applications/AppClassification/app/otbComputeImagesStatistics.cxx
@@ -48,12 +48,19 @@ private:
   void DoInit() ITK_OVERRIDE
   {
     SetName("ComputeImagesStatistics");
-    SetDescription("Computes global mean and standard deviation for each band from a set of images and optionally saves the results in an XML file.");
     SetDocName("Compute Images second order statistics");
-    SetDocLongDescription("This application computes a global mean and standard deviation for each band of a set of images and optionally saves the results in an XML file. The output XML is intended to be used an input for the TrainImagesClassifier application to normalize samples before learning.");
-    SetDocLimitations("Each image of the set must contain the same bands as the others (i.e. same types, in the same order).");
+    SetDescription("Computes global mean and standard deviation for each band "
+      "from a set of images and optionally saves the results in an XML file.");
+    SetDocLongDescription("This application computes a global mean and standard deviation "
+      "for each band of a set of images and optionally saves the results in an XML file."
+      " The output XML is intended to be used an input "
+      "for the TrainImagesClassifier application to normalize samples before learning. "
+      "You can also normalize the image with the XML file in the ImageClassifier application.");
+
+    SetDocLimitations("Each image of the set must contain the same bands as the others"
+                      " (i.e. same types, in the same order).");
     SetDocAuthors("OTB-Team");
-    SetDocSeeAlso("Documentation of the TrainImagesClassifier application.");
+    SetDocSeeAlso("Documentation of the TrainImagesClassifier and ImageClassifier application.");
 
     AddDocTag(Tags::Learning);
     AddDocTag(Tags::Analysis);
diff --git a/Modules/Applications/AppClassification/app/otbComputeOGRLayersFeaturesStatistics.cxx b/Modules/Applications/AppClassification/app/otbComputeOGRLayersFeaturesStatistics.cxx
index c9afc71..5f108a9 100644
--- a/Modules/Applications/AppClassification/app/otbComputeOGRLayersFeaturesStatistics.cxx
+++ b/Modules/Applications/AppClassification/app/otbComputeOGRLayersFeaturesStatistics.cxx
@@ -94,12 +94,23 @@ private:
 
        otb::ogr::Feature feature = layer.ogr().GetNextFeature();
        ClearChoices("feat");
+
+       std::vector<std::string> choiceKeys;
+
        for(int iField=0; iField<feature.ogr().GetFieldCount(); iField++)
          {
            std::string key, item = feature.ogr().GetFieldDefnRef(iField)->GetNameRef();
            key = item;
-           key.erase(std::remove(key.begin(), key.end(), ' '), key.end());
+
+           // Transform chain : lowercase and alphanumerical
+           key.erase(std::remove_if(key.begin(), key.end(), std::not1(std::ptr_fun(::isalnum))), key.end());
            std::transform(key.begin(), key.end(), key.begin(), tolower);
+
+           // Key must be unique
+           choiceKeys = GetChoiceKeys("feat");
+           while(choiceKeys.end() != std::find(choiceKeys.begin(), choiceKeys.end(), key) )
+             key.append("0");
+
            key="feat."+key;
            AddChoice(key,item);
          }
diff --git a/Modules/Applications/AppClassification/app/otbFusionOfClassifications.cxx b/Modules/Applications/AppClassification/app/otbFusionOfClassifications.cxx
index 15c821e..b31ae21 100644
--- a/Modules/Applications/AppClassification/app/otbFusionOfClassifications.cxx
+++ b/Modules/Applications/AppClassification/app/otbFusionOfClassifications.cxx
@@ -108,7 +108,7 @@ private:
         "confusion matrix file for the Dempster Shafer fusion.\n"
         "  - Input pixels with the NODATA label are not handled in the fusion of classification maps. Moreover, pixels for which all the input classifiers are set to NODATA "
         "keep this value in the output fused image.\n"
-        "  - In case of number of votes equality, the UNDECIDED label is attributed to the pixel.\n");
+        "  - In case of number of votes equality, the UNDECIDED label is attributed to the pixel.");
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
     SetDocSeeAlso("ImageClassifier application");
diff --git a/Modules/Applications/AppClassification/app/otbImageClassifier.cxx b/Modules/Applications/AppClassification/app/otbImageClassifier.cxx
index 47ba61e..1f94d27 100644
--- a/Modules/Applications/AppClassification/app/otbImageClassifier.cxx
+++ b/Modules/Applications/AppClassification/app/otbImageClassifier.cxx
@@ -50,7 +50,8 @@ public:
   itkTypeMacro(ImageClassifier, otb::Application);
 
   /** Filters typedef */
-  typedef UInt16ImageType                                                                      OutputImageType;
+  //typedef UInt16ImageType                                                                    OutputImageType;
+  typedef Int32ImageType                                                                       OutputImageType;
   typedef UInt8ImageType                                                                       MaskImageType;
   typedef itk::VariableLengthVector<FloatVectorImageType::InternalPixelType>                   MeasurementType;
   typedef otb::StatisticsXMLFileReader<MeasurementType>                                        StatisticsReader;
@@ -79,7 +80,7 @@ private:
 
     // Documentation
     SetDocName("Image Classification");
-    SetDocLongDescription("This application performs an image classification based on a model file produced by the TrainImagesClassifier application. Pixels of the output image will contain the class labels decided by the classifier (maximal class label = 65535). 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 co [...]
+    SetDocLongDescription("This application performs an image classification based on a model file produced by the TrainImagesClassifier application. Pixels of the output image will contain the class labels decided by the classifier (maximal class label = 65535). 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 co [...]
 
     SetDocLimitations("The input image must have the same type, order and number of bands than the images used to produce the statistics file and the SVM model file. If a statistics file was used during training by the TrainImagesClassifier, it is mandatory to use the same statistics file for classification. If an input mask is used, its size must match the input image size.");
     SetDocAuthors("OTB-Team");
@@ -101,6 +102,15 @@ private:
     SetParameterDescription("imstat", "A XML file containing mean and standard deviation to center and reduce samples before classification (produced by ComputeImagesStatistics application).");
     MandatoryOff("imstat");
 
+    AddParameter(ParameterType_Int, "nodatalabel", "Label mask value");
+    SetParameterDescription("nodatalabel", "By default, "
+      "hidden pixels will have the assigned label 0 in the output image. "
+      "It's possible to define the label mask by another value, "
+      "but be careful to not take a label from another class (max. 65535).");
+
+    SetDefaultParameterInt("nodatalabel", 0);
+    MandatoryOff("nodatalabel");
+
     AddParameter(ParameterType_OutputImage, "out",  "Output Image");
     SetParameterDescription( "out", "Output image containing class labels");
     SetDefaultOutputPixelType( "out", ImagePixelType_uint8);
@@ -165,6 +175,8 @@ private:
     m_ClassificationFilter = ClassificationFilterType::New();
     m_ClassificationFilter->SetModel(m_Model);
 
+    m_ClassificationFilter->SetDefaultLabel(GetParameterInt("nodatalabel"));
+
     // Normalize input image if asked
     if(IsParameterEnabled("imstat")  )
       {
diff --git a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx
index 36eeb31..d8e2342 100644
--- a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx
+++ b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx
@@ -18,536 +18,500 @@
  * limitations under the License.
  */
 
-
-#include "otbWrapperApplication.h"
+#include "otbWrapperCompositeApplication.h"
 #include "otbWrapperApplicationFactory.h"
 
-#include "otbVectorImage.h"
-#include "otbStreamingTraits.h"
-#include "itkImageRegionConstIterator.h"
-#include "itkListSample.h"
-#include "itkWeightedCentroidKdTreeGenerator.h"
-#include "itkKdTreeBasedKmeansEstimator.h"
-#include "otbStreamingShrinkImageFilter.h"
-#include "otbChangeLabelImageFilter.h"
-#include "otbRAMDrivenStrippedStreamingManager.h"
-
-#include "otbChangeLabelImageFilter.h"
-#include "itkLabelToRGBImageFilter.h"
-#include "otbReliefColormapFunctor.h"
-#include "itkScalarToRGBColormapImageFilter.h"
-
+#include "otbOGRDataToSamplePositionFilter.h"
 
 namespace otb
 {
-
-
 namespace Wrapper
 {
 
-namespace Functor
-{
-template <class TSample, class TLabel> class KMeansFunctor
-{
-public:
-  /** operator */
-  TLabel operator ()(const TSample& sample) const
-  {
-    typename CentroidMapType::const_iterator it = m_CentroidsMap.begin();
-
-    if (it == m_CentroidsMap.end())
-      {
-      return 0;
-      }
-
-    TLabel resp = it->first;
-    double minDist = m_Distance->Evaluate(sample, it->second);
-    ++it;
-
-    while (it != m_CentroidsMap.end())
-      {
-      double dist = m_Distance->Evaluate(sample, it->second);
-
-      if (dist < minDist)
-        {
-        resp = it->first;
-        minDist = dist;
-        }
-      ++it;
-      }
-    return resp;
-  }
-
-  /** Add a new centroid */
-  void AddCentroid(const TLabel& label, const TSample& centroid)
-  {
-    m_CentroidsMap[label] = centroid;
-  }
-
-  /** Constructor */
-  KMeansFunctor() : m_CentroidsMap(), m_Distance()
-  {
-    m_Distance = DistanceType::New();
-  }
-
-  bool operator !=(const KMeansFunctor& other) const
-  {
-    return m_CentroidsMap != other.m_CentroidsMap;
-  }
-
-private:
-  typedef std::map<TLabel, TSample>                   CentroidMapType;
-  typedef itk::Statistics::EuclideanDistanceMetric<TSample> DistanceType;
-
-  CentroidMapType m_CentroidsMap;
-  typename DistanceType::Pointer m_Distance;
-};
-}
-
-
-typedef FloatImageType::PixelType PixelType;
-typedef UInt16ImageType   LabeledImageType;
-
-typedef UInt16VectorImageType       VectorImageType;
-typedef VectorImageType::PixelType  VectorPixelType;
-typedef UInt8RGBImageType           RGBImageType;
-typedef RGBImageType::PixelType     RGBPixelType;
-
-
-typedef LabeledImageType::PixelType LabelType;
-
-
-typedef FloatVectorImageType::PixelType                               SampleType;
-typedef itk::Statistics::ListSample<SampleType> ListSampleType;
-typedef itk::Statistics::WeightedCentroidKdTreeGenerator<ListSampleType> TreeGeneratorType;
-typedef TreeGeneratorType::KdTreeType TreeType;
-typedef itk::Statistics::KdTreeBasedKmeansEstimator<TreeType> EstimatorType;
-typedef RAMDrivenStrippedStreamingManager<FloatVectorImageType> RAMDrivenStrippedStreamingManagerType;
-
-
-typedef itk::ImageRegionConstIterator<FloatVectorImageType> IteratorType;
-typedef itk::ImageRegionConstIterator<UInt8ImageType> LabeledIteratorType;
-
-typedef otb::StreamingShrinkImageFilter<FloatVectorImageType,
-     FloatVectorImageType>              ImageSamplingFilterType;
-
-typedef otb::StreamingShrinkImageFilter<UInt8ImageType,
-    UInt8ImageType>              MaskSamplingFilterType;
-typedef Functor::KMeansFunctor<SampleType, LabelType> KMeansFunctorType;
-typedef itk::UnaryFunctorImageFilter<FloatVectorImageType,
-    LabeledImageType, KMeansFunctorType>     KMeansFilterType;
-
-
-// Manual label LUT
- typedef otb::ChangeLabelImageFilter
- <LabeledImageType, VectorImageType>    ChangeLabelFilterType;
-
- // Continuous LUT mapping
-  typedef itk::ScalarToRGBColormapImageFilter<LabeledImageType, RGBImageType>      ColorMapFilterType;
-
-
-  typedef otb::Functor::ReliefColormapFunctor
-   <LabelType, RGBPixelType>           ReliefColorMapFunctorType;
-
-  typedef otb::ImageMetadataInterfaceBase ImageMetadataInterfaceType;
-
-
-class KMeansClassification: public Application
+class KMeansApplicationBase : public CompositeApplication
 {
 public:
   /** Standard class typedefs. */
-  typedef KMeansClassification Self;
-  typedef Application Superclass;
+  typedef KMeansApplicationBase Self;
+  typedef CompositeApplication Superclass;
   typedef itk::SmartPointer<Self> Pointer;
   typedef itk::SmartPointer<const Self> ConstPointer;
 
   /** Standard macro */
-  itkNewMacro(Self);
+  itkTypeMacro( KMeansApplicationBase, Superclass )
 
-  itkTypeMacro(KMeansClassification, otb::Application);
-
-private:
-  void DoInit() ITK_OVERRIDE
+protected:
+  void InitKMParams()
   {
-    SetName("KMeansClassification");
-    SetDescription("Unsupervised KMeans image classification");
+    AddApplication("ImageEnvelope", "imgenvelop", "mean shift smoothing");
+    AddApplication("PolygonClassStatistics", "polystats", "Polygon Class Statistics");
+    AddApplication("SampleSelection", "select", "Sample selection");
+    AddApplication("SampleExtraction", "extraction", "Sample extraction");
+
+    AddApplication("TrainVectorClassifier", "training", "Model training");
+    AddApplication("ComputeImagesStatistics", "imgstats", "Compute Images second order statistics");
+    AddApplication("ImageClassifier", "classif", "Performs a classification of the input image");
+
+    ShareParameter("in", "imgenvelop.in");
+    ShareParameter("out", "classif.out");
+
+    InitKMSampling();
+    InitKMClassification();
+
+    // init at the end cleanup
+    AddParameter( ParameterType_Empty, "cleanup", "Temporary files cleaning" );
+    EnableParameter( "cleanup" );
+    SetParameterDescription( "cleanup",
+                           "If activated, the application will try to clean all temporary files it created" );
+    MandatoryOff( "cleanup" );
+  }
 
-    SetDocName("Unsupervised KMeans image classification");
-    SetDocLongDescription("Performs unsupervised KMeans image classification.");
-    SetDocLimitations("None");
-    SetDocAuthors("OTB-Team");
-    SetDocSeeAlso(" ");
+  void InitKMSampling()
+  {
+    AddParameter(ParameterType_Int, "nc", "Number of classes");
+    SetParameterDescription("nc", "Number of modes, which will be used to generate class membership.");
+    SetDefaultParameterInt("nc", 5);
 
-    AddDocTag(Tags::Learning);
-	AddDocTag(Tags::Segmentation);
-	
-    AddParameter(ParameterType_InputImage, "in", "Input Image");
-    SetParameterDescription("in", "Input image to classify.");
-    AddParameter(ParameterType_OutputImage, "out", "Output Image");
-    SetParameterDescription("out", "Output image containing the class indexes.");
-    SetDefaultOutputPixelType("out",ImagePixelType_uint8);
-
-    AddRAMParameter();
-
-    AddParameter(ParameterType_InputImage, "vm", "Validity Mask");
-    SetParameterDescription("vm", "Validity mask. Only non-zero pixels will be used to estimate KMeans modes.");
-    MandatoryOff("vm");
     AddParameter(ParameterType_Int, "ts", "Training set size");
     SetParameterDescription("ts", "Size of the training set (in pixels).");
     SetDefaultParameterInt("ts", 100);
     MandatoryOff("ts");
-    AddParameter(ParameterType_Int, "nc", "Number of classes");
-    SetParameterDescription("nc", "Number of modes, which will be used to generate class membership.");
-    SetDefaultParameterInt("nc", 5);
+
     AddParameter(ParameterType_Int, "maxit", "Maximum number of iterations");
     SetParameterDescription("maxit", "Maximum number of iterations for the learning step.");
     SetDefaultParameterInt("maxit", 1000);
     MandatoryOff("maxit");
-    AddParameter(ParameterType_Float, "ct", "Convergence threshold");
-    SetParameterDescription("ct", "Convergence threshold for class centroid  (L2 distance, by default 0.0001).");
-    SetDefaultParameterFloat("ct", 0.0001);
-    MandatoryOff("ct");
+
     AddParameter(ParameterType_OutputFilename, "outmeans", "Centroid filename");
     SetParameterDescription("outmeans", "Output text file containing centroid positions");
     MandatoryOff("outmeans");
 
-    AddRANDParameter();
-
-    // Doc example parameter settings
-    SetDocExampleParameterValue("in", "QB_1_ortho.tif");
-    SetDocExampleParameterValue("ts", "1000");
-    SetDocExampleParameterValue("nc", "5");
-    SetDocExampleParameterValue("maxit", "1000");
-    SetDocExampleParameterValue("ct", "0.0001");
-    SetDocExampleParameterValue("out", "ClassificationFilterOutput.tif");
-
-    SetOfficialDocLink();
+    ShareKMSamplingParameters();
+    ConnectKMSamplingParams();
   }
 
-  void DoUpdateParameters() ITK_OVERRIDE
+  void InitKMClassification()
   {
-    // test of input image //
-    if (HasValue("in"))
-      {
-      // input image
-      FloatVectorImageType::Pointer inImage = GetParameterImage("in");
+    ShareKMClassificationParams();
+    ConnectKMClassificationParams();
+  }
 
-      RAMDrivenStrippedStreamingManagerType::Pointer streamingManager = RAMDrivenStrippedStreamingManagerType::New();
-      int availableRAM = GetParameterInt("ram");
-      streamingManager->SetAvailableRAMInMB(availableRAM);
-      float bias = 1.5; // empirical value
-      streamingManager->SetBias(bias);
-      FloatVectorImageType::RegionType largestRegion = inImage->GetLargestPossibleRegion();
-      FloatVectorImageType::SizeType largestRegionSize = largestRegion.GetSize();
-      streamingManager->PrepareStreaming(inImage, largestRegion);
+  void ShareKMSamplingParameters()
+  {
+    ShareParameter("ram", "polystats.ram");
+    ShareParameter("sampler", "select.sampler");
+    ShareParameter("vm", "polystats.mask", "Validity Mask",
+      "Validity mask, only non-zero pixels will be used to estimate KMeans modes.");
+  }
 
-      unsigned long nbDivisions = streamingManager->GetNumberOfSplits();
-      unsigned long largestPixNb = largestRegionSize[0] * largestRegionSize[1];
+  void ShareKMClassificationParams()
+  {
+    ShareParameter("nodatalabel", "classif.nodatalabel", "Label mask value",
+      "By default, hidden pixels will have the assigned label 0 in the output image. "
+      "It's possible to define the label mask by another value, "
+      "but be careful to not take a label from another class. "
+      "This application initialize the labels from 0 to N-1, "
+      "N is the number of class (defined by 'nc' parameter).");
+  }
 
-      unsigned long maxPixNb = largestPixNb / nbDivisions;
+  void ConnectKMSamplingParams()
+  {
+    Connect("polystats.in", "imgenvelop.in");
 
-      if (GetParameterInt("ts") > static_cast<int> (maxPixNb))
-        {
-        otbAppLogWARNING("The available RAM is too small to process this sample size of " << GetParameterInt("ts") <<
-            " pixels. The sample size will be reduced to " << maxPixNb << " pixels." << std::endl);
-        this->SetParameterInt("ts",maxPixNb, false);
-        }
+    Connect("select.in", "polystats.in");
+    Connect("select.vec", "polystats.vec");
+    Connect("select.ram", "polystats.ram");
 
-      this->SetMaximumParameterIntValue("ts", maxPixNb);
-      }
+    Connect("extraction.in", "select.in");
+    Connect("extraction.field", "select.field");
+    Connect("extraction.vec", "select.out");
+    Connect("extraction.ram", "polystats.ram");
   }
 
-  void DoExecute() ITK_OVERRIDE
+  void ConnectKMClassificationParams()
   {
-    GetLogger()->Debug("Entering DoExecute\n");
+    Connect("training.cfield", "extraction.field");
+    Connect("training.io.stats","imgstats.out");
 
-    m_InImage = GetParameterImage("in");
-    m_InImage->UpdateOutputInformation();
-    UInt8ImageType::Pointer maskImage;
+    Connect("classif.in", "imgenvelop.in");
+    Connect("classif.model", "training.io.out");
+    Connect("classif.ram", "polystats.ram");
+    Connect("classif.imstat", "imgstats.out");
+  }
 
-    std::ostringstream message("");
+  void ConnectKMClassificationMask()
+  {
+    otbAppLogINFO("Using input mask ...");
+    Connect("select.mask", "polystats.mask");
+    Connect("classif.mask", "select.mask");
+  }
 
-    int nbsamples = GetParameterInt("ts");
-    const unsigned int nbClasses = GetParameterInt("nc");
+  void ComputeImageEnvelope(const std::string &vectorFileName)
+  {
+    GetInternalApplication("imgenvelop")->SetParameterString("out", vectorFileName, false);
+    GetInternalApplication("imgenvelop")->ExecuteAndWriteOutput();
+  }
 
-    /*******************************************/
-    /*           Sampling data                 */
-    /*******************************************/
+  void ComputeAddField(const std::string &vectorFileName,
+                       const std::string &fieldName)
+  {
+    otbAppLogINFO("add field in the layer ...");
+    otb::ogr::DataSource::Pointer ogrDS;
+    ogrDS = otb::ogr::DataSource::New(vectorFileName, otb::ogr::DataSource::Modes::Update_LayerUpdate);
+    otb::ogr::Layer layer = ogrDS->GetLayer(0);
+
+    OGRFieldDefn classField(fieldName.c_str(), OFTInteger);
+    classField.SetWidth(classField.GetWidth());
+    classField.SetPrecision(classField.GetPrecision());
+    ogr::FieldDefn classFieldDefn(classField);
+    layer.CreateField(classFieldDefn);
+
+    otb::ogr::Layer::const_iterator it = layer.cbegin();
+    otb::ogr::Layer::const_iterator itEnd = layer.cend();
+    for( ; it!=itEnd ; ++it)
+    {
+      ogr::Feature dstFeature(layer.GetLayerDefn());
+      dstFeature.SetFrom( *it, TRUE);
+      dstFeature.SetFID(it->GetFID());
+      dstFeature[fieldName].SetValue<int>(0);
+      layer.SetFeature(dstFeature);
+    }
+    const OGRErr err = layer.ogr().CommitTransaction();
+    if (err != OGRERR_NONE)
+      itkExceptionMacro(<< "Unable to commit transaction for OGR layer " << layer.ogr().GetName() << ".");
+    ogrDS->SyncToDisk();
+  }
 
-    otbAppLogINFO("-- SAMPLING DATA --"<<std::endl);
+  void ComputePolygonStatistics(const std::string &statisticsFileName,
+                                const std::string &fieldName)
+  {
+    std::vector<std::string> fieldList = {fieldName};
 
-    // Update input images information
-    m_InImage->UpdateOutputInformation();
+    GetInternalApplication("polystats")->SetParameterStringList("field", fieldList, false);
+    GetInternalApplication("polystats")->SetParameterString("out", statisticsFileName, false);
 
-    bool maskFlag = IsParameterEnabled("vm");
-    if (maskFlag)
-      {
-      otbAppLogINFO("sample choice using mask "<<std::endl);
-      maskImage = GetParameterUInt8Image("vm");
-      maskImage->UpdateOutputInformation();
-      if (m_InImage->GetLargestPossibleRegion() != maskImage->GetLargestPossibleRegion())
-        {
-        GetLogger()->Error("Mask image and input image have different sizes.");
-        return;
-        }
-      }
+    ExecuteInternal("polystats");
+  }
 
-    // Training sample lists
-    ListSampleType::Pointer sampleList = ListSampleType::New();
-    sampleList->SetMeasurementVectorSize(m_InImage->GetNumberOfComponentsPerPixel());
+  void SelectAndExtractSamples(const std::string &statisticsFileName,
+                               const std::string &fieldName,
+                               const std::string &sampleFileName,
+                               int NBSamples)
+  {
+    /* SampleSelection */
+    GetInternalApplication("select")->SetParameterString("out", sampleFileName, false);
 
-    //unsigned int init_means_index = 0;
+    UpdateInternalParameters("select");
+    GetInternalApplication("select")->SetParameterString("instats", statisticsFileName, false);
+    GetInternalApplication("select")->SetParameterString("field", fieldName, false);
 
-    // Sample dimension and max dimension
-    const unsigned int nbComp = m_InImage->GetNumberOfComponentsPerPixel();
-    unsigned int sampleSize = nbComp;
-    unsigned int totalSamples = 0;
+    GetInternalApplication("select")->SetParameterString("strategy", "constant", false);
+    GetInternalApplication("select")->SetParameterInt("strategy.constant.nb", NBSamples, false);
 
-    // sampleSize = std::min(nbComp, maxDim);
+    if( IsParameterEnabled("rand"))
+      GetInternalApplication("select")->SetParameterInt("rand", GetParameterInt("rand"), false);
 
-    EstimatorType::ParametersType initialMeans(nbComp * nbClasses);
-    initialMeans.Fill(0);
+    // select sample positions
+    ExecuteInternal("select");
 
-    // use image and mask shrink
+    /* SampleExtraction */
+    UpdateInternalParameters("extraction");
 
-    ImageSamplingFilterType::Pointer imageSampler = ImageSamplingFilterType::New();
-    imageSampler->SetInput(m_InImage);
+    GetInternalApplication("extraction")->SetParameterString("outfield", "prefix", false);
+    GetInternalApplication("extraction")->SetParameterString("outfield.prefix.name", "value_", false);
 
-    double theoricNBSamplesForKMeans = nbsamples;
+    // extract sample descriptors
+    GetInternalApplication("extraction")->ExecuteAndWriteOutput();
+  }
 
-    const double upperThresholdNBSamplesForKMeans = 1000 * 1000;
-    const double actualNBSamplesForKMeans = std::min(theoricNBSamplesForKMeans, upperThresholdNBSamplesForKMeans);
+  void TrainKMModel(FloatVectorImageType *image,
+                    const std::string &sampleTrainFileName,
+                    const std::string &modelFileName)
+  {
+    std::vector<std::string> extractOutputList = {sampleTrainFileName};
+    GetInternalApplication("training")->SetParameterStringList("io.vd", extractOutputList, false);
+    UpdateInternalParameters("training");
+
+    // set field names
+    std::string selectPrefix = GetInternalApplication("extraction")->GetParameterString("outfield.prefix.name");
+    unsigned int nbBands = image->GetNumberOfComponentsPerPixel();
+    std::vector<std::string> selectedNames;
+    for( unsigned int i = 0; i < nbBands; i++ )
+      {
+      std::ostringstream oss;
+      oss << i;
+      selectedNames.push_back( selectPrefix + oss.str() );
+      }
+    GetInternalApplication("training")->SetParameterStringList("feat", selectedNames, false);
 
-    otbAppLogINFO(<< actualNBSamplesForKMeans << " is the maximum sample size that will be used." << std::endl);
+    GetInternalApplication("training")->SetParameterString("classifier", "sharkkm", false);
+    GetInternalApplication("training")->SetParameterInt("classifier.sharkkm.maxiter",
+                                                        GetParameterInt("maxit"), false);
+    GetInternalApplication("training")->SetParameterInt("classifier.sharkkm.k",
+                                                        GetParameterInt("nc"), false);
 
-    const double shrinkFactor = vcl_floor(
-                                          vcl_sqrt(
-                                                   m_InImage->GetLargestPossibleRegion().GetNumberOfPixels()
-                                                       / actualNBSamplesForKMeans));
-    imageSampler->SetShrinkFactor(shrinkFactor);
-    imageSampler->Update();
+    if( IsParameterEnabled("rand"))
+      GetInternalApplication("training")->SetParameterInt("rand", GetParameterInt("rand"), false);
+    GetInternalApplication("training")->GetParameterByKey("v")->SetActive(false);
 
-    MaskSamplingFilterType::Pointer maskSampler;
-    LabeledIteratorType m_MaskIt;
-    if (maskFlag)
-      {
-      maskSampler = MaskSamplingFilterType::New();
-      maskSampler->SetInput(maskImage);
-      maskSampler->SetShrinkFactor(shrinkFactor);
-      maskSampler->Update();
-      m_MaskIt = LabeledIteratorType(maskSampler->GetOutput(), maskSampler->GetOutput()->GetLargestPossibleRegion());
-      m_MaskIt.GoToBegin();
-      }
-    // Then, build the sample list
+    GetInternalApplication("training")->SetParameterString("io.out", modelFileName, false);
 
-    IteratorType it(imageSampler->GetOutput(), imageSampler->GetOutput()->GetLargestPossibleRegion());
+    ExecuteInternal( "training" );
+    otbAppLogINFO("output model : " << GetInternalApplication("training")->GetParameterString("io.out"));
+  }
 
-    it.GoToBegin();
+  void ComputeImageStatistics(const std::string &imageFileName,
+                                               const std::string &imagesStatsFileName)
+  {
+    std::vector<std::string> imageFileNameList = {imageFileName};
+    GetInternalApplication("imgstats")->SetParameterStringList("il", imageFileNameList, false);
+    GetInternalApplication("imgstats")->SetParameterString("out", imagesStatsFileName, false);
 
-    SampleType min;
-    SampleType max;
-    SampleType sample;
-    //first sample
+    ExecuteInternal( "imgstats" );
+    otbAppLogINFO("image statistics file : " << GetInternalApplication("imgstats")->GetParameterString("out"));
+  }
 
-    itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer randGen=itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance();
 
-    //randGen->Initialize();
+  void KMeansClassif()
+  {
+    ExecuteInternal( "classif" );
+  }
 
-    if (maskFlag)
+  void CreateOutMeansFile(FloatVectorImageType *image,
+                          const std::string &modelFileName,
+                          unsigned int nbClasses)
+  {
+    if (IsParameterEnabled("outmeans"))
+    {
+      unsigned int nbBands = image->GetNumberOfComponentsPerPixel();
+      unsigned int nbElements = nbClasses * nbBands;
+      // get the line in model file that contains the centroids positions
+      std::ifstream infile(modelFileName);
+      if(!infile)
       {
-      while (!it.IsAtEnd() && !m_MaskIt.IsAtEnd() && (m_MaskIt.Get() <= 0))
-        {
-        ++it;
-        ++m_MaskIt;
-        }
-
-      // If the mask is empty after the subsampling
-      if (m_MaskIt.IsAtEnd())
-        {
-        GetLogger()->Error("The mask image is empty after subsampling. Please increase the training set size.");
-        return;
-        }
+        itkExceptionMacro(<< "File : " << modelFileName << " couldn't be opened");
       }
 
-    min = it.Get();
-    max = it.Get();
-    sample = it.Get();
+      // get the end line with the centroids
+      std::string line, centroidLine;
+      while(std::getline(infile,line))
+      {
+        if (!line.empty())
+          centroidLine = line;
+      }
 
-    sampleList->PushBack(sample);
+      std::vector<std::string> centroidElm;
+      boost::split(centroidElm,centroidLine,boost::is_any_of(" "));
 
-    ++it;
+      // remove the first elements, not the centroids positions
+      int nbWord = centroidElm.size();
+      int beginCentroid = nbWord-nbElements;
+      centroidElm.erase(centroidElm.begin(), centroidElm.begin()+beginCentroid);
 
-    if (maskFlag)
-      {
-      ++m_MaskIt;
-      }
+      // write in the output file
+      std::ofstream outfile;
+      outfile.open(GetParameterString("outmeans"));
 
-    totalSamples = 1;
-    bool selectSample;
-    while (!it.IsAtEnd())
+      for (unsigned int i = 0; i < nbClasses; i++)
       {
-      if (maskFlag)
+        for (unsigned int j = 0; j < nbBands; j++)
         {
-        selectSample = (m_MaskIt.Get() > 0);
-        ++m_MaskIt;
+          outfile << std::setw(8) << centroidElm[i * nbBands + j] << " ";
         }
-      else selectSample = true;
+        outfile << std::endl;
+      }
+    }
+  }
 
-      if (selectSample)
-        {
-        totalSamples++;
+  class KMeansFileNamesHandler
+    {
+    public :
+      KMeansFileNamesHandler(const std::string &outPath)
+      {
+        tmpVectorFile = outPath + "_imgEnvelope.shp";
+        polyStatOutput = outPath + "_polyStats.xml";
+        sampleOutput = outPath + "_sampleSelect.shp";
+        modelFile = outPath + "_model.txt";
+        imgStatOutput = outPath + "_imgstats.xml";
+      }
 
-        sample = it.Get();
+      void clear()
+      {
+        RemoveFile(tmpVectorFile);
+        RemoveFile(polyStatOutput);
+        RemoveFile(sampleOutput);
+        RemoveFile(modelFile);
+        RemoveFile(imgStatOutput);
+      }
 
-        sampleList->PushBack(sample);
+      std::string tmpVectorFile;
+      std::string polyStatOutput;
+      std::string sampleOutput;
+      std::string modelFile;
+      std::string imgStatOutput;
 
-        for (unsigned int i = 0; i < nbComp; ++i)
+    private:
+      bool RemoveFile(const std::string &filePath)
+      {
+        bool res = true;
+        if( itksys::SystemTools::FileExists( filePath.c_str() ) )
           {
-          if (min[i] > sample[i])
+          size_t posExt = filePath.rfind( '.' );
+          if( posExt != std::string::npos && filePath.compare( posExt, std::string::npos, ".shp" ) == 0 )
             {
-            min[i] = sample[i];
+            std::string shxPath = filePath.substr( 0, posExt ) + std::string( ".shx" );
+            std::string dbfPath = filePath.substr( 0, posExt ) + std::string( ".dbf" );
+            std::string prjPath = filePath.substr( 0, posExt ) + std::string( ".prj" );
+            RemoveFile( shxPath );
+            RemoveFile( dbfPath );
+            RemoveFile( prjPath );
             }
-          if (max[i] < sample[i])
+          res = itksys::SystemTools::RemoveFile( filePath.c_str() );
+          if( !res )
             {
-            max[i] = sample[i];
+            //otbAppLogINFO( <<"Unable to remove file  "<<filePath );
             }
           }
-        }
-      ++it;
+        return res;
       }
 
-    // Next, initialize centroids by random sampling in the generated
-    // list of samples
+    };
 
-    for (unsigned int classIndex = 0; classIndex < nbClasses; ++classIndex)
-      {
-      SampleType newCentroid = sampleList->GetMeasurementVector(randGen->GetIntegerVariate(sampleList->Size()-1));
+};
 
-      for (unsigned int compIndex = 0; compIndex < sampleSize; ++compIndex)
-        {
-        initialMeans[compIndex + classIndex * sampleSize] = newCentroid[compIndex];
-        }
-      }
-    otbAppLogINFO(<< totalSamples << " samples will be used as estimator input." << std::endl);
 
-    /*******************************************/
-    /*           Learning                      */
-    /*******************************************/
+class KMeansClassification: public KMeansApplicationBase
+{
+public:
+  /** Standard class typedefs. */
+  typedef KMeansClassification Self;
+  typedef KMeansApplicationBase Superclass;
+  typedef itk::SmartPointer<Self> Pointer;
+  typedef itk::SmartPointer<const Self> ConstPointer;
 
-    otbAppLogINFO("-- LEARNING --" << std::endl);
-    otbAppLogINFO("Initial centroids are: " << std::endl);
+  /** Standard macro */
+  itkNewMacro(Self);
 
-    message.str("");
-    message << std::endl;
-    for (unsigned int i = 0; i < nbClasses; i++)
-      {
-      message << "Class " << i << ": ";
-      for (unsigned int j = 0; j < sampleSize; j++)
-        {
-        message << std::setw(8) << initialMeans[i * sampleSize + j] << "   ";
-        }
-      message << std::endl;
-      }
-    message << std::endl;
-    GetLogger()->Info(message.str());
-    message.str("");
-    otbAppLogINFO("Starting optimization." << std::endl);
-    EstimatorType::Pointer estimator = EstimatorType::New();
+  itkTypeMacro(Self, Superclass);
 
-    TreeGeneratorType::Pointer treeGenerator = TreeGeneratorType::New();
-    treeGenerator->SetSample(sampleList);
+private:
+  void DoInit() ITK_OVERRIDE
+  {
+    SetName("KMeansClassification");
+    SetDescription("Unsupervised KMeans image classification");
 
-    treeGenerator->SetBucketSize(10000);
-    treeGenerator->Update();
+    SetDocName("Unsupervised KMeans image classification");
+    SetDocLongDescription("Performs unsupervised KMeans image classification."
+      "KMeansClassification is a composite application, "
+      "using an existing training and classification application."
+      "The SharkKMeans model is used.\n"
+      "The steps of this composite application :\n"
+        "1) ImageEnveloppe : create a shapefile (1 polygon),\n"
+        "2) PolygonClassStatistics : compute the statistics,\n"
+        "3) SampleSelection : select the samples by constant strategy in the shapefile "
+            "(1000000 samples max),\n"
+        "4) SamplesExtraction : extract the samples descriptors (update of SampleSelection output file),\n"
+        "5) ComputeImagesStatistics : compute images second order statistics,\n"
+        "6) TrainVectorClassifier : train the SharkKMeans model,\n"
+        "7) ImageClassifier : performs the classification of the input image "
+            "according to a model file.\n\n"
+        "It's possible to choice random/periodic modes of the SampleSelection application.\n"
+        "If you want keep the temporary files (sample selected, model file, ...), "
+        "initialize cleanup parameter.\n"
+        "For more information on shark KMeans algorithm [1].");
 
-    estimator->SetParameters(initialMeans);
-    estimator->SetKdTree(treeGenerator->GetOutput());
-    int maxIt = GetParameterInt("maxit");
-    estimator->SetMaximumIteration(maxIt);
-    estimator->SetCentroidPositionChangesThreshold(GetParameterFloat("ct"));
-    estimator->StartOptimization();
+    SetDocLimitations("None");
+    SetDocAuthors("OTB-Team");
+    SetDocSeeAlso("ImageEnveloppe PolygonClassStatistics SampleSelection SamplesExtraction "
+      "PolygonClassStatistics TrainVectorClassifier ImageClassifier\n"
+      "[1] http://image.diku.dk/shark/sphinx_pages/build/html/rest_sources/tutorials/algorithms/kmeans.html");
 
-    EstimatorType::ParametersType estimatedMeans = estimator->GetParameters();
+    AddDocTag(Tags::Learning);
+    AddDocTag(Tags::Segmentation);
 
-    otbAppLogINFO("Optimization completed." );
-    if (estimator->GetCurrentIteration() == maxIt)
-      {
-      otbAppLogWARNING("The estimator reached the maximum iteration number." << std::endl);
-      }
-    message.str("");
-    message << "Estimated centroids are: " << std::endl;
-    message << std::endl;
-    for (unsigned int i = 0; i < nbClasses; i++)
-      {
-      message << "Class " << i << ": ";
-      for (unsigned int j = 0; j < sampleSize; j++)
-        {
-        message << std::setw(8) << estimatedMeans[i * sampleSize + j] << "   ";
-        }
-      message << std::endl;
-      }
+    // Perform initialization
+    ClearApplications();
 
-    message << std::endl;
-    message << "Learning completed." << std::endl;
-    message << std::endl;
-    GetLogger()->Info(message.str());
+    // initialisation parameters and synchronizes parameters
+    Superclass::InitKMParams();
 
-    /*******************************************/
-    /*           Classification                */
-    /*******************************************/
-    otbAppLogINFO("-- CLASSIFICATION --" << std::endl);
+    AddRANDParameter();
 
-    // Finally, update the KMeans filter
-    KMeansFunctorType functor;
+    // Doc example parameter settings
+    SetDocExampleParameterValue("in", "QB_1_ortho.tif");
+    SetDocExampleParameterValue("ts", "1000");
+    SetDocExampleParameterValue("nc", "5");
+    SetDocExampleParameterValue("maxit", "1000");
+    SetDocExampleParameterValue("out", "ClassificationFilterOutput.tif uint8");
 
-    for (unsigned int classIndex = 0; classIndex < nbClasses; ++classIndex)
-      {
-      SampleType centroid(sampleSize);
+    SetOfficialDocLink();
+  }
 
-      for (unsigned int compIndex = 0; compIndex < sampleSize; ++compIndex)
-        {
-        centroid[compIndex] = estimatedMeans[compIndex + classIndex * sampleSize];
-        }
-      functor.AddCentroid(classIndex, centroid);
-      }
+  void DoUpdateParameters() ITK_OVERRIDE
+  {
+  }
 
-    m_KMeansFilter = KMeansFilterType::New();
-    m_KMeansFilter->SetFunctor(functor);
-    m_KMeansFilter->SetInput(m_InImage);
+  void DoExecute() ITK_OVERRIDE
+  {
+    if (IsParameterEnabled("vm") && HasValue("vm")) Superclass::ConnectKMClassificationMask();
 
-    // optional saving option -> lut
+    KMeansFileNamesHandler fileNames(GetParameterString("out"));
 
-    if (IsParameterEnabled("outmeans"))
-      {
-      std::ofstream file;
-      file.open(GetParameterString("outmeans").c_str());
-      for (unsigned int i = 0; i < nbClasses; i++)
-        {
+    const std::string fieldName = "field";
 
-        for (unsigned int j = 0; j < sampleSize; j++)
-          {
-          file << std::setw(8) << estimatedMeans[i * sampleSize + j] << " ";
-          }
-        file << std::endl;
-        }
+    // Create an image envelope
+    Superclass::ComputeImageEnvelope(fileNames.tmpVectorFile);
+    // Add a new field at the ImageEnvelope output file
+    Superclass::ComputeAddField(fileNames.tmpVectorFile, fieldName);
 
-      file.close();
-      }
+    // Compute PolygonStatistics app
+    UpdateKMPolygonClassStatisticsParameters(fileNames.tmpVectorFile);
+    Superclass::ComputePolygonStatistics(fileNames.polyStatOutput, fieldName);
+
+    // Compute number of sample max for KMeans
+    const int theoricNBSamplesForKMeans = GetParameterInt("ts");
+    const int upperThresholdNBSamplesForKMeans = 1000 * 1000;
+    const int actualNBSamplesForKMeans = std::min(theoricNBSamplesForKMeans,
+                                                  upperThresholdNBSamplesForKMeans);
+    otbAppLogINFO(<< actualNBSamplesForKMeans << " is the maximum sample size that will be used." \
+                  << std::endl);
+
+    // Compute SampleSelection and SampleExtraction app
+    Superclass::SelectAndExtractSamples(fileNames.polyStatOutput, fieldName,
+                                        fileNames.sampleOutput,
+                                        actualNBSamplesForKMeans);
+
+    // Compute Images second order statistics
+    Superclass::ComputeImageStatistics(GetParameterString("in"), fileNames.imgStatOutput);
+
+    // Compute a train model with TrainVectorClassifier app
+    Superclass::TrainKMModel(GetParameterImage("in"), fileNames.sampleOutput,
+                             fileNames.modelFile);
+
+    // Compute a classification of the input image according to a model file
+    Superclass::KMeansClassif();
 
-    SetParameterOutputImage("out", m_KMeansFilter->GetOutput());
+    // Create the output text file containing centroids positions
+    Superclass::CreateOutMeansFile(GetParameterImage("in"), fileNames.modelFile, GetParameterInt("nc"));
 
+    // Remove all tempory files
+    if( IsParameterEnabled( "cleanup" ) )
+      {
+      otbAppLogINFO( <<"Final clean-up ..." );
+      fileNames.clear();
+      }
   }
 
-  // KMeans filter
-  KMeansFilterType::Pointer           m_KMeansFilter;
-  FloatVectorImageType::Pointer       m_InImage;
+  void UpdateKMPolygonClassStatisticsParameters(const std::string &vectorFileName)
+  {
+    GetInternalApplication( "polystats" )->SetParameterString( "vec", vectorFileName, false );
+    UpdateInternalParameters( "polystats" );
+  }
 
 };
 
-
 }
 }
 
 OTB_APPLICATION_EXPORT(otb::Wrapper::KMeansClassification)
 
-
diff --git a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx
index 6eb8ee5..889e909 100644
--- a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx
+++ b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx
@@ -110,7 +110,7 @@ private:
       "  * strategy = smallest class\n\n"
       "    - if mim = proportional, then the smallest class size (computed globally) is used for the strategy constant+proportional.\n\n"
       "    - if mim = equal       , then the smallest class size (computed globally) is used for the strategy constant+equal.\n\n"
-      "    - if mim = custom      , then the smallest class is computed and used for each image separately.\n\n"
+      "    - if mim = custom      , then the smallest class is computed and used for each image separately."
       );
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
diff --git a/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx b/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx
index 971c79a..eb58a7e 100644
--- a/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx
+++ b/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx
@@ -113,12 +113,22 @@ private:
       
       otb::ogr::Feature feature = layer.ogr().GetNextFeature();
       ClearChoices("feat");
+      std::vector<std::string> choiceKeys;
+
       for(int iField=0; iField<feature.ogr().GetFieldCount(); iField++)
         {
         std::string key, item = feature.ogr().GetFieldDefnRef(iField)->GetNameRef();
         key = item;
-        key.erase(std::remove(key.begin(), key.end(), ' '), key.end());
+
+        // Transform chain : lowercase and alphanumerical
+        key.erase(std::remove_if(key.begin(), key.end(), std::not1(std::ptr_fun(::isalnum))), key.end());
         std::transform(key.begin(), key.end(), key.begin(), tolower);
+
+        // Key must be unique
+        choiceKeys = GetChoiceKeys("feat");
+        while(choiceKeys.end() != std::find(choiceKeys.begin(), choiceKeys.end(), key) )
+          key.append("0");
+
         key="feat."+key;
         AddChoice(key,item);
         }
diff --git a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx
index c1600eb..ff4f4b0 100644
--- a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx
+++ b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx
@@ -85,7 +85,7 @@ private:
       "different for each type of geometry :\n"
       "  - polygon: select pixels whose center is inside the polygon\n"
       "  - lines  : select pixels intersecting the line\n"
-      "  - points : select closest pixel to the point\n");
+      "  - points : select closest pixel to the point");
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
     SetDocSeeAlso(" ");
diff --git a/Modules/Applications/AppClassification/app/otbSOMClassification.cxx b/Modules/Applications/AppClassification/app/otbSOMClassification.cxx
index 18e12db..86572e9 100644
--- a/Modules/Applications/AppClassification/app/otbSOMClassification.cxx
+++ b/Modules/Applications/AppClassification/app/otbSOMClassification.cxx
@@ -254,6 +254,10 @@ private:
     itk::RandomPermutation randPerm(numberOfStreamDivisions);
     unsigned int index = 0;
 
+    // reset seed and step once (itk::RandomPermutation may have used it)
+    randomGen->SetSeed(GetParameterInt("rand"));
+    randomGen->GetVariateWithClosedRange();
+
     // TODO : maybe change the approach: at the moment, the sampling process is able to pick a sample twice or more
     while (totalSamples < nbsamples)
     {
diff --git a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx
index 0437978..b41f204 100644
--- a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx
+++ b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx
@@ -120,7 +120,7 @@ private:
       "polygons, lines, points. \nThe behavior of this application is different for each type of geometry : \n\n"
       "  - polygon: select points whose center is inside the polygon\n"
       "  - lines  : select points intersecting the line\n"
-      "  - points : select closest point to the provided point\n");
+      "  - points : select closest point to the provided point");
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
     SetDocSeeAlso(" ");
diff --git a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx
index 21d3b58..1d1d387 100644
--- a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx
+++ b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx
@@ -110,9 +110,12 @@ protected:
     contingencyTableCalculator->Compute(performanceLabeledListSample->Begin(),
                                         performanceLabeledListSample->End(),predictedListSample->Begin(), predictedListSample->End());
 
-    otbAppLogINFO( "Training performances:" );
-
-    otbAppLogINFO(<<"Contingency table: reference labels (rows) vs. produced labels (cols)\n"<<contingencyTableCalculator->BuildContingencyTable());
+    if(IsParameterEnabled("v"))
+    {
+      otbAppLogINFO( "Training performances:" );
+      otbAppLogINFO(<<"Contingency table: reference labels (rows) vs. produced labels (cols)\n"
+        <<contingencyTableCalculator->BuildContingencyTable());
+    }
 
     return contingencyTableCalculator->BuildContingencyTable();
   }
diff --git a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx
index 61d3a69..b8ecd88 100644
--- a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx
+++ b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx
@@ -62,7 +62,7 @@ public:
   itkTypeMacro(Self, Application)
 
   /** Filters typedef */
-  typedef double                                        ValueType;
+  typedef float                                         ValueType;
   typedef unsigned int                                  LabelType;
   typedef itk::FixedArray<LabelType,1>                  LabelSampleType;
   typedef itk::Statistics::ListSample<LabelSampleType>  LabelListSampleType;
@@ -89,39 +89,52 @@ private:
   void DoInit() ITK_OVERRIDE
   {
     SetName("VectorClassifier");
-    SetDescription("Performs a classification of the input vector data according to a model file."
-      "Features of the vector data output will contain the class labels decided by the classifier (maximal class label = 65535).");
+    SetDescription("Performs a classification of the input vector data according to a model file.");
 
     SetDocName("Vector Classification");
     SetDocAuthors("OTB-Team");
-    SetDocLongDescription("This application performs a vector data classification based on a model file produced by the TrainVectorClassifier application.");
+    SetDocLongDescription("This application performs a vector data classification "
+      "based on a model file produced by the TrainVectorClassifier application."
+      "Features of the vector data output will contain the class labels decided by the classifier "
+      "(maximal class label = 65535). \n"
+      "There are two modes: \n"
+        "1) Update mode: add of the 'cfield' field containing the predicted class in the input file. \n"
+        "2) Write mode: copies the existing fields of the input file in the output file "
+           " and add the 'cfield' field containing the predicted class. \n"
+      "If you have declared the output file, the write mode applies. "
+      "Otherwise, the input file update mode will be applied.");
+
     SetDocLimitations("Shapefiles are supported. But the SQLite format is only supported in update mode.");
     SetDocSeeAlso("TrainVectorClassifier");
     AddDocTag(Tags::Learning);
 
     AddParameter(ParameterType_InputVectorData, "in", "Name of the input vector data");
-    SetParameterDescription("in","The input vector data to classify.");
+    SetParameterDescription("in","The input vector data file to classify.");
 
     AddParameter(ParameterType_InputFilename, "instat", "Statistics file");
     SetParameterDescription("instat", "A XML file containing mean and standard deviation to center"
-      "and reduce samples before classification (produced by ComputeImagesStatistics application).");
+      "and reduce samples before classification, produced by ComputeImagesStatistics application.");
     MandatoryOff("instat");
 
     AddParameter(ParameterType_InputFilename, "model", "Model file");
-    SetParameterDescription("model", "A model file (produced by TrainVectorClassifier application,"
-      "maximal class label = 65535).");
+    SetParameterDescription("model", "Model file produced by TrainVectorClassifier application.");
 
-    AddParameter(ParameterType_String,"cfield","Field containing the predicted class");
+    AddParameter(ParameterType_String,"cfield","Field class");
     SetParameterDescription("cfield","Field containing the predicted class."
-      "Only geometries with this field available will be taken into account.");
+      "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);
 
-    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", "Field names to be calculated.");
+    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");
-    SetParameterDescription( "confmap", "Confidence map of the produced classification. The confidence index depends on the model : \n"
-      "  - LibSVM : difference between the two highest probabilities (needs a model with probability estimates, so that classes probabilities can be computed for each sample)\n"
+    SetParameterDescription( "confmap", "Confidence map of the produced classification. "
+      "The confidence index depends on the model : \n"
+      "  - LibSVM : difference between the two highest probabilities "
+           "(needs a model with probability estimates, so that classes probabilities can be computed for each sample)\n"
       "  - OpenCV\n"
       "    * Boost : sum of votes\n"
       "    * DecisionTree : (not supported)\n"
@@ -129,8 +142,9 @@ private:
       "    * KNearestNeighbors : number of neighbors with the same label\n"
       "    * NeuralNetwork : difference between the two highest responses\n"
       "    * NormalBayes : (not supported)\n"
-      "    * 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");
+      "    * 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");
@@ -142,7 +156,7 @@ private:
     SetDocExampleParameterValue("in", "vectorData.shp");
     SetDocExampleParameterValue("instat", "meanVar.xml");
     SetDocExampleParameterValue("model", "svmModel.svm");
-    SetDocExampleParameterValue("out", "svmModel.svm");
+    SetDocExampleParameterValue("out", "vectorDataLabeledVector.shp");
     SetDocExampleParameterValue("feat", "perimeter  area  width");
     SetDocExampleParameterValue("cfield", "predicted");
 
@@ -196,7 +210,7 @@ private:
 
     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)
@@ -205,7 +219,11 @@ private:
       mv.SetSize(nbFeatures);
       for(int idx=0; idx < nbFeatures; ++idx)
         {
-        mv[idx] = (*it)[GetSelectedItems("feat")[idx]].GetValue<double>();
+        // Beware that itemIndex differs from ogr layer field index
+        unsigned int itemIndex = GetSelectedItems("feat")[idx];
+        std::string fieldName = GetChoiceNames( "feat" )[itemIndex];
+        
+        mv[idx] = static_cast<ValueType>((*it)[fieldName].GetValue<double>());
         }
       input->PushBack(mv);
       }
diff --git a/Modules/Applications/AppClassification/include/otbTrainBoost.txx b/Modules/Applications/AppClassification/include/otbTrainBoost.txx
index 44093ec..46cbbbd 100644
--- a/Modules/Applications/AppClassification/include/otbTrainBoost.txx
+++ b/Modules/Applications/AppClassification/include/otbTrainBoost.txx
@@ -39,11 +39,28 @@ namespace Wrapper
     //BoostType
     AddParameter(ParameterType_Choice, "classifier.boost.t", "Boost Type");
     AddChoice("classifier.boost.t.discrete", "Discrete AdaBoost");
-    AddChoice("classifier.boost.t.real", "Real AdaBoost (technique using confidence-rated predictions "
-                                                "and working well with categorical data)");
-    AddChoice("classifier.boost.t.logit", "LogitBoost (technique producing good regression fits)");
-    AddChoice("classifier.boost.t.gentle", "Gentle AdaBoost (technique setting less weight on outlier data points "
-                                               "and, for that reason, being often good with regression data)");
+    SetParameterDescription("classifier.boost.t.discrete",
+      "This procedure trains the classifiers on weighted versions of the training "
+      "sample, giving higher weight to cases that are currently misclassified. "
+      "This is done for a sequence of weighter samples, and then the final "
+      "classifier is defined as a linear combination of the classifier from "
+      "each stage.");
+    AddChoice("classifier.boost.t.real",
+      "Real AdaBoost (technique using confidence-rated predictions "
+      "and working well with categorical data)");
+    SetParameterDescription("classifier.boost.t.real",
+      "Adaptation of the Discrete Adaboost algorithm with Real value");
+    AddChoice("classifier.boost.t.logit",
+      "LogitBoost (technique producing good regression fits)");
+    SetParameterDescription("classifier.boost.t.logit",
+      "This procedure is an adaptive Newton algorithm for fitting an additive "
+      "logistic regression model. Beware it can produce numeric instability.");
+    AddChoice("classifier.boost.t.gentle",
+      "Gentle AdaBoost (technique setting less weight on outlier data points "
+      "and, for that reason, being often good with regression data)");
+    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);
     SetParameterDescription("classifier.boost.t", "Type of Boosting algorithm.");
     //Do not expose SplitCriteria
@@ -54,9 +71,11 @@ namespace Wrapper
     //WeightTrimRate
     AddParameter(ParameterType_Float, "classifier.boost.r", "Weight Trim Rate");
     SetParameterFloat("classifier.boost.r",0.95, false);
-    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 the next iteration of training. "
-                            "Set this parameter to 0 to turn off this functionality.");
+    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"
+      " the next iteration of training. Set this parameter to 0 to turn off this "
+      "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);
diff --git a/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx b/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx
index 3517791..9803a91 100644
--- a/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx
+++ b/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx
@@ -35,8 +35,8 @@ LearningApplicationBase<TInputValue,TOutputValue>
 {
   AddChoice("classifier.dt", "Decision Tree classifier");
   SetParameterDescription("classifier.dt",
-                          "This group of parameters allows setting Decision Tree classifier parameters. "
-                          "See complete documentation here \\url{http://docs.opencv.org/modules/ml/doc/decision_trees.html}.");
+    "This group of parameters allows setting Decision Tree classifier parameters. "
+    "See complete documentation here \\url{http://docs.opencv.org/modules/ml/doc/decision_trees.html}.");
   //MaxDepth
   AddParameter(ParameterType_Int, "classifier.dt.max", "Maximum depth of the tree");
 #ifdef OTB_OPENCV_3
@@ -44,23 +44,25 @@ LearningApplicationBase<TInputValue,TOutputValue>
 #else
   SetParameterInt("classifier.dt.max",65535, false);
 #endif
-  SetParameterDescription(
-      "classifier.dt.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 "
-      "if the tree is pruned.");
+  SetParameterDescription("classifier.dt.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 if the tree is pruned.");
 
   //MinSampleCount
   AddParameter(ParameterType_Int, "classifier.dt.min", "Minimum number of samples in each node");
   SetParameterInt("classifier.dt.min",10, false);
-  SetParameterDescription("classifier.dt.min", "If the number of samples in a node is smaller than this parameter, "
-                          "then this node will not be split.");
+  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);
-  SetParameterDescription("classifier.dt.min", "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.");
+  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 "
+    "regression accuracy parameter, then the node will not be split further.");
 
   //UseSurrogates : don't need to be exposed !
   //AddParameter(ParameterType_Empty, "classifier.dt.sur", "Surrogate splits will be built");
@@ -68,11 +70,12 @@ LearningApplicationBase<TInputValue,TOutputValue>
 
   //MaxCategories
   AddParameter(ParameterType_Int, "classifier.dt.cat",
-               "Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split");
+    "Cluster possible values of a categorical variable into K <= cat clusters to find a "
+    "suboptimal split");
   SetParameterInt("classifier.dt.cat",10, false);
-  SetParameterDescription(
-      "classifier.dt.cat",
-      "Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split.");
+  SetParameterDescription("classifier.dt.cat",
+      "Cluster possible values of a categorical variable into K <= cat clusters to find a "
+      "suboptimal split.");
 
   //CVFolds
   AddParameter(ParameterType_Int, "classifier.dt.f", "K-fold cross-validations");
@@ -82,18 +85,20 @@ LearningApplicationBase<TInputValue,TOutputValue>
 #else
   SetParameterInt("classifier.dt.f",10, false);
 #endif
-  SetParameterDescription(
-      "classifier.dt.f", "If cv_folds > 1, then it prunes a tree with K-fold cross-validation where K is equal to cv_folds.");
+  SetParameterDescription("classifier.dt.f",
+    "If cv_folds > 1, then it prunes a tree with K-fold cross-validation where K "
+    "is equal to cv_folds.");
 
   //Use1seRule
   AddParameter(ParameterType_Empty, "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.");
+  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");
-  SetParameterDescription("classifier.dt.t", "If true, then pruned branches are physically removed from the tree.");
+  SetParameterDescription("classifier.dt.t",
+    "If true, then pruned branches are physically removed from the tree.");
 
   //Priors are not exposed.
 
diff --git a/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx b/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx
index 93605b2..325d3b9 100644
--- a/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx
+++ b/Modules/Applications/AppClassification/include/otbTrainImagesBase.txx
@@ -101,7 +101,10 @@ void TrainImagesBase::ShareSamplingParameters()
   //ShareParameter("sample.mim","rates.mim");
   ShareParameter( "ram", "polystat.ram" );
   ShareParameter( "elev", "polystat.elev" );
-  ShareParameter( "sample.vfn", "polystat.field" );
+  ShareParameter( "sample.vfn", "polystat.field",
+    "Field containing the class integer label for supervision" ,
+    "Field containing the class id for supervision. "
+      "The values in this field shall be cast into integers.");
 }
 
 void TrainImagesBase::ConnectSamplingParameters()
diff --git a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx
index 0dd2d8f..18b9f4d 100644
--- a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx
+++ b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx
@@ -37,9 +37,23 @@ namespace Wrapper
     SetParameterDescription("classifier.libsvm", "This group of parameters allows setting SVM classifier parameters.");
     AddParameter(ParameterType_Choice, "classifier.libsvm.k", "SVM Kernel Type");
     AddChoice("classifier.libsvm.k.linear", "Linear");
+    SetParameterDescription("classifier.libsvm.k.linear", 
+      "Linear Kernel, no mapping is done, this is the fastest option.");
+
     AddChoice("classifier.libsvm.k.rbf", "Gaussian radial basis function");
+    SetParameterDescription("classifier.libsvm.k.rbf", 
+      "This kernel is a good choice in most of the case. It is "
+      "an exponential function of the euclidian distance between "
+      "the vectors.");
+
     AddChoice("classifier.libsvm.k.poly", "Polynomial");
+    SetParameterDescription("classifier.libsvm.k.poly", 
+      "Polynomial Kernel, the mapping is a polynomial function.");
+
     AddChoice("classifier.libsvm.k.sigmoid", "Sigmoid");
+    SetParameterDescription("classifier.libsvm.k.sigmoid", 
+      "The kernel is a hyperbolic tangente function of the vectors.");
+
     SetParameterString("classifier.libsvm.k", "linear", false);
     SetParameterDescription("classifier.libsvm.k", "SVM Kernel Type.");
     AddParameter(ParameterType_Choice, "classifier.libsvm.m", "SVM Model Type");
@@ -47,21 +61,50 @@ namespace Wrapper
     if (this->m_RegressionFlag)
       {
       AddChoice("classifier.libsvm.m.epssvr", "Epsilon Support Vector Regression");
+      SetParameterDescription("classifier.libsvm.m.epssvr",
+       "The distance between feature vectors from the training set and the "
+       "fitting hyper-plane must be less than Epsilon. For outliers the penalty "
+       "multiplier C is used ");
+
       AddChoice("classifier.libsvm.m.nusvr", "Nu Support Vector Regression");
       SetParameterString("classifier.libsvm.m", "epssvr", false);
+      SetParameterDescription("classifier.libsvm.m.nusvr",
+       "Same as the epsilon regression except that this time the bounded "
+       "parameter nu is used instead of epsilon");
       }
     else
       {
       AddChoice("classifier.libsvm.m.csvc", "C support vector classification");
+      SetParameterDescription("classifier.libsvm.m.csvc", 
+      "This formulation allows imperfect separation of classes. The penalty "
+      "is set through the cost parameter C.");
+
       AddChoice("classifier.libsvm.m.nusvc", "Nu support vector classification");
+      SetParameterDescription("classifier.libsvm.m.nusvc", 
+        "This formulation allows imperfect separation of classes. The penalty "
+        "is set through the cost parameter Nu. As compared to C, Nu is harder "
+        "to optimize, and may not be as fast.");
+
       AddChoice("classifier.libsvm.m.oneclass", "Distribution estimation (One Class SVM)");
+      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);
       }
+
     AddParameter(ParameterType_Float, "classifier.libsvm.c", "Cost parameter C");
     SetParameterFloat("classifier.libsvm.c",1.0, false);
-    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.");
+    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);
+    SetParameterDescription("classifier.libsvm.nu",
+        "Cost parameter Nu, in the range 0..1, the larger the value, "
+        "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");
     SetParameterDescription("classifier.libsvm.opt", "SVM parameters optimization flag.");
@@ -73,8 +116,10 @@ namespace Wrapper
       {
       AddParameter(ParameterType_Float, "classifier.libsvm.eps", "Epsilon");
       SetParameterFloat("classifier.libsvm.eps",1e-3, false);
-      AddParameter(ParameterType_Float, "classifier.libsvm.nu", "Nu");
-      SetParameterFloat("classifier.libsvm.nu",0.5, false);
+      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"
+        "the penalty mutliplier is set by C.");
       }
   }
 
@@ -100,6 +145,7 @@ namespace Wrapper
       {
       libSVMClassifier->SetDoProbabilityEstimates(true);
       }
+    libSVMClassifier->SetNu(GetParameterFloat("classifier.libsvm.nu"));
     libSVMClassifier->SetC(GetParameterFloat("classifier.libsvm.c"));
 
     switch (GetParameterInt("classifier.libsvm.k"))
@@ -135,7 +181,6 @@ namespace Wrapper
           break;
         }
       libSVMClassifier->SetEpsilon(GetParameterFloat("classifier.libsvm.eps"));
-      libSVMClassifier->SetNu(GetParameterFloat("classifier.libsvm.nu"));
       }
     else
       {
@@ -155,6 +200,7 @@ namespace Wrapper
           break;
         }
       }
+      
 
     libSVMClassifier->Train();
     libSVMClassifier->Save(modelPath);
diff --git a/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx b/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx
index fb8287c..4081034 100644
--- a/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx
+++ b/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx
@@ -36,95 +36,125 @@ LearningApplicationBase<TInputValue,TOutputValue>
 {
   AddChoice("classifier.ann", "Artificial Neural Network classifier");
   SetParameterDescription("classifier.ann",
-                          "This group of parameters allows setting Artificial Neural Network classifier parameters. "
-                          "See complete documentation here \\url{http://docs.opencv.org/modules/ml/doc/neural_networks.html}.");
+    "This group of parameters allows setting Artificial Neural Network "
+    "classifier parameters. See complete documentation here "
+    "\\url{http://docs.opencv.org/modules/ml/doc/neural_networks.html}.");
 
   //TrainMethod
   AddParameter(ParameterType_Choice, "classifier.ann.t", "Train Method Type");
-  AddChoice("classifier.ann.t.reg", "RPROP algorithm");
   AddChoice("classifier.ann.t.back", "Back-propagation algorithm");
+  SetParameterDescription("classifier.ann.t.back",
+    "Method to compute the gradient of the loss function and adjust weights "
+    "in the network to optimize the result.");
+  AddChoice("classifier.ann.t.reg", "Resilient Back-propagation algorithm");
+  SetParameterDescription("classifier.ann.t.reg",
+    "Almost the same as the Back-prop algorithm except that it does not "
+    "take into account the magnitude of the partial derivative (coordinate "
+    "of the gradient) but only its sign.");
+
   SetParameterString("classifier.ann.t", "reg", false);
-  SetParameterDescription("classifier.ann.t", "Type of training method for the multilayer perceptron (MLP) neural network.");
+  SetParameterDescription("classifier.ann.t", 
+    "Type of training method for the multilayer perceptron (MLP) neural network.");
 
   //LayerSizes
   //There is no ParameterType_IntList, so i use a ParameterType_StringList and convert it.
   /*std::vector<std::string> layerSizes;
    layerSizes.push_back("100");
    layerSizes.push_back("100"); */
-  AddParameter(ParameterType_StringList, "classifier.ann.sizes", "Number of neurons in each intermediate layer");
+  AddParameter(ParameterType_StringList, "classifier.ann.sizes", 
+    "Number of neurons in each intermediate layer");
   //SetParameterStringList("classifier.ann.sizes", layerSizes);
   SetParameterDescription("classifier.ann.sizes",
-                          "The number of neurons in each intermediate layer (excluding input and output layers).");
+    "The number of neurons in each intermediate layer (excluding input and output layers).");
 
   //ActivateFunction
-  AddParameter(ParameterType_Choice, "classifier.ann.f", "Neuron activation function type");
+  AddParameter(ParameterType_Choice, "classifier.ann.f", 
+    "Neuron activation function type");
   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);
-  SetParameterDescription("classifier.ann.f", "Neuron activation function.");
+  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.");
 
   //Alpha
-  AddParameter(ParameterType_Float, "classifier.ann.a", "Alpha parameter of the activation function");
+  AddParameter(ParameterType_Float, "classifier.ann.a", 
+    "Alpha parameter of the activation function");
   SetParameterFloat("classifier.ann.a",1., false);
   SetParameterDescription("classifier.ann.a",
-                          "Alpha parameter of the activation function (used only with sigmoid and gaussian functions).");
+    "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");
+  AddParameter(ParameterType_Float, "classifier.ann.b", 
+    "Beta parameter of the activation function");
   SetParameterFloat("classifier.ann.b",1., false);
   SetParameterDescription("classifier.ann.b",
-                          "Beta parameter of the activation function (used only with sigmoid and gaussian functions).");
+    "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");
+    "Strength of the weight gradient term in the BACKPROP method");
   SetParameterFloat("classifier.ann.bpdw",0.1, false);
-  SetParameterDescription(
-      "classifier.ann.bpdw",
-      "Strength of the weight gradient term in the BACKPROP method. The recommended value is about 0.1.");
+  SetParameterDescription("classifier.ann.bpdw",
+    "Strength of the weight gradient term in the BACKPROP method. The "
+    "recommended value is about 0.1.");
 
   //BackPropMomentScale
   AddParameter(ParameterType_Float, "classifier.ann.bpms",
-               "Strength of the momentum term (the difference between weights on the 2 previous iterations)");
+    "Strength of the momentum term (the difference between weights on the 2 previous iterations)");
   SetParameterFloat("classifier.ann.bpms",0.1, false);
-  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 fluctuations of the weights. "
-      "It can vary from 0 (the feature is disabled) to 1 and beyond. The value 0.1 or so is good enough.");
+  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 "
+    "fluctuations of the weights. It can vary from 0 (the feature is disabled) "
+    "to 1 and beyond. The value 0.1 or so is good enough.");
 
   //RegPropDW0
   AddParameter(ParameterType_Float, "classifier.ann.rdw",
-               "Initial value Delta_0 of update-values Delta_{ij} in RPROP method");
+    "Initial value Delta_0 of update-values Delta_{ij} in RPROP method");
   SetParameterFloat("classifier.ann.rdw",0.1, false);
-  SetParameterDescription("classifier.ann.rdw", "Initial value Delta_0 of update-values Delta_{ij} in RPROP method (default = 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");
+  AddParameter(ParameterType_Float, "classifier.ann.rdwm",
+    "Update-values lower limit Delta_{min} in RPROP method");
   SetParameterFloat("classifier.ann.rdwm",1e-7, false);
-  SetParameterDescription(
-      "classifier.ann.rdwm",
-      "Update-values lower limit Delta_{min} in RPROP method. It must be positive (default = 1e-7).");
+  SetParameterDescription("classifier.ann.rdwm",
+    "Update-values lower limit Delta_{min} in RPROP method. It must be positive "
+    "(default = 1e-7).");
 
   //TermCriteriaType
   AddParameter(ParameterType_Choice, "classifier.ann.term", "Termination criteria");
   AddChoice("classifier.ann.term.iter", "Maximum number of iterations");
+  SetParameterDescription("classifier.ann.term.iter", 
+    "Set the number of iterations allowed to the network for its "
+    "training. Training will stop regardless of the result when this "
+    "number is reached");
   AddChoice("classifier.ann.term.eps", "Epsilon");
+  SetParameterDescription("classifier.ann.term.eps", 
+    "Training will focus on result and will stop once the precision is"
+    "at most epsilon");
   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);
   SetParameterDescription("classifier.ann.term", "Termination criteria.");
 
   //Epsilon
-  AddParameter(ParameterType_Float, "classifier.ann.eps", "Epsilon value used in the Termination criteria");
+  AddParameter(ParameterType_Float, "classifier.ann.eps",
+    "Epsilon value used in the Termination criteria");
   SetParameterFloat("classifier.ann.eps",0.01, false);
-  SetParameterDescription("classifier.ann.eps", "Epsilon value used in the Termination criteria.");
+  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");
+    "Maximum number of iterations used in the Termination criteria");
   SetParameterInt("classifier.ann.iter",1000, false);
-  SetParameterDescription("classifier.ann.iter", "Maximum number of iterations used in the Termination criteria.");
+  SetParameterDescription("classifier.ann.iter",
+    "Maximum number of iterations used in the Termination criteria.");
 
 }
 
@@ -143,12 +173,12 @@ LearningApplicationBase<TInputValue,TOutputValue>
 
   switch (GetParameterInt("classifier.ann.t"))
     {
-    case 0: // RPROP
-      classifier->SetTrainMethod(CvANN_MLP_TrainParams::RPROP);
-      break;
-    case 1: // BACKPROP
+    case 0: // BACKPROP
       classifier->SetTrainMethod(CvANN_MLP_TrainParams::BACKPROP);
       break;
+    case 1: // RPROP
+      classifier->SetTrainMethod(CvANN_MLP_TrainParams::RPROP);
+      break;
     default: // DEFAULT = RPROP
       classifier->SetTrainMethod(CvANN_MLP_TrainParams::RPROP);
       break;
diff --git a/Modules/Applications/AppClassification/include/otbTrainSVM.txx b/Modules/Applications/AppClassification/include/otbTrainSVM.txx
index 4c4729e..ac9524f 100644
--- a/Modules/Applications/AppClassification/include/otbTrainSVM.txx
+++ b/Modules/Applications/AppClassification/include/otbTrainSVM.txx
@@ -53,6 +53,7 @@ namespace Wrapper
       }
     AddParameter(ParameterType_Choice, "classifier.svm.k", "SVM Kernel Type");
     AddChoice("classifier.svm.k.linear", "Linear");
+
     AddChoice("classifier.svm.k.rbf", "Gaussian radial basis function");
     AddChoice("classifier.svm.k.poly", "Polynomial");
     AddChoice("classifier.svm.k.sigmoid", "Sigmoid");
@@ -60,52 +61,71 @@ namespace Wrapper
     SetParameterDescription("classifier.svm.k", "SVM Kernel Type.");
     AddParameter(ParameterType_Float, "classifier.svm.c", "Cost parameter C");
     SetParameterFloat("classifier.svm.c",1.0, false);
-    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.");
+    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);
-    SetParameterDescription("classifier.svm.nu", "Parameter nu of a SVM optimization problem.");
+    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);
       SetParameterDescription("classifier.svm.p", "Parameter epsilon of a SVM optimization problem (EPS_SVR).");
 
-      AddParameter(ParameterType_Choice, "classifier.svm.term", "Termination criteria");
-      SetParameterDescription("classifier.svm.term","Termination criteria for iterative algorithm");
-      AddChoice("classifier.svm.term.iter", "Stops when maximum iteration is reached.");
-      AddChoice("classifier.svm.term.eps", "Stops when accuracy is lower than epsilon.");
-      AddChoice("classifier.svm.term.all", "Stops when either iteration or epsilon criteria is true");
+      AddParameter(ParameterType_Choice, 
+        "classifier.svm.term", "Termination criteria");
+      SetParameterDescription("classifier.svm.term",
+        "Termination criteria for iterative algorithm");
+      AddChoice("classifier.svm.term.iter", 
+        "Stops when maximum iteration is reached.");
+      AddChoice("classifier.svm.term.eps", 
+        "Stops when accuracy is lower than epsilon.");
+      AddChoice("classifier.svm.term.all", 
+        "Stops when either iteration or epsilon criteria is true");
 
       AddParameter(ParameterType_Float, "classifier.svm.iter", "Maximum iteration");
       SetParameterFloat("classifier.svm.iter",1000, false);
-      SetParameterDescription("classifier.svm.iter", "Maximum number of iterations (corresponds to the termination criteria 'iter').");
+      SetParameterDescription("classifier.svm.iter", 
+        "Maximum number of iterations (corresponds to the termination criteria 'iter').");
 
-      AddParameter(ParameterType_Float, "classifier.svm.eps", "Epsilon accuracy threshold");
+      AddParameter(ParameterType_Float, "classifier.svm.eps", 
+        "Epsilon accuracy threshold");
       SetParameterFloat("classifier.svm.eps",FLT_EPSILON, false);
-      SetParameterDescription("classifier.svm.eps", "Epsilon accuracy (corresponds to the termination criteria 'eps').");
+      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)");
+    AddParameter(ParameterType_Float, "classifier.svm.coef0", 
+      "Parameter coef0 of a kernel function (POLY / SIGMOID)");
     SetParameterFloat("classifier.svm.coef0",0.0, false);
-    SetParameterDescription("classifier.svm.coef0", "Parameter coef0 of a kernel function (POLY / SIGMOID).");
+    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);
-    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)");
+    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);
-    SetParameterDescription("classifier.svm.degree", "Parameter degree of a kernel function (POLY).");
-    AddParameter(ParameterType_Empty, "classifier.svm.opt", "Parameters optimization");
+    SetParameterDescription("classifier.svm.degree", 
+      "Parameter degree of a kernel function (POLY).");
+    AddParameter(ParameterType_Empty, "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 the test set error is minimal. "
-                            "Finally, the SVM training process is computed 10 times with these optimal parameters over subsets corresponding to 1/10th of "
-                            "the training samples using the k-fold cross-validation (with k = 10).\n-If set to False, the SVM classification process will be "
-                            "computed once with the currently set input SVM parameters over the training samples.\n-Thus, even with identical input SVM "
-                            "parameters and a similar random seed, the output SVM models will be different according to the method used (optimized or not) "
-                            "because the samples are not identically processed within OpenCV.");
+    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 "
+      "the test set error is minimal. Finally, the SVM training process is computed "
+      "10 times with these optimal parameters over subsets corresponding to 1/10th of "
+      "the training samples using the k-fold cross-validation (with k = 10).\n-If set "
+      "to False, the SVM classification process will be computed once with the "
+      "currently set input SVM parameters over the training samples.\n-Thus, even "
+      "with identical input SVM parameters and a similar random seed, the output "
+      "SVM models will be different according to the method used (optimized or not) "
+      "because the samples are not identically processed within OpenCV.");
   }
 
   template <class TInputValue, class TOutputValue>
diff --git a/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx b/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx
index 380dfd6..2c3575c 100644
--- a/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx
+++ b/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx
@@ -31,53 +31,70 @@ void TrainVectorBase::DoInit()
 {
   // Common Parameters for all Learning Application
   AddParameter( ParameterType_Group, "io", "Input and output data" );
-  SetParameterDescription( "io", "This group of parameters allows setting input and output data." );
+  SetParameterDescription( "io", 
+    "This group of parameters allows setting input and output data." );
 
   AddParameter( ParameterType_InputVectorDataList, "io.vd", "Input Vector Data" );
   SetParameterDescription( "io.vd",
-                           "Input geometries used for training (note : all geometries from the layer will be used)" );
+    "Input geometries used for training (note : all geometries from the layer will be used)" );
 
   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." );
+  SetParameterDescription( "io.stats", 
+    "XML file containing mean and variance of each feature." );
 
   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 model estimated (.txt format)." );
 
   AddParameter( ParameterType_Int, "layer", "Layer Index" );
-  SetParameterDescription( "layer", "Index of the layer to use in the input vector file." );
+  SetParameterDescription( "layer", 
+    "Index of the layer to use in the input vector file." );
   MandatoryOff( "layer" );
   SetDefaultParameterInt( "layer", 0 );
 
   AddParameter(ParameterType_ListView,  "feat", "Field names for training features.");
-  SetParameterDescription("feat","List of field names in the input vector data to be used as features for training.");
+  SetParameterDescription("feat",
+    "List of field names in the input vector data to be used as features for training.");
 
   // Add validation data used to compute confusion matrix or contingency table
   AddParameter( ParameterType_Group, "valid", "Validation data" );
-  SetParameterDescription( "valid", "This group of parameters defines validation data." );
+  SetParameterDescription( "valid", 
+    "This group of parameters defines validation data." );
 
-  AddParameter( ParameterType_InputVectorDataList, "valid.vd", "Validation Vector Data" );
+  AddParameter( ParameterType_InputVectorDataList, "valid.vd", 
+    "Validation Vector Data" );
   SetParameterDescription( "valid.vd", "Geometries used for validation "
           "(must contain the same fields used for training, all geometries from the layer will be used)" );
   MandatoryOff( "valid.vd" );
 
   AddParameter( ParameterType_Int, "valid.layer", "Layer Index" );
-  SetParameterDescription( "valid.layer", "Index of the layer to use in the validation vector file." );
+  SetParameterDescription( "valid.layer", 
+    "Index of the layer to use in the validation vector file." );
   MandatoryOff( "valid.layer" );
   SetDefaultParameterInt( "valid.layer", 0 );
 
   // Add class field if we used validation
-  AddParameter( ParameterType_ListView, "cfield", "Field containing the class id for supervision" );
-  SetParameterDescription( "cfield", "Field containing the class id for supervision. "
-          "Only geometries with this field available will be taken into account." );
+  AddParameter( ParameterType_ListView, "cfield",
+    "Field containing the class integer label for supervision" );
+  SetParameterDescription( "cfield", 
+    "Field containing the class id for supervision. "
+    "The values in this field shall be cast into integers. "
+    "Only geometries with this field available will be taken into account." );
   SetListViewSingleSelectionMode( "cfield", true );
 
   // Add a new parameter to compute confusion matrix / contingency table
-  AddParameter( ParameterType_OutputFilename, "io.confmatout", "Output confusion matrix or contingency table" );
-  SetParameterDescription( "io.confmatout", "Output file containing the confusion matrix or contingency table (.csv format)."
-          "The contingency table is output when we unsupervised algorithms is used otherwise the confusion matrix is output." );
+  AddParameter( ParameterType_OutputFilename, "io.confmatout", 
+    "Output confusion matrix or contingency table" );
+  SetParameterDescription( "io.confmatout", 
+    "Output file containing the confusion matrix or contingency table (.csv format)."
+    "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");
+  SetParameterDescription("v", "Verbose mode, display the contingency table result.");
+  MandatoryOff("v");
 
   // Doc example parameter settings
   SetDocExampleParameterValue( "io.vd", "vectorData.shp" );
@@ -272,7 +289,7 @@ TrainVectorBase::ExtractSamplesWithLabel(std::string parameterName, std::string
 
         input->PushBack( mv );
 
-        if( feature.ogr().IsFieldSet( cFieldIndex ) && cFieldIndex != -1 )
+        if(cFieldIndex>=0 && ogr::Field(feature,cFieldIndex).HasBeenSet())
           target->PushBack( feature.ogr().GetFieldAsInteger( cFieldIndex ) );
         else
           target->PushBack( 0 );
diff --git a/Modules/Applications/AppClassification/otb-module.cmake b/Modules/Applications/AppClassification/otb-module.cmake
index ca0c928..efd9cb3 100644
--- a/Modules/Applications/AppClassification/otb-module.cmake
+++ b/Modules/Applications/AppClassification/otb-module.cmake
@@ -53,6 +53,7 @@ otb_module(OTBAppClassification
   TEST_DEPENDS
     OTBTestKernel
     OTBCommandLine
+    OTBAppProjection
 
   DESCRIPTION
     "${DOCUMENTATION}"
diff --git a/Modules/Applications/AppClassification/test/CMakeLists.txt b/Modules/Applications/AppClassification/test/CMakeLists.txt
index e877a5e..fae1474 100644
--- a/Modules/Applications/AppClassification/test/CMakeLists.txt
+++ b/Modules/Applications/AppClassification/test/CMakeLists.txt
@@ -168,6 +168,7 @@ foreach(classifier ${classifierList})
     -io.out ${TEMP}/${OUTMODELFILE}
     -sample.vfn Class
     -rand 121212
+    -outxml ${TEMP}/cl${classifier}_OutXML1.xml
 
     VALID    ${valid}
   )
@@ -179,40 +180,15 @@ foreach(classifier ${classifierList})
   endif()
 
   otb_test_application(
-    NAME     apTvClTrainMethod${classifier}ImagesClassifierQB1_OutXML1
+    NAME     apTvClTrainMethod${classifier}ImagesClassifierQB1_InXML1
     APP      TrainImagesClassifier
-    OPTIONS  -io.il ${INPUTDATA}/Classification/QB_1_ortho${raster_input_format}
-    -io.vd ${INPUTDATA}/Classification/VectorData_${${lclassifier}_input}QB1${vector_input_format}
-    -io.imstat ${INPUTDATA}/Classification/clImageStatisticsQB1${stat_input_format}
-    -classifier ${lclassifier}
-    ${${lclassifier}_parameters}
+    OPTIONS  -inxml ${TEMP}/cl${classifier}_OutXML1.xml
     -io.out ${TEMP}/OutXML1_${OUTMODELFILE}
-    -rand 121212
-    -sample.vfn Class
-    -outxml ${TEMP}/cl${classifier}_OutXML1.xml
-
-    VALID ${valid}
-  )
 
-  if(${_classifier_has_baseline} EQUAL -1)
-    set(valid ${ascii_comparison} ${ascii_ref_path}/${OUTMODELFILE} ${TEMP}/OutXML2_${OUTMODELFILE})
-  else()
-    set(valid "")
-  endif()
-
-  otb_test_application(
-    NAME     apTvClTrainMethod${classifier}ImagesClassifierQB1_InXML1
-    APP      TrainImagesClassifier
-    OPTIONS  -inxml ${INPUTDATA}/cl${classifier}_OutXML1.xml
-    -io.il ${INPUTDATA}/Classification/QB_1_ortho${raster_input_format}
-    -io.vd ${INPUTDATA}/Classification/VectorData_${${lclassifier}_input}QB1${vector_input_format}
-    -io.imstat ${INPUTDATA}/Classification/clImageStatisticsQB1${stat_input_format}
-    -io.out ${TEMP}/OutXML2_${OUTMODELFILE}
-    -sample.vfn Class
     VALID    ${valid}
   )
 
-  #set_tests_properties(apTvClTrainMethod${classifier}ImagesClassifierQB1_InXML1 PROPERTIES DEPENDS apTvClTrainMethod${classifier}ImagesClassifierQB1_OutXML1)
+  set_tests_properties(apTvClTrainMethod${classifier}ImagesClassifierQB1_InXML1 PROPERTIES DEPENDS apTvClTrainMethod${classifier}ImagesClassifierQB1)
 
   list(FIND classifier_with_confmap ${classifier} _classifier_has_confmap)
   if(${_classifier_has_confmap} EQUAL -1)
@@ -653,55 +629,37 @@ if(OTB_DATA_USE_LARGEINPUT)
 endif()
 
 #----------- KMeansClassification TESTS ----------------
-otb_test_application(NAME apTvClKMeansImageClassification
-  APP  KMeansClassification
-  OPTIONS -in ${INPUTDATA}/qb_RoadExtract.img
-  -vm ${INPUTDATA}/qb_RoadExtract_mask.png
-  -ts 30000
-  -nc 5
-  -maxit 10000
-  -ct 0.0000001
-  -rand 121212
-  -out ${TEMP}/apTvClKMeansImageClassificationFilterOutput.tif
-  VALID   --compare-image ${NOTOL}
-  ${OTBAPP_BASELINE}/apTvClKMeansImageClassificationFilterOutput.tif
-  ${TEMP}/apTvClKMeansImageClassificationFilterOutput.tif )
-
+if(OTB_USE_SHARK)
+  otb_test_application(NAME apTvClKMeansImageClassification_composite
+    APP  KMeansClassification
+    OPTIONS -in ${INPUTDATA}/qb_RoadExtract.img
+    -vm ${INPUTDATA}/qb_RoadExtract_mask_binary.png
+    -ts 30000
+    -nc 5
+    -maxit 10000
+    -sampler periodic
+    -rand 121212
+    -nodatalabel 255
+    -outmeans ${TEMP}/apTvClKMeansImageClassificationFilterOutMeans.txt
+    -out ${TEMP}/apTvClKMeansImageClassificationFilterOutput.tif uint8
+    -cleanup 0
+    VALID   --compare-image ${NOTOL}
+    ${OTBAPP_BASELINE}/apTvClKMeansImageClassificationFilterOutput.tif
+    ${TEMP}/apTvClKMeansImageClassificationFilterOutput.tif )
+endif()
 
 #----------- TrainImagesClassifier TESTS ----------------
 if(OTB_USE_LIBSVM)
   otb_test_application(NAME apTvClTrainSVMImagesClassifierQB1_allOpt_InXML
     APP  TrainImagesClassifier
     OPTIONS
-    -inxml ${INPUTDATA}/clsvmModelQB1_OutXML.xml
-    -io.il ${INPUTDATA}/Classification/QB_1_ortho.tif
-    -io.vd ${INPUTDATA}/Classification/VectorData_QB1.shp
-    -io.imstat ${INPUTDATA}/Classification/clImageStatisticsQB1.xml
-    -sample.mv 100
-    -sample.mt 100
-    -sample.vtr 0.5
-    -sample.vfn Class
-    -classifier.libsvm.opt true
-    -rand 121212
+    -inxml ${TEMP}/clsvmModelQB1_allOpt.xml
     -io.out ${TEMP}/clsvmModelQB1_allOpt_InXML.svm
     VALID   ${ascii_comparison}
     ${OTBAPP_BASELINE_FILES}/clsvmModelQB1.svm
     ${TEMP}/clsvmModelQB1_allOpt_InXML.svm)
 
-  otb_test_application(NAME apTvClTrainSVMImagesClassifierQB1_OutXML
-    APP  TrainImagesClassifier
-    OPTIONS -io.il ${INPUTDATA}/Classification/QB_1_ortho.tif
-    -io.vd ${INPUTDATA}/Classification/VectorData_QB1.shp
-    -io.imstat ${INPUTDATA}/Classification/clImageStatisticsQB1.xml
-    -sample.vfn Class
-    -classifier libsvm
-    -classifier.libsvm.opt true
-    -io.out ${TEMP}/clsvmModelQB1_OutXML.svm
-    -rand 121212
-    -outxml ${TEMP}/clsvmModelQB1_OutXML.xml
-    VALID   ${ascii_comparison}
-    ${OTBAPP_BASELINE_FILES}/clsvmModelQB1.svm
-    ${TEMP}/clsvmModelQB1_OutXML.svm)
+  set_tests_properties(apTvClTrainSVMImagesClassifierQB1_allOpt_InXML PROPERTIES DEPENDS apTvClTrainSVMImagesClassifierQB1_allOpt)
 
   otb_test_application(NAME apTvClTrainSVMImagesClassifierQB123
     APP  TrainImagesClassifier
@@ -769,6 +727,7 @@ if(OTB_USE_LIBSVM)
     -classifier.libsvm.opt true
     -rand 121212
     -io.out ${TEMP}/clsvmModelQB1_allOpt.svm
+    -outxml ${TEMP}/clsvmModelQB1_allOpt.xml
     VALID   ${ascii_comparison}
     ${OTBAPP_BASELINE_FILES}/clsvmModelQB1.svm
     ${TEMP}/clsvmModelQB1_allOpt.svm)
diff --git a/Modules/Applications/AppEdge/app/otbEdgeExtraction.cxx b/Modules/Applications/AppEdge/app/otbEdgeExtraction.cxx
index c4bcb98..a608338 100644
--- a/Modules/Applications/AppEdge/app/otbEdgeExtraction.cxx
+++ b/Modules/Applications/AppEdge/app/otbEdgeExtraction.cxx
@@ -64,11 +64,16 @@ private:
 void DoInit() ITK_OVERRIDE
 {
 SetName("EdgeExtraction");
-SetDescription("Computes edge features on every pixel of the input image selected channel");
+SetDescription(
+  "This application computes edge features on every pixel of the input image "
+  "selected channel");
 
 // Documentation
 SetDocName("Edge Feature Extraction");
-SetDocLongDescription("This application computes edge features on a mono band image");
+SetDocLongDescription(
+  "This application computes edge features on a selected channel of the input."
+  "It uses different filter such as gradient, Sobel and Touzi");
+
 SetDocLimitations("None");
 SetDocAuthors("OTB-Team");
 SetDocSeeAlso("otb class");
@@ -77,7 +82,7 @@ AddDocTag(Tags::FeatureExtraction);
 AddDocTag("Edge");
 
 AddParameter(ParameterType_InputImage, "in",  "Input Image");
-SetParameterDescription("in", "The input image to compute the features on.");
+SetParameterDescription("in", "The input image on which the features are computed.");
 
 AddParameter(ParameterType_Int,  "channel",  "Selected Channel");
 SetParameterDescription("channel", "The selected channel index");
@@ -91,15 +96,26 @@ SetParameterDescription("filter", "Choice of edge feature");
 
 //Gradient Section
 AddChoice("filter.gradient", "Gradient");
+SetParameterDescription("filter.gradient", 
+  "This filter computes the gradient magnitude of the image at each pixel.");
 
 //Sobel Section
 AddChoice("filter.sobel", "Sobel");
+SetParameterDescription("filter.sobel", 
+  "This filter uses the Sobel operator to calculate the image gradient and "
+  "then finds the magnitude of this gradient vector.");
 
 //Touzi Section
 AddChoice("filter.touzi", "Touzi");
-AddParameter(ParameterType_Int, "filter.touzi.xradius", "The X Radius");
+SetParameterDescription("filter.touzi", 
+  "This filter is more suited for radar images. It has a spatial parameter "
+  "to avoid speckle noise perturbations. The larger the radius is, "
+  "less sensible to the speckle noise the filter is, but micro edge will be missed.");
+AddParameter(ParameterType_Int, "filter.touzi.xradius", 
+  "The X radius of the neighborhood.");
 SetDefaultParameterInt("filter.touzi.xradius", 1);
-AddParameter(ParameterType_Int, "filter.touzi.yradius", "The Y Radius");
+AddParameter(ParameterType_Int, "filter.touzi.yradius", 
+  "The Y radius of the neighborhood.");
 SetDefaultParameterInt("filter.touzi.yradius", 1);
 
 //Canny Section
diff --git a/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx b/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx
index 65eb716..b9eccc1 100644
--- a/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx
+++ b/Modules/Applications/AppEdge/app/otbLineSegmentDetection.cxx
@@ -60,10 +60,19 @@ private:
 
     // Documentation
     SetDocName("Line segment detection");
-    SetDocLongDescription("This application detects locally straight contours in a image. It is based on Burns, Hanson, and Riseman method and use an a contrario validation approach (Desolneux, Moisan, and Morel). The algorithm was published by Rafael Gromponevon Gioi, Jérémie Jakubowicz, Jean-Michel Morel and Gregory Randall.\n The given approach computes gradient and level lines of the image and detects aligned points in line support region. The application allows exporting the detecte [...]
+    SetDocLongDescription(
+      "This application detects locally straight contours in a image."
+      " It is based on Burns, Hanson, and Riseman method and use an a contrario "
+      "validation approach (Desolneux, Moisan, and Morel). The algorithm was published "
+      "by Rafael Gromponevon Gioi, Jérémie Jakubowicz, Jean-Michel Morel and "
+      "Gregory Randall. The given approach computes gradient and level lines of the "
+      "image and detects aligned points in line support region. "
+      "The application allows exporting the detected lines in a vector data.");
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
-    SetDocSeeAlso("On Line demonstration of the LSD algorithm is available here: http://www.ipol.im/pub/algo/gjmr_line_segment_detector/\n");
+    SetDocSeeAlso(
+      "On Line demonstration of the LSD algorithm is available here: "
+      "http://www.ipol.im/pub/algo/gjmr_line_segment_detector/\n");
 
     AddDocTag(Tags::FeatureExtraction);
 
@@ -77,7 +86,9 @@ private:
     ElevationParametersHandler::AddElevationParameters(this, "elev");
 
     AddParameter(ParameterType_Empty, "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");
+    SetParameterDescription("norescale",
+      "By default, the input image amplitude is rescaled between [0,255]."
+      " Turn on this parameter to skip rescaling");
     MandatoryOff("norescale");
 
     AddRAMParameter();
diff --git a/Modules/Applications/AppFiltering/app/CMakeLists.txt b/Modules/Applications/AppFiltering/app/CMakeLists.txt
index 9d58ba6..d7f3dcd 100644
--- a/Modules/Applications/AppFiltering/app/CMakeLists.txt
+++ b/Modules/Applications/AppFiltering/app/CMakeLists.txt
@@ -19,18 +19,12 @@
 #
 
 set(OTBAppFiltering_LINK_LIBS
-  ${OTBImageNoise_LIBRARIES}
   ${OTBImageManipulation_LIBRARIES}
   ${OTBApplicationEngine_LIBRARIES}
   ${OTBImageBase_LIBRARIES}
 )
 
 otb_create_application(
-  NAME           Despeckle
-  SOURCES        otbDespeckle.cxx
-  LINK_LIBRARIES ${${otb-module}_LIBRARIES})
-
-otb_create_application(
   NAME           Smoothing
   SOURCES        otbSmoothing.cxx
   LINK_LIBRARIES ${${otb-module}_LIBRARIES})
diff --git a/Modules/Applications/AppFiltering/otb-module.cmake b/Modules/Applications/AppFiltering/otb-module.cmake
index d33a9ee..5e8fc45 100644
--- a/Modules/Applications/AppFiltering/otb-module.cmake
+++ b/Modules/Applications/AppFiltering/otb-module.cmake
@@ -18,11 +18,10 @@
 # limitations under the License.
 #
 
-set(DOCUMENTATION "Basic filters application.")
+set(DOCUMENTATION "Image filtering application.")
 
 otb_module(OTBAppFiltering
   DEPENDS
-    OTBImageNoise
     OTBImageManipulation
     OTBITK
     OTBApplicationEngine
diff --git a/Modules/Applications/AppFiltering/test/CMakeLists.txt b/Modules/Applications/AppFiltering/test/CMakeLists.txt
index f88934a..9c4a802 100644
--- a/Modules/Applications/AppFiltering/test/CMakeLists.txt
+++ b/Modules/Applications/AppFiltering/test/CMakeLists.txt
@@ -19,8 +19,6 @@
 #
 
 otb_module_test()
-#----------- Despeckle TESTS ----------------
-
 #----------- Smoothing TESTS ----------------
 otb_test_application(NAME  apTvUtSmoothingTest_InXML
                      APP  Smoothing
@@ -52,46 +50,4 @@ otb_test_application(NAME  apTvUtSmoothingTest_OutXML
                              ${TEMP}/apTvUtSmoothingTest_OutXML.tif)
                              
                              
-otb_test_application(NAME  apTvDespeckleLee
-                     APP  Despeckle
-                     OPTIONS -in ${INPUTDATA}/GomaAvant.tif
-               	             -out ${TEMP}/bfFiltreLee_05_05_12_app.tif
-                             -filter lee
-                             -filter.lee.rad 5
-                             -filter.lee.nblooks 12
-                     VALID   --compare-image ${EPSILON_7}
-                             ${BASELINE}/bfFiltreLee_05_05_12.tif
-                             ${TEMP}/bfFiltreLee_05_05_12_app.tif)
-                             
-otb_test_application(NAME  apTvDespeckleFrost
-                     APP  Despeckle
-                     OPTIONS -in ${INPUTDATA}/GomaAvant.tif
-               	             -out ${TEMP}/bfFiltreFrost_05_05_12_app.tif
-                             -filter frost
-                             -filter.frost.rad 5
-                             -filter.frost.deramp 0.1
-                     VALID   --compare-image ${EPSILON_7}
-                             ${BASELINE}/bfFiltreFrost_05_05_12_app.tif
-                             ${TEMP}/bfFiltreFrost_05_05_12_app.tif)
 
-otb_test_application(NAME  apTvDespeckleGammaMAP
-                     APP  Despeckle
-                     OPTIONS -in ${INPUTDATA}/GomaAvant.tif
-               	             -out ${TEMP}/bfFiltreGammaMAP_05_05_12_app.tif
-                             -filter gammamap
-                             -filter.gammamap.rad 5
-                             -filter.gammamap.nblooks 12
-                     VALID   --compare-image ${EPSILON_7}
-                             ${BASELINE}/bfFiltreGammaMAP_05_05_12.tif
-                             ${TEMP}/bfFiltreGammaMAP_05_05_12_app.tif)                      
-                             
-otb_test_application(NAME  apTvDespeckleKuan
-                     APP  Despeckle
-                     OPTIONS -in ${INPUTDATA}/GomaAvant.tif
-               	             -out ${TEMP}/bfFiltreKuan_05_05_12_app.tif
-                             -filter kuan
-                             -filter.kuan.rad 5
-                             -filter.kuan.nblooks 12
-                     VALID   --compare-image ${EPSILON_7}
-                             ${BASELINE}/bfFiltreKuan_05_05_12.tif
-                             ${TEMP}/bfFiltreKuan_05_05_12_app.tif)
diff --git a/Modules/Applications/AppFusion/app/CMakeLists.txt b/Modules/Applications/AppFusion/app/CMakeLists.txt
index a75c4ca..1e7a0eb 100644
--- a/Modules/Applications/AppFusion/app/CMakeLists.txt
+++ b/Modules/Applications/AppFusion/app/CMakeLists.txt
@@ -35,3 +35,6 @@ otb_create_application(
   NAME           Pansharpening
   SOURCES        otbPansharpening.cxx
   LINK_LIBRARIES ${${otb-module}_LIBRARIES})
+
+# Mantis-1427 : temporary fix
+add_dependencies(${otb-module}-all otbapp_Superimpose)
diff --git a/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx b/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx
index 7c67d80..bd52a80 100644
--- a/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx
+++ b/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx
@@ -66,17 +66,16 @@ private:
     ShareParameter("out","pansharp.out");
     ShareParameter("elev","superimpose.elev");
     ShareParameter("mode","superimpose.mode");
+    ShareParameter("method","pansharp.method");
     ShareParameter("lms","superimpose.lms",
       "Spacing of the deformation field",
       "Spacing of the deformation field. Default is 10 times the PAN image spacing.");
+    ShareParameter("interpolator","superimpose.interpolator");
     ShareParameter("fv","superimpose.fv");
     ShareParameter("ram","superimpose.ram");
 
     Connect("pansharp.inp","superimpose.inr");
     Connect("pansharp.ram","superimpose.ram");
-
-    GetInternalApplication("superimpose")->SetParameterString("interpolator","bco", false);
-    GetInternalApplication("pansharp")->SetParameterString("method","rcs", false);
     
     // Doc example parameter settings
     SetDocExampleParameterValue("inp", "QB_Toulouse_Ortho_PAN.tif");
diff --git a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx
index a16a00b..3ed9b7c 100644
--- a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx
+++ b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx
@@ -95,22 +95,37 @@ private:
 
     // Documentation
     SetDocName("Hyperspectral data unmixing");
-    SetDocLongDescription("The application applies a linear unmixing algorithm to an hyperspectral data cube. This method supposes that the mixture between materials in the scene is macroscopic and simulates a linear mixing model of spectra.\nThe Linear Mixing Model (LMM) acknowledges that reflectance spectrum associated with each pixel is a linear combination of pure materials in the recovery area, commonly known as endmembers. Endmembers can be estimated using the VertexComponentAnalys [...]
+    SetDocLongDescription("The application applies a linear unmixing algorithm"
+    "to an hyperspectral data cube. This method supposes that the mixture between"
+    "aterials in the scene is macroscopic and simulates a linear mixing model of"
+    "spectra.\n\n"
+    "The Linear Mixing Model (LMM) acknowledges that reflectance"
+    "spectrum associated with each pixel is a linear combination of pure"
+    "materials in the recovery area, commonly known as endmembers. Endmembers can"
+    "be estimated using the VertexComponentAnalysis application.\n\n"
+    "The application allows to estimate the abundance maps with several algorithms :\n"
+    "  * Unconstrained Least Square (ucls)\n"
+                          //"  * Fully Constrained Least Square (fcls)\n"
+    "  * Image Space Reconstruction Algorithm (isra)\n"
+    "  * Non-negative constrained\n"
+    "  * Least Square (ncls)\n"
+    "  * Minimum Dispersion Constrained Non Negative Matrix Factorization (MDMDNMF)."
+    );
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
     SetDocSeeAlso("VertexComponentAnalysis");
 
-	AddDocTag("Miscellaneous");
+    AddDocTag("Miscellaneous");
     AddDocTag(Tags::Hyperspectral);
 
     AddParameter(ParameterType_InputImage,  "in",   "Input Image Filename");
-    SetParameterDescription("in","The hyperspectral data cube to unmix");
+    SetParameterDescription("in","The hyperspectral data cube input");
 
     AddParameter(ParameterType_OutputImage, "out",  "Output Image");
-    SetParameterDescription("out","The output abundance map");
+    SetParameterDescription("out","The output abundance map. The abundance fraction are stored in a multispectral image where band N corresponds to the fraction of endmembers N in each pixel.");
 
     AddParameter(ParameterType_InputImage,  "ie",   "Input endmembers");
-    SetParameterDescription("ie","The endmembers (estimated pure pixels) to use for unmixing. Must be stored as a multispectral image, where each pixel is interpreted as an endmember");
+    SetParameterDescription("ie","The endmembers (estimated pure pixels) to use for unmixing. Must be stored as a multispectral image, where each pixel is interpreted as an endmember.");
 
     AddParameter(ParameterType_Choice, "ua", "Unmixing algorithm");
     SetParameterDescription("ua", "The algorithm to use for unmixing");
diff --git a/Modules/Applications/AppImageUtils/app/otbConvert.cxx b/Modules/Applications/AppImageUtils/app/otbConvert.cxx
index c06b1c0..cae4ff2 100644
--- a/Modules/Applications/AppImageUtils/app/otbConvert.cxx
+++ b/Modules/Applications/AppImageUtils/app/otbConvert.cxx
@@ -21,17 +21,16 @@
 #include "otbWrapperApplication.h"
 #include "otbWrapperApplicationFactory.h"
 
-#include "itkCastImageFilter.h"
-
-
 #include "otbVectorRescaleIntensityImageFilter.h"
-#include "itkCastImageFilter.h"
 #include "otbUnaryImageFunctorWithVectorImageFilter.h"
 #include "otbStreamingShrinkImageFilter.h"
 #include "itkListSample.h"
 #include "otbListSampleToHistogramListGenerator.h"
 #include "itkImageRegionConstIterator.h"
 
+#include "otbImageListToVectorImageFilter.h"
+#include "otbMultiToMonoChannelExtractROI.h"
+#include "otbImageList.h"
 
 namespace otb
 {
@@ -71,30 +70,46 @@ public:
   /** Filters typedef */
   typedef itk::Statistics::ListSample<FloatVectorImageType::PixelType> ListSampleType;
   typedef itk::Statistics::DenseFrequencyContainer2 DFContainerType;
-  typedef ListSampleToHistogramListGenerator<ListSampleType, FloatVectorImageType::InternalPixelType, DFContainerType> HistogramsGeneratorType;
-  typedef StreamingShrinkImageFilter<FloatVectorImageType, FloatVectorImageType> ShrinkFilterType;
+  typedef ListSampleToHistogramListGenerator<ListSampleType,
+                                             FloatVectorImageType::InternalPixelType,
+                                             DFContainerType> HistogramsGeneratorType;
+  typedef StreamingShrinkImageFilter<FloatVectorImageType,
+                                     FloatVectorImageType> ShrinkFilterType;
   typedef Functor::LogFunctor<FloatVectorImageType::InternalPixelType> TransferLogFunctor;
-  typedef UnaryImageFunctorWithVectorImageFilter<FloatVectorImageType, FloatVectorImageType, TransferLogFunctor> TransferLogType;
+  typedef UnaryImageFunctorWithVectorImageFilter<FloatVectorImageType,
+                                                 FloatVectorImageType,
+                                                 TransferLogFunctor>   TransferLogType;
 
 
 private:
+
   void DoInit() ITK_OVERRIDE
   {
     SetName("Convert");
-    SetDescription("Convert an image to a different format, eventually rescaling the data"
+    SetDescription("Convert an image to a different format, optionally rescaling the data"
                    " and/or changing the pixel type.");
     // Documentation
     SetDocName("Image Conversion");
-    SetDocLongDescription("This application performs an image pixel type conversion (short, ushort, uchar, int, uint, float and double types are handled). The output image is written in the specified format (ie. that corresponds to the given extension).\n The conversion can include a rescale using the image 2 percent minimum and maximum values. The rescale can be linear or log2.");
+    SetDocLongDescription("This application performs an image pixel type conversion "
+      "(short, ushort, uchar, int, uint, float and double types are handled). "
+      "The output image is written in the specified format (ie. that corresponds "
+      "to the given extension).\n The conversion can include a rescale of the data range, "
+      "by default it's set from 2% to 98% of the data values. The rescale can be linear or log2. \n "
+      "The choice of the output channels can be done with the extended filename, "
+      "but less easy to handle. To do this, a 'channels' parameter allows you to select "
+      "the desired bands at the output. There are 3 modes, the available choices are: \n"
+        " * grayscale :  to display mono image as standard color image \n"
+        " * rgb : select 3 bands in the input image (multi-bands) \n"
+        " * all : keep all bands.");
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
     SetDocSeeAlso("Rescale");
 
-	AddDocTag(Tags::Manip);
+    AddDocTag(Tags::Manip);
     AddDocTag("Conversion");
     AddDocTag("Image Dynamic");
 
-    AddParameter(ParameterType_InputImage,  "in",   "Input image");
+    AddParameter(ParameterType_InputImage, "in", "Input image");
     SetParameterDescription("in", "Input image");
 
     AddParameter(ParameterType_Choice, "type", "Rescale type");
@@ -110,7 +125,8 @@ private:
     MandatoryOff("type.linear.gamma");
 
     AddParameter(ParameterType_InputImage,  "mask",   "Input mask");
-    SetParameterDescription("mask", "The masked pixels won't be used to adapt the dynamic (the mask must have the same dimensions as the input image)");
+    SetParameterDescription("mask", "The masked pixels won't be used to adapt the dynamic "
+      "(the mask must have the same dimensions as the input image)");
     MandatoryOff("mask");
     DisableParameter("mask");
 
@@ -118,40 +134,94 @@ private:
     SetParameterDescription("hcp","Parameters to cut the histogram edges before rescaling");
 
     AddParameter(ParameterType_Float, "hcp.high", "High Cut Quantile");
-    SetParameterDescription("hcp.high", "Quantiles to cut from histogram high values before computing min/max rescaling (in percent, 2 by default)");
+    SetParameterDescription("hcp.high", "Quantiles to cut from histogram high values "
+      "before computing min/max rescaling (in percent, 2 by default)");
     MandatoryOff("hcp.high");
     SetDefaultParameterFloat("hcp.high", 2.0);
     DisableParameter("hcp.high");
 
     AddParameter(ParameterType_Float, "hcp.low", "Low Cut Quantile");
-    SetParameterDescription("hcp.low", "Quantiles to cut from histogram low values before computing min/max rescaling (in percent, 2 by default)");
+    SetParameterDescription("hcp.low", "Quantiles to cut from histogram low values "
+      "before computing min/max rescaling (in percent, 2 by default)");
     MandatoryOff("hcp.low");
     SetDefaultParameterFloat("hcp.low", 2.0);
     DisableParameter("hcp.low");
 
     AddParameter(ParameterType_OutputImage, "out",  "Output Image");
     SetParameterDescription("out", "Output image");
+    SetDefaultOutputPixelType("out",ImagePixelType_uint8);
+
+    AddParameter(ParameterType_Choice, "channels", "Channels selection");
+    SetParameterDescription("channels", "It's possible to select the channels "
+      "of the output image. There are 3 modes, the available choices are:");
+
+    AddChoice("channels.all", "Default mode");
+    SetParameterDescription("channels.all", "Select all bands in the input image, (1,...,n).");
+
+    AddChoice("channels.grayscale", "Grayscale mode");
+    SetParameterDescription("channels.grayscale", "Display single channel as standard color image.");
+    AddParameter(ParameterType_Int, "channels.grayscale.channel", "Grayscale channel");
+    SetDefaultParameterInt("channels.grayscale.channel", 1);
+    SetMinimumParameterIntValue("channels.grayscale.channel", 1);
+
+    AddChoice("channels.rgb", "RGB composition");
+    SetParameterDescription("channels.rgb", "Select 3 bands in the input image "
+      "(multi-bands), by default (1,2,3).");
+
+    AddParameter(ParameterType_Int, "channels.rgb.red", "Red Channel");
+    SetParameterDescription("channels.rgb.red", "Red channel index.");
+    SetMinimumParameterIntValue("channels.rgb.red", 1);
+    AddParameter(ParameterType_Int, "channels.rgb.green", "Green Channel");
+    SetParameterDescription("channels.rgb.green", "Green channel index.");
+    SetMinimumParameterIntValue("channels.rgb.green", 1);
+    AddParameter(ParameterType_Int, "channels.rgb.blue", "Blue Channel");
+    SetParameterDescription("channels.rgb.blue", "Blue channel index.");
+    SetMinimumParameterIntValue("channels.rgb.blue", 1);
 
     AddRAMParameter();
 
     // Doc example parameter settings
     SetDocExampleParameterValue("in", "QB_Toulouse_Ortho_XS.tif");
-    SetDocExampleParameterValue("out", "otbConvertWithScalingOutput.png uint8");
+    SetDocExampleParameterValue("out", "otbConvertWithScalingOutput.png");
     SetDocExampleParameterValue("type", "linear");
+    SetDocExampleParameterValue("channels", "rgb");
 
     SetOfficialDocLink();
   }
 
   void DoUpdateParameters() ITK_OVERRIDE
   {
-    // Nothing to do here for the parameters : all are independent
+    // Read information
+    if ( HasValue("in") )
+      {
+      typedef otb::ImageMetadataInterfaceBase ImageMetadataInterfaceType;
+      ImageMetadataInterfaceType::Pointer metadataInterface = 
+      ImageMetadataInterfaceFactory::CreateIMI(GetParameterImage("in")->GetMetaDataDictionary());
+
+      int nbBand = GetParameterImage("in")->GetNumberOfComponentsPerPixel();
+      SetMaximumParameterIntValue("channels.grayscale.channel", nbBand);
+      SetMaximumParameterIntValue("channels.rgb.red", nbBand);
+      SetMaximumParameterIntValue("channels.rgb.green", nbBand);
+      SetMaximumParameterIntValue("channels.rgb.blue", nbBand);
+
+      if (nbBand > 1)
+        {
+        // get band index : Red/Green/Blue
+        int bandRed = metadataInterface->GetDefaultDisplay()[0] + 1;
+        int bandGreen = metadataInterface->GetDefaultDisplay()[1] + 1;
+        int bandBlue = metadataInterface->GetDefaultDisplay()[2] + 1;
+        SetDefaultParameterInt("channels.rgb.red", bandRed);
+        SetDefaultParameterInt("channels.rgb.green", bandGreen);
+        SetDefaultParameterInt("channels.rgb.blue", bandBlue);
+        }
+      }
+    
+
   }
 
   template<class TImageType>
   void GenericDoExecute()
   {
-    typename TImageType::Pointer castIm;
-
     std::string rescaleType = this->GetParameterString("type");
 
     if( (rescaleType != "none") && (rescaleType != "linear") && (rescaleType != "log2") )
@@ -161,21 +231,24 @@ private:
 
     if( rescaleType == "none" )
       {
-      castIm = this->GetParameterImage<TImageType>("in");
+      // selected channel
+      typename TImageType::Pointer tempImage;
+      tempImage = GetSelectedChannels<TImageType>();
+
+      SetParameterOutputImage<TImageType>("out", tempImage);
+
       }
-    else
+    else // linear or log2
       {
-      FloatVectorImageType::Pointer input = this->GetParameterImage("in");
-
       FloatVectorImageType::Pointer mask;
-      bool useMask = false;
-      if (IsParameterEnabled("mask"))
-        {
-        mask = this->GetParameterImage("mask");
-        useMask = true;
-        }
 
-      const unsigned int nbComp(input->GetNumberOfComponentsPerPixel());
+      if (IsParameterEnabled("mask")) mask = this->GetParameterImage("mask");
+
+      // selected channel
+      typename FloatVectorImageType::Pointer tempImage;
+      tempImage = GetSelectedChannels<FloatVectorImageType>();
+
+      const unsigned int nbComp(tempImage->GetNumberOfComponentsPerPixel());
 
       typedef otb::VectorRescaleIntensityImageFilter<FloatVectorImageType, TImageType> RescalerType;
       typename TImageType::PixelType minimum;
@@ -197,8 +270,9 @@ private:
 
       // Shrink factor is computed so as to load a quicklook of 1000
       // pixels square at most
-      typename FloatVectorImageType::SizeType imageSize = input->GetLargestPossibleRegion().GetSize();
-      unsigned int shrinkFactor = std::max(imageSize[0], imageSize[1]) < 1000 ? 1 : std::max(imageSize[0], imageSize[1])/1000;
+      typename FloatVectorImageType::SizeType imageSize = tempImage->GetLargestPossibleRegion().GetSize();
+      unsigned int shrinkFactor =
+        std::max(imageSize[0], imageSize[1]) < 1000 ? 1 : std::max(imageSize[0], imageSize[1])/1000;
 
       otbAppLogDEBUG( << "Shrink factor used to compute Min/Max: "<<shrinkFactor );
 
@@ -212,7 +286,7 @@ private:
         {
         //define the transfer log
         m_TransferLog = TransferLogType::New();
-        m_TransferLog->SetInput(input);
+        m_TransferLog->SetInput(tempImage);
         m_TransferLog->UpdateOutputInformation();
 
         shrinkFilter->SetInput(m_TransferLog->GetOutput());
@@ -221,37 +295,32 @@ private:
         }
       else
         {
-        shrinkFilter->SetInput(input);
-        rescaler->SetInput(input);
+        shrinkFilter->SetInput(tempImage);
+        rescaler->SetInput(tempImage);
         shrinkFilter->Update();
         }
 
       ShrinkFilterType::Pointer maskShrinkFilter = ShrinkFilterType::New();
-      if (useMask)
-        {
-        maskShrinkFilter->SetShrinkFactor(shrinkFactor);
-        maskShrinkFilter->SetInput(mask);
-        maskShrinkFilter->GetStreamer()->SetAutomaticAdaptativeStreaming(GetParameterInt("ram"));
-        maskShrinkFilter->Update();
-        }
-
-      otbAppLogDEBUG( << "Shrink done" );
-
 
       otbAppLogDEBUG( << "Evaluating input Min/Max..." );
-      itk::ImageRegionConstIterator<FloatVectorImageType> it(shrinkFilter->GetOutput(), shrinkFilter->GetOutput()->GetLargestPossibleRegion());
+      itk::ImageRegionConstIterator<FloatVectorImageType>
+        it(shrinkFilter->GetOutput(), shrinkFilter->GetOutput()->GetLargestPossibleRegion());
       itk::ImageRegionConstIterator<FloatVectorImageType> itMask;
-      if (useMask)
-        {
-        itMask = itk::ImageRegionConstIterator<FloatVectorImageType>(maskShrinkFilter->GetOutput(),maskShrinkFilter->GetOutput()->GetLargestPossibleRegion());
-        }
 
       typename ListSampleType::Pointer listSample = ListSampleType::New();
-      listSample->SetMeasurementVectorSize(input->GetNumberOfComponentsPerPixel());
+      listSample->SetMeasurementVectorSize(tempImage->GetNumberOfComponentsPerPixel());
 
       // Now we generate the list of samples
-      if (useMask)
+      if (IsParameterEnabled("mask"))
         {
+        maskShrinkFilter->SetShrinkFactor(shrinkFactor);
+        maskShrinkFilter->SetInput(mask);
+        maskShrinkFilter->GetStreamer()->SetAutomaticAdaptativeStreaming(GetParameterInt("ram"));
+        maskShrinkFilter->Update();
+
+        itMask = itk::ImageRegionConstIterator<FloatVectorImageType>(
+          maskShrinkFilter->GetOutput(),maskShrinkFilter->GetOutput()->GetLargestPossibleRegion());
+
         // Remove masked pixels
         it.GoToBegin();
         itMask.GoToBegin();
@@ -265,19 +334,16 @@ private:
           ++it;
           ++itMask;
           }
-        }
-      else
-        {
-        for(it.GoToBegin(); !it.IsAtEnd(); ++it)
+        if (listSample->Size() == 0)
           {
-          listSample->PushBack(it.Get());
+          otbAppLogINFO( << "All pixels were masked, the application assume a wrong mask "
+            "and include all the image");
           }
         }
 
-      // if all pixels were masked, we assume a wrong mask and then include all image
-      if (listSample->Size() == 0)
+      // if mask is disable and all pixels were masked
+      if ((!IsParameterEnabled("mask")) || (listSample->Size() == 0))
         {
-        otbAppLogINFO( << "All pixels were masked, the application assume a wrong mask and include all the image");
         for(it.GoToBegin(); !it.IsAtEnd(); ++it)
           {
           listSample->PushBack(it.Get());
@@ -294,10 +360,15 @@ private:
       // And extract the lower and upper quantile
       typename FloatVectorImageType::PixelType inputMin(nbComp), inputMax(nbComp);
 
+      auto histOutput = histogramsGenerator->GetOutput();
+      assert(histOutput);
+
       for(unsigned int i = 0; i < nbComp; ++i)
         {
-        inputMin[i] = histogramsGenerator->GetOutput()->GetNthElement(i)->Quantile(0, 0.01 * GetParameterFloat("hcp.low"));
-        inputMax[i] = histogramsGenerator->GetOutput()->GetNthElement(i)->Quantile(0, 1.0 - 0.01 * GetParameterFloat("hcp.high"));
+        auto && elm = histOutput->GetNthElement(i);
+        assert(elm);
+        inputMin[i] = elm->Quantile(0, 0.01 * GetParameterFloat("hcp.low"));
+        inputMax[i] = elm->Quantile(0, 1.0 - 0.01 * GetParameterFloat("hcp.high"));
         }
 
       otbAppLogDEBUG( << std::setprecision(5) << "Min/Max computation done : min=" << inputMin
@@ -313,15 +384,99 @@ private:
         }
 
       m_TmpFilter = rescaler;
-      castIm = rescaler->GetOutput();
+
+      SetParameterOutputImage<TImageType>("out", rescaler->GetOutput());
       }
+  }
+
+  // Get the bands order
+  std::vector<int> GetChannels()
+  {
+    std::vector<int> channels;
 
+    int nbChan = GetParameterImage("in")->GetNumberOfComponentsPerPixel();
+    std::string channelMode = GetParameterString("channels");
 
-    SetParameterOutputImage<TImageType>("out", castIm);
+    if(channelMode == "grayscale")
+    {
+      if (GetParameterInt("channels.grayscale.channel") <= nbChan)
+      {
+        channels = {GetParameterInt("channels.grayscale.channel"),
+                    GetParameterInt("channels.grayscale.channel"),
+                    GetParameterInt("channels.grayscale.channel")};
+      }
+      else
+      {
+        itkExceptionMacro(<< "The channel has an invalid index");
+      }
+    }
+    else if (channelMode == "rgb")
+    {
+      if ((GetParameterInt("channels.rgb.red") <= nbChan)
+      && ( GetParameterInt("channels.rgb.green") <= nbChan)
+      && ( GetParameterInt("channels.rgb.blue")   <= nbChan))
+      {
+        channels = {GetParameterInt("channels.rgb.red"),
+                    GetParameterInt("channels.rgb.green"),
+                    GetParameterInt("channels.rgb.blue")};
+      }
+      else
+      {
+        itkExceptionMacro(<< "At least one needed channel has an invalid index");
+      }
+    }
+    else if (channelMode == "all")
+    {
+      // take all bands
+      channels.resize(nbChan);
+      std::iota(channels.begin(), channels.end(), 1);
+    }
+    return channels;
+  }
+
+  // return an image with the bands order modified of the input image
+  template<class TImageType>
+  typename TImageType::Pointer GetSelectedChannels()
+  {
+    typedef MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType,
+                                         typename TImageType::InternalPixelType>  ExtractROIFilterType;
+    typedef ObjectList<ExtractROIFilterType>                                      ExtractROIFilterListType;
+    typedef otb::ImageList<otb::Image<typename TImageType::InternalPixelType> >   ImageListType;
+    typedef ImageListToVectorImageFilter<ImageListType,
+                                         TImageType >                             ListConcatenerFilterType;
+
+    typename ImageListType::Pointer             imageList;
+    typename ListConcatenerFilterType::Pointer  concatener;
+    typename ExtractROIFilterListType::Pointer  extractorList;
+
+    imageList = ImageListType::New();
+    concatener = ListConcatenerFilterType::New();
+    extractorList = ExtractROIFilterListType::New();
+
+    const bool monoChannel = IsParameterEnabled("channels.grayscale");
+
+    // get band order
+    std::vector<int> channels = GetChannels();
+
+    for (auto && channel : channels)
+    {
+      typename ExtractROIFilterType::Pointer extractROIFilter = ExtractROIFilterType::New();
+      extractROIFilter->SetInput(GetParameterImage("in"));
+      if (!monoChannel) extractROIFilter->SetChannel(channel);
+      extractROIFilter->UpdateOutputInformation();
+      extractorList->PushBack(extractROIFilter);
+      imageList->PushBack(extractROIFilter->GetOutput());
+    }
+
+    concatener->SetInput(imageList);
+    concatener->UpdateOutputInformation();
+    concatener->Update();
+
+    return concatener->GetOutput();
   }
 
 
- void DoExecute() ITK_OVERRIDE
+  void DoExecute() ITK_OVERRIDE
   {
     switch ( this->GetParameterOutputImagePixelType("out") )
       {
diff --git a/Modules/Applications/AppImageUtils/app/otbDownloadSRTMTiles.cxx b/Modules/Applications/AppImageUtils/app/otbDownloadSRTMTiles.cxx
index 1004b4c..813fa5c 100644
--- a/Modules/Applications/AppImageUtils/app/otbDownloadSRTMTiles.cxx
+++ b/Modules/Applications/AppImageUtils/app/otbDownloadSRTMTiles.cxx
@@ -21,6 +21,7 @@
 #include "otbWrapperApplication.h"
 #include "otbWrapperApplicationFactory.h"
 #include "otbGenericRSTransform.h"
+#include "otbOGRDataSourceWrapper.h"
 #include "otbCurlHelper.h"
 
 namespace otb
@@ -34,17 +35,14 @@ enum
 
 const std::string SRTMServerPath = "http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/";
 
-const char* USGSContinentDir[] = {"Africa",
-                                  "Australia",
-                                  "Eurasia",
-                                  "Islands",
-                                  "North_America",
-                                  "South_America"};
-
-const std::vector<std::string> USGSContinentList(USGSContinentDir, USGSContinentDir + sizeof(USGSContinentDir)/sizeof(USGSContinentDir[0]));
-
-const std::string HGTExtension = ".hgt.zip";
-const std::string HGTExtensionSimulation = ".hgt";
+const std::string HGTZIPExtension = ".hgt.zip";
+const std::string HGTExtension = ".hgt";
+const std::string ZIPExtension = ".zip";
+#ifdef _WIN32
+const char Sep = '\\';
+#else
+const char Sep = '/';
+#endif
 namespace Wrapper
 {
 
@@ -57,47 +55,143 @@ public:
   typedef itk::SmartPointer<Self>       Pointer;
   typedef itk::SmartPointer<const Self> ConstPointer;
 
-  typedef otb::GenericRSTransform<>     RSTransformType;
+  using RSTransformType = otb::GenericRSTransform<>;
+  using IndexType = FloatVectorImageType::IndexType;
+  using PointType = FloatVectorImageType::PointType;
+  using SizeType = FloatVectorImageType::SizeType;
+  using SpacingType = FloatVectorImageType::SpacingType;
 
-  typedef FloatVectorImageType::IndexType    IndexType;
-  typedef FloatVectorImageType::PointType    PointType;
-  typedef FloatVectorImageType::SizeType     SizeType;
-  typedef FloatVectorImageType::SpacingType  SpacingType;
   /** Standard macro */
   itkNewMacro(Self);
 
   itkTypeMacro(DownloadSRTMTiles, otb::Application);
 
+  typedef struct
+    {
+    int Lon : 9;
+    int Lat : 8;
+    unsigned int Conti : 3;
+    } SRTMTileId;
+
 private:
+  DownloadSRTMTiles();
 
-  int m_Mode;
-  
-  DownloadSRTMTiles() : m_Mode(Mode_Download) {}
+  class TileIdComparator
+    {
+    public:
+      bool operator() (const SRTMTileId & a, const SRTMTileId & b) const
+        {
+        if (a.Lat < b.Lat)
+          return true;
+        if (a.Lat == b.Lat && a.Lon < b.Lon)
+          return true;
+        return false;
+        }
+    };
+
+  typedef std::set<SRTMTileId,TileIdComparator> SRTMTileSet;
+
+  std::string SRTMIdToName(const SRTMTileId &id) const
+    {
+    char name[8];
+    sprintf(name,"%c%02d%c%03d",
+      (id.Lat < 0 ? 'S' : 'N'),
+      vcl_abs(id.Lat),
+      (id.Lon < 0 ? 'W' : 'E'),
+      vcl_abs(id.Lon));
+    return std::string(name);
+    }
+
+  std::string SRTMIdToContinent(const SRTMTileId &id) const
+    {
+    switch (id.Conti)
+      {
+      case 0:
+        // this tile is unknown, return an empty string.
+        break;
+      case 1:
+        return std::string("Africa");
+      case 2:
+        return std::string("Australia");
+      case 3:
+        return std::string("Eurasia");
+      case 4:
+        return std::string("Islands");
+      case 5:
+        return std::string("North_America");
+      case 6:
+        return std::string("South_America");
+      default:
+        break;
+      }
+    return std::string();
+    }
 
-  bool SRTMTileExists(const std::string & url) const
+  bool SRTMTileExists(const SRTMTileId & tile, std::string & continent) const
   {
-    switch ( m_Mode )
+    auto pos = m_SRTMTileList.find(tile);
+    if (pos != m_SRTMTileList.end())
       {
-      case Mode_Download:
+      continent = this->SRTMIdToContinent(*pos);
+      return true;
+      }
+    return false;
+  }
+
+  bool SRTMTileDownloaded(const std::string & name, const std::string & tileDir) const
+  {
+    std::string path(tileDir);
+    if (!path.empty() && path.back() != Sep)
       {
-      CurlHelper::Pointer curl = CurlHelper::New();
-      curl->SetTimeout(0);
-      return !curl->IsCurlReturnHttpError(url);
+      path += Sep;
       }
-      break;
-      case Mode_List:
+    // try different filenames
+    std::string filepath(path+name+HGTExtension);
+    bool exists = itksys::SystemTools::FileExists(filepath.c_str());
+    if (!exists)
       {
-      return itksys::SystemTools::FileExists(url.c_str());
+      filepath += ZIPExtension;
+      exists = itksys::SystemTools::FileExists(filepath.c_str());
       }
-      default :
-      break;
+
+    if (!exists)
+      {
+      std::string lowerName(name);
+      std::transform(name.begin(), name.end(), lowerName.begin(), ::tolower);
+      filepath = path + lowerName + HGTExtension;
+      exists = itksys::SystemTools::FileExists(filepath.c_str());
+      if (!exists)
+        {
+        filepath += ZIPExtension;
+        exists = itksys::SystemTools::FileExists(filepath.c_str());
+        }
       }
-    return false;
+    return exists;
   }
-  void DoInit() ITK_OVERRIDE
+
+  bool CheckPermissions(const std::string &dir) const
+    {
+    std::string path(dir);
+    if (!path.empty() && path.back() != Sep)
+      {
+      path += Sep;
+      }
+    path += "foo";
+    if( itksys::SystemTools::Touch( path.c_str(), true ) )
+      {
+      itksys::SystemTools::RemoveFile( path.c_str() );
+      }
+    else
+      {
+      return false;
+      }
+    return true;
+    }
+
+  void DoInit() override
   {
     SetName("DownloadSRTMTiles");
-    SetDescription("Download or list SRTM tiles related to a set of images");
+    SetDescription("Download or list SRTM tiles");
 
     // Documentation
     SetDocName("Download or list SRTM tiles related to a set of images");
@@ -107,368 +201,2080 @@ private:
     SetDocSeeAlso(" ");
 
     AddDocTag(Tags::Manip);
-	AddDocTag("Utilities");
+	  AddDocTag("Utilities");
 
     AddParameter(ParameterType_InputImageList,  "il",   "Input images list");
-    SetParameterDescription("il", "The list of images on which you want to determine corresponding SRTM tiles.");
+    SetParameterDescription("il", "List of images on which you want to "
+      "determine corresponding SRTM tiles.");
+    MandatoryOff("il");
+
+    AddParameter(ParameterType_InputVectorDataList, "vl", "Input vector data list");
+    SetParameterDescription("vl", "List of vector data files on which you want "
+      "to determine corresponding SRTM tiles.");
+    MandatoryOff("vl");
+
+    AddParameter(ParameterType_StringList, "names", "Input tile names");
+    SetParameterDescription("names", "List of SRTM tile names to download. "
+      "This list is added to the tiles derived from input images or vectors."
+      "The names should follow the SRTM tile naming convention, for instance "
+      "N43E001.");
+    MandatoryOff("names");
+
+    AddParameter(ParameterType_Directory, "tiledir", "Tiles directory");
+    SetParameterDescription("tiledir", "Directory where SRTM tiles "
+      "are stored. In download mode, the zipped archives will be downloaded to "
+      "this directory. You'll need to unzip all tile files before using them in"
+      " your application. In any case, this directory will be inspected to "
+      "check which tiles are already downloaded.");
 
     // UserDefined values
     AddParameter(ParameterType_Choice, "mode", "Download/List corresponding SRTM tiles.");
-    //MandatoryOn("mode");
 
     AddChoice("mode.download", "Download");
     SetParameterDescription("mode.download","Download corresponding tiles on USGE server.");
 
-    AddParameter(ParameterType_Directory, "mode.download.outdir", "Output directory");
-    SetParameterDescription("mode.download.outdir", "Directory where zipped tiles will be save. You'll need to unzip all tile files before using them in your application.");
-
     AddChoice("mode.list", "List tiles");
     SetParameterDescription("mode.list","List tiles in an existing local directory.");
 
-    AddParameter(ParameterType_Directory, "mode.list.indir", "Input directory");
-    SetParameterDescription("mode.list.indir", "Input directory where SRTM tiles can are located.");
-
     // Doc example parameter settings
     SetDocExampleParameterValue("il", "QB_Toulouse_Ortho_XS.tif");
     SetDocExampleParameterValue("mode", "list");
-    SetDocExampleParameterValue("mode.list.indir", "/home/user/srtm_dir/");
+    SetDocExampleParameterValue("tiledir", "/home/user/srtm_dir/");
 
     SetOfficialDocLink();
   }
 
-  void DoUpdateParameters() ITK_OVERRIDE
+  void DoUpdateParameters() override
   {
     // Nothing to do here : all parameters are independent
   }
 
 
-  void DoExecute() ITK_OVERRIDE
+  void DoExecute() override
   {
-
     //Get the mode
-    m_Mode = GetParameterInt("mode");
+    int mode = GetParameterInt("mode");
 
-    // Get the input image list
-    FloatVectorImageListType::Pointer inList = this->GetParameterImageList("il");
+    // Get the inputs
+    auto inList = FloatVectorImageListType::New();
+    std::vector<std::string> vectorDataList;
+    std::vector<std::string> nameList;
 
-    if( inList->Size() == 0 )
-      {
-      itkExceptionMacro("No input Image set...");
-      }
+    if (IsParameterEnabled("il") && HasValue("il"))
+      inList = this->GetParameterImageList("il");
+    if (IsParameterEnabled("vl") && HasValue("vl"))
+      vectorDataList = this->GetParameterStringList("vl");
+    if (IsParameterEnabled("names") && HasValue("names"))
+      nameList = this->GetParameterStringList("names");
 
-    inList->GetNthElement(0)->UpdateOutputInformation();
+    std::string tileDir = this->GetParameterString("tiledir");
 
-    std::set<std::string> listTilesVector;
-    std::set<std::string> tiles;
+    if( inList->Size() + vectorDataList.size() + nameList.size() == 0 )
+      {
+      itkExceptionMacro("No input image/vector/name set...");
+      }
 
+    SRTMTileSet tiles;
+    //--------------------------------------------------------------------------
+    // Check input images
     for( unsigned int i=0; i<inList->Size(); i++ )
       {
-      FloatVectorImageType::Pointer inImage = inList->GetNthElement(i);
-      inImage->UpdateOutputInformation();
-
-      RSTransformType::Pointer rsTransformToWGS84 = RSTransformType::New();
-       rsTransformToWGS84->SetInputKeywordList(inImage->GetImageKeywordlist());
-       rsTransformToWGS84->SetInputProjectionRef(inImage->GetProjectionRef());
-       rsTransformToWGS84->SetOutputProjectionRef(static_cast<std::string> (otb::GeoInformationConversion::ToWKT(4326)));
-
-       rsTransformToWGS84->InstantiateTransform();
-
-       const SizeType size = inImage->GetLargestPossibleRegion().GetSize();
-       const PointType origin=inImage->GetOrigin();
-       const SpacingType spacing=inImage->GetSpacing();
-       PointType upperLeft;
-       upperLeft[0] = origin[0];
-       upperLeft[1] = origin[1];
-       PointType upperLeftWGS84 = rsTransformToWGS84->TransformPoint(upperLeft);
-       otbAppLogDEBUG(<< "upperLeftWGS84 " << upperLeftWGS84);
-
-       PointType upperRight;
-       upperRight[0] = origin[0]+ (size[0] - 1) * spacing[0];
-       upperRight[1] = origin[1];
-       PointType upperRightWGS84 = rsTransformToWGS84->TransformPoint(upperRight);
-       otbAppLogDEBUG(<< "upperRightWGS84 " << upperRightWGS84);
-
-       PointType lowerLeft;
-       lowerLeft[0] = origin[0];
-       lowerLeft[1] = origin[1]+ (size[1] - 1) * spacing[1];
-       PointType lowerLeftWGS84 = rsTransformToWGS84->TransformPoint(lowerLeft);
-       otbAppLogDEBUG(<< "lowerLeftWGS84 " << lowerLeftWGS84);
-
-       PointType lowerRight;
-       lowerRight[0] = origin[0] + (size[0] - 1) * spacing[0];
-       lowerRight[1] = origin[1] + (size[1] - 1) * spacing[1];
-       PointType lowerRightWGS84 = rsTransformToWGS84->TransformPoint(lowerRight);
-       otbAppLogDEBUG(<< "lowerRightWGS84 " << lowerRightWGS84);
-
-      // the iterator constructor can also be used to construct from arrays:
-      const double Longitude[] = {upperLeftWGS84[0],upperRightWGS84[0],lowerLeftWGS84[0],lowerRightWGS84[0]};
-      const double Latitude[] = {upperLeftWGS84[1],upperRightWGS84[1],lowerLeftWGS84[1],lowerRightWGS84[1]};
-
-      std::vector<double> vecLong (Longitude, Longitude + sizeof(Longitude) / sizeof(double) );
-      std::vector<double> vecLat (Latitude, Latitude + sizeof(Latitude) / sizeof(double) );
-
-      std::vector<double> absVecLong;
-      absVecLong.resize(vecLong.size());                         // allocate space
-
-      std::vector<double> absVecLat;
-      absVecLat.resize(vecLat.size());                         // allocate space
-
-      std::vector<double>::iterator AbsLongit=absVecLong.begin();
-
-      for (std::vector<double>::const_iterator it=vecLong.begin(); it!=vecLong.end(); ++it)
-        {
-        *AbsLongit = vcl_abs(*it);
-        ++AbsLongit;
-        }
+      auto inImage = inList->GetNthElement(i);
+
+      auto rsTransformToWGS84 = RSTransformType::New();
+      rsTransformToWGS84->SetInputKeywordList(inImage->GetImageKeywordlist());
+      rsTransformToWGS84->SetInputProjectionRef(inImage->GetProjectionRef());
+      rsTransformToWGS84->SetOutputProjectionRef(static_cast<std::string> (otb::GeoInformationConversion::ToWKT(4326)));
+      rsTransformToWGS84->InstantiateTransform();
+
+      const SizeType size = inImage->GetLargestPossibleRegion().GetSize();
+      const IndexType start = inImage->GetLargestPossibleRegion().GetIndex();
+      PointType tmpPoint;
+      itk::ContinuousIndex<double,2> index(start);
+      index[0] += -0.5;
+      index[1] += -0.5;
+      inImage->TransformContinuousIndexToPhysicalPoint(index,tmpPoint);
+      PointType ul = rsTransformToWGS84->TransformPoint(tmpPoint);
+      index[0] += size[0];
+      inImage->TransformContinuousIndexToPhysicalPoint(index,tmpPoint);
+      PointType ur = rsTransformToWGS84->TransformPoint(tmpPoint);
+      index[1] += size[1];
+      inImage->TransformContinuousIndexToPhysicalPoint(index,tmpPoint);
+      PointType lr = rsTransformToWGS84->TransformPoint(tmpPoint);
+      index[0] -= (double)size[0];
+      inImage->TransformContinuousIndexToPhysicalPoint(index,tmpPoint);
+      PointType ll = rsTransformToWGS84->TransformPoint(tmpPoint);
+
+      int floorMinLong = std::floor(std::min( {ul[0],ur[0],ll[0],lr[0]} ));
+      int floorMaxLong = std::floor(std::max( {ul[0],ur[0],ll[0],lr[0]} ));
+      int floorMinLat = std::floor(std::min( {ul[1],ur[1],ll[1],lr[1]} ));
+      int floorMaxLat = std::floor(std::max( {ul[1],ur[1],ll[1],lr[1]} ));
 
-      std::vector<double>::iterator AbsLatit=absVecLat.begin();
-
-      for (std::vector<double>::const_iterator it=vecLat.begin(); it!=vecLat.end(); ++it)
+      //Construct SRTM tile filename based on min/max lat/long
+      for (int k = floorMinLat; k <= floorMaxLat; ++k)
         {
-        *AbsLatit = vcl_abs(*it);
-        ++AbsLatit;
+        for (int j = floorMinLong; j <= floorMaxLong; ++j)
+          {
+          tiles.insert(SRTMTileId({j,k,0}));
+          }
         }
-
-      const unsigned int distMinLong =
-        std::distance(absVecLong.begin(), min_element (absVecLong.begin(),absVecLong.end()));
-      const unsigned int distMaxLong =
-        std::distance(absVecLong.begin(), max_element (absVecLong.begin(),absVecLong.end()));
-
-      const unsigned int distMinLat =
-        std::distance(absVecLat.begin(), min_element (absVecLat.begin(),absVecLat.end()));
-      const unsigned int distMaxLat =
-        std::distance(absVecLat.begin(), max_element (absVecLat.begin(),absVecLat.end()));
-
-      //find corresponding tiled  for initialization
-      //FIXME recode this properly
-
-      int floorMinLong = 0;
-      int floorMaxLong = 0;
-      int floorMinLat = 0;
-      int floorMaxLat = 0;
-
-      if (vecLong.at(distMinLong) <= vecLong.at(distMaxLong))
+      }
+    //--------------------------------------------------------------------------
+    // Check input vector files
+    for( unsigned int i=0; i<vectorDataList.size(); i++ )
+      {
+      auto source = ogr::DataSource::New(
+        vectorDataList[i],
+        ogr::DataSource::Modes::Read);
+      OGREnvelope envelope;
+      std::string currentWkt("");
+      try
         {
-        floorMinLong = std::floor(vecLong.at(distMinLong));
-        floorMaxLong = std::floor(vecLong.at(distMaxLong));
+        envelope = source->GetGlobalExtent(false,&currentWkt);
         }
-      else
+      catch(...) {}
+      if (currentWkt.empty())
         {
-        floorMinLong = std::floor(vecLong.at(distMaxLong));
-        floorMaxLong = std::floor(vecLong.at(distMinLong));
+        try
+          {
+          envelope = source->GetGlobalExtent(true,&currentWkt);
+          }
+        catch(...)
+          {
+          otbAppLogWARNING("Can't get envelope of vector file : "<<vectorDataList[i]);
+          continue;
+          }
         }
 
-      if (vecLat.at(distMinLat) <= vecLat.at(distMaxLat))
-        {
-        floorMinLat = std::floor(vecLat.at(distMinLat));
-        floorMaxLat = std::floor(vecLat.at(distMaxLat));
-        }
-      else
-        {
-        floorMinLat = std::floor(vecLat.at(distMaxLat));
-        floorMaxLat = std::floor(vecLat.at(distMinLat));
-        }
+      auto rsTransformToWGS84 = RSTransformType::New();
+      rsTransformToWGS84->SetInputProjectionRef(currentWkt);
+      rsTransformToWGS84->SetOutputProjectionRef(static_cast<std::string> (otb::GeoInformationConversion::ToWKT(4326)));
+      rsTransformToWGS84->InstantiateTransform();
+      PointType tmpPoint;
+      tmpPoint[0] = envelope.MinX;
+      tmpPoint[1] = envelope.MinY;
+      PointType ll = rsTransformToWGS84->TransformPoint(tmpPoint);
+      tmpPoint[0] = envelope.MaxX;
+      tmpPoint[1] = envelope.MaxY;
+      PointType ur = rsTransformToWGS84->TransformPoint(tmpPoint);
+      int floorMinLong = std::floor(ll[0]);
+      int floorMaxLong = std::floor(ur[0]);
+      int floorMinLat = std::floor(ll[1]);
+      int floorMaxLat = std::floor(ur[1]);
 
       //Construct SRTM tile filename based on min/max lat/long
       for (int k = floorMinLat; k <= floorMaxLat; ++k)
         {
         for (int j = floorMinLong; j <= floorMaxLong; ++j)
           {
-          std::ostringstream ossOutput;
-          if (k < 0)
-            {
-            ossOutput << "S";
-            }
-          else
-            {
-            ossOutput << "N";
-            }
-
-          if (vcl_abs(k) <= 9)
-            {
-            ossOutput << "0";
-            }
-          ossOutput << vcl_abs(k);
-
-          if (j < 0)
-            {
-            ossOutput << "W";
-            }
-          else
-            {
-            ossOutput << "E";
-            }
-          if (vcl_abs(j) >= 10 && vcl_abs(j) < 100)
-            {
-            ossOutput << "0";
-            }
-          else if (vcl_abs(j) <= 9)
-            {
-            ossOutput << "00";
-            }
-
-          ossOutput << vcl_abs(j);
-
-          tiles.insert(ossOutput.str());
+          tiles.insert(SRTMTileId({j,k,0}));
           }
         }
-
       }
-
-    //iterate over all tiles to build URLs
-    for(std::set<std::string>::const_iterator it= tiles.begin(); it!=tiles.end(); ++it)
+    //--------------------------------------------------------------------------
+    // Check input names
+    for( unsigned int i=0; i<nameList.size(); i++ )
       {
-      switch ( m_Mode )
+      if (nameList[i].size() >= 7)
         {
-        case Mode_Download:
-        {
-        //Build URL
-        bool findURL = false;
-        std::string url;
-        for(std::vector<std::string>::const_iterator contIt= USGSContinentList.begin(); contIt!=USGSContinentList.end(); ++contIt)
+        int lon = 0, lat = 0;
+        try
           {
-          std::ostringstream urlStream;
-          CurlHelper::Pointer curl = CurlHelper::New();
-          curl->SetTimeout(0);
-          urlStream << SRTMServerPath;
-          urlStream << *contIt;
-          urlStream << "/";
-          urlStream << *it;
-          urlStream << HGTExtension;
-
-          url = urlStream.str();
-
-          if (!curl->IsCurlReturnHttpError( urlStream.str()))
-            {
-            findURL = true;
-            break;
-            }
-          else
-            {
-            //try down casing the url
-            std::string lowerIt = *it;
-            std::transform(it->begin(), it->end(), lowerIt.begin(), ::tolower);
-
-            urlStream.clear();
-            urlStream << SRTMServerPath;
-            urlStream << *contIt;
-            urlStream << "/";
-            urlStream << lowerIt;
-            urlStream << HGTExtension;
-            if (!curl->IsCurlReturnHttpError( urlStream.str()))
-              {
-              tiles.erase(*it);
-              tiles.insert(lowerIt);
-              //urls.insert(urlStream.str());
-              findURL = true;
-              break;
-              }
-            else
-              {
-              //upcase all
-              std::string upperIt = *it;
-              std::transform(it->begin(), it->end(), upperIt.begin(), ::toupper);
-
-              urlStream.clear();
-              urlStream << SRTMServerPath;
-              urlStream << *contIt;
-              urlStream << "/";
-              urlStream << upperIt;
-              urlStream << HGTExtension;
-
-              if (!curl->IsCurlReturnHttpError( urlStream.str()))
-                {
-                tiles.erase(*it);
-                tiles.insert(upperIt);
-                //urls.insert(urlStream.str());
-                findURL = true;
-                break;
-                }
-              }
-            }
-
+          lat = boost::lexical_cast<int>(nameList[i].substr(1,2));
           }
-
-        if (!findURL)
+        catch(boost::bad_lexical_cast &)
           {
-          itkExceptionMacro(<< url  <<" not found!");
+          otbAppLogWARNING(<< "Wrong longitude in tile name : "<<nameList[i]);
+          continue;
           }
-
-        otbAppLogINFO(<< "Found Tile on USGS server at URL: " << url);
-        // TODO use the RetrieveUrlInMemory? In this case need to adapt the
-        // timeout
-
-        const std::string outDir = GetParameterString("mode.download.outdir");
-
-        std::ostringstream oss;
-        oss<<outDir<<"/foo";
-
-        if( itksys::SystemTools::Touch( oss.str().c_str(), true ) == false )
+        try
           {
-          itkExceptionMacro( "Error, no write permission in given output directory "<< outDir <<".");
+          lon = boost::lexical_cast<int>(nameList[i].substr(4,3));
           }
-        else
+        catch(boost::bad_lexical_cast &)
           {
-          itksys::SystemTools::RemoveFile( oss.str().c_str() );
+          otbAppLogWARNING(<< "Wrong latitude in tile name : "<<nameList[i]);
+          continue;
           }
-
-        CurlHelper::Pointer curlReq = CurlHelper::New();
-        curlReq->SetTimeout(0);
-        curlReq->RetrieveFile(url, GetParameterString("mode.download.outdir") + "/" + *it + HGTExtension);
-        //TODO unzip here (can do this in memory?)
+        if (nameList[i][0] == 's' || nameList[i][0] == 'S')
+          lat = -lat;
+        else if (nameList[i][0] != 'n' && nameList[i][0] != 'N')
+          {
+          otbAppLogWARNING(<< "Wrong northing in tile name : "<<nameList[i]);
+          continue;
+          }
+        if (nameList[i][3] == 'w' || nameList[i][3] == 'W')
+          lon = -lon;
+        else if (nameList[i][3] != 'e' && nameList[i][3] != 'E')
+          {
+          otbAppLogWARNING(<< "Wrong easting in tile name : "<<nameList[i]);
+          continue;
+          }
+        tiles.insert(SRTMTileId({lon,lat,0}));
         }
-        break;
-        case Mode_List:
+      else
+        {
+        otbAppLogWARNING(<< "Tile name should have at least 7 characters : "<<nameList[i]);
+        }
+      }
+
+    if (tiles.empty())
+      {
+      otbAppLogWARNING(<< "No tile found for the given input(s)!");
+      return;
+      }
+
+    //iterate over all tiles to build URLs
+    std::vector<std::string> nonSRTMTiles;
+    std::vector<std::string> localTiles;
+    std::vector<std::string> missingTiles;
+    std::vector<std::string> continentList;
+    for(auto const& tileId : tiles)
+      {
+      std::string curName(this->SRTMIdToName(tileId));
+      std::string continent;
+      // Check 1 : does the tile exists in SRTM ? If yes, get the continent
+      if (SRTMTileExists(tileId,continent))
         {
-        bool findURL = false;
-        std::ostringstream listStream;
-        listStream << "Corresponding SRTM tiles: ";
-        listStream << GetParameterString("mode.list.indir") + "/";
-        if ( this->SRTMTileExists(GetParameterString("mode.list.indir") + "/" + *it + HGTExtensionSimulation) )
+        // Check 2 : is the tile already downloaded
+        if (SRTMTileDownloaded(curName,tileDir))
           {
-          listStream << *it + HGTExtensionSimulation << " ";
-          findURL = true;
+          localTiles.push_back(curName);
           }
         else
           {
-          //try down casing the url
-          std::string lowerIt = *it;
-          std::transform(it->begin(), it->end(), lowerIt.begin(), ::tolower);
-
-          if ( this->SRTMTileExists(GetParameterString("mode.list.indir") + "/" + lowerIt + HGTExtensionSimulation) )
-            {
-            tiles.erase(*it);
-            tiles.insert(lowerIt);
-            findURL = true;
-            }
-          else
-            {
-            //upcase all
-            std::string upperIt = *it;
-            std::transform(it->begin(), it->end(), upperIt.begin(), ::toupper);
-
-            if (this->SRTMTileExists(GetParameterString("mode.list.indir") + "/" + lowerIt + HGTExtensionSimulation) )
-              {
-              tiles.erase(*it);
-              tiles.insert(upperIt);
-              findURL = true;
-              }
-            }
+          missingTiles.push_back(curName);
+          continentList.push_back(continent);
           }
+        }
+      else
+        {
+        nonSRTMTiles.push_back(curName);
+        }
+      }
 
-        if (!findURL)
+    otbAppLogINFO(<<"Total candidate tiles: "<< tiles.size());
+    // If download mode : try to get missing tiles
+    int srtmHitRatio = ( 100 * (tiles.size() - nonSRTMTiles.size() ) ) /
+      tiles.size();
+    otbAppLogINFO(<<"  --> "<< nonSRTMTiles.size() << " missing tiles in SRTM (coverage ratio is "<< srtmHitRatio << "%)");
+    otbAppLogINFO(<<"  --> "<< localTiles.size()<< " tiles already in the directory");
+    otbAppLogINFO(<<"  --> "<< missingTiles.size()<< " tiles to download");
+    if (mode == Mode_List)
+      {
+      std::ostringstream oss;
+      for (auto const& tileName : nonSRTMTiles)
+        {
+        oss << "  " << tileName << " = NotSRTM\n";
+        }
+      for (auto const& tileName : localTiles)
+        {
+        oss << "  " << tileName << " = Local\n";
+        }
+      for (auto const& tileName : missingTiles)
+        {
+        oss << "  " << tileName << " = Missing\n";
+        }
+      otbAppLogINFO(<< "Status of each tile (NotSRTM/Local/Missing):\n" << oss.str());
+      }
+    if (mode == Mode_Download)
+      {
+      // Check permissions first
+      if ( !CheckPermissions(tileDir) )
+        {
+        otbAppLogFATAL(<< "Can't write into directory : '"<< tileDir <<"'");
+        }
+      std::vector<std::string>::const_iterator it,itConti;
+      auto curl = CurlHelper::New();
+      curl->SetTimeout(0);
+      std::string request;
+      if (!tileDir.empty() && tileDir.back() != Sep)
+        {
+        tileDir += Sep;
+        }
+      for (it=missingTiles.begin(), itConti=continentList.begin() ;
+           it!=missingTiles.end() && itConti!=continentList.end() ;
+           ++it, ++itConti)
+        {
+        otbAppLogINFO(<< "Downloading tile "<<*it << " ...");
+        request = SRTMServerPath + *itConti + "/" + *it + HGTZIPExtension;
+        if (curl->IsCurlReturnHttpError( request ))
           {
-          itkExceptionMacro(<< "Tile " <<  *it + HGTExtensionSimulation  <<" not found in " << GetParameterString("mode.list.indir") << " !");
+          otbAppLogWARNING(<< "Can't access tile : "<< request);
+          continue;
           }
-        otbAppLogINFO( << listStream.str());
-        }
-        break;
+        curl->RetrieveFile(request, std::string(tileDir + *it + HGTZIPExtension));
         }
       }
   }
+
+  SRTMTileSet m_SRTMTileList;
+};
+
+} // end of namespace Wrapper
+} // end of namespace otb
+
+const otb::Wrapper::DownloadSRTMTiles::SRTMTileId staticTileList[] =
+{{6,0,1},{9,0,1},{10,0,1},{11,0,1},{12,0,1},{13,0,1},{14,0,1},{15,0,1}
+,{16,0,1},{17,0,1},{18,0,1},{19,0,1},{20,0,1},{21,0,1},{22,0,1},{23,0,1}
+,{24,0,1},{25,0,1},{26,0,1},{27,0,1},{28,0,1},{29,0,1},{30,0,1},{31,0,1}
+,{32,0,1},{33,0,1},{34,0,1},{35,0,1},{36,0,1},{37,0,1},{38,0,1},{39,0,1}
+,{40,0,1},{41,0,1},{42,0,1},{43,0,1},{7,1,1},{9,1,1},{10,1,1},{11,1,1}
+,{12,1,1},{13,1,1},{14,1,1},{15,1,1},{16,1,1},{17,1,1},{18,1,1},{19,1,1}
+,{20,1,1},{21,1,1},{22,1,1},{23,1,1},{24,1,1},{25,1,1},{26,1,1},{27,1,1}
+,{28,1,1},{29,1,1},{30,1,1},{31,1,1},{32,1,1},{33,1,1},{34,1,1},{35,1,1}
+,{36,1,1},{37,1,1},{38,1,1},{39,1,1},{40,1,1},{41,1,1},{42,1,1},{43,1,1}
+,{44,1,1},{45,1,1},{9,2,1},{10,2,1},{11,2,1},{12,2,1},{13,2,1},{14,2,1}
+,{15,2,1},{16,2,1},{17,2,1},{18,2,1},{19,2,1},{20,2,1},{21,2,1},{22,2,1}
+,{23,2,1},{24,2,1},{25,2,1},{26,2,1},{27,2,1},{28,2,1},{29,2,1},{30,2,1}
+,{31,2,1},{32,2,1},{33,2,1},{34,2,1},{35,2,1},{36,2,1},{37,2,1},{38,2,1}
+,{39,2,1},{40,2,1},{41,2,1},{42,2,1},{43,2,1},{44,2,1},{45,2,1},{46,2,1}
+,{8,3,1},{9,3,1},{10,3,1},{11,3,1},{12,3,1},{13,3,1},{14,3,1},{15,3,1}
+,{16,3,1},{17,3,1},{18,3,1},{19,3,1},{20,3,1},{21,3,1},{22,3,1},{23,3,1}
+,{24,3,1},{25,3,1},{26,3,1},{27,3,1},{28,3,1},{29,3,1},{30,3,1},{31,3,1}
+,{32,3,1},{33,3,1},{34,3,1},{35,3,1},{36,3,1},{37,3,1},{38,3,1},{39,3,1}
+,{40,3,1},{41,3,1},{42,3,1},{43,3,1},{44,3,1},{45,3,1},{46,3,1},{47,3,1}
+,{5,4,1},{6,4,1},{7,4,1},{8,4,1},{9,4,1},{10,4,1},{11,4,1},{12,4,1}
+,{13,4,1},{14,4,1},{15,4,1},{16,4,1},{17,4,1},{18,4,1},{19,4,1},{20,4,1}
+,{21,4,1},{22,4,1},{23,4,1},{24,4,1},{25,4,1},{26,4,1},{27,4,1},{28,4,1}
+,{29,4,1},{30,4,1},{31,4,1},{32,4,1},{33,4,1},{34,4,1},{35,4,1},{36,4,1}
+,{37,4,1},{38,4,1},{39,4,1},{40,4,1},{41,4,1},{42,4,1},{43,4,1},{44,4,1}
+,{45,4,1},{46,4,1},{47,4,1},{48,4,1},{-2,4,1},{-3,4,1},{-6,4,1},{-7,4,1}
+,{-8,4,1},{-9,4,1},{-10,4,1},{0,5,1},{1,5,1},{4,5,1},{5,5,1},{6,5,1}
+,{7,5,1},{8,5,1},{9,5,1},{10,5,1},{11,5,1},{12,5,1},{13,5,1},{14,5,1}
+,{15,5,1},{16,5,1},{17,5,1},{18,5,1},{19,5,1},{20,5,1},{21,5,1},{22,5,1}
+,{23,5,1},{24,5,1},{25,5,1},{26,5,1},{27,5,1},{28,5,1},{29,5,1},{30,5,1}
+,{31,5,1},{32,5,1},{33,5,1},{34,5,1},{35,5,1},{36,5,1},{37,5,1},{38,5,1}
+,{39,5,1},{40,5,1},{41,5,1},{42,5,1},{43,5,1},{44,5,1},{45,5,1},{46,5,1}
+,{47,5,1},{48,5,1},{-1,5,1},{-2,5,1},{-3,5,1},{-4,5,1},{-5,5,1},{-6,5,1}
+,{-7,5,1},{-8,5,1},{-9,5,1},{-10,5,1},{-11,5,1},{0,6,1},{1,6,1},{2,6,1}
+,{3,6,1},{4,6,1},{5,6,1},{6,6,1},{7,6,1},{8,6,1},{9,6,1},{10,6,1}
+,{11,6,1},{12,6,1},{13,6,1},{14,6,1},{15,6,1},{16,6,1},{17,6,1},{18,6,1}
+,{19,6,1},{20,6,1},{21,6,1},{22,6,1},{23,6,1},{24,6,1},{25,6,1},{26,6,1}
+,{27,6,1},{28,6,1},{29,6,1},{30,6,1},{31,6,1},{32,6,1},{33,6,1},{34,6,1}
+,{35,6,1},{36,6,1},{37,6,1},{38,6,1},{39,6,1},{40,6,1},{41,6,1},{42,6,1}
+,{43,6,1},{44,6,1},{45,6,1},{46,6,1},{47,6,1},{48,6,1},{49,6,1},{-1,6,1}
+,{-2,6,1},{-3,6,1},{-4,6,1},{-5,6,1},{-6,6,1},{-7,6,1},{-8,6,1},{-9,6,1}
+,{-10,6,1},{-11,6,1},{-12,6,1},{0,7,1},{1,7,1},{2,7,1},{3,7,1},{4,7,1}
+,{5,7,1},{6,7,1},{7,7,1},{8,7,1},{9,7,1},{10,7,1},{11,7,1},{12,7,1}
+,{13,7,1},{14,7,1},{15,7,1},{16,7,1},{17,7,1},{18,7,1},{19,7,1},{20,7,1}
+,{21,7,1},{22,7,1},{23,7,1},{24,7,1},{25,7,1},{26,7,1},{27,7,1},{28,7,1}
+,{29,7,1},{30,7,1},{31,7,1},{32,7,1},{33,7,1},{34,7,1},{35,7,1},{36,7,1}
+,{37,7,1},{38,7,1},{39,7,1},{40,7,1},{41,7,1},{42,7,1},{43,7,1},{44,7,1}
+,{45,7,1},{46,7,1},{47,7,1},{48,7,1},{49,7,1},{-1,7,1},{-2,7,1},{-3,7,1}
+,{-4,7,1},{-5,7,1},{-6,7,1},{-7,7,1},{-8,7,1},{-9,7,1},{-10,7,1},{-11,7,1}
+,{-12,7,1},{-13,7,1},{-14,7,1},{0,8,1},{1,8,1},{2,8,1},{3,8,1},{4,8,1}
+,{5,8,1},{6,8,1},{7,8,1},{8,8,1},{9,8,1},{10,8,1},{11,8,1},{12,8,1}
+,{13,8,1},{14,8,1},{15,8,1},{16,8,1},{17,8,1},{18,8,1},{19,8,1},{20,8,1}
+,{21,8,1},{22,8,1},{23,8,1},{24,8,1},{25,8,1},{26,8,1},{27,8,1},{28,8,1}
+,{29,8,1},{30,8,1},{31,8,1},{32,8,1},{33,8,1},{34,8,1},{35,8,1},{36,8,1}
+,{37,8,1},{38,8,1},{39,8,1},{40,8,1},{41,8,1},{42,8,1},{43,8,1},{44,8,1}
+,{45,8,1},{46,8,1},{47,8,1},{48,8,1},{49,8,1},{50,8,1},{-1,8,1},{-2,8,1}
+,{-3,8,1},{-4,8,1},{-5,8,1},{-6,8,1},{-7,8,1},{-8,8,1},{-9,8,1},{-10,8,1}
+,{-11,8,1},{-12,8,1},{-13,8,1},{-14,8,1},{0,9,1},{1,9,1},{2,9,1},{3,9,1}
+,{4,9,1},{5,9,1},{6,9,1},{7,9,1},{8,9,1},{9,9,1},{10,9,1},{11,9,1}
+,{12,9,1},{13,9,1},{14,9,1},{15,9,1},{16,9,1},{17,9,1},{18,9,1},{19,9,1}
+,{20,9,1},{21,9,1},{22,9,1},{23,9,1},{24,9,1},{25,9,1},{26,9,1},{27,9,1}
+,{28,9,1},{29,9,1},{30,9,1},{31,9,1},{32,9,1},{33,9,1},{34,9,1},{35,9,1}
+,{36,9,1},{37,9,1},{38,9,1},{39,9,1},{40,9,1},{41,9,1},{42,9,1},{43,9,1}
+,{44,9,1},{45,9,1},{46,9,1},{47,9,1},{48,9,1},{49,9,1},{50,9,1},{-1,9,1}
+,{-2,9,1},{-3,9,1},{-4,9,1},{-5,9,1},{-6,9,1},{-7,9,1},{-8,9,1},{-9,9,1}
+,{-10,9,1},{-11,9,1},{-12,9,1},{-13,9,1},{-14,9,1},{-15,9,1},{0,10,1},{1,10,1}
+,{2,10,1},{3,10,1},{4,10,1},{5,10,1},{6,10,1},{7,10,1},{8,10,1},{9,10,1}
+,{10,10,1},{11,10,1},{12,10,1},{13,10,1},{14,10,1},{15,10,1},{16,10,1},{17,10,1}
+,{18,10,1},{19,10,1},{20,10,1},{21,10,1},{22,10,1},{23,10,1},{24,10,1},{25,10,1}
+,{26,10,1},{27,10,1},{28,10,1},{29,10,1},{30,10,1},{31,10,1},{32,10,1},{33,10,1}
+,{34,10,1},{35,10,1},{36,10,1},{37,10,1},{38,10,1},{39,10,1},{40,10,1},{41,10,1}
+,{42,10,1},{43,10,1},{44,10,1},{45,10,1},{46,10,1},{47,10,1},{48,10,1},{49,10,1}
+,{50,10,1},{51,10,1},{-1,10,1},{-2,10,1},{-3,10,1},{-4,10,1},{-5,10,1},{-6,10,1}
+,{-7,10,1},{-8,10,1},{-9,10,1},{-10,10,1},{-11,10,1},{-12,10,1},{-13,10,1},{-14,10,1}
+,{-15,10,1},{-16,10,1},{0,11,1},{1,11,1},{2,11,1},{3,11,1},{4,11,1},{5,11,1}
+,{6,11,1},{7,11,1},{8,11,1},{9,11,1},{10,11,1},{11,11,1},{12,11,1},{13,11,1}
+,{14,11,1},{15,11,1},{16,11,1},{17,11,1},{18,11,1},{19,11,1},{20,11,1},{21,11,1}
+,{22,11,1},{23,11,1},{24,11,1},{25,11,1},{26,11,1},{27,11,1},{28,11,1},{29,11,1}
+,{30,11,1},{31,11,1},{32,11,1},{33,11,1},{34,11,1},{35,11,1},{36,11,1},{37,11,1}
+,{38,11,1},{39,11,1},{40,11,1},{41,11,1},{42,11,1},{43,11,1},{47,11,1},{48,11,1}
+,{49,11,1},{50,11,1},{51,11,1},{-1,11,1},{-2,11,1},{-3,11,1},{-4,11,1},{-5,11,1}
+,{-6,11,1},{-7,11,1},{-8,11,1},{-9,11,1},{-10,11,1},{-11,11,1},{-12,11,1},{-13,11,1}
+,{-14,11,1},{-15,11,1},{-16,11,1},{-17,11,1},{0,12,1},{1,12,1},{2,12,1},{3,12,1}
+,{4,12,1},{5,12,1},{6,12,1},{7,12,1},{8,12,1},{9,12,1},{10,12,1},{11,12,1}
+,{12,12,1},{13,12,1},{14,12,1},{15,12,1},{16,12,1},{17,12,1},{18,12,1},{19,12,1}
+,{20,12,1},{21,12,1},{22,12,1},{23,12,1},{24,12,1},{25,12,1},{26,12,1},{27,12,1}
+,{28,12,1},{29,12,1},{30,12,1},{31,12,1},{32,12,1},{33,12,1},{34,12,1},{35,12,1}
+,{36,12,1},{37,12,1},{38,12,1},{39,12,1},{40,12,1},{41,12,1},{42,12,1},{43,12,1}
+,{44,12,1},{45,12,1},{52,12,1},{53,12,1},{54,12,1},{-1,12,1},{-2,12,1},{-3,12,1}
+,{-4,12,1},{-5,12,1},{-6,12,1},{-7,12,1},{-8,12,1},{-9,12,1},{-10,12,1},{-11,12,1}
+,{-12,12,1},{-13,12,1},{-14,12,1},{-15,12,1},{-16,12,1},{-17,12,1},{0,13,1},{1,13,1}
+,{2,13,1},{3,13,1},{4,13,1},{5,13,1},{6,13,1},{7,13,1},{8,13,1},{9,13,1}
+,{10,13,1},{11,13,1},{12,13,1},{13,13,1},{14,13,1},{15,13,1},{16,13,1},{17,13,1}
+,{18,13,1},{19,13,1},{20,13,1},{21,13,1},{22,13,1},{23,13,1},{24,13,1},{25,13,1}
+,{26,13,1},{27,13,1},{28,13,1},{29,13,1},{30,13,1},{31,13,1},{32,13,1},{33,13,1}
+,{34,13,1},{35,13,1},{36,13,1},{37,13,1},{38,13,1},{39,13,1},{40,13,1},{41,13,1}
+,{42,13,1},{43,13,1},{44,13,1},{45,13,1},{46,13,1},{47,13,1},{48,13,1},{-1,13,1}
+,{-2,13,1},{-3,13,1},{-4,13,1},{-5,13,1},{-6,13,1},{-7,13,1},{-8,13,1},{-9,13,1}
+,{-10,13,1},{-11,13,1},{-12,13,1},{-13,13,1},{-14,13,1},{-15,13,1},{-16,13,1},{-17,13,1}
+,{0,14,1},{1,14,1},{2,14,1},{3,14,1},{4,14,1},{5,14,1},{6,14,1},{7,14,1}
+,{8,14,1},{9,14,1},{10,14,1},{11,14,1},{12,14,1},{13,14,1},{14,14,1},{15,14,1}
+,{16,14,1},{17,14,1},{18,14,1},{19,14,1},{20,14,1},{21,14,1},{22,14,1},{23,14,1}
+,{24,14,1},{25,14,1},{26,14,1},{27,14,1},{28,14,1},{29,14,1},{30,14,1},{31,14,1}
+,{32,14,1},{33,14,1},{34,14,1},{35,14,1},{36,14,1},{37,14,1},{38,14,1},{39,14,1}
+,{40,14,1},{41,14,1},{42,14,1},{43,14,1},{44,14,1},{45,14,1},{46,14,1},{47,14,1}
+,{48,14,1},{49,14,1},{50,14,1},{-1,14,1},{-2,14,1},{-3,14,1},{-4,14,1},{-5,14,1}
+,{-6,14,1},{-7,14,1},{-8,14,1},{-9,14,1},{-10,14,1},{-11,14,1},{-12,14,1},{-13,14,1}
+,{-14,14,1},{-15,14,1},{-16,14,1},{-17,14,1},{-18,14,1},{-24,14,1},{-25,14,1},{0,15,1}
+,{1,15,1},{2,15,1},{3,15,1},{4,15,1},{5,15,1},{6,15,1},{7,15,1},{8,15,1}
+,{9,15,1},{10,15,1},{11,15,1},{12,15,1},{13,15,1},{14,15,1},{15,15,1},{16,15,1}
+,{17,15,1},{18,15,1},{19,15,1},{20,15,1},{21,15,1},{22,15,1},{23,15,1},{24,15,1}
+,{25,15,1},{26,15,1},{27,15,1},{28,15,1},{29,15,1},{30,15,1},{31,15,1},{32,15,1}
+,{33,15,1},{34,15,1},{35,15,1},{36,15,1},{37,15,1},{38,15,1},{39,15,1},{40,15,1}
+,{41,15,1},{42,15,1},{43,15,1},{44,15,1},{45,15,1},{46,15,1},{47,15,1},{48,15,1}
+,{49,15,1},{50,15,1},{51,15,1},{52,15,1},{-1,15,1},{-2,15,1},{-3,15,1},{-4,15,1}
+,{-5,15,1},{-6,15,1},{-7,15,1},{-8,15,1},{-9,15,1},{-10,15,1},{-11,15,1},{-12,15,1}
+,{-13,15,1},{-14,15,1},{-15,15,1},{-16,15,1},{-17,15,1},{-18,15,1},{-23,15,1},{-24,15,1}
+,{-25,15,1},{0,16,1},{1,16,1},{2,16,1},{3,16,1},{4,16,1},{5,16,1},{6,16,1}
+,{7,16,1},{8,16,1},{9,16,1},{10,16,1},{11,16,1},{12,16,1},{13,16,1},{14,16,1}
+,{15,16,1},{16,16,1},{17,16,1},{18,16,1},{19,16,1},{20,16,1},{21,16,1},{22,16,1}
+,{23,16,1},{24,16,1},{25,16,1},{26,16,1},{27,16,1},{28,16,1},{29,16,1},{30,16,1}
+,{31,16,1},{32,16,1},{33,16,1},{34,16,1},{35,16,1},{36,16,1},{37,16,1},{38,16,1}
+,{39,16,1},{40,16,1},{41,16,1},{42,16,1},{43,16,1},{44,16,1},{45,16,1},{46,16,1}
+,{47,16,1},{48,16,1},{49,16,1},{50,16,1},{51,16,1},{52,16,1},{53,16,1},{54,16,1}
+,{55,16,1},{-1,16,1},{-2,16,1},{-3,16,1},{-4,16,1},{-5,16,1},{-6,16,1},{-7,16,1}
+,{-8,16,1},{-9,16,1},{-10,16,1},{-11,16,1},{-12,16,1},{-13,16,1},{-14,16,1},{-15,16,1}
+,{-16,16,1},{-17,16,1},{-23,16,1},{-25,16,1},{-26,16,1},{0,17,1},{1,17,1},{2,17,1}
+,{3,17,1},{4,17,1},{5,17,1},{6,17,1},{7,17,1},{8,17,1},{9,17,1},{10,17,1}
+,{11,17,1},{12,17,1},{13,17,1},{14,17,1},{15,17,1},{16,17,1},{17,17,1},{18,17,1}
+,{19,17,1},{20,17,1},{21,17,1},{22,17,1},{23,17,1},{24,17,1},{25,17,1},{26,17,1}
+,{27,17,1},{28,17,1},{29,17,1},{30,17,1},{31,17,1},{32,17,1},{33,17,1},{34,17,1}
+,{35,17,1},{36,17,1},{37,17,1},{38,17,1},{39,17,1},{41,17,1},{42,17,1},{43,17,1}
+,{44,17,1},{45,17,1},{46,17,1},{47,17,1},{48,17,1},{49,17,1},{50,17,1},{51,17,1}
+,{52,17,1},{53,17,1},{54,17,1},{55,17,1},{56,17,1},{-1,17,1},{-2,17,1},{-3,17,1}
+,{-4,17,1},{-5,17,1},{-6,17,1},{-7,17,1},{-8,17,1},{-9,17,1},{-10,17,1},{-11,17,1}
+,{-12,17,1},{-13,17,1},{-14,17,1},{-15,17,1},{-16,17,1},{-17,17,1},{-25,17,1},{-26,17,1}
+,{0,18,1},{1,18,1},{2,18,1},{3,18,1},{4,18,1},{5,18,1},{6,18,1},{7,18,1}
+,{8,18,1},{9,18,1},{10,18,1},{11,18,1},{12,18,1},{13,18,1},{14,18,1},{15,18,1}
+,{16,18,1},{17,18,1},{18,18,1},{19,18,1},{20,18,1},{21,18,1},{22,18,1},{23,18,1}
+,{24,18,1},{25,18,1},{26,18,1},{27,18,1},{28,18,1},{29,18,1},{30,18,1},{31,18,1}
+,{32,18,1},{33,18,1},{34,18,1},{35,18,1},{36,18,1},{37,18,1},{38,18,1},{40,18,1}
+,{41,18,1},{42,18,1},{43,18,1},{44,18,1},{45,18,1},{46,18,1},{47,18,1},{48,18,1}
+,{49,18,1},{50,18,1},{51,18,1},{52,18,1},{53,18,1},{54,18,1},{55,18,1},{56,18,1}
+,{57,18,1},{-1,18,1},{-2,18,1},{-3,18,1},{-4,18,1},{-5,18,1},{-6,18,1},{-7,18,1}
+,{-8,18,1},{-9,18,1},{-10,18,1},{-11,18,1},{-12,18,1},{-13,18,1},{-14,18,1},{-15,18,1}
+,{-16,18,1},{-17,18,1},{0,19,1},{1,19,1},{2,19,1},{3,19,1},{4,19,1},{5,19,1}
+,{6,19,1},{7,19,1},{8,19,1},{9,19,1},{10,19,1},{11,19,1},{12,19,1},{13,19,1}
+,{14,19,1},{15,19,1},{16,19,1},{17,19,1},{18,19,1},{19,19,1},{20,19,1},{21,19,1}
+,{22,19,1},{23,19,1},{24,19,1},{25,19,1},{26,19,1},{27,19,1},{28,19,1},{29,19,1}
+,{30,19,1},{31,19,1},{32,19,1},{33,19,1},{34,19,1},{35,19,1},{36,19,1},{37,19,1}
+,{38,19,1},{39,19,1},{40,19,1},{41,19,1},{42,19,1},{43,19,1},{44,19,1},{45,19,1}
+,{46,19,1},{47,19,1},{48,19,1},{49,19,1},{50,19,1},{51,19,1},{52,19,1},{53,19,1}
+,{54,19,1},{55,19,1},{56,19,1},{57,19,1},{-1,19,1},{-2,19,1},{-3,19,1},{-4,19,1}
+,{-5,19,1},{-6,19,1},{-7,19,1},{-8,19,1},{-9,19,1},{-10,19,1},{-11,19,1},{-12,19,1}
+,{-13,19,1},{-14,19,1},{-15,19,1},{-16,19,1},{-17,19,1},{0,20,1},{1,20,1},{2,20,1}
+,{3,20,1},{4,20,1},{5,20,1},{6,20,1},{7,20,1},{8,20,1},{9,20,1},{10,20,1}
+,{11,20,1},{12,20,1},{13,20,1},{14,20,1},{15,20,1},{16,20,1},{17,20,1},{18,20,1}
+,{19,20,1},{20,20,1},{21,20,1},{22,20,1},{23,20,1},{24,20,1},{25,20,1},{26,20,1}
+,{27,20,1},{28,20,1},{29,20,1},{30,20,1},{31,20,1},{32,20,1},{33,20,1},{34,20,1}
+,{35,20,1},{36,20,1},{37,20,1},{39,20,1},{40,20,1},{41,20,1},{42,20,1},{43,20,1}
+,{44,20,1},{45,20,1},{46,20,1},{47,20,1},{48,20,1},{49,20,1},{50,20,1},{51,20,1}
+,{52,20,1},{53,20,1},{54,20,1},{55,20,1},{56,20,1},{57,20,1},{58,20,1},{-1,20,1}
+,{-2,20,1},{-3,20,1},{-4,20,1},{-5,20,1},{-6,20,1},{-7,20,1},{-8,20,1},{-9,20,1}
+,{-10,20,1},{-11,20,1},{-12,20,1},{-13,20,1},{-14,20,1},{-15,20,1},{-16,20,1},{-17,20,1}
+,{-18,20,1},{0,21,1},{1,21,1},{2,21,1},{3,21,1},{4,21,1},{5,21,1},{6,21,1}
+,{7,21,1},{8,21,1},{9,21,1},{10,21,1},{11,21,1},{12,21,1},{13,21,1},{14,21,1}
+,{15,21,1},{16,21,1},{17,21,1},{18,21,1},{19,21,1},{20,21,1},{21,21,1},{22,21,1}
+,{23,21,1},{24,21,1},{25,21,1},{26,21,1},{27,21,1},{28,21,1},{29,21,1},{30,21,1}
+,{31,21,1},{32,21,1},{33,21,1},{34,21,1},{35,21,1},{36,21,1},{37,21,1},{38,21,1}
+,{39,21,1},{40,21,1},{41,21,1},{42,21,1},{43,21,1},{44,21,1},{45,21,1},{46,21,1}
+,{47,21,1},{48,21,1},{49,21,1},{50,21,1},{51,21,1},{52,21,1},{53,21,1},{54,21,1}
+,{55,21,1},{56,21,1},{57,21,1},{58,21,1},{59,21,1},{-1,21,1},{-2,21,1},{-3,21,1}
+,{-4,21,1},{-5,21,1},{-6,21,1},{-7,21,1},{-8,21,1},{-9,21,1},{-10,21,1},{-11,21,1}
+,{-12,21,1},{-13,21,1},{-14,21,1},{-15,21,1},{-16,21,1},{-17,21,1},{-18,21,1},{0,22,1}
+,{1,22,1},{2,22,1},{3,22,1},{4,22,1},{5,22,1},{6,22,1},{7,22,1},{8,22,1}
+,{9,22,1},{10,22,1},{11,22,1},{12,22,1},{13,22,1},{14,22,1},{15,22,1},{16,22,1}
+,{17,22,1},{18,22,1},{19,22,1},{20,22,1},{21,22,1},{22,22,1},{23,22,1},{24,22,1}
+,{25,22,1},{26,22,1},{27,22,1},{28,22,1},{29,22,1},{30,22,1},{31,22,1},{32,22,1}
+,{33,22,1},{34,22,1},{35,22,1},{36,22,1},{38,22,1},{39,22,1},{40,22,1},{41,22,1}
+,{42,22,1},{43,22,1},{44,22,1},{45,22,1},{46,22,1},{47,22,1},{48,22,1},{49,22,1}
+,{50,22,1},{51,22,1},{52,22,1},{53,22,1},{54,22,1},{55,22,1},{56,22,1},{57,22,1}
+,{58,22,1},{59,22,1},{-1,22,1},{-2,22,1},{-3,22,1},{-4,22,1},{-5,22,1},{-6,22,1}
+,{-7,22,1},{-8,22,1},{-9,22,1},{-10,22,1},{-11,22,1},{-12,22,1},{-13,22,1},{-14,22,1}
+,{-15,22,1},{-16,22,1},{-17,22,1},{0,23,1},{1,23,1},{2,23,1},{3,23,1},{4,23,1}
+,{5,23,1},{6,23,1},{7,23,1},{8,23,1},{9,23,1},{10,23,1},{11,23,1},{12,23,1}
+,{13,23,1},{14,23,1},{15,23,1},{16,23,1},{17,23,1},{18,23,1},{19,23,1},{20,23,1}
+,{21,23,1},{22,23,1},{23,23,1},{24,23,1},{25,23,1},{26,23,1},{27,23,1},{28,23,1}
+,{29,23,1},{30,23,1},{31,23,1},{32,23,1},{33,23,1},{34,23,1},{35,23,1},{36,23,1}
+,{38,23,1},{39,23,1},{40,23,1},{41,23,1},{42,23,1},{43,23,1},{44,23,1},{45,23,1}
+,{46,23,1},{47,23,1},{48,23,1},{49,23,1},{50,23,1},{51,23,1},{52,23,1},{53,23,1}
+,{54,23,1},{55,23,1},{56,23,1},{57,23,1},{58,23,1},{59,23,1},{-1,23,1},{-2,23,1}
+,{-3,23,1},{-4,23,1},{-5,23,1},{-6,23,1},{-7,23,1},{-8,23,1},{-9,23,1},{-10,23,1}
+,{-11,23,1},{-12,23,1},{-13,23,1},{-14,23,1},{-15,23,1},{-16,23,1},{-17,23,1},{0,24,1}
+,{1,24,1},{2,24,1},{3,24,1},{4,24,1},{5,24,1},{6,24,1},{7,24,1},{8,24,1}
+,{9,24,1},{10,24,1},{11,24,1},{12,24,1},{13,24,1},{14,24,1},{15,24,1},{16,24,1}
+,{17,24,1},{18,24,1},{19,24,1},{20,24,1},{21,24,1},{22,24,1},{23,24,1},{24,24,1}
+,{25,24,1},{26,24,1},{27,24,1},{28,24,1},{29,24,1},{30,24,1},{31,24,1},{32,24,1}
+,{33,24,1},{34,24,1},{35,24,1},{37,24,1},{38,24,1},{39,24,1},{40,24,1},{41,24,1}
+,{42,24,1},{43,24,1},{44,24,1},{45,24,1},{46,24,1},{47,24,1},{48,24,1},{49,24,1}
+,{50,24,1},{51,24,1},{52,24,1},{53,24,1},{54,24,1},{55,24,1},{56,24,1},{57,24,1}
+,{-1,24,1},{-2,24,1},{-3,24,1},{-4,24,1},{-5,24,1},{-6,24,1},{-7,24,1},{-8,24,1}
+,{-9,24,1},{-10,24,1},{-11,24,1},{-12,24,1},{-13,24,1},{-14,24,1},{-15,24,1},{-16,24,1}
+,{0,25,1},{1,25,1},{2,25,1},{3,25,1},{4,25,1},{5,25,1},{6,25,1},{7,25,1}
+,{8,25,1},{9,25,1},{10,25,1},{11,25,1},{12,25,1},{13,25,1},{14,25,1},{15,25,1}
+,{16,25,1},{17,25,1},{18,25,1},{19,25,1},{20,25,1},{21,25,1},{22,25,1},{23,25,1}
+,{24,25,1},{25,25,1},{26,25,1},{27,25,1},{28,25,1},{29,25,1},{30,25,1},{31,25,1}
+,{32,25,1},{33,25,1},{34,25,1},{36,25,1},{37,25,1},{38,25,1},{39,25,1},{40,25,1}
+,{41,25,1},{42,25,1},{43,25,1},{44,25,1},{45,25,1},{46,25,1},{47,25,1},{48,25,1}
+,{49,25,1},{50,25,1},{51,25,1},{52,25,1},{54,25,1},{55,25,1},{56,25,1},{57,25,1}
+,{58,25,1},{59,25,1},{-1,25,1},{-2,25,1},{-3,25,1},{-4,25,1},{-5,25,1},{-6,25,1}
+,{-7,25,1},{-8,25,1},{-9,25,1},{-10,25,1},{-11,25,1},{-12,25,1},{-13,25,1},{-14,25,1}
+,{-15,25,1},{0,26,1},{1,26,1},{2,26,1},{3,26,1},{4,26,1},{5,26,1},{6,26,1}
+,{7,26,1},{8,26,1},{9,26,1},{10,26,1},{11,26,1},{12,26,1},{13,26,1},{14,26,1}
+,{15,26,1},{16,26,1},{17,26,1},{18,26,1},{19,26,1},{20,26,1},{21,26,1},{22,26,1}
+,{23,26,1},{24,26,1},{25,26,1},{26,26,1},{27,26,1},{28,26,1},{29,26,1},{30,26,1}
+,{31,26,1},{32,26,1},{33,26,1},{34,26,1},{35,26,1},{36,26,1},{37,26,1},{38,26,1}
+,{39,26,1},{40,26,1},{41,26,1},{42,26,1},{43,26,1},{44,26,1},{45,26,1},{46,26,1}
+,{47,26,1},{48,26,1},{49,26,1},{50,26,1},{51,26,1},{53,26,1},{54,26,1},{55,26,1}
+,{56,26,1},{57,26,1},{58,26,1},{59,26,1},{-1,26,1},{-2,26,1},{-3,26,1},{-4,26,1}
+,{-5,26,1},{-6,26,1},{-7,26,1},{-8,26,1},{-9,26,1},{-10,26,1},{-11,26,1},{-12,26,1}
+,{-13,26,1},{-14,26,1},{-15,26,1},{0,27,1},{1,27,1},{2,27,1},{3,27,1},{4,27,1}
+,{5,27,1},{6,27,1},{7,27,1},{8,27,1},{9,27,1},{10,27,1},{11,27,1},{12,27,1}
+,{13,27,1},{14,27,1},{15,27,1},{16,27,1},{17,27,1},{18,27,1},{19,27,1},{20,27,1}
+,{21,27,1},{22,27,1},{23,27,1},{24,27,1},{25,27,1},{26,27,1},{27,27,1},{28,27,1}
+,{29,27,1},{30,27,1},{31,27,1},{32,27,1},{33,27,1},{34,27,1},{35,27,1},{36,27,1}
+,{37,27,1},{38,27,1},{39,27,1},{40,27,1},{41,27,1},{42,27,1},{43,27,1},{44,27,1}
+,{45,27,1},{46,27,1},{47,27,1},{48,27,1},{49,27,1},{50,27,1},{51,27,1},{52,27,1}
+,{53,27,1},{54,27,1},{55,27,1},{56,27,1},{57,27,1},{58,27,1},{59,27,1},{-1,27,1}
+,{-2,27,1},{-3,27,1},{-4,27,1},{-5,27,1},{-6,27,1},{-7,27,1},{-8,27,1},{-9,27,1}
+,{-10,27,1},{-11,27,1},{-12,27,1},{-13,27,1},{-14,27,1},{-16,27,1},{-17,27,1},{-18,27,1}
+,{-19,27,1},{0,28,1},{1,28,1},{2,28,1},{3,28,1},{4,28,1},{5,28,1},{6,28,1}
+,{7,28,1},{8,28,1},{9,28,1},{10,28,1},{11,28,1},{12,28,1},{13,28,1},{14,28,1}
+,{15,28,1},{16,28,1},{17,28,1},{18,28,1},{19,28,1},{20,28,1},{21,28,1},{22,28,1}
+,{23,28,1},{24,28,1},{25,28,1},{26,28,1},{27,28,1},{28,28,1},{29,28,1},{30,28,1}
+,{31,28,1},{32,28,1},{33,28,1},{34,28,1},{35,28,1},{36,28,1},{37,28,1},{38,28,1}
+,{39,28,1},{40,28,1},{41,28,1},{42,28,1},{43,28,1},{44,28,1},{45,28,1},{46,28,1}
+,{47,28,1},{48,28,1},{50,28,1},{51,28,1},{52,28,1},{53,28,1},{54,28,1},{55,28,1}
+,{56,28,1},{57,28,1},{58,28,1},{59,28,1},{-1,28,1},{-2,28,1},{-3,28,1},{-4,28,1}
+,{-5,28,1},{-6,28,1},{-7,28,1},{-8,28,1},{-9,28,1},{-10,28,1},{-11,28,1},{-12,28,1}
+,{-13,28,1},{-14,28,1},{-15,28,1},{-16,28,1},{-17,28,1},{-18,28,1},{-19,28,1},{0,29,1}
+,{1,29,1},{2,29,1},{3,29,1},{4,29,1},{5,29,1},{6,29,1},{7,29,1},{8,29,1}
+,{9,29,1},{10,29,1},{11,29,1},{12,29,1},{13,29,1},{14,29,1},{15,29,1},{16,29,1}
+,{17,29,1},{18,29,1},{19,29,1},{20,29,1},{21,29,1},{22,29,1},{23,29,1},{24,29,1}
+,{25,29,1},{26,29,1},{27,29,1},{28,29,1},{29,29,1},{30,29,1},{31,29,1},{32,29,1}
+,{33,29,1},{34,29,1},{35,29,1},{36,29,1},{37,29,1},{38,29,1},{39,29,1},{40,29,1}
+,{41,29,1},{42,29,1},{43,29,1},{44,29,1},{45,29,1},{46,29,1},{47,29,1},{48,29,1}
+,{49,29,1},{50,29,1},{51,29,1},{52,29,1},{53,29,1},{54,29,1},{55,29,1},{56,29,1}
+,{57,29,1},{58,29,1},{59,29,1},{-1,29,1},{-2,29,1},{-3,29,1},{-4,29,1},{-5,29,1}
+,{-6,29,1},{-7,29,1},{-8,29,1},{-9,29,1},{-10,29,1},{-11,29,1},{-14,29,1},{0,30,1}
+,{1,30,1},{2,30,1},{3,30,1},{4,30,1},{5,30,1},{6,30,1},{7,30,1},{8,30,1}
+,{9,30,1},{10,30,1},{11,30,1},{12,30,1},{13,30,1},{14,30,1},{15,30,1},{16,30,1}
+,{17,30,1},{18,30,1},{19,30,1},{20,30,1},{21,30,1},{22,30,1},{23,30,1},{24,30,1}
+,{25,30,1},{26,30,1},{27,30,1},{28,30,1},{29,30,1},{30,30,1},{31,30,1},{32,30,1}
+,{33,30,1},{34,30,1},{35,30,1},{36,30,1},{37,30,1},{38,30,1},{39,30,1},{40,30,1}
+,{41,30,1},{42,30,1},{43,30,1},{44,30,1},{45,30,1},{46,30,1},{47,30,1},{48,30,1}
+,{49,30,1},{50,30,1},{51,30,1},{52,30,1},{53,30,1},{54,30,1},{55,30,1},{56,30,1}
+,{57,30,1},{58,30,1},{59,30,1},{-1,30,1},{-2,30,1},{-3,30,1},{-4,30,1},{-5,30,1}
+,{-6,30,1},{-7,30,1},{-8,30,1},{-9,30,1},{-10,30,1},{-16,30,1},{-17,30,1},{0,31,1}
+,{1,31,1},{2,31,1},{3,31,1},{4,31,1},{5,31,1},{6,31,1},{7,31,1},{8,31,1}
+,{9,31,1},{10,31,1},{11,31,1},{12,31,1},{13,31,1},{14,31,1},{15,31,1},{16,31,1}
+,{17,31,1},{19,31,1},{20,31,1},{21,31,1},{22,31,1},{23,31,1},{24,31,1},{25,31,1}
+,{26,31,1},{27,31,1},{28,31,1},{29,31,1},{30,31,1},{31,31,1},{32,31,1},{33,31,1}
+,{34,31,1},{35,31,1},{36,31,1},{37,31,1},{38,31,1},{39,31,1},{40,31,1},{41,31,1}
+,{42,31,1},{43,31,1},{44,31,1},{45,31,1},{46,31,1},{47,31,1},{48,31,1},{49,31,1}
+,{50,31,1},{51,31,1},{52,31,1},{53,31,1},{54,31,1},{55,31,1},{56,31,1},{57,31,1}
+,{58,31,1},{59,31,1},{-1,31,1},{-2,31,1},{-3,31,1},{-4,31,1},{-5,31,1},{-6,31,1}
+,{-7,31,1},{-8,31,1},{-9,31,1},{-10,31,1},{0,32,1},{1,32,1},{2,32,1},{3,32,1}
+,{4,32,1},{5,32,1},{6,32,1},{7,32,1},{8,32,1},{9,32,1},{10,32,1},{11,32,1}
+,{12,32,1},{13,32,1},{14,32,1},{15,32,1},{19,32,1},{20,32,1},{21,32,1},{22,32,1}
+,{23,32,1},{24,32,1},{34,32,1},{35,32,1},{36,32,1},{37,32,1},{38,32,1},{39,32,1}
+,{40,32,1},{41,32,1},{42,32,1},{43,32,1},{44,32,1},{45,32,1},{46,32,1},{47,32,1}
+,{48,32,1},{49,32,1},{50,32,1},{51,32,1},{52,32,1},{53,32,1},{54,32,1},{55,32,1}
+,{56,32,1},{57,32,1},{58,32,1},{59,32,1},{-1,32,1},{-2,32,1},{-3,32,1},{-4,32,1}
+,{-5,32,1},{-6,32,1},{-7,32,1},{-8,32,1},{-9,32,1},{-10,32,1},{-17,32,1},{-18,32,1}
+,{0,33,1},{1,33,1},{2,33,1},{3,33,1},{4,33,1},{5,33,1},{6,33,1},{7,33,1}
+,{8,33,1},{9,33,1},{10,33,1},{11,33,1},{35,33,1},{36,33,1},{37,33,1},{38,33,1}
+,{39,33,1},{40,33,1},{41,33,1},{42,33,1},{43,33,1},{44,33,1},{45,33,1},{46,33,1}
+,{47,33,1},{48,33,1},{49,33,1},{50,33,1},{51,33,1},{52,33,1},{53,33,1},{54,33,1}
+,{55,33,1},{56,33,1},{57,33,1},{58,33,1},{59,33,1},{-1,33,1},{-2,33,1},{-3,33,1}
+,{-4,33,1},{-5,33,1},{-6,33,1},{-7,33,1},{-8,33,1},{-9,33,1},{-17,33,1},{0,34,1}
+,{1,34,1},{2,34,1},{3,34,1},{4,34,1},{5,34,1},{6,34,1},{7,34,1},{8,34,1}
+,{9,34,1},{10,34,1},{11,34,1},{23,34,1},{24,34,1},{25,34,1},{26,34,1},{32,34,1}
+,{33,34,1},{34,34,1},{35,34,1},{36,34,1},{37,34,1},{38,34,1},{39,34,1},{40,34,1}
+,{41,34,1},{42,34,1},{43,34,1},{44,34,1},{45,34,1},{46,34,1},{47,34,1},{48,34,1}
+,{49,34,1},{50,34,1},{51,34,1},{52,34,1},{53,34,1},{54,34,1},{55,34,1},{56,34,1}
+,{57,34,1},{58,34,1},{59,34,1},{-1,34,1},{-2,34,1},{-3,34,1},{-4,34,1},{-5,34,1}
+,{-6,34,1},{-7,34,1},{-26,36,1},{-25,37,1},{-26,37,1},{-28,38,1},{-29,38,1},{-28,39,1}
+,{-29,39,1},{-32,39,1},{6,-1,1},{8,-1,1},{9,-1,1},{10,-1,1},{11,-1,1},{12,-1,1}
+,{13,-1,1},{14,-1,1},{15,-1,1},{16,-1,1},{17,-1,1},{18,-1,1},{19,-1,1},{20,-1,1}
+,{21,-1,1},{22,-1,1},{23,-1,1},{24,-1,1},{25,-1,1},{26,-1,1},{27,-1,1},{28,-1,1}
+,{29,-1,1},{30,-1,1},{31,-1,1},{32,-1,1},{33,-1,1},{34,-1,1},{35,-1,1},{36,-1,1}
+,{37,-1,1},{38,-1,1},{39,-1,1},{40,-1,1},{41,-1,1},{42,-1,1},{5,-2,1},{8,-2,1}
+,{9,-2,1},{10,-2,1},{11,-2,1},{12,-2,1},{13,-2,1},{14,-2,1},{15,-2,1},{16,-2,1}
+,{17,-2,1},{18,-2,1},{19,-2,1},{20,-2,1},{21,-2,1},{22,-2,1},{23,-2,1},{24,-2,1}
+,{25,-2,1},{26,-2,1},{27,-2,1},{28,-2,1},{29,-2,1},{30,-2,1},{31,-2,1},{32,-2,1}
+,{33,-2,1},{34,-2,1},{35,-2,1},{36,-2,1},{37,-2,1},{38,-2,1},{39,-2,1},{40,-2,1}
+,{41,-2,1},{42,-2,1},{9,-3,1},{10,-3,1},{11,-3,1},{12,-3,1},{13,-3,1},{14,-3,1}
+,{15,-3,1},{16,-3,1},{17,-3,1},{18,-3,1},{19,-3,1},{20,-3,1},{21,-3,1},{22,-3,1}
+,{23,-3,1},{24,-3,1},{25,-3,1},{26,-3,1},{27,-3,1},{28,-3,1},{29,-3,1},{30,-3,1}
+,{31,-3,1},{32,-3,1},{33,-3,1},{34,-3,1},{35,-3,1},{36,-3,1},{37,-3,1},{38,-3,1}
+,{39,-3,1},{40,-3,1},{41,-3,1},{10,-4,1},{11,-4,1},{12,-4,1},{13,-4,1},{14,-4,1}
+,{15,-4,1},{16,-4,1},{17,-4,1},{18,-4,1},{19,-4,1},{20,-4,1},{21,-4,1},{22,-4,1}
+,{23,-4,1},{24,-4,1},{25,-4,1},{26,-4,1},{27,-4,1},{28,-4,1},{29,-4,1},{30,-4,1}
+,{31,-4,1},{32,-4,1},{33,-4,1},{34,-4,1},{35,-4,1},{36,-4,1},{37,-4,1},{38,-4,1}
+,{39,-4,1},{40,-4,1},{55,-4,1},{11,-5,1},{12,-5,1},{13,-5,1},{14,-5,1},{15,-5,1}
+,{16,-5,1},{17,-5,1},{18,-5,1},{19,-5,1},{20,-5,1},{21,-5,1},{22,-5,1},{23,-5,1}
+,{24,-5,1},{25,-5,1},{26,-5,1},{27,-5,1},{28,-5,1},{29,-5,1},{30,-5,1},{31,-5,1}
+,{32,-5,1},{33,-5,1},{34,-5,1},{35,-5,1},{36,-5,1},{37,-5,1},{38,-5,1},{39,-5,1}
+,{53,-5,1},{55,-5,1},{11,-6,1},{12,-6,1},{13,-6,1},{14,-6,1},{15,-6,1},{16,-6,1}
+,{17,-6,1},{18,-6,1},{19,-6,1},{20,-6,1},{21,-6,1},{22,-6,1},{23,-6,1},{24,-6,1}
+,{25,-6,1},{26,-6,1},{27,-6,1},{28,-6,1},{29,-6,1},{30,-6,1},{31,-6,1},{32,-6,1}
+,{33,-6,1},{34,-6,1},{35,-6,1},{36,-6,1},{37,-6,1},{38,-6,1},{39,-6,1},{53,-6,1}
+,{55,-6,1},{12,-7,1},{13,-7,1},{14,-7,1},{15,-7,1},{16,-7,1},{17,-7,1},{18,-7,1}
+,{19,-7,1},{20,-7,1},{21,-7,1},{22,-7,1},{23,-7,1},{24,-7,1},{25,-7,1},{26,-7,1}
+,{27,-7,1},{28,-7,1},{29,-7,1},{30,-7,1},{31,-7,1},{32,-7,1},{33,-7,1},{34,-7,1}
+,{35,-7,1},{36,-7,1},{37,-7,1},{38,-7,1},{39,-7,1},{52,-7,1},{53,-7,1},{12,-8,1}
+,{13,-8,1},{14,-8,1},{15,-8,1},{16,-8,1},{17,-8,1},{18,-8,1},{19,-8,1},{20,-8,1}
+,{21,-8,1},{22,-8,1},{23,-8,1},{24,-8,1},{25,-8,1},{26,-8,1},{27,-8,1},{28,-8,1}
+,{29,-8,1},{30,-8,1},{31,-8,1},{32,-8,1},{33,-8,1},{34,-8,1},{35,-8,1},{36,-8,1}
+,{37,-8,1},{38,-8,1},{39,-8,1},{52,-8,1},{56,-8,1},{13,-9,1},{14,-9,1},{15,-9,1}
+,{16,-9,1},{17,-9,1},{18,-9,1},{19,-9,1},{20,-9,1},{21,-9,1},{22,-9,1},{23,-9,1}
+,{24,-9,1},{25,-9,1},{26,-9,1},{27,-9,1},{28,-9,1},{29,-9,1},{30,-9,1},{31,-9,1}
+,{32,-9,1},{33,-9,1},{34,-9,1},{35,-9,1},{36,-9,1},{37,-9,1},{38,-9,1},{39,-9,1}
+,{12,-10,1},{13,-10,1},{14,-10,1},{15,-10,1},{16,-10,1},{17,-10,1},{18,-10,1},{19,-10,1}
+,{20,-10,1},{21,-10,1},{22,-10,1},{23,-10,1},{24,-10,1},{25,-10,1},{26,-10,1},{27,-10,1}
+,{28,-10,1},{29,-10,1},{30,-10,1},{31,-10,1},{32,-10,1},{33,-10,1},{34,-10,1},{35,-10,1}
+,{36,-10,1},{37,-10,1},{38,-10,1},{39,-10,1},{46,-10,1},{47,-10,1},{50,-10,1},{51,-10,1}
+,{13,-11,1},{14,-11,1},{15,-11,1},{16,-11,1},{17,-11,1},{18,-11,1},{19,-11,1},{20,-11,1}
+,{21,-11,1},{22,-11,1},{23,-11,1},{24,-11,1},{25,-11,1},{26,-11,1},{27,-11,1},{28,-11,1}
+,{29,-11,1},{30,-11,1},{31,-11,1},{32,-11,1},{33,-11,1},{34,-11,1},{35,-11,1},{36,-11,1}
+,{37,-11,1},{38,-11,1},{39,-11,1},{40,-11,1},{47,-11,1},{51,-11,1},{56,-11,1},{13,-12,1}
+,{14,-12,1},{15,-12,1},{16,-12,1},{17,-12,1},{18,-12,1},{19,-12,1},{20,-12,1},{21,-12,1}
+,{22,-12,1},{23,-12,1},{24,-12,1},{25,-12,1},{26,-12,1},{27,-12,1},{28,-12,1},{29,-12,1}
+,{30,-12,1},{31,-12,1},{32,-12,1},{33,-12,1},{34,-12,1},{35,-12,1},{36,-12,1},{37,-12,1}
+,{38,-12,1},{39,-12,1},{40,-12,1},{43,-12,1},{47,-12,1},{49,-12,1},{12,-13,1},{13,-13,1}
+,{14,-13,1},{15,-13,1},{16,-13,1},{17,-13,1},{18,-13,1},{19,-13,1},{20,-13,1},{21,-13,1}
+,{22,-13,1},{23,-13,1},{24,-13,1},{25,-13,1},{26,-13,1},{27,-13,1},{28,-13,1},{29,-13,1}
+,{30,-13,1},{31,-13,1},{32,-13,1},{33,-13,1},{34,-13,1},{35,-13,1},{36,-13,1},{37,-13,1}
+,{38,-13,1},{39,-13,1},{40,-13,1},{43,-13,1},{44,-13,1},{45,-13,1},{48,-13,1},{49,-13,1}
+,{12,-14,1},{13,-14,1},{14,-14,1},{15,-14,1},{16,-14,1},{17,-14,1},{18,-14,1},{19,-14,1}
+,{20,-14,1},{21,-14,1},{22,-14,1},{23,-14,1},{24,-14,1},{25,-14,1},{26,-14,1},{27,-14,1}
+,{28,-14,1},{29,-14,1},{30,-14,1},{31,-14,1},{32,-14,1},{33,-14,1},{34,-14,1},{35,-14,1}
+,{36,-14,1},{37,-14,1},{38,-14,1},{39,-14,1},{40,-14,1},{45,-14,1},{47,-14,1},{48,-14,1}
+,{49,-14,1},{50,-14,1},{12,-15,1},{13,-15,1},{14,-15,1},{15,-15,1},{16,-15,1},{17,-15,1}
+,{18,-15,1},{19,-15,1},{20,-15,1},{21,-15,1},{22,-15,1},{23,-15,1},{24,-15,1},{25,-15,1}
+,{26,-15,1},{27,-15,1},{28,-15,1},{29,-15,1},{30,-15,1},{31,-15,1},{32,-15,1},{33,-15,1}
+,{34,-15,1},{35,-15,1},{36,-15,1},{37,-15,1},{38,-15,1},{39,-15,1},{40,-15,1},{47,-15,1}
+,{48,-15,1},{49,-15,1},{50,-15,1},{11,-16,1},{12,-16,1},{13,-16,1},{14,-16,1},{15,-16,1}
+,{16,-16,1},{17,-16,1},{18,-16,1},{19,-16,1},{20,-16,1},{21,-16,1},{22,-16,1},{23,-16,1}
+,{24,-16,1},{25,-16,1},{26,-16,1},{27,-16,1},{28,-16,1},{29,-16,1},{30,-16,1},{31,-16,1}
+,{32,-16,1},{33,-16,1},{34,-16,1},{35,-16,1},{36,-16,1},{37,-16,1},{38,-16,1},{39,-16,1}
+,{40,-16,1},{45,-16,1},{46,-16,1},{47,-16,1},{48,-16,1},{49,-16,1},{50,-16,1},{54,-16,1}
+,{11,-17,1},{12,-17,1},{13,-17,1},{14,-17,1},{15,-17,1},{16,-17,1},{17,-17,1},{18,-17,1}
+,{19,-17,1},{20,-17,1},{21,-17,1},{22,-17,1},{23,-17,1},{24,-17,1},{25,-17,1},{26,-17,1}
+,{27,-17,1},{28,-17,1},{29,-17,1},{30,-17,1},{31,-17,1},{32,-17,1},{33,-17,1},{34,-17,1}
+,{35,-17,1},{36,-17,1},{37,-17,1},{38,-17,1},{39,-17,1},{40,-17,1},{43,-17,1},{44,-17,1}
+,{45,-17,1},{46,-17,1},{47,-17,1},{48,-17,1},{49,-17,1},{50,-17,1},{59,-17,1},{11,-18,1}
+,{12,-18,1},{13,-18,1},{14,-18,1},{15,-18,1},{16,-18,1},{17,-18,1},{18,-18,1},{19,-18,1}
+,{20,-18,1},{21,-18,1},{22,-18,1},{23,-18,1},{24,-18,1},{25,-18,1},{26,-18,1},{27,-18,1}
+,{28,-18,1},{29,-18,1},{30,-18,1},{31,-18,1},{32,-18,1},{33,-18,1},{34,-18,1},{35,-18,1}
+,{36,-18,1},{37,-18,1},{38,-18,1},{39,-18,1},{42,-18,1},{43,-18,1},{44,-18,1},{45,-18,1}
+,{46,-18,1},{47,-18,1},{48,-18,1},{49,-18,1},{11,-19,1},{12,-19,1},{13,-19,1},{14,-19,1}
+,{15,-19,1},{16,-19,1},{17,-19,1},{18,-19,1},{19,-19,1},{20,-19,1},{21,-19,1},{22,-19,1}
+,{23,-19,1},{24,-19,1},{25,-19,1},{26,-19,1},{27,-19,1},{28,-19,1},{29,-19,1},{30,-19,1}
+,{31,-19,1},{32,-19,1},{33,-19,1},{34,-19,1},{35,-19,1},{36,-19,1},{37,-19,1},{43,-19,1}
+,{44,-19,1},{45,-19,1},{46,-19,1},{47,-19,1},{48,-19,1},{49,-19,1},{12,-20,1},{13,-20,1}
+,{14,-20,1},{15,-20,1},{16,-20,1},{17,-20,1},{18,-20,1},{19,-20,1},{20,-20,1},{21,-20,1}
+,{22,-20,1},{23,-20,1},{24,-20,1},{25,-20,1},{26,-20,1},{27,-20,1},{28,-20,1},{29,-20,1}
+,{30,-20,1},{31,-20,1},{32,-20,1},{33,-20,1},{34,-20,1},{35,-20,1},{44,-20,1},{45,-20,1}
+,{46,-20,1},{47,-20,1},{48,-20,1},{49,-20,1},{57,-20,1},{63,-20,1},{13,-21,1},{14,-21,1}
+,{15,-21,1},{16,-21,1},{17,-21,1},{18,-21,1},{19,-21,1},{20,-21,1},{21,-21,1},{22,-21,1}
+,{23,-21,1},{24,-21,1},{25,-21,1},{26,-21,1},{27,-21,1},{28,-21,1},{29,-21,1},{30,-21,1}
+,{31,-21,1},{32,-21,1},{33,-21,1},{34,-21,1},{35,-21,1},{43,-21,1},{44,-21,1},{45,-21,1}
+,{46,-21,1},{47,-21,1},{48,-21,1},{55,-21,1},{57,-21,1},{13,-22,1},{14,-22,1},{15,-22,1}
+,{16,-22,1},{17,-22,1},{18,-22,1},{19,-22,1},{20,-22,1},{21,-22,1},{22,-22,1},{23,-22,1}
+,{24,-22,1},{25,-22,1},{26,-22,1},{27,-22,1},{28,-22,1},{29,-22,1},{30,-22,1},{31,-22,1}
+,{32,-22,1},{33,-22,1},{34,-22,1},{35,-22,1},{43,-22,1},{44,-22,1},{45,-22,1},{46,-22,1}
+,{47,-22,1},{48,-22,1},{55,-22,1},{14,-23,1},{15,-23,1},{16,-23,1},{17,-23,1},{18,-23,1}
+,{19,-23,1},{20,-23,1},{21,-23,1},{22,-23,1},{23,-23,1},{24,-23,1},{25,-23,1},{26,-23,1}
+,{27,-23,1},{28,-23,1},{29,-23,1},{30,-23,1},{31,-23,1},{32,-23,1},{33,-23,1},{34,-23,1}
+,{35,-23,1},{40,-23,1},{43,-23,1},{44,-23,1},{45,-23,1},{46,-23,1},{47,-23,1},{48,-23,1}
+,{14,-24,1},{15,-24,1},{16,-24,1},{17,-24,1},{18,-24,1},{19,-24,1},{20,-24,1},{21,-24,1}
+,{22,-24,1},{23,-24,1},{24,-24,1},{25,-24,1},{26,-24,1},{27,-24,1},{28,-24,1},{29,-24,1}
+,{30,-24,1},{31,-24,1},{32,-24,1},{33,-24,1},{34,-24,1},{35,-24,1},{43,-24,1},{44,-24,1}
+,{45,-24,1},{46,-24,1},{47,-24,1},{14,-25,1},{15,-25,1},{16,-25,1},{17,-25,1},{18,-25,1}
+,{19,-25,1},{20,-25,1},{21,-25,1},{22,-25,1},{23,-25,1},{24,-25,1},{25,-25,1},{26,-25,1}
+,{27,-25,1},{28,-25,1},{29,-25,1},{30,-25,1},{31,-25,1},{32,-25,1},{33,-25,1},{34,-25,1}
+,{35,-25,1},{43,-25,1},{44,-25,1},{45,-25,1},{46,-25,1},{47,-25,1},{14,-26,1},{15,-26,1}
+,{16,-26,1},{17,-26,1},{18,-26,1},{19,-26,1},{20,-26,1},{21,-26,1},{22,-26,1},{23,-26,1}
+,{24,-26,1},{25,-26,1},{26,-26,1},{27,-26,1},{28,-26,1},{29,-26,1},{30,-26,1},{31,-26,1}
+,{32,-26,1},{33,-26,1},{34,-26,1},{44,-26,1},{45,-26,1},{46,-26,1},{47,-26,1},{14,-27,1}
+,{15,-27,1},{16,-27,1},{17,-27,1},{18,-27,1},{19,-27,1},{20,-27,1},{21,-27,1},{22,-27,1}
+,{23,-27,1},{24,-27,1},{25,-27,1},{26,-27,1},{27,-27,1},{28,-27,1},{29,-27,1},{30,-27,1}
+,{31,-27,1},{32,-27,1},{15,-28,1},{16,-28,1},{17,-28,1},{18,-28,1},{19,-28,1},{20,-28,1}
+,{21,-28,1},{22,-28,1},{23,-28,1},{24,-28,1},{25,-28,1},{26,-28,1},{27,-28,1},{28,-28,1}
+,{29,-28,1},{30,-28,1},{31,-28,1},{32,-28,1},{15,-29,1},{16,-29,1},{17,-29,1},{18,-29,1}
+,{19,-29,1},{20,-29,1},{21,-29,1},{22,-29,1},{23,-29,1},{24,-29,1},{25,-29,1},{26,-29,1}
+,{27,-29,1},{28,-29,1},{29,-29,1},{30,-29,1},{31,-29,1},{32,-29,1},{16,-30,1},{17,-30,1}
+,{18,-30,1},{19,-30,1},{20,-30,1},{21,-30,1},{22,-30,1},{23,-30,1},{24,-30,1},{25,-30,1}
+,{26,-30,1},{27,-30,1},{28,-30,1},{29,-30,1},{30,-30,1},{31,-30,1},{17,-31,1},{18,-31,1}
+,{19,-31,1},{20,-31,1},{21,-31,1},{22,-31,1},{23,-31,1},{24,-31,1},{25,-31,1},{26,-31,1}
+,{27,-31,1},{28,-31,1},{29,-31,1},{30,-31,1},{17,-32,1},{18,-32,1},{19,-32,1},{20,-32,1}
+,{21,-32,1},{22,-32,1},{23,-32,1},{24,-32,1},{25,-32,1},{26,-32,1},{27,-32,1},{28,-32,1}
+,{29,-32,1},{30,-32,1},{17,-33,1},{18,-33,1},{19,-33,1},{20,-33,1},{21,-33,1},{22,-33,1}
+,{23,-33,1},{24,-33,1},{25,-33,1},{26,-33,1},{27,-33,1},{28,-33,1},{29,-33,1},{17,-34,1}
+,{18,-34,1},{19,-34,1},{20,-34,1},{21,-34,1},{22,-34,1},{23,-34,1},{24,-34,1},{25,-34,1}
+,{26,-34,1},{27,-34,1},{18,-35,1},{19,-35,1},{20,-35,1},{21,-35,1},{22,-35,1},{23,-35,1}
+,{24,-35,1},{25,-35,1},{119,-11,2},{120,-11,2},{121,-11,2},{122,-11,2},{123,-11,2},{124,-11,2}
+,{132,-11,2},{133,-11,2},{141,-11,2},{142,-11,2},{143,-11,2},{147,-11,2},{148,-11,2},{149,-11,2}
+,{150,-11,2},{151,-11,2},{152,-11,2},{153,-11,2},{161,-11,2},{162,-11,2},{165,-11,2},{166,-11,2}
+,{179,-11,2},{-140,-11,2},{-151,-11,2},{-161,-11,2},{-162,-11,2},{-166,-11,2},{122,-12,2},{130,-12,2}
+,{131,-12,2},{132,-12,2},{133,-12,2},{134,-12,2},{135,-12,2},{136,-12,2},{141,-12,2},{142,-12,2}
+,{143,-12,2},{144,-12,2},{151,-12,2},{152,-12,2},{153,-12,2},{154,-12,2},{159,-12,2},{160,-12,2}
+,{166,-12,2},{169,-12,2},{170,-12,2},{-152,-12,2},{-166,-12,2},{-172,-12,2},{122,-13,2},{123,-13,2}
+,{130,-13,2},{131,-13,2},{132,-13,2},{133,-13,2},{134,-13,2},{135,-13,2},{136,-13,2},{141,-13,2}
+,{142,-13,2},{143,-13,2},{168,-13,2},{176,-13,2},{177,-13,2},{125,-14,2},{126,-14,2},{127,-14,2}
+,{129,-14,2},{130,-14,2},{131,-14,2},{132,-14,2},{133,-14,2},{134,-14,2},{135,-14,2},{136,-14,2}
+,{141,-14,2},{142,-14,2},{143,-14,2},{144,-14,2},{166,-14,2},{167,-14,2},{-164,-14,2},{-172,-14,2}
+,{-173,-14,2},{-177,-14,2},{121,-15,2},{123,-15,2},{124,-15,2},{125,-15,2},{126,-15,2},{127,-15,2}
+,{128,-15,2},{129,-15,2},{130,-15,2},{131,-15,2},{132,-15,2},{133,-15,2},{134,-15,2},{135,-15,2}
+,{136,-15,2},{141,-15,2},{142,-15,2},{143,-15,2},{144,-15,2},{145,-15,2},{166,-15,2},{167,-15,2}
+,{168,-15,2},{-139,-15,2},{-142,-15,2},{-145,-15,2},{-146,-15,2},{-147,-15,2},{-148,-15,2},{-149,-15,2}
+,{-169,-15,2},{-170,-15,2},{-171,-15,2},{-172,-15,2},{-178,-15,2},{-179,-15,2},{123,-16,2},{124,-16,2}
+,{125,-16,2},{126,-16,2},{127,-16,2},{128,-16,2},{129,-16,2},{130,-16,2},{131,-16,2},{132,-16,2}
+,{133,-16,2},{134,-16,2},{135,-16,2},{136,-16,2},{137,-16,2},{141,-16,2},{142,-16,2},{143,-16,2}
+,{144,-16,2},{145,-16,2},{166,-16,2},{167,-16,2},{168,-16,2},{-141,-16,2},{-143,-16,2},{-145,-16,2}
+,{-146,-16,2},{-147,-16,2},{-148,-16,2},{-149,-16,2},{-155,-16,2},{-174,-16,2},{-176,-16,2},{-180,-16,2}
+,{122,-17,2},{123,-17,2},{124,-17,2},{125,-17,2},{126,-17,2},{127,-17,2},{128,-17,2},{129,-17,2}
+,{130,-17,2},{131,-17,2},{132,-17,2},{133,-17,2},{134,-17,2},{135,-17,2},{136,-17,2},{137,-17,2}
+,{138,-17,2},{139,-17,2},{140,-17,2},{141,-17,2},{142,-17,2},{143,-17,2},{144,-17,2},{145,-17,2}
+,{146,-17,2},{149,-17,2},{150,-17,2},{167,-17,2},{168,-17,2},{177,-17,2},{178,-17,2},{179,-17,2}
+,{-141,-17,2},{-142,-17,2},{-143,-17,2},{-144,-17,2},{-145,-17,2},{-146,-17,2},{-147,-17,2},{-150,-17,2}
+,{-151,-17,2},{-152,-17,2},{-153,-17,2},{-154,-17,2},{-155,-17,2},{-180,-17,2},{118,-18,2},{119,-18,2}
+,{122,-18,2},{123,-18,2},{124,-18,2},{125,-18,2},{126,-18,2},{127,-18,2},{128,-18,2},{129,-18,2}
+,{130,-18,2},{131,-18,2},{132,-18,2},{133,-18,2},{134,-18,2},{135,-18,2},{136,-18,2},{137,-18,2}
+,{138,-18,2},{139,-18,2},{140,-18,2},{141,-18,2},{142,-18,2},{143,-18,2},{144,-18,2},{145,-18,2}
+,{146,-18,2},{148,-18,2},{155,-18,2},{168,-18,2},{176,-18,2},{177,-18,2},{178,-18,2},{179,-18,2}
+,{-139,-18,2},{-141,-18,2},{-142,-18,2},{-143,-18,2},{-144,-18,2},{-145,-18,2},{-146,-18,2},{-149,-18,2}
+,{-150,-18,2},{-151,-18,2},{-179,-18,2},{-180,-18,2},{121,-19,2},{122,-19,2},{123,-19,2},{124,-19,2}
+,{125,-19,2},{126,-19,2},{127,-19,2},{128,-19,2},{129,-19,2},{130,-19,2},{131,-19,2},{132,-19,2}
+,{133,-19,2},{134,-19,2},{135,-19,2},{136,-19,2},{137,-19,2},{138,-19,2},{139,-19,2},{140,-19,2}
+,{141,-19,2},{142,-19,2},{143,-19,2},{144,-19,2},{145,-19,2},{146,-19,2},{162,-19,2},{163,-19,2}
+,{168,-19,2},{169,-19,2},{177,-19,2},{178,-19,2},{179,-19,2},{-137,-19,2},{-138,-19,2},{-139,-19,2}
+,{-140,-19,2},{-141,-19,2},{-142,-19,2},{-143,-19,2},{-160,-19,2},{-164,-19,2},{-170,-19,2},{-174,-19,2}
+,{-175,-19,2},{-179,-19,2},{-180,-19,2},{118,-20,2},{119,-20,2},{120,-20,2},{121,-20,2},{122,-20,2}
+,{123,-20,2},{124,-20,2},{125,-20,2},{126,-20,2},{127,-20,2},{128,-20,2},{129,-20,2},{130,-20,2}
+,{131,-20,2},{132,-20,2},{133,-20,2},{134,-20,2},{135,-20,2},{136,-20,2},{137,-20,2},{138,-20,2}
+,{139,-20,2},{140,-20,2},{141,-20,2},{142,-20,2},{143,-20,2},{144,-20,2},{145,-20,2},{146,-20,2}
+,{147,-20,2},{148,-20,2},{158,-20,2},{163,-20,2},{169,-20,2},{170,-20,2},{177,-20,2},{178,-20,2}
+,{179,-20,2},{-139,-20,2},{-140,-20,2},{-141,-20,2},{-142,-20,2},{-145,-20,2},{-146,-20,2},{-158,-20,2}
+,{-159,-20,2},{-170,-20,2},{-175,-20,2},{-176,-20,2},{-179,-20,2},{-180,-20,2},{115,-21,2},{116,-21,2}
+,{117,-21,2},{118,-21,2},{119,-21,2},{120,-21,2},{121,-21,2},{122,-21,2},{123,-21,2},{124,-21,2}
+,{125,-21,2},{126,-21,2},{127,-21,2},{128,-21,2},{129,-21,2},{130,-21,2},{131,-21,2},{132,-21,2}
+,{133,-21,2},{134,-21,2},{135,-21,2},{136,-21,2},{137,-21,2},{138,-21,2},{139,-21,2},{140,-21,2}
+,{141,-21,2},{142,-21,2},{143,-21,2},{144,-21,2},{145,-21,2},{146,-21,2},{147,-21,2},{148,-21,2}
+,{149,-21,2},{150,-21,2},{154,-21,2},{163,-21,2},{164,-21,2},{165,-21,2},{166,-21,2},{167,-21,2}
+,{169,-21,2},{-139,-21,2},{-140,-21,2},{-144,-21,2},{-158,-21,2},{-159,-21,2},{-175,-21,2},{-176,-21,2}
+,{-179,-21,2},{113,-22,2},{114,-22,2},{115,-22,2},{116,-22,2},{117,-22,2},{118,-22,2},{119,-22,2}
+,{120,-22,2},{121,-22,2},{122,-22,2},{123,-22,2},{124,-22,2},{125,-22,2},{126,-22,2},{127,-22,2}
+,{128,-22,2},{129,-22,2},{130,-22,2},{131,-22,2},{132,-22,2},{133,-22,2},{134,-22,2},{135,-22,2}
+,{136,-22,2},{137,-22,2},{138,-22,2},{139,-22,2},{140,-22,2},{141,-22,2},{142,-22,2},{143,-22,2}
+,{144,-22,2},{145,-22,2},{146,-22,2},{147,-22,2},{148,-22,2},{149,-22,2},{150,-22,2},{151,-22,2}
+,{152,-22,2},{153,-22,2},{154,-22,2},{155,-22,2},{158,-22,2},{164,-22,2},{165,-22,2},{166,-22,2}
+,{167,-22,2},{168,-22,2},{-136,-22,2},{-137,-22,2},{-139,-22,2},{-140,-22,2},{-141,-22,2},{-155,-22,2}
+,{-158,-22,2},{-160,-22,2},{-175,-22,2},{-176,-22,2},{-179,-22,2},{113,-23,2},{114,-23,2},{115,-23,2}
+,{116,-23,2},{117,-23,2},{118,-23,2},{119,-23,2},{120,-23,2},{121,-23,2},{122,-23,2},{123,-23,2}
+,{124,-23,2},{125,-23,2},{126,-23,2},{127,-23,2},{128,-23,2},{129,-23,2},{130,-23,2},{131,-23,2}
+,{132,-23,2},{133,-23,2},{134,-23,2},{135,-23,2},{136,-23,2},{137,-23,2},{138,-23,2},{139,-23,2}
+,{140,-23,2},{141,-23,2},{142,-23,2},{143,-23,2},{144,-23,2},{145,-23,2},{146,-23,2},{147,-23,2}
+,{148,-23,2},{149,-23,2},{150,-23,2},{152,-23,2},{155,-23,2},{165,-23,2},{166,-23,2},{167,-23,2}
+,{168,-23,2},{171,-23,2},{172,-23,2},{-135,-23,2},{-137,-23,2},{-139,-23,2},{-152,-23,2},{-153,-23,2}
+,{-177,-23,2},{113,-24,2},{114,-24,2},{115,-24,2},{116,-24,2},{117,-24,2},{118,-24,2},{119,-24,2}
+,{120,-24,2},{121,-24,2},{122,-24,2},{123,-24,2},{124,-24,2},{125,-24,2},{126,-24,2},{127,-24,2}
+,{128,-24,2},{129,-24,2},{130,-24,2},{131,-24,2},{132,-24,2},{133,-24,2},{134,-24,2},{135,-24,2}
+,{136,-24,2},{137,-24,2},{138,-24,2},{139,-24,2},{140,-24,2},{141,-24,2},{142,-24,2},{143,-24,2}
+,{144,-24,2},{145,-24,2},{146,-24,2},{147,-24,2},{148,-24,2},{149,-24,2},{150,-24,2},{151,-24,2}
+,{152,-24,2},{155,-24,2},{-131,-24,2},{-135,-24,2},{-136,-24,2},{-138,-24,2},{-148,-24,2},{-150,-24,2}
+,{113,-25,2},{114,-25,2},{115,-25,2},{116,-25,2},{117,-25,2},{118,-25,2},{119,-25,2},{120,-25,2}
+,{121,-25,2},{122,-25,2},{123,-25,2},{124,-25,2},{125,-25,2},{126,-25,2},{127,-25,2},{128,-25,2}
+,{129,-25,2},{130,-25,2},{131,-25,2},{132,-25,2},{133,-25,2},{134,-25,2},{135,-25,2},{136,-25,2}
+,{137,-25,2},{138,-25,2},{139,-25,2},{140,-25,2},{141,-25,2},{142,-25,2},{143,-25,2},{144,-25,2}
+,{145,-25,2},{146,-25,2},{147,-25,2},{148,-25,2},{149,-25,2},{150,-25,2},{151,-25,2},{152,-25,2}
+,{153,-25,2},{-125,-25,2},{-129,-25,2},{112,-26,2},{113,-26,2},{114,-26,2},{115,-26,2},{116,-26,2}
+,{117,-26,2},{118,-26,2},{119,-26,2},{120,-26,2},{121,-26,2},{122,-26,2},{123,-26,2},{124,-26,2}
+,{125,-26,2},{126,-26,2},{127,-26,2},{128,-26,2},{129,-26,2},{130,-26,2},{131,-26,2},{132,-26,2}
+,{133,-26,2},{134,-26,2},{135,-26,2},{136,-26,2},{137,-26,2},{138,-26,2},{139,-26,2},{140,-26,2}
+,{141,-26,2},{142,-26,2},{143,-26,2},{144,-26,2},{145,-26,2},{146,-26,2},{147,-26,2},{148,-26,2}
+,{149,-26,2},{150,-26,2},{151,-26,2},{152,-26,2},{153,-26,2},{-131,-26,2},{113,-27,2},{114,-27,2}
+,{115,-27,2},{116,-27,2},{117,-27,2},{118,-27,2},{119,-27,2},{120,-27,2},{121,-27,2},{122,-27,2}
+,{123,-27,2},{124,-27,2},{125,-27,2},{126,-27,2},{127,-27,2},{128,-27,2},{129,-27,2},{130,-27,2}
+,{131,-27,2},{132,-27,2},{133,-27,2},{134,-27,2},{135,-27,2},{136,-27,2},{137,-27,2},{138,-27,2}
+,{139,-27,2},{140,-27,2},{141,-27,2},{142,-27,2},{143,-27,2},{144,-27,2},{145,-27,2},{146,-27,2}
+,{147,-27,2},{148,-27,2},{149,-27,2},{150,-27,2},{151,-27,2},{152,-27,2},{153,-27,2},{-106,-27,2}
+,{113,-28,2},{114,-28,2},{115,-28,2},{116,-28,2},{117,-28,2},{118,-28,2},{119,-28,2},{120,-28,2}
+,{121,-28,2},{122,-28,2},{123,-28,2},{124,-28,2},{125,-28,2},{126,-28,2},{127,-28,2},{128,-28,2}
+,{129,-28,2},{130,-28,2},{131,-28,2},{132,-28,2},{133,-28,2},{134,-28,2},{135,-28,2},{136,-28,2}
+,{137,-28,2},{138,-28,2},{139,-28,2},{140,-28,2},{141,-28,2},{142,-28,2},{143,-28,2},{144,-28,2}
+,{145,-28,2},{146,-28,2},{147,-28,2},{148,-28,2},{149,-28,2},{150,-28,2},{151,-28,2},{152,-28,2}
+,{153,-28,2},{-110,-28,2},{-144,-28,2},{-145,-28,2},{113,-29,2},{114,-29,2},{115,-29,2},{116,-29,2}
+,{117,-29,2},{118,-29,2},{119,-29,2},{120,-29,2},{121,-29,2},{122,-29,2},{123,-29,2},{124,-29,2}
+,{125,-29,2},{126,-29,2},{127,-29,2},{128,-29,2},{129,-29,2},{130,-29,2},{131,-29,2},{132,-29,2}
+,{133,-29,2},{134,-29,2},{135,-29,2},{136,-29,2},{137,-29,2},{138,-29,2},{139,-29,2},{140,-29,2}
+,{141,-29,2},{142,-29,2},{143,-29,2},{144,-29,2},{145,-29,2},{146,-29,2},{147,-29,2},{148,-29,2}
+,{149,-29,2},{150,-29,2},{151,-29,2},{152,-29,2},{153,-29,2},{114,-30,2},{115,-30,2},{116,-30,2}
+,{117,-30,2},{118,-30,2},{119,-30,2},{120,-30,2},{121,-30,2},{122,-30,2},{123,-30,2},{124,-30,2}
+,{125,-30,2},{126,-30,2},{127,-30,2},{128,-30,2},{129,-30,2},{130,-30,2},{131,-30,2},{132,-30,2}
+,{133,-30,2},{134,-30,2},{135,-30,2},{136,-30,2},{137,-30,2},{138,-30,2},{139,-30,2},{140,-30,2}
+,{141,-30,2},{142,-30,2},{143,-30,2},{144,-30,2},{145,-30,2},{146,-30,2},{147,-30,2},{148,-30,2}
+,{149,-30,2},{150,-30,2},{151,-30,2},{152,-30,2},{153,-30,2},{114,-31,2},{115,-31,2},{116,-31,2}
+,{117,-31,2},{118,-31,2},{119,-31,2},{120,-31,2},{121,-31,2},{122,-31,2},{123,-31,2},{124,-31,2}
+,{125,-31,2},{126,-31,2},{127,-31,2},{128,-31,2},{129,-31,2},{130,-31,2},{131,-31,2},{132,-31,2}
+,{133,-31,2},{134,-31,2},{135,-31,2},{136,-31,2},{137,-31,2},{138,-31,2},{139,-31,2},{140,-31,2}
+,{141,-31,2},{142,-31,2},{143,-31,2},{144,-31,2},{145,-31,2},{146,-31,2},{147,-31,2},{148,-31,2}
+,{149,-31,2},{150,-31,2},{151,-31,2},{152,-31,2},{153,-31,2},{115,-32,2},{116,-32,2},{117,-32,2}
+,{118,-32,2},{119,-32,2},{120,-32,2},{121,-32,2},{122,-32,2},{123,-32,2},{124,-32,2},{125,-32,2}
+,{126,-32,2},{127,-32,2},{128,-32,2},{129,-32,2},{130,-32,2},{131,-32,2},{132,-32,2},{133,-32,2}
+,{134,-32,2},{135,-32,2},{136,-32,2},{137,-32,2},{138,-32,2},{139,-32,2},{140,-32,2},{141,-32,2}
+,{142,-32,2},{143,-32,2},{144,-32,2},{145,-32,2},{146,-32,2},{147,-32,2},{148,-32,2},{149,-32,2}
+,{150,-32,2},{151,-32,2},{152,-32,2},{153,-32,2},{159,-32,2},{115,-33,2},{116,-33,2},{117,-33,2}
+,{118,-33,2},{119,-33,2},{120,-33,2},{121,-33,2},{122,-33,2},{123,-33,2},{124,-33,2},{125,-33,2}
+,{126,-33,2},{127,-33,2},{128,-33,2},{132,-33,2},{133,-33,2},{134,-33,2},{135,-33,2},{136,-33,2}
+,{137,-33,2},{138,-33,2},{139,-33,2},{140,-33,2},{141,-33,2},{142,-33,2},{143,-33,2},{144,-33,2}
+,{145,-33,2},{146,-33,2},{147,-33,2},{148,-33,2},{149,-33,2},{150,-33,2},{151,-33,2},{152,-33,2}
+,{114,-34,2},{115,-34,2},{116,-34,2},{117,-34,2},{118,-34,2},{119,-34,2},{120,-34,2},{121,-34,2}
+,{122,-34,2},{123,-34,2},{124,-34,2},{134,-34,2},{135,-34,2},{136,-34,2},{137,-34,2},{138,-34,2}
+,{139,-34,2},{140,-34,2},{141,-34,2},{142,-34,2},{143,-34,2},{144,-34,2},{145,-34,2},{146,-34,2}
+,{147,-34,2},{148,-34,2},{149,-34,2},{150,-34,2},{151,-34,2},{114,-35,2},{115,-35,2},{116,-35,2}
+,{117,-35,2},{118,-35,2},{119,-35,2},{120,-35,2},{121,-35,2},{122,-35,2},{123,-35,2},{134,-35,2}
+,{135,-35,2},{136,-35,2},{137,-35,2},{138,-35,2},{139,-35,2},{140,-35,2},{141,-35,2},{142,-35,2}
+,{143,-35,2},{144,-35,2},{145,-35,2},{146,-35,2},{147,-35,2},{148,-35,2},{149,-35,2},{150,-35,2}
+,{151,-35,2},{116,-36,2},{117,-36,2},{118,-36,2},{135,-36,2},{136,-36,2},{137,-36,2},{138,-36,2}
+,{139,-36,2},{140,-36,2},{141,-36,2},{142,-36,2},{143,-36,2},{144,-36,2},{145,-36,2},{146,-36,2}
+,{147,-36,2},{148,-36,2},{149,-36,2},{150,-36,2},{136,-37,2},{137,-37,2},{139,-37,2},{140,-37,2}
+,{141,-37,2},{142,-37,2},{143,-37,2},{144,-37,2},{145,-37,2},{146,-37,2},{147,-37,2},{148,-37,2}
+,{149,-37,2},{150,-37,2},{139,-38,2},{140,-38,2},{141,-38,2},{142,-38,2},{143,-38,2},{144,-38,2}
+,{145,-38,2},{146,-38,2},{147,-38,2},{148,-38,2},{149,-38,2},{150,-38,2},{140,-39,2},{141,-39,2}
+,{142,-39,2},{143,-39,2},{144,-39,2},{145,-39,2},{146,-39,2},{147,-39,2},{143,-40,2},{144,-40,2}
+,{146,-40,2},{147,-40,2},{148,-40,2},{143,-41,2},{144,-41,2},{145,-41,2},{146,-41,2},{147,-41,2}
+,{148,-41,2},{144,-42,2},{145,-42,2},{146,-42,2},{147,-42,2},{148,-42,2},{145,-43,2},{146,-43,2}
+,{147,-43,2},{148,-43,2},{145,-44,2},{146,-44,2},{147,-44,2},{148,-44,2},{72,0,3},{73,0,3}
+,{97,0,3},{98,0,3},{99,0,3},{100,0,3},{101,0,3},{102,0,3},{103,0,3},{104,0,3}
+,{106,0,3},{107,0,3},{108,0,3},{109,0,3},{110,0,3},{111,0,3},{112,0,3},{113,0,3}
+,{114,0,3},{115,0,3},{116,0,3},{117,0,3},{118,0,3},{119,0,3},{120,0,3},{121,0,3}
+,{122,0,3},{123,0,3},{124,0,3},{126,0,3},{127,0,3},{128,0,3},{129,0,3},{130,0,3}
+,{131,0,3},{134,0,3},{172,0,3},{173,0,3},{-177,0,3},{73,1,3},{97,1,3},{98,1,3}
+,{99,1,3},{100,1,3},{101,1,3},{102,1,3},{103,1,3},{104,1,3},{106,1,3},{107,1,3}
+,{108,1,3},{109,1,3},{110,1,3},{111,1,3},{112,1,3},{113,1,3},{114,1,3},{115,1,3}
+,{116,1,3},{117,1,3},{118,1,3},{119,1,3},{120,1,3},{121,1,3},{122,1,3},{124,1,3}
+,{125,1,3},{126,1,3},{127,1,3},{128,1,3},{131,1,3},{154,1,3},{172,1,3},{173,1,3}
+,{-158,1,3},{72,2,3},{73,2,3},{95,2,3},{96,2,3},{97,2,3},{98,2,3},{99,2,3}
+,{100,2,3},{101,2,3},{102,2,3},{103,2,3},{104,2,3},{105,2,3},{106,2,3},{107,2,3}
+,{108,2,3},{109,2,3},{111,2,3},{112,2,3},{113,2,3},{114,2,3},{115,2,3},{116,2,3}
+,{117,2,3},{118,2,3},{125,2,3},{127,2,3},{128,2,3},{131,2,3},{173,2,3},{-158,2,3}
+,{72,3,3},{73,3,3},{95,3,3},{96,3,3},{97,3,3},{98,3,3},{99,3,3},{100,3,3}
+,{101,3,3},{102,3,3},{103,3,3},{105,3,3},{106,3,3},{107,3,3},{108,3,3},{112,3,3}
+,{113,3,3},{114,3,3},{115,3,3},{116,3,3},{117,3,3},{125,3,3},{126,3,3},{131,3,3}
+,{154,3,3},{172,3,3},{173,3,3},{-160,3,3},{72,4,3},{73,4,3},{95,4,3},{96,4,3}
+,{97,4,3},{98,4,3},{100,4,3},{101,4,3},{102,4,3},{103,4,3},{107,4,3},{108,4,3}
+,{113,4,3},{114,4,3},{115,4,3},{116,4,3},{117,4,3},{118,4,3},{119,4,3},{125,4,3}
+,{126,4,3},{127,4,3},{131,4,3},{132,4,3},{168,4,3},{-161,4,3},{72,5,3},{73,5,3}
+,{80,5,3},{94,5,3},{95,5,3},{96,5,3},{97,5,3},{100,5,3},{101,5,3},{102,5,3}
+,{103,5,3},{114,5,3},{115,5,3},{116,5,3},{117,5,3},{118,5,3},{119,5,3},{120,5,3}
+,{121,5,3},{124,5,3},{125,5,3},{126,5,3},{132,5,3},{153,5,3},{157,5,3},{162,5,3}
+,{163,5,3},{168,5,3},{169,5,3},{172,5,3},{-163,5,3},{72,6,3},{73,6,3},{79,6,3}
+,{80,6,3},{81,6,3},{93,6,3},{95,6,3},{99,6,3},{100,6,3},{101,6,3},{102,6,3}
+,{115,6,3},{116,6,3},{117,6,3},{118,6,3},{120,6,3},{121,6,3},{122,6,3},{123,6,3}
+,{124,6,3},{125,6,3},{126,6,3},{134,6,3},{143,6,3},{149,6,3},{151,6,3},{152,6,3}
+,{157,6,3},{158,6,3},{159,6,3},{160,6,3},{169,6,3},{171,6,3},{172,6,3},{-163,6,3}
+,{72,7,3},{73,7,3},{79,7,3},{80,7,3},{81,7,3},{93,7,3},{98,7,3},{99,7,3}
+,{100,7,3},{113,7,3},{116,7,3},{117,7,3},{118,7,3},{121,7,3},{122,7,3},{123,7,3}
+,{124,7,3},{125,7,3},{126,7,3},{134,7,3},{143,7,3},{144,7,3},{145,7,3},{146,7,3}
+,{147,7,3},{149,7,3},{151,7,3},{152,7,3},{155,7,3},{157,7,3},{158,7,3},{168,7,3}
+,{171,7,3},{73,8,3},{76,8,3},{77,8,3},{78,8,3},{79,8,3},{80,8,3},{81,8,3}
+,{92,8,3},{93,8,3},{97,8,3},{98,8,3},{99,8,3},{100,8,3},{104,8,3},{105,8,3}
+,{106,8,3},{111,8,3},{116,8,3},{117,8,3},{118,8,3},{122,8,3},{123,8,3},{124,8,3}
+,{125,8,3},{126,8,3},{134,8,3},{137,8,3},{140,8,3},{144,8,3},{146,8,3},{147,8,3}
+,{149,8,3},{150,8,3},{151,8,3},{152,8,3},{154,8,3},{165,8,3},{166,8,3},{167,8,3}
+,{168,8,3},{170,8,3},{171,8,3},{76,9,3},{77,9,3},{78,9,3},{79,9,3},{80,9,3}
+,{92,9,3},{97,9,3},{98,9,3},{99,9,3},{100,9,3},{102,9,3},{103,9,3},{104,9,3}
+,{105,9,3},{106,9,3},{109,9,3},{117,9,3},{118,9,3},{119,9,3},{120,9,3},{121,9,3}
+,{122,9,3},{123,9,3},{124,9,3},{125,9,3},{126,9,3},{138,9,3},{139,9,3},{140,9,3}
+,{145,9,3},{160,9,3},{165,9,3},{166,9,3},{167,9,3},{169,9,3},{170,9,3},{72,10,3}
+,{73,10,3},{75,10,3},{76,10,3},{77,10,3},{78,10,3},{79,10,3},{92,10,3},{97,10,3}
+,{98,10,3},{99,10,3},{102,10,3},{103,10,3},{104,10,3},{105,10,3},{106,10,3},{107,10,3}
+,{108,10,3},{114,10,3},{115,10,3},{118,10,3},{119,10,3},{120,10,3},{121,10,3},{122,10,3}
+,{123,10,3},{124,10,3},{125,10,3},{126,10,3},{139,10,3},{165,10,3},{166,10,3},{168,10,3}
+,{169,10,3},{170,10,3},{72,11,3},{73,11,3},{75,11,3},{76,11,3},{77,11,3},{78,11,3}
+,{79,11,3},{92,11,3},{93,11,3},{97,11,3},{98,11,3},{99,11,3},{102,11,3},{103,11,3}
+,{104,11,3},{105,11,3},{106,11,3},{107,11,3},{108,11,3},{109,11,3},{114,11,3},{115,11,3}
+,{119,11,3},{120,11,3},{121,11,3},{122,11,3},{123,11,3},{124,11,3},{125,11,3},{162,11,3}
+,{165,11,3},{166,11,3},{167,11,3},{169,11,3},{74,12,3},{75,12,3},{76,12,3},{77,12,3}
+,{78,12,3},{79,12,3},{80,12,3},{92,12,3},{93,12,3},{97,12,3},{98,12,3},{99,12,3}
+,{100,12,3},{101,12,3},{102,12,3},{103,12,3},{104,12,3},{105,12,3},{106,12,3},{107,12,3}
+,{108,12,3},{109,12,3},{119,12,3},{120,12,3},{121,12,3},{122,12,3},{123,12,3},{124,12,3}
+,{125,12,3},{170,12,3},{74,13,3},{75,13,3},{76,13,3},{77,13,3},{78,13,3},{79,13,3}
+,{80,13,3},{92,13,3},{93,13,3},{94,13,3},{97,13,3},{98,13,3},{99,13,3},{100,13,3}
+,{101,13,3},{102,13,3},{103,13,3},{104,13,3},{105,13,3},{106,13,3},{107,13,3},{108,13,3}
+,{109,13,3},{120,13,3},{121,13,3},{122,13,3},{123,13,3},{124,13,3},{144,13,3},{74,14,3}
+,{75,14,3},{76,14,3},{77,14,3},{78,14,3},{79,14,3},{80,14,3},{93,14,3},{97,14,3}
+,{98,14,3},{99,14,3},{100,14,3},{101,14,3},{102,14,3},{103,14,3},{104,14,3},{105,14,3}
+,{106,14,3},{107,14,3},{108,14,3},{109,14,3},{120,14,3},{121,14,3},{122,14,3},{123,14,3}
+,{124,14,3},{145,14,3},{168,14,3},{169,14,3},{73,15,3},{74,15,3},{75,15,3},{76,15,3}
+,{77,15,3},{78,15,3},{79,15,3},{80,15,3},{81,15,3},{94,15,3},{95,15,3},{97,15,3}
+,{98,15,3},{99,15,3},{100,15,3},{101,15,3},{102,15,3},{103,15,3},{104,15,3},{105,15,3}
+,{106,15,3},{107,15,3},{108,15,3},{109,15,3},{111,15,3},{119,15,3},{120,15,3},{121,15,3}
+,{122,15,3},{145,15,3},{73,16,3},{74,16,3},{75,16,3},{76,16,3},{77,16,3},{78,16,3}
+,{79,16,3},{80,16,3},{81,16,3},{82,16,3},{94,16,3},{95,16,3},{96,16,3},{97,16,3}
+,{98,16,3},{99,16,3},{100,16,3},{101,16,3},{102,16,3},{103,16,3},{104,16,3},{105,16,3}
+,{106,16,3},{107,16,3},{108,16,3},{111,16,3},{112,16,3},{119,16,3},{120,16,3},{121,16,3}
+,{122,16,3},{145,16,3},{146,16,3},{73,17,3},{74,17,3},{75,17,3},{76,17,3},{77,17,3}
+,{78,17,3},{79,17,3},{80,17,3},{81,17,3},{82,17,3},{83,17,3},{94,17,3},{95,17,3}
+,{96,17,3},{97,17,3},{98,17,3},{99,17,3},{100,17,3},{101,17,3},{102,17,3},{103,17,3}
+,{104,17,3},{105,17,3},{106,17,3},{107,17,3},{120,17,3},{121,17,3},{122,17,3},{145,17,3}
+,{72,18,3},{73,18,3},{74,18,3},{75,18,3},{76,18,3},{77,18,3},{78,18,3},{79,18,3}
+,{80,18,3},{81,18,3},{82,18,3},{83,18,3},{84,18,3},{93,18,3},{94,18,3},{95,18,3}
+,{96,18,3},{97,18,3},{98,18,3},{99,18,3},{100,18,3},{101,18,3},{102,18,3},{103,18,3}
+,{104,18,3},{105,18,3},{106,18,3},{108,18,3},{109,18,3},{110,18,3},{120,18,3},{121,18,3}
+,{122,18,3},{145,18,3},{72,19,3},{73,19,3},{74,19,3},{75,19,3},{76,19,3},{77,19,3}
+,{78,19,3},{79,19,3},{80,19,3},{81,19,3},{82,19,3},{83,19,3},{84,19,3},{85,19,3}
+,{86,19,3},{92,19,3},{93,19,3},{94,19,3},{95,19,3},{96,19,3},{97,19,3},{98,19,3}
+,{99,19,3},{100,19,3},{101,19,3},{102,19,3},{103,19,3},{104,19,3},{105,19,3},{106,19,3}
+,{108,19,3},{109,19,3},{110,19,3},{111,19,3},{121,19,3},{122,19,3},{145,19,3},{166,19,3}
+,{70,20,3},{71,20,3},{72,20,3},{73,20,3},{74,20,3},{75,20,3},{76,20,3},{77,20,3}
+,{78,20,3},{79,20,3},{80,20,3},{81,20,3},{82,20,3},{83,20,3},{84,20,3},{85,20,3}
+,{86,20,3},{87,20,3},{92,20,3},{93,20,3},{94,20,3},{95,20,3},{96,20,3},{97,20,3}
+,{98,20,3},{99,20,3},{100,20,3},{101,20,3},{102,20,3},{103,20,3},{104,20,3},{105,20,3}
+,{106,20,3},{107,20,3},{109,20,3},{110,20,3},{116,20,3},{121,20,3},{122,20,3},{136,20,3}
+,{144,20,3},{145,20,3},{69,21,3},{70,21,3},{71,21,3},{72,21,3},{73,21,3},{74,21,3}
+,{75,21,3},{76,21,3},{77,21,3},{78,21,3},{79,21,3},{80,21,3},{81,21,3},{82,21,3}
+,{83,21,3},{84,21,3},{85,21,3},{86,21,3},{87,21,3},{88,21,3},{89,21,3},{90,21,3}
+,{91,21,3},{92,21,3},{93,21,3},{94,21,3},{95,21,3},{96,21,3},{97,21,3},{98,21,3}
+,{99,21,3},{100,21,3},{101,21,3},{102,21,3},{103,21,3},{104,21,3},{105,21,3},{106,21,3}
+,{107,21,3},{108,21,3},{109,21,3},{110,21,3},{111,21,3},{112,21,3},{113,21,3},{114,21,3}
+,{120,21,3},{121,21,3},{68,22,3},{69,22,3},{70,22,3},{71,22,3},{72,22,3},{73,22,3}
+,{74,22,3},{75,22,3},{76,22,3},{77,22,3},{78,22,3},{79,22,3},{80,22,3},{81,22,3}
+,{82,22,3},{83,22,3},{84,22,3},{85,22,3},{86,22,3},{87,22,3},{88,22,3},{89,22,3}
+,{90,22,3},{91,22,3},{92,22,3},{93,22,3},{94,22,3},{95,22,3},{96,22,3},{97,22,3}
+,{98,22,3},{99,22,3},{100,22,3},{101,22,3},{102,22,3},{103,22,3},{104,22,3},{105,22,3}
+,{106,22,3},{107,22,3},{108,22,3},{109,22,3},{110,22,3},{111,22,3},{112,22,3},{113,22,3}
+,{114,22,3},{115,22,3},{116,22,3},{120,22,3},{121,22,3},{67,23,3},{68,23,3},{69,23,3}
+,{70,23,3},{71,23,3},{72,23,3},{73,23,3},{74,23,3},{75,23,3},{76,23,3},{77,23,3}
+,{78,23,3},{79,23,3},{80,23,3},{81,23,3},{82,23,3},{83,23,3},{84,23,3},{85,23,3}
+,{86,23,3},{87,23,3},{88,23,3},{89,23,3},{90,23,3},{91,23,3},{92,23,3},{93,23,3}
+,{94,23,3},{95,23,3},{96,23,3},{97,23,3},{98,23,3},{99,23,3},{100,23,3},{101,23,3}
+,{102,23,3},{103,23,3},{104,23,3},{105,23,3},{106,23,3},{107,23,3},{108,23,3},{109,23,3}
+,{110,23,3},{111,23,3},{112,23,3},{113,23,3},{114,23,3},{115,23,3},{116,23,3},{117,23,3}
+,{119,23,3},{120,23,3},{121,23,3},{66,24,3},{67,24,3},{68,24,3},{69,24,3},{70,24,3}
+,{71,24,3},{72,24,3},{73,24,3},{74,24,3},{75,24,3},{76,24,3},{77,24,3},{78,24,3}
+,{79,24,3},{80,24,3},{81,24,3},{82,24,3},{83,24,3},{84,24,3},{85,24,3},{86,24,3}
+,{87,24,3},{88,24,3},{89,24,3},{90,24,3},{91,24,3},{92,24,3},{93,24,3},{94,24,3}
+,{95,24,3},{96,24,3},{97,24,3},{98,24,3},{99,24,3},{100,24,3},{101,24,3},{102,24,3}
+,{103,24,3},{104,24,3},{105,24,3},{106,24,3},{107,24,3},{108,24,3},{109,24,3},{110,24,3}
+,{111,24,3},{112,24,3},{113,24,3},{114,24,3},{115,24,3},{116,24,3},{117,24,3},{118,24,3}
+,{119,24,3},{120,24,3},{121,24,3},{122,24,3},{123,24,3},{124,24,3},{125,24,3},{131,24,3}
+,{141,24,3},{153,24,3},{60,25,3},{61,25,3},{62,25,3},{63,25,3},{64,25,3},{65,25,3}
+,{66,25,3},{67,25,3},{68,25,3},{69,25,3},{70,25,3},{71,25,3},{72,25,3},{73,25,3}
+,{74,25,3},{75,25,3},{76,25,3},{77,25,3},{78,25,3},{79,25,3},{80,25,3},{81,25,3}
+,{82,25,3},{83,25,3},{84,25,3},{85,25,3},{86,25,3},{87,25,3},{88,25,3},{89,25,3}
+,{90,25,3},{91,25,3},{92,25,3},{93,25,3},{94,25,3},{95,25,3},{96,25,3},{97,25,3}
+,{98,25,3},{99,25,3},{100,25,3},{101,25,3},{102,25,3},{103,25,3},{104,25,3},{105,25,3}
+,{106,25,3},{107,25,3},{108,25,3},{109,25,3},{110,25,3},{111,25,3},{112,25,3},{113,25,3}
+,{114,25,3},{115,25,3},{116,25,3},{117,25,3},{118,25,3},{119,25,3},{121,25,3},{122,25,3}
+,{123,25,3},{124,25,3},{131,25,3},{141,25,3},{60,26,3},{61,26,3},{62,26,3},{63,26,3}
+,{64,26,3},{65,26,3},{66,26,3},{67,26,3},{68,26,3},{69,26,3},{70,26,3},{71,26,3}
+,{72,26,3},{73,26,3},{74,26,3},{75,26,3},{76,26,3},{77,26,3},{78,26,3},{79,26,3}
+,{80,26,3},{81,26,3},{82,26,3},{83,26,3},{84,26,3},{85,26,3},{86,26,3},{87,26,3}
+,{88,26,3},{89,26,3},{90,26,3},{91,26,3},{92,26,3},{93,26,3},{94,26,3},{95,26,3}
+,{96,26,3},{97,26,3},{98,26,3},{99,26,3},{100,26,3},{101,26,3},{102,26,3},{103,26,3}
+,{104,26,3},{105,26,3},{106,26,3},{107,26,3},{108,26,3},{109,26,3},{110,26,3},{111,26,3}
+,{112,26,3},{113,26,3},{114,26,3},{115,26,3},{116,26,3},{117,26,3},{118,26,3},{119,26,3}
+,{120,26,3},{126,26,3},{127,26,3},{128,26,3},{142,26,3},{60,27,3},{61,27,3},{62,27,3}
+,{63,27,3},{64,27,3},{65,27,3},{66,27,3},{67,27,3},{68,27,3},{69,27,3},{70,27,3}
+,{71,27,3},{72,27,3},{73,27,3},{74,27,3},{75,27,3},{76,27,3},{77,27,3},{78,27,3}
+,{79,27,3},{80,27,3},{81,27,3},{82,27,3},{83,27,3},{84,27,3},{85,27,3},{86,27,3}
+,{87,27,3},{88,27,3},{89,27,3},{90,27,3},{91,27,3},{92,27,3},{93,27,3},{94,27,3}
+,{95,27,3},{96,27,3},{97,27,3},{98,27,3},{99,27,3},{100,27,3},{101,27,3},{102,27,3}
+,{103,27,3},{104,27,3},{105,27,3},{106,27,3},{107,27,3},{108,27,3},{109,27,3},{110,27,3}
+,{111,27,3},{112,27,3},{113,27,3},{114,27,3},{115,27,3},{116,27,3},{117,27,3},{118,27,3}
+,{119,27,3},{120,27,3},{121,27,3},{127,27,3},{128,27,3},{129,27,3},{140,27,3},{142,27,3}
+,{60,28,3},{61,28,3},{62,28,3},{63,28,3},{64,28,3},{65,28,3},{66,28,3},{67,28,3}
+,{68,28,3},{69,28,3},{70,28,3},{71,28,3},{72,28,3},{73,28,3},{74,28,3},{75,28,3}
+,{76,28,3},{77,28,3},{78,28,3},{79,28,3},{80,28,3},{81,28,3},{82,28,3},{83,28,3}
+,{84,28,3},{85,28,3},{86,28,3},{87,28,3},{88,28,3},{89,28,3},{90,28,3},{91,28,3}
+,{92,28,3},{93,28,3},{94,28,3},{95,28,3},{96,28,3},{97,28,3},{98,28,3},{99,28,3}
+,{100,28,3},{101,28,3},{102,28,3},{103,28,3},{104,28,3},{105,28,3},{106,28,3},{107,28,3}
+,{108,28,3},{109,28,3},{110,28,3},{111,28,3},{112,28,3},{113,28,3},{114,28,3},{115,28,3}
+,{116,28,3},{117,28,3},{118,28,3},{119,28,3},{120,28,3},{121,28,3},{122,28,3},{128,28,3}
+,{129,28,3},{130,28,3},{60,29,3},{61,29,3},{62,29,3},{63,29,3},{64,29,3},{65,29,3}
+,{66,29,3},{67,29,3},{68,29,3},{69,29,3},{70,29,3},{71,29,3},{72,29,3},{73,29,3}
+,{74,29,3},{75,29,3},{76,29,3},{77,29,3},{78,29,3},{79,29,3},{80,29,3},{81,29,3}
+,{82,29,3},{83,29,3},{84,29,3},{85,29,3},{86,29,3},{87,29,3},{88,29,3},{89,29,3}
+,{90,29,3},{91,29,3},{92,29,3},{93,29,3},{94,29,3},{95,29,3},{96,29,3},{97,29,3}
+,{98,29,3},{99,29,3},{100,29,3},{101,29,3},{102,29,3},{103,29,3},{104,29,3},{105,29,3}
+,{106,29,3},{107,29,3},{108,29,3},{109,29,3},{110,29,3},{111,29,3},{112,29,3},{113,29,3}
+,{114,29,3},{115,29,3},{116,29,3},{117,29,3},{118,29,3},{119,29,3},{120,29,3},{121,29,3}
+,{122,29,3},{129,29,3},{140,29,3},{60,30,3},{61,30,3},{62,30,3},{63,30,3},{64,30,3}
+,{65,30,3},{66,30,3},{67,30,3},{68,30,3},{69,30,3},{70,30,3},{71,30,3},{72,30,3}
+,{73,30,3},{74,30,3},{75,30,3},{76,30,3},{77,30,3},{78,30,3},{79,30,3},{80,30,3}
+,{81,30,3},{82,30,3},{83,30,3},{84,30,3},{85,30,3},{86,30,3},{87,30,3},{88,30,3}
+,{89,30,3},{90,30,3},{91,30,3},{92,30,3},{93,30,3},{94,30,3},{95,30,3},{96,30,3}
+,{97,30,3},{98,30,3},{99,30,3},{100,30,3},{101,30,3},{102,30,3},{103,30,3},{104,30,3}
+,{105,30,3},{106,30,3},{107,30,3},{108,30,3},{109,30,3},{110,30,3},{111,30,3},{112,30,3}
+,{113,30,3},{114,30,3},{115,30,3},{116,30,3},{117,30,3},{118,30,3},{119,30,3},{120,30,3}
+,{121,30,3},{122,30,3},{129,30,3},{130,30,3},{131,30,3},{140,30,3},{60,31,3},{61,31,3}
+,{62,31,3},{63,31,3},{64,31,3},{65,31,3},{66,31,3},{67,31,3},{68,31,3},{69,31,3}
+,{70,31,3},{71,31,3},{72,31,3},{73,31,3},{74,31,3},{75,31,3},{76,31,3},{77,31,3}
+,{78,31,3},{79,31,3},{80,31,3},{81,31,3},{82,31,3},{83,31,3},{84,31,3},{85,31,3}
+,{86,31,3},{87,31,3},{88,31,3},{89,31,3},{90,31,3},{91,31,3},{92,31,3},{93,31,3}
+,{94,31,3},{95,31,3},{96,31,3},{97,31,3},{98,31,3},{99,31,3},{100,31,3},{101,31,3}
+,{102,31,3},{103,31,3},{104,31,3},{105,31,3},{106,31,3},{107,31,3},{108,31,3},{109,31,3}
+,{110,31,3},{111,31,3},{112,31,3},{113,31,3},{114,31,3},{115,31,3},{116,31,3},{117,31,3}
+,{118,31,3},{119,31,3},{120,31,3},{121,31,3},{122,31,3},{128,31,3},{129,31,3},{130,31,3}
+,{131,31,3},{139,31,3},{140,31,3},{60,32,3},{61,32,3},{62,32,3},{63,32,3},{64,32,3}
+,{65,32,3},{66,32,3},{67,32,3},{68,32,3},{69,32,3},{70,32,3},{71,32,3},{72,32,3}
+,{73,32,3},{74,32,3},{75,32,3},{76,32,3},{77,32,3},{78,32,3},{79,32,3},{80,32,3}
+,{81,32,3},{82,32,3},{83,32,3},{84,32,3},{85,32,3},{86,32,3},{87,32,3},{88,32,3}
+,{89,32,3},{90,32,3},{91,32,3},{92,32,3},{93,32,3},{94,32,3},{95,32,3},{96,32,3}
+,{97,32,3},{98,32,3},{99,32,3},{100,32,3},{101,32,3},{102,32,3},{103,32,3},{104,32,3}
+,{105,32,3},{106,32,3},{107,32,3},{108,32,3},{109,32,3},{110,32,3},{111,32,3},{112,32,3}
+,{113,32,3},{114,32,3},{115,32,3},{116,32,3},{117,32,3},{118,32,3},{119,32,3},{120,32,3}
+,{121,32,3},{128,32,3},{129,32,3},{130,32,3},{131,32,3},{132,32,3},{133,32,3},{139,32,3}
+,{60,33,3},{61,33,3},{62,33,3},{63,33,3},{64,33,3},{65,33,3},{66,33,3},{67,33,3}
+,{68,33,3},{69,33,3},{70,33,3},{71,33,3},{72,33,3},{73,33,3},{74,33,3},{75,33,3}
+,{76,33,3},{77,33,3},{78,33,3},{79,33,3},{80,33,3},{81,33,3},{82,33,3},{83,33,3}
+,{84,33,3},{85,33,3},{86,33,3},{87,33,3},{88,33,3},{89,33,3},{90,33,3},{91,33,3}
+,{92,33,3},{93,33,3},{94,33,3},{95,33,3},{96,33,3},{97,33,3},{98,33,3},{99,33,3}
+,{100,33,3},{101,33,3},{102,33,3},{103,33,3},{104,33,3},{105,33,3},{106,33,3},{107,33,3}
+,{108,33,3},{109,33,3},{110,33,3},{111,33,3},{112,33,3},{113,33,3},{114,33,3},{115,33,3}
+,{116,33,3},{117,33,3},{118,33,3},{119,33,3},{120,33,3},{126,33,3},{128,33,3},{129,33,3}
+,{130,33,3},{131,33,3},{132,33,3},{133,33,3},{134,33,3},{135,33,3},{136,33,3},{138,33,3}
+,{139,33,3},{60,34,3},{61,34,3},{62,34,3},{63,34,3},{64,34,3},{65,34,3},{66,34,3}
+,{67,34,3},{68,34,3},{69,34,3},{70,34,3},{71,34,3},{72,34,3},{73,34,3},{74,34,3}
+,{75,34,3},{76,34,3},{77,34,3},{78,34,3},{79,34,3},{80,34,3},{81,34,3},{82,34,3}
+,{83,34,3},{84,34,3},{85,34,3},{86,34,3},{87,34,3},{88,34,3},{89,34,3},{90,34,3}
+,{91,34,3},{92,34,3},{93,34,3},{94,34,3},{95,34,3},{96,34,3},{97,34,3},{98,34,3}
+,{99,34,3},{100,34,3},{101,34,3},{102,34,3},{103,34,3},{104,34,3},{105,34,3},{106,34,3}
+,{107,34,3},{108,34,3},{109,34,3},{110,34,3},{111,34,3},{112,34,3},{113,34,3},{114,34,3}
+,{115,34,3},{116,34,3},{117,34,3},{118,34,3},{119,34,3},{120,34,3},{125,34,3},{126,34,3}
+,{127,34,3},{128,34,3},{129,34,3},{130,34,3},{131,34,3},{132,34,3},{133,34,3},{134,34,3}
+,{135,34,3},{136,34,3},{137,34,3},{138,34,3},{139,34,3},{0,35,3},{1,35,3},{2,35,3}
+,{3,35,3},{4,35,3},{5,35,3},{6,35,3},{7,35,3},{8,35,3},{9,35,3},{10,35,3}
+,{11,35,3},{12,35,3},{14,35,3},{23,35,3},{24,35,3},{25,35,3},{26,35,3},{27,35,3}
+,{32,35,3},{33,35,3},{34,35,3},{35,35,3},{36,35,3},{37,35,3},{38,35,3},{39,35,3}
+,{40,35,3},{41,35,3},{42,35,3},{43,35,3},{44,35,3},{45,35,3},{46,35,3},{47,35,3}
+,{48,35,3},{49,35,3},{50,35,3},{51,35,3},{52,35,3},{53,35,3},{54,35,3},{55,35,3}
+,{56,35,3},{57,35,3},{58,35,3},{59,35,3},{60,35,3},{61,35,3},{62,35,3},{63,35,3}
+,{64,35,3},{65,35,3},{66,35,3},{67,35,3},{68,35,3},{69,35,3},{70,35,3},{71,35,3}
+,{72,35,3},{73,35,3},{74,35,3},{75,35,3},{76,35,3},{77,35,3},{78,35,3},{79,35,3}
+,{80,35,3},{81,35,3},{82,35,3},{83,35,3},{84,35,3},{85,35,3},{86,35,3},{87,35,3}
+,{88,35,3},{89,35,3},{90,35,3},{91,35,3},{92,35,3},{93,35,3},{94,35,3},{95,35,3}
+,{96,35,3},{97,35,3},{98,35,3},{99,35,3},{100,35,3},{101,35,3},{102,35,3},{103,35,3}
+,{104,35,3},{105,35,3},{106,35,3},{107,35,3},{108,35,3},{109,35,3},{110,35,3},{111,35,3}
+,{112,35,3},{113,35,3},{114,35,3},{115,35,3},{116,35,3},{117,35,3},{118,35,3},{119,35,3}
+,{120,35,3},{125,35,3},{126,35,3},{127,35,3},{128,35,3},{129,35,3},{132,35,3},{133,35,3}
+,{134,35,3},{135,35,3},{136,35,3},{137,35,3},{138,35,3},{139,35,3},{140,35,3},{-1,35,3}
+,{-2,35,3},{-3,35,3},{-4,35,3},{-5,35,3},{-6,35,3},{-7,35,3},{0,36,3},{1,36,3}
+,{2,36,3},{3,36,3},{4,36,3},{5,36,3},{6,36,3},{7,36,3},{8,36,3},{9,36,3}
+,{10,36,3},{11,36,3},{12,36,3},{14,36,3},{15,36,3},{21,36,3},{22,36,3},{23,36,3}
+,{24,36,3},{25,36,3},{26,36,3},{27,36,3},{28,36,3},{29,36,3},{30,36,3},{31,36,3}
+,{32,36,3},{33,36,3},{34,36,3},{35,36,3},{36,36,3},{37,36,3},{38,36,3},{39,36,3}
+,{40,36,3},{41,36,3},{42,36,3},{43,36,3},{44,36,3},{45,36,3},{46,36,3},{47,36,3}
+,{48,36,3},{49,36,3},{50,36,3},{51,36,3},{52,36,3},{53,36,3},{54,36,3},{55,36,3}
+,{56,36,3},{57,36,3},{58,36,3},{59,36,3},{60,36,3},{61,36,3},{62,36,3},{63,36,3}
+,{64,36,3},{65,36,3},{66,36,3},{67,36,3},{68,36,3},{69,36,3},{70,36,3},{71,36,3}
+,{72,36,3},{73,36,3},{74,36,3},{75,36,3},{76,36,3},{77,36,3},{78,36,3},{79,36,3}
+,{80,36,3},{81,36,3},{82,36,3},{83,36,3},{84,36,3},{85,36,3},{86,36,3},{87,36,3}
+,{88,36,3},{89,36,3},{90,36,3},{91,36,3},{92,36,3},{93,36,3},{94,36,3},{95,36,3}
+,{96,36,3},{97,36,3},{98,36,3},{99,36,3},{100,36,3},{101,36,3},{102,36,3},{103,36,3}
+,{104,36,3},{105,36,3},{106,36,3},{107,36,3},{108,36,3},{109,36,3},{110,36,3},{111,36,3}
+,{112,36,3},{113,36,3},{114,36,3},{115,36,3},{116,36,3},{117,36,3},{118,36,3},{119,36,3}
+,{120,36,3},{121,36,3},{122,36,3},{125,36,3},{126,36,3},{127,36,3},{128,36,3},{129,36,3}
+,{132,36,3},{133,36,3},{135,36,3},{136,36,3},{137,36,3},{138,36,3},{139,36,3},{140,36,3}
+,{-2,36,3},{-3,36,3},{-4,36,3},{-5,36,3},{-6,36,3},{-7,36,3},{-8,36,3},{-9,36,3}
+,{6,37,3},{7,37,3},{8,37,3},{9,37,3},{10,37,3},{11,37,3},{12,37,3},{13,37,3}
+,{14,37,3},{15,37,3},{16,37,3},{20,37,3},{21,37,3},{22,37,3},{23,37,3},{24,37,3}
+,{25,37,3},{26,37,3},{27,37,3},{28,37,3},{29,37,3},{30,37,3},{31,37,3},{32,37,3}
+,{33,37,3},{34,37,3},{35,37,3},{36,37,3},{37,37,3},{38,37,3},{39,37,3},{40,37,3}
+,{41,37,3},{42,37,3},{43,37,3},{44,37,3},{45,37,3},{46,37,3},{47,37,3},{48,37,3}
+,{49,37,3},{50,37,3},{53,37,3},{54,37,3},{55,37,3},{56,37,3},{57,37,3},{58,37,3}
+,{59,37,3},{60,37,3},{61,37,3},{62,37,3},{63,37,3},{64,37,3},{65,37,3},{66,37,3}
+,{67,37,3},{68,37,3},{69,37,3},{70,37,3},{71,37,3},{72,37,3},{73,37,3},{74,37,3}
+,{75,37,3},{76,37,3},{77,37,3},{78,37,3},{79,37,3},{80,37,3},{81,37,3},{82,37,3}
+,{83,37,3},{84,37,3},{85,37,3},{86,37,3},{87,37,3},{88,37,3},{89,37,3},{90,37,3}
+,{91,37,3},{92,37,3},{93,37,3},{94,37,3},{95,37,3},{96,37,3},{97,37,3},{98,37,3}
+,{99,37,3},{100,37,3},{101,37,3},{102,37,3},{103,37,3},{104,37,3},{105,37,3},{106,37,3}
+,{107,37,3},{108,37,3},{109,37,3},{110,37,3},{111,37,3},{112,37,3},{113,37,3},{114,37,3}
+,{115,37,3},{116,37,3},{117,37,3},{118,37,3},{119,37,3},{120,37,3},{121,37,3},{122,37,3}
+,{124,37,3},{125,37,3},{126,37,3},{127,37,3},{128,37,3},{129,37,3},{130,37,3},{131,37,3}
+,{136,37,3},{137,37,3},{138,37,3},{139,37,3},{140,37,3},{141,37,3},{-1,37,3},{-2,37,3}
+,{-3,37,3},{-4,37,3},{-5,37,3},{-6,37,3},{-7,37,3},{-8,37,3},{-9,37,3},{0,38,3}
+,{1,38,3},{8,38,3},{9,38,3},{12,38,3},{13,38,3},{14,38,3},{15,38,3},{16,38,3}
+,{17,38,3},{20,38,3},{21,38,3},{22,38,3},{23,38,3},{24,38,3},{25,38,3},{26,38,3}
+,{27,38,3},{28,38,3},{29,38,3},{30,38,3},{31,38,3},{32,38,3},{33,38,3},{34,38,3}
+,{35,38,3},{36,38,3},{37,38,3},{38,38,3},{39,38,3},{40,38,3},{41,38,3},{42,38,3}
+,{43,38,3},{44,38,3},{45,38,3},{46,38,3},{47,38,3},{48,38,3},{49,38,3},{53,38,3}
+,{54,38,3},{55,38,3},{56,38,3},{57,38,3},{58,38,3},{59,38,3},{60,38,3},{61,38,3}
+,{62,38,3},{63,38,3},{64,38,3},{65,38,3},{66,38,3},{67,38,3},{68,38,3},{69,38,3}
+,{70,38,3},{71,38,3},{72,38,3},{73,38,3},{74,38,3},{75,38,3},{76,38,3},{77,38,3}
+,{78,38,3},{79,38,3},{80,38,3},{81,38,3},{82,38,3},{83,38,3},{84,38,3},{85,38,3}
+,{86,38,3},{87,38,3},{88,38,3},{89,38,3},{90,38,3},{91,38,3},{92,38,3},{93,38,3}
+,{94,38,3},{95,38,3},{96,38,3},{97,38,3},{98,38,3},{99,38,3},{100,38,3},{101,38,3}
+,{102,38,3},{103,38,3},{104,38,3},{105,38,3},{106,38,3},{107,38,3},{108,38,3},{109,38,3}
+,{110,38,3},{111,38,3},{112,38,3},{113,38,3},{114,38,3},{115,38,3},{116,38,3},{117,38,3}
+,{118,38,3},{120,38,3},{121,38,3},{124,38,3},{125,38,3},{126,38,3},{127,38,3},{128,38,3}
+,{138,38,3},{139,38,3},{140,38,3},{141,38,3},{-1,38,3},{-2,38,3},{-3,38,3},{-4,38,3}
+,{-5,38,3},{-6,38,3},{-7,38,3},{-8,38,3},{-9,38,3},{-10,38,3},{0,39,3},{1,39,3}
+,{2,39,3},{3,39,3},{4,39,3},{8,39,3},{9,39,3},{15,39,3},{16,39,3},{17,39,3}
+,{18,39,3},{19,39,3},{20,39,3},{21,39,3},{22,39,3},{23,39,3},{24,39,3},{25,39,3}
+,{26,39,3},{27,39,3},{28,39,3},{29,39,3},{30,39,3},{31,39,3},{32,39,3},{33,39,3}
+,{34,39,3},{35,39,3},{36,39,3},{37,39,3},{38,39,3},{39,39,3},{40,39,3},{41,39,3}
+,{42,39,3},{43,39,3},{44,39,3},{45,39,3},{46,39,3},{47,39,3},{48,39,3},{49,39,3}
+,{52,39,3},{53,39,3},{54,39,3},{55,39,3},{56,39,3},{57,39,3},{58,39,3},{59,39,3}
+,{60,39,3},{61,39,3},{62,39,3},{63,39,3},{64,39,3},{65,39,3},{66,39,3},{67,39,3}
+,{68,39,3},{69,39,3},{70,39,3},{71,39,3},{72,39,3},{73,39,3},{74,39,3},{75,39,3}
+,{76,39,3},{77,39,3},{78,39,3},{79,39,3},{80,39,3},{81,39,3},{82,39,3},{83,39,3}
+,{84,39,3},{85,39,3},{86,39,3},{87,39,3},{88,39,3},{89,39,3},{90,39,3},{91,39,3}
+,{92,39,3},{93,39,3},{94,39,3},{95,39,3},{96,39,3},{97,39,3},{98,39,3},{99,39,3}
+,{100,39,3},{101,39,3},{102,39,3},{103,39,3},{104,39,3},{105,39,3},{106,39,3},{107,39,3}
+,{108,39,3},{109,39,3},{110,39,3},{111,39,3},{112,39,3},{113,39,3},{114,39,3},{115,39,3}
+,{116,39,3},{117,39,3},{118,39,3},{119,39,3},{121,39,3},{122,39,3},{123,39,3},{124,39,3}
+,{125,39,3},{126,39,3},{127,39,3},{128,39,3},{139,39,3},{140,39,3},{141,39,3},{142,39,3}
+,{-1,39,3},{-2,39,3},{-3,39,3},{-4,39,3},{-5,39,3},{-6,39,3},{-7,39,3},{-8,39,3}
+,{-9,39,3},{-10,39,3},{0,40,3},{3,40,3},{4,40,3},{8,40,3},{9,40,3},{12,40,3}
+,{13,40,3},{14,40,3},{15,40,3},{16,40,3},{17,40,3},{18,40,3},{19,40,3},{20,40,3}
+,{21,40,3},{22,40,3},{23,40,3},{24,40,3},{25,40,3},{26,40,3},{27,40,3},{28,40,3}
+,{29,40,3},{30,40,3},{31,40,3},{32,40,3},{33,40,3},{34,40,3},{35,40,3},{36,40,3}
+,{37,40,3},{38,40,3},{39,40,3},{40,40,3},{41,40,3},{42,40,3},{43,40,3},{44,40,3}
+,{45,40,3},{46,40,3},{47,40,3},{48,40,3},{49,40,3},{50,40,3},{52,40,3},{53,40,3}
+,{54,40,3},{55,40,3},{56,40,3},{57,40,3},{58,40,3},{59,40,3},{60,40,3},{61,40,3}
+,{62,40,3},{63,40,3},{64,40,3},{65,40,3},{66,40,3},{67,40,3},{68,40,3},{69,40,3}
+,{70,40,3},{71,40,3},{72,40,3},{73,40,3},{74,40,3},{75,40,3},{76,40,3},{77,40,3}
+,{78,40,3},{79,40,3},{80,40,3},{81,40,3},{82,40,3},{83,40,3},{84,40,3},{85,40,3}
+,{86,40,3},{87,40,3},{88,40,3},{89,40,3},{90,40,3},{91,40,3},{92,40,3},{93,40,3}
+,{94,40,3},{95,40,3},{96,40,3},{97,40,3},{98,40,3},{99,40,3},{100,40,3},{101,40,3}
+,{102,40,3},{103,40,3},{104,40,3},{105,40,3},{106,40,3},{107,40,3},{108,40,3},{109,40,3}
+,{110,40,3},{111,40,3},{112,40,3},{113,40,3},{114,40,3},{115,40,3},{116,40,3},{117,40,3}
+,{118,40,3},{119,40,3},{120,40,3},{121,40,3},{122,40,3},{123,40,3},{124,40,3},{125,40,3}
+,{126,40,3},{127,40,3},{128,40,3},{129,40,3},{139,40,3},{140,40,3},{141,40,3},{-1,40,3}
+,{-2,40,3},{-3,40,3},{-4,40,3},{-5,40,3},{-6,40,3},{-7,40,3},{-8,40,3},{-9,40,3}
+,{0,41,3},{1,41,3},{2,41,3},{3,41,3},{8,41,3},{9,41,3},{11,41,3},{12,41,3}
+,{13,41,3},{14,41,3},{15,41,3},{16,41,3},{17,41,3},{19,41,3},{20,41,3},{21,41,3}
+,{22,41,3},{23,41,3},{24,41,3},{25,41,3},{26,41,3},{27,41,3},{28,41,3},{29,41,3}
+,{30,41,3},{31,41,3},{32,41,3},{33,41,3},{34,41,3},{35,41,3},{36,41,3},{37,41,3}
+,{38,41,3},{39,41,3},{40,41,3},{41,41,3},{42,41,3},{43,41,3},{44,41,3},{45,41,3}
+,{46,41,3},{47,41,3},{48,41,3},{49,41,3},{52,41,3},{53,41,3},{54,41,3},{55,41,3}
+,{56,41,3},{57,41,3},{58,41,3},{59,41,3},{60,41,3},{61,41,3},{62,41,3},{63,41,3}
+,{64,41,3},{65,41,3},{66,41,3},{67,41,3},{68,41,3},{69,41,3},{70,41,3},{71,41,3}
+,{72,41,3},{73,41,3},{74,41,3},{75,41,3},{76,41,3},{77,41,3},{78,41,3},{79,41,3}
+,{80,41,3},{81,41,3},{82,41,3},{83,41,3},{84,41,3},{85,41,3},{86,41,3},{87,41,3}
+,{88,41,3},{89,41,3},{90,41,3},{91,41,3},{92,41,3},{93,41,3},{94,41,3},{95,41,3}
+,{96,41,3},{97,41,3},{98,41,3},{99,41,3},{100,41,3},{101,41,3},{102,41,3},{103,41,3}
+,{104,41,3},{105,41,3},{106,41,3},{107,41,3},{108,41,3},{109,41,3},{110,41,3},{111,41,3}
+,{112,41,3},{113,41,3},{114,41,3},{115,41,3},{116,41,3},{117,41,3},{118,41,3},{119,41,3}
+,{120,41,3},{121,41,3},{122,41,3},{123,41,3},{124,41,3},{125,41,3},{126,41,3},{127,41,3}
+,{128,41,3},{129,41,3},{130,41,3},{139,41,3},{140,41,3},{141,41,3},{143,41,3},{-1,41,3}
+,{-2,41,3},{-3,41,3},{-4,41,3},{-5,41,3},{-6,41,3},{-7,41,3},{-8,41,3},{-9,41,3}
+,{0,42,3},{1,42,3},{2,42,3},{3,42,3},{6,42,3},{8,42,3},{9,42,3},{10,42,3}
+,{11,42,3},{12,42,3},{13,42,3},{14,42,3},{15,42,3},{16,42,3},{17,42,3},{18,42,3}
+,{19,42,3},{20,42,3},{21,42,3},{22,42,3},{23,42,3},{24,42,3},{25,42,3},{26,42,3}
+,{27,42,3},{28,42,3},{33,42,3},{34,42,3},{35,42,3},{40,42,3},{41,42,3},{42,42,3}
+,{43,42,3},{44,42,3},{45,42,3},{46,42,3},{47,42,3},{48,42,3},{51,42,3},{52,42,3}
+,{53,42,3},{54,42,3},{55,42,3},{56,42,3},{57,42,3},{58,42,3},{59,42,3},{60,42,3}
+,{61,42,3},{62,42,3},{63,42,3},{64,42,3},{65,42,3},{66,42,3},{67,42,3},{68,42,3}
+,{69,42,3},{70,42,3},{71,42,3},{72,42,3},{73,42,3},{74,42,3},{75,42,3},{76,42,3}
+,{77,42,3},{78,42,3},{79,42,3},{80,42,3},{81,42,3},{82,42,3},{83,42,3},{84,42,3}
+,{85,42,3},{86,42,3},{87,42,3},{88,42,3},{89,42,3},{90,42,3},{91,42,3},{92,42,3}
+,{93,42,3},{94,42,3},{95,42,3},{96,42,3},{97,42,3},{98,42,3},{99,42,3},{100,42,3}
+,{101,42,3},{102,42,3},{103,42,3},{104,42,3},{105,42,3},{106,42,3},{107,42,3},{108,42,3}
+,{109,42,3},{110,42,3},{111,42,3},{112,42,3},{113,42,3},{114,42,3},{115,42,3},{116,42,3}
+,{117,42,3},{118,42,3},{119,42,3},{120,42,3},{121,42,3},{122,42,3},{123,42,3},{124,42,3}
+,{125,42,3},{126,42,3},{127,42,3},{128,42,3},{129,42,3},{130,42,3},{131,42,3},{132,42,3}
+,{133,42,3},{134,42,3},{139,42,3},{140,42,3},{141,42,3},{142,42,3},{143,42,3},{144,42,3}
+,{145,42,3},{-1,42,3},{-2,42,3},{-3,42,3},{-4,42,3},{-5,42,3},{-6,42,3},{-7,42,3}
+,{-8,42,3},{-9,42,3},{-10,42,3},{0,43,3},{1,43,3},{2,43,3},{3,43,3},{4,43,3}
+,{5,43,3},{6,43,3},{7,43,3},{8,43,3},{9,43,3},{10,43,3},{11,43,3},{12,43,3}
+,{13,43,3},{15,43,3},{16,43,3},{17,43,3},{18,43,3},{19,43,3},{20,43,3},{21,43,3}
+,{22,43,3},{23,43,3},{24,43,3},{25,43,3},{26,43,3},{27,43,3},{28,43,3},{39,43,3}
+,{40,43,3},{41,43,3},{42,43,3},{43,43,3},{44,43,3},{45,43,3},{46,43,3},{47,43,3}
+,{50,43,3},{51,43,3},{52,43,3},{53,43,3},{54,43,3},{55,43,3},{56,43,3},{57,43,3}
+,{58,43,3},{59,43,3},{60,43,3},{61,43,3},{62,43,3},{63,43,3},{64,43,3},{65,43,3}
+,{66,43,3},{67,43,3},{68,43,3},{69,43,3},{70,43,3},{71,43,3},{72,43,3},{73,43,3}
+,{74,43,3},{75,43,3},{76,43,3},{77,43,3},{78,43,3},{79,43,3},{80,43,3},{81,43,3}
+,{82,43,3},{83,43,3},{84,43,3},{85,43,3},{86,43,3},{87,43,3},{88,43,3},{89,43,3}
+,{90,43,3},{91,43,3},{92,43,3},{93,43,3},{94,43,3},{95,43,3},{96,43,3},{97,43,3}
+,{98,43,3},{99,43,3},{100,43,3},{101,43,3},{102,43,3},{103,43,3},{104,43,3},{105,43,3}
+,{106,43,3},{107,43,3},{108,43,3},{109,43,3},{110,43,3},{111,43,3},{112,43,3},{113,43,3}
+,{114,43,3},{115,43,3},{116,43,3},{117,43,3},{118,43,3},{119,43,3},{120,43,3},{121,43,3}
+,{122,43,3},{123,43,3},{124,43,3},{125,43,3},{126,43,3},{127,43,3},{128,43,3},{129,43,3}
+,{130,43,3},{131,43,3},{132,43,3},{133,43,3},{134,43,3},{135,43,3},{140,43,3},{141,43,3}
+,{142,43,3},{143,43,3},{144,43,3},{145,43,3},{146,43,3},{-1,43,3},{-2,43,3},{-3,43,3}
+,{-4,43,3},{-5,43,3},{-6,43,3},{-7,43,3},{-8,43,3},{-9,43,3},{-10,43,3},{0,44,3}
+,{1,44,3},{2,44,3},{3,44,3},{4,44,3},{5,44,3},{6,44,3},{7,44,3},{8,44,3}
+,{9,44,3},{10,44,3},{11,44,3},{12,44,3},{13,44,3},{14,44,3},{15,44,3},{16,44,3}
+,{17,44,3},{18,44,3},{19,44,3},{20,44,3},{21,44,3},{22,44,3},{23,44,3},{24,44,3}
+,{25,44,3},{26,44,3},{27,44,3},{28,44,3},{29,44,3},{33,44,3},{34,44,3},{35,44,3}
+,{37,44,3},{38,44,3},{39,44,3},{40,44,3},{41,44,3},{42,44,3},{43,44,3},{44,44,3}
+,{45,44,3},{46,44,3},{47,44,3},{50,44,3},{51,44,3},{52,44,3},{53,44,3},{54,44,3}
+,{55,44,3},{56,44,3},{57,44,3},{58,44,3},{59,44,3},{60,44,3},{61,44,3},{62,44,3}
+,{63,44,3},{64,44,3},{65,44,3},{66,44,3},{67,44,3},{68,44,3},{69,44,3},{70,44,3}
+,{71,44,3},{72,44,3},{73,44,3},{74,44,3},{75,44,3},{76,44,3},{77,44,3},{78,44,3}
+,{79,44,3},{80,44,3},{81,44,3},{82,44,3},{83,44,3},{84,44,3},{85,44,3},{86,44,3}
+,{87,44,3},{88,44,3},{89,44,3},{90,44,3},{91,44,3},{92,44,3},{93,44,3},{94,44,3}
+,{95,44,3},{96,44,3},{97,44,3},{98,44,3},{99,44,3},{100,44,3},{101,44,3},{102,44,3}
+,{103,44,3},{104,44,3},{105,44,3},{106,44,3},{107,44,3},{108,44,3},{109,44,3},{110,44,3}
+,{111,44,3},{112,44,3},{113,44,3},{114,44,3},{115,44,3},{116,44,3},{117,44,3},{118,44,3}
+,{119,44,3},{120,44,3},{121,44,3},{122,44,3},{123,44,3},{124,44,3},{125,44,3},{126,44,3}
+,{127,44,3},{128,44,3},{129,44,3},{130,44,3},{131,44,3},{132,44,3},{133,44,3},{134,44,3}
+,{135,44,3},{136,44,3},{141,44,3},{142,44,3},{143,44,3},{144,44,3},{145,44,3},{146,44,3}
+,{147,44,3},{-1,44,3},{-2,44,3},{0,45,3},{1,45,3},{2,45,3},{3,45,3},{4,45,3}
+,{5,45,3},{6,45,3},{7,45,3},{8,45,3},{9,45,3},{10,45,3},{11,45,3},{12,45,3}
+,{13,45,3},{14,45,3},{15,45,3},{16,45,3},{17,45,3},{18,45,3},{19,45,3},{20,45,3}
+,{21,45,3},{22,45,3},{23,45,3},{24,45,3},{25,45,3},{26,45,3},{27,45,3},{28,45,3}
+,{29,45,3},{30,45,3},{32,45,3},{33,45,3},{34,45,3},{35,45,3},{36,45,3},{37,45,3}
+,{38,45,3},{39,45,3},{40,45,3},{41,45,3},{42,45,3},{43,45,3},{44,45,3},{45,45,3}
+,{46,45,3},{47,45,3},{48,45,3},{49,45,3},{50,45,3},{51,45,3},{52,45,3},{53,45,3}
+,{54,45,3},{55,45,3},{56,45,3},{57,45,3},{58,45,3},{59,45,3},{60,45,3},{61,45,3}
+,{62,45,3},{63,45,3},{64,45,3},{65,45,3},{66,45,3},{67,45,3},{68,45,3},{69,45,3}
+,{70,45,3},{71,45,3},{72,45,3},{73,45,3},{74,45,3},{75,45,3},{76,45,3},{77,45,3}
+,{78,45,3},{79,45,3},{80,45,3},{81,45,3},{82,45,3},{83,45,3},{84,45,3},{85,45,3}
+,{86,45,3},{87,45,3},{88,45,3},{89,45,3},{90,45,3},{91,45,3},{92,45,3},{93,45,3}
+,{94,45,3},{95,45,3},{96,45,3},{97,45,3},{98,45,3},{99,45,3},{100,45,3},{101,45,3}
+,{102,45,3},{103,45,3},{104,45,3},{105,45,3},{106,45,3},{107,45,3},{108,45,3},{109,45,3}
+,{110,45,3},{111,45,3},{112,45,3},{113,45,3},{114,45,3},{115,45,3},{116,45,3},{117,45,3}
+,{118,45,3},{119,45,3},{120,45,3},{121,45,3},{122,45,3},{123,45,3},{124,45,3},{125,45,3}
+,{126,45,3},{127,45,3},{128,45,3},{129,45,3},{130,45,3},{131,45,3},{132,45,3},{133,45,3}
+,{134,45,3},{135,45,3},{136,45,3},{137,45,3},{140,45,3},{141,45,3},{142,45,3},{147,45,3}
+,{148,45,3},{149,45,3},{150,45,3},{-1,45,3},{-2,45,3},{0,46,3},{1,46,3},{2,46,3}
+,{3,46,3},{4,46,3},{5,46,3},{6,46,3},{7,46,3},{8,46,3},{9,46,3},{10,46,3}
+,{11,46,3},{12,46,3},{13,46,3},{14,46,3},{15,46,3},{16,46,3},{17,46,3},{18,46,3}
+,{19,46,3},{20,46,3},{21,46,3},{22,46,3},{23,46,3},{24,46,3},{25,46,3},{26,46,3}
+,{27,46,3},{28,46,3},{29,46,3},{30,46,3},{31,46,3},{32,46,3},{33,46,3},{34,46,3}
+,{35,46,3},{36,46,3},{37,46,3},{38,46,3},{39,46,3},{40,46,3},{41,46,3},{42,46,3}
+,{43,46,3},{44,46,3},{45,46,3},{46,46,3},{47,46,3},{48,46,3},{49,46,3},{50,46,3}
+,{51,46,3},{52,46,3},{53,46,3},{54,46,3},{55,46,3},{56,46,3},{57,46,3},{58,46,3}
+,{59,46,3},{60,46,3},{61,46,3},{62,46,3},{63,46,3},{64,46,3},{65,46,3},{66,46,3}
+,{67,46,3},{68,46,3},{69,46,3},{70,46,3},{71,46,3},{72,46,3},{73,46,3},{74,46,3}
+,{75,46,3},{76,46,3},{77,46,3},{78,46,3},{79,46,3},{80,46,3},{81,46,3},{82,46,3}
+,{83,46,3},{84,46,3},{85,46,3},{86,46,3},{87,46,3},{88,46,3},{89,46,3},{90,46,3}
+,{91,46,3},{92,46,3},{93,46,3},{94,46,3},{95,46,3},{96,46,3},{97,46,3},{98,46,3}
+,{99,46,3},{100,46,3},{101,46,3},{102,46,3},{103,46,3},{104,46,3},{105,46,3},{106,46,3}
+,{107,46,3},{108,46,3},{109,46,3},{110,46,3},{111,46,3},{112,46,3},{113,46,3},{114,46,3}
+,{115,46,3},{116,46,3},{117,46,3},{118,46,3},{119,46,3},{120,46,3},{121,46,3},{122,46,3}
+,{123,46,3},{124,46,3},{125,46,3},{126,46,3},{127,46,3},{128,46,3},{129,46,3},{130,46,3}
+,{131,46,3},{132,46,3},{133,46,3},{134,46,3},{135,46,3},{136,46,3},{137,46,3},{138,46,3}
+,{141,46,3},{142,46,3},{143,46,3},{149,46,3},{150,46,3},{151,46,3},{152,46,3},{-1,46,3}
+,{-2,46,3},{-3,46,3},{0,47,3},{1,47,3},{2,47,3},{3,47,3},{4,47,3},{5,47,3}
+,{6,47,3},{7,47,3},{8,47,3},{9,47,3},{10,47,3},{11,47,3},{12,47,3},{13,47,3}
+,{14,47,3},{15,47,3},{16,47,3},{17,47,3},{18,47,3},{19,47,3},{20,47,3},{21,47,3}
+,{22,47,3},{23,47,3},{24,47,3},{25,47,3},{26,47,3},{27,47,3},{28,47,3},{29,47,3}
+,{30,47,3},{31,47,3},{32,47,3},{33,47,3},{34,47,3},{35,47,3},{36,47,3},{37,47,3}
+,{38,47,3},{39,47,3},{40,47,3},{41,47,3},{42,47,3},{43,47,3},{44,47,3},{45,47,3}
+,{46,47,3},{47,47,3},{48,47,3},{49,47,3},{50,47,3},{51,47,3},{52,47,3},{53,47,3}
+,{54,47,3},{55,47,3},{56,47,3},{57,47,3},{58,47,3},{59,47,3},{60,47,3},{61,47,3}
+,{62,47,3},{63,47,3},{64,47,3},{65,47,3},{66,47,3},{67,47,3},{68,47,3},{69,47,3}
+,{70,47,3},{71,47,3},{72,47,3},{73,47,3},{74,47,3},{75,47,3},{76,47,3},{77,47,3}
+,{78,47,3},{79,47,3},{80,47,3},{81,47,3},{82,47,3},{83,47,3},{84,47,3},{85,47,3}
+,{86,47,3},{87,47,3},{88,47,3},{89,47,3},{90,47,3},{91,47,3},{92,47,3},{93,47,3}
+,{94,47,3},{95,47,3},{96,47,3},{97,47,3},{98,47,3},{99,47,3},{100,47,3},{101,47,3}
+,{102,47,3},{103,47,3},{104,47,3},{105,47,3},{106,47,3},{107,47,3},{108,47,3},{109,47,3}
+,{110,47,3},{111,47,3},{112,47,3},{113,47,3},{114,47,3},{115,47,3},{116,47,3},{117,47,3}
+,{118,47,3},{119,47,3},{120,47,3},{121,47,3},{122,47,3},{123,47,3},{124,47,3},{125,47,3}
+,{126,47,3},{127,47,3},{128,47,3},{129,47,3},{130,47,3},{131,47,3},{132,47,3},{133,47,3}
+,{134,47,3},{135,47,3},{136,47,3},{137,47,3},{138,47,3},{139,47,3},{141,47,3},{142,47,3}
+,{143,47,3},{152,47,3},{153,47,3},{-1,47,3},{-2,47,3},{-3,47,3},{-4,47,3},{-5,47,3}
+,{0,48,3},{1,48,3},{2,48,3},{3,48,3},{4,48,3},{5,48,3},{6,48,3},{7,48,3}
+,{8,48,3},{9,48,3},{10,48,3},{11,48,3},{12,48,3},{13,48,3},{14,48,3},{15,48,3}
+,{16,48,3},{17,48,3},{18,48,3},{19,48,3},{20,48,3},{21,48,3},{22,48,3},{23,48,3}
+,{24,48,3},{25,48,3},{26,48,3},{27,48,3},{28,48,3},{29,48,3},{30,48,3},{31,48,3}
+,{32,48,3},{33,48,3},{34,48,3},{35,48,3},{36,48,3},{37,48,3},{38,48,3},{39,48,3}
+,{40,48,3},{41,48,3},{42,48,3},{43,48,3},{44,48,3},{45,48,3},{46,48,3},{47,48,3}
+,{48,48,3},{49,48,3},{50,48,3},{51,48,3},{52,48,3},{53,48,3},{54,48,3},{55,48,3}
+,{56,48,3},{57,48,3},{58,48,3},{59,48,3},{60,48,3},{61,48,3},{62,48,3},{63,48,3}
+,{64,48,3},{65,48,3},{66,48,3},{67,48,3},{68,48,3},{69,48,3},{70,48,3},{71,48,3}
+,{72,48,3},{73,48,3},{74,48,3},{75,48,3},{76,48,3},{77,48,3},{78,48,3},{79,48,3}
+,{80,48,3},{81,48,3},{82,48,3},{83,48,3},{84,48,3},{85,48,3},{86,48,3},{87,48,3}
+,{88,48,3},{89,48,3},{90,48,3},{91,48,3},{92,48,3},{93,48,3},{94,48,3},{95,48,3}
+,{96,48,3},{97,48,3},{98,48,3},{99,48,3},{100,48,3},{101,48,3},{102,48,3},{103,48,3}
+,{104,48,3},{105,48,3},{106,48,3},{107,48,3},{108,48,3},{109,48,3},{110,48,3},{111,48,3}
+,{112,48,3},{113,48,3},{114,48,3},{115,48,3},{116,48,3},{117,48,3},{118,48,3},{119,48,3}
+,{120,48,3},{121,48,3},{122,48,3},{123,48,3},{124,48,3},{125,48,3},{126,48,3},{127,48,3}
+,{128,48,3},{129,48,3},{130,48,3},{131,48,3},{132,48,3},{133,48,3},{134,48,3},{135,48,3}
+,{136,48,3},{137,48,3},{138,48,3},{139,48,3},{140,48,3},{141,48,3},{142,48,3},{144,48,3}
+,{153,48,3},{154,48,3},{-1,48,3},{-2,48,3},{-3,48,3},{-4,48,3},{-5,48,3},{-6,48,3}
+,{0,49,3},{1,49,3},{2,49,3},{3,49,3},{4,49,3},{5,49,3},{6,49,3},{7,49,3}
+,{8,49,3},{9,49,3},{10,49,3},{11,49,3},{12,49,3},{13,49,3},{14,49,3},{15,49,3}
+,{16,49,3},{17,49,3},{18,49,3},{19,49,3},{20,49,3},{21,49,3},{22,49,3},{23,49,3}
+,{24,49,3},{25,49,3},{26,49,3},{27,49,3},{28,49,3},{29,49,3},{30,49,3},{31,49,3}
+,{32,49,3},{33,49,3},{34,49,3},{35,49,3},{36,49,3},{37,49,3},{38,49,3},{39,49,3}
+,{40,49,3},{41,49,3},{42,49,3},{43,49,3},{44,49,3},{45,49,3},{46,49,3},{47,49,3}
+,{48,49,3},{49,49,3},{50,49,3},{51,49,3},{52,49,3},{53,49,3},{54,49,3},{55,49,3}
+,{56,49,3},{57,49,3},{58,49,3},{59,49,3},{60,49,3},{61,49,3},{62,49,3},{63,49,3}
+,{64,49,3},{65,49,3},{66,49,3},{67,49,3},{68,49,3},{69,49,3},{70,49,3},{71,49,3}
+,{72,49,3},{73,49,3},{74,49,3},{75,49,3},{76,49,3},{77,49,3},{78,49,3},{79,49,3}
+,{80,49,3},{81,49,3},{82,49,3},{83,49,3},{84,49,3},{85,49,3},{86,49,3},{87,49,3}
+,{88,49,3},{89,49,3},{90,49,3},{91,49,3},{92,49,3},{93,49,3},{94,49,3},{95,49,3}
+,{96,49,3},{97,49,3},{98,49,3},{99,49,3},{100,49,3},{101,49,3},{102,49,3},{103,49,3}
+,{104,49,3},{105,49,3},{106,49,3},{107,49,3},{108,49,3},{109,49,3},{110,49,3},{111,49,3}
+,{112,49,3},{113,49,3},{114,49,3},{115,49,3},{116,49,3},{117,49,3},{118,49,3},{119,49,3}
+,{120,49,3},{121,49,3},{122,49,3},{123,49,3},{124,49,3},{125,49,3},{126,49,3},{127,49,3}
+,{128,49,3},{129,49,3},{130,49,3},{131,49,3},{132,49,3},{133,49,3},{134,49,3},{135,49,3}
+,{136,49,3},{137,49,3},{138,49,3},{139,49,3},{140,49,3},{142,49,3},{143,49,3},{144,49,3}
+,{154,49,3},{155,49,3},{-1,49,3},{-2,49,3},{-3,49,3},{-6,49,3},{-7,49,3},{0,50,3}
+,{1,50,3},{2,50,3},{3,50,3},{4,50,3},{5,50,3},{6,50,3},{7,50,3},{8,50,3}
+,{9,50,3},{10,50,3},{11,50,3},{12,50,3},{13,50,3},{14,50,3},{15,50,3},{16,50,3}
+,{17,50,3},{18,50,3},{19,50,3},{20,50,3},{21,50,3},{22,50,3},{23,50,3},{24,50,3}
+,{25,50,3},{26,50,3},{27,50,3},{28,50,3},{29,50,3},{30,50,3},{31,50,3},{32,50,3}
+,{33,50,3},{34,50,3},{35,50,3},{36,50,3},{37,50,3},{38,50,3},{39,50,3},{40,50,3}
+,{41,50,3},{42,50,3},{43,50,3},{44,50,3},{45,50,3},{46,50,3},{47,50,3},{48,50,3}
+,{49,50,3},{50,50,3},{51,50,3},{52,50,3},{53,50,3},{54,50,3},{55,50,3},{56,50,3}
+,{57,50,3},{58,50,3},{59,50,3},{60,50,3},{61,50,3},{62,50,3},{63,50,3},{64,50,3}
+,{65,50,3},{66,50,3},{67,50,3},{68,50,3},{69,50,3},{70,50,3},{71,50,3},{72,50,3}
+,{73,50,3},{74,50,3},{75,50,3},{76,50,3},{77,50,3},{78,50,3},{79,50,3},{80,50,3}
+,{81,50,3},{82,50,3},{83,50,3},{84,50,3},{85,50,3},{86,50,3},{87,50,3},{88,50,3}
+,{89,50,3},{90,50,3},{91,50,3},{92,50,3},{93,50,3},{94,50,3},{95,50,3},{96,50,3}
+,{97,50,3},{98,50,3},{99,50,3},{100,50,3},{101,50,3},{102,50,3},{103,50,3},{104,50,3}
+,{105,50,3},{106,50,3},{107,50,3},{108,50,3},{109,50,3},{110,50,3},{111,50,3},{112,50,3}
+,{113,50,3},{114,50,3},{115,50,3},{116,50,3},{117,50,3},{118,50,3},{119,50,3},{120,50,3}
+,{121,50,3},{122,50,3},{123,50,3},{124,50,3},{125,50,3},{126,50,3},{127,50,3},{128,50,3}
+,{129,50,3},{130,50,3},{131,50,3},{132,50,3},{133,50,3},{134,50,3},{135,50,3},{136,50,3}
+,{137,50,3},{138,50,3},{139,50,3},{140,50,3},{142,50,3},{143,50,3},{154,50,3},{155,50,3}
+,{156,50,3},{-1,50,3},{-2,50,3},{-3,50,3},{-4,50,3},{-5,50,3},{-6,50,3},{0,51,3}
+,{1,51,3},{2,51,3},{3,51,3},{4,51,3},{5,51,3},{6,51,3},{7,51,3},{8,51,3}
+,{9,51,3},{10,51,3},{11,51,3},{12,51,3},{13,51,3},{14,51,3},{15,51,3},{16,51,3}
+,{17,51,3},{18,51,3},{19,51,3},{20,51,3},{21,51,3},{22,51,3},{23,51,3},{24,51,3}
+,{25,51,3},{26,51,3},{27,51,3},{28,51,3},{29,51,3},{30,51,3},{31,51,3},{32,51,3}
+,{33,51,3},{34,51,3},{35,51,3},{36,51,3},{37,51,3},{38,51,3},{39,51,3},{40,51,3}
+,{41,51,3},{42,51,3},{43,51,3},{44,51,3},{45,51,3},{46,51,3},{47,51,3},{48,51,3}
+,{49,51,3},{50,51,3},{51,51,3},{52,51,3},{53,51,3},{54,51,3},{55,51,3},{56,51,3}
+,{57,51,3},{58,51,3},{59,51,3},{60,51,3},{61,51,3},{62,51,3},{63,51,3},{64,51,3}
+,{65,51,3},{66,51,3},{67,51,3},{68,51,3},{69,51,3},{70,51,3},{71,51,3},{72,51,3}
+,{73,51,3},{74,51,3},{75,51,3},{76,51,3},{77,51,3},{78,51,3},{79,51,3},{80,51,3}
+,{81,51,3},{82,51,3},{83,51,3},{84,51,3},{85,51,3},{86,51,3},{87,51,3},{88,51,3}
+,{89,51,3},{90,51,3},{91,51,3},{92,51,3},{93,51,3},{94,51,3},{95,51,3},{96,51,3}
+,{97,51,3},{98,51,3},{99,51,3},{100,51,3},{101,51,3},{102,51,3},{103,51,3},{104,51,3}
+,{105,51,3},{106,51,3},{107,51,3},{108,51,3},{109,51,3},{110,51,3},{111,51,3},{112,51,3}
+,{113,51,3},{114,51,3},{115,51,3},{116,51,3},{117,51,3},{118,51,3},{119,51,3},{120,51,3}
+,{121,51,3},{122,51,3},{123,51,3},{124,51,3},{125,51,3},{126,51,3},{127,51,3},{128,51,3}
+,{129,51,3},{130,51,3},{131,51,3},{132,51,3},{133,51,3},{134,51,3},{135,51,3},{136,51,3}
+,{137,51,3},{138,51,3},{139,51,3},{140,51,3},{141,51,3},{142,51,3},{143,51,3},{156,51,3}
+,{157,51,3},{158,51,3},{-1,51,3},{-2,51,3},{-3,51,3},{-4,51,3},{-5,51,3},{-6,51,3}
+,{-8,51,3},{-9,51,3},{-10,51,3},{-11,51,3},{0,52,3},{1,52,3},{4,52,3},{5,52,3}
+,{6,52,3},{7,52,3},{8,52,3},{9,52,3},{10,52,3},{11,52,3},{12,52,3},{13,52,3}
+,{14,52,3},{15,52,3},{16,52,3},{17,52,3},{18,52,3},{19,52,3},{20,52,3},{21,52,3}
+,{22,52,3},{23,52,3},{24,52,3},{25,52,3},{26,52,3},{27,52,3},{28,52,3},{29,52,3}
+,{30,52,3},{31,52,3},{32,52,3},{33,52,3},{34,52,3},{35,52,3},{36,52,3},{37,52,3}
+,{38,52,3},{39,52,3},{40,52,3},{41,52,3},{42,52,3},{43,52,3},{44,52,3},{45,52,3}
+,{46,52,3},{47,52,3},{48,52,3},{49,52,3},{50,52,3},{51,52,3},{52,52,3},{53,52,3}
+,{54,52,3},{55,52,3},{56,52,3},{57,52,3},{58,52,3},{59,52,3},{60,52,3},{61,52,3}
+,{62,52,3},{63,52,3},{64,52,3},{65,52,3},{66,52,3},{67,52,3},{68,52,3},{69,52,3}
+,{70,52,3},{71,52,3},{72,52,3},{73,52,3},{74,52,3},{75,52,3},{76,52,3},{77,52,3}
+,{78,52,3},{79,52,3},{80,52,3},{81,52,3},{82,52,3},{83,52,3},{84,52,3},{85,52,3}
+,{86,52,3},{87,52,3},{88,52,3},{89,52,3},{90,52,3},{91,52,3},{92,52,3},{93,52,3}
+,{94,52,3},{95,52,3},{96,52,3},{97,52,3},{98,52,3},{99,52,3},{100,52,3},{101,52,3}
+,{102,52,3},{103,52,3},{104,52,3},{105,52,3},{106,52,3},{107,52,3},{108,52,3},{109,52,3}
+,{110,52,3},{111,52,3},{112,52,3},{113,52,3},{114,52,3},{115,52,3},{116,52,3},{117,52,3}
+,{118,52,3},{119,52,3},{120,52,3},{121,52,3},{122,52,3},{123,52,3},{124,52,3},{125,52,3}
+,{126,52,3},{127,52,3},{128,52,3},{129,52,3},{130,52,3},{131,52,3},{132,52,3},{133,52,3}
+,{134,52,3},{135,52,3},{136,52,3},{137,52,3},{138,52,3},{139,52,3},{140,52,3},{141,52,3}
+,{142,52,3},{143,52,3},{156,52,3},{157,52,3},{158,52,3},{-1,52,3},{-2,52,3},{-3,52,3}
+,{-4,52,3},{-5,52,3},{-6,52,3},{-7,52,3},{-8,52,3},{-9,52,3},{-10,52,3},{-11,52,3}
+,{0,53,3},{4,53,3},{5,53,3},{6,53,3},{7,53,3},{8,53,3},{9,53,3},{10,53,3}
+,{11,53,3},{12,53,3},{13,53,3},{14,53,3},{15,53,3},{16,53,3},{17,53,3},{18,53,3}
+,{19,53,3},{20,53,3},{21,53,3},{22,53,3},{23,53,3},{24,53,3},{25,53,3},{26,53,3}
+,{27,53,3},{28,53,3},{29,53,3},{30,53,3},{31,53,3},{32,53,3},{33,53,3},{34,53,3}
+,{35,53,3},{36,53,3},{37,53,3},{38,53,3},{39,53,3},{40,53,3},{41,53,3},{42,53,3}
+,{43,53,3},{44,53,3},{45,53,3},{46,53,3},{47,53,3},{48,53,3},{49,53,3},{50,53,3}
+,{51,53,3},{52,53,3},{53,53,3},{54,53,3},{55,53,3},{56,53,3},{57,53,3},{58,53,3}
+,{59,53,3},{60,53,3},{61,53,3},{62,53,3},{63,53,3},{64,53,3},{65,53,3},{66,53,3}
+,{67,53,3},{68,53,3},{69,53,3},{70,53,3},{71,53,3},{72,53,3},{73,53,3},{74,53,3}
+,{75,53,3},{76,53,3},{77,53,3},{78,53,3},{79,53,3},{80,53,3},{81,53,3},{82,53,3}
+,{83,53,3},{84,53,3},{85,53,3},{86,53,3},{87,53,3},{88,53,3},{89,53,3},{90,53,3}
+,{91,53,3},{92,53,3},{93,53,3},{94,53,3},{95,53,3},{96,53,3},{97,53,3},{98,53,3}
+,{99,53,3},{100,53,3},{101,53,3},{102,53,3},{103,53,3},{104,53,3},{105,53,3},{106,53,3}
+,{107,53,3},{108,53,3},{109,53,3},{110,53,3},{111,53,3},{112,53,3},{113,53,3},{114,53,3}
+,{115,53,3},{116,53,3},{117,53,3},{118,53,3},{119,53,3},{120,53,3},{121,53,3},{122,53,3}
+,{123,53,3},{124,53,3},{125,53,3},{126,53,3},{127,53,3},{128,53,3},{129,53,3},{130,53,3}
+,{131,53,3},{132,53,3},{133,53,3},{134,53,3},{135,53,3},{136,53,3},{137,53,3},{138,53,3}
+,{139,53,3},{140,53,3},{141,53,3},{142,53,3},{143,53,3},{155,53,3},{156,53,3},{157,53,3}
+,{158,53,3},{159,53,3},{160,53,3},{-1,53,3},{-2,53,3},{-3,53,3},{-4,53,3},{-5,53,3}
+,{-6,53,3},{-7,53,3},{-8,53,3},{-9,53,3},{-10,53,3},{-11,53,3},{7,54,3},{8,54,3}
+,{9,54,3},{10,54,3},{11,54,3},{12,54,3},{13,54,3},{14,54,3},{15,54,3},{16,54,3}
+,{17,54,3},{18,54,3},{19,54,3},{20,54,3},{21,54,3},{22,54,3},{23,54,3},{24,54,3}
+,{25,54,3},{26,54,3},{27,54,3},{28,54,3},{29,54,3},{30,54,3},{31,54,3},{32,54,3}
+,{33,54,3},{34,54,3},{35,54,3},{36,54,3},{37,54,3},{38,54,3},{39,54,3},{40,54,3}
+,{41,54,3},{42,54,3},{43,54,3},{44,54,3},{45,54,3},{46,54,3},{47,54,3},{48,54,3}
+,{49,54,3},{50,54,3},{51,54,3},{52,54,3},{53,54,3},{54,54,3},{55,54,3},{56,54,3}
+,{57,54,3},{58,54,3},{59,54,3},{60,54,3},{61,54,3},{62,54,3},{63,54,3},{64,54,3}
+,{65,54,3},{66,54,3},{67,54,3},{68,54,3},{69,54,3},{70,54,3},{71,54,3},{72,54,3}
+,{73,54,3},{74,54,3},{75,54,3},{76,54,3},{77,54,3},{78,54,3},{79,54,3},{80,54,3}
+,{81,54,3},{82,54,3},{83,54,3},{84,54,3},{85,54,3},{86,54,3},{87,54,3},{88,54,3}
+,{89,54,3},{90,54,3},{91,54,3},{92,54,3},{93,54,3},{94,54,3},{95,54,3},{96,54,3}
+,{97,54,3},{98,54,3},{99,54,3},{100,54,3},{101,54,3},{102,54,3},{103,54,3},{104,54,3}
+,{105,54,3},{106,54,3},{107,54,3},{108,54,3},{109,54,3},{110,54,3},{111,54,3},{112,54,3}
+,{113,54,3},{114,54,3},{115,54,3},{116,54,3},{117,54,3},{118,54,3},{119,54,3},{120,54,3}
+,{121,54,3},{122,54,3},{123,54,3},{124,54,3},{125,54,3},{126,54,3},{127,54,3},{128,54,3}
+,{129,54,3},{130,54,3},{131,54,3},{132,54,3},{133,54,3},{134,54,3},{135,54,3},{136,54,3}
+,{137,54,3},{138,54,3},{139,54,3},{140,54,3},{142,54,3},{155,54,3},{156,54,3},{157,54,3}
+,{158,54,3},{159,54,3},{160,54,3},{161,54,3},{162,54,3},{166,54,3},{167,54,3},{168,54,3}
+,{-1,54,3},{-2,54,3},{-3,54,3},{-4,54,3},{-5,54,3},{-6,54,3},{-7,54,3},{-8,54,3}
+,{-9,54,3},{-10,54,3},{-11,54,3},{8,55,3},{9,55,3},{10,55,3},{11,55,3},{12,55,3}
+,{13,55,3},{14,55,3},{15,55,3},{20,55,3},{21,55,3},{22,55,3},{23,55,3},{24,55,3}
+,{25,55,3},{26,55,3},{27,55,3},{28,55,3},{29,55,3},{30,55,3},{31,55,3},{32,55,3}
+,{33,55,3},{34,55,3},{35,55,3},{36,55,3},{37,55,3},{38,55,3},{39,55,3},{40,55,3}
+,{41,55,3},{42,55,3},{43,55,3},{44,55,3},{45,55,3},{46,55,3},{47,55,3},{48,55,3}
+,{49,55,3},{50,55,3},{51,55,3},{52,55,3},{53,55,3},{54,55,3},{55,55,3},{56,55,3}
+,{57,55,3},{58,55,3},{59,55,3},{60,55,3},{61,55,3},{62,55,3},{63,55,3},{64,55,3}
+,{65,55,3},{66,55,3},{67,55,3},{68,55,3},{69,55,3},{70,55,3},{71,55,3},{72,55,3}
+,{73,55,3},{74,55,3},{75,55,3},{76,55,3},{77,55,3},{78,55,3},{79,55,3},{80,55,3}
+,{81,55,3},{82,55,3},{83,55,3},{84,55,3},{85,55,3},{86,55,3},{87,55,3},{88,55,3}
+,{89,55,3},{90,55,3},{91,55,3},{92,55,3},{93,55,3},{94,55,3},{95,55,3},{96,55,3}
+,{97,55,3},{98,55,3},{99,55,3},{100,55,3},{101,55,3},{102,55,3},{103,55,3},{104,55,3}
+,{105,55,3},{106,55,3},{107,55,3},{108,55,3},{109,55,3},{110,55,3},{111,55,3},{112,55,3}
+,{113,55,3},{114,55,3},{115,55,3},{116,55,3},{117,55,3},{118,55,3},{119,55,3},{120,55,3}
+,{121,55,3},{122,55,3},{123,55,3},{124,55,3},{125,55,3},{126,55,3},{127,55,3},{128,55,3}
+,{129,55,3},{130,55,3},{131,55,3},{132,55,3},{133,55,3},{134,55,3},{135,55,3},{136,55,3}
+,{137,55,3},{138,55,3},{155,55,3},{156,55,3},{157,55,3},{158,55,3},{159,55,3},{160,55,3}
+,{161,55,3},{162,55,3},{165,55,3},{166,55,3},{-2,55,3},{-3,55,3},{-4,55,3},{-5,55,3}
+,{-6,55,3},{-7,55,3},{-8,55,3},{-9,55,3},{8,56,3},{9,56,3},{10,56,3},{11,56,3}
+,{12,56,3},{13,56,3},{14,56,3},{15,56,3},{16,56,3},{18,56,3},{20,56,3},{21,56,3}
+,{22,56,3},{23,56,3},{24,56,3},{25,56,3},{26,56,3},{27,56,3},{28,56,3},{29,56,3}
+,{30,56,3},{31,56,3},{32,56,3},{33,56,3},{34,56,3},{35,56,3},{36,56,3},{37,56,3}
+,{38,56,3},{39,56,3},{40,56,3},{41,56,3},{42,56,3},{43,56,3},{44,56,3},{45,56,3}
+,{46,56,3},{47,56,3},{48,56,3},{49,56,3},{50,56,3},{51,56,3},{52,56,3},{53,56,3}
+,{54,56,3},{55,56,3},{56,56,3},{57,56,3},{58,56,3},{59,56,3},{60,56,3},{61,56,3}
+,{62,56,3},{63,56,3},{64,56,3},{65,56,3},{66,56,3},{67,56,3},{68,56,3},{69,56,3}
+,{70,56,3},{71,56,3},{72,56,3},{73,56,3},{74,56,3},{75,56,3},{76,56,3},{77,56,3}
+,{78,56,3},{79,56,3},{80,56,3},{81,56,3},{82,56,3},{83,56,3},{84,56,3},{85,56,3}
+,{86,56,3},{87,56,3},{88,56,3},{89,56,3},{90,56,3},{91,56,3},{92,56,3},{93,56,3}
+,{94,56,3},{95,56,3},{96,56,3},{97,56,3},{98,56,3},{99,56,3},{100,56,3},{101,56,3}
+,{102,56,3},{103,56,3},{104,56,3},{105,56,3},{106,56,3},{107,56,3},{108,56,3},{109,56,3}
+,{110,56,3},{111,56,3},{112,56,3},{113,56,3},{114,56,3},{115,56,3},{116,56,3},{117,56,3}
+,{118,56,3},{119,56,3},{120,56,3},{121,56,3},{122,56,3},{123,56,3},{124,56,3},{125,56,3}
+,{126,56,3},{127,56,3},{128,56,3},{129,56,3},{130,56,3},{131,56,3},{132,56,3},{133,56,3}
+,{134,56,3},{135,56,3},{136,56,3},{137,56,3},{138,56,3},{143,56,3},{155,56,3},{156,56,3}
+,{157,56,3},{158,56,3},{159,56,3},{160,56,3},{161,56,3},{162,56,3},{163,56,3},{-3,56,3}
+,{-4,56,3},{-5,56,3},{-6,56,3},{-7,56,3},{-8,56,3},{6,57,3},{7,57,3},{8,57,3}
+,{9,57,3},{10,57,3},{11,57,3},{12,57,3},{13,57,3},{14,57,3},{15,57,3},{16,57,3}
+,{17,57,3},{18,57,3},{19,57,3},{21,57,3},{22,57,3},{23,57,3},{24,57,3},{25,57,3}
+,{26,57,3},{27,57,3},{28,57,3},{29,57,3},{30,57,3},{31,57,3},{32,57,3},{33,57,3}
+,{34,57,3},{35,57,3},{36,57,3},{37,57,3},{38,57,3},{39,57,3},{40,57,3},{41,57,3}
+,{42,57,3},{43,57,3},{44,57,3},{45,57,3},{46,57,3},{47,57,3},{48,57,3},{49,57,3}
+,{50,57,3},{51,57,3},{52,57,3},{53,57,3},{54,57,3},{55,57,3},{56,57,3},{57,57,3}
+,{58,57,3},{59,57,3},{60,57,3},{61,57,3},{62,57,3},{63,57,3},{64,57,3},{65,57,3}
+,{66,57,3},{67,57,3},{68,57,3},{69,57,3},{70,57,3},{71,57,3},{72,57,3},{73,57,3}
+,{74,57,3},{75,57,3},{76,57,3},{77,57,3},{78,57,3},{79,57,3},{80,57,3},{81,57,3}
+,{82,57,3},{83,57,3},{84,57,3},{85,57,3},{86,57,3},{87,57,3},{88,57,3},{89,57,3}
+,{90,57,3},{91,57,3},{92,57,3},{93,57,3},{94,57,3},{95,57,3},{96,57,3},{97,57,3}
+,{98,57,3},{99,57,3},{100,57,3},{101,57,3},{102,57,3},{103,57,3},{104,57,3},{105,57,3}
+,{106,57,3},{107,57,3},{108,57,3},{109,57,3},{110,57,3},{111,57,3},{112,57,3},{113,57,3}
+,{114,57,3},{115,57,3},{116,57,3},{117,57,3},{118,57,3},{119,57,3},{120,57,3},{121,57,3}
+,{122,57,3},{123,57,3},{124,57,3},{125,57,3},{126,57,3},{127,57,3},{128,57,3},{129,57,3}
+,{130,57,3},{131,57,3},{132,57,3},{133,57,3},{134,57,3},{135,57,3},{136,57,3},{137,57,3}
+,{138,57,3},{139,57,3},{140,57,3},{156,57,3},{157,57,3},{158,57,3},{159,57,3},{160,57,3}
+,{161,57,3},{162,57,3},{163,57,3},{-2,57,3},{-3,57,3},{-4,57,3},{-5,57,3},{-6,57,3}
+,{-7,57,3},{-8,57,3},{-9,57,3},{-14,57,3},{5,58,3},{6,58,3},{7,58,3},{8,58,3}
+,{9,58,3},{10,58,3},{11,58,3},{12,58,3},{13,58,3},{14,58,3},{15,58,3},{16,58,3}
+,{17,58,3},{18,58,3},{19,58,3},{21,58,3},{22,58,3},{23,58,3},{24,58,3},{25,58,3}
+,{26,58,3},{27,58,3},{28,58,3},{29,58,3},{30,58,3},{31,58,3},{32,58,3},{33,58,3}
+,{34,58,3},{35,58,3},{36,58,3},{37,58,3},{38,58,3},{39,58,3},{40,58,3},{41,58,3}
+,{42,58,3},{43,58,3},{44,58,3},{45,58,3},{46,58,3},{47,58,3},{48,58,3},{49,58,3}
+,{50,58,3},{51,58,3},{52,58,3},{53,58,3},{54,58,3},{55,58,3},{56,58,3},{57,58,3}
+,{58,58,3},{59,58,3},{60,58,3},{61,58,3},{62,58,3},{63,58,3},{64,58,3},{65,58,3}
+,{66,58,3},{67,58,3},{68,58,3},{69,58,3},{70,58,3},{71,58,3},{72,58,3},{73,58,3}
+,{74,58,3},{75,58,3},{76,58,3},{77,58,3},{78,58,3},{79,58,3},{80,58,3},{81,58,3}
+,{82,58,3},{83,58,3},{84,58,3},{85,58,3},{86,58,3},{87,58,3},{88,58,3},{89,58,3}
+,{90,58,3},{91,58,3},{92,58,3},{93,58,3},{94,58,3},{95,58,3},{96,58,3},{97,58,3}
+,{98,58,3},{99,58,3},{100,58,3},{101,58,3},{102,58,3},{103,58,3},{104,58,3},{105,58,3}
+,{106,58,3},{107,58,3},{108,58,3},{109,58,3},{110,58,3},{111,58,3},{112,58,3},{113,58,3}
+,{114,58,3},{115,58,3},{116,58,3},{117,58,3},{118,58,3},{119,58,3},{120,58,3},{121,58,3}
+,{122,58,3},{123,58,3},{124,58,3},{125,58,3},{126,58,3},{127,58,3},{128,58,3},{129,58,3}
+,{130,58,3},{131,58,3},{132,58,3},{133,58,3},{134,58,3},{135,58,3},{136,58,3},{137,58,3}
+,{138,58,3},{139,58,3},{140,58,3},{141,58,3},{142,58,3},{150,58,3},{151,58,3},{152,58,3}
+,{157,58,3},{158,58,3},{159,58,3},{160,58,3},{161,58,3},{162,58,3},{163,58,3},{164,58,3}
+,{-3,58,3},{-4,58,3},{-5,58,3},{-6,58,3},{-7,58,3},{-8,58,3},{4,59,3},{5,59,3}
+,{6,59,3},{7,59,3},{8,59,3},{9,59,3},{10,59,3},{11,59,3},{12,59,3},{13,59,3}
+,{14,59,3},{15,59,3},{16,59,3},{17,59,3},{18,59,3},{19,59,3},{20,59,3},{21,59,3}
+,{22,59,3},{23,59,3},{24,59,3},{25,59,3},{26,59,3},{27,59,3},{28,59,3},{29,59,3}
+,{30,59,3},{31,59,3},{32,59,3},{33,59,3},{34,59,3},{35,59,3},{36,59,3},{37,59,3}
+,{38,59,3},{39,59,3},{40,59,3},{41,59,3},{42,59,3},{43,59,3},{44,59,3},{45,59,3}
+,{46,59,3},{47,59,3},{48,59,3},{49,59,3},{50,59,3},{51,59,3},{52,59,3},{53,59,3}
+,{54,59,3},{55,59,3},{56,59,3},{57,59,3},{58,59,3},{59,59,3},{60,59,3},{61,59,3}
+,{62,59,3},{63,59,3},{64,59,3},{65,59,3},{66,59,3},{67,59,3},{68,59,3},{69,59,3}
+,{70,59,3},{71,59,3},{72,59,3},{73,59,3},{74,59,3},{75,59,3},{76,59,3},{77,59,3}
+,{78,59,3},{79,59,3},{80,59,3},{81,59,3},{82,59,3},{83,59,3},{84,59,3},{85,59,3}
+,{86,59,3},{87,59,3},{88,59,3},{89,59,3},{90,59,3},{91,59,3},{92,59,3},{93,59,3}
+,{94,59,3},{95,59,3},{96,59,3},{97,59,3},{98,59,3},{99,59,3},{100,59,3},{101,59,3}
+,{102,59,3},{103,59,3},{104,59,3},{105,59,3},{106,59,3},{107,59,3},{108,59,3},{109,59,3}
+,{110,59,3},{111,59,3},{112,59,3},{113,59,3},{114,59,3},{115,59,3},{116,59,3},{117,59,3}
+,{118,59,3},{119,59,3},{120,59,3},{121,59,3},{122,59,3},{123,59,3},{124,59,3},{125,59,3}
+,{126,59,3},{127,59,3},{128,59,3},{129,59,3},{130,59,3},{131,59,3},{132,59,3},{133,59,3}
+,{134,59,3},{135,59,3},{136,59,3},{137,59,3},{138,59,3},{139,59,3},{140,59,3},{141,59,3}
+,{142,59,3},{143,59,3},{144,59,3},{145,59,3},{146,59,3},{147,59,3},{148,59,3},{149,59,3}
+,{150,59,3},{151,59,3},{152,59,3},{153,59,3},{154,59,3},{155,59,3},{159,59,3},{160,59,3}
+,{161,59,3},{162,59,3},{163,59,3},{164,59,3},{165,59,3},{166,59,3},{-2,59,3},{-3,59,3}
+,{-4,59,3},{-5,59,3},{-6,59,3},{-7,59,3},{4,60,3},{5,60,3},{6,60,3},{7,60,3}
+,{8,60,3},{9,60,3},{10,60,3},{11,60,3},{12,60,3},{13,60,3},{14,60,3},{15,60,3}
+,{16,60,3},{17,60,3},{18,60,3},{19,60,3},{20,60,3},{21,60,3},{22,60,3},{23,60,3}
+,{24,60,3},{25,60,3},{26,60,3},{27,60,3},{28,60,3},{29,60,3},{30,60,3},{31,60,3}
+,{32,60,3},{33,60,3},{34,60,3},{35,60,3},{36,60,3},{37,60,3},{38,60,3},{39,60,3}
+,{40,60,3},{41,60,3},{42,60,3},{43,60,3},{44,60,3},{45,60,3},{46,60,3},{47,60,3}
+,{48,60,3},{49,60,3},{50,60,3},{51,60,3},{52,60,3},{53,60,3},{54,60,3},{55,60,3}
+,{56,60,3},{57,60,3},{58,60,3},{59,60,3},{60,60,3},{61,60,3},{62,60,3},{63,60,3}
+,{64,60,3},{65,60,3},{66,60,3},{67,60,3},{68,60,3},{69,60,3},{70,60,3},{71,60,3}
+,{72,60,3},{73,60,3},{74,60,3},{75,60,3},{76,60,3},{77,60,3},{78,60,3},{79,60,3}
+,{80,60,3},{81,60,3},{82,60,3},{83,60,3},{84,60,3},{85,60,3},{86,60,3},{87,60,3}
+,{88,60,3},{89,60,3},{90,60,3},{91,60,3},{92,60,3},{93,60,3},{94,60,3},{95,60,3}
+,{96,60,3},{97,60,3},{98,60,3},{99,60,3},{100,60,3},{101,60,3},{102,60,3},{103,60,3}
+,{104,60,3},{105,60,3},{106,60,3},{107,60,3},{108,60,3},{109,60,3},{110,60,3},{111,60,3}
+,{112,60,3},{113,60,3},{114,60,3},{115,60,3},{116,60,3},{117,60,3},{118,60,3},{119,60,3}
+,{120,60,3},{121,60,3},{122,60,3},{123,60,3},{124,60,3},{125,60,3},{126,60,3},{127,60,3}
+,{128,60,3},{129,60,3},{130,60,3},{131,60,3},{132,60,3},{133,60,3},{134,60,3},{135,60,3}
+,{136,60,3},{137,60,3},{138,60,3},{139,60,3},{140,60,3},{141,60,3},{142,60,3},{143,60,3}
+,{144,60,3},{145,60,3},{146,60,3},{147,60,3},{148,60,3},{149,60,3},{150,60,3},{151,60,3}
+,{152,60,3},{153,60,3},{154,60,3},{155,60,3},{156,60,3},{159,60,3},{160,60,3},{161,60,3}
+,{162,60,3},{163,60,3},{164,60,3},{165,60,3},{166,60,3},{167,60,3},{168,60,3},{169,60,3}
+,{170,60,3},{171,60,3},{172,60,3},{-1,60,3},{-2,60,3},{-3,60,3},{73,-1,3},{98,-1,3}
+,{99,-1,3},{100,-1,3},{101,-1,3},{102,-1,3},{103,-1,3},{104,-1,3},{105,-1,3},{109,-1,3}
+,{110,-1,3},{111,-1,3},{112,-1,3},{113,-1,3},{114,-1,3},{115,-1,3},{116,-1,3},{117,-1,3}
+,{119,-1,3},{120,-1,3},{121,-1,3},{122,-1,3},{123,-1,3},{127,-1,3},{128,-1,3},{129,-1,3}
+,{130,-1,3},{131,-1,3},{132,-1,3},{133,-1,3},{134,-1,3},{135,-1,3},{136,-1,3},{145,-1,3}
+,{166,-1,3},{169,-1,3},{174,-1,3},{-161,-1,3},{98,-2,3},{99,-2,3},{100,-2,3},{101,-2,3}
+,{102,-2,3},{103,-2,3},{104,-2,3},{105,-2,3},{106,-2,3},{108,-2,3},{109,-2,3},{110,-2,3}
+,{111,-2,3},{112,-2,3},{113,-2,3},{114,-2,3},{115,-2,3},{116,-2,3},{117,-2,3},{119,-2,3}
+,{120,-2,3},{121,-2,3},{122,-2,3},{123,-2,3},{124,-2,3},{125,-2,3},{126,-2,3},{127,-2,3}
+,{128,-2,3},{129,-2,3},{130,-2,3},{131,-2,3},{132,-2,3},{133,-2,3},{134,-2,3},{135,-2,3}
+,{136,-2,3},{137,-2,3},{138,-2,3},{139,-2,3},{142,-2,3},{143,-2,3},{144,-2,3},{145,-2,3}
+,{146,-2,3},{147,-2,3},{148,-2,3},{149,-2,3},{150,-2,3},{174,-2,3},{175,-2,3},{176,-2,3}
+,{99,-3,3},{100,-3,3},{101,-3,3},{102,-3,3},{103,-3,3},{104,-3,3},{105,-3,3},{106,-3,3}
+,{107,-3,3},{108,-3,3},{110,-3,3},{111,-3,3},{112,-3,3},{113,-3,3},{114,-3,3},{115,-3,3}
+,{116,-3,3},{117,-3,3},{118,-3,3},{119,-3,3},{120,-3,3},{121,-3,3},{122,-3,3},{123,-3,3}
+,{124,-3,3},{125,-3,3},{126,-3,3},{127,-3,3},{128,-3,3},{129,-3,3},{130,-3,3},{131,-3,3}
+,{132,-3,3},{133,-3,3},{134,-3,3},{135,-3,3},{136,-3,3},{137,-3,3},{138,-3,3},{139,-3,3}
+,{140,-3,3},{141,-3,3},{142,-3,3},{145,-3,3},{146,-3,3},{147,-3,3},{148,-3,3},{149,-3,3}
+,{150,-3,3},{151,-3,3},{152,-3,3},{175,-3,3},{176,-3,3},{-172,-3,3},{100,-4,3},{101,-4,3}
+,{102,-4,3},{103,-4,3},{104,-4,3},{105,-4,3},{106,-4,3},{107,-4,3},{108,-4,3},{110,-4,3}
+,{111,-4,3},{112,-4,3},{113,-4,3},{114,-4,3},{115,-4,3},{116,-4,3},{117,-4,3},{118,-4,3}
+,{119,-4,3},{120,-4,3},{121,-4,3},{122,-4,3},{123,-4,3},{125,-4,3},{126,-4,3},{127,-4,3}
+,{128,-4,3},{129,-4,3},{130,-4,3},{131,-4,3},{132,-4,3},{133,-4,3},{134,-4,3},{135,-4,3}
+,{136,-4,3},{137,-4,3},{138,-4,3},{139,-4,3},{140,-4,3},{141,-4,3},{142,-4,3},{143,-4,3}
+,{144,-4,3},{150,-4,3},{151,-4,3},{152,-4,3},{153,-4,3},{154,-4,3},{-155,-4,3},{-171,-4,3}
+,{-172,-4,3},{-175,-4,3},{101,-5,3},{102,-5,3},{103,-5,3},{104,-5,3},{105,-5,3},{114,-5,3}
+,{115,-5,3},{116,-5,3},{119,-5,3},{120,-5,3},{121,-5,3},{122,-5,3},{123,-5,3},{129,-5,3}
+,{130,-5,3},{131,-5,3},{132,-5,3},{133,-5,3},{134,-5,3},{135,-5,3},{136,-5,3},{137,-5,3}
+,{138,-5,3},{139,-5,3},{140,-5,3},{141,-5,3},{142,-5,3},{143,-5,3},{144,-5,3},{145,-5,3}
+,{146,-5,3},{149,-5,3},{150,-5,3},{151,-5,3},{152,-5,3},{153,-5,3},{154,-5,3},{155,-5,3}
+,{156,-5,3},{157,-5,3},{159,-5,3},{-155,-5,3},{-172,-5,3},{-173,-5,3},{-175,-5,3},{71,-6,3}
+,{72,-6,3},{102,-6,3},{103,-6,3},{104,-6,3},{105,-6,3},{106,-6,3},{107,-6,3},{108,-6,3}
+,{110,-6,3},{112,-6,3},{114,-6,3},{117,-6,3},{118,-6,3},{119,-6,3},{120,-6,3},{121,-6,3}
+,{122,-6,3},{123,-6,3},{124,-6,3},{127,-6,3},{130,-6,3},{131,-6,3},{132,-6,3},{133,-6,3}
+,{134,-6,3},{137,-6,3},{138,-6,3},{139,-6,3},{140,-6,3},{141,-6,3},{142,-6,3},{143,-6,3}
+,{144,-6,3},{145,-6,3},{146,-6,3},{147,-6,3},{148,-6,3},{149,-6,3},{150,-6,3},{151,-6,3}
+,{152,-6,3},{154,-6,3},{155,-6,3},{159,-6,3},{176,-6,3},{-156,-6,3},{71,-7,3},{105,-7,3}
+,{106,-7,3},{107,-7,3},{108,-7,3},{109,-7,3},{110,-7,3},{111,-7,3},{112,-7,3},{113,-7,3}
+,{114,-7,3},{115,-7,3},{116,-7,3},{118,-7,3},{119,-7,3},{120,-7,3},{121,-7,3},{122,-7,3}
+,{124,-7,3},{126,-7,3},{129,-7,3},{130,-7,3},{131,-7,3},{132,-7,3},{134,-7,3},{138,-7,3}
+,{139,-7,3},{140,-7,3},{141,-7,3},{142,-7,3},{143,-7,3},{144,-7,3},{145,-7,3},{146,-7,3}
+,{147,-7,3},{148,-7,3},{149,-7,3},{150,-7,3},{151,-7,3},{154,-7,3},{155,-7,3},{156,-7,3}
+,{157,-7,3},{176,-7,3},{177,-7,3},{72,-8,3},{105,-8,3},{106,-8,3},{107,-8,3},{108,-8,3}
+,{109,-8,3},{110,-8,3},{111,-8,3},{112,-8,3},{113,-8,3},{114,-8,3},{115,-8,3},{117,-8,3}
+,{118,-8,3},{120,-8,3},{121,-8,3},{122,-8,3},{123,-8,3},{125,-8,3},{126,-8,3},{127,-8,3}
+,{128,-8,3},{129,-8,3},{130,-8,3},{131,-8,3},{134,-8,3},{137,-8,3},{138,-8,3},{139,-8,3}
+,{140,-8,3},{141,-8,3},{142,-8,3},{143,-8,3},{144,-8,3},{145,-8,3},{146,-8,3},{147,-8,3}
+,{155,-8,3},{156,-8,3},{157,-8,3},{158,-8,3},{159,-8,3},{160,-8,3},{177,-8,3},{178,-8,3}
+,{-141,-8,3},{110,-9,3},{111,-9,3},{112,-9,3},{113,-9,3},{114,-9,3},{115,-9,3},{116,-9,3}
+,{117,-9,3},{118,-9,3},{119,-9,3},{120,-9,3},{121,-9,3},{122,-9,3},{123,-9,3},{124,-9,3}
+,{125,-9,3},{126,-9,3},{127,-9,3},{128,-9,3},{129,-9,3},{130,-9,3},{131,-9,3},{137,-9,3}
+,{138,-9,3},{139,-9,3},{140,-9,3},{141,-9,3},{142,-9,3},{143,-9,3},{145,-9,3},{146,-9,3}
+,{147,-9,3},{148,-9,3},{149,-9,3},{150,-9,3},{151,-9,3},{152,-9,3},{156,-9,3},{157,-9,3}
+,{158,-9,3},{159,-9,3},{160,-9,3},{161,-9,3},{178,-9,3},{179,-9,3},{-140,-9,3},{-141,-9,3}
+,{-158,-9,3},{-159,-9,3},{-173,-9,3},{116,-10,3},{117,-10,3},{118,-10,3},{119,-10,3},{120,-10,3}
+,{123,-10,3},{124,-10,3},{125,-10,3},{126,-10,3},{140,-10,3},{141,-10,3},{142,-10,3},{143,-10,3}
+,{144,-10,3},{146,-10,3},{147,-10,3},{148,-10,3},{149,-10,3},{150,-10,3},{151,-10,3},{152,-10,3}
+,{153,-10,3},{158,-10,3},{159,-10,3},{160,-10,3},{161,-10,3},{167,-10,3},{179,-10,3},{-139,-10,3}
+,{-140,-10,3},{-141,-10,3},{-151,-10,3},{-158,-10,3},{-159,-10,3},{-162,-10,3},{-172,-10,3},{105,-11,3}
+,{96,-12,3},{96,-13,3},{-170,16,4},{-156,18,4},{-155,19,4},{-156,19,4},{-157,19,4},{-156,20,4}
+,{-157,20,4},{-158,20,4},{-157,21,4},{-158,21,4},{-159,21,4},{-160,21,4},{-161,21,4},{-160,22,4}
+,{-161,22,4},{-162,23,4},{-165,23,4},{-167,23,4},{-168,24,4},{-168,25,4},{-172,25,4},{-174,26,4}
+,{-176,27,4},{-178,28,4},{-179,28,4},{-15,-8,4},{-6,-16,4},{-6,-17,4},{-29,-21,4},{-30,-21,4}
+,{167,-29,4},{167,-30,4},{-178,-30,4},{-179,-31,4},{-179,-32,4},{172,-35,4},{173,-35,4},{173,-36,4}
+,{174,-36,4},{175,-36,4},{173,-37,4},{174,-37,4},{175,-37,4},{176,-37,4},{77,-38,4},{174,-38,4}
+,{175,-38,4},{176,-38,4},{177,-38,4},{178,-38,4},{-13,-38,4},{77,-39,4},{174,-39,4},{175,-39,4}
+,{176,-39,4},{177,-39,4},{178,-39,4},{173,-40,4},{174,-40,4},{175,-40,4},{176,-40,4},{177,-40,4}
+,{178,-40,4},{172,-41,4},{173,-41,4},{174,-41,4},{175,-41,4},{176,-41,4},{-10,-41,4},{-11,-41,4}
+,{171,-42,4},{172,-42,4},{173,-42,4},{174,-42,4},{175,-42,4},{176,-42,4},{170,-43,4},{171,-43,4}
+,{172,-43,4},{173,-43,4},{174,-43,4},{168,-44,4},{169,-44,4},{170,-44,4},{171,-44,4},{172,-44,4}
+,{173,-44,4},{-176,-44,4},{-177,-44,4},{167,-45,4},{168,-45,4},{169,-45,4},{170,-45,4},{171,-45,4}
+,{-176,-45,4},{-177,-45,4},{50,-46,4},{166,-46,4},{167,-46,4},{168,-46,4},{169,-46,4},{170,-46,4}
+,{171,-46,4},{37,-47,4},{38,-47,4},{50,-47,4},{51,-47,4},{52,-47,4},{166,-47,4},{167,-47,4}
+,{168,-47,4},{169,-47,4},{170,-47,4},{167,-48,4},{168,-48,4},{179,-48,4},{68,-49,4},{69,-49,4}
+,{166,-49,4},{68,-50,4},{69,-50,4},{70,-50,4},{178,-50,4},{68,-51,4},{165,-51,4},{166,-51,4}
+,{73,-53,4},{168,-53,4},{169,-53,4},{72,-54,4},{73,-54,4},{-38,-54,4},{-39,-54,4},{3,-55,4}
+,{158,-55,4},{-36,-55,4},{-37,-55,4},{-38,-55,4},{-39,-55,4},{158,-56,4},{-35,-56,4},{-110,10,5}
+,{-62,15,5},{-64,15,5},{-79,15,5},{-80,15,5},{-83,15,5},{-84,15,5},{-85,15,5},{-86,15,5}
+,{-87,15,5},{-88,15,5},{-89,15,5},{-90,15,5},{-91,15,5},{-92,15,5},{-93,15,5},{-94,15,5}
+,{-96,15,5},{-97,15,5},{-98,15,5},{-62,16,5},{-63,16,5},{-86,16,5},{-87,16,5},{-88,16,5}
+,{-89,16,5},{-90,16,5},{-91,16,5},{-92,16,5},{-93,16,5},{-94,16,5},{-95,16,5},{-96,16,5}
+,{-97,16,5},{-98,16,5},{-99,16,5},{-100,16,5},{-101,16,5},{-62,17,5},{-63,17,5},{-64,17,5}
+,{-65,17,5},{-66,17,5},{-67,17,5},{-68,17,5},{-72,17,5},{-76,17,5},{-77,17,5},{-78,17,5}
+,{-84,17,5},{-88,17,5},{-89,17,5},{-90,17,5},{-91,17,5},{-92,17,5},{-93,17,5},{-94,17,5}
+,{-95,17,5},{-96,17,5},{-97,17,5},{-98,17,5},{-99,17,5},{-100,17,5},{-101,17,5},{-102,17,5}
+,{-103,17,5},{-63,18,5},{-64,18,5},{-65,18,5},{-66,18,5},{-67,18,5},{-68,18,5},{-69,18,5}
+,{-70,18,5},{-71,18,5},{-72,18,5},{-73,18,5},{-74,18,5},{-75,18,5},{-76,18,5},{-77,18,5}
+,{-78,18,5},{-79,18,5},{-88,18,5},{-89,18,5},{-90,18,5},{-91,18,5},{-92,18,5},{-93,18,5}
+,{-94,18,5},{-95,18,5},{-96,18,5},{-97,18,5},{-98,18,5},{-99,18,5},{-100,18,5},{-101,18,5}
+,{-102,18,5},{-103,18,5},{-104,18,5},{-105,18,5},{-111,18,5},{-112,18,5},{-115,18,5},{-69,19,5}
+,{-70,19,5},{-71,19,5},{-72,19,5},{-73,19,5},{-74,19,5},{-75,19,5},{-76,19,5},{-77,19,5}
+,{-78,19,5},{-80,19,5},{-81,19,5},{-82,19,5},{-88,19,5},{-89,19,5},{-90,19,5},{-91,19,5}
+,{-92,19,5},{-96,19,5},{-97,19,5},{-98,19,5},{-99,19,5},{-100,19,5},{-101,19,5},{-102,19,5}
+,{-103,19,5},{-104,19,5},{-105,19,5},{-106,19,5},{-111,19,5},{-73,20,5},{-74,20,5},{-75,20,5}
+,{-76,20,5},{-77,20,5},{-78,20,5},{-79,20,5},{-80,20,5},{-87,20,5},{-88,20,5},{-89,20,5}
+,{-90,20,5},{-91,20,5},{-92,20,5},{-93,20,5},{-97,20,5},{-98,20,5},{-99,20,5},{-100,20,5}
+,{-101,20,5},{-102,20,5},{-103,20,5},{-104,20,5},{-105,20,5},{-106,20,5},{-72,21,5},{-73,21,5}
+,{-74,21,5},{-76,21,5},{-77,21,5},{-78,21,5},{-79,21,5},{-80,21,5},{-81,21,5},{-82,21,5}
+,{-83,21,5},{-84,21,5},{-85,21,5},{-87,21,5},{-88,21,5},{-89,21,5},{-90,21,5},{-91,21,5}
+,{-98,21,5},{-99,21,5},{-100,21,5},{-101,21,5},{-102,21,5},{-103,21,5},{-104,21,5},{-105,21,5}
+,{-106,21,5},{-107,21,5},{-73,22,5},{-74,22,5},{-75,22,5},{-76,22,5},{-78,22,5},{-79,22,5}
+,{-80,22,5},{-81,22,5},{-82,22,5},{-83,22,5},{-84,22,5},{-85,22,5},{-90,22,5},{-92,22,5}
+,{-98,22,5},{-99,22,5},{-100,22,5},{-101,22,5},{-102,22,5},{-103,22,5},{-104,22,5},{-105,22,5}
+,{-106,22,5},{-107,22,5},{-110,22,5},{-111,22,5},{-74,23,5},{-75,23,5},{-76,23,5},{-77,23,5}
+,{-78,23,5},{-80,23,5},{-81,23,5},{-82,23,5},{-83,23,5},{-84,23,5},{-98,23,5},{-99,23,5}
+,{-100,23,5},{-101,23,5},{-102,23,5},{-103,23,5},{-104,23,5},{-105,23,5},{-106,23,5},{-107,23,5}
+,{-108,23,5},{-110,23,5},{-111,23,5},{-75,24,5},{-76,24,5},{-77,24,5},{-78,24,5},{-79,24,5}
+,{-80,24,5},{-81,24,5},{-82,24,5},{-83,24,5},{-98,24,5},{-99,24,5},{-100,24,5},{-101,24,5}
+,{-102,24,5},{-103,24,5},{-104,24,5},{-105,24,5},{-106,24,5},{-107,24,5},{-108,24,5},{-109,24,5}
+,{-110,24,5},{-111,24,5},{-112,24,5},{-113,24,5},{-116,24,5},{-77,25,5},{-78,25,5},{-79,25,5}
+,{-80,25,5},{-81,25,5},{-82,25,5},{-98,25,5},{-99,25,5},{-100,25,5},{-101,25,5},{-102,25,5}
+,{-103,25,5},{-104,25,5},{-105,25,5},{-106,25,5},{-107,25,5},{-108,25,5},{-109,25,5},{-110,25,5}
+,{-111,25,5},{-112,25,5},{-113,25,5},{-77,26,5},{-78,26,5},{-79,26,5},{-80,26,5},{-81,26,5}
+,{-82,26,5},{-83,26,5},{-98,26,5},{-99,26,5},{-100,26,5},{-101,26,5},{-102,26,5},{-103,26,5}
+,{-104,26,5},{-105,26,5},{-106,26,5},{-107,26,5},{-108,26,5},{-109,26,5},{-110,26,5},{-112,26,5}
+,{-113,26,5},{-114,26,5},{-115,26,5},{-78,27,5},{-79,27,5},{-81,27,5},{-82,27,5},{-83,27,5}
+,{-97,27,5},{-98,27,5},{-99,27,5},{-100,27,5},{-101,27,5},{-102,27,5},{-103,27,5},{-104,27,5}
+,{-105,27,5},{-106,27,5},{-107,27,5},{-108,27,5},{-109,27,5},{-110,27,5},{-111,27,5},{-112,27,5}
+,{-113,27,5},{-114,27,5},{-115,27,5},{-116,27,5},{-81,28,5},{-82,28,5},{-83,28,5},{-90,28,5}
+,{-96,28,5},{-97,28,5},{-98,28,5},{-99,28,5},{-100,28,5},{-101,28,5},{-102,28,5},{-103,28,5}
+,{-104,28,5},{-105,28,5},{-106,28,5},{-107,28,5},{-108,28,5},{-109,28,5},{-110,28,5},{-111,28,5}
+,{-112,28,5},{-113,28,5},{-114,28,5},{-115,28,5},{-116,28,5},{-119,28,5},{-81,29,5},{-82,29,5}
+,{-83,29,5},{-84,29,5},{-85,29,5},{-86,29,5},{-89,29,5},{-90,29,5},{-91,29,5},{-92,29,5}
+,{-93,29,5},{-94,29,5},{-95,29,5},{-96,29,5},{-97,29,5},{-98,29,5},{-99,29,5},{-100,29,5}
+,{-101,29,5},{-102,29,5},{-103,29,5},{-104,29,5},{-105,29,5},{-106,29,5},{-107,29,5},{-108,29,5}
+,{-109,29,5},{-110,29,5},{-111,29,5},{-112,29,5},{-113,29,5},{-114,29,5},{-115,29,5},{-116,29,5}
+,{-119,29,5},{-82,30,5},{-83,30,5},{-84,30,5},{-85,30,5},{-86,30,5},{-87,30,5},{-88,30,5}
+,{-89,30,5},{-90,30,5},{-91,30,5},{-92,30,5},{-93,30,5},{-94,30,5},{-95,30,5},{-96,30,5}
+,{-97,30,5},{-98,30,5},{-99,30,5},{-100,30,5},{-101,30,5},{-102,30,5},{-103,30,5},{-104,30,5}
+,{-105,30,5},{-106,30,5},{-107,30,5},{-108,30,5},{-109,30,5},{-110,30,5},{-111,30,5},{-112,30,5}
+,{-113,30,5},{-114,30,5},{-115,30,5},{-116,30,5},{-117,30,5},{-81,31,5},{-82,31,5},{-83,31,5}
+,{-84,31,5},{-85,31,5},{-86,31,5},{-87,31,5},{-88,31,5},{-89,31,5},{-90,31,5},{-91,31,5}
+,{-92,31,5},{-93,31,5},{-94,31,5},{-95,31,5},{-96,31,5},{-97,31,5},{-98,31,5},{-99,31,5}
+,{-100,31,5},{-101,31,5},{-102,31,5},{-103,31,5},{-104,31,5},{-105,31,5},{-106,31,5},{-107,31,5}
+,{-108,31,5},{-109,31,5},{-110,31,5},{-111,31,5},{-112,31,5},{-113,31,5},{-114,31,5},{-115,31,5}
+,{-116,31,5},{-117,31,5},{-65,32,5},{-80,32,5},{-81,32,5},{-82,32,5},{-83,32,5},{-84,32,5}
+,{-85,32,5},{-86,32,5},{-87,32,5},{-88,32,5},{-89,32,5},{-90,32,5},{-91,32,5},{-92,32,5}
+,{-93,32,5},{-94,32,5},{-95,32,5},{-96,32,5},{-97,32,5},{-98,32,5},{-99,32,5},{-100,32,5}
+,{-101,32,5},{-102,32,5},{-103,32,5},{-104,32,5},{-105,32,5},{-106,32,5},{-107,32,5},{-108,32,5}
+,{-109,32,5},{-110,32,5},{-111,32,5},{-112,32,5},{-113,32,5},{-114,32,5},{-115,32,5},{-116,32,5}
+,{-117,32,5},{-118,32,5},{-119,32,5},{-78,33,5},{-79,33,5},{-80,33,5},{-81,33,5},{-82,33,5}
+,{-83,33,5},{-84,33,5},{-85,33,5},{-86,33,5},{-87,33,5},{-88,33,5},{-89,33,5},{-90,33,5}
+,{-91,33,5},{-92,33,5},{-93,33,5},{-94,33,5},{-95,33,5},{-96,33,5},{-97,33,5},{-98,33,5}
+,{-99,33,5},{-100,33,5},{-101,33,5},{-102,33,5},{-103,33,5},{-104,33,5},{-105,33,5},{-106,33,5}
+,{-107,33,5},{-108,33,5},{-109,33,5},{-110,33,5},{-111,33,5},{-112,33,5},{-113,33,5},{-114,33,5}
+,{-115,33,5},{-116,33,5},{-117,33,5},{-118,33,5},{-119,33,5},{-120,33,5},{-121,33,5},{-77,34,5}
+,{-78,34,5},{-79,34,5},{-80,34,5},{-81,34,5},{-82,34,5},{-83,34,5},{-84,34,5},{-85,34,5}
+,{-86,34,5},{-87,34,5},{-88,34,5},{-89,34,5},{-90,34,5},{-91,34,5},{-92,34,5},{-93,34,5}
+,{-94,34,5},{-95,34,5},{-96,34,5},{-97,34,5},{-98,34,5},{-99,34,5},{-100,34,5},{-101,34,5}
+,{-102,34,5},{-103,34,5},{-104,34,5},{-105,34,5},{-106,34,5},{-107,34,5},{-108,34,5},{-109,34,5}
+,{-110,34,5},{-111,34,5},{-112,34,5},{-113,34,5},{-114,34,5},{-115,34,5},{-116,34,5},{-117,34,5}
+,{-118,34,5},{-119,34,5},{-120,34,5},{-121,34,5},{-76,35,5},{-77,35,5},{-78,35,5},{-79,35,5}
+,{-80,35,5},{-81,35,5},{-82,35,5},{-83,35,5},{-84,35,5},{-85,35,5},{-86,35,5},{-87,35,5}
+,{-88,35,5},{-89,35,5},{-90,35,5},{-91,35,5},{-92,35,5},{-93,35,5},{-94,35,5},{-95,35,5}
+,{-96,35,5},{-97,35,5},{-98,35,5},{-99,35,5},{-100,35,5},{-101,35,5},{-102,35,5},{-103,35,5}
+,{-104,35,5},{-105,35,5},{-106,35,5},{-107,35,5},{-108,35,5},{-109,35,5},{-110,35,5},{-111,35,5}
+,{-112,35,5},{-113,35,5},{-114,35,5},{-115,35,5},{-116,35,5},{-117,35,5},{-118,35,5},{-119,35,5}
+,{-120,35,5},{-121,35,5},{-122,35,5},{-76,36,5},{-77,36,5},{-78,36,5},{-79,36,5},{-80,36,5}
+,{-81,36,5},{-82,36,5},{-83,36,5},{-84,36,5},{-85,36,5},{-86,36,5},{-87,36,5},{-88,36,5}
+,{-89,36,5},{-90,36,5},{-91,36,5},{-92,36,5},{-93,36,5},{-94,36,5},{-95,36,5},{-96,36,5}
+,{-97,36,5},{-98,36,5},{-99,36,5},{-100,36,5},{-101,36,5},{-102,36,5},{-103,36,5},{-104,36,5}
+,{-105,36,5},{-106,36,5},{-107,36,5},{-108,36,5},{-109,36,5},{-110,36,5},{-111,36,5},{-112,36,5}
+,{-113,36,5},{-114,36,5},{-115,36,5},{-116,36,5},{-117,36,5},{-118,36,5},{-119,36,5},{-120,36,5}
+,{-121,36,5},{-122,36,5},{-123,36,5},{-76,37,5},{-77,37,5},{-78,37,5},{-79,37,5},{-80,37,5}
+,{-81,37,5},{-82,37,5},{-83,37,5},{-84,37,5},{-85,37,5},{-86,37,5},{-87,37,5},{-88,37,5}
+,{-89,37,5},{-90,37,5},{-91,37,5},{-92,37,5},{-93,37,5},{-94,37,5},{-95,37,5},{-96,37,5}
+,{-97,37,5},{-98,37,5},{-99,37,5},{-100,37,5},{-101,37,5},{-102,37,5},{-103,37,5},{-104,37,5}
+,{-105,37,5},{-106,37,5},{-107,37,5},{-108,37,5},{-109,37,5},{-110,37,5},{-111,37,5},{-112,37,5}
+,{-113,37,5},{-114,37,5},{-115,37,5},{-116,37,5},{-117,37,5},{-118,37,5},{-119,37,5},{-120,37,5}
+,{-121,37,5},{-122,37,5},{-123,37,5},{-124,37,5},{-75,38,5},{-76,38,5},{-77,38,5},{-78,38,5}
+,{-79,38,5},{-80,38,5},{-81,38,5},{-82,38,5},{-83,38,5},{-84,38,5},{-85,38,5},{-86,38,5}
+,{-87,38,5},{-88,38,5},{-89,38,5},{-90,38,5},{-91,38,5},{-92,38,5},{-93,38,5},{-94,38,5}
+,{-95,38,5},{-96,38,5},{-97,38,5},{-98,38,5},{-99,38,5},{-100,38,5},{-101,38,5},{-102,38,5}
+,{-103,38,5},{-104,38,5},{-105,38,5},{-106,38,5},{-107,38,5},{-108,38,5},{-109,38,5},{-110,38,5}
+,{-111,38,5},{-112,38,5},{-113,38,5},{-114,38,5},{-115,38,5},{-116,38,5},{-117,38,5},{-118,38,5}
+,{-119,38,5},{-120,38,5},{-121,38,5},{-122,38,5},{-123,38,5},{-124,38,5},{-75,39,5},{-76,39,5}
+,{-77,39,5},{-78,39,5},{-79,39,5},{-80,39,5},{-81,39,5},{-82,39,5},{-83,39,5},{-84,39,5}
+,{-85,39,5},{-86,39,5},{-87,39,5},{-88,39,5},{-89,39,5},{-90,39,5},{-91,39,5},{-92,39,5}
+,{-93,39,5},{-94,39,5},{-95,39,5},{-96,39,5},{-97,39,5},{-98,39,5},{-99,39,5},{-100,39,5}
+,{-101,39,5},{-102,39,5},{-103,39,5},{-104,39,5},{-105,39,5},{-106,39,5},{-107,39,5},{-108,39,5}
+,{-109,39,5},{-110,39,5},{-111,39,5},{-112,39,5},{-113,39,5},{-114,39,5},{-115,39,5},{-116,39,5}
+,{-117,39,5},{-118,39,5},{-119,39,5},{-120,39,5},{-121,39,5},{-122,39,5},{-123,39,5},{-124,39,5}
+,{-125,39,5},{-73,40,5},{-74,40,5},{-75,40,5},{-76,40,5},{-77,40,5},{-78,40,5},{-79,40,5}
+,{-80,40,5},{-81,40,5},{-82,40,5},{-83,40,5},{-84,40,5},{-85,40,5},{-86,40,5},{-87,40,5}
+,{-88,40,5},{-89,40,5},{-90,40,5},{-91,40,5},{-92,40,5},{-93,40,5},{-94,40,5},{-95,40,5}
+,{-96,40,5},{-97,40,5},{-98,40,5},{-99,40,5},{-100,40,5},{-101,40,5},{-102,40,5},{-103,40,5}
+,{-104,40,5},{-105,40,5},{-106,40,5},{-107,40,5},{-108,40,5},{-109,40,5},{-110,40,5},{-111,40,5}
+,{-112,40,5},{-113,40,5},{-114,40,5},{-115,40,5},{-116,40,5},{-117,40,5},{-118,40,5},{-119,40,5}
+,{-120,40,5},{-121,40,5},{-122,40,5},{-123,40,5},{-124,40,5},{-125,40,5},{-70,41,5},{-71,41,5}
+,{-72,41,5},{-73,41,5},{-74,41,5},{-75,41,5},{-76,41,5},{-77,41,5},{-78,41,5},{-79,41,5}
+,{-80,41,5},{-81,41,5},{-82,41,5},{-83,41,5},{-84,41,5},{-85,41,5},{-86,41,5},{-87,41,5}
+,{-88,41,5},{-89,41,5},{-90,41,5},{-91,41,5},{-92,41,5},{-93,41,5},{-94,41,5},{-95,41,5}
+,{-96,41,5},{-97,41,5},{-98,41,5},{-99,41,5},{-100,41,5},{-101,41,5},{-102,41,5},{-103,41,5}
+,{-104,41,5},{-105,41,5},{-106,41,5},{-107,41,5},{-108,41,5},{-109,41,5},{-110,41,5},{-111,41,5}
+,{-112,41,5},{-113,41,5},{-114,41,5},{-115,41,5},{-116,41,5},{-117,41,5},{-118,41,5},{-119,41,5}
+,{-120,41,5},{-121,41,5},{-122,41,5},{-123,41,5},{-124,41,5},{-125,41,5},{-71,42,5},{-72,42,5}
+,{-73,42,5},{-74,42,5},{-75,42,5},{-76,42,5},{-77,42,5},{-78,42,5},{-79,42,5},{-80,42,5}
+,{-81,42,5},{-82,42,5},{-83,42,5},{-84,42,5},{-85,42,5},{-86,42,5},{-87,42,5},{-88,42,5}
+,{-89,42,5},{-90,42,5},{-91,42,5},{-92,42,5},{-93,42,5},{-94,42,5},{-95,42,5},{-96,42,5}
+,{-97,42,5},{-98,42,5},{-99,42,5},{-100,42,5},{-101,42,5},{-102,42,5},{-103,42,5},{-104,42,5}
+,{-105,42,5},{-106,42,5},{-107,42,5},{-108,42,5},{-109,42,5},{-110,42,5},{-111,42,5},{-112,42,5}
+,{-113,42,5},{-114,42,5},{-115,42,5},{-116,42,5},{-117,42,5},{-118,42,5},{-119,42,5},{-120,42,5}
+,{-121,42,5},{-122,42,5},{-123,42,5},{-124,42,5},{-125,42,5},{-60,43,5},{-61,43,5},{-65,43,5}
+,{-66,43,5},{-67,43,5},{-69,43,5},{-70,43,5},{-71,43,5},{-72,43,5},{-73,43,5},{-74,43,5}
+,{-75,43,5},{-76,43,5},{-77,43,5},{-78,43,5},{-79,43,5},{-80,43,5},{-81,43,5},{-82,43,5}
+,{-83,43,5},{-84,43,5},{-85,43,5},{-86,43,5},{-87,43,5},{-88,43,5},{-89,43,5},{-90,43,5}
+,{-91,43,5},{-92,43,5},{-93,43,5},{-94,43,5},{-95,43,5},{-96,43,5},{-97,43,5},{-98,43,5}
+,{-99,43,5},{-100,43,5},{-101,43,5},{-102,43,5},{-103,43,5},{-104,43,5},{-105,43,5},{-106,43,5}
+,{-107,43,5},{-108,43,5},{-109,43,5},{-110,43,5},{-111,43,5},{-112,43,5},{-113,43,5},{-114,43,5}
+,{-115,43,5},{-116,43,5},{-117,43,5},{-118,43,5},{-119,43,5},{-120,43,5},{-121,43,5},{-122,43,5}
+,{-123,43,5},{-124,43,5},{-125,43,5},{-60,44,5},{-62,44,5},{-63,44,5},{-64,44,5},{-65,44,5}
+,{-66,44,5},{-67,44,5},{-68,44,5},{-69,44,5},{-70,44,5},{-71,44,5},{-72,44,5},{-73,44,5}
+,{-74,44,5},{-75,44,5},{-76,44,5},{-77,44,5},{-78,44,5},{-79,44,5},{-80,44,5},{-81,44,5}
+,{-82,44,5},{-83,44,5},{-84,44,5},{-85,44,5},{-86,44,5},{-87,44,5},{-88,44,5},{-89,44,5}
+,{-90,44,5},{-91,44,5},{-92,44,5},{-93,44,5},{-94,44,5},{-95,44,5},{-96,44,5},{-97,44,5}
+,{-98,44,5},{-99,44,5},{-100,44,5},{-101,44,5},{-102,44,5},{-103,44,5},{-104,44,5},{-105,44,5}
+,{-106,44,5},{-107,44,5},{-108,44,5},{-109,44,5},{-110,44,5},{-111,44,5},{-112,44,5},{-113,44,5}
+,{-114,44,5},{-115,44,5},{-116,44,5},{-117,44,5},{-118,44,5},{-119,44,5},{-120,44,5},{-121,44,5}
+,{-122,44,5},{-123,44,5},{-124,44,5},{-125,44,5},{-60,45,5},{-61,45,5},{-62,45,5},{-63,45,5}
+,{-64,45,5},{-65,45,5},{-66,45,5},{-67,45,5},{-68,45,5},{-69,45,5},{-70,45,5},{-71,45,5}
+,{-72,45,5},{-73,45,5},{-74,45,5},{-75,45,5},{-76,45,5},{-77,45,5},{-78,45,5},{-79,45,5}
+,{-80,45,5},{-81,45,5},{-82,45,5},{-83,45,5},{-84,45,5},{-85,45,5},{-86,45,5},{-87,45,5}
+,{-88,45,5},{-89,45,5},{-90,45,5},{-91,45,5},{-92,45,5},{-93,45,5},{-94,45,5},{-95,45,5}
+,{-96,45,5},{-97,45,5},{-98,45,5},{-99,45,5},{-100,45,5},{-101,45,5},{-102,45,5},{-103,45,5}
+,{-104,45,5},{-105,45,5},{-106,45,5},{-107,45,5},{-108,45,5},{-109,45,5},{-110,45,5},{-111,45,5}
+,{-112,45,5},{-113,45,5},{-114,45,5},{-115,45,5},{-116,45,5},{-117,45,5},{-118,45,5},{-119,45,5}
+,{-120,45,5},{-121,45,5},{-122,45,5},{-123,45,5},{-124,45,5},{-125,45,5},{-53,46,5},{-54,46,5}
+,{-55,46,5},{-56,46,5},{-57,46,5},{-60,46,5},{-61,46,5},{-62,46,5},{-63,46,5},{-64,46,5}
+,{-65,46,5},{-66,46,5},{-67,46,5},{-68,46,5},{-69,46,5},{-70,46,5},{-71,46,5},{-72,46,5}
+,{-73,46,5},{-74,46,5},{-75,46,5},{-76,46,5},{-77,46,5},{-78,46,5},{-79,46,5},{-80,46,5}
+,{-81,46,5},{-82,46,5},{-83,46,5},{-84,46,5},{-85,46,5},{-86,46,5},{-87,46,5},{-88,46,5}
+,{-89,46,5},{-90,46,5},{-91,46,5},{-92,46,5},{-93,46,5},{-94,46,5},{-95,46,5},{-96,46,5}
+,{-97,46,5},{-98,46,5},{-99,46,5},{-100,46,5},{-101,46,5},{-102,46,5},{-103,46,5},{-104,46,5}
+,{-105,46,5},{-106,46,5},{-107,46,5},{-108,46,5},{-109,46,5},{-110,46,5},{-111,46,5},{-112,46,5}
+,{-113,46,5},{-114,46,5},{-115,46,5},{-116,46,5},{-117,46,5},{-118,46,5},{-119,46,5},{-120,46,5}
+,{-121,46,5},{-122,46,5},{-123,46,5},{-124,46,5},{-125,46,5},{-53,47,5},{-54,47,5},{-55,47,5}
+,{-56,47,5},{-57,47,5},{-58,47,5},{-59,47,5},{-60,47,5},{-61,47,5},{-62,47,5},{-63,47,5}
+,{-64,47,5},{-65,47,5},{-66,47,5},{-67,47,5},{-68,47,5},{-69,47,5},{-70,47,5},{-71,47,5}
+,{-72,47,5},{-73,47,5},{-74,47,5},{-75,47,5},{-76,47,5},{-77,47,5},{-78,47,5},{-79,47,5}
+,{-80,47,5},{-81,47,5},{-82,47,5},{-83,47,5},{-84,47,5},{-85,47,5},{-86,47,5},{-88,47,5}
+,{-89,47,5},{-90,47,5},{-91,47,5},{-92,47,5},{-93,47,5},{-94,47,5},{-95,47,5},{-96,47,5}
+,{-97,47,5},{-98,47,5},{-99,47,5},{-100,47,5},{-101,47,5},{-102,47,5},{-103,47,5},{-104,47,5}
+,{-105,47,5},{-106,47,5},{-107,47,5},{-108,47,5},{-109,47,5},{-110,47,5},{-111,47,5},{-112,47,5}
+,{-113,47,5},{-114,47,5},{-115,47,5},{-116,47,5},{-117,47,5},{-118,47,5},{-119,47,5},{-120,47,5}
+,{-121,47,5},{-122,47,5},{-123,47,5},{-124,47,5},{-125,47,5},{-53,48,5},{-54,48,5},{-55,48,5}
+,{-56,48,5},{-57,48,5},{-58,48,5},{-59,48,5},{-60,48,5},{-65,48,5},{-66,48,5},{-67,48,5}
+,{-68,48,5},{-69,48,5},{-70,48,5},{-71,48,5},{-72,48,5},{-73,48,5},{-74,48,5},{-75,48,5}
+,{-76,48,5},{-77,48,5},{-78,48,5},{-79,48,5},{-80,48,5},{-81,48,5},{-82,48,5},{-83,48,5}
+,{-84,48,5},{-85,48,5},{-86,48,5},{-87,48,5},{-88,48,5},{-89,48,5},{-90,48,5},{-91,48,5}
+,{-92,48,5},{-93,48,5},{-94,48,5},{-95,48,5},{-96,48,5},{-97,48,5},{-98,48,5},{-99,48,5}
+,{-100,48,5},{-101,48,5},{-102,48,5},{-103,48,5},{-104,48,5},{-105,48,5},{-106,48,5},{-107,48,5}
+,{-108,48,5},{-109,48,5},{-110,48,5},{-111,48,5},{-112,48,5},{-113,48,5},{-114,48,5},{-115,48,5}
+,{-116,48,5},{-117,48,5},{-118,48,5},{-119,48,5},{-120,48,5},{-121,48,5},{-122,48,5},{-123,48,5}
+,{-124,48,5},{-125,48,5},{-126,48,5},{-54,49,5},{-55,49,5},{-56,49,5},{-57,49,5},{-58,49,5}
+,{-59,49,5},{-62,49,5},{-63,49,5},{-64,49,5},{-65,49,5},{-66,49,5},{-67,49,5},{-68,49,5}
+,{-69,49,5},{-70,49,5},{-71,49,5},{-72,49,5},{-73,49,5},{-74,49,5},{-75,49,5},{-76,49,5}
+,{-77,49,5},{-78,49,5},{-79,49,5},{-80,49,5},{-81,49,5},{-82,49,5},{-83,49,5},{-84,49,5}
+,{-85,49,5},{-86,49,5},{-87,49,5},{-88,49,5},{-89,49,5},{-90,49,5},{-91,49,5},{-92,49,5}
+,{-93,49,5},{-94,49,5},{-95,49,5},{-96,49,5},{-97,49,5},{-98,49,5},{-99,49,5},{-100,49,5}
+,{-101,49,5},{-102,49,5},{-103,49,5},{-104,49,5},{-105,49,5},{-106,49,5},{-107,49,5},{-108,49,5}
+,{-109,49,5},{-110,49,5},{-111,49,5},{-112,49,5},{-113,49,5},{-114,49,5},{-115,49,5},{-116,49,5}
+,{-117,49,5},{-118,49,5},{-119,49,5},{-120,49,5},{-121,49,5},{-122,49,5},{-123,49,5},{-124,49,5}
+,{-125,49,5},{-126,49,5},{-127,49,5},{-128,49,5},{-56,50,5},{-57,50,5},{-58,50,5},{-59,50,5}
+,{-60,50,5},{-61,50,5},{-62,50,5},{-63,50,5},{-64,50,5},{-65,50,5},{-66,50,5},{-67,50,5}
+,{-68,50,5},{-69,50,5},{-70,50,5},{-71,50,5},{-72,50,5},{-73,50,5},{-74,50,5},{-75,50,5}
+,{-76,50,5},{-77,50,5},{-78,50,5},{-79,50,5},{-80,50,5},{-81,50,5},{-82,50,5},{-83,50,5}
+,{-84,50,5},{-85,50,5},{-86,50,5},{-87,50,5},{-88,50,5},{-89,50,5},{-90,50,5},{-91,50,5}
+,{-92,50,5},{-93,50,5},{-94,50,5},{-95,50,5},{-96,50,5},{-97,50,5},{-98,50,5},{-99,50,5}
+,{-100,50,5},{-101,50,5},{-102,50,5},{-103,50,5},{-104,50,5},{-105,50,5},{-106,50,5},{-107,50,5}
+,{-108,50,5},{-109,50,5},{-110,50,5},{-111,50,5},{-112,50,5},{-113,50,5},{-114,50,5},{-115,50,5}
+,{-116,50,5},{-117,50,5},{-118,50,5},{-119,50,5},{-120,50,5},{-121,50,5},{-122,50,5},{-123,50,5}
+,{-124,50,5},{-125,50,5},{-126,50,5},{-127,50,5},{-128,50,5},{-129,50,5},{-130,50,5},{177,51,5}
+,{178,51,5},{179,51,5},{-56,51,5},{-57,51,5},{-58,51,5},{-59,51,5},{-60,51,5},{-61,51,5}
+,{-62,51,5},{-63,51,5},{-64,51,5},{-65,51,5},{-66,51,5},{-67,51,5},{-68,51,5},{-69,51,5}
+,{-70,51,5},{-71,51,5},{-72,51,5},{-73,51,5},{-74,51,5},{-75,51,5},{-76,51,5},{-77,51,5}
+,{-78,51,5},{-79,51,5},{-80,51,5},{-81,51,5},{-82,51,5},{-83,51,5},{-84,51,5},{-85,51,5}
+,{-86,51,5},{-87,51,5},{-88,51,5},{-89,51,5},{-90,51,5},{-91,51,5},{-92,51,5},{-93,51,5}
+,{-94,51,5},{-95,51,5},{-96,51,5},{-97,51,5},{-98,51,5},{-99,51,5},{-100,51,5},{-101,51,5}
+,{-102,51,5},{-103,51,5},{-104,51,5},{-105,51,5},{-106,51,5},{-107,51,5},{-108,51,5},{-109,51,5}
+,{-110,51,5},{-111,51,5},{-112,51,5},{-113,51,5},{-114,51,5},{-115,51,5},{-116,51,5},{-117,51,5}
+,{-118,51,5},{-119,51,5},{-120,51,5},{-121,51,5},{-122,51,5},{-123,51,5},{-124,51,5},{-125,51,5}
+,{-126,51,5},{-127,51,5},{-128,51,5},{-129,51,5},{-131,51,5},{-132,51,5},{-176,51,5},{-177,51,5}
+,{-178,51,5},{-179,51,5},{-180,51,5},{172,52,5},{173,52,5},{174,52,5},{175,52,5},{177,52,5}
+,{178,52,5},{179,52,5},{-56,52,5},{-57,52,5},{-58,52,5},{-59,52,5},{-60,52,5},{-61,52,5}
+,{-62,52,5},{-63,52,5},{-64,52,5},{-65,52,5},{-66,52,5},{-67,52,5},{-68,52,5},{-69,52,5}
+,{-70,52,5},{-71,52,5},{-72,52,5},{-73,52,5},{-74,52,5},{-75,52,5},{-76,52,5},{-77,52,5}
+,{-78,52,5},{-79,52,5},{-80,52,5},{-81,52,5},{-82,52,5},{-83,52,5},{-84,52,5},{-85,52,5}
+,{-86,52,5},{-87,52,5},{-88,52,5},{-89,52,5},{-90,52,5},{-91,52,5},{-92,52,5},{-93,52,5}
+,{-94,52,5},{-95,52,5},{-96,52,5},{-97,52,5},{-98,52,5},{-99,52,5},{-100,52,5},{-101,52,5}
+,{-102,52,5},{-103,52,5},{-104,52,5},{-105,52,5},{-106,52,5},{-107,52,5},{-108,52,5},{-109,52,5}
+,{-110,52,5},{-111,52,5},{-112,52,5},{-113,52,5},{-114,52,5},{-115,52,5},{-116,52,5},{-117,52,5}
+,{-118,52,5},{-119,52,5},{-120,52,5},{-121,52,5},{-122,52,5},{-123,52,5},{-124,52,5},{-125,52,5}
+,{-126,52,5},{-127,52,5},{-128,52,5},{-129,52,5},{-130,52,5},{-131,52,5},{-132,52,5},{-133,52,5}
+,{-169,52,5},{-170,52,5},{-171,52,5},{-172,52,5},{-173,52,5},{-174,52,5},{-175,52,5},{-176,52,5}
+,{-177,52,5},{172,53,5},{-56,53,5},{-57,53,5},{-58,53,5},{-59,53,5},{-60,53,5},{-61,53,5}
+,{-62,53,5},{-63,53,5},{-64,53,5},{-65,53,5},{-66,53,5},{-67,53,5},{-68,53,5},{-69,53,5}
+,{-70,53,5},{-71,53,5},{-72,53,5},{-73,53,5},{-74,53,5},{-75,53,5},{-76,53,5},{-77,53,5}
+,{-78,53,5},{-79,53,5},{-80,53,5},{-81,53,5},{-82,53,5},{-83,53,5},{-84,53,5},{-85,53,5}
+,{-86,53,5},{-87,53,5},{-88,53,5},{-89,53,5},{-90,53,5},{-91,53,5},{-92,53,5},{-93,53,5}
+,{-94,53,5},{-95,53,5},{-96,53,5},{-97,53,5},{-98,53,5},{-99,53,5},{-100,53,5},{-101,53,5}
+,{-102,53,5},{-103,53,5},{-104,53,5},{-105,53,5},{-106,53,5},{-107,53,5},{-108,53,5},{-109,53,5}
+,{-110,53,5},{-111,53,5},{-112,53,5},{-113,53,5},{-114,53,5},{-115,53,5},{-116,53,5},{-117,53,5}
+,{-118,53,5},{-119,53,5},{-120,53,5},{-121,53,5},{-122,53,5},{-123,53,5},{-124,53,5},{-125,53,5}
+,{-126,53,5},{-127,53,5},{-128,53,5},{-129,53,5},{-130,53,5},{-131,53,5},{-132,53,5},{-133,53,5}
+,{-134,53,5},{-167,53,5},{-168,53,5},{-169,53,5},{-170,53,5},{-57,54,5},{-58,54,5},{-59,54,5}
+,{-60,54,5},{-61,54,5},{-62,54,5},{-63,54,5},{-64,54,5},{-65,54,5},{-66,54,5},{-67,54,5}
+,{-68,54,5},{-69,54,5},{-70,54,5},{-71,54,5},{-72,54,5},{-73,54,5},{-74,54,5},{-75,54,5}
+,{-76,54,5},{-77,54,5},{-78,54,5},{-79,54,5},{-80,54,5},{-81,54,5},{-82,54,5},{-83,54,5}
+,{-84,54,5},{-85,54,5},{-86,54,5},{-87,54,5},{-88,54,5},{-89,54,5},{-90,54,5},{-91,54,5}
+,{-92,54,5},{-93,54,5},{-94,54,5},{-95,54,5},{-96,54,5},{-97,54,5},{-98,54,5},{-99,54,5}
+,{-100,54,5},{-101,54,5},{-102,54,5},{-103,54,5},{-104,54,5},{-105,54,5},{-106,54,5},{-107,54,5}
+,{-108,54,5},{-109,54,5},{-110,54,5},{-111,54,5},{-112,54,5},{-113,54,5},{-114,54,5},{-115,54,5}
+,{-116,54,5},{-117,54,5},{-118,54,5},{-119,54,5},{-120,54,5},{-121,54,5},{-122,54,5},{-123,54,5}
+,{-124,54,5},{-125,54,5},{-126,54,5},{-127,54,5},{-128,54,5},{-129,54,5},{-130,54,5},{-131,54,5}
+,{-132,54,5},{-133,54,5},{-134,54,5},{-160,54,5},{-161,54,5},{-162,54,5},{-163,54,5},{-164,54,5}
+,{-165,54,5},{-166,54,5},{-167,54,5},{-50,0,6},{-51,0,6},{-52,0,6},{-53,0,6},{-54,0,6}
+,{-55,0,6},{-56,0,6},{-57,0,6},{-58,0,6},{-59,0,6},{-60,0,6},{-61,0,6},{-62,0,6}
+,{-63,0,6},{-64,0,6},{-65,0,6},{-66,0,6},{-67,0,6},{-68,0,6},{-69,0,6},{-70,0,6}
+,{-71,0,6},{-72,0,6},{-73,0,6},{-74,0,6},{-75,0,6},{-76,0,6},{-77,0,6},{-78,0,6}
+,{-79,0,6},{-80,0,6},{-81,0,6},{-90,0,6},{-91,0,6},{-92,0,6},{-50,1,6},{-51,1,6}
+,{-52,1,6},{-53,1,6},{-54,1,6},{-55,1,6},{-56,1,6},{-57,1,6},{-58,1,6},{-59,1,6}
+,{-60,1,6},{-61,1,6},{-62,1,6},{-63,1,6},{-64,1,6},{-65,1,6},{-66,1,6},{-67,1,6}
+,{-68,1,6},{-69,1,6},{-70,1,6},{-71,1,6},{-72,1,6},{-73,1,6},{-74,1,6},{-75,1,6}
+,{-76,1,6},{-77,1,6},{-78,1,6},{-79,1,6},{-80,1,6},{-92,1,6},{-51,2,6},{-52,2,6}
+,{-53,2,6},{-54,2,6},{-55,2,6},{-56,2,6},{-57,2,6},{-58,2,6},{-59,2,6},{-60,2,6}
+,{-61,2,6},{-62,2,6},{-63,2,6},{-64,2,6},{-65,2,6},{-66,2,6},{-67,2,6},{-68,2,6}
+,{-69,2,6},{-70,2,6},{-71,2,6},{-72,2,6},{-73,2,6},{-74,2,6},{-75,2,6},{-76,2,6}
+,{-77,2,6},{-78,2,6},{-79,2,6},{-51,3,6},{-52,3,6},{-53,3,6},{-54,3,6},{-55,3,6}
+,{-56,3,6},{-57,3,6},{-58,3,6},{-59,3,6},{-60,3,6},{-61,3,6},{-62,3,6},{-63,3,6}
+,{-64,3,6},{-65,3,6},{-66,3,6},{-67,3,6},{-68,3,6},{-69,3,6},{-70,3,6},{-71,3,6}
+,{-72,3,6},{-73,3,6},{-74,3,6},{-75,3,6},{-76,3,6},{-77,3,6},{-78,3,6},{-79,3,6}
+,{-82,3,6},{-52,4,6},{-53,4,6},{-54,4,6},{-55,4,6},{-56,4,6},{-57,4,6},{-58,4,6}
+,{-59,4,6},{-60,4,6},{-61,4,6},{-62,4,6},{-63,4,6},{-64,4,6},{-65,4,6},{-66,4,6}
+,{-67,4,6},{-68,4,6},{-69,4,6},{-70,4,6},{-71,4,6},{-72,4,6},{-73,4,6},{-74,4,6}
+,{-75,4,6},{-76,4,6},{-77,4,6},{-78,4,6},{-82,4,6},{-53,5,6},{-54,5,6},{-55,5,6}
+,{-56,5,6},{-57,5,6},{-58,5,6},{-59,5,6},{-60,5,6},{-61,5,6},{-62,5,6},{-63,5,6}
+,{-64,5,6},{-65,5,6},{-66,5,6},{-67,5,6},{-68,5,6},{-69,5,6},{-70,5,6},{-71,5,6}
+,{-72,5,6},{-73,5,6},{-74,5,6},{-75,5,6},{-76,5,6},{-77,5,6},{-78,5,6},{-88,5,6}
+,{-56,6,6},{-57,6,6},{-58,6,6},{-59,6,6},{-60,6,6},{-61,6,6},{-62,6,6},{-63,6,6}
+,{-64,6,6},{-65,6,6},{-66,6,6},{-67,6,6},{-68,6,6},{-69,6,6},{-70,6,6},{-71,6,6}
+,{-72,6,6},{-73,6,6},{-74,6,6},{-75,6,6},{-76,6,6},{-77,6,6},{-78,6,6},{-59,7,6}
+,{-60,7,6},{-61,7,6},{-62,7,6},{-63,7,6},{-64,7,6},{-65,7,6},{-66,7,6},{-67,7,6}
+,{-68,7,6},{-69,7,6},{-70,7,6},{-71,7,6},{-72,7,6},{-73,7,6},{-74,7,6},{-75,7,6}
+,{-76,7,6},{-77,7,6},{-78,7,6},{-79,7,6},{-80,7,6},{-81,7,6},{-82,7,6},{-83,7,6}
+,{-60,8,6},{-61,8,6},{-62,8,6},{-63,8,6},{-64,8,6},{-65,8,6},{-66,8,6},{-67,8,6}
+,{-68,8,6},{-69,8,6},{-70,8,6},{-71,8,6},{-72,8,6},{-73,8,6},{-74,8,6},{-75,8,6}
+,{-76,8,6},{-77,8,6},{-78,8,6},{-79,8,6},{-80,8,6},{-81,8,6},{-82,8,6},{-83,8,6}
+,{-84,8,6},{-61,9,6},{-62,9,6},{-63,9,6},{-64,9,6},{-65,9,6},{-66,9,6},{-67,9,6}
+,{-68,9,6},{-69,9,6},{-70,9,6},{-71,9,6},{-72,9,6},{-73,9,6},{-74,9,6},{-75,9,6}
+,{-76,9,6},{-77,9,6},{-78,9,6},{-79,9,6},{-80,9,6},{-81,9,6},{-82,9,6},{-83,9,6}
+,{-84,9,6},{-85,9,6},{-86,9,6},{-61,10,6},{-62,10,6},{-63,10,6},{-64,10,6},{-65,10,6}
+,{-66,10,6},{-67,10,6},{-68,10,6},{-69,10,6},{-70,10,6},{-71,10,6},{-72,10,6},{-73,10,6}
+,{-74,10,6},{-75,10,6},{-76,10,6},{-84,10,6},{-85,10,6},{-86,10,6},{-61,11,6},{-62,11,6}
+,{-64,11,6},{-65,11,6},{-67,11,6},{-68,11,6},{-69,11,6},{-70,11,6},{-71,11,6},{-72,11,6}
+,{-73,11,6},{-74,11,6},{-75,11,6},{-84,11,6},{-85,11,6},{-86,11,6},{-87,11,6},{-62,12,6}
+,{-69,12,6},{-70,12,6},{-71,12,6},{-72,12,6},{-73,12,6},{-82,12,6},{-83,12,6},{-84,12,6}
+,{-85,12,6},{-86,12,6},{-87,12,6},{-88,12,6},{-60,13,6},{-61,13,6},{-62,13,6},{-81,13,6}
+,{-82,13,6},{-84,13,6},{-85,13,6},{-86,13,6},{-87,13,6},{-88,13,6},{-89,13,6},{-90,13,6}
+,{-91,13,6},{-92,13,6},{-61,14,6},{-62,14,6},{-81,14,6},{-83,14,6},{-84,14,6},{-85,14,6}
+,{-86,14,6},{-87,14,6},{-88,14,6},{-89,14,6},{-90,14,6},{-91,14,6},{-92,14,6},{-93,14,6}
+,{-47,-1,6},{-48,-1,6},{-49,-1,6},{-50,-1,6},{-51,-1,6},{-52,-1,6},{-53,-1,6},{-54,-1,6}
+,{-55,-1,6},{-56,-1,6},{-57,-1,6},{-58,-1,6},{-59,-1,6},{-60,-1,6},{-61,-1,6},{-62,-1,6}
+,{-63,-1,6},{-64,-1,6},{-65,-1,6},{-66,-1,6},{-67,-1,6},{-68,-1,6},{-69,-1,6},{-70,-1,6}
+,{-71,-1,6},{-72,-1,6},{-73,-1,6},{-74,-1,6},{-75,-1,6},{-76,-1,6},{-77,-1,6},{-78,-1,6}
+,{-79,-1,6},{-80,-1,6},{-81,-1,6},{-90,-1,6},{-91,-1,6},{-92,-1,6},{-45,-2,6},{-46,-2,6}
+,{-47,-2,6},{-48,-2,6},{-49,-2,6},{-50,-2,6},{-51,-2,6},{-52,-2,6},{-53,-2,6},{-54,-2,6}
+,{-55,-2,6},{-56,-2,6},{-57,-2,6},{-58,-2,6},{-59,-2,6},{-60,-2,6},{-61,-2,6},{-62,-2,6}
+,{-63,-2,6},{-64,-2,6},{-65,-2,6},{-66,-2,6},{-67,-2,6},{-68,-2,6},{-69,-2,6},{-70,-2,6}
+,{-71,-2,6},{-72,-2,6},{-73,-2,6},{-74,-2,6},{-75,-2,6},{-76,-2,6},{-77,-2,6},{-78,-2,6}
+,{-79,-2,6},{-80,-2,6},{-81,-2,6},{-82,-2,6},{-90,-2,6},{-91,-2,6},{-92,-2,6},{-40,-3,6}
+,{-41,-3,6},{-42,-3,6},{-43,-3,6},{-44,-3,6},{-45,-3,6},{-46,-3,6},{-47,-3,6},{-48,-3,6}
+,{-49,-3,6},{-50,-3,6},{-51,-3,6},{-52,-3,6},{-53,-3,6},{-54,-3,6},{-55,-3,6},{-56,-3,6}
+,{-57,-3,6},{-58,-3,6},{-59,-3,6},{-60,-3,6},{-61,-3,6},{-62,-3,6},{-63,-3,6},{-64,-3,6}
+,{-65,-3,6},{-66,-3,6},{-67,-3,6},{-68,-3,6},{-69,-3,6},{-70,-3,6},{-71,-3,6},{-72,-3,6}
+,{-73,-3,6},{-74,-3,6},{-75,-3,6},{-76,-3,6},{-77,-3,6},{-78,-3,6},{-79,-3,6},{-80,-3,6}
+,{-81,-3,6},{-82,-3,6},{-33,-4,6},{-34,-4,6},{-39,-4,6},{-40,-4,6},{-41,-4,6},{-42,-4,6}
+,{-43,-4,6},{-44,-4,6},{-45,-4,6},{-46,-4,6},{-47,-4,6},{-48,-4,6},{-49,-4,6},{-50,-4,6}
+,{-51,-4,6},{-52,-4,6},{-53,-4,6},{-54,-4,6},{-55,-4,6},{-56,-4,6},{-57,-4,6},{-58,-4,6}
+,{-59,-4,6},{-60,-4,6},{-61,-4,6},{-62,-4,6},{-63,-4,6},{-64,-4,6},{-65,-4,6},{-66,-4,6}
+,{-67,-4,6},{-68,-4,6},{-69,-4,6},{-70,-4,6},{-71,-4,6},{-72,-4,6},{-73,-4,6},{-74,-4,6}
+,{-75,-4,6},{-76,-4,6},{-77,-4,6},{-78,-4,6},{-79,-4,6},{-80,-4,6},{-81,-4,6},{-37,-5,6}
+,{-38,-5,6},{-39,-5,6},{-40,-5,6},{-41,-5,6},{-42,-5,6},{-43,-5,6},{-44,-5,6},{-45,-5,6}
+,{-46,-5,6},{-47,-5,6},{-48,-5,6},{-49,-5,6},{-50,-5,6},{-51,-5,6},{-52,-5,6},{-53,-5,6}
+,{-54,-5,6},{-55,-5,6},{-56,-5,6},{-57,-5,6},{-58,-5,6},{-59,-5,6},{-60,-5,6},{-61,-5,6}
+,{-62,-5,6},{-63,-5,6},{-64,-5,6},{-65,-5,6},{-66,-5,6},{-67,-5,6},{-68,-5,6},{-69,-5,6}
+,{-70,-5,6},{-71,-5,6},{-72,-5,6},{-73,-5,6},{-74,-5,6},{-75,-5,6},{-76,-5,6},{-77,-5,6}
+,{-78,-5,6},{-79,-5,6},{-80,-5,6},{-81,-5,6},{-82,-5,6},{-36,-6,6},{-37,-6,6},{-38,-6,6}
+,{-39,-6,6},{-40,-6,6},{-41,-6,6},{-42,-6,6},{-43,-6,6},{-44,-6,6},{-45,-6,6},{-46,-6,6}
+,{-47,-6,6},{-48,-6,6},{-49,-6,6},{-50,-6,6},{-51,-6,6},{-52,-6,6},{-53,-6,6},{-54,-6,6}
+,{-55,-6,6},{-56,-6,6},{-57,-6,6},{-58,-6,6},{-59,-6,6},{-60,-6,6},{-61,-6,6},{-62,-6,6}
+,{-63,-6,6},{-64,-6,6},{-65,-6,6},{-66,-6,6},{-67,-6,6},{-68,-6,6},{-69,-6,6},{-70,-6,6}
+,{-71,-6,6},{-72,-6,6},{-73,-6,6},{-74,-6,6},{-75,-6,6},{-76,-6,6},{-77,-6,6},{-78,-6,6}
+,{-79,-6,6},{-80,-6,6},{-81,-6,6},{-82,-6,6},{-35,-7,6},{-36,-7,6},{-37,-7,6},{-38,-7,6}
+,{-39,-7,6},{-40,-7,6},{-41,-7,6},{-42,-7,6},{-43,-7,6},{-44,-7,6},{-45,-7,6},{-46,-7,6}
+,{-47,-7,6},{-48,-7,6},{-49,-7,6},{-50,-7,6},{-51,-7,6},{-52,-7,6},{-53,-7,6},{-54,-7,6}
+,{-55,-7,6},{-56,-7,6},{-57,-7,6},{-58,-7,6},{-59,-7,6},{-60,-7,6},{-61,-7,6},{-62,-7,6}
+,{-63,-7,6},{-64,-7,6},{-65,-7,6},{-66,-7,6},{-67,-7,6},{-68,-7,6},{-69,-7,6},{-70,-7,6}
+,{-71,-7,6},{-72,-7,6},{-73,-7,6},{-74,-7,6},{-75,-7,6},{-76,-7,6},{-77,-7,6},{-78,-7,6}
+,{-79,-7,6},{-80,-7,6},{-81,-7,6},{-82,-7,6},{-35,-8,6},{-36,-8,6},{-37,-8,6},{-38,-8,6}
+,{-39,-8,6},{-40,-8,6},{-41,-8,6},{-42,-8,6},{-43,-8,6},{-44,-8,6},{-45,-8,6},{-46,-8,6}
+,{-47,-8,6},{-48,-8,6},{-49,-8,6},{-50,-8,6},{-51,-8,6},{-52,-8,6},{-53,-8,6},{-54,-8,6}
+,{-55,-8,6},{-56,-8,6},{-57,-8,6},{-58,-8,6},{-59,-8,6},{-60,-8,6},{-61,-8,6},{-62,-8,6}
+,{-63,-8,6},{-64,-8,6},{-65,-8,6},{-66,-8,6},{-67,-8,6},{-68,-8,6},{-69,-8,6},{-70,-8,6}
+,{-71,-8,6},{-72,-8,6},{-73,-8,6},{-74,-8,6},{-75,-8,6},{-76,-8,6},{-77,-8,6},{-78,-8,6}
+,{-79,-8,6},{-80,-8,6},{-35,-9,6},{-36,-9,6},{-37,-9,6},{-38,-9,6},{-39,-9,6},{-40,-9,6}
+,{-41,-9,6},{-42,-9,6},{-43,-9,6},{-44,-9,6},{-45,-9,6},{-46,-9,6},{-47,-9,6},{-48,-9,6}
+,{-49,-9,6},{-50,-9,6},{-51,-9,6},{-52,-9,6},{-53,-9,6},{-54,-9,6},{-55,-9,6},{-56,-9,6}
+,{-57,-9,6},{-58,-9,6},{-59,-9,6},{-60,-9,6},{-61,-9,6},{-62,-9,6},{-63,-9,6},{-64,-9,6}
+,{-65,-9,6},{-66,-9,6},{-67,-9,6},{-68,-9,6},{-69,-9,6},{-70,-9,6},{-71,-9,6},{-72,-9,6}
+,{-73,-9,6},{-74,-9,6},{-75,-9,6},{-76,-9,6},{-77,-9,6},{-78,-9,6},{-79,-9,6},{-80,-9,6}
+,{-36,-10,6},{-37,-10,6},{-38,-10,6},{-39,-10,6},{-40,-10,6},{-41,-10,6},{-42,-10,6},{-43,-10,6}
+,{-44,-10,6},{-45,-10,6},{-46,-10,6},{-47,-10,6},{-48,-10,6},{-49,-10,6},{-50,-10,6},{-51,-10,6}
+,{-52,-10,6},{-53,-10,6},{-54,-10,6},{-55,-10,6},{-56,-10,6},{-57,-10,6},{-58,-10,6},{-59,-10,6}
+,{-60,-10,6},{-61,-10,6},{-62,-10,6},{-63,-10,6},{-64,-10,6},{-65,-10,6},{-66,-10,6},{-67,-10,6}
+,{-68,-10,6},{-69,-10,6},{-70,-10,6},{-71,-10,6},{-72,-10,6},{-73,-10,6},{-74,-10,6},{-75,-10,6}
+,{-76,-10,6},{-77,-10,6},{-78,-10,6},{-79,-10,6},{-37,-11,6},{-38,-11,6},{-39,-11,6},{-40,-11,6}
+,{-41,-11,6},{-42,-11,6},{-43,-11,6},{-44,-11,6},{-45,-11,6},{-46,-11,6},{-47,-11,6},{-48,-11,6}
+,{-49,-11,6},{-50,-11,6},{-51,-11,6},{-52,-11,6},{-53,-11,6},{-54,-11,6},{-55,-11,6},{-56,-11,6}
+,{-57,-11,6},{-58,-11,6},{-59,-11,6},{-60,-11,6},{-61,-11,6},{-62,-11,6},{-63,-11,6},{-64,-11,6}
+,{-65,-11,6},{-66,-11,6},{-67,-11,6},{-68,-11,6},{-69,-11,6},{-70,-11,6},{-71,-11,6},{-72,-11,6}
+,{-73,-11,6},{-74,-11,6},{-75,-11,6},{-76,-11,6},{-77,-11,6},{-78,-11,6},{-79,-11,6},{-38,-12,6}
+,{-39,-12,6},{-40,-12,6},{-41,-12,6},{-42,-12,6},{-43,-12,6},{-44,-12,6},{-45,-12,6},{-46,-12,6}
+,{-47,-12,6},{-48,-12,6},{-49,-12,6},{-50,-12,6},{-51,-12,6},{-52,-12,6},{-53,-12,6},{-54,-12,6}
+,{-55,-12,6},{-56,-12,6},{-57,-12,6},{-58,-12,6},{-59,-12,6},{-60,-12,6},{-61,-12,6},{-62,-12,6}
+,{-63,-12,6},{-64,-12,6},{-65,-12,6},{-66,-12,6},{-67,-12,6},{-68,-12,6},{-69,-12,6},{-70,-12,6}
+,{-71,-12,6},{-72,-12,6},{-73,-12,6},{-74,-12,6},{-75,-12,6},{-76,-12,6},{-77,-12,6},{-78,-12,6}
+,{-38,-13,6},{-39,-13,6},{-40,-13,6},{-41,-13,6},{-42,-13,6},{-43,-13,6},{-44,-13,6},{-45,-13,6}
+,{-46,-13,6},{-47,-13,6},{-48,-13,6},{-49,-13,6},{-50,-13,6},{-51,-13,6},{-52,-13,6},{-53,-13,6}
+,{-54,-13,6},{-55,-13,6},{-56,-13,6},{-57,-13,6},{-58,-13,6},{-59,-13,6},{-60,-13,6},{-61,-13,6}
+,{-62,-13,6},{-63,-13,6},{-64,-13,6},{-65,-13,6},{-66,-13,6},{-67,-13,6},{-68,-13,6},{-69,-13,6}
+,{-70,-13,6},{-71,-13,6},{-72,-13,6},{-73,-13,6},{-74,-13,6},{-75,-13,6},{-76,-13,6},{-77,-13,6}
+,{-78,-13,6},{-39,-14,6},{-40,-14,6},{-41,-14,6},{-42,-14,6},{-43,-14,6},{-44,-14,6},{-45,-14,6}
+,{-46,-14,6},{-47,-14,6},{-48,-14,6},{-49,-14,6},{-50,-14,6},{-51,-14,6},{-52,-14,6},{-53,-14,6}
+,{-54,-14,6},{-55,-14,6},{-56,-14,6},{-57,-14,6},{-58,-14,6},{-59,-14,6},{-60,-14,6},{-61,-14,6}
+,{-62,-14,6},{-63,-14,6},{-64,-14,6},{-65,-14,6},{-66,-14,6},{-67,-14,6},{-68,-14,6},{-69,-14,6}
+,{-70,-14,6},{-71,-14,6},{-72,-14,6},{-73,-14,6},{-74,-14,6},{-75,-14,6},{-76,-14,6},{-77,-14,6}
+,{-39,-15,6},{-40,-15,6},{-41,-15,6},{-42,-15,6},{-43,-15,6},{-44,-15,6},{-45,-15,6},{-46,-15,6}
+,{-47,-15,6},{-48,-15,6},{-49,-15,6},{-50,-15,6},{-51,-15,6},{-52,-15,6},{-53,-15,6},{-54,-15,6}
+,{-55,-15,6},{-56,-15,6},{-57,-15,6},{-58,-15,6},{-59,-15,6},{-60,-15,6},{-61,-15,6},{-62,-15,6}
+,{-63,-15,6},{-64,-15,6},{-65,-15,6},{-66,-15,6},{-67,-15,6},{-68,-15,6},{-69,-15,6},{-70,-15,6}
+,{-71,-15,6},{-72,-15,6},{-73,-15,6},{-74,-15,6},{-75,-15,6},{-76,-15,6},{-77,-15,6},{-39,-16,6}
+,{-40,-16,6},{-41,-16,6},{-42,-16,6},{-43,-16,6},{-44,-16,6},{-45,-16,6},{-46,-16,6},{-47,-16,6}
+,{-48,-16,6},{-49,-16,6},{-50,-16,6},{-51,-16,6},{-52,-16,6},{-53,-16,6},{-54,-16,6},{-55,-16,6}
+,{-56,-16,6},{-57,-16,6},{-58,-16,6},{-59,-16,6},{-60,-16,6},{-61,-16,6},{-62,-16,6},{-63,-16,6}
+,{-64,-16,6},{-65,-16,6},{-66,-16,6},{-67,-16,6},{-68,-16,6},{-69,-16,6},{-70,-16,6},{-71,-16,6}
+,{-72,-16,6},{-73,-16,6},{-74,-16,6},{-75,-16,6},{-76,-16,6},{-39,-17,6},{-40,-17,6},{-41,-17,6}
+,{-42,-17,6},{-43,-17,6},{-44,-17,6},{-45,-17,6},{-46,-17,6},{-47,-17,6},{-48,-17,6},{-49,-17,6}
+,{-50,-17,6},{-51,-17,6},{-52,-17,6},{-53,-17,6},{-54,-17,6},{-55,-17,6},{-56,-17,6},{-57,-17,6}
+,{-58,-17,6},{-59,-17,6},{-60,-17,6},{-61,-17,6},{-62,-17,6},{-63,-17,6},{-64,-17,6},{-65,-17,6}
+,{-66,-17,6},{-67,-17,6},{-68,-17,6},{-69,-17,6},{-70,-17,6},{-71,-17,6},{-72,-17,6},{-73,-17,6}
+,{-74,-17,6},{-75,-17,6},{-39,-18,6},{-40,-18,6},{-41,-18,6},{-42,-18,6},{-43,-18,6},{-44,-18,6}
+,{-45,-18,6},{-46,-18,6},{-47,-18,6},{-48,-18,6},{-49,-18,6},{-50,-18,6},{-51,-18,6},{-52,-18,6}
+,{-53,-18,6},{-54,-18,6},{-55,-18,6},{-56,-18,6},{-57,-18,6},{-58,-18,6},{-59,-18,6},{-60,-18,6}
+,{-61,-18,6},{-62,-18,6},{-63,-18,6},{-64,-18,6},{-65,-18,6},{-66,-18,6},{-67,-18,6},{-68,-18,6}
+,{-69,-18,6},{-70,-18,6},{-71,-18,6},{-72,-18,6},{-73,-18,6},{-40,-19,6},{-41,-19,6},{-42,-19,6}
+,{-43,-19,6},{-44,-19,6},{-45,-19,6},{-46,-19,6},{-47,-19,6},{-48,-19,6},{-49,-19,6},{-50,-19,6}
+,{-51,-19,6},{-52,-19,6},{-53,-19,6},{-54,-19,6},{-55,-19,6},{-56,-19,6},{-57,-19,6},{-58,-19,6}
+,{-59,-19,6},{-60,-19,6},{-61,-19,6},{-62,-19,6},{-63,-19,6},{-64,-19,6},{-65,-19,6},{-66,-19,6}
+,{-67,-19,6},{-68,-19,6},{-69,-19,6},{-70,-19,6},{-71,-19,6},{-40,-20,6},{-41,-20,6},{-42,-20,6}
+,{-43,-20,6},{-44,-20,6},{-45,-20,6},{-46,-20,6},{-47,-20,6},{-48,-20,6},{-49,-20,6},{-50,-20,6}
+,{-51,-20,6},{-52,-20,6},{-53,-20,6},{-54,-20,6},{-55,-20,6},{-56,-20,6},{-57,-20,6},{-58,-20,6}
+,{-59,-20,6},{-60,-20,6},{-61,-20,6},{-62,-20,6},{-63,-20,6},{-64,-20,6},{-65,-20,6},{-66,-20,6}
+,{-67,-20,6},{-68,-20,6},{-69,-20,6},{-70,-20,6},{-71,-20,6},{-41,-21,6},{-42,-21,6},{-43,-21,6}
+,{-44,-21,6},{-45,-21,6},{-46,-21,6},{-47,-21,6},{-48,-21,6},{-49,-21,6},{-50,-21,6},{-51,-21,6}
+,{-52,-21,6},{-53,-21,6},{-54,-21,6},{-55,-21,6},{-56,-21,6},{-57,-21,6},{-58,-21,6},{-59,-21,6}
+,{-60,-21,6},{-61,-21,6},{-62,-21,6},{-63,-21,6},{-64,-21,6},{-65,-21,6},{-66,-21,6},{-67,-21,6}
+,{-68,-21,6},{-69,-21,6},{-70,-21,6},{-71,-21,6},{-41,-22,6},{-42,-22,6},{-43,-22,6},{-44,-22,6}
+,{-45,-22,6},{-46,-22,6},{-47,-22,6},{-48,-22,6},{-49,-22,6},{-50,-22,6},{-51,-22,6},{-52,-22,6}
+,{-53,-22,6},{-54,-22,6},{-55,-22,6},{-56,-22,6},{-57,-22,6},{-58,-22,6},{-59,-22,6},{-60,-22,6}
+,{-61,-22,6},{-62,-22,6},{-63,-22,6},{-64,-22,6},{-65,-22,6},{-66,-22,6},{-67,-22,6},{-68,-22,6}
+,{-69,-22,6},{-70,-22,6},{-71,-22,6},{-41,-23,6},{-42,-23,6},{-43,-23,6},{-44,-23,6},{-45,-23,6}
+,{-46,-23,6},{-47,-23,6},{-48,-23,6},{-49,-23,6},{-50,-23,6},{-51,-23,6},{-52,-23,6},{-53,-23,6}
+,{-54,-23,6},{-55,-23,6},{-56,-23,6},{-57,-23,6},{-58,-23,6},{-59,-23,6},{-60,-23,6},{-61,-23,6}
+,{-62,-23,6},{-63,-23,6},{-64,-23,6},{-65,-23,6},{-66,-23,6},{-67,-23,6},{-68,-23,6},{-69,-23,6}
+,{-70,-23,6},{-71,-23,6},{-42,-24,6},{-43,-24,6},{-44,-24,6},{-45,-24,6},{-46,-24,6},{-47,-24,6}
+,{-48,-24,6},{-49,-24,6},{-50,-24,6},{-51,-24,6},{-52,-24,6},{-53,-24,6},{-54,-24,6},{-55,-24,6}
+,{-56,-24,6},{-57,-24,6},{-58,-24,6},{-59,-24,6},{-60,-24,6},{-61,-24,6},{-62,-24,6},{-63,-24,6}
+,{-64,-24,6},{-65,-24,6},{-66,-24,6},{-67,-24,6},{-68,-24,6},{-69,-24,6},{-70,-24,6},{-71,-24,6}
+,{-46,-25,6},{-47,-25,6},{-48,-25,6},{-49,-25,6},{-50,-25,6},{-51,-25,6},{-52,-25,6},{-53,-25,6}
+,{-54,-25,6},{-55,-25,6},{-56,-25,6},{-57,-25,6},{-58,-25,6},{-59,-25,6},{-60,-25,6},{-61,-25,6}
+,{-62,-25,6},{-63,-25,6},{-64,-25,6},{-65,-25,6},{-66,-25,6},{-67,-25,6},{-68,-25,6},{-69,-25,6}
+,{-70,-25,6},{-71,-25,6},{-48,-26,6},{-49,-26,6},{-50,-26,6},{-51,-26,6},{-52,-26,6},{-53,-26,6}
+,{-54,-26,6},{-55,-26,6},{-56,-26,6},{-57,-26,6},{-58,-26,6},{-59,-26,6},{-60,-26,6},{-61,-26,6}
+,{-62,-26,6},{-63,-26,6},{-64,-26,6},{-65,-26,6},{-66,-26,6},{-67,-26,6},{-68,-26,6},{-69,-26,6}
+,{-70,-26,6},{-71,-26,6},{-49,-27,6},{-50,-27,6},{-51,-27,6},{-52,-27,6},{-53,-27,6},{-54,-27,6}
+,{-55,-27,6},{-56,-27,6},{-57,-27,6},{-58,-27,6},{-59,-27,6},{-60,-27,6},{-61,-27,6},{-62,-27,6}
+,{-63,-27,6},{-64,-27,6},{-65,-27,6},{-66,-27,6},{-67,-27,6},{-68,-27,6},{-69,-27,6},{-70,-27,6}
+,{-71,-27,6},{-80,-27,6},{-81,-27,6},{-49,-28,6},{-50,-28,6},{-51,-28,6},{-52,-28,6},{-53,-28,6}
+,{-54,-28,6},{-55,-28,6},{-56,-28,6},{-57,-28,6},{-58,-28,6},{-59,-28,6},{-60,-28,6},{-61,-28,6}
+,{-62,-28,6},{-63,-28,6},{-64,-28,6},{-65,-28,6},{-66,-28,6},{-67,-28,6},{-68,-28,6},{-69,-28,6}
+,{-70,-28,6},{-71,-28,6},{-72,-28,6},{-49,-29,6},{-50,-29,6},{-51,-29,6},{-52,-29,6},{-53,-29,6}
+,{-54,-29,6},{-55,-29,6},{-56,-29,6},{-57,-29,6},{-58,-29,6},{-59,-29,6},{-60,-29,6},{-61,-29,6}
+,{-62,-29,6},{-63,-29,6},{-64,-29,6},{-65,-29,6},{-66,-29,6},{-67,-29,6},{-68,-29,6},{-69,-29,6}
+,{-70,-29,6},{-71,-29,6},{-72,-29,6},{-50,-30,6},{-51,-30,6},{-52,-30,6},{-53,-30,6},{-54,-30,6}
+,{-55,-30,6},{-56,-30,6},{-57,-30,6},{-58,-30,6},{-59,-30,6},{-60,-30,6},{-61,-30,6},{-62,-30,6}
+,{-63,-30,6},{-64,-30,6},{-65,-30,6},{-66,-30,6},{-67,-30,6},{-68,-30,6},{-69,-30,6},{-70,-30,6}
+,{-71,-30,6},{-72,-30,6},{-51,-31,6},{-52,-31,6},{-53,-31,6},{-54,-31,6},{-55,-31,6},{-56,-31,6}
+,{-57,-31,6},{-58,-31,6},{-59,-31,6},{-60,-31,6},{-61,-31,6},{-62,-31,6},{-63,-31,6},{-64,-31,6}
+,{-65,-31,6},{-66,-31,6},{-67,-31,6},{-68,-31,6},{-69,-31,6},{-70,-31,6},{-71,-31,6},{-72,-31,6}
+,{-51,-32,6},{-52,-32,6},{-53,-32,6},{-54,-32,6},{-55,-32,6},{-56,-32,6},{-57,-32,6},{-58,-32,6}
+,{-59,-32,6},{-60,-32,6},{-61,-32,6},{-62,-32,6},{-63,-32,6},{-64,-32,6},{-65,-32,6},{-66,-32,6}
+,{-67,-32,6},{-68,-32,6},{-69,-32,6},{-70,-32,6},{-71,-32,6},{-72,-32,6},{-52,-33,6},{-53,-33,6}
+,{-54,-33,6},{-55,-33,6},{-56,-33,6},{-57,-33,6},{-58,-33,6},{-59,-33,6},{-60,-33,6},{-61,-33,6}
+,{-62,-33,6},{-63,-33,6},{-64,-33,6},{-65,-33,6},{-66,-33,6},{-67,-33,6},{-68,-33,6},{-69,-33,6}
+,{-70,-33,6},{-71,-33,6},{-72,-33,6},{-53,-34,6},{-54,-34,6},{-55,-34,6},{-56,-34,6},{-57,-34,6}
+,{-58,-34,6},{-59,-34,6},{-60,-34,6},{-61,-34,6},{-62,-34,6},{-63,-34,6},{-64,-34,6},{-65,-34,6}
+,{-66,-34,6},{-67,-34,6},{-68,-34,6},{-69,-34,6},{-70,-34,6},{-71,-34,6},{-72,-34,6},{-79,-34,6}
+,{-81,-34,6},{-54,-35,6},{-55,-35,6},{-56,-35,6},{-57,-35,6},{-58,-35,6},{-59,-35,6},{-60,-35,6}
+,{-61,-35,6},{-62,-35,6},{-63,-35,6},{-64,-35,6},{-65,-35,6},{-66,-35,6},{-67,-35,6},{-68,-35,6}
+,{-69,-35,6},{-70,-35,6},{-71,-35,6},{-72,-35,6},{-73,-35,6},{-58,-36,6},{-59,-36,6},{-60,-36,6}
+,{-61,-36,6},{-62,-36,6},{-63,-36,6},{-64,-36,6},{-65,-36,6},{-66,-36,6},{-67,-36,6},{-68,-36,6}
+,{-69,-36,6},{-70,-36,6},{-71,-36,6},{-72,-36,6},{-73,-36,6},{-57,-37,6},{-58,-37,6},{-59,-37,6}
+,{-60,-37,6},{-61,-37,6},{-62,-37,6},{-63,-37,6},{-64,-37,6},{-65,-37,6},{-66,-37,6},{-67,-37,6}
+,{-68,-37,6},{-69,-37,6},{-70,-37,6},{-71,-37,6},{-72,-37,6},{-73,-37,6},{-74,-37,6},{-57,-38,6}
+,{-58,-38,6},{-59,-38,6},{-60,-38,6},{-61,-38,6},{-62,-38,6},{-63,-38,6},{-64,-38,6},{-65,-38,6}
+,{-66,-38,6},{-67,-38,6},{-68,-38,6},{-69,-38,6},{-70,-38,6},{-71,-38,6},{-72,-38,6},{-73,-38,6}
+,{-74,-38,6},{-58,-39,6},{-59,-39,6},{-60,-39,6},{-61,-39,6},{-62,-39,6},{-63,-39,6},{-64,-39,6}
+,{-65,-39,6},{-66,-39,6},{-67,-39,6},{-68,-39,6},{-69,-39,6},{-70,-39,6},{-71,-39,6},{-72,-39,6}
+,{-73,-39,6},{-74,-39,6},{-62,-40,6},{-63,-40,6},{-64,-40,6},{-65,-40,6},{-66,-40,6},{-67,-40,6}
+,{-68,-40,6},{-69,-40,6},{-70,-40,6},{-71,-40,6},{-72,-40,6},{-73,-40,6},{-74,-40,6},{-63,-41,6}
+,{-64,-41,6},{-65,-41,6},{-66,-41,6},{-67,-41,6},{-68,-41,6},{-69,-41,6},{-70,-41,6},{-71,-41,6}
+,{-72,-41,6},{-73,-41,6},{-74,-41,6},{-63,-42,6},{-64,-42,6},{-65,-42,6},{-66,-42,6},{-67,-42,6}
+,{-68,-42,6},{-69,-42,6},{-70,-42,6},{-71,-42,6},{-72,-42,6},{-73,-42,6},{-74,-42,6},{-75,-42,6}
+,{-64,-43,6},{-65,-43,6},{-66,-43,6},{-67,-43,6},{-68,-43,6},{-69,-43,6},{-70,-43,6},{-71,-43,6}
+,{-72,-43,6},{-73,-43,6},{-74,-43,6},{-75,-43,6},{-65,-44,6},{-66,-44,6},{-67,-44,6},{-68,-44,6}
+,{-69,-44,6},{-70,-44,6},{-71,-44,6},{-72,-44,6},{-73,-44,6},{-74,-44,6},{-75,-44,6},{-66,-45,6}
+,{-67,-45,6},{-68,-45,6},{-69,-45,6},{-70,-45,6},{-71,-45,6},{-72,-45,6},{-73,-45,6},{-74,-45,6}
+,{-75,-45,6},{-76,-45,6},{-66,-46,6},{-67,-46,6},{-68,-46,6},{-69,-46,6},{-70,-46,6},{-71,-46,6}
+,{-72,-46,6},{-73,-46,6},{-74,-46,6},{-75,-46,6},{-76,-46,6},{-67,-47,6},{-68,-47,6},{-69,-47,6}
+,{-70,-47,6},{-71,-47,6},{-72,-47,6},{-73,-47,6},{-74,-47,6},{-75,-47,6},{-76,-47,6},{-66,-48,6}
+,{-67,-48,6},{-68,-48,6},{-69,-48,6},{-70,-48,6},{-71,-48,6},{-72,-48,6},{-73,-48,6},{-74,-48,6}
+,{-75,-48,6},{-76,-48,6},{-66,-49,6},{-67,-49,6},{-68,-49,6},{-69,-49,6},{-70,-49,6},{-71,-49,6}
+,{-72,-49,6},{-73,-49,6},{-74,-49,6},{-75,-49,6},{-76,-49,6},{-68,-50,6},{-69,-50,6},{-70,-50,6}
+,{-71,-50,6},{-72,-50,6},{-73,-50,6},{-74,-50,6},{-75,-50,6},{-76,-50,6},{-62,-51,6},{-68,-51,6}
+,{-69,-51,6},{-70,-51,6},{-71,-51,6},{-72,-51,6},{-73,-51,6},{-74,-51,6},{-75,-51,6},{-76,-51,6}
+,{-58,-52,6},{-59,-52,6},{-60,-52,6},{-61,-52,6},{-62,-52,6},{-69,-52,6},{-70,-52,6},{-71,-52,6}
+,{-72,-52,6},{-73,-52,6},{-74,-52,6},{-75,-52,6},{-76,-52,6},{-59,-53,6},{-60,-53,6},{-61,-53,6}
+,{-62,-53,6},{-69,-53,6},{-70,-53,6},{-71,-53,6},{-72,-53,6},{-73,-53,6},{-74,-53,6},{-75,-53,6}
+,{-76,-53,6},{-68,-54,6},{-69,-54,6},{-70,-54,6},{-71,-54,6},{-72,-54,6},{-73,-54,6},{-74,-54,6}
+,{-75,-54,6},{-64,-55,6},{-65,-55,6},{-66,-55,6},{-67,-55,6},{-68,-55,6},{-69,-55,6},{-70,-55,6}
+,{-71,-55,6},{-72,-55,6},{-73,-55,6},{-74,-55,6},{-67,-56,6},{-68,-56,6},{-69,-56,6},{-70,-56,6}
 };
 
-}
-}
+otb::Wrapper::DownloadSRTMTiles
+::DownloadSRTMTiles()
+  : m_SRTMTileList(std::begin(staticTileList),std::end(staticTileList))
+{}
 
 OTB_APPLICATION_EXPORT(otb::Wrapper::DownloadSRTMTiles)
diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx
index b7a4110..1f0221e 100644
--- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx
+++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx
@@ -20,12 +20,13 @@
 
 #include "otbWrapperApplication.h"
 #include "otbWrapperApplicationFactory.h"
-
 #include "otbMultiChannelExtractROI.h"
 #include "otbStandardFilterWatcher.h"
 #include "otbWrapperNumericalParameter.h"
 #include "otbWrapperListViewParameter.h"
 #include "otbWrapperTypes.h"
+#include "otbOGRDataSourceToLabelImageFilter.h"
+#include <algorithm> 
 
 #include "otbWrapperElevationParametersHandler.h"
 
@@ -55,42 +56,146 @@ public:
 
   /** Filters typedef */
   typedef otb::MultiChannelExtractROI<FloatVectorImageType::InternalPixelType,
-                                      FloatVectorImageType::InternalPixelType> ExtractROIFilterType;
+                                      FloatVectorImageType::InternalPixelType> 
+                                      ExtractROIFilterType;
+
+  typedef ExtractROIFilterType::InputImageType ImageType;
 
 private:
-  void DoInit() ITK_OVERRIDE
+  void 
+  DoInit() ITK_OVERRIDE
   {
     SetName("ExtractROI");
     SetDescription("Extract a ROI defined by the user.");
 
     // Documentation
     SetDocName("Extract ROI");
-    SetDocLongDescription("This application extracts a Region Of Interest with user defined size, or reference image.");
+    SetDocLongDescription("This application extracts a Region Of Interest with "
+      "user parameters. There are four mode of extraction. The standard mode "
+      "allows the user to enter one point (upper left corner of the region to "
+      "extract) and a size. The extent mode needs two points (upper left "
+      "corner and lower right) and the radius mode need the center of the "
+      "region and the radius : it will extract the rectangle containing the "
+      "circle defined and limited by the image dimension. The fit mode "
+      "needs a reference image or vector and the dimension of the extracted "
+      "region will be the same as the extent of the reference. "
+      "Different units are available such as pixel, image physical space "
+      "or longitude and latitude.");
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
     SetDocSeeAlso(" ");
 
     AddDocTag(Tags::Manip);
 
+    // Set parameter input
     AddParameter(ParameterType_InputImage,  "in",   "Input Image");
-    SetParameterDescription("in", "Input image.");
+    SetParameterDescription("in", "Image to be processed.");
     AddParameter(ParameterType_OutputImage, "out",  "Output Image");
-    SetParameterDescription("out", "Output image.");
+    SetParameterDescription("out", "Region of interest from the input image");
 
-    AddRAMParameter();
 
     AddParameter(ParameterType_Choice,"mode","Extraction mode");
     AddChoice("mode.standard","Standard");
-    SetParameterDescription("mode.standard","In standard mode, extract is done according the coordinates entered by the user");
-    AddChoice("mode.fit","Fit");
-    SetParameterDescription("mode.fit","In fit mode, extract is made to best fit a reference image.");
-
-    AddParameter(ParameterType_InputImage,"mode.fit.ref","Reference image");
-    SetParameterDescription("mode.fit.ref","Reference image to define the ROI");
-
-    // Elevation
-    ElevationParametersHandler::AddElevationParameters(this,"mode.fit.elev");
+    SetParameterDescription("mode.standard",
+      "In standard mode extraction is done with 2 parameters : the "
+      "upper left corner and the size of the region, decomposed "
+      "in X and Y coordinates.");
 
+    // Fit mode : the ROI is computed through a ref vector dataset or a ref image 
+    AddChoice("mode.fit","Fit");
+    SetParameterDescription("mode.fit",
+      "In fit mode, extract is made from a reference : image or vector dataset.");
+
+    AddParameter( ParameterType_InputImage , "mode.fit.im" , 
+      "Reference image" );
+    SetParameterDescription( "mode.fit.im" ,
+      "Reference image to define the ROI" );
+    AddParameter( ParameterType_InputVectorData , "mode.fit.vect" , 
+                  "Reference vector" );
+    SetParameterDescription( "mode.fit.vect" ,
+      "The extent of the input vector file is computed and then "
+      "gives a region of interest that will be extracted." );
+
+    // Extent mode : ROI is computed with two point (upper left and lower left corners)
+    AddChoice( "mode.extent" , "Extent" );
+    SetParameterDescription( "mode.extent" ,
+      "In extent mode, the ROI is defined by two points, the upper left corner "
+      "and the lower right corner, decomposed in 2 coordinates : "
+      "X and Y. The unit for those coordinates can be set." );
+    AddParameter( ParameterType_Float , "mode.extent.ulx" ,
+                  "X coordinate of the Upper left corner" );
+    SetParameterDescription( "mode.extent.ulx" ,
+      "X coordinate of upper left corner point." );
+    AddParameter( ParameterType_Float , "mode.extent.uly" ,
+                  "Y coordinate of Upper Left corner point." );
+    SetParameterDescription( "mode.extent.uly" ,
+      "Y coordinate of upper left corner point." );
+    AddParameter( ParameterType_Float , "mode.extent.lrx" , 
+                  "X coordinate of Lower Right corner point." );
+    SetParameterDescription( "mode.extent.lrx" ,
+      "X coordinate of lower right corner point." );
+    AddParameter( ParameterType_Float , "mode.extent.lry" ,
+                  "Y coordinate of Lower Right corner point." );
+    SetParameterDescription( "mode.extent.lry" ,
+      "Y coordinate of lower right corner point." );
+    // Unit of extent mode
+    AddParameter( ParameterType_Choice , "mode.extent.unit" , "Unit" );
+    AddChoice( "mode.extent.unit.pxl" , "Pixel" );
+    SetParameterDescription("mode.extent.unit.pxl",
+      "The unit for the parameters coordinates will be the pixel, meaning the "
+      "index of the two points.");
+    AddChoice( "mode.extent.unit.phy" , "Image physical space" );
+    SetParameterDescription("mode.extent.unit.phy",
+      "The unit for the parameters coordinates will be the physical "
+      "measure of the image.");
+    AddChoice( "mode.extent.unit.lonlat" , "Longitude and latitude" );
+    SetParameterDescription("mode.extent.unit.lonlat",
+      "The unit for the parameters coordinates will be the longitude and "
+      "the latitude.");
+
+
+    // Radius mode : ROI is computed through a point and a radius
+    AddChoice( "mode.radius" , "Radius" );
+    SetParameterDescription( "mode.radius" ,
+      "In radius mode, the ROI is defined by a point and a radius. The "
+      "unit of those two parameters can be chosen independently." );
+
+    AddParameter( ParameterType_Float , "mode.radius.r" , "Radius" );
+    SetParameterDescription( "mode.radius.r" ,
+      "This is the radius parameter of the radius mode." );
+    AddParameter( ParameterType_Choice , "mode.radius.unitr" , "Radius unit" );
+    AddChoice( "mode.radius.unitr.pxl" , "Pixel" );
+    SetParameterDescription("mode.radius.unitr.pxl",
+      "The unit of the radius will be the pixel.");
+    AddChoice( "mode.radius.unitr.phy" , "Image physical space" );
+    SetParameterDescription("mode.radius.unitr.phy",
+      "The unit of the radius will be the physical measure of the image.");
+
+    AddParameter( ParameterType_Float , "mode.radius.cx" ,
+                  "X coordinate of the center" );
+    SetParameterDescription( "mode.radius.cx" ,
+      "This is the center coordinate of the radius mode, it will be either an "
+      "abscissa or a longitude." );
+    AddParameter( ParameterType_Float , "mode.radius.cy" ,
+                  "Y coordinate of the center" );
+    SetParameterDescription( "mode.radius.cx" ,
+      "This is the center coordinate of the radius mode, it will be either an "
+      "ordinate or a latitude." );
+    AddParameter( ParameterType_Choice , "mode.radius.unitc" , "Center unit" );
+    AddChoice( "mode.radius.unitc.pxl" , "Pixel" );
+    SetParameterDescription("mode.radius.unitc.pxl",
+      "The unit for the center coordinates will be the pixel");
+    AddChoice( "mode.radius.unitc.phy" , "Image physical space" );
+    SetParameterDescription("mode.radius.unitc.phy",
+      "The unit for the center coordinates will be the physical "
+      "measure of the image.");
+    AddChoice( "mode.radius.unitc.lonlat" , "Lon/Lat" );
+    SetParameterDescription("mode.radius.unitc.lonlat",
+      "The unit for the center coordinates will be the longitude and "
+      "the latitude.");
+
+
+    // Standard parameter
     AddParameter(ParameterType_Int,  "startx", "Start X");
     SetParameterDescription("startx", "ROI start x position.");
     AddParameter(ParameterType_Int,  "starty", "Start Y");
@@ -100,47 +205,86 @@ private:
     AddParameter(ParameterType_Int,  "sizey",  "Size Y");
     SetParameterDescription("sizey","size along y in pixels.");
 
+    // Channelist Parameters
+    AddParameter(ParameterType_ListView,  "cl", "Output Image channels");
+    SetParameterDescription("cl","Channels to write in the output image.");
+
+    // Elevation
+    ElevationParametersHandler::AddElevationParameters(this,"elev");
+    AddRAMParameter();
+
     // Default values
     SetDefaultParameterInt("startx", 0);
     SetDefaultParameterInt("starty", 0);
     SetDefaultParameterInt("sizex",  0);
     SetDefaultParameterInt("sizey",  0);
 
-    // Channelist Parameters
-    AddParameter(ParameterType_ListView,  "cl", "Output Image channels");
-    SetParameterDescription("cl","Channels to write in the output image.");
+    SetDefaultParameterInt("mode.extent.ulx", 0);
+    SetDefaultParameterInt("mode.extent.uly", 0);
+    SetDefaultParameterInt("mode.extent.lry", 0);
+    SetDefaultParameterInt("mode.extent.lrx", 0);
+
+    SetDefaultParameterInt("mode.radius.r", 0);
+    SetDefaultParameterInt("mode.radius.cx", 0);
+    SetDefaultParameterInt("mode.radius.cy", 0);
+
 
     // Doc example parameter settings
     SetDocExampleParameterValue("in", "VegetationIndex.hd");
-    SetDocExampleParameterValue("startx", "40");
-    SetDocExampleParameterValue("starty", "250");
-    SetDocExampleParameterValue("sizex", "150");
-    SetDocExampleParameterValue("sizey", "150");
+    SetDocExampleParameterValue("mode", "extent");
+    SetDocExampleParameterValue("mode.extent.ulx", "40");
+    SetDocExampleParameterValue("mode.extent.uly", "40");
+    SetDocExampleParameterValue("mode.extent.lrx", "150");
+    SetDocExampleParameterValue("mode.extent.lry", "150");
     SetDocExampleParameterValue("out", "ExtractROI.tif");
+    SetMinimumParameterIntValue("sizex", 0);
+    SetMinimumParameterIntValue("sizey", 0);
+    SetMinimumParameterIntValue("startx", 0);
+    SetMinimumParameterIntValue("starty", 0);
+    SetMinimumParameterFloatValue( "mode.radius.r" , 0 );
 
     SetOfficialDocLink();
   }
 
-  void DoUpdateParameters() ITK_OVERRIDE
+  void 
+  DoUpdateParameters() ITK_OVERRIDE
   {
-    // Update the sizes only if the user has not defined a size
     if ( HasValue("in") )
       {
-      ExtractROIFilterType::InputImageType* inImage = GetParameterImage("in");
-      ExtractROIFilterType::InputImageType::RegionType  largestRegion = inImage->GetLargestPossibleRegion();
+      ImageType* inImage = GetParameterImage("in");
+      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" );
+
+      // 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);
+
+        // Compute extent parameter with default sizex and sizey
+        if ( GetParameterString( "mode" ) == "extent" && userExtent )
+          ComputeExtentFromIndex( inImage, largestRegion );
+
+        // Compute radius parameter with default sizex and sizey
+        if ( GetParameterString( "mode" ) == "radius" && userRadius )
+          ComputeRadiusFromIndex( inImage , largestRegion );
         }
 
+
       unsigned int nbComponents = inImage->GetNumberOfComponentsPerPixel();
-      ListViewParameter *clParam = dynamic_cast<ListViewParameter*>(GetParameterByKey("cl"));
+      ListViewParameter *clParam = 
+                  dynamic_cast<ListViewParameter*>(GetParameterByKey("cl"));
       // Update the values of the channels to be selected if nbComponents is changed
       if (clParam != ITK_NULLPTR && clParam->GetNbChoices() != nbComponents)
         {
-
         ClearChoices("cl");
         for (unsigned int idx = 0; idx < nbComponents; ++idx)
           {
@@ -152,18 +296,20 @@ private:
         }
 
       // Put the limit of the index and the size relative the image
-      SetMinimumParameterIntValue("sizex", 0);
-      SetMaximumParameterIntValue("sizex", largestRegion.GetSize(0));
-
-      SetMinimumParameterIntValue("sizey", 0);
-      SetMaximumParameterIntValue("sizey", largestRegion.GetSize(1));
-
-      SetMinimumParameterIntValue("startx", 0);
+      
+      SetMaximumParameterIntValue("sizex", largestRegion.GetSize(0));      
+      SetMaximumParameterIntValue("sizey", largestRegion.GetSize(1));      
       SetMaximumParameterIntValue("startx", largestRegion.GetSize(0));
-
-      SetMinimumParameterIntValue("starty", 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
       if(!this->CropRegionOfInterest())
@@ -173,34 +319,62 @@ private:
         SetParameterInt("starty",0, false);
         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);
+        this->DisableParameter("startx");
+        this->DisableParameter("starty");
+        this->DisableParameter("sizex");
+        this->DisableParameter("sizey");
+        }
+
+      else if(GetParameterString("mode")=="standard" || 
+              GetParameterString("mode")=="extent" ||
+              GetParameterString("mode")== "radius" )
+        {
+        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");
+        }
       }
 
-    if(GetParameterString("mode")=="fit")
+    // If not standard mode start and size parameter will be computed by the application
+    if ( GetParameterString( "mode" ) != "standard" )
       {
-      this->SetParameterRole("startx",Role_Output);
-      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");
+      MandatoryOff("startx");
+      MandatoryOff("starty");
+      MandatoryOff("sizex");
+      MandatoryOff("sizey");
+      }
+    else
+      {
+      MandatoryOn("startx");
+      MandatoryOn("starty");
+      MandatoryOn("sizex");
+      MandatoryOn("sizey");
+      }
 
+    if ( GetParameterString( "mode" ) == "fit" && HasValue( "mode.fit.im" ) )
+      {
+      MandatoryOff( "mode.fit.vect" );
+      MandatoryOn( "mode.fit.im" );
       }
-    else if(GetParameterString("mode")=="standard")
+    else if ( GetParameterString( "mode" ) == "fit" && 
+              HasValue( "mode.fit.vect" ) )
       {
-      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");
+      MandatoryOff( "mode.fit.im" );
+      MandatoryOn( "mode.fit.vect" );
       }
-  }
+  } 
 
   bool CropRegionOfInterest()
   {
@@ -209,33 +383,386 @@ private:
     region.SetSize(1,  GetParameterInt("sizey"));
     region.SetIndex(0, GetParameterInt("startx"));
     region.SetIndex(1, GetParameterInt("starty"));
-
     if ( HasValue("in") )
       {
-        if (region.Crop(GetParameterImage("in")->GetLargestPossibleRegion()))
+      if (region.Crop(GetParameterImage("in")->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"));
+        return true;
+        }
+      }
+    return false;
+  }
+
+  void
+  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" ) );
+      SetParameterInt( "startx", pixelValue , true );
+      pixelValue = std::round( GetParameterFloat( "mode.extent.lrx" ) \
+                   - pixelValue ) + 1 ;
+      SetParameterInt( "sizex", pixelValue , true );
+      pixelValue = std::round( GetParameterFloat( "mode.extent.uly" ) );
+      SetParameterInt( "starty", pixelValue , true );
+      pixelValue = std::round( GetParameterFloat( "mode.extent.lry" ) \
+                   - pixelValue ) + 1 ;
+      SetParameterInt( "sizey", pixelValue , true );
+      }
+    else if( GetParameterString( "mode.extent.unit" ) == "phy" )
+      {
+      itk::Point<float, 2> ulp,  lrp;
+      ulp[ 0 ] = GetParameterFloat( "mode.extent.ulx" );
+      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;
+      bool startin = inImage->TransformPhysicalPointToIndex(ulp,uli);
+      bool sizein = inImage->TransformPhysicalPointToIndex(lrp,lri);
+      if ( startin )
+        {
+        SetParameterInt( "startx", uli[0] , true );
+        SetParameterInt( "starty", uli[1] , true );
+        }
+        
+      if( startin && sizein )
+        {
+        SetParameterInt( "sizex", lri[0] - uli[0] + 1, true );
+        SetParameterInt( "sizey", lri[1] - uli[1] + 1, true );
+        }
+      }
+    else if( GetParameterString( "mode.extent.unit" ) == "lonlat" )
+      {
+      RSTransformType::Pointer rsTransform = RSTransformType::New();
+      ImageType* inImage = GetParameterImage("in");
+      rsTransform->SetOutputKeywordList( inImage->GetImageKeywordlist() );
+      rsTransform->SetOutputProjectionRef( inImage->GetProjectionRef() );
+      rsTransform->InstantiateTransform();
+      itk::Point<float, 2> ulp_in,  lrp_in , ulp_out , lrp_out;
+      ulp_in[ 0 ] = GetParameterFloat( "mode.extent.ulx" );
+      ulp_in[ 1 ] = GetParameterFloat( "mode.extent.uly" );
+      lrp_in[ 0 ] = GetParameterFloat( "mode.extent.lrx" );
+      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;
+      bool startin = inImage->TransformPhysicalPointToIndex(ulp_out,uli_out);
+      bool sizein = inImage->TransformPhysicalPointToIndex(lrp_out,lri_out);
+
+      if ( startin )
+        {
+        SetParameterInt( "startx", uli_out[0] , true );
+        SetParameterInt( "starty", uli_out[1] , true );
+        }
+            
+      if( startin && sizein )
+        {
+        SetParameterInt( "sizex", lri_out[0] - uli_out[0] + 1, true );
+        SetParameterInt( "sizey", lri_out[1] - uli_out[1] + 1, true );
+        }
+      }  
+  }
+
+  void
+  ComputeExtentFromIndex(const ImageType * input , 
+                         const ImageType::RegionType & largestRegion )
+  {
+    FloatVectorImageType::IndexType uli , lri;
+    uli.Fill(0);
+    lri[ 0 ] = largestRegion.GetSize()[0];
+    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);
+      }
+    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);
+
+      input->TransformIndexToPhysicalPoint(lri,lrp);
+      SetParameterFloat("mode.extent.lrx",lrp[0], false);
+      SetParameterFloat("mode.extent.lry",lrp[1], false);  
+      }
+    else if ( GetParameterString( "mode.extent.unit" ) == "lonlat" )
+      {
+      RSTransformType::Pointer rsTransform = RSTransformType::New();
+      rsTransform->SetInputKeywordList( input->GetImageKeywordlist() );
+      rsTransform->SetInputProjectionRef( input->GetProjectionRef() );
+      rsTransform->InstantiateTransform();
+      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 );
+
+      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 );
+      }
+  }
+
+  void
+  ComputeIndexFromRadius()
+  {
+    int pixelValue = -1;
+    assert( GetParameterString( "mode" ) == "radius" );
+    // First compute sizex sizey thanks to the radius
+    if ( HasUserValue( "mode.radius.r" ) )
+      {
+      if ( GetParameterString( "mode.radius.unitr" ) == "pxl" )
+        {
+        pixelValue = std::floor( 2 * GetParameterFloat( "mode.radius.r" ) ) + 1;
+        SetParameterInt( "sizey", pixelValue , true );
+        SetParameterInt( "sizex", pixelValue , true );
+        }
+      if ( GetParameterString( "mode.radius.unitr" ) == "phy" )
+        {
+        ImageType * inImage = GetParameterImage("in");
+        itk::Point<float, 2> radxp , radyp , ulp ;
+        FloatVectorImageType::IndexType radxi , radyi , uli;
+        uli.Fill(0);
+        inImage->TransformIndexToPhysicalPoint( uli , ulp );
+        radxp = ulp; 
+        radyp = ulp; 
+        radxp[0] += GetParameterFloat( "mode.radius.r" );
+        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 )
           {
-            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"));
-            return true;
+          pixelValue = std::min( radxi[0] , maxR );
           }
+        else if ( lgty )
+          {
+          pixelValue = std::min( radyi[1] , maxR );
+          }
+        else
+          {
+          pixelValue = maxR;
+          }
+        SetParameterInt( "sizey", 2 * pixelValue + 1 , true );
+        SetParameterInt( "sizex", 2 * pixelValue + 1 , true );
+        }
+      }
+
+    // Then compute startx and starty
+    bool size = ( HasValue("sizex")  && HasValue("sizey") );
+    if ( size ) 
+      {
+      int radiusxi = GetParameterInt("sizex") / 2 ;
+      int radiusyi = GetParameterInt("sizey") / 2 ;
+
+      if ( GetParameterString( "mode.radius.unitc" ) == "pxl" && size )
+        {
+        pixelValue = std::round(GetParameterFloat( "mode.radius.cx" ));
+        SetParameterInt( "startx", pixelValue - radiusxi , true );
+        pixelValue = std::round(GetParameterFloat( "mode.radius.cy" ));
+        SetParameterInt( "starty", pixelValue - radiusyi , true );
+        }
+      if ( GetParameterString( "mode.radius.unitc" ) == "phy" && size ) 
+        {
+        ImageType * inImage = GetParameterImage("in");
+        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 , true );
+          SetParameterInt( "starty", centeri[1] - radiusyi , true );
+          }
+        }
+      if ( GetParameterString( "mode.radius.unitc" ) == "lonlat" && size )
+        {
+        ImageType* inImage = GetParameterImage("in");
+        RSTransformType::Pointer rsTransform = RSTransformType::New();
+        rsTransform->SetOutputKeywordList( inImage->GetImageKeywordlist() );
+        rsTransform->SetOutputProjectionRef( inImage->GetProjectionRef() );
+        rsTransform->InstantiateTransform();
+        itk::Point<float, 2> centerp_in , centerp_out;
+        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 , true );
+          SetParameterInt( "starty", centeri_out[1] - radiusyi , true );
+          }
+        }
+      }
+  }
+
+  void
+  ComputeRadiusFromIndex(const ImageType * input , 
+                         const ImageType::RegionType & largestRegion)
+  {
+    FloatVectorImageType::IndexType centeri , helpRxi, helpRyi;
+    centeri[ 0 ] = largestRegion.GetSize()[0] / 2  \
+                   - (largestRegion.GetSize()[0] + 1)%2;
+    centeri[ 1 ] = largestRegion.GetSize()[1] / 2  \
+                   - (largestRegion.GetSize()[1] + 1)%2;
+    helpRxi[ 0 ] = centeri[ 0 ];
+    helpRxi[ 1 ] = 0;
+    helpRyi[ 0 ] = 0;
+    helpRyi[ 1 ] = centeri[ 1 ];
+    if ( GetParameterString("mode.radius.unitr") == "pxl" )
+      {
+      int rad = std::min( centeri[ 0 ], centeri[ 1 ] );
+      SetParameterFloat( "mode.radius.r" , rad , false );
+      }
+    if ( GetParameterString("mode.radius.unitr") == "phy" )
+      {
+      itk::Point<float, 2> centerp , helpRxp, helpRyp;
+      input->TransformIndexToPhysicalPoint(centeri,centerp);
+      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 );
+      }
+    if ( GetParameterString("mode.radius.unitc") == "pxl" )
+      {
+      SetParameterFloat( "mode.radius.cx" , centeri[0] , false );
+      SetParameterFloat( "mode.radius.cy" , centeri[1] , false) ;
+      }
+    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) ;
+      }
+    if ( GetParameterString("mode.radius.unitc") == "lonlat" )
+      {
+      RSTransformType::Pointer rsTransform = RSTransformType::New();
+      rsTransform->SetInputKeywordList( input->GetImageKeywordlist() );
+      rsTransform->SetInputProjectionRef( input->GetProjectionRef() );
+      rsTransform->InstantiateTransform();
+      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 );
       }
-    return false;
   }
 
-  void DoExecute() ITK_OVERRIDE
+  void 
+  DoExecute() ITK_OVERRIDE
   {
-    ExtractROIFilterType::InputImageType* inImage = GetParameterImage("in");
+    ImageType* inImage = GetParameterImage("in");
     inImage->UpdateOutputInformation();
 
+    if ( HasValue( "mode.fit.vect" ) && GetParameterString("mode") == "fit" )
+      {
+      otb::ogr::DataSource::Pointer ogrDS;
+      ogrDS = otb::ogr::DataSource::New(GetParameterString("in") ,
+                                        otb::ogr::DataSource::Modes::Read);
+      double ulx, uly, lrx, lry;
+      bool extentAvailable = true;
+      std::string inputProjectionRef = "";
+      // First try to get the extent in the metadata
+      try
+        {
+        inputProjectionRef = ogrDS->GetGlobalExtent(ulx,uly,lrx,lry);
+        }
+      catch(const itk::ExceptionObject&)
+        {
+        extentAvailable = false;
+        }
+      // If no extent available force the computation of the extent
+      if (!extentAvailable)
+        {
+        try
+          {
+          inputProjectionRef = ogrDS->GetGlobalExtent(ulx,uly,lrx,lry,true);
+          extentAvailable = true;
+          }
+        catch(itk::ExceptionObject & err)
+          {
+          extentAvailable = false;
+
+          otbAppLogFATAL(<<"Failed to retrieve the spatial extent of the dataset "
+                           "in force mode. The spatial extent is mandatory when "
+                           "orx, ory, spx and spy parameters are not set, consider "
+                           "setting them. Error from library: "<<err.GetDescription());
+          }
+        }
+
+      if (extentAvailable)
+        {
+        RSTransformType::Pointer rsTransform = RSTransformType::New();
+        rsTransform->SetInputProjectionRef(inputProjectionRef);
+        rsTransform->SetOutputKeywordList( inImage->GetImageKeywordlist() );
+        rsTransform->SetOutputProjectionRef( inImage->GetProjectionRef() );
+        rsTransform->InstantiateTransform();
+
+        itk::Point<float, 2> ulp_in,  lrp_in , ulp_out , lrp_out;
+        ulp_in[ 0 ] = ulx ;
+        ulp_in[ 1 ] = uly ;
+        lrp_in[ 0 ] = lrx ;
+        lrp_in[ 1 ] = lry ;
+        ulp_out = rsTransform->TransformPoint(ulp_in);
+        lrp_out = rsTransform->TransformPoint(lrp_in);
+
+        FloatVectorImageType::IndexType uli_out , lri_out;
+        bool startin , sizein ;
+        startin = inImage->TransformPhysicalPointToIndex(ulp_out,uli_out);
+        sizein = inImage->TransformPhysicalPointToIndex(lrp_out,lri_out);
+
+        if ( startin )
+            {
+            SetParameterInt( "startx", uli_out[0] , false );
+            SetParameterInt( "starty", uli_out[1] , false );
+            }
+                
+        if( startin && sizein )
+            {
+            SetParameterInt( "sizey", lri_out[1] - uli_out[1] + 1 , false );
+            SetParameterInt( "sizex", lri_out[0] - uli_out[0] + 1 , false );
+            }
+        }
+        
+      }
 
-    if(GetParameterString("mode")=="fit")
+    if( HasValue( "mode.fit.im" ) && GetParameterString( "mode" ) == "fit" )
       {
       // Setup the DEM Handler
-      otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"mode.fit.elev");
+      otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev");
 
-      FloatVectorImageType::Pointer referencePtr = this->GetParameterImage("mode.fit.ref");
+      FloatVectorImageType::Pointer referencePtr = this->GetParameterImage("mode.fit.im");
       referencePtr->UpdateOutputInformation();
 
       RSTransformType::Pointer rsTransform = RSTransformType::New();
@@ -278,11 +805,15 @@ private:
 
       FloatVectorImageType::IndexType uli, lri;
 
-      uli[0] = std::min(std::min(uli_out[0],uri_out[0]),std::min(lli_out[0],lri_out[0]));
-      uli[1] = std::min(std::min(uli_out[1],uri_out[1]),std::min(lli_out[1],lri_out[1]));
+      uli[0] = std::min( std::min( uli_out[0] , uri_out[0] ) , 
+                         std::min( lli_out[0] , lri_out[0] ) );
+      uli[1] = std::min( std::min( uli_out[1] , uri_out[1] ) ,
+                         std::min( lli_out[1] , lri_out[1] ) );
 
-      lri[0] = std::max(std::max(uli_out[0],uri_out[0]),std::max(lli_out[0],lri_out[0]));
-      lri[1] = std::max(std::max(uli_out[1],uri_out[1]),std::max(lli_out[1],lri_out[1]));
+      lri[0] = std::max( std::max( uli_out[0] , uri_out[0] ) ,
+                         std::max( lli_out[0] , lri_out[0] ) );
+      lri[1] = std::max( std::max( uli_out[1] , uri_out[1] ) ,
+                         std::max( lli_out[1] , lri_out[1] ) );
 
       SetParameterInt("startx",uli[0]);
       SetParameterInt("starty",uli[1]);
diff --git a/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx b/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx
index 3296b17..1bca924 100644
--- a/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx
+++ b/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx
@@ -22,6 +22,7 @@
 #include "otbWrapperApplicationFactory.h"
 
 #include "otbMultiChannelExtractROI.h"
+#include "otbGenericRSTransform.h"
 
 namespace otb
 {
@@ -32,14 +33,15 @@ class PixelValue : public Application
 {
 public:
   /** Standard class typedefs. */
-  typedef PixelValue                     Self;
+  typedef PixelValue                    Self;
   typedef Application                   Superclass;
   typedef itk::SmartPointer<Self>       Pointer;
   typedef itk::SmartPointer<const Self> ConstPointer;
 
   typedef otb::MultiChannelExtractROI<FloatVectorImageType::InternalPixelType,
-                                      FloatVectorImageType::InternalPixelType> ExtractROIFilterType;
+              FloatVectorImageType::InternalPixelType> ExtractROIFilterType;
 
+  typedef otb::GenericRSTransform<>  RSTransformType;                                    
   /** Standard macro */
   itkNewMacro(Self);
 
@@ -53,26 +55,53 @@ private:
 
     // Documentation
     SetDocName("Pixel Value");
-    SetDocLongDescription("Get the value of a pixel.\nPay attention, index starts at 0.");
+    SetDocLongDescription("This application gives the value of a selected "
+      "pixel. There are three ways to designate a pixel, with its index, "
+      "its physical coordinate (in the physical space attached to the image), "
+      "and with geographical coordinate system. Coordinates will be "
+      "interpreted differently depending on which mode is chosen.");
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
     SetDocSeeAlso(" ");
 
-	AddDocTag("Miscellaneous");
+    AddDocTag("Miscellaneous");
     AddDocTag("Utilities");
     AddDocTag("Coordinates");
     AddDocTag("Raster");
 
-    AddParameter(ParameterType_InputImage,  "in",   "Input Image");
-    SetParameterDescription("in", "Input image");
-
-    AddParameter(ParameterType_Int,"coordx","Col index");
-    SetParameterDescription("coordx","Column index of the wanted pixel (starts at 0).");
-    SetMinimumParameterIntValue("coordx", 0);
-
-    AddParameter(ParameterType_Int,"coordy","Line index");
-    SetParameterDescription("coordy","Line index of the wanted pixel (starts at 0).");
-    SetMinimumParameterIntValue("coordy", 0);
+    AddParameter(ParameterType_InputImage , "in", "Input Image");
+    SetParameterDescription("in" , "Input image");
+
+    AddParameter(ParameterType_Float , "coordx" , "X coordinate" );
+    SetParameterDescription("coordx" ,
+          "This will be the X coordinate interpreted depending on the "
+          "chosen mode");
+    AddParameter(ParameterType_Float , "coordy" , "Y coordinate" );
+    SetParameterDescription("coordy" ,
+          "This will be the Y coordinate interpreted depending on the "
+          "chosen mode");
+
+    AddParameter(ParameterType_Choice , "mode" , 
+          "Coordinate system used to designate the pixel");
+    SetParameterDescription( "mode" , 
+          "Different modes can be selected, default mode is Index.");
+    AddChoice( "mode.index" , "Index");
+    SetParameterDescription( "mode.index" , 
+          "This mode uses the given coordinates as index to locate the pixel.");
+    AddChoice( "mode.physical" , "Image physical space");
+    SetParameterDescription( "mode.physical" , 
+          "This mode interprets the given coordinates in the image "
+          "physical space.");
+    AddChoice( "mode.epsg" , "EPSG coordinates");
+    SetParameterDescription( "mode.epsg" , 
+          "This mode interprets the given coordinates in the specified "
+          "geographical coordinate system by the EPSG code.");
+
+    AddParameter(ParameterType_Int , "mode.epsg.code" , "EPSG code");
+    SetParameterDescription("mode.epsg.code" ,
+          "This code is used to define a geographical coordinate system. "
+          "If no system is specified, WGS84 (EPSG : 4326) is used by default.");
+    MandatoryOff("mode.epsg.code");
 
     AddParameter(ParameterType_ListView,"cl","Channels");
     SetParameterDescription("cl","Displayed channels");
@@ -95,7 +124,7 @@ private:
   {
     if ( HasValue("in") )
       {
-      ExtractROIFilterType::InputImageType* inImage = GetParameterImage("in");
+      ExtractROIFilterType::InputImageType * inImage = GetParameterImage("in");
 
       // Update the values of the channels to be selected
       unsigned int nbComponents = inImage->GetNumberOfComponentsPerPixel();
@@ -107,53 +136,163 @@ private:
         item<<"Channel"<<idx+1;
         AddChoice(key.str(), item.str());
         }
-
-      ExtractROIFilterType::InputImageType::RegionType  largestRegion = inImage->GetLargestPossibleRegion();
-      SetMaximumParameterIntValue("coordx", largestRegion.GetSize(0)-1);
-      SetMaximumParameterIntValue("coordy", largestRegion.GetSize(1)-1);
       }
   }
 
-  void DoExecute() ITK_OVERRIDE
+  std::string CreateBoundaryBox( const std::string & mode )
   {
-    std::ostringstream ossOutput;
     FloatVectorImageType::Pointer inImage = GetParameterImage("in");
+    FloatVectorImageType::IndexType min , max;
+    min.Fill(0);
+    max[0] = inImage->GetLargestPossibleRegion().GetSize()[0] - 1;
+    max[1] = inImage->GetLargestPossibleRegion().GetSize()[1] - 1;
+    std::string boundaries[4];
+    if (mode == "index")
+      {
+      boundaries[0] = std::to_string(max[0]);
+      boundaries[1] = std::to_string(max[1]);
+      boundaries[2] = std::to_string(min[0]);
+      boundaries[3] = std::to_string(min[1]);
+      }
+    else if (mode == "physical")
+      {
+      itk::Point< float, 2 > minP(0) , maxP(0);
+      inImage->TransformIndexToPhysicalPoint(min,minP);
+      inImage->TransformIndexToPhysicalPoint(max,maxP);
+      boundaries[0] = std::to_string(std::max(minP[0],maxP[0]));
+      boundaries[1] = std::to_string(std::max(minP[1],maxP[1]));
+      boundaries[2] = std::to_string(std::min(minP[0],maxP[0]));
+      boundaries[3] = std::to_string(std::min(minP[1],maxP[1]));
+      }
+    else if (mode == "epsg")
+      {
+      RSTransformType::Pointer inverse = RSTransformType::New();
+      if ( HasUserValue("mode.epsg.code") )
+        {
+        std::string wktFromEpsg = 
+          otb::GeoInformationConversion::ToWKT(GetParameterInt( "mode.epsg.code" ));
+        inverse->SetOutputProjectionRef(wktFromEpsg);
+        }
+      inverse->SetInputKeywordList( inImage->GetImageKeywordlist() );
+      inverse->SetInputProjectionRef( inImage->GetProjectionRef() );
+      inverse->InstantiateTransform();
+      itk::Point< float, 2 > minPOut(0) , maxPOut(0) , minP(0) , maxP(0);
+      inImage->TransformIndexToPhysicalPoint(min,minP);
+      inImage->TransformIndexToPhysicalPoint(max,maxP);
+      minPOut = inverse->TransformPoint( minP );
+      maxPOut = inverse->TransformPoint( maxP );
+      boundaries[0] = std::to_string(std::max(minPOut[0],maxPOut[0]));
+      boundaries[1] = std::to_string(std::max(minPOut[1],maxPOut[1]));
+      boundaries[2] = std::to_string(std::min(minPOut[0],maxPOut[0]));
+      boundaries[3] = std::to_string(std::min(minPOut[1],maxPOut[1]));
+      }
 
-    ExtractROIFilterType::Pointer extractor = ExtractROIFilterType::New();
-    extractor->SetInput(inImage);
+    for (int i = 0 ; i<4 ; i++)
+      {
+      std::size_t coma = boundaries[i].find(".");
+      if ( coma != std::string::npos )
+        {
+        std::size_t zero = boundaries[i].find_last_not_of("0");
+        if ( zero != std::string::npos ) 
+          boundaries[i].erase(zero + 1);
+        else
+          boundaries[i] = "0";
+        }
+      }
+  
+    std::string box = "";
+    box += "["+boundaries[2]+" , "+boundaries[0]+"] x ";
+    box += "["+boundaries[3]+" , "+boundaries[1]+"]";
+    return box;
+  }
 
-    // Create the region
-    FloatVectorImageType::IndexType id;
-    id[0] = GetParameterInt("coordx");
-    id[1] = GetParameterInt("coordy");
+  void DoExecute() ITK_OVERRIDE
+  {
+    std::string mode = GetParameterString( "mode" );
+    FloatVectorImageType::Pointer inImage = GetParameterImage("in");
+    FloatVectorImageType::IndexType id ;
+    id.Fill(0);
+    bool isPixelIn( false );
+    if ( mode == "index" )
+      {
+      id[0] = static_cast< int >( GetParameterFloat( "coordx" ) );
+      id[1] = static_cast< int >( GetParameterFloat( "coordy" ) );
+      if (static_cast< unsigned int >( id[0] ) >= 
+                    inImage->GetLargestPossibleRegion().GetSize()[0]
+       || static_cast< unsigned int >( id[1] ) >=
+                    inImage->GetLargestPossibleRegion().GetSize()[1]
+       || id[0] < 0 || id[1] < 0 )
+        {
+        id.Fill(0);
+        isPixelIn = false;
+        }
+      else
+        {
+        isPixelIn = true;
+        }
+      }
 
-    FloatVectorImageType::SizeType size;
-    size.Fill(0);
+    else if ( mode == "physical" )
+      {
+      itk::Point<float, 2> pixel(0);
+      pixel[ 0 ] = GetParameterFloat( "coordx" );
+      pixel[ 1 ] = GetParameterFloat( "coordy" );
+      isPixelIn = inImage->TransformPhysicalPointToIndex(pixel,id);
+      }
+    
+    else if ( mode == "epsg" )
+      {
+      RSTransformType::Pointer rsTransform = RSTransformType::New();
+      if ( HasUserValue("mode.epsg.code") )
+        {
+        std::string wktFromEpsg = 
+          otb::GeoInformationConversion::ToWKT( GetParameterInt( "mode.epsg.code" ) );
+        rsTransform->SetInputProjectionRef(wktFromEpsg);
+        }      
+      rsTransform->SetOutputKeywordList( inImage->GetImageKeywordlist() );
+      rsTransform->SetOutputProjectionRef( inImage->GetProjectionRef() );
+      rsTransform->InstantiateTransform();
+      itk::Point<float, 2> pixelIn(0) , pixelOut(0);
+      pixelIn[ 0 ] = GetParameterFloat( "coordx" );
+      pixelIn[ 1 ] = GetParameterFloat( "coordy" );
+      rsTransform->InstantiateTransform();
+      pixelOut = rsTransform->TransformPoint(pixelIn);
+      isPixelIn = inImage->TransformPhysicalPointToIndex(pixelOut,id);
+      }
 
-    FloatVectorImageType::RegionType region;
-    region.SetSize(size);
-    region.SetIndex(id);
+    if ( !isPixelIn )
+      {
+      std::string why = "Accessible pixels are in ";
+      why += CreateBoundaryBox( GetParameterString( "mode" ) );
+      why += " for the selected mode.";
+      otbAppLogFATAL(<<"Specified position out of bound.\n" + why);
+      }
 
-    extractor->SetExtractionRegion(region);
+    ExtractROIFilterType::Pointer extractor = ExtractROIFilterType::New();
+    extractor->SetInput(inImage);
 
     // Extract the channels if needed
     if ( GetParameterByKey("cl")->GetActive() )
       {
-      for (unsigned int idx = 0; idx < GetSelectedItems("cl").size(); ++idx)
+      for (unsigned int idx = 0; idx < GetSelectedItems("cl").size(); ++idx) 
         {
         extractor->SetChannel(GetSelectedItems("cl")[idx] + 1 );
         }
       }
+    FloatVectorImageType::SizeType size;
+    size.Fill(1);
+    FloatVectorImageType::RegionType region;
+    region.SetSize(size);
+    region.SetIndex(id);
 
-    extractor->Update();
+    extractor->SetExtractionRegion(region);
+    extractor->Update();   
 
     // Display the pixel value
     id.Fill(0);
     std::ostringstream oss;
-    oss << extractor->GetOutput()->GetPixel(id)<<std::endl;
-
+    oss << extractor->GetOutput()->GetPixel(id);
     SetParameterString("value", oss.str(), false);
-
     //Display image information in the dedicated logger
     otbAppLogINFO( << oss.str() );
   }
diff --git a/Modules/Applications/AppImageUtils/otb-module.cmake b/Modules/Applications/AppImageUtils/otb-module.cmake
index 72e63db..6b378f1 100644
--- a/Modules/Applications/AppImageUtils/otb-module.cmake
+++ b/Modules/Applications/AppImageUtils/otb-module.cmake
@@ -22,6 +22,7 @@ set(DOCUMENTATION "Image utils and handling application.")
 
 otb_module(OTBAppImageUtils
   DEPENDS
+    OTBConversion
     OTBApplicationEngine
     OTBBoostAdapters
     OTBCarto
diff --git a/Modules/Applications/AppImageUtils/test/CMakeLists.txt b/Modules/Applications/AppImageUtils/test/CMakeLists.txt
index 32d54bd..7c33a6b 100644
--- a/Modules/Applications/AppImageUtils/test/CMakeLists.txt
+++ b/Modules/Applications/AppImageUtils/test/CMakeLists.txt
@@ -24,7 +24,7 @@ otb_test_application(NAME apTuUtDownloadSRTMTiles
                      APP  DownloadSRTMTiles
                      OPTIONS -il LARGEINPUT{QUICKBIRD/TOULOUSE/000000128955_01_P001_MUL/02APR01105228-M1BS-000000128955_01_P001.TIF}
                              -mode list
-                             -mode.list.indir ${INPUTDATA}/DEM/srtm_directory
+                             -tiledir ${INPUTDATA}/DEM/srtm_directory
                      )
 
 
@@ -34,7 +34,7 @@ otb_test_application(NAME apTuUtDownloadSRTMTiles
 otb_test_application(NAME apTvUtConvertBasic
                      APP Convert
                      OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_XS.tif
-                             -out ${TEMP}/apTvUtConvertBasicOutput.tif
+                             -out ${TEMP}/apTvUtConvertBasicOutput.tif float
                      VALID   --compare-image ${NOTOL}
                              ${INPUTDATA}/apTvUtConvertBasicOutput.tif
                 	     ${TEMP}/apTvUtConvertBasicOutput.tif
@@ -49,7 +49,7 @@ otb_test_application(NAME apTuUtConvertExtendedFilename_writer
 otb_test_application(NAME apTvUtConvertWithScaling
                      APP Convert
                      OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_XS.tif
-                             -out ${TEMP}/apTvUtConvertWithScalingOutput.tif uint8
+                             -out ${TEMP}/apTvUtConvertWithScalingOutput.tif
                              -type linear
                      VALID   --compare-image ${NOTOL}
                              ${INPUTDATA}/apTvUtConvertWithScalingOutput.tif
@@ -64,6 +64,28 @@ otb_test_application(NAME apTvUtConvertExtendedFilename_readerGEOM
                              ${INPUTDATA}/ToulouseExtract_ModifiedGeom.geom
                              ${TEMP}/apTvUtGeomExtendedFilename.geom)
 
+otb_test_application(NAME apTvUtConvertSelectChannels
+                     APP Convert
+                     OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_XS.tif
+                             -out ${TEMP}/apTvUtConvertSelectChannelsRgbOutput.tif
+                             -channels rgb
+                             -channels.rgb.red 2
+                             -channels.rgb.green 3
+                             -channels.rgb.blue 1
+                             -type linear
+                     VALID   --compare-image ${NOTOL}
+                             ${INPUTDATA}/apTvUtConvertSelectChannelsRgbOutput.tif
+                             ${TEMP}/apTvUtConvertSelectChannelsRgbOutput.tif)
+
+otb_test_application(NAME apTvUtConvertMonoChannel
+                     APP Convert
+                     OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
+                             -out ${TEMP}/apTvUtConvertMonoChannelOutput.tif
+                             -channels grayscale
+                             -type linear
+                     VALID   --compare-image ${NOTOL}
+                             ${INPUTDATA}/apTvUtConvertMonoChannelOutput.tif
+                             ${TEMP}/apTvUtConvertMonoChannelOutput.tif)
 
 #----------- PixelInfo TESTS ----------------
 
@@ -77,6 +99,26 @@ otb_test_application(NAME apTvUtExtractROISizeTooBig
                              ${INPUTDATA}/couleurs_extrait.png
                              ${TEMP}/apTvUtExtractROISizeTooBig.tif)
 
+otb_test_application(NAME apTvUtExtractROISizeTooBigExtent
+                     APP  ExtractROI
+                     OPTIONS -in ${INPUTDATA}/couleurs_extrait.png
+                             -out ${TEMP}/apTvUtExtractROISizeTooBigExtent.tif
+                             -mode extent
+                             -mode.extent.lrx 1000000
+                     VALID   --compare-image ${NOTOL}
+                             ${INPUTDATA}/couleurs_extrait.png
+                             ${TEMP}/apTvUtExtractROISizeTooBigExtent.tif)
+
+otb_test_application(NAME apTvUtExtractROISizeTooBigRadius
+                     APP  ExtractROI
+                     OPTIONS -in ${INPUTDATA}/couleurs_extrait.png
+                             -out ${TEMP}/apTvUtExtractROISizeTooBigRadius.tif
+                             -mode radius
+                             -mode.radius.r 1000000
+                     VALID   --compare-image ${NOTOL}
+                             ${INPUTDATA}/couleurs_extrait.png
+                             ${TEMP}/apTvUtExtractROISizeTooBigRadius.tif)
+
 otb_test_application(NAME apTvUtExtractROISizeNULL
                      APP  ExtractROI
                      OPTIONS -in ${INPUTDATA}/couleurs_extrait.png
@@ -216,16 +258,43 @@ otb_test_application(NAME apTvUtConcatenateImages_1Image
 #----------- MultiResolutionPyramid TESTS ----------------
 
 #----------- PixelValue TESTS ----------------
-OTB_TEST_APPLICATION(NAME apTvUtPixelValue
+OTB_TEST_APPLICATION(NAME apTvUtPixelValueIndex
                      APP PixelValue
                      OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_XS.tif
                              -coordx 30
                              -coordy 30
+                             -mode index
+                             -cl Channel1 Channel3 Channel4
+                       TESTENVOPTIONS ${TEMP}/apTvUtPixelValueIndex.txt
+                       VALID --compare-ascii ${EPSILON_7}
+                             ${BASELINE_FILES}/apTvUtPixelValue.txt
+                	     ${TEMP}/apTvUtPixelValueIndex.txt
+                             )
+OTB_TEST_APPLICATION(NAME apTvUtPixelValuePhys
+                     APP PixelValue
+                     OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_XS.tif
+                             -coordx 374168
+                             -coordy 4829165.5
+                             -mode physical
+                             -cl Channel1 Channel3 Channel4
+                       TESTENVOPTIONS ${TEMP}/apTvUtPixelValuePhys.txt
+                       VALID --compare-ascii ${EPSILON_7}
+                             ${BASELINE_FILES}/apTvUtPixelValue.txt
+                         ${TEMP}/apTvUtPixelValuePhys.txt
+                             )
+
+OTB_TEST_APPLICATION(NAME apTvUtPixelValueEpsg
+                     APP PixelValue
+                     OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_XS.tif
+                             -coordx 1.4408400058746337890625
+                             -coordy 43.604839324951171875
+                             -mode epsg
+                             -mode.epsg.code 4326
                              -cl Channel1 Channel3 Channel4
-                       TESTENVOPTIONS ${TEMP}/apTvUtPixelValue.txt
+                       TESTENVOPTIONS ${TEMP}/apTvUtPixelValueEpsg.txt
                        VALID --compare-ascii ${EPSILON_7}
                              ${BASELINE_FILES}/apTvUtPixelValue.txt
-                	     ${TEMP}/apTvUtPixelValue.txt
+                         ${TEMP}/apTvUtPixelValueEpsg.txt
                              )
 
 #----------- ColorMapping TESTS ----------------
diff --git a/Modules/Applications/AppMathParser/app/otbBandMath.cxx b/Modules/Applications/AppMathParser/app/otbBandMath.cxx
index 7a03d84..f8ecc1b 100644
--- a/Modules/Applications/AppMathParser/app/otbBandMath.cxx
+++ b/Modules/Applications/AppMathParser/app/otbBandMath.cxx
@@ -55,38 +55,72 @@ public:
 private:
   void DoInit() ITK_OVERRIDE
   {
-    SetName("BandMath");
-    SetDescription("Perform a mathematical operation on monoband images");
-
-    SetDocName("Band Math");
-    SetDocLongDescription("This application performs a mathematical operation on monoband images."
-      "Mathematical formula interpretation is done via MuParser libraries.\n"
-      "For MuParser version superior to 2.0 uses '&&' and '||' logical operators, and ternary operator 'boolean_expression ? if_true : if_false'\n"
-      "For older version of MuParser (prior to v2) use 'and' and 'or' logical operators, and ternary operator 'if(; ; )'.\n"
-      "The list of features and operators is available on MuParser website: http://muparser.sourceforge.net/\n"
+    SetName( "BandMath" );
+
+    SetDescription(
+      "Outputs a monoband image which is the result of a mathematical operation "
+      "on several multi-band images."
+    );
+
+    SetDocName( "Band Math" );
+
+    SetDocLongDescription(
+      "This application performs a mathematical operation on several multi-band "
+      "images and outputs the result into a monoband image. Evaluation of the "
+      "mathematical formula is done by the muParser libraries.\n\n"
+
+      "muParser version superior to 2.0, provides the '&&' and '||' logical "
+      "operators, and a ternary operator 'boolean_expression ? if_true : "
+      "if_false'.\n\n"
+
+      "Older versions of muParser (prior to v-2.0) provides only the 'and' and "
+      "'or' logical operators, and a ternary operator 'if(; ; )'.\n\n"
+
+      "The list of features and operators is available on the muParser website [1]."
       );
 
-    SetDocLimitations("None");
-    SetDocAuthors("OTB-Team");
-    SetDocSeeAlso(" ");
-    AddDocTag("Miscellaneous");
+    SetDocLimitations( "None" );
+    SetDocAuthors( "OTB-Team" );
+    SetDocSeeAlso("[1] http://muparser.sourceforge.net/");
+    AddDocTag( "Miscellaneous" );
 
-    AddParameter(ParameterType_InputImageList,  "il",   "Input image list");
-    SetParameterDescription("il", "Image list to perform computation on.");
+    AddParameter( ParameterType_InputImageList, "il", "Input image-list" );
+    SetParameterDescription(
+      "il",
+      "Image-list of operands to the mathematical expression."
+    );
 
-    AddParameter(ParameterType_OutputImage, "out", "Output Image");
-    SetParameterDescription("out","Output image.");
+    AddParameter( ParameterType_OutputImage, "out", "Output Image" );
+    SetParameterDescription(
+      "out",
+      "Output image which is the result of the mathematical expressions on input"
+      " image-list operands.");
 
     AddRAMParameter();
 
-    AddParameter(ParameterType_String, "exp", "Expression");
-    SetParameterDescription("exp",
-                            "The mathematical expression to apply. \nUse im1b1 for the first band, im1b2 for the second one...");
+    AddParameter( ParameterType_String, "exp", "Expression");
+    SetParameterDescription(
+      "exp",
+      "The muParser mathematical expression to apply on input images.\n"
+      "Use im1b1 as first band of first image, im1b2 for the second band of "
+      "first image.\n"
+      "Use im2b1 as first band of second image, im2b2 for the second band of "
+      "second image.\n"
+      "etc."
+    );
 
     // Doc example parameter settings
-    SetDocExampleParameterValue("il", "verySmallFSATSW_r.tif verySmallFSATSW_nir.tif verySmallFSATSW.tif");
-    SetDocExampleParameterValue("out", "apTvUtBandMathOutput.tif");
-    SetDocExampleParameterValue("exp", "\"cos(im1b1) > cos(im2b1) ? im3b1 : im3b2\"");
+    SetDocExampleParameterValue(
+      "il",
+      "verySmallFSATSW_r.tif verySmallFSATSW_nir.tif verySmallFSATSW.tif"
+    );
+    SetDocExampleParameterValue(
+      "out",
+      "apTvUtBandMathOutput.tif"
+    );
+    SetDocExampleParameterValue(
+      "exp", "'cos( im1b1 ) > cos( im2b1 ) ? im3b1 : im3b2'"
+    );
 
     SetOfficialDocLink();
   }
@@ -222,5 +256,3 @@ private:
 } // namespace otb
 
 OTB_APPLICATION_EXPORT(otb::Wrapper::BandMath)
-
-
diff --git a/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx b/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx
index ef5ed35..06da000 100644
--- a/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx
+++ b/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx
@@ -57,121 +57,221 @@ public:
 private:
   void DoInit() ITK_OVERRIDE
   {
-    SetName("BandMathX");
-    SetDescription("This application performs mathematical operations on multiband images.\n"
-      "Mathematical formula interpretation is done via muParserX library : http://articles.beltoforion.de/article.php?a=muparserx");
-
-    SetDocName("Band Math X");
-    SetDocLongDescription("The goal of this documentation is to give the user some hints about the syntax used in this application.\n"
-      "The syntax is mainly constrained by the muparserx library, which can be considered as the core of the application.\n"
-      "\n\n"
-      "- Fundamentals:\n\n"
-      "The default prefix name for variables related to the ith input is 'im(i+1)'(note the indexing from 1 to N, for N inputs). \n"
-      "The following list summaries the available variables for input #0 (and so on for every input): \n"
-      "\n"
-      "im1                                -->   a pixel from first input, made of n components (n bands)\n"
-      "im1bj                             -->   jth component of a pixel from first input (first band is indexed by 1)\n"
-      "im1bjNkxp                     -->   a neighbourhood ('N') of pixels of the jth component from first input, of size kxp\n"
-      "im1PhyX and im1PhyY  -->   spacing of first input in X and Y directions (horizontal and vertical)\n"
-      "im1bjMean im1bjMin im1bjMax im1bjSum im1bjVar  -->   mean, min, max, sum, variance of jth band from first input (global statistics)\n"
-      "\nMoreover, we also have the following generic variables:\n"
-      "idxX and idxY        -->   indices of the current pixel\n"
-      "\n"
-      "Always keep in mind that this application only addresses mathematically well-defined formulas.\n"
-      "For instance, it is not possible to add vectors of different dimensions (this implies the addition of a row vector with a column vector),\n"
-      "or add a scalar to a vector or a matrix, or divide two vectors, and so on...\n"
-      "Thus, it is important to remember that a pixel of n components is always represented as a row vector.\n"
-      "\n"
-      "Example :\n\n"
-      "                   im1 + im2       (1)\n"
-      "\nrepresents the addition of pixels from first and second inputs. This expression is consistent only if\n"
-      "both inputs have the same number of bands.\n"
-      "Note that it is also possible to use the following expressions to obtain the same result:\n"
-      "\n"
-      "                   im1b1 + im2b1 \n"
-      "                   im1b2 + im2b2       (2)\n"
-      "                   ..."
-      "\n\nNevertheless, the first expression is by far much pleaseant. We call this new functionality the 'batch mode'\n"
-      "(performing the same operation in a band-to-band fashion).\n"
-
-      "\n\n"
-      "- Operations involving neighborhoods of pixels:\n\n"
-      "Another new fonctionnality is the possibility to perform operations that involve neighborhoods of pixels.\n"
-      "Variable related to such neighborhoods are always defined following the pattern imIbJNKxP, where: \n"
-      "- I is an number identifying the image input (remember, input #0 = im1, and so on)\n"
-      "- J is an number identifying the band (remember, first band is indexed by 1)\n"
-      "- KxP are two numbers that represent the size of the neighborhood (first one is related to the horizontal direction)\n"
-      "All neighborhood are centered, thus K and P must be odd numbers.\n"
-      "Many operators come with this new functionality: dotpr, mean var median min max...\n"
-      "For instance, if im1 represents the pixel of 3 bands image:\n\n"
-      "               im1 - mean(im1b1N5x5,im1b2N5x5,im1b3N5x5)       (3)\n"
-      "\ncould represent a high pass filter (Note that by implying three neighborhoods, the operator mean returns a row vector of three components.\n"
-      "It is a typical behaviour for many operators of this application).\n"
-
-      "\n\n"
-      "- Operators:\n\n"
+    SetName( "BandMathX" );
+
+    SetDescription(
+      "This application performs mathematical operations on several multiband images.\n"
+    );
+
+    SetDocName( "Band Math X" );
+
+    SetDocLongDescription(
+      "This application performs a mathematical operation on several multi-band "
+      "images and outputs the result into an image (multi- or mono-band, as "
+      "opposed to the BandMath OTB-application). The mathematical formula is "
+      "done by the muParserX libraries.\n\n"
+
+      "The list of features and the syntax of muParserX is available at [1].\n\n"
+
+      "As opposed to muParser (and thus the BandMath OTB-application [2]), "
+      "muParserX supports vector expressions which allows to output multi-band "
+      "images.\n\n"
+
+      "Hereafter is a brief reference of the muParserX syntax\n\n"
+
+      "Fundamentals\n"
+      "------------\n\n"
+
+      "The i-th input image is identified by the 'im<i+1>' (e.g. 'im1') prefix "
+      "(please, note the indexing from 1 to N, for N inputs).\n\n"
+
+      "The following list summarizes the available variables of input #0:\n\n"
+
+      "im1\n"
+      "  a pixel from 1st input, made of n components (n bands).\n\n"
+
+      "im1b2\n"
+      "  the 2nd component of a pixel from 1st input (band index is 1-based).\n\n"
+
+      "im1b2N3x4\n"
+      "  a 3x4 pixels 'N'eighbourhood of a pixel the 2nd component of a pixel "
+      "from the 1st input.\n\n"
+
+      "im1PhyX\n"
+      "  horizontal (X-axis) spacing of the 1st input.\n\n"
+
+      "im1PhyY\n"
+      "  vertical spacing of the 1st input input.\n\n"
+
+      "im1b2Mean\n"
+      "  mean of the 2nd component of the 1st input (global statistics)\n\n"
+
+      "im1b2Min\n"
+      "  minimum of the 2nd component of the 1st input (global statistics)\n\n"
+
+      "im1b2Max\n"
+      "  minimum of the 2nd component of the 1st input (global statistics)\n\n"
+
+      "im1b2Sum\n"
+      "  minimum of the 2nd component of the 1st input (global statistics)\n\n"
+
+      "im1b2Var\n"
+      "  minimum of the 2nd component of the 1st input (global statistics)\n\n"
+
+      "idxX, idxY\n"
+      "  indices of the current pixel (generic variables)\n\n"
+
+      "Always keep in mind that this application only addresses mathematically "
+      "well-defined formulas. For instance, it is not possible to add vectors of"
+      " different dimensions (e.g. addition of a row vector with a column vector"
+      "), or a scalar to a vector or matrix, or divide two vectors, etc.\n\n"
+
+      "Thus, it is important to remember that a pixel of n components is always "
+      "represented as a row vector.\n\n"
+
+      "Example:\n"
+      "  im1 + im2 (1)\n"
+      "  represents the addition of pixels from the 1st and 2nd inputs. This "
+      "expression is consistent only if both inputs have the same number of "
+      "bands.\n\n"
+
+      "Please, note that it is also possible to use the following expressions"
+      " to obtain the same result:\n"
+      "  im1b1 + im2b1\n"
+      "  im1b2 + im2b2 (2)\n"
+      "  ...\n\n"
+
+      "Nevertheless, the first expression is by far much pleaseant. We call "
+      "this new functionality the 'batch mode' (performing the same operation "
+      "in a band-to-band fashion).\n\n"
+
+      "Operations involving neighborhoods of pixels\n"
+      "--------------------------------------------\n\n"
+
+      "Another new feature is the possibility to perform operations that "
+      "involve neighborhoods of pixels. Variables related to such neighborhoods "
+      "are always defined following the imIbJNKxP pattern, where:\n"
+      "- I is an number identifying the image input (remember, input #0 = im1, "
+      "and so on)\n"
+      "- J is an number identifying the band (remember, first band is indexed by"
+      "1)\n"
+      "- KxP are two numbers that represent the size of the neighborhood (first "
+      "one is related to the horizontal direction)\n\n"
+
+      "NB: All neighborhood are centered, thus K and P must be odd numbers.\n\n"
+
+      "Many operators come with this new functionality:\n"
+      "- dotpr\n"
+      "- mean\n"
+      "- var\n"
+      "- median\n"
+      "- min\n"
+      "- max\n"
+      "- etc.\n\n"
+
+      "For instance, if im1 represents the pixel of 3 bands image:\n"
+      "  im1 - mean( im1b1N5x5, im1b2N5x5, im1b3N5x5 ) (3)\n\n"
+      "could represent a high pass filter (note that by implying three "
+      "neighborhoods, the operator mean returns a row vector of three components"
+      ". It is a typical behaviour for many operators of this application).\n\n"
+
       "In addition to the previous operators, other operators are available:\n"
-      "- existing operators/functions from muParserX, that were not originally defined for vectors and\n"
-      "matrices (for instance cos, sin, ...). These new operators/ functions keep the original names to which we added the prefix 'v' for vector (vcos, vsin, ...).\n"
-      "- mult, div and pow operators, that perform element-wise multiplication, division or exponentiation of vector/matrices (for instance im1 div im2)\n"
-      "- mlt, dv and pw operators, that perform multiplication, division or exponentiation of vector/matrices by a scalar (for instance im1 dv 2.0)\n"
-      "- bands, which is a very useful operator. It allows selecting specific bands from an image, and/or to rearrange them in a new vector;\n"
-      "for instance bands(im1,{1,2,1,1}) produces a vector of 4 components made of band 1, band 2, band 1 and band 1 values from the first input.\n"
-      "Note that curly brackets must be used in order to select the desired band indices.\n"
-      "... and so on.\n"
-
-      "\n\n"
-      "- Application itself:\n\n"
-      "The application takes the following parameters :\n"
-      "- Setting the list of inputs can be done with the 'il' parameter.\n"
-      "- Setting expressions can be done with the 'exp' parameter (see also limitations section below).\n"
-      "- Setting constants can be done with the 'incontext' parameter. User must provide a txt file with a specific syntax: #type name value\n"
-      "An example of such a file is given below:\n\n"
-      "#F expo 1.1\n"
-      "#M kernel1 { 0.1 , 0.2 , 0.3; 0.4 , 0.5 , 0.6; 0.7 , 0.8 , 0.9; 1 , 1.1 , 1.2; 1.3 , 1.4 , 1.5 }\n"
-      "\nAs we can see,  #I/#F allows the definition of an integer/float constant, whereas #M allows the definition of a vector/matrix.\n"
-      "In the latter case, elements of a row must be separated by commas, and rows must be separated by semicolons.\n"
-      "It is also possible to define expressions within the same txt file, with the pattern #E expr. For instance (two expressions; see also limitations section below):\n\n"
-      "#E $dotpr(kernel1,im1b1N3x5); im2b1^expo$\n"
-      "\n- The 'outcontext' parameter allows saving user's constants and expressions (context).\n"
-      "- Setting the output image can be done with the 'out' parameter (multi-outputs is not implemented yet).\n"
-      "\n\n"
-      "Finally, we strongly recommend that the reader takes a look at the cookbook, where additional information can be found (http://www.orfeo-toolbox.org/packages/OTBCookBook.pdf).\n"
-
-);
-
-    SetDocLimitations("The application is currently unable to produce one output image per expression, contrary to otbBandMathXImageFilter.\n"
-                      "Separating expressions by semi-colons (; ) will concatenate their results into a unique multiband output image. ");
-    SetDocAuthors("OTB-Team");
-    SetDocSeeAlso(" ");
-    AddDocTag("Miscellaneous");
-
-    AddParameter(ParameterType_InputImageList,  "il",   "Input image list");
-    SetParameterDescription("il", "Image list to perform computation on.");
-
-    AddParameter(ParameterType_OutputImage, "out", "Output Image");
-    SetParameterDescription("out","Output image.");
+      "- existing operators/functions from muParserX, that were not originally "
+      "defined for vectors and matrices (e.g. cos, sin). These new "
+      "operators/functions keep the original names to which we added the prefix "
+      "'v' for vector (vcos, vsin, etc.)\n"
+      "- mult, div and pow operators, that perform element-wise multiplication, "
+      "division or exponentiation of vector/matrices (e.g. im1 div im2).\n"
+      "- mlt, dv and pw operators, that perform multiplication, division or "
+      "exponentiation of vector/matrices by a scalar (e.g. im1 dv 2.0).\n"
+      "- bands, which is a very useful operator. It allows selecting specific "
+      "bands from an image, and/or to rearrange them in a new vector (e.g."
+      "bands( im1, { 1, 2, 1, 1 } ) produces a vector of 4 components made of "
+      "band 1, band 2, band 1 and band 1 values from the first input.\n\n"
+      "Note that curly brackets must be used in order to select the desired band"
+      "indices.\n\n"
+
+      "The application itself\n"
+      "----------------------\n\n"
+
+      "The application takes the following parameters:\n"
+      "-il          Sets the list of inputs\n"
+      "-ext         Sets the mathematical expression (see also limitations "
+      "section below).\n"
+      "-incontext   Sets the text filename containing constants values (syntax: "
+      "'#type name value')\n\n"
+
+      "An example of such a file is given below:\n"
+      "  #F expo 1.1\n"
+      "  #M kernel1 { 0.1 , 0.2 , 0.3; 0.4 , 0.5 , 0.6; 0.7 , 0.8 , 0.9; 1 , 1.1"
+      ", 1.2; 1.3 , 1.4 , 1.5 }\n\n"
+
+      "As we can see, #I/#F allows the definition of an integer/float constant, "
+      "whereas #M allows the definition of a vector/matrix. In the latter case, "
+      "elements of a row must be separated by commas, and rows must be separated"
+      " by semicolons.\n\n"
+
+      "It is also possible to define expressions within the same txt file, with "
+      "#E <expr> (see limitations, below). For instance:\n"
+      "  #E $dotpr( kernel1, im1b1N3x5 ); im2b1^expo$\n\n"
+
+      "-outcontext  Output usesr's constants and expressions (context).\n"
+      "-out         Sets output image (multi-outputs is not implemented yet).\n"
+      "\n"
 
-    AddRAMParameter();
+      "Finally, we strongly recommend to read the OTB Cookbook which can be "
+      "found at: http://www.orfeo-toolbox.org/packages/OTBCookBook.pdf"
+    );
+
+    SetDocLimitations(
+      "The application is currently unable to produce one output image per "
+      "expression, contrary to otbBandMathXImageFilter.\n\n"
+      "Separating expressions by semi-colons ';' will concatenate their results "
+      "into a unique multiband output image."
+    );
+    SetDocAuthors( "OTB-Team" );
+    SetDocSeeAlso("[1] http://articles.beltoforion.de/article.php?a=muparserx\n"
+      "[2] BandMath");
+    AddDocTag( "Miscellaneous" );
 
-    AddParameter(ParameterType_String, "exp", "Expressions");
-    SetParameterDescription("exp",
-                            "Mathematical expression to apply.");
+    AddParameter( ParameterType_InputImageList, "il", "Input image-list" );
+    SetParameterDescription( "il", "Image-list to perform computation on." );
 
-    AddParameter(ParameterType_InputFilename, "incontext", "Import context");
-    SetParameterDescription("incontext",
-                            "A txt file containing user's constants and expressions.");
-    MandatoryOff("incontext");
+    AddParameter( ParameterType_OutputImage, "out", "Output Image" );
+    SetParameterDescription( "out", "Output image." );
+
+    AddRAMParameter();
 
-    AddParameter(ParameterType_OutputFilename, "outcontext", "Export context");
-    SetParameterDescription("outcontext",
-                            "A txt file where to save user's constants and expressions.");
-    MandatoryOff("outcontext");
+    AddParameter( ParameterType_String, "exp", "Expressions" );
+    SetParameterDescription(
+      "exp",
+      "Mathematical expression to apply."
+    );
+
+    AddParameter( ParameterType_InputFilename, "incontext", "Import context" );
+    SetParameterDescription(
+      "incontext",
+      "A txt file containing user's constants and expressions."
+    );
+    MandatoryOff( "incontext" );
+
+    AddParameter( ParameterType_OutputFilename, "outcontext", "Export context" );
+    SetParameterDescription(
+      "outcontext",
+      "A txt file where to save user's constants and expressions."
+    );
+    MandatoryOff( "outcontext" );
 
     // Doc example parameter settings
-    SetDocExampleParameterValue("il", "verySmallFSATSW_r.tif verySmallFSATSW_nir.tif verySmallFSATSW.tif");
-    SetDocExampleParameterValue("out", "apTvUtBandMathOutput.tif");
-    SetDocExampleParameterValue("exp", "\"cos(im1b1)+im2b1*im3b1-im3b2+ndvi(im3b3, im3b4)\"");
+    SetDocExampleParameterValue(
+      "il",
+      "verySmallFSATSW_r.tif verySmallFSATSW_nir.tif verySmallFSATSW.tif"
+    );
+    SetDocExampleParameterValue( "out", "apTvUtBandMathOutput.tif");
+    SetDocExampleParameterValue(
+      "exp",
+      "'cos( im1b1 ) + im2b1 * im3b1 - im3b2 + ndvi( im3b3, im3b4 )'"
+    );
 
     SetOfficialDocLink();
   }
diff --git a/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx b/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx
index 3593b85..79d9464 100644
--- a/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx
+++ b/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx
@@ -103,7 +103,7 @@ private:
                                    "The output image can be :"
                                    "- A :math:`N` multi band image for the opening/closing normal or derivative profiles.\n"
                                    "- A mono band image for the opening/closing characteristics.\n"
-                                   "- A labeled image for the classification\n" );
+                                   "- A labeled image for the classification." );
     SetDocLimitations( "Generation of the morphological profile is not streamable, pay attention to this fact when setting the radius initial size and step of the structuring element." );
     SetDocAuthors( "OTB-Team" );
     SetDocSeeAlso( "otbMorphologicalOpeningProfileFilter, otbMorphologicalClosingProfileFilter, otbProfileToProfileDerivativeFilter, otbProfileDerivativeToMultiScaleCharacteristicsFilter, otbMultiScaleConvexOrConcaveClassificationFilter, classes" );
diff --git a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx
index b4253f0..7707ead 100644
--- a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx
+++ b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx
@@ -23,10 +23,10 @@
 #include "otbWrapperApplication.h"
 #include "otbWrapperApplicationFactory.h"
 
-#include "otbImageToLuminanceImageFilter.h"
-#include "otbLuminanceToReflectanceImageFilter.h"
-#include "otbLuminanceToImageImageFilter.h"
-#include "otbReflectanceToLuminanceImageFilter.h"
+#include "otbImageToRadianceImageFilter.h"
+#include "otbRadianceToReflectanceImageFilter.h"
+#include "otbRadianceToImageImageFilter.h"
+#include "otbReflectanceToRadianceImageFilter.h"
 #include "otbReflectanceToSurfaceReflectanceImageFilter.h"
 #include "itkMultiplyImageFilter.h"
 #include "otbClampVectorImageFilter.h"
@@ -78,17 +78,17 @@ public:
 
   itkTypeMacro(OpticalCalibration, Application);
 
-  typedef ImageToLuminanceImageFilter<FloatVectorImageType,
-                                      DoubleVectorImageType>              ImageToLuminanceImageFilterType;
+  typedef ImageToRadianceImageFilter<FloatVectorImageType,
+                                      DoubleVectorImageType>              ImageToRadianceImageFilterType;
 
-  typedef LuminanceToReflectanceImageFilter<DoubleVectorImageType,
-                                            DoubleVectorImageType>        LuminanceToReflectanceImageFilterType;
+  typedef RadianceToReflectanceImageFilter<DoubleVectorImageType,
+                                            DoubleVectorImageType>        RadianceToReflectanceImageFilterType;
 
-  typedef LuminanceToImageImageFilter<DoubleVectorImageType,
-                                            DoubleVectorImageType>        LuminanceToImageImageFilterType;
+  typedef RadianceToImageImageFilter<DoubleVectorImageType,
+                                            DoubleVectorImageType>        RadianceToImageImageFilterType;
 
-  typedef ReflectanceToLuminanceImageFilter<FloatVectorImageType,
-                                            DoubleVectorImageType>        ReflectanceToLuminanceImageFilterType;
+  typedef ReflectanceToRadianceImageFilter<FloatVectorImageType,
+                                            DoubleVectorImageType>        ReflectanceToRadianceImageFilterType;
 
   typedef itk::MultiplyImageFilter<DoubleVectorImageType,DoubleImageType,DoubleVectorImageType>         ScaleFilterOutDoubleType;
 
@@ -381,7 +381,7 @@ private:
       {
         ossOutput << std::endl << "File: " << m_inImageName << std::endl;
 
-        //Check if valid metadata information are available to compute ImageToLuminance and LuminanceToReflectance
+        //Check if valid metadata information are available to compute ImageToRadiance and RadianceToReflectance
         FloatVectorImageType::Pointer inImage = GetParameterFloatVectorImage("in");
         itk::MetaDataDictionary             dict = inImage->GetMetaDataDictionary();
         OpticalImageMetadataInterface::Pointer lImageMetadataInterface = OpticalImageMetadataInterfaceFactory::CreateIMI(dict);
@@ -566,11 +566,11 @@ private:
   void DoExecute() ITK_OVERRIDE
   {
     //Main filters instantiations
-    m_ImageToLuminanceFilter                = ImageToLuminanceImageFilterType::New();
-    m_LuminanceToReflectanceFilter          = LuminanceToReflectanceImageFilterType::New();
+    m_ImageToRadianceFilter                = ImageToRadianceImageFilterType::New();
+    m_RadianceToReflectanceFilter          = RadianceToReflectanceImageFilterType::New();
     m_ReflectanceToSurfaceReflectanceFilter = ReflectanceToSurfaceReflectanceImageFilterType::New();
-    m_ReflectanceToLuminanceFilter          = ReflectanceToLuminanceImageFilterType::New();
-    m_LuminanceToImageFilter                = LuminanceToImageImageFilterType::New();
+    m_ReflectanceToRadianceFilter          = ReflectanceToRadianceImageFilterType::New();
+    m_RadianceToImageFilter                = RadianceToImageImageFilterType::New();
 
     //Other instantiations
     m_ScaleFilter = ScaleFilterOutDoubleType::New();
@@ -590,22 +590,22 @@ private:
     // Set (Date and Day) OR FluxNormalizationCoef to corresponding filters
     if ( !IsParameterEnabled("acqui.fluxnormcoeff") )
     {
-      m_LuminanceToReflectanceFilter->SetDay(GetParameterInt("acqui.day"));
-      m_LuminanceToReflectanceFilter->SetMonth(GetParameterInt("acqui.month"));
+      m_RadianceToReflectanceFilter->SetDay(GetParameterInt("acqui.day"));
+      m_RadianceToReflectanceFilter->SetMonth(GetParameterInt("acqui.month"));
 
-      m_ReflectanceToLuminanceFilter->SetDay(GetParameterInt("acqui.day"));
-      m_ReflectanceToLuminanceFilter->SetMonth(GetParameterInt("acqui.month"));
+      m_ReflectanceToRadianceFilter->SetDay(GetParameterInt("acqui.day"));
+      m_ReflectanceToRadianceFilter->SetMonth(GetParameterInt("acqui.month"));
     }
     else
     {
-      m_LuminanceToReflectanceFilter->SetFluxNormalizationCoefficient(GetParameterFloat("acqui.fluxnormcoeff"));
+      m_RadianceToReflectanceFilter->SetFluxNormalizationCoefficient(GetParameterFloat("acqui.fluxnormcoeff"));
 
-      m_ReflectanceToLuminanceFilter->SetFluxNormalizationCoefficient(GetParameterFloat("acqui.fluxnormcoeff"));
+      m_ReflectanceToRadianceFilter->SetFluxNormalizationCoefficient(GetParameterFloat("acqui.fluxnormcoeff"));
     }
 
     // Set Sun Elevation Angle to corresponding filters
-    m_LuminanceToReflectanceFilter->SetElevationSolarAngle(GetParameterFloat("acqui.sun.elev"));
-    m_ReflectanceToLuminanceFilter->SetElevationSolarAngle(GetParameterFloat("acqui.sun.elev"));
+    m_RadianceToReflectanceFilter->SetElevationSolarAngle(GetParameterFloat("acqui.sun.elev"));
+    m_ReflectanceToRadianceFilter->SetElevationSolarAngle(GetParameterFloat("acqui.sun.elev"));
 
     // Set Gain and Bias to corresponding filters
     if (IsParameterEnabled("acqui.gainbias") && HasValue("acqui.gainbias"))
@@ -644,14 +644,14 @@ private:
             switch (numLine)
             {
               case 1 :
-              m_ImageToLuminanceFilter->SetAlpha(vlvector);
-              m_LuminanceToImageFilter->SetAlpha(vlvector);
+              m_ImageToRadianceFilter->SetAlpha(vlvector);
+              m_RadianceToImageFilter->SetAlpha(vlvector);
               GetLogger()->Info("Trying to get gains/biases information... OK (1/2)\n");
               break;
 
               case 2 :
-              m_ImageToLuminanceFilter->SetBeta(vlvector);
-              m_LuminanceToImageFilter->SetBeta(vlvector);
+              m_ImageToRadianceFilter->SetBeta(vlvector);
+              m_RadianceToImageFilter->SetBeta(vlvector);
               GetLogger()->Info("Trying to get gains/biases information... OK (2/2)\n");
               break;
 
@@ -669,11 +669,11 @@ private:
       //Try to retrieve information from image metadata
       if (IMIName != IMIOptDfltName)
       {
-        m_ImageToLuminanceFilter->SetAlpha(lImageMetadataInterface->GetPhysicalGain());
-        m_LuminanceToImageFilter->SetAlpha(lImageMetadataInterface->GetPhysicalGain());
+        m_ImageToRadianceFilter->SetAlpha(lImageMetadataInterface->GetPhysicalGain());
+        m_RadianceToImageFilter->SetAlpha(lImageMetadataInterface->GetPhysicalGain());
 
-        m_ImageToLuminanceFilter->SetBeta(lImageMetadataInterface->GetPhysicalBias());
-        m_LuminanceToImageFilter->SetBeta(lImageMetadataInterface->GetPhysicalBias());
+        m_ImageToRadianceFilter->SetBeta(lImageMetadataInterface->GetPhysicalBias());
+        m_RadianceToImageFilter->SetBeta(lImageMetadataInterface->GetPhysicalBias());
       }
       else
         itkExceptionMacro(<< "Please, provide a type of sensor supported by OTB for automatic metadata extraction! ");
@@ -711,8 +711,8 @@ private:
             itk::VariableLengthVector<double> vlvector;
             vlvector.SetData(values.data(),values.size(),false);
 
-            m_LuminanceToReflectanceFilter->SetSolarIllumination(vlvector);
-            m_ReflectanceToLuminanceFilter->SetSolarIllumination(vlvector);
+            m_RadianceToReflectanceFilter->SetSolarIllumination(vlvector);
+            m_ReflectanceToRadianceFilter->SetSolarIllumination(vlvector);
           }
         }
         file.close();
@@ -725,8 +725,8 @@ private:
       //Try to retrieve information from image metadata
       if (IMIName != IMIOptDfltName)
       {
-        m_LuminanceToReflectanceFilter->SetSolarIllumination(lImageMetadataInterface->GetSolarIrradiance());
-        m_ReflectanceToLuminanceFilter->SetSolarIllumination(lImageMetadataInterface->GetSolarIrradiance());
+        m_RadianceToReflectanceFilter->SetSolarIllumination(lImageMetadataInterface->GetSolarIrradiance());
+        m_ReflectanceToRadianceFilter->SetSolarIllumination(lImageMetadataInterface->GetSolarIrradiance());
       }
       else
         itkExceptionMacro(<< "Please, provide a type of sensor supported by OTB for automatic metadata extraction! ");
@@ -748,17 +748,17 @@ private:
         GetLogger()->Info("Compute Top of Atmosphere reflectance\n");
 
         //Pipeline
-        m_ImageToLuminanceFilter->SetInput(inImage);
-        m_LuminanceToReflectanceFilter->SetInput(m_ImageToLuminanceFilter->GetOutput());
+        m_ImageToRadianceFilter->SetInput(inImage);
+        m_RadianceToReflectanceFilter->SetInput(m_ImageToRadianceFilter->GetOutput());
 
         if (IsParameterEnabled("clamp"))
           {
           GetLogger()->Info("Clamp values between [0, 100]\n");
           }
 
-        m_LuminanceToReflectanceFilter->SetUseClamp(IsParameterEnabled("clamp"));
-        m_LuminanceToReflectanceFilter->UpdateOutputInformation();
-        m_ScaleFilter->SetInput(m_LuminanceToReflectanceFilter->GetOutput());
+        m_RadianceToReflectanceFilter->SetUseClamp(IsParameterEnabled("clamp"));
+        m_RadianceToReflectanceFilter->UpdateOutputInformation();
+        m_ScaleFilter->SetInput(m_RadianceToReflectanceFilter->GetOutput());
       }
       break;
       case Level_TOA_IM:
@@ -766,10 +766,10 @@ private:
         GetLogger()->Info("Convert Top of Atmosphere reflectance to image DN\n");
 
         //Pipeline
-        m_ReflectanceToLuminanceFilter->SetInput(inImage);
-        m_LuminanceToImageFilter->SetInput(m_ReflectanceToLuminanceFilter->GetOutput());
-        m_LuminanceToImageFilter->UpdateOutputInformation();
-        m_ScaleFilter->SetInput(m_LuminanceToImageFilter->GetOutput());
+        m_ReflectanceToRadianceFilter->SetInput(inImage);
+        m_RadianceToImageFilter->SetInput(m_ReflectanceToRadianceFilter->GetOutput());
+        m_RadianceToImageFilter->UpdateOutputInformation();
+        m_ScaleFilter->SetInput(m_RadianceToImageFilter->GetOutput());
       }
       break;
       case Level_TOC:
@@ -777,9 +777,9 @@ private:
         GetLogger()->Info("Compute Top of Canopy reflectance\n");
 
         //Pipeline
-        m_ImageToLuminanceFilter->SetInput(inImage);
-        m_LuminanceToReflectanceFilter->SetInput(m_ImageToLuminanceFilter->GetOutput());
-        m_ReflectanceToSurfaceReflectanceFilter->SetInput(m_LuminanceToReflectanceFilter->GetOutput());
+        m_ImageToRadianceFilter->SetInput(inImage);
+        m_RadianceToReflectanceFilter->SetInput(m_ImageToRadianceFilter->GetOutput());
+        m_ReflectanceToSurfaceReflectanceFilter->SetInput(m_RadianceToReflectanceFilter->GetOutput());
         m_ReflectanceToSurfaceReflectanceFilter->SetAcquiCorrectionParameters(m_paramAcqui);
         m_ReflectanceToSurfaceReflectanceFilter->SetAtmoCorrectionParameters(m_paramAtmo);
 
@@ -934,10 +934,10 @@ private:
   }
 
   //Keep object references as a members of the class, else the pipeline will be broken after exiting DoExecute().
-  ImageToLuminanceImageFilterType ::Pointer               m_ImageToLuminanceFilter;
-  LuminanceToReflectanceImageFilterType::Pointer          m_LuminanceToReflectanceFilter;
-  ReflectanceToLuminanceImageFilterType::Pointer          m_ReflectanceToLuminanceFilter;
-  LuminanceToImageImageFilterType::Pointer                m_LuminanceToImageFilter;
+  ImageToRadianceImageFilterType ::Pointer               m_ImageToRadianceFilter;
+  RadianceToReflectanceImageFilterType::Pointer          m_RadianceToReflectanceFilter;
+  ReflectanceToRadianceImageFilterType::Pointer          m_ReflectanceToRadianceFilter;
+  RadianceToImageImageFilterType::Pointer                m_RadianceToImageFilter;
   ReflectanceToSurfaceReflectanceImageFilterType::Pointer m_ReflectanceToSurfaceReflectanceFilter;
   ScaleFilterOutDoubleType::Pointer                       m_ScaleFilter;
   AtmoCorrectionParametersPointerType                     m_paramAtmo;
diff --git a/Modules/Applications/AppOpticalCalibration/test/CMakeLists.txt b/Modules/Applications/AppOpticalCalibration/test/CMakeLists.txt
index b5df61f..a3068e1 100644
--- a/Modules/Applications/AppOpticalCalibration/test/CMakeLists.txt
+++ b/Modules/Applications/AppOpticalCalibration/test/CMakeLists.txt
@@ -27,7 +27,7 @@ otb_test_application(NAME apTvRaOpticalCalibration_QuickbirdXS
                              -clamp false
                              -out ${TEMP}/apTvRaOpticalCalibration_QuickbirdXS.tif
                      VALID   --compare-image ${EPSILON_7}
-                             ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoQuickbirdXS.tif
+                             ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoQuickbirdXS.tif
                              ${TEMP}/apTvRaOpticalCalibration_QuickbirdXS.tif )
 
 otb_test_application(NAME apTvRaOpticalCalibration_WV2PAN
@@ -36,7 +36,7 @@ otb_test_application(NAME apTvRaOpticalCalibration_WV2PAN
                              -level toa
                              -out ${TEMP}/apTvRaOpticalCalibration_WV2PAN.tif
                      VALID   --compare-image ${EPSILON_7}
-                             ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoWV2PAN.tif
+                             ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoWV2PAN.tif
                              ${TEMP}/apTvRaOpticalCalibration_WV2PAN.tif )
 
 otb_test_application(NAME apTvRaOpticalCalibration_WV2Multi
@@ -45,7 +45,7 @@ otb_test_application(NAME apTvRaOpticalCalibration_WV2Multi
                              -level toa
                              -out ${TEMP}/apTvRaOpticalCalibration_WV2Multi.tif
                      VALID   --compare-image ${EPSILON_7}
-                             ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoWV2Multi.tif
+                             ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoWV2Multi.tif
                              ${TEMP}/apTvRaOpticalCalibration_WV2Multi.tif )
 
 otb_test_application(NAME apTvRaOpticalCalibration_Formosat
@@ -54,7 +54,7 @@ otb_test_application(NAME apTvRaOpticalCalibration_Formosat
                              -level toa
                              -out ${TEMP}/apTvRaOpticalCalibration_Formosat.img
                      VALID   --compare-image ${EPSILON_7}
-                             ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoFormosat.tif
+                             ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoFormosat.tif
                              ${TEMP}/apTvRaOpticalCalibration_Formosat.img )
 
 otb_test_application(NAME apTvRaOpticalCalibration_QuickbirdPAN
@@ -63,7 +63,7 @@ otb_test_application(NAME apTvRaOpticalCalibration_QuickbirdPAN
                              -level toa
                              -out ${TEMP}/apTvRaOpticalCalibration_QuickbirdPAN.tif
                      VALID   --compare-image ${EPSILON_7}
-                             ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoQuickbirdPAN.tif
+                             ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoQuickbirdPAN.tif
                              ${TEMP}/apTvRaOpticalCalibration_QuickbirdPAN.tif )
 
 otb_test_application(NAME apTvRaOpticalCalibration_Spot5
@@ -72,7 +72,7 @@ otb_test_application(NAME apTvRaOpticalCalibration_Spot5
                              -level toa
                              -out ${TEMP}/apTvRaOpticalCalibration_Spot5.img
                      VALID   --compare-image ${EPSILON_7}
-                             ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoSpot5.tif
+                             ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoSpot5.tif
                              ${TEMP}/apTvRaOpticalCalibration_Spot5.img )
 
 otb_test_application(NAME apTvRaOpticalCalibration_UnknownSensor
@@ -106,7 +106,7 @@ otb_test_application(NAME apTvRaOpticalCalibration_UnknownSensor
 otb_test_application(NAME apTvRaOpticalCalibration_Reverse_UnknownSensor
                      APP  OpticalCalibration
                      OPTIONS 
-			     -in ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoQuickbirdXS.tif
+			     -in ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoQuickbirdXS.tif
 			     -out ${TEMP}/apTvRaOpticalCalibration_Rev_QB-XS_UnknownSensor_test.tif
 			     -level toatoim 
 			     -acqui.gainbias ${INPUTDATA}/apTvRaOpticalCalibrationUnknownSensorGainsBiases.txt
@@ -126,6 +126,6 @@ otb_test_application(NAME apTvRaOpticalCalibration_Ikonos
                              -level toa
                              -out ${TEMP}/apTvRaOpticalCalibration_Ikonos.tif
                      VALID   --compare-image ${EPSILON_7}
-                             ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoIkonos.tif
+                             ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoIkonos.tif
                              ${TEMP}/apTvRaOpticalCalibration_Ikonos.tif )
 
diff --git a/Modules/Applications/AppProjection/app/otbImageEnvelope.cxx b/Modules/Applications/AppProjection/app/otbImageEnvelope.cxx
index 4dcee6f..cda6b1f 100644
--- a/Modules/Applications/AppProjection/app/otbImageEnvelope.cxx
+++ b/Modules/Applications/AppProjection/app/otbImageEnvelope.cxx
@@ -56,21 +56,25 @@ private:
 
     // Documentation
     SetDocName("Image Envelope");
-    SetDocLongDescription("Build a vector data containing the polygon of the image envelope.");
+    SetDocLongDescription("Build a vector data containing the image envelope polygon. "
+      "Useful for some projection, you can set the polygon with more points with the sr parameter. "
+      "This filter supports user-specified output projection. "
+      "If no projection is defined, the standard WGS84 projection will be used.");
+
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
     SetDocSeeAlso(" ");
 
     AddDocTag(Tags::Geometry);
 
-    AddParameter(ParameterType_InputImage,  "in",   "Input Image");
-    SetParameterDescription("in", "Input image.");
+    AddParameter(ParameterType_InputImage, "in", "Input Image");
+    SetParameterDescription("in", "Input image filename.");
 
-    AddParameter(ParameterType_OutputVectorData,  "out",   "Output Vector Data");
-    SetParameterDescription("out", "Vector data file containing the envelope");
+    AddParameter(ParameterType_OutputVectorData, "out", "Output Vector Data");
+    SetParameterDescription("out", "Vector data file containing the envelope.");
 
     AddParameter(ParameterType_Int, "sr", "Sampling Rate");
-    SetParameterDescription("sr", "Sampling rate for image edges (in pixel)");
+    SetParameterDescription("sr", "Sampling rate for image edges (in pixel).");
     SetDefaultParameterInt("sr",0);
     MandatoryOff("sr");
     DisableParameter("sr");
diff --git a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx
index 11aa91c..2dc6a61 100644
--- a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx
+++ b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx
@@ -91,7 +91,7 @@ private:
   {
     SetName("OrthoRectification");
     std::ostringstream oss;
-    oss << "This application allows ortho-rectification of optical images from supported sensors." << std::endl;
+    oss << "This application allows ortho-rectification of optical and radar images from supported sensors." << std::endl;
     SetDescription(oss.str());
     // Documentation
     SetDocName("Ortho-rectification");
@@ -101,7 +101,7 @@ private:
     oss<<"A Digital Elevation Model can be specified to account for terrain deformations. "<<std::endl;
     oss<<"In case of SPOT5 images, the sensor model can be approximated by an RPC model in order to speed-up computation.";
     SetDocLongDescription(oss.str());
-    SetDocLimitations("Supported sensors are Pleiades, SPOT5 (TIF format), Ikonos, Quickbird, Worldview2, GeoEye.");
+    SetDocLimitations("Supported sensors (both optical and radar) are: GeoEye, Ikonos, Pleiades, Quickbird, RadarSat, Sentinel-1, SPOT5 (TIF format), SPOT6/7, TerraSAR-X, Worldview 1/2/3.");
     SetDocAuthors("OTB-Team");
     SetDocSeeAlso("Ortho-rectification chapter from the OTB Software Guide");
 
diff --git a/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx b/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx
index d38349f..4a91dda 100644
--- a/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx
+++ b/Modules/Applications/AppSARCalibration/app/otbSARCalibration.cxx
@@ -52,7 +52,7 @@ private:
 
     // Documentation
     SetDocName("SAR Radiometric calibration");
-    SetDocLongDescription("The objective of SAR calibration is to provide imagery in which the pixel values can be directly related to the radar backscatter of the scene. This application allows computing Sigma Naught (Radiometric Calibration) for TerraSAR-X, Sentinel1 L1 and Radarsat-2 sensors. Metadata are automatically retrieved from image products.The application supports complex and non-complex images (SLC or detected products).\n");
+    SetDocLongDescription("The objective of SAR calibration is to provide imagery in which the pixel values can be directly related to the radar backscatter of the scene. This application allows computing Sigma Naught (Radiometric Calibration) for TerraSAR-X, Sentinel1 L1 and Radarsat-2 sensors. Metadata are automatically retrieved from image products.The application supports complex and non-complex images (SLC or detected products).");
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
     SetDocSeeAlso(" ");
diff --git a/Modules/Applications/AppSARCalibration/app/otbSARDeburst.cxx b/Modules/Applications/AppSARCalibration/app/otbSARDeburst.cxx
index 98bbd59..01e0946 100644
--- a/Modules/Applications/AppSARCalibration/app/otbSARDeburst.cxx
+++ b/Modules/Applications/AppSARCalibration/app/otbSARDeburst.cxx
@@ -47,23 +47,38 @@ private:
   void DoInit() ITK_OVERRIDE
   {
     SetName("SARDeburst");
-    SetDescription("This application performs a deburst operation by removing redundant lines. \n");
+    SetDescription("This application performs deburst of Sentinel1 IW SLC images by removing redundant lines.\n");
 
     // Documentation
     SetDocName("SAR Deburst");
-    SetDocLongDescription("This application performs a deburst operation by removing redundant lines between burst. This operation is useful when dealing with Sentinel1 IW SLC products, where each subswath is composed of several overlapping burst separated by black lines. Lines to remove are computed by SAR sensor model in OSSIM plugins. The output image is smaller in azimuth direction than the input line, because of removed lines. Note that the output sensor model is updated accordingly [...]
-    SetDocLimitations("Only Sentinel1 IW SLC products are supported for now.");
+    SetDocLongDescription("Sentinel1 IW SLC products are composed of several burst overlapping in"
+                          " azimuth time for each subswath, separated by black lines [1]. The deburst"
+                          " operation consist in generating a continuous image in terms of azimuth"
+                          " time, by removing black separation lines as well as redundant lines"
+                          " between bursts.\n\n"
+                          
+                          "Note that the output sensor model is updated accordingly. This deburst"
+                          " operation is the perfect preprocessing step to orthorectify S1 IW SLC"
+                          " product with OTB [2] without suffering from artifacts caused by"
+                          " bursts separation.");
+    
+    SetDocLimitations("Only Sentinel1 IW SLC products are supported for now. Processing of"
+                      " other Sentinel1 modes or TerrasarX images will result in no changes in"
+                      " the image and metadata. Images from other sensors will lead to an"
+                      " error.");
+    
     SetDocAuthors("OTB-Team");
-    SetDocSeeAlso("OrthoRectification");
+    SetDocSeeAlso("[1] Sentinel1 User Handbook, p. 52: https://sentinel.esa.int/documents/247904/685163/Sentinel-1_User_Handbook\n"
+                  "[2] OrthoRectification application");
 
-    AddDocTag(Tags::Calibration);
     AddDocTag(Tags::SAR);
+    AddDocTag(Tags::Calibration);
 
-    AddParameter(ParameterType_InputImage,  "in", "Input Image");
-    SetParameterDescription("in", "Input image");
+    AddParameter(ParameterType_InputImage,  "in", "Input Sentinel1 IW SLC Image");
+    SetParameterDescription("in", "Raw Sentinel1 IW SLC image, or any extract of such made by OTB (geom file needed)");
 
     AddParameter(ParameterType_OutputImage,  "out", "Output Image");
-    SetParameterDescription("out", "Output deburst image");
+    SetParameterDescription("out", "Deburst image, with updated geom file that can be further used by Orthorectification application. If the input image is a raw Sentinel1 product, uint16 output type should be used (encoding of S1 product). Otherwise, output type should match type of input image.");
 
     AddRAMParameter();
 
diff --git a/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx
index 8d0e99c..1557954 100644
--- a/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx
+++ b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx
@@ -97,7 +97,7 @@ private:
                           "In the coherent case, only the Pauli decomposition is available.\n"
                           "In the incoherent case, there the decompositions available : Huynen, Barnes, and H-alpha-A.\n"   
 						  "User must provide three one-band complex images HH, HV or VH, and VV (mono-static case <=> HV = VH).\n"
-						  "Incoherent decompositions consist in averaging 3x3 complex coherency/covariance matrices; the user must provide the size of the averaging window, thanks to the parameter inco.kernelsize.\n "
+						  "Incoherent decompositions consist in averaging 3x3 complex coherency/covariance matrices; the user must provide the size of the averaging window, thanks to the parameter inco.kernelsize."
 						  );
 						  
 						  
diff --git a/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx b/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx
index e558ac6..9c8c062 100644
--- a/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx
+++ b/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx
@@ -222,7 +222,7 @@ private:
     
     "11 sinclairtomueller --> Sinclair matrix to Mueller matrix (input : 4 x 1 complex channel (HH, HV, VH, VV) | output : 16 real channels)\n"
     "12 muellertomcovariance --> Mueller matrix to covariance matrix (input : 16 real channels | output : 6 complex channels)\n"
-    "13 muellertopoldegandpower --> Mueller matrix to polarization degree and power (input : 16 real channels | output : 4 real channels)\n"
+    "13 muellertopoldegandpower --> Mueller matrix to polarization degree and power (input : 16 real channels | output : 4 real channels)"
 
  );
 						  
diff --git a/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt b/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt
index e77967b..ebdaca7 100644
--- a/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt
+++ b/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt
@@ -23,7 +23,7 @@ otb_module_test()
 
 otb_test_application(NAME  apTvSARPolarSynth
                      APP  SARPolarSynth
-                     OPTIONS -in ${INPUTDATA}/RSAT2_AltonaExtract_1000_1000_100_100.hdr
+                     OPTIONS -in ${INPUTDATA}/RSAT2_AltonaExtract_1000_1000_100_100.tif
                	             -out ${TEMP}/resApMultiPolarimetricSynthesis1.tif
                              -psii 10.0 
                              -khii 0.0
diff --git a/Modules/Applications/AppSARUtils/app/CMakeLists.txt b/Modules/Applications/AppSARUtils/app/CMakeLists.txt
index f0e7132..6f0e019 100644
--- a/Modules/Applications/AppSARUtils/app/CMakeLists.txt
+++ b/Modules/Applications/AppSARUtils/app/CMakeLists.txt
@@ -1,5 +1,8 @@
 set(OTBAppSARUtils_LINK_LIBS
   ${OTBSARUtils_LIBRARIES}
+  {OTBImageNoise_LIBRARIES}
+  ${OTBImageBase_LIBRARIES}
+  ${OTBITK_LIBRARIES}
   ${OTBApplicationEngine_LIBRARIES}
 )
 
@@ -7,3 +10,8 @@ otb_create_application(
   NAME           ComputeModulusAndPhase
   SOURCES        otbComputeModulusAndPhase.cxx
   LINK_LIBRARIES ${${otb-module}_LIBRARIES})
+
+otb_create_application(
+  NAME           Despeckle
+  SOURCES        otbDespeckle.cxx
+  LINK_LIBRARIES ${${otb-module}_LIBRARIES})
diff --git a/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx b/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx
index a1ec51a..39db311 100644
--- a/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx
+++ b/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx
@@ -20,11 +20,11 @@
 
 #include "otbWrapperApplication.h"
 #include "otbWrapperApplicationFactory.h"
-#include <otbMultiToMonoChannelExtractROI.h>
+#include "otbMultiToMonoChannelExtractROI.h"
 
 #include "itkComplexToPhaseImageFilter.h"
 #include "itkComplexToModulusImageFilter.h"
-#include <itkMacro.h>
+#include "itkMacro.h"
 
 namespace otb
 {
@@ -68,21 +68,26 @@ private:
       "complex SAR image. The input should be a single band image with "
       "complex pixels."
     );
-    SetDocLimitations("None");
+    SetDocLimitations("The application takes as input single band image with complex pixels.");
     SetDocAuthors("Alexia Mondot (alexia.mondot at c-s.fr) and Mickael Savinaud (mickael.savinaud at c-s.fr)");
-    SetDocSeeAlso("SARPolarMatrixConvert, SARPolarSynth");
-    AddDocTag(Tags::SAR);
+    SetDocSeeAlso("Despeckle, SARPolarMatrixConvert, SARPolarSynth");
 
+    AddDocTag(Tags::SAR);
+    AddDocTag(Tags::Manip);
     // Input images
     AddParameter(ParameterType_ComplexInputImage,  "in",   "Input Image");
     SetParameterDescription("in", "Input image (complex single band)");
 
     // Outputs
     AddParameter(ParameterType_OutputImage, "modulus", "Modulus");
-    SetParameterDescription("modulus", "Modulus of the input: sqrt(real*real + imag*imag).");
-
+    SetParameterDescription("modulus", "Modulus of the input image computes with the\n"
+                            "following formula: :math:`\\sqrt{real*real + imag*imag}` where real and imag \n"
+                            "are respectively the real and the imaginary part of the input complex image.\n");
+    
     AddParameter(ParameterType_OutputImage, "phase", "Phase");
-    SetParameterDescription("phase", "Phase of the input: atan2(imag, real).");
+    SetParameterDescription("phase", "Phase of the input image computes with the following formula:\n"
+    ":math:`\\tan^{-1}(\\frac{imag}{real})` where real and imag are respectively the real and\n"
+    "the imaginary part of the input complex image.");
 
     AddRAMParameter();
 
diff --git a/Modules/Applications/AppFiltering/app/otbDespeckle.cxx b/Modules/Applications/AppSARUtils/app/otbDespeckle.cxx
similarity index 64%
rename from Modules/Applications/AppFiltering/app/otbDespeckle.cxx
rename to Modules/Applications/AppSARUtils/app/otbDespeckle.cxx
index 2d3a2de..f469402 100644
--- a/Modules/Applications/AppFiltering/app/otbDespeckle.cxx
+++ b/Modules/Applications/AppSARUtils/app/otbDespeckle.cxx
@@ -61,13 +61,44 @@ private:
 
     // Documentation
     SetDocName("Despeckle");
-    SetDocLongDescription("This application reduce speckle noise. Four methods are available: Lee, Frost, GammaMAP and Kuan.");
-    SetDocLimitations("None");
+    SetDocLongDescription("SAR images are affected by speckle noise that inherently exists in and which"
+     " degrades the image quality. It is caused by the coherent nature of"
+     " back-scattered waves from multiple distributed targets. It is locally strong"
+     " and it increases the mean Grey level of a local area. \n\n"
+     "Reducing the speckle noise enhances radiometric resolution but tend to decrease the spatial resolution."
+     "Several different methods are used to eliminate speckle noise, based upon"
+     " different mathematical models of the phenomenon. The application includes four"
+     " methods: Lee [1], Frost [2], GammaMAP [3] and Kuan [4]. \n\n"
+     "We sum up below the basic principle of this four methods:\n"
+      "  * Lee : Estimate the signal by mean square error minimization (MMSE) on a sliding window.\n"
+      "  * Frost : Also derived from the MMSE criteria with a weighted sum of the values within the window. The weighting factors decrease with distance from the pixel of interest.\n"
+      "  * GammaMAP  : Derived under the assumption of the image follows a Gamma distribution.\n"
+      "  * Kuan : Also derived from the MMSE criteria under the assumption of non stationary mean and variance. It is quite similar to Lee filter in form."
+      );
+
+    SetDocLimitations("The application does not handle complex image as input.");
+
     SetDocAuthors("OTB-Team");
-    SetDocSeeAlso(" ");
+
+    SetDocSeeAlso("[1] J. Lee. Digital image enhancement and noise filtering by"
+                  "use of local statistics. IEEE Transactions on Pattern Analysis and Machine"
+                  "Intelligence, 2:165–168, 1980.\n"
+                  "[2] V. S. Frost, et al., A Model for Radar Images and Its"
+                  "Application to Adaptive Digital Filtering of Multiplicative"
+                  "Noise, IEEE Trans. Pattern Anal., Machine Intell., vol. 4,"
+                  "no. 2, pp. 157-166, Mar. 1982.\n"
+                  "[3] A. Lopes, E. Nezry, R. Touzi and H. Laur, Maximum A"
+                  "Posteriori Speckle Filtering And First Order Texture Models"
+                  "In Sar Images, 10th" "Annual International Symposium on"
+                  "Geoscience and Remote Sensing, 1990,pp. 2409-2412.  doi:"
+                  "10.1109/IGARSS.1990.689026\n"
+                  "[4] Kuan, D.  T., Sawchuk, A.  A., Strand, T.  C, and Chavel,"
+                  "P., 1987.  Adaptive restoration of image with speckle.  IEEE"
+                  "Trans on Acoustic Speech and Signal Processing, 35,"
+                  "pp. 373-383.");
 
     AddDocTag(Tags::Filter);
-	AddDocTag(Tags::SAR);
+	  AddDocTag(Tags::SAR);
 
     AddParameter(ParameterType_InputImage,  "in",   "Input Image");
     SetParameterDescription("in", "Input image.");
@@ -76,39 +107,47 @@ private:
 
     AddRAMParameter();
 
-    AddParameter(ParameterType_Choice,"filter","speckle filtering method");
+    AddParameter(ParameterType_Choice,"filter","Speckle filtering method");
+    
     AddChoice("filter.lee","Lee");
     SetParameterDescription("filter.lee","Lee filter");
+
     AddChoice("filter.frost","Frost");
     SetParameterDescription("filter.frost","Frost filter");
+
     AddChoice("filter.gammamap","GammaMap");
     SetParameterDescription("filter.gammamap","GammaMap filter");
+
     AddChoice("filter.kuan","Kuan");
     SetParameterDescription("filter.kuan","Kuan filter");
 
     AddParameter(ParameterType_Int,"filter.lee.rad","Radius");
-    SetParameterDescription("filter.lee.rad","Radius for lee filter");
+    SetParameterDescription("filter.lee.rad","Radius in pixel");
 
-    AddParameter(ParameterType_Float,"filter.lee.nblooks","nb looks");
-    SetParameterDescription("filter.lee.nblooks","Nb looks for lee filter");
+    AddParameter(ParameterType_Float,"filter.lee.nblooks","Number of looks");
+    SetParameterDescription("filter.lee.nblooks","Number of looks in the input image.");
 
     AddParameter(ParameterType_Int,"filter.frost.rad","Radius");
-    SetParameterDescription("filter.frost.rad","Radius for frost filter");
-
-    AddParameter(ParameterType_Float,"filter.frost.deramp","deramp");
-    SetParameterDescription("filter.frost.deramp","Decrease factor declaration");
+    SetParameterDescription("filter.frost.rad","Radius in pixel.");
+
+    AddParameter(ParameterType_Float,"filter.frost.deramp","Deramp factor");
+    SetParameterDescription("filter.frost.deramp","factor use to control the\n"
+       "exponential function used to weight effect of the distance between the\n"
+       "central pixel and its neighborhood. Increasing the deramp parameter will\n"
+       "lead to take more into account pixels farther from the center and\n"
+       "therefore increase the smoothing effects.");
     
     AddParameter(ParameterType_Int,"filter.gammamap.rad","Radius");
-    SetParameterDescription("filter.gammamap.rad","Radius for GammaMAP filter");
+    SetParameterDescription("filter.gammamap.rad","Radius in pixel.");
 
-    AddParameter(ParameterType_Float,"filter.gammamap.nblooks","nb looks");
-    SetParameterDescription("filter.gammamap.nblooks","Nb looks for GammaMAP filter");
+    AddParameter(ParameterType_Float,"filter.gammamap.nblooks","Number of looks");
+    SetParameterDescription("filter.gammamap.nblooks","Number of looks in the input image.");
     
     AddParameter(ParameterType_Int,"filter.kuan.rad","Radius");
-    SetParameterDescription("filter.kuan.rad","Radius for Kuan filter");
+    SetParameterDescription("filter.kuan.rad","Radius in pixel.");
 
-    AddParameter(ParameterType_Float,"filter.kuan.nblooks","nb looks");
-    SetParameterDescription("filter.kuan.nblooks","Nb looks for Kuan filter");
+    AddParameter(ParameterType_Float,"filter.kuan.nblooks","Number of looks");
+    SetParameterDescription("filter.kuan.nblooks","Number of looks in the input image.");
 
     // Default values
     SetDefaultParameterInt("filter.lee.rad", 1);
diff --git a/Modules/Applications/AppSARUtils/otb-module.cmake b/Modules/Applications/AppSARUtils/otb-module.cmake
index 41a1b43..964acb5 100644
--- a/Modules/Applications/AppSARUtils/otb-module.cmake
+++ b/Modules/Applications/AppSARUtils/otb-module.cmake
@@ -3,6 +3,10 @@ set(DOCUMENTATION "SAR Utils application.")
 otb_module(OTBAppSARUtils
   DEPENDS
     OTBApplicationEngine
+    OTBImageNoise
+    OTBImageBase
+    OTBITK
+    
   TEST_DEPENDS
     OTBTestKernel
     OTBCommandLine
diff --git a/Modules/Applications/AppSARUtils/test/CMakeLists.txt b/Modules/Applications/AppSARUtils/test/CMakeLists.txt
index 65dc6b7..4c7a02e 100644
--- a/Modules/Applications/AppSARUtils/test/CMakeLists.txt
+++ b/Modules/Applications/AppSARUtils/test/CMakeLists.txt
@@ -1,13 +1,79 @@
+#
+# 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()
 #----------- ComputeModulusAndPhase TESTS ----------------
 otb_test_application(NAME apTvUtComputeModulusAndPhase_1inputComplex
-                     APP  ComputeModulusAndPhase
-                     OPTIONS -in ${INPUTDATA}/monobandComplexFloat.tif
-                             -modulus ${TEMP}/apTvUtMod1inputComplex.tif
-                             -phase ${TEMP}/apTvUtPha1inputComplex.tif
-                     VALID   --compare-n-images ${EPSILON_6} 2
-                             ${BASELINE}/Mod_monobandComplexFloat.tif
-                             ${TEMP}/apTvUtMod1inputComplex.tif
-                             ${BASELINE}/Pha_monobandComplexFloat.tif
-                             ${TEMP}/apTvUtPha1inputComplex.tif
-                     )
+  APP  ComputeModulusAndPhase
+  OPTIONS -in ${INPUTDATA}/monobandComplexFloat.tif
+  -modulus ${TEMP}/apTvUtMod1inputComplex.tif
+  -phase ${TEMP}/apTvUtPha1inputComplex.tif
+  VALID   --compare-n-images ${EPSILON_6} 2
+  ${BASELINE}/Mod_monobandComplexFloat.tif
+  ${TEMP}/apTvUtMod1inputComplex.tif
+  ${BASELINE}/Pha_monobandComplexFloat.tif
+  ${TEMP}/apTvUtPha1inputComplex.tif
+  )
+
+#----------- Despeckle TESTS ----------------
+
+otb_test_application(NAME  apTvDespeckleLee
+  APP  Despeckle
+  OPTIONS -in ${INPUTDATA}/GomaAvant.tif
+  -out ${TEMP}/bfFiltreLee_05_05_12_app.tif
+  -filter lee
+  -filter.lee.rad 5
+  -filter.lee.nblooks 12
+  VALID   --compare-image ${EPSILON_7}
+  ${BASELINE}/bfFiltreLee_05_05_12.tif
+  ${TEMP}/bfFiltreLee_05_05_12_app.tif)
+
+otb_test_application(NAME  apTvDespeckleFrost
+  APP  Despeckle
+  OPTIONS -in ${INPUTDATA}/GomaAvant.tif
+  -out ${TEMP}/bfFiltreFrost_05_05_12_app.tif
+  -filter frost
+  -filter.frost.rad 5
+  -filter.frost.deramp 0.1
+  VALID   --compare-image ${EPSILON_7}
+  ${BASELINE}/bfFiltreFrost_05_05_12_app.tif
+  ${TEMP}/bfFiltreFrost_05_05_12_app.tif)
+
+otb_test_application(NAME  apTvDespeckleGammaMAP
+  APP  Despeckle
+  OPTIONS -in ${INPUTDATA}/GomaAvant.tif
+  -out ${TEMP}/bfFiltreGammaMAP_05_05_12_app.tif
+  -filter gammamap
+  -filter.gammamap.rad 5
+  -filter.gammamap.nblooks 12
+  VALID   --compare-image ${EPSILON_7}
+  ${BASELINE}/bfFiltreGammaMAP_05_05_12.tif
+  ${TEMP}/bfFiltreGammaMAP_05_05_12_app.tif)                      
+
+otb_test_application(NAME  apTvDespeckleKuan
+  APP  Despeckle
+  OPTIONS -in ${INPUTDATA}/GomaAvant.tif
+  -out ${TEMP}/bfFiltreKuan_05_05_12_app.tif
+  -filter kuan
+  -filter.kuan.rad 5
+  -filter.kuan.nblooks 12
+  VALID   --compare-image ${EPSILON_7}
+  ${BASELINE}/bfFiltreKuan_05_05_12.tif
+  ${TEMP}/bfFiltreKuan_05_05_12_app.tif)
diff --git a/Modules/Applications/AppSegmentation/app/CMakeLists.txt b/Modules/Applications/AppSegmentation/app/CMakeLists.txt
index 097d997..f55ae3d 100644
--- a/Modules/Applications/AppSegmentation/app/CMakeLists.txt
+++ b/Modules/Applications/AppSegmentation/app/CMakeLists.txt
@@ -75,3 +75,8 @@ otb_create_application(
   NAME           MeanShiftSmoothing
   SOURCES        otbMeanShiftSmoothing.cxx
   LINK_LIBRARIES ${${otb-module}_LIBRARIES})
+
+otb_create_application(
+  NAME           LargeScaleMeanShift
+  SOURCES        otbLargeScaleMeanShift.cxx
+  LINK_LIBRARIES ${${otb-module}_LIBRARIES})
diff --git a/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx
index dd62467..93694cc 100644
--- a/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx
+++ b/Modules/Applications/AppSegmentation/app/otbLSMSSegmentation.cxx
@@ -217,51 +217,83 @@ private:
   void DoInit() ITK_OVERRIDE
   {
     SetName("LSMSSegmentation");
-    SetDescription("Second step of the exact Large-Scale Mean-Shift segmentation workflow.");
+    SetDescription("This application performs the second step of the exact Large-Scale Mean-Shift segmentation workflow (LSMS) [1].");
 
     SetDocName("Exact Large-Scale Mean-Shift segmentation, step 2");
-    SetDocLongDescription("This application performs the second step of the exact Large-Scale Mean-Shift segmentation workflow (LSMS). Filtered range image and spatial image should be created with the MeanShiftSmoothing application, with modesearch parameter disabled. If spatial image is not set, the application will only process the range image and spatial radius parameter will not be taken into account. This application will produce a labeled image where neighbor pixels whose range dis [...]
-    SetDocLimitations("This application is part of the Large-Scale Mean-Shift segmentation workflow (LSMS) and may not be suited for any other purpose.");
+    SetDocLongDescription("This application will produce a labeled image where neighbor pixels"
+                          " whose range distance is below range radius (and optionally spatial"
+                          " distance below spatial radius) will be grouped together into the same"
+                          " cluster. For large images one can use the tilesizex and tilesizey"
+                          " parameters for tile-wise processing, with the guarantees of identical"
+                          " results.\n\n"
+                          "Filtered range image and spatial image should be created with the"
+                          " MeanShiftSmoothing application outputs (fout and foutpos) [2], with"
+                          " modesearch parameter disabled. If spatial image is not set, the"
+                          " application will only process the range image and spatial radius"
+                          " parameter will not be taken into account.\n\n"
+                          "Please note that this application will generate a lot of temporary"
+                          " files (as many as the number of tiles), and will therefore require"
+                          " twice the size of the final result in term of disk space. The cleanup"
+                          " option (activated by default) allows removing all temporary file as"
+                          " soon as they are not needed anymore (if cleanup is activated, tmpdir"
+                          " set and tmpdir does not exists before running the application, it will"
+                          " be removed as well during cleanup). The tmpdir option allows defining"
+                          " a directory where to write the temporary files.\n\n"
+                          "Please also note that the output image type should be set to uint32 to"
+                          " ensure that there are enough labels available.\n\n"
+                          "The output of this application can be passed to the"
+                          " LSMSSmallRegionMerging [3] or LSMSVectorization [4] applications to"
+                          " complete the LSMS workflow.");
+    SetDocLimitations("This application is part of the Large-Scale Mean-Shift segmentation"
+                      " workflow (LSMS) [1] and may not be suited for any other purpose. This"
+                      " application is not compatible with in-memory connection since it does"
+                      " its own internal streaming.");
     SetDocAuthors("David Youssefi");
-    SetDocSeeAlso("MeanShiftSmoothing, LSMSSmallRegionsMerging, LSMSVectorization");
+    SetDocSeeAlso( "[1] Michel, J., Youssefi, D., & Grizonnet, M. (2015). Stable"
+                   " mean-shift algorithm and its application to the segmentation of"
+                   " arbitrarily large remote sensing images. IEEE Transactions on"
+                   " Geoscience and Remote Sensing, 53(2), 952-964.\n"
+                   "[2] MeanShiftSmoothing\n"
+                   "[3] LSMSSmallRegionsMerging\n"
+                   "[4] LSMSVectorization");
     AddDocTag(Tags::Segmentation);
     AddDocTag("LSMS");
 
     AddParameter(ParameterType_InputImage,  "in",    "Filtered image");
-    SetParameterDescription( "in", "The filtered image (cf. Adaptive MeanShift Smoothing application)." );
-    AddParameter(ParameterType_InputImage,  "inpos",    "Spatial image");
-    SetParameterDescription( "inpos", " The spatial image. Spatial input is the displacement map (output of the Adaptive MeanShift Smoothing application)." );
+    SetParameterDescription( "in", "The filtered image, corresponding to the fout output parameter of the MeanShiftSmoothing application." );
+    AddParameter(ParameterType_InputImage,  "inpos",    "Filtered position image");
+    SetParameterDescription( "inpos", " The filtered position image, corresponding to the foutpos output parameter of the MeanShiftSmoothing application.");
     MandatoryOff("inpos");
 
-    AddParameter(ParameterType_OutputImage, "out", "Output Image");
-    SetParameterDescription( "out", "The output image. The output image is the segmentation of the filtered image. It is recommended to set the pixel type to uint32." );
+    AddParameter(ParameterType_OutputImage, "out", "Output labeled Image");
+    SetParameterDescription( "out", "This output contains the segmented image, where each pixel value is the unique integer label of the segment it belongs to. It is recommended to set the pixel type to uint32." );
     SetDefaultOutputPixelType("out",ImagePixelType_uint32);
 
     AddParameter(ParameterType_Float, "spatialr", "Spatial radius");
-    SetParameterDescription("spatialr", "Spatial radius of the neighborhood.");
+    SetParameterDescription("spatialr", "Threshold on Spatial distance to consider pixels in the same segment. A good value is half the spatial radius used in the MeanShiftSmoothing application (spatialr parameter).");
     SetDefaultParameterFloat("spatialr", 5);
     SetMinimumParameterFloatValue("spatialr", 0);
     MandatoryOff("spatialr");
     
     AddParameter(ParameterType_Float, "ranger", "Range radius");
-    SetParameterDescription("ranger", "Range radius defining the radius (expressed in radiometry unit) in the multi-spectral space.");
+    SetParameterDescription("ranger", "Threshold on spectral signature euclidean distance (expressed in radiometry unit) to consider pixels in the same segment. A good value is half the range radius used in the MeanShiftSmoothing application (ranger parameter).");
     SetDefaultParameterFloat("ranger", 15);
     SetMinimumParameterFloatValue("ranger", 0);
     MandatoryOff("ranger");
 
-    AddParameter(ParameterType_Int, "minsize", "Minimum Region Size");
-    SetParameterDescription("minsize", "Minimum Region Size. If, after the segmentation, a region is of size lower than this criterion, the region is deleted.");
+    AddParameter(ParameterType_Int, "minsize", "Minimum Segment Size");
+    SetParameterDescription("minsize", "Minimum Segment Size. If, after the segmentation, a segment is of size lower than this criterion, the segment is discarded.");
     SetDefaultParameterInt("minsize", 0);
     SetMinimumParameterIntValue("minsize", 0);
     MandatoryOff("minsize");
 
     AddParameter(ParameterType_Int, "tilesizex", "Size of tiles in pixel (X-axis)");
-    SetParameterDescription("tilesizex", "Size of tiles along the X-axis.");
+    SetParameterDescription("tilesizex", "Size of tiles along the X-axis for tile-wise processing.");
     SetDefaultParameterInt("tilesizex", 500);
     SetMinimumParameterIntValue("tilesizex", 1);
 
     AddParameter(ParameterType_Int, "tilesizey", "Size of tiles in pixel (Y-axis)");
-    SetParameterDescription("tilesizey", "Size of tiles along the Y-axis.");
+    SetParameterDescription("tilesizey", "Size of tiles along the Y-axis for tile-wise processing.");
     SetDefaultParameterInt("tilesizey", 500);
     SetMinimumParameterIntValue("tilesizey", 1);
 
@@ -272,7 +304,7 @@ private:
 
     AddParameter(ParameterType_Empty,"cleanup","Temporary files cleaning");
     EnableParameter("cleanup");
-    SetParameterDescription("cleanup","If activated, the application will try to clean all temporary files it created");
+    SetParameterDescription("cleanup","If activated, the application will try to remove all temporary files it created.");
     MandatoryOff("cleanup");
 
     // Doc example parameter settings
diff --git a/Modules/Applications/AppSegmentation/app/otbLSMSSmallRegionsMerging.cxx b/Modules/Applications/AppSegmentation/app/otbLSMSSmallRegionsMerging.cxx
index dc04847..14c8354 100644
--- a/Modules/Applications/AppSegmentation/app/otbLSMSSmallRegionsMerging.cxx
+++ b/Modules/Applications/AppSegmentation/app/otbLSMSSmallRegionsMerging.cxx
@@ -76,38 +76,58 @@ private:
   void DoInit() ITK_OVERRIDE
   {
     SetName("LSMSSmallRegionsMerging");
-    SetDescription("Third (optional) step of the exact Large-Scale Mean-Shift segmentation workflow.");
+    SetDescription("This application performs the third (optional) step of the exact Large-Scale Mean-Shift segmentation workflow [1].");
 
     SetDocName("Exact Large-Scale Mean-Shift segmentation, step 3 (optional)");
-    SetDocLongDescription("This application performs the third step of the exact Large-Scale Mean-Shift segmentation workflow (LSMS). Given a segmentation result (label image) and the original image, it will merge regions whose size in pixels is lower than minsize parameter with the adjacent regions with the adjacent region with closest radiometry and acceptable size. Small regions will be processed by size: first all regions of area, which is equal to 1 pixel will be merged with adjacen [...]
-    SetDocLimitations("This application is part of the Large-Scale Mean-Shift segmentation workflow (LSMS) and may not be suited for any other purpose.");
+    SetDocLongDescription("Given a segmentation result (can be the out output parameter of the"
+                          " LSMSSegmentation application [2]) and the original image, it will"
+                          " merge segments whose size in pixels is lower than minsize parameter"
+                          " with the adjacent segments with the adjacent segment with closest"
+                          " radiometry and acceptable size.\n\n"
+                          "Small segments will be processed by increasing size: first all segments"
+                          " for which area is equal to 1 pixel will be merged with adjacent"
+                          " segments, then all segments of area equal to 2 pixels will be processed,"
+                          " until segments of area minsize. For large images one can use the"
+                          " tilesizex and tilesizey parameters for tile-wise processing, with the"
+                          " guarantees of identical results.\n\n"
+                          "The output of this application can be passed to the"
+                          " LSMSVectorization application [3] to complete the LSMS workflow.");
+    SetDocLimitations("This application is part of the Large-Scale Mean-Shift segmentation"
+                      " workflow (LSMS) and may not be suited for any other purpose. This"
+                      " application is not compatible with in-memory connection since it does"
+                      " its own internal streaming.");
     SetDocAuthors("David Youssefi");
-    SetDocSeeAlso("LSMSSegmentation, LSMSVectorization, MeanShiftSmoothing");
+    SetDocSeeAlso( "[1] Michel, J., Youssefi, D., & Grizonnet, M. (2015). Stable"
+                   " mean-shift algorithm and its application to the segmentation of"
+                   " arbitrarily large remote sensing images. IEEE Transactions on"
+                   " Geoscience and Remote Sensing, 53(2), 952-964.\n"
+                   "[2] LSMSegmentation\n"
+                   "[3] LSMSVectorization");
     AddDocTag(Tags::Segmentation);
     AddDocTag("LSMS");
 
     AddParameter(ParameterType_InputImage,  "in",    "Input image");
-    SetParameterDescription( "in", "The input image." );
+    SetParameterDescription( "in", "The input image, containing initial spectral signatures corresponding to the segmented image (inseg)." );
     AddParameter(ParameterType_InputImage,  "inseg",    "Segmented image");
-    SetParameterDescription( "inseg", " The segmented image input. Segmented image input is the segmentation of the input image." );
+    SetParameterDescription( "inseg", "Segmented image where each pixel value is the unique integer label of the segment it belongs to." );
 
     AddParameter(ParameterType_OutputImage, "out", "Output Image");
-    SetParameterDescription( "out", "The output image. The output image is the input image where the minimal regions have been merged." );
+    SetParameterDescription( "out", "The output image. The output image is the segmented image where the minimal segments have been merged. An ecoding of uint32 is advised." );
     SetDefaultOutputPixelType("out",ImagePixelType_uint32);
 
-    AddParameter(ParameterType_Int, "minsize", "Minimum Region Size");
-    SetParameterDescription("minsize", "Minimum Region Size. If, after the segmentation, a region is of size lower than this criterion, the region is merged with the \"nearest\" region (radiometrically).");
+    AddParameter(ParameterType_Int, "minsize", "Minimum Segment Size");
+    SetParameterDescription("minsize", "Minimum Segment Size. If, after the segmentation, a segment is of size lower than this criterion, the segment is merged with the segment that has the closest sepctral signature.");
     SetDefaultParameterInt("minsize", 50);
     SetMinimumParameterIntValue("minsize", 0);
     MandatoryOff("minsize");
 
     AddParameter(ParameterType_Int, "tilesizex", "Size of tiles in pixel (X-axis)");
-    SetParameterDescription("tilesizex", "Size of tiles along the X-axis.");
+    SetParameterDescription("tilesizex", "Size of tiles along the X-axis for tile-wise processing.");
     SetDefaultParameterInt("tilesizex", 500);
     SetMinimumParameterIntValue("tilesizex", 1);
 
     AddParameter(ParameterType_Int, "tilesizey", "Size of tiles in pixel (Y-axis)");
-    SetParameterDescription("tilesizey", "Size of tiles along the Y-axis.");
+    SetParameterDescription("tilesizey", "Size of tiles along the Y-axis for tile-wise processing.");
     SetDefaultParameterInt("tilesizey", 500);
     SetMinimumParameterIntValue("tilesizey", 1);
 
diff --git a/Modules/Applications/AppSegmentation/app/otbLSMSVectorization.cxx b/Modules/Applications/AppSegmentation/app/otbLSMSVectorization.cxx
index aa3ea2a..166b871 100644
--- a/Modules/Applications/AppSegmentation/app/otbLSMSVectorization.cxx
+++ b/Modules/Applications/AppSegmentation/app/otbLSMSVectorization.cxx
@@ -69,31 +69,46 @@ private:
   void DoInit() ITK_OVERRIDE
   {
     SetName("LSMSVectorization");
-    SetDescription("Fourth step of the exact Large-Scale Mean-Shift segmentation workflow.");
+    SetDescription("This application performs the fourth step of the exact Large-Scale Mean-Shift segmentation workflow [1].");
 
     SetDocName("Exact Large-Scale Mean-Shift segmentation, step 4");
-    SetDocLongDescription("This application performs the fourth step of the exact Large-Scale Mean-Shift segmentation workflow (LSMS). Given a segmentation result (label image), that may have been processed for small regions merging or not, it will convert it to a GIS vector file containing one polygon per segment. Each polygon contains additional fields: mean and variance of each channels from input image (in parameter), segmentation image label, number of pixels in the polygon. For lar [...]
+    SetDocLongDescription("Given a segmentation result (label image), that may come from the"
+                          " LSMSSegmentation [2] application (out parameter) or have been"
+                          " processed for small regions merging [3] (out parameter), it will"
+                          " convert it to a GIS vector file containing one polygon per"
+                          " segment. Each polygon contains additional fields: mean and variance of"
+                          " each channels from input image (in parameter), segmentation image"
+                          " label, number of pixels in the polygon. For large images one can use"
+                          " the tilesizex and tilesizey parameters for tile-wise processing, with"
+                          " the guarantees of identical results.");
     SetDocLimitations("This application is part of the Large-Scale Mean-Shift segmentation workflow (LSMS) and may not be suited for any other purpose.");
     SetDocAuthors("David Youssefi");
-    SetDocSeeAlso("MeanShiftSmoothing, LSMSSegmentation, LSMSSmallRegionsMerging");
+
+    SetDocSeeAlso( "[1] Michel, J., Youssefi, D., & Grizonnet, M. (2015). Stable"
+                   " mean-shift algorithm and its application to the segmentation of"
+                   " arbitrarily large remote sensing images. IEEE Transactions on"
+                   " Geoscience and Remote Sensing, 53(2), 952-964.\n"
+                   "[2] LSMSegmentation\n"
+                   "[3] LSMSmallRegionMerging");
+
     AddDocTag(Tags::Segmentation);
     AddDocTag("LSMS");
 
     AddParameter(ParameterType_InputImage, "in", "Input Image");
-    SetParameterDescription( "in", "The input image." );
+    SetParameterDescription( "in", "The input image, containing initial spectral signatures corresponding to the segmented image (inseg)." );
     AddParameter(ParameterType_InputImage,  "inseg",    "Segmented image");
-    SetParameterDescription( "inseg", " The segmented image input. Segmented image input is the segmentation of the input image." );
+    SetParameterDescription( "inseg", "Segmented image where each pixel value is the unique integer label of the segment it belongs to.");
 
     AddParameter(ParameterType_OutputFilename, "out", "Output GIS vector file");
     SetParameterDescription( "out", "The output GIS vector file, representing the vectorized version of the segmented image where the features of the polygons are the radiometric means and variances." );
 
     AddParameter(ParameterType_Int, "tilesizex", "Size of tiles in pixel (X-axis)");
-    SetParameterDescription("tilesizex", "Size of tiles along the X-axis.");
+    SetParameterDescription("tilesizex", "Size of tiles along the X-axis for tile-wise processing.");
     SetDefaultParameterInt("tilesizex", 500);
     SetMinimumParameterIntValue("tilesizex", 1);
 
     AddParameter(ParameterType_Int, "tilesizey", "Size of tiles in pixel (Y-axis)");
-    SetParameterDescription("tilesizey", "Size of tiles along the Y-axis.");
+    SetParameterDescription("tilesizey", "Size of tiles along the Y-axis for tile-wise processing.");
     SetDefaultParameterInt("tilesizey", 500);
     SetMinimumParameterIntValue("tilesizey", 1);
 
diff --git a/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx b/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx
new file mode 100644
index 0000000..d0dfadb
--- /dev/null
+++ b/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx
@@ -0,0 +1,233 @@
+/*
+ * 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 "otbWrapperCompositeApplication.h"
+#include "otbWrapperApplicationFactory.h"
+
+namespace otb
+{
+namespace Wrapper
+{
+
+/**
+ * \class LargeScaleMeanShift
+ *
+ * \brief All-in-one application for the LSMS framework
+ *
+ * This application gathers the 4 steps of the large-scale MeanShift
+ * segmentation framework.
+ * 
+ */
+class LargeScaleMeanShift : public CompositeApplication
+{
+public:
+  /** Standard class typedefs. */
+  typedef LargeScaleMeanShift           Self;
+  typedef CompositeApplication          Superclass;
+  typedef itk::SmartPointer<Self>       Pointer;
+  typedef itk::SmartPointer<const Self> ConstPointer;
+
+/** Standard macro */
+  itkNewMacro(Self);
+
+  itkTypeMacro(LargeScaleMeanShift, otb::CompositeApplication);
+
+private:
+  void DoInit() ITK_OVERRIDE
+    {
+    SetName("LargeScaleMeanShift");
+    SetDescription("Large-scale segmentation using MeanShift");
+
+    // Documentation
+    SetDocName("Large-Scale MeanShift");
+    SetDocLongDescription("This application chains together the 4 steps of the "
+      "MeanShit framework, that is the MeanShiftSmoothing [1], the "
+      "LSMSSegmentation [2], the LSMSSmallRegionsMerging [3] and the "
+      "LSMSVectorization [4].\n\n"
+      "This application can be a preliminary step for an object-based analysis.\n\n"
+      "It generates a vector data file containing the regions extracted with "
+      "the MeanShift algorithm. The spatial and range radius parameters allow "
+      "to adapt the sensitivity of the algorithm depending on the image dynamic "
+      "and resolution. There is a step to remove small regions whose size "
+      "(in pixels) is less than the given 'minsize' parameter. These regions "
+      "are merged to a similar neighbor region. In the output vectors, there "
+      "are additional fields to describe each region. In particular the mean "
+      "and standard deviation (for each band) is computed for each region "
+      "using the input image as support. If an optional 'imfield' image is "
+      "given, it will be used as support image instead."
+      );
+    SetDocLimitations("None");
+    SetDocAuthors("OTB-Team");
+    SetDocSeeAlso("[1] MeanShiftSmoothing\n"
+      "[2] LSMSSegmentation\n"
+      "[3] LSMSSmallRegionsMerging\n"
+      "[4] LSMSVectorization");
+
+    AddDocTag(Tags::Segmentation);
+    AddDocTag("LSMS");
+
+    ClearApplications();
+    AddApplication("MeanShiftSmoothing", "smoothing", "Smoothing step");
+    AddApplication("LSMSSegmentation", "segmentation", "Segmentation step");
+    AddApplication("LSMSSmallRegionsMerging", "merging", "Small region merging step");
+    AddApplication("LSMSVectorization", "vectorization", "Vectorization step");
+
+    ShareParameter("in","smoothing.in");
+    ShareParameter("spatialr","smoothing.spatialr");
+    ShareParameter("ranger","smoothing.ranger");
+    ShareParameter("minsize","merging.minsize");
+
+    ShareParameter("tilesizex","segmentation.tilesizex");
+    ShareParameter("tilesizey","segmentation.tilesizey");
+
+    AddParameter(ParameterType_Choice, "mode","Output mode");
+    SetParameterDescription("mode", "Type of segmented output");
+
+    AddChoice("mode.vector", "Segmentation as vector output");
+    SetParameterDescription("mode.vector","In this mode, the application will "
+      "produce a vector file or database and compute field values for each "
+      "region");
+
+    AddParameter(ParameterType_InputImage, "mode.vector.imfield", "Support image for field computation");
+    SetParameterDescription( "mode.vector.imfield", "This is an optional support image "
+      "that can be used to compute field values in each region. Otherwise, the "
+      "input image is used as support." );
+    MandatoryOff("mode.vector.imfield");
+
+    ShareParameter("mode.vector.out","vectorization.out");
+
+    AddChoice("mode.raster", "Standard segmentation with labeled raster output");
+    SetParameterDescription("mode.raster","In this mode, the application will produce a standard labeled raster.");
+
+    ShareParameter("mode.raster.out","merging.out",
+      "The output raster image",
+      "It corresponds to the output of the small region merging step.");
+
+    AddParameter( ParameterType_Empty, "cleanup", "Temporary files cleaning" );
+    EnableParameter( "cleanup" );
+    SetParameterDescription( "cleanup",
+      "If activated, the application will try to clean all temporary files it created" );
+    MandatoryOff( "cleanup" );
+
+    // Setup RAM
+    ShareParameter("ram","smoothing.ram");
+    Connect("merging.ram","smoothing.ram");
+    Connect("vectorization.ram","smoothing.ram");
+
+    Connect("merging.tilesizex","segmentation.tilesizex");
+    Connect("merging.tilesizey","segmentation.tilesizey");
+    Connect("vectorization.tilesizex","segmentation.tilesizex");
+    Connect("vectorization.tilesizey","segmentation.tilesizey");
+
+    // TODO : this is not exactly true, we used to choose the smoothed image instead
+    Connect("merging.in","smoothing.in");
+
+    // Setup constant parameters
+    GetInternalApplication("smoothing")->SetParameterString("foutpos","foo");
+    GetInternalApplication("smoothing")->EnableParameter("foutpos");
+
+    // Doc example parameter settings
+    SetDocExampleParameterValue("in", "QB_1_ortho.tif");
+    SetDocExampleParameterValue("spatialr", "4");
+    SetDocExampleParameterValue("ranger", "80");
+    SetDocExampleParameterValue("minsize", "16");
+    SetDocExampleParameterValue("mode.vector.out", "regions.shp");
+
+    SetOfficialDocLink();
+    }
+
+  void DoUpdateParameters() ITK_OVERRIDE
+  {}
+
+  void DoExecute() ITK_OVERRIDE
+    {
+    bool isVector(GetParameterString("mode") == "vector");
+    std::string outPath(isVector ?
+      GetParameterString("mode.vector.out"):
+      GetParameterString("mode.raster.out"));
+    std::vector<std::string> tmpFilenames;
+    tmpFilenames.push_back(outPath+std::string("_labelmap.tif"));
+    tmpFilenames.push_back(outPath+std::string("_labelmap.geom"));
+    ExecuteInternal("smoothing");
+    // in-memory connexion here (saves 1 additional update for foutpos)
+    GetInternalApplication("segmentation")->SetParameterInputImage("in",
+      GetInternalApplication("smoothing")->GetParameterOutputImage("fout"));
+    GetInternalApplication("segmentation")->SetParameterInputImage("inpos",
+      GetInternalApplication("smoothing")->GetParameterOutputImage("foutpos"));
+    // temporary file output here
+    GetInternalApplication("segmentation")->SetParameterString("out",
+      tmpFilenames[0]);
+    // take half of previous radii
+    GetInternalApplication("segmentation")->SetParameterFloat("spatialr",
+      0.5 * (double)GetInternalApplication("smoothing")->GetParameterInt("spatialr"));
+    GetInternalApplication("segmentation")->SetParameterFloat("ranger",
+      0.5 * GetInternalApplication("smoothing")->GetParameterFloat("ranger"));
+    GetInternalApplication("segmentation")->ExecuteAndWriteOutput();
+
+    GetInternalApplication("merging")->SetParameterString("inseg",
+      tmpFilenames[0]);
+    EnableParameter("mode.raster.out");
+    if (isVector)
+      {
+      tmpFilenames.push_back(outPath+std::string("_labelmap_merged.tif"));
+      tmpFilenames.push_back(outPath+std::string("_labelmap_merged.geom"));
+      GetInternalApplication("merging")->SetParameterString("out",
+        tmpFilenames[2]);
+      GetInternalApplication("merging")->ExecuteAndWriteOutput();
+      if (IsParameterEnabled("mode.vector.imfield") &&
+          HasValue("mode.vector.imfield"))
+        {
+        GetInternalApplication("vectorization")->SetParameterString("in",
+          GetParameterString("mode.vector.imfield"));
+        }
+      else
+        {
+        GetInternalApplication("vectorization")->SetParameterString("in",
+          GetParameterString("in"));
+        }
+      GetInternalApplication("vectorization")->SetParameterString("inseg",
+        tmpFilenames[2]);
+      ExecuteInternal("vectorization");
+      }
+    else
+      {
+      GetInternalApplication("merging")->ExecuteAndWriteOutput();
+      }
+    DisableParameter("mode.raster.out");
+
+    if( IsParameterEnabled( "cleanup" ) )
+      {
+      otbAppLogINFO( <<"Final clean-up ..." );
+      for (unsigned int i=0 ; i<tmpFilenames.size() ; ++i)
+        {
+        if(itksys::SystemTools::FileExists(tmpFilenames[i].c_str()))
+          {
+          itksys::SystemTools::RemoveFile(tmpFilenames[i].c_str());
+          }
+        }
+      }
+    }
+
+};
+
+} // end of namespace Wrapper
+} // end of namespace otb
+
+OTB_APPLICATION_EXPORT(otb::Wrapper::LargeScaleMeanShift)
diff --git a/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx b/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx
index 6f34edd..8f63bf1 100644
--- a/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx
+++ b/Modules/Applications/AppSegmentation/app/otbMeanShiftSmoothing.cxx
@@ -49,61 +49,118 @@ private:
   void DoInit() ITK_OVERRIDE
   {
     SetName("MeanShiftSmoothing");
-    SetDescription("Perform mean shift filtering");
+    SetDescription("This application smooths an image using the MeanShift algorithm.");
 
     // Documentation
-    SetDocName("Exact Large-Scale Mean-Shift segmentation, step 1 (smoothing)");
-    SetDocLongDescription("This application performs mean shift fitlering (multi-threaded).");
-    SetDocLimitations("With mode search option, the result will slightly depend on thread number.");
+    SetDocName("MeanShift Smoothing");
+    SetDocLongDescription("MeanShift [1,2,3] is an iterative edge-preserving image smoothing"
+                          " algorithm often used in image processing and as a first step for"
+                          " image segmentation. The MeanShift algorithm can be applied to"
+                          " multispectral images.\n\n"
+                          "At first iteration, for any given pixel of the input image, the"
+                          " filtered value correspond to the average spectral signature of"
+                          " neighborhood pixels that are both spatially closer than the spatial"
+                          " radius parameter (spatialr) and with spectral signature that have an euclidean"
+                          " distance to the input pixel lower than the range radius (ranger), that is,"
+                          " pixels that are both close in space and in spectral signatures."
+                          " Subsequent iterations will repeat this process by considering that"
+                          " the pixel signature corresponds to the average spectral signature"
+                          " computed during previous iteration, and that the pixel position"
+                          " corresponds to the average position of pixels used to compute the"
+                          " average signature."
+                          "The algorithm stops when the maximum number of iterations (maxiter) is reached,"
+                          " or when the position and spectral signature does not change much"
+                          " between iterations, according to the convergence threshold (thres). If the"
+                          " modesearch option is used then convergence will also stops if the"
+                          " spatial position reaches a pixel that has already converged. This"
+                          " will speed-up convergence, at the expense of stability of the result.\n\n"
+
+                          "The application outputs the image of the final averaged spectral"
+                          " signatures (fout), and can also optionally output the 2D"
+                          " displacement field between input pixel position and final pixel"
+                          " position after convergence (foutpos).\n\n"
+
+                          "Note that computing an euclidean distance between spectral signatures"
+                          " may be inaccurate and that techniques such as color space transform or image"
+                          " normalisation could be applied before using this application. Also"
+                          " note that most satellite images noise model is not gaussian, since"
+                          " noise variance linearly depends on radiance (the higher the"
+                          " radiance, the higher the noise variance). To account for such noise"
+                          " model, the application provides the range radius ramp option"
+                          " (rangeramp), which will vary the range radius linearly with the"
+                          " central pixel intensity. Default value is 1. (no ramp).\n\n"
+
+                          "This application is the first step of the large scale MeanShift method"
+                          " depicted in [4]. Both outputs (fout and foutpos) can be passed to the"
+                          " large scale MeanShift segmentation application [5]. If the"
+                          " application is used for large scale MeanShift, modesearch option should be off.");
+
+    SetDocLimitations("When modesearch is on, the application will yield slightly different"
+                      " results between executions, due to multi-threading. Results will also"
+                      " not be stable [4].");
+    
     SetDocAuthors("OTB-Team");
-    SetDocSeeAlso(" ");
+    SetDocSeeAlso("[1] Comaniciu, D., & Meer, P. (2002). Mean shift: A robust approach"
+                  " toward feature space analysis. IEEE Transactions on pattern analysis"
+                  " and machine intelligence, 24(5), 603-619.\n"
+                  "[2] Comaniciu, D., & Meer, P. (1997, June). Robust analysis of feature"
+                  " spaces: color image segmentation. In Computer Vision and Pattern"
+                  " Recognition, 1997. Proceedings., 1997 IEEE Computer Society Conference"
+                  " on (pp. 750-755). IEEE.\n"
+                  "[3] Comaniciu, D., & Meer, P. (1999). Mean shift analysis and"
+                  " applications. In Computer Vision, 1999. The Proceedings of the Seventh"
+                  " IEEE International Conference on (Vol. 2, pp. 1197-1203). IEEE.\n"
+                  "[4] Michel, J., Youssefi, D., & Grizonnet, M. (2015). Stable"
+                  " mean-shift algorithm and its application to the segmentation of"
+                  " arbitrarily large remote sensing images. IEEE Transactions on"
+                  " Geoscience and Remote Sensing, 53(2), 952-964.\n"
+                  "[5] LSMSSegmentation application");
 
     AddDocTag(Tags::Filter);
     AddDocTag("LSMS");
 
     AddParameter(ParameterType_InputImage,   "in",     "Input Image");
-    SetParameterDescription( "in", "The input image." );
+    SetParameterDescription( "in", "The input image can be any single or multiband image. Beware of pontential imbalance between bands ranges as it may alter euclidean distance." );
 
-    AddParameter(ParameterType_OutputImage,  "fout",    "Filtered output");
-    SetParameterDescription( "fout", "The filtered output image." );
+    AddParameter(ParameterType_OutputImage,  "fout",    "Spectral filtered output");
+    SetParameterDescription( "fout", "This output image contains the final average spectral signatures of each pixel. The output type should be at least as wide as the input image type. Floating point encoding is advised. This output can be used as input image (in) of the LSMSSegmentation application [4,5]."  );
 
-    AddParameter(ParameterType_OutputImage,  "foutpos",    "Spatial image");
-    SetParameterDescription( "foutpos", " The spatial image output. Spatial image output is a displacement map (pixel position after convergence).");
+    AddParameter(ParameterType_OutputImage,  "foutpos",    "Spatial filtered displacement output");
+    SetParameterDescription( "foutpos", " This output image contains the 2D displacement between the input pixel spatial position and the final position after convergence. Floating point encoding is mandatory. This output can be used as input image (in) of the LSMSSegmentation application [4,5].");
     MandatoryOff("foutpos");
 
     AddRAMParameter();
 
     AddParameter(ParameterType_Int, "spatialr", "Spatial radius");
-    SetParameterDescription("spatialr", "Spatial radius of the neighborhood.");
+    SetParameterDescription("spatialr", "Radius of the spatial neighborhood for averaging. Higher values will result in more smoothing and higher processing time.");
     SetDefaultParameterInt("spatialr", 5);
     MandatoryOff("spatialr");
 
     AddParameter(ParameterType_Float, "ranger", "Range radius");
-    SetParameterDescription("ranger", "Range radius defining the radius (expressed in radiometry unit) in the multi-spectral space.");
+    SetParameterDescription("ranger", "Threshold on spectral signature euclidean distance (expressed in radiometry unit) to consider neighborhood pixel for averaging. Higher values will be less edge-preserving (more similar to simple average in neighborhood), whereas lower values will result in less noise smoothing. Note that this parameter has no effect on processing time.");
     SetDefaultParameterFloat("ranger", 15.0);
     MandatoryOff("ranger");
 
     AddParameter(ParameterType_Float, "thres", "Mode convergence threshold");
-    SetParameterDescription("thres", "Algorithm iterative scheme will stop if mean-shift "
-                               "vector is below this threshold or if iteration number reached maximum number of iterations.");
+    SetParameterDescription("thres", "Algorithm will stop if update of average spectral signature and spatial position is below this threshold.");
     SetMinimumParameterFloatValue("thres", 0.0);
     SetDefaultParameterFloat("thres", 0.1);
     MandatoryOff("thres");
 
     AddParameter(ParameterType_Int, "maxiter", "Maximum number of iterations");
-    SetParameterDescription("maxiter", "Algorithm iterative scheme will stop if convergence hasn't been reached after the maximum number of iterations.");
+    SetParameterDescription("maxiter", "Algorithm will stop if convergence threshold is not met after the maximum number of iterations.");
     SetDefaultParameterInt("maxiter", 100);
     SetMinimumParameterIntValue("maxiter", 1);
     MandatoryOff("maxiter");
 
-    AddParameter(ParameterType_Float, "rangeramp", "Range radius coefficient");
-    SetParameterDescription("rangeramp", "This coefficient makes dependent the ranger of the colorimetry of the filtered pixel : y = rangeramp*x+ranger.");
+    AddParameter(ParameterType_Float, "rangeramp", "Range radius ramp coefficient");
+    SetParameterDescription("rangeramp", "Vary the range radius linearly with the central pixel intensity (experimental).");
     SetDefaultParameterFloat("rangeramp", 0.);
     SetMinimumParameterFloatValue("rangeramp", 0);
     MandatoryOff("rangeramp");
 
     AddParameter(ParameterType_Empty, "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");
+    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");
 
 
diff --git a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx
index c8c975c..5b3bfd2 100644
--- a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx
+++ b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx
@@ -39,6 +39,7 @@
 #include "otbOGRLayerStreamStitchingFilter.h"
 
 #include "otbGeoInformationConversion.h"
+#include "otbClampImageFilter.h"
 
 //Utils
 #include "itksys/SystemTools.hxx"
@@ -129,6 +130,8 @@ public:
   <FloatImageType,
    WatershedSegmentationFilterType>      StreamingVectorizedWatershedFilterType;
 
+  typedef otb::ClampImageFilter<FloatImageType, UInt32ImageType> ClampFilterType;
+
   /** Standard macro */
   itkNewMacro(Self);
   itkTypeMacro(Segmentation, otb::Application);
@@ -352,8 +355,12 @@ private:
 
   template<class TInputImage, class TSegmentationFilter>
   FloatVectorImageType::SizeType
-  GenericApplySegmentation(otb::StreamingImageToOGRLayerSegmentationFilter<TInputImage,
-                           TSegmentationFilter> * streamingVectorizedFilter, TInputImage * inputImage, const otb::ogr::Layer& layer, const unsigned int outputNb)
+  GenericApplySegmentation(
+    otb::StreamingImageToOGRLayerSegmentationFilter<
+      TInputImage,TSegmentationFilter> * streamingVectorizedFilter,
+    TInputImage * inputImage,
+    const otb::ogr::Layer& layer,
+    const unsigned int outputNb)
   {
     // Retrieve tile size parameter
     const unsigned int tileSize = static_cast<unsigned int> (this->GetParameterInt("mode.vector.tilesize"));
@@ -369,7 +376,7 @@ private:
 
     if (segModeType == "vector" && HasValue("mode.vector.inmask"))
       {
-      streamingVectorizedFilter->SetInputMask(this->GetParameterUInt32Image("mode.vector.inmask"));
+      streamingVectorizedFilter->SetInputMask(m_ClampFilter->GetOutput());
       otbAppLogINFO(<<"Use a mask as input." << std::endl);
       }
     streamingVectorizedFilter->SetOGRLayer(layer);
@@ -422,7 +429,9 @@ private:
       DisableParameter("mode.raster.out");
       EnableParameter("mode.vector.out");
 
-      AddProcess(streamingVectorizedFilter->GetStreamer(), "Computing " + (dynamic_cast <ChoiceParameter *> (this->GetParameterByKey("filter")))->GetChoiceKey(GetParameterInt("filter")) + " segmentation");
+      AddProcess(streamingVectorizedFilter->GetStreamer(), "Computing "
+        + this->GetParameterString("filter")
+        + " segmentation");
 
       streamingVectorizedFilter->Initialize(); //must be called !
       streamingVectorizedFilter->Update(); //must be called !
@@ -435,7 +444,9 @@ private:
       EnableParameter("mode.raster.out");
 
       streamingVectorizedFilter->GetSegmentationFilter()->SetInput(inputImage);
-      SetParameterOutputImage<UInt32ImageType> ("mode.raster.out", dynamic_cast<UInt32ImageType *> (streamingVectorizedFilter->GetSegmentationFilter()->GetOutputs().at(outputNb).GetPointer()));
+      SetParameterOutputImage<UInt32ImageType> ("mode.raster.out",
+        dynamic_cast<UInt32ImageType*>(
+          streamingVectorizedFilter->GetSegmentationFilter()->GetOutputs().at(outputNb).GetPointer()));
       //TODO add progress reporting in raster mode
       // AddProcess(dynamic_cast <OutputImageParameter *> (GetParameterByKey("mode.raster.out"))->GetWriter(),
       //            "Computing " + (dynamic_cast <ChoiceParameter *>
@@ -468,7 +479,6 @@ private:
       //projection ref conversion to ESRI need to be tested in case of .shp
       if ((dataSourceName.find(".shp") != std::string::npos) && (!projRef.empty()))
         {
-
         if (!(otb::GeoInformationConversion::IsESRIValidWKT(projRef)))
           {
           otbAppLogFATAL(<<"Image projection reference "<<std::endl<< projRef);
@@ -494,57 +504,59 @@ private:
         OGRFieldDefn field(this->GetParameterString("mode.vector.fieldname").c_str(), OFTInteger);
         layer.CreateField(field, true);
         }
-      else
-        if (outmode == "ulovw")
+      else if (outmode == "ulovw")
+        {
+        // Create the datasource
+        ogrDS = otb::ogr::DataSource::New(dataSourceName, otb::ogr::DataSource::Modes::Update_LayerOverwrite);
+
+        // and create the layer since we are in overwrite mode, the
+        // datasource is blank
+        layer = ogrDS->CreateLayer(GetParameterString("mode.vector.layername"), &oSRS, wkbMultiPolygon, options);
+        // And create the field
+        OGRFieldDefn field(this->GetParameterString("mode.vector.fieldname").c_str(), OFTInteger);
+        layer.CreateField(field, true);
+        }
+      else if (outmode == "ulu")
+        {
+        // Create the datasource
+        ogrDS = otb::ogr::DataSource::New(dataSourceName, otb::ogr::DataSource::Modes::Update_LayerUpdate);
+        // and create the layer since we are in overwrite mode, the
+        // datasource is blank
+        layer = ogrDS->CreateLayer(GetParameterString("mode.vector.layername"), &oSRS, wkbMultiPolygon, options);
+
+        // And create the field if necessary
+        std::string fieldName = this->GetParameterString("mode.vector.fieldname");
+        OGRFeatureDefn & ogrFeatureDfn = layer.GetLayerDefn();
+
+        if (-1 == ogrFeatureDfn.GetFieldIndex(fieldName.c_str()))
           {
-          // Create the datasource
-          ogrDS = otb::ogr::DataSource::New(dataSourceName, otb::ogr::DataSource::Modes::Update_LayerOverwrite);
-
-          // and create the layer since we are in overwrite mode, the
-          // datasource is blank
-          layer = ogrDS->CreateLayer(GetParameterString("mode.vector.layername"), &oSRS, wkbMultiPolygon, options);
-          // And create the field
-          OGRFieldDefn field(this->GetParameterString("mode.vector.fieldname").c_str(), OFTInteger);
+          OGRFieldDefn field(fieldName.c_str(), OFTInteger);
           layer.CreateField(field, true);
-
           }
-        else
-          if (outmode == "ulu")
-            {
-            // Create the datasource
-            ogrDS = otb::ogr::DataSource::New(dataSourceName, otb::ogr::DataSource::Modes::Update_LayerUpdate);
-            // and create the layer since we are in overwrite mode, the
-            // datasource is blank
-            layer = ogrDS->CreateLayer(GetParameterString("mode.vector.layername"), &oSRS, wkbMultiPolygon, options);
-
-            // And create the field if necessary
-            std::string fieldName = this->GetParameterString("mode.vector.fieldname");
-            OGRFeatureDefn & ogrFeatureDfn = layer.GetLayerDefn();
-
-            if (-1 == ogrFeatureDfn.GetFieldIndex(fieldName.c_str()))
-              {
-              OGRFieldDefn field(fieldName.c_str(), OFTInteger);
-              layer.CreateField(field, true);
-              }
-
-            }
-          else
-            if (outmode == "ulco")
-              {
-              // Create the datasource
-              ogrDS = otb::ogr::DataSource::New(dataSourceName, otb::ogr::DataSource::Modes::Update_LayerCreateOnly);
-
-              // and create the layer since we are in overwrite mode, the
-              // datasource is blank
-              layer = ogrDS->CreateLayer(GetParameterString("mode.vector.layername"), &oSRS, wkbMultiPolygon, options);
-              // And create the field
-              OGRFieldDefn field(this->GetParameterString("mode.vector.fieldname").c_str(), OFTInteger);
-              layer.CreateField(field, true);
-              }
-            else
-              {
-              otbAppLogFATAL(<<"outmode not handled yet: "<< outmode);
-              }
+        }
+      else if (outmode == "ulco")
+        {
+        // Create the datasource
+        ogrDS = otb::ogr::DataSource::New(dataSourceName, otb::ogr::DataSource::Modes::Update_LayerCreateOnly);
+
+        // and create the layer since we are in overwrite mode, the
+        // datasource is blank
+        layer = ogrDS->CreateLayer(GetParameterString("mode.vector.layername"), &oSRS, wkbMultiPolygon, options);
+        // And create the field
+        OGRFieldDefn field(this->GetParameterString("mode.vector.fieldname").c_str(), OFTInteger);
+        layer.CreateField(field, true);
+        }
+      else
+        {
+        otbAppLogFATAL(<<"outmode not handled yet: "<< outmode);
+        }
+      }
+
+    // handle mask
+    if (HasValue("mode.vector.inmask"))
+      {
+      m_ClampFilter = ClampFilterType::New();
+      m_ClampFilter->SetInput( this->GetParameterFloatImage("mode.vector.inmask"));
       }
 
     // The actual stream size used
@@ -554,108 +566,105 @@ private:
       {
       otbAppLogINFO(<<"Use connected component segmentation."<<std::endl);
       ConnectedComponentStreamingVectorizedSegmentationOGRType::Pointer
-          ccVectorizationFilter = ConnectedComponentStreamingVectorizedSegmentationOGRType::New();
+        ccVectorizationFilter = ConnectedComponentStreamingVectorizedSegmentationOGRType::New();
 
       if (HasValue("mode.vector.inmask"))
         {
         ccVectorizationFilter->GetSegmentationFilter()->SetMaskImage(
-                                                                     this->GetParameterUInt32Image("mode.vector.inmask"));
+          m_ClampFilter->GetOutput());
         }
 
       ccVectorizationFilter->GetSegmentationFilter()->GetFunctor().SetExpression(GetParameterString("filter.cc.expr"));
-      streamSize = GenericApplySegmentation<FloatVectorImageType, ConnectedComponentSegmentationFilterType> (
-                                                                                                             ccVectorizationFilter,
-                                                                                                             this->GetParameterFloatVectorImage(
-                                                                                                                                                "in"),
-                                                                                                             layer, 0);
+      streamSize = GenericApplySegmentation<FloatVectorImageType,ConnectedComponentSegmentationFilterType>(
+        ccVectorizationFilter,
+        this->GetParameterFloatVectorImage("in"),
+        layer,
+        0);
       }
-      else
-        if (segType == "meanshift")
-          {
-          otbAppLogINFO(<<"Use threaded Mean-shift segmentation."<<std::endl);
-
-          MeanShiftVectorizedSegmentationOGRType::Pointer
-              meanShiftVectorizationFilter = MeanShiftVectorizedSegmentationOGRType::New();
-
-          //segmentation parameters
-          const unsigned int
-              spatialRadius = static_cast<unsigned int> (this->GetParameterInt("filter.meanshift.spatialr"));
-          const float rangeRadius = static_cast<float> (this->GetParameterFloat("filter.meanshift.ranger"));
-          const unsigned int
-              minimumObjectSize = static_cast<unsigned int> (this->GetParameterInt("filter.meanshift.minsize"));
-
-          const float threshold = this->GetParameterFloat("filter.meanshift.thres");
-          const unsigned int
-              maxIterNumber = static_cast<unsigned int> (this->GetParameterInt("filter.meanshift.maxiter"));
-
-          meanShiftVectorizationFilter->GetSegmentationFilter()->SetSpatialBandwidth(spatialRadius);
-          meanShiftVectorizationFilter->GetSegmentationFilter()->SetRangeBandwidth(rangeRadius);
-          meanShiftVectorizationFilter->GetSegmentationFilter()->SetMaxIterationNumber(maxIterNumber);
-          meanShiftVectorizationFilter->GetSegmentationFilter()->SetThreshold(threshold);
-          meanShiftVectorizationFilter->GetSegmentationFilter()->SetMinRegionSize(minimumObjectSize);
-
-          streamSize = this->GenericApplySegmentation<FloatVectorImageType, MeanShiftSegmentationFilterType> (
-                                                                                                              meanShiftVectorizationFilter,
-                                                                                                              this->GetParameterFloatVectorImage(
-                                                                                                                                                 "in"),
-                                                                                                              layer, 0);
-          }
-        else
-          if (segType == "watershed")
-            {
-            otbAppLogINFO(<<"Using watershed segmentation."<<std::endl);
-
-            AmplitudeFilterType::Pointer amplitudeFilter = AmplitudeFilterType::New();
-
-            amplitudeFilter->SetInput(this->GetParameterFloatVectorImage("in"));
+    else if (segType == "meanshift")
+      {
+      otbAppLogINFO(<<"Use threaded Mean-shift segmentation."<<std::endl);
+
+      MeanShiftVectorizedSegmentationOGRType::Pointer
+          meanShiftVectorizationFilter = MeanShiftVectorizedSegmentationOGRType::New();
+
+      //segmentation parameters
+      const unsigned int
+          spatialRadius = static_cast<unsigned int> (this->GetParameterInt("filter.meanshift.spatialr"));
+      const float rangeRadius = static_cast<float> (this->GetParameterFloat("filter.meanshift.ranger"));
+      const unsigned int
+          minimumObjectSize = static_cast<unsigned int> (this->GetParameterInt("filter.meanshift.minsize"));
+
+      const float threshold = this->GetParameterFloat("filter.meanshift.thres");
+      const unsigned int
+          maxIterNumber = static_cast<unsigned int> (this->GetParameterInt("filter.meanshift.maxiter"));
+
+      meanShiftVectorizationFilter->GetSegmentationFilter()->SetSpatialBandwidth(spatialRadius);
+      meanShiftVectorizationFilter->GetSegmentationFilter()->SetRangeBandwidth(rangeRadius);
+      meanShiftVectorizationFilter->GetSegmentationFilter()->SetMaxIterationNumber(maxIterNumber);
+      meanShiftVectorizationFilter->GetSegmentationFilter()->SetThreshold(threshold);
+      meanShiftVectorizationFilter->GetSegmentationFilter()->SetMinRegionSize(minimumObjectSize);
+
+      streamSize = this->GenericApplySegmentation<FloatVectorImageType,MeanShiftSegmentationFilterType>(
+        meanShiftVectorizationFilter,
+        this->GetParameterFloatVectorImage("in"),
+        layer,
+        0);
+      }
+    else if (segType == "watershed")
+      {
+      otbAppLogINFO(<<"Using watershed segmentation."<<std::endl);
 
-            GradientMagnitudeFilterType::Pointer gradientMagnitudeFilter = GradientMagnitudeFilterType::New();
-            gradientMagnitudeFilter->SetInput(amplitudeFilter->GetOutput());
+      AmplitudeFilterType::Pointer amplitudeFilter = AmplitudeFilterType::New();
 
-            StreamingVectorizedWatershedFilterType::Pointer
-                watershedVectorizedFilter = StreamingVectorizedWatershedFilterType::New();
+      amplitudeFilter->SetInput(this->GetParameterFloatVectorImage("in"));
 
-            watershedVectorizedFilter->GetSegmentationFilter()->SetThreshold(
-                                                                             GetParameterFloat(
-                                                                                               "filter.watershed.threshold"));
-            watershedVectorizedFilter->GetSegmentationFilter()->SetLevel(GetParameterFloat("filter.watershed.level"));
+      GradientMagnitudeFilterType::Pointer gradientMagnitudeFilter = GradientMagnitudeFilterType::New();
+      gradientMagnitudeFilter->SetInput(amplitudeFilter->GetOutput());
 
-            streamSize = this->GenericApplySegmentation<FloatImageType, WatershedSegmentationFilterType> (
-                                                                                                          watershedVectorizedFilter,
-                                                                                                          gradientMagnitudeFilter->GetOutput(),
-                                                                                                          layer, 0);
-            }
+      StreamingVectorizedWatershedFilterType::Pointer
+          watershedVectorizedFilter = StreamingVectorizedWatershedFilterType::New();
 
-        else
-          if (segType == "mprofiles")
-            {
-            otbAppLogINFO(<<"Using multiscale geodesic morphology segmentation."<<std::endl);
+      watershedVectorizedFilter->GetSegmentationFilter()->SetThreshold(
+        GetParameterFloat("filter.watershed.threshold"));
+      watershedVectorizedFilter->GetSegmentationFilter()->SetLevel(GetParameterFloat("filter.watershed.level"));
 
-            unsigned int profileSize = GetParameterInt("filter.mprofiles.size");
-            unsigned int initialValue = GetParameterInt("filter.mprofiles.start");
-            unsigned int step = GetParameterInt("filter.mprofiles.step");
-            double       sigma = GetParameterFloat("filter.mprofiles.sigma");
+      streamSize = this->GenericApplySegmentation<FloatImageType,WatershedSegmentationFilterType>(
+        watershedVectorizedFilter,
+        gradientMagnitudeFilter->GetOutput(),
+        layer,
+        0);
+      }
+    else if (segType == "mprofiles")
+      {
+      otbAppLogINFO(<<"Using multiscale geodesic morphology segmentation."<<std::endl);
 
+      unsigned int profileSize = GetParameterInt("filter.mprofiles.size");
+      unsigned int initialValue = GetParameterInt("filter.mprofiles.start");
+      unsigned int step = GetParameterInt("filter.mprofiles.step");
+      double       sigma = GetParameterFloat("filter.mprofiles.sigma");
 
-            AmplitudeFilterType::Pointer amplitudeFilter = AmplitudeFilterType::New();
 
-            amplitudeFilter->SetInput(this->GetParameterFloatVectorImage("in"));
+      AmplitudeFilterType::Pointer amplitudeFilter = AmplitudeFilterType::New();
 
-            MorphoVectorizedSegmentationOGRType::Pointer morphoVectorizedSegmentation = MorphoVectorizedSegmentationOGRType::New();
-            morphoVectorizedSegmentation->GetSegmentationFilter()->SetProfileStart(initialValue);
-            morphoVectorizedSegmentation->GetSegmentationFilter()->SetProfileSize(profileSize);
-            morphoVectorizedSegmentation->GetSegmentationFilter()->SetProfileStep(step);
-            morphoVectorizedSegmentation->GetSegmentationFilter()->SetSigma(sigma);
+      amplitudeFilter->SetInput(this->GetParameterFloatVectorImage("in"));
 
-            streamSize = GenericApplySegmentation<FloatImageType, MorphologicalProfilesSegmentationFilterType> (
-        morphoVectorizedSegmentation,                                                                     amplitudeFilter->GetOutput(),
-                                                                                                             layer, 0);
+      MorphoVectorizedSegmentationOGRType::Pointer morphoVectorizedSegmentation = MorphoVectorizedSegmentationOGRType::New();
+      morphoVectorizedSegmentation->GetSegmentationFilter()->SetProfileStart(initialValue);
+      morphoVectorizedSegmentation->GetSegmentationFilter()->SetProfileSize(profileSize);
+      morphoVectorizedSegmentation->GetSegmentationFilter()->SetProfileStep(step);
+      morphoVectorizedSegmentation->GetSegmentationFilter()->SetSigma(sigma);
 
-            }
-          else
-            {
-            otbAppLogFATAL(<<"non defined filtering method "<<GetParameterInt("filter")<<std::endl);
-            }
+      streamSize = GenericApplySegmentation<FloatImageType,MorphologicalProfilesSegmentationFilterType>(
+        morphoVectorizedSegmentation,
+        amplitudeFilter->GetOutput(),
+        layer,
+        0);
+      }
+    else
+      {
+      otbAppLogFATAL(<<"non defined filtering method "<<GetParameterInt("filter")<<std::endl);
+      }
 
     if (segModeType == "vector")
       {
@@ -676,26 +685,27 @@ private:
         AddProcess(fusionFilter, "Stitching polygons");
         fusionFilter->GenerateData();
 
-       //REPACK the Layer in case of Shapefile.
-       //This request will remove features marked as deleted in the .dbf filename,
-       //and recomputed FID for each features (without holes).
+        //REPACK the Layer in case of Shapefile.
+        //This request will remove features marked as deleted in the .dbf filename,
+        //and recomputed FID for each features (without holes).
         //Note : the GetDriver() Method has not been encapsulated in otb::ogr::DataSource,
         //so we must access the OGR pointer by using .ogr()
 
         std::string driverName(otb::ogr::version_proxy::GetDriverNameFromDataSource(&ogrDS->ogr()));
-       if ( driverName.find("ESRI Shapefile") != std::string::npos)
-         {
-           otbAppLogINFO(<<"REPACK the Shapefile ..."<<std::endl);
-           //In Shapefile format, the name of the DaaSource is also the name of the Layer.
-           std::string shpLayerName = itksys::SystemTools::GetFilenameWithoutExtension(GetParameterString("mode.vector.out"));
-
-           std::string repack("REPACK ");
-           repack = repack + shpLayerName;
-           ogrDS->ExecuteSQL(repack, ITK_NULLPTR, ITK_NULLPTR);
-         }
-       }
+        if ( driverName.find("ESRI Shapefile") != std::string::npos)
+          {
+          otbAppLogINFO(<<"REPACK the Shapefile ..."<<std::endl);
+          //In Shapefile format, the name of the DaaSource is also the name of the Layer.
+          std::string shpLayerName = itksys::SystemTools::GetFilenameWithoutExtension(GetParameterString("mode.vector.out"));
+          std::string repack("REPACK ");
+          repack = repack + shpLayerName;
+          ogrDS->ExecuteSQL(repack, ITK_NULLPTR, ITK_NULLPTR);
+          }
+        }
       }
   }
+
+  ClampFilterType::Pointer m_ClampFilter;
 };
 }
 }
diff --git a/Modules/Applications/AppSegmentation/test/CMakeLists.txt b/Modules/Applications/AppSegmentation/test/CMakeLists.txt
index 090a256..e04c3bb 100644
--- a/Modules/Applications/AppSegmentation/test/CMakeLists.txt
+++ b/Modules/Applications/AppSegmentation/test/CMakeLists.txt
@@ -293,3 +293,18 @@ otb_test_application(NAME     apTvSeHooverCompareSegmentationTest
                               --ignore-lines-with 2 outgt: outms:
                      )
 
+#----------- LargeScaleMeanShift TESTS ----------------
+otb_test_application(NAME     apTvSeLargeScaleMeanShiftTest
+                     APP      LargeScaleMeanShift
+                     OPTIONS  -in ${EXAMPLEDATA}/QB_1_ortho.tif
+                              -spatialr 3
+                              -ranger 80
+                              -minsize 16
+                              -tilesizex 100
+                              -tilesizey 100
+                              -mode vector
+                              -mode.vector.out ${TEMP}/apTvSeLargeScaleMeanShiftTestOut.shp
+                     VALID    --compare-ogr ${NOTOL}
+                              ${BASELINE_FILES}/apTvSeLargeScaleMeanShiftTestOut.shp
+                              ${TEMP}/apTvSeLargeScaleMeanShiftTestOut.shp
+                     )
diff --git a/Modules/Applications/AppStereo/app/otbBlockMatching.cxx b/Modules/Applications/AppStereo/app/otbBlockMatching.cxx
index 8b19cfa..4884c77 100644
--- a/Modules/Applications/AppStereo/app/otbBlockMatching.cxx
+++ b/Modules/Applications/AppStereo/app/otbBlockMatching.cxx
@@ -127,82 +127,145 @@ private:
   void DoInit() ITK_OVERRIDE
   {
     SetName("BlockMatching");
-    SetDescription("Performs block-matching to estimate pixel-wise disparities between two images");
+    SetDescription("Performs block-matching to estimate pixel-wise disparities"
+      " between two images.");
 
     SetDocName("Pixel-wise Block-Matching");
-    SetDocLongDescription("This application allows one to performs block-matching to estimate pixel-wise disparities "
-      "between two images. One must chose block-matching method and input"
-      " masks (related to the left and right input image) of pixels for which the disparity should be investigated. "
-      "Additionally, two criteria can be optionally used to disable disparity investigation for some pixel: a "
-      "no-data value, and a threshold on the local variance. This allows one to speed-up computation by avoiding to "
-      "investigate disparities that will not be reliable anyway. For efficiency reasons, if the optimal metric values"
-      " image is desired, it will be concatenated to the output image (which will then have three bands : horizontal "
-      "disparity, vertical disparity and metric value). One can split these images afterward.");
+    SetDocLongDescription("This application allows one to performs "
+      "block-matching to estimate pixel-wise disparities for a pair of images "
+      "in epipolar geometry.\n\n"
+      "This application is part of the stereovision pipeline. It can be used "
+      "after having computed epipolar grids (with StereoRectificationGridGenerator)"
+      " and resampled each input image into epipolar geometry (with "
+      "GridBasedImageResampling).\n\n"
+      "The application searches locally for the displacement between a reference"
+      " image and a secondary image. The correspondence is evaluated for each "
+      "pixel, based on a pair of local neighborhood windows. The displacement "
+      "evaluated can be 1D (along lines) or 2D. Parameters allows to set the "
+      "minimum and maximum disparities to search (both for horizontal and "
+      "vertical directions). A winner-take-all approach is used to select the "
+      "best match. There are different metrics implemented to evaluate the "
+      "match between two local windows:\n"
+      "  * SSD : Sum of Squared Distances\n"
+      "  * NCC : Normalized Cross-Correlation\n"
+      "  * Lp  : Lp pseudo norm\n"
+      "\n"                    
+      "Once the best integer disparity is found, an optional step of sub-pixel "
+      "disparity estimation can be performed, with various algorithms "
+      "(triangular interpolation, parabollic interpolation, dichotimic search)."
+      " As post-processing, there is an optional step of median filtering on "
+      "the disparities. One can chose input masks (related to the left and "
+      "right input image) of pixels for which the disparity should be "
+      "investigated. Additionally, two criteria can be optionally used to "
+      "disable disparity investigation for some pixel: a no-data value, and a "
+      "threshold on the local variance. This allows one to speed-up computation"
+      " by avoiding to investigate disparities that will not be reliable anyway"
+      ". For efficiency reasons, if the image of optimal metric values is "
+      "desired, it will be concatenated to the output image (which will then "
+      "have three bands : horizontal disparity, vertical disparity and metric "
+      "value). One can split these images afterward.");
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
-    SetDocSeeAlso("otbStereoRectificationGridGenerator");
+    SetDocSeeAlso("[1] StereoRectificationGridGenerator\n"
+      "[2] GridBasedImageResampling");
 
     AddDocTag(Tags::Stereo);
 
     AddParameter(ParameterType_Group,"io","Input and output data");
-    SetParameterDescription("io","This group of parameters allows setting the input and output images.");
+    SetParameterDescription("io","This group of parameters allows setting the "
+      "input and output images.");
 
     AddParameter(ParameterType_InputImage,"io.inleft","Left input image");
-    SetParameterDescription("io.inleft","The left input image (reference)");
+    SetParameterDescription("io.inleft","The left input image (reference).\n"
+      "It should have the same size and same physical space as the right input."
+      " This image can be generated by GridBasedImageResampling");
 
     AddParameter(ParameterType_InputImage,"io.inright","Right input image");
-    SetParameterDescription("io.inright","The right input (secondary)");
+    SetParameterDescription("io.inright","The right input (secondary).\n"
+      "It should have the same size and same physical space as the left input."
+      " This image can be generated by GridBasedImageResampling");
 
     AddParameter(ParameterType_OutputImage, "io.out", "The output disparity map");
-    SetParameterDescription("io.out","An image containing the estimated disparities as well as the metric values if the option is used");
-
-    AddParameter(ParameterType_OutputImage, "io.outmask", "The output mask corresponding to all criterions");
-    SetParameterDescription("io.outmask","A mask image corresponding to all citerions (see masking parameters). Only required if variance threshold or nodata criterions are set.");
+    SetParameterDescription("io.out","An image containing the estimated "
+      "disparities as well as the metric values if the option is used. If no "
+      "metric is output and no sub-pixel interpolation is done, pixel type can"
+      "be a signed integer. In the other cases, floating point pixel is "
+      "advised.");
+
+    AddParameter(ParameterType_OutputImage, "io.outmask", "The output mask "
+      "corresponding to all criterions");
+    SetParameterDescription("io.outmask","An output mask image corresponding to"
+      " all citerions (see masking parameters). Only required if variance "
+      "threshold or nodata criterions are set. Output pixel type is unsigned "
+      "8bit by default.");
     SetDefaultOutputPixelType("io.outmask",ImagePixelType_uint8);
     DisableParameter("io.outmask");
     MandatoryOff("io.outmask");
 
-    AddParameter(ParameterType_Empty,"io.outmetric","Output optimal metric values as well");
-    SetParameterDescription("io.outmetric","If used, the output image will have a second component with metric optimal values");
+    AddParameter(ParameterType_Empty,"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");
 
     AddParameter(ParameterType_Group,"mask","Image masking parameters");
-    SetParameterDescription("mask","This group of parameters allows determining the masking parameters to prevent disparities estimation for some pixels of the left image");
-
-    AddParameter(ParameterType_InputImage,"mask.inleft","Discard left pixels from mask image");
-    SetParameterDescription("mask.inleft","This parameter allows providing a custom mask for the left image.Block matching will be only perform on pixels inside the mask.");
+    SetParameterDescription("mask","This group of parameters allows determining"
+      " the masking parameters to prevent disparities estimation for some "
+      "pixels of the left image");
+
+    AddParameter(ParameterType_InputImage,"mask.inleft",
+      "Mask to discard left pixels");
+    SetParameterDescription("mask.inleft","This parameter allows providing a "
+      "custom mask for the left image. Block matching will be only perform on "
+      "pixels inside the mask (non-zero values).");
     MandatoryOff("mask.inleft");
 
-    AddParameter(ParameterType_InputImage,"mask.inright","Discard right pixels from mask image");
-    SetParameterDescription("mask.inright","This parameter allows providing a custom mask for the right image.Block matching will be perform only on pixels inside the mask.");
+    AddParameter(ParameterType_InputImage,"mask.inright",
+      "Mask to discard right pixels");
+    SetParameterDescription("mask.inright","This parameter allows providing a "
+      "custom mask for the right image. Block matching will be perform only on "
+      "pixels inside the mask (non-zero values).");
     MandatoryOff("mask.inright");
 
-    AddParameter(ParameterType_Float,"mask.nodata","Discard pixels with no-data value");
-    SetParameterDescription("mask.nodata","This parameter allows discarding pixels whose value is equal to the user-defined no-data value.");
+    AddParameter(ParameterType_Float,"mask.nodata",
+      "Discard pixels with no-data value");
+    SetParameterDescription("mask.nodata","This parameter allows discarding "
+      "pixels whose value is equal to the user-defined no-data value.");
     MandatoryOff("mask.nodata");
     SetDefaultParameterFloat("mask.nodata",0.);
     DisableParameter("mask.nodata");
 
-    AddParameter(ParameterType_Float,"mask.variancet","Discard pixels with low local variance");
-    SetParameterDescription("mask.variancet","This parameter allows discarding pixels whose local variance is too small (the size of the neighborhood is given by the radius parameter)");
+    AddParameter(ParameterType_Float,"mask.variancet",
+      "Discard pixels with low local variance");
+    SetParameterDescription("mask.variancet","This parameter allows discarding"
+      " pixels whose local variance is too small (the size of the neighborhood"
+      " is given by the radius parameter)");
     MandatoryOff("mask.variancet");
     SetDefaultParameterFloat("mask.variancet",100.);
     DisableParameter("mask.variancet");
 
     AddParameter(ParameterType_Group,"bm","Block matching parameters");
-    SetParameterDescription("bm","This group of parameters allow tuning the block-matching behaviour");
+    SetParameterDescription("bm","This group of parameters allow tuning the "
+      "block-matching behaviour");
 
     AddParameter(ParameterType_Choice,   "bm.metric", "Block-matching metric");
+    SetParameterDescription("bm.metric",
+      "Metric to evaluate matching between two local windows.");
+
     AddChoice("bm.metric.ssd","Sum of Squared Distances");
-    SetParameterDescription("bm.metric.ssd","Sum of squared distances between pixels value in the metric window");
+    SetParameterDescription("bm.metric.ssd","Sum of squared distances between"
+      " pixels value in the metric window");
 
     AddChoice("bm.metric.ncc","Normalized Cross-Correlation");
-    SetParameterDescription("bm.metric.ncc","Normalized Cross-Correlation between the left and right windows");
+    SetParameterDescription("bm.metric.ncc","Normalized Cross-Correlation "
+      "between the left and right windows");
 
     AddChoice("bm.metric.lp","Lp pseudo-norm");
-    SetParameterDescription("bm.metric.lp","Lp pseudo-norm between the left and right windows");
+    SetParameterDescription("bm.metric.lp","Lp pseudo-norm between the left and"
+      " right windows.");
 
     AddParameter(ParameterType_Float,"bm.metric.lp.p","p value" );
-    SetParameterDescription("bm.metric.lp.p", "Value of the p parameter in Lp pseudo-norm (must be positive)");
+    SetParameterDescription("bm.metric.lp.p", "Value of the p parameter in Lp"
+      " pseudo-norm (must be positive).");
     SetDefaultParameterFloat("bm.metric.lp.p", 1.0);
     SetMinimumParameterFloatValue("bm.metric.lp.p", 0.0);
 
@@ -227,43 +290,61 @@ private:
     SetParameterDescription("bm.subpixel", "Estimate disparities with sub-pixel precision");
 
     AddChoice("bm.subpixel.none", "None");
-    SetParameterDescription("bm.subpixel.none", "No sub-pixel ");
+    SetParameterDescription("bm.subpixel.none", "No sub-pixel search");
 
-    AddChoice("bm.subpixel.parabolic", "Parabolic");
-    SetParameterDescription("bm.subpixel.parabolic", "Parabolic fit");
+    AddChoice("bm.subpixel.parabolic", "Parabolic fit");
+    SetParameterDescription("bm.subpixel.parabolic", "The metric values closest"
+      " to the best match are used in order to fit a parabola to the local "
+      "extremum of the metric surface. The peak position of this parabola is "
+      "output.");
 
-    AddChoice("bm.subpixel.triangular", "Triangular");
-    SetParameterDescription("bm.subpixel.triangular", "Triangular fit");
+    AddChoice("bm.subpixel.triangular", "Triangular fit");
+    SetParameterDescription("bm.subpixel.triangular", "The metric values "
+      "closest to the best match are used in order to fit a triangular peak to "
+      "the local extremum of the metric surface. The peak position of this "
+      "triangle is output.");
 
-    AddChoice("bm.subpixel.dichotomy", "Dichotomy");
-    SetParameterDescription("bm.subpixel.dichotomy", "Dichotomic search");
+    AddChoice("bm.subpixel.dichotomy", "Dichotomy search");
+    SetParameterDescription("bm.subpixel.dichotomy", "An iterative dichotomic "
+      "search is performed to find the best sub-pixel position. The window in "
+      "the right image is resampled at sub-pixel positions to estimate the match.");
 
     AddParameter(ParameterType_Int,"bm.step", "Computation step");
-    SetParameterDescription("bm.step", "Location step between computed disparities");
+    SetParameterDescription("bm.step", "Location step between computed "
+      "disparities. Disparities will be computed every 'step' pixels in the "
+      "left image (step for both rows and columns). For instance, a value of 1 "
+      "corresponds to the classic dense disparity map.");
     SetDefaultParameterInt("bm.step",1);
     SetMinimumParameterIntValue("bm.step",1);
     MandatoryOff("bm.step");
 
     AddParameter(ParameterType_Int,"bm.startx","X start index");
-    SetParameterDescription("bm.startx","X start index of the subsampled grid (wrt the input image grid)");
+    SetParameterDescription("bm.startx","X start index of the subsampled grid "
+      "(wrt the input image grid). See parameter bm.step");
     SetDefaultParameterInt("bm.startx",0);
     MandatoryOff("bm.startx");
 
     AddParameter(ParameterType_Int,"bm.starty","Y start index");
-    SetParameterDescription("bm.starty","Y start index of the subsampled grid (wrt the input image grid)");
+    SetParameterDescription("bm.starty","Y start index of the subsampled grid "
+      "(wrt the input image grid). See parameter bm.step");
     SetDefaultParameterInt("bm.starty",0);
     MandatoryOff("bm.starty");
 
-    AddParameter(ParameterType_Group,"bm.medianfilter","Median filtering");
-    SetParameterDescription("bm.medianfilter","Use a median filter to get a smooth disparity map");
+    AddParameter(ParameterType_Group,"bm.medianfilter",
+      "Median filtering of disparity map");
+    SetParameterDescription("bm.medianfilter","Use a median filter to get a "
+      "smooth disparity map");
 
     AddParameter(ParameterType_Int,"bm.medianfilter.radius", "Radius");
-    SetParameterDescription("bm.medianfilter.radius", "Radius for median filter");
+    SetParameterDescription("bm.medianfilter.radius", "Radius (in pixels) for "
+      "median filter");
     MandatoryOff("bm.medianfilter.radius");
     DisableParameter("bm.medianfilter.radius");
 
-    AddParameter(ParameterType_Float,"bm.medianfilter.incoherence", "Incoherence threshold");
-    SetParameterDescription("bm.medianfilter.incoherence", "Incoherence threshold between original and filtered disparity");
+    AddParameter(ParameterType_Float,"bm.medianfilter.incoherence",
+      "Incoherence threshold");
+    SetParameterDescription("bm.medianfilter.incoherence", "Incoherence "
+      "threshold between original and filtered disparity");
     MandatoryOff("bm.medianfilter.incoherence");
     DisableParameter("bm.medianfilter.incoherence");
 
@@ -272,42 +353,60 @@ private:
     SetParameterDescription("bm.initdisp.none", "No initial disparity used");
 
     AddChoice("bm.initdisp.uniform", "Uniform initial disparity");
-    SetParameterDescription("bm.initdisp.uniform", "Use an uniform initial disparity estimate");
+    SetParameterDescription("bm.initdisp.uniform", "Use an uniform initial "
+      "disparity estimate");
 
-    AddParameter(ParameterType_Int, "bm.initdisp.uniform.hdisp", "Horizontal initial disparity");
-    SetParameterDescription("bm.initdisp.uniform.hdisp", "Value of the uniform horizontal disparity initial estimate (in pixels)");
+    AddParameter(ParameterType_Int, "bm.initdisp.uniform.hdisp",
+      "Horizontal initial disparity");
+    SetParameterDescription("bm.initdisp.uniform.hdisp", "Value of the uniform "
+      "horizontal disparity initial estimate (in pixels)");
     SetDefaultParameterInt("bm.initdisp.uniform.hdisp", 0);
 
-    AddParameter(ParameterType_Int, "bm.initdisp.uniform.vdisp", "Vertical initial disparity");
-    SetParameterDescription("bm.initdisp.uniform.vdisp", "Value of the uniform vertical disparity initial estimate (in pixels)");
+    AddParameter(ParameterType_Int, "bm.initdisp.uniform.vdisp",
+      "Vertical initial disparity");
+    SetParameterDescription("bm.initdisp.uniform.vdisp", "Value of the uniform "
+      "vertical disparity initial estimate (in pixels)");
     SetDefaultParameterInt("bm.initdisp.uniform.vdisp", 0);
 
-    AddParameter(ParameterType_Int, "bm.initdisp.uniform.hrad", "Horizontal exploration radius");
-    SetParameterDescription("bm.initdisp.uniform.hrad", "Horizontal exploration radius around the initial disparity estimate (in pixels)");
+    AddParameter(ParameterType_Int, "bm.initdisp.uniform.hrad",
+      "Horizontal exploration radius");
+    SetParameterDescription("bm.initdisp.uniform.hrad", "Horizontal exploration"
+      " radius around the initial disparity estimate (in pixels)");
     SetDefaultParameterInt("bm.initdisp.uniform.hrad", 0);
     DisableParameter("bm.initdisp.uniform.hrad");
 
-    AddParameter(ParameterType_Int, "bm.initdisp.uniform.vrad", "Vertical exploration radius");
-    SetParameterDescription("bm.initdisp.uniform.vrad", "Vertical exploration radius around the initial disparity estimate (in pixels)");
+    AddParameter(ParameterType_Int, "bm.initdisp.uniform.vrad",
+      "Vertical exploration radius");
+    SetParameterDescription("bm.initdisp.uniform.vrad", "Vertical exploration "
+      "radius around the initial disparity estimate (in pixels)");
     SetDefaultParameterInt("bm.initdisp.uniform.vrad", 0);
     DisableParameter("bm.initdisp.uniform.vrad");
 
     AddChoice("bm.initdisp.maps", "Initial disparity maps");
-    SetParameterDescription("bm.initdisp.maps", "Use initial disparity maps");
+    SetParameterDescription("bm.initdisp.maps", "Use initial disparity maps to "
+      "define the exploration area. This area in the right image is centered on"
+      " the current position shifted by the initial disparity estimate, and has"
+      " a given exploration radius in horizontal and vertical directions.");
 
-    AddParameter(ParameterType_InputImage, "bm.initdisp.maps.hmap", "Horizontal initial disparity map");
-    SetParameterDescription("bm.initdisp.maps.hmap", "Map of the initial horizontal disparities");
+    AddParameter(ParameterType_InputImage, "bm.initdisp.maps.hmap",
+      "Horizontal initial disparity map");
+    SetParameterDescription("bm.initdisp.maps.hmap", "Map of the initial "
+      "horizontal disparities");
 
-    AddParameter(ParameterType_InputImage, "bm.initdisp.maps.vmap", "Vertical initial disparity map");
-    SetParameterDescription("bm.initdisp.maps.vmap", "Map of the initial vertical disparities");
+    AddParameter(ParameterType_InputImage, "bm.initdisp.maps.vmap",
+      "Vertical initial disparity map");
+    SetParameterDescription("bm.initdisp.maps.vmap", "Map of the initial "
+      "vertical disparities");
 
     AddParameter(ParameterType_Int, "bm.initdisp.maps.hrad", "Horizontal exploration radius");
-    SetParameterDescription("bm.initdisp.maps.hrad", "Horizontal exploration radius around the initial disparity estimate (in pixels)");
+    SetParameterDescription("bm.initdisp.maps.hrad", "Horizontal exploration "
+      "radius around the initial disparity estimate (in pixels)");
     SetDefaultParameterInt("bm.initdisp.maps.hrad", 0);
     DisableParameter("bm.initdisp.maps.hrad");
 
     AddParameter(ParameterType_Int, "bm.initdisp.maps.vrad", "Vertical exploration radius");
-    SetParameterDescription("bm.initdisp.maps.vrad", "Vertical exploration radius around the initial disparity estimate (in pixels)");
+    SetParameterDescription("bm.initdisp.maps.vrad", "Vertical exploration "
+      "radius around the initial disparity estimate (in pixels)");
     SetDefaultParameterInt("bm.initdisp.maps.vrad", 0);
     DisableParameter("bm.initdisp.maps.vrad");
 
diff --git a/Modules/Applications/AppStereo/app/otbDisparityMapToElevationMap.cxx b/Modules/Applications/AppStereo/app/otbDisparityMapToElevationMap.cxx
index 6f626cf..25e4b96 100644
--- a/Modules/Applications/AppStereo/app/otbDisparityMapToElevationMap.cxx
+++ b/Modules/Applications/AppStereo/app/otbDisparityMapToElevationMap.cxx
@@ -65,39 +65,71 @@ private:
   void DoInit() ITK_OVERRIDE
   {
     SetName("DisparityMapToElevationMap");
-    SetDescription("Projects a disparity map into a regular elevation map");
+    SetDescription("Projects a disparity map into a regular elevation map.");
 
     SetDocName("Disparity map to elevation map");
-    SetDocLongDescription("This application uses a disparity map computed from a stereo image pair to produce an "
-      "elevation map on the ground area covered by the stereo pair. The needed inputs are : the disparity map, "
-      "the stereo pair (in original geometry) and the epipolar deformation grids. These grids have to link the "
-      "original geometry (stereo pair) and the epipolar geometry (disparity map). ");
-    SetDocLimitations("None");
+    SetDocLongDescription("This application uses a disparity map computed from "
+      "a stereo image pair to produce an elevation map on the ground area "
+      "covered by the stereo pair.\n\n"
+      "This application is part of the stereo reconstruction pipeline. It can "
+      "be used after having computed the disparity map with BlockMatching.\n\n"
+      "The needed inputs are : the disparity map, the stereo pair (in original"
+      " geometry) and the epipolar deformation grids. These grids (computed by "
+      "StereoRectificationGridGenerator) have to contain the transform between "
+      "the original geometry (stereo pair) and the epipolar geometry (disparity"
+      " map). The algorithm for each disparity is the following :\n"
+      "  * skip if position is discarded by the disparity mask\n"
+      "  * compute left ray : transform the current position from epipolar "
+      "geometry to left sensor geometry (left rectification grid)\n"
+      "  * compute right ray : shift the current position with current "
+      "disparity and transform from epipolar geometry to right sensor (right "
+      "rectification grid)\n"
+      "  * estimate best 3D intersection between left and right rays\n"
+      "  * for the ground cell of the obtained 3D point, keep its elevation if "
+      "greater than current elevation (keeps the maximum of elevations of all "
+      "3D points in each cell)\n"
+      "\n"
+      "Minimum and maximum elevations settings are here to bound the "
+      "reconstructed DEM.");
+    SetDocLimitations("The epipolar deformation grid should be able to entirely"
+      " fit in memory.");
     SetDocAuthors("OTB-Team");
-    SetDocSeeAlso("otbStereoRectificationGridGenerator otbBlockMatching");
+    SetDocSeeAlso("[1] StereoRectificationGridGenerator\n"
+      "[2] BlockMatching");
 
     AddDocTag(Tags::Stereo);
 
     AddParameter(ParameterType_Group,"io","Input and output data");
-    SetParameterDescription("io","This group of parameters allows one to set input images, output images and grids.");
+    SetParameterDescription("io","This group of parameters allows one to set "
+      "input images, output images and grids.");
 
     AddParameter(ParameterType_InputImage,"io.in","Input disparity map");
-    SetParameterDescription("io.in","The input disparity map (horizontal disparity in first band, vertical in second)");
+    SetParameterDescription("io.in","The input disparity map (horizontal "
+      "disparity in first band, vertical in second). This map can be computed "
+      "by BlockMatching application.");
 
     AddParameter(ParameterType_InputImage,"io.left","Left sensor image");
-    SetParameterDescription("io.left","Left image in original (sensor) geometry");
+    SetParameterDescription("io.left","Left image in original (sensor) geometry"
+      ". Only the geometric model of this image will be used, not the pixel "
+      "values.");
 
     AddParameter(ParameterType_InputImage,"io.right","Right sensor image");
-    SetParameterDescription("io.right","Right image in original (sensor) geometry");
+    SetParameterDescription("io.right","Right image in original (sensor) "
+      "geometry. Only the geometric model of this image will be used, not the "
+      "pixel values.");
 
     AddParameter(ParameterType_InputImage,"io.lgrid","Left Grid");
-    SetParameterDescription("io.lgrid","Left epipolar grid (deformation grid between sensor et disparity spaces)");
+    SetParameterDescription("io.lgrid","Left epipolar grid (deformation grid "
+      "between left sensor et disparity spaces)");
 
     AddParameter(ParameterType_InputImage,"io.rgrid","Right Grid");
-    SetParameterDescription("io.rgrid","Right epipolar grid (deformation grid between sensor et disparity spaces)");
+    SetParameterDescription("io.rgrid","Right epipolar grid (deformation grid "
+      "between right sensor et disparity spaces)");
 
     AddParameter(ParameterType_OutputImage,"io.out","Output elevation map");
-    SetParameterDescription("io.out", "Output elevation map in ground projection");
+    SetParameterDescription("io.out", "Output elevation map in ground "
+      "projection. Elevation values are in meters. Floating point pixel type "
+      "are expected.");
 
     AddParameter(ParameterType_Float,"step","DEM step");
     SetParameterDescription("step","Spacing of the output elevation map (in meters)");
@@ -112,7 +144,8 @@ private:
     SetDefaultParameterFloat("hmax",100.0);
 
     AddParameter(ParameterType_InputImage,"io.mask","Disparity mask");
-    SetParameterDescription("io.mask","Masked disparity cells won't be projected");
+    SetParameterDescription("io.mask","Masked disparity pixels won't be "
+      "projected (mask values equal to zero)");
     MandatoryOff("io.mask");
 
     ElevationParametersHandler::AddElevationParameters(this, "elev");
diff --git a/Modules/Applications/AppStereo/app/otbFineRegistration.cxx b/Modules/Applications/AppStereo/app/otbFineRegistration.cxx
index d24627f..a7fed89 100644
--- a/Modules/Applications/AppStereo/app/otbFineRegistration.cxx
+++ b/Modules/Applications/AppStereo/app/otbFineRegistration.cxx
@@ -120,7 +120,16 @@ private:
     SetDescription("Estimate disparity map between two images.");
 
     SetDocName("Fine Registration");
-    SetDocLongDescription("Estimate disparity map between two images. Output image contain x offset, y offset and metric value.");
+    SetDocLongDescription("This application computes a disparity map between "
+      "two images that correspond to the same scene. It is intended for case "
+      "where small misregistration between images should be estimated and fixed"
+      ". The search is performed in 2D.\n\n"
+      "The algorithm uses an iterative approach to estimate a best match "
+      "between local patches. The typical use case is registration betwween "
+      "similar bands, or between two acquisitions. The output image contains "
+      "X and Y offsets, as well as the metric value. A sub-pixel accuracy can "
+      "be expected. The input images should have the same size and same "
+      "physical space.");
     SetDocLimitations("None");
     SetDocAuthors("OTB-Team");
     SetDocSeeAlso(" ");
@@ -134,7 +143,9 @@ private:
     SetParameterDescription( "sec", "The secondary image." );
 
     AddParameter(ParameterType_OutputImage,  "out",   "Output Image");
-    SetParameterDescription( "out", "The output image." );
+    SetParameterDescription( "out", "The output image contains 3 bands, for X "
+      "offset, Y offset and the metric value. It may contain a 4th one with the"
+      " validity mask (if used)." );
 
     AddParameter(ParameterType_Int,  "erx",   "Exploration Radius X");
     SetParameterDescription( "erx", "The exploration radius along x (in pixels)" );
@@ -145,15 +156,18 @@ private:
     SetMinimumParameterIntValue("ery", 0);
 
     AddParameter(ParameterType_Int,  "mrx",   "Metric Radius X");
-    SetParameterDescription( "mrx", "Radius along x (in pixels) of the metric computation window" );
+    SetParameterDescription( "mrx", "Radius along x (in pixels) of the metric "
+      "computation window" );
     SetMinimumParameterIntValue("mrx", 0);
 
     AddParameter(ParameterType_Int,  "mry",   "Metric Radius Y");
-    SetParameterDescription( "mry", "Radius along y (in pixels) of the metric computation window" );
+    SetParameterDescription( "mry", "Radius along y (in pixels) of the metric "
+      "computation window" );
     SetMinimumParameterIntValue("mry", 0);
 
     AddParameter(ParameterType_InputImage,  "w",   "Image To Warp");
-    SetParameterDescription( "w", "The image to warp after disparity estimation is completed" );
+    SetParameterDescription( "w", "The image to warp after disparity estimation"
+    " is completed." );
     MandatoryOff("w");
 
     AddParameter(ParameterType_OutputImage,  "wo",   "Output Warped Image");
@@ -161,65 +175,81 @@ private:
     MandatoryOff("wo");
 
     AddParameter(ParameterType_Float,  "cox",   "Coarse Offset X");
-    SetParameterDescription( "cox", "Coarse offset along x (in physical space) between the two images" );
+    SetParameterDescription( "cox", "Coarse offset along x (in physical space)"
+      " between the two images, used as an initial offset for all pixels." );
     SetDefaultParameterFloat("cox", 0.0);
     MandatoryOff("cox");
 
     AddParameter(ParameterType_Float,  "coy",   "Coarse Offset Y");
-    SetParameterDescription( "coy", "Coarse offset along y (in physical space) between the two images" );
+    SetParameterDescription( "coy", "Coarse offset along y (in physical space)"
+      " between the two images, used as an initial offset for all pixels." );
     SetDefaultParameterFloat("coy", 0.0);
     MandatoryOff("coy");
 
     AddParameter(ParameterType_Float,  "ssrx",   "Sub-Sampling Rate X");
-    SetParameterDescription( "ssrx", "Generates a result at a coarser resolution with a given sub-sampling rate along X" );
+    SetParameterDescription( "ssrx", "Generates a result at a coarser "
+      "resolution with a given sub-sampling rate along X" );
     SetDefaultParameterFloat("ssrx", 1.0);
     SetMinimumParameterFloatValue("ssrx", 1.0);
     MandatoryOff("ssrx");
 
     AddParameter(ParameterType_Float,  "ssry",   "Sub-Sampling Rate Y");
-    SetParameterDescription( "ssry", "Generates a result at a coarser resolution with a given sub-sampling rate along Y" );
+    SetParameterDescription( "ssry", "Generates a result at a coarser "
+      "resolution with a given sub-sampling rate along Y" );
     SetDefaultParameterFloat("ssry", 1.0);
     SetMinimumParameterFloatValue("ssry", 1.0);
     MandatoryOff("ssry");
 
     AddParameter(ParameterType_Float,  "rgsx",   "Reference Gaussian Smoothing X");
-    SetParameterDescription( "rgsx", "Performs a gaussian smoothing of the reference image. Parameter is gaussian sigma (in pixels) in X direction." );
+    SetParameterDescription( "rgsx", "Performs a gaussian smoothing of the "
+      "reference image. Parameter is gaussian sigma (in pixels) in X direction." );
     MandatoryOff("rgsx");
 
     AddParameter(ParameterType_Float,  "rgsy",   "Reference Gaussian Smoothing Y");
-    SetParameterDescription( "rgsy", "Performs a gaussian smoothing of the reference image. Parameter is gaussian sigma (in pixels) in Y direction." );
+    SetParameterDescription( "rgsy", "Performs a gaussian smoothing of the "
+      "reference image. Parameter is gaussian sigma (in pixels) in Y direction." );
     MandatoryOff("rgsy");
 
     AddParameter(ParameterType_Float,  "sgsx",   "Secondary Gaussian Smoothing X");
-    SetParameterDescription( "sgsx", "Performs a gaussian smoothing of the secondary image. Parameter is gaussian sigma (in pixels) in X direction." );
+    SetParameterDescription( "sgsx", "Performs a gaussian smoothing of the "
+      "secondary image. Parameter is gaussian sigma (in pixels) in X direction." );
     MandatoryOff("sgsx");
 
     AddParameter(ParameterType_Float,  "sgsy",   "Secondary Gaussian Smoothing Y");
-    SetParameterDescription( "sgsy", "Performs a gaussian smoothing of the secondary image. Parameter is gaussian sigma (in pixels) in Y direction." );
+    SetParameterDescription( "sgsy", "Performs a gaussian smoothing of the "
+      "secondary image. Parameter is gaussian sigma (in pixels) in Y direction." );
     MandatoryOff("sgsy");
 
     AddParameter(ParameterType_String,  "m",   "Metric");
-    SetParameterDescription( "m", "Choose the metric used for block matching. Available metrics are cross-correlation (CC), cross-correlation with subtracted mean (CCSM), mean-square difference (MSD), mean reciprocal square difference (MRSD) and mutual information (MI). Default is cross-correlation" );
+    SetParameterDescription( "m", "Choose the metric used for block matching. "
+      "Available metrics are cross-correlation (CC), cross-correlation with "
+      "subtracted mean (CCSM), mean-square difference (MSD), mean reciprocal "
+      "square difference (MRSD) and mutual information (MI). Default is "
+      "cross-correlation" );
     MandatoryOff("m");
 
     AddParameter(ParameterType_Float,  "spa",   "SubPixelAccuracy");
-    SetParameterDescription( "spa", "Metric extrema location will be refined up to the given accuracy. Default is 0.01" );
+    SetParameterDescription( "spa", "Metric extrema location will be refined up"
+      " to the given accuracy. Default is 0.01" );
     SetDefaultParameterFloat("spa", 0.01);
     SetMinimumParameterFloatValue("spa", 0.0);
     MandatoryOff("spa");
 
     AddParameter(ParameterType_Float,  "cva",   "ConvergenceAccuracy");
-    SetParameterDescription( "cva", "Metric extrema will be refined up to the given accuracy. Default is 0.01" );
+    SetParameterDescription( "cva", "Metric extrema will be refined up to the"
+      " given accuracy. Default is 0.01" );
     SetDefaultParameterFloat("cva", 0.01);
     SetMinimumParameterFloatValue("cva", 0.0);
     MandatoryOff("cva");
 
     AddParameter(ParameterType_Float,  "vmlt",   "Validity Mask Lower Threshold");
-    SetParameterDescription( "vmlt", "Lower threshold to obtain a validity mask." );
+    SetParameterDescription( "vmlt", "Lower threshold to compute the validity "
+      "mask. This mask will be the 4th output band." );
     MandatoryOff("vmlt");
 
     AddParameter(ParameterType_Float,  "vmut",   "Validity Mask Upper Threshold");
-    SetParameterDescription( "vmut", "Upper threshold to obtain a validity mask." );
+    SetParameterDescription( "vmut", "Upper threshold to obtain a validity "
+      "mask. This mask will be the 4th output band." );
     MandatoryOff("vmut");
 
     AddRAMParameter();
diff --git a/Modules/Applications/AppStereo/app/otbGeneratePlyFile.cxx b/Modules/Applications/AppStereo/app/otbGeneratePlyFile.cxx
index fde8653..928b1da 100644
--- a/Modules/Applications/AppStereo/app/otbGeneratePlyFile.cxx
+++ b/Modules/Applications/AppStereo/app/otbGeneratePlyFile.cxx
@@ -58,19 +58,38 @@ private:
     SetDescription("Generate a 3D Ply file from a DEM and a color image.");
 
     SetDocName("Ply 3D files generation");
-    SetDocLongDescription("Generate a 3D Ply file from a DEM and a color image.");
-    SetDocLimitations(" ");
+    SetDocLongDescription("The application converts an image containing "
+      "elevations into a PLY file, which is a file format to store 3D models. "
+      "This format is adpated for visualization on software such as MeshLab [2]"
+      " or CloudCompare [3]\n\n"
+      "This application is part of the stereo reconstruction framework. The "
+      "input data can be produced by the application DisparityMapToElevationMap.\n\n"
+      "There are two types of supported input images:\n"
+      "  * A DEM image, with a ground projection, containing elevation values. "
+      "Each elevation value can be considered as a 3D point.\n"
+      "  * A 3D grid image, containing 5 bands (the first 3 are the 3D "
+      "coordinates of each point, the 5th is a validity mask where valid values"
+      " are larger or equal to 1)\n"
+      "\n"
+      "The user shall also give a support image that contains color values for"
+      " each 3D point. The color values will be embedded in the PLY file.");
+    SetDocLimitations("The input DEM image has to entirely fit into memory.");
     SetDocAuthors("OTB-Team");
-    SetDocSeeAlso(" ");
+    SetDocSeeAlso("- [1] DisparityMapToElevationMap \n"
+      "- [2] http://www.meshlab.net/ \n"
+      "- [3] http://www.cloudcompare.org/");
 
     AddDocTag(Tags::Geometry);
 
-    AddParameter(ParameterType_InputImage,"indem","The input DEM");
-    SetParameterDescription("indem", "The input DEM");
+    AddParameter(ParameterType_InputImage,"indem","The input DEM image");
+    SetParameterDescription("indem", "The image should be either a projected "
+      "DEM or a 3D grid containing 3D point coordinates and a validity mask.");
 
     AddParameter(ParameterType_Choice,"mode", "Conversion Mode");
     AddChoice("mode.dem","DEM");
-    SetParameterDescription("mode.dem","DEM conversion mode");
+    SetParameterDescription("mode.dem","DEM conversion mode (the projection "
+      "information of the DEM is used to derive the X and Y coordinates of each"
+      " point)");
 
     AddChoice("mode.3dgrid","3D grid");
     SetParameterDescription("mode.3dgrid","3D grid conversion mode");
@@ -79,10 +98,14 @@ private:
     MapProjectionParametersHandler::AddMapProjectionParameters(this, "map");
 
     AddParameter(ParameterType_InputImage,"incolor","The input color image");
-    SetParameterDescription("incolor", "The input color image");
+    SetParameterDescription("incolor", "If the color image has 4 bands it will "
+      "be interpreted as Red, Green, Blue, NIR. In other cases, only the first "
+      "one is used (gray scale colors). The color values are expected in the "
+      "range 0 - 255, and will be embedded with each 3D ""point of the PLY file.");
 
     AddParameter(ParameterType_OutputFilename,"out","The output Ply file");
-    SetParameterDescription("out","The output Ply file");
+    SetParameterDescription("out","The output Ply file will contain as many 3D "
+      "points as pixels in the input DEM.");
 
     // Doc example
     SetDocExampleParameterValue("indem","image_dem.tif");
diff --git a/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx b/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx
index ac8bcfa..ed0d0fd 100644
--- a/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx
+++ b/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx
@@ -105,7 +105,7 @@ private:
     SetDescription("Generates two deformation fields to stereo-rectify (i.e. resample in epipolar geometry) a pair of stereo images up to the sensor model precision");
 
     SetDocName("Stereo-rectification deformation grid generator");
-    SetDocLongDescription("This application generates a pair of deformation grid to stereo-rectify a pair of stereo images according to sensor modelling and a mean elevation hypothesis. The deformation grids can be passed to the StereoRectificationGridGenerator application for actual resampling in epipolar geometry.");
+    SetDocLongDescription("This application generates a pair of deformation grid to stereo-rectify a pair of stereo images according to sensor modelling and a mean elevation hypothesis. The deformation grids can be passed to the GridBasedImageResampling application for actual resampling in epipolar geometry.");
     SetDocLimitations("Generation of the deformation grid is not streamable, pay attention to this fact when setting the grid step.");
     SetDocAuthors("OTB-Team");
 
diff --git a/Modules/Applications/AppTest/test/otbWrapperApplicationDocTests.cxx b/Modules/Applications/AppTest/test/otbWrapperApplicationDocTests.cxx
index b90ed3e..636b380 100644
--- a/Modules/Applications/AppTest/test/otbWrapperApplicationDocTests.cxx
+++ b/Modules/Applications/AppTest/test/otbWrapperApplicationDocTests.cxx
@@ -27,6 +27,68 @@
 using otb::Wrapper::Application;
 using otb::Wrapper::ApplicationRegistry;
 
+typedef std::pair<std::string,std::string> DocElement;
+
+bool CheckNonEmpty(const DocElement & elem)
+{
+  bool ret = true;
+  if (elem.second == "")
+    {
+    std::cout << "  /!\\ Missing "<< elem.first << std::endl;
+    ret = false;
+    }
+  return ret;
+}
+
+bool CheckMinimumSize(const DocElement & elem, unsigned int size)
+{
+  bool ret = true;
+  if (elem.second.size() < size)
+    {
+    std::cout<<"  /!\\ " << elem.first <<" too small..."<<std::endl;
+    ret = false;
+    }
+  return ret;
+}
+
+bool CheckNoNewline(const DocElement & elem)
+{
+  bool ret = true;
+  if (elem.second.find('\n') != std::string::npos)
+    {
+    std::cout << "  /!\\ "<< elem.first << " should not contain newlines"<<std::endl;
+    ret = false;
+    }
+  return ret;
+}
+
+bool CheckNoTrailingNewline(const DocElement & elem)
+{
+  bool ret = true;
+  std::string whitespace(" \t\f\v\r");
+  size_t pos = elem.second.find_last_not_of(whitespace);
+  if (pos != std::string::npos && elem.second.at(pos) == '\n')
+    {
+    std::cout << "  /!\\ "<< elem.first << " should not end with a newline" << std::endl;
+    ret = false;
+    }
+  return ret;
+}
+
+bool CheckMultiline(const DocElement & elem)
+{
+  bool ret = true;
+  std::string whitespace(" \t\f\v\r");
+  size_t pos = elem.second.find('\n');
+  size_t lastPos = elem.second.find_last_not_of(whitespace);
+  if (pos == std::string::npos || pos == lastPos)
+    {
+    std::cout << "  /!\\ "<< elem.first << " should not be a single line" << std::endl;
+    ret = false;
+    }
+  return ret;
+}
+
 int otbWrapperApplicationDocTest(int argc, char* argv[])
 {
   if (argc < 2)
@@ -69,46 +131,34 @@ int otbWrapperApplicationDocTest(int argc, char* argv[])
       }
 
     // Check doc element...
-    if( std::string(app->GetName()) == "" )
-      {
-      std::cout<<"Missing Name."<<std::endl;
-      isOK = false;
-      }
-    if( std::string(app->GetDocName()) == "" )
-      {
-      std::cout<<"Missing Doc Name."<<std::endl;
-      isOK = false;
-      }
-    if( std::string(app->GetDescription()) == "" )
-      {
-      std::cout<<"Missing Description."<<std::endl;
-      isOK = false;
-      }
-    if( std::string(app->GetDocLongDescription()) == "" )
-      {
-      std::cout<<"Missing DocLongDescription."<<std::endl;
-      isOK = false;
-      }
-    else if( std::string(app->GetDocLongDescription()).size() < 30 )
-      {
-      std::cout<<"DocLongDescription too small..."<<std::endl;
-      isOK = false;
-      }
-    if( std::string(app->GetDocAuthors()) == "" )
-      {
-      std::cout<<"Missing DocAuthors."<<std::endl;
-      isOK = false;
-      }
-    if( std::string(app->GetDocLimitations()) == "" )
-      {
-      std::cout<<"Missing DocLimitations."<<std::endl;
-      isOK = false;
-      }
-    if( std::string(app->GetDocSeeAlso()) == "" )
-      {
-      std::cout<<"Missing DocSeeAlso."<<std::endl;
-      isOK = false;
-      }
+    DocElement name("Name",app->GetName());
+    DocElement docName("Doc Name",app->GetDocName());
+    DocElement description("Description",app->GetDescription());
+    DocElement longDescription("Long description",app->GetDocLongDescription());
+    DocElement authors("DocAuthors",app->GetDocAuthors());
+    DocElement limitations("DocLimitations",app->GetDocLimitations());
+    DocElement seeAlso("DocSeeAlso",app->GetDocSeeAlso());
+
+    isOK = CheckNonEmpty(name) && isOK;
+    isOK = CheckNoNewline(name) && isOK;
+
+    isOK = CheckNonEmpty(docName) && isOK;
+    isOK = CheckNoNewline(docName) && isOK;
+
+    isOK = CheckNonEmpty(description) && isOK;
+
+    isOK = CheckNonEmpty(longDescription) && isOK;
+    isOK = CheckMinimumSize(longDescription,30) && isOK;
+    isOK = CheckNoTrailingNewline(longDescription) && isOK;
+    //isOK = CheckMultiline(longDescription) && isOK;
+
+    isOK = CheckNonEmpty(authors) && isOK;
+
+    isOK = CheckNonEmpty(limitations) && isOK;
+
+    isOK = CheckNonEmpty(seeAlso) && isOK;
+    // TODO : check format of SeeAlso section
+
     if( app->GetDocTags().size() == 0 )
       {
       std::cout<<"Missing DocTags."<<std::endl;
diff --git a/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx b/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx
index 7c73c7d..cdde4cc 100644
--- a/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx
+++ b/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx
@@ -139,8 +139,8 @@ SetParameterDescription("texture.simple","This group of parameters defines the 8
     Inertia, Cluster Shade, Cluster Prominence and Haralick Correlation");
 
 AddChoice("texture.advanced", "Advanced Texture Features");
-SetParameterDescription("texture.advanced","This group of parameters defines the 9 advanced texture feature output image.\
-    The image channels are: Mean, Variance, Sum Average, Sum Variance,\
+SetParameterDescription("texture.advanced","This group of parameters defines the 10 advanced texture feature output image.\
+    The image channels are: Mean, Variance, Dissimilarity, Sum Average, Sum Variance,\
     Sum Entropy, Difference of Entropies, Difference of Variances, IC1 and IC2");
 
 AddChoice("texture.higher", "Higher Order Texture Features");
diff --git a/Modules/Core/CommandLineParser/test/otbTestCommandLineArgumentParserHelp.cxx b/Modules/Core/CommandLineParser/test/otbTestCommandLineArgumentParserHelp.cxx
index 7b27a8b..454fc55 100644
--- a/Modules/Core/CommandLineParser/test/otbTestCommandLineArgumentParserHelp.cxx
+++ b/Modules/Core/CommandLineParser/test/otbTestCommandLineArgumentParserHelp.cxx
@@ -24,7 +24,6 @@
 #include "itkMacro.h"
 #include "otbCommandLineArgumentParser.h"
 
-// Test de sortie en erreur
 int otbTestCommandLineArgumentParserHelp(int argc, char * argv[])
 {
   try
diff --git a/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.txx b/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.txx
index 13856ec..b9bb88e 100644
--- a/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.txx
+++ b/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.txx
@@ -25,7 +25,7 @@
 #include "otbMath.h"
 #include "otbMacro.h"
 
-// Defaut when no tile hint available
+// Default when no tile hint available
 #include "otbImageRegionSquareTileSplitter.h"
 
 namespace otb
diff --git a/Modules/Core/Common/include/otbModelComponentBase.h b/Modules/Core/Common/include/otbModelComponentBase.h
index 58b3642..1bb6180 100644
--- a/Modules/Core/Common/include/otbModelComponentBase.h
+++ b/Modules/Core/Common/include/otbModelComponentBase.h
@@ -126,7 +126,7 @@ public:
   /** Show the parameters in a minimal form in comparison to PrintSelf */
   virtual void ShowParameters(std::ostream& os, itk::Indent indent) const;
 
-  // TODO: Distance entre distribution via une sorte de fonction membre...
+  // TODO: Distance between distributions with some kind of member function...
 
 protected:
   ModelComponentBase();
diff --git a/Modules/Core/Common/include/otbUnaryFunctorImageFilter.h b/Modules/Core/Common/include/otbUnaryFunctorImageFilter.h
index 798d8fe..2217de5 100644
--- a/Modules/Core/Common/include/otbUnaryFunctorImageFilter.h
+++ b/Modules/Core/Common/include/otbUnaryFunctorImageFilter.h
@@ -32,7 +32,7 @@ namespace otb
  * Add the capability to change the number of channel when operation on
  * VectorImage compared to the itk::UnaryFunctorImageFilter
  *
- * The number of channel is provided by the functor: TFunction::OutputSize. If
+ * The number of channel is provided by the functor: TFunction::GetOutputSize. If
  * this number is lower or equal to zero, the behavior of the itk::UnaryFunctorImageFilter
  * remains unchanged.
  *
diff --git a/Modules/Core/Common/src/otbConfigure.h.in b/Modules/Core/Common/src/otbConfigure.h.in
index d6968cb..5194398 100644
--- a/Modules/Core/Common/src/otbConfigure.h.in
+++ b/Modules/Core/Common/src/otbConfigure.h.in
@@ -31,3 +31,7 @@
 #cmakedefine OTB_SHOW_ALL_MSG_DEBUG
 
 #cmakedefine OTB_USE_GDAL_20
+
+#cmakedefine OTB_USE_OPENMP
+
+#cmakedefine OTB_USE_SSE_FLAGS
diff --git a/Modules/Core/ImageBase/include/otbExtractROIBase.txx b/Modules/Core/ImageBase/include/otbExtractROIBase.txx
index 655be5f..b7c6e0e 100644
--- a/Modules/Core/ImageBase/include/otbExtractROIBase.txx
+++ b/Modules/Core/ImageBase/include/otbExtractROIBase.txx
@@ -307,10 +307,13 @@ ExtractROIBase<TInputImage, TOutputImage>
   outputPtr->SetSpacing(outputSpacing);
   outputPtr->SetDirection(outputDirection);
   outputPtr->SetOrigin(outputOrigin);
-// THOMAS : dans ITK ce code est present, mais pas dans notre cas, car le nombre de composantes/pixel depend des canaux selectionnes par l'utilisateur
-//          ce parametre est renseignes dans les classes sous-jacentes
+
+// Thomas Feuvrier:
+// ITK has this code. But not in our case, because the number of component per pixel depends on the bands selected by the user.
+// This parameter is given in the underlying classes.
 //    outputPtr->SetNumberOfComponentsPerPixel(
 //       inputPtr->GetNumberOfComponentsPerPixel() );
+//
 }
 
 } // end namespace otb
diff --git a/Modules/Core/ImageBase/include/otbImage.h b/Modules/Core/ImageBase/include/otbImage.h
index f3c10b8..c13d9b9 100644
--- a/Modules/Core/ImageBase/include/otbImage.h
+++ b/Modules/Core/ImageBase/include/otbImage.h
@@ -197,10 +197,10 @@ protected:
   ~Image() ITK_OVERRIDE {}
 
 private:
-  Image(const Self &); //purposely not implemented
+  Image(const Self &) = delete;
   void operator =(const Self&); //purposely not implemented
 
-  /** Return the ImageMetadataInterfacePointer associated to the data
+    /** Return the ImageMetadataInterfacePointer associated to the data
    *  and creates it on first call
    */
   ImageMetadataInterfacePointerType GetMetaDataInterface() const;
diff --git a/Modules/Core/ImageBase/include/otbImageOfVectorsToMonoChannelExtractROI.h b/Modules/Core/ImageBase/include/otbImageOfVectorsToMonoChannelExtractROI.h
index 1a312c5..21910cc 100644
--- a/Modules/Core/ImageBase/include/otbImageOfVectorsToMonoChannelExtractROI.h
+++ b/Modules/Core/ImageBase/include/otbImageOfVectorsToMonoChannelExtractROI.h
@@ -74,7 +74,7 @@ public:
   typedef typename OutputImageType::SizeType  OutputImageSizeType;
   typedef typename InputImageType::SizeType   InputImageSizeType;
 
-  /** Selectionne le canal a traiter */
+  /** Select the channel to process */
   itkSetMacro(Channel, unsigned int);
   itkGetConstMacro(Channel, unsigned int);
 
diff --git a/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.h b/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.h
index 65dd421..2724bcf 100644
--- a/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.h
+++ b/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.h
@@ -81,7 +81,7 @@ public:
   typedef typename OutputImageType::SizeType  OutputImageSizeType;
   typedef typename InputImageType::SizeType   InputImageSizeType;
 
-  /** Selectionne le canal a traiter */
+  /** Select the channel to process */
   itkSetMacro(Channel, unsigned int);
   itkGetConstMacro(Channel, unsigned int);
 
diff --git a/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.txx b/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.txx
index 6ba3fd8..2d2ff06 100644
--- a/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.txx
+++ b/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.txx
@@ -101,7 +101,7 @@ MultiToMonoChannelExtractROI<TInputPixelType, TOutputPixelType>
   OutputIterator outIt(outputPtr, outputRegionForThread);
   InputIterator inIt(inputPtr, inputRegionForThread);
 
-  // Parcours des canaux a traiter
+  // Go through channels to process
   const unsigned int channelIn(m_Channel - 1);
 
   while (!outIt.IsAtEnd())
diff --git a/Modules/Core/ImageBase/src/otbImageIOBase.cxx b/Modules/Core/ImageBase/src/otbImageIOBase.cxx
index d88d601..1e01c55 100644
--- a/Modules/Core/ImageBase/src/otbImageIOBase.cxx
+++ b/Modules/Core/ImageBase/src/otbImageIOBase.cxx
@@ -1320,8 +1320,8 @@ ImageIOBase
 void ImageIOBase::PrintSelf(std::ostream& os, itk::Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
-
-  os << indent << "FileName: " << m_FileName << std::endl;
+  using namespace std::string_literals;
+  os << indent << "FileName: "s << m_FileName << std::endl;
   os << indent << "FileType: " << this->GetFileTypeAsString(m_FileType) << std::endl;
   os << indent << "ByteOrder: " << this->GetByteOrderAsString(m_ByteOrder) << std::endl;
   os << indent << "IORegion: " << std::endl;
diff --git a/Modules/Core/ImageBase/test/otbMultiToMonoChannelExtractROI.cxx b/Modules/Core/ImageBase/test/otbMultiToMonoChannelExtractROI.cxx
index b454cb3..a47f7b3 100644
--- a/Modules/Core/ImageBase/test/otbMultiToMonoChannelExtractROI.cxx
+++ b/Modules/Core/ImageBase/test/otbMultiToMonoChannelExtractROI.cxx
@@ -87,7 +87,7 @@ int generic_otbMultiToMonoChannelExtractROI(int itkNotUsed(argc),
 
   reader->SetFileName(inputFilename);
   //THOMAS
-  //        reader->Update(); //Necessaire pour connaitre le nombre de canaux dans l'image
+  //        reader->Update(); // Needed to know the number of channels in the image
   writer->SetFileName(outputFilename);
   extractROIFilter->SetInput(reader->GetOutput());
 
diff --git a/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.h b/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.h
index c7142a0..eb2dfbc 100644
--- a/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.h
+++ b/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.h
@@ -242,14 +242,14 @@ public:
 
   /**
    * Set/Get whether the maximum Feret diameter should be computed or not. The
-   * defaut value is false, because of the high computation time required.
+   * default value is false, because of the high computation time required.
    */
   void SetComputeFeretDiameter(bool flag);
   bool GetComputeFeretDiameter() const;
   itkBooleanMacro(ComputeFeretDiameter);
 
   /**
-   * Set/Get whether the perimeter should be computed or not. The defaut value
+   * Set/Get whether the perimeter should be computed or not. The default value
    * is false, because of the high computation time required.
    */
   void SetComputePerimeter(bool flag);
diff --git a/Modules/Core/SpatialObjects/include/otbLineSpatialObject.h b/Modules/Core/SpatialObjects/include/otbLineSpatialObject.h
index cc04dac..a4adf2d 100644
--- a/Modules/Core/SpatialObjects/include/otbLineSpatialObject.h
+++ b/Modules/Core/SpatialObjects/include/otbLineSpatialObject.h
@@ -64,6 +64,8 @@ public:
   typedef std::vector<LinePointType>                     PointListType;
   typedef itk::VectorContainer<unsigned long, PointType> PointContainerType;
   typedef itk::SmartPointer<PointContainerType>          PointContainerPointer;
+  typedef itk::SizeValueType SizeValueType;
+  typedef itk::IdentifierType IdentifierType;
 
   /** Returns a reference to the list of the Line points.*/
   PointListType& GetPoints(void);
@@ -72,19 +74,19 @@ public:
   void SetPoints(PointListType& newPoints);
 
   /** Return a point in the list given the index */
-  const SpatialObjectPointType* GetPoint(unsigned long id) const ITK_OVERRIDE
+  const SpatialObjectPointType* GetPoint(IdentifierType id) const ITK_OVERRIDE
   {
     return &(m_Points[id]);
   }
 
   /** Return a point in the list given the index */
-  SpatialObjectPointType* GetPoint(unsigned long id) ITK_OVERRIDE
+  SpatialObjectPointType* GetPoint(IdentifierType id) ITK_OVERRIDE
   {
     return &(m_Points[id]);
   }
 
   /** Return the number of points in the list */
-  itk::SizeValueType GetNumberOfPoints(void) const ITK_OVERRIDE
+  SizeValueType GetNumberOfPoints(void) const ITK_OVERRIDE
   {
     return m_Points.size();
   }
diff --git a/Modules/Core/Transform/include/otbGeoInformationConversion.h b/Modules/Core/Transform/include/otbGeoInformationConversion.h
index 3fd9b45..d20f786 100644
--- a/Modules/Core/Transform/include/otbGeoInformationConversion.h
+++ b/Modules/Core/Transform/include/otbGeoInformationConversion.h
@@ -33,7 +33,9 @@ namespace otb
  *  \brief Helper functions to do the geo information conversions used frequently.
  *
  *  This namespace provides helpers functions to build a WKT from a valid EPSG number using
- *  the method ToWKT(int srid).
+ *  the method ToWKT(int srid), and also to retrieve an EPSG number from a WKT
+ *  using the method ToEPSG(const std::string &)
+ *
  */
 namespace GeoInformationConversion
 {
@@ -43,6 +45,13 @@ namespace GeoInformationConversion
 
   /** this method try to morph a wkt to ESRI WKT format and returns the error code**/
   OTBTransform_EXPORT bool IsESRIValidWKT(const std::string &Wkt);
+
+  /** Function used to get an epsg number from a wkt string.
+   *  Returns -1 if the wkt is neither a PROJCS nor a GEOGCS.
+   *  Returns 0 if no authority code is found but wkt has a PROJCS or a GEOGCS.
+   *  Otherwise the EPSG authority code is returned
+   */
+  OTBTransform_EXPORT int ToEPSG(const std::string &wkt);
 }
 
 } // End namespace otb
diff --git a/Modules/Core/Transform/include/otbSensorModelBase.h b/Modules/Core/Transform/include/otbSensorModelBase.h
index 5b73cb1..07d4e23 100644
--- a/Modules/Core/Transform/include/otbSensorModelBase.h
+++ b/Modules/Core/Transform/include/otbSensorModelBase.h
@@ -36,7 +36,7 @@ namespace otb
  *  \brief Base class for the sensor model projection classes.
  *
  *  This class allows transforming a geographic point in (lat, long) to a point
- *  in the sensor geometry.  (lat, lon) -> (i, j) ou (lat, lon, h) -> (i, j)
+ *  in the sensor geometry.  (lat, lon) -> (i, j) or (lat, lon, h) -> (i, j)
  *
  * \ingroup Projection
  *
diff --git a/Modules/Core/Transform/src/otbGeoInformationConversion.cxx b/Modules/Core/Transform/src/otbGeoInformationConversion.cxx
index 635b8cf..4beb0cd 100644
--- a/Modules/Core/Transform/src/otbGeoInformationConversion.cxx
+++ b/Modules/Core/Transform/src/otbGeoInformationConversion.cxx
@@ -73,4 +73,35 @@ bool GeoInformationConversion::IsESRIValidWKT(const std::string &wkt)
   return SRS.Validate()==OGRERR_NONE;
 }
 
+int GeoInformationConversion::ToEPSG(const std::string &wkt)
+{
+  int code = -1;
+  OGRSpatialReference srs(wkt.c_str());
+  srs.Fixup();
+  srs.AutoIdentifyEPSG();
+  const char * epsg = nullptr;
+  if (srs.IsGeographic())
+    {
+    code = 0;
+    epsg = srs.GetAuthorityCode("GEOGCS");
+    }
+  else if (srs.IsProjected())
+    {
+    code = 0;
+    epsg = srs.GetAuthorityCode("PROJCS");
+    }
+  if (epsg!=nullptr && strcmp( epsg, "" )!=0 )
+    {
+    try
+      {
+      code = boost::lexical_cast<int>(epsg);
+      }
+    catch(boost::bad_lexical_cast &)
+      {
+      code = 0;
+      }
+    }
+  return code;
+}
+
 } // End namespace otb
diff --git a/Modules/Feature/Descriptors/include/otbHistogramOfOrientedGradientCovariantImageFunction.h b/Modules/Feature/Descriptors/include/otbHistogramOfOrientedGradientCovariantImageFunction.h
index ebe2729..6a464dd 100644
--- a/Modules/Feature/Descriptors/include/otbHistogramOfOrientedGradientCovariantImageFunction.h
+++ b/Modules/Feature/Descriptors/include/otbHistogramOfOrientedGradientCovariantImageFunction.h
@@ -59,7 +59,7 @@ namespace otb
  * all lie in the range $[0, 1]$.
  *
  * This class is templated over the input image type, the output
- * precision (e.g. float ou double) and the
+ * precision (e.g. float or double) and the
  * coordinate representation type (e.g. float or double).
 
  * \ingroup ImageFunctions
diff --git a/Modules/Feature/Descriptors/test/otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii.cxx b/Modules/Feature/Descriptors/test/otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii.cxx
index 4a2a416..d5f0f32 100644
--- a/Modules/Feature/Descriptors/test/otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii.cxx
+++ b/Modules/Feature/Descriptors/test/otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii.cxx
@@ -36,9 +36,9 @@ bool CMP(std::vector<float>  a, std::vector<float>  b)
   return lexicographical_compare(a.begin(), a.begin() + 2, b.begin(), b.begin() + 2);
 }
 
-int otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii(int itkNotUsed(argc), char * argv[])
+int
+otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii( int itkNotUsed( argc ), char * argv[] )
 {
-
   const char * infname = argv[1];
   const char * outfname = argv[2];
 
@@ -59,7 +59,7 @@ int otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii(int itkNotUsed(a
   typedef PointSetType::PointDataContainer PointDataContainerType;
   typedef PointDataContainerType::Iterator PointDataIteratorType;
 
-  typedef std::vector<float>          siftDataVector;
+  typedef std::vector< RealType > siftDataVector;
   typedef std::vector<siftDataVector> ImageDataType;   //Kind of PointSet with vectors
 
   // Instantiating object
@@ -76,10 +76,29 @@ int otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii(int itkNotUsed(a
   PointsIteratorType    pIt = filter->GetOutput()->GetPoints()->Begin();
   PointDataIteratorType pDataIt = filter->GetOutput()->GetPointData()->Begin();
 
+  assert(
+    filter->GetOutput()->GetPoints()->Size() ==
+    filter->GetOutput()->GetPointData()->Size() );
+
   std::ofstream outfile(outfname);
 
   outfile << "Number of scales: " << scales << std::endl;
-  outfile << "Number of SIFT key points: " << filter->GetOutput()->GetNumberOfPoints() << std::endl;
+
+  outfile << "Number of SIFT key points: "
+	  << filter->GetOutput()->GetNumberOfPoints()
+	  << std::endl;
+
+  outfile << "Number of points: "
+	  << filter->GetOutput()->GetPoints()->Size()
+	  << std::endl;
+
+  outfile << "Number of points data: "
+	  << filter->GetOutput()->GetPointData()->Size()
+	  << std::endl;
+
+  if( filter->GetOutput()->GetPoints()->Size() !=
+      filter->GetOutput()->GetPointData()->Size() )
+    return EXIT_FAILURE;
 
   // Copy the PointSet to std::vector< std::vector >
   while (pIt != filter->GetOutput()->GetPoints()->End())
diff --git a/Modules/Feature/Edge/include/otbLineDetectorImageFilterBase.txx b/Modules/Feature/Edge/include/otbLineDetectorImageFilterBase.txx
index c98f2ba..7fb19ba 100644
--- a/Modules/Feature/Edge/include/otbLineDetectorImageFilterBase.txx
+++ b/Modules/Feature/Edge/include/otbLineDetectorImageFilterBase.txx
@@ -52,7 +52,7 @@ LineDetectorImageFilterBase<TInputImage, TOutputImage, TOutputImageDirection, In
   m_Threshold = 0;
   m_NumberOfDirections = 4;
   m_FaceList.Fill(0);
-// THOMAS : donc contructeur de base
+// THOMAS : hence base constructor
 //  this->SetNthOutput(0, OutputImageType::New());
 //  this->SetNthOutput(1, OutputImageType::New());
 }
diff --git a/Modules/Feature/Textures/include/otbSFSTexturesFunctor.h b/Modules/Feature/Textures/include/otbSFSTexturesFunctor.h
index 45c24ff..b1b9ee1 100644
--- a/Modules/Feature/Textures/include/otbSFSTexturesFunctor.h
+++ b/Modules/Feature/Textures/include/otbSFSTexturesFunctor.h
@@ -95,11 +95,13 @@ public:
   }
   void SetTextureStatus(unsigned int id, bool isSelected){ m_SelectedTextures[id] = isSelected; }
 
-  unsigned int GetSpatialThreshold(){ return m_SpatialThreshold; }
-  InternalPixelType GetSpectralThreshold(){ return m_SpectralThreshold; }
-  unsigned int GetRatioMaxConsiderationNumber(){ return m_RatioMaxConsiderationNumber; }
-  double  GetAlpha(){ return m_Alpha; }
-  unsigned int GetNumberOfDirections(){ return m_NumberOfDirections(); }
+  // Define some getters using itkGetMacro
+  itkGetMacro(SpatialThreshold,unsigned int);
+  itkGetMacro(SpectralThreshold,InternalPixelType);
+  itkGetMacro(RatioMaxConsiderationNumber,unsigned int);
+  itkGetMacro(Alpha,double);
+  itkGetMacro(NumberOfDirections,unsigned int);
+  
   std::vector<bool> GetTexturesStatus(){ return m_SelectedTextures; }
 
   inline OutputType operator ()(const TIter& it)
diff --git a/Modules/Filtering/Convolution/include/otbConvolutionImageFilter.txx b/Modules/Filtering/Convolution/include/otbConvolutionImageFilter.txx
index 02b7937..95abd81 100644
--- a/Modules/Filtering/Convolution/include/otbConvolutionImageFilter.txx
+++ b/Modules/Filtering/Convolution/include/otbConvolutionImageFilter.txx
@@ -32,6 +32,7 @@
 
 #include "otbMacro.h"
 
+
 namespace otb
 {
 
@@ -123,6 +124,8 @@ ConvolutionImageFilter<TInputImage, TOutputImage, TBoundaryCondition, TFilterPre
   inputIt.GoToBegin();
   unsigned int neighborhoodSize = inputIt.Size();
 
+  double norm_double = 1.;
+  
   // Compute the norm of the filter
   if (m_NormalizeFilter)
     {
@@ -131,6 +134,7 @@ ConvolutionImageFilter<TInputImage, TOutputImage, TBoundaryCondition, TFilterPre
       {
       norm += static_cast<InputRealType>(vcl_abs(m_Filter(i)));
       }
+    norm_double = static_cast<double>(vcl_abs(norm));
     }
 
   while (!inputIt.IsAtEnd())
@@ -145,7 +149,7 @@ ConvolutionImageFilter<TInputImage, TOutputImage, TBoundaryCondition, TFilterPre
     // get the mean value
     if (m_NormalizeFilter)
       {
-      outputIt.Set(static_cast<OutputPixelType>(sum / double(norm)));
+      outputIt.Set(static_cast<OutputPixelType>(sum / norm_double));
       }
     else
       {
diff --git a/Modules/Filtering/DimensionalityReduction/include/otbMNFImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbMNFImageFilter.h
index ab384e3..50557f1 100644
--- a/Modules/Filtering/DimensionalityReduction/include/otbMNFImageFilter.h
+++ b/Modules/Filtering/DimensionalityReduction/include/otbMNFImageFilter.h
@@ -35,7 +35,7 @@ namespace otb {
  * The high pass filter which has to be used for the noise estimation is templated
  * for a better scalability.
  *
- * TODO? Utiliser une 2e entree pour donner directement une image de bruit ?
+ * TODO? Use a 2nd input to give a noise image directly?
  *
  * \sa otbStreamingStatisticsVectorImageFilter
  * \sa PCAImageFiler
diff --git a/Modules/Filtering/DimensionalityReduction/include/otbNAPCAImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbNAPCAImageFilter.h
index 6f1e4b9..c784777 100644
--- a/Modules/Filtering/DimensionalityReduction/include/otbNAPCAImageFilter.h
+++ b/Modules/Filtering/DimensionalityReduction/include/otbNAPCAImageFilter.h
@@ -38,7 +38,7 @@ namespace otb {
  * matrix definition (through GenerateTransformationMatrix function)
  * differs.
  *
- * TODO? Utiliser une 2e entree pour donner directement une image de bruit ??
+ * TODO? Use a 2nd input to give a noise image directly?
  *
  * \sa otbStreamingStatisticsVectorImageFilter
  * \sa MNFImageFilter
diff --git a/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorImageFilter.h
new file mode 100644
index 0000000..e0e246a
--- /dev/null
+++ b/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorImageFilter.h
@@ -0,0 +1,84 @@
+/*=========================================================================
+
+  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 otbBinaryFunctorImageFilter_h
+#define otbBinaryFunctorImageFilter_h
+
+#include "itkBinaryFunctorImageFilter.h"
+
+namespace otb
+{
+/**
+ * \class BinaryFunctorImageFilter
+ * \brief Implements pixel-wise generic operation on two images.
+ *
+ * Add the capability to change the number of channel when operation on
+ * VectorImage compared to the itk::BinaryFunctorImageFilter
+ *
+ * The number of channel is provided by the functor: TFunction::GetOutputSize. If
+ * this number is lower or equal to zero, the behavior of the itk::BinaryFunctorImageFilter
+ * remains unchanged.
+ *
+ * \sa itk::BinaryFunctorImageFilter
+ *
+ * \ingroup OTBImageManipulation
+ */
+template <class TInputImage1, class TInputImage2, class TOutputImage, class TFunction>
+class ITK_EXPORT BinaryFunctorImageFilter : public itk::BinaryFunctorImageFilter<TInputImage1, TInputImage2, TOutputImage, TFunction>
+{
+public:
+  /** Standard class typedefs. */
+  typedef BinaryFunctorImageFilter                                            Self;
+  typedef itk::BinaryFunctorImageFilter<TInputImage1, TInputImage2, TOutputImage, TFunction> Superclass;
+  typedef itk::SmartPointer<Self>                                            Pointer;
+  typedef itk::SmartPointer<const Self>                                      ConstPointer;
+
+  /** Method for creation through the object factory. */
+  itkNewMacro(Self);
+
+  /** Run-time type information (and related methods). */
+  itkTypeMacro(BinaryFunctorImageFilter, itk::BinaryFunctorImageFilter);
+
+protected:
+  BinaryFunctorImageFilter() {};
+  ~BinaryFunctorImageFilter() ITK_OVERRIDE {}
+
+  /** BinaryFunctorImageFilter can produce an image which has a different number of bands
+   * than its input image.  As such, BinaryFunctorImageFilter
+   * needs to provide an implementation for
+   * GenerateOutputInformation() in order to inform the pipeline
+   * execution model.  The original documentation of this method is
+   * below.
+   *
+   * \sa ProcessObject::GenerateOutputInformaton()  */
+  void GenerateOutputInformation() ITK_OVERRIDE
+  {
+    Superclass::GenerateOutputInformation();
+    typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
+    outputPtr->SetNumberOfComponentsPerPixel( // propagate vector length info
+      this->GetFunctor().GetOutputSize());
+  }
+
+private:
+  BinaryFunctorImageFilter(const Self &); //purposely not implemented
+  void operator =(const Self&); //purposely not implemented
+
+};
+
+} // end namespace otb
+
+#endif
diff --git a/Modules/Filtering/ImageManipulation/include/otbTernaryFunctorImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbTernaryFunctorImageFilter.h
new file mode 100644
index 0000000..3e6d3f5
--- /dev/null
+++ b/Modules/Filtering/ImageManipulation/include/otbTernaryFunctorImageFilter.h
@@ -0,0 +1,84 @@
+/*=========================================================================
+
+  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 otbTernaryFunctorImageFilter_h
+#define otbTernaryFunctorImageFilter_h
+
+#include "itkTernaryFunctorImageFilter.h"
+
+namespace otb
+{
+/**
+ * \class TernaryFunctorImageFilter
+ * \brief Implements pixel-wise generic operation on three images.
+ *
+ * Add the capability to change the number of channel when operation on
+ * VectorImage compared to the itk::TernaryFunctorImageFilter
+ *
+ * The number of channel is provided by the functor: TFunction::GetOutputSize. If
+ * this number is lower or equal to zero, the behavior of the itk::TernaryFunctorImageFilter
+ * remains unchanged.
+ *
+ * \sa itk::TernaryFunctorImageFilter
+ *
+ * \ingroup OTBImageManipulation
+ */
+template <class TInputImage1, class TInputImage2, class TInputImage3, class TOutputImage, class TFunction>
+class ITK_EXPORT TernaryFunctorImageFilter : public itk::TernaryFunctorImageFilter<TInputImage1, TInputImage2, TInputImage3, TOutputImage, TFunction>
+{
+public:
+  /** Standard class typedefs. */
+  typedef TernaryFunctorImageFilter                                            Self;
+  typedef itk::TernaryFunctorImageFilter<TInputImage1, TInputImage2, TInputImage3, TOutputImage, TFunction> Superclass;
+  typedef itk::SmartPointer<Self>                                            Pointer;
+  typedef itk::SmartPointer<const Self>                                      ConstPointer;
+
+  /** Method for creation through the object factory. */
+  itkNewMacro(Self);
+
+  /** Run-time type information (and related methods). */
+  itkTypeMacro(TernaryFunctorImageFilter, itk::TernaryFunctorImageFilter);
+
+protected:
+  TernaryFunctorImageFilter() {};
+  ~TernaryFunctorImageFilter() ITK_OVERRIDE {}
+
+  /** TernaryFunctorImageFilter can produce an image which has a different number of bands
+   * than its input image.  As such, TernaryFunctorImageFilter
+   * needs to provide an implementation for
+   * GenerateOutputInformation() in order to inform the pipeline
+   * execution model.  The original documentation of this method is
+   * below.
+   *
+   * \sa ProcessObject::GenerateOutputInformaton()  */
+  void GenerateOutputInformation() ITK_OVERRIDE
+  {
+    Superclass::GenerateOutputInformation();
+    typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
+    outputPtr->SetNumberOfComponentsPerPixel( // propagate vector length info
+      this->GetFunctor().GetOutputSize());
+  }
+
+private:
+  TernaryFunctorImageFilter(const Self &); //purposely not implemented
+  void operator =(const Self&); //purposely not implemented
+
+};
+
+} // end namespace otb
+
+#endif
diff --git a/Modules/Filtering/ImageNoise/include/otbLeeImageFilter.h b/Modules/Filtering/ImageNoise/include/otbLeeImageFilter.h
index 0383ed5..6479cc5 100644
--- a/Modules/Filtering/ImageNoise/include/otbLeeImageFilter.h
+++ b/Modules/Filtering/ImageNoise/include/otbLeeImageFilter.h
@@ -111,7 +111,7 @@ protected:
    *  LEE filter:
    *\f$   R = E[I] + b(I-E[I])\f$ with \f$  b  = C^2r / ( C^2r + C^2v )\f$
    *          \f$ Cv = 1 / \sqrt(L) \f$ with L the number of look.
-   *          \f$ Cr = \sqrt(Var(I)) / E[I] avec Var(I) = E[I^2] - E[I]^2 \f$
+   *          \f$ Cr = \sqrt(Var(I)) / E[I] where Var(I) = E[I^2] - E[I]^2 \f$
    *
    * \sa ImageToImageFilter::ThreadedGenerateData(),
    *     ImageToImageFilter::GenerateData() */
diff --git a/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.txx b/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.txx
index 85f5407..4a5c0ed 100644
--- a/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.txx
+++ b/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.txx
@@ -191,7 +191,7 @@ MultiChannelsPolarimetricSynthesisFilter<TInputImage, TOutputImage, TFunction>
         }
       break;
 
-    // With 3 channels : HH HV VV ou HH VH VV
+    // With 3 channels : HH HV VV or HH VH VV
     case HH_HV_VV:
       while (!inputIt.IsAtEnd())
         {
diff --git a/Modules/Filtering/Polarimetry/test/CMakeLists.txt b/Modules/Filtering/Polarimetry/test/CMakeLists.txt
index 73045f5..d1c7762 100644
--- a/Modules/Filtering/Polarimetry/test/CMakeLists.txt
+++ b/Modules/Filtering/Polarimetry/test/CMakeLists.txt
@@ -74,7 +74,7 @@ otb_add_test(NAME saTvVectorMultiChannelsPolarimetricSynthesisFilter COMMAND otb
   --compare-image ${EPSILON_7}   ${BASELINE}/saTvMultiPolarimetricSynthesis1.tif
   ${TEMP}/resMultiPolarimetricSynthesis1.tif
   otbVectorMultiChannelsPolarimetricSynthesisFilter
-  ${INPUTDATA}/RSAT2_AltonaExtract_1000_1000_100_100.hdr
+  ${INPUTDATA}/RSAT2_AltonaExtract_1000_1000_100_100.tif
   ${TEMP}/resMultiPolarimetricSynthesis1.tif
   10.0     # PsiI
   0.0     # KhiI
diff --git a/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.txx b/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.txx
index 31ce15b..5dcf3cf 100644
--- a/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.txx
+++ b/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.txx
@@ -230,7 +230,7 @@ WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD>
     destRegion.SetSize(destSize);
 
 #if 0
-    // Contrairement a Wavelet::INVERSE, ici ca ne sera a rien apparemment...
+    // Contrary to Wavelet::INVERSE, this is useless apparently...
 
     // Region Padding
     LowPassOperatorType lowPassOperator;
diff --git a/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorNonThreadFilter.txx b/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorNonThreadFilter.txx
index c4d02c2..8f30610 100644
--- a/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorNonThreadFilter.txx
+++ b/Modules/Hyperspectral/AnomalyDetection/include/otbLocalRxDetectorNonThreadFilter.txx
@@ -112,9 +112,6 @@ LocalRxDetectorNonThreadFilter<TInputImage, TOutputImage>
 
   ImageRegionIteratorType outputIt(outputPtr, *fit);
 
-  //std::cout << "Region de la face list : " << *vectorFit << std::endl;
-  //std::cout << "Region dans le buffer : " << inputPtr->GetBufferedRegion() << std::endl;
-
   // Run Input Image
   for (inputIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd(); ++inputIt, ++outputIt)
     {
diff --git a/Modules/Hyperspectral/EndmembersExtraction/include/otbVcaImageFilter.txx b/Modules/Hyperspectral/EndmembersExtraction/include/otbVcaImageFilter.txx
index 919e3a6..014ff8e 100644
--- a/Modules/Hyperspectral/EndmembersExtraction/include/otbVcaImageFilter.txx
+++ b/Modules/Hyperspectral/EndmembersExtraction/include/otbVcaImageFilter.txx
@@ -233,7 +233,7 @@ void VCAImageFilter<TImage>::GenerateData()
   vnl_matrix<PrecisionType> A(m_NumberOfEndmembers, m_NumberOfEndmembers);
   A.fill(0);
   A(m_NumberOfEndmembers - 1, 0) = 1;
-  typename RandomVariateGeneratorType::Pointer randomGen = RandomVariateGeneratorType::New();
+  typename RandomVariateGeneratorType::Pointer randomGen = RandomVariateGeneratorType::GetInstance();
 
   for (unsigned int i = 0; i < m_NumberOfEndmembers; ++i)
     {
diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
index 968ec2a..812c938 100644
--- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
+++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
@@ -1578,7 +1578,7 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer)
   if (driverShortName == "NOT-FOUND")
     {
     itkExceptionMacro(
-      << "GDAL Writing failed : the image file name '" << m_FileName.c_str() << "' is not recognized by GDAL.");
+      << "GDAL Writing failed: the image file name '" << m_FileName.c_str() << "' is not recognized by GDAL.");
     }
 
   if (m_CanStreamWrite)
@@ -1664,9 +1664,7 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer)
 
   if (m_Dataset.IsNull())
     {
-    itkExceptionMacro(
-      << "GDAL Writing failed : Impossible to create the image file name '"
-      << m_FileName << "' : " << CPLGetLastErrorMsg() );
+    itkExceptionMacro(<< CPLGetLastErrorMsg());
     }
 
   /*----------------------------------------------------------------------*/
@@ -1768,19 +1766,26 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer)
   /* -------------------------------------------------------------------- */
   /*  Set the six coefficients of affine geoTransform                     */
   /* -------------------------------------------------------------------- */
-  itk::VariableLengthVector<double> geoTransform(6);
-  /// Reporting origin and spacing
-  // Beware : GDAL origin is at the corner of the top-left pixel
-  // whereas OTB/ITK origin is at the centre of the top-left pixel
-  geoTransform[0] = m_Origin[0] - 0.5*m_Spacing[0];
-  geoTransform[3] = m_Origin[1] - 0.5*m_Spacing[1];
-  geoTransform[1] = m_Spacing[0];
-  geoTransform[5] = m_Spacing[1];
-
-  // FIXME: Here component 1 and 4 should be replaced by the orientation parameters
-  geoTransform[2] = 0.;
-  geoTransform[4] = 0.;
-  dataset->SetGeoTransform(const_cast<double*>(geoTransform.GetDataPointer()));
+  if ( vcl_abs(m_Origin[0] - 0.5) > Epsilon
+    || vcl_abs(m_Origin[1] - 0.5) > Epsilon
+    || vcl_abs(m_Spacing[0] - 1.0) > Epsilon
+    || vcl_abs(m_Spacing[1] - 1.0) > Epsilon )
+    {
+    // Only set the geotransform if it is not identity (it may erase GCP)
+    itk::VariableLengthVector<double> geoTransform(6);
+    /// Reporting origin and spacing
+    // Beware : GDAL origin is at the corner of the top-left pixel
+    // whereas OTB/ITK origin is at the centre of the top-left pixel
+    geoTransform[0] = m_Origin[0] - 0.5*m_Spacing[0];
+    geoTransform[3] = m_Origin[1] - 0.5*m_Spacing[1];
+    geoTransform[1] = m_Spacing[0];
+    geoTransform[5] = m_Spacing[1];
+
+    // FIXME: Here component 1 and 4 should be replaced by the orientation parameters
+    geoTransform[2] = 0.;
+    geoTransform[4] = 0.;
+    dataset->SetGeoTransform(const_cast<double*>(geoTransform.GetDataPointer()));
+    }
 
   /* -------------------------------------------------------------------- */
   /*      Report metadata.                                                */
diff --git a/Modules/IO/IOGDAL/src/otbOGRIOHelper.cxx b/Modules/IO/IOGDAL/src/otbOGRIOHelper.cxx
index 8248ef8..53b6199 100644
--- a/Modules/IO/IOGDAL/src/otbOGRIOHelper.cxx
+++ b/Modules/IO/IOGDAL/src/otbOGRIOHelper.cxx
@@ -211,7 +211,7 @@ void OGRIOHelper
     otb::VectorDataKeywordlist kwl;
     for (int fieldNum = 0; fieldNum < feature->GetFieldCount(); ++fieldNum)
       {
-      if (feature->IsFieldSet(fieldNum))
+      if (ogr::version_proxy::IsFieldSetAndNotNull(feature, fieldNum))
         {
         kwl.AddField(feature->GetFieldDefnRef(fieldNum), feature->GetRawFieldRef(fieldNum));
         }
diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.h b/Modules/IO/ImageIO/include/otbImageFileReader.h
index daf6c58..631f9d7 100644
--- a/Modules/IO/ImageIO/include/otbImageFileReader.h
+++ b/Modules/IO/ImageIO/include/otbImageFileReader.h
@@ -54,19 +54,14 @@ public:
 
   /** Constructor. */
   ImageFileReaderException(const char *file, unsigned int line,
-                           const char* message = "Error in IO",
-                           const char* loc = "Unknown") :
-    ExceptionObject(file, line, message, loc)
+                           const std::string& desc = "",
+                           const std::string& filename = "") :
+    ExceptionObject(file, line, desc),
+    m_Filename(filename)
   {
   }
 
-  /** Constructor. */
-  ImageFileReaderException(const std::string &file, unsigned int line,
-                           const char* message = "Error in IO",
-                           const char* loc = "Unknown") :
-    ExceptionObject(file, line, message, loc)
-  {
-  }
+  std::string m_Filename;
 };
 
 /** \class ImageFileReader
@@ -170,12 +165,10 @@ protected:
   void DoConvertBuffer(void* buffer, size_t numberOfPixels);
 
 private:
-  /** Test whether the given filename exist and it is readable,
-      this is intended to be called before attempting to use
-      ImageIO classes for actually reading the file. If the file
-      doesn't exist or it is not readable, and exception with an
-      appropriate message will be thrown. */
-  void TestFileExistenceAndReadability();
+  /** Test whether m_ImageIO is valid (not NULL). This is intended to be called
+   * after trying to create it via an ImageIOFactory. Throws an exception with
+   * an appropriate message otherwise. */
+  void TestValidImageIO();
 
   /** Generate the filename (for GDALImageI for example). If filename is a directory, look if is a
     * CEOS product (file "DAT...") In this case, the GdalFileName contain the open image file.
@@ -196,8 +189,6 @@ private:
 
   bool m_UseStreaming;
 
-  std::string   m_ExceptionMessage;
-
   // The region that the ImageIO class will return when we ask to
   // produce the requested region.
   itk::ImageIORegion m_ActualIORegion;
diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx
index cf647aa..966fe43 100644
--- a/Modules/IO/ImageIO/include/otbImageFileReader.txx
+++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx
@@ -65,7 +65,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
    m_UserSpecifiedImageIO(false),
    m_FileName(""),
    m_UseStreaming(true),
-   m_ExceptionMessage(""),
    m_ActualIORegion(),
    m_FilenameHelper(FNameHelperType::New()),
    m_AdditionalNumber(0),
@@ -129,9 +128,9 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
   output->SetBufferedRegion(output->GetRequestedRegion());
   output->Allocate();
 
-  // Test if the file exist and if it can be open.
-  // An exception will be thrown otherwise.
-  this->TestFileExistenceAndReadability();
+  // Raise an exception if the file could not be opened
+  // i.e. if this->m_ImageIO is Null
+  this->TestValidImageIO();
 
   // Tell the ImageIO to read the file
   OutputImagePixelType *buffer =
@@ -242,8 +241,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
       }
     else
       {
-      throw otb::ImageFileReaderException(__FILE__, __LINE__,
-                                          "Invalid output object type");
+      throw otb::ImageFileReaderException(__FILE__, __LINE__, "Invalid output object type");
       }
     }
 }
@@ -253,74 +251,32 @@ void
 ImageFileReader<TOutputImage, ConvertPixelTraits>
 ::GenerateOutputInformation(void)
 {
-
   typename TOutputImage::Pointer output = this->GetOutput();
 
-  itkDebugMacro(<< "Reading file for GenerateOutputInformation()" << this->m_FileName);
-
   // Check to see if we can read the file given the name or prefix
-  //
   if (this->m_FileName == "")
-    {
-    throw otb::ImageFileReaderException(__FILE__, __LINE__, "FileName must be specified");
-    }
+  {
+    throw otb::ImageFileReaderException(__FILE__, __LINE__, "Filename must be specified.");
+  }
 
   // Find real image file name
   // !!!!  Update FileName
   std::string lFileName;
-  bool        found = GetGdalReadImageFileName(this->m_FileName, lFileName);
-  if (found == false)
-    {
-    otbMsgDebugMacro(<< "Filename was NOT unknown. May be recognized by a Image factory ! ");
-    }
-  // Update FileName
-  this->m_FileName = lFileName;
-
-  // Test if the file exists and if it can be opened.
-  // An exception will be thrown otherwise.
-  // We catch the exception because some ImageIO's may not actually
-  // open a file. Still reports file error if no ImageIO is loaded.
-  
-  try
-    {
-    m_ExceptionMessage = "";
-    this->TestFileExistenceAndReadability();
-    }
-  catch (itk::ExceptionObject & err)
-    {
-    m_ExceptionMessage = err.GetDescription();
-    }
-  
+  bool found = GetGdalReadImageFileName(this->m_FileName, lFileName);
+  if (found)
+  {
+    // Update FileName
+    this->m_FileName = lFileName;
+  }
+
   if (this->m_UserSpecifiedImageIO == false)   //try creating via factory
-    {
+  {
     this->m_ImageIO = ImageIOFactory::CreateImageIO(this->m_FileName.c_str(), otb::ImageIOFactory::ReadMode);
-    }
-  
-  if (this->m_ImageIO.IsNull())
-    {
-    //this->Print(std::cerr);
-    otb::ImageFileReaderException e(__FILE__, __LINE__);
-    std::ostringstream msg;
-    msg << " Could not create IO object for file "
-        << this->m_FileName.c_str() << std::endl;
-    msg << "  Tried to create one of the following:" << std::endl;
-    std::list<itk::LightObject::Pointer> allobjects =
-      itk::ObjectFactoryBase::CreateAllInstance("otbImageIOBase");
-    for (std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin();
-         i != allobjects.end(); ++i)
-      {
-      otb::ImageIOBase* io = dynamic_cast<otb::ImageIOBase*>(i->GetPointer());
-      // IO should never be null, but we would better check for it
-      if(io)
-        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());
-    throw e;
-    return;
-    }
+  }
 
+  // Raise an exception if the file could not be opened
+  // i.e. if this->m_ImageIO is Null
+  this->TestValidImageIO();
 
   // Get the ImageIO MetaData Dictionary
   itk::MetaDataDictionary& dict = this->m_ImageIO->GetMetaDataDictionary();
@@ -331,7 +287,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
   bool lVectorImage = false;
   if (strcmp(output->GetNameOfClass(), "VectorImage") == 0)
     lVectorImage= true;
-  
+
   this->m_ImageIO->SetOutputImagePixelType(PixelIsComplex(dummy),lVectorImage);
 
   // Pass the dataset number (used for hdf files for example)
@@ -359,9 +315,9 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
   //
   this->m_ImageIO->SetFileName(this->m_FileName.c_str());
   this->m_ImageIO->ReadImageInformation();
-  // Initialization du nombre de Composante par pixel
-// THOMAS ceci n'est pas dans ITK !!
-//  output->SetNumberOfComponentsPerPixel(this->m_ImageIO->GetNumberOfComponents());
+  // Initialize the number of component per pixel
+  // THOMAS: This is not in ITK!
+  // output->SetNumberOfComponentsPerPixel(this->m_ImageIO->GetNumberOfComponents());
 
   SizeType                             dimSize;
   double                               spacing[TOutputImage::ImageDimension];
@@ -435,9 +391,9 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
 
   if(!m_KeywordListUpToDate && !m_FilenameHelper->GetSkipGeom())
     {
-    
+
     std::string lFileNameOssimKeywordlist = GetDerivedDatasetSourceFileName(m_FileName);
-  
+
     // Update otb Keywordlist
     ImageKeywordlist otb_kwl;
     if (!m_FilenameHelper->ExtGEOMFileNameIsSet())
@@ -450,7 +406,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
       otb_kwl = ReadGeometryFromGEOMFile(m_FilenameHelper->GetExtGEOMFileName());
       otbMsgDevMacro(<< "Loading external kwl");
       }
-    
+
     // Don't add an empty ossim keyword list
     if(!otb_kwl.Empty())
       {
@@ -511,7 +467,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
 
     }
 
-  
+
   // If Skip ProjectionRef is activated, remove ProjRef from dict
   if (m_FilenameHelper->GetSkipCarto())
     {
@@ -576,9 +532,9 @@ std::string
 ImageFileReader<TOutputImage, ConvertPixelTraits>
 ::GetDerivedDatasetSourceFileName(const std::string & filename) const
 {
-  
+
   const size_t dsds_pos = filename.find(DerivedSubdatasetPrefix);
-  
+
   if(dsds_pos != std::string::npos)
       {
       // Derived subdataset from gdal
@@ -595,50 +551,22 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
 template <class TOutputImage, class ConvertPixelTraits>
 void
 ImageFileReader<TOutputImage, ConvertPixelTraits>
-::TestFileExistenceAndReadability()
+::TestValidImageIO()
 {
-  // Test if the file a server name : if so the test is skipped
-  if (this->m_FileName.find(std::string("http://")) == 0 ||
-      this->m_FileName.find(std::string("https://")) == 0)
-    {
-    return;
-    }
+  if (this->m_ImageIO.IsNull())
+  {
+    std::string fileToCheck = GetDerivedDatasetSourceFileName(m_FileName);
 
-  std::string fileToCheck = GetDerivedDatasetSourceFileName(m_FileName);
-  
-  // Test if the file exists.
-  if (!itksys::SystemTools::FileExists(fileToCheck.c_str()))
+    // Test if the file exists.
+    if (!itksys::SystemTools::FileExists(fileToCheck.c_str()))
     {
-    otb::ImageFileReaderException e(__FILE__, __LINE__);
-    std::ostringstream msg;
-    msg << "The file doesn't exist. "
-        << std::endl << "Filename = " << fileToCheck
-        << std::endl;
-    e.SetDescription(msg.str().c_str());
-    throw e;
-    return;
+      throw otb::ImageFileReaderException (__FILE__, __LINE__, "The file does not exist.", fileToCheck);
     }
-
-  // Test if the file can be open for reading access.
-  //Only if m_FileName specify a filename (not a dirname)
-  if (itksys::SystemTools::FileExists(fileToCheck.c_str(), true))
+    else
     {
-    std::ifstream readTester;
-    readTester.open(fileToCheck.c_str());
-    if (readTester.fail())
-      {
-      readTester.close();
-      std::ostringstream msg;
-      msg << "The file couldn't be opened for reading. "
-          << std::endl << "Filename: " << fileToCheck
-          << std::endl;
-      otb::ImageFileReaderException e(__FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION);
-      throw e;
-      return;
-
-      }
-    readTester.close();
+      throw otb::ImageFileReaderException(__FILE__, __LINE__, "Probably unsupported format or incorrect filename extension.", this->m_FileName);
     }
+  }
 }
 
 template <class TOutputImage, class ConvertPixelTraits>
@@ -659,7 +587,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
   std::string str_FileName;
   bool fic_trouve(false);
 
-  // Si c'est un repertoire, on regarde le contenu pour voir si c'est pas du RADARSAT, ERS
+  // If it's a directory, look at the content to see if it's RADARSAT, ERS
   std::vector<std::string> listFileFind;
   listFileFind = System::Readdir(filename);
   if (listFileFind.empty() == false)
@@ -686,17 +614,16 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
     std::string extension = itksys::SystemTools::GetFilenameLastExtension(strFileName);
     if ((extension == ".HDR") || (extension == ".hdr"))
       {
-      //Supprime l'extension
       GdalFileName = System::GetRootName(strFileName);
       }
     else
       {
-      // Sinon le filename est le nom du fichier a ouvrir
+      // Else, the filename is the name of the file to open
       GdalFileName = std::string(filename);
       }
     fic_trouve = true;
     }
-  
+
   otbMsgDevMacro(<< "lFileNameGdal : " << GdalFileName.c_str());
   otbMsgDevMacro(<< "fic_trouve : " << fic_trouve);
   return (fic_trouve);
@@ -717,12 +644,12 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
 {
   const std::string skip_geom_key = "skipgeom";
   const std::string geom_key = "geom";
-  
+
   if (in)
     {
     // First, see if the simple filename has changed
     typename FNameHelperType::Pointer helper = FNameHelperType::New();
-    
+
     helper->SetExtendedFileName(in);
     std::string simpleFileName = helper->GetSimpleFileName();
 
@@ -736,7 +663,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
       if(oldMap.size() != newMap.size() || !std::equal(oldMap.begin(),oldMap.end(),newMap.begin()))
         {
         this->Modified();
-        
+
         // Now check if keywordlist needs to be generated again
         // Condition is: one of the old or new map has the skip_geom
         // key and the other does not
@@ -760,7 +687,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
       m_KeywordListUpToDate = false;
       this->Modified();
       }
-    
+
     m_FilenameHelper = helper;
     }
 }
@@ -782,15 +709,15 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
 
   return this->m_ImageIO->GetOverviewsCount();
  }
- 
- 
+
+
 template <class TOutputImage, class ConvertPixelTraits>
 std::vector<std::string>
 ImageFileReader<TOutputImage, ConvertPixelTraits>
 ::GetOverviewsInfo()
  {
   this->UpdateOutputInformation();
-  
+
   return this->m_ImageIO->GetOverviewsInfo();
  }
 
@@ -807,7 +734,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
   // TODO:
   // Pass down the PixelType (RGB, VECTOR, etc.) so that any vector to
   // scalar conversion be type specific. i.e. RGB to scalar would use
-  // a formula to convert to luminance, VECTOR to scalar would use
+  // a formula to convert to radiance, VECTOR to scalar would use
   // vector magnitude.
 
 
diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx
index 3224f5a..37bb644 100644
--- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx
+++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx
@@ -448,20 +448,7 @@ ImageFileWriter<TInputImage>
     {
     itk::ImageFileWriterException e(__FILE__, __LINE__);
     std::ostringstream msg;
-    msg << " Could not create IO object for file "
-        << m_FileName.c_str() << std::endl;
-    msg << "  Tried to create one of the following:" << std::endl;
-    std::list<itk::LightObject::Pointer> allobjects =
-      itk::ObjectFactoryBase::CreateAllInstance("otbImageIOBase");
-    for (std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin();
-         i != allobjects.end(); ++i)
-      {
-      otb::ImageIOBase* io = dynamic_cast<otb::ImageIOBase*>(i->GetPointer());
-      if(io)
-        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;
+    msg << "Cannot write image " << m_FileName.c_str() << ". Probably unsupported format or incorrect filename extension.";
     e.SetDescription(msg.str().c_str());
     e.SetLocation(ITK_LOCATION);
     throw e;
diff --git a/Modules/IO/ImageIO/src/otbImageIOFactory.cxx b/Modules/IO/ImageIO/src/otbImageIOFactory.cxx
index 671a62d..1f084b6 100644
--- a/Modules/IO/ImageIO/src/otbImageIOFactory.cxx
+++ b/Modules/IO/ImageIO/src/otbImageIOFactory.cxx
@@ -48,38 +48,35 @@ ImageIOFactory::CreateImageIO(const char* path, FileModeType mode)
     itk::ObjectFactoryBase::CreateAllInstance("otbImageIOBase");
   for(std::list<itk::LightObject::Pointer>::iterator i = allobjects.begin();
       i != allobjects.end(); ++i)
-    {
+  {
     otb::ImageIOBase* io = dynamic_cast<otb::ImageIOBase*>(i->GetPointer());
     if(io)
-      {
+    {
       possibleImageIO.push_back(io);
-      }
-    else
-      {
-      std::cerr << "Error ImageIO factory did not return an ImageIOBase: "
-                << (*i)->GetNameOfClass()
-                << std::endl;
-      }
     }
-  for(std::list<otb::ImageIOBase::Pointer>::iterator k = possibleImageIO.begin();
-      k != possibleImageIO.end(); ++k)
+    else
     {
+      itkGenericExceptionMacro(<< "ImageIO factory did not return an ImageIOBase but a " << (*i)->GetNameOfClass());
+    }
+  }
+
+  for(std::list<otb::ImageIOBase::Pointer>::iterator k = possibleImageIO.begin(); k != possibleImageIO.end(); ++k)
+  {
     if( mode == ReadMode )
-      {
+    {
       if((*k)->CanReadFile(path))
-        {
+      {
         return *k;
-        }
       }
+    }
     else if( mode == WriteMode )
-      {
+    {
       if((*k)->CanWriteFile(path))
-        {
+      {
         return *k;
-        }
-
       }
     }
+  }
   return ITK_NULLPTR;
 }
 
diff --git a/Modules/IO/ImageIO/test/CMakeLists.txt b/Modules/IO/ImageIO/test/CMakeLists.txt
index d8374f8..aac49fc 100644
--- a/Modules/IO/ImageIO/test/CMakeLists.txt
+++ b/Modules/IO/ImageIO/test/CMakeLists.txt
@@ -458,13 +458,13 @@ otb_add_test(NAME ioTvStreamingImageFileWriterCalculateNumberOfDivisions_SetNumb
   )
 
 otb_add_test(NAME ioTvStreamingImageFileWriterCalculateNumberOfDivisions_SetTileDimensionTiledStreaming COMMAND otbImageIOTestDriver
-  --compare-image ${EPSILON_9}   ${INPUTDATA}/ToulouseQuickBird_Extrait_1500_3750.tif
+  --compare-image ${EPSILON_9}   ${INPUTDATA}/QB_Toulouse_ortho_labelImage.tif
   ${TEMP}/ioStreamingImageFileWriterCalculateNumberOfDivisions_SetTileDimensionTiledStreaming.tif
   otbImageFileWriterTestCalculateNumberOfDivisions
-  ${INPUTDATA}/ToulouseQuickBird_Extrait_1500_3750.tif
+  ${INPUTDATA}/QB_Toulouse_ortho_labelImage.tif
   ${TEMP}/ioStreamingImageFileWriterCalculateNumberOfDivisions_SetTileDimensionTiledStreaming.tif
   SetTileDimensionTiledStreaming
-  32
+  256
   )
 
 otb_add_test(NAME ioTvStreamingImageFileWriterCalculateNumberOfDivisions_SetNumberOfDivisionsTiledStreamingS COMMAND otbImageIOTestDriver
diff --git a/Modules/IO/TestKernel/src/otbTestHelper.cxx b/Modules/IO/TestKernel/src/otbTestHelper.cxx
index dfdd234..9c1559a 100644
--- a/Modules/IO/TestKernel/src/otbTestHelper.cxx
+++ b/Modules/IO/TestKernel/src/otbTestHelper.cxx
@@ -1941,7 +1941,7 @@ void TestHelper::DumpOGRFeature(FILE* fpOut, OGRFeature* feature, char** papszOp
               poFDefn->GetNameRef(),
               OGRFieldDefn::GetFieldTypeName(poFDefn->GetType()));
 
-      if (feature->IsFieldSet(iField)) fprintf(fpOut, "%s\n", feature->GetFieldAsString(iField));
+      if (ogr::version_proxy::IsFieldSetAndNotNull(feature, iField)) fprintf(fpOut, "%s\n", feature->GetFieldAsString(iField));
       else fprintf(fpOut, "(null)\n");
 
       }
diff --git a/Modules/IO/TestKernel/test/CMakeLists.txt b/Modules/IO/TestKernel/test/CMakeLists.txt
index d0195c9..9451678 100644
--- a/Modules/IO/TestKernel/test/CMakeLists.txt
+++ b/Modules/IO/TestKernel/test/CMakeLists.txt
@@ -32,6 +32,38 @@ set(OTBTestKernelTests
 
 add_executable(otbTestKernelTestDriver ${OTBTestKernelTests})
 target_link_libraries(otbTestKernelTestDriver ${OTBTestKernel-Test_LIBRARIES})
+
+# So the story here is that -Wl,-no-needed is a default linker flag on only on Ubuntu
+# (debian or archlinux does not use this). This will exclude a lot of libraries from linking into
+# executable.
+# #ITK_LIBRARIES in a superbuild now contains the following libraries.
+# "itkdouble-conversion itksys itkvcl itknetlib itkv3p_netlib itkvnl itkvnl_algo
+# ITKVNLInstantiation ITKCommon itkNetlibSlatec ITKStatistics ITKTransform ITKLabelMap
+# ITKMesh ITKMetaIO ITKSpatialObjects ITKPath ITKQuadEdgeMesh ITKIOImageBase ITKOptimizers
+# ITKPolynomials ITKBiasCorrection ITKFFT ITKKLMRegionGrowing ITKOptimizersv4 ITKWatersheds"
+
+# OTBITK module will find all of these components in Modules/ThirdParty/ITK/otb-module-init.cmake
+# But due to default -Wl,-as-needed flag many of them are ignored.
+# see the documentation of GNU ld -as-needed for details on this behaviour.
+
+# Our problem is that we need these ignored ones in the some header-only modules.
+# Eg: Modules/Core/LabelMap
+# This module depends on ITKLabelMap but does not link with it as it doesn't create any module (lib, exe)
+# All it use is a couple of headers from ITKLabelMap. So removing that dependency is out of question.
+
+# At this point, possible solution are follows:
+# 1. use -Wl,-as-no-needed to CMAKE_LINKER FLAGS and be done with it. (all executable contains many used libs)
+# 2. glob all libITK*, libitk* in the package script. (ugly and I don't agree)
+# 3. make a dummy executable and link that with all of OTB libs and use -Wl,-no-as-needed in that
+# 4. pick one of the random test executable and only add -Wl,-no-as-needed to it. (still a hack)
+# ..
+# ...
+# RK: I finally decided to go with 4th option.
+# Take an existing test executable otbTestKernelTestDriver and force -Wl,-no-as-needed.
+if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+  set_target_properties(otbTestKernelTestDriver PROPERTIES LINK_FLAGS "-Wl,-no-as-needed")
+endif()
+
 otb_module_target_label(otbTestKernelTestDriver)
 otb_add_test(NAME tsTvCompareAscii2 COMMAND otbTestKernelTestDriver
   --compare-ascii ${NOTOL}
diff --git a/Modules/Learning/LearningBase/include/otbGaussianModelComponent.h b/Modules/Learning/LearningBase/include/otbGaussianModelComponent.h
index 2904d0c..58472dd 100644
--- a/Modules/Learning/LearningBase/include/otbGaussianModelComponent.h
+++ b/Modules/Learning/LearningBase/include/otbGaussianModelComponent.h
@@ -101,7 +101,7 @@ private:
   void operator =(const Self&); //purposely not implemented
 
   typename NativeMembershipFunctionType::Pointer m_GaussianMembershipFunction;
-  // TODO ajouter un m_GaussianCumulativeFunction
+  // TODO add a m_GaussianCumulativeFunction
   typename CovarianceEstimatorType::Pointer m_CovarianceEstimator;
 
   MeanVectorType  m_Mean;
diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModel.h b/Modules/Learning/LearningBase/include/otbMachineLearningModel.h
index c5fb59f..552880c 100644
--- a/Modules/Learning/LearningBase/include/otbMachineLearningModel.h
+++ b/Modules/Learning/LearningBase/include/otbMachineLearningModel.h
@@ -22,8 +22,8 @@
 #define otbMachineLearningModel_h
 
 #include "itkObject.h"
-#include "itkVariableLengthVector.h"
 #include "itkListSample.h"
+#include "otbMachineLearningModelTraits.h"
 
 namespace otb
 {
@@ -66,6 +66,7 @@ namespace otb
  *
  * \ingroup OTBLearningBase
  */
+
 template <class TInputValue, class TTargetValue, class TConfidenceValue = double >
 class ITK_EXPORT MachineLearningModel
   : public itk::Object
@@ -81,22 +82,22 @@ public:
 
   /**\name Input related typedefs */
   //@{
-  typedef TInputValue                                   InputValueType;
-  typedef itk::VariableLengthVector<InputValueType>     InputSampleType;
-  typedef itk::Statistics::ListSample<InputSampleType>  InputListSampleType;
+  typedef typename MLMSampleTraits<TInputValue>::ValueType  InputValueType;
+  typedef typename MLMSampleTraits<TInputValue>::SampleType InputSampleType;
+  typedef itk::Statistics::ListSample<InputSampleType>      InputListSampleType;
   //@}
 
   /**\name Target related typedefs */
   //@{
-  typedef TTargetValue                                  TargetValueType;
-  typedef itk::FixedArray<TargetValueType,1>            TargetSampleType;
-  typedef itk::Statistics::ListSample<TargetSampleType> TargetListSampleType;
+  typedef typename MLMTargetTraits<TTargetValue>::ValueType  TargetValueType;
+  typedef typename MLMTargetTraits<TTargetValue>::SampleType 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;
+  typedef typename MLMTargetTraits<TConfidenceValue>::ValueType  ConfidenceValueType;
+  typedef typename MLMTargetTraits<TConfidenceValue>::SampleType ConfidenceSampleType;
+  typedef itk::Statistics::ListSample<ConfidenceSampleType>      ConfidenceListSampleType;
 
   /**\name Standard macros */
   //@{
diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModelTraits.h b/Modules/Learning/LearningBase/include/otbMachineLearningModelTraits.h
new file mode 100644
index 0000000..e5f53f3
--- /dev/null
+++ b/Modules/Learning/LearningBase/include/otbMachineLearningModelTraits.h
@@ -0,0 +1,104 @@
+/*
+ * 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 otbMachineLearningModelTraits_h
+#define otbMachineLearningModelTraits_h
+
+
+#include "itkVariableLengthVector.h"
+#include "itkFixedArray.h"
+#include "itkIsNumber.h"
+#include "itkMetaProgrammingLibrary.h"
+
+namespace otb
+{
+
+/**
+ * This is the struct defining the sample implementation for
+ * MachineLearningModel. It offers two type definitions: SampleType
+ * and ValueType.
+ *
+ * \tparam TInput : input sample type (can be either a scalar type or
+ * a VariableLengthVector
+ * \tparam isNumber either TrueType or FalseType for partial
+ * specialization
+  
+ */
+template <typename TInput, typename isNumber> struct MLMSampleTraitsImpl;
+
+
+/// \cond SPECIALIZATION_IMPLEMENTATION
+// For Numbers
+template <typename TInput> struct MLMSampleTraitsImpl<TInput, itk::mpl::TrueType> {
+  typedef TInput                             ValueType;
+   typedef itk::VariableLengthVector<TInput> SampleType;
+};
+
+// For Vectors
+template <typename TInput> struct MLMSampleTraitsImpl<TInput, itk::mpl::FalseType> {
+  typedef typename TInput::ValueType        ValueType;
+  typedef TInput                            SampleType;
+};
+/// \endcond
+
+/**
+ * Simplified implementation of SampleTraits using MLMSampleTraitsImpl
+ */
+template <typename TInput> using MLMSampleTraits = MLMSampleTraitsImpl< TInput, typename itk::mpl::IsNumber<TInput>::Type >;
+
+
+/**
+ * This is the struct defining the sample implementation for
+ * MachineLearningModel. It offers two type definitions: TargetType
+ * and ValueType.
+ *
+ * \tparam TInput : input sample type (can be either a scalar type or
+ * a VariableLengthVector or a FixedArray
+ * \tparam isNumber either TrueType or FalseType for partial
+ * specialization
+  
+ */
+template <typename TInput, typename isNumber> struct MLMTargetTraitsImpl;
+
+
+/// \cond SPECIALIZATION_IMPLEMENTATION
+// For Numbers
+template <typename TInput> struct MLMTargetTraitsImpl<TInput, itk::mpl::TrueType> {
+  typedef TInput                             ValueType;
+  typedef itk::FixedArray<TInput,1>          SampleType;
+};
+
+// For Vectors
+template <typename TInput> struct MLMTargetTraitsImpl<TInput, itk::mpl::FalseType> {
+  typedef typename TInput::ValueType        ValueType;
+  typedef TInput                            SampleType;
+};
+/// \endcond
+
+/**
+ * Simplified implementation of TargetTraits using MLMTargetTraitsImpl
+ */
+template <typename TInput> using MLMTargetTraits = MLMTargetTraitsImpl< TInput, typename itk::mpl::IsNumber<TInput>::Type >;
+
+
+} // End namespace otb
+
+#endif
diff --git a/Modules/Learning/LearningBase/test/CMakeLists.txt b/Modules/Learning/LearningBase/test/CMakeLists.txt
index 74a67d4..d1d16c3 100644
--- a/Modules/Learning/LearningBase/test/CMakeLists.txt
+++ b/Modules/Learning/LearningBase/test/CMakeLists.txt
@@ -29,6 +29,7 @@ otbDecisionTreeWithRealValues.cxx
 otbSEMClassifierNew.cxx
 otbDecisionTreeNew.cxx
 otbKMeansImageClassificationFilterNew.cxx
+otbMachineLearningModelTemplates.cxx
 )
 
 add_executable(otbLearningBaseTestDriver ${OTBLearningBaseTests})
diff --git a/Modules/Learning/LearningBase/test/otbMachineLearningModelTemplates.cxx b/Modules/Learning/LearningBase/test/otbMachineLearningModelTemplates.cxx
new file mode 100644
index 0000000..96d35e0
--- /dev/null
+++ b/Modules/Learning/LearningBase/test/otbMachineLearningModelTemplates.cxx
@@ -0,0 +1,40 @@
+/*
+ * 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 <otbMachineLearningModel.h>
+
+typedef otb::MachineLearningModel<float,short>          MachineLearningModelType1;
+typedef MachineLearningModelType1::InputValueType       InputValueType1;
+typedef MachineLearningModelType1::InputSampleType      InputSampleType1;
+typedef MachineLearningModelType1::InputListSampleType  InputListSampleType1;
+typedef MachineLearningModelType1::TargetValueType      TargetValueType1;
+typedef MachineLearningModelType1::TargetSampleType     TargetSampleType1;
+typedef MachineLearningModelType1::TargetListSampleType TargetListSampleType1;
+
+typedef otb::MachineLearningModel<float,itk::VariableLengthVector<double> > MachineLearningModelType2;
+typedef MachineLearningModelType2::InputValueType       InputValueType2;
+typedef MachineLearningModelType2::InputSampleType      InputSampleType2;
+typedef MachineLearningModelType2::InputListSampleType  InputListSampleType2;
+typedef MachineLearningModelType2::TargetValueType      TargetValueType2;
+typedef MachineLearningModelType2::TargetSampleType     TargetSampleType2;
+typedef MachineLearningModelType2::TargetListSampleType TargetListSampleType2;
+
+
+
diff --git a/Modules/Learning/Sampling/include/otbImageSampleExtractorFilter.txx b/Modules/Learning/Sampling/include/otbImageSampleExtractorFilter.txx
index 8e38503..d5faa10 100644
--- a/Modules/Learning/Sampling/include/otbImageSampleExtractorFilter.txx
+++ b/Modules/Learning/Sampling/include/otbImageSampleExtractorFilter.txx
@@ -175,6 +175,7 @@ PersistentImageSampleExtractorFilter<TInputImage>
   IndexType imgIndex;
   PixelType imgPixel;
   double imgComp;
+
   ogr::Layer::const_iterator featIt = layerForThread.begin();
   for(; featIt!=layerForThread.end(); ++featIt)
     {
diff --git a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx
index a262824..7fa8822 100644
--- a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx
+++ b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx
@@ -41,6 +41,8 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage>
   , m_OutLayerName(std::string("output"))
   , m_OGRLayerCreationOptions()
   , m_AdditionalFields()
+  , m_InMemoryInputs()
+  , m_InMemoryOutputs()
 {
   this->SetNthOutput(0,TInputImage::New());
 }
@@ -723,19 +725,22 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage>
     {
     tmpLayers.push_back(this->GetInMemoryInput(i));
     }
-  
+
+  const unsigned int nbFeatThread = std::ceil(inLayer.GetFeatureCount(true) / (float) numberOfThreads);
+  assert(nbFeatThread > 0);
+
   OGRFeatureDefn &layerDefn = inLayer.GetLayerDefn();
   ogr::Layer::const_iterator featIt = inLayer.begin();
   unsigned int counter=0;
+  unsigned int cptFeat = 0;
   for(; featIt!=inLayer.end(); ++featIt)
     {
     ogr::Feature dstFeature(layerDefn);
     dstFeature.SetFrom( *featIt, TRUE );
     dstFeature.SetFID(featIt->GetFID());
     tmpLayers[counter].CreateFeature( dstFeature );
-    counter++;
-    if (counter >= tmpLayers.size())
-      counter = 0;
+    cptFeat++;
+    if (cptFeat > nbFeatThread) counter++; cptFeat=0;
     }
 
   inLayer.SetSpatialFilter(ITK_NULLPTR);
diff --git a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h
index a8baa08..329722a 100644
--- a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h
+++ b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h
@@ -141,7 +141,7 @@ public:
     return m_Parameters.coef0;
   }
 
-  /** Set the C parameter for the training for C_SVC, EPSILON_SVR and NU_SVR */
+  /** Set the C parameter for the training for C_SVC, EPSILON_SVR and C_SVR */
   otbSetSVMParameterMacro(C,C,double)
 
   /** Get the C parameter for the training for C_SVC, EPSILON_SVR and NU_SVR */
diff --git a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h
index f88bd13..899c56a 100644
--- a/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h
+++ b/Modules/MPI/MPIVrtWriter/include/otbMPIVrtWriter.h
@@ -260,7 +260,7 @@ template <typename TImage> void WriteMPI(TImage *img, const std::string &output,
       }
 
       // Close
-      OGRFree(wkt);
+      CPLFree(wkt);
       GDALClose(VRTOutput);
     }
   }
diff --git a/Modules/Radiometry/OpticalCalibration/include/otbImageToLuminanceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbImageToLuminanceImageFilter.h
index d451f59..0b6cda1 100644
--- a/Modules/Radiometry/OpticalCalibration/include/otbImageToLuminanceImageFilter.h
+++ b/Modules/Radiometry/OpticalCalibration/include/otbImageToLuminanceImageFilter.h
@@ -22,204 +22,27 @@
 #ifndef otbImageToLuminanceImageFilter_h
 #define otbImageToLuminanceImageFilter_h
 
-#include "otbUnaryImageFunctorWithVectorImageFilter.h"
-#include "itkNumericTraits.h"
-#include "otbMacro.h"
-#include "otbOpticalImageMetadataInterfaceFactory.h"
-
-#include <fstream>
+#include <otbImageToRadianceImageFilter.h>
+#include <vcl_deprecated_header.h>
 
 namespace otb
 {
-namespace Functor
-{
-/**
-   * \class ImageToLuminanceImageFunctor
-   * \brief Add beta to the quotient Input over alpha.
-   *
-   * \sa ImageToLuminanceImageFilter
-   * \ingroup Functor
-   * \ingroup Radiometry
- *
- * \ingroup OTBOpticalCalibration
- */
-
-template <class TInput, class TOutput>
-class ImageToLuminanceImageFunctor
-{
-public:
-  ImageToLuminanceImageFunctor() :
-    m_Alpha(1.),
-    m_Beta(0.)
-  {}
-
-  virtual ~ImageToLuminanceImageFunctor() {}
-
-  void SetAlpha(double alpha)
-  {
-    m_Alpha = alpha;
-  }
-  void SetBeta(double beta)
-  {
-    m_Beta = beta;
-  }
-  double GetAlpha()
-  {
-    return m_Alpha;
-  }
-  double GetBeta()
-  {
-    return m_Beta;
-  }
 
-  inline TOutput operator ()(const TInput& inPixel) const
-  {
-    TOutput outPixel;
-    double  temp;
-    temp = static_cast<double>(inPixel) / m_Alpha + m_Beta;
-    outPixel = static_cast<TOutput>(temp);
-    return outPixel;
-  }
-
-private:
-  double m_Alpha;
-  double m_Beta;
-};
-}
 
 /** \class ImageToLuminanceImageFilter
- *  \brief Convert a raw value into a luminance value
- *
- * Transform a classical image into the luminance image. For this it
- * uses the functor ImageToLuminanceImageFunctor calling for each component of each pixel.
- *
- *
- * For Spot image in the dimap format, the correction parameters are
- * retrieved automatically from the metadata
+ *  \brief Convert a raw value into a Luminance value
  *
- * \ingroup ImageToLuminanceImageFunctor
- * \ingroup Radiometry
- *
- * \example Radiometry/AtmosphericCorrectionSequencement.cxx
+ * \deprecated in OTB 6.2, please use ImageToRadianceImageFilter instead
  *
  * \ingroup OTBOpticalCalibration
  */
 template <class TInputImage, class TOutputImage>
 class ITK_EXPORT ImageToLuminanceImageFilter :
-  public UnaryImageFunctorWithVectorImageFilter<TInputImage,
-      TOutputImage,
-      typename Functor::ImageToLuminanceImageFunctor<typename
-          TInputImage::
-          InternalPixelType,
-          typename
-          TOutputImage::
-          InternalPixelType> >
+  public ImageToRadianceImageFilter<TInputImage, TOutputImage>
 {
-public:
-  /**   Extract input and output images dimensions.*/
-  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
-  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
-
-  /** "typedef" to simplify the variables definition and the declaration. */
-  typedef TInputImage  InputImageType;
-  typedef TOutputImage OutputImageType;
-  typedef typename Functor::ImageToLuminanceImageFunctor<typename InputImageType::InternalPixelType,
-      typename OutputImageType::InternalPixelType> FunctorType;
-
-  /** "typedef" for standard classes. */
-  typedef ImageToLuminanceImageFilter                                                          Self;
-  typedef UnaryImageFunctorWithVectorImageFilter<InputImageType, OutputImageType, FunctorType> Superclass;
-  typedef itk::SmartPointer<Self>                                                              Pointer;
-  typedef itk::SmartPointer<const Self>                                                        ConstPointer;
-
-  /** object factory method. */
-  itkNewMacro(Self);
-
-  /** return class name. */
-  itkTypeMacro(ImageToLuminanceImageFilter, UnaryImageFunctorWithVectorImageFiltermageFilter);
-
-  /** Supported images definition. */
-  typedef typename InputImageType::PixelType          InputPixelType;
-  typedef typename InputImageType::InternalPixelType  InputInternalPixelType;
-  typedef typename InputImageType::RegionType         InputImageRegionType;
-  typedef typename OutputImageType::PixelType         OutputPixelType;
-  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
-  typedef typename OutputImageType::RegionType        OutputImageRegionType;
-
-  typedef typename itk::VariableLengthVector<double> VectorType;
-
-  /** Image size "typedef" definition. */
-  typedef typename InputImageType::SizeType SizeType;
-
-  /** Set the absolute calibration gains. */
-  itkSetMacro(Alpha, VectorType);
-
-  /** Give the absolute calibration gains. */
-  itkGetConstReferenceMacro(Alpha, VectorType);
-
-  /** Set the absolute calibration bias. */
-  itkSetMacro(Beta, VectorType);
-  /** Give the absolute calibration bias. */
-  itkGetConstReferenceMacro(Beta, VectorType);
-
-protected:
-  /** Constructor */
-  ImageToLuminanceImageFilter()
-    {
-    m_Alpha.SetSize(0);
-    m_Beta.SetSize(0);
-    };
-
-  /** Destructor */
-  ~ImageToLuminanceImageFilter() ITK_OVERRIDE {}
-
-  /** Update the functor list and input parameters */
-  void BeforeThreadedGenerateData(void) ITK_OVERRIDE
-  {
-    OpticalImageMetadataInterface::Pointer imageMetadataInterface = OpticalImageMetadataInterfaceFactory::CreateIMI(
-      this->GetInput()->GetMetaDataDictionary());
-    if (m_Alpha.GetSize() == 0)
-      {
-      m_Alpha = imageMetadataInterface->GetPhysicalGain();
-      }
-
-    if (m_Beta.GetSize() == 0)
-      {
-      m_Beta = imageMetadataInterface->GetPhysicalBias();
-      }
-
-    otbMsgDevMacro(<< "Dimension: ");
-    otbMsgDevMacro(<< "m_Alpha.GetSize(): " << m_Alpha.GetSize());
-    otbMsgDevMacro(<< "m_Beta.GetSize() : " << m_Beta.GetSize());
-    otbMsgDevMacro(
-      << "this->GetInput()->GetNumberOfComponentsPerPixel() : " << this->GetInput()->GetNumberOfComponentsPerPixel());
-
-    if ((m_Alpha.GetSize() != this->GetInput()->GetNumberOfComponentsPerPixel())
-        || (m_Beta.GetSize() != this->GetInput()->GetNumberOfComponentsPerPixel()))
-      {
-      itkExceptionMacro(<< "Alpha and Beta parameters should have the same size as the number of bands");
-      }
-
-    otbMsgDevMacro(<< "Using correction parameters: ");
-    otbMsgDevMacro(<< "Alpha (gain): " << m_Alpha);
-    otbMsgDevMacro(<< "Beta (bias):  " << m_Beta);
-
-    this->GetFunctorVector().clear();
-    for (unsigned int i = 0; i < this->GetInput()->GetNumberOfComponentsPerPixel(); ++i)
-      {
-      FunctorType functor;
-      functor.SetAlpha(m_Alpha[i]);
-      functor.SetBeta(m_Beta[i]);
-      this->GetFunctorVector().push_back(functor);
-      }
-  }
-
-private:
-  /** Ponderation declaration*/
-  VectorType m_Alpha;
-  VectorType m_Beta;
 };
 
-} // end namespace otb
+
+} // namespace otb
 
 #endif
diff --git a/Modules/Radiometry/OpticalCalibration/include/otbImageToLuminanceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbImageToRadianceImageFilter.h
similarity index 84%
copy from Modules/Radiometry/OpticalCalibration/include/otbImageToLuminanceImageFilter.h
copy to Modules/Radiometry/OpticalCalibration/include/otbImageToRadianceImageFilter.h
index d451f59..fc8b7c3 100644
--- a/Modules/Radiometry/OpticalCalibration/include/otbImageToLuminanceImageFilter.h
+++ b/Modules/Radiometry/OpticalCalibration/include/otbImageToRadianceImageFilter.h
@@ -19,8 +19,8 @@
  * limitations under the License.
  */
 
-#ifndef otbImageToLuminanceImageFilter_h
-#define otbImageToLuminanceImageFilter_h
+#ifndef otbImageToRadianceImageFilter_h
+#define otbImageToRadianceImageFilter_h
 
 #include "otbUnaryImageFunctorWithVectorImageFilter.h"
 #include "itkNumericTraits.h"
@@ -34,10 +34,10 @@ namespace otb
 namespace Functor
 {
 /**
-   * \class ImageToLuminanceImageFunctor
+   * \class ImageToRadianceImageFunctor
    * \brief Add beta to the quotient Input over alpha.
    *
-   * \sa ImageToLuminanceImageFilter
+   * \sa ImageToRadianceImageFilter
    * \ingroup Functor
    * \ingroup Radiometry
  *
@@ -45,15 +45,15 @@ namespace Functor
  */
 
 template <class TInput, class TOutput>
-class ImageToLuminanceImageFunctor
+class ImageToRadianceImageFunctor
 {
 public:
-  ImageToLuminanceImageFunctor() :
+  ImageToRadianceImageFunctor() :
     m_Alpha(1.),
     m_Beta(0.)
   {}
 
-  virtual ~ImageToLuminanceImageFunctor() {}
+  virtual ~ImageToRadianceImageFunctor() {}
 
   void SetAlpha(double alpha)
   {
@@ -87,17 +87,17 @@ private:
 };
 }
 
-/** \class ImageToLuminanceImageFilter
- *  \brief Convert a raw value into a luminance value
+/** \class ImageToRadianceImageFilter
+ *  \brief Convert a raw value into a radiance value
  *
- * Transform a classical image into the luminance image. For this it
- * uses the functor ImageToLuminanceImageFunctor calling for each component of each pixel.
+ * Transform a classical image into the radiance image. For this it
+ * uses the functor ImageToRadianceImageFunctor calling for each component of each pixel.
  *
  *
  * For Spot image in the dimap format, the correction parameters are
  * retrieved automatically from the metadata
  *
- * \ingroup ImageToLuminanceImageFunctor
+ * \ingroup ImageToRadianceImageFunctor
  * \ingroup Radiometry
  *
  * \example Radiometry/AtmosphericCorrectionSequencement.cxx
@@ -105,10 +105,10 @@ private:
  * \ingroup OTBOpticalCalibration
  */
 template <class TInputImage, class TOutputImage>
-class ITK_EXPORT ImageToLuminanceImageFilter :
+class ITK_EXPORT ImageToRadianceImageFilter :
   public UnaryImageFunctorWithVectorImageFilter<TInputImage,
       TOutputImage,
-      typename Functor::ImageToLuminanceImageFunctor<typename
+      typename Functor::ImageToRadianceImageFunctor<typename
           TInputImage::
           InternalPixelType,
           typename
@@ -123,11 +123,11 @@ public:
   /** "typedef" to simplify the variables definition and the declaration. */
   typedef TInputImage  InputImageType;
   typedef TOutputImage OutputImageType;
-  typedef typename Functor::ImageToLuminanceImageFunctor<typename InputImageType::InternalPixelType,
+  typedef typename Functor::ImageToRadianceImageFunctor<typename InputImageType::InternalPixelType,
       typename OutputImageType::InternalPixelType> FunctorType;
 
   /** "typedef" for standard classes. */
-  typedef ImageToLuminanceImageFilter                                                          Self;
+  typedef ImageToRadianceImageFilter                                                          Self;
   typedef UnaryImageFunctorWithVectorImageFilter<InputImageType, OutputImageType, FunctorType> Superclass;
   typedef itk::SmartPointer<Self>                                                              Pointer;
   typedef itk::SmartPointer<const Self>                                                        ConstPointer;
@@ -136,7 +136,7 @@ public:
   itkNewMacro(Self);
 
   /** return class name. */
-  itkTypeMacro(ImageToLuminanceImageFilter, UnaryImageFunctorWithVectorImageFiltermageFilter);
+  itkTypeMacro(ImageToRadianceImageFilter, UnaryImageFunctorWithVectorImageFiltermageFilter);
 
   /** Supported images definition. */
   typedef typename InputImageType::PixelType          InputPixelType;
@@ -164,14 +164,14 @@ public:
 
 protected:
   /** Constructor */
-  ImageToLuminanceImageFilter()
+  ImageToRadianceImageFilter()
     {
     m_Alpha.SetSize(0);
     m_Beta.SetSize(0);
     };
 
   /** Destructor */
-  ~ImageToLuminanceImageFilter() ITK_OVERRIDE {}
+  ~ImageToRadianceImageFilter() ITK_OVERRIDE {}
 
   /** Update the functor list and input parameters */
   void BeforeThreadedGenerateData(void) ITK_OVERRIDE
diff --git a/Modules/Radiometry/OpticalCalibration/include/otbImageToReflectanceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbImageToReflectanceImageFilter.h
index 024a723..6dbc688 100644
--- a/Modules/Radiometry/OpticalCalibration/include/otbImageToReflectanceImageFilter.h
+++ b/Modules/Radiometry/OpticalCalibration/include/otbImageToReflectanceImageFilter.h
@@ -22,22 +22,22 @@
 #ifndef otbImageToReflectanceImageFilter_h
 #define otbImageToReflectanceImageFilter_h
 
-#include "otbImageToLuminanceImageFilter.h"
-#include "otbLuminanceToReflectanceImageFilter.h"
+#include "otbImageToRadianceImageFilter.h"
+#include "otbRadianceToReflectanceImageFilter.h"
 
 namespace otb
 {
 namespace Functor
 {
 /** \class ImageToReflectanceImageFunctor
-   *  \brief Call the ImageToLuminanceFunctor over the input and the LuminanceToReflectanceFunctor to this result.
+   *  \brief Call the ImageToRadianceFunctor over the input and the RadianceToReflectanceFunctor to this result.
    *
    *
    * \sa ImageToReflectanceImageFilter
    *
    * \ingroup Functor
-   * \ingroup ImageToLuminanceFunctor
-   * \ingroup LuminanceToReflectanceFunctor
+   * \ingroup ImageToRadianceFunctor
+   * \ingroup RadianceToReflectanceFunctor
    * \ingroup Radiometry
  *
  * \ingroup OTBOpticalCalibration
@@ -49,8 +49,8 @@ public:
   ImageToReflectanceImageFunctor() {}
   virtual ~ImageToReflectanceImageFunctor() {}
 
-  typedef Functor::ImageToLuminanceImageFunctor<TInput, TOutput>       ImToLumFunctorType;
-  typedef Functor::LuminanceToReflectanceImageFunctor<TInput, TOutput> LumToReflecFunctorType;
+  typedef Functor::ImageToRadianceImageFunctor<TInput, TOutput>       ImToLumFunctorType;
+  typedef Functor::RadianceToReflectanceImageFunctor<TInput, TOutput> LumToReflecFunctorType;
 
   void SetAlpha(double alpha)
   {
@@ -124,8 +124,8 @@ private:
  * retrieved automatically from the metadata
  *
  * \ingroup ImageToReflectanceImageFunctor
- * \ingroup ImageToLuminanceImageFilter
- * \ingroup ReflectanceToLuminanceImageFilter
+ * \ingroup ImageToRadianceImageFilter
+ * \ingroup ReflectanceToRadianceImageFilter
  * \ingroup Radiometry
  *
  * \ingroup OTBOpticalCalibration
diff --git a/Modules/Radiometry/OpticalCalibration/include/otbLuminanceToImageImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbLuminanceToImageImageFilter.h
index c28fd72..3ddbe95 100644
--- a/Modules/Radiometry/OpticalCalibration/include/otbLuminanceToImageImageFilter.h
+++ b/Modules/Radiometry/OpticalCalibration/include/otbLuminanceToImageImageFilter.h
@@ -22,205 +22,24 @@
 #ifndef otbLuminanceToImageImageFilter_h
 #define otbLuminanceToImageImageFilter_h
 
-#include "otb_6S.h"
-#include "otbUnaryImageFunctorWithVectorImageFilter.h"
-#include "itkNumericTraits.h"
-#include "otbMacro.h"
-#include "otbOpticalImageMetadataInterfaceFactory.h"
-
-#include <fstream>
+#include <otbRadianceToImageImageFilter.h>
+#include <vcl_deprecated_header.h>
 
 namespace otb
 {
-namespace Functor
-{
-/**
-   * \class LuminanceToImageImageFunctor
-   * \brief Subtract beta to the Input and multiply by alpha.
-   *
-   * \sa LuminanceToImageImageFilter
-   * \ingroup Functor
-   * \ingroup Radiometry
- *
- * \ingroup OTBOpticalCalibration
- */
-
-template <class TInput, class TOutput>
-class LuminanceToImageImageFunctor
-{
-public:
-  LuminanceToImageImageFunctor() :
-    m_Alpha(1.),
-    m_Beta(0.)
-  {}
-
-  virtual ~LuminanceToImageImageFunctor() {}
-
-  void SetAlpha(double alpha)
-  {
-    m_Alpha = alpha;
-  }
-  void SetBeta(double beta)
-  {
-    m_Beta = beta;
-  }
-  double GetAlpha()
-  {
-    return m_Alpha;
-  }
-  double GetBeta()
-  {
-    return m_Beta;
-  }
-
-  inline TOutput operator ()(const TInput& inPixel) const
-  {
-    TOutput outPixel;
-    double  temp;
-    temp = (static_cast<double>(inPixel) - m_Beta) * m_Alpha;
-    outPixel = static_cast<TOutput>(temp);
-    return outPixel;
-  }
-
-private:
-  double m_Alpha;
-  double m_Beta;
-};
-}
 
 /** \class LuminanceToImageImageFilter
- *  \brief Convert a raw value into a luminance value
- *
- * Transform a luminance image into a classical image. For this it
- * uses the functor LuminanceToImageImageFunctor calling for each component of each pixel.
- *
+ *  \brief Convert a radiance value into raw image value
  *
- * For Spot image in the dimap format, the correction parameters are
- * retrieved automatically from the metadata
- *
- * \ingroup LuminanceToImageImageFunctor
- * \ingroup Radiometry
- *
- * \example Radiometry/AtmosphericCorrectionSequencement.cxx
+ * \deprecated in OTB 6.2, please use RadianceToImageImageFilter instead
  *
  * \ingroup OTBOpticalCalibration
  */
 template <class TInputImage, class TOutputImage>
 class ITK_EXPORT LuminanceToImageImageFilter :
-  public UnaryImageFunctorWithVectorImageFilter<TInputImage,
-      TOutputImage,
-      typename Functor::LuminanceToImageImageFunctor<typename
-          TInputImage::
-          InternalPixelType,
-          typename
-          TOutputImage::
-          InternalPixelType> >
+  public RadianceToImageImageFilter<TInputImage, TOutputImage>
 {
-public:
-  /**   Extract input and output images dimensions.*/
-  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
-  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
-
-  /** "typedef" to simplify the variables definition and the declaration. */
-  typedef TInputImage  InputImageType;
-  typedef TOutputImage OutputImageType;
-  typedef typename Functor::LuminanceToImageImageFunctor<typename InputImageType::InternalPixelType,
-      typename OutputImageType::InternalPixelType> FunctorType;
-
-  /** "typedef" for standard classes. */
-  typedef LuminanceToImageImageFilter                                                          Self;
-  typedef UnaryImageFunctorWithVectorImageFilter<InputImageType, OutputImageType, FunctorType> Superclass;
-  typedef itk::SmartPointer<Self>                                                              Pointer;
-  typedef itk::SmartPointer<const Self>                                                        ConstPointer;
-
-  /** object factory method. */
-  itkNewMacro(Self);
-
-  /** return class name. */
-  itkTypeMacro(LuminanceToImageImageFilter, UnaryImageFunctorWithVectorImageFiltermageFilter);
-
-  /** Supported images definition. */
-  typedef typename InputImageType::PixelType          InputPixelType;
-  typedef typename InputImageType::InternalPixelType  InputInternalPixelType;
-  typedef typename InputImageType::RegionType         InputImageRegionType;
-  typedef typename OutputImageType::PixelType         OutputPixelType;
-  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
-  typedef typename OutputImageType::RegionType        OutputImageRegionType;
-
-  typedef typename itk::VariableLengthVector<double> VectorType;
-
-  /** Image size "typedef" definition. */
-  typedef typename InputImageType::SizeType SizeType;
-
-  /** Set the absolute calibration gains. */
-  itkSetMacro(Alpha, VectorType);
-
-  /** Give the absolute calibration gains. */
-  itkGetConstReferenceMacro(Alpha, VectorType);
-
-  /** Set the absolute calibration bias. */
-  itkSetMacro(Beta, VectorType);
-  /** Give the absolute calibration bias. */
-  itkGetConstReferenceMacro(Beta, VectorType);
-
-protected:
-  /** Constructor */
-  LuminanceToImageImageFilter()
-    {
-    m_Alpha.SetSize(0);
-    m_Beta.SetSize(0);
-    };
-
-  /** Destructor */
-  ~LuminanceToImageImageFilter() ITK_OVERRIDE {}
-
-  /** Update the functor list and input parameters */
-  void BeforeThreadedGenerateData(void) ITK_OVERRIDE
-  {
-    OpticalImageMetadataInterface::Pointer imageMetadataInterface = OpticalImageMetadataInterfaceFactory::CreateIMI(
-      this->GetInput()->GetMetaDataDictionary());
-    if (m_Alpha.GetSize() == 0)
-      {
-      m_Alpha = imageMetadataInterface->GetPhysicalGain();
-      }
-
-    if (m_Beta.GetSize() == 0)
-      {
-      m_Beta = imageMetadataInterface->GetPhysicalBias();
-      }
-
-    otbMsgDevMacro(<< "Dimension: ");
-    otbMsgDevMacro(<< "m_Alpha.GetSize(): " << m_Alpha.GetSize());
-    otbMsgDevMacro(<< "m_Beta.GetSize() : " << m_Beta.GetSize());
-    otbMsgDevMacro(
-      << "this->GetInput()->GetNumberOfComponentsPerPixel() : " << this->GetInput()->GetNumberOfComponentsPerPixel());
-
-    if ((m_Alpha.GetSize() != this->GetInput()->GetNumberOfComponentsPerPixel())
-        || (m_Beta.GetSize() != this->GetInput()->GetNumberOfComponentsPerPixel()))
-      {
-      itkExceptionMacro(<< "Alpha and Beta parameters should have the same size as the number of bands");
-      }
-
-    otbMsgDevMacro(<< "Using correction parameters: ");
-    otbMsgDevMacro(<< "Alpha (gain): " << m_Alpha);
-    otbMsgDevMacro(<< "Beta (bias):  " << m_Beta);
-
-    this->GetFunctorVector().clear();
-    for (unsigned int i = 0; i < this->GetInput()->GetNumberOfComponentsPerPixel(); ++i)
-      {
-      FunctorType functor;
-      functor.SetAlpha(m_Alpha[i]);
-      functor.SetBeta(m_Beta[i]);
-      this->GetFunctorVector().push_back(functor);
-      }
-  }
-
-private:
-  /** Ponderation declaration*/
-  VectorType m_Alpha;
-  VectorType m_Beta;
 };
 
-} // end namespace otb
-
+}
 #endif
diff --git a/Modules/Radiometry/OpticalCalibration/include/otbLuminanceToReflectanceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbLuminanceToReflectanceImageFilter.h
index 1d126c8..79a14d6 100644
--- a/Modules/Radiometry/OpticalCalibration/include/otbLuminanceToReflectanceImageFilter.h
+++ b/Modules/Radiometry/OpticalCalibration/include/otbLuminanceToReflectanceImageFilter.h
@@ -22,321 +22,24 @@
 #ifndef otbLuminanceToReflectanceImageFilter_h
 #define otbLuminanceToReflectanceImageFilter_h
 
-#include "otbVarSol.h"
-#include "otbUnaryImageFunctorWithVectorImageFilter.h"
-#include "otbMacro.h"
-#include "otbOpticalImageMetadataInterfaceFactory.h"
-#include <iomanip>
+#include <otbRadianceToReflectanceImageFilter.h>
+#include <vcl_deprecated_header.h>
 
 namespace otb
 {
-namespace Functor
-{
-/**
-   * \class LuminanceToReflectanceImageFunctor
-   * \brief Compupute reflectance from the luminance value
-   *
-   *  Multiply by Pi and by an illumination correction coefficient the
-   *  quotient between the input and the given solar illumination.
-   *
-   *
-   * \sa LuminanceToReflectanceImageFilter
-   *
-   * \ingroup Functor
-   * \ingroup Radiometry
-   *
- *
- * \ingroup OTBOpticalCalibration
- */
-template <class TInput, class TOutput>
-class LuminanceToReflectanceImageFunctor
-{
-public:
-  LuminanceToReflectanceImageFunctor() :
-    m_SolarIllumination(1.0),
-    m_IlluminationCorrectionCoefficient(1.0),
-    m_UseClamp(true)
-  {}
-
-  virtual ~LuminanceToReflectanceImageFunctor() {}
-
-  void SetSolarIllumination(double solarIllumination)
-  {
-    m_SolarIllumination = solarIllumination;
-  }
-  void SetIlluminationCorrectionCoefficient(double coef)
-  {
-    m_IlluminationCorrectionCoefficient = coef;
-  }
-  void SetUseClamp(bool useClamp)
-  {
-    m_UseClamp = useClamp;
-  }
-
-  double GetSolarIllumination()
-  {
-    return m_SolarIllumination;
-  }
-  double GetIlluminationCorrectionCoefficient()
-  {
-    return m_IlluminationCorrectionCoefficient;
-  }
-  bool GetUseClamp()
-  {
-    return m_UseClamp;
-  }
-
-  inline TOutput operator ()(const TInput& inPixel) const
-  {
-    TOutput outPixel;
-    double  temp;
-    temp = static_cast<double>(inPixel)
-           * static_cast<double>(CONST_PI)
-           * m_IlluminationCorrectionCoefficient
-           / m_SolarIllumination;
-
-    if (m_UseClamp)
-    {
-      temp = std::max(temp,0.);
-      temp = std::min(temp,1.);
-    }
-    outPixel = static_cast<TOutput>(temp);
-
-    return outPixel;
-  }
-
-private:
-  double m_SolarIllumination;
-  double m_IlluminationCorrectionCoefficient;
-  double m_UseClamp;
-};
-}
 
 /** \class LuminanceToReflectanceImageFilter
- *  \brief Convert luminance value into reflectance value
- *
- * Transform a luminance image into the reflectance. For this it uses the
- * functor LuminanceToReflectanceImageFunctor calling for each component of each pixel.
- *
+ *  \brief Convert radiance value into reflectance value
  *
- * For Spot image in the dimap format, the correction parameters are
- * retrieved automatically from the metadata
- *
- * \ingroup ImageToLuminanceImageFunctor
- * \ingroup Radiometry
- *
- * \example Radiometry/AtmosphericCorrectionSequencement.cxx
+ * \deprecated in OTB 6.2, please use RadianceToReflectanceImageFilter instead
  *
  * \ingroup OTBOpticalCalibration
  */
 template <class TInputImage, class TOutputImage>
 class ITK_EXPORT LuminanceToReflectanceImageFilter :
-  public UnaryImageFunctorWithVectorImageFilter<TInputImage,
-      TOutputImage,
-      typename Functor::LuminanceToReflectanceImageFunctor<typename
-          TInputImage::
-          InternalPixelType,
-          typename
-          TOutputImage::
-          InternalPixelType> >
+  public RadianceToReflectanceImageFilter<TInputImage,TOutputImage>
 {
-public:
-  /**   Extract input and output images dimensions.*/
-  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
-  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
-
-  /** "typedef" to simplify the variables definition and the declaration. */
-  typedef TInputImage  InputImageType;
-  typedef TOutputImage OutputImageType;
-  typedef typename Functor::LuminanceToReflectanceImageFunctor<typename InputImageType::InternalPixelType,
-      typename OutputImageType::InternalPixelType>
-  FunctorType;
-
-  /** "typedef" for standard classes. */
-  typedef LuminanceToReflectanceImageFilter                                                    Self;
-  typedef UnaryImageFunctorWithVectorImageFilter<InputImageType, OutputImageType, FunctorType> Superclass;
-  typedef itk::SmartPointer<Self>                                                              Pointer;
-  typedef itk::SmartPointer<const Self>                                                        ConstPointer;
-
-  /** object factory method. */
-  itkNewMacro(Self);
-
-  /** return class name. */
-  itkTypeMacro(LuminanceToReflectanceImageFilter, UnaryImageFunctorWithVectorImageFiltermageFilter);
-
-  /** Supported images definition. */
-  typedef typename InputImageType::PixelType          InputPixelType;
-  typedef typename InputImageType::InternalPixelType  InputInternalPixelType;
-  typedef typename InputImageType::RegionType         InputImageRegionType;
-  typedef typename OutputImageType::PixelType         OutputPixelType;
-  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
-  typedef typename OutputImageType::RegionType        OutputImageRegionType;
-
-  typedef typename itk::VariableLengthVector<double> VectorType;
-
-  /** Image size "typedef" definition. */
-  typedef typename InputImageType::SizeType SizeType;
-
-  /** Set the solar illumination value. */
-  itkSetMacro(SolarIllumination, VectorType);
-  /** Give the solar illumination value. */
-  itkGetConstReferenceMacro(SolarIllumination, VectorType);
-
-  /** Set the zenithal solar angle. */
-  itkSetMacro(ZenithalSolarAngle, double);
-  /** Give the zenithal solar angle. */
-  itkGetConstReferenceMacro(ZenithalSolarAngle, double);
-
-  /** Set/Get the sun elevation angle (internally handled by the zenithal angle)*/
-  virtual void SetElevationSolarAngle(double elevationAngle)
-  {
-    double zenithalAngle = 90.0 - elevationAngle;
-    if (this->m_ZenithalSolarAngle != zenithalAngle)
-      {
-      this->m_ZenithalSolarAngle = zenithalAngle;
-      this->Modified();
-      }
-  }
-
-  virtual double GetElevationSolarAngle() const
-  {
-    return 90.0 - this->m_ZenithalSolarAngle;
-  }
-
-  /** Set the day. */
-  itkSetClampMacro(Day, int, 1, 31);
-  /** Give the day. */
-  itkGetConstReferenceMacro(Day, int);
-
-  /** Set the month. */
-  itkSetClampMacro(Month, int, 1, 12);
-  /** Give the month. */
-  itkGetConstReferenceMacro(Month, int);
-
-  /** Set the flux normalization coefficient. */
-  void SetFluxNormalizationCoefficient(double coef)
-  {
-    m_FluxNormalizationCoefficient = coef;
-    m_IsSetFluxNormalizationCoefficient = true;
-    this->Modified();
-  }
-  /** Give the flux normalization coefficient. */
-  itkGetConstReferenceMacro(FluxNormalizationCoefficient, double);
-
-  /** Set the IsSetFluxNormalizationCoefficient boolean. */
-  itkSetMacro(IsSetFluxNormalizationCoefficient, bool);
-  /** Give the IsSetFluxNormalizationCoefficient boolean. */
-  itkGetConstReferenceMacro(IsSetFluxNormalizationCoefficient, bool);
-
-  /** Set the UseClamp boolean. */
-  itkSetMacro(UseClamp, bool);
-  /** Give the UseClamp boolean. */
-  itkGetConstReferenceMacro(UseClamp, bool);
-
-protected:
-  /** Constructor */
-  LuminanceToReflectanceImageFilter() :
-    m_ZenithalSolarAngle(120.0), //invalid value which will lead to negative radiometry
-    m_FluxNormalizationCoefficient(1.),
-    m_Day(0),
-    m_Month(0),
-    m_IsSetFluxNormalizationCoefficient(false),
-    m_UseClamp(true)
-    {
-    m_SolarIllumination.SetSize(0);
-    };
-
-  /** Destructor */
-  ~LuminanceToReflectanceImageFilter() ITK_OVERRIDE {}
-
-  /** Update the functor list and input parameters */
-  void BeforeThreadedGenerateData(void) ITK_OVERRIDE
-  {
-    OpticalImageMetadataInterface::Pointer imageMetadataInterface = OpticalImageMetadataInterfaceFactory::CreateIMI(
-      this->GetInput()->GetMetaDataDictionary());
-    if ((m_Day == 0) && (!m_IsSetFluxNormalizationCoefficient))
-      {
-      m_Day = imageMetadataInterface->GetDay();
-      }
-
-    if ((m_Month == 0) && (!m_IsSetFluxNormalizationCoefficient))
-      {
-      m_Month = imageMetadataInterface->GetMonth();
-      }
-
-    if (m_SolarIllumination.GetSize() == 0)
-      {
-      m_SolarIllumination = imageMetadataInterface->GetSolarIrradiance();
-      }
-
-    if (m_ZenithalSolarAngle == 120.0)
-      {
-      //the zenithal angle is the complementary of the elevation angle
-      m_ZenithalSolarAngle = 90.0 - imageMetadataInterface->GetSunElevation();
-      }
-
-    otbMsgDevMacro(<< "Using correction parameters: ");
-    otbMsgDevMacro(<< "Day:               " << m_Day);
-    otbMsgDevMacro(<< "Month:             " << m_Month);
-    otbMsgDevMacro(<< "Solar irradiance:  " << m_SolarIllumination);
-    otbMsgDevMacro(<< "Zenithal angle:    " << m_ZenithalSolarAngle);
-
-    if ((m_SolarIllumination.GetSize() != this->GetInput()->GetNumberOfComponentsPerPixel()))
-      {
-      itkExceptionMacro(<< "SolarIllumination parameter should have the same size as the number of bands");
-      }
-
-    this->GetFunctorVector().clear();
-
-    for (unsigned int i = 0; i < this->GetInput()->GetNumberOfComponentsPerPixel(); ++i)
-      {
-      FunctorType functor;
-      double      coefTemp = 0.;
-      if (!m_IsSetFluxNormalizationCoefficient)
-        {
-        if (m_Day * m_Month != 0 && m_Day < 32 && m_Month < 13)
-          {
-          double dsol = VarSol::GetVarSol(m_Day, m_Month);
-          coefTemp = vcl_cos(m_ZenithalSolarAngle * CONST_PI_180) * dsol;
-          }
-        else
-          {
-          itkExceptionMacro(<< "Day has to be included between 1 and 31, Month between 1 and 12.");
-          }
-        }
-      else
-        {
-        coefTemp =
-          vcl_cos(m_ZenithalSolarAngle *
-                  CONST_PI_180) * m_FluxNormalizationCoefficient * m_FluxNormalizationCoefficient;
-        }
-      functor.SetIlluminationCorrectionCoefficient(1. / coefTemp);
-      functor.SetSolarIllumination(static_cast<double>(m_SolarIllumination[i]));
-      functor.SetUseClamp(m_UseClamp);
-
-      this->GetFunctorVector().push_back(functor);
-      }
-  }
-
-private:
-
-  /** Set the zenithal soalr angle. */
-  double m_ZenithalSolarAngle;
-  /** Flux normalization coefficient. */
-  double m_FluxNormalizationCoefficient;
-  /** Acquisition day. */
-  int m_Day;
-  /** Acquisition month. */
-  int m_Month;
-  /** Solar illumination value. */
-  VectorType m_SolarIllumination;
-  /** Used to know if the user has set a value for the FluxNormalizationCoefficient parameter
-   * or if the class has to compute it */
-  bool m_IsSetFluxNormalizationCoefficient;
-  /** Clamp values to [0,1] */
-  bool m_UseClamp;
-
 };
 
-} // end namespace otb
+}
 #endif
diff --git a/Modules/Radiometry/OpticalCalibration/include/otbLuminanceToImageImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbRadianceToImageImageFilter.h
similarity index 84%
copy from Modules/Radiometry/OpticalCalibration/include/otbLuminanceToImageImageFilter.h
copy to Modules/Radiometry/OpticalCalibration/include/otbRadianceToImageImageFilter.h
index c28fd72..b52793f 100644
--- a/Modules/Radiometry/OpticalCalibration/include/otbLuminanceToImageImageFilter.h
+++ b/Modules/Radiometry/OpticalCalibration/include/otbRadianceToImageImageFilter.h
@@ -19,8 +19,8 @@
  * limitations under the License.
  */
 
-#ifndef otbLuminanceToImageImageFilter_h
-#define otbLuminanceToImageImageFilter_h
+#ifndef otbRadianceToImageImageFilter_h
+#define otbRadianceToImageImageFilter_h
 
 #include "otb_6S.h"
 #include "otbUnaryImageFunctorWithVectorImageFilter.h"
@@ -35,10 +35,10 @@ namespace otb
 namespace Functor
 {
 /**
-   * \class LuminanceToImageImageFunctor
+   * \class RadianceToImageImageFunctor
    * \brief Subtract beta to the Input and multiply by alpha.
    *
-   * \sa LuminanceToImageImageFilter
+   * \sa RadianceToImageImageFilter
    * \ingroup Functor
    * \ingroup Radiometry
  *
@@ -46,15 +46,15 @@ namespace Functor
  */
 
 template <class TInput, class TOutput>
-class LuminanceToImageImageFunctor
+class RadianceToImageImageFunctor
 {
 public:
-  LuminanceToImageImageFunctor() :
+  RadianceToImageImageFunctor() :
     m_Alpha(1.),
     m_Beta(0.)
   {}
 
-  virtual ~LuminanceToImageImageFunctor() {}
+  virtual ~RadianceToImageImageFunctor() {}
 
   void SetAlpha(double alpha)
   {
@@ -88,17 +88,17 @@ private:
 };
 }
 
-/** \class LuminanceToImageImageFilter
- *  \brief Convert a raw value into a luminance value
+/** \class RadianceToImageImageFilter
+ *  \brief Convert a radiance value into raw image value
  *
- * Transform a luminance image into a classical image. For this it
- * uses the functor LuminanceToImageImageFunctor calling for each component of each pixel.
+ * Transform a radiance image into a classical image. For this it
+ * uses the functor RadianceToImageImageFunctor calling for each component of each pixel.
  *
  *
  * For Spot image in the dimap format, the correction parameters are
  * retrieved automatically from the metadata
  *
- * \ingroup LuminanceToImageImageFunctor
+ * \ingroup RadianceToImageImageFunctor
  * \ingroup Radiometry
  *
  * \example Radiometry/AtmosphericCorrectionSequencement.cxx
@@ -106,10 +106,10 @@ private:
  * \ingroup OTBOpticalCalibration
  */
 template <class TInputImage, class TOutputImage>
-class ITK_EXPORT LuminanceToImageImageFilter :
+class ITK_EXPORT RadianceToImageImageFilter :
   public UnaryImageFunctorWithVectorImageFilter<TInputImage,
       TOutputImage,
-      typename Functor::LuminanceToImageImageFunctor<typename
+      typename Functor::RadianceToImageImageFunctor<typename
           TInputImage::
           InternalPixelType,
           typename
@@ -124,11 +124,11 @@ public:
   /** "typedef" to simplify the variables definition and the declaration. */
   typedef TInputImage  InputImageType;
   typedef TOutputImage OutputImageType;
-  typedef typename Functor::LuminanceToImageImageFunctor<typename InputImageType::InternalPixelType,
+  typedef typename Functor::RadianceToImageImageFunctor<typename InputImageType::InternalPixelType,
       typename OutputImageType::InternalPixelType> FunctorType;
 
   /** "typedef" for standard classes. */
-  typedef LuminanceToImageImageFilter                                                          Self;
+  typedef RadianceToImageImageFilter                                                          Self;
   typedef UnaryImageFunctorWithVectorImageFilter<InputImageType, OutputImageType, FunctorType> Superclass;
   typedef itk::SmartPointer<Self>                                                              Pointer;
   typedef itk::SmartPointer<const Self>                                                        ConstPointer;
@@ -137,7 +137,7 @@ public:
   itkNewMacro(Self);
 
   /** return class name. */
-  itkTypeMacro(LuminanceToImageImageFilter, UnaryImageFunctorWithVectorImageFiltermageFilter);
+  itkTypeMacro(RadianceToImageImageFilter, UnaryImageFunctorWithVectorImageFiltermageFilter);
 
   /** Supported images definition. */
   typedef typename InputImageType::PixelType          InputPixelType;
@@ -165,14 +165,14 @@ public:
 
 protected:
   /** Constructor */
-  LuminanceToImageImageFilter()
+  RadianceToImageImageFilter()
     {
     m_Alpha.SetSize(0);
     m_Beta.SetSize(0);
     };
 
   /** Destructor */
-  ~LuminanceToImageImageFilter() ITK_OVERRIDE {}
+  ~RadianceToImageImageFilter() ITK_OVERRIDE {}
 
   /** Update the functor list and input parameters */
   void BeforeThreadedGenerateData(void) ITK_OVERRIDE
diff --git a/Modules/Radiometry/OpticalCalibration/include/otbLuminanceToReflectanceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbRadianceToReflectanceImageFilter.h
similarity index 88%
copy from Modules/Radiometry/OpticalCalibration/include/otbLuminanceToReflectanceImageFilter.h
copy to Modules/Radiometry/OpticalCalibration/include/otbRadianceToReflectanceImageFilter.h
index 1d126c8..9e4d667 100644
--- a/Modules/Radiometry/OpticalCalibration/include/otbLuminanceToReflectanceImageFilter.h
+++ b/Modules/Radiometry/OpticalCalibration/include/otbRadianceToReflectanceImageFilter.h
@@ -19,8 +19,8 @@
  * limitations under the License.
  */
 
-#ifndef otbLuminanceToReflectanceImageFilter_h
-#define otbLuminanceToReflectanceImageFilter_h
+#ifndef otbRadianceToReflectanceImageFilter_h
+#define otbRadianceToReflectanceImageFilter_h
 
 #include "otbVarSol.h"
 #include "otbUnaryImageFunctorWithVectorImageFilter.h"
@@ -33,14 +33,14 @@ namespace otb
 namespace Functor
 {
 /**
-   * \class LuminanceToReflectanceImageFunctor
-   * \brief Compupute reflectance from the luminance value
+   * \class RadianceToReflectanceImageFunctor
+   * \brief Compute reflectance from the radiance value
    *
    *  Multiply by Pi and by an illumination correction coefficient the
    *  quotient between the input and the given solar illumination.
    *
    *
-   * \sa LuminanceToReflectanceImageFilter
+   * \sa RadianceToReflectanceImageFilter
    *
    * \ingroup Functor
    * \ingroup Radiometry
@@ -49,16 +49,16 @@ namespace Functor
  * \ingroup OTBOpticalCalibration
  */
 template <class TInput, class TOutput>
-class LuminanceToReflectanceImageFunctor
+class RadianceToReflectanceImageFunctor
 {
 public:
-  LuminanceToReflectanceImageFunctor() :
+  RadianceToReflectanceImageFunctor() :
     m_SolarIllumination(1.0),
     m_IlluminationCorrectionCoefficient(1.0),
     m_UseClamp(true)
   {}
 
-  virtual ~LuminanceToReflectanceImageFunctor() {}
+  virtual ~RadianceToReflectanceImageFunctor() {}
 
   void SetSolarIllumination(double solarIllumination)
   {
@@ -112,17 +112,17 @@ private:
 };
 }
 
-/** \class LuminanceToReflectanceImageFilter
- *  \brief Convert luminance value into reflectance value
+/** \class RadianceToReflectanceImageFilter
+ *  \brief Convert radiance value into reflectance value
  *
- * Transform a luminance image into the reflectance. For this it uses the
- * functor LuminanceToReflectanceImageFunctor calling for each component of each pixel.
+ * Transform a radiance image into the reflectance. For this it uses the
+ * functor RadianceToReflectanceImageFunctor calling for each component of each pixel.
  *
  *
  * For Spot image in the dimap format, the correction parameters are
  * retrieved automatically from the metadata
  *
- * \ingroup ImageToLuminanceImageFunctor
+ * \ingroup ImageToRadianceImageFunctor
  * \ingroup Radiometry
  *
  * \example Radiometry/AtmosphericCorrectionSequencement.cxx
@@ -130,10 +130,10 @@ private:
  * \ingroup OTBOpticalCalibration
  */
 template <class TInputImage, class TOutputImage>
-class ITK_EXPORT LuminanceToReflectanceImageFilter :
+class ITK_EXPORT RadianceToReflectanceImageFilter :
   public UnaryImageFunctorWithVectorImageFilter<TInputImage,
       TOutputImage,
-      typename Functor::LuminanceToReflectanceImageFunctor<typename
+      typename Functor::RadianceToReflectanceImageFunctor<typename
           TInputImage::
           InternalPixelType,
           typename
@@ -148,12 +148,12 @@ public:
   /** "typedef" to simplify the variables definition and the declaration. */
   typedef TInputImage  InputImageType;
   typedef TOutputImage OutputImageType;
-  typedef typename Functor::LuminanceToReflectanceImageFunctor<typename InputImageType::InternalPixelType,
+  typedef typename Functor::RadianceToReflectanceImageFunctor<typename InputImageType::InternalPixelType,
       typename OutputImageType::InternalPixelType>
   FunctorType;
 
   /** "typedef" for standard classes. */
-  typedef LuminanceToReflectanceImageFilter                                                    Self;
+  typedef RadianceToReflectanceImageFilter                                                    Self;
   typedef UnaryImageFunctorWithVectorImageFilter<InputImageType, OutputImageType, FunctorType> Superclass;
   typedef itk::SmartPointer<Self>                                                              Pointer;
   typedef itk::SmartPointer<const Self>                                                        ConstPointer;
@@ -162,7 +162,7 @@ public:
   itkNewMacro(Self);
 
   /** return class name. */
-  itkTypeMacro(LuminanceToReflectanceImageFilter, UnaryImageFunctorWithVectorImageFiltermageFilter);
+  itkTypeMacro(RadianceToReflectanceImageFilter, UnaryImageFunctorWithVectorImageFiltermageFilter);
 
   /** Supported images definition. */
   typedef typename InputImageType::PixelType          InputPixelType;
@@ -235,7 +235,7 @@ public:
 
 protected:
   /** Constructor */
-  LuminanceToReflectanceImageFilter() :
+  RadianceToReflectanceImageFilter() :
     m_ZenithalSolarAngle(120.0), //invalid value which will lead to negative radiometry
     m_FluxNormalizationCoefficient(1.),
     m_Day(0),
@@ -247,7 +247,7 @@ protected:
     };
 
   /** Destructor */
-  ~LuminanceToReflectanceImageFilter() ITK_OVERRIDE {}
+  ~RadianceToReflectanceImageFilter() ITK_OVERRIDE {}
 
   /** Update the functor list and input parameters */
   void BeforeThreadedGenerateData(void) ITK_OVERRIDE
diff --git a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToImageImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToImageImageFilter.h
index 23fa33c..6050d66 100644
--- a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToImageImageFilter.h
+++ b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToImageImageFilter.h
@@ -22,22 +22,22 @@
 #ifndef otbReflectanceToImageImageFilter_h
 #define otbReflectanceToImageImageFilter_h
 
-#include "otbLuminanceToImageImageFilter.h"
-#include "otbReflectanceToLuminanceImageFilter.h"
+#include "otbRadianceToImageImageFilter.h"
+#include "otbReflectanceToRadianceImageFilter.h"
 
 namespace otb
 {
 namespace Functor
 {
 /** \class ReflectanceToImageImageFunctor
-   *  \brief Call the ReflectanceToLuminanceFunctor over the input and the LuminanceToImageFunctor to this result.
+   *  \brief Call the ReflectanceToRadianceFunctor over the input and the RadianceToImageFunctor to this result.
    *
    *
    * \sa ReflectanceToImageImageFilter
    *
    * \ingroup Functor
-   * \ingroup LuminanceToImageFunctor
-   * \ingroup ReflectanceToLuminanceFunctor
+   * \ingroup RadianceToImageFunctor
+   * \ingroup ReflectanceToRadianceFunctor
    * \ingroup Radiometry
  *
  * \ingroup OTBOpticalCalibration
@@ -49,8 +49,8 @@ public:
   ReflectanceToImageImageFunctor() {}
   virtual ~ReflectanceToImageImageFunctor() {}
 
-  typedef Functor::LuminanceToImageImageFunctor<TInput, TOutput>       LumToImFunctorType;
-  typedef Functor::ReflectanceToLuminanceImageFunctor<TInput, TOutput> ReflecToLumFunctorType;
+  typedef Functor::RadianceToImageImageFunctor<TInput, TOutput>       LumToImFunctorType;
+  typedef Functor::ReflectanceToRadianceImageFunctor<TInput, TOutput> ReflecToLumFunctorType;
 
   void SetAlpha(double alpha)
   {
@@ -116,8 +116,8 @@ private:
  * retrieved automatically from the metadata
  *
  * \ingroup ReflectanceToImageImageFunctor
- * \ingroup LuminanceToImageImageFilter
- * \ingroup ReflectanceToLuminanceImageFilter
+ * \ingroup RadianceToImageImageFilter
+ * \ingroup ReflectanceToRadianceImageFilter
  * \ingroup Radiometry
  *
  * \ingroup OTBOpticalCalibration
diff --git a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToLuminanceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToLuminanceImageFilter.h
index be52414..786e023 100644
--- a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToLuminanceImageFilter.h
+++ b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToLuminanceImageFilter.h
@@ -22,303 +22,23 @@
 #ifndef otbReflectanceToLuminanceImageFilter_h
 #define otbReflectanceToLuminanceImageFilter_h
 
-#include "otbVarSol.h"
-#include "otbUnaryImageFunctorWithVectorImageFilter.h"
-#include "otbMath.h"
-#include "otbMacro.h"
-#include "otbOpticalImageMetadataInterfaceFactory.h"
-#include <iomanip>
+#include <otbReflectanceToRadianceImageFilter.h>
+#include <vcl_deprecated_header.h>
 
 namespace otb
 {
-namespace Functor
-{
-/**
-   * \class ReflectanceToLuminanceImageFunctor
-   * \brief Compupute luminance from the reflectance value
-   *
-   *  Divide by Pi and multiply by an illumination correction coefficient
-   *  and the given solar illumination.
-   *
-   *
-   * \sa ReflectanceToLuminanceImageFilter
-   *
-   * \ingroup Functor
-   * \ingroup Radiometry
-   *
- *
- * \ingroup OTBOpticalCalibration
- */
-template <class TInput, class TOutput>
-class ReflectanceToLuminanceImageFunctor
-{
-public:
-  ReflectanceToLuminanceImageFunctor() :
-    m_SolarIllumination(1.0),
-    m_IlluminationCorrectionCoefficient(1.0)
-  {}
-
-  virtual ~ReflectanceToLuminanceImageFunctor() {}
-
-  void SetSolarIllumination(double solarIllumination)
-  {
-    m_SolarIllumination = solarIllumination;
-  }
-  void SetIlluminationCorrectionCoefficient(double coef)
-  {
-    m_IlluminationCorrectionCoefficient = coef;
-  }
-
-  double GetSolarIllumination()
-  {
-    return m_SolarIllumination;
-  }
-  double GetIlluminationCorrectionCoefficient()
-  {
-    return m_IlluminationCorrectionCoefficient;
-  }
-
-  inline TOutput operator ()(const TInput& inPixel) const
-  {
-    TOutput outPixel;
-    double  temp;
-    temp = static_cast<double>(inPixel)
-           / static_cast<double>(CONST_PI)
-           * m_IlluminationCorrectionCoefficient
-           * m_SolarIllumination;
-
-    outPixel = static_cast<TOutput>(temp);
-    return outPixel;
-  }
-
-private:
-  double m_SolarIllumination;
-  double m_IlluminationCorrectionCoefficient;
-};
-}
-
 /** \class ReflectanceToLuminanceImageFilter
- *  \brief Convert reflectance value into luminance value
- *
- * Transform a reflectance image into the luminance. For this it uses the
- * functor ReflectanceToLuminanceImageFunctor calling for each component of each pixel.
- *
+ *  \brief Convert reflectance value into radiance value
  *
- * For Spot image in the dimap format, the correction parameters are
- * retrieved automatically from the metadata
- *
- * \ingroup ImageToLuminanceImageFunctor
- * \ingroup Radiometry
- *
- * \example Radiometry/AtmosphericCorrectionSequencement.cxx
+ * \deprecated in OTB 6.2, please use ReflectanceToRadianceImageFilter instead
  *
  * \ingroup OTBOpticalCalibration
  */
 template <class TInputImage, class TOutputImage>
 class ITK_EXPORT ReflectanceToLuminanceImageFilter :
-  public UnaryImageFunctorWithVectorImageFilter<TInputImage,
-      TOutputImage,
-      typename Functor::ReflectanceToLuminanceImageFunctor<typename
-          TInputImage::
-          InternalPixelType,
-          typename
-          TOutputImage::
-          InternalPixelType> >
+  public ReflectanceToRadianceImageFilter<TInputImage,TOutputImage>
 {
-public:
-  /**   Extract input and output images dimensions.*/
-  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
-  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
-
-  /** "typedef" to simplify the variables definition and the declaration. */
-  typedef TInputImage  InputImageType;
-  typedef TOutputImage OutputImageType;
-  typedef typename Functor::ReflectanceToLuminanceImageFunctor<typename InputImageType::InternalPixelType,
-      typename OutputImageType::InternalPixelType>
-  FunctorType;
-
-  /** "typedef" for standard classes. */
-  typedef ReflectanceToLuminanceImageFilter                                                    Self;
-  typedef UnaryImageFunctorWithVectorImageFilter<InputImageType, OutputImageType, FunctorType> Superclass;
-  typedef itk::SmartPointer<Self>                                                              Pointer;
-  typedef itk::SmartPointer<const Self>                                                        ConstPointer;
-
-  /** object factory method. */
-  itkNewMacro(Self);
-
-  /** return class name. */
-  itkTypeMacro(ReflectanceToLuminanceImageFilter, UnaryImageFunctorWithVectorImageFiltermageFilter);
-
-  /** Supported images definition. */
-  typedef typename InputImageType::PixelType          InputPixelType;
-  typedef typename InputImageType::InternalPixelType  InputInternalPixelType;
-  typedef typename InputImageType::RegionType         InputImageRegionType;
-  typedef typename OutputImageType::PixelType         OutputPixelType;
-  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
-  typedef typename OutputImageType::RegionType        OutputImageRegionType;
-
-  typedef typename itk::VariableLengthVector<double> VectorType;
-
-  /** Image size "typedef" definition. */
-  typedef typename InputImageType::SizeType SizeType;
-
-  /** Set the solar illumination value. */
-  itkSetMacro(SolarIllumination, VectorType);
-  /** Give the solar illumination value. */
-  itkGetConstReferenceMacro(SolarIllumination, VectorType);
-
-  /** Set the zenithal solar angle. */
-  itkSetMacro(ZenithalSolarAngle, double);
-  /** Give the zenithal solar angle. */
-  itkGetConstReferenceMacro(ZenithalSolarAngle, double);
-
-  /** Set/Get the sun elevation angle (internally handled by the zenithal angle)*/
-  virtual void SetElevationSolarAngle(double elevationAngle)
-  {
-    double zenithalAngle = 90.0 - elevationAngle;
-    if (this->m_ZenithalSolarAngle != zenithalAngle)
-      {
-      this->m_ZenithalSolarAngle = zenithalAngle;
-      this->Modified();
-      }
-  }
-
-  virtual double GetElevationSolarAngle() const
-  {
-    return 90.0 - this->m_ZenithalSolarAngle;
-  }
-
-  /** Set the day. */
-  itkSetClampMacro(Day, int, 1, 31);
-  /** Give the day. */
-  itkGetConstReferenceMacro(Day, int);
-
-  /** Set the month. */
-  itkSetClampMacro(Month, int, 1, 12);
-  /** Give the month. */
-  itkGetConstReferenceMacro(Month, int);
-
-  /** Set the flux normalization coefficient. */
-  void SetFluxNormalizationCoefficient(double coef)
-  {
-    m_FluxNormalizationCoefficient = coef;
-    m_IsSetFluxNormalizationCoefficient = true;
-    this->Modified();
-  }
-  /** Give the flux normalization coefficient. */
-  itkGetConstReferenceMacro(FluxNormalizationCoefficient, double);
-
-  /** Set the IsSetFluxNormalizationCoefficient boolean. */
-  itkSetMacro(IsSetFluxNormalizationCoefficient, bool);
-  /** Give the IsSetFluxNormalizationCoefficient boolean. */
-  itkGetConstReferenceMacro(IsSetFluxNormalizationCoefficient, bool);
-
-  /** Set the UseClamp boolean. */
-  itkSetMacro(UseClamp, bool);
-  /** Give the UseClamp boolean. */
-  itkGetConstReferenceMacro(UseClamp, bool);
-
-protected:
-  /** Constructor */
-  ReflectanceToLuminanceImageFilter() :
-    m_ZenithalSolarAngle(120.0), //invalid value which will lead to negative radiometry
-    m_FluxNormalizationCoefficient(1.),
-    m_Day(0),
-    m_Month(0),
-    m_IsSetFluxNormalizationCoefficient(false)
-    {
-    m_SolarIllumination.SetSize(0);
-    };
-
-  /** Destructor */
-  ~ReflectanceToLuminanceImageFilter() ITK_OVERRIDE {}
-
-  /** Update the functor list and input parameters */
-  void BeforeThreadedGenerateData(void) ITK_OVERRIDE
-  {
-    OpticalImageMetadataInterface::Pointer imageMetadataInterface = OpticalImageMetadataInterfaceFactory::CreateIMI(
-      this->GetInput()->GetMetaDataDictionary());
-    if ((m_Day == 0) && (!m_IsSetFluxNormalizationCoefficient))
-      {
-      m_Day = imageMetadataInterface->GetDay();
-      }
-
-    if ((m_Month == 0) && (!m_IsSetFluxNormalizationCoefficient))
-      {
-      m_Month = imageMetadataInterface->GetMonth();
-      }
-
-    if (m_SolarIllumination.GetSize() == 0)
-      {
-      m_SolarIllumination = imageMetadataInterface->GetSolarIrradiance();
-      }
-
-    if (m_ZenithalSolarAngle == 120.0)
-      {
-      //the zenithal angle is the complementary of the elevation angle
-      m_ZenithalSolarAngle = 90.0 - imageMetadataInterface->GetSunElevation();
-      }
-
-    std::cout << "Using correction parameters: " << std::endl;
-    std::cout<< "Day:               " << m_Day << std::endl;
-    std::cout<< "Month:             " << m_Month << std::endl;
-    std::cout<< "Solar irradiance:  " << m_SolarIllumination << std::endl;
-    std::cout<< "Zenithal angle:    " << m_ZenithalSolarAngle << std::endl;
-
-    if ((m_SolarIllumination.GetSize() != this->GetInput()->GetNumberOfComponentsPerPixel()))
-      {
-      itkExceptionMacro(<< "SolarIllumination parameter should have the same size as the number of bands");
-      }
-
-    this->GetFunctorVector().clear();
-
-    for (unsigned int i = 0; i < this->GetInput()->GetNumberOfComponentsPerPixel(); ++i)
-      {
-      FunctorType functor;
-      double      coefTemp = 0.;
-      if (!m_IsSetFluxNormalizationCoefficient)
-        {
-        if (m_Day * m_Month != 0 && m_Day < 32 && m_Month < 13)
-          {
-          coefTemp = vcl_cos(m_ZenithalSolarAngle * CONST_PI_180) * VarSol::GetVarSol(m_Day,m_Month);
-          }
-        else
-          {
-          itkExceptionMacro(<< "Day has to be included between 1 and 31, Month between 1 and 12.");
-          }
-        }
-      else
-        {
-        coefTemp =
-          vcl_cos(m_ZenithalSolarAngle *
-                  CONST_PI_180) * m_FluxNormalizationCoefficient * m_FluxNormalizationCoefficient;
-        }
-      functor.SetIlluminationCorrectionCoefficient(coefTemp);
-      functor.SetSolarIllumination(static_cast<double>(m_SolarIllumination[i]));
-
-      this->GetFunctorVector().push_back(functor);
-      }
-  }
-
-private:
-
-  /** Set the zenithal soalr angle. */
-  double m_ZenithalSolarAngle;
-  /** Flux normalization coefficient. */
-  double m_FluxNormalizationCoefficient;
-  /** Acquisition day. */
-  int m_Day;
-  /** Acquisition month. */
-  int m_Month;
-  /** Solar illumination value. */
-  VectorType m_SolarIllumination;
-  /** Used to know if the user has set a value for the FluxNormalizationCoefficient parameter
-   * or if the class has to compute it */
-  bool m_IsSetFluxNormalizationCoefficient;
-  /** Clamp values to [0,1] */
-  bool m_UseClamp;
-
 };
 
-} // end namespace otb
+}
 #endif
diff --git a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToLuminanceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToRadianceImageFilter.h
similarity index 88%
copy from Modules/Radiometry/OpticalCalibration/include/otbReflectanceToLuminanceImageFilter.h
copy to Modules/Radiometry/OpticalCalibration/include/otbReflectanceToRadianceImageFilter.h
index be52414..6935238 100644
--- a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToLuminanceImageFilter.h
+++ b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToRadianceImageFilter.h
@@ -19,8 +19,8 @@
  * limitations under the License.
  */
 
-#ifndef otbReflectanceToLuminanceImageFilter_h
-#define otbReflectanceToLuminanceImageFilter_h
+#ifndef otbReflectanceToRadianceImageFilter_h
+#define otbReflectanceToRadianceImageFilter_h
 
 #include "otbVarSol.h"
 #include "otbUnaryImageFunctorWithVectorImageFilter.h"
@@ -34,14 +34,14 @@ namespace otb
 namespace Functor
 {
 /**
-   * \class ReflectanceToLuminanceImageFunctor
-   * \brief Compupute luminance from the reflectance value
+   * \class ReflectanceToRadianceImageFunctor
+   * \brief Compute radiance from the reflectance value
    *
    *  Divide by Pi and multiply by an illumination correction coefficient
    *  and the given solar illumination.
    *
    *
-   * \sa ReflectanceToLuminanceImageFilter
+   * \sa ReflectanceToRadianceImageFilter
    *
    * \ingroup Functor
    * \ingroup Radiometry
@@ -50,15 +50,15 @@ namespace Functor
  * \ingroup OTBOpticalCalibration
  */
 template <class TInput, class TOutput>
-class ReflectanceToLuminanceImageFunctor
+class ReflectanceToRadianceImageFunctor
 {
 public:
-  ReflectanceToLuminanceImageFunctor() :
+  ReflectanceToRadianceImageFunctor() :
     m_SolarIllumination(1.0),
     m_IlluminationCorrectionCoefficient(1.0)
   {}
 
-  virtual ~ReflectanceToLuminanceImageFunctor() {}
+  virtual ~ReflectanceToRadianceImageFunctor() {}
 
   void SetSolarIllumination(double solarIllumination)
   {
@@ -97,17 +97,17 @@ private:
 };
 }
 
-/** \class ReflectanceToLuminanceImageFilter
- *  \brief Convert reflectance value into luminance value
+/** \class ReflectanceToRadianceImageFilter
+ *  \brief Convert reflectance value into radiance value
  *
- * Transform a reflectance image into the luminance. For this it uses the
- * functor ReflectanceToLuminanceImageFunctor calling for each component of each pixel.
+ * Transform a reflectance image into the radiance. For this it uses the
+ * functor ReflectanceToRadianceImageFunctor calling for each component of each pixel.
  *
  *
  * For Spot image in the dimap format, the correction parameters are
  * retrieved automatically from the metadata
  *
- * \ingroup ImageToLuminanceImageFunctor
+ * \ingroup ImageToRadianceImageFunctor
  * \ingroup Radiometry
  *
  * \example Radiometry/AtmosphericCorrectionSequencement.cxx
@@ -115,10 +115,10 @@ private:
  * \ingroup OTBOpticalCalibration
  */
 template <class TInputImage, class TOutputImage>
-class ITK_EXPORT ReflectanceToLuminanceImageFilter :
+class ITK_EXPORT ReflectanceToRadianceImageFilter :
   public UnaryImageFunctorWithVectorImageFilter<TInputImage,
       TOutputImage,
-      typename Functor::ReflectanceToLuminanceImageFunctor<typename
+      typename Functor::ReflectanceToRadianceImageFunctor<typename
           TInputImage::
           InternalPixelType,
           typename
@@ -133,12 +133,12 @@ public:
   /** "typedef" to simplify the variables definition and the declaration. */
   typedef TInputImage  InputImageType;
   typedef TOutputImage OutputImageType;
-  typedef typename Functor::ReflectanceToLuminanceImageFunctor<typename InputImageType::InternalPixelType,
+  typedef typename Functor::ReflectanceToRadianceImageFunctor<typename InputImageType::InternalPixelType,
       typename OutputImageType::InternalPixelType>
   FunctorType;
 
   /** "typedef" for standard classes. */
-  typedef ReflectanceToLuminanceImageFilter                                                    Self;
+  typedef ReflectanceToRadianceImageFilter                                                    Self;
   typedef UnaryImageFunctorWithVectorImageFilter<InputImageType, OutputImageType, FunctorType> Superclass;
   typedef itk::SmartPointer<Self>                                                              Pointer;
   typedef itk::SmartPointer<const Self>                                                        ConstPointer;
@@ -147,7 +147,7 @@ public:
   itkNewMacro(Self);
 
   /** return class name. */
-  itkTypeMacro(ReflectanceToLuminanceImageFilter, UnaryImageFunctorWithVectorImageFiltermageFilter);
+  itkTypeMacro(ReflectanceToRadianceImageFilter, UnaryImageFunctorWithVectorImageFiltermageFilter);
 
   /** Supported images definition. */
   typedef typename InputImageType::PixelType          InputPixelType;
@@ -220,7 +220,7 @@ public:
 
 protected:
   /** Constructor */
-  ReflectanceToLuminanceImageFilter() :
+  ReflectanceToRadianceImageFilter() :
     m_ZenithalSolarAngle(120.0), //invalid value which will lead to negative radiometry
     m_FluxNormalizationCoefficient(1.),
     m_Day(0),
@@ -231,7 +231,7 @@ protected:
     };
 
   /** Destructor */
-  ~ReflectanceToLuminanceImageFilter() ITK_OVERRIDE {}
+  ~ReflectanceToRadianceImageFilter() ITK_OVERRIDE {}
 
   /** Update the functor list and input parameters */
   void BeforeThreadedGenerateData(void) ITK_OVERRIDE
diff --git a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToSurfaceReflectanceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToSurfaceReflectanceImageFilter.h
index bf35488..7fc9c22 100644
--- a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToSurfaceReflectanceImageFilter.h
+++ b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToSurfaceReflectanceImageFilter.h
@@ -119,7 +119,7 @@ private:
  *
  * \ingroup AtmosphericRadiativeTerms
  * \ingroup AtmosphericCorrectionParameters
- * \ingroup LuminanceToReflectanceImageFilter
+ * \ingroup RadianceToReflectanceImageFilter
  * \ingroup ImageToReflectanceImageFilter
  * \ingroup ImageMetadataCorrectionParameters
  * \ingroup otbRadiometryCorrectionParametersToAtmosphericRadiativeTerms
diff --git a/Modules/Radiometry/OpticalCalibration/otb-module.cmake b/Modules/Radiometry/OpticalCalibration/otb-module.cmake
index 0df5e31..104d2b0 100644
--- a/Modules/Radiometry/OpticalCalibration/otb-module.cmake
+++ b/Modules/Radiometry/OpticalCalibration/otb-module.cmake
@@ -18,7 +18,7 @@
 # limitations under the License.
 #
 
-set(DOCUMENTATION "Digital number to luminance correction. luminance to
+set(DOCUMENTATION "Digital number to radiance correction. radiance to
 refletance image conversion. atmospheric correction for TOA (top of atmosphere) to TOC
 (top of canopy) reflectance estimation. correction of the adjacency effects taking
 into account the neighborhood contribution.")
diff --git a/Modules/Radiometry/OpticalCalibration/test/CMakeLists.txt b/Modules/Radiometry/OpticalCalibration/test/CMakeLists.txt
index 3221ced..a835c80 100644
--- a/Modules/Radiometry/OpticalCalibration/test/CMakeLists.txt
+++ b/Modules/Radiometry/OpticalCalibration/test/CMakeLists.txt
@@ -24,14 +24,14 @@ set(OTBOpticalCalibrationTests
 otbOpticalCalibrationTestDriver.cxx
 otbSpectralSensitivityReaderTest.cxx
 otbReflectanceToImageImageFilter.cxx
-otbReflectanceToLuminanceImageFilterNew.cxx
-otbLuminanceToReflectanceImageFilterNew.cxx
-otbLuminanceToReflectanceImageFilterAuto.cxx
-otbImageToLuminanceImageFilterNew.cxx
+otbReflectanceToRadianceImageFilterNew.cxx
+otbRadianceToReflectanceImageFilterNew.cxx
+otbRadianceToReflectanceImageFilterAuto.cxx
+otbImageToRadianceImageFilterNew.cxx
 otbRadiometryCorrectionParametersToAtmosphericRadiativeTermsNew.cxx
-otbLuminanceToImageImageFilterAuto.cxx
-otbLuminanceToImageImageFilterNew.cxx
-otbReflectanceToLuminanceImageFilterAuto.cxx
+otbRadianceToImageImageFilterAuto.cxx
+otbRadianceToImageImageFilterNew.cxx
+otbReflectanceToRadianceImageFilterAuto.cxx
 otbAeronetExtractDataBadData.cxx
 otbRomaniaReflectanceToRomaniaSurfaceReflectanceImageFilter.cxx
 otbRadiometryCorrectionParametersToAtmosphericRadiativeTerms.cxx
@@ -42,21 +42,21 @@ otbImageToReflectanceImageFilterNew.cxx
 otbWavelengthSpectralBandsTest.cxx
 otbAtmosphericRadiativeTermsTest.cxx
 otbImageToReflectanceImageFilter.cxx
-otbLuminanceToReflectanceImageFilter.cxx
+otbRadianceToReflectanceImageFilter.cxx
 otbReflectanceToImageImageFilterAuto.cxx
 otbAeronetNew.cxx
 otbAeronetExtractData.cxx
 otbReflectanceToSurfaceReflectanceImageFilterTest.cxx
 otbImageMetadataCorrectionParametersNew.cxx
-otbImageToLuminanceImageFilterAuto.cxx
+otbImageToRadianceImageFilterAuto.cxx
 otbAtmosphericCorrectionSequencement.cxx
 otbSIXSTraitsTest.cxx
 otbSIXSTraitsComputeAtmosphericParameters.cxx
 otbReflectanceToImageImageFilterNew.cxx
 otbSurfaceAdjacencyEffectCorrectionSchemeFilter.cxx
-otbLuminanceToImageImageFilter.cxx
-otbReflectanceToLuminanceImageFilter.cxx
-otbImageToLuminanceImageFilter.cxx
+otbRadianceToImageImageFilter.cxx
+otbReflectanceToRadianceImageFilter.cxx
+otbImageToRadianceImageFilter.cxx
 )
 
 add_executable(otbOpticalCalibrationTestDriver ${OTBOpticalCalibrationTests})
@@ -170,102 +170,102 @@ otb_add_test(NAME raTvRomaniaReflectanceToImage COMMAND otbOpticalCalibrationTes
   0.9889145564708814   #= sqrt(0.977952) d/d0 corresponding to the date 03/05
   )
 
-otb_add_test(NAME raTuReflectanceToLuminanceImageFilterNew COMMAND otbOpticalCalibrationTestDriver
-  otbReflectanceToLuminanceImageFilterNew
+otb_add_test(NAME raTuReflectanceToRadianceImageFilterNew COMMAND otbOpticalCalibrationTestDriver
+  otbReflectanceToRadianceImageFilterNew
   )
 
-otb_add_test(NAME raTuLuminanceToReflectanceImageFilterNew COMMAND otbOpticalCalibrationTestDriver
-  otbLuminanceToReflectanceImageFilterNew
+otb_add_test(NAME raTuRadianceToReflectanceImageFilterNew COMMAND otbOpticalCalibrationTestDriver
+  otbRadianceToReflectanceImageFilterNew
   )
 
-otb_add_test(NAME raTvLuminanceToReflectanceImageFilterAutoQuickbirdPAN COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoQuickbirdPAN.tif
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoQuickbirdPAN.tif
-  otbLuminanceToReflectanceImageFilterAuto
+otb_add_test(NAME raTvRadianceToReflectanceImageFilterAutoQuickbirdPAN COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoQuickbirdPAN.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoQuickbirdPAN.tif
+  otbRadianceToReflectanceImageFilterAuto
   LARGEINPUT{QUICKBIRD/TOULOUSE/000000128955_01_P001_PAN/02APR01105228-P1BS-000000128955_01_P001.TIF}
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoQuickbirdPAN.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoQuickbirdPAN.tif
   )
 
-otb_add_test(NAME raTvLuminanceToReflectanceImageFilterAutoWV2PAN COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoWV2PAN.tif
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoWV2PAN.tif
-  otbLuminanceToReflectanceImageFilterAuto
+otb_add_test(NAME raTvRadianceToReflectanceImageFilterAutoWV2PAN COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoWV2PAN.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoWV2PAN.tif
+  otbRadianceToReflectanceImageFilterAuto
   LARGEINPUT{WORLDVIEW2/ROME/WV-2_standard_8band_bundle_16bit/052298844010_01_P001_PAN/09DEC10103019-P2AS-052298844010_01_P001.TIF}
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoWV2PAN.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoWV2PAN.tif
   )
 
-otb_add_test(NAME raTvLuminanceToReflectanceImageFilterAutoSpot5 COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoSpot5.tif
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoSpot5.img
-  otbLuminanceToReflectanceImageFilterAuto
+otb_add_test(NAME raTvRadianceToReflectanceImageFilterAutoSpot5 COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoSpot5.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoSpot5.img
+  otbRadianceToReflectanceImageFilterAuto
   LARGEINPUT{SPOT5/TEHERAN/IMAGERY.TIF}
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoSpot5.img
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoSpot5.img
   )
 
-otb_add_test(NAME raTvLuminanceToReflectanceImageFilterAutoIkonos COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoIkonos.tif
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoIkonos.tif
-  otbLuminanceToReflectanceImageFilterAuto
+otb_add_test(NAME raTvRadianceToReflectanceImageFilterAutoIkonos COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoIkonos.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoIkonos.tif
+  otbRadianceToReflectanceImageFilterAuto
   LARGEINPUT{IKONOS/BLOSSEVILLE/po_2619900_pan_0000000.tif}
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoIkonos.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoIkonos.tif
   )
 
-otb_add_test(NAME raTvLuminanceToReflectanceImageFilterAutoWV2MULTI COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoWV2Multi.tif
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoWV2Multi.tif
-  otbLuminanceToReflectanceImageFilterAuto
+otb_add_test(NAME raTvRadianceToReflectanceImageFilterAutoWV2MULTI COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoWV2Multi.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoWV2Multi.tif
+  otbRadianceToReflectanceImageFilterAuto
   LARGEINPUT{WORLDVIEW2/ROME/WV-2_standard_8band_bundle_16bit/052298844010_01_P001_MUL/09DEC10103019-M2AS-052298844010_01_P001.TIF}
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoWV2Multi.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoWV2Multi.tif
   )
 
-otb_add_test(NAME raTvLuminanceToReflectanceImageFilterAutoQuickbirdXS COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoQuickbirdXS.tif
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoQuickbirdXS.tif
-  otbLuminanceToReflectanceImageFilterAuto
+otb_add_test(NAME raTvRadianceToReflectanceImageFilterAutoQuickbirdXS COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoQuickbirdXS.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoQuickbirdXS.tif
+  otbRadianceToReflectanceImageFilterAuto
   LARGEINPUT{QUICKBIRD/TOULOUSE/000000128955_01_P001_MUL/02APR01105228-M1BS-000000128955_01_P001.TIF}
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoQuickbirdXS.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoQuickbirdXS.tif
   )
 
-otb_add_test(NAME raTvLuminanceToReflectanceImageFilterAutoFORMOSAT COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoFormosat.tif
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoFormosat.img
-  otbLuminanceToReflectanceImageFilterAuto
+otb_add_test(NAME raTvRadianceToReflectanceImageFilterAutoFORMOSAT COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvRadianceToReflectanceImageFilterAutoFormosat.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoFormosat.img
+  otbRadianceToReflectanceImageFilterAuto
   LARGEINPUT{FORMOSAT/Sudouest_20071013_MS_fmsat/IMAGERY.TIF}
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterAutoFormosat.img
+  ${TEMP}/raTvRadianceToReflectanceImageFilterAutoFormosat.img
   )
 
-otb_add_test(NAME raTuImageToLuminanceImageFilterNew COMMAND otbOpticalCalibrationTestDriver
-  otbImageToLuminanceImageFilterNew
+otb_add_test(NAME raTuImageToRadianceImageFilterNew COMMAND otbOpticalCalibrationTestDriver
+  otbImageToRadianceImageFilterNew
   )
 
 
 otb_add_test(NAME raTuRadiometryCorrectionParametersToAtmosphericRadiativeTermsNew COMMAND otbOpticalCalibrationTestDriver
   otbRadiometryCorrectionParametersToAtmosphericRadiativeTermsNew)
 
-otb_add_test(NAME raTuLuminanceToImageImageFilterNew COMMAND otbOpticalCalibrationTestDriver
-  otbLuminanceToImageImageFilterNew
+otb_add_test(NAME raTuRadianceToImageImageFilterNew COMMAND otbOpticalCalibrationTestDriver
+  otbRadianceToImageImageFilterNew
   )
 
 #FIXME Those tests have performing local copies of header, baselines...They were migrate "as it" for now in version 5.0 but
 # something cleaner could be done in the future.
 #TODO Rewrite those tests and ban local copy and cmake trickery
-if(OTB_DATA_USE_LARGEINPUT)
+if(OTB_DATA_USE_LARGEINPUT AND OTB_DATA_ROOT)
 
   set(TOULOUSEQBDIR ${TEMP}/OpticalCalibLumToImQBPAN)
   file(MAKE_DIRECTORY ${TOULOUSEQBDIR})
   set(MTDATADIR ${OTB_DATA_LARGEINPUT_ROOT}/QUICKBIRD/TOULOUSE/000000128955_01_P001_PAN)
   file(GLOB MTDATA ${MTDATADIR}/*TIL ${MTDATADIR}/*RPB ${MTDATADIR}/*XML ${MTDATADIR}/*IMD)
   file(COPY ${MTDATA} DESTINATION ${TOULOUSEQBDIR})
-  otb_copy_rename(${BASELINE}/raTvImageToLuminanceImageFilterAutoQuickbirdPAN.tif ${TOULOUSEQBDIR}/02APR01105228-P1BS-000000128955_01_P001.TIF)
+  otb_copy_rename(${BASELINE}/raTvImageToRadianceImageFilterAutoQuickbirdPAN.tif ${TOULOUSEQBDIR}/02APR01105228-P1BS-000000128955_01_P001.TIF)
 
-  otb_add_test(NAME raTvLuminanceToImageImageFilterAutoQuickbirdPAN COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${TOULOUSEQBDIR}/raTvSMALLTOULOUSELuminanceToImageImageFilterAutoQuickbirdPAN.tif
-    ${TOULOUSEQBDIR}/raTvLuminanceToImageImageFilterAutoQuickbirdPAN.tif
-    otbLuminanceToImageImageFilterAuto
+  otb_add_test(NAME raTvRadianceToImageImageFilterAutoQuickbirdPAN COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${TOULOUSEQBDIR}/raTvSMALLTOULOUSERadianceToImageImageFilterAutoQuickbirdPAN.tif
+    ${TOULOUSEQBDIR}/raTvRadianceToImageImageFilterAutoQuickbirdPAN.tif
+    otbRadianceToImageImageFilterAuto
     ${TOULOUSEQBDIR}/02APR01105228-P1BS-000000128955_01_P001.TIF
     LARGEINPUT{QUICKBIRD/TOULOUSE/000000128955_01_P001_PAN/02APR01105228-P1BS-000000128955_01_P001.TIF}
-    ${TOULOUSEQBDIR}/raTvLuminanceToImageImageFilterAutoQuickbirdPAN.tif
-    ${TOULOUSEQBDIR}/raTvSMALLTOULOUSELuminanceToImageImageFilterAutoQuickbirdPAN.tif
+    ${TOULOUSEQBDIR}/raTvRadianceToImageImageFilterAutoQuickbirdPAN.tif
+    ${TOULOUSEQBDIR}/raTvSMALLTOULOUSERadianceToImageImageFilterAutoQuickbirdPAN.tif
     )
 
 
@@ -274,16 +274,16 @@ if(OTB_DATA_USE_LARGEINPUT)
   set(MTDATADIR ${OTB_DATA_LARGEINPUT_ROOT}/QUICKBIRD/TOULOUSE/000000128955_01_P001_MUL)
   file(GLOB MTDATA ${MTDATADIR}/*TIL ${MTDATADIR}/*RPB ${MTDATADIR}/*XML ${MTDATADIR}/*IMD)
   file(COPY ${MTDATA} DESTINATION ${TOULOUSEQBDIR})
-  otb_copy_rename(${BASELINE}/raTvImageToLuminanceImageFilterAutoQuickbirdXS.tif ${TOULOUSEQBDIR}/02APR01105228-M1BS-000000128955_01_P001.TIF)
+  otb_copy_rename(${BASELINE}/raTvImageToRadianceImageFilterAutoQuickbirdXS.tif ${TOULOUSEQBDIR}/02APR01105228-M1BS-000000128955_01_P001.TIF)
 
-  otb_add_test(NAME raTvLuminanceToImageImageFilterAutoQuickbirdXS COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${TOULOUSEQBDIR}/raTvSMALLTOULOUSELuminanceToImageImageFilterAutoQuickbirdXS.tif
-    ${TOULOUSEQBDIR}/raTvLuminanceToImageImageFilterAutoQuickbirdXS.tif
-    otbLuminanceToImageImageFilterAuto
+  otb_add_test(NAME raTvRadianceToImageImageFilterAutoQuickbirdXS COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${TOULOUSEQBDIR}/raTvSMALLTOULOUSERadianceToImageImageFilterAutoQuickbirdXS.tif
+    ${TOULOUSEQBDIR}/raTvRadianceToImageImageFilterAutoQuickbirdXS.tif
+    otbRadianceToImageImageFilterAuto
     ${TOULOUSEQBDIR}/02APR01105228-M1BS-000000128955_01_P001.TIF
     LARGEINPUT{QUICKBIRD/TOULOUSE/000000128955_01_P001_MUL/02APR01105228-M1BS-000000128955_01_P001.TIF}
-    ${TOULOUSEQBDIR}/raTvLuminanceToImageImageFilterAutoQuickbirdXS.tif
-    ${TOULOUSEQBDIR}/raTvSMALLTOULOUSELuminanceToImageImageFilterAutoQuickbirdXS.tif
+    ${TOULOUSEQBDIR}/raTvRadianceToImageImageFilterAutoQuickbirdXS.tif
+    ${TOULOUSEQBDIR}/raTvSMALLTOULOUSERadianceToImageImageFilterAutoQuickbirdXS.tif
     )
 
   set(ROMEWV2DIR ${TEMP}/OpticalCalibLumToImWv2MULTI)
@@ -291,48 +291,48 @@ if(OTB_DATA_USE_LARGEINPUT)
   set(MTDATADIR ${OTB_DATA_LARGEINPUT_ROOT}/WORLDVIEW2/ROME/WV-2_standard_8band_bundle_16bit/052298844010_01_P001_MUL)
   file(GLOB MTDATA ${MTDATADIR}/*TIL ${MTDATADIR}/*RPB ${MTDATADIR}/*XML ${MTDATADIR}/*IMD)
   file(COPY ${MTDATA} DESTINATION ${ROMEWV2DIR})
-  otb_copy_rename(${BASELINE}/raTvImageToLuminanceImageFilterAutoWV2Multi.tif ${ROMEWV2DIR}/09DEC10103019-M2AS-052298844010_01_P001.TIF)
+  otb_copy_rename(${BASELINE}/raTvImageToRadianceImageFilterAutoWV2Multi.tif ${ROMEWV2DIR}/09DEC10103019-M2AS-052298844010_01_P001.TIF)
 
-  otb_add_test(NAME raTvLuminanceToImageImageFilterAutoWV2MULTI COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${ROMEWV2DIR}/raTvSMALLROMELuminanceToImageImageFilterAutoWV2Multi.tif
-    ${ROMEWV2DIR}/raTvLuminanceToImageImageFilterAutoWV2Multi.tif
-    otbLuminanceToImageImageFilterAuto
+  otb_add_test(NAME raTvRadianceToImageImageFilterAutoWV2MULTI COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${ROMEWV2DIR}/raTvSMALLROMERadianceToImageImageFilterAutoWV2Multi.tif
+    ${ROMEWV2DIR}/raTvRadianceToImageImageFilterAutoWV2Multi.tif
+    otbRadianceToImageImageFilterAuto
     ${ROMEWV2DIR}/09DEC10103019-M2AS-052298844010_01_P001.TIF
     LARGEINPUT{WORLDVIEW2/ROME/WV-2_standard_8band_bundle_16bit/052298844010_01_P001_MUL/09DEC10103019-M2AS-052298844010_01_P001.TIF}
-    ${ROMEWV2DIR}/raTvLuminanceToImageImageFilterAutoWV2Multi.tif
-    ${ROMEWV2DIR}/raTvSMALLROMELuminanceToImageImageFilterAutoWV2Multi.tif
+    ${ROMEWV2DIR}/raTvRadianceToImageImageFilterAutoWV2Multi.tif
+    ${ROMEWV2DIR}/raTvSMALLROMERadianceToImageImageFilterAutoWV2Multi.tif
     )
 
   set(BLOSSEVILLEIKONOSDIR ${TEMP}/OpticalCalibLumToImIkonos)
   file(MAKE_DIRECTORY ${BLOSSEVILLEIKONOSDIR})
   file(GLOB MTDATA ${OTB_DATA_LARGEINPUT_ROOT}/IKONOS/BLOSSEVILLE/*metadata.txt ${OTB_DATA_LARGEINPUT_ROOT}/IKONOS/BLOSSEVILLE/*pan*)
   file(COPY ${MTDATA} DESTINATION ${BLOSSEVILLEIKONOSDIR})
-  otb_copy_rename(${BASELINE}/raTvImageToLuminanceImageFilterAutoIkonos.tif ${BLOSSEVILLEIKONOSDIR}/po_2619900_pan_0000000.tif)
+  otb_copy_rename(${BASELINE}/raTvImageToRadianceImageFilterAutoIkonos.tif ${BLOSSEVILLEIKONOSDIR}/po_2619900_pan_0000000.tif)
 
-  otb_add_test(NAME raTvLuminanceToImageImageFilterAutoIkonos COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${BLOSSEVILLEIKONOSDIR}/raTvSMALLBLOSSEVILLELuminanceToImageImageFilterAutoIkonos.tif
-    ${BLOSSEVILLEIKONOSDIR}/raTvLuminanceToImageImageFilterAutoIkonos.tif
-    otbLuminanceToImageImageFilterAuto
+  otb_add_test(NAME raTvRadianceToImageImageFilterAutoIkonos COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${BLOSSEVILLEIKONOSDIR}/raTvSMALLBLOSSEVILLERadianceToImageImageFilterAutoIkonos.tif
+    ${BLOSSEVILLEIKONOSDIR}/raTvRadianceToImageImageFilterAutoIkonos.tif
+    otbRadianceToImageImageFilterAuto
     ${BLOSSEVILLEIKONOSDIR}/po_2619900_pan_0000000.tif
     LARGEINPUT{IKONOS/BLOSSEVILLE/po_2619900_pan_0000000.tif}
-    ${BLOSSEVILLEIKONOSDIR}/raTvLuminanceToImageImageFilterAutoIkonos.tif
-    ${BLOSSEVILLEIKONOSDIR}/raTvSMALLBLOSSEVILLELuminanceToImageImageFilterAutoIkonos.tif
+    ${BLOSSEVILLEIKONOSDIR}/raTvRadianceToImageImageFilterAutoIkonos.tif
+    ${BLOSSEVILLEIKONOSDIR}/raTvSMALLBLOSSEVILLERadianceToImageImageFilterAutoIkonos.tif
     )
 
   set(TEHERANSPOT5DIR ${TEMP}/OpticalCalibLumToImSPOT5)
   file(MAKE_DIRECTORY ${TEHERANSPOT5DIR})
   file(GLOB MTDATA ${OTB_DATA_LARGEINPUT_ROOT}/SPOT5/TEHERAN/*.DIM)
   file(COPY ${MTDATA} DESTINATION ${TEHERANSPOT5DIR})
-  otb_copy_rename(${BASELINE}/raTvImageToLuminanceImageFilterAutoSpot5.tif ${TEHERANSPOT5DIR}/IMAGERY.TIF)
+  otb_copy_rename(${BASELINE}/raTvImageToRadianceImageFilterAutoSpot5.tif ${TEHERANSPOT5DIR}/IMAGERY.TIF)
 
-  otb_add_test(NAME raTvLuminanceToImageImageFilterAutoSpot5 COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${TEHERANSPOT5DIR}/raTvSMALLTEHERANLuminanceToImageImageFilterAutoSpot5.img
-    ${TEHERANSPOT5DIR}/raTvLuminanceToImageImageFilterAutoSpot5.tif
-    otbLuminanceToImageImageFilterAuto
+  otb_add_test(NAME raTvRadianceToImageImageFilterAutoSpot5 COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${TEHERANSPOT5DIR}/raTvSMALLTEHERANRadianceToImageImageFilterAutoSpot5.img
+    ${TEHERANSPOT5DIR}/raTvRadianceToImageImageFilterAutoSpot5.tif
+    otbRadianceToImageImageFilterAuto
     ${TEHERANSPOT5DIR}/IMAGERY.TIF
     LARGEINPUT{SPOT5/TEHERAN/IMAGERY.TIF}
-    ${TEHERANSPOT5DIR}/raTvLuminanceToImageImageFilterAutoSpot5.tif
-    ${TEHERANSPOT5DIR}/raTvSMALLTEHERANLuminanceToImageImageFilterAutoSpot5.img
+    ${TEHERANSPOT5DIR}/raTvRadianceToImageImageFilterAutoSpot5.tif
+    ${TEHERANSPOT5DIR}/raTvSMALLTEHERANRadianceToImageImageFilterAutoSpot5.img
     )
 
   set(ROMEWV2DIR ${TEMP}/OpticalCalibLumToImWv2PAN)
@@ -340,16 +340,16 @@ if(OTB_DATA_USE_LARGEINPUT)
   set(MTDATADIR ${OTB_DATA_LARGEINPUT_ROOT}/WORLDVIEW2/ROME/WV-2_standard_8band_bundle_16bit/052298844010_01_P001_PAN)
   file(GLOB MTDATA ${MTDATADIR}/*TIL ${MTDATADIR}/*RPB ${MTDATADIR}/*XML ${MTDATADIR}/*IMD)
   file(COPY ${MTDATA} DESTINATION ${ROMEWV2DIR})
-  otb_copy_rename(${BASELINE}/raTvImageToLuminanceImageFilterAutoWV2PAN.tif ${ROMEWV2DIR}/09DEC10103019-P2AS-052298844010_01_P001.TIF)
+  otb_copy_rename(${BASELINE}/raTvImageToRadianceImageFilterAutoWV2PAN.tif ${ROMEWV2DIR}/09DEC10103019-P2AS-052298844010_01_P001.TIF)
 
-  otb_add_test(NAME raTvLuminanceToImageImageFilterAutoWV2PAN COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${ROMEWV2DIR}/raTvSMALLROMELuminanceToImageImageFilterAutoWV2PAN.tif
-    ${ROMEWV2DIR}/raTvLuminanceToImageImageFilterAutoWV2PAN.tif
-    otbLuminanceToImageImageFilterAuto
+  otb_add_test(NAME raTvRadianceToImageImageFilterAutoWV2PAN COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${ROMEWV2DIR}/raTvSMALLROMERadianceToImageImageFilterAutoWV2PAN.tif
+    ${ROMEWV2DIR}/raTvRadianceToImageImageFilterAutoWV2PAN.tif
+    otbRadianceToImageImageFilterAuto
     ${ROMEWV2DIR}/09DEC10103019-P2AS-052298844010_01_P001.TIF
     LARGEINPUT{WORLDVIEW2/ROME/WV-2_standard_8band_bundle_16bit/052298844010_01_P001_PAN/09DEC10103019-P2AS-052298844010_01_P001.TIF}
-    ${ROMEWV2DIR}/raTvLuminanceToImageImageFilterAutoWV2PAN.tif
-    ${ROMEWV2DIR}/raTvSMALLROMELuminanceToImageImageFilterAutoWV2PAN.tif
+    ${ROMEWV2DIR}/raTvRadianceToImageImageFilterAutoWV2PAN.tif
+    ${ROMEWV2DIR}/raTvSMALLROMERadianceToImageImageFilterAutoWV2PAN.tif
     )
 
   set(SUDOUESTFORMOSATDIR ${TEMP}/OpticalCalibLumToImFormosat)
@@ -357,16 +357,16 @@ if(OTB_DATA_USE_LARGEINPUT)
   set(MTDATADIR ${OTB_DATA_LARGEINPUT_ROOT}/FORMOSAT/Sudouest_20071013_MS_fmsat)
   file(GLOB MTDATA ${MTDATADIR}/*.DIM)
   file(COPY ${MTDATA} DESTINATION ${SUDOUESTFORMOSATDIR})
-  otb_copy_rename(${BASELINE}/raTvImageToLuminanceImageFilterAutoFormosat.tif ${SUDOUESTFORMOSATDIR}/IMAGERY.TIF)
+  otb_copy_rename(${BASELINE}/raTvImageToRadianceImageFilterAutoFormosat.tif ${SUDOUESTFORMOSATDIR}/IMAGERY.TIF)
 
-  otb_add_test(NAME raTvLuminanceToImageImageFilterAutoFORMOSAT COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${SUDOUESTFORMOSATDIR}/raTvSMALLSOLuminanceToImageImageFilterAutoFormosat.img
-    ${SUDOUESTFORMOSATDIR}/raTvLuminanceToImageImageFilterAutoFormosat.tif
-    otbLuminanceToImageImageFilterAuto
+  otb_add_test(NAME raTvRadianceToImageImageFilterAutoFORMOSAT COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${SUDOUESTFORMOSATDIR}/raTvSMALLSORadianceToImageImageFilterAutoFormosat.img
+    ${SUDOUESTFORMOSATDIR}/raTvRadianceToImageImageFilterAutoFormosat.tif
+    otbRadianceToImageImageFilterAuto
     ${SUDOUESTFORMOSATDIR}/IMAGERY.TIF
     LARGEINPUT{FORMOSAT/Sudouest_20071013_MS_fmsat/IMAGERY.TIF}
-    ${SUDOUESTFORMOSATDIR}/raTvLuminanceToImageImageFilterAutoFormosat.tif
-    ${SUDOUESTFORMOSATDIR}/raTvSMALLSOLuminanceToImageImageFilterAutoFormosat.img
+    ${SUDOUESTFORMOSATDIR}/raTvRadianceToImageImageFilterAutoFormosat.tif
+    ${SUDOUESTFORMOSATDIR}/raTvSMALLSORadianceToImageImageFilterAutoFormosat.img
     )
 
   set(TOULOUSEQBDIR ${TEMP}/OpticalCalibRefToLumQBPAN)
@@ -374,14 +374,14 @@ if(OTB_DATA_USE_LARGEINPUT)
   set(MTDATADIR ${OTB_DATA_LARGEINPUT_ROOT}/QUICKBIRD/TOULOUSE/000000128955_01_P001_PAN)
   file(GLOB MTDATA ${MTDATADIR}/*TIL ${MTDATADIR}/*RPB ${MTDATADIR}/*XML ${MTDATADIR}/*IMD)
   file(COPY ${MTDATA} DESTINATION ${TOULOUSEQBDIR})
-  otb_copy_rename(${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoQuickbirdPAN.tif ${TOULOUSEQBDIR}/02APR01105228-P1BS-000000128955_01_P001.TIF)
+  otb_copy_rename(${BASELINE}/raTvRadianceToReflectanceImageFilterAutoQuickbirdPAN.tif ${TOULOUSEQBDIR}/02APR01105228-P1BS-000000128955_01_P001.TIF)
 
-  otb_add_test(NAME raTvReflectanceToLuminanceImageFilterAutoQuickbirdPAN COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoQuickbirdPAN.tif
-    ${TOULOUSEQBDIR}/raTvReflectanceToLuminanceImageFilterAutoQuickbirdPAN.tif
-    otbReflectanceToLuminanceImageFilterAuto
+  otb_add_test(NAME raTvReflectanceToRadianceImageFilterAutoQuickbirdPAN COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoQuickbirdPAN.tif
+    ${TOULOUSEQBDIR}/raTvReflectanceToRadianceImageFilterAutoQuickbirdPAN.tif
+    otbReflectanceToRadianceImageFilterAuto
     ${TOULOUSEQBDIR}/02APR01105228-P1BS-000000128955_01_P001.TIF
-    ${TOULOUSEQBDIR}/raTvReflectanceToLuminanceImageFilterAutoQuickbirdPAN.tif
+    ${TOULOUSEQBDIR}/raTvReflectanceToRadianceImageFilterAutoQuickbirdPAN.tif
     )
 
   set(ROMEWV2DIR ${TEMP}/OpticalCalibRefToLumWv2PAN)
@@ -389,42 +389,42 @@ if(OTB_DATA_USE_LARGEINPUT)
   set(MTDATADIR ${OTB_DATA_LARGEINPUT_ROOT}/WORLDVIEW2/ROME/WV-2_standard_8band_bundle_16bit/052298844010_01_P001_PAN)
   file(GLOB MTDATA ${MTDATADIR}/*TIL ${MTDATADIR}/*RPB ${MTDATADIR}/*XML ${MTDATADIR}/*IMD)
   file(COPY ${MTDATA} DESTINATION ${ROMEWV2DIR})
-  otb_copy_rename(${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoWV2PAN.tif ${ROMEWV2DIR}/09DEC10103019-P2AS-052298844010_01_P001.TIF)
+  otb_copy_rename(${BASELINE}/raTvRadianceToReflectanceImageFilterAutoWV2PAN.tif ${ROMEWV2DIR}/09DEC10103019-P2AS-052298844010_01_P001.TIF)
 
-  otb_add_test(NAME raTvReflectanceToLuminanceImageFilterAutoWV2PAN COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoWV2PAN.tif
-    ${ROMEWV2DIR}/raTvReflectanceToLuminanceImageFilterAutoWV2PAN.tif
-    otbReflectanceToLuminanceImageFilterAuto
+  otb_add_test(NAME raTvReflectanceToRadianceImageFilterAutoWV2PAN COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoWV2PAN.tif
+    ${ROMEWV2DIR}/raTvReflectanceToRadianceImageFilterAutoWV2PAN.tif
+    otbReflectanceToRadianceImageFilterAuto
     ${ROMEWV2DIR}/09DEC10103019-P2AS-052298844010_01_P001.TIF
-    ${ROMEWV2DIR}/raTvReflectanceToLuminanceImageFilterAutoWV2PAN.tif
+    ${ROMEWV2DIR}/raTvReflectanceToRadianceImageFilterAutoWV2PAN.tif
     )
 
   set(TEHERANSPOT5DIR ${TEMP}/OpticalCalibRefToLumSPOT5)
   file(MAKE_DIRECTORY ${TEHERANSPOT5DIR})
   file(GLOB MTDATA ${OTB_DATA_LARGEINPUT_ROOT}/SPOT5/TEHERAN/*.DIM)
   file(COPY ${MTDATA} DESTINATION ${TEHERANSPOT5DIR})
-  otb_copy_rename(${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoSpot5.tif ${TEHERANSPOT5DIR}/IMAGERY.TIF)
+  otb_copy_rename(${BASELINE}/raTvRadianceToReflectanceImageFilterAutoSpot5.tif ${TEHERANSPOT5DIR}/IMAGERY.TIF)
 
-  otb_add_test(NAME raTvReflectanceToLuminanceImageFilterAutoSpot5 COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoSpot5.tif
-    ${TEHERANSPOT5DIR}/raTvReflectanceToLuminanceImageFilterAutoSpot5.img
-    otbReflectanceToLuminanceImageFilterAuto
+  otb_add_test(NAME raTvReflectanceToRadianceImageFilterAutoSpot5 COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoSpot5.tif
+    ${TEHERANSPOT5DIR}/raTvReflectanceToRadianceImageFilterAutoSpot5.img
+    otbReflectanceToRadianceImageFilterAuto
     ${TEHERANSPOT5DIR}/IMAGERY.TIF
-    ${TEHERANSPOT5DIR}/raTvReflectanceToLuminanceImageFilterAutoSpot5.img
+    ${TEHERANSPOT5DIR}/raTvReflectanceToRadianceImageFilterAutoSpot5.img
     )
 
   set(BLOSSEVILLEIKONOSDIR ${TEMP}/OpticalCalibRefToLumIkonos)
   file(MAKE_DIRECTORY ${BLOSSEVILLEIKONOSDIR})
   file(GLOB MTDATA ${OTB_DATA_LARGEINPUT_ROOT}/IKONOS/BLOSSEVILLE/*metadata.txt ${OTB_DATA_LARGEINPUT_ROOT}/IKONOS/BLOSSEVILLE/*pan*)
   file(COPY ${MTDATA} DESTINATION ${BLOSSEVILLEIKONOSDIR})
-  otb_copy_rename(${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoIkonos.tif ${BLOSSEVILLEIKONOSDIR}/po_2619900_pan_0000000.tif)
+  otb_copy_rename(${BASELINE}/raTvRadianceToReflectanceImageFilterAutoIkonos.tif ${BLOSSEVILLEIKONOSDIR}/po_2619900_pan_0000000.tif)
 
-  otb_add_test(NAME raTvReflectanceToLuminanceImageFilterAutoIkonos COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoIkonos.tif
-    ${BLOSSEVILLEIKONOSDIR}/raTvReflectanceToLuminanceImageFilterAutoIkonos.tif
-    otbReflectanceToLuminanceImageFilterAuto
+  otb_add_test(NAME raTvReflectanceToRadianceImageFilterAutoIkonos COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoIkonos.tif
+    ${BLOSSEVILLEIKONOSDIR}/raTvReflectanceToRadianceImageFilterAutoIkonos.tif
+    otbReflectanceToRadianceImageFilterAuto
     ${BLOSSEVILLEIKONOSDIR}/po_2619900_pan_0000000.tif
-    ${BLOSSEVILLEIKONOSDIR}/raTvReflectanceToLuminanceImageFilterAutoIkonos.tif
+    ${BLOSSEVILLEIKONOSDIR}/raTvReflectanceToRadianceImageFilterAutoIkonos.tif
     )
 
   set(TOULOUSEQBDIR ${TEMP}/OpticalCalibRefToLumQBXS)
@@ -432,14 +432,14 @@ if(OTB_DATA_USE_LARGEINPUT)
   set(MTDATADIR ${OTB_DATA_LARGEINPUT_ROOT}/QUICKBIRD/TOULOUSE/000000128955_01_P001_MUL)
   file(GLOB MTDATA ${MTDATADIR}/*TIL ${MTDATADIR}/*RPB ${MTDATADIR}/*XML ${MTDATADIR}/*IMD)
   file(COPY ${MTDATA} DESTINATION ${TOULOUSEQBDIR})
-  otb_copy_rename(${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoQuickbirdXS.tif ${TOULOUSEQBDIR}/02APR01105228-M1BS-000000128955_01_P001.TIF)
+  otb_copy_rename(${BASELINE}/raTvRadianceToReflectanceImageFilterAutoQuickbirdXS.tif ${TOULOUSEQBDIR}/02APR01105228-M1BS-000000128955_01_P001.TIF)
 
-  otb_add_test(NAME raTvReflectanceToLuminanceImageFilterAutoQuickbirdXS COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoQuickbirdXS.tif
-    ${TOULOUSEQBDIR}/raTvReflectanceToLuminanceImageFilterAutoQuickbirdXS.tif
-    otbReflectanceToLuminanceImageFilterAuto
+  otb_add_test(NAME raTvReflectanceToRadianceImageFilterAutoQuickbirdXS COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoQuickbirdXS.tif
+    ${TOULOUSEQBDIR}/raTvReflectanceToRadianceImageFilterAutoQuickbirdXS.tif
+    otbReflectanceToRadianceImageFilterAuto
     ${TOULOUSEQBDIR}/02APR01105228-M1BS-000000128955_01_P001.TIF
-    ${TOULOUSEQBDIR}/raTvReflectanceToLuminanceImageFilterAutoQuickbirdXS.tif
+    ${TOULOUSEQBDIR}/raTvReflectanceToRadianceImageFilterAutoQuickbirdXS.tif
     )
 
   set(ROMEWV2DIR ${TEMP}/OpticalCalibRefToLumWv2MULTI)
@@ -447,14 +447,14 @@ if(OTB_DATA_USE_LARGEINPUT)
   set(MTDATADIR ${OTB_DATA_LARGEINPUT_ROOT}/WORLDVIEW2/ROME/WV-2_standard_8band_bundle_16bit/052298844010_01_P001_MUL)
   file(GLOB MTDATA ${MTDATADIR}/*TIL ${MTDATADIR}/*RPB ${MTDATADIR}/*XML ${MTDATADIR}/*IMD)
   file(COPY ${MTDATA} DESTINATION ${ROMEWV2DIR})
-  otb_copy_rename(${BASELINE}/raTvLuminanceToReflectanceImageFilterAutoWV2Multi.tif ${ROMEWV2DIR}/09DEC10103019-M2AS-052298844010_01_P001.TIF)
+  otb_copy_rename(${BASELINE}/raTvRadianceToReflectanceImageFilterAutoWV2Multi.tif ${ROMEWV2DIR}/09DEC10103019-M2AS-052298844010_01_P001.TIF)
 
-  otb_add_test(NAME raTvReflectanceToLuminanceImageFilterAutoWV2MULTI COMMAND otbOpticalCalibrationTestDriver
-    --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoWV2Multi.tif
-    ${ROMEWV2DIR}/raTvReflectanceToLuminanceImageFilterAutoWV2Multi.tif
-    otbReflectanceToLuminanceImageFilterAuto
+  otb_add_test(NAME raTvReflectanceToRadianceImageFilterAutoWV2MULTI COMMAND otbOpticalCalibrationTestDriver
+    --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoWV2Multi.tif
+    ${ROMEWV2DIR}/raTvReflectanceToRadianceImageFilterAutoWV2Multi.tif
+    otbReflectanceToRadianceImageFilterAuto
     ${ROMEWV2DIR}/09DEC10103019-M2AS-052298844010_01_P001.TIF
-    ${ROMEWV2DIR}/raTvReflectanceToLuminanceImageFilterAutoWV2Multi.tif
+    ${ROMEWV2DIR}/raTvReflectanceToRadianceImageFilterAutoWV2Multi.tif
     )
 
 endif()
@@ -621,12 +621,12 @@ otb_add_test(NAME raTvRomaniaImageToReflectance COMMAND otbOpticalCalibrationTes
   0.9889145564708814   #= sqrt(0.977952) d/d0 corresponding to the date 03/05
   )
 
-otb_add_test(NAME raTvLuminanceToReflectanceImageFilterDayMonth COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvLuminanceToReflectanceImageFilter.tif
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterDayMonth.tif
-  otbLuminanceToReflectanceImageFilter
+otb_add_test(NAME raTvRadianceToReflectanceImageFilterDayMonth COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvRadianceToReflectanceImageFilter.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterDayMonth.tif
+  otbRadianceToReflectanceImageFilter
   ${INPUTDATA}/verySmallFSATSW.tif
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterDayMonth.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterDayMonth.tif
   0.2 #radius
   10  #channel 1 illumination
   20  #channel 2 illumination
@@ -636,12 +636,12 @@ otb_add_test(NAME raTvLuminanceToReflectanceImageFilterDayMonth COMMAND otbOptic
   5   #month
   )
 
-otb_add_test(NAME raTvLuminanceToReflectanceImageFilter COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvLuminanceToReflectanceImageFilterDsol.tif
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterDsol.tif
-  otbLuminanceToReflectanceImageFilter
+otb_add_test(NAME raTvRadianceToReflectanceImageFilter COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvRadianceToReflectanceImageFilterDsol.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterDsol.tif
+  otbRadianceToReflectanceImageFilter
   ${INPUTDATA}/verySmallFSATSW.tif
-  ${TEMP}/raTvLuminanceToReflectanceImageFilterDsol.tif
+  ${TEMP}/raTvRadianceToReflectanceImageFilterDsol.tif
   0.2 #radius
   10  #channel 1 illumination
   20  #channel 2 illumination
@@ -748,60 +748,60 @@ otb_add_test(NAME raTuImageMetadataCorrectionParametersNew COMMAND otbOpticalCal
   otbImageMetadataCorrectionParametersNew
   )
 
-otb_add_test(NAME raTvImageToLuminanceImageFilterAutoFORMOSAT COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoFormosat.tif
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoFormosat.img
-  otbImageToLuminanceImageFilterAuto
+otb_add_test(NAME raTvImageToRadianceImageFilterAutoFORMOSAT COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoFormosat.tif
+  ${TEMP}/raTvImageToRadianceImageFilterAutoFormosat.img
+  otbImageToRadianceImageFilterAuto
   LARGEINPUT{FORMOSAT/Sudouest_20071013_MS_fmsat/IMAGERY.TIF}
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoFormosat.img
+  ${TEMP}/raTvImageToRadianceImageFilterAutoFormosat.img
   )
 
-otb_add_test(NAME raTvImageToLuminanceImageFilterAutoIkonos COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoIkonos.tif
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoIkonos.tif
-  otbImageToLuminanceImageFilterAuto
+otb_add_test(NAME raTvImageToRadianceImageFilterAutoIkonos COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoIkonos.tif
+  ${TEMP}/raTvImageToRadianceImageFilterAutoIkonos.tif
+  otbImageToRadianceImageFilterAuto
   LARGEINPUT{IKONOS/BLOSSEVILLE/po_2619900_pan_0000000.tif}
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoIkonos.tif
+  ${TEMP}/raTvImageToRadianceImageFilterAutoIkonos.tif
   )
 
-otb_add_test(NAME raTvImageToLuminanceImageFilterAutoQuickbirdXS COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoQuickbirdXS.tif
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoQuickbirdXS.tif
-  otbImageToLuminanceImageFilterAuto
+otb_add_test(NAME raTvImageToRadianceImageFilterAutoQuickbirdXS COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoQuickbirdXS.tif
+  ${TEMP}/raTvImageToRadianceImageFilterAutoQuickbirdXS.tif
+  otbImageToRadianceImageFilterAuto
   LARGEINPUT{QUICKBIRD/TOULOUSE/000000128955_01_P001_MUL/02APR01105228-M1BS-000000128955_01_P001.TIF}
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoQuickbirdXS.tif
+  ${TEMP}/raTvImageToRadianceImageFilterAutoQuickbirdXS.tif
   )
 
-otb_add_test(NAME raTvImageToLuminanceImageFilterAutoQuickbirdPAN COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoQuickbirdPAN.tif
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoQuickbirdPAN.tif
-  otbImageToLuminanceImageFilterAuto
+otb_add_test(NAME raTvImageToRadianceImageFilterAutoQuickbirdPAN COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoQuickbirdPAN.tif
+  ${TEMP}/raTvImageToRadianceImageFilterAutoQuickbirdPAN.tif
+  otbImageToRadianceImageFilterAuto
   LARGEINPUT{QUICKBIRD/TOULOUSE/000000128955_01_P001_PAN/02APR01105228-P1BS-000000128955_01_P001.TIF}
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoQuickbirdPAN.tif
+  ${TEMP}/raTvImageToRadianceImageFilterAutoQuickbirdPAN.tif
   )
 
-otb_add_test(NAME raTvImageToLuminanceImageFilterAutoWV2MULTI COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoWV2Multi.tif
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoWV2Multi.tif
-  otbImageToLuminanceImageFilterAuto
+otb_add_test(NAME raTvImageToRadianceImageFilterAutoWV2MULTI COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoWV2Multi.tif
+  ${TEMP}/raTvImageToRadianceImageFilterAutoWV2Multi.tif
+  otbImageToRadianceImageFilterAuto
   LARGEINPUT{WORLDVIEW2/ROME/WV-2_standard_8band_bundle_16bit/052298844010_01_P001_MUL/09DEC10103019-M2AS-052298844010_01_P001.TIF}
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoWV2Multi.tif
+  ${TEMP}/raTvImageToRadianceImageFilterAutoWV2Multi.tif
   )
 
-otb_add_test(NAME raTvImageToLuminanceImageFilterAutoSpot5 COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoSpot5.tif
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoSpot5.img
-  otbImageToLuminanceImageFilterAuto
+otb_add_test(NAME raTvImageToRadianceImageFilterAutoSpot5 COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoSpot5.tif
+  ${TEMP}/raTvImageToRadianceImageFilterAutoSpot5.img
+  otbImageToRadianceImageFilterAuto
   LARGEINPUT{SPOT5/TEHERAN/IMAGERY.TIF}
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoSpot5.img
+  ${TEMP}/raTvImageToRadianceImageFilterAutoSpot5.img
   )
 
-otb_add_test(NAME raTvImageToLuminanceImageFilterAutoWV2PAN COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilterAutoWV2PAN.tif
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoWV2PAN.tif
-  otbImageToLuminanceImageFilterAuto
+otb_add_test(NAME raTvImageToRadianceImageFilterAutoWV2PAN COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilterAutoWV2PAN.tif
+  ${TEMP}/raTvImageToRadianceImageFilterAutoWV2PAN.tif
+  otbImageToRadianceImageFilterAuto
   LARGEINPUT{WORLDVIEW2/ROME/WV-2_standard_8band_bundle_16bit/052298844010_01_P001_PAN/09DEC10103019-P2AS-052298844010_01_P001.TIF}
-  ${TEMP}/raTvImageToLuminanceImageFilterAutoWV2PAN.tif
+  ${TEMP}/raTvImageToRadianceImageFilterAutoWV2PAN.tif
   )
 
 otb_add_test(NAME raTvAtmosphericCorrectionSequencementTest COMMAND otbOpticalCalibrationTestDriver
@@ -860,11 +860,11 @@ otb_add_test(NAME raTvSurfaceAdjacencyEffectCorrectionSchemeFilter COMMAND otbOp
   ${TEMP}/raTvSurfaceAdjacencyEffect6SCorrectionSchemeFilterOutput6SVallues.txt
   )
 
-otb_add_test(NAME raTvLuminanceToImageImageFilter COMMAND otbOpticalCalibrationTestDriver
+otb_add_test(NAME raTvRadianceToImageImageFilter COMMAND otbOpticalCalibrationTestDriver
   --compare-image ${EPSILON_12}  ${INPUTDATA}/verySmallFSATSW.tif
   ${TEMP}/raTvverySmallFSATSWImageFilter.tif
-  otbLuminanceToImageImageFilter
-  ${BASELINE}/raTvImageToLuminanceImageFilter.tif
+  otbRadianceToImageImageFilter
+  ${BASELINE}/raTvImageToRadianceImageFilter.tif
   ${TEMP}/raTvverySmallFSATSWImageFilter.tif
   10   #channel 1 alpha
   20   #channel 2 alpha
@@ -876,11 +876,11 @@ otb_add_test(NAME raTvLuminanceToImageImageFilter COMMAND otbOpticalCalibrationT
   4    #channel 4 beta
   )
 
-otb_add_test(NAME raTvReflectanceToLuminanceImageFilter COMMAND otbOpticalCalibrationTestDriver
+otb_add_test(NAME raTvReflectanceToRadianceImageFilter COMMAND otbOpticalCalibrationTestDriver
   --compare-image ${EPSILON_12}  ${INPUTDATA}/verySmallFSATSW.tif
   ${TEMP}/raTvverySmallFSATSWImageFilterDsol.tif
-  otbReflectanceToLuminanceImageFilter
-  ${BASELINE}/raTvLuminanceToReflectanceImageFilterDsol.tif
+  otbReflectanceToRadianceImageFilter
+  ${BASELINE}/raTvRadianceToReflectanceImageFilterDsol.tif
   ${TEMP}/raTvverySmallFSATSWImageFilterDsol.tif
   0.2 #radius
   10  #channel 1 illumination
@@ -890,11 +890,11 @@ otb_add_test(NAME raTvReflectanceToLuminanceImageFilter COMMAND otbOpticalCalibr
   0.9923885328
   )
 
-otb_add_test(NAME raTvReflectanceToLuminanceImageFilterDayMonth COMMAND otbOpticalCalibrationTestDriver
+otb_add_test(NAME raTvReflectanceToRadianceImageFilterDayMonth COMMAND otbOpticalCalibrationTestDriver
   --compare-image ${EPSILON_12}  ${INPUTDATA}/verySmallFSATSW.tif
   ${TEMP}/raTvverySmallFSATSWImageFilterDayMonth.tif
-  otbReflectanceToLuminanceImageFilter
-  ${BASELINE}/raTvLuminanceToReflectanceImageFilter.tif
+  otbReflectanceToRadianceImageFilter
+  ${BASELINE}/raTvRadianceToReflectanceImageFilter.tif
   ${TEMP}/raTvverySmallFSATSWImageFilterDayMonth.tif
   0.2 #radius
   10  #channel 1 illumination
@@ -905,12 +905,12 @@ otb_add_test(NAME raTvReflectanceToLuminanceImageFilterDayMonth COMMAND otbOptic
   5   #month
   )
 
-otb_add_test(NAME raTvImageToLuminanceImageFilter COMMAND otbOpticalCalibrationTestDriver
-  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToLuminanceImageFilter.tif
-  ${TEMP}/raTvImageToLuminanceImageFilter.tif
-  otbImageToLuminanceImageFilter
+otb_add_test(NAME raTvImageToRadianceImageFilter COMMAND otbOpticalCalibrationTestDriver
+  --compare-image ${EPSILON_12}  ${BASELINE}/raTvImageToRadianceImageFilter.tif
+  ${TEMP}/raTvImageToRadianceImageFilter.tif
+  otbImageToRadianceImageFilter
   ${INPUTDATA}/verySmallFSATSW.tif
-  ${TEMP}/raTvImageToLuminanceImageFilter.tif
+  ${TEMP}/raTvImageToRadianceImageFilter.tif
   10   #channel 1 alpha
   20   #channel 2 alpha
   30   #channel 3 alpha
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbAtmosphericCorrectionSequencement.cxx b/Modules/Radiometry/OpticalCalibration/test/otbAtmosphericCorrectionSequencement.cxx
index 5603540..0e1d8a9 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbAtmosphericCorrectionSequencement.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbAtmosphericCorrectionSequencement.cxx
@@ -20,8 +20,8 @@
 
 
 
-#include "otbImageToLuminanceImageFilter.h"
-#include "otbLuminanceToReflectanceImageFilter.h"
+#include "otbImageToRadianceImageFilter.h"
+#include "otbRadianceToReflectanceImageFilter.h"
 #include "otbReflectanceToSurfaceReflectanceImageFilter.h"
 #include "otbSurfaceAdjacencyEffectCorrectionSchemeFilter.h"
 
@@ -63,9 +63,9 @@ int otbAtmosphericCorrectionSequencementTest(int argc, char *argv[])
 
 //-------------------------------
 
-  typedef otb::ImageToLuminanceImageFilter<ImageType, ImageType>
-  ImageToLuminanceImageFilterType;
-  typedef ImageToLuminanceImageFilterType::VectorType VectorType;
+  typedef otb::ImageToRadianceImageFilter<ImageType, ImageType>
+  ImageToRadianceImageFilterType;
+  typedef ImageToRadianceImageFilterType::VectorType VectorType;
 
   VectorType alpha(nbOfComponent);
   VectorType beta(nbOfComponent);
@@ -84,16 +84,16 @@ int otbAtmosphericCorrectionSequencementTest(int argc, char *argv[])
     }
   fin.close();
 
-  ImageToLuminanceImageFilterType::Pointer filterImageToLuminance = ImageToLuminanceImageFilterType::New();
-  filterImageToLuminance->SetAlpha(alpha);
-  filterImageToLuminance->SetBeta(beta);
-  filterImageToLuminance->SetInput(reader->GetOutput());
+  ImageToRadianceImageFilterType::Pointer filterImageToRadiance = ImageToRadianceImageFilterType::New();
+  filterImageToRadiance->SetAlpha(alpha);
+  filterImageToRadiance->SetBeta(beta);
+  filterImageToRadiance->SetInput(reader->GetOutput());
 
 //-------------------------------
-  typedef otb::LuminanceToReflectanceImageFilter<ImageType, ImageType>
-  LuminanceToReflectanceImageFilterType;
+  typedef otb::RadianceToReflectanceImageFilter<ImageType, ImageType>
+  RadianceToReflectanceImageFilterType;
 
-  typedef LuminanceToReflectanceImageFilterType::VectorType VectorType;
+  typedef RadianceToReflectanceImageFilterType::VectorType VectorType;
 
   VectorType solarIllumination(nbOfComponent);
   solarIllumination.Fill(0);
@@ -107,16 +107,16 @@ int otbAtmosphericCorrectionSequencementTest(int argc, char *argv[])
     }
   fin.close();
 
-  LuminanceToReflectanceImageFilterType::Pointer filterLuminanceToReflectance =
-    LuminanceToReflectanceImageFilterType::New();
+  RadianceToReflectanceImageFilterType::Pointer filterRadianceToReflectance =
+    RadianceToReflectanceImageFilterType::New();
   const int day(atoi(argv[5]));
   const int month(atoi(argv[6]));
 
-  filterLuminanceToReflectance->SetZenithalSolarAngle(static_cast<double>(atof(argv[4])));
-  filterLuminanceToReflectance->SetDay(day);
-  filterLuminanceToReflectance->SetMonth(month);
-  filterLuminanceToReflectance->SetSolarIllumination(solarIllumination);
-  filterLuminanceToReflectance->SetInput(filterImageToLuminance->GetOutput());
+  filterRadianceToReflectance->SetZenithalSolarAngle(static_cast<double>(atof(argv[4])));
+  filterRadianceToReflectance->SetDay(day);
+  filterRadianceToReflectance->SetMonth(month);
+  filterRadianceToReflectance->SetSolarIllumination(solarIllumination);
+  filterRadianceToReflectance->SetInput(filterImageToRadiance->GetOutput());
 
 //-------------------------------
   /*typedef otb::RadiometryCorrectionParametersToAtmosphericRadiativeTerms  RadiometryCorrectionParametersToRadiativeTermsType;
@@ -189,7 +189,7 @@ int otbAtmosphericCorrectionSequencementTest(int argc, char *argv[])
   fin.close();
 
   // Set parameters
-  /*dataAtmosphericCorrectionParameters->SetSolarZenithalAngle(filterLuminanceToReflectance->GetZenithalSolarAngle());
+  /*dataAtmosphericCorrectionParameters->SetSolarZenithalAngle(filterRadianceToReflectance->GetZenithalSolarAngle());
   dataAtmosphericCorrectionParameters->SetSolarAzimutalAngle(static_cast<double>(atof(argv[8])));
   dataAtmosphericCorrectionParameters->SetViewingZenithalAngle(static_cast<double>(atof(argv[9])));
   dataAtmosphericCorrectionParameters->SetViewingAzimutalAngle(static_cast<double>(atof(argv[10])));
@@ -208,7 +208,7 @@ int otbAtmosphericCorrectionSequencementTest(int argc, char *argv[])
   filterAtmosphericCorrectionParametersTo6SRadiativeTerms->SetInput(dataAtmosphericCorrectionParameters);
   filterAtmosphericCorrectionParametersTo6SRadiativeTerms->Update(); */
 
-  paramAcqui->SetSolarZenithalAngle(filterLuminanceToReflectance->GetZenithalSolarAngle());
+  paramAcqui->SetSolarZenithalAngle(filterRadianceToReflectance->GetZenithalSolarAngle());
   paramAcqui->SetSolarAzimutalAngle(static_cast<double>(atof(argv[8])));
   paramAcqui->SetViewingZenithalAngle(static_cast<double>(atof(argv[9])));
   paramAcqui->SetViewingAzimutalAngle(static_cast<double>(atof(argv[10])));
@@ -231,7 +231,7 @@ int otbAtmosphericCorrectionSequencementTest(int argc, char *argv[])
     ReflectanceToSurfaceReflectanceImageFilterType::New();
 
   filterReflectanceToSurfaceReflectanceImageFilter->SetAtmosphericRadiativeTerms(radiative);
-  filterReflectanceToSurfaceReflectanceImageFilter->SetInput(filterLuminanceToReflectance->GetOutput());
+  filterReflectanceToSurfaceReflectanceImageFilter->SetInput(filterRadianceToReflectance->GetOutput());
 
 //-------------------------------
   typedef otb::SurfaceAdjacencyEffectCorrectionSchemeFilter<ImageType,
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbImageToLuminanceImageFilter.cxx b/Modules/Radiometry/OpticalCalibration/test/otbImageToRadianceImageFilter.cxx
similarity index 84%
rename from Modules/Radiometry/OpticalCalibration/test/otbImageToLuminanceImageFilter.cxx
rename to Modules/Radiometry/OpticalCalibration/test/otbImageToRadianceImageFilter.cxx
index ff31be6..130e08b 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbImageToLuminanceImageFilter.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbImageToRadianceImageFilter.cxx
@@ -20,11 +20,11 @@
 
 #include "itkMacro.h"
 
-#include "otbImageToLuminanceImageFilter.h"
+#include "otbImageToRadianceImageFilter.h"
 #include "otbImageFileReader.h"
 #include "otbImageFileWriter.h"
 
-int otbImageToLuminanceImageFilter(int itkNotUsed(argc), char * argv[])
+int otbImageToRadianceImageFilter(int itkNotUsed(argc), char * argv[])
 {
   const char * inputFileName  = argv[1];
   const char * outputFileName = argv[2];
@@ -35,8 +35,8 @@ int otbImageToLuminanceImageFilter(int itkNotUsed(argc), char * argv[])
   typedef otb::VectorImage<PixelType, Dimension>                            OutputImageType;
   typedef otb::ImageFileReader<InputImageType>                              ReaderType;
   typedef otb::ImageFileWriter<OutputImageType>                             WriterType;
-  typedef otb::ImageToLuminanceImageFilter<InputImageType, OutputImageType> ImageToLuminanceImageFilterType;
-  typedef ImageToLuminanceImageFilterType::VectorType                       VectorType;
+  typedef otb::ImageToRadianceImageFilter<InputImageType, OutputImageType> ImageToRadianceImageFilterType;
+  typedef ImageToRadianceImageFilterType::VectorType                       VectorType;
 
   ReaderType::Pointer reader  = ReaderType::New();
   WriterType::Pointer writer = WriterType::New();
@@ -58,7 +58,7 @@ int otbImageToLuminanceImageFilter(int itkNotUsed(argc), char * argv[])
     }
 
   // Instantiating object
-  ImageToLuminanceImageFilterType::Pointer filter = ImageToLuminanceImageFilterType::New();
+  ImageToRadianceImageFilterType::Pointer filter = ImageToRadianceImageFilterType::New();
   filter->SetAlpha(alpha);
   filter->SetBeta(beta);
   filter->SetInput(reader->GetOutput());
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbImageToLuminanceImageFilterAuto.cxx b/Modules/Radiometry/OpticalCalibration/test/otbImageToRadianceImageFilterAuto.cxx
similarity index 86%
rename from Modules/Radiometry/OpticalCalibration/test/otbImageToLuminanceImageFilterAuto.cxx
rename to Modules/Radiometry/OpticalCalibration/test/otbImageToRadianceImageFilterAuto.cxx
index fccdd66..a5225ac 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbImageToLuminanceImageFilterAuto.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbImageToRadianceImageFilterAuto.cxx
@@ -19,13 +19,13 @@
  */
 
 
-#include "otbImageToLuminanceImageFilter.h"
+#include "otbImageToRadianceImageFilter.h"
 #include "otbImageFileReader.h"
 #include "otbImageFileWriter.h"
 #include "otbMultiChannelExtractROI.h"
 
 //Test the retrieval of parameters from the image metadata
-int otbImageToLuminanceImageFilterAuto(int itkNotUsed(argc), char * argv[])
+int otbImageToRadianceImageFilterAuto(int itkNotUsed(argc), char * argv[])
 {
   const char * inputFileName  = argv[1];
   const char * outputFileName = argv[2];
@@ -36,7 +36,7 @@ int otbImageToLuminanceImageFilterAuto(int itkNotUsed(argc), char * argv[])
   typedef otb::VectorImage<PixelType, Dimension>                            OutputImageType;
   typedef otb::ImageFileReader<InputImageType>                              ReaderType;
   typedef otb::ImageFileWriter<OutputImageType>                             WriterType;
-  typedef otb::ImageToLuminanceImageFilter<InputImageType, OutputImageType> ImageToLuminanceImageFilterType;
+  typedef otb::ImageToRadianceImageFilter<InputImageType, OutputImageType> ImageToRadianceImageFilterType;
   typedef otb::MultiChannelExtractROI<PixelType, PixelType>                 RoiFilterType;
 
   ReaderType::Pointer reader  = ReaderType::New();
@@ -46,7 +46,7 @@ int otbImageToLuminanceImageFilterAuto(int itkNotUsed(argc), char * argv[])
   reader->UpdateOutputInformation();
 
   // Instantiating object
-  ImageToLuminanceImageFilterType::Pointer filter = ImageToLuminanceImageFilterType::New();
+  ImageToRadianceImageFilterType::Pointer filter = ImageToRadianceImageFilterType::New();
   filter->SetInput(reader->GetOutput());
 
   RoiFilterType::Pointer roiFilter = RoiFilterType::New();
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbImageToLuminanceImageFilterNew.cxx b/Modules/Radiometry/OpticalCalibration/test/otbImageToRadianceImageFilterNew.cxx
similarity index 75%
rename from Modules/Radiometry/OpticalCalibration/test/otbImageToLuminanceImageFilterNew.cxx
rename to Modules/Radiometry/OpticalCalibration/test/otbImageToRadianceImageFilterNew.cxx
index ebc20d7..83086a2 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbImageToLuminanceImageFilterNew.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbImageToRadianceImageFilterNew.cxx
@@ -20,18 +20,18 @@
 
 #include "itkMacro.h"
 
-#include "otbImageToLuminanceImageFilter.h"
+#include "otbImageToRadianceImageFilter.h"
 
-int otbImageToLuminanceImageFilterNew(int itkNotUsed(argc), char * itkNotUsed(argv)[])
+int otbImageToRadianceImageFilterNew(int itkNotUsed(argc), char * itkNotUsed(argv)[])
 {
   const unsigned int Dimension = 2;
   typedef double                                 PixelType;
   typedef otb::VectorImage<PixelType, Dimension> InputImageType;
 
-  typedef otb::ImageToLuminanceImageFilter<InputImageType, InputImageType> ImageToLuminanceImageFilterType;
+  typedef otb::ImageToRadianceImageFilter<InputImageType, InputImageType> ImageToRadianceImageFilterType;
 
   // Instantiating object
-  ImageToLuminanceImageFilterType::Pointer filter = ImageToLuminanceImageFilterType::New();
+  ImageToRadianceImageFilterType::Pointer filter = ImageToRadianceImageFilterType::New();
 
   std::cout << filter << std::endl;
 
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbOpticalCalibrationTestDriver.cxx b/Modules/Radiometry/OpticalCalibration/test/otbOpticalCalibrationTestDriver.cxx
index 244ebdc..d9d6d93 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbOpticalCalibrationTestDriver.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbOpticalCalibrationTestDriver.cxx
@@ -26,14 +26,14 @@ void RegisterTests()
   REGISTER_TEST(otbSpectralSensitivityReaderTest);
   REGISTER_TEST(otbSpectralSensitivityReaderGenericTest);
   REGISTER_TEST(otbReflectanceToImageImageFilter);
-  REGISTER_TEST(otbReflectanceToLuminanceImageFilterNew);
-  REGISTER_TEST(otbLuminanceToReflectanceImageFilterNew);
-  REGISTER_TEST(otbLuminanceToReflectanceImageFilterAuto);
-  REGISTER_TEST(otbImageToLuminanceImageFilterNew);
+  REGISTER_TEST(otbReflectanceToRadianceImageFilterNew);
+  REGISTER_TEST(otbRadianceToReflectanceImageFilterNew);
+  REGISTER_TEST(otbRadianceToReflectanceImageFilterAuto);
+  REGISTER_TEST(otbImageToRadianceImageFilterNew);
   REGISTER_TEST(otbRadiometryCorrectionParametersToAtmosphericRadiativeTermsNew);
-  REGISTER_TEST(otbLuminanceToImageImageFilterAuto);
-  REGISTER_TEST(otbLuminanceToImageImageFilterNew);
-  REGISTER_TEST(otbReflectanceToLuminanceImageFilterAuto);
+  REGISTER_TEST(otbRadianceToImageImageFilterAuto);
+  REGISTER_TEST(otbRadianceToImageImageFilterNew);
+  REGISTER_TEST(otbReflectanceToRadianceImageFilterAuto);
   REGISTER_TEST(otbAeronetExtractDataBadData);
   REGISTER_TEST(otbRomaniaReflectanceToRomaniaSurfaceReflectanceImageFilter);
   REGISTER_TEST(otbRadiometryCorrectionParametersToAtmosphericRadiativeTerms);
@@ -47,7 +47,7 @@ void RegisterTests()
   REGISTER_TEST(otbAtmosphericRadiativeTermsSingleChannelNew);
   REGISTER_TEST(otbAtmosphericRadiativeTermsTest);
   REGISTER_TEST(otbImageToReflectanceImageFilter);
-  REGISTER_TEST(otbLuminanceToReflectanceImageFilter);
+  REGISTER_TEST(otbRadianceToReflectanceImageFilter);
   REGISTER_TEST(otbReflectanceToImageImageFilterAuto);
   REGISTER_TEST(otbAeronetNew);
   REGISTER_TEST(otbAeronetExtractData);
@@ -55,13 +55,13 @@ void RegisterTests()
   REGISTER_TEST(otbReflectanceToSurfaceReflectanceImageFilterTest);
   REGISTER_TEST(otbReflectanceToSurfaceReflectanceImageFilterTest2);
   REGISTER_TEST(otbImageMetadataCorrectionParametersNew);
-  REGISTER_TEST(otbImageToLuminanceImageFilterAuto);
+  REGISTER_TEST(otbImageToRadianceImageFilterAuto);
   REGISTER_TEST(otbAtmosphericCorrectionSequencementTest);
   REGISTER_TEST(otbSIXSTraitsTest);
   REGISTER_TEST(otbSIXSTraitsComputeAtmosphericParametersTest);
   REGISTER_TEST(otbReflectanceToImageImageFilterNew);
   REGISTER_TEST(otbSurfaceAdjacencyEffectCorrectionSchemeFilter);
-  REGISTER_TEST(otbLuminanceToImageImageFilter);
-  REGISTER_TEST(otbReflectanceToLuminanceImageFilter);
-  REGISTER_TEST(otbImageToLuminanceImageFilter);
+  REGISTER_TEST(otbRadianceToImageImageFilter);
+  REGISTER_TEST(otbReflectanceToRadianceImageFilter);
+  REGISTER_TEST(otbImageToRadianceImageFilter);
 }
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbLuminanceToImageImageFilter.cxx b/Modules/Radiometry/OpticalCalibration/test/otbRadianceToImageImageFilter.cxx
similarity index 84%
rename from Modules/Radiometry/OpticalCalibration/test/otbLuminanceToImageImageFilter.cxx
rename to Modules/Radiometry/OpticalCalibration/test/otbRadianceToImageImageFilter.cxx
index 1b75114..3753231 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbLuminanceToImageImageFilter.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbRadianceToImageImageFilter.cxx
@@ -20,13 +20,13 @@
 
 #include "itkMacro.h"
 
-#include "otbLuminanceToImageImageFilter.h"
+#include "otbRadianceToImageImageFilter.h"
 #include "otbVectorImage.h"
 #include "otbImageFileReader.h"
 #include "otbImageFileWriter.h"
 #include "itkVariableLengthVector.h"
 
-int otbLuminanceToImageImageFilter(int itkNotUsed(argc), char * argv[])
+int otbRadianceToImageImageFilter(int itkNotUsed(argc), char * argv[])
 {
   const char * inputFileName  = argv[1];
   const char * outputFileName = argv[2];
@@ -37,8 +37,8 @@ int otbLuminanceToImageImageFilter(int itkNotUsed(argc), char * argv[])
   typedef otb::VectorImage<PixelType, Dimension>                            OutputImageType;
   typedef otb::ImageFileReader<InputImageType>                              ReaderType;
   typedef otb::ImageFileWriter<OutputImageType>                             WriterType;
-  typedef otb::LuminanceToImageImageFilter<InputImageType, OutputImageType> LuminanceToImageImageFilterType;
-  typedef LuminanceToImageImageFilterType::VectorType                       VectorType;
+  typedef otb::RadianceToImageImageFilter<InputImageType, OutputImageType> RadianceToImageImageFilterType;
+  typedef RadianceToImageImageFilterType::VectorType                       VectorType;
 
   ReaderType::Pointer reader  = ReaderType::New();
   WriterType::Pointer writer = WriterType::New();
@@ -60,7 +60,7 @@ int otbLuminanceToImageImageFilter(int itkNotUsed(argc), char * argv[])
     }
 
   // Instantiating object
-  LuminanceToImageImageFilterType::Pointer filter = LuminanceToImageImageFilterType::New();
+  RadianceToImageImageFilterType::Pointer filter = RadianceToImageImageFilterType::New();
   filter->SetAlpha(alpha);
   filter->SetBeta(beta);
   filter->SetInput(reader->GetOutput());
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbLuminanceToImageImageFilterAuto.cxx b/Modules/Radiometry/OpticalCalibration/test/otbRadianceToImageImageFilterAuto.cxx
similarity index 88%
rename from Modules/Radiometry/OpticalCalibration/test/otbLuminanceToImageImageFilterAuto.cxx
rename to Modules/Radiometry/OpticalCalibration/test/otbRadianceToImageImageFilterAuto.cxx
index a7d7c2f..55dfb6d 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbLuminanceToImageImageFilterAuto.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbRadianceToImageImageFilterAuto.cxx
@@ -19,13 +19,13 @@
  */
 
 
-#include "otbLuminanceToImageImageFilter.h"
+#include "otbRadianceToImageImageFilter.h"
 #include "otbImageFileReader.h"
 #include "otbImageFileWriter.h"
 #include "otbMultiChannelExtractROI.h"
 
 //Test the retrieval of parameters from the image metadata
-int otbLuminanceToImageImageFilterAuto(int itkNotUsed(argc), char * argv[])
+int otbRadianceToImageImageFilterAuto(int itkNotUsed(argc), char * argv[])
 {
   const char * inputFileName  = argv[1];
   const char * inputFileName2  = argv[2];
@@ -38,7 +38,7 @@ int otbLuminanceToImageImageFilterAuto(int itkNotUsed(argc), char * argv[])
   typedef otb::VectorImage<PixelType, Dimension>                            OutputImageType;
   typedef otb::ImageFileReader<InputImageType>                              ReaderType;
   typedef otb::ImageFileWriter<OutputImageType>                             WriterType;
-  typedef otb::LuminanceToImageImageFilter<InputImageType, OutputImageType> LuminanceToImageImageFilterType;
+  typedef otb::RadianceToImageImageFilter<InputImageType, OutputImageType> RadianceToImageImageFilterType;
   typedef otb::MultiChannelExtractROI<PixelType, PixelType>                 RoiFilterType;
 
   ReaderType::Pointer reader  = ReaderType::New();
@@ -54,7 +54,7 @@ int otbLuminanceToImageImageFilterAuto(int itkNotUsed(argc), char * argv[])
   reader2->UpdateOutputInformation();
 
   // Instantiating object
-  LuminanceToImageImageFilterType::Pointer filter = LuminanceToImageImageFilterType::New();
+  RadianceToImageImageFilterType::Pointer filter = RadianceToImageImageFilterType::New();
 
   filter->SetInput(reader->GetOutput());
   writer->SetInput(filter->GetOutput());
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbLuminanceToImageImageFilterNew.cxx b/Modules/Radiometry/OpticalCalibration/test/otbRadianceToImageImageFilterNew.cxx
similarity index 75%
rename from Modules/Radiometry/OpticalCalibration/test/otbLuminanceToImageImageFilterNew.cxx
rename to Modules/Radiometry/OpticalCalibration/test/otbRadianceToImageImageFilterNew.cxx
index b33f89f..ca4a7be 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbLuminanceToImageImageFilterNew.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbRadianceToImageImageFilterNew.cxx
@@ -20,19 +20,19 @@
 
 #include "itkMacro.h"
 
-#include "otbLuminanceToImageImageFilter.h"
+#include "otbRadianceToImageImageFilter.h"
 #include "otbVectorImage.h"
 
-int otbLuminanceToImageImageFilterNew(int itkNotUsed(argc), char * itkNotUsed(argv)[])
+int otbRadianceToImageImageFilterNew(int itkNotUsed(argc), char * itkNotUsed(argv)[])
 {
   const unsigned int Dimension = 2;
   typedef double                                 PixelType;
   typedef otb::VectorImage<PixelType, Dimension> InputImageType;
 
-  typedef otb::LuminanceToImageImageFilter<InputImageType, InputImageType> LuminanceToImageImageFilterType;
+  typedef otb::RadianceToImageImageFilter<InputImageType, InputImageType> RadianceToImageImageFilterType;
 
   // Instantiating object
-  LuminanceToImageImageFilterType::Pointer filter = LuminanceToImageImageFilterType::New();
+  RadianceToImageImageFilterType::Pointer filter = RadianceToImageImageFilterType::New();
 
   std::cout << filter << std::endl;
 
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbLuminanceToReflectanceImageFilter.cxx b/Modules/Radiometry/OpticalCalibration/test/otbRadianceToReflectanceImageFilter.cxx
similarity index 86%
rename from Modules/Radiometry/OpticalCalibration/test/otbLuminanceToReflectanceImageFilter.cxx
rename to Modules/Radiometry/OpticalCalibration/test/otbRadianceToReflectanceImageFilter.cxx
index 111a0c6..144781c 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbLuminanceToReflectanceImageFilter.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbRadianceToReflectanceImageFilter.cxx
@@ -20,12 +20,12 @@
 
 #include "itkMacro.h"
 
-#include "otbLuminanceToReflectanceImageFilter.h"
+#include "otbRadianceToReflectanceImageFilter.h"
 #include "otbVectorImage.h"
 #include "otbImageFileReader.h"
 #include "otbImageFileWriter.h"
 
-int otbLuminanceToReflectanceImageFilter(int argc, char * argv[])
+int otbRadianceToReflectanceImageFilter(int argc, char * argv[])
 {
   const char * inputFileName  = argv[1];
   const char * outputFileName = argv[2];
@@ -50,8 +50,8 @@ int otbLuminanceToReflectanceImageFilter(int argc, char * argv[])
   typedef otb::VectorImage<PixelType, Dimension>                                  OutputImageType;
   typedef otb::ImageFileReader<InputImageType>                                    ReaderType;
   typedef otb::ImageFileWriter<OutputImageType>                                   WriterType;
-  typedef otb::LuminanceToReflectanceImageFilter<InputImageType, OutputImageType> LuminanceToReflectanceImageFilterType;
-  typedef LuminanceToReflectanceImageFilterType::VectorType                       VectorType;
+  typedef otb::RadianceToReflectanceImageFilter<InputImageType, OutputImageType> RadianceToReflectanceImageFilterType;
+  typedef RadianceToReflectanceImageFilterType::VectorType                       VectorType;
 
   ReaderType::Pointer reader  = ReaderType::New();
   WriterType::Pointer writer = WriterType::New();
@@ -69,7 +69,7 @@ int otbLuminanceToReflectanceImageFilter(int argc, char * argv[])
   solarIllumination[3] = static_cast<double>(atof(argv[7]));
 
   // Instantiating object
-  LuminanceToReflectanceImageFilterType::Pointer filter = LuminanceToReflectanceImageFilterType::New();
+  RadianceToReflectanceImageFilterType::Pointer filter = RadianceToReflectanceImageFilterType::New();
 
   filter->SetZenithalSolarAngle(angle);
   filter->SetSolarIllumination(solarIllumination);
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbLuminanceToReflectanceImageFilterAuto.cxx b/Modules/Radiometry/OpticalCalibration/test/otbRadianceToReflectanceImageFilterAuto.cxx
similarity index 73%
rename from Modules/Radiometry/OpticalCalibration/test/otbLuminanceToReflectanceImageFilterAuto.cxx
rename to Modules/Radiometry/OpticalCalibration/test/otbRadianceToReflectanceImageFilterAuto.cxx
index fda44a1..511b4d6 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbLuminanceToReflectanceImageFilterAuto.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbRadianceToReflectanceImageFilterAuto.cxx
@@ -19,13 +19,13 @@
  */
 
 
-#include "otbImageToLuminanceImageFilter.h"
-#include "otbLuminanceToReflectanceImageFilter.h"
+#include "otbImageToRadianceImageFilter.h"
+#include "otbRadianceToReflectanceImageFilter.h"
 #include "otbImageFileReader.h"
 #include "otbImageFileWriter.h"
 #include "otbMultiChannelExtractROI.h"
 
-int otbLuminanceToReflectanceImageFilterAuto(int itkNotUsed(argc), char * argv[])
+int otbRadianceToReflectanceImageFilterAuto(int itkNotUsed(argc), char * argv[])
 {
   const char * inputFileName  = argv[1];
   const char * outputFileName = argv[2];
@@ -36,9 +36,9 @@ int otbLuminanceToReflectanceImageFilterAuto(int itkNotUsed(argc), char * argv[]
   typedef otb::VectorImage<PixelType, Dimension>                            OutputImageType;
   typedef otb::ImageFileReader<InputImageType>                              ReaderType;
   typedef otb::ImageFileWriter<OutputImageType>                             WriterType;
-  typedef otb::ImageToLuminanceImageFilter<InputImageType, OutputImageType> ImageToLuminanceImageFilterType;
-  typedef otb::LuminanceToReflectanceImageFilter<OutputImageType,
-      OutputImageType> LuminanceToReflectanceImageFilterType;
+  typedef otb::ImageToRadianceImageFilter<InputImageType, OutputImageType> ImageToRadianceImageFilterType;
+  typedef otb::RadianceToReflectanceImageFilter<OutputImageType,
+      OutputImageType> RadianceToReflectanceImageFilterType;
   typedef otb::MultiChannelExtractROI<PixelType, PixelType> RoiFilterType;
 
   ReaderType::Pointer reader  = ReaderType::New();
@@ -48,11 +48,11 @@ int otbLuminanceToReflectanceImageFilterAuto(int itkNotUsed(argc), char * argv[]
   reader->UpdateOutputInformation();
 
   // Instantiating object
-  ImageToLuminanceImageFilterType::Pointer filterToLuminance = ImageToLuminanceImageFilterType::New();
-  filterToLuminance->SetInput(reader->GetOutput());
+  ImageToRadianceImageFilterType::Pointer filterToRadiance = ImageToRadianceImageFilterType::New();
+  filterToRadiance->SetInput(reader->GetOutput());
 
-  LuminanceToReflectanceImageFilterType::Pointer filterToReflectance = LuminanceToReflectanceImageFilterType::New();
-  filterToReflectance->SetInput(filterToLuminance->GetOutput());
+  RadianceToReflectanceImageFilterType::Pointer filterToReflectance = RadianceToReflectanceImageFilterType::New();
+  filterToReflectance->SetInput(filterToRadiance->GetOutput());
   filterToReflectance->SetUseClamp(false);
 
   RoiFilterType::Pointer roiFilter = RoiFilterType::New();
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbLuminanceToReflectanceImageFilterNew.cxx b/Modules/Radiometry/OpticalCalibration/test/otbRadianceToReflectanceImageFilterNew.cxx
similarity index 73%
rename from Modules/Radiometry/OpticalCalibration/test/otbLuminanceToReflectanceImageFilterNew.cxx
rename to Modules/Radiometry/OpticalCalibration/test/otbRadianceToReflectanceImageFilterNew.cxx
index 12b4671..2d208d1 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbLuminanceToReflectanceImageFilterNew.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbRadianceToReflectanceImageFilterNew.cxx
@@ -20,19 +20,19 @@
 
 #include "itkMacro.h"
 
-#include "otbLuminanceToReflectanceImageFilter.h"
+#include "otbRadianceToReflectanceImageFilter.h"
 #include "otbVectorImage.h"
 
-int otbLuminanceToReflectanceImageFilterNew(int itkNotUsed(argc), char * itkNotUsed(argv)[])
+int otbRadianceToReflectanceImageFilterNew(int itkNotUsed(argc), char * itkNotUsed(argv)[])
 {
   const unsigned int Dimension = 2;
   typedef double                                 PixelType;
   typedef otb::VectorImage<PixelType, Dimension> InputImageType;
 
-  typedef otb::LuminanceToReflectanceImageFilter<InputImageType, InputImageType> LuminanceToReflectanceImageFilterType;
+  typedef otb::RadianceToReflectanceImageFilter<InputImageType, InputImageType> RadianceToReflectanceImageFilterType;
 
   // Instantiating object
-  LuminanceToReflectanceImageFilterType::Pointer filter = LuminanceToReflectanceImageFilterType::New();
+  RadianceToReflectanceImageFilterType::Pointer filter = RadianceToReflectanceImageFilterType::New();
 
   std::cout << filter << std::endl;
 
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToImageImageFilter.cxx b/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToImageImageFilter.cxx
index a61ae86..c52c21e 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToImageImageFilter.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToImageImageFilter.cxx
@@ -22,8 +22,8 @@
 
 #include "otbReflectanceToImageImageFilter.h"
 
-//#include "otbReflectanceToLuminanceImageFilter.h"
-//#include "otbLuminanceToImageImageFilter.h"
+//#include "otbReflectanceToRadianceImageFilter.h"
+//#include "otbRadianceToImageImageFilter.h"
 
 #include "otbVectorImage.h"
 #include "otbImageFileReader.h"
@@ -129,10 +129,10 @@ int otbReflectanceToImageImageFilter(int argc, char * argv[])
   typedef otb::ImageFileReader<InputImageType>                                ReaderType;
   typedef otb::ImageFileWriter<OutputImageType>                               WriterType;
 
-typedef otb::ReflectanceToLuminanceImageFilter<InputImageType, InputImageType> ReflectanceToLuminanceImageFilterType;
-typedef otb::LuminanceToImageImageFilter<InputImageType, OutputImageType> LuminanceToImageImageFilterType;
+typedef otb::ReflectanceToRadianceImageFilter<InputImageType, InputImageType> ReflectanceToRadianceImageFilterType;
+typedef otb::RadianceToImageImageFilter<InputImageType, OutputImageType> RadianceToImageImageFilterType;
 
-  typedef ReflectanceToLuminanceImageFilterType::VectorType                       VectorType;
+  typedef ReflectanceToRadianceImageFilterType::VectorType                       VectorType;
 
   ReaderType::Pointer reader  = ReaderType::New();
   WriterType::Pointer writer = WriterType::New();
@@ -158,8 +158,8 @@ typedef otb::LuminanceToImageImageFilter<InputImageType, OutputImageType> Lumina
 
   // Instantiating object
 
-ReflectanceToLuminanceImageFilterType::Pointer filter = ReflectanceToLuminanceImageFilterType::New();
-LuminanceToImageImageFilterType::Pointer filter2 = LuminanceToImageImageFilterType::New();
+ReflectanceToRadianceImageFilterType::Pointer filter = ReflectanceToRadianceImageFilterType::New();
+RadianceToImageImageFilterType::Pointer filter2 = RadianceToImageImageFilterType::New();
 
   filter2->SetAlpha(alpha);
   filter2->SetBeta(beta);
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToLuminanceImageFilter.cxx b/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToRadianceImageFilter.cxx
similarity index 86%
rename from Modules/Radiometry/OpticalCalibration/test/otbReflectanceToLuminanceImageFilter.cxx
rename to Modules/Radiometry/OpticalCalibration/test/otbReflectanceToRadianceImageFilter.cxx
index b7fcc26..3bd7974 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToLuminanceImageFilter.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToRadianceImageFilter.cxx
@@ -20,11 +20,11 @@
 
 #include "itkMacro.h"
 
-#include "otbReflectanceToLuminanceImageFilter.h"
+#include "otbReflectanceToRadianceImageFilter.h"
 #include "otbImageFileReader.h"
 #include "otbImageFileWriter.h"
 
-int otbReflectanceToLuminanceImageFilter(int argc, char * argv[])
+int otbReflectanceToRadianceImageFilter(int argc, char * argv[])
 {
   const char * inputFileName  = argv[1];
   const char * outputFileName = argv[2];
@@ -49,8 +49,8 @@ int otbReflectanceToLuminanceImageFilter(int argc, char * argv[])
   typedef otb::VectorImage<PixelType, Dimension>                                  OutputImageType;
   typedef otb::ImageFileReader<InputImageType>                                    ReaderType;
   typedef otb::ImageFileWriter<OutputImageType>                                   WriterType;
-  typedef otb::ReflectanceToLuminanceImageFilter<InputImageType, OutputImageType> ReflectanceToLuminanceImageFilterType;
-  typedef ReflectanceToLuminanceImageFilterType::VectorType                       VectorType;
+  typedef otb::ReflectanceToRadianceImageFilter<InputImageType, OutputImageType> ReflectanceToRadianceImageFilterType;
+  typedef ReflectanceToRadianceImageFilterType::VectorType                       VectorType;
 
   ReaderType::Pointer reader  = ReaderType::New();
   WriterType::Pointer writer = WriterType::New();
@@ -68,7 +68,7 @@ int otbReflectanceToLuminanceImageFilter(int argc, char * argv[])
   solarIllumination[3] = static_cast<double>(atof(argv[7]));
 
   // Instantiating object
-  ReflectanceToLuminanceImageFilterType::Pointer filter = ReflectanceToLuminanceImageFilterType::New();
+  ReflectanceToRadianceImageFilterType::Pointer filter = ReflectanceToRadianceImageFilterType::New();
 
   filter->SetZenithalSolarAngle(angle);
   filter->SetSolarIllumination(solarIllumination);
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToLuminanceImageFilterAuto.cxx b/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToRadianceImageFilterAuto.cxx
similarity index 77%
rename from Modules/Radiometry/OpticalCalibration/test/otbReflectanceToLuminanceImageFilterAuto.cxx
rename to Modules/Radiometry/OpticalCalibration/test/otbReflectanceToRadianceImageFilterAuto.cxx
index 08d6ba5..034a714 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToLuminanceImageFilterAuto.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToRadianceImageFilterAuto.cxx
@@ -19,12 +19,12 @@
  */
 
 
-#include "otbReflectanceToLuminanceImageFilter.h"
+#include "otbReflectanceToRadianceImageFilter.h"
 #include "otbImageFileReader.h"
 #include "otbImageFileWriter.h"
 #include "otbMultiChannelExtractROI.h"
 
-int otbReflectanceToLuminanceImageFilterAuto(int itkNotUsed(argc), char * argv[])
+int otbReflectanceToRadianceImageFilterAuto(int itkNotUsed(argc), char * argv[])
 {
 
 const char * inputFileName  = argv[1];
@@ -36,8 +36,8 @@ const char * inputFileName  = argv[1];
   typedef otb::VectorImage<PixelType, Dimension>                            OutputImageType;
   typedef otb::ImageFileReader<InputImageType>                              ReaderType;
   typedef otb::ImageFileWriter<OutputImageType>                             WriterType;
-  typedef otb::ReflectanceToLuminanceImageFilter<OutputImageType,
-      OutputImageType> ReflectanceToLuminanceImageFilterType;
+  typedef otb::ReflectanceToRadianceImageFilter<OutputImageType,
+      OutputImageType> ReflectanceToRadianceImageFilterType;
 
   ReaderType::Pointer reader  = ReaderType::New();
   WriterType::Pointer writer = WriterType::New();
@@ -46,10 +46,10 @@ const char * inputFileName  = argv[1];
   reader->UpdateOutputInformation();
 
   // Instantiating object
-  ReflectanceToLuminanceImageFilterType::Pointer filterToLuminance = ReflectanceToLuminanceImageFilterType::New();
+  ReflectanceToRadianceImageFilterType::Pointer filterToRadiance = ReflectanceToRadianceImageFilterType::New();
 
-  filterToLuminance->SetInput(reader->GetOutput());
-  writer->SetInput(filterToLuminance->GetOutput());
+  filterToRadiance->SetInput(reader->GetOutput());
+  writer->SetInput(filterToRadiance->GetOutput());
   writer->Update();
 
   return EXIT_SUCCESS;
diff --git a/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToLuminanceImageFilterNew.cxx b/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToRadianceImageFilterNew.cxx
similarity index 73%
rename from Modules/Radiometry/OpticalCalibration/test/otbReflectanceToLuminanceImageFilterNew.cxx
rename to Modules/Radiometry/OpticalCalibration/test/otbReflectanceToRadianceImageFilterNew.cxx
index 0722483..c6eb589 100644
--- a/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToLuminanceImageFilterNew.cxx
+++ b/Modules/Radiometry/OpticalCalibration/test/otbReflectanceToRadianceImageFilterNew.cxx
@@ -20,18 +20,18 @@
 
 #include "itkMacro.h"
 
-#include "otbReflectanceToLuminanceImageFilter.h"
+#include "otbReflectanceToRadianceImageFilter.h"
 
-int otbReflectanceToLuminanceImageFilterNew(int itkNotUsed(argc), char * itkNotUsed(argv)[])
+int otbReflectanceToRadianceImageFilterNew(int itkNotUsed(argc), char * itkNotUsed(argv)[])
 {
   const unsigned int Dimension = 2;
   typedef double                                 PixelType;
   typedef otb::VectorImage<PixelType, Dimension> InputImageType;
 
-  typedef otb::ReflectanceToLuminanceImageFilter<InputImageType, InputImageType> ReflectanceToLuminanceImageFilterType;
+  typedef otb::ReflectanceToRadianceImageFilter<InputImageType, InputImageType> ReflectanceToRadianceImageFilterType;
 
   // Instantiating object
-  ReflectanceToLuminanceImageFilterType::Pointer filter = ReflectanceToLuminanceImageFilterType::New();
+  ReflectanceToRadianceImageFilterType::Pointer filter = ReflectanceToRadianceImageFilterType::New();
 
   std::cout << filter << std::endl;
 
diff --git a/Modules/Radiometry/Simulation/include/otbImageSimulationMethod.txx b/Modules/Radiometry/Simulation/include/otbImageSimulationMethod.txx
index ee58c5f..d42b05f 100644
--- a/Modules/Radiometry/Simulation/include/otbImageSimulationMethod.txx
+++ b/Modules/Radiometry/Simulation/include/otbImageSimulationMethod.txx
@@ -39,8 +39,8 @@ ImageSimulationMethod< TInputVectorData, TSpatialisation, TSimulationStep1, TSim
   //    this->SetNthOutput(0, OutputImageType::New());
   //    this->SetNthOutput(1, OutputLabelImageType::New());
 
-  //TODO a changer mais pour le moment obligatoire car ProlateInterpolateImageFunction
-  // ne fonctionne qu'avec des images mono canal.
+  // TODO fix this. But for now this is mandatory because ProlateInterpolateImageFunction
+  // only works with single channel images.
   //    m_FTMFilter = FTMFilterType::New();
   //    m_Interpolator = InterpolatorType::New();
   //    m_MultiToMonoChannelFilter = MultiToMonoChannelFilterType::New();
diff --git a/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.h b/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.h
index dd3a116..d9a944b 100644
--- a/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.h
+++ b/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.h
@@ -39,7 +39,7 @@ namespace otb
    * compute the satellite spectral bands.
    *
    * There are 2 operating modes:
-   * - luminance mode (default): integrates the spectral response over each band
+   * - radiance mode (default): integrates the spectral response over each band
    * - reflectance mode (needs to call SetReflectanceMode(true)): takes into account
    *   the solar irradiance in the integration
    *
@@ -154,7 +154,7 @@ private:
   /** the computed response */
   InputSpectralResponsePointerType m_ReduceResponse;
 
-  /** Choose between reflectance or luminance mode */
+  /** Choose between reflectance or radiance mode */
   bool m_ReflectanceMode;
 };
 
diff --git a/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.txx b/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.txx
index 422d19f..2c7af98 100644
--- a/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.txx
+++ b/Modules/Radiometry/Simulation/include/otbReduceSpectralResponse.txx
@@ -97,36 +97,39 @@ ReduceSpectralResponse<TSpectralResponse , TRSR>
     ++it;
     while (it != pairs.end())
       {
-      PrecisionType lambda1 = (*(it-1)).first;
-      PrecisionType lambda2 = (*it).first;
-//      PrecisionType deltaLambda = lambda2-lambda1;
       ValuePrecisionType rsr1 = (*(it-1)).second;
       ValuePrecisionType rsr2 = (*it).second;
-      ValuePrecisionType spectrum1 = (*m_InputSpectralResponse)(lambda1);
-      ValuePrecisionType spectrum2 = (*m_InputSpectralResponse)(lambda2);
-      /*
+      if(rsr1 > 0 || rsr2 >0)
+        {
+        PrecisionType lambda1 = (*(it-1)).first;
+        PrecisionType lambda2 = (*it).first;
+//      PrecisionType deltaLambda = lambda2-lambda1;
+        ValuePrecisionType spectrum1 = (*m_InputSpectralResponse)(lambda1);
+        ValuePrecisionType spectrum2 = (*m_InputSpectralResponse)(lambda2);
+        /*
         In order to simplify the computation for the reflectance mode,
         we introduce the solar irradiance in the general formula with
-        a value of 1.0 for the luminance case.
+        a value of 1.0 for the radiance case.
 
         In this way the formula is the same if we weight the RSR by
         the solar irradiance before the integration.
       */
-      ValuePrecisionType solarIrradiance1(1.0);
-      ValuePrecisionType solarIrradiance2(1.0);
-      if(m_ReflectanceMode)
-        {
-        solarIrradiance1 = (*solarIrradiance)(lambda1);
-        solarIrradiance2 = (*solarIrradiance)(lambda2);
+        ValuePrecisionType solarIrradiance1(1.0);
+        ValuePrecisionType solarIrradiance2(1.0);
+        if(m_ReflectanceMode)
+          {
+          solarIrradiance1 = (*solarIrradiance)(lambda1);
+          solarIrradiance2 = (*solarIrradiance)(lambda2);
+          }
+        rsr1 *= solarIrradiance1;
+        rsr2 *= solarIrradiance2;
+        res += trapezoid_area(lambda1, lambda2,
+                              rsr1*spectrum1,
+                              rsr2*spectrum2);
+        totalArea += trapezoid_area(lambda1, lambda2,
+                                    rsr1,
+                                    rsr2);
         }
-      rsr1 *= solarIrradiance1;
-      rsr2 *= solarIrradiance2;
-      res += trapezoid_area(lambda1, lambda2,
-                            rsr1*spectrum1,
-                            rsr2*spectrum2);
-      totalArea += trapezoid_area(lambda1, lambda2,
-                                  rsr1,
-                                  rsr2);
       ++it;
       }
     return res / totalArea;
@@ -194,7 +197,7 @@ ReduceSpectralResponse<TSpectralResponse , TRSR>
      os <<indent << "[Center Wavelength (micrometers), Reflectance (percent)]" << std::endl;
      }
    else{
-   os <<indent << "[Center Wavelength (micrometers), Luminance (percent)]" << std::endl;
+   os <<indent << "[Center Wavelength (micrometers), Radiance (percent)]" << std::endl;
    }
 
    for(typename VectorPairType::const_iterator it = m_ReduceResponse->GetResponse().begin(); it != m_ReduceResponse->GetResponse().end(); ++it)
diff --git a/Modules/Radiometry/Simulation/include/otbSailModel.h b/Modules/Radiometry/Simulation/include/otbSailModel.h
index 288d0d7..572e25a 100644
--- a/Modules/Radiometry/Simulation/include/otbSailModel.h
+++ b/Modules/Radiometry/Simulation/include/otbSailModel.h
@@ -25,6 +25,9 @@
 #include "otbSpectralResponse.h"
 #include "otbDataSpecP5B.h"
 #include "otbSimulationStep2Base.h"
+#include "otbSoilDataBase.h"
+#include <string>
+#include <memory>
 
 namespace otb
 {
@@ -42,116 +45,122 @@ namespace otb
 
 class OTBSimulation_EXPORT SailModel : public SimulationStep2Base
 {
-   public:
-      /** Standard class typedefs */
-      typedef SailModel Self;
-      typedef SimulationStep2Base   Superclass;
-      typedef itk::SmartPointer<Self> Pointer;
-      typedef itk::SmartPointer<const Self> ConstPointer;
-
-      typedef Superclass::SpectralResponseType      SpectralResponseType;
-      typedef std::vector<double>                   VectorType;
-      typedef Superclass::ParametersType   ParametersType;
-
-      typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
-
-      /** Standard macros */
-      itkNewMacro(Self);
-      itkTypeMacro(SailModel, ProcessObject);
-
-
-      /** Set Inputs */
-      void SetReflectance(const SpectralResponseType *object) ITK_OVERRIDE;
-      SpectralResponseType * GetReflectance();
-
-      void SetTransmittance(const SpectralResponseType *object) ITK_OVERRIDE;
-      SpectralResponseType * GetTransmittance();
-
-      /** Set parameters */
-      /** Set/Get leaf area index */
-      itkSetMacro(LAI, double);
-      itkGetMacro(LAI, double);
-
-      /** Set/Get average leaf angle (deg)*/
-      itkSetMacro(Angl, double);
-      itkGetMacro(Angl, double);
-
-      /** Set/Get soil coefficient*/
-      itkSetMacro(PSoil, double);
-      itkGetMacro(PSoil, double);
-
-      /** Set/Get diffuse/direct radiation*/
-      itkSetMacro(Skyl, double);
-      itkGetMacro(Skyl, double);
-
-      /** Set/Get hot spot */
-      itkSetMacro(HSpot, double);
-      itkGetMacro(HSpot, double);
-
-      /** Set/Get solar zenith angle (deg) */
-      itkSetMacro(TTS, double);
-      itkGetMacro(TTS, double);
-
-      /** Set/Get observer zenith angle (deg) */
-      itkSetMacro(TTO, double);
-      itkGetMacro(TTO, double);
-
-      /** Set/Get azimuth(deg) */
-      itkSetMacro(PSI, double);
-      itkGetMacro(PSI, double);
-
-      /** Get the computed fcover */
-      itkGetMacro(FCoverView, double);
-
-      /** GenerateData */
-      void GenerateData() ITK_OVERRIDE;
-
-      /** Get Output */
-      virtual SpectralResponseType * GetViewingReflectance();
-      virtual SpectralResponseType * GetHemisphericalReflectance();
-      virtual SpectralResponseType * GetViewingAbsorptance();
-      virtual SpectralResponseType * GetHemisphericalAbsorptance();
-
-     const ParametersType  GetInput();
-     void SetInput(const ParametersType &);
-     using Superclass::SetInput;
-
-
-   protected:
-      /** Constructor */
-      SailModel();
-      /** Destructor */
-      ~SailModel() ITK_OVERRIDE;
-      /** PrintSelf method */
-      void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
-
-      DataObjectPointer MakeOutput(DataObjectPointerArraySizeType) ITK_OVERRIDE;
-      using Superclass::MakeOutput;
-
-      /** Compute Leaf Angle Distribution */
-      void Calc_LIDF(const double a, VectorType &lidf);
-      void Campbell(const double ala, VectorType &freq);
-
-      /** J functions */
-      double Jfunc1(const double k, const double l, const double t);
-      double Jfunc2(const double k, const double l, const double t);
-      double Jfunc3(const double k, const double l, const double t);
-      /** Volscatt */
-      void Volscatt(const double tts, const double tto, const double psi, const double ttl, VectorType &result);
-
-   private:
-      SailModel(const Self&); //purposely not implemented
-      void operator=(const Self&); //purposely not implemented
-
-      double m_LAI; //leaf area index
-      double m_Angl; //average leaf angle
-      double m_PSoil; //soil coefficient
-      double m_Skyl; //diffuse/direct radiation
-      double m_HSpot; //hot spot
-      double m_TTS; //solar zenith angle
-      double m_TTO; //observer zenith angle
-      double m_PSI; //azimuth
-      double m_FCoverView; //fCover in the viewing direction
+public:
+  /** Standard class typedefs */
+  typedef SailModel Self;
+  typedef SimulationStep2Base   Superclass;
+  typedef itk::SmartPointer<Self> Pointer;
+  typedef itk::SmartPointer<const Self> ConstPointer;
+
+  typedef Superclass::SpectralResponseType      SpectralResponseType;
+  typedef std::vector<double>                   VectorType;
+  typedef Superclass::ParametersType   ParametersType;
+
+  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
+
+  /** Standard macros */
+  itkNewMacro(Self);
+  itkTypeMacro(SailModel, ProcessObject);
+
+
+  /** Set Inputs */
+  void SetReflectance(const SpectralResponseType *object) override;
+  SpectralResponseType * GetReflectance();
+
+  void SetTransmittance(const SpectralResponseType *object) override;
+  SpectralResponseType * GetTransmittance();
+
+  /** Set parameters */
+  /** Set/Get leaf area index */
+  itkSetMacro(LAI, double);
+  itkGetMacro(LAI, double);
+
+  /** Set/Get average leaf angle (deg)*/
+  itkSetMacro(Angl, double);
+  itkGetMacro(Angl, double);
+
+  /** Set/Get soil coefficient*/
+  itkSetMacro(PSoil, double);
+  itkGetMacro(PSoil, double);
+
+  /** Set/Get diffuse/direct radiation*/
+  itkSetMacro(Skyl, double);
+  itkGetMacro(Skyl, double);
+
+  /** Set/Get hot spot */
+  itkSetMacro(HSpot, double);
+  itkGetMacro(HSpot, double);
+
+  /** Set/Get solar zenith angle (deg) */
+  itkSetMacro(TTS, double);
+  itkGetMacro(TTS, double);
+
+  /** Set/Get observer zenith angle (deg) */
+  itkSetMacro(TTO, double);
+  itkGetMacro(TTO, double);
+
+  /** Set/Get azimuth(deg) */
+  itkSetMacro(PSI, double);
+  itkGetMacro(PSI, double);
+
+  /** Get the computed fcover */
+  itkGetMacro(FCoverView, double);
+
+  /** Use an external soil DB */
+  void UseExternalSoilDB(std::shared_ptr<SoilDataBase> SoilDB, size_t SoilIndex);
+
+  /** GenerateData */
+  void GenerateData() override;
+
+  /** Get Output */
+  virtual SpectralResponseType * GetViewingReflectance();
+  virtual SpectralResponseType * GetHemisphericalReflectance();
+  virtual SpectralResponseType * GetViewingAbsorptance();
+  virtual SpectralResponseType * GetHemisphericalAbsorptance();
+
+  const ParametersType  GetInput();
+  void SetInput(const ParametersType &);
+  using Superclass::SetInput;
+
+
+protected:
+  /** Constructor */
+  SailModel();
+  /** Destructor */
+  ~SailModel() override;
+  /** PrintSelf method */
+  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
+
+  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType) override;
+  using Superclass::MakeOutput;
+
+  /** Compute Leaf Angle Distribution */
+  void Calc_LIDF(const double a, VectorType &lidf) const;
+  void Campbell(const double ala, VectorType &freq) const;
+
+  /** J functions */
+  double Jfunc1(const double k, const double l, const double t) const;
+  double Jfunc2(const double k, const double l, const double t) const;
+  double Jfunc3(const double k, const double l, const double t) const;
+  /** Volscatt */
+  void Volscatt(const double tts, const double tto, const double psi, const double ttl, VectorType &result) const;
+
+private:
+  SailModel(const Self&) = delete; 
+  void operator=(const Self&) = delete;
+
+  double m_LAI; //leaf area index
+  double m_Angl; //average leaf angle
+  double m_PSoil; //soil coefficient
+  double m_Skyl; //diffuse/direct radiation
+  double m_HSpot; //hot spot
+  double m_TTS; //solar zenith angle
+  double m_TTO; //observer zenith angle
+  double m_PSI; //azimuth
+  double m_FCoverView; //fCover in the viewing direction
+  bool m_UseSoilFile; //use a soil file instead of DataSpecP5B
+  size_t m_SoilIndex; //which soil in the soil file
+  std::shared_ptr<SoilDataBase> m_SoilDataBase;
 };
 
 }// end namespace otb
diff --git a/Modules/Radiometry/Simulation/include/otbSoilDataBase.h b/Modules/Radiometry/Simulation/include/otbSoilDataBase.h
new file mode 100644
index 0000000..673bc51
--- /dev/null
+++ b/Modules/Radiometry/Simulation/include/otbSoilDataBase.h
@@ -0,0 +1,57 @@
+/*
+ * 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 otbSoilDataBase_h
+#define otbSoilDataBase_h
+
+#include "OTBSimulationExport.h"
+#include "itkMacro.h"
+#include <vector>
+#include <unordered_map>
+#include <string>
+
+namespace otb
+{
+
+class ITK_ABI_EXPORT SoilDataBase
+{
+public:
+  //wavelength in nm
+  using WavelenghtType = unsigned int;
+  using SoilData = std::unordered_map<WavelenghtType, double>;
+  using SoilDataVector = std::vector<SoilData>;
+
+  SoilDataBase(const std::string& SoilFileName, double wlfactor); 
+  const SoilDataVector& GetDB() const;
+  double GetReflectance(size_t SoilIndex, WavelenghtType wl) const;
+
+protected:
+  size_t CountColumns(std::string fileName) const;
+  void ParseSoilFile();
+
+  std::string m_SoilFileName;
+  double m_WlFactor;
+  SoilDataVector m_SoilDataVector;
+  std::vector<WavelenghtType> m_Wavelengths;
+};
+}
+
+#endif /* otbSoilDataBase_h */
diff --git a/Modules/Radiometry/Simulation/include/otbSurfaceReflectanceToReflectanceFilter.h b/Modules/Radiometry/Simulation/include/otbSurfaceReflectanceToReflectanceFilter.h
index 6205016..c07fbd4 100644
--- a/Modules/Radiometry/Simulation/include/otbSurfaceReflectanceToReflectanceFilter.h
+++ b/Modules/Radiometry/Simulation/include/otbSurfaceReflectanceToReflectanceFilter.h
@@ -153,7 +153,7 @@ private:
  *
  * \ingroup AtmosphericRadiativeTerms
  * \ingroup AtmosphericCorrectionParameters
- * \ingroup LuminanceToReflectanceImageFilter
+ * \ingroup RadianceToReflectanceImageFilter
  * \ingroup ImageToReflectanceImageFilter
  * \ingroup Radiometry
  *
diff --git a/Modules/Radiometry/Simulation/src/CMakeLists.txt b/Modules/Radiometry/Simulation/src/CMakeLists.txt
index a58c546..7f862d3 100644
--- a/Modules/Radiometry/Simulation/src/CMakeLists.txt
+++ b/Modules/Radiometry/Simulation/src/CMakeLists.txt
@@ -23,6 +23,7 @@ set(OTBSimulation_SRC
   otbProspectModel.cxx
   otbDataSpecP5B.cxx
   otbLeafParameters.cxx
+  otbSoilDataBase.cxx
   )
 
 add_library(OTBSimulation ${OTBSimulation_SRC})
diff --git a/Modules/Radiometry/Simulation/src/otbSailModel.cxx b/Modules/Radiometry/Simulation/src/otbSailModel.cxx
index 15e262f..1049da6 100644
--- a/Modules/Radiometry/Simulation/src/otbSailModel.cxx
+++ b/Modules/Radiometry/Simulation/src/otbSailModel.cxx
@@ -34,22 +34,22 @@ namespace otb
 /** Constructor */
 SailModel
 ::SailModel() : m_LAI(2), m_Angl(50), m_PSoil(1), m_Skyl(70), m_HSpot(0.2),
-                m_TTS(30), m_TTO(0), m_PSI(0), m_FCoverView(0.0)
+                m_TTS(30), m_TTO(0), m_PSI(0), m_FCoverView(0.0), m_UseSoilFile(false)
 {
-   this->ProcessObject::SetNumberOfRequiredInputs(2);
-   this->ProcessObject::SetNumberOfRequiredOutputs(4);
+  this->ProcessObject::SetNumberOfRequiredInputs(2);
+  this->ProcessObject::SetNumberOfRequiredOutputs(4);
 
-   SpectralResponseType::Pointer vRefl = static_cast<SpectralResponseType *>(this->MakeOutput(0).GetPointer());
-   this->itk::ProcessObject::SetNthOutput(0, vRefl.GetPointer());
+  SpectralResponseType::Pointer vRefl = static_cast<SpectralResponseType *>(this->MakeOutput(0).GetPointer());
+  this->itk::ProcessObject::SetNthOutput(0, vRefl.GetPointer());
 
-   SpectralResponseType::Pointer hRefl = static_cast<SpectralResponseType *>(this->MakeOutput(1).GetPointer());
-   this->itk::ProcessObject::SetNthOutput(1, hRefl.GetPointer());
+  SpectralResponseType::Pointer hRefl = static_cast<SpectralResponseType *>(this->MakeOutput(1).GetPointer());
+  this->itk::ProcessObject::SetNthOutput(1, hRefl.GetPointer());
 
-   SpectralResponseType::Pointer vAbs = static_cast<SpectralResponseType *>(this->MakeOutput(2).GetPointer());
-   this->itk::ProcessObject::SetNthOutput(2, vAbs.GetPointer());
+  SpectralResponseType::Pointer vAbs = static_cast<SpectralResponseType *>(this->MakeOutput(2).GetPointer());
+  this->itk::ProcessObject::SetNthOutput(2, vAbs.GetPointer());
 
-   SpectralResponseType::Pointer hAbs = static_cast<SpectralResponseType *>(this->MakeOutput(3).GetPointer());
-   this->itk::ProcessObject::SetNthOutput(3, hAbs.GetPointer());
+  SpectralResponseType::Pointer hAbs = static_cast<SpectralResponseType *>(this->MakeOutput(3).GetPointer());
+  this->itk::ProcessObject::SetNthOutput(3, hAbs.GetPointer());
 }
 
 /** Destructor */
@@ -62,112 +62,112 @@ void
 SailModel
 ::SetReflectance(const SpectralResponseType * object)
 {
-   this->itk::ProcessObject::SetNthInput(0, const_cast<SpectralResponseType *>(object));
+  this->itk::ProcessObject::SetNthInput(0, const_cast<SpectralResponseType *>(object));
 }
 
 SailModel::SpectralResponseType *
 SailModel
 ::GetReflectance()
-{
-   if(this->GetNumberOfInputs() != 2)
-   {
-      //exit
-      return ITK_NULLPTR;
-   }
-   return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetInput(0));
-}
+                  {
+                    if(this->GetNumberOfInputs() != 2)
+                      {
+                      //exit
+                      return ITK_NULLPTR;
+                      }
+                    return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetInput(0));
+                  }
 
 /** Set/Get input transmittance */
-void
-SailModel
-::SetTransmittance(const SpectralResponseType * object)
-{
-   this->itk::ProcessObject::SetNthInput(1, const_cast<SpectralResponseType *>(object));
-}
-
-SailModel::SpectralResponseType *
-SailModel
-::GetTransmittance()
-{
-   if(this->GetNumberOfInputs() != 2)
-   {
-      //exit
-      return ITK_NULLPTR;
-   }
-   return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetInput(1));
-}
+                  void
+                  SailModel
+                  ::SetTransmittance(const SpectralResponseType * object)
+                  {
+                    this->itk::ProcessObject::SetNthInput(1, const_cast<SpectralResponseType *>(object));
+                  }
+
+                  SailModel::SpectralResponseType *
+                  SailModel
+                  ::GetTransmittance()
+                  {
+                    if(this->GetNumberOfInputs() != 2)
+                      {
+                      //exit
+                      return ITK_NULLPTR;
+                      }
+                    return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetInput(1));
+                  }
 
 /** Make output */
-SailModel::DataObjectPointer
-SailModel
-::MakeOutput(DataObjectPointerArraySizeType)
-{
-   return static_cast<itk::DataObject*>(SpectralResponseType::New().GetPointer());
-}
+                  SailModel::DataObjectPointer
+                  SailModel
+                  ::MakeOutput(DataObjectPointerArraySizeType)
+                  {
+                    return static_cast<itk::DataObject*>(SpectralResponseType::New().GetPointer());
+                  }
 
 /** Get output viewing reflectance */
-SailModel::SpectralResponseType *
-SailModel
-::GetViewingReflectance()
-{
-   if(this->GetNumberOfOutputs() < 4)
-   {
-      //exit
-      return ITK_NULLPTR;
-   }
-   return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(0));
-}
+                  SailModel::SpectralResponseType *
+                  SailModel
+                  ::GetViewingReflectance()
+                  {
+                    if(this->GetNumberOfOutputs() < 4)
+                      {
+                      //exit
+                      return ITK_NULLPTR;
+                      }
+                    return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(0));
+                  }
 
 /** Get output hemispherical reflectance */
-SailModel::SpectralResponseType *
-SailModel
-::GetHemisphericalReflectance()
-{
-   if(this->GetNumberOfOutputs() < 4)
-   {
-      //exit
-      return ITK_NULLPTR;
-   }
-   return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(1));
-}
+                  SailModel::SpectralResponseType *
+                  SailModel
+                  ::GetHemisphericalReflectance()
+                  {
+                    if(this->GetNumberOfOutputs() < 4)
+                      {
+                      //exit
+                      return ITK_NULLPTR;
+                      }
+                    return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(1));
+                  }
 
 /** Get output viewing absorptance */
-SailModel::SpectralResponseType *
-SailModel
-::GetViewingAbsorptance()
-{
-   if(this->GetNumberOfOutputs() < 4)
-   {
-      //exit
-      return ITK_NULLPTR;
-   }
-   return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(2));
-}
+                  SailModel::SpectralResponseType *
+                  SailModel
+                  ::GetViewingAbsorptance()
+                  {
+                    if(this->GetNumberOfOutputs() < 4)
+                      {
+                      //exit
+                      return ITK_NULLPTR;
+                      }
+                    return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(2));
+                  }
 
 /** Get output hemispherical absorptance */
-SailModel::SpectralResponseType *
-SailModel
-::GetHemisphericalAbsorptance()
-{
-   if(this->GetNumberOfOutputs() < 4)
-   {
-      //exit
-      return ITK_NULLPTR;
-   }
-   return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(3));
-}
+                  SailModel::SpectralResponseType *
+                  SailModel
+                  ::GetHemisphericalAbsorptance()
+                  {
+                    if(this->GetNumberOfOutputs() < 4)
+                      {
+                      //exit
+                      return ITK_NULLPTR;
+                      }
+                    return static_cast<SpectralResponseType *>(this->itk::ProcessObject::GetOutput(3));
+                  }
 
 
 /** Set Parameters */
-void
-SailModel
-::SetInput(const ParametersType & params)
-{
-
-   if(params.Size()!=8) itkExceptionMacro( << "Must have 8 parameters in that order : LAI, Angl, PSoil, Skyl, HSpot, TTS, TTO, PSI" );
-   this->SetParameters(params);
-   m_LAI=params[0];
-   m_Angl=params[1];
+                  void
+                  SailModel
+                  ::SetInput(const ParametersType & params)
+                  {
+
+                    if(params.Size()!=8) itkExceptionMacro( << "Must have 8 parameters in that order : LAI, Angl, PSoil, Skyl, HSpot, TTS, TTO, PSI" );
+                    this->SetParameters(params);
+                    m_LAI=params[0];
+                    m_Angl=params[1];
    m_PSoil=params[2];
    m_Skyl=params[3];
    m_HSpot=params[4];
@@ -319,7 +319,14 @@ SailModel
       // Soil Reflectance Properties
       //rsoil1 = dry soil
       //rsoil2 = wet soil
-      rsoil0 = m_PSoil*Rsoil1+(1-m_PSoil)*Rsoil2;
+      if(!m_UseSoilFile)
+        {
+        rsoil0 = m_PSoil*Rsoil1+(1-m_PSoil)*Rsoil2;
+        }
+      else
+        {
+        rsoil0 = m_SoilDataBase->GetReflectance(m_SoilIndex, lambda)*m_PSoil;
+        }
 
       // Here rho and tau come in
       sigb = ddb*rho+ddf*tau;
@@ -339,94 +346,94 @@ SailModel
       // Here the LAI comes in
       // Outputs for the case LAI = 0
       if (m_LAI<0)
-      {
-         //tss = 1;
-         too = 1;
-         tsstoo = 1;
-         rdd = 0;
-         tdd = 1;
-         rsd = 0;
-         tsd = 0;
-         rdo = 0;
-         tdo = 0;
-         //rso = 0;
-         rsos = 0;
-         rsod = 0;
-
-         rddt = rsoil0;
-         rsdt = rsoil0;
-         rdot = rsoil0;
-         rsodt = 0;
-         rsost = rsoil0;
-         //rsot = rsoil0;
-      }
-
-      // Other cases (LAI > 0)
-      e1 = exp(-m*m_LAI);
-      e2 = e1*e1;
-      rinf = (att-m)/sigb;
-      rinf2 = rinf*rinf;
-      re = rinf*e1;
-      denom = 1.-rinf2*e2;
-
-      J1ks=Jfunc1(ks, m, m_LAI);
-      J2ks=Jfunc2(ks, m, m_LAI);
-      J1ko=Jfunc1(ko, m, m_LAI);
-      J2ko=Jfunc2(ko, m, m_LAI);
-
-      Ps = (sf+sb*rinf)*J1ks;
-      Qs = (sf*rinf+sb)*J2ks;
-      Pv = (vf+vb*rinf)*J1ko;
-      Qv = (vf*rinf+vb)*J2ko;
-
-      rdd = rinf*(1.-e2)/denom;
-      tdd = (1.-rinf2)*e1/denom;
-      tsd = (Ps-re*Qs)/denom;
-      rsd = (Qs-re*Ps)/denom;
-      tdo = (Pv-re*Qv)/denom;
-      rdo = (Qv-re*Pv)/denom;
-
-      tss = exp(-ks*m_LAI);
-      too = exp(-ko*m_LAI);
-      z = Jfunc3(ks, ko, m_LAI);
-      g1 = (z-J1ks*too)/(ko+m);
-      g2 = (z-J1ko*tss)/(ks+m);
-
-      Tv1 = (vf*rinf+vb)*g1;
-      Tv2 = (vf+vb*rinf)*g2;
-      T1 = Tv1*(sf+sb*rinf);
-      T2 = Tv2*(sf*rinf+sb);
-      T3 = (rdo*Qs+tdo*Ps)*rinf;
-
-      // Multiple scattering contribution to bidirectional canopy reflectance
-      rsod = (T1+T2-T3)/(1.-rinf2);
-
-      // Treatment of the hotspot-effect
-      alf=1e6;
-      // Apply correction 2/(K+k) suggested by F.-M. Bron
-      if (m_HSpot>0) alf=(dso/m_HSpot)*2./(ks+ko);
-      if (alf>200) alf=200;
-      if (alf==0)
-      {
-         // The pure hotspot - no shadow
-         tsstoo = tss;
-         sumint = (1-tss)/(ks*m_LAI);
-      }
-      else
-      {
-         // Outside the hotspot
-         fhot=m_LAI*vcl_sqrt(ko*ks);
-         // Integrate by exponential Simpson method in 20 steps
-         // the steps are arranged according to equal partitioning
-         // of the slope of the joint probability function
-         x1=0;
-         y1=0;
-         f1=1;
-         fint=(1.-exp(-alf))*0.05;
-         sumint=0;
-
-         for(unsigned int j=1; j<=20; ++j)
-         {
+          {
+          //tss = 1;
+          too = 1;
+          tsstoo = 1;
+          rdd = 0;
+          tdd = 1;
+          rsd = 0;
+          tsd = 0;
+          rdo = 0;
+          tdo = 0;
+          //rso = 0;
+          rsos = 0;
+          rsod = 0;
+
+          rddt = rsoil0;
+          rsdt = rsoil0;
+          rdot = rsoil0;
+          rsodt = 0;
+          rsost = rsoil0;
+          //rsot = rsoil0;
+          }
+
+        // Other cases (LAI > 0)
+        e1 = exp(-m*m_LAI);
+        e2 = e1*e1;
+        rinf = (att-m)/sigb;
+        rinf2 = rinf*rinf;
+        re = rinf*e1;
+        denom = 1.-rinf2*e2;
+
+        J1ks=Jfunc1(ks, m, m_LAI);
+        J2ks=Jfunc2(ks, m, m_LAI);
+        J1ko=Jfunc1(ko, m, m_LAI);
+        J2ko=Jfunc2(ko, m, m_LAI);
+
+        Ps = (sf+sb*rinf)*J1ks;
+        Qs = (sf*rinf+sb)*J2ks;
+        Pv = (vf+vb*rinf)*J1ko;
+        Qv = (vf*rinf+vb)*J2ko;
+
+        rdd = rinf*(1.-e2)/denom;
+        tdd = (1.-rinf2)*e1/denom;
+        tsd = (Ps-re*Qs)/denom;
+        rsd = (Qs-re*Ps)/denom;
+        tdo = (Pv-re*Qv)/denom;
+        rdo = (Qv-re*Pv)/denom;
+
+        tss = exp(-ks*m_LAI);
+        too = exp(-ko*m_LAI);
+        z = Jfunc3(ks, ko, m_LAI);
+        g1 = (z-J1ks*too)/(ko+m);
+        g2 = (z-J1ko*tss)/(ks+m);
+
+        Tv1 = (vf*rinf+vb)*g1;
+        Tv2 = (vf+vb*rinf)*g2;
+        T1 = Tv1*(sf+sb*rinf);
+        T2 = Tv2*(sf*rinf+sb);
+        T3 = (rdo*Qs+tdo*Ps)*rinf;
+
+        // Multiple scattering contribution to bidirectional canopy reflectance
+        rsod = (T1+T2-T3)/(1.-rinf2);
+
+        // Treatment of the hotspot-effect
+        alf=1e6;
+        // Apply correction 2/(K+k) suggested by F.-M. Bron
+        if (m_HSpot>0) alf=(dso/m_HSpot)*2./(ks+ko);
+        if (alf>200) alf=200;
+        if (alf==0)
+          {
+          // The pure hotspot - no shadow
+          tsstoo = tss;
+          sumint = (1-tss)/(ks*m_LAI);
+          }
+        else
+          {
+          // Outside the hotspot
+          fhot=m_LAI*vcl_sqrt(ko*ks);
+          // Integrate by exponential Simpson method in 20 steps
+          // the steps are arranged according to equal partitioning
+          // of the slope of the joint probability function
+          x1=0;
+          y1=0;
+          f1=1;
+          fint=(1.-exp(-alf))*0.05;
+          sumint=0;
+
+          for(unsigned int j=1; j<=20; ++j)
+            {
             if (j<20) x2 = -vcl_log(1.-j*fint)/alf;
             else x2 = 1;
             y2 = -(ko+ks)*m_LAI*x2+fhot*(1.-exp(-alf*x2))/alf;
@@ -435,13 +442,13 @@ SailModel
             x1=x2;
             y1=y2;
             f1=f2;
-         }
-         tsstoo=f1;
-      }
+            }
+          tsstoo=f1;
+          }
 
-      // Bidirectional reflectance
-      // Single scattering contribution
-      rsos = w*m_LAI*sumint;
+        // Bidirectional reflectance
+        // Single scattering contribution
+        rsos = w*m_LAI*sumint;
       // Total canopy contribution
       // rso=rsos+rsod;
       //Interaction with the soil
@@ -478,7 +485,7 @@ SailModel
 
 void
 SailModel
-::Calc_LIDF(const double a, VectorType &lidf)
+::Calc_LIDF(const double a, VectorType &lidf) const
 {
    int ala=a;
    VectorType freq;
@@ -490,7 +497,7 @@ SailModel
 
 void
 SailModel
-::Campbell(const double ala, VectorType &freq)
+::Campbell(const double ala, VectorType &freq) const
 {
    unsigned int n=18;
    double excent = exp(-1.6184e-5*vcl_pow(ala, 3)+2.1145e-3*ala*ala-1.2390e-1*ala+3.2491);
@@ -552,7 +559,7 @@ SailModel
 
 void
 SailModel
-::Volscatt(const double tts, const double tto, const double psi, const double ttl, VectorType &result)
+::Volscatt(const double tts, const double tto, const double psi, const double ttl, VectorType &result) const
 {
 
    double rd = CONST_PI/180;
@@ -666,7 +673,7 @@ SailModel
 
 double
 SailModel
-::Jfunc1(const double k, const double l, const double t)
+::Jfunc1(const double k, const double l, const double t) const
 {
    //J1 function with avoidance of singularity problem
    double v;
@@ -686,7 +693,7 @@ SailModel
 
 double
 SailModel
-::Jfunc2(const double k, const double l, const double t)
+::Jfunc2(const double k, const double l, const double t) const
 {
    double v;
    v = (1.-exp(-(k+l)*t))/(k+l);
@@ -696,7 +703,7 @@ SailModel
 
 double
 SailModel
-::Jfunc3(const double k, const double l, const double t)
+::Jfunc3(const double k, const double l, const double t) const
 {
    double v;
    v =  (1.-exp(-(k+l)*t))/(k+l);
@@ -711,4 +718,12 @@ SailModel
    Superclass::PrintSelf(os, indent);
 
 }
+
+void SailModel::UseExternalSoilDB(std::shared_ptr<SoilDataBase> SoilDB, 
+                                  size_t SoilIndex)
+{
+  m_UseSoilFile = true;
+  m_SoilIndex = SoilIndex;
+  m_SoilDataBase = SoilDB;
+}
 } // end namespace otb
diff --git a/Modules/Radiometry/Simulation/src/otbSoilDataBase.cxx b/Modules/Radiometry/Simulation/src/otbSoilDataBase.cxx
new file mode 100644
index 0000000..6c7686a
--- /dev/null
+++ b/Modules/Radiometry/Simulation/src/otbSoilDataBase.cxx
@@ -0,0 +1,134 @@
+/*
+ * 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 "otbSoilDataBase.h"
+#include <fstream>
+#include <sstream>
+#include <algorithm>
+#include <boost/algorithm/string.hpp>
+#include "itkMacro.h"
+
+
+namespace otb
+{
+
+SoilDataBase::SoilDataBase(const std::string& SoilFileName, double wlfactor) : 
+  m_SoilFileName(SoilFileName), m_WlFactor(wlfactor) 
+{
+  ParseSoilFile();
+}; 
+
+const typename SoilDataBase::SoilDataVector& SoilDataBase::GetDB() const
+{
+  return m_SoilDataVector;
+}
+
+double SoilDataBase::GetReflectance(size_t SoilIndex, WavelenghtType wl) const
+{
+  if(SoilIndex >= m_SoilDataVector.size())
+    {
+    std::stringstream  errmessg;
+    errmessg << "Soil index must be >= 0 and < " << m_SoilDataVector.size() << 
+      ". " << SoilIndex <<" was passed.\n";
+    throw std::range_error( errmessg.str() );
+    }
+  // wl not in the set of measured ones
+  if(m_SoilDataVector[SoilIndex].find(wl)==m_SoilDataVector[SoilIndex].end())
+    {
+    const auto wlmin = m_Wavelengths[0];
+    const auto wlmax = m_Wavelengths[m_Wavelengths.size()-1];
+    if(wl<wlmin) return (*m_SoilDataVector[SoilIndex].find(wlmin)).second;
+    if(wl>wlmax) return (*m_SoilDataVector[SoilIndex].find(wlmax)).second;
+
+    const auto p = std::partition_point(m_Wavelengths.cbegin(), m_Wavelengths.cend(),
+                                        [&](WavelenghtType w){ return w<wl;}
+      );
+    const auto wlinf = *(p-1);
+    const auto wlsup = *p;
+    const auto factinf = wl-wlinf;
+    const auto factsup = wlsup-wl;
+    const auto vinf = (*m_SoilDataVector[SoilIndex].find(wlinf)).second;
+    const auto vsup = (*m_SoilDataVector[SoilIndex].find(wlsup)).second;
+    return (vinf*factinf+vsup*factsup)/(factinf+factsup);
+    }
+  else
+    {
+    return (*m_SoilDataVector[SoilIndex].find(wl)).second;
+    }
+}
+
+size_t SoilDataBase::CountColumns(std::string fileName) const
+{
+  std::ifstream ifile(fileName.c_str());
+  std::string line;
+  if (ifile.is_open())
+       {
+       size_t nbSpaces = 0;
+       if(!getline(ifile,line))
+         {
+         itkGenericExceptionMacro(<< "Error reading file " << fileName);
+         }
+       ifile.close();
+       boost::trim(line);
+       auto found = line.find(' ');
+       while(found!=std::string::npos)
+         {
+         ++nbSpaces;
+         while(line[found+1] == ' ') ++found;
+         found = line.find(' ', found+1);
+         }
+       return nbSpaces+1;
+       }
+  else
+    {
+    itkGenericExceptionMacro(<< "Could not open file " << fileName);
+    }
+}
+void SoilDataBase::ParseSoilFile()
+{
+  auto number_of_soils = CountColumns(m_SoilFileName) - 1;
+  m_SoilDataVector.resize(number_of_soils);
+  std::ifstream sdb(m_SoilFileName);
+  if(! sdb.is_open())
+    {
+    itkGenericExceptionMacro(<< "Could not open file " << m_SoilFileName);
+    }
+  std::string line;
+  while(std::getline(sdb, line))
+    {
+    if(line.size() > 3)
+      {
+      std::stringstream ss(line);
+      double tmpwl;
+      ss >> tmpwl;
+      WavelenghtType wl = static_cast<WavelenghtType>(m_WlFactor*tmpwl);
+      m_Wavelengths.push_back(wl);
+      for(size_t i=0; i< number_of_soils; ++i)
+        {
+        double refl;
+        ss >> refl;
+        m_SoilDataVector[i][wl] = refl;
+        }
+      }
+    }
+  std::sort(m_Wavelengths.begin(), m_Wavelengths.end());
+}
+}// namespace otb
diff --git a/Modules/Radiometry/Simulation/test/CMakeLists.txt b/Modules/Radiometry/Simulation/test/CMakeLists.txt
index fc44b84..bcb0733 100644
--- a/Modules/Radiometry/Simulation/test/CMakeLists.txt
+++ b/Modules/Radiometry/Simulation/test/CMakeLists.txt
@@ -53,10 +53,11 @@ otbSailReflVTest.cxx
 otbSatelliteRSRNew.cxx
 otbSailReflHTest.cxx
 otbFilterFunctionValues.cxx
+otbSoilDBTest.cxx
 )
 
 add_executable(otbSimulationTestDriver ${OTBSimulationTests})
-target_link_libraries(otbSimulationTestDriver ${OTBSimulation-Test_LIBRARIES})
+target_link_libraries(otbSimulationTestDriver ${OTBSimulation-Test_LIBRARIES} )
 otb_module_target_label(otbSimulationTestDriver)
 
 # Tests Declaration
@@ -318,3 +319,46 @@ otb_add_test(NAME raTuFilterFunctionValuesTest COMMAND otbSimulationTestDriver
   0.05            # user step
   0.2 0.5 0.3 0.9 0.8 # vector
   )
+
+otb_add_test(NAME siTvSoilDataParseFile COMMAND otbSimulationTestDriver otbSoilDataBaseParseFile
+  ${INPUTDATA}/Radiometry/Soils/sols_avignon_1990.txt
+  400 # wlmin
+  2450# wlmax
+  10  # wlstep
+  400 # wltest
+  0   # soil index test
+  1.0200000e-001 # refl test
+  460
+  2
+  6.2000000e-002
+  2440
+  134
+  6.8700000e-001
+  2450
+  133
+  6.0800000e-001
+  )
+
+otb_add_test(NAME siTvSailReflHSoilTest COMMAND otbSimulationTestDriver
+  --compare-ascii ${EPSILON_3} ${BASELINE_FILES}/Simulation/siTvSailReflHSoilTest.txt
+  ${TEMP}/siTvSailReflHSoilTest.txt
+  otbSailReflHTest
+  30.0 #cab
+  10.0 #car
+  0.0 #CBrown
+  0.015 #Cw
+  0.009 #Cm
+  1.2 #N
+  2 #LAI
+  50 #Angl
+  1 #PSoil
+  70 #Skyl
+  0.2 #HSpot
+  30 #TTS
+  0 #TTO
+  0 #PSI
+  ${TEMP}/siTvSailReflHSoilTest.txt
+  ${INPUTDATA}/Radiometry/Soils/sols_avignon_1990.txt
+  20 # soil index
+  1000 #wlfactor
+  )
diff --git a/Modules/Radiometry/Simulation/test/otbReduceSpectralResponse.cxx b/Modules/Radiometry/Simulation/test/otbReduceSpectralResponse.cxx
index 1d03b3a..388f669 100644
--- a/Modules/Radiometry/Simulation/test/otbReduceSpectralResponse.cxx
+++ b/Modules/Radiometry/Simulation/test/otbReduceSpectralResponse.cxx
@@ -62,7 +62,7 @@ int otbReduceSpectralResponse(int argc, char * argv[])
   myReduceResponse->SetInputSatRSR(myRSR);
   /** Load the spectral response of the object in the simulator*/
   myReduceResponse->SetInputSpectralResponse(mySpectralResponse);
-  /** Set the reflectance or luminance mode */
+  /** Set the reflectance or radiance mode */
   myReduceResponse->SetReflectanceMode(reflectanceMode);
   myReduceResponse->CalculateResponse();
   /** Print the Reduce SR*/
@@ -194,7 +194,7 @@ int otbReduceSpectralResponseSimpleValues(int argc, char * argv[])
 
   if(fabs(b0Result-b0Expected)>tolerance)
     {
-    std::cout << "Wrong value for B0: expected eq. luminance = " << b0Expected
+    std::cout << "Wrong value for B0: expected eq. radiance = " << b0Expected
               << "; got " << b0Result
               << std::endl;
     return EXIT_FAILURE;
@@ -207,7 +207,7 @@ int otbReduceSpectralResponseSimpleValues(int argc, char * argv[])
 
   if(fabs(b1Result-b1Expected)>tolerance)
     {
-    std::cout << "Wrong value for B1: expected eq. luminance = " << b1Expected
+    std::cout << "Wrong value for B1: expected eq. radiance = " << b1Expected
               << "; got " << b1Result
               << std::endl;
     return EXIT_FAILURE;
diff --git a/Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx b/Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx
index dfd6c31..33f6d8c 100644
--- a/Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx
+++ b/Modules/Radiometry/Simulation/test/otbSailReflHTest.cxx
@@ -29,11 +29,11 @@
 
 int otbSailReflHTest(int argc, char * argv[])
 {
-   if(argc != 16)
-   {
-      std::cout<<"Wrong number of arguments !"<<std::endl;
-      return EXIT_FAILURE;
-   }
+  if(argc < 16 || argc > 19)
+    {
+    std::cout<<"Wrong number of arguments !"<<std::endl;
+    return EXIT_FAILURE;
+    }
 
    double Cab=static_cast<double>(atof(argv[1]));
    double Car=static_cast<double>(atof(argv[2]));
@@ -50,6 +50,17 @@ int otbSailReflHTest(int argc, char * argv[])
    double TTO=static_cast<double>(atof(argv[13]));
    double PSI=static_cast<double>(atof(argv[14]));
    char * OutputName      = argv[15];
+   std::string SoilFileName{};
+   size_t SoilIndex{0};
+   double WlFactor{1000};
+   bool UseSoilFile = false;
+   if(argc == 19)
+     {
+     UseSoilFile = true;
+     SoilFileName = argv[16];
+     SoilIndex = static_cast<size_t>(atoi(argv[17]));
+     WlFactor = static_cast<double>(atof(argv[18]));
+     }
 
 
    typedef otb::ProspectModel ProspectType;
@@ -81,13 +92,20 @@ int otbSailReflHTest(int argc, char * argv[])
    sail->SetPSI(PSI);
    sail->SetReflectance(prospect->GetReflectance());
    sail->SetTransmittance(prospect->GetTransmittance());
+   std::shared_ptr<otb::SoilDataBase> SoilDB;
+   if(UseSoilFile)
+     {
+     std::cout << "Using soil file " << SoilFileName << '\n';
+     SoilDB = std::make_shared<otb::SoilDataBase>(SoilFileName, WlFactor);
+     sail->UseExternalSoilDB(SoilDB, SoilIndex);
+     }
    sail->Update();
 
    std::ofstream outputFile(OutputName, std::ios::out);
    for(unsigned int i=0; i<sail->GetHemisphericalReflectance()->Size(); ++i)
-   {
-      outputFile<<sail->GetHemisphericalReflectance()->GetResponse()[i].second<<std::endl;
-   }
+        {
+        outputFile<<sail->GetHemisphericalReflectance()->GetResponse()[i].second<<std::endl;
+        }
 
 
    return EXIT_SUCCESS;
diff --git a/Modules/Radiometry/Simulation/test/otbSimulationTestDriver.cxx b/Modules/Radiometry/Simulation/test/otbSimulationTestDriver.cxx
index 854e8b8..8ae63e0 100644
--- a/Modules/Radiometry/Simulation/test/otbSimulationTestDriver.cxx
+++ b/Modules/Radiometry/Simulation/test/otbSimulationTestDriver.cxx
@@ -50,4 +50,5 @@ void RegisterTests()
   REGISTER_TEST(otbSailReflHTest);
   REGISTER_TEST(otbFilterFunctionValuesSpectralResponseTest);
   REGISTER_TEST(otbFilterFunctionValuesTest);
+  REGISTER_TEST(otbSoilDataBaseParseFile);
 }
diff --git a/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx b/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx
new file mode 100644
index 0000000..49e89d7
--- /dev/null
+++ b/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx
@@ -0,0 +1,77 @@
+/*
+ * 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 "otbMacro.h"
+#include "otbSoilDataBase.h"
+#include <iostream>
+
+int otbSoilDataBaseParseFile(int argc, char * argv[])
+{
+  if(argc < 5)
+    {
+    std::cout << "Usage: " << argv[0] << " soil_file wlmin wlmax wlstep wltest1 soilindextest1 refltest1 [wltest2 soilindextest2 refltest2 ...]" << '\n';
+    return EXIT_FAILURE;
+    }
+  std::string sfn(argv[1]);
+
+  otb::SoilDataBase sdb(sfn, 1000);
+  auto db = sdb.GetDB();
+
+  for(unsigned int i=5; i<static_cast<unsigned int>(argc); i+=3)
+    {
+    auto wltest = std::stoi(argv[i]);
+    auto sindex = std::stoi(argv[i+1]);
+    auto refltest = std::stod(argv[i+2]);
+    auto read_refl = db[sindex][wltest];
+    if(fabs(refltest-read_refl)>10e-5)
+      {
+      std::cout << "GetDB " << i << " " << refltest << " " << read_refl << "\n";
+      return EXIT_FAILURE;
+      }
+
+    read_refl = sdb.GetReflectance(sindex, wltest);
+    if(fabs(refltest-read_refl)>10e-5)
+      {
+      std::cout << "GetRefl " << i << " " << refltest << " " << read_refl << "\n";
+      return EXIT_FAILURE;
+      }
+
+    }
+
+  for(unsigned int i=5; i<static_cast<unsigned int>(argc); i+=3)
+    {
+    auto wltest = std::stoi(argv[i]);
+    auto sindex = std::stoi(argv[i+1]);
+    auto refltest = std::stod(argv[i+2]);
+    auto read_refl = db[sindex][wltest];
+
+    read_refl = sdb.GetReflectance(sindex, wltest+1);
+    if(fabs(refltest-read_refl)>10e-2)
+      {
+      std::cout << refltest << " " << read_refl << '\n';
+      return EXIT_FAILURE;
+      }
+
+    }
+
+  return EXIT_SUCCESS;
+}
+
diff --git a/Modules/Remote/Mosaic.remote.cmake b/Modules/Remote/Mosaic.remote.cmake
index adfa72d..035a5bc 100644
--- a/Modules/Remote/Mosaic.remote.cmake
+++ b/Modules/Remote/Mosaic.remote.cmake
@@ -5,5 +5,5 @@ A more detailed description can be found on the project website:
 https://github.com/remicres/otb-mosaic
 "
   GIT_REPOSITORY https://github.com/remicres/otb-mosaic.git
-  GIT_TAG 516dfa7e7b91aa0263e495ee6b3878a03ced9173
+  GIT_TAG 56426908db01f33a5b96311e2a7eaac30ecd8e5d
 )
diff --git a/Modules/Remote/SertitObject.remote.cmake b/Modules/Remote/SertitObject.remote.cmake
index 429896f..e424926 100644
--- a/Modules/Remote/SertitObject.remote.cmake
+++ b/Modules/Remote/SertitObject.remote.cmake
@@ -26,5 +26,5 @@ median, variance, kurtosis, skewness. The result could be use to perform further
 object-oriented image analysis.
 "
   GIT_REPOSITORY https://github.com/sertit/SertitObject.git
-  GIT_TAG 9088356af5835e0a8de9946bd508735f3e55cb83
+  GIT_TAG 49b6540c774ddb7c2d56e39f6f118c4dfb9b8bd3
 )
diff --git a/Modules/Remote/otb-bv.remote.cmake b/Modules/Remote/otb-bv.remote.cmake
index 4816ae2..06e067e 100644
--- a/Modules/Remote/otb-bv.remote.cmake
+++ b/Modules/Remote/otb-bv.remote.cmake
@@ -25,5 +25,5 @@ A more detailed description can be found on the project website:
 http://tully.ups-tlse.fr/jordi/otb-bv
 "
   GIT_REPOSITORY http://tully.ups-tlse.fr/jordi/otb-bv.git
-  GIT_TAG master
+  GIT_TAG 0e56e487aebc4a493e25223960560e9ef0ca27ec
 )
diff --git a/Modules/Remote/otbFFSforGMM.remote.cmake b/Modules/Remote/otbFFSforGMM.remote.cmake
index 06e69cf..edd80d7 100644
--- a/Modules/Remote/otbFFSforGMM.remote.cmake
+++ b/Modules/Remote/otbFFSforGMM.remote.cmake
@@ -25,5 +25,5 @@ A more detailed description can be found on the project website:
 https://github.com/Laadr/otbFFSforGMM
 "
   GIT_REPOSITORY https://github.com/Laadr/otbFFSforGMM.git
-  GIT_TAG 20f3938ffa585a3ec6e735c48e8d5e6ec77fe80a
+  GIT_TAG 1164391d09b9987f7f7ea6718347c772e31a396a
   )
diff --git a/Modules/Remote/otbGRM.remote.cmake b/Modules/Remote/otbGRM.remote.cmake
index c6ac506..383c97d 100644
--- a/Modules/Remote/otbGRM.remote.cmake
+++ b/Modules/Remote/otbGRM.remote.cmake
@@ -11,6 +11,6 @@ to see which format you must respect to add a new criterion.
 A more detailed description can be found on the project website:
 http://tully.ups-tlse.fr/lassallep/grm
 "
-  GIT_REPOSITORY http://tully.ups-tlse.fr/lassallep/grm.git
-  GIT_TAG a08d2309bc8d4f4ceaf1dba8bda33aa1e21fc4aa
+  GIT_REPOSITORY https://github.com/orfeotoolbox/GRM
+  GIT_TAG c53a61d12b895a85c3909130021988730c309cb7
 )
diff --git a/Modules/Remote/phenotb.remote.cmake b/Modules/Remote/phenotb.remote.cmake
index d76b4f1..aa9e9a8 100644
--- a/Modules/Remote/phenotb.remote.cmake
+++ b/Modules/Remote/phenotb.remote.cmake
@@ -27,5 +27,5 @@ A more detailed description can be found on the project website:
 http://tully.ups-tlse.fr/jordi/phenotb
 "
   GIT_REPOSITORY http://tully.ups-tlse.fr/jordi/phenotb.git
-  GIT_TAG master
+  GIT_TAG c9349eb89a652a18b28a40dfb3fa352b76388527
 )
diff --git a/Modules/Remote/temporal-gapfilling.remote.cmake b/Modules/Remote/temporal-gapfilling.remote.cmake
index 5570cee..a33a9e0 100644
--- a/Modules/Remote/temporal-gapfilling.remote.cmake
+++ b/Modules/Remote/temporal-gapfilling.remote.cmake
@@ -26,5 +26,5 @@ A more detailed description can be found on the project website:
 http://tully.ups-tlse.fr/jordi/temporalgapfilling
 "
   GIT_REPOSITORY http://tully.ups-tlse.fr/jordi/temporalgapfilling.git
-  GIT_TAG master
+  GIT_TAG 4180f28091fb10029860ada2dcf9c9526d3a55d2
 )
diff --git a/Modules/ThirdParty/GeoTIFF/otb-module.cmake b/Modules/ThirdParty/GeoTIFF/otb-module.cmake
index 0f331ec..8fbc7b5 100644
--- a/Modules/ThirdParty/GeoTIFF/otb-module.cmake
+++ b/Modules/ThirdParty/GeoTIFF/otb-module.cmake
@@ -27,4 +27,6 @@ otb_module(OTBGeoTIFF
     
   DESCRIPTION
     "${DOCUMENTATION}"
+
+  EXCLUDE_FROM_DEFAULT
   )
diff --git a/Modules/ThirdParty/MuParserX/otb-module.cmake b/Modules/ThirdParty/MuParserX/otb-module.cmake
index d0242cb..d443a21 100644
--- a/Modules/ThirdParty/MuParserX/otb-module.cmake
+++ b/Modules/ThirdParty/MuParserX/otb-module.cmake
@@ -30,5 +30,3 @@ otb_module(OTBMuParserX
   )
 
 otb_module_activation_option("Enable MuParserX dependent modules" OFF)
-
-otb_module_requires_cxx11()
diff --git a/Modules/ThirdParty/OpenCV/CMakeLists.txt b/Modules/ThirdParty/OpenCV/CMakeLists.txt
index 224f731..e6b73b5 100644
--- a/Modules/ThirdParty/OpenCV/CMakeLists.txt
+++ b/Modules/ThirdParty/OpenCV/CMakeLists.txt
@@ -27,7 +27,5 @@ set(OTBOpenCV_LIBRARIES "${OPENCV_LIBRARIES}")
 set(OTBOpenCV_INCLUDE_DIRS
   ${OTBOpenCV_BINARY_DIR}/src
   )
-set(OTBOpenCV_EXPORT_CODE_BUILD "find_package(OpenCV REQUIRED)")
-set(OTBOpenCV_EXPORT_CODE_INSTALL ${OTBOpenCV_EXPORT_CODE_BUILD})
 
 otb_module_impl()
diff --git a/Modules/ThirdParty/OpenGL/CMakeLists.txt b/Modules/ThirdParty/OpenGL/CMakeLists.txt
index cfbdd8c..99ab638 100644
--- a/Modules/ThirdParty/OpenGL/CMakeLists.txt
+++ b/Modules/ThirdParty/OpenGL/CMakeLists.txt
@@ -23,5 +23,12 @@ set(OTBOpenGL_THIRD_PARTY 1)
 
 set(OTBOpenGL_SYSTEM_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
 set(OTBOpenGL_LIBRARIES ${OPENGL_LIBRARIES})
+set(OTBOpenGL_EXPORT_CODE_INSTALL "
+set(OTBOpenGL_LIBRARIES)
+set(OTBOpenGL_INCLUDE_DIRS)
+find_package(OpenGL REQUIRED)
+set(OTBOpenGL_LIBRARIES \${OPENGL_LIBRARIES})
+set(OTBOpenGL_SYSTEM_INCLUDE_DIRS \${OPENGL_INCLUDE_DIR})
+")
 
 otb_module_impl()
diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimCosmoSkymedModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimCosmoSkymedModel.cpp
index 30cbcff..ca120f9 100644
--- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimCosmoSkymedModel.cpp
+++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimCosmoSkymedModel.cpp
@@ -99,7 +99,7 @@ bool ossimCosmoSkymedModel::InitSensorParams(const ossimKeywordlist &kwl, const
 
 
   /**
-  * @todo : � voir sur de vrais produits (exemples de DESCENDING et ASCENDING)
+  * @todo : see on real products (for example DESCENDING and ASCENDING)
   */
   const char* orbitDirection_str = kwl.find(prefix,"orbitDirection");
   std::string orbitDirection(orbitDirection_str) ;
diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimEnvisatAsarModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimEnvisatAsarModel.cpp
index dacf39e..78b2911 100644
--- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimEnvisatAsarModel.cpp
+++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimEnvisatAsarModel.cpp
@@ -404,7 +404,7 @@ namespace ossimplugins
          fa = 1.0/atof(fa_str);
       }
 
-      // TODO : v�rifier que ceci est ok pour les produits IMP
+      // TODO check that this is OK for IMP products
       const char* time_dir_pix = "INCREASE";
       const char* time_dir_lin = "INCREASE";
 
diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesDimapSupportData.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesDimapSupportData.cpp
index ab0e39e..274cbcd 100644
--- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesDimapSupportData.cpp
+++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesDimapSupportData.cpp
@@ -2763,7 +2763,7 @@ namespace ossimplugins
       vector<ossimRefPtr<ossimXmlNode> > xml_nodes;
 
       //---
-      // Fetch the mission index (1A ou 1B) ?
+      // Fetch the mission index (1A or 1B) ?
       // and generate theSensorID
       //---
       if (theDIMAPVersion == OSSIM_PLEIADES_DIMAPv1)
@@ -2791,7 +2791,7 @@ namespace ossimplugins
       }
 
       //---
-      // Fetch the mission index (1A ou 1B) ?
+      // Fetch the mission index (1A or 1B) ?
       // and generate theSensorID
       //---
       if (theDIMAPVersion == OSSIM_PLEIADES_DIMAPv1)
diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp
index 0ac9007..49e06d3 100644
--- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp
+++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp
@@ -996,7 +996,7 @@ namespace ossimplugins
          std::vector<ossimSarSensorModel::OrbitRecordType> & orbitRecords)
    {
       char orbit_prefix_[256];
-      std::size_t nbOrbits;
+      std::size_t nbOrbits(0);
       try {
          get(kwl, "orbitList.nb_orbits", nbOrbits);
       } catch (kw_runtime_error const& e) {
@@ -1042,7 +1042,7 @@ namespace ossimplugins
          std::vector<ossimSarSensorModel::BurstRecordType> & burstRecords)
    {
       char burstPrefix_[1024];
-      std::size_t nbBursts ;
+      std::size_t nbBursts(0);
       get(kwl, BURST_NUMBER_KEY, nbBursts);
       for (std::size_t burstId=0; burstId!=nbBursts ; ++burstId) {
          const int pos = s_printf(burstPrefix_, "%s[%d].", BURST_PREFIX.c_str(), burstId);
@@ -1063,7 +1063,7 @@ namespace ossimplugins
          std::vector<ossimSarSensorModel::GCPRecordType> & gcpRecords)
    {
       char prefix_[1024];
-      std::size_t nbGCPs ;
+      std::size_t nbGCPs(0);
       get(kwl, GCP_NUMBER_KEY, nbGCPs);
       for (std::size_t gcpId=0; gcpId!=nbGCPs ; ++gcpId) {
          const int pos = s_printf(prefix_, "%s[%d].", GCP_PREFIX.c_str(), gcpId);
@@ -1089,7 +1089,7 @@ namespace ossimplugins
          std::vector<ossimSarSensorModel::CoordinateConversionRecordType> & outputRecords)
    {
       char prefix_[1024];
-      std::size_t nbCoords ;
+      std::size_t nbCoords(0);
       get(kwl, sr_gr_prefix +"."+ NUMBER_KEY, nbCoords);
 
       for (std::size_t idx=0 ; idx!=nbCoords ; ++idx)
@@ -1102,7 +1102,7 @@ namespace ossimplugins
          get(kwl, prefix + keyAzimuthTime,  coordRecord.azimuthTime);
          get(kwl, prefix + rg0,             coordRecord.rg0);
 
-         std::size_t nbCoeffs;
+         std::size_t nbCoeffs(0);
          get(kwl, prefix + NUMBER_KEY,      nbCoeffs);
          for (std::size_t coeff_idx=0; coeff_idx!=nbCoeffs ; ++coeff_idx) {
             const int pos2 = s_printf(prefix_+pos, sizeof(prefix_)-pos, "coeff[%d]", coeff_idx);
diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6DimapSupportData.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6DimapSupportData.cpp
index 9fdba63..bd852c0 100644
--- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6DimapSupportData.cpp
+++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6DimapSupportData.cpp
@@ -2128,7 +2128,7 @@ namespace ossimplugins
       vector<ossimRefPtr<ossimXmlNode> > xml_nodes;
 
       //---
-      // Fetch the mission index (1A ou 1B) ?
+      // Fetch the mission index (1A or 1B) ?
       // and generate theSensorID
       //---
       xpath = "/Dataset_Sources/Source_Identification/Strip_Source/MISSION";
@@ -2149,7 +2149,7 @@ namespace ossimplugins
       }
 
       //---
-      // Fetch the mission index (1A ou 1B) ?
+      // Fetch the mission index (1A or 1B) ?
       // and generate theSensorID
       //---
       xpath = "/Dataset_Sources/Source_Identification/Strip_Source/MISSION_INDEX"; //DIMAPv2
diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarModel.cpp
index a783c83..0b59928 100644
--- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarModel.cpp
+++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarModel.cpp
@@ -2400,56 +2400,36 @@ bool ossimplugins::ossimTerraSarModel::findTSXLeader(const ossimFilename& file,
    }
    else
    {
-      if (traceDebug())
-      {
-         ossimNotify(ossimNotifyLevel_DEBUG)
-            << "ossimplugins::ossimTerraSarModel::findTSXLeader "
-            << " directory scan turned off.  This is killing the factory open."
-            << " We should never scan a directory.  Need to resolve. "
-            << std::endl;
-      }
-
-//#if 0
-      ossimFilename imagePath = file.path();
-      if (imagePath.empty())
-         imagePath = ossimEnvironmentUtility::instance()->getCurrentWorkingDir();
-
-      ossimDirectory directory = ossimDirectory(imagePath.path());
-      std::vector<ossimFilename> vectName;
-      ossimString reg = ".xml";
-      directory.findAllFilesThatMatch( vectName, reg, 1 );
-
-      bool goodFileFound = false;
-      unsigned int loop = 0;
-      while(loop<vectName.size() && !goodFileFound)
-      {
-         ossimFilename curFile = vectName[loop];
-         if(curFile.file().beforePos(3) == ossimString("TSX"))
-            goodFileFound = true;
-         else
-            loop++;
-      }
-      if(goodFileFound)
-      {
-         metadataFile = vectName[loop];
-         res = true;
-      }
-      else
-      {
-         if (traceDebug())
-         {
-            if (res)
-            {
-               this->print(ossimNotify(ossimNotifyLevel_DEBUG));
-            }
-            
-            ossimNotify(ossimNotifyLevel_DEBUG)
-               << "ossimplugins::ossimTerraSarModel::findTSXLeader "
-               << " exit status = " << (res?"true":"false\n")
-               << std::endl;
-         }
+      ossimFilename imagePath = file.expand().path();
+
+      if (imagePath.file() == ossimString("IMAGEDATA"))
+      {
+        std::cerr << "SCANNING DIRECTORY" << std::endl;
+        ossimFilename productPath = imagePath.path();
+        ossimDirectory directory = ossimDirectory(productPath);
+        std::vector<ossimFilename> vectName;
+        ossimString reg = "^T(S|D)X1_SAR__.*\\.xml$";
+        directory.findAllFilesThatMatch( vectName, reg, 1 );
+        if (vectName.size())
+        {
+          metadataFile = vectName[0];
+          res = true;
+        }
+        else
+        {
+           if (traceDebug())
+           {
+              if (res)
+              {
+                 this->print(ossimNotify(ossimNotifyLevel_DEBUG));
+              }
+              ossimNotify(ossimNotifyLevel_DEBUG)
+                 << "ossimplugins::ossimTerraSarModel::findTSXLeader "
+                 << " exit status = " << (res?"true":"false\n")
+                 << std::endl;
+           }
+        }
       }
-//#endif
    }
 
    return res;
diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/CivilDateTime.h b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/CivilDateTime.h
index 7388246..e363b9b 100644
--- a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/CivilDateTime.h
+++ b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/CivilDateTime.h
@@ -80,21 +80,21 @@ public:
    /**
     * @brief This function converts the current CivilDateTime into Julian Date
     * @return 0 if no error or an int greater than 0 indicating the error
-    * @param julianDate [out] The classe that receives the result of the conversion of the current CivilDateTime into JulianDate
+    * @param julianDate [out] The class that receives the result of the conversion of the current CivilDateTime into JulianDate
     */
    int AsJulianDate(JulianDate* julianDate);
 
    /**
     * @brief This function converts the current CivilDateTime into JSDDateTime
     * @return 0 if no error or an int greater than 0 indicating the error
-    * @param JSDdate [out] The classe that receives the result of the conversion of the current CivilDateTime into JSDDateTime
+    * @param JSDdate [out] The class that receives the result of the conversion of the current CivilDateTime into JSDDateTime
     */
    int AsJSDDateTime(JSDDateTime* JSDdate);
 
    /**
     * @brief This function converts the current CivilDateTime into GMSTDateTime
     * @return 0 if no error or an int greater than 0 indicating the error
-    * @param GMSTdate [out] The classe that receives the result of the conversion of the current CivilDateTime into GMSTDateTime
+    * @param GMSTdate [out] The class that receives the result of the conversion of the current CivilDateTime into GMSTDateTime
     */
    int AsGMSTDateTime(GMSTDateTime* GMSTdate);
 
diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/GalileanEphemeris.h b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/GalileanEphemeris.h
index d9fc831..251aeb2 100644
--- a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/GalileanEphemeris.h
+++ b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/GalileanEphemeris.h
@@ -68,7 +68,7 @@ public:
   GalileanEphemeris& operator=(const GalileanEphemeris& rhs);
 
   /**
-   * @brief This fonction converts the current ephemeris in the Geographic coordinates syst�m
+   * @brief This function converts the current ephemeris in the Geographic coordinates system
    */
   void ToGeographic(GeographicEphemeris* vGeo);
   void ToGeographic(double greenwich,GeographicEphemeris* vGeo);
diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/GeographicEphemeris.h b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/GeographicEphemeris.h
index e7daea9..465b5d9 100644
--- a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/GeographicEphemeris.h
+++ b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/GeographicEphemeris.h
@@ -66,7 +66,7 @@ public:
   GeographicEphemeris& operator=(const GeographicEphemeris& rhs);
 
   /**
-   * @brief This fonction converts the current ephemeris in the Galilean coordinates system
+   * @brief This function converts the current ephemeris in the Galilean coordinates system
    */
   void ToGalilean(GalileanEphemeris* vGal);
 
diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/JSDDateTime.h b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/JSDDateTime.h
index d5154ee..8f6b251 100644
--- a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/JSDDateTime.h
+++ b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/JSDDateTime.h
@@ -117,7 +117,7 @@ public:
    /**
     * @brief This function converts the current JSDDateTime into Julian Date
     * @return 0 if no error or an int greater than 0 indicating the error
-    * @param julianDate [out] The classe that receives the result of the conversion of the current JSDDateTime in JulianDate
+    * @param julianDate [out] The class that receives the result of the conversion of the current JSDDateTime in JulianDate
     */
    int AsJulianDate(JulianDate* julian);
 
diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/JulianDate.h b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/JulianDate.h
index c4a68e2..6c99837 100644
--- a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/JulianDate.h
+++ b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/JulianDate.h
@@ -89,7 +89,7 @@ public:
   /**
    * @brief This function converts the current JulianDate in JSDDateTime
    * @return 0 if no error or an int greater than 0 indicating the error
-   * @param JSDdate [out] The classe that receives the result of the conversion of the current JulianDate in JSDDateTime
+   * @param JSDdate [out] The class that receives the result of the conversion of the current JulianDate in JSDDateTime
    */
   int AsJSDDateTime(JSDDateTime* JSDdate);
 
diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/PlatformPosition.h b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/PlatformPosition.h
index b41072e..7568315 100644
--- a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/PlatformPosition.h
+++ b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/PlatformPosition.h
@@ -66,7 +66,7 @@ namespace ossimplugins
        * @param nbrData Number of Ephemeris in data
        * @remarks All the ephemeris have to be in the same coordinates system
        * @remarks This constructor copy the content of data, so it's the
-       * calling fonction that have to manage the memory of data.
+       * calling function that have to manage the memory of data.
        */
       PlatformPosition(Ephemeris** data, int nbrData);
 
diff --git a/Modules/ThirdParty/Qt4/otb-module-init.cmake b/Modules/ThirdParty/Qt4/otb-module-init.cmake
index d121d06..951a961 100644
--- a/Modules/ThirdParty/Qt4/otb-module-init.cmake
+++ b/Modules/ThirdParty/Qt4/otb-module-init.cmake
@@ -18,7 +18,7 @@
 # limitations under the License.
 #
 
-find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL QtXml )
+find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL) # QtXml )
 mark_as_advanced( QT_QMAKE_EXECUTABLE )
-set( QT_USE_QTXML 1 )
+#set( QT_USE_QTXML 1 )
 include( ${QT_USE_FILE} )
diff --git a/Modules/ThirdParty/Qwt/otb-module-init.cmake b/Modules/ThirdParty/Qwt/otb-module-init.cmake
index 76973fa..1c34103 100644
--- a/Modules/ThirdParty/Qwt/otb-module-init.cmake
+++ b/Modules/ThirdParty/Qwt/otb-module-init.cmake
@@ -20,8 +20,8 @@
 
 find_package(Qwt REQUIRED)
 
-if(NOT QWT_MAJOR_VERSION EQUAL 5)
-  message(FATAL_ERROR "Only Qwt 5 is supported. Found version ${QWT_VERSION_STRING}")
+if(NOT QWT_MAJOR_VERSION EQUAL 6)
+  message(FATAL_ERROR "Only Qwt 6 is supported. Found version '${QWT_VERSION_STRING}'")
 endif()
 
 if(WIN32)
diff --git a/Modules/ThirdParty/SPTW/otb-module.cmake b/Modules/ThirdParty/SPTW/otb-module.cmake
index eca0cb9..a1dc674 100644
--- a/Modules/ThirdParty/SPTW/otb-module.cmake
+++ b/Modules/ThirdParty/SPTW/otb-module.cmake
@@ -24,6 +24,7 @@ otb_module(OTBSPTW
   DEPENDS
     OTBMPI
     OTBGDAL
+    OTBTIFF
 
   TEST_DEPENDS
 
diff --git a/Modules/ThirdParty/SPTW/src/CMakeLists.txt b/Modules/ThirdParty/SPTW/src/CMakeLists.txt
index 5e0feb3..fcc9539 100644
--- a/Modules/ThirdParty/SPTW/src/CMakeLists.txt
+++ b/Modules/ThirdParty/SPTW/src/CMakeLists.txt
@@ -28,7 +28,11 @@ set(OTBSPTW_MAIN_SRCS sptw.cc)
 
 
 add_library(otbSPTW ${OTBSPTW_MAIN_SRCS})
-target_link_libraries(otbSPTW)
+target_link_libraries(otbSPTW
+  ${OTBMPI_LIBRARIES}
+  ${OTBGDAL_LIBRARIES}
+  ${OTBTIFF_LIBRARIES}
+  )
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 
 #Install TARGET & FILES for otb-lib
diff --git a/Modules/ThirdParty/Shark/otb-module.cmake b/Modules/ThirdParty/Shark/otb-module.cmake
index 99ba28e..2fee75a 100644
--- a/Modules/ThirdParty/Shark/otb-module.cmake
+++ b/Modules/ThirdParty/Shark/otb-module.cmake
@@ -30,6 +30,3 @@ otb_module(OTBShark
   )
 
 otb_module_activation_option("Enable SHARK dependent modules" OFF)
-
-otb_module_requires_cxx11()
-
diff --git a/Modules/ThirdParty/SiftFast/src/CMakeLists.txt b/Modules/ThirdParty/SiftFast/src/CMakeLists.txt
index d96230c..2c6dc50 100644
--- a/Modules/ThirdParty/SiftFast/src/CMakeLists.txt
+++ b/Modules/ThirdParty/SiftFast/src/CMakeLists.txt
@@ -51,12 +51,8 @@ if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
             message(FATAL_ERROR "Impossible to compile libsiftfast. Contact OTB development team")
         endif()
         set(OTB_DISABLE_FAST_FUNCTIONS_VALUE 1)
-    else()
-        message(STATUS "Try to compile libsiftfast.cpp done.")
     endif()
 
-  set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g")
-  add_definitions(" -Wall -fPIC ")
 
   # check for x86-64 system
   check_cxx_source_runs("
@@ -72,120 +68,30 @@ if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
     return 0;
   }"
   IS_X86_64)
-
-  if( IS_X86_64 )
-    add_definitions("-D__x86_64__")
-  endif()
 else()
   set(IS_X86_64 0)
 endif()
 
-if(OTB_DISABLE_FAST_FUNCTIONS_VALUE)
-    add_definitions(-DOTB_DISABLE_FAST_FUNCTIONS)
-endif()
-
-
-include(CheckIncludeFile)
-include(CheckLibraryExists)
-include(CheckCXXSourceRuns)
-include(CheckCXXCompilerFlag)
-
-# if( UNIX OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
-#   set(STDC_LIBRARY stdc++)
-# else()
-#   set(STDC_LIBRARY)
-# endif()
+#set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g")
+#add_xxdefinitions(" -Wall -fPIC ")
 
-# check for SSE extensions
+add_library(otbsiftfast libsiftfast.cpp)
 if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
-  set(SSE_FLAGS)
-
-  set(CMAKE_REQUIRED_FLAGS "-msse2")
-  check_cxx_source_runs("
-    #include <emmintrin.h>
-
-    int main()
-    {
-        __m128d a, b;
-        double vals[2] = {0};
-        a = _mm_loadu_pd(vals);
-        b = _mm_add_pd(a,a);
-        _mm_storeu_pd(vals,b);
-        return 0;
-     }"
-     HAS_SSE2_EXTENSIONS)
-
-  set(CMAKE_REQUIRED_FLAGS "-msse")
-  check_cxx_source_runs("
-    #include <xmmintrin.h>
-    int main()
-    {
-        __m128 a, b;
-        float vals[4] = {0};
-        a = _mm_loadu_ps(vals);
-        b = a;
-        b = _mm_add_ps(a,b);
-        _mm_storeu_ps(vals,b);
-        return 0;
-    }"
-    HAS_SSE_EXTENSIONS)
-
-  set(CMAKE_REQUIRED_FLAGS)
-
-  if(HAS_SSE2_EXTENSIONS)
-    message(STATUS "Using SSE2 extensions")
-    set(SSE_FLAGS "-msse2 -mfpmath=sse")
-  elseif(HAS_SSE_EXTENSIONS)
-    message(STATUS "Using SSE extensions")
-    set(SSE_FLAGS "-msse -mfpmath=sse")
-  endif()
-
-  add_definitions(${SSE_FLAGS})
-elseif(MSVC)
-    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
-      message(STATUS "Not using SSE2 extensions on x64")
-    else()
-      check_cxx_source_runs("
-       #include <emmintrin.h>
-       
-        int main()
-        {
-          __m128d a, b;
-          double vals[2] = {0};
-          a = _mm_loadu_pd(vals);
-          b = _mm_add_pd(a,a);
-          _mm_storeu_pd(vals,b);
-          return 0;
-        }"
-      HAS_SSE2_EXTENSIONS)
-     
-      if( HAS_SSE2_EXTENSIONS )
-        message(STATUS "Using SSE2 extensions")
-        add_definitions( "/arch:SSE2 /fp:fast -D__SSE__ -D__SSE2__" )
-      endif()
-    endif()
+  #  target_link_libraries(otbsiftfast m stdc++)
+  target_link_libraries(otbsiftfast m)
 endif()
 
-#set(Boost_ADDITIONAL_VERSIONS "1.40" "1.39" "1.38" "1.37.0" "1.37" "1.35.0" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33")
-#if( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
-#  set(Boost_INCLUDE_DIR $ENV{BOOST_INCLUDEDIR})
-#endif()
-#if( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
-#  set(Boost_LIBRARY_DIRS $ENV{BOOST_LIBRARYDIR})
-#endif()
-#find_package(Boost COMPONENTS python)
-
-#if( Boost_FOUND )
-#  message(STATUS "found boost version: ${Boost_VERSION}")
-#else()
-#  message(STATUS "Could not find boost libraries!")
-#endif()
 
-add_library(otbsiftfast libsiftfast.cpp)
+if(IS_X86_64)
+  set_target_properties(otbsiftfast
+    PROPERTIES COMPILE_FLAGS "-D__x86_64__")
+endif()
 
-if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
-#  target_link_libraries(otbsiftfast m stdc++)
-  target_link_libraries(otbsiftfast m)
+#set_source_files_properties(<file> PROPERTIES COMPILE_FLAGS <flags>)
+
+if(OTB_DISABLE_FAST_FUNCTIONS_VALUE)
+  set_target_properties(otbsiftfast
+    PROPERTIES COMPILE_FLAGS "-DOTB_DISABLE_FAST_FUNCTIONS")
 endif()
 
 #set_target_properties(otbsiftfast PROPERTIES OUTPUT_NAME  siftfast CLEAN_DIRECT_OUTPUT 1)
@@ -195,20 +101,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 #set_target_properties(siftfast PROPERTIES COMPILE_FLAGS "-DDVPROFILE")
 #target_link_libraries(siftfast libsiftfast)
 
-# check for OpenMP
-find_package(OpenMP)
-if(OPENMP_FOUND)
-  message(STATUS "Enabling OpenMP support")
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
-else()
-  message(STATUS "Disabling OpenMP support")
-endif()
-
 #Install TARGET & FILES for otb-lib
 if(OTB_LIBRARY_PROPERTIES)
-  set_target_properties(otbsiftfast PROPERTIES ${OTB_LIBRARY_PROPERTIES})
+  set_target_properties(otbsiftfast PROPERTIES ${OTB_LIBRARY_PROPERTIES}) 
 endif()
 
 install(TARGETS otbsiftfast
diff --git a/Modules/ThirdParty/Qt4/otb-module-init.cmake b/Modules/ThirdParty/TIFF/CMakeLists.txt
similarity index 82%
copy from Modules/ThirdParty/Qt4/otb-module-init.cmake
copy to Modules/ThirdParty/TIFF/CMakeLists.txt
index d121d06..d3cb2a3 100644
--- a/Modules/ThirdParty/Qt4/otb-module-init.cmake
+++ b/Modules/ThirdParty/TIFF/CMakeLists.txt
@@ -18,7 +18,9 @@
 # limitations under the License.
 #
 
-find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL QtXml )
-mark_as_advanced( QT_QMAKE_EXECUTABLE )
-set( QT_USE_QTXML 1 )
-include( ${QT_USE_FILE} )
+project(OTBTIFF)
+
+set(OTBTIFF_SYSTEM_INCLUDE_DIRS ${TIFF_INCLUDE_DIRS})
+set(OTBTIFF_LIBRARIES "${TIFF_LIBRARIES}")
+
+otb_module_impl()
diff --git a/Modules/ThirdParty/Qt4/otb-module-init.cmake b/Modules/ThirdParty/TIFF/otb-module-init.cmake
similarity index 82%
copy from Modules/ThirdParty/Qt4/otb-module-init.cmake
copy to Modules/ThirdParty/TIFF/otb-module-init.cmake
index d121d06..93a99b6 100644
--- a/Modules/ThirdParty/Qt4/otb-module-init.cmake
+++ b/Modules/ThirdParty/TIFF/otb-module-init.cmake
@@ -18,7 +18,4 @@
 # limitations under the License.
 #
 
-find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL QtXml )
-mark_as_advanced( QT_QMAKE_EXECUTABLE )
-set( QT_USE_QTXML 1 )
-include( ${QT_USE_FILE} )
+find_package ( TIFF REQUIRED )
diff --git a/Modules/ThirdParty/GeoTIFF/otb-module.cmake b/Modules/ThirdParty/TIFF/otb-module.cmake
similarity index 87%
copy from Modules/ThirdParty/GeoTIFF/otb-module.cmake
copy to Modules/ThirdParty/TIFF/otb-module.cmake
index 0f331ec..a066280 100644
--- a/Modules/ThirdParty/GeoTIFF/otb-module.cmake
+++ b/Modules/ThirdParty/TIFF/otb-module.cmake
@@ -18,13 +18,15 @@
 # limitations under the License.
 #
 
-set(DOCUMENTATION "This module imports GeoTIFF to the build system")
+set(DOCUMENTATION "This module imports TIFF to the build system")
 
-otb_module(OTBGeoTIFF
+otb_module(OTBTIFF
   DEPENDS
     
   TEST_DEPENDS
     
   DESCRIPTION
     "${DOCUMENTATION}"
+
+  EXCLUDE_FROM_DEFAULT
   )
diff --git a/Modules/Visualization/Mapla/src/CMakeLists.txt b/Modules/Visualization/Mapla/src/CMakeLists.txt
index 76c0f3c..ee5df87 100644
--- a/Modules/Visualization/Mapla/src/CMakeLists.txt
+++ b/Modules/Visualization/Mapla/src/CMakeLists.txt
@@ -72,7 +72,6 @@ add_to_qt4_i18n_forms( ${OTBMapla_FORMS} )
 
 ##########################[Mapla library]####################################
 add_library( OTBMapla
-  STATIC
   ${OTBMapla_SRCS}
   ${OTBMapla_FORMS_HEADERS}
   ${OTBMapla_SRC_MOC}
diff --git a/Modules/Visualization/Mapla/src/mvdMaplaWin32.rc.in b/Modules/Visualization/Mapla/src/mvdMaplaWin32.rc.in
index 59c1507..9c40a86 100644
--- a/Modules/Visualization/Mapla/src/mvdMaplaWin32.rc.in
+++ b/Modules/Visualization/Mapla/src/mvdMaplaWin32.rc.in
@@ -16,7 +16,7 @@ BEGIN
         BLOCK "000004b0"
         BEGIN
             VALUE "CompanyName", "OrfeoToolbox"
-            VALUE "FileDescription", "Monteverdi 2"
+            VALUE "FileDescription", "Monteverdi"
             VALUE "FileVersion", "@Monteverdi_VERSION_MAJOR at .@Monteverdi_VERSION_MINOR at .@Monteverdi_VERSION_PATCH at .0"
             VALUE "LegalCopyright", "Copyright (c) 2012-2013 Centre National d'Etudes Spatiales. All rights reserved."
             VALUE "InternalName", "mapla"
diff --git a/Modules/Visualization/Monteverdi/src/CMakeLists.txt b/Modules/Visualization/Monteverdi/src/CMakeLists.txt
index d130e78..6b450c1 100644
--- a/Modules/Visualization/Monteverdi/src/CMakeLists.txt
+++ b/Modules/Visualization/Monteverdi/src/CMakeLists.txt
@@ -55,7 +55,6 @@ add_to_qt4_i18n_forms( ${OTBMonteverdi_FORMS} )
 
 #############################################################################
 add_library( OTBMonteverdi
-  STATIC
   ${OTBMonteverdi_SRCS}
   ${OTBMonteverdi_FORMS_HEADERS}
   ${OTBMonteverdi_SRC_MOC}
diff --git a/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx b/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx
index 136343a..6b1d92c 100644
--- a/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx
+++ b/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx
@@ -1562,6 +1562,14 @@ MainWindow
     this,
     SLOT( OnReferenceLayerChanged( size_t ) )
   );
+
+  QObject::connect(
+    model,
+    SIGNAL( LayerRenamed() ),
+    // to:
+    this,
+    SLOT( RefreshReferenceLayerComboBox() )
+  );
 }
 
 /*****************************************************************************/
@@ -1597,21 +1605,11 @@ MainWindow
     AbstractLayerModel * layer = model->At( i );
     assert( layer!=NULL );
 
-    if( layer->inherits( VectorImageModel::staticMetaObject.className() ) )
-      {
-      const VectorImageModel * vectorImageModel =
-        qobject_cast< const VectorImageModel * >( layer );
-
-      assert( vectorImageModel!=NULL );
-
-      comboBox->addItem(
-        QString( "%1 (%2)" )
-        .arg( layer->GetAuthorityCode( true ).c_str()  )
-        .arg( QFileInfo( vectorImageModel->GetFilename() ).fileName() )
-      );
-      }
-    else
-      qDebug() << "Unhandled AbstractLayerModel subclass.";
+    comboBox->addItem(
+      QString( "%1 (%2)" )
+      .arg( layer->GetAuthorityCode( true ).c_str()  )
+      .arg( layer->GetName() )
+    );
     }
 
   {
@@ -1683,6 +1681,14 @@ MainWindow
       this,
       SLOT( OnReferenceLayerChanged( size_t ) )
     );
+
+    QObject::connect(
+      model,
+      SIGNAL( LayerRenamed() ),
+      // to:
+      this,
+      SLOT( RefreshReferenceLayerComboBox() )
+    );
     }
 
   comboBox->clear();
diff --git a/Modules/Visualization/Monteverdi/src/mvdWin32.rc.in b/Modules/Visualization/Monteverdi/src/mvdWin32.rc.in
index fdb8647..c26d776 100644
--- a/Modules/Visualization/Monteverdi/src/mvdWin32.rc.in
+++ b/Modules/Visualization/Monteverdi/src/mvdWin32.rc.in
@@ -16,12 +16,12 @@ BEGIN
         BLOCK "000004b0"
         BEGIN
             VALUE "CompanyName", "OrfeoToolbox"
-            VALUE "FileDescription", "Monteverdi 2"
+            VALUE "FileDescription", "Monteverdi"
             VALUE "FileVersion", "@Monteverdi_VERSION_MAJOR at .@Monteverdi_VERSION_MINOR at .@Monteverdi_VERSION_PATCH at .0"
             VALUE "LegalCopyright", "Copyright (c) 2012-2013 Centre National d'Etudes Spatiales. All rights reserved."
             VALUE "InternalName", "monteverdi"
             VALUE "OriginalFilename", "monteverdi.exe"
-            VALUE "ProductName", "Monteverdi 2"
+            VALUE "ProductName", "Monteverdi"
             VALUE "ProductVersion", "@Monteverdi_VERSION_MAJOR at .@Monteverdi_VERSION_MINOR at .@Monteverdi_VERSION_PATCH at .0"
         END
     END
diff --git a/Modules/Visualization/MonteverdiCore/include/mvdAbstractLayerModel.h b/Modules/Visualization/MonteverdiCore/include/mvdAbstractLayerModel.h
index ce0c2bd..ab4065a 100644
--- a/Modules/Visualization/MonteverdiCore/include/mvdAbstractLayerModel.h
+++ b/Modules/Visualization/MonteverdiCore/include/mvdAbstractLayerModel.h
@@ -139,6 +139,12 @@ public:
    */
   void ToWgs84( const PointType &, PointType & wgs84, double & alt ) const;
 
+  /** Setter for the m_Name attribute ( should be initialized by subclasses )*/
+  void SetName(const QString & name);
+
+  /** Getter for the m_Name attribute */
+  const QString & GetName() const;
+
   /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
 
 //
@@ -155,6 +161,9 @@ signals:
   void VisibilityChanged( bool =true );
   void VisibilityChanged( AbstractLayerModel *, bool );
 
+  /** Signal to other components that the name has changed */
+  void NameChanged();
+
   /*-[ PROTECTED SECTION ]---------------------------------------------------*/
 
 //
@@ -198,6 +207,7 @@ private:
 // Private attributes.
 private:
 
+  QString m_Name;
   /*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
 
 //
diff --git a/Modules/Visualization/MonteverdiCore/include/mvdStackedLayerModel.h b/Modules/Visualization/MonteverdiCore/include/mvdStackedLayerModel.h
index ff76795..035914c 100644
--- a/Modules/Visualization/MonteverdiCore/include/mvdStackedLayerModel.h
+++ b/Modules/Visualization/MonteverdiCore/include/mvdStackedLayerModel.h
@@ -254,6 +254,8 @@ signals:
 
   void ResolutionsChanged( const PixelInfo::Vector & );
 
+  void LayerRenamed();
+
   /*-[ PROTECTED SECTION ]---------------------------------------------------*/
 
 //
diff --git a/Modules/Visualization/MonteverdiCore/src/ConfigureMonteverdi.h.in b/Modules/Visualization/MonteverdiCore/src/ConfigureMonteverdi.h.in
index 0ec23e9..8074033 100644
--- a/Modules/Visualization/MonteverdiCore/src/ConfigureMonteverdi.h.in
+++ b/Modules/Visualization/MonteverdiCore/src/ConfigureMonteverdi.h.in
@@ -60,6 +60,9 @@
 			       OTB_VERSION_MINOR==(m) && OTB_VERSION_PATH>=(p))))
 
 //
+#define QWT_IS_ABOVE_6_1 ( QWT_VERSION >= 0x060100 )
+
+//
 // Sub-directories
 #define Monteverdi_INSTALL_DATA_I18N_DIR Monteverdi_INSTALL_DATA_DIR "/i18n"
 
diff --git a/Modules/Visualization/MonteverdiCore/src/mvdAbstractLayerModel.cxx b/Modules/Visualization/MonteverdiCore/src/mvdAbstractLayerModel.cxx
index 4598db5..7d59542 100644
--- a/Modules/Visualization/MonteverdiCore/src/mvdAbstractLayerModel.cxx
+++ b/Modules/Visualization/MonteverdiCore/src/mvdAbstractLayerModel.cxx
@@ -37,7 +37,7 @@
 
 //
 // OTB includes (sorted by alphabetic order)
-
+#include "otbGeoInformationConversion.h"
 //
 // Monteverdi includes (sorted by alphabetic order)
 #include "mvdAlgorithm.h"
@@ -62,6 +62,7 @@ namespace
 {
 char const * const STR_SENSOR = QT_TRANSLATE_NOOP( "mvd::AbstractLayerModel", "Sensor" );
 char const * const STR_UNKNOWN = QT_TRANSLATE_NOOP( "mvd::AbstractLayerModel", "Unknown" );
+char const * const STR_NOEPSG = QT_TRANSLATE_NOOP( "mvd::AbstractLayerModel", "No EPSG" );
 } // end of anonymous namespace.
 
 
@@ -98,16 +99,12 @@ GetSpatialReferenceType( const std::string & wkt, bool hasKwl )
 
   OGRSpatialReference ogr_sr( wkt.c_str() );
 
-  const char * epsg = ogr_sr.GetAuthorityCode( "PROJCS" );
+  if(ogr_sr.IsGeographic())
+    return SRT_GEO;
 
-  if( epsg!=NULL && strcmp( epsg, "" )!=0 )
+  if(ogr_sr.IsProjected())
     return SRT_CARTO;
 
-  epsg = ogr_sr.GetAuthorityCode( "GEOGCS" );
-
-  if( epsg!=NULL && strcmp( epsg, "" )!=0 )
-    return SRT_GEO;
-
   return SRT_UNKNOWN;
 }
 
@@ -117,7 +114,8 @@ GetSpatialReferenceType( const std::string & wkt, bool hasKwl )
 AbstractLayerModel
 ::AbstractLayerModel( QObject* p ) :
   AbstractModel( p ),
-  VisibleInterface()
+  VisibleInterface(),
+  m_Name(QString())
 {
 }
 
@@ -158,19 +156,13 @@ AbstractLayerModel
 	  ? ToStdString( tr( STR_SENSOR ) )
 	  : ToStdString( tr( STR_UNKNOWN ) ) );
 
-  OGRSpatialReference ogr_sr( wkt.c_str() );
-
-  const char * epsg = ogr_sr.GetAuthorityCode( "PROJCS" );
-
-  if( epsg!=NULL && strcmp( epsg, "" )!=0 )
-    return epsg;
-
-  epsg = ogr_sr.GetAuthorityCode( "GEOGCS" );
-
-  if( epsg==NULL || strcmp( epsg, "" )==0 )
+  int code = otb::GeoInformationConversion::ToEPSG(wkt);
+  if(code < 0)
     return ToStdString( tr( STR_UNKNOWN ) );
+  else if(code == 0)
+    return ToStdString( tr( STR_NOEPSG ) );
 
-  return epsg;
+  return boost::lexical_cast<std::string>(code);
 }
 
 /*******************************************************************************/
@@ -189,6 +181,26 @@ AbstractLayerModel
   virtual_ToWgs84( p, wgs84, alt );
 }
 
+/*****************************************************************************/
+void
+AbstractLayerModel
+::SetName(const QString & name)
+{
+  if (name != m_Name)
+    {
+    m_Name = name;
+    emit NameChanged();
+    }
+}
+
+/*****************************************************************************/
+const QString &
+AbstractLayerModel
+::GetName() const
+{
+  return m_Name;
+}
+
 /*******************************************************************************/
 bool
 AbstractLayerModel
diff --git a/Modules/Visualization/MonteverdiCore/src/mvdI18nCoreApplication.cxx b/Modules/Visualization/MonteverdiCore/src/mvdI18nCoreApplication.cxx
index e8dbd77..3031c06 100644
--- a/Modules/Visualization/MonteverdiCore/src/mvdI18nCoreApplication.cxx
+++ b/Modules/Visualization/MonteverdiCore/src/mvdI18nCoreApplication.cxx
@@ -160,7 +160,7 @@ I18nCoreApplication
 
   // get the md5 of the filename
   QByteArray result =
-    QCryptographicHash::hash( fileInfo.absoluteFilePath().toAscii(), 
+    QCryptographicHash::hash( fileInfo.absoluteFilePath().toAscii(),
 			      QCryptographicHash::Md5 );
 
   // MD5 hash-code.
@@ -606,7 +606,7 @@ I18nCoreApplication
 
   // Begin from the executable path
   QDir bin_dir( QDir::cleanPath(QCoreApplication::applicationDirPath()) );
-  
+
   // Go up in the directory hierarchy until we have a candidate install prefix
   bool prefixFound = false;
   QDir prefix( bin_dir );
@@ -618,7 +618,7 @@ I18nCoreApplication
       break;
       }
     }
-  
+
   if( !prefixFound )
     throw std::runtime_error(
       ToStdString(
@@ -647,7 +647,7 @@ I18nCoreApplication
   else
     {
     m_IsRunningFromBuildDir = false;
-    
+
     // Report found install prefix
     qDebug()
       << tr( "Running from install directory '%1'." )
diff --git a/Modules/Visualization/MonteverdiCore/src/mvdStackedLayerModel.cxx b/Modules/Visualization/MonteverdiCore/src/mvdStackedLayerModel.cxx
index 607d9bd..c4d050b 100644
--- a/Modules/Visualization/MonteverdiCore/src/mvdStackedLayerModel.cxx
+++ b/Modules/Visualization/MonteverdiCore/src/mvdStackedLayerModel.cxx
@@ -270,6 +270,15 @@ StackedLayerModel
   // Remove layer-model.
   AbstractLayerModel * layer = it->second;
 
+  // Disconnect the renaming signals
+  QObject::disconnect(
+    layer,
+    SIGNAL( NameChanged() ),
+    // from:
+    this,
+    SIGNAL( LayerRenamed() )
+  );
+
   m_LayerModels.erase( it );
 
   m_Keys.erase( m_Keys.begin() + index );
@@ -394,6 +403,15 @@ StackedLayerModel
   m_LayerModels.insert( LayerModelMap::value_type( key, model ) );
   m_Keys.insert( m_Keys.begin() + index, key );
 
+  // Connect the renaming signals
+  QObject::connect(
+    model,
+    SIGNAL( NameChanged() ),
+    // to:
+    this,
+    SIGNAL( LayerRenamed() )
+  );
+
   //
   // Update pointer to current.
   if( emitCurrentChanged )
diff --git a/Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx b/Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx
index c60019e..378763d 100644
--- a/Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx
+++ b/Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx
@@ -94,6 +94,7 @@ VectorImageModel
 ::SetFilename( const QString& filename , int w, int h)
 {
   setObjectName( filename );
+  SetName( QFileInfo( filename ).fileName() );
 
   // 1. store the input filename
   FilenameInterface::SetFilename( filename );
diff --git a/Modules/Visualization/MonteverdiGui/include/mvdHistogramPlotPicker.h b/Modules/Visualization/MonteverdiGui/include/mvdHistogramPlotPicker.h
index 6a6d797..0e58a1f 100644
--- a/Modules/Visualization/MonteverdiGui/include/mvdHistogramPlotPicker.h
+++ b/Modules/Visualization/MonteverdiGui/include/mvdHistogramPlotPicker.h
@@ -131,7 +131,7 @@ public:
 
   /**
    */
-  void SetGrayscaleActivated( bool activated );
+  void SetGrayscaleActivated( bool isGrayscale );
 
   //
   // QwtPlotPicker methods.
@@ -161,7 +161,7 @@ protected:
 
   using QwtPlotPicker::trackerText;
 
-  QwtText trackerText( const QwtDoublePoint & ) const ITK_OVERRIDE;
+  QwtText trackerTextF( const QPointF & ) const ITK_OVERRIDE;
 
 //
 // Protected attributes.
diff --git a/Modules/Visualization/MonteverdiGui/include/mvdHistogramWidget.h b/Modules/Visualization/MonteverdiGui/include/mvdHistogramWidget.h
index 4879293..cbda62b 100644
--- a/Modules/Visualization/MonteverdiGui/include/mvdHistogramWidget.h
+++ b/Modules/Visualization/MonteverdiGui/include/mvdHistogramWidget.h
@@ -37,8 +37,6 @@
 
 //
 // Qwt includes.
-#include <qwt_double_rect.h>
-#include <qwt_polygon.h>
 
 //
 // System includes (sorted by alphabetic order)
@@ -328,18 +326,18 @@ private slots:
 
   /**
    */
-  void OnAppended( const QwtDoublePoint& pos );
-  void OnAppended( const QPoint& pos );
+  void OnAppended( const QPointF & );
+  void OnAppended( const QPoint & );
 
-  void OnChanged( const QwtPolygon& pa );
+  void OnChanged( const QPolygon & );
 
-  void OnMoved( const QwtDoublePoint&pos );
-  void OnMoved( const QPoint& pos );
+  void OnMoved( const QPointF & );
+  void OnMoved( const QPoint & );
 
-  void OnSelected( const QwtDoublePoint& pos );
-  void OnSelected( const QwtDoubleRect& rect );
-  void OnSelected( const QwtPolygon& pa );
-  void OnSelected( const QwtArray< QwtDoublePoint >& pa );
+  void OnSelected( const QPointF & );
+  void OnSelected( const QRectF & );
+  void OnSelected( const QPolygon & );
+  void OnSelected( const QVector< QPointF > & );
 };
 
 } // end namespace 'mvd'
diff --git a/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h b/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h
index 4d92b37..61d425e 100644
--- a/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h
+++ b/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetParameterInitializers.h
@@ -59,6 +59,8 @@
 #include "otbWrapperQtWidgetOutputImageParameter.h"
 #include "otbWrapperQtWidgetOutputProcessXMLParameter.h"
 #include "otbWrapperQtWidgetOutputVectorDataParameter.h"
+#include "otbWrapperQtWidgetComplexInputImageParameter.h"
+#include "otbWrapperQtWidgetComplexOutputImageParameter.h"
 #include "otbWrapperQtWidgetParameterFactory.h"
 #endif //tag=QT4-boost-compatibility
 
@@ -176,6 +178,23 @@ private:
 };
 
 /**
+ * \class ComplexInputImageInitializer
+ *
+ * \ingroup OTBMonteverdiGUI
+ *
+ * \brief WIP.
+ */
+class ComplexInputImageInitializer : public std::unary_function<
+  otb::Wrapper::QtWidgetComplexInputImageParameter*,
+  void
+  >
+{
+public:
+  inline ComplexInputImageInitializer();
+  inline result_type operator () ( argument_type widget ) const;
+};
+
+/**
  * \class InputVectorDataInitializer
  *
  * \ingroup OTBMonteverdiGUI
@@ -282,6 +301,26 @@ private:
 };
 
 /**
+ * \class ComplexOutputImageInitializer
+ *
+ * \ingroup OTBMonteverdiGUI
+ *
+ * \brief WIP.
+ */
+class ComplexOutputImageInitializer : public std::unary_function<
+  otb::Wrapper::QtWidgetComplexOutputImageParameter*,
+  void
+  >
+{
+public:
+  inline ComplexOutputImageInitializer( const QString & prefix );
+  inline result_type operator () ( argument_type widget ) const;
+
+private:
+  QString m_Prefix;
+};
+
+/**
  * \class OutputVectorDataInitializer
  *
  * \ingroup OTBMonteverdiGUI
@@ -443,6 +482,24 @@ InputImageListInitializer
 
 /*****************************************************************************/
 inline
+ComplexInputImageInitializer
+::ComplexInputImageInitializer()
+{
+}
+
+/*****************************************************************************/
+inline
+ComplexInputImageInitializer::result_type
+ComplexInputImageInitializer
+::operator () ( argument_type widget ) const
+{
+  assert( widget!=NULL );
+
+  SetupForFilenameDrop( widget, "You can drop filename here." );
+}
+
+/*****************************************************************************/
+inline
 InputFilenameInitializer::result_type
 InputFilenameInitializer
 ::operator () ( argument_type widget ) const
@@ -578,6 +635,41 @@ OutputImageInitializer
 
 /*****************************************************************************/
 inline
+ComplexOutputImageInitializer
+::ComplexOutputImageInitializer( const QString& prefix) :
+  m_Prefix( prefix )
+{
+}
+
+/*****************************************************************************/
+inline
+ComplexOutputImageInitializer::result_type
+ComplexOutputImageInitializer
+::operator () ( argument_type widget ) const
+{
+  assert( widget!=NULL );
+  assert( I18nCoreApplication::ConstInstance()!=NULL );
+
+  if( m_Prefix.isEmpty() )
+    {
+    SetupForFilenameDrop( widget, "You can drop filename here." );
+
+    assert( qApp!=NULL );
+    assert( !qApp->arguments().empty() );
+
+    SetupOutputFilename( widget );
+    }
+  else
+    SetupOutputFilename(
+      widget,
+      I18nCoreApplication::ConstInstance()->GetResultsDir(),
+      m_Prefix,
+      ".tif"
+    );
+}
+
+/*****************************************************************************/
+inline
 OutputVectorDataInitializer::result_type
 OutputVectorDataInitializer
 ::operator () ( argument_type widget ) const
@@ -671,13 +763,29 @@ SetupForFilenameDrop( W* widget, const char* text )
 
   lineEdit->installEventFilter( eventFilter );
 
-  QObject::connect(
-    eventFilter,
-    SIGNAL( FilenameDropped( const QString& ) ),
-    // to:
-    lineEdit,
-    SLOT( setText( const QString& ) )
-  );
+  // BUG : temporary fix for drag & drop in InputImageParameter
+  // in the future, all "filename" parameters should have the same behaviour
+  if (dynamic_cast<otb::Wrapper::QtWidgetInputImageParameter*>(widget) ||
+      dynamic_cast<otb::Wrapper::QtFileSelectionWidget*>(widget))
+    {
+    QObject::connect(
+      eventFilter,
+      SIGNAL( FilenameDropped( const QString& ) ),
+      // to:
+      widget,
+      SLOT( SetFileName( const QString& ) )
+    );
+    }
+  else
+    {
+    QObject::connect(
+      eventFilter,
+      SIGNAL( FilenameDropped( const QString& ) ),
+      // to:
+      lineEdit,
+      SLOT( setText( const QString& ) )
+    );
+    }
 }
 
 /*****************************************************************************/
diff --git a/Modules/Visualization/MonteverdiGui/src/mvdAboutDialog.ui b/Modules/Visualization/MonteverdiGui/src/mvdAboutDialog.ui
index 5d20ab4..527e2a4 100644
--- a/Modules/Visualization/MonteverdiGui/src/mvdAboutDialog.ui
+++ b/Modules/Visualization/MonteverdiGui/src/mvdAboutDialog.ui
@@ -98,7 +98,7 @@
         <enum>QFrame::NoFrame</enum>
        </property>
        <property name="text">
-         <string><p>Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)</p><p>Monteverdi is part of Orfeo Toolbox</p><a href="https://www.orfeo-toolbox.org/">https://www.orfeo-toolbox.org/</a><p>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</p><a href="http://www.apache.org/licenses/LICENSE-2.0"&g [...]
+         <string><html><head/><body><p>Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)</p><p>Monteverdi is part of Orfeo Toolbox</p><p><a href="https://www.orfeo-toolbox.org/"><span style=" text-decoration: underline; color:#0000ff;">https://www.orfeo-toolbox.org/</span></a></p><p>Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); you ma [...]
        </property>
       </widget>
      </item>
diff --git a/Modules/Visualization/MonteverdiGui/src/mvdHistogramPlotPicker.cxx b/Modules/Visualization/MonteverdiGui/src/mvdHistogramPlotPicker.cxx
index cfe4329..a7f9e30 100644
--- a/Modules/Visualization/MonteverdiGui/src/mvdHistogramPlotPicker.cxx
+++ b/Modules/Visualization/MonteverdiGui/src/mvdHistogramPlotPicker.cxx
@@ -30,12 +30,26 @@
 
 //
 // Qwt includes.
+
+#if defined(__GNUC__) || defined(__clang__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wunused-parameter"
+# pragma GCC diagnostic ignored "-Wshadow"
+#endif
+
 #include <qwt_plot_curve.h>
-#include <qwt_data.h>
 #include <qwt_painter.h>
+#include <qwt_picker_machine.h>
 #include <qwt_plot.h>
+#if QWT_IS_ABOVE_6_1
+#  include <qwt_plot_canvas.h>
+#endif // QWT_ABOVE_6_1
 #include <qwt_text.h>
 
+#if defined(__GNUC__) || defined(__clang__)
+# pragma GCC diagnostic pop
+#endif
+
 //
 // System includes (sorted by alphabetic order)
 #include <cassert>
@@ -83,7 +97,8 @@ HistogramPlotPicker
 {
   assert( m_PlotCurves.size()==HistogramPlotPicker::CURVE_COUNT );
 
-  setSelectionFlags( QwtPicker::PointSelection );
+  setStateMachine( new QwtPickerDragPointMachine() );
+
   setRubberBand( QwtPicker::UserRubberBand );
 }
 
@@ -101,7 +116,8 @@ HistogramPlotPicker
 {
   assert( m_PlotCurves.size()==HistogramPlotPicker::CURVE_COUNT );
 
-  setSelectionFlags( QwtPicker::PointSelection );
+  setStateMachine( new QwtPickerDragPointMachine() );
+
   setRubberBand( QwtPicker::UserRubberBand );
 }
 
@@ -115,7 +131,6 @@ HistogramPlotPicker
   QwtPlotPicker(
     xA,
     yA,
-    QwtPicker::PointSelection,
     QwtPicker::UserRubberBand,
     tracker,
     can ),
@@ -124,6 +139,8 @@ HistogramPlotPicker
   m_IsGrayscaleActivated( false )
 {
   assert( m_PlotCurves.size()==HistogramPlotPicker::CURVE_COUNT );
+
+  setStateMachine( new QwtPickerDragPointMachine() );
 }
 
 /*******************************************************************************/
@@ -152,9 +169,9 @@ HistogramPlotPicker
 /*******************************************************************************/
 void
 HistogramPlotPicker
-::SetGrayscaleActivated( bool activated )
+::SetGrayscaleActivated( bool isGrayscale )
 {
-  m_IsGrayscaleActivated = activated;
+  m_IsGrayscaleActivated = isGrayscale;
 }
 
 /*******************************************************************************/
@@ -175,15 +192,24 @@ HistogramPlotPicker
       rubberBandPen().style()==Qt::NoPen )
     return;
 
-  const QwtPolygon& pa = selection();
+  const QPolygon & pa = selection();
 
   if( rubberBand()==QwtPicker::UserRubberBand &&
-      ( selectionFlags() & PointSelection ) &&
+      // ( selectionType()==QwtPicker::PointSelection ) &&
       selection().count() >= 1 )
     {
-    const QRect& rect = pickRect();
+#if QWT_IS_ABOVE_6_1
+    assert( parentWidget()!=nullptr );
+
+    const QRect & rect = parentWidget()->contentsRect();
+
+#else // QWT_IS_ABOVE_6_1
+    const QRect & rect = pickRect();
+
+#endif //QWT_IS_ABOVE_6_1
+
     const QPoint& pos = pa[ 0 ];
-   
+
     QwtPainter::drawLine(
       painter,
       pos.x(), rect.bottom(),
@@ -196,7 +222,7 @@ HistogramPlotPicker
     if( !RgbwBounds( start, stop, RGBW_CHANNEL_ALL ) )
       return;
 
-    QwtDoublePoint p( invTransform( pos ) );
+    QPointF p( invTransform( pos ) );
 
     for( CountType i=start; i<stop; ++i )
       if( m_PlotCurves[ i ]->isVisible() )
@@ -225,10 +251,10 @@ HistogramPlotPicker
 /*******************************************************************************/
 QwtText
 HistogramPlotPicker
-::trackerText( const QwtDoublePoint& point ) const
+::trackerTextF( const QPointF & point ) const
 {
   if( rubberBand()!=QwtPicker::UserRubberBand )
-    return QwtPlotPicker::trackerText( point );
+    return QwtPlotPicker::trackerTextF( point );
 
   if( !isActive() )
     return QwtText(
@@ -270,7 +296,11 @@ double
 HistogramPlotPicker
 ::Find( const QwtPlotCurve* curve, double x ) const
 {
-  const QwtData& data = curve->data();
+  typedef QwtSeriesData< QPointF > SeriesData;
+
+  const SeriesData * data = curve->data();
+
+  assert( data!=nullptr );
 
 /*
 #if HISTOGRAM_CURVE_TYPE==0
@@ -282,42 +312,52 @@ HistogramPlotPicker
 #elif HISTOGRAM_CURVE_TYPE==2
 */
 
-  assert( data.size() % 4 == 0 );
+  assert( data->size() % 4 == 0 );
 
   CountType steps = 0;
 
-  if( data.size()==0 )
+  if( data->size()==0 )
     return -1.0;
 
   CountType i0 = 0;
-  CountType i1 = data.size() / 4 - 1;
+  CountType i1 = data->size() / 4 - 1;
 
-  // assert( x>=data.x( 4 * i0 ) && x<=data.x( 4 * i1 + 3 ) );
-  if( x<data.x( 4 * i0 ) || x>data.x( 4 * i1 + 3 ) )
+  // assert( x>=data->sample( 4 * i0 ).x() && x<=data->sample( 4 * i1 + 3 ).x() );
+  if( x<data->sample( 4 * i0 ).x() ||
+      x>data->sample( 4 * i1 + 3 ).x() )
     return -1.0;
 
   while( i0!=i1 )
     {
-    assert( data.x( 4 * i0 )==data.x( 4 * i0 + 1 ) );
-    assert( data.x( 4 * i0 + 2 )==data.x( 4 * i0 + 3 ) );
-    assert( data.y( 4 * i0 + 1 )==data.y( 4 * i0 + 2 ) );
-    assert( data.y( 4 * i0 )==data.y( 4 * i0 + 3 ) );
+    assert( data->sample( 4 * i0 ).x()==data->sample( 4 * i0 + 1 ).x() );
+    assert( data->sample( 4 * i0 + 2 ).x()==data->sample( 4 * i0 + 3 ).x() );
+    assert( data->sample( 4 * i0 + 1 ).y()==data->sample( 4 * i0 + 2 ).y() );
+    assert( data->sample( 4 * i0 ).y()==data->sample( 4 * i0 + 3 ).y() );
 
-    assert( data.x( 4 * i1 )==data.x( 4 * i1 + 1 ) );
-    assert( data.x( 4 * i1 + 2 )==data.x( 4 * i1 + 3 ) );
-    assert( data.y( 4 * i1 + 1 )==data.y( 4 * i1 + 2 ) );
-    assert( data.y( 4 * i1 )==data.y( 4 * i1 + 3 ) );
+    assert( data->sample( 4 * i1 ).x()==data->sample( 4 * i1 + 1 ).x() );
+    assert( data->sample( 4 * i1 + 2 ).x()==data->sample( 4 * i1 + 3 ).x() );
+    assert( data->sample( 4 * i1 + 1 ).y()==data->sample( 4 * i1 + 2 ).y() );
+    assert( data->sample( 4 * i1 ).y()==data->sample( 4 * i1 + 3 ).y() );
 
     CountType i = (i0 + i1 + 1) / 2;
 
 #if 0
     qDebug()
-      << i0 << " (" << data.x( 4*i0 ) << ", " << data.x( 4*i0+2 ) << ") "
-      << i << " (" << data.x( 4*i ) << ", " << data.x( 4*i+2 ) << ") "
-      << i1 << " (" << data.x( 4*i1 ) << ", " << data.x( 4*i1+2 ) << ")";
+      << i0
+      << " (" << data->sample( 4*i0 ).x()
+      << ", " << data->sample( 4*i0+2 ).x()
+      << ") "
+      << i
+      << " (" << data->sample( 4*i ).x()
+      << ", " << data->sample( 4*i+2 ).x()
+      << ") "
+      << i1
+      << " (" << data->sample( 4*i1 ).x()
+      << ", " << data->sample( 4*i1+2 ).x()
+      << ")";
 #endif
 
-    if( x<data.x( 4 * i ) )
+    if( x<data->sample( 4 * i ).x() )
       i1 = i - 1;
     else
       i0 = i;
@@ -325,17 +365,17 @@ HistogramPlotPicker
     ++ steps;
     }
 
-  assert( x>=data.x( 4 * i0 ) && x<=data.x( 4 * i0 + 2 ) );
-  assert( x>=data.x( 4 * i0 + 1 ) && x<=data.x( 4 * i0 + 3 ) );
+  assert( x>=data->sample( 4 * i0 ).x() && x<=data->sample( 4 * i0 + 2 ).x() );
+  assert( x>=data->sample( 4 * i0 + 1 ).x() && x<=data->sample( 4 * i0 + 3 ).x() );
 
 #if 0
   qDebug()
     << steps << ":"
-    << x << "in [" << data.x( 4 * i0 ) << "; " << data.x( 4 * i0 + 2 ) << "] ->"
-    << data.y( 4 * i0 + 1 );
+    << x << "in [" << data->sample( 4 * i0 ).x() << "; " << data->sample( 4 * i0 + 2 ).x() << "] ->"
+    << data->sample( 4 * i0 + 1 ).y();
 #endif
 
-  return data.y( 4 * i0 + 1 );
+  return data->sample( 4 * i0 + 1 ).y();
 
 /*
 #else
@@ -354,7 +394,11 @@ HistogramPlotPicker
 	double& xmax,
 	double& y ) const
 {
-  const QwtData& data = curve->data();
+  typedef QwtSeriesData< QPointF > SeriesData;
+
+  const SeriesData * data = curve->data();
+
+  assert( data!=nullptr );
 
 /*
 #if HISTOGRAM_CURVE_TYPE==0
@@ -366,41 +410,51 @@ HistogramPlotPicker
 #elif HISTOGRAM_CURVE_TYPE==2
 */
 
-  assert( data.size() % 4 == 0 );
+  assert( data->size() % 4 == 0 );
 
   CountType steps = 0;
 
-  if( data.size()==0 )
+  if( data->size()==0 )
     return 0;
 
   CountType i0 = 0;
-  CountType i1 = data.size() / 4 - 1;
+  CountType i1 = data->size() / 4 - 1;
 
-  if( x<data.x( 4 * i0 ) || x>data.x( 4 * i1 + 3 ) )
+  if( x<data->sample( 4 * i0 ).x() ||
+      x>data->sample( 4 * i1 + 3 ).x() )
     return 0;
 
   while( i0!=i1 )
     {
-    assert( data.x( 4 * i0 )==data.x( 4 * i0 + 1 ) );
-    assert( data.x( 4 * i0 + 2 )==data.x( 4 * i0 + 3 ) );
-    assert( data.y( 4 * i0 + 1 )==data.y( 4 * i0 + 2 ) );
-    assert( data.y( 4 * i0 )==data.y( 4 * i0 + 3 ) );
+    assert( data->sample( 4 * i0 ).x()==data->sample( 4 * i0 + 1 ).x() );
+    assert( data->sample( 4 * i0 + 2 ).x()==data->sample( 4 * i0 + 3 ).x() );
+    assert( data->sample( 4 * i0 + 1 ).y()==data->sample( 4 * i0 + 2 ).y() );
+    assert( data->sample( 4 * i0 ).y()==data->sample( 4 * i0 + 3 ).y() );
 
-    assert( data.x( 4 * i1 )==data.x( 4 * i1 + 1 ) );
-    assert( data.x( 4 * i1 + 2 )==data.x( 4 * i1 + 3 ) );
-    assert( data.y( 4 * i1 + 1 )==data.y( 4 * i1 + 2 ) );
-    assert( data.y( 4 * i1 )==data.y( 4 * i1 + 3 ) );
+    assert( data->sample( 4 * i1 ).x()==data->sample( 4 * i1 + 1 ).x() );
+    assert( data->sample( 4 * i1 + 2 ).x()==data->sample( 4 * i1 + 3 ).x() );
+    assert( data->sample( 4 * i1 + 1 ).y()==data->sample( 4 * i1 + 2 ).y() );
+    assert( data->sample( 4 * i1 ).y()==data->sample( 4 * i1 + 3 ).y() );
 
     CountType i = (i0 + i1 + 1) / 2;
 
 #if 0
     qDebug()
-      << i0 << " (" << data.x( 4*i0 ) << ", " << data.x( 4*i0+2 ) << ") "
-      << i << " (" << data.x( 4*i ) << ", " << data.x( 4*i+2 ) << ") "
-      << i1 << " (" << data.x( 4*i1 ) << ", " << data.x( 4*i1+2 ) << ")";
+      << i0
+      << " (" << data->sample( 4*i0 ).x()
+      << ", " << data->sample( 4*i0+2 ).x()
+      << ") "
+      << i
+      << " (" << data->sample( 4*i ).x()
+      << ", " << data->sample( 4*i+2 ).x()
+      << ") "
+      << i1
+      << " (" << data->sample( 4*i1 ).x()
+      << ", " << data->sample( 4*i1+2 ).x()
+      << ")";
 #endif
 
-    if( x<data.x( 4 * i ) )
+    if( x<data->sample( 4 * i ).x() )
       i1 = i - 1;
     else
       i0 = i;
@@ -408,19 +462,19 @@ HistogramPlotPicker
     ++ steps;
     }
 
-  assert( x>=data.x( 4 * i0 ) && x<=data.x( 4 * i0 + 2 ) );
-  assert( x>=data.x( 4 * i0 + 1 ) && x<=data.x( 4 * i0 + 3 ) );
+  assert( x>=data->sample( 4 * i0 ).x() && x<=data->sample( 4 * i0 + 2 ).x() );
+  assert( x>=data->sample( 4 * i0 + 1 ).x() && x<=data->sample( 4 * i0 + 3 ).x() );
 
 #if 0
   qDebug()
     << steps << ":"
-    << x << "in [" << data.x( 4 * i0 ) << "; " << data.x( 4 * i0 + 2 ) << "] ->"
-    << data.y( 4 * i0 + 1 );
+    << x << "in [" << data->sample( 4 * i0 ).x() << "; " << data->sample( 4 * i0 + 2 ).x() << "] ->"
+    << data->sample( 4 * i0 + 1 ).y();
 #endif
 
-  xmin = data.x( 4 * i0 );
-  xmax = data.x( 4 * i0 + 2 );
-  y = data.y( 4 * i0 + 1 );
+  xmin = data->sample( 4 * i0 ).x();
+  xmax = data->sample( 4 * i0 + 2 ).x();
+  y = data->sample( 4 * i0 + 1 ).y();
 
   return steps;
 
diff --git a/Modules/Visualization/MonteverdiGui/src/mvdHistogramWidget.cxx b/Modules/Visualization/MonteverdiGui/src/mvdHistogramWidget.cxx
index fbb8e3f..7caa68b 100644
--- a/Modules/Visualization/MonteverdiGui/src/mvdHistogramWidget.cxx
+++ b/Modules/Visualization/MonteverdiGui/src/mvdHistogramWidget.cxx
@@ -19,8 +19,19 @@
  */
 
 #include "mvdHistogramWidget.h"
+
+#if defined(__GNUC__) || defined(__clang__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wunused-parameter"
+# pragma GCC diagnostic ignored "-Wshadow"
+#endif
+
 #include "ui_mvdHistogramWidget.h"
 
+#if defined(__GNUC__) || defined(__clang__)
+# pragma GCC diagnostic pop
+#endif
+
 
 /*****************************************************************************/
 /* INCLUDE SECTION                                                           */
@@ -33,18 +44,14 @@
 // Qwt includes
 
 #if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#pragma GCC diagnostic ignored "-Wshadow"
-#include <qwt_plot_curve.h>
-#include <qwt_plot_grid.h>
-#include <qwt_plot_magnifier.h>
-#include <qwt_plot_marker.h>
-#include <qwt_plot_panner.h>
-// #include <qwt_plot_zoomer.h>
-#include <qwt_scale_engine.h>
-#pragma GCC diagnostic pop
-#else
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wunused-parameter"
+# pragma GCC diagnostic ignored "-Wshadow"
+#endif
+
+#if QWT_IS_ABOVE_6_1
+# include <qwt_plot_canvas.h>
+#endif // QWT_IS_ABOVE_6_1
 #include <qwt_plot_curve.h>
 #include <qwt_plot_grid.h>
 #include <qwt_plot_magnifier.h>
@@ -52,7 +59,11 @@
 #include <qwt_plot_panner.h>
 // #include <qwt_plot_zoomer.h>
 #include <qwt_scale_engine.h>
+
+#if defined(__GNUC__) || defined(__clang__)
+# pragma GCC diagnostic pop
 #endif
+
 //
 // System includes (sorted by alphabetic order)
 
@@ -94,7 +105,7 @@ HistogramWidget::CURVE_NAMES[ HistogramWidget::CURVE_COUNT ] =
   QT_TRANSLATE_NOOP( "mvd::HistogramWidget", "Red" ),
   QT_TRANSLATE_NOOP( "mvd::HistogramWidget", "Green" ),
   QT_TRANSLATE_NOOP( "mvd::HistogramWidget", "Blue" ),
-  QT_TRANSLATE_NOOP( "mvd::HistogramWidget", "Gray" ), 
+  QT_TRANSLATE_NOOP( "mvd::HistogramWidget", "Gray" ),
 };
 
 const QColor
@@ -151,7 +162,7 @@ const QColor RUBBER_BAND_COLOR( 0xFF, 0xFF, 0x00, 0xAA );
 
 /*******************************************************************************/
 HistogramWidget
-::HistogramWidget( QWidget* p, Qt::WindowFlags flags  ):
+::HistogramWidget( QWidget* p, Qt::WindowFlags flags  ) :
   QWidget( p, flags ),
   m_UI( new mvd::Ui::HistogramWidget() ),
   m_PlotGrid( NULL ),
@@ -177,8 +188,14 @@ HistogramWidget
   m_PlotGrid = new QwtPlotGrid();
   m_PlotGrid->attach( m_UI->histogramPlot );
 
+#if QWT_IS_ABOVE_6_1
+  m_PlotGrid->setMajorPen( GRID_MAJ_PEN_COLOR );
+  m_PlotGrid->setMinorPen( GRID_MIN_PEN_COLOR );
+
+#else // QWT_IS_ABOVE_6_1
   m_PlotGrid->setMajPen( GRID_MAJ_PEN_COLOR );
   m_PlotGrid->setMinPen( GRID_MIN_PEN_COLOR );
+#endif // QWT_IS_ABOVE_6_1
 
   //
   // ZOOMER.
@@ -252,9 +269,22 @@ HistogramWidget
 
   //
   // PICKER.
+  assert(
+    dynamic_cast< QwtPlotCanvas * >( m_UI->histogramPlot->canvas() )!=nullptr
+  );
 
   m_PlotPicker =
-    new HistogramPlotPicker( curves, m_UI->histogramPlot->canvas() );
+    new HistogramPlotPicker(
+      curves,
+#if QWT_IS_ABOVE_6_1
+      dynamic_cast< QwtPlotCanvas * >(
+#endif // QWT_IS_ABOVE_6_1
+	m_UI->histogramPlot->canvas()
+#if QWT_IS_ABOVE_6_1
+        )
+#endif // QWT_IS_ABOVE_6_1
+      );
+
   m_PlotPicker->setTrackerMode( QwtPicker::ActiveOnly );
   m_PlotPicker->setRubberBandPen( RUBBER_BAND_COLOR );
   m_PlotPicker->setTrackerPen( QColor( Qt::yellow ) );
@@ -273,8 +303,8 @@ HistogramWidget
   //
   //
   QObject::connect(
-    m_PlotPicker, SIGNAL( appended( const QwtDoublePoint& ) ),
-    this, SLOT( OnAppended( const QwtDoublePoint& ) )
+    m_PlotPicker, SIGNAL( appended( const QPointF& ) ),
+    this, SLOT( OnAppended( const QPointF& ) )
   );
   QObject::connect(
     m_PlotPicker, SIGNAL( appended( const QPoint& ) ),
@@ -282,25 +312,25 @@ HistogramWidget
   );
   //
   QObject::connect(
-    m_PlotPicker, SIGNAL( changed( const QwtPolygon& ) ),
-    this, SLOT( OnChanged( const QwtPolygon& ) )
+    m_PlotPicker, SIGNAL( changed( const QPolygon& ) ),
+    this, SLOT( OnChanged( const QPolygon& ) )
   );
   //
   QObject::connect(
-    m_PlotPicker, SIGNAL( selected( const QwtDoublePoint& ) ),
-    this, SLOT( OnSelected( const QwtDoublePoint& ) )
+    m_PlotPicker, SIGNAL( selected( const QPointF& ) ),
+    this, SLOT( OnSelected( const QPointF& ) )
   );
   QObject::connect(
-    m_PlotPicker, SIGNAL( selected( const QwtDoubleRect& ) ),
-    this, SLOT( OnSelected( const QwtDoubleRect& ) )
+    m_PlotPicker, SIGNAL( selected( const QRectF& ) ),
+    this, SLOT( OnSelected( const QRectF& ) )
   );
   QObject::connect(
-    m_PlotPicker, SIGNAL( selected( const QwtPolygon& ) ),
-    this, SLOT( OnSelected( const QwtPolygon& ) )
+    m_PlotPicker, SIGNAL( selected( const QPolygon& ) ),
+    this, SLOT( OnSelected( const QPolygon& ) )
   );
   QObject::connect(
-    m_PlotPicker, SIGNAL( selected( const QwtArray< QwtDoublePoint >& ) ),
-    this, SLOT( OnSelected( const QwtArray< QwtDoublePoint >& ) )
+    m_PlotPicker, SIGNAL( selected( const QVector< QPointF >& ) ),
+    this, SLOT( OnSelected( const QVector< QPointF >& ) )
   );
 }
 
@@ -404,7 +434,7 @@ HistogramWidget
     assert( i<HistogramWidget::CURVE_COUNT );
     assert( m_PlotCurves[ i ]!=NULL );
 
-    m_PlotCurves[ i ]->setData( xVal, yVal, sizeVal );
+    m_PlotCurves[ i ]->setSamples( xVal, yVal, sizeVal );
 
     if( xVal==NULL && yVal==NULL )
       m_PlotCurves[ i ]->setVisible( false );
@@ -486,7 +516,7 @@ HistogramWidget
   /*
   for( CountType i=0; i<HistogramWidget::CURVE_COUNT; ++i )
     {
-    bool isVisible = 
+    bool isVisible =
       i<RGBW_CHANNEL_WHITE
       ? !activated
       : activated;
@@ -555,7 +585,7 @@ HistogramWidget
       ? i==RGBW_CHANNEL_WHITE
       : ( index==RGBW_CHANNEL_WHITE
 	  ? i<RGBW_CHANNEL_WHITE
-	  : i==index ); 
+	  : i==index );
 
     assert( i<HistogramWidget::CURVE_COUNT );
 
@@ -700,9 +730,9 @@ HistogramWidget
 /*******************************************************************************/
 void
 HistogramWidget
-::OnAppended( const QwtDoublePoint & )
+::OnAppended( const QPointF & )
 {
-  // qDebug() << this << "::OnAppended(" << pos.x() << ", " << pos.y() << ")";
+  // qDebug() << this << "::OnAppended(" << p << ")";
 }
 
 /*******************************************************************************/
@@ -710,23 +740,23 @@ void
 HistogramWidget
 ::OnAppended( const QPoint & )
 {
-  // qDebug() << this << "::OnAppended(" << pos << ")";
+  // qDebug() << this << "::OnAppended(" << p << ")";
 }
 
 /*******************************************************************************/
 void
 HistogramWidget
-::OnChanged( const QwtPolygon & )
+::OnChanged( const QPolygon & )
 {
-  // qDebug() << this << "::OnChanged(" << pa << ")";
+  // qDebug() << this << "::OnChanged(" << p << ")";
 }
 
 /*******************************************************************************/
 void
 HistogramWidget
-::OnMoved( const QwtDoublePoint & )
+::OnMoved( const QPointF & )
 {
-  // qDebug() << this << "::OnMoved(" << pos.x() << ", " << pos.y() << ")";
+  // qDebug() << this << "::OnMoved(" << p << ")";
 }
 
 /*******************************************************************************/
@@ -734,39 +764,39 @@ void
 HistogramWidget
 ::OnMoved( const QPoint & )
 {
-  // qDebug() << this << "::OnMoved(" << pos << ")";
+  // qDebug() << this << "::OnMoved(" << p << ")";
 }
 
 /*******************************************************************************/
 void
 HistogramWidget
-::OnSelected( const QwtDoublePoint & )
+::OnSelected( const QPointF & )
 {
-  // qDebug() << this << "::OnSelected(" << pos.x() << ", " << pos.y() << ")";
+  // qDebug() << this << "::OnSelected(" << p << ")";
 }
 
 /*******************************************************************************/
 void
 HistogramWidget
-::OnSelected( const QwtDoubleRect & )
+::OnSelected( const QRectF & )
 {
-  // qDebug() << this << "::OnSelected(" << rect.x() << ", " << rect.y() << ")";
+  // qDebug() << this << "::OnSelected(" << r << ")";
 }
 
 /*******************************************************************************/
 void
 HistogramWidget
-::OnSelected( const QwtPolygon & )
+::OnSelected( const QPolygon & )
 {
-  // qDebug() << this << "::OnSelected(" << pa << ")";
+  // qDebug() << this << "::OnSelected(" << p << ")";
 }
 
 /*******************************************************************************/
 void
 HistogramWidget
-::OnSelected( const QwtArray< QwtDoublePoint > & )
+::OnSelected( const QVector< QPointF > & )
 {
-  // qDebug() << this << "::OnSelected(" << pa << ")";
+  // qDebug() << this << "::OnSelected(" << v << ")";
 }
 
 } // end namespace 'mvd'
diff --git a/Modules/Visualization/MonteverdiGui/src/mvdLayerStackItemModel.cxx b/Modules/Visualization/MonteverdiGui/src/mvdLayerStackItemModel.cxx
index e6c7a54..cc073ec 100644
--- a/Modules/Visualization/MonteverdiGui/src/mvdLayerStackItemModel.cxx
+++ b/Modules/Visualization/MonteverdiGui/src/mvdLayerStackItemModel.cxx
@@ -423,6 +423,7 @@ LayerStackItemModel
         }
       break;
 
+    case Qt::EditRole:
     case Qt::DisplayRole:
       switch( idx.column() )
         {
@@ -447,21 +448,7 @@ LayerStackItemModel
 	break;
 
         case COLUMN_NAME:
-          if( layer->inherits(
-                VectorImageModel::staticMetaObject.className() ) )
-            {
-            const VectorImageModel * vectorImageModel =
-              qobject_cast< const VectorImageModel * >( layer );
-            assert( vectorImageModel!=NULL );
-
-            // qDebug() << "filename:" << vectorImageModel->GetFilename();
-
-            return QFileInfo( vectorImageModel->GetFilename() ).fileName();
-            }
-          else
-            {
-            qDebug() << "Unhandled AbstractLayerModel subclass.";
-            }
+          return layer->GetName();
           break;
 
 	case COLUMN_EFFECT:
@@ -842,7 +829,7 @@ LayerStackItemModel
   // qDebug()
   //   << this << "::setData(" << idx << "," << value << "," << role << ")";
 
-  if( idx.column()==COLUMN_NAME && role==Qt::CheckStateRole )
+  if( idx.column()==COLUMN_NAME )
     {
     // qDebug() << idx.row() << "check-state:" << value;
 
@@ -856,30 +843,45 @@ LayerStackItemModel
 
     assert( layer!=NULL );
     assert( layer==dynamic_cast< VisibleInterface * >( layer ) );
-
     VisibleInterface * interface = dynamic_cast< VisibleInterface * >( layer );
     assert( interface!=NULL );
 
-    switch( value.toInt() )
+    switch( role )
       {
-      case Qt::Checked:
-        interface->SetVisible( true );
+      case Qt::EditRole:
+        {
+        QString strValue = value.toString();
+        if( !strValue.isEmpty() )
+          {
+          layer->SetName( strValue );
+          emit dataChanged( idx, idx );
+          return true;
+          }
+        }
         break;
-
-      case Qt::Unchecked:
-        interface->SetVisible( false );
+      case Qt::CheckStateRole:
+        switch( value.toInt() )
+          {
+          case Qt::Checked:
+            interface->SetVisible( true );
+            break;
+
+          case Qt::Unchecked:
+            interface->SetVisible( false );
+            break;
+
+          default:
+            assert( false && "Unhandled Qt::CheckedState value." );
+            break;
+          }
+        emit dataChanged( idx, idx );
+        return true;
         break;
 
       default:
-        assert( false && "Unhandled Qt::CheckedState value." );
         break;
       }
-
-    emit dataChanged( idx, idx );
-
-    return true;
     }
-
   return false;
 }
 
diff --git a/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx b/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx
index 12640d6..ff6d14e 100644
--- a/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx
+++ b/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx
@@ -348,6 +348,7 @@ QtWidgetView
   SetupWidget( widget, InputFilenameListInitializer( this ) );
   SetupWidget( widget, InputImageInitializer() );
   SetupWidget( widget, InputImageListInitializer( this ) );
+  SetupWidget( widget, ComplexInputImageInitializer() );
   SetupWidget( widget, InputProcessXMLInitializer() );
   SetupWidget( widget, InputVectorDataInitializer() );
   SetupWidget( widget, InputVectorDataListInitializer( this ) );
@@ -362,6 +363,10 @@ QtWidgetView
     widget,
     OutputImageInitializer( m_Application->GetName() )
   );
+  SetupWidget(
+    widget,
+    ComplexOutputImageInitializer( m_Application->GetName() )
+  );
 
   SetupWidget( widget, OutputVectorDataInitializer() );
 }
diff --git a/Modules/Wrappers/ApplicationEngine/include/otbLogger.h b/Modules/Wrappers/ApplicationEngine/include/otbLogger.h
new file mode 100644
index 0000000..ba43072
--- /dev/null
+++ b/Modules/Wrappers/ApplicationEngine/include/otbLogger.h
@@ -0,0 +1,57 @@
+/*
+ * 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 otbLogger_h
+#define otbLogger_h
+
+#include "itkLoggerBase.h"
+#include "itkLogger.h"
+
+namespace otb {
+
+/** \class Logger
+ *  \brief An ITK logger specialized for OTB
+ *
+ *  Sets OTB wide settings in its constructor
+ *
+ * \ingroup OTBApplicationEngine
+ */
+class Logger : public itk::Logger
+{
+public:
+  typedef Logger                          Self;
+  typedef itk::Logger                     Superclass;
+  typedef itk::SmartPointer< Self >       Pointer;
+  typedef itk::SmartPointer< const Self > ConstPointer;
+
+  itkTypeMacro(Logger, Object);
+  itkNewMacro(Self);
+
+  // Overwrite this to provide custom formatting of log entries
+  std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) ITK_OVERRIDE;
+
+protected:
+    Logger();
+    virtual ~Logger();
+}; // class Logger
+
+} // namespace otb
+
+#endif // otbLogger_h
diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h
index 741f5c4..aa0cdd0 100644
--- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h
+++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h
@@ -26,7 +26,7 @@
 #include "otbWrapperTags.h"
 #include "otbWrapperParameterGroup.h"
 
-#include "itkLogger.h"
+#include "otbLogger.h"
 #include "itkTimeProbe.h"
 #include "otbWrapperMacros.h"
 #include "otbWrapperInputImageParameter.h"
@@ -40,6 +40,37 @@
 
 namespace otb
 {
+
+/** \class ApplicationException
+ *  \brief Exception for runtime errors in OTB Applications
+ *
+ *  Usually thrown with the otbAppLogFATAL macro
+ *
+ * \ingroup OTBApplicationEngine
+ */
+class ApplicationException : public itk::ExceptionObject
+{
+public:
+  /** Run-time information. */
+  itkTypeMacro( ApplicationException, ExceptionObject );
+
+  /** Constructor. */
+  ApplicationException(const char *file, unsigned int line,
+                       const char* message = "Application error.",
+                       const char* loc = "Unknown") :
+    ExceptionObject(file, line, message, loc)
+  {
+  }
+
+  /** Constructor. */
+  ApplicationException(const std::string &file, unsigned int line,
+                       const char* message = "Application error.",
+                       const char* loc = "Unknown") :
+    ExceptionObject(file, line, message, loc)
+  {
+  }
+};
+
 namespace Wrapper
 {
 
@@ -70,6 +101,7 @@ public:
     m_Name = name;
     GetDocExample()->SetApplicationName(name);
     this->Modified();
+    m_Logger->SetName(name);
   }
 
   itkGetStringMacro(Name);
@@ -135,7 +167,7 @@ public:
   /* Get the internal application parameter specified
    *
    * WARNING: this method may disappear from the API */
-  const Parameter* GetParameterByKey(std::string parameter) const;
+  const Parameter* GetParameterByKey(std::string parameter, bool follow=true) const;
 
   /* Returns the description of a parameter */
   std::string GetParameterName(std::string paramKey);
@@ -252,8 +284,21 @@ public:
 
   void SetParameterEmpty(std::string parameter, bool value, bool hasUserValueFlag = true);
 
+  /** Checks if the application is ready to be executed. It checks that there
+   *  is no parameter missing
+   */
   bool IsApplicationReady();
 
+  /** Checks if a parameter 'key' is missing.
+   *
+   * A parameter is missing when all the following conditions are true :
+   *   - the parameter is mandatory
+   *   - the parameter has Role_Input
+   *   - the parameter is not a group
+   *   - the parameter has no value
+   *   - the parameter ancestors are mandatory or enabled.
+   */
+  bool IsParameterMissing(const std::string &key) const;
 
   /* Set an default integer value, must used in the
    * DoInit when setting a value by default
@@ -663,7 +708,10 @@ public:
    */
   ComplexImagePixelType GetParameterComplexOutputImagePixelType(std::string parameter);
 
-  itk::Logger* GetLogger();
+  otb::Logger* GetLogger() const;
+
+  /** Sets the logger instance of the application (use with caution) */
+  void SetLogger(otb::Logger *logger);
 
   itk::ProcessObject* GetProgressSource() const;
 
@@ -778,7 +826,7 @@ public:
   /** documentation link */
   void SetDocLink(const std::string & link)
   {
-    if (!m_Doclink.compare(link) == 0) {
+    if (m_Doclink.compare(link) != 0) {
       m_Doclink = link;
       this->Modified();
     }
@@ -916,7 +964,6 @@ protected:
       }
   }
 
-
 private:
   /* Implement this method to add parameters */
   virtual void DoInit() = 0;
@@ -938,7 +985,7 @@ private:
   std::string                       m_Name;
   std::string                       m_Description;
   ParameterGroup::Pointer           m_ParameterList;
-  itk::Logger::Pointer              m_Logger;
+  otb::Logger::Pointer              m_Logger;
 
   itk::ProcessObject::Pointer       m_ProgressSource;
   std::string                       m_ProgressSourceDescription;
diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h
index 3dae3b1..859e6a8 100644
--- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h
+++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h
@@ -149,10 +149,6 @@ private:
 
   InternalAppContainer m_AppContainer;
 
-  itk::StdStreamLogOutput::Pointer  m_LogOutput;
-
-  std::ostringstream m_Oss;
-
   AddProcessCommandType::Pointer    m_AddProcessCommand;
 };
 
diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h
index 94a5429..6b4bf70 100644
--- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h
+++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h
@@ -71,7 +71,9 @@ public:
  /** Get one specific stored image filename. */
   std::string GetNthFileName( unsigned int i ) const;
 
-  /** Get one list of the stored image. */
+  /** Get one list of the stored image. WARNING : if the parameter list changes,
+   *  the returned image list may become obsolete. You should call
+   *  GetImageList() again to make sure your image list is up-to-date. */
   FloatVectorImageListType* GetImageList() const;
 
   /** Get one specific stored image. */
diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx
index f8aa185..64a620f 100644
--- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx
+++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx
@@ -56,14 +56,7 @@ InputImageParameter::GetImage()
       typename ReaderType::Pointer reader = ReaderType::New();
       reader->SetFileName(m_FileName);
 
-      try
-        {
-        reader->UpdateOutputInformation();
-        }
-      catch (itk::ExceptionObject &)
-        {
-        this->ClearValue();
-        }
+      reader->UpdateOutputInformation();
 
       m_Image = reader->GetOutput();
       m_Reader = reader;
diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperMacros.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperMacros.h
index 49da204..39e4c57 100644
--- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperMacros.h
+++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperMacros.h
@@ -24,10 +24,15 @@
 
 #define otbAppLogFATAL(x) \
   { \
-  std::ostringstream msg; \
-  msg << "" x << std::endl; \
-  this->GetLogger()->Write( itk::LoggerBase::FATAL, msg.str() ); \
-  itkGenericExceptionMacro(<< "Fatal error caught. Aborting..."); \
+    std::ostringstream msg; \
+    msg << "" x << std::endl; \
+    this->GetLogger()->Fatal(msg.str()); \
+    {                                                                                          \
+      std::ostringstream message;                                                              \
+      message << "otb::ApplicationException " x;                                               \
+      ::otb::ApplicationException e_(__FILE__, __LINE__, message.str().c_str(), ITK_LOCATION); \
+      throw e_; /* Explicit naming to work around Intel compiler bug.  */                      \
+    } \
   }
 
 #define otbAppLogCRITICAL(x) \
diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h
index ab35f96..7f247f2 100644
--- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h
+++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h
@@ -98,8 +98,17 @@ protected:
 
 private:
 
+  /** Recursive function to parse a group parameter */
+  void ParseGroup(const std::string& group);
+
   std::string    m_FileName;
 
+  /** Temporary storage of the XML node to fill (internal) */
+  TiXmlElement* m_Node;
+
+  /** Temporary pointer to the application to parse (internal) */
+  Application::Pointer m_Appli;
+
   OutputProcessXMLParameter(const OutputProcessXMLParameter &); //purposely not implemented
   void operator =(const OutputProcessXMLParameter&); //purposely not implemented
 
diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt
index 6bfea3a..3251a05 100644
--- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt
+++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt
@@ -48,6 +48,7 @@ set(OTBApplicationEngine_SRC
   otbWrapperApplicationRegistry.cxx
   otbWrapperApplicationFactoryBase.cxx
   otbWrapperCompositeApplication.cxx
+  otbLogger.cxx
   )
 
 add_library(OTBApplicationEngine ${OTBApplicationEngine_SRC})
diff --git a/Modules/Wrappers/ApplicationEngine/src/otbLogger.cxx b/Modules/Wrappers/ApplicationEngine/src/otbLogger.cxx
new file mode 100644
index 0000000..f7994ee
--- /dev/null
+++ b/Modules/Wrappers/ApplicationEngine/src/otbLogger.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 "otbLogger.h"
+#include "itksys/SystemTools.hxx"
+
+namespace otb
+{
+
+Logger::Logger() :
+    itk::Logger::Logger()
+{
+#if OTB_DEBUG
+  this->SetPriorityLevel(itk::LoggerBase::DEBUG);
+#else
+  this->SetPriorityLevel(itk::LoggerBase::INFO);
+#endif
+
+  this->SetLevelForFlushing(itk::LoggerBase::CRITICAL);
+
+  this->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE);
+  this->SetHumanReadableFormat("%Y-%m-%d %H:%M:%S");
+}
+
+Logger::~Logger()
+{
+}
+
+std::string Logger::BuildFormattedEntry(itk::Logger::PriorityLevelType level, std::string const & content)
+{
+ static const std::string levelString[] = { "(MUSTFLUSH)", "(FATAL)", "(CRITICAL)",
+                                         "(WARNING)", "(INFO)", "(DEBUG)", "(NOTSET)" };
+
+  // TODO: assert(level <= std::extent<decltype(levelString)>::value);  // requires C++11
+
+  std::ostringstream s;
+
+
+  switch ( this->m_TimeStampFormat )
+  {
+    case REALVALUE:
+    {
+      s.precision(30);
+      s << m_Clock->GetTimeInSeconds();
+      break;
+    }
+    case HUMANREADABLE:
+    {
+      s << itksys::SystemTools::GetCurrentDateTime( this->m_HumanReadableFormat.c_str() );
+      break;
+    }
+  }
+  s << " " << levelString[level] << ": " << content;
+
+  return s.str();
+}
+
+} // namespace otb
diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx
index 9ad9107..120365d 100644
--- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx
+++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx
@@ -36,6 +36,7 @@
 #include "otbWrapperInputProcessXMLParameter.h"
 #include "otbWrapperRAMParameter.h"
 #include "otbWrapperProxyParameter.h"
+#include "otbWrapperParameterKey.h"
 
 
 #include "otbWrapperAddProcessToWatchEvent.h"
@@ -53,7 +54,7 @@ namespace Wrapper
 Application::Application()
   : m_Name(""),
     m_Description(""),
-    m_Logger(itk::Logger::New()),
+    m_Logger(otb::Logger::New()),
     m_ProgressSourceDescription(""),
     m_DocName(""),
     m_DocLongDescription(""),
@@ -68,19 +69,25 @@ Application::Application()
 {
   // Don't call Init from the constructor, since it calls a virtual method !
   m_Logger->SetName("Application.logger");
-  m_Logger->SetPriorityLevel(itk::LoggerBase::DEBUG);
-  m_Logger->SetLevelForFlushing(itk::LoggerBase::CRITICAL);
 }
 
 Application::~Application()
 {
 }
 
-itk::Logger* Application::GetLogger()
+otb::Logger* Application::GetLogger() const
 {
   return m_Logger;
 }
 
+void Application::SetLogger(otb::Logger *logger)
+{
+  if (m_Logger != logger)
+    {
+    m_Logger = logger;
+    }
+}
+
 std::vector<std::string>
 Application::GetParametersKeys(bool recursive)
 {
@@ -199,9 +206,7 @@ void Application::SetParameterString(std::string parameter, std::string value, b
   else if (dynamic_cast<InputImageParameter*>(param))
     {
     InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param);
-    if ( !paramDown->SetFromFileName(value) )
-    otbAppLogCRITICAL( <<"Invalid image filename " << value <<".");
-
+    paramDown->SetFromFileName(value);
     }
   else if (dynamic_cast<ComplexInputImageParameter*>(param))
     {
@@ -301,11 +306,11 @@ void Application::SetParameterUserValue(std::string paramKey, bool value)
   GetParameterByKey(paramKey)->SetUserValue(value);
 }
 
-const Parameter* Application::GetParameterByKey(std::string name) const
+const Parameter* Application::GetParameterByKey(std::string name, bool follow) const
 {
   // GetParameterList is non const...
   Application* _this = const_cast<Application*>(this);
-  return _this->GetParameterByKey(name);
+  return _this->GetParameterByKey(name,follow);
 }
 
 void Application::Init()
@@ -340,8 +345,9 @@ void Application::UpdateParameters()
       InputProcessXMLParameter* inXMLParam = dynamic_cast<InputProcessXMLParameter*>(param);
       if(inXMLParam!=ITK_NULLPTR)
         {
-        inXMLParam->Read(this);
+        // switch on 'm_IsInXMLParsed' before Read() to avoid cyclic calls
         m_IsInXMLParsed = true;
+        inXMLParam->Read(this);
         }
       }
     }
@@ -435,7 +441,7 @@ int Application::ExecuteAndWriteOutput()
             std::string checkReturn = outputParam->CheckFileName(true);
             if (!checkReturn.empty())
               {
-              otbAppLogWARNING("Check filename : "<<checkReturn);
+              otbAppLogWARNING("Check filename: "<<checkReturn);
               }
             if (useRAM)
               {
@@ -746,30 +752,31 @@ std::vector<std::string> Application::GetChoiceNames(std::string name)
 void Application::SetDefaultParameterInt(std::string parameter, int value)
 {
   Parameter* param = GetParameterByKey(parameter);
+  bool hasUserValue = param->HasUserValue();
 
   if (dynamic_cast<RadiusParameter*>(param))
     {
     RadiusParameter* paramRadius = dynamic_cast<RadiusParameter*>(param);
     paramRadius->SetDefaultValue(value);
-    paramRadius->SetValue(value);
+    if (!hasUserValue) paramRadius->SetValue(value);
     }
    else if (dynamic_cast<IntParameter*>(param))
     {
     IntParameter* paramInt = dynamic_cast<IntParameter*>(param);
     paramInt->SetDefaultValue(value);
-    paramInt->SetValue(value);
+    if (!hasUserValue) paramInt->SetValue(value);
     }
   else if (dynamic_cast<FloatParameter*>(param))
     {
     FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param);
     paramFloat->SetDefaultValue(static_cast<float>(value));
-    paramFloat->SetValue(static_cast<float>(value));
+    if (!hasUserValue) paramFloat->SetValue(static_cast<float>(value));
     }
   else if (dynamic_cast<RAMParameter*>(param))
     {
     RAMParameter* paramRAM = dynamic_cast<RAMParameter*>(param);
     paramRAM->SetDefaultValue(static_cast<unsigned int>(value));
-    paramRAM->SetValue(static_cast<unsigned int>(value));
+    if (!hasUserValue) paramRAM->SetValue(static_cast<unsigned int>(value));
     }
 }
 
@@ -781,7 +788,7 @@ void Application::SetDefaultParameterFloat(std::string parameter, float value)
     {
     FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param);
     paramFloat->SetDefaultValue(value);
-    paramFloat->SetValue(value);
+    if (!param->HasUserValue()) paramFloat->SetValue(value);
     }
 }
 
@@ -1602,57 +1609,50 @@ Application::IsApplicationReady()
        it != paramList.end();
        ++it)
     {
-    // Check all Input Parameters with Input Role
-    if (GetParameterByKey(*it)->GetRole() == Role_Input)
+    // Check all parameters
+    if (IsParameterMissing(*it))
       {
-      // When a parameter is mandatory :
-      // return false when does not have value and:
-      //  - The param is root
-      //  - The param is not root and belonging to a Mandatory Group
-      //    which is activated
-      if ( !this->HasValue(*it)  && IsMandatory(*it) )
-        {
-        if( GetParameterByKey(*it)->IsRoot() )
-          {
-          otbDebugMacro("MISSING : "<< (*it).c_str() << " ( Is Root)");
-          return false;
-          }
-        else
-          {
-          // check if the parameter is linked to a root parameter with a chain of active parameters
-          Parameter* currentParam = GetParameterByKey(*it)->GetRoot();
-          if (currentParam->IsRoot())
-            {
-            otbDebugMacro("MISSING : "<< (*it).c_str() << " ( Is Level 1)");
-            return false;
-            }
-
-          int level = 1;
-
-          while (!currentParam->IsRoot())
-            {
-            if (!currentParam->GetActive())
-              {
-              // the missing parameter is not on an active branch : we can ignore it
-              break;
-              }
-            currentParam = currentParam->GetRoot();
-
-            level++;
+      ready = false;
+      break;
+      }
+    }
+  return ready;
+}
 
-            if (currentParam->IsRoot())
-              {
-              // the missing parameter is on an active branch : we need it
-              otbDebugMacro("MISSING : "<< (*it).c_str() << " ( Is Level "<< level<<")");
-              return false;
-              }
-            }
-          }
+bool
+Application::IsParameterMissing(const std::string &key) const
+{
+  bool ret(false);
+  const Parameter* param = GetParameterByKey(key);
+  if (param->GetRole() == Role_Input &&
+      GetParameterType(key) != ParameterType_Group &&
+      param->GetMandatory() &&
+      !param->HasValue())
+    {
+    ret = true;
+    ParameterKey paramKey(key);
+    std::vector<std::string> split = paramKey.Split();
+    std::string currentRoot(key);
+    unsigned int level = 1;
+    while (level < split.size())
+      {
+      currentRoot.resize(currentRoot.find_last_of("."));
+      param = GetParameterByKey(currentRoot);
+      if (!param->GetActive() && !param->GetMandatory())
+        {
+        // the missing parameter is not on an active branch : we can ignore it
+        ret = false;
+        break;
         }
+      level++;
+      }
+    if (ret)
+      {
+      // the missing parameter is on an active branch : we need it
+      otbDebugMacro("MISSING : "<< key << " (Level "<< split.size()<<")");
       }
     }
-
-  return ready;
+  return ret;
 }
 
 void
diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperChoiceParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperChoiceParameter.cxx
index 1ebb88d..2f64625 100644
--- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperChoiceParameter.cxx
+++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperChoiceParameter.cxx
@@ -44,7 +44,7 @@ ChoiceParameter::AddChoice( std::string choicekey, std::string choiceName )
   choice.m_AssociatedParameter->SetName(choiceName);
   choice.m_AssociatedParameter->SetRoot(this);
   choice.m_AssociatedParameter->SetKey(choicekey);
-  
+  choice.m_AssociatedParameter->SetMandatory(false);
   m_ChoiceList.push_back(choice);
 
   // check if the new choice matches the m_CurrentChoice : if so the group should be active.
diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx
index 741bcb0..db21659 100644
--- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx
+++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx
@@ -32,8 +32,6 @@ namespace Wrapper
 
 CompositeApplication::CompositeApplication()
 {
-  m_LogOutput = itk::StdStreamLogOutput::New();
-  m_LogOutput->SetStream(m_Oss);
   m_AddProcessCommand = AddProcessCommandType::New();
   m_AddProcessCommand->SetCallbackFunction(this, &CompositeApplication::LinkWatchers);
 }
@@ -65,8 +63,7 @@ CompositeApplication
   container.App = ApplicationRegistry::CreateApplication(appType);
   container.Desc = desc;
   // Setup logger
-  container.App->GetLogger()->AddLogOutput(m_LogOutput);
-  container.App->GetLogger()->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE);
+  container.App->SetLogger(this->GetLogger());
   container.App->AddObserver(AddProcessToWatchEvent(), m_AddProcessCommand.GetPointer());
   m_AppContainer[key] = container;
   return true;
@@ -179,40 +176,14 @@ CompositeApplication
 ::ExecuteInternal(std::string key)
 {
   otbAppLogINFO(<< GetInternalAppDescription(key) <<"...");
-  try
-    {
-    GetInternalApplication(key)->Execute();
-    }
-  catch(...)
-    {
-    this->GetLogger()->Write( itk::LoggerBase::FATAL, std::string("\n") + m_Oss.str() );
-    throw;
-    }
-  if(!m_Oss.str().empty())
-    {
-    otbAppLogINFO(<< "\n" << m_Oss.str());
-    m_Oss.str(std::string(""));
-    }
+  GetInternalApplication(key)->Execute();
 }
 
 void
 CompositeApplication
 ::UpdateInternalParameters(std::string key)
 {
-  try
-    {
-    GetInternalApplication(key)->UpdateParameters();
-    }
-  catch(...)
-    {
-    this->GetLogger()->Write( itk::LoggerBase::FATAL, std::string("\n") + m_Oss.str() );
-    throw;
-    }
-  if(!m_Oss.str().empty())
-    {
-    otbAppLogINFO(<< "\n" << m_Oss.str());
-    m_Oss.str(std::string(""));
-    }
+  GetInternalApplication(key)->UpdateParameters();
 }
 
 } // end namespace Wrapper
diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx
index eb91c4e..e65e220 100644
--- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx
+++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx
@@ -43,38 +43,21 @@ InputFilenameListParameter::SetListFromFileName(const std::vector<std::string> &
   // First clear previous file chosen
   this->ClearValue();
 
-  bool isOk = true;
   for(unsigned int i=0; i<filenames.size(); i++)
     {
     std::string filename = filenames[i];
-    // TODO : when the logger will be available, redirect the exception
-    // in the logger (like what is done in MsgReporter)
     // File existence checked by the reader
     if (!filename.empty())
       {
       StringParameter::Pointer strParameter = StringParameter::New();
       strParameter->SetValue(filename);
-      try
-        {
-        strParameter->HasValue();
-        }
-      catch(itk::ExceptionObject & /*err*/)
-        {
-        this->ClearValue();
-        isOk = false;
-        break;
-        }
+      strParameter->HasValue();
 
       // everything went fine, store the object reference
       m_FilenameList->PushBack(strParameter);
       }
     }
 
-  if( !isOk )
-    {
-    return false;
-    }
-
   SetActive(true);
   this->Modified();
   return true;
@@ -92,22 +75,12 @@ InputFilenameListParameter::AddNullElement()
 bool
 InputFilenameListParameter::AddFromFileName(const std::string & filename)
 {
-  // TODO : when the logger will be available, redirect the exception
-  // in the logger (like what is done in MsgReporter)
   // File existence checked by the reader
   if (!filename.empty())
     {
     StringParameter::Pointer strParameter = StringParameter::New();
     strParameter->SetValue(filename);
-    try
-      {
-      strParameter->HasValue();
-      }
-    catch(itk::ExceptionObject & /*err*/)
-      {
-      this->ClearValue();
-      return false;
-      }
+    strParameter->HasValue();
 
     // everything went fine, store the object references
     m_FilenameList->PushBack(strParameter);
@@ -127,25 +100,15 @@ InputFilenameListParameter::SetNthFileName( const unsigned int id, const std::st
     itkExceptionMacro(<< "No file "<<id<<". Only "<<m_FilenameList->Size()<<" filenames available.");
     }
 
-  // TODO : when the logger will be available, redirect the exception
-  // in the logger (like what is done in MsgReporter)
   // File existence checked by the reader
   if (!filename.empty())
     {
     StringParameter::Pointer strParameter = StringParameter::New();
     strParameter->SetValue(filename);
-    try
-      {
-      strParameter->HasValue();
-      }
-    catch(itk::ExceptionObject &)
-      {
-      this->ClearValue();
-      return false;
-      }
+    strParameter->HasValue();
 
     m_FilenameList->SetNthElement(id, strParameter);
-
+    SetActive(true);
     this->Modified();
     return true;
     }
diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx
index 01be700..01c31e1 100644
--- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx
+++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx
@@ -44,40 +44,23 @@ InputImageListParameter::SetListFromFileName(const std::vector<std::string> & fi
   // First clear previous file chosen
   this->ClearValue();
 
-  bool isOk = true;
   for(unsigned int i=0; i<filenames.size(); i++)
     {
     const std::string filename = filenames[i];
-    // TODO : when the logger will be available, redirect the exception
-    // in the logger (like what is done in MsgReporter)
+
     // File existence checked by the reader
     if (!filename.empty())
       {
       // Try to build a new ParameterInputImage
       InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New();
-
       tmpInputImageParameter->SetFromFileName(filename);
 
-      if(!tmpInputImageParameter->HasValue())
-        {
-        // If loading failed
-        this->ClearValue();
-        isOk = false;
-        break;
-        }
-
       m_InputImageParameterVector.push_back(tmpInputImageParameter);
-      m_ImageList->PushBack(tmpInputImageParameter->GetFloatVectorImage());
       }
     }
 
-  if( !isOk )
-    {
-    return false;
-    }
-
-  SetActive(true);
   this->Modified();
+  SetActive(true);
   return true;
 }
 
@@ -86,7 +69,6 @@ void
 InputImageListParameter::AddNullElement()
 {
   m_InputImageParameterVector.push_back(ITK_NULLPTR);
-  m_ImageList->PushBack(ITK_NULLPTR);
   SetActive(false);
   this->Modified();
 }
@@ -94,27 +76,16 @@ InputImageListParameter::AddNullElement()
 bool
 InputImageListParameter::AddFromFileName(const std::string & filename)
 {
-  // TODO : when the logger will be available, redirect the exception
-  // in the logger (like what is done in MsgReporter)
   // File existence checked by the reader
   if (!filename.empty())
     {
-    // Try to build a new ParameterInputImage
     InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New();
-
     tmpInputImageParameter->SetFromFileName(filename);
-    
-    if(!tmpInputImageParameter->HasValue())
-      {
-      // If loading failed
-      this->ClearValue();
-      return false;
-      }
-    
+
     m_InputImageParameterVector.push_back(tmpInputImageParameter);
-    m_ImageList->PushBack(tmpInputImageParameter->GetFloatVectorImage());
-    SetActive(true);
+
     this->Modified();
+    SetActive(true);
     return true;
     }
 
@@ -129,24 +100,14 @@ InputImageListParameter::SetNthFileName( const unsigned int id, const std::strin
     itkExceptionMacro(<< "No image "<<id<<". Only "<<m_InputImageParameterVector.size()<<" images available.");
     }
 
-  // TODO : when the logger will be available, redirect the exception
-  // in the logger (like what is done in MsgReporter)
   // File existence checked by the reader
   if (!filename.empty())
     {
     InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New();
-
     tmpInputImageParameter->SetFromFileName(filename);
 
-    if(!tmpInputImageParameter->HasValue())
-      {
-      this->ClearValue();
-      return false;
-      }
-
     m_InputImageParameterVector[id] = tmpInputImageParameter;
-    m_ImageList->SetNthElement(id,tmpInputImageParameter->GetFloatVectorImage());
-      
+
     this->Modified();
     SetActive(true);
     return true;
@@ -164,9 +125,13 @@ InputImageListParameter::GetFileNameList() const
   for(InputImageParameterVectorType::const_iterator it = m_InputImageParameterVector.begin();
       it!=m_InputImageParameterVector.end();++it)
     {
+    if(it->IsNull())
+      {
+      itkExceptionMacro(<< "Empty image in InputImageListParameter.");
+      }
     filenames.push_back( (*it)->GetFileName() );
     }
-  
+
   return filenames;
 }
 
@@ -178,43 +143,50 @@ InputImageListParameter::GetNthFileName( unsigned int i ) const
       {
       itkExceptionMacro(<< "No image "<<i<<". Only "<<m_InputImageParameterVector.size()<<" images available.");
       }
-
+    if(m_InputImageParameterVector[i].IsNull())
+      {
+      itkExceptionMacro(<< "Requested image "<<i<<" has no filename");
+      }
     return m_InputImageParameterVector[i]->GetFileName();
 }
 
 FloatVectorImageListType*
 InputImageListParameter::GetImageList() const
 {
+  m_ImageList->Clear();
+  for (unsigned int i=0 ; i < this->Size() ; ++i)
+    {
+    if(m_InputImageParameterVector[i].IsNull())
+      {
+      itkExceptionMacro(<< "Image "<<i<<" is empty.");
+      }
+    m_ImageList->PushBack(m_InputImageParameterVector[i]->GetFloatVectorImage());
+    }
   return m_ImageList;
 }
 
 FloatVectorImageType*
 InputImageListParameter::GetNthImage(unsigned int i) const
 {
-  if(m_ImageList->Size()<i)
+  if(this->Size()<=i)
+    {
+    itkExceptionMacro(<< "No image "<<i<<". Only "<<this->Size()<<" images available.");
+    }
+  if(m_InputImageParameterVector[i].IsNull())
     {
-    itkExceptionMacro(<< "No image "<<i<<". Only "<<m_ImageList->Size()<<" images available.");
+    itkExceptionMacro(<< "Image "<<i<<" is empty.");
     }
-  return m_ImageList->GetNthElement(i);
+  return m_InputImageParameterVector[i]->GetFloatVectorImage();
 }
 
 void
 InputImageListParameter::SetImageList(FloatVectorImageListType* imList)
 {
   // Check input availability
-  // TODO : when the logger will be available, redirect the exception
-  // in the logger (like what is done in MsgReporter)
-  try
-    {
-    for(unsigned int i=0; i<imList->Size(); i++)
-      {
-      imList->GetNthElement( i )->UpdateOutputInformation();
-      }
-    }
-  catch(itk::ExceptionObject &)
-    {
-    return;
-    }
+  for(unsigned int i = 0; i < imList->Size(); i++)
+  {
+    imList->GetNthElement(i)->UpdateOutputInformation();
+  }
 
   // Clear previous values
   this->ClearValue();
@@ -223,39 +195,33 @@ InputImageListParameter::SetImageList(FloatVectorImageListType* imList)
     {
     // Try to build a new ParameterInputImage
     InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New();
-    
+
     tmpInputImageParameter->SetImage(imList->GetNthElement(i));
-    
+
     m_InputImageParameterVector.push_back(tmpInputImageParameter);
     m_ImageList->PushBack(tmpInputImageParameter->GetFloatVectorImage());
     }
-  
+
   SetActive(true);
   this->Modified();
 }
 
 void InputImageListParameter::SetNthImage(unsigned int i, ImageBaseType * img)
 {
-  if(m_ImageList->Size()<i)
-    {
-    itkExceptionMacro(<< "No image "<<i<<". Only "<<m_ImageList->Size()<<" images available.");
-    }
-  try
-    {
-    img->UpdateOutputInformation();
-    }
-  catch(itk::ExceptionObject &)
-    {
-    return;
-    }
-  
+  if(this->Size()<i)
+  {
+    itkExceptionMacro(<< "No image "<<i<<". Only "<<this->Size()<<" images available.");
+  }
+
+  // Check input availability
+  img->UpdateOutputInformation();
+
   // Try to build a new ParameterInputImage
   InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New();
-  
+
   tmpInputImageParameter->SetImage(img);
 
   m_InputImageParameterVector[i] = tmpInputImageParameter;
-  m_ImageList->SetNthElement(i,tmpInputImageParameter->GetFloatVectorImage());
 }
 
 
@@ -263,23 +229,13 @@ void
 InputImageListParameter::AddImage(ImageBaseType* image)
 {
   // Check input availability
-  // TODO : when the logger will be available, redirect the exception
-  // in the logger (like what is done in MsgReporter)
-  try
-    {
-    image->UpdateOutputInformation();
-    }
-  catch(itk::ExceptionObject &)
-    {
-    return;
-    }
+  image->UpdateOutputInformation();
 
   InputImageParameter::Pointer tmpInputImageParameter = InputImageParameter::New();
-  
+
   tmpInputImageParameter->SetImage(image);
-  
+
   m_InputImageParameterVector.push_back(tmpInputImageParameter);
-  m_ImageList->PushBack(tmpInputImageParameter->GetFloatVectorImage());
 
   this->Modified();
 }
@@ -287,16 +243,18 @@ InputImageListParameter::AddImage(ImageBaseType* image)
 bool
 InputImageListParameter::HasValue() const
 {
-  if(m_ImageList->Size() == 0)
+  if(this->Size() == 0)
     {
     return false;
     }
 
   bool res(true);
   unsigned int i(0);
-  while(i < m_ImageList->Size() && res == true)
+  while(i < this->Size() && res == true)
     {
-    res = m_ImageList->GetNthElement(i).IsNotNull();
+    res = (m_InputImageParameterVector[i] ?
+           m_InputImageParameterVector[i]->HasValue() :
+           false);
     i++;
     }
 
@@ -307,12 +265,11 @@ InputImageListParameter::HasValue() const
 void
 InputImageListParameter::Erase( unsigned int id )
 {
-  if(m_ImageList->Size()<id)
+  if(this->Size()<id)
     {
-    itkExceptionMacro(<< "No image "<<id<<". Only "<<m_ImageList->Size()<<" images available.");
+    itkExceptionMacro(<< "No image "<<id<<". Only "<<this->Size()<<" images available.");
     }
 
-  m_ImageList->Erase( id );
   m_InputImageParameterVector.erase(m_InputImageParameterVector.begin()+id);
 
   this->Modified();
diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx
index dcd9d21..08c0e1c 100644
--- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx
+++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx
@@ -53,27 +53,10 @@ InputImageParameter::SetFromFileName(const std::string& filename)
   //  - Done in the reader
   //  - allow appending additional information to the filename
   // myfile.tif:2 for example, or myfile.tif:nocarto
-  if (!filename.empty())
-    {
-    FloatVectorReaderType::Pointer reader = FloatVectorReaderType::New();
-
-    try
-      {
-      reader->SetFileName(filename);
-      reader->UpdateOutputInformation();
-      }
-    catch(itk::ExceptionObject & /*err*/)
-      {
-      return false;
-      }
-
-    // the specified filename is valid => store the value
-    m_FileName = filename;
-    m_UseFilename = true;
-    SetActive(true);
-    return true;
-    }
-  return false;
+  m_FileName = filename;
+  m_UseFilename = true;
+  SetActive(true);
+  return true;
 }
 
 
diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx
index 886261a..8bfd04b 100644
--- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx
+++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx
@@ -447,6 +447,9 @@ InputProcessXMLParameter::Read(Application::Pointer this_)
 
       this_->SetParameterStringList(key, values);
       }
+
+    // Call UpdateParameters after each parameter is set
+    this_->UpdateParameters();
     } //end updateFromXML
   //choice also comes as setint and setstring why??
 
diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx
index f8b6d77..5ba1037 100644
--- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx
+++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx
@@ -45,6 +45,8 @@ namespace otb
 namespace Wrapper
 {
 OutputProcessXMLParameter::OutputProcessXMLParameter()
+  : m_Node(ITK_NULLPTR)
+  , m_Appli()
 {
   this->SetKey("outxml");
   this->SetName("Save otb application to xml file");
@@ -160,7 +162,9 @@ OutputProcessXMLParameter::Write(Application::Pointer app)
 TiXmlElement*
 OutputProcessXMLParameter::ParseApplication(Application::Pointer app)
 {
+  m_Appli = app;
   TiXmlElement * n_App = new TiXmlElement("application");
+  m_Node = n_App;
 
   AddChildNodeTo(n_App, "name", app->GetName());
   AddChildNodeTo(n_App, "descr", app->GetDescription());
@@ -183,24 +187,55 @@ OutputProcessXMLParameter::ParseApplication(Application::Pointer app)
       std::string tag = *tagIt;
       AddChildNodeTo(n_DocTags, "tag", tag);
     }
-  ParameterGroup::Pointer paramGroup = app->GetParameterList();
 
-  std::vector<std::string> paramList = paramGroup->GetParametersKeys(true);
+  // recursive call to ParseGroup(), starting with "" (i.e. GetParameterList())
+  this->ParseGroup(std::string(""));
 
+  // reset temporary members
+  m_Appli = ITK_NULLPTR;
+  m_Node = ITK_NULLPTR;
+  return n_App;
+}
+
+void
+OutputProcessXMLParameter::ParseGroup(const std::string& group)
+{
+  std::string prefix(group);
+  ParameterGroup::Pointer paramGroup = m_Appli->GetParameterList();
+  if (!group.empty())
+    {
+    prefix += '.';
+    Parameter* rawParam = paramGroup->GetParameterByKey(group);
+    ParameterGroup* rawParamAsGroup = dynamic_cast<ParameterGroup*>(rawParam);
+    if (rawParamAsGroup)
+      {
+      paramGroup = rawParamAsGroup;
+      }
+    else
+      {
+      itkExceptionMacro("Function ParseGroup() expected a group parameter for key "<<group);
+      }
+    }
+
+  std::vector<std::string> paramList = paramGroup->GetParametersKeys(false);
 
   // Iterate through parameters
   for (std::vector<std::string>::const_iterator it = paramList.begin(); it!= paramList.end(); ++it)
     {
-      std::string key = *it;
-      Parameter *param = paramGroup->GetParameterByKey(key);
+      std::string key = prefix + *it;
+      Parameter *param = paramGroup->GetParameterByKey(*it);
       std::string paramName = param->GetName();
-      ParameterType type = app->GetParameterType(key);
+      ParameterType type = m_Appli->GetParameterType(key);
       std::string typeAsString = paramGroup->GetParameterTypeAsString(type);
 
-      // if param is a Group, don't do anything, ParamGroup don't have values
-      if (type != ParameterType_Group)
-      {
-       bool paramExists = app->HasUserValue(key) && app->IsParameterEnabled(key);
+      // if param is a Group, inspect this group with a recursive call
+      if (type == ParameterType_Group)
+        {
+        this->ParseGroup(key);
+        }
+      else
+       {
+       bool paramExists = m_Appli->HasUserValue(key) && m_Appli->IsParameterEnabled(key);
        if ( type == ParameterType_OutputProcessXML )
          {
            paramExists = false;
@@ -213,7 +248,7 @@ OutputProcessXMLParameter::ParseApplication(Application::Pointer app)
 
            if(eParam!=ITK_NULLPTR)
              {
-             //Don't use app->HasUserValue which returns false always because of
+             //Don't use m_Appli->HasUserValue which returns false always because of
              //EmptyParameter::HasValue() is false for EmptyParameter
              if(eParam->HasUserValue())
                {
@@ -252,18 +287,18 @@ OutputProcessXMLParameter::ParseApplication(Application::Pointer app)
                   type == ParameterType_InputVectorDataList || type == ParameterType_StringList ||
                   type == ParameterType_ListView )
            {
-           values = app->GetParameterStringList(key);
+           values = m_Appli->GetParameterStringList(key);
            hasValueList = true;
            }
          else if (type == ParameterType_Int || type == ParameterType_Radius || type == ParameterType_RAM )
            {
-           value = app->GetParameterAsString(key);
+           value = m_Appli->GetParameterAsString(key);
            }
          else if(type == ParameterType_Float)
            {
            std::ostringstream oss;
            oss << std::setprecision(std::numeric_limits<float>::digits10+1);
-           oss << app->GetParameterFloat( key );
+           oss << m_Appli->GetParameterFloat( key );
            value = oss.str();
            }
          else if ( type == ParameterType_String || type == ParameterType_InputFilename ||
@@ -272,12 +307,12 @@ OutputProcessXMLParameter::ParseApplication(Application::Pointer app)
                    type == ParameterType_Choice || type == ParameterType_OutputVectorData ||
                    type == ParameterType_OutputFilename)
            {
-           value = app->GetParameterString(key);
+           value = m_Appli->GetParameterString(key);
            }
          else if(key == "rand")
            {
            std::ostringstream strm;
-           strm << app->GetParameterInt("rand");
+           strm << m_Appli->GetParameterInt("rand");
            value = strm.str();
            }
          else if (typeAsString == "Empty")
@@ -285,7 +320,10 @@ OutputProcessXMLParameter::ParseApplication(Application::Pointer app)
            //Nothing to do. copy emptyValue
            value = emptyValue;
            }
-
+         else if (type == ParameterType_InputProcessXML)
+           {
+             continue;
+           }
          //get only file name
     /*
       if(type == ParameterType_InputFilename || type == ParameterType_InputImage ||
@@ -341,11 +379,18 @@ OutputProcessXMLParameter::ParseApplication(Application::Pointer app)
                 AddChildNodeTo(n_Values, "value",*strIt);
               }
            }
-         n_App->LinkEndChild(n_Parameter);
-       }
+         m_Node->LinkEndChild(n_Parameter);
+         }
+       // dig into Choice parameter
+       if (type == ParameterType_Choice)
+        {
+        std::string choiceGroup(key);
+        choiceGroup += '.';
+        choiceGroup += m_Appli->GetParameterString(key);
+        this->ParseGroup(choiceGroup);
+        }
       }
     }
-  return n_App;
 }
 
 } //end namespace wrapper
diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx
index d49fcf9..2ba9ba9 100644
--- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx
+++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx
@@ -788,7 +788,7 @@ ParameterGroup::GetParameterByKey(std::string name, bool follow)
         }
       std::string childName = childNameOss.str();
 
-      return parentAsGroup->GetParameterByKey(childName);
+      return parentAsGroup->GetParameterByKey(childName,follow);
       }
 
     // Handle ChoiceParameter case
@@ -823,7 +823,7 @@ ParameterGroup::GetParameterByKey(std::string name, bool follow)
             }
           }
         std::string childName = childNameOss.str();
-        return associatedParam->GetParameterByKey(childName);
+        return associatedParam->GetParameterByKey(childName,follow);
         }
       return associatedParam.GetPointer();
       }
diff --git a/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineLauncher.h b/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineLauncher.h
index 36b0b0d..c54d4a9 100644
--- a/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineLauncher.h
+++ b/Modules/Wrappers/CommandLine/include/otbWrapperCommandLineLauncher.h
@@ -109,7 +109,10 @@ public:
   bool BeforeExecute();
 
   /** Create and display the help of the application */
-  void DisplayHelp();
+  void DisplayHelp(bool longHelp=false);
+
+   /** Create and display the long help of the application */
+  void DisplayLongHelp();
 
   /** Performs specific action for testing environment */
   void LoadTestEnv();
@@ -131,7 +134,7 @@ protected:
     * Pay attention, the executable paths have to be loaded or set in
     * the environment before calling the function.
     */
-  void LoadApplication();
+  bool LoadApplication();
 
   /** Parse the user expression, extract the key and the associated
     * string and set it as value of each corresponding application
@@ -141,7 +144,7 @@ protected:
 
   /** Create and display the help of the application */
   std::string DisplayParameterHelp( const Parameter::Pointer & param,
-                                    const std::string paramKey );
+                                    const std::string paramKey, bool longHelp = false);
 
   /** Check if each key is unique in the expression. */
   bool CheckUnicity();
@@ -161,6 +164,8 @@ protected:
   /** Clear watcher list, deleting its pointers. */
   void DeleteWatcherList();
 
+  /** Returns the width of the longest key (in number of chars) */
+  unsigned int GetMaxKeySize() const;
 
 private:
 
@@ -181,7 +186,6 @@ private:
   AddProcessCommandType::Pointer    m_AddProcessCommand;
   bool                              m_ReportProgress;
 
-  unsigned int m_MaxKeySize;
 }; //end class
 
 } // end namespace Wrapper
diff --git a/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx b/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx
index c684158..4c5bd8a 100644
--- a/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx
+++ b/Modules/Wrappers/CommandLine/src/otbApplicationLauncherCommandLine.cxx
@@ -256,24 +256,28 @@ std::string CleanWord(const std::string & word)
   return res;
 }
 
+void ShowUsage(char* argv[])
+{
+  std::cerr << "Usage: " << argv[0] << " module_name [MODULEPATH] [arguments]" << std::endl;
+}
+
 int main(int argc, char* argv[])
 {
   #ifdef OTB_USE_MPI
   otb::MPIConfig::Instance()->Init(argc,argv);
   #endif
-  
+
   if (argc < 2)
-    {
-    std::cerr << "Usage : " << argv[0] << " module_name [MODULEPATH] [arguments]" << std::endl;
-    return EXIT_FAILURE;
-    }
+  {
+      ShowUsage(argv);
+      return false;
+  }
 
   std::vector<std::string> vexp;
 
   std::string exp;
   if (strcmp(argv[1], "-inxml") == 0)
     {
-    //exp = PrepareExpressionFromXML(argv[2]);
     vexp = PrepareVectorExpressionFromXML(argv[2]);
     }
   else
@@ -281,15 +285,6 @@ int main(int argc, char* argv[])
     // Construct the string expression
     for (int i = 1; i < argc; i++)
       {
-      /*if (i != argc - 1)
-        {
-        exp.append(argv[i]);
-        exp.append(" ");
-        }
-      else
-        {
-        exp.append(argv[i]);
-        }*/
       std::string strarg(argv[i]);
       std::string cleanArg = CleanWord(strarg);
       if (cleanArg.empty())
@@ -300,12 +295,16 @@ int main(int argc, char* argv[])
       vexp.push_back(cleanArg);
       }
     }
-  //  std::cerr << exp << ":\n";
 
   typedef otb::Wrapper::CommandLineLauncher LauncherType;
   LauncherType::Pointer launcher = LauncherType::New();
 
-  //if (launcher->Load(exp) == true)
+  if (vexp.empty())
+  {
+    ShowUsage(argv);
+    return false;
+  }
+
   bool success = launcher->Load(vexp) && launcher->ExecuteAndWriteOutput();
 
   // shutdown MPI after application finished
diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx
index d1cc388..736ad39 100644
--- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx
+++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx
@@ -49,13 +49,15 @@
 #include <string>
 #include <iostream>
 
+using std::string;
+
 namespace otb
 {
 namespace Wrapper
 {
 
 CommandLineLauncher::CommandLineLauncher() :
-  /*m_Expression(""),*/m_VExpression(), m_WatcherList(), m_ReportProgress(true), m_MaxKeySize(0)
+  /*m_Expression(""),*/m_VExpression(), m_WatcherList(), m_ReportProgress(true)
 {
   m_Application = ITK_NULLPTR;
   m_Parser = CommandLineParser::New();
@@ -94,20 +96,15 @@ bool CommandLineLauncher::Load(const std::vector<std::string> &vexp)
 
 bool CommandLineLauncher::Load()
 {
-  if (m_VExpression.empty())
-    {
-    itkExceptionMacro("No expression specified...");
-    }
-
   if (this->CheckParametersPrefix() == false)
     {
-    std::cerr << "ERROR: Parameter keys have to set using \"-\", not \"--\"" << std::endl;
+    std::cerr << "ERROR: Parameters are set using \"-\", not \"--\"." << std::endl;
     return false;
     }
 
   if (this->CheckUnicity() == false)
     {
-    std::cerr << "ERROR: At least one key is not unique in the expression..." << std::endl;
+    std::cerr << "ERROR: At least one parameter is not unique in the expression." << std::endl;
     return false;
     }
 
@@ -116,14 +113,12 @@ bool CommandLineLauncher::Load()
     if (m_Parser->GetPathsAsString(m_VExpression).size() != 0)
       {
       std::cerr << "ERROR: At least one specified path within \"" << m_Parser->GetPathsAsString(m_VExpression)
-                << "\" is invalid or doesn't exist..." << std::endl;
+                << "\" is invalid or doesn't exist." << std::endl;
       return false;
       }
     }
 
-  this->LoadApplication();
-
-  return true;
+  return this->LoadApplication();
 }
 
 bool CommandLineLauncher::Execute()
@@ -145,31 +140,54 @@ bool CommandLineLauncher::Execute()
 bool CommandLineLauncher::ExecuteAndWriteOutput()
 {
   try
-    {
+  {
     if (this->BeforeExecute() == false)
-      {
+    {
       return false;
-      }
+    }
 
     if( m_Application->ExecuteAndWriteOutput() == 0 )
-      {
+    {
       this->DisplayOutputParameters();
-      }
+    }
     else
+    {
       return false;
     }
+  }
+  catch(otb::ApplicationException& err)
+  {
+      // These are thrown with otbAppLogFATAL, a macro which logs a user
+      // friendly error message before throwing. So log exception details only
+      // in debug.
+      m_Application->GetLogger()->Debug("Caught otb::ApplicationException during application execution:\n");
+      m_Application->GetLogger()->Debug(string(err.what()) + "\n");
+      return false;
+  }
+  catch(otb::ImageFileReaderException& err)
+  {
+      m_Application->GetLogger()->Debug("Caught otb::ImageFileReaderException during application execution:\n");
+      m_Application->GetLogger()->Debug(string(err.what()) + "\n");
+      m_Application->GetLogger()->Fatal(string("Cannot open image ") + err.m_Filename + string(". ") + err.GetDescription() + string("\n"));
+      return false;
+  }
+  catch(itk::ExceptionObject& err)
+  {
+    m_Application->GetLogger()->Debug("Caught itk::ExceptionObject during application execution:\n");
+    m_Application->GetLogger()->Debug(string(err.what()) + "\n");
+    m_Application->GetLogger()->Fatal(string(err.GetDescription()) + "\n");
+    return false;
+  }
   catch(std::exception& err)
-    {
-    std::ostringstream message;
-    message << "The following error occurred during application execution : " << err.what() << std::endl;
-    m_Application->GetLogger()->Write( itk::LoggerBase::FATAL, message.str() );
+  {
+    m_Application->GetLogger()->Fatal(std::string("Caught std::exception during application execution: ") + err.what() + "\n");
     return false;
-    }
+  }
   catch(...)
-    {
-    m_Application->GetLogger()->Write( itk::LoggerBase::FATAL, "An unknown exception has been raised during application execution" );
+  {
+    m_Application->GetLogger()->Fatal("Caught unknown exception during application execution.\n");
     return false;
-    }
+  }
 
   return true;
 }
@@ -177,10 +195,10 @@ bool CommandLineLauncher::ExecuteAndWriteOutput()
 bool CommandLineLauncher::BeforeExecute()
 {
   if (m_Application.IsNull())
-    {
-    std::cerr << "ERROR: No loaded application..." << std::endl;
+  {
+    std::cerr << "ERROR: No loaded application." << std::endl;
     return false;
-    }
+  }
 
   // Check if there's keys in the expression if the application takes
   // at least 1 mandatory parameter
@@ -189,7 +207,8 @@ bool CommandLineLauncher::BeforeExecute()
 
   if( appKeyList.size()!=0 && keyList.size()==0 )
     {
-    std::cerr << "ERROR: Waiting for at least one parameter..." << std::endl;
+    std::cerr << "ERROR: Waiting for at least one parameter." << std::endl;
+    std::cerr << std::endl;
     this->DisplayHelp();
     return false;
     }
@@ -197,7 +216,26 @@ bool CommandLineLauncher::BeforeExecute()
   // if help is asked...
   if (m_Parser->IsAttributExists("-help", m_VExpression) == true)
     {
-    this->DisplayHelp();
+    std::vector<std::string> val;
+    val = m_Parser->GetAttribut("-help", m_VExpression);
+
+    if(val.empty())
+      {      
+      this->DisplayHelp(true);
+      }
+    else
+      {
+     
+      
+      for(std::vector<std::string>::const_iterator it = val.begin(); it!=val.end();++it)
+        {
+        Parameter::Pointer param = m_Application->GetParameterByKey(*it);
+        if (param->GetRole() != Role_Output)
+          {
+          std::cerr << this->DisplayParameterHelp(param, *it,true)<<std::endl;
+          }
+        }
+      }
     return false;
     }
 
@@ -218,64 +256,22 @@ bool CommandLineLauncher::BeforeExecute()
   std::string unknownKey;
   if (this->CheckKeyValidity(unknownKey) == false)
     {
-    std::cerr << "ERROR: option -"<<unknownKey<<" does not exist in the application." << std::endl;
-    this->DisplayHelp();
+    std::cerr << "ERROR: Parameter -" << unknownKey <<" does not exist in the application." << std::endl;
     return false;
     }
-  try
-    {
-    if (this->LoadParameters() != OKPARAM)
-      {
-      std::cerr << "ERROR: Troubles loading parameter, please check your line argument..." << std::endl;
-      // Force to reload the application, the LoadParameters can change wrong values
-      this->LoadApplication();
-      m_Application->Init();
-      this->DisplayHelp();
 
-      return false;
-      }
-    }
-  catch (itk::ExceptionObject& err)
-    {
-    std::cerr << "ERROR: Troubles in parameter setting, please check your line argument..." << std::endl;
-    std::cerr << err.GetDescription() << std::endl;
-    // Force to reload the application, the LoadParameters can change wrong values
-    this->LoadApplication();
-    m_Application->Init();
-    this->DisplayHelp();
+  ParamResultType result = this->LoadParameters();
 
+  if (result == MISSINGMANDATORYPARAMETER)
+  {
+    std::cerr << std::endl;
+    this->DisplayHelp();
     return false;
-    }
-
-  // Check for the progress report
-  if (m_Parser->IsAttributExists("-progress", m_VExpression) == true)
-    {
-    std::vector<std::string> val;
-    val = m_Parser->GetAttribut("-progress", m_VExpression);
-    if (val.size() != 1)
-      {
-      std::cerr << "ERROR: Invalid progress argument, must be unique value..." << std::endl;
-      return false;
-      }
-    if (val[0] == "1" || val[0] == "true")
-      {
-      m_ReportProgress = true;
-      }
-    else
-      if (val[0] == "0" || val[0] == "false")
-        {
-        m_ReportProgress = false;
-        }
-      else
-        {
-        std::cerr << "ERROR: Invalid progress argument, must be 0, 1, false or true..." << std::endl;
-        // Force to reload the application, the LoadParameters can change wrong values
-        this->LoadApplication();
-        this->DisplayHelp();
-
-        return false;
-        }
-    }
+  }
+  else if (result != OKPARAM)
+  {
+    return false;
+  }
 
   return true;
 }
@@ -300,15 +296,14 @@ bool CommandLineLauncher::LoadPath()
   return true;
 }
 
-void CommandLineLauncher::LoadApplication()
+bool CommandLineLauncher::LoadApplication()
 {
   // Look for the module name
   std::string moduleName;
-  //if (m_Parser->GetModuleName(moduleName, m_Expression) != CommandLineParser::OK)
   if (m_Parser->GetModuleName(moduleName, m_VExpression) != CommandLineParser::OK)
     {
-    std::cerr << "ERROR: LoadApplication, no module found..." << std::endl;
-    return;
+    std::cerr << "ERROR: Invalid module name: " << m_VExpression[0] << "." << std::endl;
+    return false;
     }
 
   // Instantiate the application using the factory
@@ -323,26 +318,27 @@ void CommandLineLauncher::LoadApplication()
     std::vector<std::string> list = ApplicationRegistry::GetAvailableApplications();
     if (list.size() == 0)
       {
-      std::cerr << "ERROR: Available modules : none." << std::endl;
+      std::cerr << "ERROR: Available modules: none." << std::endl;
       }
     else
       {
-      std::cerr << "ERROR: Available modules :" << std::endl;
+      std::cerr << "ERROR: Available modules:" << std::endl;
       for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
         {
         std::cerr << "\t" << *it << std::endl;
         }
       }
+    return false;
     }
   else
     {
     // Attach log output to the Application logger
-    m_Application->GetLogger()->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE);
     m_Application->GetLogger()->AddLogOutput(m_LogOutput);
 
     // Add an observer to the AddedProcess event
     m_Application->AddObserver(AddProcessToWatchEvent(), m_AddProcessCommand.GetPointer());
 
+    return true;
     }
 }
 
@@ -367,6 +363,25 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters()
     m_Application->UpdateParameters();
     }
 
+  // Check for the progress report parameter
+  if (m_Parser->IsAttributExists("-progress", m_VExpression) == true)
+  {
+    std::vector<std::string> val = m_Parser->GetAttribut("-progress", m_VExpression);
+    if (val.size() == 1 && (val[0] == "1" || val[0] == "true"))
+    {
+      m_ReportProgress = true;
+    }
+    else if (val.size() == 1 && (val[0] == "0" || val[0] == "false"))
+    {
+      m_ReportProgress = false;
+    }
+    else
+    {
+      std::cerr << "ERROR: Invalid value for parameter -progress. It must be 0, 1, false or true." << std::endl;
+      return WRONGPARAMETERVALUE;
+    }
+  }
+
   const std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true);
   // Loop over each parameter key declared in the application
   // FIRST PASS : set parameter values
@@ -393,8 +408,7 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters()
         // Check if there is a value associated to the attribute
         if ( values.empty() )
           {
-          std::cerr << "ERROR: No value associated to the parameter : \"" << paramKey
-                    << "\", invalid number of values " << values.size() << std::endl;
+          std::cerr << "ERROR: No value associated to parameter -" << paramKey << "." << std::endl;
           return INVALIDNUMBEROFVALUE;
           }
 
@@ -449,16 +463,16 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters()
                       else if (values[1] == "double")
                         outPixType = ImagePixelType_double;
                       else
-                        {
+                      {
+                        std::cerr << "ERROR: Invalid output type for parameter -" << paramKey << ": " << values[1] << "." << std::endl;
                         return WRONGPARAMETERVALUE;
-                        }
+                      }
                       dynamic_cast<OutputImageParameter *> (param.GetPointer())->SetPixelType(outPixType);
                       }
                     else
-                      if (values.size() != 1 && values.size() != 2)
+                      if (values.size() > 2)
                         {
-                        std::cerr << "ERROR: Invalid number of value for: \"" << paramKey
-                                  << "\", invalid number of values " << values.size() << std::endl;
+                        std::cerr << "ERROR: Too many values for parameter -" << paramKey << " (expected 2 or less, got " << values.size() << ")." << std::endl;
                         return INVALIDNUMBEROFVALUE;
                         }
                     }
@@ -474,9 +488,10 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters()
                       else if (values[1] == "cdouble")
                         outPixType = ComplexImagePixelType_double;
                       else
-                        {
+                      {
+                        std::cerr << "ERROR: Invalid output type for parameter -" << paramKey << ": " << values[1] << "." << std::endl;
                         return WRONGPARAMETERVALUE;
-                        }
+                      }
                       dynamic_cast<ComplexOutputImageParameter *> (param.GetPointer())->SetComplexPixelType(outPixType);
                       }
                     else
@@ -551,7 +566,7 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters()
                 }
              else
               {
-              std::cerr << "ERROR: Wrong parameter value: " << paramKey << std::endl;
+              std::cerr << "ERROR: Wrong value for parameter -" << paramKey << "." << std::endl;
               return WRONGPARAMETERVALUE;
               }
             }
@@ -567,100 +582,23 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters()
   for (unsigned int i = 0; i < appKeyList.size(); i++)
     {
     const std::string paramKey(appKeyList[i]);
-    Parameter::Pointer param = m_Application->GetParameterByKey(paramKey);
     ParameterType type = m_Application->GetParameterType(paramKey);
-    const bool paramExists(m_Parser->IsAttributExists(std::string("-").append(paramKey), m_VExpression));
-    std::vector<std::string> values;
-
-    // When a parameter is mandatory :
-    // it must be set if :
-    //  - The param is root
-    //  - The param is not root and belonging to a Mandatory Group
-    //    which is activated
-    bool mustBeSet = false;
-    const bool hasValue = m_Application->HasValue(paramKey);
-
-    //skip if mandatory parameters are missing because we have it already in XML
-    if(!paramInXMLExists)
-      {
-      if( param->GetMandatory() == true && param->GetRole() != Role_Output && type != ParameterType_Group)
-        {
-        // check if the parameter is linked to a root parameter with a chain of active parameters
-        if( param->IsRoot() || param->GetRoot()->IsRoot())
-          {
-          // the parameter is a root or inside a group at root level
-          mustBeSet = true;
-          }
-        else
-          {
-          Parameter* currentParam = param->GetRoot();
-          while (!currentParam->IsRoot())
-            {
-            if (!currentParam->GetActive())
-              {
-              // the missing parameter is not on an active branch : we can ignore it
-              break;
-              }
-            currentParam = currentParam->GetRoot();
-
-            if (currentParam->IsRoot())
-              {
-              // the missing parameter is on an active branch : we need it
-              mustBeSet = true;
-              }
-            }
-          }
-        }
-      }
-
-    if( mustBeSet )
-      {
-      if (!paramExists)
-        {
-        // If key doesn't exist and parameter hasn't default value set...
-        if (!hasValue)
-          {
-          std::cerr << "ERROR: Missing mandatory parameter: " << paramKey << "  " << m_Application->HasValue(paramKey)
-                    << std::endl;
-          return MISSINGMANDATORYPARAMETER;
-          }
-        }
-      else
-        {
-        values = m_Parser->GetAttribut(std::string("-").append(paramKey), m_VExpression);
-        if (values.size() == 0 && !m_Application->HasValue(paramKey))
-          {
-          std::cerr << "ERROR: Missing mandatory parameter: " << paramKey << std::endl;
-          return MISSINGPARAMETERVALUE;
-          }
-        }
-      }
-    // Check if non mandatory parameter have values
-    else
+    if (m_Application->IsParameterMissing(paramKey))
       {
-      if( paramExists )
-        {
-        values = m_Parser->GetAttribut(std::string("-").append(paramKey), m_VExpression);
-        if (values.size() == 0)
-          {
-          std::cerr << "ERROR: Missing non-mandatory parameter: " << paramKey << std::endl;
-          return MISSINGPARAMETERVALUE;
-          }
-        }
+      std::cerr << "ERROR: Missing mandatory parameter -" << paramKey << "." << std::endl;
+      return MISSINGMANDATORYPARAMETER;
       }
 
     // Check output paths validity
-    if (hasValue)
+    if (m_Application->HasValue(paramKey) &&
+        type == ParameterType_OutputFilename)
       {
-      if (type == ParameterType_OutputFilename)
+      std::string filename = m_Application->GetParameterString(paramKey);
+      itksys::String path = itksys::SystemTools::GetFilenamePath(filename);
+      if (path!="" && !itksys::SystemTools::FileIsDirectory(path.c_str()))
         {
-        std::string filename = m_Application->GetParameterString(paramKey);
-        itksys::String path = itksys::SystemTools::GetFilenamePath(filename);
-        if (path!="" && !itksys::SystemTools::FileIsDirectory(path.c_str()))
-          {
-          std::cerr <<"ERROR: Directory doesn't exist : "<< path.c_str() << std::endl;
-          return WRONGPARAMETERVALUE;
-          }
+        std::cerr <<"ERROR: Directory doesn't exist : "<< path.c_str() << std::endl;
+        return WRONGPARAMETERVALUE;
         }
       }
     }
@@ -685,69 +623,100 @@ void CommandLineLauncher::LinkWatchers(itk::Object * itkNotUsed(caller), const i
     }
 }
 
-void CommandLineLauncher::DisplayHelp()
+void CommandLineLauncher::DisplayHelp(bool longHelp)
 {
-  std::cerr << "This is the "<<m_Application->GetName() << " application, version " << OTB_VERSION_STRING <<std::endl;
+  std::cerr<<std::endl;
+  std::cerr << "This is the "<<m_Application->GetDocName() << " ("<<m_Application->GetName()<<") application, version " << OTB_VERSION_STRING <<std::endl<<std::endl;
 
   std::cerr << m_Application->GetDescription() << std::endl;
-  std::cerr<<std::endl;
 
-  std::string link = m_Application->GetDocLink();
-  if (!link.empty())
-  {
-    std::cerr << "Complete documentation: " << link << std::endl;
+  if(longHelp)
+    { 
+    std::cerr<<"Tags: ";
+
+    std::vector<std::string> tags = m_Application->GetDocTags();
+    
+    for(std::vector<std::string>::const_iterator it = tags.begin(); it!=tags.end();++it)
+      {
+      std::cerr<<*it<<" ";
+      }
     std::cerr<<std::endl;
-  }
+  
+    std::cerr<<std::endl;
+    std::cerr<<m_Application->GetDocLongDescription() << std::endl;
+    std::cerr<<std::endl;
+    }
+  else
+    {
+    std::string link = m_Application->GetDocLink();
+    if (!link.empty())
+      {
+      std::cerr << "Complete documentation: " << link << " or -help" <<std::endl;
+      std::cerr<<std::endl;
+      }
+    }
 
   std::cerr << "Parameters: " << std::endl;
 
   const std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true);
   const unsigned int nbOfParam = appKeyList.size();
 
-  m_MaxKeySize = std::string("progress").size();
-  for (unsigned int i = 0; i < nbOfParam; i++)
-    {
-    if (m_Application->GetParameterRole(appKeyList[i]) != Role_Output)
-      {
-      if( m_MaxKeySize < appKeyList[i].size() )
-        m_MaxKeySize = appKeyList[i].size();
-      }
-    }
+  unsigned int maxKeySize = GetMaxKeySize();
 
   //// progress report parameter
   std::string bigKey = "progress";
-  for(unsigned int i=0; i<m_MaxKeySize-std::string("progress").size(); i++)
+  for(unsigned int i=0; i<maxKeySize-std::string("progress").size(); i++)
     bigKey.append(" ");
 
   std::cerr << "        -"<<bigKey<<" <boolean>        Report progress " << std::endl;
+  bigKey = "help";
+  for(unsigned int i=0; i<maxKeySize-std::string("help").size(); i++)
+    bigKey.append(" ");
+  std::cerr << "        -"<<bigKey<<" <string list>    Display long help (empty list), or help for given parameters keys" << std::endl;
 
   for (unsigned int i = 0; i < nbOfParam; i++)
     {
-      Parameter::Pointer param = m_Application->GetParameterByKey(appKeyList[i]);
-      if (param->GetRole() != Role_Output)
-        {
-        std::cerr << this->DisplayParameterHelp(param, appKeyList[i]);
-        }
+    Parameter::Pointer param = m_Application->GetParameterByKey(appKeyList[i]);
+    if (param->GetRole() != Role_Output)
+      {
+      std::cerr << this->DisplayParameterHelp(param, appKeyList[i]);
+      }
     }
 
   std::cerr<<std::endl;
   //std::string cl(m_Application->GetCLExample());
 
+
+  std::cerr<<"Use -help param1 [... paramN] to see detailed documentation of those parameters."<<std::endl;
+  std::cerr<<std::endl;
+  
   std::cerr << "Examples: " << std::endl;
   std::cerr << m_Application->GetCLExample() << std::endl;
 
-}
+  if(longHelp)
+    {
+    std::cerr<<"Authors: "<<std::endl<<m_Application->GetDocAuthors() << std::endl;
+
+    std::cerr<<std::endl;
+    std::cerr<<"Limitations: "<<std::endl<<m_Application->GetDocLimitations() << std::endl;
+
+    std::cerr<<std::endl;
+    std::cerr<<"See also: "<<std::endl<<m_Application->GetDocSeeAlso() << std::endl;
+    std::cerr<<std::endl;
 
+    }  
+
+}
 
 void CommandLineLauncher::LoadTestEnv()
 {
   //Set seed for rand and itk mersenne twister
   //srand(1);
- // itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->SetSeed(121212);
+  // itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->SetSeed(121212);
 }
 
 
-std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & param, const std::string paramKey)
+std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & param, const std::string paramKey, bool longHelp)
 {
   // Display the type the type
   ParameterType type = m_Application->GetParameterType(paramKey);
@@ -768,47 +737,7 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer &
 
   std::ostringstream oss;
 
-  // When a parameter is mandatory :
-  // it must be set if :
-  //  - The param is root
-  //  - The param is not root and belonging to a Mandatory Group
-  //    which is activated
-  bool isMissing = false;
-  if (!m_Parser->IsAttributExists(std::string("-").append(paramKey), m_VExpression))
-    {
-    if (!m_Application->HasValue(paramKey))
-      {
-      if( param->GetMandatory() && param->GetRole() != Role_Output )
-        {
-        if( param->IsRoot() || param->GetRoot()->IsRoot())
-          {
-          // the parameter is a root or inside a group at root level
-          isMissing = true;
-          }
-        else
-          {
-          Parameter* currentParam = param->GetRoot();
-          while (!currentParam->IsRoot())
-            {
-            if (!currentParam->GetActive())
-              {
-              // the missing parameter is not on an active branch : we can ignore it
-              break;
-              }
-            currentParam = currentParam->GetRoot();
-
-            if (currentParam->IsRoot())
-              {
-              // the missing parameter is on an active branch : we need it
-              isMissing = true;
-              }
-            }
-          }
-        }
-      }
-    }
-
-  if( isMissing )
+  if( m_Application->IsParameterMissing(paramKey) )
     {
     oss << "MISSING ";
     }
@@ -818,7 +747,10 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer &
     }
 
   std::string bigKey = paramKey;
-  for(unsigned int i=0; i<m_MaxKeySize-paramKey.size(); i++)
+
+  unsigned int maxKeySize = GetMaxKeySize();
+  
+  for(unsigned int i=0; i<maxKeySize-paramKey.size(); i++)
     bigKey.append(" ");
 
   oss<< "-" << bigKey << " ";
@@ -924,6 +856,17 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer &
   oss<<")";
 
   oss << std::endl;
+
+  if(longHelp)
+    {
+    oss << "        ";
+    for(unsigned int i=0; i<maxKeySize;++i)
+      oss<<" ";
+    oss<<"                   ";
+    oss<<m_Application->GetParameterDescription(paramKey)<<std::endl;
+
+    }
+  
   return oss.str();
 }
 
@@ -1041,5 +984,24 @@ void CommandLineLauncher::DisplayOutputParameters()
   std::cout << oss.str() << std::endl;
 }
 
+unsigned int CommandLineLauncher::GetMaxKeySize() const
+{
+  const std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true);
+  const unsigned int nbOfParam = appKeyList.size();
+
+  unsigned int maxKeySize = std::string("progress").size();
+  
+  for (unsigned int i = 0; i < nbOfParam; i++)
+    {
+    if (m_Application->GetParameterRole(appKeyList[i]) != Role_Output)
+      {
+      if( maxKeySize < appKeyList[i].size() )
+        maxKeySize = appKeyList[i].size();
+      }
+    }
+  
+  return maxKeySize;
+}
+
 }
 }
diff --git a/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h b/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h
index f976019..ec1977b 100644
--- a/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h
+++ b/Modules/Wrappers/QtWidget/include/otbQtFileSelectionWidget.h
@@ -81,8 +81,13 @@ public:
   void SetIOMode( IOMode );
   IOMode GetIOMode() const;
 
+signals:
+  void FilenameChanged();
+
 protected slots:
   void SelectFile();
+  void CallFilenameChanged();
+  void SetFileName(const QString &);
 
 private:
   QtFileSelectionWidget(const QtFileSelectionWidget&); //purposely not implemented
diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexInputImageParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexInputImageParameter.h
index da397a5..2492830 100644
--- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexInputImageParameter.h
+++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexInputImageParameter.h
@@ -45,6 +45,9 @@ public:
   QtWidgetComplexInputImageParameter(ComplexInputImageParameter*, QtWidgetModel*);
   ~QtWidgetComplexInputImageParameter() ITK_OVERRIDE;
 
+  inline const QLineEdit* GetInput() const;
+  inline QLineEdit* GetInput();
+
 protected slots:
   bool SetFileName( const QString& value );
   void SelectFile();
@@ -65,6 +68,21 @@ private:
   QPushButton * m_Button;
 };
 
+inline
+const QLineEdit*
+QtWidgetComplexInputImageParameter
+::GetInput() const
+{
+  return m_Input;
+}
+
+inline
+QLineEdit*
+QtWidgetComplexInputImageParameter
+::GetInput()
+{
+  return m_Input;
+}
 
 }
 }
diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexOutputImageParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexOutputImageParameter.h
index af01fc7..1ec7b3f 100644
--- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexOutputImageParameter.h
+++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetComplexOutputImageParameter.h
@@ -45,11 +45,16 @@ public:
   QtWidgetComplexOutputImageParameter(ComplexOutputImageParameter*, QtWidgetModel*);
   ~QtWidgetComplexOutputImageParameter() ITK_OVERRIDE;
 
+  inline const QLineEdit* GetInput() const;
+  inline QLineEdit* GetInput();
+
   /** Get the PixelType*/
   //itkGetMacro(PixelType, int);
 
-protected slots:
+public slots:
   void SetFileName( const QString& value );
+
+protected slots:
   void SelectFile();
   void SetPixelType(int pixelType);
 
@@ -72,6 +77,21 @@ private:
 
 };
 
+inline
+const QLineEdit*
+QtWidgetComplexOutputImageParameter
+::GetInput() const
+{
+  return m_Input;
+}
+
+inline
+QLineEdit*
+QtWidgetComplexOutputImageParameter
+::GetInput()
+{
+  return m_Input;
+}
 
 }
 }
diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h
index 8c2a578..5c970fc 100644
--- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h
+++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetInputImageParameter.h
@@ -48,10 +48,16 @@ public:
   inline const QLineEdit* GetInput() const;
   inline QLineEdit* GetInput();
 
+signals:
+  void FileNameIsSet();
+
 protected slots:
-  bool SetFileName( const QString& value );
+  bool SetFileName(const QString& value);
   void SelectFile();
 
+private slots:
+  void OnEditingFinished();
+
 private:
   QtWidgetInputImageParameter(const QtWidgetInputImageParameter&); //purposely not implemented
   void operator=(const QtWidgetInputImageParameter&); //purposely not implemented
diff --git a/Modules/Wrappers/QtWidget/src/otbQtFileSelectionWidget.cxx b/Modules/Wrappers/QtWidget/src/otbQtFileSelectionWidget.cxx
index 818628a..44eb911 100644
--- a/Modules/Wrappers/QtWidget/src/otbQtFileSelectionWidget.cxx
+++ b/Modules/Wrappers/QtWidget/src/otbQtFileSelectionWidget.cxx
@@ -74,6 +74,7 @@ void QtFileSelectionWidget::DoCreateWidget()
   m_HLayout->addWidget(m_Checkbox);
 
   m_Input = new QLineEdit;
+  connect( m_Input, SIGNAL(editingFinished()), this, SLOT(CallFilenameChanged()) );
   m_HLayout->addWidget(m_Input);
 
   // Set up input text edit
@@ -115,9 +116,24 @@ QtFileSelectionWidget
   if( filename.isEmpty() )
     return;
 
-  m_Input->setText( filename  );
+  SetFileName(filename);
+}
+
+void
+QtFileSelectionWidget
+::CallFilenameChanged()
+{
+  emit FilenameChanged();
 }
 
+void
+QtFileSelectionWidget
+::SetFileName(const QString & filename)
+{
+  m_Input->setText( filename  );
+
+  emit FilenameChanged();
+}
 
 }
 
diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameListParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameListParameter.cxx
index ad92f51..da366b6 100644
--- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameListParameter.cxx
+++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputFilenameListParameter.cxx
@@ -169,6 +169,10 @@ QtWidgetInputFilenameListParameter::UpdateFilenameList()
     }
 
   emit Change();
+
+  // notify of value change
+  QString key(m_InputFilenameListParam->GetKey());
+  emit ParameterChanged(key);
 }
 
 
diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx
index 18e3a7a..8224946 100644
--- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx
+++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageListParameter.cxx
@@ -134,7 +134,7 @@ void QtWidgetInputImageListParameter::DoCreateWidget()
   fileSelection->setFixedHeight(30);
   fileLayout->addWidget(fileSelection);
   m_InputImageListParam->AddNullElement();
-  connect(fileSelection->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateImageList()));
+  connect(fileSelection, SIGNAL(FilenameChanged()), this, SLOT(UpdateImageList()));
 
   m_FileSelectionList.push_back(fileSelection);
 
@@ -160,16 +160,14 @@ void QtWidgetInputImageListParameter::DoCreateWidget()
 void
 QtWidgetInputImageListParameter::UpdateImageList()
 {
-  /* Adding a NullElement so to make the m_FileSelectionList and
-* m_InputImageList's ImageList are of same size. So that GetImageList().Size()
-* seems to be happy.
-  */
-  for(unsigned int i = m_InputImageListParam->GetImageList()->Size(); i < m_FileSelectionList.size(); i++)
+  // Adding a NullElement so to make the m_FileSelectionList and
+  // m_InputImageList's ImageList are of same size.
+  for(unsigned int i = m_InputImageListParam->Size(); i < m_FileSelectionList.size(); i++)
     {
     m_InputImageListParam->AddNullElement();
     }
 
-  for(unsigned int j = 0; j < m_InputImageListParam->GetImageList()->Size(); j++)
+  for(unsigned int j = 0; j < m_InputImageListParam->Size(); j++)
     {
     if(m_InputImageListParam->SetNthFileName(j, m_FileSelectionList[j]->GetFilename()) == false)
       {
@@ -321,8 +319,8 @@ QtWidgetInputImageListParameter::AddFile()
   /* No need of AddNullElement() here. Moved adding NullElement when updating the list  */
   //m_InputImageListParam->AddNullElement();
   connect(
-    fileSelection->GetInput(),
-    SIGNAL( textChanged( const QString & ) ),
+    fileSelection,
+    SIGNAL( FilenameChanged() ),
     this,
     SLOT( UpdateImageList() )
   );
@@ -374,7 +372,7 @@ QtWidgetInputImageListParameter::EraseFile()
   m_FileLayout->addWidget(fileSelection);
   m_FileSelectionList.push_back(fileSelection);
   m_InputImageListParam->AddNullElement();
-  connect(fileSelection->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateImageList()));
+  connect(fileSelection, SIGNAL(FilenameChanged()), this, SLOT(UpdateImageList()));
 
   QGroupBox *mainGroup = new QGroupBox();
   mainGroup->setLayout(m_FileLayout);
@@ -398,7 +396,7 @@ void QtWidgetInputImageListParameter::RecreateImageList()
     for(unsigned int j = 0; j < m_FileSelectionList.size(); j++)
       {
       m_InputImageListParam->AddFromFileName(m_FileSelectionList[j]->GetFilename());
-      connect(m_FileSelectionList[j]->GetInput(), SIGNAL(textChanged(const QString&)), this, SLOT(UpdateImageList()));
+      connect(m_FileSelectionList[j], SIGNAL(FilenameChanged()), this, SLOT(UpdateImageList()));
       }
 
     emit Change();
diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx
index 2f2b065..e41c35d 100644
--- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx
+++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputImageParameter.cxx
@@ -69,8 +69,8 @@ void QtWidgetInputImageParameter::DoCreateWidget()
   m_HLayout->setContentsMargins(0, 0, 0, 0);
   m_Input = new QLineEdit;
   m_Input->setToolTip( m_InputImageParam->GetDescription() );
-  connect( m_Input, SIGNAL(textChanged(const QString&)), this, SLOT(SetFileName(const QString&)) );
-  connect( m_Input, SIGNAL(textChanged(const QString&)), GetModel(), SLOT(NotifyUpdate()) );
+  connect( m_Input, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished()) );
+  connect( this, SIGNAL(FileNameIsSet()), GetModel(), SLOT(NotifyUpdate()) );
 
   m_HLayout->addWidget(m_Input);
 
@@ -105,7 +105,7 @@ QtWidgetInputImageParameter
   if( filename.isEmpty() )
     return;
 
-  if( !SetFileName( filename ) )
+  if( !SetFileName(filename) )
     {
     std::ostringstream oss;
 
@@ -119,8 +119,6 @@ QtWidgetInputImageParameter
 
     return;
     }
-
-  m_Input->setText( filename  );
 }
 
 bool QtWidgetInputImageParameter::SetFileName(const QString& value)
@@ -130,10 +128,12 @@ bool QtWidgetInputImageParameter::SetFileName(const QString& value)
   if( m_InputImageParam->SetFromFileName(
 	QFile::encodeName( value ).constData() ) == true )
     {
+    m_Input->setText( value  );
     // notify of value change
     QString key( m_InputImageParam->GetKey() );
 
     emit ParameterChanged(key);
+    emit FileNameIsSet();
     }
   else
     res = false;
@@ -141,5 +141,10 @@ bool QtWidgetInputImageParameter::SetFileName(const QString& value)
   return res;
 }
 
+void QtWidgetInputImageParameter::OnEditingFinished()
+{
+  SetFileName( m_Input->text() );
+}
+
 }
 }
diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputProcessXMLParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputProcessXMLParameter.cxx
index 256bb30..bd72303 100644
--- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputProcessXMLParameter.cxx
+++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputProcessXMLParameter.cxx
@@ -98,8 +98,6 @@ QtWidgetInputProcessXMLParameter
   if( filename.isEmpty() )
     return;
 
-  SetFileName( filename );
-
   m_Input->setText( filename  );
 }
 
@@ -113,7 +111,7 @@ void QtWidgetInputProcessXMLParameter::SetFileName(const QString& value)
     // notify of value change
     QString key( m_XMLParam->GetKey() );
     emit ParameterChanged(key);
-    GetModel()->UpdateAllWidgets();
+    GetModel()->GetApplication()->ForceInXMLParseFlag();
     }
 }
 
diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataListParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataListParameter.cxx
index 6f28cf7..fd8cdad 100644
--- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataListParameter.cxx
+++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetInputVectorDataListParameter.cxx
@@ -168,6 +168,10 @@ QtWidgetInputVectorDataListParameter::UpdateVectorDataList()
     }
 
   emit Change();
+
+  // notify of value change
+  QString key(m_InputVectorDataListParam->GetKey());
+  emit ParameterChanged(key);
 }
 
 
diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListViewParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListViewParameter.cxx
index 4ed51d0..7f7b3ab 100644
--- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListViewParameter.cxx
+++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetListViewParameter.cxx
@@ -40,13 +40,31 @@ QtWidgetListViewParameter::~QtWidgetListViewParameter()
 
 void QtWidgetListViewParameter::DoUpdateGUI()
 {
-  size_t numSelected = m_ListViewParam->GetSelectedItems().size();
+  bool resetNeeded = false;
+  if (m_ListViewParam->GetNbChoices() != (unsigned int) m_ListView->count())
+    {
+    resetNeeded = true;
+    }
+  else
+    {
+    for (unsigned int i = 0; i < m_ListViewParam->GetNbChoices(); ++i)
+      {
+      QString key = m_ListViewParam->GetChoiceName(i).c_str();
+      if (key != m_ListView->item(i)->text() )
+        {
+        resetNeeded = true;
+        break;
+        }
+      }
+    }
 
-  //Clear m_ListView add re-add choices only if no items selected.
-  //Otherwise results in mantis #1025
+  // save selected choices
+  std::vector<int> selected = m_ListViewParam->GetSelectedItems();
 
-  if(numSelected < 1)
+  //Beware of mantis #1025 and #1403
+  if(resetNeeded)
     {
+    m_SelectedItems.clear();
     while(m_ListView->takeItem(0))
       {
       m_ListView->removeItemWidget( m_ListView->takeItem(0) );
@@ -55,18 +73,30 @@ void QtWidgetListViewParameter::DoUpdateGUI()
     for (unsigned int i = 0; i < m_ListViewParam->GetNbChoices(); ++i)
       {
       // Add listBox items
-      QString key = m_ListViewParam->GetChoiceKey(i).c_str();
+      QString key = m_ListViewParam->GetChoiceName(i).c_str();
       m_ListView->addItem( key);
       }
     }
 
-  //I can't find any reason for calling m_ListView->setCurrentRow(value) in this
-  //case because QListWidget is a MultiSelection widget.
-  if (m_ListView->selectionMode() == QAbstractItemView::SingleSelection)
+  // test if selection has to be updated
+  if (selected != m_SelectedItems)
     {
-    unsigned int value = m_ListViewParam->GetValue( );
-    m_ListView->setCurrentRow(value);
+    for (int idx = 0; idx < m_ListView->count(); ++idx)
+      {
+      // check if this item is selected
+      bool isSelected = false;
+      for (unsigned int k = 0 ; k < selected.size() ; ++k)
+        {
+        if (selected[k] == idx)
+          {
+          isSelected = true;
+          break;
+          }
+        }
+      m_ListView->item(idx)->setSelected(isSelected);
+      }
     }
+
 }
 
 void QtWidgetListViewParameter::DoCreateWidget()
@@ -100,7 +130,7 @@ void QtWidgetListViewParameter::SelectedItems()
   m_SelectedItems.clear();
 
   // Item changed (check if selected or not)
-  for (int idx = 0; idx < m_ListView->count(); ++idx)
+  for (int idx = 0; idx < m_ListView->count() && idx < (int) m_ListViewParam->GetNbChoices(); ++idx)
     {
     if (m_ListView->item(idx)->isSelected())
       {
diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx
index 30f0da4..1fa1e28 100644
--- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx
+++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx
@@ -23,6 +23,8 @@
 //Use to create command line from the application parameters
 #include "otbWrapperOutputProcessXMLParameter.h"
 
+using std::string;
+
 namespace otb
 {
 
@@ -44,7 +46,6 @@ QtWidgetModel
   m_LogOutput = QtLogOutput::New();
 
   // Attach log output to the Application logger
-  m_Application->GetLogger()->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE);
   m_Application->GetLogger()->AddLogOutput(m_LogOutput);
 
   m_Timer = new QTimer(this);
@@ -266,41 +267,44 @@ AppliThread
 {
   int result = -1;
 
-  //
-  // Try to execute OTB-application.
   try
-    {
+  {
     result = m_Application->ExecuteAndWriteOutput();
-    }
-  //
-  // Catch standard exceptions.
-  catch( std::exception& err )
-    {
-    std::ostringstream message;
-
-    message
-      << "The following error occurred during OTB-application execution: "
-      << err.what()
-      << std::endl;
-
-    m_Application->GetLogger()->Write( itk::LoggerBase::FATAL, message.str() );
-
-    // Signal exception.
+  }
+  catch(otb::ApplicationException& err)
+  {
+    // These are thrown with otbAppLogFATAL, a macro which logs a user
+    // friendly error message before throwing. So log exception details only
+    // in debug.
+    m_Application->GetLogger()->Debug("Caught otb::ApplicationException during application execution:\n");
+    m_Application->GetLogger()->Debug(string(err.what()) + "\n");
     emit ExceptionRaised( err.what() );
-    }
-  //
-  // Catch other exceptions.
-  catch( ... )
-    {
-    m_Application->GetLogger()->Write(
-      itk::LoggerBase::FATAL,
-      "An unknown exception has been raised during OTB-application execution"
-    );
+  }
+  catch(otb::ImageFileReaderException& err)
+  {
+    m_Application->GetLogger()->Debug("Caught otb::ImageFileReaderException during application execution:\n");
+    m_Application->GetLogger()->Debug(string(err.what()) + "\n");
+    m_Application->GetLogger()->Fatal(string("Cannot open image ") + err.m_Filename + string(". ") + err.GetDescription() + string("\n"));
+    emit ExceptionRaised( err.what() );
+  }
+  catch(itk::ExceptionObject& err)
+  {
+    m_Application->GetLogger()->Debug("Caught itk::ExceptionObject during application execution:\n");
+    m_Application->GetLogger()->Debug(string(err.what()) + "\n");
+    m_Application->GetLogger()->Fatal(string(err.GetDescription()) + "\n");
+    emit ExceptionRaised( err.what() );
+  }
+  catch(std::exception& err)
+  {
+    m_Application->GetLogger()->Fatal(string("Caught std::exception during application execution: ") + err.what() + "\n");
+    emit ExceptionRaised( err.what() );
+  }
+  catch(...)
+  {
+    m_Application->GetLogger()->Fatal("Caught unknown exception during application execution.\n");
+    emit ExceptionRaised("Unknown exception.");
+  }
 
-    // Signal exception.
-    emit ExceptionRaised( "Exception raised by OTB-application." );
-    }
-  //
   // Signal OTB-application has ended with result status.
   emit ApplicationExecutionDone( result );
 }
diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringListParameter.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringListParameter.cxx
index 7de01b1..04667ea 100644
--- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringListParameter.cxx
+++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetStringListParameter.cxx
@@ -138,6 +138,9 @@ QtWidgetStringListParameter::UpdateStringList()
 
   // notify model text changed
   emit Change();
+
+  QString key( m_StringListParam->GetKey() );
+  emit ParameterChanged(key);
 }
 
 
diff --git a/Modules/Wrappers/SWIG/src/itkBase.i b/Modules/Wrappers/SWIG/src/itkBase.i
index b514c3c..2a15719 100644
--- a/Modules/Wrappers/SWIG/src/itkBase.i
+++ b/Modules/Wrappers/SWIG/src/itkBase.i
@@ -29,6 +29,10 @@
 %exception {
   try {
     $action
+  } catch(otb::ImageFileReaderException& err) {
+    std::ostringstream oss;
+    oss << "Cannot open image " << err.m_Filename + ". " + err.GetDescription();
+    SWIG_exception( SWIG_RuntimeError, oss.str().c_str() );
   } catch( itk::ExceptionObject &ex ) {
     std::ostringstream oss;
     oss << "Exception thrown in otbApplication $symname: " << ex.what();
diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i
index 4f548c7..72adde8 100644
--- a/Modules/Wrappers/SWIG/src/otbApplication.i
+++ b/Modules/Wrappers/SWIG/src/otbApplication.i
@@ -576,7 +576,7 @@ class ApplicationProxy(object):
 		    if attr in key_list:
 		      return self.GetParameterValue(attr.lower())
 		    else:
-		      raise AttributeError
+		      raise AttributeError("Parameter {} does not exist in the application.".format(attr.lower()))
 
 		def __setattr__(self, attr, value):
 		  """
@@ -593,7 +593,7 @@ class ApplicationProxy(object):
 		    if attr in key_list:
 		      self.SetParameterValue(attr.lower(), value)
 		    else:
-		      raise AttributeError
+		      raise AttributeError("Parameter {} does not exist in the application.".format(attr.lower()))
 
     }
 }
diff --git a/Modules/Wrappers/SWIG/test/python/CMakeLists.txt b/Modules/Wrappers/SWIG/test/python/CMakeLists.txt
index 6f53c52..2342234 100644
--- a/Modules/Wrappers/SWIG/test/python/CMakeLists.txt
+++ b/Modules/Wrappers/SWIG/test/python/CMakeLists.txt
@@ -102,13 +102,12 @@ add_test( NAME pyTvBandMathInXML
   COMMAND ${TEST_DRIVER} Execute
   ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
   PythonInXMLTest
-  ${INPUTDATA}/pyTvBandMathInXML.xml
-  ${OTB_DATA_ROOT}/Input/verySmallFSATSW_r.tif
-  ${OTB_DATA_ROOT}/Input/verySmallFSATSW_nir.tif
-  ${OTB_DATA_ROOT}/Input/verySmallFSATSW.tif
+  ${TEMP}/pyTvBandMathOutXML.xml
   ${TEMP}/pyTvBandMathInXML.tif
   )
 
+set_tests_properties(pyTvBandMathInXML PROPERTIES DEPENDS pyTvBandMathOutXML)
+
 add_test( NAME pyTvNumpyIO
   COMMAND ${TEST_DRIVER} Execute
   ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
diff --git a/Modules/Wrappers/SWIG/test/python/PythonInXMLTest.py b/Modules/Wrappers/SWIG/test/python/PythonInXMLTest.py
index 7344384..8eb3133 100644
--- a/Modules/Wrappers/SWIG/test/python/PythonInXMLTest.py
+++ b/Modules/Wrappers/SWIG/test/python/PythonInXMLTest.py
@@ -31,8 +31,5 @@ def test(otb, argv):
 	app.SetParameterString("inxml", argv[1])
 	app.UpdateParameters()
 
-	imagelist = argv[2:-1]
-	app.SetParameterStringList("il", imagelist, True)
-
 	app.SetParameterString("out"  , argv[-1])
 	app.ExecuteAndWriteOutput()
diff --git a/Packaging/CMakeLists.txt b/Packaging/CMakeLists.txt
new file mode 100644
index 0000000..c7f84df
--- /dev/null
+++ b/Packaging/CMakeLists.txt
@@ -0,0 +1,238 @@
+#
+# 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.
+#
+
+cmake_minimum_required(VERSION 3.3.0)
+
+project(OTBPackaging)
+
+include(CMakeParseArguments)
+include(CMakeDetermineSystem)
+include(GetPrerequisites)
+include(CTest)
+
+#setting this variable prints a lot of debug information
+set(PKG_DEBUG OFF)
+#set( PKG_DEBUG 1)
+
+set(CMAKE_BUILD_TYPE    Release)
+
+#user-defined variables and option
+option(OTB_WRAP_PYTHON "include python bindings in package" ON)
+set(SUPERBUILD_BINARY_DIR "" CACHE PATH "path to superbuild binary directory")
+set(SUPERBUILD_INSTALL_DIR "" CACHE PATH "path to superbuild install directory")
+set(DOWNLOAD_LOCATION "" CACHE PATH "path to superbuild download archives")
+
+#variables based on above user-defined variables 
+set(OTB_BINARY_DIR            "${SUPERBUILD_BINARY_DIR}/OTB/build")
+set(QT_TRANSLATIONS_DIR       "${SUPERBUILD_INSTALL_DIR}/translations")
+get_filename_component(PACKAGE_OTB_SRC_DIR ${OTBPackaging_SOURCE_DIR} PATH)
+set(SUPERBUILD_SOURCE_DIR     "${PACKAGE_OTB_SRC_DIR}/SuperBuild")
+
+
+set(LINUX FALSE)
+if( "${CMAKE_SYSTEM_NAME}"  MATCHES "Linux")
+  set(LINUX TRUE)
+endif()
+
+if(OTB_WRAP_PYTHON AND NOT PYTHON_EXECUTABLE)
+  find_package(PythonInterp REQUIRED)
+endif()
+
+find_program(FILE_COMMAND NAMES  "file")
+find_program(READLINK NAMES "readlink")
+find_program(ZIP_EXECUTABLE NAMES 7z 7za)
+
+#install prefix is same as SUPERBUILD_INSTALL_DIR. could be changed later
+set(CMAKE_INSTALL_PREFIX "${SUPERBUILD_INSTALL_DIR}")
+
+#set CMAKE_MODULE_PATH to be the current source directory.
+# This will allow to include all cmake files without full path and .cmake extension!
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+#include superbuild_macro for get_version()
+include(${SUPERBUILD_SOURCE_DIR}/CMake/SuperBuild_Macro.cmake)
+
+#include superbuild_macro for OTB_TARGET_SYSTEM_ARCH_IS_X64 value
+include(${PACKAGE_OTB_SRC_DIR}/CMake/OTBCheckTargetSystemArch.cmake)
+
+# get itk version from External_itk.cmake if not on mingw
+# because mxe has different version
+get_version(
+  INPUT_FILE   "${SUPERBUILD_SOURCE_DIR}/CMake/External_itk.cmake"
+  MATCH_STRINGS "SB_ITK_VERSION_MAJOR" "SB_ITK_VERSION_MINOR"
+  PREFIX PKG
+  )
+set(PKG_ITK_SB_VERSION "${PKG_SB_ITK_VERSION_MAJOR}.${PKG_SB_ITK_VERSION_MINOR}")
+
+#get version of OTB from source_dir/CMakeLists.txt
+get_version(
+  INPUT_FILE   "${PACKAGE_OTB_SRC_DIR}/CMakeLists.txt"
+  MATCH_STRINGS "OTB_VERSION_MAJOR" "OTB_VERSION_MINOR" "OTB_VERSION_PATCH"
+  PREFIX PKG
+  )
+
+set(PKG_OTB_VERSION_STRING ${PKG_OTB_VERSION_MAJOR}.${PKG_OTB_VERSION_MINOR}.${PKG_OTB_VERSION_PATCH})
+
+set(PACKAGE_LONG_NAME OrfeoToolBox)
+set(NAME_SUFFIX "" CACHE STRING "extra suffix for package name")
+set(PACKAGE_NAME OTB)
+if(NAME_SUFFIX)
+  set(PACKAGE_NAME OTB${NAME_SUFFIX})
+endif()
+if(APPLE)
+  set(PACKAGE_PLATFORM_NAME "Darwin")
+elseif(WIN32)
+  set(PACKAGE_PLATFORM_NAME "win")
+elseif(LINUX)
+  set(PACKAGE_PLATFORM_NAME "Linux")
+endif()
+set(PACKAGE_ARCH "32")
+if(OTB_TARGET_SYSTEM_ARCH_IS_X64)
+set(PACKAGE_ARCH "64")
+endif()
+
+# This directory is important.
+# We stage/keep files that goes into final package in this directory
+set(PKG_STAGE_DIR ${PACKAGE_NAME}-${PKG_OTB_VERSION_STRING}-${PACKAGE_PLATFORM_NAME}${PACKAGE_ARCH})
+
+set(PATCHELF_PROGRAM "${CMAKE_BINARY_DIR}/PATCHELF/src/patchelf/src/patchelf")
+include(External_patchelf)
+
+include(PackageGlobals)
+
+# Note that MANY or ALL of function use global variables set in this CMakeLists.txt
+# The order in which the functions in these "included" files are called is only important.
+# We tried not to share variables which are created inside functions or macro. In such cases,
+# function return the value. 
+
+include(setif_value_in_list)
+include(get_variables_ending_with)
+include(clear_cmakecache_variables)
+include(check_cmake_variables)
+include(configure_loader)
+include(search_library)
+include(prepare_search_dirs)
+include(prepare_file_list)
+include(process_file_recurse)
+include(install_without_message)
+include(install_rule)
+include(isfile_symlink)
+include(detect_using_file_command)
+include(install_otbapp_wrapper_scripts)
+include(cleanup_package)
+
+# below functions include many install commands which are installing
+# files under PKG_STAGE_DIR
+include(install_include_dirs)
+include(install_importlibs)
+include(install_python_bindings)
+include(install_share_dirs)
+include(install_cmake_files)
+include(install_qtdev_files)
+include(install_vstudio_files)
+include(installer_files)
+include(create_package)
+
+configure_loader(LOADER_PROGRAM LOADER_ARGS LOADER_REGEX)
+
+
+# creation of package is different from windows and unix like
+# WE KEEP THIS VARIABLE HERE BECAUSE IT IS USED IN
+# cleanup_package, create_package, testing.cmake
+# and check_cmake_variables
+
+# THIS IS JUST TO AVOID DUPLICATION
+if(WIN32)
+  set(PACKAGE_OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PKG_STAGE_DIR}.zip")
+else()
+  set(PACKAGE_OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PKG_STAGE_DIR}.run")
+endif()
+
+check_cmake_variables()
+
+cleanup_package()
+
+set(HAVE_QT4 FALSE CACHE INTERNAL "HAVE_QT4")
+if(EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/otbApplicationLauncherQt${EXE_EXT}")
+  set(HAVE_QT4 TRUE)
+endif()
+
+set(HAVE_MVD FALSE  CACHE INTERNAL "HAVE_MVD")
+if(EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/monteverdi${EXE_EXT}")
+  set(HAVE_MVD TRUE)
+endif()
+
+set(HAVE_PYTHON FALSE CACHE INTERNAL "HAVE_PYTHON")
+if(EXISTS "${SUPERBUILD_INSTALL_DIR}/lib/otb/python/_otbApplication${PYMODULE_EXT}")
+  set(HAVE_PYTHON TRUE)
+endif()
+
+  #only for *nix
+if(UNIX)
+  file(WRITE ${CMAKE_BINARY_DIR}/make_symlinks   "#!/bin/sh\n")
+endif()
+
+#remove all *_USED|*_RESOLVED variables from CMakeCache.txt
+clear_cmakecache_variables()
+
+set(PKG_SEARCHDIRS)
+prepare_search_dirs(PKG_SEARCHDIRS)
+
+set(PKG_PEFILES)
+prepare_file_list(PKG_PEFILES)
+foreach(pfile ${PKG_PEFILES})
+  process_file_recurse(${pfile})
+endforeach()
+
+install_include_dirs()
+
+install_importlibs()
+
+install_python_bindings()
+
+install_share_dirs()
+
+install_cmake_files()
+
+install_qtdev_files()
+
+install_vstudio_files()
+
+installer_files()
+
+create_package()
+
+if(BUILD_TESTING)
+  enable_testing()
+  include(testing.cmake)
+endif()
+
+
+
+
+#TODO: dummy targets. to be removed after merge
+add_custom_target(
+    PACKAGE-OTB
+    COMMAND
+    "${CMAKE_COMMAND}" --build . --target install
+    WORKING_DIRECTORY
+    "${CMAKE_BINARY_DIR}"
+    COMMENT "dummy target PACKAGE-OTB"
+    )
diff --git a/Modules/Applications/AppFiltering/otb-module.cmake b/Packaging/CTestConfig.cmake
similarity index 66%
copy from Modules/Applications/AppFiltering/otb-module.cmake
copy to Packaging/CTestConfig.cmake
index d33a9ee..ac2fbdc 100644
--- a/Modules/Applications/AppFiltering/otb-module.cmake
+++ b/Packaging/CTestConfig.cmake
@@ -18,20 +18,11 @@
 # limitations under the License.
 #
 
-set(DOCUMENTATION "Basic filters application.")
-
-otb_module(OTBAppFiltering
-  DEPENDS
-    OTBImageNoise
-    OTBImageManipulation
-    OTBITK
-    OTBApplicationEngine
-    OTBImageBase
-
-  TEST_DEPENDS
-    OTBTestKernel
-    OTBCommandLine
-
-  DESCRIPTION
-    "${DOCUMENTATION}"
-)
+set(CTEST_PROJECT_NAME "OTB")
+set(CTEST_NIGHTLY_START_TIME "20:00:00 CEST")
+set(CTEST_DROP_METHOD "https")
+set(CTEST_DROP_SITE "dash.orfeo-toolbox.org")
+set(CTEST_DROP_LOCATION "/submit.php?project=OTB")
+set(CTEST_DROP_SITE_CDASH TRUE)
+set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 4096)
+set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 4096)
diff --git a/Packaging/External_patchelf.cmake b/Packaging/External_patchelf.cmake
new file mode 100644
index 0000000..d168763
--- /dev/null
+++ b/Packaging/External_patchelf.cmake
@@ -0,0 +1,61 @@
+#
+# 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(PATCHELF_PREFIX_DIR "${CMAKE_BINARY_DIR}/PATCHELF")
+set(PATCHELF_SOURCE_DIR  "${PATCHELF_PREFIX_DIR}/src/patchelf")
+# PATCHELF_BINARY_DIR is same as PATCHELF_SOURCE_DIR
+set(PATCHELF_INSTALL_DIR "${PATCHELF_PREFIX_DIR}/install/patchelf")
+set(PATCHELF_STAMP_DIR   "${PATCHELF_PREFIX_DIR}/stamp/patchelf")
+set(PATCHELF_TMP_DIR     "${PATCHELF_PREFIX_DIR}/tmp/patchelf")
+
+if( __EXTERNAL_PATCHELF__)
+  return()
+else()
+  set(__EXTERNAL_PATCHELF__ 1)
+endif()
+
+if(WIN32 OR APPLE)
+  add_custom_target(PATCHELF)
+  return()
+endif()
+
+include(ExternalProject)
+
+set(PATCHELF_ENV_COMMAND env CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} CXXFLAGS=-static)
+
+ExternalProject_Add(PATCHELF
+  PREFIX "${PATCHELF_PREFIX_DIR}"
+  URL                 "http://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2"
+  URL_MD5             d02687629c7e1698a486a93a0d607947
+  DOWNLOAD_DIR        "${DOWNLOAD_LOCATION}"
+  SOURCE_DIR          "${PATCHELF_SOURCE_DIR}"
+  BINARY_DIR          "${PATCHELF_SOURCE_DIR}"
+  INSTALL_DIR         "${PATCHELF_INSTALL_DIR}"
+  STAMP_DIR           "${PATCHELF_STAMP_DIR}"
+  TMP_DIR             "${PATCHELF_TMP_DIR}"
+  CONFIGURE_COMMAND
+  ${PATCHELF_ENV_COMMAND}
+  ${PATCHELF_SOURCE_DIR}/configure
+  INSTALL_COMMAND ""
+  LOG_DOWNLOAD 1
+  LOG_CONFIGURE 1
+  LOG_BUILD 1
+  LOG_INSTALL 1
+  )
+
diff --git a/Packaging/Files/Monteverdi.icns b/Packaging/Files/Monteverdi.icns
new file mode 100644
index 0000000..9f7645a
Binary files /dev/null and b/Packaging/Files/Monteverdi.icns differ
diff --git a/Packaging/Files/OTB Project.zip b/Packaging/Files/OTB Project.zip
new file mode 100644
index 0000000..5e5b6d6
Binary files /dev/null and b/Packaging/Files/OTB Project.zip differ
diff --git a/Packaging/Files/build_examples.cmake b/Packaging/Files/build_examples.cmake
new file mode 100644
index 0000000..46404dd
--- /dev/null
+++ b/Packaging/Files/build_examples.cmake
@@ -0,0 +1,97 @@
+#
+# 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(NOT SRC_DIR)
+  message(FATAL_ERROR "SRC_DIR is not set")
+endif()
+
+set(PKG_DIR)
+get_filename_component(PKG_DIR ${CMAKE_CURRENT_LIST_DIR} PATH)
+set(TEST_DIR ${PKG_DIR}/ex_build)
+
+if(EXISTS "${TEST_DIR}")
+  execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR})
+  execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory   ${TEST_DIR})
+else()
+  execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory   ${TEST_DIR})
+endif()
+message("TEST_DIR=${TEST_DIR}")
+message("PKG_DIR=${PKG_DIR}")
+message("SRC_DIR=${SRC_DIR}")
+
+set(cmake_gen)
+if(WIN32)
+  set(cmake_gen "-GNinja")
+endif()
+
+execute_process(
+  COMMAND ${CMAKE_COMMAND}
+  -DCMAKE_INSTALL_PREFIX=${PKG_DIR}
+  -DCMAKE_BUILD_TYPE=RelWithDebInfo
+  ${cmake_gen}
+  ${SRC_DIR}
+  WORKING_DIRECTORY ${TEST_DIR}
+  RESULT_VARIABLE configure_rv
+  OUTPUT_VARIABLE configure_ov
+  ERROR_VARIABLE  configure_ov
+  )
+
+if( configure_rv )
+  message(FATAL_ERROR "Configure FAILED. configure_ov:\n${configure_ov}")
+  return()
+else()
+  message("Configure PASSED. configure_ov:\n${configure_ov}")
+endif()
+
+# If you want to test building a third targert, use foreach.
+# the code is written in a way that it is easy to stuff these two
+# into a cmake foreach
+execute_process(COMMAND ${CMAKE_COMMAND}
+  --build ${TEST_DIR}
+  --config RelWithDebInfo
+  --target HelloWorldOTB
+  WORKING_DIRECTORY ${TEST_DIR}
+  RESULT_VARIABLE build_HelloWorldOTB_rv
+  OUTPUT_VARIABLE build_HelloWorldOTB_ov
+  ERROR_VARIABLE  build_HelloWorldOTB_ov
+  )
+
+if( build_HelloWorldOTB_rv )
+  message(FATAL_ERROR "Build FAILED. build_HelloWorldOTB_ov:\n${build_HelloWorldOTB_ov}")
+  return()
+else()
+  message("Build PASSED. build_HelloWorldOTB_ov:\n${build_HelloWorldOTB_ov}")
+endif()
+
+execute_process(COMMAND ${CMAKE_COMMAND}
+  --build ${TEST_DIR}
+  --config RelWithDebInfo
+  --target Pipeline
+  WORKING_DIRECTORY ${TEST_DIR}
+  RESULT_VARIABLE build_Pipeline_rv
+  OUTPUT_VARIABLE build_Pipeline_ov
+  ERROR_VARIABLE  build_Pipeline_ov
+  )
+
+if( build_Pipeline_rv )
+  message(FATAL_ERROR "Build FAILED. build_Pipeline_ov=${build_Pipeline_ov}")
+  return()
+else()
+  message("Build PASSED. build_Pipeline_ov=${build_Pipeline_ov}")  
+endif()
diff --git a/Packaging/Files/linux_pkgsetup.in b/Packaging/Files/linux_pkgsetup.in
new file mode 100644
index 0000000..93d5a6a
--- /dev/null
+++ b/Packaging/Files/linux_pkgsetup.in
@@ -0,0 +1,96 @@
+#!/bin/sh
+#
+# 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 -e
+
+# verify basic tools are here
+which sh >/dev/null 2>&1 || ret=$?
+if [ ! -z "$ret" ] ; then echo "ERROR: Missing tool 'which'"; exit 1 ; fi
+for tool in dirname find file grep cut sed chmod cat readlink ; do
+  if [ -z "$(which $tool)" ] ; then
+    echo "ERROR: Missing tool '${tool}'"
+    echo "Please install it and make sure it can be found from PATH"
+    exit 1;
+  fi
+done
+
+DIRNAME_0=$(dirname "$0")
+cd  "$DIRNAME_0"
+
+# NOTE: $OUT_DIR is also used in make_sylinks script (see below)
+# Avoid any pre-mature optimization on variable names here.
+
+OUT_DIR=$(pwd)
+
+PATCH_ELF_EXE="$OUT_DIR/patchelf"
+
+#do not move below block. it must be before "unset LD_LIBRARY_PATH" code
+#check if we have any python bindings
+if [ -f "$OUT_DIR/lib/python/_otbApplication.so" ] ; then
+    chmod +x "$OUT_DIR/setup_python.sh"
+    ./setup_python.sh || setup_python_ret=$?
+fi
+
+# No no interference with LD_LIBRARY_PATH
+unset LD_LIBRARY_PATH
+
+# we remove files in $OUT_DIR/lib/gtk which we CANNOT add new rpath
+BINARY_FILES=$(find "$OUT_DIR/lib" "$OUT_DIR/bin" -type f -exec file {} \; | grep -v '/lib/gtk/' | grep -i elf|cut -f1 -d':')
+# run patchelf
+for bin_file in $BINARY_FILES; do
+    #echo "adding rpath to $bin_file"
+    if [ -f "$bin_file" ]; then
+        "$PATCH_ELF_EXE" "--set-rpath" "$OUT_DIR/lib" "$bin_file"
+    fi
+done
+
+#install uninstall_otb script
+echo "Installing uninstall script for OTB 'tools/uninstall_otb.sh'"
+sed -i -E "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/tools/uninstall_otb.sh"
+chmod +x "$OUT_DIR/tools/uninstall_otb.sh"
+
+sed -i -E  "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/monteverdi.sh"
+chmod +x "$OUT_DIR/monteverdi.sh"
+
+sed -i -E "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/mapla.sh"
+chmod +x "$OUT_DIR/mapla.sh"
+
+sed -i -E "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/otbenv.profile"
+chmod +x "$OUT_DIR/otbenv.profile"
+
+sed -i  -E "s,../lib,$OUT_DIR/lib,g" "$OUT_DIR/bin/qt.conf"
+
+#echo "Creating symbolic links..."
+. ./make_symlinks
+
+rm -f  "$OUT_DIR/make_symlinks"
+
+printf %s\\n ""
+printf %s\\n "source './otbenv.profile' file to set required environment variables"
+printf %s\\n "eg: '. $OUT_DIR/otbenv.profile'"
+printf %s\\n "You can also copy above line to  ~/.profile to keep changes permanently!"
+printf %s\\n "More documentation can be found in $OUT_DIR/README"
+
+
+#rm -f  "$OUT_DIR/make_symlinks"
+rm -f  "$OUT_DIR/patchelf"
+rm -f  "$OUT_DIR/setup_python.sh"
+rm -f  "$OUT_DIR/pkgsetup"
+
diff --git a/Packaging/Files/macx_pkgsetup.in b/Packaging/Files/macx_pkgsetup.in
new file mode 100755
index 0000000..7c4b5c8
--- /dev/null
+++ b/Packaging/Files/macx_pkgsetup.in
@@ -0,0 +1,120 @@
+#!/bin/sh
+#
+# 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 -e
+
+# verify basic tools are here (install_name_tool is specific macOS)
+which sh >/dev/null 2>&1 || ret=$?
+if [ ! -z "$ret" ] ; then echo "ERROR: Missing tool 'which'"; exit 1 ; fi
+for tool in dirname find file grep cut sed chmod cat readlink install_name_tool ; do
+  if [ -z "$(which $tool)" ] ; then
+    echo "ERROR: Missing tool '${tool}'"
+    echo "Please install it and make sure it can be found from PATH"
+    exit 1;
+  fi
+done
+
+DIRNAME_0=$(dirname "$0")
+cd  "$DIRNAME_0" || exit 1
+
+# NOTE: $OUT_DIR is also used in make_sylinks script (see below)
+# Avoid any pre-mature optimization on variable names here.
+
+OUT_DIR=$(pwd)
+
+#do not move below 3 lines. it must be before "unset LD_LIBRARY_PATH" code
+if [ -f "$OUT_DIR/lib/python/_otbApplication.so" ] ; then
+  chmod +x "$OUT_DIR/setup_python.sh"
+  ./setup_python.sh || setup_python_ret=$?
+fi
+
+# no interference with DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH
+unset DYLD_LIBRARY_PATH
+unset DYLD_FALLBACK_LIBRARY_PATH
+
+echo "Configuring..."
+
+LIB_FILES=$(find "$OUT_DIR/lib" -type f -exec file {} \; | grep -i "Mach-O"|cut -d ':' -f1)
+BIN_FILES=$(find "$OUT_DIR/bin" -type f -exec file {} \; | grep -i "Mach-O*.*executable"|cut -d ':' -f1)
+# run install_name_tool
+for input_file in $LIB_FILES $BIN_FILES; do
+    #echo "adding rpath to $OUT_DIR/$lib_file"
+    if [ -f "$input_file" ]; then
+      input_file_old_rpaths=$(otool -l "$input_file" | grep -A 3 "LC_RPATH" | grep -oE 'path .* \(offset' | cut -d ' ' -f 2)
+      for rpath_old in $input_file_old_rpaths; do
+        install_name_tool "-delete_rpath" "$rpath_old" "$input_file"
+      done
+      install_name_tool "-add_rpath" "$OUT_DIR/lib" "$input_file"
+    fi
+done
+
+#install uninstall_otb script
+echo "Installing uninstall script for OTB 'tools/uninstall_otb.sh'"
+sed -i "" "s,mapla.sh,Mapla.app -r,g" "$OUT_DIR/tools/uninstall_otb.sh"
+sed -i "" "s,monteverdi.sh,Monteverdi.app -r,g" "$OUT_DIR/tools/uninstall_otb.sh"
+sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/tools/uninstall_otb.sh"
+chmod +x "$OUT_DIR/tools/uninstall_otb.sh"
+
+mkdir "$OUT_DIR/template.app/Contents/MacOS"
+mkdir "$OUT_DIR/template.app/Contents/Resources"
+cp -r "$OUT_DIR/template.app" "$OUT_DIR/Mapla.app"
+cp -r "$OUT_DIR/template.app" "$OUT_DIR/Monteverdi.app"
+mv "$OUT_DIR/mapla.sh" "Mapla.app/Contents/MacOS/Mapla"
+mv "$OUT_DIR/monteverdi.sh" "Monteverdi.app/Contents/MacOS/Monteverdi"
+rm -fr "template.app"
+LONG_VERSION_STRING=@Monteverdi_VERSION_MAJOR at .@Monteverdi_VERSION_MINOR at .@Monteverdi_VERSION_PATCH@
+SHORT_VERSION_STRING=@Monteverdi_VERSION_MAJOR at .@Monteverdi_VERSION_MINOR@
+#sed qt.conf
+sed -i "" "s,../lib,$OUT_DIR/lib,g" "$OUT_DIR/bin/qt.conf"
+
+cp "$OUT_DIR/bin/qt.conf" "$OUT_DIR/Mapla.app/Contents/Resources/qt.conf"
+cp "$OUT_DIR/Monteverdi.icns" "Mapla.app/Contents/Resources/"
+sed -i "" "s,STARTUP_FILE,Mapla,g" "Mapla.app/Contents/Info.plist"
+sed -i "" "s,LONG_VERSION,$LONG_VERSION_STRING,g" "Mapla.app/Contents/Info.plist"
+sed -i "" "s,SHORT_VERSION,$SHORT_VERSION_STRING,g" "Mapla.app/Contents/Info.plist"
+sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/Mapla.app/Contents/MacOS/Mapla"
+chmod +x "$OUT_DIR/Mapla.app/Contents/MacOS/Mapla"
+
+cp "$OUT_DIR/bin/qt.conf" "$OUT_DIR/Monteverdi.app/Contents/Resources/qt.conf"
+cp "$OUT_DIR/Monteverdi.icns" "Monteverdi.app/Contents/Resources/"
+sed -i "" "s,STARTUP_FILE,Monteverdi,g" "Monteverdi.app/Contents/Info.plist"
+sed -i "" "s,LONG_VERSION,$LONG_VERSION_STRING,g" "Monteverdi.app/Contents/Info.plist"
+sed -i "" "s,SHORT_VERSION,$SHORT_VERSION_STRING,g" "Monteverdi.app/Contents/Info.plist"
+sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/Monteverdi.app/Contents/MacOS/Monteverdi"
+chmod +x "$OUT_DIR/Monteverdi.app/Contents/MacOS/Monteverdi"
+
+sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/otbenv.profile"
+chmod +x "$OUT_DIR/otbenv.profile"
+
+printf %s\\n ""
+printf %s\\n "source './otbenv.profile' file to set required environment variables"
+printf %s\\n "eg: '. $OUT_DIR/otbenv.profile'"
+printf %s\\n "You can also copy above line to  ~/.profile to keep changes permanently!"
+printf %s\\n "More documentation can be found in $OUT_DIR/README"
+
+
+# echo "Creating symbolic links..."
+. "./make_symlinks"
+rm -f "$OUT_DIR/make_symlinks"
+rm -f "$OUT_DIR/setup_python.sh"
+rm -f "$OUT_DIR/Monteverdi.icns"
+rm -f "$OUT_DIR/pkgsetup"
+
+#open "$OUT_DIR"
diff --git a/Packaging/Files/mapla.bat b/Packaging/Files/mapla.bat
new file mode 100644
index 0000000..1823697
--- /dev/null
+++ b/Packaging/Files/mapla.bat
@@ -0,0 +1,38 @@
+::
+:: 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.
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: Mapla launcher to set up proper environment
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ at echo off
+setlocal
+
+:: Get the directory of the current script
+set CURRENT_SCRIPT_DIR=%~dp0
+
+:: Setup environment
+call "%CURRENT_SCRIPT_DIR%otbenv.bat"
+
+:: Set current dir to HOME dir because Monteverdi generates temporary files and need write access
+cd %HOMEDRIVE%%HOMEPATH%
+
+:: Start Monteverdi
+start "Monteverdi Application Launcher" /B "%CURRENT_SCRIPT_DIR%bin\mapla.exe" %*
+
+endlocal
diff --git a/Modules/ThirdParty/Qt4/otb-module-init.cmake b/Packaging/Files/mapla.sh
old mode 100644
new mode 100755
similarity index 82%
copy from Modules/ThirdParty/Qt4/otb-module-init.cmake
copy to Packaging/Files/mapla.sh
index d121d06..1164c66
--- a/Modules/ThirdParty/Qt4/otb-module-init.cmake
+++ b/Packaging/Files/mapla.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
 #
 # Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
 #
@@ -18,7 +19,6 @@
 # limitations under the License.
 #
 
-find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL QtXml )
-mark_as_advanced( QT_QMAKE_EXECUTABLE )
-set( QT_USE_QTXML 1 )
-include( ${QT_USE_FILE} )
+. OUT_DIR/otbenv.profile
+
+OUT_DIR/bin/mapla "$@"
diff --git a/Packaging/Files/monteverdi.bat b/Packaging/Files/monteverdi.bat
new file mode 100644
index 0000000..4ffe603
--- /dev/null
+++ b/Packaging/Files/monteverdi.bat
@@ -0,0 +1,38 @@
+::
+:: 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.
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: Monteverdi launcher to set up proper environment
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ at echo off
+setlocal
+
+:: Get the directory of the current script
+set CURRENT_SCRIPT_DIR=%~dp0
+
+:: Setup environment
+call "%CURRENT_SCRIPT_DIR%otbenv.bat"
+
+:: Set current dir to HOME dir because Monteverdi generates temporary files and need write access
+cd %HOMEDRIVE%%HOMEPATH%
+
+:: Start Monteverdi
+start "Monteverdi Viewer" /B "%CURRENT_SCRIPT_DIR%bin\monteverdi.exe" %*
+
+endlocal
diff --git a/Modules/ThirdParty/Qt4/otb-module-init.cmake b/Packaging/Files/monteverdi.sh
old mode 100644
new mode 100755
similarity index 82%
copy from Modules/ThirdParty/Qt4/otb-module-init.cmake
copy to Packaging/Files/monteverdi.sh
index d121d06..6ba6a2c
--- a/Modules/ThirdParty/Qt4/otb-module-init.cmake
+++ b/Packaging/Files/monteverdi.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
 #
 # Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
 #
@@ -18,7 +19,6 @@
 # limitations under the License.
 #
 
-find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL QtXml )
-mark_as_advanced( QT_QMAKE_EXECUTABLE )
-set( QT_USE_QTXML 1 )
-include( ${QT_USE_FILE} )
+. OUT_DIR/otbenv.profile
+
+OUT_DIR/bin/monteverdi "$@"
diff --git a/Packaging/Files/otb_loader.cxx b/Packaging/Files/otb_loader.cxx
new file mode 100644
index 0000000..31d09d4
--- /dev/null
+++ b/Packaging/Files/otb_loader.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.
+ */
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include <windows.h>
+#else
+#include <dlfcn.h>
+#endif
+
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+  if (argc < 2)
+    {
+    std::cout << "Usage : "<< argv[0] << "  library_file" << std::endl;
+    return 1;
+    }
+  const char* input = argv[1];
+#if defined(_WIN32) && !defined(__CYGWIN__)
+  HMODULE library = LoadLibrary(input);
+  if (library == NULL)
+    {
+    std::cout << "Failed to load "<< input << std::endl;
+    LPVOID lpMsgBuf=NULL;
+    FormatMessage(
+      FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+      NULL,
+      GetLastError(),
+      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+      (LPTSTR) &lpMsgBuf,
+      0,
+      NULL
+      );
+    if(lpMsgBuf)
+      {
+      std::cout << (char*)lpMsgBuf << std::endl;
+      LocalFree( lpMsgBuf );
+      }
+    }
+  else
+    {
+    FreeLibrary(library);
+    }
+#else
+  void* library = dlopen(input, RTLD_LAZY);
+  if (library == NULL)
+    {
+    std::cout << "Failed to load "<< input << std::endl;
+    std::cout << dlerror() << std::endl;
+    }
+  else
+    {
+    dlclose(library);
+    }
+#endif
+  return 0;
+}
diff --git a/Modules/ThirdParty/OpenCV/CMakeLists.txt b/Packaging/Files/otbenv.bash
similarity index 50%
copy from Modules/ThirdParty/OpenCV/CMakeLists.txt
copy to Packaging/Files/otbenv.bash
index 224f731..50151f6 100644
--- a/Modules/ThirdParty/OpenCV/CMakeLists.txt
+++ b/Packaging/Files/otbenv.bash
@@ -1,4 +1,4 @@
-#
+#!/usr/bin/env bash
 # Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
 #
 # This file is part of Orfeo Toolbox
@@ -18,16 +18,26 @@
 # limitations under the License.
 #
 
-project(OTBOpenCV)
+# The below environment variables only affect current shell
+# So if you run again from a terminal. you need to run the script again
+# see how this is sourced in monteverdi.sh and mapla.sh
+
+CURRENT_DIR=$(cd -P -- "$(dirname -- "$BASH_SOURCE")" && printf '%s\n' "$(pwd -P)")
 
-configure_file( src/otb_opencv_api.h.in src/otb_opencv_api.h )
+unset LD_LIBRARY_PATH
 
-set(OTBOpenCV_SYSTEM_INCLUDE_DIRS ${OPENCV_INCLUDE_DIRS})
-set(OTBOpenCV_LIBRARIES "${OPENCV_LIBRARIES}")
-set(OTBOpenCV_INCLUDE_DIRS
-  ${OTBOpenCV_BINARY_DIR}/src
-  )
-set(OTBOpenCV_EXPORT_CODE_BUILD "find_package(OpenCV REQUIRED)")
-set(OTBOpenCV_EXPORT_CODE_INSTALL ${OTBOpenCV_EXPORT_CODE_BUILD})
+PATH=$CURRENT_DIR/bin:$PATH
+GDAL_DATA=$CURRENT_DIR/share/data
+GEOTIFF_CSV=$CURRENT_DIR/share/epsg_csv
+PYTHONPATH=$CURRENT_DIR/lib/python:$PYTHONPATH
+OTB_APPLICATION_PATH=$CURRENT_DIR/lib/otb/applications
+GDAL_DRIVER_PATH="disable"
+LC_NUMERIC=C
 
-otb_module_impl()
+export PATH
+export GDAL_DATA
+export GEOTIFF_CSV
+export PYTHONPATH
+export OTB_APPLICATION_PATH
+export GDAL_DRIVER_PATH
+export LC_NUMERIC
diff --git a/Packaging/Files/otbenv.bat b/Packaging/Files/otbenv.bat
new file mode 100644
index 0000000..dbc42ee
--- /dev/null
+++ b/Packaging/Files/otbenv.bat
@@ -0,0 +1,30 @@
+::
+:: 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.
+
+:: Setup environment for OTB package
+set CURRENT_SCRIPT_DIR=%~dp0
+
+set PATH=%CURRENT_SCRIPT_DIR%bin;%PATH%
+set GDAL_DATA=%CURRENT_SCRIPT_DIR%share\data
+set GEOTIFF_CSV=%CURRENT_SCRIPT_DIR%share\epsg_csv
+set PYTHONPATH=%CURRENT_SCRIPT_DIR%lib\python;%PYTHONPATH%
+set OTB_APPLICATION_PATH=%CURRENT_SCRIPT_DIR%lib\otb\applications
+set GDAL_DRIVER_PATH=disable
+:: Set numeric locale to C
+set LC_NUMERIC=C
diff --git a/Packaging/Files/otbenv.profile b/Packaging/Files/otbenv.profile
new file mode 100644
index 0000000..191121e
--- /dev/null
+++ b/Packaging/Files/otbenv.profile
@@ -0,0 +1,75 @@
+#!/bin/sh
+#
+# 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.
+#
+
+# The below environment variables only affect current shell
+# So if you run again from a terminal. you need to run the script again
+# see how this is sourced in monteverdi.sh and mapla.sh
+
+# unset any existing LD_LIBRARY_PATH
+unset LD_LIBRARY_PATH
+
+CMAKE_PREFIX_PATH=OUT_DIR
+export CMAKE_PREFIX_PATH
+
+
+# if OTB_USE_LOCAL_GTK is set to one,
+# we must include ./lib/gtk because gtklibs are installed there. 
+# OTB_USE_LOCAL_GTK is not set by default (use GTK system)
+#This code only affect linux system. for osx OUT_DIR/lib/gtk does not exists
+if [ "$OTB_USE_LOCAL_GTK" = "1" ]; then
+    if [ -d "OUT_DIR/lib/gtk" ]; then
+	LD_LIBRARY_PATH=OUT_DIR/lib/gtk
+	export LD_LIBRARY_PATH
+    fi
+fi
+
+# check and set OTB_APPLICATION_PATH
+if [ -z "$OTB_APPLICATION_PATH" ] || [ "$OTB_APPLICATION_PATH" = "" ]; then
+    OTB_APPLICATION_PATH=OUT_DIR/lib/otb/applications
+else
+    OTB_APPLICATION_PATH=OUT_DIR/lib/otb/applications:$OTB_APPLICATION_PATH
+fi
+
+# Add bin direcotory to system PATH
+PATH=OUT_DIR/bin:$PATH
+
+# export PYTHONPATH to import otbApplication.py
+PYTHONPATH=OUT_DIR/lib/python:$PYTHONPATH
+
+# set numeric locale to C
+LC_NUMERIC=C
+
+# set GDAL_DATA variable used by otb application
+GDAL_DATA=OUT_DIR/share/gdal
+
+export GDAL_DRIVER_PATH=disable
+
+# set GEOTIFF_CSV variable used by otb application
+GEOTIFF_CSV=OUT_DIR/share/epsg_csv
+
+# export variables
+export LC_NUMERIC
+export GDAL_DATA
+export GEOTIFF_CSV
+export OTB_APPLICATION_PATH
+export PATH
+export PYTHONPATH
+
diff --git a/Packaging/Files/qt.conf b/Packaging/Files/qt.conf
new file mode 100644
index 0000000..43c4c4f
--- /dev/null
+++ b/Packaging/Files/qt.conf
@@ -0,0 +1,3 @@
+[Paths]
+Translations=../lib/qt4/translations
+Plugins=../lib/qt4/plugins
diff --git a/Packaging/Files/selftester.bat b/Packaging/Files/selftester.bat
new file mode 100755
index 0000000..756b3f7
--- /dev/null
+++ b/Packaging/Files/selftester.bat
@@ -0,0 +1,255 @@
+ at echo off
+::  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.
+
+rem set EXIT_ON_ERROR=0
+rem set TEST_VERBOSE=1
+rem cmd /k tools\selftester.bat /q > selftest_report.log 2>&1
+
+set MY_TOOLS_DIR=%~dp0
+cd %MY_TOOLS_DIR%..
+set MY_INSTALL_DIR=%cd%
+echo "MY_INSTALL_DIR=%MY_INSTALL_DIR%"
+
+:: this is set in wrapper script
+::set EXIT_ON_ERROR=0
+IF %EXIT_ON_ERROR%.==. ( set EXIT_ON_ERROR=1)
+IF %TEST_VERBOSE%.==. ( set TEST_VERBOSE=1)
+
+echo TEST_VERBOSE=%TEST_VERBOSE%
+echo EXIT_ON_ERROR=%EXIT_ON_ERROR%
+
+:: if "/q" is given, hide the error dialogs (hence make the script non-interactive)
+if /i not -%1-==-/q- (
+  goto :skip_hide_error
+)
+
+
+call :getDontShowUI
+if %DONTSHOWUI_VALUE% equ 0 call :setDontShowUI 1
+:skip_hide_error
+echo Hide error dialogs
+:: Get current PID
+type NUL > pid.log
+wmic PROCESS where "Name='WMIC.exe'" get ParentProcessId >pid.log 2>&1
+for /F "TOKENS=1" %%b in ('type pid.log ^| findstr [0-9]') do set CURRENT_PID=%%b
+
+:: setup the otbenv
+call otbenv.bat
+
+:: -----------------------------------------------------------------------------------
+REM Check 1 : check binaries
+for /R %%i in (*.dll) do (
+  call :check_binary %%i
+)
+for %%i in (bin\mapla.exe,bin\monteverdi.exe,bin\otbApplicationLauncherCommandLine.exe,bin\otbApplicationLauncherQt.exe) do (
+  call :check_binary %%i
+)
+call :check_binary lib\python\_otbApplication.pyd
+
+:: -----------------------------------------------------------------------------------
+rem Check 2 : check applications and Python wrapping
+set /a app_count=0
+for /R %%i in (lib\otb\applications\otbapp_*.dll) do (
+  call :check_application %%i
+)
+if %app_count% leq 90 (
+  echo WARNING: only %app_count% applications found ! Expected at least 90
+)
+call :check_python_wrapping
+
+:: -----------------------------------------------------------------------------------
+rem Check 3 : check monteverdi & mapla
+call :check_desktop_app monteverdi
+call :check_desktop_app mapla 20
+
+if /i not -%1-==-/q- (
+  goto :skip_restore_error
+)
+if %DONTSHOWUI_VALUE% equ 0 call :setDontShowUI 0
+:skip_restore_error
+setlocal
+del pid.log
+del tmp.log
+endlocal
+goto :eof
+
+::########################[ FUNCTIONS ]##################################
+:check_binary
+setlocal
+if %TEST_VERBOSE% gtr 1 ( echo ":check_binary %1" )
+type NUL > tmp.log
+tools\otb_loader.exe %1 > tmp.log 2>&1
+call :nb_tmp_lines
+if %nb_tmp_lines_out% gtr 0 (
+  echo "ERROR: otb_loader.exe %1"
+  type tmp.log
+  if %EXIT_ON_ERROR% equ 1 ( exit 1 )
+)
+endlocal
+goto :eof
+::-----------------------------------------------------------------------
+:check_application
+setlocal
+set dll_path=%~n1
+set app=%dll_path:~7%
+if %TEST_VERBOSE% equ 1 ( echo ":check_application %app%" )
+if not exist bin\otbcli_%app%.bat (
+  echo ERROR : missing cli launcher for application %app%
+  if %EXIT_ON_ERROR% equ 1 ( exit 1 )
+  goto :check_gui
+)
+type NUL > tmp.log
+cmd /C bin\otbcli_%app%.bat "-help" ^> tmp.log ^2^>^&^1
+call :parse_cli_output
+if %parse_cli_result% equ 0 (
+  echo ERROR : error launching application otbcli_%app%
+  type results.txt 
+  if %EXIT_ON_ERROR% equ 1 ( exit 1 )
+  )
+
+:check_gui
+if not exist bin\otbgui_%app%.bat (
+  echo ERROR : missing gui launcher for application %app%
+  if %EXIT_ON_ERROR% equ 1 ( exit 1 )
+  goto :check_application_end
+)
+if %app_count% geq 2 goto :check_application_end
+type NUL > tmp.log
+start "otbgui application" /b bin\otbgui_%app%.bat ^> tmp.log ^2^>^&^1
+timeout 5 >nul
+call :get_child_pid %CURRENT_PID% cmd.exe
+set first_child=0
+if %child_pid% gtr 1 (
+  set first_child=%child_pid%
+) else (
+  echo ERROR : could not launch otbgui_%app%
+  type tmp.log 
+  goto :check_application_clean
+)
+call :get_child_pid %first_child% otbApplicationLauncherQt.exe
+if not %child_pid% gtr 1 (
+  echo ERROR : could not launch otbApplicationLauncherQt %app%
+  type tmp.log
+  if %EXIT_ON_ERROR% equ 1 ( exit 1 )
+)
+  
+:check_application_clean
+if not %first_child% == 0 (
+  taskkill /PID %first_child% /F /T > NUL 2>&1
+)
+  
+:check_application_end
+endlocal & set /a app_count=app_count+1
+goto :eof
+::-----------------------------------------------------------------------
+:check_desktop_app
+setlocal
+set appName=%1
+set delay=5
+if not -%2-==-- set delay=%2
+type NUL > tmp.log
+start "Desktop app" /b bin\%appName%.exe > tmp.log 2>&1
+timeout %delay% >nul
+call :get_child_pid %CURRENT_PID% %appName%.exe
+if %child_pid% gtr 1 (
+  taskkill /PID %child_pid% /F /T > NUL 2>&1
+) else (
+  echo ERROR : could not launch %appName%.exe
+  type tmp.log
+  if %EXIT_ON_ERROR% equ 1 ( exit 1 )
+)
+endlocal
+goto :eof
+::-----------------------------------------------------------------------
+:check_python_wrapping
+setlocal
+type NUL > tmp.log
+python -c "import otbApplication" > tmp.log 2>&1
+call :nb_tmp_lines
+if %nb_tmp_lines_out% gtr 0 (
+  echo ERROR : failed to run python wrapping
+  type tmp.log
+  if %EXIT_ON_ERROR% equ 1 ( exit 1 )
+)
+endlocal
+goto :eof
+::-----------------------------------------------------------------------
+:parse_cli_output
+setlocal
+set /a ret=1
+findstr /n /r /c:"^This is the *.*(%app%) application, version " tmp.log  > results.txt
+if %errorlevel%==1 (
+  set /a ret=0
+  echo "findstr failed 1st regex in parse_cli_output"
+  goto :parse_cli_output_end  
+)
+findstr /n /r /c:"^Parameters: " tmp.log  > results.txt
+if %errorlevel%==1 (
+  set /a ret=0
+  echo "findstr failed 2nd regex in parse_cli_output"
+  goto :parse_cli_output_end  
+)
+findstr /n /r /c:"^Examples: " tmp.log  > results.txt
+if %errorlevel%==1 (
+  set /a ret=0
+    echo "findstr failed 3rd regex in parse_cli_output"
+  goto :parse_cli_output_end  
+)
+findstr /n /r /c:"FATAL" tmp.log  > results.txt
+if %errorlevel%==0 (
+  set /a ret=0
+    echo "findstr passed 4th regex in parse_cli_output"
+  goto :parse_cli_output_end  
+)
+
+:parse_cli_output_end
+endlocal & set /a parse_cli_result=%ret%
+goto :eof
+::-----------------------------------------------------------------------
+
+:nb_tmp_lines
+setlocal
+for /F "delims=" %%i in ('find /C /V "" ^< tmp.log') do set output=%%i
+endlocal & set nb_tmp_lines_out=%output%
+goto :eof
+::-----------------------------------------------------------------------
+:get_child_pid
+setlocal
+set parent_pid=%1
+set process_name=%2
+set output=0
+type NUL > pid.log
+wmic PROCESS where (ParentProcessId=%parent_pid% AND Name="%process_name%") get ProcessId >pid.log 2>&1
+for /F "TOKENS=1" %%a in ('type pid.log ^| findstr [0-9]') do set output=%%a
+endlocal & set child_pid=%output%
+goto :eof
+::-----------------------------------------------------------------------
+:getDontShowUI
+setlocal
+set output=0
+for /F "TOKENS=3" %%a in ('reg query "HKCU\Software\Microsoft\Windows\Windows Error Reporting" /v DontShowUI ^| findstr DontShowUI') do set output=%%a
+endlocal & set DONTSHOWUI_VALUE=%output:~2%
+goto :eof
+::-----------------------------------------------------------------------
+:setDontShowUI
+setlocal
+reg add "HKCU\Software\Microsoft\Windows\Windows Error Reporting" /v DontShowUI /t REG_DWORD /d %1 /f
+endlocal
+goto :eof
+
diff --git a/Packaging/Files/selftester.sh b/Packaging/Files/selftester.sh
new file mode 100755
index 0000000..69d42e1
--- /dev/null
+++ b/Packaging/Files/selftester.sh
@@ -0,0 +1,223 @@
+#!/bin/sh
+#
+# 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.
+#
+# Setup test environment
+CUR_DIR="$( cd "$( dirname "$0" )/../" && pwd )"
+echo "CUR_DIR=$CUR_DIR"
+cd "$CUR_DIR" || exit
+
+EXIT_ON_ERROR=1
+
+# define convenient functions
+# ps_children( parentPID ) : get PIDs of children processes
+ps_children () {
+  ps -e -o pid -o command=COMMAND-WIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIDE-COLUMN -o ppid | grep " $1$" | grep -v -e ' grep ' -e ' ps -e '
+}
+
+# nb_report_lines( ) : get number of lines in report
+nb_report_lines () {
+  report_lines="$(wc -l selftest_report.log)"
+  echo $report_lines | cut -d ' ' -f 1
+}
+#
+
+exit_if () {
+  if [ $EXIT_ON_ERROR = 1 ]; then
+      echo "EXIT_ON_ERROR=1"
+      exit 1;
+  fi
+}
+
+# echo_and_report ( string ) : echo and print to report
+echo_and_report () {
+    echo "$1" | tee -a selftest_report.log
+    exit_if
+}
+
+# -------------------------------------------------------------------------
+. "$CUR_DIR/otbenv.profile"
+
+rm -f selftest_report.log
+touch selftest_report.log
+REF_SIZE=0
+REF_SIZE=$(nb_report_lines)
+
+# Check 1 : check binaries
+OTB_SO_LIBRARIES=$(find lib -name '*.so*')
+OTB_DY_LIBRARIES=$(find lib -name '*.dylib')
+OTB_EXE="bin/mapla bin/monteverdi bin/otbApplicationLauncherQt bin/otbApplicationLauncherCommandLine"
+for name in $OTB_SO_LIBRARIES $OTB_DY_LIBRARIES $OTB_EXE; do
+    F_OUTPUT=$(file "$name")
+  if echo "$F_OUTPUT" | grep -q 'cannot open'; then
+    echo_and_report "$F_OUTPUT"
+  elif echo "$F_OUTPUT" | grep -q ': broken symbolic link'; then
+    echo_and_report "$F_OUTPUT"
+  elif echo "$F_OUTPUT" | grep -q -i -e ': ELF .*shared object' -e ': ELF .*executable'; then
+    LDD_ERRORS=$(ldd "$name" | grep -i -e '=> not found' -e 'not a dynamic executable')
+    if [ -n "$LDD_ERRORS" ]; then
+      echo_and_report "ldd $name"
+      echo_and_report "$LDD_ERRORS"
+    fi
+  elif echo "$F_OUTPUT" | grep -q -i -e ': Mach-O .*shared library' -e ': Mach-O .*bundle' -e ': Mach-O .*executable'; then
+    DL_ERRORS=$(dltest "$name" | grep -i 'ERROR')
+    if [ -n "$DL_ERRORS" ]; then
+      echo_and_report "dltest $name"
+      echo_and_report "$DL_ERRORS"
+    fi
+  elif echo "$F_OUTPUT" | grep -q ': symbolic link'; then
+    :
+  else
+    echo_and_report "Unknown file type : $F_OUTPUT"
+  fi
+done
+
+REPORT_SIZE=$(nb_report_lines)
+if [ "$REPORT_SIZE" -ne "$REF_SIZE" ]; then
+  echo "Check 1/4 : FAIL"
+else
+  echo "Check 1/4 : PASS"
+fi
+REF_SIZE=$REPORT_SIZE
+
+# Check 2 : OTB applications and Python wrapping
+OTB_APP_COUNT=$(find lib/otb/applications -name 'otbapp_*.*' | wc -w)
+OTB_APPS=$(find lib/otb/applications -name 'otbapp_*.*' | cut -d '_' -f 2 | cut -d '.' -f 1)
+if [ "$OTB_APP_COUNT" -le 90 ]; then
+  echo "WARNING: Only $OTB_APP_COUNT applications found ! Expected at least 90"
+fi
+app_index=0
+for app in $OTB_APPS; do
+  if [ ! -f "bin/otbcli_$app" ]; then
+      echo_and_report "ERROR: missing cli launcher for application $app"
+      
+  else
+    CLI_OUTPUT=$("bin/otbcli_$app" -help 2>&1)
+    CLI_FILTER=$(echo "${CLI_OUTPUT}"| tr '\n' ' ' | grep -E "This is the*.*$app*.*application, version .* Parameters: .* Examples:.*")
+    CLI_FILTER2=$(echo "$CLI_FILTER" | grep -v 'FATAL')
+    if [ -z "$CLI_FILTER2" ]; then
+      echo_and_report "ERROR: bin/otbcli_$app\n$CLI_OUTPUT"
+    fi
+  fi
+  # test the gui launcher only on 2 first applications
+  if [ ! -f "bin/otbgui_$app" ]; then
+    echo_and_report "ERROR: missing gui launcher for application $app"
+  elif [ $app_index -lt 2 ]; then
+    echo "" >tmp.log
+    "bin/otbgui_$app" >tmp.log 2>&1 &
+    GUI_PID=$!
+    sleep 5s
+    # Check process tree
+    CHILD_PROC=$(ps_children $GUI_PID | grep "bin/otbgui $app")
+    if [ -n "$CHILD_PROC" ]; then
+      CHILD_PID=$(echo "$CHILD_PROC" | cut -d ' ' -f 1)
+      NEXT_CHILD_PROC=$(ps_children "$CHILD_PID" | grep 'otbApplicationLauncherQt')
+      if [ -n "$NEXT_CHILD_PROC" ]; then
+        NEXT_CHILD_PID=$(echo "$NEXT_CHILD_PROC" | cut -d ' ' -f 1)
+        kill -9 "$NEXT_CHILD_PID"
+        wait "$NEXT_CHILD_PID" 2>/dev/null
+      else
+        echo "ERROR: otbApplicationLauncherQt $app failed to launch"
+        tee -a selftest_report.log < tmp.log
+	exit_if
+      fi
+    else
+	echo "ERROR: bin/otbgui_$app failed to launch"
+	tee -a selftest_report.log < tmp.log
+	exit_if
+    fi
+  fi
+  app_index=$(( app_index + 1 ))
+done
+
+# test python wrapping
+PY_OUTPUT=$(python -c 'import otbApplication' 2>&1)
+if [ -n "$PY_OUTPUT" ]; then
+  echo_and_report "ERROR: python wrapping test failed :"
+  echo_and_report "$PY_OUTPUT"
+fi
+
+REPORT_SIZE=$(nb_report_lines)
+if [ "$REPORT_SIZE" -ne "$REF_SIZE" ]; then
+  echo "Check 2/4 : FAIL"
+else
+  echo "Check 2/4 : PASS"
+fi
+REF_SIZE=$REPORT_SIZE
+
+# Check 3 : OTB binaries monteverdi & mapla
+# Monteverdi
+echo "" >tmp.log
+bin/monteverdi >tmp.log 2>&1 &
+MVD_PID=$!
+sleep 5s
+if pgrep monteverdi | grep -q $MVD_PID; then
+  MVD_LOG=$(grep -i -e 'error' -e 'exception' tmp.log)
+  if [ -n "$MVD_LOG" ]; then
+    echo_and_report "ERROR: launching monteverdi"
+    tee -a selftest_report.log < tmp.log
+  fi
+  kill -9 $MVD_PID
+  wait $MVD_PID 2>/dev/null
+else
+  echo_and_report "ERROR: failed to launch monteverdi"
+  tee -a selftest_report.log < tmp.log
+fi
+# Mapla
+echo "" >tmp.log
+bin/mapla >tmp.log 2>&1 &
+MAPLA_PID=$!
+sleep 5s
+if pgrep mapla | grep -q $MAPLA_PID; then
+  MAPLA_LOG=$(grep -i -e 'error' -e 'exception' tmp.log)
+  if [ -n "$MAPLA_LOG" ]; then
+    echo_and_report "ERROR: launching mapla"
+    tee -a selftest_report.log < tmp.log
+  fi
+  kill -9 $MAPLA_PID
+  wait $MAPLA_PID 2>/dev/null
+else
+  echo_and_report "ERROR: failed to launch mapla"
+  tee -a selftest_report.log < tmp.log
+fi
+
+REPORT_SIZE=$(nb_report_lines)
+if [ "$REPORT_SIZE" -ne "$REF_SIZE" ]; then
+  echo "Check 3/4 : FAIL"
+else
+  echo "Check 3/4 : PASS"
+fi
+
+grep_cmd=$(which grep)
+grep_out=$($grep_cmd -Rs "/usr/" "$CUR_DIR/lib/cmake/")
+grep_ret=$?
+if [ $grep_ret -ne 1 ]; then
+    echo "Check 4/4 : FAIL"
+    echo "ERROR: your cmake files contains references to /usr. Is this normal?"
+    echo_and_report "$grep_out"
+else
+    echo "Check 4/4 : PASS"
+fi
+
+# clean any background process
+ps_children $$ >tmp.log
+for pid in $(cut -d ' ' -f 1 < tmp.log); do
+  kill -9 "$pid"
+done
+rm -f tmp.log
diff --git a/Packaging/Files/setup_python.sh b/Packaging/Files/setup_python.sh
new file mode 100755
index 0000000..e0f0320
--- /dev/null
+++ b/Packaging/Files/setup_python.sh
@@ -0,0 +1,98 @@
+#!/bin/sh
+#
+# 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.
+#
+
+# get current working dir (this should be the install directory)
+CWD=$(pwd)
+
+# Setup python environment
+if [ ! -f "$OTB_PYTHON_EXE" ] ; then
+    OTB_PYTHON_EXE=$(which python)
+fi
+
+if [ ! -f "$OTB_PYTHON_EXE" ] ; then
+    printf %s\\n "*****Error occurred during installation******"
+    printf %s\\n "Python executable not found"
+    exit 1
+fi
+
+python_major_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[0])")
+python_minor_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[1])")
+python_patch_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[2])")
+python_version="$python_major_version.$python_minor_version.$python_patch_version"
+
+python_check_failed() {
+    printf %s\\n "*****Error occurred during installation******"
+    printf %s\\n "OTB python bindings requires python2.6 or python2.7 but current detected python version is $python_version"
+    printf %s\\n "If you have python2.6 or Python2.7 installed in your system "
+    printf %s\\n "You should set OTB_PYTHON_EXE and re-run this installation script."
+    printf %s\\n "eg: OTB_PYTHON_EXE=/path/to/python2.7 ./OTB-X.Y-Linux64.run"
+    exit 1
+}
+if [ "$python_major_version" -gt 2 ]; then
+python_check_failed
+fi
+
+if [ "$python_minor_version" -lt 5 ]; then
+python_check_failed
+fi
+
+python_INSTSONAME=$($OTB_PYTHON_EXE -c "import sys; from distutils import sysconfig; print (sysconfig.get_config_var('INSTSONAME'));")
+
+python_lib_dirs="$LD_LIBRARY_PATH /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu"
+if [ "$(uname)" = "Darwin" ]; then
+    python_lib_dirs="$DYLD_LIBRARY_PATH /usr/lib /Library/Frameworks /opt/local/lib /opt/local/Library/Frameworks"
+fi;
+
+found_python_lib="0"
+python_lib_file_path=""
+for list_of_dir in $python_lib_dirs
+do
+    if [ -f "$list_of_dir/$python_INSTSONAME" ]; then
+        python_lib_file_path="$list_of_dir/$python_INSTSONAME"
+        found_python_lib="1"
+        break
+    fi
+done
+
+if [ "$found_python_lib" -eq "1" ]; then
+    numpy_import_result="$($OTB_PYTHON_EXE -c 'import numpy' 2>&1)" || numpy_ret=$?
+    if [ ! -z "$numpy_import_result" ]; then
+      printf %s\\n "*****Error occurred during installation******"
+      printf %s\\n "Python interpreter detected is : $OTB_PYTHON_EXE ( version: $python_version )"
+      printf %s\\n "numpy not installed with '$OTB_PYTHON_EXE'"
+      printf %s\\n "Check failed with result:"
+      printf %s\\n "$numpy_import_result"
+      exit 1
+    else
+      printf %s\\n "OTB python bindings will be configured for $OTB_PYTHON_EXE ( version: $python_version )"
+      printf %s\\n "Found python library: $python_lib_file_path"
+    fi
+    #ln -sf "$python_lib_file_path" "$CWD/lib/$python_INSTALLED_SONAME"
+else
+    printf %s\\n "*****Error occurred during installation******"
+    printf %s\\n "Python interpreter detected is : $OTB_PYTHON_EXE ( version: $python_version )"
+    printf %s\\n "$python_INSTSONAME cannot be found in any of search directories."
+    printf %s\\n "We had searched following directories $python_lib_dirs"
+    printf %s\\n "If you don't have python-dev package installed, install it and make a symlink"
+    printf %s\\n "If you don't have python headers and so installed on a custom location, then make a symlink"
+    printf %s\\n "eg: ln -s /usr/lib/x86_64-linux-gnu/$python_INSTSONAME $CWD/lib/$python_INSTSONAME"
+    exit 1
+fi
diff --git a/Packaging/Files/start_devenv.bat b/Packaging/Files/start_devenv.bat
new file mode 100755
index 0000000..f0458cf
--- /dev/null
+++ b/Packaging/Files/start_devenv.bat
@@ -0,0 +1,41 @@
+::
+:: 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.
+::
+
+ at echo on
+
+set CURRENT_SCRIPT_DIR=%~dp0
+set CURRENT_SCRIPT_DIR=%CURRENT_SCRIPT_DIR:~0,-1%
+
+
+set PATH=%CURRENT_SCRIPT_DIR%\bin;%PATH%
+set VSDEV_ENV=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe
+set OTB_VS_TEMPLATE_DIR=%USERPROFILE%\Documents\Visual Studio 2015\Templates\ProjectTemplates
+
+set OTB_XDK_DIR=%CURRENT_SCRIPT_DIR:\=/%
+::dir %OTB_VS_TEMPLATE_DIR%
+if exist "%VSDEV_ENV%" (
+if not exist "%OTB_VS_TEMPLATE_DIR%" (   md "%OTB_VS_TEMPLATE_DIR%" )
+copy "%CURRENT_SCRIPT_DIR%\OTB Project.zip" "%OTB_VS_TEMPLATE_DIR%"
+START "" "%VSDEV_ENV%"
+) else (
+echo "%VSDEV_ENV% not found"
+)
+
+ at cmd
diff --git a/Packaging/Files/template.app/Contents/Info.plist b/Packaging/Files/template.app/Contents/Info.plist
new file mode 100644
index 0000000..5f870f8
--- /dev/null
+++ b/Packaging/Files/template.app/Contents/Info.plist
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+  <key>CFBundleExecutable</key>
+  <string>STARTUP_FILE</string>
+  <key>CFBundleIconFile</key>
+  <string>Monteverdi.icns</string>
+  <key>CFBundleInfoDictionaryVersion</key>
+  <string>6.0</string>
+  <key>CFBundlePackageType</key>
+  <string>APPL</string>
+  <key>CFBundleLongVersionString</key>
+  <string>LONG_VERSION</string>
+  <key>CFBundleShortVersionString</key>
+  <string>SHORT_VERSION</string>
+</dict>
+</plist>
diff --git a/Packaging/Files/uninstall_otb.bat b/Packaging/Files/uninstall_otb.bat
new file mode 100644
index 0000000..b437444
--- /dev/null
+++ b/Packaging/Files/uninstall_otb.bat
@@ -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.
+
+:: script to uninstall OTB
+
+setlocal
+set CUR_DIR=%~dp0
+cd %CUR_DIR%..
+set MY_INSTALL_DIR=%cd%
+del /S /Q %MY_INSTALL_DIR%\include\OTB* || exit 1
+del /S /Q %MY_INSTALL_DIR%\lib\cmake\OTB* || exit 1
+del /S /Q %MY_INSTALL_DIR%\lib\otb* || exit 1
+del /S /Q %MY_INSTALL_DIR%\lib\python\_otbApplication.* || exit 1
+del /S /Q %MY_INSTALL_DIR%\bin\otb* || exit 1
+del /S /Q %MY_INSTALL_DIR%\bin\monteverdi.exe || exit 1
+del /S /Q %MY_INSTALL_DIR%\bin\mapla.exe || exit 1
+del /S /Q %MY_INSTALL_DIR%\mapla.bat || exit 1
+del /S /Q %MY_INSTALL_DIR%\monteverdi.bat || exit 1
+del /S /Q %MY_INSTALL_DIR%\share\OTB* || exit 1
+del /S /Q "%MY_INSTALL_DIR%\OTB Project.zip" || exit 1
+endlocal
+
+
diff --git a/Modules/Applications/AppFiltering/otb-module.cmake b/Packaging/Files/uninstall_otb.sh
old mode 100644
new mode 100755
similarity index 71%
copy from Modules/Applications/AppFiltering/otb-module.cmake
copy to Packaging/Files/uninstall_otb.sh
index d33a9ee..4f596f3
--- a/Modules/Applications/AppFiltering/otb-module.cmake
+++ b/Packaging/Files/uninstall_otb.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
 #
 # Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
 #
@@ -17,21 +18,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+set -e
+rm -fr OUT_DIR/include/OTB-*
+rm -f OUT_DIR/lib/{libotb*,libOTB*}
+rm -fr OUT_DIR/lib/{otb,python/_otbApplication*}
+rm -fr OUT_DIR/share/OTB*
+rm -fv OUT_DIR/bin/{otb*,monteverdi,mapla}
+rm -fv OUT_DIR/{mapla.sh,monteverdi.sh}
 
-set(DOCUMENTATION "Basic filters application.")
-
-otb_module(OTBAppFiltering
-  DEPENDS
-    OTBImageNoise
-    OTBImageManipulation
-    OTBITK
-    OTBApplicationEngine
-    OTBImageBase
-
-  TEST_DEPENDS
-    OTBTestKernel
-    OTBCommandLine
-
-  DESCRIPTION
-    "${DOCUMENTATION}"
-)
+echo "OTB is now uninstalled from OUT_DIR"
diff --git a/Packaging/PackageGlobals.cmake b/Packaging/PackageGlobals.cmake
new file mode 100644
index 0000000..e945e98
--- /dev/null
+++ b/Packaging/PackageGlobals.cmake
@@ -0,0 +1,170 @@
+#
+# 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(LOADER_REGEX_EOL "E")
+set(DEST_BIN_DIR bin)
+set(DEST_APP_DIR lib/otb/applications)
+
+set(LIB_PREFIX lib)
+set(DEST_LIB_DIR lib)
+set(EXE_EXT "")
+set(SCRIPT_EXT ".sh")
+set(LIB_EXT ".so")
+set(PYMODULE_EXT ".so")
+set(STATIC_LIB_EXT ".a")
+
+if(WIN32)
+  set(LIB_PREFIX)
+  set(DEST_LIB_DIR bin)
+  set(EXE_EXT ".exe")
+  set(LIB_EXT ".dll")
+  set(SCRIPT_EXT ".bat")
+  set(PYMODULE_EXT ".pyd")
+  set(STATIC_LIB_EXT ".lib")
+elseif(APPLE)
+  set(LIB_EXT ".dylib")
+endif()
+
+set(WINDOWS_SYSTEM_DLLS
+  user32.dll
+  gdi32.dll
+  shell32.dll
+  kernel32.dll
+  ws2_32.dll
+  wldap32.dll
+  ole32.dll
+  comdlg32.dll
+  shfolder.dll
+  secur32.dll
+  wsock32.dll
+  advapi32.dll
+  crypt32.dll
+  imm32.dll
+  oleaut32.dll
+  winmm.dll
+  opengl32.dll
+  glu32.dll
+  rpcrt4.dll
+  winspool.drv
+  normaliz.dll
+  odbc32.dll
+  psapi.dll
+  python...dll
+  )
+
+set(LINUX_SYSTEM_DLLS
+  libm.so
+  libc.so.*
+  libstdc*
+  libgcc_s.so
+  librt.so
+  libdl.so
+  libpthread.so
+  libidn.so
+  libgomp.so*
+  ld-linux-x86-64.so*
+  libX11.so*
+  libXi.so*  #GLUT
+  libXcursor.so* #GLFW
+  libXinerama.so*  #GLFW
+  libXext.so*
+  libXau.so*
+  libXdmcp.so*
+  libXxf86vm.so*
+  libdrm.so.2
+  libGL.so*
+  libGLU.so*
+  libXrender.so*
+  libSM.so*
+  libICE.so*
+  libXrandr.so*
+  libpython*
+  )
+  # libexpat.so.*
+  # libfontconfig.so*
+  # libfreetype.so*
+  # libwebp.so*
+  # )
+
+# libgcc_s.*dylib and other *.framework are dragged by QT
+set(APPLE_SYSTEM_DLLS
+  libSystem.*dylib
+  libiconv.*dylib
+  libc\\+\\+.*dylib
+  libstdc.*dylib
+  libobjc.*dylib
+  ApplicationServices.framework
+  CoreFoundation.framework
+  CoreServices.framework
+  Security.framework
+  Carbon.framework
+  AppKit.framework
+  Foundation.framework
+  Python.framework
+  AGL.framework
+  OpenGL.framework
+  libgcc_s.*dylib
+  )
+
+if(WIN32)
+  set(SYSTEM_DLLS "${WINDOWS_SYSTEM_DLLS}")
+else() #case for unixes
+  if(APPLE)
+    set(SYSTEM_DLLS "${APPLE_SYSTEM_DLLS}")
+  else()
+    set(SYSTEM_DLLS "${LINUX_SYSTEM_DLLS}")
+  endif()
+endif(WIN32)
+
+# Take gtk libs from system. we should fix this to take from custom
+# build location
+set(PKG_GTK_SEARCHDIRS
+  /usr/lib64
+  /lib64
+  /lib/x86_64-linux-gnu/
+  /usr/lib/x86_64-linux-gnu/
+  )
+
+#superbuild cannot manage build of gtk2+ just for qt gtkstyle.
+# -gtkstyle option is deactivated by default in build of QT4
+# So the list of requirements on building OTB with superbuild stays same.
+#For our user base, we need monteverdi with a nice look and feel
+# rather than simply X11 based windows. Hence we need -gtkstyle
+# This forces us to have system gtk+ installed on the system.
+# OTB package manager 'this script' will pick them up and put
+# into the binary package. Below cmake variable controls the list of
+#libraries coming from /usr/lib a.k.a system.
+
+set(GTK_LIB_LIST_1
+  libgthread-2.0.so.0
+  libglib-2.0.so.0
+  libgobject-2.0.so.0
+  libXrender.so.1
+  libpcre.so.3
+  libffi.so.6
+  )
+# set(GTK_LIB_LIST_2
+#   libz.so.1
+#   libpng12.so.0
+#   )
+
+
+#set(ALLOWED_SYSTEM_DLLS ${GTK_LIB_LIST_1} ${GTK_LIB_LIST_2})
+set(ALLOWED_SYSTEM_DLLS ${GTK_LIB_LIST_1}) # ${GTK_LIB_LIST_2})
diff --git a/Packaging/README.md b/Packaging/README.md
new file mode 100644
index 0000000..e845566
--- /dev/null
+++ b/Packaging/README.md
@@ -0,0 +1 @@
+README
diff --git a/Packaging/check_cmake_variables.cmake b/Packaging/check_cmake_variables.cmake
new file mode 100644
index 0000000..a757a3b
--- /dev/null
+++ b/Packaging/check_cmake_variables.cmake
@@ -0,0 +1,57 @@
+#
+# 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.
+#
+macro(check_cmake_variables)
+  set(required_vars)
+  if(OTB_WRAP_PYTHON)
+    list(APPEND required_vars PYTHON_EXECUTABLE)
+  endif()
+  
+  if(LINUX)
+    list(APPEND required_vars FILE_COMMAND)
+    list(APPEND required_vars READLINK)
+    list(APPEND required_vars  PATCHELF_PROGRAM)
+  endif()
+
+  if(WIN32)
+    list(APPEND required_vars ZIP_EXECUTABLE)
+  endif()
+  foreach(req
+      ${required_vars}
+      PKG_STAGE_DIR
+      SUPERBUILD_BINARY_DIR
+      SUPERBUILD_INSTALL_DIR
+      SUPERBUILD_SOURCE_DIR
+      PACKAGE_OTB_SRC_DIR
+      OTB_TARGET_SYSTEM_ARCH
+      OTB_TARGET_SYSTEM_ARCH_IS_X64
+      LOADER_PROGRAM
+      LOADER_ARGS
+      LOADER_REGEX
+      PKG_ITK_SB_VERSION
+      PKG_OTB_VERSION_STRING
+      PACKAGE_OUTPUT_FILE
+      )
+    if(NOT DEFINED ${req} OR "${${req}}" STREQUAL "")
+      message(FATAL_ERROR "you must set ${req}")
+    endif()
+    message(STATUS "${req}=[${${req}}]")
+  endforeach(req)
+
+endmacro()
diff --git a/Packaging/cleanup_package.cmake b/Packaging/cleanup_package.cmake
new file mode 100644
index 0000000..e7bae31
--- /dev/null
+++ b/Packaging/cleanup_package.cmake
@@ -0,0 +1,58 @@
+#
+# 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.
+#
+
+macro(cleanup_package)
+
+if(EXISTS "${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}")
+
+message(STATUS "Deleting package staging directory: ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}")
+execute_process(COMMAND 
+${CMAKE_COMMAND} -E remove_directory
+  "${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}"
+  RESULT_VARIABLE cleanup_stagedir_rv
+  OUTPUT_VARIABLE cleanup_stagedir_ov
+  ERROR_VARIABLE cleanup_stagedir_ov
+  )
+  
+  if(cleanup_stagedir_rv)
+  message(FATAL_ERROR  "Delete ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR} - FAILED\ncleanup_stagedir_ov=${cleanup_stagedir_ov}")
+  else()
+  message(STATUS "Delete ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR} - OK")  
+  endif()
+endif()
+
+if(EXISTS "${PACKAGE_OUTPUT_FILE}")
+message(STATUS "Remove PACKAGE_OUTPUT_FILE: ${PACKAGE_OUTPUT_FILE}")
+execute_process(COMMAND 
+${CMAKE_COMMAND} -E remove -f "${PACKAGE_OUTPUT_FILE}"
+  RESULT_VARIABLE cleanup_pkgfile_rv
+  OUTPUT_VARIABLE cleanup_pkgfile_ov
+  ERROR_VARIABLE cleanup_pkgfile_ov
+  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+  )
+  
+    if(cleanup_pkgfile_rv)
+  message(FATAL_ERROR  "Delete ${PACKAGE_OUTPUT_FILE} - FAILED\ncleanup_pkgfile_ov=${cleanup_pkgfile_ov}")
+  else()
+  message(STATUS "Delete ${PACKAGE_OUTPUT_FILE} - OK")  
+  endif()
+  
+endif()
+endmacro()
diff --git a/Modules/Applications/AppFiltering/otb-module.cmake b/Packaging/clear_cmakecache_variables.cmake
similarity index 67%
copy from Modules/Applications/AppFiltering/otb-module.cmake
copy to Packaging/clear_cmakecache_variables.cmake
index d33a9ee..e4418c0 100644
--- a/Modules/Applications/AppFiltering/otb-module.cmake
+++ b/Packaging/clear_cmakecache_variables.cmake
@@ -17,21 +17,13 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-
-set(DOCUMENTATION "Basic filters application.")
-
-otb_module(OTBAppFiltering
-  DEPENDS
-    OTBImageNoise
-    OTBImageManipulation
-    OTBITK
-    OTBApplicationEngine
-    OTBImageBase
-
-  TEST_DEPENDS
-    OTBTestKernel
-    OTBCommandLine
-
-  DESCRIPTION
-    "${DOCUMENTATION}"
-)
+macro(clear_cmakecache_variables)
+unset(matched_vars CACHE)
+  get_variables_ending_with("_USED|_RESOLVED" matched_vars)
+  foreach (var_to_unset IN LISTS matched_vars)
+    if(PKG_DEBUG)
+      message("unset ${var_to_unset} from cache")
+    endif()
+    unset(${var_to_unset} CACHE)
+  endforeach()
+endmacro() #clear_cmakecache_variables
diff --git a/Packaging/configure_loader.cmake b/Packaging/configure_loader.cmake
new file mode 100644
index 0000000..74f7094
--- /dev/null
+++ b/Packaging/configure_loader.cmake
@@ -0,0 +1,50 @@
+#
+# 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.
+#
+function(configure_loader loader_pgm_result loader_args_result loader_regex_result)
+set(loader_PATHS)
+if(MSVC)
+    set(loader_PATHS)
+    set(loader_names      "dumpbin")
+    set(loader_args       "/DEPENDENTS")
+    set(loader_regex      "^    ([^ ].*[Dd][Ll][Ll])${LOADER_REGEX_EOL}$")
+  elseif(APPLE)
+    set(loader_PATHS)
+    set(loader_names    otool)
+    set(loader_args      "-l" )
+    set(loader_regex ".*name.*([ ].*dylib ).*${LOADER_REGEX_EOL}$")
+  elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
+    set(loader_PATHS)
+    set(loader_names    objdump)
+    set(loader_args    "-p" )
+    set(loader_regex "^..NEEDED.*([ ].*so.*)${LOADER_REGEX_EOL}$")
+  else()
+    message(FATAL_ERROR "find_loader_and_args: Unknown platform")
+  endif()
+  
+  find_program(loader_pgm "${loader_names}" PATHS ${loader_PATHS})
+  if(NOT loader_pgm)
+    message(FATAL_ERROR "${loader_names} not found in ${loader_PATHS}.")
+  endif()
+
+  #save result in PARENT_SCOPE
+  set(${loader_args_result} ${loader_args} PARENT_SCOPE)
+  set(${loader_pgm_result} ${loader_pgm} PARENT_SCOPE)
+  set(${loader_regex_result} ${loader_regex} PARENT_SCOPE)  
+endfunction()
diff --git a/Packaging/create_package.cmake b/Packaging/create_package.cmake
new file mode 100644
index 0000000..d53e018
--- /dev/null
+++ b/Packaging/create_package.cmake
@@ -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.
+#
+macro(create_package)
+  install(CODE "
+    message(STATUS \"Creating ${PACKAGE_OUTPUT_FILE}\") 
+    if(WIN32)
+      execute_process(
+        COMMAND ${ZIP_EXECUTABLE} \"a\" \"-r\" \"-y\"
+        \"${PACKAGE_OUTPUT_FILE}\" \"${PKG_STAGE_DIR}/*\"
+        WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\"
+      )
+    else()
+      execute_process(
+        COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/makeself/makeself.sh
+        \"--quiet\"
+        \"--target\"
+        \"${PKG_STAGE_DIR}\"
+        \"${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}\"
+        \"${PKG_STAGE_DIR}.run\"
+        \"${PACKAGE_LONG_NAME} ${PKG_OTB_VERSION_STRING}\"
+        \"./pkgsetup\"
+        WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\"
+     )
+    endif()
+  ")
+
+endmacro()
+
diff --git a/Packaging/detect_using_file_command.cmake b/Packaging/detect_using_file_command.cmake
new file mode 100644
index 0000000..61a0603
--- /dev/null
+++ b/Packaging/detect_using_file_command.cmake
@@ -0,0 +1,111 @@
+#
+# 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.
+#
+function(detect_using_file_command input_file result_type result_dir)
+  
+  execute_process(COMMAND "${FILE_COMMAND}" "${input_file}"
+    RESULT_VARIABLE file_rv
+    OUTPUT_VARIABLE file_ov
+    ERROR_VARIABLE file_ev
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+  if(NOT file_rv STREQUAL "0")
+    message(FATAL_ERROR "${FILE_COMMAND} failed: ${file_rv}\n${file_ev}\n${file_ov}")
+  endif()
+
+  get_filename_component(input_file_NAME ${input_file} NAME)
+  string(REPLACE "${input_file}" " _file_full_ " file_ov "${file_ov}")
+  string(TOLOWER "${file_ov}" file_ov_lower)
+
+  set(detected_type)
+  set(detected_dir)
+  # below executable check works for both mac osx and linux
+  if("${file_ov_lower}" MATCHES "executable")
+    set(detected_type PROGRAMS)
+    set(detected_dir bin)
+    # detect position independent executables on Linux,
+    # where "file" gives "dynamically linked (uses shared libraries)"
+  elseif("${file_ov_lower}" MATCHES "dynamically linked.*\(uses shared libs\)")
+    set(detected_type FILES)
+    set(detected_dir lib)
+    # detect position independent executables on Linux,
+    # where "file" gives "shared object ... (uses shared libraries)"
+  elseif("${file_ov_lower}" MATCHES "shared object.*\(uses shared libs\)")
+    set(detected_type FILES)
+    set(detected_dir lib)
+    # detect shared libraries on Linux,
+    # where "file" gives "ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped"
+  elseif("${file_ov_lower}" MATCHES "elf.*shared object.*version")
+    set(detected_type FILES)
+    set(detected_dir lib)
+    # "file" version 5.22 does not print "(used shared libraries)"
+    # but uses "interpreter"
+  elseif("${file_ov_lower}" MATCHES "shared object.*interpreter")
+    set(detected_type FILES)
+    set(detected_dir lib)
+    # detect shared libraries on Mac OSX
+    # where "file" gives "Mach-O 64-bit x86_64 dynamically linked shared library"
+  elseif("${file_ov_lower}" MATCHES "mach-o.*dynamically linked shared library")
+    set(detected_type FILES)
+    set(detected_dir lib)
+    #below check is redundant.  detect executables on Mac OSX
+    # where "file" gives "Mach-O 64-bit x86_64 executable"
+  elseif("${file_ov_lower}" MATCHES "mach-o.*executable")
+    set(detected_type PROGRAMS)
+    set(detected_dir bin)
+    # detect shared libraries on Mac OSX
+    # where "file" gives "Mach-O 64-bit x86_64 bundle"
+  elseif("${file_ov_lower}" MATCHES "mach-o.*bundle")
+    set(detected_type FILES)
+    set(detected_dir lib)
+  elseif("${file_ov_lower}" MATCHES "mach-o.*bundle")
+    set(detected_type FILES)
+    set(detected_dir lib)
+  elseif("${file_ov_lower}" MATCHES "symbolic link")
+    #this will do a symlink check again using but that's okay!
+
+    #set type to symlink we are going to resolve it anyway
+    set(detected_type "symlink")
+
+    set(is_this_a_symbolic_link FALSE)
+    set(target_file)
+    isfile_symlink("${input_file}" is_this_a_symbolic_link target_file)    
+    if(is_this_a_symbolic_link)
+      
+      if(target_file)
+	set(libdir "lib")
+	setif_value_in_list(is_gtk_lib "${input_file_NAME}" GTK_LIB_LIST_1)
+	if(is_gtk_lib)
+	  set(libdir "lib/gtk")
+	endif()
+	file(APPEND
+	  ${CMAKE_BINARY_DIR}/make_symlinks
+	  "ln -sf \"$OUT_DIR/${libdir}/${target_file}\" \"$OUT_DIR/${libdir}/${input_file_NAME}\" \n"
+	  )
+      endif() #target_file
+    endif() #is_this_a_symbolic_link
+  else() #if("${file_ov_lower}" MATCHES ...)
+    #we are out of options at this point. throw error!
+    message(FATAL_ERROR "unknown/untracked file type found: ${input_file}")
+  endif() #if("${file_ov_lower}" MATCHES ...)
+
+  #message("detected_type=${detected_type}")
+  set(${result_type} "${detected_type}" PARENT_SCOPE)
+  set(${result_dir} "${detected_dir}" PARENT_SCOPE)
+endfunction()
diff --git a/Modules/ThirdParty/Qt4/otb-module-init.cmake b/Packaging/get_variables_ending_with.cmake
similarity index 73%
copy from Modules/ThirdParty/Qt4/otb-module-init.cmake
copy to Packaging/get_variables_ending_with.cmake
index d121d06..8998aff 100644
--- a/Modules/ThirdParty/Qt4/otb-module-init.cmake
+++ b/Packaging/get_variables_ending_with.cmake
@@ -17,8 +17,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-
-find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL QtXml )
-mark_as_advanced( QT_QMAKE_EXECUTABLE )
-set( QT_USE_QTXML 1 )
-include( ${QT_USE_FILE} )
+function (get_variables_ending_with suffix result)
+  get_cmake_property(all_cmake_vars VARIABLES)
+  string (REGEX MATCHALL "(^|;)[A-Za-z0-9_\\.\\-]*(${suffix})" _matchedVars "${all_cmake_vars}")
+  set(${result} ${_matchedVars} PARENT_SCOPE)
+endfunction()
diff --git a/Packaging/howto_update_makeself b/Packaging/howto_update_makeself
new file mode 100644
index 0000000..97df254
--- /dev/null
+++ b/Packaging/howto_update_makeself
@@ -0,0 +1,11 @@
+HOW TO UPDATE MAKESELF
+
+#If makEself version with your required bug fix is 2.3.1
+# cd to otb/sources/Packaging/
+
+wget https://github.com/megastep/makeself/archive/release-2.3.1.tar.gz
+tar xzf release-2.3.1.tar.gz
+mv makeself-release-2.3.1 makeself
+rm -fr release-2.3.1.tar.gz
+
+run git diff to check if everything is in place and git commit 
diff --git a/Modules/Applications/AppFiltering/otb-module.cmake b/Packaging/install_cmake_files.cmake
similarity index 63%
copy from Modules/Applications/AppFiltering/otb-module.cmake
copy to Packaging/install_cmake_files.cmake
index d33a9ee..ca63afb 100644
--- a/Modules/Applications/AppFiltering/otb-module.cmake
+++ b/Packaging/install_cmake_files.cmake
@@ -17,21 +17,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+include(patch_cmake_files.cmake)
 
-set(DOCUMENTATION "Basic filters application.")
-
-otb_module(OTBAppFiltering
-  DEPENDS
-    OTBImageNoise
-    OTBImageManipulation
-    OTBITK
-    OTBApplicationEngine
-    OTBImageBase
-
-  TEST_DEPENDS
-    OTBTestKernel
-    OTBCommandLine
-
-  DESCRIPTION
-    "${DOCUMENTATION}"
-)
+function(install_cmake_files)
+ patch_cmake_files(NAME "ITK"
+   VERSION "${PKG_ITK_SB_VERSION}"
+   MATCH_STRING  "${CMAKE_INSTALL_PREFIX}"
+   REPLACE_VAR "ITK_INSTALL_PREFIX"
+   )
+ 
+ patch_cmake_files(NAME "OTB"
+   VERSION "${PKG_OTB_VERSION_MAJOR}.${PKG_OTB_VERSION_MINOR}"
+   MATCH_STRING  "${CMAKE_INSTALL_PREFIX}"
+   REPLACE_VAR "OTB_INSTALL_PREFIX"
+   )
+endfunction()
diff --git a/Packaging/install_importlibs.cmake b/Packaging/install_importlibs.cmake
new file mode 100644
index 0000000..5a68caf
--- /dev/null
+++ b/Packaging/install_importlibs.cmake
@@ -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.
+#
+#
+# This is more messed up that you might think.
+# On windows we cannot track dependency on .lib files like dll
+function(install_importlibs)
+  if(NOT WIN32)
+    return()
+  endif()
+  
+  #ALL .lib files are required for building
+  #eg: gdal.dll will have gdal_i.lib which is
+  #needed when you do cmake configure for projects
+  #using OTB. Hence the *.lib regex is non optional
+  #and cannot be optimized at any level.
+  #Only thing you can control is to create only those
+  #required .lib files in install directory.
+  file(GLOB import_lib_files
+    "${SUPERBUILD_INSTALL_DIR}/lib/*.lib"
+    "${SUPERBUILD_INSTALL_DIR}/bin/itk*.dll"
+    )
+  foreach( import_lib_file ${import_lib_files})
+    install_rule(${import_lib_file})
+  endforeach()
+
+endfunction()
diff --git a/Packaging/install_include_dirs.cmake b/Packaging/install_include_dirs.cmake
new file mode 100644
index 0000000..1a243ae
--- /dev/null
+++ b/Packaging/install_include_dirs.cmake
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+function(install_include_dirs)
+  # #install ${SUPERBUILD_INSTALL_DIR}/include directory.
+  file(GLOB ALL_IN_INCLUDE_DIR "${SUPERBUILD_INSTALL_DIR}/include/*")
+  foreach(INCLUDE_DIR_ITEM ${ALL_IN_INCLUDE_DIR})
+    get_filename_component(INCLUDE_DIR_ITEM_name ${INCLUDE_DIR_ITEM} NAME)
+    if( IS_DIRECTORY ${INCLUDE_DIR_ITEM})
+      install(CODE
+        "message(STATUS \"Installing: ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}/include/${INCLUDE_DIR_ITEM_name}/\")" )
+      install(DIRECTORY   "${INCLUDE_DIR_ITEM}"
+        DESTINATION "${PKG_STAGE_DIR}/include/"
+        MESSAGE_NEVER)
+    else()
+      install(FILES   "${INCLUDE_DIR_ITEM}"
+        DESTINATION "${PKG_STAGE_DIR}/include/" )
+    endif() #if( IS_DIRECTORY    
+  endforeach()
+endfunction()
diff --git a/Packaging/install_otbapp_wrapper_scripts.cmake b/Packaging/install_otbapp_wrapper_scripts.cmake
new file mode 100644
index 0000000..bba639a
--- /dev/null
+++ b/Packaging/install_otbapp_wrapper_scripts.cmake
@@ -0,0 +1,58 @@
+#
+# 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.
+#
+function(install_otbapp_wrapper_scripts otbapp_libfile)
+  ########### install cli and gui script for each application ###########
+  set(my_script_ext "")
+  if(WIN32)
+    set(my_script_ext ".bat")
+  endif()
+  get_filename_component(otbapp_libfile_WE ${otbapp_libfile} NAME_WE)
+  #just remove otbapp_ first. we will add otbcli_ or otbgui_ later
+  set(otbapp_name)
+  string(REPLACE "otbapp_" "" otbapp_name ${otbapp_libfile_WE})
+
+  #now define cli_script with valid name otbcli_<APPNAME><EXT>
+  set(cli_script "otbcli_${otbapp_name}${my_script_ext}")
+  if(NOT EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/${cli_script}")
+    #report error!
+    message(FATAL_ERROR "Cannot find ${cli_script} for ${otbapp_libfile}")
+  endif()
+  #install file
+  install(
+    PROGRAMS "${SUPERBUILD_INSTALL_DIR}/bin/${cli_script}"
+    DESTINATION ${PKG_STAGE_DIR}/bin
+    )
+
+  #Do the same for otbgui script but only if HAVE_QT4 is set.
+  if(NOT HAVE_QT4)
+    return()
+  endif()
+  
+  #now define gui_script_actual with valid name otbgui_<APPNAME><EXT>
+  set(gui_script "otbgui_${otbapp_name}${my_script_ext}")
+  if(NOT EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/${gui_script}")
+    #report error
+    message(FATAL_ERROR "Cannot find ${gui_script} for ${otbapp_libfile}")
+  endif()
+  #install script file
+  install(
+  PROGRAMS "${SUPERBUILD_INSTALL_DIR}/bin/${gui_script}"
+  DESTINATION ${PKG_STAGE_DIR}/bin )
+endfunction() 
diff --git a/Modules/ThirdParty/Qwt/otb-module-init.cmake b/Packaging/install_python_bindings.cmake
similarity index 76%
copy from Modules/ThirdParty/Qwt/otb-module-init.cmake
copy to Packaging/install_python_bindings.cmake
index 76973fa..451894b 100644
--- a/Modules/ThirdParty/Qwt/otb-module-init.cmake
+++ b/Packaging/install_python_bindings.cmake
@@ -17,13 +17,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-
-find_package(Qwt REQUIRED)
-
-if(NOT QWT_MAJOR_VERSION EQUAL 5)
-  message(FATAL_ERROR "Only Qwt 5 is supported. Found version ${QWT_VERSION_STRING}")
-endif()
-
-if(WIN32)
-  add_definitions(-DQWT_DLL)
-endif(WIN32)
+function(install_python_bindings)
+  if(HAVE_PYTHON)
+    install(DIRECTORY ${SUPERBUILD_INSTALL_DIR}/lib/otb/python
+      DESTINATION ${PKG_STAGE_DIR}/lib
+      PATTERN "*.pyc" EXCLUDE
+      )
+  endif()
+endfunction()
diff --git a/Packaging/install_qtdev_files.cmake b/Packaging/install_qtdev_files.cmake
new file mode 100644
index 0000000..a615b02
--- /dev/null
+++ b/Packaging/install_qtdev_files.cmake
@@ -0,0 +1,46 @@
+#
+# 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.
+#
+function(install_qtdev_files)
+  if(NOT HAVE_QT4)
+    return()
+  endif()
+set(QT_REQ_DIRS)
+  if(MSVC)
+    file(GLOB ALL_LIB_FILES "${SUPERBUILD_INSTALL_DIR}/lib/*.lib")
+  endif()
+  foreach(LIB_FILE ${LIB_FILES})
+    install_rule(${LIB_FILE})
+  endforeach()
+  list(APPEND QT_REQ_DIRS imports)  
+  list(APPEND QT_REQ_DIRS mkspecs)
+  list(APPEND QT_REQ_DIRS plugins)
+  list(APPEND QT_REQ_DIRS translations)
+  foreach(QT_REQ_DIR ${QT_REQ_DIRS} )
+    if(EXISTS "${SUPERBUILD_INSTALL_DIR}/${QT_REQ_DIR}")
+      install_without_message("${SUPERBUILD_INSTALL_DIR}/${QT_REQ_DIR}" "")
+    endif()
+  endforeach()
+
+  install(FILES
+    ${CMAKE_CURRENT_SOURCE_DIR}/Files/qt.conf
+    DESTINATION ${PKG_STAGE_DIR}/bin
+    )
+ 
+endfunction()
diff --git a/Packaging/install_rule.cmake b/Packaging/install_rule.cmake
new file mode 100644
index 0000000..b4d40f0
--- /dev/null
+++ b/Packaging/install_rule.cmake
@@ -0,0 +1,123 @@
+#
+# 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.
+#
+#
+# This is one big fat if-elseif ladder
+# that will detect a type and destination to use in
+# install(..
+
+function(install_rule src_file)
+
+  get_filename_component(src_file_EXT ${src_file} EXT)
+  get_filename_component(src_file_NAME ${src_file} NAME)
+  get_filename_component(src_file_NAME_WE ${src_file} NAME_WE)
+  get_filename_component(src_file_PATH ${src_file} PATH)
+
+  file(GLOB src_file_star "${src_file_PATH}/${src_file_NAME_WE}*")
+  foreach(sfile ${src_file_star})
+    get_filename_component(sfile_NAME ${sfile} NAME)
+    string(TOLOWER "${sfile_NAME}" sfile_NAME_LOWER)
+
+    get_filename_component(sfile_ABS "${sfile}" ABSOLUTE)
+    string(TOLOWER "${sfile_ABS}" sfile_ABS_LOWER)
+    set(install_type)
+    set(install_dir)
+    if ("${sfile_NAME_LOWER}" MATCHES "^(otb|mvd)([a-z0-9]+)test*.*" )
+      if(PKG_DEBUG)
+        message("SKIP INSTALL for ${sfile_NAME_LOWER}")
+      endif()
+      continue()
+    elseif ("${sfile_NAME_LOWER}" MATCHES "headertest" )
+      # special case for remote modules which has executables
+      # like MosiacHeaderTest1.exe. This ideally should be
+      # fixed in remote modules like OTBMosiacHeaderTest1.exe
+      if(PKG_DEBUG)
+	message("SKIP INSTALL for ${sfile_NAME_LOWER}")
+      endif()
+      continue()
+    elseif("${sfile_ABS_LOWER}" MATCHES "(\\.exe)$")
+      set(install_type PROGRAMS)
+      set(install_dir bin)
+    elseif("${sfile_ABS_LOWER}" MATCHES "(\\.dll)$")
+      set(install_type FILES)
+      set(install_dir bin) 
+    elseif("${sfile_ABS_LOWER}" MATCHES "(\\.lib)$")
+      set(install_type FILES)
+      set(install_dir lib)
+    elseif("${sfile_ABS_LOWER}" MATCHES "(\\.pyd)$")
+      #python bindings are installed in install_python_bindings
+      continue()
+    elseif( "${sfile_NAME_LOWER}" MATCHES "^_otbapplication")
+      # _otbApplication.so matched below; so we explicit skip it
+      # because it's already handled in install_python_bindings.cmake
+      continue()
+    elseif("${sfile_ABS_LOWER}" MATCHES "\\.lnk$")
+      #we don't install symlink on windows. issue a warning
+      set(install_type "symlink")
+      set(install_dir)
+    elseif("${sfile_ABS_LOWER}" MATCHES "(\\.a)$")
+      set(install_type FILES)
+      set(install_dir lib)
+    elseif("${sfile_ABS_LOWER}" MATCHES "\\.prl$")
+      continue()
+    elseif("${sfile_ABS_LOWER}" MATCHES "\\.la$")
+      continue()
+    elseif("${sfile_ABS_LOWER}" MATCHES "\\.settings$")
+      continue()
+    else()
+      if(UNIX)
+        #the last else() loop where we run a 'file' command to find file type and directory
+        set(install_type)
+        set(install_dir)
+        #this is whole other story
+        detect_using_file_command(${sfile_ABS} install_type install_dir)
+      endif(UNIX)
+    endif()
+
+    if(install_type STREQUAL "symlink")
+      #we don't install symlink on windows. issue a warning and continue
+      if(PKG_DEBUG)
+        message("${sfile_ABS} is a symbolic link and this will be excluded from package")
+      endif()
+      continue()
+    endif()
+    
+    # This check comes outside the first if-elseif ladder
+    # because no matter what extension of file type, otbapp_* must go
+    # into lib/otb/applications
+  if("${sfile_NAME_LOWER}" MATCHES "^otbapp_")
+    install_otbapp_wrapper_scripts(${sfile_NAME})
+    set(install_dir "lib/otb/applications")
+    set(install_type PROGRAMS)
+  endif()
+  
+    if(NOT install_type OR NOT install_dir)
+      #throw fatal error and return
+      message(FATAL_ERROR "sfile_ABS=${sfile_ABS}.\ninstall_type=${install_type}\ninstall_dir=${install_dir}")
+      return()
+    endif()
+
+    install(${install_type} "${sfile}"
+      DESTINATION
+      "${PKG_STAGE_DIR}/${install_dir}"
+      )
+
+  endforeach()  
+endfunction()   
+
diff --git a/Packaging/install_share_dirs.cmake b/Packaging/install_share_dirs.cmake
new file mode 100644
index 0000000..fabeb3d
--- /dev/null
+++ b/Packaging/install_share_dirs.cmake
@@ -0,0 +1,97 @@
+#
+# 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.
+#
+function(install_share_dirs)
+
+  #a convenient cmake var for storing <prefix>/bin
+  set(PKG_STAGE_BIN_DIR "${PKG_STAGE_DIR}/bin")
+
+  #<prefix>/share for gdal data files
+  set(PKG_SHARE_DEST_DIR ${PKG_STAGE_DIR}/share)
+
+  set(PKG_SHARE_SOURCE_DIR ${SUPERBUILD_INSTALL_DIR}/share)
+
+
+  ####################### install mvd i18N ############################
+  # OTB i18n directory is different from qt's i18N directory
+  #which is <prefix>/share/qt4/translations by default on linux.
+
+  # To install otb i18n directory correctly, we need to find
+  #Monteverdi_INSTALL_DATA_DIR. Value of this is a defined in  ConfigureMonteverdi.h
+  # and default value is "share/OTB-X.Y"
+  #...
+  # #define Monteverdi_INSTALL_DATA_DIR
+  #...
+  #Instead of parsing ConfigureMonteverdi.h,
+  #we simply use default and add a check for this directory!
+
+  #define Monteverdi_INSTALL_DATA_DIR "share/OTB-X.Y"
+
+  set(OTB_I18N_DIRNAME OTB-${PKG_OTB_VERSION_MAJOR}.${PKG_OTB_VERSION_MINOR}/i18n)  
+  set(MVD_I18N_SOURCE_DIR ${PKG_SHARE_SOURCE_DIR}/${OTB_I18N_DIRNAME})
+  if(NOT EXISTS "${MVD_I18N_SOURCE_DIR}")
+    message(FATAL_ERROR "Error ${MVD_I18N_SOURCE_DIR} not exists")
+  endif()
+  set(MVD_I18N_DEST_DIR ${PKG_SHARE_DEST_DIR}/${OTB_I18N_DIRNAME})
+  file(GLOB MVD_APP_TS_FILES ${PACKAGE_OTB_SRC_DIR}/i18n/*.ts) # qm files
+  foreach(APP_TS_FILE ${MVD_APP_TS_FILES})
+    get_filename_component(APP_TS_FILENAME ${APP_TS_FILE} NAME_WE)
+    install(FILES ${MVD_I18N_SOURCE_DIR}/${APP_TS_FILENAME}.qm
+      DESTINATION ${MVD_I18N_DEST_DIR}
+      )
+  endforeach()
+
+  ####################### install GDAL data ############################
+  set(GDAL_DATA_DIR ${PKG_SHARE_SOURCE_DIR}/gdal)
+  #MSVC install gdal-data in in a different directory. So we don't spoil it
+  if(MSVC)
+    set(GDAL_DATA_DIR ${SUPERBUILD_INSTALL_DIR}/data)
+  endif()
+  if(NOT EXISTS "${GDAL_DATA_DIR}/epsg.wkt")
+    message(FATAL_ERROR
+      "Cannot generate package without GDAL_DATA : ${GDAL_DATA_DIR}")
+  endif()
+  install_without_message("${GDAL_DATA_DIR}" "share" )
+
+  ####################### install GeoTIFF data ########################
+  install_without_message("${PKG_SHARE_SOURCE_DIR}/epsg_csv" "share" )
+
+  ####################### install OSSIM data ##########################
+  install_without_message("${PKG_SHARE_SOURCE_DIR}/ossim" "share" )
+
+  ####################### install proj share ##########################
+  if(EXISTS ${PKG_SHARE_SOURCE_DIR}/proj)
+    install_without_message("${PKG_SHARE_SOURCE_DIR}/proj" "share" )
+  endif()
+  
+  ####################### Install copyrights ##########################
+  #install license for packages
+  install_without_message("${PKG_SHARE_SOURCE_DIR}/copyright" "share" )
+  install(FILES ${PKG_SHARE_SOURCE_DIR}/copyright/LICENSE
+    DESTINATION ${PKG_STAGE_DIR})
+
+  ####################### Install VERSION ##########################
+  set(PKG_VERSION_FILE
+    "${SUPERBUILD_INSTALL_DIR}/share/doc/${PKG_OTB_VERSION_MAJOR}.${PKG_OTB_VERSION_MINOR}/VERSION")
+  if(EXISTS ${PKG_VERSION_FILE} )
+    install(FILES ${PKG_VERSION_FILE} DESTINATION ${PKG_STAGE_DIR})
+  endif()
+ 
+endfunction()
+
diff --git a/Modules/ThirdParty/Qt4/otb-module-init.cmake b/Packaging/install_vstudio_files.cmake
similarity index 79%
copy from Modules/ThirdParty/Qt4/otb-module-init.cmake
copy to Packaging/install_vstudio_files.cmake
index d121d06..8630dd8 100644
--- a/Modules/ThirdParty/Qt4/otb-module-init.cmake
+++ b/Packaging/install_vstudio_files.cmake
@@ -17,8 +17,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-
-find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL QtXml )
-mark_as_advanced( QT_QMAKE_EXECUTABLE )
-set( QT_USE_QTXML 1 )
-include( ${QT_USE_FILE} )
+function(install_vstudio_files)
+if(MSVC)
+    install(FILES
+      "Files/OTB Project.zip"
+      "Files/start_devenv.bat"
+      DESTINATION "${PKG_STAGE_DIR}" )
+  endif()
+endfunction()
diff --git a/Packaging/install_without_message.cmake b/Packaging/install_without_message.cmake
new file mode 100644
index 0000000..947e8d9
--- /dev/null
+++ b/Packaging/install_without_message.cmake
@@ -0,0 +1,40 @@
+#
+# 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.
+#
+function(install_without_message src_dir dst_dir_suffix)
+  set (extra_func_args ${ARGN})
+  list(LENGTH extra_func_args num_extra_args)
+  if (${num_extra_args} GREATER 0)
+    list(GET extra_func_args 0 optional_msg)
+  endif()
+
+  if( "${dst_dir_suffix}" STREQUAL "")
+    set(dst_dir "${PKG_STAGE_DIR}")
+  else()
+    set(dst_dir "${PKG_STAGE_DIR}/${dst_dir_suffix}")
+  endif()
+
+  get_filename_component(src_dir_name ${src_dir} NAME)
+  set(install_msg "message(STATUS \"Installing: ${CMAKE_INSTALL_PREFIX}/${dst_dir}/${src_dir_name} ${optional_msg}\")")
+  install(CODE "${install_msg}" )
+  install(
+    DIRECTORY   ${src_dir}
+    DESTINATION ${dst_dir}
+    MESSAGE_NEVER )
+endfunction() #install_without_message
diff --git a/Packaging/installer_files.cmake b/Packaging/installer_files.cmake
new file mode 100644
index 0000000..941f7f8
--- /dev/null
+++ b/Packaging/installer_files.cmake
@@ -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.
+#
+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)
+  elseif(LINUX) #not osx
+    set(README_FILE ${RSTDOC_DIR}/Installation_Linux.txt)
+  elseif(WIN32) #windows
+    set(README_FILE ${RSTDOC_DIR}/Installation_Windows.txt)
+  endif()
+  configure_file("${README_FILE}" ${CMAKE_BINARY_DIR}/README )
+  install(FILES ${CMAKE_BINARY_DIR}/README DESTINATION ${PKG_STAGE_DIR} )
+
+  
+  #configure pkgsetup for mac and linux
+  if(LINUX)
+    configure_file(
+      ${CMAKE_CURRENT_SOURCE_DIR}/Files/linux_pkgsetup.in
+      ${CMAKE_CURRENT_BINARY_DIR}/pkgsetup @ONLY
+      )
+  endif()
+
+  if(APPLE)
+    set(ORIGINAL_RPATH_TO_REPLACE ${SUPERBUILD_INSTALL_DIR}/lib)
+    configure_file(
+      ${CMAKE_CURRENT_SOURCE_DIR}/Files/macx_pkgsetup.in
+      ${CMAKE_CURRENT_BINARY_DIR}/pkgsetup @ONLY
+      )
+
+    #install icon file for .app file. Monteverdi and Mapla has same icon!
+    install(FILES
+      Files/Monteverdi.icns DESTINATION ${PKG_STAGE_DIR})
+  endif()
+
+  #start installing script and other stuff related to package
+  if(UNIX)
+    install( PROGRAMS
+      ${CMAKE_BINARY_DIR}/pkgsetup
+      ${CMAKE_BINARY_DIR}/make_symlinks
+      Files/setup_python.sh
+      Files/otbenv.profile
+      DESTINATION ${PKG_STAGE_DIR}
+      )
+  endif()
+
+  # We also need wrapper script to start mapla & monteverdi
+  #if(NOT HAVE_MVD)
+  #  message(FATAL_ERROR "not have mvd")
+  #endif()
+  if(HAVE_MVD)
+    install(PROGRAMS
+      Files/mapla${SCRIPT_EXT}
+      Files/monteverdi${SCRIPT_EXT}
+      DESTINATION ${PKG_STAGE_DIR}
+      )
+
+    #for mac osx, we have a template.app which is
+    # later processed in pkgsetup (macx_pkgsetup.in)
+    if(APPLE)
+      install(DIRECTORY Files/template.app
+	DESTINATION "${PKG_STAGE_DIR}")
+    endif()
+  endif() #HAVE_MVD
+
+  #my_file_ext is required for otbcli and otbgui files which has
+  # no extension on linux. (hence we cannot use SCRIPT_EXT
+
+  #For windows otbenv.bash and otbenv.bat is required.
+  # Former is for windows shell users and latter is for other
+  # linux emulator such as bash for windows or mobxterm
+  set(my_file_ext "")
+  if(WIN32)
+    set(my_file_ext ".bat")
+    install( PROGRAMS
+      Files/otbenv.bat
+      Files/otbenv.bash
+      DESTINATION ${PKG_STAGE_DIR}
+      )
+  endif()
+
+  #these scripts are not auto-installed in PKG_STAGE_DIR
+  #could this be move them to somewhere else?
+  install(PROGRAMS
+    "${SUPERBUILD_INSTALL_DIR}/bin/otbcli${my_file_ext}"
+    "${SUPERBUILD_INSTALL_DIR}/bin/otbgui${my_file_ext}"
+    DESTINATION ${PKG_STAGE_DIR}/bin)
+
+  install(PROGRAMS
+    Files/selftester${SCRIPT_EXT}
+    Files/uninstall_otb${SCRIPT_EXT}
+    DESTINATION ${PKG_STAGE_DIR}/tools)
+
+  # only required for linux.
+  # THIS WILL BE REMOVED ONCE INSTALLATION IS DONE
+  # USE --noexec option when running .run file to keep this file
+  # along with other installation files
+  if(LINUX)
+    install(PROGRAMS
+      "${PATCHELF_PROGRAM}"
+      DESTINATION ${PKG_STAGE_DIR})
+  endif()
+
+  install(FILES
+    Files/build_examples.cmake
+    DESTINATION ${PKG_STAGE_DIR}/tools)
+
+  
+  #add otb_loader
+  add_executable(otb_loader ${CMAKE_CURRENT_SOURCE_DIR}/Files/otb_loader.cxx)
+  target_link_libraries(otb_loader ${CMAKE_DL_LIBS})
+  install(TARGETS otb_loader DESTINATION ${PKG_STAGE_DIR}/tools)
+  add_dependencies(otb_loader PATCHELF)
+endmacro()
diff --git a/Packaging/isfile_symlink.cmake b/Packaging/isfile_symlink.cmake
new file mode 100644
index 0000000..0d3b490
--- /dev/null
+++ b/Packaging/isfile_symlink.cmake
@@ -0,0 +1,89 @@
+#
+# 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.
+#
+function(isfile_symlink file result_var1 result_var2)
+  #
+  # A file is not executable until proven otherwise:
+  #
+  set(${result_var1} 0 PARENT_SCOPE)
+  set(${result_var2} "" PARENT_SCOPE)
+
+  get_filename_component(file_full "${file}" ABSOLUTE)
+  string(TOLOWER "${file_full}" file_full_lower)
+
+  # If file name ends in .lnk on Windows,
+  # *assume* symlink a.k.a shortcut.
+  #
+  if(WIN32 AND NOT UNIX)
+    if("${file_full_lower}" MATCHES "\\.lnk$")
+      set(${result_var1} 1 PARENT_SCOPE)
+      #Assuming the file is linked to a file
+      #with same name without .lnk extension
+      get_filename_component(file_full_name_we "${file_full}" NAME_WE)
+      set(${result_var2} "${file_full_name_we}" PARENT_SCOPE)
+      return()
+    endif()
+
+    # A clause could be added here that uses output or return value of dumpbin
+    # to determine ${result_var}. In 99%+? practical cases, the exe name
+    # match will be sufficient...
+    #
+  endif()
+
+  #if we are not on a unix or unix-like platform,
+  #then we don't have any business after this line.
+  if(NOT UNIX)
+    return()
+  endif()
+
+  # Use the information returned from the Unix shell command "file" to
+  # determine if ${file_full} should be considered an executable file...
+  #
+  # If the file command's output contains "executable" and does *not* contain
+  # "text" then it is likely an executable suitable for prerequisite analysis
+  # via the get_prerequisites macro.
+  
+  execute_process(COMMAND "${READLINK}" "${file_full}"
+    RESULT_VARIABLE readlink_rv
+    OUTPUT_VARIABLE readlink_ov
+    ERROR_VARIABLE readlink_ev
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+
+  if(PKG_DEBUG)
+    message("${READLINK} on '${file_full} has output: '${readlink_ov}'\nreadlink_ev=${readlink_ev}")
+  endif()
+  
+  if(readlink_rv STREQUAL "1")
+    set(${result_var1} 0 PARENT_SCOPE)
+    set(${result_var2} "" PARENT_SCOPE)
+    return()
+  endif()
+
+  #got a symlink!. set result_var1 to TRUE
+  set(${result_var1} 1 PARENT_SCOPE)
+
+  #Now get the resolved link to result_var2
+  set(symlinked_to)
+  string(STRIP ${readlink_ov} symlinked_to)
+  set(${result_var2} "${symlinked_to}" PARENT_SCOPE)
+
+  return()
+
+endfunction()
diff --git a/Packaging/makeself/COPYING b/Packaging/makeself/COPYING
new file mode 100644
index 0000000..d159169
--- /dev/null
+++ b/Packaging/makeself/COPYING
@@ -0,0 +1,339 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/Packaging/makeself/README.md b/Packaging/makeself/README.md
new file mode 100644
index 0000000..cf7f312
--- /dev/null
+++ b/Packaging/makeself/README.md
@@ -0,0 +1,220 @@
+[![AUR](https://img.shields.io/aur/license/yaourt.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
+[![Build Status](https://travis-ci.org/megastep/makeself.svg?branch=master)](https://travis-ci.org/megastep/makeself)
+
+# makeself - Make self-extractable archives on Unix
+
+[makeself.sh][1] is a small shell script that generates a self-extractable
+compressed tar archive from a directory. The resulting file appears as a shell script
+(many of those have a **.run** suffix), and can be launched as is. The archive
+will then uncompress itself to a temporary directory and an optional arbitrary
+command will be executed (for example an installation script). This is pretty
+similar to archives generated with WinZip Self-Extractor in the Windows world.
+Makeself archives also include checksums for integrity self-validation (CRC
+and/or MD5 checksums).
+
+The makeself.sh script itself is used only to create the archives from a
+directory of files. The resultant archive is actually a compressed (using
+gzip, bzip2, or compress) TAR archive, with a small shell script stub at the
+beginning. This small stub performs all the steps of extracting the files,
+running the embedded command, and removing the temporary files when done.
+All the user has to do to install the software contained in such an
+archive is to "run" the archive, i.e **sh nice-software.run**. I recommend
+using the ".run" (which was introduced by some Makeself archives released by
+Loki Software) or ".sh" suffix for such archives not to confuse the users,
+so that they will know they are actually shell scripts (with quite a lot of binary data
+attached to them though!).
+
+I am trying to keep the code of this script as portable as possible, i.e it is
+not relying on any bash-specific features and only calls commands that are
+installed on any functioning UNIX-compatible system. This script as well as
+the archives it generates should run on any Unix flavor, with any compatible
+Bourne shell, provided of course that the compression programs are available.
+
+As of version 2.1, Makeself has been rewritten and tested on the following
+platforms :
+
+  * Linux (all distributions)
+  * Sun Solaris (8 and above)
+  * HP-UX (tested on 11.0 and 11i on HPPA RISC)
+  * SCO OpenUnix and OpenServer
+  * IBM AIX 5.1L
+  * macOS (Darwin)
+  * SGI IRIX 6.5
+  * FreeBSD
+  * UnicOS / Cray
+  * Cygwin (Windows)
+
+If you successfully run Makeself and/or archives created with it on another
+system, then please [let me know][2]!
+
+Examples of publicly available archives made using makeself are :
+
+  * Game patches and installers for [Id Software][3] games like Quake 3 for Linux or Return To Castle Wolfenstein ;
+  * All game patches released by [Loki Software][4] for the Linux version of popular games ;
+  * The [nVidia drivers][5] for Linux
+  * The installer for the Linux version of [Google Earth][6]
+  * The [VirtualBox][7] installers for Linux
+  * The [Makeself][1] distribution itself ;-)
+  * and countless others...
+
+**Important note for Apache users:** By default, most Web servers will think that Makeself archives are regular text files and thus they may show up as text in a Web browser. The correct way to prevent this is to add a MIME type for this file format, like so (in httpd.conf) :
+
+`AddType application/x-makeself .run`
+
+**Important note for certain GNU/Linux distributions:** Archives created with Makeself prior to v2.1.2 were using an old syntax for the _head_ and _tail_ Unix commands that is being progressively obsoleted in their GNU forms. Therefore you may have problems uncompressing some of these archives. A workaround for this is to set the environment variable $_POSIX2_VERSION to enable the old syntax, i.e. :
+
+`export _POSIX2_VERSION=199209`
+
+## Usage
+
+The syntax of makeself is the following:
+
+```
+makeself.sh [args] archive_dir file_name label startup_script [script_args]
+```
+
+  * _args_ are optional options for Makeself. The available ones are :
+
+    * **--version** : Prints the version number on stdout, then exits immediately
+    * **--gzip** : Use gzip for compression (the default on platforms on which gzip is commonly available, like Linux)
+    * **--bzip2** : Use bzip2 instead of gzip for better compression. The bzip2 command must be available in the command path. It is recommended that the archive prefix be set to something like '.bz2.run', so that potential users know that they'll need bzip2 to extract it.
+    * **--pbzip2** : Use pbzip2 instead of gzip for better and faster compression on machines having multiple CPUs. The pbzip2 command must be available in the command path. It is recommended that the archive prefix be set to something like '.bz2.run', so that potential users know that they'll need bzip2 to extract it.
+    * **--xz** : Use xz instead of gzip for better compression. The xz command must be available in the command path. It is recommended that the archive prefix be set to something like '.xz.run' for the archive, so that potential users know that they'll need xz to extract it.
+    * **--lzo** : Use lzop instead of gzip for better compression. The lzop command must be available in the command path. It is recommended that the archive prefix be set to something like '.lzo.run' for the archive, so that potential users know that they'll need lzop to extract it.
+    * **--lz4** : Use lz4 instead of gzip for better compression. The lz4 command must be available in the command path. It is recommended that the archive prefix be set to something like '.lz4.run' for the archive, so that potential users know that they'll need lz4 to extract it.
+    * **--pigz** : Use pigz for compression.
+    * **--base64** : Encode the archive to ASCII in Base64 format instead of compressing (base64 command required).
+    * **--gpg-encrypt** : Encrypt the archive using `gpg -ac -z $COMPRESS_LEVEL`. This will prompt for a password to encrypt with. Assumes that potential users have `gpg` installed.
+    * **--ssl-encrypt** : Encrypt the archive using `openssl aes-256-cbc -a -salt`. This will prompt for a password to encrypt with. Assumes that the potential users have the OpenSSL tools installed.
+    * **--compress** : Use the UNIX `compress` command to compress the data. This should be the default on all platforms that don't have gzip available.
+    * **--nocomp** : Do not use any compression for the archive, which will then be an uncompressed TAR.
+    * **--complevel** : Specify the compression level for gzip, bzip2, pbzip2, xz, lzo or lz4. (defaults to 9)
+    * **--notemp** : The generated archive will not extract the files to a temporary directory, but in a new directory created in the current directory. This is better to distribute software packages that may extract and compile by themselves (i.e. launch the compilation through the embedded script).
+    * **--current** : Files will be extracted to the current directory, instead of in a subdirectory. This option implies `--notemp` above.
+    * **--follow** : Follow the symbolic links inside of the archive directory, i.e. store the files that are being pointed to instead of the links themselves.
+    * **--append** _(new in 2.1.x)_: Append data to an existing archive, instead of creating a new one. In this mode, the settings from the original archive are reused (compression type, label, embedded script), and thus don't need to be specified again on the command line.
+    * **--header** : Makeself 2.0 uses a separate file to store the header stub, called `makeself-header.sh`. By default, it is assumed that it is stored in the same location as makeself.sh. This option can be used to specify its actual location if it is stored someplace else.
+    * **--copy** : Upon extraction, the archive will first extract itself to a temporary directory. The main application of this is to allow self-contained installers stored in a Makeself archive on a CD, when the installer program will later need to unmount the CD and allow a new one to be inserted. This prevents "Filesystem busy" errors for installers that span multiple CDs.
+    * **--nox11** : Disable the automatic spawning of a new terminal in X11.
+    * **--nowait** : When executed from a new X11 terminal, disable the user prompt at the end of the script execution.
+    * **--nomd5** and **--nocrc** : Disable the creation of a MD5 / CRC checksum for the archive. This speeds up the extraction process if integrity checking is not necessary.
+    * **--lsm _file_** : Provide and LSM file to makeself, that will be embedded in the generated archive. LSM files are describing a software package in a way that is easily parseable. The LSM entry can then be later retrieved using the `--lsm` argument to the archive. An example of a LSM file is provided with Makeself.
+    * **--tar-extra opt** : Append more options to the tar command line.
+
+        For instance, in order to exclude the `.git` directory from the packaged archive directory using the GNU `tar`, one can use `makeself.sh --tar-extra "--exclude=.git" ...`
+
+    * **--keep-umask** : Keep the umask set to shell default, rather than overriding when executing self-extracting archive.
+    * **--packaging-date date** : Use provided string as the packaging date instead of the current date.
+    * **--license** : Append a license file.
+    * **--nooverwrite** : Do not extract the archive if the specified target directory already exists.
+    * **--header file** : Specify the location of the header script file (default `makeself-header.sh`)
+    * **--help-header file** : Add a header to the archive's `--help` output.
+  * _archive_dir_ is the name of the directory that contains the files to be archived
+  * _file_name_ is the name of the archive to be created
+  * _label_ is an arbitrary text string describing the package. It will be displayed while extracting the files.
+  * _startup_script_ is the command to be executed _from within_ the directory of extracted files. Thus, if you wish to execute a program contain in this directory, you must prefix your command with `./`. For example, `./program` will be fine. The _script_args_ are additional arguments for this command.
+
+Here is an example, assuming the user has a package image stored in a **/home/joe/mysoft**, and he wants to generate a self-extracting package named
+**mysoft.sh**, which will launch the "setup" script initially stored in /home/joe/mysoft :
+
+`makeself.sh /home/joe/mysoft mysoft.sh "Joe's Nice Software Package" ./setup
+`
+
+Here is also how I created the [makeself.run][9] archive which contains the Makeself distribution :
+
+`makeself.sh --notemp makeself makeself.run "Makeself by Stephane Peter" echo "Makeself has extracted itself" `
+
+Archives generated with Makeself can be passed the following arguments:
+
+  * _--keep_ : Prevent the files to be extracted in a temporary directory that will be removed after the embedded script's execution. The files will then be extracted in the current working directory and will stay here until you remove them.
+  * _--verbose_ : Will prompt the user before executing the embedded command
+  * _--target dir_ : Allows to extract the archive in an arbitrary place.
+  * _--nox11_ : Do not spawn a X11 terminal.
+  * _--confirm_ : Prompt the user for confirmation before running the embedded command.
+  * _--info_ : Print out general information about the archive (does not extract).
+  * _--lsm_ : Print out the LSM entry, if it is present.
+  * _--list_ : List the files in the archive.
+  * _--check_ : Check the archive for integrity using the embedded checksums. Does not extract the archive.
+  * _--nochown_ : By default, a `chown -R` command is run on the target directory after extraction, so that all files belong to the current user. This is mostly needed if you are running as root, as tar will then try to recreate the initial user ownerships. You may disable this behavior with this flag.
+  * _--tar_ : Run the tar command on the contents of the archive, using the following arguments as parameter for the command.
+  * _--noexec_ : Do not run the embedded script after extraction.
+  * _--nodiskspace_ : Do not check for available disk space before attempting to extract.
+
+Any subsequent arguments to the archive will be passed as additional arguments to the embedded command. You must explicitly use the _--_ special command-line construct before any such options to make sure that Makeself will not try to interpret them.
+
+## Maven Usage
+
+Makeself is now supported by the following maven plugin [makeself-maven-plugin](https://github.com/hazendaz/makeself-maven-plugin).  Please refer to project for usage and report any bugs in regards to maven plugin on that project.
+
+## License
+
+Makeself is covered by the [GNU General Public License][8] (GPL) version 2 and above. Archives generated by Makeself don't have to be placed under this license (although I encourage it ;-)), since the archive itself is merely data for Makeself.
+
+## Contributing
+
+I will gladly consider merging your pull requests on the [GitHub][10] repository. However, please keep the following in mind:
+
+  * One of the main purposes of Makeself is portability. Do not submit patches that will break supported platforms. The more platform-agnostic, the better.
+  * Please explain clearly what the purpose of the patch is, and how you achieved it.
+
+## Download
+
+Get the latest official distribution [here][9] (version 2.3.1).
+
+The latest development version can be grabbed from [GitHub][10]. Feel free to submit any patches there through the fork and pull request process.
+
+## Version history
+
+  * **v1.0:** Initial public release
+  * **v1.1:** The archive can be passed parameters that will be passed on to the embedded script, thanks to John C. Quillan
+  * **v1.2:** Cosmetic updates, support for bzip2 compression and non-temporary archives. Many ideas thanks to Francois Petitjean.
+  * **v1.3:** More patches from Bjarni R. Einarsson and Francois Petitjean: Support for no compression (--nocomp), script is no longer mandatory, automatic launch in an xterm, optional verbose output, and -target archive option to indicate where to extract the files.
+  * **v1.4:** Many patches from Francois Petitjean: improved UNIX compatibility, automatic integrity checking, support of LSM files to get info on the package at run time..
+  * **v1.5.x:** A lot of bugfixes, and many other patches, including automatic verification through the usage of checksums. Version 1.5.5 was the stable release for a long time, even though the Web page didn't get updated ;-). Makeself was also officially made a part of the [Loki Setup installer][11], and its source is being maintained as part of this package.
+  * **v2.0:** Complete internal rewrite of Makeself. The command-line parsing was vastly improved, the overall maintenance of the package was greatly improved by separating the stub from makeself.sh. Also Makeself was ported and tested to a variety of Unix platforms.
+  * **v2.0.1:** First public release of the new 2.0 branch. Prior versions are officially obsoleted. This release introduced the '--copy' argument that was introduced in response to a need for the [UT2K3][12] Linux installer.
+  * **v2.1.0:** Big change : Makeself can now support multiple embedded tarballs, each stored separately with their own checksums. An existing archive can be updated with the --append flag. Checksums are also better managed, and the --nochown option for archives appeared.
+  * **v2.1.1:** Fixes related to the Unix compression (compress command). Some Linux distributions made the insane choice to make it unavailable, even though gzip is capable of uncompressing these files, plus some more bugfixes in the extraction and checksum code.
+  * **v2.1.2:** Some bug fixes. Use head -n to avoid problems with POSIX conformance.
+  * **v2.1.3:** Bug fixes with the command line when spawning terminals. Added --tar, --noexec for archives. Added --nomd5 and --nocrc to avoid creating checksums in archives. The embedded script is now run through "eval". The --info output now includes the command used to create the archive. A man page was contributed by Bartosz Fenski.
+  * **v2.1.4:** Fixed --info output. Generate random directory name when extracting files to . to avoid problems. Better handling of errors with wrong permissions for the directory containing the files. Avoid some race conditions, Unset the $CDPATH variable to avoid problems if it is set. Better handling of dot files in the archive directory.
+  * **v2.1.5:** Made the md5sum detection consistent with the header code. Check for the presence of the archive directory. Added --encrypt for symmetric encryption through gpg (Eric Windisch). Added support for the digest command on Solaris 10 for MD5 checksums. Check for available disk space before extracting to the target directory (Andreas Schweitzer). Allow extraction to run asynchronously (patch by Peter Hatch). Use file descriptors internally to avoid error messages (patch by Kay  [...]
+  * **v2.1.6:** Replaced one dot per file progress with a realtime progress percentage and a spining cursor. Added --noprogress to prevent showing the progress during the decompression. Added --target dir to allow extracting directly to a target directory. (Guy Baconniere)
+  * **v2.2.0:** First major new release in years! Includes many bugfixes and user contributions. Please look at the [project page on Github][10] for all the details.
+  * **v2.3.0:** Support for archive encryption via GPG or OpenSSL. Added LZO and LZ4 compression support. Options to set the packaging date and stop the umask from being overridden. Optionally ignore check for available disk space when extracting. New option to check for root permissions before extracting.
+  * **v2.3.1:** Various compatibility updates. Added unit tests for Travis CI in the GitHub repo. New --tar-extra, --untar-extra, --gpg-extra, --gpg-asymmetric-encrypt-sign options.
+
+## Links
+
+  * Check out the ["Loki Setup"][11] installer, used to install many Linux games and other applications, and of which I am the co-author. Since the demise of Loki, I am now the official maintainer of the project, and it is now being hosted here on GitHub.
+  * Bjarni R. Einarsson also wrote the **setup.sh** installer script, inspired by Makeself. [Check it out !][14]
+
+## Contact
+
+This script was written by [Stéphane Peter][15] (megastep at megastep.org). Any enhancements and suggestions are welcome.
+
+Contributions were included from John C. Quillan, Bjarni R. Einarsson,
+Francois Petitjean, Ryan C. Gordon, and many contributors on GitHub. If you think I forgot
+your name, don't hesitate to contact me.
+
+This project is now hosted on GitHub. Feel free to submit patches and bug reports on the [project page][10].
+
+* * *
+
+[Stephane Peter][2]
+
+   [1]: http://makeself.io/
+   [2]: mailto:megastep at megastep.org
+   [3]: http://www.idsoftware.com/
+   [4]: http://www.lokigames.com/products/myth2/updates.php3
+   [5]: http://www.nvidia.com/
+   [6]: http://earth.google.com/
+   [7]: http://www.virtualbox.org/
+   [8]: http://www.gnu.org/copyleft/gpl.html
+   [9]: https://github.com/megastep/makeself/releases/download/release-2.3.1/makeself-2.3.1.run
+   [10]: https://github.com/megastep/makeself
+   [11]: https://github.com/megastep/loki_setup/
+   [12]: http://www.unrealtournament2003.com/
+   [13]: http://www.icculus.org/
+   [14]: http://bre.klaki.net/programs/setup.sh/
+   [15]: https://stephanepeter.com/
diff --git a/Packaging/makeself/makeself-header.sh b/Packaging/makeself/makeself-header.sh
new file mode 100755
index 0000000..83131a1
--- /dev/null
+++ b/Packaging/makeself/makeself-header.sh
@@ -0,0 +1,553 @@
+cat << EOF  > "$archname"
+#!/bin/sh
+# This script was generated using Makeself $MS_VERSION
+
+ORIG_UMASK=\`umask\`
+if test "$KEEP_UMASK" = n; then
+    umask 077
+fi
+
+CRCsum="$CRCsum"
+MD5="$MD5sum"
+TMPROOT=\${TMPDIR:=/tmp}
+USER_PWD="\$PWD"; export USER_PWD
+
+label="$LABEL"
+script="$SCRIPT"
+scriptargs="$SCRIPTARGS"
+licensetxt="$LICENSE"
+helpheader='$HELPHEADER'
+targetdir="$archdirname"
+filesizes="$filesizes"
+keep="$KEEP"
+nooverwrite="$NOOVERWRITE"
+quiet="n"
+accept="n"
+nodiskspace="n"
+export_conf="$EXPORT_CONF"
+
+print_cmd_arg=""
+if type printf > /dev/null; then
+    print_cmd="printf"
+elif test -x /usr/ucb/echo; then
+    print_cmd="/usr/ucb/echo"
+else
+    print_cmd="echo"
+fi
+	
+if test -d /usr/xpg4/bin; then
+    PATH=/usr/xpg4/bin:\$PATH
+    export PATH
+fi
+
+unset CDPATH
+
+MS_Printf()
+{
+    \$print_cmd \$print_cmd_arg "\$1"
+}
+
+MS_PrintLicense()
+{
+  if test x"\$licensetxt" != x; then
+    echo "\$licensetxt"
+    if test x"\$accept" != xy; then
+      while true
+      do
+        MS_Printf "Please type y to accept, n otherwise: "
+        read yn
+        if test x"\$yn" = xn; then
+          keep=n
+          eval \$finish; exit 1
+          break;
+        elif test x"\$yn" = xy; then
+          break;
+        fi
+      done
+    fi
+  fi
+}
+
+MS_diskspace()
+{
+	(
+	df -kP "\$1" | tail -1 | awk '{ if (\$4 ~ /%/) {print \$3} else {print \$4} }'
+	)
+}
+
+MS_dd()
+{
+    blocks=\`expr \$3 / 1024\`
+    bytes=\`expr \$3 % 1024\`
+    dd if="\$1" ibs=\$2 skip=1 obs=1024 conv=sync 2> /dev/null | \\
+    { test \$blocks -gt 0 && dd ibs=1024 obs=1024 count=\$blocks ; \\
+      test \$bytes  -gt 0 && dd ibs=1 obs=1024 count=\$bytes ; } 2> /dev/null
+}
+
+MS_dd_Progress()
+{
+    if test x"\$noprogress" = xy; then
+        MS_dd \$@
+        return \$?
+    fi
+    file="\$1"
+    offset=\$2
+    length=\$3
+    pos=0
+    bsize=4194304
+    while test \$bsize -gt \$length; do
+        bsize=\`expr \$bsize / 4\`
+    done
+    blocks=\`expr \$length / \$bsize\`
+    bytes=\`expr \$length % \$bsize\`
+    (
+        dd ibs=\$offset skip=1 2>/dev/null
+        pos=\`expr \$pos \+ \$bsize\`
+        MS_Printf "     0%% " 1>&2
+        if test \$blocks -gt 0; then
+            while test \$pos -le \$length; do
+                dd bs=\$bsize count=1 2>/dev/null
+                pcent=\`expr \$length / 100\`
+                pcent=\`expr \$pos / \$pcent\`
+                if test \$pcent -lt 100; then
+                    MS_Printf "\b\b\b\b\b\b\b" 1>&2
+                    if test \$pcent -lt 10; then
+                        MS_Printf "    \$pcent%% " 1>&2
+                    else
+                        MS_Printf "   \$pcent%% " 1>&2
+                    fi
+                fi
+                pos=\`expr \$pos \+ \$bsize\`
+            done
+        fi
+        if test \$bytes -gt 0; then
+            dd bs=\$bytes count=1 2>/dev/null
+        fi
+        MS_Printf "\b\b\b\b\b\b\b" 1>&2
+        MS_Printf " 100%%  " 1>&2
+    ) < "\$file"
+}
+
+MS_Help()
+{
+    cat << EOH >&2
+\${helpheader}Makeself version $MS_VERSION
+ 1) Getting help or info about \$0 :
+  \$0 --help   Print this message
+  \$0 --info   Print embedded info : title, default target directory, embedded script ...
+  \$0 --lsm    Print embedded lsm entry (or no LSM)
+  \$0 --list   Print the list of files in the archive
+  \$0 --check  Checks integrity of the archive
+
+ 2) Running \$0 :
+  \$0 [options] [--] [additional arguments to embedded script]
+  with following options (in that order)
+  --confirm             Ask before running embedded script
+  --quiet		Do not print anything except error messages
+  --accept              Accept the license
+  --noexec              Do not run embedded script
+  --keep                Do not erase target directory after running
+			the embedded script
+  --noprogress          Do not show the progress during the decompression
+  --nox11               Do not spawn an xterm
+  --nochown             Do not give the extracted files to the current user
+  --nodiskspace         Do not check for available disk space
+  --target dir          Extract directly to a target directory
+                        directory path can be either absolute or relative
+  --tar arg1 [arg2 ...] Access the contents of the archive through the tar command
+  --                    Following arguments will be passed to the embedded script
+EOH
+}
+
+MS_Check()
+{
+    OLD_PATH="\$PATH"
+    PATH=\${GUESS_MD5_PATH:-"\$OLD_PATH:/bin:/usr/bin:/sbin:/usr/local/ssl/bin:/usr/local/bin:/opt/openssl/bin"}
+	MD5_ARG=""
+    MD5_PATH=\`exec <&- 2>&-; which md5sum || command -v md5sum || type md5sum\`
+    test -x "\$MD5_PATH" || MD5_PATH=\`exec <&- 2>&-; which md5 || command -v md5 || type md5\`
+	test -x "\$MD5_PATH" || MD5_PATH=\`exec <&- 2>&-; which digest || command -v digest || type digest\`
+    PATH="\$OLD_PATH"
+
+    if test x"\$quiet" = xn; then
+		MS_Printf "Verifying archive integrity..."
+    fi
+    offset=\`head -n $SKIP "\$1" | wc -c | tr -d " "\`
+    verb=\$2
+    i=1
+    for s in \$filesizes
+    do
+		crc=\`echo \$CRCsum | cut -d" " -f\$i\`
+		if test -x "\$MD5_PATH"; then
+			if test x"\`basename \$MD5_PATH\`" = xdigest; then
+				MD5_ARG="-a md5"
+			fi
+			md5=\`echo \$MD5 | cut -d" " -f\$i\`
+			if test x"\$md5" = x00000000000000000000000000000000; then
+				test x"\$verb" = xy && echo " \$1 does not contain an embedded MD5 checksum." >&2
+			else
+				md5sum=\`MS_dd_Progress "\$1" \$offset \$s | eval "\$MD5_PATH \$MD5_ARG" | cut -b-32\`;
+				if test x"\$md5sum" != x"\$md5"; then
+					echo "Error in MD5 checksums: \$md5sum is different from \$md5" >&2
+					exit 2
+				else
+					test x"\$verb" = xy && MS_Printf " MD5 checksums are OK." >&2
+				fi
+				crc="0000000000"; verb=n
+			fi
+		fi
+		if test x"\$crc" = x0000000000; then
+			test x"\$verb" = xy && echo " \$1 does not contain a CRC checksum." >&2
+		else
+			sum1=\`MS_dd_Progress "\$1" \$offset \$s | CMD_ENV=xpg4 cksum | awk '{print \$1}'\`
+			if test x"\$sum1" = x"\$crc"; then
+				test x"\$verb" = xy && MS_Printf " CRC checksums are OK." >&2
+			else
+				echo "Error in checksums: \$sum1 is different from \$crc" >&2
+				exit 2;
+			fi
+		fi
+		i=\`expr \$i + 1\`
+		offset=\`expr \$offset + \$s\`
+    done
+    if test x"\$quiet" = xn; then
+		echo " All good."
+    fi
+}
+
+UnTAR()
+{
+    if test x"\$quiet" = xn; then
+		tar \$1vf - $UNTAR_EXTRA 2>&1 || { echo " ... Extraction failed." > /dev/tty; kill -15 \$$; }
+    else
+		tar \$1f - $UNTAR_EXTRA 2>&1 || { echo Extraction failed. > /dev/tty; kill -15 \$$; }
+    fi
+}
+
+finish=true
+xterm_loop=
+noprogress=$NOPROGRESS
+nox11=$NOX11
+copy=$COPY
+ownership=y
+verbose=n
+
+initargs="\$@"
+
+while true
+do
+    case "\$1" in
+    -h | --help)
+	MS_Help
+	exit 0
+	;;
+    -q | --quiet)
+	quiet=y
+	noprogress=y
+	shift
+	;;
+	--accept)
+	accept=y
+	shift
+	;;
+    --info)
+	echo Identification: "\$label"
+	echo Target directory: "\$targetdir"
+	echo Uncompressed size: $USIZE KB
+	echo Compression: $COMPRESS
+	echo Date of packaging: $DATE
+	echo Built with Makeself version $MS_VERSION on $OSTYPE
+	echo Build command was: "$MS_COMMAND"
+	if test x"\$script" != x; then
+	    echo Script run after extraction:
+	    echo "    " \$script \$scriptargs
+	fi
+	if test x"$copy" = xcopy; then
+		echo "Archive will copy itself to a temporary location"
+	fi
+	if test x"$NEED_ROOT" = xy; then
+		echo "Root permissions required for extraction"
+	fi
+	if test x"$KEEP" = xy; then
+	    echo "directory \$targetdir is permanent"
+	else
+	    echo "\$targetdir will be removed after extraction"
+	fi
+	exit 0
+	;;
+    --dumpconf)
+	echo LABEL=\"\$label\"
+	echo SCRIPT=\"\$script\"
+	echo SCRIPTARGS=\"\$scriptargs\"
+	echo archdirname=\"$archdirname\"
+	echo KEEP=$KEEP
+	echo NOOVERWRITE=$NOOVERWRITE
+	echo COMPRESS=$COMPRESS
+	echo filesizes=\"\$filesizes\"
+	echo CRCsum=\"\$CRCsum\"
+	echo MD5sum=\"\$MD5\"
+	echo OLDUSIZE=$USIZE
+	echo OLDSKIP=`expr $SKIP + 1`
+	exit 0
+	;;
+    --lsm)
+cat << EOLSM
+EOF
+eval "$LSM_CMD"
+cat << EOF  >> "$archname"
+EOLSM
+	exit 0
+	;;
+    --list)
+	echo Target directory: \$targetdir
+	offset=\`head -n $SKIP "\$0" | wc -c | tr -d " "\`
+	for s in \$filesizes
+	do
+	    MS_dd "\$0" \$offset \$s | eval "$GUNZIP_CMD" | UnTAR t
+	    offset=\`expr \$offset + \$s\`
+	done
+	exit 0
+	;;
+	--tar)
+	offset=\`head -n $SKIP "\$0" | wc -c | tr -d " "\`
+	arg1="\$2"
+    if ! shift 2; then MS_Help; exit 1; fi
+	for s in \$filesizes
+	do
+	    MS_dd "\$0" \$offset \$s | eval "$GUNZIP_CMD" | tar "\$arg1" - "\$@"
+	    offset=\`expr \$offset + \$s\`
+	done
+	exit 0
+	;;
+    --check)
+	MS_Check "\$0" y
+	exit 0
+	;;
+    --confirm)
+	verbose=y
+	shift
+	;;
+	--noexec)
+	script=""
+	shift
+	;;
+    --keep)
+	keep=y
+	shift
+	;;
+    --target)
+	keep=y
+	targetdir=\${2:-.}
+    if ! shift 2; then MS_Help; exit 1; fi
+	;;
+    --noprogress)
+	noprogress=y
+	shift
+	;;
+    --nox11)
+	nox11=y
+	shift
+	;;
+    --nochown)
+	ownership=n
+	shift
+	;;
+    --nodiskspace)
+	nodiskspace=y
+	shift
+	;;
+    --xwin)
+	if test "$NOWAIT" = n; then
+		finish="echo Press Return to close this window...; read junk"
+	fi
+	xterm_loop=1
+	shift
+	;;
+    --phase2)
+	copy=phase2
+	shift
+	;;
+    --)
+	shift
+	break ;;
+    -*)
+	echo Unrecognized flag : "\$1" >&2
+	MS_Help
+	exit 1
+	;;
+    *)
+	break ;;
+    esac
+done
+
+if test x"\$quiet" = xy -a x"\$verbose" = xy; then
+	echo Cannot be verbose and quiet at the same time. >&2
+	exit 1
+fi
+
+if test x"$NEED_ROOT" = xy -a \`id -u\` -ne 0; then
+	echo "Administrative privileges required for this archive (use su or sudo)" >&2
+	exit 1	
+fi
+
+if test x"\$copy" \!= xphase2; then
+    MS_PrintLicense
+fi
+
+case "\$copy" in
+copy)
+    tmpdir=\$TMPROOT/makeself.\$RANDOM.\`date +"%y%m%d%H%M%S"\`.\$\$
+    mkdir "\$tmpdir" || {
+	echo "Could not create temporary directory \$tmpdir" >&2
+	exit 1
+    }
+    SCRIPT_COPY="\$tmpdir/makeself"
+    echo "Copying to a temporary location..." >&2
+    cp "\$0" "\$SCRIPT_COPY"
+    chmod +x "\$SCRIPT_COPY"
+    cd "\$TMPROOT"
+    exec "\$SCRIPT_COPY" --phase2 -- \$initargs
+    ;;
+phase2)
+    finish="\$finish ; rm -rf \`dirname \$0\`"
+    ;;
+esac
+
+if test x"\$nox11" = xn; then
+    if tty -s; then                 # Do we have a terminal?
+	:
+    else
+        if test x"\$DISPLAY" != x -a x"\$xterm_loop" = x; then  # No, but do we have X?
+            if xset q > /dev/null 2>&1; then # Check for valid DISPLAY variable
+                GUESS_XTERMS="xterm gnome-terminal rxvt dtterm eterm Eterm xfce4-terminal lxterminal kvt konsole aterm terminology"
+                for a in \$GUESS_XTERMS; do
+                    if type \$a >/dev/null 2>&1; then
+                        XTERM=\$a
+                        break
+                    fi
+                done
+                chmod a+x \$0 || echo Please add execution rights on \$0
+                if test \`echo "\$0" | cut -c1\` = "/"; then # Spawn a terminal!
+                    exec \$XTERM -title "\$label" -e "\$0" --xwin "\$initargs"
+                else
+                    exec \$XTERM -title "\$label" -e "./\$0" --xwin "\$initargs"
+                fi
+            fi
+        fi
+    fi
+fi
+
+if test x"\$targetdir" = x.; then
+    tmpdir="."
+else
+    if test x"\$keep" = xy; then
+	if test x"\$nooverwrite" = xy && test -d "\$targetdir"; then
+            echo "Target directory \$targetdir already exists, aborting." >&2
+            exit 1
+	fi
+	if test x"\$quiet" = xn; then
+	    echo "Creating directory \$targetdir" >&2
+	fi
+	tmpdir="\$targetdir"
+	dashp="-p"
+    else
+	tmpdir="\$TMPROOT/selfgz\$\$\$RANDOM"
+	dashp=""
+    fi
+    mkdir \$dashp \$tmpdir || {
+	echo 'Cannot create target directory' \$tmpdir >&2
+	echo 'You should try option --target dir' >&2
+	eval \$finish
+	exit 1
+    }
+fi
+
+location="\`pwd\`"
+if test x"\$SETUP_NOCHECK" != x1; then
+    MS_Check "\$0"
+fi
+offset=\`head -n $SKIP "\$0" | wc -c | tr -d " "\`
+
+if test x"\$verbose" = xy; then
+	MS_Printf "About to extract $USIZE KB in \$tmpdir ... Proceed ? [Y/n] "
+	read yn
+	if test x"\$yn" = xn; then
+		eval \$finish; exit 1
+	fi
+fi
+
+if test x"\$quiet" = xn; then
+	MS_Printf "Uncompressing \$label"
+fi
+res=3
+if test x"\$keep" = xn; then
+    trap 'echo Signal caught, cleaning up >&2; cd \$TMPROOT; /bin/rm -rf \$tmpdir; eval \$finish; exit 15' 1 2 3 15
+fi
+
+if test x"\$nodiskspace" = xn; then
+    leftspace=\`MS_diskspace \$tmpdir\`
+    if test -n "\$leftspace"; then
+        if test "\$leftspace" -lt $USIZE; then
+            echo
+            echo "Not enough space left in "\`dirname \$tmpdir\`" (\$leftspace KB) to decompress \$0 ($USIZE KB)" >&2
+            echo "Use --nodiskspace option to skip this check and proceed anyway" >&2
+            if test x"\$keep" = xn; then
+                echo "Consider setting TMPDIR to a directory with more free space."
+            fi
+            eval \$finish; exit 1
+        fi
+    fi
+fi
+
+for s in \$filesizes
+do
+    if MS_dd_Progress "\$0" \$offset \$s | eval "$GUNZIP_CMD" | ( cd "\$tmpdir"; umask \$ORIG_UMASK ; UnTAR xp ) 1>/dev/null; then
+		if test x"\$ownership" = xy; then
+			(cd "\$tmpdir"; chown -R \`id -u\` .;  chgrp -R \`id -g\` .)
+		fi
+    else
+		echo >&2
+		echo "Unable to decompress \$0" >&2
+		eval \$finish; exit 1
+    fi
+    offset=\`expr \$offset + \$s\`
+done
+if test x"\$quiet" = xn; then
+	echo
+fi
+
+cd "\$tmpdir"
+res=0
+if test x"\$script" != x; then
+    if test x"\$export_conf" = x"y"; then
+        MS_BUNDLE="\$0"
+        MS_LABEL="\$label"
+        MS_SCRIPT="\$script"
+        MS_SCRIPTARGS="\$scriptargs"
+        MS_ARCHDIRNAME="\$archdirname"
+        MS_KEEP="\$KEEP"
+        MS_NOOVERWRITE="\$NOOVERWRITE"
+        MS_COMPRESS="\$COMPRESS"
+        export MS_BUNDLE MS_LABEL MS_SCRIPT MS_SCRIPTARGS
+        export MS_ARCHDIRNAME MS_KEEP MS_NOOVERWRITE MS_COMPRESS
+    fi
+
+    if test x"\$verbose" = x"y"; then
+		MS_Printf "OK to execute: \$script \$scriptargs \$* ? [Y/n] "
+		read yn
+		if test x"\$yn" = x -o x"\$yn" = xy -o x"\$yn" = xY; then
+			eval "\"\$script\" \$scriptargs \"\\\$@\""; res=\$?;
+		fi
+    else
+		eval "\"\$script\" \$scriptargs \"\\\$@\""; res=\$?
+    fi
+    if test "\$res" -ne 0; then
+		test x"\$verbose" = xy && echo "The program '\$script' returned an error code (\$res)" >&2
+    fi
+fi
+if test x"\$keep" = xn; then
+    cd \$TMPROOT
+    /bin/rm -rf \$tmpdir
+fi
+eval \$finish; exit \$res
+EOF
diff --git a/Packaging/makeself/makeself.1 b/Packaging/makeself/makeself.1
new file mode 100644
index 0000000..abab230
--- /dev/null
+++ b/Packaging/makeself/makeself.1
@@ -0,0 +1,104 @@
+.TH "makeself" "1" "2.1.6"
+.SH "NAME"
+makeself \- An utility to generate self-extractable archives.
+.SH "SYNTAX"
+.LP 
+.B makeself [\fIoptions\fP] archive_dir file_name label 
+.B [\fIstartup_script\fP] [\fIargs\fP]
+.SH "DESCRIPTION"
+.LP 
+This program is a free (GPL) utility designed to create self-extractable 
+archives from a directory. 
+.br
+.SH "OPTIONS"
+.LP 
+The following options are supported.
+.LP 
+.TP 15
+.B -v, --version
+Prints out the makeself version number and exits.
+.TP
+.B -h, --help
+Print out help information.
+.TP
+.B --tar-quietly
+Suppress verbose output from the tar command
+.TP
+.B --quiet
+Do not print any messages other than errors
+.TP
+.B --gzip
+Compress using gzip (default if detected).
+.TP
+.B --bzip2
+Compress using bzip2.
+.TP
+.B --pbzip2
+Compress using pbzip2.
+.TP
+.B --xz
+Compress using xz.
+.TP
+.B --lzo
+Compress using lzop.
+.TP
+.B --lz4
+Compress using lz4.
+.TP
+.B --compress
+Compress using the UNIX 'compress' command.
+.TP
+.B --nocomp
+Do not compress the data.
+.TP
+.B --complevel lvl
+Specify the compression level for gzip,bzip2,pbzui2,xz,lzo or lz4
+.TP
+.B --notemp
+The archive will create archive_dir in the current directory and 
+uncompress in ./archive_dir.
+.TP
+.B --copy
+Upon extraction, the archive will first copy itself to a temporary directory.
+.TP
+.B --append
+Append more files to an existing makeself archive. The label and startup scripts will then be ignored.
+.TP
+.B --current
+Files will be extracted to the current directory. Both --current and --target dir imply --notemp.
+.TP
+.B --target dir
+Extract directly to a target directory. Directory path can be either absolute or relative.
+.TP
+.B --header file
+Specify location of the header script. 
+.TP
+.B --follow
+Follow the symlinks in the archive.
+.TP
+.B --noprogress
+Do not show the progress during the decompression.
+.TP
+.B --nox11
+Disable automatic spawn of an xterm if running in X11.
+.TP
+.B --nowait
+Do not wait for user input after executing embedded program from an xterm.
+.TP
+.B --nomd5
+Do not create a MD5 checksum for the archive.
+.TP
+.B --nocrc
+Do not create a CRC32 checksum for the archive.
+.TP
+.B --lsm file
+LSM file describing the package.
+.B --packaging-date date
+Use provided string as the packaging date instead of the current date.
+.PD
+.SH "AUTHORS"
+.LP 
+Makeself has been written by St�phane Peter <megastep at megastep.org>.
+.BR 
+This man page was originally written by Bartosz Fenski <fenio at o2.pl> for the 
+Debian GNU/Linux distribution (but it may be used by others).
diff --git a/Packaging/makeself/makeself.lsm b/Packaging/makeself/makeself.lsm
new file mode 100644
index 0000000..e32722e
--- /dev/null
+++ b/Packaging/makeself/makeself.lsm
@@ -0,0 +1,16 @@
+Begin3
+Title:          makeself.sh
+Version:        2.3.0
+Description:    makeself.sh is a shell script that generates a self-extractable        
+                tar.gz archive from a directory. The resulting file appears as a shell          
+                script, and can be launched as is. The archive will then uncompress
+                itself to a temporary directory and an arbitrary command will be
+                executed (for example an installation script). This is pretty similar
+                to archives generated with WinZip Self-Extractor in the Windows world.
+Keywords:       Installation archive tar winzip
+Author:         Stephane Peter (megastep at megastep.org)
+Maintained-by:  Stephane Peter (megastep at megastep.org)
+Original-site:  http://makeself.io/
+Platform:       Unix
+Copying-policy: GPL
+End
diff --git a/Packaging/makeself/makeself.sh b/Packaging/makeself/makeself.sh
new file mode 100755
index 0000000..5e39905
--- /dev/null
+++ b/Packaging/makeself/makeself.sh
@@ -0,0 +1,620 @@
+#!/bin/sh
+#
+# Makeself version 2.3.x
+#  by Stephane Peter <megastep at megastep.org>
+#
+# Utility to create self-extracting tar.gz archives.
+# The resulting archive is a file holding the tar.gz archive with
+# a small Shell script stub that uncompresses the archive to a temporary
+# directory and then executes a given script from within that directory.
+#
+# Makeself home page: http://makeself.io/
+#
+# Version 2.0 is a rewrite of version 1.0 to make the code easier to read and maintain.
+#
+# Version history :
+# - 1.0 : Initial public release
+# - 1.1 : The archive can be passed parameters that will be passed on to
+#         the embedded script, thanks to John C. Quillan
+# - 1.2 : Package distribution, bzip2 compression, more command line options,
+#         support for non-temporary archives. Ideas thanks to Francois Petitjean
+# - 1.3 : More patches from Bjarni R. Einarsson and Francois Petitjean:
+#         Support for no compression (--nocomp), script is no longer mandatory,
+#         automatic launch in an xterm, optional verbose output, and -target 
+#         archive option to indicate where to extract the files.
+# - 1.4 : Improved UNIX compatibility (Francois Petitjean)
+#         Automatic integrity checking, support of LSM files (Francois Petitjean)
+# - 1.5 : Many bugfixes. Optionally disable xterm spawning.
+# - 1.5.1 : More bugfixes, added archive options -list and -check.
+# - 1.5.2 : Cosmetic changes to inform the user of what's going on with big 
+#           archives (Quake III demo)
+# - 1.5.3 : Check for validity of the DISPLAY variable before launching an xterm.
+#           More verbosity in xterms and check for embedded command's return value.
+#           Bugfix for Debian 2.0 systems that have a different "print" command.
+# - 1.5.4 : Many bugfixes. Print out a message if the extraction failed.
+# - 1.5.5 : More bugfixes. Added support for SETUP_NOCHECK environment variable to
+#           bypass checksum verification of archives.
+# - 1.6.0 : Compute MD5 checksums with the md5sum command (patch from Ryan Gordon)
+# - 2.0   : Brand new rewrite, cleaner architecture, separated header and UNIX ports.
+# - 2.0.1 : Added --copy
+# - 2.1.0 : Allow multiple tarballs to be stored in one archive, and incremental updates.
+#           Added --nochown for archives
+#           Stopped doing redundant checksums when not necessary
+# - 2.1.1 : Work around insane behavior from certain Linux distros with no 'uncompress' command
+#           Cleaned up the code to handle error codes from compress. Simplified the extraction code.
+# - 2.1.2 : Some bug fixes. Use head -n to avoid problems.
+# - 2.1.3 : Bug fixes with command line when spawning terminals.
+#           Added --tar for archives, allowing to give arbitrary arguments to tar on the contents of the archive.
+#           Added --noexec to prevent execution of embedded scripts.
+#           Added --nomd5 and --nocrc to avoid creating checksums in archives.
+#           Added command used to create the archive in --info output.
+#           Run the embedded script through eval.
+# - 2.1.4 : Fixed --info output.
+#           Generate random directory name when extracting files to . to avoid problems. (Jason Trent)
+#           Better handling of errors with wrong permissions for the directory containing the files. (Jason Trent)
+#           Avoid some race conditions (Ludwig Nussel)
+#           Unset the $CDPATH variable to avoid problems if it is set. (Debian)
+#           Better handling of dot files in the archive directory.
+# - 2.1.5 : Made the md5sum detection consistent with the header code.
+#           Check for the presence of the archive directory
+#           Added --encrypt for symmetric encryption through gpg (Eric Windisch)
+#           Added support for the digest command on Solaris 10 for MD5 checksums
+#           Check for available disk space before extracting to the target directory (Andreas Schweitzer)
+#           Allow extraction to run asynchronously (patch by Peter Hatch)
+#           Use file descriptors internally to avoid error messages (patch by Kay Tiong Khoo)
+# - 2.1.6 : Replaced one dot per file progress with a realtime progress percentage and a spining cursor (Guy Baconniere)
+#           Added --noprogress to prevent showing the progress during the decompression (Guy Baconniere)
+#           Added --target dir to allow extracting directly to a target directory (Guy Baconniere)
+# - 2.2.0 : Many bugfixes, updates and contributions from users. Check out the project page on Github for the details.
+# - 2.3.0 : Option to specify packaging date to enable byte-for-byte reproducibility. (Marc Pawlowsky)
+#
+# (C) 1998-2017 by Stephane Peter <megastep at megastep.org>
+#
+# This software is released under the terms of the GNU GPL version 2 and above
+# Please read the license at http://www.gnu.org/copyleft/gpl.html
+#
+
+MS_VERSION=2.3.1
+MS_COMMAND="$0"
+unset CDPATH
+
+for f in "${1+"$@"}"; do
+    MS_COMMAND="$MS_COMMAND \\\\
+    \\\"$f\\\""
+done
+
+# For Solaris systems
+if test -d /usr/xpg4/bin; then
+    PATH=/usr/xpg4/bin:$PATH
+    export PATH
+fi
+
+# Procedures
+
+MS_Usage()
+{
+    echo "Usage: $0 [params] archive_dir file_name label startup_script [args]"
+    echo "params can be one or more of the following :"
+    echo "    --version | -v     : Print out Makeself version number and exit"
+    echo "    --help | -h        : Print out this help message"
+    echo "    --tar-quietly      : Suppress verbose output from the tar command"
+    echo "    --quiet | -q       : Do not print any messages other than errors."
+    echo "    --gzip             : Compress using gzip (default if detected)"
+    echo "    --pigz             : Compress with pigz"
+    echo "    --bzip2            : Compress using bzip2 instead of gzip"
+    echo "    --pbzip2           : Compress using pbzip2 instead of gzip"
+    echo "    --xz               : Compress using xz instead of gzip"
+    echo "    --lzo              : Compress using lzop instead of gzip"
+    echo "    --lz4              : Compress using lz4 instead of gzip"
+    echo "    --compress         : Compress using the UNIX 'compress' command"
+    echo "    --complevel lvl    : Compression level for gzip pigz xz lzo lz4 bzip2 and pbzip2 (default 9)"
+    echo "    --base64           : Instead of compressing, encode the data using base64"
+    echo "    --gpg-encrypt      : Instead of compressing, encrypt the data using GPG"
+    echo "    --gpg-asymmetric-encrypt-sign"
+    echo "                       : Instead of compressing, asymmetrically encrypt and sign the data using GPG"
+    echo "    --gpg-extra opt    : Append more options to the gpg command line"
+    echo "    --ssl-encrypt      : Instead of compressing, encrypt the data using OpenSSL"
+    echo "    --nocomp           : Do not compress the data"
+    echo "    --notemp           : The archive will create archive_dir in the"
+    echo "                         current directory and uncompress in ./archive_dir"
+    echo "    --needroot         : Check that the root user is extracting the archive before proceeding"
+    echo "    --copy             : Upon extraction, the archive will first copy itself to"
+    echo "                         a temporary directory"
+    echo "    --append           : Append more files to an existing Makeself archive"
+    echo "                         The label and startup scripts will then be ignored"
+    echo "    --target dir       : Extract directly to a target directory"
+    echo "                         directory path can be either absolute or relative"
+    echo "    --nooverwrite      : Do not extract the archive if the specified target directory exists"
+    echo "    --current          : Files will be extracted to the current directory"
+    echo "                         Both --current and --target imply --notemp"
+    echo "    --tar-extra opt    : Append more options to the tar command line"
+    echo "    --untar-extra opt  : Append more options to the during the extraction of the tar archive"
+    echo "    --nomd5            : Don't calculate an MD5 for archive"
+    echo "    --nocrc            : Don't calculate a CRC for archive"
+    echo "    --header file      : Specify location of the header script"
+    echo "    --follow           : Follow the symlinks in the archive"
+    echo "    --noprogress       : Do not show the progress during the decompression"
+    echo "    --nox11            : Disable automatic spawn of a xterm"
+    echo "    --nowait           : Do not wait for user input after executing embedded"
+    echo "                         program from an xterm"
+    echo "    --lsm file         : LSM file describing the package"
+    echo "    --license file     : Append a license file"
+    echo "    --help-header file : Add a header to the archive's --help output"
+    echo "    --packaging-date date"
+    echo "                       : Use provided string as the packaging date"
+    echo "                         instead of the current date."
+    echo
+    echo "    --keep-umask       : Keep the umask set to shell default, rather than overriding when executing self-extracting archive."
+    echo "    --export-conf      : Export configuration variables to startup_script"
+    echo
+    echo "Do not forget to give a fully qualified startup script name"
+    echo "(i.e. with a ./ prefix if inside the archive)."
+    exit 1
+}
+
+# Default settings
+if type gzip 2>&1 > /dev/null; then
+    COMPRESS=gzip
+else
+    COMPRESS=Unix
+fi
+COMPRESS_LEVEL=9
+KEEP=n
+CURRENT=n
+NOX11=n
+NOWAIT=n
+APPEND=n
+TAR_QUIETLY=n
+KEEP_UMASK=n
+QUIET=n
+NOPROGRESS=n
+COPY=none
+NEED_ROOT=n
+TAR_ARGS=cvf
+TAR_EXTRA=""
+GPG_EXTRA=""
+DU_ARGS=-ks
+HEADER=`dirname "$0"`/makeself-header.sh
+TARGETDIR=""
+NOOVERWRITE=n
+DATE=`LC_ALL=C date`
+EXPORT_CONF=n
+
+# LSM file stuff
+LSM_CMD="echo No LSM. >> \"\$archname\""
+
+while true
+do
+    case "$1" in
+    --version | -v)
+	echo Makeself version $MS_VERSION
+	exit 0
+	;;
+    --pbzip2)
+	COMPRESS=pbzip2
+	shift
+	;;
+    --bzip2)
+	COMPRESS=bzip2
+	shift
+	;;
+    --gzip)
+	COMPRESS=gzip
+	shift
+	;;
+    --pigz)
+    	COMPRESS=pigz
+    	shift
+    	;;
+    --xz)
+	COMPRESS=xz
+	shift
+	;;
+    --lzo)
+	COMPRESS=lzo
+	shift
+	;;
+    --lz4)
+	COMPRESS=lz4
+	shift
+	;;
+    --compress)
+	COMPRESS=Unix
+	shift
+	;;
+    --base64)
+	COMPRESS=base64
+	shift
+	;;
+    --gpg-encrypt)
+	COMPRESS=gpg
+	shift
+	;;
+    --gpg-asymmetric-encrypt-sign)
+  COMPRESS=gpg-asymmetric
+  shift
+  ;;
+    --gpg-extra)
+  GPG_EXTRA="$2"
+  if ! shift 2; then MS_Help; exit 1; fi
+  ;;
+    --ssl-encrypt)
+  COMPRESS=openssl
+  shift
+  ;;
+    --nocomp)
+	COMPRESS=none
+	shift
+	;;
+    --complevel)
+	COMPRESS_LEVEL="$2"
+	if ! shift 2; then MS_Help; exit 1; fi
+	;;
+    --notemp)
+	KEEP=y
+	shift
+	;;
+    --copy)
+	COPY=copy
+	shift
+	;;
+    --current)
+	CURRENT=y
+	KEEP=y
+	shift
+	;;
+    --tar-extra)
+	TAR_EXTRA="$2"
+        if ! shift 2; then MS_Help; exit 1; fi
+        ;;
+    --untar-extra)
+        UNTAR_EXTRA="$2"
+        if ! shift 2; then MS_Help; exit 1; fi
+        ;;
+    --target)
+	TARGETDIR="$2"
+	KEEP=y
+        if ! shift 2; then MS_Help; exit 1; fi
+	;;
+    --nooverwrite)
+        NOOVERWRITE=y
+	shift
+        ;;
+    --needroot)
+	NEED_ROOT=y
+	shift
+	;;
+    --header)
+	HEADER="$2"
+        if ! shift 2; then MS_Help; exit 1; fi
+	;;
+    --license)
+        LICENSE=`cat $2`
+        if ! shift 2; then MS_Help; exit 1; fi
+	;;
+    --follow)
+	TAR_ARGS=cvhf
+	DU_ARGS=-ksL
+	shift
+	;;
+    --noprogress)
+	NOPROGRESS=y
+	shift
+	;;
+    --nox11)
+	NOX11=y
+	shift
+	;;
+    --nowait)
+	NOWAIT=y
+	shift
+	;;
+    --nomd5)
+	NOMD5=y
+	shift
+	;;
+    --nocrc)
+	NOCRC=y
+	shift
+	;;
+    --append)
+	APPEND=y
+	shift
+	;;
+    --lsm)
+	LSM_CMD="cat \"$2\" >> \"\$archname\""
+    if ! shift 2; then MS_Help; exit 1; fi
+	;;
+    --packaging-date)
+	DATE="$2"
+	if ! shift 2; then MS_Help; exit 1; fi
+        ;;
+    --help-header)
+	HELPHEADER=`sed -e "s/'/'\\\\\''/g" $2`
+    if ! shift 2; then MS_Help; exit 1; fi
+	[ -n "$HELPHEADER" ] && HELPHEADER="$HELPHEADER
+"
+    ;;
+    --tar-quietly)
+	TAR_QUIETLY=y
+	shift
+	;;
+	--keep-umask)
+	KEEP_UMASK=y
+	shift
+	;;
+    --export-conf)
+    EXPORT_CONF=y
+    shift
+    ;;
+    -q | --quiet)
+	QUIET=y
+	shift
+	;;
+    -h | --help)
+	MS_Usage
+	;;
+    -*)
+	echo Unrecognized flag : "$1"
+	MS_Usage
+	;;
+    *)
+	break
+	;;
+    esac
+done
+
+if test $# -lt 1; then
+	MS_Usage
+else
+	if test -d "$1"; then
+		archdir="$1"
+	else
+		echo "Directory $1 does not exist." >&2
+		exit 1
+	fi
+fi
+archname="$2"
+
+if test "$QUIET" = "y" || test "$TAR_QUIETLY" = "y"; then
+    if test "$TAR_ARGS" = "cvf"; then
+	TAR_ARGS="cf"
+    elif test "$TAR_ARGS" = "cvhf";then
+	TAR_ARGS="chf"
+    fi
+fi
+
+if test "$APPEND" = y; then
+    if test $# -lt 2; then
+	MS_Usage
+    fi
+
+    # Gather the info from the original archive
+    OLDENV=`sh "$archname" --dumpconf`
+    if test $? -ne 0; then
+	echo "Unable to update archive: $archname" >&2
+	exit 1
+    else
+	eval "$OLDENV"
+    fi
+else
+    if test "$KEEP" = n -a $# = 3; then
+	echo "ERROR: Making a temporary archive with no embedded command does not make sense!" >&2
+	echo >&2
+	MS_Usage
+    fi
+    # We don't want to create an absolute directory unless a target directory is defined
+    if test "$CURRENT" = y; then
+	archdirname="."
+    elif test x$TARGETDIR != x; then
+	archdirname="$TARGETDIR"
+    else
+	archdirname=`basename "$1"`
+    fi
+
+    if test $# -lt 3; then
+	MS_Usage
+    fi
+
+    LABEL="$3"
+    SCRIPT="$4"
+    test "x$SCRIPT" = x || shift 1
+    shift 3
+    SCRIPTARGS="$*"
+fi
+
+if test "$KEEP" = n -a "$CURRENT" = y; then
+    echo "ERROR: It is A VERY DANGEROUS IDEA to try to combine --notemp and --current." >&2
+    exit 1
+fi
+
+case $COMPRESS in
+gzip)
+    GZIP_CMD="gzip -c$COMPRESS_LEVEL"
+    GUNZIP_CMD="gzip -cd"
+    ;;
+pigz) 
+    GZIP_CMD="pigz -$COMPRESS_LEVEL"
+    GUNZIP_CMD="gzip -cd"
+    ;;
+pbzip2)
+    GZIP_CMD="pbzip2 -c$COMPRESS_LEVEL"
+    GUNZIP_CMD="bzip2 -d"
+    ;;
+bzip2)
+    GZIP_CMD="bzip2 -$COMPRESS_LEVEL"
+    GUNZIP_CMD="bzip2 -d"
+    ;;
+xz)
+    GZIP_CMD="xz -c$COMPRESS_LEVEL"
+    GUNZIP_CMD="xz -d"
+    ;;
+lzo)
+    GZIP_CMD="lzop -c$COMPRESS_LEVEL"
+    GUNZIP_CMD="lzop -d"
+    ;;
+lz4)
+    GZIP_CMD="lz4 -c$COMPRESS_LEVEL"
+    GUNZIP_CMD="lz4 -d"
+    ;;
+base64)
+    GZIP_CMD="base64"
+    GUNZIP_CMD="base64 -d -i"
+    ;;
+gpg)
+    GZIP_CMD="gpg $GPG_EXTRA -ac -z$COMPRESS_LEVEL"
+    GUNZIP_CMD="gpg -d"
+    ;;
+gpg-asymmetric)
+    GZIP_CMD="gpg $GPG_EXTRA -z$COMPRESS_LEVEL -es"
+    GUNZIP_CMD="gpg --yes -d"
+    ;;
+openssl)
+    GZIP_CMD="openssl aes-256-cbc -a -salt"
+    GUNZIP_CMD="openssl aes-256-cbc -d -a"
+    ;;
+Unix)
+    GZIP_CMD="compress -cf"
+    GUNZIP_CMD="exec 2>&-; uncompress -c || test \\\$? -eq 2 || gzip -cd"
+    ;;
+none)
+    GZIP_CMD="cat"
+    GUNZIP_CMD="cat"
+    ;;
+esac
+
+tmpfile="${TMPDIR:=/tmp}/mkself$$"
+
+if test -f "$HEADER"; then
+	oldarchname="$archname"
+	archname="$tmpfile"
+	# Generate a fake header to count its lines
+	SKIP=0
+    . "$HEADER"
+    SKIP=`cat "$tmpfile" |wc -l`
+	# Get rid of any spaces
+	SKIP=`expr $SKIP`
+	rm -f "$tmpfile"
+    if test "$QUIET" = "n";then
+    	echo Header is $SKIP lines long >&2
+    fi
+
+	archname="$oldarchname"
+else
+    echo "Unable to open header file: $HEADER" >&2
+    exit 1
+fi
+
+if test "$QUIET" = "n";then 
+    echo
+fi
+
+if test "$APPEND" = n; then
+    if test -f "$archname"; then
+		echo "WARNING: Overwriting existing file: $archname" >&2
+    fi
+fi
+
+USIZE=`du $DU_ARGS "$archdir" | awk '{print $1}'`
+
+if test "." = "$archdirname"; then
+	if test "$KEEP" = n; then
+		archdirname="makeself-$$-`date +%Y%m%d%H%M%S`"
+	fi
+fi
+
+test -d "$archdir" || { echo "Error: $archdir does not exist."; rm -f "$tmpfile"; exit 1; }
+if test "$QUIET" = "n";then
+   echo About to compress $USIZE KB of data...
+   echo Adding files to archive named \"$archname\"...
+fi
+exec 3<> "$tmpfile"
+( cd "$archdir" && ( tar $TAR_EXTRA -$TAR_ARGS - . | eval "$GZIP_CMD" >&3 ) ) || \
+    { echo Aborting: archive directory not found or temporary file: "$tmpfile" could not be created.; exec 3>&-; rm -f "$tmpfile"; exit 1; }
+exec 3>&- # try to close the archive
+
+fsize=`cat "$tmpfile" | wc -c | tr -d " "`
+
+# Compute the checksums
+
+md5sum=00000000000000000000000000000000
+crcsum=0000000000
+
+if test "$NOCRC" = y; then
+	if test "$QUIET" = "n";then
+		echo "skipping crc at user request"
+	fi
+else
+	crcsum=`cat "$tmpfile" | CMD_ENV=xpg4 cksum | sed -e 's/ /Z/' -e 's/	/Z/' | cut -dZ -f1`
+	if test "$QUIET" = "n";then
+		echo "CRC: $crcsum"
+	fi
+fi
+
+if test "$NOMD5" = y; then
+	if test "$QUIET" = "n";then
+		echo "skipping md5sum at user request"
+	fi
+else
+	# Try to locate a MD5 binary
+	OLD_PATH=$PATH
+	PATH=${GUESS_MD5_PATH:-"$OLD_PATH:/bin:/usr/bin:/sbin:/usr/local/ssl/bin:/usr/local/bin:/opt/openssl/bin"}
+	MD5_ARG=""
+	MD5_PATH=`exec <&- 2>&-; which md5sum || command -v md5sum || type md5sum`
+	test -x "$MD5_PATH" || MD5_PATH=`exec <&- 2>&-; which md5 || command -v md5 || type md5`
+	test -x "$MD5_PATH" || MD5_PATH=`exec <&- 2>&-; which digest || command -v digest || type digest`
+	PATH=$OLD_PATH
+	if test -x "$MD5_PATH"; then
+		if test `basename ${MD5_PATH}`x = digestx; then
+			MD5_ARG="-a md5"
+		fi
+		md5sum=`cat "$tmpfile" | eval "$MD5_PATH $MD5_ARG" | cut -b-32`;
+		if test "$QUIET" = "n";then
+			echo "MD5: $md5sum"
+		fi
+	else
+		if test "$QUIET" = "n";then
+			echo "MD5: none, MD5 command not found"
+		fi
+	fi
+fi
+
+if test "$APPEND" = y; then
+    mv "$archname" "$archname".bak || exit
+
+    # Prepare entry for new archive
+    filesizes="$filesizes $fsize"
+    CRCsum="$CRCsum $crcsum"
+    MD5sum="$MD5sum $md5sum"
+    USIZE=`expr $USIZE + $OLDUSIZE`
+    # Generate the header
+    . "$HEADER"
+    # Append the original data
+    tail -n +$OLDSKIP "$archname".bak >> "$archname"
+    # Append the new data
+    cat "$tmpfile" >> "$archname"
+
+    chmod +x "$archname"
+    rm -f "$archname".bak
+    if test "$QUIET" = "n";then
+    	echo Self-extractable archive \"$archname\" successfully updated.
+    fi
+else
+    filesizes="$fsize"
+    CRCsum="$crcsum"
+    MD5sum="$md5sum"
+
+    # Generate the header
+    . "$HEADER"
+
+    # Append the compressed tar data after the stub
+    if test "$QUIET" = "n";then
+    	echo
+    fi
+    cat "$tmpfile" >> "$archname"
+    chmod +x "$archname"
+    if test "$QUIET" = "n";then
+    	echo Self-extractable archive \"$archname\" successfully created.
+    fi
+fi
+rm -f "$tmpfile"
diff --git a/Packaging/otb_update_makeself b/Packaging/otb_update_makeself
new file mode 100644
index 0000000..8240538
--- /dev/null
+++ b/Packaging/otb_update_makeself
@@ -0,0 +1,11 @@
+HOWTO UPDATE MAKESELF
+
+#If makEself version with your required bug fix is 2.3.1
+# cd to otb/sources/Packaging/
+
+wget https://github.com/megastep/makeself/archive/release-2.3.1.tar.gz
+tar xzf release-2.3.1.tar.gz
+mv makeself-release-2.3.1 makeself
+rm -fr release-2.3.1.tar.gz
+
+run git diff to check if everything is in place and git commit 
diff --git a/Packaging/patch_cmake_files.cmake b/Packaging/patch_cmake_files.cmake
new file mode 100644
index 0000000..49ee420
--- /dev/null
+++ b/Packaging/patch_cmake_files.cmake
@@ -0,0 +1,63 @@
+#
+# 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.
+#
+function(patch_cmake_files)
+  cmake_parse_arguments(PATCH  "" "NAME;VERSION;MATCH_STRING;REPLACE_VAR" "" ${ARGN} )
+
+  set(PATCH_DIR_NAME ${PATCH_NAME}-${PATCH_VERSION})
+  set(PATCH_DIR "${SUPERBUILD_INSTALL_DIR}/lib/cmake/${PATCH_DIR_NAME}")
+  set(PATCH_STAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/patched/${PATCH_DIR_NAME})
+
+  ##message("COPY ${PATCH_DIR} to ${PATCH_STAGE_DIR} for patching")
+
+  execute_process(
+    COMMAND ${CMAKE_COMMAND} -E make_directory "${PATCH_STAGE_DIR}"
+    COMMAND ${CMAKE_COMMAND} -E copy_directory "${PATCH_DIR}" "${PATCH_STAGE_DIR}"
+    )
+
+  set(DIR_LIST "${PATCH_STAGE_DIR}|${PATCH_STAGE_DIR}/Modules")
+
+  execute_process(COMMAND ${CMAKE_COMMAND}
+    -DP_DIRS=${DIR_LIST}
+    -DP_MATCH=${PATCH_MATCH_STRING}
+    -DP_REPLACE=${PATCH_REPLACE_VAR}
+    -P ${CMAKE_CURRENT_SOURCE_DIR}/post_install.cmake
+    RESULT_VARIABLE patch_${PATCH_NAME}_cmake_rv
+    )
+
+  if(patch_${PATCH_NAME}_cmake_rv)
+    message(FATAL_ERROR "    execute_process() failed.")
+  endif()
+
+  install_without_message("${PATCH_STAGE_DIR}" "lib/cmake")
+
+  # file( GLOB otb_opengl
+  #   "${SUPERBUILD_INSTALL_DIR}/lib/cmake/OTB*/Modules/OTBOpenGL.cmake" )
+  # if(EXISTS ${otb_opengl})
+  #   file(STRINGS "${otb_opengl}" otb_opengl_cmake)
+  #   set(otb_opengl_cmake_NEW)
+  #   foreach(line ${otb_opengl_cmake})
+  #     if( NOT line MATCHES "/usr")
+  # 	list(APPEND otb_opengl_cmake_NEW "${line}\n")
+  #     endif()
+  #   endforeach()
+  # endif()
+  # file(WRITE "${otb_opengl}" ${otb_opengl_cmake_NEW})
+  
+endfunction()
diff --git a/Packaging/post_install.cmake b/Packaging/post_install.cmake
new file mode 100644
index 0000000..29c937e
--- /dev/null
+++ b/Packaging/post_install.cmake
@@ -0,0 +1,46 @@
+#
+# 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.
+#
+
+#check variables are set
+foreach(var P_DIRS P_MATCH P_REPLACE)
+  if(NOT ${var})
+    message(FATAL_ERROR "${var} not set")
+  endif()
+endforeach()
+
+string(REPLACE "|" ";" P_DIRS ${P_DIRS})
+
+
+foreach( p_dir ${P_DIRS} )
+  set(file_list)
+  file( GLOB file_list "${p_dir}/*.cmake" )
+  list(SORT file_list)
+  foreach( cmake_file ${file_list} )
+    file(STRINGS "${cmake_file}" MATCH_FOUND REGEX "${P_MATCH}")
+    if(MATCH_FOUND)
+      message(STATUS "Patching: ${cmake_file}")
+      #message("Patch: Replace '${P_MATCH}' with '${P_REPLACE}' in ${cmake_file}")
+      file(STRINGS "${cmake_file}" cmake_file_CONTENTS NEWLINE_CONSUME)
+      string(REPLACE "${P_MATCH}" "$${}{${P_REPLACE}}" cmake_file_CONTENTS ${cmake_file_CONTENTS})
+      file(WRITE "${cmake_file}"  "# This file is modified by OTB after installation.
+      \n${cmake_file_CONTENTS}")
+    endif()
+  endforeach() # foreach( cmake_file
+endforeach() # foreach( p_dir
diff --git a/Packaging/prepare_file_list.cmake b/Packaging/prepare_file_list.cmake
new file mode 100644
index 0000000..8ba085b
--- /dev/null
+++ b/Packaging/prepare_file_list.cmake
@@ -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.
+#
+function(prepare_file_list file_list_result)
+
+  set(file_list)
+  set(otbapp_launcher "otbApplicationLauncherCommandLine${EXE_EXT}")
+  #This must exist in any OTB Installation. minimal or full
+  if(NOT EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/${otbapp_launcher}")
+    message(
+      FATAL_ERROR
+      "${SUPERBUILD_INSTALL_DIR}/bin/${otbapp_launcher} not found.")
+    return()
+  endif()
+
+  # find OTB targets
+  set(_otb_targets_path
+    "${SUPERBUILD_INSTALL_DIR}/lib/cmake/OTB-${PKG_OTB_VERSION_MAJOR}.${PKG_OTB_VERSION_MINOR}")
+  file(GLOB _targets_config_files "${_otb_targets_path}/OTBTargets-*.cmake")
+  set(_IMPORT_PREFIX ${SUPERBUILD_INSTALL_DIR})
+  foreach(f ${_targets_config_files})
+    file(STRINGS ${f} _f_content REGEX " IMPORTED_LOCATION_[A-Z]+ ")
+    string(REGEX REPLACE " +IMPORTED_LOCATION_[A-Z]+ \"([^\"]+)\"" "\\1;" _filtered ${_f_content})
+    string(CONFIGURE "${_filtered}" _configured)
+    list(APPEND file_list "${_configured}")
+  endforeach()
+
+  if(HAVE_PYTHON)
+    list(APPEND file_list "_otbApplication${PYMODULE_EXT}")
+  endif()
+  
+  foreach(exe_file "SharkVersion")
+    if(EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/${exe_file}${EXE_EXT}")
+      list(APPEND file_list "${exe_file}${EXE_EXT}")
+    else()
+      message(STATUS "${exe_file}${EXE_EXT} not found in ${SUPERBUILD_INSTALL_DIR}/bin. (skipping)")
+    endif()
+  endforeach()
+
+  #Qt stuff
+  if(HAVE_QT4)
+    list(APPEND file_list "lrelease${EXE_EXT}")
+    list(APPEND file_list "moc${EXE_EXT}")
+    list(APPEND file_list "qmake${EXE_EXT}")
+    list(APPEND file_list "rcc${EXE_EXT}")
+    list(APPEND file_list "uic${EXE_EXT}")
+    list(APPEND file_list "proj${EXE_EXT}")
+    list(APPEND file_list "cs2cs${EXE_EXT}")
+  endif()
+  
+  file(GLOB otb_test_exe_list 
+    "${SUPERBUILD_INSTALL_DIR}/bin/gdal*${EXE_EXT}"
+    "${OTB_BINARY_DIR}/bin/*[T|t]est*${EXE_EXT}"
+    )
+
+  #special items to be removed!. hackety-hack
+  list(REMOVE_ITEM otb_test_exe_list
+    "${SUPERBUILD_INSTALL_DIR}/bin/gdal-config"
+    )
+  list(REMOVE_ITEM otb_test_exe_list
+    "${OTB_BINARY_DIR}/bin/otbcli_TestApplication")
+  
+  list(REMOVE_ITEM otb_test_exe_list
+    "${OTB_BINARY_DIR}/bin/otbgui_TestApplication")
+  
+  foreach(otb_test_exe   ${otb_test_exe_list})
+    get_filename_component(otb_test_exe_name ${otb_test_exe} NAME)
+    list(APPEND file_list ${otb_test_exe_name})
+  endforeach()
+  
+  # special case for msvc: ucrtbase.dll must be explicitly vetted.
+  # for proj.dll, see Mantis-1424
+  if(MSVC)
+    list(APPEND file_list "ucrtbase.dll")
+    list(APPEND file_list "proj.dll")
+  endif()
+
+  set(${file_list_result} ${file_list} PARENT_SCOPE)
+endfunction()
diff --git a/Packaging/prepare_search_dirs.cmake b/Packaging/prepare_search_dirs.cmake
new file mode 100644
index 0000000..8f246ed
--- /dev/null
+++ b/Packaging/prepare_search_dirs.cmake
@@ -0,0 +1,59 @@
+#
+# 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.
+#
+function(prepare_search_dirs search_dirs_result)
+  
+  set(search_dirs)
+  
+  if(MSVC)
+    if(NOT DEFINED ENV{UniversalCRTSdkDir})
+      message(FATAL_ERROR "UniversalCRTSdkDir variable not set. Cannot continue")
+    endif()
+    if(NOT DEFINED ENV{VCINSTALLDIR})
+      message(FATAL_ERROR  "VCINSTALLDIR variable not set. Cannot continue.")
+    endif()
+  endif()
+  
+  if(MSVC)    
+    file(TO_CMAKE_PATH "$ENV{UniversalCRTSdkDir}" UCRT_SDK_DIR)
+    list(APPEND search_dirs "${UCRT_SDK_DIR}/Redist/ucrt/DLLs/${OTB_TARGET_SYSTEM_ARCH}") #ucrt dlls
+  
+  #additional msvc redist dll from VCINSTALLDIR
+  file(TO_CMAKE_PATH "$ENV{VCINSTALLDIR}" PKG_VCINSTALLDIR)
+  list(APPEND search_dirs 
+    "${PKG_VCINSTALLDIR}/redist/${OTB_TARGET_SYSTEM_ARCH}/Microsoft.VC140.CRT"
+    "${PKG_VCINSTALLDIR}/redist/${OTB_TARGET_SYSTEM_ARCH}/Microsoft.VC140.OPENMP"
+    )
+endif()
+
+#superbuild .so /.dylib
+list(APPEND search_dirs "${SUPERBUILD_INSTALL_DIR}/lib")
+#all executables gdalinfo etc..
+list(APPEND search_dirs "${SUPERBUILD_INSTALL_DIR}/bin") 
+#common for all platforms.
+list(APPEND search_dirs "${SUPERBUILD_INSTALL_DIR}/lib/otb/applications")
+
+#_otbApplication.so
+list(APPEND search_dirs "${SUPERBUILD_INSTALL_DIR}/lib/otb/python")
+
+#for otbtest executables. 
+list(APPEND search_dirs ${OTB_BINARY_DIR}/bin)
+
+set(${search_dirs_result} ${search_dirs} PARENT_SCOPE)
+endfunction()
diff --git a/Packaging/process_file_recurse.cmake b/Packaging/process_file_recurse.cmake
new file mode 100644
index 0000000..b8f31b4
--- /dev/null
+++ b/Packaging/process_file_recurse.cmake
@@ -0,0 +1,148 @@
+#
+# 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.
+#
+function(process_file_recurse input_file)
+  set(input_file_full_path)
+  if(IS_ABSOLUTE "${input_file}" AND EXISTS "${input_file}")
+    set(input_file_full_path ${input_file})
+    if(PKG_DEBUG)
+      message("Found '${input_file}' (return)")
+    endif()
+  else()
+    search_library(${input_file} PKG_SEARCHDIRS input_file_full_path)
+  endif()
+  if(NOT input_file_full_path)
+    if(LINUX)
+      setif_value_in_list(is_gtk_lib "${input_file}" ALLOWED_SYSTEM_DLLS)
+      if(is_gtk_lib)
+	search_library(${input_file} PKG_GTK_SEARCHDIRS input_file_full_path)
+	if( NOT input_file_full_path)
+	  message(FATAL_ERROR "${input_file} not found. searched in ${PKG_GTK_SEARCHDIRS}")
+	endif()
+      endif()
+      if( NOT input_file_full_path)
+	message(FATAL_ERROR "${input_file} not found. searched in ${PKG_SEARCHDIRS}")
+	endif()
+    endif(LINUX)
+
+  endif() #if(NOT input_file_full_path)
+
+  if(NOT PKG_DEBUG)
+    message("Processing ${input_file_full_path}")
+  endif()
+  
+  # Install the file with install_rule().
+  # This function has specific "rules" to decide wheather and where to install file  
+  install_rule(${input_file_full_path})
+  
+  set(raw_items)
+
+  execute_process(
+    COMMAND ${LOADER_PROGRAM} ${LOADER_ARGS} "${input_file_full_path}"
+    RESULT_VARIABLE loader_rv
+    OUTPUT_VARIABLE loader_ov
+    ERROR_VARIABLE loader_ev
+    )
+  
+  if(loader_rv)
+    message(FATAL_ERROR "loader_ev=${loader_ev}\n PACKAGE-OTB: result_variable is '${loader_rv}'")
+  endif()
+
+  string(REPLACE ";" "\\;" candidates "${loader_ov}")
+  string(REPLACE "\n" "${LOADER_REGEX_EOL};" candidates "${candidates}")
+  
+  get_filename_component(bn_name ${input_file_full_path} NAME)
+  set(${bn_name}_USED TRUE CACHE INTERNAL "")
+
+  if(PKG_DEBUG)
+    message("Processing ${input_file} started. Set ${bn_name}_USED=${${bn_name}_USED}")
+  endif()
+
+  foreach(candidate ${candidates})
+    if(NOT candidate)
+      continue()
+    endif()
+
+    if(NOT "${candidate}" MATCHES "${LOADER_REGEX}")
+      continue()
+    endif()
+
+    string(REGEX REPLACE "${LOADER_REGEX}" "\\1" raw_item "${candidate}")
+
+    if(NOT raw_item)
+      continue()
+    endif()  
+
+    string(STRIP ${raw_item} raw_item)
+    set(is_system FALSE)
+    setif_value_in_list(is_system "${raw_item}" SYSTEM_DLLS)
+    if(APPLE AND NOT is_system)
+      if("${raw_item}" MATCHES "@rpath")
+        string(REGEX REPLACE "@rpath." "" raw_item "${raw_item}")
+      else()
+        message(FATAL_ERROR "'${raw_item}' does not have @rpath")
+      endif()
+    endif()
+
+    if(PKG_DEBUG AND ${raw_item}_RESOLVED)
+      message("${raw_item} is already resolved [${raw_item}_RESOLVED=${${raw_item}_RESOLVED}]")
+    endif()
+
+    if(PKG_DEBUG)
+      message("raw_item='${raw_item}'\tis_system='${is_system}'")
+    endif()
+    if(is_system OR ${raw_item}_RESOLVED OR ${raw_item}_USED)
+      continue()
+    endif()
+    
+    list(APPEND raw_items ${raw_item})
+    
+  endforeach()
+
+  if(PKG_DEBUG)
+    string(REPLACE ";" "\n" raw_items_pretty_print "${raw_items}")
+    # message(FATAL_ERROR "raw_items=${raw_items_pretty_print}")
+  endif(PKG_DEBUG)
+
+  if(raw_items)
+    list(REVERSE raw_items)
+    foreach(item ${raw_items})      
+      search_library(${item} PKG_SEARCHDIRS item_full_path)
+      set(is_a_symlink FALSE)
+      set(item_target_file)
+      isfile_symlink("${item_full_path}" is_a_symlink item_target_file)
+      if(is_a_symlink)
+        set(${item}_RESOLVED TRUE CACHE INTERNAL "")
+        set(item ${item_target_file})
+      endif()
+      if(PKG_DEBUG)
+        message("${bn_name} depends on '${item}'. So we now process '${item}'") # [ ${item}_USED=${${item}_USED} ${item}_RESOLVED=${${item}_RESOLVED}]")
+      endif()
+      process_file_recurse(${item})
+    endforeach()
+  endif()
+
+  set(${bn_name}_RESOLVED TRUE CACHE INTERNAL "")
+   if(PKG_DEBUG)
+     message("All dependencies of ${bn_name} are processed. Install file and set ${bn_name}_RESOLVED=${${bn_name}_RESOLVED}")
+   endif()
+
+   #install_rule(${input_file_full_path})
+
+endfunction() #function(process_file_recurse infile)
diff --git a/Modules/ThirdParty/Shark/otb-module.cmake b/Packaging/search_library.cmake
similarity index 52%
copy from Modules/ThirdParty/Shark/otb-module.cmake
copy to Packaging/search_library.cmake
index 99ba28e..500bbb9 100644
--- a/Modules/ThirdParty/Shark/otb-module.cmake
+++ b/Packaging/search_library.cmake
@@ -17,19 +17,23 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+function(search_library input_file pkg_searchdirs result)
+  set(${result} "" PARENT_SCOPE)
+  foreach(pkg_searchdir ${${pkg_searchdirs}})
 
-set(DOCUMENTATION "This module imports SHARK to the build system")
-
-otb_module(OTBShark
-  DEPENDS
-    
-  TEST_DEPENDS
-    
-  DESCRIPTION
-    "${DOCUMENTATION}"
-  )
-
-otb_module_activation_option("Enable SHARK dependent modules" OFF)
-
-otb_module_requires_cxx11()
+    if(EXISTS ${pkg_searchdir}/${input_file} )
+      if(PKG_DEBUG)
+        message("Found '${pkg_searchdir}/${input_file}' (return)")
+      endif()
+      set(${result} "${pkg_searchdir}/${input_file}" PARENT_SCOPE)
+      return()
+    endif()
 
+    #check for file with lowercase
+    string(TOLOWER "${input_file}" input_file_lower )
+    if(EXISTS ${pkg_searchdir}/${input_file_lower})
+      set(${result} "${pkg_searchdir}/${input_file_lower}"  PARENT_SCOPE)
+      return()
+    endif()
+  endforeach()
+endfunction()
diff --git a/Modules/Applications/AppFiltering/otb-module.cmake b/Packaging/setif_value_in_list.cmake
similarity index 62%
copy from Modules/Applications/AppFiltering/otb-module.cmake
copy to Packaging/setif_value_in_list.cmake
index d33a9ee..7ae6820 100644
--- a/Modules/Applications/AppFiltering/otb-module.cmake
+++ b/Packaging/setif_value_in_list.cmake
@@ -17,21 +17,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-
-set(DOCUMENTATION "Basic filters application.")
-
-otb_module(OTBAppFiltering
-  DEPENDS
-    OTBImageNoise
-    OTBImageManipulation
-    OTBITK
-    OTBApplicationEngine
-    OTBImageBase
-
-  TEST_DEPENDS
-    OTBTestKernel
-    OTBCommandLine
-
-  DESCRIPTION
-    "${DOCUMENTATION}"
-)
+function(setif_value_in_list matched VALUE list)
+  set(${matched} FALSE  PARENT_SCOPE)
+  string(TOLOWER ${VALUE} value)
+  foreach (PATTERN ${${list}})
+    string(TOLOWER ${PATTERN} pattern)
+    if("${value}" MATCHES "${pattern}")
+      set(${matched} TRUE PARENT_SCOPE)
+      #we found a match. return from loop.
+      return()
+    endif()
+  endforeach()
+  #message("'${value}' not found in ${list}")
+endfunction()
diff --git a/Packaging/testing.cmake b/Packaging/testing.cmake
new file mode 100644
index 0000000..c7dce46
--- /dev/null
+++ b/Packaging/testing.cmake
@@ -0,0 +1,85 @@
+#
+# 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.
+#
+# add_test(NAME <name> COMMAND <command> [<arg>...]
+#          [CONFIGURATIONS <config>...]
+#          [WORKING_DIRECTORY <dir>])
+
+set(testing_dir ${CMAKE_BINARY_DIR}/tests)
+if(EXISTS "${testing_dir}")
+  execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${testing_dir})
+  execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory   ${testing_dir})
+else()
+  execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory   ${testing_dir})
+endif()
+
+set(install_package_ARGS)
+set(selftester_ARGS)
+set(pkg_extracted_dir "${testing_dir}/${PKG_STAGE_DIR}")
+if(WIN32)
+  set(install_package_ARGS "x;${PACKAGE_OUTPUT_FILE}")
+  set(install_package_CMD "${ZIP_EXECUTABLE}")
+  #selftester
+  set(selftester_CMD ${pkg_extracted_dir}/tools/selftester.bat)
+  set(selftester_ARGS "/q")
+  #uninstall OTB
+  set(uninstall_otb_CMD ${pkg_extracted_dir}/tools/uninstall_otb.bat)
+else()
+  set(install_package_ARGS "--noprogress;--nox11;--target;${pkg_extracted_dir}")
+  set(install_package_CMD "${PACKAGE_OUTPUT_FILE}")
+  #selftester
+  set(selftester_CMD ${pkg_extracted_dir}/tools/selftester.sh)
+  set(selftester_ARGS)
+  #uninstall OTB
+  set(uninstall_otb_CMD ${pkg_extracted_dir}/tools/uninstall_otb.sh)
+endif()
+add_test(
+  NAME Tu_install_package
+  COMMAND ${install_package_CMD} ${install_package_ARGS}
+  WORKING_DIRECTORY ${testing_dir}
+  )
+
+add_test(
+  NAME Tu_selftester
+  COMMAND ${selftester_CMD} ${selftester_ARGS}
+  WORKING_DIRECTORY ${pkg_extracted_dir}
+  )
+
+add_test(
+  NAME Tu_build_examples
+  COMMAND ${CMAKE_COMMAND}
+  -DSRC_DIR=${CMAKE_SOURCE_DIR}/../Examples
+  -P ${pkg_extracted_dir}/tools/build_examples.cmake
+  WORKING_DIRECTORY ${testing_dir}
+  )
+
+add_test(
+  NAME Tu_uninstall_otb
+  COMMAND ${uninstall_otb_CMD}
+  WORKING_DIRECTORY ${testing_dir}
+  )
+
+#configure test dependencies..
+set_tests_properties ( Tu_selftester PROPERTIES DEPENDS Tu_install_package)
+set_tests_properties ( Tu_build_examples PROPERTIES DEPENDS Tu_selftester)
+set_tests_properties ( Tu_uninstall_otb PROPERTIES DEPENDS Tu_build_examples)
+
+#if(UNIX)
+  #TODO: add test with shellcheck for script files
+#endif()
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 49a5f3d..e91f39a 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,3 +1,82 @@
+OTB-v.6.2.0 - Changes since version 6.0.0 (October 4th, 2017)
+----------------------------------------------------------
+
+* Request for Changes (http://wiki.orfeo-toolbox.org/index.php/Requests_for_Changes):
+  * Request for Changes-91: Better error messages (adopted, merged)
+  * Request for Changes-92: Build remote modules as standalone cmake projects (adopted, merged)
+  * Request for Changes-93: Update third party versions in Superbuild for 6.2 (adopted, merged)
+  * Request for Changes-94: CookBook licensed under cc-by-sa (adopted, merged)
+  * Request for Changes-95: Compile OTB with C++14 by default (adopted, merged)
+  * Request for Changes-96: Long help in otbcli (adopted, merged)
+  * Request for Changes-97: KMeansClassification reimplemented (adopted, merged)
+  * Request for Changes-98: Upgrade Monteverdi dependency from QWT 5 to QWT 6 (adopted, merged)
+  * Request for Changes-99: Refactor ExtractROI application (adopted, merged)
+  * Request for Changes-100: Add external soil file to Sail model (adopted, merged)
+  * Request for changes-102: Extend MachineLearningModel sample and target types (adopted, merged)
+  * Request for changes-103: Improve OTB Applications documentation (part 1) (adopted, merged)
+  * Request for changes-105: Simplify logging of composite applications (adopted, merged)
+  * Request for changes-106: All-in-one LSMS application (adopted, merged)
+  * Request for changes-107: Refactor Convert application (adopted, merged)
+  * Request for changes-108: Make OTB package great again (adopted, merged)
+  * Request for changes-109: Refactor PixelValue application (adopted, merged)
+  * Request for changes-111: SuperBuild dependencies additions for GDAL (adopted, merged)
+  * Request for changes-112: New-functor-filters (adopted, merged)
+  * Request for changes-114: Add Daniel McInerney as a new committer (adopted)
+  * Request for changes-115: Refactoring of DownloadSRTMTiles (adopted, merged)
+
+* Bugfixes :
+  * OTB-Qgis
+    * 0001445: Mean shift segmentation ignoring mask OTB QGIS
+
+  * Documentation
+    * 0001434: Bibliography references are not set in the Software Guide (PDF version)
+    * 0001400: Training  applications reference documentation do not include shark parameters
+
+  * Monteverdi
+    * 0001431: RGE Alti files inverted on Monteverdi
+    * 0001432: RGE Alti files inverted on Monteverdi
+    * 0001408: Issue in Monteverdi French translation (typo)
+
+  * OTB-Packaging
+    * 0001449: Issues with OTB 6.1 standalone packages (Linux)
+    * 0001404: OTB xdk 5.10.1 is not able to compile a simple program on a Ubuntu 16.04 VM
+    * 0001430: building 6.0.0 fails at otbSFSTextureExtraction.cxx.o
+
+  * Orfeo Toolbox (OTB)
+    * 0001453: Applications crash with inxml paramter (GUI mode)
+    * 0001405: Crash on optical calibration, TOC mode, GUI only (command line works), only on Mac
+    * 0001422: Optical Calibration application crash on MacOSX
+    * 0001401: ktrace reports too many file open for any otbapplication
+    * 0001439: GUI of ComputeOGRLayersFeaturesStatistics and OGRLayerClassifier crash on certain shape files
+    * 0001399: missing include_directories call when building external projects
+    * 0001438: Input Value Type of Classification apps
+    * 0001420: Change layer name in Monteverdi has no effect
+    * 0001446: Write mode on the SampleExtraction application
+    * 0001435: Performance issue on OTB 6.0 otbcli_MeanShiftSmoothing
+    * 0001407: In TrainImagesClassifier, field selection gets reset all the time
+    * 0001448: VectorClassifier isn't working for me...
+    * 0001397: OTBIOkml links only with base, dom, and engine but cmake includes all kml libs
+    * 0001413: set GDAL_DRIVER_PATH to avoid autoload of gdal driver from another installation
+    * 0001443: Fails to build with cmake 3.9.0
+    * 0001444: cmake fails if OTB_DATA_LARGEINPUT_ROOT is set and OTB_DATA_ROOT is not set
+    * 0001398: OTB won't parse *.xml metadata file on newest Pleiades data
+    * 0001418: Two more InXML incorrect tests
+    * 0001416: Parameter names different in cli and gui version
+    * 0001417: In windows packages otbenv.cmd and otbenv.bat, GDAL_DATA is set to a folder that does not exist
+    * 0001425: Cli Command line produced by otbgui_TrainImagesClassifier is wrong
+    * 0001424: ComputeConfusionMatrix crashes because proj.dll is missing
+    * 0001403: InXML1 tests fail but report as passed
+    * 0001419: Fix detection of OpenCV on i386 architecture.
+    * 0001426: GUI TrainimagesClassifier resets "field name" parameter when another parameter is set
+    * 0001421: otbenv.bash has windows endline
+    * 0001402: 404 link on otb-users
+
+  * OTB-applications
+    * 0001441: Error in param in template otbTrainLibSVM.txx
+    * 0001411: Training applications  needs field name of type integer
+    * 0001410: BundleToPerfectSensor composite application does not expose parameters of internal applications
+
+
 OTB-v.6.0.0 - Changes since version 5.10.1 (May 2th, 2017)
 ----------------------------------------------------------
 
@@ -147,7 +226,7 @@ OTB-v.5.8.0 - Changes since version 5.6.1 (November 8th, 2016)
     * 0001300: monteverdi $input_filename crash with relative path
     * 0001303: Memory issue in Monteverdi with images with subdatasets (HDF4)
     * 0001299: Monteverdi shortcuts list needs some updates
-    * 0001291: Word "Échiquier" is not displayed properly in layer stack (effect column)
+    * 0001291: Word "Echiquier" is not displayed properly in layer stack (effect column)
 
   * OTB-Packaging
     * 0001290: Unable to run OTB applications from Mapla.app on Mac OS X
@@ -1758,7 +1837,7 @@ OTB-v.3.12.0 - Changes since version 3.10.0 (2011/01/31)
       are missing)
 
   * Documentation
-    * 0000483: "<" or ">" are interpreted as ¿ in Cookbook
+    * 0000483: "<" or ">" are interpreted as inverted ? in Cookbook
     * 0000370: Cookbook : make a HTML documentation
     * 0000378: Doxygen not updated
 
@@ -2251,10 +2330,10 @@ OTB-v.3.0.0 - Changes since version 2.8.0 (2009/05/11)
 --------------------------------------------------------
 
 * Applications
-  - Urban area extraction (Pléaides, QB, Ikonos, SPOT5). For more
+  - Urban area extraction (Pleaides, QB, Ikonos, SPOT5). For more
     details,
     see the README file
-  - Image to Data Base registration (Pléiades, QB). For more details, see
+  - Image to Data Base registration (Pleiades, QB). For more details, see
     the README file
   - Feature Extraction: add new textures, new radiometric indexes and
     add MeanShift capabilities
@@ -2262,7 +2341,7 @@ OTB-v.3.0.0 - Changes since version 2.8.0 (2009/05/11)
 
 * Library
     The library includes these additions
-  - Cloud detection for QB/Pléiades images
+  - Cloud detection for QB/Pleiades images
   - Alignment and right angle detection (Burns, Grompone)
   - Radiometric indices (vegetation, water, soil)
   - Optimized texture computations including Haralick, SFS, Pantex,
@@ -2354,7 +2433,7 @@ OTB-v.2.4.0 - Changes since version 2.2.0 (2008/07/24)
 *Common:
 
       Extraction ROI Classes :
-    - Lifting of the otbExtractionBase classe
+    - Lifting of the otbExtractionBase class
     - Correction of the SetExtractionRegion method
 
 *BasicFilters:
diff --git a/Utilities/Doxygen/doxygen.config.in b/Utilities/Doxygen/doxygen.config.in
index f23888a..c77823e 100644
--- a/Utilities/Doxygen/doxygen.config.in
+++ b/Utilities/Doxygen/doxygen.config.in
@@ -1121,7 +1121,7 @@ HTML_COLORSTYLE_HUE    = 220
 HTML_COLORSTYLE_SAT    = 100
 
 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
-# luminance component of the colors in the HTML output. Values below 100
+# radiance component of the colors in the HTML output. Values below 100
 # gradually make the output lighter, whereas values above 100 make the output
 # darker. The value divided by 100 is the actual gamma applied, so 80 represents
 # a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
diff --git a/Utilities/Maintenance/SuperbuildDownloadList.sh b/Utilities/Maintenance/SuperbuildDownloadList.sh
index 6b09c62..da5c4cb 100755
--- a/Utilities/Maintenance/SuperbuildDownloadList.sh
+++ b/Utilities/Maintenance/SuperbuildDownloadList.sh
@@ -20,77 +20,62 @@
 #
 
 
-export LC_ALL=C
-if [ $# -eq 2 ]; then
-DOWNLOAD_DIR=$(readlink -f $1)
-OUTPUT_DIR=$(readlink -f $2)
-else
-echo 'Usage: '$0' <download_directory> <archive_output_directory>'
-exit 1
+
+if [ $# -lt 2 ]; then
+    echo "Usage: $0 <download_directory> <archive_output_directory>"
+    exit 1
 fi
 
-WGET="wget -nv -q"
+export LC_ALL=C
 
-SB_CMAKE_DIR_REL=$(dirname $0)/../../SuperBuild/CMake
-SB_CMAKE_DIR=$(readlink -f ${SB_CMAKE_DIR_REL})
+DOWNLOAD_DIR=$(readlink -f "$1")
+OUTPUT_DIR=$(readlink -f "$2")
+WGET=$(which wget)
 
-cd $(dirname $0)/../../
 
-GIT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
+CUR_DIR="$( cd "$( dirname "$0" )" && pwd )"
 
+SB_CMAKE_DIR_REL=$CUR_DIR/../../SuperBuild/CMake
+SB_CMAKE_DIR=$(readlink -f "${SB_CMAKE_DIR_REL}")
+cd "$CUR_DIR/../../" || echo "cannot cd to CUR_DIR/../../"
+GIT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
 #if a branch contains release-X.Y then xdk is taken from packages/xdk/OTB-X.Y
 if [[ "$GIT_BRANCH" =~ release-* ]]; then
-    VERSION=$(echo ${GIT_BRANCH}| sed 's/.*release-//'| cut -d'-' -f 1)
+    VERSION=$(echo "${GIT_BRANCH}"| sed 's/.*release-//'| cut -d'-' -f 1)
 else
     VERSION="develop"
 fi
-DOWNLOAD_LIST=$(grep -h -E "^[^#]*\"https?://.*(\.tar\.gz|\.tar\.bz2|\.tgz|\.tar\.xz|\.zip|export=download).*\"" ${SB_CMAKE_DIR}/*.cmake | grep -o -E "https?://[^\"]*" | sed "s/\/\(download\)\?$//" | sort | uniq)
+CMAKE_FILES=$(find "${SB_CMAKE_DIR}" -maxdepth 1 -type f -name "External_*")
+DOWNLOAD_LIST=$(grep -h -E '^[^#]*\"(ftp|http|https)://.*(\.tar\.gz|\.tar\.bz2|\.tgz|\.tar\.xz|\.zip|export=download).*\"' ${CMAKE_FILES} |
+		    grep -o -E '(ftp|http|https)://[^\"]*' | sort | uniq)
 
 DOWNLOAD_NAMES=
 
-mkdir -p ${DOWNLOAD_DIR}
-cd ${DOWNLOAD_DIR}
+#echo "DOWNLOAD_LIST=$DOWNLOAD_LIST"
 
+mkdir -p "${DOWNLOAD_DIR}"
+cd "${DOWNLOAD_DIR}" || echo "cannot cd to DOWNLOAD_DIR"
 echo "Downloading files to ${DOWNLOAD_DIR}/"
-
 for url in ${DOWNLOAD_LIST}; do
-  # clean log file
-
-  file_name=$(echo "${url}" | grep -o -E "[^\/]+$")
-  docs_google=$(echo "${file_name}" | grep -F "export=download")
-  if [ "${docs_google}" = "" ]; then
-      if [ -f "$file_name" ]; then
-          echo "$file_name exists, skipping"
-      fi;
-      $WGET -N ${url}
-      ret="$?"
-   if [ $ret -gt 0 -a $ret -ne 8  ]; then
-       echo "Download failed for URL: '${url}'. wget finished with exit status '$ret'."
-       exit 1;
-   fi
-  else
-    # look into the original file for a valid download name
-    file_name=$(grep -h -A 3 -B 3 -F "${url}" ${SB_CMAKE_DIR}/*.cmake | grep -E "^[^#]*DOWNLOAD_NAME" | grep -o -E "[^ ]*\.(tar\.gz|tar\.bz2|tar\.xz|zip)" | uniq)
-    if [ -z "$file_name" ]; then
-        echo "Can't find correct filename for url ${url} : skip download"
-        exit 1;
-    else
-        # echo "Download ${file_name}..."
-        $WGET ${url} -O ${file_name}
-    fi
+  file_name=$(echo "${url}" | grep -o -E '[^\/]+$')
+  $WGET -N "${url}"
+  ret="$?"
+  if [ $ret -gt 0 ] && [ $ret -ne 8 ]; then
+     echo "Download failed for URL: '${url}'. wget finished with exit status '$ret'."
+     exit 1;
   fi
 
   if [ "$file_name" != "" ]; then
-      DOWNLOAD_NAMES="${DOWNLOAD_NAMES} ${file_name}"
+     DOWNLOAD_NAMES="${DOWNLOAD_NAMES} ${file_name}"
+  else
+     echo "invalid filename for url=${url}" && exit 1;
   fi
-
 done
 
 ARCHIVE_NAME="SuperBuild-archives-$VERSION"
 echo "Creating archive ${OUTPUT_DIR}/$ARCHIVE_NAME.tar.bz2"
-
-cd ${OUTPUT_DIR}
-tar -cjf $ARCHIVE_NAME.tar.bz2 -C ${DOWNLOAD_DIR} ${DOWNLOAD_NAMES}
-
+cd "${OUTPUT_DIR}" || echo "cannot cd to OUTPUT_DIR"
+touch "${DOWNLOAD_DIR}/OTBSuperBuild.readme"
+tar -cjf "$ARCHIVE_NAME.tar.bz2" -C "${DOWNLOAD_DIR}" ${DOWNLOAD_NAMES} OTBSuperBuild.readme
 echo "Saving md5sum to ${OUTPUT_DIR}/$ARCHIVE_NAME.md5"
-md5sum $ARCHIVE_NAME.tar.bz2 > $ARCHIVE_NAME.md5
+md5sum "$ARCHIVE_NAME.tar.bz2" > "$ARCHIVE_NAME.md5"
diff --git a/i18n/fr_FR.ts b/i18n/fr_FR.ts
index 283f9fe..609bada 100644
--- a/i18n/fr_FR.ts
+++ b/i18n/fr_FR.ts
@@ -278,8 +278,8 @@ Veuillez, s'il vous plait, supprimer votre répertoire de cache Monteverdi.
         <translation>Version OTB M.m.pl (nom_de_code)</translation>
     </message>
     <message>
-        <source><p>Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)</p><p>Monteverdi is part of Orfeo Toolbox</p><a href="https://www.orfeo-toolbox.org/">https://www.orfeo-toolbox.org/</a><p>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</p><a href="http://www.apache.org [...]
-        <translation></translation>
+        <source><html><head/><body><p>Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)</p><p>Monteverdi is part of Orfeo Toolbox</p><p><a href="https://www.orfeo-toolbox.org/"><span style=" text-decoration: underline; color:#0000ff;">https://www.orfeo-toolbox.org/</span></a></p><p>Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); yo [...]
+        <translation type="unfinished"></translation>
     </message>
 </context>
 <context>
@@ -357,6 +357,10 @@ Veuillez, s'il vous plait, supprimer votre répertoire de cache Monteverdi.
         <source>Unknown</source>
         <translation>Inconnu</translation>
     </message>
+    <message>
+        <source>No EPSG</source>
+        <translation>Pas d'EPSG</translation>
+    </message>
 </context>
 <context>
     <name>mvd::AbstractModel</name>
@@ -5083,7 +5087,7 @@ Le(s) résultat(s) vont être importés en tant que jeu de données.</translatio
     </message>
     <message>
         <source>OTB-Application '%1' cannot be closed while running!</source>
-        <translation>Impossible de fermer l'OTB-Application '%1' pendant sont exéution !</translation>
+        <translation>Impossible de fermer l'OTB-Application '%1' pendant sont exécution !</translation>
     </message>
     <message>
         <source>Following files will be overwritten. Are you sure you want to continue?

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/otb.git



More information about the Pkg-grass-devel mailing list