21 #ifndef otbComplexMomentsImageFunction_hxx
22 #define otbComplexMomentsImageFunction_hxx
25 #include "itkConstNeighborhoodIterator.h"
26 #include "itkNumericTraits.h"
34 template <
class TInputImage,
class TCoordRep>
37 m_NeighborhoodRadius = 1;
42 template <
class TInputImage,
class TCoordRep>
45 this->Superclass::PrintSelf(os, indent);
46 os << indent <<
" p indice maximum value : " << m_Pmax << std::endl;
47 os << indent <<
" q indice maximum value : " << m_Qmax << std::endl;
48 os << indent <<
" Neighborhood radius value : " << m_NeighborhoodRadius << std::endl;
51 template <
class TInputImage,
class TCoordRep>
57 moments.resize(m_Pmax + 1);
60 for (
unsigned int p = 0; p <= m_Pmax; p++)
62 moments[p].resize(m_Qmax + 1);
63 for (
unsigned int q = 0; q <= m_Qmax; q++)
70 if (!this->GetInputImage())
76 if (!this->IsInsideBuffer(index))
82 typename InputImageType::SizeType kernelSize;
83 kernelSize.Fill(m_NeighborhoodRadius);
85 itk::ConstNeighborhoodIterator<InputImageType> it(kernelSize, this->GetInputImage(), this->GetInputImage()->GetBufferedRegion());
88 it.SetLocation(index);
91 const unsigned int size = it.Size();
92 for (
unsigned int i = 0; i < size; ++i)
103 for (
unsigned int p = 0; p <= m_Pmax; p++)
105 for (
unsigned int q = 0; q <= m_Qmax; q++)
109 if (p != 0 || x != 0 || y != 0)
111 pow1 = std::pow(xpy,
static_cast<int>(p));
113 if (q != 0 || x != 0 || y != 0)
115 pow2 = std::pow(xqy,
static_cast<int>(q));
118 moments[p][q] += pow1 * pow2 * value;
124 for (
int p = m_Pmax; p >= 0; p--)
126 for (
int q = m_Qmax; q >= 0; q--)
128 moments[p][q] /= moments[0][0];