1 #ifndef __itkBinaryThinningImageFilter3D_h
\r
2 #define __itkBinaryThinningImageFilter3D_h
\r
4 #include <itkNeighborhoodIterator.h>
\r
5 #include <itkImageToImageFilter.h>
\r
6 #include <itkImageRegionIteratorWithIndex.h>
\r
7 #include <itkConstantBoundaryCondition.h>
\r
11 /** \class BinaryThinningImageFilter3D
\r
13 * \brief This filter computes one-pixel-wide skeleton of a 3D input image.
\r
15 * This class is parametrized over the type of the input image
\r
16 * and the type of the output image.
\r
18 * The input is assumed to be a binary image. All non-zero valued voxels
\r
19 * are set to 1 internally to simplify the computation. The filter will
\r
20 * produce a skeleton of the object. The output background values are 0,
\r
21 * and the foreground values are 1.
\r
23 * A 26-neighbourhood configuration is used for the foreground and a
\r
24 * 6-neighbourhood configuration for the background. Thinning is performed
\r
25 * symmetrically in order to guarantee that the skeleton lies medial within
\r
28 * This filter is a parallel thinning algorithm and is an implementation
\r
29 * of the algorithm described in:
\r
31 * T.C. Lee, R.L. Kashyap, and C.N. Chu.
\r
32 * Building skeleton models via 3-D medial surface/axis thinning algorithms.
\r
33 * Computer Vision, Graphics, and Image Processing, 56(6):462--478, 1994.
\r
35 * To do: Make use of multi-threading.
\r
37 * \author Hanno Homann, Oxford University, Wolfson Medical Vision Lab, UK.
\r
39 * \sa MorphologyImageFilter
\r
40 * \ingroup ImageEnhancement MathematicalMorphologyImageFilters
\r
43 template <class TInputImage,class TOutputImage>
\r
44 class BinaryThinningImageFilter3D :
\r
45 public ImageToImageFilter<TInputImage,TOutputImage>
\r
48 /** Standard class typedefs. */
\r
49 typedef BinaryThinningImageFilter3D Self;
\r
50 typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass;
\r
51 typedef SmartPointer<Self> Pointer;
\r
52 typedef SmartPointer<const Self> ConstPointer;
\r
54 /** Method for creation through the object factory */
\r
57 /** Run-time type information (and related methods). */
\r
58 itkTypeMacro( BinaryThinningImageFilter3D, ImageToImageFilter );
\r
60 /** Type for input image. */
\r
61 typedef TInputImage InputImageType;
\r
63 /** Type for output image: Skelenton of the object. */
\r
64 typedef TOutputImage OutputImageType;
\r
66 /** Type for the region of the input image. */
\r
67 typedef typename InputImageType::RegionType RegionType;
\r
69 /** Type for the index of the input image. */
\r
70 typedef typename RegionType::IndexType IndexType;
\r
72 /** Type for the pixel type of the input image. */
\r
73 typedef typename InputImageType::PixelType InputImagePixelType ;
\r
75 /** Type for the pixel type of the input image. */
\r
76 typedef typename OutputImageType::PixelType OutputImagePixelType ;
\r
78 /** Type for the size of the input image. */
\r
79 typedef typename RegionType::SizeType SizeType;
\r
81 /** Pointer Type for input image. */
\r
82 typedef typename InputImageType::ConstPointer InputImagePointer;
\r
84 /** Pointer Type for the output image. */
\r
85 typedef typename OutputImageType::Pointer OutputImagePointer;
\r
87 /** Boundary condition type for the neighborhood iterator */
\r
88 typedef ConstantBoundaryCondition< TInputImage > ConstBoundaryConditionType;
\r
90 /** Neighborhood iterator type */
\r
91 typedef NeighborhoodIterator<TInputImage, ConstBoundaryConditionType> NeighborhoodIteratorType;
\r
93 /** Neighborhood type */
\r
94 typedef typename NeighborhoodIteratorType::NeighborhoodType NeighborhoodType;
\r
96 /** Get Skelenton by thinning image. */
\r
97 OutputImageType * GetThinning(void);
\r
99 /** ImageDimension enumeration */
\r
100 itkStaticConstMacro(InputImageDimension, unsigned int,
\r
101 TInputImage::ImageDimension );
\r
102 itkStaticConstMacro(OutputImageDimension, unsigned int,
\r
103 TOutputImage::ImageDimension );
\r
105 #ifdef ITK_USE_CONCEPT_CHECKING
\r
106 /** Begin concept checking */
\r
107 itkConceptMacro(SameDimensionCheck,
\r
108 (Concept::SameDimension<InputImageDimension, 3>));
\r
109 itkConceptMacro(SameTypeCheck,
\r
110 (Concept::SameType<InputImagePixelType, OutputImagePixelType>));
\r
111 itkConceptMacro(InputAdditiveOperatorsCheck,
\r
112 (Concept::AdditiveOperators<InputImagePixelType>));
\r
113 itkConceptMacro(InputConvertibleToIntCheck,
\r
114 (Concept::Convertible<InputImagePixelType, int>));
\r
115 itkConceptMacro(IntConvertibleToInputCheck,
\r
116 (Concept::Convertible<int, InputImagePixelType>));
\r
117 itkConceptMacro(InputIntComparableCheck,
\r
118 (Concept::Comparable<InputImagePixelType, int>));
\r
119 /** End concept checking */
\r
123 BinaryThinningImageFilter3D();
\r
124 virtual ~BinaryThinningImageFilter3D() {};
\r
125 void PrintSelf(std::ostream& os, Indent indent) const;
\r
127 /** Compute thinning Image. */
\r
128 void GenerateData();
\r
130 /** Prepare data. */
\r
131 void PrepareData();
\r
133 /** Compute thinning Image. */
\r
134 void ComputeThinImage();
\r
136 /** isEulerInvariant [Lee94] */
\r
137 bool isEulerInvariant(NeighborhoodType neighbors, int *LUT);
\r
138 void fillEulerLUT(int *LUT);
\r
139 /** isSimplePoint [Lee94] */
\r
140 bool isSimplePoint(NeighborhoodType neighbors);
\r
141 /** Octree_labeling [Lee94] */
\r
142 void Octree_labeling(int octant, int label, int *cube);
\r
146 BinaryThinningImageFilter3D(const Self&); //purposely not implemented
\r
147 void operator=(const Self&); //purposely not implemented
\r
149 }; // end of BinaryThinningImageFilter3D class
\r
151 } //end namespace itk
\r
153 #ifndef ITK_MANUAL_INSTANTIATION
\r
154 #include "itkBinaryThinningImageFilter3D.txx"
\r