From 75bfb38c98ac24cda87c4a386335673495871f2f Mon Sep 17 00:00:00 2001 From: Christophe Palmann <christophe.palmann@c-s.fr> Date: Thu, 23 Jul 2015 17:20:51 +0200 Subject: [PATCH] ENH: added new application for performing polarimetric decompositions (SAR) --- .../AppSARDecompositions/CMakeLists.txt | 2 + .../AppSARDecompositions/app/CMakeLists.txt | 12 ++ .../app/otbSARDecompositions.cxx | 167 ++++++++++++++++++ .../AppSARDecompositions/otb-module.cmake | 17 ++ .../AppSARDecompositions/test/CMakeLists.txt | 16 ++ 5 files changed, 214 insertions(+) create mode 100644 Modules/Applications/AppSARDecompositions/CMakeLists.txt create mode 100644 Modules/Applications/AppSARDecompositions/app/CMakeLists.txt create mode 100644 Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx create mode 100644 Modules/Applications/AppSARDecompositions/otb-module.cmake create mode 100644 Modules/Applications/AppSARDecompositions/test/CMakeLists.txt diff --git a/Modules/Applications/AppSARDecompositions/CMakeLists.txt b/Modules/Applications/AppSARDecompositions/CMakeLists.txt new file mode 100644 index 0000000000..aa7832f8f4 --- /dev/null +++ b/Modules/Applications/AppSARDecompositions/CMakeLists.txt @@ -0,0 +1,2 @@ +project(OTBAppSARDecompositions) +otb_module_impl() diff --git a/Modules/Applications/AppSARDecompositions/app/CMakeLists.txt b/Modules/Applications/AppSARDecompositions/app/CMakeLists.txt new file mode 100644 index 0000000000..d311a3c7e5 --- /dev/null +++ b/Modules/Applications/AppSARDecompositions/app/CMakeLists.txt @@ -0,0 +1,12 @@ +set(OTBAppFiltering_LINK_LIBS + ${OTBPolarimetry_LIBRARIES} + ${OTBImageManipulation_LIBRARIES} + ${OTBApplicationEngine_LIBRARIES} + ${OTBImageBase_LIBRARIES} +) + +otb_create_application( + NAME SARDecompositions + SOURCES otbSARDecompositions.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + diff --git a/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx new file mode 100644 index 0000000000..c4ae956f55 --- /dev/null +++ b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx @@ -0,0 +1,167 @@ +/*========================================================================= + + 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 "otbReciprocalHAlphaImageFilter.h" +#include "otbSinclairReciprocalImageFilter.h" +#include "otbSinclairToReciprocalCoherencyMatrixFunctor.h" + + +namespace otb +{ +namespace Wrapper +{ + +class SARDecompositions : public Application +{ +public: + /** Standard class typedefs. */ + typedef SARDecompositions Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + + + typedef otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor<ComplexFloatImageType::PixelType, + ComplexFloatImageType::PixelType, + ComplexFloatImageType::PixelType, + ComplexFloatVectorImageType::PixelType> FunctorType; + + + typedef SinclairReciprocalImageFilter<ComplexFloatImageType, + ComplexFloatImageType, + ComplexFloatImageType, + ComplexFloatVectorImageType, + FunctorType > SRFilterType; + + + typedef otb::ReciprocalHAlphaImageFilter<ComplexFloatVectorImageType, FloatVectorImageType> HAFilterType; + + + + + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(SARDecompositions, otb::Application); + +private: + void DoInit() + { + SetName("SARDecompositions"); + SetDescription("From one-band complex images (HH, HV or VH, VV), returns the selected decomposition."); + + // Documentation + SetDocName("SARDecompositions"); + SetDocLongDescription("From one-band complex images (HH, HV, VH, VV), returns the selected decomposition.\n" + "The H-alpha-A decomposition is currently the only one available; it is implemented for the monostatic case (transmitter and receiver are co-located).\n" + "User must provide three one-band complex images HH, HV or VH, and VV (monostatic case <=> HV = VH).\n" + "The applications returns a float vector image, made of three channels : H (entropy), Alpha, A (Anisotropy)." ); + + SetDocLimitations("None"); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso(""); + + AddDocTag(Tags::SAR); + + AddParameter(ParameterType_ComplexInputImage, "inhh", "Input Image"); + SetParameterDescription("inhh", "Input image (HH)"); + + AddParameter(ParameterType_ComplexInputImage, "inhv", "Input Image"); + SetParameterDescription("inhv", "Input image (HV)"); + MandatoryOff("inhv"); + + AddParameter(ParameterType_ComplexInputImage, "invh", "Input Image"); + SetParameterDescription("invh", "Input image (VH)"); + MandatoryOff("invh"); + + AddParameter(ParameterType_ComplexInputImage, "invv", "Input Image"); + SetParameterDescription("invv", "Input image (VV)"); + + AddParameter(ParameterType_ComplexOutputImage, "out", "Output Image"); + SetParameterDescription("out", "Output image"); + + AddParameter(ParameterType_Choice, "decomp", "Decompositions"); + AddChoice("decomp.haa","H-alpha-A decomposition"); + SetParameterDescription("decomp.haa","H-alpha-A decomposition"); + + AddRAMParameter(); + + // Default values + SetDefaultParameterInt("decomp", 0); // H-alpha-A + + // Doc example parameter settings + SetDocExampleParameterValue("inhh", "HH.tif"); + SetDocExampleParameterValue("invh", "VH.tif"); + SetDocExampleParameterValue("invv", "VV.tif"); + SetDocExampleParameterValue("decomp", "haa"); + SetDocExampleParameterValue("out", "HaA.tif"); + } + + void DoUpdateParameters() + { + // Nothing to do here : all parameters are independent + } + + void DoExecute() + { + + bool inhv = HasUserValue("inhv"); + bool invh = HasUserValue("invh"); + + if ( (!inhv) && (!invh) ) + otbAppLogFATAL( << "Parameter inhv or invh not set. Please provide a HV or a VH complex image."); + + switch (GetParameterInt("decomp")) + { + case 0: // H-alpha-A + + m_SRFilter = SRFilterType::New(); + m_HAFilter = HAFilterType::New(); + + if (inhv) + m_SRFilter->SetInputHV_VH(GetParameterComplexFloatImage("inhv")); + else if (invh) + m_SRFilter->SetInputHV_VH(GetParameterComplexFloatImage("invh")); + + m_SRFilter->SetInputHH(GetParameterComplexFloatImage("inhh")); + m_SRFilter->SetInputVV(GetParameterComplexFloatImage("invv")); + + m_HAFilter->SetInput(m_SRFilter->GetOutput()); + + SetParameterOutputImage("out", m_HAFilter->GetOutput() ); + + break; + } + + } + + //MCPSFilterType::Pointer m_MCPSFilter; + SRFilterType::Pointer m_SRFilter; + HAFilterType::Pointer m_HAFilter; + + +}; + +} //end namespace Wrapper +} //end namespace otb + +OTB_APPLICATION_EXPORT(otb::Wrapper::SARDecompositions) diff --git a/Modules/Applications/AppSARDecompositions/otb-module.cmake b/Modules/Applications/AppSARDecompositions/otb-module.cmake new file mode 100644 index 0000000000..71303c803d --- /dev/null +++ b/Modules/Applications/AppSARDecompositions/otb-module.cmake @@ -0,0 +1,17 @@ +set(DOCUMENTATION "Basic filters application.") + +otb_module(OTBAppSARDecompositions + DEPENDS + OTBPolarimetry + OTBImageManipulation + OTBITK + OTBApplicationEngine + OTBImageBase + + TEST_DEPENDS + OTBTestKernel + OTBCommandLine + + DESCRIPTION + "${DOCUMENTATION}" +) diff --git a/Modules/Applications/AppSARDecompositions/test/CMakeLists.txt b/Modules/Applications/AppSARDecompositions/test/CMakeLists.txt new file mode 100644 index 0000000000..f9936bdd68 --- /dev/null +++ b/Modules/Applications/AppSARDecompositions/test/CMakeLists.txt @@ -0,0 +1,16 @@ +otb_module_test() +#----------- SARDecompositions TESTS ---------------- + +otb_test_application(NAME apTvSARDecompositions + APP SARDecompositions + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -decomp haa + -out ${TEMP}/apTvReciprocalHAlpha.tif + + VALID --compare-image ${EPSILON_7} + ${BASELINE}/apTvReciprocalHAlpha.tif + ${TEMP}/apTvReciprocalHAlpha.tif) + -- GitLab