OTB  9.0.0
Orfeo Toolbox
otbSinclairToCoherencyMatrixImageFilter.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 otbSinclairToCoherencyMatrixImageFilter_h
22 #define otbSinclairToCoherencyMatrixImageFilter_h
23 
24 #include <complex>
25 #include "otbFunctorImageFilter.h"
26 #include "otbPolarimetryTags.h"
27 
28 namespace otb
29 {
30 namespace Functor
31 {
67 template <class TInput1, class TInput2, class TInput3, class TInput4, class TOutput>
69 {
70 public:
72  typedef double RealType;
73  typedef std::complex<RealType> ComplexType;
74  typedef typename TOutput::ValueType OutputValueType;
75  inline void operator()(TOutput& result, const TInput1& Shh, const TInput2& Shv, const TInput3& Svh, const TInput4& Svv) const
76  {
77  const ComplexType S_hh = static_cast<ComplexType>(Shh);
78  const ComplexType S_hv = static_cast<ComplexType>(Shv);
79  const ComplexType S_vh = static_cast<ComplexType>(Svh);
80  const ComplexType S_vv = static_cast<ComplexType>(Svv);
82 
83  const ComplexType HHPlusVV = S_hh + S_vv;
84  const ComplexType HHMinusVV = S_hh - S_vv;
85  const ComplexType HVPlusVH = S_hv + S_vh;
86  const ComplexType jHVMinusVH = (S_hv - S_vh) * ComplexType(0., 1.);
87 
88  result[0] = static_cast<OutputValueType>(std::norm(HHPlusVV));
89  result[1] = static_cast<OutputValueType>(HHPlusVV * std::conj(HHMinusVV));
90  result[2] = static_cast<OutputValueType>(HHPlusVV * std::conj(HVPlusVH));
91  result[3] = static_cast<OutputValueType>(HHPlusVV * std::conj(jHVMinusVH));
92  result[4] = static_cast<OutputValueType>(std::norm(HHMinusVV));
93  result[5] = static_cast<OutputValueType>(HHMinusVV * std::conj(HVPlusVH));
94  result[6] = static_cast<OutputValueType>(HHMinusVV * std::conj(jHVMinusVH));
95  result[7] = static_cast<OutputValueType>(std::norm(HVPlusVH));
96  result[8] = static_cast<OutputValueType>(HVPlusVH * std::conj(jHVMinusVH));
97  result[9] = static_cast<OutputValueType>(std::norm(jHVMinusVH));
98 
99  result /= 2.0;
100  }
101 
102  constexpr size_t OutputSize(...) const
103  {
104  // Size of coherency matrix
105  return 10;
106  }
107 
110  {
111  }
112 
115  {
116  }
117 };
118 
119 } // namespace Functor
120 
138 template <typename TInputImage, typename TOutputImage>
139 using SinclairToCoherencyMatrixImageFilter = FunctorImageFilter<
140  Functor::SinclairToCoherencyMatrixFunctor<typename TInputImage::PixelType, typename TInputImage::PixelType, typename TInputImage::PixelType,
141  typename TInputImage::PixelType, typename TOutputImage::PixelType>,
142  std::tuple<polarimetry_tags::hh, polarimetry_tags::hv, polarimetry_tags::vh, polarimetry_tags::vv>>;
143 } // namespace otb
145 
146 #endif
otbFunctorImageFilter.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::SinclairToCoherencyMatrixFunctor::ComplexType
std::complex< RealType > ComplexType
Definition: otbSinclairToCoherencyMatrixImageFilter.h:73
otb::Functor::SinclairToCoherencyMatrixFunctor::OutputSize
constexpr vcl_size_t OutputSize(...) const
Definition: otbSinclairToCoherencyMatrixImageFilter.h:102
otb::SinclairToCoherencyMatrixImageFilter
FunctorImageFilter< Functor::SinclairToCoherencyMatrixFunctor< typename TInputImage::PixelType, typename TInputImage::PixelType, typename TInputImage::PixelType, typename TInputImage::PixelType, typename TOutputImage::PixelType >, std::tuple< polarimetry_tags::hh, polarimetry_tags::hv, polarimetry_tags::vh, polarimetry_tags::vv > > SinclairToCoherencyMatrixImageFilter
Applies otb::Functor::SinclairToCoherencyMatrixFunctor.
Definition: otbSinclairToCoherencyMatrixImageFilter.h:142
otb::Functor::SinclairToCoherencyMatrixFunctor::~SinclairToCoherencyMatrixFunctor
virtual ~SinclairToCoherencyMatrixFunctor()
Definition: otbSinclairToCoherencyMatrixImageFilter.h:114
otb::Functor::SinclairToCoherencyMatrixFunctor::SinclairToCoherencyMatrixFunctor
SinclairToCoherencyMatrixFunctor()
Definition: otbSinclairToCoherencyMatrixImageFilter.h:109
otb::Functor::SinclairToCoherencyMatrixFunctor::RealType
double RealType
Definition: otbSinclairToCoherencyMatrixImageFilter.h:72
otb::Functor::SinclairToCoherencyMatrixFunctor
Construct the fully polarimetric coherency matrix with Sinclair matrix information.
Definition: otbSinclairToCoherencyMatrixImageFilter.h:68
otb::Functor::SinclairToCoherencyMatrixFunctor::operator()
void operator()(TOutput &result, const TInput1 &Shh, const TInput2 &Shv, const TInput3 &Svh, const TInput4 &Svv) const
Definition: otbSinclairToCoherencyMatrixImageFilter.h:75
otbPolarimetryTags.h
otb::Functor::SinclairToCoherencyMatrixFunctor::OutputValueType
TOutput::ValueType OutputValueType
Definition: otbSinclairToCoherencyMatrixImageFilter.h:74