Orfeo Toolbox  3.16
otbHuPathFunction.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbHuPathFunction_txx
19 #define __otbHuPathFunction_txx
20 
21 #include "otbHuPathFunction.h"
23 #include "itkNumericTraits.h"
24 
25 #include "otbMacro.h"
26 
27 namespace otb
28 {
29 
33 template <class TInputPath, class TOutput, class TPrecision>
36 {
37  m_MomentNumber = -1;
38 }
39 
43 template <class TInputPath, class TOutput, class TPrecision>
44 void
46 ::PrintSelf(std::ostream& os, itk::Indent indent) const
47 {
48  this->Superclass::PrintSelf(os, indent);
49  os << indent << " m_MomentNumber : " << m_MomentNumber << std::endl;
50 }
51 
52 template <class TInputPath, class TOutput, class TPrecision>
55 ::Evaluate(const PathType& path) const
56 {
57  typedef ComplexMomentPathFunction<PathType> FunctionType;
58  typedef typename FunctionType::ComplexType ComplexType;
59 
60  RealType HuValue = 0.;
61  ComplexType HuValueComplex;
62 
63  typename FunctionType::Pointer function = FunctionType::New();
64 
65  function->SetInputPath(this->GetInputPath());
66 
67  switch (m_MomentNumber)
68  {
69  case 1:
70  {
71  ComplexType C11;
72  function->SetP(1);
73  function->SetQ(1);
74  C11 = function->Evaluate();
75  HuValue = C11.real();
76  }
77  break;
78  case 2:
79  {
80  ComplexType C20, C02;
81  function->SetP(2);
82  function->SetQ(0);
83  C20 = function->Evaluate();
84  function->SetP(0);
85  function->SetQ(2);
86  C02 = function->Evaluate();
87 
88  HuValue = vcl_abs(C20 * C02);
89 
90  }
91  break;
92  case 3:
93  {
94  ComplexType C30, C03;
95  function->SetP(3);
96  function->SetQ(0);
97  C30 = function->Evaluate();
98  function->SetP(0);
99  function->SetQ(3);
100  C03 = function->Evaluate();
101 
102  HuValue = vcl_abs(C30 * C03);
103  }
104  break;
105  case 4:
106  {
107  ComplexType C21, C12;
108  function->SetP(2);
109  function->SetQ(1);
110  C21 = function->Evaluate();
111  function->SetP(1);
112  function->SetQ(2);
113  C12 = function->Evaluate();
114 
115  HuValue = vcl_abs(C21 * C12);
116  }
117  break;
118 
119  case 5:
120  {
121  ComplexType C30, C12;
122  function->SetP(3);
123  function->SetQ(0);
124  C30 = function->Evaluate();
125  function->SetP(1);
126  function->SetQ(2);
127  C12 = function->Evaluate();
128 
129  HuValueComplex = C30 * vcl_pow(C12, 3);
130  HuValue = HuValueComplex.real();
131  }
132  break;
133 
134  case 6:
135  {
136  ComplexType C20, C12;
137  function->SetP(2);
138  function->SetQ(0);
139  C20 = function->Evaluate();
140  function->SetP(1);
141  function->SetQ(2);
142  C12 = function->Evaluate();
143 
144  HuValueComplex = C20 * vcl_pow(C12, 2);
145  HuValue = HuValueComplex.real();
146  }
147  break;
148 
149  case 7:
150  {
151  ComplexType C30, C12;
152  function->SetP(3);
153  function->SetQ(0);
154  C30 = function->Evaluate();
155  function->SetP(1);
156  function->SetQ(2);
157  C12 = function->Evaluate();
158 
159  HuValueComplex = C30 * vcl_pow(C12, 3);
160  HuValue = HuValueComplex.imag();
161  }
162  break;
163 
164  default:
165  itkWarningMacro("Hu's invariant parameters are between 1 and 7");
166  }
167 
168  return (static_cast<RealType>(HuValue));
169 
170 }
171 
172 template <class TInputPath, class TOutput, class TPrecision>
175 ::Evaluate() const
176 {
177  if (!this->GetInputPath())
178  {
179  otbMsgDevMacro(<< "Pb with GetInputPath");
180  return static_cast<RealType>(itk::NumericTraits<PrecisionType>::max());
181  }
182 
183  RealType Result = Evaluate(*(this->GetInputPath()));
184 
185  return Result;
186 
187 }
188 
189 } // namespace otb
190 
191 #endif

Generated at Sun May 19 2013 00:26:39 for Orfeo Toolbox with doxygen 1.8.3.1