ITK  4.8.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< typename TInput, typename 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< typename TInputImage, typename 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  // Begin concept checking
118  itkConceptMacro( InputHasNumericTraitsCheck,
120  // End concept checking
121 #endif
122 
123 protected:
126 
127 private:
128  MatrixIndexSelectionImageFilter(const Self &); //purposely not implemented
129  void operator=(const Self &); //purposely not implemented
130 };
131 } // end namespace itk
132 
133 #endif
void SetIndices(unsigned int i, unsigned int j)
Base class for all process objects that output image data.
void GetIndices(unsigned int &i, unsigned int &j) const
virtual void Modified() const
bool operator!=(const MatrixIndexSelection &other) const
bool operator==(const MatrixIndexSelection &other) const
Implements pixel-wise generic operation on one image.
void GetIndices(unsigned int &i, unsigned int &j) const
void SetIndices(unsigned int i, unsigned int j)
Extracts the selected indices of a matrix image that is the input pixel type.
#define itkConceptMacro(name, concept)
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::MatrixIndexSelection< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass