Skip to content
Snippets Groups Projects
Commit 6efe1c4b authored by Julien Michel's avatar Julien Michel
Browse files

Merge branch 'develop' of https://git.orfeo-toolbox.org/git/otb into develop

parents 125e89ec dcac38f9
No related branches found
No related tags found
No related merge requests found
project(OTBAppSARUtils)
otb_module_impl()
set(OTBAppSARUtils_LINK_LIBS
${OTBSARUtils_LIBRARIES}
${OTBApplicationEngine_LIBRARIES}
)
otb_create_application(
NAME ComputeModulusAndPhase
SOURCES otbComputeModulusAndPhase.cxx
LINK_LIBRARIES ${${otb-module}_LIBRARIES})
/*
* 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)
set(DOCUMENTATION "SAR Utils application.")
otb_module(OTBAppSARUtils
DEPENDS
OTBApplicationEngine
TEST_DEPENDS
OTBTestKernel
OTBCommandLine
DESCRIPTION
"${DOCUMENTATION}"
)
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
)
......@@ -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)
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment