diff --git a/Modules/Applications/AppSARUtils/CMakeLists.txt b/Modules/Applications/AppSARUtils/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..bd7a065d1828ce742920e76cd6382c222f5f67cf --- /dev/null +++ b/Modules/Applications/AppSARUtils/CMakeLists.txt @@ -0,0 +1,2 @@ +project(OTBAppSARUtils) +otb_module_impl() diff --git a/Modules/Applications/AppSARUtils/app/CMakeLists.txt b/Modules/Applications/AppSARUtils/app/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f0e7132c08c68baa6c95c2bc7dd114974e26278f --- /dev/null +++ b/Modules/Applications/AppSARUtils/app/CMakeLists.txt @@ -0,0 +1,9 @@ +set(OTBAppSARUtils_LINK_LIBS + ${OTBSARUtils_LIBRARIES} + ${OTBApplicationEngine_LIBRARIES} +) + +otb_create_application( + NAME ComputeModulusAndPhase + SOURCES otbComputeModulusAndPhase.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) diff --git a/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx b/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f3ea3c2349c357faf97b6a3d2baa6e36ed99725d --- /dev/null +++ b/Modules/Applications/AppSARUtils/app/otbComputeModulusAndPhase.cxx @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" +#include <otbMultiToMonoChannelExtractROI.h> + +#include "itkComplexToPhaseImageFilter.h" +#include "itkComplexToModulusImageFilter.h" +#include <itkMacro.h> + +namespace otb +{ +// Application class is defined in Wrapper namespace. +namespace Wrapper +{ + +/** \class ComputeModulusAndPhase + * \brief ComputeModulusAndPhase is an application that + * computes modulus and phase from a complex SAR image. + * + * \ingroup AppSARUtils + */ +class ComputeModulusAndPhase: public Application +{ +public: + // Class declaration is followed by ITK public types for the class, the superclass and smart pointers. + typedef ComputeModulusAndPhase Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Standard macro */ + itkNewMacro (Self); + itkTypeMacro(ComputeModulusAndPhase, otb::Wrapper::Application); + + //typedefs for the application + typedef otb::MultiToMonoChannelExtractROI<typename ComplexFloatVectorImageType::InternalPixelType, typename ComplexFloatImageType::PixelType> ExtractFilterType; + typedef itk::ComplexToModulusImageFilter<ComplexFloatImageType, FloatImageType> ModulusFilterType; + typedef itk::ComplexToPhaseImageFilter<ComplexFloatImageType, FloatImageType> PhaseFilterType; + +private: + void DoInit() + { + SetName("ComputeModulusAndPhase"); + SetDescription("This application computes the modulus and the phase of a complex SAR image."); + + SetDocName("Compute Modulus And Phase"); + SetDocLongDescription( + "This application computes the modulus and the phase of a " + "complex SAR image. The input shoud be a single band image with " + "complex pixels." + ); + SetDocLimitations("None"); + SetDocAuthors("Alexia Mondot (alexia.mondot@c-s.fr) and Mickael Savinaud (mickael.savinaud@c-s.fr)"); + SetDocSeeAlso("SARPolarMatrixConvert, SARPolarSynth"); + AddDocTag(Tags::SAR); + + // Input images + AddParameter(ParameterType_ComplexInputImage, "in", "Input Image"); + SetParameterDescription("in", "Input image (complex single band)"); + + // Outputs + AddParameter(ParameterType_OutputImage, "modulus", "Modulus"); + SetParameterDescription("modulus", "Modulus of the input: sqrt(real*real + imag*imag)."); + + AddParameter(ParameterType_OutputImage, "phase", "Phase"); + SetParameterDescription("phase", "Phase of the input: atan2(imag, real)."); + + AddRAMParameter(); + + // Doc example parameter settings + SetDocExampleParameterValue("in", "monobandComplexFloat.tif"); + SetDocExampleParameterValue("modulus", "modulus.tif"); + SetDocExampleParameterValue("phase", "phase.tif"); + } + + // DoUpdateParameters() is called as soon as a parameter value change. + void DoUpdateParameters() + { + } + + // DoExecute() contains the application core. + void DoExecute() + { + m_Modulus = ModulusFilterType::New(); + m_Phase = PhaseFilterType::New(); + + ComplexFloatVectorImageType::Pointer inImage = GetParameterComplexImage("in"); + + if (inImage->GetNumberOfComponentsPerPixel() != 1) + { + otbAppLogFATAL("Input must be a single band complex image."); + } + + // Get first band + m_Extract = ExtractFilterType::New(); + m_Extract->SetInput(inImage); + + // Compute modulus and phase + m_Modulus->SetInput(m_Extract->GetOutput()); + m_Phase->SetInput(m_Extract->GetOutput()); + + SetParameterOutputImage("modulus", m_Modulus->GetOutput() ); + SetParameterOutputImage("phase", m_Phase->GetOutput()); + } + + ExtractFilterType::Pointer m_Extract; + ModulusFilterType::Pointer m_Modulus; + PhaseFilterType::Pointer m_Phase; +}; + +} // namespace Wrapper +} // namespace otb +OTB_APPLICATION_EXPORT(otb::Wrapper::ComputeModulusAndPhase) diff --git a/Modules/Applications/AppSARUtils/otb-module.cmake b/Modules/Applications/AppSARUtils/otb-module.cmake new file mode 100644 index 0000000000000000000000000000000000000000..41a1b43467aa97d35721a46dd6f4e4f4ad6b04be --- /dev/null +++ b/Modules/Applications/AppSARUtils/otb-module.cmake @@ -0,0 +1,12 @@ +set(DOCUMENTATION "SAR Utils application.") + +otb_module(OTBAppSARUtils + DEPENDS + OTBApplicationEngine + TEST_DEPENDS + OTBTestKernel + OTBCommandLine + + DESCRIPTION + "${DOCUMENTATION}" + ) diff --git a/Modules/Applications/AppSARUtils/test/CMakeLists.txt b/Modules/Applications/AppSARUtils/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..65dc6b75a9de038c360f9671a1a83c357a020bed --- /dev/null +++ b/Modules/Applications/AppSARUtils/test/CMakeLists.txt @@ -0,0 +1,13 @@ +otb_module_test() +#----------- ComputeModulusAndPhase TESTS ---------------- +otb_test_application(NAME apTvUtComputeModulusAndPhase_1inputComplex + APP ComputeModulusAndPhase + OPTIONS -in ${INPUTDATA}/monobandComplexFloat.tif + -modulus ${TEMP}/apTvUtMod1inputComplex.tif + -phase ${TEMP}/apTvUtPha1inputComplex.tif + VALID --compare-n-images ${EPSILON_6} 2 + ${BASELINE}/Mod_monobandComplexFloat.tif + ${TEMP}/apTvUtMod1inputComplex.tif + ${BASELINE}/Pha_monobandComplexFloat.tif + ${TEMP}/apTvUtPha1inputComplex.tif + ) diff --git a/Modules/Filtering/MathParser/src/otbParser.cxx b/Modules/Filtering/MathParser/src/otbParser.cxx index 56bdd287dcdb7f2c12fdb481bbe7d6f71dd03de4..4280d3ac9c85b508453b5c23685bf0dc52f89255 100644 --- a/Modules/Filtering/MathParser/src/otbParser.cxx +++ b/Modules/Filtering/MathParser/src/otbParser.cxx @@ -62,6 +62,7 @@ public: { m_MuParser.DefineFun("ndvi", Self::NDVI); m_MuParser.DefineFun("NDVI", Self::NDVI); + m_MuParser.DefineFun("atan2", Self::ATAN2); #ifdef OTB_MUPARSER_HAS_CXX_LOGICAL_OPERATORS /* Starting with muParser 2.0.0, logical operators have been @@ -208,6 +209,11 @@ private: } return (niri-r)/(niri+r); } + + static ValueType ATAN2(ValueType y, ValueType x) + { + return vcl_atan2(y,x); + } #ifdef OTB_MUPARSER_HAS_CXX_LOGICAL_OPERATORS static ValueType AND(ValueType left, ValueType right) diff --git a/Modules/Visualization/Monteverdi/src/main.cxx b/Modules/Visualization/Monteverdi/src/main.cxx index feccb84f5e3451e40784f083693ea57d608cb1cc..e44dbb8459d0b239c8bc5c5283d5c41a6412d7ef 100644 --- a/Modules/Visualization/Monteverdi/src/main.cxx +++ b/Modules/Visualization/Monteverdi/src/main.cxx @@ -111,7 +111,7 @@ main( int argc, char* argv[] ) QCoreApplication::translate( PROJECT_NAME, "Usage: %1 [-h|--help] [-a|--applications] [<filename>...]\n" - " -1, --no-glsl force OpenGL 1.x compatible rendering." + " -n, --no-glsl force OpenGL 1.x compatible rendering." " -a, --applications load OTB-applications from OTB_APPLICATIONS_PATH." " -h, --help display this help message.\n" ) @@ -130,7 +130,7 @@ main( int argc, char* argv[] ) it = args.erase( it ); } - else if(it->compare( "-1" )==0 || + else if(it->compare( "-n" )==0 || it->compare( "--no-glsl" )==0 ) { flags.forceNoGLSL = true;