GaussianBlurring.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2008-2017 Imperial College London
5  * Copyright 2008-2013 Daniel Rueckert, Julia Schnabel
6  * Copyright 2013-2017 Andreas Schuh
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef MIRTK_GaussianBlurring_H
22 #define MIRTK_GaussianBlurring_H
23 
24 #include "mirtk/SeparableConvolution.h"
25 
26 
27 namespace mirtk {
28 
29 
30 /**
31  * Class for Gaussian blurring of images
32  *
33  * This class defines and implements the Gaussian blurring of images. The
34  * blurring is implemented by three successive 1D convolutions with a 1D
35  * Gaussian kernel.
36  *
37  * By default, if one isotropic Gaussian standard deviation is specified,
38  * the first three dimensions of the image are blurred only. Otherwise,
39  * the 1D convolution with a 1D Gaussian kernel is performed only for
40  * dimensions of more than one voxel size and for which a non-zero
41  * standard deviation for the Gaussian kernel has been set.
42  */
43 template <class TVoxel>
44 class GaussianBlurring : public SeparableConvolution<TVoxel>
45 {
46  mirtkInPlaceImageFilterMacro(GaussianBlurring, TVoxel);
47 
48 protected:
49 
50  /// Type of convolution kernels
52 
53  /// Standard deviation of Gaussian kernel in x
54  mirtkAttributeMacro(double, SigmaX);
55 
56  /// Standard deviation of Gaussian kernel in y
57  mirtkAttributeMacro(double, SigmaY);
58 
59  /// Standard deviation of Gaussian kernel in z
60  mirtkAttributeMacro(double, SigmaZ);
61 
62  /// Standard deviation of Gaussian kernel in t
63  mirtkAttributeMacro(double, SigmaT);
64 
65 protected:
66 
67  // Base class setters unused, should not be called by user
68  virtual void KernelX(const KernelType *) {}
69  virtual void KernelY(const KernelType *) {}
70  virtual void KernelZ(const KernelType *) {}
71  virtual void KernelT(const KernelType *) {}
72 
73  // Instantiated Gaussian kernels
74  UniquePtr<KernelType> _GaussianKernel[4];
75 
76  /// Initialize 1D Gaussian kernel with sigma given in voxel units
77  UniquePtr<KernelType> InitializeKernel(double);
78 
79  /// Initialize filter
80  virtual void Initialize();
81 
82 public:
83 
84  /// Constructor
85  GaussianBlurring(double = 1.);
86 
87  /// Constructor
88  GaussianBlurring(double, double, double = 0., double = 0.);
89 
90  /// Destructor
92 
93  /// Set sigma
94  virtual void SetSigma(double);
95 
96  /// Set sigma
97  virtual void SetSigma(double, double, double = 0., double = 0.);
98 
99  /// Kernel size used for a given sigma (divided by voxel size)
100  static int KernelSize(double);
101 
102 };
103 
104 
105 } // namespace mirtk
106 
107 #endif // MIRTK_GaussianBlurring_H
SeparableConvolution< TVoxel >::KernelType KernelType
Type of convolution kernels.
UniquePtr< KernelType > InitializeKernel(double)
Initialize 1D Gaussian kernel with sigma given in voxel units.
virtual void Initialize()
Initialize filter.
static int KernelSize(double)
Kernel size used for a given sigma (divided by voxel size)
Definition: IOConfig.h:41
virtual void SetSigma(double)
Set sigma.
GaussianBlurring(double=1.)
Constructor.
~GaussianBlurring()
Destructor.
mirtkAttributeMacro(double, SigmaX)
Standard deviation of Gaussian kernel in x.