ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkGrayscaleMorphologicalOpeningImageFilter.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 __itkGrayscaleMorphologicalOpeningImageFilter_h
00019 #define __itkGrayscaleMorphologicalOpeningImageFilter_h
00020 
00021 #include "itkKernelImageFilter.h"
00022 #include "itkMovingHistogramDilateImageFilter.h"
00023 #include "itkMovingHistogramErodeImageFilter.h"
00024 #include "itkBasicDilateImageFilter.h"
00025 #include "itkBasicErodeImageFilter.h"
00026 #include "itkAnchorOpenImageFilter.h"
00027 #include "itkVanHerkGilWermanErodeImageFilter.h"
00028 #include "itkVanHerkGilWermanDilateImageFilter.h"
00029 #include "itkConstantBoundaryCondition.h"
00030 #include "itkNeighborhood.h"
00031 
00032 namespace itk
00033 {
00050 template< class TInputImage, class TOutputImage, class TKernel >
00051 class ITK_EXPORT GrayscaleMorphologicalOpeningImageFilter:
00052   public KernelImageFilter< TInputImage, TOutputImage, TKernel >
00053 {
00054 public:
00056   typedef GrayscaleMorphologicalOpeningImageFilter                Self;
00057   typedef KernelImageFilter< TInputImage, TOutputImage, TKernel > Superclass;
00058   typedef SmartPointer< Self >                                    Pointer;
00059   typedef SmartPointer< const Self >                              ConstPointer;
00060 
00062   itkNewMacro(Self);
00063 
00065   itkTypeMacro(GrayscaleMorphologicalOpeningImageFilter,
00066                KernelImageFilter);
00067 
00069   itkStaticConstMacro(ImageDimension, unsigned int,
00070                       TInputImage::ImageDimension);
00071 
00073   typedef TInputImage                                InputImageType;
00074   typedef TOutputImage                               OutputImageType;
00075   typedef typename TInputImage::RegionType           RegionType;
00076   typedef typename TInputImage::SizeType             SizeType;
00077   typedef typename TInputImage::IndexType            IndexType;
00078   typedef typename TInputImage::PixelType            PixelType;
00079   typedef typename TInputImage::OffsetType           OffsetType;
00080   typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
00081 
00082   typedef FlatStructuringElement< itkGetStaticConstMacro(ImageDimension) >
00083   FlatKernelType;
00084   typedef MovingHistogramDilateImageFilter< TInputImage, TOutputImage, TKernel >
00085   HistogramDilateFilterType;
00086   typedef MovingHistogramErodeImageFilter< TInputImage, TOutputImage, TKernel >
00087   HistogramErodeFilterType;
00088   typedef BasicErodeImageFilter< TInputImage, TInputImage, TKernel >
00089   BasicErodeFilterType;
00090   typedef BasicDilateImageFilter< TInputImage, TOutputImage, TKernel >
00091   BasicDilateFilterType;
00092   typedef AnchorOpenImageFilter< TInputImage, FlatKernelType > AnchorFilterType;
00093   typedef VanHerkGilWermanErodeImageFilter< TInputImage, FlatKernelType >
00094   VanHerkGilWermanErodeFilterType;
00095   typedef VanHerkGilWermanDilateImageFilter< TInputImage, FlatKernelType >
00096   VanHerkGilWermanDilateFilterType;
00097   typedef CastImageFilter< TInputImage, TOutputImage > SubtractFilterType;
00098 
00100   typedef TKernel KernelType;
00101 //   typedef typename KernelType::Superclass KernelSuperClass;
00102 //   typedef Neighborhood< typename KernelType::PixelType, ImageDimension >
00103 // KernelSuperClass;
00104 
00106   void SetKernel(const KernelType & kernel);
00107 
00109   void SetAlgorithm(int algo);
00110 
00111   itkGetConstMacro(Algorithm, int);
00112 
00115   virtual void Modified() const;
00116 
00118   enum {
00119     BASIC = 0,
00120     HISTO = 1,
00121     ANCHOR = 2,
00122     VHGW = 3
00123     } AlgorithmChoice;
00124 
00127   itkSetMacro(SafeBorder, bool);
00128   itkGetConstReferenceMacro(SafeBorder, bool);
00129   itkBooleanMacro(SafeBorder);
00130 protected:
00131   GrayscaleMorphologicalOpeningImageFilter();
00132   ~GrayscaleMorphologicalOpeningImageFilter() {}
00133   void PrintSelf(std::ostream & os, Indent indent) const;
00135 
00136   void GenerateData();
00137 
00138 private:
00139   GrayscaleMorphologicalOpeningImageFilter(const Self &); //purposely not
00140                                                           // implemented
00141   void operator=(const Self &);                           //purposely not
00142 
00143   // implemented
00144 
00145   // the filters used internally
00146   typename HistogramDilateFilterType::Pointer m_HistogramDilateFilter;
00147 
00148   typename HistogramErodeFilterType::Pointer m_HistogramErodeFilter;
00149 
00150   typename BasicDilateFilterType::Pointer m_BasicDilateFilter;
00151 
00152   typename BasicErodeFilterType::Pointer m_BasicErodeFilter;
00153 
00154   typename VanHerkGilWermanDilateFilterType::Pointer m_VanHerkGilWermanDilateFilter;
00155 
00156   typename VanHerkGilWermanErodeFilterType::Pointer m_VanHerkGilWermanErodeFilter;
00157 
00158   typename AnchorFilterType::Pointer m_AnchorFilter;
00159 
00160   // and the name of the filter
00161   int m_Algorithm;
00162 
00163   bool m_SafeBorder;
00164 }; // end of class
00165 } // end namespace itk
00166 
00167 #ifndef ITK_MANUAL_INSTANTIATION
00168 #include "itkGrayscaleMorphologicalOpeningImageFilter.hxx"
00169 #endif
00170 
00171 #endif
00172