21 #ifndef otbSparseWvltToAngleMapperListFilter_hxx
22 #define otbSparseWvltToAngleMapperListFilter_hxx
25 #include <vnl/vnl_math.h>
27 #include "itkProgressReporter.h"
32 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages>
35 this->SetNumberOfRequiredInputs(NumberOfInputImages);
38 typename OutputSampleListObjectType::Pointer outputPtr =
static_cast<OutputSampleListObjectType*
>(this->MakeOutput(0).GetPointer());
39 this->ProcessObject::SetNthOutput(0, outputPtr.GetPointer());
41 m_ThresholdValue =
static_cast<ValueType>(10.);
44 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages>
50 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages>
53 if (i >= this->GetNumberOfInputs())
61 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages>
65 typename OutputSampleListObjectType::Pointer outputPtr = OutputSampleListObjectType::New();
67 outputPtr->Set(outputSampleList);
71 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages>
75 typename OutputSampleListObjectType::Pointer dataObjectPointer =
static_cast<OutputSampleListObjectType*
>(this->ProcessObject::GetOutput(0));
79 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages>
86 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages>
89 Superclass::PrintSelf(os, indent);
90 os << indent <<
"Threshold : " << m_ThresholdValue <<
"\n";
93 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages>
97 for (
unsigned int i = 0; i < NumberOfInputImages; ++i)
98 it[i] = this->GetInput(i)->Begin();
103 itk::ProgressReporter progress(
this, 0, this->GetInput(0)->Size());
105 bool iteratorsNotAtEnd =
true;
106 while (iteratorsNotAtEnd)
109 for (
unsigned int i = 0; i < NumberOfInputImages; ++i)
112 imgIt[i].GoToBegin();
115 bool localIteratorsNotAtEnd =
true;
116 while (localIteratorsNotAtEnd)
118 if (IsToGenerate(imgIt))
120 outputList->PushBack(GenerateData(imgIt));
123 for (
unsigned int i = 0; i < NumberOfInputImages; ++i)
126 if (imgIt[i].IsAtEnd())
127 localIteratorsNotAtEnd =
false;
131 for (
unsigned int i = 0; i < NumberOfInputImages; ++i)
134 if (it[i] != this->GetInput(i)->End())
135 iteratorsNotAtEnd =
false;
138 progress.CompletedPixel();
142 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages>
145 for (
unsigned int i = 0; i < NumberOfInputImages; ++i)
147 if (it[i].Get() < m_ThresholdValue)
154 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages>
158 return FromEuclideanToSphericalSpace(it);
161 template <
class TInputImageList,
class TOutputSampleList,
unsigned int VNbInputImages>
168 for (
unsigned int i = 0; i < NumberOfInputImages; ++i)
170 modulus += std::pow(
static_cast<double>(it[i].Get()), 2.);
173 modulus = std::sqrt(modulus);
180 if (NumberOfInputImages == 2)
184 angle[0] = std::acos(it[0].Get() / modulus);
188 angle[0] = -std::acos(it[0].Get() / modulus);
193 for (
unsigned int k = 0; k < angle.Size() - 1; ++k)
195 double phase = std::acos(it[k].Get() / modulus);
197 modulus *= std::sin(phase);
202 while (++k < angle.Size())
212 double sign = NumberOfInputImages == 3 ? -1. : 1.;
213 if (it[NumberOfInputImages - 1].Get() < 0)
215 angle[angle.Size() - 1] = sign * std::acos(it[NumberOfInputImages - 2].Get() / modulus);
219 angle[angle.Size() - 1] = -sign * std::acos(it[NumberOfInputImages - 2].Get() / modulus);