ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkShapeLabelObjectAccessors.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://hdl.handle.net/1926/584
30  * http://www.insight-journal.org/browse/publication/176
31  *
32  */
33 
34 namespace itk
35 {
36 namespace Functor
37 {
38 template< class TLabelObject >
40 {
41 public:
42  typedef TLabelObject LabelObjectType;
44 
45  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
46  {
47  return labelObject->GetNumberOfPixels();
48  }
49 };
50 
51 template< class TLabelObject >
53 {
54 public:
55  typedef TLabelObject LabelObjectType;
56  typedef typename LabelObjectType::RegionType AttributeValueType;
57 
58  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
59  {
60  return labelObject->GetBoundingBox();
61  }
62 };
63 
64 template< class TLabelObject >
66 {
67 public:
68  typedef TLabelObject LabelObjectType;
69  typedef double AttributeValueType;
70 
71  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
72  {
73  return labelObject->GetPhysicalSize();
74  }
75 };
76 
77 template< class TLabelObject >
79 {
80 public:
81  typedef TLabelObject LabelObjectType;
83 
84  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
85  {
86  return labelObject->GetNumberOfPixelsOnBorder();
87  }
88 };
89 
90 template< class TLabelObject >
92 {
93 public:
94  typedef TLabelObject LabelObjectType;
95  typedef double AttributeValueType;
96 
97  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
98  {
99  return labelObject->GetPerimeterOnBorder();
100  }
101 };
102 
103 template< class TLabelObject >
105 {
106 public:
107  typedef TLabelObject LabelObjectType;
108  typedef typename LabelObjectType::CentroidType AttributeValueType;
109 
110  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
111  {
112  return labelObject->GetCentroid();
113  }
114 };
115 
116 template< class TLabelObject >
118 {
119 public:
120  typedef TLabelObject LabelObjectType;
121  typedef double AttributeValueType;
122 
123  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
124  {
125  return labelObject->GetFeretDiameter();
126  }
127 };
128 
129 template< class TLabelObject >
131 {
132 public:
133  typedef TLabelObject LabelObjectType;
134  typedef typename LabelObjectType::VectorType AttributeValueType;
135 
136  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
137  {
138  return labelObject->GetPrincipalMoments();
139  }
140 };
141 
142 template< class TLabelObject >
144 {
145 public:
146  typedef TLabelObject LabelObjectType;
147  typedef typename LabelObjectType::MatrixType AttributeValueType;
148 
149  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
150  {
151  return labelObject->GetPrincipalAxes();
152  }
153 };
154 
155 template< class TLabelObject >
157 {
158 public:
159  typedef TLabelObject LabelObjectType;
160  typedef double AttributeValueType;
161 
162  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
163  {
164  return labelObject->GetElongation();
165  }
166 };
167 
168 template< class TLabelObject >
170 {
171 public:
172  typedef TLabelObject LabelObjectType;
173  typedef double AttributeValueType;
174 
175  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
176  {
177  return labelObject->GetPerimeter();
178  }
179 };
180 
181 template< class TLabelObject >
183 {
184 public:
185  typedef TLabelObject LabelObjectType;
186  typedef double AttributeValueType;
187 
188  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
189  {
190  return labelObject->GetRoundness();
191  }
192 };
193 
194 template< class TLabelObject >
196 {
197 public:
198  typedef TLabelObject LabelObjectType;
199  typedef double AttributeValueType;
200 
201  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
202  {
203  return labelObject->GetEquivalentSphericalRadius();
204  }
205 };
206 
207 template< class TLabelObject >
209 {
210 public:
211  typedef TLabelObject LabelObjectType;
212  typedef double AttributeValueType;
213 
214  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
215  {
216  return labelObject->GetEquivalentSphericalPerimeter();
217  }
218 };
219 
220 template< class TLabelObject >
222 {
223 public:
224  typedef TLabelObject LabelObjectType;
225  typedef typename LabelObjectType::VectorType AttributeValueType;
226 
227  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
228  {
229  return labelObject->GetEquivalentEllipsoidDiameter();
230  }
231 };
232 
233 template< class TLabelObject >
235 {
236 public:
237  typedef TLabelObject LabelObjectType;
238  typedef double AttributeValueType;
239 
240  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
241  {
242  return labelObject->GetFlatness();
243  }
244 };
245 
246 template< class TLabelObject >
248 {
249 public:
250  typedef TLabelObject LabelObjectType;
251  typedef double AttributeValueType;
252 
253  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
254  {
255  return labelObject->GetPerimeterOnBorderRatio();
256  }
257 };
258 
259 }
260 } // end namespace itk
261 
262 #endif
263