[vtkusers] Once more -- how do I get the outline contours of regions in a mask/binary image

Karthik Krishnan karthik.krishnan at kitware.com
Thu Mar 27 16:49:27 EDT 2008


On 3/27/08, kent williams <nkwmailinglists at gmail.com> wrote:
>
> Here's what I want:
>
> Input: Image where pixel == 0 is outside mask pixel != 0 is inside mask
> Output: Polygon/Polyline outline of all regions of nonzero pixels in
> image.
>
> Reason: My program uses vtkContourWidget to trace anatomical features.
>

I've written what I think should work, below, but it looks really,
> really wrong when I load it -- it seems to be some woven agglomeration
> of many too many conour outlines.


I agree with Bill. I glanced at the code and I don't see a vtkStripper in
there. You need something that will massage the output of vtkContourFilter
or vtkMarchingSquares. The contour filters will generate a bunch of
un-ordered line segments.

vtkStripper should do the job for you (ie. generate one or more polylines
(with an ordered set of vertices)). You can then reduce the number of points
in this output (using the curvature based polyline subsampling code that you
seem to have below).

Your pipeline should look like

  vtkMarchingSquares -> vtkStripper -> SubsamplePolyline ->
vtkContourWidget.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080327/051dc3d2/attachment.htm>


More information about the vtkusers mailing list