OTB  9.0.0
Orfeo Toolbox
otbFlusserPathFunction.hxx
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 otbFlusserPathFunction_hxx
22 #define otbFlusserPathFunction_hxx
23 
24 #include "otbFlusserPathFunction.h"
26 #include "itkNumericTraits.h"
27 #include "otbMacro.h"
28 
29 namespace otb
30 {
31 
35 template <class TInputPath, class TOutput, class TPrecision>
37 {
38  m_MomentNumber = -1;
39 }
40 
44 template <class TInputPath, class TOutput, class TPrecision>
45 void FlusserPathFunction<TInputPath, TOutput, TPrecision>::PrintSelf(std::ostream& os, itk::Indent indent) const
46 {
47  this->Superclass::PrintSelf(os, indent);
48  os << indent << " m_MomentNumber : " << m_MomentNumber << std::endl;
49 }
51 
52 template <class TInputPath, class TOutput, class TPrecision>
55 {
56  typedef ComplexMomentPathFunction<PathType> FunctionType;
57  typedef typename FunctionType::ComplexType ComplexType;
58 
59  RealType FlusserValue(itk::NumericTraits<RealType>::Zero);
60  ComplexType FlusserValueComplex(itk::NumericTraits<ComplexType>::Zero);
61 
62  typename FunctionType::Pointer function = FunctionType::New();
63 
64  function->SetInputPath(this->GetInputPath());
65 
66  switch (m_MomentNumber)
67  {
68  case 1:
69  {
70  ComplexType C11;
71  function->SetP(1);
72  function->SetQ(1);
73  C11 = function->Evaluate();
74  FlusserValue = C11.real();
75  }
76  break;
77  case 2:
78  {
79  ComplexType C21, C12;
80  function->SetP(2);
81  function->SetQ(1);
82  C21 = function->Evaluate();
83  function->SetP(1);
84  function->SetQ(2);
85  C12 = function->Evaluate();
86 
87  FlusserValue = std::abs(C21 * C12);
88  }
89  break;
90  case 3:
91  {
92  ComplexType C20, C12;
93  function->SetP(2);
94  function->SetQ(0);
95  C20 = function->Evaluate();
96  function->SetP(1);
97  function->SetQ(2);
98  C12 = function->Evaluate();
99  FlusserValueComplex = C20 * std::pow(C12, 2);
100  FlusserValue = FlusserValueComplex.real();
101  }
102  break;
103  case 4:
104  {
105  ComplexType C20, C12;
106  function->SetP(2);
107  function->SetQ(0);
108  C20 = function->Evaluate();
109  function->SetP(1);
110  function->SetQ(2);
111  C12 = function->Evaluate();
112  FlusserValueComplex = C20 * std::pow(C12, 2);
113  FlusserValue = FlusserValueComplex.imag();
114  }
115  break;
116  case 5:
117  {
118  ComplexType C30, C12;
119  function->SetP(3);
120  function->SetQ(0);
121  C30 = function->Evaluate();
122  function->SetP(1);
123  function->SetQ(2);
124  C12 = function->Evaluate();
125 
126  FlusserValueComplex = C30 * std::pow(C12, 3);
127  FlusserValue = FlusserValueComplex.real();
128  }
129  break;
130  case 6:
131  {
132  ComplexType C30, C12;
133  function->SetP(3);
134  function->SetQ(0);
135  C30 = function->Evaluate();
136  function->SetP(1);
137  function->SetQ(2);
138  C12 = function->Evaluate();
139 
140  FlusserValueComplex = C30 * std::pow(C12, 3);
141  FlusserValue = FlusserValueComplex.imag();
142  }
143  break;
144  case 7:
145  {
146  ComplexType C22;
147  function->SetP(2);
148  function->SetQ(2);
149  C22 = function->Evaluate();
150  FlusserValue = C22.real();
151  }
152  break;
153  case 8:
154  {
155  ComplexType C31, C12;
156  function->SetP(3);
157  function->SetQ(1);
158  C31 = function->Evaluate();
159  function->SetP(1);
160  function->SetQ(2);
161  C12 = function->Evaluate();
162  FlusserValueComplex = C31 * std::pow(C12, 2);
163  FlusserValue = FlusserValueComplex.real();
164  }
165  break;
166  case 9:
167  {
168  ComplexType C31, C12;
169  function->SetP(3);
170  function->SetQ(1);
171  C31 = function->Evaluate();
172  function->SetP(1);
173  function->SetQ(2);
174  C12 = function->Evaluate();
175  FlusserValueComplex = C31 * std::pow(C12, 2);
176  FlusserValue = FlusserValueComplex.imag();
177  }
178  break;
179  case 10:
180  {
181  ComplexType C40, C12;
182  function->SetP(4);
183  function->SetQ(0);
184  C40 = function->Evaluate();
185  function->SetP(1);
186  function->SetQ(2);
187  C12 = function->Evaluate();
188  FlusserValueComplex = C40 * std::pow(C12, 4);
189  FlusserValue = FlusserValueComplex.real();
190  }
191  break;
192  case 11:
193  {
194  ComplexType C40, C12;
195  function->SetP(4);
196  function->SetQ(0);
197  C40 = function->Evaluate();
198  function->SetP(1);
199  function->SetQ(2);
200  C12 = function->Evaluate();
201  FlusserValueComplex = C40 * std::pow(C12, 4);
202  FlusserValue = FlusserValueComplex.imag();
203  }
204  break;
205 
206  default:
207  itkWarningMacro("Flusser's invariant parameters are between 1 and 11");
208  }
209 
210  return (static_cast<RealType>(FlusserValue));
211 }
212 
213 template <class TInputPath, class TOutput, class TPrecision>
215 {
216  if (!this->GetInputPath())
217  {
218  otbMsgDevMacro(<< "Pb with GetInputPath");
219  return static_cast<RealType>(itk::NumericTraits<PrecisionType>::max());
220  }
221 
222  RealType Result = Evaluate(*(this->GetInputPath()));
223 
224  return Result;
225 }
226 
227 } // namespace otb
228 
229 #endif
otb::FlusserPathFunction::RealType
Superclass::RealType RealType
Definition: otbFlusserPathFunction.h:88
otbComplexMomentPathFunction.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbFlusserPathFunction.h
otbMacro.h
otb::FlusserPathFunction::Evaluate
virtual RealType Evaluate() const
Definition: otbFlusserPathFunction.hxx:214
otb::ComplexMomentPathFunction
Calculate the complex moment value over a path.
Definition: otbComplexMomentPathFunction.h:54
otbMsgDevMacro
#define otbMsgDevMacro(x)
Definition: otbMacro.h:64
otb::FlusserPathFunction::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbFlusserPathFunction.hxx:45
otb::FlusserPathFunction::PathType
Superclass::PathType PathType
Definition: otbFlusserPathFunction.h:79
otb::FlusserPathFunction::FlusserPathFunction
FlusserPathFunction()
Definition: otbFlusserPathFunction.hxx:36