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_SincInterpolateImageFunction3D_H
21 #define MIRTK_SincInterpolateImageFunction3D_H
22 
23 #include "mirtk/SincInterpolateImageFunction.h"
24 #include "mirtk/BaseImage.h"
25 
26 
27 namespace mirtk {
28 
29 
30 /**
31  * Sinc interpolation of generic 3D image
32  */
33 template <class TImage>
34 class GenericSincInterpolateImageFunction3D
35 : public GenericSincInterpolateImageFunction<TImage>
36 {
37   mirtkObjectMacro(GenericSincInterpolateImageFunction3D);
38   mirtkGenericInterpolatorTypes(GenericSincInterpolateImageFunction);
39 
40 public:
41 
42   /// Default constructor
43   GenericSincInterpolateImageFunction3D();
44 
45   /// Get value 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   VoxelType Get(double, double, double, double = 0) const;
50 
51   /// Get value 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   VoxelType GetWithPadding(double, double, double, double = 0) const;
56 
57   /// Get value 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> typename TOtherImage::VoxelType
65   Get(const TOtherImage *, double, double, double, double = 0) const;
66 
67   /// Get value 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> typename TOtherImage::VoxelType
78   GetWithPadding(const TOtherImage *, double, double, double, double = 0) const;
79 
80   /// Evaluate generic image 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 VoxelType GetInside(double, double, double, double = 0) const;
86 
87   /// Evaluate generic image at an arbitrary location (in pixels)
88   virtual VoxelType GetOutside(double, double, double, double = 0) const;
89 
90   /// Evaluate generic image 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 VoxelType GetWithPaddingInside(double, double, double, double = 0) const;
100 
101   /// Evaluate generic image 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 VoxelType GetWithPaddingOutside(double, double, double, double = 0) const;
107 
108 };
109 
110 
111 /**
112  * Sinc interpolation of any 3D image
113  */
114 class SincInterpolateImageFunction3D
115 : public GenericSincInterpolateImageFunction3D<BaseImage>
116 {
117   mirtkObjectMacro(SincInterpolateImageFunction3D);
118 
119 public:
120 
121   /// Constructor
SincInterpolateImageFunction3D()122   SincInterpolateImageFunction3D() {}
123 
124 };
125 
126 
127 } // namespace mirtk
128 
129 #endif // MIRTK_SincInterpolateImageFunction3D_H
130