ITK  5.3.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  * 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 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://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;
43 
44  inline AttributeValueType
45  operator()(const LabelObjectType * labelObject) const
46  {
47  return labelObject->GetNumberOfPixels();
48  }
49 };
50 
51 template <typename TLabelObject>
53 {
54 public:
55  using LabelObjectType = TLabelObject;
57 
58  inline AttributeValueType
59  operator()(const LabelObjectType * labelObject) const
60  {
61  return labelObject->GetBoundingBox();
62  }
63 };
64 
65 template <typename TLabelObject>
67 {
68 public:
69  using LabelObjectType = TLabelObject;
70  using AttributeValueType = double;
71 
72  inline AttributeValueType
73  operator()(const LabelObjectType * labelObject) const
74  {
75  return labelObject->GetPhysicalSize();
76  }
77 };
78 
79 template <typename TLabelObject>
81 {
82 public:
83  using LabelObjectType = TLabelObject;
85 
86  inline AttributeValueType
87  operator()(const LabelObjectType * labelObject) const
88  {
89  return labelObject->GetNumberOfPixelsOnBorder();
90  }
91 };
92 
93 template <typename TLabelObject>
95 {
96 public:
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 
107 template <typename TLabelObject>
109 {
110 public:
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 
121 template <typename TLabelObject>
123 {
124 public:
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 
135 template <typename TLabelObject>
137 {
138 public:
139  using LabelObjectType = TLabelObject;
141 
142  inline AttributeValueType
143  operator()(const LabelObjectType * labelObject) const
144  {
145  return labelObject->GetPrincipalMoments();
146  }
147 };
148 
149 template <typename TLabelObject>
151 {
152 public:
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 
163 template <typename TLabelObject>
165 {
166 public:
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 
177 template <typename TLabelObject>
179 {
180 public:
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 
191 template <typename TLabelObject>
193 {
194 public:
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 
205 template <typename TLabelObject>
207 {
208 public:
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 
219 template <typename TLabelObject>
221 {
222 public:
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 
233 template <typename TLabelObject>
235 {
236 public:
237  using LabelObjectType = TLabelObject;
239 
240  inline AttributeValueType
241  operator()(const LabelObjectType * labelObject) const
242  {
243  return labelObject->GetEquivalentEllipsoidDiameter();
244  }
245 };
246 
247 template <typename TLabelObject>
249 {
250 public:
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 
261 template <typename TLabelObject>
263 {
264 public:
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
itk::Functor::PerimeterOnBorderLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:101
itk::Functor::EquivalentSphericalRadiusLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:213
itk::Functor::BoundingBoxLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:52
itk::Functor::PrincipalAxesLabelObjectAccessor::AttributeValueType
typename LabelObjectType::MatrixType AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:154
itk::Functor::PhysicalSizeLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:69
itk::Functor::NumberOfPixelsLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:38
itk::Functor::PerimeterLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:178
itk::Functor::EquivalentSphericalPerimeterLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:223
itk::Functor::FlatnessLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:255
itk::Functor::PhysicalSizeLabelObjectAccessor::AttributeValueType
double AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:70
itk::GTest::TypedefsAndConstructors::Dimension2::VectorType
ImageBaseType::SpacingType VectorType
Definition: itkGTestTypedefsAndConstructors.h:53
itk::Functor::PerimeterOnBorderRatioLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:265
itk::Functor::PerimeterLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:181
itk::Functor::ElongationLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:164
itk::Functor::EquivalentEllipsoidDiameterLabelObjectAccessor::AttributeValueType
typename LabelObjectType::VectorType AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:238
itk::Functor::NumberOfPixelsOnBorderLabelObjectAccessor::AttributeValueType
SizeValueType AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:84
itk::Functor::EquivalentEllipsoidDiameterLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:237
itk::Functor::EquivalentSphericalRadiusLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:206
itk::Functor::PerimeterLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:185
itk::Functor::EquivalentSphericalRadiusLabelObjectAccessor::AttributeValueType
double AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:210
itk::Functor::PhysicalSizeLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:66
itk::Functor::NumberOfPixelsLabelObjectAccessor::AttributeValueType
SizeValueType AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:42
itk::Functor::FlatnessLabelObjectAccessor::AttributeValueType
double AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:252
itk::Functor::CentroidLabelObjectAccessor::AttributeValueType
typename LabelObjectType::CentroidType AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:112
itk::Functor::PerimeterLabelObjectAccessor::AttributeValueType
double AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:182
itk::Functor::PrincipalAxesLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:157
itk::Functor::CentroidLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:108
itk::Functor::PrincipalMomentsLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:143
itk::Functor::PhysicalSizeLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:73
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::Functor::CentroidLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:111
itk::Functor::FeretDiameterLabelObjectAccessor::AttributeValueType
double AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:126
itk::Functor::NumberOfPixelsLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:45
itk::Functor::PrincipalMomentsLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:139
itk::Functor::FlatnessLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:251
itk::Functor::NumberOfPixelsOnBorderLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:83
itk::Functor::EquivalentSphericalRadiusLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:209
itk::Functor::PerimeterOnBorderLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:94
itk::Functor::EquivalentSphericalPerimeterLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:227
itk::Functor::EquivalentEllipsoidDiameterLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:241
itk::Functor::PrincipalAxesLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:153
itkIntTypes.h
itk::Functor::RoundnessLabelObjectAccessor::AttributeValueType
double AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:196
itk::Functor::RoundnessLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:199
itk::Functor::PerimeterOnBorderRatioLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:262
itk::Functor::FeretDiameterLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:122
itk::Functor::CentroidLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:115
itk::Functor::NumberOfPixelsOnBorderLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:87
itk::Functor::PerimeterOnBorderRatioLabelObjectAccessor::AttributeValueType
double AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:266
itkLabelObjectAccessors.h
itk::Functor::ElongationLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:171
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Functor::ElongationLabelObjectAccessor::AttributeValueType
double AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:168
itk::Functor::EquivalentEllipsoidDiameterLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:234
itk::Functor::NumberOfPixelsLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:41
itk::Functor::PerimeterOnBorderLabelObjectAccessor::AttributeValueType
double AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:98
itk::Functor::FlatnessLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:248
itk::Functor::BoundingBoxLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:59
itk::Functor::EquivalentSphericalPerimeterLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:220
itk::Functor::FeretDiameterLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:129
itk::Functor::FeretDiameterLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:125
itk::Functor::BoundingBoxLabelObjectAccessor::AttributeValueType
typename LabelObjectType::RegionType AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:56
itk::Functor::RoundnessLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:195
itk::Functor::PrincipalAxesLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:150
itk::Functor::NumberOfPixelsOnBorderLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:80
itk::Functor::ElongationLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:167
itk::Functor::PrincipalMomentsLabelObjectAccessor::AttributeValueType
typename LabelObjectType::VectorType AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:140
itk::Functor::PerimeterOnBorderLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:97
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::Functor::EquivalentSphericalPerimeterLabelObjectAccessor::AttributeValueType
double AttributeValueType
Definition: itkShapeLabelObjectAccessors.h:224
itk::Functor::PrincipalMomentsLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:136
itk::Functor::RoundnessLabelObjectAccessor
Definition: itkShapeLabelObjectAccessors.h:192
itk::Functor::BoundingBoxLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkShapeLabelObjectAccessors.h:55
itk::Functor::PerimeterOnBorderRatioLabelObjectAccessor::operator()
AttributeValueType operator()(const LabelObjectType *labelObject) const
Definition: itkShapeLabelObjectAccessors.h:269