ITK  6.0.0
Insight Toolkit
itkNeighborhoodOperator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 {
71 template <typename TPixel, unsigned int VDimension, typename TAllocator = NeighborhoodAllocator<TPixel>>
72 class ITK_TEMPLATE_EXPORT NeighborhoodOperator : public Neighborhood<TPixel, VDimension, TAllocator>
73 {
74 public:
78 
79  itkOverrideGetNameOfClassMacro(NeighborhoodOperator);
80 
82  using typename Superclass::SizeType;
83 
85  using PixelType = TPixel;
86 
89 
91 
93  void
94  SetDirection(const unsigned long direction)
95  {
96  if (direction >= VDimension)
97  {
98  itkExceptionMacro(<< " Can not set direction " << direction << " greater than dimensionality of neighborhood "
99  << VDimension);
100  }
101  m_Direction = direction;
102  }
106  unsigned long
107  GetDirection() const
108  {
109  return m_Direction;
110  }
111 
116  virtual void
117  CreateDirectional();
118 
123  virtual void
124  CreateToRadius(const SizeType &);
125 
130  virtual void
131  CreateToRadius(const SizeValueType);
132 
135  virtual void
136  FlipAxes();
137 
138  void
139  PrintSelf(std::ostream & os, Indent indent) const override
140  {
141  Superclass::PrintSelf(os, indent);
142 
143  os << indent << "Direction: " << m_Direction << std::endl;
144  }
145 
148  void ScaleCoefficients(PixelRealType);
149 
150 protected:
153  using CoefficientVector = typename std::vector<PixelRealType>;
154 
157  virtual CoefficientVector
158  GenerateCoefficients() = 0;
159 
162  virtual void
163  Fill(const CoefficientVector &) = 0;
164 
170  virtual void
171  FillCenteredDirectional(const CoefficientVector &);
172 
174  void
176  {
177  for (unsigned int i = 0; i < this->Size(); ++i)
178  {
179  this->operator[](i) = PixelType{};
180  }
181  }
184 private:
186  unsigned long m_Direction{ 0 };
187 };
188 } // namespace itk
189 
190 #ifndef ITK_MANUAL_INSTANTIATION
191 # include "itkNeighborhoodOperator.hxx"
192 #endif
193 
194 /*
195 #ifndef ITK_MANUAL_INSTANTIATION
196 #include "itkNeighborhoodOperator.hxx"
197 #endif
198 */
199 #endif
itk::NeighborhoodOperator::SetDirection
void SetDirection(const unsigned long direction)
Definition: itkNeighborhoodOperator.h:94
itk::NeighborhoodOperator::GetDirection
unsigned long GetDirection() const
Definition: itkNeighborhoodOperator.h:107
itk::NeighborhoodOperator< TPixel, TDimension, TAllocator >::PixelRealType
typename NumericTraits< TPixel >::RealType PixelRealType
Definition: itkNeighborhoodOperator.h:90
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:69
itk::SliceIterator
A flexible iterator for itk containers(i.e. itk::Neighborhood) that support pixel access through oper...
Definition: itkSliceIterator.h:48
itk::NeighborhoodOperator
Virtual class that defines a common interface to all neighborhood operator subtypes.
Definition: itkNeighborhoodOperator.h:72
itk::Neighborhood
A light-weight container object for storing an N-dimensional neighborhood of values.
Definition: itkNeighborhood.h:54
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkNeighborhood.h
itk::NeighborhoodOperator< TPixel, TDimension, TAllocator >::CoefficientVector
typename std::vector< PixelRealType > CoefficientVector
Definition: itkNeighborhoodOperator.h:153
itk::Neighborhood::PixelType
TPixel PixelType
Definition: itkNeighborhood.h:70
itk::NeighborhoodOperator::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkNeighborhoodOperator.h:139
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itkNumericTraits.h
itk::NumericTraits::RealType
double RealType
Definition: itkNumericTraits.h:86
itk::NeighborhoodOperator::InitializeToZero
void InitializeToZero()
Definition: itkNeighborhoodOperator.h:175
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86