]> Creatis software - clitk.git/blob - itk/clitkConditionalGrayscaleDilateImageFilter.txx
Change some SetInputData into SetInputConnection to be consistent with algorithm...
[clitk.git] / itk / clitkConditionalGrayscaleDilateImageFilter.txx
1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkConditionalGrayscaleDilateImageFilter.txx,v $
5   Language:  C++
6   Date:      $Date: 2009-04-28 14:36:20 $
7   Version:   $Revision: 1.17 $
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 #ifndef __clitkConditionalGrayscaleDilateImageFilter_txx
18 #define __clitkConditionalGrayscaleDilateImageFilter_txx
19
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"
24
25 #ifdef ITK_USE_CONSOLIDATED_MORPHOLOGY
26 #include "itkOptGrayscaleDilateImageFilter.txx"
27 #else
28
29
30 #include "clitkConditionalGrayscaleDilateImageFilter.h"
31
32 namespace itk {
33
34 template<class TInputImage, class TOutputImage, class TKernel>
35 ConditionalGrayscaleDilateImageFilter<TInputImage, TOutputImage, TKernel>
36 ::ConditionalGrayscaleDilateImageFilter()
37 {
38   m_DilateBoundaryCondition.SetConstant( NumericTraits<PixelType>::NonpositiveMin() );
39   this->OverrideBoundaryCondition( &m_DilateBoundaryCondition );
40 }
41
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)
48 {
49   unsigned int i;
50   PixelType max = NumericTraits<PixelType>::NonpositiveMin();
51   PixelType temp;
52
53   KernelIteratorType kernel_it;
54
55   PixelType center = nit.GetCenterPixel ();
56   // if (center != NumericTraits<KernelPixelType>::Zero)  {
57   //   DD((int)center);
58   // }
59
60   if (center > NumericTraits<KernelPixelType>::Zero) return center;
61   
62   for( i=0, kernel_it=kernelBegin; kernel_it<kernelEnd; ++kernel_it, ++i )
63     {
64     // if structuring element is positive, use the pixel under that element
65     // in the image
66     if( *kernel_it > NumericTraits<KernelPixelType>::Zero )
67       {
68       // note we use GetPixel() on the SmartNeighborhoodIterator to
69       // respect boundary conditions
70       temp = nit.GetPixel(i);
71
72       if( temp > max )
73         {
74         max = temp;
75         }
76       }
77     }
78   
79   return max;
80
81
82
83 }// end namespace itk
84 #endif
85
86 #endif