OTB  6.7.0
Orfeo Toolbox
otbMuellerToPolarisationDegreeAndPowerImageFilter.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 
22 #ifndef otbMuellerToPolarisationDegreeAndPowerImageFilter_h
23 #define otbMuellerToPolarisationDegreeAndPowerImageFilter_h
24 
25 #include "itkNumericTraits.h"
26 #include "itkMatrix.h"
27 #include "itkVector.h"
28 #include "otbMath.h"
29 
30 #include "otbFunctorImageFilter.h"
31 
32 namespace otb
33  {
34 
35 namespace Functor {
36 
82 template< class TInput, class TOutput>
84 {
85 public:
86  typedef typename TOutput::ValueType OutputValueType;
89 
90  inline void operator()(TOutput& result, const TInput& Mueller) const
91  {
92  double P;
93  double deg_pol;
94  double tau;
95  double psi;
98 
99  double l_PowerMin(itk::NumericTraits<double>::max());
100  double l_PowerMax(itk::NumericTraits<double>::min());
101  double l_PolarisationDegreeMin(itk::NumericTraits<double>::max());
102  double l_PolarisationDegreeMax(itk::NumericTraits<double>::min());
103 
104  MuellerMatrixType muellerMatrix;
105  muellerMatrix[0][0] = Mueller[0];
106  muellerMatrix[0][1] = Mueller[1];
107  muellerMatrix[0][2] = Mueller[2];
108  muellerMatrix[0][3] = Mueller[3];
109  muellerMatrix[1][0] = Mueller[4];
110  muellerMatrix[1][1] = Mueller[5];
111  muellerMatrix[1][2] = Mueller[6];
112  muellerMatrix[1][3] = Mueller[7];
113  muellerMatrix[2][0] = Mueller[8];
114  muellerMatrix[2][1] = Mueller[9];
115  muellerMatrix[2][2] = Mueller[10];
116  muellerMatrix[2][3] = Mueller[11];
117  muellerMatrix[3][0] = Mueller[12];
118  muellerMatrix[3][1] = Mueller[13];
119  muellerMatrix[3][2] = Mueller[14];
120  muellerMatrix[3][3] = Mueller[15];
121 
122  tau = -45.0;
123  while (tau < 46.0)
124  {
125  psi = -90.0;
126  while (psi < 91.0)
127  {
128  // Define the incident Stokes vector
129  Si[0] = 1.0;
130  Si[1] = cos(psi * m_PI_90) * cos(tau * m_PI_90);
131  Si[2] = sin(psi * m_PI_90) * cos(tau * m_PI_90);
132  Si[3] = sin(tau * m_PI_90);
133 
134  // Evaluate the received Stokes vector
135  Sr = muellerMatrix * Si;
136 
137  //Evaluate Power and Polarisation degree
138  P = Sr[0];
139 
140  if (P < m_Epsilon)
141  {
142  deg_pol = 0.;
143  }
144  else
145  {
146  deg_pol = std::sqrt(Sr[1] * Sr[1] + Sr[2] * Sr[2] + Sr[3] * Sr[3]) / Sr[0];
147  }
148 
149  if (P > l_PowerMax)
150  {
151  l_PowerMax = P;
152  }
153  else
154  {
155  l_PowerMin = P;
156  }
157 
158  if (deg_pol > l_PolarisationDegreeMax)
159  {
160  l_PolarisationDegreeMax = deg_pol;
161  }
162  else
163  {
164  l_PolarisationDegreeMin = deg_pol;
165  }
166  psi += 5.0;
167  }
168  tau += 5.0;
169  }
170 
171  result[0] = l_PowerMin;
172  result[1] = l_PowerMax;
173  result[2] = l_PolarisationDegreeMin;
174  result[3] = l_PolarisationDegreeMax;
175  }
176 
177  constexpr size_t OutputSize(...) const
178  {
179  // Size of the result
180  return 4;
181  }
182 private:
183  static constexpr double m_Epsilon = 1e-6;
184  static constexpr double m_PI_90 = 2 * CONST_PI_180;
185 };
186 } // namespace Functor
187 
200 template <typename TInputImage, typename TOutputImage>
203 
204 
205 } // end namespace otb
206 
207 #endif
Evaluate the min and max polarisation degree and min and max power from the Mueller image...
constexpr double CONST_PI_180
Definition: otbMath.h:55
A generic functor filter templated by its functor.