diff --git a/CMake/FindShark.cmake b/CMake/FindShark.cmake index 800ba587743e349ab286aa91318a2de6cdbc1815..0833d7f5cb92b7ce06a189f1bb0b7fbfd36d8e53 100755 --- a/CMake/FindShark.cmake +++ b/CMake/FindShark.cmake @@ -26,7 +26,7 @@ find_path( SHARK_INCLUDE_DIR shark/Core/Shark.h PATH_SUFFIXES include include/shark shark) find_library( SHARK_LIBRARY - NAMES shark + NAMES shark shark_debug PATHS "${SHARK_SEARCH_PATH}" PATH_SUFFIXES lib ) diff --git a/CMake/otbcli.bat.in b/CMake/otbcli.bat.in index ffe1fb2a3f4695e6d1377f453cda524d90723bf2..165d8338726754d5f7188bc7ae3ae3e52a41685d 100644 --- a/CMake/otbcli.bat.in +++ b/CMake/otbcli.bat.in @@ -16,8 +16,13 @@ if exist %CURRENT_SCRIPT_DIR%otbApplicationLauncherCommandLine.exe ( setlocal :: works for install tree -if exist %CURRENT_SCRIPT_DIR%../@OTB_INSTALL_APP_DIR@ ( - set OTB_APPLICATION_PATH=%CURRENT_SCRIPT_DIR%../@OTB_INSTALL_APP_DIR@;%OTB_APPLICATION_PATH% +if exist %CURRENT_SCRIPT_DIR%..\@OTB_INSTALL_APP_DIR_NATIVE@ ( + set OTB_APPLICATION_PATH=%CURRENT_SCRIPT_DIR%..\@OTB_INSTALL_APP_DIR_NATIVE@;%OTB_APPLICATION_PATH% +) + +::set GDAL_DATA, EPSG_CSV and update PATH +if exist %CURRENT_SCRIPT_DIR%\..\otbenv.cmd ( + call %CURRENT_SCRIPT_DIR%\..\otbenv.cmd ) set LC_NUMERIC=C diff --git a/CMakeLists.txt b/CMakeLists.txt index efb8aff8b37eeaa4855f4ab80b6b15d4a7e2d9ae..d3608f3e3237f4b5b416c688c621f7a5aa556c4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,7 @@ set(main_project_name ${_OTBModuleMacros_DEFAULT_LABEL}) #----------------------------------------------------------------------------- # OTB version number. set(OTB_VERSION_MAJOR "5") -set(OTB_VERSION_MINOR "9") +set(OTB_VERSION_MINOR "11") set(OTB_VERSION_PATCH "0") set(OTB_VERSION_STRING "${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}.${OTB_VERSION_PATCH}") @@ -134,6 +134,9 @@ if(NOT OTB_INSTALL_PACKAGE_DIR) set(OTB_INSTALL_PACKAGE_DIR "${OTB_INSTALL_LIBRARY_DIR}/cmake/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}") endif() +#convert path to native for reconfiguring otbcli.bat.in +file(TO_NATIVE_PATH "${OTB_INSTALL_APP_DIR}" OTB_INSTALL_APP_DIR_NATIVE) + # Override CMake's built-in add_* commands: assign LABELS to tests and targets # automatically. Depends on the CMake variable otb-module being set to the # "current" module when add_* is called. @@ -309,7 +312,12 @@ 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") diff --git a/Documentation/Cookbook/rst/Installation_Linux.txt b/Documentation/Cookbook/rst/Installation_Linux.txt index 0567d00c1ce372a8ddd323481dbd3b8595584bdd..8a6e941d15f3de94da5f53739af25686a2e000db 100644 --- a/Documentation/Cookbook/rst/Installation_Linux.txt +++ b/Documentation/Cookbook/rst/Installation_Linux.txt @@ -93,17 +93,17 @@ A: This is due to a conflict with system Qt4 (usually seen on KDE) and Qt4 + gtk Q: Monteverdi and Mapla applications look different from my other applications. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -A: By default, Monteverdi, Mapla and otbapplication (otbgui\_\*) uses a default gtk theme (plastic) -which is distributed with the OTB package!. We do this to be on safe side, like when a user does -not have gtk libraries installed when using our package. +A: By default, Monteverdi, Mapla and otbapplication (otbgui\_\*) uses a the +system gtk theme. If you can't install GTK on your system you can use the +distributed with the OTB package. Note that using system GTK is the preferred +way with the OTB standalone package as the distributed version of GTK do not +work on recent Linux distributions. -gtk libraries in the package is the reason why you are getting a default "plastic" look & feel that -makes it look different from other GUI applications. -To get same look and feel, you can "force" Monteverdi and Mapla to use system GTK. +To use the distributed GTK libraries you need to set the OTB_USE_LOCAL_GTK: :: - export OTB_USE_SYSTEM_GTK=1 + export OTB_USE_LOCAL_GTK=1 And now start ``monteverdi.sh`` or ``mapla.sh`` from OTB-|release|-Linux64 -To get back default behaviour, unset OTB_USE_SYSTEM_GTK=1 or set OTB_USE_SYSTEM_GTK=0 +To get back default behaviour, unset OTB_USE_LOCAL_GTK=1 or set OTB_USE_LOCAL_GTK=0 diff --git a/Documentation/Cookbook/rst/Installation_Linux_xdk.txt b/Documentation/Cookbook/rst/Installation_Linux_xdk.txt new file mode 100644 index 0000000000000000000000000000000000000000..9542af41aa905cc367b97c264b118a07ba11f5cd --- /dev/null +++ b/Documentation/Cookbook/rst/Installation_Linux_xdk.txt @@ -0,0 +1,66 @@ +Synopsis +-------- + +This archive provides a development kit for the ORFEO ToolBox library which +allows to easily compile OTB and facilitate the creation of programs based on +OTB. + +It contains shared libraries of OTB dependencies and helper scripts for the +configuration and the compilation of the library. + +Note that OTB sources are not included in the archive (see instructions below). + +Prerequisites +------------- + +- cmake (>= 3.2) +- gcc (>= 4.9) +- git + +Extract XDK +----------- + +:: + + cd /opt (You can use another a directory of your own choice) + chmod +x OTB-|release|-xdk-Linux64.run + ./OTB-|release|-xdk-Linux64.run + +**You now will have a directory named **OTB-|release|-xdk-Linux64** in **/opt** + +Setup environment +----------------- +There is a helper script in package called **xdkenv.profile**. This script export +required environments to configure and build OTB. + +:: + + cd /opt/OTB-|release|-xdk-Linux64 + . ./xdkenv.profile + +Test environment setup by checking value of CMAKE_PREFIX_PATH + +:: + + echo $CMAKE_PREFIX_PATH + +The above command will output: + /opt/OTB-|release|-xdk-Linux64 + + +Download, Configure and build OTB +--------------------------------- + +:: + + mkdir -p /opt/OTB/build && cd /opt/OTB + git clone --depth=1 --branch=develop https://git@git.orfeo-toolbox.org/git/otb.git source + cd build && cmake ../source + make -j2 + + +Notes +~~~~~ + +By default, all OTB\_USE\_\* variables in OTB are set to FALSE except for 6S and SiftFast. You can check/activate them in your cmake-gui/ccmake. + diff --git a/Documentation/Cookbook/rst/Installation_Macx_xdk.txt b/Documentation/Cookbook/rst/Installation_Macx_xdk.txt new file mode 100644 index 0000000000000000000000000000000000000000..648393dc3496a11f07ebc0a2f4353df09bbcab57 --- /dev/null +++ b/Documentation/Cookbook/rst/Installation_Macx_xdk.txt @@ -0,0 +1,2 @@ +README.md + diff --git a/Documentation/Cookbook/rst/Installation_Windows_xdk.txt b/Documentation/Cookbook/rst/Installation_Windows_xdk.txt new file mode 100644 index 0000000000000000000000000000000000000000..b43bf86b50fd8d3529a0dc062c30006ed38f309e --- /dev/null +++ b/Documentation/Cookbook/rst/Installation_Windows_xdk.txt @@ -0,0 +1 @@ +README.md diff --git a/Documentation/Cookbook/rst/Monteverdi.rst b/Documentation/Cookbook/rst/Monteverdi.rst index 6fb7c21db040abe0f06762efdaa3c3e2ce3fc0fe..57614e613d75aa505fa9cce1ce6cbf94f9f481b2 100644 --- a/Documentation/Cookbook/rst/Monteverdi.rst +++ b/Documentation/Cookbook/rst/Monteverdi.rst @@ -12,22 +12,19 @@ Monteverdi is a satellite image viewer. Its main features are: - **Powerful**: Access to all processing application from OTB. Orthorectification, optical calibration, classification, SAR processing, and much more! -GUI : what does it look like ? ------------------------------- - .. image:: Art/MonteverdiImages/gui.png -This is Monteverdi’s main window where the different functionalities are reachable: +This is Monteverdi’s main window where the different functionalities are: #. Main menu #. Top toolbar -#. Image displaying +#. Image View -#. Right side dock +#. Widgets -#. Stack layer +#. Layer stack Main menu ~~~~~~~~~ @@ -92,9 +89,9 @@ In the image displaying part: - CTRL+Mouse drag = Quick scroll view (rending is done after releasing CTRL key) -- CTRL+Mouse wheel = Zoom in out +- Mouse wheel = Zoom -- + or - = Zoom in out +- + or - = Zoom In the layer stack part: diff --git a/Documentation/SoftwareGuide/Latex/ContributorList.tex b/Documentation/SoftwareGuide/Latex/ContributorList.tex index dc42ae456a7fc58cc2a8d22e1f1d19ac125f5916..d17508de9313fa479c70eac7773d244c213dc383 100644 --- a/Documentation/SoftwareGuide/Latex/ContributorList.tex +++ b/Documentation/SoftwareGuide/Latex/ContributorList.tex @@ -33,6 +33,7 @@ Julien Osman, Julien Radoux (UCL), Laurentiu Nicola (CS Romania), Luc Hermitte (CS), +Ludovic Hussonnois (CS), Manuel Grizonnet (CNES), Massimo Di Stefano, Mathieu Deltorre (CS), diff --git a/Modules/Adapters/QtAdapters/src/otbQtAdapters.cxx b/Modules/Adapters/QtAdapters/src/otbQtAdapters.cxx index b36d66cff678d575dc0c20d6270a33ee1000ce3a..d665845923c78ac923baab163183389ee7c8ef14 100644 --- a/Modules/Adapters/QtAdapters/src/otbQtAdapters.cxx +++ b/Modules/Adapters/QtAdapters/src/otbQtAdapters.cxx @@ -66,13 +66,18 @@ GetExistingDirectory( QWidget * p, const QString& dir, QFileDialog::Options options ) { + QString dialogCaption(caption.isEmpty() + ? QObject::tr( "Select directory..." ) + : caption); + QString dialogDir(dir.isEmpty() + ? RecentDirectory + : dir); + QString path( QFileDialog::getExistingDirectory( p, - caption.isEmpty() - ? QObject::tr( "Select directory..." ) - : caption, - dir.isEmpty() ? RecentDirectory : dir, + dialogCaption, + dialogDir, options ) ); @@ -95,13 +100,18 @@ GetOpenFileName( QWidget * p, QString* selectedFilter, QFileDialog::Options options ) { + QString dialogCaption(caption.isEmpty() + ? QObject::tr( "Open file..." ) + : caption); + QString dialogDir(dir.isEmpty() + ? RecentDirectory + : dir); + QString filename( QFileDialog::getOpenFileName( p, - caption.isEmpty() - ? QObject::tr( "Open file..." ) - : caption, - dir.isEmpty() ? RecentDirectory : dir, + dialogCaption, + dialogDir, filter, selectedFilter, options @@ -124,13 +134,18 @@ GetOpenFileNames( QWidget * p, QString * selectedFilter, QFileDialog::Options options ) { + QString dialogCaption(caption.isEmpty() + ? QObject::tr( "Open file..." ) + : caption); + QString dialogDir(dir.isEmpty() + ? RecentDirectory + : dir); + QStringList filenames( QFileDialog::getOpenFileNames( p, - caption.isEmpty() - ? QObject::tr( "Open file..." ) - : caption, - dir.isEmpty() ? RecentDirectory : dir, + dialogCaption, + dialogDir, filter, selectedFilter, options @@ -153,13 +168,18 @@ GetSaveFileName( QWidget * p, QString * selectedFilter, QFileDialog::Options options ) { + QString dialogCaption(caption.isEmpty() + ? QObject::tr( "Save file..." ) + : caption); + QString dialogDir(dir.isEmpty() + ? RecentDirectory + : dir); + QString filename( QFileDialog::getSaveFileName( p, - caption.isEmpty() - ? QObject::tr( "Save file..." ) - : caption, - dir.isEmpty() ? RecentDirectory : dir, + dialogCaption, + dialogDir, filter, selectedFilter, options diff --git a/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx b/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx index dd9d347a1fc42ecfc0a190384dfeaa1b321e6b25..29a2b45989846859f26c236788f2d11d6fbf3b1c 100644 --- a/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx +++ b/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx @@ -140,12 +140,12 @@ private: AddParameter(ParameterType_String, "cri", "Criterion"); SetParameterDescription("cri", "Dempster Shafer criterion (by default (belief+plausibility)/2)"); MandatoryOff("cri"); - SetParameterString("cri","((Belief + Plausibility)/2.)"); + SetParameterString("cri","((Belief + Plausibility)/2.)", false); AddParameter(ParameterType_Float,"wgt","Weighting"); SetParameterDescription("wgt","Coefficient between 0 and 1 to promote undetection or false detections (default 0.5)"); MandatoryOff("wgt"); - SetParameterFloat("wgt", 0.5); + SetParameterFloat("wgt",0.5, false); AddParameter(ParameterType_InputFilename,"initmod","initialization model"); SetParameterDescription("initmod","Initialization model (xml file) to be used. If the xml initialization model is set, the descriptor list is not used (specified using the option -desclist)"); @@ -154,12 +154,12 @@ private: AddParameter(ParameterType_StringList, "desclist","Descriptor list"); SetParameterDescription("desclist","List of the descriptors to be used in the model (must be specified to perform an automatic initialization)"); MandatoryOff("desclist"); - SetParameterString("desclist",""); + SetParameterString("desclist","", false); AddParameter(ParameterType_Int,"maxnbit","Maximum number of iterations"); MandatoryOff("maxnbit"); SetParameterDescription("maxnbit","Maximum number of optimizer iteration (default 200)"); - SetParameterInt("maxnbit", 200); + SetParameterInt("maxnbit",200, false); AddParameter(ParameterType_Empty,"optobs","Optimizer Observer"); SetParameterDescription("optobs","Activate the optimizer observer"); diff --git a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx index d83410e452ae8825bd799cd3219379024502c43d..d511384c0e95e99a36c662b5344f36180b6b0527 100644 --- a/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx +++ b/Modules/Applications/AppClassification/app/otbKMeansClassification.cxx @@ -245,7 +245,7 @@ private: { 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); + this->SetParameterInt("ts",maxPixNb, false); } this->SetMaximumParameterIntValue("ts", maxPixNb); diff --git a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx index f1e90e88a8c9e4a134eedb93a4ed12500bda89bf..8bbd60510cf0938116c462e59fbab50c5bed8f42 100644 --- a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx +++ b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx @@ -161,7 +161,7 @@ private: SetParameterDescription("strategy.all","Take all samples"); // Default strategy : smallest - SetParameterString("strategy","smallest"); + SetParameterString("strategy","smallest", false); AddParameter(ParameterType_Choice, "mim", "Multi-Image Mode"); diff --git a/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx b/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx index b1161dddd7a2fd9e8bd66bf930f299aa7ca29e46..6ec4a448ed8d868649e12e5b838f26044e6deec8 100644 --- a/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx @@ -78,7 +78,7 @@ private: AddParameter(ParameterType_String,"cfield","Field containing the predicted class."); SetParameterDescription("cfield","Field containing the predicted class"); - SetParameterString("cfield","predicted"); + SetParameterString("cfield","predicted", false); // Doc example parameter settings SetDocExampleParameterValue("inshp", "vectorData.shp"); diff --git a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx index bd5f447ed718235410bb86804787918d19620ffd..0eb1e3a8a9a60c18a3ed3a6a79fbdb44f3b9e40f 100644 --- a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx @@ -86,7 +86,7 @@ private: AddParameter(ParameterType_String, "outfield.prefix.name", "Output field prefix"); SetParameterDescription("outfield.prefix.name","Prefix used to form the field names that" "will contain the extracted values."); - SetParameterString("outfield.prefix.name", "value_"); + SetParameterString("outfield.prefix.name", "value_", false); AddChoice("outfield.list","Use the given name list"); SetParameterDescription("outfield.list","Use the given name list"); diff --git a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx index 5ff2926888f5a97b2e735fd8ac3e895dae114829..81b2b33f021a01753d7a7703abe050ba4c51790e 100644 --- a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx @@ -197,7 +197,7 @@ private: SetParameterDescription("strategy.all","Take all samples"); // Default strategy : smallest - SetParameterString("strategy","smallest"); + SetParameterString("strategy","smallest", false); AddParameter(ParameterType_ListView, "field", "Field Name"); SetParameterDescription("field","Name of the field carrying the class name in the input vectors."); diff --git a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx index 6fdcecf6d104b6aa9597fd24408c088cc3e42aa7..5433dcf170b2d8110b488267033bf87bd2ef9628 100644 --- a/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainImagesClassifier.cxx @@ -155,7 +155,7 @@ void DoInit() ITK_OVERRIDE SetParameterDescription("sample.vtr", "Ratio between training and validation samples (0.0 = all training, 1.0 = " "all validation) (default = 0.5)."); - SetParameterFloat("sample.vtr", 0.5); + SetParameterFloat("sample.vtr",0.5, false); SetMaximumParameterFloatValue("sample.vtr",1.0); SetMinimumParameterFloatValue("sample.vtr",0.0); @@ -214,7 +214,7 @@ void DoUpdateParameters() ITK_OVERRIDE if ( HasValue("io.vd") ) { std::vector<std::string> vectorFileList = GetParameterStringList("io.vd"); - GetInternalApplication("polystat")->SetParameterString("vec",vectorFileList[0]); + GetInternalApplication("polystat")->SetParameterString("vec",vectorFileList[0], false); UpdateInternalParameters("polystat"); } } @@ -289,21 +289,21 @@ void DoExecute() ITK_OVERRIDE for (unsigned int i=0 ; i<nbInputs ; i++) { GetInternalApplication("polystat")->SetParameterInputImage("in",imageList->GetNthElement(i)); - GetInternalApplication("polystat")->SetParameterString("vec",vectorFileList[i]); - GetInternalApplication("polystat")->SetParameterString("out",polyStatTrainOutputs[i]); + GetInternalApplication("polystat")->SetParameterString("vec",vectorFileList[i], false); + GetInternalApplication("polystat")->SetParameterString("out",polyStatTrainOutputs[i], false); ExecuteInternal("polystat"); // analyse polygons given for validation if (dedicatedValidation) { - GetInternalApplication("polystat")->SetParameterString("vec",validationVectorFileList[i]); - GetInternalApplication("polystat")->SetParameterString("out",polyStatValidOutputs[i]); + GetInternalApplication("polystat")->SetParameterString("vec",validationVectorFileList[i], false); + GetInternalApplication("polystat")->SetParameterString("out",polyStatValidOutputs[i], false); ExecuteInternal("polystat"); } } // --------------------------------------------------------------------------- // Compute sampling rates - GetInternalApplication("rates")->SetParameterString("mim","proportional"); + GetInternalApplication("rates")->SetParameterString("mim","proportional", false); double vtr = GetParameterFloat("sample.vtr"); long mt = GetParameterInt("sample.mt"); long mv = GetParameterInt("sample.mv"); @@ -348,44 +348,44 @@ void DoExecute() ITK_OVERRIDE } // Sampling rates for training - GetInternalApplication("rates")->SetParameterStringList("il",polyStatTrainOutputs); - GetInternalApplication("rates")->SetParameterString("out",rateTrainOut); + GetInternalApplication("rates")->SetParameterStringList("il",polyStatTrainOutputs, false); + GetInternalApplication("rates")->SetParameterString("out",rateTrainOut, false); if (GetParameterInt("sample.bm") != 0) { - GetInternalApplication("rates")->SetParameterString("strategy","smallest"); + GetInternalApplication("rates")->SetParameterString("strategy","smallest", false); } else { if (fmt > -1) { - GetInternalApplication("rates")->SetParameterString("strategy","constant"); + GetInternalApplication("rates")->SetParameterString("strategy","constant", false); GetInternalApplication("rates")->SetParameterInt("strategy.constant.nb",fmt); } else { - GetInternalApplication("rates")->SetParameterString("strategy","all"); + GetInternalApplication("rates")->SetParameterString("strategy","all", false); } } ExecuteInternal("rates"); // Sampling rates for validation if (dedicatedValidation) { - GetInternalApplication("rates")->SetParameterStringList("il",polyStatValidOutputs); - GetInternalApplication("rates")->SetParameterString("out",rateValidOut); + GetInternalApplication("rates")->SetParameterStringList("il",polyStatValidOutputs, false); + GetInternalApplication("rates")->SetParameterString("out",rateValidOut, false); if (GetParameterInt("sample.bm") != 0) { - GetInternalApplication("rates")->SetParameterString("strategy","smallest"); + GetInternalApplication("rates")->SetParameterString("strategy","smallest", false); } else { if (fmv > -1) { - GetInternalApplication("rates")->SetParameterString("strategy","constant"); + GetInternalApplication("rates")->SetParameterString("strategy","constant", false); GetInternalApplication("rates")->SetParameterInt("strategy.constant.nb",fmv); } else { - GetInternalApplication("rates")->SetParameterString("strategy","all"); + GetInternalApplication("rates")->SetParameterString("strategy","all", false); } } ExecuteInternal("rates"); @@ -393,18 +393,18 @@ void DoExecute() ITK_OVERRIDE // --------------------------------------------------------------------------- // Select & extract samples - GetInternalApplication("select")->SetParameterString("sampler", "periodic"); + GetInternalApplication("select")->SetParameterString("sampler", "periodic", false); GetInternalApplication("select")->SetParameterInt("sampler.periodic.jitter",50); - GetInternalApplication("select")->SetParameterString("strategy","byclass"); - GetInternalApplication("extraction")->SetParameterString("outfield", "prefix"); - GetInternalApplication("extraction")->SetParameterString("outfield.prefix.name","value_"); + GetInternalApplication("select")->SetParameterString("strategy","byclass", false); + GetInternalApplication("extraction")->SetParameterString("outfield", "prefix", false); + GetInternalApplication("extraction")->SetParameterString("outfield.prefix.name","value_", false); for (unsigned int i=0 ; i<nbInputs ; i++) { GetInternalApplication("select")->SetParameterInputImage("in",imageList->GetNthElement(i)); - GetInternalApplication("select")->SetParameterString("vec",vectorFileList[i]); - GetInternalApplication("select")->SetParameterString("out",sampleOutputs[i]); - GetInternalApplication("select")->SetParameterString("instats",polyStatTrainOutputs[i]); - GetInternalApplication("select")->SetParameterString("strategy.byclass.in",ratesTrainOutputs[i]); + GetInternalApplication("select")->SetParameterString("vec",vectorFileList[i], false); + GetInternalApplication("select")->SetParameterString("out",sampleOutputs[i], false); + GetInternalApplication("select")->SetParameterString("instats",polyStatTrainOutputs[i], false); + GetInternalApplication("select")->SetParameterString("strategy.byclass.in",ratesTrainOutputs[i], false); // select sample positions ExecuteInternal("select"); // extract sample descriptors @@ -412,10 +412,10 @@ void DoExecute() ITK_OVERRIDE if (dedicatedValidation) { - GetInternalApplication("select")->SetParameterString("vec",validationVectorFileList[i]); - GetInternalApplication("select")->SetParameterString("out",sampleValidOutputs[i]); - GetInternalApplication("select")->SetParameterString("instats",polyStatValidOutputs[i]); - GetInternalApplication("select")->SetParameterString("strategy.byclass.in",ratesValidOutputs[i]); + GetInternalApplication("select")->SetParameterString("vec",validationVectorFileList[i], false); + GetInternalApplication("select")->SetParameterString("out",sampleValidOutputs[i], false); + GetInternalApplication("select")->SetParameterString("instats",polyStatValidOutputs[i], false); + GetInternalApplication("select")->SetParameterString("strategy.byclass.in",ratesValidOutputs[i], false); // select sample positions ExecuteInternal("select"); // extract sample descriptors @@ -473,8 +473,8 @@ void DoExecute() ITK_OVERRIDE // --------------------------------------------------------------------------- // Train model - GetInternalApplication("training")->SetParameterStringList("io.vd",sampleTrainOutputs); - GetInternalApplication("training")->SetParameterStringList("valid.vd",sampleValidOutputs); + GetInternalApplication("training")->SetParameterStringList("io.vd",sampleTrainOutputs, false); + GetInternalApplication("training")->SetParameterStringList("valid.vd",sampleValidOutputs, false); UpdateInternalParameters("training"); // set field names FloatVectorImageType::Pointer image = imageList->GetNthElement(0); @@ -486,7 +486,7 @@ void DoExecute() ITK_OVERRIDE oss << i; selectedNames.push_back("value_"+oss.str()); } - GetInternalApplication("training")->SetParameterStringList("feat",selectedNames); + GetInternalApplication("training")->SetParameterStringList("feat",selectedNames, false); ExecuteInternal("training"); // cleanup diff --git a/Modules/Applications/AppClassification/app/otbTrainOGRLayersClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainOGRLayersClassifier.cxx index b461ac2a89f97fda7b2b2308d6e6f08ce5834964..0e4affaa6c4957b0c773af552d9756ce44339278 100644 --- a/Modules/Applications/AppClassification/app/otbTrainOGRLayersClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainOGRLayersClassifier.cxx @@ -80,7 +80,7 @@ private: AddParameter(ParameterType_String,"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."); - SetParameterString("cfield","class"); + SetParameterString("cfield","class", false); // Doc example parameter settings SetDocExampleParameterValue("inshp", "vectorData.shp"); diff --git a/Modules/Applications/AppClassification/app/otbTrainRegression.cxx b/Modules/Applications/AppClassification/app/otbTrainRegression.cxx index 3039d44a0a053a5a84787683258069c16575b27c..335961cfce88ce3c259f1cb4f25be9d2b029c8ac 100644 --- a/Modules/Applications/AppClassification/app/otbTrainRegression.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainRegression.cxx @@ -159,7 +159,7 @@ void DoInit() ITK_OVERRIDE AddParameter(ParameterType_Float, "sample.vtr", "Training and validation sample ratio"); SetParameterDescription("sample.vtr", "Ratio between training and validation samples (0.0 = all training, 1.0 = all validation) (default = 0.5)."); - SetParameterFloat("sample.vtr", 0.5); + SetParameterFloat("sample.vtr",0.5, false); Superclass::DoInit(); diff --git a/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx b/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx index c260e168195bc5b9e923b4ac34e48bec6a054a63..234b90e7677adcebd0259cba08d084b2d9e793d2 100644 --- a/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorDataDSValidation.cxx @@ -84,12 +84,12 @@ private: AddParameter(ParameterType_String, "cri", "Criterion"); SetParameterDescription("cri", "Dempster Shafer criterion (by default (belief+plausibility)/2)"); MandatoryOff("cri"); - SetParameterString("cri", "((Belief + Plausibility)/2.)"); + SetParameterString("cri", "((Belief + Plausibility)/2.)", false); AddParameter(ParameterType_Float, "thd", "Criterion threshold"); SetParameterDescription("thd", "Criterion threshold (default 0.5)"); MandatoryOff("thd"); - SetParameterFloat("thd", 0.5); + SetParameterFloat("thd",0.5, false); AddParameter(ParameterType_OutputVectorData, "out", "Output Vector Data"); SetParameterDescription("out", "Output VectorData containing only the validated samples"); diff --git a/Modules/Applications/AppClassification/include/otbTrainBoost.txx b/Modules/Applications/AppClassification/include/otbTrainBoost.txx index fbd99531a4eff13525b9db92ddad63643397bb2a..ea725cc28e52dfcbb1e25f4b77df859fac005792 100644 --- a/Modules/Applications/AppClassification/include/otbTrainBoost.txx +++ b/Modules/Applications/AppClassification/include/otbTrainBoost.txx @@ -39,22 +39,22 @@ namespace Wrapper 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)"); - SetParameterString("classifier.boost.t", "real"); + SetParameterString("classifier.boost.t", "real", false); SetParameterDescription("classifier.boost.t", "Type of Boosting algorithm."); //Do not expose SplitCriteria //WeakCount AddParameter(ParameterType_Int, "classifier.boost.w", "Weak count"); - SetParameterInt("classifier.boost.w", 100); + SetParameterInt("classifier.boost.w",100, false); SetParameterDescription("classifier.boost.w","The number of weak classifiers."); //WeightTrimRate AddParameter(ParameterType_Float, "classifier.boost.r", "Weight Trim Rate"); - SetParameterFloat("classifier.boost.r", 0.95); + 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."); //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); + SetParameterInt("classifier.boost.m",1, false); SetParameterDescription("classifier.boost.m","Maximum depth of the tree."); } diff --git a/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx b/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx index 61cd1a34befbcf00aa70ea0703f3f43af3c81570..def7b605e537d51e73de0ab43dbd398d64032798 100644 --- a/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx +++ b/Modules/Applications/AppClassification/include/otbTrainDecisionTree.txx @@ -34,7 +34,7 @@ LearningApplicationBase<TInputValue,TOutputValue> "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"); - SetParameterInt("classifier.dt.max", 65535); + SetParameterInt("classifier.dt.max",65535, false); 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 " @@ -42,13 +42,13 @@ LearningApplicationBase<TInputValue,TOutputValue> //MinSampleCount AddParameter(ParameterType_Int, "classifier.dt.min", "Minimum number of samples in each node"); - SetParameterInt("classifier.dt.min", 10); + 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."); //RegressionAccuracy AddParameter(ParameterType_Float, "classifier.dt.ra", "Termination criteria for regression tree"); - SetParameterFloat("classifier.dt.ra", 0.01); + 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."); @@ -60,14 +60,14 @@ 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"); - SetParameterInt("classifier.dt.cat", 10); + 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."); //CVFolds AddParameter(ParameterType_Int, "classifier.dt.f", "K-fold cross-validations"); - SetParameterInt("classifier.dt.f", 10); + SetParameterInt("classifier.dt.f",10, false); 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."); diff --git a/Modules/Applications/AppClassification/include/otbTrainGradientBoostedTree.txx b/Modules/Applications/AppClassification/include/otbTrainGradientBoostedTree.txx index bcf5caa86181a84c546c264052bad32f2d8fd95f..d67f9643447686f4d8ee87e1143fc9a847d55b93 100644 --- a/Modules/Applications/AppClassification/include/otbTrainGradientBoostedTree.txx +++ b/Modules/Applications/AppClassification/include/otbTrainGradientBoostedTree.txx @@ -45,7 +45,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //WeakCount AddParameter(ParameterType_Int, "classifier.gbt.w", "Number of boosting algorithm iterations"); - SetParameterInt("classifier.gbt.w", 200); + SetParameterInt("classifier.gbt.w",200, false); SetParameterDescription( "classifier.gbt.w", "Number \"w\" of boosting algorithm iterations, with w*K being the total number of trees in " @@ -53,20 +53,20 @@ LearningApplicationBase<TInputValue,TOutputValue> //Shrinkage AddParameter(ParameterType_Float, "classifier.gbt.s", "Regularization parameter"); - SetParameterFloat("classifier.gbt.s", 0.01); + SetParameterFloat("classifier.gbt.s",0.01, false); SetParameterDescription("classifier.gbt.s", "Regularization parameter."); //SubSamplePortion AddParameter(ParameterType_Float, "classifier.gbt.p", "Portion of the whole training set used for each algorithm iteration"); - SetParameterFloat("classifier.gbt.p", 0.8); + SetParameterFloat("classifier.gbt.p",0.8, false); SetParameterDescription( "classifier.gbt.p", "Portion of the whole training set used for each algorithm iteration. The subset is generated randomly."); //MaxDepth AddParameter(ParameterType_Int, "classifier.gbt.max", "Maximum depth of the tree"); - SetParameterInt("classifier.gbt.max", 3); + SetParameterInt("classifier.gbt.max",3, false); SetParameterDescription( "classifier.gbt.max", "The training algorithm attempts to split each node while its depth is smaller than the maximum " "possible depth of the tree. The actual depth may be smaller if the other termination criteria are met, and/or " diff --git a/Modules/Applications/AppClassification/include/otbTrainKNN.txx b/Modules/Applications/AppClassification/include/otbTrainKNN.txx index fdf10cdf283f1a5f22f3044aea335c844c16101c..6fba81fe4ea9d0604c5e0e3c19bcea876bfb76be 100644 --- a/Modules/Applications/AppClassification/include/otbTrainKNN.txx +++ b/Modules/Applications/AppClassification/include/otbTrainKNN.txx @@ -34,7 +34,7 @@ namespace Wrapper //K parameter AddParameter(ParameterType_Int, "classifier.knn.k", "Number of Neighbors"); - SetParameterInt("classifier.knn.k", 32); + SetParameterInt("classifier.knn.k",32, false); SetParameterDescription("classifier.knn.k","The number of neighbors to use."); if (this->m_RegressionFlag) diff --git a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx index f89b7141566e3993f117990eaea5c7cb87f9438b..120b572fcee064bac28a14cce05526eb82862f2d 100644 --- a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx +++ b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx @@ -35,7 +35,7 @@ namespace Wrapper AddChoice("classifier.libsvm.k.rbf", "Gaussian radial basis function"); AddChoice("classifier.libsvm.k.poly", "Polynomial"); AddChoice("classifier.libsvm.k.sigmoid", "Sigmoid"); - SetParameterString("classifier.libsvm.k", "linear"); + SetParameterString("classifier.libsvm.k", "linear", false); SetParameterDescription("classifier.libsvm.k", "SVM Kernel Type."); AddParameter(ParameterType_Choice, "classifier.libsvm.m", "SVM Model Type"); SetParameterDescription("classifier.libsvm.m", "Type of SVM formulation."); @@ -43,17 +43,17 @@ namespace Wrapper { AddChoice("classifier.libsvm.m.epssvr", "Epsilon Support Vector Regression"); AddChoice("classifier.libsvm.m.nusvr", "Nu Support Vector Regression"); - SetParameterString("classifier.libsvm.m", "epssvr"); + SetParameterString("classifier.libsvm.m", "epssvr", false); } else { AddChoice("classifier.libsvm.m.csvc", "C support vector classification"); AddChoice("classifier.libsvm.m.nusvc", "Nu support vector classification"); AddChoice("classifier.libsvm.m.oneclass", "Distribution estimation (One Class SVM)"); - SetParameterString("classifier.libsvm.m", "csvc"); + SetParameterString("classifier.libsvm.m", "csvc", false); } AddParameter(ParameterType_Float, "classifier.libsvm.c", "Cost parameter C"); - SetParameterFloat("classifier.libsvm.c", 1.0); + 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."); @@ -67,9 +67,9 @@ namespace Wrapper if (this->m_RegressionFlag) { AddParameter(ParameterType_Float, "classifier.libsvm.eps", "Epsilon"); - SetParameterFloat("classifier.libsvm.eps", 1e-3); + SetParameterFloat("classifier.libsvm.eps",1e-3, false); AddParameter(ParameterType_Float, "classifier.libsvm.nu", "Nu"); - SetParameterFloat("classifier.libsvm.nu", 0.5); + SetParameterFloat("classifier.libsvm.nu",0.5, false); } } diff --git a/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx b/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx index ee7bf43d47c7e9f9b653208b8c7d611afc13c62e..8f9386a8d557b48a16f24df93edc5b943d062324 100644 --- a/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx +++ b/Modules/Applications/AppClassification/include/otbTrainNeuralNetwork.txx @@ -38,7 +38,7 @@ LearningApplicationBase<TInputValue,TOutputValue> AddParameter(ParameterType_Choice, "classifier.ann.t", "Train Method Type"); AddChoice("classifier.ann.t.reg", "RPROP algorithm"); AddChoice("classifier.ann.t.back", "Back-propagation algorithm"); - SetParameterString("classifier.ann.t", "reg"); + SetParameterString("classifier.ann.t", "reg", false); SetParameterDescription("classifier.ann.t", "Type of training method for the multilayer perceptron (MLP) neural network."); //LayerSizes @@ -56,25 +56,25 @@ LearningApplicationBase<TInputValue,TOutputValue> AddChoice("classifier.ann.f.ident", "Identity function"); AddChoice("classifier.ann.f.sig", "Symmetrical Sigmoid function"); AddChoice("classifier.ann.f.gau", "Gaussian function (Not completely supported)"); - SetParameterString("classifier.ann.f", "sig"); + SetParameterString("classifier.ann.f", "sig", false); SetParameterDescription("classifier.ann.f", "Neuron activation function."); //Alpha AddParameter(ParameterType_Float, "classifier.ann.a", "Alpha parameter of the activation function"); - SetParameterFloat("classifier.ann.a", 1.); + SetParameterFloat("classifier.ann.a",1., false); SetParameterDescription("classifier.ann.a", "Alpha parameter of the activation function (used only with sigmoid and gaussian functions)."); //Beta AddParameter(ParameterType_Float, "classifier.ann.b", "Beta parameter of the activation function"); - SetParameterFloat("classifier.ann.b", 1.); + SetParameterFloat("classifier.ann.b",1., false); SetParameterDescription("classifier.ann.b", "Beta parameter of the activation function (used only with sigmoid and gaussian functions)."); //BackPropDWScale AddParameter(ParameterType_Float, "classifier.ann.bpdw", "Strength of the weight gradient term in the BACKPROP method"); - SetParameterFloat("classifier.ann.bpdw", 0.1); + 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."); @@ -82,7 +82,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //BackPropMomentScale AddParameter(ParameterType_Float, "classifier.ann.bpms", "Strength of the momentum term (the difference between weights on the 2 previous iterations)"); - SetParameterFloat("classifier.ann.bpms", 0.1); + 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). " @@ -92,12 +92,12 @@ LearningApplicationBase<TInputValue,TOutputValue> //RegPropDW0 AddParameter(ParameterType_Float, "classifier.ann.rdw", "Initial value Delta_0 of update-values Delta_{ij} in RPROP method"); - SetParameterFloat("classifier.ann.rdw", 0.1); + 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)."); //RegPropDWMin AddParameter(ParameterType_Float, "classifier.ann.rdwm", "Update-values lower limit Delta_{min} in RPROP method"); - SetParameterFloat("classifier.ann.rdwm", 1e-7); + 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)."); @@ -107,18 +107,18 @@ LearningApplicationBase<TInputValue,TOutputValue> AddChoice("classifier.ann.term.iter", "Maximum number of iterations"); AddChoice("classifier.ann.term.eps", "Epsilon"); AddChoice("classifier.ann.term.all", "Max. iterations + Epsilon"); - SetParameterString("classifier.ann.term", "all"); + 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"); - SetParameterFloat("classifier.ann.eps", 0.01); + SetParameterFloat("classifier.ann.eps",0.01, false); SetParameterDescription("classifier.ann.eps", "Epsilon value used in the Termination criteria."); //MaxIter AddParameter(ParameterType_Int, "classifier.ann.iter", "Maximum number of iterations used in the Termination criteria"); - SetParameterInt("classifier.ann.iter", 1000); + SetParameterInt("classifier.ann.iter",1000, false); SetParameterDescription("classifier.ann.iter", "Maximum number of iterations used in the Termination criteria."); } diff --git a/Modules/Applications/AppClassification/include/otbTrainRandomForests.txx b/Modules/Applications/AppClassification/include/otbTrainRandomForests.txx index 669b4562b6e955aaf34dd821675e3194d5b8f37b..7a507bb8f8d2bdbd4fabf4a9c01e3fc922c558c3 100644 --- a/Modules/Applications/AppClassification/include/otbTrainRandomForests.txx +++ b/Modules/Applications/AppClassification/include/otbTrainRandomForests.txx @@ -34,7 +34,7 @@ LearningApplicationBase<TInputValue,TOutputValue> "See complete documentation here \\url{http://docs.opencv.org/modules/ml/doc/random_trees.html}."); //MaxDepth AddParameter(ParameterType_Int, "classifier.rf.max", "Maximum depth of the tree"); - SetParameterInt("classifier.rf.max", 5); + SetParameterInt("classifier.rf.max",5, false); SetParameterDescription( "classifier.rf.max", "The depth of the tree. A low value will likely underfit and conversely a high value will likely overfit. " @@ -42,14 +42,14 @@ LearningApplicationBase<TInputValue,TOutputValue> //MinSampleCount AddParameter(ParameterType_Int, "classifier.rf.min", "Minimum number of samples in each node"); - SetParameterInt("classifier.rf.min", 10); + SetParameterInt("classifier.rf.min",10, false); SetParameterDescription( "classifier.rf.min", "If the number of samples in a node is smaller than this parameter, " "then the node will not be split. A reasonable value is a small percentage of the total data e.g. 1 percent."); //RegressionAccuracy AddParameter(ParameterType_Float, "classifier.rf.ra", "Termination Criteria for regression tree"); - SetParameterFloat("classifier.rf.ra", 0.); + SetParameterFloat("classifier.rf.ra",0., false); SetParameterDescription("classifier.rf.ra", "If all absolute differences between an estimated value in a node " "and the values of the train samples in this node are smaller than this regression accuracy parameter, " "then the node will not be split."); @@ -61,7 +61,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxNumberOfCategories AddParameter(ParameterType_Int, "classifier.rf.cat", "Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split"); - SetParameterInt("classifier.rf.cat", 10); + SetParameterInt("classifier.rf.cat",10, false); SetParameterDescription( "classifier.rf.cat", "Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split."); @@ -73,7 +73,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxNumberOfVariables AddParameter(ParameterType_Int, "classifier.rf.var", "Size of the randomly selected subset of features at each tree node"); - SetParameterInt("classifier.rf.var", 0); + SetParameterInt("classifier.rf.var",0, false); SetParameterDescription( "classifier.rf.var", "The size of the subset of features, randomly selected at each tree node, that are used to find the best split(s). " @@ -82,7 +82,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxNumberOfTrees AddParameter(ParameterType_Int, "classifier.rf.nbtrees", "Maximum number of trees in the forest"); - SetParameterInt("classifier.rf.nbtrees", 100); + SetParameterInt("classifier.rf.nbtrees",100, false); SetParameterDescription( "classifier.rf.nbtrees", "The maximum number of trees in the forest. Typically, the more trees you have, the better the accuracy. " @@ -92,7 +92,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //ForestAccuracy AddParameter(ParameterType_Float, "classifier.rf.acc", "Sufficient accuracy (OOB error)"); - SetParameterFloat("classifier.rf.acc", 0.01); + SetParameterFloat("classifier.rf.acc",0.01, false); SetParameterDescription("classifier.rf.acc","Sufficient accuracy (OOB error)."); diff --git a/Modules/Applications/AppClassification/include/otbTrainSVM.txx b/Modules/Applications/AppClassification/include/otbTrainSVM.txx index d36c28dd052097b98a06bd7be44e163d5dc1cf38..2893b43e4b97304f902c5adf5a0328f042c7904e 100644 --- a/Modules/Applications/AppClassification/include/otbTrainSVM.txx +++ b/Modules/Applications/AppClassification/include/otbTrainSVM.txx @@ -37,35 +37,35 @@ namespace Wrapper { AddChoice("classifier.svm.m.epssvr", "Epsilon Support Vector Regression"); AddChoice("classifier.svm.m.nusvr", "Nu Support Vector Regression"); - SetParameterString("classifier.svm.m", "epssvr"); + SetParameterString("classifier.svm.m", "epssvr", false); } else { AddChoice("classifier.svm.m.csvc", "C support vector classification"); AddChoice("classifier.svm.m.nusvc", "Nu support vector classification"); AddChoice("classifier.svm.m.oneclass", "Distribution estimation (One Class SVM)"); - SetParameterString("classifier.svm.m", "csvc"); + SetParameterString("classifier.svm.m", "csvc", false); } 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"); - SetParameterString("classifier.svm.k", "linear"); + SetParameterString("classifier.svm.k", "linear", false); SetParameterDescription("classifier.svm.k", "SVM Kernel Type."); AddParameter(ParameterType_Float, "classifier.svm.c", "Cost parameter C"); - SetParameterFloat("classifier.svm.c", 1.0); + 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."); AddParameter(ParameterType_Float, "classifier.svm.nu", "Parameter nu of a SVM optimization problem (NU_SVC / ONE_CLASS)"); - SetParameterFloat("classifier.svm.nu", 0.0); + SetParameterFloat("classifier.svm.nu",0.0, false); 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); + 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"); @@ -75,22 +75,22 @@ namespace Wrapper 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); + SetParameterFloat("classifier.svm.iter",1000, false); SetParameterDescription("classifier.svm.iter", "Maximum number of iterations (corresponds to the termination criteria 'iter')."); AddParameter(ParameterType_Float, "classifier.svm.eps", "Epsilon accuracy threshold"); - SetParameterFloat("classifier.svm.eps", FLT_EPSILON); + SetParameterFloat("classifier.svm.eps",FLT_EPSILON, false); SetParameterDescription("classifier.svm.eps", "Epsilon accuracy (corresponds to the termination criteria 'eps')."); } AddParameter(ParameterType_Float, "classifier.svm.coef0", "Parameter coef0 of a kernel function (POLY / SIGMOID)"); - SetParameterFloat("classifier.svm.coef0", 0.0); + SetParameterFloat("classifier.svm.coef0",0.0, false); 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); + 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)"); - SetParameterFloat("classifier.svm.degree", 1.0); + 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"); MandatoryOff("classifier.svm.opt"); @@ -211,15 +211,15 @@ namespace Wrapper SVMClassifier->Save(modelPath); // Update the displayed parameters in the GUI after the training process, for further use of them - SetParameterFloat("classifier.svm.c", static_cast<float> (SVMClassifier->GetOutputC())); - SetParameterFloat("classifier.svm.nu", static_cast<float> (SVMClassifier->GetOutputNu())); + SetParameterFloat("classifier.svm.c",static_cast<float> (SVMClassifier->GetOutputC()), false); + SetParameterFloat("classifier.svm.nu",static_cast<float> (SVMClassifier->GetOutputNu()), false); if (this->m_RegressionFlag) { - SetParameterFloat("classifier.svm.p", static_cast<float> (SVMClassifier->GetOutputP())); + SetParameterFloat("classifier.svm.p",static_cast<float> (SVMClassifier->GetOutputP()), false); } - SetParameterFloat("classifier.svm.coef0", static_cast<float> (SVMClassifier->GetOutputCoef0())); - SetParameterFloat("classifier.svm.gamma", static_cast<float> (SVMClassifier->GetOutputGamma())); - SetParameterFloat("classifier.svm.degree", static_cast<float> (SVMClassifier->GetOutputDegree())); + SetParameterFloat("classifier.svm.coef0",static_cast<float> (SVMClassifier->GetOutputCoef0()), false); + SetParameterFloat("classifier.svm.gamma",static_cast<float> (SVMClassifier->GetOutputGamma()), false); + SetParameterFloat("classifier.svm.degree",static_cast<float> (SVMClassifier->GetOutputDegree()), false); } } //end namespace wrapper diff --git a/Modules/Applications/AppClassification/include/otbTrainSharkRandomForests.txx b/Modules/Applications/AppClassification/include/otbTrainSharkRandomForests.txx index c9b2d565695c708da557074076fadfcaa3a6c4cd..cf9705b3089884c39a4563b021893370d4facb2c 100644 --- a/Modules/Applications/AppClassification/include/otbTrainSharkRandomForests.txx +++ b/Modules/Applications/AppClassification/include/otbTrainSharkRandomForests.txx @@ -38,7 +38,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MaxNumberOfTrees AddParameter(ParameterType_Int, "classifier.sharkrf.nbtrees", "Maximum number of trees in the forest"); - SetParameterInt("classifier.sharkrf.nbtrees", 100); + SetParameterInt("classifier.sharkrf.nbtrees",100, false); SetParameterDescription( "classifier.sharkrf.nbtrees", "The maximum number of trees in the forest. Typically, the more trees you have, the better the accuracy. " @@ -48,7 +48,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //NodeSize AddParameter(ParameterType_Int, "classifier.sharkrf.nodesize", "Min size of the node for a split"); - SetParameterInt("classifier.sharkrf.nodesize", 25); + SetParameterInt("classifier.sharkrf.nodesize",25, false); SetParameterDescription( "classifier.sharkrf.nodesize", "If the number of samples in a node is smaller than this parameter, " @@ -56,7 +56,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //MTry AddParameter(ParameterType_Int, "classifier.sharkrf.mtry", "Number of features tested at each node"); - SetParameterInt("classifier.sharkrf.mtry", 0); + SetParameterInt("classifier.sharkrf.mtry",0, false); SetParameterDescription( "classifier.sharkrf.mtry", "The number of features (variables) which will be tested at each node in " @@ -66,7 +66,7 @@ LearningApplicationBase<TInputValue,TOutputValue> //OOB Ratio AddParameter(ParameterType_Float, "classifier.sharkrf.oobr", "Out of bound ratio"); - SetParameterFloat("classifier.sharkrf.oobr", 0.66); + SetParameterFloat("classifier.sharkrf.oobr",0.66, false); SetParameterDescription("classifier.sharkrf.oobr", "Set the fraction of the original training dataset to use as the out of bag sample." "A good default value is 0.66. "); diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx index dd9c450359f24d17d5389bc2172f728ae25d0bc8..18d951eeda4964327c5f97fbceb5fc3cb0bd94df 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx @@ -168,6 +168,8 @@ private: AddParameter(ParameterType_OutputFilename, "outmatrix", "Transformation matrix output (text format)"); SetParameterDescription("outmatrix", "Filename to store the transformation matrix (csv format)"); MandatoryOff("outmatrix"); + DisableParameter("outmatrix"); + AddRAMParameter(); @@ -189,7 +191,7 @@ private: unsigned int nbComp = static_cast<unsigned int> (GetParameterInt("nbcomp")); if (nbComp > nbComponents) { - SetParameterInt("nbcomp", nbComponents); + SetParameterInt("nbcomp",nbComponents, false); otbAppLogINFO( << "number of selected components can't exceed image dimension : "<<nbComponents ); } @@ -199,14 +201,14 @@ private: if (this->GetParameterString("outinv").size()!= 0) { otbAppLogWARNING(<<"This application only provides the forward transform for the MAF method."); - this->SetParameterString("outinv", ""); + this->SetParameterString("outinv", "", false); } this->DisableParameter("outinv"); if (this->GetParameterString("outmatrix").size()!= 0) { otbAppLogWARNING(<<"No transformation matrix available for MAF method."); - this->SetParameterString("outmatrix", ""); + this->SetParameterString("outmatrix", "", false); } this->DisableParameter("outmatrix"); @@ -218,7 +220,7 @@ private: unsigned int nbComp = static_cast<unsigned int> (GetParameterInt("nbcomp")); if ((nbComp != 0) && (nbComp != nbComponents)) { - SetParameterInt("nbcomp", nbComponents); + SetParameterInt("nbcomp",nbComponents, false); otbAppLogINFO( << "all components are kept when using MAF filter method."); } diff --git a/Modules/Applications/AppDomainTransform/CMakeLists.txt b/Modules/Applications/AppDomainTransform/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..67bc711e4a98cb05b8138dbc8da9ccb0ee460610 --- /dev/null +++ b/Modules/Applications/AppDomainTransform/CMakeLists.txt @@ -0,0 +1,2 @@ +project(OTBAppDomainTransform) +otb_module_impl() diff --git a/Modules/Applications/AppDomainTransform/app/CMakeLists.txt b/Modules/Applications/AppDomainTransform/app/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6837a6312608fed3480b2ea570d88ee9c47d3c5f --- /dev/null +++ b/Modules/Applications/AppDomainTransform/app/CMakeLists.txt @@ -0,0 +1,4 @@ +otb_create_application( + NAME DomainTransform + SOURCES otbDomainTransform.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) diff --git a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx new file mode 100644 index 0000000000000000000000000000000000000000..417861fa8d36762d7fa3405d02a1c70207bb59f8 --- /dev/null +++ b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx @@ -0,0 +1,425 @@ +/*========================================================================= + + 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. + + =========================================================================*/ + +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" +#include "otbWaveletImageFilter.h" +#include "otbWaveletInverseImageFilter.h" +#include "otbWaveletGenerator.h" + +#include <itkConfigure.h> +#include <itkForwardFFTImageFilter.h> +#include <itkInverseFFTImageFilter.h> +#include <itkUnaryFunctorImageFilter.h> +#include <itkFFTShiftImageFilter.h> + +#include "otbComplexToVectorImageCastFilter.h" + +namespace otb +{ +namespace Wrapper +{ +template< class TInput, class TOutput> +class ToComplexPixel +{ +public: + ToComplexPixel ( ) { }; + + ~ToComplexPixel( ) { }; + + bool operator!=( const ToComplexPixel & ) const + { + return false; + } + bool operator==( const ToComplexPixel & other ) const + { + return !(*this != other); + } + inline TOutput operator( )( const TInput & A ) const + { + return TOutput( static_cast<typename TOutput::value_type> ( A[0] ), + static_cast<typename TOutput::value_type> ( A[1] ) ); + } +}; + +class DomainTransform : public Application +{ +public: + /** Standard class typedefs. */ + typedef DomainTransform Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + + typedef itk::SmartPointer<const Self> ConstPointer; + typedef float InputPixelType; + typedef float OutputPixelType; + + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(Self, otb::Application); + +private: + DomainTransform() {} + + ~DomainTransform() ITK_OVERRIDE + { + // This is a trick to make sure fftw will cleanup its threads when application + // shared lib is released. + #if defined(ITK_USE_FFTWF) + fftwf_cleanup_threads(); + fftwf_cleanup(); + #endif + #if defined(ITK_USE_FFTWD) + fftw_cleanup_threads(); + fftw_cleanup(); + #endif + } + + void DoInit() ITK_OVERRIDE + { + SetName("DomainTransform"); + SetDescription("Domain Transform application for wavelet and fourier"); + + // Documentation + SetDocName("DomainTransform"); + SetDocLongDescription("Domain Transform application for wavelet and fourier"); + SetDocLimitations("This application is not streamed, check your system resources when processing large images"); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso("otbWaveletImageFilter, otbWaveletInverseImageFilter, otbWaveletTransform"); + AddDocTag(Tags::Filter); + + // Parameters + AddParameter(ParameterType_InputImage, "in", "Input Image"); + SetParameterDescription("in", "This will take an input image to be transformed" + " image. For FFT inverse transform, it expects a complex image as two-band" + " image in which first band represent real part and second band represent" + " imaginary part."); + + AddParameter(ParameterType_OutputImage, "out", "Output Image"); + SetParameterDescription("out", "This parameter holds the output file name to" + " which transformed image will be written. This has a slightly different" + " behaviour depending on transform type. \n For Wavelet, output is a" + " single band image for both forward and inverse transform. \n For FFT" + " forward transform, output is two band image where first band represents" + " real part and second band represents imaginary part of a complex image."); + + AddParameter(ParameterType_Choice, "mode", "Mode"); + SetParameterDescription("mode", "This parameter allows one to select between" + " fft(fourier) and wavelet"); + + AddChoice("mode.fft", "FFT transform"); + SetParameterDescription("mode.fft", "FFT transform"); + + AddParameter(ParameterType_Empty, "mode.fft.shift", "Shift fft transform"); + SetParameterDescription("mode.fft.shift", "Shift transform of fft filter"); + + AddChoice("mode.wavelet", "Wavelet"); + SetParameterDescription("mode.wavelet", "Wavelet transform"); + + AddParameter(ParameterType_Choice, "mode.wavelet.form", "Select wavelet form"); + AddChoice("mode.wavelet.form.haar", "HAAR"); + AddChoice("mode.wavelet.form.db4", "DAUBECHIES4"); + AddChoice("mode.wavelet.form.db6", "DAUBECHIES6"); + AddChoice("mode.wavelet.form.db8", "DAUBECHIES8"); + AddChoice("mode.wavelet.form.db12", "DAUBECHIES12"); + AddChoice("mode.wavelet.form.db20", "DAUBECHIES20"); + AddChoice("mode.wavelet.form.sb24", "SPLINE_BIORTHOGONAL_2_4"); + AddChoice("mode.wavelet.form.sb44", "SPLINE_BIORTHOGONAL_4_4"); + AddChoice("mode.wavelet.form.sym8", "SYMLET8"); + + // Default values for mode + SetParameterString("mode", "wavelet", false); + SetParameterString("mode.wavelet.form", "haar", false); + + AddParameter(ParameterType_Choice,"direction", "Direction"); + AddChoice("direction.forward", "Forward"); + AddChoice("direction.inverse", "Inverse"); + + AddParameter(ParameterType_Int,"mode.wavelet.nlevels","Number of decomposition levels"); + SetParameterDescription("mode.wavelet.nlevels","Number of decomposition levels"); + SetDefaultParameterInt("mode.wavelet.nlevels",2); + SetMinimumParameterIntValue("mode.wavelet.nlevels",2); + + AddRAMParameter(); + + SetDocExampleParameterValue("in", "input.tif"); + SetDocExampleParameterValue("mode.wavelet.form", "haar"); + SetDocExampleParameterValue("out", "output_wavelet_haar.tif"); + } + + void DoUpdateParameters() ITK_OVERRIDE + { + + } + + void DoExecute() ITK_OVERRIDE + { + int dir = GetParameterInt("direction"); + int mode = GetParameterInt("mode"); + + if( dir != 0 && dir != 1) + { + itkExceptionMacro(<< "-dir is '" + << dir << "'." + << "It must be either 'forward' or 'inverse'"); + } + + if( mode != 0 && mode != 1) + { + itkExceptionMacro( << "mode is '" + << mode << "'." + << "It must must be either 'fft' or 'wavelet'"); + } + + if ( mode == 1) + { + int wavelet_type = GetParameterInt("mode.wavelet.form"); + unsigned int nlevels = GetParameterInt("mode.wavelet.nlevels"); + switch (wavelet_type) + { + case 0: + { + DoWaveletTransform<otb::Wavelet::HAAR>(dir, nlevels); + break; + } + case 1: + { + DoWaveletTransform<otb::Wavelet::DB4>(dir, nlevels); + break; + } + case 2: + { + DoWaveletTransform<otb::Wavelet::DB4>(dir, nlevels); + break; + } + case 3: + { + DoWaveletTransform<otb::Wavelet::DB6>(dir, nlevels); + break; + } + case 4: + { + DoWaveletTransform<otb::Wavelet::DB8>(dir, nlevels); + break; + } + case 5: + { + DoWaveletTransform<otb::Wavelet::DB12>(dir, nlevels); + break; + } + case 6: + { + DoWaveletTransform<otb::Wavelet::DB20>(dir, nlevels); + break; + } + case 7: + { + DoWaveletTransform<otb::Wavelet::SPLINE_BIORTHOGONAL_2_4 >(dir, nlevels); + break; + } + case 8: + { + DoWaveletTransform<otb::Wavelet::SPLINE_BIORTHOGONAL_4_4>(dir, nlevels); + break; + } + case 9: + { + DoWaveletTransform<otb::Wavelet::SYMLET8>(dir, nlevels); + break; + } + default: + { + itkExceptionMacro( << "Invalid wavelet type: '" << wavelet_type << "'"); + break; + } + } + } + else + { + // fft ttransform + bool shift = IsParameterEnabled( "mode.fft.shift"); + typedef otb::Image< std::complex<OutputPixelType> > ComplexOutputImageType; + + if (dir == 0 ) + { + //forward fft + typedef otb::Image<InputPixelType> TInputImage; + typedef TInputImage::Pointer TInputImagePointer; + + //get input parameter as otb::Image<InputPixelType> + TInputImagePointer inImage = GetParameterImage<TInputImage>("in"); + + //typedef itk::::ForwardFFTImageFilter over otbImage< InputPixelType > + + typedef itk::ForwardFFTImageFilter < TInputImage, ComplexOutputImageType > FFTFilter; + FFTFilter::Pointer fwdFilter = FFTFilter::New(); + fwdFilter->SetInput( inImage ); + + + //typedef VectorImage for output of UnaryFunctorImageFilter + typedef otb::VectorImage<OutputPixelType> TOutputImage; + + typedef otb::ComplexToVectorImageCastFilter< + ComplexOutputImageType, + TOutputImage > ComplexToVectorImageCastFilter; + ComplexToVectorImageCastFilter::Pointer unaryFunctorImageFilter = ComplexToVectorImageCastFilter::New(); + + if( shift) + { + otbAppLogINFO( << "Applying Shift image filter" ); + typedef itk::FFTShiftImageFilter< + FFTFilter::OutputImageType, + FFTFilter::OutputImageType > FFTShiftFilterType; + + FFTShiftFilterType::Pointer + fftShiftFilter = FFTShiftFilterType::New(); + + fftShiftFilter->SetInput( fwdFilter->GetOutput() ); + fftShiftFilter->Update(); + unaryFunctorImageFilter->SetInput(fftShiftFilter->GetOutput() ); + } + else + { + unaryFunctorImageFilter->SetInput(fwdFilter->GetOutput()); + } + + unaryFunctorImageFilter->Update(); + + //set output image + SetParameterOutputImage<TOutputImage>("out", + unaryFunctorImageFilter->GetOutput()); + } + else + { + //inverse fft + typedef otb::VectorImage<InputPixelType> TInputImage; + typedef TInputImage::Pointer TInputImagePointer; + + TInputImagePointer inImage = GetParameterImage("in"); + + // typedef TComplexImage for InverseFFTImageFilter input + // This a image type of std::complex<InputPixelType> + typedef otb::Image< + std::complex<InputPixelType>, 2 > TComplexImage; + //typedef TOutputImage for InverseFFTImageFilter output + typedef otb::Image< OutputPixelType > TOutputImage; + + // a unary functor to convert vectorimage to complex image + typedef itk::UnaryFunctorImageFilter + <TInputImage, + TComplexImage, + ToComplexPixel + <TInputImage::PixelType, + TComplexImage::PixelType> > UnaryFunctorImageFilter; + + UnaryFunctorImageFilter::Pointer + unaryFunctorImageFilter = UnaryFunctorImageFilter::New(); + + if( shift) + { + typedef itk::FFTShiftImageFilter< + TInputImage, + TInputImage > FFTShiftFilterType; + + FFTShiftFilterType::Pointer + fftShiftFilter = FFTShiftFilterType::New(); + fftShiftFilter->SetInput( inImage ); + + fftShiftFilter->Update(); + + unaryFunctorImageFilter->SetInput(fftShiftFilter->GetOutput() ); + } + else + { + unaryFunctorImageFilter->SetInput(inImage); + } + + unaryFunctorImageFilter->Update(); + + //typedef itk::::InverseFFTImageFilter over TComplexImage + typedef itk::InverseFFTImageFilter + < TComplexImage, + TOutputImage > FFTFilter; + FFTFilter::Pointer invFilter = FFTFilter::New(); + invFilter->SetInput( unaryFunctorImageFilter->GetOutput() ); + invFilter->Update(); + + //set output image + SetParameterOutputImage<TOutputImage>("out", invFilter->GetOutput()); + } + } + } + + template<otb::Wavelet::Wavelet TWaveletOperator> + void DoWaveletTransform(const int dir, + const unsigned int nlevels, + const std::string inkey = "in", + const std::string outkey = "out") + { + typedef otb::Image< InputPixelType > TInputImage; + typedef otb::Image< OutputPixelType > TOutputImage; + typedef typename TInputImage::Pointer TInputImagePointer; + + TInputImagePointer inImage = GetParameterImage<TInputImage>(inkey); + + if( dir == 0) + { + typedef otb::WaveletImageFilter< + TInputImage, + TOutputImage, + TWaveletOperator> TWaveletImageFilter; + + typedef typename + TWaveletImageFilter::Pointer + TWaveletImageFilterPointer; + TWaveletImageFilterPointer waveletImageFilter = + TWaveletImageFilter::New(); + + waveletImageFilter->SetInput(inImage); + waveletImageFilter->SetNumberOfDecompositions(nlevels); + waveletImageFilter->Update(); + SetParameterOutputImage<TOutputImage>(outkey, waveletImageFilter->GetOutput() ); + } + else + { + typedef otb::WaveletInverseImageFilter< + TInputImage, + TOutputImage, + TWaveletOperator > TWaveletImageFilter; + + typedef typename + TWaveletImageFilter::Pointer + TWaveletImageFilterPointer; + + TWaveletImageFilterPointer waveletImageFilter = + TWaveletImageFilter::New(); + + waveletImageFilter->SetInput(inImage); + waveletImageFilter->SetNumberOfDecompositions(nlevels); + waveletImageFilter->Update(); + + SetParameterOutputImage<TOutputImage>( outkey, waveletImageFilter->GetOutput() ); + } + } +}; + +} // end of namespace Wrapper +} // end of namespace otb + +OTB_APPLICATION_EXPORT(otb::Wrapper::DomainTransform) diff --git a/Modules/Applications/AppDomainTransform/otb-module.cmake b/Modules/Applications/AppDomainTransform/otb-module.cmake new file mode 100644 index 0000000000000000000000000000000000000000..7346a4367b9c898ce8a654a217cf05beaeb529df --- /dev/null +++ b/Modules/Applications/AppDomainTransform/otb-module.cmake @@ -0,0 +1,15 @@ +set(DOCUMENTATION "Application to perform Wavelet and Fourier transform. This application is not streamed") + +otb_module(OTBAppDomainTransform +DEPENDS + OTBWavelet + OTBApplicationEngine + + TEST_DEPENDS + OTBTestKernel + OTBCommandLine + + DESCRIPTION + "${DOCUMENTATION}" +) + diff --git a/Modules/Applications/AppDomainTransform/test/CMakeLists.txt b/Modules/Applications/AppDomainTransform/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..593cf6f458cd2fb143bc7d916a0288efcbc0446e --- /dev/null +++ b/Modules/Applications/AppDomainTransform/test/CMakeLists.txt @@ -0,0 +1,38 @@ +otb_module_test() +otb_test_application(NAME apTvDomainTransform_wav_db20_fwd + APP DomainTransform + OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif + -mode wavelet + -mode.wavelet.form db20 + -mode.wavelet.nlevels 2 + -direction forward + -out ${TEMP}/apTvDomainTransform_wav_db20_fwd.tif + ) + +otb_test_application(NAME apTvDomainTransform_wav_haar_inv + APP DomainTransform + OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif + -mode wavelet + -mode.wavelet.form haar + -direction inverse + -out ${TEMP}/apTvDomainTransform_wav_haar_inv.tif + ) + +otb_test_application(NAME apTvDomainTransform_fft_shift_fwd + APP DomainTransform + OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif + -mode fft + -mode.fft.shift true + -direction forward + -out ${TEMP}/apTvDomainTransform_fft_shift_fwd.tif + ) + + +otb_test_application(NAME apTvDomainTransform_fft_inv + APP DomainTransform + OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif + -mode fft + -direction inverse + -out ${TEMP}/apTvDomainTransform_fft_shift_inv.tif + ) + diff --git a/Modules/Applications/AppFiltering/app/otbSmoothing.cxx b/Modules/Applications/AppFiltering/app/otbSmoothing.cxx index 18cd825f50212ee39e70be300824861e15503d23..14e6be72943071e6dc9f8d92299e70ec1209d98e 100644 --- a/Modules/Applications/AppFiltering/app/otbSmoothing.cxx +++ b/Modules/Applications/AppFiltering/app/otbSmoothing.cxx @@ -103,7 +103,7 @@ private: SetDefaultParameterInt("type.anidif.nbiter", 10); SetDefaultParameterInt("type.anidif.conductance", 1.); - SetParameterString("type", "anidif"); + SetParameterString("type", "anidif", false); // Doc example parameter settings SetExampleComment("Image smoothing using a mean filter.", 0); diff --git a/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx b/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx index 2f31cd6344d4c8a76db4436b4303e1aed42af98d..48d0c9c0a8f8cd3c133d07ab30ea367e95aaa088 100644 --- a/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx +++ b/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx @@ -16,25 +16,14 @@ =========================================================================*/ #include "otbWrapperApplicationFactory.h" +#include "otbWrapperCompositeApplication.h" -#include "otbMultiToMonoChannelExtractROI.h" -#include "otbGenericRSResampleImageFilter.h" -#include "otbGridResampleImageFilter.h" -#include "otbImportGeoInformationImageFilter.h" -#include "otbBCOInterpolateImageFunction.h" -#include "otbSimpleRcsPanSharpeningFusionImageFilter.h" -#include "itkFixedArray.h" - -// Elevation handler -#include "otbWrapperElevationParametersHandler.h" - -#include "otbPleiadesPToXSAffineTransformCalculator.h" namespace otb { namespace Wrapper { -class BundleToPerfectSensor : public Application +class BundleToPerfectSensor : public CompositeApplication { public: /** Standard class typedefs. */ @@ -46,7 +35,7 @@ public: /** Standard macro */ itkNewMacro(Self); - itkTypeMacro(BundleToPerfectSensor, otb::Application); + itkTypeMacro(BundleToPerfectSensor, otb::Wrapper::CompositeApplication); private: @@ -65,38 +54,27 @@ private: AddDocTag(Tags::Geometry); AddDocTag(Tags::Pansharpening); - AddParameter(ParameterType_InputImage, "inp", "Input PAN Image"); - SetParameterDescription("inp"," Input panchromatic image."); - AddParameter(ParameterType_InputImage, "inxs", "Input XS Image"); - SetParameterDescription("inxs"," Input XS image."); - - AddParameter(ParameterType_OutputImage, "out", "Output image"); - SetParameterDescription("out"," Output image."); - - // Elevation - ElevationParametersHandler::AddElevationParameters(this, "elev"); - - // Superposition mode - AddParameter(ParameterType_Choice,"mode", "Mode"); - SetParameterDescription("mode", "Superimposition mode"); - - AddChoice("mode.default", "Default mode"); - SetParameterDescription("mode.default", "Default superimposition mode : " - "uses any projection reference or sensor model found in the images"); - - AddChoice("mode.phr", "Pleiades mode"); - SetParameterDescription("mode.phr", "Pleiades superimposition mode, " - "designed for the case of a P+XS bundle in SENSOR geometry. It uses" - " a simple transform on the XS image : a scaling and a residual " - "translation."); + ClearApplications(); + AddApplication("Superimpose", "superimpose", "Reproject XS onto Pan"); + AddApplication("Pansharpening", "pansharp", "Fusion of XS and Pan"); + + ShareParameter("inp","superimpose.inr","Input PAN Image","Input panchromatic image."); + ShareParameter("inxs","superimpose.inm","Input XS Image","Input XS image."); + ShareParameter("out","pansharp.out"); + ShareParameter("elev","superimpose.elev"); + ShareParameter("mode","superimpose.mode"); + ShareParameter("lms","superimpose.lms", + "Spacing of the deformation field", + "Spacing of the deformation field. Default is 10 times the PAN image spacing."); + 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); - AddParameter(ParameterType_Float, "lms", "Spacing of the deformation field"); - SetParameterDescription("lms"," Spacing of the deformation field. Default is 10 times the PAN image spacing."); - - AddRAMParameter(); - - MandatoryOff("lms"); - // Doc example parameter settings SetDocExampleParameterValue("inp", "QB_Toulouse_Ortho_PAN.tif"); SetDocExampleParameterValue("inxs", "QB_Toulouse_Ortho_XS.tif"); @@ -106,150 +84,19 @@ private: void DoUpdateParameters() ITK_OVERRIDE { - if(!HasUserValue("mode") && HasValue("inp") && HasValue("inxs") && otb::PleiadesPToXSAffineTransformCalculator::CanCompute(GetParameterImage("inp"),GetParameterImage("inxs"))) - { - otbAppLogWARNING("Forcing PHR mode with PHR data. You need to add \"-mode default\" to force the default mode with PHR images."); - SetParameterString("mode","phr"); - } + UpdateInternalParameters("superimpose"); } void DoExecute() ITK_OVERRIDE { - FloatVectorImageType* panchroV = GetParameterImage("inp"); - FloatVectorImageType* xs = GetParameterImage("inxs"); - - if ( panchroV->GetNumberOfComponentsPerPixel() != 1 ) - { - itkExceptionMacro(<< "The panchromatic image must be a single channel image") - } - - // Transform the PAN image to otb::Image - typedef otb::Image<FloatVectorImageType::InternalPixelType> InternalImageType; - typedef otb::MultiToMonoChannelExtractROI<float,float> ExtractFilterType; - - ExtractFilterType::Pointer channelSelect = ExtractFilterType::New(); - m_Ref.push_back(channelSelect.GetPointer()); - channelSelect->SetChannel(1); - channelSelect->SetInput(panchroV); - channelSelect->UpdateOutputInformation(); - InternalImageType::Pointer panchro = channelSelect->GetOutput(); - - typedef otb::BCOInterpolateImageFunction<FloatVectorImageType> InterpolatorType; - typedef otb::GenericRSResampleImageFilter<FloatVectorImageType, FloatVectorImageType> ResamplerType; - typedef otb::GridResampleImageFilter<FloatVectorImageType, FloatVectorImageType> BasicResamplerType; - typedef otb::ImportGeoInformationImageFilter<FloatVectorImageType,InternalImageType> ImportGeoInformationFilterType; - typedef otb::SimpleRcsPanSharpeningFusionImageFilter<InternalImageType, FloatVectorImageType, FloatVectorImageType> FusionFilterType; + ExecuteInternal("superimpose"); - // Resample filter - ResamplerType::Pointer resampler = ResamplerType::New(); - m_Ref.push_back(resampler.GetPointer()); - - BasicResamplerType::Pointer basicResampler = BasicResamplerType::New(); - m_Ref.push_back(basicResampler.GetPointer()); - - ImportGeoInformationFilterType::Pointer geoImport = ImportGeoInformationFilterType::New(); - m_Ref.push_back(geoImport.GetPointer()); - - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - resampler->SetInterpolator(interpolator); - basicResampler->SetInterpolator(interpolator); - - // Fusion filter - FusionFilterType::Pointer fusionFilter = FusionFilterType::New(); - m_Ref.push_back(fusionFilter.GetPointer()); - fusionFilter->SetPanInput(panchro); - - // Setup the DEM Handler - otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev"); - - // Set up output image information - FloatVectorImageType::SpacingType spacing = panchro->GetSpacing(); - FloatVectorImageType::IndexType start = panchro->GetLargestPossibleRegion().GetIndex(); - FloatVectorImageType::SizeType size = panchro->GetLargestPossibleRegion().GetSize(); - FloatVectorImageType::PointType origin = panchro->GetOrigin(); - - FloatVectorImageType::PixelType defaultValue; - itk::NumericTraits<FloatVectorImageType::PixelType>::SetLength(defaultValue, xs->GetNumberOfComponentsPerPixel()); + GetInternalApplication("pansharp")->SetParameterInputImage("inxs", + GetInternalApplication("superimpose")->GetParameterOutputImage("out")); - if(GetParameterString("mode") == "default") - { - otbAppLogINFO("Using the default mode"); - if(IsParameterEnabled("lms") && HasValue("lms")) - { - double defScalarSpacing = GetParameterFloat("lms"); - otbAppLogINFO(<< "Generating coarse deformation field (spacing="<<defScalarSpacing<<")" << std::endl); - FloatVectorImageType::SpacingType defSpacing; - - defSpacing[0] = defScalarSpacing; - defSpacing[1] = defScalarSpacing; - - resampler->SetDisplacementFieldSpacing(defSpacing); - } - else - { - FloatVectorImageType::SpacingType defSpacing; - defSpacing[0]=10*spacing[0]; - defSpacing[1]=10*spacing[1]; - resampler->SetDisplacementFieldSpacing(defSpacing); - } - - resampler->SetInput(xs); - resampler->SetOutputOrigin(origin); - resampler->SetOutputSpacing(spacing); - resampler->SetOutputSize(size); - resampler->SetOutputStartIndex(start); - resampler->SetOutputKeywordList(panchro->GetImageKeywordlist()); - resampler->SetOutputProjectionRef(panchro->GetProjectionRef()); - resampler->SetEdgePaddingValue(defaultValue); - fusionFilter->SetXsInput(resampler->GetOutput()); - } - else if(GetParameterString("mode")=="phr") - { - otbAppLogINFO("Using the PHR mode"); - - otb::PleiadesPToXSAffineTransformCalculator::TransformType::OffsetType offset - = otb::PleiadesPToXSAffineTransformCalculator::ComputeOffset(GetParameterImage("inp"), - GetParameterImage("inxs")); - - origin+=offset; - origin[0]=origin[0]/4; - origin[1]=origin[1]/4; - - basicResampler->SetOutputOrigin(origin); - basicResampler->SetInput(xs); - basicResampler->SetOutputOrigin(origin); - - FloatVectorImageType::SpacingType xsSpacing = GetParameterImage("inxs")->GetSpacing(); - xsSpacing*=0.25; - - basicResampler->SetOutputSpacing(xsSpacing); - basicResampler->SetOutputSize(size); - basicResampler->SetOutputStartIndex(start); - basicResampler->SetEdgePaddingValue(defaultValue); - - geoImport->SetInput(basicResampler->GetOutput()); - geoImport->SetSource(panchro); - - fusionFilter->SetXsInput(geoImport->GetOutput()); - - // Set the profRef & Keywordlist from Pan into the resampled XS image - basicResampler->UpdateOutputInformation(); - itk::MetaDataDictionary& dict = basicResampler->GetOutput()->GetMetaDataDictionary(); - itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey, - panchro->GetProjectionRef()); - itk::EncapsulateMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey, - panchro->GetImageKeywordlist()); - } - else - { - otbAppLogWARNING("Unknown mode"); - } - - SetParameterOutputImage("out", fusionFilter->GetOutput()); + ExecuteInternal("pansharp"); } - std::vector<itk::ProcessObject::Pointer> m_Ref; - }; diff --git a/Modules/Applications/AppFusion/otb-module.cmake b/Modules/Applications/AppFusion/otb-module.cmake index 54fe75ccac06953703f04292cf71acadd3a4939c..e09047b0b4b7372b86c007a6b70532d6b6f4e691 100644 --- a/Modules/Applications/AppFusion/otb-module.cmake +++ b/Modules/Applications/AppFusion/otb-module.cmake @@ -10,6 +10,7 @@ otb_module(OTBAppFusion OTBInterpolation TEST_DEPENDS + OTBAppProjection OTBTestKernel OTBCommandLine diff --git a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx index 750dab500b013de237e0873ca42ee8829384dc2d..403368ec40fcb2f466ec2938d4513ffed9847fc2 100644 --- a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx +++ b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx @@ -126,7 +126,7 @@ private: AddChoice("ua.mdmdnmf", "MDMDNMF"); SetParameterDescription("ua.mdmdnmf", "Minimum Dispersion Constrained Non Negative Matrix Factorization"); - SetParameterString("ua", "ucls"); + SetParameterString("ua", "ucls", false); // Doc example parameter settings SetDocExampleParameterValue("in", "cupriteSubHsi.tif"); SetDocExampleParameterValue("ie", "cupriteEndmembers.tif"); diff --git a/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx b/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx index 8191f40f6242d61e8d90f86e775c0778e614b91b..214c77f4e458bbec05dc6f855821bb12c541c73a 100644 --- a/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx +++ b/Modules/Applications/AppHyperspectral/app/otbVertexComponentAnalysis.cxx @@ -65,7 +65,7 @@ private: AddParameter(ParameterType_Int, "ne", "Number of endmembers"); SetParameterDescription("ne","The number of endmembers to extract from the data cube"); - SetParameterInt("ne", 1); + SetParameterInt("ne",1, false); MandatoryOn("ne"); AddParameter(ParameterType_OutputImage, "outendm", "Output Endmembers"); diff --git a/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx b/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx index 5be587709679b0ad3f70d7472b2c5a7a24244af6..cd1d0c4e8911de9f5fe253a56b79ba93709dd549 100644 --- a/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx +++ b/Modules/Applications/AppImageUtils/app/otbColorMapping.cxx @@ -342,11 +342,11 @@ private: AddParameter(ParameterType_Float,"method.continuous.min","Mapping range lower value"); SetParameterDescription("method.continuous.min","Set the lower input value of the mapping range."); - SetParameterFloat("method.continuous.min", 0.); + SetParameterFloat("method.continuous.min",0., false); AddParameter(ParameterType_Float,"method.continuous.max","Mapping range higher value"); SetParameterDescription("method.continuous.max","Set the higher input value of the mapping range."); - SetParameterFloat("method.continuous.max", 255.); + SetParameterFloat("method.continuous.max",255., false); // Optimal LUT AddChoice("method.optimal","Compute an optimized look-up table"); @@ -355,7 +355,7 @@ private: "[color to label] Searching all the colors present in the image to compute a continuous label list"); AddParameter(ParameterType_Int,"method.optimal.background", "Background label"); SetParameterDescription("method.optimal.background","Value of the background label"); - SetParameterInt("method.optimal.background", 0); + SetParameterInt("method.optimal.background",0, false); SetMinimumParameterIntValue("method.optimal.background", 0); SetMaximumParameterIntValue("method.optimal.background", 255); @@ -367,18 +367,18 @@ private: AddParameter(ParameterType_Float, "method.image.nodatavalue", "NoData value"); SetParameterDescription("method.image.nodatavalue","NoData value for each channel of the support image, which will not be handled in the LUT estimation. If NOT checked, ALL the pixel values of the support image will be handled in the LUT estimation."); MandatoryOff("method.image.nodatavalue"); - SetParameterFloat("method.image.nodatavalue", 0); + SetParameterFloat("method.image.nodatavalue",0, false); DisableParameter("method.image.nodatavalue"); AddParameter(ParameterType_Int, "method.image.low", "lower quantile"); SetParameterDescription("method.image.low","lower quantile for image normalization"); MandatoryOff("method.image.low"); - SetParameterInt("method.image.low", 2); + SetParameterInt("method.image.low",2, false); SetMinimumParameterIntValue("method.image.low", 0); SetMaximumParameterIntValue("method.image.low", 100); AddParameter(ParameterType_Int, "method.image.up", "upper quantile"); SetParameterDescription("method.image.up","upper quantile for image normalization"); MandatoryOff("method.image.up"); - SetParameterInt("method.image.up", 2); + SetParameterInt("method.image.up",2, false); SetMinimumParameterIntValue("method.image.up", 0); SetMaximumParameterIntValue("method.image.up", 100); @@ -400,7 +400,7 @@ private: if (GetParameterInt("method")==1 || GetParameterInt("method")==3) { otbAppLogWARNING("Override method : use optimal"); - SetParameterInt("method", 2); + SetParameterInt("method",2, false); } } } diff --git a/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx b/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx index 37210b5790277f47898c442b2b0576048fe9c877..b7d34b93bbb52d6b1733e1fbbba6fa9e94acac7a 100644 --- a/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx +++ b/Modules/Applications/AppImageUtils/app/otbCompareImages.cxx @@ -220,10 +220,10 @@ private: otbAppLogINFO( << "PSNR: " << m_CompareFilter->GetPSNR() ); otbAppLogINFO( << "Number of Pixel different: " << m_CompareFilter->GetDiffCount() ); - SetParameterFloat( "mse", m_CompareFilter->GetMSE() ); - SetParameterFloat( "mae", m_CompareFilter->GetMAE() ); - SetParameterFloat( "psnr", m_CompareFilter->GetPSNR() ); - SetParameterFloat( "count", m_CompareFilter->GetDiffCount() ); + SetParameterFloat( "mse",m_CompareFilter->GetMSE() , false); + SetParameterFloat( "mae",m_CompareFilter->GetMAE() , false); + SetParameterFloat( "psnr",m_CompareFilter->GetPSNR() , false); + SetParameterFloat( "count",m_CompareFilter->GetDiffCount() , false); } diff --git a/Modules/Applications/AppImageUtils/app/otbConvert.cxx b/Modules/Applications/AppImageUtils/app/otbConvert.cxx index c5ec7a20bc3a6fbd26880c2294a387024579640b..085fe5db06158ac110424666d2100b4b32fbd546 100644 --- a/Modules/Applications/AppImageUtils/app/otbConvert.cxx +++ b/Modules/Applications/AppImageUtils/app/otbConvert.cxx @@ -99,7 +99,7 @@ private: AddChoice("type.none", "None"); AddChoice("type.linear", "Linear"); AddChoice("type.log2", "Log2"); - SetParameterString("type", "none"); + SetParameterString("type", "none", false); AddParameter(ParameterType_Float,"type.linear.gamma","Gamma correction factor"); SetParameterDescription("type.linear.gamma","Gamma correction factor"); diff --git a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx index 8a3bc91d200271f629acfb2e5341a8bdb35c104a..4983ff4dc1f26bf7b00549e38b0f1049fe5fa83a 100644 --- a/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx +++ b/Modules/Applications/AppImageUtils/app/otbExtractROI.cxx @@ -126,8 +126,8 @@ private: if (!HasUserValue("sizex") && !HasUserValue("sizey") ) { - SetParameterInt("sizex", largestRegion.GetSize()[0]); - SetParameterInt("sizey", largestRegion.GetSize()[1]); + SetParameterInt("sizex",largestRegion.GetSize()[0], false); + SetParameterInt("sizey",largestRegion.GetSize()[1], false); } unsigned int nbComponents = inImage->GetNumberOfComponentsPerPixel(); @@ -164,8 +164,8 @@ private: if(!this->CropRegionOfInterest()) { // Put the index of the ROI to origin and try to crop again - SetParameterInt("startx", 0); - SetParameterInt("starty", 0); + SetParameterInt("startx",0, false); + SetParameterInt("starty",0, false); this->CropRegionOfInterest(); } } @@ -209,10 +209,10 @@ private: { if (region.Crop(GetParameterImage("in")->GetLargestPossibleRegion())) { - SetParameterInt("sizex", region.GetSize(0)); - SetParameterInt("sizey", region.GetSize(1)); - SetParameterInt("startx", region.GetIndex(0)); - SetParameterInt("starty", region.GetIndex(1)); + 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; } } diff --git a/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx b/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx index 03d98cf42bb1fd1577fd65be9731192b35155d82..5611b960aa02194370a4d11d684e857b4f5c2742 100644 --- a/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx +++ b/Modules/Applications/AppImageUtils/app/otbManageNoData.cxx @@ -109,7 +109,7 @@ private: SetParameterDescription("mode.apply.ndval","No Data value used according to the mask image"); SetDefaultParameterFloat("mode.apply.ndval", 0.0); - SetParameterString("mode","buildmask"); + SetParameterString("mode","buildmask", false); AddRAMParameter(); diff --git a/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx b/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx index f616b678864604ba6c759d067ebe171cc580235b..ed170b21e63896ea5562165d5fe08bbf93444086 100644 --- a/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx +++ b/Modules/Applications/AppImageUtils/app/otbPixelValue.cxx @@ -147,7 +147,7 @@ private: std::ostringstream oss; oss << extractor->GetOutput()->GetPixel(id)<<std::endl; - SetParameterString("value", oss.str()); + SetParameterString("value", oss.str(), false); //Display image information in the dedicated logger otbAppLogINFO( << oss.str() ); diff --git a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx index 7c3677041f526f47dbad77da25e6b96344ebdd3a..03d9ef4e2ac0d73c4533a20bc2aca1badc44d092 100644 --- a/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx +++ b/Modules/Applications/AppImageUtils/app/otbQuicklook.cxx @@ -141,8 +141,8 @@ private: if (!HasUserValue("rsx") && !HasUserValue("rsy") ) { - SetParameterInt("rsx", largestRegion.GetSize()[0]); - SetParameterInt("rsy", largestRegion.GetSize()[1]); + SetParameterInt("rsx",largestRegion.GetSize()[0], false); + SetParameterInt("rsy",largestRegion.GetSize()[1], false); } // Put the limit of the index and the size relative the image @@ -163,8 +163,8 @@ private: if(!this->CropRegionOfInterest()) { // Put the index of the ROI to origin and try to crop again - SetParameterInt("rox", 0); - SetParameterInt("roy", 0); + SetParameterInt("rox",0, false); + SetParameterInt("roy",0, false); this->CropRegionOfInterest(); } } @@ -183,10 +183,10 @@ bool CropRegionOfInterest() { if (region.Crop(GetParameterImage("in")->GetLargestPossibleRegion())) { - SetParameterInt("rsx", region.GetSize(0)); - SetParameterInt("rsy", region.GetSize(1)); - SetParameterInt("rox", region.GetIndex(0)); - SetParameterInt("roy", region.GetIndex(1)); + SetParameterInt( "rsx", region.GetSize(0), HasUserValue("rsx") ); + SetParameterInt( "rsy", region.GetSize(1), HasUserValue("rsy") ); + SetParameterInt( "rox", region.GetIndex(0), HasUserValue("rox") ); + SetParameterInt( "roy", region.GetIndex(1), HasUserValue("roy") ); return true; } } diff --git a/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx b/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx index aaa1143fb52239e13ece0aed69ab33829a49280a..8c78a284ec289951807ea4f064149b1cc6a1fde2 100644 --- a/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx +++ b/Modules/Applications/AppImageUtils/app/otbReadImageInfo.cxx @@ -262,7 +262,7 @@ private: ImageMetadataInterfaceType::Pointer metadataInterface = ImageMetadataInterfaceFactory::CreateIMI(inImage->GetMetaDataDictionary()); //Get number of bands - SetParameterInt("numberbands", inImage->GetNumberOfComponentsPerPixel()); + SetParameterInt("numberbands",inImage->GetNumberOfComponentsPerPixel(), false); ossOutput << "\tNumber of bands : " << GetParameterInt("numberbands") << std::endl; std::vector<bool> noDataValueAvailable; bool ret = itk::ExposeMetaData<std::vector<bool> >(inImage->GetMetaDataDictionary(),MetaDataKey::NoDataValueAvailable,noDataValueAvailable); @@ -293,26 +293,26 @@ private: ossOutput<<std::endl; //Get image size - SetParameterInt("indexx", inImage->GetLargestPossibleRegion().GetIndex()[0]); - SetParameterInt("indexy", inImage->GetLargestPossibleRegion().GetIndex()[1]); + SetParameterInt("indexx",inImage->GetLargestPossibleRegion().GetIndex()[0], false); + SetParameterInt("indexy",inImage->GetLargestPossibleRegion().GetIndex()[1], false); ossOutput << "\tStart index : [" << GetParameterInt("indexx") << "," << GetParameterInt("indexy") << "]" << std::endl; //Get image size - SetParameterInt("sizex", inImage->GetLargestPossibleRegion().GetSize()[0]); - SetParameterInt("sizey", inImage->GetLargestPossibleRegion().GetSize()[1]); + SetParameterInt("sizex",inImage->GetLargestPossibleRegion().GetSize()[0], false); + SetParameterInt("sizey",inImage->GetLargestPossibleRegion().GetSize()[1], false); ossOutput << "\tSize : [" << GetParameterInt("sizex") << "," << GetParameterInt("sizey") << "]" << std::endl; //Get image origin - SetParameterFloat("originx", inImage->GetOrigin()[0]); - SetParameterFloat("originy", inImage->GetOrigin()[1]); + SetParameterFloat("originx",inImage->GetOrigin()[0], false); + SetParameterFloat("originy",inImage->GetOrigin()[1], false); ossOutput << "\tOrigin : [" << GetParameterFloat("originx") << "," << GetParameterFloat("originy") << "]" << std::endl; //Get image spacing - SetParameterFloat("spacingx", inImage->GetSpacing()[0]); - SetParameterFloat("spacingy", inImage->GetSpacing()[1]); + SetParameterFloat("spacingx",inImage->GetSpacing()[0], false); + SetParameterFloat("spacingy",inImage->GetSpacing()[1], false); ossOutput << "\tSpacing : [" << GetParameterFloat("spacingx") << "," << GetParameterFloat("spacingy") << "]" << std::endl; //Estimate ground spacing @@ -331,14 +331,14 @@ private: approxGroundSpacing = groundSpacing->EvaluateAtIndex(index); //Get image estimated ground spacing (in m) - SetParameterFloat("estimatedgroundspacingx", approxGroundSpacing[0]); - SetParameterFloat("estimatedgroundspacingy", approxGroundSpacing[1]); + SetParameterFloat("estimatedgroundspacingx",approxGroundSpacing[0], false); + SetParameterFloat("estimatedgroundspacingy",approxGroundSpacing[1], false); ossOutput << "\tEstimated ground spacing (in meters): [" << GetParameterFloat("estimatedgroundspacingx") << "," << GetParameterFloat("estimatedgroundspacingy") << "]" << std::endl; ossOutput << std::endl << "Image acquisition information:" << std::endl; - SetParameterString("sensor", metadataInterface->GetSensorID()); + SetParameterString("sensor", metadataInterface->GetSensorID(), false); ossOutput << "\tSensor : "; if (!GetParameterString("sensor").empty()) ossOutput << GetParameterString("sensor"); @@ -348,11 +348,11 @@ private: ossOutput << "\tImage identification number: "; if (metadataInterface->GetImageKeywordlist().HasKey("image_id")) { - SetParameterString("id", metadataInterface->GetImageKeywordlist().GetMetadataByKey("image_id")); + SetParameterString("id", metadataInterface->GetImageKeywordlist().GetMetadataByKey("image_id"), false); ossOutput << GetParameterString("id"); } ossOutput << std::endl; - SetParameterString("projectionref", metadataInterface->GetProjectionRef()); + SetParameterString("projectionref", metadataInterface->GetProjectionRef(), false); if (!GetParameterString("projectionref").empty()) ossOutput << "\tImage projection : " << GetParameterString("projectionref") << std::endl; @@ -376,7 +376,7 @@ private: osstime<<"0"; osstime<<metadataInterface->GetMinute(); osstime<<":00"; - SetParameterString("time", osstime.str()); + SetParameterString("time", osstime.str(), false); ossOutput << "\tAcquisition time : " << GetParameterString("time") << std::endl; } @@ -405,29 +405,29 @@ private: if( !coord2name->GetCountryName().empty() ) { - SetParameterString("country", coord2name->GetCountryName()); + SetParameterString("country", coord2name->GetCountryName(), false); ossOutput << "\tCountry : " << GetParameterString("country") << std::endl; } else - SetParameterString("country", "Not available"); + SetParameterString("country", "Not available", false); if( !coord2name->GetPlaceName().empty() ) { - SetParameterString("town", coord2name->GetPlaceName()); + SetParameterString("town", coord2name->GetPlaceName(), false); ossOutput << "\tTown : " << GetParameterString("town") << std::endl; } else - SetParameterString("town", "Not available"); + SetParameterString("town", "Not available", false); // Retrieve footprint - SetParameterFloat("ullat", ullat); - SetParameterFloat("ullon", ullon); - SetParameterFloat("urlat", urlat); - SetParameterFloat("urlon", urlon); - SetParameterFloat("lrlat", lrlat); - SetParameterFloat("lrlon", lrlon); - SetParameterFloat("lllat", lllat); - SetParameterFloat("lllon", lllon); + SetParameterFloat("ullat",ullat, false); + SetParameterFloat("ullon",ullon, false); + SetParameterFloat("urlat",urlat, false); + SetParameterFloat("urlon",urlon, false); + SetParameterFloat("lrlat",lrlat, false); + SetParameterFloat("lrlon",lrlon, false); + SetParameterFloat("lllat",lllat, false); + SetParameterFloat("lllon",lllon, false); ossOutput << std::endl << "Image footprint coordinates:" << std::endl; ossOutput << "\tUpper left corner (latitude, longitude) = [" << GetParameterFloat("ullat") << "," << GetParameterFloat("ullon") << "]" << std::endl; @@ -439,15 +439,15 @@ private: { } - SetParameterInt("rgb.r", metadataInterface->GetDefaultDisplay()[0]); - SetParameterInt("rgb.g", metadataInterface->GetDefaultDisplay()[1]); - SetParameterInt("rgb.b", metadataInterface->GetDefaultDisplay()[2]); + SetParameterInt("rgb.r",metadataInterface->GetDefaultDisplay()[0], false); + SetParameterInt("rgb.g",metadataInterface->GetDefaultDisplay()[1], false); + SetParameterInt("rgb.b",metadataInterface->GetDefaultDisplay()[2], false); ossOutput << std::endl << "Image default RGB composition:" << std::endl; ossOutput << "\t[R, G, B] = [" << GetParameterInt("rgb.r") << "," << GetParameterInt("rgb.g") << "," << GetParameterInt("rgb.b") << "]" << std::endl; - SetParameterInt("gcp.count", metadataInterface->GetGCPCount()); - SetParameterString("gcp.proj", metadataInterface->GetGCPProjection()); + SetParameterInt("gcp.count",metadataInterface->GetGCPCount(), false); + SetParameterString("gcp.proj", metadataInterface->GetGCPProjection(), false); ossOutput << std::endl << "Ground control points information:" << std::endl; ossOutput << "\tNumber of GCPs = " << GetParameterInt("gcp.count") << std::endl; @@ -476,16 +476,16 @@ private: ossOutput << "\t\tGround coordinates =" << gcp_geocoord.back() << std::endl; } - SetParameterStringList("gcp.ids", gcp_ids); - SetParameterStringList("gcp.imcoord", gcp_imcoord); - SetParameterStringList("gcp.geocoord", gcp_geocoord); - SetParameterStringList("gcp.info", gcp_infos); + SetParameterStringList("gcp.ids", gcp_ids, false); + SetParameterStringList("gcp.imcoord", gcp_imcoord, false); + SetParameterStringList("gcp.geocoord", gcp_geocoord, false); + SetParameterStringList("gcp.info", gcp_infos, false); if ( IsParameterEnabled("keywordlist") ) { std::ostringstream osskeywordlist; osskeywordlist<<metadataInterface->GetImageKeywordlist() << std::endl; - SetParameterString("keyword", osskeywordlist.str()); + SetParameterString("keyword", osskeywordlist.str(), false); ossOutput << std::endl << "Image OSSIM keywordlist (optional):" << std::endl; ossOutput << "\t" << GetParameterString("keyword") << std::endl; diff --git a/Modules/Applications/AppImageUtils/app/otbRescale.cxx b/Modules/Applications/AppImageUtils/app/otbRescale.cxx index ea109547cf8cba64d6e9775436ad18aafeb4d6f3..21ada14c85674bff0b3795578f7dc7c1ec619cfe 100644 --- a/Modules/Applications/AppImageUtils/app/otbRescale.cxx +++ b/Modules/Applications/AppImageUtils/app/otbRescale.cxx @@ -52,8 +52,9 @@ private: SetDescription("Rescale the image between two given values."); SetDocName("Rescale Image"); - SetDocLongDescription("This application scales the given image pixel intensity between two given values. " - "By default min (resp. max) value is set to 0 (resp. 255)."); + SetDocLongDescription("This application scales the given image pixel intensity between two given values.\n" + "By default min (resp. max) value is set to 0 (resp. 255).\n" + "Input minimum and maximum values is automatically computed for all image bands."); SetDocLimitations("None"); SetDocAuthors("OTB-Team"); SetDocSeeAlso(" "); @@ -109,6 +110,7 @@ private: m_RescaleFilter = RescaleImageFilterType::New(); m_RescaleFilter->SetInput( inImage ); + m_RescaleFilter->SetAutomaticInputMinMaxComputation(false); m_RescaleFilter->SetInputMinimum( m_MinMaxFilter->GetMinimum() ); m_RescaleFilter->SetInputMaximum( m_MinMaxFilter->GetMaximum() ); diff --git a/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx b/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx index 19ef784627e25fa05532510984377a1705074f75..53884d3afa94e2455f1a94dc940e44949bff1168 100644 --- a/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx +++ b/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx @@ -209,7 +209,7 @@ private: if (useContext) { // only set the first expression, 'ManyExpression' is disabled. - this->SetParameterString("exp",dummyFilter->GetExpression(0)); + this->SetParameterString("exp",dummyFilter->GetExpression(0), false); } } } diff --git a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx index 10004ff35386d3add63f0cb6eef784ceacabac5a..52dd349396c57ebc48d03ae629ee5a13e8a5bfd9 100644 --- a/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx +++ b/Modules/Applications/AppOpticalCalibration/app/otbOpticalCalibration.cxx @@ -194,7 +194,7 @@ private: AddChoice("level.toa", "Image to Top Of Atmosphere reflectance"); AddChoice("level.toatoim", "TOA reflectance to Image"); AddChoice("level.toc", "Image to Top Of Canopy reflectance (atmospheric corrections)"); - SetParameterString("level", "toa"); + SetParameterString("level", "toa", false); AddParameter(ParameterType_Empty, "milli", "Convert to milli reflectance"); SetParameterDescription("milli", "Flag to use milli-reflectance instead of reflectance.\n" @@ -424,21 +424,21 @@ private: ossOutput << "Acquisition Minute already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.minute", lImageMetadataInterface->GetMinute()); + SetParameterInt("acqui.minute",lImageMetadataInterface->GetMinute(), false); } if (HasUserValue("acqui.hour")) ossOutput << "Acquisition Hour already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.hour", lImageMetadataInterface->GetHour()); + SetParameterInt("acqui.hour",lImageMetadataInterface->GetHour(), false); } if (HasUserValue("acqui.day")) ossOutput << "Acquisition Day already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.day", lImageMetadataInterface->GetDay()); + SetParameterInt("acqui.day",lImageMetadataInterface->GetDay(), false); if (IsParameterEnabled("acqui.fluxnormcoeff")) DisableParameter("acqui.day"); } @@ -447,7 +447,7 @@ private: ossOutput << "Acquisition Month already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.month", lImageMetadataInterface->GetMonth()); + SetParameterInt("acqui.month",lImageMetadataInterface->GetMonth(), false); if (IsParameterEnabled("acqui.fluxnormcoeff")) DisableParameter("acqui.month"); } @@ -456,28 +456,28 @@ private: ossOutput << "Acquisition Year already set by user: no overload" <<std::endl; else { - SetParameterInt("acqui.year", lImageMetadataInterface->GetYear()); + SetParameterInt("acqui.year",lImageMetadataInterface->GetYear(), false); } if (HasUserValue("acqui.sun.elev")) ossOutput << "Acquisition Sun Elevation Angle already set by user: no overload" <<std::endl; else - SetParameterFloat("acqui.sun.elev", lImageMetadataInterface->GetSunElevation()); + SetParameterFloat("acqui.sun.elev",lImageMetadataInterface->GetSunElevation(), false); if (HasUserValue("acqui.sun.azim")) ossOutput << "Acquisition Sun Azimuth Angle already set by user: no overload" <<std::endl; else - SetParameterFloat("acqui.sun.azim", lImageMetadataInterface->GetSunAzimuth()); + SetParameterFloat("acqui.sun.azim",lImageMetadataInterface->GetSunAzimuth(), false); if (HasUserValue("acqui.view.elev")) ossOutput << "Acquisition Viewing Elevation Angle already set by user: no overload" <<std::endl; else - SetParameterFloat("acqui.view.elev", lImageMetadataInterface->GetSatElevation()); + SetParameterFloat("acqui.view.elev",lImageMetadataInterface->GetSatElevation(), false); if (HasUserValue("acqui.view.azim")) ossOutput << "Acquisition Viewing Azimuth Angle already set by user: no overload" <<std::endl; else - SetParameterFloat("acqui.view.azim", lImageMetadataInterface->GetSatAzimuth()); + SetParameterFloat("acqui.view.azim",lImageMetadataInterface->GetSatAzimuth(), false); // Set default value so that they are stored somewhere even if // they are overloaded by user values @@ -823,12 +823,14 @@ private: { otbAppLogWARNING("No relative spectral response found, using " "default response (constant between 0.3 and 1.0µm)"); - AcquiCorrectionParametersType::WavelengthSpectralBandVectorType spectralDummy; + AcquiCorrectionParametersType::WavelengthSpectralBandVectorType spectralDummy = + AcquiCorrectionParametersType::InternalWavelengthSpectralBandVectorType::New(); spectralDummy->Clear(); for (unsigned int i = 0; i < inImage->GetNumberOfComponentsPerPixel(); ++i) { spectralDummy->PushBack(FilterFunctionValues::New()); } + m_paramAcqui->SetWavelengthSpectralBand(spectralDummy); } // Aeronet file diff --git a/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx index 718d79168034d56ea72abadfa55c8aead3f81e1c..819b035884da04e9caeffd2dad3f9f5673e06af9 100644 --- a/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbConvertCartoToGeoPoint.cxx @@ -117,8 +117,8 @@ private: otbAppLogINFO( << std::setprecision(10) << "Geographic Point (Long, Lat) : (" << geoPoint[0] << ", " << geoPoint[1] << ")" ); - SetParameterFloat( "long", geoPoint[0] ); - SetParameterFloat( "lat", geoPoint[1] ); + SetParameterFloat( "long",geoPoint[0] , false); + SetParameterFloat( "lat",geoPoint[1] , false); } }; diff --git a/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx index 3b3140b2b1c614000e4f4d193cc852e64974e4a0..be3f19a20f2c6524b8dd7e126103f4c3b60b3ceb 100644 --- a/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbConvertSensorToGeoPoint.cxx @@ -125,8 +125,8 @@ private: outputPoint = model->TransformPoint(point); // Set the value computed - SetParameterFloat("output.idx", outputPoint[0]); - SetParameterFloat("output.idy", outputPoint[1]); + SetParameterFloat("output.idx",outputPoint[0], false); + SetParameterFloat("output.idy",outputPoint[1], false); // Set the town and the neaerest city CoordinateToName::Pointer coord2name = CoordinateToName::New(); @@ -134,8 +134,8 @@ private: coord2name->SetLat(outputPoint[1]); coord2name->Evaluate(); - SetParameterString("output.town", coord2name->GetPlaceName()); - SetParameterString("output.country", coord2name->GetCountryName()); + SetParameterString("output.town", coord2name->GetPlaceName(), false); + SetParameterString("output.country", coord2name->GetCountryName(), false); } }; diff --git a/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx b/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx index be181ebb320b2b4fe0f97d48c0e836f42512e73d..f640e072e7441bc60430c89333640061364c7bae 100644 --- a/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx +++ b/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx @@ -60,7 +60,13 @@ private: SetDescription("Generate a RPC sensor model from a list of Ground Control Points."); SetDocName("Generate a RPC sensor model"); - SetDocLongDescription("This application generates a RPC sensor model from a list of Ground Control Points. At least 20 points are required for estimation wihtout elevation support, and 40 points for estimation with elevation support. Elevation support will be automatically deactivated if an insufficient amount of points is provided. The application can optionnaly output a file containing accuracy statistics for each point, and a vector file containing segments represening points residues. The map projection parameter allows defining a map projection in which the accuracy is evaluated."); + SetDocLongDescription( "This application generates a RPC sensor model from a list of Ground Control Points. " + "At least 20 points are required for estimation without elevation support, " + "and 40 points for estimation with elevation support. " + "Elevation support will be automatically deactivated if an insufficient amount of points is provided. " + "The application can optionally output a file containing accuracy statistics for each point," + " and a vector file containing segments representing points residues. " + "The map projection parameter allows defining a map projection in which the accuracy is evaluated." ); AddDocTag(Tags::Geometry); @@ -72,7 +78,7 @@ private: SetParameterDescription("outgeom","Geom file containing the generated RPC sensor model"); AddParameter(ParameterType_InputFilename,"inpoints","Input file containing tie points"); - SetParameterDescription("inpoints","Input file containing tie points. Points are stored in following format: col row lon lat. Line beginning with # are ignored."); + SetParameterDescription("inpoints","Input file containing tie points. Points are stored in following format: col row lon lat. Spaced by a space or tab character. Line beginning with # are ignored."); AddParameter(ParameterType_OutputFilename,"outstat","Output file containing output precision statistics"); SetParameterDescription("outstat","Output file containing the following info: ref_lon ref_lat elevation predicted_lon predicted_lat x_error_ref(meters) y_error_ref(meters) global_error_ref(meters) x_error(meters) y_error(meters) overall_error(meters)"); @@ -125,20 +131,8 @@ private: // Avoid commented lines or too short ones if (!line.empty() && line[0] != '#') { - // retrieve the x component - std::string::size_type pos = 0; - std::string::size_type nextpos = line.find_first_of("\t", pos); - x = atof(line.substr(pos, nextpos).c_str()); - pos = nextpos + 1; - nextpos = line.find_first_of("\t", pos); - y = atof(line.substr(pos, nextpos).c_str()); - pos = nextpos + 1; - nextpos = line.find_first_of("\t", pos); - lon = atof(line.substr(pos, nextpos).c_str()); - pos = nextpos + 1; - nextpos = line.find_first_of("\t", pos); - lat = atof(line.substr(pos, nextpos).c_str()); - + std::istringstream iss(line); + iss >> x >> y >> lon >> lat; z = otb::DEMHandler::Instance()->GetHeightAboveEllipsoid(lon,lat); otbAppLogINFO("Adding tie point x="<<x<<", y="<<y<<", z="<<z<<", lon="<<lon<<", lat="<<lat); diff --git a/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx b/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx index 5d782b3d17d1f5cfcf31613172cea5d2e42791c1..5a3286c4664ee2b0a87e17faa9b03fe604e62e54 100644 --- a/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx +++ b/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx @@ -170,7 +170,7 @@ private: AddParameter(ParameterType_Radius, "interpolator.bco.radius", "Radius for bicubic interpolation"); SetParameterDescription("interpolator.bco.radius","This parameter allows controlling the size of the bicubic interpolation filter. If the target pixel size is higher than the input pixel size, increasing this parameter will reduce aliasing artifacts."); SetDefaultParameterInt("interpolator.bco.radius", 2); - SetParameterString("interpolator","bco"); + SetParameterString("interpolator","bco", false); AddRAMParameter(); diff --git a/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx b/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx index e31337346082e978c70673002df5074802f12500..acfb9028faf1690c3f556225f45ec7ad6e04f188 100644 --- a/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx +++ b/Modules/Applications/AppProjection/app/otbObtainUTMZoneFromGeoPoint.cxx @@ -89,7 +89,7 @@ private: { int utmZone = otb::Utils::GetZoneFromGeoPoint(GetParameterFloat("lon"), GetParameterFloat("lat")); - SetParameterInt("utm", utmZone); + SetParameterInt("utm",utmZone, false); } }; diff --git a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx index e94168465dba16134a52a42901156dc430521b67..4e0b6b56f56c8d40c5e68503e3f844e84c1ed9e9 100644 --- a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx +++ b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx @@ -235,6 +235,11 @@ private: { if (HasValue("io.in")) { + + // Clear and reset the DEM Handler + otb::DEMHandler::Instance()->ClearDEMs(); + otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev"); + // input image FloatVectorImageType::Pointer inImage = GetParameterImage("io.in"); @@ -263,28 +268,28 @@ private: // Fill the Gui with the computed parameters if (!HasUserValue("outputs.sizex")) - SetParameterInt("outputs.sizex", genericRSEstimator->GetOutputSize()[0]); + SetParameterInt("outputs.sizex",genericRSEstimator->GetOutputSize()[0], false); if (!HasUserValue("outputs.sizey")) - SetParameterInt("outputs.sizey", genericRSEstimator->GetOutputSize()[1]); + SetParameterInt("outputs.sizey",genericRSEstimator->GetOutputSize()[1], false); if (!HasUserValue("outputs.spacingx")) - SetParameterFloat("outputs.spacingx", genericRSEstimator->GetOutputSpacing()[0]); + SetParameterFloat("outputs.spacingx",genericRSEstimator->GetOutputSpacing()[0], false); if (!HasUserValue("outputs.spacingy")) - SetParameterFloat("outputs.spacingy", genericRSEstimator->GetOutputSpacing()[1]); + SetParameterFloat("outputs.spacingy",genericRSEstimator->GetOutputSpacing()[1], false); if (!HasUserValue("outputs.ulx")) - SetParameterFloat("outputs.ulx", genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0]); + SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0], false); if (!HasUserValue("outputs.uly")) - SetParameterFloat("outputs.uly", genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1]); + SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1], false); if (!HasUserValue("outputs.lrx")) - SetParameterFloat("outputs.lrx", GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); if (!HasUserValue("outputs.lry")) - SetParameterFloat("outputs.lry", GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); // Handle the spacing and size field following the mode // chose by the user @@ -325,8 +330,8 @@ private: MandatoryOff("outputs.ortho"); // Update lower right - SetParameterFloat("outputs.lrx", GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); - SetParameterFloat("outputs.lry", GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); } break; case Mode_AutomaticSize: @@ -371,16 +376,16 @@ private: genericRSEstimator->Compute(); // Set the processed size relative to this forced spacing - SetParameterInt("outputs.sizex", genericRSEstimator->GetOutputSize()[0]); - SetParameterInt("outputs.sizey", genericRSEstimator->GetOutputSize()[1]); + SetParameterInt("outputs.sizex",genericRSEstimator->GetOutputSize()[0], false); + SetParameterInt("outputs.sizey",genericRSEstimator->GetOutputSize()[1], false); // Reset Origin to default - SetParameterFloat("outputs.ulx", genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0]); - SetParameterFloat("outputs.uly", genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1]); + SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0], false); + SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1], false); // Update lower right - SetParameterFloat("outputs.lrx", GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); - SetParameterFloat("outputs.lry", GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); } break; case Mode_AutomaticSpacing: @@ -425,16 +430,16 @@ private: genericRSEstimator->Compute(); // Set the processed spacing relative to this forced size - SetParameterFloat("outputs.spacingx", genericRSEstimator->GetOutputSpacing()[0]); - SetParameterFloat("outputs.spacingy", genericRSEstimator->GetOutputSpacing()[1]); + SetParameterFloat("outputs.spacingx",genericRSEstimator->GetOutputSpacing()[0], false); + SetParameterFloat("outputs.spacingy",genericRSEstimator->GetOutputSpacing()[1], false); // Reset Origin to default - SetParameterFloat("outputs.ulx", genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0]); - SetParameterFloat("outputs.uly", genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1]); + SetParameterFloat("outputs.ulx",genericRSEstimator->GetOutputOrigin()[0] - 0.5 * genericRSEstimator->GetOutputSpacing()[0], false); + SetParameterFloat("outputs.uly",genericRSEstimator->GetOutputOrigin()[1] - 0.5 * genericRSEstimator->GetOutputSpacing()[1], false); // Update lower right - SetParameterFloat("outputs.lrx", GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); - SetParameterFloat("outputs.lry", GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); } break; @@ -478,9 +483,9 @@ private: // Set the processed size relative to this forced spacing if (vcl_abs(spacing[0]) > 0.0) - SetParameterInt("outputs.sizex", static_cast<int>(vcl_ceil((GetParameterFloat("outputs.lrx")-GetParameterFloat("outputs.ulx"))/spacing[0]))); + SetParameterInt("outputs.sizex",static_cast<int>(vcl_ceil((GetParameterFloat("outputs.lrx")-GetParameterFloat("outputs.ulx"))/spacing[0])), false); if (vcl_abs(spacing[1]) > 0.0) - SetParameterInt("outputs.sizey", static_cast<int>(vcl_ceil((GetParameterFloat("outputs.lry")-GetParameterFloat("outputs.uly"))/spacing[1]))); + SetParameterInt("outputs.sizey",static_cast<int>(vcl_ceil((GetParameterFloat("outputs.lry")-GetParameterFloat("outputs.uly"))/spacing[1])), false); } break; case Mode_OrthoFit: @@ -530,11 +535,11 @@ private: SetParameterInt("outputs.sizey",size[1]); SetParameterFloat("outputs.spacingx",spacing[0]); SetParameterFloat("outputs.spacingy",spacing[1]); - SetParameterFloat("outputs.ulx", orig[0] - 0.5 * spacing[0]); - SetParameterFloat("outputs.uly", orig[1] - 0.5 * spacing[1]); + SetParameterFloat("outputs.ulx",orig[0] - 0.5 * spacing[0], false); + SetParameterFloat("outputs.uly",orig[1] - 0.5 * spacing[1], false); // Update lower right - SetParameterFloat("outputs.lrx", GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex"))); - SetParameterFloat("outputs.lry", GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey"))); + SetParameterFloat("outputs.lrx",GetParameterFloat("outputs.ulx") + GetParameterFloat("outputs.spacingx") * static_cast<double>(GetParameterInt("outputs.sizex")), false); + SetParameterFloat("outputs.lry",GetParameterFloat("outputs.uly") + GetParameterFloat("outputs.spacingy") * static_cast<double>(GetParameterInt("outputs.sizey")), false); } } break; @@ -580,11 +585,11 @@ private: // Use the smallest spacing (more precise grid) double optimalSpacing = std::min( vcl_abs(xgridspacing), vcl_abs(ygridspacing) ); otbAppLogINFO( "Setting grid spacing to " << optimalSpacing ); - SetParameterFloat("opt.gridspacing", optimalSpacing); + SetParameterFloat("opt.gridspacing",optimalSpacing, false); } else // if (m_OutputProjectionRef == otb::GeoInformationConversion::ToWKT(4326)) { - SetParameterFloat("opt.gridspacing", DefaultGridSpacingMeter); + SetParameterFloat("opt.gridspacing",DefaultGridSpacingMeter, false); } // if (m_OutputProjectionRef == otb::GeoInformationConversion::ToWKT(4326)) } // if (!HasUserValue("opt.gridspacing")) } // if (HasValue("io.in")) @@ -645,9 +650,6 @@ private: break; } - // Setup the DEM Handler - otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev"); - // If activated, generate RPC model if(IsParameterEnabled("opt.rpc")) { @@ -692,11 +694,16 @@ private: otbAppLogINFO("Using a deformation grid with a physical spacing of " << GetParameterFloat("opt.gridspacing")); + if ( GetParameterFloat( "opt.gridspacing" ) == 0 ) + { + otbAppLogFATAL( "opt.gridspacing must be different from 0 " ); + } + // Predict size of deformation grid - ResampleFilterType::SizeType deformationGridSize; - deformationGridSize[0] = static_cast<ResampleFilterType::SizeType::SizeValueType>(vcl_abs( + ResampleFilterType::SpacingType deformationGridSize; + deformationGridSize[0] = static_cast<ResampleFilterType::SpacingType::ValueType >(vcl_abs( GetParameterInt("outputs.sizex") * GetParameterFloat("outputs.spacingx") / GetParameterFloat("opt.gridspacing") )); - deformationGridSize[1] = static_cast<ResampleFilterType::SizeType::SizeValueType>(vcl_abs( + deformationGridSize[1] = static_cast<ResampleFilterType::SpacingType::ValueType>(vcl_abs( GetParameterInt("outputs.sizey") * GetParameterFloat("outputs.spacingy") / GetParameterFloat("opt.gridspacing") )); otbAppLogINFO("Using a deformation grid of size " << deformationGridSize); diff --git a/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx b/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx index f7ec69e7efcab2ef79c9b71065bf38df2c0e25ca..c3bd9e3df9b8055098256fa9d41573f68008c6e9 100644 --- a/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx +++ b/Modules/Applications/AppProjection/app/otbRigidTransformResample.cxx @@ -156,7 +156,7 @@ private: AddParameter(ParameterType_Radius, "interpolator.bco.radius", "Radius for bicubic interpolation"); SetParameterDescription("interpolator.bco.radius","This parameter allows controlling the size of the bicubic interpolation filter. If the target pixel size is higher than the input pixel size, increasing this parameter will reduce aliasing artifacts."); SetDefaultParameterInt("interpolator.bco.radius", 2); - SetParameterString("interpolator","bco"); + SetParameterString("interpolator","bco", false); // RAM available AddRAMParameter("ram"); diff --git a/Modules/Applications/AppProjection/app/otbSuperimpose.cxx b/Modules/Applications/AppProjection/app/otbSuperimpose.cxx index a2fc5e2549333380e9b2cca755f2cacf3f43eeea..71cb75003eb0f48450e4f0f07c69888f3af49153 100644 --- a/Modules/Applications/AppProjection/app/otbSuperimpose.cxx +++ b/Modules/Applications/AppProjection/app/otbSuperimpose.cxx @@ -104,6 +104,7 @@ private: AddParameter(ParameterType_Float, "lms", "Spacing of the deformation field"); SetParameterDescription("lms","Generate a coarser deformation field with the given spacing"); SetDefaultParameterFloat("lms", 4.); + DisableParameter("lms"); MandatoryOff("lms"); AddParameter(ParameterType_Float, "fv", "Fill Value"); @@ -158,7 +159,7 @@ private: if(!HasUserValue("mode") && HasValue("inr") && HasValue("inm") && otb::PleiadesPToXSAffineTransformCalculator::CanCompute(GetParameterImage("inr"),GetParameterImage("inm"))) { otbAppLogWARNING("Forcing PHR mode with PHR data. You need to add \"-mode default\" to force the default mode with PHR images."); - SetParameterString("mode","phr"); + SetParameterString("mode","phr", false); } } @@ -219,20 +220,24 @@ private: if(GetParameterString("mode")=="default") { + FloatVectorImageType::SpacingType defSpacing; if(IsParameterEnabled("lms")) { float defScalarSpacing = vcl_abs(GetParameterFloat("lms")); otbAppLogDEBUG("Generating coarse deformation field (spacing="<<defScalarSpacing<<")"); - FloatVectorImageType::SpacingType defSpacing; defSpacing[0] = defScalarSpacing; defSpacing[1] = defScalarSpacing; if (spacing[0]<0.0) defSpacing[0] *= -1.0; if (spacing[1]<0.0) defSpacing[1] *= -1.0; - - m_Resampler->SetDisplacementFieldSpacing(defSpacing); } + else + { + defSpacing[0]=10*spacing[0]; + defSpacing[1]=10*spacing[1]; + } + m_Resampler->SetDisplacementFieldSpacing(defSpacing); // Setup transform through projRef and Keywordlist m_Resampler->SetInputKeywordList(movingImage->GetImageKeywordlist()); diff --git a/Modules/Applications/AppProjection/test/CMakeLists.txt b/Modules/Applications/AppProjection/test/CMakeLists.txt index bff04845b68deeb44c0924471b7d10066d522319..81eea8e987ac15269fb0677ce0b80dedadfc892f 100644 --- a/Modules/Applications/AppProjection/test/CMakeLists.txt +++ b/Modules/Applications/AppProjection/test/CMakeLists.txt @@ -320,6 +320,7 @@ otb_test_application(NAME apTvPrSuperimpose -inm ${INPUTDATA}/QB_Toulouse_Ortho_XS_ROI_170x230.tif -elev.dem ${INPUTDATA}/DEM/srtm_directory -out ${TEMP}/apTvPrSuperimpose.tif int16 + -lms 4.0 VALID --compare-image ${EPSILON_7} ${BASELINE}/apTvPrSuperimpose.tif ${TEMP}/apTvPrSuperimpose.tif) diff --git a/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx index d8224dbf51a08fa5b72f858ee1d2df1820e07da5..14fce9949dad4ae4fee9ac0615ad5d2cfefd3103 100644 --- a/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbHooverCompareSegmentation.cxx @@ -292,10 +292,10 @@ private: m_InstanceFilter->Update(); - SetParameterFloat("rc", m_InstanceFilter->GetMeanRC()); - SetParameterFloat("rf", m_InstanceFilter->GetMeanRF()); - SetParameterFloat("ra", m_InstanceFilter->GetMeanRA()); - SetParameterFloat("rm", m_InstanceFilter->GetMeanRM()); + SetParameterFloat("rc",m_InstanceFilter->GetMeanRC(), false); + SetParameterFloat("rf",m_InstanceFilter->GetMeanRF(), false); + SetParameterFloat("ra",m_InstanceFilter->GetMeanRA(), false); + SetParameterFloat("rm",m_InstanceFilter->GetMeanRM(), false); } ImageToLabelMapFilterType::Pointer m_GTFilter; diff --git a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx index 4234666c4972d80a1e609f29ae873bd38af6c9be..6454b130e6cca255631841921a0c8e7dc1ec2d5a 100644 --- a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx @@ -305,11 +305,11 @@ private: AddParameter(ParameterType_String, "mode.vector.layername", "Layer name"); SetParameterDescription("mode.vector.layername", "Name of the layer in the vector file or database (default is Layer)."); - SetParameterString("mode.vector.layername", "layer"); + SetParameterString("mode.vector.layername", "layer", false); AddParameter(ParameterType_String, "mode.vector.fieldname", "Geometry index field name"); SetParameterDescription("mode.vector.fieldname", "Name of the field holding the geometry index in the output vector file or database."); - SetParameterString("mode.vector.fieldname", "DN"); + SetParameterString("mode.vector.fieldname", "DN", false); AddParameter(ParameterType_Int, "mode.vector.tilesize", "Tiles size"); SetParameterDescription("mode.vector.tilesize", diff --git a/Modules/Applications/AppStereo/app/otbStereoFramework.cxx b/Modules/Applications/AppStereo/app/otbStereoFramework.cxx index 1b18dc5b89b6cece6460f3c72f7774f239cc873b..e4c4e030e286d1754169ce702b5b9e65fd1c8dac 100644 --- a/Modules/Applications/AppStereo/app/otbStereoFramework.cxx +++ b/Modules/Applications/AppStereo/app/otbStereoFramework.cxx @@ -346,7 +346,7 @@ private: SetParameterDescription("input.co","List of index of couples im image list. Couples must be separated by a comma. (index start at 0). for example : 0 1,1 2 will process a first couple composed of the first and the second image in image list, then the first and the third image\n. note that images are handled by pairs." " if left empty couples are created from input index i.e. a first couple will be composed of the first and second image, a second couple with third and fourth image etc. (in this case image list must be even)."); MandatoryOff("input.co"); - SetParameterString("input.co",""); + SetParameterString("input.co","", false); DisableParameter("input.co"); AddParameter(ParameterType_Int, "input.channel", "Image channel used for the block matching"); @@ -363,7 +363,7 @@ private: // // Build the Output Map Projection // for custom map projection MapProjectionParametersHandler::AddMapProjectionParameters(this, "map"); - SetParameterString("map","wgs"); + SetParameterString("map","wgs", false); AddParameter(ParameterType_Float, "output.res","Output resolution"); SetParameterDescription("output.res","Spatial sampling distance of the output elevation : the cell size (in m)"); diff --git a/Modules/Applications/AppTest/test/CMakeLists.txt b/Modules/Applications/AppTest/test/CMakeLists.txt index 9a2d8705e6bcf16029961b6a972337c938d85f0b..ac83baa32c87ed5668d8771b47623689258e0f62 100644 --- a/Modules/Applications/AppTest/test/CMakeLists.txt +++ b/Modules/Applications/AppTest/test/CMakeLists.txt @@ -33,5 +33,5 @@ otb_test_application(NAME apTvTestApplicationOutputXML_All VALID --compare-ascii ${NOTOL} ${OTBAPP_BASELINE_FILES}/apTvTestApplicationOutputXML_All.xml ${TEMP}/apTvTestApplicationOutputXML_All.xml - --ignore-lines-with 7 letter.scale foo.txt world_boundaries foo.tif anaglyphInput1.tif anaglyphInput2.tif RADARSAT2_ALTONA_300_300_VV.tif + --ignore-lines-with 8 letter.scale foo.txt world_boundaries foo.tif anaglyphInput1.tif anaglyphInput2.tif RADARSAT2_ALTONA_300_300_VV.tif <version> ) diff --git a/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx b/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx index ee0f645a14cc9a958510d5afc28f9a17c5e05960..e007a457fd6a215d6ba3c1ddcca89122f1d0a98e 100644 --- a/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx +++ b/Modules/Applications/AppTextures/app/otbHaralickTextureExtraction.cxx @@ -87,6 +87,13 @@ SetParameterDescription("channel", "The selected channel index"); SetDefaultParameterInt("channel", 1); SetMinimumParameterIntValue("channel", 1); +AddParameter(ParameterType_Int, "step", "Computation step"); +SetParameterDescription("step", "Step (in pixels) to compute output texture values." + " The first computed pixel position is shifted by (step-1)/2 in both directions."); +SetDefaultParameterInt("step", 1); +SetMinimumParameterIntValue("step", 1); +MandatoryOff("step"); + AddRAMParameter(); AddParameter(ParameterType_Group, "parameters", "Texture feature parameters"); @@ -180,6 +187,12 @@ void DoExecute() ITK_OVERRIDE offset[0] = GetParameterInt("parameters.xoff"); offset[1] = GetParameterInt("parameters.yoff"); + RadiusType stepping; + stepping.Fill(GetParameterInt("step")); + + OffsetType stepOffset; + stepOffset.Fill((GetParameterInt("step") - 1) / 2); + m_ExtractorFilter = ExtractorFilterType::New(); m_ExtractorFilter->SetInput(inImage); m_ExtractorFilter->SetStartX(inImage->GetLargestPossibleRegion().GetIndex(0)); @@ -214,6 +227,8 @@ void DoExecute() ITK_OVERRIDE m_HarTexFilter->SetInputImageMinimum(GetParameterFloat("parameters.min")); m_HarTexFilter->SetInputImageMaximum(GetParameterFloat("parameters.max")); m_HarTexFilter->SetNumberOfBinsPerAxis(GetParameterInt("parameters.nbbin")); + m_HarTexFilter->SetSubsampleFactor(stepping); + m_HarTexFilter->SetSubsampleOffset(stepOffset); m_HarTexFilter->UpdateOutputInformation(); m_HarImageList->PushBack(m_HarTexFilter->GetEnergyOutput()); m_HarImageList->PushBack(m_HarTexFilter->GetEntropyOutput()); @@ -235,6 +250,8 @@ void DoExecute() ITK_OVERRIDE m_AdvTexFilter->SetInputImageMinimum(GetParameterFloat("parameters.min")); m_AdvTexFilter->SetInputImageMaximum(GetParameterFloat("parameters.max")); m_AdvTexFilter->SetNumberOfBinsPerAxis(GetParameterInt("parameters.nbbin")); + m_AdvTexFilter->SetSubsampleFactor(stepping); + m_AdvTexFilter->SetSubsampleOffset(stepOffset); m_AdvImageList->PushBack(m_AdvTexFilter->GetMeanOutput()); m_AdvImageList->PushBack(m_AdvTexFilter->GetVarianceOutput()); m_AdvImageList->PushBack(m_AdvTexFilter->GetDissimilarityOutput()); @@ -257,6 +274,8 @@ void DoExecute() ITK_OVERRIDE m_HigTexFilter->SetInputImageMinimum(GetParameterFloat("parameters.min")); m_HigTexFilter->SetInputImageMaximum(GetParameterFloat("parameters.max")); m_HigTexFilter->SetNumberOfBinsPerAxis(GetParameterInt("parameters.nbbin")); + m_HigTexFilter->SetSubsampleFactor(stepping); + m_HigTexFilter->SetSubsampleOffset(stepOffset); m_HigImageList->PushBack(m_HigTexFilter->GetShortRunEmphasisOutput()); m_HigImageList->PushBack(m_HigTexFilter->GetLongRunEmphasisOutput()); m_HigImageList->PushBack(m_HigTexFilter->GetGreyLevelNonuniformityOutput()); diff --git a/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx b/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx index 683a46b83422b4712005904939e2c95e3d4d35e5..1d3ebf78fa4aad74b62fb4389e843442c0cd774e 100644 --- a/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx +++ b/Modules/Applications/AppVectorDataTranslation/app/otbRasterization.cxx @@ -129,7 +129,7 @@ private: AddParameter(ParameterType_String,"mode.attribute.field","The attribute field to burn"); SetParameterDescription("mode.attribute.field","Name of the attribute field to burn"); - SetParameterString("mode.attribute.field","DN"); + SetParameterString("mode.attribute.field","DN", false); AddRAMParameter(); diff --git a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h index 813a4440bfebbf3b1dd0f2920cc013365a1c16a5..19435f45c38c0fbb3ef26fb2c124ab664990b68e 100644 --- a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h +++ b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.h @@ -105,7 +105,7 @@ private: StreamingWarpImageFilter(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented - // Assesment of the maximum displacement for streaming + // Assessment of the maximum displacement for streaming DisplacementValueType m_MaximumDisplacement; }; diff --git a/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.h b/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.h index 456cf4aca4b25fae98cf8bfa0bbf7bfa3d390ff9..42c1a5f0739946ca6fbdf6e6717333bf1af3ded5 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.h +++ b/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.h @@ -164,6 +164,18 @@ public: /** Get the input image maximum */ itkGetMacro(InputImageMaximum, InputPixelType); + /** Set the sub-sampling factor */ + itkSetMacro(SubsampleFactor, SizeType); + + /** Get the sub-sampling factor */ + itkGetMacro(SubsampleFactor, SizeType); + + /** Set the sub-sampling offset */ + itkSetMacro(SubsampleOffset, OffsetType); + + /** Get the sub-sampling offset */ + itkGetMacro(SubsampleOffset, OffsetType); + /** Get the mean output image */ OutputImageType * GetMeanOutput(); @@ -199,6 +211,8 @@ protected: ScalarImageToAdvancedTexturesFilter(); /** Destructor */ ~ScalarImageToAdvancedTexturesFilter() ITK_OVERRIDE; + /** Generate the output informations */ + void GenerateOutputInformation() ITK_OVERRIDE; /** Generate the input requested region */ void GenerateInputRequestedRegion() ITK_OVERRIDE; /** Before Parallel textures extraction */ @@ -231,6 +245,11 @@ private: /** Input image maximum */ InputPixelType m_InputImageMaximum; + /** Sub-sampling factor */ + SizeType m_SubsampleFactor; + + /** Sub-sampling offset */ + OffsetType m_SubsampleOffset; }; } // End namespace otb diff --git a/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.txx b/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.txx index e0463ab5c888f97a007d5ad62ba27d7a596dfbd1..80cf17d04104a6e9ee86abe698f36fd5b5dc8f5b 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.txx +++ b/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.txx @@ -37,6 +37,8 @@ ScalarImageToAdvancedTexturesFilter<TInputImage, TOutputImage> , m_NumberOfBinsPerAxis(8) , m_InputImageMinimum(0) , m_InputImageMaximum(255) +, m_SubsampleFactor() +, m_SubsampleOffset() { // There are 10 outputs corresponding to the 9 textures indices this->SetNumberOfRequiredOutputs(10); @@ -52,6 +54,9 @@ ScalarImageToAdvancedTexturesFilter<TInputImage, TOutputImage> this->SetNthOutput(7, OutputImageType::New()); this->SetNthOutput(8, OutputImageType::New()); this->SetNthOutput(9, OutputImageType::New()); + + this->m_SubsampleFactor.Fill(1); + this->m_SubsampleOffset.Fill(0); } template <class TInputImage, class TOutputImage> @@ -188,6 +193,38 @@ ScalarImageToAdvancedTexturesFilter<TInputImage, TOutputImage> return static_cast<OutputImageType *>(this->GetOutput(9)); } +template <class TInputImage, class TOutputImage> +void +ScalarImageToAdvancedTexturesFilter<TInputImage, TOutputImage> +::GenerateOutputInformation() +{ + // First, call superclass implementation + Superclass::GenerateOutputInformation(); + + // Compute output size, origin & spacing + InputRegionType inputRegion = this->GetInput()->GetLargestPossibleRegion(); + OutputRegionType outputRegion; + outputRegion.SetIndex(0,0); + outputRegion.SetIndex(1,0); + outputRegion.SetSize(0, 1 + (inputRegion.GetSize(0) - 1 - m_SubsampleOffset[0]) / m_SubsampleFactor[0]); + outputRegion.SetSize(1, 1 + (inputRegion.GetSize(1) - 1 - m_SubsampleOffset[1]) / m_SubsampleFactor[1]); + + typename OutputImageType::SpacingType outSpacing = this->GetInput()->GetSpacing(); + outSpacing[0] *= m_SubsampleFactor[0]; + outSpacing[1] *= m_SubsampleFactor[1]; + + typename OutputImageType::PointType outOrigin; + this->GetInput()->TransformIndexToPhysicalPoint(inputRegion.GetIndex()+m_SubsampleOffset,outOrigin); + + for (unsigned int i=0 ; i<this->GetNumberOfOutputs() ; i++) + { + OutputImagePointerType outputPtr = this->GetOutput(i); + outputPtr->SetLargestPossibleRegion(outputRegion); + outputPtr->SetOrigin(outOrigin); + outputPtr->SetSpacing(outSpacing); + } +} + template <class TInputImage, class TOutputImage> void ScalarImageToAdvancedTexturesFilter<TInputImage, TOutputImage> @@ -209,12 +246,19 @@ ScalarImageToAdvancedTexturesFilter<TInputImage, TOutputImage> // We use only the first output since requested regions for all outputs are enforced to be equal // by the default GenerateOutputRequestedRegiont() implementation OutputRegionType outputRequestedRegion = outputPtr->GetRequestedRegion(); + InputRegionType inputLargest = inputPtr->GetLargestPossibleRegion(); typename OutputRegionType::IndexType outputIndex = outputRequestedRegion.GetIndex(); typename OutputRegionType::SizeType outputSize = outputRequestedRegion.GetSize(); typename InputRegionType::IndexType inputIndex; typename InputRegionType::SizeType inputSize; + // Convert index and size to full grid + outputIndex[0] = outputIndex[0] * m_SubsampleFactor[0] + m_SubsampleOffset[0] + inputLargest.GetIndex(0); + outputIndex[1] = outputIndex[1] * m_SubsampleFactor[1] + m_SubsampleOffset[1] + inputLargest.GetIndex(1); + outputSize[0] = 1 + (outputSize[0] - 1) * m_SubsampleFactor[0]; + outputSize[1] = 1 + (outputSize[1] - 1) * m_SubsampleFactor[1]; + // First, apply offset for (unsigned int dim = 0; dim < InputImageType::ImageDimension; ++dim) { @@ -311,6 +355,8 @@ ScalarImageToAdvancedTexturesFilter<TInputImage, TOutputImage> const unsigned int histSize = m_NumberOfBinsPerAxis; const long unsigned int twiceHistSize = 2 * m_NumberOfBinsPerAxis; + InputRegionType inputLargest = inputPtr->GetLargestPossibleRegion(); + // Set-up progress reporting itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); @@ -330,11 +376,16 @@ ScalarImageToAdvancedTexturesFilter<TInputImage, TOutputImage> typename InputRegionType::IndexType inputIndex; typename InputRegionType::SizeType inputSize; + // Convert index to full grid + typename OutputImageType::IndexType outIndex; + // First, create an window for neighborhood iterator based on m_Radius // For example, if xradius and yradius is 2. window size is 5x5 (2 * radius + 1). for (unsigned int dim = 0; dim < InputImageType::ImageDimension; ++dim) { - inputIndex[dim] = varianceIt.GetIndex()[dim] - m_Radius[dim]; + outIndex[dim] = varianceIt.GetIndex()[dim] * m_SubsampleFactor[dim] + + m_SubsampleOffset[dim] + inputLargest.GetIndex(dim); + inputIndex[dim] = outIndex[dim] - m_Radius[dim]; inputSize[dim] = 2 * m_Radius[dim] + 1; } diff --git a/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.h b/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.h index 4879c7565a03a992d317e22b03d9e7b25e3bd184..781d69f80b028c6477dc0c03b6f95a709d504865 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.h +++ b/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.h @@ -148,6 +148,18 @@ public: itkSetMacro(FastCalculations, bool); itkBooleanMacro(FastCalculations); + /** Set the sub-sampling factor */ + itkSetMacro(SubsampleFactor, SizeType); + + /** Get the sub-sampling factor */ + itkGetMacro(SubsampleFactor, SizeType); + + /** Set the sub-sampling offset */ + itkSetMacro(SubsampleOffset, OffsetType); + + /** Get the sub-sampling offset */ + itkGetMacro(SubsampleOffset, OffsetType); + /** Get the Short Run Emphasis output image */ OutputImageType * GetShortRunEmphasisOutput(); @@ -186,6 +198,8 @@ protected: ScalarImageToHigherOrderTexturesFilter(); /** Destructor */ ~ScalarImageToHigherOrderTexturesFilter() ITK_OVERRIDE; + /** Generate the output informations */ + void GenerateOutputInformation() ITK_OVERRIDE; /** Generate the input requested region */ void GenerateInputRequestedRegion() ITK_OVERRIDE; /** Parallel textures extraction */ @@ -215,6 +229,12 @@ private: /** Fast calculation */ bool m_FastCalculations; + + /** Sub-sampling factor */ + SizeType m_SubsampleFactor; + + /** Sub-sampling offset */ + OffsetType m_SubsampleOffset; }; } // End namespace otb diff --git a/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.txx b/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.txx index 66d4a4b65a75403e3c66805807f7e0d475868452..fecb7ae6bbe4965cd2d7fc4f58e5f4e08d0900c9 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.txx +++ b/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.txx @@ -32,7 +32,9 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> m_NumberOfBinsPerAxis(8), m_InputImageMinimum(0), m_InputImageMaximum(255), - m_FastCalculations(false) + m_FastCalculations(false), + m_SubsampleFactor(), + m_SubsampleOffset() { // There are 11 outputs corresponding to the 8 textures indices this->SetNumberOfRequiredOutputs(10); @@ -71,6 +73,8 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> } this->SetOffsets( offsets ); + this->m_SubsampleFactor.Fill(1); + this->m_SubsampleOffset.Fill(0); } template <class TInputImage, class TOutputImage> @@ -231,6 +235,38 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> this->SetOffsets( offsetVector ); } +template <class TInputImage, class TOutputImage> +void +ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> +::GenerateOutputInformation() +{ + // First, call superclass implementation + Superclass::GenerateOutputInformation(); + + // Compute output size, origin & spacing + InputRegionType inputRegion = this->GetInput()->GetLargestPossibleRegion(); + OutputRegionType outputRegion; + outputRegion.SetIndex(0,0); + outputRegion.SetIndex(1,0); + outputRegion.SetSize(0, 1 + (inputRegion.GetSize(0) - 1 - m_SubsampleOffset[0]) / m_SubsampleFactor[0]); + outputRegion.SetSize(1, 1 + (inputRegion.GetSize(1) - 1 - m_SubsampleOffset[1]) / m_SubsampleFactor[1]); + + typename OutputImageType::SpacingType outSpacing = this->GetInput()->GetSpacing(); + outSpacing[0] *= m_SubsampleFactor[0]; + outSpacing[1] *= m_SubsampleFactor[1]; + + typename OutputImageType::PointType outOrigin; + this->GetInput()->TransformIndexToPhysicalPoint(inputRegion.GetIndex()+m_SubsampleOffset,outOrigin); + + for (unsigned int i=0 ; i<this->GetNumberOfOutputs() ; i++) + { + OutputImagePointerType outputPtr = this->GetOutput(i); + outputPtr->SetLargestPossibleRegion(outputRegion); + outputPtr->SetOrigin(outOrigin); + outputPtr->SetSpacing(outSpacing); + } +} + template <class TInputImage, class TOutputImage> void ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> @@ -252,7 +288,17 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> // We use only the first output since requested regions for all outputs are enforced to be equal // by the default GenerateOutputRequestedRegiont() implementation OutputRegionType outputRequestedRegion = outputPtr->GetRequestedRegion(); - InputRegionType inputRequestedRegion = outputRequestedRegion; + typename OutputRegionType::IndexType outputIndex = outputRequestedRegion.GetIndex(); + typename OutputRegionType::SizeType outputSize = outputRequestedRegion.GetSize(); + InputRegionType inputLargest = inputPtr->GetLargestPossibleRegion(); + + // Convert index and size to full grid + outputIndex[0] = outputIndex[0] * m_SubsampleFactor[0] + m_SubsampleOffset[0] + inputLargest.GetIndex(0); + outputIndex[1] = outputIndex[1] * m_SubsampleFactor[1] + m_SubsampleOffset[1] + inputLargest.GetIndex(1); + outputSize[0] = 1 + (outputSize[0] - 1) * m_SubsampleFactor[0]; + outputSize[1] = 1 + (outputSize[1] - 1) * m_SubsampleFactor[1]; + + InputRegionType inputRequestedRegion(outputIndex,outputSize); // Apply the radius inputRequestedRegion.PadByRadius(m_Radius); @@ -297,6 +343,8 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> inputPtr->TransformIndexToPhysicalPoint( outputImagesIterators[0].GetIndex() + m_Radius, bottomRightPoint ); double maxDistance = topLeftPoint.EuclideanDistanceTo(bottomRightPoint); + InputRegionType inputLargest = inputPtr->GetLargestPossibleRegion(); + // Set-up progress reporting itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); @@ -304,12 +352,17 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage> while ( !outputImagesIterators[0].IsAtEnd() ) { // Compute the region on which run-length matrix will be estimated - typename InputRegionType::IndexType inputIndex = outputImagesIterators[0].GetIndex() - m_Radius; + typename InputRegionType::IndexType inputIndex; typename InputRegionType::SizeType inputSize; - // First, apply offset + // Convert index to full grid + typename OutputImageType::IndexType outIndex; + for (unsigned int dim = 0; dim < InputImageType::ImageDimension; ++dim) { + outIndex[dim] = outputImagesIterators[0].GetIndex()[dim] * m_SubsampleFactor[dim] + + m_SubsampleOffset[dim] + inputLargest.GetIndex(dim); + inputIndex[dim] = outIndex[dim] - m_Radius[dim]; inputSize[dim] = 2 * m_Radius[dim] + 1; } diff --git a/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.h b/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.h index bb40e1766ccf609329504448ec1aae6174032434..a8387cd74d9fa32312b9f43c63c64f454dc2e7de 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.h +++ b/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.h @@ -166,6 +166,18 @@ public: /** Get the input image maximum */ itkGetMacro(InputImageMaximum, InputPixelType); + /** Set the sub-sampling factor */ + itkSetMacro(SubsampleFactor, SizeType); + + /** Get the sub-sampling factor */ + itkGetMacro(SubsampleFactor, SizeType); + + /** Set the sub-sampling offset */ + itkSetMacro(SubsampleOffset, OffsetType); + + /** Get the sub-sampling offset */ + itkGetMacro(SubsampleOffset, OffsetType); + /** Get the energy output image */ OutputImageType * GetEnergyOutput(); @@ -195,6 +207,8 @@ protected: ScalarImageToTexturesFilter(); /** Destructor */ ~ScalarImageToTexturesFilter() ITK_OVERRIDE; + /** Generate the output informations */ + void GenerateOutputInformation() ITK_OVERRIDE; /** Generate the input requested region */ void GenerateInputRequestedRegion() ITK_OVERRIDE; /** Before Parallel textures extraction */ @@ -230,6 +244,11 @@ private: //TODO: should we use constexpr? only c++11 and problem for msvc inline double GetPixelValueTolerance() const {return 0.0001; } + /** Sub-sampling factor */ + SizeType m_SubsampleFactor; + + /** Sub-sampling offset */ + OffsetType m_SubsampleOffset; }; } // End namespace otb diff --git a/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.txx b/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.txx index c67e3a9ebfd3d6d9a46f3cfc9955914ffcaa97a5..be489347843888f73133163f852140abd721eabd 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.txx +++ b/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.txx @@ -39,6 +39,8 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> , m_NumberOfBinsPerAxis(8) , m_InputImageMinimum(0) , m_InputImageMaximum(255) +, m_SubsampleFactor() +, m_SubsampleOffset() { // There are 8 outputs corresponding to the 8 textures indices this->SetNumberOfRequiredOutputs(8); @@ -52,6 +54,9 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> this->SetNthOutput(5, OutputImageType::New()); this->SetNthOutput(6, OutputImageType::New()); this->SetNthOutput(7, OutputImageType::New()); + + this->m_SubsampleFactor.Fill(1); + this->m_SubsampleOffset.Fill(0); } template <class TInputImage, class TOutputImage> @@ -163,6 +168,38 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> return static_cast<OutputImageType *>(this->GetOutput(7)); } +template <class TInputImage, class TOutputImage> +void +ScalarImageToTexturesFilter<TInputImage, TOutputImage> +::GenerateOutputInformation() +{ + // First, call superclass implementation + Superclass::GenerateOutputInformation(); + + // Compute output size, origin & spacing + InputRegionType inputRegion = this->GetInput()->GetLargestPossibleRegion(); + OutputRegionType outputRegion; + outputRegion.SetIndex(0,0); + outputRegion.SetIndex(1,0); + outputRegion.SetSize(0, 1 + (inputRegion.GetSize(0) - 1 - m_SubsampleOffset[0]) / m_SubsampleFactor[0]); + outputRegion.SetSize(1, 1 + (inputRegion.GetSize(1) - 1 - m_SubsampleOffset[1]) / m_SubsampleFactor[1]); + + typename OutputImageType::SpacingType outSpacing = this->GetInput()->GetSpacing(); + outSpacing[0] *= m_SubsampleFactor[0]; + outSpacing[1] *= m_SubsampleFactor[1]; + + typename OutputImageType::PointType outOrigin; + this->GetInput()->TransformIndexToPhysicalPoint(inputRegion.GetIndex()+m_SubsampleOffset,outOrigin); + + for (unsigned int i=0 ; i<this->GetNumberOfOutputs() ; i++) + { + OutputImagePointerType outputPtr = this->GetOutput(i); + outputPtr->SetLargestPossibleRegion(outputRegion); + outputPtr->SetOrigin(outOrigin); + outputPtr->SetSpacing(outSpacing); + } +} + template <class TInputImage, class TOutputImage> void ScalarImageToTexturesFilter<TInputImage, TOutputImage> @@ -189,6 +226,13 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> typename OutputRegionType::SizeType outputSize = outputRequestedRegion.GetSize(); typename InputRegionType::IndexType inputIndex; typename InputRegionType::SizeType inputSize; + InputRegionType inputLargest = inputPtr->GetLargestPossibleRegion(); + + // Convert index and size to full grid + outputIndex[0] = outputIndex[0] * m_SubsampleFactor[0] + m_SubsampleOffset[0] + inputLargest.GetIndex(0); + outputIndex[1] = outputIndex[1] * m_SubsampleFactor[1] + m_SubsampleOffset[1] + inputLargest.GetIndex(1); + outputSize[0] = 1 + (outputSize[0] - 1) * m_SubsampleFactor[0]; + outputSize[1] = 1 + (outputSize[1] - 1) * m_SubsampleFactor[1]; // First, apply offset for (unsigned int dim = 0; dim < InputImageType::ImageDimension; ++dim) @@ -278,6 +322,8 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> const double log2 = vcl_log(2.0); + InputRegionType inputLargest = inputPtr->GetLargestPossibleRegion(); + // Set-up progress reporting itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); @@ -295,11 +341,15 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> typename InputRegionType::IndexType inputIndex; typename InputRegionType::SizeType inputSize; + // Convert index to full grid + typename OutputImageType::IndexType outIndex; + // First, create an window for neighborhood iterator based on m_Radius // For example, if xradius and yradius is 2. window size is 5x5 (2 * radius + 1). for (unsigned int dim = 0; dim < InputImageType::ImageDimension; ++dim) { - inputIndex[dim] = energyIt.GetIndex()[dim] - m_Radius[dim]; + outIndex[dim] = energyIt.GetIndex()[dim] * m_SubsampleFactor[dim] + m_SubsampleOffset[dim] + inputLargest.GetIndex(dim); + inputIndex[dim] = outIndex[dim] - m_Radius[dim]; inputSize[dim] = 2 * m_Radius[dim] + 1; } diff --git a/Modules/Filtering/ImageManipulation/include/otbVectorRescaleIntensityImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbVectorRescaleIntensityImageFilter.h index 150b4166c9043b87bd200e880f8726105a8fdf6e..f7e5aa53b0f7ea7ff03a13479ab594339b81c0b5 100644 --- a/Modules/Filtering/ImageManipulation/include/otbVectorRescaleIntensityImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbVectorRescaleIntensityImageFilter.h @@ -198,10 +198,15 @@ private: * * This filter rescales each band to match the [OutputMinimum, OutputMaximum] range. * In order to avoid odd values to alter the intensity extent, one can set a clamp percentage. + * The clamp percentage is set to 0.01 by default. * * Values lower than the first quantile of this percentage are set to the OutputMinimum. * Values upper than the last quantile of this percentage are set to the OutputMaximum. * + * This filter differ from itk::VectorRescaleIntensityImageFilter. + * Instead of setting only the OutputMaximumMagnitude, you can set the minimum and maximum values for the input and output images. + * There is also the possibilty to set a Gamma value and change the clamp percentage. + * * \ingroup IntensityImageFilters * \ingroup MultiThreaded * diff --git a/Modules/Filtering/MathParserX/include/otbParserX.h b/Modules/Filtering/MathParserX/include/otbParserX.h index 30d571d76b5c11f72f6bfea767384cd7e478bb17..55eecfa431adb46e1e6a67c03e6109b863bafe7f 100644 --- a/Modules/Filtering/MathParserX/include/otbParserX.h +++ b/Modules/Filtering/MathParserX/include/otbParserX.h @@ -24,9 +24,15 @@ #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc++11-extensions" + +/* Apple's 3.6.0 based clang doesn't support -Winconsistent-missing-override */ +#if !defined(__apple_build_version__) || __apple_build_version__ >= 7000053 #pragma clang diagnostic ignored "-Winconsistent-missing-override" +#endif + #include "mpParser.h" -#pragma GCC diagnostic pop +#pragma clang diagnostic pop + #else #include "mpParser.h" #endif diff --git a/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.h b/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.h index 93042076a9bcdecdc18d91177c05069a03970358..7b6414666690f457da39333505aa215061ca7873 100644 --- a/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.h +++ b/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.h @@ -102,7 +102,6 @@ protected: SubsampleImageFilter () { m_SubsampleFactor.Fill(1); - //this->SetNumberOfThreads(1); } ~SubsampleImageFilter() ITK_OVERRIDE {} diff --git a/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.txx b/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.txx index 1848cc66b5b054d97f353da298315bb2798e2191..7e9545261dcdb448a0ccf7cc8d9b4072f4890a54 100644 --- a/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.txx +++ b/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.txx @@ -83,7 +83,7 @@ SubsampleImageFilter<TInputImage, TOutputImage, TDirectionOfTransformation> { Superclass::CallCopyOutputRegionToInputRegion(destRegion, srcRegion); - if (static_cast<int>(DirectionOfTransformation) == Wavelet::INVERSE) + if (DirectionOfTransformation == Wavelet::INVERSE) { typename OutputImageRegionType::IndexType srcIndex = srcRegion.GetIndex(); typename OutputImageRegionType::SizeType srcSize = srcRegion.GetSize(); @@ -112,7 +112,7 @@ SubsampleImageFilter<TInputImage, TOutputImage, TDirectionOfTransformation> { Superclass::CallCopyInputRegionToOutputRegion(destRegion, srcRegion); - if (static_cast<int>(DirectionOfTransformation) == Wavelet::INVERSE) + if (DirectionOfTransformation == Wavelet::INVERSE) { typename InputImageRegionType::IndexType srcIndex = srcRegion.GetIndex(); typename InputImageRegionType::SizeType srcSize = srcRegion.GetSize(); @@ -161,8 +161,7 @@ SubsampleImageFilter<TInputImage, TOutputImage, TDirectionOfTransformation> SubsampledImageRegionConstIterator<InputImageType> inputIter (this->GetInput(), inputRegionForThread); - if (static_cast<int>(itkGetStaticConstMacro(DirectionOfTransformation)) - == static_cast<int>(Wavelet::FORWARD)) + if (DirectionOfTransformation == Wavelet::FORWARD) { inputIter.SetSubsampleFactor(GetSubsampleFactor()); inputIter.GoToBegin(); diff --git a/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.h b/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.h index 0089018a601933d6ced0181490a8a9581f627b9f..cc454f0faaf6dc3df0ebe1ac8beee74ba0cd62c3 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.h @@ -399,6 +399,11 @@ protected: WaveletFilterBank(); ~WaveletFilterBank() ITK_OVERRIDE {} + void VerifyInputInformation() ITK_OVERRIDE + { + + } + /** GenerateOutputInformation * Set the size of the output image depending on the decimation factor * Copy information from the input image if existing. diff --git a/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.txx b/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.txx index b03e0fbb8b1eb3765edf96581489f18be4693dd6..7e7d238b937d6f4d6e118240425d75ea8792a34e 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.txx +++ b/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.txx @@ -27,9 +27,6 @@ #include "itkPeriodicBoundaryCondition.h" -// FIXME -#define __myDebug__ 0 - namespace otb { /** @@ -54,7 +51,6 @@ WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD> m_UpSampleFilterFactor = 0; m_SubsampleImageFactor = 1; - //this->SetNumberOfThreads(1); } template <class TInputImage, class TOutputImage, class TWaveletOperator> @@ -66,11 +62,9 @@ WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD> if (GetSubsampleImageFactor() == 1) return; -#if __myDebug__ otbGenericMsgDebugMacro(<< " down sampling output regions by a factor of " << GetSubsampleImageFactor()); otbGenericMsgDebugMacro(<< "initial region " << this->GetInput()->GetLargestPossibleRegion().GetSize()[0] << "," << this->GetInput()->GetLargestPossibleRegion().GetSize()[1]); -#endif OutputImageRegionType newRegion; this->CallCopyInputRegionToOutputRegion(newRegion, this->GetInput()->GetLargestPossibleRegion()); @@ -80,9 +74,8 @@ WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD> this->GetOutput(i)->SetRegions(newRegion); } -#if __myDebug__ otbGenericMsgDebugMacro(<< "new region output " << newRegion.GetSize()[0] << "," << newRegion.GetSize()[1]); -#endif + } template <class TInputImage, class TOutputImage, class TWaveletOperator> @@ -185,12 +178,13 @@ WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::FORWARD> this->CallCopyInputRegionToOutputRegion(InputImageDimension - 1 - direction, smallerRegion, largerRegion); - for (unsigned int i = 0; i < m_InternalImages[direction].size(); ++i) + const unsigned int d = InputImageDimension - 2 - direction; + for (unsigned int i = 0; i < m_InternalImages[d].size(); ++i) { - m_InternalImages[InputImageDimension - 2 - direction][i] = OutputImageType::New(); - m_InternalImages[InputImageDimension - 2 - direction][i]->SetRegions(smallerRegion); - m_InternalImages[InputImageDimension - 2 - direction][i]->Allocate(); - m_InternalImages[InputImageDimension - 2 - direction][i]->FillBuffer(0); + m_InternalImages[d][i] = OutputImageType::New(); + m_InternalImages[d][i]->SetRegions(smallerRegion); + m_InternalImages[d][i]->Allocate(); + m_InternalImages[d][i]->FillBuffer(0); } largerRegion = smallerRegion; @@ -642,21 +636,18 @@ WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE> } } -#if __myDebug__ otbGenericMsgDebugMacro(<< " up sampling output regions by a factor of " << GetSubsampleImageFactor()); otbGenericMsgDebugMacro(<< "initial region " << this->GetInput(0)->GetLargestPossibleRegion().GetSize()[0] << "," << this->GetInput(0)->GetLargestPossibleRegion().GetSize()[1]); -#endif OutputImageRegionType newRegion; this->CallCopyInputRegionToOutputRegion(newRegion, this->GetInput(0)->GetLargestPossibleRegion()); this->GetOutput()->SetRegions(newRegion); -#if __myDebug__ otbGenericMsgDebugMacro(<< "new region output " << newRegion.GetSize()[0] << "," << newRegion.GetSize()[1]); -#endif + } template <class TInputImage, class TOutputImage, class TWaveletOperator> @@ -1178,7 +1169,7 @@ WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE> typename FilterType::Pointer overSampledLowPass = FilterType::New(); overSampledLowPass->SetInput(cropedLowPass); overSampledLowPass->SetSubsampleFactor(delta); - overSampledLowPass->SetNumberOfThreads(1); + overSampledLowPass->SetNumberOfThreads(1); overSampledLowPass->Update(); InputImagePointerType cropedHighPass = InputImageType::New(); @@ -1197,7 +1188,7 @@ WaveletFilterBank<TInputImage, TOutputImage, TWaveletOperator, Wavelet::INVERSE> typename FilterType::Pointer overSampledHighPass = FilterType::New(); overSampledHighPass->SetInput(cropedHighPass); overSampledHighPass->SetSubsampleFactor(delta); - overSampledHighPass->SetNumberOfThreads(1); + overSampledHighPass->SetNumberOfThreads(1); overSampledHighPass->Update(); InnerProductType innerProduct; diff --git a/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..76ac1af497f60a866647e34d72d105556702e846 --- /dev/null +++ b/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.h @@ -0,0 +1,112 @@ +/*========================================================================= + + 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 otbWaveletImageFilter_h +#define otbWaveletImageFilter_h + +#include "otbWaveletOperator.h" +#include "otbWaveletFilterBank.h" +#include "otbWaveletTransform.h" +#include "otbWaveletsBandsListToWaveletsSynopsisImageFilter.h" + +namespace otb { + +/** \class WaveletImageFilter + * \brief + * This filter performs wavelet forward transform. + * It takes three template arguments: Input, Output and WaveletOperator + * This filter is not streamed. + * + * \ingroup OTBWavelet + * \sa WaveletInverseImageFilter + * \sa WaveletsBandsListToWaveletsSynopsisImageFilter + * \sa WaveletGenerator + */ +template < class TInputImage, + class TOutputImage, + Wavelet::Wavelet TMotherWaveletOperator > +class WaveletImageFilter : + public itk::ImageToImageFilter< TInputImage, TOutputImage > +{ +public: + /** Standard class typedefs. */ + typedef TInputImage InputImageType; + typedef TOutputImage OutputImageType; + + itkStaticConstMacro( ImageDimension, unsigned int, InputImageType::ImageDimension ); + itkStaticConstMacro( MotherWaveletOperator, short, TMotherWaveletOperator ); + itkStaticConstMacro( DirectionOfTransformation, short, otb::Wavelet::FORWARD ); + + typedef WaveletImageFilter<InputImageType,OutputImageType, TMotherWaveletOperator> Self; + typedef itk::ImageToImageFilter<InputImageType, OutputImageType> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef typename InputImageType::PixelType InputPixelType; + + typedef otb::WaveletOperator< TMotherWaveletOperator, otb::Wavelet::FORWARD, InputPixelType, ImageDimension > + WaveletOperatorType; + typedef otb::WaveletFilterBank< InputImageType, InputImageType, WaveletOperatorType, otb::Wavelet::FORWARD > + FilterBankType; + typedef otb::WaveletTransform< InputImageType, InputImageType, FilterBankType, otb::Wavelet::FORWARD > + WaveletTransformFilterType; + typedef typename WaveletTransformFilterType::Pointer + WaveletTransformFilterPointerType; + + typedef typename WaveletTransformFilterType::OutputImageListType + WaveletTransformFilterOutputImageListType; + typedef otb::WaveletsBandsListToWaveletsSynopsisImageFilter<WaveletTransformFilterOutputImageListType, OutputImageType> + WaveletBandsListToWaveletsSynopsisImageFilterType; + typedef typename WaveletBandsListToWaveletsSynopsisImageFilterType::Pointer + WaveletBandsListToWaveletsSynopsisImageFilterPointerType; + + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(WaveletImageFilter, ImageToImageFilter); + + itkGetMacro(NumberOfDecompositions,unsigned int); + itkSetMacro(NumberOfDecompositions,unsigned int); + +protected: + WaveletImageFilter(); + virtual ~WaveletImageFilter(); + + virtual void GenerateInputRequestedRegion(); + + virtual void GenerateData(); + + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + WaveletImageFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + WaveletTransformFilterPointerType m_WaveletTransform; + WaveletBandsListToWaveletsSynopsisImageFilterPointerType m_WaveletBandsListToWaveletsSynopsis; + unsigned int m_NumberOfDecompositions; +}; + +} + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbWaveletImageFilter.txx" +#endif + +#endif diff --git a/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.txx b/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..290012331aae257df2117f189fa51f0b591b71dc --- /dev/null +++ b/Modules/Filtering/Wavelet/include/otbWaveletImageFilter.txx @@ -0,0 +1,95 @@ +/*========================================================================= + + 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 otbWaveletImageFilter_txx +#define otbWaveletImageFilter_txx + +#include "otbWaveletImageFilter.h" + +namespace otb +{ +/** Constructor */ +template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator> +WaveletImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator> +::WaveletImageFilter() : m_NumberOfDecompositions(2) +{ + m_WaveletTransform = WaveletTransformFilterType::New(); + m_WaveletTransform->SetSubsampleImageFactor(2); + + m_WaveletBandsListToWaveletsSynopsis = WaveletBandsListToWaveletsSynopsisImageFilterType::New(); + m_WaveletBandsListToWaveletsSynopsis->SetInput( m_WaveletTransform->GetOutput() ); +} + +/** Destructor */ +template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator> +WaveletImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator> +::~WaveletImageFilter() +{ +} + +/** + * GenerateInputRequestedRegion + */ +template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator> +void +WaveletImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator> +::GenerateInputRequestedRegion(void) +{ + // call the superclass' implementation of this method + Superclass::GenerateInputRequestedRegion(); + + // get pointers to the inputs + typename InputImageType::Pointer input = + const_cast<InputImageType *> (this->GetInput()); + + if ( !input ) + { + return; + } + + input->SetRequestedRegionToLargestPossibleRegion(); +} + +/** + * Main computation method + */ +template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator> +void +WaveletImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator> +::GenerateData() +{ + m_WaveletTransform->SetInput( this->GetInput() ); + m_WaveletTransform->SetNumberOfDecompositions( m_NumberOfDecompositions ); + m_WaveletBandsListToWaveletsSynopsis->GraftOutput( this->GetOutput() ); + m_WaveletBandsListToWaveletsSynopsis->Update(); + this->GraftOutput( m_WaveletBandsListToWaveletsSynopsis->GetOutput() ); +} + +/** + * PrintSelf Method + */ +template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator> +void +WaveletImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + +} + +#endif diff --git a/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..16eb9d414ecf528fc4a412453d64865b8bc7f9ff --- /dev/null +++ b/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.h @@ -0,0 +1,113 @@ +/*========================================================================= + + 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 otbWaveletInverseImageFilter_h +#define otbWaveletInverseImageFilter_h + +#include "otbWaveletOperator.h" +#include "otbWaveletFilterBank.h" +#include "otbWaveletTransform.h" +#include "otbWaveletsSynopsisImageToWaveletsBandsListFilter.h" + +namespace otb { + +/** \class WaveletInverseImageFilter + * \brief + * This filter performs wavelet inverse transform. + * It takes three template arguments: Input, Output and WaveletOperator + * This filter is not streamed. + * \ingroup OTBWavelet + * \sa WaveletImageFilter + * \sa WaveletsSynopsisImageToWaveletsBandsListFilter + * \sa WaveletGenerator + */ +template < class TInputImage, + class TOutputImage, + Wavelet::Wavelet TMotherWaveletOperator > +class WaveletInverseImageFilter : + public itk::ImageToImageFilter< TInputImage, TOutputImage > +{ +public: + /** Standard class typedefs. */ + typedef TInputImage InputImageType; + typedef TOutputImage OutputImageType; + + itkStaticConstMacro( ImageDimension, unsigned int, InputImageType::ImageDimension ); + itkStaticConstMacro( MotherWaveletOperator, short, TMotherWaveletOperator ); + itkStaticConstMacro( DirectionOfTransformation, short , otb::Wavelet::FORWARD ); + + typedef WaveletInverseImageFilter<InputImageType,OutputImageType, TMotherWaveletOperator> Self; + typedef itk::ImageToImageFilter<InputImageType, OutputImageType> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef typename InputImageType::PixelType InputPixelType; + typedef typename OutputImageType::PixelType OutputPixelType; + + typedef otb::WaveletOperator< TMotherWaveletOperator, otb::Wavelet::INVERSE, OutputPixelType, ImageDimension > + WaveletOperatorType; + typedef otb::WaveletFilterBank< OutputImageType, OutputImageType, WaveletOperatorType, otb::Wavelet::INVERSE > + FilterBankType; + typedef otb::WaveletTransform< OutputImageType, OutputImageType, FilterBankType, otb::Wavelet::INVERSE > + WaveletInverseTransformFilterType; + typedef typename WaveletInverseTransformFilterType::Pointer + WaveletInverseTransformFilterPointerType; + + typedef otb::WaveletsSynopsisImageToWaveletsBandsListFilter<InputImageType, typename WaveletInverseTransformFilterType::InputImageListType> + WaveletsSynopsisImageToWaveletsBandsListFilterType; + typedef typename WaveletsSynopsisImageToWaveletsBandsListFilterType::Pointer + WaveletsSynopsisImageToWaveletsBandsListFilterPointerType; + + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(WaveletInverseImageFilter, ImageToImageFilter); + + itkGetMacro(NumberOfDecompositions,unsigned int); + itkSetMacro(NumberOfDecompositions,unsigned int); + + /** If the filter is modified, the internal filters need to be modified too */ + virtual void Modified() const; + +protected: + WaveletInverseImageFilter(); + virtual ~WaveletInverseImageFilter(); + + virtual void GenerateInputRequestedRegion(); + + virtual void GenerateData(); + + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + WaveletInverseImageFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + WaveletsSynopsisImageToWaveletsBandsListFilterPointerType m_SynopsisImageToWaveletsBandsList; + WaveletInverseTransformFilterPointerType m_WaveletTransform; + unsigned int m_NumberOfDecompositions; +}; + +} + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbWaveletInverseImageFilter.txx" +#endif + +#endif diff --git a/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.txx b/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..58ac44df317b0bb86475b370aa3dae5b9ef6214e --- /dev/null +++ b/Modules/Filtering/Wavelet/include/otbWaveletInverseImageFilter.txx @@ -0,0 +1,109 @@ +/*========================================================================= + + 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 __otbWaveletInverseImageFilter_txx +#define __otbWaveletInverseImageFilter_txx + +#include "otbWaveletInverseImageFilter.h" + +namespace otb +{ +/** Constructor */ +template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator> +WaveletInverseImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator> +::WaveletInverseImageFilter() : m_NumberOfDecompositions(2) +{ + m_SynopsisImageToWaveletsBandsList = WaveletsSynopsisImageToWaveletsBandsListFilterType::New(); + m_SynopsisImageToWaveletsBandsList->SetDecimationRatio(2); + + m_WaveletTransform = WaveletInverseTransformFilterType::New(); + m_WaveletTransform->SetSubsampleImageFactor(2); + m_WaveletTransform->SetInput( m_SynopsisImageToWaveletsBandsList->GetOutput() ); + +} + +/** Destructor */ +template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator> +WaveletInverseImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator> +::~WaveletInverseImageFilter() +{ +} + +/** Destructor */ +template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator> +void +WaveletInverseImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator> +::Modified() const +{ + Superclass::Modified(); + m_SynopsisImageToWaveletsBandsList->Modified(); + m_WaveletTransform->Modified(); +} + +/** + * GenerateInputRequestedRegion + */ +template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator> +void +WaveletInverseImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator> +::GenerateInputRequestedRegion(void) +{ + // call the superclass' implementation of this method + Superclass::GenerateInputRequestedRegion(); + + // get pointers to the inputs + typename InputImageType::Pointer input = + const_cast<InputImageType *> (this->GetInput()); + + if ( !input ) + { + return; + } + + input->SetRequestedRegionToLargestPossibleRegion(); +} + +/** + * Main computation method + */ +template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator> +void +WaveletInverseImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator> +::GenerateData() +{ + m_SynopsisImageToWaveletsBandsList->SetInput( this->GetInput() ); + m_SynopsisImageToWaveletsBandsList->SetNumberOfLevels( m_NumberOfDecompositions ); + + m_WaveletTransform->GraftOutput( this->GetOutput() ); + m_WaveletTransform->Update(); + this->GraftOutput( m_WaveletTransform->GetOutput() ); +} + +/** + * PrintSelf Method + */ +template <class TInputImage, class TOutputImage, Wavelet::Wavelet TMotherWaveletOperator> +void +WaveletInverseImageFilter<TInputImage, TOutputImage, TMotherWaveletOperator> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + +} + +#endif diff --git a/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..9e22f84968e16a1d48c02f674dc5e544e150be98 --- /dev/null +++ b/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h @@ -0,0 +1,103 @@ +/*========================================================================= + + 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 otbWaveletsBandsListToWaveletsSynopsisImageFilter_h +#define otbWaveletsBandsListToWaveletsSynopsisImageFilter_h + + +#include "otbImageListToImageFilter.h" + +namespace otb +{ + +/** \class WaveletsBandsListToWaveletsSynopsisImageFilter + * \brief Converts a list of wavelets bands to the traditional multi-resolution wavelets view + * + * The decimation ratio is taken into account. + * + * \ingroup OTBWavelet + * \sa WaveletsSynopsisImageToWaveletsBandsListFilter + */ + +template <class TImageList, class TImage> +class ITK_EXPORT WaveletsBandsListToWaveletsSynopsisImageFilter + : public ImageListToImageFilter<typename TImageList::ImageType, TImage> +{ +public: + /** Standard typedefs */ + typedef WaveletsBandsListToWaveletsSynopsisImageFilter Self; + typedef ImageListToImageFilter< + typename TImageList::ImageType,TImage> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Type macro */ + itkNewMacro(Self); + + /** Useful typedefs */ + typedef TImageList InputImageListType; + typedef typename InputImageListType::ImageType InputImageType; + typedef TImage OutputImageType; + typedef typename OutputImageType::RegionType RegionType; + + /** Creation through object factory macro */ + itkTypeMacro(WaveletsBandsListToWaveletsSynopsisImageFilter,ImageToImageListFilter); + + /** Set the decimation ratio */ + itkSetMacro(DecimationRatio,unsigned int); + + /** Get the decimation ratio */ + itkGetMacro(DecimationRatio,unsigned int); + +protected: + /** Main computation method */ + virtual void ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId); + + /** GenerateOutputInformation + * Set the number of bands of the output. + * Copy informations from the first image of the list if existing. + **/ + virtual void GenerateOutputInformation(void); + + /** + * GenerateInputRequestedRegion + * Set the requested region of each image in the list. + */ + virtual void GenerateInputRequestedRegion(void); + + /** Constructor */ + WaveletsBandsListToWaveletsSynopsisImageFilter(); + + /** Destructor */ + virtual ~WaveletsBandsListToWaveletsSynopsisImageFilter(); + + /**PrintSelf method */ + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + WaveletsBandsListToWaveletsSynopsisImageFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + /** The decimation ratio used in the decomposition */ + unsigned int m_DecimationRatio; +}; +}// End namespace otb +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbWaveletsBandsListToWaveletsSynopsisImageFilter.txx" +#endif + +#endif diff --git a/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.txx b/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..ea21c6c2a968d5b698fa0c18d8dda09f5e12e7f5 --- /dev/null +++ b/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.txx @@ -0,0 +1,222 @@ +/*========================================================================= + + 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 otbWaveletsBandsListToWaveletsSynopsisImageFilter_txx +#define otbWaveletsBandsListToWaveletsSynopsisImageFilter_txx + +#include "otbWaveletsBandsListToWaveletsSynopsisImageFilter.h" +#include "itkImageRegionIterator.h" +#include "itkImageRegionConstIterator.h" +#include "otbMacro.h" +#include "itkProgressReporter.h" + +namespace otb +{ +/** Constructor */ +template <class TImageList, class TImage> +WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList,TImage> +::WaveletsBandsListToWaveletsSynopsisImageFilter() : m_DecimationRatio(2) +{} + +/** Destructor */ +template <class TImageList, class TImage> +WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList,TImage> +::~WaveletsBandsListToWaveletsSynopsisImageFilter() +{} + +/** + * GenerateOutputInformation + */ +template <class TImageList, class TImage> +void +WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList,TImage> +::GenerateOutputInformation(void) +{ + // We must set the size of the output image to be twice the size of the last image + // of the image list, which is the first band. + if(this->GetOutput()) + { + if (this->GetInput()->Size()>0) + { + // Retrieve the largest band + typename InputImageType::Pointer lastBand = this->GetInput()->Back(); + + // Retrieve the region of the largest band + RegionType largestBandRegion = lastBand->GetLargestPossibleRegion(); + + // Retrieve the size of the largest region + typename RegionType::SizeType outputSize = largestBandRegion.GetSize(); + + // Multiply this size by two + outputSize[0]*=m_DecimationRatio; + outputSize[1]*=m_DecimationRatio; + + // Build the output region + RegionType outputLargestRegion; + outputLargestRegion.SetSize(outputSize); + + // Copy information to the output image + this->GetOutput()->CopyInformation(lastBand); + this->GetOutput()->SetLargestPossibleRegion(outputLargestRegion); + + } + } +} +/** + * GenerateInputRequestedRegion + */ +template <class TImageList, class TImage> +void +WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList,TImage> +::GenerateInputRequestedRegion(void) +{ + typename InputImageListType::Pointer inputPtr = this->GetInput(); + typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin(); + while (inputListIt!=inputPtr->End()) + { + inputListIt.Get()->SetRequestedRegionToLargestPossibleRegion(); + ++inputListIt; + } +} + +/** + * Main computation method + */ +template <class TImageList, class TImage> +void +WaveletsBandsListToWaveletsSynopsisImageFilter<TImageList,TImage> +::ThreadedGenerateData(const RegionType & outputRegionForThread, + itk::ThreadIdType threadId) +{ + // Retrieve input and output pointers + typename InputImageListType::Pointer inputPtr = this->GetInput(); + typename OutputImageType::Pointer outputPtr = this->GetOutput(); + + // Set up progress reporting + itk::ProgressReporter progress(this, + threadId, + outputRegionForThread.GetNumberOfPixels()); + + // defines input and output iterators + typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType; + typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType; + + // Set up an iterator on the input wavelets band + typename InputImageListType::ConstIterator inputListIt = inputPtr->Begin(); + unsigned int bandIndex = 0; + + // Compute number of decomposition levels + unsigned int numberOfDecompositionLevels = (inputPtr->Size()-1)/3; + + // Retrieve the largest possible region size + typename RegionType::SizeType largestSize = outputPtr->GetLargestPossibleRegion().GetSize(); + + // Iterate on each band + for (;inputListIt!=inputPtr->End();++inputListIt,++bandIndex) + { + // Build a band offset + typename RegionType::OffsetType currentOffset; + currentOffset.Fill(0); + + // Initialise Current level + unsigned int currentLevel = 0; + unsigned int currentSubBand = 0; + + if(bandIndex > 0) + { + // Compute current level and sub band + currentLevel = 1 + (bandIndex-1)/3; + currentSubBand = (bandIndex-1)%3; + + // Compute potentiel offset in x and y + unsigned int offsetX = largestSize[0]/(unsigned int)vcl_pow((double)m_DecimationRatio,(double)1+numberOfDecompositionLevels-currentLevel); + unsigned int offsetY = largestSize[1]/(unsigned int)vcl_pow((double)m_DecimationRatio,(double)1+numberOfDecompositionLevels-currentLevel); + + // Compute final offset according to the subband index + if(currentSubBand == 0) + { + currentOffset[0]+=offsetX; + } + else if(currentSubBand == 1) + { + currentOffset[1]+=offsetY; + } + else + { + currentOffset[0]+=offsetX; + currentOffset[1]+=offsetY; + } + } + // Retrieve current band region + RegionType currentBandRegion = inputListIt.Get()->GetLargestPossibleRegion(); + + // Apply offset to get the current output region + RegionType currentOutputRegion = currentBandRegion; + typename RegionType::IndexType currentOutputIndex = currentBandRegion.GetIndex(); + currentOutputIndex+=currentOffset; + currentOutputRegion.SetIndex(currentOutputIndex); + + // Crop with the outputRegionForThread. If the crop fails, + // it means that currentOutputRegion is outside of outputRegionForThread, + // and in this case we skip to the next image in the list. + if(currentOutputRegion.Crop(outputRegionForThread)) + { + // Compute the corresponding input region + RegionType currentInputRegion = currentBandRegion; + currentOutputIndex = currentOutputRegion.GetIndex(); + typename RegionType::IndexType currentInputIndex = currentBandRegion.GetIndex(); + + for(unsigned int i = 0; i < InputImageType::ImageDimension;++i) + { + currentInputIndex[i]+=currentOutputIndex[i]; + currentInputIndex[i]-=currentOffset[i]; + } + currentInputRegion.SetSize(currentOutputRegion.GetSize()); + currentInputRegion.SetIndex(currentInputIndex); + + InputIteratorType inIt(inputListIt.Get(),currentInputRegion); + OutputIteratorType outIt(outputPtr,currentOutputRegion); + + // Go to begin + inIt.GoToBegin(); + outIt.GoToBegin(); + + // Copy pixels + while(!inIt.IsAtEnd() && !outIt.IsAtEnd()) + { + // Copy pixel value + outIt.Set(static_cast<typename OutputImageType::InternalPixelType>(inIt.Get())); + // Step forward + ++inIt; + ++outIt; + progress.CompletedPixel(); + } + } + } +} +/** + * PrintSelf Method + */ +template <class TImageType, class TImageList> +void +WaveletsBandsListToWaveletsSynopsisImageFilter<TImageType,TImageList> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} +} // End namespace otb +#endif diff --git a/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..8ad9a302b90c3e4049b671231192d9d951bc2db0 --- /dev/null +++ b/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.h @@ -0,0 +1,122 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef otbWaveletsSynopsisImageToWaveletsBandsListFilter_h +#define otbWaveletsSynopsisImageToWaveletsBandsListFilter_h + +#include "otbImageToImageListFilter.h" +#include "itkRegionOfInterestImageFilter.h" + + +namespace otb +{ + +/** \class WaveletsSynopsisImageToWaveletsBandsListFilter + * \brief This class convert the standard wavelets view to a list of bands. + * + * \ingroup OTBWavelet + * \sa WaveletsBandsListToWaveletsSynopsisImageFilter + */ + +template <class TImage, class TImageList> +class ITK_EXPORT WaveletsSynopsisImageToWaveletsBandsListFilter + : public ImageToImageListFilter<TImage,typename TImageList::ImageType> +{ +public: + /** Standard typedefs */ + typedef WaveletsSynopsisImageToWaveletsBandsListFilter Self; + typedef ImageToImageListFilter<TImage, + typename TImageList::ImageType> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Type macro */ + itkNewMacro(Self); + + /** Creation through object factory macro */ + itkTypeMacro(WaveletsSynopsisImageToWaveletsBandsListFilter,ImageToImageListFilter); + + /** Template parameters typedefs */ + typedef TImage InputImageType; + typedef typename InputImageType::RegionType RegionType; + typedef TImageList OutputImageListType; + typedef typename OutputImageListType::ImageType OutputImageType; + + typedef itk::RegionOfInterestImageFilter< + InputImageType, + InputImageType > ExtractFilterType; + + typedef typename ExtractFilterType::Pointer ExtractFilterPointerType; + + typedef std::vector<ExtractFilterPointerType> ExtractFilterVectorType; + + /** Set the number of levels */ + itkSetMacro(NumberOfLevels,unsigned int); + + /** Get the number of levels */ + itkGetMacro(NumberOfLevels,unsigned int); + + /** Set the decimation ratio */ + itkSetMacro(DecimationRatio,unsigned int); + + /** Get the decimation ratio */ + itkGetMacro(DecimationRatio,unsigned int); + + /** If the filter is modified, the extract list need to be regenerated */ + virtual void Modified() const; + +protected: + /** Constructor */ + WaveletsSynopsisImageToWaveletsBandsListFilter(); + + /** Destructor */ + virtual ~WaveletsSynopsisImageToWaveletsBandsListFilter(); + + /**PrintSelf method */ + virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; + + /** Generate the input requested region from the first element in the list. */ + virtual void GenerateInputRequestedRegion(void); + + /** Generate the output information by building the output list. */ + virtual void GenerateOutputInformation(void); + + /** Main computation method */ + virtual void GenerateData(void); + +private: + WaveletsSynopsisImageToWaveletsBandsListFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + /** The number of levels in the decomposition */ + unsigned int m_NumberOfLevels; + + /** The decimation ratio used in the decomposition */ + unsigned int m_DecimationRatio; + + /** The vector of extraction filters for each band */ + ExtractFilterVectorType m_ExtractFilters; + + /** True if extract list is up-to-date */ + mutable bool m_ExtractFiltersUpToDate; +}; +}// End namespace otb +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbWaveletsSynopsisImageToWaveletsBandsListFilter.txx" +#endif + +#endif diff --git a/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.txx b/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..45de1a2c532aab00e33acf44a7b4816401c12c70 --- /dev/null +++ b/Modules/Filtering/Wavelet/include/otbWaveletsSynopsisImageToWaveletsBandsListFilter.txx @@ -0,0 +1,179 @@ +/*========================================================================= + + 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 otbWaveletsSynopsisImageToWaveletsBandsListFilter_txx +#define otbWaveletsSynopsisImageToWaveletsBandsListFilter_txx + +#include "otbWaveletsSynopsisImageToWaveletsBandsListFilter.h" + +namespace otb +{ +/** Constructor */ +template <class TImage, class TImageList> +WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList> +::WaveletsSynopsisImageToWaveletsBandsListFilter() : m_NumberOfLevels(1), + m_DecimationRatio(2), + m_ExtractFilters(), + m_ExtractFiltersUpToDate(false) +{} + +/** Destructor */ +template <class TImage, class TImageList> +WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList> +::~WaveletsSynopsisImageToWaveletsBandsListFilter() +{ + m_ExtractFilters.clear(); +} + +/** Modify overload */ +template <class TImage, class TImageList> +void +WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList> +::Modified() const +{ + // Call superclass implementation + Superclass::Modified(); + m_ExtractFiltersUpToDate = false; +} + +/** Generate the input requested region from the first element in the list. */ +template <class TImage, class TImageList> +void +WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList> +::GenerateOutputInformation(void) +{ + typename OutputImageListType::Pointer outputPtr = this->GetOutput(); + typename InputImageType::ConstPointer inputPtr = this->GetInput(); + + // Check if we need to regenerate the extract filters + if (inputPtr && !m_ExtractFiltersUpToDate) + { + // Retrieve image size + typename RegionType::SizeType largestSize = inputPtr->GetLargestPossibleRegion().GetSize(); + + // Compute the number of output images + unsigned int numberOfOutputImages = m_NumberOfLevels*3 + 1; + + // Clear the output image list + outputPtr->Clear(); + + // Clear the extract filter vector + m_ExtractFilters.clear(); + + // For each output image + for (unsigned int i=0;i<numberOfOutputImages;++i) + { + // Build the current extract filter + typename ExtractFilterType::Pointer currentExtract = ExtractFilterType::New(); + currentExtract->SetInput(inputPtr); + + // Add it to the filter list + m_ExtractFilters.push_back(currentExtract); + + // Add its output to the filter's output + outputPtr->PushBack(currentExtract->GetOutput()); + + // Build the corresponding region + RegionType currentRegion; + typename RegionType::IndexType currentIndex; + typename RegionType::SizeType currentSize; + currentIndex.Fill(0); + + // If this is not the first sub-band + if(i > 0) + { + // Compute current sub-band and level + unsigned int currentLevel = (i-1)/3; + unsigned int currentSubBand = (i-1)%3; + + unsigned int offsetX = largestSize[0]/(unsigned int)vcl_pow((double)m_DecimationRatio,(double)m_NumberOfLevels-currentLevel); + unsigned int offsetY = largestSize[1]/(unsigned int)vcl_pow((double)m_DecimationRatio,(double)m_NumberOfLevels-currentLevel); + + // Compute current size + currentSize[0] = offsetX; + currentSize[1] = offsetY; + + // Compute current index + if(currentSubBand == 0) + { + currentIndex[0]+= offsetX; + } + else if(currentSubBand == 1) + { + currentIndex[1]= offsetY; + } + else + { + currentIndex[0]= offsetX; + currentIndex[1]= offsetY; + } + } + else + { + // The coarsest scale size + currentSize[0] = largestSize[0]/(unsigned int)vcl_pow((double)m_DecimationRatio,(double)m_NumberOfLevels); + currentSize[1] = largestSize[1]/(unsigned int)vcl_pow((double)m_DecimationRatio,(double)m_NumberOfLevels); + } + // Build current region + currentRegion.SetIndex(currentIndex); + currentRegion.SetSize(currentSize); + //std::cout<<"Band: "<<i<<", region "<<currentRegion<<std::endl; + currentExtract->SetRegionOfInterest(currentRegion); + } + m_ExtractFiltersUpToDate = true; + } +} +/** Generate the output information by building the output list. */ +template <class TImage, class TImageList> +void +WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList> +::GenerateInputRequestedRegion(void) +{ + typename InputImageType::Pointer inputPtr = this->GetInput(); + + if (inputPtr) + { + inputPtr->SetRequestedRegionToLargestPossibleRegion(); + } +} +/** + * Main computation method + */ +template <class TImage, class TImageList> +void +WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList> +::GenerateData(void) +{ + // Update each extract fillter + for(typename ExtractFilterVectorType::iterator it = m_ExtractFilters.begin(); + it!=m_ExtractFilters.end();++it) + { + (*it)->Update(); + } +} +/** + * PrintSelf Method + */ +template <class TImage, class TImageList> +void +WaveletsSynopsisImageToWaveletsBandsListFilter<TImage,TImageList> +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} +} // End namespace otb +#endif diff --git a/Modules/Filtering/Wavelet/test/CMakeLists.txt b/Modules/Filtering/Wavelet/test/CMakeLists.txt index e09d0c8e48ffea54f1fba01038175b636de7b919..f8c8023e5de7774d5707d296a2b854169716ab5e 100644 --- a/Modules/Filtering/Wavelet/test/CMakeLists.txt +++ b/Modules/Filtering/Wavelet/test/CMakeLists.txt @@ -15,6 +15,7 @@ otbWaveletFilterBank.cxx otbWaveletPacketTransformNew.cxx otbWaveletFilterBankNew.cxx otbWaveletOperatorNew.cxx +otbWaveletImageToImageFilter.cxx ) add_executable(otbWaveletTestDriver ${OTBWaveletTests}) @@ -572,3 +573,11 @@ otb_add_test(NAME msTuWaveletFilterBankNew COMMAND otbWaveletTestDriver otb_add_test(NAME msTuWaveletOperatorNew COMMAND otbWaveletTestDriver otbWaveletOperatorNew ) +otb_add_test(NAME msTvWaveletImageToImageFilter COMMAND otbWaveletTestDriver + --compare-image ${EPSILON_6} + ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif + ${TEMP}/msTvWaveletImageToImageFilterOut.tif + otbWaveletImageToImageFilter + ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif + ${TEMP}/msTvWaveletImageToImageFilterOut.tif + ) diff --git a/Modules/Filtering/Wavelet/test/otbWaveletImageToImageFilter.cxx b/Modules/Filtering/Wavelet/test/otbWaveletImageToImageFilter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7a81db8bab9d9b5ce095ccad7737089e610fc7dc --- /dev/null +++ b/Modules/Filtering/Wavelet/test/otbWaveletImageToImageFilter.cxx @@ -0,0 +1,87 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +/* +This test code will run a WaveletImageFilter on given input image. Output +from this filter is then fed to WaveletInverseImageFilter which does +the inverse transform. Hence output of inverse transform passed to +ImageFileWriter will result in the input image. + +Wavelet operator used is HAAR (otb::Wavelet::HAAR). +This filter works only in single-threaded setup +*/ + +#include "otbImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" +#include "otbWaveletImageFilter.h" +#include "otbWaveletInverseImageFilter.h" + +int otbWaveletImageToImageFilter(int argc, char * argv[]) +{ + + const char * inputFileName = argv[1]; + const char * outputFileName = argv[argc-1]; + + /* Wavelet operator */ + const otb::Wavelet::Wavelet OperatorType = otb::Wavelet::HAAR; + + const int Dimension = 2; + typedef double PixelType; + typedef otb::Image<PixelType, Dimension> ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; + + + + typedef otb::WaveletImageFilter< + ImageType, + ImageType, + OperatorType> FwdFilterType; + + typedef otb::WaveletInverseImageFilter< + ImageType, + ImageType, + OperatorType> InvFilterType; + + typedef otb::ImageFileWriter<ImageType> WriterType; + + // itk::MultiThreader::SetGlobalMaximumNumberOfThreads( 1 ); + + /* Reading */ + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(inputFileName); + + /* Forward Transformation */ + FwdFilterType::Pointer fwdFilter = FwdFilterType::New(); + + fwdFilter->SetInput(reader->GetOutput()); + fwdFilter->Update(); + + /* Inverse Transformation */ + + InvFilterType::Pointer invFilter = InvFilterType::New(); + + invFilter->SetInput(fwdFilter->GetOutput()); + invFilter->Update(); + + /* Writing output */ + WriterType::Pointer writer = WriterType::New(); + writer->SetFileName(outputFileName); + writer->SetInput(invFilter->GetOutput()); + writer->Update(); + + return EXIT_SUCCESS; +} diff --git a/Modules/Filtering/Wavelet/test/otbWaveletTestDriver.cxx b/Modules/Filtering/Wavelet/test/otbWaveletTestDriver.cxx index 532d5e7880926866964abe550f940c198b594eb6..60c07f794cfc141162783e429dc8849425b361ff 100644 --- a/Modules/Filtering/Wavelet/test/otbWaveletTestDriver.cxx +++ b/Modules/Filtering/Wavelet/test/otbWaveletTestDriver.cxx @@ -14,4 +14,5 @@ void RegisterTests() REGISTER_TEST(otbWaveletPacketTransformNew); REGISTER_TEST(otbWaveletFilterBankNew); REGISTER_TEST(otbWaveletOperatorNew); + REGISTER_TEST(otbWaveletImageToImageFilter); } diff --git a/Modules/Fusion/PanSharpening/include/otbSimpleRcsPanSharpeningFusionImageFilter.h b/Modules/Fusion/PanSharpening/include/otbSimpleRcsPanSharpeningFusionImageFilter.h index 25e1470de639d4b87a9a068e705dbc1281b31b13..822db14618dfa82479b480167892fc781b60b72d 100644 --- a/Modules/Fusion/PanSharpening/include/otbSimpleRcsPanSharpeningFusionImageFilter.h +++ b/Modules/Fusion/PanSharpening/include/otbSimpleRcsPanSharpeningFusionImageFilter.h @@ -110,8 +110,8 @@ private: * This functor applies the * \f[ \frac{XS}{\mathrm{Filtered}(PAN)}PAN \f] * operation. It is intended for internal use only. - * - * \ingroup OTBPanSharpening + * + * \ingroup OTBPanSharpening */ class FusionFunctor { @@ -142,6 +142,83 @@ private: } }; + + /** \class NoDataFusionFunctor + * This functor applies the following operation if there is no data : + * \f[ \frac{XS}{\mathrm{Filtered}(PAN)}PAN \f] + * It is intended for internal use only. + * + * \ingroup OTBPanSharpening + */ + class NoDataFusionFunctor + { + public: + // Implement the fusion as a three arguments operator + typename TOutputImageType::PixelType operator()(const typename TXsImageType::PixelType& xsPixel, + const TInternalPrecision& smoothPanchroPixel, + const typename TPanImageType::PixelType& sharpPanchroPixel) const + { + // Build output pixel + typename TOutputImageType::PixelType output(xsPixel.Size()); + + // Check for no data Pan value + if( m_NoDataValuePanAvailable && sharpPanchroPixel == m_NoDataValuePan ) + { + for ( unsigned int i = 0; i < xsPixel.Size(); ++i ) + { + output[i] = static_cast<typename TOutputImageType::InternalPixelType>( m_NoDataValuesXs[i] ); + } + return output; + } + + TInternalPrecision scale = 1.; + + if(vcl_abs(smoothPanchroPixel) > 1e-10) + { + scale = sharpPanchroPixel/smoothPanchroPixel; + } + + // Perform fusion for each band with appropriate casting + for(unsigned int i = 0; i < xsPixel.Size(); ++i) + { + output[i] = ( m_NoDataValuesXsAvailable[i] && (xsPixel[i] == m_NoDataValuesXs[i]) ) ? + static_cast<typename TOutputImageType::InternalPixelType>( xsPixel[i] ) : + static_cast<typename TOutputImageType::InternalPixelType>( xsPixel[i] * scale ); + } + // Returns the output pixel + return output; + } + + void SetNoDataValuePanAvailable(bool noDataAvailable) { + m_NoDataValuePanAvailable = noDataAvailable; + } + + void SetNoDataValuePan(typename TPanImageType::PixelType noDataValue) { + m_NoDataValuePan = noDataValue; + } + + void SetNoDataValuesXsAvailable(std::vector<bool> noDataValuesAvailable) { + m_NoDataValuesXsAvailable = noDataValuesAvailable; + } + + void SetNoDataValuesXs(std::vector<typename TXsImageType::InternalPixelType> noDataValues) { + m_NoDataValuesXs = noDataValues; + } + + + private: + /** No data flags and values for APN image */ + bool m_NoDataValuePanAvailable; + typename TPanImageType::InternalPixelType m_NoDataValuePan; + + /** No data flags and values for XS image */ + std::vector<bool> m_NoDataValuesXsAvailable; + std::vector<typename TXsImageType::InternalPixelType> m_NoDataValuesXs; + + + }; + + /** * Typedef of the TernaryFunctorImageFilter applying the fusion functor to * p, p_smooth and xs. @@ -152,6 +229,16 @@ private: TOutputImageType, FusionFunctor> FusionFilterType; + /** + * Typedef of the TernaryFunctorImageFilter applying the no data fusion functor to + * p, p_smooth and xs. + */ + typedef itk::TernaryFunctorImageFilter<TXsImageType, + InternalImageType, + TPanImageType, + TOutputImageType, + NoDataFusionFunctor> NoDataFusionFilterType; + /** Typedef of the convolution filter performing smoothing */ typedef otb::ConvolutionImageFilter <TPanImageType, @@ -160,10 +247,16 @@ private: TInternalPrecision> ConvolutionFilterType; /** Pointer to the internal convolution filter */ - typename ConvolutionFilterType::Pointer m_ConvolutionFilter; + typename ConvolutionFilterType::Pointer m_ConvolutionFilter; /** Pointer to the fusion filter */ - typename FusionFilterType::Pointer m_FusionFilter; + typename FusionFilterType::Pointer m_FusionFilter; + + /** Pointer to the fusion filter */ + typename NoDataFusionFilterType::Pointer m_NoDataFusionFilter; + + /** Boolean used for no data */ + bool m_UseNoData; /** Radius used for the smoothing filter */ RadiusType m_Radius; diff --git a/Modules/Fusion/PanSharpening/include/otbSimpleRcsPanSharpeningFusionImageFilter.txx b/Modules/Fusion/PanSharpening/include/otbSimpleRcsPanSharpeningFusionImageFilter.txx index 4ddbe4831764bef8a4b72abe65c251009b9f6670..f849204758ffaf98aad467666968dfe68080ab4d 100644 --- a/Modules/Fusion/PanSharpening/include/otbSimpleRcsPanSharpeningFusionImageFilter.txx +++ b/Modules/Fusion/PanSharpening/include/otbSimpleRcsPanSharpeningFusionImageFilter.txx @@ -32,6 +32,7 @@ SimpleRcsPanSharpeningFusionImageFilter { // Fix number of required inputs this->SetNumberOfRequiredInputs(2); + this->m_UseNoData = false; // Instantiate convolution filter m_ConvolutionFilter = ConvolutionFilterType::New(); @@ -42,15 +43,6 @@ SimpleRcsPanSharpeningFusionImageFilter m_Filter.SetSize(7 * 7); m_Filter.Fill(1); - // Instantiate fusion filter - m_FusionFilter = FusionFilterType::New(); - m_FusionFilter->SetInput2(m_ConvolutionFilter->GetOutput()); - - // Set-up progress reporting - m_ProgressAccumulator = itk::ProgressAccumulator::New(); - m_ProgressAccumulator->SetMiniPipelineFilter(this); - m_ProgressAccumulator->RegisterInternalFilter(m_ConvolutionFilter, 0.9); - m_ProgressAccumulator->RegisterInternalFilter(m_FusionFilter, 0.1); } template <class TPanImageType, class TXsImageType, class TOutputImageType, class TInternalPrecision> @@ -127,18 +119,89 @@ SimpleRcsPanSharpeningFusionImageFilter itkExceptionMacro(<< "SimpleRcsPanSharpeningFusionImageFilter: Wrong Pan/Xs size"); } - //Process the fusion + // Set-up progress reporting + m_ProgressAccumulator = itk::ProgressAccumulator::New(); + m_ProgressAccumulator->SetMiniPipelineFilter(this); + m_ProgressAccumulator->RegisterInternalFilter(m_ConvolutionFilter, 0.9); + m_ConvolutionFilter->SetInput(this->GetPanInput()); m_ConvolutionFilter->SetRadius(this->m_Radius); m_ConvolutionFilter->SetFilter(this->m_Filter); - m_FusionFilter->SetInput1(this->GetXsInput()); - m_FusionFilter->SetInput3(this->GetPanInput()); + typedef typename TPanImageType::InternalPixelType PanPixelType; + typedef typename TXsImageType::InternalPixelType XsPixelType; + + // Write no-data flags for Pan image + std::vector<bool> tmpNoDataValuePanAvailable; + std::vector<double> tmpNoDataValuePan; + bool noDataValuePanAvailable = false; + PanPixelType noDataValuePan = 0; + + bool retPan = itk::ExposeMetaData<std::vector<bool> >( this->GetPanInput()->GetMetaDataDictionary(), MetaDataKey::NoDataValueAvailable, tmpNoDataValuePanAvailable ); + retPan &= itk::ExposeMetaData<std::vector<double> >( this->GetPanInput()->GetMetaDataDictionary(), MetaDataKey::NoDataValue, tmpNoDataValuePan ); + + if(retPan && tmpNoDataValuePanAvailable.size() > 0 && tmpNoDataValuePan.size() > 0) + { + noDataValuePanAvailable = tmpNoDataValuePanAvailable[0] && retPan; + noDataValuePan = static_cast<PanPixelType>( tmpNoDataValuePan[0] ); + } + + + // Write no-data flags for Xs image + std::vector<bool> noDataValuesXsAvailable; + std::vector<double> tmpNoDataValuesXs; + std::vector<XsPixelType> noDataValuesXs; + + bool retXs = itk::ExposeMetaData<std::vector<bool> >( this->GetXsInput()->GetMetaDataDictionary(), MetaDataKey::NoDataValueAvailable, noDataValuesXsAvailable ); + retXs &= itk::ExposeMetaData<std::vector<double> >( this->GetXsInput()->GetMetaDataDictionary(), MetaDataKey::NoDataValue, tmpNoDataValuesXs ); + + // Check if noData is needed and update noDataValuesAvailable with return function value + if ( retPan || retXs ) + { + m_UseNoData = noDataValuePanAvailable; + for ( unsigned int i = 0; i < tmpNoDataValuesXs.size() && i < noDataValuesXsAvailable.size(); ++i ) + { + noDataValuesXs.push_back( static_cast<XsPixelType>(tmpNoDataValuesXs[i]) ); + m_UseNoData |= (noDataValuesXsAvailable[i] = (noDataValuesXsAvailable[i] && retXs)); + } + } + + // Instantiate fusion filter + if ( m_UseNoData ) + { + m_NoDataFusionFilter = NoDataFusionFilterType::New(); + m_ProgressAccumulator->RegisterInternalFilter( m_NoDataFusionFilter, 0.1 ); + + m_NoDataFusionFilter->SetInput2( m_ConvolutionFilter->GetOutput() ); + m_NoDataFusionFilter->GetFunctor().SetNoDataValuesXsAvailable( noDataValuesXsAvailable ); + m_NoDataFusionFilter->GetFunctor().SetNoDataValuePanAvailable( noDataValuePanAvailable ); + m_NoDataFusionFilter->GetFunctor().SetNoDataValuePan( noDataValuePan ); + m_NoDataFusionFilter->GetFunctor().SetNoDataValuesXs( noDataValuesXs ); + + m_NoDataFusionFilter->SetInput1( this->GetXsInput() ); + m_NoDataFusionFilter->SetInput2( m_ConvolutionFilter->GetOutput() ); + m_NoDataFusionFilter->SetInput3( this->GetPanInput() ); + + // Wire composite filter + m_NoDataFusionFilter->GraftOutput( this->GetOutput() ); + m_NoDataFusionFilter->Update(); + this->GraftOutput( m_NoDataFusionFilter->GetOutput() ); + } + else + { + m_FusionFilter = FusionFilterType::New(); + m_ProgressAccumulator->RegisterInternalFilter( m_FusionFilter, 0.1 ); + + m_FusionFilter->SetInput1( this->GetXsInput() ); + m_FusionFilter->SetInput2( m_ConvolutionFilter->GetOutput() ); + m_FusionFilter->SetInput3( this->GetPanInput() ); + + // Wire composite filter + m_FusionFilter->GraftOutput( this->GetOutput() ); + m_FusionFilter->Update(); + this->GraftOutput( m_FusionFilter->GetOutput() ); + } - // Wire composite filter - m_FusionFilter->GraftOutput(this->GetOutput()); - m_FusionFilter->Update(); - this->GraftOutput(m_FusionFilter->GetOutput()); } template <class TPanImageType, class TXsImageType, class TOutputImageType, class TInternalPrecision> diff --git a/Modules/IO/IOGDAL/src/otbGDALOverviewsBuilder.cxx b/Modules/IO/IOGDAL/src/otbGDALOverviewsBuilder.cxx index ecfdfcbeb1690a06cc0a0a513a53a83c2b7923bd..5e15ca437386840f76b958dc5242ba9a4f2d3dcf 100644 --- a/Modules/IO/IOGDAL/src/otbGDALOverviewsBuilder.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALOverviewsBuilder.cxx @@ -200,7 +200,7 @@ GDALOverviewsBuilder unsigned int n = std::min( count, - CountResolutions( factor ) + CountResolutions( factor , 1) ); for( unsigned int i=0; i<n; ++i ) diff --git a/Modules/Remote/Mosaic.remote.cmake b/Modules/Remote/Mosaic.remote.cmake index 1989f99e313c74ee177e5b50b8faa3220d9baeb4..adfa72d32c7efb2f6171a63b2110352a0f141774 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 9a8cdd63ed3bba500bb4ea3867abc38bce8be562 + GIT_TAG 516dfa7e7b91aa0263e495ee6b3878a03ced9173 ) diff --git a/Modules/Remote/otb-bv.remote.cmake b/Modules/Remote/otb-bv.remote.cmake index f699009f62157dc925cb290851f91d83bddc38f9..e760e4b739df0fdfb2ffba94d731f91aa8516b3d 100644 --- a/Modules/Remote/otb-bv.remote.cmake +++ b/Modules/Remote/otb-bv.remote.cmake @@ -5,5 +5,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 d13a3b3febe61c3c67777eac8261e07a6257a519 ) diff --git a/Modules/Remote/otbFFSforGMM.remote.cmake b/Modules/Remote/otbFFSforGMM.remote.cmake index b7ae4ee086c7bdb040faabc2c4b4c5baa381631b..f1806e1602e7a5b50cffc6205a7a7e406df5f090 100644 --- a/Modules/Remote/otbFFSforGMM.remote.cmake +++ b/Modules/Remote/otbFFSforGMM.remote.cmake @@ -5,5 +5,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 master + GIT_TAG 78743f7d57de4acf913bf300cfbb93323a5c8ad3 ) diff --git a/Modules/Remote/phenotb.remote.cmake b/Modules/Remote/phenotb.remote.cmake index 3640ef3cfa99b6039f8f1010ab5ecb4daa8ffaa7..209b9682cfb29d206d17b2b35b245a2efade4964 100644 --- a/Modules/Remote/phenotb.remote.cmake +++ b/Modules/Remote/phenotb.remote.cmake @@ -7,5 +7,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 17d69b1bc1f23041dafe265e320b46ffb20229b6 ) diff --git a/Modules/Remote/temporal-gapfilling.remote.cmake b/Modules/Remote/temporal-gapfilling.remote.cmake index b135cb29a30b790987240fd46d4b621878e23cd9..681ae6e773cbd3720115b9a90a31461cf1195b79 100644 --- a/Modules/Remote/temporal-gapfilling.remote.cmake +++ b/Modules/Remote/temporal-gapfilling.remote.cmake @@ -6,5 +6,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 14c56cb73250861d8694effeba934cebde09424c ) diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp index acfecf8f58ad57fb8222fea2d274b101b1e874ee..7925680ccbf553e00c90d2d14fee2abeff612555 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp @@ -235,20 +235,6 @@ namespace ossimplugins return false; } } - else - { - /* Keep this notify as WARN. code should not reach here. - If manifest.safe is not found then we are not loading a valid S1 dataset. - If the input is tiff or annotation xml, then also there must exists a - manifest.safe. However, we are forced to read only annotaion xml and - make ossimSentinel1Model out of it for the sake of - "ossimSentinel1ModelTest". This is not a very good idea to allow - reading a fake dataset. So user must be warned! - */ - ossimNotify(ossimNotifyLevel_WARN) - << MODULE - << " manifest.safe not found. but checking if xml file is valid" << "\n"; - } // -----[ Read product file ossimFilename xmlFileName = file; @@ -259,6 +245,12 @@ namespace ossimplugins const ossimFilename fileNameWihtoutExtension = file.fileNoExtension(); const ossimFilename path = file.path().path(); xmlFileName = ossimFilename(path+"/annotation/"+fileNameWihtoutExtension+".xml"); + + if (!xmlFileName.exists() && safeFile.empty()) + { + // this is just a plain tiff file without safe nor xml + return false; + } } if ( !xmlFileName.exists() || !this->readProduct(xmlFileName) ) @@ -279,6 +271,23 @@ namespace ossimplugins << " !xmlFileName.exists() || !this->readProduct(xmlFileName) fails \n"; return false; } + else + { + if ( safeFile.empty() ) + { + /* Keep this notify as WARN. code should not reach here. + If manifest.safe is not found then we are not loading a valid S1 dataset. + If the input is tiff or annotation xml, then also there must exists a + manifest.safe. However, we are forced to read only annotaion xml and + make ossimSentinel1Model out of it for the sake of + "ossimSentinel1ModelTest". This is not a very good idea to allow + reading a fake dataset. So user must be warned! + */ + ossimNotify(ossimNotifyLevel_WARN) + << MODULE + << " manifest.safe not found, but xml file is valid" << "\n"; + } + } if ( !this->initImageSize( theImageSize ) ) { diff --git a/Modules/ThirdParty/Shark/src/otb_shark.h.in b/Modules/ThirdParty/Shark/src/otb_shark.h.in index 3b5ea0997ef7b354f2e509923717b17f2afb9c88..c6c432e09b4ea52d44c513b5fb4d8405d8130805 100755 --- a/Modules/ThirdParty/Shark/src/otb_shark.h.in +++ b/Modules/ThirdParty/Shark/src/otb_shark.h.in @@ -33,7 +33,7 @@ #define BOOST_PARAMETER_MAX_ARITY 15 #define BOOST_FILESYSTEM_VERSION 3 -/* without having a compile defintion will give an linker error +/* without having a compile definition will give an linker error * when build otbapp_TrainImagesClassifier or this header test. * So define them depending on wheather you have static or shared * build of boost. diff --git a/Modules/Visualization/Ice/include/otbGlView.h b/Modules/Visualization/Ice/include/otbGlView.h index a1aa852883560b332206c20798bea54acb0f8368..48c02d0333fa73ac3e6245e17df7e5655b788912 100644 --- a/Modules/Visualization/Ice/include/otbGlView.h +++ b/Modules/Visualization/Ice/include/otbGlView.h @@ -319,7 +319,6 @@ GlView if( actor.IsNull() ) return false; - // // Reference actor does not implement geo-interface. const otb::GeoInterface * geo = @@ -328,7 +327,8 @@ GlView if( geo==ITK_NULLPTR ) return false; - + const otb::GeoInterface::Spacing2 nativeReferenceSpacing = geo->GetSpacing(); + // // Compute transform origin. if( !geo->TransformFromViewport( center, vcenter, true ) ) @@ -390,13 +390,12 @@ GlView spacing[ 0 ] = vcl_sqrt( x[ 0 ] * x[ 0 ] + x[ 1 ] * x[ 1 ] ) / norm; spacing[ 1 ] = vcl_sqrt( y[ 0 ] * y[ 0 ] + y[ 1 ] * y[ 1 ] ) / norm; - // Sign of x-spacing is done by sign( x . (1, 0) ) which is sign( x[ 0 ] ) - // Sign of y-spacing is done by sign( y . (0, 1) ) which is sign[ y[ 1 ] ) - - if( x[ 0 ]<0.0 ) + // New spacing signs should match signs of the reference image spacing + + if( nativeReferenceSpacing[0]<0.0 ) spacing[ 0 ] = -spacing[ 0 ]; - if( y[ 1 ]<0.0 ) + if( nativeReferenceSpacing[1]<0.0 ) spacing[ 1 ] = -spacing[ 1 ]; // diff --git a/Modules/Visualization/Ice/src/otbGlImageActor.cxx b/Modules/Visualization/Ice/src/otbGlImageActor.cxx index f95da4257f877da2ca46469cbdbc9e5367340f84..530055e07ac6128893e542c183b5ceb957174d8c 100644 --- a/Modules/Visualization/Ice/src/otbGlImageActor.cxx +++ b/Modules/Visualization/Ice/src/otbGlImageActor.cxx @@ -873,13 +873,13 @@ GlImageActor #else index[ 0 ] = static_cast< IndexType::IndexValueType >( - ( physical[ 0 ] - m_Origin[ 0 ] ) / + ( physical[ 0 ] + 0.5 * m_Spacing[0] - m_Origin[ 0 ] ) / m_Spacing[ 0 ] ); index[ 1 ] = static_cast< IndexType::IndexValueType >( - ( physical[ 1 ]- m_Origin[ 1 ] ) / + ( physical[ 1 ] + 0.5 * m_Spacing[1] - m_Origin[ 1 ] ) / m_Spacing[ 1 ] ); diff --git a/Modules/Visualization/Mapla/src/mvdMaplaApplication.cxx b/Modules/Visualization/Mapla/src/mvdMaplaApplication.cxx index 4a1a871a2765d59d932c377223b97e22f0433a24..0096d801ee41af7a3797ec5ae8d5b74dfb7c7232 100644 --- a/Modules/Visualization/Mapla/src/mvdMaplaApplication.cxx +++ b/Modules/Visualization/Mapla/src/mvdMaplaApplication.cxx @@ -31,6 +31,7 @@ // // OTB includes (sorted by alphabetic order) +#include "otbWrapperApplicationRegistry.h" // // Monteverdi includes (sorted by alphabetic order) @@ -74,6 +75,7 @@ MaplaApplication MaplaApplication ::~MaplaApplication() { + otb::Wrapper::ApplicationRegistry::CleanRegistry(); } /*******************************************************************************/ diff --git a/Modules/Visualization/Monteverdi/src/CMakeLists.txt b/Modules/Visualization/Monteverdi/src/CMakeLists.txt index 85e016f6010b6734053bada692eec4f0b1ed0003..ab66fc6a2ce08e56d8a708d749c56edf10642506 100644 --- a/Modules/Visualization/Monteverdi/src/CMakeLists.txt +++ b/Modules/Visualization/Monteverdi/src/CMakeLists.txt @@ -72,6 +72,14 @@ add_executable( monteverdi ${Monteverdi_App_WIN32_RC_FILE} ${OTBMonteverdi_RESOURCES_RCC} ) + +# set monterverdi stack size to 10Mbytes on windows platform because +# the default size with visual compiler it is 1Mbyte +# which is to lower for us (thanks to 6S code). +if (WIN32) + set_linker_stack_size_flag( monteverdi 10000000 ) +endif() + target_link_libraries( monteverdi OTBMonteverdi ) diff --git a/Modules/Visualization/Monteverdi/src/mvdApplication.cxx b/Modules/Visualization/Monteverdi/src/mvdApplication.cxx index e42c38f39ab21199b0e4e0d3346581fc1b9ea0b8..265818ade759b107718b230bb87b08208b113826 100644 --- a/Modules/Visualization/Monteverdi/src/mvdApplication.cxx +++ b/Modules/Visualization/Monteverdi/src/mvdApplication.cxx @@ -34,6 +34,7 @@ // // Monteverdi includes (sorted by alphabetic order) +#include "mvdMainWindow.h" #include "mvdStackedLayerModel.h" // @@ -41,6 +42,10 @@ # include "mvdOTBApplicationsModel.h" #endif +#if USE_OTB_APPS +#include "otbWrapperApplicationRegistry.h" +#endif + // // Class implementation. namespace mvd @@ -76,6 +81,9 @@ Application Application ::~Application() { +#if USE_OTB_APPS + otb::Wrapper::ApplicationRegistry::CleanRegistry(); +#endif } /*******************************************************************************/ diff --git a/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx b/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx index db0d976419d438eff52100102157c4611d75a0c6..263b69deb604af1f23f02e3cb6f359498357f5a1 100644 --- a/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx +++ b/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx @@ -1102,8 +1102,8 @@ MainWindow quicklookView->SetPickingEnabled( false ); quicklookView->SetPickingDefaultStatus( false ); - quicklookView->setMinimumSize( 64, 64 ); - quicklookView->setMaximumSize( 512, 512 ); + quicklookView->setMinimumSize( 32, 32 ); + quicklookView->setMaximumSize( 1024, 1024 ); quicklookView->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ); return quicklookView; @@ -1757,8 +1757,9 @@ MainWindow { // // Select filename. + QString caption(tr("Open file...")); ImportImages( - otb::GetOpenFileNames( this, tr( "Open file..." ) ) + otb::GetOpenFileNames( this, caption ) ); } diff --git a/Modules/Visualization/Monteverdi/src/mvdMainWindow.qrc b/Modules/Visualization/Monteverdi/src/mvdMainWindow.qrc index c4178f41819dabd3388f1c73daf46c7039fa1ce5..dfd8f7d2866727451fc5998de9f6515725cd9362 100644 --- a/Modules/Visualization/Monteverdi/src/mvdMainWindow.qrc +++ b/Modules/Visualization/Monteverdi/src/mvdMainWindow.qrc @@ -7,7 +7,7 @@ <file alias="action_LayerProjection_Icon">../../../../Utilities/Data/Icons/projection_24x24.png</file> <file alias="action_LayerUp_Icon">../../../../Utilities/Data/Icons/layer-up_24x24.png</file> <file alias="action_LayerBottom_Icon">../../../../Utilities/Data/Icons/layer-bottom_24x24.png</file> - <file alias="action_LayerDelete_Icon">../../../../Utilities/Data/Icons/layer-delete_24x24.png</file> + <file alias="action_LayerDelete_Icon">../../../../Utilities/Data/Icons/layer-delete.png</file> <file alias="action_LayerDown_Icon">../../../../Utilities/Data/Icons/layer-down_24x24.png</file> <file alias="action_LayerTop_Icon">../../../../Utilities/Data/Icons/layer-top_24x24.png</file> <file alias="action_ZoomFull_Icon">../../../../Utilities/Data/Icons/zoom-1to1.png</file> diff --git a/Modules/Visualization/MonteverdiCore/src/mvdI18nCoreApplication.cxx b/Modules/Visualization/MonteverdiCore/src/mvdI18nCoreApplication.cxx index da3a3c66329969ea7521ab64abcc2dbc0bf09da7..f3b45caa3fcae98b30765f2a64941cc1eab8a417 100644 --- a/Modules/Visualization/MonteverdiCore/src/mvdI18nCoreApplication.cxx +++ b/Modules/Visualization/MonteverdiCore/src/mvdI18nCoreApplication.cxx @@ -562,34 +562,33 @@ I18nCoreApplication // QTextCodec::setCodecForCStrings( QTextCodec::codecForName("System") ); - qWarning() + qDebug() << "Codec for C-strings:" << ( QTextCodec::codecForCStrings()!=NULL ? QTextCodec::codecForCStrings()->name() : "none" ); - qWarning() + qDebug() << "Codec for Locale:" << ( QTextCodec::codecForLocale()!=NULL ? QTextCodec::codecForLocale()->name() : "none" ); - qWarning() + qDebug() << "Codec for Tr:" << ( QTextCodec::codecForTr()!=NULL ? QTextCodec::codecForTr()->name() : "none" ); - // // 1. default UI language is english (no translation). QLocale sys_lc( QLocale::system() ); // Trace system locale. - qWarning() + qDebug() << "Language:" << QLocale::languageToString( sys_lc.language() ); - qWarning() + qDebug() << "Country:" << QLocale::countryToString( sys_lc.country() ); // Check system locale. diff --git a/Modules/Visualization/MonteverdiCore/src/mvdStackedLayerModel.cxx b/Modules/Visualization/MonteverdiCore/src/mvdStackedLayerModel.cxx index 7118fb34023ae2c973933a4e3e3d0702fa9e8a29..148aafbb79698b24b59ba47db37556efd4bd6855 100644 --- a/Modules/Visualization/MonteverdiCore/src/mvdStackedLayerModel.cxx +++ b/Modules/Visualization/MonteverdiCore/src/mvdStackedLayerModel.cxx @@ -253,7 +253,7 @@ StackedLayerModel ? m_Current : ( m_Current>0 ? m_Current - 1 - : StackedLayerModel::NIL_INDEX ); + : GetCount()>1 ? 0 : StackedLayerModel::NIL_INDEX ); // // Emit signals. @@ -287,7 +287,7 @@ StackedLayerModel ? m_Reference : ( m_Reference > 0 ? m_Reference - 1 - : StackedLayerModel::NIL_INDEX ), + : GetCount() > 0 ? 0 : StackedLayerModel::NIL_INDEX ), true ); diff --git a/Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx b/Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx index d891e8f687524d9f39a5d47d6aee028eade4c47b..98511d85480dd0b022c354a93a8cb0906fe41eff 100644 --- a/Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx +++ b/Modules/Visualization/MonteverdiCore/src/mvdVectorImageModel.cxx @@ -212,7 +212,7 @@ VectorImageModel // TODO: this choice should be done by the user during the import of the file bool forceToCacheOvw = true; - qWarning() << tr( "The ImageIO used to read this file supports overviews." ); + qDebug() << tr( "The ImageIO used to read this file supports overviews." ); if( nbOfAvailableOvw>0 ) { @@ -223,7 +223,7 @@ VectorImageModel // TODO MSD: how to manage case of JPEG2000 with no overviews ? : wait GDAL support OpenJPEG ... // The current file don't have overviews available - qWarning() << tr( "The file doesn't have overviews." ); + qDebug() << tr( "The file doesn't have overviews." ); if( !forceToCacheOvw ) { diff --git a/Modules/Visualization/MonteverdiGui/CMakeLists.txt b/Modules/Visualization/MonteverdiGui/CMakeLists.txt index 37f9984e1ddbabc5b30532cf9802c06bfee4d2d0..d503daf285d81eac54f3688603ff6e8b9d2baab3 100644 --- a/Modules/Visualization/MonteverdiGui/CMakeLists.txt +++ b/Modules/Visualization/MonteverdiGui/CMakeLists.txt @@ -42,7 +42,8 @@ if (UNIX AND NOT APPLE) # ------------------------- # Install freedesktop entry - install(FILES ${OTBMonteverdiGUI_DATA_DIR}/monteverdi.desktop + configure_file(${OTBMonteverdiGUI_DATA_DIR}/monteverdi.desktop.in ${CMAKE_BINARY_DIR}/monteverdi.desktop) + install(FILES ${CMAKE_BINARY_DIR}/monteverdi.desktop DESTINATION share/applications) endif() diff --git a/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetView.h b/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetView.h index 417ebf0b59751a83b791feeb038fec208e450ad2..6a339467d433cca297f55449196fb848fda9fd0d 100644 --- a/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetView.h +++ b/Modules/Visualization/MonteverdiGui/include/mvdQtWidgetView.h @@ -33,6 +33,7 @@ // Qt includes (sorted by alphabetic order) //// Must be included before system/custom includes. #include <QtGui> +#include <QShortcut> // // System includes (sorted by alphabetic order) @@ -199,6 +200,7 @@ private: QPushButton* m_ExecButton; QPushButton* m_QuitButton; + QShortcut* m_QuitShortcut; QLabel* m_Message; bool m_IsClosable : 1; diff --git a/Modules/Visualization/MonteverdiGui/src/mvdColorBandDynamicsWidget.ui b/Modules/Visualization/MonteverdiGui/src/mvdColorBandDynamicsWidget.ui index dd697ccb77c7f316937a185e2effa32c335876be..b7d6734aa9efc54de9199733340f24fa83b72ec7 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdColorBandDynamicsWidget.ui +++ b/Modules/Visualization/MonteverdiGui/src/mvdColorBandDynamicsWidget.ui @@ -343,7 +343,7 @@ </property> <property name="icon"> <iconset> - <normaloff>:/icons/Data/Icons/execute.png</normaloff>:/icons/Data/Icons/execute.png</iconset> + <normaloff>:/icons/Utilities/Data/Icons/execute.png</normaloff>:/icons/Utilities/Data/Icons/execute.png</iconset> </property> <property name="iconSize"> <size> diff --git a/Modules/Visualization/MonteverdiGui/src/mvdColorDynamicsWidget.ui b/Modules/Visualization/MonteverdiGui/src/mvdColorDynamicsWidget.ui index f09efce079e9c67f448d3329bff418abe4c5628a..09afa39e08c0a41a75e033030780ec950226a15c 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdColorDynamicsWidget.ui +++ b/Modules/Visualization/MonteverdiGui/src/mvdColorDynamicsWidget.ui @@ -321,5 +321,22 @@ <resources> <include location="mvdIcons.qrc"/> </resources> - <connections/> + <connections> + <connection> + <sender>noDataCheckBox</sender> + <signal>toggled(bool)</signal> + <receiver>noDataLineEdit</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>49</x> + <y>23</y> + </hint> + <hint type="destinationlabel"> + <x>100</x> + <y>24</y> + </hint> + </hints> + </connection> + </connections> </ui> diff --git a/Modules/Visualization/MonteverdiGui/src/mvdColorSetupWidget.ui b/Modules/Visualization/MonteverdiGui/src/mvdColorSetupWidget.ui index 2bed58e35869d5ea15ce46809c4af8628686766c..662283b0b3f3b00ec1d852cda018e8e7c209556a 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdColorSetupWidget.ui +++ b/Modules/Visualization/MonteverdiGui/src/mvdColorSetupWidget.ui @@ -11,7 +11,7 @@ </rect> </property> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -47,10 +47,13 @@ </item> <item row="0" column="0"> <layout class="QGridLayout" name="gridLayout"> + <property name="margin"> + <number>9</number> + </property> <property name="spacing"> <number>3</number> </property> - <item row="4" column="0"> + <item row="3" column="0"> <layout class="QHBoxLayout" name="wHorizontalLayout"> <property name="spacing"> <number>1</number> @@ -95,7 +98,7 @@ </item> </layout> </item> - <item row="4" column="1"> + <item row="3" column="1"> <widget class="QComboBox" name="wComboBox"> <property name="enabled"> <bool>false</bool> @@ -123,23 +126,7 @@ </item> </widget> </item> - <item row="0" column="1"> - <widget class="QLabel" name="fileComponentLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string><html><head/><body><p align="center">Image bands<br/>↓</p></body></html></string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="1" column="0"> + <item row="0" column="0"> <layout class="QHBoxLayout" name="rHorizontalLayout"> <property name="spacing"> <number>1</number> @@ -178,7 +165,7 @@ </item> </layout> </item> - <item row="1" column="1"> + <item row="0" column="1"> <widget class="QComboBox" name="rComboBox"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Maximum"> @@ -203,7 +190,7 @@ </item> </widget> </item> - <item row="2" column="0"> + <item row="1" column="0"> <layout class="QHBoxLayout" name="gHorizontalLayout"> <property name="spacing"> <number>1</number> @@ -242,7 +229,7 @@ </item> </layout> </item> - <item row="2" column="1"> + <item row="1" column="1"> <widget class="QComboBox" name="gComboBox"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Maximum"> @@ -267,7 +254,7 @@ </item> </widget> </item> - <item row="3" column="0"> + <item row="2" column="0"> <layout class="QHBoxLayout" name="bHorizontalLayout"> <property name="spacing"> <number>1</number> @@ -306,7 +293,7 @@ </item> </layout> </item> - <item row="3" column="1"> + <item row="2" column="1"> <widget class="QComboBox" name="bComboBox"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Maximum"> @@ -331,7 +318,7 @@ </item> </widget> </item> - <item row="4" column="2"> + <item row="3" column="2"> <widget class="QCheckBox" name="wCheckBox"> <property name="toolTip"> <string>Enable/disable gray-scale mode.</string> diff --git a/Modules/Visualization/MonteverdiGui/src/mvdHistogramWidget.ui b/Modules/Visualization/MonteverdiGui/src/mvdHistogramWidget.ui index b66d978f9682d5422665c04bd5ad3c5344c6e744..0ca487f4eb2eb0f7f1f8e12740f9150c033f06aa 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdHistogramWidget.ui +++ b/Modules/Visualization/MonteverdiGui/src/mvdHistogramWidget.ui @@ -100,7 +100,7 @@ <property name="minimumSize"> <size> <width>200</width> - <height>100</height> + <height>60</height> </size> </property> <property name="toolTip"> diff --git a/Modules/Visualization/MonteverdiGui/src/mvdI18nMainWindow.cxx b/Modules/Visualization/MonteverdiGui/src/mvdI18nMainWindow.cxx index 3aad4081bea5228e44199aff3a2febb3c60ab9a2..499e6a8bb1430b5e7f2d9992eb3639e3c51c522c 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdI18nMainWindow.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdI18nMainWindow.cxx @@ -181,14 +181,23 @@ I18nMainWindow ::BuildGDALOverviews( const QStringList & filenames ) { ImportImagesDialog * importDialog = new ImportImagesDialog( filenames, this ); + // The import dialog should be deleted before leaving this function if( importDialog->GetEffectiveCount()<1 ) + { + delete importDialog; + importDialog = NULL; return true; + } int result = importDialog->exec(); if( result== QDialog::Rejected ) + { + delete importDialog; + importDialog = NULL; return false; + } if( result==QDialog::Accepted ) { @@ -205,6 +214,11 @@ I18nMainWindow Import( builder ); } + if (importDialog) + { + delete importDialog; + importDialog = NULL; + } return true; } diff --git a/Modules/Visualization/MonteverdiGui/src/mvdImageViewWidget.cxx b/Modules/Visualization/MonteverdiGui/src/mvdImageViewWidget.cxx index 911ac1b8968f77256cac60fcc126ab97fab17cdd..1afaf36d82892653ff8b36ca07d7921b3df7ccf3 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdImageViewWidget.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdImageViewWidget.cxx @@ -335,8 +335,10 @@ ImageViewWidget ::Initialize( AbstractImageViewManipulator* manipulator, AbstractImageViewRenderer* renderer ) { +#if OTB_DEBUG // Test OpenGL. ListGlVersions(); +#endif // Accept drops setAcceptDrops( true ); diff --git a/Modules/Visualization/MonteverdiGui/src/mvdImportImagesDialog.cxx b/Modules/Visualization/MonteverdiGui/src/mvdImportImagesDialog.cxx index 73b848ba0e894d9d3c03a1887d53a654ea2fbadf..76614c96afe42b8193043a8d8cd58f450f061bdc 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdImportImagesDialog.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdImportImagesDialog.cxx @@ -222,28 +222,39 @@ ImportImagesDialog I18nCoreApplication::SETTINGS_KEY_OVERVIEWS_SIZE ) ); - - count = - builder->CountResolutions( - 2, - value.isValid() - ? value.toInt() - : OVERVIEWS_SIZE_DEFAULT - ); + unsigned int threshold = + value.isValid() ? value.toInt() : OVERVIEWS_SIZE_DEFAULT; + + otb::GDALOverviewsBuilder::SizeVector ovrSizes; + builder->SetResolutionFactor(2); + // Count all resolution with minimum size 1 (the high requested count is + // clamped by the builder) + builder->ListResolutions(ovrSizes, 2, 9999); + // Count the number of levels with a least 1 size larger than the default size + for (unsigned int k=0 ; k<ovrSizes.size() ; k++) + { + if (std::max(ovrSizes[k][0],ovrSizes[k][1]) >= threshold) + count++; + else + break; + } } if( builder->GetOverviewsCount()>0 ) builder->SetBypassEnabled( true ); - else + else if (count>1) { flags |= Qt::ItemIsEnabled; - builder->SetBypassEnabled( count<=1 ); + builder->SetBypassEnabled( false ); ++ m_EffectiveCount; } + else + { + builder->SetBypassEnabled(true); + } - builder->SetResolutionFactor( 2 ); builder->SetNbResolutions( count ); builder->SetResamplingMethod( otb::GDAL_RESAMPLING_AVERAGE ); builder->SetCompressionMethod( otb::GDAL_COMPRESSION_NONE ); diff --git a/Modules/Visualization/MonteverdiGui/src/mvdLayerStackItemModel.cxx b/Modules/Visualization/MonteverdiGui/src/mvdLayerStackItemModel.cxx index 4aa7d0c0e3ce0160328ed9b5f7d0a8871d67057a..fd626710b0d542a1f2348218a21a006bc49445c5 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdLayerStackItemModel.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdLayerStackItemModel.cxx @@ -683,7 +683,8 @@ LayerStackItemModel // qDebug() // << this << "::index(" << row << "," << column << "," << parent << ")"; - assert( m_StackedLayerModel!=NULL ); + if (m_StackedLayerModel == NULL) + return QModelIndex(); // qDebug() // << "index:" << row << "," << column << "," << m_StackedLayerModel->At( row ); diff --git a/Modules/Visualization/MonteverdiGui/src/mvdLayerStackWidget.cxx b/Modules/Visualization/MonteverdiGui/src/mvdLayerStackWidget.cxx index 4e1e163f443c1692b291f3ef650f031d7862a47d..053773b03e969e155da39b6eddda874ef507cc48 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdLayerStackWidget.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdLayerStackWidget.cxx @@ -87,6 +87,22 @@ LayerStackWidget InstallEventFilter( this ); + // Width of the columns in the layer stack: + // Header section sizes are user adjustable but are not saved after a restart + // So we set it to a guess value here + // The unit is pixel, Qt's default is 100 + m_UI->treeView->header()->resizeSection(LayerStackItemModel::COLUMN_PROJ, 75); + m_UI->treeView->header()->resizeSection(LayerStackItemModel::COLUMN_RESOLUTION, 40); + m_UI->treeView->header()->resizeSection(LayerStackItemModel::COLUMN_NAME, 200); + m_UI->treeView->header()->resizeSection(LayerStackItemModel::COLUMN_EFFECT, 90); + m_UI->treeView->header()->resizeSection(LayerStackItemModel::COLUMN_I, 60); + m_UI->treeView->header()->resizeSection(LayerStackItemModel::COLUMN_J, 60); + m_UI->treeView->header()->resizeSection(LayerStackItemModel::COLUMN_R, 90); + m_UI->treeView->header()->resizeSection(LayerStackItemModel::COLUMN_G, 90); + m_UI->treeView->header()->resizeSection(LayerStackItemModel::COLUMN_B, 90); + m_UI->treeView->header()->resizeSection(LayerStackItemModel::COLUMN_X, 90); + m_UI->treeView->header()->resizeSection(LayerStackItemModel::COLUMN_Y, 90); + QObject::connect( m_UI->treeView->selectionModel(), SIGNAL( currentRowChanged( const QModelIndex &, const QModelIndex & ) ), diff --git a/Modules/Visualization/MonteverdiGui/src/mvdLayerStackWidget.ui b/Modules/Visualization/MonteverdiGui/src/mvdLayerStackWidget.ui index 0d4f254b2c3dfc05866bf8678938ad7bc57c90a1..96f5c15ebc7868902d2c32a573040f7ff93fdea3 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdLayerStackWidget.ui +++ b/Modules/Visualization/MonteverdiGui/src/mvdLayerStackWidget.ui @@ -194,9 +194,9 @@ </widget> </item> <item> - <widget class="QToolButton" name="deleteAllButton"> + <widget class="QToolButton" name="deleteButton"> <property name="toolTip"> - <string>Delete all layers</string> + <string>Delete selected layer</string> </property> <property name="locale"> <locale language="C" country="AnyCountry"/> @@ -206,14 +206,14 @@ </property> <property name="icon"> <iconset> - <normaloff>:/icons/action_LayerDeleteAll_Icon</normaloff>:/icons/action_LayerDeleteAll_Icon</iconset> + <normaloff>:/icons/action_LayerDelete_Icon</normaloff>:/icons/action_LayerDelete_Icon</iconset> </property> </widget> </item> <item> - <widget class="QToolButton" name="deleteButton"> + <widget class="QToolButton" name="deleteAllButton"> <property name="toolTip"> - <string>Delete selected layer</string> + <string>Delete all layers</string> </property> <property name="locale"> <locale language="C" country="AnyCountry"/> @@ -223,7 +223,7 @@ </property> <property name="icon"> <iconset> - <normaloff>:/icons/action_LayerDelete_Icon</normaloff>:/icons/action_LayerDelete_Icon</iconset> + <normaloff>:/icons/action_LayerDeleteAll_Icon</normaloff>:/icons/action_LayerDeleteAll_Icon</iconset> </property> </widget> </item> diff --git a/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx b/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx index 6efb0517e81dfb09c58725ab1448e970f0345845..5f62c2f37d366f30505e03d10fffe00ab44faa06 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx @@ -300,6 +300,11 @@ QtWidgetView SLOT( close() ) ); + // Add Ctrl-Q shortcut to quit + m_QuitShortcut = new QShortcut(QKeySequence("Ctrl+Q"), this); + connect( m_QuitShortcut, SIGNAL(activated()), this, SLOT(close()) ); + + // Put the buttons on the right footerLayout->addStretch(); footerLayout->addWidget(m_ExecButton); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 26c389002dc32713c481a6fd5fc6728f57a83d73..90d0a226651b8dbdbc39dd6707ddd7e89a53d5ea 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -172,10 +172,6 @@ public: * or a value set externally by user */ bool HasValue(std::string paramKey) const; - /* Activate or deactivate the bool parameter - */ - void SetParameterEmpty(std::string paramKey, bool active); - /* Get active flag of parameter with key paramKey */ bool GetParameterEmpty(std::string paramKey); @@ -204,13 +200,6 @@ public: */ /* Set the Parameter value and Update the UserFlag. used by xml parameter */ - void SetParameterInt(std::string parameter, int value, bool hasUserValueFlag); - void SetParameterFloat(std::string parameter, float value, bool hasUserValueFlag); - void SetParameterString(std::string parameter, std::string value, bool hasUserValueFlag); - void SetParameterStringList(std::string parameter, std::vector<std::string> values, bool hasUserValueFlag); - void SetParameterEmpty(std::string parameter, bool value, bool hasUserValueFlag); - - bool IsApplicationReady(); /* Set an integer value * @@ -220,14 +209,48 @@ public: * \li ParameterType_Radius * \li ParameterType_Choice */ - void SetParameterInt(std::string parameter, int value); + void SetParameterInt(std::string parameter, int value, bool hasUserValueFlag = true); /* Set a floating value * * Can be called for types : * \li ParameterType_Float */ - void SetParameterFloat(std::string parameter, float value); + void SetParameterFloat(std::string parameter, float value, bool hasUserValueFlag = true); + + /* Set a string value + * + * Can be called for types : + * \li ParameterType_InputImageListParameter + * \li ParameterType_InputVectorDataListParameter + * \li ParameterType_InputFilenameListParameter + * \li ParameterType_StringList + */ + void SetParameterString(std::string parameter, std::string value, bool hasUserValueFlag = true); + + /* Set a string value + * + * Can be called for types : + * \li ParameterType_String + * \li ParameterType_InputFilename + * \li ParameterType_OutputFilename + * \li ParameterType_Directory + * \li ParameterType_Choice + * \li ParameterType_Float + * \li ParameterType_Int + * \li ParameterType_Radius + * \li ParameterType_InputImageParameter + * \li ParameterType_InputComplexImageParameter + * \li ParameterType_InputVectorDataParameter + * \li ParameterType_OutputImageParameter + * \li ParameterType_OutputVectorDataParameter + */ + void SetParameterStringList(std::string parameter, std::vector<std::string> values, bool hasUserValueFlag = true); + + void SetParameterEmpty(std::string parameter, bool value, bool hasUserValueFlag = true); + + bool IsApplicationReady(); + /* Set an default integer value, must used in the * DoInit when setting a value by default @@ -309,35 +332,6 @@ public: * \li ParameterType_ListView */ void SetListViewSingleSelectionMode(std::string parameter, bool status); - - /* Set a string value - * - * Can be called for types : - * \li ParameterType_String - * \li ParameterType_InputFilename - * \li ParameterType_OutputFilename - * \li ParameterType_Directory - * \li ParameterType_Choice - * \li ParameterType_Float - * \li ParameterType_Int - * \li ParameterType_Radius - * \li ParameterType_InputImageParameter - * \li ParameterType_InputComplexImageParameter - * \li ParameterType_InputVectorDataParameter - * \li ParameterType_OutputImageParameter - * \li ParameterType_OutputVectorDataParameter - */ - void SetParameterString(std::string parameter, std::string value); - - /* Set a string value - * - * Can be called for types : - * \li ParameterType_InputImageListParameter - * \li ParameterType_InputVectorDataListParameter - * \li ParameterType_InputFilenameListParameter - * \li ParameterType_StringList - */ - void SetParameterStringList(std::string parameter, std::vector<std::string> value); /* Set an output image value * diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h index caa6b6754cfcf4cb9949ef025873ee53be4f39db..7c7bfa3ae3e05c144fdcd74dae3896bc7dcd6341 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h @@ -86,7 +86,7 @@ protected: /** * Method to remove all internal applications. Application deriving from - * CompositeApplication should call this method at the begining of their + * CompositeApplication should call this method at the beginning of their * DoInit(). */ void ClearApplications(); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index cf17ba6fc9b2d0856d0d69e5350740b0803a83dc..6a8a8795a44c47bedf99e1a60ac914fb9cc398a3 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -105,30 +105,185 @@ Parameter* Application::GetParameterByKey(std::string name, bool follow) void Application::SetParameterInt(std::string parameter, int value, bool hasUserValueFlag) { - this->SetParameterInt(parameter, value); + Parameter* param = GetParameterByKey(parameter); + + if (dynamic_cast<IntParameter*>(param)) + { + IntParameter* paramInt = dynamic_cast<IntParameter*>(param); + paramInt->SetValue(value); + } + else if (dynamic_cast<FloatParameter*>(param)) + { + FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); + paramFloat->SetValue(static_cast<float>(value)); + } + else if (dynamic_cast<RadiusParameter*>(param)) + { + RadiusParameter* paramRadius = dynamic_cast<RadiusParameter*>(param); + paramRadius->SetValue(static_cast<unsigned int>(value)); + } + else if (dynamic_cast<ChoiceParameter*>(param)) + { + ChoiceParameter* paramChoice = dynamic_cast<ChoiceParameter*>(param); + paramChoice->SetValue(value); + } + this->SetParameterUserValue(parameter, hasUserValueFlag); } void Application::SetParameterFloat(std::string parameter, float value, bool hasUserValueFlag) { - this->SetParameterFloat(parameter, value); + Parameter* param = GetParameterByKey(parameter); + + if (dynamic_cast<FloatParameter*>(param)) + { + FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); + paramFloat->SetValue(value); + } + this->SetParameterUserValue(parameter, hasUserValueFlag); } void Application::SetParameterString(std::string parameter, std::string value, bool hasUserValueFlag) { - this->SetParameterString(parameter, value); + Parameter* param = GetParameterByKey(parameter); + + if (dynamic_cast<ChoiceParameter*>(param)) + { + ChoiceParameter* paramDown = dynamic_cast<ChoiceParameter*>(param); + paramDown->SetValue(value); + } + else if (dynamic_cast<ListViewParameter*>(param)) + { + ListViewParameter* paramDown = dynamic_cast<ListViewParameter*>(param); + paramDown->SetValue(value); + } + else if (dynamic_cast<StringParameter*>(param)) + { + StringParameter* paramDown = dynamic_cast<StringParameter*>(param); + paramDown->SetValue(value); + } + else if (dynamic_cast<InputFilenameParameter*>(param)) + { + InputFilenameParameter* paramDown = dynamic_cast<InputFilenameParameter*>(param); + paramDown->SetValue(value); + } + else if (dynamic_cast<OutputFilenameParameter*>(param)) + { + OutputFilenameParameter* paramDown = dynamic_cast<OutputFilenameParameter*>(param); + paramDown->SetValue(value); + } + else if (dynamic_cast<DirectoryParameter*>(param)) + { + DirectoryParameter* paramDown = dynamic_cast<DirectoryParameter*>(param); + paramDown->SetValue(value); + } + else if (dynamic_cast<FloatParameter*>(param)) + { + FloatParameter* paramDown = dynamic_cast<FloatParameter*>(param); + paramDown->SetValue(value); + } + else if (dynamic_cast<RadiusParameter*>(param)) + { + RadiusParameter* paramDown = dynamic_cast<RadiusParameter*>(param); + paramDown->SetValue(value); + } + else if (dynamic_cast<IntParameter*>(param)) + { + IntParameter* paramDown = dynamic_cast<IntParameter*>(param); + paramDown->SetValue(value); + } + else if (dynamic_cast<InputImageParameter*>(param)) + { + InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param); + if ( !paramDown->SetFromFileName(value) ) + otbAppLogCRITICAL( <<"Invalid image filename " << value <<"."); + + } + else if (dynamic_cast<ComplexInputImageParameter*>(param)) + { + ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*>(param); + paramDown->SetFromFileName(value); + } + else if (dynamic_cast<InputVectorDataParameter*>(param)) + { + InputVectorDataParameter* paramDown = dynamic_cast<InputVectorDataParameter*>(param); + if ( !paramDown->SetFromFileName(value) ) + otbAppLogCRITICAL( <<"Invalid vector data filename " << value <<"."); + } + else if (dynamic_cast<OutputImageParameter*>(param)) + { + OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(param); + paramDown->SetFileName(value); + } + else if (dynamic_cast<ComplexOutputImageParameter*>(param)) + { + ComplexOutputImageParameter* paramDown = dynamic_cast<ComplexOutputImageParameter*>(param); + paramDown->SetFileName(value); + } + else if (dynamic_cast<OutputVectorDataParameter*>(param)) + { + OutputVectorDataParameter* paramDown = dynamic_cast<OutputVectorDataParameter*>(param); + paramDown->SetFileName(value); + } + else if (dynamic_cast<RAMParameter*>(param)) + { + RAMParameter* paramDown = dynamic_cast<RAMParameter*>(param); + paramDown->SetValue(value); + } + else if (dynamic_cast<OutputProcessXMLParameter*>(param)) + { + OutputProcessXMLParameter* paramDown = dynamic_cast<OutputProcessXMLParameter*>(param); + paramDown->SetValue(value); + } + else if (dynamic_cast<InputProcessXMLParameter*>(param)) + { + InputProcessXMLParameter* paramDown = dynamic_cast<InputProcessXMLParameter*>(param); + if ( !paramDown->SetFileName(value) ) + otbAppLogCRITICAL( <<"Invalid XML parameter filename " << value <<"."); + } + this->SetParameterUserValue(parameter, hasUserValueFlag); } void Application::SetParameterStringList(std::string parameter, std::vector<std::string> values, bool hasUserValueFlag) { - this->SetParameterStringList(parameter, values); + Parameter* param = GetParameterByKey(parameter); + + if (dynamic_cast<InputImageListParameter*>(param)) + { + InputImageListParameter* paramDown = dynamic_cast<InputImageListParameter*>(param); + if( !paramDown->SetListFromFileName(values) ) + otbAppLogCRITICAL( <<"At least one image filename is invalid."); + } + else if (dynamic_cast<InputVectorDataListParameter*>(param)) + { + InputVectorDataListParameter* paramDown = dynamic_cast<InputVectorDataListParameter*>(param); + if( !paramDown->SetListFromFileName(values) ) + otbAppLogCRITICAL( <<"At least one vector data filename is invalid.."); + } + else if (dynamic_cast<InputFilenameListParameter*>(param)) + { + InputFilenameListParameter* paramDown = dynamic_cast<InputFilenameListParameter*>(param); + if( !paramDown->SetListFromFileName(values) ) + otbAppLogCRITICAL( <<"At least one filename is invalid.."); + } + else if (dynamic_cast<StringListParameter*>(param)) + { + StringListParameter* paramDown = dynamic_cast<StringListParameter*>(param); + paramDown->SetValue(values); + } + else if(dynamic_cast<ListViewParameter *>(param)) + { + ListViewParameter * paramDown = dynamic_cast<ListViewParameter *>(param); + paramDown->SetSelectedNames(values); + } + this->SetParameterUserValue(parameter, hasUserValueFlag); } void Application::SetParameterEmpty(std::string parameter, bool value, bool hasUserValueFlag) { - this->SetParameterEmpty(parameter, value); + GetParameterByKey(parameter)->SetActive(value); this->SetParameterUserValue(parameter, hasUserValueFlag); } @@ -429,11 +584,6 @@ Role Application::GetParameterRole(std::string paramKey) const return GetParameterByKey(paramKey)->GetRole(); } -void Application::SetParameterEmpty(std::string paramKey, bool active) -{ - GetParameterByKey(paramKey)->SetActive(active); -} - bool Application::GetParameterEmpty(std::string paramKey) { return GetParameterByKey(paramKey)->GetActive(); @@ -588,42 +738,6 @@ std::vector<std::string> Application::GetChoiceNames(std::string name) itkExceptionMacro(<< name << " is not a choice parameter"); } -void Application::SetParameterInt(std::string parameter, int value) -{ - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<IntParameter*>(param)) - { - IntParameter* paramInt = dynamic_cast<IntParameter*>(param); - paramInt->SetValue(value); - } - else if (dynamic_cast<FloatParameter*>(param)) - { - FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); - paramFloat->SetValue(static_cast<float>(value)); - } - else if (dynamic_cast<RadiusParameter*>(param)) - { - RadiusParameter* paramRadius = dynamic_cast<RadiusParameter*>(param); - paramRadius->SetValue(static_cast<unsigned int>(value)); - } - else if (dynamic_cast<ChoiceParameter*>(param)) - { - ChoiceParameter* paramChoice = dynamic_cast<ChoiceParameter*>(param); - paramChoice->SetValue(value); - } -} - -void Application::SetParameterFloat(std::string parameter, float value) -{ - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<FloatParameter*>(param)) - { - FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); - paramFloat->SetValue(value); - } -} void Application::SetDefaultParameterInt(std::string parameter, int value) { @@ -759,140 +873,6 @@ void Application::SetListViewSingleSelectionMode(std::string parameter, bool sta } -void Application::SetParameterString(std::string parameter, std::string value) -{ - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<ChoiceParameter*>(param)) - { - ChoiceParameter* paramDown = dynamic_cast<ChoiceParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<ListViewParameter*>(param)) - { - ListViewParameter* paramDown = dynamic_cast<ListViewParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<StringParameter*>(param)) - { - StringParameter* paramDown = dynamic_cast<StringParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<InputFilenameParameter*>(param)) - { - InputFilenameParameter* paramDown = dynamic_cast<InputFilenameParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<OutputFilenameParameter*>(param)) - { - OutputFilenameParameter* paramDown = dynamic_cast<OutputFilenameParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<DirectoryParameter*>(param)) - { - DirectoryParameter* paramDown = dynamic_cast<DirectoryParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<FloatParameter*>(param)) - { - FloatParameter* paramDown = dynamic_cast<FloatParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<RadiusParameter*>(param)) - { - RadiusParameter* paramDown = dynamic_cast<RadiusParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<IntParameter*>(param)) - { - IntParameter* paramDown = dynamic_cast<IntParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<InputImageParameter*>(param)) - { - InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param); - if ( !paramDown->SetFromFileName(value) ) - otbAppLogCRITICAL( <<"Invalid image filename " << value <<"."); - - } - else if (dynamic_cast<ComplexInputImageParameter*>(param)) - { - ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*>(param); - paramDown->SetFromFileName(value); - } - else if (dynamic_cast<InputVectorDataParameter*>(param)) - { - InputVectorDataParameter* paramDown = dynamic_cast<InputVectorDataParameter*>(param); - if ( !paramDown->SetFromFileName(value) ) - otbAppLogCRITICAL( <<"Invalid vector data filename " << value <<"."); - } - else if (dynamic_cast<OutputImageParameter*>(param)) - { - OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(param); - paramDown->SetFileName(value); - } - else if (dynamic_cast<ComplexOutputImageParameter*>(param)) - { - ComplexOutputImageParameter* paramDown = dynamic_cast<ComplexOutputImageParameter*>(param); - paramDown->SetFileName(value); - } - else if (dynamic_cast<OutputVectorDataParameter*>(param)) - { - OutputVectorDataParameter* paramDown = dynamic_cast<OutputVectorDataParameter*>(param); - paramDown->SetFileName(value); - } - else if (dynamic_cast<RAMParameter*>(param)) - { - RAMParameter* paramDown = dynamic_cast<RAMParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<OutputProcessXMLParameter*>(param)) - { - OutputProcessXMLParameter* paramDown = dynamic_cast<OutputProcessXMLParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<InputProcessXMLParameter*>(param)) - { - InputProcessXMLParameter* paramDown = dynamic_cast<InputProcessXMLParameter*>(param); - if ( !paramDown->SetFileName(value) ) - otbAppLogCRITICAL( <<"Invalid XML parameter filename " << value <<"."); - } -} - -void Application::SetParameterStringList(std::string parameter, std::vector<std::string> value) -{ - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<InputImageListParameter*>(param)) - { - InputImageListParameter* paramDown = dynamic_cast<InputImageListParameter*>(param); - if( !paramDown->SetListFromFileName(value) ) - otbAppLogCRITICAL( <<"At least one image filename is invalid."); - } - else if (dynamic_cast<InputVectorDataListParameter*>(param)) - { - InputVectorDataListParameter* paramDown = dynamic_cast<InputVectorDataListParameter*>(param); - if( !paramDown->SetListFromFileName(value) ) - otbAppLogCRITICAL( <<"At least one vector data filename is invalid.."); - } - else if (dynamic_cast<InputFilenameListParameter*>(param)) - { - InputFilenameListParameter* paramDown = dynamic_cast<InputFilenameListParameter*>(param); - if( !paramDown->SetListFromFileName(value) ) - otbAppLogCRITICAL( <<"At least one filename is invalid.."); - } - else if (dynamic_cast<StringListParameter*>(param)) - { - StringListParameter* paramDown = dynamic_cast<StringListParameter*>(param); - paramDown->SetValue(value); - } - else if(dynamic_cast<ListViewParameter *>(param)) - { - ListViewParameter * paramDown = dynamic_cast<ListViewParameter *>(param); - paramDown->SetSelectedNames(value); - } -} - void Application::SetParameterOutputImage(std::string parameter, FloatVectorImageType* value) { Parameter* param = GetParameterByKey(parameter); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationHtmlDocGenerator.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationHtmlDocGenerator.cxx index 086ec18a624d7a6756a4a27e859a2595452a3837..bb6864898d0c35488195ba8cdff1d4c12403e5de 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationHtmlDocGenerator.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationHtmlDocGenerator.cxx @@ -186,7 +186,7 @@ void ApplicationHtmlDocGenerator::GetDocParameters( const Application::Pointer a for( unsigned int i=0; i<nbOfParam; i++ ) { const std::string key(appKeyList[i]); - Parameter::Pointer param = app->GetParameterByKey( key ); + Parameter::Pointer param = app->GetParameterByKey(key, false); if( app->GetParameterType(key) == ParameterType_Group) { oss << "<li>"; @@ -235,7 +235,7 @@ void ApplicationHtmlDocGenerator::GetDocParameterGroup( const Application::Point for( unsigned int i=0; i<nbOfParam; i++ ) { const std::string fullKey(std::string(key).append(".").append(appKeyList[i])); - Parameter::Pointer param = app->GetParameterByKey( fullKey ); + Parameter::Pointer param = app->GetParameterByKey( fullKey, false); if( app->GetParameterType(fullKey) == ParameterType_Group) { oss<<"<li>"; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx index e72145ce085f42418074a7643a740d7ffb6cc756..409f8ad46ed49cad63f9b735ddd32261018bb773 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx @@ -107,10 +107,20 @@ void ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(const Ap // Set DEM directory if available if(IsDEMUsed(app,key)) { - oss.str(""); - oss<<"Elevation management: using DEM directory ("<<GetDEMDirectory(app,key)<<")"<<std::endl; - otb::DEMHandler::Instance()->OpenDEMDirectory(GetDEMDirectory(app,key)); - app->GetLogger()->Info(oss.str()); + std::string demDirectory = GetDEMDirectory(app,key); + if(otb::DEMHandler::Instance()->IsValidDEMDirectory(demDirectory.c_str())) + { + oss.str( "" ); + oss << "Elevation management: using DEM directory (" << demDirectory << ")" << std::endl; + otb::DEMHandler::Instance()->OpenDEMDirectory( demDirectory ); + app->GetLogger()->Info( oss.str() ); + } + else + { + oss.str( "" ); + oss << "DEM directory : " << demDirectory << " is not a valid DEM directory"; + app->GetLogger()->Warning( oss.str() ); + } } } @@ -161,10 +171,10 @@ ElevationParametersHandler::IsGeoidUsed(const Application::Pointer app, const st bool ElevationParametersHandler::IsDEMUsed(const Application::Pointer app, const std::string& key) { - std::ostringstream geoidKey; - geoidKey<< key<<".dem"; + std::ostringstream demKey; + demKey<< key<<".dem"; - return app->IsParameterEnabled(geoidKey.str()) && app->HasValue(geoidKey.str()); + return app->IsParameterEnabled(demKey.str()) && app->HasValue(demKey.str()); } diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx index 8fa88be9de329b084a1876b6c3a302cea2db70a0..c75e921044d320ac88361b26b22929d77d81ec74 100644 --- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx +++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx @@ -858,7 +858,7 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & itkExceptionMacro("Not handled parameter type."); - oss<< " " << param->GetName() << " "; + oss<< " " << m_Application->GetParameterName(paramKey) << " "; if (type == ParameterType_OutputImage) { diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h index b4d69cc539b8492e5af2799f9d55c7bbf3b97fb0..bd6a31155eea9d312efffef520e38b69e454b942 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetView.h @@ -20,6 +20,7 @@ #include <QtGui> #include <QObject> +#include <QShortcut> #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility #include "otbWrapperQtWidgetModel.h" #endif //tag=QT4-boost-compatibility @@ -80,6 +81,7 @@ private: QPushButton* m_ExecButton; QPushButton* m_QuitButton; + QShortcut* m_QuitShortcut; QLabel* m_Message; }; diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx index 1e089805e5ff7ea5e4431ff58e27163cd30181e0..e9587623dbc3eeeea23a7fb28c345fbcc95aa9df 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx @@ -57,6 +57,8 @@ QtWidgetModel QtWidgetModel::~QtWidgetModel() { + if (m_Timer) + delete m_Timer; } void @@ -177,6 +179,13 @@ QtWidgetModel SLOT( OnApplicationExecutionDone( int ) ) ); + QObject::connect( + taskAppli, + SIGNAL( finished() ), + taskAppli, + SLOT( deleteLater() ) + ); + // Tell the Progress Reporter to begin emit SetProgressReportBegin(); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx index fbb113c46ad3b7b0c6cf77cb76e6cef45d54effa..872b4b4703e65e59603ed19359ebaaae77d4f86d 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx @@ -55,6 +55,7 @@ void QtWidgetParameterGroup::DoCreateWidget() for (unsigned int i = 0; i < nbParams; ++i) { Parameter* param = m_ParamList->GetParameterByIndex(i); + Parameter* rawParam = m_ParamList->GetParameterByIndex(i,false); if (param != ITK_NULLPTR) { @@ -70,7 +71,7 @@ void QtWidgetParameterGroup::DoCreateWidget() if (paramAsGroup == ITK_NULLPTR && paramAsChoice == ITK_NULLPTR && !paramIsXML) { // Label (col 1) - QWidget* label = new QtWidgetParameterLabel( param ); + QWidget* label = new QtWidgetParameterLabel( rawParam ); gridLayout->addWidget(label, i, 1); // Parameter Widget (col 2) @@ -149,7 +150,7 @@ void QtWidgetParameterGroup::DoCreateWidget() } connect(group, SIGNAL(clicked(bool)), specificWidget, SLOT(SetActivationState(bool))); - group->setTitle(param->GetName()); + group->setTitle(rawParam->GetName()); gridLayout->addWidget(group, i, 0, 1, -1); m_WidgetList.push_back(specificWidget); diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx index 43f7472ca46f7466cbc081fdf698f9e581c5e05d..c299ca8459aacd2e49da7c8ad9f94be4021a4c4a 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetView.cxx @@ -27,6 +27,7 @@ #include "itksys/SystemTools.hxx" + namespace otb { namespace Wrapper @@ -142,6 +143,10 @@ QWidget* QtWidgetView::CreateFooter() m_QuitButton->setText(QObject::tr("Quit")); connect( m_QuitButton, SIGNAL(clicked()), this, SLOT(CloseSlot()) ); + // Add Ctrl-Q shortcut to quit + m_QuitShortcut = new QShortcut(QKeySequence("Ctrl+Q"), this); + connect( m_QuitShortcut, SIGNAL(activated()), this, SLOT(CloseSlot()) ); + // Put the buttons on the right footerLayout->addStretch(); footerLayout->addWidget(m_ExecButton); diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index aa93633ba359170270f853d5b4973c7cfa54de1e..d02d01a36d11aa7119c3eba841824fd6883c51cf 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -181,16 +181,11 @@ public: bool IsApplicationReady(); - void SetParameterInt(std::string parameter, int value); - void SetParameterFloat(std::string parameter, float value); - void SetParameterString(std::string parameter, std::string value); - void SetParameterStringList(std::string parameter, std::vector<std::string> value); - - void SetParameterInt(std::string parameter, int value, bool hasUserValueFlag); - void SetParameterFloat(std::string parameter, float value, bool hasUserValueFlag); - void SetParameterString(std::string parameter, std::string value, bool hasUserValueFlag); - void SetParameterStringList(std::string parameter, std::vector<std::string> values, bool hasUserValueFlag); - void SetParameterEmpty(std::string parameter, bool value, bool hasUserValueFlag); + void SetParameterInt(std::string parameter, int value, bool hasUserValueFlag = true); + void SetParameterFloat(std::string parameter, float value, bool hasUserValueFlag = true); + void SetParameterString(std::string parameter, std::string value, bool hasUserValueFlag = true); + void SetParameterStringList(std::string parameter, std::vector<std::string> values, bool hasUserValueFlag = true); + void SetParameterEmpty(std::string parameter, bool value, bool hasUserValueFlag = true); void SetParameterOutputImagePixelType(std::string parameter, otb::Wrapper::ImagePixelType pixelType); void SetParameterComplexOutputImagePixelType(std::string parameter, otb::Wrapper::ComplexImagePixelType cpixelType); @@ -416,6 +411,7 @@ private: void operator =(const Application&); }; + DECLARE_REF_COUNT_CLASS( Application ) diff --git a/Modules/Wrappers/SWIG/src/otbApplicationLuaMain.cxx b/Modules/Wrappers/SWIG/src/otbApplicationLuaMain.cxx deleted file mode 100644 index dba66e3fbf3c9104845fa4ff4597d6b5de9d6ce9..0000000000000000000000000000000000000000 --- a/Modules/Wrappers/SWIG/src/otbApplicationLuaMain.cxx +++ /dev/null @@ -1,426 +0,0 @@ -/* -** $Id: lua.c, v 1.157 2005/12/29 16:23:32 roberto Exp $ -** Lua stand-alone interpreter -** See Copyright Notice in lua.h -*/ - -#include <itkVersion.h> -#include <itksys/SystemTools.hxx> -#include <itkMultiThreader.h> - -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <string> - -#define lua_c - -#if !defined(_WIN32) -#define LUA_USE_POSIX -#endif - - -extern "C" { -#include "lua.h" -#include "lualib.h" -#include "lauxlib.h" -} - -static lua_State *globalL = NULL; - -static const char *progname = LUA_PROGNAME; - -static void lstop (lua_State *L, lua_Debug *ar) { - (void)ar; /* unused arg. */ - lua_sethook(L, NULL, 0, 0); - luaL_error(L, "interrupted!"); -} - - -static void laction (int i) { - signal(i, SIG_DFL); /* if another SIGINT happens before lstop, - terminate process (default action) */ - lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); -} - - -static void print_usage (void) { - fprintf(stderr, - "usage: %s [options] [script [args]].\n" - "Available options are:\n" - " -e stat execute string " LUA_QL("stat") "\n" - " -l name require library " LUA_QL("name") "\n" - " -c conf configure logger from file " LUA_QL("config") "\n" - " -i enter interactive mode after executing " LUA_QL("script") "\n" - " -v show version information\n" - " -- stop handling options\n" - " - execute stdin and stop handling options\n" - , - progname); - fflush(stderr); -} - - -static void l_message (const char *pname, const char *msg) { - if (pname) fprintf(stderr, "%s: ", pname); - fprintf(stderr, "%s\n", msg); - fflush(stderr); -} - - -static int report (lua_State *L, int status) { - if (status && !lua_isnil(L, -1)) { - const char *msg = lua_tostring(L, -1); - if (msg == NULL) msg = "(error object is not a string)"; - l_message(progname, msg); - lua_pop(L, 1); - } - return status; -} - - -static int traceback (lua_State *L) { - lua_getfield(L, LUA_GLOBALSINDEX, "debug"); - if (!lua_istable(L, -1)) { - lua_pop(L, 1); - return 1; - } - lua_getfield(L, -1, "traceback"); - if (!lua_isfunction(L, -1)) { - lua_pop(L, 2); - return 1; - } - lua_pushvalue(L, 1); /* pass error message */ - lua_pushinteger(L, 2); /* skip this function and traceback */ - lua_call(L, 2, 1); /* call debug.traceback */ - return 1; -} - - -static int docall (lua_State *L, int narg, int clear) { - int status; - int base = lua_gettop(L) - narg; /* function index */ - lua_pushcfunction(L, traceback); /* push traceback function */ - lua_insert(L, base); /* put it under chunk and args */ - signal(SIGINT, laction); - status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); - signal(SIGINT, SIG_DFL); - lua_remove(L, base); /* remove traceback function */ - /* force a complete garbage collection in case of errors */ - if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); - return status; -} - -static void print_version (void) { - fprintf ( stdout, LUA_VERSION " " LUA_COPYRIGHT "\n" ); - fprintf ( stdout, "otbApplication\nInsight Toolkit %s\n", itk::Version::GetITKVersion() ); -} - - -static int getargs (lua_State *L, char **argv, int n) { - int narg; - int i; - int argc = 0; - while (argv[argc]) argc++; /* count total number of arguments */ - narg = argc - (n + 1); /* number of arguments to the script */ - luaL_checkstack(L, narg + 3, "too many arguments to script"); - for (i=n+1; i < argc; i++) - lua_pushstring(L, argv[i]); - lua_createtable(L, narg, n + 1); - for (i=0; i < argc; i++) { - lua_pushstring(L, argv[i]); - lua_rawseti(L, -2, i - n); - } - return narg; -} - - -static int dofile (lua_State *L, const char *name) { - int status = luaL_loadfile(L, name) || docall(L, 0, 1); - return report(L, status); -} - - -static int dostring (lua_State *L, const char *s, const char *name) { - int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); - return report(L, status); -} - - -static int dolibrary (lua_State *L, const char *name) { - lua_getglobal(L, "require"); - lua_pushstring(L, name); - return report(L, lua_pcall(L, 1, 0, 0)); -} - - -static const char *get_prompt (lua_State *L, int firstline) { - const char *p; - lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); - p = lua_tostring(L, -1); - if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); - lua_pop(L, 1); /* remove global */ - return p; -} - - -static int incomplete (lua_State *L, int status) { - if (status == LUA_ERRSYNTAX) { - size_t lmsg; - const char *msg = lua_tolstring(L, -1, &lmsg); - const char *tp = msg + lmsg - (sizeof(LUA_QL("<eof>")) - 1); - if (strstr(msg, LUA_QL("<eof>")) == tp) { - lua_pop(L, 1); - return 1; - } - } - return 0; /* else... */ -} - - -static int pushline (lua_State *L, int firstline) { - char buffer[LUA_MAXINPUT]; - char *b = buffer; - size_t l; - const char *prmt = get_prompt(L, firstline); - if (lua_readline(L, b, prmt) == 0) - return 0; /* no input */ - l = strlen(b); - if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ - b[l-1] = '\0'; /* remove it */ - if (firstline && b[0] == '=') /* first line starts with `=' ? */ - lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ - else - lua_pushstring(L, b); - lua_freeline(L, b); - return 1; -} - - -static int loadline (lua_State *L) { - int status; - lua_settop(L, 0); - if (!pushline(L, 1)) - return -1; /* no input */ - for (; ;) { /* repeat until gets a complete line */ - status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); - if (!incomplete(L, status)) break; /* cannot try to add lines? */ - if (!pushline(L, 0)) /* no more input? */ - return -1; - lua_pushliteral(L, "\n"); /* add a new line... */ - lua_insert(L, -2); /* ...between the two lines */ - lua_concat(L, 3); /* join them */ - } - lua_saveline(L, 1); - lua_remove(L, 1); /* remove line */ - return status; -} - - -static void dotty (lua_State *L) { - int status; - const char *oldprogname = progname; - progname = NULL; - while ((status = loadline(L)) != -1) { - if (status == 0) status = docall(L, 0, 0); - report(L, status); - if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ - lua_getglobal(L, "print"); - lua_insert(L, 1); - if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) - l_message(progname, lua_pushfstring(L, - "error calling " LUA_QL("print") " (%s)", - lua_tostring(L, -1))); - } - } - lua_settop(L, 0); /* clear stack */ - fputs("\n", stdout); - fflush(stdout); - progname = oldprogname; -} - - -static int handle_script (lua_State *L, char **argv, int n) { - int status; - const char *fname; - int narg = getargs(L, argv, n); /* collect arguments */ - lua_setglobal(L, "arg"); - fname = argv[n]; - if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) - fname = NULL; /* stdin */ - status = luaL_loadfile(L, fname); - lua_insert(L, -(narg+1)); - if (status == 0) - status = docall(L, narg, 0); - else - lua_pop(L, narg); - return report(L, status); -} - - -static int collectargs (char **argv, int *pi, int *pv, int *pe) { - int i; - for (i = 1; argv[i] != NULL; i++) { - if (argv[i][0] != '-') /* not an option? */ - return i; - switch (argv[i][1]) { /* option */ - case '-': return (argv[i+1] != NULL ? i+1 : 0); - case '\0': return i; - case 'i': *pi = 1; /* go through */ - case 'v': *pv = 1; break; - case 'e': *pe = 1; /* go through */ - case 'c': - case 'l': - if (argv[i][2] == '\0') { - i++; - if (argv[i] == NULL) return -1; - } - break; - default: return -1; /* invalid option */ - } - } - return 0; -} - - -std::string LogConfigFilename (""); - -static int runargs (lua_State *L, char **argv, int n) { - int i; - for (i = 1; i < n; i++) { - if (argv[i] == NULL) continue; - lua_assert(argv[i][0] == '-'); - switch (argv[i][1]) { /* option */ - case 'e': { - const char *chunk = argv[i] + 2; - if (*chunk == '\0') chunk = argv[++i]; - lua_assert(chunk != NULL); - if (dostring(L, chunk, "=(command line)") != 0) - return 1; - break; - } - case 'l': { - const char *filename = argv[i] + 2; - if (*filename == '\0') filename = argv[++i]; - lua_assert(filename != NULL); - if (dolibrary(L, filename)) - return 1; /* stop if file fails */ - break; - } - case 'c': { - const char *filename = argv[i] + 2; - if (*filename == '\0') filename = argv[++i]; - lua_assert(filename != NULL); - LogConfigFilename = filename; - break; - } - default: break; - } - } - return 0; -} - - -static int handle_luainit (lua_State *L) { - const char *init = getenv("LUA_INIT"); - if (init == NULL) return 0; /* status OK */ - else if (init[0] == '@') - return dofile(L, init+1); - else - return dostring(L, init, "=LUA_INIT"); -} - - -struct Smain { - int argc; - char **argv; - int status; -}; - - -#include <itkMultiThreader.h> - -extern "C" int luaopen_otbApplication ( lua_State* L ); - -static int pmain (lua_State *L) { - struct Smain *s = (struct Smain *)lua_touserdata(L, 1); - char **argv = s->argv; - int script; - int has_i = 0, has_v = 0, has_e = 0; - globalL = L; - if (argv[0] && argv[0][0]) progname = argv[0]; - lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ - luaL_openlibs(L); /* open libraries */ - - // Insert our custom code - luaopen_otbApplication(L); - - lua_gc(L, LUA_GCRESTART, 0); - s->status = handle_luainit(L); - if (s->status != 0) return 0; - script = collectargs(argv, &has_i, &has_v, &has_e); - if (script < 0) { /* invalid args? */ - print_usage(); - s->status = 1; - return 0; - } - if (has_v) print_version(); - s->status = runargs(L, argv, (script > 0) ? script : s->argc); - if (s->status != 0) return 0; - - // See if we have OMP_NUM_THREADS set, and if so, make ITK obey - std::string NumThreads; - if ( itksys::SystemTools::GetEnv ( "OMP_NUM_THREADS", NumThreads ) ) { - itk::MultiThreader::SetGlobalDefaultNumberOfThreads ( atoi ( NumThreads.c_str() ) ); - } - - if (script) - s->status = handle_script(L, argv, script); - if (s->status != 0) return 0; - if (has_i) - dotty(L); - else if (script == 0 && !has_e && !has_v) { - if (lua_stdin_is_tty()) { - print_version(); - dotty(L); - } - else dofile(L, NULL); /* executes stdin as a file */ - } - return 0; -} - - -int main (int argc, char **argv) { - int status = 0; - - struct Smain s; - lua_State *L = lua_open(); /* create state */ - if (L == NULL) { - l_message(argv[0], "cannot create state: not enough memory"); - return EXIT_FAILURE; - } -#ifdef USE_TECLA - // Initialize Tecla - gl = new_GetLine(16*1024, 2048); - gl_configure_getline ( gl, "", "", "~/.otbApplicationLua" ); - gl_load_history ( gl, "~/.otbApplication.history", "--" ); -#endif - - - s.argc = argc; - s.argv = argv; - try { - status = lua_cpcall(L, &pmain, &s); - report(L, status); - lua_close(L); - } catch (...) {} - -#ifdef USE_TECLA - gl_save_history ( gl, "~/.otbApplication.history", "--", 1000 ); - del_GetLine ( gl ); -#endif - return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; -} - - diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index e7815e818e73fbf246819fd7ae5af58d4c015079..bd8070c1c6eecdcf6b3a75588cd089ac91da989c 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,3 +1,61 @@ +OTB-v.5.10.0 - Changes since version 5.8.0 (February 14th, 2017) +--------------------------------------------------------------- + +* Request for Changes (http://wiki.orfeo-toolbox.org/index.php/Requests_for_Changes): + * Request for Changes-69: Force Monteverdi no-GLSL option (adopted, merged) + * Request for Changes-70: Composite application framework (adopted, merged) + * Request for Changes-71: Enhance class field selection in training applications (adopted, merged) + * Request for Changes-72: Remove JPEG2000ImageIO (adopted, merged) + * Request for Changes-73: Compatibility with muparserx 4.0.7 (last stable release) (adopted, merged) + * Request for Changes-74: Translate the application GUI to the corresponding command line (adopted, merged) + * Request for Changes-75: Monteverdi/App November code sprint (adopted, merged) + * Request for Changes-76: Single band color-mapping in Monteverdi (adopted, merged) + * Request for Changes-77: New application for wavelet and fft domain transform (adopted, merged) + * Request for Changes-78: Refactor TrainImagesClassifier (adopted, merged) + * Request for Changes-79: BundleToPerfectSensor implemented as composite application (adopted, merged) + * Request for Changes-80: Compute sub-sampled Haralick textures (adopted, merged) + +* Bugfixes : + + * Monteverdi + * 0001351: Broken 5.10 standalone package on Linux (missing libstdc++) + * 0001334: On Windows standalone package, selection and drag&drop is broken on Monteverdi layer stack + * 0001338: Monteverdi does not correctly free memory + * 0001345: Wrong behavior of minimum image size for overviews in preference dialog + * 0001320: Pixel picking in Monteverdi is half-pixel shifted + * 0001309: Monteverdi 5.8: cannot drag and drop filename to OTB app + + * OTB-Packaging + * 0001361: _dl_close error message in Linux standalone package when closing the application + * 0001357: segfault when loading OTB applications in linux standalone package + * 0001356: Linux package requires OTB_USE_SYSTEM_GTK=1 on CentOS 7 + * 0001355: Patch to set OTB_APPLICATION_PATH environment variable in monteverdi desktop file + * 0001335: On Windows standalone package, TOC calibration crashes monteverdi + * 0001326: OTB python bindings does not work + * 0001336: setup.sh is missing in Windows standalone packages + * 0001337: On windows standalone package otbcli.bat misses the GDAL_DATA environment variable + * 0001325: libsvm URL in superbuild does not exists anymore + + * OTB-applications + * 0001341: Rescale application does not exactly rescale image + * 0001339: ExtractROI application yields wrong size through python bindings + * 0001321: Unable to apply radiometric calibration to S1A SLC product + * 0001316: Application parameter of type ListView are not export in XML + + * Orfeo Toolbox (OTB) + * 0001317: cmake c and cxx flags are not written in OTBConfig.cmake or UseOTB.cmake + * 0001323: Install monteverdi icons along with the application. + * 0001342: Download of libsvm is failing when (super)building + * 0001331: TrainVectorClassifier: misleading error message + * 0001330: Superbuild crashes with invalid libSVM source link + * 0001327: Quicklook application introduces a shift + * 0001328: OTB 5.8 : superImpose introduce "NODATA" + * 0001319: OTB 5.8 vector Sampler + * 0001324: Add Keywords to desktop entry file. + + * Documentation + * 0001313: Some latex fragments are not rendered in RST cookbook + OTB-v.5.8.0 - Changes since version 5.6.1 (November 8th, 2016) -------------------------------------------------------------- diff --git a/SuperBuild/CMake/External_gdal.cmake b/SuperBuild/CMake/External_gdal.cmake index d8db8f1e3fc4fe7494921b5fa82b994e6151fc26..c4f3f08f02c965ca82d846ac294d04800fc3cad3 100644 --- a/SuperBuild/CMake/External_gdal.cmake +++ b/SuperBuild/CMake/External_gdal.cmake @@ -20,12 +20,12 @@ set(GDAL_CONFIGURE_COMMAND) set(GDAL_BUILD_COMMAND) set(GDAL_INSTALL_COMMAND) + if(UNIX) set(GDAL_SB_EXTRA_OPTIONS "" CACHE STRING "Extra options to be passed to GDAL configure script") mark_as_advanced(GDAL_SB_EXTRA_OPTIONS) #Convert GDAL_SB_EXTRA_OPTIONS to a list to allow to add multiple instructions to the CONFIGURE_COMMAND separate_arguments(GDAL_SB_EXTRA_OPTIONS) - #we don't do any framework build on osx. So let's be sure on case of gdal if(APPLE) list(APPEND GDAL_SB_CONFIG "--with-macosx-framework=no") @@ -42,9 +42,7 @@ if(UNIX) endif() set(GDAL_CONFIGURE_COMMAND "${SB_ENV_CONFIGURE_CMD};${GDAL_SB_SRC}/configure" - --prefix=${SB_INSTALL_PREFIX} - --enable-static=no - --enable-shared=yes + ${SB_CONFIGURE_ARGS} --with-cfitsio=no --with-dods-root=no --with-dwgdirect=no diff --git a/SuperBuild/CMake/External_geotiff.cmake b/SuperBuild/CMake/External_geotiff.cmake index dd6424936845e07a2903122ceea39f0b5305528c..3a0f3e38739c712ae9659b6a42395197aed3e14b 100644 --- a/SuperBuild/CMake/External_geotiff.cmake +++ b/SuperBuild/CMake/External_geotiff.cmake @@ -36,11 +36,8 @@ if(UNIX) CONFIGURE_COMMAND ${SB_ENV_CONFIGURE_CMD} ${GEOTIFF_SB_SRC}/configure - --prefix=${SB_INSTALL_PREFIX} - --enable-static=no + ${SB_CONFIGURE_ARGS} ${GEOTIFF_SB_CONFIG} - BUILD_COMMAND $(MAKE) - INSTALL_COMMAND $(MAKE) install LOG_BUILD 1 LOG_INSTALL 1 ) diff --git a/SuperBuild/CMake/External_glew.cmake b/SuperBuild/CMake/External_glew.cmake index 8673593e85e5c7e134c680fe911a3edbda990c78..15497200c7e38efb6a97020f2dee2db0895f2037 100644 --- a/SuperBuild/CMake/External_glew.cmake +++ b/SuperBuild/CMake/External_glew.cmake @@ -13,6 +13,8 @@ ExternalProject_Add(GLEW CONFIGURE_COMMAND ${SB_CMAKE_COMMAND} ${SB_CMAKE_CACHE_ARGS} -DBUILD_UTILS:BOOL=OFF ${GLEW_SB_SRC}/build/cmake/ ) +SUPERBUILD_PATCH_SOURCE(GLEW) + set(_SB_GLEW_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) if(WIN32) set(_SB_GLEW_LIBRARY ${SB_INSTALL_PREFIX}/lib/glew32.lib) diff --git a/SuperBuild/CMake/External_itk.cmake b/SuperBuild/CMake/External_itk.cmake index 8f0c9e404ab39d46206ccc2d57e23b3f7f79c893..92e674a38f62c4a24731875bf3bc1ab9327777b5 100644 --- a/SuperBuild/CMake/External_itk.cmake +++ b/SuperBuild/CMake/External_itk.cmake @@ -164,11 +164,3 @@ ExternalProject_Add(ITK SUPERBUILD_PATCH_SOURCE(ITK) -set(DIR_LIST "${SB_INSTALL_PREFIX}/lib/cmake/ITK-4.10|${SB_INSTALL_PREFIX}/lib/cmake/ITK-4.10/Modules") -ExternalProject_Add_Step(ITK POST_INSTALL - COMMAND ${CMAKE_COMMAND} - -DP_DIRS=${DIR_LIST} - -DP_MATCH=${SB_INSTALL_PREFIX} - -DP_REPLACE=ITK_INSTALL_PREFIX - -P ${CMAKE_SOURCE_DIR}/CMake/post_install.cmake - DEPENDEES install) diff --git a/SuperBuild/CMake/External_qt4.cmake b/SuperBuild/CMake/External_qt4.cmake index 639734156bf662ef445d3e7c6580bf36d1ddfc9c..cffeefa9231eb2f02a4235a6e6d2c37d702e1ecc 100644 --- a/SuperBuild/CMake/External_qt4.cmake +++ b/SuperBuild/CMake/External_qt4.cmake @@ -11,7 +11,7 @@ SETUP_SUPERBUILD(QT4) # endif() -option(QT4_SB_ENABLE_GTK "Enable GTK+ style with qt using -gtkstlye. Default is OFF" OFF) +set(QT4_SB_ENABLE_GTK OFF CACHE INTERNAL "Enable GTK+ style with qt using -gtkstlye. Default is OFF") if(NOT DEFINED git_protocol) set(git_protocol "git") @@ -34,7 +34,8 @@ if(UNIX) set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -no-framework") else() #Linux if(QT4_SB_ENABLE_GTK) - message(STATUS "QT4_SB_ENABLE_GTK is activated. QT4 build includes gtk+ and libfreetype, libpng (dependencies of gtk+ package)") + message(WARNING "QT4_SB_ENABLE_GTK support is experimental") + set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -sm -xrender -xrandr -gtkstyle") else() set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -no-gtkstyle") @@ -64,6 +65,10 @@ else() set(QT4_CONFIGURE_COMMAND_IN ${CMAKE_SOURCE_DIR}/patches/QT4/configure_qt4.sh.in) endif() +if(EXISTS "${QT4_CONFIGURE_COMMAND}") + execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f "${QT4_CONFIGURE_COMMAND}") +endif() + configure_file(${QT4_CONFIGURE_COMMAND_IN} ${QT4_CONFIGURE_COMMAND} @ONLY ) #Remove left over or previous installation from install prefix. diff --git a/SuperBuild/CMake/External_zlib.cmake b/SuperBuild/CMake/External_zlib.cmake index c86bd4a25089e30e7eddf853c5176019d8d85a21..dc15d5770feb39c84bbe856ba52a5324f8a8d93f 100644 --- a/SuperBuild/CMake/External_zlib.cmake +++ b/SuperBuild/CMake/External_zlib.cmake @@ -27,6 +27,8 @@ if(MSVC) DEPENDEES install) endif() +SUPERBUILD_PATCH_SOURCE(ZLIB) + set(_SB_ZLIB_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) if(WIN32) set(_SB_ZLIB_LIBRARY ${SB_INSTALL_PREFIX}/lib/zdll.lib) diff --git a/SuperBuild/CMake/post_install.cmake b/SuperBuild/CMake/post_install.cmake index e211e653fdbdc1cd8547569ff119dd4cc35d76b0..603c8c24e5b86fbd4f1266a9a06d9c7642a961ef 100644 --- a/SuperBuild/CMake/post_install.cmake +++ b/SuperBuild/CMake/post_install.cmake @@ -1,11 +1,22 @@ +#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 "${MATCH}") + + file(STRINGS "${cmake_file}" MATCH_FOUND REGEX "${P_MATCH}") if(MATCH_FOUND) + message("Replacing '${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. diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index b5a660fa5dbc2e6ee38c291c5ed56a912a939428..4398c001576ce4eec9500a8c18d5bdeacaebcbe9 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -69,7 +69,7 @@ endif() option(BUILD_EXAMPLES " Build the OTB Examples directory" OFF) option(USE_DEFAULT_INSTALL_PREFIX "Install superbuild to default prefix /usr/local for unix" OFF) - + #get version of OTB from source_dir/CMakeLists.txt get_version( INPUT_FILE "${CMAKE_SOURCE_DIR}/../CMakeLists.txt" @@ -175,6 +175,12 @@ else() list(APPEND SB_CONFIGURE_ARGS "--enable-shared=no") endif() +if(CMAKE_BUILD_TYPE MATCHES "Debug") + list(APPEND SB_CONFIGURE_ARGS "--enable-debug=yes") +else() + list(APPEND SB_CONFIGURE_ARGS "--enable-debug=no") +endif() + if(UNIX) if(APPLE) set(SB_CMAKE_COMMAND env CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} ${CMAKE_COMMAND} ${SB_CMAKE_ARGS}) diff --git a/SuperBuild/Packaging/CMakeLists.txt b/SuperBuild/Packaging/CMakeLists.txt index 3d48cda512f907348364e09d347afc54017b40ee..ce9f3eeb6d4f0cdc5f7e120557a30bf08fa99c6c 100644 --- a/SuperBuild/Packaging/CMakeLists.txt +++ b/SuperBuild/Packaging/CMakeLists.txt @@ -124,7 +124,14 @@ set(CMAKE_INSTALL_PREFIX "${SUPERBUILD_INSTALL_DIR}") set(PACKAGE_LONG_NAME OrfeoToolBox) # Make up part of output package file +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) diff --git a/SuperBuild/Packaging/CreateCMakeProjects.cmake b/SuperBuild/Packaging/CreateCMakeProjects.cmake index b21a95cb0df62f9068216b955aa09017db41679b..69649513442b7122cf8484203ab13abd24e64cb1 100644 --- a/SuperBuild/Packaging/CreateCMakeProjects.cmake +++ b/SuperBuild/Packaging/CreateCMakeProjects.cmake @@ -30,6 +30,7 @@ macro(macro_setup_cmake_project pkg) include(CMakeDetermineSystem) set(CMAKE_BUILD_TYPE Release) set(PACKAGE_OTB_SRC_DIR \"${PACKAGE_OTB_SRC_DIR}\") + set(SUPERBUILD_BINARY_DIR \"${SUPERBUILD_BINARY_DIR}\") set(OTB_BINARY_DIR \"${OTB_BINARY_DIR}\") set(OTB_INSTALL_DIR \"${OTB_INSTALL_DIR}\") set(QT_PLUGINS_DIR \"${QT_PLUGINS_DIR}\") @@ -58,12 +59,16 @@ macro(macro_setup_cmake_project pkg) macro_super_package(STAGE_DIR \"${archive_name}\")" ) +set(README_FILE_SUFFIX) +if(PKG_GENERATE_XDK) + set(README_FILE_SUFFIX "_xdk") +endif() if(APPLE) - set(README_FILE ${PACKAGE_OTB_SRC_DIR}/Documentation/Cookbook/rst/Installation_Macx.txt) + set(README_FILE ${PACKAGE_OTB_SRC_DIR}/Documentation/Cookbook/rst/Installation_Macx${README_FILE_SUFFIX}.txt) elseif(LINUX) #not osx - set(README_FILE ${PACKAGE_OTB_SRC_DIR}/Documentation/Cookbook/rst/Installation_Linux.txt) + set(README_FILE ${PACKAGE_OTB_SRC_DIR}/Documentation/Cookbook/rst/Installation_Linux${README_FILE_SUFFIX}.txt) elseif(WIN32) #windows - set(README_FILE ${PACKAGE_OTB_SRC_DIR}/Documentation/Cookbook/rst/Installation_Windows.txt) + set(README_FILE ${PACKAGE_OTB_SRC_DIR}/Documentation/Cookbook/rst/Installation_Windows${README_FILE_SUFFIX}.txt) endif() configure_file( diff --git a/SuperBuild/Packaging/Files/linux_pkgsetup.in b/SuperBuild/Packaging/Files/linux_pkgsetup.in index 7b4b6b8237cf1b157957aeed5f026cd67db2c981..98e060f50a62045b1d51137e6dfc681c5ed2ede8 100644 --- a/SuperBuild/Packaging/Files/linux_pkgsetup.in +++ b/SuperBuild/Packaging/Files/linux_pkgsetup.in @@ -73,12 +73,12 @@ cat > "$OUT_DIR/otbenv.profile" << EOF # unset any existing LD_LIBRARY_PATH unset LD_LIBRARY_PATH -# if OTB_USE_SYSTEM_GTK is not set or is set to zero, +# if OTB_USE_LOCAL_GTK is set to one, # we must include <OUT_DIR>/lib/gtk because glib files are # installed there. -# OTB_USE_SYSTEM_GTK is not set by default -if [ -z "\$OTB_USE_SYSTEM_GTK" ] || [ "\$OTB_USE_SYSTEM_GTK" = "0" ]; then +# OTB_USE_LOCAL_GTK is not set by default (use GTK system) +if [ "\$OTB_USE_LOCAL_GTK" = "1" ]; then LD_LIBRARY_PATH=$OUT_DIR/lib/gtk export LD_LIBRARY_PATH fi @@ -121,6 +121,43 @@ EOF chmod +x "$OUT_DIR/otbenv.profile" +else + +cat > "$OUT_DIR/xdkenv.profile" << EOF +#!/bin/sh + +# The below environment variables only affect current shell +# So if you run again from a terminal. you need to run the script again + +# unset any existing LD_LIBRARY_PATH +unset LD_LIBRARY_PATH + +# Add bin direcotory to system PATH +PATH=$OUT_DIR/bin:\$PATH + +# set numeric locale to C +LC_NUMERIC=C + +# set GDAL_DATA variable used by otb application +GDAL_DATA=$OUT_DIR/share/gdal + +# set GEOTIFF_CSV variable used by otb application +GEOTIFF_CSV=$OUT_DIR/share/epsg_csv + +CMAKE_PREFIX_PATH=$OUT_DIR + +# export variables +export LC_NUMERIC +export GDAL_DATA +export GEOTIFF_CSV +export CMAKE_PREFIX_PATH +export PATH + +EOF + + +chmod +x "$OUT_DIR/xdkenv.profile" + fi #echo "Creating symbolic links..." @@ -149,7 +186,7 @@ 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 occured during installation******" + 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." @@ -188,7 +225,7 @@ if [ "$found_python_lib" -eq "1" ]; then printf %s\\n "To test OTB python bindings:" printf %s\\n "$OTB_PYTHON_EXE -c 'import otbApplication'" else - printf %s\\n "*****Error occured during installation******" + 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" diff --git a/SuperBuild/Packaging/Files/macx_pkgsetup.in b/SuperBuild/Packaging/Files/macx_pkgsetup.in index 2fda1e5436ae0b679ff868a8867b120927750f80..c196337ae9982275d74a76a3d5589fb29e5b67a8 100755 --- a/SuperBuild/Packaging/Files/macx_pkgsetup.in +++ b/SuperBuild/Packaging/Files/macx_pkgsetup.in @@ -140,7 +140,7 @@ EOF cat > "$OUT_DIR/otbenv.profile" << EOF #!/bin/sh -PATH=\$PATH:$OUT_DIR/bin +PATH=$OUT_DIR/bin:\$PATH PYTHONPATH=$OUT_DIR/lib/python:\$PYTHONPATH GDAL_DATA=$OUT_DIR/share/gdal GEOTIFF_CSV=$OUT_DIR/share/epsg_csv diff --git a/SuperBuild/Packaging/Files/otbenv.profile b/SuperBuild/Packaging/Files/otbenv.bash similarity index 52% rename from SuperBuild/Packaging/Files/otbenv.profile rename to SuperBuild/Packaging/Files/otbenv.bash index ac6e35ff54d5378257b4e3a25c6c5acab7039ecf..4cc55aeb4034a77fd704fd76e25a5f944d3861f2 100644 --- a/SuperBuild/Packaging/Files/otbenv.profile +++ b/SuperBuild/Packaging/Files/otbenv.bash @@ -1,17 +1,13 @@ -#!/bin/sh +#!/usr/bin/env bash -DIRNAME_0=$(dirname "$0") -cd "$DIRNAME_0" - -CURRENT_DIR=$(pwd) +CURRENT_DIR=$(cd -P -- "$(dirname -- "$BASH_SOURCE")" && printf '%s\n' "$(pwd -P)") unset LD_LIBRARY_PATH -PATH=$PATH:$CURRENT_DIR/bin +PATH=$CURRENT_DIR/bin:$PATH GDAL_DATA=$CURRENT_DIR/share/gdal GEOTIFF_CSV=$CURRENT_DIR/share/epsg_csv export PATH export GDAL_DATA export GEOTIFF_CSV - diff --git a/SuperBuild/Packaging/Files/otbenv.cmd b/SuperBuild/Packaging/Files/otbenv.cmd index 493cfbde9719b9e0eb2f064022a58703961a4bc6..e7f605870e79019a5bafb0b018ed3164c355df86 100644 --- a/SuperBuild/Packaging/Files/otbenv.cmd +++ b/SuperBuild/Packaging/Files/otbenv.cmd @@ -1,6 +1,6 @@ set CURRENT_SCRIPT_DIR=%~dp0 -set PATH=%PATH%;%CURRENT_SCRIPT_DIR%\bin +set PATH=%CURRENT_SCRIPT_DIR%\bin;%PATH% set GDAL_DATA=%CURRENT_SCRIPT_DIR%\share\gdal diff --git a/SuperBuild/Packaging/InstallSupportFiles.cmake b/SuperBuild/Packaging/InstallSupportFiles.cmake index dab10f56ac31f1796e57804e79a6c2b669255971..cd3b76d5b59c7af029b621e560cca8513d44b082 100644 --- a/SuperBuild/Packaging/InstallSupportFiles.cmake +++ b/SuperBuild/Packaging/InstallSupportFiles.cmake @@ -47,10 +47,47 @@ function(func_install_xdk_files) endif() endforeach() - file(GLOB ITK_CMAKE_DIRS "${DEPENDENCIES_INSTALL_DIR}/lib/cmake/ITK*") - foreach(ITK_CMAKE_DIR ${ITK_CMAKE_DIRS}) - func_install_without_message("${ITK_CMAKE_DIR}" "lib/cmake") - endforeach() + set(ITK_CMAKE_DIR "${DEPENDENCIES_INSTALL_DIR}/lib/cmake/ITK-${PKG_ITK_SB_VERSION}") + message("COPY ${DEPENDENCIES_INSTALL_DIR}/lib/cmake/ITK-${PKG_ITK_SB_VERSION} to ${CMAKE_CURRENT_BINARY_DIR}/_tmp/ to patch") + execute_process( + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/_tmp/ + COMMAND ${CMAKE_COMMAND} + -E copy_directory + ${ITK_CMAKE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/_tmp/ITK-${PKG_ITK_SB_VERSION} + ) + + #reset ITK_CMAKE_DIR + set(ITK_CMAKE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_tmp/ITK-${PKG_ITK_SB_VERSION}") + + set(DIR_LIST "${CMAKE_CURRENT_BINARY_DIR}/_tmp/ITK-${PKG_ITK_SB_VERSION}|${CMAKE_CURRENT_BINARY_DIR}/_tmp/ITK-${PKG_ITK_SB_VERSION}/Modules") + + #SUPERBUILD_INSTALL_DIR + execute_process( + COMMAND ${CMAKE_COMMAND} + -DP_DIRS=${DIR_LIST} + -DP_MATCH=${CMAKE_INSTALL_PREFIX} + -DP_REPLACE=ITK_INSTALL_PREFIX + -P ${PACKAGE_OTB_SRC_DIR}/SuperBuild/CMake/post_install.cmake + RESULT_VARIABLE patch_itk_cmake_rv + ) + + file(STRINGS "${SUPERBUILD_BINARY_DIR}/ITK/build/CMakeCache.txt" + MATCH_FOUND REGEX "ITK_USE_SYSTEM_ZLIB:BOOL=ON") + if(MATCH_FOUND) + find_package(ZLIB QUIET) + get_filename_component(ZLIB_PREFIX ${ZLIB_LIBRARY} PATH) + execute_process( + COMMAND ${CMAKE_COMMAND} + -DP_DIRS=${DIR_LIST} + -DP_MATCH=${ZLIB_PREFIX} + -DP_REPLACE=ITK_INSTALL_PREFIX + -P ${PACKAGE_OTB_SRC_DIR}/SuperBuild/CMake/post_install.cmake + ) + + endif() + + func_install_without_message("${ITK_CMAKE_DIR}" "lib/cmake") set(QT_REQ_DIRS) if(WIN32) @@ -227,16 +264,18 @@ function(func_install_otb_support_files) set(PKG_SHARE_SOURCE_DIR ${DEPENDENCIES_INSTALL_DIR}/share) #For Unixes we make them in the *pkgsetup.in - ##################### install environment source ########################## + ##################### install environment setup file ########################## if(WIN32) - foreach(ENV_SOURCE_FILE - "${PACKAGE_SUPPORT_FILES_DIR}/otbenv.cmd" - "${PACKAGE_SUPPORT_FILES_DIR}/otbenv.profile") - if(EXISTS ${ENV_SOURCE_FILE}) - install(FILES ${ENV_SOURCE_FILE} DESTINATION ${PKG_STAGE_DIR}) - endif() - endforeach() + install( + FILES ${PACKAGE_SUPPORT_FILES_DIR}/otbenv.cmd + DESTINATION ${PKG_STAGE_DIR} + ) + install( + FILES ${PACKAGE_SUPPORT_FILES_DIR}/otbenv.bash + DESTINATION ${PKG_STAGE_DIR} + ) + #we need startup files for mapla monteverdi in the root directory #For Unixes, we make them inside pkgsetup script! foreach(exe_file mapla monteverdi) @@ -290,6 +329,7 @@ function(func_install_monteverdi_support_files) # we find this value by parsing ConfigureMonteverdi.h set(ConfigureMonteverdi_H "${OTB_BINARY_DIR}/Modules/Visualization/MonteverdiCore/ConfigureMonteverdi.h") if(NOT EXISTS "${ConfigureMonteverdi_H}") + #maybe deactivate monteverdi? message(FATAL_ERROR "${ConfigureMonteverdi_H} does not exists. Cannot continue") endif() diff --git a/SuperBuild/Packaging/PackageGlobals.cmake b/SuperBuild/Packaging/PackageGlobals.cmake index d59c32f730d97b30baa6ec8155d2154f89d9abdc..863fb92c2f174c2b9ab8529c2c3c663beedc2096 100644 --- a/SuperBuild/Packaging/PackageGlobals.cmake +++ b/SuperBuild/Packaging/PackageGlobals.cmake @@ -68,7 +68,9 @@ set(LINUX_SYSTEM_DLLS libICE.so* libXrandr.so* libpython* - libexpat.so.0 + libexpat.so.* + libfontconfig.so* + libfreetype.so* ) # libgcc_s.*dylib and other *.framework are dragged by QT @@ -119,12 +121,18 @@ set(PKG_GTK_SEARCHDIRS # 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(ALLOWED_SYSTEM_DLLS - libfreetype.so.6.* + +set(GTK_LIB_LIST_1 libgthread-2.0.so.0 libglib-2.0.so.0 libgobject-2.0.so.0 libXrender.so.1 - libfontconfig.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}) diff --git a/SuperBuild/Packaging/PackageHelper.cmake b/SuperBuild/Packaging/PackageHelper.cmake index 88061550968272491accd8c33299514e2c6eaa29..dd42ddf4b43759c50821f518bf740bbf6c1bd9b5 100644 --- a/SuperBuild/Packaging/PackageHelper.cmake +++ b/SuperBuild/Packaging/PackageHelper.cmake @@ -105,7 +105,7 @@ macro(macro_super_package) "UniversalCRTSdkDir variable not set. call vcvarsall.bat <arch> first before starting build.") endif() - #addtional msvc redist dll from VCINSTALLDIR + #additional msvc redist dll from VCINSTALLDIR if(DEFINED ENV{VCINSTALLDIR}) file(TO_CMAKE_PATH "$ENV{VCINSTALLDIR}" PKG_VCINSTALLDIR) list( @@ -224,8 +224,6 @@ endmacro(macro_super_package) function(func_prepare_package) - - file(WRITE ${CMAKE_BINARY_DIR}/make_symlinks_temp "") #This must exist in any OTB Installation. minimal or full @@ -331,7 +329,9 @@ endfunction() #func_prepare_package function(func_process_deps input_file) + set(input_file_full_path) search_library(${input_file} PKG_SEARCHDIRS input_file_full_path) + if(NOT input_file_full_path) if(LINUX) setif_value_in_list(is_gtk_lib "${input_file}" ALLOWED_SYSTEM_DLLS) @@ -348,11 +348,15 @@ function(func_process_deps input_file) endif() #if(NOT input_file_full_path) - message("Processing ${input_file_full_path}") + if(NOT PKG_DEBUG) + message("Processing ${input_file_full_path}") + endif() set(is_executable FALSE) - is_file_executable2("${input_file_full_path}" is_executable) + is_file_executable2(input_file_full_path is_executable) + if(NOT is_executable) + #copy back to input_file_full_path pkg_install_rule(${input_file_full_path}) message("not is_executable ${input_file_full_path}") return() @@ -377,23 +381,23 @@ function(func_process_deps input_file) OR IS_DIRECTORY "${sofile}" ) set(not_valid TRUE) endif() - + if(not_valid) continue() endif() - + func_is_file_a_symbolic_link("${sofile}" is_symlink linked_to_file) - + if(is_symlink) add_to_symlink_list("${linked_to_file}" "${basename_of_sofile}") endif() # is_symlink - + endforeach() - + endif(UNIX) - + set(raw_items) - + execute_process( COMMAND ${LOADER_PROGRAM} ${LOADER_PROGRAM_ARGS} "${input_file_full_path}" RESULT_VARIABLE loader_rv @@ -411,10 +415,15 @@ function(func_process_deps input_file) 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_program_regex}") continue() endif() @@ -424,25 +433,25 @@ function(func_process_deps input_file) 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}") + string(REGEX REPLACE "@rpath." "" raw_item "${raw_item}") else() - message(FATAL_ERROR "'${raw_item}' does not have @rpath") + message(FATAL_ERROR "'${raw_item}' does not have @rpath") endif() endif() - - if(is_system OR ${raw_item}_RESOLVED OR ${raw_item}_USED) - continue() + + 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} is not resolved, used. ${raw_item}_RESOLVED | ${raw_item}_USED") + + if(is_system OR ${raw_item}_RESOLVED OR ${raw_item}_USED) + continue() endif() list(APPEND raw_items ${raw_item}) @@ -451,7 +460,7 @@ function(func_process_deps input_file) if(PKG_DEBUG) string(REPLACE ";" "\n" raw_items_pretty_print "${raw_items}") - message(FATAL_ERROR "raw_items=${raw_items_pretty_print}") + # message(FATAL_ERROR "raw_items=${raw_items_pretty_print}") endif(PKG_DEBUG) if(raw_items) @@ -460,25 +469,25 @@ function(func_process_deps input_file) search_library(${item} PKG_SEARCHDIRS item_full_path) set(is_a_symlink FALSE) set(item_target_file) - if(PKG_DEBUG) - message("item0=${item_full_path}") - endif() func_is_file_a_symbolic_link("${item_full_path}" is_a_symlink item_target_file) if(is_a_symlink) - set(${item}_RESOLVED TRUE CACHE INTERNAL "") - set(item ${item_target_file}) + set(${item}_RESOLVED TRUE CACHE INTERNAL "") + set(item ${item_target_file}) endif() if(PKG_DEBUG) - message("running func_process_deps on '${item}'") + message("${bn_name} depends on '${item}'. So we now process '${item}'") # [ ${item}_USED=${${item}_USED} ${item}_RESOLVED=${${item}_RESOLVED}]") endif() func_process_deps(${item}) - endforeach() -endif() - -set(${bn_name}_RESOLVED TRUE CACHE INTERNAL "") + endforeach() + endif() -pkg_install_rule(${input_file_full_path}) + 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 the file with pkg_install_rule. This function has specific rules to decide wheather install file or not + pkg_install_rule(${input_file_full_path}) endfunction() #function(func_process_deps infile) @@ -500,11 +509,15 @@ function(pkg_install_rule src_file) endif() set(SKIP_INSTALL FALSE) - setif_value_in_list(is_gtk_lib "${src_file_NAME}" ALLOWED_SYSTEM_DLLS) + + setif_value_in_list(is_gtk_lib "${src_file_NAME}" GTK_LIB_LIST_1) if(is_gtk_lib) - set(output_dir "lib/gtk") - set(SKIP_INSTALL TRUE) - endif() + if(PKG_GENERATE_XDK) + set(SKIP_INSTALL TRUE) + else() + set(output_dir "lib/gtk") + endif() #if(PKG_GENERATE_XDK) + endif() #if(is_gtk_lib) #special case if("${src_file_NAME}" MATCHES "^otbapp_") diff --git a/SuperBuild/Packaging/PackageMacros.cmake b/SuperBuild/Packaging/PackageMacros.cmake index 6a2084b8aa78c8ea6e620ff0d666db3ebfce7fc7..6a5ac835872e7ec892d6a82ed2984deb0b0bf2e3 100755 --- a/SuperBuild/Packaging/PackageMacros.cmake +++ b/SuperBuild/Packaging/PackageMacros.cmake @@ -55,7 +55,7 @@ function(search_library input_file pkg_searchdirs result) if(EXISTS ${pkg_searchdir}/${input_file} ) if(PKG_DEBUG) - message("searching for '${input_file}' in '${pkg_searchdir}'") + message("Found '${pkg_searchdir}/${input_file}' (return)") endif() set(${result} "${pkg_searchdir}/${input_file}" PARENT_SCOPE) return() @@ -71,44 +71,51 @@ function(search_library input_file pkg_searchdirs result) endfunction() -macro(add_to_symlink_list src_file target_file) +macro(add_to_symlink_list src_file_name link_file_name) #TODO: avoid code duplication here and later in install_rule set(SKIP_INSTALL FALSE) + + get_filename_component(src_file_name_NAME ${src_file_name} NAME) + if(PKG_GENERATE_XDK) - get_filename_component(src_file_NAME ${src_file} NAME) - setif_value_in_list(is_gtk_lib "${src_file_NAME}" ALLOWED_SYSTEM_DLLS) - if ("${src_file_NAME}" + if ("${src_file_name_NAME}" MATCHES "libOTB|libotb|otbApp|otbapp_|otbTest|libMonteverdi|monteverdi|mapla|iceViewer" ) set(SKIP_INSTALL TRUE) endif() - - if(is_gtk_lib) - set(SKIP_INSTALL TRUE) - endif() - endif(PKG_GENERATE_XDK) + + setif_value_in_list(is_gtk_lib "${src_file_name_NAME}" GTK_LIB_LIST_1) + if(is_gtk_lib AND PKG_GENERATE_XDK) + set(SKIP_INSTALL TRUE) + endif() + + # NOTE: $OUT_DIR is set actually in pkgsetup.in. So don't try # any pre-mature optimization on that variable names if(NOT SKIP_INSTALL) + + set(lib_dir "lib") + if(is_gtk_lib) + set(lib_dir "lib/gtk") + endif() file(APPEND ${CMAKE_BINARY_DIR}/make_symlinks_temp - "ln -sf \"$OUT_DIR/lib/${src_file}\" \"$OUT_DIR/lib/${target_file}\" \n" + "ln -sf \"$OUT_DIR/${lib_dir}/${src_file_name}\" \"$OUT_DIR/${lib_dir}/${link_file_name}\" \n" ) endif() endmacro() -function(is_file_executable2 file result_var) +function(is_file_executable2 file_var result_var) # # A file is not executable until proven otherwise: # set(${result_var} 0 PARENT_SCOPE) - get_filename_component(file_full "${file}" ABSOLUTE) + get_filename_component(file_full "${${file_var}}" ABSOLUTE) string(TOLOWER "${file_full}" file_full_lower) - # If file name ends in .exe on Windows, *assume* executable: # if(WIN32 AND NOT UNIX) @@ -125,9 +132,15 @@ function(is_file_executable2 file result_var) func_is_file_a_symbolic_link("${file_full}" is_a_symlink file_full_target) if(is_a_symlink) - message("resolving '${file_full}' to '${file_full_target}") + message("Resolving '${file_full}' to '${file_full_target}") get_filename_component(file_full_path "${file_full}" PATH) set(file_full "${file_full_path}/${file_full_target}") + if( EXISTS "${file_full}") + set(${file_var} "${file_full}" PARENT_SCOPE) + else() + message(FATAL_ERROR "${file_full} does not exists. Cannot continue") + endif() + string(TOLOWER "${file_full}" file_full_lower) endif() @@ -149,6 +162,7 @@ function(is_file_executable2 file result_var) if(NOT EXISTS "${file_full}") message(FATAL_ERROR "err. '${file_full}' does not exists or is not absolute path") + set(${file_var} "" PARENT_SCOPE) endif() execute_process(COMMAND "${FILE_COMMAND}" "${file_full}" diff --git a/SuperBuild/patches/GLEW/glew-1-fixes-all.diff b/SuperBuild/patches/GLEW/glew-1-fixes-all.diff new file mode 100644 index 0000000000000000000000000000000000000000..acbc34ec66119f9c5faaace851d1075b0cf6ae7c --- /dev/null +++ b/SuperBuild/patches/GLEW/glew-1-fixes-all.diff @@ -0,0 +1,15 @@ +diff -burN glew-1.13.0.orig/build/cmake/CMakeLists.txt glew-1.13.0/build/cmake/CMakeLists.txt +--- glew-1.13.0.orig/build/cmake/CMakeLists.txt Thu Feb 2 11:07:22 2017 ++++ glew-1.13.0/build/cmake/CMakeLists.txt Thu Feb 2 11:08:28 2017 +@@ -10,8 +10,9 @@ + cmake_policy (SET CMP0003 NEW) + endif() + +-set(CMAKE_DEBUG_POSTFIX d) +- ++############# OTB ############# ++#set(CMAKE_DEBUG_POSTFIX d) ++############# OTB ############# + option (BUILD_UTILS "utilities" ON) + + set (GLEW_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..) diff --git a/SuperBuild/patches/QT4/qt4-4-mantis1334-qpoint-initialization-all.diff b/SuperBuild/patches/QT4/qt4-4-mantis1334-qpoint-initialization-all.diff new file mode 100644 index 0000000000000000000000000000000000000000..d37eb1f13220801e1d35446b5c12d638774326b5 --- /dev/null +++ b/SuperBuild/patches/QT4/qt4-4-mantis1334-qpoint-initialization-all.diff @@ -0,0 +1,30 @@ +--- qt-everywhere-opensource-src-4.8.7.orig/src/gui/itemviews/qtreeview.cpp 2015-05-07 16:14:43.000000000 +0200 ++++ qt-everywhere-opensource-src-4.8.7/src/gui/itemviews/qtreeview.cpp 2017-02-07 15:30:57.463689900 +0100 +@@ -2261,10 +2261,23 @@ + return; + + d->executePostedLayout(); +- QPoint tl(isRightToLeft() ? qMax(rect.left(), rect.right()) +- : qMin(rect.left(), rect.right()), qMin(rect.top(), rect.bottom())); +- QPoint br(isRightToLeft() ? qMin(rect.left(), rect.right()) : +- qMax(rect.left(), rect.right()), qMax(rect.top(), rect.bottom())); ++ QPoint tl(rect.left(),rect.top()); ++ QPoint br(rect.right(),rect.bottom()); ++ if (isRightToLeft()) { ++ if (rect.left() < rect.right()) { ++ tl.setX(rect.right()); ++ br.setX(rect.left()); ++ } ++ } else { ++ if (rect.left() > rect.right()) { ++ tl.setX(rect.right()); ++ br.setX(rect.left()); ++ } ++ } ++ if (rect.bottom() < rect.top()) { ++ tl.setY(rect.bottom()); ++ br.setY(rect.top()); ++ } + QModelIndex topLeft = indexAt(tl); + QModelIndex bottomRight = indexAt(br); + if (!topLeft.isValid() && !bottomRight.isValid()) { diff --git a/SuperBuild/patches/ZLIB/zlib-1-debug_fixes-win.diff b/SuperBuild/patches/ZLIB/zlib-1-debug_fixes-win.diff new file mode 100644 index 0000000000000000000000000000000000000000..78ab8499cc2a38a4264007ab2e4eb00136a2b214 --- /dev/null +++ b/SuperBuild/patches/ZLIB/zlib-1-debug_fixes-win.diff @@ -0,0 +1,14 @@ +diff -burN zlib-1.2.8.orig/CMakeLists.txt zlib-1.2.8/CMakeLists.txt +--- zlib-1.2.8.orig/CMakeLists.txt Thu Feb 2 11:13:32 2017 ++++ zlib-1.2.8/CMakeLists.txt Thu Feb 2 11:14:53 2017 +@@ -60,7 +60,9 @@ + check_include_file(unistd.h Z_HAVE_UNISTD_H) + + if(MSVC) +- set(CMAKE_DEBUG_POSTFIX "d") ++ ############# OTB ############# ++ # set(CMAKE_DEBUG_POSTFIX d) ++ ############# OTB ############# + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/Utilities/Data/Icons/layer-delete.png b/Utilities/Data/Icons/layer-delete.png new file mode 100644 index 0000000000000000000000000000000000000000..7d6aaf6f257bee75a76325181f7a39b4b903034a Binary files /dev/null and b/Utilities/Data/Icons/layer-delete.png differ diff --git a/Utilities/Data/Icons/layer-delete_24x24.png b/Utilities/Data/Icons/layer-delete_24x24.png deleted file mode 100644 index bf57b112d72f6d8276168ff1ef39a2c0e7b63034..0000000000000000000000000000000000000000 Binary files a/Utilities/Data/Icons/layer-delete_24x24.png and /dev/null differ diff --git a/Utilities/Data/Icons/layers-remove_24x24.png b/Utilities/Data/Icons/layers-remove_24x24.png index 8e2713096c7071e7b38aa0bcfee465724e014780..2e2a29e433ed2b895c00fd32fb1dce53541efe1f 100644 Binary files a/Utilities/Data/Icons/layers-remove_24x24.png and b/Utilities/Data/Icons/layers-remove_24x24.png differ diff --git a/Utilities/Data/monteverdi.desktop b/Utilities/Data/monteverdi.desktop.in similarity index 70% rename from Utilities/Data/monteverdi.desktop rename to Utilities/Data/monteverdi.desktop.in index 2e791673b964a8fac739bdafbf2ca275a2a6e64e..ee8b5f1a2b74f5af426f794e7e6c9a2964795d3b 100644 --- a/Utilities/Data/monteverdi.desktop +++ b/Utilities/Data/monteverdi.desktop.in @@ -4,8 +4,8 @@ Name=Monteverdi Name[fr_FR]=Monteverdi GenericName=Image processing Comment=Remote sensing image processing application based on OrfeoToolbox -TryExec=/usr/bin/monteverdi -Exec=/usr/bin/monteverdi %F +TryExec=@CMAKE_INSTALL_PREFIX@/bin/monteverdi +Exec=env OTB_APPLICATION_PATH=@CMAKE_INSTALL_PREFIX@/@OTB_INSTALL_APP_DIR@ @CMAKE_INSTALL_PREFIX@/bin/monteverdi %F Terminal=false StartupNotify=false Icon=monteverdi diff --git a/i18n/fr_FR.ts b/i18n/fr_FR.ts index 3127cae92a120fc18d8369046efbb674cdb7cc47..1779a7ffbc860d921008dd0964a8fe7a195e7ae5 100644 --- a/i18n/fr_FR.ts +++ b/i18n/fr_FR.ts @@ -213,6 +213,46 @@ Veuillez, s'il vous plait, supprimer votre répertoire de cache Monteverdi. <source>512</source> <translation>512</translation> </message> + <message> + <source>Lookup table (jet)</source> + <translation>Table de couleur (jet)</translation> + </message> + <message> + <source>Local lookup table (jet)</source> + <translation>Table de couleur locale (jet)</translation> + </message> + <message> + <source>Lookup table (hot)</source> + <translation>Table de couleur (hot)</translation> + </message> + <message> + <source>Local lookup table (hot)</source> + <translation>Table de couleur locale (hot)</translation> + </message> + <message> + <source>Lookup table (winter)</source> + <translation>Table de couleur (winter)</translation> + </message> + <message> + <source>Local lookup table (winter)</source> + <translation>Table de couleur locale (winter)</translation> + </message> + <message> + <source>Lookup table (summer)</source> + <translation>Table de couleur (summer)</translation> + </message> + <message> + <source>Local lookup table (summer)</source> + <translation>Table de couleur locale (summer)</translation> + </message> + <message> + <source>Lookup table (cool)</source> + <translation>Table de couleur (cool)</translation> + </message> + <message> + <source>Local lookup table (cool)</source> + <translation>Table de couleur locale (cool)</translation> + </message> </context> <context> <name>mvd::AboutDialog</name> @@ -621,6 +661,10 @@ Veuillez, s'il vous plait, supprimer votre répertoire de cache Monteverdi. <source>Gamma: </source> <translation>Gamma : </translation> </message> + <message> + <source>Reset value to 1.</source> + <translation>Réinitialiser à 1.</translation> + </message> </context> <context> <name>mvd::ColorSetupController</name> @@ -1027,7 +1071,7 @@ Veuillez, s'il vous plait, supprimer votre répertoire de cache Monteverdi. </message> <message> <source>Zero relevant pixels found when computing histogram (probably because of no-data settings)</source> - <translation>Aucun pixel utilisable lors du calcul d'histogramme (probablement à cause des réglages no-data)</translation> + <translation>Aucun pixel utilisable lors du calcul d'histogramme (probablement à cause des réglages no-data)</translation> </message> </context> <context> @@ -1262,7 +1306,7 @@ Veuillez, s'il vous plait, supprimer votre répertoire de cache Monteverdi. </message> <message> <source>Cannot access settings file.</source> - <translation>Impossible d'accéder au fichiers des paramètres</translation> + <translation>Impossible d'accéder au fichiers des paramètres</translation> </message> <message> <source>Bad settings file format.</source> @@ -3614,11 +3658,11 @@ p, li { white-space: pre-wrap; } </message> <message> <source>I</source> - <translation>I</translation> + <translation type="obsolete">I</translation> </message> <message> <source>J</source> - <translation>J</translation> + <translation type="obsolete">J</translation> </message> <message> <source>Red</source> @@ -3640,6 +3684,14 @@ p, li { white-space: pre-wrap; } <source>Y</source> <translation>Y</translation> </message> + <message> + <source>Column</source> + <translation>Colonne</translation> + </message> + <message> + <source>Line</source> + <translation>Ligne</translation> + </message> </context> <context> <name>mvd::LayerStackWidget</name> @@ -3688,6 +3740,10 @@ p, li { white-space: pre-wrap; } <comment>Necessary for lupdate to be aware of C++ namespaces. Context comment for translator.</comment> <translation></translation> </message> + <message> + <source>Reset all layer effects to Normal</source> + <translation>Réinitialiser tous les effets à Normal</translation> + </message> </context> <context> <name>mvd::MainWindow</name> @@ -4080,6 +4136,14 @@ Charger '%1' provoquera l'affichage des couches dans une vue non <source>Ctrl+P</source> <translation>Ctrl+P</translation> </message> + <message> + <source>OpenGL texture</source> + <translation>Texture OpenGL</translation> + </message> + <message> + <source>Use OpenGL Shading Language (GLSL)</source> + <translation>Utiliser OpenGL Shading Language (GLSL)</translation> + </message> </context> <context> <name>mvd::MainWindowTitleLoader</name> @@ -4637,7 +4701,7 @@ Merci d'en sélectionner un autre.</translation> </message> <message> <source>mvd</source> - <translation>mvd</translation> + <translation type="obsolete">mvd</translation> </message> <message> <source>Rendering effects have been disabled because OpenGL Shading Language minimal requirements have not been met while running on this system.</source> @@ -4753,11 +4817,11 @@ Merci d'en sélectionner un autre.</translation> </message> <message> <source>Read tag '%1' does not match expected tag '%2'.</source> - <translation>L'étiquette lue '%1' ne correspond pas à l'étiquette attendue '%2'.</translation> + <translation>L'étiquette lue '%1' ne correspond pas à l'étiquette attendue '%2'.</translation> </message> <message> <source>Invalid tag name '%1'.</source> - <translation>Nom d'étiquette invalide '%1'.</translation> + <translation>Nom d'étiquette invalide '%1'.</translation> </message> <message> <source>Array dimension (%1) does not match expected dimension (%2).</source> @@ -4765,31 +4829,31 @@ Merci d'en sélectionner un autre.</translation> </message> <message> <source>Histogram sample count (%1) does not match written sample count (%2).</source> - <translation>Le nombre d'échantillons dans l'histrogramme (%1) ne correspond pas au nombre d'échantillons écrits (%2).</translation> + <translation>Le nombre d'échantillons dans l'histrogramme (%1) ne correspond pas au nombre d'échantillons écrits (%2).</translation> </message> <message> <source>Histogram mins dimension (%1) does not match expected dimension (%2).</source> - <translation>La taille des minima d'histogramme (%1) ne correspond pas à la taille attendue (%2).</translation> + <translation>La taille des minima d'histogramme (%1) ne correspond pas à la taille attendue (%2).</translation> </message> <message> <source>Histogram maxs dimension (%1) does not match expected dimension (%2).</source> - <translation>La taille des maxima d'histogramme (%1) ne correspond pas à la taille attendue (%2).</translation> + <translation>La taille des maxima d'histogramme (%1) ne correspond pas à la taille attendue (%2).</translation> </message> <message> <source>Histogram dimension (%1) does not match expected dimension (%2).</source> - <translation>La taille de l'histogramme (%1) ne correspond pas à la taille attendue (%2).</translation> + <translation>La taille de l'histogramme (%1) ne correspond pas à la taille attendue (%2).</translation> </message> <message> <source>Histogram bin count (%1) does not match expected bin count (%2).</source> - <translation>Le nombre de barres dans l'histogramme (%1) ne correspond pas à la valeur attendue (%2).</translation> + <translation>Le nombre de barres dans l'histogramme (%1) ne correspond pas à la valeur attendue (%2).</translation> </message> <message> <source>Histogram sample count (%1) does not match expected sample count (%2).</source> - <translation>Le nombre d'échantillons dans l'histogramme (%1) ne correspond pas à la valeur attendue (%2).</translation> + <translation>Le nombre d'échantillons dans l'histogramme (%1) ne correspond pas à la valeur attendue (%2).</translation> </message> <message> <source>Read sample count (histogram) (%1) does not match written sample count (%2).</source> - <translation>Le nombre d'échantillons lus (histrogramme) (%1) ne correspond pas au nombre d'échantillons écrits (%2).</translation> + <translation>Le nombre d'échantillons lus (histrogramme) (%1) ne correspond pas au nombre d'échantillons écrits (%2).</translation> </message> </context> <context>