ITK  6.0.0
Insight Toolkit
itkShapeLabelObjectAccessors.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 itkShapeLabelObjectAccessors_h
19#define itkShapeLabelObjectAccessors_h
20
22#include "itkIntTypes.h"
23
24/*
25 *
26 * This code was contributed in the Insight Journal paper:
27 * "Label object representation and manipulation with ITK"
28 * by Lehmann G.
29 * https://doi.org/10.54294/q6auw4
30 *
31 */
32
33namespace itk
34{
35namespace Functor
36{
37template <typename TLabelObject>
39{
40public:
41 using LabelObjectType = TLabelObject;
43
45 operator()(const LabelObjectType * labelObject) const
46 {
47 return labelObject->GetNumberOfPixels();
48 }
49};
50
51template <typename TLabelObject>
53{
54public:
55 using LabelObjectType = TLabelObject;
57
59 operator()(const LabelObjectType * labelObject) const
60 {
61 return labelObject->GetBoundingBox();
62 }
63};
64
65template <typename TLabelObject>
67{
68public:
69 using LabelObjectType = TLabelObject;
70 using AttributeValueType = double;
71
73 operator()(const LabelObjectType * labelObject) const
74 {
75 return labelObject->GetPhysicalSize();
76 }
77};
78
79template <typename TLabelObject>
81{
82public:
83 using LabelObjectType = TLabelObject;
85
87 operator()(const LabelObjectType * labelObject) const
88 {
89 return labelObject->GetNumberOfPixelsOnBorder();
90 }
91};
92
93template <typename TLabelObject>
95{
96public:
97 using LabelObjectType = TLabelObject;
98 using AttributeValueType = double;
99
100 inline AttributeValueType
101 operator()(const LabelObjectType * labelObject) const
102 {
103 return labelObject->GetPerimeterOnBorder();
104 }
105};
106
107template <typename TLabelObject>
109{
110public:
111 using LabelObjectType = TLabelObject;
112 using AttributeValueType = typename LabelObjectType::CentroidType;
113
114 inline AttributeValueType
115 operator()(const LabelObjectType * labelObject) const
116 {
117 return labelObject->GetCentroid();
118 }
119};
120
121template <typename TLabelObject>
123{
124public:
125 using LabelObjectType = TLabelObject;
126 using AttributeValueType = double;
127
128 inline AttributeValueType
129 operator()(const LabelObjectType * labelObject) const
130 {
131 return labelObject->GetFeretDiameter();
132 }
133};
134
135template <typename TLabelObject>
137{
138public:
139 using LabelObjectType = TLabelObject;
141
142 inline AttributeValueType
143 operator()(const LabelObjectType * labelObject) const
144 {
145 return labelObject->GetPrincipalMoments();
146 }
147};
148
149template <typename TLabelObject>
151{
152public:
153 using LabelObjectType = TLabelObject;
154 using AttributeValueType = typename LabelObjectType::MatrixType;
155
156 inline AttributeValueType
157 operator()(const LabelObjectType * labelObject) const
158 {
159 return labelObject->GetPrincipalAxes();
160 }
161};
162
163template <typename TLabelObject>
165{
166public:
167 using LabelObjectType = TLabelObject;
168 using AttributeValueType = double;
169
170 inline AttributeValueType
171 operator()(const LabelObjectType * labelObject) const
172 {
173 return labelObject->GetElongation();
174 }
175};
176
177template <typename TLabelObject>
179{
180public:
181 using LabelObjectType = TLabelObject;
182 using AttributeValueType = double;
183
184 inline AttributeValueType
185 operator()(const LabelObjectType * labelObject) const
186 {
187 return labelObject->GetPerimeter();
188 }
189};
190
191template <typename TLabelObject>
193{
194public:
195 using LabelObjectType = TLabelObject;
196 using AttributeValueType = double;
197
198 inline AttributeValueType
199 operator()(const LabelObjectType * labelObject) const
200 {
201 return labelObject->GetRoundness();
202 }
203};
204
205template <typename TLabelObject>
207{
208public:
209 using LabelObjectType = TLabelObject;
210 using AttributeValueType = double;
211
212 inline AttributeValueType
213 operator()(const LabelObjectType * labelObject) const
214 {
215 return labelObject->GetEquivalentSphericalRadius();
216 }
217};
218
219template <typename TLabelObject>
221{
222public:
223 using LabelObjectType = TLabelObject;
224 using AttributeValueType = double;
225
226 inline AttributeValueType
227 operator()(const LabelObjectType * labelObject) const
228 {
229 return labelObject->GetEquivalentSphericalPerimeter();
230 }
231};
232
233template <typename TLabelObject>
235{
236public:
237 using LabelObjectType = TLabelObject;
239
240 inline AttributeValueType
241 operator()(const LabelObjectType * labelObject) const
242 {
243 return labelObject->GetEquivalentEllipsoidDiameter();
244 }
245};
246
247template <typename TLabelObject>
249{
250public:
251 using LabelObjectType = TLabelObject;
252 using AttributeValueType = double;
253
254 inline AttributeValueType
255 operator()(const LabelObjectType * labelObject) const
256 {
257 return labelObject->GetFlatness();
258 }
259};
260
261template <typename TLabelObject>
263{
264public:
265 using LabelObjectType = TLabelObject;
266 using AttributeValueType = double;
267
268 inline AttributeValueType
269 operator()(const LabelObjectType * labelObject) const
270 {
271 return labelObject->GetPerimeterOnBorderRatio();
272 }
273};
274
275} // namespace Functor
276} // end namespace itk
277
278#endif
AttributeValueType operator()(const LabelObjectType *labelObject) const
typename LabelObjectType::RegionType AttributeValueType
typename LabelObjectType::CentroidType AttributeValueType
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
typename LabelObjectType::MatrixType AttributeValueType
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86