X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FitkBinaryThinningImageFilter3D.h;h=f75d8834683d7dad62019931534913408ec5f96a;hb=69dacfe0651ee24bef0f9e6b41171b9eec96fd2e;hp=7b82278ba6d2b285bfa68eae1a0394655d00c8f9;hpb=021d8fc72f6edbf44b2b63db3a10552df34120ee;p=clitk.git diff --git a/itk/itkBinaryThinningImageFilter3D.h b/itk/itkBinaryThinningImageFilter3D.h index 7b82278..f75d883 100644 --- a/itk/itkBinaryThinningImageFilter3D.h +++ b/itk/itkBinaryThinningImageFilter3D.h @@ -1,157 +1,174 @@ -#ifndef __itkBinaryThinningImageFilter3D_h -#define __itkBinaryThinningImageFilter3D_h - -#include -#include -#include -#include - -namespace itk -{ -/** \class BinaryThinningImageFilter3D -* -* \brief This filter computes one-pixel-wide skeleton of a 3D input image. -* -* This class is parametrized over the type of the input image -* and the type of the output image. -* -* The input is assumed to be a binary image. All non-zero valued voxels -* are set to 1 internally to simplify the computation. The filter will -* produce a skeleton of the object. The output background values are 0, -* and the foreground values are 1. -* -* A 26-neighbourhood configuration is used for the foreground and a -* 6-neighbourhood configuration for the background. Thinning is performed -* symmetrically in order to guarantee that the skeleton lies medial within -* the object. -* -* This filter is a parallel thinning algorithm and is an implementation -* of the algorithm described in: -* -* T.C. Lee, R.L. Kashyap, and C.N. Chu. -* Building skeleton models via 3-D medial surface/axis thinning algorithms. -* Computer Vision, Graphics, and Image Processing, 56(6):462--478, 1994. -* -* To do: Make use of multi-threading. -* -* \author Hanno Homann, Oxford University, Wolfson Medical Vision Lab, UK. -* -* \sa MorphologyImageFilter -* \ingroup ImageEnhancement MathematicalMorphologyImageFilters -*/ - -template -class BinaryThinningImageFilter3D : - public ImageToImageFilter -{ -public: - /** Standard class typedefs. */ - typedef BinaryThinningImageFilter3D Self; - typedef ImageToImageFilter Superclass; - typedef SmartPointer Pointer; - typedef SmartPointer ConstPointer; - - /** Method for creation through the object factory */ - itkNewMacro(Self); - - /** Run-time type information (and related methods). */ - itkTypeMacro( BinaryThinningImageFilter3D, ImageToImageFilter ); - - /** Type for input image. */ - typedef TInputImage InputImageType; - - /** Type for output image: Skelenton of the object. */ - typedef TOutputImage OutputImageType; - - /** Type for the region of the input image. */ - typedef typename InputImageType::RegionType RegionType; - - /** Type for the index of the input image. */ - typedef typename RegionType::IndexType IndexType; - - /** Type for the pixel type of the input image. */ - typedef typename InputImageType::PixelType InputImagePixelType ; - - /** Type for the pixel type of the input image. */ - typedef typename OutputImageType::PixelType OutputImagePixelType ; - - /** Type for the size of the input image. */ - typedef typename RegionType::SizeType SizeType; - - /** Pointer Type for input image. */ - typedef typename InputImageType::ConstPointer InputImagePointer; - - /** Pointer Type for the output image. */ - typedef typename OutputImageType::Pointer OutputImagePointer; - - /** Boundary condition type for the neighborhood iterator */ - typedef ConstantBoundaryCondition< TInputImage > ConstBoundaryConditionType; - - /** Neighborhood iterator type */ - typedef NeighborhoodIterator NeighborhoodIteratorType; - - /** Neighborhood type */ - typedef typename NeighborhoodIteratorType::NeighborhoodType NeighborhoodType; - - /** Get Skelenton by thinning image. */ - OutputImageType * GetThinning(void); - - /** ImageDimension enumeration */ - itkStaticConstMacro(InputImageDimension, unsigned int, - TInputImage::ImageDimension ); - itkStaticConstMacro(OutputImageDimension, unsigned int, - TOutputImage::ImageDimension ); - -#ifdef ITK_USE_CONCEPT_CHECKING - /** Begin concept checking */ - itkConceptMacro(SameDimensionCheck, - (Concept::SameDimension)); - itkConceptMacro(SameTypeCheck, - (Concept::SameType)); - itkConceptMacro(InputAdditiveOperatorsCheck, - (Concept::AdditiveOperators)); - itkConceptMacro(InputConvertibleToIntCheck, - (Concept::Convertible)); - itkConceptMacro(IntConvertibleToInputCheck, - (Concept::Convertible)); - itkConceptMacro(InputIntComparableCheck, - (Concept::Comparable)); - /** End concept checking */ -#endif - -protected: - BinaryThinningImageFilter3D(); - virtual ~BinaryThinningImageFilter3D() {}; - void PrintSelf(std::ostream& os, Indent indent) const; - - /** Compute thinning Image. */ - void GenerateData(); - - /** Prepare data. */ - void PrepareData(); - - /** Compute thinning Image. */ - void ComputeThinImage(); - - /** isEulerInvariant [Lee94] */ - bool isEulerInvariant(NeighborhoodType neighbors, int *LUT); - void fillEulerLUT(int *LUT); - /** isSimplePoint [Lee94] */ - bool isSimplePoint(NeighborhoodType neighbors); - /** Octree_labeling [Lee94] */ - void Octree_labeling(int octant, int label, int *cube); - - -private: - BinaryThinningImageFilter3D(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - -}; // end of BinaryThinningImageFilter3D class - -} //end namespace itk - -#ifndef ITK_MANUAL_INSTANTIATION -#include "itkBinaryThinningImageFilter3D.txx" -#endif - -#endif +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================*/ +#ifndef __itkBinaryThinningImageFilter3D_h +#define __itkBinaryThinningImageFilter3D_h + +#include +#include +#include +#include + +namespace itk +{ +/** \class BinaryThinningImageFilter3D +* +* \brief This filter computes one-pixel-wide skeleton of a 3D input image. +* +* This class is parametrized over the type of the input image +* and the type of the output image. +* +* The input is assumed to be a binary image. All non-zero valued voxels +* are set to 1 internally to simplify the computation. The filter will +* produce a skeleton of the object. The output background values are 0, +* and the foreground values are 1. +* +* A 26-neighbourhood configuration is used for the foreground and a +* 6-neighbourhood configuration for the background. Thinning is performed +* symmetrically in order to guarantee that the skeleton lies medial within +* the object. +* +* This filter is a parallel thinning algorithm and is an implementation +* of the algorithm described in: +* +* T.C. Lee, R.L. Kashyap, and C.N. Chu. +* Building skeleton models via 3-D medial surface/axis thinning algorithms. +* Computer Vision, Graphics, and Image Processing, 56(6):462--478, 1994. +* +* To do: Make use of multi-threading. +* +* \author Hanno Homann, Oxford University, Wolfson Medical Vision Lab, UK. +* +* \sa MorphologyImageFilter +* \ingroup ImageEnhancement MathematicalMorphologyImageFilters +*/ + +template +class BinaryThinningImageFilter3D : + public ImageToImageFilter +{ +public: + /** Standard class typedefs. */ + typedef BinaryThinningImageFilter3D Self; + typedef ImageToImageFilter Superclass; + typedef SmartPointer Pointer; + typedef SmartPointer ConstPointer; + + /** Method for creation through the object factory */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro( BinaryThinningImageFilter3D, ImageToImageFilter ); + + /** Type for input image. */ + typedef TInputImage InputImageType; + + /** Type for output image: Skelenton of the object. */ + typedef TOutputImage OutputImageType; + + /** Type for the region of the input image. */ + typedef typename InputImageType::RegionType RegionType; + + /** Type for the index of the input image. */ + typedef typename RegionType::IndexType IndexType; + + /** Type for the pixel type of the input image. */ + typedef typename InputImageType::PixelType InputImagePixelType ; + + /** Type for the pixel type of the input image. */ + typedef typename OutputImageType::PixelType OutputImagePixelType ; + + /** Type for the size of the input image. */ + typedef typename RegionType::SizeType SizeType; + + /** Pointer Type for input image. */ + typedef typename InputImageType::ConstPointer InputImagePointer; + + /** Pointer Type for the output image. */ + typedef typename OutputImageType::Pointer OutputImagePointer; + + /** Boundary condition type for the neighborhood iterator */ + typedef ConstantBoundaryCondition< TInputImage > ConstBoundaryConditionType; + + /** Neighborhood iterator type */ + typedef NeighborhoodIterator NeighborhoodIteratorType; + + /** Neighborhood type */ + typedef typename NeighborhoodIteratorType::NeighborhoodType NeighborhoodType; + + /** Get Skelenton by thinning image. */ + OutputImageType * GetThinning(void); + + /** ImageDimension enumeration */ + itkStaticConstMacro(InputImageDimension, unsigned int, + TInputImage::ImageDimension ); + itkStaticConstMacro(OutputImageDimension, unsigned int, + TOutputImage::ImageDimension ); + +#ifdef ITK_USE_CONCEPT_CHECKING + /** Begin concept checking */ + itkConceptMacro(SameDimensionCheck, + (Concept::SameDimension)); + itkConceptMacro(SameTypeCheck, + (Concept::SameType)); + itkConceptMacro(InputAdditiveOperatorsCheck, + (Concept::AdditiveOperators)); + itkConceptMacro(InputConvertibleToIntCheck, + (Concept::Convertible)); + itkConceptMacro(IntConvertibleToInputCheck, + (Concept::Convertible)); + itkConceptMacro(InputIntComparableCheck, + (Concept::Comparable)); + /** End concept checking */ +#endif + +protected: + BinaryThinningImageFilter3D(); + virtual ~BinaryThinningImageFilter3D() {}; + void PrintSelf(std::ostream& os, Indent indent) const; + + /** Compute thinning Image. */ + void GenerateData(); + + /** Prepare data. */ + void PrepareData(); + + /** Compute thinning Image. */ + void ComputeThinImage(); + + /** isEulerInvariant [Lee94] */ + bool isEulerInvariant(NeighborhoodType neighbors, int *LUT); + void fillEulerLUT(int *LUT); + /** isSimplePoint [Lee94] */ + bool isSimplePoint(NeighborhoodType neighbors); + /** Octree_labeling [Lee94] */ + void Octree_labeling(int octant, int label, int *cube); + + +private: + BinaryThinningImageFilter3D(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + +}; // end of BinaryThinningImageFilter3D class + +} //end namespace itk + +#ifndef ITK_MANUAL_INSTANTIATION +#include "itkBinaryThinningImageFilter3D.txx" +#endif + +#endif