Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkMatrixIndexSelectionImageFilter_h
00018 #define __itkMatrixIndexSelectionImageFilter_h
00019
00020 #include "itkUnaryFunctorImageFilter.h"
00021
00022 namespace itk
00023 {
00024
00025 namespace Functor {
00026
00027 template< class TInput, class TOutput>
00028 class MatrixIndexSelection
00029 {
00030 public:
00031 MatrixIndexSelection() {m_I = m_J = 0;}
00032 ~MatrixIndexSelection() {}
00033
00034 void GetIndices(unsigned int& i, unsigned int& j) const {i= m_I; j=m_J;}
00035 void SetIndices(unsigned int i,unsigned int j) {m_I= i; m_J =j;}
00036
00037 bool operator!=( const MatrixIndexSelection & other ) const
00038 {
00039 if( m_I != other.m_I ||
00040 m_J != other.m_J )
00041 {
00042 return true;
00043 }
00044 return false;
00045 }
00046 bool operator==( const MatrixIndexSelection & other ) const
00047 {
00048 return !(*this != other);
00049 }
00050
00051 inline TOutput operator()( const TInput & A ) const
00052 {
00053 return static_cast<TOutput>( A[m_I][m_J] );
00054 }
00055
00056 private:
00057 unsigned int m_I;
00058 unsigned int m_J;
00059 };
00060 }
00061
00078 template <class TInputImage, class TOutputImage>
00079 class ITK_EXPORT MatrixIndexSelectionImageFilter :
00080 public
00081 UnaryFunctorImageFilter<TInputImage,TOutputImage,Functor::MatrixIndexSelection< typename TInputImage::PixelType,typename TOutputImage::PixelType> >
00082 {
00083 public:
00085 typedef MatrixIndexSelectionImageFilter Self;
00086 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage,Functor::MatrixIndexSelection<typename TInputImage::PixelType,typename TOutputImage::PixelType> > Superclass;
00087 typedef SmartPointer<Self> Pointer;
00088 typedef SmartPointer<const Self> ConstPointer;
00089
00091 itkTypeMacro( MatrixIndexSelectionImageFilter, UnaryFunctorImageFilter );
00092
00094 itkNewMacro(Self);
00095
00097 void SetIndices(unsigned int i, unsigned int j)
00098 {
00099 this->GetFunctor().SetIndices(i,j);
00100 this->Modified();
00101 }
00103
00104 void GetIndices(unsigned int& i, unsigned int& j) const
00105 { return this->GetFunctor().GetIndices(i,j); }
00106
00107 #ifdef ITK_USE_CONCEPT_CHECKING
00108
00109 itkConceptMacro(InputHasNumericTraitsCheck,
00110 (Concept::HasNumericTraits<typename TInputImage::PixelType::ValueType>));
00111
00113 #endif
00114
00115 protected:
00116 MatrixIndexSelectionImageFilter() {}
00117 virtual ~MatrixIndexSelectionImageFilter() {}
00118
00119 private:
00120 MatrixIndexSelectionImageFilter(const Self&);
00121 void operator=(const Self&);
00122 };
00123
00124 }
00125
00126
00127 #endif
00128