[Insight-users] Polygon to Image Exception

Karthik Krishnan karthik.krishnan at kitware.com
Sat Jan 9 01:22:18 EST 2010


I fixed this error in the polygonspatialObject class a few weeks ago.
Please update to HEAD and let us know...

Thanks


----------------------------
revision 1.29
date: 2009-12-03 01:15:25 -0500;  author: karthik;  state: Exp;
lines: +6 -6;  commitid: JbCTuLHuUx3joTdu;
----------------------------
revision 1.28
date: 2009-12-02 00:23:14 -0500;  author: karthik;  state: Exp;
lines: +5 -4;  commitid: fK8zV6NxWgoo8Ldu;
ENH: Incorrect orientation of plane, causing false Evaluate results in
PolygonSpatialObject.
----------------------------
revision 1.27
date: 2009-10-23 03:57:25 -0400;  author: karthik;  state: Exp;
lines: +7 -2;  commitid: kxGiwqM4w4bXgD8u;
ENH: Planes should be computed only if the image dimension is greater
than or equal to 3


On Fri, Jan 8, 2010 at 2:51 PM, Jazz Kartell <jazzkartell at gmx.de> wrote:
> Hello,
>
> i want to store a convex hull of an object in an image...
> i had a look at:
> http://www.itk.org/pipermail/insight-users/2009-April/029800.html
> but i get the following error:
>
> terminate called after throwing an instance of 'itk::ExceptionObject'
>  what():  ...../Code/SpatialObject/itkPolygonSpatialObject.txx:426:
> non-planar polygon
>
> i don't understand that message, because the dimension of the polygon is set
> to 2, so it should be planar...
>
> perhaps someone could help me?
>
> Thanks in advance and best regards
>
>    //write convex hulls to file
>    typedef itk::PolygonSpatialObject<2>  PolygonType;
>    PolygonType::Pointer polygon = PolygonType::New();
>    PolygonType::PointType point;
>
>    polygon->ComputeObjectToWorldTransform();
>
>        for (int i=0; i< lower_hull.size(); i++){
>            std::pair<int,int> p = lower_hull[i];
>            point[0]=p.first;
>            point[1]=p.second;
>            polygon->AddPoint(point);
>        }
>        for (int i=upper_hull.size()-1; i>=0; i--){
>            std::pair<int,int> p = upper_hull[i];
>            point[0]=p.first;
>            point[1]=p.second;
>            polygon->AddPoint(point);
>        }
>
>    typedef itk::Image<double, 2> ImageType;
>    typedef itk::SpatialObjectToImageFilter< PolygonType, ImageType >
> SpatialObjectToImageFilterType;
>    ImageType::Pointer image = ImageType::New();
>    SpatialObjectToImageFilterType::Pointer imageFilter =
>  SpatialObjectToImageFilterType::New();
>
>    imageFilter->SetInput( polygon );
>    imageFilter->SetInsideValue(1);
>    imageFilter->SetOutsideValue(0);
>    polygon->SetThickness(1.0);
>
>    ImageType::SizeType size;
>    size[0] = 500;
>    size[1] = 500;
>    imageFilter->SetSize(size);
>
>    double origin[2];
>    origin[0] = 0.0;
>    origin[1] = 0.0;
>    imageFilter->SetOrigin(origin);
>
>    double spacing[2];
>    spacing[0] = 1.0;
>    spacing[1] = 1.0;
>    imageFilter->SetSpacing(spacing);
>    imageFilter->Update();
>
>    image = imageFilter->GetOutput();
>
>    typedef itk::ImageFileWriter<ImageType> WriterType;
>    WriterType::Pointer w = WriterType::New();
>
>    w->SetInput(image);
>    w->SetFileName("/home/bkirchholtes/out.jpg");
>    w->Update();
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list