OTB  6.7.0
Orfeo Toolbox
otbSinclairToCoherencyMatrixImageFilter.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 #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,
68  class TInput4, class TOutput>
70 {
71 public:
73  typedef double RealType;
74  typedef std::complex <RealType> ComplexType;
75  typedef typename TOutput::ValueType OutputValueType;
76  inline void operator()(TOutput& result, const TInput1& Shh, const TInput2& Shv, const TInput3& Svh, const TInput4& Svv) const
77  {
78  const ComplexType S_hh = static_cast<ComplexType>(Shh);
79  const ComplexType S_hv = static_cast<ComplexType>(Shv);
80  const ComplexType S_vh = static_cast<ComplexType>(Svh);
81  const ComplexType S_vv = static_cast<ComplexType>(Svv);
83 
84  const ComplexType HHPlusVV = S_hh + S_vv;
85  const ComplexType HHMinusVV = S_hh - S_vv;
86  const ComplexType HVPlusVH = S_hv + S_vh;
87  const ComplexType jHVMinusVH = (S_hv - S_vh) * ComplexType(0., 1.);
88 
89  result[0] = static_cast<OutputValueType>( std::norm(HHPlusVV) );
90  result[1] = static_cast<OutputValueType>( HHPlusVV * std::conj(HHMinusVV) );
91  result[2] = static_cast<OutputValueType>( HHPlusVV * std::conj(HVPlusVH) );
92  result[3] = static_cast<OutputValueType>( HHPlusVV * std::conj(jHVMinusVH) );
93  result[4] = static_cast<OutputValueType>( std::norm(HHMinusVV) );
94  result[5] = static_cast<OutputValueType>( HHMinusVV * std::conj(HVPlusVH) );
95  result[6] = static_cast<OutputValueType>( HHMinusVV * std::conj(jHVMinusVH) );
96  result[7] = static_cast<OutputValueType>( std::norm(HVPlusVH) );
97  result[8] = static_cast<OutputValueType>( HVPlusVH * std::conj(jHVMinusVH) );
98  result[9] = static_cast<OutputValueType>( std::norm(jHVMinusVH) );
99 
100  result /= 2.0;
101  }
102 
103  constexpr size_t OutputSize(...) const
104  {
105  // Size of coherency matrix
106  return 10;
107  }
108 
111 
114 };
115 
116 } // namespace Functor
117 
135 template <typename TInputImage, typename TOutputImage>
136 using SinclairToCoherencyMatrixImageFilter = FunctorImageFilter<
137  Functor::SinclairToCoherencyMatrixFunctor<typename TInputImage::PixelType, typename TInputImage::PixelType, typename TInputImage::PixelType,
138  typename TInputImage::PixelType, typename TOutputImage::PixelType>,
139  std::tuple<polarimetry_tags::hh, polarimetry_tags::hv, polarimetry_tags::vh, polarimetry_tags::vv>>;
140 } // namespace otb
142 
143 #endif
Construct the fully polarimetric coherency matrix with Sinclair matrix information.
void operator()(TOutput &result, const TInput1 &Shh, const TInput2 &Shv, const TInput3 &Svh, const TInput4 &Svv) const
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.