OTB  10.0.0
Orfeo Toolbox
otbGenericInterpolateImageFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 otbGenericInterpolateImageFunction_h
22 #define otbGenericInterpolateImageFunction_h
23 
24 #include "itkInterpolateImageFunction.h"
25 #include "itkConstNeighborhoodIterator.h"
26 #include "itkConstantBoundaryCondition.h"
27 
28 namespace otb
29 {
30 
43 template <class TInputImage, class TFunction, class TBoundaryCondition = itk::ZeroFluxNeumannBoundaryCondition<TInputImage>, class TCoordRep = double>
44 class ITK_EXPORT GenericInterpolateImageFunction : public itk::InterpolateImageFunction<TInputImage, TCoordRep>
45 {
46 public:
49  typedef itk::InterpolateImageFunction<TInputImage, TCoordRep> Superclass;
50  typedef itk::SmartPointer<Self> Pointer;
51  typedef itk::SmartPointer<const Self> ConstPointer;
52 
54  itkTypeMacro(GenericInterpolateImageFunction, itk::InterpolateImageFunction);
55 
57  itkNewMacro(Self);
58 
60  typedef typename Superclass::OutputType OutputType;
61  typedef typename Superclass::InputImageType InputImageType;
62 
64  // itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
65 
67  typedef typename Superclass::IndexType IndexType;
68  typedef typename InputImageType::SizeType SizeType;
69  typedef typename Superclass::RealType RealType;
70  typedef TFunction FunctionType;
71  typedef itk::ConstNeighborhoodIterator<InputImageType, TBoundaryCondition> IteratorType;
72 
74  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
75 
77  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
78 
87  OutputType EvaluateAtContinuousIndex(const ContinuousIndexType& index) const override;
88 
90  virtual void SetRadius(unsigned int rad);
91  virtual typename itk::InterpolateImageFunction<TInputImage, TCoordRep>::SizeType GetRadius() const
92  {
93  auto rad = m_Function.GetRadius();
94  typename itk::InterpolateImageFunction<TInputImage, TCoordRep>::SizeType size({rad,rad});
95  return size;
96  }
97  // unsigned int GetRadius() { return this->GetFunction().GetRadius(); };
99 
101  // Don't have to be used here, just declared for the inheritance classes.
102  // virtual void SetWindowSize(unsigned int win){ m_WindowSize = win; };
103 
105  virtual FunctionType& GetFunction(void)
106  {
107  return m_Function;
108  }
109 
111  virtual void Initialize();
112 
114  itkSetMacro(NormalizeWeight, bool);
115  itkGetMacro(NormalizeWeight, bool);
117 
118 protected:
121  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
122 
125  void Modified(void) const override;
126 
128  virtual void ResetOffsetTable();
129 
131  virtual void InitializeTables();
132 
134  virtual void FillWeightOffsetTable();
135 
136 private:
138  void operator=(const Self&) = delete;
140  // unsigned int m_Radius;
141  // Constant to store twice the radius
142  unsigned int m_WindowSize;
143 
146 
148  unsigned int m_ImageDimension;
149 
155  mutable unsigned int m_OffsetTableSize;
156 
159  mutable unsigned int* m_OffsetTable;
160 
162  mutable unsigned int** m_WeightOffsetTable;
163 
166 
169 };
170 
171 } // end namespace itk
172 
173 #ifndef OTB_MANUAL_INSTANTIATION
175 #endif
176 
177 #endif
Generic interpolation of an otb::Image.
virtual itk::InterpolateImageFunction< TInputImage, TCoordRep >::SizeType GetRadius() const
itk::InterpolateImageFunction< TInputImage, TCoordRep > Superclass
GenericInterpolateImageFunction(const Self &)=delete
void operator=(const Self &)=delete
itk::ConstNeighborhoodIterator< InputImageType, TBoundaryCondition > IteratorType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.