1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================*/
18 #ifndef __itkBinaryThinningImageFilter3D_h
19 #define __itkBinaryThinningImageFilter3D_h
21 #include <itkNeighborhoodIterator.h>
22 #include <itkImageToImageFilter.h>
23 #include <itkImageRegionIteratorWithIndex.h>
24 #include <itkConstantBoundaryCondition.h>
28 /** \class BinaryThinningImageFilter3D
30 * \brief This filter computes one-pixel-wide skeleton of a 3D input image.
32 * This class is parametrized over the type of the input image
33 * and the type of the output image.
35 * The input is assumed to be a binary image. All non-zero valued voxels
36 * are set to 1 internally to simplify the computation. The filter will
37 * produce a skeleton of the object. The output background values are 0,
38 * and the foreground values are 1.
40 * A 26-neighbourhood configuration is used for the foreground and a
41 * 6-neighbourhood configuration for the background. Thinning is performed
42 * symmetrically in order to guarantee that the skeleton lies medial within
45 * This filter is a parallel thinning algorithm and is an implementation
46 * of the algorithm described in:
48 * T.C. Lee, R.L. Kashyap, and C.N. Chu.
49 * Building skeleton models via 3-D medial surface/axis thinning algorithms.
50 * Computer Vision, Graphics, and Image Processing, 56(6):462--478, 1994.
52 * To do: Make use of multi-threading.
54 * \author Hanno Homann, Oxford University, Wolfson Medical Vision Lab, UK.
56 * \sa MorphologyImageFilter
57 * \ingroup ImageEnhancement MathematicalMorphologyImageFilters
60 template <class TInputImage,class TOutputImage>
61 class BinaryThinningImageFilter3D :
62 public ImageToImageFilter<TInputImage,TOutputImage>
65 /** Standard class typedefs. */
66 typedef BinaryThinningImageFilter3D Self;
67 typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass;
68 typedef SmartPointer<Self> Pointer;
69 typedef SmartPointer<const Self> ConstPointer;
71 /** Method for creation through the object factory */
74 /** Run-time type information (and related methods). */
75 itkTypeMacro( BinaryThinningImageFilter3D, ImageToImageFilter );
77 /** Type for input image. */
78 typedef TInputImage InputImageType;
80 /** Type for output image: Skelenton of the object. */
81 typedef TOutputImage OutputImageType;
83 /** Type for the region of the input image. */
84 typedef typename InputImageType::RegionType RegionType;
86 /** Type for the index of the input image. */
87 typedef typename RegionType::IndexType IndexType;
89 /** Type for the pixel type of the input image. */
90 typedef typename InputImageType::PixelType InputImagePixelType ;
92 /** Type for the pixel type of the input image. */
93 typedef typename OutputImageType::PixelType OutputImagePixelType ;
95 /** Type for the size of the input image. */
96 typedef typename RegionType::SizeType SizeType;
98 /** Pointer Type for input image. */
99 typedef typename InputImageType::ConstPointer InputImagePointer;
101 /** Pointer Type for the output image. */
102 typedef typename OutputImageType::Pointer OutputImagePointer;
104 /** Boundary condition type for the neighborhood iterator */
105 typedef ConstantBoundaryCondition< TInputImage > ConstBoundaryConditionType;
107 /** Neighborhood iterator type */
108 typedef NeighborhoodIterator<TInputImage, ConstBoundaryConditionType> NeighborhoodIteratorType;
110 /** Neighborhood type */
111 typedef typename NeighborhoodIteratorType::NeighborhoodType NeighborhoodType;
113 /** Get Skelenton by thinning image. */
114 OutputImageType * GetThinning(void);
116 /** ImageDimension enumeration */
117 itkStaticConstMacro(InputImageDimension, unsigned int,
118 TInputImage::ImageDimension );
119 itkStaticConstMacro(OutputImageDimension, unsigned int,
120 TOutputImage::ImageDimension );
122 #ifdef ITK_USE_CONCEPT_CHECKING
123 /** Begin concept checking */
124 itkConceptMacro(SameDimensionCheck,
125 (Concept::SameDimension<InputImageDimension, 3>));
126 itkConceptMacro(SameTypeCheck,
127 (Concept::SameType<InputImagePixelType, OutputImagePixelType>));
128 itkConceptMacro(InputAdditiveOperatorsCheck,
129 (Concept::AdditiveOperators<InputImagePixelType>));
130 itkConceptMacro(InputConvertibleToIntCheck,
131 (Concept::Convertible<InputImagePixelType, int>));
132 itkConceptMacro(IntConvertibleToInputCheck,
133 (Concept::Convertible<int, InputImagePixelType>));
134 itkConceptMacro(InputIntComparableCheck,
135 (Concept::Comparable<InputImagePixelType, int>));
136 /** End concept checking */
140 BinaryThinningImageFilter3D();
141 virtual ~BinaryThinningImageFilter3D() {};
142 void PrintSelf(std::ostream& os, Indent indent) const;
144 /** Compute thinning Image. */
150 /** Compute thinning Image. */
151 void ComputeThinImage();
153 /** isEulerInvariant [Lee94] */
154 bool isEulerInvariant(NeighborhoodType neighbors, int *LUT);
155 void fillEulerLUT(int *LUT);
156 /** isSimplePoint [Lee94] */
157 bool isSimplePoint(NeighborhoodType neighbors);
158 /** Octree_labeling [Lee94] */
159 void Octree_labeling(int octant, int label, int *cube);
163 BinaryThinningImageFilter3D(const Self&); //purposely not implemented
164 void operator=(const Self&); //purposely not implemented
166 }; // end of BinaryThinningImageFilter3D class
168 } //end namespace itk
170 #ifndef ITK_MANUAL_INSTANTIATION
171 #include "itkBinaryThinningImageFilter3D.txx"