OTB  6.7.0
Orfeo Toolbox
otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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 
59 template< class TInput, class TOutput>
61 {
62 public:
63  typedef double RealType;
64  typedef typename std::complex <double> ComplexType;
65  typedef typename TOutput::ValueType OutputValueType;
66 
67  inline void operator()(TOutput& result, const TInput& Covariance) const
68  {
69  const ComplexType C11 = static_cast<ComplexType>( Covariance[0] ); // <hh.hh*>
70  const ComplexType C12 = static_cast<ComplexType>( Covariance[1] ); // <sqrt(2).hh.hv*>
71  const ComplexType C13 = static_cast<ComplexType>( Covariance[2] ); // <hh.vv*>
72  const ComplexType C22 = static_cast<ComplexType>( Covariance[3] ); // <2.hv.hv*>
73  const ComplexType C23 = static_cast<ComplexType>( Covariance[4] ); // <sqrt(2).hv.vv*>
74  const ComplexType C33 = static_cast<ComplexType>( Covariance[5] ); // <vv.vv*>
75 
76 
77  const ComplexType cst1 = ComplexType(0.0, std::sqrt(2.0));
78  const ComplexType two = ComplexType(2.0, 0 );
79 
80  result[0] = static_cast<ComplexType>( C33-cst1*C23-C13+cst1*std::conj(C23)-std::conj(C13)+two*C22-cst1*C12+cst1*std::conj(C12)+C11 ) ;
81  result[1] = static_cast<ComplexType>( cst1*C33+two*C23-cst1*C13+cst1*std::conj(C13)+two*std::conj(C12)-cst1*C11 );
82  result[2] = 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[3] = static_cast<ComplexType>( two*C33+two*C13+two*std::conj(C13)+two*C11 ) ;
84  result[4] = static_cast<ComplexType>( cst1*C33+cst1*C13+two*std::conj(C23)-cst1*std::conj(C13)+two*C12-cst1*C11 ) ;
85  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 ) ;
86 
87  result /= 4.0;
88  }
89 
90  constexpr size_t OutputSize(...) const
91  {
92  // Size of the result (entropy, alpha, anisotropy)
93  return 6;
94  }
95 };
96 } // namespace Functor
97 
110 template <typename TInputImage, typename TOutputImage>
113 
114 } // end namespace otb
115 
116 #endif
Compute the reciprocal Covariance circular matrix from the reciprocal Covariance linear matrix...
FunctorImageFilter< Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType >> ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter
Applies otb::Functor::ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor.