ITK  5.2.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://hdl.handle.net/1926/584
29  * http://www.insight-journal.org/browse/publication/176
30  *
31  */
32 
33 namespace itk
34 {
35 namespace Functor
36 {
37 template <typename TLabelObject>
39 {
40 public:
41  using LabelObjectType = TLabelObject;
42  using AttributeValueType = typename LabelObjectType::LabelType;
43 
44  inline AttributeValueType
45  operator()(const LabelObjectType * labelObject) const
46  {
47  return labelObject->GetLabel();
48  }
49 };
50 
51 template <typename TLabelObject>
53 {
54 public:
55  using LabelObjectType = TLabelObject;
56  using AttributeValueType = int;
57 
58  inline AttributeValueType
59  operator()(const LabelObjectType * labelObject) const
60  {
61  return labelObject->GetNumberOfLines();
62  }
63 };
64 
65 template <typename TLabelObject, typename TAttributeAccessor>
67 {
68 public:
69  using LabelObjectType = TLabelObject;
70  using AttributeAccessorType = TAttributeAccessor;
71  bool
72  operator()(const LabelObjectType * a, const LabelObjectType * b) const
73  {
74  return m_Accessor(a) > m_Accessor(b);
75  }
76 
77  LabelObjectComparator() = default;
79 
80 private:
82 };
83 
84 template <typename TLabelObject, typename TAttributeAccessor>
86 {
87 public:
88  using LabelObjectType = TLabelObject;
89  using AttributeAccessorType = TAttributeAccessor;
90  bool
91  operator()(const LabelObjectType * a, const LabelObjectType * b) const
92  {
93  return m_Accessor(a) < m_Accessor(b);
94  }
95 
96  LabelObjectReverseComparator() = default;
98 
99 private:
101 };
102 } // namespace Functor
103 } // end namespace itk
104 
105 #endif
itk::Functor::LabelObjectReverseComparator::LabelObjectType
TLabelObject LabelObjectType
Definition: itkLabelObjectAccessors.h:88
itk::Functor::LabelObjectComparator::operator()
bool operator()(const LabelObjectType *a, const LabelObjectType *b) const
Definition: itkLabelObjectAccessors.h:72
itk::Functor::LabelLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkLabelObjectAccessors.h:41
itk::Functor::NumberOfLinesLabelObjectAccessor::AttributeValueType
int AttributeValueType
Definition: itkLabelObjectAccessors.h:56
itk::Functor::LabelLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkLabelObjectAccessors.h:45
itk::Functor::LabelObjectReverseComparator::LabelObjectReverseComparator
LabelObjectReverseComparator()=default
itk::Functor::LabelObjectComparator
Definition: itkLabelObjectAccessors.h:66
itk::Functor::LabelObjectComparator::AttributeAccessorType
TAttributeAccessor AttributeAccessorType
Definition: itkLabelObjectAccessors.h:70
itk::Functor::LabelObjectReverseComparator
Definition: itkLabelObjectAccessors.h:85
itk::Functor::LabelObjectReverseComparator::m_Accessor
AttributeAccessorType m_Accessor
Definition: itkLabelObjectAccessors.h:100
itk::Functor::LabelObjectReverseComparator::LabelObjectReverseComparator
LabelObjectReverseComparator(LabelObjectReverseComparator const &from)
Definition: itkLabelObjectAccessors.h:97
itkMacro.h
itk::Functor::LabelObjectComparator::LabelObjectComparator
LabelObjectComparator()=default
itk::Functor::NumberOfLinesLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkLabelObjectAccessors.h:55
itk::Functor::LabelObjectComparator::m_Accessor
AttributeAccessorType m_Accessor
Definition: itkLabelObjectAccessors.h:81
itk::Functor::NumberOfLinesLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkLabelObjectAccessors.h:59
itk::Functor::LabelObjectComparator::LabelObjectType
TLabelObject LabelObjectType
Definition: itkLabelObjectAccessors.h:69
itk::Functor::LabelObjectComparator::LabelObjectComparator
LabelObjectComparator(LabelObjectComparator const &from)
Definition: itkLabelObjectAccessors.h:78
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:89
itk::Functor::LabelObjectReverseComparator::operator()
bool operator()(const LabelObjectType *a, const LabelObjectType *b) const
Definition: itkLabelObjectAccessors.h:91
itk::Functor::LabelLabelObjectAccessor
Definition: itkLabelObjectAccessors.h:38
itk::Functor::NumberOfLinesLabelObjectAccessor
Definition: itkLabelObjectAccessors.h:52
itk::Functor::LabelLabelObjectAccessor::AttributeValueType
typename LabelObjectType::LabelType AttributeValueType
Definition: itkLabelObjectAccessors.h:42