00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 )
00050 {
00051 TOutput result = static_cast<TOutput>( x % m_Dividend );
00052 return result;
00053 }
00054 private:
00055 TInput m_Dividend;
00056 };
00057
00058 }
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<TInputImage,TOutputImage,
00083 Functor::ModulusTransform<
00084 typename TInputImage::PixelType,
00085 typename TOutputImage::PixelType> > Superclass;
00086 typedef SmartPointer<Self> Pointer;
00087 typedef SmartPointer<const Self> ConstPointer;
00088
00089 typedef typename TOutputImage::PixelType OutputPixelType;
00090 typedef typename TInputImage::PixelType InputPixelType;
00091 typedef typename NumericTraits<InputPixelType>::RealType RealType;
00092
00094 itkNewMacro(Self);
00095
00097 itkTypeMacro(ModulusImageFilter,
00098 UnaryFunctorImageFilter);
00099
00101 itkSetMacro( Dividend, InputPixelType );
00102 itkGetConstReferenceMacro( Dividend, InputPixelType );
00104
00106 void PrintSelf(std::ostream& os, Indent indent) const;
00107
00109 void BeforeThreadedGenerateData(void);
00110
00111 #ifdef ITK_USE_CONCEPT_CHECKING
00112
00113 itkConceptMacro(InputHasNumericTraitsCheck,
00114 (Concept::HasNumericTraits<InputPixelType>));
00115
00117 #endif
00118
00119 protected:
00120 ModulusImageFilter();
00121 virtual ~ModulusImageFilter() {};
00122
00123 private:
00124 ModulusImageFilter(const Self&);
00125 void operator=(const Self&);
00126
00127 InputPixelType m_Dividend;
00128 };
00129
00130
00131
00132 }
00133
00134 #ifndef ITK_MANUAL_INSTANTIATION
00135 #include "itkModulusImageFilter.txx"
00136 #endif
00137
00138 #endif
00139