ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkAnnulusOperator.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkAnnulusOperator_h
00019 #define __itkAnnulusOperator_h
00020 
00021 #include "itkNeighborhoodOperator.h"
00022 #include "itkVector.h"
00023 
00024 namespace itk
00025 {
00068 template< class TPixel, unsigned int TDimension = 2,
00069           class TAllocator = NeighborhoodAllocator< TPixel > >
00070 class ITK_EXPORT AnnulusOperator:
00071   public NeighborhoodOperator< TPixel, TDimension, TAllocator >
00072 {
00073 public:
00074 
00076   typedef AnnulusOperator                                        Self;
00077   typedef NeighborhoodOperator< TPixel, TDimension, TAllocator > Superclass;
00078 
00080   typedef typename Superclass::SizeType      SizeType;
00081   typedef typename Superclass::OffsetType    OffsetType;
00082   typedef Vector< double, TDimension >       SpacingType;
00083 
00084   itkTypeMacro(AnnulusOperator, NeighborhoodOperator);
00085 
00086   AnnulusOperator():
00087     NeighborhoodOperator< TPixel, TDimension, TAllocator >(),
00088     m_Normalize(false), m_BrightCenter(false),
00089     m_InteriorValue(NumericTraits< PixelType >::Zero),
00090     m_AnnulusValue(NumericTraits< PixelType >::One),
00091     m_ExteriorValue(NumericTraits< PixelType >::Zero)
00092   { m_Spacing.Fill(1.0); }
00093 
00094   AnnulusOperator(const Self & other):
00095     NeighborhoodOperator< TPixel, TDimension, TAllocator >(other)
00096   {
00097     m_InnerRadius = other.m_InnerRadius;
00098     m_Thickness = other.m_Thickness;
00099     m_Spacing = other.m_Spacing;
00100     m_InteriorValue = other.m_InteriorValue;
00101     m_AnnulusValue = other.m_AnnulusValue;
00102     m_ExteriorValue = other.m_ExteriorValue;
00103     m_Normalize = other.m_Normalize;
00104     m_BrightCenter = other.m_BrightCenter;
00105   }
00106 
00109   void CreateOperator();
00110 
00113   void SetInnerRadius(double r)
00114   { m_InnerRadius = r; }
00115   double GetInnerRadius() const
00116   { return m_InnerRadius; }
00118 
00122   void SetThickness(double t)
00123   { m_Thickness = t; }
00124   double GetThickness() const
00125   { return m_Thickness; }
00127 
00130   void SetSpacing(SpacingType & s)
00131   { m_Spacing = s; }
00132   const SpacingType & GetSpacing() const
00133   { return m_Spacing; }
00135 
00138   void SetNormalize(bool b)
00139   { m_Normalize = b; }
00140   bool GetNormalize() const
00141   { return m_Normalize; }
00142   void NormalizeOn()
00143   { this->SetNormalize(true); }
00144   void NormalizeOff()
00145   { this->SetNormalize(false); }
00147 
00150   void SetBrightCenter(bool b)
00151   { m_BrightCenter = b; }
00152   bool GetBrightCenter() const
00153   { return m_BrightCenter; }
00154   void BrightCenterOn()
00155   { this->SetBrightCenter(true); }
00156   void BrightCenterOff()
00157   { this->SetBrightCenter(false); }
00159 
00164   void SetInteriorValue(TPixel v)
00165   { m_InteriorValue = v; }
00166   TPixel GetInteriorValue() const
00167   { return m_InteriorValue; }
00168   void SetAnnulusValue(TPixel v)
00169   { m_AnnulusValue = v; }
00170   TPixel GetAnnulusValue() const
00171   { return m_AnnulusValue; }
00172   void SetExteriorValue(TPixel v)
00173   { m_ExteriorValue = v; }
00174   TPixel GetExteriorValue() const
00175   { return m_ExteriorValue; }
00177 
00179   Self & operator=(const Self & other)
00180   {
00181     Superclass::operator=(other);
00182     m_InnerRadius = other.m_InnerRadius;
00183     m_Thickness = other.m_Thickness;
00184     m_Spacing = other.m_Spacing;
00185     m_InteriorValue = other.m_InteriorValue;
00186     m_AnnulusValue = other.m_AnnulusValue;
00187     m_ExteriorValue = other.m_ExteriorValue;
00188     m_Normalize = other.m_Normalize;
00189     m_BrightCenter = other.m_BrightCenter;
00190     return *this;
00191   }
00193 
00195   virtual void PrintSelf(std::ostream & os, Indent i) const
00196   {
00197     os << i << "AnnulusOperator { this=" << this
00198        << ", m_InnerRadius = " << m_InnerRadius
00199        << ", m_Thickness = " << m_Thickness
00200        << ", m_Spacing = " << m_Spacing
00201        << ", m_Normalize = " << m_Normalize
00202        << ", m_BrightCenter = " << m_BrightCenter
00203        << ", m_InteriorValue = " << m_InteriorValue
00204        << ", m_ExteriorValue = " << m_ExteriorValue
00205        << "}" << std::endl;
00206     Superclass::PrintSelf( os, i.GetNextIndent() );
00207   }
00209 
00210 protected:
00211 
00214   typedef typename Superclass::CoefficientVector CoefficientVector;
00215   typedef typename Superclass::PixelType         PixelType;
00216 
00218   CoefficientVector GenerateCoefficients();
00219 
00221   void Fill(const CoefficientVector & c);
00222 
00223 private:
00224 
00225   double      m_InnerRadius;
00226   double      m_Thickness;
00227   bool        m_Normalize;
00228   bool        m_BrightCenter;
00229   PixelType   m_InteriorValue;
00230   PixelType   m_AnnulusValue;
00231   PixelType   m_ExteriorValue;
00232   SpacingType m_Spacing;
00233 };
00234 } // namespace itk
00235 
00236 // Define instantiation macro for this template.
00237 #define ITK_TEMPLATE_AnnulusOperator(_, EXPORT, TypeX, TypeY)     \
00238   namespace itk                                                   \
00239   {                                                               \
00240   _( 2 ( class EXPORT AnnulusOperator< ITK_TEMPLATE_2 TypeX > ) ) \
00241   namespace Templates                                             \
00242   {                                                               \
00243   typedef AnnulusOperator< ITK_TEMPLATE_2 TypeX >                 \
00244   AnnulusOperator##TypeY;                                       \
00245   }                                                               \
00246   }
00247 
00248 #if ITK_TEMPLATE_EXPLICIT
00249 #include "Templates/itkAnnulusOperator+-.h"
00250 #endif
00251 
00252 #if ITK_TEMPLATE_TXX
00253 #include "itkAnnulusOperator.hxx"
00254 #endif
00255 
00256 #endif
00257