KWStyle - itkAnnulusOperator.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkAnnulusOperator.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:32 $
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
18 #ifndef __itkAnnulusOperator_h
19 #define __itkAnnulusOperator_h
20
21 #include "itkExceptionObject.h"
22 #include "itkNeighborhoodOperator.h"
23 #include "itkVector.h"
24
25 namespace itk {
26
27 /**
28  * \class AnnulusOperator
29  *
30  * \brief A NeighborhoodOperator for performing a matched filtering with an 
31  * annulus (two concentric circles, spheres, hyperspheres, etc.)
32  *
33  * AnnulusOperator defines a non-directional NeighborhoodOperator
34  * representing two concentric circles, spheres, hyperspheres, etc.
35  * The inner radius and the thickness of the annulus can be specified.
36  *
37  * The values for the annulus can be specified in a variety of
38  * manners:
39  *
40  * 1) The values for the interior of the annulus (interior of inner
41  * circle), the values for annulus (the region between the inner and
42  * outer circle), and the values for the exterior of the annulus can
43  * be specified.  This mode is useful in correlation based matched
44  * filter applications. For instance, defining a hollow (or even
45  * filled) circle.
46  *
47  * 2) The values can defined automatically for normalized
48  * correlation. The values in the kernel will be defined to have mean
49  * zero and norm 1.  The area outside the annulus will have values
50  * of zero. In this mode, you can also specify whether you want the
51  * center of the annulus to be bright (intensity > 0) or dark
52  * (intensity < 0).
53  *
54  * 1) Set the annulus parameters: InnerRadius and Thickness
55  * 2) Set the intensities to use for interior, wall, and exterior
56  * kernel positions for correlation based operations or call
57  * NormalizeOn() to define kernel values automatically for use in
58  * normalized correlation.
59  * 3) If NormalizedOn(), indicate whether you want the center of the
60  * annulus to be bright or dark.
61  * 4) call \c CreateOperator() 
62  *
63  * \sa NeighborhoodOperator
64  * \sa Neighborhood
65  * 
66  * \ingroup Operators
67  */
68 template<class TPixel, unsigned int VDimension=2,
69   class TAllocator = NeighborhoodAllocator<TPixel> >
70 class ITK_EXPORT AnnulusOperator
71 IND **: public NeighborhoodOperator<TPixel, VDimension, TAllocator>
72 {
73 public:
74   /** Standard typedefs */
75   typedef AnnulusOperator Self;
76 TDA   typedef NeighborhoodOperator<TPixel, VDimension, TAllocator>  Superclass;
77
78   /** Additional typedefs */
79   typedef typename Superclass::SizeType SizeType;
80 TDA   typedef typename Superclass::OffsetType OffsetType;
81 TDA   typedef Vector<double, VDimension> SpacingType;
82   
83   itkTypeMacro(AnnulusOperator, NeighborhoodOperator);
84   
85   AnnulusOperator()
86 IND ****: NeighborhoodOperator<TPixel, VDimension, TAllocator>(),
87 IND ******m_Normalize(false), m_BrightCenter(false),
88 IND ******m_InteriorValue(NumericTraits<PixelType>::Zero),
89 IND ******m_AnnulusValue(NumericTraits<PixelType>::One),
90 IND ******m_ExteriorValue(NumericTraits<PixelType>::Zero)
91     { m_Spacing.Fill(1.0); }
92
93   AnnulusOperator(const Self& other)
94 IND ****: NeighborhoodOperator<TPixel, VDimension, TAllocator>(other)
95     {
96     m_InnerRadius = other.m_InnerRadius;
97     m_Thickness = other.m_Thickness;
98     m_Spacing = other.m_Spacing;
99     m_InteriorValue = other.m_InteriorValue;
100     m_AnnulusValue = other.m_AnnulusValue;
101     m_ExteriorValue = other.m_ExteriorValue;
102     m_Normalize = other.m_Normalize;
103     m_BrightCenter = other.m_BrightCenter;
104     }
105
106   /** This function is called to create the operator.  The radius of
107    * the operator is determine automatically.  */ 
108   void CreateOperator();  
109
110   /** Set/Get the inner radius of the annulus. Radius is specified in
111    * physical units (mm). */
112   void SetInnerRadius(double r)
113     { m_InnerRadius = r; }
114   double GetInnerRadius() const
115     { return m_InnerRadius; }
116
117   /** Set/Get the thickness of the annulus.  The outer radius of the
118    * annulus is defined as r = InnerRadius + Thickness. Thickness is
119    * specified in physical units (mm). */
120   void SetThickness(double t)
121     { m_Thickness = t; }
122   double GetThickness() const
123     { return m_Thickness; }
124
125   /** Set/Get the pixel spacings.  Setting these ensures the annulus
126    * is round in physical space. Defaults to 1. */
127   void SetSpacing(SpacingType &s)
128     { m_Spacing = s; }
129   const SpacingType& GetSpacing() const
130     { return m_Spacing; }
131   
132   /** Set/Get whether kernel values are computed automatically or
133    * specified manually */
134   void SetNormalize(bool b)
135     { m_Normalize = b; }
136   bool GetNormalize() const
137     { return m_Normalize; }
138   void NormalizeOn()
139     { this->SetNormalize(true); }
140   void NormalizeOff()
141     { this->SetNormalize(false); }
142
143   /** If Normalize is on, you define the annulus to have a bright
144    * center or a dark center. */
145   void SetBrightCenter(bool b)
146     { m_BrightCenter = b; }
147   bool GetBrightCenter() const
148     { return m_BrightCenter; }
149   void BrightCenterOn()
150     { this->SetBrightCenter(true); }
151   void BrightCenterOff()
152     { this->SetBrightCenter(false); }
153
154   /** If Normalize is off, the interior to annulus, the
155    * annulus (region between the two circles), and the region exterior to the
156    * annulus to be defined manually.  Defauls are 0, 1, 0
157    * respectively. */
158   void SetInteriorValue(TPixel v)
159     { m_InteriorValue = v; }
160   TPixel GetInteriorValue() const
161     { return m_InteriorValue; }
162   void SetAnnulusValue(TPixel v)
163     { m_AnnulusValue = v; }
164   TPixel GetAnnulusValue() const
165     { return m_AnnulusValue; }
166   void SetExteriorValue(TPixel v)
167     { m_ExteriorValue = v; }
168   TPixel GetExteriorValue() const
169     { return m_ExteriorValue; }
170   
171   /**
172    * Assignment operator
173    */
174   Self &operator=(const Self& other)
175 IND **{
176     Superclass::operator=(other);
177     m_InnerRadius = other.m_InnerRadius;
178     m_Thickness = other.m_Thickness;
179     m_Spacing = other.m_Spacing;
180     m_InteriorValue = other.m_InteriorValue;
181     m_AnnulusValue = other.m_AnnulusValue;
182     m_ExteriorValue = other.m_ExteriorValue;
183     m_Normalize = other.m_Normalize;
184     m_BrightCenter = other.m_BrightCenter;
185     return *this;
186 IND **}
187   /**
188    * Prints some debugging information
189    */
190   virtual void PrintSelf(std::ostream &os, Indent i) const  
191 IND **{ 
192     os << i << "AnnulusOperator { this=" << this
193 IND *******<< ", m_InnerRadius = " << m_InnerRadius
194 IND *******<< ", m_Thickness = " << m_Thickness
195 IND *******<< ", m_Spacing = " << m_Spacing 
196 IND *******<< ", m_Normalize = " << m_Normalize  
197 IND *******<< ", m_BrightCenter = " << m_BrightCenter
198 IND *******<< ", m_InteriorValue = " << m_InteriorValue
199 IND *******<< ", m_ExteriorValue = " << m_ExteriorValue
200 IND *******<< "}" << std::endl;
201     Superclass::PrintSelf(os, i.GetNextIndent());
202 IND **}
203
204   
205 protected:
206   /**
207    * Typedef support for coefficient vector type.  Necessary to
208    * work around compiler bug on VC++.
209    */
210   typedef typename Superclass::CoefficientVector CoefficientVector;
211 TDA   typedef typename Superclass::PixelType PixelType;
212
213   /**
214    * Calculates operator coefficients.
215    */
216   CoefficientVector GenerateCoefficients();
217
218   /**
219    * Arranges coefficients spatially in the memory buffer.
220    */
221   void Fill(const CoefficientVector &c);
222
223 private:
224   double m_InnerRadius;
225   double m_Thickness;
226   bool m_Normalize;
227   bool m_BrightCenter;
228   PixelType m_InteriorValue;
229   PixelType m_AnnulusValue;
230   PixelType m_ExteriorValue;
231   SpacingType m_Spacing;
232 };
233
234 // namespace itk
235
236 #ifndef ITK_MANUAL_INSTANTIATION
237 #include "itkAnnulusOperator.txx"
238 #endif
239
240 #endif
241
242 EOF
243 EOF,EML

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