diff --git a/CMakeLists.txt b/CMakeLists.txt index 899d6afaf4d6a0755963b9d0f6f89c65bc77bc3b..d3608f3e3237f4b5b416c688c621f7a5aa556c4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,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..a81d7f1f6f09f6740bee5b41fc1c4aff4515b6d0 --- /dev/null +++ b/Documentation/Cookbook/rst/Installation_Linux_xdk.txt @@ -0,0 +1,75 @@ +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. + +* If you need to activate Qt4 modules (Monteverdi, Ice, QtWidget, ApplicationEngine ..), you must set *QT_BINARY_DIR*. + +:: + + cd /opt/OTB/build && cmake -DOTB_USE_QT4=TRUE -DQT_BINARY_DIR=$CMAKE_PREFIX_PATH/bin + +This is because Qt tools ( moc, rcc, et al) are reported as not found by cmake due to incorrect path in "qmake -query" + + 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/CMakeLists.txt b/Documentation/SoftwareGuide/CMakeLists.txt index 8ca676e96b42411d54b9375542de593a20e55b71..7c77844ef9c5beb94ba6843d55ed923f10011e79 100644 --- a/Documentation/SoftwareGuide/CMakeLists.txt +++ b/Documentation/SoftwareGuide/CMakeLists.txt @@ -62,7 +62,7 @@ FIND_PATH(OTB_DATA_ROOT README-OTB-Data PATHS $ENV{OTB_DATA_ROOT} ${OTB_SOURCE_D FIND_PATH(OTB_DATA_LARGEINPUT_ROOT OTBData.readme PATHS $ENV{OTB_DATA_LARGEINPUT_ROOT}) IF( NOT OTB_DATA_LARGEINPUT_ROOT ) - MESSAGE(FATAL_ERROR "Large input directory is not set") + MESSAGE(FATAL_ERROR "Large input directory is not set and is mandatory to build the Software Guide.") ENDIF( NOT OTB_DATA_LARGEINPUT_ROOT ) # OTB_DATA_PATHS is searched recursively.. you need not enter sub-directories 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/Documentation/SoftwareGuide/Latex/WriteAnApplication.tex b/Documentation/SoftwareGuide/Latex/WriteAnApplication.tex index 6c04a8c1422903d190cb3e1a88539034f6263961..562f384ad7207a8788e44050f0ff8ff8494b54dc 100644 --- a/Documentation/SoftwareGuide/Latex/WriteAnApplication.tex +++ b/Documentation/SoftwareGuide/Latex/WriteAnApplication.tex @@ -150,7 +150,7 @@ name of the files to write, but they also encapsulate the corresponding writers. \section{Composite application} The application framework has been extended to allow the implementation of composite applications : -applications that use other applications. The concept is simple : you have two applications A and B +\textbf{applications that use other applications}. The concept is simple : you have two applications A and B that you want to chain in order to build a third application C. Rather than writing C by copying the code of A and B, you would like to re-use applications A and B. This plain example will be re-used in this section for explanations. @@ -231,7 +231,7 @@ with \code{b.in}. In this case, you have to manually call the writers of paramet \code{a.out}. \end{itemize} -At the moment, the connexion of vector data parameters is not supported. +At the moment, the in-memory connexion of vector data parameters is not supported. \subsection{Orchestration} @@ -242,8 +242,17 @@ parameter update. In the \code{DoExecute()} of your composite application, you have to call \code{ExecuteInternal()} in order to launch each internal application. The order should be compatible with -image parameter connexions. If you want to do "in-memory" connexions, you can to it between -two calls to \code{ExecuteInternal()}. +image parameter connexions. If you want to do "in-memory" connexions, you can do it between +two calls to \code{ExecuteInternal()}, for instance : + +\small +\begin{lstlisting} +ExecuteInternal("a"); +GetInternalApplication("b")->SetParameterInputImage("in", + GetInternalApplication("a")->GetParameterOutputImage("out")); +ExecuteInternal("b"); +\end{lstlisting} +\normalsize The application BundleToPerfectSensor is a simple example of composite applications. For a more complex example, you can check the application TrainImagesClassifier. diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRFeatureWrapper.txx b/Modules/Adapters/GdalAdapters/include/otbOGRFeatureWrapper.txx index 891b5ae37824461705b6a1dc0319257b02e815b0..51e17751fa024faccaea35086bfe95383eb01fb9 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRFeatureWrapper.txx +++ b/Modules/Adapters/GdalAdapters/include/otbOGRFeatureWrapper.txx @@ -42,6 +42,12 @@ using boost::interprocess::move; /*===========================================================================*/ /*================================[ Feature ]================================*/ /*===========================================================================*/ +inline +void otb::ogr::Feature::CheckInvariants() const +{ + assert(m_Feature && "OGRFeature can't be null"); +} + inline otb::ogr::Feature otb::ogr::Feature::Clone() const { @@ -199,11 +205,4 @@ void otb::ogr::Feature::PrintSelf(std::ostream & os, itk::Indent indent) const UncheckedPrintSelf(os, indent); } - -inline -void otb::ogr::Feature::CheckInvariants() const -{ - assert(m_Feature && "OGRFeature can't be null"); -} - #endif // otbOGRFeatureWrapper_txx diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.h index c5af3e93bd98e9fe967d2f3ff9567dfa50fe80d1..14eefed3ee4d78e760d6556ddbef2ce9d4046f14 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.h @@ -166,6 +166,9 @@ public: */ void Assign(Field const& f); + /** \copydoc Field::ogr() const */ + OGRField & ogr(); + /** Access to the raw underlying OGR data. * This function provides an abstraction leak in case deeper control on the * underlying \c OGRFeature is required. @@ -174,9 +177,6 @@ public: */ OGRField & ogr() const; - /** \copydoc Field::ogr() const */ - OGRField & ogr(); - private: /**\name Unchecked definitions * All the definitions that follow do the real work. However, they are not the diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.txx b/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.txx index a1c3e6752e5c5dde3a8b2982253b38d5fc3bfc7e..76e624156593b2ea43e84c6972de30bf1f7204d7 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.txx +++ b/Modules/Adapters/GdalAdapters/include/otbOGRFieldWrapper.txx @@ -465,12 +465,6 @@ void otb::ogr::Field::Assign(Field const& f) CheckInvariants(); } -inline -OGRField & otb::ogr::Field::ogr() const -{ - return const_cast <Field*>(this)->ogr(); -} - inline OGRField & otb::ogr::Field::ogr() { @@ -480,4 +474,10 @@ OGRField & otb::ogr::Field::ogr() return *f; } +inline +OGRField & otb::ogr::Field::ogr() const +{ + return const_cast <Field*>(this)->ogr(); +} + #endif // otbOGRFieldWrapper_txx diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRLayerWrapper.h b/Modules/Adapters/GdalAdapters/include/otbOGRLayerWrapper.h index 4f328fee2113ed9e24324a1eed6f8bb6dabdc4ed..36b408d86ad85d745d03291b369ac3bff467d7fa 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRLayerWrapper.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRLayerWrapper.h @@ -506,7 +506,11 @@ public: */ OGRwkbGeometryType GetGeomType() const; - friend bool otb::ogr::operator==(Layer const& lhs, Layer const& rhs); + friend bool operator==(Layer const& lhs, Layer const& rhs) + { + const bool equal = lhs.m_Layer.get() == rhs.m_Layer.get(); + return equal; + } private: /** diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRLayerWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRLayerWrapper.cxx index 58c3b503d25c08bf38bf88426793ab14e0e0fca7..185edf72898df8ab0076bdb89d27265f0775f9ba 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRLayerWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRLayerWrapper.cxx @@ -448,8 +448,3 @@ OGRwkbGeometryType otb::ogr::Layer::GetGeomType() const #endif } -bool otb::ogr::operator==(Layer const& lhs, Layer const& rhs) -{ - const bool equal = lhs.m_Layer.get() == rhs.m_Layer.get(); - return equal; -} diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h new file mode 100644 index 0000000000000000000000000000000000000000..537d2e6112320413213365ec8cd9b31990d4cad0 --- /dev/null +++ b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h @@ -0,0 +1,98 @@ +/*========================================================================= + + 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 otbSarSensorModelAdapter_h +#define otbSarSensorModelAdapter_h + +#include <memory> + +#include "otbDEMHandler.h" + +namespace ossimplugins +{ +class ossimSarSensorModel; +} + +namespace otb +{ + +class ImageKeywordlist; + +/** + * \class SarSensorModelAdapter + * \brief Wrapper class to access SarSensorModel specific methods + * + * This class is NOT intended to be used outside of OTB. Use the + * InverseSensorModel and ForwardSensorModel. If you feel that you need to use + * it directly, think again! + * + * \sa InverseSensorModel + * \sa ForwardSensorModel + * \ingroup Projection + * + * + * \ingroup OTBOSSIMAdapters + **/ + +class OTBOSSIMAdapters_EXPORT SarSensorModelAdapter: public itk::Object +{ +public: + /** Standard class typedefs. */ + typedef SarSensorModelAdapter Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef std::auto_ptr<ossimplugins::ossimSarSensorModel> InternalModelPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(SarSensorModelAdapter, itk::Object); + + /** Load model from keyword list */ + bool LoadState(const ImageKeywordlist& image_kwl); + + /** Save keyword list from model */ + bool SaveState(ImageKeywordlist & image_kwl); + + /** Is sensor model valid method. return false if the m_SensorModel is null*/ + bool IsValidSensorModel() const; + + /** Deburst metadata if possible and return lines to keep in image file */ + bool Deburst(std::vector<std::pair<unsigned long, unsigned long> > & lines); + + static bool ImageLineToDeburstLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long imageLine, unsigned long & deburstLine); + + static void DeburstLineToImageLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long deburstLine, unsigned long & imageLine); + + +protected: + SarSensorModelAdapter(); + virtual ~SarSensorModelAdapter() ITK_OVERRIDE; + +private: + SarSensorModelAdapter(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + + InternalModelPointer m_SensorModel; +}; + +} // namespace otb + +#endif diff --git a/Modules/Adapters/OSSIMAdapters/src/CMakeLists.txt b/Modules/Adapters/OSSIMAdapters/src/CMakeLists.txt index 257cc6352ea0cbfec69a5bc7feed4e6d09b59fe9..62bc0f0d326a590f36dc30babfa36b1cc5531524 100644 --- a/Modules/Adapters/OSSIMAdapters/src/CMakeLists.txt +++ b/Modules/Adapters/OSSIMAdapters/src/CMakeLists.txt @@ -11,6 +11,7 @@ set(OTBOSSIMAdapters_SRC otbFilterFunctionValues.cxx otbMetaDataKey.cxx otbEllipsoidAdapter.cxx + otbSarSensorModelAdapter.cxx ) add_library(OTBOSSIMAdapters ${OTBOSSIMAdapters_SRC}) diff --git a/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..bc96ade5e82238971abd138d0b1525a332c3c082 --- /dev/null +++ b/Modules/Adapters/OSSIMAdapters/src/otbSarSensorModelAdapter.cxx @@ -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. + +=========================================================================*/ + +#include "otbSarSensorModelAdapter.h" + +#include <cassert> + +#include "otbMacro.h" +#include "otbImageKeywordlist.h" + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wshadow" +#pragma GCC diagnostic ignored "-Woverloaded-virtual" +#include "ossim/ossimSarSensorModel.h" +#include "ossim/ossimPluginProjectionFactory.h" +#pragma GCC diagnostic pop +#else +#include "ossim/ossimSarSensorModel.h" +#include "ossim/ossimPluginProjectionFactory.h" +#endif + + +namespace otb +{ + +SarSensorModelAdapter::SarSensorModelAdapter(): + m_SensorModel(ITK_NULLPTR) +{ +} + +SarSensorModelAdapter::~SarSensorModelAdapter() +{} + +bool SarSensorModelAdapter::LoadState(const ImageKeywordlist& image_kwl) +{ + // InternalModelPointer model = new ossimplugins::ossimSarSensorModel(); + + ossimKeywordlist geom; + image_kwl.convertToOSSIMKeywordlist(geom); + + + m_SensorModel.reset(dynamic_cast<ossimplugins::ossimSarSensorModel* >(ossimplugins::ossimPluginProjectionFactory::instance()->createProjection(geom))); + + return IsValidSensorModel(); +} + +bool SarSensorModelAdapter::SaveState(ImageKeywordlist & image_kwl) +{ + if(m_SensorModel.get() != ITK_NULLPTR) + { + ossimKeywordlist geom; + + bool success = m_SensorModel->saveState(geom); + + if(success) + { + image_kwl.Clear(); + image_kwl.SetKeywordlist(geom); + + } + return success; + } + + return false; +} + +bool SarSensorModelAdapter::IsValidSensorModel() const +{ + return m_SensorModel.get() != ITK_NULLPTR; +} + +bool SarSensorModelAdapter::Deburst(std::vector<std::pair<unsigned long, unsigned long> > & lines) +{ + if(m_SensorModel.get() != ITK_NULLPTR) + { + return m_SensorModel->deburst(lines); + } + + return false; +} + +bool SarSensorModelAdapter::ImageLineToDeburstLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long imageLine, unsigned long & deburstLine) +{ + return ossimplugins::ossimSarSensorModel::imageLineToDeburstLine(lines,imageLine,deburstLine); +} + +void SarSensorModelAdapter::DeburstLineToImageLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long deburstLine, unsigned long & imageLine) +{ + ossimplugins::ossimSarSensorModel::deburstLineToImageLine(lines,deburstLine,imageLine); +} + + + + +} // namespace otb 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 b3b15d108f351e616c8bee9a9dd370ffa1814995..18d951eeda4964327c5f97fbceb5fc3cb0bd94df 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbDimensionalityReduction.cxx @@ -191,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 ); } @@ -201,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"); @@ -220,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/app/otbDomainTransform.cxx b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx index 97247f418e060832bf643641e7608d5b95d4954b..9258414ff66492d5a917bd685978d56ce37895fa 100644 --- a/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx +++ b/Modules/Applications/AppDomainTransform/app/otbDomainTransform.cxx @@ -97,7 +97,7 @@ private: } void DoInit() ITK_OVERRIDE - { + { SetName("DomainTransform"); SetDescription("Domain Transform application for wavelet and fourier"); @@ -109,25 +109,35 @@ private: 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."); - AddRAMParameter(); + 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"); + 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", "false"); + + AddParameter(ParameterType_Empty, "mode.fft.shift", "Shift fft transform"); SetParameterDescription("mode.fft.shift", "Shift transform of fft filter"); - AddChoice("mode.wavelet", "wavelet"); + + AddChoice("mode.wavelet", "Wavelet"); SetParameterDescription("mode.wavelet", "Wavelet transform"); - AddParameter(ParameterType_Choice, "mode.wavelet.form", "Select wavelet form"); + 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"); @@ -138,32 +148,25 @@ private: AddChoice("mode.wavelet.form.sb44", "SPLINE_BIORTHOGONAL_4_4"); AddChoice("mode.wavelet.form.sym8", "SYMLET8"); - //Default value - SetParameterString("mode", "wavelet"); - SetParameterString("mode.wavelet.form", "haar"); + // 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); - AddParameter(ParameterType_Choice,"dir", "Direction"); - - AddChoice("dir.fwd", "Forward"); - AddChoice("dir.inv", "Inverse"); - - 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."); + AddRAMParameter(); SetDocExampleParameterValue("in", "input.tif"); SetDocExampleParameterValue("mode.wavelet.form", "haar"); SetDocExampleParameterValue("out", "output_wavelet_haar.tif"); - } + } void DoUpdateParameters() ITK_OVERRIDE { @@ -172,14 +175,14 @@ private: void DoExecute() ITK_OVERRIDE { - int dir = GetParameterInt("dir"); + int dir = GetParameterInt("direction"); int mode = GetParameterInt("mode"); if( dir != 0 && dir != 1) { itkExceptionMacro(<< "-dir is '" << dir << "'." - << "It must be either 'fwd' or 'inv'"); + << "It must be either 'forward' or 'inverse'"); } if( mode != 0 && mode != 1) @@ -260,12 +263,11 @@ private: if (dir == 0 ) { - otbAppLogINFO( << "Forward FFT" ); //forward fft typedef otb::Image<InputPixelType> TInputImage; typedef TInputImage::Pointer TInputImagePointer; - //get input paramter as otb::Image<InputPixelType> + //get input parameter as otb::Image<InputPixelType> TInputImagePointer inImage = GetParameterImage<TInputImage>("in"); //typedef itk::::ForwardFFTImageFilter over otbImage< InputPixelType > @@ -287,8 +289,8 @@ private: { otbAppLogINFO( << "Applying Shift image filter" ); typedef itk::FFTShiftImageFilter< - typename FFTFilter::OutputImageType, - typename FFTFilter::OutputImageType > FFTShiftFilterType; + FFTFilter::OutputImageType, + FFTFilter::OutputImageType > FFTShiftFilterType; FFTShiftFilterType::Pointer fftShiftFilter = FFTShiftFilterType::New(); @@ -310,7 +312,6 @@ private: } else { - otbAppLogINFO( << "Inverse FFT" ); //inverse fft typedef otb::VectorImage<InputPixelType> TInputImage; typedef TInputImage::Pointer TInputImagePointer; @@ -337,7 +338,6 @@ private: if( shift) { - otbAppLogINFO( << "Applying Shift image filter" ); typedef itk::FFTShiftImageFilter< TInputImage, TInputImage > FFTShiftFilterType; diff --git a/Modules/Applications/AppDomainTransform/test/CMakeLists.txt b/Modules/Applications/AppDomainTransform/test/CMakeLists.txt index f5bb2c2e30d2f8db030057dc8c08ec0ca86a2516..593cf6f458cd2fb143bc7d916a0288efcbc0446e 100644 --- a/Modules/Applications/AppDomainTransform/test/CMakeLists.txt +++ b/Modules/Applications/AppDomainTransform/test/CMakeLists.txt @@ -5,7 +5,7 @@ otb_test_application(NAME apTvDomainTransform_wav_db20_fwd -mode wavelet -mode.wavelet.form db20 -mode.wavelet.nlevels 2 - -dir fwd + -direction forward -out ${TEMP}/apTvDomainTransform_wav_db20_fwd.tif ) @@ -14,7 +14,7 @@ otb_test_application(NAME apTvDomainTransform_wav_haar_inv OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif -mode wavelet -mode.wavelet.form haar - -dir inv + -direction inverse -out ${TEMP}/apTvDomainTransform_wav_haar_inv.tif ) @@ -23,32 +23,16 @@ otb_test_application(NAME apTvDomainTransform_fft_shift_fwd OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif -mode fft -mode.fft.shift true - -dir fwd + -direction forward -out ${TEMP}/apTvDomainTransform_fft_shift_fwd.tif ) -otb_test_application(NAME apTvDomainTransform_fft_fwd - APP DomainTransform - OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif - -mode fft - -dir fwd - -out ${TEMP}/apTvDomainTransform_fft_fwd.tif - ) -otb_test_application(NAME apTvDomainTransform_fft_shift_inv +otb_test_application(NAME apTvDomainTransform_fft_inv APP DomainTransform OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif -mode fft - -mode.fft.shift true - -dir inv + -direction inverse -out ${TEMP}/apTvDomainTransform_fft_shift_inv.tif ) -otb_test_application(NAME apTvDomainTransform_fft_inv - APP DomainTransform - OPTIONS -in ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif - -mode fft - -dir inv - -out ${TEMP}/apTvDomainTransform_fft_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 62741969214b647891ac0bc47f282906080cf86b..48d0c9c0a8f8cd3c133d07ab30ea367e95aaa088 100644 --- a/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx +++ b/Modules/Applications/AppFusion/app/otbBundleToPerfectSensor.cxx @@ -72,8 +72,8 @@ private: Connect("pansharp.inp","superimpose.inr"); Connect("pansharp.ram","superimpose.ram"); - GetInternalApplication("superimpose")->SetParameterString("interpolator","bco"); - GetInternalApplication("pansharp")->SetParameterString("method","rcs"); + GetInternalApplication("superimpose")->SetParameterString("interpolator","bco", false); + GetInternalApplication("pansharp")->SetParameterString("method","rcs", false); // Doc example parameter settings SetDocExampleParameterValue("inp", "QB_Toulouse_Ortho_PAN.tif"); diff --git a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx index 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/AppMorphology/app/CMakeLists.txt b/Modules/Applications/AppMorphology/app/CMakeLists.txt index 183589a76c30de97230a76d7667272a1243d54bc..6bfab46d0f8c03a22e0039bc9a748fa0c5d1f23e 100644 --- a/Modules/Applications/AppMorphology/app/CMakeLists.txt +++ b/Modules/Applications/AppMorphology/app/CMakeLists.txt @@ -2,6 +2,7 @@ set(OTBAppMorphology_LINK_LIBS ${OTBImageBase_LIBRARIES} ${OTBApplicationEngine_LIBRARIES} ${OTBObjectList_LIBRARIES} + ${OTBMorphologicalProfiles_LIBRARIES} ) otb_create_application( @@ -13,3 +14,19 @@ otb_create_application( NAME GrayScaleMorphologicalOperation SOURCES otbGrayScaleMorphologicalOperation.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + + +otb_create_application( + NAME MorphologicalClassification + SOURCES otbMorphologicalClassification.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + +otb_create_application( + NAME MorphologicalProfilesAnalysis + SOURCES otbMorphologicalProfilesAnalysis.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + +otb_create_application( + NAME MorphologicalMultiScaleDecomposition + SOURCES otbMorphologicalMultiScaleDecomposition.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) diff --git a/Modules/Applications/AppMorphology/app/otbMorphologicalClassification.cxx b/Modules/Applications/AppMorphology/app/otbMorphologicalClassification.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ea9035da67867c21dc38d056f5f4df523272c239 --- /dev/null +++ b/Modules/Applications/AppMorphology/app/otbMorphologicalClassification.cxx @@ -0,0 +1,214 @@ +/*========================================================================= + + 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 "otbGeodesicMorphologyDecompositionImageFilter.h" +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + +#include "itkBinaryBallStructuringElement.h" +#include "itkBinaryCrossStructuringElement.h" + +#include "itkBinaryDilateImageFilter.h" +#include "itkBinaryErodeImageFilter.h" +#include "itkBinaryMorphologicalOpeningImageFilter.h" +#include "itkBinaryMorphologicalClosingImageFilter.h" + +#include "otbMultiToMonoChannelExtractROI.h" +#include "otbImageList.h" +#include "otbImageListToVectorImageFilter.h" + +#include "itkTimeProbe.h" +#include "otbConvexOrConcaveClassificationFilter.h" +#include "otbMorphologicalProfilesSegmentationFilter.h" + +namespace otb { +namespace Wrapper { + +class MorphologicalClassification : public Application { +public: +/** Standard class typedefs. */ + typedef MorphologicalClassification Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef FloatVectorImageType::InternalPixelType InputPixelType; + typedef otb::Image<InputPixelType, 2> FloatImageType; + + typedef unsigned short LabeledPixelType; + typedef otb::Image<LabeledPixelType, 2> LabeledImageType; + + typedef otb::MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType, InputPixelType> + ExtractorFilterType; + + typedef otb::ConvexOrConcaveClassificationFilter<FloatImageType, LabeledImageType> ClassificationFilterType; + + typedef itk::BinaryBallStructuringElement<InputPixelType, 2> BallStructuringElementType; + typedef itk::BinaryCrossStructuringElement<InputPixelType, 2> CrossStructuringElementType; + +/** Standard macro */ + itkNewMacro( Self ); + + itkTypeMacro( MorphologicalClassification, otb::Application ); + +private: + + void DoInit() ITK_OVERRIDE + { + SetName( "MorphologicalClassification" ); + SetDescription( "Performs morphological convex, concave and flat classification on an input image channel" ); + + // Documentation + SetDocName( "Morphological Classification" ); + SetDocLongDescription( "This algorithm is based on the following publication:\n" + "\n" + "Martino Pesaresi and Jon Alti Benediktsson, Member, IEEE: A new approach\n" + "for the morphological segmentation of high resolution satellite imagery.\n" + "IEEE Transactions on geoscience and remote sensing, vol. 39, NO. 2,\n" + "February 2001, p. 309-320.\n" + "\n" + "This application perform the following decision rule to classify a pixel\n" + "between the three classes Convex, Concave and Flat. Let :math:`f` denote\n" + "the input image and :math:`\\psi_{N}(f)` the geodesic leveling of\n" + ":math:`f` with a structuring element of size :math:`N`. One can derive\n" + "the following decision rule to classify :math:`f` into Convex (label\n" + ":math:`\\stackrel{\\smile}{k}`), Concave (label\n" + ":math:`\\stackrel{rown}{k}`) and Flat (label :math:`\\bar{k}`): \n" + "\n" + ":math:`f(n) = \\begin{cases} \\stackrel{\\smile}{k} &:& f-\\psi_{N}(f)>\\sigma \\\\ \\stackrel{\\frown}{k} &:& \\psi_{N}(f)-f>\\sigma\\\\ \\bar{k}&:&\\mid f - \\psi_{N}(f) \\mid \\leq \\sigma \\end{cases}`" + "\n\n" + "This output is a labeled image (0 : Flat, 1 : Convex, 2 : Concave)" ); + SetDocLimitations( "Generation of the morphological classification is not streamable, pay attention to this fact when setting the radius size of the structuring element." ); + SetDocAuthors( "OTB-Team" ); + SetDocSeeAlso( "otbConvexOrConcaveClassificationFilter class" ); + + AddDocTag( "MorphologicalClassification" ); + + AddParameter( ParameterType_InputImage, "in", "Input Image" ); + SetParameterDescription( "in", "The input image to be classified." ); + + AddParameter( ParameterType_OutputImage, "out", "Output Image" ); + SetParameterDescription( "out", + "The output classified image with 3 different values (0 : Flat, 1 : Convex, 2 : Concave)" ); + + AddParameter( ParameterType_Int, "channel", "Selected Channel" ); + SetParameterDescription( "channel", "The selected channel index for input image" ); + SetDefaultParameterInt( "channel", 1 ); + SetMinimumParameterIntValue( "channel", 1 ); + + AddRAMParameter(); + + // Structuring Element (Ball | Cross) + AddParameter( ParameterType_Choice, "structype", "Structuring Element Type" ); + SetParameterDescription( "structype", "Choice of the structuring element type" ); + AddChoice( "structype.ball", "Ball" ); + AddChoice( "structype.cross", "Cross" ); + + AddParameter( ParameterType_Int, "radius", "Radius" ); + SetParameterDescription( "radius", "Radius of the structuring element (in pixels)" ); + SetDefaultParameterInt( "radius", 5 ); + SetMinimumParameterIntValue( "radius", 1 ); + + AddParameter( ParameterType_Float, "sigma", "Sigma value for leveling tolerance" ); + SetParameterDescription( "sigma", "Sigma value for leveling tolerance" ); + SetDefaultParameterFloat( "sigma", 0.5 ); + SetMinimumParameterFloatValue( "sigma", 0 ); + + SetDocExampleParameterValue( "in", "ROI_IKO_PAN_LesHalles.tif" ); + SetDocExampleParameterValue( "channel", "1" ); + SetDocExampleParameterValue( "structype", "ball" ); + SetDocExampleParameterValue( "radius", "5" ); + SetDocExampleParameterValue( "sigma", "0.5" ); + SetDocExampleParameterValue( "out", "output.tif" ); + + } + + void DoUpdateParameters() ITK_OVERRIDE + { + // Nothing to do here : all parameters are independent + } + + void DoExecute() ITK_OVERRIDE + { + FloatVectorImageType::Pointer inImage = GetParameterImage( "in" ); + + int nBComp = inImage->GetNumberOfComponentsPerPixel(); + int selectedChannel = GetParameterInt( "channel" ); + + if ( selectedChannel > nBComp ) + { + itkExceptionMacro( << "The specified channel index for input image is invalid." ); + } + + m_ExtractorFilter = ExtractorFilterType::New(); + m_ExtractorFilter->SetInput( inImage ); + m_ExtractorFilter->SetStartX( static_cast<unsigned int>(inImage->GetLargestPossibleRegion().GetIndex( 0 )) ); + m_ExtractorFilter->SetStartY( static_cast<unsigned int>(inImage->GetLargestPossibleRegion().GetIndex( 1 )) ); + m_ExtractorFilter->SetSizeX( inImage->GetLargestPossibleRegion().GetSize( 0 ) ); + m_ExtractorFilter->SetSizeY( inImage->GetLargestPossibleRegion().GetSize( 1 ) ); + m_ExtractorFilter->SetChannel( static_cast<unsigned int>(selectedChannel) ); + + unsigned int sigma = static_cast<unsigned int>(GetParameterInt( "sigma" )); + unsigned int radius = static_cast<unsigned int>(GetParameterInt( "radius" )); + + m_ClassificationFilter = ClassificationFilterType::New(); + m_ClassificationFilter->SetInput( m_ExtractorFilter->GetOutput() ); + m_ClassificationFilter->SetSigma( sigma ); + m_ClassificationFilter->SetFlatLabel( 0 ); + m_ClassificationFilter->SetConvexLabel( 1 ); + m_ClassificationFilter->SetConcaveLabel( 2 ); + + if ( GetParameterString( "structype" ) == "ball" ) + { + performClassification<BallStructuringElementType>( radius ); + } else // Cross + { + performClassification<CrossStructuringElementType>( radius ); + } + + SetParameterOutputImage( "out", m_ClassificationFilter->GetOutput() ); + + } + + template<typename TStructuringElement> + void performClassification(unsigned int radius_size) { + + typedef otb::GeodesicMorphologyDecompositionImageFilter<FloatImageType, FloatImageType, TStructuringElement> TDecompositionImageFilter; + + typename TDecompositionImageFilter::Pointer decompositionImageFilter; + decompositionImageFilter = TDecompositionImageFilter::New(); + decompositionImageFilter->SetInput( m_ExtractorFilter->GetOutput() ); + + typename TStructuringElement::RadiusType radius; + radius.Fill( radius_size ); + decompositionImageFilter->SetRadius( radius ); + AddProcess(decompositionImageFilter, "Image Decomposition"); + decompositionImageFilter->Update(); + + m_ClassificationFilter->SetInputLeveling( decompositionImageFilter->GetOutput() ); + } + + ExtractorFilterType::Pointer m_ExtractorFilter; + ClassificationFilterType::Pointer m_ClassificationFilter; + +}; +} +} + +OTB_APPLICATION_EXPORT( otb::Wrapper::MorphologicalClassification ) + diff --git a/Modules/Applications/AppMorphology/app/otbMorphologicalMultiScaleDecomposition.cxx b/Modules/Applications/AppMorphology/app/otbMorphologicalMultiScaleDecomposition.cxx new file mode 100644 index 0000000000000000000000000000000000000000..592a2fd0563dde94c47198d2accfdf39545629df --- /dev/null +++ b/Modules/Applications/AppMorphology/app/otbMorphologicalMultiScaleDecomposition.cxx @@ -0,0 +1,233 @@ +/*========================================================================= + + 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 "itkComposeImageFilter.h" +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + +#include "itkBinaryBallStructuringElement.h" +#include "itkBinaryCrossStructuringElement.h" + +#include "itkBinaryDilateImageFilter.h" +#include "itkBinaryErodeImageFilter.h" +#include "itkBinaryMorphologicalOpeningImageFilter.h" +#include "itkBinaryMorphologicalClosingImageFilter.h" + +#include "otbMultiToMonoChannelExtractROI.h" +#include "otbImageList.h" +#include "otbImageListToVectorImageFilter.h" + +#include "itkTimeProbe.h" +#include "otbConvexOrConcaveClassificationFilter.h" +#include "otbMorphologicalProfilesSegmentationFilter.h" +#include "otbGeodesicMorphologyIterativeDecompositionImageFilter.h" + +namespace otb { +namespace Wrapper { + +class MorphologicalMultiScaleDecomposition : public Application { +public: +/** Standard class typedefs. */ + typedef MorphologicalMultiScaleDecomposition Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef FloatVectorImageType::InternalPixelType InputVectorPixelType; + + typedef otb::MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType, InputVectorPixelType> + ExtractorFilterType; + + typedef itk::BinaryBallStructuringElement<InputVectorPixelType, 2> BallStructuringElementType; + typedef itk::BinaryCrossStructuringElement<InputVectorPixelType, 2> CrossStructuringElementType; + +/** Standard macro */ + itkNewMacro( Self ); + + itkTypeMacro( MorphologicalMultiScaleDecomposition, otb::Application ); + +private: + + void DoInit() ITK_OVERRIDE + { + SetName( "MorphologicalMultiScaleDecomposition" ); + SetDescription( "Perform a geodesic morphology based image analysis on an input image channel" ); + + // Documentation + SetDocName( "Morphological Multi Scale Decomposition" ); + SetDocLongDescription( + "This application recursively apply geodesic decomposition. \n" + "\n" + "This algorithm is derived from the following publication:\n" + "\n" + "Martino Pesaresi and Jon Alti Benediktsson, Member, IEEE: A new approach " + "for the morphological segmentation of high resolution satellite imagery.\n" + "IEEE Transactions on geoscience and remote sensing, vol. 39, NO. 2, " + "February 2001, p. 309-320.\n" + "\n" + "It provides a geodesic decomposition of the input image, with the " + "following scheme. Let :math:`f_0` denote the input image, :math:`\\stackrel{\\smile}{\\mu}_{N}(f)` denote the convex membership function, :math:`\\stackrel{\\frown}{\\mu}_{N}(f)` denote the concave membership function and :math:`\\psi_{N}(f)` denote the leveling function, for a given radius :math:`N` as defined in the documentation\n" + "of the GeodesicMorphologyDecompositionImageFilter. Let :math:`[N_{1},\\ldots, N_{n}]` denote a range of increasing radius (or scales). The iterative decomposition is defined as follows:\n" + "\n" + "[ f\\_n = `\\psi`\\_N\\_n(f\\_n-1) ]\n" + "\n" + "[ :math:`\\stackrel{\\frown}{f}_n` = :math:`\\stackrel{\\frown}{\\mu}_N_N(f_n)` ]\n" + "\n" + "[ :math:`\\stackrel{\\smile}{f}_n` = :math:`\\stackrel{\\smile}{\\mu}_N_N(f_n)` ]\n" + "\n" + "The :math:`\\stackrel{\\frown}{f}_{n}` and :math:`\\stackrel{\\frown}{f}_{n}` are membership function for the convex\n" + "(resp. concave) objects whose size is comprised between :math:`N_{n-1}` and :math:`N_n`\n" + "\n" + "Output convex, concave and leveling images with N bands, where N is the number of levels." ); + + SetDocLimitations( "Generation of the multi scale decomposition is not streamable, pay attention to this fact when setting the number of iterating levels." ); + SetDocAuthors( "OTB-Team" ); + SetDocSeeAlso( "otbGeodesicMorphologyDecompositionImageFilter class" ); + + AddDocTag( "MorphologicalMultiScaleDecomposition" ); + + AddParameter( ParameterType_InputImage, "in", "Input Image" ); + SetParameterDescription( "in", "The input image to be classified." ); + + AddParameter( ParameterType_OutputImage, "outconvex", "Output Convex Image" ); + SetParameterDescription( "outconvex", "The output convex image with N bands" ); + AddParameter( ParameterType_OutputImage, "outconcave", "Output Concave Image" ); + SetParameterDescription( "outconcave", "The output concave concave with N bands" ); + AddParameter( ParameterType_OutputImage, "outleveling", "Output Image" ); + SetParameterDescription( "outleveling", "The output leveling image with N bands" ); + + AddParameter( ParameterType_Int, "channel", "Selected Channel" ); + SetParameterDescription( "channel", "The selected channel index for input image" ); + SetDefaultParameterInt( "channel", 1 ); + SetMinimumParameterIntValue( "channel", 1 ); + + AddRAMParameter(); + + // Strucring Element (Ball | Cross) + AddParameter( ParameterType_Choice, "structype", "Structuring Element Type" ); + SetParameterDescription( "structype", "Choice of the structuring element type" ); + AddChoice( "structype.ball", "Ball" ); + AddChoice( "structype.cross", "Cross" ); + + AddParameter( ParameterType_Int, "radius", "Initial radius" ); + SetParameterDescription( "radius", "Initial radius of the structuring element (in pixels)" ); + SetDefaultParameterInt( "radius", 5 ); + SetMinimumParameterIntValue( "radius", 1 ); + + AddParameter( ParameterType_Int, "step", "Radius step." ); + SetParameterDescription( "step", "Radius step along the profile (in pixels)" ); + SetDefaultParameterInt( "step", 1 ); + SetMinimumParameterIntValue( "step", 1 ); + + AddParameter( ParameterType_Int, "levels", "Number of levels use for multi scale" ); + SetParameterDescription( "levels", "Number of levels use for multi scale" ); + SetDefaultParameterInt( "levels", 1 ); + SetMinimumParameterIntValue( "levels", 1 ); + + SetDocExampleParameterValue("in", "ROI_IKO_PAN_LesHalles.tif"); + SetDocExampleParameterValue("structype", "ball"); + SetDocExampleParameterValue("channel", "1"); + SetDocExampleParameterValue("radius", "2"); + SetDocExampleParameterValue("levels", "2"); + SetDocExampleParameterValue("step", "3"); + SetDocExampleParameterValue("outconvex", "convex.tif"); + SetDocExampleParameterValue("outconcave", "concave.tif"); + SetDocExampleParameterValue("outleveling", "leveling.tif"); + + + } + + void DoUpdateParameters() ITK_OVERRIDE + { + // Nothing to do here : all parameters are independent + } + + void DoExecute() ITK_OVERRIDE + { + FloatVectorImageType::Pointer inImage = GetParameterImage( "in" ); + int nBComp = inImage->GetNumberOfComponentsPerPixel(); + int selectedChannel = GetParameterInt( "channel" ); + + if ( selectedChannel > nBComp ) + { + itkExceptionMacro( << "The specified channel index for input image is invalid." ); + } + + m_ExtractorFilter = ExtractorFilterType::New(); + m_ExtractorFilter->SetInput( inImage ); + m_ExtractorFilter->SetStartX( static_cast<unsigned int>(inImage->GetLargestPossibleRegion().GetIndex( 0 )) ); + m_ExtractorFilter->SetStartY( static_cast<unsigned int>(inImage->GetLargestPossibleRegion().GetIndex( 1 )) ); + m_ExtractorFilter->SetSizeX( inImage->GetLargestPossibleRegion().GetSize( 0 ) ); + m_ExtractorFilter->SetSizeY( inImage->GetLargestPossibleRegion().GetSize( 1 ) ); + m_ExtractorFilter->SetChannel( static_cast<unsigned int>(GetParameterInt( "channel" )) ); + + unsigned int numberOfLevels = static_cast<unsigned int>(GetParameterInt( "levels" )); + unsigned int initValue = static_cast<unsigned int>(GetParameterInt( "radius" )); + unsigned int step = static_cast<unsigned int>(GetParameterInt( "step" )); + + + if ( GetParameterString( "structype" ) == "ball" ) + { + performDecomposition<BallStructuringElementType>( numberOfLevels, step, initValue ); + } else // Cross + { + performDecomposition<CrossStructuringElementType>( numberOfLevels, step, initValue ); + } + } + + template<typename StructuringElement> + void performDecomposition(unsigned int numberOfLevels, unsigned int step, unsigned int initValue) { + + typedef otb::GeodesicMorphologyIterativeDecompositionImageFilter<FloatImageType, StructuringElement> TDecompositionImageFilter; + typedef typename TDecompositionImageFilter::OutputImageListType TImageList; + typedef otb::ImageListToVectorImageFilter<TImageList, FloatVectorImageType> TListToVectorImageFilter; + + typename TDecompositionImageFilter::Pointer decompositionImageFilter; + decompositionImageFilter = TDecompositionImageFilter::New(); + decompositionImageFilter->SetInput( m_ExtractorFilter->GetOutput() ); + decompositionImageFilter->SetNumberOfIterations( numberOfLevels ); + decompositionImageFilter->SetInitialValue( initValue ); + decompositionImageFilter->SetStep( step ); + AddProcess(decompositionImageFilter, "Image Decomposition"); + decompositionImageFilter->Update(); + + typename TListToVectorImageFilter::Pointer levelingListToVectorImageFilter = TListToVectorImageFilter::New(); + typename TListToVectorImageFilter::Pointer concaveListToVectorImageFilter = TListToVectorImageFilter::New(); + typename TListToVectorImageFilter::Pointer convexListToVectorImageFilter = TListToVectorImageFilter::New(); + + levelingListToVectorImageFilter->SetInput( decompositionImageFilter->GetOutput() ); + levelingListToVectorImageFilter->Update(); + SetParameterOutputImage( "outleveling", levelingListToVectorImageFilter->GetOutput() ); + + concaveListToVectorImageFilter->SetInput( decompositionImageFilter->GetConcaveOutput() ); + concaveListToVectorImageFilter->Update(); + SetParameterOutputImage( "outconcave", concaveListToVectorImageFilter->GetOutput() ); + + convexListToVectorImageFilter->SetInput( decompositionImageFilter->GetConvexOutput() ); + convexListToVectorImageFilter->Update(); + SetParameterOutputImage( "outconvex", convexListToVectorImageFilter->GetOutput() ); + } + + ExtractorFilterType::Pointer m_ExtractorFilter; + +}; +} +} + +OTB_APPLICATION_EXPORT( otb::Wrapper::MorphologicalMultiScaleDecomposition ) + diff --git a/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx b/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..432053c3b58a6bcb47088627c1785b293fb85da1 --- /dev/null +++ b/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx @@ -0,0 +1,339 @@ +/*========================================================================= + + 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 <itkComposeImageFilter.h> +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + +#include "itkBinaryBallStructuringElement.h" +#include "itkBinaryCrossStructuringElement.h" + +#include "itkBinaryDilateImageFilter.h" +#include "itkBinaryErodeImageFilter.h" +#include "itkBinaryMorphologicalOpeningImageFilter.h" +#include "itkBinaryMorphologicalClosingImageFilter.h" + +#include "otbMultiToMonoChannelExtractROI.h" +#include "otbImageList.h" +#include "otbImageListToVectorImageFilter.h" + +#include "itkTimeProbe.h" +#include "otbConvexOrConcaveClassificationFilter.h" +#include "otbMorphologicalProfilesSegmentationFilter.h" +#include "otbGeodesicMorphologyIterativeDecompositionImageFilter.h" + +namespace otb +{ +namespace Wrapper +{ + +class MorphologicalProfilesAnalysis : public Application +{ +public: +/** Standard class typedefs. */ + typedef MorphologicalProfilesAnalysis Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef FloatVectorImageType::InternalPixelType InputPixelType; + + typedef unsigned short LabeledPixelType; + typedef otb::Image<LabeledPixelType, 2> LabeledImageType; + + typedef otb::MultiToMonoChannelExtractROI<InputPixelType, InputPixelType> ExtractorFilterType; + + typedef itk::BinaryBallStructuringElement<InputPixelType, 2> BallStructuringElementType; + typedef itk::BinaryCrossStructuringElement<InputPixelType, 2> CrossStructuringElementType; + +/** Standard macro */ + itkNewMacro( Self ); + + itkTypeMacro( MorphologicalProfilesAnalysis, otb::Application ); + +private: + + void DoInit() ITK_OVERRIDE + { + SetName( "MorphologicalProfilesAnalysis" ); + SetDescription( "Performs morphological profiles analysis on an input image channel." ); + + // Documentation + SetDocName( "Morphological Profiles Analysis" ); + SetDocLongDescription( "This algorithm is derived from the following publication:\n" + "\n" + "Martino Pesaresi and Jon Alti Benediktsson, Member, IEEE: A new approach\n" + "for the morphological segmentation of high resolution satellite imagery.\n" + "IEEE Transactions on geoscience and remote sensing, vol. 39, NO. 2,\n" + "February 2001, p. 309-320.\n" + "\n" + "Depending of the profile selection, the application provides::\n\n" + "- The multi scale geodesic morphological opening or closing profile of the input image.\n" + "- The multi scale derivative of the opening or closing profile.\n" + "- The parameter (called characteristic) of the maximum derivative value of the multi scale closing or opening profile for which this maxima occurs.\n" + "- The labeled classification of the input image.\n" + "\n" + "The behavior of the classification is :\n" + "\n" + "Given :math:`x_1` and :math:`x_2` two membership values,\n" + ":math:`L_1, L_2` two labels associated, and :math:`\\sigma` a tolerance\n" + "value, the following decision rule is applied:\n" + "\n" + ":math:`L = \\begin{cases} L_{1} &:& x_{1}>x_{2} \\quad and \\quad x_{1}>\\sigma\\\\ L_{2} &:& x_{2}>x_{1} \\quad and \\quad x_{2}>\\sigma\\\\ 0 &:& otherwise. \\end{cases}`" + "\n" + "The output image can be :" + "- A :math:`N` multi band image for the opening/closing normal or derivative profiles.\n" + "- A mono band image for the opening/closing characteristics.\n" + "- A labeled image for the classification\n" ); + SetDocLimitations( "Generation of the morphological profile is not streamable, pay attention to this fact when setting the radius initial size and step of the structuring element." ); + SetDocAuthors( "OTB-Team" ); + SetDocSeeAlso( "otbMorphologicalOpeningProfileFilter, otbMorphologicalClosingProfileFilter, otbProfileToProfileDerivativeFilter, otbProfileDerivativeToMultiScaleCharacteristicsFilter, otbMultiScaleConvexOrConcaveClassificationFilter, classes" ); + + AddDocTag( "MorphologicalProfilesAnalysis" ); + + AddParameter( ParameterType_InputImage, "in", "Input Image" ); + SetParameterDescription( "in", "The input image." ); + + AddParameter( ParameterType_OutputImage, "out", "Output Image" ); + SetParameterDescription( "out", "The output image." ); + + AddParameter( ParameterType_Int, "channel", "Selected Channel" ); + SetParameterDescription( "channel", "The selected channel index for input image" ); + SetDefaultParameterInt( "channel", 1 ); + SetMinimumParameterIntValue( "channel", 1 ); + + AddRAMParameter(); + + // Structuring Element (Ball | Cross) + AddParameter( ParameterType_Choice, "structype", "Structuring Element Type" ); + SetParameterDescription( "structype", "Choice of the structuring element type" ); + AddChoice( "structype.ball", "Ball" ); + AddChoice( "structype.cross", "Cross" ); + + AddParameter( ParameterType_Int, "size", "Profile Size" ); + SetParameterDescription( "size", "Size of the profiles" ); + SetDefaultParameterInt( "size", 5 ); + SetMinimumParameterIntValue( "size", 2 ); + + AddParameter( ParameterType_Int, "radius", "Initial radius" ); + SetParameterDescription( "radius", "Initial radius of the structuring element (in pixels)" ); + SetDefaultParameterInt( "radius", 5 ); + SetMinimumParameterIntValue( "radius", 1 ); + + AddParameter( ParameterType_Int, "step", "Radius step." ); + SetParameterDescription( "step", "Radius step along the profile (in pixels)" ); + SetDefaultParameterInt( "step", 1 ); + SetMinimumParameterIntValue( "step", 1 ); + + + AddParameter( ParameterType_Choice, "profile", "Profile" ); + SetParameterDescription( "profile", "" ); + AddChoice( "profile.opening", "opening" ); + AddChoice( "profile.closing", "closing" ); + AddChoice( "profile.derivativeopening", "derivativeopening" ); + AddChoice( "profile.derivativeclosing", "derivativeclosing" ); + AddChoice( "profile.openingcharacteristics", "openingcharacteristics" ); + AddChoice( "profile.closingcharacteristics", "closingcharacteristics" ); + AddChoice( "profile.classification", "classification" ); + + AddParameter( ParameterType_Float, "profile.classification.sigma", "Sigma value for leveling tolerance" ); + SetParameterDescription( "profile.classification.sigma", "Sigma value for leveling tolerance" ); + SetDefaultParameterFloat( "profile.classification.sigma", 1 ); + SetMinimumParameterFloatValue( "profile.classification.sigma", 0 ); + + SetDocExampleParameterValue( "in", "ROI_IKO_PAN_LesHalles.tif" ); + SetDocExampleParameterValue( "channel", "1" ); + SetDocExampleParameterValue( "structype", "ball" ); + SetDocExampleParameterValue( "profile", "classification" ); + SetDocExampleParameterValue( "size", "5" ); + SetDocExampleParameterValue( "radius", "1" ); + SetDocExampleParameterValue( "step", "1" ); + SetDocExampleParameterValue( "profile.classification.sigma", "1" ); + SetDocExampleParameterValue( "out", "output.tif" ); + } + + void DoUpdateParameters() ITK_OVERRIDE + { + // Nothing to do here : all parameters are independent + } + + void DoExecute() ITK_OVERRIDE + { + + FloatVectorImageType::Pointer inImage = GetParameterImage( "in" ); + + int nBComp = inImage->GetNumberOfComponentsPerPixel(); + int selectedChannel = GetParameterInt( "channel" ); + + if( selectedChannel > nBComp ) + { + itkExceptionMacro( << "The specified channel index for input image is invalid." ); + } + + m_ExtractorFilter = ExtractorFilterType::New(); + m_ExtractorFilter->SetInput( inImage ); + m_ExtractorFilter->SetStartX( static_cast<unsigned int>(inImage->GetLargestPossibleRegion().GetIndex( 0 )) ); + m_ExtractorFilter->SetStartY( static_cast<unsigned int>(inImage->GetLargestPossibleRegion().GetIndex( 1 )) ); + m_ExtractorFilter->SetSizeX( inImage->GetLargestPossibleRegion().GetSize( 0 ) ); + m_ExtractorFilter->SetSizeY( inImage->GetLargestPossibleRegion().GetSize( 1 ) ); + m_ExtractorFilter->SetChannel( static_cast<unsigned int>(GetParameterInt( "channel" )) ); + + unsigned int profileSize = static_cast<unsigned int>(GetParameterInt( "size" )); + unsigned short initValue = static_cast<unsigned short>(GetParameterInt( "radius" )); + unsigned short step = static_cast<unsigned short>(GetParameterInt( "step" )); + float sigma = GetParameterFloat( "profile.classification.sigma" ); + std::string profile = GetParameterString( "profile" ); + + + if ( GetParameterString( "structype" ) == "ball" ) + { + performProfileAnalysis<BallStructuringElementType>( profile, profileSize, initValue, step, sigma ); + } + else // Cross + { + performProfileAnalysis<CrossStructuringElementType>( profile, profileSize, initValue, step, sigma ); + } + } + + template<typename StructuringElementType> + void + performProfileAnalysis(std::string profile, unsigned int profileSize, unsigned short initValue, + unsigned short step, float sigma) { + + typedef otb::MorphologicalOpeningProfileFilter<FloatImageType, FloatImageType, StructuringElementType> OpeningProfileFilterType; + typedef otb::MorphologicalClosingProfileFilter<FloatImageType, FloatImageType, StructuringElementType> ClosingProfileFilterType; + typedef otb::ProfileToProfileDerivativeFilter<FloatImageType, FloatImageType> DerivativeFilterType; + + typedef otb::MultiScaleConvexOrConcaveClassificationFilter<FloatImageType, LabeledImageType> MultiScaleClassificationFilterType; + typedef otb::ProfileDerivativeToMultiScaleCharacteristicsFilter<FloatImageType, FloatImageType, LabeledImageType> MultiScaleCharacteristicsFilterType; + + // Instantiation + typename OpeningProfileFilterType::Pointer oprofileFilter; + typename ClosingProfileFilterType::Pointer cprofileFilter; + typename DerivativeFilterType::Pointer oderivativeFilter; + typename DerivativeFilterType::Pointer cderivativeFilter; + typename MultiScaleCharacteristicsFilterType::Pointer omsCharFilter; + typename MultiScaleCharacteristicsFilterType::Pointer cmsCharFilter; + typename MultiScaleClassificationFilterType::Pointer classificationFilter; + + bool classify = profile == "classification"; + bool opening = profile == "opening"; + bool closing = profile == "closing"; + bool characOpening = profile == "openingcharacteristics"; + bool characClosing = profile == "closingcharacteristics"; + bool derivativeOpening = profile == "derivativeopening"; + bool derivativeClosing = profile == "derivativeclosing"; + + bool doOpening = classify || opening || derivativeOpening || characOpening; + bool doClosing = classify || closing || derivativeClosing || characClosing; + + if ( doOpening ) + { + performOperations<OpeningProfileFilterType, DerivativeFilterType, MultiScaleCharacteristicsFilterType>( + oprofileFilter, oderivativeFilter, omsCharFilter, + opening, derivativeOpening, characOpening, + profileSize, step, initValue ); + if ( !classify ) + return; + } + + if ( doClosing ) + { + performOperations<ClosingProfileFilterType, DerivativeFilterType, MultiScaleCharacteristicsFilterType>( + cprofileFilter, cderivativeFilter, cmsCharFilter, + closing, derivativeClosing, characClosing, + profileSize, step, initValue ); + if ( !classify ) + return; + } + + classificationFilter = MultiScaleClassificationFilterType::New(); + classificationFilter->SetOpeningProfileDerivativeMaxima( omsCharFilter->GetOutput() ); + classificationFilter->SetOpeningProfileCharacteristics( omsCharFilter->GetOutputCharacteristics() ); + classificationFilter->SetClosingProfileDerivativeMaxima( cmsCharFilter->GetOutput() ); + classificationFilter->SetClosingProfileCharacteristics( cmsCharFilter->GetOutputCharacteristics() ); + classificationFilter->SetSigma( sigma ); + classificationFilter->SetLabelSeparator( static_cast<unsigned short>(initValue + profileSize * step) ); + AddProcess(classificationFilter, "Classification"); + classificationFilter->Update(); + SetParameterOutputImage( "out", classificationFilter->GetOutput() ); + } + + + template<typename TProfileFilter, typename TDerivativeFilter, typename TCharacteristicsFilter> + void + performOperations(typename TProfileFilter::Pointer &profileFilter, + typename TDerivativeFilter::Pointer &derivativeFilter, + typename TCharacteristicsFilter::Pointer &msCharFilter, + bool profile, bool derivative, bool characteristics, + unsigned int profileSize, unsigned short initValue, unsigned short step) { + + typedef ImageList<FloatImageType> TImageList; + typedef otb::ImageListToVectorImageFilter<TImageList, FloatVectorImageType> TListToVectorImageFilter; + + profileFilter = TProfileFilter::New(); + profileFilter->SetInput( m_ExtractorFilter->GetOutput() ); + profileFilter->SetProfileSize( profileSize ); + profileFilter->SetInitialValue( initValue ); + profileFilter->SetStep( step ); + + if ( profile ) + { + TListToVectorImageFilter::Pointer listToVectorImageFilter = TListToVectorImageFilter::New(); + listToVectorImageFilter->SetInput( profileFilter->GetOutput() ); + AddProcess(listToVectorImageFilter, "Profile"); + listToVectorImageFilter->Update(); + SetParameterOutputImage( "out", listToVectorImageFilter->GetOutput() ); + return; + } + + derivativeFilter = TDerivativeFilter::New(); + derivativeFilter->SetInput( profileFilter->GetOutput() ); + + if ( derivative ) + { + TListToVectorImageFilter::Pointer listToVectorImageFilter = TListToVectorImageFilter::New(); + listToVectorImageFilter->SetInput( derivativeFilter->GetOutput() ); + AddProcess(listToVectorImageFilter, "Derivative"); + listToVectorImageFilter->Update(); + SetParameterOutputImage( "out", listToVectorImageFilter->GetOutput() ); + return; + } + + msCharFilter = TCharacteristicsFilter::New(); + msCharFilter->SetInput( derivativeFilter->GetOutput() ); + msCharFilter->SetInitialValue( initValue ); + msCharFilter->SetStep( step ); + + if ( characteristics ) + { + AddProcess(msCharFilter, "Characteristics"); + msCharFilter->Update(); + SetParameterOutputImage( "out", msCharFilter->GetOutputCharacteristics() ); + } + } + + ExtractorFilterType::Pointer m_ExtractorFilter; + +}; +} +} + +OTB_APPLICATION_EXPORT( otb::Wrapper::MorphologicalProfilesAnalysis ) + diff --git a/Modules/Applications/AppMorphology/otb-module.cmake b/Modules/Applications/AppMorphology/otb-module.cmake index 4f64254c0dd1976c3925efcc6d919b3939cd8ec1..f504d55f40948ffe09b92aeee802f579abb79f1e 100644 --- a/Modules/Applications/AppMorphology/otb-module.cmake +++ b/Modules/Applications/AppMorphology/otb-module.cmake @@ -6,6 +6,7 @@ otb_module(OTBAppMorphology OTBObjectList OTBITK OTBApplicationEngine + OTBMorphologicalProfiles TEST_DEPENDS OTBTestKernel diff --git a/Modules/Applications/AppMorphology/test/CMakeLists.txt b/Modules/Applications/AppMorphology/test/CMakeLists.txt index 8bd720d505c83023b3648e1a91c92a818bd79c39..f60f8311e75eb52bd609670fc919f3d77abc2262 100644 --- a/Modules/Applications/AppMorphology/test/CMakeLists.txt +++ b/Modules/Applications/AppMorphology/test/CMakeLists.txt @@ -28,3 +28,101 @@ otb_test_application(NAME apTvFEGrayScaleMorphologicalOperation ${BASELINE}/apTvFEGrayScaleMorphologicalOperation.tif ${TEMP}/apTvFEGrayScaleMorphologicalOperation.tif) + +#----------- MorphologicalMultiScaleDecomposition TESTS ---------------- +otb_test_application(NAME apTvFEMorphologicalMultiScaleDecomposition + APP MorphologicalMultiScaleDecomposition + OPTIONS -in ${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif + -channel 1 + -radius 4 + -structype ball + -outleveling ${TEMP}/apTvFEMorphologicalMultiScaleDecomposition_levelingIteration_1.tif + -outconcave ${TEMP}/apTvFEMorphologicalMultiScaleDecomposition_concaveIteration_1.tif + -outconvex ${TEMP}/apTvFEMorphologicalMultiScaleDecomposition_convexIteration_1.tif + VALID --compare-n-images ${NOTOL} 3 + ${BASELINE}/apTvFEMorphologicalMultiScaleDecomposition_levelingIteration_1.tif + ${TEMP}/apTvFEMorphologicalMultiScaleDecomposition_levelingIteration_1.tif + ${BASELINE}/apTvFEMorphologicalMultiScaleDecomposition_concaveIteration_1.tif + ${TEMP}/apTvFEMorphologicalMultiScaleDecomposition_concaveIteration_1.tif + ${BASELINE}/apTvFEMorphologicalMultiScaleDecomposition_convexIteration_1.tif + ${TEMP}/apTvFEMorphologicalMultiScaleDecomposition_convexIteration_1.tif) + + +#----------- Iterative MorphologicalMultiScaleDecomposition TESTS ---------------- +otb_test_application(NAME apTvFEMorphologicalMultiScaleDecompositionIteratif + APP MorphologicalMultiScaleDecomposition + OPTIONS -in ${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif + -channel 1 + -levels 2 + -structype ball + -step 3 + -radius 2 + -outleveling ${TEMP}/apTvFEMorphologicalMultiScaleDecomposition_levelingIteration_2.tif + -outconcave ${TEMP}/apTvFEMorphologicalMultiScaleDecomposition_concaveIteration_2.tif + -outconvex ${TEMP}/apTvFEMorphologicalMultiScaleDecomposition_convexIteration_2.tif + VALID --compare-n-images ${NOTOL} 3 + ${BASELINE}/apTvFEMorphologicalMultiScaleDecomposition_levelingIteration_2.tif + ${TEMP}/apTvFEMorphologicalMultiScaleDecomposition_levelingIteration_2.tif + ${BASELINE}/apTvFEMorphologicalMultiScaleDecomposition_concaveIteration_2.tif + ${TEMP}/apTvFEMorphologicalMultiScaleDecomposition_concaveIteration_2.tif + ${BASELINE}/apTvFEMorphologicalMultiScaleDecomposition_convexIteration_2.tif + ${TEMP}/apTvFEMorphologicalMultiScaleDecomposition_convexIteration_2.tif) + + +#----------- MorphologicalClassification TESTS ---------------- +otb_test_application(NAME apTvFEMorphologicalClassification + APP MorphologicalClassification + OPTIONS -in ${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif + -channel 1 + -structype ball + -radius 5 + -sigma 0.5 + -out ${TEMP}/apTvFEMorphologicalProfilesClassification.tif + VALID --compare-image ${NOTOL} + ${BASELINE}/apTvFEMorphologicalProfilesClassification.tif + ${TEMP}/apTvFEMorphologicalProfilesClassification.tif) + + + +#----------- Opening MorphologicalProfilesAnalysis TESTS ---------------- +otb_test_application(NAME apTvFEMorphologicalProfilesAnalysisOpening + APP MorphologicalProfilesAnalysis + OPTIONS -in ${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif + -channel 1 + -structype ball + -profile closing + -size 4 + -radius 1 + -step 1 + -out ${TEMP}/apTvFEMorphologicalProfilesOpeningAnalysis.tif) + +#----------- Closing MorphologicalProfilesAnalysis TESTS ---------------- +otb_test_application(NAME apTvFEMorphologicalProfilesAnalysisClosing + APP MorphologicalProfilesAnalysis + OPTIONS -in ${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif + -channel 1 + -structype ball + -profile closing + -size 4 + -radius 1 + -step 1 + -out ${TEMP}/apTvFEMorphologicalProfilesClosingAnalysis.tif + VALID --compare-image ${NOTOL} + ${BASELINE}/apTvFEMorphologicalProfilesClosingAnalysis.tif + ${TEMP}/apTvFEMorphologicalProfilesClosingAnalysis.tif) + +#----------- Classfication MorphologicalProfilesAnalysis TESTS ---------------- +otb_test_application(NAME apTvFEMorphologicalProfilesAnalysisClassification + APP MorphologicalProfilesAnalysis + OPTIONS -in ${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif + -channel 1 + -structype ball + -profile classification + -size 5 + -radius 1 + -step 1 + -profile.classification.sigma 1 + -out ${TEMP}/apTvFEMorphologicalProfilesClosingAnalysis.tif + VALID --compare-image ${NOTOL} + ${BASELINE}/msMultiScaleConvexOrConcaveClassificationFilterOutput.tif + ${TEMP}/apTvFEMorphologicalProfilesClosingAnalysis.tif) 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 ac37bdc6e7ce080d7ec95303d3f52e7d02e69be8..71cb75003eb0f48450e4f0f07c69888f3af49153 100644 --- a/Modules/Applications/AppProjection/app/otbSuperimpose.cxx +++ b/Modules/Applications/AppProjection/app/otbSuperimpose.cxx @@ -159,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); } } diff --git a/Modules/Applications/AppSARCalibration/app/CMakeLists.txt b/Modules/Applications/AppSARCalibration/app/CMakeLists.txt index 5df3a5ecb22ab0afcaa40758d6b2a399d2bb14d0..0d02f26055a74dd3064295904330b1e62e712e59 100644 --- a/Modules/Applications/AppSARCalibration/app/CMakeLists.txt +++ b/Modules/Applications/AppSARCalibration/app/CMakeLists.txt @@ -12,3 +12,8 @@ otb_create_application( NAME SARCalibration SOURCES otbSARCalibration.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + +otb_create_application( + NAME SARDeburst + SOURCES otbSARDeburst.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) diff --git a/Modules/Applications/AppSARCalibration/app/otbSARDeburst.cxx b/Modules/Applications/AppSARCalibration/app/otbSARDeburst.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f865987072051f2e05e0ec83eb499ff5a71da364 --- /dev/null +++ b/Modules/Applications/AppSARCalibration/app/otbSARDeburst.cxx @@ -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. + + =========================================================================*/ +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + +#include "otbSarDeburstImageFilter.h" + +namespace otb +{ +namespace Wrapper +{ +class SARDeburst : public Application +{ +public: + /** Standard class typedefs. */ + typedef SARDeburst Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(SARDeburst, otb::Application); + + typedef otb::SarDeburstImageFilter<FloatVectorImageType> DeburstFilterType; + +private: + void DoInit() ITK_OVERRIDE + { + SetName("SARDeburst"); + SetDescription("This application performs a deburst operation by removing redundant lines. \n"); + + // Documentation + SetDocName("SAR Deburst"); + SetDocLongDescription("This application performs a deburst operation by removing redundant lines between burst. This operation is useful when dealing with Sentinel1 IW SLC products, where each subswath is composed of several overlapping burst separated by black lines. Lines to remove are computed by SAR sensor model in OSSIM plugins. The output image is smaller in azimuth direction than the input line, because of removed lines. Note that the output sensor model is updated accordingly. This deburst filter is the perfect preprocessing step to orthorectify S1 IW SLC product with OTB without suffering from artifacts caused by bursts separation.\n"); + SetDocLimitations("Only Sentinel1 IW SLC products are supported for now."); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso("OrthoRectification"); + + AddDocTag(Tags::Calibration); + AddDocTag(Tags::SAR); + + AddParameter(ParameterType_InputImage, "in", "Input Image"); + SetParameterDescription("in", "Input image"); + + AddParameter(ParameterType_OutputImage, "out", "Output Image"); + SetParameterDescription("out", "Output deburst image"); + + AddRAMParameter(); + + SetDocExampleParameterValue("in","s1_iw_slc.tif"); + SetDocExampleParameterValue("out","s1_iw_slc_deburst.tif"); + + + } + + void DoUpdateParameters() ITK_OVERRIDE + {} + + void DoExecute() ITK_OVERRIDE + { + // Get the input complex image + FloatVectorImageType* in = GetParameterImage("in"); + + // Set the filer input + m_DeburstFilter = DeburstFilterType::New(); + m_DeburstFilter->SetInput(in); + + // Set the output image + SetParameterOutputImage("out", m_DeburstFilter->GetOutput()); + } + + DeburstFilterType::Pointer m_DeburstFilter; + +}; +} +} + +OTB_APPLICATION_EXPORT(otb::Wrapper::SARDeburst) diff --git a/Modules/Applications/AppSARCalibration/test/CMakeLists.txt b/Modules/Applications/AppSARCalibration/test/CMakeLists.txt index dfceda5530c883a31d3b892e6d04ef673833a6b1..af0751c6b5a90a46dff513d805f1ed17ee056ce0 100644 --- a/Modules/Applications/AppSARCalibration/test/CMakeLists.txt +++ b/Modules/Applications/AppSARCalibration/test/CMakeLists.txt @@ -25,3 +25,12 @@ otb_test_application(NAME apTvRaSarRadiometricCalibration_RADARSAT2 VALID --compare-image ${EPSILON_5} ${BASELINE}/raTvSarRadiometricCalibration_RADARSAT2.tif ${TEMP}/apTvRaSarRadiometricCalibration_RADARSAT2.tif ) + +otb_test_application(NAME apTvRaSarDeburst_SENTINEL1 + APP SARDeburst + OPTIONS -in ${INPUTDATA}/s1a-iw1-slc-vh-amp_xt.tif + -out ${TEMP}/apTvRaSarDeburst_SENTINEL1_output.tif uint16 + VALID --compare-image ${NOTOL} + # Same baseline as filter test + ${BASELINE}/saTvSarDeburstImageFilterTestOutput.tif + ${TEMP}/apTvRaSarDeburst_SENTINEL1_output.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/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/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 55eecfa431adb46e1e6a67c03e6109b863bafe7f..043cc3710e56b548b80b225bfbd1ff7fcf2dff1e 100644 --- a/Modules/Filtering/MathParserX/include/otbParserX.h +++ b/Modules/Filtering/MathParserX/include/otbParserX.h @@ -26,7 +26,7 @@ #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 +#if defined(__apple_build_version__) && __apple_build_version__ >= 7000053 #pragma clang diagnostic ignored "-Winconsistent-missing-override" #endif diff --git a/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h b/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h index 3cd4af3b2bcae20e50a4a7323ad66ef59434b957..9e22f84968e16a1d48c02f674dc5e544e150be98 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.h @@ -25,7 +25,7 @@ namespace otb { /** \class WaveletsBandsListToWaveletsSynopsisImageFilter - * \brief Converts a list of wavelets bands to the traditionnal multi-resolution wavelets view + * \brief Converts a list of wavelets bands to the traditional multi-resolution wavelets view * * The decimation ratio is taken into account. * 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/MPI/MPIConfig/src/otbMPIConfig.cxx b/Modules/MPI/MPIConfig/src/otbMPIConfig.cxx index ca967ebb483028790fc83e36927839e956c6d65c..7de0fa870b8afb99a6e23033692ecaf316fee7c5 100644 --- a/Modules/MPI/MPIConfig/src/otbMPIConfig.cxx +++ b/Modules/MPI/MPIConfig/src/otbMPIConfig.cxx @@ -77,7 +77,7 @@ MPIConfig::Pointer MPIConfig::Instance() /** CreateInitialize MPI environment */ MPIConfig::MPIConfig() - : m_MyRank(0), + : m_MyRank(-1), m_NbProcs(0), m_abortOnException(true), m_initialized(false), diff --git a/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.h b/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..d7f85cb45914838489b3ac3f62224e98ba2dc38d --- /dev/null +++ b/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.h @@ -0,0 +1,100 @@ +/*========================================================================= + + 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 otbSarDeburstImageFilter_h +#define otbSarDeburstImageFilter_h + +#include "itkImageToImageFilter.h" +#include "itkSmartPointer.h" + +namespace otb +{ +/** \class SarDeburstImageFilter + * \brief Performs a deburst operation by removing redundant lines + * + * This filter performs a deburst operation by removing redundant + * lines between burst. This operation is useful when dealing with + * Sentinel1 IW SLC products, where each subswath is composed of + * several overlapping burst separated by black lines. Lines to remove + * are computed by SAR sensor model in OSSIM plugins. The output image + * is smaller in azimuth direction than the input line, because of + * removed lines. Note that the output sensor model is updated + * accordingly. This deburst filter is the perfect preprocessing step + * to orthorectify S1 IW SLC product with OTB without suffering from + * artifacts caused by bursts separation. + * + * Note that currently only Sentinel1 IW SLC products are supported. + * + * \ingroup OTBSARCalibration + */ + +template <class TImage> class ITK_EXPORT SarDeburstImageFilter : + public itk::ImageToImageFilter<TImage,TImage> +{ +public: + // Standard class typedefs + typedef SarDeburstImageFilter Self; + typedef itk::ImageToImageFilter<TImage,TImage> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + itkNewMacro(Self); + itkTypeMacro(SarDeburstImageFilter,ImageToImageFilter); + + typedef TImage ImageType; + typedef typename ImageType::RegionType RegionType; + typedef typename ImageType::PointType PointType; + + typedef std::pair<unsigned long, unsigned long> LinesRecordType; + typedef std::vector<LinesRecordType> LinesRecordVectorType; + +protected: + // Constructor + SarDeburstImageFilter(); + + // Destructor + virtual ~SarDeburstImageFilter() ITK_OVERRIDE {}; + + // Needs to be re-implemented since size of output is modified + virtual void GenerateOutputInformation() ITK_OVERRIDE; + + // Needs to be re-implemented since size of output is modified + virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; + + // Actual processing + virtual void ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE; + + RegionType OutputRegionToInputRegion(const RegionType& outputRegion) const; + +private: + SarDeburstImageFilter(const Self&); // purposely not implemented + void operator=(const Self &); // purposely not implemented + + // Vector of line records + LinesRecordVectorType m_LinesRecord; + +}; + +} // End namespace otb + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbSarDeburstImageFilter.txx" +#endif + + + +#endif diff --git a/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.txx b/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.txx new file mode 100644 index 0000000000000000000000000000000000000000..3b7d737986a60c6126fbff824512b794c01116f5 --- /dev/null +++ b/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.txx @@ -0,0 +1,241 @@ +/*========================================================================= + + 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 otbSarDeburstImageFilter_txx +#define otbSarDeburstImageFilter_txx + +#include "otbSarDeburstImageFilter.h" + +#include "otbSarSensorModelAdapter.h" +#include "otbImageKeywordlist.h" +#include "itkImageScanlineIterator.h" +#include "itkImageScanlineConstIterator.h" + +namespace otb +{ +// Constructor +template <class TImage> SarDeburstImageFilter<TImage>::SarDeburstImageFilter() + : m_LinesRecord() +{} + +// Needs to be re-implemented since size of output is modified +template< class TImage> +void +SarDeburstImageFilter<TImage>::GenerateOutputInformation() +{ + // Call superclass implementation + Superclass::GenerateOutputInformation(); + + // Retrieve the input image pointer + const ImageType * inputPtr = this->GetInput(); + ImageType * outputPtr = this->GetOutput(); + + // Check that azimuth spacing has not been modified + if(vcl_abs(inputPtr->GetSpacing()[1]-1.)>=std::numeric_limits<double>::epsilon()) + itkExceptionMacro("Can not perform deburst if input image azimuth spacing is not 1."); + + // Check that the azimuth sampling grid has not been modified + if(vcl_abs(inputPtr->GetOrigin()[1]-static_cast<long>(inputPtr->GetOrigin()[1])-0.5)>=std::numeric_limits<double>::epsilon()) + itkExceptionMacro("Can not perform deburst if input image azimuth origin is not N.5"); + + // Retrieve input image keywordlist + ImageKeywordlist inputKwl = inputPtr->GetImageKeywordlist(); + + // Try to create a SarSensorModelAdapter + SarSensorModelAdapter::Pointer sarSensorModel = SarSensorModelAdapter::New(); + bool loadOk = sarSensorModel->LoadState(inputKwl); + + if(!loadOk || !sarSensorModel->IsValidSensorModel()) + itkExceptionMacro(<<"Input image does not contain a valid SAR sensor model."); + + // Try to call the deburst function + bool deburstOk = sarSensorModel->Deburst(m_LinesRecord); + + if(!deburstOk || m_LinesRecord.empty()) + itkExceptionMacro(<<"Could not deburst SAR sensor model from input image"); + + // Compute the actual lines to remove + typename ImageType::RegionType largestPossibleRegion = this->GetInput()->GetLargestPossibleRegion(); + typename ImageType::PointType origin = this->GetInput()->GetOrigin(); + + // Export the new keywordlist + ImageKeywordlist newKwl; + + bool saveOk = sarSensorModel->SaveState(newKwl); + + if(!saveOk) + itkExceptionMacro(<<"Could not export deburst SAR sensor model to keyword list"); + + // Set new keyword list to output image + outputPtr->SetImageKeywordList(newKwl); + + // Now, filter the LinesRecord so as to account for possible + // extracts on input image + long firstInputLine = static_cast<long>(origin[1]-0.5); + + // We know that spacing[1]=1. + long lastInputLine = static_cast<long>(origin[1]-0.5+largestPossibleRegion.GetSize()[1]-1); + + // Move origin + unsigned long outputOriginLine = 0; + SarSensorModelAdapter::ImageLineToDeburstLine(m_LinesRecord,firstInputLine,outputOriginLine); + + // std::cout<<"OutputOriginLine: "<<outputOriginLine<<std::endl; + + origin[1]=0.5+outputOriginLine; + outputPtr->SetOrigin(origin); + + // Update line records to accomodate actual input image region + LinesRecordVectorType filteredRecords; + + for(LinesRecordVectorType::const_iterator it = m_LinesRecord.begin(); + it!=m_LinesRecord.end();++it) + { + // If record is inside input image region + if((long)it->first<=lastInputLine && (long)it->second>=firstInputLine) + { + LinesRecordType filteredRecord = *it; + filteredRecord.first = std::max((long)filteredRecord.first,firstInputLine); + filteredRecord.second = std::min((long)filteredRecord.second,lastInputLine); + filteredRecords.push_back(filteredRecord); + } + } + + // Use filtered records + // m_LinesRecord.swap(filteredRecords); + + // TODO: Ensure that records are sorted ? + + // Compute deburst azimuth size + typename ImageType::SizeType deburstSize = largestPossibleRegion.GetSize(); + deburstSize[1]=0; + + + for(LinesRecordVectorType::const_iterator it = filteredRecords.begin(); + it!=filteredRecords.end();++it) + { + deburstSize[1]+=it->second-it->first+1; + } + + // Set largest possible region + typename ImageType::RegionType outputLargestPossibleRegion = largestPossibleRegion; + largestPossibleRegion.SetSize(deburstSize); + outputPtr->SetLargestPossibleRegion(largestPossibleRegion); +} + +template<class TImage> +typename SarDeburstImageFilter<TImage>::RegionType +SarDeburstImageFilter<TImage>::OutputRegionToInputRegion(const RegionType& outputRegion) const +{ + PointType outputUperLeft, outputLowerLeft; + + typename RegionType::IndexType outputUpperLeftIndex = outputRegion.GetIndex(); + typename RegionType::IndexType outputLowerLeftIndex = outputUpperLeftIndex; + outputLowerLeftIndex[1]+=outputRegion.GetSize()[1]-1; + + this->GetOutput()->TransformIndexToPhysicalPoint(outputUpperLeftIndex,outputUperLeft); + this->GetOutput()->TransformIndexToPhysicalPoint(outputLowerLeftIndex,outputLowerLeft); + + // TODO: Watch for <0 + unsigned long upperLeftLine = static_cast<unsigned long>(outputUperLeft[1]-0.5); + unsigned long lowerLeftLine = static_cast<unsigned long>(outputLowerLeft[1]-0.5); + + unsigned long inputUpperLeftLine, inputLowerLeftLine; + + SarSensorModelAdapter::DeburstLineToImageLine(m_LinesRecord,upperLeftLine,inputUpperLeftLine); + SarSensorModelAdapter::DeburstLineToImageLine(m_LinesRecord,lowerLeftLine,inputLowerLeftLine); + + long originOffset = static_cast<long>(this->GetInput()->GetOrigin()[1]-0.5); + + inputUpperLeftLine-=originOffset; + inputLowerLeftLine-=originOffset; + + RegionType inputRegion = outputRegion; + + typename RegionType::SizeType size = inputRegion.GetSize(); + typename RegionType::IndexType index = inputRegion.GetIndex(); + + index[1]=inputUpperLeftLine; + size[1]=inputLowerLeftLine-inputUpperLeftLine+1; + + inputRegion.SetIndex(index); + inputRegion.SetSize(size); + + return inputRegion; +} + + +// Needs to be re-implemented since size of output is modified +template <class TImage> void SarDeburstImageFilter<TImage>::GenerateInputRequestedRegion() +{ + RegionType outputRequestedRegion = this->GetOutput()->GetRequestedRegion(); + RegionType inputRequestedRegion = OutputRegionToInputRegion(outputRequestedRegion); + + ImageType * inputPtr = const_cast<ImageType *>(this->GetInput()); + + inputPtr->SetRequestedRegion(inputRequestedRegion); +} + +// Actual processing +template <class TImage> void SarDeburstImageFilter<TImage>::ThreadedGenerateData(const RegionType& outputRegionForThread, itk::ThreadIdType itkNotUsed(threadId)) +{ + // Compute corresponding input region + RegionType inputRegionForThread = OutputRegionToInputRegion(outputRegionForThread); + + itk::ImageScanlineConstIterator<ImageType> inputIt(this->GetInput(),inputRegionForThread); + itk::ImageScanlineIterator<ImageType> outputIt(this->GetOutput(),outputRegionForThread); + + inputIt.GoToBegin(); + outputIt.GoToBegin(); + + while(!inputIt.IsAtEnd()&&!outputIt.IsAtEnd()) + { + typename ImageType::IndexType currentInputIndex = inputIt.GetIndex(); + PointType currentInputPoint; + this->GetInput()->TransformIndexToPhysicalPoint(currentInputIndex,currentInputPoint); + + bool lineToKeep = false; + + for(LinesRecordVectorType::const_iterator it = m_LinesRecord.begin(); + it!=m_LinesRecord.end();++it) + { + if(currentInputPoint[1]-0.5>=it->first && currentInputPoint[1]-0.5<=it->second) + { + lineToKeep = true; + break; + } + } + if(lineToKeep) + { + for(inputIt.GoToBeginOfLine(),outputIt.GoToBeginOfLine(); + !inputIt.IsAtEndOfLine() && !outputIt.IsAtEndOfLine(); + ++inputIt,++outputIt) + { + outputIt.Set(inputIt.Get()); + + } + outputIt.NextLine(); + } + + + inputIt.NextLine(); + } +} + +} // End namespace otb + +#endif diff --git a/Modules/Radiometry/SARCalibration/test/CMakeLists.txt b/Modules/Radiometry/SARCalibration/test/CMakeLists.txt index f6ccc87ca94ee82085d126f21975218c0927a20d..849187da1d11b9aee6a912ded03ff4cd3f2a2ca9 100644 --- a/Modules/Radiometry/SARCalibration/test/CMakeLists.txt +++ b/Modules/Radiometry/SARCalibration/test/CMakeLists.txt @@ -22,6 +22,7 @@ otbSarRadiometricCalibrationFunctionWithoutNoise.cxx otbTerraSarBrightnessImageComplexFilterTest.cxx otbSarRadiometricCalibrationToImageFilterWithComplexPixelTest.cxx otbSarBrightnessToImageFilterTest.cxx +otbSarDeburstFilterTest.cxx ) add_executable(otbSARCalibrationTestDriver ${OTBSARCalibrationTests}) @@ -272,3 +273,11 @@ otb_add_test(NAME raTvSarBrightnessToImageFilter COMMAND otbSARCalibrationTestD ${TEMP}/raTvSarBrightnessToImageFilter_TSX_PANGKALANBUUN_HH.tif 1000 1000 250 250 # Extract ) + +otb_add_test(NAME saTvSarDeburstImageFilterTest COMMAND otbSARCalibrationTestDriver + --compare-image ${NOTOL} + ${BASELINE}/saTvSarDeburstImageFilterTestOutput.tif + ${TEMP}/saTvSarDeburstImageFilterTestOutput.tif + otbSarDeburstFilterTest + ${INPUTDATA}/s1a-iw1-slc-vh-amp_xt.tif + ${TEMP}/saTvSarDeburstImageFilterTestOutput.tif) diff --git a/Modules/Radiometry/SARCalibration/test/otbSARCalibrationTestDriver.cxx b/Modules/Radiometry/SARCalibration/test/otbSARCalibrationTestDriver.cxx index 873a912bbe6538f0583e348a02184b4bcca4e6f9..fd15425b0c5f6a310cf3211b584d32163e7a0104 100644 --- a/Modules/Radiometry/SARCalibration/test/otbSARCalibrationTestDriver.cxx +++ b/Modules/Radiometry/SARCalibration/test/otbSARCalibrationTestDriver.cxx @@ -21,4 +21,5 @@ void RegisterTests() REGISTER_TEST(otbTerraSarBrightnessImageComplexFilterTest); REGISTER_TEST(otbSarRadiometricCalibrationToImageFilterWithComplexPixelTest); REGISTER_TEST(otbSarBrightnessToImageFilterTest); + REGISTER_TEST(otbSarDeburstFilterTest); } diff --git a/Modules/Radiometry/SARCalibration/test/otbSarDeburstFilterTest.cxx b/Modules/Radiometry/SARCalibration/test/otbSarDeburstFilterTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ec3f2347801d56e8075e311fea9d66358ce3fe9d --- /dev/null +++ b/Modules/Radiometry/SARCalibration/test/otbSarDeburstFilterTest.cxx @@ -0,0 +1,43 @@ +/*========================================================================= + + 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 "otbSarDeburstImageFilter.h" +#include "otbImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" + +typedef otb::Image<unsigned short> ImageType; +typedef otb::ImageFileReader<ImageType> ReaderType; +typedef otb::ImageFileWriter<ImageType> WriterType; +typedef otb::SarDeburstImageFilter<ImageType> DeburstFilterType; + +int otbSarDeburstFilterTest(int itkNotUsed(argc), char * argv[]) +{ + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(argv[1]); + + DeburstFilterType::Pointer filter = DeburstFilterType::New(); + filter->SetInput(reader->GetOutput()); + + WriterType::Pointer writer = WriterType::New(); + writer->SetInput(filter->GetOutput()); + writer->SetFileName(argv[2]); + writer->Update(); + + return EXIT_SUCCESS; +} + 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/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyDecompositionImageFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyDecompositionImageFilter.h index bc8a2915b3896d264507b262b07b51ae86bd6b48..b8f6c1c996e8a021d1f88c8c60d408eceaf098c3 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyDecompositionImageFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyDecompositionImageFilter.h @@ -174,6 +174,8 @@ private: bool m_PreserveIntensities; /** Use fully connected morphological operators */ bool m_FullyConnected; + /** Progress accumulator to report internal filter progress */ + itk::ProgressAccumulator::Pointer m_Progress; }; } // End namespace otb diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyDecompositionImageFilter.txx b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyDecompositionImageFilter.txx index bb910c8192f934669b3efd463e67d840b26c6acd..adec859e7bad72183dc1d18bdb6e28d28de543cf 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyDecompositionImageFilter.txx +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyDecompositionImageFilter.txx @@ -36,12 +36,24 @@ GeodesicMorphologyDecompositionImageFilter<TInputImage, TOutputImage, TStructuri m_Radius.Fill(1); + // Create a process accumulator for tracking the progress of minipipeline + m_Progress = itk::ProgressAccumulator::New(); + m_Progress->SetMiniPipelineFilter(this); + m_OpeningFilter = OpeningFilterType::New(); m_ClosingFilter = ClosingFilterType::New(); m_LevelingFilter = LevelingFilterType::New(); m_ConvexFilter = ConvexFilterType::New(); m_ConcaveFilter = ConcaveFilterType::New(); + // Register Internal Filter for progress + m_Progress->RegisterInternalFilter(m_OpeningFilter, 0.2); + m_Progress->RegisterInternalFilter(m_ClosingFilter, 0.2); + m_Progress->RegisterInternalFilter(m_LevelingFilter, 0.2); + m_Progress->RegisterInternalFilter(m_ConvexFilter, 0.2); + m_Progress->RegisterInternalFilter(m_ConcaveFilter, 0.2); + + m_FullyConnected = true; m_PreserveIntensities = true; } diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyIterativeDecompositionImageFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyIterativeDecompositionImageFilter.h index e37c89b1a7b8810e43d7485bc33895564aff7f1b..a15b08f2fe92c733db63fb237fff8e1f2ad4f3fc 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyIterativeDecompositionImageFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyIterativeDecompositionImageFilter.h @@ -146,6 +146,8 @@ private: unsigned int m_InitialValue; /** The number of iterations */ unsigned int m_NumberOfIterations; + /** Progress accumulator to report internal filter progress */ + itk::ProgressAccumulator::Pointer m_Progress; }; } // End namespace otb diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyIterativeDecompositionImageFilter.txx b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyIterativeDecompositionImageFilter.txx index e88d11f9b9ef422a7b097c902fbdad9ed28c235b..06da40f579983cbe58b351eac567b0727a3664f6 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyIterativeDecompositionImageFilter.txx +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbGeodesicMorphologyIterativeDecompositionImageFilter.txx @@ -32,6 +32,10 @@ template <class TImage, class TStructuringElement> GeodesicMorphologyIterativeDecompositionImageFilter<TImage, TStructuringElement> ::GeodesicMorphologyIterativeDecompositionImageFilter() { + // Create a process accumulator for tracking the progress of minipipeline + m_Progress = itk::ProgressAccumulator::New(); + m_Progress->SetMiniPipelineFilter(this); + this->SetNumberOfRequiredInputs(1); this->SetNumberOfRequiredOutputs(3); m_NumberOfIterations = 2; @@ -185,6 +189,10 @@ GeodesicMorphologyIterativeDecompositionImageFilter<TImage, TStructuringElement> while (i < m_NumberOfIterations) { filter = DecompositionFilterType::New(); + + // Register Internal Filter for progress + m_Progress->RegisterInternalFilter(filter, 1./m_NumberOfIterations); + typename StructuringElementType::RadiusType radius; radius.Fill(m_InitialValue + i * m_Step); filter->SetRadius(radius); @@ -195,8 +203,8 @@ GeodesicMorphologyIterativeDecompositionImageFilter<TImage, TStructuringElement> filter->GetOutput()->UpdateOutputData(); outputPtr->SetNthElement(i, filter->GetOutput()); - concOutputPtr->SetNthElement(i, filter->GetConvexMap()); - convOutputPtr->SetNthElement(i, filter->GetConcaveMap()); + concOutputPtr->SetNthElement(i, filter->GetConcaveMap()); + convOutputPtr->SetNthElement(i, filter->GetConvexMap()); current = filter->GetOutput(); diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp index e59b428bbf007ee10fc5b45f576213af28c7d5c2..22d7dce984c6573bb5136a5e07d5e1131f55456c 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.cpp @@ -821,7 +821,7 @@ namespace ossimplugins bool ossimSarSensorModel::autovalidateInverseModelFromGCPs(const double & xtol, const double & ytol, const double azTimeTol, const double & rangeTimeTol) const { - // std::clog << "ossimSarSensorModel::autovalidateInverseModelFromGCPs()\n"; + std::clog << "ossimSarSensorModel::autovalidateInverseModelFromGCPs()\n"; if(theGCPRecords.empty()) { return false; @@ -831,7 +831,7 @@ namespace ossimplugins unsigned int gcpId = 1; - // std::clog << theGCPRecords.size() << " GCPS\n"; + std::clog << theGCPRecords.size() << " GCPS\n"; for(std::vector<GCPRecordType>::const_iterator gcpIt = theGCPRecords.begin(); gcpIt!=theGCPRecords.end();++gcpIt,++gcpId) { ossimDpt estimatedImPt; @@ -1172,8 +1172,151 @@ namespace ossimplugins } return false; } + +bool ossimSarSensorModel::deburst(std::vector<std::pair<unsigned long, unsigned long> >& lines) +{ + if(theBurstRecords.empty()) + return false; + + // First, clear lines record + lines.clear(); + + // Check the single burst record case + if(theBurstRecords.size() == 1) + { + lines.push_back(std::make_pair(theBurstRecords.front().startLine,theBurstRecords.front().endLine)); + return false; + } + + // TODO: Ensure bursts are sorted + + // Process each burst + std::vector<BurstRecordType>::const_iterator it = theBurstRecords.begin(); + // Correct since we have at least 2 bursts records + std::vector<BurstRecordType>::const_iterator next = it+1; + std::vector<BurstRecordType>::const_iterator itend = theBurstRecords.end(); + + unsigned long currentStart = it->startLine; + TimeType deburstAzimuthStartTime = it->azimuthStartTime; + + unsigned long deburstEndLine = 0; + + for(; next!= itend ;++it,++next) + { + DurationType timeOverlapEnd = (it->azimuthStopTime - next->azimuthStartTime); + + unsigned long overlapLength = timeOverlapEnd/theAzimuthTimeInterval; + + unsigned long halfLineOverlapEnd = overlapLength/2; + TimeType endTimeInNextBurst = it->azimuthStopTime-(halfLineOverlapEnd-1)*theAzimuthTimeInterval; + + unsigned long halfLineOverlapBegin = std::floor(0.5+(endTimeInNextBurst-next->azimuthStartTime)/theAzimuthTimeInterval); + + unsigned long currentStop = it->endLine-halfLineOverlapEnd; + + deburstEndLine+=currentStop-currentStart; + + lines.push_back(std::make_pair(currentStart,currentStop)); + + currentStart = next->startLine+halfLineOverlapBegin; + } + + TimeType deburstAzimuthStopTime = it->azimuthStopTime; + deburstEndLine+=it->endLine-currentStart; + + lines.push_back(std::make_pair(currentStart,it->endLine)); + + // Now, update other metadata accordingly + + // Clear the previous burst records + theBurstRecords.clear(); + + // Create the single burst + BurstRecordType deburstBurst; + deburstBurst.startLine = 0; + deburstBurst.azimuthStartTime = deburstAzimuthStartTime; + deburstBurst.endLine = deburstEndLine; + deburstBurst.azimuthStopTime = deburstAzimuthStopTime; + + theBurstRecords.push_back(deburstBurst); + + std::vector<GCPRecordType> deburstGCPs; + + // Now move GCPs + for(std::vector<GCPRecordType>::iterator gcpIt = theGCPRecords.begin(); gcpIt!=theGCPRecords.end();++gcpIt) + { + GCPRecordType currentGCP = *gcpIt; + unsigned long newLine=0; + + unsigned long gcpLine = std::floor(currentGCP.imPt.y+0.5); + + // Be careful about fractional part of GCPs + double fractional = currentGCP.imPt.y - gcpLine; + + bool deburstOk = imageLineToDeburstLine(lines,gcpLine,newLine); + + if(deburstOk) + { + currentGCP.imPt.y = newLine+fractional; + deburstGCPs.push_back(currentGCP); + } + } + + theGCPRecords.swap(deburstGCPs); + + return true; +} + +bool ossimSarSensorModel::imageLineToDeburstLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long imageLine, unsigned long & deburstLine) +{ + std::vector<std::pair<unsigned long,unsigned long> >::const_iterator vit = lines.begin(); + std::vector<std::pair<unsigned long,unsigned long> >::const_iterator nit = vit+1; + + unsigned long lineOffset = vit->first; + + deburstLine = imageLine; + + while(nit != lines.end()) + { + if(imageLine>=vit->first && imageLine<=vit->second) + { + deburstLine-=lineOffset; + return true; + } + lineOffset+=nit->first - vit->second-1; + ++vit; + ++nit; + } + return false; +} + +void ossimSarSensorModel::deburstLineToImageLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long deburstLine, unsigned long & imageLine) +{ + std::vector<std::pair<unsigned long,unsigned long> >::const_iterator vit = lines.begin(); + std::vector<std::pair<unsigned long,unsigned long> >::const_iterator nit = vit+1; + + unsigned long lineOffset = vit->first; + + imageLine = deburstLine; + + while(nit != lines.end()) + { + if(imageLine+lineOffset>=vit->first && imageLine+lineOffset<=vit->second) + break; + + lineOffset+=nit->first - vit->second-1; + ++vit; + ++nit; + } + imageLine+=lineOffset; } + +} + + + + namespace ossimplugins { template <typename T> inline std::ostream & operator<<(std::ostream & os, const std::vector<T> & v) diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.h index 2c113c8921e395ef945a810b2141a53b03de47ef..cb5d6e06304c401b7443d76da0aee10c52f96a51 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.h +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSarSensorModel.h @@ -243,6 +243,38 @@ public: void optimizeTimeOffsetsFromGcps(); + /** + * This method will perform a deburst operation, and return the + * a vector of lines range of lines to keep in the image file. + * Note that the deburst operation has no effect if theBurstRecords + * contains a single burst. Otherwise it will merge burst together + * into a single burst, and update GCPs accordingly. + * \return true if the deburst operation succeeded. No changes is + * made to the object if the operation fails. + * \param lines A container for the lines ranges to keep in the + * deburst image. + */ + bool deburst(std::vector<std::pair<unsigned long,unsigned long> >& lines); + + /** + * This is a helper function to convert image line to deburst image + * line. + * \param lines The vector of lines range to keep + * \param imageLine The input image line + * \param deburstLine The output deburst line + * \return True if imageLine is within a preserved range, false otherwise + */ + static bool imageLineToDeburstLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long imageLine, unsigned long & deburstLine); + + /** + * This is a helper function to convert deburst line to input image + * line + * \param lines The vector of lines range to keep + * \param imageLine The input deburst line + * \param deburstLine The output original image line + */ + static void deburstLineToImageLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines, unsigned long deburstLine, unsigned long & imageLine); + /** * Returns pointer to a new instance, copy of this. */ diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp index acfecf8f58ad57fb8222fea2d274b101b1e874ee..4dd192df8ca56dadddf4bf1ea5225c963f573363 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp @@ -137,6 +137,25 @@ namespace ossimplugins kwl.addList(theManifestKwl, true); kwl.addList(theProductKwl, true); + // Rewrite burst records since model could have been debursted + kwl.removeKeysThatMatch(BURST_PREFIX+"*"); + + add(kwl,BURST_NUMBER_KEY.c_str(),(unsigned int)theBurstRecords.size()); + + unsigned int burstId(0); + char burstPrefix[1024]; + + for(std::vector<BurstRecordType>::const_iterator burstIt = theBurstRecords.begin(); + burstIt!=theBurstRecords.end();++burstIt) + { + s_printf(burstPrefix, "%s[%d].", BURST_PREFIX.c_str(), burstId); + add(kwl,burstPrefix+keyStartLine,(ossim_uint32)burstIt->startLine); + add(kwl,burstPrefix+keyEndLine,(ossim_uint32)burstIt->endLine); + add(kwl,burstPrefix+keyAzimuthStartTime,burstIt->azimuthStartTime); + add(kwl,burstPrefix+keyAzimuthStopTime,burstIt->azimuthStopTime); + ++burstId; + } + return ossimSarSensorModel::saveState(kwl, prefix); } @@ -235,20 +254,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 +264,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 +290,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/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp index c54d59f2e913f8696262d8baf1f3f46ec8a4e57c..a78f075cc7d0cece9834b76e64dc0ec2a28a23b2 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp @@ -203,6 +203,7 @@ void ossimSentinel1SarSensorModel::readAnnotationFile(const std::string & annota if(!end_found && *sIt=="-1") { end_found = true; + --last_valid; } else { diff --git a/Modules/ThirdParty/OssimPlugins/test/ossimSentinel1ModelTest.cpp b/Modules/ThirdParty/OssimPlugins/test/ossimSentinel1ModelTest.cpp index d7730aa7d9adaa2ad39bfc4d96aa44fefe2efdc5..d1aaaf7c25ddcb87ad1c0efbc70a9d5124a9f015 100644 --- a/Modules/ThirdParty/OssimPlugins/test/ossimSentinel1ModelTest.cpp +++ b/Modules/ThirdParty/OssimPlugins/test/ossimSentinel1ModelTest.cpp @@ -88,10 +88,27 @@ int main(int argc, char * argv[]) sensor->print(std::clog); } - const bool validate = inverse == inv + + bool validate = inverse == inv ? sensor->autovalidateInverseModelFromGCPs() : sensor->autovalidateForwardModelFromGCPs() ; + + std::vector<std::pair<unsigned long, unsigned long> > deburstLines; + + std::cout<<"Trying to deburst data ..."<<std::endl; + bool deburstOk = sensor->deburst(deburstLines); + std::cout<<"Deburst succeed: "<<(deburstOk?"yes":"no")<<std::endl; + + if(deburstOk) + { + + std::cout<<"Validation with deburst model"<<std::endl; + + validate = validate && (inverse == inv + ? sensor->autovalidateInverseModelFromGCPs() + : sensor->autovalidateForwardModelFromGCPs()); + } std::cout << "Validate: " << validate << "\n"; return validate ? EXIT_SUCCESS : EXIT_FAILURE; 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/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 482ed115167ad51c55084fb6843009f91c5c709b..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 - : GetCount()>0 ? 0 : StackedLayerModel::NIL_INDEX ); + : GetCount()>1 ? 0 : StackedLayerModel::NIL_INDEX ); // // Emit signals. 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.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_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/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/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..ec3a220ab75ebc19fdd540b78785e550264a281d 100755 --- a/SuperBuild/Packaging/Files/macx_pkgsetup.in +++ b/SuperBuild/Packaging/Files/macx_pkgsetup.in @@ -28,9 +28,12 @@ EXE_FILES=$(find "$OUT_DIR/bin" -type f -exec file {} \; | grep -i "Mach-O*.*ex for lib_file in $LIBRARY_FILES $EXE_FILES; do #echo "adding rpath to $OUT_DIR/$lib_file" if [ -f "$lib_file" ]; then - #echo "$INSTALL_NAME_TOOL -add_rpath $OUT_DIR/lib $lib_file" - $INSTALL_NAME_TOOL "-add_rpath" "$OUT_DIR/lib" "$lib_file" - fi + lib_file_original_rpaths=$(otool -l "$lib_file" | grep -A 3 "LC_RPATH" | grep -oE 'path .* \(offset' | cut -d ' ' -f 2) + for original_rpath in $lib_file_original_rpaths; do + $INSTALL_NAME_TOOL "-delete_rpath" "$original_rpath" "$lib_file" + done + $INSTALL_NAME_TOOL "-add_rpath" "$OUT_DIR/lib" "$lib_file" + fi done @@ -50,12 +53,15 @@ if [ "$I_AM_XDK" = false ] ; then OTB_APP_FILES=$(find "$OUT_DIR/lib/otb/applications" -maxdepth 1 -type f) # run install_name_tool for app_file in $OTB_APP_FILES; do - #echo "adding rpath to $app_file" - if [ -f "$app_file" ]; then - $INSTALL_NAME_TOOL "-add_rpath" "$OUT_DIR/lib" "$app_file" - fi + #echo "adding rpath to $app_file" + if [ -f "$app_file" ]; then + $INSTALL_NAME_TOOL "-rpath" "@ORIGINAL_RPATH_TO_REPLACE@" "$OUT_DIR/lib" "$app_file" + fi done - + if [ -f "$OUT_DIR/lib/python/_otbApplication.so" ]; then + $INSTALL_NAME_TOOL "-rpath" "@ORIGINAL_RPATH_TO_REPLACE@" "$OUT_DIR/lib" "$OUT_DIR/lib/python/_otbApplication.so" + fi + rm -fr "Mapla.app" rm -fr "Monteveridi.app" @@ -140,16 +146,25 @@ 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 +if [ -z "\$OTB_APPLICATION_PATH" ] || [ "\$OTB_APPLICATION_PATH" = "" ]; then + OTB_APPLICATION_PATH=$OUT_DIR/lib/otb/applications +else + OTB_APPLICATION_PATH=\$(readlink -f "\$OTB_APPLICATION_PATH") + if ! [ "\$OTB_APPLICATION_PATH" = "$OUT_DIR/lib/otb/applications" ]; then + OTB_APPLICATION_PATH=$OUT_DIR/lib/otb/applications:\$OTB_APPLICATION_PATH + fi +fi export LC_NUMERIC=C export PATH export GDAL_DATA export GEOTIFF_CSV export PYTHONPATH +export OTB_APPLICATION_PATH EOF chmod +x "$OUT_DIR/otbenv.profile" 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 4c33431831cd678c86ace612ce8cd401cc59929c..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 @@ -129,11 +131,8 @@ set(GTK_LIB_LIST_1 libffi.so.6 ) set(GTK_LIB_LIST_2 - libfreetype.so.6 libz.so.1 libpng12.so.0 - libexpat.so.1 - libfontconfig.so.1 ) 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 91eae8e359fe65c3efb313ba7a719674d4ee1f78..9ef66b1a70ae87fb3ed71db925f0cb931ef79130 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( @@ -184,7 +184,11 @@ macro(macro_super_package) file(APPEND ${CMAKE_BINARY_DIR}/make_symlinks "${make_symlink_cmd}\n") endforeach() - + + if(APPLE) + set(ORIGINAL_RPATH_TO_REPLACE ${DEPENDENCIES_INSTALL_DIR}/lib) + endif() + configure_file(${PACKAGE_SUPPORT_FILES_DIR}/${PKGSETUP_IN_FILENAME} ${CMAKE_BINARY_DIR}/pkgsetup @ONLY) @@ -329,7 +333,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) @@ -346,10 +352,13 @@ 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) + if(NOT is_executable) #copy back to input_file_full_path pkg_install_rule(${input_file_full_path}) @@ -376,23 +385,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 @@ -410,10 +419,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() @@ -423,25 +437,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}) @@ -450,7 +464,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) @@ -459,25 +473,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) diff --git a/SuperBuild/Packaging/PackageMacros.cmake b/SuperBuild/Packaging/PackageMacros.cmake index c5c975eb912ab369f6b57071855371cb5630af35..86a2901206ccced25a6ec1b7a6201edddf37bf40 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() @@ -115,9 +115,7 @@ function(is_file_executable2 file_var result_var) set(${result_var} 0 PARENT_SCOPE) get_filename_component(file_full "${${file_var}}" ABSOLUTE) - set(${file_var} "${file_full}" PARENT_SCOPE) string(TOLOWER "${file_full}" file_full_lower) - # If file name ends in .exe on Windows, *assume* executable: # if(WIN32 AND NOT UNIX) @@ -137,7 +135,12 @@ function(is_file_executable2 file_var result_var) 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}") - set(${file_var} "${file_full}" PARENT_SCOPE) + 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() @@ -238,6 +241,13 @@ function(is_file_executable2 file_var result_var) return() endif() + # detect shared libraries on Mac OSX + # where "file" gives "Mach-O 64-bit x86_64 bundle" + if("${file_ov}" MATCHES "mach-o.*bundle") + set(${result_var} 1 PARENT_SCOPE) + return() + endif() + endif(APPLE) endfunction() 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/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>