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