OTB  9.0.0
Orfeo Toolbox
otbSinclairToReciprocalCoherencyMatrixImageFilter.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 #ifndef otbSinclairToReciprocalCoherencyMatrixImageFilter_h
22 #define otbSinclairToReciprocalCoherencyMatrixImageFilter_h
23 
24 #include "itkMacro.h"
25 #include <complex>
26 #include "otbMath.h"
27 #include "vnl/vnl_matrix.h"
28 
29 #include "otbFunctorImageFilter.h"
30 #include "otbPolarimetryTags.h"
31 
32 namespace otb
33 {
34 namespace Functor
35 {
69 template <class TInput1, class TInput2, class TInput3, class TOutput>
71 {
72 public:
74  typedef typename std::complex<double> ComplexType;
75  typedef vnl_matrix<ComplexType> VNLMatrixType;
76  typedef typename TOutput::ValueType OutputValueType;
77 
78  inline void operator()(TOutput& result, const TInput1& Shh, const TInput2& Shv, const TInput3& Svv) const
79  {
80  const ComplexType S_hh = static_cast<ComplexType>(Shh);
81  const ComplexType S_hv = static_cast<ComplexType>(Shv);
82  const ComplexType S_vv = static_cast<ComplexType>(Svv);
83 
84  VNLMatrixType f3p(3, 1, 0.);
85  f3p[0][0] = (S_hh + S_vv) / ComplexType(std::sqrt(2.0), 0.0);
86  f3p[1][0] = (S_hh - S_vv) / ComplexType(std::sqrt(2.0), 0.0);
87  f3p[2][0] = ComplexType(std::sqrt(2.0), 0.0) * S_hv;
88 
89  VNLMatrixType res = f3p * f3p.conjugate_transpose();
90 
91  result[0] = static_cast<OutputValueType>(res[0][0]);
92  result[1] = static_cast<OutputValueType>(res[0][1]);
93  result[2] = static_cast<OutputValueType>(res[0][2]);
94  result[3] = static_cast<OutputValueType>(res[1][1]);
95  result[4] = static_cast<OutputValueType>(res[1][2]);
96  result[5] = static_cast<OutputValueType>(res[2][2]);
97  }
98 
99  constexpr size_t OutputSize(...) const
100  {
101  // Size of the matrix
102  return 6;
103  }
104 };
105 
106 } // namespace Functor
107 
124 template <typename TInputImage, typename TOutputImage>
126  FunctorImageFilter<Functor::SinclairToReciprocalCoherencyMatrixFunctor<typename TInputImage::PixelType, typename TInputImage::PixelType,
127  typename TInputImage::PixelType, typename TOutputImage::PixelType>,
128  std::tuple<polarimetry_tags::hh, polarimetry_tags::hv_or_vh, polarimetry_tags::vv>>;
130 
131 } // namespace otb
132 
133 #endif
otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor
Construct the reciprocal fully polarimetric coherency matrix with Sinclair matrix information.
Definition: otbSinclairToReciprocalCoherencyMatrixImageFilter.h:70
otbFunctorImageFilter.h
otbMath.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor::VNLMatrixType
vnl_matrix< ComplexType > VNLMatrixType
Definition: otbSinclairToReciprocalCoherencyMatrixImageFilter.h:75
otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor::OutputSize
constexpr vcl_size_t OutputSize(...) const
Definition: otbSinclairToReciprocalCoherencyMatrixImageFilter.h:99
otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor::ComplexType
std::complex< double > ComplexType
Definition: otbSinclairToReciprocalCoherencyMatrixImageFilter.h:74
otb::SinclairToReciprocalCoherencyMatrixImageFilter
FunctorImageFilter< Functor::SinclairToReciprocalCoherencyMatrixFunctor< typename TInputImage::PixelType, typename TInputImage::PixelType, typename TInputImage::PixelType, typename TOutputImage::PixelType >, std::tuple< polarimetry_tags::hh, polarimetry_tags::hv_or_vh, polarimetry_tags::vv > > SinclairToReciprocalCoherencyMatrixImageFilter
Applies otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor.
Definition: otbSinclairToReciprocalCoherencyMatrixImageFilter.h:128
otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor::operator()
void operator()(TOutput &result, const TInput1 &Shh, const TInput2 &Shv, const TInput3 &Svv) const
Definition: otbSinclairToReciprocalCoherencyMatrixImageFilter.h:78
otbPolarimetryTags.h
otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor::OutputValueType
TOutput::ValueType OutputValueType
Definition: otbSinclairToReciprocalCoherencyMatrixImageFilter.h:76