ITK  6.0.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 * https://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://doi.org/10.54294/q6auw4
29 *
30 */
31
32namespace itk
33{
34namespace Functor
35{
36template <typename TLabelObject>
38{
39public:
40 using LabelObjectType = TLabelObject;
41 using AttributeValueType = typename LabelObjectType::LabelType;
42
44 operator()(const LabelObjectType * labelObject) const
45 {
46 return labelObject->GetLabel();
47 }
48};
49
50template <typename TLabelObject>
52{
53public:
54 using LabelObjectType = TLabelObject;
55 using AttributeValueType = int;
56
58 operator()(const LabelObjectType * labelObject) const
59 {
60 return labelObject->GetNumberOfLines();
61 }
62};
63
64template <typename TLabelObject, typename TAttributeAccessor>
66{
67public:
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
78
79private:
81};
82
83template <typename TLabelObject, typename TAttributeAccessor>
85{
86public:
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
97
98private:
100};
101} // namespace Functor
102} // end namespace itk
103
104#endif
AttributeValueType operator()(const LabelObjectType *labelObject) const
typename LabelObjectType::LabelType AttributeValueType
bool operator()(const LabelObjectType *a, const LabelObjectType *b) const
LabelObjectComparator(LabelObjectComparator const &from)
bool operator()(const LabelObjectType *a, const LabelObjectType *b) const
LabelObjectReverseComparator(LabelObjectReverseComparator const &from)
AttributeValueType operator()(const LabelObjectType *labelObject) const
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....