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

kent williams nkwmailinglists at gmail.com
Fri Mar 28 14:39:36 EDT 2008


Thanks for your help, all you all ;-)

That kinda-sorta does what needs doing.  The 'kinda-sorta' means that
curvature based polyline subsampling only reduces the point count so
much. I'm working on something a little more thorough, and have
another question below. But first, background:

My goal is to load a binary image, and generate a set of contours
around the points inside the mask.  My test case is to use my program
to draw a contour, save a binary image using that contour, and then
try and read in the binary image and reconstruct a reasonable set of
contours corresponding to the binary image.

Since the ContourFilter generates a ton of points, and the
curvature-based culler doesn't remove very many of them, my supervisor
Hans Johnson suggested an algorithm to cull them further.

1. Compute the  area of the polygon to cull.
2. For each point on the polygon, remove it, and compute the area of
the new polygon. Throw out the point with the least difference in area
from the original.
3. Repeat step two until you either reduce the point count
sufficiently or you reach the maximum acceptable error.

At step two, I want to compute the area of the polygon described by
the bezier-curved contour, not the raw point outline.  My first
thought is 'oh the vtkContourRepresentation will give me the points
outlining the polygon defined by a set of control poitns!'
In other words, use a contour representation to do the conversion from
a list of control points, to an outline of the polygon.

This works, but there are a couple of issues here:

1. The ContourRepresentation requires a Renderer to work properly.
I've looked at the innards of vtkOrientedGlyphContourRepresentation,
and the Bezier curve stuff intersects with the Renderer only in that
it wants its points in World Coordinates.  But unless I actually
instantiate a vtkRenderWindow, vtkRenderWindowInteractor and
vtkRenderer, the Contour Representation just crashes for lack of
initialization of the Camera and other objects.

2. Pushing a list of points into the ContourRepresentation --
especially a large list -- is super slow.  I'm not sure yet where it's
spending it's time but it's on the order of a second on a lightly
loaded quad core Intel Mac.

So my questions are these: Is there an obvious way to speed this
process up? Am I missing something obvious that I can do to more
quickly decimate the point list?
On Thu, Mar 27, 2008 at 3:49 PM, Karthik Krishnan
<karthik.krishnan at kitware.com> wrote:
> On 3/27/08, kent williams <nkwmailinglists at gmail.com> wrote:
>
>   vtkMarchingSquares -> vtkStripper -> SubsamplePolyline ->
> vtkContourWidget.
>



More information about the vtkusers mailing list