ITK  4.9.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 AnnulusOperator:
71  public NeighborhoodOperator< TPixel, TDimension, TAllocator >
72 {
73 public:
74 
76  typedef AnnulusOperator Self;
78 
80  typedef typename Superclass::SizeType SizeType;
81  typedef typename Superclass::OffsetType OffsetType;
82  typedef Vector< double, TDimension > SpacingType;
83 
84  itkTypeMacro(AnnulusOperator, NeighborhoodOperator);
85 
87  NeighborhoodOperator< TPixel, TDimension, TAllocator >(),
88  m_InnerRadius(1.0),
89  m_Thickness( 1.0 ),
90  m_Normalize(false),
91  m_BrightCenter(false),
92  m_InteriorValue(NumericTraits< PixelType >::ZeroValue()),
93  m_AnnulusValue(NumericTraits< PixelType >::OneValue()),
94  m_ExteriorValue(NumericTraits< PixelType >::ZeroValue()),
95  m_Spacing( 1.0 )
96  {}
97 
98  AnnulusOperator(const Self & other):
99  NeighborhoodOperator< TPixel, TDimension, TAllocator >(other),
100  m_InnerRadius( other.m_InnerRadius ),
101  m_Thickness( other.m_Thickness ),
102  m_Normalize( other.m_Normalize ),
103  m_BrightCenter( other.m_BrightCenter ),
104  m_InteriorValue( other.m_InteriorValue ),
105  m_AnnulusValue( other.m_AnnulusValue ),
106  m_ExteriorValue( other.m_ExteriorValue ),
107  m_Spacing( other.m_Spacing )
108  {
109  }
110 
113  void CreateOperator();
114 
117  void SetInnerRadius(double r)
118  { m_InnerRadius = r; }
119  double GetInnerRadius() const
120  { return m_InnerRadius; }
122 
126  void SetThickness(double t)
127  { m_Thickness = t; }
128  double GetThickness() const
129  { return m_Thickness; }
131 
134  void SetSpacing(SpacingType & s)
135  { m_Spacing = s; }
136  const SpacingType & GetSpacing() const
137  { return m_Spacing; }
139 
142  void SetNormalize(bool b)
143  { m_Normalize = b; }
144  bool GetNormalize() const
145  { return m_Normalize; }
146  void NormalizeOn()
147  { this->SetNormalize(true); }
148  void NormalizeOff()
149  { this->SetNormalize(false); }
151 
154  void SetBrightCenter(bool b)
155  { m_BrightCenter = b; }
156  bool GetBrightCenter() const
157  { return m_BrightCenter; }
158  void BrightCenterOn()
159  { this->SetBrightCenter(true); }
160  void BrightCenterOff()
161  { this->SetBrightCenter(false); }
163 
168  void SetInteriorValue(TPixel v)
169  { m_InteriorValue = v; }
170  TPixel GetInteriorValue() const
171  { return m_InteriorValue; }
172  void SetAnnulusValue(TPixel v)
173  { m_AnnulusValue = v; }
174  TPixel GetAnnulusValue() const
175  { return m_AnnulusValue; }
176  void SetExteriorValue(TPixel v)
177  { m_ExteriorValue = v; }
178  TPixel GetExteriorValue() const
179  { return m_ExteriorValue; }
181 
183  Self & operator=(const Self & other)
184  {
185  if(this != &other)
186  {
187  Superclass::operator=(other);
188  m_InnerRadius = other.m_InnerRadius;
189  m_Thickness = other.m_Thickness;
190  m_Spacing = other.m_Spacing;
191  m_InteriorValue = other.m_InteriorValue;
192  m_AnnulusValue = other.m_AnnulusValue;
193  m_ExteriorValue = other.m_ExteriorValue;
194  m_Normalize = other.m_Normalize;
195  m_BrightCenter = other.m_BrightCenter;
196  }
197  return *this;
198  }
200 
202  virtual void PrintSelf(std::ostream & os, Indent i) const ITK_OVERRIDE
203  {
204  os << i << "AnnulusOperator { this=" << this
205  << ", m_InnerRadius = " << m_InnerRadius
206  << ", m_Thickness = " << m_Thickness
207  << ", m_Spacing = " << m_Spacing
208  << ", m_Normalize = " << m_Normalize
209  << ", m_BrightCenter = " << m_BrightCenter
210  << ", m_InteriorValue = " << m_InteriorValue
211  << ", m_ExteriorValue = " << m_ExteriorValue
212  << "}" << std::endl;
213  Superclass::PrintSelf( os, i.GetNextIndent() );
214  }
216 
217 protected:
218 
221  typedef typename Superclass::CoefficientVector CoefficientVector;
222  typedef typename Superclass::PixelType PixelType;
223 
225  CoefficientVector GenerateCoefficients() ITK_OVERRIDE;
226 
228  void Fill(const CoefficientVector & c) ITK_OVERRIDE;
229 
230 private:
231 
232  double m_InnerRadius;
233  double m_Thickness;
234  bool m_Normalize;
235  bool m_BrightCenter;
236  PixelType m_InteriorValue;
237  PixelType m_AnnulusValue;
238  PixelType m_ExteriorValue;
239  SpacingType m_Spacing;
240 };
241 } // namespace itk
242 
243 #ifndef ITK_MANUAL_INSTANTIATION
244 #include "itkAnnulusOperator.hxx"
245 #endif
246 #endif
A NeighborhoodOperator for performing a matched filtering with an annulus (two concentric circles...