ITK  5.2.0
Insight Toolkit
itkMatrixIndexSelectionImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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
35  GetIndices(unsigned int & i, unsigned int & j) const
36  {
37  i = m_I;
38  j = m_J;
39  }
40  void
41  SetIndices(unsigned int i, unsigned int j)
42  {
43  m_I = i;
44  m_J = j;
45  }
46 
47  bool
48  operator!=(const MatrixIndexSelection & other) const
49  {
50  if (m_I != other.m_I || m_J != other.m_J)
51  {
52  return true;
53  }
54  return false;
55  }
56 
57  bool
58  operator==(const MatrixIndexSelection & other) const
59  {
60  return !(*this != other);
61  }
62 
63  inline TOutput
64  operator()(const TInput & A) const
65  {
66  return static_cast<TOutput>(A[m_I][m_J]);
67  }
68 
69 private:
70  unsigned int m_I;
71  unsigned int m_J;
72 };
73 } // namespace Functor
74 
92 template <typename TInputImage, typename TOutputImage>
94  : public UnaryFunctorImageFilter<
95  TInputImage,
96  TOutputImage,
97  Functor::MatrixIndexSelection<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
98 {
99 public:
100  ITK_DISALLOW_COPY_AND_MOVE(MatrixIndexSelectionImageFilter);
101 
105  TInputImage,
106  TOutputImage,
110 
113 
115  itkNewMacro(Self);
116 
118  void
119  SetIndices(unsigned int i, unsigned int j)
120  {
121  this->GetFunctor().SetIndices(i, j);
122  this->Modified();
123  }
125 
126  void
127  GetIndices(unsigned int & i, unsigned int & j) const
128  {
129  return this->GetFunctor().GetIndices(i, j);
130  }
131 
132 #ifdef ITK_USE_CONCEPT_CHECKING
133  // Begin concept checking
135  // End concept checking
136 #endif
137 
138 protected:
140  ~MatrixIndexSelectionImageFilter() override = default;
141 };
142 } // end namespace itk
143 
144 #endif
itk::Functor::MatrixIndexSelection::~MatrixIndexSelection
~MatrixIndexSelection()=default
itkUnaryFunctorImageFilter.h
itk::Functor::MatrixIndexSelection::m_J
unsigned int m_J
Definition: itkMatrixIndexSelectionImageFilter.h:71
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:714
itk::UnaryFunctorImageFilter
Implements pixel-wise generic operation on one image.
Definition: itkUnaryFunctorImageFilter.h:50
itk::Functor::MatrixIndexSelection::operator!=
bool operator!=(const MatrixIndexSelection &other) const
Definition: itkMatrixIndexSelectionImageFilter.h:48
itk::Functor::MatrixIndexSelection::operator==
bool operator==(const MatrixIndexSelection &other) const
Definition: itkMatrixIndexSelectionImageFilter.h:58
itk::MatrixIndexSelectionImageFilter
Extracts the selected indices of a matrix image that is the input pixel type.
Definition: itkMatrixIndexSelectionImageFilter.h:93
itk::SmartPointer< Self >
itk::Functor::MatrixIndexSelection::SetIndices
void SetIndices(unsigned int i, unsigned int j)
Definition: itkMatrixIndexSelectionImageFilter.h:41
itk::Functor::MatrixIndexSelection::GetIndices
void GetIndices(unsigned int &i, unsigned int &j) const
Definition: itkMatrixIndexSelectionImageFilter.h:35
itk::MatrixIndexSelectionImageFilter::~MatrixIndexSelectionImageFilter
~MatrixIndexSelectionImageFilter() override=default
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::Functor::MatrixIndexSelection
Definition: itkMatrixIndexSelectionImageFilter.h:28
itk::Functor::MatrixIndexSelection::MatrixIndexSelection
MatrixIndexSelection()
Definition: itkMatrixIndexSelectionImageFilter.h:31
itk::MatrixIndexSelectionImageFilter::GetIndices
void GetIndices(unsigned int &i, unsigned int &j) const
Definition: itkMatrixIndexSelectionImageFilter.h:127
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::MatrixIndexSelectionImageFilter::MatrixIndexSelectionImageFilter
MatrixIndexSelectionImageFilter()=default
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::MatrixIndexSelection< TInputImage::PixelType, TOutputImage::PixelType > >::GetFunctor
FunctorType & GetFunctor()
Definition: itkUnaryFunctorImageFilter.h:85
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::Functor::MatrixIndexSelection::operator()
TOutput operator()(const TInput &A) const
Definition: itkMatrixIndexSelectionImageFilter.h:64
itk::Object::Modified
virtual void Modified() const
itk::Functor::MatrixIndexSelection::m_I
unsigned int m_I
Definition: itkMatrixIndexSelectionImageFilter.h:70
itk::MatrixIndexSelectionImageFilter::SetIndices
void SetIndices(unsigned int i, unsigned int j)
Definition: itkMatrixIndexSelectionImageFilter.h:119