ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkNeighborhoodOperator.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 __itkNeighborhoodOperator_h
00019 #define __itkNeighborhoodOperator_h
00020 
00021 #include "itkNeighborhood.h"
00022 #include "itkNumericTraits.h"
00023 #include <vector>
00024 
00025 namespace itk
00026 {
00064 template< class TPixel, unsigned int VDimension,
00065           class TAllocator = NeighborhoodAllocator< TPixel > >
00066 class ITK_EXPORT NeighborhoodOperator:
00067   public Neighborhood< TPixel, VDimension, TAllocator >
00068 {
00069 public:
00071   typedef NeighborhoodOperator                           Self;
00072   typedef Neighborhood< TPixel, VDimension, TAllocator > Superclass;
00073 
00075   typedef typename Superclass::SizeType      SizeType;
00076 
00078   typedef TPixel PixelType;
00079 
00081   typedef SliceIterator< TPixel, Self > SliceIteratorType;
00082 
00084   NeighborhoodOperator()
00085   {  m_Direction = 0;  }
00086 
00088   NeighborhoodOperator(const Self & orig):
00089     Neighborhood< TPixel, VDimension, TAllocator >(orig)
00090   {   m_Direction = orig.m_Direction;   }
00091 
00093   Self & operator=(const Self & orig)
00094   {
00095     Superclass::operator=(orig);
00096     m_Direction = orig.m_Direction;
00097     return *this;
00098   }
00100 
00102   void SetDirection(const unsigned long & direction)
00103   {  m_Direction = direction;   }
00104 
00106   unsigned long GetDirection() const
00107   {  return m_Direction;  }
00108 
00113   virtual void CreateDirectional();
00114 
00119   virtual void CreateToRadius(const SizeType &);
00120 
00125   virtual void CreateToRadius(const SizeValueType);
00126 
00129   virtual void FlipAxes();
00130 
00132   virtual void PrintSelf(std::ostream & os, Indent i) const
00133   {
00134     os << i << "NeighborhoodOperator { this=" << this
00135        << " Direction = " << m_Direction << " }" << std::endl;
00136     Superclass::PrintSelf( os, i.GetNextIndent() );
00137   }
00139 
00140   typedef typename NumericTraits< TPixel >::RealType PixelRealType;
00141 
00144   void ScaleCoefficients(PixelRealType);
00145 protected:
00146 
00149   typedef std::vector< double > CoefficientVector;
00150 
00153   virtual CoefficientVector GenerateCoefficients() = 0;
00154 
00157   virtual void Fill(const CoefficientVector &) = 0;
00158 
00164   virtual void FillCenteredDirectional(const CoefficientVector &);
00165 
00167   void InitializeToZero()
00168   {
00169     for ( unsigned int i = 0; i < this->Size(); ++i )
00170       {
00171       this->operator[](i) = NumericTraits< PixelType >::Zero;
00172       }
00173   }
00175 
00176 private:
00178   unsigned long m_Direction;
00179 };
00180 } // namespace itk
00181 
00182 // Define instantiation macro for this template.
00183 #define ITK_TEMPLATE_NeighborhoodOperator(_, EXPORT, TypeX, TypeY)     \
00184   namespace itk                                                        \
00185   {                                                                    \
00186   _( 2 ( class EXPORT NeighborhoodOperator< ITK_TEMPLATE_2 TypeX > ) ) \
00187   namespace Templates                                                  \
00188   {                                                                    \
00189   typedef NeighborhoodOperator< ITK_TEMPLATE_2 TypeX >                 \
00190   NeighborhoodOperator##TypeY;                                       \
00191   }                                                                    \
00192   }
00193 
00194 #if ITK_TEMPLATE_EXPLICIT
00195 #include "Templates/itkNeighborhoodOperator+-.h"
00196 #endif
00197 
00198 #if ITK_TEMPLATE_TXX
00199 #include "itkNeighborhoodOperator.hxx"
00200 #endif
00201 
00202 /*
00203 #ifndef ITK_MANUAL_INSTANTIATION
00204 #include "itkNeighborhoodOperator.hxx"
00205 #endif
00206 */
00207 #endif
00208