[Insight-users] ContourExtractor2DImageFilter producing closed paths for line segments

David Doria daviddoria at gmail.com
Tue Jun 12 16:45:35 EDT 2012


In this example:
http://www.itk.org/Wiki/ITK/Examples/Segmentation/ContourExtractor2DImageFilter

I create an image of two simple line segments (values of 255 on an
otherwise 0 background). Then I extract them as contours using
ContourExtractor2DImageFilter. As it says in the documentation, this
filter generate closed paths. That is, I create a line like this:

  // Create another line of pixels
  for(unsigned int i = 10; i < 20; ++i)
    {
    itk::Index<2> pixel;
    pixel[0] = 10;
    pixel[1] = i;
    image->SetPixel(pixel, 255);
    }

and the path it returns is

[10.502, 19] // one end point
[10.4624, 18]
[10.4624, 17]
[10.4624, 16]
[10.4624, 15]
[10.4624, 14]
[10.4624, 13]
[10.4624, 12]
[10.4624, 11]
[10.502, 10] // the other end point! (how to detect this?)
[10, 9.58388]
[9.49804, 10]
[9.53758, 11]
[9.53758, 12]
[9.53758, 13]
[9.53758, 14]
[9.53758, 15]
[9.53758, 16]
[9.53758, 17]
[9.53758, 18]
[9.49804, 19]
[10, 19.4161]
[10.502, 19]

rather than just

[10.502, 19] // one end point
[10.4624, 18]
[10.4624, 17]
[10.4624, 16]
[10.4624, 15]
[10.4624, 14]
[10.4624, 13]
[10.4624, 12]
[10.4624, 11]
[10.502, 10]
[10, 9.58388] // the other end point

like I would like.

Is there any way to identify the endpoints of the contours produced by
this filter if the image indeed contains open contours like these line
segments?

Thanks,

David


More information about the Insight-users mailing list