ITK  5.3.0
Insight Toolkit
itkLabelObjectAccessors.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 itkLabelObjectAccessors_h
19 #define itkLabelObjectAccessors_h
20 
21 #include "itkMacro.h"
22 
23 /*
24  *
25  * This code was contributed in the Insight Journal paper:
26  * "Label object representation and manipulation with ITK"
27  * by Lehmann G.
28  * https://www.insight-journal.org/browse/publication/176
29  *
30  */
31 
32 namespace itk
33 {
34 namespace Functor
35 {
36 template <typename TLabelObject>
38 {
39 public:
40  using LabelObjectType = TLabelObject;
41  using AttributeValueType = typename LabelObjectType::LabelType;
42 
43  inline AttributeValueType
44  operator()(const LabelObjectType * labelObject) const
45  {
46  return labelObject->GetLabel();
47  }
48 };
49 
50 template <typename TLabelObject>
52 {
53 public:
54  using LabelObjectType = TLabelObject;
55  using AttributeValueType = int;
56 
57  inline AttributeValueType
58  operator()(const LabelObjectType * labelObject) const
59  {
60  return labelObject->GetNumberOfLines();
61  }
62 };
63 
64 template <typename TLabelObject, typename TAttributeAccessor>
66 {
67 public:
68  using LabelObjectType = TLabelObject;
69  using AttributeAccessorType = TAttributeAccessor;
70  bool
71  operator()(const LabelObjectType * a, const LabelObjectType * b) const
72  {
73  return m_Accessor(a) > m_Accessor(b);
74  }
75 
76  LabelObjectComparator() = default;
78 
79 private:
81 };
82 
83 template <typename TLabelObject, typename TAttributeAccessor>
85 {
86 public:
87  using LabelObjectType = TLabelObject;
88  using AttributeAccessorType = TAttributeAccessor;
89  bool
90  operator()(const LabelObjectType * a, const LabelObjectType * b) const
91  {
92  return m_Accessor(a) < m_Accessor(b);
93  }
94 
95  LabelObjectReverseComparator() = default;
97 
98 private:
100 };
101 } // namespace Functor
102 } // end namespace itk
103 
104 #endif
itk::Functor::LabelObjectReverseComparator::LabelObjectType
TLabelObject LabelObjectType
Definition: itkLabelObjectAccessors.h:87
itk::Functor::LabelObjectComparator::operator()
bool operator()(const LabelObjectType *a, const LabelObjectType *b) const
Definition: itkLabelObjectAccessors.h:71
itk::Functor::LabelLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkLabelObjectAccessors.h:40
itk::Functor::NumberOfLinesLabelObjectAccessor::AttributeValueType
int AttributeValueType
Definition: itkLabelObjectAccessors.h:55
itk::Functor::LabelLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkLabelObjectAccessors.h:44
itk::Functor::LabelObjectReverseComparator::LabelObjectReverseComparator
LabelObjectReverseComparator()=default
itk::Functor::LabelObjectComparator
Definition: itkLabelObjectAccessors.h:65
itk::Functor::LabelObjectComparator::AttributeAccessorType
TAttributeAccessor AttributeAccessorType
Definition: itkLabelObjectAccessors.h:69
itk::Functor::LabelObjectReverseComparator
Definition: itkLabelObjectAccessors.h:84
itk::Functor::LabelObjectReverseComparator::m_Accessor
AttributeAccessorType m_Accessor
Definition: itkLabelObjectAccessors.h:99
itk::Functor::LabelObjectReverseComparator::LabelObjectReverseComparator
LabelObjectReverseComparator(LabelObjectReverseComparator const &from)
Definition: itkLabelObjectAccessors.h:96
itkMacro.h
itk::Functor::LabelObjectComparator::LabelObjectComparator
LabelObjectComparator()=default
itk::Functor::NumberOfLinesLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkLabelObjectAccessors.h:54
itk::Functor::LabelObjectComparator::m_Accessor
AttributeAccessorType m_Accessor
Definition: itkLabelObjectAccessors.h:80
itk::Functor::NumberOfLinesLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkLabelObjectAccessors.h:58
itk::Functor::LabelObjectComparator::LabelObjectType
TLabelObject LabelObjectType
Definition: itkLabelObjectAccessors.h:68
itk::Functor::LabelObjectComparator::LabelObjectComparator
LabelObjectComparator(LabelObjectComparator const &from)
Definition: itkLabelObjectAccessors.h:77
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Functor::LabelObjectReverseComparator::AttributeAccessorType
TAttributeAccessor AttributeAccessorType
Definition: itkLabelObjectAccessors.h:88
itk::Functor::LabelObjectReverseComparator::operator()
bool operator()(const LabelObjectType *a, const LabelObjectType *b) const
Definition: itkLabelObjectAccessors.h:90
itk::Functor::LabelLabelObjectAccessor
Definition: itkLabelObjectAccessors.h:37
itk::Functor::NumberOfLinesLabelObjectAccessor
Definition: itkLabelObjectAccessors.h:51
itk::Functor::LabelLabelObjectAccessor::AttributeValueType
typename LabelObjectType::LabelType AttributeValueType
Definition: itkLabelObjectAccessors.h:41