MantisBT - ITK
View Issue Details
0005357ITKpublic2007-07-17 17:272010-10-21 11:12
Dan Homerick 
Luis Ibanez 
normalmajoralways
assignedopen 
ITK-4-A3 
 
backlog
0005357: PolygonSpatialObject cannot calculate area with 2D image
The Area() method depends on the Plane() method. Plane() is hard-coded for 3-D and doesn't work in 2-D (since min[2] != max[2], at least with gcc v4.1.2).

Best solution is to rewrite Plane to handle cases other than 3D properly. Quick solution is to add the special case:
if (TDimension == 2) return Coronal;
No tags attached.
Issue History
2008-01-23 17:07Luis IbanezAssigned ToLydia Ng => Luis Ibanez
2008-01-23 17:08Luis IbanezNote Added: 0010276
2008-01-23 17:08Luis IbanezStatusassigned => acknowledged
2008-04-29 11:01Luis IbanezStatusacknowledged => assigned
2008-04-29 11:01Luis IbanezAssigned ToLuis Ibanez => Brad Davis
2009-10-20 02:23mseiseNote Added: 0018120
2010-07-28 15:55pingkunyanNote Added: 0021527
2010-10-21 11:09Hans JohnsonAssigned ToBrad Davis => Luis Ibanez
2010-10-21 11:11Hans JohnsonNote Added: 0022565
2010-10-21 11:12Hans JohnsonSprint Status => backlog
2010-10-21 11:12Hans JohnsonProduct Version => ITK-4-A3

Notes
(0010276)
Luis Ibanez   
2008-01-23 17:08   
will fix code and add test.
(0018120)
mseise   
2009-10-20 02:23   
The same problem occurs when using the IsInside() method for a 2dimensional Polygon (PolygonSpatialObject< 2 >).
That method is used, for example, in SpatialObjectToImageFilter.
(0021527)
pingkunyan   
2010-07-28 15:55   
The bug still exists when calculating the area of a 2D polygon.

In line 32-35 of "itkPolygonSpatialObject.txx", it is hard coded that
  if (Self::ObjectDimension == 2)
    {
    return Axial;
    }

However, when calculating area, in line 156-157
    case Axial:
      X = 0; Y = 2;

For 2D case, this will never get the right Y location and thus give invalid area size.

A quick fix is to take mseise's suggestion:
  if (Self::ObjectDimension == 2)
    {
    return Coronal;
    }
(0022565)
Hans Johnson   
2010-10-21 11:11   
To be fixed in ITKv4