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