ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkMatrixIndexSelectionImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkMatrixIndexSelectionImageFilter_h
19 #define __itkMatrixIndexSelectionImageFilter_h
20 
22 
23 namespace itk
24 {
25 namespace Functor
26 {
27 template< class TInput, class TOutput >
29 {
30 public:
33 
34  void GetIndices(unsigned int & i, unsigned int & j) const { i = m_I; j = m_J; }
35  void SetIndices(unsigned int i, unsigned int j) { m_I = i; m_J = j; }
36 
37  bool operator!=(const MatrixIndexSelection & other) const
38  {
39  if ( m_I != other.m_I
40  || m_J != other.m_J )
41  {
42  return true;
43  }
44  return false;
45  }
46 
47  bool operator==(const MatrixIndexSelection & other) const
48  {
49  return !( *this != other );
50  }
51 
52  inline TOutput operator()(const TInput & A) const
53  {
54  return static_cast< TOutput >( A[m_I][m_J] );
55  }
56 
57 private:
58  unsigned int m_I;
59  unsigned int m_J;
60 };
61 }
62 
80 template< class TInputImage, class TOutputImage >
82  public
83  UnaryFunctorImageFilter< TInputImage, TOutputImage,
84  Functor::MatrixIndexSelection< typename TInputImage::PixelType,
85  typename TOutputImage::PixelType > >
86 {
87 public:
91  typedef UnaryFunctorImageFilter< TInputImage, TOutputImage,
92  Functor::MatrixIndexSelection< typename TInputImage::PixelType,
93  typename TOutputImage::PixelType > > Superclass;
94  typedef SmartPointer< Self >
98 
101 
103  itkNewMacro(Self);
104 
106  void SetIndices(unsigned int i, unsigned int j)
107  {
108  this->GetFunctor().SetIndices(i, j);
109  this->Modified();
110  }
112 
113  void GetIndices(unsigned int & i, unsigned int & j) const
114  { return this->GetFunctor().GetIndices(i, j); }
115 
116 #ifdef ITK_USE_CONCEPT_CHECKING
117 
118  itkConceptMacro( InputHasNumericTraitsCheck,
120 
122 #endif
123 
124 protected:
127 
128 private:
129  MatrixIndexSelectionImageFilter(const Self &); //purposely not implemented
130  void operator=(const Self &); //purposely not implemented
131 };
132 } // end namespace itk
133 
134 #endif
135