OTB  9.0.0
Orfeo Toolbox
otbReciprocalCovarianceToCoherencyDegreeImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 
22 #ifndef otbReciprocalCovarianceToCoherencyDegreeImageFilter_h
23 #define otbReciprocalCovarianceToCoherencyDegreeImageFilter_h
24 
25 #include "otbFunctorImageFilter.h"
26 
27 namespace otb
28 {
29 
30 namespace Functor
31 {
32 
52 template <class TInput, class TOutput>
54 {
55 public:
56  typedef double RealType;
57  typedef typename std::complex<double> ComplexType;
58  typedef typename TOutput::ValueType OutputValueType;
59 
60  inline void operator()(TOutput& result, const TInput& Covariance) const
61  {
62  /* Using the convention
63  * \f$ C_{11} = S_{hh}*S_{hh}^* \f$
64  * \f$ C_{12} = S_{hh}*S_{hv}^* \f$
65  * \f$ C_{13} = S_{hh}*S_{vv}^* \f$
66  * \f$ C_{22} = S_{hv}*S_{hv}^* \f$
67  * \f$ C_{23} = S_{hv}*S_{vv}^* \f$
68  * \f$ C_{33} = S_{vv}*S_{vv}^* \f$
69  */
70  const RealType C11 = static_cast<RealType>(Covariance[0].real());
71  const ComplexType C12 = static_cast<ComplexType>(Covariance[1]);
72  const ComplexType C13 = static_cast<ComplexType>(Covariance[2]);
73  const RealType C22 = static_cast<RealType>(Covariance[3].real());
74  const ComplexType C23 = static_cast<ComplexType>(Covariance[4]);
75  const RealType C33 = static_cast<RealType>(Covariance[5].real());
76 
77  if ((C11 > m_Epsilon) && (C33 > m_Epsilon))
78  {
79  result[0] = std::abs(C13) / std::sqrt(C11 * C33); // |<hh.vv*|/sqrt(<hh.hh*><vv.vv*>)
80  }
81 
82  if ((C22 > m_Epsilon) && (C33 > m_Epsilon))
83  {
84  result[1] = std::abs(C23) / std::sqrt(C22 * C33); // |<hv.vv*|/sqrt(<hv.hv*><vv.vv*>)
85  }
86 
87  if ((C11 > m_Epsilon) && (C22 > m_Epsilon))
88  {
89  result[2] = std::abs(C12) / std::sqrt(C11 * C22); // |<hh.hv*|/sqrt(<hh.hh*><hv.hv*>)
90  }
91  }
92 
93  constexpr size_t OutputSize(...) const
94  {
95  // Size of the result
96  return 3;
97  }
98 
99 private:
100  static constexpr double m_Epsilon = 1e-6;
101 };
102 } // namespace Functor
103 
116 template <typename TInputImage, typename TOutputImage>
119 } // end namespace otb
120 
121 #endif
otbFunctorImageFilter.h
otb::Functor::ReciprocalCovarianceToCoherencyDegreeFunctor::OutputSize
constexpr vcl_size_t OutputSize(...) const
Definition: otbReciprocalCovarianceToCoherencyDegreeImageFilter.h:93
otb::Functor::ReciprocalCovarianceToCoherencyDegreeFunctor::operator()
void operator()(TOutput &result, const TInput &Covariance) const
Definition: otbReciprocalCovarianceToCoherencyDegreeImageFilter.h:60
otb::Functor::ReciprocalCovarianceToCoherencyDegreeFunctor
Evaluate the Coherency Degree coefficient from from the MLC image.
Definition: otbReciprocalCovarianceToCoherencyDegreeImageFilter.h:53
otb::FunctorImageFilter
A generic functor filter templated by its functor.
Definition: otbFunctorImageFilter.h:322
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::ReciprocalCovarianceToCoherencyDegreeFunctor::ComplexType
std::complex< double > ComplexType
Definition: otbReciprocalCovarianceToCoherencyDegreeImageFilter.h:57
otb::Functor::ReciprocalCovarianceToCoherencyDegreeFunctor::RealType
double RealType
Definition: otbReciprocalCovarianceToCoherencyDegreeImageFilter.h:56
otb::Functor::ReciprocalCovarianceToCoherencyDegreeFunctor::m_Epsilon
static constexpr double m_Epsilon
Definition: otbReciprocalCovarianceToCoherencyDegreeImageFilter.h:100
otb::Functor::ReciprocalCovarianceToCoherencyDegreeFunctor::OutputValueType
TOutput::ValueType OutputValueType
Definition: otbReciprocalCovarianceToCoherencyDegreeImageFilter.h:58