NearestNeighborExtrapolateImageFunction.h
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_NearestNeighorExtrapolateImageFunction_H
21 #define MIRTK_NearestNeighorExtrapolateImageFunction_H
22 
23 #include "mirtk/ExtrapolateImageFunction.h"
24 #include "mirtk/BaseImage.h"
25 
26 
27 namespace mirtk {
28 
29 
30 /**
31  * Nearest neighbor extrapolation of generic image
32  *
33  * The nearest neighor extrapolation of a discrete image corresponds to a
34  * Neumann boundary condition with the derivative value outside the image domain
35  * set to zero.
36  */
37 template <class TImage>
39 : public IndexExtrapolateImageFunction<TImage>
40 {
41  mirtkExtrapolatorMacro(
43  Extrapolation_NN
44  );
45 
46 public:
47 
48  /// Constructor
50 
51  /// Destructor
53 
54  /// Transform index such that it is inside the range [0, max]
55  virtual void TransformIndex(int &index, int max) const
56  {
57  if (index < 0 ) index = 0;
58  else if (index > max) index = max;
59  }
60 
61 };
62 
63 
64 /**
65  * Nearest neighbor extrapolation of any image
66  *
67  * The nearest neighor extrapolation of a discrete image corresponds to a
68  * Neumann boundary condition with the derivative value outside the image domain
69  * set to zero.
70  */
73 {
75 
76 public:
77 
78  /// Constructor
80 
81  /// Destructor
83 
84 };
85 
86 
87 } // namespace mirtk
88 
89 #endif // MIRTK_NearestNeighorExtrapolateImageFunction_H
Definition: IOConfig.h:41
virtual void TransformIndex(int &index, int max) const
Transform index such that it is inside the range [0, max].