1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: itkGrayscaleDilateImageFilter.h,v $
6 Date: $Date: 2009-04-28 14:36:20 $
7 Version: $Revision: 1.19 $
9 Copyright (c) Insight Software Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
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.
16 =========================================================================*/
18 #ifndef __clitkGrayscaleDilateImageFilter_h
19 #define __clitkGrayscaleDilateImageFilter_h
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"
26 #ifdef ITK_USE_CONSOLIDATED_MORPHOLOGY
27 #include "itkOptGrayscaleDilateImageFilter.h"
31 #include "itkMorphologyImageFilter.h"
36 * \class ConditionalGrayscaleDilateImageFilter
37 * \brief gray scale dilation of an image
39 * Dilate an image using grayscale morphology. Dilation takes the
40 * maximum of all the pixels identified by the structuring element.
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.
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
52 * \sa MorphologyImageFilter, GrayscaleFunctionDilateImageFilter, BinaryDilateImageFilter
53 * \ingroup ImageEnhancement MathematicalMorphologyImageFilters
56 template<class TInputImage, class TOutputImage, class TKernel>
57 class ITK_EXPORT ConditionalGrayscaleDilateImageFilter :
58 public MorphologyImageFilter<TInputImage, TOutputImage, TKernel>
61 /** Standard class typedefs. */
62 typedef ConditionalGrayscaleDilateImageFilter Self;
63 typedef MorphologyImageFilter<TInputImage, TOutputImage, TKernel>
65 typedef SmartPointer<Self> Pointer;
66 typedef SmartPointer<const Self> ConstPointer;
68 /** Standard New method. */
71 /** Runtime information support. */
72 itkTypeMacro(ConditionalGrayscaleDilateImageFilter,
73 MorphologyImageFilter);
75 /** Declaration of pixel type. */
76 typedef typename Superclass::PixelType PixelType;
78 /** Kernel (structuring element) iterator. */
79 typedef typename Superclass::KernelIteratorType KernelIteratorType;
81 /** Neighborhood iterator type. */
82 typedef typename Superclass::NeighborhoodIteratorType NeighborhoodIteratorType;
84 /** Kernel typedef. */
85 typedef typename Superclass::KernelType KernelType;
87 /** Default boundary condition type */
88 typedef typename Superclass::DefaultBoundaryConditionType DefaultBoundaryConditionType;
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);
98 /** Type of the pixels in the Kernel. */
99 typedef typename TKernel::PixelType KernelPixelType;
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 */
117 ConditionalGrayscaleDilateImageFilter();
118 ~ConditionalGrayscaleDilateImageFilter() {};
120 /** Evaluate image neighborhood with kernel to find the new value
121 * for the center pixel value
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);
131 ConditionalGrayscaleDilateImageFilter(const Self&); //purposely not implemented
132 void operator=(const Self&); //purposely not implemented
134 // Default boundary condition for dilation filter, defaults to
135 // NumericTraits<PixelType>::NonpositiveMin()
136 DefaultBoundaryConditionType m_DilateBoundaryCondition;
140 } // end namespace itk
142 #ifndef ITK_MANUAL_INSTANTIATION
143 #include "clitkConditionalGrayscaleDilateImageFilter.txx"