OTB  9.0.0
Orfeo Toolbox
otbRadiometricMomentsImageFunction.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbRadiometricMomentsImageFunction_hxx
22 #define otbRadiometricMomentsImageFunction_hxx
23 
25 #include "itkMacro.h"
26 #include "itkVariableLengthVector.h"
27 #include <complex>
28 
29 namespace otb
30 {
31 
35 template <class TInputImage, class TCoordRep>
37 {
38  m_NeighborhoodRadius = 1;
39 }
40 
41 template <class TInputImage, class TCoordRep>
42 void RadiometricMomentsImageFunction<TInputImage, TCoordRep>::PrintSelf(std::ostream& os, itk::Indent indent) const
43 {
44  this->Superclass::PrintSelf(os, indent);
45  os << indent << " Neighborhood radius value : " << m_NeighborhoodRadius << std::endl;
46 }
47 
48 template <class TInputImage, class TCoordRep>
51 {
52  // Build moments vector
53  OutputType moments;
54 
55  // Initialize moments
56  moments.Fill(itk::NumericTraits<ScalarRealType>::Zero);
57 
58  // Check for input image
59  if (!this->GetInputImage())
60  {
61  return moments;
62  }
63 
64  // Check for out of buffer
65  // Self* _this = const_cast<Self*>(this);
66  //_this->SetInputImage( this->GetInputImage() );
67  if (!this->IsInsideBuffer(index))
68  {
69  return moments;
70  }
71 
72  // Create an N-d neighborhood kernel, using a zeroflux boundary condition
73  typename InputImageType::SizeType kernelSize;
74  kernelSize.Fill(m_NeighborhoodRadius);
75 
76  itk::ConstNeighborhoodIterator<InputImageType> it(kernelSize, this->GetInputImage(), this->GetInputImage()->GetBufferedRegion());
77 
78  // Set the iterator at the desired location
79  it.SetLocation(index);
80 
81  itk::VariableLengthVector<ScalarRealType> tmp(m_Functor(it));
82 
83  for (unsigned int i = 0; i < 4; i++)
84  {
85  moments[i] = tmp[i];
86  }
87 
88  // Return result
89  return moments;
90 }
91 
92 } // namespace otb
93 
94 #endif
otb::RadiometricMomentsImageFunction::RadiometricMomentsImageFunction
RadiometricMomentsImageFunction()
Definition: otbRadiometricMomentsImageFunction.hxx:36
otb::RadiometricMomentsImageFunction::OutputType
Superclass::OutputType OutputType
Definition: otbRadiometricMomentsImageFunction.h:70
otb::RadiometricMomentsImageFunction::EvaluateAtIndex
OutputType EvaluateAtIndex(const IndexType &index) const override
Definition: otbRadiometricMomentsImageFunction.hxx:50
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::RadiometricMomentsImageFunction::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbRadiometricMomentsImageFunction.hxx:42
otb::RadiometricMomentsImageFunction::IndexType
Superclass::IndexType IndexType
Definition: otbRadiometricMomentsImageFunction.h:66
otbRadiometricMomentsImageFunction.h