FastLinearImageGradientFunction3D.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_FastLinearImageGradientFunction3D_H
21 #define MIRTK_FastLinearImageGradientFunction3D_H
22 
23 #include "mirtk/BaseImage.h"
24 #include "mirtk/FastLinearImageGradientFunction.h"
25 
26 
27 namespace mirtk {
28 
29 
30 /**
31  * Fast linear interpolation of generic 3D image gradient
32  */
33 template <class TImage>
36 {
38  mirtkGenericGradientInterpolatorTypes(GenericFastLinearImageGradientFunction);
39 
40 public:
41 
42  /// Default constructor
44 
45  /// Get gradient of given image at arbitrary location (in pixels)
46  ///
47  /// This function is used to interpolate the image value at arbitrary
48  /// locations when no extrapolator was set.
49  GradientType Get(double, double, double = 0, double = 0) const;
50 
51  /// Get gradient of given image at arbitrary location (in pixels)
52  ///
53  /// This function is used to only interpolate foreground image values.
54  /// If fully outside the foreground region, the _DefaultValue is returned.
55  GradientType GetWithPadding(double, double, double = 0, double = 0) const;
56 
57  /// Get gradient of given image at arbitrary location (in pixels)
58  ///
59  /// If the location is inside the finite domain of the image, an actual image
60  /// instance can be passed as first argument directly such as an instance of
61  /// GenericImage. Otherwise, an image function which extends the finite
62  /// image domain to an infinite lattice is needed, i.e., an instance of a
63  /// subclass of ExtrapolateImageFunction.
64  template <class TOtherImage>
65  GradientType Get(const TOtherImage *, double, double, double = 0, double = 0) const;
66 
67  /// Get gradient of given image at arbitrary location (in pixels)
68  ///
69  /// This function is used to only interpolate foreground image values.
70  /// If fully outside the foreground region, the _DefaultValue is returned.
71  ///
72  /// If the location is inside the finite domain of the image, an actual image
73  /// instance can be passed as first argument directly such as an instance of
74  /// GenericImage. Otherwise, an image function which extends the finite
75  /// image domain to an infinite lattice is needed, i.e., an instance of a
76  /// subclass of ExtrapolateImageFunction.
77  template <class TOtherImage>
78  GradientType GetWithPadding(const TOtherImage *, double, double, double = 0, double = 0) const;
79 
80  /// Evaluate image gradient without handling boundary conditions
81  ///
82  /// This version is faster than EvaluateOutside, but is only defined inside
83  /// the domain for which all image values required for interpolation are
84  /// defined and thus require no extrapolation of the finite image.
85  virtual GradientType GetInside(double, double, double = 0, double = 0) const;
86 
87  /// Evaluate image gradient at an arbitrary location (in pixels)
88  virtual GradientType GetOutside(double, double, double = 0, double = 0) const;
89 
90  /// Evaluate image gradient without handling boundary conditions
91  ///
92  /// If the location is partially inside the foreground region of the image,
93  /// only the foreground values are interpolated. Otherwise, the _DefaultValue
94  /// is returned.
95  ///
96  /// This version is faster than GetWithPaddingOutside, but is only defined
97  /// inside the domain for which all image values required for interpolation
98  /// are defined and thus require no extrapolation of the finite image.
99  virtual GradientType GetWithPaddingInside(double, double, double = 0, double = 0) const;
100 
101  /// Evaluate image gradient at an arbitrary location (in pixels)
102  ///
103  /// If the location is partially inside the foreground region of the image,
104  /// only the foreground values are interpolated. Otherwise, the _DefaultValue
105  /// is returned.
106  virtual GradientType GetWithPaddingOutside(double, double, double = 0, double = 0) const;
107 
108 };
109 
110 
111 /**
112  * Fast linear interpolation of any 3D image gradient
113  */
116 {
117  mirtkObjectMacro(FastLinearImageGradientFunction3D);
118 
119 public:
120 
121  /// Constructor
123 
124 };
125 
126 
127 } // namespace mirtk
128 
129 #endif // MIRTK_FastLinearImageGradientFunction3D_H
virtual GradientType GetWithPaddingOutside(double, double, double=0, double=0) const
virtual GradientType GetOutside(double, double, double=0, double=0) const
Evaluate image gradient at an arbitrary location (in pixels)
virtual GradientType GetInside(double, double, double=0, double=0) const
GradientType Get(double, double, double=0, double=0) const
Definition: IOConfig.h:41
virtual GradientType GetWithPaddingInside(double, double, double=0, double=0) const
GradientType GetWithPadding(double, double, double=0, double=0) const