ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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::Functor
33{
34template <typename TLabelObject>
36{
37public:
38 using LabelObjectType = TLabelObject;
39 using AttributeValueType = typename LabelObjectType::LabelType;
40
42 operator()(const LabelObjectType * labelObject) const
43 {
44 return labelObject->GetLabel();
45 }
46};
47
48template <typename TLabelObject>
50{
51public:
52 using LabelObjectType = TLabelObject;
53 using AttributeValueType = int;
54
56 operator()(const LabelObjectType * labelObject) const
57 {
58 return labelObject->GetNumberOfLines();
59 }
60};
61
62template <typename TLabelObject, typename TAttributeAccessor>
64{
65public:
66 using LabelObjectType = TLabelObject;
67 using AttributeAccessorType = TAttributeAccessor;
68 bool
69 operator()(const LabelObjectType * a, const LabelObjectType * b) const
70 {
71 return m_Accessor(a) > m_Accessor(b);
72 }
73
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
99
100private:
102};
103} // namespace itk::Functor
104
105#endif
AttributeValueType operator()(const LabelObjectType *labelObject) const
typename LabelObjectType::LabelType AttributeValueType
LabelObjectComparator(const LabelObjectComparator &from)
bool operator()(const LabelObjectType *a, const LabelObjectType *b) const
bool operator()(const LabelObjectType *a, const LabelObjectType *b) const
LabelObjectReverseComparator(const LabelObjectReverseComparator &from)
AttributeValueType operator()(const LabelObjectType *labelObject) const