diff --git a/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx b/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx index 74339a90eb4208172b341e8e329be3f2c8efca3b..5b343a486fb2bc0c5c218ffb163a571aa42b1a04 100644 --- a/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx +++ b/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx @@ -21,24 +21,9 @@ #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 +// Polarimetric filters #include "otbSinclairImageFilters.h" -#include "otbMuellerToReciprocalCovarianceImageFilter.h" -#include "otbMuellerToPolarisationDegreeAndPowerImageFilter.h" - - namespace otb { namespace Wrapper @@ -455,7 +440,7 @@ private: case 3: // ReciprocalCoherencyToReciprocalMuellerImageFilter m_RCRMFilter = RCRMFilterType::New(); - m_RCRMFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); + m_RCRMFilter->SetVariadicInput<0>(GetParameterComplexDoubleVectorImage("inc")); SetParameterOutputImage("outf", m_RCRMFilter->GetOutput()); // input : 6 complex channels | 16 real channels @@ -465,7 +450,7 @@ private: case 4: // ReciprocalCovarianceToCoherencyDegreeImageFilter m_RCCDFilter = RCCDFilterType::New(); - m_RCCDFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); + m_RCCDFilter->SetInput1(GetParameterComplexDoubleVectorImage("inc")); SetParameterOutputImage("outc", m_RCCDFilter->GetOutput()); // input : 6 complex channels | 3 complex channels @@ -475,7 +460,7 @@ private: case 5: // ReciprocalCovarianceToReciprocalCoherencyImageFilter m_RCRCFilter = RCRCFilterType::New(); - m_RCRCFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); + m_RCRCFilter->SetInput1(GetParameterComplexDoubleVectorImage("inc")); SetParameterOutputImage("outc", m_RCRCFilter->GetOutput()); // input : 6 complex channels | 6 complex channels @@ -485,7 +470,7 @@ private: case 6: // ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter m_RLCRCCFilter = RLCRCCFilterType::New(); - m_RLCRCCFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); + m_RLCRCCFilter->SetInput1(GetParameterComplexDoubleVectorImage("inc")); SetParameterOutputImage("outc", m_RLCRCCFilter->GetOutput()); // input : 6 complex channels | output : 6 complex channels @@ -496,7 +481,7 @@ private: m_MRCFilter = MRCFilterType::New(); - m_MRCFilter->SetInput(GetParameterDoubleVectorImage("inf")); + m_MRCFilter->SetInput1(GetParameterDoubleVectorImage("inf")); SetParameterOutputImage("outc", m_MRCFilter->GetOutput()); // input : 16 real channels | output : 6 complex channels @@ -567,7 +552,7 @@ private: case 12: // MuellerToPolarisationDegreeAndPowerImageFilter m_MPDPFilter = MPDPFilterType::New(); - m_MPDPFilter->SetInput(GetParameterDoubleVectorImage("inf")); + m_MPDPFilter->SetInput1(GetParameterDoubleVectorImage("inf")); SetParameterOutputImage("outf", m_MPDPFilter->GetOutput()); // input : 16 real channels | output : 4 real channels diff --git a/Modules/Filtering/Polarimetry/include/otbMuellerToPolarisationDegreeAndPowerImageFilter.h b/Modules/Filtering/Polarimetry/include/otbMuellerToPolarisationDegreeAndPowerFunctor.h similarity index 100% rename from Modules/Filtering/Polarimetry/include/otbMuellerToPolarisationDegreeAndPowerImageFilter.h rename to Modules/Filtering/Polarimetry/include/otbMuellerToPolarisationDegreeAndPowerFunctor.h diff --git a/Modules/Filtering/Polarimetry/include/otbMuellerToReciprocalCovarianceImageFilter.h b/Modules/Filtering/Polarimetry/include/otbMuellerToReciprocalCovarianceFunctor.h similarity index 100% rename from Modules/Filtering/Polarimetry/include/otbMuellerToReciprocalCovarianceImageFilter.h rename to Modules/Filtering/Polarimetry/include/otbMuellerToReciprocalCovarianceFunctor.h diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalCoherencyToReciprocalMuellerImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalCoherencyToReciprocalMuellerFunctor.h similarity index 51% rename from Modules/Filtering/Polarimetry/include/otbReciprocalCoherencyToReciprocalMuellerImageFilter.h rename to Modules/Filtering/Polarimetry/include/otbReciprocalCoherencyToReciprocalMuellerFunctor.h index 315239c7d643c1cd044541d05c8c0501e186e7ef..da536a04b8ab6ae01ac62e596c5b94af3116c657 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalCoherencyToReciprocalMuellerImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalCoherencyToReciprocalMuellerFunctor.h @@ -19,10 +19,8 @@ */ -#ifndef otbReciprocalCoherencyToReciprocalMuellerImageFilter_h -#define otbReciprocalCoherencyToReciprocalMuellerImageFilter_h - -#include "otbUnaryFunctorImageFilter.h" +#ifndef otbReciprocalCoherencyToReciprocalMuellerFunctor_h +#define otbReciprocalCoherencyToReciprocalMuellerFunctor_h namespace otb { @@ -51,9 +49,9 @@ namespace Functor { * - channel #15 : \f$ 0.5.Re(VAL0) \f$ * * With: - * VAL0 = C_{33}+C_{12}-C_{11}-(C_{12}-C_{22})^{*} - * VAL1 = -C_{33}+C_{12}-C_{11}-(C_{12}-C_{22})^{*} - * + * VAL0 = C_{33}+C_{12}-C_{11}-(C_{12}-C_{22})^{*} + * VAL1 = -C_{33}+C_{12}-C_{11}-(C_{12}-C_{22})^{*} + * * Where Coherency is the input pixel and contains: * - channel #0 : \f$ 0.5*(S_{hh}+S_{vv}).(S_{hh}+S_{vv})^{*} \f$ * - channel #1 : \f$ 0.5*(S_{hh}+S_{vv}).(S_{hh}-S_{vv})^{*} \f$ @@ -77,101 +75,48 @@ public: typedef typename std::complex <double> ComplexType; typedef typename TOutput::ValueType OutputValueType; - inline TOutput operator()( const TInput & Coherency ) const - { - TOutput result; - result.SetSize(NumberOfComponentsPerPixel); - + inline void operator()( TOutput & result, const TInput & Coherency ) const + { const double T1 = static_cast<double>(Coherency[0].real()); const double T2 = static_cast<double>(Coherency[3].real()); const double T3 = static_cast<double>(Coherency[5].real()); - + ComplexType VAL4 = static_cast<ComplexType>( (Coherency[1] - Coherency[3]) ); ComplexType VAL5 = static_cast<ComplexType>( (Coherency[1] - Coherency[0]) ); - ComplexType VAL0 = static_cast<ComplexType>( Coherency[5] ) + VAL5 - std::conj(VAL4); + ComplexType VAL0 = static_cast<ComplexType>( Coherency[5] ) + VAL5 - std::conj(VAL4); ComplexType VAL1 = static_cast<ComplexType>( -Coherency[5] ) + VAL5 - std::conj(VAL4); - result[0] = 0.5*(T1+T2+T3); + result[0] = 0.5*(T1+T2+T3); result[1] = static_cast<double>( Coherency[1].real()+Coherency[3].imag() ); - result[2] = static_cast<double>( Coherency[2].real() ); - result[3] = static_cast<double>( Coherency[4].imag() ); - result[4] = static_cast<double>( Coherency[1].real() ); - result[5] = 0.5*(T1+T2-T3); + result[2] = static_cast<double>( Coherency[2].real() ); + result[3] = static_cast<double>( Coherency[4].imag() ); + result[4] = static_cast<double>( Coherency[1].real() ); + result[5] = 0.5*(T1+T2-T3); result[6] = static_cast<double>( Coherency[4].real() ); - result[7] = static_cast<double>( Coherency[2].imag() ); + result[7] = static_cast<double>( Coherency[2].imag() ); result[8] = static_cast<double>( -Coherency[2].real() ); result[9] = static_cast<double>( -Coherency[4].real() ); - result[10] = static_cast<double>( 0.5*VAL1.real() ); - result[11] = static_cast<double>( 0.5*VAL0.imag() ); - result[12] = static_cast<double>( Coherency[4].imag() ); - result[13] = static_cast<double>( Coherency[2].imag() ); - result[14] = static_cast<double>( 0.5*std::conj(VAL1).imag() ); - result[15] = static_cast<double>( 0.5*VAL0.real() ); - - return result; - } - - unsigned int GetOutputSize() - { - return NumberOfComponentsPerPixel; - } + result[10] = static_cast<double>( 0.5*VAL1.real() ); + result[11] = static_cast<double>( 0.5*VAL0.imag() ); + result[12] = static_cast<double>( Coherency[4].imag() ); + result[13] = static_cast<double>( Coherency[2].imag() ); + result[14] = static_cast<double>( 0.5*std::conj(VAL1).imag() ); + result[15] = static_cast<double>( 0.5*VAL0.real() ); + } + + constexpr size_t OutputSize(...) const + { + // Size of the reciprocal mueller matrix + return 16; + } /** Constructor */ ReciprocalCoherencyToReciprocalMuellerFunctor() {} /** Destructor */ virtual ~ReciprocalCoherencyToReciprocalMuellerFunctor() {} - -private: - itkStaticConstMacro(NumberOfComponentsPerPixel, unsigned int, 16); }; -} - - -/** \class otbReciprocalCoherencyToReciprocalMuellerImageFilter - * \brief Compute the reciprocal Mueller matrix image (10 real channels) - * from the Reciprocal coherency image (6 complex channels) - * - * For more datails, please refer to ReciprocalCoherencyToReciprocalMuellerFunctor. - * - * \ingroup SARPolarimetry - * \sa ReciprocalCoherencyToReciprocalMuellerFunctor - * - * - * \ingroup OTBPolarimetry - */ -template <class TInputImage, class TOutputImage> -class ITK_EXPORT ReciprocalCoherencyToReciprocalMuellerImageFilter : - public UnaryFunctorImageFilter<TInputImage, TOutputImage, Functor::ReciprocalCoherencyToReciprocalMuellerFunctor< - typename TInputImage::PixelType, typename TOutputImage::PixelType> > -{ -public: - /** Standard class typedefs. */ - typedef ReciprocalCoherencyToReciprocalMuellerImageFilter Self; - typedef typename Functor::ReciprocalCoherencyToReciprocalMuellerFunctor< - typename TInputImage::PixelType, typename TOutputImage::PixelType> FunctionType; - typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctionType> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Runtime information support. */ - itkTypeMacro(ReciprocalCoherencyToReciprocalMuellerImageFilter, UnaryFunctorImageFilter); - - -protected: - ReciprocalCoherencyToReciprocalMuellerImageFilter() {} - ~ReciprocalCoherencyToReciprocalMuellerImageFilter() override {} - - -private: - ReciprocalCoherencyToReciprocalMuellerImageFilter(const Self&) = delete; - void operator=(const Self&) = delete; - -}; - +} // end namespace functor } // end namespace otb #endif diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToCoherencyDegreeFunctor.h similarity index 57% rename from Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h rename to Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToCoherencyDegreeFunctor.h index 9e559850bc52e064e045e50afd33755689ea168d..f8b0ca652c2718a418b70d655587a169cd8505b8 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToCoherencyDegreeImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToCoherencyDegreeFunctor.h @@ -19,10 +19,8 @@ */ -#ifndef otbReciprocalCovarianceToCoherencyDegreeImageFilter_h -#define otbReciprocalCovarianceToCoherencyDegreeImageFilter_h - -#include "otbUnaryFunctorImageFilter.h" +#ifndef otbReciprocalCovarianceToCoherencyDegreeFunctor_h +#define otbReciprocalCovarianceToCoherencyDegreeFunctor_h namespace otb { @@ -56,12 +54,8 @@ public: typedef typename std::complex <double> ComplexType; typedef typename TOutput::ValueType OutputValueType; - inline TOutput operator()( const TInput & Covariance ) const + inline void operator()( TOutput & result, const TInput & Covariance ) const { - TOutput result; - result.SetSize(m_NumberOfComponentsPerPixel); - result.Fill(0.0); - /* Using the convention * \f$ C_{11} = S_{hh}*S_{hh}^* \f$ * \f$ C_{12} = S_{hh}*S_{hv}^* \f$ @@ -91,71 +85,24 @@ public: { result[2] = std::abs(C12) / std::sqrt(C11 * C22); // |<hh.hv*|/sqrt(<hh.hh*><hv.hv*>) } - - return result; } - unsigned int GetOutputSize() - { - return m_NumberOfComponentsPerPixel; - } + constexpr size_t OutputSize(...) const + { + // Size of the result + return 3; + } /** Constructor */ - ReciprocalCovarianceToCoherencyDegreeFunctor() : m_NumberOfComponentsPerPixel(3), m_Epsilon(1e-6) {} + ReciprocalCovarianceToCoherencyDegreeFunctor() {} /** Destructor */ virtual ~ReciprocalCovarianceToCoherencyDegreeFunctor() {} private: - unsigned int m_NumberOfComponentsPerPixel; - const double m_Epsilon; + static constexpr double m_Epsilon = 1e-6; }; -} - - -/** \class otbReciprocalCovarianceToCoherencyDegreeImageFilter - * \brief Compute the Coherency Degree coefficient - * from the MLC image (6 complex channels) - * For more details, lease refer to the class ReciprocalCovarianceToCoherencyDegreeFunctor. - * - * \ingroup SARPolarimetry - * \sa ReciprocalCovarianceToCoherencyDegreeFunctor - * - * - * \ingroup OTBPolarimetry - */ -template <class TInputImage, class TOutputImage> -class ITK_EXPORT ReciprocalCovarianceToCoherencyDegreeImageFilter : - public UnaryFunctorImageFilter<TInputImage, TOutputImage, Functor::ReciprocalCovarianceToCoherencyDegreeFunctor< - typename TInputImage::PixelType, typename TOutputImage::PixelType> > -{ -public: - /** Standard class typedefs. */ - typedef ReciprocalCovarianceToCoherencyDegreeImageFilter Self; - typedef typename Functor::ReciprocalCovarianceToCoherencyDegreeFunctor< - typename TInputImage::PixelType, typename TOutputImage::PixelType> FunctionType; - typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctionType> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Runtime information support. */ - itkTypeMacro(ReciprocalCovarianceToCoherencyDegreeImageFilter, UnaryFunctorImageFilter); - - -protected: - ReciprocalCovarianceToCoherencyDegreeImageFilter() {} - ~ReciprocalCovarianceToCoherencyDegreeImageFilter() override {} - -private: - ReciprocalCovarianceToCoherencyDegreeImageFilter(const Self&) = delete; - void operator=(const Self&) = delete; - - -}; - +} // end namespace functor } // end namespace otb #endif diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToReciprocalCoherencyFunctor.h similarity index 57% rename from Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h rename to Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToReciprocalCoherencyFunctor.h index c5cff9de09cfa45e2ce9cfa161b475f953b1ff7c..bd76a70d045cc043ed4c6f4e10b19ff9e961d0e2 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalCovarianceToReciprocalCoherencyFunctor.h @@ -19,10 +19,8 @@ */ -#ifndef otbReciprocalCovarianceToReciprocalCoherencyImageFilter_h -#define otbReciprocalCovarianceToReciprocalCoherencyImageFilter_h - -#include "otbUnaryFunctorImageFilter.h" +#ifndef otbReciprocalCovarianceToReciprocalCoherencyFunctor_h +#define otbReciprocalCovarianceToReciprocalCoherencyFunctor_h namespace otb { @@ -59,22 +57,18 @@ public: typedef typename std::complex <double> ComplexType; typedef typename TOutput::ValueType OutputValueType; - inline TOutput operator()( const TInput & Covariance ) const + inline void operator()( TOutput & result, const TInput & Covariance ) const { - TOutput result; - result.SetSize(m_NumberOfComponentsPerPixel); - - const ComplexType C11 = static_cast<ComplexType>(Covariance[0]); const ComplexType C12 = static_cast<ComplexType>(Covariance[1]); const ComplexType C13 = static_cast<ComplexType>(Covariance[2]); const ComplexType C22 = static_cast<ComplexType>(Covariance[3]); const ComplexType C23 = static_cast<ComplexType>(Covariance[4]); const ComplexType C33 = static_cast<ComplexType>(Covariance[5]); - + const ComplexType two = ComplexType(2.0, 0.0); const ComplexType rootTwo = ComplexType(std::sqrt(2.0), 0.0); - + result[0] = static_cast<OutputValueType>( C33 + C13 + std::conj(C13) + C11 ); result[1] = static_cast<OutputValueType>( -C33 - C13 + std::conj(C13) + C11 ); result[2] = static_cast<OutputValueType>( rootTwo*C12 + rootTwo*std::conj(C23) ); @@ -83,70 +77,20 @@ public: result[5] = static_cast<OutputValueType>( two * C22 ); result /= 2.0; - - return result; } - unsigned int GetOutputSize() - { - return m_NumberOfComponentsPerPixel; - } + constexpr size_t OutputSize(...) const + { + // Size of the result + return 6; + } /** Constructor */ - ReciprocalCovarianceToReciprocalCoherencyFunctor() : m_NumberOfComponentsPerPixel(6) {} - + ReciprocalCovarianceToReciprocalCoherencyFunctor() {} /** Destructor */ virtual ~ReciprocalCovarianceToReciprocalCoherencyFunctor() {} - -private: - unsigned int m_NumberOfComponentsPerPixel; -}; -} - - -/** \class otbReciprocalCovarianceToReciprocalCoherencyImageFilter - * \brief Compute the Coherency image (6 complex channels) - * from the Covariance image (6 complex channels) - * - * For more details, please refer to the class ReciprocalCovarianceToReciprocalCoherencyFunctor. - * - * \ingroup SARPolarimetry - * \sa ReciprocalCovarianceToReciprocalCoherencyFunctor - * - * \ingroup OTBPolarimetry - */ -template <class TInputImage, class TOutputImage> -class ITK_EXPORT ReciprocalCovarianceToReciprocalCoherencyImageFilter : - public UnaryFunctorImageFilter<TInputImage, TOutputImage, Functor::ReciprocalCovarianceToReciprocalCoherencyFunctor< - typename TInputImage::PixelType, typename TOutputImage::PixelType> > -{ -public: - /** Standard class typedefs. */ - typedef ReciprocalCovarianceToReciprocalCoherencyImageFilter Self; - typedef Functor::ReciprocalCovarianceToReciprocalCoherencyFunctor< - typename TInputImage::PixelType, typename TOutputImage::PixelType> FunctorType; - typedef UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctorType> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Runtime information support. */ - itkTypeMacro(ReciprocalCovarianceToReciprocalCoherencyImageFilter, UnaryFunctorImageFilter); - - -protected: - ReciprocalCovarianceToReciprocalCoherencyImageFilter() {} - ~ReciprocalCovarianceToReciprocalCoherencyImageFilter() override {} - -private: - ReciprocalCovarianceToReciprocalCoherencyImageFilter(const Self&) = delete; - void operator=(const Self&) = delete; - - }; - +} // end namespace functor } // end namespace otb #endif diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor.h similarity index 65% rename from Modules/Filtering/Polarimetry/include/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h rename to Modules/Filtering/Polarimetry/include/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor.h index 6cf8ea7e2ae5fe4071ca435c273fc7d0a0bb0c28..0e23399484754fec92c47ecd6c984e93e0242e90 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor.h @@ -19,8 +19,8 @@ */ -#ifndef otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter_h -#define otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter_h +#ifndef otbReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor_h +#define otbReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor_h #include "itkUnaryFunctorImageFilter.h" #include <complex> @@ -64,21 +64,16 @@ public: typedef typename std::complex <double> ComplexType; typedef typename TOutput::ValueType OutputValueType; - inline TOutput operator()( const TInput & Covariance ) const + inline void operator()( TOutput & result, const TInput & Covariance ) const { - TOutput result; - result.SetSize(m_NumberOfComponentsPerPixel); - result.Fill(0.0); - - const ComplexType C11 = static_cast<ComplexType>( Covariance[0] ); // <hh.hh*> const ComplexType C12 = static_cast<ComplexType>( Covariance[1] ); // <sqrt(2).hh.hv*> const ComplexType C13 = static_cast<ComplexType>( Covariance[2] ); // <hh.vv*> const ComplexType C22 = static_cast<ComplexType>( Covariance[3] ); // <2.hv.hv*> const ComplexType C23 = static_cast<ComplexType>( Covariance[4] ); // <sqrt(2).hv.vv*> const ComplexType C33 = static_cast<ComplexType>( Covariance[5] ); // <vv.vv*> - - + + const ComplexType cst1 = ComplexType(0.0, std::sqrt(2.0)); const ComplexType two = ComplexType(2.0, 0 ); @@ -90,66 +85,21 @@ public: result[5] = static_cast<ComplexType>( C33+cst1*C23-C13-cst1*std::conj(C23)-std::conj(C13)+two*C22+cst1*C12-cst1*std::conj(C12)+C11 ) ; result /= 4.0; - - return result; } - unsigned int GetOutputSize() - { - return m_NumberOfComponentsPerPixel; - } + constexpr size_t OutputSize(...) const + { + // Size of the result (entropy, alpha, anisotropy) + return 6; + } /** Constructor */ - ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor() : m_NumberOfComponentsPerPixel(6) {} + ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor() {} /** Destructor */ virtual ~ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor() {} - -private: - unsigned int m_NumberOfComponentsPerPixel; -}; -} - - -/** \class otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter - * \brief Compute the reciprocal Covariance circular matrix image from the reciprocal Covariance linear matrix image. - * For more details, please refer to the class ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor. - * - * \ingroup SARPolarimetry - * \sa ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor - * - * \ingroup OTBPolarimetry - */ - template <class TInputImage, class TOutputImage> -class ITK_EXPORT ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter : - public itk::UnaryFunctorImageFilter<TInputImage, TOutputImage, Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor< - typename TInputImage::PixelType, typename TOutputImage::PixelType> > -{ -public: - /** Standard class typedefs. */ - typedef ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter Self; - typedef typename Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor< - typename TInputImage::PixelType, typename TOutputImage::PixelType> FunctionType; - typedef itk::UnaryFunctorImageFilter<TInputImage, TOutputImage, FunctionType> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Runtime information support. */ - itkTypeMacro(ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter, itk::UnaryFunctorImageFilter); - - -protected: - ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter() {} - ~ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter() override {} - -private: - ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter(const Self&) = delete; - void operator=(const Self&) = delete; - }; +} // end namespace functor } // end namespace otb diff --git a/Modules/Filtering/Polarimetry/include/otbSinclairImageFilters.h b/Modules/Filtering/Polarimetry/include/otbSinclairImageFilters.h index 2dc5a529a3b973ee097eb2c0216320e2ad320591..b34cab703f3246e77c80bc2ec542292622c3880d 100644 --- a/Modules/Filtering/Polarimetry/include/otbSinclairImageFilters.h +++ b/Modules/Filtering/Polarimetry/include/otbSinclairImageFilters.h @@ -42,6 +42,16 @@ #include "otbReciprocalHuynenDecompFunctor.h" #include "otbReciprocalPauliDecompFunctor.h" +// Mueller functor +#include "otbMuellerToPolarisationDegreeAndPowerFunctor.h" +#include "otbMuellerToReciprocalCovarianceFunctor.h" + +// Other reciprocal filters +#include "otbReciprocalCoherencyToReciprocalMuellerFunctor.h" +#include "otbReciprocalCovarianceToCoherencyDegreeFunctor.h" +#include "otbReciprocalCovarianceToReciprocalCoherencyFunctor.h" +#include "otbReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor.h" + namespace otb { //################# @@ -140,7 +150,30 @@ template <typename TInputImage, typename TOutputImage> using MuellerToReciprocalCovarianceImageFilter = FunctorImageFilter<Functor::MuellerToReciprocalCovarianceFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType>>; +//######################### +// Other reciprocal filters +//######################### +// This is the entire declaration of ReciprocalCoherencyToReciprocalMuellerImageFilter +template <typename TInputImage, typename TOutputImage> +using ReciprocalCoherencyToReciprocalMuellerImageFilter = + FunctorImageFilter<Functor:: + ReciprocalCoherencyToReciprocalMuellerFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType>>; + +// This is the entire declaration of ReciprocalCovarianceToCoherencyDegreeImageFilter +template <typename TInputImage, typename TOutputImage> +using ReciprocalCovarianceToCoherencyDegreeImageFilter = + FunctorImageFilter<Functor::ReciprocalCovarianceToCoherencyDegreeFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType>>; + +// This is the entire declaration of ReciprocalCovarianceToReciprocalCoherencyImageFilter +template <typename TInputImage, typename TOutputImage> +using ReciprocalCovarianceToReciprocalCoherencyImageFilter = + FunctorImageFilter<Functor::ReciprocalCovarianceToReciprocalCoherencyFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType>>; + +// This is the entire declaration of ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter +template <typename TInputImage, typename TOutputImage> +using ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter = + FunctorImageFilter<Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType>>; } // end namespace otb diff --git a/Modules/Filtering/Polarimetry/test/otbMuellerToPolarisationDegreeAndPowerImageFilter.cxx b/Modules/Filtering/Polarimetry/test/otbMuellerToPolarisationDegreeAndPowerImageFilter.cxx index 79d9276afc42ed5db1dc5387ba5a1b86a19e6d02..946615eb0f88c0cf11a71487ce09fc121ebabc28 100644 --- a/Modules/Filtering/Polarimetry/test/otbMuellerToPolarisationDegreeAndPowerImageFilter.cxx +++ b/Modules/Filtering/Polarimetry/test/otbMuellerToPolarisationDegreeAndPowerImageFilter.cxx @@ -26,8 +26,7 @@ #include "otbVectorImage.h" #include "otbImageFileReader.h" #include "otbImageFileWriter.h" -#include "otbMuellerToPolarisationDegreeAndPowerImageFilter.h" - +#include "otbSinclairImageFilters.h" int otbMuellerToPolarisationDegreeAndPowerImageFilter(int itkNotUsed(argc), char * argv[]) { @@ -49,7 +48,7 @@ int otbMuellerToPolarisationDegreeAndPowerImageFilter(int itkNotUsed(argc), char reader->SetFileName(inputFilename); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(reader->GetOutput()); + filter->SetInput1(reader->GetOutput()); writer->SetFileName(outputFilename); writer->SetInput(filter->GetOutput()); diff --git a/Modules/Filtering/Polarimetry/test/otbMuellerToReciprocalCovarianceFunctor.cxx b/Modules/Filtering/Polarimetry/test/otbMuellerToReciprocalCovarianceFunctor.cxx index e5cda3f7dd5bc4aa49c3009a89e497616f8fd08f..a8e601235ff7e8bd1e41b6fe8e54b05c776ceee8 100644 --- a/Modules/Filtering/Polarimetry/test/otbMuellerToReciprocalCovarianceFunctor.cxx +++ b/Modules/Filtering/Polarimetry/test/otbMuellerToReciprocalCovarianceFunctor.cxx @@ -20,7 +20,7 @@ #include "itkMacro.h" -#include "otbMuellerToReciprocalCovarianceImageFilter.h" +#include "otbSinclairImageFilters.h" #include "itkVariableLengthVector.h" #include <complex> diff --git a/Modules/Filtering/Polarimetry/test/otbMuellerToReciprocalCovarianceImageFilter.cxx b/Modules/Filtering/Polarimetry/test/otbMuellerToReciprocalCovarianceImageFilter.cxx index 53991133273f9f5844192319a02b511ad2b8638a..2b86494fa6d41cd3d6486dd39a10c8b593483331 100644 --- a/Modules/Filtering/Polarimetry/test/otbMuellerToReciprocalCovarianceImageFilter.cxx +++ b/Modules/Filtering/Polarimetry/test/otbMuellerToReciprocalCovarianceImageFilter.cxx @@ -24,9 +24,10 @@ #include "otbVectorImage.h" #include "otbImageFileReader.h" #include "otbImageFileWriter.h" -#include "otbMuellerToReciprocalCovarianceImageFilter.h" #include "otbExtractROI.h" +#include "otbSinclairImageFilters.h" + int otbMuellerToReciprocalCovarianceImageFilter(int itkNotUsed(argc), char * argv[]) { const char * inputFilename = argv[1]; @@ -48,7 +49,7 @@ int otbMuellerToReciprocalCovarianceImageFilter(int itkNotUsed(argc), char * arg reader->SetFileName(inputFilename ); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(reader->GetOutput()); + filter->SetInput1(reader->GetOutput()); writer->SetFileName(outputFilename); writer->SetInput(filter->GetOutput()); diff --git a/Modules/Filtering/Polarimetry/test/otbReciprocalCoherencyToReciprocalMuellerImageFilter.cxx b/Modules/Filtering/Polarimetry/test/otbReciprocalCoherencyToReciprocalMuellerImageFilter.cxx index 1e8c910a9baf20a15385608ad9ad7ab554bbdd5b..47b237dc300b312e95aec6756db0dcdf661cad20 100644 --- a/Modules/Filtering/Polarimetry/test/otbReciprocalCoherencyToReciprocalMuellerImageFilter.cxx +++ b/Modules/Filtering/Polarimetry/test/otbReciprocalCoherencyToReciprocalMuellerImageFilter.cxx @@ -26,7 +26,7 @@ #include "otbVectorImage.h" #include "otbImageFileReader.h" #include "otbImageFileWriter.h" -#include "otbReciprocalCoherencyToReciprocalMuellerImageFilter.h" +#include "otbSinclairImageFilters.h" int otbReciprocalCoherencyToReciprocalMuellerImageFilter(int itkNotUsed(argc), char * argv[]) @@ -53,7 +53,7 @@ int otbReciprocalCoherencyToReciprocalMuellerImageFilter(int itkNotUsed(argc), c reader->SetFileName(inputFilename); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(reader->GetOutput()); + filter->SetInput1(reader->GetOutput()); writer->SetFileName(outputFilename); writer->SetInput(filter->GetOutput()); diff --git a/Modules/Filtering/Polarimetry/test/otbReciprocalCovarianceToCoherencyDegreeImageFilter.cxx b/Modules/Filtering/Polarimetry/test/otbReciprocalCovarianceToCoherencyDegreeImageFilter.cxx index 1223a207d98e578889586d8e191e0d612f2deb91..68f4fc12673cbb87bc03c414c235010e4f4934c3 100644 --- a/Modules/Filtering/Polarimetry/test/otbReciprocalCovarianceToCoherencyDegreeImageFilter.cxx +++ b/Modules/Filtering/Polarimetry/test/otbReciprocalCovarianceToCoherencyDegreeImageFilter.cxx @@ -26,8 +26,7 @@ #include "otbVectorImage.h" #include "otbImageFileReader.h" #include "otbImageFileWriter.h" -#include "otbReciprocalCovarianceToCoherencyDegreeImageFilter.h" - +#include "otbSinclairImageFilters.h" int otbReciprocalCovarianceToCoherencyDegreeImageFilter(int itkNotUsed(argc), char * argv[]) { @@ -50,7 +49,7 @@ int otbReciprocalCovarianceToCoherencyDegreeImageFilter(int itkNotUsed(argc), ch reader->SetFileName(inputFilename); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(reader->GetOutput()); + filter->SetInput1(reader->GetOutput()); writer->SetFileName(outputFilename); writer->SetInput(filter->GetOutput()); diff --git a/Modules/Filtering/Polarimetry/test/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.cxx b/Modules/Filtering/Polarimetry/test/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.cxx index c52d7b6c46d418492de202fdeb794182edc3eebe..420bd429e051d672a46a6f966b7b553191353117 100644 --- a/Modules/Filtering/Polarimetry/test/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.cxx +++ b/Modules/Filtering/Polarimetry/test/otbReciprocalCovarianceToReciprocalCoherencyImageFilter.cxx @@ -25,7 +25,7 @@ #include "otbVectorImage.h" #include "otbImageFileReader.h" #include "otbImageFileWriter.h" -#include "otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h" +#include "otbSinclairImageFilters.h" int otbReciprocalCovarianceToReciprocalCoherencyImageFilter(int itkNotUsed(argc), char * argv[]) @@ -47,7 +47,7 @@ int otbReciprocalCovarianceToReciprocalCoherencyImageFilter(int itkNotUsed(argc) reader->SetFileName(inputFilename); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(reader->GetOutput()); + filter->SetInput1(reader->GetOutput()); writer->SetFileName(outputFilename); writer->SetInput(filter->GetOutput()); diff --git a/Modules/Filtering/Polarimetry/test/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.cxx b/Modules/Filtering/Polarimetry/test/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.cxx index 24d50369400a5a2c9977e088e3237c4808e3fdb7..8e6d581ec34220583430c67f4ee3d7765ae60cd3 100644 --- a/Modules/Filtering/Polarimetry/test/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.cxx +++ b/Modules/Filtering/Polarimetry/test/otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.cxx @@ -25,7 +25,7 @@ #include "otbVectorImage.h" #include "otbImageFileReader.h" #include "otbImageFileWriter.h" -#include "otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h" +#include "otbSinclairImageFilters.h" int otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter(int itkNotUsed(argc), char * argv[]) { @@ -49,7 +49,7 @@ int otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter(int i reader->SetFileName(inputFilename); FilterType::Pointer filter = FilterType::New(); - filter->SetInput(reader->GetOutput()); + filter->SetInput1(reader->GetOutput()); writer->SetFileName(outputFilename); writer->SetInput(filter->GetOutput());