OTB  6.7.0
Orfeo Toolbox
otbMuellerToReciprocalCovarianceImageFilter.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 otbMuellerToReciprocalCovarianceImageFilter_h
23 #define otbMuellerToReciprocalCovarianceImageFilter_h
24 
25 #include "otbFunctorImageFilter.h"
26 
27 namespace otb
28  {
29 
30 namespace Functor {
31 
69 template< class TInput, class TOutput>
71 {
72 public:
73  typedef std::complex<double> ComplexType;
74  typedef typename TOutput::ValueType OutputValueType;
75 
76  inline void operator()(TOutput& result, const TInput& Mueller) const
77  {
78  // Keep the upper diagonal of the matrix
79  const double M11 = static_cast<double>(Mueller[0]);
80  const double M12 = static_cast<double>(Mueller[1]);
81  const double M13 = static_cast<double>(Mueller[2]);
82  const double M14 = static_cast<double>(Mueller[3]);
83  const double M22 = static_cast<double>(Mueller[5]);
84  const double M23 = static_cast<double>(Mueller[6]);
85  const double M24 = static_cast<double>(Mueller[7]);
86  const double M33 = static_cast<double>(Mueller[10]);
87  const double M34 = static_cast<double>(Mueller[11]);
88  const double M44 = static_cast<double>(Mueller[15]);
89 
90 
91  const ComplexType A(0.5*(M11+M22+2*M12));
92  const ComplexType B(0.5*std::sqrt(2.0)*(M13+M23), 0.5*std::sqrt(2.0)*(M14+M24));
93  const ComplexType C(-0.5*(M33+M44), -M34);
94  const ComplexType E(M11-M22, 0.0);
95  const ComplexType F(0.5*std::sqrt(2.0)*(M13-M23), 0.5*std::sqrt(2.0)*(M14-M24));
96  const ComplexType I(0.5*(M11+M22-2*M12));
97 
98  result[0] = static_cast<OutputValueType>( A );
99  result[1] = static_cast<OutputValueType>( B );
100  result[2] = static_cast<OutputValueType>( C );
101  result[3] = static_cast<OutputValueType>( E );
102  result[4] = static_cast<OutputValueType>( F );
103  result[5] = static_cast<OutputValueType>( I );
104  }
105 
106  constexpr size_t OutputSize(...) const
107  {
108  // Size of the result
109  return 6;
110  }
111 };
112 } // namespace Functor
113 
126 template <typename TInputImage, typename TOutputImage>
129 
130 
131 } // end namespace otb
132 
133 #endif
A generic functor filter templated by its functor.
FunctorImageFilter< Functor::MuellerToReciprocalCovarianceFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType >> MuellerToReciprocalCovarianceImageFilter
Applies otb::Functor::MuellerToReciprocalCovarianceFunctor.
void operator()(TOutput &result, const TInput &Mueller) const