OTB  6.7.0
Orfeo Toolbox
otbSinclairToCovarianceMatrixImageFilter.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 otbSinclairToCovarianceMatrixImageFilter_h
22 #define otbSinclairToCovarianceMatrixImageFilter_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 typename std::complex <double> 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  result[0] = static_cast<OutputValueType>( std::norm(S_hh) );
84  result[1] = static_cast<OutputValueType>( S_hh*std::conj(S_hv) );
85  result[2] = static_cast<OutputValueType>( S_hh*std::conj(S_vh) );
86  result[3] = static_cast<OutputValueType>( S_hh*std::conj(S_vv) );
87  result[4] = static_cast<OutputValueType>( std::norm(S_hv) );
88  result[5] = static_cast<OutputValueType>( S_hv*std::conj(S_vh) );
89  result[6] = static_cast<OutputValueType>( S_hv*std::conj(S_vv) );
90  result[7] = static_cast<OutputValueType>( std::norm(S_vh) );
91  result[8] = static_cast<OutputValueType>( S_vh*std::conj(S_vv) );
92  result[9] = static_cast<OutputValueType>( std::norm(S_vv) );
93  }
94 
95  constexpr size_t OutputSize(...) const
96  {
97  // Number of components in the covariance matrix
98  return 10;
99  }
100 };
101 } // namespace Functor
102 
120 template <typename TInputImage, typename TOutputImage>
121 using SinclairToCovarianceMatrixImageFilter = FunctorImageFilter<
122  Functor::SinclairToCovarianceMatrixFunctor<typename TInputImage::PixelType, typename TInputImage::PixelType, typename TInputImage::PixelType,
123  typename TInputImage::PixelType, typename TOutputImage::PixelType>,
124  std::tuple<polarimetry_tags::hh, polarimetry_tags::hv, polarimetry_tags::vh, polarimetry_tags::vv>>;
126 
127 } // namespace otb
128 
129 #endif
Construct the fully polarimetric covariance matrix with Sinclair matrix information.
void operator()(TOutput &result, const TInput1 &Shh, const TInput2 &Shv, const TInput3 &Svh, const TInput4 &Svv) const
FunctorImageFilter< Functor::SinclairToCovarianceMatrixFunctor< 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 >> SinclairToCovarianceMatrixImageFilter
Applies otb::Functor::SinclairToCovarianceMatrixFunctor.