ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkGaussianInterpolateImageFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 
52 template <typename TInputImage, typename TCoordRep = double>
53 class ITK_TEMPLATE_EXPORT GaussianInterpolateImageFunction :
54  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 ContinuousIndexType = typename Superclass::ContinuousIndexType;
89 
92 
94  void SetInputImage( const TInputImage *image ) override
95  {
96  Superclass::SetInputImage( image );
97  this->ComputeBoundingBox();
98  }
100 
102  virtual void SetSigma( const ArrayType s )
103  {
104  if( this->m_Sigma != s )
105  {
106  this->m_Sigma = s;
107  this->ComputeBoundingBox();
108  this->Modified();
109  }
110  }
111  virtual void SetSigma( RealType *s )
112  {
113  ArrayType sigma;
114  for( unsigned int d = 0; d < ImageDimension; d++ )
115  {
116  sigma[d] = s[d];
117  }
118  this->SetSigma( sigma );
119  }
120  itkGetConstMacro( Sigma, ArrayType );
122 
124  virtual void SetAlpha( const RealType a )
125  {
126  if( Math::NotExactlyEquals(this->m_Alpha, a) )
127  {
128  this->m_Alpha = a;
129  this->ComputeBoundingBox();
130  this->Modified();
131  }
132  }
133  itkGetConstMacro( Alpha, RealType );
135 
137  virtual void SetParameters( RealType *sigma, RealType alpha )
138  {
139  this->SetSigma( sigma );
140  this->SetAlpha( alpha );
141  }
143 
146  const ContinuousIndexType & cindex ) const override
147  {
148  return this->EvaluateAtContinuousIndex( cindex, nullptr );
149  }
150 
151 protected:
153  ~GaussianInterpolateImageFunction() override = default;
154  void PrintSelf( std::ostream& os, Indent indent ) const override;
155 
156  virtual void ComputeBoundingBox();
157 
158  virtual void ComputeErrorFunctionArray( unsigned int dimension, RealType cindex,
159  vnl_vector<RealType> &erfArray, vnl_vector<RealType> &gerfArray,
160  bool evaluateGradient = false ) const;
161 
163  itkSetMacro( BoundingBoxStart, ArrayType );
164  itkGetConstMacro( BoundingBoxStart, ArrayType );
166 
168  itkSetMacro( BoundingBoxEnd, ArrayType );
169  itkGetConstMacro( BoundingBoxEnd, ArrayType );
171 
173  itkSetMacro( CutOffDistance, ArrayType );
174  itkGetConstMacro( CutOffDistance, ArrayType );
176 
177 
178 private:
180  virtual OutputType EvaluateAtContinuousIndex(
181  const ContinuousIndexType &, OutputType * ) const;
182 
185 
190 
191 
192 };
193 
194 } // end namespace itk
195 
196 #ifndef ITK_MANUAL_INSTANTIATION
197 #include "itkGaussianInterpolateImageFunction.hxx"
198 #include "itkMath.h"
199 #endif
200 
201 #endif
typename Superclass::ContinuousIndexType ContinuousIndexType
Light weight base class for most itk classes.
Evaluates the Gaussian interpolation of an image.
virtual void SetParameters(RealType *sigma, RealType alpha)
typename NumericTraits< typename TInputImage::PixelType >::RealType RealType
OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
bool NotExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Definition: itkMath.h:718
void SetInputImage(const TInputImage *image) override
Base class for all image interpolaters.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename Superclass::InputImageType InputImageType