Commit 3bceaa54 authored by Manuel Grizonnet's avatar Manuel Grizonnet

Merge branch 'modulus_2bands' into 'develop'

ENH: Allow to compute modulus and phase from 2 bands scalar image

See merge request orfeotoolbox/otb!154
parents 5ec9d84f 11c304d9
......@@ -20,10 +20,10 @@
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"
#include "otbMultiToMonoChannelExtractROI.h"
#include "itkComplexToPhaseImageFilter.h"
#include "itkComplexToModulusImageFilter.h"
#include "itkMacro.h"
namespace otb
......@@ -52,7 +52,6 @@ public:
itkTypeMacro(ComputeModulusAndPhase, otb::Wrapper::Application);
//typedefs for the application
typedef otb::MultiToMonoChannelExtractROI<ComplexFloatVectorImageType::InternalPixelType, ComplexFloatImageType::PixelType> ExtractFilterType;
typedef itk::ComplexToModulusImageFilter<ComplexFloatImageType, FloatImageType> ModulusFilterType;
typedef itk::ComplexToPhaseImageFilter<ComplexFloatImageType, FloatImageType> PhaseFilterType;
......@@ -60,30 +59,30 @@ private:
void DoInit() override
SetDescription("This application computes the modulus and the phase of a complex SAR image.");
SetDescription("This application computes the modulus and the phase of a complex SAR image or an image with 2 components (real and imaginary parts).");
SetDocName("Compute Modulus And Phase");
SetDocName("Compute Modulus and Phase");
"This application computes the modulus and the phase of a "
"complex SAR image. The input should be a single band image with "
"complex pixels."
"complex pixels or a 2 bands image (real and imaginary components in separate bands)."
SetDocLimitations("The application takes as input single band image with complex pixels.");
SetDocLimitations("The application takes as input single band image with complex pixels or a 2 bands image (real and imaginary part in separate bands).");
SetDocAuthors("Alexia Mondot ( and Mickael Savinaud (");
SetDocSeeAlso("Despeckle, SARPolarMatrixConvert, SARPolarSynth");
// Input images
AddParameter(ParameterType_InputImage, "in", "Input Image");
SetParameterDescription("in", "Input image (complex single band)");
AddParameter(ParameterType_InputImage, "in", "Input Image");
SetParameterDescription("in","Input image (complex single band or 2 bands (real/imaginary parts))");
// Outputs
AddParameter(ParameterType_OutputImage, "modulus", "Modulus");
SetParameterDescription("modulus", "Modulus of the input image computes with the\n"
"following formula: :math:`\\sqrt{real*real + imag*imag}` where real and imag \n"
"are respectively the real and the imaginary part of the input complex image.\n");
AddParameter(ParameterType_OutputImage, "phase", "Phase");
SetParameterDescription("phase", "Phase of the input image computes with the following formula:\n"
":math:`\\tan^{-1}(\\frac{imag}{real})` where real and imag are respectively the real and\n"
......@@ -107,31 +106,24 @@ private:
// DoExecute() contains the application core.
void DoExecute() override
m_Modulus = ModulusFilterType::New();
m_Phase = PhaseFilterType::New();
ComplexFloatVectorImageType::Pointer inImage = GetParameterComplexFloatVectorImage("in");
// Read the input as a complex image (with one component) Input with 2
// components are also supported (band 1 is interpreted as the real part and
// band 2 as the imaginary part VectorImage of complex image are not
// supported by the application
ComplexFloatImageType::Pointer inImage = GetParameterComplexFloatImage("in");
if (inImage->GetNumberOfComponentsPerPixel() != 1)
otbAppLogFATAL("Input must be a single band complex image.");
// Get first band
m_Extract = ExtractFilterType::New();
ModulusFilterType::Pointer modulus = ModulusFilterType::New();
PhaseFilterType::Pointer phase = PhaseFilterType::New();
// Compute modulus and phase
SetParameterOutputImage("modulus", m_Modulus->GetOutput() );
SetParameterOutputImage("phase", m_Phase->GetOutput());
SetParameterOutputImage("modulus", modulus->GetOutput());
SetParameterOutputImage("phase", phase->GetOutput());
ExtractFilterType::Pointer m_Extract;
ModulusFilterType::Pointer m_Modulus;
PhaseFilterType::Pointer m_Phase;
} // namespace Wrapper
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment