1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: itkConditionalGrayscaleDilateImageFilter.txx,v $
6 Date: $Date: 2009-04-28 14:36:20 $
7 Version: $Revision: 1.17 $
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 =========================================================================*/
17 #ifndef __clitkConditionalGrayscaleDilateImageFilter_txx
18 #define __clitkConditionalGrayscaleDilateImageFilter_txx
20 // First make sure that the configuration is available.
21 // This line can be removed once the optimized versions
22 // gets integrated into the main directories.
23 #include "itkConfigure.h"
25 #ifdef ITK_USE_CONSOLIDATED_MORPHOLOGY
26 #include "itkOptGrayscaleDilateImageFilter.txx"
30 #include "clitkConditionalGrayscaleDilateImageFilter.h"
34 template<class TInputImage, class TOutputImage, class TKernel>
35 ConditionalGrayscaleDilateImageFilter<TInputImage, TOutputImage, TKernel>
36 ::ConditionalGrayscaleDilateImageFilter()
38 m_DilateBoundaryCondition.SetConstant( NumericTraits<PixelType>::NonpositiveMin() );
39 this->OverrideBoundaryCondition( &m_DilateBoundaryCondition );
42 template<class TInputImage, class TOutputImage, class TKernel>
43 typename ConditionalGrayscaleDilateImageFilter<TInputImage, TOutputImage, TKernel>::PixelType
44 ConditionalGrayscaleDilateImageFilter<TInputImage, TOutputImage, TKernel>
45 ::Evaluate(const NeighborhoodIteratorType &nit,
46 const KernelIteratorType kernelBegin,
47 const KernelIteratorType kernelEnd)
50 PixelType max = NumericTraits<PixelType>::NonpositiveMin();
53 KernelIteratorType kernel_it;
55 PixelType center = nit.GetCenterPixel ();
56 // if (center != NumericTraits<KernelPixelType>::Zero) {
60 if (center > NumericTraits<KernelPixelType>::Zero) return center;
62 for( i=0, kernel_it=kernelBegin; kernel_it<kernelEnd; ++kernel_it, ++i )
64 // if structuring element is positive, use the pixel under that element
66 if( *kernel_it > NumericTraits<KernelPixelType>::Zero )
68 // note we use GetPixel() on the SmartNeighborhoodIterator to
69 // respect boundary conditions
70 temp = nit.GetPixel(i);