ITK  5.4.0
Insight Toolkit
itkGaussianInterpolateImageFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef itkGaussianInterpolateImageFunction_h
20 #define itkGaussianInterpolateImageFunction_h
21 
23 
24 #include "itkConceptChecking.h"
25 #include "itkFixedArray.h"
26 #include "vnl/vnl_erf.h"
27 
28 namespace itk
29 {
30 
53 template <typename TInputImage, typename TCoordRep = double>
54 class ITK_TEMPLATE_EXPORT GaussianInterpolateImageFunction : public InterpolateImageFunction<TInputImage, TCoordRep>
55 {
56 public:
57  ITK_DISALLOW_COPY_AND_MOVE(GaussianInterpolateImageFunction);
58 
64 
66  itkOverrideGetNameOfClassMacro(GaussianInterpolateImageFunction);
67 
69  itkNewMacro(Self);
70 
72  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
73 
74 
76  using typename Superclass::OutputType;
77 
79  using typename Superclass::InputImageType;
80 
82  using typename Superclass::RealType;
83 
85  using typename Superclass::IndexType;
86 
88  using typename Superclass::SizeType;
89 
91  using typename Superclass::ContinuousIndexType;
92 
95 
97  void
98  SetInputImage(const TInputImage * image) override
99  {
100  Superclass::SetInputImage(image);
101  this->ComputeBoundingBox();
102  }
106  virtual void
108  {
109  if (this->m_Sigma != s)
110  {
111  this->m_Sigma = s;
112  this->ComputeBoundingBox();
113  this->Modified();
114  }
115  }
116  virtual void
118  {
119  ArrayType sigma;
120  for (unsigned int d = 0; d < ImageDimension; ++d)
121  {
122  sigma[d] = s[d];
123  }
124  this->SetSigma(sigma);
125  }
126  itkGetConstMacro(Sigma, ArrayType);
130  virtual void
132  {
133  if (Math::NotExactlyEquals(this->m_Alpha, a))
134  {
135  this->m_Alpha = a;
136  this->ComputeBoundingBox();
137  this->Modified();
138  }
139  }
140  itkGetConstMacro(Alpha, RealType);
144  virtual void
146  {
147  this->SetSigma(sigma);
148  this->SetAlpha(alpha);
149  }
153  OutputType
154  EvaluateAtContinuousIndex(const ContinuousIndexType & cindex) const override
155  {
156  return this->EvaluateAtContinuousIndex(cindex, nullptr);
157  }
158 
159  SizeType
160  GetRadius() const override;
161 
162 protected:
164  ~GaussianInterpolateImageFunction() override = default;
165  void
166  PrintSelf(std::ostream & os, Indent indent) const override;
167 
168  virtual void
169  ComputeBoundingBox();
170 
172 
174  RegionType
175  ComputeInterpolationRegion(const ContinuousIndexType &) const;
176 
177  virtual void
178  ComputeErrorFunctionArray(const RegionType & region,
179  unsigned int dimension,
180  RealType cindex,
181  vnl_vector<RealType> & erfArray,
182  vnl_vector<RealType> & gerfArray,
183  bool evaluateGradient = false) const;
184 
186  itkSetMacro(BoundingBoxStart, ArrayType);
187  itkGetConstMacro(BoundingBoxStart, ArrayType);
191  itkSetMacro(BoundingBoxEnd, ArrayType);
192  itkGetConstMacro(BoundingBoxEnd, ArrayType);
196  itkSetMacro(CutOffDistance, ArrayType);
197  itkGetConstMacro(CutOffDistance, ArrayType);
201 private:
203  virtual OutputType
204  EvaluateAtContinuousIndex(const ContinuousIndexType &, OutputType *) const;
205 
206  ArrayType m_Sigma{};
207  RealType m_Alpha{};
208 
209  ArrayType m_BoundingBoxStart{};
210  ArrayType m_BoundingBoxEnd{};
211  ArrayType m_ScalingFactor{};
212  ArrayType m_CutOffDistance{};
213 };
214 
215 } // end namespace itk
216 
217 #ifndef ITK_MANUAL_INSTANTIATION
218 # include "itkGaussianInterpolateImageFunction.hxx"
219 # include "itkMath.h"
220 #endif
221 
222 #endif
itk::GaussianInterpolateImageFunction::SetAlpha
virtual void SetAlpha(const RealType a)
Definition: itkGaussianInterpolateImageFunction.h:131
itk::ImageRegion
An image region represents a structured region of data.
Definition: itkImageRegion.h:80
itkConceptChecking.h
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Math::NotExactlyEquals
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:736
itk::FunctionBase< Point< TCoordRep, TInputImage::ImageDimension >, NumericTraits< TInputImage::PixelType >::RealType >::OutputType
NumericTraits< TInputImage::PixelType >::RealType OutputType
Definition: itkFunctionBase.h:62
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::GaussianInterpolateImageFunction
Evaluates the Gaussian interpolation of an image.
Definition: itkGaussianInterpolateImageFunction.h:54
itkFixedArray.h
itk::GaussianInterpolateImageFunction::SetParameters
virtual void SetParameters(RealType *sigma, RealType alpha)
Definition: itkGaussianInterpolateImageFunction.h:145
itk::FixedArray< RealType, ImageDimension >
itk::GaussianInterpolateImageFunction::SetSigma
virtual void SetSigma(RealType *s)
Definition: itkGaussianInterpolateImageFunction.h:117
itk::GaussianInterpolateImageFunction::SetInputImage
void SetInputImage(const TInputImage *image) override
Definition: itkGaussianInterpolateImageFunction.h:98
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::GaussianInterpolateImageFunction::SetSigma
virtual void SetSigma(const ArrayType s)
Definition: itkGaussianInterpolateImageFunction.h:107
itk::ContinuousIndex< TCoordRep, Self::ImageDimension >
itkInterpolateImageFunction.h
itkMath.h
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:45
itk::GaussianInterpolateImageFunction::EvaluateAtContinuousIndex
OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
Definition: itkGaussianInterpolateImageFunction.h:154
itk::InterpolateImageFunction::RealType
typename NumericTraits< typename TInputImage::PixelType >::RealType RealType
Definition: itkInterpolateImageFunction.h:85