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

itkOptBinaryMorphologyImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkOptBinaryMorphologyImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-08-13 12:37:50 $
00007   Version:   $Revision: 1.1 $
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 __itkOptBinaryMorphologyImageFilter_h
00018 #define __itkOptBinaryMorphologyImageFilter_h
00019 
00020 #include <vector>
00021 #include <queue>
00022 #include "itkKernelImageFilter.h"
00023 #include "itkImage.h"
00024 #include "itkNumericTraits.h"
00025 #include "itkNeighborhoodIterator.h"
00026 #include "itkConstNeighborhoodIterator.h"
00027 #include "itkNeighborhood.h"
00028 #include "itkImageBoundaryCondition.h"
00029 #include "itkImageRegionIterator.h"
00030 #include "itkConceptChecking.h"
00031 
00032 namespace itk
00033 {
00104 template <class TInputImage, class TOutputImage, class TKernel>
00105 class ITK_EXPORT BinaryMorphologyImageFilter :
00106     public KernelImageFilter< TInputImage, TOutputImage, TKernel >
00107 {
00108 public:
00109 
00111   itkStaticConstMacro(InputImageDimension, unsigned int,
00112                       TInputImage::ImageDimension);
00113   itkStaticConstMacro(OutputImageDimension, unsigned int,
00114                       TOutputImage::ImageDimension);
00116 
00118   itkStaticConstMacro(KernelDimension, unsigned int,
00119                       TKernel::NeighborhoodDimension);
00120 
00122   typedef TInputImage  InputImageType;
00123   typedef TOutputImage OutputImageType;
00124 
00126   typedef BinaryMorphologyImageFilter                          Self;
00127   typedef KernelImageFilter< InputImageType, OutputImageType, TKernel>
00128                                                                Superclass;
00129   typedef SmartPointer<Self>                                   Pointer;
00130   typedef SmartPointer<const Self>                             ConstPointer;
00131 
00133   itkNewMacro(Self);
00134 
00136   itkTypeMacro(BinaryMorphologyImageFilter, ImageToImageFilter);
00137 
00139   typedef TKernel KernelType;
00140 
00142   typedef typename KernelType::ConstIterator KernelIteratorType;
00143 
00145   typedef typename InputImageType::PixelType               InputPixelType;
00146   typedef typename OutputImageType::PixelType              OutputPixelType;
00147   typedef typename NumericTraits<InputPixelType>::RealType InputRealType;
00148   typedef typename InputImageType::OffsetType              OffsetType;
00149   typedef typename InputImageType::IndexType               IndexType;
00150 
00151   typedef typename InputImageType::RegionType  InputImageRegionType;
00152   typedef typename OutputImageType::RegionType OutputImageRegionType;
00153   typedef typename InputImageType::SizeType    InputSizeType;
00154 
00156   itkConceptMacro(ImageDimensionCheck,
00157       (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension),
00158                               itkGetStaticConstMacro(OutputImageDimension)>));
00159 
00160 // Cannot get this to work with gcc compiler
00161 #if 0
00162 
00163   itkConceptMacro(KernelDimensionCheck,
00164       (Concept::SameDimension<itkGetStaticConstMacro(KernelDimension),
00165                               itkGetStaticConstMacro(InputImageDimension)>));
00166 #endif
00167 
00171   itkSetMacro(ForegroundValue, InputPixelType);
00172 
00175   itkGetConstMacro(ForegroundValue, InputPixelType);
00176 
00181   itkSetMacro(BackgroundValue, OutputPixelType);
00182 
00187   itkGetConstMacro(BackgroundValue, OutputPixelType);
00188 
00191   itkSetMacro(BoundaryToForeground, bool);
00192   itkGetConstReferenceMacro(BoundaryToForeground, bool);
00193   itkBooleanMacro(BoundaryToForeground);
00195 
00197   void SetKernel( const KernelType& kernel );
00198 
00199 protected:
00200   BinaryMorphologyImageFilter();
00201   virtual ~BinaryMorphologyImageFilter(){}
00202   void PrintSelf(std::ostream& os, Indent indent) const;
00203 
00207   void AnalyzeKernel();
00208 
00209   // type definition of container of neighbourhood index
00210   typedef std::vector< OffsetType > NeighborIndexContainer;
00211 
00212   // type definition of container of container of neighbourhood index
00213   typedef std::vector<NeighborIndexContainer> NeighborIndexContainerContainer;
00214 
00215   // type definition of the container for indices
00216   typedef std::vector< OffsetType > ComponentVectorType;
00217 
00218   // iterator for ComponentVectorType
00219   typedef typename ComponentVectorType::const_iterator
00220     ComponentVectorConstIterator;
00221 
00225   NeighborIndexContainer& GetDifferenceSet(unsigned int code)
00226     { return m_KernelDifferenceSets[code]; }
00227 
00231   ComponentVectorConstIterator KernelCCVectorBegin()
00232     { return m_KernelCCVector.begin(); }
00233 
00237   ComponentVectorConstIterator KernelCCVectorEnd()
00238     { return m_KernelCCVector.end(); }
00239 
00240   bool m_BoundaryToForeground;
00241 
00242 private:
00243   BinaryMorphologyImageFilter(const Self&); //purposely not implemented
00244   void operator=(const Self&); //purposely not implemented
00245 
00247   InputPixelType m_ForegroundValue;
00248 
00250   OutputPixelType m_BackgroundValue;
00251 
00252   // Difference sets definition
00253   NeighborIndexContainerContainer m_KernelDifferenceSets;
00254 
00255   // For each Connected Component ( CC ) of structuring element we
00256   // store the position of one element, arbitrary chosen, which
00257   // belongs to the CC
00258   std::vector< OffsetType > m_KernelCCVector;
00259 };
00260 
00261 } // end namespace itk
00262 
00263 #ifndef ITK_MANUAL_INSTANTIATION
00264 #include "itkOptBinaryMorphologyImageFilter.txx"
00265 #endif
00266 
00267 #endif
00268 

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