18 #ifndef __itkShapeLabelObject_h
19 #define __itkShapeLabelObject_h
41 template<
class TLabel,
unsigned int VImageDimension >
61 itkStaticConstMacro(ImageDimension,
unsigned int, VImageDimension);
67 typedef typename Superclass::LineType
LineType;
147 if ( s ==
"NumberOfPixels" )
149 return NUMBER_OF_PIXELS;
151 else if ( s ==
"PhysicalSize" )
153 return PHYSICAL_SIZE;
155 else if ( s ==
"Centroid" )
159 else if ( s ==
"BoundingBox" )
163 else if ( s ==
"NumberOfPixelsOnBorder" )
165 return NUMBER_OF_PIXELS_ON_BORDER;
167 else if ( s ==
"PerimeterOnBorder" )
169 return PERIMETER_ON_BORDER;
171 else if ( s ==
"FeretDiameter" )
173 return FERET_DIAMETER;
175 else if ( s ==
"PrincipalMoments" )
177 return PRINCIPAL_MOMENTS;
179 else if ( s ==
"PrincipalAxes" )
181 return PRINCIPAL_AXES;
183 else if ( s ==
"Elongation" )
187 else if ( s ==
"Perimeter" )
191 else if ( s ==
"Roundness" )
195 else if ( s ==
"EquivalentSphericalRadius" )
197 return EQUIVALENT_SPHERICAL_RADIUS;
199 else if ( s ==
"EquivalentSphericalPerimeter" )
201 return EQUIVALENT_SPHERICAL_PERIMETER;
203 else if ( s ==
"EquivalentEllipsoidDiameter" )
205 return EQUIVALENT_ELLIPSOID_DIAMETER;
207 else if ( s ==
"Flatness" )
211 else if ( s ==
"PerimeterOnBorderRatio" )
213 return PERIMETER_ON_BORDER_RATIO;
216 return Superclass::GetAttributeFromName(s);
224 case NUMBER_OF_PIXELS:
225 name =
"NumberOfPixels";
228 name =
"PhysicalSize";
234 name =
"BoundingBox";
236 case NUMBER_OF_PIXELS_ON_BORDER:
237 name =
"NumberOfPixelsOnBorder";
239 case PERIMETER_ON_BORDER:
240 name =
"PerimeterOnBorder";
243 name =
"FeretDiameter";
245 case PRINCIPAL_MOMENTS:
246 name =
"PrincipalMoments";
249 name =
"PrincipalAxes";
260 case EQUIVALENT_SPHERICAL_RADIUS:
261 name =
"EquivalentSphericalRadius";
263 case EQUIVALENT_SPHERICAL_PERIMETER:
264 name =
"EquivalentSphericalPerimeter";
266 case EQUIVALENT_ELLIPSOID_DIAMETER:
267 name =
"EquivalentEllipsoidDiameter";
272 case PERIMETER_ON_BORDER_RATIO:
273 name =
"PerimeterOnBorderRatio";
277 name = Superclass::GetNameFromAttribute(a);
293 return m_BoundingBox;
301 const double & GetPhysicalSize()
const
303 return m_PhysicalSize;
306 void SetPhysicalSize(
const double & v)
313 return m_NumberOfPixels;
318 m_NumberOfPixels = v;
328 m_Centroid = centroid;
333 return m_NumberOfPixelsOnBorder;
338 m_NumberOfPixelsOnBorder = v;
341 const double & GetPerimeterOnBorder()
const
343 return m_PerimeterOnBorder;
346 void SetPerimeterOnBorder(
const double & v)
348 m_PerimeterOnBorder = v;
351 const double & GetFeretDiameter()
const
353 return m_FeretDiameter;
356 void SetFeretDiameter(
const double & v)
363 return m_PrincipalMoments;
368 m_PrincipalMoments = v;
373 return m_PrincipalAxes;
381 const double & GetElongation()
const
386 void SetElongation(
const double & v)
391 const double & GetPerimeter()
const
396 void SetPerimeter(
const double & v)
401 const double & GetRoundness()
const
406 void SetRoundness(
const double & v)
411 const double & GetEquivalentSphericalRadius()
const
413 return m_EquivalentSphericalRadius;
416 void SetEquivalentSphericalRadius(
const double & v)
418 m_EquivalentSphericalRadius = v;
421 const double & GetEquivalentSphericalPerimeter()
const
423 return m_EquivalentSphericalPerimeter;
426 void SetEquivalentSphericalPerimeter(
const double & v)
428 m_EquivalentSphericalPerimeter = v;
433 return m_EquivalentEllipsoidDiameter;
438 m_EquivalentEllipsoidDiameter = v;
441 const double & GetFlatness()
const
446 void SetFlatness(
const double & v)
451 const double & GetPerimeterOnBorderRatio()
const
453 return m_PerimeterOnBorderRatio;
456 void SetPerimeterOnBorderRatio(
const double & v)
458 m_PerimeterOnBorderRatio = v;
474 for (
unsigned int i = 0; i < VImageDimension; i++ )
476 offset[i] = m_Centroid[i];
477 for (
unsigned int j = 0; j < VImageDimension; j++ )
479 matrix[j][i] = m_PrincipalAxes[i][j];
486 result->SetMatrix(matrix);
487 result->SetOffset(offset);
500 for (
unsigned int i = 0; i < VImageDimension; i++ )
502 offset[i] = m_Centroid[i];
503 for (
unsigned int j = 0; j < VImageDimension; j++ )
505 matrix[j][i] = m_PrincipalAxes[i][j];
511 result->SetMatrix(matrix);
512 result->SetOffset(offset);
515 result->GetInverse(inverse);
522 Superclass::CopyAttributesFrom(lo);
525 const Self *src =
dynamic_cast< const Self *
>( lo );
530 m_BoundingBox = src->m_BoundingBox;
531 m_NumberOfPixels = src->m_NumberOfPixels;
532 m_PhysicalSize = src->m_PhysicalSize;
533 m_Centroid = src->m_Centroid;
534 m_NumberOfPixelsOnBorder = src->m_NumberOfPixelsOnBorder;
535 m_PerimeterOnBorder = src->m_PerimeterOnBorder;
536 m_FeretDiameter = src->m_FeretDiameter;
537 m_PrincipalMoments = src->m_PrincipalMoments;
538 m_PrincipalAxes = src->m_PrincipalAxes;
539 m_Elongation = src->m_Elongation;
540 m_Perimeter = src->m_Perimeter;
541 m_Roundness = src->m_Roundness;
542 m_EquivalentSphericalRadius = src->m_EquivalentSphericalRadius;
543 m_EquivalentSphericalPerimeter = src->m_EquivalentSphericalPerimeter;
544 m_EquivalentEllipsoidDiameter = src->m_EquivalentEllipsoidDiameter;
545 m_Flatness = src->m_Flatness;
546 m_PerimeterOnBorderRatio = src->m_PerimeterOnBorderRatio;
552 m_NumberOfPixels = 0;
555 m_NumberOfPixelsOnBorder = 0;
556 m_PerimeterOnBorder = 0;
558 m_PrincipalMoments.Fill(0);
559 m_PrincipalAxes.Fill(0);
563 m_EquivalentSphericalRadius = 0;
564 m_EquivalentSphericalPerimeter = 0;
565 m_EquivalentEllipsoidDiameter.Fill(0);
567 m_PerimeterOnBorderRatio = 0;
570 void PrintSelf(std::ostream & os,
Indent indent)
const
572 Superclass::PrintSelf(os, indent);
574 os << indent <<
"NumberOfPixels: " << m_NumberOfPixels << std::endl;
575 os << indent <<
"PhysicalSize: " << m_PhysicalSize << std::endl;
576 os << indent <<
"Perimeter: " << m_Perimeter << std::endl;
577 os << indent <<
"NumberOfPixelsOnBorder: " << m_NumberOfPixelsOnBorder << std::endl;
578 os << indent <<
"PerimeterOnBorder: " << m_PerimeterOnBorder << std::endl;
579 os << indent <<
"PerimeterOnBorderRatio: " << m_PerimeterOnBorderRatio << std::endl;
580 os << indent <<
"Elongation: " << m_Elongation << std::endl;
581 os << indent <<
"Flatness: " << m_Flatness << std::endl;
582 os << indent <<
"Roundness: " << m_Roundness << std::endl;
583 os << indent <<
"Centroid: " << m_Centroid << std::endl;
584 os << indent <<
"BoundingBox: ";
585 m_BoundingBox.Print(os, indent);
586 os << indent <<
"EquivalentSphericalRadius: " << m_EquivalentSphericalRadius << std::endl;
587 os << indent <<
"EquivalentSphericalPerimeter: " << m_EquivalentSphericalPerimeter << std::endl;
588 os << indent <<
"EquivalentEllipsoidDiameter: " << m_EquivalentEllipsoidDiameter << std::endl;
589 os << indent <<
"PrincipalMoments: " << m_PrincipalMoments << std::endl;
590 os << indent <<
"PrincipalAxes: " << std::endl << m_PrincipalAxes;
591 os << indent <<
"FeretDiameter: " << m_FeretDiameter << std::endl;
596 void operator=(
const Self &);