ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkVectorCentralDifferenceImageFunction.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 #ifndef __itkVectorCentralDifferenceImageFunction_h
19 #define __itkVectorCentralDifferenceImageFunction_h
20 
21 #include "itkImageFunction.h"
22 #include "itkMatrix.h"
23 
24 namespace itk
25 {
26 #ifndef __itkVectorInterpolateImageFunction_h
27 
33 template< typename T >
34 struct GetDimension {
35  itkStaticConstMacro(Dimension, int, T::Dimension);
36 };
37 #endif
38 
57 template<
58  class TInputImage,
59  class TCoordRep = float >
61  public ImageFunction< TInputImage,
62  Matrix< double, \
63  ::itk::GetDimension< typename TInputImage::PixelType >::Dimension, \
64  ::itk::GetImageDimension< TInputImage >::ImageDimension >,
65  TCoordRep >
66 {
67 public:
68  typedef typename TInputImage::PixelType InputPixelType;
69 
71  itkStaticConstMacro(Dimension, unsigned int,
72  InputPixelType::Dimension);
73 
75  itkStaticConstMacro(ImageDimension, unsigned int,
76  TInputImage::ImageDimension);
77 
80  typedef ImageFunction< TInputImage,
81  Matrix< double, itkGetStaticConstMacro(Dimension),
82  itkGetStaticConstMacro(ImageDimension) >,
83  TCoordRep > Superclass;
87 
90 
92  itkNewMacro(Self);
93 
95  typedef TInputImage InputImageType;
96 
98  typedef typename Superclass::OutputType OutputType;
99 
101  typedef typename Superclass::IndexType IndexType;
102 
104  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
105 
107  typedef typename Superclass::PointType PointType;
108 
116  virtual OutputType EvaluateAtIndex(const IndexType & index) const;
117 
126  virtual OutputType Evaluate(const PointType & point) const
127  {
128  IndexType index;
129 
130  this->ConvertPointToNearestIndex(point, index);
131  return this->EvaluateAtIndex(index);
132  }
133 
134  virtual OutputType EvaluateAtContinuousIndex(
135  const ContinuousIndexType & cindex) const
136  {
137  IndexType index;
138 
139  this->ConvertContinuousIndexToNearestIndex(cindex, index);
140  return this->EvaluateAtIndex(index);
141  }
142 
153  itkSetMacro(UseImageDirection, bool);
154  itkGetConstMacro(UseImageDirection, bool);
155  itkBooleanMacro(UseImageDirection);
156 protected:
159  void PrintSelf(std::ostream & os, Indent indent) const;
161 
162 private:
163  VectorCentralDifferenceImageFunction(const Self &); //purposely not
164  // implemented
165  void operator=(const Self &); //purposely not
166  // implemented
167 
168  // flag to take or not the image direction into account
169  // when computing the derivatives.
171 };
172 } // end namespace itk
173 
174 #ifndef ITK_MANUAL_INSTANTIATION
175 #include "itkVectorCentralDifferenceImageFunction.hxx"
176 #endif
177 
178 #endif
179