18 #ifndef __otbSparseWvltToAngleMapperListFilter_txx
19 #define __otbSparseWvltToAngleMapperListFilter_txx
22 #include <vnl/vnl_math.h>
28 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages >
32 this->SetNumberOfRequiredInputs(NumberOfInputImages);
37 this->ProcessObject::SetNthOutput(0, outputPtr.
GetPointer());
39 m_ThresholdValue =
static_cast<ValueType>( 10. );
42 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages >
48 const_cast< InputImageListType * >( img ) );
51 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages >
52 const TInputImageList *
56 if ( i >= this->GetNumberOfInputs() )
65 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages >
73 outputPtr->Set(outputSampleList);
77 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages >
79 ::OutputSampleListType *
88 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages >
90 ::OutputSampleListObjectType *
95 (this->ProcessObject::GetOutput(0) );
98 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages >
103 Superclass::PrintSelf(os, indent);
104 os << indent <<
"Threshold : " << m_ThresholdValue <<
"\n";
107 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages >
113 for (
unsigned int i = 0; i < NumberOfInputImages; ++i )
114 it[i] = this->GetInput(i)->Begin();
121 bool iteratorsNotAtEnd =
true;
122 while ( iteratorsNotAtEnd )
125 for (
unsigned int i = 0; i < NumberOfInputImages; ++i )
128 imgIt[i].GoToBegin();
131 bool localIteratorsNotAtEnd =
true;
132 while ( localIteratorsNotAtEnd )
134 if ( IsToGenerate( imgIt ) )
136 outputList->PushBack( GenerateData( imgIt ) );
139 for (
unsigned int i = 0; i < NumberOfInputImages; ++i )
142 if ( imgIt[i].IsAtEnd() )
143 localIteratorsNotAtEnd =
false;
147 for (
unsigned int i = 0; i < NumberOfInputImages; ++i )
150 if ( it[i] != this->GetInput(i)->End() )
151 iteratorsNotAtEnd =
false;
158 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages >
163 for (
unsigned int i = 0; i < NumberOfInputImages; ++i )
165 if ( it[i].Get() < m_ThresholdValue )
172 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages >
174 ::OutputMeasurementVectorType
178 return FromEuclideanToSphericalSpace( it );
181 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages >
183 ::OutputMeasurementVectorType
190 for (
unsigned int i = 0; i < NumberOfInputImages; ++i )
192 modulus += vcl_pow( static_cast<double>( it[i].Get() ), 2. );
195 modulus = vcl_sqrt( modulus );
200 angle.Fill( static_cast< OutputValueType >( 0. ) );
202 if ( NumberOfInputImages == 2 )
204 if ( it[1].Get() < 0 )
206 angle[0] = vcl_acos( it[0].Get() / modulus );
210 angle[0] = - vcl_acos( it[0].Get() / modulus );
215 for (
unsigned int k = 0; k < angle.Size()-1; ++k )
217 double phase = vcl_acos( it[k].Get() / modulus );
219 modulus *= vcl_sin( phase );
222 if ( modulus < 1e-5 )
224 while ( ++k < angle.Size() )
234 double sign = NumberOfInputImages == 3 ? -1. : 1.;
235 if ( it[ NumberOfInputImages-1 ].Get() < 0 )
237 angle[ angle.Size()-1 ] = sign * vcl_acos( it[ NumberOfInputImages-2 ].Get() / modulus );
241 angle[ angle.Size()-1 ] = - sign * vcl_acos( it[ NumberOfInputImages-2 ].Get() / modulus );