21 #ifndef otbFlusserMomentsImageFunction_hxx
22 #define otbFlusserMomentsImageFunction_hxx
25 #include "itkConstNeighborhoodIterator.h"
26 #include "itkNumericTraits.h"
35 template <
class TInputImage,
class TCoordRep>
38 m_NeighborhoodRadius = 1;
41 template <
class TInputImage,
class TCoordRep>
44 this->Superclass::PrintSelf(os, indent);
45 os << indent <<
" Neighborhood radius value : " << m_NeighborhoodRadius << std::endl;
48 template <
class TInputImage,
class TCoordRep>
56 moments.Fill(itk::NumericTraits<ScalarRealType>::Zero);
59 if (!this->GetInputImage())
65 if (!this->IsInsideBuffer(index))
71 typedef std::complex<ScalarRealType> ComplexType;
74 ComplexType c11, c12, c21, c20, c30, c22, c31, c40;
75 c11 = itk::NumericTraits<ComplexType>::Zero;
76 c12 = itk::NumericTraits<ComplexType>::Zero;
77 c21 = itk::NumericTraits<ComplexType>::Zero;
78 c20 = itk::NumericTraits<ComplexType>::Zero;
79 c30 = itk::NumericTraits<ComplexType>::Zero;
80 c22 = itk::NumericTraits<ComplexType>::Zero;
81 c31 = itk::NumericTraits<ComplexType>::Zero;
82 c40 = itk::NumericTraits<ComplexType>::Zero;
87 typename InputImageType::SizeType kernelSize;
88 kernelSize.Fill(m_NeighborhoodRadius);
90 itk::ConstNeighborhoodIterator<InputImageType> it(kernelSize, this->GetInputImage(), this->GetInputImage()->GetBufferedRegion());
93 it.SetLocation(index);
96 const unsigned int size = it.Size();
97 for (
unsigned int i = 0; i < size; ++i)
105 ComplexType xpy(x, y), xqy(x, -y);
109 c11 += xpy * xqy * value;
110 c12 += xpy * xqy * xqy * value;
111 c21 += xpy * xpy * xqy * value;
112 c20 += xpy * xpy * value;
113 c30 += xpy * xpy * xpy * value;
114 c22 += xpy * xpy * xqy * xqy * value;
115 c31 += xpy * xpy * xpy * xqy * value;
116 c40 += xpy * xpy * xpy * xpy * value;
132 moments[2] =
static_cast<ScalarRealType>((c20 * c12 * c12).real());
133 moments[3] =
static_cast<ScalarRealType>((c20 * c12 * c12).imag());
134 moments[4] =
static_cast<ScalarRealType>((c30 * c12 * c12 * c12).real());
135 moments[5] =
static_cast<ScalarRealType>((c30 * c12 * c12 * c12).imag());
137 moments[7] =
static_cast<ScalarRealType>((c31 * c12 * c12).real());
138 moments[8] =
static_cast<ScalarRealType>((c31 * c12 * c12).imag());
139 moments[9] =
static_cast<ScalarRealType>((c40 * c12 * c12 * c12 * c12).real());
140 moments[10] =
static_cast<ScalarRealType>((c40 * c12 * c12 * c12 * c12).imag());