ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkMorphologyImageFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkMorphologyImageFilter_h
00019 #define __itkMorphologyImageFilter_h
00020 
00021 #include "itkKernelImageFilter.h"
00022 #include "itkNeighborhoodIterator.h"
00023 #include "itkNeighborhood.h"
00024 #include "itkConstSliceIterator.h"
00025 #include "itkConstantBoundaryCondition.h"
00026 #include "itkImageRegionIterator.h"
00027 
00028 namespace itk
00029 {
00071 template< class TInputImage, class TOutputImage, class TKernel >
00072 class ITK_EXPORT MorphologyImageFilter:
00073   public KernelImageFilter< TInputImage, TOutputImage, TKernel >
00074 {
00075 public:
00077   typedef MorphologyImageFilter                                   Self;
00078   typedef KernelImageFilter< TInputImage, TOutputImage, TKernel > Superclass;
00079   typedef SmartPointer< Self >                                    Pointer;
00080   typedef SmartPointer< const Self >                              ConstPointer;
00081 
00083   itkTypeMacro(MorphologyImageFilter, KernelImageFilter);
00084 
00086   typedef TInputImage                                InputImageType;
00087   typedef TOutputImage                               OutputImageType;
00088   typedef typename TInputImage::RegionType           RegionType;
00089   typedef typename TInputImage::SizeType             SizeType;
00090   typedef typename TInputImage::IndexType            IndexType;
00091   typedef typename TInputImage::PixelType            PixelType;
00092   typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
00093 
00095   itkStaticConstMacro(ImageDimension, unsigned int,
00096                       TInputImage::ImageDimension);
00097 
00099   typedef ImageBoundaryCondition< InputImageType > *      ImageBoundaryConditionPointerType;
00100   typedef ImageBoundaryCondition< InputImageType > const *ImageBoundaryConditionConstPointerType;
00101   typedef ConstantBoundaryCondition< InputImageType >     DefaultBoundaryConditionType;
00102 
00104   typedef ConstNeighborhoodIterator< TInputImage > NeighborhoodIteratorType;
00105 
00107   typedef TKernel KernelType;
00108 
00110   typedef typename KernelType::ConstIterator KernelIteratorType;
00111 
00113   typedef typename KernelType::SizeType RadiusType;
00114 
00120   void OverrideBoundaryCondition(const ImageBoundaryConditionPointerType i)
00121   {
00122     m_BoundaryCondition = i;
00123   }
00124 
00126   void ResetBoundaryCondition()
00127   {
00128     m_BoundaryCondition = &m_DefaultBoundaryCondition;
00129   }
00130 
00132   itkGetConstMacro(BoundaryCondition, ImageBoundaryConditionPointerType);
00133 protected:
00134   MorphologyImageFilter();
00135   ~MorphologyImageFilter() {}
00136   void PrintSelf(std::ostream & os, Indent indent) const;
00138 
00140   void  ThreadedGenerateData(const OutputImageRegionType &
00141                              outputRegionForThread,
00142                              ThreadIdType threadId);
00143 
00146   virtual PixelType Evaluate(const NeighborhoodIteratorType & nit,
00147                              const KernelIteratorType kernelBegin,
00148                              const KernelIteratorType kernelEnd) = 0;
00149 
00150 private:
00151   MorphologyImageFilter(const Self &); //purposely not implemented
00152   void operator=(const Self &);        //purposely not implemented
00153 
00156   ImageBoundaryConditionPointerType m_BoundaryCondition;
00157 
00159   DefaultBoundaryConditionType m_DefaultBoundaryCondition;
00160 }; // end of class
00161 } // end namespace itk
00162 
00163 #ifndef ITK_MANUAL_INSTANTIATION
00164 #include "itkMorphologyImageFilter.hxx"
00165 #endif
00166 
00167 #endif
00168