Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkModulusImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkModulusImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-01 14:36:31 $
00007   Version:   $Revision: 1.7 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkModulusImageFilter_h
00018 #define __itkModulusImageFilter_h
00019 
00020 #include "itkUnaryFunctorImageFilter.h"
00021 
00022 namespace itk
00023 {
00024 
00025 namespace Functor {  
00026  
00027 template< typename TInput, typename  TOutput>
00028 class ModulusTransform
00029 {
00030 public:
00031   ModulusTransform() {m_Dividend = 5;}
00032   ~ModulusTransform() {}
00033   void SetDividend( TOutput dividend ) { m_Dividend = dividend; }
00034 
00035   bool operator!=( const ModulusTransform & other ) const
00036     {
00037     if( m_Dividend != other.m_Dividend )
00038       {
00039       return true;
00040       }
00041     return false;
00042     }
00043 
00044   bool operator==( const ModulusTransform & other ) const
00045     {
00046     return !(*this != other);
00047     }
00048 
00049   inline TOutput operator()( const TInput & x ) const
00050     {
00051     TOutput  result = static_cast<TOutput>( x % m_Dividend );
00052     return result;
00053     }
00054 private:
00055   TInput  m_Dividend;
00056 }; 
00057 
00058 }  // end namespace functor
00059 
00060 
00071 template <typename  TInputImage, typename  TOutputImage=TInputImage>
00072 class ITK_EXPORT ModulusImageFilter :
00073     public
00074 UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00075                         Functor::ModulusTransform< 
00076   typename TInputImage::PixelType, 
00077   typename TOutputImage::PixelType>   >
00078 {
00079 public:
00081   typedef ModulusImageFilter               Self;
00082   typedef UnaryFunctorImageFilter<
00083     TInputImage,TOutputImage, 
00084     Functor::ModulusTransform< 
00085       typename TInputImage::PixelType, 
00086       typename TOutputImage::PixelType> >  Superclass;
00087   typedef SmartPointer<Self>               Pointer;
00088   typedef SmartPointer<const Self>         ConstPointer;
00089 
00090   typedef typename TOutputImage::PixelType                 OutputPixelType;
00091   typedef typename TInputImage::PixelType                  InputPixelType;
00092   typedef typename NumericTraits<InputPixelType>::RealType RealType;
00093 
00095   itkNewMacro(Self);
00096 
00098   itkTypeMacro(ModulusImageFilter, 
00099                UnaryFunctorImageFilter);
00100 
00102   itkSetMacro( Dividend, InputPixelType );
00103   itkGetConstReferenceMacro( Dividend, InputPixelType );
00105 
00107   void PrintSelf(std::ostream& os, Indent indent) const;
00108 
00110   void BeforeThreadedGenerateData(void);
00111 
00112 #ifdef ITK_USE_CONCEPT_CHECKING
00113 
00114   itkConceptMacro(InputHasNumericTraitsCheck,
00115                   (Concept::HasNumericTraits<InputPixelType>));
00116 
00118 #endif
00119 
00120 protected:
00121   ModulusImageFilter();
00122   virtual ~ModulusImageFilter() {};
00123 
00124 private:
00125   ModulusImageFilter(const Self&); //purposely not implemented
00126   void operator=(const Self&); //purposely not implemented
00127 
00128   InputPixelType        m_Dividend;
00129 };
00130 
00131 
00132   
00133 } // end namespace itk
00134   
00135 #ifndef ITK_MANUAL_INSTANTIATION
00136 #include "itkModulusImageFilter.txx"
00137 #endif
00138   
00139 #endif
00140 

Generated at Thu May 28 10:48:01 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000