ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkNeighborhoodOperator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkNeighborhoodOperator_h
19 #define __itkNeighborhoodOperator_h
20 
21 #include "itkNeighborhood.h"
22 #include "itkNumericTraits.h"
23 #include <vector>
24 
25 namespace itk
26 {
64 template< class TPixel, unsigned int VDimension,
65  class TAllocator = NeighborhoodAllocator< TPixel > >
66 class ITK_EXPORT NeighborhoodOperator:
67  public Neighborhood< TPixel, VDimension, TAllocator >
68 {
69 public:
73 
75  typedef typename Superclass::SizeType SizeType;
76 
78  typedef TPixel PixelType;
79 
82 
85  { m_Direction = 0; }
86 
88  NeighborhoodOperator(const Self & orig):
89  Neighborhood< TPixel, VDimension, TAllocator >(orig)
90  { m_Direction = orig.m_Direction; }
91 
93  Self & operator=(const Self & orig)
94  {
95  Superclass::operator=(orig);
96  m_Direction = orig.m_Direction;
97  return *this;
98  }
100 
102  void SetDirection(const unsigned long & direction)
103  { m_Direction = direction; }
104 
106  unsigned long GetDirection() const
107  { return m_Direction; }
108 
113  virtual void CreateDirectional();
114 
119  virtual void CreateToRadius(const SizeType &);
120 
125  virtual void CreateToRadius(const SizeValueType);
126 
129  virtual void FlipAxes();
130 
132  virtual void PrintSelf(std::ostream & os, Indent i) const
133  {
134  os << i << "NeighborhoodOperator { this=" << this
135  << " Direction = " << m_Direction << " }" << std::endl;
136  Superclass::PrintSelf( os, i.GetNextIndent() );
137  }
139 
141 
144  void ScaleCoefficients(PixelRealType);
145 protected:
146 
149  typedef std::vector< double > CoefficientVector;
150 
153  virtual CoefficientVector GenerateCoefficients() = 0;
154 
157  virtual void Fill(const CoefficientVector &) = 0;
158 
164  virtual void FillCenteredDirectional(const CoefficientVector &);
165 
167  void InitializeToZero()
168  {
169  for ( unsigned int i = 0; i < this->Size(); ++i )
170  {
171  this->operator[](i) = NumericTraits< PixelType >::Zero;
172  }
173  }
175 
176 private:
178  unsigned long m_Direction;
179 };
180 } // namespace itk
181 
182 // Define instantiation macro for this template.
183 #define ITK_TEMPLATE_NeighborhoodOperator(_, EXPORT, TypeX, TypeY) \
184  namespace itk \
185  { \
186  _( 2 ( class EXPORT NeighborhoodOperator< ITK_TEMPLATE_2 TypeX > ) ) \
187  namespace Templates \
188  { \
189  typedef NeighborhoodOperator< ITK_TEMPLATE_2 TypeX > \
190  NeighborhoodOperator##TypeY; \
191  } \
192  }
193 
194 #if ITK_TEMPLATE_EXPLICIT
195 #include "Templates/itkNeighborhoodOperator+-.h"
196 #endif
197 
198 #if ITK_TEMPLATE_TXX
199 #include "itkNeighborhoodOperator.hxx"
200 #endif
201 
202 /*
203 #ifndef ITK_MANUAL_INSTANTIATION
204 #include "itkNeighborhoodOperator.hxx"
205 #endif
206 */
207 #endif
208