diff --git a/Modules/Applications/AppSARDecompositions/CMakeLists.txt b/Modules/Applications/AppSARDecompositions/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..aa7832f8f44840a95e5ac6bfdbcddee53ade5a7c --- /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 0000000000000000000000000000000000000000..d311a3c7e5755cf7de35c79e054dd6c0164c5316 --- /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 0000000000000000000000000000000000000000..a159356f4a076b53fb2923877b050aab9ff11276 --- /dev/null +++ b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx @@ -0,0 +1,189 @@ +/*========================================================================= + + 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" +#include "otbPerBandVectorImageFilter.h" +#include "itkMeanImageFilter.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<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> FunctorType; + + + typedef SinclairReciprocalImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + FunctorType > SRFilterType; + + + typedef otb::ReciprocalHAlphaImageFilter<ComplexDoubleVectorImageType, DoubleVectorImageType> HAFilterType; + + + typedef itk::MeanImageFilter<ComplexDoubleImageType, ComplexDoubleImageType> MeanFilterType; + typedef otb::PerBandVectorImageFilter<ComplexDoubleVectorImageType, ComplexDoubleVectorImageType, MeanFilterType> PerBandMeanFilterType; + //FloatImageType + + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(SARDecompositions, otb::Application); + +private: + void DoInit() + { + SetName("SARDecompositions"); + SetDescription("From one-band complex images (each one related to an element of the Sinclair matrix), returns the selected decomposition."); + + // Documentation + SetDocName("SARDecompositions"); + SetDocLongDescription("From one-band complex images (HH, HV, VH, VV), returns the selected decomposition.\n \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 H-alpha-A decomposition consists in averaging 3x3 complex coherency matrices (incoherent analysis); the user must provide the size of the averaging window, thanks to the parameter inco.kernelsize.\n " + "The applications returns a float vector image, made up of three channels : H (entropy), Alpha, A (Anisotropy)." ); + + + + SetDocLimitations("None"); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso("SARPolarMatrixConvert, SARPolarSynth"); + + 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_OutputImage, "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"); + + AddParameter(ParameterType_Group,"inco","Incoherent decompositions"); + SetParameterDescription("inco","This group allows to set parameters related to the incoherent decompositions."); + + AddParameter(ParameterType_Int, "inco.kernelsize", "Kernel size for spatial incoherent averaging."); + SetParameterDescription("inco.kernelsize", "Minute (0-59)"); + SetMinimumParameterIntValue("inco.kernelsize", 1); + SetDefaultParameterInt("inco.kernelsize", 3); + MandatoryOff("inco.kernelsize"); + + 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(); + m_MeanFilter = PerBandMeanFilterType::New(); + + if (inhv) + m_SRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("inhv")); + else if (invh) + m_SRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("invh")); + + m_SRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_SRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + MeanFilterType::InputSizeType radius; + radius.Fill( GetParameterInt("inco.kernelsize") ); + m_MeanFilter->GetFilter()->SetRadius(radius); + + + m_MeanFilter->SetInput(m_SRFilter->GetOutput()); + m_HAFilter->SetInput(m_MeanFilter->GetOutput()); + SetParameterOutputImage("out", m_HAFilter->GetOutput() ); + + break; + } + + } + + //MCPSFilterType::Pointer m_MCPSFilter; + SRFilterType::Pointer m_SRFilter; + HAFilterType::Pointer m_HAFilter; + PerBandMeanFilterType::Pointer m_MeanFilter; + +}; + +} //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 0000000000000000000000000000000000000000..71303c803d5d707c9918ec8b578e89a204cc53b6 --- /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 0000000000000000000000000000000000000000..b99fa48fe8d6b2fea3afa6ab5a63b21228496094 --- /dev/null +++ b/Modules/Applications/AppSARDecompositions/test/CMakeLists.txt @@ -0,0 +1,14 @@ +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 + + ) + diff --git a/Modules/Applications/AppSARPolarMatrixConvert/CMakeLists.txt b/Modules/Applications/AppSARPolarMatrixConvert/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b20d3ebc6c81733b0ce1f5738dca23a6ff522139 --- /dev/null +++ b/Modules/Applications/AppSARPolarMatrixConvert/CMakeLists.txt @@ -0,0 +1,2 @@ +project(OTBAppSARPolarMatrixConvert) +otb_module_impl() diff --git a/Modules/Applications/AppSARPolarMatrixConvert/app/CMakeLists.txt b/Modules/Applications/AppSARPolarMatrixConvert/app/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..81426caca5d49ecef97df614ebc0214cd79bd008 --- /dev/null +++ b/Modules/Applications/AppSARPolarMatrixConvert/app/CMakeLists.txt @@ -0,0 +1,12 @@ +set(OTBAppFiltering_LINK_LIBS + ${OTBPolarimetry_LIBRARIES} + ${OTBImageManipulation_LIBRARIES} + ${OTBApplicationEngine_LIBRARIES} + ${OTBImageBase_LIBRARIES} +) + +otb_create_application( + NAME SARPolarMatrixConvert + SOURCES otbSARPolarMatrixConvert.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + diff --git a/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx b/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c670aabb0e2c2273daf5749368cd419142079b81 --- /dev/null +++ b/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx @@ -0,0 +1,709 @@ +/*========================================================================= + + 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" + + + + + +//monostatic case +#include "otbSinclairReciprocalImageFilter.h" +#include "otbSinclairToReciprocalCoherencyMatrixFunctor.h" +#include "otbSinclairToReciprocalCovarianceMatrixFunctor.h" +#include "otbSinclairToReciprocalCircularCovarianceMatrixFunctor.h" + +#include "otbReciprocalCoherencyToReciprocalMuellerImageFilter.h" +#include "otbReciprocalCovarianceToCoherencyDegreeImageFilter.h" +#include "otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h" +#include "otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h" + + +//bistatic case +#include "otbSinclairImageFilter.h" +#include "otbSinclairToCoherencyMatrixFunctor.h" +#include "otbSinclairToCovarianceMatrixFunctor.h" +#include "otbSinclairToCircularCovarianceMatrixFunctor.h" +#include "otbSinclairToMuellerMatrixFunctor.h" + +#include "otbMuellerToReciprocalCovarianceImageFilter.h" +#include "otbMuellerToPolarisationDegreeAndPowerImageFilter.h" + + + + + + +namespace otb +{ +namespace Wrapper +{ + +class SARPolarMatrixConvert : public Application +{ +public: + /** Standard class typedefs. */ + typedef SARPolarMatrixConvert Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + + //Monostatic case + typedef otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> RCoherencyFunctorType; + + typedef otb::Functor::SinclairToReciprocalCovarianceMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> RCovarianceFunctorType; + + typedef otb::Functor::SinclairToReciprocalCircularCovarianceMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> RCircularCovarianceFunctorType; + + + typedef SinclairReciprocalImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + RCoherencyFunctorType > RCohSRFilterType; + + + typedef SinclairReciprocalImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + RCovarianceFunctorType > RCovSRFilterType; + + typedef SinclairReciprocalImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + RCircularCovarianceFunctorType > RCCSRFilterType; + + + typedef otb::ReciprocalCoherencyToReciprocalMuellerImageFilter<ComplexDoubleVectorImageType, DoubleVectorImageType> RCRMFilterType; + + typedef otb::ReciprocalCovarianceToCoherencyDegreeImageFilter<ComplexDoubleVectorImageType, ComplexDoubleVectorImageType> RCCDFilterType; + + typedef otb::ReciprocalCovarianceToReciprocalCoherencyImageFilter<ComplexDoubleVectorImageType, ComplexDoubleVectorImageType> RCRCFilterType; + + typedef otb::ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter<ComplexDoubleVectorImageType, ComplexDoubleVectorImageType> RLCRCCFilterType; + + + //Bistatic case + typedef otb::Functor::SinclairToCoherencyMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> CoherencyFunctorType; + + + typedef otb::Functor::SinclairToCovarianceMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> CovarianceFunctorType; + + + typedef otb::Functor::SinclairToCircularCovarianceMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> CircularCovarianceFunctorType; + + + typedef otb::Functor::SinclairToMuellerMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + DoubleVectorImageType::PixelType> MuellerFunctorType; + + + typedef SinclairImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + CoherencyFunctorType > CohSRFilterType; + + + typedef SinclairImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + CovarianceFunctorType > CovSRFilterType; + + typedef SinclairImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + CircularCovarianceFunctorType > CCSRFilterType; + + typedef SinclairImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + DoubleVectorImageType, + MuellerFunctorType > MSRFilterType; + + + typedef otb::MuellerToReciprocalCovarianceImageFilter<DoubleVectorImageType, ComplexDoubleVectorImageType> MRCFilterType; + + typedef otb::MuellerToPolarisationDegreeAndPowerImageFilter<DoubleVectorImageType, DoubleVectorImageType> MPDPFilterType; + + + + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(SARPolarMatrixConvert, otb::Application); + +private: + void DoInit() + { + SetName("SARPolarMatrixConvert"); + SetDescription("This applications allows converting classical polarimetric matrices to each other."); + + // Documentation + SetDocName("SARPolarMatrixConvert"); + SetDocLongDescription( + + "This application allows converting classical polarimetric matrices to each other.\n" + "For instance, it is possible to get the coherency matrix from the Sinclar one, or the Mueller matrix from the coherency one.\n" + "The filters used in this application never handle matrices, but images where each band is related to their elements.\n" + "As most of the time SAR polarimetry handles symetric/hermitian matrices, only the relevant elements are stored, so that the images representing them have a minimal number of bands.\n" + "For instance, the coherency matrix size is 3x3 in the monostatic case, and 4x4 in the bistatic case : it will thus be stored in a 6-band or a 10-band complex image (the diagonal and the upper elements of the matrix).\n" + "\n" + "The Sinclair matrix is a special case : it is always represented as 3 or 4 one-band complex images (for mono- or bistatic case).\n" + "The available conversions are listed below:\n" + + "\n--- Monostatic case ---\n" + + "1 msinclairtocoherency --> Sinclair matrix to coherency matrix (input : 3 x 1 complex channel (HH, HV or VH, VV) | output : 6 complex channels)\n" + "2 msinclairtocovariance --> Sinclair matrix to covariance matrix (input : 3 x 1 complex channel (HH, HV or VH, VV) | output : 6 complex channels)\n" + "3 msinclairtocircovariance --> Sinclair matrix to circular covariance matrix (input : 3 x 1 complex channel (HH, HV or VH, VV) | output : 6 complex channels)\n" + "4 mcoherencytomueller --> Coherency matrix to Mueller matrix (input : 6 complex channels | 16 real channels)\n" + "5 mcovariancetocoherencydegree --> Covariance matrix to coherency degree (input : 6 complex channels | 3 complex channels)\n" + "6 mcovariancetocoherency --> Covariance matrix to coherency matrix (input : 6 complex channels | 6 complex channels)\n" + "7 mlinearcovariancetocircularcovariance --> Covariance matrix to circular covariance matrix (input : 6 complex channels | output : 6 complex channels)\n" + + "\n--- Bistatic case ---\n" + + "8 bsinclairtocoherency --> Sinclair matrix to coherency matrix (input : 4 x 1 complex channel (HH, HV, VH, VV) | 10 complex channels)\n" + "9 bsinclairtocovariance --> Sinclair matrix to covariance matrix (input : 4 x 1 complex channel (HH, HV, VH, VV) | output : 10 complex channels)\n" + "10 bsinclairtocircovariance --> Sinclair matrix to circular covariance matrix (input : 4 x 1 complex channel (HH, HV, VH, VV) | output : 10 complex channels)\n" + + "\n--- Both cases ---\n" + + "11 sinclairtomueller --> Sinclair matrix to Mueller matrix (input : 4 x 1 complex channel (HH, HV, VH, VV) | output : 16 real channels)\n" + "12 muellertomcovariance --> Mueller matrix to covariance matrix (input : 16 real channels | output : 6 complex channels)\n" + "13 muellertopoldegandpower --> Mueller matrix to polarization degree and power (input : 16 real channels | output : 4 real channels)\n" + + ); + + SetDocLimitations("None"); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso("SARPolarSynth, SARDecompositions"); + + AddDocTag(Tags::SAR); + + AddParameter(ParameterType_ComplexInputImage, "inc", "Input : multi-band complex image"); + SetParameterDescription("inc", "Input : multi-band complex image"); + MandatoryOff("inc"); + + AddParameter(ParameterType_InputImage, "inf", "Input : multi-band real image"); + SetParameterDescription("inf", "Input : multi-band real image"); + MandatoryOff("inf"); + + + AddParameter(ParameterType_ComplexInputImage, "inhh", "Input : one-band complex image (HH)"); + SetParameterDescription("inhh", "Input : one-band complex image (HH)"); + MandatoryOff("inhh"); + + AddParameter(ParameterType_ComplexInputImage, "inhv", "Input : one-band complex image (HV)"); + SetParameterDescription("inhv", "Input : one-band complex image (HV)"); + MandatoryOff("inhv"); + + AddParameter(ParameterType_ComplexInputImage, "invh", "Input : one-band complex image (VH)"); + SetParameterDescription("invh", "Input : one-band complex image (VH)"); + MandatoryOff("invh"); + + AddParameter(ParameterType_ComplexInputImage, "invv", "Input : one-band complex image (VV)"); + SetParameterDescription("invv", "Input : one-band complex image (VV)"); + MandatoryOff("invv"); + + AddParameter(ParameterType_ComplexOutputImage, "outc", "Output Complex Image"); + SetParameterDescription("outc", "Output Complex image."); + MandatoryOff("outc"); + + AddParameter(ParameterType_OutputImage, "outf", "Output Real Image"); + SetParameterDescription("outf", "Output Real image."); + MandatoryOff("outf"); + + + + AddParameter(ParameterType_Choice, "conv", "Convertion"); + + //Monostatic case + + // #1 + // SinclairToReciprocalCoherency + AddChoice("conv.msinclairtocoherency","1 Monostatic : Sinclair matrix to coherency matrix (complex output)"); + SetParameterDescription("conv.msinclairtocoherency","1 Monostatic :Sinclair matrix to coherency matrix (complex output)"); + + // #2 + // SinclairToReciprocalCovariance + AddChoice("conv.msinclairtocovariance","2 Monostatic : Sinclair matrix to covariance matrix (complex output)"); + SetParameterDescription("conv.msinclairtocovariance","2 Monostatic : Sinclair matrix to covariance matrix (complex output)"); + + // #3 + // SinclairToReciprocalCircularCovariance + AddChoice("conv.msinclairtocircovariance","3 Monostatic : Sinclair matrix to circular covariance matrix (complex output)"); + SetParameterDescription("conv.msinclairtocircovariance","3 Monostatic : Sinclair matrix to circular covariance matrix (complex output)"); + + // #4 + // ReciprocalCoherencyToReciprocalMuellerImageFilter + AddChoice("conv.mcoherencytomueller","4 Monostatic : Coherency matrix to Mueller matrix"); + SetParameterDescription("conv.mcoherencytomueller","4 Monostatic : Coherency matrix to Mueller matrix"); + + // #5 + // ReciprocalCovarianceToCoherencyDegreeImageFilter + AddChoice("conv.mcovariancetocoherencydegree","5 Monostatic : Covariance matrix to coherency degree "); + SetParameterDescription("conv.mcovariancetocoherencydegree","5 Monostatic : Covariance matrix to coherency degree "); + + // #6 + // ReciprocalCovarianceToReciprocalCoherencyImageFilter + AddChoice("conv.mcovariancetocoherency","6 Monostatic : Covariance matrix to coherency matrix (complex output)"); + SetParameterDescription("conv.mcovariancetocoherency","6 Monostatic : Covariance matrix to coherency matrix (complex output)"); + + // #7 + // ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter + AddChoice("conv.mlinearcovariancetocircularcovariance","7 Monostatic : Covariance matrix to circular covariance matrix (complex output)"); + SetParameterDescription("conv.mlinearcovariancetocircularcovariance","7 Monostatic : Covariance matrix to circular covariance matrix (complex output)"); + + // #8 + // MuellerToReciprocalCovarianceImageFilter + AddChoice("conv.muellertomcovariance","8 Bi/mono : Mueller matrix to monostatic covariance matrix"); + SetParameterDescription("conv.muellertomcovariance","8 Bi/mono : Mueller matrix to monostatic covariance matrix"); + + //Bistatic case + + // #9 + // SinclairToCoherency + AddChoice("conv.bsinclairtocoherency","9 Bistatic : Sinclair matrix to coherency matrix (complex output)"); + SetParameterDescription("conv.bsinclairtocoherency","9 Bistatic : Sinclair matrix to coherency matrix (complex output)"); + + // #10 + // SinclairToCovariance + AddChoice("conv.bsinclairtocovariance","10 Bistatic : Sinclair matrix to covariance matrix (complex output)"); + SetParameterDescription("conv.bsinclairtocovariance","10 Bistatic : Sinclair matrix to covariance matrix (complex output)"); + + // #11 + // SinclairToCircularCovariance + AddChoice("conv.bsinclairtocircovariance","11 Bistatic : Sinclair matrix to circular covariance matrix (complex output)"); + SetParameterDescription("conv.bsinclairtocircovariance","11 Bistatic : Sinclair matrix to circular covariance matrix (complex output)"); + + //Both case + + // #12 + // SinclairToMueller + AddChoice("conv.sinclairtomueller","12 Bi/mono : Sinclair matrix to Mueller matrix"); + SetParameterDescription("conv.sinclairtomueller","12 Bi/mono : Sinclair matrix to Mueller matrix"); + + + // #13 + // MuellerToPolarisationDegreeAndPowerImageFilter + AddChoice("conv.muellertopoldegandpower","13 Bi/mono : Mueller matrix to polarisation degree and power"); + SetParameterDescription("conv.muellertopoldegandpower","13 Bi/mono : Mueller matrix to polarisation degree and power"); + + AddRAMParameter(); + + // Default values + SetDefaultParameterInt("conv", 0); // SinclairToReciprocalCoherency + + // Doc example parameter settings + SetDocExampleParameterValue("inhh", "HH.tif"); + SetDocExampleParameterValue("invh", "VH.tif"); + SetDocExampleParameterValue("invv", "VV.tif"); + SetDocExampleParameterValue("conv", "msinclairtocoherency"); + SetDocExampleParameterValue("outc", "mcoherency.tif"); + } + + void DoUpdateParameters() + { + + int convType = GetParameterInt("conv"); + + if ( (convType>=0) && (convType<=2)) //msinclairtocoherency msinclairtocovariance msinclairtocircovariance + { + GetParameterByKey("inc")->SetActive(false); + GetParameterByKey("inf")->SetActive(false); + GetParameterByKey("inhh")->SetActive(true); + GetParameterByKey("inhv")->SetActive(true); + GetParameterByKey("invh")->SetActive(true); + GetParameterByKey("invv")->SetActive(true); + GetParameterByKey("outc")->SetActive(true); + GetParameterByKey("outf")->SetActive(false); + } + else if ( (convType>=3) && (convType<=6)) // mcoherencytomueller mcovariancetocoherencydegree mcovariancetocoherency mlinearcovariancetocircularcovariance + { + GetParameterByKey("inc")->SetActive(true); + GetParameterByKey("inf")->SetActive(false); + GetParameterByKey("inhh")->SetActive(false); + GetParameterByKey("inhv")->SetActive(false); + GetParameterByKey("invh")->SetActive(false); + GetParameterByKey("invv")->SetActive(false); + + if (convType == 3) + { + GetParameterByKey("outc")->SetActive(false); + GetParameterByKey("outf")->SetActive(true); + } + else + { + GetParameterByKey("outc")->SetActive(true); + GetParameterByKey("outf")->SetActive(false); + } + } + else if ( convType==7) // muellertomcovariance + { + GetParameterByKey("inc")->SetActive(false); + GetParameterByKey("inf")->SetActive(true); + GetParameterByKey("inhh")->SetActive(false); + GetParameterByKey("inhv")->SetActive(false); + GetParameterByKey("invh")->SetActive(false); + GetParameterByKey("invv")->SetActive(false); + GetParameterByKey("outc")->SetActive(true); + GetParameterByKey("outf")->SetActive(false); + } + else if ( (convType>=8) && (convType<=11)) // bsinclairtocoherency bsinclairtocovariance bsinclairtocircovariance sinclairtomueller + { + GetParameterByKey("inc")->SetActive(false); + GetParameterByKey("inf")->SetActive(false); + GetParameterByKey("inhh")->SetActive(true); + GetParameterByKey("inhv")->SetActive(true); + GetParameterByKey("invh")->SetActive(true); + GetParameterByKey("invv")->SetActive(true); + + if (convType == 11) + { + GetParameterByKey("outc")->SetActive(false); + GetParameterByKey("outf")->SetActive(true); + } + else + { + GetParameterByKey("outc")->SetActive(true); + GetParameterByKey("outf")->SetActive(false); + } + + } + else if ( convType==12 ) // muellertopoldegandpower + { + GetParameterByKey("inc")->SetActive(false); + GetParameterByKey("inf")->SetActive(true); + GetParameterByKey("inhh")->SetActive(false); + GetParameterByKey("inhv")->SetActive(false); + GetParameterByKey("invh")->SetActive(false); + GetParameterByKey("invv")->SetActive(false); + GetParameterByKey("outc")->SetActive(false); + GetParameterByKey("outf")->SetActive(true); + } + + + + } + + void DoExecute() + { + + //**************************************** + //* Check inputs and outputs consistency * + //**************************************** + + bool inc = HasUserValue("inc"); + bool inf = HasUserValue("inf"); + bool inhh = HasUserValue("inhh"); + bool inhv = HasUserValue("inhv"); + bool invh = HasUserValue("invh"); + bool invv = HasUserValue("invv"); + bool outc = HasUserValue("outc"); + bool outf = HasUserValue("outf"); + + int convType = GetParameterInt("conv"); + + + if ( (!outc) && (!outf) ) + otbAppLogFATAL( << "No output image provided; please, set the parameter 'outc' or 'outf'."); + + + if ( (convType>=0) && (convType<=2)) //msinclairtocoherency msinclairtocovariance msinclairtocircovariance + { + if ( (!inhv) && (!invh) ) + otbAppLogFATAL( << "Parameter 'inhv' or 'invh' not set."); + if ( !inhh ) + otbAppLogFATAL( << "Parameter 'inhh' not set."); + if ( !invv ) + otbAppLogFATAL( << "Parameter 'invv' not set."); + + } + + else if ( (convType>=3) && (convType<=6)) // mcoherencytomueller mcovariancetocoherencydegree mcovariancetocoherency mlinearcovariancetocircularcovariance + { + if ( !inc ) + otbAppLogFATAL( << "Parameter 'inc' not set."); + } + else if ( (convType>=8) && (convType<=11)) // bsinclairtocoherency bsinclairtocovariance bsinclairtocircovariance sinclairtomueller + { + if ( (!inhh) || (!inhv) || (!invh) || (!invv) ) + otbAppLogFATAL( << "Please, ensure that HH, HV, VH and VV complex images have been provided (paramaters inhh, inhv, invh, invv)."); + } + else if ( (convType==7) || (convType==12) ) // muellertomcovariance muellertopoldegandpower + { + if ( !inf ) + otbAppLogFATAL( << "Parameter 'inf' not set."); + } + + + switch (GetParameterInt("conv")) + { + + //*************************************** + //* MONOSTATIC * + //*************************************** + + case 0: // SinclairToReciprocalCoherency + m_RCohSRFilter = RCohSRFilterType::New(); + + if (inhv) + m_RCohSRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("inhv")); + else if (invh) + m_RCohSRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("invh")); + + m_RCohSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_RCohSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterComplexOutputImage("outc", m_RCohSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels + + break; + + + case 1: // SinclairToReciprocalCovariance + + m_RCovSRFilter = RCovSRFilterType::New(); + + if (inhv) + m_RCovSRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("inhv")); + else if (invh) + m_RCovSRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("invh")); + + m_RCovSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_RCovSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterComplexOutputImage("outc", m_RCovSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels + + break; + + + + case 2: // SinclairToReciprocalCircularCovariance + + m_RCCSRFilter = RCCSRFilterType::New(); + + if (inhv) + m_RCCSRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("inhv")); + else if (invh) + m_RCCSRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("invh")); + + m_RCCSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_RCCSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterComplexOutputImage("outc", m_RCCSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels + + break; + + + case 3: // ReciprocalCoherencyToReciprocalMuellerImageFilter + + m_RCRMFilter = RCRMFilterType::New(); + m_RCRMFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); + + SetParameterOutputImage("outf", m_RCRMFilter->GetOutput() ); // input : 6 complex channels | 16 real channels + + break; + + + + case 4: // ReciprocalCovarianceToCoherencyDegreeImageFilter + + m_RCCDFilter = RCCDFilterType::New(); + m_RCCDFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); + + SetParameterComplexOutputImage("outc", m_RCCDFilter->GetOutput() ); // input : 6 complex channels | 3 complex channels + + break; + + + case 5: // ReciprocalCovarianceToReciprocalCoherencyImageFilter + + m_RCRCFilter = RCRCFilterType::New(); + m_RCRCFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); + + SetParameterComplexOutputImage("outc", m_RCRCFilter->GetOutput() ); // input : 6 complex channels | 6 complex channels + + break; + + + + case 6: // ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter + + m_RLCRCCFilter = RLCRCCFilterType::New(); + m_RLCRCCFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); + + SetParameterComplexOutputImage("outc", m_RLCRCCFilter->GetOutput() ); // input : 6 complex channels | output : 6 complex channels + + break; + + + case 7: // MuellerToReciprocalCovarianceImageFilter + + m_MRCFilter = MRCFilterType::New(); + + m_MRCFilter->SetInput(GetParameterDoubleVectorImage("inf")); + + SetParameterComplexOutputImage("outc", m_MRCFilter->GetOutput() ); // input : 16 real channels | output : 6 complex channels + + break; + + + //*************************************** + //* BISTATIC * + //*************************************** + + case 8: // SinclairToCoherency + + m_CohSRFilter = CohSRFilterType::New(); + + m_CohSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_CohSRFilter->SetInputHV(GetParameterComplexDoubleImage("inhv")); + m_CohSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh")); + m_CohSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterComplexOutputImage("outc", m_CohSRFilter->GetOutput() ); // input : 4 x 1 complex channel | 10 complex channels + + break; + + + + case 9: // SinclairToCovariance + + m_CovSRFilter = CovSRFilterType::New(); + + m_CovSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_CovSRFilter->SetInputHV(GetParameterComplexDoubleImage("inhv")); + m_CovSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh")); + m_CovSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterComplexOutputImage("outc", m_CovSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 10 complex channels + + break; + + + case 10: // SinclairToCircularCovariance + + m_CCSRFilter = CCSRFilterType::New(); + + m_CCSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_CCSRFilter->SetInputHV(GetParameterComplexDoubleImage("inhv")); + m_CCSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh")); + m_CCSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterComplexOutputImage("outc", m_CCSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 10 complex channels + + break; + + + //*************************************** + //* BOTH CASES * + //*************************************** + + + case 11: // SinclairToMueller + std::cout << "taloula 1" << std::endl; + m_MSRFilter = MSRFilterType::New(); + + m_MSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_MSRFilter->SetInputHV(GetParameterComplexDoubleImage("inhv")); + m_MSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh")); + m_MSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterOutputImage("outf", m_MSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 16 real channels + + break; + + + case 12: // MuellerToPolarisationDegreeAndPowerImageFilter + m_MPDPFilter = MPDPFilterType::New(); + + m_MPDPFilter->SetInput(GetParameterDoubleVectorImage("inf")); + + SetParameterOutputImage("outf", m_MPDPFilter->GetOutput() ); // input : 16 real channels | output : 4 real channels + + break; + + } + + + + } + + //Monostatic + RCohSRFilterType::Pointer m_RCohSRFilter; + RCovSRFilterType::Pointer m_RCovSRFilter; + RCCSRFilterType::Pointer m_RCCSRFilter; + RCRMFilterType::Pointer m_RCRMFilter; + RCCDFilterType::Pointer m_RCCDFilter; + RCRCFilterType::Pointer m_RCRCFilter; + RLCRCCFilterType::Pointer m_RLCRCCFilter; + + //Bistatic + CohSRFilterType::Pointer m_CohSRFilter; + CovSRFilterType::Pointer m_CovSRFilter; + CCSRFilterType::Pointer m_CCSRFilter; + MSRFilterType::Pointer m_MSRFilter; + + //Both cases + MRCFilterType::Pointer m_MRCFilter; + MPDPFilterType::Pointer m_MPDPFilter; + + + + + +}; + +} //end namespace Wrapper +} //end namespace otb + +OTB_APPLICATION_EXPORT(otb::Wrapper::SARPolarMatrixConvert) diff --git a/Modules/Applications/AppSARPolarMatrixConvert/otb-module.cmake b/Modules/Applications/AppSARPolarMatrixConvert/otb-module.cmake new file mode 100644 index 0000000000000000000000000000000000000000..759161f8b45b6a0e22916b9838c78f29c36b75ba --- /dev/null +++ b/Modules/Applications/AppSARPolarMatrixConvert/otb-module.cmake @@ -0,0 +1,17 @@ +set(DOCUMENTATION "Basic filters application.") + +otb_module(OTBAppSARPolarMatrixConvert + DEPENDS + OTBPolarimetry + OTBImageManipulation + OTBITK + OTBApplicationEngine + OTBImageBase + + TEST_DEPENDS + OTBTestKernel + OTBCommandLine + + DESCRIPTION + "${DOCUMENTATION}" +) diff --git a/Modules/Applications/AppSARPolarMatrixConvert/test/CMakeLists.txt b/Modules/Applications/AppSARPolarMatrixConvert/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a7c518f53999ce2c19ca2c74db8ce4eea95d486b --- /dev/null +++ b/Modules/Applications/AppSARPolarMatrixConvert/test/CMakeLists.txt @@ -0,0 +1,157 @@ +otb_module_test() +#----------- SARPolarMatrixConvert TESTS ---------------- + +#1 +otb_test_application(NAME apTvSARPolarMatrixConvertRecCoherency + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv msinclairtocoherency + -outc ${TEMP}/apTvSARPolarMatrixConvertRecCoherency.tif + + ) + +#2 +otb_test_application(NAME apTvSARPolarMatrixConvertRecCovariance + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv msinclairtocovariance + -outc ${TEMP}/apTvSARPolarMatrixConvertRecCovariance.tif + + ) + +#3 +otb_test_application(NAME apTvSARPolarMatrixConvertRecCirCovariance + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv msinclairtocircovariance + -outc ${TEMP}/apTvSARPolarMatrixConvertRecCirCovariance.tif + + ) + +#4 +otb_test_application(NAME apTvSARPolarMatrixConvertRecCohToMueller + APP SARPolarMatrixConvert + OPTIONS + -inc ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif + -conv mcoherencytomueller + -outf ${TEMP}/apTvSARPolarMatrixConvertRecCohToMueller.tif + + ) + + +#5 +otb_test_application(NAME apTvSARPolarMatrixConvertRecCovToCohDeg + APP SARPolarMatrixConvert + OPTIONS + -inc ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif + -conv mcovariancetocoherencydegree + -outc ${TEMP}/apTvSARPolarMatrixConvertRecCovToCohDeg.tif + + ) + + +#6 +otb_test_application(NAME apTvSARPolarMatrixConvertRecCovToRecCoh + APP SARPolarMatrixConvert + OPTIONS + -inc ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif + -conv mcovariancetocoherency + -outc ${TEMP}/apTvSARPolarMatrixConvertRecCovToRecCoh.tif + + ) + +#7 +otb_test_application(NAME apTvSARPolarMatrixConvertRecLinCovToRecCirCov + APP SARPolarMatrixConvert + OPTIONS + -inc ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif + -conv mlinearcovariancetocircularcovariance + -outc ${TEMP}/apTvSARPolarMatrixConvertRecCovToRecCoh.tif + + ) + + +#8 +otb_test_application(NAME apTvSARPolarMatrixConvertMuellerToRecCov + APP SARPolarMatrixConvert + OPTIONS + -inf ${BASELINE}/saTvSinclairImageFilter_SinclairToMueller.tif + -conv muellertomcovariance + -outc ${TEMP}/apTvSARPolarMatrixConvertMuellerToRecCov.tif + + ) + + +#9 +otb_test_application(NAME apTvSARPolarMatrixConvertBiSincToCoherency + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invh ${INPUTDATA}/RSAT_imageryC_VH.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv bsinclairtocoherency + -outc ${TEMP}/apTvSARPolarMatrixConvertBiSincToCoherency.tif + + ) + + +#10 +otb_test_application(NAME apTvSARPolarMatrixConvertBiSincToCovariance + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invh ${INPUTDATA}/RSAT_imageryC_VH.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv bsinclairtocovariance + -outc ${TEMP}/apTvSARPolarMatrixConvertBiSincToCovariance.tif + + ) + +#11 +otb_test_application(NAME apTvSARPolarMatrixConvertBiSincToCirCovariance + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invh ${INPUTDATA}/RSAT_imageryC_VH.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv bsinclairtocircovariance + -outc ${TEMP}/apTvSARPolarMatrixConvertBiSincToCirCovariance.tif + + ) + + +#12 +otb_test_application(NAME apTvSARPolarMatrixConvertSincToMueller + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invh ${INPUTDATA}/RSAT_imageryC_HV.tif #monostatic + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv sinclairtomueller + -outf ${TEMP}/apTvSARPolarMatrixConvertSincToMueller.tif + + ) + + +#13 +otb_test_application(NAME apTvSARPolarMatrixConvertMuellerToPolDeGPow + APP SARPolarMatrixConvert + OPTIONS + -inf ${BASELINE}/saTvSinclairImageFilter_SinclairToMueller.tif + -conv muellertopoldegandpower + -outf ${TEMP}/apTvSARPolarMatrixConvertMuellerToPolDeGPow.tif + + ) diff --git a/Modules/Applications/AppSARPolarSynth/CMakeLists.txt b/Modules/Applications/AppSARPolarSynth/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f6c2324b5b9053c0a5f0f3818560e586c30ba62c --- /dev/null +++ b/Modules/Applications/AppSARPolarSynth/CMakeLists.txt @@ -0,0 +1,2 @@ +project(OTBAppSARPolarSynth) +otb_module_impl() diff --git a/Modules/Applications/AppSARPolarSynth/app/CMakeLists.txt b/Modules/Applications/AppSARPolarSynth/app/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ea87ee870ad0182cd2338fc42e915c81279f6495 --- /dev/null +++ b/Modules/Applications/AppSARPolarSynth/app/CMakeLists.txt @@ -0,0 +1,12 @@ +set(OTBAppFiltering_LINK_LIBS + ${OTBPolarimetry_LIBRARIES} + ${OTBImageManipulation_LIBRARIES} + ${OTBApplicationEngine_LIBRARIES} + ${OTBImageBase_LIBRARIES} +) + +otb_create_application( + NAME SARPolarSynth + SOURCES otbSARPolarSynth.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + diff --git a/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx b/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4963306b34a459f87283d7bf17cc98b0ad4060d9 --- /dev/null +++ b/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx @@ -0,0 +1,185 @@ +/*========================================================================= + + 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 "otbMultiChannelsPolarimetricSynthesisFilter.h" + +namespace otb +{ +namespace Wrapper +{ + +class SARPolarSynth : public Application +{ +public: + /** Standard class typedefs. */ + typedef SARPolarSynth Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef MultiChannelsPolarimetricSynthesisFilter<ComplexDoubleVectorImageType, FloatImageType> MCPSFilterType; + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(SARPolarSynth, otb::Application); + +private: + void DoInit() + { + SetName("SARPolarSynth"); + SetDescription("Gives, for each pixel, the power that would have been received by a SAR system with a basis different from the classical (H,V) one (polarimetric synthetis)."); + + // Documentation + SetDocName("SARPolarSynth"); + SetDocLongDescription("This application gives, for each pixel, the power that would have been received by a SAR system with a basis different from the classical (H,V) one (polarimetric synthetis).\n" + "The new basis A and B are indicated through two Jones vectors, defined by the user thanks to orientation (psi) and ellipticity (khi) parameters.\n" + "These parameters are namely psii, khii, psir and khir. The suffixes (i) and (r) refer to the transmiting antenna and the receiving antenna respectively.\n" + "Orientations and ellipticities are given in degrees, and are between -90°/90° and -45°/45° respectively.\n " + "\n" + "Four polarization architectures can be processed : \n" + "1) HH_HV_VH_VV : full polarization, general bistatic case.\n" + "2) HH_HV_VV or HH_VH_VV : full polarization, monostatic case (transmitter and receiver are co-located).\n" + "3) HH_HV : dual polarization.\n" + "4) VH_VV : dual polarization.\n" + "The application takes a complex vector image as input, where each band correspond to a particular emission/reception polarization scheme.\n" + "User must comply with the band order given above, since the bands are used to build the Sinclair matrix.\n" + "\n" + "In order to determine the architecture, the application first relies on the number of bands of the input image.\n" + "1) Architecture HH_HV_VH_VV is the only one with four bands, there is no possible confusion.\n" + "2) Concerning HH_HV_VV and HH_VH_VV architectures, both correspond to a three channels image. But they are processed in the same way, as the Sinclair matrix is symetric in the monostatic case.\n" + "3) Finally, the two last architectures (dual polarizations), can't be distinguished only by the number of bands of the input image.\n" + " User must then use the parameters emissionh and emissionv to indicate the architecture of the system : emissionh=1 and emissionv=0 --> HH_HV, emissionh=0 and emissionv=1 --> VH_VV.\n" + "Note : if the architecture is HH_HV, khii and psii are automatically set to 0°/0°; if the architecture is VH_VV, khii and psii are automatically set to 0°/90°.\n" + "\n" + "It is also possible to force the calculation to co-polar or cross-polar modes.\n" + "In the co-polar case, values for psir and khir will be ignored and forced to psii and khii; same as the cross-polar mode, where khir and psir will be forced to psii+90° and -khii.\n" + "\n" + "Finally, the result of the polarimetric synthetis is expressed in the power domain, through a one-band scalar image.\n" + "Note: this application doesn't take into account the terms which do not depend on the polarization of the antennas. \n" + "The parameter gain can be used for this purpose.\n" + "\n" + "The final formula is thus : P = | B^T . [S] . A |², where A ans B are two Jones vectors and S is a Sinclair matrix."); + + SetDocLimitations("None"); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso("SARDecompositions, SARPolarMatrixConvert"); + + AddDocTag(Tags::SAR); + + AddParameter(ParameterType_ComplexInputImage, "in", "Input Image"); + SetParameterDescription("in", "Input image."); + AddParameter(ParameterType_OutputImage, "out", "Output Image"); + SetParameterDescription("out", "Output image."); + + AddParameter(ParameterType_Float,"psii","psii"); + SetParameterDescription("psii","Orientation (transmitting antenna)"); + SetMinimumParameterFloatValue("psii",-90.0); + SetMaximumParameterFloatValue("psii",90.0); + + AddParameter(ParameterType_Float,"khii","khii"); + SetParameterDescription("khii","Ellipticity (transmitting antenna)"); + SetMinimumParameterFloatValue("khii",-45.0); + SetMaximumParameterFloatValue("khii",45.0); + + AddParameter(ParameterType_Float,"psir","psir"); + SetParameterDescription("psir","Orientation (receiving antenna)"); + SetMinimumParameterFloatValue("psir",-90.0); + SetMaximumParameterFloatValue("psir",90.0); + + AddParameter(ParameterType_Float,"khir","khir"); + SetParameterDescription("khir","Ellipticity (receiving antenna)"); + SetMinimumParameterFloatValue("khir",-45.0); + SetMaximumParameterFloatValue("khir",45.0); + + AddParameter(ParameterType_Int,"emissionh","Emission H"); + SetParameterDescription("emissionh","This parameter is useful in determining the polarization architecture (dual polarization case)."); + SetMinimumParameterIntValue("emissionh",0); + SetMaximumParameterIntValue("emissionh",1); + MandatoryOff("emissionh"); + + AddParameter(ParameterType_Int,"emissionv","Emission V"); + SetParameterDescription("emissionv","This parameter is useful in determining the polarization architecture (dual polarization case)."); + SetMinimumParameterIntValue("emissionv",0); + SetMaximumParameterIntValue("emissionv",1); + MandatoryOff("emissionv"); + + AddParameter(ParameterType_Choice, "mode", "Forced mode"); + AddChoice("mode.none","None"); + SetParameterDescription("mode.none","None"); + AddChoice("mode.co","Copolarization"); + SetParameterDescription("mode.none","Copolarization"); + AddChoice("mode.cross","Crosspolarization"); + SetParameterDescription("mode.cross","Crosspolarization"); + + + AddRAMParameter(); + + // Default values + SetDefaultParameterFloat("psii", 0.); + SetDefaultParameterFloat("khii", 0.); + SetDefaultParameterFloat("psir", 0.); + SetDefaultParameterFloat("khir", 0.); + SetDefaultParameterInt("emissionh", 0); + SetDefaultParameterInt("emissionv", 0); + SetDefaultParameterFloat("mode", 0); + + // Doc example parameter settings + SetDocExampleParameterValue("in", "sar.tif"); + SetDocExampleParameterValue("psii","15."); + SetDocExampleParameterValue("khii", "5."); + SetDocExampleParameterValue("psir","-25."); + SetDocExampleParameterValue("khir", "10."); + SetDocExampleParameterValue("out", "newbasis.tif"); + } + + void DoUpdateParameters() + { + // Nothing to do here : all parameters are independent + } + + void DoExecute() + { + + m_MCPSFilter = MCPSFilterType::New(); + m_MCPSFilter->SetPsiI(GetParameterFloat("psii")); + m_MCPSFilter->SetKhiI(GetParameterFloat("khii")); + m_MCPSFilter->SetPsiR(GetParameterFloat("psir")); + m_MCPSFilter->SetKhiR(GetParameterFloat("khir")); + m_MCPSFilter->SetEmissionH(GetParameterInt("emissionh")); + m_MCPSFilter->SetEmissionV(GetParameterInt("emissionv")); + m_MCPSFilter->SetMode(GetParameterInt("mode")); + + ComplexDoubleVectorImageType* inVImage = GetParameterComplexDoubleVectorImage("in"); + inVImage->UpdateOutputInformation(); + int nbBands = inVImage->GetNumberOfComponentsPerPixel(); + otbAppLogINFO( << "nbBands = " << nbBands); + + m_MCPSFilter->SetInput(inVImage); + + SetParameterOutputImage("out", m_MCPSFilter->GetOutput()); + } + //std::vector<itk::ProcessObject::Pointer> m_Ref; + MCPSFilterType::Pointer m_MCPSFilter; +}; + +} //end namespace Wrapper +} //end namespace otb + +OTB_APPLICATION_EXPORT(otb::Wrapper::SARPolarSynth) diff --git a/Modules/Applications/AppSARPolarSynth/otb-module.cmake b/Modules/Applications/AppSARPolarSynth/otb-module.cmake new file mode 100644 index 0000000000000000000000000000000000000000..16d19e0a98d9dde0b29258a43063e6d2696e563e --- /dev/null +++ b/Modules/Applications/AppSARPolarSynth/otb-module.cmake @@ -0,0 +1,17 @@ +set(DOCUMENTATION "Basic filters application.") + +otb_module(OTBAppSARPolarSynth + DEPENDS + OTBPolarimetry + OTBImageManipulation + OTBITK + OTBApplicationEngine + OTBImageBase + + TEST_DEPENDS + OTBTestKernel + OTBCommandLine + + DESCRIPTION + "${DOCUMENTATION}" +) diff --git a/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt b/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..1adeb2028634a4d0cb63774dd91a7d07cfb44110 --- /dev/null +++ b/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt @@ -0,0 +1,13 @@ +otb_module_test() +#----------- PolarSynth TESTS ---------------- + +otb_test_application(NAME apTvSARPolarSynth + APP SARPolarSynth + OPTIONS -in ${INPUTDATA}/RSAT2_AltonaExtract_1000_1000_100_100.hdr + -out ${TEMP}/resApMultiPolarimetricSynthesis1.tif + -psii 10.0 + -khii 0.0 + -psir 0.0 + -khir 0.0 + ) + diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalHAlphaImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalHAlphaImageFilter.h index 06a7a949d5ae59d1090521a4a914c50627362a5c..0967d1747196fa2632a926d3eedfe26692a92927 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalHAlphaImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalHAlphaImageFilter.h @@ -137,6 +137,7 @@ public: plog[k]=0.0; else plog[k]=-p[k]*log(p[k])/log(3.0); + } entropy = 0.0; diff --git a/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCoherencyMatrixFunctor.h b/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCoherencyMatrixFunctor.h index e1d6743c6f9a4f5e960f1897c457f371f50a305e..7fb9ddc327a721737781b24eb065de7bc07dcf63 100644 --- a/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCoherencyMatrixFunctor.h +++ b/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCoherencyMatrixFunctor.h @@ -18,8 +18,10 @@ #ifndef __otbSinclairToReciprocalCoherencyMatrixFunctor_h #define __otbSinclairToReciprocalCoherencyMatrixFunctor_h -#include "vcl_complex.h" #include "itkMacro.h" +#include "vcl_complex.h" +#include "otbMath.h" +#include "vnl/vnl_matrix.h" namespace otb { @@ -62,6 +64,7 @@ class SinclairToReciprocalCoherencyMatrixFunctor public: /** Some typedefs. */ typedef typename std::complex <double> ComplexType; + typedef vnl_matrix<ComplexType> VNLMatrixType; typedef typename TOutput::ValueType OutputValueType; itkStaticConstMacro(NumberOfComponentsPerPixel, unsigned int, 6); @@ -75,19 +78,23 @@ public: const ComplexType S_hh = static_cast<ComplexType>(Shh); const ComplexType S_hv = static_cast<ComplexType>(Shv); const ComplexType S_vv = static_cast<ComplexType>(Svv); - - const ComplexType HHPlusVV = S_hh + S_vv; - const ComplexType HHMinusVV = S_hh - S_vv; - const ComplexType twoHV = ComplexType( 2.0 ) * S_hv; - - result[0] = static_cast<OutputValueType>( std::norm(HHPlusVV) ); - result[1] = static_cast<OutputValueType>( HHPlusVV * vcl_conj(HHMinusVV) ); - result[2] = static_cast<OutputValueType>( HHPlusVV * vcl_conj(twoHV) ); - result[3] = static_cast<OutputValueType>( std::norm(HHMinusVV) ); - result[4] = static_cast<OutputValueType>( HHMinusVV *vcl_conj(twoHV) ); - result[5] = static_cast<OutputValueType>( std::norm(twoHV) ); - - result /= 2.0; + + + VNLMatrixType f3p(3, 1, 0.); + f3p[0][0]= (S_hh + S_vv) / ComplexType( std::sqrt(2.0) , 0.0); + f3p[1][0]= (S_hh - S_vv) / ComplexType( std::sqrt(2.0) , 0.0); + f3p[2][0]= ComplexType( std::sqrt(2.0) , 0.0) * S_hv; + + + VNLMatrixType res = f3p*f3p.conjugate_transpose(); + + result[0] = static_cast<OutputValueType>( res[0][0] ); + result[1] = static_cast<OutputValueType>( res[0][1] ); + result[2] = static_cast<OutputValueType>( res[0][2] ); + result[3] = static_cast<OutputValueType>( res[1][1] ); + result[4] = static_cast<OutputValueType>( res[1][2] ); + result[5] = static_cast<OutputValueType>( res[2][2] ); + return (result); } diff --git a/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCovarianceMatrixFunctor.h b/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCovarianceMatrixFunctor.h index 8ad714abef0d6c103c84e882489cf7d3fa634226..632033676ae0d5b2895f723074d9459a736969ba 100644 --- a/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCovarianceMatrixFunctor.h +++ b/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCovarianceMatrixFunctor.h @@ -19,6 +19,8 @@ #define __otbSinclairToReciprocalCovarianceMatrixFunctor_h #include "vcl_complex.h" +#include "otbMath.h" +#include "vnl/vnl_matrix.h" namespace otb { @@ -61,6 +63,7 @@ class SinclairToReciprocalCovarianceMatrixFunctor public: /** Some typedefs. */ typedef typename std::complex <double> ComplexType; + typedef vnl_matrix<ComplexType> VNLMatrixType; typedef typename TOutput::ValueType OutputValueType; inline TOutput operator ()(const TInput1& Shh, const TInput2& Shv, const TInput3& Svv) { @@ -72,12 +75,19 @@ public: const ComplexType S_hv = static_cast<ComplexType>(Shv); const ComplexType S_vv = static_cast<ComplexType>(Svv); - result[0] = static_cast<OutputValueType>( std::norm( S_hh ) ); - result[1] = static_cast<OutputValueType>( vcl_sqrt(2.0)*S_hh*vcl_conj(S_hv) ); - result[2] = static_cast<OutputValueType>( S_hh*vcl_conj(S_vv) ); - result[3] = static_cast<OutputValueType>( 2.0*std::norm( S_hv ) ); - result[4] = static_cast<OutputValueType>( vcl_sqrt(2.0)*S_hv*vcl_conj(S_vv) ); - result[5] = static_cast<OutputValueType>( std::norm( S_vv ) ); + VNLMatrixType f3l(3, 1, 0.); + f3l[0][0]=S_hh; + f3l[1][0]=ComplexType(std::sqrt(2.0),0.0)*S_hv; + f3l[2][0]=S_vv; + + VNLMatrixType res = f3l*f3l.conjugate_transpose(); + + result[0] = static_cast<OutputValueType>( res[0][0] ); + result[1] = static_cast<OutputValueType>( res[0][1] ); + result[2] = static_cast<OutputValueType>( res[0][2] ); + result[3] = static_cast<OutputValueType>( res[1][1] ); + result[4] = static_cast<OutputValueType>( res[1][2] ); + result[5] = static_cast<OutputValueType>( res[2][2] ); return (result); }