Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkBinaryMorphologyImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkBinaryMorphologyImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-09 15:31:36 $
00007   Version:   $Revision: 1.6 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkBinaryMorphologyImageFilter_h
00018 #define __itkBinaryMorphologyImageFilter_h
00019 
00020 
00021 // First make sure that the configuration is available.
00022 // This line can be removed once the optimized versions
00023 // gets integrated into the main directories.
00024 #include "itkConfigure.h"
00025 
00026 #ifdef ITK_USE_CONSOLIDATED_MORPHOLOGY
00027 #include "itkOptBinaryMorphologyImageFilter.h"
00028 #else
00029 
00030 #include <vector>
00031 #include <queue>
00032 #include "itkImageToImageFilter.h"
00033 #include "itkImage.h"
00034 #include "itkNumericTraits.h"
00035 #include "itkNeighborhoodIterator.h"
00036 #include "itkConstNeighborhoodIterator.h"
00037 #include "itkNeighborhood.h"
00038 #include "itkImageBoundaryCondition.h"
00039 #include "itkImageRegionIterator.h"
00040 #include "itkConceptChecking.h"
00041 
00042 namespace itk
00043 {
00114 template <class TInputImage, class TOutputImage, class TKernel>
00115 class ITK_EXPORT BinaryMorphologyImageFilter :
00116     public ImageToImageFilter< TInputImage, TOutputImage >
00117 {
00118 public:
00119 
00121   itkStaticConstMacro(InputImageDimension, unsigned int,
00122                       TInputImage::ImageDimension);
00123   itkStaticConstMacro(OutputImageDimension, unsigned int,
00124                       TOutputImage::ImageDimension);
00126 
00128   itkStaticConstMacro(KernelDimension, unsigned int,
00129                       TKernel::NeighborhoodDimension);
00130 
00132   typedef TInputImage  InputImageType;
00133   typedef TOutputImage OutputImageType;
00134 
00136   typedef BinaryMorphologyImageFilter                          Self;
00137   typedef ImageToImageFilter< InputImageType, OutputImageType> Superclass;
00138   typedef SmartPointer<Self>                                   Pointer;
00139   typedef SmartPointer<const Self>                             ConstPointer;
00140 
00142   itkNewMacro(Self);
00143 
00145   itkTypeMacro(BinaryMorphologyImageFilter, ImageToImageFilter);
00146 
00148   typedef TKernel KernelType;
00149 
00151   typedef typename KernelType::ConstIterator KernelIteratorType;
00152 
00154   typedef typename InputImageType::PixelType               InputPixelType;
00155   typedef typename OutputImageType::PixelType              OutputPixelType;
00156   typedef typename NumericTraits<InputPixelType>::RealType InputRealType;
00157   typedef typename InputImageType::OffsetType              OffsetType;
00158   typedef typename InputImageType::IndexType               IndexType;
00159 
00160   typedef typename InputImageType::RegionType  InputImageRegionType;
00161   typedef typename OutputImageType::RegionType OutputImageRegionType;
00162   typedef typename InputImageType::SizeType    InputSizeType;
00163 
00165   itkConceptMacro(ImageDimensionCheck,
00166       (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension),
00167                               itkGetStaticConstMacro(OutputImageDimension)>));
00168 
00170   void SetKernel( const KernelType& kernel );
00171 
00173   itkGetConstReferenceMacro(Kernel, KernelType);
00174 
00178   itkSetMacro(ForegroundValue, InputPixelType);
00179 
00182   itkGetConstMacro(ForegroundValue, InputPixelType);
00183 
00188   itkSetMacro(BackgroundValue, OutputPixelType);
00189 
00194   itkGetConstMacro(BackgroundValue, OutputPixelType);
00195 
00197   itkSetMacro(BoundaryToForeground, bool);
00198   itkGetConstReferenceMacro(BoundaryToForeground, bool);
00199   itkBooleanMacro(BoundaryToForeground);
00201 
00202 protected:
00203   BinaryMorphologyImageFilter();
00204   virtual ~BinaryMorphologyImageFilter(){}
00205   void PrintSelf(std::ostream& os, Indent indent) const;
00206 
00210   void AnalyzeKernel();
00211 
00220   void GenerateInputRequestedRegion() throw (InvalidRequestedRegionError);
00221 
00222   // type definition of container of neighbourhood index
00223   typedef std::vector< OffsetType > NeighborIndexContainer;
00224 
00225   // type definition of container of container of neighbourhood index
00226   typedef std::vector<NeighborIndexContainer> NeighborIndexContainerContainer;
00227 
00228   // type definition of the container for indices
00229   typedef std::vector< OffsetType > ComponentVectorType;
00230 
00231   // iterator for ComponentVectorType
00232   typedef typename ComponentVectorType::const_iterator
00233     ComponentVectorConstIterator;
00234 
00238   NeighborIndexContainer& GetDifferenceSet(unsigned int code)
00239     { return m_KernelDifferenceSets[code]; }
00240 
00244   ComponentVectorConstIterator KernelCCVectorBegin()
00245     { return m_KernelCCVector.begin(); }
00246 
00250   ComponentVectorConstIterator KernelCCVectorEnd()
00251     { return m_KernelCCVector.end(); }
00252 
00256   InputSizeType GetRadius() const
00257     { return m_Radius; }
00258 
00259   bool m_BoundaryToForeground;
00260 
00261 private:
00262   BinaryMorphologyImageFilter(const Self&); //purposely not implemented
00263   void operator=(const Self&); //purposely not implemented
00264 
00267   InputSizeType m_Radius;
00268 
00270   KernelType m_Kernel;
00271 
00273   InputPixelType m_ForegroundValue;
00274 
00276   OutputPixelType m_BackgroundValue;
00277 
00278   // Difference sets definition
00279   NeighborIndexContainerContainer m_KernelDifferenceSets;
00280 
00281   // For each Connected Component ( CC ) of structuring element we
00282   // store the position of one element, arbitrary chosen, which
00283   // belongs to the CC
00284   std::vector< OffsetType > m_KernelCCVector;
00285 };
00286 
00287 } // end namespace itk
00288 
00289 #ifndef ITK_MANUAL_INSTANTIATION
00290 #include "itkBinaryMorphologyImageFilter.txx"
00291 #endif
00292 
00293 #endif
00294 
00295 #endif
00296 

Generated at Wed Nov 5 20:27:20 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000