CubicBSplineInterpolateImageFunction3D.hxx
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_CubicBSplineInterpolateImageFunction3D_HXX
21 #define MIRTK_CubicBSplineInterpolateImageFunction3D_HXX
22 
23 #include "mirtk/CubicBSplineInterpolateImageFunction3D.h"
24 #include "mirtk/CubicBSplineInterpolateImageFunction.hxx"
25 
26 
27 namespace mirtk {
28 
29 
30 // -----------------------------------------------------------------------------
31 template <class TImage>
34 {
35  this->NumberOfDimensions(3);
36 }
37 
38 // -----------------------------------------------------------------------------
39 template <class TImage>
40 inline typename GenericCubicBSplineInterpolateImageFunction3D<TImage>::VoxelType
42 ::Get(double x, double y, double z, double t) const
43 {
44  return this->Get3D(x, y, z, t);
45 }
46 
47 // -----------------------------------------------------------------------------
48 template <class TImage>
49 inline typename GenericCubicBSplineInterpolateImageFunction3D<TImage>::VoxelType
51 ::GetWithPadding(double x, double y, double z, double t) const
52 {
53  return this->GetWithPadding3D(x, y, z, t);
54 }
55 
56 // -----------------------------------------------------------------------------
57 template <class TImage> template <class TOtherImage>
58 inline typename TOtherImage::VoxelType
60 ::Get(const TOtherImage *coeff, double x, double y, double z, double t) const
61 {
62  return this->Get3D(coeff, x, y, z, t);
63 }
64 
65 // -----------------------------------------------------------------------------
66 template <class TImage> template <class TOtherImage, class TCoefficient>
67 inline typename TCoefficient::VoxelType
69 ::GetWithPadding(const TOtherImage *input, const TCoefficient *coeff,
70  double x, double y, double z, double t) const
71 {
72  return this->GetWithPadding3D(input, coeff, x, y, z, t);
73 }
74 
75 // -----------------------------------------------------------------------------
76 template <class TImage>
77 inline typename GenericCubicBSplineInterpolateImageFunction3D<TImage>::VoxelType
79 ::GetInside(double x, double y, double z, double t) const
80 {
81  // Use faster coefficient iteration than Get3D(Coefficient(), x, y, z, t)
82  return this->GetInside3D(x, y, z, t);
83 }
84 
85 // -----------------------------------------------------------------------------
86 template <class TImage>
87 inline typename GenericCubicBSplineInterpolateImageFunction3D<TImage>::VoxelType
89 ::GetOutside(double x, double y, double z, double t) const
90 {
91  if (this->_InfiniteCoefficient) {
92  return voxel_cast<VoxelType>(Get(this->_InfiniteCoefficient, x, y, z, t));
93  } else {
94  return Get(x, y, z, t);
95  }
96 }
97 
98 // -----------------------------------------------------------------------------
99 template <class TImage>
100 inline typename GenericCubicBSplineInterpolateImageFunction3D<TImage>::VoxelType
102 ::GetWithPaddingInside(double x, double y, double z, double t) const
103 {
104  return voxel_cast<VoxelType>(GetWithPadding(this->Input(), &this->_Coefficient, x, y, z, t));
105 }
106 
107 // -----------------------------------------------------------------------------
108 template <class TImage>
109 inline typename GenericCubicBSplineInterpolateImageFunction3D<TImage>::VoxelType
111 ::GetWithPaddingOutside(double x, double y, double z, double t) const
112 {
113  if (this->Extrapolator() && this->_InfiniteCoefficient) {
114  return voxel_cast<VoxelType>(GetWithPadding(this->Extrapolator(), this->_InfiniteCoefficient, x, y, z, t));
115  } else {
116  return GetWithPadding(x, y, z, t);
117  }
118 }
119 
120 
121 } // namespace mirtk
122 
123 #endif // MIRTK_CubicBSplineInterpolateImageFunction3D_HXX
string Get(const ParameterList &params, string name)
Get parameter value from parameters list.
Definition: Object.h:202
virtual VoxelType GetWithPaddingOutside(double, double, double, double=0) const
virtual VoxelType GetWithPaddingInside(double, double, double, double=0) const
virtual VoxelType GetInside(double, double, double, double=0) const
Definition: IOConfig.h:41
virtual VoxelType GetOutside(double, double, double, double=0) const
Evaluate generic image at an arbitrary location (in pixels)
VoxelType GetWithPadding(double, double, double, double=0) const