KWStyle - itkNeighborhoodBinaryThresholdImageFunction.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkNeighborhoodBinaryThresholdImageFunction.txx.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:42 $
7   Version:   $Revision: 1.4 $
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 DEF #ifndef _itkNeighborhoodBinaryThresholdImageFunction_txx
18 DEF #define _itkNeighborhoodBinaryThresholdImageFunction_txx
19 #include "itkNeighborhoodBinaryThresholdImageFunction.h"
20
21 #include "itkNumericTraits.h"
22 #include "itkConstNeighborhoodIterator.h"
23
24 namespace itk
25 {
26
27 /**
28  * Constructor
29  */
30 template <class TInputImage, class TCoordRep>
31 NeighborhoodBinaryThresholdImageFunction<TInputImage,TCoordRep>
32 ::NeighborhoodBinaryThresholdImageFunction()
33 {
34   m_Radius.Fill(1);
35 }
36
37
38 /**
39  *
40  */
41 template <class TInputImage, class TCoordRep>
42 void
43 NeighborhoodBinaryThresholdImageFunction<TInputImage,TCoordRep>
44 ::PrintSelf(std::ostream& os, Indent indent) const
45 {
46   this->Superclass::PrintSelf(os,indent);
47
48   os << indent << "Radius: " << m_Radius << std::endl;
49 }
50
51
52 /**
53  *
54  */
55 template <class TInputImage, class TCoordRep>
56 bool
57 NeighborhoodBinaryThresholdImageFunction<TInputImage,TCoordRep>
58 ::EvaluateAtIndex(const IndexType& index) const
59 {
60   
61   if( !this->GetInputImage() )
62     {
63     return ( false );
64     }
65   
66   if ( !this->IsInsideBuffer( index ) )
67     {
68     return ( false );
69     }
70
71   // Create an N-d neighborhood kernel, using a zeroflux boundary condition
72   ConstNeighborhoodIterator<InputImageType>
73 LEN,IND ****it(m_Radius, this->GetInputImage(), this->GetInputImage()->GetBufferedRegion());
74
75   // Set the iterator at the desired location
76   it.SetLocation(index);
77
78   // Walk the neighborhood
79   bool allInside = true;
80   PixelType lower = this->GetLower();
81   PixelType upper = this->GetUpper();
82   PixelType value;
83   const unsigned int size = it.Size();
84   for (unsigned int i = 0; i < size; ++i)
85     {
86     value = it.GetPixel(i);
87     if (lower > value || value > upper)
88       {
89       allInside = false;
90       break;
91       }
92     }
93
94   return ( allInside );
95 }
96
97
98 // namespace itk
99
100 #endif
101

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:27PM
© Kitware Inc.