EuclideanDistanceTransform.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2008-2015 Imperial College London
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef MIRTK_EuclideanDistanceTransform_H
20 #define MIRTK_EuclideanDistanceTransform_H
21 
22 #include "mirtk/ImageToImage.h"
23 
24 
25 namespace mirtk {
26 
27 
28 template <class TVoxel>
29 class EuclideanDistanceTransform : public ImageToImage<TVoxel>
30 {
31  mirtkInPlaceImageFilterMacro(EuclideanDistanceTransform, TVoxel);
32 
33 public:
34 
35  /// 2D or 3D distance transform
36  enum Mode { DT_2D, DT_3D };
37 
38 protected:
39 
40  /// 2D or 3D distance transform
41  Mode _distanceTransformMode;
42 
43  /// Calculate the Vornoi diagram
44  int edtVornoiEDT(long *, long);
45 
46  /// Calculate 2D distance transform
47  void edtComputeEDT_2D(char *, long *, long, long);
48 
49  /// Calculate 3D distance transform
50  void edtComputeEDT_3D(char *, long *, long, long, long);
51 
52  /// Calculate the Vornoi diagram for anisotripic voxel sizes
53  int edtVornoiEDT_anisotropic(VoxelType *, long, double);
54 
55  /// Calculate 2D distance transform for anisotripic voxel sizes
56  void edtComputeEDT_2D_anisotropic(const VoxelType *, VoxelType *, long, long, double, double);
57 
58  /// Calculate 3D distance transform for anisotripic voxel sizes
59  void edtComputeEDT_3D_anisotropic(const VoxelType *, VoxelType *, long, long, long, double, double, double);
60 
61 public:
62 
63  /// Default constructor
64  EuclideanDistanceTransform(Mode = DT_3D);
65 
66  /// Destructor (empty).
67  ~EuclideanDistanceTransform() {};
68 
69  // Run distance transform
70  virtual void Run();
71 
72  // Get Radial
73  virtual void Radial();
74 
75  // Get Radial+Thickness
76  virtual void TRadial();
77 };
78 
79 
80 } // namespace mirtk
81 
82 #endif // MIRTK_EuclideanDistanceTransform_H
Definition: IOConfig.h:41
virtual double Run(int, int, int, int=0)
Run filter on single voxel.