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_CSplineInterpolateImageFunction4D_H
21 #define MIRTK_CSplineInterpolateImageFunction4D_H
22 
23 #include "mirtk/CSplineInterpolateImageFunction.h"
24 
25 
26 namespace mirtk {
27 
28 
29 /**
30  * Cubic spline interpolation of generic 4D image
31  */
32 template <class TImage>
33 class GenericCSplineInterpolateImageFunction4D
34 : public GenericCSplineInterpolateImageFunction<TImage>
35 {
36   mirtkObjectMacro(GenericCSplineInterpolateImageFunction4D);
37   mirtkGenericInterpolatorTypes(GenericCSplineInterpolateImageFunction);
38 
39 public:
40 
41   /// Default constructor
42   GenericCSplineInterpolateImageFunction4D();
43 
44   /// Get value 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   VoxelType Get(double, double, double, double) const;
49 
50   /// Get value 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   VoxelType GetWithPadding(double, double, double, double) const;
55 
56   /// Get value 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> typename TOtherImage::VoxelType
64   Get(const TOtherImage *, double, double, double, double) const;
65 
66   /// Get value 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> typename TOtherImage::VoxelType
77   GetWithPadding(const TOtherImage *, double, double, double, double) const;
78 
79   /// Evaluate generic image 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 VoxelType GetInside(double, double, double, double) const;
85 
86   /// Evaluate generic image at an arbitrary location (in pixels)
87   virtual VoxelType GetOutside(double, double, double, double) const;
88 
89   /// Evaluate generic image 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 VoxelType GetWithPaddingInside(double, double, double, double) const;
99 
100   /// Evaluate generic image 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 VoxelType GetWithPaddingOutside(double, double, double, double) const;
106 
107 };
108 
109 /**
110  * Cubic spline interpolation of any 4D image
111  */
112 class CSplineInterpolateImageFunction4D
113 : public GenericCSplineInterpolateImageFunction4D<BaseImage>
114 {
115   mirtkObjectMacro(CSplineInterpolateImageFunction4D);
116 
117 public:
118 
119   /// Constructor
CSplineInterpolateImageFunction4D()120   CSplineInterpolateImageFunction4D() {}
121 
122 };
123 
124 
125 } // namespace mirtk
126 
127 #endif // MIRTK_CSplineInterpolateImageFunction4D_H
128