OTB  9.0.0
Orfeo Toolbox
otbSinclairToCovarianceMatrixImageFilter.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 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, class TInput4, class TOutput>
69 {
70 public:
72  typedef typename std::complex<double> ComplexType;
73  typedef typename TOutput::ValueType OutputValueType;
74  inline void operator()(TOutput& result, const TInput1& Shh, const TInput2& Shv, const TInput3& Svh, const TInput4& Svv) const
75  {
76  const ComplexType S_hh = static_cast<ComplexType>(Shh);
77  const ComplexType S_hv = static_cast<ComplexType>(Shv);
78  const ComplexType S_vh = static_cast<ComplexType>(Svh);
79  const ComplexType S_vv = static_cast<ComplexType>(Svv);
81 
82  result[0] = static_cast<OutputValueType>(std::norm(S_hh));
83  result[1] = static_cast<OutputValueType>(S_hh * std::conj(S_hv));
84  result[2] = static_cast<OutputValueType>(S_hh * std::conj(S_vh));
85  result[3] = static_cast<OutputValueType>(S_hh * std::conj(S_vv));
86  result[4] = static_cast<OutputValueType>(std::norm(S_hv));
87  result[5] = static_cast<OutputValueType>(S_hv * std::conj(S_vh));
88  result[6] = static_cast<OutputValueType>(S_hv * std::conj(S_vv));
89  result[7] = static_cast<OutputValueType>(std::norm(S_vh));
90  result[8] = static_cast<OutputValueType>(S_vh * std::conj(S_vv));
91  result[9] = static_cast<OutputValueType>(std::norm(S_vv));
92  }
93 
94  constexpr size_t OutputSize(...) const
95  {
96  // Number of components in the covariance matrix
97  return 10;
98  }
99 };
100 } // namespace Functor
101 
119 template <typename TInputImage, typename TOutputImage>
120 using SinclairToCovarianceMatrixImageFilter = FunctorImageFilter<
121  Functor::SinclairToCovarianceMatrixFunctor<typename TInputImage::PixelType, typename TInputImage::PixelType, typename TInputImage::PixelType,
122  typename TInputImage::PixelType, typename TOutputImage::PixelType>,
123  std::tuple<polarimetry_tags::hh, polarimetry_tags::hv, polarimetry_tags::vh, polarimetry_tags::vv>>;
125 
126 } // namespace otb
127 
128 #endif
otbFunctorImageFilter.h
otb::Functor::SinclairToCovarianceMatrixFunctor::OutputSize
constexpr vcl_size_t OutputSize(...) const
Definition: otbSinclairToCovarianceMatrixImageFilter.h:94
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::SinclairToCovarianceMatrixFunctor::OutputValueType
TOutput::ValueType OutputValueType
Definition: otbSinclairToCovarianceMatrixImageFilter.h:73
otb::Functor::SinclairToCovarianceMatrixFunctor::ComplexType
std::complex< double > ComplexType
Definition: otbSinclairToCovarianceMatrixImageFilter.h:72
otb::Functor::SinclairToCovarianceMatrixFunctor::operator()
void operator()(TOutput &result, const TInput1 &Shh, const TInput2 &Shv, const TInput3 &Svh, const TInput4 &Svv) const
Definition: otbSinclairToCovarianceMatrixImageFilter.h:74
otb::Functor::SinclairToCovarianceMatrixFunctor
Construct the fully polarimetric covariance matrix with Sinclair matrix information.
Definition: otbSinclairToCovarianceMatrixImageFilter.h:68
otb::SinclairToCovarianceMatrixImageFilter
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.
Definition: otbSinclairToCovarianceMatrixImageFilter.h:123
otbPolarimetryTags.h