OTB  9.0.0
Orfeo Toolbox
otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.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 otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter_h
23 #define otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter_h
24 
25 #include "otbFunctorImageFilter.h"
26 #include <complex>
27 
28 namespace otb
29 {
30 
31 namespace Functor
32 {
33 
60 template <class TInput, class TOutput>
62 {
63 public:
64  typedef double RealType;
65  typedef typename std::complex<double> ComplexType;
66  typedef typename TOutput::ValueType OutputValueType;
67 
68  inline void operator()(TOutput& result, const TInput& Covariance) const
69  {
70  const ComplexType C11 = static_cast<ComplexType>(Covariance[0]); // <hh.hh*>
71  const ComplexType C12 = static_cast<ComplexType>(Covariance[1]); // <sqrt(2).hh.hv*>
72  const ComplexType C13 = static_cast<ComplexType>(Covariance[2]); // <hh.vv*>
73  const ComplexType C22 = static_cast<ComplexType>(Covariance[3]); // <2.hv.hv*>
74  const ComplexType C23 = static_cast<ComplexType>(Covariance[4]); // <sqrt(2).hv.vv*>
75  const ComplexType C33 = static_cast<ComplexType>(Covariance[5]); // <vv.vv*>
76 
77 
78  const ComplexType cst1 = ComplexType(0.0, std::sqrt(2.0));
79  const ComplexType two = ComplexType(2.0, 0);
80 
81  result[0] =
82  static_cast<ComplexType>(C33 - cst1 * C23 - C13 + cst1 * std::conj(C23) - std::conj(C13) + two * C22 - cst1 * C12 + cst1 * std::conj(C12) + C11);
83  result[1] = static_cast<ComplexType>(cst1 * C33 + two * C23 - cst1 * C13 + cst1 * std::conj(C13) + two * std::conj(C12) - cst1 * C11);
84  result[2] =
85  static_cast<ComplexType>(-C33 + cst1 * C23 + C13 + cst1 * std::conj(C23) + std::conj(C13) + two * C22 - cst1 * C12 - cst1 * std::conj(C12) - C11);
86  result[3] = static_cast<ComplexType>(two * C33 + two * C13 + two * std::conj(C13) + two * C11);
87  result[4] = static_cast<ComplexType>(cst1 * C33 + cst1 * C13 + two * std::conj(C23) - cst1 * std::conj(C13) + two * C12 - cst1 * C11);
88  result[5] =
89  static_cast<ComplexType>(C33 + cst1 * C23 - C13 - cst1 * std::conj(C23) - std::conj(C13) + two * C22 + cst1 * C12 - cst1 * std::conj(C12) + C11);
90 
91  result /= 4.0;
92  }
93 
94  constexpr size_t OutputSize(...) const
95  {
96  // Size of the result (entropy, alpha, anisotropy)
97  return 6;
98  }
99 };
100 } // namespace Functor
101 
114 template <typename TInputImage, typename TOutputImage>
117 
118 } // end namespace otb
119 
120 #endif
otbFunctorImageFilter.h
otb::ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter
FunctorImageFilter< Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType > > ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter
Applies otb::Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor.
Definition: otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h:116
otb::Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor::ComplexType
std::complex< double > ComplexType
Definition: otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h:65
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor
Compute the reciprocal Covariance circular matrix from the reciprocal Covariance linear matrix....
Definition: otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h:61
otb::Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor::operator()
void operator()(TOutput &result, const TInput &Covariance) const
Definition: otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h:68
otb::Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor::OutputValueType
TOutput::ValueType OutputValueType
Definition: otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h:66
otb::Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor::OutputSize
constexpr vcl_size_t OutputSize(...) const
Definition: otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h:94
otb::Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor::RealType
double RealType
Definition: otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h:64