OTB  9.0.0
Orfeo Toolbox
otbReciprocalCovarianceToReciprocalCoherencyImageFilter.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 otbReciprocalCovarianceToReciprocalCoherencyImageFilter_h
23 #define otbReciprocalCovarianceToReciprocalCoherencyImageFilter_h
24 
25 #include "otbFunctorImageFilter.h"
26 
27 namespace otb
28 {
29 
30 namespace Functor
31 {
32 
59 template <class TInput, class TOutput>
61 {
62 public:
63  typedef typename std::complex<double> ComplexType;
64  typedef typename TOutput::ValueType OutputValueType;
65 
66  inline void operator()(TOutput& result, const TInput& Covariance) const
67  {
68  const ComplexType C11 = static_cast<ComplexType>(Covariance[0]);
69  const ComplexType C12 = static_cast<ComplexType>(Covariance[1]);
70  const ComplexType C13 = static_cast<ComplexType>(Covariance[2]);
71  const ComplexType C22 = static_cast<ComplexType>(Covariance[3]);
72  const ComplexType C23 = static_cast<ComplexType>(Covariance[4]);
73  const ComplexType C33 = static_cast<ComplexType>(Covariance[5]);
74 
75  const ComplexType two = ComplexType(2.0, 0.0);
76  const ComplexType rootTwo = ComplexType(std::sqrt(2.0), 0.0);
77 
78  result[0] = static_cast<OutputValueType>(C33 + C13 + std::conj(C13) + C11);
79  result[1] = static_cast<OutputValueType>(-C33 - C13 + std::conj(C13) + C11);
80  result[2] = static_cast<OutputValueType>(rootTwo * C12 + rootTwo * std::conj(C23));
81  result[3] = static_cast<OutputValueType>(C33 - C13 - std::conj(C13) + C11);
82  result[4] = static_cast<OutputValueType>(rootTwo * C12 - rootTwo * std::conj(C23));
83  result[5] = static_cast<OutputValueType>(two * C22);
84 
85  result /= 2.0;
86  }
87 
88  constexpr size_t OutputSize(...) const
89  {
90  // Size of the result
91  return 6;
92  }
93 };
94 } // namespace Functor
95 
108 template <typename TInputImage, typename TOutputImage>
111 
112 } // end namespace otb
113 
114 #endif
otbFunctorImageFilter.h
otb::Functor::ReciprocalCovarianceToReciprocalCoherencyFunctor
Evaluate the Coherency matrix from the Covariance image.
Definition: otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h:60
otb::Functor::ReciprocalCovarianceToReciprocalCoherencyFunctor::OutputValueType
TOutput::ValueType OutputValueType
Definition: otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h:64
otb::Functor::ReciprocalCovarianceToReciprocalCoherencyFunctor::ComplexType
std::complex< double > ComplexType
Definition: otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h:63
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::ReciprocalCovarianceToReciprocalCoherencyFunctor::operator()
void operator()(TOutput &result, const TInput &Covariance) const
Definition: otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h:66
otb::Functor::ReciprocalCovarianceToReciprocalCoherencyFunctor::OutputSize
constexpr vcl_size_t OutputSize(...) const
Definition: otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h:88
otb::ReciprocalCovarianceToReciprocalCoherencyImageFilter
FunctorImageFilter< Functor::ReciprocalCovarianceToReciprocalCoherencyFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType > > ReciprocalCovarianceToReciprocalCoherencyImageFilter
Applies ReciprocalCovarianceToReciprocalCoherencyFunctor.
Definition: otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h:110