ITK  5.2.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  * http://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_ASSIGN(GaussianInterpolateImageFunction);
58 
64 
67 
69  itkNewMacro(Self);
70 
72  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
73 
74 
76  using OutputType = typename Superclass::OutputType;
77 
79  using InputImageType = typename Superclass::InputImageType;
80 
82  using RealType = typename Superclass::RealType;
83 
85  using IndexType = typename Superclass::IndexType;
86 
88  using SizeType = typename Superclass::SizeType;
89 
91  using ContinuousIndexType = typename Superclass::ContinuousIndexType;
92 
95 
97  void
98  SetInputImage(const TInputImage * image) override
99  {
100  Superclass::SetInputImage(image);
101  this->ComputeBoundingBox();
102  }
104 
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);
128 
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);
142 
144  virtual void
146  {
147  this->SetSigma(sigma);
148  this->SetAlpha(alpha);
149  }
151 
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);
189 
191  itkSetMacro(BoundingBoxEnd, ArrayType);
192  itkGetConstMacro(BoundingBoxEnd, ArrayType);
194 
196  itkSetMacro(CutOffDistance, ArrayType);
197  itkGetConstMacro(CutOffDistance, ArrayType);
199 
200 
201 private:
203  virtual OutputType
204  EvaluateAtContinuousIndex(const ContinuousIndexType &, OutputType *) const;
205 
208 
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::m_BoundingBoxStart
ArrayType m_BoundingBoxStart
Definition: itkGaussianInterpolateImageFunction.h:209
itk::GaussianInterpolateImageFunction::m_BoundingBoxEnd
ArrayType m_BoundingBoxEnd
Definition: itkGaussianInterpolateImageFunction.h:210
itk::GaussianInterpolateImageFunction::IndexType
typename Superclass::IndexType IndexType
Definition: itkGaussianInterpolateImageFunction.h:85
itk::GaussianInterpolateImageFunction::SetAlpha
virtual void SetAlpha(const RealType a)
Definition: itkGaussianInterpolateImageFunction.h:131
itk::GaussianInterpolateImageFunction::m_Alpha
RealType m_Alpha
Definition: itkGaussianInterpolateImageFunction.h:207
itk::ImageRegion
An image region represents a structured region of data.
Definition: itkImageRegion.h:69
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:733
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:59
itk::GaussianInterpolateImageFunction
Evaluates the Gaussian interpolation of an image.
Definition: itkGaussianInterpolateImageFunction.h:54
itk::GaussianInterpolateImageFunction::m_Sigma
ArrayType m_Sigma
Definition: itkGaussianInterpolateImageFunction.h:206
itkFixedArray.h
itk::GaussianInterpolateImageFunction::SetParameters
virtual void SetParameters(RealType *sigma, RealType alpha)
Definition: itkGaussianInterpolateImageFunction.h:145
itk::GaussianInterpolateImageFunction::m_CutOffDistance
ArrayType m_CutOffDistance
Definition: itkGaussianInterpolateImageFunction.h:212
itk::FixedArray< RealType, ImageDimension >
itk::GaussianInterpolateImageFunction::OutputType
typename Superclass::OutputType OutputType
Definition: itkGaussianInterpolateImageFunction.h:76
itk::GaussianInterpolateImageFunction::RealType
typename Superclass::RealType RealType
Definition: itkGaussianInterpolateImageFunction.h:82
itk::GaussianInterpolateImageFunction::SetSigma
virtual void SetSigma(RealType *s)
Definition: itkGaussianInterpolateImageFunction.h:117
itk::GaussianInterpolateImageFunction::SizeType
typename Superclass::SizeType SizeType
Definition: itkGaussianInterpolateImageFunction.h:88
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::GaussianInterpolateImageFunction::InputImageType
typename Superclass::InputImageType InputImageType
Definition: itkGaussianInterpolateImageFunction.h:79
itk::GaussianInterpolateImageFunction::m_ScalingFactor
ArrayType m_ScalingFactor
Definition: itkGaussianInterpolateImageFunction.h:211
itkInterpolateImageFunction.h
itkMath.h
itk::GaussianInterpolateImageFunction::ContinuousIndexType
typename Superclass::ContinuousIndexType ContinuousIndexType
Definition: itkGaussianInterpolateImageFunction.h:91
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