FastCubicBSplineInterpolateImageFunction4D.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_FastCubicBSplineInterpolateImageFunction4D_HXX
21 #define MIRTK_FastCubicBSplineInterpolateImageFunction4D_HXX
22 
23 #include "mirtk/FastCubicBSplineInterpolateImageFunction4D.h"
24 #include "mirtk/FastCubicBSplineInterpolateImageFunction.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 GenericFastCubicBSplineInterpolateImageFunction4D<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 GenericFastCubicBSplineInterpolateImageFunction4D<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 GenericFastCubicBSplineInterpolateImageFunction4D<TImage>::VoxelType
79 ::GetInside(double x, double y, double z, double t) const
80 {
81  // Use faster coefficient iteration than Get4D(Coefficient(), x, y, z, t)
82  return this->GetInside4D(x, y, z, t);
83 }
84 
85 // -----------------------------------------------------------------------------
86 template <class TImage>
87 inline typename GenericFastCubicBSplineInterpolateImageFunction4D<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 GenericFastCubicBSplineInterpolateImageFunction4D<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 GenericFastCubicBSplineInterpolateImageFunction4D<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_FastCubicBSplineInterpolateImageFunction4D_HXX
string Get(const ParameterList &params, string name)
Get parameter value from parameters list.
Definition: Object.h:202
virtual VoxelType GetWithPaddingInside(double, double, double, double) const
virtual VoxelType GetWithPaddingOutside(double, double, double, double) const
virtual VoxelType GetOutside(double, double, double, double) const
Evaluate generic image at an arbitrary location (in pixels)
Definition: IOConfig.h:41