OTB  9.0.0
Orfeo Toolbox
otbBSplineInterpolateImageFunction.h
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 otbBSplineInterpolateImageFunction_h
22 #define otbBSplineInterpolateImageFunction_h
23 
24 #include <vector>
25 
26 #include "itkInterpolateImageFunction.h"
27 #include "vnl/vnl_matrix.h"
28 
30 #include "itkConceptChecking.h"
31 #include "itkCovariantVector.h"
32 
33 namespace otb
34 {
47 template <class TImageType, class TCoordRep = double, class TCoefficientType = double>
48 class ITK_EXPORT BSplineInterpolateImageFunction : public itk::InterpolateImageFunction<TImageType, TCoordRep>
49 {
50 public:
53  typedef itk::InterpolateImageFunction<TImageType, TCoordRep> Superclass;
54  typedef itk::SmartPointer<Self> Pointer;
55  typedef itk::SmartPointer<const Self> ConstPointer;
56 
58  itkTypeMacro(BSplineInterpolateImageFunction, InterpolateImageFunction);
59 
61  itkNewMacro(Self);
62 
64  typedef typename Superclass::OutputType OutputType;
65 
67  typedef typename Superclass::InputImageType InputImageType;
68 
70  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
71 
73  typedef typename Superclass::IndexType IndexType;
74 
76  typedef typename InputImageType::RegionType RegionType;
77 
79  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
80 
82  typedef typename Superclass::PointType PointType;
83 
85  typedef itk::ImageLinearIteratorWithIndex<TImageType> Iterator;
86 
88  typedef TCoefficientType CoefficientDataType;
89  typedef itk::Image<CoefficientDataType, itkGetStaticConstMacro(ImageDimension)> CoefficientImageType;
90 
94 
103  OutputType EvaluateAtContinuousIndex(const ContinuousIndexType& index) const override;
104 
106  typedef itk::CovariantVector<OutputType, itkGetStaticConstMacro(ImageDimension)> CovariantVectorType;
107 
109  {
110  ContinuousIndexType index;
111  this->GetInputImage()->TransformPhysicalPointToContinuousIndex(point, index);
112  return (this->EvaluateDerivativeAtContinuousIndex(index));
113  }
114 
115  CovariantVectorType EvaluateDerivativeAtContinuousIndex(const ContinuousIndexType& x) const;
116 
119  void SetSplineOrder(unsigned int SplineOrder);
120  itkGetMacro(SplineOrder, int);
122 
124  void SetInputImage(const TImageType* inputData) override;
125 
128  virtual void UpdateCoefficientsFilter(void);
129 
130 protected:
132  ~BSplineInterpolateImageFunction() override = default;
133 
134  void operator=(const Self&) = delete;
135  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
136 
137  // These are needed by the smoothing spline routine.
138  std::vector<CoefficientDataType> m_Scratch; // temp storage for processing of Coefficients
139  typename TImageType::SizeType m_DataLength; // Image size
140  unsigned int m_SplineOrder; // User specified spline order (3rd or cubic is the default)
141 
142  typename CoefficientImageType::ConstPointer m_Coefficients; // Spline coefficients
143 
144 private:
145  BSplineInterpolateImageFunction(const Self&) = delete;
147  void SetInterpolationWeights(const ContinuousIndexType& x, const vnl_matrix<long>& EvaluateIndex, vnl_matrix<double>& weights,
148  unsigned int splineOrder) const;
149 
151  void SetDerivativeWeights(const ContinuousIndexType& x, const vnl_matrix<long>& EvaluateIndex, vnl_matrix<double>& weights, unsigned int splineOrder) const;
152 
155  void GeneratePointsToIndex();
156 
158  void DetermineRegionOfSupport(vnl_matrix<long>& evaluateIndex, const ContinuousIndexType& x, unsigned int splineOrder) const;
159 
162  void ApplyMirrorBoundaryConditions(vnl_matrix<long>& evaluateIndex, unsigned int splineOrder) const;
163 
164  Iterator m_CIterator; // Iterator for traversing spline coefficients.
165  unsigned long m_MaxNumberInterpolationPoints; // number of neighborhood points used for interpolation
166  std::vector<IndexType> m_PointsToIndex; // Preallocation of interpolation neighborhood indices
167 
169 
171 };
172 
173 } // namespace otb
174 
175 #ifndef OTB_MANUAL_INSTANTIATION
177 #endif
178 
179 #endif
otb::BSplineInterpolateImageFunction::InputImageType
Superclass::InputImageType InputImageType
Definition: otbBSplineInterpolateImageFunction.h:67
otb::BSplineInterpolateImageFunction
This class is an evolution of the itk::BSplineInterpolateImageFunction to handle huge images with thi...
Definition: otbBSplineInterpolateImageFunction.h:48
otb::BSplineInterpolateImageFunction::Iterator
itk::ImageLinearIteratorWithIndex< TImageType > Iterator
Definition: otbBSplineInterpolateImageFunction.h:85
otb::BSplineInterpolateImageFunction::m_Coefficients
CoefficientImageType::ConstPointer m_Coefficients
Definition: otbBSplineInterpolateImageFunction.h:142
otb::BSplineInterpolateImageFunction::CoefficientFilter
otb::BSplineDecompositionImageFilter< TImageType, CoefficientImageType > CoefficientFilter
Definition: otbBSplineInterpolateImageFunction.h:92
otb::BSplineInterpolateImageFunction::m_CoefficientFilter
CoefficientFilterPointer m_CoefficientFilter
Definition: otbBSplineInterpolateImageFunction.h:168
otb::BSplineInterpolateImageFunction::CoefficientImageType
itk::Image< CoefficientDataType, itkGetStaticConstMacro(ImageDimension)> CoefficientImageType
Definition: otbBSplineInterpolateImageFunction.h:89
otb::BSplineInterpolateImageFunction::CoefficientDataType
TCoefficientType CoefficientDataType
Definition: otbBSplineInterpolateImageFunction.h:88
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::BSplineInterpolateImageFunction::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbBSplineInterpolateImageFunction.h:54
otb::BSplineInterpolateImageFunction::EvaluateDerivative
CovariantVectorType EvaluateDerivative(const PointType &point) const
Definition: otbBSplineInterpolateImageFunction.h:108
otb::BSplineDecompositionImageFilter
This class is an evolution of the itk::BSplineDecompositionImageFilter to handle huge images with thi...
Definition: otbBSplineDecompositionImageFilter.h:43
otb::BSplineInterpolateImageFunction::m_SplineOrder
unsigned int m_SplineOrder
Definition: otbBSplineInterpolateImageFunction.h:140
otb::BSplineInterpolateImageFunction::CoefficientFilterPointer
CoefficientFilter::Pointer CoefficientFilterPointer
Definition: otbBSplineInterpolateImageFunction.h:93
otbBSplineDecompositionImageFilter.h
otb::BSplineInterpolateImageFunction::m_Scratch
std::vector< CoefficientDataType > m_Scratch
Definition: otbBSplineInterpolateImageFunction.h:138
otb::BSplineInterpolateImageFunction::IndexType
Superclass::IndexType IndexType
Definition: otbBSplineInterpolateImageFunction.h:73
otb::BSplineInterpolateImageFunction::Superclass
itk::InterpolateImageFunction< TImageType, TCoordRep > Superclass
Definition: otbBSplineInterpolateImageFunction.h:53
otb::BSplineInterpolateImageFunction::m_CIterator
Iterator m_CIterator
Definition: otbBSplineInterpolateImageFunction.h:164
otb::BSplineInterpolateImageFunction::m_MaxNumberInterpolationPoints
unsigned long m_MaxNumberInterpolationPoints
Definition: otbBSplineInterpolateImageFunction.h:165
otb::BSplineInterpolateImageFunction::PointType
Superclass::PointType PointType
Definition: otbBSplineInterpolateImageFunction.h:82
otbBSplineInterpolateImageFunction.hxx
otb::BSplineInterpolateImageFunction::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbBSplineInterpolateImageFunction.h:55
otb::BSplineInterpolateImageFunction::Self
BSplineInterpolateImageFunction Self
Definition: otbBSplineInterpolateImageFunction.h:52
otb::BSplineInterpolateImageFunction::OutputType
Superclass::OutputType OutputType
Definition: otbBSplineInterpolateImageFunction.h:61
otb::BSplineInterpolateImageFunction::m_DataLength
TImageType::SizeType m_DataLength
Definition: otbBSplineInterpolateImageFunction.h:139
otb::BSplineInterpolateImageFunction::CovariantVectorType
itk::CovariantVector< OutputType, itkGetStaticConstMacro(ImageDimension)> CovariantVectorType
Definition: otbBSplineInterpolateImageFunction.h:106
otb::BSplineDecompositionImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbBSplineDecompositionImageFilter.h:49
otb::BSplineInterpolateImageFunction::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbBSplineInterpolateImageFunction.h:79
otb::BSplineInterpolateImageFunction::RegionType
InputImageType::RegionType RegionType
Definition: otbBSplineInterpolateImageFunction.h:76
otb::BSplineInterpolateImageFunction::m_CurrentBufferedRegion
RegionType m_CurrentBufferedRegion
Definition: otbBSplineInterpolateImageFunction.h:170
otb::BSplineInterpolateImageFunction::m_PointsToIndex
std::vector< IndexType > m_PointsToIndex
Definition: otbBSplineInterpolateImageFunction.h:166