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_LinearInterpolateImageFunction2D_HXX
21 #define MIRTK_LinearInterpolateImageFunction2D_HXX
22 
23 #include "mirtk/LinearInterpolateImageFunction2D.h"
24 #include "mirtk/LinearInterpolateImageFunction.hxx"
25 
26 
27 namespace mirtk {
28 
29 
30 // -----------------------------------------------------------------------------
31 template <class TImage>
32 GenericLinearInterpolateImageFunction2D<TImage>
GenericLinearInterpolateImageFunction2D()33 ::GenericLinearInterpolateImageFunction2D()
34 {
35   this->NumberOfDimensions(2);
36 }
37 
38 // -----------------------------------------------------------------------------
39 template <class TImage>
40 inline typename GenericLinearInterpolateImageFunction2D<TImage>::VoxelType
41 GenericLinearInterpolateImageFunction2D<TImage>
Get(double x,double y,double z,double t) const42 ::Get(double x, double y, double z, double t) const
43 {
44   return this->Get2D(x, y, z, t);
45 }
46 
47 // -----------------------------------------------------------------------------
48 template <class TImage>
49 inline typename GenericLinearInterpolateImageFunction2D<TImage>::VoxelType
50 GenericLinearInterpolateImageFunction2D<TImage>
GetWithPadding(double x,double y,double z,double t) const51 ::GetWithPadding(double x, double y, double z, double t) const
52 {
53   return this->GetWithPadding2D(x, y, z, t);
54 }
55 
56 // -----------------------------------------------------------------------------
57 template <class TImage> template <class TOtherImage>
58 inline typename TOtherImage::VoxelType
59 GenericLinearInterpolateImageFunction2D<TImage>
Get(const TOtherImage * input,double x,double y,double z,double t) const60 ::Get(const TOtherImage *input, double x, double y, double z, double t) const
61 {
62   return this->Get2D(input, x, y, z, t);
63 }
64 
65 // -----------------------------------------------------------------------------
66 template <class TImage> template <class TOtherImage>
67 inline typename TOtherImage::VoxelType
68 GenericLinearInterpolateImageFunction2D<TImage>
GetWithPadding(const TOtherImage * input,double x,double y,double z,double t) const69 ::GetWithPadding(const TOtherImage *input, double x, double y, double z, double t) const
70 {
71   return this->GetWithPadding2D(input, x, y, z, t);
72 }
73 
74 // -----------------------------------------------------------------------------
75 template <class TImage>
76 inline typename GenericLinearInterpolateImageFunction2D<TImage>::VoxelType
77 GenericLinearInterpolateImageFunction2D<TImage>
GetInside(double x,double y,double z,double t) const78 ::GetInside(double x, double y, double z, double t) const
79 {
80   // Use faster pixel access than Get2D(Input(), x, y, z, t), which requires
81   // a 4D array lookup with three indirections instead of a direct 1D lookup
82   return this->GetInside2D(x, y, z, t);
83 }
84 
85 // -----------------------------------------------------------------------------
86 template <class TImage>
87 inline typename GenericLinearInterpolateImageFunction2D<TImage>::VoxelType
88 GenericLinearInterpolateImageFunction2D<TImage>
GetOutside(double x,double y,double z,double t) const89 ::GetOutside(double x, double y, double z, double t) const
90 {
91   if (this->Extrapolator()) {
92     return Get(this->Extrapolator(), x, y, z, t);
93   } else {
94     return Get(x, y, z, t);
95   }
96 }
97 
98 // -----------------------------------------------------------------------------
99 template <class TImage>
100 inline typename GenericLinearInterpolateImageFunction2D<TImage>::VoxelType
101 GenericLinearInterpolateImageFunction2D<TImage>
GetWithPaddingInside(double x,double y,double z,double t) const102 ::GetWithPaddingInside(double x, double y, double z, double t) const
103 {
104   return this->GetWithPadding(this->Input(), x, y, z, t);
105 }
106 
107 // -----------------------------------------------------------------------------
108 template <class TImage>
109 inline typename GenericLinearInterpolateImageFunction2D<TImage>::VoxelType
110 GenericLinearInterpolateImageFunction2D<TImage>
GetWithPaddingOutside(double x,double y,double z,double t) const111 ::GetWithPaddingOutside(double x, double y, double z, double t) const
112 {
113   if (this->Extrapolator()) {
114     return GetWithPadding(this->Extrapolator(), x, y, z, t);
115   } else {
116     return GetWithPadding(x, y, z, t);
117   }
118 }
119 
120 
121 } // namespace mirtk
122 
123 #endif // MIRTK_LinearInterpolateImageFunction2D_HXX
124