ITK  5.0.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 
45 template<
46  typename TInputImage,
47  typename TCoordRep = float >
48 class ITK_TEMPLATE_EXPORT VectorCentralDifferenceImageFunction:
49  public ImageFunction< TInputImage,
50  Matrix< double,
51  TInputImage::PixelType::Dimension,
52  TInputImage::ImageDimension >,
53  TCoordRep >
54 {
55 public:
56  ITK_DISALLOW_COPY_AND_ASSIGN(VectorCentralDifferenceImageFunction);
57 
58  using InputPixelType = typename TInputImage::PixelType;
59 
61  static constexpr unsigned int Dimension = InputPixelType::Dimension;
62 
64  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
65 
68  using Superclass = ImageFunction< TInputImage,
69  Matrix< double, Self::Dimension,
70  Self::ImageDimension >,
71  TCoordRep >;
74 
77 
79  itkNewMacro(Self);
80 
82  using InputImageType = TInputImage;
83 
85  using OutputType = typename Superclass::OutputType;
86 
88  using IndexType = typename Superclass::IndexType;
89 
91  using ContinuousIndexType = typename Superclass::ContinuousIndexType;
92 
94  using PointType = typename Superclass::PointType;
95 
103  OutputType EvaluateAtIndex(const IndexType & index) const override;
104 
113  OutputType Evaluate(const PointType & point) const override
114  {
115  IndexType index;
116 
117  this->ConvertPointToNearestIndex(point, index);
118  return this->EvaluateAtIndex(index);
119  }
120 
122  const ContinuousIndexType & cindex) const override
123  {
124  IndexType index;
125 
126  this->ConvertContinuousIndexToNearestIndex(cindex, index);
127  return this->EvaluateAtIndex(index);
128  }
129 
140  itkSetMacro(UseImageDirection, bool);
141  itkGetConstMacro(UseImageDirection, bool);
142  itkBooleanMacro(UseImageDirection);
144 
145 protected:
148  void PrintSelf(std::ostream & os, Indent indent) const override;
149 
150 private:
151  // flag to take or not the image direction into account
152  // when computing the derivatives.
154 };
155 } // end namespace itk
156 
157 #ifndef ITK_MANUAL_INSTANTIATION
158 #include "itkVectorCentralDifferenceImageFunction.hxx"
159 #endif
160 
161 #endif
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:49
Light weight base class for most itk classes.
typename Superclass::ContinuousIndexType ContinuousIndexType
OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Calculate the derivative by central differencing.
Evaluates a function of an image at specified position.
OutputType Evaluate(const PointType &point) const override