ITK  5.0.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:
32  ~MatrixIndexSelection() = default;
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:
88  ITK_DISALLOW_COPY_AND_ASSIGN(MatrixIndexSelectionImageFilter);
89 
92  using Superclass = UnaryFunctorImageFilter< TInputImage, TOutputImage,
93  Functor::MatrixIndexSelection< typename TInputImage::PixelType,
94  typename TOutputImage::PixelType > >;
97 
100 
102  itkNewMacro(Self);
103 
105  void SetIndices(unsigned int i, unsigned int j)
106  {
107  this->GetFunctor().SetIndices(i, j);
108  this->Modified();
109  }
111 
112  void GetIndices(unsigned int & i, unsigned int & j) const
113  { return this->GetFunctor().GetIndices(i, j); }
114 
115 #ifdef ITK_USE_CONCEPT_CHECKING
116  // Begin concept checking
117  itkConceptMacro( InputHasNumericTraitsCheck,
119  // End concept checking
120 #endif
121 
122 protected:
124  ~MatrixIndexSelectionImageFilter() override = default;
125 };
126 } // end namespace itk
127 
128 #endif
void SetIndices(unsigned int i, unsigned int j)
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
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)
Templated n-dimensional image class.
Definition: itkImage.h:75
~MatrixIndexSelectionImageFilter() override=default