]> Creatis software - clitk.git/blob - itk/clitkConditionalGrayscaleDilateImageFilter.h
Ensure compatibility with VTK6 for Image2DicomRTStruct tool
[clitk.git] / itk / clitkConditionalGrayscaleDilateImageFilter.h
1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkGrayscaleDilateImageFilter.h,v $
5   Language:  C++
6   Date:      $Date: 2009-04-28 14:36:20 $
7   Version:   $Revision: 1.19 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17
18 #ifndef __clitkGrayscaleDilateImageFilter_h
19 #define __clitkGrayscaleDilateImageFilter_h
20
21 // First make sure that the configuration is available.
22 // This line can be removed once the optimized versions
23 // gets integrated into the main directories.
24 #include "itkConfigure.h"
25
26 #ifdef ITK_USE_CONSOLIDATED_MORPHOLOGY
27 #include "itkOptGrayscaleDilateImageFilter.h"
28 #else
29
30
31 #include "itkMorphologyImageFilter.h"
32
33 namespace itk {
34
35 /**
36  * \class ConditionalGrayscaleDilateImageFilter
37  * \brief gray scale dilation of an image
38  *
39  * Dilate an image using grayscale morphology. Dilation takes the
40  * maximum of all the pixels identified by the structuring element.
41  *
42  * The structuring element is assumed to be composed of binary
43  * values (zero or one). Only elements of the structuring element
44  * having values > 0 are candidates for affecting the center pixel.
45  * 
46  * For the each input image pixel, 
47  *   - NeighborhoodIterator gives neighbors of the pixel. 
48  *   - Evaluate() member function returns the maximum value among 
49  *     the image neighbors where the kernel has elements > 0.
50  *   - Replace the original value with the max value
51  *
52  * \sa MorphologyImageFilter, GrayscaleFunctionDilateImageFilter, BinaryDilateImageFilter
53  * \ingroup ImageEnhancement  MathematicalMorphologyImageFilters
54  */
55
56 template<class TInputImage, class TOutputImage, class TKernel>
57 class ITK_EXPORT ConditionalGrayscaleDilateImageFilter : 
58     public MorphologyImageFilter<TInputImage, TOutputImage, TKernel>
59 {
60 public:
61   /** Standard class typedefs. */
62   typedef ConditionalGrayscaleDilateImageFilter Self;
63   typedef MorphologyImageFilter<TInputImage, TOutputImage, TKernel>
64                                      Superclass;
65   typedef SmartPointer<Self>         Pointer;
66   typedef SmartPointer<const Self>   ConstPointer;
67   
68   /** Standard New method. */
69   itkNewMacro(Self);  
70
71   /** Runtime information support. */
72   itkTypeMacro(ConditionalGrayscaleDilateImageFilter, 
73                MorphologyImageFilter);
74   
75   /** Declaration of pixel type. */
76   typedef typename Superclass::PixelType PixelType;
77
78   /** Kernel (structuring element) iterator. */
79   typedef typename Superclass::KernelIteratorType  KernelIteratorType;
80
81   /** Neighborhood iterator type. */
82   typedef typename Superclass::NeighborhoodIteratorType NeighborhoodIteratorType;
83
84   /** Kernel typedef. */
85   typedef typename Superclass::KernelType KernelType;
86
87   /** Default boundary condition type */
88   typedef typename Superclass::DefaultBoundaryConditionType DefaultBoundaryConditionType;
89
90   /** ImageDimension constants */
91   itkStaticConstMacro(InputImageDimension, unsigned int,
92                       TInputImage::ImageDimension);
93   itkStaticConstMacro(OutputImageDimension, unsigned int,
94                       TOutputImage::ImageDimension);
95   itkStaticConstMacro(KernelDimension, unsigned int,
96                       TKernel::NeighborhoodDimension);
97
98   /** Type of the pixels in the Kernel. */
99   typedef typename TKernel::PixelType            KernelPixelType;
100
101 #ifdef ITK_USE_CONCEPT_CHECKING
102   /** Begin concept checking */
103   itkConceptMacro(InputConvertibleToOutputCheck,
104     (Concept::Convertible<PixelType, typename TOutputImage::PixelType>));
105   itkConceptMacro(SameDimensionCheck1,
106      (Concept::SameDimension<InputImageDimension, OutputImageDimension>));
107   itkConceptMacro(SameDimensionCheck2,
108     (Concept::SameDimension<InputImageDimension, KernelDimension>));
109   itkConceptMacro(InputGreaterThanComparableCheck,
110     (Concept::GreaterThanComparable<PixelType>));
111   itkConceptMacro(KernelGreaterThanComparableCheck,
112     (Concept::GreaterThanComparable<KernelPixelType>));
113   /** End concept checking */
114 #endif
115
116 protected:
117   ConditionalGrayscaleDilateImageFilter();
118   ~ConditionalGrayscaleDilateImageFilter() {};
119
120   /** Evaluate image neighborhood with kernel to find the new value 
121    * for the center pixel value
122    *
123    * It will return the maximum value of the image pixels whose corresponding
124    * element in the structuring element is positive. This version of
125    * Evaluate is used for non-boundary pixels. */
126   PixelType Evaluate(const NeighborhoodIteratorType &nit,
127                      const KernelIteratorType kernelBegin,
128                      const KernelIteratorType kernelEnd);
129
130 private:
131   ConditionalGrayscaleDilateImageFilter(const Self&); //purposely not implemented
132   void operator=(const Self&); //purposely not implemented
133
134   // Default boundary condition for dilation filter, defaults to
135   // NumericTraits<PixelType>::NonpositiveMin()
136   DefaultBoundaryConditionType m_DilateBoundaryCondition;
137
138 }; // end of class
139
140 } // end namespace itk
141   
142 #ifndef ITK_MANUAL_INSTANTIATION
143 #include "clitkConditionalGrayscaleDilateImageFilter.txx"
144 #endif
145
146 #endif
147
148 #endif