LinearImageGradientFunction.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_LinearImageGradientFunction_H
21 #define MIRTK_LinearImageGradientFunction_H
22 
23 #include "mirtk/BaseImage.h"
24 #include "mirtk/ImageGradientFunction.h"
25 #include "mirtk/LinearInterpolateImageFunction.h"
26 
27 
28 namespace mirtk {
29 
30 
31 /**
32  * Linear interpolation of generic image gradient
33  */
34 template <class TImage>
36 : public GenericImageGradientFunction<TImage>
37 {
38  mirtkGenericGradientInterpolatorMacro(
40  Interpolation_Linear
41  );
42 
43 protected:
44 
45  /// Image intensity interpolator
47 
48 public:
49 
50  // ---------------------------------------------------------------------------
51  // Construction/Destruction
52 
53  /// Default constructor
55 
56  /// Destructor
58 
59  /// Initialize interpolation function
60  virtual void Initialize(bool = false);
61 
62  // ---------------------------------------------------------------------------
63  // Domain checks
64 
65  /// Returns interval of discrete image indices whose values are needed for
66  /// interpolation of the image value at a given continuous coordinate
67  virtual void BoundingInterval(double, int &, int &) const;
68 
69  // ---------------------------------------------------------------------------
70  // Evaluation
71 
72  /// Get gradient of given 2D image without handling boundary conditions
73  GradientType GetInside2D(double, double, double = 0, double = 0) const;
74 
75  /// Get gradient of given 2D image without handling boundary conditions
76  ///
77  /// This function is used to only interpolate foreground image values.
78  /// If fully outside the foreground region, the _DefaultValue is returned.
79  GradientType GetWithPaddingInside2D(double, double, double = 0, double = 0) const;
80 
81  /// Get gradient of given 3D image without handling boundary conditions
82  GradientType GetInside3D(double, double, double = 0, double = 0) const;
83 
84  /// Get gradient of given 3D image without handling boundary conditions
85  ///
86  /// This function is used to only interpolate foreground image values.
87  /// If fully outside the foreground region, the _DefaultValue is returned.
88  GradientType GetWithPaddingInside3D(double, double, double = 0, double = 0) const;
89 
90  /// Evaluate generic image gradient without handling boundary conditions
91  ///
92  /// This version is faster than EvaluateOutside, but is only defined inside
93  /// the domain for which all image values required for interpolation are
94  /// defined and thus require no extrapolation of the finite image.
95  virtual GradientType GetInside(double, double, double = 0, double = 0) const;
96 
97  /// Evaluate generic image gradient at an arbitrary location (in pixels)
98  /// \returns Always returns _DefaultValue.
99  virtual GradientType GetOutside(double, double, double = 0, double = 0) const;
100 
101  /// Evaluate generic image gradient without handling boundary conditions
102  virtual GradientType GetWithPaddingInside(double, double, double = 0, double = 0) const;
103 
104  /// Evaluate generic image gradient at an arbitrary location (in pixels)
105  /// \returns Always returns _DefaultValue.
106  virtual GradientType GetWithPaddingOutside(double, double, double = 0, double = 0) const;
107 
108 };
109 
110 
111 /**
112  * Linear interpolation of any scalar image gradient
113  */
115 : public GenericLinearImageGradientFunction<BaseImage>
116 {
117  mirtkObjectMacro(LinearImageGradientFunction);
118 
119 public:
120 
121  /// Constructor
123 
124 };
125 
126 
127 } // namespace mirtk
128 
129 #endif // MIRTK_LinearImageGradientFunction_H
GradientType GetInside3D(double, double, double=0, double=0) const
Get gradient of given 3D image without handling boundary conditions.
virtual GradientType GetWithPaddingInside(double, double, double=0, double=0) const
Evaluate generic image gradient without handling boundary conditions.
virtual GradientType GetInside(double, double, double=0, double=0) const
virtual void Initialize(bool=false)
Initialize interpolation function.
Definition: IOConfig.h:41
GenericLinearInterpolateImageFunction< TImage > _ContinuousImage
Image intensity interpolator.
virtual GradientType GetOutside(double, double, double=0, double=0) const
GradientType GetWithPaddingInside2D(double, double, double=0, double=0) const
virtual void BoundingInterval(double, int &, int &) const
virtual GradientType GetWithPaddingOutside(double, double, double=0, double=0) const
GradientType GetWithPaddingInside3D(double, double, double=0, double=0) const
GradientType GetInside2D(double, double, double=0, double=0) const
Get gradient of given 2D image without handling boundary conditions.