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 )
00052 {
00053 return static_cast<TOutput>( A[m_I][m_J] );
00054 }
00055
00056 private:
00057 unsigned int m_I, m_J;
00058 };
00059 }
00060
00077 template <class TInputImage, class TOutputImage>
00078 class ITK_EXPORT MatrixIndexSelectionImageFilter :
00079 public
00080 UnaryFunctorImageFilter<TInputImage,TOutputImage,Functor::MatrixIndexSelection< typename TInputImage::PixelType,typename TOutputImage::PixelType> >
00081 {
00082 public:
00084 typedef MatrixIndexSelectionImageFilter Self;
00085 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage,Functor::MatrixIndexSelection<typename TInputImage::PixelType,typename TOutputImage::PixelType> > Superclass;
00086 typedef SmartPointer<Self> Pointer;
00087 typedef SmartPointer<const Self> ConstPointer;
00088
00090 itkTypeMacro( MatrixIndexSelectionImageFilter, UnaryFunctorImageFilter );
00091
00093 itkNewMacro(Self);
00094
00096 void SetIndices(unsigned int i, unsigned int j)
00097 {
00098 this->GetFunctor().SetIndices(i,j);
00099 this->Modified();
00100 }
00102
00103 void GetIndices(unsigned int& i, unsigned int& j) const
00104 { return this->GetFunctor().GetIndices(i,j); }
00105
00106 #ifdef ITK_USE_CONCEPT_CHECKING
00107
00108 itkConceptMacro(InputHasNumericTraitsCheck,
00109 (Concept::HasNumericTraits<typename TInputImage::PixelType::ValueType>));
00110
00112 #endif
00113
00114 protected:
00115 MatrixIndexSelectionImageFilter() {}
00116 virtual ~MatrixIndexSelectionImageFilter() {}
00117
00118 private:
00119 MatrixIndexSelectionImageFilter(const Self&);
00120 void operator=(const Self&);
00121 };
00122
00123 }
00124
00125
00126 #endif
00127