BSplineInterpolateImageFunction4D.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_BSplineInterpolateImageFunction4D_HXX
21 #define MIRTK_BSplineInterpolateImageFunction4D_HXX
22 
23 #include "mirtk/BSplineInterpolateImageFunction4D.h"
24 #include "mirtk/BSplineInterpolateImageFunction.hxx"
25 
26 
27 namespace mirtk {
28 
29 
30 // -----------------------------------------------------------------------------
31 template <class TImage>
34 {
35  this->NumberOfDimensions(4);
36 }
37 
38 // -----------------------------------------------------------------------------
39 template <class TImage>
40 inline typename GenericBSplineInterpolateImageFunction4D<TImage>::VoxelType
42 ::Get(double x, double y, double z, double t) const
43 {
44  return this->Get4D(x, y, z, t);
45 }
46 
47 // -----------------------------------------------------------------------------
48 template <class TImage>
49 inline typename GenericBSplineInterpolateImageFunction4D<TImage>::VoxelType
51 ::GetWithPadding(double x, double y, double z, double t) const
52 {
53  return this->GetWithPadding4D(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->Get4D(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->GetWithPadding4D(input, coeff, x, y, z, t);
73 }
74 
75 // -----------------------------------------------------------------------------
76 template <class TImage>
77 inline typename GenericBSplineInterpolateImageFunction4D<TImage>::VoxelType
79 ::GetInside(double x, double y, double z, double t) const
80 {
81  return voxel_cast<VoxelType>(Get(&this->_Coefficient, x, y, z, t));
82 }
83 
84 // -----------------------------------------------------------------------------
85 template <class TImage>
86 inline typename GenericBSplineInterpolateImageFunction4D<TImage>::VoxelType
88 ::GetOutside(double x, double y, double z, double t) const
89 {
90  if (this->_InfiniteCoefficient) {
91  return voxel_cast<VoxelType>(Get(this->_InfiniteCoefficient, x, y, z, t));
92  } else {
93  return Get(x, y, z, t);
94  }
95 }
96 
97 // -----------------------------------------------------------------------------
98 template <class TImage>
99 inline typename GenericBSplineInterpolateImageFunction4D<TImage>::VoxelType
101 ::GetWithPaddingInside(double x, double y, double z, double t) const
102 {
103  return voxel_cast<VoxelType>(GetWithPadding(this->Input(), &this->_Coefficient, x, y, z, t));
104 }
105 
106 // -----------------------------------------------------------------------------
107 template <class TImage>
108 inline typename GenericBSplineInterpolateImageFunction4D<TImage>::VoxelType
110 ::GetWithPaddingOutside(double x, double y, double z, double t) const
111 {
112  if (this->Extrapolator() && this->_InfiniteCoefficient) {
113  return voxel_cast<VoxelType>(GetWithPadding(this->Extrapolator(), this->_InfiniteCoefficient, x, y, z, t));
114  } else {
115  return GetWithPadding(x, y, z, t);
116  }
117 }
118 
119 
120 } // namespace mirtk
121 
122 #endif // MIRTK_BSplineInterpolateImageFunction4D_HXX
string Get(const ParameterList &params, string name)
Get parameter value from parameters list.
Definition: Object.h:202
virtual VoxelType GetOutside(double, double, double, double) const
Evaluate generic image at an arbitrary location (in pixels)
VoxelType GetWithPadding(double, double, double, double) const
virtual VoxelType GetWithPaddingInside(double, double, double, double) const
Definition: IOConfig.h:41
virtual VoxelType GetInside(double, double, double, double) const
VoxelType Get(double, double, double, double) const
virtual VoxelType GetWithPaddingOutside(double, double, double, double) const