Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkGaussianInterpolateImageFunction.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 /*===================================================================
18 
19 This file is based heavily on a corresponding ITK filter.
20 
21 ===================================================================*/
22 #ifndef __itkGaussianInterpolateImageFunction_h
23 #define __itkGaussianInterpolateImageFunction_h
24 
25 #include "itkInterpolateImageFunction.h"
26 
27 #include "itkConceptChecking.h"
28 #include "itkFixedArray.h"
29 #include "vnl/vnl_erf.h"
30 
31 namespace itk
32 {
33 
48 template <class TInputImage, class TCoordRep = double>
50  public InterpolateImageFunction<TInputImage, TCoordRep>
51 {
52 public:
55  typedef InterpolateImageFunction<TInputImage, TCoordRep> Superclass;
58 
60  itkTypeMacro( GaussianInterpolateImageFunction, InterpolateImageFunction );
61 
63  itkFactorylessNewMacro(Self)
64  itkCloneMacro(Self)
65 
67  itkStaticConstMacro( ImageDimension, unsigned int,
68  TInputImage::ImageDimension );
69 
70 
72  typedef typename Superclass::OutputType OutputType;
73 
75  typedef typename Superclass::InputImageType InputImageType;
76 
78  typedef typename Superclass::RealType RealType;
79 
81  typedef typename Superclass::IndexType IndexType;
82 
84  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
85 
87  typedef FixedArray<RealType,
88  itkGetStaticConstMacro( ImageDimension )> ArrayType;
89 
93  virtual void SetInputImage( const TInputImage *image )
94  {
95  Superclass::SetInputImage( image );
96  this->ComputeBoundingBox();
97  }
98 
102  virtual void SetSigma( const ArrayType s )
103  {
104  itkDebugMacro( "setting Sigma to " << s );
105  if( this->m_Sigma != s )
106  {
107  this->m_Sigma = s;
108  this->ComputeBoundingBox();
109  this->Modified();
110  }
111  }
112  itkGetConstMacro( Sigma, ArrayType );
113  void SetSigma( RealType *s )
114  {
115  ArrayType sigma;
116  for( unsigned int d = 0; d < ImageDimension; d++ )
117  {
118  sigma[d] = s[d];
119  }
120  this->SetSigma( sigma );
121  }
122 
123  virtual void SetAlpha( const RealType a )
124  {
125  itkDebugMacro( "setting Alpha to " << a );
126  if( this->m_Alpha != a )
127  {
128  this->m_Alpha = a;
129  this->ComputeBoundingBox();
130  this->Modified();
131  }
132  }
133  itkGetConstMacro( Alpha, RealType );
134 
135  void SetParameters( RealType *sigma, RealType alpha )
136  {
137  this->SetSigma( sigma );
138  this->SetAlpha( alpha );
139  }
140 
145  const ContinuousIndexType & cindex ) const
146  {
147  return this->EvaluateAtContinuousIndex( cindex, nullptr );
148  }
149 
153  virtual OutputType EvaluateAtContinuousIndex(
154  const ContinuousIndexType &, OutputType * ) const;
155 
156 protected:
159  void PrintSelf( std::ostream& os, Indent indent ) const;
160 
161 private:
162  GaussianInterpolateImageFunction( const Self& ); //purposely not implemented
163  void operator=( const Self& ); //purposely not implemented
164 
165  void ComputeBoundingBox();
166 
167  void ComputeErrorFunctionArray( unsigned int dimension, RealType cindex,
168  vnl_vector<RealType> &erfArray, vnl_vector<RealType> &gerfArray,
169  bool evaluateGradient = false ) const;
170 
171  ArrayType m_Sigma;
172  RealType m_Alpha;
173 
174  ArrayType m_BoundingBoxStart;
175  ArrayType m_BoundingBoxEnd;
176  ArrayType m_ScalingFactor;
177  ArrayType m_CutoffDistance;
178 };
179 
180 } // end namespace itk
181 
182 #ifndef ITK_MANUAL_INSTANTIATION
184 #endif
185 
186 #endif
Evaluates the Gaussian interpolation of an image.
void SetParameters(RealType *sigma, RealType alpha)
virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const
InterpolateImageFunction< TInputImage, TCoordRep > Superclass
FixedArray< RealType, itkGetStaticConstMacro(ImageDimension)> ArrayType