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