ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkAnnulusOperator.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 itkAnnulusOperator_h
19 #define itkAnnulusOperator_h
20 
22 #include "itkVector.h"
23 
24 namespace itk
25 {
68 template< typename TPixel, unsigned int TDimension = 2,
69  typename TAllocator = NeighborhoodAllocator< TPixel > >
70 class ITK_TEMPLATE_EXPORT AnnulusOperator:
71  public NeighborhoodOperator< TPixel, TDimension, TAllocator >
72 {
73 public:
74 
76  using Self = AnnulusOperator;
78 
80  using SizeType = typename Superclass::SizeType;
81  using OffsetType = typename Superclass::OffsetType;
82  using SpacingType = Vector< double, TDimension >;
83 
84  itkTypeMacro(AnnulusOperator, NeighborhoodOperator);
85 
87  NeighborhoodOperator< TPixel, TDimension, TAllocator >(),
88  m_InteriorValue(NumericTraits< PixelType >::ZeroValue()),
89  m_AnnulusValue(NumericTraits< PixelType >::OneValue()),
90  m_ExteriorValue(NumericTraits< PixelType >::ZeroValue()),
91  m_Spacing( 1.0 )
92  {}
93 
94  AnnulusOperator(const Self & other):
95  NeighborhoodOperator< TPixel, TDimension, TAllocator >(other),
96  m_InnerRadius( other.m_InnerRadius ),
97  m_Thickness( other.m_Thickness ),
98  m_Normalize( other.m_Normalize ),
99  m_BrightCenter( other.m_BrightCenter ),
100  m_InteriorValue( other.m_InteriorValue ),
101  m_AnnulusValue( other.m_AnnulusValue ),
102  m_ExteriorValue( other.m_ExteriorValue ),
103  m_Spacing( other.m_Spacing )
104  {
105  }
106 
109  void CreateOperator();
110 
113  void SetInnerRadius(double r)
114  { m_InnerRadius = r; }
115  double GetInnerRadius() const
116  { return m_InnerRadius; }
118 
122  void SetThickness(double t)
123  { m_Thickness = t; }
124  double GetThickness() const
125  { return m_Thickness; }
127 
130  void SetSpacing(SpacingType & s)
131  { m_Spacing = s; }
132  const SpacingType & GetSpacing() const
133  { return m_Spacing; }
135 
138  void SetNormalize(bool b)
139  { m_Normalize = b; }
140  bool GetNormalize() const
141  { return m_Normalize; }
142  void NormalizeOn()
143  { this->SetNormalize(true); }
144  void NormalizeOff()
145  { this->SetNormalize(false); }
147 
150  void SetBrightCenter(bool b)
151  { m_BrightCenter = b; }
152  bool GetBrightCenter() const
153  { return m_BrightCenter; }
154  void BrightCenterOn()
155  { this->SetBrightCenter(true); }
156  void BrightCenterOff()
157  { this->SetBrightCenter(false); }
159 
164  void SetInteriorValue(TPixel v)
165  { m_InteriorValue = v; }
166  TPixel GetInteriorValue() const
167  { return m_InteriorValue; }
168  void SetAnnulusValue(TPixel v)
169  { m_AnnulusValue = v; }
170  TPixel GetAnnulusValue() const
171  { return m_AnnulusValue; }
172  void SetExteriorValue(TPixel v)
173  { m_ExteriorValue = v; }
174  TPixel GetExteriorValue() const
175  { return m_ExteriorValue; }
177 
179  Self & operator=(const Self & other)
180  {
181  if(this != &other)
182  {
183  Superclass::operator=(other);
184  m_InnerRadius = other.m_InnerRadius;
185  m_Thickness = other.m_Thickness;
186  m_Spacing = other.m_Spacing;
187  m_InteriorValue = other.m_InteriorValue;
188  m_AnnulusValue = other.m_AnnulusValue;
189  m_ExteriorValue = other.m_ExteriorValue;
190  m_Normalize = other.m_Normalize;
191  m_BrightCenter = other.m_BrightCenter;
192  }
193  return *this;
194  }
196 
198  void PrintSelf(std::ostream & os, Indent i) const override
199  {
200  os << i << "AnnulusOperator { this=" << this
201  << ", m_InnerRadius = " << m_InnerRadius
202  << ", m_Thickness = " << m_Thickness
203  << ", m_Spacing = " << m_Spacing
204  << ", m_Normalize = " << m_Normalize
205  << ", m_BrightCenter = " << m_BrightCenter
206  << ", m_InteriorValue = " << m_InteriorValue
207  << ", m_ExteriorValue = " << m_ExteriorValue
208  << "}" << std::endl;
209  Superclass::PrintSelf( os, i.GetNextIndent() );
210  }
212 
213 protected:
214 
217  using CoefficientVector = typename Superclass::CoefficientVector;
218  using PixelType = typename Superclass::PixelType;
219 
221  CoefficientVector GenerateCoefficients() override;
222 
224  void Fill(const CoefficientVector & c) override;
225 
226 private:
227 
228  double m_InnerRadius{1.0};
229  double m_Thickness{ 1.0 };
230  bool m_Normalize{false};
231  bool m_BrightCenter{false};
232  PixelType m_InteriorValue;
233  PixelType m_AnnulusValue;
234  PixelType m_ExteriorValue;
235  SpacingType m_Spacing;
236 };
237 } // namespace itk
238 
239 #ifndef ITK_MANUAL_INSTANTIATION
240 #include "itkAnnulusOperator.hxx"
241 #endif
242 #endif
Define numeric traits for std::vector.
A NeighborhoodOperator for performing a matched filtering with an annulus (two concentric circles...