OTB  9.0.0
Orfeo Toolbox
otbSinclairToMuellerMatrixImageFilter.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 otbSinclairToMuellerMatrixImageFilter_h
22 #define otbSinclairToMuellerMatrixImageFilter_h
23 
24 #include <complex>
25 #include "otbFunctorImageFilter.h"
26 #include "otbPolarimetryTags.h"
27 
28 namespace otb
29 {
30 namespace Functor
31 {
85 template <class TInput1, class TInput2, class TInput3, class TInput4, class TOutput>
87 {
88 public:
90  typedef typename std::complex<double> ComplexType;
91  typedef typename TOutput::ValueType OutputValueType;
92  typedef double RealType;
93 
94  inline void operator()(TOutput& result, const TInput1& Shh, const TInput2& Shv, const TInput3& Svh, const TInput4& Svv) const
95  {
96  const ComplexType Txx = static_cast<ComplexType>(-Shh);
97  const ComplexType Txy = static_cast<ComplexType>(-Shv);
98  const ComplexType Tyx = static_cast<ComplexType>(Svh);
99  const ComplexType Tyy = static_cast<ComplexType>(Svv);
100 
101  const ComplexType conjTxx = std::conj(Txx);
102  const ComplexType conjTxy = std::conj(Txy);
103  const ComplexType conjTyx = std::conj(Tyx);
104  const ComplexType conjTyy = std::conj(Tyy);
105 
106  result[0] = static_cast<OutputValueType>(0.5 * (std::norm(Txx) + std::norm(Txy) + std::norm(Tyx) + std::norm(Tyy)));
107  result[1] = static_cast<OutputValueType>(0.5 * (std::norm(Txx) - std::norm(Txy) + std::norm(Tyx) - std::norm(Tyy)));
108  result[2] = static_cast<OutputValueType>((Txx * conjTxy + Tyx * conjTyy).real());
109  result[3] = static_cast<OutputValueType>((Txx * conjTxy + Tyx * conjTyy).imag());
110  result[4] = static_cast<OutputValueType>(0.5 * (std::norm(Txx) + std::norm(Txy) - std::norm(Tyx) - std::norm(Tyy)));
111  result[5] = static_cast<OutputValueType>(0.5 * (std::norm(Txx) - std::norm(Txy) - std::norm(Tyx) + std::norm(Tyy)));
112  result[6] = static_cast<OutputValueType>((Txx * conjTxy - Tyx * conjTyy).real());
113  result[7] = static_cast<OutputValueType>((Txx * conjTxy - Tyx * conjTyy).imag());
114  result[8] = static_cast<OutputValueType>((Txx * conjTyx + Txy * conjTyy).real());
115  result[9] = static_cast<OutputValueType>((Txx * conjTyx - Txy * conjTyy).real());
116  result[10] = static_cast<OutputValueType>((Txx * conjTyy + Txy * conjTyx).real());
117  result[11] = static_cast<OutputValueType>((Txx * conjTyy - Txy * conjTyx).imag());
118  result[12] = static_cast<OutputValueType>((conjTxx * Tyx + conjTxy * Tyy).imag());
119  result[13] = static_cast<OutputValueType>((conjTxx * Tyx - conjTxy * Tyy).imag());
120  result[14] = static_cast<OutputValueType>((conjTxx * Tyy + conjTxy * Tyx).imag());
121  result[15] = static_cast<OutputValueType>((Txx * conjTyy - Txy * conjTyx).real());
122  }
123 
124  constexpr size_t OutputSize(...) const
125  {
126  // Size of mueller matrix
127  return 16;
128  }
129 
132  {
133  }
134 
137  {
138  }
139 };
140 
141 } // namespace Functor
142 
160 template <typename TInputImage, typename TOutputImage>
161 using SinclairToMuellerMatrixImageFilter = FunctorImageFilter<
162  Functor::SinclairToMuellerMatrixFunctor<typename TInputImage::PixelType, typename TInputImage::PixelType, typename TInputImage::PixelType,
163  typename TInputImage::PixelType, typename TOutputImage::PixelType>,
164  std::tuple<polarimetry_tags::hh, polarimetry_tags::hv, polarimetry_tags::vh, polarimetry_tags::vv>>;
166 
167 } // namespace otb
168 
169 #endif
otbFunctorImageFilter.h
otb::SinclairToMuellerMatrixImageFilter
FunctorImageFilter< Functor::SinclairToMuellerMatrixFunctor< 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 > > SinclairToMuellerMatrixImageFilter
Applies otb::Functor::SinclairToMuellerMatrixFunctor.
Definition: otbSinclairToMuellerMatrixImageFilter.h:164
otb::Functor::SinclairToMuellerMatrixFunctor::RealType
double RealType
Definition: otbSinclairToMuellerMatrixImageFilter.h:92
otb::Functor::SinclairToMuellerMatrixFunctor::SinclairToMuellerMatrixFunctor
SinclairToMuellerMatrixFunctor()
Definition: otbSinclairToMuellerMatrixImageFilter.h:131
otb::Functor::SinclairToMuellerMatrixFunctor::~SinclairToMuellerMatrixFunctor
virtual ~SinclairToMuellerMatrixFunctor()
Definition: otbSinclairToMuellerMatrixImageFilter.h:136
otb::Functor::SinclairToMuellerMatrixFunctor::operator()
void operator()(TOutput &result, const TInput1 &Shh, const TInput2 &Shv, const TInput3 &Svh, const TInput4 &Svv) const
Definition: otbSinclairToMuellerMatrixImageFilter.h:94
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::SinclairToMuellerMatrixFunctor::ComplexType
std::complex< double > ComplexType
Definition: otbSinclairToMuellerMatrixImageFilter.h:90
otb::Functor::SinclairToMuellerMatrixFunctor::OutputValueType
TOutput::ValueType OutputValueType
Definition: otbSinclairToMuellerMatrixImageFilter.h:91
otb::Functor::SinclairToMuellerMatrixFunctor
Construct Mueller matrix with Sinclair matrix information. Elements of the Mueller matrix are extract...
Definition: otbSinclairToMuellerMatrixImageFilter.h:86
otbPolarimetryTags.h
otb::Functor::SinclairToMuellerMatrixFunctor::OutputSize
constexpr vcl_size_t OutputSize(...) const
Definition: otbSinclairToMuellerMatrixImageFilter.h:124