CubicBSplineConvolution.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2017 Imperial College London
5  * Copyright 2017 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_CubicBSplineConvolution_H
21 #define MIRTK_CubicBSplineConvolution_H
22 
23 #include "mirtk/SeparableConvolution.h"
24 
25 
26 namespace mirtk {
27 
28 
29 /**
30  * Convolves image with separable cubic B-spline kernel
31  */
32 template <class TVoxel>
34 {
35  mirtkInPlaceImageFilterMacro(CubicBSplineConvolution, TVoxel);
36 
37 protected:
38 
39  /// Type of convolution kernels
41 
42  /// Radius of cubic B-spline support region along x axis
43  ///
44  /// - r<0: voxel units
45  /// - r=0: no smoothing in x
46  /// - r>0: mm units
47  mirtkAttributeMacro(double, RadiusX);
48 
49  /// Radius of cubic B-spline support region along y axis
50  ///
51  /// - r<0: voxel units
52  /// - r=0: no smoothing in y
53  /// - r>0: mm units
54  mirtkAttributeMacro(double, RadiusY);
55 
56  /// Radius of cubic B-spline support region along z axis
57  ///
58  /// - r<0: voxel units
59  /// - r=0: no smoothing in z
60  /// - r>0: mm units
61  mirtkAttributeMacro(double, RadiusZ);
62 
63  /// Radius of cubic B-spline support region along t axis
64  ///
65  /// - r<0: voxel units
66  /// - r=0: no smoothing in t
67  /// - r>0: mm units
68  mirtkAttributeMacro(double, RadiusT);
69 
70 protected:
71 
72  // Base class setters unused, should not be called by user
73  virtual void KernelX(const KernelType *) {}
74  virtual void KernelY(const KernelType *) {}
75  virtual void KernelZ(const KernelType *) {}
76  virtual void KernelT(const KernelType *) {}
77 
78  // Instantiated cubic B-spline kernels
79  UniquePtr<KernelType> _BSplineKernel[4];
80 
81  /// Initialize 1D cubic B-spline kernel with radius given in voxel units
82  UniquePtr<KernelType> InitializeKernel(double);
83 
84  /// Initialize filter
85  virtual void Initialize();
86 
87 public:
88 
89  /// Constructor
90  CubicBSplineConvolution(double = 2.);
91 
92  /// Constructor
93  CubicBSplineConvolution(double, double, double = 0., double = 0.);
94 
95  /// Destructor
97 
98  /// Set isotropic radius of spatial cubic B-spline support region
99  virtual void Radius(double);
100 
101  /// Set radius of cubic B-spline support region
102  virtual void Radius(double, double, double = 0., double = 0.);
103 
104  /// Kernel size used for a given radius (divided by voxel size)
105  static int KernelSize(double);
106 
107 };
108 
109 
110 } // namespace mirtk
111 
112 #endif // MIRTK_CubicBSplineConvolution_H
UniquePtr< KernelType > InitializeKernel(double)
Initialize 1D cubic B-spline kernel with radius given in voxel units.
virtual void Initialize()
Initialize filter.
virtual void Radius(double)
Set isotropic radius of spatial cubic B-spline support region.
SeparableConvolution< TVoxel >::KernelType KernelType
Type of convolution kernels.
CubicBSplineConvolution(double=2.)
Constructor.
Definition: IOConfig.h:41
static int KernelSize(double)
Kernel size used for a given radius (divided by voxel size)
mirtkAttributeMacro(double, RadiusX)
~CubicBSplineConvolution()
Destructor.